@vertesia/ui 1.5.0-dev.20260910.052912Z → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/lib/core/components/Link.js +1 -1
  2. package/lib/core/components/Link.js.map +1 -1
  3. package/lib/core/components/Spinner.js +1 -1
  4. package/lib/core/components/Spinner.js.map +1 -1
  5. package/lib/core/components/TagsInput.js +7 -7
  6. package/lib/core/components/TagsInput.js.map +1 -1
  7. package/lib/core/components/shadcn/badge.js +1 -1
  8. package/lib/core/components/shadcn/badge.js.map +1 -1
  9. package/lib/core/components/shadcn/button.d.ts.map +1 -1
  10. package/lib/core/components/shadcn/button.js +2 -2
  11. package/lib/core/components/shadcn/button.js.map +1 -1
  12. package/lib/core/components/shadcn/filters/comboBox/DateCombobox.js +2 -2
  13. package/lib/core/components/shadcn/filters/comboBox/DateCombobox.js.map +1 -1
  14. package/lib/core/components/shadcn/filters/comboBox/SelectCombobox.js +1 -1
  15. package/lib/core/components/shadcn/filters/comboBox/SelectCombobox.js.map +1 -1
  16. package/lib/core/components/shadcn/filters/comboBox/StringListCombobox.js +1 -1
  17. package/lib/core/components/shadcn/filters/comboBox/StringListCombobox.js.map +1 -1
  18. package/lib/core/components/shadcn/filters/comboBox/TextCombobox.js +1 -1
  19. package/lib/core/components/shadcn/filters/comboBox/TextCombobox.js.map +1 -1
  20. package/lib/core/components/shadcn/filters/filter/dateFilter.js +1 -1
  21. package/lib/core/components/shadcn/filters/filter/dateFilter.js.map +1 -1
  22. package/lib/core/components/shadcn/filters/filters.js +1 -1
  23. package/lib/core/components/shadcn/filters/filters.js.map +1 -1
  24. package/lib/core/components/shadcn/overflowTabs.js +2 -2
  25. package/lib/core/components/shadcn/overflowTabs.js.map +1 -1
  26. package/lib/core/components/shadcn/tabs.js +1 -1
  27. package/lib/core/components/shadcn/tabs.js.map +1 -1
  28. package/lib/features/activity-doc/ActivityDoc.js +1 -1
  29. package/lib/features/activity-doc/ActivityDoc.js.map +1 -1
  30. package/lib/features/agent/chat/AskUserWidget.d.ts +1 -0
  31. package/lib/features/agent/chat/AskUserWidget.d.ts.map +1 -1
  32. package/lib/features/agent/chat/AskUserWidget.js +15 -4
  33. package/lib/features/agent/chat/AskUserWidget.js.map +1 -1
  34. package/lib/features/agent/chat/ModernAgentOutput/AllMessagesMixed.d.ts.map +1 -1
  35. package/lib/features/agent/chat/ModernAgentOutput/AllMessagesMixed.js +5 -3
  36. package/lib/features/agent/chat/ModernAgentOutput/AllMessagesMixed.js.map +1 -1
  37. package/lib/features/agent/chat/ModernAgentOutput/MessageItem.d.ts.map +1 -1
  38. package/lib/features/agent/chat/ModernAgentOutput/MessageItem.js +3 -2
  39. package/lib/features/agent/chat/ModernAgentOutput/MessageItem.js.map +1 -1
  40. package/lib/features/layout/GenericPageNavHeader.js +1 -1
  41. package/lib/features/layout/GenericPageNavHeader.js.map +1 -1
  42. package/lib/features/magic-pdf/AnnotatedImageSlider.js +1 -1
  43. package/lib/features/magic-pdf/AnnotatedImageSlider.js.map +1 -1
  44. package/lib/features/magic-pdf/GroundedExtractionView.js +3 -3
  45. package/lib/features/magic-pdf/GroundedExtractionView.js.map +1 -1
  46. package/lib/features/permissions/UserPermissionsProvider.js +1 -1
  47. package/lib/features/permissions/UserPermissionsProvider.js.map +1 -1
  48. package/lib/features/store/objects/DocumentPreviewPanel.js +5 -5
  49. package/lib/features/store/objects/DocumentPreviewPanel.js.map +1 -1
  50. package/lib/features/store/objects/components/DocumentInput.js +1 -1
  51. package/lib/features/store/objects/components/DocumentInput.js.map +1 -1
  52. package/lib/features/store/objects/upload/DocumentUploadModal.js +1 -1
  53. package/lib/features/store/objects/upload/DocumentUploadModal.js.map +1 -1
  54. package/lib/features/user/UserInfo.d.ts +2 -0
  55. package/lib/features/user/UserInfo.d.ts.map +1 -1
  56. package/lib/features/user/UserInfo.js +1 -1
  57. package/lib/features/user/UserInfo.js.map +1 -1
  58. package/lib/router/RouteComponent.d.ts.map +1 -1
  59. package/lib/router/RouteComponent.js +15 -12
  60. package/lib/router/RouteComponent.js.map +1 -1
  61. package/lib/session/UserSession.d.ts.map +1 -1
  62. package/lib/session/UserSession.js +4 -0
  63. package/lib/session/UserSession.js.map +1 -1
  64. package/lib/shell/SplashScreen.js +1 -1
  65. package/lib/shell/SplashScreen.js.map +1 -1
  66. package/lib/vertesia-ui-core.js +3 -3
  67. package/lib/vertesia-ui-core.js.map +1 -1
  68. package/lib/vertesia-ui-features.js +32 -32
  69. package/lib/vertesia-ui-features.js.map +1 -1
  70. package/lib/vertesia-ui-router.js +1 -1
  71. package/lib/vertesia-ui-router.js.map +1 -1
  72. package/lib/vertesia-ui-session.js +1 -1
  73. package/lib/vertesia-ui-session.js.map +1 -1
  74. package/lib/vertesia-ui-shell.js +1 -1
  75. package/lib/vertesia-ui-shell.js.map +1 -1
  76. package/lib/vertesia-ui-widgets.js +2 -2
  77. package/lib/vertesia-ui-widgets.js.map +1 -1
  78. package/lib/widgets/json-view/JSONCode.js +1 -1
  79. package/lib/widgets/json-view/JSONCode.js.map +1 -1
  80. package/lib/widgets/upload/DropZone.d.ts.map +1 -1
  81. package/lib/widgets/upload/DropZone.js +1 -1
  82. package/lib/widgets/upload/DropZone.js.map +1 -1
  83. package/package.json +7 -7
  84. package/src/core/components/Link.tsx +1 -1
  85. package/src/core/components/Spinner.tsx +1 -1
  86. package/src/core/components/TagsInput.tsx +7 -7
  87. package/src/core/components/shadcn/badge.tsx +1 -1
  88. package/src/core/components/shadcn/button.tsx +2 -3
  89. package/src/core/components/shadcn/filters/comboBox/DateCombobox.tsx +2 -2
  90. package/src/core/components/shadcn/filters/comboBox/SelectCombobox.tsx +1 -1
  91. package/src/core/components/shadcn/filters/comboBox/StringListCombobox.tsx +1 -1
  92. package/src/core/components/shadcn/filters/comboBox/TextCombobox.tsx +1 -1
  93. package/src/core/components/shadcn/filters/filter/dateFilter.tsx +1 -1
  94. package/src/core/components/shadcn/filters/filters.tsx +1 -1
  95. package/src/core/components/shadcn/overflowTabs.tsx +2 -2
  96. package/src/core/components/shadcn/tabs.tsx +1 -1
  97. package/src/css/utilities.css +7 -0
  98. package/src/features/activity-doc/ActivityDoc.tsx +1 -1
  99. package/src/features/agent/chat/AskUserWidget.test.tsx +24 -2
  100. package/src/features/agent/chat/AskUserWidget.tsx +19 -4
  101. package/src/features/agent/chat/ModernAgentOutput/AllMessagesMixed.test.tsx +62 -0
  102. package/src/features/agent/chat/ModernAgentOutput/AllMessagesMixed.tsx +8 -7
  103. package/src/features/agent/chat/ModernAgentOutput/MessageItem.tsx +4 -3
  104. package/src/features/layout/GenericPageNavHeader.test.tsx +36 -0
  105. package/src/features/layout/GenericPageNavHeader.tsx +1 -1
  106. package/src/features/magic-pdf/AnnotatedImageSlider.tsx +1 -1
  107. package/src/features/magic-pdf/GroundedExtractionView.tsx +3 -3
  108. package/src/features/permissions/UserPermissionsProvider.tsx +1 -1
  109. package/src/features/store/objects/DocumentPreviewPanel.tsx +10 -10
  110. package/src/features/store/objects/components/DocumentInput.tsx +1 -1
  111. package/src/features/store/objects/upload/DocumentUploadModal.tsx +1 -1
  112. package/src/features/user/UserInfo.tsx +1 -1
  113. package/src/router/RouteComponent.test.tsx +65 -1
  114. package/src/router/RouteComponent.tsx +18 -15
  115. package/src/session/UserSession.test.ts +65 -0
  116. package/src/session/UserSession.ts +4 -0
  117. package/src/shell/SplashScreen.tsx +1 -1
  118. package/src/widgets/json-view/JSONCode.test.tsx +2 -2
  119. package/src/widgets/json-view/JSONCode.tsx +1 -1
  120. package/src/widgets/upload/DropZone.tsx +2 -4
@@ -6,7 +6,7 @@ import{Fragment as e,jsx as t,jsxs as n}from"react/jsx-runtime";import{Avatar as
6
6
  ${_}px !important;
7
7
  ${v}px !important;
8
8
  }
9
- `),()=>{c.current?.removeAttribute(`data-motion-pop-id`),b.contains(y)&&b.removeChild(y)}},[n]),t(Ud,{isPresent:n,childRef:c,sizeRef:l,pop:o,children:o===!1?e:B.cloneElement(e,{ref:d})})}const Gd=({children:e,initial:n,isPresent:r,onExitComplete:i,custom:a,presenceAffectsLayout:o,mode:s,anchorX:c,anchorY:l,root:u})=>{let d=br(Kd),f=vt(),p=W(r),m=W(i);xr(()=>{p.current=r,m.current=i});let h=!0,g=U(()=>(h=!1,{id:f,initial:n,isPresent:r,custom:a,onExitComplete:e=>{d.set(e,!0);for(let e of d.values())if(!e)return;i&&i()},register:e=>(d.set(e,!1),()=>{d.delete(e),!p.current&&!d.size&&m.current?.()})}),[r,d,i]);return o&&h&&(g={...g}),U(()=>{d.forEach((e,t)=>d.set(t,!1))},[r]),B.useEffect(()=>{!r&&!d.size&&i&&i()},[r]),e=t(Wd,{pop:s===`popLayout`,isPresent:r,anchorX:c,anchorY:l,root:u,children:e}),t(Sr.Provider,{value:g,children:e})};function Kd(){return new Map}function qd(e=!0){let t=_t(Sr);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=vt();H(()=>{if(e)return i(a)},[e]);let o=V(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}const Jd=e=>e.key||``;function Yd(e){let t=[];return st.forEach(e,e=>{mt(e)&&t.push(e)}),t}const Xd=({children:n,custom:r,initial:i=!0,onExitComplete:a,presenceAffectsLayout:o=!0,mode:s=`sync`,propagate:c=!1,anchorX:l=`left`,anchorY:u=`top`,root:d})=>{let[f,p]=qd(c),m=U(()=>Yd(n),[n]),h=c&&!f?[]:m.map(Jd),g=W(!0),_=W(m),v=br(()=>new Map),y=W(new Set),[b,x]=G(m),[S,C]=G(m);xr(()=>{g.current=!1,_.current=m;for(let e=0;e<S.length;e++){let t=Jd(S[e]);h.includes(t)?(v.delete(t),y.current.delete(t)):v.get(t)!==!0&&v.set(t,!1)}},[S,h.length,h.join(`-`)]);let w=[];if(m!==b){let e=[...m];for(let t=0;t<S.length;t++){let n=S[t],r=Jd(n);h.includes(r)||(e.splice(t,0,n),w.push(n))}return s===`wait`&&w.length&&(e=w),C(Yd(e)),x(m),null}let{forceRender:T}=_t(yr);return t(e,{children:S.map(e=>{let n=Jd(e),b=c&&!f?!1:m===S||h.includes(n);return t(Gd,{isPresent:b,initial:!g.current||i?void 0:!1,custom:r,presenceAffectsLayout:o,mode:s,root:d,onExitComplete:b?void 0:()=>{if(y.current.has(n))return;if(v.has(n))y.current.add(n),v.set(n,!0);else return;let e=!0;v.forEach(t=>{t||(e=!1)}),e&&(T?.(),C(_.current),c&&p?.(),a&&a())},anchorX:l,anchorY:u,children:e},n)})})},Zd=dt({strict:!1}),Qd={animation:[`animate`,`variants`,`whileHover`,`whileTap`,`exit`,`whileInView`,`whileFocus`,`whileDrag`],exit:[`exit`],drag:[`drag`,`dragControls`],focus:[`whileFocus`],hover:[`whileHover`,`onHoverStart`,`onHoverEnd`],tap:[`whileTap`,`onTap`,`onTapStart`,`onTapCancel`],pan:[`onPan`,`onPanStart`,`onPanSessionStart`,`onPanEnd`],inView:[`whileInView`,`onViewportEnter`,`onViewportLeave`],layout:[`layout`,`layoutId`]};let $d=!1;function ef(){if($d)return;let e={};for(let t in Qd)e[t]={isEnabled:e=>Qd[t].some(t=>!!e[t])};ul(e),$d=!0}function tf(){return ef(),dl()}function nf(e){let t=tf();for(let n in e)t[n]={...t[n],...e[n]};ul(t)}const rf=new Set(`animate.exit.variants.initial.style.values.variants.transition.transformTemplate.custom.inherit.onBeforeLayoutMeasure.onAnimationStart.onAnimationComplete.onUpdate.onDragStart.onDrag.onDragEnd.onMeasureDragConstraints.onDirectionLock.onDragTransitionEnd._dragX._dragY.onHoverStart.onHoverEnd.onViewportEnter.onViewportLeave.globalTapTarget.propagate.ignoreStrict.viewport`.split(`.`));function af(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||rf.has(e)}let of=e=>!af(e);function sf(e){typeof e==`function`&&(of=t=>t.startsWith(`on`)?!af(t):e(t))}try{sf(vr(`@emotion/is-prop-valid`).default)}catch{}function cf(e,t,n){let r={};for(let i in e)(i!==`values`||typeof e.values!=`object`)&&(Es(e[i])||(of(i)||n===!0&&af(i)||!t&&!af(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]));return r}const lf=dt({});function uf(e,t){if(tl(e)){let{initial:t,animate:n}=e;return{initial:t===!1||Qc(t)?t:void 0,animate:Qc(n)?n:void 0}}return e.inherit===!1?{}:t}function df(e){let{initial:t,animate:n}=uf(e,_t(lf));return U(()=>({initial:t,animate:n}),[ff(t),ff(n)])}function ff(e){return Array.isArray(e)?e.join(` `):e}const pf=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function mf(e,t,n){for(let r in t)!Es(t[r])&&!Gl(r,n)&&(e[r]=t[r])}function hf({transformTemplate:e},t){return U(()=>{let n=pf();return zl(n,t,e),Object.assign({},n.vars,n.style)},[t])}function gf(e,t){let n=e.style||{},r={};return mf(r,n,e),Object.assign(r,hf(e,t)),r}function _f(e,t){let n={},r=gf(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout=`none`,r.touchAction=e.drag===!0?`none`:`pan-${e.drag===`x`?`y`:`x`}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}const vf=()=>({...pf(),attrs:{}});function yf(e,t,n,r){let i=U(()=>{let n=vf();return $l(n,t,tu(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};mf(t,e.style,e),i.style={...t,...i.style}}return i}const bf=[`animate`,`circle`,`defs`,`desc`,`ellipse`,`g`,`image`,`line`,`filter`,`marker`,`mask`,`metadata`,`path`,`pattern`,`polygon`,`polyline`,`rect`,`stop`,`switch`,`symbol`,`svg`,`text`,`tspan`,`use`,`view`];function xf(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(bf.indexOf(e)>-1||/[A-Z]/u.test(e))}function Sf(e,t,n,{latestValues:r},i,a=!1,o){let s=(o??xf(e)?yf:_f)(t,r,i,e),c=cf(t,typeof e==`string`,a),l=e===lt?{}:{...c,...s,ref:n},{children:u}=t,d=U(()=>Es(u)?u.get():u,[u]);return ft(e,{...l,children:d})}function Cf({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:wf(n,r,i,e),renderState:t()}}function wf(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=td(a[e]);let{initial:o,animate:s}=e,c=tl(e),l=nl(e);t&&l&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),s===void 0&&(s=t.animate));let u=n?n.initial===!1:!1;u||=o===!1;let d=u?s:o;if(d&&typeof d!=`boolean`&&!Zc(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=ys(e,t[n]);if(r){let{transitionEnd:e,transition:t,...n}=r;for(let e in n){let t=n[e];if(Array.isArray(t)){let e=u?t.length-1:0;t=t[e]}t!==null&&(i[e]=t)}for(let t in e)i[t]=e[t]}}}return i}const Tf=e=>(t,n)=>{let r=_t(lf),i=_t(Sr),a=()=>Cf(e,t,r,i);return n?a():br(a)},Ef=Tf({scrapeMotionValuesFromProps:Kl,createRenderState:pf}),Df=Tf({scrapeMotionValuesFromProps:ru,createRenderState:vf}),Of=Symbol.for(`motionComponentSymbol`);function kf(e,t,n){let r=W(n);yt(()=>{r.current=n});let i=W(null);return V(n=>{n&&e.onMount?.(n),t&&(n?t.mount(n):t.unmount());let a=r.current;if(typeof a==`function`){if(n){let e=a(n);typeof e==`function`&&(i.current=e)}else i.current?(i.current(),i.current=null):a(n)}else a&&(a.current=n)},[t])}const Af=dt({});function jf(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function Mf(e,t,n,r,i,a){let{visualElement:o}=_t(lf),s=_t(Zd),c=_t(Sr),l=_t(zd),u=l.reducedMotion,d=l.skipAnimations,f=W(null),p=W(!1);r||=s.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:d,isSVG:a}),p.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));let m=f.current,h=_t(Af);m&&!m.projection&&i&&(m.type===`html`||m.type===`svg`)&&Nf(f.current,n,i,h);let g=W(!1);yt(()=>{m&&g.current&&m.update(n,c)});let _=n[As],v=W(!!_&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(_)&&window.MotionHasOptimisedAnimation?.(_));return xr(()=>{p.current=!0,m&&(g.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),v.current&&m.animationState&&m.animationState.animateChanges())}),H(()=>{m&&(!v.current&&m.animationState&&m.animationState.animateChanges(),v.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(_)}),!1),m.enteringChildren=void 0)}),m}function Nf(e,t,n,r){let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:c,layoutRoot:l,layoutAnchor:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t[`data-framer-portal-id`]?void 0:Pf(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&jf(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function Pf(e){if(e)return e.options.allowProjection===!1?Pf(e.parent):e.projection}function Ff(e,{forwardMotionProps:r=!1,type:i}={},a,o){a&&nf(a);let s=i?i===`svg`:xf(e),c=s?Df:Ef;function l(i,l){let u,d={..._t(zd),...i,layoutId:If(i)},{isStatic:f}=d,p=df(i),m=c(i,f);if(!f&&typeof window<`u`){Lf(d,a);let t=Rf(d);u=t.MeasureLayout,p.visualElement=Mf(e,m,d,o,t.ProjectionNode,s)}return n(lf.Provider,{value:p,children:[u&&p.visualElement?t(u,{visualElement:p.visualElement,...d}):null,Sf(e,i,kf(m,p.visualElement,l),m,f,r,s)]})}l.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let u=pt(l);return u[Of]=e,u}function If({layoutId:e}){let t=_t(yr).id;return t&&e!==void 0?t+`-`+e:e}function Lf(e,t){_t(Zd).strict}function Rf(e){let{drag:t,layout:n}=tf();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function zf(e,t){if(typeof Proxy>`u`)return Ff;let n=new Map,r=(n,r)=>Ff(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,Ff(a,void 0,e,t)),n.get(a))})}const Bf=(e,t)=>t.isSVG??xf(e)?new iu(t):new Jl(t,{allowProjection:e!==lt});var Vf=class extends ml{constructor(e){super(e),e.animationState||=du(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();Zc(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}};let Hf=0;const Uf={animation:{Feature:Vf},exit:{Feature:class extends ml{constructor(){super(...arguments),this.id=Hf++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;let{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;if(e&&n===!1){if(this.isExitComplete){let{initial:e,custom:t}=this.node.getProps();if(typeof e==`string`||typeof e==`object`&&e&&!Array.isArray(e)){let n=bs(this.node,e,t);if(n){let{transition:e,transitionEnd:t,...r}=n;for(let e in r)this.node.getValue(e)?.jump(r[e])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive(`exit`,!1);this.isExitComplete=!1;return}let r=this.node.animationState.setActive(`exit`,!e);t&&!e&&r.then(()=>{this.isExitComplete=!0,t(this.id)})}mount(){let{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}}};function Wf(e){return{point:{x:e.pageX,y:e.pageY}}}const Gf=e=>t=>hc(t)&&e(t,Wf(t));function Kf(e,t,n,r){return Zu(e,t,Gf(n),r)}const qf=({current:e})=>e?e.ownerDocument.defaultView:null,Jf=(e,t)=>Math.abs(e-t);function Yf(e,t){let n=Jf(e.x,t.x),r=Jf(e.y,t.y);return Math.sqrt(n**2+r**2)}const Xf=new Set([`auto`,`scroll`]);var Zf=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=Qf(this.lastRawMoveEventInfo,this.transformPagePoint));let e=ep(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=Yf(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=li;this.history.push({...r,timestamp:i});let{onStart:a,onMove:o}=this.handlers;t||(a&&a(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),o&&o(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastRawMoveEventInfo=t,this.lastMoveEventInfo=Qf(t,this.transformPagePoint),si.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();let{onEnd:n,onSessionEnd:r,resumeAnimation:i}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&i&&i(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=ep(e.type===`pointercancel`?this.lastMoveEventInfo:Qf(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!hc(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=Qf(Wf(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=li;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,ep(s,this.history));let d={passive:!0,capture:!0};this.removeListeners=Mr(Kf(this.contextWindow,`pointermove`,this.handlePointerMove,d),Kf(this.contextWindow,`pointerup`,this.handlePointerUp,d),Kf(this.contextWindow,`pointercancel`,this.handlePointerUp,d)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(Xf.has(e.overflowX)||Xf.has(e.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.addEventListener(`scroll`,this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.removeEventListener(`scroll`,this.onWindowScroll)}}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-t.x,y:r.y-t.y};(i.x!==0||i.y!==0)&&(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),si.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),ci(this.updatePoint)}};function Qf(e,t){return t?{point:t(e.point)}:e}function $f(e,t){return{x:e.x-t.x,y:e.y-t.y}}function ep({point:e},t){return{point:e,delta:$f(e,np(t)),offset:$f(e,tp(t)),velocity:rp(t,.1)}}function tp(e){return e[0]}function np(e){return e[e.length-1]}function rp(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=np(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>Fr(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>Fr(t)*2&&(r=e[1]);let a=Ir(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};let o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function ip(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?aa(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?aa(n,e,r.max):Math.min(e,n)),e}function ap(e,t,n){return{min:t===void 0?void 0:e.min+t,max:n===void 0?void 0:e.max+n-(e.max-e.min)}}function op(e,{top:t,left:n,bottom:r,right:i}){return{x:ap(e.x,n,i),y:ap(e.y,t,r)}}function sp(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function cp(e,t){return{x:sp(e.x,t.x),y:sp(e.y,t.y)}}function lp(e,t){let n=.5,r=vu(e),i=vu(t);return i>r?n=Nr(t.min,t.max-r,e.min):r>i&&(n=Nr(e.min,e.max-i,t.min)),Tr(0,1,n)}function up(e,t){let n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const dp=.35;function fp(e=dp){return e===!1?e=0:e===!0&&(e=dp),{x:pp(e,`left`,`right`),y:pp(e,`top`,`bottom`)}}function pp(e,t,n){return{min:mp(e,t),max:mp(e,n)}}function mp(e,t){return typeof e==`number`?e:e[t]||0}const hp=new WeakMap;var gp=class{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Yc(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){let{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;let i=e=>{t&&this.snapToCursor(Wf(e).point),this.stopAnimation()},a=(e,t)=>{let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock&&this.openDragLock(),this.openDragLock=uc(n),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Bu(e=>{let t=this.getAxisMotionValue(e).get()||0;if(Ii.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=vu(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&si.update(()=>i(e,t),!1,!0),Os(this.visualElement,`transform`);let{animationState:a}=this.visualElement;a&&a.setActive(`whileDrag`,!0)},o=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;let{dragPropagation:n,dragDirectionLock:r,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;let{offset:o}=t;if(r&&this.currentDirection===null){this.currentDirection=bp(o),this.currentDirection!==null&&i&&i(this.currentDirection);return}this.updateAxis(`x`,t.point,o),this.updateAxis(`y`,t.point,o),this.visualElement.render(),a&&si.update(()=>a(e,t),!1,!0)},s=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{let{dragSnapToOrigin:e}=this.getProps();(e||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:l}=this.getProps();this.panSession=new Zf(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:qf(this.visualElement),element:this.visualElement.current})}stop(e,t){let n=e||this.latestPointerEvent,r=t||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!n)return;let{velocity:a}=r;this.startAnimation(a);let{onDragEnd:o}=this.getProps();o&&si.postRender(()=>o(n,r))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();let{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive(`whileDrag`,!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,n){let{drag:r}=this.getProps();if(!n||!yp(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=ip(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&jf(e)?this.constraints||=this.resolveRefConstraints():this.constraints=e&&n?op(n.layoutBox,e):!1,this.elastic=fp(t),r!==this.constraints&&!jf(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&Bu(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=up(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!jf(e))return!1;let n=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;r.root&&(r.root.scroll=void 0,r.root.updateScroll());let i=Fl(n,r.root,this.visualElement.getTransformPagePoint()),a=cp(r.layout.layoutBox,i);if(t){let e=t(gl(a));this.hasMutatedConstraints=!!e,e&&(a=hl(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=Bu(o=>{if(!yp(o,t,this.currentDirection))return;let c=s&&s[o]||{};(a===!0||a===o)&&(c={min:0,max:0});let l=r?200:1e6,u=r?40:1e7,d={type:`inertia`,velocity:n?e[o]:0,bounceStiffness:l,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(o,d)});return Promise.all(c).then(o)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return Os(this.visualElement,e),n.start(ms(e,n,0,t,this.visualElement,!1))}stopAnimation(){Bu(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`;return this.visualElement.getProps()[t]||this.visualElement.getValue(e,this.visualElement.latestValues[e]??0)}snapToCursor(e){Bu(t=>{let{drag:n}=this.getProps();if(!yp(t,n,this.currentDirection))return;let{projection:r}=this.visualElement,i=this.getAxisMotionValue(t);if(r&&r.layout){let{min:n,max:a}=r.layout.layoutBox[t],o=i.get()||0;i.set(e[t]-aa(n,a,.5)+o)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!jf(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};Bu(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=lp({min:n,max:n},this.constraints[e])}});let{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},``):`none`,n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),Bu(t=>{if(!yp(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(aa(i,a,r[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;hp.set(this.visualElement,this);let e=this.visualElement.current,t=Kf(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&yc(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();jf(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=vp(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),si.read(r);let o=Zu(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(Bu(t=>{let n=this.getAxisMotionValue(t);n&&(this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate))}),this.visualElement.render())}));return()=>{o(),t(),a(),s&&s(),n&&n()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=dp,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function _p(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function vp(e,t,n){let r=Vc(e,_p(n)),i=Vc(t,_p(n));return()=>{r(),i()}}function yp(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function bp(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var xp=class extends ml{constructor(e){super(e),this.removeGroupControls=jr,this.removeListeners=jr,this.controls=new gp(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||jr}update(){let{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}};const Sp=e=>(t,n)=>{e&&si.update(()=>e(t,n),!1,!0)};var Cp=class extends ml{constructor(){super(...arguments),this.removePointerDownListener=jr}onPointerDown(e){this.session=new Zf(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:qf(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:Sp(e),onStart:Sp(t),onMove:Sp(n),onEnd:(e,t)=>{delete this.session,r&&si.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=Kf(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}};let wp=!1;var Tp=class extends ct{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group&&t.group.add(i),n&&n.register&&r&&n.register(i),wp&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),rd.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:n,drag:r,isPresent:i}=this.props,{projection:a}=n;return a?(a.isPresent=i,e.layoutDependency!==t&&a.setOptions({...a.options,layoutDependency:t}),wp=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||si.postRender(()=>{let e=a.getStack();(!e||!e.members.length)&&this.safeToRemove()})),null):null}componentDidUpdate(){let{visualElement:e,layoutAnchor:t}=this.props,{projection:n}=e;n&&(n.options.layoutAnchor=t,n.root.didUpdate(),oc.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;wp=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function Ep(e){let[n,r]=qd(),i=_t(yr);return t(Tp,{...e,layoutGroup:i,switchLayoutGroup:_t(Af),isPresent:n,safeToRemove:r})}const Dp={pan:{Feature:Cp},drag:{Feature:xp,ProjectionNode:Rd,MeasureLayout:Ep}};function Op(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&si.postRender(()=>i(t,Wf(t)))}var kp=class extends ml{mount(){let{current:e}=this.node;e&&(this.unmount=pc(e,(e,t)=>(Op(this.node,t,`Start`),e=>Op(this.node,e,`End`))))}unmount(){}},Ap=class extends ml{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(`:focus-visible`)}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!1),this.isActive=!1)}mount(){this.unmount=Mr(Zu(this.node.current,`focus`,()=>this.onFocus()),Zu(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function jp(e,t,n){let{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive(`whileTap`,n===`Start`);let i=r[`onTap`+(n===`End`?``:n)];i&&si.postRender(()=>i(t,Wf(t)))}var Mp=class extends ml{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=Ec(e,(e,t)=>(jp(this.node,t,`Start`),(e,{success:t})=>jp(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}};const Np=new WeakMap,Pp=new WeakMap,Fp=e=>{let t=Np.get(e.target);t&&t(e)},Ip=e=>{e.forEach(Fp)};function Lp({root:e,...t}){let n=e||document;Pp.has(n)||Pp.set(n,{});let r=Pp.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(Ip,{root:e,...t})),r[i]}function Rp(e,t,n){let r=Lp(t);return Np.set(e,n),r.observe(e),()=>{Np.delete(e),r.unobserve(e)}}const zp={some:0,all:1};var Bp=class extends ml{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r=`some`,once:i}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r==`number`?r:zp[r]},o=e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive(`whileInView`,t);let{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),a=t?n:r;a&&a(e)};this.stopObserver=Rp(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(Vp(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function Vp({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const Hp={inView:{Feature:Bp},tap:{Feature:Mp},focus:{Feature:Ap},hover:{Feature:kp}},Up={layout:{ProjectionNode:Rd,MeasureLayout:Ep}},Wp=zf({...Uf,...Hp,...Dp,...Up},Bf);function Gp({children:e,secondary:n=!1}){return t(`span`,{className:n?`bg-secondary text-primary`:`text-foreground bg-muted`,children:e})}function Kp(e){if(e)return e.name===`array`?Kp(e.innerType):e}function qp({property:e}){return n(`div`,{className:`flex items-center gap-x-2`,children:[t(`div`,{className:`font-semibold text-muted`,children:e.name}),e.optional&&t(Gp,{children:`optional`}),t(Gp,{children:e.type.value})]})}function Jp({activities:e}){return t(`div`,{className:`flex flex-col gap-y-4 divide-y divide-border`,children:e.map(e=>t(Xp,{activity:e},e.name))})}function Yp({code:e,children:r}){return n(`div`,{className:`flex gap-2 items-center border-b border-b-border mb-2`,children:[t(`div`,{className:`text-lg font-medium text-foreground py-2 `,children:r}),e&&t(`div`,{children:t(Gp,{children:e})})]})}function Xp({activity:e,headingClass:r,headingRef:i}){return n(`div`,{className:r,id:e.name,ref:i,children:[t(`div`,{className:`text-xl font-semibold pt-8`,children:e.title}),t(`div`,{className:`pb-4`,children:t(Gp,{children:e.name})}),e.doc&&t(`div`,{className:`text-foreground pb-2`,children:e.doc}),n(`div`,{className:`pb-4`,children:[t(Yp,{code:e.paramsType,children:`Parameters`}),t(`div`,{className:`divide-y divide-border`,children:e.params.map(e=>t(Zp,{property:e},e.name))})]}),n(`div`,{className:`pb-4`,children:[t(Yp,{children:`Returns`}),t(`div`,{children:e.returnType?e.returnType.value:`void`})]})]})}function Zp({property:e,className:r}){let i=U(()=>{let n=Kp(e.type.innerType)??e.type;return n.name===`object`&&n.members?t($p,{members:n.members}):n.name===`enum`&&n.enum?t(Qp,{values:n.enum}):null},[e.type]);return n(`div`,{className:it(`py-2`,r),children:[t(qp,{property:e}),e.doc&&t(`div`,{className:`text-foreground text-sm pt-2`,children:e.doc}),i&&t(`div`,{className:`my-2 overflow-hidden`,children:i})]})}function Qp({values:e}){return t(`div`,{className:`flex flex-wrap items-center gap-2`,children:e.map(e=>t(Gp,{secondary:!0,children:e},e))})}function $p({members:e}){return t(tm,{className:`rounded-md border border-border`,button:e=>n(`div`,{className:`px-4 py-2 flex items-center gap-x-2 text-sm font-medium hover:text-info`,children:[t(nm,{isOpen:e}),e?t(`div`,{children:`Hide child properties`}):t(`div`,{children:`Show child properties`})]}),body:t(em,{properties:e})})}function em({properties:e}){return t(`div`,{className:`border-s-2 border-s-info flex flex-col divide-y divide-border border-t border-t-border`,children:e.map(e=>t(Zp,{property:e,className:`px-4 py-2`},e.name))})}function tm({button:e,body:r,className:i,isInitiallyOpen:a}){let[s,c]=G(a||!1);return n(`div`,{className:it(s?`block`:`inline-block`,i),children:[t(o,{variant:`unstyled`,className:`p-0 m-0 bg-transparent`,onClick:()=>c(!s),children:t(Xd,{children:e(s)})}),t(Xd,{children:s&&t(Wp.div,{className:`overflow-hidden`,initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.3,ease:`easeOut`},children:r})})]})}function nm({isOpen:e}){return t(Xd,{propagate:!0,mode:`wait`,children:t(Wp.div,{className:`font-mono font-semibold text-muted text-lg`,initial:{rotate:0},animate:{rotate:e?45:0},transition:{duration:.2},children:`+`},`closeIcon`)})}var rm,im=Y((()=>{rm=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim()
9
+ `),()=>{c.current?.removeAttribute(`data-motion-pop-id`),b.contains(y)&&b.removeChild(y)}},[n]),t(Ud,{isPresent:n,childRef:c,sizeRef:l,pop:o,children:o===!1?e:B.cloneElement(e,{ref:d})})}const Gd=({children:e,initial:n,isPresent:r,onExitComplete:i,custom:a,presenceAffectsLayout:o,mode:s,anchorX:c,anchorY:l,root:u})=>{let d=br(Kd),f=vt(),p=W(r),m=W(i);xr(()=>{p.current=r,m.current=i});let h=!0,g=U(()=>(h=!1,{id:f,initial:n,isPresent:r,custom:a,onExitComplete:e=>{d.set(e,!0);for(let e of d.values())if(!e)return;i&&i()},register:e=>(d.set(e,!1),()=>{d.delete(e),!p.current&&!d.size&&m.current?.()})}),[r,d,i]);return o&&h&&(g={...g}),U(()=>{d.forEach((e,t)=>d.set(t,!1))},[r]),B.useEffect(()=>{!r&&!d.size&&i&&i()},[r]),e=t(Wd,{pop:s===`popLayout`,isPresent:r,anchorX:c,anchorY:l,root:u,children:e}),t(Sr.Provider,{value:g,children:e})};function Kd(){return new Map}function qd(e=!0){let t=_t(Sr);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=vt();H(()=>{if(e)return i(a)},[e]);let o=V(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}const Jd=e=>e.key||``;function Yd(e){let t=[];return st.forEach(e,e=>{mt(e)&&t.push(e)}),t}const Xd=({children:n,custom:r,initial:i=!0,onExitComplete:a,presenceAffectsLayout:o=!0,mode:s=`sync`,propagate:c=!1,anchorX:l=`left`,anchorY:u=`top`,root:d})=>{let[f,p]=qd(c),m=U(()=>Yd(n),[n]),h=c&&!f?[]:m.map(Jd),g=W(!0),_=W(m),v=br(()=>new Map),y=W(new Set),[b,x]=G(m),[S,C]=G(m);xr(()=>{g.current=!1,_.current=m;for(let e=0;e<S.length;e++){let t=Jd(S[e]);h.includes(t)?(v.delete(t),y.current.delete(t)):v.get(t)!==!0&&v.set(t,!1)}},[S,h.length,h.join(`-`)]);let w=[];if(m!==b){let e=[...m];for(let t=0;t<S.length;t++){let n=S[t],r=Jd(n);h.includes(r)||(e.splice(t,0,n),w.push(n))}return s===`wait`&&w.length&&(e=w),C(Yd(e)),x(m),null}let{forceRender:T}=_t(yr);return t(e,{children:S.map(e=>{let n=Jd(e),b=c&&!f?!1:m===S||h.includes(n);return t(Gd,{isPresent:b,initial:!g.current||i?void 0:!1,custom:r,presenceAffectsLayout:o,mode:s,root:d,onExitComplete:b?void 0:()=>{if(y.current.has(n))return;if(v.has(n))y.current.add(n),v.set(n,!0);else return;let e=!0;v.forEach(t=>{t||(e=!1)}),e&&(T?.(),C(_.current),c&&p?.(),a&&a())},anchorX:l,anchorY:u,children:e},n)})})},Zd=dt({strict:!1}),Qd={animation:[`animate`,`variants`,`whileHover`,`whileTap`,`exit`,`whileInView`,`whileFocus`,`whileDrag`],exit:[`exit`],drag:[`drag`,`dragControls`],focus:[`whileFocus`],hover:[`whileHover`,`onHoverStart`,`onHoverEnd`],tap:[`whileTap`,`onTap`,`onTapStart`,`onTapCancel`],pan:[`onPan`,`onPanStart`,`onPanSessionStart`,`onPanEnd`],inView:[`whileInView`,`onViewportEnter`,`onViewportLeave`],layout:[`layout`,`layoutId`]};let $d=!1;function ef(){if($d)return;let e={};for(let t in Qd)e[t]={isEnabled:e=>Qd[t].some(t=>!!e[t])};ul(e),$d=!0}function tf(){return ef(),dl()}function nf(e){let t=tf();for(let n in e)t[n]={...t[n],...e[n]};ul(t)}const rf=new Set(`animate.exit.variants.initial.style.values.variants.transition.transformTemplate.custom.inherit.onBeforeLayoutMeasure.onAnimationStart.onAnimationComplete.onUpdate.onDragStart.onDrag.onDragEnd.onMeasureDragConstraints.onDirectionLock.onDragTransitionEnd._dragX._dragY.onHoverStart.onHoverEnd.onViewportEnter.onViewportLeave.globalTapTarget.propagate.ignoreStrict.viewport`.split(`.`));function af(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||rf.has(e)}let of=e=>!af(e);function sf(e){typeof e==`function`&&(of=t=>t.startsWith(`on`)?!af(t):e(t))}try{sf(vr(`@emotion/is-prop-valid`).default)}catch{}function cf(e,t,n){let r={};for(let i in e)(i!==`values`||typeof e.values!=`object`)&&(Es(e[i])||(of(i)||n===!0&&af(i)||!t&&!af(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]));return r}const lf=dt({});function uf(e,t){if(tl(e)){let{initial:t,animate:n}=e;return{initial:t===!1||Qc(t)?t:void 0,animate:Qc(n)?n:void 0}}return e.inherit===!1?{}:t}function df(e){let{initial:t,animate:n}=uf(e,_t(lf));return U(()=>({initial:t,animate:n}),[ff(t),ff(n)])}function ff(e){return Array.isArray(e)?e.join(` `):e}const pf=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function mf(e,t,n){for(let r in t)!Es(t[r])&&!Gl(r,n)&&(e[r]=t[r])}function hf({transformTemplate:e},t){return U(()=>{let n=pf();return zl(n,t,e),Object.assign({},n.vars,n.style)},[t])}function gf(e,t){let n=e.style||{},r={};return mf(r,n,e),Object.assign(r,hf(e,t)),r}function _f(e,t){let n={},r=gf(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout=`none`,r.touchAction=e.drag===!0?`none`:`pan-${e.drag===`x`?`y`:`x`}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}const vf=()=>({...pf(),attrs:{}});function yf(e,t,n,r){let i=U(()=>{let n=vf();return $l(n,t,tu(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};mf(t,e.style,e),i.style={...t,...i.style}}return i}const bf=[`animate`,`circle`,`defs`,`desc`,`ellipse`,`g`,`image`,`line`,`filter`,`marker`,`mask`,`metadata`,`path`,`pattern`,`polygon`,`polyline`,`rect`,`stop`,`switch`,`symbol`,`svg`,`text`,`tspan`,`use`,`view`];function xf(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(bf.indexOf(e)>-1||/[A-Z]/u.test(e))}function Sf(e,t,n,{latestValues:r},i,a=!1,o){let s=(o??xf(e)?yf:_f)(t,r,i,e),c=cf(t,typeof e==`string`,a),l=e===lt?{}:{...c,...s,ref:n},{children:u}=t,d=U(()=>Es(u)?u.get():u,[u]);return ft(e,{...l,children:d})}function Cf({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:wf(n,r,i,e),renderState:t()}}function wf(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=td(a[e]);let{initial:o,animate:s}=e,c=tl(e),l=nl(e);t&&l&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),s===void 0&&(s=t.animate));let u=n?n.initial===!1:!1;u||=o===!1;let d=u?s:o;if(d&&typeof d!=`boolean`&&!Zc(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=ys(e,t[n]);if(r){let{transitionEnd:e,transition:t,...n}=r;for(let e in n){let t=n[e];if(Array.isArray(t)){let e=u?t.length-1:0;t=t[e]}t!==null&&(i[e]=t)}for(let t in e)i[t]=e[t]}}}return i}const Tf=e=>(t,n)=>{let r=_t(lf),i=_t(Sr),a=()=>Cf(e,t,r,i);return n?a():br(a)},Ef=Tf({scrapeMotionValuesFromProps:Kl,createRenderState:pf}),Df=Tf({scrapeMotionValuesFromProps:ru,createRenderState:vf}),Of=Symbol.for(`motionComponentSymbol`);function kf(e,t,n){let r=W(n);yt(()=>{r.current=n});let i=W(null);return V(n=>{n&&e.onMount?.(n),t&&(n?t.mount(n):t.unmount());let a=r.current;if(typeof a==`function`){if(n){let e=a(n);typeof e==`function`&&(i.current=e)}else i.current?(i.current(),i.current=null):a(n)}else a&&(a.current=n)},[t])}const Af=dt({});function jf(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function Mf(e,t,n,r,i,a){let{visualElement:o}=_t(lf),s=_t(Zd),c=_t(Sr),l=_t(zd),u=l.reducedMotion,d=l.skipAnimations,f=W(null),p=W(!1);r||=s.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:d,isSVG:a}),p.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));let m=f.current,h=_t(Af);m&&!m.projection&&i&&(m.type===`html`||m.type===`svg`)&&Nf(f.current,n,i,h);let g=W(!1);yt(()=>{m&&g.current&&m.update(n,c)});let _=n[As],v=W(!!_&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(_)&&window.MotionHasOptimisedAnimation?.(_));return xr(()=>{p.current=!0,m&&(g.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),v.current&&m.animationState&&m.animationState.animateChanges())}),H(()=>{m&&(!v.current&&m.animationState&&m.animationState.animateChanges(),v.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(_)}),!1),m.enteringChildren=void 0)}),m}function Nf(e,t,n,r){let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:c,layoutRoot:l,layoutAnchor:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t[`data-framer-portal-id`]?void 0:Pf(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&jf(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function Pf(e){if(e)return e.options.allowProjection===!1?Pf(e.parent):e.projection}function Ff(e,{forwardMotionProps:r=!1,type:i}={},a,o){a&&nf(a);let s=i?i===`svg`:xf(e),c=s?Df:Ef;function l(i,l){let u,d={..._t(zd),...i,layoutId:If(i)},{isStatic:f}=d,p=df(i),m=c(i,f);if(!f&&typeof window<`u`){Lf(d,a);let t=Rf(d);u=t.MeasureLayout,p.visualElement=Mf(e,m,d,o,t.ProjectionNode,s)}return n(lf.Provider,{value:p,children:[u&&p.visualElement?t(u,{visualElement:p.visualElement,...d}):null,Sf(e,i,kf(m,p.visualElement,l),m,f,r,s)]})}l.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let u=pt(l);return u[Of]=e,u}function If({layoutId:e}){let t=_t(yr).id;return t&&e!==void 0?t+`-`+e:e}function Lf(e,t){_t(Zd).strict}function Rf(e){let{drag:t,layout:n}=tf();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function zf(e,t){if(typeof Proxy>`u`)return Ff;let n=new Map,r=(n,r)=>Ff(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,Ff(a,void 0,e,t)),n.get(a))})}const Bf=(e,t)=>t.isSVG??xf(e)?new iu(t):new Jl(t,{allowProjection:e!==lt});var Vf=class extends ml{constructor(e){super(e),e.animationState||=du(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();Zc(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}};let Hf=0;const Uf={animation:{Feature:Vf},exit:{Feature:class extends ml{constructor(){super(...arguments),this.id=Hf++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;let{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;if(e&&n===!1){if(this.isExitComplete){let{initial:e,custom:t}=this.node.getProps();if(typeof e==`string`||typeof e==`object`&&e&&!Array.isArray(e)){let n=bs(this.node,e,t);if(n){let{transition:e,transitionEnd:t,...r}=n;for(let e in r)this.node.getValue(e)?.jump(r[e])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive(`exit`,!1);this.isExitComplete=!1;return}let r=this.node.animationState.setActive(`exit`,!e);t&&!e&&r.then(()=>{this.isExitComplete=!0,t(this.id)})}mount(){let{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}}};function Wf(e){return{point:{x:e.pageX,y:e.pageY}}}const Gf=e=>t=>hc(t)&&e(t,Wf(t));function Kf(e,t,n,r){return Zu(e,t,Gf(n),r)}const qf=({current:e})=>e?e.ownerDocument.defaultView:null,Jf=(e,t)=>Math.abs(e-t);function Yf(e,t){let n=Jf(e.x,t.x),r=Jf(e.y,t.y);return Math.sqrt(n**2+r**2)}const Xf=new Set([`auto`,`scroll`]);var Zf=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=Qf(this.lastRawMoveEventInfo,this.transformPagePoint));let e=ep(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=Yf(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=li;this.history.push({...r,timestamp:i});let{onStart:a,onMove:o}=this.handlers;t||(a&&a(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),o&&o(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastRawMoveEventInfo=t,this.lastMoveEventInfo=Qf(t,this.transformPagePoint),si.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();let{onEnd:n,onSessionEnd:r,resumeAnimation:i}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&i&&i(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=ep(e.type===`pointercancel`?this.lastMoveEventInfo:Qf(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!hc(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=Qf(Wf(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=li;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,ep(s,this.history));let d={passive:!0,capture:!0};this.removeListeners=Mr(Kf(this.contextWindow,`pointermove`,this.handlePointerMove,d),Kf(this.contextWindow,`pointerup`,this.handlePointerUp,d),Kf(this.contextWindow,`pointercancel`,this.handlePointerUp,d)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(Xf.has(e.overflowX)||Xf.has(e.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.addEventListener(`scroll`,this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.removeEventListener(`scroll`,this.onWindowScroll)}}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-t.x,y:r.y-t.y};(i.x!==0||i.y!==0)&&(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),si.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),ci(this.updatePoint)}};function Qf(e,t){return t?{point:t(e.point)}:e}function $f(e,t){return{x:e.x-t.x,y:e.y-t.y}}function ep({point:e},t){return{point:e,delta:$f(e,np(t)),offset:$f(e,tp(t)),velocity:rp(t,.1)}}function tp(e){return e[0]}function np(e){return e[e.length-1]}function rp(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=np(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>Fr(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>Fr(t)*2&&(r=e[1]);let a=Ir(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};let o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function ip(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?aa(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?aa(n,e,r.max):Math.min(e,n)),e}function ap(e,t,n){return{min:t===void 0?void 0:e.min+t,max:n===void 0?void 0:e.max+n-(e.max-e.min)}}function op(e,{top:t,left:n,bottom:r,right:i}){return{x:ap(e.x,n,i),y:ap(e.y,t,r)}}function sp(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function cp(e,t){return{x:sp(e.x,t.x),y:sp(e.y,t.y)}}function lp(e,t){let n=.5,r=vu(e),i=vu(t);return i>r?n=Nr(t.min,t.max-r,e.min):r>i&&(n=Nr(e.min,e.max-i,t.min)),Tr(0,1,n)}function up(e,t){let n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const dp=.35;function fp(e=dp){return e===!1?e=0:e===!0&&(e=dp),{x:pp(e,`left`,`right`),y:pp(e,`top`,`bottom`)}}function pp(e,t,n){return{min:mp(e,t),max:mp(e,n)}}function mp(e,t){return typeof e==`number`?e:e[t]||0}const hp=new WeakMap;var gp=class{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Yc(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){let{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;let i=e=>{t&&this.snapToCursor(Wf(e).point),this.stopAnimation()},a=(e,t)=>{let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock&&this.openDragLock(),this.openDragLock=uc(n),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Bu(e=>{let t=this.getAxisMotionValue(e).get()||0;if(Ii.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=vu(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&si.update(()=>i(e,t),!1,!0),Os(this.visualElement,`transform`);let{animationState:a}=this.visualElement;a&&a.setActive(`whileDrag`,!0)},o=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;let{dragPropagation:n,dragDirectionLock:r,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;let{offset:o}=t;if(r&&this.currentDirection===null){this.currentDirection=bp(o),this.currentDirection!==null&&i&&i(this.currentDirection);return}this.updateAxis(`x`,t.point,o),this.updateAxis(`y`,t.point,o),this.visualElement.render(),a&&si.update(()=>a(e,t),!1,!0)},s=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{let{dragSnapToOrigin:e}=this.getProps();(e||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:l}=this.getProps();this.panSession=new Zf(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:qf(this.visualElement),element:this.visualElement.current})}stop(e,t){let n=e||this.latestPointerEvent,r=t||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!n)return;let{velocity:a}=r;this.startAnimation(a);let{onDragEnd:o}=this.getProps();o&&si.postRender(()=>o(n,r))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();let{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive(`whileDrag`,!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,n){let{drag:r}=this.getProps();if(!n||!yp(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=ip(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&jf(e)?this.constraints||=this.resolveRefConstraints():this.constraints=e&&n?op(n.layoutBox,e):!1,this.elastic=fp(t),r!==this.constraints&&!jf(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&Bu(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=up(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!jf(e))return!1;let n=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;r.root&&(r.root.scroll=void 0,r.root.updateScroll());let i=Fl(n,r.root,this.visualElement.getTransformPagePoint()),a=cp(r.layout.layoutBox,i);if(t){let e=t(gl(a));this.hasMutatedConstraints=!!e,e&&(a=hl(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=Bu(o=>{if(!yp(o,t,this.currentDirection))return;let c=s&&s[o]||{};(a===!0||a===o)&&(c={min:0,max:0});let l=r?200:1e6,u=r?40:1e7,d={type:`inertia`,velocity:n?e[o]:0,bounceStiffness:l,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(o,d)});return Promise.all(c).then(o)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return Os(this.visualElement,e),n.start(ms(e,n,0,t,this.visualElement,!1))}stopAnimation(){Bu(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`;return this.visualElement.getProps()[t]||this.visualElement.getValue(e,this.visualElement.latestValues[e]??0)}snapToCursor(e){Bu(t=>{let{drag:n}=this.getProps();if(!yp(t,n,this.currentDirection))return;let{projection:r}=this.visualElement,i=this.getAxisMotionValue(t);if(r&&r.layout){let{min:n,max:a}=r.layout.layoutBox[t],o=i.get()||0;i.set(e[t]-aa(n,a,.5)+o)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!jf(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};Bu(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=lp({min:n,max:n},this.constraints[e])}});let{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},``):`none`,n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),Bu(t=>{if(!yp(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(aa(i,a,r[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;hp.set(this.visualElement,this);let e=this.visualElement.current,t=Kf(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&yc(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();jf(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=vp(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),si.read(r);let o=Zu(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(Bu(t=>{let n=this.getAxisMotionValue(t);n&&(this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate))}),this.visualElement.render())}));return()=>{o(),t(),a(),s&&s(),n&&n()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=dp,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function _p(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function vp(e,t,n){let r=Vc(e,_p(n)),i=Vc(t,_p(n));return()=>{r(),i()}}function yp(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function bp(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var xp=class extends ml{constructor(e){super(e),this.removeGroupControls=jr,this.removeListeners=jr,this.controls=new gp(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||jr}update(){let{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}};const Sp=e=>(t,n)=>{e&&si.update(()=>e(t,n),!1,!0)};var Cp=class extends ml{constructor(){super(...arguments),this.removePointerDownListener=jr}onPointerDown(e){this.session=new Zf(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:qf(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:Sp(e),onStart:Sp(t),onMove:Sp(n),onEnd:(e,t)=>{delete this.session,r&&si.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=Kf(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}};let wp=!1;var Tp=class extends ct{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group&&t.group.add(i),n&&n.register&&r&&n.register(i),wp&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),rd.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:n,drag:r,isPresent:i}=this.props,{projection:a}=n;return a?(a.isPresent=i,e.layoutDependency!==t&&a.setOptions({...a.options,layoutDependency:t}),wp=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||si.postRender(()=>{let e=a.getStack();(!e||!e.members.length)&&this.safeToRemove()})),null):null}componentDidUpdate(){let{visualElement:e,layoutAnchor:t}=this.props,{projection:n}=e;n&&(n.options.layoutAnchor=t,n.root.didUpdate(),oc.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;wp=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function Ep(e){let[n,r]=qd(),i=_t(yr);return t(Tp,{...e,layoutGroup:i,switchLayoutGroup:_t(Af),isPresent:n,safeToRemove:r})}const Dp={pan:{Feature:Cp},drag:{Feature:xp,ProjectionNode:Rd,MeasureLayout:Ep}};function Op(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&si.postRender(()=>i(t,Wf(t)))}var kp=class extends ml{mount(){let{current:e}=this.node;e&&(this.unmount=pc(e,(e,t)=>(Op(this.node,t,`Start`),e=>Op(this.node,e,`End`))))}unmount(){}},Ap=class extends ml{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(`:focus-visible`)}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!1),this.isActive=!1)}mount(){this.unmount=Mr(Zu(this.node.current,`focus`,()=>this.onFocus()),Zu(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function jp(e,t,n){let{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive(`whileTap`,n===`Start`);let i=r[`onTap`+(n===`End`?``:n)];i&&si.postRender(()=>i(t,Wf(t)))}var Mp=class extends ml{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=Ec(e,(e,t)=>(jp(this.node,t,`Start`),(e,{success:t})=>jp(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}};const Np=new WeakMap,Pp=new WeakMap,Fp=e=>{let t=Np.get(e.target);t&&t(e)},Ip=e=>{e.forEach(Fp)};function Lp({root:e,...t}){let n=e||document;Pp.has(n)||Pp.set(n,{});let r=Pp.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(Ip,{root:e,...t})),r[i]}function Rp(e,t,n){let r=Lp(t);return Np.set(e,n),r.observe(e),()=>{Np.delete(e),r.unobserve(e)}}const zp={some:0,all:1};var Bp=class extends ml{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r=`some`,once:i}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r==`number`?r:zp[r]},o=e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive(`whileInView`,t);let{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),a=t?n:r;a&&a(e)};this.stopObserver=Rp(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(Vp(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function Vp({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const Hp={inView:{Feature:Bp},tap:{Feature:Mp},focus:{Feature:Ap},hover:{Feature:kp}},Up={layout:{ProjectionNode:Rd,MeasureLayout:Ep}},Wp=zf({...Uf,...Hp,...Dp,...Up},Bf);function Gp({children:e,secondary:n=!1}){return t(`span`,{className:n?`bg-secondary text-info`:`text-foreground bg-muted`,children:e})}function Kp(e){if(e)return e.name===`array`?Kp(e.innerType):e}function qp({property:e}){return n(`div`,{className:`flex items-center gap-x-2`,children:[t(`div`,{className:`font-semibold text-muted`,children:e.name}),e.optional&&t(Gp,{children:`optional`}),t(Gp,{children:e.type.value})]})}function Jp({activities:e}){return t(`div`,{className:`flex flex-col gap-y-4 divide-y divide-border`,children:e.map(e=>t(Xp,{activity:e},e.name))})}function Yp({code:e,children:r}){return n(`div`,{className:`flex gap-2 items-center border-b border-b-border mb-2`,children:[t(`div`,{className:`text-lg font-medium text-foreground py-2 `,children:r}),e&&t(`div`,{children:t(Gp,{children:e})})]})}function Xp({activity:e,headingClass:r,headingRef:i}){return n(`div`,{className:r,id:e.name,ref:i,children:[t(`div`,{className:`text-xl font-semibold pt-8`,children:e.title}),t(`div`,{className:`pb-4`,children:t(Gp,{children:e.name})}),e.doc&&t(`div`,{className:`text-foreground pb-2`,children:e.doc}),n(`div`,{className:`pb-4`,children:[t(Yp,{code:e.paramsType,children:`Parameters`}),t(`div`,{className:`divide-y divide-border`,children:e.params.map(e=>t(Zp,{property:e},e.name))})]}),n(`div`,{className:`pb-4`,children:[t(Yp,{children:`Returns`}),t(`div`,{children:e.returnType?e.returnType.value:`void`})]})]})}function Zp({property:e,className:r}){let i=U(()=>{let n=Kp(e.type.innerType)??e.type;return n.name===`object`&&n.members?t($p,{members:n.members}):n.name===`enum`&&n.enum?t(Qp,{values:n.enum}):null},[e.type]);return n(`div`,{className:it(`py-2`,r),children:[t(qp,{property:e}),e.doc&&t(`div`,{className:`text-foreground text-sm pt-2`,children:e.doc}),i&&t(`div`,{className:`my-2 overflow-hidden`,children:i})]})}function Qp({values:e}){return t(`div`,{className:`flex flex-wrap items-center gap-2`,children:e.map(e=>t(Gp,{secondary:!0,children:e},e))})}function $p({members:e}){return t(tm,{className:`rounded-md border border-border`,button:e=>n(`div`,{className:`px-4 py-2 flex items-center gap-x-2 text-sm font-medium hover:text-info`,children:[t(nm,{isOpen:e}),e?t(`div`,{children:`Hide child properties`}):t(`div`,{children:`Show child properties`})]}),body:t(em,{properties:e})})}function em({properties:e}){return t(`div`,{className:`border-s-2 border-s-info flex flex-col divide-y divide-border border-t border-t-border`,children:e.map(e=>t(Zp,{property:e,className:`px-4 py-2`},e.name))})}function tm({button:e,body:r,className:i,isInitiallyOpen:a}){let[s,c]=G(a||!1);return n(`div`,{className:it(s?`block`:`inline-block`,i),children:[t(o,{variant:`unstyled`,className:`p-0 m-0 bg-transparent`,onClick:()=>c(!s),children:t(Xd,{children:e(s)})}),t(Xd,{children:s&&t(Wp.div,{className:`overflow-hidden`,initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.3,ease:`easeOut`},children:r})})]})}function nm({isOpen:e}){return t(Xd,{propagate:!0,mode:`wait`,children:t(Wp.div,{className:`font-mono font-semibold text-muted text-lg`,initial:{rotate:0},animate:{rotate:e?45:0},transition:{duration:.2},children:`+`},`closeIcon`)})}var rm,im=Y((()=>{rm=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim()
10
10
  /**
11
11
  * @license lucide-react v1.31.0 - ISC
12
12
  *
@@ -895,7 +895,7 @@ Z(),Lm(),Ym(),jh(),Ph(),Lh(),Bh(),Uh(),Kh(),sg(),Tg(),Pg(),Bg(),u_(),S_(),P_(),t
895
895
  * This source code is licensed under the ISC license.
896
896
  * See the LICENSE file in the root directory of this source tree.
897
897
  */
898
- Q();function qb(e){return e===`full_control`?`text-attention`:e===`auto_review`?`text-info`:`text-muted`}function Jb(e){return t(e===`full_control`?zy:e===`ask`?w_:Hy,{className:`size-4`})}function Yb({mode:e,onChange:r,disabled:i=!1,className:a}){let{t:s}=K(),c=U(()=>[{mode:`ask`,label:s(`agent.approvalMode.ask`),description:s(`agent.approvalMode.askDescription`),icon:t(w_,{className:`size-4`})},{mode:`auto_review`,label:s(`agent.approvalMode.autoReview`),description:s(`agent.approvalMode.autoReviewDescription`),icon:t(Hy,{className:`size-4`})},{mode:`full_control`,label:s(`agent.approvalMode.fullControl`),description:s(`agent.approvalMode.fullControlDescription`),icon:t(zy,{className:`size-4`})}],[s]),l=c.find(t=>t.mode===e)??c[2],u=t=>{t!==e&&r(t)};return n(T,{children:[t(A,{asChild:!0,children:n(o,{type:`button`,variant:`ghost`,size:`sm`,disabled:i,className:z(`h-8 max-w-[13rem] rounded-full px-2.5 font-medium`,`bg-mixer-muted/15 text-muted hover:bg-muted hover:text-foreground disabled:opacity-60`,a),"aria-label":s(`agent.approvalMode.selectorLabel`),children:[t(`span`,{className:z(`shrink-0`,qb(e)),children:Jb(e)}),t(`span`,{className:`min-w-0 truncate`,children:l.label}),t(rh,{className:`size-4 shrink-0 opacity-70`})]})}),n(E,{align:`start`,className:`z-[1000000] w-[min(28rem,calc(100vw-1rem))] p-2`,children:[t(`div`,{className:`px-2 pb-1.5 pt-1 text-sm font-medium text-foreground`,children:s(`agent.approvalMode.dropdownTitle`)}),t(O,{value:e,onValueChange:e=>u(e),children:c.map(e=>n(k,{value:e.mode,className:`min-h-14 items-start gap-3 rounded-md py-2 pe-8 ps-2 text-start`,children:[t(`span`,{className:z(`mt-0.5 shrink-0`,qb(e.mode)),children:e.icon}),n(`span`,{className:`min-w-0 flex-1`,children:[t(`span`,{className:`block text-sm font-medium text-foreground`,children:e.label}),t(`span`,{className:`mt-0.5 block whitespace-normal text-sm leading-5 text-muted`,children:e.description})]})]},e.mode))})]})]})}var Xb=Object.defineProperty,Zb=(e,t)=>Xb(e,`name`,{value:t,configurable:!0}),Qb=!!(typeof window<`u`&&window.document&&window.document.createElement);function $b(e,t,{checkForDefaultPrevented:n=!0}={}){return Zb(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}Zb($b,`composeEventHandlers`);function ex(e){if(!Qb)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}Zb(ex,`getOwnerWindow`);function tx(e){if(!Qb)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}Zb(tx,`getOwnerDocument`);function nx(e,t=!1){let{activeElement:n}=tx(e);if(!n?.nodeName)return null;if(rx(n)&&n.contentDocument)return nx(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=tx(n).getElementById(e);if(t)return t}}return n}Zb(nx,`getActiveElement`);function rx(e){return e.tagName===`IFRAME`}Zb(rx,`isFrame`);var ix=Object.defineProperty,ax=(e,t)=>ix(e,`name`,{value:t,configurable:!0});function ox(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}ax(ox,`setRef`);function sx(...e){return t=>{let n=!1,r=e.map(e=>{let r=ox(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():ox(e[t],null)}}}}ax(sx,`composeRefs`);function cx(...e){return B.useCallback(sx(...e),e)}ax(cx,`useComposedRefs`);var lx=Object.defineProperty,ux=(e,t)=>lx(e,`name`,{value:t,configurable:!0});function dx(e,n){let r=B.createContext(n);r.displayName=e+`Context`;let i=ux(e=>{let{children:n,...i}=e,a=B.useMemo(()=>i,Object.values(i));return t(r.Provider,{value:a,children:n})},`Provider`);i.displayName=e+`Provider`;function a(t,i={}){let{optional:a=!1}=i,o=B.useContext(r);if(o)return o;if(n!==void 0)return n;if(!a)throw Error(`\`${t}\` must be used within \`${e}\``)}return ux(a,`useContext`),[i,a]}ux(dx,`createContext`);function fx(e,n=[]){let r=[];function i(n,i){let a=B.createContext(i);a.displayName=n+`Context`;let o=r.length;r=[...r,i];let s=ux(n=>{let{scope:r,children:i,...s}=n,c=r?.[e]?.[o]||a,l=B.useMemo(()=>s,Object.values(s));return t(c.Provider,{value:l,children:i})},`Provider`);s.displayName=n+`Provider`;function c(t,r,s={}){let{optional:c=!1}=s,l=r?.[e]?.[o]||a,u=B.useContext(l);if(u)return u;if(i!==void 0)return i;if(!c)throw Error(`\`${t}\` must be used within \`${n}\``)}return ux(c,`useContext`),[s,c]}ux(i,`createContext`);let a=ux(()=>{let t=r.map(e=>B.createContext(e));return ux(function(n){let r=n?.[e]||t;return B.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},`useScope`)},`createScope`);return a.scopeName=e,[i,px(a,...n)]}ux(fx,`createContextScope`);function px(...e){let t=e[0];if(e.length===1)return t;let n=ux(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return ux(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return B.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},`useComposedScopes`)},`createScope`);return n.scopeName=t.scopeName,n}ux(px,`composeContextScopes`);var mx=globalThis?.document?B.useLayoutEffect:()=>{},hx=Object.defineProperty,gx=(e,t)=>hx(e,`name`,{value:t,configurable:!0}),_x=B.useId||(()=>void 0),vx=0;function yx(e){let[t,n]=B.useState(_x());return mx(()=>{e||n(e=>e??String(vx++))},[e]),e||(t?`radix-${t}`:``)}gx(yx,`useId`);var bx=Object.defineProperty,xx=(e,t)=>bx(e,`name`,{value:t,configurable:!0}),Sx=B.useEffectEvent,Cx=B.useInsertionEffect;function wx(e){if(typeof Sx==`function`)return Sx(e);let t=B.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof Cx==`function`?Cx(()=>{t.current=e}):mx(()=>{t.current=e}),B.useMemo(()=>((...e)=>t.current?.(...e)),[])}xx(wx,`useEffectEvent`);var Tx=Object.defineProperty,Ex=(e,t)=>Tx(e,`name`,{value:t,configurable:!0}),Dx=B.useInsertionEffect||mx;function Ox({prop:e,defaultProp:t,onChange:n=Ex(()=>{},`onChange`),caller:r}){let[i,a,o]=kx({defaultProp:t,onChange:n}),s=e!==void 0;return[s?e:i,B.useCallback(t=>{if(s){let n=Ax(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}Ex(Ox,`useControllableState`);function kx({defaultProp:e,onChange:t}){let[n,r]=B.useState(e),i=B.useRef(n),a=B.useRef(t);return Dx(()=>{a.current=t},[t]),B.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}Ex(kx,`useUncontrolledState`);function Ax(e){return typeof e==`function`}Ex(Ax,`isFunction`);var jx=Symbol(`RADIX:SYNC_STATE`);function Mx(e,t,n,r){let{prop:i,defaultProp:a,onChange:o,caller:s}=t,c=i!==void 0,l=wx(o),u=[{...n,state:a}];r&&u.push(r);let[d,f]=B.useReducer((t,n)=>{if(n.type===jx)return{...t,state:n.state};let r=e(t,n);return c&&!Object.is(r.state,t.state)&&l(r.state),r},...u),p=d.state,m=B.useRef(p);B.useEffect(()=>{m.current!==p&&(m.current=p,c||l(p))},[p,m,c]);let h=B.useMemo(()=>i===void 0?d:{...d,state:i},[d,i]);return B.useEffect(()=>{c&&!Object.is(i,d.state)&&f({type:jx,state:i})},[i,d.state,c]),[h,f]}Ex(Mx,`useControllableStateReducer`);var Nx=Object.defineProperty,Px=(e,t)=>Nx(e,`name`,{value:t,configurable:!0});function Fx(e){let t=B.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,s=[];Wx(r)&&typeof Jx==`function`&&(r=Jx(r._payload)),B.Children.forEach(r,e=>{if(Hx(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;Wx(n)&&typeof Jx==`function`&&(n=Jx(n._payload)),a=zx(t,n),s.push(a?.props?.children)}else s.push(e)}),a?a=B.cloneElement(a,void 0,s):!o&&B.Children.count(r)===1&&B.isValidElement(r)&&(a=r);let c=a?Vx(a):void 0,l=cx(n,c);if(!a){if(r||r===0)throw Error(o?qx(e):Kx(e));return r}let u=Bx(i,a.props??{});return a.type!==B.Fragment&&(u.ref=n?l:c),B.cloneElement(a,u)});return t.displayName=`${e}.Slot`,t}Px(Fx,`createSlot`);var Ix=Fx(`Slot`),Lx=Symbol.for(`radix.slottable`);function Rx(e){let t=Px(e=>`child`in e?e.children(e.child):e.children,`Slottable`);return t.displayName=`${e}.Slottable`,t.__radixId=Lx,t}Px(Rx,`createSlottable`);var zx=Px((e,t)=>{if(`child`in e.props){let t=e.props.child;return B.isValidElement(t)?B.cloneElement(t,void 0,e.props.children(t.props.children)):null}return B.isValidElement(t)?t:null},`getSlottableElementFromSlottable`);function Bx(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}Px(Bx,`mergeProps`);function Vx(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}Px(Vx,`getElementRef`);function Hx(e){return B.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===Lx}Px(Hx,`isSlottable`);var Ux=Symbol.for(`react.lazy`);function Wx(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===Ux&&`_payload`in e&&Gx(e._payload)}Px(Wx,`isLazyComponent`);function Gx(e){return typeof e==`object`&&!!e&&`then`in e}Px(Gx,`isPromiseLike`);var Kx=Px(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,`createSlotError`),qx=Px(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,`createSlottableError`),Jx=B.use,Yx=Object.defineProperty,Xx=(e,t)=>Yx(e,`name`,{value:t,configurable:!0}),Zx=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,n)=>{let r=Fx(`Primitive.${n}`),i=B.forwardRef((e,i)=>{let{asChild:a,...o}=e,s=a?r:n;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),t(s,{...o,ref:i})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{});function Qx(e,t){e&&tn.flushSync(()=>e.dispatchEvent(t))}Xx(Qx,`dispatchDiscreteCustomEvent`);var $x=Object.defineProperty,eS=B.forwardRef(((e,t)=>$x(e,`name`,{value:t,configurable:!0}))(function(e,n){let{container:r,...i}=e,[a,o]=B.useState(!1);mx(()=>o(!0),[]);let s=r||a&&globalThis?.document?.body;return s?tn.createPortal(t(Zx.div,{...i,ref:n}),s):null},`Portal`)),tS=Object.defineProperty,nS=(e,t)=>tS(e,`name`,{value:t,configurable:!0});function rS(e,t){return B.useReducer((e,n)=>t[e][n]??e,e)}nS(rS,`useStateMachine`);var iS=nS(e=>{let{present:t,children:n}=e,r=aS(t),i=typeof n==`function`?n({present:r.isPresent}):B.Children.only(n),a=sS(r.ref,lS(i));return typeof n==`function`||r.isPresent?B.cloneElement(i,{ref:a}):null},`Presence`);function aS(e){let[t,n]=B.useState(),r=B.useRef(null),i=B.useRef(e),a=B.useRef(`none`),o=B.useRef(void 0),[s,c]=rS(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return B.useEffect(()=>{s===`mounted`?(a.current=o.current??cS(r.current),o.current=void 0):a.current=`none`},[s]),mx(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=cS(t);e?(o.current=s,c(`MOUNT`)):s===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),mx(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=nS(a=>{let o=cS(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},`handleAnimationEnd`),s=nS(e=>{e.target===t&&(a.current=cS(r.current))},`handleAnimationStart`);return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:B.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=cS(t)}else r.current=null;n(e)},[])}}nS(aS,`usePresence`);function oS(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}nS(oS,`setRef`);function sS(...e){let t=B.useRef(e);return t.current=e,B.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=oS(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():oS(n[e],null)}}},[])}nS(sS,`useStableComposedRefs`);function cS(e){return e?.animationName||`none`}nS(cS,`getAnimationName`);function lS(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}nS(lS,`getElementRef`);var uS=Object.defineProperty,dS=(e,t)=>uS(e,`name`,{value:t,configurable:!0}),fS=`Dialog`,[pS,mS]=fx(fS),[hS,gS]=pS(fS),_S=dS(e=>{let{__scopeDialog:n,children:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=B.useRef(null),l=B.useRef(null),[u,d]=Ox({prop:i,defaultProp:a??!1,onChange:o,caller:fS}),[f,p]=B.useState(0),[m,h]=B.useState(0);return t(hS,{scope:n,triggerRef:c,contentRef:l,contentId:yx(),titleId:yx(),descriptionId:yx(),titlePresent:f>0,descriptionPresent:m>0,setTitleCount:p,setDescriptionCount:h,open:u,onOpenChange:d,onOpenToggle:B.useCallback(()=>d(e=>!e),[d]),modal:s,children:r})},`Dialog`),vS=`DialogPortal`,[yS,bS]=pS(vS,{forceMount:void 0}),xS=dS(e=>{let{__scopeDialog:n,forceMount:r,children:i,container:a}=e,o=gS(vS,n);return t(yS,{scope:n,forceMount:r,children:B.Children.map(i,e=>t(iS,{present:r||o.open,children:t(eS,{asChild:!0,container:a,children:e})}))})},`DialogPortal`),SS=`DialogOverlay`,CS=B.forwardRef(dS(function(e,n){let r=bS(SS,e.__scopeDialog),{forceMount:i=r.forceMount,...a}=e,o=gS(SS,e.__scopeDialog);return o.modal?t(iS,{present:i||o.open,children:t(TS,{...a,ref:n})}):null},`DialogOverlay`)),wS=Fx(`DialogOverlay.RemoveScroll`),TS=B.forwardRef(dS(function(e,n){let{__scopeDialog:r,...i}=e,a=gS(SS,r),o=cx(n,$t());return t(rn,{as:wS,allowPinchZoom:!0,shards:[a.contentRef],children:t(Zx.div,{"data-state":LS(a.open),...i,ref:o,style:{pointerEvents:`auto`,...i.style}})})},`DialogOverlayImpl`)),ES=`DialogContent`,DS=B.forwardRef(dS(function(e,n){let r=bS(ES,e.__scopeDialog),{forceMount:i=r.forceMount,...a}=e,o=gS(ES,e.__scopeDialog);return t(iS,{present:i||o.open,children:o.modal?t(OS,{...a,ref:n}):t(kS,{...a,ref:n})})},`DialogContent`)),OS=B.forwardRef(dS(function(e,n){let r=gS(ES,e.__scopeDialog),i=B.useRef(null),a=cx(n,r.contentRef,i);return B.useEffect(()=>{let e=i.current;if(e)return an(e)},[]),t(AS,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,onCloseAutoFocus:$b(e.onCloseAutoFocus,e=>{e.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:$b(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:$b(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),kS=B.forwardRef(dS(function(e,n){let r=gS(ES,e.__scopeDialog),i=B.useRef(!1),a=B.useRef(!1);return t(AS,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(i.current||r.triggerRef.current?.focus(),t.preventDefault()),i.current=!1,a.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(i.current=!0,t.detail.originalEvent.type===`pointerdown`&&(a.current=!0));let n=t.target;r.triggerRef.current?.contains(n)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&a.current&&t.preventDefault()}})},`DialogContentNonModal`)),AS=B.forwardRef(dS(function(n,r){let{__scopeDialog:i,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:s,...c}=n,l=gS(ES,i);return nn(),t(e,{children:t(en,{asChild:!0,loop:!0,trapped:a,onMountAutoFocus:o,onUnmountAutoFocus:s,children:t(Qt,{role:`dialog`,id:l.contentId,"aria-describedby":l.descriptionPresent?l.descriptionId:void 0,"aria-labelledby":l.titlePresent?l.titleId:void 0,"data-state":LS(l.open),...c,ref:r,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1)})})})},`DialogContentImpl`)),jS=`DialogTitle`,MS=B.forwardRef(dS(function(e,n){let{__scopeDialog:r,...i}=e,a=gS(jS,r),{setTitleCount:o}=a;return mx(()=>(o(e=>e+1),()=>o(e=>e-1)),[o]),t(Zx.h2,{id:a.titleId,...i,ref:n})},`DialogTitle`)),NS=`DialogDescription`,PS=B.forwardRef(dS(function(e,n){let{__scopeDialog:r,...i}=e,a=gS(NS,r),{setDescriptionCount:o}=a;return mx(()=>(o(e=>e+1),()=>o(e=>e-1)),[o]),t(Zx.p,{id:a.descriptionId,...i,ref:n})},`DialogDescription`)),FS=`DialogClose`,IS=B.forwardRef(dS(function(e,n){let{__scopeDialog:r,...i}=e,a=gS(FS,r);return t(Zx.button,{type:`button`,...i,ref:n,onClick:$b(e.onClick,()=>a.onOpenChange(!1))})},`DialogClose`));function LS(e){return e?`open`:`closed`}dS(LS,`getState`);function RS(...e){return sn(at(e))}const zS=dt(null);function BS({children:e}){let n=W(new Map),r=W(new Map),i=V(e=>n.current.get(e),[]),a=V((e,t)=>{n.current.set(e,t)},[]),o=V(async(e,t)=>{let i=n.current.get(e);if(i)return i;let a=r.current.get(e);if(a)return a;let o=t().then(t=>(n.current.set(e,t),r.current.delete(e),t)).catch(t=>{throw r.current.delete(e),t});return r.current.set(e,o),o},[]),s=ot.useMemo(()=>({getUrl:i,setUrl:a,getOrFetch:o}),[i,a,o]);return t(zS.Provider,{value:s,children:e})}function VS(){return _t(zS)}function HS(e){return e.startsWith(`agents/`)||e.startsWith(`documents/`)}function US(e,t,n=`inline`){return`artifact:${e}:${t}:${n}`}function WS(e){return`file:${e}`}Q();const GS=ht(()=>import(`react-vega`).then(({VegaEmbed:e})=>({default:e})));function KS({error:e,chartTitle:r}){return t(`div`,{className:`flex items-center justify-center h-full bg-red-50 dark:bg-red-950 rounded-md p-4`,children:n(`div`,{className:`text-center`,children:[n(`p`,{className:`text-sm font-medium text-red-600 dark:text-red-400`,children:[`Cannot render `,r||`Vega-Lite`,` chart`]}),t(`p`,{className:`text-xs text-red-500 dark:text-red-500 mt-1 max-w-xs truncate`,children:e})]})})}function qS(){return t(`output`,{className:`flex items-center justify-center w-full h-full`,children:t(ev,{className:`w-5 h-5 animate-spin text-gray-500 dark:text-gray-400`})})}function JS({isOpen:e,onClose:r,title:i,description:a,children:s}){let{t:c}=K();return t(_S,{open:e,onOpenChange:e=>!e&&r(),children:n(xS,{children:[t(CS,{className:`fixed inset-0 z-50 bg-black/80 backdrop-blur-sm transition-all duration-300 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`}),n(DS,{className:`fixed inset-2 sm:inset-4 z-50 flex flex-col bg-white dark:bg-gray-900 rounded-xl shadow-2xl transition-all duration-300 ease-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-98 data-[state=open]:zoom-in-98 data-[state=closed]:slide-out-to-bottom-2 data-[state=open]:slide-in-from-bottom-2`,onEscapeKeyDown:r,children:[t(IS,{asChild:!0,children:t(o,{variant:`unstyled`,onClick:r,className:`absolute top-3 end-3 z-10 p-2 rounded-lg bg-white/80 dark:bg-gray-800/80 backdrop-blur-sm hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors duration-150 shadow-sm`,"aria-label":c(`agent.closeFullscreen`),children:t(Gb,{className:`w-5 h-5 text-gray-600 dark:text-gray-300`})})}),t(`div`,{className:`flex-1 overflow-auto p-4 sm:p-6 animate-in fade-in-0 duration-500 delay-150`,children:s}),t(`div`,{className:`flex items-center justify-between px-4 sm:px-6 py-3 border-t border-gray-200 dark:border-gray-800 bg-gray-50/50 dark:bg-gray-800/50 rounded-b-xl`,children:n(`div`,{className:`flex flex-col`,children:[t(MS,{className:`text-base font-semibold text-gray-900 dark:text-gray-100`,children:i||c(`agent.dashboard`)}),a&&t(PS,{className:`text-sm text-gray-500 dark:text-gray-400 mt-0.5`,children:a})]})})]})]})})}function YS(e,t){if(t===`chart`)return 280;let n=1;if(e.vconcat)n=Array.isArray(e.vconcat)?e.vconcat.length:1;else if(e.concat){let t=e.columns||2,r=Array.isArray(e.concat)?e.concat.length:1;n=Math.ceil(r/t)}else e.facet&&(n=2);return Math.max(500,n*280+40)}const XS={categorical:[`#6366f1`,`#8b5cf6`,`#ec4899`,`#f43f5e`,`#f97316`,`#eab308`,`#22c55e`,`#14b8a6`,`#06b6d4`,`#3b82f6`],blues:[`#dbeafe`,`#93c5fd`,`#3b82f6`,`#1d4ed8`,`#1e3a8a`],purples:[`#f3e8ff`,`#c4b5fd`,`#8b5cf6`,`#6d28d9`,`#4c1d95`],greens:[`#dcfce7`,`#86efac`,`#22c55e`,`#15803d`,`#14532d`],diverging:[`#ef4444`,`#fca5a5`,`#fef3c7`,`#86efac`,`#22c55e`]};function ZS(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function QS(e){return ZS(e)}function $S(e){let t=JSON.parse(JSON.stringify(e)),n=[`vconcat`,`hconcat`,`concat`];if(!n.some(e=>Array.isArray(t[e])))return t;let r=[];if(Array.isArray(t.params))for(let e of t.params)e&&typeof e==`object`&&e.name&&e.select&&r.push({name:e.name,param:e});if(r.length===0)return t;for(let{name:e,param:i}of r){let r=i.select?.fields||[],a=i.select?.bind===`legend`,o=null;for(let e of n)if(Array.isArray(t[e])){o=t[e];break}if(!o||o.length===0)continue;let s=0;for(let e=0;e<o.length;e++){let t=o[e];if(tC(t,r)||a&&nC(t,r)){s=e;break}}let c=o[s];c.params||=[],c.params.push(i),t.params=(t.params??[]).filter(t=>t.name!==e)}return Array.isArray(t.params)&&t.params.length===0&&delete t.params,t}function eC(e,t){if(!t||Object.keys(t).length===0)return e;let n=JSON.parse(JSON.stringify(e)),r=e=>{for(let n of e)n.name&&n.name in t&&(n.value=t[n.name])};Array.isArray(n.params)&&r(n.params);let i=e=>{if(Array.isArray(e)){for(let t of e)if(Array.isArray(t.params)&&r(t.params),t.vconcat&&i(t.vconcat),t.hconcat&&i(t.hconcat),t.concat&&i(t.concat),Array.isArray(t.layer))for(let e of t.layer)Array.isArray(e.params)&&r(e.params)}};if(n.vconcat&&i(n.vconcat),n.hconcat&&i(n.hconcat),n.concat&&i(n.concat),Array.isArray(n.layer))for(let e of n.layer)e&&Array.isArray(e.params)&&r(e.params);return n}function tC(e,t){if(!e?.encoding)return!1;for(let n of t)for(let t of Object.values(e.encoding))if(t.field===n)return!0;if(Array.isArray(e.layer)){for(let n of e.layer)if(tC(n,t))return!0}return!1}function nC(e,t){if(!e)return!1;let n=e=>{if(!e)return!1;let n=e.color?.field;return!!n&&t.includes(n)};if(n(e.encoding))return!0;if(Array.isArray(e.layer)){for(let t of e.layer)if(n(t.encoding))return!0}return!1}function rC(e,t=[]){let n=[];if(!e||typeof e!=`object`)return n;if(e.data&&typeof e.data==`object`){let r=e.data.url;typeof r==`string`&&r.startsWith(`artifact:`)&&n.push({path:[...t,`data`],artifactPath:r.replace(/^artifact:/,``).trim()})}for(let r of[`layer`,`vconcat`,`hconcat`,`concat`,`spec`,`repeat`,`facet`])if(r in e){let i=e[r];Array.isArray(i)?i.forEach((e,i)=>{QS(e)&&n.push(...rC(e,[...t,r,String(i)]))}):QS(i)&&n.push(...rC(i,[...t,r]))}return n}function iC(e,t){let n=JSON.parse(JSON.stringify(e));for(let[e,r]of t){let t=e.split(`.`),i=n;for(let e=0;e<t.length-1;e++){let n=i[t[e]];if(!ZS(n))break;i=n}let a=t[t.length-1],o=i[a];ZS(o)&&(delete o.url,o.values=r)}return n}function aC(e){let t={background:`transparent`,view:{stroke:`transparent`},range:{category:XS.categorical,diverging:XS.diverging,heatmap:XS.purples,ramp:XS.blues},mark:{tooltip:!0},bar:{tooltip:!0,cornerRadiusTopLeft:4,cornerRadiusTopRight:4},line:{tooltip:!0,strokeWidth:2.5,strokeCap:`round`},point:{tooltip:!0,size:60,filled:!0},area:{tooltip:!0,fillOpacity:.7,line:!0},rect:{tooltip:!0,cornerRadius:2},arc:{tooltip:!0,cornerRadius:4},circle:{tooltip:!0,size:80}};return e?{...t,axis:{labelColor:`#a1a1aa`,titleColor:`#e4e4e7`,gridColor:`#3f3f46`,domainColor:`#52525b`,tickColor:`#52525b`,labelFont:`Inter, system-ui, sans-serif`,titleFont:`Inter, system-ui, sans-serif`,labelFontSize:11,titleFontSize:12,titleFontWeight:500},legend:{labelColor:`#a1a1aa`,titleColor:`#e4e4e7`,labelFont:`Inter, system-ui, sans-serif`,titleFont:`Inter, system-ui, sans-serif`,labelFontSize:11,titleFontSize:12,symbolSize:100},title:{color:`#fafafa`,font:`Inter, system-ui, sans-serif`,fontSize:14,fontWeight:600}}:{...t,axis:{labelColor:`#71717a`,titleColor:`#3f3f46`,gridColor:`#e4e4e7`,domainColor:`#d4d4d8`,tickColor:`#d4d4d8`,labelFont:`Inter, system-ui, sans-serif`,titleFont:`Inter, system-ui, sans-serif`,labelFontSize:11,titleFontSize:12,titleFontWeight:500},legend:{labelColor:`#71717a`,titleColor:`#3f3f46`,labelFont:`Inter, system-ui, sans-serif`,titleFont:`Inter, system-ui, sans-serif`,labelFontSize:11,titleFontSize:12,symbolSize:100},title:{color:`#18181b`,font:`Inter, system-ui, sans-serif`,fontSize:14,fontWeight:600}}}const oC=gt(function({spec:r,artifactRunId:i}){let{t:a}=K(),{title:s,description:c,options:l}=r,u=r.spec,[d,f]=G(!1),[p,m]=G(!1),[h,g]=G(null),[_,v]=G(!1),y=W(null),b=W(null),x=W(null),{client:S}=q(),C=VS(),w=W(S);w.current=S;let T=W(C);T.current=C;let[E,D]=G(null),[O,k]=G(!1),[A,j]=G(null),M=l?.mode||`chart`,N=M===`dashboard`,P=l?.enableFullscreen??N,F=l?.height||YS(u,M);H(()=>{let e=rC(u);if(e.length===0){D(u),k(!1),j(null);return}i?console.info(`[VegaLiteChart] resolving artifacts with runId:`,i,e.map(e=>e.artifactPath)):console.warn(`[VegaLiteChart] artifact references found but artifactRunId is missing!`,{references:e.map(e=>e.artifactPath),artifactRunId:i});let t=!1;return k(!0),j(null),(async()=>{let n=new Map,r=w.current,a=T.current;for(let o of e)try{let e=o.path.join(`.`),t;if(i&&!HS(o.artifactPath)){let e=US(i,o.artifactPath,`inline`);t=a?await a.getOrFetch(e,async()=>(await r.files.getArtifactDownloadUrl(i,o.artifactPath,`inline`)).url):(await r.files.getArtifactDownloadUrl(i,o.artifactPath,`inline`)).url}else{let e=WS(o.artifactPath);t=a?await a.getOrFetch(e,async()=>(await r.files.getDownloadUrl(o.artifactPath)).url):(await r.files.getDownloadUrl(o.artifactPath)).url}let s=await fetch(t);if(!s.ok)throw Error(`Failed to fetch artifact data: ${s.statusText}`);let c=o.artifactPath.toLowerCase().endsWith(`.csv`),l;if(c){let{default:e}=await import(`papaparse`),t=await s.text();l=e.parse(t,{header:!0,skipEmptyLines:!0,dynamicTyping:!0}).data}else{let e=await s.json();l=Array.isArray(e)?e:[e]}n.set(e,l)}catch(e){console.error(`Failed to resolve artifact: ${o.artifactPath}`,e),t||j(`Failed to load data from artifact: ${o.artifactPath}`);return}if(!t){let e=iC(u,n);D(e),k(!1)}})(),()=>{t=!0}},[u,i]);let[I,L]=G(!1),ee=W(!1);H(()=>{let e=()=>{let e=document.documentElement.classList.contains(`dark`);e!==ee.current&&(ee.current=e,L(e))};e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>t.disconnect()},[]);let[R,te]=G(0),ne=W(0);H(()=>{if(!x.current)return;let e,t=new ResizeObserver(t=>{clearTimeout(e),e=setTimeout(()=>{let e=t[0]?.contentRect.width;e&&e!==ne.current&&(ne.current=e,te(e))},100)});t.observe(x.current);let n=x.current.clientWidth;return ne.current=n,te(n),()=>{clearTimeout(e),t.disconnect()}},[]);let re=U(()=>rC(u).length>0,[u]),ie=U(()=>{if(re&&!E)return null;let e=E||u;return e?(l?.parameterValues&&(e=eC(e,l.parameterValues)),$S(e)):null},[E,u,re,l?.parameterValues]),ae=V((e,t)=>{if(!e||typeof e!=`object`)return e;if(e.hconcat&&Array.isArray(e.hconcat)){let n=e.hconcat.length,r=(e.spacing??10)*(n-1),i=Math.floor((t-r)/n);return{...e,hconcat:e.hconcat.map(e=>ae(e,i))}}if(e.vconcat&&Array.isArray(e.vconcat))return{...e,vconcat:e.vconcat.map(e=>ae(e,t))};if(e.concat&&Array.isArray(e.concat)){let n=e.columns??e.concat.length,r=(e.spacing??10)*(n-1),i=Math.floor((t-r)/n);return{...e,concat:e.concat.map(e=>ae(e,i))}}let n=e.width;return n===`container`||typeof n==`number`&&n>t?{...e,width:t}:e},[]),oe=V((e,t=!1)=>{if(!ie)return null;let n=aC(I),r=t?typeof window<`u`?Math.min(window.innerWidth-80,1400):1200:R>0?R-24:500,i=`vconcat`in ie||`hconcat`in ie||`concat`in ie,a=i?{type:`pad`,contains:`padding`}:{type:`fit`,contains:`padding`},o=ie;i&&r&&(o=ae(ie,r));let c=o.width,l=i?void 0:c===`container`?r:c??r,{width:u,...d}=o;return{$schema:`https://vega.github.io/schema/vega-lite/v6.json`,...!i&&l?{width:l}:{},height:t?void 0:e,autosize:a,...i?o:d,...s&&!ie.title?{title:s}:{},config:{...n,...ie.config}}},[ie,s,I,R,ae]),se=V(async()=>{let e=_?b.current:y.current;if(!(!e||p))try{(await e.toCanvas(2)).toBlob(async e=>{e&&(await navigator.clipboard.write([new ClipboardItem({"image/png":e})]),m(!0),setTimeout(()=>m(!1),2e3))},`image/png`)}catch(e){console.error(`Failed to copy chart:`,e)}},[p,_]),ce=V(async()=>{let e=_?b.current:y.current;if(!(!e||d)){f(!0);try{let t=await e.toImageURL(`png`,2),n=document.createElement(`a`);n.download=`${s||`chart`}.png`,n.href=t,n.click()}catch(e){console.error(`Failed to export chart:`,e)}finally{f(!1)}}},[s,d,_]),le=V(e=>{y.current=e,g(null)},[]),ue=V(e=>{b.current=e},[]),de=V(e=>{console.error(`Vega-Lite rendering error:`,e),g(e instanceof Error?e.message:`Unknown error`)},[]),fe=V(()=>{v(e=>!e)},[]);H(()=>{g(null)},[u]);let pe=({className:e})=>n(`div`,{className:RS(`flex items-center gap-2`,e),children:[n(o,{variant:`unstyled`,onClick:se,disabled:p,className:`text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors disabled:opacity-50 flex items-center gap-1`,title:a(`agent.copyToClipboard`),children:[t(p?eh:fg,{className:`w-3 h-3`}),a(p?`agent.copied`:`agent.copy`)]}),n(o,{variant:`unstyled`,onClick:ce,disabled:d,className:`text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-1`,title:a(`agent.exportAsPng`),children:[t(xg,{className:`w-3 h-3`}),a(d?`agent.exporting`:`agent.export`)]}),P&&n(o,{variant:`unstyled`,onClick:fe,className:`text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors flex items-center gap-1`,title:a(_?`agent.exitFullscreen`:`agent.fullscreen`),children:[t(_?Dv:lv,{className:`w-3 h-3`}),a(_?`agent.exit`:`agent.fullscreen`)]})]});if(O||re&&!E)return t(`div`,{className:`bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm`,children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[t(`div`,{className:`flex items-center justify-between`,children:t(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:s||`Chart`})}),t(`div`,{className:`flex items-center justify-center bg-gray-50 dark:bg-gray-800 rounded`,style:{width:`100%`,height:F},children:n(`div`,{className:`flex items-center gap-2 text-gray-500 dark:text-gray-400`,children:[t(ev,{className:`w-5 h-5 animate-spin`}),t(`span`,{className:`text-sm`,children:`Loading data from artifacts...`})]})})]})});if(A)return t(`div`,{className:`bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm`,children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[t(`div`,{className:`flex items-center justify-between`,children:t(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:s||`Chart`})}),t(`div`,{style:{width:`100%`,height:F},children:t(KS,{error:A,chartTitle:s})})]})});if(h)return t(`div`,{className:`bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm`,children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[t(`div`,{className:`flex items-center justify-between`,children:t(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:s||`Chart`})}),t(`div`,{style:{width:`100%`,height:F},children:t(KS,{error:h,chartTitle:s})})]})});let me=oe(F),he=oe(0,!0);return me?(typeof window<`u`&&localStorage.getItem(`DEBUG_VEGA_RENDERS`)&&console.log(`VegaLite rendering with spec:`,{title:s,hasData:!!me.data?.values,dataLength:me.data?.values?.length}),n(e,{children:[t(`div`,{className:RS(`bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm`,N&&`border-2`),children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[n(`div`,{className:`flex items-center justify-between`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:s||(N?`Dashboard`:`Chart`)}),N&&t(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-indigo-100 dark:bg-indigo-900 text-indigo-700 dark:text-indigo-300`,children:`Interactive`})]}),t(pe,{})]}),c&&t(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:c}),t(`div`,{ref:x,className:`bg-white dark:bg-gray-900 rounded overflow-hidden`,style:{width:`100%`,height:F,minWidth:0},children:t(ut,{fallback:t(qS,{}),children:t(GS,{spec:me,onEmbed:e=>le(e.view),onError:de,options:{renderer:l?.renderer||`canvas`,actions:!1}})})})]})}),n(JS,{isOpen:_,onClose:()=>v(!1),title:s||(N?`Dashboard`:`Chart`),description:c,children:[t(`div`,{className:`w-full h-full min-h-[calc(100vh-200px)]`,children:he&&t(ut,{fallback:t(qS,{}),children:t(GS,{spec:he,onEmbed:e=>ue(e.view),onError:de,options:{renderer:l?.renderer||`canvas`,actions:!1}})})}),t(`div`,{className:`absolute bottom-6 end-6`,children:t(pe,{className:`bg-white dark:bg-gray-800 rounded-lg shadow-lg p-2 border border-gray-200 dark:border-gray-700`})})]})]})):null},(e,t)=>JSON.stringify(e.spec)===JSON.stringify(t.spec)&&e.artifactRunId===t.artifactRunId);function sC(e){return e.library===`vega-lite`&&typeof e.spec==`object`}function cC(e){return e.library===`recharts`||e.library===void 0}function lC(e){return typeof e.$schema==`string`&&e.$schema.includes(`vega`)}const uC=gt(function({spec:e,artifactRunId:r}){return sC(e)?t(oC,{spec:e,artifactRunId:r}):lC(e)?t(oC,{spec:{library:`vega-lite`,spec:e},artifactRunId:r}):n(`div`,{className:`my-5 rounded-lg border border-attention bg-attention p-4 text-sm text-attention`,children:[`Recharts chart rendering has been retired. Use a Vega-Lite chart spec (`,t(`code`,{children:`library: "vega-lite"`}),` with `,t(`code`,{children:`spec`}),`).`]})},(e,t)=>JSON.stringify(e.spec)===JSON.stringify(t.spec)&&e.artifactRunId===t.artifactRunId);function dC(e,t){return e===`live`?e:t===0?`live`:Math.min(Math.max(e,0),t-1)}function fC(e,t){return t===0?-1:e===`live`?t-1:Math.min(Math.max(e,0),t-1)}function pC(e,t){if(e.length===0)return null;let n=t===`live`?e.length:fC(t,e.length);for(let t=Math.min(n-1,e.length-1);t>=0;t--)if(e[t].type===J.QUESTION)return t;return null}function mC(e,t){if(e.length===0||t===`live`)return null;let n=fC(t,e.length);for(let t=n+1;t<e.length;t++)if(e[t].type===J.QUESTION)return t;return`live`}function hC(e,t,n){let r=n?dC(t,e.length):`live`,i=fC(r,e.length),a=!n||r===`live`,o=a?e:e.slice(0,i+1);return{cursor:r,cursorIndex:i,isLive:a,renderedMessageCount:o.length,displayedMessages:o}}function gC(e){let t=e.indexOf(`?`);return t===-1?new URLSearchParams:new URLSearchParams(e.slice(t+1))}function _C(){return!(typeof window>`u`)}function vC(){if(!_C())return!1;let e=new URLSearchParams(window.location.search),t=gC(window.location.hash),n=e.get(`agentChatPlayback`)??t.get(`agentChatPlayback`);return n===`1`||n===`true`}const yC=_C,bC=vC;Q();function xC({cursor:e,messages:r,onChangeCursor:i,className:a}){let{t:s}=K(),c=r.length,l=e===`live`,u=fC(e,c),d=c>0&&(l||u>0),f=!l&&c>0,p=c>0&&(l||u>0),m=!l&&c>0&&u<c-1,h=c===0?0:u+1,[g,_]=G(String(h));H(()=>{_(String(h))},[h]);let v=()=>{if(c!==0){if(e===`live`){i(c-1);return}i(Math.max(0,u-1))}},y=()=>{if(c!==0&&e!==`live`){if(u>=c-1){i(`live`);return}i(u+1)}},b=()=>{c!==0&&i(0)},x=()=>{c!==0&&i(c-1)},S=()=>{_(String(h))},C=(e,t=!1)=>{if(c===0){_(`0`);return}let n=Number.parseInt(e,10);if(!Number.isFinite(n)){t&&S();return}let r=Math.min(Math.max(n,1),c);_(String(r)),i(r-1)},w=e=>{c!==0&&C(e)},T=c>1,E=+!!T,D=Math.max(1,c),O=`size-7 rounded-lg text-muted hover:text-foreground disabled:opacity-35`,k=`${Math.max(3,String(c).length+1)}ch`;return n(`div`,{className:z(`inline-flex max-w-full flex-col gap-1 rounded-xl border border-border/70 bg-background/95 px-2 py-1 text-sm leading-none text-muted shadow-lg shadow-black/10 backdrop-blur`,a),"data-testid":`agent-test-playback-controls`,"data-playback-cursor":e,"data-live-message-count":c,"data-rendered-message-count":l?c:u+1,children:[n(`div`,{className:`flex max-w-full items-center gap-1`,children:[t(`span`,{className:`ms-2 me-1 font-medium leading-none text-foreground/80`,children:s(`agent.rewind.label`)}),t(o,{type:`button`,variant:`ghost`,size:`icon`,title:s(`agent.rewind.jumpToStart`),disabled:!p,onClick:b,className:O,children:t(vh,{className:`size-4`})}),t(o,{type:`button`,variant:`ghost`,size:`icon`,title:s(`agent.rewind.previousMessage`),disabled:!d,onClick:v,className:O,children:t(oh,{className:`size-4`})}),n(`span`,{className:`inline-flex min-w-16 items-center justify-center gap-0.5 px-1 font-medium leading-none tabular-nums text-foreground/80`,"data-testid":`agent-test-playback-position`,children:[t(te,{type:`text`,variant:`unstyled`,size:`sm`,clearable:!1,inputMode:`numeric`,pattern:`[0-9]*`,value:g,"aria-label":s(`agent.rewind.positionInput`),disabled:c===0,onChange:e=>{let t=e.replace(/\D/g,``);_(t)},onBlur:e=>C(e.currentTarget.value,!0),onKeyDown:e=>{e.key===`Enter`&&(C(e.currentTarget.value,!0),e.currentTarget.blur())},style:{width:k},className:`h-7 w-auto rounded-md border border-transparent bg-transparent px-1 text-center text-sm font-medium leading-none tabular-nums text-foreground outline-none transition-colors hover:border-border focus:border-ring focus:bg-muted/30 disabled:opacity-50`}),t(`span`,{"aria-hidden":`true`,className:`text-muted`,children:`/`}),t(`span`,{className:`text-muted`,children:c})]}),t(o,{type:`button`,variant:`ghost`,size:`icon`,title:s(`agent.rewind.nextMessage`),disabled:!f,onClick:y,className:O,children:t(lh,{className:`size-4`})}),t(o,{type:`button`,variant:`ghost`,size:`icon`,title:s(`agent.rewind.jumpToLatest`),disabled:!m,onClick:x,className:O,children:t(xh,{className:`size-4`})}),t(o,{type:`button`,variant:l?`secondary`:`ghost`,size:`icon`,title:s(`agent.rewind.jumpToLive`),disabled:l,onClick:()=>i(`live`),className:z(O,l&&`bg-muted text-foreground`),children:t(ly,{className:`size-4`})})]}),t(`div`,{className:`px-2 pb-1`,children:t(ke,{min:E,max:D,step:1,value:[h],"aria-label":s(`agent.rewind.positionInput`),disabled:!T,onValueChange:([e])=>w(String(e)),className:`h-2`})})]})}var SC=typeof document<`u`?bt:function(){};function CC(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!CC(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!CC(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function wC(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function TC(e,t){let n=wC(e);return Math.round(t*n)/n}function EC(e){let t=B.useRef(e);return SC(()=>{t.current=e}),t}function DC(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=B.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=B.useState(r);CC(f,r)||p(r);let[m,h]=B.useState(null),[g,_]=B.useState(null),v=B.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=B.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=B.useRef(null),C=B.useRef(null),w=B.useRef(u),T=c!=null,E=EC(c),D=EC(i),O=EC(l),k=B.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),Fn(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!CC(w.current,t)&&(w.current=t,tn.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);SC(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=B.useRef(!1);SC(()=>(A.current=!0,()=>{A.current=!1}),[]),SC(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=B.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=B.useMemo(()=>({reference:b,floating:x}),[b,x]),N=B.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=TC(M.floating,u.x),r=TC(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...wC(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return B.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:N}),[u,k,j,M,N])}const OC=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:Nn({element:r.current,padding:i}).fn(n):r?Nn({element:r,padding:i}).fn(n):{}}}},kC=(e,t)=>{let n=zn(e);return{name:n.name,fn:n.fn,options:[e,t]}},AC=(e,t)=>{let n=Bn(e);return{name:n.name,fn:n.fn,options:[e,t]}},jC=(e,t)=>({fn:Rn(e).fn,options:[e,t]}),MC=(e,t)=>{let n=In(e);return{name:n.name,fn:n.fn,options:[e,t]}},NC=(e,t)=>{let n=Vn(e);return{name:n.name,fn:n.fn,options:[e,t]}},PC=(e,t)=>{let n=Ln(e);return{name:n.name,fn:n.fn,options:[e,t]}},FC=(e,t)=>{let n=OC(e);return{name:n.name,fn:n.fn,options:[e,t]}};var IC=Object.defineProperty,LC=(e,t)=>IC(e,`name`,{value:t,configurable:!0});function RC(e){let t=B.useRef(e);return B.useEffect(()=>{t.current=e}),B.useMemo(()=>((...e)=>t.current?.(...e)),[])}LC(RC,`useCallbackRef`);var zC=Object.defineProperty,BC=(e,t)=>zC(e,`name`,{value:t,configurable:!0});function VC(e){let[t,n]=B.useState(void 0);return mx(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}BC(VC,`useSize`);var HC=Object.defineProperty,UC=(e,t)=>HC(e,`name`,{value:t,configurable:!0}),WC=`Popper`,[GC,KC]=fx(WC),[qC,JC]=GC(WC),YC=UC(e=>{let{__scopePopper:n,children:r}=e,[i,a]=B.useState(null),[o,s]=B.useState(void 0);return t(qC,{scope:n,anchor:i,onAnchorChange:a,placementState:o,setPlacementState:s,children:r})},`Popper`),XC=`PopperAnchor`,ZC=B.forwardRef(UC(function(e,n){let{__scopePopper:r,virtualRef:i,...a}=e,o=JC(XC,r),s=B.useRef(null),c=o.onAnchorChange,l=cx(n,B.useCallback(e=>{s.current=e,e&&c(e)},[c])),u=B.useRef(null);B.useEffect(()=>{if(!i)return;let e=u.current;u.current=i.current,e!==u.current&&c(u.current)});let d=o.placementState&&iw(o.placementState),f=d?.[0],p=d?.[1];return i?null:t(Zx.div,{"data-radix-popper-side":f,"data-radix-popper-align":p,...a,ref:l})},`PopperAnchor`)),QC=`PopperContent`,[$C,ew]=GC(QC),tw=B.forwardRef(UC(function(e,n){let{__scopePopper:r,side:i=`bottom`,sideOffset:a=0,align:o=`center`,alignOffset:s=0,arrowPadding:c=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f=`partial`,hideWhenDetached:p=!1,updatePositionStrategy:m=`optimized`,onPlaced:h,...g}=e,_=JC(QC,r),[v,y]=B.useState(null),b=cx(n,y),[x,S]=B.useState(null),C=VC(x),w=C?.width??0,T=C?.height??0,E=i+(o===`center`?``:`-`+o),D=typeof d==`number`?d:{top:0,right:0,bottom:0,left:0,...d},O=Array.isArray(u)?u:[u],k=O.length>0,A={padding:D,boundary:O.filter(nw),altBoundary:k},{refs:j,floatingStyles:M,placement:N,isPositioned:P,middlewareData:F}=DC({strategy:`fixed`,placement:E,whileElementsMounted:UC((...e)=>Pn(...e,{animationFrame:m===`always`}),`whileElementsMounted`),elements:{reference:_.anchor},middleware:[kC({mainAxis:a+T,alignmentAxis:s}),l&&AC({mainAxis:!0,crossAxis:!1,limiter:f===`partial`?jC():void 0,...A}),l&&MC({...A}),NC({...A,apply:UC(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),x&&FC({element:x,padding:c}),rw({arrowWidth:w,arrowHeight:T}),p&&PC({strategy:`referenceHidden`,...A,boundary:k?A.boundary:void 0})]}),I=_.setPlacementState;mx(()=>(I(N),()=>{I(void 0)}),[N,I]);let[L,ee]=iw(N),R=RC(h);mx(()=>{P&&R?.()},[P,R]);let te=F.arrow?.x,ne=F.arrow?.y,re=F.arrow?.centerOffset!==0,[ie,ae]=B.useState();return mx(()=>{v&&ae(window.getComputedStyle(v).zIndex)},[v]),t(`div`,{ref:j.setFloating,"data-radix-popper-content-wrapper":``,style:{...M,transform:P?M.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:ie,"--radix-popper-transform-origin":[F.transformOrigin?.x,F.transformOrigin?.y].join(` `),...F.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:t($C,{scope:r,placedSide:L,placedAlign:ee,onArrowChange:S,arrowX:te,arrowY:ne,shouldHideArrow:re,children:t(Zx.div,{"data-side":L,"data-align":ee,...g,ref:b,style:{...g.style,animation:P?g.style?.animation:`none`}})})})},`PopperContent`));function nw(e){return e!==null}UC(nw,`isNotNull`);var rw=UC(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=iw(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function iw(e){let[t,n=`center`]=e.split(`-`);return[t,n]}UC(iw,`getSideAndAlignFromPlacement`);var aw=YC,ow=ZC,sw=tw,cw=Object.defineProperty,lw=(e,t)=>cw(e,`name`,{value:t,configurable:!0}),uw=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),dw=B.forwardRef(lw(function(e,n){return t(Zx.span,{...e,ref:n,style:{...uw,...e.style}})},`VisuallyHidden`)),fw=Object.defineProperty,pw=(e,t)=>fw(e,`name`,{value:t,configurable:!0}),[mw,hw]=fx(`Tooltip`,[KC]),gw=KC(),_w=`TooltipProvider`,vw=700,yw=`tooltip.open`,[bw,xw]=mw(_w),Sw=pw(e=>{let{__scopeTooltip:n,delayDuration:r=vw,skipDelayDuration:i=300,disableHoverableContent:a=!1,children:o}=e,s=B.useRef(!0),c=B.useRef(!1),l=B.useRef(0);return B.useEffect(()=>{let e=l.current;return()=>window.clearTimeout(e)},[]),t(bw,{scope:n,isOpenDelayedRef:s,delayDuration:r,onOpen:B.useCallback(()=>{i<=0||(window.clearTimeout(l.current),s.current=!1)},[i]),onClose:B.useCallback(()=>{i<=0||(window.clearTimeout(l.current),l.current=window.setTimeout(()=>s.current=!0,i))},[i]),isPointerInTransitRef:c,onPointerInTransitChange:B.useCallback(e=>{c.current=e},[]),disableHoverableContent:a,children:o})},`TooltipProvider`),Cw=`Tooltip`,[ww,Tw]=mw(Cw),Ew=pw(e=>{let{__scopeTooltip:n,children:r,open:i,defaultOpen:a,onOpenChange:o,disableHoverableContent:s,delayDuration:c}=e,l=xw(Cw,e.__scopeTooltip),u=gw(n),[d,f]=B.useState(null),[p,m]=B.useState(void 0),h=yx(),g=B.useRef(0),_=s??l.disableHoverableContent,v=c??l.delayDuration,y=B.useRef(!1),[b,x]=Ox({prop:i,defaultProp:a??!1,onChange:pw(e=>{e?(l.onOpen(),document.dispatchEvent(new CustomEvent(yw))):l.onClose(),o?.(e)},`onChange`),caller:Cw}),S=B.useMemo(()=>b?y.current?`delayed-open`:`instant-open`:`closed`,[b]),C=B.useCallback(()=>{window.clearTimeout(g.current),g.current=0,y.current=!1,x(!0)},[x]),w=B.useCallback(()=>{window.clearTimeout(g.current),g.current=0,x(!1)},[x]),T=B.useCallback(()=>{window.clearTimeout(g.current),g.current=window.setTimeout(()=>{y.current=!0,x(!0),g.current=0},v)},[v,x]);B.useEffect(()=>()=>{g.current&&=(window.clearTimeout(g.current),0)},[]);let E=p??h;return t(aw,{...u,children:t(ww,{scope:n,contentId:E,setContentId:m,open:b,stateAttribute:S,trigger:d,onTriggerChange:f,onTriggerEnter:B.useCallback(()=>{l.isOpenDelayedRef.current?T():C()},[l.isOpenDelayedRef,T,C]),onTriggerLeave:B.useCallback(()=>{_?w():(window.clearTimeout(g.current),g.current=0)},[w,_]),onOpen:C,onClose:w,disableHoverableContent:_,children:r})})},`Tooltip`),Dw=`TooltipTrigger`,Ow=B.forwardRef(pw(function(e,n){let{__scopeTooltip:r,...i}=e,a=Tw(Dw,r),o=xw(Dw,r),s=gw(r),c=cx(n,B.useRef(null),a.onTriggerChange),l=B.useRef(!1),u=B.useRef(!1),d=B.useCallback(()=>l.current=!1,[]);return B.useEffect(()=>()=>document.removeEventListener(`pointerup`,d),[d]),t(ow,{asChild:!0,...s,children:t(Zx.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...i,ref:c,onPointerMove:$b(e.onPointerMove,e=>{e.pointerType!==`touch`&&!u.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),u.current=!0)}),onPointerLeave:$b(e.onPointerLeave,()=>{a.onTriggerLeave(),u.current=!1}),onPointerDown:$b(e.onPointerDown,()=>{a.open&&a.onClose(),l.current=!0,document.addEventListener(`pointerup`,d,{once:!0})}),onFocus:$b(e.onFocus,()=>{l.current||a.onOpen()}),onBlur:$b(e.onBlur,a.onClose),onClick:$b(e.onClick,a.onClose)})})},`TooltipTrigger`)),kw=`TooltipPortal`,[Aw,jw]=mw(kw,{forceMount:void 0}),Mw=pw(e=>{let{__scopeTooltip:n,forceMount:r,children:i,container:a}=e,o=Tw(kw,n);return t(Aw,{scope:n,forceMount:r,children:t(iS,{present:r||o.open,children:t(eS,{asChild:!0,container:a,children:i})})})},`TooltipPortal`),Nw=`TooltipContent`,Pw=B.forwardRef(pw(function(e,n){let r=jw(Nw,e.__scopeTooltip),{forceMount:i=r.forceMount,side:a=`top`,...o}=e,s=Tw(Nw,e.__scopeTooltip);return t(iS,{present:i||s.open,children:s.disableHoverableContent?t(Lw,{side:a,...o,ref:n}):t(Fw,{side:a,...o,ref:n})})},`TooltipContent`)),Fw=B.forwardRef(pw(function(e,n){let r=Tw(Nw,e.__scopeTooltip),i=xw(Nw,e.__scopeTooltip),a=B.useRef(null),o=cx(n,a),[s,c]=B.useState(null),{trigger:l,onClose:u}=r,d=a.current,{onPointerInTransitChange:f}=i,p=B.useCallback(()=>{c(null),f(!1)},[f]),m=B.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=zw(r,Rw(r,n.getBoundingClientRect())),a=Bw(t.getBoundingClientRect()),o=Hw([...i,...a]);c(o),f(!0)},[f]);return B.useEffect(()=>()=>p(),[p]),B.useEffect(()=>{if(l&&d){let e=pw(e=>m(e,d),`handleTriggerLeave`),t=pw(e=>m(e,l),`handleContentLeave`);return l.addEventListener(`pointerleave`,e),d.addEventListener(`pointerleave`,t),()=>{l.removeEventListener(`pointerleave`,e),d.removeEventListener(`pointerleave`,t)}}},[l,d,m,p]),B.useEffect(()=>{if(s){let e=pw(e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=l?.contains(t)||d?.contains(t),i=!Vw(n,s);r?p():i&&(p(),u())},`handleTrackPointerGrace`);return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[l,d,s,u,p]),t(Lw,{...e,ref:o})},`TooltipContentHoverable`)),Iw=Rx(`TooltipContent`),Lw=B.forwardRef(pw(function(e,r){let{__scopeTooltip:i,children:a,"aria-label":o,id:s,onEscapeKeyDown:c,onPointerDownOutside:l,...u}=e,d=Tw(Nw,i),f=gw(i),{onClose:p}=d;B.useEffect(()=>(document.addEventListener(yw,p),()=>document.removeEventListener(yw,p)),[p]),B.useEffect(()=>{if(d.trigger){let e=pw(e=>{e.target instanceof Node&&e.target.contains(d.trigger)&&p()},`handleScroll`);return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[d.trigger,p]);let{setContentId:m}=d;return mx(()=>(m(s),()=>{m(void 0)}),[s,m]),t(Qt,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:c,onPointerDownOutside:l,onFocusOutside:e=>e.preventDefault(),onDismiss:p,children:n(sw,{"data-state":d.stateAttribute,role:o?void 0:`tooltip`,id:o?void 0:d.contentId,...f,...u,ref:r,style:{...u.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[t(Iw,{children:a}),o?t(dw,{id:d.contentId,role:`tooltip`,children:o}):null]})})},`TooltipContentImpl`));function Rw(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}pw(Rw,`getExitSideFromRect`);function zw(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}pw(zw,`getPaddedExitPoints`);function Bw(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}pw(Bw,`getPointsFromRect`);function Vw(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}pw(Vw,`isPointInPolygon`);function Hw(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),Uw(t)}pw(Hw,`getHull`);function Uw(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}pw(Uw,`getHullPresorted`);var Ww=Sw,Gw=Ew,Kw=Ow,qw=Mw,Jw=Pw;const Yw=ot.createContext(void 0);function Xw(){return ot.useContext(Yw)}const Zw=Ww,Qw=Gw,$w=Kw,eT=B.forwardRef(({className:e,sideOffset:n=4,side:r=`top`,...i},a)=>{let o=Xw();return t(qw,{container:o,children:t(Jw,{ref:a,sideOffset:n,side:r,style:{zIndex:100},className:RS(`max-w-[90vw]`,`z-50 overflow-hidden rounded-md bg-tooltips border border-border px-3 py-1.5 text-xs animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...i})})});eT.displayName=Jw.displayName;function tT({description:e,children:r,size:i=`sm`,placement:a=`top`,className:o,asChild:s}){let[c,l]=B.useState(!1),u=B.useRef(!1);return B.useEffect(()=>{let e=()=>{l(!1),u.current=!0,requestAnimationFrame(()=>{u.current=!1})};return window.addEventListener(`blur`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`blur`,e),document.removeEventListener(`visibilitychange`,e)}},[]),t(Zw,{delayDuration:0,children:n(Qw,{open:c,onOpenChange:e=>{u.current||l(e)},children:[t($w,{className:`cursor-pointer`,asChild:s,children:r}),t(eT,{side:a,className:`px-3 py-1.5 max-w-${i} text-${i} px-3 ${o}`,children:e})]})})}Q();const nT=new Set;function rT(e,t,n){H(()=>{t&&!nT.has(e)&&(nT.add(e),console.warn(`[@vertesia/ui] ${e} is deprecated: ${n}`))},[t,n,e])}function iT(e){return B.Children.toArray(e).some(e=>{if(typeof e==`string`)return e.trim().length>0;if(typeof e==`number`)return!0;if(B.isValidElement(e)){let t=e.props;return t[`aria-hidden`]===!0||t[`aria-hidden`]===`true`?!1:iT(t.children)}return!1})}const aT=Mn(`hover:cursor-pointer inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,{variants:{variant:{destructive:`bg-destructive text-destructive ring-1 ring-inset ring-destructive/50 shadow-xs hover:bg-destructive/50`,outline:`border border-input bg-background shadow-xs hover:bg-muted ring-inset`,secondary:`bg-primary/5 dark:bg-primary/10 text-primary shadow-xs hover:bg-primary/10 dark:hover:bg-primary/20 ring-inset`,ghost:`hover:bg-muted/50 dark:hover:bg-muted/20 ring-inset`,link:`text-foreground underline-offset-4 hover:underline ring-inset`,primary:`bg-primary text-white shadow-xs hover:bg-primary/90 ring-inset`,unstyled:``},size:{xs:`h-7 rounded px-2 py-1 text-xs gap-x-1`,sm:`h-8 rounded px-3 text-xs`,md:`h-9 rounded-md px-4 py-2`,lg:`h-10 rounded-md px-3`,xl:`rounded-md px-3.5 py-2.5 text-sm gap-x-2`,icon:`p-0 m-0 rounded-full`,none:``}},defaultVariants:{variant:`primary`,size:`md`}}),oT=B.forwardRef(({className:r,variant:i,size:a,asChild:o=!1,alt:s,isDisabled:c,isLoading:l,title:u,tooltipPlacement:d=`top`,onClick:f,type:p,...m},h)=>{rT(`Button.alt`,s!==void 0,"use `title` instead — it drives the same tooltip and the accessible name. `alt` remains an alias for one release.");let g=o?Ix:`button`,_=o?p:p??`button`,v=u??s,y=m[`aria-label`]??s??(iT(m.children)?void 0:u),b=o?m.children:n(e,{children:[l&&t(ev,{className:`animate-spin`}),m.children]}),x=t(g,{className:it(RS(aT({variant:i,size:a})),r),disabled:c||l||m.disabled,ref:h,onClick:f,type:_,autoFocus:!1,...m,"aria-label":y,children:b});return v?t(tT,{description:v,asChild:!0,className:`cursor-pointer`,size:`xs`,placement:d,children:x}):x});oT.displayName=`Button`;const sT=B.forwardRef(({size:e,content:n,toast:r,className:i,alt:a,"aria-label":o,...s},c)=>{let[l,u]=G(!1),{t:d}=K();rT(`CopyButton.alt`,a!==void 0,"use aria-label for the accessible name. `alt` is forwarded for one release.");let f=e=>{e.stopPropagation(),navigator.clipboard.writeText(n).then(()=>{u(!0),setTimeout(()=>u(!1),2e3),r?.toast&&r.toast({status:`success`,title:r.message||d(`misc.copiedToClipboard`),duration:2e3})}).catch(e=>{console.error(`Failed to copy text: `,e),r?.toast&&r.toast({status:`error`,title:d(`misc.failedToCopy`),duration:2e3})})},p=o??a??d(`misc.copy`);return t(oT,{ref:c,className:RS(i),variant:`unstyled`,size:e||`sm`,onClick:f,...s,title:p,children:l?t(eh,{className:`text-success`}):t(fg,{className:`size-4`})})});sT.displayName=`CopyButton`;function cT(e){return t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e(t))}}const lT=Mn(`inline-flex items-center rounded-md px-2 py-1 text-xs font-medium`,{variants:{variant:{default:`text-foreground bg-muted`,secondary:`bg-secondary text-primary`,destructive:`bg-destructive text-destructive`,attention:`bg-attention text-attention`,success:`bg-success text-success`,info:`bg-info text-info`,done:`bg-done text-done`,outline:`bg-transparent border border-border text-foreground`}},defaultVariants:{variant:`default`}});function uT({className:e,variant:n,children:r,onClick:i,...a}){let o=i?{role:`button`,tabIndex:0,onClick:i,onKeyDown:cT(i)}:{};return t(`span`,{className:RS(lT({variant:n}),e),...o,...a,children:r})}Mn(`inline-flex items-center gap-x-1.5 rounded-md px-2 py-1 text-xs font-medium ring-1 ring-inset ring-border`,{variants:{variant:{default:``,success:``,destructive:``,attention:``,done:``,info:``,outline:``}},defaultVariants:{variant:`default`}}),Mn(`h-1.5 w-1.5`,{variants:{variant:{default:`fill-foreground`,success:`fill-success`,destructive:`fill-destructive`,attention:`fill-attention`,done:`fill-done`,info:`fill-info`,outline:`fill-foreground`}},defaultVariants:{variant:`default`}});function dT({children:e}){return t(`span`,{style:{border:0,clip:`rect(0 0 0 0)`,height:`1px`,margin:`-1px`,overflow:`hidden`,padding:0,position:`absolute`,width:`1px`,whiteSpace:`nowrap`,wordWrap:`normal`},children:e})}Q();const fT=dt(!1);function pT({children:e}){return t(fT.Provider,{value:!0,children:e})}function mT({className:e,children:r,isOpen:i,onClose:a,description:o=`Modal Description`,noCloseButton:s=!1,allowOverflow:c=!1,disableCloseOnClickOutside:l=!1,size:u=`md`,action:d}){let f=e=>{e||a()};function p(){switch(u){case`sm`:return`max-w-[20vw]`;case`md`:return`max-w-[60vw] lg:max-w-[40vw]`;case`lg`:return`max-w-[80vw] md:max-w-[60vw]`;case`xl`:return`max-w-[95vw] lg:max-w-[80vw]`;case`full`:return`h-[calc(100vh-2rem)] max-w-[calc(100vw-2rem)]`;default:return`max-w-[60vw] lg:max-w-[40vw]`}}return n(_T,{open:i,onOpenChange:e=>{(!l||e)&&f(e)},children:[c&&t(bT,{className:`z-50 fixed inset-0 bg-black/80`}),t(dT,{children:t(ST,{children:o})}),n(xT,{className:RS(`min-h-20 p-4`,`fixed left-[50%] top-[50%] z-50 grid w-full translate-x-[-50%] translate-y-[-50%] border bg-background shadow-lg duration-200 sm:rounded-lg`,p(),e),children:[t(`div`,{className:`top-4 end-4 absolute`,children:n(`div`,{className:`flex gap-2`,children:[d&&d,!s&&t(yT,{onClick:()=>f(!1),asChild:!0,autoFocus:!1,children:t(oT,{variant:`outline`,title:`Close`,className:`data-[state=open]:bg-muted opacity-70 hover:opacity-100 rounded-sm focus:outline-none focus:ring-2 focus:ring-ring ring-offset-background focus:ring-offset-2 data-[state=open]:text-muted transition-opacity disabled:pointer-events-none`,children:t(Gb,{className:`size-4`})})})]})}),t(pT,{children:r})]})]})}const hT=({children:e,show:r=!0,className:i,description:a,showDivider:o=!1,...s})=>r?n(CT,{className:RS(o?`border-b-solid border-b border-b-1 pb-2 mb-4`:``,`text-lg font-semibold leading-6 tracking-tight`,{"py-2":!a},i),...s,children:[e,a&&t(ST,{className:`text-sm !font-normal text-muted pb-2`,children:a})]}):n(dT,{children:[t(CT,{children:e}),a&&t(ST,{children:a})]}),gT=({children:e,className:n,...r})=>t(`div`,{className:RS(`text-sm max-h-[80vh] overflow-y-auto`,n),...r,children:e}),_T=_S,vT=xS,yT=IS,bT=B.forwardRef(({className:e,...n},r)=>t(CS,{ref:r,className:RS(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...n}));bT.displayName=CS.displayName;const xT=B.forwardRef(({className:e,children:r,...i},a)=>{let o=Xw();return n(vT,{container:o,children:[t(bT,{}),t(DS,{ref:a,className:RS(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] border bg-background shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg`,e),...i,children:r})]})});xT.displayName=DS.displayName;const ST=B.forwardRef(({className:e,...n},r)=>t(PS,{ref:r,className:RS(`text-sm text-muted`,e),...n}));ST.displayName=PS.displayName;const CT=B.forwardRef(({className:e,...n},r)=>t(MS,{ref:r,className:RS(`text-lg font-semibold leading-none tracking-tight`,e),...n}));CT.displayName=MS.displayName;var wT=Object.defineProperty,TT=(e,t)=>wT(e,`name`,{value:t,configurable:!0});function ET(e){let n=e+`CollectionProvider`,[r,i]=fx(n),[a,o]=r(n,{collectionRef:{current:null},itemMap:new Map}),s=TT(e=>{let{scope:n,children:r}=e,i=B.useRef(null),o=B.useRef(new Map).current;return t(a,{scope:n,itemMap:o,collectionRef:i,children:r})},`CollectionProvider`);s.displayName=n;let c=e+`CollectionSlot`,l=Fx(c),u=B.forwardRef((e,n)=>{let{scope:r,children:i}=e,a=cx(n,o(c,r).collectionRef);return t(l,{ref:a,children:i})});u.displayName=c;let d=e+`CollectionItemSlot`,f=`data-radix-collection-item`,p=Fx(d),m=B.forwardRef((e,n)=>{let{scope:r,children:i,...a}=e,s=B.useRef(null),c=cx(n,s),l=o(d,r);return B.useEffect(()=>(l.itemMap.set(s,{ref:s,...a}),()=>void l.itemMap.delete(s))),t(p,{[f]:``,ref:c,children:i})});m.displayName=d;function h(t){let n=o(e+`CollectionConsumer`,t);return B.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${f}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return TT(h,`useCollection`),[{Provider:s,Slot:u,ItemSlot:m},h,i]}TT(ET,`createCollection`);var DT=new WeakMap,OT=class e extends Map{static{TT(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],DT.set(this,!0)}set(e,t){return DT.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,t),this}insert(e,t,n){let r=this.has(t),i=this.#e.length,a=jT(e),o=a>=0?a:i+a,s=o<0||o>=i?-1:o;if(s===this.size||r&&s===this.size-1||s===-1)return this.set(t,n),this;let c=this.size+ +!r;a<0&&o++;let l=[...this.#e],u,d=!1;for(let e=o;e<c;e++)if(o===e){let i=l[e];l[e]===t&&(i=l[e+1]),r&&this.delete(t),u=this.get(i),this.set(t,n)}else{!d&&l[e-1]===t&&(d=!0);let n=l[d?e:e-1],r=u;u=this.get(n),this.delete(n),this.set(n,r)}return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=this.#e.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r,t,n)}after(e){let t=this.#e.indexOf(e);if(t=t===-1||t===this.size-1?-1:t+1,t!==-1)return this.entryAt(t)}setAfter(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#e.splice(this.#e.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return t!==void 0&&this.delete(t)}at(e){let t=kT(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=kT(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return kT(this.#e,e)}from(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return-1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=0,i=n??this.at(0);for(let n of this)i=r===0&&e.length===1?n:Reflect.apply(t,this,[i,n,r,this]),r++;return i}reduceRight(...e){let[t,n]=e,r=n??this.at(-1);for(let n=this.size-1;n>=0;n--){let i=this.at(n);r=n===this.size-1&&e.length===1?i:Reflect.apply(t,this,[r,i,n,this])}return r}toSorted(t){let n=[...this.entries()].sort(t);return new e(n)}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e,i=this.size-1;if(t===void 0)return r;t<0&&(t+=this.size),n!==void 0&&n>0&&(i=n-1);for(let e=t;e<=i;e++){let t=this.keyAt(e),n=this.get(t);r.set(t,n)}return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}};function kT(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=AT(e,t);return n===-1?void 0:e[n]}TT(kT,`at`);function AT(e,t){let n=e.length,r=jT(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}TT(AT,`toSafeIndex`);function jT(e){return e!==e||e===0?0:Math.trunc(e)}TT(jT,`toSafeInteger`);function MT(e){let n=e+`CollectionProvider`,[r,i]=fx(n),[a,o]=r(n,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new OT,setItemMap:TT(()=>void 0,`setItemMap`)}),s=TT(({state:e,...n})=>e?t(l,{...n,state:e}):t(c,{...n}),`CollectionProvider`);s.displayName=n;let c=TT(e=>{let n=g();return t(l,{...e,state:n})},`CollectionInit`);c.displayName=n+`Init`;let l=TT(e=>{let{scope:n,children:r,state:i}=e,o=B.useRef(null),[s,c]=B.useState(null),l=cx(o,c),[u,d]=i;return B.useEffect(()=>{if(!s)return;let e=IT(()=>{});return e.observe(s,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[s]),t(a,{scope:n,itemMap:u,setItemMap:d,collectionRef:l,collectionRefObject:o,collectionElement:s,children:r})},`CollectionProviderImpl`);l.displayName=n+`Impl`;let u=e+`CollectionSlot`,d=Fx(u),f=B.forwardRef((e,n)=>{let{scope:r,children:i}=e,a=cx(n,o(u,r).collectionRef);return t(d,{ref:a,children:i})});f.displayName=u;let p=e+`CollectionItemSlot`,m=Fx(p),h=B.forwardRef((e,n)=>{let{scope:r,children:i,...a}=e,s=B.useRef(null),[c,l]=B.useState(null),u=cx(n,s,l),{setItemMap:d}=o(p,r),f=B.useRef(a);NT(f.current,a)||(f.current=a);let h=f.current;return B.useEffect(()=>{let e=h;return d(t=>c?t.has(c)?t.set(c,{...e,element:c}).toSorted(FT):(t.set(c,{...e,element:c}),t.toSorted(FT)):t),()=>{d(e=>!c||!e.has(c)?e:(e.delete(c),new OT(e)))}},[c,h,d]),t(m,{"data-radix-collection-item":``,ref:u,children:i})});h.displayName=p;function g(){return B.useState(new OT)}TT(g,`useInitCollection`);function _(t){let{itemMap:n}=o(e+`CollectionConsumer`,t);return n}return TT(_,`useCollection`),[{Provider:s,Slot:f,ItemSlot:h},{createCollectionScope:i,useCollection:_,useInitCollection:g}]}TT(MT,`createCollection`);function NT(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||e[r]!==t[r])return!1;return!0}TT(NT,`shallowEqual`);function PT(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}TT(PT,`isElementPreceding`);function FT(e,t){return!e[1].element||!t[1].element?0:PT(e[1].element,t[1].element)?-1:1}TT(FT,`sortByDocumentPosition`);function IT(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}TT(IT,`getChildListObserver`);var LT=Object.defineProperty,RT=(e,t)=>LT(e,`name`,{value:t,configurable:!0}),zT=!1;function BT(){let[e,t]=B.useState(zT);return B.useEffect(()=>{zT||(zT=!0,t(!0))},[]),e}RT(BT,`useIsHydrated`);var VT=B.useSyncExternalStore;function HT(){return()=>{}}RT(HT,`subscribe`);function UT(){return VT(HT,()=>!0,()=>!1)}RT(UT,`useIsHydratedModern`);var WT=typeof VT==`function`?UT:BT,GT=Object.defineProperty,KT=(e,t)=>GT(e,`name`,{value:t,configurable:!0}),qT=`rovingFocusGroup.onEntryFocus`,JT={bubbles:!1,cancelable:!0},YT=`RovingFocusGroup`,[XT,ZT,QT]=ET(YT),[$T,eE]=fx(YT,[QT]),[tE,nE]=$T(YT),rE=B.forwardRef(KT(function(e,n){return t(XT.Provider,{scope:e.__scopeRovingFocusGroup,children:t(XT.Slot,{scope:e.__scopeRovingFocusGroup,children:t(iE,{...e,ref:n})})})},`RovingFocusGroup`)),iE=B.forwardRef(KT(function(e,n){let{__scopeRovingFocusGroup:r,orientation:i,loop:a=!1,dir:o,currentTabStopId:s,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,p=B.useRef(null),m=cx(n,p),h=Un(o),[g,_]=Ox({prop:s,defaultProp:c??null,onChange:l,caller:YT}),[v,y]=B.useState(!1),b=RC(u),x=ZT(r),S=B.useRef(!1),[C,w]=B.useState(0);return B.useEffect(()=>{let e=p.current;if(e)return e.addEventListener(qT,b),()=>e.removeEventListener(qT,b)},[b]),t(tE,{scope:r,orientation:i,dir:h,loop:a,currentTabStopId:g,onItemFocus:B.useCallback(e=>_(e),[_]),onItemShiftTab:B.useCallback(()=>y(!0),[]),onFocusableItemAdd:B.useCallback(()=>w(e=>e+1),[]),onFocusableItemRemove:B.useCallback(()=>w(e=>e-1),[]),children:t(Zx.div,{tabIndex:v||C===0?-1:0,"data-orientation":i,...f,ref:m,style:{outline:`none`,...e.style},onMouseDown:$b(e.onMouseDown,()=>{S.current=!0}),onFocus:$b(e.onFocus,e=>{let t=!S.current;if(e.target===e.currentTarget&&t&&!v){let t=new CustomEvent(qT,JT);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=x().filter(e=>e.focusable);uE([e.find(e=>e.active),e.find(e=>e.id===g),...e].filter(Boolean).map(e=>e.ref.current),d)}}S.current=!1}),onBlur:$b(e.onBlur,()=>y(!1))})})},`RovingFocusGroupImpl`)),aE=`RovingFocusGroupItem`,oE=B.forwardRef(KT(function(e,n){let{__scopeRovingFocusGroup:r,focusable:i=!0,active:a=!1,tabStopId:o,children:s,...c}=e,l=yx(),u=o||l,d=nE(aE,r),f=d.currentTabStopId===u,p=ZT(r),{onFocusableItemAdd:m,onFocusableItemRemove:h,currentTabStopId:g}=d,_=WT();return mx(()=>{if(!(!_||!i))return m(),()=>h()},[_,i,m,h]),B.useEffect(()=>{if(!(_||!i))return m(),()=>h()},[_,i,m,h]),t(XT.ItemSlot,{scope:r,id:u,focusable:i,active:a,children:t(Zx.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...c,ref:n,onMouseDown:$b(e.onMouseDown,e=>{i?d.onItemFocus(u):e.preventDefault()}),onFocus:$b(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:$b(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){d.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=lE(e,d.orientation,d.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=p().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=d.loop?dE(n,r+1):n.slice(r+1)}setTimeout(()=>uE(n))}}),children:typeof s==`function`?s({isCurrentTabStop:f,hasTabStop:g!=null}):s})})},`RovingFocusGroupItem`)),sE={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function cE(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}KT(cE,`getDirectionAwareKey`);function lE(e,t,n){let r=cE(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return sE[r]}KT(lE,`getFocusIntent`);function uE(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}KT(uE,`focusFirst`);function dE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}KT(dE,`wrapArray`);var fE=rE,pE=oE,mE=Object.defineProperty,hE=(e,t)=>mE(e,`name`,{value:t,configurable:!0}),gE=[`Enter`,` `],_E=[`ArrowDown`,`PageUp`,`Home`],vE=[`ArrowUp`,`PageDown`,`End`],yE=[..._E,...vE];[...gE],[...gE];var bE=`Menu`,[xE,SE,CE]=ET(bE),[wE,TE]=fx(bE,[CE,KC,eE]),EE=KC(),DE=eE(),[OE,kE]=wE(bE),[AE,jE]=wE(bE),ME=hE(e=>{let{__scopeMenu:n,open:r=!1,children:i,dir:a,onOpenChange:o,modal:s=!0}=e,c=EE(n),[l,u]=B.useState(null),d=B.useRef(!1),f=RC(o),p=Un(a);return B.useEffect(()=>{let e=hE(()=>{d.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=hE(()=>d.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),B.useEffect(()=>{if(!r)return;let e=hE(()=>f(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[r,f]),t(aw,{...c,children:t(OE,{scope:n,open:r,onOpenChange:f,content:l,onContentChange:u,children:t(AE,{scope:n,onClose:B.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:p,modal:s,children:i})})})},`Menu`),NE=B.forwardRef(hE(function(e,n){let{__scopeMenu:r,...i}=e,a=EE(r);return t(ow,{...a,...i,ref:n})},`MenuAnchor`)),PE=`MenuPortal`,[FE,IE]=wE(PE,{forceMount:void 0}),LE=hE(e=>{let{__scopeMenu:n,forceMount:r,children:i,container:a}=e,o=kE(PE,n);return t(FE,{scope:n,forceMount:r,children:t(iS,{present:r||o.open,children:t(eS,{asChild:!0,container:a,children:i})})})},`MenuPortal`),RE=`MenuContent`,[zE,BE]=wE(RE),VE=B.forwardRef(hE(function(e,n){let r=IE(RE,e.__scopeMenu),{forceMount:i=r.forceMount,...a}=e,o=kE(RE,e.__scopeMenu),s=jE(RE,e.__scopeMenu);return t(xE.Provider,{scope:e.__scopeMenu,children:t(iS,{present:i||o.open,children:t(xE.Slot,{scope:e.__scopeMenu,children:s.modal?t(HE,{...a,ref:n}):t(UE,{...a,ref:n})})})})},`MenuContent`)),HE=B.forwardRef(hE(function(e,n){let r=kE(RE,e.__scopeMenu),i=B.useRef(null),a=cx(n,i);return B.useEffect(()=>{let e=i.current;if(e)return an(e)},[]),t(GE,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:$b(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})},`MenuRootContentModal`)),UE=B.forwardRef(hE(function(e,n){let r=kE(RE,e.__scopeMenu);return t(GE,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})},`MenuRootContentNonModal`)),WE=Fx(`MenuContent.ScrollLock`),GE=B.forwardRef(hE(function(e,n){let{__scopeMenu:r,loop:i=!1,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:c,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:m,disableOutsideScroll:h,...g}=e,_=kE(RE,r),v=jE(RE,r),y=EE(r),b=DE(r),x=SE(r),[S,C]=B.useState(null),w=B.useRef(null),T=cx(n,w,_.onContentChange),E=B.useRef(0),D=B.useRef(``),O=B.useRef(0),k=B.useRef(null),A=B.useRef(`right`),j=B.useRef(0),M=h?rn:B.Fragment,N=h?{as:WE,allowPinchZoom:!0}:void 0,P=hE(e=>{let t=D.current+e,n=x().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=sD(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;hE((function e(t){D.current=t,window.clearTimeout(E.current),t!==``&&(E.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);B.useEffect(()=>()=>window.clearTimeout(E.current),[]),nn();let F=B.useCallback(e=>A.current===k.current?.side&&lD(e,k.current?.area),[]);return t(zE,{scope:r,searchRef:D,onItemEnter:B.useCallback(e=>{F(e)&&e.preventDefault()},[F]),onItemLeave:B.useCallback(e=>{F(e)||(w.current?.focus(),C(null))},[F]),onTriggerLeave:B.useCallback(e=>{F(e)&&e.preventDefault()},[F]),pointerGraceTimerRef:O,onPointerGraceIntentChange:B.useCallback(e=>{k.current=e},[]),children:t(M,{...N,children:t(en,{asChild:!0,trapped:a,onMountAutoFocus:$b(o,e=>{e.preventDefault(),w.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:s,children:t(Qt,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:m,children:t(fE,{asChild:!0,...b,dir:v.dir,orientation:`vertical`,loop:i,currentTabStopId:S,onCurrentTabStopIdChange:C,onEntryFocus:$b(l,e=>{v.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:t(sw,{role:`menu`,"aria-orientation":`vertical`,"data-state":nD(_.open),"data-radix-menu-content":``,dir:v.dir,...y,...g,ref:T,style:{outline:`none`,...g.style},onKeyDown:$b(g.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&P(e.key));let i=w.current;if(e.target!==i||!yE.includes(e.key))return;e.preventDefault();let a=x().filter(e=>!e.disabled).map(e=>e.ref.current);vE.includes(e.key)&&a.reverse(),aD(a)}),onBlur:$b(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(E.current),D.current=``)}),onPointerMove:$b(e.onPointerMove,uD(e=>{let t=e.target,n=j.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>j.current?`right`:`left`;A.current=t,j.current=e.clientX}}))})})})})})})},`MenuContentImpl`)),KE=`MenuItem`,qE=`menu.itemSelect`,JE=B.forwardRef(hE(function(e,n){let{disabled:r=!1,onSelect:i,...a}=e,o=B.useRef(null),s=jE(KE,e.__scopeMenu),c=BE(KE,e.__scopeMenu),l=cx(n,o),u=B.useRef(!1),d=hE(()=>{let e=o.current;if(!r&&e){let t=new CustomEvent(qE,{bubbles:!0,cancelable:!0});e.addEventListener(qE,e=>i?.(e),{once:!0}),Qx(e,t),t.defaultPrevented?u.current=!1:s.onClose()}},`handleSelect`);return t(YE,{...a,ref:l,disabled:r,onClick:$b(e.onClick,d),onPointerDown:t=>{e.onPointerDown?.(t),u.current=!0},onPointerUp:$b(e.onPointerUp,e=>{u.current||e.currentTarget?.click()}),onKeyDown:$b(e.onKeyDown,e=>{r||e.target!==e.currentTarget||(c.searchRef.current===``||e.key!==` `)&&gE.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),YE=B.forwardRef(hE(function(e,n){let{__scopeMenu:r,disabled:i=!1,textValue:a,...o}=e,s=BE(KE,r),c=DE(r),l=B.useRef(null),u=cx(n,l),[d,f]=B.useState(!1),[p,m]=B.useState(``);return B.useEffect(()=>{let e=l.current;e&&m((e.textContent??``).trim())},[o.children]),t(xE.ItemSlot,{scope:r,disabled:i,textValue:a??p,children:t(pE,{asChild:!0,...c,focusable:!i,children:t(Zx.div,{role:`menuitem`,"data-highlighted":d?``:void 0,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,...o,ref:u,onPointerMove:$b(e.onPointerMove,uD(e=>{i?s.onItemLeave(e):(s.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:$b(e.onPointerLeave,uD(e=>s.onItemLeave(e))),onFocus:$b(e.onFocus,()=>f(!0)),onBlur:$b(e.onBlur,()=>f(!1))})})})},`MenuItemImpl`)),[XE,ZE]=wE(`MenuRadioGroup`,{value:void 0,onValueChange:hE(()=>{},`onValueChange`)}),[QE,$E]=wE(`MenuItemIndicator`,{checked:!1}),[eD,tD]=wE(`MenuSub`);function nD(e){return e?`open`:`closed`}hE(nD,`getOpenState`);function rD(e){return e===`indeterminate`}hE(rD,`isIndeterminate`);function iD(e){return rD(e)?`indeterminate`:e?`checked`:`unchecked`}hE(iD,`getCheckedState`);function aD(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}hE(aD,`focusFirst`);function oD(e,t){return e.map((n,r)=>e[(t+r)%e.length])}hE(oD,`wrapArray`);function sD(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=oD(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}hE(sD,`getNextMatch`);function cD(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}hE(cD,`isPointInPolygon`);function lD(e,t){return t?cD({x:e.clientX,y:e.clientY},t):!1}hE(lD,`isPointerInGraceArea`);function uD(e){return t=>t.pointerType===`mouse`?e(t):void 0}hE(uD,`whenMouse`);var dD=ME,fD=NE,pD=LE,mD=VE,hD=JE,gD=Object.defineProperty,_D=(e,t)=>gD(e,`name`,{value:t,configurable:!0}),vD=`DropdownMenu`,[yD,bD]=fx(vD,[TE]),xD=TE(),[SD,CD]=yD(vD),wD=_D(e=>{let{__scopeDropdownMenu:n,children:r,dir:i,open:a,defaultOpen:o,onOpenChange:s,modal:c=!0}=e,l=xD(n),u=B.useRef(null),[d,f]=Ox({prop:a,defaultProp:o??!1,onChange:s,caller:vD});return t(SD,{scope:n,triggerId:yx(),triggerRef:u,contentId:yx(),open:d,onOpenChange:f,onOpenToggle:B.useCallback(()=>f(e=>!e),[f]),modal:c,children:t(dD,{...l,open:d,onOpenChange:f,dir:i,modal:c,children:r})})},`DropdownMenu`),TD=`DropdownMenuTrigger`,ED=B.forwardRef(_D(function(e,n){let{__scopeDropdownMenu:r,disabled:i=!1,...a}=e,o=CD(TD,r),s=xD(r),c=cx(n,o.triggerRef);return t(fD,{asChild:!0,...s,children:t(Zx.button,{type:`button`,id:o.triggerId,"aria-haspopup":`menu`,"aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?`open`:`closed`,"data-disabled":i?``:void 0,disabled:i,...a,ref:c,onPointerDown:$b(e.onPointerDown,e=>{!i&&e.button===0&&e.ctrlKey===!1&&(o.onOpenToggle(),o.open||e.preventDefault())}),onKeyDown:$b(e.onKeyDown,e=>{i||([`Enter`,` `].includes(e.key)&&o.onOpenToggle(),e.key===`ArrowDown`&&o.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),DD=_D(e=>{let{__scopeDropdownMenu:n,...r}=e,i=xD(n);return t(pD,{...i,...r})},`DropdownMenuPortal`),OD=`DropdownMenuContent`,kD=B.forwardRef(_D(function(e,n){let{__scopeDropdownMenu:r,...i}=e,a=CD(OD,r),o=xD(r),s=B.useRef(!1);return t(mD,{id:a.contentId,"aria-labelledby":a.triggerId,...o,...i,ref:n,onCloseAutoFocus:$b(e.onCloseAutoFocus,e=>{s.current||a.triggerRef.current?.focus(),s.current=!1,e.preventDefault()}),onInteractOutside:$b(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!a.modal||r)&&(s.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),AD=B.forwardRef(_D(function(e,n){let{__scopeDropdownMenu:r,...i}=e,a=xD(r);return t(hD,{...a,...i,ref:n})},`DropdownMenuItem`)),jD=wD,MD=ED,ND=DD,PD=kD,FD=AD;const ID=B.createContext(!1);function LD({...e}){return t(jD,{"data-slot":`dropdown-menu`,...e})}function RD({...e}){return t(MD,{"data-slot":`dropdown-menu-trigger`,...e})}function zD({className:e,align:n=`start`,sideOffset:r=4,...i}){return t(ND,{children:t(PD,{"data-slot":`dropdown-menu-content`,sideOffset:r,align:n,className:RS(`data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 bg-popover text-popover-foreground min-w-32 rounded-lg p-1 shadow-md ring-1 duration-100 z-50 max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto data-[state=closed]:overflow-hidden`,e),...i})})}function BD({className:e,inset:n,variant:r=`default`,...i}){return t(FD,{"data-slot":`dropdown-menu-item`,"data-inset":n,"data-variant":r,className:RS(`hover:bg-muted focus:bg-muted data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:text-destructive gap-2 rounded-md px-1.5 py-1 text-sm data-inset:ps-7 [&_svg:not([class*='size-'])]:size-4 group/dropdown-menu-item relative flex cursor-default items-center outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0`,e),...i})}const VD={left:`start`,center:`center`,right:`end`};function HD({trigger:e,children:r,align:i=`right`,hover:a}){let[o,s]=B.useState(!1),c=B.useRef(null);return a?n(`div`,{className:`relative inline-flex`,onMouseEnter:()=>{c.current&&clearTimeout(c.current),s(!0)},onMouseLeave:()=>{c.current=setTimeout(()=>s(!1),80)},children:[e,o&&t(`div`,{className:RS(`absolute top-full pt-1 z-50`,i===`right`?`end-0`:i===`center`?`left-1/2 -translate-x-1/2`:`start-0`),children:t(`div`,{className:`min-w-32 rounded-lg p-1 shadow-md ring-1 ring-foreground/10 bg-popover text-popover-foreground`,children:t(ID.Provider,{value:!0,children:r})})})]}):n(LD,{children:[t(RD,{asChild:!0,children:t(`span`,{className:`-m-1.5 flex items-center p-1.5`,children:e})}),t(zD,{align:VD[i],className:`w-max`,children:r})]})}function UD({children:e,href:n,onClick:r,isDisabled:i=!1,variant:a=`default`,className:o}){let s=B.useContext(ID),c=RS(`w-full gap-2 rounded-md px-1.5 py-1 text-sm text-nowrap [&_svg:not([class*='size-'])]:size-4 flex cursor-default items-center select-none [&_svg]:pointer-events-none [&_svg]:shrink-0`,a===`destructive`?`text-destructive`:``,i?`pointer-events-none opacity-50`:`hover:bg-muted focus:bg-muted`,o);return s?n?t(`a`,{href:n,className:c,children:e}):t(`button`,{type:`button`,className:c,disabled:i,onClick:e=>{e.stopPropagation(),r?.(e)},children:e}):t(BD,{className:RS(`data-[disabled]:pointer-events-none data-[disabled]:opacity-50 text-nowrap`,o),disabled:i,variant:a,onClick:e=>{e.stopPropagation(),r?.(e)},asChild:!!n,children:n?t(`a`,{href:n,children:e}):e})}Wn.extend(Kn),Wn.extend(Gn);var WD=Wn,GD=Object.defineProperty,KD=(e,t)=>GD(e,`name`,{value:t,configurable:!0}),qD=`Switch`,[JD,YD]=fx(qD),[XD,ZD]=JD(qD);function QD(e){let{__scopeSwitch:n,checked:r,children:i,defaultChecked:a,disabled:o,form:s,name:c,onCheckedChange:l,required:u,value:d=`on`,internal_do_not_use_render:f}=e,[p,m]=Ox({prop:r,defaultProp:a??!1,onChange:l,caller:qD}),[h,g]=B.useState(null),[_,v]=B.useState(null),y=B.useRef(!1),[b,x]=B.useReducer(e=>e+1,0),S={checked:p,setChecked:m,disabled:o,control:h,setControl:g,name:c,form:s,value:d,hasConsumerStoppedPropagationRef:y,userInteractionCount:b,onUserInteraction:x,required:u,defaultChecked:a,isFormControl:!h||!!s||!!h.closest(`form`),bubbleInput:_,setBubbleInput:v};return t(XD,{scope:n,...S,children:oO(f)?f(S):i})}KD(QD,`SwitchProvider`);var $D=`SwitchTrigger`,eO=B.forwardRef(KD(function({__scopeSwitch:e,onClick:n,...r},i){let{control:a,form:o,value:s,disabled:c,checked:l,required:u,setControl:d,setChecked:f,hasConsumerStoppedPropagationRef:p,onUserInteraction:m,isFormControl:h,bubbleInput:g}=ZD($D,e),_=cx(i,d),v=B.useRef(l);return B.useEffect(()=>{let e=o?a?.ownerDocument.getElementById(o):a?.form;if(e instanceof HTMLFormElement){let t=KD(()=>f(v.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[a,o,f]),t(Zx.button,{type:`button`,role:`switch`,"aria-checked":l,"aria-required":u,"data-state":sO(l),"data-disabled":c?``:void 0,disabled:c,value:s,...r,ref:_,onClick:$b(n,e=>{m(),f(e=>!e),g&&h&&(p.current=e.isPropagationStopped(),p.current||e.stopPropagation())})})},`SwitchTrigger`)),tO=B.forwardRef(KD(function(r,i){let{__scopeSwitch:a,name:o,checked:s,defaultChecked:c,required:l,disabled:u,value:d,onCheckedChange:f,form:p,...m}=r;return t(QD,{__scopeSwitch:a,checked:s,defaultChecked:c,disabled:u,required:l,onCheckedChange:f,name:o,form:p,value:d,internal_do_not_use_render:({isFormControl:r})=>n(e,{children:[t(eO,{...m,ref:i,__scopeSwitch:a}),r&&t(aO,{__scopeSwitch:a})]})})},`Switch`)),nO=`SwitchThumb`,rO=B.forwardRef(KD(function(e,n){let{__scopeSwitch:r,...i}=e,a=ZD(nO,r);return t(Zx.span,{"data-state":sO(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:n})},`SwitchThumb`)),iO=`SwitchBubbleInput`,aO=B.forwardRef(KD(function({__scopeSwitch:e,onClick:n,...r},i){let{control:a,hasConsumerStoppedPropagationRef:o,userInteractionCount:s,checked:c,defaultChecked:l,required:u,disabled:d,name:f,value:p,form:m,bubbleInput:h,setBubbleInput:g}=ZD(iO,e),_=cx(i,g),v=VC(a),y=B.useRef(!1),b=B.useRef(c),x=B.useRef(s);B.useEffect(()=>{let e=h;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=s!==x.current;x.current=s;let i=b.current!==c;b.current=c;let a=!(r&&o.current);if(i&&n){y.current=!r;let t=new Event(`click`,{bubbles:a});n.call(e,c),e.dispatchEvent(t),y.current=!1}},[h,c,o,s]);let S=B.useRef(c);return t(Zx.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:l??S.current,required:u,disabled:d,name:f,value:p,form:m,...r,tabIndex:-1,ref:_,onClick:$b(n,e=>{y.current&&e.stopPropagation()}),style:{...r.style,...v,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`SwitchBubbleInput`));function oO(e){return typeof e==`function`}KD(oO,`isFunction`);function sO(e){return e?`checked`:`unchecked`}KD(sO,`getState`);const cO={sm:[`h-5 w-8`,`size-3`,`translate-x-4 rtl:-translate-x-4`],md:[`h-6 w-11`,`size-4`,`translate-x-6 rtl:-translate-x-6`],lg:[`h-8 w-16`,`size-6`,`translate-x-9 rtl:-translate-x-9`]};function lO({className:e,size:r=`md`,value:i,onChange:a,children:o,disabled:s,...c}){let[l,u,d]=cO[r],f=t(tO,{"data-slot":`switch`,checked:i,onCheckedChange:a,disabled:s,...c,className:RS(`data-[state=checked]:bg-primary data-[state=unchecked]:bg-muted focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 shrink-0 rounded-full border focus-visible:ring-3 aria-invalid:ring-3 peer group/switch relative inline-flex items-center transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`,l,!o&&e),children:t(rO,{"data-slot":`switch-thumb`,className:RS(`bg-white rounded-full pointer-events-none block ring-0 transition-transform`,u,i?d:`translate-x-1 rtl:-translate-x-1`)})});return o?n(`div`,{className:RS(`flex items-center`,e),children:[f,t(`span`,{className:`px-2`,children:o})]}):f}function uO(e){switch(e){case`xs`:return`size-2`;case`sm`:return`size-3`;case`md`:return`size-4`;case`lg`:return`size-5`;case`xl`:return`size-7`;case`2xl`:return`size-10`;default:throw Error(`Unexpected size: ${e}`)}}function dO({size:e,className:r}){let i=uO(e||`md`);return n(`svg`,{className:it(`animate-[spin_0.8s_linear_infinite] text-primary`,i,r),xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,role:`img`,"aria-label":`Loading`,children:[t(`title`,{children:`Loading`}),t(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),t(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`})]})}function fO(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`oauth-complete`&&`success`in e&&typeof e.success==`boolean`}function pO({onComplete:e,onError:t}){let n=W(null),r=W(e),i=W(t);return H(()=>{r.current=e,i.current=t},[e,t]),H(()=>()=>{n.current&&=(n.current(),null)},[]),{openOAuthPopup:e=>{n.current&&=(n.current(),null);let t=window.screenX+(window.outerWidth-600)/2,a=window.screenY+(window.outerHeight-700)/2,o=window.open(e,`oauth_popup`,`width=600,height=700,left=${t},top=${a},popup=yes`),s=!1,c=null,l=new BroadcastChannel(`oauth-callback`);l.addEventListener(`message`,e=>{fO(e.data)&&(s=!0,l.close(),c&&clearInterval(c),r.current(),!e.data.success&&e.data.error&&i.current?.(e.data.error),n.current=null)}),o&&(c=setInterval(()=>{o.closed&&(c&&clearInterval(c),l.close(),s||r.current(),n.current=null)},1e3)),n.current=()=>{l.close(),c&&clearInterval(c)}}}}Q();function mO({appId:r,collectionId:i,collectionName:a,authenticated:o,onAuthChange:s,onError:c,variant:l=`default`,showLabel:u=!1,showDisconnect:d=!1,readOnly:f=!1}){let{client:p}=q(),{t:m}=K(),[h,g]=G(null),[_,v]=G(o===void 0&&!f),[y,b]=G(!1),[x,S]=G(!1),C=o??h?.authenticated??!1,w=a??i,T=`h-6 w-32 justify-center px-2 text-xs`,E=V(async()=>{if(o!==void 0){v(!1);return}if(f){v(!1);return}try{v(!0);let e=await p.remoteMcpConnections.getCollectionStatus(r,i);g(e)}catch(e){console.error(`[RemoteMcpConnectionButton] Failed to load OAuth status:`,e)}finally{v(!1)}},[p,r,i,o,f]);H(()=>{E()},[E]);let{openOAuthPopup:D}=pO({onComplete:()=>{b(!1),E(),s?.()},onError:e=>{console.error(`OAuth failed:`,e),b(!1)}}),O=async()=>{try{b(!0),c?.(null);let e=await p.remoteMcpConnections.authorize(r,i);e.connected?(b(!1),await E(),s?.()):e.authorization_url?D(e.authorization_url):(c?.(`${w}: Authorization URL not provided by server`),b(!1))}catch(e){console.error(`Failed to authorize:`,e);let t=(e instanceof Error?e.original_message??e.message:`Failed to connect`).replace(/^[A-Za-z\s]+:\s/,``);c?.(`${w}: ${t}`),b(!1)}},k=async()=>{try{S(!0),await p.remoteMcpConnections.disconnect(r,i),await E(),s?.()}catch(e){console.error(`Failed to disconnect:`,e)}finally{S(!1)}};return _?l===`compact`?t(oT,{variant:`outline`,size:`sm`,disabled:!0,className:T,title:m(`mcpConnections.checkingStatus`),children:t(dO,{className:`size-3`})}):t(`div`,{className:`flex items-center gap-2 text-sm`,children:t(dO,{className:`size-4`})}):l===`full`?C?n(`div`,{className:`flex items-center gap-2`,children:[u&&n(`span`,{className:`font-medium text-sm text-foreground`,children:[w,`:`]}),n(`div`,{className:`flex items-center gap-1 text-success text-sm`,children:[t(Ih,{className:`size-4`}),t(`span`,{children:m(`mcpOAuth.connected`)})]}),d&&t(oT,{variant:`ghost`,size:`sm`,onClick:k,disabled:x,children:x?t(dO,{className:`size-4`}):m(`mcpOAuth.disconnect`)})]}):n(`div`,{className:`flex items-center gap-2 text-sm`,children:[u&&n(`span`,{className:`font-medium text-foreground`,children:[w,`:`]}),t(oT,{variant:`ghost`,size:`sm`,onClick:O,disabled:y,children:y?n(e,{children:[t(dO,{className:`size-4`}),t(`span`,{children:m(`mcpOAuth.authenticating`)})]}):n(e,{children:[t(zy,{className:`size-4`}),t(`span`,{children:m(`mcpOAuth.authenticate`)})]})})]}):C?l===`compact`?n(`div`,{className:`flex items-center gap-2`,children:[u&&n(`span`,{className:`font-medium text-xs text-foreground`,children:[w,`:`]}),!f&&d&&t(oT,{variant:`outline`,size:`sm`,onClick:k,disabled:x,className:T,children:x?t(dO,{className:`size-3`}):n(e,{children:[t(xb,{className:`size-3`}),t(`span`,{children:m(`mcpOAuth.disconnect`)})]})})]}):n(`div`,{className:`flex items-center gap-1 text-success`,children:[t(Ih,{className:`size-4`}),t(`span`,{className:`text-sm`,children:m(`mcpOAuth.connected`)})]}):l===`compact`?f?n(`div`,{className:`flex items-center gap-2`,children:[u&&n(`span`,{className:`font-medium text-xs text-foreground`,children:[a,`:`]}),t(`div`,{className:`flex items-center gap-1 text-muted`,children:t(`span`,{className:`text-xs`,children:m(`mcpOAuth.notConnected`)})})]}):n(`div`,{className:`flex items-center gap-2`,children:[u&&n(`span`,{className:`font-medium text-xs text-foreground`,children:[w,`:`]}),t(oT,{variant:`outline`,size:`sm`,onClick:O,disabled:y,className:T,children:y?n(e,{children:[t(dO,{className:`size-3`}),t(`span`,{children:m(`mcpOAuth.connecting`)})]}):n(e,{children:[t(G_,{className:`size-3`}),t(`span`,{children:m(`mcpOAuth.connect`)})]})})]}):t(oT,{variant:`outline`,size:`sm`,onClick:O,disabled:f||y,children:y?n(e,{children:[t(dO,{className:`size-4`}),t(`span`,{children:m(`mcpOAuth.connecting`)})]}):n(e,{children:[t(G_,{className:`size-4 me-1`}),t(`span`,{children:m(`mcpOAuth.connect`)})]})})}function hO(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}const gO=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,_O=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,vO={};function yO(e,t){return((t||vO).jsx?_O:gO).test(e)}const bO=/[ \t\n\f\r]/g;function xO(e){return typeof e==`object`?e.type===`text`&&SO(e.value):SO(e)}function SO(e){return e.replace(bO,``)===``}var CO=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};CO.prototype.normal={},CO.prototype.property={},CO.prototype.space=void 0;function wO(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new CO(n,r,t)}function TO(e){return e.toLowerCase()}var EO=class{constructor(e,t){this.attribute=t,this.property=e}};EO.prototype.attribute=``,EO.prototype.booleanish=!1,EO.prototype.boolean=!1,EO.prototype.commaOrSpaceSeparated=!1,EO.prototype.commaSeparated=!1,EO.prototype.defined=!1,EO.prototype.mustUseProperty=!1,EO.prototype.number=!1,EO.prototype.overloadedBoolean=!1,EO.prototype.property=``,EO.prototype.spaceSeparated=!1,EO.prototype.space=void 0;var DO=mr({boolean:()=>kO,booleanish:()=>AO,commaOrSpaceSeparated:()=>PO,commaSeparated:()=>NO,number:()=>$,overloadedBoolean:()=>jO,spaceSeparated:()=>MO});let OO=0;const kO=FO(),AO=FO(),jO=FO(),$=FO(),MO=FO(),NO=FO(),PO=FO();function FO(){return 2**++OO}const IO=Object.keys(DO);var LO=class extends EO{constructor(e,t,n,r){let i=-1;if(super(e,t),RO(this,`space`,r),typeof n==`number`)for(;++i<IO.length;){let e=IO[i];RO(this,IO[i],(n&DO[e])===DO[e])}}};LO.prototype.defined=!0;function RO(e,t,n){n&&(e[t]=n)}function zO(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new LO(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[TO(r)]=r,n[TO(a.attribute)]=r}return new CO(t,n,e.space)}const BO=zO({properties:{ariaActiveDescendant:null,ariaAtomic:AO,ariaAutoComplete:null,ariaBusy:AO,ariaChecked:AO,ariaColCount:$,ariaColIndex:$,ariaColSpan:$,ariaControls:MO,ariaCurrent:null,ariaDescribedBy:MO,ariaDetails:null,ariaDisabled:AO,ariaDropEffect:MO,ariaErrorMessage:null,ariaExpanded:AO,ariaFlowTo:MO,ariaGrabbed:AO,ariaHasPopup:null,ariaHidden:AO,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:MO,ariaLevel:$,ariaLive:null,ariaModal:AO,ariaMultiLine:AO,ariaMultiSelectable:AO,ariaOrientation:null,ariaOwns:MO,ariaPlaceholder:null,ariaPosInSet:$,ariaPressed:AO,ariaReadOnly:AO,ariaRelevant:null,ariaRequired:AO,ariaRoleDescription:MO,ariaRowCount:$,ariaRowIndex:$,ariaRowSpan:$,ariaSelected:AO,ariaSetSize:$,ariaSort:null,ariaValueMax:$,ariaValueMin:$,ariaValueNow:$,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function VO(e,t){return t in e?e[t]:t}function HO(e,t){return VO(e,t.toLowerCase())}const UO=zO({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:NO,acceptCharset:MO,accessKey:MO,action:null,allow:null,allowFullScreen:kO,allowPaymentRequest:kO,allowUserMedia:kO,alt:null,as:null,async:kO,autoCapitalize:null,autoComplete:MO,autoFocus:kO,autoPlay:kO,blocking:MO,capture:null,charSet:null,checked:kO,cite:null,className:MO,cols:$,colSpan:null,content:null,contentEditable:AO,controls:kO,controlsList:MO,coords:$|NO,crossOrigin:null,data:null,dateTime:null,decoding:null,default:kO,defer:kO,dir:null,dirName:null,disabled:kO,download:jO,draggable:AO,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:kO,formTarget:null,headers:MO,height:$,hidden:jO,high:$,href:null,hrefLang:null,htmlFor:MO,httpEquiv:MO,id:null,imageSizes:null,imageSrcSet:null,inert:kO,inputMode:null,integrity:null,is:null,isMap:kO,itemId:null,itemProp:MO,itemRef:MO,itemScope:kO,itemType:MO,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:kO,low:$,manifest:null,max:null,maxLength:$,media:null,method:null,min:null,minLength:$,multiple:kO,muted:kO,name:null,nonce:null,noModule:kO,noValidate:kO,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:kO,optimum:$,pattern:null,ping:MO,placeholder:null,playsInline:kO,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:kO,referrerPolicy:null,rel:MO,required:kO,reversed:kO,rows:$,rowSpan:$,sandbox:MO,scope:null,scoped:kO,seamless:kO,selected:kO,shadowRootClonable:kO,shadowRootDelegatesFocus:kO,shadowRootMode:null,shape:null,size:$,sizes:null,slot:null,span:$,spellCheck:AO,src:null,srcDoc:null,srcLang:null,srcSet:null,start:$,step:null,style:null,tabIndex:$,target:null,title:null,translate:null,type:null,typeMustMatch:kO,useMap:null,value:AO,width:$,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:MO,axis:null,background:null,bgColor:null,border:$,borderColor:null,bottomMargin:$,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:kO,declare:kO,event:null,face:null,frame:null,frameBorder:null,hSpace:$,leftMargin:$,link:null,longDesc:null,lowSrc:null,marginHeight:$,marginWidth:$,noResize:kO,noHref:kO,noShade:kO,noWrap:kO,object:null,profile:null,prompt:null,rev:null,rightMargin:$,rules:null,scheme:null,scrolling:AO,standby:null,summary:null,text:null,topMargin:$,valueType:null,version:null,vAlign:null,vLink:null,vSpace:$,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:kO,disableRemotePlayback:kO,prefix:null,property:null,results:$,security:null,unselectable:null},space:`html`,transform:HO}),WO=zO({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:PO,accentHeight:$,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:$,amplitude:$,arabicForm:null,ascent:$,attributeName:null,attributeType:null,azimuth:$,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:$,by:null,calcMode:null,capHeight:$,className:MO,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:$,diffuseConstant:$,direction:null,display:null,dur:null,divisor:$,dominantBaseline:null,download:kO,dx:null,dy:null,edgeMode:null,editable:null,elevation:$,enableBackground:null,end:null,event:null,exponent:$,externalResourcesRequired:null,fill:null,fillOpacity:$,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:NO,g2:NO,glyphName:NO,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:$,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:$,horizOriginX:$,horizOriginY:$,id:null,ideographic:$,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:$,k:$,k1:$,k2:$,k3:$,k4:$,kernelMatrix:PO,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:$,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:$,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:$,overlineThickness:$,paintOrder:null,panose1:null,path:null,pathLength:$,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:MO,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:$,pointsAtY:$,pointsAtZ:$,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:PO,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:PO,rev:PO,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:PO,requiredFeatures:PO,requiredFonts:PO,requiredFormats:PO,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:$,specularExponent:$,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:$,strikethroughThickness:$,string:null,stroke:null,strokeDashArray:PO,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:$,strokeOpacity:$,strokeWidth:null,style:null,surfaceScale:$,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:PO,tabIndex:$,tableValues:null,target:null,targetX:$,targetY:$,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:PO,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:$,underlineThickness:$,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:$,values:null,vAlphabetic:$,vMathematical:$,vectorEffect:null,vHanging:$,vIdeographic:$,version:null,vertAdvY:$,vertOriginX:$,vertOriginY:$,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:$,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:VO}),GO=zO({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),KO=zO({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:HO}),qO=zO({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),JO={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},YO=/[A-Z]/g,XO=/-[a-z]/g,ZO=/^data[-\w.:]+$/i;function QO(e,t){let n=TO(t),r=t,i=EO;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&ZO.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(XO,ek);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!XO.test(e)){let n=e.replace(YO,$O);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=LO}return new i(r,t)}function $O(e){return`-`+e.toLowerCase()}function ek(e){return e.charAt(1).toUpperCase()}const tk=wO([BO,UO,GO,KO,qO],`html`),nk=wO([BO,WO,GO,KO,qO],`svg`);function rk(e){return e.join(` `).trim()}function ik(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var n=1,r=1;function i(e){var t=e.match(sk);t&&(n+=t.length);var i=e.lastIndexOf(mk);r=~i?e.length-i:r+e.length}function a(){var e={line:n,column:r};return function(t){return t.position=new o(e),l(),t}}function o(e){this.start=e,this.end={line:n,column:r},this.source=t.source}o.prototype.content=e;function s(i){var a=Error(t.source+`:`+n+`:`+r+`: `+i);if(a.reason=i,a.filename=t.source,a.line=n,a.column=r,a.source=e,!t.silent)throw a}function c(t){var n=t.exec(e);if(n){var r=n[0];return i(r),e=e.slice(r.length),n}}function l(){c(ck)}function u(e){var t;for(e||=[];t=d();)t!==!1&&e.push(t);return e}function d(){var t=a();if(hk==e.charAt(0)&&gk==e.charAt(1)){for(var n=2;_k!=e.charAt(n)&&(gk!=e.charAt(n)||hk!=e.charAt(n+1));)++n;if(n+=2,_k===e.charAt(n-1))return s(`End of comment missing`);var o=e.slice(2,n-2);return r+=2,i(o),e=e.slice(n),r+=2,t({type:vk,comment:o})}}function f(){var e=a(),t=c(lk);if(t){if(d(),!c(uk))return s(`property missing ':'`);var n=c(dk),r=e({type:yk,property:ak(t[0].replace(ok,_k)),value:n?ak(n[0].replace(ok,_k)):_k});return c(fk),r}}function p(){var e=[];u(e);for(var t;t=f();)t!==!1&&(e.push(t),u(e));return e}return l(),p()}function ak(e){return e?e.replace(pk,_k):_k}var ok,sk,ck,lk,uk,dk,fk,pk,mk,hk,gk,_k,vk,yk,bk=Y((()=>{ok=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,sk=/\n/g,ck=/^\s*/,lk=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,uk=/^:\s*/,dk=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,fk=/^[;\s]*/,pk=/^\s+|\s+$/g,mk=`
898
+ Q();function qb(e){return e===`full_control`?`text-attention`:e===`auto_review`?`text-info`:`text-muted`}function Jb(e){return t(e===`full_control`?zy:e===`ask`?w_:Hy,{className:`size-4`})}function Yb({mode:e,onChange:r,disabled:i=!1,className:a}){let{t:s}=K(),c=U(()=>[{mode:`ask`,label:s(`agent.approvalMode.ask`),description:s(`agent.approvalMode.askDescription`),icon:t(w_,{className:`size-4`})},{mode:`auto_review`,label:s(`agent.approvalMode.autoReview`),description:s(`agent.approvalMode.autoReviewDescription`),icon:t(Hy,{className:`size-4`})},{mode:`full_control`,label:s(`agent.approvalMode.fullControl`),description:s(`agent.approvalMode.fullControlDescription`),icon:t(zy,{className:`size-4`})}],[s]),l=c.find(t=>t.mode===e)??c[2],u=t=>{t!==e&&r(t)};return n(T,{children:[t(A,{asChild:!0,children:n(o,{type:`button`,variant:`ghost`,size:`sm`,disabled:i,className:z(`h-8 max-w-[13rem] rounded-full px-2.5 font-medium`,`bg-mixer-muted/15 text-muted hover:bg-muted hover:text-foreground disabled:opacity-60`,a),"aria-label":s(`agent.approvalMode.selectorLabel`),children:[t(`span`,{className:z(`shrink-0`,qb(e)),children:Jb(e)}),t(`span`,{className:`min-w-0 truncate`,children:l.label}),t(rh,{className:`size-4 shrink-0 opacity-70`})]})}),n(E,{align:`start`,className:`z-[1000000] w-[min(28rem,calc(100vw-1rem))] p-2`,children:[t(`div`,{className:`px-2 pb-1.5 pt-1 text-sm font-medium text-foreground`,children:s(`agent.approvalMode.dropdownTitle`)}),t(O,{value:e,onValueChange:e=>u(e),children:c.map(e=>n(k,{value:e.mode,className:`min-h-14 items-start gap-3 rounded-md py-2 pe-8 ps-2 text-start`,children:[t(`span`,{className:z(`mt-0.5 shrink-0`,qb(e.mode)),children:e.icon}),n(`span`,{className:`min-w-0 flex-1`,children:[t(`span`,{className:`block text-sm font-medium text-foreground`,children:e.label}),t(`span`,{className:`mt-0.5 block whitespace-normal text-sm leading-5 text-muted`,children:e.description})]})]},e.mode))})]})]})}var Xb=Object.defineProperty,Zb=(e,t)=>Xb(e,`name`,{value:t,configurable:!0}),Qb=!!(typeof window<`u`&&window.document&&window.document.createElement);function $b(e,t,{checkForDefaultPrevented:n=!0}={}){return Zb(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}Zb($b,`composeEventHandlers`);function ex(e){if(!Qb)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}Zb(ex,`getOwnerWindow`);function tx(e){if(!Qb)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}Zb(tx,`getOwnerDocument`);function nx(e,t=!1){let{activeElement:n}=tx(e);if(!n?.nodeName)return null;if(rx(n)&&n.contentDocument)return nx(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=tx(n).getElementById(e);if(t)return t}}return n}Zb(nx,`getActiveElement`);function rx(e){return e.tagName===`IFRAME`}Zb(rx,`isFrame`);var ix=Object.defineProperty,ax=(e,t)=>ix(e,`name`,{value:t,configurable:!0});function ox(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}ax(ox,`setRef`);function sx(...e){return t=>{let n=!1,r=e.map(e=>{let r=ox(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():ox(e[t],null)}}}}ax(sx,`composeRefs`);function cx(...e){return B.useCallback(sx(...e),e)}ax(cx,`useComposedRefs`);var lx=Object.defineProperty,ux=(e,t)=>lx(e,`name`,{value:t,configurable:!0});function dx(e,n){let r=B.createContext(n);r.displayName=e+`Context`;let i=ux(e=>{let{children:n,...i}=e,a=B.useMemo(()=>i,Object.values(i));return t(r.Provider,{value:a,children:n})},`Provider`);i.displayName=e+`Provider`;function a(t,i={}){let{optional:a=!1}=i,o=B.useContext(r);if(o)return o;if(n!==void 0)return n;if(!a)throw Error(`\`${t}\` must be used within \`${e}\``)}return ux(a,`useContext`),[i,a]}ux(dx,`createContext`);function fx(e,n=[]){let r=[];function i(n,i){let a=B.createContext(i);a.displayName=n+`Context`;let o=r.length;r=[...r,i];let s=ux(n=>{let{scope:r,children:i,...s}=n,c=r?.[e]?.[o]||a,l=B.useMemo(()=>s,Object.values(s));return t(c.Provider,{value:l,children:i})},`Provider`);s.displayName=n+`Provider`;function c(t,r,s={}){let{optional:c=!1}=s,l=r?.[e]?.[o]||a,u=B.useContext(l);if(u)return u;if(i!==void 0)return i;if(!c)throw Error(`\`${t}\` must be used within \`${n}\``)}return ux(c,`useContext`),[s,c]}ux(i,`createContext`);let a=ux(()=>{let t=r.map(e=>B.createContext(e));return ux(function(n){let r=n?.[e]||t;return B.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},`useScope`)},`createScope`);return a.scopeName=e,[i,px(a,...n)]}ux(fx,`createContextScope`);function px(...e){let t=e[0];if(e.length===1)return t;let n=ux(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return ux(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return B.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},`useComposedScopes`)},`createScope`);return n.scopeName=t.scopeName,n}ux(px,`composeContextScopes`);var mx=globalThis?.document?B.useLayoutEffect:()=>{},hx=Object.defineProperty,gx=(e,t)=>hx(e,`name`,{value:t,configurable:!0}),_x=B.useId||(()=>void 0),vx=0;function yx(e){let[t,n]=B.useState(_x());return mx(()=>{e||n(e=>e??String(vx++))},[e]),e||(t?`radix-${t}`:``)}gx(yx,`useId`);var bx=Object.defineProperty,xx=(e,t)=>bx(e,`name`,{value:t,configurable:!0}),Sx=B.useEffectEvent,Cx=B.useInsertionEffect;function wx(e){if(typeof Sx==`function`)return Sx(e);let t=B.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof Cx==`function`?Cx(()=>{t.current=e}):mx(()=>{t.current=e}),B.useMemo(()=>((...e)=>t.current?.(...e)),[])}xx(wx,`useEffectEvent`);var Tx=Object.defineProperty,Ex=(e,t)=>Tx(e,`name`,{value:t,configurable:!0}),Dx=B.useInsertionEffect||mx;function Ox({prop:e,defaultProp:t,onChange:n=Ex(()=>{},`onChange`),caller:r}){let[i,a,o]=kx({defaultProp:t,onChange:n}),s=e!==void 0;return[s?e:i,B.useCallback(t=>{if(s){let n=Ax(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}Ex(Ox,`useControllableState`);function kx({defaultProp:e,onChange:t}){let[n,r]=B.useState(e),i=B.useRef(n),a=B.useRef(t);return Dx(()=>{a.current=t},[t]),B.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}Ex(kx,`useUncontrolledState`);function Ax(e){return typeof e==`function`}Ex(Ax,`isFunction`);var jx=Symbol(`RADIX:SYNC_STATE`);function Mx(e,t,n,r){let{prop:i,defaultProp:a,onChange:o,caller:s}=t,c=i!==void 0,l=wx(o),u=[{...n,state:a}];r&&u.push(r);let[d,f]=B.useReducer((t,n)=>{if(n.type===jx)return{...t,state:n.state};let r=e(t,n);return c&&!Object.is(r.state,t.state)&&l(r.state),r},...u),p=d.state,m=B.useRef(p);B.useEffect(()=>{m.current!==p&&(m.current=p,c||l(p))},[p,m,c]);let h=B.useMemo(()=>i===void 0?d:{...d,state:i},[d,i]);return B.useEffect(()=>{c&&!Object.is(i,d.state)&&f({type:jx,state:i})},[i,d.state,c]),[h,f]}Ex(Mx,`useControllableStateReducer`);var Nx=Object.defineProperty,Px=(e,t)=>Nx(e,`name`,{value:t,configurable:!0});function Fx(e){let t=B.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,s=[];Wx(r)&&typeof Jx==`function`&&(r=Jx(r._payload)),B.Children.forEach(r,e=>{if(Hx(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;Wx(n)&&typeof Jx==`function`&&(n=Jx(n._payload)),a=zx(t,n),s.push(a?.props?.children)}else s.push(e)}),a?a=B.cloneElement(a,void 0,s):!o&&B.Children.count(r)===1&&B.isValidElement(r)&&(a=r);let c=a?Vx(a):void 0,l=cx(n,c);if(!a){if(r||r===0)throw Error(o?qx(e):Kx(e));return r}let u=Bx(i,a.props??{});return a.type!==B.Fragment&&(u.ref=n?l:c),B.cloneElement(a,u)});return t.displayName=`${e}.Slot`,t}Px(Fx,`createSlot`);var Ix=Fx(`Slot`),Lx=Symbol.for(`radix.slottable`);function Rx(e){let t=Px(e=>`child`in e?e.children(e.child):e.children,`Slottable`);return t.displayName=`${e}.Slottable`,t.__radixId=Lx,t}Px(Rx,`createSlottable`);var zx=Px((e,t)=>{if(`child`in e.props){let t=e.props.child;return B.isValidElement(t)?B.cloneElement(t,void 0,e.props.children(t.props.children)):null}return B.isValidElement(t)?t:null},`getSlottableElementFromSlottable`);function Bx(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}Px(Bx,`mergeProps`);function Vx(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}Px(Vx,`getElementRef`);function Hx(e){return B.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===Lx}Px(Hx,`isSlottable`);var Ux=Symbol.for(`react.lazy`);function Wx(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===Ux&&`_payload`in e&&Gx(e._payload)}Px(Wx,`isLazyComponent`);function Gx(e){return typeof e==`object`&&!!e&&`then`in e}Px(Gx,`isPromiseLike`);var Kx=Px(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,`createSlotError`),qx=Px(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,`createSlottableError`),Jx=B.use,Yx=Object.defineProperty,Xx=(e,t)=>Yx(e,`name`,{value:t,configurable:!0}),Zx=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,n)=>{let r=Fx(`Primitive.${n}`),i=B.forwardRef((e,i)=>{let{asChild:a,...o}=e,s=a?r:n;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),t(s,{...o,ref:i})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{});function Qx(e,t){e&&tn.flushSync(()=>e.dispatchEvent(t))}Xx(Qx,`dispatchDiscreteCustomEvent`);var $x=Object.defineProperty,eS=B.forwardRef(((e,t)=>$x(e,`name`,{value:t,configurable:!0}))(function(e,n){let{container:r,...i}=e,[a,o]=B.useState(!1);mx(()=>o(!0),[]);let s=r||a&&globalThis?.document?.body;return s?tn.createPortal(t(Zx.div,{...i,ref:n}),s):null},`Portal`)),tS=Object.defineProperty,nS=(e,t)=>tS(e,`name`,{value:t,configurable:!0});function rS(e,t){return B.useReducer((e,n)=>t[e][n]??e,e)}nS(rS,`useStateMachine`);var iS=nS(e=>{let{present:t,children:n}=e,r=aS(t),i=typeof n==`function`?n({present:r.isPresent}):B.Children.only(n),a=sS(r.ref,lS(i));return typeof n==`function`||r.isPresent?B.cloneElement(i,{ref:a}):null},`Presence`);function aS(e){let[t,n]=B.useState(),r=B.useRef(null),i=B.useRef(e),a=B.useRef(`none`),o=B.useRef(void 0),[s,c]=rS(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return B.useEffect(()=>{s===`mounted`?(a.current=o.current??cS(r.current),o.current=void 0):a.current=`none`},[s]),mx(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=cS(t);e?(o.current=s,c(`MOUNT`)):s===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),mx(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=nS(a=>{let o=cS(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},`handleAnimationEnd`),s=nS(e=>{e.target===t&&(a.current=cS(r.current))},`handleAnimationStart`);return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:B.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=cS(t)}else r.current=null;n(e)},[])}}nS(aS,`usePresence`);function oS(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}nS(oS,`setRef`);function sS(...e){let t=B.useRef(e);return t.current=e,B.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=oS(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():oS(n[e],null)}}},[])}nS(sS,`useStableComposedRefs`);function cS(e){return e?.animationName||`none`}nS(cS,`getAnimationName`);function lS(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}nS(lS,`getElementRef`);var uS=Object.defineProperty,dS=(e,t)=>uS(e,`name`,{value:t,configurable:!0}),fS=`Dialog`,[pS,mS]=fx(fS),[hS,gS]=pS(fS),_S=dS(e=>{let{__scopeDialog:n,children:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=B.useRef(null),l=B.useRef(null),[u,d]=Ox({prop:i,defaultProp:a??!1,onChange:o,caller:fS}),[f,p]=B.useState(0),[m,h]=B.useState(0);return t(hS,{scope:n,triggerRef:c,contentRef:l,contentId:yx(),titleId:yx(),descriptionId:yx(),titlePresent:f>0,descriptionPresent:m>0,setTitleCount:p,setDescriptionCount:h,open:u,onOpenChange:d,onOpenToggle:B.useCallback(()=>d(e=>!e),[d]),modal:s,children:r})},`Dialog`),vS=`DialogPortal`,[yS,bS]=pS(vS,{forceMount:void 0}),xS=dS(e=>{let{__scopeDialog:n,forceMount:r,children:i,container:a}=e,o=gS(vS,n);return t(yS,{scope:n,forceMount:r,children:B.Children.map(i,e=>t(iS,{present:r||o.open,children:t(eS,{asChild:!0,container:a,children:e})}))})},`DialogPortal`),SS=`DialogOverlay`,CS=B.forwardRef(dS(function(e,n){let r=bS(SS,e.__scopeDialog),{forceMount:i=r.forceMount,...a}=e,o=gS(SS,e.__scopeDialog);return o.modal?t(iS,{present:i||o.open,children:t(TS,{...a,ref:n})}):null},`DialogOverlay`)),wS=Fx(`DialogOverlay.RemoveScroll`),TS=B.forwardRef(dS(function(e,n){let{__scopeDialog:r,...i}=e,a=gS(SS,r),o=cx(n,$t());return t(rn,{as:wS,allowPinchZoom:!0,shards:[a.contentRef],children:t(Zx.div,{"data-state":LS(a.open),...i,ref:o,style:{pointerEvents:`auto`,...i.style}})})},`DialogOverlayImpl`)),ES=`DialogContent`,DS=B.forwardRef(dS(function(e,n){let r=bS(ES,e.__scopeDialog),{forceMount:i=r.forceMount,...a}=e,o=gS(ES,e.__scopeDialog);return t(iS,{present:i||o.open,children:o.modal?t(OS,{...a,ref:n}):t(kS,{...a,ref:n})})},`DialogContent`)),OS=B.forwardRef(dS(function(e,n){let r=gS(ES,e.__scopeDialog),i=B.useRef(null),a=cx(n,r.contentRef,i);return B.useEffect(()=>{let e=i.current;if(e)return an(e)},[]),t(AS,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,onCloseAutoFocus:$b(e.onCloseAutoFocus,e=>{e.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:$b(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:$b(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),kS=B.forwardRef(dS(function(e,n){let r=gS(ES,e.__scopeDialog),i=B.useRef(!1),a=B.useRef(!1);return t(AS,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(i.current||r.triggerRef.current?.focus(),t.preventDefault()),i.current=!1,a.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(i.current=!0,t.detail.originalEvent.type===`pointerdown`&&(a.current=!0));let n=t.target;r.triggerRef.current?.contains(n)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&a.current&&t.preventDefault()}})},`DialogContentNonModal`)),AS=B.forwardRef(dS(function(n,r){let{__scopeDialog:i,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:s,...c}=n,l=gS(ES,i);return nn(),t(e,{children:t(en,{asChild:!0,loop:!0,trapped:a,onMountAutoFocus:o,onUnmountAutoFocus:s,children:t(Qt,{role:`dialog`,id:l.contentId,"aria-describedby":l.descriptionPresent?l.descriptionId:void 0,"aria-labelledby":l.titlePresent?l.titleId:void 0,"data-state":LS(l.open),...c,ref:r,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1)})})})},`DialogContentImpl`)),jS=`DialogTitle`,MS=B.forwardRef(dS(function(e,n){let{__scopeDialog:r,...i}=e,a=gS(jS,r),{setTitleCount:o}=a;return mx(()=>(o(e=>e+1),()=>o(e=>e-1)),[o]),t(Zx.h2,{id:a.titleId,...i,ref:n})},`DialogTitle`)),NS=`DialogDescription`,PS=B.forwardRef(dS(function(e,n){let{__scopeDialog:r,...i}=e,a=gS(NS,r),{setDescriptionCount:o}=a;return mx(()=>(o(e=>e+1),()=>o(e=>e-1)),[o]),t(Zx.p,{id:a.descriptionId,...i,ref:n})},`DialogDescription`)),FS=`DialogClose`,IS=B.forwardRef(dS(function(e,n){let{__scopeDialog:r,...i}=e,a=gS(FS,r);return t(Zx.button,{type:`button`,...i,ref:n,onClick:$b(e.onClick,()=>a.onOpenChange(!1))})},`DialogClose`));function LS(e){return e?`open`:`closed`}dS(LS,`getState`);function RS(...e){return sn(at(e))}const zS=dt(null);function BS({children:e}){let n=W(new Map),r=W(new Map),i=V(e=>n.current.get(e),[]),a=V((e,t)=>{n.current.set(e,t)},[]),o=V(async(e,t)=>{let i=n.current.get(e);if(i)return i;let a=r.current.get(e);if(a)return a;let o=t().then(t=>(n.current.set(e,t),r.current.delete(e),t)).catch(t=>{throw r.current.delete(e),t});return r.current.set(e,o),o},[]),s=ot.useMemo(()=>({getUrl:i,setUrl:a,getOrFetch:o}),[i,a,o]);return t(zS.Provider,{value:s,children:e})}function VS(){return _t(zS)}function HS(e){return e.startsWith(`agents/`)||e.startsWith(`documents/`)}function US(e,t,n=`inline`){return`artifact:${e}:${t}:${n}`}function WS(e){return`file:${e}`}Q();const GS=ht(()=>import(`react-vega`).then(({VegaEmbed:e})=>({default:e})));function KS({error:e,chartTitle:r}){return t(`div`,{className:`flex items-center justify-center h-full bg-red-50 dark:bg-red-950 rounded-md p-4`,children:n(`div`,{className:`text-center`,children:[n(`p`,{className:`text-sm font-medium text-red-600 dark:text-red-400`,children:[`Cannot render `,r||`Vega-Lite`,` chart`]}),t(`p`,{className:`text-xs text-red-500 dark:text-red-500 mt-1 max-w-xs truncate`,children:e})]})})}function qS(){return t(`output`,{className:`flex items-center justify-center w-full h-full`,children:t(ev,{className:`w-5 h-5 animate-spin text-gray-500 dark:text-gray-400`})})}function JS({isOpen:e,onClose:r,title:i,description:a,children:s}){let{t:c}=K();return t(_S,{open:e,onOpenChange:e=>!e&&r(),children:n(xS,{children:[t(CS,{className:`fixed inset-0 z-50 bg-black/80 backdrop-blur-sm transition-all duration-300 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`}),n(DS,{className:`fixed inset-2 sm:inset-4 z-50 flex flex-col bg-white dark:bg-gray-900 rounded-xl shadow-2xl transition-all duration-300 ease-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-98 data-[state=open]:zoom-in-98 data-[state=closed]:slide-out-to-bottom-2 data-[state=open]:slide-in-from-bottom-2`,onEscapeKeyDown:r,children:[t(IS,{asChild:!0,children:t(o,{variant:`unstyled`,onClick:r,className:`absolute top-3 end-3 z-10 p-2 rounded-lg bg-white/80 dark:bg-gray-800/80 backdrop-blur-sm hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors duration-150 shadow-sm`,"aria-label":c(`agent.closeFullscreen`),children:t(Gb,{className:`w-5 h-5 text-gray-600 dark:text-gray-300`})})}),t(`div`,{className:`flex-1 overflow-auto p-4 sm:p-6 animate-in fade-in-0 duration-500 delay-150`,children:s}),t(`div`,{className:`flex items-center justify-between px-4 sm:px-6 py-3 border-t border-gray-200 dark:border-gray-800 bg-gray-50/50 dark:bg-gray-800/50 rounded-b-xl`,children:n(`div`,{className:`flex flex-col`,children:[t(MS,{className:`text-base font-semibold text-gray-900 dark:text-gray-100`,children:i||c(`agent.dashboard`)}),a&&t(PS,{className:`text-sm text-gray-500 dark:text-gray-400 mt-0.5`,children:a})]})})]})]})})}function YS(e,t){if(t===`chart`)return 280;let n=1;if(e.vconcat)n=Array.isArray(e.vconcat)?e.vconcat.length:1;else if(e.concat){let t=e.columns||2,r=Array.isArray(e.concat)?e.concat.length:1;n=Math.ceil(r/t)}else e.facet&&(n=2);return Math.max(500,n*280+40)}const XS={categorical:[`#6366f1`,`#8b5cf6`,`#ec4899`,`#f43f5e`,`#f97316`,`#eab308`,`#22c55e`,`#14b8a6`,`#06b6d4`,`#3b82f6`],blues:[`#dbeafe`,`#93c5fd`,`#3b82f6`,`#1d4ed8`,`#1e3a8a`],purples:[`#f3e8ff`,`#c4b5fd`,`#8b5cf6`,`#6d28d9`,`#4c1d95`],greens:[`#dcfce7`,`#86efac`,`#22c55e`,`#15803d`,`#14532d`],diverging:[`#ef4444`,`#fca5a5`,`#fef3c7`,`#86efac`,`#22c55e`]};function ZS(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function QS(e){return ZS(e)}function $S(e){let t=JSON.parse(JSON.stringify(e)),n=[`vconcat`,`hconcat`,`concat`];if(!n.some(e=>Array.isArray(t[e])))return t;let r=[];if(Array.isArray(t.params))for(let e of t.params)e&&typeof e==`object`&&e.name&&e.select&&r.push({name:e.name,param:e});if(r.length===0)return t;for(let{name:e,param:i}of r){let r=i.select?.fields||[],a=i.select?.bind===`legend`,o=null;for(let e of n)if(Array.isArray(t[e])){o=t[e];break}if(!o||o.length===0)continue;let s=0;for(let e=0;e<o.length;e++){let t=o[e];if(tC(t,r)||a&&nC(t,r)){s=e;break}}let c=o[s];c.params||=[],c.params.push(i),t.params=(t.params??[]).filter(t=>t.name!==e)}return Array.isArray(t.params)&&t.params.length===0&&delete t.params,t}function eC(e,t){if(!t||Object.keys(t).length===0)return e;let n=JSON.parse(JSON.stringify(e)),r=e=>{for(let n of e)n.name&&n.name in t&&(n.value=t[n.name])};Array.isArray(n.params)&&r(n.params);let i=e=>{if(Array.isArray(e)){for(let t of e)if(Array.isArray(t.params)&&r(t.params),t.vconcat&&i(t.vconcat),t.hconcat&&i(t.hconcat),t.concat&&i(t.concat),Array.isArray(t.layer))for(let e of t.layer)Array.isArray(e.params)&&r(e.params)}};if(n.vconcat&&i(n.vconcat),n.hconcat&&i(n.hconcat),n.concat&&i(n.concat),Array.isArray(n.layer))for(let e of n.layer)e&&Array.isArray(e.params)&&r(e.params);return n}function tC(e,t){if(!e?.encoding)return!1;for(let n of t)for(let t of Object.values(e.encoding))if(t.field===n)return!0;if(Array.isArray(e.layer)){for(let n of e.layer)if(tC(n,t))return!0}return!1}function nC(e,t){if(!e)return!1;let n=e=>{if(!e)return!1;let n=e.color?.field;return!!n&&t.includes(n)};if(n(e.encoding))return!0;if(Array.isArray(e.layer)){for(let t of e.layer)if(n(t.encoding))return!0}return!1}function rC(e,t=[]){let n=[];if(!e||typeof e!=`object`)return n;if(e.data&&typeof e.data==`object`){let r=e.data.url;typeof r==`string`&&r.startsWith(`artifact:`)&&n.push({path:[...t,`data`],artifactPath:r.replace(/^artifact:/,``).trim()})}for(let r of[`layer`,`vconcat`,`hconcat`,`concat`,`spec`,`repeat`,`facet`])if(r in e){let i=e[r];Array.isArray(i)?i.forEach((e,i)=>{QS(e)&&n.push(...rC(e,[...t,r,String(i)]))}):QS(i)&&n.push(...rC(i,[...t,r]))}return n}function iC(e,t){let n=JSON.parse(JSON.stringify(e));for(let[e,r]of t){let t=e.split(`.`),i=n;for(let e=0;e<t.length-1;e++){let n=i[t[e]];if(!ZS(n))break;i=n}let a=t[t.length-1],o=i[a];ZS(o)&&(delete o.url,o.values=r)}return n}function aC(e){let t={background:`transparent`,view:{stroke:`transparent`},range:{category:XS.categorical,diverging:XS.diverging,heatmap:XS.purples,ramp:XS.blues},mark:{tooltip:!0},bar:{tooltip:!0,cornerRadiusTopLeft:4,cornerRadiusTopRight:4},line:{tooltip:!0,strokeWidth:2.5,strokeCap:`round`},point:{tooltip:!0,size:60,filled:!0},area:{tooltip:!0,fillOpacity:.7,line:!0},rect:{tooltip:!0,cornerRadius:2},arc:{tooltip:!0,cornerRadius:4},circle:{tooltip:!0,size:80}};return e?{...t,axis:{labelColor:`#a1a1aa`,titleColor:`#e4e4e7`,gridColor:`#3f3f46`,domainColor:`#52525b`,tickColor:`#52525b`,labelFont:`Inter, system-ui, sans-serif`,titleFont:`Inter, system-ui, sans-serif`,labelFontSize:11,titleFontSize:12,titleFontWeight:500},legend:{labelColor:`#a1a1aa`,titleColor:`#e4e4e7`,labelFont:`Inter, system-ui, sans-serif`,titleFont:`Inter, system-ui, sans-serif`,labelFontSize:11,titleFontSize:12,symbolSize:100},title:{color:`#fafafa`,font:`Inter, system-ui, sans-serif`,fontSize:14,fontWeight:600}}:{...t,axis:{labelColor:`#71717a`,titleColor:`#3f3f46`,gridColor:`#e4e4e7`,domainColor:`#d4d4d8`,tickColor:`#d4d4d8`,labelFont:`Inter, system-ui, sans-serif`,titleFont:`Inter, system-ui, sans-serif`,labelFontSize:11,titleFontSize:12,titleFontWeight:500},legend:{labelColor:`#71717a`,titleColor:`#3f3f46`,labelFont:`Inter, system-ui, sans-serif`,titleFont:`Inter, system-ui, sans-serif`,labelFontSize:11,titleFontSize:12,symbolSize:100},title:{color:`#18181b`,font:`Inter, system-ui, sans-serif`,fontSize:14,fontWeight:600}}}const oC=gt(function({spec:r,artifactRunId:i}){let{t:a}=K(),{title:s,description:c,options:l}=r,u=r.spec,[d,f]=G(!1),[p,m]=G(!1),[h,g]=G(null),[_,v]=G(!1),y=W(null),b=W(null),x=W(null),{client:S}=q(),C=VS(),w=W(S);w.current=S;let T=W(C);T.current=C;let[E,D]=G(null),[O,k]=G(!1),[A,j]=G(null),M=l?.mode||`chart`,N=M===`dashboard`,P=l?.enableFullscreen??N,F=l?.height||YS(u,M);H(()=>{let e=rC(u);if(e.length===0){D(u),k(!1),j(null);return}i?console.info(`[VegaLiteChart] resolving artifacts with runId:`,i,e.map(e=>e.artifactPath)):console.warn(`[VegaLiteChart] artifact references found but artifactRunId is missing!`,{references:e.map(e=>e.artifactPath),artifactRunId:i});let t=!1;return k(!0),j(null),(async()=>{let n=new Map,r=w.current,a=T.current;for(let o of e)try{let e=o.path.join(`.`),t;if(i&&!HS(o.artifactPath)){let e=US(i,o.artifactPath,`inline`);t=a?await a.getOrFetch(e,async()=>(await r.files.getArtifactDownloadUrl(i,o.artifactPath,`inline`)).url):(await r.files.getArtifactDownloadUrl(i,o.artifactPath,`inline`)).url}else{let e=WS(o.artifactPath);t=a?await a.getOrFetch(e,async()=>(await r.files.getDownloadUrl(o.artifactPath)).url):(await r.files.getDownloadUrl(o.artifactPath)).url}let s=await fetch(t);if(!s.ok)throw Error(`Failed to fetch artifact data: ${s.statusText}`);let c=o.artifactPath.toLowerCase().endsWith(`.csv`),l;if(c){let{default:e}=await import(`papaparse`),t=await s.text();l=e.parse(t,{header:!0,skipEmptyLines:!0,dynamicTyping:!0}).data}else{let e=await s.json();l=Array.isArray(e)?e:[e]}n.set(e,l)}catch(e){console.error(`Failed to resolve artifact: ${o.artifactPath}`,e),t||j(`Failed to load data from artifact: ${o.artifactPath}`);return}if(!t){let e=iC(u,n);D(e),k(!1)}})(),()=>{t=!0}},[u,i]);let[I,L]=G(!1),ee=W(!1);H(()=>{let e=()=>{let e=document.documentElement.classList.contains(`dark`);e!==ee.current&&(ee.current=e,L(e))};e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>t.disconnect()},[]);let[R,te]=G(0),ne=W(0);H(()=>{if(!x.current)return;let e,t=new ResizeObserver(t=>{clearTimeout(e),e=setTimeout(()=>{let e=t[0]?.contentRect.width;e&&e!==ne.current&&(ne.current=e,te(e))},100)});t.observe(x.current);let n=x.current.clientWidth;return ne.current=n,te(n),()=>{clearTimeout(e),t.disconnect()}},[]);let re=U(()=>rC(u).length>0,[u]),ie=U(()=>{if(re&&!E)return null;let e=E||u;return e?(l?.parameterValues&&(e=eC(e,l.parameterValues)),$S(e)):null},[E,u,re,l?.parameterValues]),ae=V((e,t)=>{if(!e||typeof e!=`object`)return e;if(e.hconcat&&Array.isArray(e.hconcat)){let n=e.hconcat.length,r=(e.spacing??10)*(n-1),i=Math.floor((t-r)/n);return{...e,hconcat:e.hconcat.map(e=>ae(e,i))}}if(e.vconcat&&Array.isArray(e.vconcat))return{...e,vconcat:e.vconcat.map(e=>ae(e,t))};if(e.concat&&Array.isArray(e.concat)){let n=e.columns??e.concat.length,r=(e.spacing??10)*(n-1),i=Math.floor((t-r)/n);return{...e,concat:e.concat.map(e=>ae(e,i))}}let n=e.width;return n===`container`||typeof n==`number`&&n>t?{...e,width:t}:e},[]),oe=V((e,t=!1)=>{if(!ie)return null;let n=aC(I),r=t?typeof window<`u`?Math.min(window.innerWidth-80,1400):1200:R>0?R-24:500,i=`vconcat`in ie||`hconcat`in ie||`concat`in ie,a=i?{type:`pad`,contains:`padding`}:{type:`fit`,contains:`padding`},o=ie;i&&r&&(o=ae(ie,r));let c=o.width,l=i?void 0:c===`container`?r:c??r,{width:u,...d}=o;return{$schema:`https://vega.github.io/schema/vega-lite/v6.json`,...!i&&l?{width:l}:{},height:t?void 0:e,autosize:a,...i?o:d,...s&&!ie.title?{title:s}:{},config:{...n,...ie.config}}},[ie,s,I,R,ae]),se=V(async()=>{let e=_?b.current:y.current;if(!(!e||p))try{(await e.toCanvas(2)).toBlob(async e=>{e&&(await navigator.clipboard.write([new ClipboardItem({"image/png":e})]),m(!0),setTimeout(()=>m(!1),2e3))},`image/png`)}catch(e){console.error(`Failed to copy chart:`,e)}},[p,_]),ce=V(async()=>{let e=_?b.current:y.current;if(!(!e||d)){f(!0);try{let t=await e.toImageURL(`png`,2),n=document.createElement(`a`);n.download=`${s||`chart`}.png`,n.href=t,n.click()}catch(e){console.error(`Failed to export chart:`,e)}finally{f(!1)}}},[s,d,_]),le=V(e=>{y.current=e,g(null)},[]),ue=V(e=>{b.current=e},[]),de=V(e=>{console.error(`Vega-Lite rendering error:`,e),g(e instanceof Error?e.message:`Unknown error`)},[]),fe=V(()=>{v(e=>!e)},[]);H(()=>{g(null)},[u]);let pe=({className:e})=>n(`div`,{className:RS(`flex items-center gap-2`,e),children:[n(o,{variant:`unstyled`,onClick:se,disabled:p,className:`text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors disabled:opacity-50 flex items-center gap-1`,title:a(`agent.copyToClipboard`),children:[t(p?eh:fg,{className:`w-3 h-3`}),a(p?`agent.copied`:`agent.copy`)]}),n(o,{variant:`unstyled`,onClick:ce,disabled:d,className:`text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-1`,title:a(`agent.exportAsPng`),children:[t(xg,{className:`w-3 h-3`}),a(d?`agent.exporting`:`agent.export`)]}),P&&n(o,{variant:`unstyled`,onClick:fe,className:`text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors flex items-center gap-1`,title:a(_?`agent.exitFullscreen`:`agent.fullscreen`),children:[t(_?Dv:lv,{className:`w-3 h-3`}),a(_?`agent.exit`:`agent.fullscreen`)]})]});if(O||re&&!E)return t(`div`,{className:`bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm`,children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[t(`div`,{className:`flex items-center justify-between`,children:t(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:s||`Chart`})}),t(`div`,{className:`flex items-center justify-center bg-gray-50 dark:bg-gray-800 rounded`,style:{width:`100%`,height:F},children:n(`div`,{className:`flex items-center gap-2 text-gray-500 dark:text-gray-400`,children:[t(ev,{className:`w-5 h-5 animate-spin`}),t(`span`,{className:`text-sm`,children:`Loading data from artifacts...`})]})})]})});if(A)return t(`div`,{className:`bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm`,children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[t(`div`,{className:`flex items-center justify-between`,children:t(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:s||`Chart`})}),t(`div`,{style:{width:`100%`,height:F},children:t(KS,{error:A,chartTitle:s})})]})});if(h)return t(`div`,{className:`bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm`,children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[t(`div`,{className:`flex items-center justify-between`,children:t(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:s||`Chart`})}),t(`div`,{style:{width:`100%`,height:F},children:t(KS,{error:h,chartTitle:s})})]})});let me=oe(F),he=oe(0,!0);return me?(typeof window<`u`&&localStorage.getItem(`DEBUG_VEGA_RENDERS`)&&console.log(`VegaLite rendering with spec:`,{title:s,hasData:!!me.data?.values,dataLength:me.data?.values?.length}),n(e,{children:[t(`div`,{className:RS(`bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm`,N&&`border-2`),children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[n(`div`,{className:`flex items-center justify-between`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:s||(N?`Dashboard`:`Chart`)}),N&&t(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-indigo-100 dark:bg-indigo-900 text-indigo-700 dark:text-indigo-300`,children:`Interactive`})]}),t(pe,{})]}),c&&t(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:c}),t(`div`,{ref:x,className:`bg-white dark:bg-gray-900 rounded overflow-hidden`,style:{width:`100%`,height:F,minWidth:0},children:t(ut,{fallback:t(qS,{}),children:t(GS,{spec:me,onEmbed:e=>le(e.view),onError:de,options:{renderer:l?.renderer||`canvas`,actions:!1}})})})]})}),n(JS,{isOpen:_,onClose:()=>v(!1),title:s||(N?`Dashboard`:`Chart`),description:c,children:[t(`div`,{className:`w-full h-full min-h-[calc(100vh-200px)]`,children:he&&t(ut,{fallback:t(qS,{}),children:t(GS,{spec:he,onEmbed:e=>ue(e.view),onError:de,options:{renderer:l?.renderer||`canvas`,actions:!1}})})}),t(`div`,{className:`absolute bottom-6 end-6`,children:t(pe,{className:`bg-white dark:bg-gray-800 rounded-lg shadow-lg p-2 border border-gray-200 dark:border-gray-700`})})]})]})):null},(e,t)=>JSON.stringify(e.spec)===JSON.stringify(t.spec)&&e.artifactRunId===t.artifactRunId);function sC(e){return e.library===`vega-lite`&&typeof e.spec==`object`}function cC(e){return e.library===`recharts`||e.library===void 0}function lC(e){return typeof e.$schema==`string`&&e.$schema.includes(`vega`)}const uC=gt(function({spec:e,artifactRunId:r}){return sC(e)?t(oC,{spec:e,artifactRunId:r}):lC(e)?t(oC,{spec:{library:`vega-lite`,spec:e},artifactRunId:r}):n(`div`,{className:`my-5 rounded-lg border border-attention bg-attention p-4 text-sm text-attention`,children:[`Recharts chart rendering has been retired. Use a Vega-Lite chart spec (`,t(`code`,{children:`library: "vega-lite"`}),` with `,t(`code`,{children:`spec`}),`).`]})},(e,t)=>JSON.stringify(e.spec)===JSON.stringify(t.spec)&&e.artifactRunId===t.artifactRunId);function dC(e,t){return e===`live`?e:t===0?`live`:Math.min(Math.max(e,0),t-1)}function fC(e,t){return t===0?-1:e===`live`?t-1:Math.min(Math.max(e,0),t-1)}function pC(e,t){if(e.length===0)return null;let n=t===`live`?e.length:fC(t,e.length);for(let t=Math.min(n-1,e.length-1);t>=0;t--)if(e[t].type===J.QUESTION)return t;return null}function mC(e,t){if(e.length===0||t===`live`)return null;let n=fC(t,e.length);for(let t=n+1;t<e.length;t++)if(e[t].type===J.QUESTION)return t;return`live`}function hC(e,t,n){let r=n?dC(t,e.length):`live`,i=fC(r,e.length),a=!n||r===`live`,o=a?e:e.slice(0,i+1);return{cursor:r,cursorIndex:i,isLive:a,renderedMessageCount:o.length,displayedMessages:o}}function gC(e){let t=e.indexOf(`?`);return t===-1?new URLSearchParams:new URLSearchParams(e.slice(t+1))}function _C(){return!(typeof window>`u`)}function vC(){if(!_C())return!1;let e=new URLSearchParams(window.location.search),t=gC(window.location.hash),n=e.get(`agentChatPlayback`)??t.get(`agentChatPlayback`);return n===`1`||n===`true`}const yC=_C,bC=vC;Q();function xC({cursor:e,messages:r,onChangeCursor:i,className:a}){let{t:s}=K(),c=r.length,l=e===`live`,u=fC(e,c),d=c>0&&(l||u>0),f=!l&&c>0,p=c>0&&(l||u>0),m=!l&&c>0&&u<c-1,h=c===0?0:u+1,[g,_]=G(String(h));H(()=>{_(String(h))},[h]);let v=()=>{if(c!==0){if(e===`live`){i(c-1);return}i(Math.max(0,u-1))}},y=()=>{if(c!==0&&e!==`live`){if(u>=c-1){i(`live`);return}i(u+1)}},b=()=>{c!==0&&i(0)},x=()=>{c!==0&&i(c-1)},S=()=>{_(String(h))},C=(e,t=!1)=>{if(c===0){_(`0`);return}let n=Number.parseInt(e,10);if(!Number.isFinite(n)){t&&S();return}let r=Math.min(Math.max(n,1),c);_(String(r)),i(r-1)},w=e=>{c!==0&&C(e)},T=c>1,E=+!!T,D=Math.max(1,c),O=`size-7 rounded-lg text-muted hover:text-foreground disabled:opacity-35`,k=`${Math.max(3,String(c).length+1)}ch`;return n(`div`,{className:z(`inline-flex max-w-full flex-col gap-1 rounded-xl border border-border/70 bg-background/95 px-2 py-1 text-sm leading-none text-muted shadow-lg shadow-black/10 backdrop-blur`,a),"data-testid":`agent-test-playback-controls`,"data-playback-cursor":e,"data-live-message-count":c,"data-rendered-message-count":l?c:u+1,children:[n(`div`,{className:`flex max-w-full items-center gap-1`,children:[t(`span`,{className:`ms-2 me-1 font-medium leading-none text-foreground/80`,children:s(`agent.rewind.label`)}),t(o,{type:`button`,variant:`ghost`,size:`icon`,title:s(`agent.rewind.jumpToStart`),disabled:!p,onClick:b,className:O,children:t(vh,{className:`size-4`})}),t(o,{type:`button`,variant:`ghost`,size:`icon`,title:s(`agent.rewind.previousMessage`),disabled:!d,onClick:v,className:O,children:t(oh,{className:`size-4`})}),n(`span`,{className:`inline-flex min-w-16 items-center justify-center gap-0.5 px-1 font-medium leading-none tabular-nums text-foreground/80`,"data-testid":`agent-test-playback-position`,children:[t(te,{type:`text`,variant:`unstyled`,size:`sm`,clearable:!1,inputMode:`numeric`,pattern:`[0-9]*`,value:g,"aria-label":s(`agent.rewind.positionInput`),disabled:c===0,onChange:e=>{let t=e.replace(/\D/g,``);_(t)},onBlur:e=>C(e.currentTarget.value,!0),onKeyDown:e=>{e.key===`Enter`&&(C(e.currentTarget.value,!0),e.currentTarget.blur())},style:{width:k},className:`h-7 w-auto rounded-md border border-transparent bg-transparent px-1 text-center text-sm font-medium leading-none tabular-nums text-foreground outline-none transition-colors hover:border-border focus:border-ring focus:bg-muted/30 disabled:opacity-50`}),t(`span`,{"aria-hidden":`true`,className:`text-muted`,children:`/`}),t(`span`,{className:`text-muted`,children:c})]}),t(o,{type:`button`,variant:`ghost`,size:`icon`,title:s(`agent.rewind.nextMessage`),disabled:!f,onClick:y,className:O,children:t(lh,{className:`size-4`})}),t(o,{type:`button`,variant:`ghost`,size:`icon`,title:s(`agent.rewind.jumpToLatest`),disabled:!m,onClick:x,className:O,children:t(xh,{className:`size-4`})}),t(o,{type:`button`,variant:l?`secondary`:`ghost`,size:`icon`,title:s(`agent.rewind.jumpToLive`),disabled:l,onClick:()=>i(`live`),className:z(O,l&&`bg-muted text-foreground`),children:t(ly,{className:`size-4`})})]}),t(`div`,{className:`px-2 pb-1`,children:t(ke,{min:E,max:D,step:1,value:[h],"aria-label":s(`agent.rewind.positionInput`),disabled:!T,onValueChange:([e])=>w(String(e)),className:`h-2`})})]})}var SC=typeof document<`u`?bt:function(){};function CC(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!CC(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!CC(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function wC(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function TC(e,t){let n=wC(e);return Math.round(t*n)/n}function EC(e){let t=B.useRef(e);return SC(()=>{t.current=e}),t}function DC(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=B.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=B.useState(r);CC(f,r)||p(r);let[m,h]=B.useState(null),[g,_]=B.useState(null),v=B.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=B.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=B.useRef(null),C=B.useRef(null),w=B.useRef(u),T=c!=null,E=EC(c),D=EC(i),O=EC(l),k=B.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),Fn(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!CC(w.current,t)&&(w.current=t,tn.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);SC(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=B.useRef(!1);SC(()=>(A.current=!0,()=>{A.current=!1}),[]),SC(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=B.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=B.useMemo(()=>({reference:b,floating:x}),[b,x]),N=B.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=TC(M.floating,u.x),r=TC(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...wC(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return B.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:N}),[u,k,j,M,N])}const OC=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:Nn({element:r.current,padding:i}).fn(n):r?Nn({element:r,padding:i}).fn(n):{}}}},kC=(e,t)=>{let n=zn(e);return{name:n.name,fn:n.fn,options:[e,t]}},AC=(e,t)=>{let n=Bn(e);return{name:n.name,fn:n.fn,options:[e,t]}},jC=(e,t)=>({fn:Rn(e).fn,options:[e,t]}),MC=(e,t)=>{let n=In(e);return{name:n.name,fn:n.fn,options:[e,t]}},NC=(e,t)=>{let n=Vn(e);return{name:n.name,fn:n.fn,options:[e,t]}},PC=(e,t)=>{let n=Ln(e);return{name:n.name,fn:n.fn,options:[e,t]}},FC=(e,t)=>{let n=OC(e);return{name:n.name,fn:n.fn,options:[e,t]}};var IC=Object.defineProperty,LC=(e,t)=>IC(e,`name`,{value:t,configurable:!0});function RC(e){let t=B.useRef(e);return B.useEffect(()=>{t.current=e}),B.useMemo(()=>((...e)=>t.current?.(...e)),[])}LC(RC,`useCallbackRef`);var zC=Object.defineProperty,BC=(e,t)=>zC(e,`name`,{value:t,configurable:!0});function VC(e){let[t,n]=B.useState(void 0);return mx(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}BC(VC,`useSize`);var HC=Object.defineProperty,UC=(e,t)=>HC(e,`name`,{value:t,configurable:!0}),WC=`Popper`,[GC,KC]=fx(WC),[qC,JC]=GC(WC),YC=UC(e=>{let{__scopePopper:n,children:r}=e,[i,a]=B.useState(null),[o,s]=B.useState(void 0);return t(qC,{scope:n,anchor:i,onAnchorChange:a,placementState:o,setPlacementState:s,children:r})},`Popper`),XC=`PopperAnchor`,ZC=B.forwardRef(UC(function(e,n){let{__scopePopper:r,virtualRef:i,...a}=e,o=JC(XC,r),s=B.useRef(null),c=o.onAnchorChange,l=cx(n,B.useCallback(e=>{s.current=e,e&&c(e)},[c])),u=B.useRef(null);B.useEffect(()=>{if(!i)return;let e=u.current;u.current=i.current,e!==u.current&&c(u.current)});let d=o.placementState&&iw(o.placementState),f=d?.[0],p=d?.[1];return i?null:t(Zx.div,{"data-radix-popper-side":f,"data-radix-popper-align":p,...a,ref:l})},`PopperAnchor`)),QC=`PopperContent`,[$C,ew]=GC(QC),tw=B.forwardRef(UC(function(e,n){let{__scopePopper:r,side:i=`bottom`,sideOffset:a=0,align:o=`center`,alignOffset:s=0,arrowPadding:c=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f=`partial`,hideWhenDetached:p=!1,updatePositionStrategy:m=`optimized`,onPlaced:h,...g}=e,_=JC(QC,r),[v,y]=B.useState(null),b=cx(n,y),[x,S]=B.useState(null),C=VC(x),w=C?.width??0,T=C?.height??0,E=i+(o===`center`?``:`-`+o),D=typeof d==`number`?d:{top:0,right:0,bottom:0,left:0,...d},O=Array.isArray(u)?u:[u],k=O.length>0,A={padding:D,boundary:O.filter(nw),altBoundary:k},{refs:j,floatingStyles:M,placement:N,isPositioned:P,middlewareData:F}=DC({strategy:`fixed`,placement:E,whileElementsMounted:UC((...e)=>Pn(...e,{animationFrame:m===`always`}),`whileElementsMounted`),elements:{reference:_.anchor},middleware:[kC({mainAxis:a+T,alignmentAxis:s}),l&&AC({mainAxis:!0,crossAxis:!1,limiter:f===`partial`?jC():void 0,...A}),l&&MC({...A}),NC({...A,apply:UC(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),x&&FC({element:x,padding:c}),rw({arrowWidth:w,arrowHeight:T}),p&&PC({strategy:`referenceHidden`,...A,boundary:k?A.boundary:void 0})]}),I=_.setPlacementState;mx(()=>(I(N),()=>{I(void 0)}),[N,I]);let[L,ee]=iw(N),R=RC(h);mx(()=>{P&&R?.()},[P,R]);let te=F.arrow?.x,ne=F.arrow?.y,re=F.arrow?.centerOffset!==0,[ie,ae]=B.useState();return mx(()=>{v&&ae(window.getComputedStyle(v).zIndex)},[v]),t(`div`,{ref:j.setFloating,"data-radix-popper-content-wrapper":``,style:{...M,transform:P?M.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:ie,"--radix-popper-transform-origin":[F.transformOrigin?.x,F.transformOrigin?.y].join(` `),...F.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:t($C,{scope:r,placedSide:L,placedAlign:ee,onArrowChange:S,arrowX:te,arrowY:ne,shouldHideArrow:re,children:t(Zx.div,{"data-side":L,"data-align":ee,...g,ref:b,style:{...g.style,animation:P?g.style?.animation:`none`}})})})},`PopperContent`));function nw(e){return e!==null}UC(nw,`isNotNull`);var rw=UC(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=iw(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function iw(e){let[t,n=`center`]=e.split(`-`);return[t,n]}UC(iw,`getSideAndAlignFromPlacement`);var aw=YC,ow=ZC,sw=tw,cw=Object.defineProperty,lw=(e,t)=>cw(e,`name`,{value:t,configurable:!0}),uw=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),dw=B.forwardRef(lw(function(e,n){return t(Zx.span,{...e,ref:n,style:{...uw,...e.style}})},`VisuallyHidden`)),fw=Object.defineProperty,pw=(e,t)=>fw(e,`name`,{value:t,configurable:!0}),[mw,hw]=fx(`Tooltip`,[KC]),gw=KC(),_w=`TooltipProvider`,vw=700,yw=`tooltip.open`,[bw,xw]=mw(_w),Sw=pw(e=>{let{__scopeTooltip:n,delayDuration:r=vw,skipDelayDuration:i=300,disableHoverableContent:a=!1,children:o}=e,s=B.useRef(!0),c=B.useRef(!1),l=B.useRef(0);return B.useEffect(()=>{let e=l.current;return()=>window.clearTimeout(e)},[]),t(bw,{scope:n,isOpenDelayedRef:s,delayDuration:r,onOpen:B.useCallback(()=>{i<=0||(window.clearTimeout(l.current),s.current=!1)},[i]),onClose:B.useCallback(()=>{i<=0||(window.clearTimeout(l.current),l.current=window.setTimeout(()=>s.current=!0,i))},[i]),isPointerInTransitRef:c,onPointerInTransitChange:B.useCallback(e=>{c.current=e},[]),disableHoverableContent:a,children:o})},`TooltipProvider`),Cw=`Tooltip`,[ww,Tw]=mw(Cw),Ew=pw(e=>{let{__scopeTooltip:n,children:r,open:i,defaultOpen:a,onOpenChange:o,disableHoverableContent:s,delayDuration:c}=e,l=xw(Cw,e.__scopeTooltip),u=gw(n),[d,f]=B.useState(null),[p,m]=B.useState(void 0),h=yx(),g=B.useRef(0),_=s??l.disableHoverableContent,v=c??l.delayDuration,y=B.useRef(!1),[b,x]=Ox({prop:i,defaultProp:a??!1,onChange:pw(e=>{e?(l.onOpen(),document.dispatchEvent(new CustomEvent(yw))):l.onClose(),o?.(e)},`onChange`),caller:Cw}),S=B.useMemo(()=>b?y.current?`delayed-open`:`instant-open`:`closed`,[b]),C=B.useCallback(()=>{window.clearTimeout(g.current),g.current=0,y.current=!1,x(!0)},[x]),w=B.useCallback(()=>{window.clearTimeout(g.current),g.current=0,x(!1)},[x]),T=B.useCallback(()=>{window.clearTimeout(g.current),g.current=window.setTimeout(()=>{y.current=!0,x(!0),g.current=0},v)},[v,x]);B.useEffect(()=>()=>{g.current&&=(window.clearTimeout(g.current),0)},[]);let E=p??h;return t(aw,{...u,children:t(ww,{scope:n,contentId:E,setContentId:m,open:b,stateAttribute:S,trigger:d,onTriggerChange:f,onTriggerEnter:B.useCallback(()=>{l.isOpenDelayedRef.current?T():C()},[l.isOpenDelayedRef,T,C]),onTriggerLeave:B.useCallback(()=>{_?w():(window.clearTimeout(g.current),g.current=0)},[w,_]),onOpen:C,onClose:w,disableHoverableContent:_,children:r})})},`Tooltip`),Dw=`TooltipTrigger`,Ow=B.forwardRef(pw(function(e,n){let{__scopeTooltip:r,...i}=e,a=Tw(Dw,r),o=xw(Dw,r),s=gw(r),c=cx(n,B.useRef(null),a.onTriggerChange),l=B.useRef(!1),u=B.useRef(!1),d=B.useCallback(()=>l.current=!1,[]);return B.useEffect(()=>()=>document.removeEventListener(`pointerup`,d),[d]),t(ow,{asChild:!0,...s,children:t(Zx.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...i,ref:c,onPointerMove:$b(e.onPointerMove,e=>{e.pointerType!==`touch`&&!u.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),u.current=!0)}),onPointerLeave:$b(e.onPointerLeave,()=>{a.onTriggerLeave(),u.current=!1}),onPointerDown:$b(e.onPointerDown,()=>{a.open&&a.onClose(),l.current=!0,document.addEventListener(`pointerup`,d,{once:!0})}),onFocus:$b(e.onFocus,()=>{l.current||a.onOpen()}),onBlur:$b(e.onBlur,a.onClose),onClick:$b(e.onClick,a.onClose)})})},`TooltipTrigger`)),kw=`TooltipPortal`,[Aw,jw]=mw(kw,{forceMount:void 0}),Mw=pw(e=>{let{__scopeTooltip:n,forceMount:r,children:i,container:a}=e,o=Tw(kw,n);return t(Aw,{scope:n,forceMount:r,children:t(iS,{present:r||o.open,children:t(eS,{asChild:!0,container:a,children:i})})})},`TooltipPortal`),Nw=`TooltipContent`,Pw=B.forwardRef(pw(function(e,n){let r=jw(Nw,e.__scopeTooltip),{forceMount:i=r.forceMount,side:a=`top`,...o}=e,s=Tw(Nw,e.__scopeTooltip);return t(iS,{present:i||s.open,children:s.disableHoverableContent?t(Lw,{side:a,...o,ref:n}):t(Fw,{side:a,...o,ref:n})})},`TooltipContent`)),Fw=B.forwardRef(pw(function(e,n){let r=Tw(Nw,e.__scopeTooltip),i=xw(Nw,e.__scopeTooltip),a=B.useRef(null),o=cx(n,a),[s,c]=B.useState(null),{trigger:l,onClose:u}=r,d=a.current,{onPointerInTransitChange:f}=i,p=B.useCallback(()=>{c(null),f(!1)},[f]),m=B.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=zw(r,Rw(r,n.getBoundingClientRect())),a=Bw(t.getBoundingClientRect()),o=Hw([...i,...a]);c(o),f(!0)},[f]);return B.useEffect(()=>()=>p(),[p]),B.useEffect(()=>{if(l&&d){let e=pw(e=>m(e,d),`handleTriggerLeave`),t=pw(e=>m(e,l),`handleContentLeave`);return l.addEventListener(`pointerleave`,e),d.addEventListener(`pointerleave`,t),()=>{l.removeEventListener(`pointerleave`,e),d.removeEventListener(`pointerleave`,t)}}},[l,d,m,p]),B.useEffect(()=>{if(s){let e=pw(e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=l?.contains(t)||d?.contains(t),i=!Vw(n,s);r?p():i&&(p(),u())},`handleTrackPointerGrace`);return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[l,d,s,u,p]),t(Lw,{...e,ref:o})},`TooltipContentHoverable`)),Iw=Rx(`TooltipContent`),Lw=B.forwardRef(pw(function(e,r){let{__scopeTooltip:i,children:a,"aria-label":o,id:s,onEscapeKeyDown:c,onPointerDownOutside:l,...u}=e,d=Tw(Nw,i),f=gw(i),{onClose:p}=d;B.useEffect(()=>(document.addEventListener(yw,p),()=>document.removeEventListener(yw,p)),[p]),B.useEffect(()=>{if(d.trigger){let e=pw(e=>{e.target instanceof Node&&e.target.contains(d.trigger)&&p()},`handleScroll`);return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[d.trigger,p]);let{setContentId:m}=d;return mx(()=>(m(s),()=>{m(void 0)}),[s,m]),t(Qt,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:c,onPointerDownOutside:l,onFocusOutside:e=>e.preventDefault(),onDismiss:p,children:n(sw,{"data-state":d.stateAttribute,role:o?void 0:`tooltip`,id:o?void 0:d.contentId,...f,...u,ref:r,style:{...u.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[t(Iw,{children:a}),o?t(dw,{id:d.contentId,role:`tooltip`,children:o}):null]})})},`TooltipContentImpl`));function Rw(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}pw(Rw,`getExitSideFromRect`);function zw(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}pw(zw,`getPaddedExitPoints`);function Bw(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}pw(Bw,`getPointsFromRect`);function Vw(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}pw(Vw,`isPointInPolygon`);function Hw(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),Uw(t)}pw(Hw,`getHull`);function Uw(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}pw(Uw,`getHullPresorted`);var Ww=Sw,Gw=Ew,Kw=Ow,qw=Mw,Jw=Pw;const Yw=ot.createContext(void 0);function Xw(){return ot.useContext(Yw)}const Zw=Ww,Qw=Gw,$w=Kw,eT=B.forwardRef(({className:e,sideOffset:n=4,side:r=`top`,...i},a)=>{let o=Xw();return t(qw,{container:o,children:t(Jw,{ref:a,sideOffset:n,side:r,style:{zIndex:100},className:RS(`max-w-[90vw]`,`z-50 overflow-hidden rounded-md bg-tooltips border border-border px-3 py-1.5 text-xs animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...i})})});eT.displayName=Jw.displayName;function tT({description:e,children:r,size:i=`sm`,placement:a=`top`,className:o,asChild:s}){let[c,l]=B.useState(!1),u=B.useRef(!1);return B.useEffect(()=>{let e=()=>{l(!1),u.current=!0,requestAnimationFrame(()=>{u.current=!1})};return window.addEventListener(`blur`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`blur`,e),document.removeEventListener(`visibilitychange`,e)}},[]),t(Zw,{delayDuration:0,children:n(Qw,{open:c,onOpenChange:e=>{u.current||l(e)},children:[t($w,{className:`cursor-pointer`,asChild:s,children:r}),t(eT,{side:a,className:`px-3 py-1.5 max-w-${i} text-${i} px-3 ${o}`,children:e})]})})}Q();const nT=new Set;function rT(e,t,n){H(()=>{t&&!nT.has(e)&&(nT.add(e),console.warn(`[@vertesia/ui] ${e} is deprecated: ${n}`))},[t,n,e])}function iT(e){return B.Children.toArray(e).some(e=>{if(typeof e==`string`)return e.trim().length>0;if(typeof e==`number`)return!0;if(B.isValidElement(e)){let t=e.props;return t[`aria-hidden`]===!0||t[`aria-hidden`]===`true`?!1:iT(t.children)}return!1})}const aT=Mn(`hover:cursor-pointer inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,{variants:{variant:{destructive:`bg-destructive text-destructive ring-1 ring-inset ring-destructive/50 shadow-xs hover:bg-destructive/50`,outline:`border border-input bg-background shadow-xs hover:bg-muted ring-inset`,secondary:`bg-info text-info shadow-xs hover:bg-mixer-info/10 ring-inset`,ghost:`hover:bg-muted/50 dark:hover:bg-muted/20 ring-inset`,link:`text-foreground underline-offset-4 hover:underline ring-inset`,primary:`bg-primary text-primary shadow-xs hover:bg-primary/90 ring-inset`,unstyled:``},size:{xs:`h-7 rounded px-2 py-1 text-xs gap-x-1`,sm:`h-8 rounded px-3 text-xs`,md:`h-9 rounded-md px-4 py-2`,lg:`h-10 rounded-md px-3`,xl:`rounded-md px-3.5 py-2.5 text-sm gap-x-2`,icon:`p-0 m-0 rounded-full`,none:``}},defaultVariants:{variant:`primary`,size:`md`}}),oT=B.forwardRef(({className:r,variant:i,size:a,asChild:o=!1,alt:s,isDisabled:c,isLoading:l,title:u,tooltipPlacement:d=`top`,onClick:f,type:p,...m},h)=>{rT(`Button.alt`,s!==void 0,"use `title` instead — it drives the same tooltip and the accessible name. `alt` remains an alias for one release.");let g=o?Ix:`button`,_=o?p:p??`button`,v=u??s,y=m[`aria-label`]??s??(iT(m.children)?void 0:u),b=o?m.children:n(e,{children:[l&&t(ev,{className:`animate-spin`}),m.children]}),x=t(g,{className:it(RS(aT({variant:i,size:a})),r),disabled:c||l||m.disabled,ref:h,onClick:f,type:_,autoFocus:!1,...m,"aria-label":y,children:b});return v?t(tT,{description:v,asChild:!0,className:`cursor-pointer`,size:`xs`,placement:d,children:x}):x});oT.displayName=`Button`;const sT=B.forwardRef(({size:e,content:n,toast:r,className:i,alt:a,"aria-label":o,...s},c)=>{let[l,u]=G(!1),{t:d}=K();rT(`CopyButton.alt`,a!==void 0,"use aria-label for the accessible name. `alt` is forwarded for one release.");let f=e=>{e.stopPropagation(),navigator.clipboard.writeText(n).then(()=>{u(!0),setTimeout(()=>u(!1),2e3),r?.toast&&r.toast({status:`success`,title:r.message||d(`misc.copiedToClipboard`),duration:2e3})}).catch(e=>{console.error(`Failed to copy text: `,e),r?.toast&&r.toast({status:`error`,title:d(`misc.failedToCopy`),duration:2e3})})},p=o??a??d(`misc.copy`);return t(oT,{ref:c,className:RS(i),variant:`unstyled`,size:e||`sm`,onClick:f,...s,title:p,children:l?t(eh,{className:`text-success`}):t(fg,{className:`size-4`})})});sT.displayName=`CopyButton`;function cT(e){return t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e(t))}}const lT=Mn(`inline-flex items-center rounded-md px-2 py-1 text-xs font-medium`,{variants:{variant:{default:`text-foreground bg-muted`,secondary:`bg-secondary text-info`,destructive:`bg-destructive text-destructive`,attention:`bg-attention text-attention`,success:`bg-success text-success`,info:`bg-info text-info`,done:`bg-done text-done`,outline:`bg-transparent border border-border text-foreground`}},defaultVariants:{variant:`default`}});function uT({className:e,variant:n,children:r,onClick:i,...a}){let o=i?{role:`button`,tabIndex:0,onClick:i,onKeyDown:cT(i)}:{};return t(`span`,{className:RS(lT({variant:n}),e),...o,...a,children:r})}Mn(`inline-flex items-center gap-x-1.5 rounded-md px-2 py-1 text-xs font-medium ring-1 ring-inset ring-border`,{variants:{variant:{default:``,success:``,destructive:``,attention:``,done:``,info:``,outline:``}},defaultVariants:{variant:`default`}}),Mn(`h-1.5 w-1.5`,{variants:{variant:{default:`fill-foreground`,success:`fill-success`,destructive:`fill-destructive`,attention:`fill-attention`,done:`fill-done`,info:`fill-info`,outline:`fill-foreground`}},defaultVariants:{variant:`default`}});function dT({children:e}){return t(`span`,{style:{border:0,clip:`rect(0 0 0 0)`,height:`1px`,margin:`-1px`,overflow:`hidden`,padding:0,position:`absolute`,width:`1px`,whiteSpace:`nowrap`,wordWrap:`normal`},children:e})}Q();const fT=dt(!1);function pT({children:e}){return t(fT.Provider,{value:!0,children:e})}function mT({className:e,children:r,isOpen:i,onClose:a,description:o=`Modal Description`,noCloseButton:s=!1,allowOverflow:c=!1,disableCloseOnClickOutside:l=!1,size:u=`md`,action:d}){let f=e=>{e||a()};function p(){switch(u){case`sm`:return`max-w-[20vw]`;case`md`:return`max-w-[60vw] lg:max-w-[40vw]`;case`lg`:return`max-w-[80vw] md:max-w-[60vw]`;case`xl`:return`max-w-[95vw] lg:max-w-[80vw]`;case`full`:return`h-[calc(100vh-2rem)] max-w-[calc(100vw-2rem)]`;default:return`max-w-[60vw] lg:max-w-[40vw]`}}return n(_T,{open:i,onOpenChange:e=>{(!l||e)&&f(e)},children:[c&&t(bT,{className:`z-50 fixed inset-0 bg-black/80`}),t(dT,{children:t(ST,{children:o})}),n(xT,{className:RS(`min-h-20 p-4`,`fixed left-[50%] top-[50%] z-50 grid w-full translate-x-[-50%] translate-y-[-50%] border bg-background shadow-lg duration-200 sm:rounded-lg`,p(),e),children:[t(`div`,{className:`top-4 end-4 absolute`,children:n(`div`,{className:`flex gap-2`,children:[d&&d,!s&&t(yT,{onClick:()=>f(!1),asChild:!0,autoFocus:!1,children:t(oT,{variant:`outline`,title:`Close`,className:`data-[state=open]:bg-muted opacity-70 hover:opacity-100 rounded-sm focus:outline-none focus:ring-2 focus:ring-ring ring-offset-background focus:ring-offset-2 data-[state=open]:text-muted transition-opacity disabled:pointer-events-none`,children:t(Gb,{className:`size-4`})})})]})}),t(pT,{children:r})]})]})}const hT=({children:e,show:r=!0,className:i,description:a,showDivider:o=!1,...s})=>r?n(CT,{className:RS(o?`border-b-solid border-b border-b-1 pb-2 mb-4`:``,`text-lg font-semibold leading-6 tracking-tight`,{"py-2":!a},i),...s,children:[e,a&&t(ST,{className:`text-sm !font-normal text-muted pb-2`,children:a})]}):n(dT,{children:[t(CT,{children:e}),a&&t(ST,{children:a})]}),gT=({children:e,className:n,...r})=>t(`div`,{className:RS(`text-sm max-h-[80vh] overflow-y-auto`,n),...r,children:e}),_T=_S,vT=xS,yT=IS,bT=B.forwardRef(({className:e,...n},r)=>t(CS,{ref:r,className:RS(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...n}));bT.displayName=CS.displayName;const xT=B.forwardRef(({className:e,children:r,...i},a)=>{let o=Xw();return n(vT,{container:o,children:[t(bT,{}),t(DS,{ref:a,className:RS(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] border bg-background shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg`,e),...i,children:r})]})});xT.displayName=DS.displayName;const ST=B.forwardRef(({className:e,...n},r)=>t(PS,{ref:r,className:RS(`text-sm text-muted`,e),...n}));ST.displayName=PS.displayName;const CT=B.forwardRef(({className:e,...n},r)=>t(MS,{ref:r,className:RS(`text-lg font-semibold leading-none tracking-tight`,e),...n}));CT.displayName=MS.displayName;var wT=Object.defineProperty,TT=(e,t)=>wT(e,`name`,{value:t,configurable:!0});function ET(e){let n=e+`CollectionProvider`,[r,i]=fx(n),[a,o]=r(n,{collectionRef:{current:null},itemMap:new Map}),s=TT(e=>{let{scope:n,children:r}=e,i=B.useRef(null),o=B.useRef(new Map).current;return t(a,{scope:n,itemMap:o,collectionRef:i,children:r})},`CollectionProvider`);s.displayName=n;let c=e+`CollectionSlot`,l=Fx(c),u=B.forwardRef((e,n)=>{let{scope:r,children:i}=e,a=cx(n,o(c,r).collectionRef);return t(l,{ref:a,children:i})});u.displayName=c;let d=e+`CollectionItemSlot`,f=`data-radix-collection-item`,p=Fx(d),m=B.forwardRef((e,n)=>{let{scope:r,children:i,...a}=e,s=B.useRef(null),c=cx(n,s),l=o(d,r);return B.useEffect(()=>(l.itemMap.set(s,{ref:s,...a}),()=>void l.itemMap.delete(s))),t(p,{[f]:``,ref:c,children:i})});m.displayName=d;function h(t){let n=o(e+`CollectionConsumer`,t);return B.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${f}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return TT(h,`useCollection`),[{Provider:s,Slot:u,ItemSlot:m},h,i]}TT(ET,`createCollection`);var DT=new WeakMap,OT=class e extends Map{static{TT(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],DT.set(this,!0)}set(e,t){return DT.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,t),this}insert(e,t,n){let r=this.has(t),i=this.#e.length,a=jT(e),o=a>=0?a:i+a,s=o<0||o>=i?-1:o;if(s===this.size||r&&s===this.size-1||s===-1)return this.set(t,n),this;let c=this.size+ +!r;a<0&&o++;let l=[...this.#e],u,d=!1;for(let e=o;e<c;e++)if(o===e){let i=l[e];l[e]===t&&(i=l[e+1]),r&&this.delete(t),u=this.get(i),this.set(t,n)}else{!d&&l[e-1]===t&&(d=!0);let n=l[d?e:e-1],r=u;u=this.get(n),this.delete(n),this.set(n,r)}return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=this.#e.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r,t,n)}after(e){let t=this.#e.indexOf(e);if(t=t===-1||t===this.size-1?-1:t+1,t!==-1)return this.entryAt(t)}setAfter(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#e.splice(this.#e.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return t!==void 0&&this.delete(t)}at(e){let t=kT(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=kT(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return kT(this.#e,e)}from(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return-1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=0,i=n??this.at(0);for(let n of this)i=r===0&&e.length===1?n:Reflect.apply(t,this,[i,n,r,this]),r++;return i}reduceRight(...e){let[t,n]=e,r=n??this.at(-1);for(let n=this.size-1;n>=0;n--){let i=this.at(n);r=n===this.size-1&&e.length===1?i:Reflect.apply(t,this,[r,i,n,this])}return r}toSorted(t){let n=[...this.entries()].sort(t);return new e(n)}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e,i=this.size-1;if(t===void 0)return r;t<0&&(t+=this.size),n!==void 0&&n>0&&(i=n-1);for(let e=t;e<=i;e++){let t=this.keyAt(e),n=this.get(t);r.set(t,n)}return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}};function kT(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=AT(e,t);return n===-1?void 0:e[n]}TT(kT,`at`);function AT(e,t){let n=e.length,r=jT(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}TT(AT,`toSafeIndex`);function jT(e){return e!==e||e===0?0:Math.trunc(e)}TT(jT,`toSafeInteger`);function MT(e){let n=e+`CollectionProvider`,[r,i]=fx(n),[a,o]=r(n,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new OT,setItemMap:TT(()=>void 0,`setItemMap`)}),s=TT(({state:e,...n})=>e?t(l,{...n,state:e}):t(c,{...n}),`CollectionProvider`);s.displayName=n;let c=TT(e=>{let n=g();return t(l,{...e,state:n})},`CollectionInit`);c.displayName=n+`Init`;let l=TT(e=>{let{scope:n,children:r,state:i}=e,o=B.useRef(null),[s,c]=B.useState(null),l=cx(o,c),[u,d]=i;return B.useEffect(()=>{if(!s)return;let e=IT(()=>{});return e.observe(s,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[s]),t(a,{scope:n,itemMap:u,setItemMap:d,collectionRef:l,collectionRefObject:o,collectionElement:s,children:r})},`CollectionProviderImpl`);l.displayName=n+`Impl`;let u=e+`CollectionSlot`,d=Fx(u),f=B.forwardRef((e,n)=>{let{scope:r,children:i}=e,a=cx(n,o(u,r).collectionRef);return t(d,{ref:a,children:i})});f.displayName=u;let p=e+`CollectionItemSlot`,m=Fx(p),h=B.forwardRef((e,n)=>{let{scope:r,children:i,...a}=e,s=B.useRef(null),[c,l]=B.useState(null),u=cx(n,s,l),{setItemMap:d}=o(p,r),f=B.useRef(a);NT(f.current,a)||(f.current=a);let h=f.current;return B.useEffect(()=>{let e=h;return d(t=>c?t.has(c)?t.set(c,{...e,element:c}).toSorted(FT):(t.set(c,{...e,element:c}),t.toSorted(FT)):t),()=>{d(e=>!c||!e.has(c)?e:(e.delete(c),new OT(e)))}},[c,h,d]),t(m,{"data-radix-collection-item":``,ref:u,children:i})});h.displayName=p;function g(){return B.useState(new OT)}TT(g,`useInitCollection`);function _(t){let{itemMap:n}=o(e+`CollectionConsumer`,t);return n}return TT(_,`useCollection`),[{Provider:s,Slot:f,ItemSlot:h},{createCollectionScope:i,useCollection:_,useInitCollection:g}]}TT(MT,`createCollection`);function NT(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||e[r]!==t[r])return!1;return!0}TT(NT,`shallowEqual`);function PT(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}TT(PT,`isElementPreceding`);function FT(e,t){return!e[1].element||!t[1].element?0:PT(e[1].element,t[1].element)?-1:1}TT(FT,`sortByDocumentPosition`);function IT(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}TT(IT,`getChildListObserver`);var LT=Object.defineProperty,RT=(e,t)=>LT(e,`name`,{value:t,configurable:!0}),zT=!1;function BT(){let[e,t]=B.useState(zT);return B.useEffect(()=>{zT||(zT=!0,t(!0))},[]),e}RT(BT,`useIsHydrated`);var VT=B.useSyncExternalStore;function HT(){return()=>{}}RT(HT,`subscribe`);function UT(){return VT(HT,()=>!0,()=>!1)}RT(UT,`useIsHydratedModern`);var WT=typeof VT==`function`?UT:BT,GT=Object.defineProperty,KT=(e,t)=>GT(e,`name`,{value:t,configurable:!0}),qT=`rovingFocusGroup.onEntryFocus`,JT={bubbles:!1,cancelable:!0},YT=`RovingFocusGroup`,[XT,ZT,QT]=ET(YT),[$T,eE]=fx(YT,[QT]),[tE,nE]=$T(YT),rE=B.forwardRef(KT(function(e,n){return t(XT.Provider,{scope:e.__scopeRovingFocusGroup,children:t(XT.Slot,{scope:e.__scopeRovingFocusGroup,children:t(iE,{...e,ref:n})})})},`RovingFocusGroup`)),iE=B.forwardRef(KT(function(e,n){let{__scopeRovingFocusGroup:r,orientation:i,loop:a=!1,dir:o,currentTabStopId:s,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,p=B.useRef(null),m=cx(n,p),h=Un(o),[g,_]=Ox({prop:s,defaultProp:c??null,onChange:l,caller:YT}),[v,y]=B.useState(!1),b=RC(u),x=ZT(r),S=B.useRef(!1),[C,w]=B.useState(0);return B.useEffect(()=>{let e=p.current;if(e)return e.addEventListener(qT,b),()=>e.removeEventListener(qT,b)},[b]),t(tE,{scope:r,orientation:i,dir:h,loop:a,currentTabStopId:g,onItemFocus:B.useCallback(e=>_(e),[_]),onItemShiftTab:B.useCallback(()=>y(!0),[]),onFocusableItemAdd:B.useCallback(()=>w(e=>e+1),[]),onFocusableItemRemove:B.useCallback(()=>w(e=>e-1),[]),children:t(Zx.div,{tabIndex:v||C===0?-1:0,"data-orientation":i,...f,ref:m,style:{outline:`none`,...e.style},onMouseDown:$b(e.onMouseDown,()=>{S.current=!0}),onFocus:$b(e.onFocus,e=>{let t=!S.current;if(e.target===e.currentTarget&&t&&!v){let t=new CustomEvent(qT,JT);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=x().filter(e=>e.focusable);uE([e.find(e=>e.active),e.find(e=>e.id===g),...e].filter(Boolean).map(e=>e.ref.current),d)}}S.current=!1}),onBlur:$b(e.onBlur,()=>y(!1))})})},`RovingFocusGroupImpl`)),aE=`RovingFocusGroupItem`,oE=B.forwardRef(KT(function(e,n){let{__scopeRovingFocusGroup:r,focusable:i=!0,active:a=!1,tabStopId:o,children:s,...c}=e,l=yx(),u=o||l,d=nE(aE,r),f=d.currentTabStopId===u,p=ZT(r),{onFocusableItemAdd:m,onFocusableItemRemove:h,currentTabStopId:g}=d,_=WT();return mx(()=>{if(!(!_||!i))return m(),()=>h()},[_,i,m,h]),B.useEffect(()=>{if(!(_||!i))return m(),()=>h()},[_,i,m,h]),t(XT.ItemSlot,{scope:r,id:u,focusable:i,active:a,children:t(Zx.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...c,ref:n,onMouseDown:$b(e.onMouseDown,e=>{i?d.onItemFocus(u):e.preventDefault()}),onFocus:$b(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:$b(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){d.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=lE(e,d.orientation,d.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=p().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=d.loop?dE(n,r+1):n.slice(r+1)}setTimeout(()=>uE(n))}}),children:typeof s==`function`?s({isCurrentTabStop:f,hasTabStop:g!=null}):s})})},`RovingFocusGroupItem`)),sE={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function cE(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}KT(cE,`getDirectionAwareKey`);function lE(e,t,n){let r=cE(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return sE[r]}KT(lE,`getFocusIntent`);function uE(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}KT(uE,`focusFirst`);function dE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}KT(dE,`wrapArray`);var fE=rE,pE=oE,mE=Object.defineProperty,hE=(e,t)=>mE(e,`name`,{value:t,configurable:!0}),gE=[`Enter`,` `],_E=[`ArrowDown`,`PageUp`,`Home`],vE=[`ArrowUp`,`PageDown`,`End`],yE=[..._E,...vE];[...gE],[...gE];var bE=`Menu`,[xE,SE,CE]=ET(bE),[wE,TE]=fx(bE,[CE,KC,eE]),EE=KC(),DE=eE(),[OE,kE]=wE(bE),[AE,jE]=wE(bE),ME=hE(e=>{let{__scopeMenu:n,open:r=!1,children:i,dir:a,onOpenChange:o,modal:s=!0}=e,c=EE(n),[l,u]=B.useState(null),d=B.useRef(!1),f=RC(o),p=Un(a);return B.useEffect(()=>{let e=hE(()=>{d.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=hE(()=>d.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),B.useEffect(()=>{if(!r)return;let e=hE(()=>f(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[r,f]),t(aw,{...c,children:t(OE,{scope:n,open:r,onOpenChange:f,content:l,onContentChange:u,children:t(AE,{scope:n,onClose:B.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:p,modal:s,children:i})})})},`Menu`),NE=B.forwardRef(hE(function(e,n){let{__scopeMenu:r,...i}=e,a=EE(r);return t(ow,{...a,...i,ref:n})},`MenuAnchor`)),PE=`MenuPortal`,[FE,IE]=wE(PE,{forceMount:void 0}),LE=hE(e=>{let{__scopeMenu:n,forceMount:r,children:i,container:a}=e,o=kE(PE,n);return t(FE,{scope:n,forceMount:r,children:t(iS,{present:r||o.open,children:t(eS,{asChild:!0,container:a,children:i})})})},`MenuPortal`),RE=`MenuContent`,[zE,BE]=wE(RE),VE=B.forwardRef(hE(function(e,n){let r=IE(RE,e.__scopeMenu),{forceMount:i=r.forceMount,...a}=e,o=kE(RE,e.__scopeMenu),s=jE(RE,e.__scopeMenu);return t(xE.Provider,{scope:e.__scopeMenu,children:t(iS,{present:i||o.open,children:t(xE.Slot,{scope:e.__scopeMenu,children:s.modal?t(HE,{...a,ref:n}):t(UE,{...a,ref:n})})})})},`MenuContent`)),HE=B.forwardRef(hE(function(e,n){let r=kE(RE,e.__scopeMenu),i=B.useRef(null),a=cx(n,i);return B.useEffect(()=>{let e=i.current;if(e)return an(e)},[]),t(GE,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:$b(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})},`MenuRootContentModal`)),UE=B.forwardRef(hE(function(e,n){let r=kE(RE,e.__scopeMenu);return t(GE,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})},`MenuRootContentNonModal`)),WE=Fx(`MenuContent.ScrollLock`),GE=B.forwardRef(hE(function(e,n){let{__scopeMenu:r,loop:i=!1,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:c,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:m,disableOutsideScroll:h,...g}=e,_=kE(RE,r),v=jE(RE,r),y=EE(r),b=DE(r),x=SE(r),[S,C]=B.useState(null),w=B.useRef(null),T=cx(n,w,_.onContentChange),E=B.useRef(0),D=B.useRef(``),O=B.useRef(0),k=B.useRef(null),A=B.useRef(`right`),j=B.useRef(0),M=h?rn:B.Fragment,N=h?{as:WE,allowPinchZoom:!0}:void 0,P=hE(e=>{let t=D.current+e,n=x().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=sD(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;hE((function e(t){D.current=t,window.clearTimeout(E.current),t!==``&&(E.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);B.useEffect(()=>()=>window.clearTimeout(E.current),[]),nn();let F=B.useCallback(e=>A.current===k.current?.side&&lD(e,k.current?.area),[]);return t(zE,{scope:r,searchRef:D,onItemEnter:B.useCallback(e=>{F(e)&&e.preventDefault()},[F]),onItemLeave:B.useCallback(e=>{F(e)||(w.current?.focus(),C(null))},[F]),onTriggerLeave:B.useCallback(e=>{F(e)&&e.preventDefault()},[F]),pointerGraceTimerRef:O,onPointerGraceIntentChange:B.useCallback(e=>{k.current=e},[]),children:t(M,{...N,children:t(en,{asChild:!0,trapped:a,onMountAutoFocus:$b(o,e=>{e.preventDefault(),w.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:s,children:t(Qt,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:m,children:t(fE,{asChild:!0,...b,dir:v.dir,orientation:`vertical`,loop:i,currentTabStopId:S,onCurrentTabStopIdChange:C,onEntryFocus:$b(l,e=>{v.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:t(sw,{role:`menu`,"aria-orientation":`vertical`,"data-state":nD(_.open),"data-radix-menu-content":``,dir:v.dir,...y,...g,ref:T,style:{outline:`none`,...g.style},onKeyDown:$b(g.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&P(e.key));let i=w.current;if(e.target!==i||!yE.includes(e.key))return;e.preventDefault();let a=x().filter(e=>!e.disabled).map(e=>e.ref.current);vE.includes(e.key)&&a.reverse(),aD(a)}),onBlur:$b(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(E.current),D.current=``)}),onPointerMove:$b(e.onPointerMove,uD(e=>{let t=e.target,n=j.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>j.current?`right`:`left`;A.current=t,j.current=e.clientX}}))})})})})})})},`MenuContentImpl`)),KE=`MenuItem`,qE=`menu.itemSelect`,JE=B.forwardRef(hE(function(e,n){let{disabled:r=!1,onSelect:i,...a}=e,o=B.useRef(null),s=jE(KE,e.__scopeMenu),c=BE(KE,e.__scopeMenu),l=cx(n,o),u=B.useRef(!1),d=hE(()=>{let e=o.current;if(!r&&e){let t=new CustomEvent(qE,{bubbles:!0,cancelable:!0});e.addEventListener(qE,e=>i?.(e),{once:!0}),Qx(e,t),t.defaultPrevented?u.current=!1:s.onClose()}},`handleSelect`);return t(YE,{...a,ref:l,disabled:r,onClick:$b(e.onClick,d),onPointerDown:t=>{e.onPointerDown?.(t),u.current=!0},onPointerUp:$b(e.onPointerUp,e=>{u.current||e.currentTarget?.click()}),onKeyDown:$b(e.onKeyDown,e=>{r||e.target!==e.currentTarget||(c.searchRef.current===``||e.key!==` `)&&gE.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),YE=B.forwardRef(hE(function(e,n){let{__scopeMenu:r,disabled:i=!1,textValue:a,...o}=e,s=BE(KE,r),c=DE(r),l=B.useRef(null),u=cx(n,l),[d,f]=B.useState(!1),[p,m]=B.useState(``);return B.useEffect(()=>{let e=l.current;e&&m((e.textContent??``).trim())},[o.children]),t(xE.ItemSlot,{scope:r,disabled:i,textValue:a??p,children:t(pE,{asChild:!0,...c,focusable:!i,children:t(Zx.div,{role:`menuitem`,"data-highlighted":d?``:void 0,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,...o,ref:u,onPointerMove:$b(e.onPointerMove,uD(e=>{i?s.onItemLeave(e):(s.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:$b(e.onPointerLeave,uD(e=>s.onItemLeave(e))),onFocus:$b(e.onFocus,()=>f(!0)),onBlur:$b(e.onBlur,()=>f(!1))})})})},`MenuItemImpl`)),[XE,ZE]=wE(`MenuRadioGroup`,{value:void 0,onValueChange:hE(()=>{},`onValueChange`)}),[QE,$E]=wE(`MenuItemIndicator`,{checked:!1}),[eD,tD]=wE(`MenuSub`);function nD(e){return e?`open`:`closed`}hE(nD,`getOpenState`);function rD(e){return e===`indeterminate`}hE(rD,`isIndeterminate`);function iD(e){return rD(e)?`indeterminate`:e?`checked`:`unchecked`}hE(iD,`getCheckedState`);function aD(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}hE(aD,`focusFirst`);function oD(e,t){return e.map((n,r)=>e[(t+r)%e.length])}hE(oD,`wrapArray`);function sD(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=oD(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}hE(sD,`getNextMatch`);function cD(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}hE(cD,`isPointInPolygon`);function lD(e,t){return t?cD({x:e.clientX,y:e.clientY},t):!1}hE(lD,`isPointerInGraceArea`);function uD(e){return t=>t.pointerType===`mouse`?e(t):void 0}hE(uD,`whenMouse`);var dD=ME,fD=NE,pD=LE,mD=VE,hD=JE,gD=Object.defineProperty,_D=(e,t)=>gD(e,`name`,{value:t,configurable:!0}),vD=`DropdownMenu`,[yD,bD]=fx(vD,[TE]),xD=TE(),[SD,CD]=yD(vD),wD=_D(e=>{let{__scopeDropdownMenu:n,children:r,dir:i,open:a,defaultOpen:o,onOpenChange:s,modal:c=!0}=e,l=xD(n),u=B.useRef(null),[d,f]=Ox({prop:a,defaultProp:o??!1,onChange:s,caller:vD});return t(SD,{scope:n,triggerId:yx(),triggerRef:u,contentId:yx(),open:d,onOpenChange:f,onOpenToggle:B.useCallback(()=>f(e=>!e),[f]),modal:c,children:t(dD,{...l,open:d,onOpenChange:f,dir:i,modal:c,children:r})})},`DropdownMenu`),TD=`DropdownMenuTrigger`,ED=B.forwardRef(_D(function(e,n){let{__scopeDropdownMenu:r,disabled:i=!1,...a}=e,o=CD(TD,r),s=xD(r),c=cx(n,o.triggerRef);return t(fD,{asChild:!0,...s,children:t(Zx.button,{type:`button`,id:o.triggerId,"aria-haspopup":`menu`,"aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?`open`:`closed`,"data-disabled":i?``:void 0,disabled:i,...a,ref:c,onPointerDown:$b(e.onPointerDown,e=>{!i&&e.button===0&&e.ctrlKey===!1&&(o.onOpenToggle(),o.open||e.preventDefault())}),onKeyDown:$b(e.onKeyDown,e=>{i||([`Enter`,` `].includes(e.key)&&o.onOpenToggle(),e.key===`ArrowDown`&&o.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),DD=_D(e=>{let{__scopeDropdownMenu:n,...r}=e,i=xD(n);return t(pD,{...i,...r})},`DropdownMenuPortal`),OD=`DropdownMenuContent`,kD=B.forwardRef(_D(function(e,n){let{__scopeDropdownMenu:r,...i}=e,a=CD(OD,r),o=xD(r),s=B.useRef(!1);return t(mD,{id:a.contentId,"aria-labelledby":a.triggerId,...o,...i,ref:n,onCloseAutoFocus:$b(e.onCloseAutoFocus,e=>{s.current||a.triggerRef.current?.focus(),s.current=!1,e.preventDefault()}),onInteractOutside:$b(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!a.modal||r)&&(s.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),AD=B.forwardRef(_D(function(e,n){let{__scopeDropdownMenu:r,...i}=e,a=xD(r);return t(hD,{...a,...i,ref:n})},`DropdownMenuItem`)),jD=wD,MD=ED,ND=DD,PD=kD,FD=AD;const ID=B.createContext(!1);function LD({...e}){return t(jD,{"data-slot":`dropdown-menu`,...e})}function RD({...e}){return t(MD,{"data-slot":`dropdown-menu-trigger`,...e})}function zD({className:e,align:n=`start`,sideOffset:r=4,...i}){return t(ND,{children:t(PD,{"data-slot":`dropdown-menu-content`,sideOffset:r,align:n,className:RS(`data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 bg-popover text-popover-foreground min-w-32 rounded-lg p-1 shadow-md ring-1 duration-100 z-50 max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto data-[state=closed]:overflow-hidden`,e),...i})})}function BD({className:e,inset:n,variant:r=`default`,...i}){return t(FD,{"data-slot":`dropdown-menu-item`,"data-inset":n,"data-variant":r,className:RS(`hover:bg-muted focus:bg-muted data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:text-destructive gap-2 rounded-md px-1.5 py-1 text-sm data-inset:ps-7 [&_svg:not([class*='size-'])]:size-4 group/dropdown-menu-item relative flex cursor-default items-center outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0`,e),...i})}const VD={left:`start`,center:`center`,right:`end`};function HD({trigger:e,children:r,align:i=`right`,hover:a}){let[o,s]=B.useState(!1),c=B.useRef(null);return a?n(`div`,{className:`relative inline-flex`,onMouseEnter:()=>{c.current&&clearTimeout(c.current),s(!0)},onMouseLeave:()=>{c.current=setTimeout(()=>s(!1),80)},children:[e,o&&t(`div`,{className:RS(`absolute top-full pt-1 z-50`,i===`right`?`end-0`:i===`center`?`left-1/2 -translate-x-1/2`:`start-0`),children:t(`div`,{className:`min-w-32 rounded-lg p-1 shadow-md ring-1 ring-foreground/10 bg-popover text-popover-foreground`,children:t(ID.Provider,{value:!0,children:r})})})]}):n(LD,{children:[t(RD,{asChild:!0,children:t(`span`,{className:`-m-1.5 flex items-center p-1.5`,children:e})}),t(zD,{align:VD[i],className:`w-max`,children:r})]})}function UD({children:e,href:n,onClick:r,isDisabled:i=!1,variant:a=`default`,className:o}){let s=B.useContext(ID),c=RS(`w-full gap-2 rounded-md px-1.5 py-1 text-sm text-nowrap [&_svg:not([class*='size-'])]:size-4 flex cursor-default items-center select-none [&_svg]:pointer-events-none [&_svg]:shrink-0`,a===`destructive`?`text-destructive`:``,i?`pointer-events-none opacity-50`:`hover:bg-muted focus:bg-muted`,o);return s?n?t(`a`,{href:n,className:c,children:e}):t(`button`,{type:`button`,className:c,disabled:i,onClick:e=>{e.stopPropagation(),r?.(e)},children:e}):t(BD,{className:RS(`data-[disabled]:pointer-events-none data-[disabled]:opacity-50 text-nowrap`,o),disabled:i,variant:a,onClick:e=>{e.stopPropagation(),r?.(e)},asChild:!!n,children:n?t(`a`,{href:n,children:e}):e})}Wn.extend(Kn),Wn.extend(Gn);var WD=Wn,GD=Object.defineProperty,KD=(e,t)=>GD(e,`name`,{value:t,configurable:!0}),qD=`Switch`,[JD,YD]=fx(qD),[XD,ZD]=JD(qD);function QD(e){let{__scopeSwitch:n,checked:r,children:i,defaultChecked:a,disabled:o,form:s,name:c,onCheckedChange:l,required:u,value:d=`on`,internal_do_not_use_render:f}=e,[p,m]=Ox({prop:r,defaultProp:a??!1,onChange:l,caller:qD}),[h,g]=B.useState(null),[_,v]=B.useState(null),y=B.useRef(!1),[b,x]=B.useReducer(e=>e+1,0),S={checked:p,setChecked:m,disabled:o,control:h,setControl:g,name:c,form:s,value:d,hasConsumerStoppedPropagationRef:y,userInteractionCount:b,onUserInteraction:x,required:u,defaultChecked:a,isFormControl:!h||!!s||!!h.closest(`form`),bubbleInput:_,setBubbleInput:v};return t(XD,{scope:n,...S,children:oO(f)?f(S):i})}KD(QD,`SwitchProvider`);var $D=`SwitchTrigger`,eO=B.forwardRef(KD(function({__scopeSwitch:e,onClick:n,...r},i){let{control:a,form:o,value:s,disabled:c,checked:l,required:u,setControl:d,setChecked:f,hasConsumerStoppedPropagationRef:p,onUserInteraction:m,isFormControl:h,bubbleInput:g}=ZD($D,e),_=cx(i,d),v=B.useRef(l);return B.useEffect(()=>{let e=o?a?.ownerDocument.getElementById(o):a?.form;if(e instanceof HTMLFormElement){let t=KD(()=>f(v.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[a,o,f]),t(Zx.button,{type:`button`,role:`switch`,"aria-checked":l,"aria-required":u,"data-state":sO(l),"data-disabled":c?``:void 0,disabled:c,value:s,...r,ref:_,onClick:$b(n,e=>{m(),f(e=>!e),g&&h&&(p.current=e.isPropagationStopped(),p.current||e.stopPropagation())})})},`SwitchTrigger`)),tO=B.forwardRef(KD(function(r,i){let{__scopeSwitch:a,name:o,checked:s,defaultChecked:c,required:l,disabled:u,value:d,onCheckedChange:f,form:p,...m}=r;return t(QD,{__scopeSwitch:a,checked:s,defaultChecked:c,disabled:u,required:l,onCheckedChange:f,name:o,form:p,value:d,internal_do_not_use_render:({isFormControl:r})=>n(e,{children:[t(eO,{...m,ref:i,__scopeSwitch:a}),r&&t(aO,{__scopeSwitch:a})]})})},`Switch`)),nO=`SwitchThumb`,rO=B.forwardRef(KD(function(e,n){let{__scopeSwitch:r,...i}=e,a=ZD(nO,r);return t(Zx.span,{"data-state":sO(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:n})},`SwitchThumb`)),iO=`SwitchBubbleInput`,aO=B.forwardRef(KD(function({__scopeSwitch:e,onClick:n,...r},i){let{control:a,hasConsumerStoppedPropagationRef:o,userInteractionCount:s,checked:c,defaultChecked:l,required:u,disabled:d,name:f,value:p,form:m,bubbleInput:h,setBubbleInput:g}=ZD(iO,e),_=cx(i,g),v=VC(a),y=B.useRef(!1),b=B.useRef(c),x=B.useRef(s);B.useEffect(()=>{let e=h;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=s!==x.current;x.current=s;let i=b.current!==c;b.current=c;let a=!(r&&o.current);if(i&&n){y.current=!r;let t=new Event(`click`,{bubbles:a});n.call(e,c),e.dispatchEvent(t),y.current=!1}},[h,c,o,s]);let S=B.useRef(c);return t(Zx.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:l??S.current,required:u,disabled:d,name:f,value:p,form:m,...r,tabIndex:-1,ref:_,onClick:$b(n,e=>{y.current&&e.stopPropagation()}),style:{...r.style,...v,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`SwitchBubbleInput`));function oO(e){return typeof e==`function`}KD(oO,`isFunction`);function sO(e){return e?`checked`:`unchecked`}KD(sO,`getState`);const cO={sm:[`h-5 w-8`,`size-3`,`translate-x-4 rtl:-translate-x-4`],md:[`h-6 w-11`,`size-4`,`translate-x-6 rtl:-translate-x-6`],lg:[`h-8 w-16`,`size-6`,`translate-x-9 rtl:-translate-x-9`]};function lO({className:e,size:r=`md`,value:i,onChange:a,children:o,disabled:s,...c}){let[l,u,d]=cO[r],f=t(tO,{"data-slot":`switch`,checked:i,onCheckedChange:a,disabled:s,...c,className:RS(`data-[state=checked]:bg-primary data-[state=unchecked]:bg-muted focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 shrink-0 rounded-full border focus-visible:ring-3 aria-invalid:ring-3 peer group/switch relative inline-flex items-center transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`,l,!o&&e),children:t(rO,{"data-slot":`switch-thumb`,className:RS(`bg-white rounded-full pointer-events-none block ring-0 transition-transform`,u,i?d:`translate-x-1 rtl:-translate-x-1`)})});return o?n(`div`,{className:RS(`flex items-center`,e),children:[f,t(`span`,{className:`px-2`,children:o})]}):f}function uO(e){switch(e){case`xs`:return`size-2`;case`sm`:return`size-3`;case`md`:return`size-4`;case`lg`:return`size-5`;case`xl`:return`size-7`;case`2xl`:return`size-10`;default:throw Error(`Unexpected size: ${e}`)}}function dO({size:e,className:r}){let i=uO(e||`md`);return n(`svg`,{className:it(`animate-[spin_0.8s_linear_infinite] text-info`,i,r),xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,role:`img`,"aria-label":`Loading`,children:[t(`title`,{children:`Loading`}),t(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),t(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`})]})}function fO(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`oauth-complete`&&`success`in e&&typeof e.success==`boolean`}function pO({onComplete:e,onError:t}){let n=W(null),r=W(e),i=W(t);return H(()=>{r.current=e,i.current=t},[e,t]),H(()=>()=>{n.current&&=(n.current(),null)},[]),{openOAuthPopup:e=>{n.current&&=(n.current(),null);let t=window.screenX+(window.outerWidth-600)/2,a=window.screenY+(window.outerHeight-700)/2,o=window.open(e,`oauth_popup`,`width=600,height=700,left=${t},top=${a},popup=yes`),s=!1,c=null,l=new BroadcastChannel(`oauth-callback`);l.addEventListener(`message`,e=>{fO(e.data)&&(s=!0,l.close(),c&&clearInterval(c),r.current(),!e.data.success&&e.data.error&&i.current?.(e.data.error),n.current=null)}),o&&(c=setInterval(()=>{o.closed&&(c&&clearInterval(c),l.close(),s||r.current(),n.current=null)},1e3)),n.current=()=>{l.close(),c&&clearInterval(c)}}}}Q();function mO({appId:r,collectionId:i,collectionName:a,authenticated:o,onAuthChange:s,onError:c,variant:l=`default`,showLabel:u=!1,showDisconnect:d=!1,readOnly:f=!1}){let{client:p}=q(),{t:m}=K(),[h,g]=G(null),[_,v]=G(o===void 0&&!f),[y,b]=G(!1),[x,S]=G(!1),C=o??h?.authenticated??!1,w=a??i,T=`h-6 w-32 justify-center px-2 text-xs`,E=V(async()=>{if(o!==void 0){v(!1);return}if(f){v(!1);return}try{v(!0);let e=await p.remoteMcpConnections.getCollectionStatus(r,i);g(e)}catch(e){console.error(`[RemoteMcpConnectionButton] Failed to load OAuth status:`,e)}finally{v(!1)}},[p,r,i,o,f]);H(()=>{E()},[E]);let{openOAuthPopup:D}=pO({onComplete:()=>{b(!1),E(),s?.()},onError:e=>{console.error(`OAuth failed:`,e),b(!1)}}),O=async()=>{try{b(!0),c?.(null);let e=await p.remoteMcpConnections.authorize(r,i);e.connected?(b(!1),await E(),s?.()):e.authorization_url?D(e.authorization_url):(c?.(`${w}: Authorization URL not provided by server`),b(!1))}catch(e){console.error(`Failed to authorize:`,e);let t=(e instanceof Error?e.original_message??e.message:`Failed to connect`).replace(/^[A-Za-z\s]+:\s/,``);c?.(`${w}: ${t}`),b(!1)}},k=async()=>{try{S(!0),await p.remoteMcpConnections.disconnect(r,i),await E(),s?.()}catch(e){console.error(`Failed to disconnect:`,e)}finally{S(!1)}};return _?l===`compact`?t(oT,{variant:`outline`,size:`sm`,disabled:!0,className:T,title:m(`mcpConnections.checkingStatus`),children:t(dO,{className:`size-3`})}):t(`div`,{className:`flex items-center gap-2 text-sm`,children:t(dO,{className:`size-4`})}):l===`full`?C?n(`div`,{className:`flex items-center gap-2`,children:[u&&n(`span`,{className:`font-medium text-sm text-foreground`,children:[w,`:`]}),n(`div`,{className:`flex items-center gap-1 text-success text-sm`,children:[t(Ih,{className:`size-4`}),t(`span`,{children:m(`mcpOAuth.connected`)})]}),d&&t(oT,{variant:`ghost`,size:`sm`,onClick:k,disabled:x,children:x?t(dO,{className:`size-4`}):m(`mcpOAuth.disconnect`)})]}):n(`div`,{className:`flex items-center gap-2 text-sm`,children:[u&&n(`span`,{className:`font-medium text-foreground`,children:[w,`:`]}),t(oT,{variant:`ghost`,size:`sm`,onClick:O,disabled:y,children:y?n(e,{children:[t(dO,{className:`size-4`}),t(`span`,{children:m(`mcpOAuth.authenticating`)})]}):n(e,{children:[t(zy,{className:`size-4`}),t(`span`,{children:m(`mcpOAuth.authenticate`)})]})})]}):C?l===`compact`?n(`div`,{className:`flex items-center gap-2`,children:[u&&n(`span`,{className:`font-medium text-xs text-foreground`,children:[w,`:`]}),!f&&d&&t(oT,{variant:`outline`,size:`sm`,onClick:k,disabled:x,className:T,children:x?t(dO,{className:`size-3`}):n(e,{children:[t(xb,{className:`size-3`}),t(`span`,{children:m(`mcpOAuth.disconnect`)})]})})]}):n(`div`,{className:`flex items-center gap-1 text-success`,children:[t(Ih,{className:`size-4`}),t(`span`,{className:`text-sm`,children:m(`mcpOAuth.connected`)})]}):l===`compact`?f?n(`div`,{className:`flex items-center gap-2`,children:[u&&n(`span`,{className:`font-medium text-xs text-foreground`,children:[a,`:`]}),t(`div`,{className:`flex items-center gap-1 text-muted`,children:t(`span`,{className:`text-xs`,children:m(`mcpOAuth.notConnected`)})})]}):n(`div`,{className:`flex items-center gap-2`,children:[u&&n(`span`,{className:`font-medium text-xs text-foreground`,children:[w,`:`]}),t(oT,{variant:`outline`,size:`sm`,onClick:O,disabled:y,className:T,children:y?n(e,{children:[t(dO,{className:`size-3`}),t(`span`,{children:m(`mcpOAuth.connecting`)})]}):n(e,{children:[t(G_,{className:`size-3`}),t(`span`,{children:m(`mcpOAuth.connect`)})]})})]}):t(oT,{variant:`outline`,size:`sm`,onClick:O,disabled:f||y,children:y?n(e,{children:[t(dO,{className:`size-4`}),t(`span`,{children:m(`mcpOAuth.connecting`)})]}):n(e,{children:[t(G_,{className:`size-4 me-1`}),t(`span`,{children:m(`mcpOAuth.connect`)})]})})}function hO(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}const gO=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,_O=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,vO={};function yO(e,t){return((t||vO).jsx?_O:gO).test(e)}const bO=/[ \t\n\f\r]/g;function xO(e){return typeof e==`object`?e.type===`text`&&SO(e.value):SO(e)}function SO(e){return e.replace(bO,``)===``}var CO=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};CO.prototype.normal={},CO.prototype.property={},CO.prototype.space=void 0;function wO(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new CO(n,r,t)}function TO(e){return e.toLowerCase()}var EO=class{constructor(e,t){this.attribute=t,this.property=e}};EO.prototype.attribute=``,EO.prototype.booleanish=!1,EO.prototype.boolean=!1,EO.prototype.commaOrSpaceSeparated=!1,EO.prototype.commaSeparated=!1,EO.prototype.defined=!1,EO.prototype.mustUseProperty=!1,EO.prototype.number=!1,EO.prototype.overloadedBoolean=!1,EO.prototype.property=``,EO.prototype.spaceSeparated=!1,EO.prototype.space=void 0;var DO=mr({boolean:()=>kO,booleanish:()=>AO,commaOrSpaceSeparated:()=>PO,commaSeparated:()=>NO,number:()=>$,overloadedBoolean:()=>jO,spaceSeparated:()=>MO});let OO=0;const kO=FO(),AO=FO(),jO=FO(),$=FO(),MO=FO(),NO=FO(),PO=FO();function FO(){return 2**++OO}const IO=Object.keys(DO);var LO=class extends EO{constructor(e,t,n,r){let i=-1;if(super(e,t),RO(this,`space`,r),typeof n==`number`)for(;++i<IO.length;){let e=IO[i];RO(this,IO[i],(n&DO[e])===DO[e])}}};LO.prototype.defined=!0;function RO(e,t,n){n&&(e[t]=n)}function zO(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new LO(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[TO(r)]=r,n[TO(a.attribute)]=r}return new CO(t,n,e.space)}const BO=zO({properties:{ariaActiveDescendant:null,ariaAtomic:AO,ariaAutoComplete:null,ariaBusy:AO,ariaChecked:AO,ariaColCount:$,ariaColIndex:$,ariaColSpan:$,ariaControls:MO,ariaCurrent:null,ariaDescribedBy:MO,ariaDetails:null,ariaDisabled:AO,ariaDropEffect:MO,ariaErrorMessage:null,ariaExpanded:AO,ariaFlowTo:MO,ariaGrabbed:AO,ariaHasPopup:null,ariaHidden:AO,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:MO,ariaLevel:$,ariaLive:null,ariaModal:AO,ariaMultiLine:AO,ariaMultiSelectable:AO,ariaOrientation:null,ariaOwns:MO,ariaPlaceholder:null,ariaPosInSet:$,ariaPressed:AO,ariaReadOnly:AO,ariaRelevant:null,ariaRequired:AO,ariaRoleDescription:MO,ariaRowCount:$,ariaRowIndex:$,ariaRowSpan:$,ariaSelected:AO,ariaSetSize:$,ariaSort:null,ariaValueMax:$,ariaValueMin:$,ariaValueNow:$,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function VO(e,t){return t in e?e[t]:t}function HO(e,t){return VO(e,t.toLowerCase())}const UO=zO({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:NO,acceptCharset:MO,accessKey:MO,action:null,allow:null,allowFullScreen:kO,allowPaymentRequest:kO,allowUserMedia:kO,alt:null,as:null,async:kO,autoCapitalize:null,autoComplete:MO,autoFocus:kO,autoPlay:kO,blocking:MO,capture:null,charSet:null,checked:kO,cite:null,className:MO,cols:$,colSpan:null,content:null,contentEditable:AO,controls:kO,controlsList:MO,coords:$|NO,crossOrigin:null,data:null,dateTime:null,decoding:null,default:kO,defer:kO,dir:null,dirName:null,disabled:kO,download:jO,draggable:AO,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:kO,formTarget:null,headers:MO,height:$,hidden:jO,high:$,href:null,hrefLang:null,htmlFor:MO,httpEquiv:MO,id:null,imageSizes:null,imageSrcSet:null,inert:kO,inputMode:null,integrity:null,is:null,isMap:kO,itemId:null,itemProp:MO,itemRef:MO,itemScope:kO,itemType:MO,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:kO,low:$,manifest:null,max:null,maxLength:$,media:null,method:null,min:null,minLength:$,multiple:kO,muted:kO,name:null,nonce:null,noModule:kO,noValidate:kO,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:kO,optimum:$,pattern:null,ping:MO,placeholder:null,playsInline:kO,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:kO,referrerPolicy:null,rel:MO,required:kO,reversed:kO,rows:$,rowSpan:$,sandbox:MO,scope:null,scoped:kO,seamless:kO,selected:kO,shadowRootClonable:kO,shadowRootDelegatesFocus:kO,shadowRootMode:null,shape:null,size:$,sizes:null,slot:null,span:$,spellCheck:AO,src:null,srcDoc:null,srcLang:null,srcSet:null,start:$,step:null,style:null,tabIndex:$,target:null,title:null,translate:null,type:null,typeMustMatch:kO,useMap:null,value:AO,width:$,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:MO,axis:null,background:null,bgColor:null,border:$,borderColor:null,bottomMargin:$,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:kO,declare:kO,event:null,face:null,frame:null,frameBorder:null,hSpace:$,leftMargin:$,link:null,longDesc:null,lowSrc:null,marginHeight:$,marginWidth:$,noResize:kO,noHref:kO,noShade:kO,noWrap:kO,object:null,profile:null,prompt:null,rev:null,rightMargin:$,rules:null,scheme:null,scrolling:AO,standby:null,summary:null,text:null,topMargin:$,valueType:null,version:null,vAlign:null,vLink:null,vSpace:$,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:kO,disableRemotePlayback:kO,prefix:null,property:null,results:$,security:null,unselectable:null},space:`html`,transform:HO}),WO=zO({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:PO,accentHeight:$,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:$,amplitude:$,arabicForm:null,ascent:$,attributeName:null,attributeType:null,azimuth:$,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:$,by:null,calcMode:null,capHeight:$,className:MO,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:$,diffuseConstant:$,direction:null,display:null,dur:null,divisor:$,dominantBaseline:null,download:kO,dx:null,dy:null,edgeMode:null,editable:null,elevation:$,enableBackground:null,end:null,event:null,exponent:$,externalResourcesRequired:null,fill:null,fillOpacity:$,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:NO,g2:NO,glyphName:NO,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:$,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:$,horizOriginX:$,horizOriginY:$,id:null,ideographic:$,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:$,k:$,k1:$,k2:$,k3:$,k4:$,kernelMatrix:PO,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:$,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:$,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:$,overlineThickness:$,paintOrder:null,panose1:null,path:null,pathLength:$,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:MO,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:$,pointsAtY:$,pointsAtZ:$,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:PO,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:PO,rev:PO,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:PO,requiredFeatures:PO,requiredFonts:PO,requiredFormats:PO,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:$,specularExponent:$,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:$,strikethroughThickness:$,string:null,stroke:null,strokeDashArray:PO,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:$,strokeOpacity:$,strokeWidth:null,style:null,surfaceScale:$,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:PO,tabIndex:$,tableValues:null,target:null,targetX:$,targetY:$,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:PO,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:$,underlineThickness:$,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:$,values:null,vAlphabetic:$,vMathematical:$,vectorEffect:null,vHanging:$,vIdeographic:$,version:null,vertAdvY:$,vertOriginX:$,vertOriginY:$,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:$,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:VO}),GO=zO({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),KO=zO({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:HO}),qO=zO({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),JO={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},YO=/[A-Z]/g,XO=/-[a-z]/g,ZO=/^data[-\w.:]+$/i;function QO(e,t){let n=TO(t),r=t,i=EO;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&ZO.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(XO,ek);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!XO.test(e)){let n=e.replace(YO,$O);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=LO}return new i(r,t)}function $O(e){return`-`+e.toLowerCase()}function ek(e){return e.charAt(1).toUpperCase()}const tk=wO([BO,UO,GO,KO,qO],`html`),nk=wO([BO,WO,GO,KO,qO],`svg`);function rk(e){return e.join(` `).trim()}function ik(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var n=1,r=1;function i(e){var t=e.match(sk);t&&(n+=t.length);var i=e.lastIndexOf(mk);r=~i?e.length-i:r+e.length}function a(){var e={line:n,column:r};return function(t){return t.position=new o(e),l(),t}}function o(e){this.start=e,this.end={line:n,column:r},this.source=t.source}o.prototype.content=e;function s(i){var a=Error(t.source+`:`+n+`:`+r+`: `+i);if(a.reason=i,a.filename=t.source,a.line=n,a.column=r,a.source=e,!t.silent)throw a}function c(t){var n=t.exec(e);if(n){var r=n[0];return i(r),e=e.slice(r.length),n}}function l(){c(ck)}function u(e){var t;for(e||=[];t=d();)t!==!1&&e.push(t);return e}function d(){var t=a();if(hk==e.charAt(0)&&gk==e.charAt(1)){for(var n=2;_k!=e.charAt(n)&&(gk!=e.charAt(n)||hk!=e.charAt(n+1));)++n;if(n+=2,_k===e.charAt(n-1))return s(`End of comment missing`);var o=e.slice(2,n-2);return r+=2,i(o),e=e.slice(n),r+=2,t({type:vk,comment:o})}}function f(){var e=a(),t=c(lk);if(t){if(d(),!c(uk))return s(`property missing ':'`);var n=c(dk),r=e({type:yk,property:ak(t[0].replace(ok,_k)),value:n?ak(n[0].replace(ok,_k)):_k});return c(fk),r}}function p(){var e=[];u(e);for(var t;t=f();)t!==!1&&(e.push(t),u(e));return e}return l(),p()}function ak(e){return e?e.replace(pk,_k):_k}var ok,sk,ck,lk,uk,dk,fk,pk,mk,hk,gk,_k,vk,yk,bk=Y((()=>{ok=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,sk=/\n/g,ck=/^\s*/,lk=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,uk=/^:\s*/,dk=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,fk=/^[;\s]*/,pk=/^\s+|\s+$/g,mk=`
899
899
  `,hk=`/`,gk=`*`,_k=``,vk=`comment`,yk=`declaration`})),xk=mr({default:()=>Sk});function Sk(e,t){let n=null;if(!e||typeof e!=`string`)return n;let r=ik(e),i=typeof t==`function`;return r.forEach(e=>{if(e.type!==`declaration`)return;let{property:r,value:a}=e;i?t(r,a,e):a&&(n||={},n[r]=a)}),n}var Ck=Y((()=>{bk()})),wk=pr((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),Tk=pr(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})((Ck(),_r(xk))),r=wk();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i}));const Ek=Ok(`end`),Dk=Ok(`start`);function Ok(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function kk(e){let t=Dk(e),n=Ek(e);if(t&&n)return{start:t,end:n}}function Ak(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?Mk(e.position):`start`in e||`end`in e?Mk(e):`line`in e||`column`in e?jk(e):``}function jk(e){return Nk(e&&e.line)+`:`+Nk(e&&e.column)}function Mk(e){return jk(e&&e.start)+`-`+jk(e&&e.end)}function Nk(e){return e&&typeof e==`number`?e:1}var Pk=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=Ak(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};Pk.prototype.file=``,Pk.prototype.name=``,Pk.prototype.reason=``,Pk.prototype.message=``,Pk.prototype.stack=``,Pk.prototype.column=void 0,Pk.prototype.line=void 0,Pk.prototype.ancestors=void 0,Pk.prototype.cause=void 0,Pk.prototype.fatal=void 0,Pk.prototype.place=void 0,Pk.prototype.ruleId=void 0,Pk.prototype.source=void 0;var Fk=gr(Tk(),1);const Ik={}.hasOwnProperty,Lk=new Map,Rk=/[A-Z]/g,zk=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),Bk=new Set([`td`,`th`]);function Vk(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=Qk(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=Zk(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?nk:tk,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=Hk(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function Hk(e,t,n){if(t.type===`element`)return Uk(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return Wk(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return Kk(e,t,n);if(t.type===`mdxjsEsm`)return Gk(e,t);if(t.type===`root`)return qk(e,t,n);if(t.type===`text`)return Jk(e,t)}function Uk(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=nk,e.schema=i),e.ancestors.push(t);let a=iA(e,t.tagName,!1),o=$k(e,t),s=tA(e,t);return zk.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!xO(e)})),Yk(e,o,a,t),Xk(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Wk(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}aA(e,t.position)}function Gk(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);aA(e,t.position)}function Kk(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=nk,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:iA(e,t.name,!0),o=eA(e,t),s=tA(e,t);return Yk(e,o,a,t),Xk(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function qk(e,t,n){let r={};return Xk(r,tA(e,t)),e.create(t,e.Fragment,r,n)}function Jk(e,t){return t.value}function Yk(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Xk(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function Zk(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function Qk(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=Dk(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function $k(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&Ik.call(t.properties,i)){let a=nA(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&Bk.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function eA(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else aA(e,t.position)}else{let i=r.name,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else aA(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function tA(e,t){let n=[],r=-1,i=e.passKeys?new Map:Lk;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=Hk(e,a,o);s!==void 0&&n.push(s)}return n}function nA(e,t,n){let r=QO(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?hO(n):rk(n)),r.property===`style`){let t=typeof n==`object`?n:rA(e,String(n));return e.stylePropertyNameCase===`css`&&(t=oA(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?JO[r.property]||r.property:r.attribute,n]}}function rA(e,t){try{return(0,Fk.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new Pk("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=`https://github.com/syntax-tree/hast-util-to-jsx-runtime#cannot-parse-style-attribute`,r}}function iA(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=yO(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=yO(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return Ik.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);aA(e)}function aA(e,t){let n=new Pk("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=`https://github.com/syntax-tree/hast-util-to-jsx-runtime#cannot-handle-mdx-estrees-without-createevaluater`,n}function oA(e){let t={},n;for(n in e)Ik.call(e,n)&&(t[sA(n)]=e[n]);return t}function sA(e){let t=e.replace(Rk,cA);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function cA(e){return`-`+e.toLowerCase()}const lA={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},uA={};function dA(e,t){let n=t||uA;return fA(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function fA(e,t,n){if(mA(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return pA(e.children,t,n)}return Array.isArray(e)?pA(e,t,n):``}function pA(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=fA(e[i],t,n);return r.join(``)}function mA(e){return!!(e&&typeof e==`object`)}const hA=document.createElement(`i`);function gA(e){let t=`&`+e+`;`;hA.innerHTML=t;let n=hA.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function _A(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function vA(e,t){return e.length>0?(_A(e,e.length,0,t),e):t}const yA={}.hasOwnProperty;function bA(e){let t={},n=-1;for(;++n<e.length;)xA(t,e[n]);return t}function xA(e,t){let n;for(n in t){let r=(yA.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){yA.call(r,a)||(r[a]=[]);let e=i[a];SA(r[a],Array.isArray(e)?e:e?[e]:[])}}}function SA(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);_A(e,0,0,r)}function CA(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function wA(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}const TA=LA(/[A-Za-z]/),EA=LA(/[\dA-Za-z]/),DA=LA(/[#-'*+\--9=?A-Z^-~]/);function OA(e){return e!==null&&(e<32||e===127)}const kA=LA(/\d/),AA=LA(/[\dA-Fa-f]/),jA=LA(/[!-/:-@[-`{-~]/);function MA(e){return e!==null&&e<-2}function NA(e){return e!==null&&(e<0||e===32)}function PA(e){return e===-2||e===-1||e===32}const FA=LA(/\p{P}|\p{S}/u),IA=LA(/\s/);function LA(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function RA(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&EA(e.charCodeAt(n+1))&&EA(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function zA(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return PA(r)?(e.enter(n),s(r)):t(r)}function s(r){return PA(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}const BA={tokenize:VA};function VA(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),zA(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return MA(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}const HA={tokenize:WA},UA={tokenize:GA};function WA(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return _A(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(UA,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(UA,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return MA(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;_A(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function GA(e,t,n){return zA(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function KA(e){if(e===null||NA(e)||IA(e))return 1;if(FA(e))return 2}function qA(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}const JA={name:`attention`,resolveAll:YA,tokenize:XA};function YA(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};ZA(d,-c),ZA(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=vA(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=vA(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=vA(l,qA(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=vA(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=vA(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,_A(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function XA(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=KA(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=KA(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function ZA(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const QA={name:`autolink`,tokenize:$A};function $A(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return TA(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||EA(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||EA(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||OA(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):DA(t)?(e.consume(t),l):n(t)}function u(e){return EA(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||EA(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}const ej={partial:!0,tokenize:tj};function tj(e,t,n){return r;function r(t){return PA(t)?zA(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||MA(e)?t(e):n(e)}}const nj={continuation:{tokenize:ij},exit:aj,name:`blockQuote`,tokenize:rj};function rj(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return PA(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function ij(e,t,n){let r=this;return i;function i(t){return PA(t)?zA(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(nj,t,n)(r)}}function aj(e){e.exit(`blockQuote`)}const oj={name:`characterEscape`,tokenize:sj};function sj(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return jA(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}const cj={name:`characterReference`,tokenize:lj};function lj(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=EA,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=AA,u):(e.enter(`characterReferenceValue`),a=7,o=kA,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===EA&&!gA(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}const uj={partial:!0,tokenize:pj},dj={concrete:!0,name:`codeFenced`,tokenize:fj};function fj(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),PA(t)?zA(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||MA(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(uj,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||MA(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):PA(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),zA(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||MA(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||MA(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&PA(t)?zA(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||MA(t)?e.check(uj,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||MA(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),PA(t)?zA(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),PA(t)?zA(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||MA(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function pj(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}const mj={name:`codeIndented`,tokenize:gj},hj={partial:!0,tokenize:_j};function gj(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),zA(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):MA(t)?e.attempt(hj,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||MA(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function _j(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):MA(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):zA(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):MA(e)?i(e):n(e)}}const vj={name:`codeText`,previous:bj,resolve:yj,tokenize:xj};function yj(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function bj(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function xj(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):MA(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||MA(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var Sj=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&Cj(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),Cj(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Cj(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);Cj(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);Cj(this.left,t.reverse())}}}};function Cj(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function wj(e){let t={},n=-1,r,i,a,o,s,c,l,u=new Sj(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,Tj(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return _A(e,0,1/0,u.slice(0)),!l}function Tj(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}const Ej={resolve:Oj,tokenize:kj},Dj={partial:!0,tokenize:Aj};function Oj(e){return wj(e),e}function kj(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):MA(t)?e.check(Dj,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function Aj(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),zA(e,a,`linePrefix`)}function a(i){if(i===null||MA(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function jj(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||OA(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||MA(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||NA(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||OA(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function Mj(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):MA(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||MA(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!PA(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function Nj(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):MA(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),zA(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||MA(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function Pj(e,t){let n;return r;function r(i){return MA(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):PA(i)?zA(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}const Fj={name:`definition`,tokenize:Lj},Ij={partial:!0,tokenize:Rj};function Lj(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return Mj.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=wA(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return NA(t)?Pj(e,l)(t):l(t)}function l(t){return jj(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(Ij,d,d)(t)}function d(t){return PA(t)?zA(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||MA(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function Rj(e,t,n){return r;function r(t){return NA(t)?Pj(e,i)(t):n(t)}function i(t){return Nj(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return PA(t)?zA(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||MA(e)?t(e):n(e)}}const zj={name:`hardBreakEscape`,tokenize:Bj};function Bj(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return MA(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}const Vj={name:`headingAtx`,resolve:Hj,tokenize:Uj};function Hj(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},_A(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function Uj(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||NA(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||MA(n)?(e.exit(`atxHeading`),t(n)):PA(n)?zA(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||NA(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}const Wj=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),Gj=[`pre`,`script`,`style`,`textarea`],Kj={concrete:!0,name:`htmlFlow`,resolveTo:Yj,tokenize:Xj},qj={partial:!0,tokenize:Qj},Jj={partial:!0,tokenize:Zj};function Yj(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Xj(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:I):TA(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):TA(a)?(e.consume(a),i=4,r.interrupt?t:I):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:I):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return TA(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||NA(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&Gj.includes(l)?(i=1,r.interrupt?t(s):O(s)):Wj.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||EA(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return PA(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||TA(t)?(e.consume(t),b):PA(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||EA(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):PA(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):PA(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||MA(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||NA(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||PA(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||MA(t)?O(t):PA(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),N):t===62&&i===4?(e.consume(t),L):t===63&&i===3?(e.consume(t),I):t===93&&i===5?(e.consume(t),F):MA(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(qj,ee,k)(t)):t===null||MA(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(Jj,A,ee)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||MA(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),I):O(t)}function N(t){return t===47?(e.consume(t),o=``,P):O(t)}function P(t){if(t===62){let n=o.toLowerCase();return Gj.includes(n)?(e.consume(t),L):O(t)}return TA(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),P):O(t)}function F(t){return t===93?(e.consume(t),I):O(t)}function I(t){return t===62?(e.consume(t),L):t===45&&i===2?(e.consume(t),I):O(t)}function L(t){return t===null||MA(t)?(e.exit(`htmlFlowData`),ee(t)):(e.consume(t),L)}function ee(n){return e.exit(`htmlFlow`),t(n)}}function Zj(e,t,n){let r=this;return i;function i(t){return MA(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function Qj(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(ej,t,n)}}const $j={name:`htmlText`,tokenize:eM};function eM(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):TA(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):TA(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):MA(t)?(o=d,N(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):MA(t)?(o=h,N(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):MA(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):MA(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return TA(t)?(e.consume(t),S):n(t)}function S(t){return t===45||EA(t)?(e.consume(t),S):C(t)}function C(t){return MA(t)?(o=C,N(t)):PA(t)?(e.consume(t),C):M(t)}function w(t){return t===45||EA(t)?(e.consume(t),w):t===47||t===62||NA(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||TA(t)?(e.consume(t),E):MA(t)?(o=T,N(t)):PA(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||EA(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):MA(t)?(o=D,N(t)):PA(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):MA(t)?(o=O,N(t)):PA(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):MA(t)?(o=k,N(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||NA(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||NA(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function N(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),P}function P(t){return PA(t)?zA(e,F,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):F(t)}function F(t){return e.enter(`htmlTextData`),o(t)}}const tM={name:`labelEnd`,resolveAll:aM,resolveTo:oM,tokenize:sM},nM={tokenize:cM},rM={tokenize:lM},iM={tokenize:uM};function aM(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&_A(e,0,e.length,n),e}function oM(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=vA(s,e.slice(a+1,a+r+3)),s=vA(s,[[`enter`,u,t]]),s=vA(s,qA(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=vA(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=vA(s,e.slice(o+1)),s=vA(s,[[`exit`,c,t]]),_A(e,a,e.length,s),e}function sM(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(wA(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(nM,u,o?u:d)(t):t===91?e.attempt(rM,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(iM,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function cM(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return NA(t)?Pj(e,a)(t):a(t)}function a(t){return t===41?u(t):jj(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return NA(t)?Pj(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?Nj(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return NA(t)?Pj(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function lM(e,t,n){let r=this;return i;function i(t){return Mj.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(wA(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function uM(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}const dM={name:`labelStartImage`,resolveAll:tM.resolveAll,tokenize:fM};function fM(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}const pM={name:`labelStartLink`,resolveAll:tM.resolveAll,tokenize:mM};function mM(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}const hM={name:`lineEnding`,tokenize:gM};function gM(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),zA(e,t,`linePrefix`)}}const _M={name:`thematicBreak`,tokenize:vM};function vM(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||MA(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),PA(t)?zA(e,s,`whitespace`)(t):s(t))}}const yM={continuation:{tokenize:CM},exit:TM,name:`list`,tokenize:SM},bM={partial:!0,tokenize:EM},xM={partial:!0,tokenize:wM};function SM(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:kA(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(_M,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return kA(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(ej,r.interrupt?n:u,e.attempt(bM,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return PA(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function CM(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(ej,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,zA(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!PA(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(xM,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,zA(e,e.attempt(yM,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function wM(e,t,n){let r=this;return zA(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function TM(e){e.exit(this.containerState.type)}function EM(e,t,n){let r=this;return zA(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!PA(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}const DM={name:`setextUnderline`,resolveTo:OM,tokenize:kM};function OM(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function kM(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),PA(t)?zA(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||MA(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}const AM={tokenize:jM};function jM(e){let t=this,n=e.attempt(ej,r,e.attempt(this.parser.constructs.flowInitial,i,zA(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Ej,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}const MM={resolveAll:IM()},NM=FM(`string`),PM=FM(`text`);function FM(e){return{resolveAll:IM(e===`text`?LM:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function IM(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function LM(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var RM=mr({attentionMarkers:()=>KM,contentInitial:()=>BM,disable:()=>qM,document:()=>zM,flow:()=>HM,flowInitial:()=>VM,insideSpan:()=>GM,string:()=>UM,text:()=>WM});const zM={42:yM,43:yM,45:yM,48:yM,49:yM,50:yM,51:yM,52:yM,53:yM,54:yM,55:yM,56:yM,57:yM,62:nj},BM={91:Fj},VM={[-2]:mj,[-1]:mj,32:mj},HM={35:Vj,42:_M,45:[DM,_M],60:Kj,61:DM,95:_M,96:dj,126:dj},UM={38:cj,92:oj},WM={[-5]:hM,[-4]:hM,[-3]:hM,33:dM,38:cj,42:JA,60:[QA,$j],91:pM,92:[zj,oj],93:tM,95:JA,96:vj},GM={null:[JA,MM]},KM={null:[42,95]},qM={null:[]};function JM(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=vA(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=qA(a,l.events,l),l.events):[]}function f(e,t){return XM(p(e),t)}function p(e){return YM(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){MA(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&_A(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function YM(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function XM(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
900
900
  `;break;case-3:o=`\r
901
901
  `;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function ZM(e){let t={constructs:bA([RM,...(e||{}).extensions||[]]),content:n(BA),defined:[],document:n(HA),flow:n(AM),lazy:{},string:n(NM),text:n(PM)};return t;function n(e){return n;function n(n){return JM(t,e,n)}}}function QM(e){for(;!wj(e););return e}const $M=/[\0\t\n\r]/g;function eN(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if($M.lastIndex=u,c=$M.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}const tN=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function nN(e){return e.replace(tN,rN)}function rN(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return CA(n.slice(t?2:1),t?16:10)}return gA(n)||e}const iN={}.hasOwnProperty;function aN(e,t,n){return typeof t!=`string`&&(n=t,t=void 0),oN(n)(QM(ZM(n).document().write(eN()(e,t,!0))))}function oN(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(ge),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(fe),blockQuote:a(se),characterEscape:T,characterReference:T,codeFenced:a(ce),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(ce,o),codeText:a(le,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(ue),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(de),hardBreakEscape:a(pe),hardBreakTrailing:a(pe),htmlFlow:a(me,o),htmlFlowData:T,htmlText:a(me,o),htmlTextData:T,image:a(he),label:o,link:a(ge),listItem:a(ve),listItemValue:f,listOrdered:a(_e,d),listUnordered:a(_e),paragraph:a(ye),reference:R,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(fe),strong:a(be),thematicBreak:a(Se)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:oe,autolinkProtocol:ae,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:ne,characterReferenceMarkerNumeric:ne,characterReferenceValue:re,characterReference:ie,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(j),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(N),label:F,labelText:P,lineEnding:D,link:c(M),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:te,resourceDestinationString:I,resourceTitleString:L,resource:ee,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};cN(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];iN.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||uN).call(a,void 0,e[0])}for(r.position={start:sN(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:sN(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(t[1].type!==`linePrefix`&&t[1].type!==`blockQuotePrefix`&&t[1].type!==`blockQuotePrefixWhitespace`&&t[1].type!==`blockQuoteMarker`&&t[1].type!==`listItemIndent`)break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:sN(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||uN).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+Ak({start:e.start,end:e.end})+`): it’s not open`);n.position.end=sN(e.end)}function u(){return dA(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=wA(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=xe(),n.position={start:sN(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=sN(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=sN(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function N(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function P(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=nN(t),n.identifier=wA(t).toLowerCase()}function F(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function I(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function L(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function ee(){this.data.inReference=void 0}function R(){this.data.referenceType=`collapsed`}function te(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=wA(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function ne(e){this.data.characterReferenceType=e.type}function re(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=CA(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=gA(t);let i=this.stack[this.stack.length-1];i.value+=r}function ie(e){let t=this.stack.pop();t.position.end=sN(e.end)}function ae(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function oe(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function se(){return{type:`blockquote`,children:[]}}function ce(){return{type:`code`,lang:null,meta:null,value:``}}function le(){return{type:`inlineCode`,value:``}}function ue(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function de(){return{type:`emphasis`,children:[]}}function fe(){return{type:`heading`,depth:0,children:[]}}function pe(){return{type:`break`}}function me(){return{type:`html`,value:``}}function he(){return{type:`image`,title:null,url:``,alt:null}}function ge(){return{type:`link`,title:null,url:``,children:[]}}function _e(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function ve(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function ye(){return{type:`paragraph`,children:[]}}function be(){return{type:`strong`,children:[]}}function xe(){return{type:`text`,value:``}}function Se(){return{type:`thematicBreak`}}}function sN(e){return{line:e.line,column:e.column,offset:e.offset}}function cN(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?cN(e,r):lN(e,r)}}function lN(e,t){let n;for(n in t)if(iN.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function uN(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+Ak({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Ak({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+Ak({start:t.start,end:t.end})+`) is still open`)}function dN(e){let t=this;t.parser=n;function n(n){return aN(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function fN(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function pN(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
@@ -941,32 +941,32 @@ Q();function qb(e){return e===`full_control`?`text-attention`:e===`auto_review`?
941
941
  `,before:c,encode:[`$`],...a.current()})),t()}return c+=a.move(`
942
942
  `),i&&(c+=a.move(i+`
943
943
  `)),c+=a.move(o),s(),c}function r(e,n,r){let i=e.value||``,a=1;for(t||a++;RegExp(`(^|[^$])`+`\\$`.repeat(a)+`([^$]|$)`).test(i);)a++;let o=`$`.repeat(a);/[^ \r\n]/.test(i)&&(/^[ \r\n]/.test(i)&&/[ \r\n]$/.test(i)||/^\$|\$$/.test(i))&&(i=` `+i+` `);let s=-1;for(;++s<r.unsafe.length;){let e=r.unsafe[s];if(!e.atBreak)continue;let t=r.compilePattern(e),n;for(;n=t.exec(i);){let e=n.index;i.codePointAt(e)===10&&i.codePointAt(e-1)===13&&e--,i=i.slice(0,e)+` `+i.slice(n.index+1)}}return o+i+o}function i(){return`$`}}const vB={tokenize:bB,concrete:!0,name:`mathFlow`},yB={tokenize:xB,partial:!0};function bB(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){return e.enter(`mathFlow`),e.enter(`mathFlowFence`),e.enter(`mathFlowFenceSequence`),c(t)}function c(t){return t===36?(e.consume(t),o++,c):o<2?n(t):(e.exit(`mathFlowFenceSequence`),zA(e,l,`whitespace`)(t))}function l(t){return t===null||MA(t)?d(t):(e.enter(`mathFlowFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===null||MA(t)?(e.exit(`chunkString`),e.exit(`mathFlowFenceMeta`),d(t)):t===36?n(t):(e.consume(t),u)}function d(n){return e.exit(`mathFlowFence`),r.interrupt?t(n):e.attempt(yB,f,g)(n)}function f(t){return e.attempt({tokenize:_,partial:!0},g,p)(t)}function p(t){return(a?zA(e,m,`linePrefix`,a+1):m)(t)}function m(t){return t===null?g(t):MA(t)?e.attempt(yB,f,g)(t):(e.enter(`mathFlowValue`),h(t))}function h(t){return t===null||MA(t)?(e.exit(`mathFlowValue`),m(t)):(e.consume(t),h)}function g(n){return e.exit(`mathFlow`),t(n)}function _(e,t,n){let i=0;return zA(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4);function a(t){return e.enter(`mathFlowFence`),e.enter(`mathFlowFenceSequence`),s(t)}function s(t){return t===36?(i++,e.consume(t),s):i<o?n(t):(e.exit(`mathFlowFenceSequence`),zA(e,c,`whitespace`)(t))}function c(r){return r===null||MA(r)?(e.exit(`mathFlowFence`),t(r)):n(r)}}}function xB(e,t,n){let r=this;return i;function i(n){return n===null?t(n):(e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function SB(e){let t=(e||{}).singleDollarTextMath;return t??=!0,{tokenize:n,resolve:CB,previous:wB,name:`mathText`};function n(e,n,r){let i=0,a,o;return s;function s(t){return e.enter(`mathText`),e.enter(`mathTextSequence`),c(t)}function c(n){return n===36?(e.consume(n),i++,c):i<2&&!t?r(n):(e.exit(`mathTextSequence`),l(n))}function l(t){return t===null?r(t):t===36?(o=e.enter(`mathTextSequence`),a=0,d(t)):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),l):MA(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),l):(e.enter(`mathTextData`),u(t))}function u(t){return t===null||t===32||t===36||MA(t)?(e.exit(`mathTextData`),l(t)):(e.consume(t),u)}function d(t){return t===36?(e.consume(t),a++,d):a===i?(e.exit(`mathTextSequence`),e.exit(`mathText`),n(t)):(o.type=`mathTextData`,u(t))}}}function CB(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`mathTextData`){e[t][1].type=`mathTextPadding`,e[n][1].type=`mathTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`mathTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function wB(e){return e!==36||this.events[this.events.length-1][1].type===`characterEscape`}function TB(e){return{flow:{36:vB},text:{36:SB(e)}}}const EB={};function DB(e){let t=this,n=e||EB,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(TB(n)),a.push(gB()),o.push(_B(n))}const OB=(function(e){if(e==null)return NB;if(typeof e==`string`)return jB(e);if(typeof e==`object`)return Array.isArray(e)?kB(e):AB(e);if(typeof e==`function`)return MB(e);throw Error(`Expected function, string, or object as test`)});function kB(e){let t=[],n=-1;for(;++n<e.length;)t[n]=OB(e[n]);return MB(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].call(this,...e))return!0;return!1}}function AB(e){return MB(t);function t(t){let n;for(n in e)if(t[n]!==e[n])return!1;return!0}}function jB(e){return MB(t);function t(t){return t&&t.type===e}}function MB(e){return t;function t(t,...n){return!!(t&&typeof t==`object`&&`type`in t&&e.call(this,t,...n))}}function NB(){return!0}function PB(e){return e}const FB=(function(e,t,n,r){typeof t==`function`&&typeof n!=`function`&&(r=n,n=t,t=null);let i=OB(t),a=r?-1:1;o(e,void 0,[])();function o(e,s,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,"name",{value:`node (`+PB(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=[],u,d,f;if((!t||i(e,s,c[c.length-1]||null))&&(l=IB(n(e,c)),l[0]===!1))return l;if(e.children&&l[0]!==`skip`)for(d=(r?e.children.length:-1)+a,f=c.concat(e);d>-1&&d<e.children.length;){if(u=o(e.children[d],d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+a}return l}}});function IB(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:[e]}const LB=(function(e,t,n,r){typeof t==`function`&&typeof n!=`function`&&(r=n,n=t,t=null),FB(e,t,i,r);function i(e,t){let r=t[t.length-1];return n(e,r?r.children.indexOf(e):null,r)}});function RB(){return e=>{LB(e,[`text`],(e,t,n)=>{if(e.type!==`text`)return;let{value:r}=e,i=r.split(/\^/);if(i.length===1||i.length%2==0)return;let a=i.map((e,t)=>t%2==0?{type:`text`,value:e}:{type:`superscript`,data:{hName:`sup`},children:[{type:`text`,value:e}]});n.children.splice(t,1,...a)}),LB(e,[`text`],(e,t,n)=>{if(e.type!==`text`)return;let{value:r}=e,i=r.split(/\~/);if(i.length===1||i.length%2==0)return;let a=i.map((e,t)=>t%2==0?{type:`text`,value:e}:{type:`subscript`,data:{hName:`sub`},children:[{type:`text`,value:e}]});n.children.splice(t,1,...a)})}}const zB=ot.createContext({});function BB({children:e,artifactRunId:n,onProposalSelect:r,onProposalSubmit:i,MarkdownRenderer:a}){let o=U(()=>({artifactRunId:n,onProposalSelect:r,onProposalSubmit:i,MarkdownRenderer:a}),[n,r,i,a]);return t(zB.Provider,{value:o,children:e})}function VB(){return ot.useContext(zB)}const HB=dt(null);function UB(){return _t(HB)}Q();const WB={chart:{icon:Jm,label:`chart`,defaultHeight:200},mermaid:{icon:f_,label:`diagram`,defaultHeight:150},proposal:{icon:xv,label:`options`,defaultHeight:100},code:{icon:lg,label:`code`,defaultHeight:80},image:{icon:D_,label:`image`,defaultHeight:150},link:{icon:J_,label:`link`,defaultHeight:24},expand:{icon:xg,label:`content`,defaultHeight:100},table:{icon:lb,label:`table`,defaultHeight:150},markdown:{icon:Gg,label:`content`,defaultHeight:100},"fusion-fragment":{icon:lg,label:`fragment`,defaultHeight:150}};function GB({type:e,error:r,onRetry:i,message:a,height:s}){let c=WB[e],l=s??c.defaultHeight,u=e===`link`;if(r)return n(`div`,{className:`flex items-center gap-2 rounded border border-destructive/30 bg-destructive/5 text-destructive ${u?`inline-flex px-2 py-1 text-sm`:`p-4`}`,style:u?void 0:{minHeight:l},children:[n(`span`,{className:`text-destructive`,children:[`Failed to load `,c.label]}),i&&t(o,{variant:`unstyled`,onClick:i,className:`ms-2 rounded bg-destructive/10 px-2 py-1 text-xs hover:bg-destructive/20 transition-colors text-destructive`,children:`Retry`})]});let d=c.icon;return u?n(`span`,{className:`inline-flex items-center gap-1 text-muted animate-pulse`,children:[t(d,{className:`h-3 w-3`}),t(`span`,{children:a||`Loading ${c.label}...`})]}):n(`div`,{className:`flex flex-col items-center justify-center gap-3 rounded border border-border bg-muted/30 animate-pulse`,style:{minHeight:l},children:[t(d,{className:`h-8 w-8 text-muted`}),t(`span`,{className:`text-sm text-muted`,children:a||`Loading ${c.label}...`}),t(`div`,{className:`flex gap-1`,children:[...[,,,]].map((e,n)=>t(`div`,{className:`h-2 w-2 rounded-full bg-muted animate-bounce`,style:{animationDelay:`${n*150}ms`}},`dot-${n}`))})]})}var KB=class extends ot.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`CodeBlock rendering error (${this.props.type}):`,e,t),this.props.onError?.(e)}handleRetry=()=>{this.setState({hasError:!1,error:void 0})};render(){if(this.state.hasError){let{type:e,fallbackCode:r}=this.props;return n(`div`,{className:`space-y-2`,children:[t(GB,{type:e,error:this.state.error?.message||`Rendering failed`,onRetry:this.handleRetry}),r&&n(`details`,{className:`text-sm`,children:[t(`summary`,{className:`cursor-pointer text-muted hover:text-foreground`,children:`Show raw content`}),t(`pre`,{className:`mt-2 overflow-x-auto rounded bg-muted/50 p-2 text-xs`,children:t(`code`,{children:r})})]})]})}return this.props.children}};function qB(e,t,n){let r=t.split(`.`).pop()?.toLowerCase();if(r===`svg`)return`mockup`;if([`png`,`jpg`,`jpeg`,`gif`,`webp`].includes(r||``))return`image`;if(r===`md`)return`markdown`;if(r===`csv`)return`table`;if(n===`json`&&typeof e==`object`&&e){let t=e;if(typeof t.$schema==`string`&&t.$schema.includes(`vega`)||t.library===`vega-lite`&&`spec`in t)return`vega-lite`;if(`template`in t&&`data`in t)return`fusion-fragment`;if(Array.isArray(e)&&e.length>0&&typeof e[0]==`object`)return`table`}return`code`}function JB(e){if(typeof e!=`object`||!e)return null;let t=e;return t.library===`vega-lite`&&`spec`in t&&typeof t.spec==`object`&&t.spec!==null?t:typeof t.$schema==`string`&&t.$schema.includes(`vega`)?{library:`vega-lite`,spec:t}:null}function YB({content:e}){let{headers:r,rows:i}=U(()=>{if(!Array.isArray(e)||e.length===0)return{headers:[],rows:[]};let t=e[0];if(typeof t!=`object`||!t)return{headers:[],rows:[]};let n=Object.keys(t);return{headers:n,rows:e.map(e=>n.map(t=>{let n=e[t];return n==null?``:typeof n==`object`?JSON.stringify(n):String(n)}))}},[e]);return r.length===0?t(GB,{type:`table`,error:`No table data found`}):n(`div`,{className:`overflow-x-auto`,children:[n(`table`,{className:`min-w-full text-sm border-collapse`,children:[t(`thead`,{children:t(`tr`,{className:`border-b`,children:r.map(e=>t(`th`,{className:`px-3 py-2 text-start font-medium text-muted`,children:e},e))})}),t(`tbody`,{children:i.slice(0,100).map((e,n)=>t(`tr`,{className:`border-b border-muted/20`,children:e.map((e,n)=>t(`td`,{className:`px-3 py-2`,children:e},`cell-${n}`))},`row-${n}`))})]}),i.length>100&&n(`div`,{className:`text-sm text-muted py-2`,children:[`Showing 100 of `,i.length,` rows`]})]})}function XB({content:e,path:n}){let r=n.split(`.`).pop()?.toLowerCase()||``,i=typeof e==`string`?e:JSON.stringify(e,null,2);return t(`pre`,{className:`overflow-x-auto p-3 bg-muted/10 rounded text-sm`,children:t(`code`,{className:`language-${r}`,children:i})})}function ZB(e){return Xn.sanitize(e,{USE_PROFILES:{svg:!0,svgFilters:!0},ADD_TAGS:[`use`],FORBID_TAGS:[`foreignObject`]})}function QB(e){return e.replace(/<svg([^>]*)>/i,(e,t)=>{let n=t;if(!/viewBox/i.test(n)){let e=/\swidth\s*=\s*["']?(\d+(?:\.\d+)?)/i.exec(n),t=/\sheight\s*=\s*["']?(\d+(?:\.\d+)?)/i.exec(n);e&&t&&(n+=` viewBox="0 0 ${e[1]} ${t[1]}"`)}return n=n.replace(/\swidth\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/i,``).replace(/\sheight\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/i,``),/style="/i.test(n)?n=n.replace(/style="([^"]*)"/i,(e,t)=>`style="${t};width:100%;height:auto;display:block;max-width:100%;"`):n+=` style="width:100%;height:auto;display:block;max-width:100%;"`,/preserveAspectRatio=/i.test(n)||(n+=` preserveAspectRatio="xMidYMid meet"`),`<svg${n}>`})}function $B({content:e}){let n=U(()=>{let t=typeof e==`string`?e.trim():``;return t?QB(ZB(t)):null},[e]);return n?t(`div`,{style:{margin:`16px 0`,width:`100%`,overflowX:`auto`},dangerouslySetInnerHTML:{__html:n}}):t(GB,{type:`expand`,error:`Empty mockup`})}function eV({content:e,path:n}){let r=typeof e==`string`?e:``,i=n.split(`/`).pop()||`Artifact image`;return t(`img`,{src:r,alt:i,className:`max-w-full h-auto rounded`,loading:`lazy`})}function tV({content:e,renderType:n,path:r,runId:i,contentType:a}){let{MarkdownRenderer:o}=VB();switch(U(()=>n===`auto`?qB(e,r,a):n,[e,r,a,n])){case`chart`:{let n=JB(e);return n?t(KB,{type:`chart`,fallbackCode:JSON.stringify(e,null,2),children:t(oC,{spec:n,artifactRunId:i})}):t(GB,{type:`chart`,error:`Only Vega-Lite charts are supported. Recharts rendering has been retired.`})}case`vega-lite`:{let n=JB(e);return n?t(KB,{type:`chart`,fallbackCode:JSON.stringify(e,null,2),children:t(oC,{spec:n,artifactRunId:i})}):t(GB,{type:`chart`,error:`Invalid Vega-Lite specification`})}case`fusion-fragment`:{let n=e;return console.log(`[ArtifactContentRenderer] fusion-fragment:`,{hasTemplate:!!n.template,hasData:!!n.data,runId:i,hasVegaLiteChart:!!oC}),n.template&&n.data?t(KB,{type:`fusion-fragment`,fallbackCode:JSON.stringify(e,null,2),children:t(Yn,{data:n.data,ChartComponent:oC,artifactRunId:i,children:t(Jn,{code:JSON.stringify(n.template),data:n.data})})}):t(KB,{type:`fusion-fragment`,fallbackCode:JSON.stringify(e,null,2),children:t(Jn,{code:JSON.stringify(e)})})}case`table`:return t(KB,{type:`table`,fallbackCode:JSON.stringify(e,null,2),children:t(YB,{content:e})});case`markdown`:{let n=typeof e==`string`?e:String(e);return t(KB,{type:`markdown`,fallbackCode:n,children:o?t(o,{artifactRunId:i,children:n}):t(`pre`,{className:`overflow-x-auto p-3 bg-muted/10 rounded text-sm`,children:t(`code`,{children:n})})})}case`mockup`:return t(KB,{type:`expand`,fallbackCode:typeof e==`string`?e:r,children:t($B,{content:e})});case`image`:return t(KB,{type:`image`,fallbackCode:r,children:t(eV,{content:e,path:r})});default:return t(XB,{content:e,path:r})}}const nV=`Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`;function rV(e){let t=e.trim(),n=``,r=!1,i=!1;for(let e=0;e<t.length;e++){let a=t[e],o=e>0?t[e-1]:``;if(a===`"`&&!i&&o!==`\\`){r=!r,n+=a;continue}if(a===`'`&&!r&&o!==`\\`){i=!i,n+=a;continue}if((r||i)&&a===`\\`){let r=e;for(;t[r]===`\\`;)r++;if(t[r]===`n`){n+=`<br/>`,e=r;continue}}n+=a}return n}function iV(e){return e.replace(/<svg([^<>]*)>/i,(e,t)=>{let n=t.replace(/\swidth="[^"]*"/i,``).replace(/\sheight="[^"]*"/i,``);return/style="/i.test(n)?n=n.replace(/style="([^"]*)"/i,(e,t)=>`style="${t};width:100%;height:auto;display:block;max-width:100%;"`):n+=` style="width:100%;height:auto;display:block;max-width:100%;"`,/preserveAspectRatio=/i.test(n)||(n+=` preserveAspectRatio="xMidYMid meet"`),`<svg${n}>`})}let aV;function oV(){return aV||=import(`mermaid`).then(({default:e})=>(e.initialize({startOnLoad:!1,theme:`default`,securityLevel:`loose`,fontFamily:nV,suppressErrorRendering:!0,flowchart:{htmlLabels:!0,useMaxWidth:!0,nodeSpacing:40,rankSpacing:50,padding:12},sequence:{useMaxWidth:!0},themeVariables:{fontFamily:nV}}),e)),aV}function sV({code:e,className:n}){let r=W(null),[i,a]=G(null),[o,s]=G(null),c=vt().replace(/:/g,`_`);return H(()=>{let t=!1;return(async()=>{if(!e.trim()){a(null),s(null);return}try{s(null);let n=`mermaid-${c}-${Date.now()}`,r=rV(e),{svg:i}=await(await oV()).render(n,r),o=iV(i);t||a(o)}catch(e){if(!t){let t=e instanceof Error?e.message:`Failed to render mermaid diagram`;s(t),a(null)}}})(),()=>{t=!0}},[e,c]),o?null:i?t(`div`,{ref:r,className:`my-4 w-full overflow-x-auto [&_svg]:mx-auto [&_svg]:w-full [&_svg]:h-auto [&_svg]:max-w-full ${n||``}`,dangerouslySetInnerHTML:{__html:i}}):t(`div`,{className:`my-4 p-4 bg-muted rounded-lg animate-pulse ${n||``}`,children:t(`div`,{className:`h-32 bg-muted rounded`})})}function cV(e){switch(e.split(`.`).pop()?.toLowerCase()){case`json`:return`json`;case`md`:case`txt`:case`csv`:case`yaml`:case`yml`:return`text`;case`png`:case`jpg`:case`jpeg`:case`gif`:case`webp`:case`pdf`:return`binary`;default:return`text`}}function lV({runId:e,path:t,parseJson:n=!0}){let{client:r}=q(),i=VS(),a=W(r);a.current=r;let o=W(i);o.current=i;let[s,c]=G({data:void 0,rawContent:void 0,isLoading:!0,error:void 0,contentType:void 0}),l=V(async()=>{if(!e){c({data:void 0,rawContent:void 0,isLoading:!1,error:`No run ID provided`,contentType:void 0});return}if(!t){c({data:void 0,rawContent:void 0,isLoading:!1,error:`No artifact path provided`,contentType:void 0});return}c(e=>({...e,isLoading:!0,error:void 0}));let r=a.current,i=o.current,s=cV(t);try{let a=US(e,t,`inline`),o;o=i?await i.getOrFetch(a,async()=>(await r.files.getArtifactDownloadUrl(e,t,`inline`)).url):(await r.files.getArtifactDownloadUrl(e,t,`inline`)).url;let l=await fetch(o);if(!l.ok)throw Error(`Failed to fetch artifact: ${l.status} ${l.statusText}`);if(s===`binary`){c({data:o,rawContent:void 0,isLoading:!1,error:void 0,contentType:s,etag:l.headers.get(`etag`)?.replace(/^"(.*)"$/,`$1`)});return}let u=await l.text(),d;if(n&&s===`json`)try{d=JSON.parse(u)}catch{d=u}else d=u;c({data:d,rawContent:u,isLoading:!1,error:void 0,contentType:s,etag:l.headers.get(`etag`)?.replace(/^"(.*)"$/,`$1`)})}catch(e){let n=e instanceof Error?e.message:`Failed to fetch artifact`;console.error(`Failed to fetch artifact content:`,t,e),c({data:void 0,rawContent:void 0,isLoading:!1,error:n,contentType:s})}},[e,t,n]);H(()=>{l()},[l]);let u=V(()=>{c({data:void 0,rawContent:void 0,isLoading:!0,error:void 0,contentType:void 0}),l()},[l]);return{data:s.data,rawContent:s.rawContent,isLoading:s.isLoading,error:s.error,contentType:s.contentType,etag:s.etag,retry:u}}function uV(e){let t=e.trim();if(t.length<2)return!0;if(!t.startsWith(`{`))return!1;try{return JSON.parse(t),!1}catch(e){let n=e instanceof Error?e.message:``,r=[`unexpected end`,`unterminated string`,`expected`,`unexpected token`],i=n.toLowerCase();if(r.some(e=>i.includes(e))){let e=0,n=0,r=!1,i=!1;for(let a of t){if(i){i=!1;continue}if(a===`\\`){i=!0;continue}if(a===`"`){r=!r;continue}r||(a===`{`?e++:a===`}`?e--:a===`[`?n++:a===`]`&&n--)}return e>0||n>0||r}return!1}}function dV(e){try{let t=e.trim(),n=t.indexOf(`{`),r=t.lastIndexOf(`}`);return n!==-1&&r>n&&(t=t.slice(n,r+1)),JSON.parse(t)}catch{return null}}function fV(e){let t=typeof e.$schema==`string`&&e.$schema.includes(`vega`),n=e.library===`vega-lite`&&`spec`in e;return t||n?`vega-lite`:null}function pV({code:e}){let{artifactRunId:n}=VB();n||console.warn(`[VegaLiteCodeBlockHandler] artifactRunId is missing from CodeBlockContext`);let r=U(()=>uV(e),[e]),i=U(()=>{if(r)return null;let t=dV(e);return t?{library:`vega-lite`,spec:t}:null},[e,r]);return r?t(GB,{type:`chart`,message:`Loading chart...`}):i?t(KB,{type:`chart`,fallbackCode:e,children:t(oC,{spec:i,artifactRunId:n})}):t(GB,{type:`chart`,error:`Invalid Vega-Lite specification`})}function mV({code:e}){let{artifactRunId:n}=VB();n||console.warn(`[ChartCodeBlockHandler] artifactRunId is missing from CodeBlockContext`);let r=U(()=>uV(e),[e]),i=U(()=>{if(r)return null;let t=dV(e);return!t||!fV(t)?null:t.library===`vega-lite`&&`spec`in t&&typeof t.spec==`object`?t:{library:`vega-lite`,spec:t}},[e,r]);return r?t(GB,{type:`chart`,message:`Loading chart...`}):i?t(KB,{type:`chart`,fallbackCode:e,children:t(oC,{spec:i,artifactRunId:n})}):t(GB,{type:`chart`,error:`Invalid Vega-Lite chart specification`})}function hV({code:e}){let n=e.trim();return n?t(KB,{type:`mermaid`,fallbackCode:e,children:t(sV,{code:n})}):t(GB,{type:`mermaid`,error:`Empty diagram`})}function gV({code:e}){let n=U(()=>{let t=e.trim();return t?QB(ZB(t)):null},[e]);return n?t(KB,{type:`code`,fallbackCode:e,children:t(`div`,{style:{margin:`16px 0`,width:`100%`,overflowX:`auto`},dangerouslySetInnerHTML:{__html:n}})}):t(GB,{type:`code`,error:`Empty mockup`})}function _V({code:e,language:n}){let{artifactRunId:r}=VB(),i=e.trim(),a=U(()=>{if(!n?.includes(`:`))return`auto`;let e=n.split(`:`)[1];return[`chart`,`vega-lite`,`table`,`markdown`,`fusion-fragment`,`mockup`,`code`,`image`,`auto`].includes(e)?e:`auto`},[n]),{data:o,isLoading:s,error:c,contentType:l}=lV({runId:r,path:i});return r?s?t(GB,{type:`expand`,message:`Loading ${i}...`}):c?t(GB,{type:`expand`,error:`Failed to load artifact: ${c}`}):o===void 0?t(GB,{type:`expand`,error:`No content found in artifact`}):t(tV,{content:o,renderType:a,path:i,runId:r,contentType:l}):t(GB,{type:`expand`,error:`No artifact run ID available`})}function vV(e){return e?.startsWith(`expand`)??!1}function yV(){return{chart:mV,"vega-lite":pV,vegalite:pV,mermaid:hV,mockup:gV,svg:gV}}const bV=new Set([`store`,`document`,`collection`,`interaction`,`prompt`,`agent`,`workflow`,`process`,`run`]);function xV(e){return e.trim().replace(/^\/+/,``)}function SV(e){if(e.startsWith(`artifact:`))return{scheme:`artifact`,path:e.slice(9).trim()};if(e.startsWith(`image:`))return{scheme:`image`,path:e.slice(6).trim()};let t=e.indexOf(`:`);if(t>0){let n=e.slice(0,t);if(bV.has(n))return{scheme:n,path:xV(e.slice(t+1))}}return{scheme:`standard`,path:e}}function CV({rawUrl:e,artifactRunId:t,disposition:n=`inline`}){let{client:r}=q(),i=VS(),a=W(r);a.current=r;let o=W(i);o.current=i;let{scheme:s,path:c}=SV(e),[l,u]=G(()=>{if(s===`standard`)return{url:e,isLoading:!1,error:void 0};if(i&&(s===`artifact`||s===`image`)){let e;e=s===`artifact`&&t&&!HS(c)?US(t,c,n):WS(c);let r=i.getUrl(e);if(r)return{url:r,isLoading:!1,error:void 0}}return{url:void 0,isLoading:!0,error:void 0}}),d=V(async()=>{if(s===`standard`)return;if(s!==`artifact`&&s!==`image`){u({url:void 0,isLoading:!1,error:`Unknown scheme: ${s}`});return}u(e=>({...e,isLoading:!0,error:void 0}));let e=a.current,r=o.current;try{let i;if(s===`artifact`){if(t&&!HS(c)){let a=US(t,c,n);i=r?await r.getOrFetch(a,async()=>(await e.files.getArtifactDownloadUrl(t,c,n)).url):(await e.files.getArtifactDownloadUrl(t,c,n)).url}else{let t=WS(c);i=r?await r.getOrFetch(t,async()=>(await e.files.getDownloadUrl(c)).url):(await e.files.getDownloadUrl(c)).url}}else{let t=WS(c);i=r?await r.getOrFetch(t,async()=>(await e.files.getDownloadUrl(c)).url):(await e.files.getDownloadUrl(c)).url}u({url:i,isLoading:!1,error:void 0})}catch(e){let t=e instanceof Error?e.message:`Failed to resolve URL`;console.error(`Failed to resolve URL:`,c,e),u({url:void 0,isLoading:!1,error:t})}},[s,c,t,n]);H(()=>{if(l.url&&!l.error)return;let e=!1;return e||(async()=>{await d()})(),()=>{e=!0}},[d,l.url,l.error]);let f=V(()=>{u({url:void 0,isLoading:!0,error:void 0}),d()},[d]);return{url:l.url,isLoading:l.isLoading,error:l.error,scheme:s,retry:f}}function wV({src:e,alt:r,caption:i,className:a,artifactRunId:o}){let s=e||``,{scheme:c}=SV(s);return c===`standard`?n(`figure`,{className:`my-4`,children:[t(`img`,{src:e,alt:r,className:a}),t(`figcaption`,{className:`mt-2 text-sm text-muted text-center italic`,children:i})]}):t(TV,{rawSrc:s,alt:r,caption:i,artifactRunId:o,className:a})}function TV({rawSrc:e,alt:r,caption:i,artifactRunId:a,className:o}){let{url:s,isLoading:c,error:l,retry:u}=CV({rawUrl:e,artifactRunId:a,disposition:`inline`});return c?t(GB,{type:`image`,message:r?`Loading ${r}...`:void 0}):l?t(GB,{type:`image`,error:l,onRetry:u}):s?n(`figure`,{className:`my-4`,children:[t(`img`,{src:s,alt:r,className:o}),t(`figcaption`,{className:`mt-2 text-sm text-muted text-center italic`,children:i})]}):null}function EV({node:e,src:n,alt:r,className:i,artifactRunId:a,ExistingImg:o,...s}){let c=n||``,{scheme:l}=SV(c);return l===`standard`?typeof o==`function`?t(o,{node:e,src:n,alt:r,...s}):t(`img`,{src:n,alt:r,className:i,...s}):t(DV,{rawSrc:c,alt:r,artifactRunId:a,className:i,rest:s})}function DV({rawSrc:e,alt:n,artifactRunId:r,className:i,rest:a}){let{url:o,isLoading:s,error:c,retry:l}=CV({rawUrl:e,artifactRunId:r,disposition:`inline`});return s?t(GB,{type:`image`,message:n?`Loading ${n}...`:void 0}):c?t(GB,{type:`image`,error:c,onRetry:l}):o?t(`img`,{src:o,alt:n,className:i,...a}):null}const OV=dt(()=>({kind:`none`}));OV.Provider;function kV(){return _t(OV)}const AV={store:`document`,document:`document`,collection:`collection`,interaction:`interaction`,prompt:`prompt`,agent:`agent`,workflow:`workflow`,process:`process`,run:`interaction_run`};function jV(e){let t=e.indexOf(`:`);if(t<=0)return;let n=e.slice(0,t);if(!Object.hasOwn(AV,n))return;let r=e.slice(t+1).trim().replace(/^\/+/,``);if(r)return{type:AV[n],id:r}}function MV({node:e,href:n,children:r,className:i,artifactRunId:a,onArtifactOpen:o,ExistingLink:s,...c}){let l=n||``,u=jV(l);if(u)return t(NV,{resource:u,rawHref:l,artifactRunId:a,className:i,ExistingLink:s,rest:c,children:r});let{scheme:d,path:f}=SV(l);return d===`standard`?typeof s==`function`?t(s,{node:e,href:n,className:i,...c,children:r}):t(`a`,{href:n,...c,className:i,target:`_blank`,rel:`noopener noreferrer`,children:r}):t(PV,{rawHref:l,artifactRunId:a,artifactPath:d===`artifact`?f:void 0,onArtifactOpen:o,className:i,rest:c,children:r})}function NV({resource:e,rawHref:n,artifactRunId:r,className:i,children:a,ExistingLink:s,rest:c}){let l=kV()(e,{workflowRunId:r,source:`markdown`,rawHref:n});return l.kind===`navigate`?typeof s==`function`?t(s,{href:l.href,className:i,...c,children:a}):t(`a`,{href:l.href,...c,className:i,target:`_blank`,rel:`noopener noreferrer`,children:a}):l.kind===`activate`?t(o,{variant:`link`,size:`none`,className:i,onClick:l.onActivate,children:a}):t(`span`,{className:i,children:a})}function PV({rawHref:e,artifactRunId:n,artifactPath:r,onArtifactOpen:i,className:a,children:o,rest:s}){let{url:c,isLoading:l,error:u,retry:d}=CV({rawUrl:e,artifactRunId:n,disposition:`attachment`});return l?t(`span`,{className:`inline-flex items-center gap-1 text-muted`,children:t(GB,{type:`link`})}):u?t(`span`,{className:`inline-flex items-center gap-1`,children:t(GB,{type:`link`,error:u,onRetry:d})}):t(`a`,{href:c||`#`,...s,className:a,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>{r&&/\.md$/i.test(r)&&i&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&e.button===0&&(e.preventDefault(),i(r))},children:o})}const FV=[`artifact:`,`image:`,`store:`,`document://`,`collection:`,`interaction:`,`prompt:`,`agent:`,`workflow:`,`process:`,`run:`],IV=/(!?\[[^[\]\n]*\]\()((?:artifact:|image:|store:|document:\/\/|collection:|interaction:|prompt:|agent:|workflow:|process:|run:)[^)[\n]+)(\))/g,LV=/`[^`\n]*`/g,RV=/(^|\n)(`{3,}|~{3,})[^\n]*\n[\s\S]*?\n\2(?=\n|$)/g,zV=/\s+("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\([^)]*\))\s*$/;function BV(e){return FV.some(t=>e.startsWith(t))}function VV(e){let t=e.trim();if(t.startsWith(`<`)){let n=t.indexOf(`>`);if(n>0&&BV(t.slice(1,n).trim()))return e}let n=t.match(zV)?.index??-1,r=(n>=0?t.slice(0,n):t).trim(),i=n>=0?t.slice(n):``;return BV(r)?`<${r}>${i}`:e}function HV(e){return e.replace(IV,(e,t,n,r)=>`${t}${VV(n)}${r}`)}function UV(e){let t=``,n=0;for(let r of e.matchAll(LV))t+=HV(e.slice(n,r.index)),t+=r[0],n=r.index+r[0].length;return t+=HV(e.slice(n)),t}function WV(e){if(!e||!FV.some(t=>e.includes(t)))return e;let t=``,n=0;for(let r of e.matchAll(RV))t+=UV(e.slice(n,r.index)),t+=r[0],n=r.index+r[0].length;return t+=UV(e.slice(n)),t}const GV=/^([ \t]*):::([^\n]*?):::[ \t]*$/gm,KV=/^\w+/;function qV(e){return e?.includes(`:::`)?e.replace(GV,(e,t,n)=>{let r=n.trim(),i=KV.exec(r);if(!i)return e;let a=i[0],o=r.slice(a.length).trim();return o?`${t}:::${a}\n${t}${o}\n${t}:::`:`${t}::${a}`}):e}const JV=/(^|\n)(`{3,}|~{3,})[^\n]*\n[\s\S]*?\n\2(?=\n|$)/g,YV=/`[^`\n]*`/g,XV=/\\\$/g,ZV=/\\[^\s]/,QV=/[{}]/,$V=/[_^][\w{]/,eH=/^[a-zA-Z]$/,tH=/^[a-zA-Z]\s*=/,nH=/^\s/,rH=/\s$/,iH=/[+*/-]$/,aH=/\^[+-]$/;function oH(e){return ZV.test(e)||QV.test(e)||$V.test(e)||eH.test(e)||tH.test(e)}function sH(e){return!!(nH.test(e)||rH.test(e)||iH.test(e)&&!aH.test(e))}function cH(e){let t=[];for(let n=0;n<e.length;n++)if(e[n]===`$`&&!(n>0&&e[n-1]===`\\`)){if(n+1<e.length&&e[n+1]===`$`){n++;continue}n>0&&e[n-1]===`$`&&(n<2||e[n-2]!==`\\`)||t.push(n)}return t}function lH(e,t,n){let r=e.slice(t+1,n);return r.length===0||r.includes(`
944
- `)?null:r}function uH(e){let t=cH(e);if(t.length<2)return e;let n=new Set,r=new Set,i=Array(t.length-1);for(let n=0;n<t.length-1;n++)i[n]=lH(e,t[n],t[n+1]);let a=[];for(let e=0;e<t.length-1;e++){if(n.has(e))continue;let r=i[e];r!==null&&oH(r)&&(n.add(e),n.add(e+1),a.push([t[e],t[e+1]]))}let o=0;for(;o<t.length;){if(n.has(o)){o++;continue}let e=o+1;for(;e<t.length&&n.has(e);)e++;if(e>=t.length)break;if(e>o+1){r.add(t[o]),o++;continue}let a=i[o];if(a===null){o++;continue}sH(a)&&(r.add(t[o]),r.add(t[e])),n.add(o),n.add(e),o=e+1}for(let e=0;e<t.length;e++)n.has(e)||e+1<t.length&&n.has(e+1)&&r.add(t[e]);if(r.size===0&&a.length===0)return e;let s=[],c=0,l=Array.from(r).sort((e,t)=>e-t),u=0,d=0;for(;u<l.length||d<a.length;){let t=u<l.length?l[u]:1/0;if(t<(d<a.length?a[d][0]:1/0))t>c&&s.push(e.slice(c,t)),s.push(`\\$`),c=t+1,u++;else{let[t,n]=a[d];t>c&&s.push(e.slice(c,t));let r=e.slice(t,n+1);for(s.push(r.replace(XV,`\\text{\\textdollar}`)),c=n+1;u<l.length&&l[u]<=n;)u++;d++}}return c<e.length&&s.push(e.slice(c)),s.join(``)}function dH(e){let t=[],n=0;for(let r of e.matchAll(YV))t.push(uH(e.slice(n,r.index))),t.push(r[0]),n=r.index+r[0].length;return t.push(uH(e.slice(n))),t.join(``)}function fH(e){if(!e?.includes(`$`))return e;let t=[],n=0;for(let r of e.matchAll(JV))t.push(dH(e.slice(n,r.index))),t.push(r[0]),n=r.index+r[0].length;return t.push(dH(e.slice(n))),t.join(``)}const pH={note:`md-callout-info`,tip:`md-callout-info`,warning:`md-callout-attention`,important:`md-callout-attention`,caution:`md-callout-destructive`},mH={note:`Note`,tip:`Tip`,warning:`Warning`,important:`Important`,caution:`Caution`};function hH(){return(e,t)=>{mP(e,(e,n,r)=>{if(e.type===`textDirective`){let i=e.position?.start.offset,a=e.position?.end.offset;if(r&&n!==void 0&&i!==void 0&&a!==void 0){let o={type:`text`,value:t.toString().slice(i,a),position:e.position};r.children[n]=o}return dP}if(e.type!==`containerDirective`&&e.type!==`leafDirective`)return;let i=e;i.data||={};let a=i.data,o=i.attributes||{},s=i.name;if(s===`pagebreak`){a.hName=`hr`,a.hProperties={className:`md-pagebreak`};return}if(s===`columns`){a.hName=`div`,a.hProperties={className:`md-columns`};return}if(s===`column`){a.hName=`div`;let e={className:`md-column`};o.width&&(e.style=`flex-basis:${o.width};flex-grow:0;flex-shrink:0`),a.hProperties=e;return}if(s in pH){a.hName=`div`,a.hProperties={className:`md-callout ${pH[s]}`,"data-callout-type":s};let e=mH[s];if(e&&i.children){let t={type:`paragraph`,data:{hName:`p`,hProperties:{className:`md-callout-title`}},children:[{type:`text`,value:e}]};i.children.unshift(t)}return}a.hName=`div`,a.hProperties={className:`md-${s}`,...Object.fromEntries(Object.entries(o).filter(([e])=>e!==`class`))},o.class&&(a.hProperties.className+=` ${o.class}`)})}}const gH=/(?:^|[^\\])\$/,_H=[];let vH,yH;function bH(){return yH||=import(`rehype-katex`).then(({default:e})=>(vH=e,e)),yH}function xH(e){let t=ot.useMemo(()=>gH.test(e),[e]),[n,r]=ot.useState(()=>vH);return ot.useEffect(()=>{if(!t||n)return;let e=!1;return bH().then(t=>{e||r(()=>t)}).catch(e=>{console.error(`Failed to load KaTeX; math will render unstyled`,e)}),()=>{e=!0}},[t,n]),ot.useMemo(()=>n?[n]:_H,[n])}const SH=[`artifact:`,`image:`,`store:`,`document:`,`document://`,`collection:`,`interaction:`,`prompt:`,`agent:`,`workflow:`,`process:`,`run:`];function CH(e){return SH.some(t=>e.startsWith(t))?e:gF(e)}function wH(){return e=>{mP(e,`html`,(e,t,n)=>{let r=e,i=n;if(typeof r.value==`string`&&/<!--[\s\S]*?-->/.test(r.value)&&i?.children&&typeof t==`number`)return i.children.splice(t,1),[dP,t]})}}const TH=yV();function EH({children:e,components:n,remarkPlugins:r=[],removeComments:i=!0,artifactRunId:a,onArtifactOpen:o,className:s,codeClassName:c,inlineCodeClassName:l,linkClassName:u,imageClassName:d,onProposalSelect:f,onProposalSubmit:p,preserveSourcePositions:m=!1}){let h=UB(),g=ot.useMemo(()=>m?e:qV(WV(fH(e))),[e,m]),_=ot.useMemo(()=>{let e=[uB,fL,hH,pB,XF,RB,DB,...r];return i&&e.push(wH),e},[r,i]),v=xH(g),y=ot.useMemo(()=>({handlers:{...JF}}),[]),b=ot.useMemo(()=>{let e=n||{},r=e.code,i=e.a,s=e.img,f=({node:e,className:n,children:i,...a})=>{let o=/language-([\w-]+)/.exec(n||``),s=!o,u=o?o[1]:``;if(!s&&u){if(h){let e=h.getComponent(u);if(e){let n=String(i||``).trim();return t(e,{code:n,language:u})}}if(vV(u)){let e=String(i||``).trim();return t(_V,{code:e,language:u})}let e=TH[u];if(e){let n=String(i||``).trim();return t(e,{code:n,language:u})}}return typeof r==`function`?t(r,{node:e,className:n,...a,children:i}):t(`code`,{...a,className:s?`px-1.5 py-0.5 rounded ${l||``}`:` ${c||``}`,children:i})},p=e=>{let{node:n,href:r,children:s,...c}=e;return t(MV,{node:n,href:r,className:u,artifactRunId:a,onArtifactOpen:o,ExistingLink:typeof i==`function`?i:void 0,...c,children:s})},m=e=>{let{node:n,src:r,alt:i,title:o,...c}=e;return o?t(wV,{src:r,alt:i,caption:o,className:d,artifactRunId:a}):t(EV,{node:n,src:r,alt:i,className:d,artifactRunId:a,ExistingImg:typeof s==`function`?s:void 0,...c})};return{...e,code:f,a:p,img:m}},[n,a,o,h,c,l,u,d]),x=t(BB,{artifactRunId:a,onProposalSelect:f,onProposalSubmit:p,MarkdownRenderer:EH,children:t(fF,{remarkPlugins:_,rehypePlugins:v,remarkRehypeOptions:y,components:b,urlTransform:CH,children:g})});return s?t(`div`,{className:`md-content ${s}`,children:x}):t(`div`,{className:`md-content`,children:x})}Q();const DH={default:{border:`border-s-attention`,bg:`bg-attention`,icon:`text-attention`},warning:{border:`border-s-destructive`,bg:`bg-destructive`,icon:`text-destructive`},info:{border:`border-s-info`,bg:`bg-info`,icon:`text-info`},success:{border:`border-s-success`,bg:`bg-success`,icon:`text-success`}},OH={default:Hh,warning:Ah,info:xv,success:Nh},kH=`max-h-80 overflow-y-auto overscroll-contain pe-2`;function AH({question:r,description:i,options:a,onSelect:s,onMultiSelect:c,onSubmit:l,allowFreeResponse:u=!1,multiSelect:d=!1,placeholder:f,submitLabel:p,isLoading:m=!1,icon:h,variant:g=`default`,hideIcon:_=!1,hideBorder:v=!1,compact:y=!1,answered:b=!1,className:x,cardClassName:S,headerClassName:C,iconClassName:w,questionClassName:T,descriptionClassName:E,optionsClassName:D,buttonClassName:O,inputContainerClassName:k,inputClassName:A,submitButtonClassName:j}){let{t:M}=K(),N=f??M(`agent.typeYourResponse`),P=p??M(`agent.send`),[F,I]=ot.useState(``),[L,ee]=ot.useState(new Set),R=ot.useRef(null),te=DH[g],ne=OH[g],re=Array.isArray(a)?a:[],ie=ot.useRef(!1);ot.useEffect(()=>{a===void 0||Array.isArray(a)||ie.current||(ie.current=!0,Hn.logger.warn(`AskUserWidget received invalid options; rendering without options`,{vertesia:{component:`AskUserWidget`,received_type:typeof a}}),console.warn(`[AskUserWidget] Invalid options received; rendering without options.`))},[a]);let ae=e=>{ee(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},oe=()=>{L.size>0&&c&&(c(Array.from(L)),ee(new Set))},se=()=>{F.trim()&&l&&(l(F.trim()),I(``))},ce=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),se())},le=v?``:`border-s-4 ${te.border}`;if(y){let a=h||t(ne,{className:`size-4`}),c=t(`div`,{className:z(`agent-ask-question text-sm leading-6 text-foreground/85`,T),children:t(EH,{children:r})});return b?t(`div`,{className:z(`my-1.5 font-sans`,x),children:n(`div`,{className:kH,children:[c,i&&t(`p`,{className:z(`mt-1 text-xs leading-5 text-muted`,E),children:i})]})}):t(`div`,{className:z(`my-2 font-sans`,x),children:n(`div`,{className:z(`rounded-lg border border-border bg-background/60 shadow-none`,S),children:[t(`div`,{className:z(`px-3 py-2`,C),children:n(`div`,{className:`flex items-start gap-2.5`,children:[!_&&t(`div`,{className:z(`mt-1 flex-shrink-0 text-attention`,w),children:a}),t(`div`,{className:`min-w-0 flex-1`,children:n(`div`,{className:kH,children:[c,i&&t(`p`,{className:z(`mt-1 text-xs leading-5 text-muted`,E),children:i})]})})]})}),re.length>0&&t(`div`,{className:z(`flex flex-col gap-1.5 px-3 pb-3 pt-0`,D),children:d?n(e,{children:[re.map(e=>{let r=L.has(e.id);return n(`label`,{className:z(`flex cursor-pointer items-start gap-2.5 rounded-md border px-3 py-2 text-start transition-colors`,r?`border-info/60 bg-info/10`:`border-border bg-background/70 hover:bg-mixer-muted/15`,m&&`cursor-not-allowed opacity-50`,O),children:[t(`input`,{type:`checkbox`,checked:r,onChange:()=>ae(e.id),disabled:m,className:`mt-1 size-4 rounded border-border bg-background text-info focus:ring-info`}),n(`span`,{className:`min-w-0 flex-1`,children:[n(`span`,{className:`flex items-center gap-2 text-sm font-medium leading-5 text-foreground`,children:[e.icon,t(`span`,{className:`break-words`,children:e.label})]}),e.description&&t(`span`,{className:`mt-0.5 block break-words text-xs leading-5 text-muted`,children:e.description})]})]},e.id)}),t(`div`,{className:`pt-1`,children:n(o,{size:`sm`,onClick:oe,disabled:m||L.size===0,className:`inline-flex items-center gap-2`,children:[t(Ny,{className:`size-4`}),L.size>0?M(`agent.submitSelectionCount`,{count:L.size}):M(`agent.submitSelection`)]})})]}):re.map(e=>n(`button`,{type:`button`,onClick:()=>s?.(e.id),disabled:m,className:z(`flex w-full cursor-pointer items-start gap-2.5 rounded-md border border-border bg-background/70 px-3 py-2 text-start transition-colors`,`hover:bg-mixer-muted/15 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,m&&`cursor-not-allowed opacity-50`,O),children:[t(`span`,{className:`mt-1 size-4 flex-shrink-0 rounded-full border border-border`,"aria-hidden":`true`}),n(`span`,{className:`min-w-0 flex-1`,children:[n(`span`,{className:`flex items-center gap-2 text-sm font-medium leading-5 text-foreground`,children:[e.icon,t(`span`,{className:`break-words`,children:e.label})]}),e.description&&t(`span`,{className:`mt-0.5 block break-words text-xs leading-5 text-muted`,children:e.description})]})]},e.id))}),u&&t(`div`,{className:z(`px-3 pb-3 pt-0`,k),children:n(`div`,{className:`flex gap-2`,children:[t(`input`,{ref:R,type:`text`,value:F,onChange:e=>I(e.target.value),onKeyDown:ce,placeholder:N,disabled:m,className:z(`min-w-0 flex-1 rounded-md border border-border bg-background/70 px-3 py-2 text-sm text-foreground focus:border-transparent focus:ring-2 focus:ring-ring`,A)}),t(o,{size:`sm`,onClick:se,disabled:m||!F.trim(),className:j,children:m?`...`:P})]})})]})})}return t(`div`,{className:`my-4 font-sans ${x||``}`,children:n(`div`,{className:`${le} ${te.bg} rounded-e-lg shadow-sm ${S||``}`,children:[t(`div`,{className:`px-4 py-3 ${C||``}`,children:n(`div`,{className:`flex items-start gap-3`,children:[!_&&t(`div`,{className:`flex-shrink-0 mt-0.5 ${te.icon} ${w||``}`,children:h||t(ne,{className:`size-5`})}),t(`div`,{className:`min-w-0 flex-1`,children:n(`div`,{className:kH,children:[t(`div`,{className:`agent-ask-question prose prose-sm dark:prose-invert max-w-none text-foreground ${T||``}`,children:t(EH,{children:r})}),i&&t(`p`,{className:`mt-1 text-sm text-muted ${E||``}`,children:i})]})})]})}),re.length>0&&t(`div`,{className:`px-4 pb-3 pt-1 ${D||``}`,children:d?n(`div`,{className:`space-y-2`,children:[re.map(e=>n(`label`,{className:`flex items-start gap-3 px-4 py-3 rounded-lg cursor-pointer transition-colors
944
+ `)?null:r}function uH(e){let t=cH(e);if(t.length<2)return e;let n=new Set,r=new Set,i=Array(t.length-1);for(let n=0;n<t.length-1;n++)i[n]=lH(e,t[n],t[n+1]);let a=[];for(let e=0;e<t.length-1;e++){if(n.has(e))continue;let r=i[e];r!==null&&oH(r)&&(n.add(e),n.add(e+1),a.push([t[e],t[e+1]]))}let o=0;for(;o<t.length;){if(n.has(o)){o++;continue}let e=o+1;for(;e<t.length&&n.has(e);)e++;if(e>=t.length)break;if(e>o+1){r.add(t[o]),o++;continue}let a=i[o];if(a===null){o++;continue}sH(a)&&(r.add(t[o]),r.add(t[e])),n.add(o),n.add(e),o=e+1}for(let e=0;e<t.length;e++)n.has(e)||e+1<t.length&&n.has(e+1)&&r.add(t[e]);if(r.size===0&&a.length===0)return e;let s=[],c=0,l=Array.from(r).sort((e,t)=>e-t),u=0,d=0;for(;u<l.length||d<a.length;){let t=u<l.length?l[u]:1/0;if(t<(d<a.length?a[d][0]:1/0))t>c&&s.push(e.slice(c,t)),s.push(`\\$`),c=t+1,u++;else{let[t,n]=a[d];t>c&&s.push(e.slice(c,t));let r=e.slice(t,n+1);for(s.push(r.replace(XV,`\\text{\\textdollar}`)),c=n+1;u<l.length&&l[u]<=n;)u++;d++}}return c<e.length&&s.push(e.slice(c)),s.join(``)}function dH(e){let t=[],n=0;for(let r of e.matchAll(YV))t.push(uH(e.slice(n,r.index))),t.push(r[0]),n=r.index+r[0].length;return t.push(uH(e.slice(n))),t.join(``)}function fH(e){if(!e?.includes(`$`))return e;let t=[],n=0;for(let r of e.matchAll(JV))t.push(dH(e.slice(n,r.index))),t.push(r[0]),n=r.index+r[0].length;return t.push(dH(e.slice(n))),t.join(``)}const pH={note:`md-callout-info`,tip:`md-callout-info`,warning:`md-callout-attention`,important:`md-callout-attention`,caution:`md-callout-destructive`},mH={note:`Note`,tip:`Tip`,warning:`Warning`,important:`Important`,caution:`Caution`};function hH(){return(e,t)=>{mP(e,(e,n,r)=>{if(e.type===`textDirective`){let i=e.position?.start.offset,a=e.position?.end.offset;if(r&&n!==void 0&&i!==void 0&&a!==void 0){let o={type:`text`,value:t.toString().slice(i,a),position:e.position};r.children[n]=o}return dP}if(e.type!==`containerDirective`&&e.type!==`leafDirective`)return;let i=e;i.data||={};let a=i.data,o=i.attributes||{},s=i.name;if(s===`pagebreak`){a.hName=`hr`,a.hProperties={className:`md-pagebreak`};return}if(s===`columns`){a.hName=`div`,a.hProperties={className:`md-columns`};return}if(s===`column`){a.hName=`div`;let e={className:`md-column`};o.width&&(e.style=`flex-basis:${o.width};flex-grow:0;flex-shrink:0`),a.hProperties=e;return}if(s in pH){a.hName=`div`,a.hProperties={className:`md-callout ${pH[s]}`,"data-callout-type":s};let e=mH[s];if(e&&i.children){let t={type:`paragraph`,data:{hName:`p`,hProperties:{className:`md-callout-title`}},children:[{type:`text`,value:e}]};i.children.unshift(t)}return}a.hName=`div`,a.hProperties={className:`md-${s}`,...Object.fromEntries(Object.entries(o).filter(([e])=>e!==`class`))},o.class&&(a.hProperties.className+=` ${o.class}`)})}}const gH=/(?:^|[^\\])\$/,_H=[];let vH,yH;function bH(){return yH||=import(`rehype-katex`).then(({default:e})=>(vH=e,e)),yH}function xH(e){let t=ot.useMemo(()=>gH.test(e),[e]),[n,r]=ot.useState(()=>vH);return ot.useEffect(()=>{if(!t||n)return;let e=!1;return bH().then(t=>{e||r(()=>t)}).catch(e=>{console.error(`Failed to load KaTeX; math will render unstyled`,e)}),()=>{e=!0}},[t,n]),ot.useMemo(()=>n?[n]:_H,[n])}const SH=[`artifact:`,`image:`,`store:`,`document:`,`document://`,`collection:`,`interaction:`,`prompt:`,`agent:`,`workflow:`,`process:`,`run:`];function CH(e){return SH.some(t=>e.startsWith(t))?e:gF(e)}function wH(){return e=>{mP(e,`html`,(e,t,n)=>{let r=e,i=n;if(typeof r.value==`string`&&/<!--[\s\S]*?-->/.test(r.value)&&i?.children&&typeof t==`number`)return i.children.splice(t,1),[dP,t]})}}const TH=yV();function EH({children:e,components:n,remarkPlugins:r=[],removeComments:i=!0,artifactRunId:a,onArtifactOpen:o,className:s,codeClassName:c,inlineCodeClassName:l,linkClassName:u,imageClassName:d,onProposalSelect:f,onProposalSubmit:p,preserveSourcePositions:m=!1}){let h=UB(),g=ot.useMemo(()=>m?e:qV(WV(fH(e))),[e,m]),_=ot.useMemo(()=>{let e=[uB,fL,hH,pB,XF,RB,DB,...r];return i&&e.push(wH),e},[r,i]),v=xH(g),y=ot.useMemo(()=>({handlers:{...JF}}),[]),b=ot.useMemo(()=>{let e=n||{},r=e.code,i=e.a,s=e.img,f=({node:e,className:n,children:i,...a})=>{let o=/language-([\w-]+)/.exec(n||``),s=!o,u=o?o[1]:``;if(!s&&u){if(h){let e=h.getComponent(u);if(e){let n=String(i||``).trim();return t(e,{code:n,language:u})}}if(vV(u)){let e=String(i||``).trim();return t(_V,{code:e,language:u})}let e=TH[u];if(e){let n=String(i||``).trim();return t(e,{code:n,language:u})}}return typeof r==`function`?t(r,{node:e,className:n,...a,children:i}):t(`code`,{...a,className:s?`px-1.5 py-0.5 rounded ${l||``}`:` ${c||``}`,children:i})},p=e=>{let{node:n,href:r,children:s,...c}=e;return t(MV,{node:n,href:r,className:u,artifactRunId:a,onArtifactOpen:o,ExistingLink:typeof i==`function`?i:void 0,...c,children:s})},m=e=>{let{node:n,src:r,alt:i,title:o,...c}=e;return o?t(wV,{src:r,alt:i,caption:o,className:d,artifactRunId:a}):t(EV,{node:n,src:r,alt:i,className:d,artifactRunId:a,ExistingImg:typeof s==`function`?s:void 0,...c})};return{...e,code:f,a:p,img:m}},[n,a,o,h,c,l,u,d]),x=t(BB,{artifactRunId:a,onProposalSelect:f,onProposalSubmit:p,MarkdownRenderer:EH,children:t(fF,{remarkPlugins:_,rehypePlugins:v,remarkRehypeOptions:y,components:b,urlTransform:CH,children:g})});return s?t(`div`,{className:`md-content ${s}`,children:x}):t(`div`,{className:`md-content`,children:x})}Q();function DH(e){return Array.isArray(e)&&e.every(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let{id:t,label:n,description:r}=e;return typeof t==`string`&&typeof n==`string`&&(r==null||typeof r==`string`)})}const OH={default:{border:`border-s-attention`,bg:`bg-attention`,icon:`text-attention`},warning:{border:`border-s-destructive`,bg:`bg-destructive`,icon:`text-destructive`},info:{border:`border-s-info`,bg:`bg-info`,icon:`text-info`},success:{border:`border-s-success`,bg:`bg-success`,icon:`text-success`}},kH={default:Hh,warning:Ah,info:xv,success:Nh},AH=`max-h-80 overflow-y-auto overscroll-contain pe-2`;function jH({question:r,description:i,options:a,onSelect:s,onMultiSelect:c,onSubmit:l,allowFreeResponse:u=!1,multiSelect:d=!1,placeholder:f,submitLabel:p,isLoading:m=!1,icon:h,variant:g=`default`,hideIcon:_=!1,hideBorder:v=!1,compact:y=!1,answered:b=!1,className:x,cardClassName:S,headerClassName:C,iconClassName:w,questionClassName:T,descriptionClassName:E,optionsClassName:D,buttonClassName:O,inputContainerClassName:k,inputClassName:A,submitButtonClassName:j}){let{t:M}=K(),N=f??M(`agent.typeYourResponse`),P=p??M(`agent.send`),[F,I]=ot.useState(``),[L,ee]=ot.useState(new Set),R=ot.useRef(null),te=OH[g],ne=kH[g],re=DH(a),ie=re?a:[],ae=ot.useRef(!1);ot.useEffect(()=>{a===void 0||re||ae.current||(ae.current=!0,Hn.logger.warn(`AskUserWidget received invalid options; rendering without options`,{vertesia:{component:`AskUserWidget`,received_type:typeof a}}))},[a,re]);let oe=e=>{ee(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},se=()=>{L.size>0&&c&&(c(Array.from(L)),ee(new Set))},ce=()=>{F.trim()&&l&&(l(F.trim()),I(``))},le=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),ce())},ue=v?``:`border-s-4 ${te.border}`;if(y){let a=h||t(ne,{className:`size-4`}),c=t(`div`,{className:z(`agent-ask-question text-sm leading-6 text-foreground/85`,T),children:t(EH,{children:r})});return b?t(`div`,{className:z(`my-1.5 font-sans`,x),children:n(`div`,{className:AH,children:[c,i&&t(`p`,{className:z(`mt-1 text-xs leading-5 text-muted`,E),children:i})]})}):t(`div`,{className:z(`my-2 font-sans`,x),children:n(`div`,{className:z(`rounded-lg border border-border bg-background/60 shadow-none`,S),children:[t(`div`,{className:z(`px-3 py-2`,C),children:n(`div`,{className:`flex items-start gap-2.5`,children:[!_&&t(`div`,{className:z(`mt-1 flex-shrink-0 text-attention`,w),children:a}),t(`div`,{className:`min-w-0 flex-1`,children:n(`div`,{className:AH,children:[c,i&&t(`p`,{className:z(`mt-1 text-xs leading-5 text-muted`,E),children:i})]})})]})}),ie.length>0&&t(`div`,{className:z(`flex flex-col gap-1.5 px-3 pb-3 pt-0`,D),children:d?n(e,{children:[ie.map(e=>{let r=L.has(e.id);return n(`label`,{className:z(`flex cursor-pointer items-start gap-2.5 rounded-md border px-3 py-2 text-start transition-colors`,r?`border-info/60 bg-info/10`:`border-border bg-background/70 hover:bg-mixer-muted/15`,m&&`cursor-not-allowed opacity-50`,O),children:[t(`input`,{type:`checkbox`,checked:r,onChange:()=>oe(e.id),disabled:m,className:`mt-1 size-4 rounded border-border bg-background text-info focus:ring-info`}),n(`span`,{className:`min-w-0 flex-1`,children:[n(`span`,{className:`flex items-center gap-2 text-sm font-medium leading-5 text-foreground`,children:[e.icon,t(`span`,{className:`break-words`,children:e.label})]}),e.description&&t(`span`,{className:`mt-0.5 block break-words text-xs leading-5 text-muted`,children:e.description})]})]},e.id)}),t(`div`,{className:`pt-1`,children:n(o,{size:`sm`,onClick:se,disabled:m||L.size===0,className:`inline-flex items-center gap-2`,children:[t(Ny,{className:`size-4`}),L.size>0?M(`agent.submitSelectionCount`,{count:L.size}):M(`agent.submitSelection`)]})})]}):ie.map(e=>n(`button`,{type:`button`,onClick:()=>s?.(e.id),disabled:m,className:z(`flex w-full cursor-pointer items-start gap-2.5 rounded-md border border-border bg-background/70 px-3 py-2 text-start transition-colors`,`hover:bg-mixer-muted/15 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,m&&`cursor-not-allowed opacity-50`,O),children:[t(`span`,{className:`mt-1 size-4 flex-shrink-0 rounded-full border border-border`,"aria-hidden":`true`}),n(`span`,{className:`min-w-0 flex-1`,children:[n(`span`,{className:`flex items-center gap-2 text-sm font-medium leading-5 text-foreground`,children:[e.icon,t(`span`,{className:`break-words`,children:e.label})]}),e.description&&t(`span`,{className:`mt-0.5 block break-words text-xs leading-5 text-muted`,children:e.description})]})]},e.id))}),u&&t(`div`,{className:z(`px-3 pb-3 pt-0`,k),children:n(`div`,{className:`flex gap-2`,children:[t(`input`,{ref:R,type:`text`,value:F,onChange:e=>I(e.target.value),onKeyDown:le,placeholder:N,disabled:m,className:z(`min-w-0 flex-1 rounded-md border border-border bg-background/70 px-3 py-2 text-sm text-foreground focus:border-transparent focus:ring-2 focus:ring-ring`,A)}),t(o,{size:`sm`,onClick:ce,disabled:m||!F.trim(),className:j,children:m?`...`:P})]})})]})})}return t(`div`,{className:`my-4 font-sans ${x||``}`,children:n(`div`,{className:`${ue} ${te.bg} rounded-e-lg shadow-sm ${S||``}`,children:[t(`div`,{className:`px-4 py-3 ${C||``}`,children:n(`div`,{className:`flex items-start gap-3`,children:[!_&&t(`div`,{className:`flex-shrink-0 mt-0.5 ${te.icon} ${w||``}`,children:h||t(ne,{className:`size-5`})}),t(`div`,{className:`min-w-0 flex-1`,children:n(`div`,{className:AH,children:[t(`div`,{className:`agent-ask-question prose prose-sm dark:prose-invert max-w-none text-foreground ${T||``}`,children:t(EH,{children:r})}),i&&t(`p`,{className:`mt-1 text-sm text-muted ${E||``}`,children:i})]})})]})}),ie.length>0&&t(`div`,{className:`px-4 pb-3 pt-1 ${D||``}`,children:d?n(`div`,{className:`space-y-2`,children:[ie.map(e=>n(`label`,{className:`flex items-start gap-3 px-4 py-3 rounded-lg cursor-pointer transition-colors
945
945
  ${L.has(e.id)?`bg-info border border-info`:`bg-white dark:bg-muted border border-border hover:bg-muted`}
946
- ${m?`opacity-50 cursor-not-allowed`:``}`,children:[t(`input`,{type:`checkbox`,checked:L.has(e.id),onChange:()=>ae(e.id),disabled:m,className:`mt-0.5 w-4 h-4 rounded border-border text-info focus:ring-info dark:bg-muted`}),n(`div`,{className:`flex-1 overflow-hidden`,children:[n(`div`,{className:`flex items-center gap-2 text-sm font-medium text-foreground break-words`,children:[e.icon,t(`span`,{className:`break-words`,children:e.label})]}),e.description&&t(`div`,{className:`mt-1 text-sm text-muted break-words whitespace-pre-wrap`,children:e.description})]})]},e.id)),t(`div`,{className:`pt-2`,children:n(o,{size:`sm`,onClick:oe,disabled:m||L.size===0,className:`flex items-center gap-2`,children:[t(Ny,{className:`size-4`}),L.size>0?M(`agent.submitSelectionCount`,{count:L.size}):M(`agent.submitSelection`)]})})]}):t(`div`,{className:`flex flex-col gap-2 w-full`,children:re.map(e=>t(o,{variant:`unstyled`,onClick:()=>s?.(e.id),disabled:m,className:`w-full h-auto whitespace-normal text-start px-4 py-3 rounded-lg border border-border
946
+ ${m?`opacity-50 cursor-not-allowed`:``}`,children:[t(`input`,{type:`checkbox`,checked:L.has(e.id),onChange:()=>oe(e.id),disabled:m,className:`mt-0.5 w-4 h-4 rounded border-border text-info focus:ring-info dark:bg-muted`}),n(`div`,{className:`flex-1 overflow-hidden`,children:[n(`div`,{className:`flex items-center gap-2 text-sm font-medium text-foreground break-words`,children:[e.icon,t(`span`,{className:`break-words`,children:e.label})]}),e.description&&t(`div`,{className:`mt-1 text-sm text-muted break-words whitespace-pre-wrap`,children:e.description})]})]},e.id)),t(`div`,{className:`pt-2`,children:n(o,{size:`sm`,onClick:se,disabled:m||L.size===0,className:`flex items-center gap-2`,children:[t(Ny,{className:`size-4`}),L.size>0?M(`agent.submitSelectionCount`,{count:L.size}):M(`agent.submitSelection`)]})})]}):t(`div`,{className:`flex flex-col gap-2 w-full`,children:ie.map(e=>t(o,{variant:`unstyled`,onClick:()=>s?.(e.id),disabled:m,className:`w-full h-auto whitespace-normal text-start px-4 py-3 rounded-lg border border-border
947
947
  bg-white dark:bg-muted
948
948
  hover:bg-muted hover:border-border
949
949
  focus:outline-none focus:ring-2 focus:ring-info focus:ring-offset-1
950
950
  transition-colors
951
951
  ${m?`opacity-50 cursor-not-allowed`:`cursor-pointer`}
952
- ${O||``}`,children:n(`div`,{className:`flex items-start gap-3`,children:[e.icon&&t(`span`,{className:`flex-shrink-0 mt-0.5 text-muted`,children:e.icon}),n(`div`,{className:`flex-1 overflow-hidden`,children:[t(`div`,{className:`font-medium text-sm text-foreground break-words text-center`,children:e.label}),e.description&&t(`div`,{className:`mt-1 text-sm text-muted break-words whitespace-pre-wrap`,children:e.description})]})]})},e.id))})}),u&&t(`div`,{className:`px-4 pb-3 pt-1 ${k||``}`,children:n(`div`,{className:`flex gap-2`,children:[t(`input`,{ref:R,type:`text`,value:F,onChange:e=>I(e.target.value),onKeyDown:ce,placeholder:N,disabled:m,className:`flex-1 px-3 py-2 text-sm border border-border rounded-md bg-white dark:bg-muted focus:ring-2 focus:ring-info focus:border-transparent ${A||``}`}),t(o,{size:`sm`,onClick:se,disabled:m||!F.trim(),className:j,children:m?`...`:P})]})})]})})}function jH({question:e,description:n,onConfirm:r,onCancel:i,confirmLabel:a,cancelLabel:o,isLoading:s=!1,variant:c=`default`,className:l}){let{t:u}=K(),d=a??u(`agent.yes`),f=o??u(`agent.no`);return t(AH,{question:e,description:n,variant:c,isLoading:s,className:l,options:[{id:`confirm`,label:d,icon:t(Nh,{className:`size-4`})},{id:`cancel`,label:f,icon:t(Gh,{className:`size-4`})}],onSelect:e=>{e===`confirm`?r():i()}})}function MH(e){let t=e.replace(/^workstream[:_-]?/i,``).replace(/^sys:/i,``).replace(/[-_:]?[0-9a-f]{8}-[0-9a-f-]{12,}$/i,``).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/([A-Z]+)([A-Z][a-z])/g,`$1 $2`).replace(/[:_-]+/g,` `).trim();return t?t.split(/\s+/).map(e=>{let t=e.toLowerCase();return t===`qa`?`QA`:t===`ui`?`UI`:t===`api`?`API`:t===`url`?`URL`:t.charAt(0).toUpperCase()+t.slice(1)}).join(` `):e}function NH(e){return/[0-9a-f]{8}-[0-9a-f-]{12,}/i.test(e)}function PH(e,t){let n=t?MH(t):``,r=MH(e);if(!n)return r;if(NH(e))return n;let i=n.toLowerCase().replace(/\s+/g,``);return r.toLowerCase().replace(/\s+/g,``).startsWith(i)?n:r}function FH(e){return e.message?typeof e.message==`object`?JSON.stringify(e.message,null,2):String(e.message).trim():``}function IH(e){if(typeof e!=`string`)return!1;let t=e.trim().toLowerCase();return!!(t&&t!==`main`&&t!==`all`)}function LH(e){let t=e.trim();if(!t||!/^[{[]/.test(t))return!1;try{return JSON.parse(t),!0}catch{return!1}}function RH(e,t){return IH(t)&&LH(e)}function zH(e){return!RH(FH(e),e.workstream_id)||e.type!==J.ANSWER&&e.type!==J.COMPLETE?!1:e.details?.event_class===`user_content`||e.details?.streamed===!0}function BH(e){switch(e){case`running`:return`bg-info`;case`canceling`:return`bg-attention`;case`completed`:return`bg-success`;case`canceled`:case`failed`:case`timeout`:return`bg-destructive`}}function VH(e){let t=e.details,n=t?.status;if(n===`running`||n===`canceling`||n===`completed`||n===`canceled`||n===`failed`||n===`timeout`)return n;if(t?.workstream_event===`completed`)return`completed`}function HH(e){let t=e.details;if(t?.workstream_event!==`launched`)return null;let n=typeof t.workstream_id==`string`?t.workstream_id:typeof e.workstream_id==`string`?e.workstream_id:``;return!n||n===`main`||n===`all`?null:{workstreamId:n,launchId:typeof t.launch_id==`string`?t.launch_id:void 0,kind:typeof t.kind==`string`?t.kind:void 0,interaction:typeof t.interaction==`string`?t.interaction:void 0,childWorkflowId:typeof t.child_workflow_id==`string`?t.child_workflow_id:void 0,childWorkflowRunId:typeof t.child_workflow_run_id==`string`?t.child_workflow_run_id:void 0}}function UH(e){let t=e.details;if(t?.event_class!==`activity`||t.workstream_event!==void 0||e.type===J.ERROR)return null;let n=typeof t.child_workflow_id==`string`?t.child_workflow_id:void 0,r=typeof t.child_workflow_run_id==`string`?t.child_workflow_run_id:void 0;if(!n&&!r)return null;let i=typeof t.workstream_id==`string`&&t.workstream_id.trim()?t.workstream_id:typeof e.workstream_id==`string`?e.workstream_id:``;return IH(i)?{workstreamId:i,launchId:typeof t.launch_id==`string`?t.launch_id:void 0,kind:typeof t.kind==`string`?t.kind:void 0,interaction:typeof t.interaction==`string`?t.interaction:void 0,childWorkflowId:n,childWorkflowRunId:r}:null}function WH(e){let t=e.indexOf(`?`);return t===-1?null:new URLSearchParams(e.slice(t+1)).get(`agentChatDebug`)}function GH(){if(typeof window>`u`)return!1;let e=new URLSearchParams(window.location.search).get(`agentChatDebug`),t=WH(window.location.hash),n=e??t;if(n!==null)return n===`1`||n===`true`;try{let e=window.localStorage.getItem(`agentChatDebug`);return e===`1`||e===`true`}catch{return!1}}function KH(e,t){GH()&&console.debug(`[agent-chat] ${e}`,t??{})}function qH(e,t){let n=typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime(),r=e.findIndex(e=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())>n);r===-1?e.push(t):e.splice(r,0,t)}const JH=[J.COMPLETE,J.IDLE,J.REQUEST_INPUT,J.TERMINATED];function YH(e){return e.type===J.UPDATE&&e.details?.event_class===`artifact_updated`}function XH(e){if(!e.length)return!0;let t=e=>e.details?._optimistic&&e.details?._deliveryStatus===`failed`&&JH.includes(e.type),n=e.filter(e=>!t(e)&&!YH(e)),r=n.filter(e=>$H(e)===`main`);if(r.length===0){let e=n[n.length-1];return!e||!JH.includes(e.type)}let i=r[r.length-1];return!JH.includes(i.type)}function ZH(e){if(e.type!==J.IDLE)return!1;let t=e.details?.status_reason,n=e.details?.display_role;return t===`user_stopped`||n===`user_stopped`||String(e.message??``).trim().toLowerCase().startsWith(`stopped.`)}function QH(e){return typeof e==`number`?e:new Date(e).getTime()}function $H(e){return e.workstream_id?e.workstream_id:`main`}function eU(e){let t=e.details;return!t||typeof t!=`object`||Array.isArray(t)?{}:t}function tU(e){if($H(e)===`main`||HH(e)||UH(e))return!0;let t=eU(e),n=typeof t.child_workflow_id==`string`||typeof t.child_workflow_run_id==`string`,r=typeof t.tool==`string`||typeof t.tool_run_id==`string`;return t.event_class===`activity`&&(e.type===J.ERROR||e.type===J.WARNING)&&!n&&!r}function nU(e,t){return t===`all`?e.filter(tU):e.filter(e=>(HH(e)??UH(e))?.workstreamId!==t&&$H(e)===t)}async function rU(e,t){return e.agents.getArtifactUrl(t,`conversation.json`).then(e=>e.url)}function iU(e,t){if(!t)return!0;let n=e.workstreamId||`main`;return t===`all`?n===`main`:t===n}function aU(e){if(typeof e==`string`)return e.replace(/\r\n/g,`
953
- `).trim()||void 0}function oU(e){return aU(e.message)}function sU(e,t){let n=aU(e.text);if(!n)return!1;let r=e.workstreamId||`main`;return t.some(t=>{if(QH(t.timestamp)<e.startTimestamp||$H(t)!==r)return!1;let i=typeof t.details?.streaming_id==`string`?t.details.streaming_id:void 0;return e.streamingId&&i?i===e.streamingId?t.details?.display_role===`thinking`?oU(t)===n:!(lU(t)||t.details?.tool_status):!1:e.activityId&&t.details?.activity_id===e.activityId?t.details?.display_role===`thinking`?oU(t)===n:!(lU(t)||t.details?.tool_status):t.type!==J.THOUGHT&&t.type!==J.ANSWER&&t.type!==J.COMPLETE&&t.type!==J.IDLE?!1:oU(t)===n})}function cU(e,t){if($H(e)!==$H(t))return!1;let n=oU(e),r=oU(t);if(!n||n!==r)return!1;let i=QH(e.timestamp);return QH(t.timestamp)-i>1e4?!1:!!(e.type===J.ANSWER&&(t.type===J.COMPLETE||t.type===J.IDLE)||e.type===J.THOUGHT&&(t.type===J.ANSWER||t.type===J.COMPLETE||t.type===J.IDLE)&&(e.details?.streamed||t.details?.streamed)||e.type===t.type&&(e.details?.streamed||t.details?.streamed)&&(t.type===J.THOUGHT||t.type===J.ANSWER||t.type===J.COMPLETE||t.type===J.IDLE))}function lU(e){return e.type===J.THOUGHT&&!!e.details?.tool}function uU(e){let t=e.details;return e.type===J.THOUGHT&&(t?.display_role===`tool_preamble`||t?.tool===`think`)}function dU(e){if(uU(e))return!1;if(lU(e))return!0;if(e.type!==J.THOUGHT)return!1;let t=e.details;return!!(Array.isArray(t?.tools)&&t.tools.length>0)}function fU(e){return e.details?.tool_run_id}function pU(e){return e.details?.tool_iteration}function mU(e){return e.details?.tool_status}function hU(e){let t=e.details?.activity_group_id;if(typeof t==`string`&&t.trim()!==``)return t}function gU(e,t,n){let r=new Map,i=new Map,a=new Map,o=[];for(let t of e){let e=hU(t);if(t.type===J.REQUEST_INPUT||t.type===J.BATCH_PROGRESS)o.push(t);else if(uU(t))o.push(t);else if(e)r.has(e)||r.set(e,{messages:[],firstTimestamp:QH(t.timestamp)}),r.get(e)?.messages.push(t);else if(dU(t)){let e=pU(t),n=fU(t);e===void 0?n?(a.has(n)||a.set(n,{messages:[],firstTimestamp:QH(t.timestamp)}),a.get(n)?.messages.push(t)):o.push(t):(i.has(e)||i.set(e,{messages:[],firstTimestamp:QH(t.timestamp)}),i.get(e)?.messages.push(t))}else o.push(t)}let s=[];r.forEach((e,t)=>{s.push({kind:`activity_group`,activityGroupId:t,messages:e.messages,timestamp:e.firstTimestamp})}),i.forEach((e,t)=>{s.push({kind:`iteration_group`,iteration:t,messages:e.messages,timestamp:e.firstTimestamp})}),a.forEach((e,t)=>{s.push({kind:`tool_run`,toolRunId:t,messages:e.messages,timestamp:e.firstTimestamp})});for(let e of o)s.push({kind:`message`,message:e,timestamp:QH(e.timestamp)});t.forEach((t,r)=>{t.text&&(sU(t,e)||iU(t,n)&&s.push({kind:`streaming`,streamingId:r,data:t,timestamp:t.startTimestamp}))}),s.sort((e,t)=>{let n=e.kind===`streaming`&&!e.data.isComplete,r=t.kind===`streaming`&&!t.data.isComplete;return n&&!r?1:r&&!n?-1:e.timestamp-t.timestamp});let c=[],l=[],u=()=>{l.length>0&&(l.length===1&&!uU(l[0])?c.push({type:`single`,message:l[0]}):c.push({type:`tool_group`,messages:l,firstTimestamp:QH(l[0].timestamp)}),l=[])};for(let e of s)if(e.kind===`streaming`)u(),c.push({type:`streaming`,streamingId:e.streamingId,text:e.data.text,workstreamId:e.data.workstreamId,startTimestamp:e.data.startTimestamp,isComplete:e.data.isComplete});else if(e.kind===`activity_group`){u();let t=[...e.messages].sort((e,t)=>QH(e.timestamp)-QH(t.timestamp)),n=t.reduce((e,t)=>mU(t)||e,void 0);c.push({type:`tool_group`,messages:t,firstTimestamp:e.timestamp,toolRunId:e.activityGroupId,toolStatus:n})}else if(e.kind===`iteration_group`){u();let t=[...e.messages].sort((e,t)=>QH(e.timestamp)-QH(t.timestamp)),n=t.reduce((e,t)=>mU(t)||e,void 0);c.push({type:`tool_group`,messages:t,firstTimestamp:e.timestamp,toolStatus:n})}else if(e.kind===`tool_run`){u();let t=[...e.messages].sort((e,t)=>QH(e.timestamp)-QH(t.timestamp)),n=t.reduce((e,t)=>mU(t)||e,void 0);c.push({type:`tool_group`,messages:t,firstTimestamp:e.timestamp,toolRunId:e.toolRunId,toolStatus:n})}else dU(e.message)?l.push(e.message):(u(),c.push({type:`single`,message:e.message}));return u(),c}function _U(e,t){return t??e}function vU(e){let t=[],n=null,r=()=>{n&&=(t.push({type:`tool_group`,messages:n.messages,firstTimestamp:n.firstTimestamp,toolRunId:n.toolRunId,toolStatus:n.toolStatus,preambleText:n.preambleText,preambleMessage:n.preambleMessage}),null)};for(let i of e)i.type===`tool_group`?n?(n.messages=[...n.messages,...i.messages],n.toolStatus=_U(n.toolStatus,i.toolStatus),!n.toolRunId&&i.toolRunId&&(n.toolRunId=i.toolRunId),!n.preambleMessage&&i.preambleMessage&&(n.preambleMessage=i.preambleMessage,n.preambleText=i.preambleText)):n={messages:[...i.messages],firstTimestamp:i.firstTimestamp,toolRunId:i.toolRunId,toolStatus:i.toolStatus,preambleText:i.preambleText,preambleMessage:i.preambleMessage}:(r(),t.push(i));return r(),t}function yU(e){return e.message?typeof e.message==`object`?JSON.stringify(e.message,null,2):String(e.message).trim():``}function bU(e){let t=xU(e.details?.tool_approval);if(!t)return yU(e);let n=SU(t.tool_title)??SU(t.tool_name),r=wU(SU(t.target));if(n&&r)return`Approve ${n}: ${r}?`;let i=SU(t.action_summary);return i?`Approve ${CU(i)}?`:yU(e)}function xU(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:void 0}function SU(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function CU(e){return e.replace(/:\s*name(?::|\s+)/i,`: `)}function wU(e){if(!e)return;let t=e.indexOf(`:`);if(t<0)return e;let n=e.slice(0,t),r=e.slice(t+1).trim();if(!r)return e;switch(n){case`document_id`:return`document ${r}`;case`object_id`:return`object ${r}`;case`collection_id`:return`collection ${r}`;case`process_id`:return`process ${r}`;case`process_definition_id`:return`process definition ${r}`;case`interaction_id`:return`interaction ${r}`;case`prompt_id`:return`prompt ${r}`;case`dashboard_id`:return`dashboard ${r}`;case`database_id`:return`database ${r}`;case`table_id`:return`table ${r}`;default:return r}}function TU(e){let t=e.details;return e.type===J.REQUEST_INPUT&&!!t?.ux}function EU(e){let t=e.details;return[t?.request_id,t?.requestId,t?.activity_id,t?.activityId,t?.tool_run_id,t?.toolRunId,e.timestamp,yU(e)].filter(e=>typeof e==`string`||typeof e==`number`).map(String).join(`|`)}function DU(e){let t=e.details,n=t?.request_id??t?.tool_use_id;return typeof n==`string`&&n?n:void 0}function OU(e){return DU(e)??EU(e)}function kU(e,t){return`vertesia:answered-request-input:${e}:${t}`}function AU(e,t){if(!(typeof window>`u`))try{window.sessionStorage.setItem(kU(e,t),`1`)}catch{}}function jU(e,t){if(!(typeof window>`u`))try{window.sessionStorage.removeItem(kU(e,t))}catch{}}function MU(e,t){if(t.type!==J.REQUEST_INPUT)return!1;let n=DU(t);if(!n||typeof window>`u`)return!1;try{return window.sessionStorage.getItem(kU(e,n))===`1`}catch{return!1}}function NU(e){if(e.type!==J.QUESTION)return;let t=xU(e.details),n=xU(t?.metadata),r=(xU(t?.request_input_response)??xU(n?.request_input_response))?.request_id;return typeof r==`string`&&r?r:void 0}function PU(e){let t=e.details;return[t?.ack,t?._messageId,t?._deliveryStatus,e.timestamp,$H(e),yU(e)].filter(e=>typeof e==`string`||typeof e==`number`).map(String).join(`|`)}function FU(e){let t=new Set,n=new Map;return e.forEach((e,t)=>{let r=NU(e);r&&n.set(r,t)}),e.forEach((r,i)=>{if(r.type!==J.REQUEST_INPUT)return;let a=DU(r),o=a?n.get(a):void 0;if(o!==void 0&&o>i){t.add(EU(r));return}let s=$H(r);for(let n=i+1;n<e.length;n+=1){let i=e[n];if($H(i)===s){if(i.type===J.REQUEST_INPUT)break;if(i.type===J.QUESTION){NU(i)||t.add(EU(r));break}}}}),t}function IU(e,t){let n=DU(e);return n?{...t,request_input_response:{request_id:n}}:t}function LU(e,t,n,r){if(!e)return;let i=IU(t,r);i?e(n,i):e(n)}function RU(e){let t=xU(e?.request_input_response)?.request_id;return typeof t==`string`&&t?t:void 0}const zU=`request:`;function BU(e){let t=new Set;for(let n of e){let e=xU(n.details),r=xU(e?.approval_request)?.approval_key,i=e?.approval_decision;if(i===`auto_approved`){let n=e?.request_id;typeof n==`string`&&n&&t.add(`${zU}${n}`);continue}typeof r==`string`&&(i===`denied`||i===`denied_with_feedback`||i===`timeout`||i===`reviewer_denied`||i===`cancelled_after_denial`)&&t.add(r)}return t}function VU(e){let t=xU(xU(e.details)?.tool_approval)?.approval_key;return typeof t==`string`?t:void 0}function HU(e){return e.type===J.REQUEST_INPUT&&VU(e)!==void 0}const UU=new Set([`allow_once`,`allow_for_run`,`deny`]);function WU(e,t){let n=VU(e);if(!(!n||!UU.has(t)))return{tool_approval_response:{decision:t,approval_key:n}}}function GU(e){if(e.type!==J.QUESTION)return!1;let t=yU(e).trim().toLowerCase();return t===`allow_once`||t===`allow_for_run`||t===`deny`}function KU(e){if(e.type!==J.QUESTION)return!1;let t=xU(e.details),n=xU(t?.metadata),r=(xU(t?.tool_approval_response)??xU(n?.tool_approval_response))?.decision;return r===`deny_with_feedback`||typeof r==`string`&&UU.has(r)}function qU(e){return GU(e)||KU(e)}function JU(e,t){if(e.type!==J.REQUEST_INPUT)return!1;let n=DU(e);if(n&&t.has(`${zU}${n}`))return!0;let r=VU(e);return r?t.has(r):!1}function YU(e){let t=new Set;return e.forEach((n,r)=>{if(!HU(n))return;let i=$H(n);for(let a=r+1;a<e.length;a+=1){let r=e[a];if($H(r)===i){if(r.type===J.REQUEST_INPUT)break;if(r.type===J.QUESTION){qU(r)&&t.add(EU(n));break}}}}),t}function XU(e,t,n){return HU(e)&&(t.has(EU(e))||JU(e,n))}function ZU(e,t){let n=new Set;return e.forEach((r,i)=>{if(!HU(r)||t&&!JU(r,t))return;let a=$H(r);for(let t=i+1;t<e.length;t+=1){let r=e[t];if($H(r)===a){if(r.type===J.REQUEST_INPUT)break;if(r.type===J.QUESTION){GU(r)&&n.add(PU(r));break}}}}),n}function QU(e,t){return e.type===J.QUESTION&&t.has(PU(e))}function $U(e,t){return e.type===J.REQUEST_INPUT&&t.has(EU(e))}function eW(e,t=`main`,n){let r=FU(e),i=BU(e);for(let a=e.length-1;a>=0;--a){let o=e[a];if(TU(o)&&$H(o)===t&&!n?.has(OU(o))&&!$U(o,r)&&!JU(o,i))return o}}Q();function tW({mcpConnect:e,onMcpConnected:r,onDecline:i,disabled:a}){let{client:s}=q(),{t:c}=K();return n(`div`,{className:`flex shrink-0 items-center justify-end gap-2`,children:[t(mO,{appId:e.app_install_id,collectionId:e.collection_id,collectionName:e.name,variant:`default`,onAuthChange:()=>{s.remoteMcpConnections.getCollectionStatus(e.app_install_id,e.collection_id).then(t=>{t.authenticated&&r?.(e)}).catch(()=>{})},readOnly:a}),n(o,{variant:`ghost`,size:`sm`,onClick:i,disabled:a,children:[t(Gb,{className:`size-4`}),t(`span`,{children:c(`mcpOAuth.decline`)})]})]})}function nW({message:e,onSendMessage:r,onMcpConnected:i,isLoading:a=!1,disabled:o=!1,className:s}){let{t:c}=K();if(!e)return null;let l=e.details.ux,u=l.options??[],d=l.mcp_connect,f=l.free_response,p=o||a||!r,m=bU(e),h=(t,n)=>{p||LU(r,e,t,n)},g=z(`flex-shrink-0 border-t border-border/70 bg-background/95 backdrop-blur`,`fixed bottom-0 end-0 start-0 z-20 lg:sticky lg:start-auto lg:end-auto`,`pb-safe-area`,s);return d?t(`div`,{className:g,"data-agent-request-input-overlay":!0,children:n(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-3 px-3 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[t(`div`,{className:`min-w-0 text-sm leading-6 text-foreground/85`,children:m}),t(tW,{mcpConnect:d,onMcpConnected:t=>i?.(t,IU(e)),onDecline:()=>h(c(`agent.mcpDeclinedMessage`,{name:d.name})),disabled:p})]})}):t(`div`,{className:g,"data-agent-request-input-overlay":!0,children:t(`div`,{className:`mx-auto w-full max-w-3xl px-3 py-3`,children:t(AH,{question:m,options:u,variant:l.variant,multiSelect:l.multiSelect,allowFreeResponse:u.length===0||!!f,placeholder:f?.placeholder,submitLabel:f?.submit_label,onSelect:t=>h(t,WU(e,t)),onMultiSelect:e=>h(e.join(`, `)),onSubmit:e=>h(e,f?.metadata),hideBorder:!0,compact:!0,isLoading:p,className:`my-0`,cardClassName:`bg-background/80 shadow-lg shadow-black/5 dark:shadow-none`})})})}function rW({className:e,inline:r=!1,color:i=`blue`}){let a={blue:`from-blue-400 to-indigo-500 dark:from-blue-500 dark:to-indigo-400`,purple:`from-purple-400 to-violet-500 dark:from-purple-500 dark:to-violet-400`,teal:`from-teal-400 to-emerald-500 dark:from-teal-500 dark:to-emerald-400`,green:`from-green-400 to-emerald-500 dark:from-green-500 dark:to-emerald-400`,amber:`from-amber-400 to-orange-500 dark:from-amber-500 dark:to-orange-400`}[i];return n(`div`,{className:z(`flex items-center gap-1.5`,r?`inline-flex`:``,e),children:[t(`div`,{className:`w-2 h-2 bg-gradient-to-r ${a} rounded-full animate-[bounce_1.2s_ease-in-out_infinite]`}),t(`div`,{className:`w-2 h-2 bg-gradient-to-r ${a} rounded-full animate-[bounce_1.2s_ease-in-out_0.2s_infinite]`}),t(`div`,{className:`w-2 h-2 bg-gradient-to-r ${a} rounded-full animate-[bounce_1.2s_ease-in-out_0.4s_infinite]`})]})}function iW({className:e,size:r=`md`,color:i=`blue`}){let a={sm:`w-3 h-3`,md:`w-5 h-5`,lg:`w-7 h-7`},o={blue:`bg-blue-500 dark:bg-blue-400`,purple:`bg-purple-500 dark:bg-purple-400`,teal:`bg-teal-500 dark:bg-teal-400`,green:`bg-green-500 dark:bg-green-400`,amber:`bg-amber-500 dark:bg-amber-400`};return n(`span`,{className:z(`relative flex`,e),children:[t(`span`,{className:z(`animate-ping absolute inline-flex h-full w-full rounded-full opacity-60`,o[i])}),t(`span`,{className:z(`animate-pulse absolute inline-flex h-[80%] w-[80%] rounded-full opacity-80`,o[i]),style:{left:`10%`,top:`10%`,animationDuration:`2s`}}),t(`span`,{className:z(`relative inline-flex rounded-full`,o[i],a[r])})]})}function aW({className:e,color:n=`blue`}){let[r,i]=G(`.`);return H(()=>{let e=setInterval(()=>{i(e=>e===`.`?`..`:e===`..`?`...`:`.`)},500);return()=>clearInterval(e)},[]),t(`span`,{className:z({blue:`text-blue-600 dark:text-blue-400`,purple:`text-purple-600 dark:text-purple-400`,teal:`text-teal-600 dark:text-teal-400`,green:`text-green-600 dark:text-green-400`,amber:`text-amber-600 dark:text-amber-400`}[n],`font-bold`,e),children:r})}function oW({message:e,className:r,color:i=`blue`}){let a={blue:{dot:`bg-blue-500 dark:bg-blue-400`,text:`text-blue-700 dark:text-blue-300`},purple:{dot:`bg-purple-500 dark:bg-purple-400`,text:`text-purple-700 dark:text-purple-300`},teal:{dot:`bg-teal-500 dark:bg-teal-400`,text:`text-teal-700 dark:text-teal-300`},green:{dot:`bg-green-500 dark:bg-green-400`,text:`text-green-700 dark:text-green-300`},amber:{dot:`bg-amber-500 dark:bg-amber-400`,text:`text-amber-700 dark:text-amber-300`}};return n(`div`,{className:z(`flex items-center gap-2 py-1`,r),children:[n(`div`,{className:`flex gap-1`,children:[t(`div`,{className:`w-1.5 h-1.5 ${a[i].dot} rounded-full animate-bounce`}),t(`div`,{className:`w-1.5 h-1.5 ${a[i].dot} rounded-full animate-bounce`,style:{animationDelay:`0.2s`}}),t(`div`,{className:`w-1.5 h-1.5 ${a[i].dot} rounded-full animate-bounce`,style:{animationDelay:`0.4s`}})]}),t(`div`,{className:`${a[i].text} font-medium text-xs`,children:e})]})}function sW({className:e,color:r=`blue`,width:i=`md`,message:a}){let[o,s]=G(15),[c,l]=G(`increasing`),[u,d]=G(.4),f=W(null),p=W(!0);return H(()=>{let e=f.current;if(!e)return;let t=new IntersectionObserver(([e])=>{p.current=e.isIntersecting},{threshold:0});return t.observe(e),()=>t.disconnect()},[]),H(()=>{let e,t=Date.now(),n=()=>{if(!p.current){e=requestAnimationFrame(n);return}let r=Date.now(),i=r-t;t=r,s(e=>{let t=i/16*u,n=c===`increasing`?e+t:e-t;return n>=85?(l(`decreasing`),d(.3+Math.random()*.2),85):n<=15?(l(`increasing`),d(.3+Math.random()*.2),15):(Math.random()>.99&&d(e=>Math.max(.2,Math.min(.5,e+(Math.random()*.1-.05)))),n)}),e=requestAnimationFrame(n)};return e=requestAnimationFrame(n),()=>{cancelAnimationFrame(e)}},[c,u]),n(`div`,{ref:f,className:z(`flex flex-col gap-1`,e),children:[a&&t(`div`,{className:`text-xs font-medium ${{blue:`text-blue-700 dark:text-blue-300`,purple:`text-purple-700 dark:text-purple-300`,teal:`text-teal-700 dark:text-teal-300`,green:`text-green-700 dark:text-green-300`,amber:`text-amber-700 dark:text-amber-300`}[r]} mb-1`,children:a}),t(`div`,{className:z(`h-1.5 rounded-full overflow-hidden shadow-inner`,{blue:`bg-blue-200 dark:bg-blue-900/30`,purple:`bg-purple-200 dark:bg-purple-900/30`,teal:`bg-teal-200 dark:bg-teal-900/30`,green:`bg-green-200 dark:bg-green-900/30`,amber:`bg-amber-200 dark:bg-amber-900/30`}[r],{sm:`w-24`,md:`w-32`,lg:`w-48`,xl:`w-64`,full:`w-full`}[i]),children:t(`div`,{className:z(`h-full rounded-full`,{blue:`bg-gradient-to-r from-blue-400 to-blue-500 dark:from-blue-500 dark:to-blue-400`,purple:`bg-gradient-to-r from-purple-400 to-purple-500 dark:from-purple-500 dark:to-purple-400`,teal:`bg-gradient-to-r from-teal-400 to-teal-500 dark:from-teal-500 dark:to-teal-400`,green:`bg-gradient-to-r from-green-400 to-green-500 dark:from-green-500 dark:to-green-400`,amber:`bg-gradient-to-r from-amber-400 to-amber-500 dark:from-amber-500 dark:to-amber-400`}[r]),style:{width:`${o}%`,transition:`width 150ms cubic-bezier(0.4, 0.0, 0.2, 1)`}})})]})}function cW({className:e,color:n=`blue`,size:r=`md`}){let[i,a]=G(Array(7).fill(50)),o=W(null),s=W(!0);H(()=>{let e=o.current;if(!e)return;let t=new IntersectionObserver(([e])=>{s.current=e.isIntersecting},{threshold:0});return t.observe(e),()=>t.disconnect()},[]);let c={sm:{width:`w-16`,height:`h-4`,barWidth:`w-0.5`,gap:`gap-[2px]`},md:{width:`w-20`,height:`h-5`,barWidth:`w-1`,gap:`gap-[3px]`},lg:{width:`w-24`,height:`h-6`,barWidth:`w-1.5`,gap:`gap-1`}},l={blue:`bg-gradient-to-b from-blue-400 to-blue-500 dark:from-blue-400 dark:to-blue-500`,purple:`bg-gradient-to-b from-purple-400 to-purple-500 dark:from-purple-400 dark:to-purple-500`,teal:`bg-gradient-to-b from-teal-400 to-teal-500 dark:from-teal-400 dark:to-teal-500`,green:`bg-gradient-to-b from-green-400 to-green-500 dark:from-green-400 dark:to-green-500`,amber:`bg-gradient-to-b from-amber-400 to-amber-500 dark:from-amber-400 dark:to-amber-500`};return H(()=>{let e,t=[1.2,1,1.5,.8,1.3,.9,1.1],n=[0,.5,1,1.5,2,2.5,3],r=0,i=()=>{if(!s.current){e=requestAnimationFrame(i);return}r+=.02;let o=Array(7).fill(0).map((e,i)=>10+(Math.sin(r*t[i]+n[i])+1)*40);a(o),e=requestAnimationFrame(i)};return e=requestAnimationFrame(i),()=>{cancelAnimationFrame(e)}},[]),t(`div`,{ref:o,className:z(`flex items-end justify-center`,c[r].width,c[r].height,c[r].gap,e),children:i.map((e,i)=>t(`div`,{className:z(c[r].barWidth,`rounded-full transform-gpu`,l[n]),style:{height:`${e}%`,transition:`height 100ms cubic-bezier(0.4, 0.0, 0.2, 1)`,opacity:.9}},`bar-${i}`))})}Q();const lW=[`agent-markdown vprose prose max-w-none break-words text-sm leading-6 text-foreground/80`,`prose-p:my-2 prose-p:leading-6 prose-li:my-0.5 prose-pre:my-3 prose-headings:tracking-normal`,`prose-headings:text-foreground prose-strong:text-foreground prose-code:text-foreground`,`prose-a:text-foreground prose-a:underline prose-a:decoration-muted prose-a:underline-offset-4`,`[&_p]:text-foreground/80 [&_li]:text-foreground/80 [&_li::marker]:text-muted`].join(` `);function uW({children:e,artifactRunId:r,components:i,disableCollapse:a,className:o,"data-testid":s}){let{t:c}=K(),l=e.trim(),[u,d]=G(!1),f=l?l.split(/\r?\n/).length:0,p=l.length>520||f>6,m=p&&!a&&!u;return n(`div`,{className:z(`min-w-0`,o),children:[t(`div`,{"data-testid":s,className:z(lW,m&&`[display:-webkit-box] overflow-hidden [-webkit-box-orient:vertical] [-webkit-line-clamp:6]`),style:{overflowWrap:`anywhere`},children:t(Nt,{artifactRunId:r,components:i,children:e})}),p&&!a?t(`div`,{className:`mt-1.5 flex justify-end`,children:n(`button`,{type:`button`,"aria-expanded":u,className:z(`inline-flex items-center gap-1 text-sm font-medium text-muted transition-colors`,`[text-decoration:none] hover:text-foreground hover:[text-decoration:none]`,`focus-visible:text-foreground focus-visible:[text-decoration:none]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`),onClick:()=>d(e=>!e),children:[c(u?`agent.showLess`:`agent.showMore`),t(rh,{className:z(`size-4 transition-transform`,u&&`rotate-180`),"aria-hidden":`true`})]})}):null]})}Q();const dW=new Set([`heading`,`paragraph`,`list`,`list_item`,`blockquote`,`code_block`,`table`,`separator`]);function fW(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:void 0}function pW(e,t){let n=e?.[t];return typeof n==`string`&&n.length>0?n:void 0}function mW(e){let t=fW(e),n=pW(t,`kind`);if(n===`store_document`){let e=pW(t,`document_id`);if(!e)return;let r=pW(t,`name`);return{kind:n,document_id:e,...r?{name:r}:{}}}if(n===`agent_artifact`){let e=pW(t,`run_id`),r=pW(t,`path`);return e&&r?{kind:n,run_id:e,path:r}:void 0}}function hW(e){let t=fW(e),n=fW(t?.anchor),r=pW(t,`operation_id`),i=pW(t,`action`),a=pW(n,`block_id`),o=pW(n,`block_type`),s=pW(n,`exact_text`),c=mW(t?.resource);if(!r||i!==`comment`&&i!==`edit`||!a||!o||!dW.has(o)||!s||!c)return;let l=pW(t,`base_version`),u=pW(t,`comment`),d=fW(t?.user_change),f=pW(d,`before`),p=pW(d,`after`);if(i===`comment`&&!u||i===`edit`&&(!f||!p))return;let m=pW(t,`updated_document_id`);return{operation_id:r,resource:c,...l?{base_version:l}:{},action:i,anchor:{block_id:a,block_type:o,exact_text:s},...u?{comment:u}:{},...f&&p?{user_change:{before:f,after:p}}:{},...t?.applied===!0?{applied:!0}:{},...m?{updated_document_id:m}:{}}}function gW(e){return e.length>12?`${e.slice(0,4)}…${e.slice(-4)}`:e}function _W(e){return e.kind===`store_document`?e.name||gW(e.document_id):e.path}const vW=[`[&_h1]:text-base [&_h2]:text-base [&_h3]:text-base [&_h4]:text-base [&_h5]:text-base [&_h6]:text-base`,`[&_h1]:leading-snug [&_h2]:leading-snug [&_h3]:leading-snug`,`[&_:first-child]:mt-0 [&_:last-child]:mb-0`].join(` `);function yW({children:e,className:n}){return t(`pre`,{className:z(`m-0 max-h-48 overflow-auto whitespace-pre-wrap font-mono text-xs leading-5 text-foreground/80`,n),children:e})}function bW({before:e,after:n}){let r=U(()=>Ht(e,n),[e,n]);return t(yW,{children:r.map((e,n)=>e.type===`removed`?t(`del`,{className:`rounded-xs bg-mixer-destructive/15 text-destructive line-through decoration-destructive/50`,children:e.text},n):e.type===`added`?t(`ins`,{className:`rounded-xs bg-mixer-success/15 text-success no-underline`,children:e.text},n):t(`span`,{children:e.text},n))})}function xW({action:r}){let{t:i}=K(),a=r.action===`comment`,o=r.applied===!0,s=r.anchor.block_type.replaceAll(`_`,` `),c=a?vv:Zv,l=r.resource.kind===`agent_artifact`?r.resource.run_id:void 0;return n(`div`,{className:`min-w-0 space-y-2 text-start`,"data-document-edit-action":r.action,children:[n(`div`,{className:`flex min-w-0 items-center gap-1.5 text-sm text-muted`,children:[t(c,{className:`size-4 shrink-0`,"aria-hidden":`true`}),t(`span`,{className:`shrink-0 font-medium text-foreground`,children:i(a?`agent.documentEditCardComment`:o?`agent.documentEditCardApplied`:`agent.documentEditCardDirectEdit`)}),t(`span`,{"aria-hidden":`true`,children:`·`}),t(`span`,{className:`shrink-0 capitalize`,children:s}),t(`span`,{"aria-hidden":`true`,children:`·`}),t(`span`,{className:`truncate`,children:_W(r.resource)})]}),a?n(e,{children:[r.comment?t(uW,{artifactRunId:l,disableCollapse:!0,className:vW,children:r.comment}):null,t(uW,{artifactRunId:l,disableCollapse:!0,className:z(`border-s-2 border-mixer-muted/30 ps-3 text-foreground/70`,vW),children:r.anchor.exact_text})]}):t(bW,{before:r.user_change?.before??r.anchor.exact_text,after:r.user_change?.after??``})]})}const SW=`Brewing some code magic...(Doing the robot dance...(Cooking up something good...(Working my gears...(Parsing the possibilities...(Crunching the numbers...(Connecting the digital dots...(Processing at maximum capacity...(Searching through my circuits...(Running advanced algorithms...(Computing optimal solutions...(Loading brilliance.exe...(Scanning the knowledge base...(Optimizing response protocols...(Having a quick brainstorm...(Thinking cap firmly on...(Pondering the digital universe...(Consulting my silicon wisdom...(Untangling the logic knots...(Assembling clever responses...(Mixing thoughtful ingredients...(Polishing the perfect answer...(Taking a momentary mind sprint...(Connecting virtual synapses...(Baking fresh ideas...(Stirring the thought pot...(Simmering solutions slowly...(Whipping up a smart response...(Adding a dash of intelligence...(Preparing a gourmet answer...(Growing brilliant ideas...(Cultivating the perfect response...(Gathering digital nectar...(Planting seeds of solutions...(Exploring the data landscape...(Mapping the solution path...(Navigating through possibilities...(Charting the course to answers...(Embarking on a thought expedition...(Sketching out concepts...(Painting with digital brushstrokes...(Composing my response symphony...(Crafting precision answers...(Weaving threads of information...(Just a moment of processing...(Taking a quick thinking break...(Almost there, final touches...(Putting the pieces together...(Making progress, hold tight...`.split(`(`);function CW(e,t){if(e.startsWith(t))return e.slice(t.length).split(/[/?#]/,1)[0]||void 0}function wW(e={}){let{StoreLinkComponent:n,CollectionLinkComponent:r,addStickyParams:i}=e;return function({node:e,ref:a,...o}){let s=o.href||``,c=s.startsWith(`/`)&&!s.startsWith(`//`),l=c&&i?i(s):s,u=c?CW(s,`/store/objects/`):void 0;if(u&&n)return t(n,{href:l,documentId:u,className:o.className,children:o.children});let d=c?CW(s,`/store/collections/`):void 0;return d&&r?t(r,{href:l,collectionId:d,className:o.className,children:o.children}):c?t(Zn,{href:l,className:o.className,topLevelNav:!0,children:o.children}):t(`a`,{...o,target:`_blank`,rel:`noopener noreferrer`})}}Q();const TW=dt(null);function EW(){return _t(TW)||{openImage:e=>window.open(e,`_blank`),closeImage:()=>{}}}function DW({children:e}){let[r,i]=G(null),a=V((e,t)=>{i({src:e,alt:t})},[]),s=V(()=>{i(null)},[]),{t:c}=K();return n(TW.Provider,{value:{openImage:a,closeImage:s},children:[e,r&&t(`div`,{role:`button`,tabIndex:-1,"aria-label":c(`agent.close`),className:`fixed inset-0 z-[100] flex items-center justify-center bg-black/80 backdrop-blur-sm`,onClick:s,onKeyDown:qe(s),children:n(`div`,{className:`relative max-w-[90vw] max-h-[90vh]`,children:[t(`img`,{src:r.src,alt:r.alt||c(`agent.enlargedView`),className:`max-w-full max-h-[90vh] object-contain rounded-lg shadow-2xl`}),t(o,{variant:`unstyled`,className:`absolute top-2 end-2 text-white bg-black/50 rounded-full p-2 hover:bg-black/70 transition-colors`,onClick:s,title:c(`agent.close`),children:t(Gb,{className:`size-6`})}),t(`a`,{href:r.src,target:`_blank`,rel:`noopener noreferrer`,className:`absolute bottom-2 end-2 text-white bg-black/50 rounded-full p-2 hover:bg-black/70 transition-colors`,onClick:e=>e.stopPropagation(),title:c(`agent.openInNewTab`),children:t(Dg,{className:`size-5`})})]})})]})}Q();const OW=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`svg`]),kW=new Set([`css`,`csv`,`html`,`js`,`json`,`jsx`,`log`,`md`,`mjs`,`sql`,`ts`,`tsx`,`txt`,`xml`,`yaml`,`yml`]);function AW(e){let t=e?.split(/[?#]/)[0]??``;return t.includes(`.`)?(t.split(`.`).pop()??``).toLowerCase():``}function jW(e){return e.contentType?.toLowerCase().startsWith(`image/`)?!0:OW.has(AW(e.artifactPath||e.href||e.name))}function MW(e){let t=e.contentType?.toLowerCase()??``;return t.startsWith(`text/`)||t===`application/json`||t.includes(`xml`)?!0:kW.has(AW(e.artifactPath||e.href||e.name))}function NW(e){if(e.artifactPath)return e.artifactPath;if(e.href?.startsWith(`artifact:`))return e.href.slice(9)}function PW(e){let t=e.split(`/store/objects/`)[1];return t?t.split(/[?#]/)[0]:e.replace(/^store:/,``).replace(/^document:(?:\/\/)?/,``).split(/[?#]/)[0]}function FW(e){return e.split(`/store/collections/`)[1]||e.replace(/^collection:/,``)}function IW(e){return!!(e?.includes(`/store/objects/`)||e?.startsWith(`store:`)||e?.startsWith(`document:`))}function LW(e){return!!(e?.includes(`/store/collections/`)||e?.startsWith(`collection:`))}function RW({item:n,children:r,onOpenArtifact:i,StoreLinkComponent:a,CollectionLinkComponent:o}){let s=n.href;if(!s)return t(e,{children:r});let c=NW(n);if(c&&/\.md$/i.test(c)&&i)return t(`button`,{type:`button`,className:`max-w-full text-start`,onClick:()=>i(c),children:r});if(IW(s)){let e=PW(s);return a?t(a,{href:s,documentId:e,children:r}):t(`a`,{href:s.startsWith(`store:`)||s.startsWith(`document:`)?`/store/objects/${e}`:s,children:r})}if(LW(s)){let e=FW(s);return o?t(o,{href:s,collectionId:e,children:r}):t(`a`,{href:s.startsWith(`collection:`)?`/store/collections/${e}`:s,children:r})}return/^https?:\/\//.test(s)||s.startsWith(`/`)?t(`a`,{href:s,target:s.startsWith(`/`)?void 0:`_blank`,rel:`noopener noreferrer`,children:r}):t(e,{children:r})}function zW({item:e,artifactRunId:r,variant:i,onRemove:a,onOpenArtifact:s,StoreLinkComponent:c,CollectionLinkComponent:l}){let{t:u}=K(),d=_t(on),f=VS(),{openImage:p}=EW(),m=NW(e),h=jW(e),g=h&&!MW(e),[_,v]=G(e.previewUrl);H(()=>{v(e.previewUrl)},[e.previewUrl]),H(()=>{if(!g||e.previewUrl||!r||!m||!d?.client)return;let t=!1,n=US(r,m,`inline`);return(async()=>{let e=f?await f.getOrFetch(n,async()=>(await d.client.files.getArtifactDownloadUrl(r,m,`inline`)).url):(await d.client.files.getArtifactDownloadUrl(r,m,`inline`)).url;t||v(e)})().catch(()=>{t||v(void 0)}),()=>{t=!0}},[m,r,e.previewUrl,d?.client,g,f]);let y={attention:`bg-attention/15 text-attention`,destructive:`bg-destructive/15 text-destructive`,info:`bg-info/15 text-info`,muted:`bg-muted text-muted`,success:`bg-success/15 text-success`}[e.statusTone??`muted`],b=!!(a&&e.removable!==!1),x=t=>{t.stopPropagation(),t.preventDefault(),a?.(e.id)},S=b?t(o,{variant:`unstyled`,size:`none`,"aria-label":u(`agent.removeFile`,{name:e.name}),onClick:x,className:z(`absolute -end-1.5 -top-1.5 inline-flex size-5 items-center justify-center rounded-full`,`border border-border bg-background text-muted shadow-sm transition-colors hover:text-foreground`),children:t(Gb,{className:`size-3`,"aria-hidden":`true`})}):null,C=b?t(o,{variant:`unstyled`,size:`none`,"aria-label":u(`agent.removeFile`,{name:e.name}),onClick:x,className:z(`-me-1 inline-flex size-6 shrink-0 items-center justify-center rounded-md text-muted`,`transition-colors hover:bg-mixer-muted/30 hover:text-foreground`),children:t(Gb,{className:`size-3.5`,"aria-hidden":`true`})}):null,w=g&&_?t(o,{type:`button`,variant:`unstyled`,size:`none`,onClick:t=>{t.stopPropagation(),t.preventDefault(),p(_,e.name)},"aria-label":e.name,title:u(`agent.enlargedView`),className:z(`group shrink-0 overflow-hidden rounded border border-border/60 p-0`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,i===`composer`?`size-6`:`size-24`),children:t(`img`,{src:_,alt:e.name,className:`h-full w-full object-cover transition-transform group-hover:scale-[1.05]`})}):t(h?D_:Gg,{className:`size-3.5 shrink-0 text-muted`,"aria-hidden":`true`}),T=n(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1.5`,children:[w,t(`span`,{className:z(`truncate`,i===`composer`?`max-w-[14rem]`:`max-w-[16rem]`),children:e.name}),e.statusLabel?t(`span`,{className:z(`shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium`,y),children:e.statusLabel}):null]});if(i===`composer`)return n(`span`,{title:e.name,className:z(`inline-flex min-h-8 max-w-full items-center gap-1 rounded-xl border border-border/60`,`bg-mixer-muted/15 px-2.5 py-1 text-sm text-foreground/80 transition-colors`,e.href&&`hover:bg-mixer-muted/25`),children:[t(RW,{item:e,StoreLinkComponent:c,CollectionLinkComponent:l,children:T}),C]});let E=t(`span`,{title:e.name,className:z(`inline-flex max-w-full items-center gap-1.5 rounded-md border border-border/60 bg-mixer-muted/15`,`px-2.5 py-1.5 text-xs text-foreground/80 transition-colors`,e.href&&`hover:bg-mixer-muted/25`),children:T});return n(`span`,{className:`relative inline-flex max-w-full`,children:[t(RW,{item:e,onOpenArtifact:s,StoreLinkComponent:c,CollectionLinkComponent:l,children:E}),S]})}function BW({items:e,artifactRunId:r,className:i,align:a=`start`,variant:s=`message`,onRemove:c,onOpenArtifact:l,StoreLinkComponent:u,CollectionLinkComponent:d}){let{t:f}=K(),[p,m]=G(!1),h=vt(),g=s===`composer`&&e.length>3,_=g&&!p?e.slice(0,3):e,v=e.length-3;return H(()=>{e.length<=3&&m(!1)},[e.length]),e.length===0?null:n(`div`,{id:h,className:z(`flex flex-wrap gap-2`,a===`end`&&`justify-end`,i),children:[_.map(e=>t(zW,{item:e,artifactRunId:r,variant:s,onRemove:c,onOpenArtifact:l,StoreLinkComponent:u,CollectionLinkComponent:d},e.id)),g&&n(o,{type:`button`,variant:`ghost`,size:`sm`,"aria-controls":h,"aria-expanded":p,onClick:()=>m(e=>!e),className:`h-8 shrink-0 gap-1 rounded-xl px-2.5 text-xs text-muted`,children:[!p&&n(`span`,{children:[`+`,v]}),f(p?`agent.showLess`:`agent.showMore`),t(rh,{className:z(`size-3.5 transition-transform`,p&&`rotate-180`),"aria-hidden":`true`})]})]})}const VW=/^\s*(?:\*\*)?(attachments|uploaded artifacts):(?:\*\*)?\s*$/i,HW=/\s/,UW=[`image -`,`text extracted to `];function WW(e){let t=e;if((t.startsWith(`-`)||t.startsWith(`*`))&&(t=t.slice(1).trimStart()),!t.startsWith(`[`)||!t.endsWith(`)`))return null;let n=t.indexOf(`]`);if(n<2||t[n+1]!==`(`)return null;let r=t.slice(1,n),i=t.slice(n+2,-1);for(let e=i.lastIndexOf(`(`);e>0;e=i.lastIndexOf(`(`,e-1)){let t=e;for(;t>0&&HW.test(i[t-1]);)t--;if(t===e||t<2||i[t-1]!==`)`)continue;let n=i.slice(e+1);if(UW.some(e=>n.startsWith(e)))return{name:r,href:i.slice(0,t-1),note:n}}return i?{name:r,href:i}:null}function GW(e){let t=e.split(/\r?\n/),n=[],r=[],i=!1;for(let e of t){let t=e.trim();if(VW.test(t)){i=!0;continue}if(!i){n.push(e);continue}if(!t)continue;let a=WW(t);if(!a){i=!1,n.push(e);continue}let{name:o,href:s,note:c}=a,l=s.startsWith(`artifact:`)?s.slice(9):void 0;r.push({id:`${s}-${r.length}`,name:o,href:s,artifactPath:l,contentType:c?.toLowerCase().includes(`image`)?`image/*`:void 0})}return{body:n.join(`
954
- `).trim(),attachments:r}}function KW(e){let t=new Set;for(let n of e)if(!(n.type!==J.QUESTION||n.details?._optimistic||typeof n.message!=`string`))for(let e of GW(n.message).attachments)e.href&&t.add(e.href),e.artifactPath&&t.add(e.artifactPath);return t}Q();function qW({message:e,batchData:r,isRunning:i=!1,className:a,headerClassName:s,senderClassName:c,progressBarClassName:l,itemListClassName:u,itemClassName:d,summaryClassName:f}){let[p,m]=G(!1),h=nt(),{t:g}=K(),{tool_name:_,total:v,completed:y,succeeded:b,failed:x,items:S,started_at:C,completed_at:w}=r,T=v>0?y/v*100:0,E=x>0,D=y===v&&!i,O=i||!D?`running`:x===v?`error`:x>0?`warning`:`completed`,k=()=>i||!D?t(iW,{size:`sm`,color:`blue`}):O===`completed`?t(Nh,{className:`size-4 text-success`}):O===`error`||O===`warning`?t(Ah,{className:`size-4 text-destructive`}):t(N_,{className:`size-4 text-done`}),A=()=>O===`completed`?`border-s-success`:O===`error`?`border-s-destructive`:O===`warning`?`border-s-attention`:`border-s-info`,j=()=>E?`bg-attention`:D?`bg-success`:`bg-primary`,M=()=>{let e=JSON.stringify(r,null,2);navigator.clipboard.writeText(e).then(()=>{h({status:`success`,title:g(`agent.copiedBatchDetails`),duration:2e3})})},N=((w?w-C:Date.now()-C)/1e3).toFixed(1);return n(`div`,{className:z(`border-s-4 shadow-md overflow-hidden bg-white dark:bg-muted mb-5`,A(),a),children:[n(`div`,{role:`button`,tabIndex:0,"aria-expanded":p,className:z(`flex items-center justify-between px-4 py-2 border-b border-border/80 bg-info/50 dark:bg-info/10 cursor-pointer`,s),onClick:()=>m(!p),onKeyDown:qe(()=>m(!p)),children:[n(`div`,{className:`flex items-center gap-2`,children:[k(),t(`span`,{className:z(`text-xs font-medium text-muted`,c),children:g(`agent.batch`)}),t(`span`,{className:`text-xs text-info font-medium`,children:_}),n(`span`,{className:`text-xs text-muted`,children:[y,`/`,v]}),p?t(rh,{className:`size-3 text-muted`}):t(lh,{className:`size-3 text-muted cn-rtl-flip`})]}),n(`div`,{className:`flex items-center gap-2`,children:[n(`span`,{className:`text-xs text-muted`,children:[N,`s`]}),t(`span`,{className:`text-xs text-muted`,children:WD(C).format(`HH:mm:ss`)}),t(o,{variant:`ghost`,size:`xs`,onClick:e=>{e.stopPropagation(),M()},className:`text-muted`,title:g(`agent.copyBatchDetails`),children:t(fg,{className:`size-3`})})]})]}),t(`div`,{className:z(`px-4 py-2 bg-muted/50 dark:bg-muted/30`,l),children:n(`div`,{className:`flex items-center gap-3`,children:[t(`div`,{className:`flex-1 h-2 bg-muted rounded-full overflow-hidden`,children:t(`div`,{className:`h-full ${j()} transition-all duration-300 ease-out`,style:{width:`${T}%`}})}),n(`div`,{className:`flex items-center gap-2 text-xs`,children:[b>0&&n(`span`,{className:`text-success flex items-center gap-1`,children:[t(Nh,{className:`size-3`}),b]}),x>0&&n(`span`,{className:`text-destructive flex items-center gap-1`,children:[t(Ah,{className:`size-3`}),x]}),i&&y<v&&n(`span`,{className:`text-info flex items-center gap-1`,children:[t(ev,{className:`size-3 animate-spin`}),v-y]})]})]})}),p&&S.length>0&&t(`div`,{className:z(`max-h-64 overflow-y-auto`,u),children:S.map(e=>n(`div`,{className:z(`flex items-center gap-2 px-4 py-1.5 text-xs border-b border-border last:border-b-0 hover:bg-muted`,d),children:[n(`div`,{className:`w-4 flex-shrink-0`,children:[e.status===`success`&&t(Nh,{className:`size-3 text-success`}),e.status===`error`&&t(Ah,{className:`size-3 text-destructive`}),e.status===`running`&&t(ev,{className:`size-3 text-info animate-spin`}),e.status===`pending`&&t(`div`,{className:`size-3 rounded-full border border-border`})]}),t(`span`,{className:`font-mono text-muted w-24 truncate flex-shrink-0`,title:e.id,children:e.id}),t(`span`,{className:`text-muted truncate flex-1`,title:e.message,children:e.message||(e.status===`pending`?g(`agent.waiting`):``)}),e.duration_ms!==void 0&&n(`span`,{className:`text-muted flex-shrink-0`,children:[(e.duration_ms/1e3).toFixed(1),`s`]})]},e.id))}),!p&&e.message&&t(`div`,{className:z(`px-4 py-2 text-xs text-muted`,f),children:e.message})]})}const JW=gt(qW,(e,t)=>e.isRunning===t.isRunning&&e.batchData.completed===t.batchData.completed&&e.batchData.succeeded===t.batchData.succeeded&&e.batchData.failed===t.batchData.failed);Q();const YW={sending:{icon:rg,className:`text-muted/70`},received:{icon:eh,className:`text-info`},consumed:{icon:Zm,className:`text-success`},failed:{icon:Ah,className:`text-destructive`}};function XW(e){return e===`sending`||e===`received`||e===`consumed`||e===`failed`}function ZW(e){if(e.type!==J.QUESTION&&!ZH(e))return;let t=e.details?._deliveryStatus;if(XW(t))return t;if(e.details?.ack)return`consumed`}function QW(e,t){switch(t){case`sending`:return e(`agent.messageSending`);case`received`:return e(`agent.messageReceived`);case`consumed`:return e(`agent.messageConsumed`);case`failed`:return e(`agent.messageFailed`)}return t}function $W({message:e,className:n}){let{t:r}=K(),i=ZW(e);if(!i)return null;let a=YW[i],o=a.icon,s=QW(r,i);return t(We,{description:s,asChild:!0,children:t(`span`,{"aria-label":s,className:z(`inline-flex h-5 w-5 items-center justify-center`,a.className,n),role:`img`,children:t(o,{className:`size-3.5`,"aria-hidden":`true`})})})}function eG(e){return e.content?.name||e.name}function tG({client:e,toast:t}){let n=Xt.getFixedT(null,Yt),[r,i]=G(!1),a=V(async(r,a)=>{if(r){i(!0);try{nG((await e.files.getDownloadUrlWithOptions({file:r,name:a})).url,a)}catch(e){t({status:`error`,title:n(`store.downloadFailed`),description:e instanceof Error?e.message:n(`store.failedToGetDownloadUrl`),duration:5e3})}finally{i(!1)}}},[e,t,n]),o=V((e,t)=>{e&&nG(e,t)},[]),s=V(async(t,n)=>{let r=await(`store`in e?e.store:e).rendering.render(t);if(r.download_url)nG(r.download_url,n);else if(r.file_uri)nG((await e.files.getDownloadUrlWithOptions({file:r.file_uri,name:n})).url,n);else throw Error(`No download URL or file URI in response`)},[e]);return{downloadFromContentSource:a,downloadFromUrl:o,renderDocument:V(async(e,r)=>{i(!0);try{let i=`${r.title||`document`}.${r.format}`;await s({object_id:e,format:r.format,title:r.title,pandoc_options:r.pandocOptions,use_default_template:r.useDefaultTemplate,template_path:r.templateObjectId?`store:${r.templateObjectId}`:void 0},i),t({status:`success`,title:n(`store.documentExported`),description:n(`store.successfullyExportedTo`,{format:r.format.toUpperCase()}),duration:2e3})}catch(e){t({status:`error`,title:n(`store.exportFailed`),description:e instanceof Error?e.message:n(`store.failedToExportDocument`),duration:5e3})}finally{i(!1)}},[s,t,n]),renderContent:V(async(e,r)=>{i(!0);try{let i=`${r.title||`export`}.${r.format}`;await s({content:e,format:r.format,title:r.title,artifact_run_id:r.artifactRunId,pandoc_options:r.pandocOptions},i),t({status:`success`,title:n(`store.contentExported`),description:n(`store.successfullyExportedTo`,{format:r.format.toUpperCase()}),duration:2e3})}catch(e){t({status:`error`,title:n(`store.exportFailed`),description:e instanceof Error?e.message:n(`store.failedToExportContent`),duration:5e3})}finally{i(!1)}},[s,t,n]),isDownloading:r}}function nG(e,t){fetch(e).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.blob()}).then(n=>{let r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=t||rG(e),i.style.display=`none`,document.body.appendChild(i),i.click(),setTimeout(()=>{document.body.removeChild(i),URL.revokeObjectURL(r)},100)}).catch(()=>{let n=document.createElement(`a`);n.href=e,n.download=t||rG(e),n.target=`_blank`,n.rel=`noopener noreferrer`,n.style.display=`none`,document.body.appendChild(n),n.click(),setTimeout(()=>{document.body.removeChild(n)},100)})}function rG(e){try{let t=new URL(e).pathname.split(`/`);return t[t.length-1]||`download`}catch{return`download`}}function iG(e){return e!==void 0&&e>=`0`&&e<=`9`}function aG(e){return e===` `||e===` `}function oG(e){return e!==void 0&&e!==` `&&e!==` `&&e!==`
955
- `&&e!==`\r`}function sG(e,t){if(t>0&&iG(e[t-1]))return;let n=t;for(;iG(e[n]);)n++;if(n===t||e[n]!==`.`)return;n++;let r=n;for(;aG(e[n]);)n++;return n>r&&oG(e[n])?n:void 0}function cG(e,t){for(let n=t;n<e.length;n++)if(sG(e,n)!==void 0)return n;return-1}function lG(e){let t=cG(e,0);if(t===-1)return e;let n=e.slice(0,t),r=t;for(;r!==-1;){let t=cG(e,sG(e,r)??r+1);if(t===-1){n+=e.slice(r),n+=`
952
+ ${O||``}`,children:n(`div`,{className:`flex items-start gap-3`,children:[e.icon&&t(`span`,{className:`flex-shrink-0 mt-0.5 text-muted`,children:e.icon}),n(`div`,{className:`flex-1 overflow-hidden`,children:[t(`div`,{className:`font-medium text-sm text-foreground break-words text-center`,children:e.label}),e.description&&t(`div`,{className:`mt-1 text-sm text-muted break-words whitespace-pre-wrap`,children:e.description})]})]})},e.id))})}),u&&t(`div`,{className:`px-4 pb-3 pt-1 ${k||``}`,children:n(`div`,{className:`flex gap-2`,children:[t(`input`,{ref:R,type:`text`,value:F,onChange:e=>I(e.target.value),onKeyDown:le,placeholder:N,disabled:m,className:`flex-1 px-3 py-2 text-sm border border-border rounded-md bg-white dark:bg-muted focus:ring-2 focus:ring-info focus:border-transparent ${A||``}`}),t(o,{size:`sm`,onClick:ce,disabled:m||!F.trim(),className:j,children:m?`...`:P})]})})]})})}function MH({question:e,description:n,onConfirm:r,onCancel:i,confirmLabel:a,cancelLabel:o,isLoading:s=!1,variant:c=`default`,className:l}){let{t:u}=K(),d=a??u(`agent.yes`),f=o??u(`agent.no`);return t(jH,{question:e,description:n,variant:c,isLoading:s,className:l,options:[{id:`confirm`,label:d,icon:t(Nh,{className:`size-4`})},{id:`cancel`,label:f,icon:t(Gh,{className:`size-4`})}],onSelect:e=>{e===`confirm`?r():i()}})}function NH(e){let t=e.replace(/^workstream[:_-]?/i,``).replace(/^sys:/i,``).replace(/[-_:]?[0-9a-f]{8}-[0-9a-f-]{12,}$/i,``).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/([A-Z]+)([A-Z][a-z])/g,`$1 $2`).replace(/[:_-]+/g,` `).trim();return t?t.split(/\s+/).map(e=>{let t=e.toLowerCase();return t===`qa`?`QA`:t===`ui`?`UI`:t===`api`?`API`:t===`url`?`URL`:t.charAt(0).toUpperCase()+t.slice(1)}).join(` `):e}function PH(e){return/[0-9a-f]{8}-[0-9a-f-]{12,}/i.test(e)}function FH(e,t){let n=t?NH(t):``,r=NH(e);if(!n)return r;if(PH(e))return n;let i=n.toLowerCase().replace(/\s+/g,``);return r.toLowerCase().replace(/\s+/g,``).startsWith(i)?n:r}function IH(e){return e.message?typeof e.message==`object`?JSON.stringify(e.message,null,2):String(e.message).trim():``}function LH(e){if(typeof e!=`string`)return!1;let t=e.trim().toLowerCase();return!!(t&&t!==`main`&&t!==`all`)}function RH(e){let t=e.trim();if(!t||!/^[{[]/.test(t))return!1;try{return JSON.parse(t),!0}catch{return!1}}function zH(e,t){return LH(t)&&RH(e)}function BH(e){return!zH(IH(e),e.workstream_id)||e.type!==J.ANSWER&&e.type!==J.COMPLETE?!1:e.details?.event_class===`user_content`||e.details?.streamed===!0}function VH(e){switch(e){case`running`:return`bg-info`;case`canceling`:return`bg-attention`;case`completed`:return`bg-success`;case`canceled`:case`failed`:case`timeout`:return`bg-destructive`}}function HH(e){let t=e.details,n=t?.status;if(n===`running`||n===`canceling`||n===`completed`||n===`canceled`||n===`failed`||n===`timeout`)return n;if(t?.workstream_event===`completed`)return`completed`}function UH(e){let t=e.details;if(t?.workstream_event!==`launched`)return null;let n=typeof t.workstream_id==`string`?t.workstream_id:typeof e.workstream_id==`string`?e.workstream_id:``;return!n||n===`main`||n===`all`?null:{workstreamId:n,launchId:typeof t.launch_id==`string`?t.launch_id:void 0,kind:typeof t.kind==`string`?t.kind:void 0,interaction:typeof t.interaction==`string`?t.interaction:void 0,childWorkflowId:typeof t.child_workflow_id==`string`?t.child_workflow_id:void 0,childWorkflowRunId:typeof t.child_workflow_run_id==`string`?t.child_workflow_run_id:void 0}}function WH(e){let t=e.details;if(t?.event_class!==`activity`||t.workstream_event!==void 0||e.type===J.ERROR)return null;let n=typeof t.child_workflow_id==`string`?t.child_workflow_id:void 0,r=typeof t.child_workflow_run_id==`string`?t.child_workflow_run_id:void 0;if(!n&&!r)return null;let i=typeof t.workstream_id==`string`&&t.workstream_id.trim()?t.workstream_id:typeof e.workstream_id==`string`?e.workstream_id:``;return LH(i)?{workstreamId:i,launchId:typeof t.launch_id==`string`?t.launch_id:void 0,kind:typeof t.kind==`string`?t.kind:void 0,interaction:typeof t.interaction==`string`?t.interaction:void 0,childWorkflowId:n,childWorkflowRunId:r}:null}function GH(e){let t=e.indexOf(`?`);return t===-1?null:new URLSearchParams(e.slice(t+1)).get(`agentChatDebug`)}function KH(){if(typeof window>`u`)return!1;let e=new URLSearchParams(window.location.search).get(`agentChatDebug`),t=GH(window.location.hash),n=e??t;if(n!==null)return n===`1`||n===`true`;try{let e=window.localStorage.getItem(`agentChatDebug`);return e===`1`||e===`true`}catch{return!1}}function qH(e,t){KH()&&console.debug(`[agent-chat] ${e}`,t??{})}function JH(e,t){let n=typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime(),r=e.findIndex(e=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())>n);r===-1?e.push(t):e.splice(r,0,t)}const YH=[J.COMPLETE,J.IDLE,J.REQUEST_INPUT,J.TERMINATED];function XH(e){return e.type===J.UPDATE&&e.details?.event_class===`artifact_updated`}function ZH(e){if(!e.length)return!0;let t=e=>e.details?._optimistic&&e.details?._deliveryStatus===`failed`&&YH.includes(e.type),n=e.filter(e=>!t(e)&&!XH(e)),r=n.filter(e=>eU(e)===`main`);if(r.length===0){let e=n[n.length-1];return!e||!YH.includes(e.type)}let i=r[r.length-1];return!YH.includes(i.type)}function QH(e){if(e.type!==J.IDLE)return!1;let t=e.details?.status_reason,n=e.details?.display_role;return t===`user_stopped`||n===`user_stopped`||String(e.message??``).trim().toLowerCase().startsWith(`stopped.`)}function $H(e){return typeof e==`number`?e:new Date(e).getTime()}function eU(e){return e.workstream_id?e.workstream_id:`main`}function tU(e){let t=e.details;return!t||typeof t!=`object`||Array.isArray(t)?{}:t}function nU(e){if(eU(e)===`main`||UH(e)||WH(e))return!0;let t=tU(e),n=typeof t.child_workflow_id==`string`||typeof t.child_workflow_run_id==`string`,r=typeof t.tool==`string`||typeof t.tool_run_id==`string`;return t.event_class===`activity`&&(e.type===J.ERROR||e.type===J.WARNING)&&!n&&!r}function rU(e,t){return t===`all`?e.filter(nU):e.filter(e=>(UH(e)??WH(e))?.workstreamId!==t&&eU(e)===t)}async function iU(e,t){return e.agents.getArtifactUrl(t,`conversation.json`).then(e=>e.url)}function aU(e,t){if(!t)return!0;let n=e.workstreamId||`main`;return t===`all`?n===`main`:t===n}function oU(e){if(typeof e==`string`)return e.replace(/\r\n/g,`
953
+ `).trim()||void 0}function sU(e){return oU(e.message)}function cU(e,t){let n=oU(e.text);if(!n)return!1;let r=e.workstreamId||`main`;return t.some(t=>{if($H(t.timestamp)<e.startTimestamp||eU(t)!==r)return!1;let i=typeof t.details?.streaming_id==`string`?t.details.streaming_id:void 0;return e.streamingId&&i?i===e.streamingId?t.details?.display_role===`thinking`?sU(t)===n:!(uU(t)||t.details?.tool_status):!1:e.activityId&&t.details?.activity_id===e.activityId?t.details?.display_role===`thinking`?sU(t)===n:!(uU(t)||t.details?.tool_status):t.type!==J.THOUGHT&&t.type!==J.ANSWER&&t.type!==J.COMPLETE&&t.type!==J.IDLE?!1:sU(t)===n})}function lU(e,t){if(eU(e)!==eU(t))return!1;let n=sU(e),r=sU(t);if(!n||n!==r)return!1;let i=$H(e.timestamp);return $H(t.timestamp)-i>1e4?!1:!!(e.type===J.ANSWER&&(t.type===J.COMPLETE||t.type===J.IDLE)||e.type===J.THOUGHT&&(t.type===J.ANSWER||t.type===J.COMPLETE||t.type===J.IDLE)&&(e.details?.streamed||t.details?.streamed)||e.type===t.type&&(e.details?.streamed||t.details?.streamed)&&(t.type===J.THOUGHT||t.type===J.ANSWER||t.type===J.COMPLETE||t.type===J.IDLE))}function uU(e){return e.type===J.THOUGHT&&!!e.details?.tool}function dU(e){let t=e.details;return e.type===J.THOUGHT&&(t?.display_role===`tool_preamble`||t?.tool===`think`)}function fU(e){if(dU(e))return!1;if(uU(e))return!0;if(e.type!==J.THOUGHT)return!1;let t=e.details;return!!(Array.isArray(t?.tools)&&t.tools.length>0)}function pU(e){return e.details?.tool_run_id}function mU(e){return e.details?.tool_iteration}function hU(e){return e.details?.tool_status}function gU(e){let t=e.details?.activity_group_id;if(typeof t==`string`&&t.trim()!==``)return t}function _U(e,t,n){let r=new Map,i=new Map,a=new Map,o=[];for(let t of e){let e=gU(t);if(t.type===J.REQUEST_INPUT||t.type===J.BATCH_PROGRESS)o.push(t);else if(dU(t))o.push(t);else if(e)r.has(e)||r.set(e,{messages:[],firstTimestamp:$H(t.timestamp)}),r.get(e)?.messages.push(t);else if(fU(t)){let e=mU(t),n=pU(t);e===void 0?n?(a.has(n)||a.set(n,{messages:[],firstTimestamp:$H(t.timestamp)}),a.get(n)?.messages.push(t)):o.push(t):(i.has(e)||i.set(e,{messages:[],firstTimestamp:$H(t.timestamp)}),i.get(e)?.messages.push(t))}else o.push(t)}let s=[];r.forEach((e,t)=>{s.push({kind:`activity_group`,activityGroupId:t,messages:e.messages,timestamp:e.firstTimestamp})}),i.forEach((e,t)=>{s.push({kind:`iteration_group`,iteration:t,messages:e.messages,timestamp:e.firstTimestamp})}),a.forEach((e,t)=>{s.push({kind:`tool_run`,toolRunId:t,messages:e.messages,timestamp:e.firstTimestamp})});for(let e of o)s.push({kind:`message`,message:e,timestamp:$H(e.timestamp)});t.forEach((t,r)=>{t.text&&(cU(t,e)||aU(t,n)&&s.push({kind:`streaming`,streamingId:r,data:t,timestamp:t.startTimestamp}))}),s.sort((e,t)=>{let n=e.kind===`streaming`&&!e.data.isComplete,r=t.kind===`streaming`&&!t.data.isComplete;return n&&!r?1:r&&!n?-1:e.timestamp-t.timestamp});let c=[],l=[],u=()=>{l.length>0&&(l.length===1&&!dU(l[0])?c.push({type:`single`,message:l[0]}):c.push({type:`tool_group`,messages:l,firstTimestamp:$H(l[0].timestamp)}),l=[])};for(let e of s)if(e.kind===`streaming`)u(),c.push({type:`streaming`,streamingId:e.streamingId,text:e.data.text,workstreamId:e.data.workstreamId,startTimestamp:e.data.startTimestamp,isComplete:e.data.isComplete});else if(e.kind===`activity_group`){u();let t=[...e.messages].sort((e,t)=>$H(e.timestamp)-$H(t.timestamp)),n=t.reduce((e,t)=>hU(t)||e,void 0);c.push({type:`tool_group`,messages:t,firstTimestamp:e.timestamp,toolRunId:e.activityGroupId,toolStatus:n})}else if(e.kind===`iteration_group`){u();let t=[...e.messages].sort((e,t)=>$H(e.timestamp)-$H(t.timestamp)),n=t.reduce((e,t)=>hU(t)||e,void 0);c.push({type:`tool_group`,messages:t,firstTimestamp:e.timestamp,toolStatus:n})}else if(e.kind===`tool_run`){u();let t=[...e.messages].sort((e,t)=>$H(e.timestamp)-$H(t.timestamp)),n=t.reduce((e,t)=>hU(t)||e,void 0);c.push({type:`tool_group`,messages:t,firstTimestamp:e.timestamp,toolRunId:e.toolRunId,toolStatus:n})}else fU(e.message)?l.push(e.message):(u(),c.push({type:`single`,message:e.message}));return u(),c}function vU(e,t){return t??e}function yU(e){let t=[],n=null,r=()=>{n&&=(t.push({type:`tool_group`,messages:n.messages,firstTimestamp:n.firstTimestamp,toolRunId:n.toolRunId,toolStatus:n.toolStatus,preambleText:n.preambleText,preambleMessage:n.preambleMessage}),null)};for(let i of e)i.type===`tool_group`?n?(n.messages=[...n.messages,...i.messages],n.toolStatus=vU(n.toolStatus,i.toolStatus),!n.toolRunId&&i.toolRunId&&(n.toolRunId=i.toolRunId),!n.preambleMessage&&i.preambleMessage&&(n.preambleMessage=i.preambleMessage,n.preambleText=i.preambleText)):n={messages:[...i.messages],firstTimestamp:i.firstTimestamp,toolRunId:i.toolRunId,toolStatus:i.toolStatus,preambleText:i.preambleText,preambleMessage:i.preambleMessage}:(r(),t.push(i));return r(),t}function bU(e){return e.message?typeof e.message==`object`?JSON.stringify(e.message,null,2):String(e.message).trim():``}function xU(e){let t=SU(e.details?.tool_approval);if(!t)return bU(e);let n=CU(t.tool_title)??CU(t.tool_name),r=TU(CU(t.target));if(n&&r)return`Approve ${n}: ${r}?`;let i=CU(t.action_summary);return i?`Approve ${wU(i)}?`:bU(e)}function SU(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:void 0}function CU(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function wU(e){return e.replace(/:\s*name(?::|\s+)/i,`: `)}function TU(e){if(!e)return;let t=e.indexOf(`:`);if(t<0)return e;let n=e.slice(0,t),r=e.slice(t+1).trim();if(!r)return e;switch(n){case`document_id`:return`document ${r}`;case`object_id`:return`object ${r}`;case`collection_id`:return`collection ${r}`;case`process_id`:return`process ${r}`;case`process_definition_id`:return`process definition ${r}`;case`interaction_id`:return`interaction ${r}`;case`prompt_id`:return`prompt ${r}`;case`dashboard_id`:return`dashboard ${r}`;case`database_id`:return`database ${r}`;case`table_id`:return`table ${r}`;default:return r}}function EU(e){let t=e.details;return e.type===J.REQUEST_INPUT&&!!t?.ux}function DU(e){let t=e.details;return[t?.request_id,t?.requestId,t?.activity_id,t?.activityId,t?.tool_run_id,t?.toolRunId,e.timestamp,bU(e)].filter(e=>typeof e==`string`||typeof e==`number`).map(String).join(`|`)}function OU(e){let t=e.details,n=t?.request_id??t?.tool_use_id;return typeof n==`string`&&n?n:void 0}function kU(e){return OU(e)??DU(e)}function AU(e,t){return`vertesia:answered-request-input:${e}:${t}`}function jU(e,t){if(!(typeof window>`u`))try{window.sessionStorage.setItem(AU(e,t),`1`)}catch{}}function MU(e,t){if(!(typeof window>`u`))try{window.sessionStorage.removeItem(AU(e,t))}catch{}}function NU(e,t){if(t.type!==J.REQUEST_INPUT)return!1;let n=OU(t);if(!n||typeof window>`u`)return!1;try{return window.sessionStorage.getItem(AU(e,n))===`1`}catch{return!1}}function PU(e){if(e.type!==J.QUESTION)return;let t=SU(e.details),n=SU(t?.metadata),r=(SU(t?.request_input_response)??SU(n?.request_input_response))?.request_id;return typeof r==`string`&&r?r:void 0}function FU(e){let t=e.details;return[t?.ack,t?._messageId,t?._deliveryStatus,e.timestamp,eU(e),bU(e)].filter(e=>typeof e==`string`||typeof e==`number`).map(String).join(`|`)}function IU(e){let t=new Set,n=new Map;return e.forEach((e,t)=>{let r=PU(e);r&&n.set(r,t)}),e.forEach((r,i)=>{if(r.type!==J.REQUEST_INPUT)return;let a=OU(r),o=a?n.get(a):void 0;if(o!==void 0&&o>i){t.add(DU(r));return}let s=eU(r);for(let n=i+1;n<e.length;n+=1){let i=e[n];if(eU(i)===s){if(i.type===J.REQUEST_INPUT)break;if(i.type===J.QUESTION){PU(i)||t.add(DU(r));break}}}}),t}function LU(e,t){let n=OU(e);return n?{...t,request_input_response:{request_id:n}}:t}function RU(e,t,n,r){if(!e)return;let i=LU(t,r);i?e(n,i):e(n)}function zU(e){let t=SU(e?.request_input_response)?.request_id;return typeof t==`string`&&t?t:void 0}const BU=`request:`;function VU(e){let t=new Set;for(let n of e){let e=SU(n.details),r=SU(e?.approval_request)?.approval_key,i=e?.approval_decision;if(i===`auto_approved`){let n=e?.request_id;typeof n==`string`&&n&&t.add(`${BU}${n}`);continue}typeof r==`string`&&(i===`denied`||i===`denied_with_feedback`||i===`timeout`||i===`reviewer_denied`||i===`cancelled_after_denial`)&&t.add(r)}return t}function HU(e){let t=SU(SU(e.details)?.tool_approval)?.approval_key;return typeof t==`string`?t:void 0}function UU(e){return e.type===J.REQUEST_INPUT&&HU(e)!==void 0}const WU=new Set([`allow_once`,`allow_for_run`,`deny`]);function GU(e,t){let n=HU(e);if(!(!n||!WU.has(t)))return{tool_approval_response:{decision:t,approval_key:n}}}function KU(e){if(e.type!==J.QUESTION)return!1;let t=bU(e).trim().toLowerCase();return t===`allow_once`||t===`allow_for_run`||t===`deny`}function qU(e){if(e.type!==J.QUESTION)return!1;let t=SU(e.details),n=SU(t?.metadata),r=(SU(t?.tool_approval_response)??SU(n?.tool_approval_response))?.decision;return r===`deny_with_feedback`||typeof r==`string`&&WU.has(r)}function JU(e){return KU(e)||qU(e)}function YU(e,t){if(e.type!==J.REQUEST_INPUT)return!1;let n=OU(e);if(n&&t.has(`${BU}${n}`))return!0;let r=HU(e);return r?t.has(r):!1}function XU(e){let t=new Set;return e.forEach((n,r)=>{if(!UU(n))return;let i=eU(n);for(let a=r+1;a<e.length;a+=1){let r=e[a];if(eU(r)===i){if(r.type===J.REQUEST_INPUT)break;if(r.type===J.QUESTION){JU(r)&&t.add(DU(n));break}}}}),t}function ZU(e,t,n){return UU(e)&&(t.has(DU(e))||YU(e,n))}function QU(e,t){let n=new Set;return e.forEach((r,i)=>{if(!UU(r)||t&&!YU(r,t))return;let a=eU(r);for(let t=i+1;t<e.length;t+=1){let r=e[t];if(eU(r)===a){if(r.type===J.REQUEST_INPUT)break;if(r.type===J.QUESTION){KU(r)&&n.add(FU(r));break}}}}),n}function $U(e,t){return e.type===J.QUESTION&&t.has(FU(e))}function eW(e,t){return e.type===J.REQUEST_INPUT&&t.has(DU(e))}function tW(e,t=`main`,n){let r=IU(e),i=VU(e);for(let a=e.length-1;a>=0;--a){let o=e[a];if(EU(o)&&eU(o)===t&&!n?.has(kU(o))&&!eW(o,r)&&!YU(o,i))return o}}Q();function nW({mcpConnect:e,onMcpConnected:r,onDecline:i,disabled:a}){let{client:s}=q(),{t:c}=K();return n(`div`,{className:`flex shrink-0 items-center justify-end gap-2`,children:[t(mO,{appId:e.app_install_id,collectionId:e.collection_id,collectionName:e.name,variant:`default`,onAuthChange:()=>{s.remoteMcpConnections.getCollectionStatus(e.app_install_id,e.collection_id).then(t=>{t.authenticated&&r?.(e)}).catch(()=>{})},readOnly:a}),n(o,{variant:`ghost`,size:`sm`,onClick:i,disabled:a,children:[t(Gb,{className:`size-4`}),t(`span`,{children:c(`mcpOAuth.decline`)})]})]})}function rW({message:e,onSendMessage:r,onMcpConnected:i,isLoading:a=!1,disabled:o=!1,className:s}){let{t:c}=K();if(!e)return null;let l=e.details.ux,u=l.options??[],d=l.mcp_connect,f=l.free_response,p=o||a||!r,m=xU(e),h=(t,n)=>{p||RU(r,e,t,n)},g=z(`flex-shrink-0 border-t border-border/70 bg-background/95 backdrop-blur`,`fixed bottom-0 end-0 start-0 z-20 lg:sticky lg:start-auto lg:end-auto`,`pb-safe-area`,s);return d?t(`div`,{className:g,"data-agent-request-input-overlay":!0,children:n(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-3 px-3 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[t(`div`,{className:`min-w-0 text-sm leading-6 text-foreground/85`,children:m}),t(nW,{mcpConnect:d,onMcpConnected:t=>i?.(t,LU(e)),onDecline:()=>h(c(`agent.mcpDeclinedMessage`,{name:d.name})),disabled:p})]})}):t(`div`,{className:g,"data-agent-request-input-overlay":!0,children:t(`div`,{className:`mx-auto w-full max-w-3xl px-3 py-3`,children:t(jH,{question:m,options:u,variant:l.variant,multiSelect:l.multiSelect,allowFreeResponse:u.length===0||!!f,placeholder:f?.placeholder,submitLabel:f?.submit_label,onSelect:t=>h(t,GU(e,t)),onMultiSelect:e=>h(e.join(`, `)),onSubmit:e=>h(e,f?.metadata),hideBorder:!0,compact:!0,isLoading:p,className:`my-0`,cardClassName:`bg-background/80 shadow-lg shadow-black/5 dark:shadow-none`})})})}function iW({className:e,inline:r=!1,color:i=`blue`}){let a={blue:`from-blue-400 to-indigo-500 dark:from-blue-500 dark:to-indigo-400`,purple:`from-purple-400 to-violet-500 dark:from-purple-500 dark:to-violet-400`,teal:`from-teal-400 to-emerald-500 dark:from-teal-500 dark:to-emerald-400`,green:`from-green-400 to-emerald-500 dark:from-green-500 dark:to-emerald-400`,amber:`from-amber-400 to-orange-500 dark:from-amber-500 dark:to-orange-400`}[i];return n(`div`,{className:z(`flex items-center gap-1.5`,r?`inline-flex`:``,e),children:[t(`div`,{className:`w-2 h-2 bg-gradient-to-r ${a} rounded-full animate-[bounce_1.2s_ease-in-out_infinite]`}),t(`div`,{className:`w-2 h-2 bg-gradient-to-r ${a} rounded-full animate-[bounce_1.2s_ease-in-out_0.2s_infinite]`}),t(`div`,{className:`w-2 h-2 bg-gradient-to-r ${a} rounded-full animate-[bounce_1.2s_ease-in-out_0.4s_infinite]`})]})}function aW({className:e,size:r=`md`,color:i=`blue`}){let a={sm:`w-3 h-3`,md:`w-5 h-5`,lg:`w-7 h-7`},o={blue:`bg-blue-500 dark:bg-blue-400`,purple:`bg-purple-500 dark:bg-purple-400`,teal:`bg-teal-500 dark:bg-teal-400`,green:`bg-green-500 dark:bg-green-400`,amber:`bg-amber-500 dark:bg-amber-400`};return n(`span`,{className:z(`relative flex`,e),children:[t(`span`,{className:z(`animate-ping absolute inline-flex h-full w-full rounded-full opacity-60`,o[i])}),t(`span`,{className:z(`animate-pulse absolute inline-flex h-[80%] w-[80%] rounded-full opacity-80`,o[i]),style:{left:`10%`,top:`10%`,animationDuration:`2s`}}),t(`span`,{className:z(`relative inline-flex rounded-full`,o[i],a[r])})]})}function oW({className:e,color:n=`blue`}){let[r,i]=G(`.`);return H(()=>{let e=setInterval(()=>{i(e=>e===`.`?`..`:e===`..`?`...`:`.`)},500);return()=>clearInterval(e)},[]),t(`span`,{className:z({blue:`text-blue-600 dark:text-blue-400`,purple:`text-purple-600 dark:text-purple-400`,teal:`text-teal-600 dark:text-teal-400`,green:`text-green-600 dark:text-green-400`,amber:`text-amber-600 dark:text-amber-400`}[n],`font-bold`,e),children:r})}function sW({message:e,className:r,color:i=`blue`}){let a={blue:{dot:`bg-blue-500 dark:bg-blue-400`,text:`text-blue-700 dark:text-blue-300`},purple:{dot:`bg-purple-500 dark:bg-purple-400`,text:`text-purple-700 dark:text-purple-300`},teal:{dot:`bg-teal-500 dark:bg-teal-400`,text:`text-teal-700 dark:text-teal-300`},green:{dot:`bg-green-500 dark:bg-green-400`,text:`text-green-700 dark:text-green-300`},amber:{dot:`bg-amber-500 dark:bg-amber-400`,text:`text-amber-700 dark:text-amber-300`}};return n(`div`,{className:z(`flex items-center gap-2 py-1`,r),children:[n(`div`,{className:`flex gap-1`,children:[t(`div`,{className:`w-1.5 h-1.5 ${a[i].dot} rounded-full animate-bounce`}),t(`div`,{className:`w-1.5 h-1.5 ${a[i].dot} rounded-full animate-bounce`,style:{animationDelay:`0.2s`}}),t(`div`,{className:`w-1.5 h-1.5 ${a[i].dot} rounded-full animate-bounce`,style:{animationDelay:`0.4s`}})]}),t(`div`,{className:`${a[i].text} font-medium text-xs`,children:e})]})}function cW({className:e,color:r=`blue`,width:i=`md`,message:a}){let[o,s]=G(15),[c,l]=G(`increasing`),[u,d]=G(.4),f=W(null),p=W(!0);return H(()=>{let e=f.current;if(!e)return;let t=new IntersectionObserver(([e])=>{p.current=e.isIntersecting},{threshold:0});return t.observe(e),()=>t.disconnect()},[]),H(()=>{let e,t=Date.now(),n=()=>{if(!p.current){e=requestAnimationFrame(n);return}let r=Date.now(),i=r-t;t=r,s(e=>{let t=i/16*u,n=c===`increasing`?e+t:e-t;return n>=85?(l(`decreasing`),d(.3+Math.random()*.2),85):n<=15?(l(`increasing`),d(.3+Math.random()*.2),15):(Math.random()>.99&&d(e=>Math.max(.2,Math.min(.5,e+(Math.random()*.1-.05)))),n)}),e=requestAnimationFrame(n)};return e=requestAnimationFrame(n),()=>{cancelAnimationFrame(e)}},[c,u]),n(`div`,{ref:f,className:z(`flex flex-col gap-1`,e),children:[a&&t(`div`,{className:`text-xs font-medium ${{blue:`text-blue-700 dark:text-blue-300`,purple:`text-purple-700 dark:text-purple-300`,teal:`text-teal-700 dark:text-teal-300`,green:`text-green-700 dark:text-green-300`,amber:`text-amber-700 dark:text-amber-300`}[r]} mb-1`,children:a}),t(`div`,{className:z(`h-1.5 rounded-full overflow-hidden shadow-inner`,{blue:`bg-blue-200 dark:bg-blue-900/30`,purple:`bg-purple-200 dark:bg-purple-900/30`,teal:`bg-teal-200 dark:bg-teal-900/30`,green:`bg-green-200 dark:bg-green-900/30`,amber:`bg-amber-200 dark:bg-amber-900/30`}[r],{sm:`w-24`,md:`w-32`,lg:`w-48`,xl:`w-64`,full:`w-full`}[i]),children:t(`div`,{className:z(`h-full rounded-full`,{blue:`bg-gradient-to-r from-blue-400 to-blue-500 dark:from-blue-500 dark:to-blue-400`,purple:`bg-gradient-to-r from-purple-400 to-purple-500 dark:from-purple-500 dark:to-purple-400`,teal:`bg-gradient-to-r from-teal-400 to-teal-500 dark:from-teal-500 dark:to-teal-400`,green:`bg-gradient-to-r from-green-400 to-green-500 dark:from-green-500 dark:to-green-400`,amber:`bg-gradient-to-r from-amber-400 to-amber-500 dark:from-amber-500 dark:to-amber-400`}[r]),style:{width:`${o}%`,transition:`width 150ms cubic-bezier(0.4, 0.0, 0.2, 1)`}})})]})}function lW({className:e,color:n=`blue`,size:r=`md`}){let[i,a]=G(Array(7).fill(50)),o=W(null),s=W(!0);H(()=>{let e=o.current;if(!e)return;let t=new IntersectionObserver(([e])=>{s.current=e.isIntersecting},{threshold:0});return t.observe(e),()=>t.disconnect()},[]);let c={sm:{width:`w-16`,height:`h-4`,barWidth:`w-0.5`,gap:`gap-[2px]`},md:{width:`w-20`,height:`h-5`,barWidth:`w-1`,gap:`gap-[3px]`},lg:{width:`w-24`,height:`h-6`,barWidth:`w-1.5`,gap:`gap-1`}},l={blue:`bg-gradient-to-b from-blue-400 to-blue-500 dark:from-blue-400 dark:to-blue-500`,purple:`bg-gradient-to-b from-purple-400 to-purple-500 dark:from-purple-400 dark:to-purple-500`,teal:`bg-gradient-to-b from-teal-400 to-teal-500 dark:from-teal-400 dark:to-teal-500`,green:`bg-gradient-to-b from-green-400 to-green-500 dark:from-green-400 dark:to-green-500`,amber:`bg-gradient-to-b from-amber-400 to-amber-500 dark:from-amber-400 dark:to-amber-500`};return H(()=>{let e,t=[1.2,1,1.5,.8,1.3,.9,1.1],n=[0,.5,1,1.5,2,2.5,3],r=0,i=()=>{if(!s.current){e=requestAnimationFrame(i);return}r+=.02;let o=Array(7).fill(0).map((e,i)=>10+(Math.sin(r*t[i]+n[i])+1)*40);a(o),e=requestAnimationFrame(i)};return e=requestAnimationFrame(i),()=>{cancelAnimationFrame(e)}},[]),t(`div`,{ref:o,className:z(`flex items-end justify-center`,c[r].width,c[r].height,c[r].gap,e),children:i.map((e,i)=>t(`div`,{className:z(c[r].barWidth,`rounded-full transform-gpu`,l[n]),style:{height:`${e}%`,transition:`height 100ms cubic-bezier(0.4, 0.0, 0.2, 1)`,opacity:.9}},`bar-${i}`))})}Q();const uW=[`agent-markdown vprose prose max-w-none break-words text-sm leading-6 text-foreground/80`,`prose-p:my-2 prose-p:leading-6 prose-li:my-0.5 prose-pre:my-3 prose-headings:tracking-normal`,`prose-headings:text-foreground prose-strong:text-foreground prose-code:text-foreground`,`prose-a:text-foreground prose-a:underline prose-a:decoration-muted prose-a:underline-offset-4`,`[&_p]:text-foreground/80 [&_li]:text-foreground/80 [&_li::marker]:text-muted`].join(` `);function dW({children:e,artifactRunId:r,components:i,disableCollapse:a,className:o,"data-testid":s}){let{t:c}=K(),l=e.trim(),[u,d]=G(!1),f=l?l.split(/\r?\n/).length:0,p=l.length>520||f>6,m=p&&!a&&!u;return n(`div`,{className:z(`min-w-0`,o),children:[t(`div`,{"data-testid":s,className:z(uW,m&&`[display:-webkit-box] overflow-hidden [-webkit-box-orient:vertical] [-webkit-line-clamp:6]`),style:{overflowWrap:`anywhere`},children:t(Nt,{artifactRunId:r,components:i,children:e})}),p&&!a?t(`div`,{className:`mt-1.5 flex justify-end`,children:n(`button`,{type:`button`,"aria-expanded":u,className:z(`inline-flex items-center gap-1 text-sm font-medium text-muted transition-colors`,`[text-decoration:none] hover:text-foreground hover:[text-decoration:none]`,`focus-visible:text-foreground focus-visible:[text-decoration:none]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`),onClick:()=>d(e=>!e),children:[c(u?`agent.showLess`:`agent.showMore`),t(rh,{className:z(`size-4 transition-transform`,u&&`rotate-180`),"aria-hidden":`true`})]})}):null]})}Q();const fW=new Set([`heading`,`paragraph`,`list`,`list_item`,`blockquote`,`code_block`,`table`,`separator`]);function pW(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:void 0}function mW(e,t){let n=e?.[t];return typeof n==`string`&&n.length>0?n:void 0}function hW(e){let t=pW(e),n=mW(t,`kind`);if(n===`store_document`){let e=mW(t,`document_id`);if(!e)return;let r=mW(t,`name`);return{kind:n,document_id:e,...r?{name:r}:{}}}if(n===`agent_artifact`){let e=mW(t,`run_id`),r=mW(t,`path`);return e&&r?{kind:n,run_id:e,path:r}:void 0}}function gW(e){let t=pW(e),n=pW(t?.anchor),r=mW(t,`operation_id`),i=mW(t,`action`),a=mW(n,`block_id`),o=mW(n,`block_type`),s=mW(n,`exact_text`),c=hW(t?.resource);if(!r||i!==`comment`&&i!==`edit`||!a||!o||!fW.has(o)||!s||!c)return;let l=mW(t,`base_version`),u=mW(t,`comment`),d=pW(t?.user_change),f=mW(d,`before`),p=mW(d,`after`);if(i===`comment`&&!u||i===`edit`&&(!f||!p))return;let m=mW(t,`updated_document_id`);return{operation_id:r,resource:c,...l?{base_version:l}:{},action:i,anchor:{block_id:a,block_type:o,exact_text:s},...u?{comment:u}:{},...f&&p?{user_change:{before:f,after:p}}:{},...t?.applied===!0?{applied:!0}:{},...m?{updated_document_id:m}:{}}}function _W(e){return e.length>12?`${e.slice(0,4)}…${e.slice(-4)}`:e}function vW(e){return e.kind===`store_document`?e.name||_W(e.document_id):e.path}const yW=[`[&_h1]:text-base [&_h2]:text-base [&_h3]:text-base [&_h4]:text-base [&_h5]:text-base [&_h6]:text-base`,`[&_h1]:leading-snug [&_h2]:leading-snug [&_h3]:leading-snug`,`[&_:first-child]:mt-0 [&_:last-child]:mb-0`].join(` `);function bW({children:e,className:n}){return t(`pre`,{className:z(`m-0 max-h-48 overflow-auto whitespace-pre-wrap font-mono text-xs leading-5 text-foreground/80`,n),children:e})}function xW({before:e,after:n}){let r=U(()=>Ht(e,n),[e,n]);return t(bW,{children:r.map((e,n)=>e.type===`removed`?t(`del`,{className:`rounded-xs bg-mixer-destructive/15 text-destructive line-through decoration-destructive/50`,children:e.text},n):e.type===`added`?t(`ins`,{className:`rounded-xs bg-mixer-success/15 text-success no-underline`,children:e.text},n):t(`span`,{children:e.text},n))})}function SW({action:r}){let{t:i}=K(),a=r.action===`comment`,o=r.applied===!0,s=r.anchor.block_type.replaceAll(`_`,` `),c=a?vv:Zv,l=r.resource.kind===`agent_artifact`?r.resource.run_id:void 0;return n(`div`,{className:`min-w-0 space-y-2 text-start`,"data-document-edit-action":r.action,children:[n(`div`,{className:`flex min-w-0 items-center gap-1.5 text-sm text-muted`,children:[t(c,{className:`size-4 shrink-0`,"aria-hidden":`true`}),t(`span`,{className:`shrink-0 font-medium text-foreground`,children:i(a?`agent.documentEditCardComment`:o?`agent.documentEditCardApplied`:`agent.documentEditCardDirectEdit`)}),t(`span`,{"aria-hidden":`true`,children:`·`}),t(`span`,{className:`shrink-0 capitalize`,children:s}),t(`span`,{"aria-hidden":`true`,children:`·`}),t(`span`,{className:`truncate`,children:vW(r.resource)})]}),a?n(e,{children:[r.comment?t(dW,{artifactRunId:l,disableCollapse:!0,className:yW,children:r.comment}):null,t(dW,{artifactRunId:l,disableCollapse:!0,className:z(`border-s-2 border-mixer-muted/30 ps-3 text-foreground/70`,yW),children:r.anchor.exact_text})]}):t(xW,{before:r.user_change?.before??r.anchor.exact_text,after:r.user_change?.after??``})]})}const CW=`Brewing some code magic...(Doing the robot dance...(Cooking up something good...(Working my gears...(Parsing the possibilities...(Crunching the numbers...(Connecting the digital dots...(Processing at maximum capacity...(Searching through my circuits...(Running advanced algorithms...(Computing optimal solutions...(Loading brilliance.exe...(Scanning the knowledge base...(Optimizing response protocols...(Having a quick brainstorm...(Thinking cap firmly on...(Pondering the digital universe...(Consulting my silicon wisdom...(Untangling the logic knots...(Assembling clever responses...(Mixing thoughtful ingredients...(Polishing the perfect answer...(Taking a momentary mind sprint...(Connecting virtual synapses...(Baking fresh ideas...(Stirring the thought pot...(Simmering solutions slowly...(Whipping up a smart response...(Adding a dash of intelligence...(Preparing a gourmet answer...(Growing brilliant ideas...(Cultivating the perfect response...(Gathering digital nectar...(Planting seeds of solutions...(Exploring the data landscape...(Mapping the solution path...(Navigating through possibilities...(Charting the course to answers...(Embarking on a thought expedition...(Sketching out concepts...(Painting with digital brushstrokes...(Composing my response symphony...(Crafting precision answers...(Weaving threads of information...(Just a moment of processing...(Taking a quick thinking break...(Almost there, final touches...(Putting the pieces together...(Making progress, hold tight...`.split(`(`);function wW(e,t){if(e.startsWith(t))return e.slice(t.length).split(/[/?#]/,1)[0]||void 0}function TW(e={}){let{StoreLinkComponent:n,CollectionLinkComponent:r,addStickyParams:i}=e;return function({node:e,ref:a,...o}){let s=o.href||``,c=s.startsWith(`/`)&&!s.startsWith(`//`),l=c&&i?i(s):s,u=c?wW(s,`/store/objects/`):void 0;if(u&&n)return t(n,{href:l,documentId:u,className:o.className,children:o.children});let d=c?wW(s,`/store/collections/`):void 0;return d&&r?t(r,{href:l,collectionId:d,className:o.className,children:o.children}):c?t(Zn,{href:l,className:o.className,topLevelNav:!0,children:o.children}):t(`a`,{...o,target:`_blank`,rel:`noopener noreferrer`})}}Q();const EW=dt(null);function DW(){return _t(EW)||{openImage:e=>window.open(e,`_blank`),closeImage:()=>{}}}function OW({children:e}){let[r,i]=G(null),a=V((e,t)=>{i({src:e,alt:t})},[]),s=V(()=>{i(null)},[]),{t:c}=K();return n(EW.Provider,{value:{openImage:a,closeImage:s},children:[e,r&&t(`div`,{role:`button`,tabIndex:-1,"aria-label":c(`agent.close`),className:`fixed inset-0 z-[100] flex items-center justify-center bg-black/80 backdrop-blur-sm`,onClick:s,onKeyDown:qe(s),children:n(`div`,{className:`relative max-w-[90vw] max-h-[90vh]`,children:[t(`img`,{src:r.src,alt:r.alt||c(`agent.enlargedView`),className:`max-w-full max-h-[90vh] object-contain rounded-lg shadow-2xl`}),t(o,{variant:`unstyled`,className:`absolute top-2 end-2 text-white bg-black/50 rounded-full p-2 hover:bg-black/70 transition-colors`,onClick:s,title:c(`agent.close`),children:t(Gb,{className:`size-6`})}),t(`a`,{href:r.src,target:`_blank`,rel:`noopener noreferrer`,className:`absolute bottom-2 end-2 text-white bg-black/50 rounded-full p-2 hover:bg-black/70 transition-colors`,onClick:e=>e.stopPropagation(),title:c(`agent.openInNewTab`),children:t(Dg,{className:`size-5`})})]})})]})}Q();const kW=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`svg`]),AW=new Set([`css`,`csv`,`html`,`js`,`json`,`jsx`,`log`,`md`,`mjs`,`sql`,`ts`,`tsx`,`txt`,`xml`,`yaml`,`yml`]);function jW(e){let t=e?.split(/[?#]/)[0]??``;return t.includes(`.`)?(t.split(`.`).pop()??``).toLowerCase():``}function MW(e){return e.contentType?.toLowerCase().startsWith(`image/`)?!0:kW.has(jW(e.artifactPath||e.href||e.name))}function NW(e){let t=e.contentType?.toLowerCase()??``;return t.startsWith(`text/`)||t===`application/json`||t.includes(`xml`)?!0:AW.has(jW(e.artifactPath||e.href||e.name))}function PW(e){if(e.artifactPath)return e.artifactPath;if(e.href?.startsWith(`artifact:`))return e.href.slice(9)}function FW(e){let t=e.split(`/store/objects/`)[1];return t?t.split(/[?#]/)[0]:e.replace(/^store:/,``).replace(/^document:(?:\/\/)?/,``).split(/[?#]/)[0]}function IW(e){return e.split(`/store/collections/`)[1]||e.replace(/^collection:/,``)}function LW(e){return!!(e?.includes(`/store/objects/`)||e?.startsWith(`store:`)||e?.startsWith(`document:`))}function RW(e){return!!(e?.includes(`/store/collections/`)||e?.startsWith(`collection:`))}function zW({item:n,children:r,onOpenArtifact:i,StoreLinkComponent:a,CollectionLinkComponent:o}){let s=n.href;if(!s)return t(e,{children:r});let c=PW(n);if(c&&/\.md$/i.test(c)&&i)return t(`button`,{type:`button`,className:`max-w-full text-start`,onClick:()=>i(c),children:r});if(LW(s)){let e=FW(s);return a?t(a,{href:s,documentId:e,children:r}):t(`a`,{href:s.startsWith(`store:`)||s.startsWith(`document:`)?`/store/objects/${e}`:s,children:r})}if(RW(s)){let e=IW(s);return o?t(o,{href:s,collectionId:e,children:r}):t(`a`,{href:s.startsWith(`collection:`)?`/store/collections/${e}`:s,children:r})}return/^https?:\/\//.test(s)||s.startsWith(`/`)?t(`a`,{href:s,target:s.startsWith(`/`)?void 0:`_blank`,rel:`noopener noreferrer`,children:r}):t(e,{children:r})}function BW({item:e,artifactRunId:r,variant:i,onRemove:a,onOpenArtifact:s,StoreLinkComponent:c,CollectionLinkComponent:l}){let{t:u}=K(),d=_t(on),f=VS(),{openImage:p}=DW(),m=PW(e),h=MW(e),g=h&&!NW(e),[_,v]=G(e.previewUrl);H(()=>{v(e.previewUrl)},[e.previewUrl]),H(()=>{if(!g||e.previewUrl||!r||!m||!d?.client)return;let t=!1,n=US(r,m,`inline`);return(async()=>{let e=f?await f.getOrFetch(n,async()=>(await d.client.files.getArtifactDownloadUrl(r,m,`inline`)).url):(await d.client.files.getArtifactDownloadUrl(r,m,`inline`)).url;t||v(e)})().catch(()=>{t||v(void 0)}),()=>{t=!0}},[m,r,e.previewUrl,d?.client,g,f]);let y={attention:`bg-attention/15 text-attention`,destructive:`bg-destructive/15 text-destructive`,info:`bg-info/15 text-info`,muted:`bg-muted text-muted`,success:`bg-success/15 text-success`}[e.statusTone??`muted`],b=!!(a&&e.removable!==!1),x=t=>{t.stopPropagation(),t.preventDefault(),a?.(e.id)},S=b?t(o,{variant:`unstyled`,size:`none`,"aria-label":u(`agent.removeFile`,{name:e.name}),onClick:x,className:z(`absolute -end-1.5 -top-1.5 inline-flex size-5 items-center justify-center rounded-full`,`border border-border bg-background text-muted shadow-sm transition-colors hover:text-foreground`),children:t(Gb,{className:`size-3`,"aria-hidden":`true`})}):null,C=b?t(o,{variant:`unstyled`,size:`none`,"aria-label":u(`agent.removeFile`,{name:e.name}),onClick:x,className:z(`-me-1 inline-flex size-6 shrink-0 items-center justify-center rounded-md text-muted`,`transition-colors hover:bg-mixer-muted/30 hover:text-foreground`),children:t(Gb,{className:`size-3.5`,"aria-hidden":`true`})}):null,w=g&&_?t(o,{type:`button`,variant:`unstyled`,size:`none`,onClick:t=>{t.stopPropagation(),t.preventDefault(),p(_,e.name)},"aria-label":e.name,title:u(`agent.enlargedView`),className:z(`group shrink-0 overflow-hidden rounded border border-border/60 p-0`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,i===`composer`?`size-6`:`size-24`),children:t(`img`,{src:_,alt:e.name,className:`h-full w-full object-cover transition-transform group-hover:scale-[1.05]`})}):t(h?D_:Gg,{className:`size-3.5 shrink-0 text-muted`,"aria-hidden":`true`}),T=n(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1.5`,children:[w,t(`span`,{className:z(`truncate`,i===`composer`?`max-w-[14rem]`:`max-w-[16rem]`),children:e.name}),e.statusLabel?t(`span`,{className:z(`shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium`,y),children:e.statusLabel}):null]});if(i===`composer`)return n(`span`,{title:e.name,className:z(`inline-flex min-h-8 max-w-full items-center gap-1 rounded-xl border border-border/60`,`bg-mixer-muted/15 px-2.5 py-1 text-sm text-foreground/80 transition-colors`,e.href&&`hover:bg-mixer-muted/25`),children:[t(zW,{item:e,StoreLinkComponent:c,CollectionLinkComponent:l,children:T}),C]});let E=t(`span`,{title:e.name,className:z(`inline-flex max-w-full items-center gap-1.5 rounded-md border border-border/60 bg-mixer-muted/15`,`px-2.5 py-1.5 text-xs text-foreground/80 transition-colors`,e.href&&`hover:bg-mixer-muted/25`),children:T});return n(`span`,{className:`relative inline-flex max-w-full`,children:[t(zW,{item:e,onOpenArtifact:s,StoreLinkComponent:c,CollectionLinkComponent:l,children:E}),S]})}function VW({items:e,artifactRunId:r,className:i,align:a=`start`,variant:s=`message`,onRemove:c,onOpenArtifact:l,StoreLinkComponent:u,CollectionLinkComponent:d}){let{t:f}=K(),[p,m]=G(!1),h=vt(),g=s===`composer`&&e.length>3,_=g&&!p?e.slice(0,3):e,v=e.length-3;return H(()=>{e.length<=3&&m(!1)},[e.length]),e.length===0?null:n(`div`,{id:h,className:z(`flex flex-wrap gap-2`,a===`end`&&`justify-end`,i),children:[_.map(e=>t(BW,{item:e,artifactRunId:r,variant:s,onRemove:c,onOpenArtifact:l,StoreLinkComponent:u,CollectionLinkComponent:d},e.id)),g&&n(o,{type:`button`,variant:`ghost`,size:`sm`,"aria-controls":h,"aria-expanded":p,onClick:()=>m(e=>!e),className:`h-8 shrink-0 gap-1 rounded-xl px-2.5 text-xs text-muted`,children:[!p&&n(`span`,{children:[`+`,v]}),f(p?`agent.showLess`:`agent.showMore`),t(rh,{className:z(`size-3.5 transition-transform`,p&&`rotate-180`),"aria-hidden":`true`})]})]})}const HW=/^\s*(?:\*\*)?(attachments|uploaded artifacts):(?:\*\*)?\s*$/i,UW=/\s/,WW=[`image -`,`text extracted to `];function GW(e){let t=e;if((t.startsWith(`-`)||t.startsWith(`*`))&&(t=t.slice(1).trimStart()),!t.startsWith(`[`)||!t.endsWith(`)`))return null;let n=t.indexOf(`]`);if(n<2||t[n+1]!==`(`)return null;let r=t.slice(1,n),i=t.slice(n+2,-1);for(let e=i.lastIndexOf(`(`);e>0;e=i.lastIndexOf(`(`,e-1)){let t=e;for(;t>0&&UW.test(i[t-1]);)t--;if(t===e||t<2||i[t-1]!==`)`)continue;let n=i.slice(e+1);if(WW.some(e=>n.startsWith(e)))return{name:r,href:i.slice(0,t-1),note:n}}return i?{name:r,href:i}:null}function KW(e){let t=e.split(/\r?\n/),n=[],r=[],i=!1;for(let e of t){let t=e.trim();if(HW.test(t)){i=!0;continue}if(!i){n.push(e);continue}if(!t)continue;let a=GW(t);if(!a){i=!1,n.push(e);continue}let{name:o,href:s,note:c}=a,l=s.startsWith(`artifact:`)?s.slice(9):void 0;r.push({id:`${s}-${r.length}`,name:o,href:s,artifactPath:l,contentType:c?.toLowerCase().includes(`image`)?`image/*`:void 0})}return{body:n.join(`
954
+ `).trim(),attachments:r}}function qW(e){let t=new Set;for(let n of e)if(!(n.type!==J.QUESTION||n.details?._optimistic||typeof n.message!=`string`))for(let e of KW(n.message).attachments)e.href&&t.add(e.href),e.artifactPath&&t.add(e.artifactPath);return t}Q();function JW({message:e,batchData:r,isRunning:i=!1,className:a,headerClassName:s,senderClassName:c,progressBarClassName:l,itemListClassName:u,itemClassName:d,summaryClassName:f}){let[p,m]=G(!1),h=nt(),{t:g}=K(),{tool_name:_,total:v,completed:y,succeeded:b,failed:x,items:S,started_at:C,completed_at:w}=r,T=v>0?y/v*100:0,E=x>0,D=y===v&&!i,O=i||!D?`running`:x===v?`error`:x>0?`warning`:`completed`,k=()=>i||!D?t(aW,{size:`sm`,color:`blue`}):O===`completed`?t(Nh,{className:`size-4 text-success`}):O===`error`||O===`warning`?t(Ah,{className:`size-4 text-destructive`}):t(N_,{className:`size-4 text-done`}),A=()=>O===`completed`?`border-s-success`:O===`error`?`border-s-destructive`:O===`warning`?`border-s-attention`:`border-s-info`,j=()=>E?`bg-attention`:D?`bg-success`:`bg-primary`,M=()=>{let e=JSON.stringify(r,null,2);navigator.clipboard.writeText(e).then(()=>{h({status:`success`,title:g(`agent.copiedBatchDetails`),duration:2e3})})},N=((w?w-C:Date.now()-C)/1e3).toFixed(1);return n(`div`,{className:z(`border-s-4 shadow-md overflow-hidden bg-white dark:bg-muted mb-5`,A(),a),children:[n(`div`,{role:`button`,tabIndex:0,"aria-expanded":p,className:z(`flex items-center justify-between px-4 py-2 border-b border-border/80 bg-info/50 dark:bg-info/10 cursor-pointer`,s),onClick:()=>m(!p),onKeyDown:qe(()=>m(!p)),children:[n(`div`,{className:`flex items-center gap-2`,children:[k(),t(`span`,{className:z(`text-xs font-medium text-muted`,c),children:g(`agent.batch`)}),t(`span`,{className:`text-xs text-info font-medium`,children:_}),n(`span`,{className:`text-xs text-muted`,children:[y,`/`,v]}),p?t(rh,{className:`size-3 text-muted`}):t(lh,{className:`size-3 text-muted cn-rtl-flip`})]}),n(`div`,{className:`flex items-center gap-2`,children:[n(`span`,{className:`text-xs text-muted`,children:[N,`s`]}),t(`span`,{className:`text-xs text-muted`,children:WD(C).format(`HH:mm:ss`)}),t(o,{variant:`ghost`,size:`xs`,onClick:e=>{e.stopPropagation(),M()},className:`text-muted`,title:g(`agent.copyBatchDetails`),children:t(fg,{className:`size-3`})})]})]}),t(`div`,{className:z(`px-4 py-2 bg-muted/50 dark:bg-muted/30`,l),children:n(`div`,{className:`flex items-center gap-3`,children:[t(`div`,{className:`flex-1 h-2 bg-muted rounded-full overflow-hidden`,children:t(`div`,{className:`h-full ${j()} transition-all duration-300 ease-out`,style:{width:`${T}%`}})}),n(`div`,{className:`flex items-center gap-2 text-xs`,children:[b>0&&n(`span`,{className:`text-success flex items-center gap-1`,children:[t(Nh,{className:`size-3`}),b]}),x>0&&n(`span`,{className:`text-destructive flex items-center gap-1`,children:[t(Ah,{className:`size-3`}),x]}),i&&y<v&&n(`span`,{className:`text-info flex items-center gap-1`,children:[t(ev,{className:`size-3 animate-spin`}),v-y]})]})]})}),p&&S.length>0&&t(`div`,{className:z(`max-h-64 overflow-y-auto`,u),children:S.map(e=>n(`div`,{className:z(`flex items-center gap-2 px-4 py-1.5 text-xs border-b border-border last:border-b-0 hover:bg-muted`,d),children:[n(`div`,{className:`w-4 flex-shrink-0`,children:[e.status===`success`&&t(Nh,{className:`size-3 text-success`}),e.status===`error`&&t(Ah,{className:`size-3 text-destructive`}),e.status===`running`&&t(ev,{className:`size-3 text-info animate-spin`}),e.status===`pending`&&t(`div`,{className:`size-3 rounded-full border border-border`})]}),t(`span`,{className:`font-mono text-muted w-24 truncate flex-shrink-0`,title:e.id,children:e.id}),t(`span`,{className:`text-muted truncate flex-1`,title:e.message,children:e.message||(e.status===`pending`?g(`agent.waiting`):``)}),e.duration_ms!==void 0&&n(`span`,{className:`text-muted flex-shrink-0`,children:[(e.duration_ms/1e3).toFixed(1),`s`]})]},e.id))}),!p&&e.message&&t(`div`,{className:z(`px-4 py-2 text-xs text-muted`,f),children:e.message})]})}const YW=gt(JW,(e,t)=>e.isRunning===t.isRunning&&e.batchData.completed===t.batchData.completed&&e.batchData.succeeded===t.batchData.succeeded&&e.batchData.failed===t.batchData.failed);Q();const XW={sending:{icon:rg,className:`text-muted/70`},received:{icon:eh,className:`text-info`},consumed:{icon:Zm,className:`text-success`},failed:{icon:Ah,className:`text-destructive`}};function ZW(e){return e===`sending`||e===`received`||e===`consumed`||e===`failed`}function QW(e){if(e.type!==J.QUESTION&&!QH(e))return;let t=e.details?._deliveryStatus;if(ZW(t))return t;if(e.details?.ack)return`consumed`}function $W(e,t){switch(t){case`sending`:return e(`agent.messageSending`);case`received`:return e(`agent.messageReceived`);case`consumed`:return e(`agent.messageConsumed`);case`failed`:return e(`agent.messageFailed`)}return t}function eG({message:e,className:n}){let{t:r}=K(),i=QW(e);if(!i)return null;let a=XW[i],o=a.icon,s=$W(r,i);return t(We,{description:s,asChild:!0,children:t(`span`,{"aria-label":s,className:z(`inline-flex h-5 w-5 items-center justify-center`,a.className,n),role:`img`,children:t(o,{className:`size-3.5`,"aria-hidden":`true`})})})}function tG(e){return e.content?.name||e.name}function nG({client:e,toast:t}){let n=Xt.getFixedT(null,Yt),[r,i]=G(!1),a=V(async(r,a)=>{if(r){i(!0);try{rG((await e.files.getDownloadUrlWithOptions({file:r,name:a})).url,a)}catch(e){t({status:`error`,title:n(`store.downloadFailed`),description:e instanceof Error?e.message:n(`store.failedToGetDownloadUrl`),duration:5e3})}finally{i(!1)}}},[e,t,n]),o=V((e,t)=>{e&&rG(e,t)},[]),s=V(async(t,n)=>{let r=await(`store`in e?e.store:e).rendering.render(t);if(r.download_url)rG(r.download_url,n);else if(r.file_uri)rG((await e.files.getDownloadUrlWithOptions({file:r.file_uri,name:n})).url,n);else throw Error(`No download URL or file URI in response`)},[e]);return{downloadFromContentSource:a,downloadFromUrl:o,renderDocument:V(async(e,r)=>{i(!0);try{let i=`${r.title||`document`}.${r.format}`;await s({object_id:e,format:r.format,title:r.title,pandoc_options:r.pandocOptions,use_default_template:r.useDefaultTemplate,template_path:r.templateObjectId?`store:${r.templateObjectId}`:void 0},i),t({status:`success`,title:n(`store.documentExported`),description:n(`store.successfullyExportedTo`,{format:r.format.toUpperCase()}),duration:2e3})}catch(e){t({status:`error`,title:n(`store.exportFailed`),description:e instanceof Error?e.message:n(`store.failedToExportDocument`),duration:5e3})}finally{i(!1)}},[s,t,n]),renderContent:V(async(e,r)=>{i(!0);try{let i=`${r.title||`export`}.${r.format}`;await s({content:e,format:r.format,title:r.title,artifact_run_id:r.artifactRunId,pandoc_options:r.pandocOptions},i),t({status:`success`,title:n(`store.contentExported`),description:n(`store.successfullyExportedTo`,{format:r.format.toUpperCase()}),duration:2e3})}catch(e){t({status:`error`,title:n(`store.exportFailed`),description:e instanceof Error?e.message:n(`store.failedToExportContent`),duration:5e3})}finally{i(!1)}},[s,t,n]),isDownloading:r}}function rG(e,t){fetch(e).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.blob()}).then(n=>{let r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=t||iG(e),i.style.display=`none`,document.body.appendChild(i),i.click(),setTimeout(()=>{document.body.removeChild(i),URL.revokeObjectURL(r)},100)}).catch(()=>{let n=document.createElement(`a`);n.href=e,n.download=t||iG(e),n.target=`_blank`,n.rel=`noopener noreferrer`,n.style.display=`none`,document.body.appendChild(n),n.click(),setTimeout(()=>{document.body.removeChild(n)},100)})}function iG(e){try{let t=new URL(e).pathname.split(`/`);return t[t.length-1]||`download`}catch{return`download`}}function aG(e){return e!==void 0&&e>=`0`&&e<=`9`}function oG(e){return e===` `||e===` `}function sG(e){return e!==void 0&&e!==` `&&e!==` `&&e!==`
955
+ `&&e!==`\r`}function cG(e,t){if(t>0&&aG(e[t-1]))return;let n=t;for(;aG(e[n]);)n++;if(n===t||e[n]!==`.`)return;n++;let r=n;for(;oG(e[n]);)n++;return n>r&&sG(e[n])?n:void 0}function lG(e,t){for(let n=t;n<e.length;n++)if(cG(e,n)!==void 0)return n;return-1}function uG(e){let t=lG(e,0);if(t===-1)return e;let n=e.slice(0,t),r=t;for(;r!==-1;){let t=lG(e,cG(e,r)??r+1);if(t===-1){n+=e.slice(r),n+=`
956
956
 
957
- `;break}let i=t;for(;i>r&&aG(e[i-1]);)i--;n+=e.slice(r,i),n+=`
957
+ `;break}let i=t;for(;i>r&&oG(e[i-1]);)i--;n+=e.slice(r,i),n+=`
958
958
 
959
- `,r=t}return n}function uG(e){let t=0;for(;aG(e[t]);)t++;return sG(e,t)!==void 0}function dG(e){if(!e.includes(`
959
+ `,r=t}return n}function dG(e){let t=0;for(;oG(e[t]);)t++;return cG(e,t)!==void 0}function fG(e){if(!e.includes(`
960
960
  `))return e;let t=e.split(`
961
- `),n=!1;return t.map(e=>{let t=n&&e.length>=2&&!iG(e[0])&&e[1]!==`:`?` ${e}`:e;return n=uG(e),t}).join(`
962
- `)}function fG(e,t,n){if(typeof e!=`string`)return e;if(t===J.THOUGHT||typeof n==`string`&&(n.toLowerCase().includes(`thinking about`)||n.toLowerCase().includes(`i'm thinking`)||n.toLowerCase().includes(`💭`))){let t=e;return t=dG(lG(t)),t.includes(`:`)&&!t.includes(`
961
+ `),n=!1;return t.map(e=>{let t=n&&e.length>=2&&!aG(e[0])&&e[1]!==`:`?` ${e}`:e;return n=dG(e),t}).join(`
962
+ `)}function pG(e,t,n){if(typeof e!=`string`)return e;if(t===J.THOUGHT||typeof n==`string`&&(n.toLowerCase().includes(`thinking about`)||n.toLowerCase().includes(`i'm thinking`)||n.toLowerCase().includes(`💭`))){let t=e;return t=fG(uG(t)),t.includes(`:`)&&!t.includes(`
963
963
 
964
964
  `)&&(t=t.replace(/\b(First|Next|Then|Finally|Lastly|Additionally|Step \d+):\s+/gi,`
965
965
 
966
966
  $&`)),t.includes(` - `)&&(t=t.replace(/(^|\S)\s+-\s+/g,`$1
967
967
  - `)),t}return e.includes(`
968
968
 
969
- `)?e:lG(e)}Q();const pG=[`className`,`cardClassName`,`headerClassName`,`contentClassName`,`timestampClassName`,`senderClassName`,`iconClassName`,`detailsClassName`,`artifactsClassName`,`proseClassName`];function mG(e,t,...n){let r={};for(let i of pG)r[i]=z(e[i],t[i],...n.map(e=>e?.[i]));return r}const hG={Ready:`agent.ready`,Error:`agent.error`},gG={[J.ANSWER]:{borderColor:`border-s-info`,iconColor:`text-info`,sender:`Agent`,Icon:Am},[J.COMPLETE]:{borderColor:`border-s-success`,iconColor:`text-success`,sender:`Completed`,Icon:Nh},[J.IDLE]:{borderColor:`border-s-info`,iconColor:`text-info`,sender:`Ready`,Icon:rg},[J.REQUEST_INPUT]:{borderColor:`border-s-attention`,iconColor:`text-attention`,sender:`Input`,Icon:Db},[J.QUESTION]:{borderColor:`border-s-muted`,iconColor:`text-muted`,sender:`User`,Icon:Db},[J.THOUGHT]:{borderColor:`border-s-done`,iconColor:`text-done`,sender:`Agent`,Icon:Am},[J.ERROR]:{borderColor:`border-s-destructive`,iconColor:`text-destructive`,sender:`Error`,Icon:Ah},[J.UPDATE]:{borderColor:`border-s-success`,iconColor:`text-success`,sender:`Update`,Icon:A_},[J.PLAN]:{borderColor:`border-s-attention`,iconColor:`text-attention`,sender:`Plan`,Icon:xv},[J.TERMINATED]:{borderColor:`border-s-muted`,iconColor:`text-muted`,sender:`Terminated`,Icon:Nh},[J.WARNING]:{borderColor:`border-s-attention`,iconColor:`text-attention`,sender:`Warning`,Icon:Ah},[J.SYSTEM]:{borderColor:`border-s-muted`,iconColor:`text-muted`,sender:`System`,Icon:A_},[J.STREAMING_CHUNK]:{borderColor:`border-s-info`,iconColor:`text-info`,sender:`Agent`,Icon:Am},[J.BATCH_PROGRESS]:{borderColor:`border-s-info`,iconColor:`text-info`,sender:`Batch`,Icon:N_},[J.RESTARTING]:{borderColor:`border-s-attention`,iconColor:`text-attention`,sender:`Restarting`,Icon:fy},default:{borderColor:`border-s-muted`,iconColor:`text-muted`,sender:`Agent`,Icon:Am}};function _G({message:e,showPulsatingCircle:r=!1,onSendMessage:a,onOpenArtifact:s,requestInputAnswered:c=!1,className:l,cardClassName:u,headerClassName:d,contentClassName:f,timestampClassName:p,senderClassName:m,iconClassName:h,detailsClassName:g,artifactsClassName:_,proseClassName:v,messageStyleOverrides:y,StoreLinkComponent:b,CollectionLinkComponent:x}){let[S,C]=G(!1),{t:T}=K(),{client:E}=q(),D=nt(),O=VS(),{openImage:k}=EW(),{router:A}=$n(),j=W(E);j.current=E;let M=W(O);M.current=O;let{renderContent:N,isDownloading:P}=tG({client:E,toast:D}),F=U(()=>{let t=gG[e.type]||gG.default,n=y?.default,r=y?.[e.type];return{...t,...n,...r,...mG(t,{className:l,cardClassName:u,headerClassName:d,contentClassName:f,timestampClassName:p,senderClassName:m,iconClassName:h,detailsClassName:g,artifactsClassName:_,proseClassName:v},n,r)}},[e.type,y,l,u,d,f,p,m,h,g,_,v]),I=U(()=>{let t=``;if(e.message&&(t=typeof e.message==`object`?JSON.stringify(e.message,null,2):e.message.trim?e.message.trim():String(e.message)),typeof t==`string`&&t.includes(`%thinking_message%`)){let e=Math.floor(Math.random()*SW.length);t=t.replace(/%thinking_message%/g,SW[e])}return t},[e.message]),L=U(()=>e.type===J.QUESTION?GW(I):null,[I,e.type]),ee=L?.body??I,R=L?.attachments??[],te=U(()=>e.type===J.QUESTION?hW(e.details?.editing_action):void 0,[e.details,e.type]),ne=U(()=>ee?fG(ee,e.type,typeof e.message==`string`?e.message:void 0):``,[ee,e.type,e.message]),re=()=>{let t=I||``,n=typeof e.details==`string`?e.details:e.details?JSON.stringify(e.details,null,2):``,r=[t,n?`\n\nDetails:\n${n}`:``].join(``).trim();navigator.clipboard.writeText(r).then(()=>{D({status:`success`,title:T(`agent.copiedToClipboard`),duration:2e3})})},ie=async t=>{let n=typeof I==`string`?I:``;if(!n.trim()){D({status:`error`,title:T(`agent.noContentToExport`),duration:2e3});return}let r=`Message ${WD(e.timestamp).format(`YYYY-MM-DD HH-mm-ss`)}`;await N(n,{format:t,title:r,artifactRunId:fe})},oe=typeof I==`string`&&I.trim().length>0,se=e.type===J.REQUEST_INPUT?e.details?.ux:void 0,ce=U(()=>({a:wW({StoreLinkComponent:b,CollectionLinkComponent:x,addStickyParams:e=>A.getTopRouter().navigator.addStickyParams(e)}),img:({node:e,ref:n,...r})=>t(o,{variant:`unstyled`,className:`block p-0`,onClick:()=>r.src&&k(r.src,r.alt),"aria-label":r.alt||r.src||`image`,children:t(`img`,{...r,alt:r.alt??``,className:`max-w-full h-auto rounded-lg shadow-md my-3 cursor-pointer hover:shadow-lg transition-shadow`,loading:`lazy`})})}),[k,b,x,A]),le=n=>{if(typeof n==`object`)return t(`pre`,{className:`text-xs font-mono whitespace-pre-wrap overflow-x-auto bg-muted p-2 rounded text-foreground`,children:JSON.stringify(n,null,2)});let r=e.workflow_run_id;return!r&&typeof n==`string`&&n.includes(`artifact:`)&&console.warn(`[MessageItem] message contains artifact references but workflow_run_id is missing!`,{type:e.type,workflow_run_id:e.workflow_run_id,hasArtifact:n.includes(`artifact:`)}),t(`div`,{className:z(`vprose prose prose-slate dark:prose-invert prose-p:leading-relaxed prose-p:my-3 prose-headings:font-semibold prose-headings:tracking-normal prose-headings:mt-6 prose-headings:mb-3 prose-h1:text-xl prose-h2:text-lg prose-h3:text-base prose-li:my-1 prose-ul:my-3 prose-ol:my-3 prose-table:my-5 prose-pre:my-4 prose-hr:my-6 max-w-none text-[15px] break-words`,F.proseClassName),style:{overflowWrap:`anywhere`},children:t(Nt,{artifactRunId:r,onArtifactOpen:s,onProposalSelect:e=>a?.(e),onProposalSubmit:e=>a?.(e),components:ce,children:n})})},[ue,de]=G([]),fe=e.workflow_run_id,pe=e.details,me=pe?.outputFiles??pe?.files;H(()=>{(async()=>{if(!fe||!Array.isArray(me)||me.length===0){de([]);return}let e=j.current,t=M.current;try{let n=await Promise.all(me.map(async n=>{if(typeof n!=`string`||!n.trim())return null;let r=n.trim(),i=r.startsWith(`artifact:`)?r.slice(9):r,a=i.split(`.`).pop()?.toLowerCase()||``,o=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`svg`]).has(a),s=o?`inline`:`attachment`;try{let n=US(fe,i,s),a;return a=t?await t.getOrFetch(n,async()=>(await e.files.getArtifactDownloadUrl(fe,i,s)).url):(await e.files.getArtifactDownloadUrl(fe,i,s)).url,{displayName:r,artifactPath:i,url:a,isImage:o}}catch(e){return console.error(`Failed to resolve artifact URL for ${i}`,e),null}}));de(n.filter(e=>!!e))}catch(e){console.error(`Error loading artifact URLs from message details`,e),de([])}})()},[fe,me]);let he=$H(e),{Icon:ge}=F;return t(`div`,{className:z(`w-full max-w-full`,F.className),children:n(`div`,{className:z(`border-s-4 bg-white dark:bg-muted mb-4 w-full max-w-full overflow-hidden`,F.borderColor,F.cardClassName),"data-workstream-id":he,children:[n(`div`,{className:z(`flex items-center justify-between px-4 py-1.5`,F.headerClassName),children:[n(`div`,{className:`flex items-center gap-1.5`,children:[t(`div`,{className:z(r?`animate-fadeIn`:``,F.iconClassName),children:r?t(iW,{size:`sm`,color:`blue`}):t(ge,{className:`size-4 ${F.iconColor}`})}),t(`span`,{className:z(`text-xs font-medium text-muted`,F.senderClassName),children:hG[F.sender]?T(hG[F.sender]):F.sender}),he!==`main`&&he!==`all`&&t(i,{variant:`default`,className:`text-xs text-muted ms-1`,children:he})]}),n(`div`,{className:`flex items-center gap-1.5 print:hidden`,children:[t($W,{message:e}),t(`span`,{className:z(`text-[11px] text-muted/70`,F.timestampClassName),children:WD(e.timestamp).format(`HH:mm:ss`)}),t(o,{variant:`ghost`,size:`xs`,onClick:re,className:`text-muted/50 hover:text-muted h-5 w-5 p-0`,title:T(`agent.copyMessage`),children:t(fg,{className:`size-3`})}),oe&&n(w,{trigger:t(o,{variant:`ghost`,size:`xs`,className:`text-muted/50 hover:text-muted h-5 w-5 p-0`,title:T(`agent.exportMessage`),disabled:P,children:t(xg,{className:`size-3 ${P?`animate-pulse`:``}`})}),children:[t(ae,{onClick:()=>ie(gn.pdf),children:T(`agent.exportAsPdf`)}),t(ae,{onClick:()=>ie(gn.docx),children:T(`agent.exportAsWord`)})]})]})]}),n(`div`,{className:z(`px-4 pb-3 bg-white dark:bg-muted overflow-hidden`,F.contentClassName),children:[se?t(AH,{question:typeof I==`string`?I:``,options:se.options,variant:se.variant,multiSelect:se.multiSelect,onSelect:t=>LU(a,e,t,WU(e,t)),onMultiSelect:t=>LU(a,e,t.join(`, `)),allowFreeResponse:!se.options?.length||!!se.free_response,placeholder:se.free_response?.placeholder,submitLabel:se.free_response?.submit_label,onSubmit:t=>LU(a,e,t,se.free_response?.metadata),hideBorder:!0,compact:!0,answered:c}):te?t(xW,{action:te}):ee&&t(`div`,{className:`message-content break-words w-full`,style:{overflowWrap:`anywhere`,wordBreak:`break-word`},children:le(ne||ee)}),R.length>0&&t(BW,{items:R,artifactRunId:fe,onOpenArtifact:s,variant:`message`,className:z(ee&&`mt-3`),StoreLinkComponent:b,CollectionLinkComponent:x}),ue.length>0&&n(`div`,{className:z(`mt-3 text-xs`,F.artifactsClassName),children:[t(`div`,{className:`font-medium text-muted mb-1`,children:`Artifacts`}),ue.some(e=>e.isImage)&&t(`div`,{className:`mb-2 flex flex-wrap gap-3`,children:ue.filter(e=>e.isImage).map(({displayName:e,artifactPath:r,url:i})=>n(o,{variant:`unstyled`,className:`max-w-xs cursor-pointer text-start p-0`,onClick:()=>k(i,e),"aria-label":e,children:[t(`img`,{src:i,alt:e,className:`max-w-full h-auto rounded-lg shadow-sm hover:shadow-md transition-shadow`}),t(`div`,{className:`mt-1 text-[11px] text-muted truncate`,children:e})]},`${r}-preview`))}),t(`div`,{className:`flex flex-wrap gap-2 print:hidden`,children:ue.map(({displayName:e,artifactPath:n,url:r})=>t(o,{variant:`outline`,size:`xs`,className:`px-2 py-1 text-xs`,onClick:()=>{if(/\.md$/i.test(n)&&s){s(n);return}window.open(r,`_blank`)},title:n,children:e},n+r))})]}),e.details&&n(`div`,{className:z(`mt-2 print:hidden`,F.detailsClassName),children:[n(o,{variant:`unstyled`,onClick:()=>C(!S),className:`text-[11px] text-muted flex items-center`,children:[T(S?`agent.hideDetails`:`agent.showDetails`),t(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:`h-3 w-3 ms-1 transition-transform ${S?`rotate-180`:``}`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"aria-hidden":`true`,children:t(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M19 9l-7 7-7-7`})})]}),S&&t(`div`,{className:`mt-1 p-1.5 bg-muted border border-mixer-muted/40 rounded text-sm`,children:typeof e.details==`string`?le(e.details):t(`pre`,{className:`text-xs font-mono whitespace-pre-wrap overflow-x-auto bg-muted p-2 rounded text-muted`,children:JSON.stringify(e.details,null,2)})})]})]})]})})}const vG=gt(_G,(e,t)=>e.message.timestamp===t.message.timestamp&&e.message.type===t.message.type&&e.message.message===t.message.message&&e.message.details===t.message.details&&e.message.workstream_id===t.message.workstream_id&&e.message.workflow_run_id===t.message.workflow_run_id&&e.showPulsatingCircle===t.showPulsatingCircle&&e.onSendMessage===t.onSendMessage&&e.onOpenArtifact===t.onOpenArtifact&&e.requestInputAnswered===t.requestInputAnswered&&e.messageStyleOverrides===t.messageStyleOverrides&&pG.every(n=>e[n]===t[n]));Q();const yG={document:vg,collection:Nm,content_type:Jg,interaction:wv,prompt:eb,agent:zm,workflow:zb,process:zb,process_run:zh,interaction_run:zh,view:zv};function bG(e){return yG[e]}function xG(e){switch(e){case`created`:return`success`;case`deleted`:return`outline`;default:return`info`}}function SG({resource:r,workflowRunId:a,showAction:s=!0,className:c}){let{t:l}=K(),u=Kt()(r,{workflowRunId:a,source:`structured`}),d=bG(r.type),f=r.action===`created`?l(`agent.resourceActionCreated`):r.action===`deleted`?l(`agent.resourceActionDeleted`):l(`agent.resourceActionUpdated`),p=n(e,{children:[t(d,{className:`size-3.5 shrink-0 text-foreground`,"aria-hidden":`true`}),t(`span`,{className:`truncate`,children:r.label}),s&&t(i,{variant:xG(r.action),className:`shrink-0 px-1.5 py-0 text-[10px]`,children:f})]}),m=z(`inline-flex max-w-full items-center gap-1.5 rounded-md border border-border bg-background px-2 py-1 text-xs`,c);return u.kind===`navigate`?t(Zn,{href:u.href,topLevelNav:!0,className:z(m,`font-medium transition-colors hover:bg-muted/60`),children:p}):u.kind===`activate`?t(o,{variant:`unstyled`,onClick:u.onActivate,className:z(m,`font-medium transition-colors hover:bg-muted/60`),children:p}):t(`span`,{className:z(m,`text-muted`),children:p})}function CG({resources:e,workflowRunId:r,className:i}){let{t:a}=K();return e.length===0?null:t(`div`,{className:z(`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,i),"data-agent-resource-activity":!0,children:e.map(e=>{let i=e.action===`created`?a(`agent.resourceActionCreated`):e.action===`deleted`?a(`agent.resourceActionDeleted`):a(`agent.resourceActionUpdated`);return n(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[t(`span`,{className:`shrink-0 text-sm text-muted`,children:i}),t(SG,{resource:e,workflowRunId:r,showAction:!1,className:`py-0.5`})]},`${e.type}:${e.id}:${e.action}`)})})}function wG({resources:e,workflowRunId:n,className:r}){return e.length===0?null:t(`div`,{className:z(`flex flex-wrap gap-1.5`,r),children:e.map(e=>t(SG,{resource:e,workflowRunId:n},`${e.type}:${e.id}:${e.action}`))})}function TG({resources:e,workflowRunId:r,className:i}){let{t:a}=K(),[s,c]=G(!1);if(e.length===0)return null;let l=e.length>5,u=l&&!s?e.slice(0,5):e;return n(`div`,{className:z(`mx-auto w-full max-w-3xl py-2`,i),"data-agent-resource-summary":!0,children:[t(`div`,{className:`mb-2 text-xs font-medium text-muted`,children:a(`agent.resourcesChanged`)}),t(wG,{resources:u,workflowRunId:r}),l&&t(o,{variant:`outline`,size:`xs`,className:`mt-2`,onClick:()=>c(e=>!e),children:s?a(`agent.resourceShowLess`):a(`agent.resourceViewAll`,{total:e.length})})]})}function EG(e){let t=[],n=new Map;for(let r of e)for(let e of Dn(r)){let r=`${e.type}:${e.id}`,i=n.get(r);i||(i={ref:e,firstAction:e.action,lastAction:e.action,createdInTurn:!1},n.set(r,i),t.push(r)),i.ref=e,i.lastAction=e.action,e.action===`created`&&(i.createdInTurn=!0)}let r=[];for(let e of t){let t=n.get(e);if(!t||t.firstAction===`created`&&t.lastAction===`deleted`)continue;let i=t.lastAction===`deleted`?`deleted`:t.lastAction===`created`||t.createdInTurn?`created`:`updated`;r.push({...t.ref,action:i})}return r}function DG(e){if(e.length===0)return[];let t=[],n=[],r=!1;for(let i of e)i.type===J.QUESTION&&r&&(t.push(n),n=[],r=!1),i.type===J.QUESTION&&(r=!0),n.push(i);return n.length>0&&t.push(n),t.map(EG)}function OG(e){if(!XH(e))return!0;let t=e.filter(e=>$H(e)===`main`);return t[t.length-1]?.type===J.ANSWER}function kG(e,t,n,r){if(n.length===0)return e;let i=[],a=e=>{let t=n[e];!t||t.length===0||e>=n.length-1&&!r||i.push({type:`resource_summary`,key:`resource-summary-${e}`,resources:t})},o=0;for(let n of e){let e=t(n);e&&o>0&&a(o-1),e&&(o+=1),i.push(n)}return a(o>0?o-1:n.length-1),i}Q();function AG({text:e,workstreamId:r,artifactRunId:i,revealSpeed:a=300,isComplete:s=!1,timestamp:c,className:l,cardClassName:u,headerClassName:d,contentClassName:f,proseClassName:p,senderClassName:m,iconClassName:h}){let{t:g}=K(),[_,v]=G(0),[y,b]=G(``),x=W(null),S=W(e.length),C=W(0),w=W(c||Date.now()),T=W(e),E=W(0),D=W(performance.now()),O=W(a),k=W(0);H(()=>{let t=performance.now(),n=e.length-E.current,r=t-D.current;if(n>0&&r>30){let e=n/r*1e3;O.current=O.current*.8+e*.2,O.current=Math.max(50,Math.min(2e3,O.current))}E.current=e.length,D.current=t},[e.length]),S.current=e.length,T.current=e;let A=V(()=>{let e=performance.now(),t=n=>{let r=n-e;e=n;let i=S.current-C.current;if(i<=0){k.current=0,x.current=null;return}let a;if(s)a=Math.max(500,O.current*2);else if(i<20)a=O.current*.85;else if(i<100)a=O.current;else if(i<500){let e=(i-100)/400;a=O.current*(1+e*.5)}else a=O.current*2;let o=a*r/1e3+k.current,c=Math.floor(o);k.current=o-c,c>0&&(C.current=Math.min(C.current+c,S.current),v(C.current)),x.current=requestAnimationFrame(t)};x.current=requestAnimationFrame(t)},[s]);H(()=>(e.length>C.current&&!x.current&&A(),()=>{x.current&&=(cancelAnimationFrame(x.current),null)}),[e.length,A]),H(()=>{s&&C.current<e.length&&(x.current&&=(cancelAnimationFrame(x.current),null),A())},[s,e.length,A]);let j=W(null),M=W(0);H(()=>{(_>=S.current||s)&&(b(T.current.slice(0,_)),M.current=_)},[_,s]);let N=_<e.length&&!s;H(()=>{if(!N){j.current&&=(clearInterval(j.current),null);return}return j.current||=window.setInterval(()=>{let e=C.current;e>M.current&&(b(T.current.slice(0,e)),M.current=e)},33),()=>{j.current&&=(clearInterval(j.current),null)}},[N]);let P=nt(),F=U(()=>WD(w.current).format(`HH:mm:ss`),[]),I=_<e.length,L=U(()=>{let t=y||e.slice(0,_);return I?t+`│`:t},[y,e,_,I]);return e?t(`div`,{className:z(`w-full max-w-full`,l),children:n(`div`,{className:z(`border-s-4 bg-white dark:bg-muted mb-4 border-s-done w-full max-w-full overflow-hidden`,u),"data-workstream-id":r,children:[n(`div`,{className:z(`flex items-center justify-between px-4 py-1.5`,d),children:[n(`div`,{className:`flex items-center gap-1.5`,children:[t(`div`,{className:z(`animate-fadeIn`,h),children:I?t(`span`,{className:`size-2 rounded-full bg-primary animate-pulse inline-block`}):t(Am,{className:`size-4 text-done`})}),t(`span`,{className:z(`text-xs font-medium text-muted`,m),children:`Agent`}),r&&r!==`main`&&n(`span`,{className:`text-xs text-muted`,children:[`• Task `,r]})]}),n(`div`,{className:`flex items-center gap-2 text-muted`,children:[t(`span`,{className:`text-[11px]`,children:F}),t(o,{variant:`ghost`,size:`xs`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>{P({status:`success`,title:g(`agent.copiedToClipboard`),duration:2e3})})},className:`size-6 p-0 hover:bg-muted`,title:g(`agent.copyMessage`),children:t(fg,{className:`size-3`})})]})]}),n(`div`,{className:z(`px-3 pb-2 streaming-content`,I&&`streaming-active`,f),children:[t(`div`,{className:z(`vprose prose prose-slate dark:prose-invert prose-p:leading-relaxed prose-p:my-3 prose-headings:font-semibold prose-headings:tracking-normal prose-headings:mt-6 prose-headings:mb-3 prose-h1:text-xl prose-h2:text-lg prose-h3:text-base prose-li:my-1 prose-ul:my-3 prose-ol:my-3 prose-table:my-5 prose-pre:my-4 prose-hr:my-6 max-w-none text-[15px] break-words`,p),style:{overflowWrap:`anywhere`},children:t(Nt,{artifactRunId:i,children:L})}),t(`style`,{children:`
969
+ `)?e:uG(e)}Q();const mG=[`className`,`cardClassName`,`headerClassName`,`contentClassName`,`timestampClassName`,`senderClassName`,`iconClassName`,`detailsClassName`,`artifactsClassName`,`proseClassName`];function hG(e,t,...n){let r={};for(let i of mG)r[i]=z(e[i],t[i],...n.map(e=>e?.[i]));return r}const gG={Ready:`agent.ready`,Error:`agent.error`},_G={[J.ANSWER]:{borderColor:`border-s-info`,iconColor:`text-info`,sender:`Agent`,Icon:Am},[J.COMPLETE]:{borderColor:`border-s-success`,iconColor:`text-success`,sender:`Completed`,Icon:Nh},[J.IDLE]:{borderColor:`border-s-info`,iconColor:`text-info`,sender:`Ready`,Icon:rg},[J.REQUEST_INPUT]:{borderColor:`border-s-attention`,iconColor:`text-attention`,sender:`Input`,Icon:Db},[J.QUESTION]:{borderColor:`border-s-muted`,iconColor:`text-muted`,sender:`User`,Icon:Db},[J.THOUGHT]:{borderColor:`border-s-done`,iconColor:`text-done`,sender:`Agent`,Icon:Am},[J.ERROR]:{borderColor:`border-s-destructive`,iconColor:`text-destructive`,sender:`Error`,Icon:Ah},[J.UPDATE]:{borderColor:`border-s-success`,iconColor:`text-success`,sender:`Update`,Icon:A_},[J.PLAN]:{borderColor:`border-s-attention`,iconColor:`text-attention`,sender:`Plan`,Icon:xv},[J.TERMINATED]:{borderColor:`border-s-muted`,iconColor:`text-muted`,sender:`Terminated`,Icon:Nh},[J.WARNING]:{borderColor:`border-s-attention`,iconColor:`text-attention`,sender:`Warning`,Icon:Ah},[J.SYSTEM]:{borderColor:`border-s-muted`,iconColor:`text-muted`,sender:`System`,Icon:A_},[J.STREAMING_CHUNK]:{borderColor:`border-s-info`,iconColor:`text-info`,sender:`Agent`,Icon:Am},[J.BATCH_PROGRESS]:{borderColor:`border-s-info`,iconColor:`text-info`,sender:`Batch`,Icon:N_},[J.RESTARTING]:{borderColor:`border-s-attention`,iconColor:`text-attention`,sender:`Restarting`,Icon:fy},default:{borderColor:`border-s-muted`,iconColor:`text-muted`,sender:`Agent`,Icon:Am}};function vG({message:e,showPulsatingCircle:r=!1,onSendMessage:a,onOpenArtifact:s,requestInputAnswered:c=!1,className:l,cardClassName:u,headerClassName:d,contentClassName:f,timestampClassName:p,senderClassName:m,iconClassName:h,detailsClassName:g,artifactsClassName:_,proseClassName:v,messageStyleOverrides:y,StoreLinkComponent:b,CollectionLinkComponent:x}){let[S,C]=G(!1),{t:T}=K(),{client:E}=q(),D=nt(),O=VS(),{openImage:k}=DW(),{router:A}=$n(),j=W(E);j.current=E;let M=W(O);M.current=O;let{renderContent:N,isDownloading:P}=nG({client:E,toast:D}),F=U(()=>{let t=_G[e.type]||_G.default,n=y?.default,r=y?.[e.type];return{...t,...n,...r,...hG(t,{className:l,cardClassName:u,headerClassName:d,contentClassName:f,timestampClassName:p,senderClassName:m,iconClassName:h,detailsClassName:g,artifactsClassName:_,proseClassName:v},n,r)}},[e.type,y,l,u,d,f,p,m,h,g,_,v]),I=U(()=>{let t=``;if(e.message&&(t=typeof e.message==`object`?JSON.stringify(e.message,null,2):e.message.trim?e.message.trim():String(e.message)),typeof t==`string`&&t.includes(`%thinking_message%`)){let e=Math.floor(Math.random()*CW.length);t=t.replace(/%thinking_message%/g,CW[e])}return t},[e.message]),L=U(()=>e.type===J.QUESTION?KW(I):null,[I,e.type]),ee=L?.body??I,R=L?.attachments??[],te=U(()=>e.type===J.QUESTION?gW(e.details?.editing_action):void 0,[e.details,e.type]),ne=U(()=>ee?pG(ee,e.type,typeof e.message==`string`?e.message:void 0):``,[ee,e.type,e.message]),re=()=>{let t=I||``,n=typeof e.details==`string`?e.details:e.details?JSON.stringify(e.details,null,2):``,r=[t,n?`\n\nDetails:\n${n}`:``].join(``).trim();navigator.clipboard.writeText(r).then(()=>{D({status:`success`,title:T(`agent.copiedToClipboard`),duration:2e3})})},ie=async t=>{let n=typeof I==`string`?I:``;if(!n.trim()){D({status:`error`,title:T(`agent.noContentToExport`),duration:2e3});return}let r=`Message ${WD(e.timestamp).format(`YYYY-MM-DD HH-mm-ss`)}`;await N(n,{format:t,title:r,artifactRunId:pe})},oe=typeof I==`string`&&I.trim().length>0,se=e.type===J.REQUEST_INPUT?e.details?.ux:void 0,ce=DH(se?.options)&&se.options.length>0,le=U(()=>({a:TW({StoreLinkComponent:b,CollectionLinkComponent:x,addStickyParams:e=>A.getTopRouter().navigator.addStickyParams(e)}),img:({node:e,ref:n,...r})=>t(o,{variant:`unstyled`,className:`block p-0`,onClick:()=>r.src&&k(r.src,r.alt),"aria-label":r.alt||r.src||`image`,children:t(`img`,{...r,alt:r.alt??``,className:`max-w-full h-auto rounded-lg shadow-md my-3 cursor-pointer hover:shadow-lg transition-shadow`,loading:`lazy`})})}),[k,b,x,A]),ue=n=>{if(typeof n==`object`)return t(`pre`,{className:`text-xs font-mono whitespace-pre-wrap overflow-x-auto bg-muted p-2 rounded text-foreground`,children:JSON.stringify(n,null,2)});let r=e.workflow_run_id;return!r&&typeof n==`string`&&n.includes(`artifact:`)&&console.warn(`[MessageItem] message contains artifact references but workflow_run_id is missing!`,{type:e.type,workflow_run_id:e.workflow_run_id,hasArtifact:n.includes(`artifact:`)}),t(`div`,{className:z(`vprose prose prose-slate dark:prose-invert prose-p:leading-relaxed prose-p:my-3 prose-headings:font-semibold prose-headings:tracking-normal prose-headings:mt-6 prose-headings:mb-3 prose-h1:text-xl prose-h2:text-lg prose-h3:text-base prose-li:my-1 prose-ul:my-3 prose-ol:my-3 prose-table:my-5 prose-pre:my-4 prose-hr:my-6 max-w-none text-[15px] break-words`,F.proseClassName),style:{overflowWrap:`anywhere`},children:t(Nt,{artifactRunId:r,onArtifactOpen:s,onProposalSelect:e=>a?.(e),onProposalSubmit:e=>a?.(e),components:le,children:n})})},[de,fe]=G([]),pe=e.workflow_run_id,me=e.details,he=me?.outputFiles??me?.files;H(()=>{(async()=>{if(!pe||!Array.isArray(he)||he.length===0){fe([]);return}let e=j.current,t=M.current;try{let n=await Promise.all(he.map(async n=>{if(typeof n!=`string`||!n.trim())return null;let r=n.trim(),i=r.startsWith(`artifact:`)?r.slice(9):r,a=i.split(`.`).pop()?.toLowerCase()||``,o=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`svg`]).has(a),s=o?`inline`:`attachment`;try{let n=US(pe,i,s),a;return a=t?await t.getOrFetch(n,async()=>(await e.files.getArtifactDownloadUrl(pe,i,s)).url):(await e.files.getArtifactDownloadUrl(pe,i,s)).url,{displayName:r,artifactPath:i,url:a,isImage:o}}catch(e){return console.error(`Failed to resolve artifact URL for ${i}`,e),null}}));fe(n.filter(e=>!!e))}catch(e){console.error(`Error loading artifact URLs from message details`,e),fe([])}})()},[pe,he]);let ge=eU(e),{Icon:_e}=F;return t(`div`,{className:z(`w-full max-w-full`,F.className),children:n(`div`,{className:z(`border-s-4 bg-white dark:bg-muted mb-4 w-full max-w-full overflow-hidden`,F.borderColor,F.cardClassName),"data-workstream-id":ge,children:[n(`div`,{className:z(`flex items-center justify-between px-4 py-1.5`,F.headerClassName),children:[n(`div`,{className:`flex items-center gap-1.5`,children:[t(`div`,{className:z(r?`animate-fadeIn`:``,F.iconClassName),children:r?t(aW,{size:`sm`,color:`blue`}):t(_e,{className:`size-4 ${F.iconColor}`})}),t(`span`,{className:z(`text-xs font-medium text-muted`,F.senderClassName),children:gG[F.sender]?T(gG[F.sender]):F.sender}),ge!==`main`&&ge!==`all`&&t(i,{variant:`default`,className:`text-xs text-muted ms-1`,children:ge})]}),n(`div`,{className:`flex items-center gap-1.5 print:hidden`,children:[t(eG,{message:e}),t(`span`,{className:z(`text-[11px] text-muted/70`,F.timestampClassName),children:WD(e.timestamp).format(`HH:mm:ss`)}),t(o,{variant:`ghost`,size:`xs`,onClick:re,className:`text-muted/50 hover:text-muted h-5 w-5 p-0`,title:T(`agent.copyMessage`),children:t(fg,{className:`size-3`})}),oe&&n(w,{trigger:t(o,{variant:`ghost`,size:`xs`,className:`text-muted/50 hover:text-muted h-5 w-5 p-0`,title:T(`agent.exportMessage`),disabled:P,children:t(xg,{className:`size-3 ${P?`animate-pulse`:``}`})}),children:[t(ae,{onClick:()=>ie(gn.pdf),children:T(`agent.exportAsPdf`)}),t(ae,{onClick:()=>ie(gn.docx),children:T(`agent.exportAsWord`)})]})]})]}),n(`div`,{className:z(`px-4 pb-3 bg-white dark:bg-muted overflow-hidden`,F.contentClassName),children:[se?t(jH,{question:typeof I==`string`?I:``,options:ce?se.options:void 0,variant:se.variant,multiSelect:se.multiSelect,onSelect:t=>RU(a,e,t,GU(e,t)),onMultiSelect:t=>RU(a,e,t.join(`, `)),allowFreeResponse:!ce||!!se.free_response,placeholder:se.free_response?.placeholder,submitLabel:se.free_response?.submit_label,onSubmit:t=>RU(a,e,t,se.free_response?.metadata),hideBorder:!0,compact:!0,answered:c}):te?t(SW,{action:te}):ee&&t(`div`,{className:`message-content break-words w-full`,style:{overflowWrap:`anywhere`,wordBreak:`break-word`},children:ue(ne||ee)}),R.length>0&&t(VW,{items:R,artifactRunId:pe,onOpenArtifact:s,variant:`message`,className:z(ee&&`mt-3`),StoreLinkComponent:b,CollectionLinkComponent:x}),de.length>0&&n(`div`,{className:z(`mt-3 text-xs`,F.artifactsClassName),children:[t(`div`,{className:`font-medium text-muted mb-1`,children:`Artifacts`}),de.some(e=>e.isImage)&&t(`div`,{className:`mb-2 flex flex-wrap gap-3`,children:de.filter(e=>e.isImage).map(({displayName:e,artifactPath:r,url:i})=>n(o,{variant:`unstyled`,className:`max-w-xs cursor-pointer text-start p-0`,onClick:()=>k(i,e),"aria-label":e,children:[t(`img`,{src:i,alt:e,className:`max-w-full h-auto rounded-lg shadow-sm hover:shadow-md transition-shadow`}),t(`div`,{className:`mt-1 text-[11px] text-muted truncate`,children:e})]},`${r}-preview`))}),t(`div`,{className:`flex flex-wrap gap-2 print:hidden`,children:de.map(({displayName:e,artifactPath:n,url:r})=>t(o,{variant:`outline`,size:`xs`,className:`px-2 py-1 text-xs`,onClick:()=>{if(/\.md$/i.test(n)&&s){s(n);return}window.open(r,`_blank`)},title:n,children:e},n+r))})]}),e.details&&n(`div`,{className:z(`mt-2 print:hidden`,F.detailsClassName),children:[n(o,{variant:`unstyled`,onClick:()=>C(!S),className:`text-[11px] text-muted flex items-center`,children:[T(S?`agent.hideDetails`:`agent.showDetails`),t(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:`h-3 w-3 ms-1 transition-transform ${S?`rotate-180`:``}`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"aria-hidden":`true`,children:t(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M19 9l-7 7-7-7`})})]}),S&&t(`div`,{className:`mt-1 p-1.5 bg-muted border border-mixer-muted/40 rounded text-sm`,children:typeof e.details==`string`?ue(e.details):t(`pre`,{className:`text-xs font-mono whitespace-pre-wrap overflow-x-auto bg-muted p-2 rounded text-muted`,children:JSON.stringify(e.details,null,2)})})]})]})]})})}const yG=gt(vG,(e,t)=>e.message.timestamp===t.message.timestamp&&e.message.type===t.message.type&&e.message.message===t.message.message&&e.message.details===t.message.details&&e.message.workstream_id===t.message.workstream_id&&e.message.workflow_run_id===t.message.workflow_run_id&&e.showPulsatingCircle===t.showPulsatingCircle&&e.onSendMessage===t.onSendMessage&&e.onOpenArtifact===t.onOpenArtifact&&e.requestInputAnswered===t.requestInputAnswered&&e.messageStyleOverrides===t.messageStyleOverrides&&mG.every(n=>e[n]===t[n]));Q();const bG={document:vg,collection:Nm,content_type:Jg,interaction:wv,prompt:eb,agent:zm,workflow:zb,process:zb,process_run:zh,interaction_run:zh,view:zv};function xG(e){return bG[e]}function SG(e){switch(e){case`created`:return`success`;case`deleted`:return`outline`;default:return`info`}}function CG({resource:r,workflowRunId:a,showAction:s=!0,className:c}){let{t:l}=K(),u=Kt()(r,{workflowRunId:a,source:`structured`}),d=xG(r.type),f=r.action===`created`?l(`agent.resourceActionCreated`):r.action===`deleted`?l(`agent.resourceActionDeleted`):l(`agent.resourceActionUpdated`),p=n(e,{children:[t(d,{className:`size-3.5 shrink-0 text-foreground`,"aria-hidden":`true`}),t(`span`,{className:`truncate`,children:r.label}),s&&t(i,{variant:SG(r.action),className:`shrink-0 px-1.5 py-0 text-[10px]`,children:f})]}),m=z(`inline-flex max-w-full items-center gap-1.5 rounded-md border border-border bg-background px-2 py-1 text-xs`,c);return u.kind===`navigate`?t(Zn,{href:u.href,topLevelNav:!0,className:z(m,`font-medium transition-colors hover:bg-muted/60`),children:p}):u.kind===`activate`?t(o,{variant:`unstyled`,onClick:u.onActivate,className:z(m,`font-medium transition-colors hover:bg-muted/60`),children:p}):t(`span`,{className:z(m,`text-muted`),children:p})}function wG({resources:e,workflowRunId:r,className:i}){let{t:a}=K();return e.length===0?null:t(`div`,{className:z(`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,i),"data-agent-resource-activity":!0,children:e.map(e=>{let i=e.action===`created`?a(`agent.resourceActionCreated`):e.action===`deleted`?a(`agent.resourceActionDeleted`):a(`agent.resourceActionUpdated`);return n(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[t(`span`,{className:`shrink-0 text-sm text-muted`,children:i}),t(CG,{resource:e,workflowRunId:r,showAction:!1,className:`py-0.5`})]},`${e.type}:${e.id}:${e.action}`)})})}function TG({resources:e,workflowRunId:n,className:r}){return e.length===0?null:t(`div`,{className:z(`flex flex-wrap gap-1.5`,r),children:e.map(e=>t(CG,{resource:e,workflowRunId:n},`${e.type}:${e.id}:${e.action}`))})}function EG({resources:e,workflowRunId:r,className:i}){let{t:a}=K(),[s,c]=G(!1);if(e.length===0)return null;let l=e.length>5,u=l&&!s?e.slice(0,5):e;return n(`div`,{className:z(`mx-auto w-full max-w-3xl py-2`,i),"data-agent-resource-summary":!0,children:[t(`div`,{className:`mb-2 text-xs font-medium text-muted`,children:a(`agent.resourcesChanged`)}),t(TG,{resources:u,workflowRunId:r}),l&&t(o,{variant:`outline`,size:`xs`,className:`mt-2`,onClick:()=>c(e=>!e),children:s?a(`agent.resourceShowLess`):a(`agent.resourceViewAll`,{total:e.length})})]})}function DG(e){let t=[],n=new Map;for(let r of e)for(let e of Dn(r)){let r=`${e.type}:${e.id}`,i=n.get(r);i||(i={ref:e,firstAction:e.action,lastAction:e.action,createdInTurn:!1},n.set(r,i),t.push(r)),i.ref=e,i.lastAction=e.action,e.action===`created`&&(i.createdInTurn=!0)}let r=[];for(let e of t){let t=n.get(e);if(!t||t.firstAction===`created`&&t.lastAction===`deleted`)continue;let i=t.lastAction===`deleted`?`deleted`:t.lastAction===`created`||t.createdInTurn?`created`:`updated`;r.push({...t.ref,action:i})}return r}function OG(e){if(e.length===0)return[];let t=[],n=[],r=!1;for(let i of e)i.type===J.QUESTION&&r&&(t.push(n),n=[],r=!1),i.type===J.QUESTION&&(r=!0),n.push(i);return n.length>0&&t.push(n),t.map(DG)}function kG(e){if(!ZH(e))return!0;let t=e.filter(e=>eU(e)===`main`);return t[t.length-1]?.type===J.ANSWER}function AG(e,t,n,r){if(n.length===0)return e;let i=[],a=e=>{let t=n[e];!t||t.length===0||e>=n.length-1&&!r||i.push({type:`resource_summary`,key:`resource-summary-${e}`,resources:t})},o=0;for(let n of e){let e=t(n);e&&o>0&&a(o-1),e&&(o+=1),i.push(n)}return a(o>0?o-1:n.length-1),i}Q();function jG({text:e,workstreamId:r,artifactRunId:i,revealSpeed:a=300,isComplete:s=!1,timestamp:c,className:l,cardClassName:u,headerClassName:d,contentClassName:f,proseClassName:p,senderClassName:m,iconClassName:h}){let{t:g}=K(),[_,v]=G(0),[y,b]=G(``),x=W(null),S=W(e.length),C=W(0),w=W(c||Date.now()),T=W(e),E=W(0),D=W(performance.now()),O=W(a),k=W(0);H(()=>{let t=performance.now(),n=e.length-E.current,r=t-D.current;if(n>0&&r>30){let e=n/r*1e3;O.current=O.current*.8+e*.2,O.current=Math.max(50,Math.min(2e3,O.current))}E.current=e.length,D.current=t},[e.length]),S.current=e.length,T.current=e;let A=V(()=>{let e=performance.now(),t=n=>{let r=n-e;e=n;let i=S.current-C.current;if(i<=0){k.current=0,x.current=null;return}let a;if(s)a=Math.max(500,O.current*2);else if(i<20)a=O.current*.85;else if(i<100)a=O.current;else if(i<500){let e=(i-100)/400;a=O.current*(1+e*.5)}else a=O.current*2;let o=a*r/1e3+k.current,c=Math.floor(o);k.current=o-c,c>0&&(C.current=Math.min(C.current+c,S.current),v(C.current)),x.current=requestAnimationFrame(t)};x.current=requestAnimationFrame(t)},[s]);H(()=>(e.length>C.current&&!x.current&&A(),()=>{x.current&&=(cancelAnimationFrame(x.current),null)}),[e.length,A]),H(()=>{s&&C.current<e.length&&(x.current&&=(cancelAnimationFrame(x.current),null),A())},[s,e.length,A]);let j=W(null),M=W(0);H(()=>{(_>=S.current||s)&&(b(T.current.slice(0,_)),M.current=_)},[_,s]);let N=_<e.length&&!s;H(()=>{if(!N){j.current&&=(clearInterval(j.current),null);return}return j.current||=window.setInterval(()=>{let e=C.current;e>M.current&&(b(T.current.slice(0,e)),M.current=e)},33),()=>{j.current&&=(clearInterval(j.current),null)}},[N]);let P=nt(),F=U(()=>WD(w.current).format(`HH:mm:ss`),[]),I=_<e.length,L=U(()=>{let t=y||e.slice(0,_);return I?t+`│`:t},[y,e,_,I]);return e?t(`div`,{className:z(`w-full max-w-full`,l),children:n(`div`,{className:z(`border-s-4 bg-white dark:bg-muted mb-4 border-s-done w-full max-w-full overflow-hidden`,u),"data-workstream-id":r,children:[n(`div`,{className:z(`flex items-center justify-between px-4 py-1.5`,d),children:[n(`div`,{className:`flex items-center gap-1.5`,children:[t(`div`,{className:z(`animate-fadeIn`,h),children:I?t(`span`,{className:`size-2 rounded-full bg-primary animate-pulse inline-block`}):t(Am,{className:`size-4 text-done`})}),t(`span`,{className:z(`text-xs font-medium text-muted`,m),children:`Agent`}),r&&r!==`main`&&n(`span`,{className:`text-xs text-muted`,children:[`• Task `,r]})]}),n(`div`,{className:`flex items-center gap-2 text-muted`,children:[t(`span`,{className:`text-[11px]`,children:F}),t(o,{variant:`ghost`,size:`xs`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>{P({status:`success`,title:g(`agent.copiedToClipboard`),duration:2e3})})},className:`size-6 p-0 hover:bg-muted`,title:g(`agent.copyMessage`),children:t(fg,{className:`size-3`})})]})]}),n(`div`,{className:z(`px-3 pb-2 streaming-content`,I&&`streaming-active`,f),children:[t(`div`,{className:z(`vprose prose prose-slate dark:prose-invert prose-p:leading-relaxed prose-p:my-3 prose-headings:font-semibold prose-headings:tracking-normal prose-headings:mt-6 prose-headings:mb-3 prose-h1:text-xl prose-h2:text-lg prose-h3:text-base prose-li:my-1 prose-ul:my-3 prose-ol:my-3 prose-table:my-5 prose-pre:my-4 prose-hr:my-6 max-w-none text-[15px] break-words`,p),style:{overflowWrap:`anywhere`},children:t(Nt,{artifactRunId:i,children:L})}),t(`style`,{children:`
970
970
  /* Ensure inline elements flow properly */
971
971
  .streaming-content p:last-child,
972
972
  .streaming-content li:last-child {
@@ -977,11 +977,11 @@ $&`)),t.includes(` - `)&&(t=t.replace(/(^|\S)\s+-\s+/g,`$1
977
977
  mask-image: linear-gradient(to right, black 97%, transparent 100%);
978
978
  -webkit-mask-image: linear-gradient(to right, black 97%, transparent 100%);
979
979
  }
980
- `})]})]})}):null}const jG=ot.memo(AG);function MG(e){return e.message?typeof e.message==`object`?JSON.stringify(e.message,null,2):String(e.message).trim():``}function NG(e){let t=e.replace(/\s+/g,` `).trim().toLowerCase();return t===`thinking`||t===`thinking...`||t===`working`||t===`working...`||t===`waiting`||t===`waiting...`}function PG(e){return e.type===J.THOUGHT&&e.details?.display_role===`thinking`}function FG(e){if(PG(e))return!0;if(e.type!==J.WARNING)return!1;let t=e.details,n=MG(e).replace(/^[^A-Za-z0-9]+/,``).toLowerCase();return typeof t?.attempt==`number`&&typeof t?.maxAttempts==`number`&&typeof t?.estimatedBackoffSeconds==`number`&&typeof t?.activityId==`string`&&(n.startsWith(`retrying operation`)||n.startsWith(`retrying checkpoint operation`))}function IG(e){if(typeof e==`number`)return e;if(!e)return-1/0;let t=new Date(e).getTime();return Number.isFinite(t)?t:-1/0}function LG(e){return e.reduce((e,t)=>Math.max(e,IG(t.timestamp)),-1/0)}function RG(e,t){let n=e.details?.[t];return typeof n==`string`&&n.trim()||void 0}function zG(e,t,n){if(!e.some(FG))return e;if(!t)return e.filter(e=>!FG(e));let r=-1,i=-1;return e.forEach((e,t)=>{FG(e)?i=t:r=t}),e.filter((e,t)=>!FG(e)||t===i&&t>r&&IG(e.timestamp)>=n)}function BG(e){if(zH(e))return!1;let t=MG(e);return!t||NG(t)?!1:e.type===J.ANSWER?!0:uU(e)?e.details?.display_role===`tool_preamble`&&(e.details.tool===`ask_user`||Array.isArray(e.details.tools)&&e.details.tools.some(e=>typeof e==`string`?e===`ask_user`:!e||typeof e!=`object`?!1:`name`in e&&e.name===`ask_user`||`tool`in e&&e.tool===`ask_user`)):e.type===J.THOUGHT&&!!e.details?.streamed}function VG(e){if(e.type!==J.ERROR&&e.type!==J.WARNING)return!1;let t=e.details;return!!(t?.tool||t?.tool_status||t?.tool_run_id||t?.activity_group_id||t?.tool_event)}function HG(e){if(e.type!==J.ERROR||VG(e))return!1;let t=e.details;return MG(e).startsWith(`Error analyzing conversation:`)&&typeof t?.error==`string`}function UG(e){if(e.type!==J.ERROR)return!1;let t=e.details;if(t?.event_class!==`activity`||t.workstream_event)return!1;let n=typeof e.workstream_id==`string`&&e.workstream_id.trim()?e.workstream_id.trim():typeof t.workstream_id==`string`?t.workstream_id.trim():``,r=n.toLowerCase();return!n||r===`main`||r===`all`?!1:!(t.tool||t.tool_status||t.tool_run_id||t.activity_group_id||t.tool_event)}function WG(e){return zH(e)||UG(e)?!1:e.type===J.QUESTION||!!HH(e)||BG(e)||e.type===J.REQUEST_INPUT&&!HU(e)||e.type===J.TERMINATED||(e.type===J.ERROR||e.type===J.WARNING)&&!VG(e)&&!FG(e)}function GG(e){let t=e.details?.tool_status;if(t===`running`||t===`completed`||t===`error`||t===`warning`)return t;if(e.type===J.ERROR)return`error`;if(e.type===J.WARNING)return`warning`}function KG(e,t){for(let n=e.length-1;n>=0;n--){let r=GG(e[n]);if(r===`error`||r===`warning`)return r;if(r)return t?`running`:`completed`}return t?`running`:`completed`}function qG(e,t){return dU(e)&&!PG(e)&&t.length>0&&t.every(PG)}function JG(e){return zH(e)||BG(e)||HH(e)?!1:UG(e)||FG(e)||HU(e)||VG(e)||uU(e)||dU(e)||e.type===J.UPDATE||e.type===J.PLAN?!0:e.type===J.THOUGHT&&!e.details?.streamed}function YG(e,t,n=LG(e)){let r=[],i=[],a=new Set,o=(e,t)=>{if(i.length===0)return;let a=zG(i,e,n);if(a.length===0){i=[];return}let o=a[0],s=a[a.length-1],c=KG(a,e);r.push({type:`work`,id:e?`${o.timestamp}-active`:`${o.timestamp}-${s.timestamp}-${a.length}`,messages:a,isActive:e,status:c,startTimestamp:o.timestamp,endTimestamp:t?.timestamp??s.timestamp}),i=[]};for(let t of e){let e=HH(t),n=e?null:UH(t),s=e??n;if(s){let n=a.has(s.workstreamId);if(a.add(s.workstreamId),e||!n){o(!1,t),r.push({type:`message`,message:t});continue}}if(t.type===J.COMPLETE||t.type===J.IDLE){if(ZH(t)){let e=i[0]?.timestamp;o(!1,t);let n=r[r.length-1];r.push({type:`stopped`,message:t,startTimestamp:e!==void 0&&n?.type===`work`?n.startTimestamp:e??t.timestamp,endTimestamp:t.timestamp});continue}o(!1,t);continue}if(JG(t)||i.length>0&&HG(t)){if(qG(t,i)){let e=r[r.length-1];if(e?.type===`work`&&!e.isActive){r.pop(),i=[...e.messages,t];continue}}i.push(t);continue}WG(t)&&(o(!1,t),r.push({type:`message`,message:t}))}return o(!t),r}function XG(e,t){if(e.activityId){let n=t.find(t=>dU(t)&&(RG(t,`activity_id`)===e.activityId||RG(t,`activity_group_id`)===e.activityId));if(n)return n;let r=t.find(t=>RG(t,`activity_id`)===e.activityId&&RG(t,`activity_group_id`))?.details?.activity_group_id;if(typeof r==`string`){let e=t.find(e=>dU(e)&&RG(e,`activity_group_id`)===r);if(e)return e}}if(e.isComplete)return;let n=IG(e.startTimestamp);if(!Number.isFinite(n))return;let r=[...t].filter(e=>IG(e.timestamp)>=n).sort((e,t)=>IG(e.timestamp)-IG(t.timestamp));for(let e of r){if(IG(e.timestamp)-n>6e4)return;if(dU(e))return e;if(WG(e))return}}function ZG(e,t){if(t.size===0)return e;let n=e.find(e=>e.workflow_run_id)?.workflow_run_id??``,r=[];return t.forEach((t,i)=>{let a=t.text.trim();if(!a||sU(t,e)||RH(a,t.workstreamId))return;let o=XG(t,e),s=o?RG(o,`activity_group_id`):void 0;r.push({timestamp:t.startTimestamp,workflow_run_id:n,type:o?J.THOUGHT:J.ANSWER,message:a,workstream_id:t.workstreamId,details:{activity_id:t.activityId,activity_group_id:s,display_role:o?`tool_preamble`:void 0,source:`streaming_summary`,streamed:!0,streaming_id:i,tools:o?.details?.tool?[o.details.tool]:void 0}})}),r.length===0?e:[...e,...r].sort((e,t)=>IG(e.timestamp)-IG(t.timestamp))}function QG(e,t,n){let r=e[e.length-1];return r?r.type===`work`?r.endTimestamp??r.startTimestamp:r.message.timestamp??n:t.reduce((e,t)=>{let n=IG(t.timestamp);return!Number.isFinite(n)||n>=e.ms?e:{timestamp:t.timestamp,ms:n}},{ms:1/0}).timestamp??n}function $G(e,t,n){if(!t||n||e.some(e=>e.type===`work`&&e.isActive))return!1;let r=e[e.length-1];return r?r.type===`work`||r.message.type===J.QUESTION:!1}function eK(e){let t=e[e.length-1];return t?t.type===`message`&&t.message.type===J.QUESTION&&e.length===1:!1}Q();const tK=new Set([`tool`,`tool_event`,`tool_run_id`,`tool_use_id`,`activity_group_id`,`event_class`,`tool_iteration`,`tool_status`,`message_to_human`,`tools`,`streamed`,`files`,`outputFiles`,`display_role`,`duration_ms`,`observation`,`progress_messages`,`resources`,`browseruse`,`browser_use`]);function nK(e){return e?Object.entries(e).filter(([e,t])=>!tK.has(e)&&t!=null&&t!==``):[]}function rK(e){return e.replace(/_/g,` `).replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/^./,e=>e.toUpperCase())}function iK(e){let t=e?.progress_messages;return Array.isArray(t)?t.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e,n=typeof t.message==`string`?t.message.trim():``;return n?[{message:n,status:typeof t.status==`string`?t.status:void 0,timestamp:typeof t.timestamp==`number`||typeof t.timestamp==`string`?t.timestamp:void 0}]:[]}):[]}function aK(e){return[`progress`,e.timestamp??`no-time`,e.status??`status`,e.message].join(`:`)}function oK(e){let t=e.details,n=typeof t?.tool_run_id==`string`?t.tool_run_id:void 0;if(n)return`tool-run:${n}`;let r=typeof t?.activity_group_id==`string`?t.activity_group_id:void 0,i=typeof t?.tool_use_id==`string`?t.tool_use_id:void 0;return r||i?`tool:${r??`no-activity`}:${i??`no-use`}`:[`message`,e.workstream_id??`main`,e.type,e.timestamp,mK(e)].join(`:`)}function sK(e,t){return e.timestamp===t.timestamp&&e.type===t.type&&e.message===t.message&&e.details===t.details&&e.workstream_id===t.workstream_id&&e.workflow_run_id===t.workflow_run_id}function cK(e){switch(e){case`completed`:return`bg-success text-success border-success`;case`running`:return`bg-info text-info border-info`;case`error`:return`bg-destructive text-destructive border-destructive`;case`warning`:return`bg-attention text-attention border-attention`;default:return``}}function lK(e){let t=new Map,n=[];for(let r of e){let e=r.details?.tool_run_id;e?(t.has(e)||t.set(e,[]),t.get(e)?.push(r)):n.push(r)}for(let[e,r]of t){if(r.length<=1){n.push(...r);continue}r.sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime()));let e=r[r.length-1],t=r.find(e=>e.details?.tool_event===`started`),i=r.find(e=>e.details?.tool_status===`running`),a=t??i??r.find(e=>e.message?.trim()),o=(typeof a?.details?.message_to_human==`string`?a.details.message_to_human:void 0)||a?.message||e.message,s=r.filter(e=>e.details?.tool_event===`progress`&&e.message?.trim()).map(e=>({message:e.message.trim(),status:e.details?.tool_status,timestamp:e.timestamp})),c={};for(let e of r)Object.assign(c,e.details);s.length>0&&(c.progress_messages=s),n.push({...e,message:o,details:c})}return n.sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())),n}const uK=e=>/\.(png|jpg|jpeg|gif|webp|svg)(\?|$)/i.test(e);function dK({files:e,className:r}){let{t:i}=K(),{openImage:a}=EW();return!e||e.length===0?null:t(`div`,{className:z(`mt-2 flex flex-wrap gap-2`,r),children:e.map(e=>{let r=e.split(`/`).pop()?.split(`?`)[0]||`file`;return uK(e)?t(o,{variant:`unstyled`,className:`cursor-pointer p-0`,onClick:()=>a(e,r),title:i(`agent.clickToEnlarge`),"aria-label":r,children:t(`img`,{src:e,alt:r,className:`max-w-[300px] max-h-[200px] rounded border hover:opacity-80 transition-opacity hover:shadow-lg`})},e):n(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 px-2 py-1 bg-muted rounded text-xs hover:bg-muted/80`,children:[`📎 `,r]},e)})})}const fK=e=>{if(!e)return;let t=e.files??e.outputFiles;return Array.isArray(t)?t:void 0},pK=e=>{let t=e.details;return e.type===J.THOUGHT&&t?.display_role===`tool_preamble`},mK=e=>{let t=e.details;if(pK(e))return`assistant`;if(t?.tool)return t.tool;switch(e.type){case J.UPDATE:return`update`;case J.WARNING:return`warning`;case J.ERROR:return`error`;case J.SYSTEM:return`system`;default:return`activity`}},hK=e=>pK(e)?`text-[10px] px-1.5 py-0.5 rounded-md bg-muted text-foreground border border-border font-medium`:`text-[10px] px-1.5 py-0.5 rounded-md bg-done text-done border border-done font-medium`;function gK({message:e,isExpanded:r,onToggle:i,artifactRunId:a,classNames:s={}}){let{t:c}=K(),[l,u]=G([]),d=nt(),{client:f}=q(),p=VS(),m=W(f);m.current=f;let h=W(p);h.current=p;let g=e.details,_=mK(e),v=hK(e),y=fK(g),b=typeof e.message==`string`?e.message:``;H(()=>{if(!y||y.length===0||!a){u([]);return}let e=!1;return(async()=>{let t=m.current,n=h.current,r=await Promise.all(y.map(async e=>{if(!e||typeof e!=`string`)return null;if(e.startsWith(`http://`)||e.startsWith(`https://`))return e;let r=e.startsWith(`artifact:`)?e.slice(9):e,i=r.split(`.`).pop()?.toLowerCase()||``,o=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`svg`]).has(i)?`inline`:`attachment`;try{let e=US(a,r,o);return n?await n.getOrFetch(e,async()=>(await t.files.getArtifactDownloadUrl(a,r,o)).url):(await t.files.getArtifactDownloadUrl(a,r,o)).url}catch(e){return console.error(`Failed to resolve artifact URL for ${r}`,e),null}}));e||u(r.filter(e=>!!e))})(),()=>{e=!0}},[y,a]);let x=l.filter(e=>uK(e)),S=l.filter(e=>!uK(e)),C=()=>{let e=[b,g?`\n\nDetails:\n${JSON.stringify(g,null,2)}`:``].join(``).trim();navigator.clipboard.writeText(e).then(()=>{d({status:`success`,title:c(`agent.copiedToClipboard`),duration:2e3})})};return n(`div`,{className:z(`border-b border-border last:border-b-0`,s.itemClassName),children:[n(`div`,{role:`button`,tabIndex:0,className:z(`flex items-start justify-between px-3 py-2 cursor-pointer hover:bg-muted transition-colors`,s.itemHeaderClassName),onClick:i,onKeyDown:qe(i),children:[n(`div`,{className:`flex items-start gap-2 flex-1 min-w-0`,children:[t(`div`,{className:`flex-shrink-0 pt-0.5`,children:r?t(rh,{className:`size-3 text-muted`}):t(lh,{className:`size-3 text-muted cn-rtl-flip`})}),t(`div`,{className:`flex-1 min-w-0`,children:b?t(`span`,{className:`text-xs text-foreground line-clamp-2`,children:b}):n(`span`,{className:`text-xs text-muted italic`,children:[`Activity: `,_]})})]}),n(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[!r&&t(`span`,{className:z(v,s.toolBadgeClassName),children:_}),t(o,{variant:`ghost`,size:`xs`,onClick:e=>{e.stopPropagation(),C()},className:`text-muted opacity-0 group-hover:opacity-100 transition-opacity`,title:c(`agent.copyMessage`),children:t(fg,{className:`size-3`})})]})]}),x.length>0&&t(`div`,{className:`px-3 pb-1.5`,children:t(dK,{files:x})}),r&&(()=>{let r=g?.tool_status,i=nK(g),o=iK(g);return n(`div`,{className:z(`px-4 py-2 bg-muted/50 dark:bg-muted/30`,s.itemContentClassName),children:[n(`div`,{className:`flex items-center gap-2 mb-2 flex-wrap`,children:[t(`span`,{className:z(v,s.toolBadgeClassName),children:_}),r&&t(`span`,{className:z(`text-[10px] px-1.5 py-0.5 rounded-md border font-medium`,cK(r)),children:r}),t(`span`,{className:`text-[10px] text-muted/70`,children:WD(e.timestamp).format(`HH:mm:ss`)})]}),i.length>0&&t(`div`,{className:`mb-2 space-y-0.5`,children:i.map(([e,r])=>n(`div`,{className:`flex gap-1.5 text-xs`,children:[n(`span`,{className:`text-muted font-medium flex-shrink-0`,children:[rK(e),`:`]}),t(`span`,{className:`text-foreground break-all`,children:typeof r==`object`?JSON.stringify(r):String(r)})]},e))}),o.length>0&&n(`div`,{className:`mb-2 space-y-1`,children:[t(`div`,{className:`text-[10px] uppercase tracking-wide text-muted/70 font-medium`,children:c(`agent.progress`)}),o.map(e=>n(`div`,{className:`text-xs text-muted`,children:[e.timestamp&&t(`span`,{className:`me-1 text-muted/60`,children:WD(e.timestamp).format(`HH:mm:ss`)}),t(`span`,{children:e.message})]},aK(e)))]}),(()=>{let e=typeof g?.observation==`string`?g.observation:void 0;return e&&e!==b?t(`div`,{className:`vprose prose prose-slate dark:prose-invert prose-p:leading-relaxed prose-p:my-1.5 max-w-none text-sm`,children:t(Nt,{artifactRunId:a,children:e})}):null})(),S.length>0&&t(dK,{files:S})]})})()]})}function _K({files:e,artifactRunId:n}){let[r,i]=G([]),{client:a}=q(),o=VS(),s=W(a);s.current=a;let c=W(o);return c.current=o,H(()=>{if(!e||e.length===0||!n){i([]);return}let t=!1;return(async()=>{let r=s.current,a=c.current,o=await Promise.all(e.map(async e=>{if(!e||typeof e!=`string`)return null;let t=e.startsWith(`artifact:`)?e.slice(9):e,i=t.split(`.`).pop()?.toLowerCase()||``;if(new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`svg`]).has(i))return null;if(t.startsWith(`http://`)||t.startsWith(`https://`))return t;try{let e=US(n,t,`attachment`);return a?await a.getOrFetch(e,async()=>(await r.files.getArtifactDownloadUrl(n,t,`attachment`)).url):(await r.files.getArtifactDownloadUrl(n,t,`attachment`)).url}catch(e){return console.error(`Failed to resolve artifact URL for ${t}`,e),null}}));t||i(o.filter(e=>!!e))})(),()=>{t=!0}},[e,n]),r.length===0?null:t(`div`,{className:`ps-4 pe-2 pb-1.5`,children:t(dK,{files:r})})}function vK({messages:e,artifactRunId:n}){let[r,i]=G([]),{client:a}=q(),o=VS(),s=W(a);s.current=a;let c=W(o);return c.current=o,H(()=>{if(!n||e.length===0){i([]);return}let t=e[e.length-1].details,r=fK(t);if(!r||r.length===0){i([]);return}let a=!1;return(async()=>{let e=s.current,t=c.current,o=await Promise.all(r.map(async r=>{if(!r||typeof r!=`string`)return null;let i=r.startsWith(`artifact:`)?r.slice(9):r,a=i.split(`.`).pop()?.toLowerCase()||``;if(!new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`svg`]).has(a))return null;if(i.startsWith(`http://`)||i.startsWith(`https://`))return i;try{let r=US(n,i,`inline`);return t?await t.getOrFetch(r,async()=>(await e.files.getArtifactDownloadUrl(n,i,`inline`)).url):(await e.files.getArtifactDownloadUrl(n,i,`inline`)).url}catch(e){return console.error(`Failed to resolve artifact URL for ${i}`,e),null}}));a||i(o.filter(e=>!!e))})(),()=>{a=!0}},[e,n]),r.length===0?null:t(`div`,{className:`px-3 py-1.5 border-b border-border`,children:t(dK,{files:r})})}function yK({messages:r,showPulsatingCircle:i=!1,toolRunId:a,toolStatus:s,preambleText:c,preambleMessage:l,rootClassName:u,headerClassName:d,senderClassName:f,toolSummaryClassName:p,toolBadgeClassName:m,itemClassName:h,itemHeaderClassName:g,itemContentClassName:_}){let v=U(()=>lK(r),[r]),y=U(()=>v.map(oK),[v]),[b,x]=G(!0),[S,C]=G(new Set),[w,T]=G(new Set),E=W(y),{t:D}=K(),O=nt(),k=v.find(e=>e.workflow_run_id)?.workflow_run_id??v[0]?.workflow_run_id,A=U(()=>{let e=new Set,t=[];for(let n of v)for(let r of Dn(n)){let n=`${r.type}:${r.id}:${r.action}`;e.has(n)||(e.add(n),t.push(r))}return t},[v]),j=()=>i?t(iW,{size:`sm`,color:`blue`}):s===`running`?t(`span`,{className:`size-2 rounded-full bg-primary inline-block`}):s===`completed`?t(Nh,{className:`size-4 text-success`}):s===`error`?t(Ah,{className:`size-4 text-destructive`}):s===`warning`?t(vb,{className:`size-4 text-attention`}):t(Am,{className:`size-4 text-done`}),M=()=>s===`completed`?`border-s-success`:s===`error`?`border-s-destructive`:s===`warning`?`border-s-attention`:`border-s-done`;H(()=>{let e=E.current,t=new Set(e),n=y.filter(e=>!t.has(e));if(n.length>0){T(new Set(n));let e=setTimeout(()=>{T(new Set)},500);return E.current=y,()=>clearTimeout(e)}E.current=y},[y]);let N=v[0],P=v[v.length-1],F=N.timestamp,I=P.timestamp,L=v.map(e=>mK(e)),ee=new Set(L).size===1?`${v.length}× ${L[0]}`:`${v.length} activity updates`,R=e=>{C(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},te=()=>{let e=v.map(e=>{let t=e.details;return`[${mK(e)}] ${e.message||``}\n${t?JSON.stringify(t,null,2):``}`}).join(`
980
+ `})]})]})}):null}const MG=ot.memo(jG);function NG(e){return e.message?typeof e.message==`object`?JSON.stringify(e.message,null,2):String(e.message).trim():``}function PG(e){let t=e.replace(/\s+/g,` `).trim().toLowerCase();return t===`thinking`||t===`thinking...`||t===`working`||t===`working...`||t===`waiting`||t===`waiting...`}function FG(e){return e.type===J.THOUGHT&&e.details?.display_role===`thinking`}function IG(e){if(FG(e))return!0;if(e.type!==J.WARNING)return!1;let t=e.details,n=NG(e).replace(/^[^A-Za-z0-9]+/,``).toLowerCase();return typeof t?.attempt==`number`&&typeof t?.maxAttempts==`number`&&typeof t?.estimatedBackoffSeconds==`number`&&typeof t?.activityId==`string`&&(n.startsWith(`retrying operation`)||n.startsWith(`retrying checkpoint operation`))}function LG(e){if(typeof e==`number`)return e;if(!e)return-1/0;let t=new Date(e).getTime();return Number.isFinite(t)?t:-1/0}function RG(e){return e.reduce((e,t)=>Math.max(e,LG(t.timestamp)),-1/0)}function zG(e,t){let n=e.details?.[t];return typeof n==`string`&&n.trim()||void 0}function BG(e,t,n){if(!e.some(IG))return e;if(!t)return e.filter(e=>!IG(e));let r=-1,i=-1;return e.forEach((e,t)=>{IG(e)?i=t:r=t}),e.filter((e,t)=>!IG(e)||t===i&&t>r&&LG(e.timestamp)>=n)}function VG(e){if(BH(e))return!1;let t=NG(e);return!t||PG(t)?!1:e.type===J.ANSWER?!0:dU(e)?e.details?.display_role===`tool_preamble`&&(e.details.tool===`ask_user`||Array.isArray(e.details.tools)&&e.details.tools.some(e=>typeof e==`string`?e===`ask_user`:!e||typeof e!=`object`?!1:`name`in e&&e.name===`ask_user`||`tool`in e&&e.tool===`ask_user`)):e.type===J.THOUGHT&&!!e.details?.streamed}function HG(e){if(e.type!==J.ERROR&&e.type!==J.WARNING)return!1;let t=e.details;return!!(t?.tool||t?.tool_status||t?.tool_run_id||t?.activity_group_id||t?.tool_event)}function UG(e){if(e.type!==J.ERROR||HG(e))return!1;let t=e.details;return NG(e).startsWith(`Error analyzing conversation:`)&&typeof t?.error==`string`}function WG(e){if(e.type!==J.ERROR)return!1;let t=e.details;if(t?.event_class!==`activity`||t.workstream_event)return!1;let n=typeof e.workstream_id==`string`&&e.workstream_id.trim()?e.workstream_id.trim():typeof t.workstream_id==`string`?t.workstream_id.trim():``,r=n.toLowerCase();return!n||r===`main`||r===`all`?!1:!(t.tool||t.tool_status||t.tool_run_id||t.activity_group_id||t.tool_event)}function GG(e){return BH(e)||WG(e)?!1:e.type===J.QUESTION||!!UH(e)||VG(e)||e.type===J.REQUEST_INPUT&&!UU(e)||e.type===J.TERMINATED||(e.type===J.ERROR||e.type===J.WARNING)&&!HG(e)&&!IG(e)}function KG(e){let t=e.details?.tool_status;if(t===`running`||t===`completed`||t===`error`||t===`warning`)return t;if(e.type===J.ERROR)return`error`;if(e.type===J.WARNING)return`warning`}function qG(e,t){for(let n=e.length-1;n>=0;n--){let r=KG(e[n]);if(r===`error`||r===`warning`)return r;if(r)return t?`running`:`completed`}return t?`running`:`completed`}function JG(e,t){return fU(e)&&!FG(e)&&t.length>0&&t.every(FG)}function YG(e){return BH(e)||VG(e)||UH(e)?!1:WG(e)||IG(e)||UU(e)||HG(e)||dU(e)||fU(e)||e.type===J.UPDATE||e.type===J.PLAN?!0:e.type===J.THOUGHT&&!e.details?.streamed}function XG(e,t,n=RG(e)){let r=[],i=[],a=new Set,o=(e,t)=>{if(i.length===0)return;let a=BG(i,e,n);if(a.length===0){i=[];return}let o=a[0],s=a[a.length-1],c=qG(a,e);r.push({type:`work`,id:e?`${o.timestamp}-active`:`${o.timestamp}-${s.timestamp}-${a.length}`,messages:a,isActive:e,status:c,startTimestamp:o.timestamp,endTimestamp:t?.timestamp??s.timestamp}),i=[]};for(let t of e){let e=UH(t),n=e?null:WH(t),s=e??n;if(s){let n=a.has(s.workstreamId);if(a.add(s.workstreamId),e||!n){o(!1,t),r.push({type:`message`,message:t});continue}}if(t.type===J.COMPLETE||t.type===J.IDLE){if(QH(t)){let e=i[0]?.timestamp;o(!1,t);let n=r[r.length-1];r.push({type:`stopped`,message:t,startTimestamp:e!==void 0&&n?.type===`work`?n.startTimestamp:e??t.timestamp,endTimestamp:t.timestamp});continue}o(!1,t);continue}if(YG(t)||i.length>0&&UG(t)){if(JG(t,i)){let e=r[r.length-1];if(e?.type===`work`&&!e.isActive){r.pop(),i=[...e.messages,t];continue}}i.push(t);continue}GG(t)&&(o(!1,t),r.push({type:`message`,message:t}))}return o(!t),r}function ZG(e,t){if(e.activityId){let n=t.find(t=>fU(t)&&(zG(t,`activity_id`)===e.activityId||zG(t,`activity_group_id`)===e.activityId));if(n)return n;let r=t.find(t=>zG(t,`activity_id`)===e.activityId&&zG(t,`activity_group_id`))?.details?.activity_group_id;if(typeof r==`string`){let e=t.find(e=>fU(e)&&zG(e,`activity_group_id`)===r);if(e)return e}}if(e.isComplete)return;let n=LG(e.startTimestamp);if(!Number.isFinite(n))return;let r=[...t].filter(e=>LG(e.timestamp)>=n).sort((e,t)=>LG(e.timestamp)-LG(t.timestamp));for(let e of r){if(LG(e.timestamp)-n>6e4)return;if(fU(e))return e;if(GG(e))return}}function QG(e,t){if(t.size===0)return e;let n=e.find(e=>e.workflow_run_id)?.workflow_run_id??``,r=[];return t.forEach((t,i)=>{let a=t.text.trim();if(!a||cU(t,e)||zH(a,t.workstreamId))return;let o=ZG(t,e),s=o?zG(o,`activity_group_id`):void 0;r.push({timestamp:t.startTimestamp,workflow_run_id:n,type:o?J.THOUGHT:J.ANSWER,message:a,workstream_id:t.workstreamId,details:{activity_id:t.activityId,activity_group_id:s,display_role:o?`tool_preamble`:void 0,source:`streaming_summary`,streamed:!0,streaming_id:i,tools:o?.details?.tool?[o.details.tool]:void 0}})}),r.length===0?e:[...e,...r].sort((e,t)=>LG(e.timestamp)-LG(t.timestamp))}function $G(e,t,n){let r=e[e.length-1];return r?r.type===`work`?r.endTimestamp??r.startTimestamp:r.message.timestamp??n:t.reduce((e,t)=>{let n=LG(t.timestamp);return!Number.isFinite(n)||n>=e.ms?e:{timestamp:t.timestamp,ms:n}},{ms:1/0}).timestamp??n}function eK(e,t,n){if(!t||n||e.some(e=>e.type===`work`&&e.isActive))return!1;let r=e[e.length-1];return r?r.type===`work`||r.message.type===J.QUESTION:!1}function tK(e){let t=e[e.length-1];return t?t.type===`message`&&t.message.type===J.QUESTION&&e.length===1:!1}Q();const nK=new Set([`tool`,`tool_event`,`tool_run_id`,`tool_use_id`,`activity_group_id`,`event_class`,`tool_iteration`,`tool_status`,`message_to_human`,`tools`,`streamed`,`files`,`outputFiles`,`display_role`,`duration_ms`,`observation`,`progress_messages`,`resources`,`browseruse`,`browser_use`]);function rK(e){return e?Object.entries(e).filter(([e,t])=>!nK.has(e)&&t!=null&&t!==``):[]}function iK(e){return e.replace(/_/g,` `).replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/^./,e=>e.toUpperCase())}function aK(e){let t=e?.progress_messages;return Array.isArray(t)?t.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e,n=typeof t.message==`string`?t.message.trim():``;return n?[{message:n,status:typeof t.status==`string`?t.status:void 0,timestamp:typeof t.timestamp==`number`||typeof t.timestamp==`string`?t.timestamp:void 0}]:[]}):[]}function oK(e){return[`progress`,e.timestamp??`no-time`,e.status??`status`,e.message].join(`:`)}function sK(e){let t=e.details,n=typeof t?.tool_run_id==`string`?t.tool_run_id:void 0;if(n)return`tool-run:${n}`;let r=typeof t?.activity_group_id==`string`?t.activity_group_id:void 0,i=typeof t?.tool_use_id==`string`?t.tool_use_id:void 0;return r||i?`tool:${r??`no-activity`}:${i??`no-use`}`:[`message`,e.workstream_id??`main`,e.type,e.timestamp,hK(e)].join(`:`)}function cK(e,t){return e.timestamp===t.timestamp&&e.type===t.type&&e.message===t.message&&e.details===t.details&&e.workstream_id===t.workstream_id&&e.workflow_run_id===t.workflow_run_id}function lK(e){switch(e){case`completed`:return`bg-success text-success border-success`;case`running`:return`bg-info text-info border-info`;case`error`:return`bg-destructive text-destructive border-destructive`;case`warning`:return`bg-attention text-attention border-attention`;default:return``}}function uK(e){let t=new Map,n=[];for(let r of e){let e=r.details?.tool_run_id;e?(t.has(e)||t.set(e,[]),t.get(e)?.push(r)):n.push(r)}for(let[e,r]of t){if(r.length<=1){n.push(...r);continue}r.sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime()));let e=r[r.length-1],t=r.find(e=>e.details?.tool_event===`started`),i=r.find(e=>e.details?.tool_status===`running`),a=t??i??r.find(e=>e.message?.trim()),o=(typeof a?.details?.message_to_human==`string`?a.details.message_to_human:void 0)||a?.message||e.message,s=r.filter(e=>e.details?.tool_event===`progress`&&e.message?.trim()).map(e=>({message:e.message.trim(),status:e.details?.tool_status,timestamp:e.timestamp})),c={};for(let e of r)Object.assign(c,e.details);s.length>0&&(c.progress_messages=s),n.push({...e,message:o,details:c})}return n.sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())),n}const dK=e=>/\.(png|jpg|jpeg|gif|webp|svg)(\?|$)/i.test(e);function fK({files:e,className:r}){let{t:i}=K(),{openImage:a}=DW();return!e||e.length===0?null:t(`div`,{className:z(`mt-2 flex flex-wrap gap-2`,r),children:e.map(e=>{let r=e.split(`/`).pop()?.split(`?`)[0]||`file`;return dK(e)?t(o,{variant:`unstyled`,className:`cursor-pointer p-0`,onClick:()=>a(e,r),title:i(`agent.clickToEnlarge`),"aria-label":r,children:t(`img`,{src:e,alt:r,className:`max-w-[300px] max-h-[200px] rounded border hover:opacity-80 transition-opacity hover:shadow-lg`})},e):n(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 px-2 py-1 bg-muted rounded text-xs hover:bg-muted/80`,children:[`📎 `,r]},e)})})}const pK=e=>{if(!e)return;let t=e.files??e.outputFiles;return Array.isArray(t)?t:void 0},mK=e=>{let t=e.details;return e.type===J.THOUGHT&&t?.display_role===`tool_preamble`},hK=e=>{let t=e.details;if(mK(e))return`assistant`;if(t?.tool)return t.tool;switch(e.type){case J.UPDATE:return`update`;case J.WARNING:return`warning`;case J.ERROR:return`error`;case J.SYSTEM:return`system`;default:return`activity`}},gK=e=>mK(e)?`text-[10px] px-1.5 py-0.5 rounded-md bg-muted text-foreground border border-border font-medium`:`text-[10px] px-1.5 py-0.5 rounded-md bg-done text-done border border-done font-medium`;function _K({message:e,isExpanded:r,onToggle:i,artifactRunId:a,classNames:s={}}){let{t:c}=K(),[l,u]=G([]),d=nt(),{client:f}=q(),p=VS(),m=W(f);m.current=f;let h=W(p);h.current=p;let g=e.details,_=hK(e),v=gK(e),y=pK(g),b=typeof e.message==`string`?e.message:``;H(()=>{if(!y||y.length===0||!a){u([]);return}let e=!1;return(async()=>{let t=m.current,n=h.current,r=await Promise.all(y.map(async e=>{if(!e||typeof e!=`string`)return null;if(e.startsWith(`http://`)||e.startsWith(`https://`))return e;let r=e.startsWith(`artifact:`)?e.slice(9):e,i=r.split(`.`).pop()?.toLowerCase()||``,o=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`svg`]).has(i)?`inline`:`attachment`;try{let e=US(a,r,o);return n?await n.getOrFetch(e,async()=>(await t.files.getArtifactDownloadUrl(a,r,o)).url):(await t.files.getArtifactDownloadUrl(a,r,o)).url}catch(e){return console.error(`Failed to resolve artifact URL for ${r}`,e),null}}));e||u(r.filter(e=>!!e))})(),()=>{e=!0}},[y,a]);let x=l.filter(e=>dK(e)),S=l.filter(e=>!dK(e)),C=()=>{let e=[b,g?`\n\nDetails:\n${JSON.stringify(g,null,2)}`:``].join(``).trim();navigator.clipboard.writeText(e).then(()=>{d({status:`success`,title:c(`agent.copiedToClipboard`),duration:2e3})})};return n(`div`,{className:z(`border-b border-border last:border-b-0`,s.itemClassName),children:[n(`div`,{role:`button`,tabIndex:0,className:z(`flex items-start justify-between px-3 py-2 cursor-pointer hover:bg-muted transition-colors`,s.itemHeaderClassName),onClick:i,onKeyDown:qe(i),children:[n(`div`,{className:`flex items-start gap-2 flex-1 min-w-0`,children:[t(`div`,{className:`flex-shrink-0 pt-0.5`,children:r?t(rh,{className:`size-3 text-muted`}):t(lh,{className:`size-3 text-muted cn-rtl-flip`})}),t(`div`,{className:`flex-1 min-w-0`,children:b?t(`span`,{className:`text-xs text-foreground line-clamp-2`,children:b}):n(`span`,{className:`text-xs text-muted italic`,children:[`Activity: `,_]})})]}),n(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[!r&&t(`span`,{className:z(v,s.toolBadgeClassName),children:_}),t(o,{variant:`ghost`,size:`xs`,onClick:e=>{e.stopPropagation(),C()},className:`text-muted opacity-0 group-hover:opacity-100 transition-opacity`,title:c(`agent.copyMessage`),children:t(fg,{className:`size-3`})})]})]}),x.length>0&&t(`div`,{className:`px-3 pb-1.5`,children:t(fK,{files:x})}),r&&(()=>{let r=g?.tool_status,i=rK(g),o=aK(g);return n(`div`,{className:z(`px-4 py-2 bg-muted/50 dark:bg-muted/30`,s.itemContentClassName),children:[n(`div`,{className:`flex items-center gap-2 mb-2 flex-wrap`,children:[t(`span`,{className:z(v,s.toolBadgeClassName),children:_}),r&&t(`span`,{className:z(`text-[10px] px-1.5 py-0.5 rounded-md border font-medium`,lK(r)),children:r}),t(`span`,{className:`text-[10px] text-muted/70`,children:WD(e.timestamp).format(`HH:mm:ss`)})]}),i.length>0&&t(`div`,{className:`mb-2 space-y-0.5`,children:i.map(([e,r])=>n(`div`,{className:`flex gap-1.5 text-xs`,children:[n(`span`,{className:`text-muted font-medium flex-shrink-0`,children:[iK(e),`:`]}),t(`span`,{className:`text-foreground break-all`,children:typeof r==`object`?JSON.stringify(r):String(r)})]},e))}),o.length>0&&n(`div`,{className:`mb-2 space-y-1`,children:[t(`div`,{className:`text-[10px] uppercase tracking-wide text-muted/70 font-medium`,children:c(`agent.progress`)}),o.map(e=>n(`div`,{className:`text-xs text-muted`,children:[e.timestamp&&t(`span`,{className:`me-1 text-muted/60`,children:WD(e.timestamp).format(`HH:mm:ss`)}),t(`span`,{children:e.message})]},oK(e)))]}),(()=>{let e=typeof g?.observation==`string`?g.observation:void 0;return e&&e!==b?t(`div`,{className:`vprose prose prose-slate dark:prose-invert prose-p:leading-relaxed prose-p:my-1.5 max-w-none text-sm`,children:t(Nt,{artifactRunId:a,children:e})}):null})(),S.length>0&&t(fK,{files:S})]})})()]})}function vK({files:e,artifactRunId:n}){let[r,i]=G([]),{client:a}=q(),o=VS(),s=W(a);s.current=a;let c=W(o);return c.current=o,H(()=>{if(!e||e.length===0||!n){i([]);return}let t=!1;return(async()=>{let r=s.current,a=c.current,o=await Promise.all(e.map(async e=>{if(!e||typeof e!=`string`)return null;let t=e.startsWith(`artifact:`)?e.slice(9):e,i=t.split(`.`).pop()?.toLowerCase()||``;if(new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`svg`]).has(i))return null;if(t.startsWith(`http://`)||t.startsWith(`https://`))return t;try{let e=US(n,t,`attachment`);return a?await a.getOrFetch(e,async()=>(await r.files.getArtifactDownloadUrl(n,t,`attachment`)).url):(await r.files.getArtifactDownloadUrl(n,t,`attachment`)).url}catch(e){return console.error(`Failed to resolve artifact URL for ${t}`,e),null}}));t||i(o.filter(e=>!!e))})(),()=>{t=!0}},[e,n]),r.length===0?null:t(`div`,{className:`ps-4 pe-2 pb-1.5`,children:t(fK,{files:r})})}function yK({messages:e,artifactRunId:n}){let[r,i]=G([]),{client:a}=q(),o=VS(),s=W(a);s.current=a;let c=W(o);return c.current=o,H(()=>{if(!n||e.length===0){i([]);return}let t=e[e.length-1].details,r=pK(t);if(!r||r.length===0){i([]);return}let a=!1;return(async()=>{let e=s.current,t=c.current,o=await Promise.all(r.map(async r=>{if(!r||typeof r!=`string`)return null;let i=r.startsWith(`artifact:`)?r.slice(9):r,a=i.split(`.`).pop()?.toLowerCase()||``;if(!new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`svg`]).has(a))return null;if(i.startsWith(`http://`)||i.startsWith(`https://`))return i;try{let r=US(n,i,`inline`);return t?await t.getOrFetch(r,async()=>(await e.files.getArtifactDownloadUrl(n,i,`inline`)).url):(await e.files.getArtifactDownloadUrl(n,i,`inline`)).url}catch(e){return console.error(`Failed to resolve artifact URL for ${i}`,e),null}}));a||i(o.filter(e=>!!e))})(),()=>{a=!0}},[e,n]),r.length===0?null:t(`div`,{className:`px-3 py-1.5 border-b border-border`,children:t(fK,{files:r})})}function bK({messages:r,showPulsatingCircle:i=!1,toolRunId:a,toolStatus:s,preambleText:c,preambleMessage:l,rootClassName:u,headerClassName:d,senderClassName:f,toolSummaryClassName:p,toolBadgeClassName:m,itemClassName:h,itemHeaderClassName:g,itemContentClassName:_}){let v=U(()=>uK(r),[r]),y=U(()=>v.map(sK),[v]),[b,x]=G(!0),[S,C]=G(new Set),[w,T]=G(new Set),E=W(y),{t:D}=K(),O=nt(),k=v.find(e=>e.workflow_run_id)?.workflow_run_id??v[0]?.workflow_run_id,A=U(()=>{let e=new Set,t=[];for(let n of v)for(let r of Dn(n)){let n=`${r.type}:${r.id}:${r.action}`;e.has(n)||(e.add(n),t.push(r))}return t},[v]),j=()=>i?t(aW,{size:`sm`,color:`blue`}):s===`running`?t(`span`,{className:`size-2 rounded-full bg-primary inline-block`}):s===`completed`?t(Nh,{className:`size-4 text-success`}):s===`error`?t(Ah,{className:`size-4 text-destructive`}):s===`warning`?t(vb,{className:`size-4 text-attention`}):t(Am,{className:`size-4 text-done`}),M=()=>s===`completed`?`border-s-success`:s===`error`?`border-s-destructive`:s===`warning`?`border-s-attention`:`border-s-done`;H(()=>{let e=E.current,t=new Set(e),n=y.filter(e=>!t.has(e));if(n.length>0){T(new Set(n));let e=setTimeout(()=>{T(new Set)},500);return E.current=y,()=>clearTimeout(e)}E.current=y},[y]);let N=v[0],P=v[v.length-1],F=N.timestamp,I=P.timestamp,L=v.map(e=>hK(e)),ee=new Set(L).size===1?`${v.length}× ${L[0]}`:`${v.length} activity updates`,R=e=>{C(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},te=()=>{let e=v.map(e=>{let t=e.details;return`[${hK(e)}] ${e.message||``}\n${t?JSON.stringify(t,null,2):``}`}).join(`
981
981
 
982
982
  ---
983
983
 
984
- `);navigator.clipboard.writeText(e).then(()=>{O({status:`success`,title:D(`agent.copiedAllToolCalls`),duration:2e3})})};return n(`div`,{className:z(`border-s-4 overflow-hidden bg-white dark:bg-muted mb-4`,M(),u),children:[n(`div`,{role:`button`,tabIndex:0,"aria-expanded":!b,className:z(`flex items-center justify-between px-4 py-1.5 cursor-pointer hover:bg-muted transition-colors`,d),onClick:()=>x(!b),onKeyDown:qe(()=>x(!b)),children:[n(`div`,{className:`flex items-center gap-1 flex-1 min-w-0`,children:[j(),c?t(`span`,{className:z(`text-xs text-foreground line-clamp-2 flex-1 min-w-0`,p),children:c}):n(e,{children:[t(`span`,{className:z(`text-xs font-medium text-muted`,f),children:`Agent`}),t(`span`,{className:z(`text-xs text-done font-medium`,p),children:ee})]}),b?t(lh,{className:`size-3 text-muted flex-shrink-0 cn-rtl-flip`}):t(rh,{className:`size-3 text-muted flex-shrink-0`})]}),n(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[c&&t(`span`,{className:z(`text-[10px] text-done font-medium`,p),children:ee}),n(`span`,{className:`text-[11px] text-muted/70`,children:[WD(F).format(`HH:mm:ss`),v.length>1&&` - ${WD(I).format(`HH:mm:ss`)}`]}),t(o,{variant:`ghost`,size:`xs`,onClick:e=>{e.stopPropagation(),te()},className:`text-muted/50 hover:text-muted h-5 w-5 p-0`,title:D(`agent.copyAllToolCalls`),children:t(fg,{className:`size-3`})})]})]}),t(vK,{messages:v,artifactRunId:k}),A.length>0&&t(`div`,{className:`px-4 pt-1 pb-2`,children:t(wG,{resources:A,workflowRunId:k})}),b&&t(`div`,{className:`px-3 py-0.5 space-y-0`,children:v.map((e,r)=>{let i=y[r]??oK(e),a=e.details,o=mK(e),s=hK(e),c=typeof e.message==`string`?e.message:``,l=w.has(i),u=S.has(i),d=fK(a);return n(`div`,{className:z(`border-b border-border last:border-b-0`,h),style:{opacity:+!l,transform:l?`translateX(-10px)`:`translateX(0)`,transition:`opacity 0.3s ease-out, transform 0.3s ease-out`,transitionDelay:`${(r-(v.length-w.size))*100}ms`,animation:l?`slideInFade 0.4s ease-out forwards`:`none`,animationDelay:`${(r-(v.length-w.size))*100}ms`},children:[n(`div`,{role:`button`,tabIndex:0,"aria-expanded":u,className:z(`flex items-start gap-2 py-1.5 text-xs cursor-pointer hover:bg-muted`,g),onClick:()=>R(i),onKeyDown:qe(()=>R(i)),title:c,children:[t(`div`,{className:`flex-shrink-0 pt-0.5`,children:u?t(rh,{className:`size-3 text-muted`}):t(lh,{className:`size-3 text-muted cn-rtl-flip`})}),t(`div`,{className:`flex-1 min-w-0`,children:c?t(`span`,{className:`text-foreground line-clamp-2`,children:c}):n(`span`,{className:`text-muted italic`,children:[`Activity: `,o]})}),!u&&t(`span`,{className:z(s,`flex-shrink-0`,m),children:o})]}),t(_K,{files:d,artifactRunId:k}),u&&(()=>{let r=a?.tool_status,i=nK(a),l=iK(a);return n(`div`,{className:z(`ps-5 pe-3 pb-2 text-sm`,_),children:[n(`div`,{className:`flex items-center gap-2 mb-1.5 flex-wrap`,children:[t(`span`,{className:z(s,m),children:o}),r&&t(`span`,{className:z(`text-[10px] px-1.5 py-0.5 rounded-md border font-medium`,cK(r)),children:r}),t(`span`,{className:`text-[10px] text-muted/70`,children:WD(e.timestamp).format(`HH:mm:ss`)})]}),i.length>0&&t(`div`,{className:`mb-1.5 space-y-0.5`,children:i.map(([e,r])=>n(`div`,{className:`flex gap-1.5 text-xs`,children:[n(`span`,{className:`text-muted font-medium flex-shrink-0`,children:[rK(e),`:`]}),t(`span`,{className:`text-foreground break-all`,children:typeof r==`object`?JSON.stringify(r):String(r)})]},e))}),l.length>0&&n(`div`,{className:`mb-1.5 space-y-1`,children:[t(`div`,{className:`text-[10px] uppercase tracking-wide text-muted/70 font-medium`,children:D(`agent.progress`)}),l.map(e=>n(`div`,{className:`text-xs text-muted`,children:[e.timestamp&&t(`span`,{className:`me-1 text-muted/60`,children:WD(e.timestamp).format(`HH:mm:ss`)}),t(`span`,{children:e.message})]},aK(e)))]}),(()=>{let e=typeof a?.observation==`string`?a.observation:void 0;return e&&e!==c?t(`div`,{className:`vprose prose prose-slate dark:prose-invert prose-p:leading-relaxed prose-p:my-1.5 max-w-none text-sm`,children:t(Nt,{artifactRunId:k,children:e})}):null})()]})})()]},i)})}),t(`style`,{children:`
984
+ `);navigator.clipboard.writeText(e).then(()=>{O({status:`success`,title:D(`agent.copiedAllToolCalls`),duration:2e3})})};return n(`div`,{className:z(`border-s-4 overflow-hidden bg-white dark:bg-muted mb-4`,M(),u),children:[n(`div`,{role:`button`,tabIndex:0,"aria-expanded":!b,className:z(`flex items-center justify-between px-4 py-1.5 cursor-pointer hover:bg-muted transition-colors`,d),onClick:()=>x(!b),onKeyDown:qe(()=>x(!b)),children:[n(`div`,{className:`flex items-center gap-1 flex-1 min-w-0`,children:[j(),c?t(`span`,{className:z(`text-xs text-foreground line-clamp-2 flex-1 min-w-0`,p),children:c}):n(e,{children:[t(`span`,{className:z(`text-xs font-medium text-muted`,f),children:`Agent`}),t(`span`,{className:z(`text-xs text-done font-medium`,p),children:ee})]}),b?t(lh,{className:`size-3 text-muted flex-shrink-0 cn-rtl-flip`}):t(rh,{className:`size-3 text-muted flex-shrink-0`})]}),n(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[c&&t(`span`,{className:z(`text-[10px] text-done font-medium`,p),children:ee}),n(`span`,{className:`text-[11px] text-muted/70`,children:[WD(F).format(`HH:mm:ss`),v.length>1&&` - ${WD(I).format(`HH:mm:ss`)}`]}),t(o,{variant:`ghost`,size:`xs`,onClick:e=>{e.stopPropagation(),te()},className:`text-muted/50 hover:text-muted h-5 w-5 p-0`,title:D(`agent.copyAllToolCalls`),children:t(fg,{className:`size-3`})})]})]}),t(yK,{messages:v,artifactRunId:k}),A.length>0&&t(`div`,{className:`px-4 pt-1 pb-2`,children:t(TG,{resources:A,workflowRunId:k})}),b&&t(`div`,{className:`px-3 py-0.5 space-y-0`,children:v.map((e,r)=>{let i=y[r]??sK(e),a=e.details,o=hK(e),s=gK(e),c=typeof e.message==`string`?e.message:``,l=w.has(i),u=S.has(i),d=pK(a);return n(`div`,{className:z(`border-b border-border last:border-b-0`,h),style:{opacity:+!l,transform:l?`translateX(-10px)`:`translateX(0)`,transition:`opacity 0.3s ease-out, transform 0.3s ease-out`,transitionDelay:`${(r-(v.length-w.size))*100}ms`,animation:l?`slideInFade 0.4s ease-out forwards`:`none`,animationDelay:`${(r-(v.length-w.size))*100}ms`},children:[n(`div`,{role:`button`,tabIndex:0,"aria-expanded":u,className:z(`flex items-start gap-2 py-1.5 text-xs cursor-pointer hover:bg-muted`,g),onClick:()=>R(i),onKeyDown:qe(()=>R(i)),title:c,children:[t(`div`,{className:`flex-shrink-0 pt-0.5`,children:u?t(rh,{className:`size-3 text-muted`}):t(lh,{className:`size-3 text-muted cn-rtl-flip`})}),t(`div`,{className:`flex-1 min-w-0`,children:c?t(`span`,{className:`text-foreground line-clamp-2`,children:c}):n(`span`,{className:`text-muted italic`,children:[`Activity: `,o]})}),!u&&t(`span`,{className:z(s,`flex-shrink-0`,m),children:o})]}),t(vK,{files:d,artifactRunId:k}),u&&(()=>{let r=a?.tool_status,i=rK(a),l=aK(a);return n(`div`,{className:z(`ps-5 pe-3 pb-2 text-sm`,_),children:[n(`div`,{className:`flex items-center gap-2 mb-1.5 flex-wrap`,children:[t(`span`,{className:z(s,m),children:o}),r&&t(`span`,{className:z(`text-[10px] px-1.5 py-0.5 rounded-md border font-medium`,lK(r)),children:r}),t(`span`,{className:`text-[10px] text-muted/70`,children:WD(e.timestamp).format(`HH:mm:ss`)})]}),i.length>0&&t(`div`,{className:`mb-1.5 space-y-0.5`,children:i.map(([e,r])=>n(`div`,{className:`flex gap-1.5 text-xs`,children:[n(`span`,{className:`text-muted font-medium flex-shrink-0`,children:[iK(e),`:`]}),t(`span`,{className:`text-foreground break-all`,children:typeof r==`object`?JSON.stringify(r):String(r)})]},e))}),l.length>0&&n(`div`,{className:`mb-1.5 space-y-1`,children:[t(`div`,{className:`text-[10px] uppercase tracking-wide text-muted/70 font-medium`,children:D(`agent.progress`)}),l.map(e=>n(`div`,{className:`text-xs text-muted`,children:[e.timestamp&&t(`span`,{className:`me-1 text-muted/60`,children:WD(e.timestamp).format(`HH:mm:ss`)}),t(`span`,{children:e.message})]},oK(e)))]}),(()=>{let e=typeof a?.observation==`string`?a.observation:void 0;return e&&e!==c?t(`div`,{className:`vprose prose prose-slate dark:prose-invert prose-p:leading-relaxed prose-p:my-1.5 max-w-none text-sm`,children:t(Nt,{artifactRunId:k,children:e})}):null})()]})})()]},i)})}),t(`style`,{children:`
985
985
  @keyframes slideInFade {
986
986
  from {
987
987
  opacity: 0;
@@ -992,12 +992,12 @@ $&`)),t.includes(` - `)&&(t=t.replace(/(^|\S)\s+-\s+/g,`$1
992
992
  transform: translateX(0);
993
993
  }
994
994
  }
995
- `}),!b&&t(`div`,{className:`group`,children:v.map((e,n)=>{let r=y[n]??oK(e);return t(gK,{message:e,isExpanded:S.has(r),onToggle:()=>R(r),artifactRunId:k,classNames:{toolBadgeClassName:m,itemClassName:h,itemHeaderClassName:g,itemContentClassName:_}},r)})})]})}const bK=gt(yK,(e,t)=>e.messages.length!==t.messages.length||e.showPulsatingCircle!==t.showPulsatingCircle||e.toolRunId!==t.toolRunId||e.toolStatus!==t.toolStatus||e.preambleText!==t.preambleText||e.rootClassName!==t.rootClassName||e.headerClassName!==t.headerClassName||e.senderClassName!==t.senderClassName||e.toolSummaryClassName!==t.toolSummaryClassName||e.toolBadgeClassName!==t.toolBadgeClassName||e.itemClassName!==t.itemClassName||e.itemHeaderClassName!==t.itemHeaderClassName||e.itemContentClassName!==t.itemContentClassName?!1:e.messages.every((e,n)=>sK(e,t.messages[n])));Q();const xK=`flex items-center gap-1.5 px-2 py-1 text-xs font-medium whitespace-nowrap transition-colors border-b-2 shrink-0 cursor-pointer`,SK=`border-transparent text-muted hover:bg-muted`,CK=`border-info bg-info text-info`;function wK(e){return e.length>20?`${e.substring(0,18)}...`:e}function TK({items:e,current:r,onSelect:i,label:a,active:o,count:s,completionStatus:c}){return t(fe,{label:a,triggerClassName:z(xK,o?CK:SK),icon:t(rh,{className:`ms-0.5 size-3.5`}),children:e.map(([e,a])=>{let o=(s?.get(e)??0)>0;return n(D,{onClick:()=>i(e),className:z(`flex items-center gap-2`,e===r&&`text-info`),children:[t(`span`,{className:`truncate`,children:a}),o&&n(`span`,{className:`ms-auto inline-flex items-center gap-1`,children:[t(`span`,{className:`inline-flex items-center justify-center rounded-full bg-muted px-1.5 text-[10px] text-muted`,children:s?.get(e)}),c&&e!==`all`&&(c.get(e)?t(Nh,{className:`size-3 text-success`}):t(rg,{className:`size-3 text-attention`}))]})]},e)})})}function EK({entries:r,activeWorkstream:i,onSelectWorkstream:a,count:o,completionStatus:s}){let{t:c}=K(),{containerRef:l,setItemRef:u,setMoreRef:d,visible:f,overflow:p,activeInOverflow:m}=et(r,([e])=>e===i),h=c(`agent.moreTabs`),g=(r,i,a)=>{let c=(o?.get(r)??0)>0;return n(e,{children:[wK(i),c&&n(`span`,{className:`flex items-center gap-1`,children:[t(`span`,{className:z(`inline-flex items-center justify-center p-1 text-xs rounded-full`,a?`bg-info text-info`:`bg-muted text-muted`),children:o?.get(r)}),s&&r!==`all`&&(s.get(r)?t(Nh,{className:`size-3 text-success`}):t(rg,{className:`size-3 text-attention`}))]})]})};return n(`div`,{ref:l,className:`relative mb-1 bg-muted border-b border-muted/20`,children:[n(`div`,{"aria-hidden":!0,className:`pointer-events-none invisible absolute start-0 top-0 flex w-max gap-1`,children:[r.map(([e,n],r)=>t(`button`,{type:`button`,tabIndex:-1,ref:u(r),className:z(xK,SK),children:g(e,n,!1)},e)),n(`button`,{type:`button`,tabIndex:-1,ref:d,className:z(xK,SK),children:[h,t(rh,{className:`ms-0.5 size-3.5`})]})]}),n(`div`,{className:`flex gap-1 overflow-hidden`,children:[f.map(([e,n])=>{let r=i===e;return t(`button`,{type:`button`,"aria-current":r?`page`:void 0,onClick:()=>a(e),title:n.length>20?n:void 0,className:z(xK,r?CK:SK),children:g(e,n,r)},e)}),p.length>0&&t(TK,{items:p,current:i,onSelect:a,label:h,active:m,count:o,completionStatus:s})]})]})}function DK({workstreams:e,activeWorkstream:n,onSelectWorkstream:r,count:i,completionStatus:a}){let{t:o}=K(),s=new Map;s.set(`all`,o(`agent.allMessages`)),s.set(`main`,o(`agent.main`)),e.forEach((e,t)=>{t!==`all`&&t!==`main`&&t!==`research_france`&&t!==`statistics`&&s.set(t,e)}),e=s;let c=Array.from(e.entries()).sort(([e],[t])=>e===`all`?-1:t===`all`?1:e===`main`?-1:t===`main`?1:e.localeCompare(t));return c.length>2?t(EK,{entries:c,activeWorkstream:n,onSelectWorkstream:r,count:i,completionStatus:a}):t(`div`,{className:`py-0.5`})}function OK(e){let t=new Map,n=Xt.getFixedT(null,Yt);return t.set(`all`,n(`agent.allMessages`)),t.set(`main`,n(`agent.main`)),e.forEach(e=>{e.workstream_id&&e.workstream_id!==`main`&&e.workstream_id!==`all`&&!t.has(e.workstream_id)&&t.set(e.workstream_id,e.workstream_id)}),t}function kK(e,t){return t===`all`?[...e]:t===`main`?e.filter(e=>$H(e)===`main`):e.filter(e=>$H(e)===t)}Q();const AK=e=>e.type===J.BATCH_PROGRESS&&!!e.details?.batch_id;function jK(e){if(e==null||e===``)return Date.now();let t=typeof e==`number`?e:new Date(e).getTime();return Number.isFinite(t)?t:Date.now()}function MK(e){let t=Date.now()-jK(e);return Math.max(0,Math.round(t/1e3))}function NK(e,t){let n=jK(t)-jK(e);return Math.max(0,Math.round(n/1e3))}function PK(e){if(e<60)return`${e}s`;let t=Math.floor(e/60),n=e%60;return n>0?`${t}m ${n}s`:`${t}m`}function FK(e){if(e==null||e===``)return;let t=typeof e==`number`?e:new Date(e).getTime();return Number.isFinite(t)?t:void 0}function IK(e){let t=FK(e);if(t!==void 0)return new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}).format(new Date(t))}function LK(e){let t=e.details,n=t?.tool||``,r=Array.isArray(t?.tools)?t.tools.map(e=>typeof e==`string`?e:e.name||e.tool||``).filter(Boolean):[],i=[n,...r].join(` `).toLowerCase(),a=n.toLowerCase(),o=typeof e.message==`string`?e.message.trim():``;return t?.display_role===`tool_preamble`?i.includes(`search`)||i.includes(`web`)||i.includes(`fetch`)?`Preparing search`:r.length>0?`Preparing tools`:`Thinking`:a.includes(`search`)?`Searching`:a.includes(`fetch`)||a.includes(`web`)?`Searching the web`:a.includes(`read`)||a.includes(`document`)?`Reading`:a.includes(`edit`)||a.includes(`write`)||a.includes(`create`)?`Editing`:a.includes(`bash`)||a.includes(`shell`)||a.includes(`command`)?`Running command`:o||`Using tool`}function RK(e){return e?`Working`:`Worked`}function zK(e){return e.length>0&&e.every(FG)}function BK(e){return RK(e)}function VK(e){let t=e.filter(e=>$H(e)===`main`);return(t[t.length-1]??e[e.length-1])?.type===J.QUESTION}function HK(e,t){let n=e.filter(e=>$H(e)===`main`),r=n[n.length-1]??e[e.length-1];if(!r||!QU(r,t))return!1;let i=zq(r);return i===`allow_once`||i===`allow_for_run`}function UK(e){if(e.type!==J.UPDATE)return;let t=Cq(e);if(t.tool!==void 0||t.activity_group_id!==void 0)return;let n=typeof t.path==`string`&&t.path.trim()?t.path.trim():void 0;if(n)return KK(e)===`Prepared and saved artifact to ${n}`?n:void 0}function WK(e,t){let n=$H(e[t]);for(let r=t-1;r>=0;--r){let t=e[r];if($H(t)!==n)continue;let i=Cq(t);if(i.tool===`write_artifact`&&typeof i.activity_group_id==`string`)return t;if(t.type!==J.REQUEST_INPUT&&!zq(t)&&i.display_role!==`thinking`&&(typeof i.tool==`string`&&i.tool!==`write_artifact`||t.type===J.ANSWER||t.type===J.COMPLETE||t.type===J.IDLE||t.type===J.TERMINATED))return}}function GK(e){return e.map((t,n)=>{let r=UK(t);if(!r)return t;let i=WK(e,n),a=i?Cq(i):void 0;if(!a)return t;let o=typeof a.activity_group_id==`string`?a.activity_group_id:void 0,s=typeof a.tool_run_id==`string`?a.tool_run_id:void 0,c=typeof a.tool_use_id==`string`?a.tool_use_id:void 0,l=typeof a.tool_iteration==`number`?a.tool_iteration:void 0;return o?{...t,details:{...t.details,event_class:`activity`,tool:`write_artifact`,tool_run_id:s??`write_artifact`,tool_use_id:c??s??`write_artifact`,tool_iteration:l,tool_status:`completed`,tool_event:`progress`,activity_group_id:o,output:KK(t),path:r}}:t})}function KK(e){return e.message?typeof e.message==`object`?JSON.stringify(e.message,null,2):String(e.message).trim():``}function qK({message:e,details:r,onSelectWorkstream:i}){let{t:a}=K(),o=PH(r.workstreamId,r.interaction),s=r.interaction?MH(r.interaction):``,c=s&&s!==o?s:void 0;return t(`div`,{className:`mx-auto w-full max-w-3xl px-1`,"data-workstream-id":r.workstreamId,children:n(`button`,{type:`button`,className:z(`group flex w-full items-start gap-3 border-b border-border/70 py-2 text-start text-sm text-muted`,`transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2`,`focus-visible:ring-focus focus-visible:ring-offset-2 focus-visible:ring-offset-background`),onClick:()=>i?.(r.workstreamId),children:[t(Am,{className:`mt-0.5 size-4 shrink-0 text-muted`,"aria-hidden":`true`}),n(`div`,{className:`min-w-0 flex-1`,children:[n(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[t(`span`,{className:`font-medium text-muted`,children:a(`agent.workstreams`)}),t(`span`,{className:`min-w-0 truncate text-foreground/85`,children:o})]}),c&&t(`div`,{className:`mt-0.5 truncate text-xs text-muted/75`,children:c}),t(`span`,{className:`sr-only`,children:KK(e)})]}),t(lh,{className:`mt-0.5 size-4 shrink-0 text-muted transition-transform group-hover:translate-x-0.5 rtl:rotate-180 rtl:group-hover:-translate-x-0.5`})]})})}const JK=/\[[^\]]+\]\((?:\/store\/(?:objects|collections)\/|store:|document:|document:\/\/|collection:)[^)]+\)/,YK={table:iq};function XK(e){if(!e||typeof e!=`object`)return``;let t=e;return typeof t.value==`string`?t.value:Array.isArray(t.children)?t.children.map(XK).join(``):``}function ZK(e,t){if(!e||typeof e!=`object`)return[];let n=e.children;return Array.isArray(n)?n.filter(e=>{if(!e||typeof e!=`object`)return!1;let n=e;return t?n.tagName===t:typeof n.tagName==`string`}):[]}function QK(e){return ZK(e).filter(e=>e.tagName===`thead`||e.tagName===`tbody`).flatMap(e=>ZK(e,`tr`).map(e=>ZK(e).filter(e=>e.tagName===`th`||e.tagName===`td`).map(e=>XK(e).replace(/\s+/g,` `).trim())))}function $K(e){return ZK(e,`tbody`).flatMap(e=>ZK(e,`tr`).map(e=>ZK(e,`td`).map(e=>XK(e).replace(/\s+/g,` `).trim())))}function eq(e){let t=QK(e),n=$K(e),r=Math.max(0,...t.map(e=>e.length));if(r<=1)return new Set;let i=new Set;for(let e=0;e<r;e+=1){let t=n.map(t=>t[e]||``).map(e=>e.trim()).filter(Boolean);if(t.length===0)continue;let r=t.map(e=>e.length),a=Math.max(...r),o=r.reduce((e,t)=>e+t,0)/r.length,s=t.some(e=>/\S{12,}/.test(e));a<=16&&o<=10&&!s&&i.add(e)}return i.size>=r?new Set:i}function tq(e,t,n){return Math.min(n,Math.max(t,e))}function nq(e){return e.reduce((e,t)=>{let n=t.match(/\S+/g)||[];return Math.max(e,...n.map(e=>e.length))},0)}function rq(e){let t=QK(e),n=Math.max(0,...t.map(e=>e.length));if(n<=1)return[];let r=eq(e),i=Array.from({length:n},(e,n)=>{if(r.has(n))return 8;let i=t.map(e=>e[n]||``).map(e=>e.trim()).filter(Boolean);if(i.length===0)return 18;let a=i.map(e=>e.length),o=Math.max(...a),s=a.reduce((e,t)=>e+t,0)/a.length,c=nq(i);return tq(s*.7+o*.25+c*.45,18,90)}),a=i.reduce((e,t,n)=>e+(r.has(n)?0:t),0);return a<=0?[]:i.map((e,t)=>{let n=e/a,i=r.has(t)?`8rem`:`calc(${(n*100).toFixed(3)}% - ${(r.size*8*n).toFixed(3)}rem)`;return{key:`agent-markdown-table-column-${t}`,compact:r.has(t),width:i}})}function iq({node:e,className:r,children:i,...a}){let o=rq(e);return t(`div`,{className:`overflow-x-auto`,children:n(`table`,{...a,className:r,style:{minWidth:`${o.length*8}rem`,...a.style},children:[o.length>0?t(`colgroup`,{children:o.map(e=>t(`col`,{className:e.compact?`agent-markdown-table-compact-col`:void 0,style:{"--agent-markdown-table-column-width":e.width}},e.key))}):null,i]})})}function aq(e){if(e==null||typeof e==`boolean`)return 0;if(typeof e==`string`||typeof e==`number`)return String(e).length;if(Array.isArray(e))return e.reduce((e,t)=>e+aq(t),0);if(ot.isValidElement(e)){let t=e.props;return aq(t.children)}return 0}function oq(e,t){let[n,r]=G(()=>MK(e));return H(()=>{if(!t){r(MK(e));return}let n=()=>r(MK(e));n();let i=window.setInterval(n,1e3);return()=>window.clearInterval(i)},[t,e]),n}function sq(e=!0){let[t,n]=G(0);return H(()=>{if(!e)return;let t=window.setInterval(()=>{n(()=>Math.floor(Math.random()*SW.length))},4e3);return()=>window.clearInterval(t)},[e]),t}function cq({children:e,message:r,workstreamId:i,className:a,artifactRunId:o,onOpenArtifact:s,markdownComponents:c}){let{t:l}=K(),[u,d]=G(!1),f=U(()=>aq(e),[e])>520,p=typeof e==`string`||typeof e==`number`,m=p?String(e):``,h=typeof e==`string`&&JK.test(e),g=r?ZW(r):void 0;return H(()=>{!f&&u&&d(!1)},[u,f]),t(`div`,{className:`mx-auto flex w-full max-w-3xl justify-end px-1`,children:n(`div`,{className:z(`max-w-[min(44rem,82%)] rounded-[1.35rem] bg-mixer-muted/35 px-4 py-2.5`,`text-sm font-normal leading-6 text-foreground/90 shadow-sm shadow-black/5 dark:bg-mixer-muted/15 dark:text-foreground/88 dark:shadow-none`,`break-words [overflow-wrap:anywhere]`,a),"data-workstream-id":i,children:[t(`div`,{className:z(p&&!h&&`whitespace-pre-wrap`,f&&!u&&`max-h-72 overflow-hidden [mask-image:linear-gradient(to_bottom,black_76%,transparent_100%)]`),children:h?t(Nt,{artifactRunId:o,onArtifactOpen:s,components:c,className:z(`agent-markdown vprose prose max-w-none break-words text-sm leading-6 text-foreground/90`,`prose-p:my-0 prose-p:leading-6 prose-a:text-foreground prose-a:underline prose-a:decoration-muted prose-a:underline-offset-4`,`[&_p+_p]:mt-2`),children:m}):e}),f&&n(`button`,{type:`button`,"aria-expanded":u,className:`mt-2 inline-flex items-center gap-1 text-sm font-medium text-muted transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>d(e=>!e),children:[l(u?`agent.showLess`:`agent.showMore`),t(rh,{className:z(`size-4 transition-transform`,u&&`rotate-180`),"aria-hidden":`true`})]}),r&&g?t(`div`,{className:`mt-1.5 flex justify-end`,children:t($W,{message:r,className:`h-4 w-4`})}):null]})})}function lq({message:r,onSendMessage:i,onOpenArtifact:a,onSelectWorkstream:o,requestInputAnswered:s=!1,StoreLinkComponent:c,CollectionLinkComponent:l}){let{router:u}=$n(),d=r.type===J.REQUEST_INPUT?bU(r):KK(r),f=HH(r)??UH(r),p=$H(r),m=r.workflow_run_id,h=U(()=>r.type===J.QUESTION?GW(d):null,[d,r.type]),g=U(()=>r.type===J.QUESTION?hW(r.details?.editing_action):void 0,[r.details,r.type]),_=U(()=>({...YK,a:wW({StoreLinkComponent:c,CollectionLinkComponent:l,addStickyParams:e=>u.getTopRouter().navigator.addStickyParams(e)})}),[c,l,u]);if(f)return t(qK,{message:r,details:f,onSelectWorkstream:o});if(r.type===J.QUESTION){let i=h?.body??d,o=h?.attachments??[];return n(e,{children:[o.length>0&&t(`div`,{className:`mx-auto flex w-full max-w-3xl justify-end px-1`,children:t(BW,{items:o,artifactRunId:m,onOpenArtifact:a,align:`end`,variant:`message`,StoreLinkComponent:c,CollectionLinkComponent:l})}),i&&t(cq,{message:r,workstreamId:p,artifactRunId:m,onOpenArtifact:a,markdownComponents:_,className:g?`max-w-[min(44rem,90%)]`:void 0,children:g?t(xW,{action:g}):i})]})}let v=r.details;if(r.type===J.REQUEST_INPUT&&v?.ux){let e=v.ux;return t(`div`,{className:`mx-auto w-full max-w-3xl px-1`,children:t(AH,{question:d,options:e.options,variant:e.variant,multiSelect:e.multiSelect,onSelect:e=>LU(i,r,e,WU(r,e)),onMultiSelect:e=>LU(i,r,e.join(`, `)),allowFreeResponse:!e.options?.length||!!e.free_response,placeholder:e.free_response?.placeholder,submitLabel:e.free_response?.submit_label,onSubmit:t=>LU(i,r,t,e.free_response?.metadata),hideBorder:!0,compact:!0,answered:s})})}let y=r.type===J.ERROR||r.type===J.WARNING;return n(`div`,{className:`mx-auto w-full max-w-3xl px-1`,"data-workstream-id":p,children:[y&&t(`div`,{className:`mb-2 text-xs font-medium text-destructive`,children:r.type===J.WARNING?`Warning`:`Error`}),d&&t(`div`,{className:z(lW,y&&`rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2`),style:{overflowWrap:`anywhere`},children:t(Nt,{artifactRunId:m,onArtifactOpen:a,onProposalSelect:e=>i?.(e),onProposalSubmit:e=>i?.(e),components:_,children:d})})]})}function uq(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function dq(e){return e==null?!1:typeof e==`string`?e.trim().length>0:Array.isArray(e)?e.length>0:typeof e!=`object`||Object.keys(e).length>0}function fq(e){return e==null||e===!1?!1:typeof e!=`string`||e.trim().length>0}function pq(e){if(!e||!uq(e))return{};let t=e.properties;return uq(t)?t:{}}function mq(e,t){let n=e&&uq(e)?e.title:void 0;return typeof n==`string`&&n.trim()?n:t.replace(/[_-]+/g,` `).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/\b\w/g,e=>e.toUpperCase())}function hq(e){if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e,null,2)}catch{return String(e)}}function gq(e){return e==null||e===``?t(`span`,{className:`text-muted`,children:`Not provided`}):typeof e==`boolean`?e?`Yes`:`No`:typeof e==`number`?String(e):typeof e==`string`?t(`span`,{className:`whitespace-pre-wrap`,children:e}):Array.isArray(e)&&e.every(e=>typeof e!=`object`||!e)?e.map(e=>hq(e)).join(`, `):t(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap rounded-md bg-background/55 px-2 py-1.5 font-mono text-[12px] leading-relaxed text-foreground/80`,children:hq(e)})}function _q(e,r,i){if(!dq(e))return null;if(!uq(e))return gq(e);let a=pq(r),o=[...Object.keys(a),...Object.keys(e).filter(e=>!(e in a))].map(t=>({key:t,label:mq(a[t],t),value:e[t]})).filter(e=>dq(e.value));return o.length===0?null:n(`div`,{className:`space-y-2 text-start`,children:[i?t(`div`,{className:`text-xs font-medium uppercase tracking-normal text-muted`,children:i}):null,t(`dl`,{className:`space-y-2`,children:o.map(e=>n(`div`,{className:`grid gap-1 sm:grid-cols-[minmax(7rem,32%)_1fr] sm:gap-3`,children:[t(`dt`,{className:`text-xs font-medium text-muted`,children:e.label}),t(`dd`,{className:`min-w-0 break-words text-sm text-foreground`,children:gq(e.value)})]},e.key))})]})}function vq({data:e,schema:n,title:r,template:i,prependFriendlyMessage:a,timestamp:o,isSummaryView:s,messageItemClassNames:c,messageStyleOverrides:l,StoreLinkComponent:u,CollectionLinkComponent:d}){let f=a?.trim()||(typeof e==`string`?e.trim():``),p=i?.({data:e??a,schema:n,title:r});if(!fq(p)&&f){let e={type:J.QUESTION,message:f,timestamp:jK(o),workflow_run_id:``,workstream_id:`main`};return s?t(lq,{message:e,StoreLinkComponent:u,CollectionLinkComponent:d}):t(vG,{...c,messageStyleOverrides:l,message:e})}let m=fq(p)?p:_q(e,n,r);return fq(m)?t(cq,{className:`py-3`,children:m}):null}function yq({label:e,timestamp:r,className:i}){let a=sq(),o=oq(r,!0);return t(`div`,{className:z(`mx-auto w-full max-w-3xl px-1`,i),children:n(`div`,{className:`border-b border-border/70 pb-4 text-sm text-muted`,children:[n(`div`,{className:`flex items-center gap-3`,children:[t(iW,{size:`sm`,color:`blue`}),n(`div`,{className:`min-w-0`,children:[n(`div`,{children:[t(`span`,{className:`font-medium`,children:e}),n(`span`,{className:`ms-2 text-muted/75`,children:[`for `,PK(o)]})]}),t(`div`,{className:`mt-1 truncate text-muted/80`,children:SW[a]})]})]}),t(`div`,{className:`mt-3 ps-6`,children:t(rW,{color:`blue`})})]})})}const bq=`_summary_started_at`,xq=`_summary_finished_at`,Sq=new Set([`account_id`,`activity_group_id`,`activity_id`,`channel_id`,`collection_id`,`document_id`,`display_role`,`duration_ms`,`event_class`,`id`,`object_id`,`project_id`,`run_id`,`streamed`,`tenant_id`,`thread_id`,`tool`,`tool_event`,`tool_iteration`,`tool_run_id`,`tool_use_id`,`tool_status`,`tools`,`message_to_human`,`progress_messages`,`resources`,`source`,`token_usage`,`checkpoint_at`,`checkpoint_threshold`,`approval_decision`,`approval_request`,`cancellation_reason`,bq,xq,`workflow_run_id`]);function Cq(e){return uq(e.details)?e.details:{}}function wq(e){if(e.type!==J.UPDATE)return!1;let t=Cq(e).event_class;return t===`document_created`||t===`document_updated`}function Tq(e){return e.replace(/[_-]+/g,` `).replace(/\s+/g,` `).trim().replace(/\b\w/g,e=>e.toUpperCase())}function Eq(e){let t=[];if(typeof e.tool==`string`&&e.tool.trim()&&t.push(e.tool.trim()),Array.isArray(e.tools)){for(let n of e.tools)if(typeof n==`string`&&n.trim())t.push(n.trim());else if(uq(n)){let e=typeof n.name==`string`?n.name:n.tool;typeof e==`string`&&e.trim()&&t.push(e.trim())}}return t}function Dq(e){let t=Array.from(new Set(Eq(e)));return t.length>0?t.join(`, `):void 0}function Oq(e){return typeof e==`number`||typeof e==`string`?e:void 0}const kq=[`query`,`path`,`file`,`file_name`,`fileName`,`filename`,`name`,`title`,`artifact`,`artifact_path`,`url`,`command`];function Aq(e){for(let t of kq){let n=e[t];if(typeof n==`string`&&n.trim())return{key:t,value:n.trim()};if(typeof n==`number`||typeof n==`boolean`)return{key:t,value:String(n)}}}function jq(e){let t=Cq(e),n=Eq(t).join(` `).toLowerCase(),r=typeof t.tool==`string`?t.tool.toLowerCase():``,i=r||n;return uU(e)?`think`:r.startsWith(`learn_`)||n.includes(`learn_`)?`skill`:r===`discover_tools`?`discover`:e.type===J.THOUGHT&&!r?`think`:i.includes(`search`)||i.includes(`web`)||i.includes(`fetch`)?`search`:i.includes(`read`)||i.includes(`document`)||i.includes(`file`)?`read`:i.includes(`edit`)||i.includes(`write`)||i.includes(`patch`)||i.includes(`create`)?`edit`:i.includes(`bash`)||i.includes(`shell`)||i.includes(`command`)||i.includes(`terminal`)?`command`:e.type===J.THOUGHT&&n.length===0?`think`:`tool`}function Mq(e){switch(e){case`search`:return`Search`;case`read`:return`Read`;case`edit`:return`Edit`;case`command`:return`Bash`;case`skill`:return`Skill`;case`discover`:return`Tool`;case`think`:return`Thought`;default:return`Tool`}}function Nq(e){let t=Aq(e);if(t)return t.value;let n=e.files??e.outputFiles;if(Array.isArray(n)&&n.length>0)return n.map(e=>hq(e)).join(`, `)}function Pq(e){return typeof e==`string`&&e!==`auto_approved`}function Fq(e,t){switch(e){case`denied`:case`denied_with_feedback`:return`User declined to use ${t}.`;case`timeout`:return`Approval timed out for ${t}.`;case`reviewer_denied`:return`Approval reviewer denied ${t}.`;case`cancelled_after_denial`:return`Cancelled ${t} after another tool was denied.`;case`auto_approved`:return`Approval no longer required for ${t}.`;default:return}}function Iq(e){switch(e){case`denied`:case`denied_with_feedback`:return`Declined by user`;case`timeout`:return`Approval timed out`;case`reviewer_denied`:return`Denied by reviewer`;case`cancelled_after_denial`:return`Cancelled after denial`;case`auto_approved`:return`Approved without asking`;default:return}}function Lq(e){let t=Cq(e).tool_approval;return uq(t)?t:void 0}function Rq(e){let t=e?.approval_key;return typeof t==`string`&&t.trim()?t.trim():void 0}function zq(e){if(e.type!==J.QUESTION)return;let t=KK(e).trim().toLowerCase();if(t===`allow_once`||t===`allow_for_run`||t===`deny`)return t}function Bq(e){let t=e.tool_title;if(typeof t==`string`&&t.trim())return t.trim();let n=e.tool_name;return typeof n==`string`&&n.trim()?Tq(n.trim()):`tool action`}function Vq(e,t){let n=[];return e.forEach((r,i)=>{if(r.type!==J.REQUEST_INPUT)return;let a=Lq(r),o=Rq(a);if(!a||!o||t.has(o))return;let s=$H(r),c;for(let t=i+1;t<e.length;t+=1){let n=e[t];if($H(n)===s){if(n.type===J.REQUEST_INPUT)break;if(n.type===J.QUESTION){c=n;break}}}if(!c||zq(c)!==`deny`)return;let l=typeof a.tool_name==`string`&&a.tool_name.trim()?a.tool_name.trim():`tool_action`,u=Bq(a),d=typeof a.target==`string`&&a.target.trim()?a.target:``,f={tool_name:l,tool_title:a.tool_title,action_summary:a.action_summary,target:a.target,approval_key:o};n.push({timestamp:c.timestamp??r.timestamp,workflow_run_id:c.workflow_run_id||r.workflow_run_id,type:J.THOUGHT,message:Fq(`denied`,u)??`User declined to use ${u}.`,workstream_id:s,details:{event_class:`activity`,tool:l,tool_run_id:`approval:${o}`,tool_use_id:`approval:${o}`,tool_status:`error`,tool_event:`failed`,activity_group_id:`approval:${o}`,approval_decision:`denied`,approval_request:f,input:a.input,target:d,observation:`The user declined this tool action.`,source:`synthetic_tool_approval_decision`}})}),n.length===0?e:[...e,...n].sort((e,t)=>jK(e.timestamp)-jK(t.timestamp))}function Hq(e,t=160){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-1)}...`:n}const Uq=[`batch_id`,`activity_group_id`,`activity_id`,`tool_run_id`,`tool_use_id`,`streaming_id`,`chunk_index`,`tool_iteration`,`tool_event`];function Wq(e){for(let t of Uq){let n=e[t];if(typeof n==`string`&&n.trim())return`${t}:${n.trim()}`;if(typeof n==`number`||typeof n==`boolean`)return`${t}:${n}`}}function Gq(e,t=`message`){let n=Wq(Cq(e)),r=Hq(KK(e),96);return[t,e.workstream_id||`main`,e.workflow_run_id,e.timestamp,e.type,n??r].filter(Boolean).join(`:`)}function Kq(e){if(e.type===`single`)return Gq(e.message);if(e.type===`streaming`)return`streaming:${e.streamingId}:${e.startTimestamp}:${e.workstreamId||`main`}`;let t=e.messages[0],n=e.messages[e.messages.length-1],r=t?Gq(t,`first`):e.firstTimestamp,i=n?Gq(n,`last`):e.firstTimestamp;return[`group`,e.toolRunId,e.firstTimestamp,r,i].filter(Boolean).join(`:`)}function qq(e,t){for(let n=t-1;n>=0;n--){let t=e[n];if(t.type===`single`)return t.message.timestamp;if(t.type===`tool_group`)return t.firstTimestamp;if(t.type===`streaming`)return t.startTimestamp}}function Jq(e){let t=hq(e).trim();return t.length>2400?`${t.slice(0,2400)}\n...`:t}function Yq(e,t,n,r){if(n!=null&&n!==``&&!(Array.isArray(n)&&n.length===0)&&!(uq(n)&&Object.keys(n).length===0))return{key:e,label:t,value:n,tone:r}}function Xq(e,t){let n=Object.entries(e).reduce((e,[n,r])=>(Sq.has(n)||t.has(n)||r==null||r===``||(e[n]=r),e),{});return Object.keys(n).length>0?n:void 0}function Zq(e){let t=Cq(e),n=new Set,r=[],i=Aq(t),a=(e,i,a)=>{for(let o of i){let i=Yq(o,e,t[o],a);if(i){n.add(o),r.push(i);return}}};a(`Query`,[`query`]),a(`Input`,[`input`,`params`,`arguments`,`args`]),a(`Output`,[`output`,`stdout`,`result`,`results`,`content`,`result_summary`,`observation`,`display_message`],Pq(t.approval_decision)?`error`:void 0),a(`Files`,[`files`,`outputFiles`]),a(`Error`,[`error`,`stderr`],`error`),i&&n.add(i.key);let o=Xq(t,n);return r.length===0&&o&&r.push({key:`details`,label:`Details`,value:o}),r}function Qq(e,t){if(e.type===J.REQUEST_INPUT)return;let n=KK(e),r=Cq(e),i=uU(e),a=jq(e),o=Eq(r),s=Nq(r),c=typeof r.command==`string`&&r.command.trim()?r.command.trim():void 0,l=o[0]?Tq(o[0]):LK(e),u=Fq(r.approval_decision,l),d=Iq(r.approval_decision),f=typeof r.message_to_human==`string`&&r.message_to_human.trim()?r.message_to_human.trim():void 0,p=a===`think`?n||l:Hq(a===`command`?f||(u?``:n)||c||l:f||s||(u?``:n)||l),m=n?a===`think`?n:Hq(n,420):void 0,h=m&&m!==p&&!u;if(!(!p&&!h))return{key:`${e.timestamp}-${r.activity_id||r.tool_run_id||t}`,kind:a,label:Mq(a),title:p,isPreamble:i,command:c,text:h?m:void 0,toolName:Dq(r),startedAt:Oq(r[bq])??e.timestamp,finishedAt:Oq(r[xq])??e.timestamp,status:u?`error`:r.tool_status,decisionText:d,resources:Dn(e),workflowRunId:e.workflow_run_id,sections:Zq(e)}}function $q(e){let t=Cq(e);return t.tool===`plan`||t.tool===`update_plan`}function eJ(e){let t=Cq(e);return e.type===J.UPDATE&&Array.isArray(t.updates)?!0:e.type===J.PLAN&&Array.isArray(t.plan)}function tJ(e){return typeof e.activity_group_id==`string`&&e.activity_group_id.trim()?e.activity_group_id.trim():void 0}function nJ(e){if(typeof e.tool_use_id==`string`&&e.tool_use_id.trim())return e.tool_use_id.trim();if(typeof e.tool_run_id==`string`&&e.tool_run_id.trim())return e.tool_run_id.trim();if(typeof e.tool==`string`&&e.tool.trim())return e.tool.trim()}function rJ(e){let t=new Map,n=new Map,r=(e,t,n)=>{if(!t||!n)return;let r=e.get(t)??new Set;r.add(n),e.set(t,r)};for(let i of e){let e=Cq(i),a=tJ(e),o=nJ(e);e.tool_event===`started`&&r(t,a,o),typeof e.approval_decision==`string`&&r(n,a,o)}return new Set([...t.entries(),...n.entries()].filter(([,e])=>e.size>1).map(([e])=>e))}function iJ(e,t){let n=tJ(e),r=nJ(e);if(n)return r&&t.has(n)?`activity:${n}:tool:${r}`:`activity:${n}`;if(typeof e.tool_use_id==`string`&&e.tool_use_id.trim())return`tool-use:${e.tool_use_id.trim()}`;if(typeof e.tool_run_id==`string`&&e.tool_run_id.trim())return`run:${e.tool_run_id.trim()}`}function aJ(e){let t=new Map,n=[],r,i=rJ(e);e.forEach((e,a)=>{let o=Cq(e);if(uU(e)){n.push({index:a,message:e}),r=void 0;return}let s=iJ(o,i),c=!s&&eJ(e)?r:void 0,l=s??c;if(!l){n.push({index:a,message:e});return}let u=t.get(l);u?u.messages.push(e):t.set(l,{index:a,messages:[e]}),$q(e)?r=l:e.type===J.PLAN&&(r=void 0)});let a=Array.from(t.values()).map(({index:e,messages:t})=>{let n=[...t].sort((e,t)=>jK(e.timestamp)-jK(t.timestamp)),r=n[n.length-1],i=n.find(e=>Cq(e).tool_event===`started`),a=n.find(e=>KK(e)),o=n.findLast(e=>typeof Cq(e).approval_decision==`string`&&!!KK(e)),s=n.findLast(e=>KK(e).startsWith(`$ `)),c=n.findLast(e=>(e.type===J.ERROR||e.type===J.WARNING)&&KK(e)),l={};for(let e of n)Object.assign(l,Cq(e));c&&l.error===void 0&&l.stderr===void 0&&(l.error=KK(c)),!c&&n.some(e=>e.type===J.PLAN&&Array.isArray(e.details?.plan))&&(l.tool_status=`completed`),s&&l.command===void 0&&(l.command=KK(s)),l[bq]=n[0]?.timestamp,l[xq]=n[n.length-1]?.timestamp;let u=typeof i?.details?.message_to_human==`string`?i.details.message_to_human:``;return{index:e,message:{...r,message:o?.message||u||(a?a.message:r.message),details:l}}});return[...n,...a].sort((e,t)=>e.index-t.index).map(({message:e})=>e)}function oJ(e){let t=new Set,n=[];return aJ(e).forEach((e,r)=>{let i=Qq(e,r);if(!i)return;let a=`${i.kind}:${i.label}:${i.title}:${i.text??``}`;t.has(a)||(t.add(a),n.push(i))}),n}function sJ({kind:e,status:n}){if(n===`error`||n===`warning`)return t(vb,{className:`size-3.5`});switch(e){case`search`:return t(Ay,{className:`size-3.5`});case`read`:return t(Gg,{className:`size-3.5`});case`edit`:return t(ey,{className:`size-3.5`});case`command`:return t(fb,{className:`size-3.5`});case`skill`:return t(Hm,{className:`size-3.5`});case`discover`:return t(Hb,{className:`size-3.5`});case`think`:return t(Hm,{className:`size-3.5`});default:return t(Hb,{className:`size-3.5`})}}function cJ(e){let t=[],n=FK(e.startedAt),r=FK(e.finishedAt),i=IK(e.startedAt),a=IK(e.finishedAt);return e.toolName&&t.push({label:`Tool`,value:e.toolName}),i&&a&&n!==void 0&&r!==void 0&&n!==r?(t.push({label:`Started`,value:i}),t.push({label:`Ended`,value:a}),t.push({label:`Duration`,value:PK(NK(e.startedAt,e.finishedAt))})):(i||a)&&t.push({label:`Time`,value:i??a??``}),t}function lJ({hasDetailContent:e,item:r}){let i=cJ(r);return i.length===0?null:t(`dl`,{className:z(`flex flex-wrap gap-x-4 gap-y-1 text-xs`,e&&`mb-3 border-b border-border/60 pb-2`),children:i.map(e=>n(`div`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[t(`dt`,{className:`shrink-0 text-muted`,children:e.label}),t(`dd`,{className:`min-w-0 wrap-break-word font-medium text-foreground/80`,children:e.value})]},e.label))})}function uJ({section:e}){let r=e.value,i=typeof r==`string`||typeof r==`number`||typeof r==`boolean`,a=e.label===`Files`&&Array.isArray(r),o=e.label===`Output`;if(a){let e=Array.from(new Set(r.map(e=>hq(e))));return t(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:e.map(e=>t(`span`,{className:`rounded-md bg-mixer-muted/15 px-1.5 py-0.5 font-mono text-[11px] text-muted`,children:Hq(e,64)},e))})}let s=z(`text-xs font-medium`,e.tone===`error`?`text-destructive`:`text-muted`),c=i&&!String(r).includes(`
996
- `)&&String(r).length<180?t(`div`,{className:z(`break-words text-xs`,e.tone===`error`?`text-destructive`:`text-foreground/75`),children:String(r)}):t(`pre`,{className:z(`max-h-52 overflow-auto whitespace-pre-wrap rounded-lg px-3 py-2 font-mono text-[11px] leading-relaxed`,e.tone===`error`?`bg-destructive/5 text-destructive`:`bg-mixer-muted/10 text-foreground/75`),children:Jq(r)});return n(`div`,{className:`mt-2`,children:[o?null:t(`div`,{className:z(`mb-1`,s),children:e.label}),c]})}function dJ(e){return e.kind===`command`?`Shell`:e.label}function fJ(e){if(e.kind!==`command`)return e.title;let t=e.command||e.title;return t.trim().startsWith(`$`)?t:`$ ${t}`}function pJ(e){let t=[dJ(e),fJ(e)],n=cJ(e).map(e=>`${e.label}: ${e.value}`);n.length>0&&t.push(n.join(`
995
+ `}),!b&&t(`div`,{className:`group`,children:v.map((e,n)=>{let r=y[n]??sK(e);return t(_K,{message:e,isExpanded:S.has(r),onToggle:()=>R(r),artifactRunId:k,classNames:{toolBadgeClassName:m,itemClassName:h,itemHeaderClassName:g,itemContentClassName:_}},r)})})]})}const xK=gt(bK,(e,t)=>e.messages.length!==t.messages.length||e.showPulsatingCircle!==t.showPulsatingCircle||e.toolRunId!==t.toolRunId||e.toolStatus!==t.toolStatus||e.preambleText!==t.preambleText||e.rootClassName!==t.rootClassName||e.headerClassName!==t.headerClassName||e.senderClassName!==t.senderClassName||e.toolSummaryClassName!==t.toolSummaryClassName||e.toolBadgeClassName!==t.toolBadgeClassName||e.itemClassName!==t.itemClassName||e.itemHeaderClassName!==t.itemHeaderClassName||e.itemContentClassName!==t.itemContentClassName?!1:e.messages.every((e,n)=>cK(e,t.messages[n])));Q();const SK=`flex items-center gap-1.5 px-2 py-1 text-xs font-medium whitespace-nowrap transition-colors border-b-2 shrink-0 cursor-pointer`,CK=`border-transparent text-muted hover:bg-muted`,wK=`border-info bg-info text-info`;function TK(e){return e.length>20?`${e.substring(0,18)}...`:e}function EK({items:e,current:r,onSelect:i,label:a,active:o,count:s,completionStatus:c}){return t(fe,{label:a,triggerClassName:z(SK,o?wK:CK),icon:t(rh,{className:`ms-0.5 size-3.5`}),children:e.map(([e,a])=>{let o=(s?.get(e)??0)>0;return n(D,{onClick:()=>i(e),className:z(`flex items-center gap-2`,e===r&&`text-info`),children:[t(`span`,{className:`truncate`,children:a}),o&&n(`span`,{className:`ms-auto inline-flex items-center gap-1`,children:[t(`span`,{className:`inline-flex items-center justify-center rounded-full bg-muted px-1.5 text-[10px] text-muted`,children:s?.get(e)}),c&&e!==`all`&&(c.get(e)?t(Nh,{className:`size-3 text-success`}):t(rg,{className:`size-3 text-attention`}))]})]},e)})})}function DK({entries:r,activeWorkstream:i,onSelectWorkstream:a,count:o,completionStatus:s}){let{t:c}=K(),{containerRef:l,setItemRef:u,setMoreRef:d,visible:f,overflow:p,activeInOverflow:m}=et(r,([e])=>e===i),h=c(`agent.moreTabs`),g=(r,i,a)=>{let c=(o?.get(r)??0)>0;return n(e,{children:[TK(i),c&&n(`span`,{className:`flex items-center gap-1`,children:[t(`span`,{className:z(`inline-flex items-center justify-center p-1 text-xs rounded-full`,a?`bg-info text-info`:`bg-muted text-muted`),children:o?.get(r)}),s&&r!==`all`&&(s.get(r)?t(Nh,{className:`size-3 text-success`}):t(rg,{className:`size-3 text-attention`}))]})]})};return n(`div`,{ref:l,className:`relative mb-1 bg-muted border-b border-muted/20`,children:[n(`div`,{"aria-hidden":!0,className:`pointer-events-none invisible absolute start-0 top-0 flex w-max gap-1`,children:[r.map(([e,n],r)=>t(`button`,{type:`button`,tabIndex:-1,ref:u(r),className:z(SK,CK),children:g(e,n,!1)},e)),n(`button`,{type:`button`,tabIndex:-1,ref:d,className:z(SK,CK),children:[h,t(rh,{className:`ms-0.5 size-3.5`})]})]}),n(`div`,{className:`flex gap-1 overflow-hidden`,children:[f.map(([e,n])=>{let r=i===e;return t(`button`,{type:`button`,"aria-current":r?`page`:void 0,onClick:()=>a(e),title:n.length>20?n:void 0,className:z(SK,r?wK:CK),children:g(e,n,r)},e)}),p.length>0&&t(EK,{items:p,current:i,onSelect:a,label:h,active:m,count:o,completionStatus:s})]})]})}function OK({workstreams:e,activeWorkstream:n,onSelectWorkstream:r,count:i,completionStatus:a}){let{t:o}=K(),s=new Map;s.set(`all`,o(`agent.allMessages`)),s.set(`main`,o(`agent.main`)),e.forEach((e,t)=>{t!==`all`&&t!==`main`&&t!==`research_france`&&t!==`statistics`&&s.set(t,e)}),e=s;let c=Array.from(e.entries()).sort(([e],[t])=>e===`all`?-1:t===`all`?1:e===`main`?-1:t===`main`?1:e.localeCompare(t));return c.length>2?t(DK,{entries:c,activeWorkstream:n,onSelectWorkstream:r,count:i,completionStatus:a}):t(`div`,{className:`py-0.5`})}function kK(e){let t=new Map,n=Xt.getFixedT(null,Yt);return t.set(`all`,n(`agent.allMessages`)),t.set(`main`,n(`agent.main`)),e.forEach(e=>{e.workstream_id&&e.workstream_id!==`main`&&e.workstream_id!==`all`&&!t.has(e.workstream_id)&&t.set(e.workstream_id,e.workstream_id)}),t}function AK(e,t){return t===`all`?[...e]:t===`main`?e.filter(e=>eU(e)===`main`):e.filter(e=>eU(e)===t)}Q();const jK=e=>e.type===J.BATCH_PROGRESS&&!!e.details?.batch_id;function MK(e){if(e==null||e===``)return Date.now();let t=typeof e==`number`?e:new Date(e).getTime();return Number.isFinite(t)?t:Date.now()}function NK(e){let t=Date.now()-MK(e);return Math.max(0,Math.round(t/1e3))}function PK(e,t){let n=MK(t)-MK(e);return Math.max(0,Math.round(n/1e3))}function FK(e){if(e<60)return`${e}s`;let t=Math.floor(e/60),n=e%60;return n>0?`${t}m ${n}s`:`${t}m`}function IK(e){if(e==null||e===``)return;let t=typeof e==`number`?e:new Date(e).getTime();return Number.isFinite(t)?t:void 0}function LK(e){let t=IK(e);if(t!==void 0)return new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}).format(new Date(t))}function RK(e){let t=e.details,n=t?.tool||``,r=Array.isArray(t?.tools)?t.tools.map(e=>typeof e==`string`?e:e.name||e.tool||``).filter(Boolean):[],i=[n,...r].join(` `).toLowerCase(),a=n.toLowerCase(),o=typeof e.message==`string`?e.message.trim():``;return t?.display_role===`tool_preamble`?i.includes(`search`)||i.includes(`web`)||i.includes(`fetch`)?`Preparing search`:r.length>0?`Preparing tools`:`Thinking`:a.includes(`search`)?`Searching`:a.includes(`fetch`)||a.includes(`web`)?`Searching the web`:a.includes(`read`)||a.includes(`document`)?`Reading`:a.includes(`edit`)||a.includes(`write`)||a.includes(`create`)?`Editing`:a.includes(`bash`)||a.includes(`shell`)||a.includes(`command`)?`Running command`:o||`Using tool`}function zK(e){return e?`Working`:`Worked`}function BK(e){return e.length>0&&e.every(IG)}function VK(e){return zK(e)}function HK(e){let t=e.filter(e=>eU(e)===`main`);return(t[t.length-1]??e[e.length-1])?.type===J.QUESTION}function UK(e,t){let n=e.filter(e=>eU(e)===`main`),r=n[n.length-1]??e[e.length-1];if(!r||!$U(r,t))return!1;let i=Bq(r);return i===`allow_once`||i===`allow_for_run`}function WK(e){if(e.type!==J.UPDATE)return;let t=wq(e);if(t.tool!==void 0||t.activity_group_id!==void 0)return;let n=typeof t.path==`string`&&t.path.trim()?t.path.trim():void 0;if(n)return qK(e)===`Prepared and saved artifact to ${n}`?n:void 0}function GK(e,t){let n=eU(e[t]);for(let r=t-1;r>=0;--r){let t=e[r];if(eU(t)!==n)continue;let i=wq(t);if(i.tool===`write_artifact`&&typeof i.activity_group_id==`string`)return t;if(t.type!==J.REQUEST_INPUT&&!Bq(t)&&i.display_role!==`thinking`&&(typeof i.tool==`string`&&i.tool!==`write_artifact`||t.type===J.ANSWER||t.type===J.COMPLETE||t.type===J.IDLE||t.type===J.TERMINATED))return}}function KK(e){return e.map((t,n)=>{let r=WK(t);if(!r)return t;let i=GK(e,n),a=i?wq(i):void 0;if(!a)return t;let o=typeof a.activity_group_id==`string`?a.activity_group_id:void 0,s=typeof a.tool_run_id==`string`?a.tool_run_id:void 0,c=typeof a.tool_use_id==`string`?a.tool_use_id:void 0,l=typeof a.tool_iteration==`number`?a.tool_iteration:void 0;return o?{...t,details:{...t.details,event_class:`activity`,tool:`write_artifact`,tool_run_id:s??`write_artifact`,tool_use_id:c??s??`write_artifact`,tool_iteration:l,tool_status:`completed`,tool_event:`progress`,activity_group_id:o,output:qK(t),path:r}}:t})}function qK(e){return e.message?typeof e.message==`object`?JSON.stringify(e.message,null,2):String(e.message).trim():``}function JK({message:e,details:r,onSelectWorkstream:i}){let{t:a}=K(),o=FH(r.workstreamId,r.interaction),s=r.interaction?NH(r.interaction):``,c=s&&s!==o?s:void 0;return t(`div`,{className:`mx-auto w-full max-w-3xl px-1`,"data-workstream-id":r.workstreamId,children:n(`button`,{type:`button`,className:z(`group flex w-full items-start gap-3 border-b border-border/70 py-2 text-start text-sm text-muted`,`transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2`,`focus-visible:ring-focus focus-visible:ring-offset-2 focus-visible:ring-offset-background`),onClick:()=>i?.(r.workstreamId),children:[t(Am,{className:`mt-0.5 size-4 shrink-0 text-muted`,"aria-hidden":`true`}),n(`div`,{className:`min-w-0 flex-1`,children:[n(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[t(`span`,{className:`font-medium text-muted`,children:a(`agent.workstreams`)}),t(`span`,{className:`min-w-0 truncate text-foreground/85`,children:o})]}),c&&t(`div`,{className:`mt-0.5 truncate text-xs text-muted/75`,children:c}),t(`span`,{className:`sr-only`,children:qK(e)})]}),t(lh,{className:`mt-0.5 size-4 shrink-0 text-muted transition-transform group-hover:translate-x-0.5 rtl:rotate-180 rtl:group-hover:-translate-x-0.5`})]})})}const YK=/\[[^\]]+\]\((?:\/store\/(?:objects|collections)\/|store:|document:|document:\/\/|collection:)[^)]+\)/,XK={table:aq};function ZK(e){if(!e||typeof e!=`object`)return``;let t=e;return typeof t.value==`string`?t.value:Array.isArray(t.children)?t.children.map(ZK).join(``):``}function QK(e,t){if(!e||typeof e!=`object`)return[];let n=e.children;return Array.isArray(n)?n.filter(e=>{if(!e||typeof e!=`object`)return!1;let n=e;return t?n.tagName===t:typeof n.tagName==`string`}):[]}function $K(e){return QK(e).filter(e=>e.tagName===`thead`||e.tagName===`tbody`).flatMap(e=>QK(e,`tr`).map(e=>QK(e).filter(e=>e.tagName===`th`||e.tagName===`td`).map(e=>ZK(e).replace(/\s+/g,` `).trim())))}function eq(e){return QK(e,`tbody`).flatMap(e=>QK(e,`tr`).map(e=>QK(e,`td`).map(e=>ZK(e).replace(/\s+/g,` `).trim())))}function tq(e){let t=$K(e),n=eq(e),r=Math.max(0,...t.map(e=>e.length));if(r<=1)return new Set;let i=new Set;for(let e=0;e<r;e+=1){let t=n.map(t=>t[e]||``).map(e=>e.trim()).filter(Boolean);if(t.length===0)continue;let r=t.map(e=>e.length),a=Math.max(...r),o=r.reduce((e,t)=>e+t,0)/r.length,s=t.some(e=>/\S{12,}/.test(e));a<=16&&o<=10&&!s&&i.add(e)}return i.size>=r?new Set:i}function nq(e,t,n){return Math.min(n,Math.max(t,e))}function rq(e){return e.reduce((e,t)=>{let n=t.match(/\S+/g)||[];return Math.max(e,...n.map(e=>e.length))},0)}function iq(e){let t=$K(e),n=Math.max(0,...t.map(e=>e.length));if(n<=1)return[];let r=tq(e),i=Array.from({length:n},(e,n)=>{if(r.has(n))return 8;let i=t.map(e=>e[n]||``).map(e=>e.trim()).filter(Boolean);if(i.length===0)return 18;let a=i.map(e=>e.length),o=Math.max(...a),s=a.reduce((e,t)=>e+t,0)/a.length,c=rq(i);return nq(s*.7+o*.25+c*.45,18,90)}),a=i.reduce((e,t,n)=>e+(r.has(n)?0:t),0);return a<=0?[]:i.map((e,t)=>{let n=e/a,i=r.has(t)?`8rem`:`calc(${(n*100).toFixed(3)}% - ${(r.size*8*n).toFixed(3)}rem)`;return{key:`agent-markdown-table-column-${t}`,compact:r.has(t),width:i}})}function aq({node:e,className:r,children:i,...a}){let o=iq(e);return t(`div`,{className:`overflow-x-auto`,children:n(`table`,{...a,className:r,style:{minWidth:`${o.length*8}rem`,...a.style},children:[o.length>0?t(`colgroup`,{children:o.map(e=>t(`col`,{className:e.compact?`agent-markdown-table-compact-col`:void 0,style:{"--agent-markdown-table-column-width":e.width}},e.key))}):null,i]})})}function oq(e){if(e==null||typeof e==`boolean`)return 0;if(typeof e==`string`||typeof e==`number`)return String(e).length;if(Array.isArray(e))return e.reduce((e,t)=>e+oq(t),0);if(ot.isValidElement(e)){let t=e.props;return oq(t.children)}return 0}function sq(e,t){let[n,r]=G(()=>NK(e));return H(()=>{if(!t){r(NK(e));return}let n=()=>r(NK(e));n();let i=window.setInterval(n,1e3);return()=>window.clearInterval(i)},[t,e]),n}function cq(e=!0){let[t,n]=G(0);return H(()=>{if(!e)return;let t=window.setInterval(()=>{n(()=>Math.floor(Math.random()*CW.length))},4e3);return()=>window.clearInterval(t)},[e]),t}function lq({children:e,message:r,workstreamId:i,className:a,artifactRunId:o,onOpenArtifact:s,markdownComponents:c}){let{t:l}=K(),[u,d]=G(!1),f=U(()=>oq(e),[e])>520,p=typeof e==`string`||typeof e==`number`,m=p?String(e):``,h=typeof e==`string`&&YK.test(e),g=r?QW(r):void 0;return H(()=>{!f&&u&&d(!1)},[u,f]),t(`div`,{className:`mx-auto flex w-full max-w-3xl justify-end px-1`,children:n(`div`,{className:z(`max-w-[min(44rem,82%)] rounded-[1.35rem] bg-mixer-muted/35 px-4 py-2.5`,`text-sm font-normal leading-6 text-foreground/90 shadow-sm shadow-black/5 dark:bg-mixer-muted/15 dark:text-foreground/88 dark:shadow-none`,`break-words [overflow-wrap:anywhere]`,a),"data-workstream-id":i,children:[t(`div`,{className:z(p&&!h&&`whitespace-pre-wrap`,f&&!u&&`max-h-72 overflow-hidden [mask-image:linear-gradient(to_bottom,black_76%,transparent_100%)]`),children:h?t(Nt,{artifactRunId:o,onArtifactOpen:s,components:c,className:z(`agent-markdown vprose prose max-w-none break-words text-sm leading-6 text-foreground/90`,`prose-p:my-0 prose-p:leading-6 prose-a:text-foreground prose-a:underline prose-a:decoration-muted prose-a:underline-offset-4`,`[&_p+_p]:mt-2`),children:m}):e}),f&&n(`button`,{type:`button`,"aria-expanded":u,className:`mt-2 inline-flex items-center gap-1 text-sm font-medium text-muted transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>d(e=>!e),children:[l(u?`agent.showLess`:`agent.showMore`),t(rh,{className:z(`size-4 transition-transform`,u&&`rotate-180`),"aria-hidden":`true`})]}),r&&g?t(`div`,{className:`mt-1.5 flex justify-end`,children:t(eG,{message:r,className:`h-4 w-4`})}):null]})})}function uq({message:r,onSendMessage:i,onOpenArtifact:a,onSelectWorkstream:o,requestInputAnswered:s=!1,StoreLinkComponent:c,CollectionLinkComponent:l}){let{router:u}=$n(),d=r.type===J.REQUEST_INPUT?xU(r):qK(r),f=UH(r)??WH(r),p=eU(r),m=r.workflow_run_id,h=U(()=>r.type===J.QUESTION?KW(d):null,[d,r.type]),g=U(()=>r.type===J.QUESTION?gW(r.details?.editing_action):void 0,[r.details,r.type]),_=U(()=>({...XK,a:TW({StoreLinkComponent:c,CollectionLinkComponent:l,addStickyParams:e=>u.getTopRouter().navigator.addStickyParams(e)})}),[c,l,u]);if(f)return t(JK,{message:r,details:f,onSelectWorkstream:o});if(r.type===J.QUESTION){let i=h?.body??d,o=h?.attachments??[];return n(e,{children:[o.length>0&&t(`div`,{className:`mx-auto flex w-full max-w-3xl justify-end px-1`,children:t(VW,{items:o,artifactRunId:m,onOpenArtifact:a,align:`end`,variant:`message`,StoreLinkComponent:c,CollectionLinkComponent:l})}),i&&t(lq,{message:r,workstreamId:p,artifactRunId:m,onOpenArtifact:a,markdownComponents:_,className:g?`max-w-[min(44rem,90%)]`:void 0,children:g?t(SW,{action:g}):i})]})}let v=r.details;if(r.type===J.REQUEST_INPUT&&v?.ux){let e=v.ux,n=DH(e.options)&&e.options.length>0;return t(`div`,{className:`mx-auto w-full max-w-3xl px-1`,children:t(jH,{question:d,options:n?e.options:void 0,variant:e.variant,multiSelect:e.multiSelect,onSelect:e=>RU(i,r,e,GU(r,e)),onMultiSelect:e=>RU(i,r,e.join(`, `)),allowFreeResponse:!n||!!e.free_response,placeholder:e.free_response?.placeholder,submitLabel:e.free_response?.submit_label,onSubmit:t=>RU(i,r,t,e.free_response?.metadata),hideBorder:!0,compact:!0,answered:s})})}let y=r.type===J.ERROR||r.type===J.WARNING;return n(`div`,{className:`mx-auto w-full max-w-3xl px-1`,"data-workstream-id":p,children:[y&&t(`div`,{className:`mb-2 text-xs font-medium text-destructive`,children:r.type===J.WARNING?`Warning`:`Error`}),d&&t(`div`,{className:z(uW,y&&`rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2`),style:{overflowWrap:`anywhere`},children:t(Nt,{artifactRunId:m,onArtifactOpen:a,onProposalSelect:e=>i?.(e),onProposalSubmit:e=>i?.(e),components:_,children:d})})]})}function dq(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function fq(e){return e==null?!1:typeof e==`string`?e.trim().length>0:Array.isArray(e)?e.length>0:typeof e!=`object`||Object.keys(e).length>0}function pq(e){return e==null||e===!1?!1:typeof e!=`string`||e.trim().length>0}function mq(e){if(!e||!dq(e))return{};let t=e.properties;return dq(t)?t:{}}function hq(e,t){let n=e&&dq(e)?e.title:void 0;return typeof n==`string`&&n.trim()?n:t.replace(/[_-]+/g,` `).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/\b\w/g,e=>e.toUpperCase())}function gq(e){if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e,null,2)}catch{return String(e)}}function _q(e){return e==null||e===``?t(`span`,{className:`text-muted`,children:`Not provided`}):typeof e==`boolean`?e?`Yes`:`No`:typeof e==`number`?String(e):typeof e==`string`?t(`span`,{className:`whitespace-pre-wrap`,children:e}):Array.isArray(e)&&e.every(e=>typeof e!=`object`||!e)?e.map(e=>gq(e)).join(`, `):t(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap rounded-md bg-background/55 px-2 py-1.5 font-mono text-[12px] leading-relaxed text-foreground/80`,children:gq(e)})}function vq(e,r,i){if(!fq(e))return null;if(!dq(e))return _q(e);let a=mq(r),o=[...Object.keys(a),...Object.keys(e).filter(e=>!(e in a))].map(t=>({key:t,label:hq(a[t],t),value:e[t]})).filter(e=>fq(e.value));return o.length===0?null:n(`div`,{className:`space-y-2 text-start`,children:[i?t(`div`,{className:`text-xs font-medium uppercase tracking-normal text-muted`,children:i}):null,t(`dl`,{className:`space-y-2`,children:o.map(e=>n(`div`,{className:`grid gap-1 sm:grid-cols-[minmax(7rem,32%)_1fr] sm:gap-3`,children:[t(`dt`,{className:`text-xs font-medium text-muted`,children:e.label}),t(`dd`,{className:`min-w-0 break-words text-sm text-foreground`,children:_q(e.value)})]},e.key))})]})}function yq({data:e,schema:n,title:r,template:i,prependFriendlyMessage:a,timestamp:o,isSummaryView:s,messageItemClassNames:c,messageStyleOverrides:l,StoreLinkComponent:u,CollectionLinkComponent:d}){let f=a?.trim()||(typeof e==`string`?e.trim():``),p=i?.({data:e??a,schema:n,title:r});if(!pq(p)&&f){let e={type:J.QUESTION,message:f,timestamp:MK(o),workflow_run_id:``,workstream_id:`main`};return s?t(uq,{message:e,StoreLinkComponent:u,CollectionLinkComponent:d}):t(yG,{...c,messageStyleOverrides:l,message:e})}let m=pq(p)?p:vq(e,n,r);return pq(m)?t(lq,{className:`py-3`,children:m}):null}function bq({label:e,timestamp:r,className:i}){let a=cq(),o=sq(r,!0);return t(`div`,{className:z(`mx-auto w-full max-w-3xl px-1`,i),children:n(`div`,{className:`border-b border-border/70 pb-4 text-sm text-muted`,children:[n(`div`,{className:`flex items-center gap-3`,children:[t(aW,{size:`sm`,color:`blue`}),n(`div`,{className:`min-w-0`,children:[n(`div`,{children:[t(`span`,{className:`font-medium`,children:e}),n(`span`,{className:`ms-2 text-muted/75`,children:[`for `,FK(o)]})]}),t(`div`,{className:`mt-1 truncate text-muted/80`,children:CW[a]})]})]}),t(`div`,{className:`mt-3 ps-6`,children:t(iW,{color:`blue`})})]})})}const xq=`_summary_started_at`,Sq=`_summary_finished_at`,Cq=new Set([`account_id`,`activity_group_id`,`activity_id`,`channel_id`,`collection_id`,`document_id`,`display_role`,`duration_ms`,`event_class`,`id`,`object_id`,`project_id`,`run_id`,`streamed`,`tenant_id`,`thread_id`,`tool`,`tool_event`,`tool_iteration`,`tool_run_id`,`tool_use_id`,`tool_status`,`tools`,`message_to_human`,`progress_messages`,`resources`,`source`,`token_usage`,`checkpoint_at`,`checkpoint_threshold`,`approval_decision`,`approval_request`,`cancellation_reason`,xq,Sq,`workflow_run_id`]);function wq(e){return dq(e.details)?e.details:{}}function Tq(e){if(e.type!==J.UPDATE)return!1;let t=wq(e).event_class;return t===`document_created`||t===`document_updated`}function Eq(e){return e.replace(/[_-]+/g,` `).replace(/\s+/g,` `).trim().replace(/\b\w/g,e=>e.toUpperCase())}function Dq(e){let t=[];if(typeof e.tool==`string`&&e.tool.trim()&&t.push(e.tool.trim()),Array.isArray(e.tools)){for(let n of e.tools)if(typeof n==`string`&&n.trim())t.push(n.trim());else if(dq(n)){let e=typeof n.name==`string`?n.name:n.tool;typeof e==`string`&&e.trim()&&t.push(e.trim())}}return t}function Oq(e){let t=Array.from(new Set(Dq(e)));return t.length>0?t.join(`, `):void 0}function kq(e){return typeof e==`number`||typeof e==`string`?e:void 0}const Aq=[`query`,`path`,`file`,`file_name`,`fileName`,`filename`,`name`,`title`,`artifact`,`artifact_path`,`url`,`command`];function jq(e){for(let t of Aq){let n=e[t];if(typeof n==`string`&&n.trim())return{key:t,value:n.trim()};if(typeof n==`number`||typeof n==`boolean`)return{key:t,value:String(n)}}}function Mq(e){let t=wq(e),n=Dq(t).join(` `).toLowerCase(),r=typeof t.tool==`string`?t.tool.toLowerCase():``,i=r||n;return dU(e)?`think`:r.startsWith(`learn_`)||n.includes(`learn_`)?`skill`:r===`discover_tools`?`discover`:e.type===J.THOUGHT&&!r?`think`:i.includes(`search`)||i.includes(`web`)||i.includes(`fetch`)?`search`:i.includes(`read`)||i.includes(`document`)||i.includes(`file`)?`read`:i.includes(`edit`)||i.includes(`write`)||i.includes(`patch`)||i.includes(`create`)?`edit`:i.includes(`bash`)||i.includes(`shell`)||i.includes(`command`)||i.includes(`terminal`)?`command`:e.type===J.THOUGHT&&n.length===0?`think`:`tool`}function Nq(e){switch(e){case`search`:return`Search`;case`read`:return`Read`;case`edit`:return`Edit`;case`command`:return`Bash`;case`skill`:return`Skill`;case`discover`:return`Tool`;case`think`:return`Thought`;default:return`Tool`}}function Pq(e){let t=jq(e);if(t)return t.value;let n=e.files??e.outputFiles;if(Array.isArray(n)&&n.length>0)return n.map(e=>gq(e)).join(`, `)}function Fq(e){return typeof e==`string`&&e!==`auto_approved`}function Iq(e,t){switch(e){case`denied`:case`denied_with_feedback`:return`User declined to use ${t}.`;case`timeout`:return`Approval timed out for ${t}.`;case`reviewer_denied`:return`Approval reviewer denied ${t}.`;case`cancelled_after_denial`:return`Cancelled ${t} after another tool was denied.`;case`auto_approved`:return`Approval no longer required for ${t}.`;default:return}}function Lq(e){switch(e){case`denied`:case`denied_with_feedback`:return`Declined by user`;case`timeout`:return`Approval timed out`;case`reviewer_denied`:return`Denied by reviewer`;case`cancelled_after_denial`:return`Cancelled after denial`;case`auto_approved`:return`Approved without asking`;default:return}}function Rq(e){let t=wq(e).tool_approval;return dq(t)?t:void 0}function zq(e){let t=e?.approval_key;return typeof t==`string`&&t.trim()?t.trim():void 0}function Bq(e){if(e.type!==J.QUESTION)return;let t=qK(e).trim().toLowerCase();if(t===`allow_once`||t===`allow_for_run`||t===`deny`)return t}function Vq(e){let t=e.tool_title;if(typeof t==`string`&&t.trim())return t.trim();let n=e.tool_name;return typeof n==`string`&&n.trim()?Eq(n.trim()):`tool action`}function Hq(e,t){let n=[];return e.forEach((r,i)=>{if(r.type!==J.REQUEST_INPUT)return;let a=Rq(r),o=zq(a);if(!a||!o||t.has(o))return;let s=eU(r),c;for(let t=i+1;t<e.length;t+=1){let n=e[t];if(eU(n)===s){if(n.type===J.REQUEST_INPUT)break;if(n.type===J.QUESTION){c=n;break}}}if(!c||Bq(c)!==`deny`)return;let l=typeof a.tool_name==`string`&&a.tool_name.trim()?a.tool_name.trim():`tool_action`,u=Vq(a),d=typeof a.target==`string`&&a.target.trim()?a.target:``,f={tool_name:l,tool_title:a.tool_title,action_summary:a.action_summary,target:a.target,approval_key:o};n.push({timestamp:c.timestamp??r.timestamp,workflow_run_id:c.workflow_run_id||r.workflow_run_id,type:J.THOUGHT,message:Iq(`denied`,u)??`User declined to use ${u}.`,workstream_id:s,details:{event_class:`activity`,tool:l,tool_run_id:`approval:${o}`,tool_use_id:`approval:${o}`,tool_status:`error`,tool_event:`failed`,activity_group_id:`approval:${o}`,approval_decision:`denied`,approval_request:f,input:a.input,target:d,observation:`The user declined this tool action.`,source:`synthetic_tool_approval_decision`}})}),n.length===0?e:[...e,...n].sort((e,t)=>MK(e.timestamp)-MK(t.timestamp))}function Uq(e,t=160){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-1)}...`:n}const Wq=[`batch_id`,`activity_group_id`,`activity_id`,`tool_run_id`,`tool_use_id`,`streaming_id`,`chunk_index`,`tool_iteration`,`tool_event`];function Gq(e){for(let t of Wq){let n=e[t];if(typeof n==`string`&&n.trim())return`${t}:${n.trim()}`;if(typeof n==`number`||typeof n==`boolean`)return`${t}:${n}`}}function Kq(e,t=`message`){let n=Gq(wq(e)),r=Uq(qK(e),96);return[t,e.workstream_id||`main`,e.workflow_run_id,e.timestamp,e.type,n??r].filter(Boolean).join(`:`)}function qq(e){if(e.type===`single`)return Kq(e.message);if(e.type===`streaming`)return`streaming:${e.streamingId}:${e.startTimestamp}:${e.workstreamId||`main`}`;let t=e.messages[0],n=e.messages[e.messages.length-1],r=t?Kq(t,`first`):e.firstTimestamp,i=n?Kq(n,`last`):e.firstTimestamp;return[`group`,e.toolRunId,e.firstTimestamp,r,i].filter(Boolean).join(`:`)}function Jq(e,t){for(let n=t-1;n>=0;n--){let t=e[n];if(t.type===`single`)return t.message.timestamp;if(t.type===`tool_group`)return t.firstTimestamp;if(t.type===`streaming`)return t.startTimestamp}}function Yq(e){let t=gq(e).trim();return t.length>2400?`${t.slice(0,2400)}\n...`:t}function Xq(e,t,n,r){if(n!=null&&n!==``&&!(Array.isArray(n)&&n.length===0)&&!(dq(n)&&Object.keys(n).length===0))return{key:e,label:t,value:n,tone:r}}function Zq(e,t){let n=Object.entries(e).reduce((e,[n,r])=>(Cq.has(n)||t.has(n)||r==null||r===``||(e[n]=r),e),{});return Object.keys(n).length>0?n:void 0}function Qq(e){let t=wq(e),n=new Set,r=[],i=jq(t),a=(e,i,a)=>{for(let o of i){let i=Xq(o,e,t[o],a);if(i){n.add(o),r.push(i);return}}};a(`Query`,[`query`]),a(`Input`,[`input`,`params`,`arguments`,`args`]),a(`Output`,[`output`,`stdout`,`result`,`results`,`content`,`result_summary`,`observation`,`display_message`],Fq(t.approval_decision)?`error`:void 0),a(`Files`,[`files`,`outputFiles`]),a(`Error`,[`error`,`stderr`],`error`),i&&n.add(i.key);let o=Zq(t,n);return r.length===0&&o&&r.push({key:`details`,label:`Details`,value:o}),r}function $q(e,t){if(e.type===J.REQUEST_INPUT)return;let n=qK(e),r=wq(e),i=dU(e),a=Mq(e),o=Dq(r),s=Pq(r),c=typeof r.command==`string`&&r.command.trim()?r.command.trim():void 0,l=o[0]?Eq(o[0]):RK(e),u=Iq(r.approval_decision,l),d=Lq(r.approval_decision),f=typeof r.message_to_human==`string`&&r.message_to_human.trim()?r.message_to_human.trim():void 0,p=a===`think`?n||l:Uq(a===`command`?f||(u?``:n)||c||l:f||s||(u?``:n)||l),m=n?a===`think`?n:Uq(n,420):void 0,h=m&&m!==p&&!u;if(!(!p&&!h))return{key:`${e.timestamp}-${r.activity_id||r.tool_run_id||t}`,kind:a,label:Nq(a),title:p,isPreamble:i,command:c,text:h?m:void 0,toolName:Oq(r),startedAt:kq(r[xq])??e.timestamp,finishedAt:kq(r[Sq])??e.timestamp,status:u?`error`:r.tool_status,decisionText:d,resources:Dn(e),workflowRunId:e.workflow_run_id,sections:Qq(e)}}function eJ(e){let t=wq(e);return t.tool===`plan`||t.tool===`update_plan`}function tJ(e){let t=wq(e);return e.type===J.UPDATE&&Array.isArray(t.updates)?!0:e.type===J.PLAN&&Array.isArray(t.plan)}function nJ(e){return typeof e.activity_group_id==`string`&&e.activity_group_id.trim()?e.activity_group_id.trim():void 0}function rJ(e){if(typeof e.tool_use_id==`string`&&e.tool_use_id.trim())return e.tool_use_id.trim();if(typeof e.tool_run_id==`string`&&e.tool_run_id.trim())return e.tool_run_id.trim();if(typeof e.tool==`string`&&e.tool.trim())return e.tool.trim()}function iJ(e){let t=new Map,n=new Map,r=(e,t,n)=>{if(!t||!n)return;let r=e.get(t)??new Set;r.add(n),e.set(t,r)};for(let i of e){let e=wq(i),a=nJ(e),o=rJ(e);e.tool_event===`started`&&r(t,a,o),typeof e.approval_decision==`string`&&r(n,a,o)}return new Set([...t.entries(),...n.entries()].filter(([,e])=>e.size>1).map(([e])=>e))}function aJ(e,t){let n=nJ(e),r=rJ(e);if(n)return r&&t.has(n)?`activity:${n}:tool:${r}`:`activity:${n}`;if(typeof e.tool_use_id==`string`&&e.tool_use_id.trim())return`tool-use:${e.tool_use_id.trim()}`;if(typeof e.tool_run_id==`string`&&e.tool_run_id.trim())return`run:${e.tool_run_id.trim()}`}function oJ(e){let t=new Map,n=[],r,i=iJ(e);e.forEach((e,a)=>{let o=wq(e);if(dU(e)){n.push({index:a,message:e}),r=void 0;return}let s=aJ(o,i),c=!s&&tJ(e)?r:void 0,l=s??c;if(!l){n.push({index:a,message:e});return}let u=t.get(l);u?u.messages.push(e):t.set(l,{index:a,messages:[e]}),eJ(e)?r=l:e.type===J.PLAN&&(r=void 0)});let a=Array.from(t.values()).map(({index:e,messages:t})=>{let n=[...t].sort((e,t)=>MK(e.timestamp)-MK(t.timestamp)),r=n[n.length-1],i=n.find(e=>wq(e).tool_event===`started`),a=n.find(e=>qK(e)),o=n.findLast(e=>typeof wq(e).approval_decision==`string`&&!!qK(e)),s=n.findLast(e=>qK(e).startsWith(`$ `)),c=n.findLast(e=>(e.type===J.ERROR||e.type===J.WARNING)&&qK(e)),l={};for(let e of n)Object.assign(l,wq(e));c&&l.error===void 0&&l.stderr===void 0&&(l.error=qK(c)),!c&&n.some(e=>e.type===J.PLAN&&Array.isArray(e.details?.plan))&&(l.tool_status=`completed`),s&&l.command===void 0&&(l.command=qK(s)),l[xq]=n[0]?.timestamp,l[Sq]=n[n.length-1]?.timestamp;let u=typeof i?.details?.message_to_human==`string`?i.details.message_to_human:``;return{index:e,message:{...r,message:o?.message||u||(a?a.message:r.message),details:l}}});return[...n,...a].sort((e,t)=>e.index-t.index).map(({message:e})=>e)}function sJ(e){let t=new Set,n=[];return oJ(e).forEach((e,r)=>{let i=$q(e,r);if(!i)return;let a=`${i.kind}:${i.label}:${i.title}:${i.text??``}`;t.has(a)||(t.add(a),n.push(i))}),n}function cJ({kind:e,status:n}){if(n===`error`||n===`warning`)return t(vb,{className:`size-3.5`});switch(e){case`search`:return t(Ay,{className:`size-3.5`});case`read`:return t(Gg,{className:`size-3.5`});case`edit`:return t(ey,{className:`size-3.5`});case`command`:return t(fb,{className:`size-3.5`});case`skill`:return t(Hm,{className:`size-3.5`});case`discover`:return t(Hb,{className:`size-3.5`});case`think`:return t(Hm,{className:`size-3.5`});default:return t(Hb,{className:`size-3.5`})}}function lJ(e){let t=[],n=IK(e.startedAt),r=IK(e.finishedAt),i=LK(e.startedAt),a=LK(e.finishedAt);return e.toolName&&t.push({label:`Tool`,value:e.toolName}),i&&a&&n!==void 0&&r!==void 0&&n!==r?(t.push({label:`Started`,value:i}),t.push({label:`Ended`,value:a}),t.push({label:`Duration`,value:FK(PK(e.startedAt,e.finishedAt))})):(i||a)&&t.push({label:`Time`,value:i??a??``}),t}function uJ({hasDetailContent:e,item:r}){let i=lJ(r);return i.length===0?null:t(`dl`,{className:z(`flex flex-wrap gap-x-4 gap-y-1 text-xs`,e&&`mb-3 border-b border-border/60 pb-2`),children:i.map(e=>n(`div`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[t(`dt`,{className:`shrink-0 text-muted`,children:e.label}),t(`dd`,{className:`min-w-0 wrap-break-word font-medium text-foreground/80`,children:e.value})]},e.label))})}function dJ({section:e}){let r=e.value,i=typeof r==`string`||typeof r==`number`||typeof r==`boolean`,a=e.label===`Files`&&Array.isArray(r),o=e.label===`Output`;if(a){let e=Array.from(new Set(r.map(e=>gq(e))));return t(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:e.map(e=>t(`span`,{className:`rounded-md bg-mixer-muted/15 px-1.5 py-0.5 font-mono text-[11px] text-muted`,children:Uq(e,64)},e))})}let s=z(`text-xs font-medium`,e.tone===`error`?`text-destructive`:`text-muted`),c=i&&!String(r).includes(`
996
+ `)&&String(r).length<180?t(`div`,{className:z(`break-words text-xs`,e.tone===`error`?`text-destructive`:`text-foreground/75`),children:String(r)}):t(`pre`,{className:z(`max-h-52 overflow-auto whitespace-pre-wrap rounded-lg px-3 py-2 font-mono text-[11px] leading-relaxed`,e.tone===`error`?`bg-destructive/5 text-destructive`:`bg-mixer-muted/10 text-foreground/75`),children:Yq(r)});return n(`div`,{className:`mt-2`,children:[o?null:t(`div`,{className:z(`mb-1`,s),children:e.label}),c]})}function fJ(e){return e.kind===`command`?`Shell`:e.label}function pJ(e){if(e.kind!==`command`)return e.title;let t=e.command||e.title;return t.trim().startsWith(`$`)?t:`$ ${t}`}function mJ(e){let t=[fJ(e),pJ(e)],n=lJ(e).map(e=>`${e.label}: ${e.value}`);n.length>0&&t.push(n.join(`
997
997
  `)),e.text&&t.push(e.text),e.resources.length>0&&t.push(`Resources\n${e.resources.map(e=>`${e.label} (${e.type}:${e.id}) — ${e.action}`).join(`
998
- `)}`);for(let n of e.sections)t.push(`${n.label}\n${Jq(n.value)}`);return t.filter(Boolean).join(`
998
+ `)}`);for(let n of e.sections)t.push(`${n.label}\n${Yq(n.value)}`);return t.filter(Boolean).join(`
999
999
 
1000
- `)}async function mJ(e){try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}if(typeof document>`u`)return!1;let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.insetInlineStart=`-9999px`,t.style.top=`0`,document.body.appendChild(t);try{return t.focus(),t.select(),document.execCommand(`copy`)}catch{return!1}finally{t.remove()}}function hJ({item:e}){let r=e.kind===`command`&&e.command?fJ(e):void 0,i=!r&&e.sections.length===0?e.text:void 0,a=!!(r||i||e.sections.length),o=pJ(e),[s,c]=G(`idle`),l=W(void 0);return H(()=>()=>{l.current!==void 0&&window.clearTimeout(l.current)},[]),n(`div`,{className:`relative mt-2 rounded-lg border border-border/70 bg-mixer-muted/10 p-3 shadow-sm`,children:[a?t(`div`,{className:`absolute end-2 top-2`,children:t(`button`,{type:`button`,className:z(`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-muted opacity-70 transition`,`hover:bg-mixer-muted/20 hover:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,s===`copied`&&`text-success opacity-100`,s===`failed`&&`text-destructive opacity-100`),onClick:()=>{mJ(o).then(e=>{c(e?`copied`:`failed`),l.current!==void 0&&window.clearTimeout(l.current),l.current=window.setTimeout(()=>c(`idle`),2e3)})},"aria-label":`Copy tool details`,title:`Copy tool details`,children:t(s===`copied`?Nh:fg,{className:`size-4`})})}):null,n(`div`,{className:z(a&&`pe-7`),children:[t(lJ,{item:e,hasDetailContent:a}),r?t(`pre`,{className:`mb-3 whitespace-pre-wrap break-words font-mono text-sm leading-6 text-foreground/85`,children:r}):null,i?t(`div`,{className:`mb-3 break-words text-sm leading-6 text-foreground/75`,children:i}):null,e.sections.length>0?t(`div`,{className:`space-y-3`,children:e.sections.map(e=>t(uJ,{section:e},e.key))}):null]}),s===`failed`&&a?t(`div`,{className:`mt-3 text-xs text-destructive`,children:`Copy failed`}):null]})}function gJ({item:e}){let{t:r}=K(),a=!!e.decisionText,s=!a&&(e.status===`error`||e.status===`warning`),c=cJ(e).length>0,l=!!(e.command||e.text||e.sections.length||c),u=e.resources.length>0,[d,f]=G(!1),p=a?void 0:e.status,m=r(d?`agent.hideDetails`:`agent.showDetails`),h=u?e.resources.map(e=>e.label).join(`, `):e.title,g=t(`span`,{className:z(`flex size-5 items-center justify-center pt-0.5`,s?`text-attention`:`text-muted`),children:t(sJ,{kind:e.kind,status:p})}),_=t(rh,{className:z(`size-4 shrink-0 text-muted opacity-50 transition-transform`,!d&&`-rotate-90`),"aria-hidden":`true`});return n(`div`,{className:`min-w-0`,children:[u?n(`div`,{className:`grid w-full grid-cols-[1.5rem_1fr_auto] items-center gap-2 text-start`,children:[g,t(CG,{resources:e.resources,workflowRunId:e.workflowRunId}),l?t(We,{description:m,asChild:!0,children:t(o,{variant:`ghost`,size:`xs`,className:`size-6 p-0 text-muted`,onClick:()=>f(e=>!e),"aria-expanded":d,"aria-label":`${m}: ${h}`,children:_})}):null]}):n(`button`,{type:`button`,className:z(`grid w-full grid-cols-[1.5rem_1fr_auto] gap-2 text-start outline-none transition-colors`,`focus-visible:text-foreground focus-visible:underline focus-visible:underline-offset-4`,l?`cursor-pointer hover:text-foreground`:`cursor-default`),onClick:()=>l&&f(e=>!e),"aria-expanded":l?d:void 0,disabled:!l,children:[g,n(`span`,{className:`min-w-0 text-sm text-muted`,children:[t(`span`,{className:`break-words`,children:e.title}),e.decisionText?t(i,{variant:`destructive`,className:`ms-2 rounded-full shadow-sm shadow-destructive/10`,children:e.decisionText}):null]}),l?_:null]}),l&&d?t(`div`,{className:`mt-1`,children:t(hJ,{item:e})}):null]})}function _J({item:e,artifactRunId:r,disableCollapse:i}){let{t:a}=K(),o=e.text??e.title,s=o.trim(),[c,l]=G(!1),u=s?s.split(/\r?\n/).length:0,d=s.length>520||u>6,f=a(c?`agent.showLess`:`agent.showMore`);return n(`div`,{className:`min-w-0 py-1`,children:[t(`div`,{"data-testid":`summary-thought-prose`,className:z(lW,d&&!i&&!c&&`[display:-webkit-box] overflow-hidden [-webkit-box-orient:vertical] [-webkit-line-clamp:6]`),style:{overflowWrap:`anywhere`},children:t(Nt,{artifactRunId:r,components:YK,children:o})}),d&&!i?t(`div`,{className:`mt-1.5 flex justify-end`,children:n(`button`,{type:`button`,"aria-expanded":c,className:z(`inline-flex items-center gap-1 text-sm font-medium text-muted transition-colors`,`[text-decoration:none] hover:text-foreground hover:[text-decoration:none]`,`focus-visible:text-foreground focus-visible:[text-decoration:none]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`),onClick:()=>l(e=>!e),children:[f,t(rh,{className:z(`size-4 transition-transform`,c&&`rotate-180`),"aria-hidden":`true`})]})}):null]})}function vJ({items:e,artifactRunId:n,disablePreambleCollapse:r}){return t(`div`,{className:`mt-3`,children:t(`div`,{className:`space-y-3`,children:e.map(e=>e.isPreamble||e.kind===`think`?t(_J,{item:e,artifactRunId:n,disableCollapse:r},e.key):t(gJ,{item:e},e.key))})})}function yJ({text:e,artifactRunId:n,workstreamId:r}){return t(`div`,{className:`mx-auto w-full max-w-3xl px-1`,"data-workstream-id":r,children:t(`div`,{className:lW,style:{overflowWrap:`anywhere`},children:t(Nt,{artifactRunId:n,components:YK,children:e})})})}function bJ({message:e,startTimestamp:r,endTimestamp:i,className:a}){let{t:o}=K(),s=PK(NK(r??e.timestamp,i??e.timestamp));return n(`div`,{className:z(`mx-auto w-full max-w-3xl px-1`,a),"data-testid":`summary-stopped-message`,children:[n(`div`,{className:`flex items-center justify-end gap-2 text-sm font-medium text-muted`,children:[t(`span`,{children:o(`agent.youStoppedAfter`,{duration:s})}),t($W,{message:e,className:`h-4 w-4`})]}),t(`div`,{className:`mt-5 border-b border-border/70`})]})}function xJ({label:r,timestamp:i,durationSeconds:a,showElapsed:o,details:s,emptyDetailsLabel:c,defaultExpanded:l=!1,disablePreambleCollapse:u=!1,className:d,artifactRunId:f,onSendMessage:p,answeredToolApprovalRequestInputKeys:m,resolvedToolApprovalKeys:h}){let[g,_]=G(l),v=oq(i,o&&a===void 0),y=a??v,b=o&&i!==void 0,x=U(()=>oJ(s??[]),[s]),S=U(()=>(s??[]).filter(e=>TU(e)&&!XU(e,m??new Set,h??new Set)),[m,s,h]),C=x.length>0||S.length>0||!!c;return t(`div`,{className:z(`mx-auto w-full max-w-3xl px-1`,d),children:n(`div`,{className:`border-b border-border/70 pb-3 text-sm text-muted`,children:[n(`button`,{type:`button`,className:z(`inline-flex max-w-full items-center gap-2 text-start outline-none`,`focus-visible:text-foreground focus-visible:underline focus-visible:underline-offset-4`,C?`cursor-pointer hover:text-foreground`:`cursor-default`),onClick:()=>C&&_(e=>!e),"aria-expanded":C?g:void 0,disabled:!C,children:[t(`span`,{className:`min-w-0 truncate font-medium`,children:r}),b?n(`span`,{className:`shrink-0 text-muted/75`,children:[`for `,PK(y)]}):null,C?t(g?rh:lh,{className:`size-4 shrink-0 opacity-50`}):null]}),C&&g?x.length>0||S.length>0?n(e,{children:[x.length>0?t(vJ,{items:x,artifactRunId:f,disablePreambleCollapse:u}):null,S.length>0?t(`div`,{className:`mt-3 space-y-3`,children:S.map(e=>{let n=e.details.ux;return t(AH,{question:bU(e),options:n.options,variant:n.variant,multiSelect:n.multiSelect,onSelect:t=>LU(p,e,t,WU(e,t)),onMultiSelect:t=>LU(p,e,t.join(`, `)),allowFreeResponse:!n.options?.length||!!n.free_response,placeholder:n.free_response?.placeholder,submitLabel:n.free_response?.submit_label,onSubmit:t=>LU(p,e,t,n.free_response?.metadata),hideBorder:!0,compact:!0,className:`my-0`,cardClassName:`bg-background/60 shadow-none`},Gq(e,`work-request-input`))})}):null]}):n(`div`,{className:`mt-3 flex items-center gap-2 text-sm text-muted`,children:[t(fb,{className:`size-4 opacity-70`,"aria-hidden":`true`}),t(`span`,{children:c})]}):null]})})}function SJ({children:e,status:r}){let i=r===`error`?`bg-destructive`:r===`warning`?`bg-attention`:r===`completed`?`bg-success`:`bg-muted`;return n(`div`,{className:`relative ps-7`,children:[t(`div`,{className:`absolute start-2 top-0 bottom-0 w-px bg-border`}),t(`div`,{className:z(`absolute start-[5px] top-4 size-2.5 rounded-full ring-4 ring-background`,i)}),e]})}var CJ=class extends ct{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return console.error(`Message render error:`,e),{hasError:!0,error:e}}componentDidUpdate(e){this.state.hasError&&e.children!==this.props.children&&this.setState({hasError:!1,error:void 0})}render(){return this.state.hasError?n(`div`,{className:`border-s-4 border-s-destructive bg-destructive/10 px-4 py-2 my-2 rounded-e`,children:[t(`p`,{className:`text-sm text-destructive font-medium`,children:Xt.getFixedT(null,Yt)(`agent.failedToRenderMessage`)}),t(`p`,{className:`text-xs text-muted mt-1 truncate`,children:this.state.error?.message||`Unknown error`})]}):this.props.children}};function wJ(e,t){let n=[...e.filter(e=>!wq(e)&&!t?.includes(e.type))].sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())),r=[];for(let e of n){let t=r[r.length-1];t&&cU(t,e)||t&&EJ(t,e)||r.push(e)}return r}function TJ({messages:r,workstreamSourceMessages:i,bottomRef:a,viewMode:s=`stacked`,isCompleted:c=!1,streamingMessages:l=new Map,onSendMessage:u,onOpenArtifact:d,messageItemClassNames:f,messageStyleOverrides:p,toolCallGroupClassNames:m,hideToolCallsInViewMode:h,streamingMessageClassNames:g,batchProgressPanelClassNames:_,artifactRunId:v,hideWorkstreamTabs:y,workingIndicatorClassName:b,messageListClassName:x,StoreLinkComponent:S,CollectionLinkComponent:C,prependFriendlyMessage:w,initialRequestData:T,initialRequestSchema:E,initialRequestTitle:D,initialRequestTemplate:O,showInitialRequest:k,hiddenMessageTypes:A,disableAutoScroll:j=!1,renderRequestInputControls:M=!0,activeWorkstream:N,onActiveWorkstreamChange:P}){v||console.warn(`[AllMessagesMixed] artifactRunId prop is missing!`);let{t:F}=K(),I=W(null),[L,ee]=G(`all`),R=N??L,te=V(e=>{N===void 0&&ee(e),P?.(e)},[N,P]),ne=W(0),re=W(null),ie=W(!1),ae=W(!1),oe=l.size>0,se=s===`sliding`;H(()=>{let e=I.current;if(!e)return;let t=()=>{if(ae.current)return;let{scrollTop:t,scrollHeight:n,clientHeight:r}=e,i=n-t-r;ie.current=i>80};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[]);let ce=U(()=>{let e=0;return l.forEach(t=>{e+=t.text?.length||0}),Math.floor(e/200)},[l]),le=V(()=>{a.current&&(ae.current=!0,a.current.scrollIntoView({behavior:oe?`instant`:`smooth`}),ne.current=Date.now(),requestAnimationFrame(()=>{ae.current=!1})),re.current=null},[a,oe]);H(()=>{if(r.length,l.size,j||ie.current)return;let e=Date.now()-ne.current;if(e>=100)le();else if(re.current===null){let t=100-e;re.current=window.setTimeout(le,t)}return()=>{re.current!==null&&(clearTimeout(re.current),re.current=null)}},[r.length,l.size,ce,le,j]);let ue=ot.useMemo(()=>wJ(r,A),[r,A]),de=ot.useMemo(()=>i?wJ(i,A):ue,[i,A,ue]),fe=ot.useMemo(()=>{let e=OK(de);return de.forEach(t=>{let n=HH(t)??UH(t);n&&e.set(n.workstreamId,PH(n.workstreamId,n.interaction))}),e},[de]),pe=ot.useMemo(()=>{if(R!==`all`)return fe.get(R)??MH(R)},[R,fe]),me=V(()=>{let e=I.current;e&&(ae.current=!0,typeof e.scrollTo==`function`?e.scrollTo({top:0,behavior:`smooth`}):e.scrollTop=0,requestAnimationFrame(()=>{ae.current=!1}))},[]),he=W(R);H(()=>{he.current!==R&&(he.current=R,requestAnimationFrame(me))},[R,me]);let ge=V(e=>{te(e)},[te]),_e=V(()=>{te(`all`)},[te]);H(()=>{R!==`all`&&!fe.has(R)&&te(`all`)},[R,fe,te]);let ve=ot.useMemo(()=>{let e=new Map;e.set(`all`,de.length);let t=kK(de,`main`);return e.set(`main`,t.length),de.forEach(t=>{let n=$H(t);n!==`main`&&e.set(n,(e.get(n)||0)+1)}),e},[de]),ye=ot.useMemo(()=>GK(nU(ue,R)),[ue,R]),be=ot.useMemo(()=>FU(ye),[ye]),xe=ot.useMemo(()=>BU(ye),[ye]),Se=ot.useMemo(()=>YU(ye),[ye]),Ce=ot.useMemo(()=>ZU(ye),[ye]),we=ot.useMemo(()=>{if(M)return;let e=eW(ye);return e?EU(e):void 0},[ye,M]),Te=ot.useCallback(e=>e.type===J.REQUEST_INPUT&&(we===EU(e)||XU(e,Se,xe)),[Se,we,xe]),Ee=ot.useCallback(e=>QU(e,Ce),[Ce]),De=ot.useMemo(()=>ye.filter(e=>!Ee(e)),[ye,Ee]),Oe=W(Date.now()),ke=(!!w?.trim()||dq(T)||O!==void 0)&&(k??!0),Ae=U(()=>ye.some(e=>e.type===J.QUESTION),[ye]),je=R===`all`&&ke&&!Ae,Me=U(()=>ye.reduce((e,t)=>Math.max(e,jK(t.timestamp)),-1/0),[ye]),Ne=U(()=>ye.reduce((e,t)=>PG(t)?e:Math.max(e,jK(t.timestamp)),-1/0),[ye]),Pe=U(()=>ye.some(e=>HU(e)&&!XU(e,Se,xe)),[Se,ye,xe]),Fe=U(()=>HK(ye,Ce),[ye,Ce]),Ie=U(()=>Pe||Fe||VK(De)?!1:c||!XH(De),[De,Fe,Pe,c]),Le=U(()=>{if(de.length===0)return de;let e=r[r.length-1];if(!e)return[];let t=de.indexOf(e);if(t>=0)return t>=de.length-1?de:de.slice(0,t+1);let n=jK(e.timestamp);return de.filter(e=>jK(e.timestamp)<=n)},[de,r]),Re=U(()=>c||OG(Le),[c,Le]),ze=U(()=>DG(Le),[Le]),{completeStreaming:Be,incompleteStreaming:Ve}=ot.useMemo(()=>{let e=new Map,t=[];return l.forEach((n,r)=>{iU(n,R)&&(n.startTimestamp<=Ne?e.set(r,n):n.text&&t.push({id:r,data:n}))}),{completeStreaming:e,incompleteStreaming:t}},[l,R,Ne]),He=ot.useMemo(()=>Vq(ZG(ye,Be),xe),[ye,Be,xe]),Ue=ot.useMemo(()=>He.filter(e=>!Te(e)&&!Ee(e)),[He,Te,Ee]),We=U(()=>{if(Ve.some(({data:e})=>e.text.trim().length>0))return 1/0;let e=Ve.reduce((e,{data:t})=>Math.max(e,t.startTimestamp),-1/0);return Math.max(Me,e)},[Ve,Me]),Ge=ot.useMemo(()=>YG(Ue,Ie,We),[Ue,Ie,We]),Ke=ot.useMemo(()=>kG(Ge,e=>e.type===`message`&&e.message.type===J.QUESTION,ze,Re),[Ge,ze,Re]),qe=ot.useMemo(()=>vU(gU(ye,Be,R)),[ye,Be,R]),Je=ot.useMemo(()=>kG(qe,e=>e.type===`single`&&e.message.type===J.QUESTION,ze,Re),[qe,ze,Re]),Ye=U(()=>!Ie||VK(De),[De,Ie]),Xe=U(()=>{if(!Ye||Ve.length>0)return!1;let e=Ge[Ge.length-1],t=De[De.length-1],n=t!==void 0&&(t.details?.display_role===`thinking`||dU(t)&&t.details?.tool_status===`completed`);return e?.type===`work`&&e.isActive&&n},[De,Ve.length,Ye,Ge]),Ze=$G(Ge,Ye,Ve.length>0),Qe=eK(Ge)?F(`agent.preparing`):F(`agent.working`),$e=ye.length===0&&ke&&Ye&&Ve.length===0,et=U(()=>QG(Ge,Ue,Oe.current),[Ge,Ue]),tt=W(et),nt=W(!1),rt=U(()=>{if(!Ze)return et;let e=jK(et),t=jK(tt.current);return!nt.current||e<t?et:tt.current},[et,Ze]);H(()=>{tt.current=rt,nt.current=Ze},[rt,Ze]);let it=U(()=>{let e=new Map,t=new Map;de.forEach(e=>{let n=$H(e);t.has(n)||t.set(n,[]),t.get(n)?.push(e)});for(let[n,r]of t.entries())if(r.length>0){let t=r.some(e=>{if([J.COMPLETE,J.IDLE,J.REQUEST_INPUT,J.TERMINATED].includes(e.type))return!0;if(e.type===J.UPDATE&&e.details){let t=e.details;return t.workstream_event===`completed`||t.status===`completed`||t.status===`canceled`}return!1});e.set(n,t)}return e},[de]);return n(`div`,{ref:I,tabIndex:0,className:`flex-1 min-h-0 h-full w-full max-w-full overflow-y-auto overflow-x-hidden px-1.5 sm:px-2.5 lg:px-3 flex flex-col relative focus:outline-none`,"data-testid":`all-messages-mixed`,"data-message-count":r.length,"data-streaming-count":l.size,"data-view-mode":s,children:[t(`style`,{children:`
1000
+ `)}async function hJ(e){try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}if(typeof document>`u`)return!1;let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.insetInlineStart=`-9999px`,t.style.top=`0`,document.body.appendChild(t);try{return t.focus(),t.select(),document.execCommand(`copy`)}catch{return!1}finally{t.remove()}}function gJ({item:e}){let r=e.kind===`command`&&e.command?pJ(e):void 0,i=!r&&e.sections.length===0?e.text:void 0,a=!!(r||i||e.sections.length),o=mJ(e),[s,c]=G(`idle`),l=W(void 0);return H(()=>()=>{l.current!==void 0&&window.clearTimeout(l.current)},[]),n(`div`,{className:`relative mt-2 rounded-lg border border-border/70 bg-mixer-muted/10 p-3 shadow-sm`,children:[a?t(`div`,{className:`absolute end-2 top-2`,children:t(`button`,{type:`button`,className:z(`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-muted opacity-70 transition`,`hover:bg-mixer-muted/20 hover:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,s===`copied`&&`text-success opacity-100`,s===`failed`&&`text-destructive opacity-100`),onClick:()=>{hJ(o).then(e=>{c(e?`copied`:`failed`),l.current!==void 0&&window.clearTimeout(l.current),l.current=window.setTimeout(()=>c(`idle`),2e3)})},"aria-label":`Copy tool details`,title:`Copy tool details`,children:t(s===`copied`?Nh:fg,{className:`size-4`})})}):null,n(`div`,{className:z(a&&`pe-7`),children:[t(uJ,{item:e,hasDetailContent:a}),r?t(`pre`,{className:`mb-3 whitespace-pre-wrap break-words font-mono text-sm leading-6 text-foreground/85`,children:r}):null,i?t(`div`,{className:`mb-3 break-words text-sm leading-6 text-foreground/75`,children:i}):null,e.sections.length>0?t(`div`,{className:`space-y-3`,children:e.sections.map(e=>t(dJ,{section:e},e.key))}):null]}),s===`failed`&&a?t(`div`,{className:`mt-3 text-xs text-destructive`,children:`Copy failed`}):null]})}function _J({item:e}){let{t:r}=K(),a=!!e.decisionText,s=!a&&(e.status===`error`||e.status===`warning`),c=lJ(e).length>0,l=!!(e.command||e.text||e.sections.length||c),u=e.resources.length>0,[d,f]=G(!1),p=a?void 0:e.status,m=r(d?`agent.hideDetails`:`agent.showDetails`),h=u?e.resources.map(e=>e.label).join(`, `):e.title,g=t(`span`,{className:z(`flex size-5 items-center justify-center pt-0.5`,s?`text-attention`:`text-muted`),children:t(cJ,{kind:e.kind,status:p})}),_=t(rh,{className:z(`size-4 shrink-0 text-muted opacity-50 transition-transform`,!d&&`-rotate-90`),"aria-hidden":`true`});return n(`div`,{className:`min-w-0`,children:[u?n(`div`,{className:`grid w-full grid-cols-[1.5rem_1fr_auto] items-center gap-2 text-start`,children:[g,t(wG,{resources:e.resources,workflowRunId:e.workflowRunId}),l?t(We,{description:m,asChild:!0,children:t(o,{variant:`ghost`,size:`xs`,className:`size-6 p-0 text-muted`,onClick:()=>f(e=>!e),"aria-expanded":d,"aria-label":`${m}: ${h}`,children:_})}):null]}):n(`button`,{type:`button`,className:z(`grid w-full grid-cols-[1.5rem_1fr_auto] gap-2 text-start outline-none transition-colors`,`focus-visible:text-foreground focus-visible:underline focus-visible:underline-offset-4`,l?`cursor-pointer hover:text-foreground`:`cursor-default`),onClick:()=>l&&f(e=>!e),"aria-expanded":l?d:void 0,disabled:!l,children:[g,n(`span`,{className:`min-w-0 text-sm text-muted`,children:[t(`span`,{className:`break-words`,children:e.title}),e.decisionText?t(i,{variant:`destructive`,className:`ms-2 rounded-full shadow-sm shadow-destructive/10`,children:e.decisionText}):null]}),l?_:null]}),l&&d?t(`div`,{className:`mt-1`,children:t(gJ,{item:e})}):null]})}function vJ({item:e,artifactRunId:r,disableCollapse:i}){let{t:a}=K(),o=e.text??e.title,s=o.trim(),[c,l]=G(!1),u=s?s.split(/\r?\n/).length:0,d=s.length>520||u>6,f=a(c?`agent.showLess`:`agent.showMore`);return n(`div`,{className:`min-w-0 py-1`,children:[t(`div`,{"data-testid":`summary-thought-prose`,className:z(uW,d&&!i&&!c&&`[display:-webkit-box] overflow-hidden [-webkit-box-orient:vertical] [-webkit-line-clamp:6]`),style:{overflowWrap:`anywhere`},children:t(Nt,{artifactRunId:r,components:XK,children:o})}),d&&!i?t(`div`,{className:`mt-1.5 flex justify-end`,children:n(`button`,{type:`button`,"aria-expanded":c,className:z(`inline-flex items-center gap-1 text-sm font-medium text-muted transition-colors`,`[text-decoration:none] hover:text-foreground hover:[text-decoration:none]`,`focus-visible:text-foreground focus-visible:[text-decoration:none]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`),onClick:()=>l(e=>!e),children:[f,t(rh,{className:z(`size-4 transition-transform`,c&&`rotate-180`),"aria-hidden":`true`})]})}):null]})}function yJ({items:e,artifactRunId:n,disablePreambleCollapse:r}){return t(`div`,{className:`mt-3`,children:t(`div`,{className:`space-y-3`,children:e.map(e=>e.isPreamble||e.kind===`think`?t(vJ,{item:e,artifactRunId:n,disableCollapse:r},e.key):t(_J,{item:e},e.key))})})}function bJ({text:e,artifactRunId:n,workstreamId:r}){return t(`div`,{className:`mx-auto w-full max-w-3xl px-1`,"data-workstream-id":r,children:t(`div`,{className:uW,style:{overflowWrap:`anywhere`},children:t(Nt,{artifactRunId:n,components:XK,children:e})})})}function xJ({message:e,startTimestamp:r,endTimestamp:i,className:a}){let{t:o}=K(),s=FK(PK(r??e.timestamp,i??e.timestamp));return n(`div`,{className:z(`mx-auto w-full max-w-3xl px-1`,a),"data-testid":`summary-stopped-message`,children:[n(`div`,{className:`flex items-center justify-end gap-2 text-sm font-medium text-muted`,children:[t(`span`,{children:o(`agent.youStoppedAfter`,{duration:s})}),t(eG,{message:e,className:`h-4 w-4`})]}),t(`div`,{className:`mt-5 border-b border-border/70`})]})}function SJ({label:r,timestamp:i,durationSeconds:a,showElapsed:o,details:s,emptyDetailsLabel:c,defaultExpanded:l=!1,disablePreambleCollapse:u=!1,className:d,artifactRunId:f,onSendMessage:p,answeredToolApprovalRequestInputKeys:m,resolvedToolApprovalKeys:h}){let[g,_]=G(l),v=sq(i,o&&a===void 0),y=a??v,b=o&&i!==void 0,x=U(()=>sJ(s??[]),[s]),S=U(()=>(s??[]).filter(e=>EU(e)&&!ZU(e,m??new Set,h??new Set)),[m,s,h]),C=x.length>0||S.length>0||!!c;return t(`div`,{className:z(`mx-auto w-full max-w-3xl px-1`,d),children:n(`div`,{className:`border-b border-border/70 pb-3 text-sm text-muted`,children:[n(`button`,{type:`button`,className:z(`inline-flex max-w-full items-center gap-2 text-start outline-none`,`focus-visible:text-foreground focus-visible:underline focus-visible:underline-offset-4`,C?`cursor-pointer hover:text-foreground`:`cursor-default`),onClick:()=>C&&_(e=>!e),"aria-expanded":C?g:void 0,disabled:!C,children:[t(`span`,{className:`min-w-0 truncate font-medium`,children:r}),b?n(`span`,{className:`shrink-0 text-muted/75`,children:[`for `,FK(y)]}):null,C?t(g?rh:lh,{className:`size-4 shrink-0 opacity-50`}):null]}),C&&g?x.length>0||S.length>0?n(e,{children:[x.length>0?t(yJ,{items:x,artifactRunId:f,disablePreambleCollapse:u}):null,S.length>0?t(`div`,{className:`mt-3 space-y-3`,children:S.map(e=>{let n=e.details.ux,r=DH(n.options)&&n.options.length>0;return t(jH,{question:xU(e),options:r?n.options:void 0,variant:n.variant,multiSelect:n.multiSelect,onSelect:t=>RU(p,e,t,GU(e,t)),onMultiSelect:t=>RU(p,e,t.join(`, `)),allowFreeResponse:!r||!!n.free_response,placeholder:n.free_response?.placeholder,submitLabel:n.free_response?.submit_label,onSubmit:t=>RU(p,e,t,n.free_response?.metadata),hideBorder:!0,compact:!0,className:`my-0`,cardClassName:`bg-background/60 shadow-none`},Kq(e,`work-request-input`))})}):null]}):n(`div`,{className:`mt-3 flex items-center gap-2 text-sm text-muted`,children:[t(fb,{className:`size-4 opacity-70`,"aria-hidden":`true`}),t(`span`,{children:c})]}):null]})})}function CJ({children:e,status:r}){let i=r===`error`?`bg-destructive`:r===`warning`?`bg-attention`:r===`completed`?`bg-success`:`bg-muted`;return n(`div`,{className:`relative ps-7`,children:[t(`div`,{className:`absolute start-2 top-0 bottom-0 w-px bg-border`}),t(`div`,{className:z(`absolute start-[5px] top-4 size-2.5 rounded-full ring-4 ring-background`,i)}),e]})}var wJ=class extends ct{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return console.error(`Message render error:`,e),{hasError:!0,error:e}}componentDidUpdate(e){this.state.hasError&&e.children!==this.props.children&&this.setState({hasError:!1,error:void 0})}render(){return this.state.hasError?n(`div`,{className:`border-s-4 border-s-destructive bg-destructive/10 px-4 py-2 my-2 rounded-e`,children:[t(`p`,{className:`text-sm text-destructive font-medium`,children:Xt.getFixedT(null,Yt)(`agent.failedToRenderMessage`)}),t(`p`,{className:`text-xs text-muted mt-1 truncate`,children:this.state.error?.message||`Unknown error`})]}):this.props.children}};function TJ(e,t){let n=[...e.filter(e=>!Tq(e)&&!t?.includes(e.type))].sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())),r=[];for(let e of n){let t=r[r.length-1];t&&lU(t,e)||t&&DJ(t,e)||r.push(e)}return r}function EJ({messages:r,workstreamSourceMessages:i,bottomRef:a,viewMode:s=`stacked`,isCompleted:c=!1,streamingMessages:l=new Map,onSendMessage:u,onOpenArtifact:d,messageItemClassNames:f,messageStyleOverrides:p,toolCallGroupClassNames:m,hideToolCallsInViewMode:h,streamingMessageClassNames:g,batchProgressPanelClassNames:_,artifactRunId:v,hideWorkstreamTabs:y,workingIndicatorClassName:b,messageListClassName:x,StoreLinkComponent:S,CollectionLinkComponent:C,prependFriendlyMessage:w,initialRequestData:T,initialRequestSchema:E,initialRequestTitle:D,initialRequestTemplate:O,showInitialRequest:k,hiddenMessageTypes:A,disableAutoScroll:j=!1,renderRequestInputControls:M=!0,activeWorkstream:N,onActiveWorkstreamChange:P}){v||console.warn(`[AllMessagesMixed] artifactRunId prop is missing!`);let{t:F}=K(),I=W(null),[L,ee]=G(`all`),R=N??L,te=V(e=>{N===void 0&&ee(e),P?.(e)},[N,P]),ne=W(0),re=W(null),ie=W(!1),ae=W(!1),oe=l.size>0,se=s===`sliding`;H(()=>{let e=I.current;if(!e)return;let t=()=>{if(ae.current)return;let{scrollTop:t,scrollHeight:n,clientHeight:r}=e,i=n-t-r;ie.current=i>80};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[]);let ce=U(()=>{let e=0;return l.forEach(t=>{e+=t.text?.length||0}),Math.floor(e/200)},[l]),le=V(()=>{a.current&&(ae.current=!0,a.current.scrollIntoView({behavior:oe?`instant`:`smooth`}),ne.current=Date.now(),requestAnimationFrame(()=>{ae.current=!1})),re.current=null},[a,oe]);H(()=>{if(r.length,l.size,j||ie.current)return;let e=Date.now()-ne.current;if(e>=100)le();else if(re.current===null){let t=100-e;re.current=window.setTimeout(le,t)}return()=>{re.current!==null&&(clearTimeout(re.current),re.current=null)}},[r.length,l.size,ce,le,j]);let ue=ot.useMemo(()=>TJ(r,A),[r,A]),de=ot.useMemo(()=>i?TJ(i,A):ue,[i,A,ue]),fe=ot.useMemo(()=>{let e=kK(de);return de.forEach(t=>{let n=UH(t)??WH(t);n&&e.set(n.workstreamId,FH(n.workstreamId,n.interaction))}),e},[de]),pe=ot.useMemo(()=>{if(R!==`all`)return fe.get(R)??NH(R)},[R,fe]),me=V(()=>{let e=I.current;e&&(ae.current=!0,typeof e.scrollTo==`function`?e.scrollTo({top:0,behavior:`smooth`}):e.scrollTop=0,requestAnimationFrame(()=>{ae.current=!1}))},[]),he=W(R);H(()=>{he.current!==R&&(he.current=R,requestAnimationFrame(me))},[R,me]);let ge=V(e=>{te(e)},[te]),_e=V(()=>{te(`all`)},[te]);H(()=>{R!==`all`&&!fe.has(R)&&te(`all`)},[R,fe,te]);let ve=ot.useMemo(()=>{let e=new Map;e.set(`all`,de.length);let t=AK(de,`main`);return e.set(`main`,t.length),de.forEach(t=>{let n=eU(t);n!==`main`&&e.set(n,(e.get(n)||0)+1)}),e},[de]),ye=ot.useMemo(()=>KK(rU(ue,R)),[ue,R]),be=ot.useMemo(()=>IU(ye),[ye]),xe=ot.useMemo(()=>VU(ye),[ye]),Se=ot.useMemo(()=>XU(ye),[ye]),Ce=ot.useMemo(()=>QU(ye),[ye]),we=ot.useMemo(()=>{if(M)return;let e=tW(ye);return e?DU(e):void 0},[ye,M]),Te=ot.useCallback(e=>e.type===J.REQUEST_INPUT&&(we===DU(e)||ZU(e,Se,xe)),[Se,we,xe]),Ee=ot.useCallback(e=>$U(e,Ce),[Ce]),De=ot.useMemo(()=>ye.filter(e=>!Ee(e)),[ye,Ee]),Oe=W(Date.now()),ke=(!!w?.trim()||fq(T)||O!==void 0)&&(k??!0),Ae=U(()=>ye.some(e=>e.type===J.QUESTION),[ye]),je=R===`all`&&ke&&!Ae,Me=U(()=>ye.reduce((e,t)=>Math.max(e,MK(t.timestamp)),-1/0),[ye]),Ne=U(()=>ye.reduce((e,t)=>FG(t)?e:Math.max(e,MK(t.timestamp)),-1/0),[ye]),Pe=U(()=>ye.some(e=>UU(e)&&!ZU(e,Se,xe)),[Se,ye,xe]),Fe=U(()=>UK(ye,Ce),[ye,Ce]),Ie=U(()=>Pe||Fe||HK(De)?!1:c||!ZH(De),[De,Fe,Pe,c]),Le=U(()=>{if(de.length===0)return de;let e=r[r.length-1];if(!e)return[];let t=de.indexOf(e);if(t>=0)return t>=de.length-1?de:de.slice(0,t+1);let n=MK(e.timestamp);return de.filter(e=>MK(e.timestamp)<=n)},[de,r]),Re=U(()=>c||kG(Le),[c,Le]),ze=U(()=>OG(Le),[Le]),{completeStreaming:Be,incompleteStreaming:Ve}=ot.useMemo(()=>{let e=new Map,t=[];return l.forEach((n,r)=>{aU(n,R)&&(n.startTimestamp<=Ne?e.set(r,n):n.text&&t.push({id:r,data:n}))}),{completeStreaming:e,incompleteStreaming:t}},[l,R,Ne]),He=ot.useMemo(()=>Hq(QG(ye,Be),xe),[ye,Be,xe]),Ue=ot.useMemo(()=>He.filter(e=>!Te(e)&&!Ee(e)),[He,Te,Ee]),We=U(()=>{if(Ve.some(({data:e})=>e.text.trim().length>0))return 1/0;let e=Ve.reduce((e,{data:t})=>Math.max(e,t.startTimestamp),-1/0);return Math.max(Me,e)},[Ve,Me]),Ge=ot.useMemo(()=>XG(Ue,Ie,We),[Ue,Ie,We]),Ke=ot.useMemo(()=>AG(Ge,e=>e.type===`message`&&e.message.type===J.QUESTION,ze,Re),[Ge,ze,Re]),qe=ot.useMemo(()=>yU(_U(ye,Be,R)),[ye,Be,R]),Je=ot.useMemo(()=>AG(qe,e=>e.type===`single`&&e.message.type===J.QUESTION,ze,Re),[qe,ze,Re]),Ye=U(()=>!Ie||HK(De),[De,Ie]),Xe=U(()=>{if(!Ye||Ve.length>0)return!1;let e=Ge[Ge.length-1],t=De[De.length-1],n=t!==void 0&&(t.details?.display_role===`thinking`||fU(t)&&t.details?.tool_status===`completed`);return e?.type===`work`&&e.isActive&&n},[De,Ve.length,Ye,Ge]),Ze=eK(Ge,Ye,Ve.length>0),Qe=tK(Ge)?F(`agent.preparing`):F(`agent.working`),$e=ye.length===0&&ke&&Ye&&Ve.length===0,et=U(()=>$G(Ge,Ue,Oe.current),[Ge,Ue]),tt=W(et),nt=W(!1),rt=U(()=>{if(!Ze)return et;let e=MK(et),t=MK(tt.current);return!nt.current||e<t?et:tt.current},[et,Ze]);H(()=>{tt.current=rt,nt.current=Ze},[rt,Ze]);let it=U(()=>{let e=new Map,t=new Map;de.forEach(e=>{let n=eU(e);t.has(n)||t.set(n,[]),t.get(n)?.push(e)});for(let[n,r]of t.entries())if(r.length>0){let t=r.some(e=>{if([J.COMPLETE,J.IDLE,J.REQUEST_INPUT,J.TERMINATED].includes(e.type))return!0;if(e.type===J.UPDATE&&e.details){let t=e.details;return t.workstream_event===`completed`||t.status===`completed`||t.status===`canceled`}return!1});e.set(n,t)}return e},[de]);return n(`div`,{ref:I,tabIndex:0,className:`flex-1 min-h-0 h-full w-full max-w-full overflow-y-auto overflow-x-hidden px-1.5 sm:px-2.5 lg:px-3 flex flex-col relative focus:outline-none`,"data-testid":`all-messages-mixed`,"data-message-count":r.length,"data-streaming-count":l.size,"data-view-mode":s,children:[t(`style`,{children:`
1001
1001
  /* Better vertical rhythm for markdown */
1002
1002
  .vprose > * + * {
1003
1003
  margin-top: 0.625rem;
@@ -1249,7 +1249,7 @@ $&`)),t.includes(` - `)&&(t=t.replace(/(^|\S)\s+-\s+/g,`$1
1249
1249
  .agent-markdown tbody tr:hover {
1250
1250
  background: transparent;
1251
1251
  }
1252
- `}),s===`stacked`&&t(`div`,{className:z(`sticky top-0 z-10`,y&&`hidden`),children:t(DK,{workstreams:fe,activeWorkstream:R,onSelectWorkstream:ge,count:ve,completionStatus:it})}),ye.length===0&&Ve.length===0&&!ke&&!(se&&Ze)?R===`all`&&Ye?t(`div`,{className:`flex-1 px-2 py-6 sm:px-4`,children:t(yq,{label:F(`agent.preparing`),timestamp:Oe.current,className:b})}):t(`div`,{className:`flex items-center justify-center h-full text-center py-8`,children:t(`div`,{className:`flex items-center px-3 py-2 text-sm text-muted`,children:F(R===`all`?`agent.waitingForAgentResponse`:`agent.noMessagesInWorkstream`)})}):n(`div`,{className:z(`flex-1 flex flex-col justify-start w-full max-w-full`,se?`gap-6 px-2 py-6 sm:px-4`:`gap-3 pb-4`,x),children:[se&&R!==`all`&&pe&&t(`div`,{className:`sticky top-0 z-20 -mx-2 bg-background/95 px-2 pb-2 pt-1 backdrop-blur sm:-mx-4 sm:px-4`,children:n(`div`,{className:`mx-auto flex w-full max-w-3xl items-center gap-2 border-b border-border/70 pb-3`,children:[t(o,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8 shrink-0 text-muted hover:text-foreground`,title:F(`agent.backToMainAgent`),onClick:_e,children:t(wm,{className:`size-4`,"aria-hidden":`true`})}),t(`div`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-foreground`,children:pe})]})}),je&&t(vq,{data:T,schema:E,title:D,template:O,prependFriendlyMessage:w,timestamp:ye[0]?.timestamp??Date.now(),isSummaryView:se,messageItemClassNames:f,messageStyleOverrides:p,StoreLinkComponent:S,CollectionLinkComponent:C},`initial-request`),$e&&t(yq,{label:Qe,timestamp:rt,className:b}),s===`stacked`?n(e,{children:[Je.map((e,n)=>{let r=n===Je.length-1;if(e.type===`resource_summary`)return t(TG,{resources:e.resources,workflowRunId:v,className:`my-2`},e.key);if(e.type===`tool_group`){let n=e.messages[e.messages.length-1],i=e.toolStatus===`completed`||e.toolStatus===`error`||e.toolStatus===`warning`,a=!c&&r&&!JH.includes(n.type)&&!i;return h?.includes(s)?null:t(SJ,{status:e.toolStatus,children:t(CJ,{children:t(bK,{...m,messages:e.messages,showPulsatingCircle:a,toolRunId:e.toolRunId,toolStatus:e.toolStatus,preambleText:e.preambleText,preambleMessage:e.preambleMessage,rootClassName:z(`rounded-lg border border-border bg-background/60 shadow-none`,m?.rootClassName),headerClassName:z(`px-3 py-2`,m?.headerClassName),itemHeaderClassName:z(`hover:bg-mixer-muted/20`,m?.itemHeaderClassName)})})},Kq(e))}if(e.type===`streaming`)return t(SJ,{children:t(jG,{...g,text:e.text,workstreamId:e.workstreamId,isComplete:e.isComplete,timestamp:e.startTimestamp,artifactRunId:v,cardClassName:z(`rounded-lg border border-border bg-background/60 shadow-none`,g?.cardClassName)})},Kq(e));{let i=e.message;if(Te(i)||Ee(i))return null;if(ZH(i))return t(SJ,{children:t(bJ,{message:i,startTimestamp:qq(Je,n)??i.timestamp,endTimestamp:i.timestamp})},Gq(i,`stopped`));let a=!c&&r&&!JH.includes(i.type);return AK(i)?t(CJ,{children:t(JW,{message:i,batchData:i.details,isRunning:!i.details.completed_at,..._})},`batch-${i.details.batch_id}-${i.timestamp}`):t(SJ,{status:`message`,children:t(CJ,{children:t(vG,{...f,message:i,showPulsatingCircle:a,onSendMessage:u,onOpenArtifact:d,requestInputAnswered:$U(i,be),cardClassName:z(`rounded-lg border border-border bg-background/60 shadow-none`,f?.cardClassName),headerClassName:z(`px-3 py-2`,f?.headerClassName),contentClassName:z(`bg-transparent`,f?.contentClassName),messageStyleOverrides:p,StoreLinkComponent:S,CollectionLinkComponent:C})})},Gq(i))}}),Ve.map(({id:e,data:n})=>t(SJ,{children:t(jG,{...g,text:n.text,workstreamId:n.workstreamId,isComplete:n.isComplete,timestamp:n.startTimestamp,artifactRunId:v,cardClassName:z(`rounded-lg border border-border bg-background/60 shadow-none`,g?.cardClassName)})},`streaming-incomplete-${e}`)),Ye&&Ve.length===0&&!$e&&t(SJ,{children:n(`div`,{className:z(`flex items-center gap-2 py-2 text-sm text-muted`,b),children:[t(iW,{size:`sm`,color:`blue`}),t(`span`,{children:F(`agent.working`)})]})})]}):n(e,{children:[Ke.map(e=>{if(e.type===`resource_summary`)return t(TG,{resources:e.resources,workflowRunId:v,className:`my-2`},e.key);if(e.type===`work`){if(h?.includes(s))return null;let n=zK(e.messages);return t(xJ,{label:BK(e.isActive),status:e.status,timestamp:e.startTimestamp,durationSeconds:e.isActive?void 0:NK(e.startTimestamp,e.endTimestamp),showElapsed:!0,details:n?void 0:e.messages,defaultExpanded:e.isActive&&!n,disablePreambleCollapse:e.isActive,className:b,onSendMessage:u,answeredToolApprovalRequestInputKeys:Se,resolvedToolApprovalKeys:xe},`work-${e.id}-${e.isActive?`active`:`done`}-${e.status}`)}if(e.type===`stopped`)return t(bJ,{message:e.message,startTimestamp:e.startTimestamp,endTimestamp:e.endTimestamp},Gq(e.message,`stopped-summary`));let n=e.message;return Te(n)||Ee(n)?null:AK(n)?t(CJ,{children:t(JW,{message:n,batchData:n.details,isRunning:!n.details.completed_at,..._})},Gq(n,`batch`)):t(CJ,{children:t(lq,{message:n,onSendMessage:u,onOpenArtifact:d,onSelectWorkstream:ge,requestInputAnswered:$U(n,be),StoreLinkComponent:S,CollectionLinkComponent:C})},Gq(n,`summary`))}),Ve.map(({id:e,data:n})=>t(yJ,{text:n.text,workstreamId:n.workstreamId,artifactRunId:v},`streaming-incomplete-${e}`)),Xe&&t(`div`,{className:z(`mx-auto w-full max-w-3xl px-1 text-sm text-muted`,b),"data-testid":`post-tool-thinking-indicator`,children:F(`agent.thinking`)}),Ze&&!$e&&t(xJ,{label:Qe,status:`running`,timestamp:rt,showElapsed:!0,className:b})]}),t(`div`,{ref:a,className:`h-2`})]})]})}const EJ=(e,t)=>{if(e.type!==t.type||e.message!==t.message)return!1;let n=e.details,r=t.details;if(n?.tool_status!==`completed`||r?.tool_status!==`completed`)return!1;let i=typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime();return(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())-i<2e3},DJ=ot.memo(TJ);Q();function OJ(e){return e?new Map(e.streamingMessages.map((e,t)=>[e.id??e.activityId??`stream-${t}`,e])):new Map}function kJ(e,t){return e?.find(e=>e.cursor===t)}function AJ(e,t){if(t===0||e===`live`)return`live`;let n=fC(e,t);return n>=t-1?`live`:n+1}function jJ(e){let t=0,n=e.length;for(;t<n&&e[t]===`-`;)t++;for(;n>t&&e[n-1]===`-`;)n--;return e.slice(t,n)}function MJ(e){return jJ(e.trim().replace(/[^a-z0-9-_]+/gi,`-`)).slice(0,80)}function NJ(e,t){let n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}function PJ({fixture:e,cursor:r,initialCursor:i,onCursorChange:a,autoStepMs:s,repeat:c=1,viewMode:l,className:u,title:d,showHeader:f=!0}){let{t:p}=K(),m=e.messages,h=i??(m.length>0?0:`live`),[g,_]=G(()=>dC(h,m.length)),v=r??g,y=l??`sliding`,[b,x]=G(!!s),[S,C]=G(0),w=W(null),T=U(()=>hC(m,v,!0),[v,m]),E=T.displayedMessages,D=U(()=>OJ(kJ(e.streamingFrames,T.cursor)),[e.streamingFrames,T.cursor]),O=V(e=>{let t=dC(e,m.length);r===void 0&&_(t),a?.(t)},[r,m.length,a]);H(()=>{let e=dC(v,m.length);e!==v&&O(e)},[v,m.length,O]),H(()=>{if(!s||s<=0||!b)return;let e=window.setInterval(()=>{let e=AJ(v,m.length);if(e===`live`&&v===`live`){C(e=>{let t=e+1;return c>0&&t>=c?(x(!1),t):(O(m.length>0?0:`live`),t)});return}O(e)},s);return()=>window.clearInterval(e)},[s,v,b,m.length,c,O]);let k=E.length>0&&!XH(E),A=U(()=>eW(E),[E]),j=d??e.metadata?.title??p(`agent.rewind.fixtureTitle`),M=V(()=>{let t={...e,metadata:{...e.metadata,title:j,exported_at:e.metadata?.exported_at??new Date().toISOString(),message_count:m.length}},n=e.metadata?.agent_run_id??`fixture`;NJ(`${MJ(j)||`agent-chat`}-${MJ(n)}.json`,t)},[e,m.length,j]),N=V(()=>{O(AJ(T.cursor,m.length))},[m.length,T.cursor,O]);return n(`div`,{className:z(`flex h-full min-h-0 w-full flex-col bg-background text-foreground`,u),"data-agent-test-playback-enabled":!0,"data-agent-playback-cursor":T.cursor,"data-agent-live-message-count":m.length,"data-agent-rendered-message-count":T.renderedMessageCount,"data-agent-replay-playing":b||void 0,"data-agent-replay-loop":S,children:[f&&n(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-b border-border px-3 py-2`,children:[n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`truncate text-sm font-medium`,children:j}),t(`div`,{className:`text-xs text-muted`,children:p(`agent.rewind.fixtureMeta`,{messageCount:m.length,loops:S})})]}),n(`div`,{className:`flex items-center gap-2`,children:[n(o,{type:`button`,variant:`secondary`,size:`sm`,onClick:M,children:[t(og,{className:`size-4`}),t(`span`,{className:`ms-1.5`,children:p(`agent.rewind.exportFixture`)})]}),s&&s>0&&n(o,{type:`button`,variant:`secondary`,size:`sm`,onClick:()=>x(e=>!e),children:[t(b?Gv:ry,{className:`size-4`}),t(`span`,{className:`ms-1.5`,children:p(b?`agent.rewind.pause`:`agent.rewind.resume`)})]})]})]}),t(`div`,{className:`flex flex-shrink-0 justify-end px-2 py-1.5`,children:t(xC,{cursor:T.cursor,messages:m,onChangeCursor:O})}),t(DJ,{messages:E,isCompleted:k,streamingMessages:D,bottomRef:w,artifactRunId:e.metadata?.agent_run_id??`agent-chat-fixture`,viewMode:y,renderRequestInputControls:!A}),A&&t(nW,{message:A,onSendMessage:N,isLoading:!1})]})}function FJ({className:e,inline:r=!1}){return n(`div`,{className:z(`flex items-center gap-1`,r?`inline-flex`:``,e),children:[t(`div`,{className:`w-2 h-2 bg-primary rounded-full animate-[jumping_1s_infinite_ease-in-out] hover:bg-primary`,style:{transform:`translateY(0)`,animationRange:`0px -8px`}}),t(`div`,{className:`w-2 h-2 bg-primary rounded-full animate-[jumping_1s_0.3s_infinite_ease-in-out] hover:bg-primary`,style:{transform:`translateY(0)`,animationRange:`0px -8px`}}),t(`div`,{className:`w-2 h-2 bg-primary rounded-full animate-[jumping_1s_0.6s_infinite_ease-in-out] hover:bg-primary`,style:{transform:`translateY(0)`,animationRange:`0px -8px`}})]})}function IJ(){let{client:e}=q(),[t,n]=G([]),[r,i]=G(!0),[a,o]=G(!1),s=W(0),c=V(async()=>{let t=s.current+1;s.current=t,i(!0),o(!1);try{let r=await e.apps.getInstalledApps(`tools`),a=[];for(let e of r){let t=e,n=t.oauth_collection_ids??[],r=t.manifest.oauth_providers??{};if(!t.manifest.tool_collections)continue;let i=t.manifest.tool_collections.map(e=>An(e)).filter(e=>e.type===`mcp`),o=i.filter(e=>e.auth!==`api_key`&&n.includes(e.id)),s=i.filter(e=>e.auth===`api_key`),c=new Map,l=new Map,u=[];for(let e of o)if(e.oauth_provider){let t=c.get(e.oauth_provider)??[];t.push(e),c.set(e.oauth_provider,t)}else if(e.oauth_app){let t=l.get(e.oauth_app)??[];t.push(e),l.set(e.oauth_app,t)}else u.push(e);for(let[e,n]of c){let i=n[0].id;for(let o of n)a.push({key:`${t.id}:provider:${e}:${o.id}`,appId:t.id,appName:t.manifest.title||t.manifest.name,label:o.name,representativeId:i,memberIds:[o.id],memberNames:[o.name],authType:`oauth`,oauthGrantType:r[e]?.grant_type})}for(let[e,n]of l){let r=n[0].id;for(let i of n)a.push({key:`${t.id}:oauthapp:${e}:${i.id}`,appId:t.id,appName:t.manifest.title||t.manifest.name,label:i.name,representativeId:r,memberIds:[i.id],memberNames:[i.name],authType:`oauth`})}for(let e of u)a.push({key:`${t.id}:individual:${e.id}`,appId:t.id,appName:t.manifest.title||t.manifest.name,label:e.name,representativeId:e.id,memberIds:[e.id],memberNames:[e.name],authType:`oauth`});for(let e of s)a.push({key:`${t.id}:api-key:${e.id}`,appId:t.id,appName:t.manifest.title||t.manifest.name,label:e.name,representativeId:e.id,memberIds:[e.id],memberNames:[e.name],authType:`api_key`})}if(s.current!==t||(n(a),i(!1),a.length===0))return;o(!0);let c=new Map,l=await Promise.all(a.map(async t=>{try{let n=c.get(t.appId);n||(n=e.remoteMcpConnections.getStatus(t.appId),c.set(t.appId,n));let r=(await n).find(e=>e.collection_id===t.representativeId);return{...t,authStatus:r}}catch{return t}}));if(s.current!==t)return;n(l)}catch(e){s.current===t&&(console.error(`Failed to load MCP tool collections:`,e),n([]))}finally{s.current===t&&(i(!1),o(!1))}},[e]);return H(()=>{c()},[c]),{groups:t,loading:r,statusLoading:a,reload:c}}function LJ(e,t){return t?.length?e.memberIds.every(e=>t.includes(e)):!1}function RJ(e,t,n){let r=new Set(t??[]);if(n)for(let t of e.memberIds)r.delete(t);else for(let t of e.memberIds)r.add(t);return Array.from(r)}function zJ(e,t){return e.filter(e=>e.authStatus?.authenticated===!0&&!LJ(e,t)).length}function BJ(e,t){return e.filter(e=>e.authStatus?.authenticated===!0&&!LJ(e,t)).map(e=>e.label)}Q();function VJ({isOpen:e,onClose:r,groups:i,loading:a,statusLoading:o=!1,reload:s,disabledCollections:c,onChange:l,onConnectionChange:u,readOnly:d=!1}){let{t:f}=K(),p=()=>{s(),u?.()};return n(mT,{isOpen:e,onClose:r,size:`md`,className:`max-w-[92vw] sm:max-w-[620px] lg:max-w-[620px]`,children:[t(hT,{children:f(`mcpConnections.title`)}),n(gT,{children:[t(`p`,{className:`mb-4 text-sm text-muted`,children:f(`mcpConnections.subtitle`)}),a?t(`div`,{className:`flex items-center justify-center py-8`,children:t(dO,{className:`size-5`})}):i.length===0?t(`div`,{className:`py-8 text-center text-sm text-muted`,children:f(`mcpConnections.empty`)}):t(`div`,{className:`space-y-1`,children:i.map(e=>{let r=!LJ(e,c),i=e.authStatus?.authenticated===!0,a=e.authType===`oauth`&&e.oauthGrantType!==`client_credentials`;return n(`div`,{className:`flex items-center justify-between gap-3 py-3`,children:[n(`div`,{className:`flex min-w-0 items-center gap-2`,children:[t(i?G_:H_,{className:`size-4 shrink-0 ${i?`text-success`:`text-muted`}`,"aria-hidden":`true`}),t(tT,{description:n(`div`,{className:`space-y-0.5`,children:[t(`div`,{className:`font-medium`,children:e.appName}),e.memberNames.length>1&&t(`div`,{className:`text-xs text-muted`,children:e.memberNames.join(` · `)})]}),placement:`top`,asChild:!0,children:t(`span`,{className:`truncate ${r?`text-foreground`:`text-muted line-through`}`,children:e.label})})]}),n(`div`,{className:`flex shrink-0 items-center gap-3`,children:[a&&o&&!e.authStatus?t(oT,{variant:`outline`,size:`sm`,disabled:!0,className:`h-6 w-32 justify-center px-2 text-xs`,title:f(`mcpConnections.checkingStatus`),children:t(dO,{className:`size-3`})}):a?t(mO,{appId:e.appId,collectionId:e.representativeId,collectionName:e.label,authenticated:e.authStatus?.authenticated,onAuthChange:p,variant:`compact`,showDisconnect:!0,readOnly:d}):e.authType===`oauth`?t(uT,{variant:`outline`,className:`h-6 w-32 justify-center px-2 text-xs`,children:f(`mcpConnections.managedByApp`)}):null,l&&t(lO,{size:`sm`,value:r,onChange:t=>l(RJ(e,c,t)),disabled:d,"aria-label":f(r?`mcpConnections.deactivateAria`:`mcpConnections.activateAria`,{name:e.label})})]})]},e.key)})})]})]})}Q();function HJ({disabledCollections:r,onChange:i,onConnectionChange:a,readOnly:o=!1,variant:s=`outline`,size:c=`sm`}){let{t:l}=K(),{groups:u,loading:d,statusLoading:f,reload:p}=IJ(),[m,h]=G(!1);if(!d&&u.length===0)return null;let g=zJ(u,r),_=BJ(u,r),v=_.slice(0,2),y=_.length-v.length,b=v.length>0?`${v.join(`, `)}${y>0?` +${y}`:``}`:void 0;return n(e,{children:[n(`div`,{className:`flex min-w-0 items-center gap-2`,children:[b&&t(`span`,{className:`max-w-48 truncate text-muted`,title:_.join(`, `),children:b}),n(oT,{variant:s,size:c,className:`shrink-0`,onClick:()=>h(!0),disabled:d,"aria-label":l(`mcpConnections.manage`),children:[t(`span`,{children:l(`mcpConnections.label`)}),g>0&&t(uT,{variant:`success`,children:g})]})]}),t(VJ,{isOpen:m,onClose:()=>h(!1),groups:u,loading:d,reload:p,statusLoading:f,disabledCollections:r,onChange:i,onConnectionChange:a,readOnly:o})]})}function UJ({disabledCollections:e,onChange:r,onConnectionChange:i,readOnly:a=!1}){let{t:o}=K(),{groups:s,loading:c,statusLoading:l,reload:u}=IJ();if(!c&&s.length===0)return null;let d=()=>{u(),i?.()};return c&&s.length===0?n(`div`,{className:`flex items-center gap-2 border-y border-border/70 py-2 text-sm text-muted`,children:[t(dO,{className:`size-4`}),t(`span`,{children:o(`mcpConnections.label`)})]}):t(`div`,{className:`space-y-1`,children:s.map(i=>{let s=!LJ(i,e),c=i.authStatus?.authenticated===!0,u=i.authType===`oauth`&&i.oauthGrantType!==`client_credentials`;return n(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 py-2 text-sm`,children:[n(`div`,{className:`flex min-w-36 flex-1 items-center gap-2`,children:[t(c?G_:H_,{className:`size-4 shrink-0 ${c?`text-success`:`text-muted`}`,"aria-hidden":`true`}),t(tT,{description:n(`div`,{className:`space-y-0.5`,children:[t(`div`,{className:`font-medium`,children:i.appName}),i.memberNames.length>1&&t(`div`,{className:`text-xs text-muted`,children:i.memberNames.join(` · `)})]}),placement:`top`,asChild:!0,children:t(`span`,{className:`block truncate ${s?`text-foreground`:`text-muted line-through`}`,children:i.label})})]}),u&&l&&!i.authStatus?t(oT,{variant:`outline`,size:`sm`,disabled:!0,className:`h-6 w-32 justify-center px-2 text-xs`,title:o(`mcpConnections.checkingStatus`),children:t(dO,{className:`size-3`})}):u?t(mO,{appId:i.appId,collectionId:i.representativeId,collectionName:i.label,authenticated:i.authStatus?.authenticated,onAuthChange:d,variant:`compact`,showDisconnect:!0,readOnly:a}):t(uT,{variant:`outline`,className:`h-6 w-32 justify-center px-2 text-xs`,children:i.authType===`api_key`?o(`mcpConnections.apiKey`):o(`mcpConnections.managedByApp`)}),r&&n(`div`,{className:`flex min-w-24 items-center justify-end gap-2 text-xs`,children:[t(`span`,{className:s?`text-muted`:`text-attention`,children:o(s?`mcpConnections.enabled`:`mcpConnections.disabled`)}),t(lO,{size:`sm`,value:s,onChange:t=>r(RJ(i,e,t)),disabled:a,"aria-label":o(s?`mcpConnections.deactivateAria`:`mcpConnections.activateAria`,{name:i.label})})]})]},i.key)})})}function WJ({disabledCollections:r,onChange:i,onConnectionChange:a,readOnly:o=!1}){let{t:s}=K(),{groups:c,loading:l,statusLoading:u,reload:d}=IJ(),[f,p]=G(!1);if(!l&&c.length===0)return null;let m=zJ(c,r);return n(e,{children:[t(HD,{align:`left`,trigger:t(oT,{variant:`ghost`,size:`icon`,className:`size-8 rounded-md text-muted hover:bg-muted`,title:s(`mcpConnections.settings`),disabled:l,children:t(`span`,{className:`flex size-5 items-center justify-center rounded-[3px] border border-muted text-sm font-semibold leading-none`,"aria-hidden":`true`,children:`/`})}),children:n(UD,{onClick:()=>p(!0),isDisabled:l,children:[t(`span`,{children:s(`mcpConnections.title`)}),m>0&&t(uT,{variant:`success`,children:m})]})}),t(VJ,{isOpen:f,onClose:()=>p(!1),groups:c,loading:l,reload:d,statusLoading:u,disabledCollections:r,onChange:i,onConnectionChange:a,readOnly:o})]})}const GJ=/(^|\/)(tool-inputs|tool-results|archive)(\/|$)/,KJ=/(^|\/)process\/(history|state)(\/|$)/,qJ=[/conversation\.json$/,/^conversation-checkpoint-\d+\.json$/,/^tools\.json$/,/^tool-input-refs\.json$/,/^toolu[_-]/i];function JJ(e){if(GJ.test(e)||KJ.test(e))return!0;let t=e.split(`/`).pop()??e;return qJ.some(e=>e.test(t))}function YJ(e){let t={name:``,path:``,isDirectory:!0,children:[]};for(let n of e){let e=n.split(`/`),r=t,i=``;for(let t=0;t<e.length;t++){let n=e[t];i=i?`${i}/${n}`:n;let a=t===e.length-1,o=r.children.find(e=>e.name===n);o||(o={name:n,path:i,isDirectory:!a,children:[]},r.children.push(o)),r=o}}let n=e=>{e.children.sort((e,t)=>e.isDirectory===t.isDirectory?e.name.localeCompare(t.name):e.isDirectory?-1:1),e.children.forEach(n)};return n(t),t.children}function XJ(e,t){let n=`agents/${t}/`,r=e.indexOf(n);return r===-1?e.split(`/`).pop()??e:e.slice(r+n.length)}function ZJ(e,t,n=0,r=!1){let[i,a]=G([]),[o,s]=G(!1),[c,l]=G(null),[u,d]=G(0),f=W(0),p=V(async()=>{if(!t)return;let n=++f.current;s(!0),l(null);try{let r=await e.files.listArtifacts(t);if(n!==f.current)return;let i=r.map(e=>XJ(e,t)).filter(e=>!!e);a(i)}catch(e){if(n!==f.current)return;l(e instanceof Error?e.message:`Failed to list artifacts`),a([])}finally{n===f.current&&s(!1)}},[e,t]);H(()=>{p()},[p,n,u]);let m=U(()=>r?i:i.filter(e=>!JJ(e)),[i,r]),h=U(()=>YJ(m),[m]),g=i.length-m.length,_=V(()=>{d(e=>e+1)},[]);return{tree:h,flatFiles:m,totalCount:i.length,systemHiddenCount:g,isLoading:o,error:c,refresh:_}}function QJ(){return $J||=import(`react-pdf`).then(e=>{let{pdfjs:t}=e;return t.GlobalWorkerOptions.workerSrc=`//unpkg.com/pdfjs-dist@${t.version}/build/pdf.worker.min.mjs`,e}),$J}var $J,eY,tY,nY=Y((()=>{eY=ht(()=>QJ().then(({Document:e})=>({default:e}))),tY=ht(()=>QJ().then(({Page:e})=>({default:e})))}));function rY({className:e,size:n=`md`}){return t(`div`,{className:`flex items-center justify-center ${e||``}`,children:t(ev,{className:`${{sm:`w-4 h-4`,md:`w-6 h-6`,lg:`w-8 h-8`}[n]} animate-spin text-muted`})})}function iY({pdfUrl:e,pageNumber:r,width:i,className:a,renderTextLayer:o=!1,renderAnnotationLayer:s=!1,onLoadSuccess:c,onError:l}){let[u,d]=G(!0),[f,p]=G(null);return f?t(`div`,{className:`flex items-center justify-center text-destructive text-sm ${a||``}`,children:`Failed to load PDF`}):n(`div`,{className:a,children:[u&&t(rY,{className:`py-4`,size:`md`}),t(ut,{fallback:null,children:t(eY,{file:e,onLoadSuccess:({numPages:e})=>{d(!1),c?.(e)},onLoadError:e=>{d(!1),p(e),l?.(e)},loading:null,children:t(tY,{pageNumber:r,width:i,renderTextLayer:o,renderAnnotationLayer:s,loading:t(rY,{className:`py-4`,size:`sm`})})})})]})}function aY({pdfUrl:e,urlLoading:n=!1,children:r,onLoadSuccess:i}){let[a,o]=G(0),[s,c]=G(!0),[l,u]=G(null),[d,f]=G(null),p=async e=>{o(e.numPages),i?.(e.numPages);try{let t=(await e.getPage(1)).getViewport({scale:1});f({width:t.width,height:t.height,aspectRatio:t.width/t.height})}catch(e){console.error(`Failed to get page dimensions:`,e)}c(!1)},m=e=>{c(!1),u(e)},h={pdfUrl:e,numPages:a,loading:n||!e||s,error:l,pageDimensions:d};return l?t(`div`,{className:`flex items-center justify-center text-destructive text-sm py-4`,children:`Failed to load PDF`}):t(fY.Provider,{value:h,children:e?t(ut,{fallback:t(rY,{className:`py-4`,size:`md`}),children:t(eY,{file:e,onLoadSuccess:p,onLoadError:m,loading:t(rY,{className:`py-4`,size:`md`}),children:r((e,n)=>t(tY,{pageNumber:e,width:n,renderTextLayer:!1,renderAnnotationLayer:!1,loading:t(rY,{className:`py-4`,size:`sm`})},e))})}):t(rY,{className:`py-4`,size:`md`})})}function oY(){return _t(fY)}function sY({pageNumber:e,width:n,className:r}){let i=oY(),a=i?.pageDimensions?.aspectRatio??pY,o=n?Math.round(n/a):200;return i?.loading?t(`div`,{className:`flex items-center justify-center bg-muted ${r||``}`,style:{height:o,width:n||`100%`},children:t(rY,{size:`md`})}):t(`div`,{className:r,children:t(tY,{pageNumber:e,width:n,renderTextLayer:!1,renderAnnotationLayer:!1,loading:t(rY,{className:`py-4`,size:`sm`})})})}function cY({pageNumber:e,width:n,isSelected:r,onSelect:i,renderThumbnail:a,aspectRatio:o=pY,rootMargin:s=`200px 0px`}){let c=W(null),[l,u]=G(!1);H(()=>{let e=c.current;if(!e)return;let t=new IntersectionObserver(e=>{e[0]?.isIntersecting&&u(!0)},{rootMargin:s,threshold:0});return t.observe(e),()=>t.disconnect()},[s]);let d=n?Math.round(n/o):200,f=l?t(tY,{pageNumber:e,width:n,renderTextLayer:!1,renderAnnotationLayer:!1,loading:t(`div`,{className:`flex items-center justify-center bg-muted`,style:{height:d},children:t(rY,{size:`sm`})})}):t(`div`,{className:`flex items-center justify-center bg-muted`,style:{height:d,width:n||`100%`},children:t(`span`,{className:`text-muted text-xs`,children:e})});return t(`div`,{ref:c,children:a({pageNumber:e,isSelected:r,pageElement:f,onSelect:i})})}function lY(e){if(!e)return null;let t=e.parentElement;for(;t;){let e=window.getComputedStyle(t).overflowY;if(e===`auto`||e===`scroll`)return t;t=t.parentElement}return null}function uY({pdfUrl:r,urlLoading:i=!1,pageCount:a,currentPage:o,thumbnailWidth:s,onPageSelect:c,renderThumbnail:l,scrollContainerRef:u,onAspectRatioChange:d,onItemHeightChange:f,calculateItemHeight:p,onPageCountChange:m}){let[h,g]=G(null),[_,v]=G({start:0,end:Math.min(15,a)}),[y,b]=G(null),x=W(null),S=V(e=>{g(e)},[]),C=V(async e=>{m?.(e.numPages);try{let t=(await e.getPage(1)).getViewport({scale:1}),n=t.width/t.height;b(n),d?.(n)}catch(e){console.error(`Failed to get page dimensions:`,e),b(pY),d?.(pY)}},[d,m]),w=y??pY,T=s?Math.round(s/w):200,E=p?p(T):T+16+24+8;if(H(()=>{E>0&&y!==null&&f?.(E)},[E,y,f]),H(()=>{let e=u?.current||lY(x.current);if(!e)return;let t=()=>{let t=e.scrollTop,n=e.clientHeight,r=Math.floor(t/E),i=Math.ceil((t+n)/E),o=Math.max(0,r-5),s=Math.min(a,i+5);v(e=>e.start!==o||e.end!==s?{start:o,end:s}:e)};return t(),e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[E,a,u]),h)return t(`div`,{className:`flex items-center justify-center text-destructive text-sm py-4`,children:`Failed to load PDF`});if(i||!r)return t(rY,{className:`py-4`,size:`md`});let D=_.start*E,O=(a-_.end)*E,k=y!==null;return t(`div`,{ref:x,children:t(ut,{fallback:t(rY,{className:`py-4`,size:`md`}),children:t(eY,{file:r,onLoadSuccess:C,onLoadError:S,loading:t(rY,{className:`py-4`,size:`md`}),children:k?n(e,{children:[D>0&&t(`div`,{style:{height:D}}),Array.from({length:_.end-_.start},(e,n)=>{let r=_.start+n+1;return t(`div`,{"data-page-index":r-1,style:{height:E,overflow:`hidden`},children:t(cY,{pageNumber:r,width:s,isSelected:r===o,onSelect:()=>c(r),renderThumbnail:l,aspectRatio:w})},r)}),O>0&&t(`div`,{style:{height:O}})]}):t(rY,{className:`py-4`,size:`md`})})})})}function dY({pdfUrl:e,pageNumber:r,width:i,height:a,className:o,renderTextLayer:s=!1,renderAnnotationLayer:c=!1,onPageChange:l}){let[u,d]=G(0),[f,p]=G(!0),[m,h]=G(null);return H(()=>{u>0&&l?.(r,u)},[r,u,l]),m?t(`div`,{className:`flex items-center justify-center text-destructive ${o||``}`,children:n(`span`,{children:[`Failed to load PDF: `,m.message]})}):n(`div`,{className:o,children:[f&&t(rY,{className:`py-8`,size:`lg`}),t(ut,{fallback:null,children:t(eY,{file:e,onLoadSuccess:({numPages:e})=>{d(e),p(!1)},onLoadError:e=>{p(!1),h(e)},loading:null,children:t(tY,{pageNumber:Math.min(r,u||1),width:i,height:a,renderTextLayer:s,renderAnnotationLayer:c,loading:t(rY,{className:`py-8`,size:`md`})})})})]})}var fY,pY,mY=Y((()=>{Q(),nY(),fY=dt(null),pY=210/297}));function hY({pdfUrl:r,pdfUrlLoading:i=!1,pageCount:a,currentPage:s,onChange:c,onPageCountChange:l,className:u,compact:d=!1,headerExtra:f}){let{t:m}=K(),h=W(null),g=W(null),[_,v]=G(void 0),[y,b]=G(bY),[x,S]=G(vY),[C,w]=G(null),T=W(null),E=_?Math.round(_*y/100):void 0,D=V(()=>{let e=yY.findIndex(e=>e>=y);e===-1&&(e=yY.length-1);let t=Math.min(e+1,yY.length-1);b(yY[t])},[y]),O=V(()=>{let e=yY.findIndex(e=>e>=y);e===-1&&(e=yY.length-1);let t=Math.max(e-1,0);b(yY[t])},[y]),k=V(()=>{b(bY)},[]),A=V(e=>e+(d?28:48),[d]),j=V((e,t)=>{let n=e?Math.round(e/t):200;return A(n)},[A]);H(()=>{let e=g.current;if(!e)return;let t=null,n=()=>e.clientWidth-16-16-4,r=()=>{let t=n();if(t<=0)return;let r=T.current;if(r&&r>0){let n=e.scrollTop,i=Math.round(n/r),a=j(t,x),o=i*a;v(t),requestAnimationFrame(()=>{e.scrollTo({top:o,behavior:`instant`})}),T.current=a}else v(t),T.current=j(t,x)},i=n();i>0&&(v(i),T.current=j(i,x));let a=new ResizeObserver(()=>{t&&clearTimeout(t),t=setTimeout(r,150)});return a.observe(e),()=>{t&&clearTimeout(t),a.disconnect()}},[x,j]);let M=W(!1),N=W(null),P=W(y);H(()=>{P.current!==y&&(P.current=y,N.current={targetPage:s},M.current=!0)},[y,s]),H(()=>{let e=g.current,t=N.current;if(t&&e&&C){N.current=null;let n=(t.targetPage-1)*C;requestAnimationFrame(()=>{e.scrollTo({top:n,behavior:`instant`}),requestAnimationFrame(()=>{M.current=!1})})}},[C]);let F=W(!1);H(()=>{let e=g.current;if(!(!e||!C||F.current)){if(s>1){F.current=!0,M.current=!0;let t=(s-1)*C;e.scrollTo({top:t,behavior:`instant`}),requestAnimationFrame(()=>{M.current=!1})}else F.current=!0}},[C,s]);let I=W(s);return H(()=>{let e=g.current;if(!(!e||!C)&&I.current!==s){I.current=s,M.current=!0;let t=(s-1)*C;e.scrollTo({top:t,behavior:`instant`}),requestAnimationFrame(()=>{M.current=!1})}},[s,C]),H(()=>{let e=g.current;if(!e||!C)return;let t=null,n=()=>{M.current||(t&&clearTimeout(t),t=setTimeout(()=>{let t=e.scrollTop,n=Math.round(t/C)+1,r=Math.max(1,Math.min(n,a));r!==s&&(I.current=r,c(r))},50))};return e.addEventListener(`scroll`,n,{passive:!0}),()=>{t&&clearTimeout(t),e.removeEventListener(`scroll`,n)}},[C,a,s,c]),n(`div`,{ref:h,className:it(`flex flex-col items-stretch`,d?`gap-y-1`:`gap-y-2`,u),children:[n(`div`,{className:it(`relative flex items-center justify-center px-2`,d?`h-6`:`h-9`),children:[t(o,{variant:`ghost`,size:`xs`,onClick:()=>{s>1&&c(s-1)},title:m(`pdf.previousPage`),children:t(Dh,{className:`size-4`})}),n(`div`,{className:`absolute start-2 flex items-center gap-x-1`,children:[t(_Y,{zoom:y,onZoomIn:D,onZoomOut:O,onFitToView:k,canZoomIn:y<yY[yY.length-1],canZoomOut:y>yY[0]}),f&&n(e,{children:[t(`div`,{className:`w-px h-4 bg-border mx-1`}),f]})]}),t(`div`,{className:`absolute end-2`,children:t(gY,{currentPage:s,totalPages:a,onChange:c})})]}),t(`div`,{ref:g,className:it(`flex flex-col items-center flex-1 overflow-y-auto px-2`,d?`gap-1`:`gap-2`),children:t(uY,{pdfUrl:r,urlLoading:i,pageCount:a,currentPage:s,thumbnailWidth:E,onPageSelect:c,onPageCountChange:l,scrollContainerRef:g,onAspectRatioChange:S,onItemHeightChange:w,calculateItemHeight:A,renderThumbnail:({pageNumber:e,isSelected:r,pageElement:i,onSelect:a})=>n(`div`,{className:it(`hover:bg-muted rounded-md w-full`,d?`p-1`:`p-2`),children:[t(o,{variant:`unstyled`,size:`none`,"aria-pressed":r,"aria-label":`Page ${e}`,className:it(`relative border-[2px] cursor-pointer overflow-hidden`,r?`border-primary`:`border-border`),onClick:a,children:i}),t(p,{className:it(`text-muted font-semibold`,d?`text-xs pt-0.5`:`text-sm pt-1`),children:e})]},e)})}),t(`div`,{className:it(`flex items-center justify-center`,d?`h-6`:`h-9`),children:t(o,{variant:`ghost`,size:`xs`,onClick:()=>{s<a&&c(s+1)},title:m(`pdf.nextPage`),children:t(hh,{className:`size-4`})})})]})}function gY({currentPage:e,totalPages:r,onChange:i}){let{t:a}=K(),o=W(null),[s,c]=G(String(e));H(()=>{c(String(e))},[e]);let l=()=>{let t=parseInt(s,10);!Number.isNaN(t)&&t>=1&&t<=r?i(t):c(String(e))};return n(`div`,{className:`flex items-center gap-1 text-xs text-muted`,children:[t(`span`,{children:a(`pdf.page`)}),t(`input`,{ref:o,type:`text`,value:s,onChange:e=>c(e.target.value),onKeyDown:t=>{t.key===`Enter`?(l(),o.current?.blur()):t.key===`Escape`&&(c(String(e)),o.current?.blur())},onBlur:()=>{l()},className:`w-8 h-5 text-center text-xs px-1 py-0 bg-background border border-border rounded focus:outline-none focus:border-primary`}),n(`span`,{children:[`/ `,r]})]})}function _Y({zoom:e,onZoomIn:r,onZoomOut:i,onFitToView:a,canZoomIn:s,canZoomOut:c}){let{t:l}=K();return n(`div`,{className:`flex items-center gap-x-0.5`,children:[t(o,{variant:`ghost`,size:`xs`,onClick:i,isDisabled:!c,title:l(`pdf.zoomOut`),children:t(Av,{})}),n(`span`,{className:`text-xs text-muted min-w-[32px] text-center`,children:[e,`%`]}),t(o,{variant:`ghost`,size:`xs`,onClick:r,isDisabled:!s,title:l(`pdf.zoomIn`),children:t(oy,{})}),t(o,{variant:`ghost`,size:`xs`,onClick:a,title:l(`pdf.fitToWidth`),className:e===bY?`text-muted/40`:void 0,children:t(fv,{})})]})}var vY,yY,bY,xY=Y((()=>{Q(),mY(),vY=210/297,yY=[50,75,100,125,150,200,300],bY=100}));function SY({object:e,url:r,source:i,className:a}){let{t:s}=K(),{client:c}=q(),[l,u]=G(1),[d,f]=G(r||``),[p,m]=G(!r),[h,g]=G(0),[_,v]=G(!1);H(()=>{if(r){f(r),m(!1);return}let t=i||e?.content?.source;if(!t){m(!1);return}m(!0),c.files.getDownloadUrl(t).then(e=>{f(e.url)}).catch(e=>{console.error(`Failed to get PDF URL:`,e)}).finally(()=>{m(!1)})},[r,i,e?.content?.source,c]),H(()=>{let t=e?.metadata,n=t?.pages||t?.page_count||0;n>0&&g(n)},[e?.metadata]);let y=e=>{g(e)};return p?t(`div`,{className:`flex items-center justify-center h-full`,children:t(je,{size:`lg`})}):d?_?n(`div`,{className:`fixed inset-0 bg-background z-50 flex flex-col overflow-hidden`,children:[t(`div`,{className:`flex h-9 items-center justify-end shrink-0 bg-sidebar px-2 border-b border-sidebar-border`,children:t(o,{variant:`ghost`,size:`xs`,onClick:()=>v(!1),title:s(`pdf.closeFullscreen`),children:t(Gb,{className:`size-4`})})}),t(hY,{pdfUrl:d,pdfUrlLoading:p,pageCount:h||100,currentPage:l,onChange:u,onPageCountChange:y,className:`flex-1 min-h-0`})]}):t(`div`,{className:`relative h-full flex flex-col`,children:t(hY,{pdfUrl:d,pdfUrlLoading:p,pageCount:h||100,currentPage:l,onChange:u,onPageCountChange:y,className:a,compact:!0,headerExtra:t(o,{title:s(`pdf.fullscreen`),tooltipPlacement:`bottom`,variant:`unstyled`,className:`p-1 rounded cursor-pointer transition-colors text-muted hover:text-foreground hover:bg-muted`,onClick:()=>v(!0),children:t(lv,{className:`size-4`})})})}):t(`div`,{className:`flex items-center justify-center h-full text-muted`,children:s(`pdf.noPdfAvailable`)})}var CY=Y((()=>{Q(),xY()})),wY=mr({UniversalDocumentViewer:()=>YY});function TY(e){return e.fileName||e.title||e.artifact?.path.split(`/`).pop()||e.sourcePath?.split(`/`).pop()||`Document`}function EY(e){let t=e.split(`?`)[0]||e;return t.includes(`.`)&&t.split(`.`).pop()?.toLowerCase()||``}function DY(e){return e.contentType===`application/pdf`||e.extension===`pdf`}function OY(e){return[`md`,`markdown`].includes(e.extension)||[`text/markdown`,`text/x-markdown`].includes(e.contentType||``)}function kY(e){return e.contentType?.startsWith(`image/`)||[`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`].includes(e.extension)}function AY(e){return e.contentType===`text/html`||[`html`,`htm`].includes(e.extension)}function jY(e){return[`application/xml`,`text/xml`].includes(e.contentType||``)||e.extension===`xml`}function MY(e){return e.contentType?.startsWith(`text/`)||[`css`,`csv`,`json`,`txt`,`tsx`,`ts`,`jsx`,`js`,`xml`,`yaml`,`yml`].includes(e.extension)}function NY(e){return[`tsx`,`jsx`].includes(e.extension)}function PY(e){return[`doc`,`docx`,`ppt`,`pptx`].includes(e.extension)||[`application/msword`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,`application/vnd.ms-powerpoint`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`].includes(e.contentType||``)}function FY({content:e,extension:n}){return t(`pre`,{className:`h-full overflow-auto rounded-md bg-muted/10 p-3 text-xs leading-5`,children:t(`code`,{className:n?`language-${n}`:void 0,children:e||``})})}function IY({message:e}){return n(`div`,{className:`flex h-full min-h-64 flex-col items-center justify-center gap-2 text-muted`,children:[t(Zg,{className:`size-8`}),t(`span`,{className:`text-sm`,children:e})]})}function LY(e,n){if(e.Component){let r=e.Component;return t(r,{context:n})}return e.render?.(n)??null}function RY(e,t){return e.includes(`.`)?e.replace(/\.[^/.]+$/,t):`${e}${t}`}function zY(e){return e.split(`/`).pop()||e}function BY(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function VY(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function HY(e){if(e!==void 0)return e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(+(e<1e4))} s`}function UY(e){return Array.isArray(e)?e.length:0}function WY(e){try{let t=BY(JSON.parse(e));if(!t)return;let n=BY(t.viewport);return{ok:typeof t.ok==`boolean`?t.ok:void 0,source_artifact:typeof t.source_artifact==`string`?t.source_artifact:void 0,screenshot_artifact:typeof t.screenshot_artifact==`string`?t.screenshot_artifact:void 0,rendered_at:typeof t.rendered_at==`string`?t.rendered_at:void 0,viewport:n?{width:VY(n.width),height:VY(n.height)}:void 0,dependencies_reused:typeof t.dependencies_reused==`boolean`?t.dependencies_reused:void 0,status:VY(t.status),title:typeof t.title==`string`?t.title:void 0,console_errors:Array.isArray(t.console_errors)?t.console_errors:void 0,page_errors:Array.isArray(t.page_errors)?t.page_errors:void 0,failed_requests:Array.isArray(t.failed_requests)?t.failed_requests:void 0,bad_responses:Array.isArray(t.bad_responses)?t.bad_responses:void 0,timings_ms:BY(t.timings_ms),error:t.error}}catch{return}}async function GY(e,t){let n=await fetch(e);if(!n.ok)throw Error(`Failed to load ${t}: ${n.statusText}`);return n.text()}function KY({metadata:e,sourcePath:t,fallbackPath:n,artifactMode:r}){let i=e?.screenshot_artifact?.replace(/^\/+/,``);if(!i)return n;if(r)return i;let a=e?.source_artifact?.replace(/^\/+/,``),o=t.replace(/^\/+/,``);if(a&&o.endsWith(a)){let e=o.slice(0,-a.length).replace(/\/+$/,``);return e?`${e}/${i}`:i}let s=o.includes(`/`)?o.slice(0,o.lastIndexOf(`/`)+1):``;return s?`${s}${zY(i)}`:n}function qY({metadata:e}){if(!e)return null;let r=VY(e.timings_ms?.total_before_cleanup),a=UY(e.console_errors)+UY(e.page_errors)+UY(e.failed_requests)+UY(e.bad_responses);return n(`div`,{className:`grid gap-2 border-b p-3 text-xs`,children:[n(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.ok!==void 0&&t(i,{variant:e.ok?`success`:`destructive`,children:e.ok?`render ok`:`render failed`}),e.dependencies_reused!==void 0&&n(i,{variant:e.dependencies_reused?`info`:`secondary`,children:[`deps `,e.dependencies_reused?`reused`:`installed`]}),e.status&&n(i,{variant:`secondary`,children:[`HTTP `,e.status]}),a>0&&n(i,{variant:`attention`,children:[a,` browser issue(s)`]})]}),n(`div`,{className:`grid gap-1 text-muted sm:grid-cols-2`,children:[e.viewport?.width&&e.viewport.height&&n(`div`,{children:[`Viewport `,e.viewport.width,` x `,e.viewport.height]}),HY(r)&&n(`div`,{children:[`Total `,HY(r)]}),e.rendered_at&&n(`div`,{children:[`Rendered `,new Date(e.rendered_at).toLocaleString()]}),e.title&&n(`div`,{className:`truncate`,children:[`Title `,e.title]})]}),typeof e.error==`string`&&t(`div`,{className:`text-destructive`,children:e.error})]})}function JY({context:e}){let{client:r}=q(),a=e.source.artifact,o=a?.path||e.source.sourcePath,s=!!a,c=e.content||``,[l,u]=G({isLoading:!1}),d=V(async(e,t)=>a?(await r.files.getArtifactDownloadUrl(a.runId,e,t)).url:(await r.files.getDownloadUrl(e,zY(e),t)).url,[a,r]);return H(()=>{if(!o){u({isLoading:!1,previewError:`No source path is available for this TSX artifact.`});return}let e=o,t=!1,n=RY(e,`.png`),r=RY(e,`.render.json`);async function i(){u({isLoading:!0});let i,a,o=n;try{i=WY(await GY(await d(r,`inline`),zY(r))),o=KY({metadata:i,sourcePath:e,fallbackPath:n,artifactMode:s})}catch(e){a=e instanceof Error?e.message:`Render metadata is not available`}let c,l;try{c=await d(o,`inline`)}catch(e){l=e instanceof Error?e.message:`Sandbox render image is not available`}t||u({isLoading:!1,imageUrl:c,metadata:i,metadataError:a,previewError:l})}return i(),()=>{t=!0}},[s,d,o]),n(`div`,{className:`flex h-full min-h-0 flex-col`,children:[n(`div`,{className:`flex min-h-10 flex-wrap items-center gap-2 border-b px-3 py-2 text-sm`,children:[t(D_,{className:`size-4 text-info`}),t(`span`,{className:`font-medium`,children:`Sandbox render`}),l.isLoading?t(i,{variant:`secondary`,children:`loading`}):l.imageUrl?t(i,{variant:`success`,children:`PNG preview`}):t(i,{variant:`attention`,children:`source only`}),l.metadata?.rendered_at&&t(`span`,{className:`text-xs text-muted`,children:new Date(l.metadata.rendered_at).toLocaleString()})]}),l.isLoading?n(`div`,{className:`flex h-full min-h-64 items-center justify-center gap-2 text-muted`,children:[t(ev,{className:`size-5 animate-spin`}),t(`span`,{className:`text-sm`,children:`Loading sandbox render...`})]}):l.imageUrl?n(`div`,{className:`grid min-h-0 flex-1 xl:grid-cols-[minmax(0,1fr)_minmax(24rem,0.7fr)]`,children:[t(`div`,{className:`flex min-h-0 items-center justify-center overflow-auto bg-muted/10 p-3`,children:t(`img`,{src:l.imageUrl,alt:`${e.fileName} sandbox render`,className:`max-h-full max-w-full rounded-md object-contain`})}),n(`div`,{className:`min-h-0 overflow-auto border-t xl:border-s xl:border-t-0`,children:[t(qY,{metadata:l.metadata}),t(`div`,{className:`p-3`,children:t(FY,{content:c,extension:e.extension})})]})]}):n(`div`,{className:`grid min-h-0 flex-1 grid-rows-[auto_minmax(0,1fr)]`,children:[n(`div`,{className:`border-b px-3 py-2 text-xs text-muted`,children:[`No sandbox-rendered PNG was found for this TSX artifact. Showing the source without executing it in Studio.`,l.previewError&&n(`span`,{className:`ms-1`,children:[`Preview lookup: `,l.previewError]}),!l.previewError&&l.metadataError&&n(`span`,{className:`ms-1`,children:[`Metadata lookup: `,l.metadataError]})]}),n(`div`,{className:`min-h-0 overflow-auto p-3`,children:[t(qY,{metadata:l.metadata}),t(FY,{content:c,extension:e.extension})]})]})]})}function YY({source:e,className:r,bodyClassName:i,renderers:a=[],converters:s=[],resolveUrl:c,loadText:l,createRendition:u,markdownComponents:d,showHeader:f=!1,onDownload:p}){let{client:m}=q(),h=U(()=>TY(e),[e]),g=U(()=>EY(h),[h]),[_,v]=G(e.url),[y,b]=G(e.content),[x,S]=G(null),[C,w]=G(!1),[T,E]=G(null),[D,O]=G(0),k=[e.id,e.title,e.fileName,e.contentType,e.url,e.sourcePath,e.content,e.artifact?.runId,e.artifact?.path].join(`\0`),A=V(async(e,t)=>e.url?e.url:e.artifact?(await m.files.getArtifactDownloadUrl(e.artifact.runId,e.artifact.path,t)).url:e.sourcePath?(await m.files.getDownloadUrl(e.sourcePath,e.fileName,t)).url:``,[m]),j=c||A,M=V(async e=>{if(e.content!==void 0)return e.content;let t=await j(e,`inline`);if(!t)return``;let n=await fetch(t);if(!n.ok)throw Error(`Failed to load ${TY(e)}: ${n.statusText}`);return n.text()},[j]),N=l||M,P={source:e,fileName:h,extension:g,contentType:e.contentType||x?.contentType,url:x?.url||_,content:x?.content||y,isLoading:C,error:T,reload:()=>O(e=>e+1)},F=a.find(e=>e.canRender(P)),I=!F&&(OY(P)||AY(P)||jY(P)||MY(P)),L=!F&&(DY(P)||kY(P)),ee={source:e,fileName:h,extension:g,contentType:e.contentType,target:`pdf`},R=!F&&!P.url?s.find(e=>e.target===`pdf`&&e.canConvert(ee)):void 0,te=!F&&!P.url&&(PY(P)||!!R)&&(!!R||!!u);H(()=>{let t=!1,n=e;E(null),v(n.url),b(n.content),S(null);async function r(){if(!(!I&&!L&&!te)){w(!0);try{if(te){let e=R?await R.convert({source:n,fileName:h,extension:g,contentType:n.contentType,target:`pdf`}):await u?.(n,`pdf`);t||S(e??null);return}if(I){let e=await N(n);t||b(e);return}if(L){let e=await j(n,`inline`);t||v(e)}}catch(e){t||E(e instanceof Error?e.message:`Failed to load document`)}finally{t||w(!1)}}}return r(),()=>{t=!0}},[u,g,h,N,te,I,L,D,j,R,e,k]);let ne={...P,url:x?.url||_,content:x?.content||y,contentType:x?.contentType||e.contentType,isLoading:C,error:T},re;return re=C?n(`div`,{className:`flex h-full min-h-64 items-center justify-center gap-2 text-muted`,children:[t(ev,{className:`size-5 animate-spin`}),t(`span`,{className:`text-sm`,children:`Loading preview...`})]}):T?n(`div`,{className:`flex h-full min-h-64 flex-col items-center justify-center gap-2 text-destructive`,children:[t(Ah,{className:`size-7`}),t(`span`,{className:`max-w-xl text-center text-sm`,children:T}),t(o,{variant:`outline`,size:`sm`,onClick:ne.reload,children:`Retry`})]}):F?LY(F,ne):(DY(ne)||x?.contentType===`application/pdf`)&&ne.url?t(SY,{url:ne.url,className:`h-full`}):kY(ne)&&ne.url?t(`div`,{className:`flex h-full min-h-0 items-center justify-center overflow-auto bg-muted/10 p-3`,children:t(`img`,{src:ne.url,alt:h,className:`max-h-full max-w-full rounded-md object-contain`})}):OY(ne)?t(`div`,{className:`prose prose-sm dark:prose-invert max-w-none px-5 py-4`,children:t(Nt,{artifactRunId:e.artifact?.runId,components:d,children:ne.content||``})}):AY(ne)?t(`iframe`,{title:h,className:`h-full min-h-96 w-full bg-white`,sandbox:``,srcDoc:ne.content||``}):jY(ne)?t(`div`,{className:`px-4 py-2`,children:t(Rt,{xml:ne.content||``,collapsible:!0})}):NY(ne)?t(JY,{context:ne}):MY(ne)?t(FY,{content:ne.content,extension:g}):PY(ne)&&!R&&!u?t(IY,{message:`This file needs a PDF rendition before it can be previewed.`}):t(IY,{message:`Preview is not available for this file type.`}),n(`div`,{className:z(`flex h-full min-h-0 flex-col overflow-hidden`,r),children:[f&&n(`div`,{className:`flex min-h-10 items-center justify-between gap-3 border-b py-2 ps-3 pe-16`,children:[n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`truncate text-sm font-medium`,title:h,children:h}),ne.contentType&&t(`div`,{className:`truncate text-xs text-muted`,children:ne.contentType})]}),p&&t(o,{variant:`outline`,size:`sm`,onClick:()=>p(e),children:`Download`})]}),t(`div`,{className:z(`min-h-0 flex-1 overflow-auto`,i),children:re})]})}var XY=Y((()=>{Q(),CY()}));Q();const ZY=ot.lazy(async()=>({default:(await Promise.resolve().then(()=>(XY(),wY))).UniversalDocumentViewer})),QY=new Set([`md`,`markdown`,`mdx`,`txt`]);function $Y(e){let t=e.split(`.`).pop()?.toLowerCase();return t!==void 0&&QY.has(t)}function eX(e){return e.replace(/[_-]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function tX({node:e,depth:r,runId:i,onOpen:a,onDownload:s,downloadingPath:c,forceExpanded:l=!1}){let{t:u}=K(),[d,f]=G(!1),p=l||d;if(e.isDirectory)return n(`div`,{className:`min-w-0`,children:[n(o,{variant:`unstyled`,className:`flex w-full max-w-full items-center justify-start gap-1.5 rounded px-1 py-1 text-start text-sm hover:bg-muted/30`,style:{paddingInlineStart:`${r*14+4}px`},onClick:()=>f(e=>!e),"aria-expanded":p,children:[p?t(rh,{className:`size-3.5 shrink-0 text-muted`}):t(lh,{className:`size-3.5 shrink-0 text-muted cn-rtl-flip`}),t(p?r_:o_,{className:`size-4 shrink-0 text-info`}),t(`span`,{className:`min-w-0 truncate font-medium`,title:e.path,children:eX(e.name)})]}),p&&e.children.map(e=>t(tX,{node:e,depth:r+1,runId:i,onOpen:a,onDownload:s,downloadingPath:c,forceExpanded:l},`${i}:${e.path}`))]});let m=c===e.path;return n(`div`,{className:`flex min-w-0 items-center gap-1`,children:[n(o,{variant:`unstyled`,className:`flex min-w-0 flex-1 items-center justify-start gap-1.5 rounded px-1 py-1 text-start text-sm hover:bg-muted/30`,style:{paddingInlineStart:`${r*14+4}px`},onClick:()=>a(e.path),title:e.path,children:[t(`span`,{className:`size-3.5 shrink-0`}),t(Zg,{className:`size-4 shrink-0 text-muted`}),t(`span`,{className:`min-w-0 truncate`,children:e.name})]}),t(o,{variant:`ghost`,size:`sm`,className:`h-7 w-7 shrink-0 p-0`,onClick:()=>s(e.path),disabled:m,"aria-label":u(`agent.download`),title:u(`agent.download`),children:m?t(ev,{className:`size-3.5 animate-spin text-info`}):t(xg,{className:`size-3.5`})})]})}function nX(e){return e.reduce((e,t)=>t.isDirectory?e+nX(t.children):e+1,0)}function rX(e,t){let n=t.trim().toLocaleLowerCase();return n?e.flatMap(e=>{let t=`${e.name} ${e.path}`.toLocaleLowerCase().includes(n);if(!e.isDirectory)return t?[e]:[];let r=rX(e.children,n);return t?[{...e}]:r.length>0?[{...e,children:r}]:[]}):e}function iX(e,t){let n=document.createElement(`a`);n.href=e,n.download=t,n.rel=`noopener noreferrer`,n.style.display=`none`,document.body.appendChild(n),n.click(),n.remove()}function aX(e){switch(e.split(`.`).pop()?.toLowerCase()){case`css`:return`text/css`;case`gif`:return`image/gif`;case`htm`:case`html`:return`text/html`;case`jpeg`:case`jpg`:return`image/jpeg`;case`json`:return`application/json`;case`md`:case`markdown`:return`text/markdown`;case`pdf`:return`application/pdf`;case`png`:return`image/png`;case`svg`:return`image/svg+xml`;case`ts`:case`tsx`:return`text/typescript`;case`txt`:return`text/plain`;case`webp`:return`image/webp`;default:return}}function oX({runId:e,path:r,onBack:i,onDownload:a,refreshKey:s,refreshDetails:c,onSendMessage:l}){let{t:u}=K(),[d,f]=G(`components`),[p,m]=G(`idle`);return n(`div`,{className:`flex h-full min-h-0 flex-col`,children:[n(`div`,{className:`flex shrink-0 items-center gap-1 border-b border-border/60 px-2 py-1`,children:[t(o,{variant:`ghost`,size:`sm`,className:`size-8 shrink-0 rounded-md p-0`,onClick:i,"aria-label":u(`agent.backToArtifacts`),title:u(`agent.backToArtifacts`),children:t(wm,{className:`size-4 cn-rtl-flip`})}),n(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[t(`span`,{className:`truncate text-sm font-medium`,title:r,children:r.split(`/`).pop()}),p===`saving`?t(We,{description:u(`agent.savingWorkingCopy`),asChild:!0,children:t(ev,{className:`size-3.5 shrink-0 animate-spin text-muted`,"aria-label":u(`agent.savingWorkingCopy`)})}):p===`saved`?t(We,{description:u(`agent.savedToWorkingCopy`),asChild:!0,children:t(eh,{className:`size-3.5 shrink-0 text-success`,"aria-label":u(`agent.savedToWorkingCopy`)})}):null]}),n(`div`,{className:`flex items-center gap-0.5`,children:[t(o,{variant:d===`components`?`primary`:`ghost`,size:`sm`,className:`size-8 shrink-0 rounded-md p-0`,onClick:()=>f(`components`),"aria-label":u(`agent.blockMode`),"aria-pressed":d===`components`,title:u(`agent.blockMode`),children:t(xy,{className:`size-4`})}),t(o,{variant:d===`document`?`primary`:`ghost`,size:`sm`,className:`size-8 shrink-0 rounded-md p-0`,onClick:()=>f(`document`),"aria-label":u(`agent.editMode`),"aria-pressed":d===`document`,title:u(`agent.editMode`),children:t(Jv,{className:`size-4`})})]}),t(o,{variant:`ghost`,size:`sm`,className:`size-8 shrink-0 rounded-md p-0`,onClick:()=>a(r),"aria-label":u(`agent.download`),title:u(`agent.download`),children:t(xg,{className:`size-4`})})]}),t(wt,{runId:e,path:r,viewMode:d,refreshKey:s,refreshDetails:c,readOnly:!l,onAction:e=>{if(!l)return;let t=e.anchor.block_type.replaceAll(`_`,` `);l(e.comment?.trim()||u(`agent.editedSelectionMessage`,{blockType:t}),{editing_action:e})},onSaveStatusChange:m,onSendMessage:l?e=>l(e):void 0,className:z(`relative min-h-0 flex-1`,d===`document`?`overflow-hidden`:`overflow-y-auto px-6 py-5`)})]})}function sX({icon:e,children:r,action:i}){return n(p,{className:`h-full min-h-[240px] flex-col text-center text-muted`,children:[e,t(`span`,{className:`text-sm`,children:r}),i]})}function cX({runId:r,refreshKey:i=0,refreshDetails:a,selectedPath:s,onSelectedPathChange:c,onSendMessage:l}){let{t:u}=K(),{client:d}=q(),[f,m]=G(!1),{tree:h,flatFiles:g,totalCount:_,systemHiddenCount:v,isLoading:y,error:b,refresh:x}=ZJ(d,r,i,f),[S,C]=G(null),[w,T]=G(null),[E,D]=G(``),[O,k]=G(null),A=s===void 0?O:s,j=V(e=>{s===void 0&&k(e),c?.(e)},[c,s]),N=E.trim(),P=U(()=>rX(h,N),[h,N]),F=U(()=>nX(P),[P]),I=vt(),L=V(async e=>{if(r){C(e);try{let{url:t}=await d.files.getArtifactDownloadUrl(r,e,`attachment`);iX(t,e.split(`/`).pop()||`artifact`)}catch(e){console.error(`Failed to get artifact download URL:`,e)}finally{C(null)}}},[d,r]),ee=V(e=>{if($Y(e)){j(e);return}T(e)},[j]),R=r&&w?{title:w.split(`/`).pop()||w,fileName:w.split(`/`).pop()||w,contentType:aX(w),artifact:{runId:r,path:w}}:null;return r?y&&_===0?t(sX,{icon:t(ev,{className:`mb-2 size-6 animate-spin`}),children:u(`agent.loadingArtifacts`)}):b?t(`div`,{className:`flex flex-col items-center justify-center p-4 text-muted w-full`,children:n(M,{title:`Fail to load Artifacts`,className:`w-full`,action:x,actionLabel:n(e,{children:[t(hy,{className:`size-3.5 me-1.5`}),u(`agent.retry`)]}),children:[t(`span`,{className:`break-all text-muted`,children:b}),` `,t(`br`,{})]})}):_===0?t(sX,{icon:t(Iv,{className:`mb-2 size-8`}),action:n(o,{variant:`ghost`,size:`sm`,className:`mt-2`,onClick:x,children:[t(hy,{className:`size-3.5 me-1.5`}),u(`agent.refresh`)]}),children:u(`agent.noArtifactsYet`)}):A?t(oX,{runId:r,path:A,refreshKey:i,refreshDetails:a,onBack:()=>j(null),onDownload:e=>void L(e),onSendMessage:l}):n(`div`,{className:`flex flex-col h-full`,children:[n(`div`,{className:`flex shrink-0 flex-col gap-2 border-b px-3 py-2`,children:[n(`div`,{className:`flex items-center justify-between gap-2 text-xs text-muted`,children:[n(`span`,{children:[N?`${F} of ${g.length} file${g.length===1?``:`s`}`:`${g.length} file${g.length===1?``:`s`}`,!f&&v>0?` · ${v} hidden`:``]}),n(`div`,{className:`flex items-center gap-1`,children:[t(Ne,{size:`sm`,value:f,onChange:m,children:t(`span`,{className:`text-xs text-muted`,children:u(`agent.showSystemArtifacts`)})}),t(o,{variant:`ghost`,size:`sm`,onClick:x,disabled:y,className:`h-6 w-6 p-0`,children:t(hy,{className:`size-3.5 ${y?`animate-spin`:``}`})})]})]}),t(`label`,{htmlFor:I,className:`sr-only`,children:u(`form.filter`)}),t(te,{id:I,type:`text`,role:`searchbox`,autoComplete:`off`,placeholder:u(`store.searchPlaceholder`),value:E,onChange:D,clearable:!0})]}),t(`div`,{className:`flex-1 overflow-y-auto px-3 py-2`,children:P.length>0?t(`div`,{className:`min-w-0`,children:P.map(e=>t(tX,{node:e,depth:0,runId:r,onOpen:ee,onDownload:L,downloadingPath:S,forceExpanded:!!N},`${r}:${e.path}`))}):t(`div`,{className:`px-1 py-6 text-sm text-muted`,children:u(!f&&v>0?`agent.onlySystemArtifacts`:`agent.noContentAvailable`)})}),R&&n(se,{isOpen:!!w,onClose:()=>T(null),size:`xl`,className:`h-[90vh] p-0`,description:`Artifact preview`,children:[t(ue,{show:!1,children:R.fileName}),t(ce,{className:`h-full max-h-none p-0`,children:t(ot.Suspense,{fallback:t(p,{className:`h-full`,children:t(ev,{className:`size-6 animate-spin text-muted`})}),children:t(ZY,{source:R,className:`h-full`,showHeader:!0,onDownload:()=>w&&void L(w)})})})]})]}):t(sX,{icon:t(Iv,{className:`mb-2 size-8`}),children:`No run selected`})}const lX=ot.memo(cX);Q();function uX(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function dX(e){if(!uX(e))return;let t=e.browseruse??e.browser_use;if(!uX(t))return;let n={widget:typeof t.widget==`string`?t.widget:void 0,browser_workflow_id:typeof t.browser_workflow_id==`string`?t.browser_workflow_id:void 0,workstream_id:typeof t.workstream_id==`string`?t.workstream_id:void 0,phase:typeof t.phase==`string`?t.phase:void 0,url:typeof t.url==`string`?t.url:void 0,title:typeof t.title==`string`?t.title:void 0,screenshot:typeof t.screenshot==`string`?t.screenshot:void 0,raw_screenshot:typeof t.raw_screenshot==`string`?t.raw_screenshot:void 0,prefer_raw_screenshot:typeof t.prefer_raw_screenshot==`boolean`?t.prefer_raw_screenshot:void 0,updated_at:typeof t.updated_at==`number`?t.updated_at:void 0};if(!(n.widget&&n.widget!==`browseruse`)&&!(!n.url&&!n.title&&!n.screenshot&&!n.raw_screenshot))return n}function fX(e){let t=new Map;for(let n of e){let e=dX(n.details);if(!e)continue;let r=e.workstream_id||n.workstream_id||`main`,i=e.updated_at??(typeof n.timestamp==`number`?n.timestamp:new Date(n.timestamp).getTime()),a=t.get(r);(!a||i>=a.timestamp)&&t.set(r,{state:{...e,workstream_id:r},timestamp:i})}return new Map(Array.from(t.entries()).map(([e,t])=>[e,t.state]))}function pX(e){return e.replace(/^artifact:\/\//,``).replace(/^artifact:/,``).replace(/^\/+/,``)}function mX(e){return e?e.replace(/_/g,` `):`browser`}function hX({state:e,runId:r,className:a,compact:o}){let{t:s}=K(),{client:c}=q(),l=VS(),{openImage:u}=EW(),[d,f]=G(),p=e.prefer_raw_screenshot===!1?e.screenshot||e.raw_screenshot:e.raw_screenshot||e.screenshot,m=e.title||e.url||s(`agent.browserUse`),h=U(()=>p&&pX(p).split(`/`).pop()||s(`agent.browserScreenshot`),[p,s]);return H(()=>{if(!p){f(void 0);return}if(p.startsWith(`http://`)||p.startsWith(`https://`)){f(p);return}if(!r){f(void 0);return}let e=!1;return(async()=>{let t=pX(p);try{let n=US(r,t,`inline`),i=l?await l.getOrFetch(n,async()=>(await c.files.getArtifactDownloadUrl(r,t,`inline`)).url):(await c.files.getArtifactDownloadUrl(r,t,`inline`)).url;e||f(i)}catch(n){console.error(`Failed to resolve browser screenshot ${t}`,n),e||f(void 0)}})(),()=>{e=!0}},[c,r,p,l]),o?n(`div`,{className:z(`overflow-hidden rounded-md border border-border/70 bg-transparent`,a),children:[n(`div`,{className:`flex items-center gap-2 px-2 py-1.5`,children:[t(Nv,{className:`size-3.5 shrink-0 text-info`}),n(`div`,{className:`min-w-0 flex-1`,children:[n(`div`,{className:`flex min-w-0 items-center gap-1`,children:[t(`span`,{className:`text-xs font-medium text-foreground`,children:s(`agent.browserPreview`)}),e.phase&&n(`span`,{className:`truncate text-[11px] capitalize text-muted`,children:[`· `,mX(e.phase)]})]}),t(`div`,{className:`truncate text-[11px] text-muted`,title:m,children:m})]}),e.url&&t(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,title:s(`agent.openInNewTab`),className:z(`inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md`,`text-muted hover:bg-muted hover:text-foreground`),children:t(Dg,{className:`size-3`})})]}),p&&(d?t(`button`,{type:`button`,className:`block w-full bg-mixer-muted/20 text-start`,onClick:()=>u(d,h),title:s(`agent.clickToEnlarge`),children:t(`img`,{src:d,alt:h,className:`block max-h-32 w-full object-contain`})}):n(`div`,{className:`flex min-h-16 items-center justify-center gap-2 bg-mixer-muted/20 px-3 py-4 text-xs text-muted`,children:[t(D_,{className:`size-4`}),t(`span`,{children:s(`agent.browserScreenshotPending`)})]}))]}):n(`div`,{className:z(`overflow-hidden rounded-md border border-muted bg-mixer-muted/10`,a),children:[n(`div`,{className:`flex items-start justify-between gap-2 border-b border-muted px-2.5 py-2`,children:[n(`div`,{className:`flex min-w-0 items-start gap-2`,children:[t(Nv,{className:`mt-0.5 size-4 shrink-0 text-info`}),n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`text-xs font-medium text-foreground`,children:s(`agent.browserUse`)}),t(`div`,{className:`truncate text-xs text-muted`,title:m,children:m})]})]}),t(i,{variant:`info`,className:`shrink-0 capitalize`,children:mX(e.phase)})]}),d?t(`button`,{type:`button`,className:`block w-full bg-mixer-muted/20 text-start`,onClick:()=>u(d,h),title:s(`agent.clickToEnlarge`),children:t(`img`,{src:d,alt:h,className:`block max-h-56 w-full object-contain`})}):n(`div`,{className:`flex min-h-28 items-center justify-center gap-2 bg-mixer-muted/20 px-3 py-6 text-xs text-muted`,children:[t(D_,{className:`size-4`}),t(`span`,{children:s(`agent.browserScreenshotPending`)})]}),e.url&&n(`div`,{className:`flex items-center gap-2 border-t border-muted px-2.5 py-1.5`,children:[t(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`min-w-0 flex-1 truncate text-xs text-info hover:underline`,title:e.url,children:e.url}),t(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,title:s(`agent.openInNewTab`),className:z(`inline-flex h-6 shrink-0 items-center justify-center rounded-md px-1.5`,`text-muted hover:bg-muted hover:text-foreground`),children:t(Dg,{className:`size-3`})})]})]})}Q();function gX({documentId:e,title:r,onBack:i,onUpdateDocumentTitle:a,refreshKey:s,runId:c}){let{client:l}=q(),{t:u}=K(),[d,f]=G(null),[p,m]=G(!1),[h,g]=G(null),[_,v]=G(null),y=V(async e=>{m(!0),g(null);try{let[t,n]=await Promise.all([l.store.objects.getObjectText(e),l.store.objects.retrieve(e)]);f(t.text??null);let r=n.name;v(r),r&&a?.(e,r)}catch(e){let t=e instanceof Error?e.message:u(`agent.failedToLoadDocument`);g(t),f(null)}finally{m(!1)}},[l,a,u]);return H(()=>{y(e)},[e,s,y]),n(`div`,{className:`h-full overflow-hidden flex flex-col`,children:[n(`div`,{className:`flex items-center justify-between gap-1 px-2 py-1 border-b border-border/60 shrink-0`,children:[t(o,{variant:`ghost`,size:`sm`,className:`size-8 shrink-0 rounded-md p-0`,onClick:i,"aria-label":u(`agent.backToDocuments`),title:u(`agent.backToDocuments`),children:t(wm,{className:`size-4 cn-rtl-flip`})}),n(`div`,{className:`flex items-center gap-1.5 min-w-0 flex-1`,children:[t(Gg,{className:`size-4 text-muted shrink-0`}),t(`span`,{className:`truncate text-sm font-medium`,title:_||r,children:_||r||u(`agent.document`)})]}),n(Zn,{href:`/store/objects/${e}#overview`,topLevelNav:!0,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted hover:bg-muted/20 hover:text-foreground`,children:[t(We,{description:u(`agent.openDocument`),placement:`top`,size:`xs`,asChild:!0,children:t(Dg,{className:`size-4`,"aria-hidden":`true`})}),t(`span`,{className:`sr-only`,children:u(`agent.openDocument`)})]})]}),t(`div`,{className:`flex-1 overflow-y-auto px-4 py-4`,children:p?n(`div`,{className:`flex items-center justify-center py-12`,children:[t(ev,{className:`size-5 animate-spin text-muted`}),t(`span`,{className:`ms-2 text-sm text-muted`,children:u(`agent.loadingDocument`)})]}):h?t(`div`,{className:`p-4 rounded-md bg-destructive/10 text-destructive text-sm`,children:h}):d?t(`div`,{className:`prose prose-sm dark:prose-invert max-w-none`,children:t(Nt,{artifactRunId:c,children:d})}):n(`div`,{className:`flex flex-col items-center justify-center py-12 text-muted`,children:[t(Gg,{className:`size-8 mb-2`}),t(`span`,{className:`text-sm`,children:u(`agent.noContentAvailable`)})]})})]})}const _X=ot.memo(gX);Q();function vX({documents:r,activeDocumentId:i,onSelectDocument:a,onUpdateDocumentTitle:s,refreshKey:c,runId:l}){let{t:u}=K(),[d,f]=G(``),p=vt(),m=d.trim().toLocaleLowerCase(),h=U(()=>m?r.filter(e=>e.title.toLocaleLowerCase().includes(m)):r,[r,m]),g=V(()=>a(null),[a]),_=i?r.find(e=>e.id===i):void 0;return i?t(_X,{documentId:i,title:_?.title,onBack:g,onUpdateDocumentTitle:s,refreshKey:c,runId:l}):n(`div`,{className:`flex flex-col h-full`,children:[n(`div`,{className:`flex shrink-0 flex-col gap-2 border-b px-3 py-2`,children:[t(`span`,{className:`text-xs text-muted`,children:m?u(`agent.documentsFiltered`,{visible:h.length,total:r.length}):u(`agent.documentCount`,{count:r.length})}),r.length>5&&n(e,{children:[t(`label`,{htmlFor:p,className:`sr-only`,children:u(`form.filter`)}),t(te,{id:p,type:`text`,role:`searchbox`,autoComplete:`off`,placeholder:u(`store.searchPlaceholder`),value:d,onChange:f,clearable:!0})]})]}),t(`div`,{className:`flex-1 overflow-y-auto px-3 py-2`,children:h.length>0?t(`div`,{className:`min-w-0`,children:h.map(e=>n(`div`,{className:`flex min-w-0 items-center gap-1`,children:[n(o,{variant:`unstyled`,className:`flex min-w-0 flex-1 items-center justify-start gap-1.5 rounded px-1 py-1 text-start text-sm hover:bg-muted/30`,onClick:()=>a(e.id),title:e.title,children:[t(Gg,{className:`size-4 shrink-0 text-muted`}),t(`span`,{className:`min-w-0 truncate`,children:e.title})]}),n(Zn,{href:`/store/objects/${e.id}#overview`,topLevelNav:!0,className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted hover:bg-muted/20 hover:text-foreground`,children:[t(We,{description:u(`agent.openDocument`),placement:`top`,size:`xs`,asChild:!0,children:t(Dg,{className:`size-3.5`,"aria-hidden":`true`})}),t(`span`,{className:`sr-only`,children:u(`agent.openDocument`)})]})]},e.id))}):t(`div`,{className:`px-1 py-6 text-sm text-muted`,children:u(`agent.noMatchingDocuments`)})})]})}const yX=ot.memo(vX);Q();function bX({plan:e,workstreamStatus:r,isOpen:i,onClose:a,plans:s=[],activePlanIndex:c=0,onChangePlan:l=()=>{}}){let{t:u}=K();if(!i)return null;let d=e.plan||[],f=d.length,m=d.reduce((e,t)=>t?.id&&(r.get(t.id.toString())===`completed`||t.status===`completed`)?e+1:e,0),h=f>0?Math.round(m/f*100):0,g=s.length>0?s.length-c:1,_=s[c]?.timestamp;return d.length===0?t(`div`,{className:`h-full overflow-hidden`,children:n(p,{className:`h-full min-h-[240px] flex-col text-center text-muted`,children:[t(eg,{className:`mb-2 size-8`}),t(`span`,{className:`text-sm`,children:u(`agent.noPlanAvailable`)})]})}):t(`div`,{className:`h-full overflow-hidden`,children:n(`div`,{className:`flex h-full flex-col gap-4 overflow-y-auto px-2 py-3`,children:[n(`div`,{className:`space-y-2`,children:[n(`div`,{className:`flex items-start justify-between gap-3`,children:[n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`text-sm font-medium text-foreground`,children:u(`agent.taskProgress`)}),t(`div`,{className:`text-xs text-muted`,children:u(`agent.tasksCompleted`,{completed:m,total:f})})]}),s.length>1&&n(`div`,{className:`flex shrink-0 items-center gap-1 text-xs text-muted`,children:[t(o,{variant:`ghost`,size:`icon`,className:`size-7`,onClick:()=>l(Math.min(s.length-1,c+1)),disabled:c>=s.length-1,"aria-label":u(`agent.olderPlan`),title:u(`agent.olderPlan`),children:t(oh,{className:`size-4`,"aria-hidden":`true`})}),n(`div`,{className:`min-w-20 text-center`,children:[n(`div`,{className:`font-medium text-foreground`,children:[g,`/`,s.length]}),t(`div`,{className:`truncate`,children:_?new Date(_).toLocaleTimeString():u(`agent.unknownTime`)})]}),t(o,{variant:`ghost`,size:`icon`,className:`size-7`,onClick:()=>l(Math.max(0,c-1)),disabled:c<=0,"aria-label":u(`agent.newerPlan`),title:u(`agent.newerPlan`),children:t(lh,{className:`size-4`,"aria-hidden":`true`})})]})]}),t(`div`,{className:`h-2 overflow-hidden rounded-full bg-mixer-muted/20`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":f,"aria-valuenow":m,"aria-label":u(`agent.taskProgress`),children:t(`div`,{className:`h-full rounded-full bg-success transition-all duration-300`,style:{width:`${h}%`}})})]}),t(`ol`,{className:`divide-y divide-border/60`,children:d.map((e,i)=>{let a=e.id?e.id.toString():`task-${i}`,o=e.goal||`Task ${i+1}`,s=e.id?`task-${e.id.toString()}`:`task-${o}-${e.status||`pending`}`,c=e.status||`pending`,l=r.get(a);l!==void 0&&(c=l);let d=Jh,f=`text-muted`;c===`in_progress`?(d=rg,f=`text-info`):c===`completed`&&(d=Nh,f=`text-success`);let p=u(c===`completed`?`agent.completed`:c===`in_progress`?`agent.inProgress`:`agent.pending`);return n(`li`,{className:`grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-3 px-1 py-3`,children:[t(`span`,{className:`mt-0.5 min-w-5 text-center text-xs font-medium tabular-nums text-muted/80`,children:a}),t(`span`,{className:`min-w-0 text-sm leading-5 text-foreground/85`,children:o}),n(`span`,{className:z(`flex items-center gap-1.5 text-xs font-medium`,f),children:[t(d,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t(`span`,{children:p})]})]},s)})}),(()=>{let e=new Set(d.filter(e=>e?.id).map(e=>e.id.toString())),i=Array.from(r.entries()).filter(([t])=>t!==`main`&&!e.has(t));return i.length>0?n(`div`,{className:`mt-1 px-1 py-2`,children:[t(`div`,{className:`mb-2 text-xs font-medium text-muted`,children:u(`agent.workstreams`)}),t(`div`,{className:`divide-y divide-border/60`,children:i.map(([e,r])=>{let i=Jh,a=`text-muted`,o=u(`agent.pending`);return r===`in_progress`?(i=rg,a=`text-info`,o=u(`agent.inProgress`)):r===`completed`&&(i=Nh,a=`text-success`,o=u(`agent.completed`)),n(`div`,{className:`flex items-center gap-2 py-2`,children:[t(i,{className:z(`size-3.5 shrink-0`,a)}),t(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium text-foreground/80`,children:e}),t(`span`,{className:`text-xs font-medium text-muted`,children:o})]},e)})})]}):null})()]})})}const xX=ot.memo(bX);Q();function SX({icon:e,children:r}){return n(p,{className:`h-full min-h-[240px] flex-col text-center text-muted`,children:[e,t(`span`,{className:`text-sm`,children:r})]})}function CX({files:e}){let{t:r}=K(),a=U(()=>e?Array.from(e.values()):[],[e]),o=e=>{switch(e){case pn.UPLOADING:case pn.PROCESSING:return t(ev,{className:`size-4 animate-spin text-info`});case pn.READY:return t(Nh,{className:`size-4 text-success`});case pn.ERROR:return t(Gh,{className:`size-4 text-destructive`});default:return t(Gg,{className:`size-4 text-muted`})}},s=e=>{switch(e){case pn.UPLOADING:return t(i,{variant:`info`,children:r(`agent.uploading`)});case pn.PROCESSING:return t(i,{variant:`info`,children:r(`agent.processing`)});case pn.READY:return t(i,{variant:`success`,children:r(`agent.ready`)});case pn.ERROR:return t(i,{variant:`destructive`,children:r(`agent.error`)});default:return null}};return t(`div`,{className:`h-full min-h-0`,children:a.length===0?t(SX,{icon:t(Gg,{className:`mb-2 size-8`}),children:r(`agent.noFilesUploadedYet`)}):t(`div`,{className:`space-y-2 p-2`,children:a.map(e=>n(`div`,{className:`flex items-start gap-2 p-2 border border-muted rounded-md`,children:[t(`div`,{className:`mt-0.5`,children:o(e.status)}),n(`div`,{className:`flex-1 min-w-0`,children:[n(`div`,{className:`flex items-center justify-between gap-2`,children:[t(`span`,{className:`text-sm font-medium truncate`,children:e.name}),s(e.status)]}),e.error&&t(`div`,{className:`text-xs text-destructive mt-1`,children:e.error})]})]},e.id))})})}var wX=class extends ot.Component{state={hasError:!1};static getDerivedStateFromError(e){return{hasError:!0,message:e instanceof Error?e.message:String(e)}}componentDidCatch(e,t){console.error(`Agent right panel section failed to render`,{error:e,componentStack:t.componentStack})}render(){return this.state.hasError?n(`div`,{className:z(`rounded-md border border-destructive bg-mixer-destructive/10 text-destructive`,this.props.compact?`p-2 text-xs`:`m-3 p-3 text-sm`),children:[t(`div`,{className:`font-medium`,children:this.props.title}),t(`div`,{className:`mt-1 text-xs text-muted`,children:this.props.description}),this.state.message&&t(`div`,{className:`mt-1 break-all text-[11px] text-muted`,children:this.state.message})]}):this.props.children}};function TX({workstreams:e,messages:r,runId:a}){let{t:s}=K(),{client:c}=q(),l=nt(),u=U(()=>fX(r),[r]),d=s(`agent.panelRenderErrorDescription`),f=V(e=>{navigator.clipboard.writeText(e),l({status:`success`,title:s(`agent.runIdCopied`),duration:2e3})},[s,l]),p=V(async e=>{try{let t=await rU(c,e);t&&window.open(t,`_blank`)}catch{l({status:`error`,title:s(`agent.failedToDownload`)})}},[c,s,l]);return e.length===0?t(SX,{icon:t(z_,{className:`mb-2 size-8`}),children:s(`agent.noActiveParallelTasks`)}):n(`div`,{className:`h-full min-h-0 overflow-y-auto px-2 py-2`,children:[t(`div`,{className:`px-1 pb-2 text-xs text-muted`,children:s(`agent.parallelWorkDescription`)}),t(`div`,{className:`divide-y divide-border/60`,children:e.map(e=>{let r=e.status===`running`||e.status===`canceling`,c=Math.round(e.elapsed_ms/1e3),l=Math.max(0,Math.round(e.remaining_ms/1e3)),m=e.deadline_ms>0?Math.min(100,Math.round(e.elapsed_ms/e.deadline_ms*100)):0,h=u.get(e.workstream_id),g=e.deadline_ms>0,_=e.child_workflow_run_id,v=[e.phase?MH(e.phase):void 0,c>0?s(`agent.elapsed`,{seconds:c}):void 0,g&&l>0?s(`agent.remaining`,{seconds:l}):void 0].filter(Boolean),y=(()=>{switch(e.status){case`running`:return t(i,{variant:`info`,children:s(`agent.running`)});case`canceling`:return t(i,{variant:`attention`,children:s(`agent.canceling`)});case`completed`:return t(i,{variant:`done`,children:s(`agent.completed`)});case`failed`:return t(i,{variant:`destructive`,children:s(`agent.failed`)});case`timeout`:return t(i,{variant:`destructive`,children:s(`agent.timeout`)});case`canceled`:return t(i,{variant:`destructive`,children:s(`agent.canceled`)})}})();return t(wX,{title:s(`agent.workstreamRenderError`),description:d,compact:!0,children:t(`div`,{className:`py-3`,children:n(`div`,{className:`flex items-start gap-2`,children:[t(`span`,{className:z(`mt-2 size-2 shrink-0 rounded-full`,BH(e.status)),"aria-hidden":`true`}),n(`div`,{className:`min-w-0 flex-1`,children:[n(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[t(`span`,{className:`min-w-0 truncate text-sm font-medium text-foreground`,title:e.workstream_id,children:MH(e.workstream_id)}),y]}),v.length>0&&t(`div`,{className:`mt-0.5 truncate text-xs text-muted`,children:v.join(` · `)}),r&&g&&t(`div`,{className:`mt-2 h-1 rounded-full bg-muted`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":m,"aria-valuetext":s(`agent.workstreamProgress`,{percent:m}),children:t(`div`,{className:`h-full rounded-full bg-info transition-all duration-500`,style:{width:`${m}%`}})}),h&&t(wX,{title:s(`agent.browserWidgetRenderError`),description:d,compact:!0,children:t(hX,{state:h,runId:a,compact:!0,className:`mt-2`})}),_&&n(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n(o,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs text-muted hover:text-foreground`,onClick:()=>f(_),children:[t(Zh,{className:`size-3 me-1`}),s(`agent.copyRunId`)]}),n(o,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs text-muted hover:text-foreground`,onClick:()=>p(_),children:[t(og,{className:`size-3 me-1`}),s(`agent.download`)]})]})]})]})})},e.launch_id)})})]})}function EX({plan:e,workstreamStatus:r,plans:i=[],activePlanIndex:a=0,onChangePlan:s,activeWorkstreams:c=[],messages:l=[],hideWorkstreams:u=!1,openDocuments:d=[],activeDocumentId:f,onSelectDocument:p,onUpdateDocumentTitle:m,docRefreshKey:h=0,runId:g,processingFiles:_,showArtifacts:v=!1,artifactRefreshKey:y=0,artifactRefreshDetails:b,selectedArtifactPath:x,onSelectedArtifactPathChange:S,onSendMessage:C,payloadContent:w,conversationContent:T,onClose:E,defaultTab:D,activeTab:O,onTabChange:k}){let{t:A}=K(),[j,M]=G(D||`plan`),N=O??j,P=e=>{M(e),k?.(e)},F=!u&&c.length>0,I=d.length>0,L=_?_.size>0:!1,ee=V((e,n)=>t(wX,{title:A(`agent.panelRenderError`,{name:e}),description:A(`agent.panelRenderErrorDescription`),children:n}),[A]),R={name:`conversation`,label:`Conversation`,content:T?ee(`Conversation`,t(`div`,{className:`flex flex-col h-full min-h-0`,children:T})):null,is_allowed:!!T},te=[...T?[R]:[],{name:`plan`,label:A(`agent.plan`),content:ee(A(`agent.plan`),e?t(xX,{plan:e,workstreamStatus:r||new Map,isOpen:!0,onClose:E,plans:i,activePlanIndex:a,onChangePlan:s}):t(SX,{icon:t(z_,{className:`mb-2 size-8`}),children:A(`agent.noPlanAvailable`)})),is_allowed:!0},{name:`workstreams`,label:F?n(`span`,{className:`inline-flex min-w-0 items-center gap-1 whitespace-nowrap`,children:[A(`agent.workstreams`),` `,t(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-full bg-info px-1.5 py-0.5 text-[10px] text-info`,children:c.length})]}):A(`agent.workstreams`),content:ee(A(`agent.workstreams`),t(TX,{workstreams:c,messages:l,runId:g})),is_allowed:!u},{name:`documents`,label:I?n(`span`,{className:`inline-flex min-w-0 items-center gap-1 whitespace-nowrap`,children:[A(`agent.documents`),` `,t(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-full bg-info px-1.5 py-0.5 text-[10px] text-info`,children:d.length})]}):A(`agent.documents`),content:ee(A(`agent.documents`),d.length>0&&p?t(yX,{documents:d,activeDocumentId:f??null,onSelectDocument:p,onUpdateDocumentTitle:m,refreshKey:h,runId:g}):t(SX,{icon:t(Gg,{className:`mb-2 size-8`}),children:A(`agent.noDocumentsOpen`)})),is_allowed:!0},{name:`uploads`,label:L?n(`span`,{className:`inline-flex min-w-0 items-center gap-1 whitespace-nowrap`,children:[A(`agent.uploads`),` `,t(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-info`})]}):A(`agent.uploads`),content:ee(A(`agent.uploads`),t(CX,{files:_})),is_allowed:!0},{name:`artifacts`,label:A(`agent.artifacts`),content:ee(A(`agent.artifacts`),t(lX,{runId:g,refreshKey:y,refreshDetails:b,selectedPath:x,onSelectedPathChange:S,onSendMessage:C})),is_allowed:v},{name:`payload`,label:A(`agent.payload`),content:w?ee(A(`agent.payload`),t(`div`,{className:`overflow-y-auto`,children:w})):null,is_allowed:!!w}],ne=te.filter(e=>e.is_allowed===void 0||e.is_allowed===!0);return n(ze,{tabs:te,current:N,onTabChange:P,fullHeight:!0,className:`px-0`,children:[n(`div`,{className:`flex items-end justify-between shrink-0 px-1 py-1 gap-1`,children:[t(pe,{tabs:ne,current:N,onTabChange:P,className:`min-w-0 flex-1`}),!T&&t(o,{variant:`ghost`,size:`sm`,className:`shrink-0 ms-1`,onClick:E,title:`Close Right Panel`,children:t(Gb,{className:`size-4`})})]}),t(Ve,{className:`flex-1 min-h-0 pt-0 pb-0`})]})}const DX=ot.memo(EX);function OX(e){if(!e)return[];let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r.kind!==`file`)continue;let i=r.getAsFile();if(i){if(r.type.startsWith(`image/`)&&(!i.name||i.name===`image.png`)){let e=r.type.split(`/`)[1]||`png`;t.push(new File([i],`pasted-image-${Date.now()}.${e}`,{type:i.type}))}else t.push(i)}}return t}function kX(e,t,n=!1){let[r,i]=G([]),[a,o]=G(0),[s,c]=G(new Map),[l,u]=G(t),[d,f]=G(!n),p=W(-1),m=W(new Set);H(()=>{e.length===0&&(i([]),o(0),c(new Map),f(!n),p.current=-1,m.current.clear())},[e.length,n]);let h=V(e=>{let n=e[e.length-1];n&&(n.type===J.TERMINATED?u(!1):u(t?!0:n.type===J.REQUEST_INPUT))},[t]);return H(()=>{if(e.length===0)return;let t=p.current+1;if(t>=e.length){h(e);return}let n=!1,r=[],a=[];for(let i=t;i<e.length;i++){let t=e[i];if(t.type===J.PLAN)try{let e=null;if(t.details&&typeof t.details==`object`&&t.details.plan&&Array.isArray(t.details.plan)&&(e={plan:t.details.plan}),e){let i=typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime();if(!m.current.has(i)){m.current.add(i),n=!0,r.push({plan:e,timestamp:i});let t=new Map;t.set(`main`,`in_progress`),Array.isArray(e.plan)&&e.plan.forEach(e=>{if(e&&typeof e==`object`&&e.id){let n=e.id.toString();t.set(n,e.status||`pending`)}}),a.push({timestamp:i,statusMap:t})}}}catch(e){console.error(`Failed to parse plan from message:`,e)}}p.current=e.length-1,n&&r.length>0&&(i(e=>[...[...r].reverse(),...e]),o(0),f(!0),a.length>0&&c(e=>{let t=new Map(e);for(let e of a)t.set(e.timestamp,e.statusMap);return t})),h(e)},[e,h]),H(()=>{if(r.length===1&&!d&&!sessionStorage.getItem(`plan-panel-shown`)){let e=setTimeout(()=>{f(!0),sessionStorage.setItem(`plan-panel-shown`,`true`)},500);return()=>clearTimeout(e)}},[r.length,d]),{plans:r,activePlanIndex:a,setActivePlanIndex:o,workstreamStatusMap:s,showInput:l,showSlidingPanel:d,setShowSlidingPanel:f}}function AX(e,t){return{...e,details:{...e.details??{},_deliveryStatus:t}}}function jX(e){let t=e.details,n=t?._messageId;if(typeof n==`string`&&n)return n;let r=t?.ack;return typeof r==`string`&&r?r:void 0}function MX(e,t){let n=e?.[t];return typeof n==`string`&&n?n:void 0}function NX(e){return e?.streaming_id_scope===`workflow_run`}function PX(e){return[J.COMPLETE,J.IDLE,J.TERMINATED,J.REQUEST_INPUT].includes(e.type)}function FX(e){if(e.type===J.STREAMING_CHUNK)return!1;if(e.type===J.UPDATE&&typeof e.details?.event_class==`string`)return!0;if(e.type===J.SYSTEM){let t=e.details;if(t?.system_type===`file_processing`&&t.files)return!1}return!!e.message||PX(e)||Dn(e).length>0}function IX(e){if(e)return{type:e.type,timestamp:e.timestamp,workstream_id:e.workstream_id,text:typeof e.message==`string`?e.message.slice(0,80):e.message?`[non-string]`:``,display_role:e.details?.display_role,source:e.details?.source}}function LX(e,t){if(e.find(e=>e.timestamp===t.timestamp))return e;if(!t.details?._optimistic&&(t.type===J.QUESTION||ZH(t))){let n=typeof t.details?.ack==`string`?t.details.ack:void 0,r=n?AX(t,`consumed`):t;if(n){let i=e.filter(e=>!((e.type===t.type||ZH(e))&&e.details?._optimistic&&jX(e)===n));return qH(i,r),i}if(t.type===J.QUESTION){let n=e.filter(e=>e.type===J.QUESTION&&e.details?._optimistic&&e.message===t.message&&(e.workstream_id??`main`)===(t.workstream_id??`main`));if(n.length===1){let r=e.filter(e=>e!==n[0]);return qH(r,t),r}}}let n=[...e];return qH(n,t),n}function RX(e){let t=e.details,n=MX(t,`streaming_id`),r=MX(t,`activity_id`);return n&&NX(t)?n:r??n}function zX(e){let t=e.details,n=MX(t,`streaming_id`),r=MX(t,`activity_id`),i=[];return n&&NX(t)&&i.push(n),r&&i.push(r),[...new Set(i)]}function BX(e,t,n){let[r,i]=G([]),[a,o]=G(!1),[s,c]=G(`loading`),[l,u]=G(null),[d,f]=G(null),p=W(n);p.current=n;let[m,h]=G(new Map),[g,_]=G(0),v=V(()=>_(e=>e+1),[]),y=W(null),b=W(0),[x,S]=G(new Map),C=W(new Map),w=W(null),[T,E]=G(!1),D=W(null),O=V(()=>{let e=w.current;e&&(e.mode===`raf`?cancelAnimationFrame(e.id):clearTimeout(e.id),w.current=null)},[]),k=V(()=>{C.current.size>0&&(S(new Map(C.current)),E(!0),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>E(!1),50)),w.current=null},[]);return H(()=>{o(!XH(r))},[r]),H(()=>{KH(`stream state`,{agentRunId:t,messageCount:r.length,streamingCount:x.size,initialHistoryStatus:s,isCompleted:a,lastDeliveredTs:b.current,first:IX(r[0]),last:IX(r[r.length-1])})},[t,s,a,r,x.size]),H(()=>{let n=y.current!==t;y.current=t,n&&(i([]),c(`loading`),u(null),f(null),S(new Map),h(new Map),b.current=0);let r=new AbortController,a=n?void 0:b.current||void 0;return KH(`stream start`,{agentRunId:t,isNewConversation:n,since:a,streamNonce:g}),e.agents.getInternals(t).then(e=>{r.signal.aborted||(KH(`internals loaded`,{agentRunId:t,status:e.status,first_workflow_run_id:e.first_workflow_run_id}),u(e.status?.toUpperCase()??null),f(e.first_workflow_run_id??null))}).catch(e=>{r.signal.aborted||console.error(`Failed to check agent run status:`,e)}),e.agents.streamMessages(t,e=>{if(r.signal.aborted)return;let n=!!(e.timestamp&&e.timestamp<=b.current);if(n||p.current?.(e),KH(`stream message`,{agentRunId:t,type:e.type,timestamp:e.timestamp,workstream_id:e.workstream_id,hasMessage:!!e.message,display_role:e.details?.display_role,source:e.details?.source}),e.timestamp&&e.timestamp>b.current&&(b.current=e.timestamp),e.type===J.STREAMING_CHUNK){let t=e.details,n=RX(e);if(!n)return;let r=C.current.get(n)||{text:``,workstreamId:e.workstream_id,startTimestamp:Date.now(),activityId:t?.activity_id,streamingId:t?.streaming_id},i=r.text+(e.message||``);C.current.set(n,{text:i,workstreamId:e.workstream_id,isComplete:t.is_final,startTimestamp:r.startTimestamp,activityId:t?.activity_id,streamingId:t?.streaming_id}),w.current===null&&(document.hidden?w.current={mode:`timeout`,id:window.setTimeout(k,16)}:w.current={mode:`raf`,id:requestAnimationFrame(k)});return}if(e.type===J.SYSTEM){let t=e.details;if(t?.system_type===`file_processing`&&t.files){n||h(new Map(t.files.map(e=>[e.id,e])));return}}if(e.type===J.THOUGHT||e.type===J.ANSWER){let t=zX(e);if(t.length>0){for(let e of t)C.current.delete(e);S(e=>{let n=new Map(e),r=!1;for(let e of t)r=n.delete(e)||r;return r?n:e})}}(e.type===J.COMPLETE||e.type===J.IDLE)&&C.current.size>0&&k(),FX(e)&&i(t=>LX(t,e))},a,r.signal,{closeOnIdle:!1,onHistoryLoaded:e=>{if(r.signal.aborted)return;let n=e.filter(FX),o,s=-1/0;for(let t of e)if(t.timestamp&&t.timestamp>b.current&&(b.current=t.timestamp),t.type===J.SYSTEM){let e=t.details;if(e?.system_type===`file_processing`&&e.files){let n=t.timestamp??-1/0;(!o||n>=s)&&(o=e,s=n)}}o&&h(new Map(o.files.map(e=>[e.id,e]))),KH(`history loaded`,{agentRunId:t,count:e.length,timelineCount:n.length,since:a,first:IX(e[0]),last:IX(e[e.length-1])}),c(e.length>0?`has_messages`:`empty`),n.length>0&&i(e=>n.reduce((e,t)=>LX(e,t),e))},onHistoryError:e=>{r.signal.aborted||(KH(`history error`,{agentRunId:t,error:e instanceof Error?e.message:String(e)}),c(`error`))}}).then(()=>{if(!r.signal.aborted)return KH(`stream resolved`,{agentRunId:t}),e.agents.getInternals(t).then(e=>{r.signal.aborted||(KH(`internals refreshed after stream end`,{agentRunId:t,status:e.status}),u(e.status?.toUpperCase()??null))}).catch(e=>{r.signal.aborted||console.error(`Failed to refresh agent run status on stream end:`,e)})}).catch(e=>{r.signal.aborted||(KH(`stream failed`,{agentRunId:t,error:e instanceof Error?e.message:String(e)}),console.error(`Failed to stream agent messages:`,e))}),()=>{KH(`stream cleanup`,{agentRunId:t,streamNonce:g}),r.abort(),O(),C.current.clear(),D.current&&=(clearTimeout(D.current),null)}},[t,g,e.agents,k,O]),H(()=>{let e=()=>{!document.hidden&&C.current.size>0&&(O(),k())};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e)}},[k,O]),{messages:r,streamingMessages:x,isCompleted:a,initialHistoryStatus:s,debugChunkFlash:T,addOptimisticMessage:V(e=>{i(t=>{let n=[...t,e];return n.sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())),n})},[]),updateOptimisticMessageStatus:V((e,t)=>{i(n=>n.map(n=>n.details?._optimistic&&jX(n)===e?AX(n,t):n))},[]),removeOptimisticMessages:V(e=>{i(t=>t.filter(t=>!e(t)))},[]),reconnect:v,agentRunStatus:l,workflowRunId:d,serverFileUpdates:m}}function VX(e){if(typeof e==`string`&&e.trim().length>0)return e}function HX(e,t){let n=VX(e.revision_root_id)||VX(e.revision_root)||VX(e.root_document_id)||VX(e.root_id);if(n)return n;let r=e.revision_info;if(r&&typeof r==`object`){let e=VX(r.root);if(e)return e}return t}function UX(e,t){return e.revisionRootId&&t.revisionRootId?e.revisionRootId===t.revisionRootId:t.revisionRootId?e.id===t.revisionRootId:e.revisionRootId?e.revisionRootId===t.id:e.id===t.id}function WX(e){let[t,n]=G([]),[r,i]=G(null),[a,o]=G(!1),[s,c]=G(0),l=W(-1);return H(()=>{e.length===0&&(n([]),i(null),o(!1),c(0),l.current=-1)},[e.length]),H(()=>{let t=l.current+1;if(!(t>=e.length)){for(let r=t;r<e.length;r++){let t=e[r];if(t.type===J.UPDATE&&t.details){let e=t.details;if(e.event_class===`document_created`||e.event_class===`document_updated`){let t=VX(e.document_id),r=VX(e.updated_document_id)||t,a=e.title;if(r){let s=HX(e,t||r),l={id:r,title:a||`Document`,revisionRootId:s};n(e=>{let t=e.findIndex(e=>UX(e,l));if(t<0)return[...e,l];let n=e[t];if(n.id===l.id&&n.title===l.title&&n.revisionRootId===l.revisionRootId)return e;let r=[...e];return r[t]=l,r}),i(l.id),o(!0),e.event_class===`document_updated`&&c(e=>e+1)}}}}l.current=e.length-1}},[e]),{openDocuments:t,activeDocumentId:r,isDocPanelOpen:a,docRefreshKey:s,closeDocPanel:V(()=>{o(!1)},[]),selectDocument:V(e=>{i(e)},[]),openDocInPanel:V(e=>{n(t=>t.some(t=>t.id===e)?t:[...t,{id:e,title:`Document`,revisionRootId:e}]),i(e),o(!0)},[]),updateDocumentTitle:V((e,t)=>{n(n=>n.map(n=>n.id===e?{...n,title:t}:n))},[])}}function GX(e){return e.type.startsWith(`image/`)}function KX(e){if(!(!GX(e)||typeof URL>`u`||!URL.createObjectURL))return URL.createObjectURL(e)}function qX(e){typeof URL<`u`&&URL.revokeObjectURL&&URL.revokeObjectURL(e)}function JX(e,t,n,r,i){let a=Xt.getFixedT(null,Yt),[o,s]=G(new Map),[c,l]=G(new Set),u=W(new Set),d=W(new Map),f=W(t),p=W(o);p.current=o;let m=W(n);m.current=n;let h=V(e=>{let t=d.current.get(e);t&&(qX(t),d.current.delete(e))},[]);H(()=>{if(f.current!==t){f.current=t,d.current.forEach(qX),d.current.clear(),s(new Map);let e=new Set;u.current=e,l(e)}},[t]),H(()=>()=>{d.current.forEach(qX),d.current.clear()},[]);let g=U(()=>{let e=new Map;if(o.forEach((t,n)=>{c.has(n)||e.set(n,t)}),n.forEach((t,n)=>{if(t.consumed_at){e.delete(n);return}if(!c.has(n)){let r=o.get(n);e.set(n,{...t,artifact_path:t.artifact_path??r?.artifact_path,reference:t.reference??r?.reference,...r?.preview_url?{preview_url:r.preview_url}:{}})}}),i&&i.size>0)for(let[t,n]of e)(n.reference&&i.has(n.reference)||n.artifact_path&&i.has(n.artifact_path))&&e.delete(t);return e},[o,c,n,i]);return{processingFiles:g,hasProcessingFiles:U(()=>Array.from(g.values()).some(e=>e.status===pn.UPLOADING||e.status===pn.PROCESSING),[g]),handleFileUpload:V(async n=>{for(let i of n){let n=`file-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,o=`files/${i.name}`,c=KX(i);c&&d.current.set(n,c);let l={id:n,name:i.name,content_type:i.type||`application/octet-stream`,size:i.size,status:pn.UPLOADING,started_at:Date.now(),preview_url:c};s(e=>new Map(e).set(n,l));try{if(await e.agents.uploadArtifact(t,o,i),s(e=>{let t=new Map(e),r=t.get(n);return r&&(r.status=pn.PROCESSING,r.artifact_path=o,r.reference=`artifact:${o}`),t}),u.current.has(n))continue;await e.agents.sendSignal(t,`FileUploaded`,{id:n,name:i.name,content_type:i.type||`application/octet-stream`,reference:`artifact:${o}`,artifact_path:o})}catch(e){if(u.current.has(n))continue;s(t=>{let r=new Map(t),i=r.get(n);return i&&(i.status=pn.ERROR,i.error=e instanceof Error?e.message:`Upload failed`,i.completed_at=Date.now()),r}),r({status:`error`,title:a(`agent.uploadFailed`),description:e instanceof Error?e.message:`Failed to upload file`,duration:3e3})}}},[e,t,r,a]),removeProcessingFile:V(async n=>{l(e=>{if(e.has(n))return e;let t=new Set(e);return t.add(n),u.current=t,t}),s(e=>{if(!e.has(n))return e;let t=new Map(e);return t.delete(n),t}),h(n);try{await e.agents.sendSignal(t,`FileRemoved`,{id:n})}catch(e){r({status:`error`,title:a(`agent.removeFileFailed`),description:e instanceof Error?e.message:`Failed to remove file`,duration:3e3})}},[t,e,h,a,r]),clearProcessingFiles:V(()=>{d.current.forEach(qX),d.current.clear(),l(e=>{let t=new Set(e);for(let e of m.current.keys())t.add(e);for(let e of p.current.keys())t.add(e);return u.current=t,t}),s(new Map)},[])}}Q();function YX({activeWorkstreams:r,onSelectWorkstream:i,className:a}){let{t:s}=K(),[c,l]=G(!1),[u,d]=G(!1),f=vt(),p=U(()=>r.filter(e=>e.status===`running`||e.status===`canceling`),[r]),m=c?p:p.slice(0,3),h=Math.max(0,p.length-m.length),g=p.length>3;return H(()=>{g||l(!1)},[g]),p.length===0?null:t(`div`,{className:z(`mx-auto mb-2 w-full max-w-3xl px-1`,a),"data-agent-active-workstreams":!0,children:n(`output`,{className:`flex flex-col gap-1.5 rounded-2xl border border-border/70 bg-background/95 p-2 text-xs text-muted shadow-lg shadow-black/5`,"aria-live":`polite`,children:[n(`div`,{className:`flex items-center justify-between gap-2`,children:[n(`div`,{className:`flex min-w-0 items-center gap-2 px-1 font-medium`,children:[t(Am,{className:`size-3.5 shrink-0 text-muted`,"aria-hidden":`true`}),t(`span`,{className:`truncate`,children:s(`agent.activeWorkstreams`,{count:p.length})})]}),n(o,{variant:`ghost`,size:`icon`,onClick:()=>d(!u),title:s(u?`agent.showActiveWorkstreams`:`agent.hideActiveWorkstreams`),children:[t(u?fh:rh,{className:`size-4`}),s(u?`agent.showActiveWorkstreams`:`agent.hideActiveWorkstreams`)]})]}),u?null:n(e,{children:[t(`div`,{id:f,className:`flex flex-col gap-0.5`,children:m.map(r=>{let a=PH(r.workstream_id,r.interaction),s=n(e,{children:[t(`span`,{className:z(`size-1.5 shrink-0 rounded-full`,BH(r.status)),"aria-hidden":`true`}),t(`span`,{className:`truncate font-medium`,children:a}),r.phase&&t(`span`,{className:`truncate text-xs text-muted/75`,children:MH(r.phase)})]});return i?n(o,{type:`button`,variant:`ghost`,className:`h-auto min-w-0 justify-start gap-2 rounded-lg px-1 py-1 text-sm text-foreground/80`,title:a,onClick:()=>{l(!1),i(r.workstream_id)},children:[s,t(lh,{className:`ms-auto size-3.5 shrink-0 rtl:rotate-180`,"aria-hidden":`true`})]},r.launch_id||r.workstream_id):t(`div`,{className:`flex min-w-0 items-center gap-2 rounded-lg px-1 py-1 text-sm text-foreground/80`,title:a,children:s},r.launch_id||r.workstream_id)})}),g&&n(o,{type:`button`,variant:`ghost`,size:`sm`,className:`h-8 w-fit shrink-0 gap-1 rounded-xl px-2.5 text-xs text-muted`,"aria-expanded":c,"aria-controls":f,onClick:()=>l(e=>!e),children:[!c&&n(`span`,{children:[`+`,h]}),s(c?`agent.showLess`:`agent.showMore`),t(rh,{className:z(`size-3.5 transition-transform`,c&&`rotate-180`),"aria-hidden":`true`})]})]})]})})}const XX=new er({strict:!1,validateFormats:!1});function ZX(e){if(e!==wn.virtual_lb&&e!==wn.virtual_mediator&&e!==wn.test)return e}var QX=class{_listeners=new Set;snapshot;constructor(e){this.snapshot=new $X(e,this)}subscribe=e=>(this._listeners.add(e),()=>{this._listeners.delete(e)});getSnapshot=()=>this.snapshot;notify(){this._listeners.forEach(e=>{e()})}},$X=class e{vertesia;_interactive=!0;_debug_mode=!1;_non_blocking_subagents=!0;_checkpoint_tokens;_visibility;_user_channels;_collection;_disabled_mcp_collections;_start=!1;_preserveRunValues=!1;_interaction;_environment;_model=``;_model_options;_tool_names=[];_data;_mode=`start`;_scheduledWorkflowConfig;_interactionParamsSchema;_schemaVersion=0;_inputValidator;_store;constructor(e,t){this.vertesia=e,this._store=t}onStateChanged(){let e=this.clone();this._store.snapshot=e,this._store.notify()}clone(){let t=new e(this.vertesia,this._store);return t._interactionParamsSchema=this._interactionParamsSchema,t._schemaVersion=this._schemaVersion,t._interaction=this._interaction,t._data=this._data,t._environment=this._environment,t._model=this._model,t._model_options=this._model_options?{...this._model_options}:void 0,t._tool_names=[...this._tool_names],t._interactive=this._interactive,t._debug_mode=this._debug_mode,t._non_blocking_subagents=this._non_blocking_subagents,t._checkpoint_tokens=this._checkpoint_tokens,t._visibility=this._visibility,t._user_channels=this._user_channels?[...this._user_channels]:void 0,t._inputValidator=this._inputValidator,t._start=this._start,t._collection=this._collection,t._disabled_mcp_collections=this._disabled_mcp_collections?[...this._disabled_mcp_collections]:void 0,t._preserveRunValues=this._preserveRunValues,t._mode=this._mode,t._scheduledWorkflowConfig=this._scheduledWorkflowConfig,t}set mode(e){e!==this._mode&&(this._mode=e,e===`schedule`&&!this._scheduledWorkflowConfig&&(this._scheduledWorkflowConfig={name:``,description:``,cron_expression:`0 9 * * *`,timezone:`UTC`}),this.onStateChanged())}get mode(){return this._mode}set scheduledWorkflowConfig(e){this._scheduledWorkflowConfig=e,this.onStateChanged()}get scheduledWorkflowConfig(){return this._scheduledWorkflowConfig}updateScheduledWorkflowConfig(e){this._scheduledWorkflowConfig={...this._scheduledWorkflowConfig,...e},this.onStateChanged()}get interactive(){return this._interactive}set interactive(e){e!==this._interactive&&(this._interactive=e,this.onStateChanged())}get debug_mode(){return this._debug_mode}set debug_mode(e){e!==this._debug_mode&&(this._debug_mode=e,this.onStateChanged())}get non_blocking_subagents(){return this._non_blocking_subagents}set non_blocking_subagents(e){e!==this._non_blocking_subagents&&(this._non_blocking_subagents=e,this.onStateChanged())}get checkpoint_tokens(){return this._checkpoint_tokens}set checkpoint_tokens(e){e!==this._checkpoint_tokens&&(this._checkpoint_tokens=e,this.onStateChanged())}get visibility(){return this._visibility}set visibility(e){e!==this._visibility&&(this._visibility=e,this.onStateChanged())}get user_channels(){return this._user_channels}set user_channels(e){this._user_channels=e,this.onStateChanged()}get collection(){return this._collection}set collection(e){e!==this._collection&&(this._collection=e,this.onStateChanged())}get disabled_mcp_collections(){return this._disabled_mcp_collections}set disabled_mcp_collections(e){this._disabled_mcp_collections=e&&e.length>0?e:void 0,this.onStateChanged()}get search_scope(){return this._collection?ln.Collection:void 0}async restoreConversation(e){let t=e.interaction;e.version&&(/^[a-fA-F0-9]{24}$/.test(t)||(t=`${t}@${e.version}`));let n=await this.vertesia.interactions.catalog.resolve(t),r=n.runtime?.environment||e.config?.environment,i=e.config?.model,a=await(r?this.vertesia.environments.retrieve(r).catch(()=>void 0):Promise.resolve(void 0));this._data=e.data,this.interaction=n,e.interactionParamsSchema!=null&&(this.interactionParamsSchema=e.interactionParamsSchema),this._tool_names=e.tool_names||[],this._interactive=e.interactive,this._debug_mode=e.debug_mode??!1,this._non_blocking_subagents=e.non_blocking_subagents??!0,this._checkpoint_tokens=e.checkpoint_tokens,this._user_channels=e.user_channels,this._disabled_mcp_collections=e.disabled_mcp_collections,this._model_options=e.config?.model_options,this.collection=e.collection_id??void 0,this._model_options=e.config?.model_options,this.environment=a,i&&(this._model=i),this.onStateChanged()}get interaction(){return this._interaction}set interaction(e){if(e?.id!==this._interaction?.id){if(this._interaction=e,this.interactionParamsSchema=e?On(e.prompts):void 0,this._inputValidator=void 0,e&&!this._preserveRunValues&&(this._model_options=e.model_options,e.runtime?.environment)){let t=e.runtime.environment;this.vertesia.environments.retrieve(t).then(e=>this.environment=e)}this.onStateChanged()}}get environment(){return this._environment}set environment(e){if(e?.id!==this._environment?.id){if(this._environment=e,!this._preserveRunValues){let t=e?ZX(e.provider):void 0,n=this.interaction?.runtime?.model;this._model=n&&t&&jn(n,t)?n:e?.default_model&&t&&jn(e.default_model,t)?e.default_model:``}this.onStateChanged()}}get model(){return this._model}set model(e){e!==this._model&&(this._model=e||``,this.onStateChanged())}get model_options(){return this._model_options}set model_options(e){JSON.stringify(e)!==JSON.stringify(this._model_options)&&(this._model_options=e,this.onStateChanged())}get tool_names(){return this._tool_names}set tool_names(e){this._tool_names=e,this.onStateChanged()}get data(){return this._data}set data(e){this._data=e,this.onStateChanged()}set run(e){console.log(`run`,e),this.onStateChanged()}set start(e){this._start!==e&&(this._start=e,this.onStateChanged())}markStarted(){this.start=!0}setMode(e){this.mode=e}setInteraction(e){this.interaction=e}setEnvironment(e){this.environment=e}setModel(e){this.model=e}setModelOptions(e){this.model_options=e}setToolNames(e){this.tool_names=e}setCollection(e){this.collection=e}setDisabledMcpCollections(e){this.disabled_mcp_collections=e}setInteractive(e){this.interactive=e}setDebugMode(e){this.debug_mode=e}setUserChannels(e){this.user_channels=e}setCheckpointTokens(e){this.checkpoint_tokens=e}setVisibility(e){this.visibility=e}setData(e){this.data=e}setDraftData(e){this._data=e}setPreserveRunValues(e){this.preserveRunValues=e}get start(){return this._start}get preserveRunValues(){return this._preserveRunValues}set preserveRunValues(e){this._preserveRunValues=e}get schemaVersion(){return this._schemaVersion}get interactionParamsSchema(){return this._interactionParamsSchema}set interactionParamsSchema(e){this._interactionParamsSchema!==e&&(this._interactionParamsSchema=e,this._schemaVersion+=1,e&&(this._data=this.initializeBooleanDefaults(this._data||{},e)),this.onStateChanged())}initializeBooleanDefaults(e,t){if(!t.properties)return e;let n={...e};for(let[e,r]of Object.entries(t.properties)){let t=r;t.type===`boolean`&&n[e]===void 0?n[e]=!1:t.type===`object`&&t.properties&&(n[e]=this.initializeBooleanDefaults(n[e]||{},t))}return n}reset(){if(this._start=!1,this._interactive=!0,this._debug_mode=!1,this._non_blocking_subagents=!0,this._checkpoint_tokens=void 0,this._visibility=void 0,this._user_channels=void 0,this._collection=void 0,this._disabled_mcp_collections=void 0,this._preserveRunValues=!1,this._model=``,this._model_options=void 0,this._environment=void 0,this._tool_names=[],this._interaction=void 0,this._data=void 0,this._interactionParamsSchema=null,this._inputValidator=void 0,this.model=void 0,this.environment=void 0,this.onStateChanged(),location.hash){let e=window.location.origin+window.location.pathname+window.location.search;history.replaceState(null,``,e),location.hash=``}}validateInput(){if(!this._interactionParamsSchema)return{isValid:!0};(!this._inputValidator||this._inputValidator.schema!==this._interactionParamsSchema)&&(this._inputValidator={validate:XX.compile(this._interactionParamsSchema),schema:this._interactionParamsSchema});let e=this._data||{};return this._inputValidator.validate(e)?{isValid:!0}:{isValid:!1,errorMessage:this._inputValidator.validate.errors?this._inputValidator.validate.errors.map(e=>`${e.instancePath}: ${e.message}`).join(`, `):`Invalid payload data`}}};const eZ=dt(void 0);function tZ({children:e}){let{client:n}=q(),[r]=G(()=>new QX(n)),i=xt(r.subscribe,r.getSnapshot);return t(eZ.Provider,{value:i,children:e})}function nZ(){let e=_t(eZ);if(!e)throw Error(`usePayloadBuilder must be used within a PayloadProvider`);return e}Q();function rZ(){let{router:e}=$n();return t=>{let n=t.startsWith(`/`)?e.getTopRouter().navigator.addStickyParams(t):t;return window.open(n,`_blank`,`noopener,noreferrer`),n}}function iZ({title:e,variant:r=`full`,isTerminal:i=!1,onClose:a,isModal:s,agentRunId:c,workflowRunId:l,viewMode:u,onViewModeChange:d,showPlanPanel:f,showPlanButton:p=!0,onTogglePlanPanel:m,showPlaybackButton:h=!1,isPlaybackEnabled:g=!1,onTogglePlayback:_,onDownload:v,onExportFixture:y,resetWorkflow:b,onExportPdf:x,onShowDetails:S,allowWorkflowControl:C=!0,onClone:w,isReceivingChunks:T=!1,className:E}){let{t:D}=K(),O=rZ(),k=r===`compact`,A=u===`sliding`?`stacked`:`sliding`,j=D(`agent.verbose`),M=D(`agent.summary`),N=A===`stacked`?j:M,P=n(`div`,{className:z(k?`flex flex-row items-center gap-1 lg:flex-col`:`flex justify-end items-center gap-2 ms-auto`),children:[p&&t(`div`,{className:`relative`,children:n(o,{size:r===`compact`?`icon`:`sm`,variant:f?`primary`:`ghost`,onClick:m,className:z(`transition-all duration-200 rounded-md`,r===`compact`&&`size-8 rounded-lg`),title:D(`agent.toggleRightSidebar`),children:[t(eg,{className:z(`size-4`,r===`full`&&`me-1.5`)}),r===`full`?t(`span`,{className:`font-medium text-xs`,children:D(f?`agent.hideSidebar`:`agent.showSidebar`)}):t(`span`,{className:`sr-only`,children:D(f?`agent.hideSidebar`:`agent.showSidebar`)})]})}),k?t(o,{variant:`ghost`,size:`icon`,onClick:()=>d(A),className:`size-8 rounded-lg`,title:N,"aria-label":N,children:t(A===`stacked`?xy:vv,{className:`size-4`})}):n(`div`,{className:`flex items-center gap-1 bg-muted rounded p-0.5 mt-2 lg:mt-0`,children:[n(o,{variant:u===`stacked`?`outline`:`ghost`,size:`xs`,onClick:()=>d(`stacked`),"aria-pressed":u===`stacked`,className:`gap-1.5`,children:[t(xy,{className:`size-3.5`}),j]}),n(o,{variant:u===`sliding`?`outline`:`ghost`,size:`xs`,onClick:()=>d(`sliding`),"aria-pressed":u===`sliding`,className:`gap-1.5`,children:[t(vv,{className:`size-3.5`}),M]})]}),h&&_&&n(o,{type:`button`,size:r===`compact`?`icon`:`sm`,variant:g?`primary`:`ghost`,onClick:_,"aria-pressed":g,title:D(`agent.rewind.label`),className:z(`transition-all duration-200 rounded-md`,r===`compact`&&`size-8 rounded-lg`),children:[t(Gm,{className:z(`size-4`,r===`full`&&`me-1.5`)}),r===`full`?t(`span`,{className:`font-medium text-xs`,children:D(`agent.rewind.label`)}):t(`span`,{className:`sr-only`,children:D(`agent.rewind.label`)})]}),c&&t(o,{type:`button`,size:k?`icon`:`xs`,variant:`ghost`,onClick:()=>O(`/store/agent-runner/${c}`),title:D(`agent.openInNewTab`),className:z(`transition-all duration-200 rounded-md`,k&&`size-8 rounded-lg`),children:t(Dg,{className:`size-4`})}),b&&t(o,{type:`button`,size:r===`compact`?`icon`:`sm`,variant:`ghost`,onClick:b,title:D(`agent.startNewConversation`),className:z(`transition-all duration-200 rounded-md`,r===`compact`&&`size-8 rounded-lg`),children:t(hv,{className:z(`size-4`,r===`full`&&`me-1.5`)})}),t(aZ,{compact:k,agentRunId:c,workflowRunId:l,isModal:s,isTerminal:i,onClose:a,onDownload:v,onExportFixture:y,resetWorkflow:b,onExportPdf:x,onShowDetails:S,allowWorkflowControl:C,onClone:w}),a&&!s&&t(o,{size:`xs`,variant:`ghost`,onClick:a,"aria-label":D(`agent.close`),children:t(Gb,{className:`size-4`})})]});return r===`compact`?t(tZ,{children:t(`div`,{className:z(`inline-flex items-center rounded-xl border border-border/70 bg-background/90 p-1 shadow-lg shadow-black/10 backdrop-blur`,E),children:P})}):t(tZ,{children:n(`div`,{className:z(`flex flex-wrap items-center justify-between py-1.5 px-2 border-b shadow-sm flex-shrink-0`,E),children:[n(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n(`div`,{className:`flex items-center gap-1`,children:[t(Am,{className:`size-5 text-muted`}),t(`span`,{className:`font-medium`,children:e})]}),n(`span`,{className:`text-xs text-muted ms-1 flex items-center gap-1.5`,children:[`(Agent Run ID: `,c,`)`,t(`span`,{className:z(`w-2 h-2 rounded-full transition-colors duration-200`,T?`bg-purple-500 shadow-[0_0_6px_2px_rgba(168,85,247,0.6)]`:`bg-muted`)})]})]}),P]})})}function aZ({compact:e=!1,agentRunId:r,workflowRunId:i,isModal:a,isTerminal:s,onClose:c,onDownload:l,onExportFixture:u,resetWorkflow:d,onExportPdf:f,onShowDetails:p,allowWorkflowControl:m=!0,onClone:h}){let{t:g}=K(),_=nt(),{client:v}=q(),y=nZ();return t(w,{align:`right`,trigger:t(o,{size:e?`icon`:`xs`,variant:`ghost`,title:g(`agent.moreActions`),className:e?`size-8 rounded-lg`:void 0,children:t(wg,{className:`size-4`})}),children:n(ie,{label:`Actions`,children:[n(ae,{onClick:()=>{navigator.clipboard.writeText(r),_({status:`success`,title:g(`agent.agentRunIdCopied`),duration:2e3})},children:[t(fg,{className:`size-3.5 text-muted`}),` `,g(`agent.copyAgentRunId`)]}),n(ae,{onClick:()=>{navigator.clipboard.writeText(i),_({status:`success`,title:g(`agent.workflowRunIdCopied`),duration:2e3})},children:[t(fg,{className:`size-3.5 text-muted`}),` `,g(`agent.copyWorkflowRunId`)]}),p&&n(ae,{onClick:p,children:[t(A_,{className:`size-3.5 text-muted`}),` `,g(`agent.details`)]}),n(ae,{onClick:()=>{l?l():rU(v,r).then(e=>window.open(e,`_blank`))},children:[t(og,{className:`size-3.5 text-muted`}),` `,g(`agent.downloadConversation`)]}),f&&n(ae,{onClick:f,children:[t(og,{className:`size-3.5 text-muted`}),` `,g(`agent.exportAsPdf`)]}),u&&n(ae,{onClick:u,children:[t(og,{className:`size-3.5 text-muted`}),` `,g(`agent.rewind.exportFixture`)]}),c&&a&&n(ae,{onClick:c,children:[t(Gb,{className:`size-3.5 text-muted`}),` `,g(`agent.close`)]}),h&&n(ae,{onClick:async()=>{try{let e=await v.agents.fork(r);_({status:`success`,title:g(`agent.conversationCloned`),duration:2e3}),h?.(e)}catch{_({status:`error`,title:g(`agent.failedToCloneConversation`),duration:2e3})}},children:[t(v_,{className:`size-3.5 text-muted`}),` `,g(`agent.cloneConversation`)]}),m&&!s&&n(ae,{onClick:async()=>{try{return await v.agents.terminate(r,`cancel`),_({status:`success`,title:g(`agent.workflowCancelled`),duration:2e3}),y.reset(),d?.(),!0}catch{return _({status:`error`,title:g(`agent.failedToCancelWorkflow`),duration:2e3}),!1}},variant:`destructive`,children:[t(Gb,{className:`size-3.5`}),` `,g(`agent.cancelWorkflow`)]})]})})}function oZ(e){return typeof e==`object`&&!!e&&`value`in e}function sZ(e){return oZ(e)?e.value:e}function cZ(e){if(e.type===`stringList`)return e.value.map(e=>typeof e==`string`?e:sZ(e));if(e.multiple)return e.value.map(sZ);let t=e.value[0];return t===void 0?void 0:sZ(t)}function lZ(e,t,n){e.query[t]=n}function uZ(e){let t=new Set(e);return e=>t.has(e)}const dZ=[`sys`,`app`,`tmp`],fZ=/^[0-9a-fA-F]{24}$/;function pZ(e){let t=e.indexOf(`:`),n=t>0?e.slice(0,t):void 0;return n&&dZ.includes(n)?{type:n,label:e.slice(t+1)}:{label:e}}function mZ(e,...t){let n=[e?.name,...t].filter(e=>!!e),r=n.find(e=>!fZ.test(e));if(r)return r;let i=n[0];return i?`Deleted interaction (~${i.slice(-8)})`:void 0}function hZ(e){return!!e&&e.version===0&&e.status===hn.unknown}function gZ({interaction:e,className:n}){let r=`success`;switch(e.status){case hn.published:r=`success`;break;case hn.archived:r=`destructive`;break;case hn.code:r=`info`}let a=[e.version?`v${e.version}`:``,e.status&&e.status!==hn.unknown?e.status:``].filter(Boolean).join(` `);return a?t(i,{variant:r,className:n,children:a}):null}function _Z({interaction:r,fallbacks:a=[],fallbackNode:o=null}){let s=mZ(r,...a);if(!s)return t(e,{children:o});let{type:c,label:l}=pZ(s),u=!!r&&!hZ(r);return n(e,{children:[l,(c||u)&&n(`div`,{className:`flex items-center mt-1.5 shrink-0 gap-2`,children:[c&&t(i,{variant:`secondary`,children:c}),u&&r&&t(gZ,{interaction:r})]})]})}function vZ(e,t){return mZ(e,t)??t}function yZ({buckets:e,name:r,placeholder:a}){let o=e.map(e=>({label:`(${e.count})`,value:e._id}));return{name:r,placeholder:a||`${r.charAt(0).toUpperCase()+r.slice(1)}`,options:o,type:`select`,labelRenderer:r=>{let a=e.find(e=>e._id===r),{type:o,label:s}=pZ(vZ(a,r));return n(`div`,{className:`w-full flex items-center justify-between`,children:[n(`div`,{className:`flex flex-row flex-wrap items-center gap-2 min-w-0 flex-1`,children:[t(`span`,{className:`text-sm truncate`,children:s}),o&&t(i,{variant:`secondary`,className:`text-xs w-fit`,children:o}),a&&t(gZ,{interaction:a,className:`text-xs w-fit`})]}),(a?.count??0)>0&&n(`span`,{className:`ms-2 text-xs shrink-0`,children:[`(`,a?.count,`)`]})]})},filterBy:(t,n)=>vZ(e.find(e=>e._id===t),t).toLowerCase().includes(n.toLowerCase())}}function bZ(e){return`${e._id} (${e.count})`}function xZ(e){return`${e.name} (${e.count})`}function SZ({buckets:e,name:t,placeholder:n,type:r=`select`,multiple:i=!1}){return{name:t,options:e.map(e=>({label:bZ(e),value:e._id})),type:r,multiple:i,placeholder:`${n??`${t.charAt(0).toUpperCase()+t.slice(1)}`}`,allowCreate:!1}}function CZ({buckets:e,name:t,placeholder:n,type:r,multiple:i}){return SZ({buckets:e,name:t,placeholder:n,type:r,multiple:i})}Q();const wZ={},TZ={},EZ={};function DZ(e){return typeof e==`object`&&!!e&&`status`in e&&e.status===404}function OZ(e,t,n){let r=e[t];return r||(r=n().catch(n=>{throw DZ(n)||delete e[t],n}),e[t]=r),r}function kZ(e){let{client:t}=q();return Ye(()=>OZ(wZ,e,()=>t.users.retrieve(e)),{deps:[e],condition:()=>!!e})}function AZ(e){let{client:t}=q();return Ye(()=>OZ(TZ,e,()=>t.iam.groups.retrieve(e)),{deps:[e],condition:()=>!!e})}function jZ(e){let{client:t}=q();return Ye(()=>OZ(EZ,e,()=>t.apikeys.retrieve(e)),{deps:[e],condition:()=>!!e})}function MZ(){return t(`div`,{className:`size-8`})}function NZ({showTitle:e=!1,size:i=`md`}){let{t:a}=K();return t(GZ,{title:a(`user.systemUser`),description:a(`user.systemUserDescription`),children:n(`div`,{className:`flex gap-2 items-center`,children:[t(r,{src:`/icon.svg`,size:i}),e&&t(`div`,{className:`text-sm font-semibold ps-2`,children:a(`user.systemUser`)})]})})}function PZ({showTitle:e=!1,size:r=`md`}){let{t:i}=K();return t(GZ,{title:i(`user.allProjectMembers`),description:i(`user.allProjectMembersDescription`),children:n(`div`,{className:`flex gap-2 items-center`,children:[t(Ab,{className:`size-4`,size:r}),e&&t(`div`,{className:`text-sm font-semibold ps-2`,children:i(`user.allProjectMembers`)})]})})}function FZ({accountId:i,showTitle:a=!1,size:o=`md`}){let{t:s}=K(),c=n(e,{children:[t(`div`,{children:s(`user.serviceAccountDescription`)}),n(`div`,{className:`text-muted text-sm`,children:[t(`span`,{className:`font-semibold`,children:`ID:`}),` `,i]})]});return t(GZ,{title:s(`user.serviceAccount`),description:c,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[t(r,{src:`/cloud.svg`,name:`SA`,color:`bg-amber-500`,className:`px-[5px] text-white`,size:o}),a&&n(`div`,{className:`text-sm font-semibold ps-2 truncate`,children:[s(`user.serviceAccount`),` : ~`,i.slice(-6)]})]})})}function IZ({email:i,showTitle:a=!1,size:o=`md`}){let{t:s}=K(),c=n(e,{children:[t(`div`,{children:s(`user.agentOnBehalfOf`)}),n(`div`,{className:`text-muted text-sm`,children:[t(`span`,{className:`font-semibold`,children:`Email:`}),` `,i]})]});return t(GZ,{title:`Email Agent`,description:c,children:n(`div`,{className:`flex items-center gap-2`,children:[n(`div`,{className:`flex items-center -space-x-2`,children:[t(r,{src:`/cloud.svg`,color:`bg-amber-500`,className:`px-[5px] text-white border-2 border-background`,size:o}),t(r,{name:i,size:o,className:`border-2 border-background`})]}),a&&n(`div`,{className:`text-sm font-semibold truncate`,children:[`Agent (`,i,`)`]})]})})}function LZ({agentId:i,onBehalfOfType:a,onBehalfOfId:o,showTitle:s=!1,size:c=`md`,isScheduleAgent:l=!1}){let{t:u}=K(),d=a===`user`&&o,f=a===`apikey`&&o,p=kZ(o||``),m=jZ(o||``),h=d?p.data:void 0,g=f?m.data:void 0,_=i.slice(-6),v=h?u(`user.agentOnBehalfOf`):g?u(`user.agentOnBehalfOfApiKey`):`${u(`user.serviceAccount`)}~${_}`,y=l?u(`user.schedule`,{title:v}):v,b=n(`div`,{className:`space-y-2`,children:[h&&n(`div`,{className:`flex items-center gap-2`,children:[t(r,{src:h.picture,name:h.name,size:`sm`}),n(`div`,{children:[t(`div`,{className:`font-medium`,children:h.name||h.email}),h.email&&h.name&&t(`div`,{className:`text-xs text-muted`,children:h.email})]})]}),g&&n(`div`,{children:[t(`div`,{className:`font-medium`,children:g.name}),n(`div`,{className:`text-xs text-muted`,children:[`Key ID: `,g.id]})]}),!h&&!g&&n(e,{children:[t(`div`,{children:u(`user.serviceAccountDescription`)}),n(`div`,{className:`text-foreground dark:text-muted text-sm`,children:[t(`span`,{className:`font-semibold`,children:`ID:`}),` `,i]})]})]});return t(GZ,{title:y,description:b,children:n(`div`,{className:`flex items-center gap-2`,children:[n(`div`,{className:`flex items-center -space-x-2`,children:[t(r,{src:`/cloud.svg`,color:`bg-amber-500`,className:`px-[5px] text-white border-2 border-background`,size:c}),h&&t(r,{src:h.picture,name:h.name,size:c,className:`border-2 border-background`}),g&&t(r,{name:`API`,color:`bg-gray-400`,size:c,className:`border-2 border-background`})]}),s&&t(`div`,{className:`text-sm font-semibold truncate`,children:h?`Agent (${h.name||h.email})`:g?`Agent (${g.name})`:v})]})})}function RZ({title:e=`Error`,error:n,showTitle:r=!1,size:i=`md`}){return t(VZ,{title:e,message:Ge(n),color:`bg-red-500`,showTitle:r,size:i})}function zZ({showTitle:e=!1,size:n=`md`,color:r}){let{t:i}=K();return t(VZ,{title:i(`user.unknownUser`),message:i(`user.unknownUserDescription`),color:r,showTitle:e,size:n})}function BZ({userRef:e,showTitle:n=!1,size:r=`md`}){let{t:i}=K();if(!e)return t(VZ,{title:i(`user.unknownUser`),message:i(`user.unknownUserDescription`),showTitle:n,size:r});let a=e.split(`:`),o=a[0];switch(o){case bn.User:return t(UZ,{userId:a[1],showTitle:n,size:r});case bn.Group:return t(HZ,{userId:a[1],showTitle:n,size:r});case`system`:return t(NZ,{showTitle:n,size:r});case bn.ServiceAccount:return t(FZ,{accountId:a.slice(1).join(`:`),showTitle:n,size:r});case bn.Agent:{let e,i,o;return a[1]===`agent`?(e=a.slice(2,5).join(`:`),i=a[5],o=a[6]):(e=a.slice(1,4).join(`:`),i=a[4],o=a[5]),t(LZ,{agentId:e,onBehalfOfType:i,onBehalfOfId:o,showTitle:n,size:r})}case bn.Schedule:{let e=a[2]===`agent`?a.slice(3,6).join(`:`):`unknown-agent`,i=a[6],o=a[7];return t(LZ,{agentId:e,onBehalfOfType:i,onBehalfOfId:o,showTitle:n,size:r,isScheduleAgent:!0})}case`email`:return t(IZ,{email:a[1],showTitle:n,size:r});case bn.ApiKey:return t(WZ,{keyId:a[1],size:r,showTitle:n});case`project`:if(a[1]===`*`)return t(PZ,{showTitle:n,size:r});break;default:return t(RZ,{title:i(`user.unknownUser`),error:`Invalid user ref type: ${o}`,showTitle:n,size:r})}}function VZ({title:e,message:i,color:a,size:o=`md`,showTitle:s=!1}){return t(GZ,{title:e,description:i,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[t(r,{color:a,size:o}),s&&t(`div`,{className:`text-sm font-semibold ps-1`,children:e})]})})}function HZ({userId:e,showTitle:r=!1,size:i=`md`}){let{t:a}=K(),{data:o,error:s}=AZ(e);if(s)return DZ(s)?t(zZ,{showTitle:r,size:i,color:`bg-indigo-500`}):t(RZ,{title:a(`user.failedToFetchGroup`),error:s,showTitle:r,size:i});if(!o)return t(MZ,{});let c=n(`div`,{className:`space-y-1`,children:[o.description&&t(`div`,{className:`text-sm`,children:o.description}),t(`div`,{className:`text-xs text-muted`,children:a(`user.groupId`,{id:o.id})}),o.tags&&o.tags.length>0&&t(`div`,{className:`flex flex-wrap gap-1`,children:o.tags.map(e=>t(`span`,{className:`px-1.5 py-0.5 bg-muted rounded text-xs`,children:e},e))})]});return t(GZ,{title:o.name||a(`user.unnamedGroup`),description:c,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[t(Nb,{className:`size-6 text-primary`,size:i}),r&&t(`div`,{className:`text-sm font-semibold ps-2`,children:o.name||a(`user.unnamedGroup`)})]})})}function UZ({userId:e,showTitle:i=!1,size:a=`md`}){let{t:o}=K(),{data:s,error:c}=kZ(e);if(c)return DZ(c)?t(zZ,{showTitle:i,size:a,color:`bg-indigo-500`}):t(RZ,{title:o(`user.failedToFetchUser`),error:c,showTitle:i,size:a});if(!s)return t(MZ,{});let l=t(`div`,{className:`truncate`,title:s.email,children:s.email});return t(GZ,{title:s.name||s.email||s.username||o(`user.unknown`),description:l,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[t(r,{src:s.picture,name:s.name,color:`bg-indigo-500`,size:a}),i&&t(`div`,{className:`text-sm font-semibold ps-2`,children:s.name||s.email||s.username||o(`user.unknown`)})]})})}function WZ({keyId:e,showTitle:i=!1,size:a=`md`}){let{t:o}=K(),{data:s,error:c}=jZ(e);if(c)return DZ(c)?t(zZ,{showTitle:i,size:a,color:`bg-pink-500`}):t(RZ,{title:o(`user.failedToFetchApiKey`),error:c,showTitle:i,size:a});if(!s)return t(MZ,{});let l=o(`user.privateKey`),u=t(r,{name:`PK`,color:`bg-pink-500`,size:a}),d=n(Le,{className:`dark:bg-muted dark:text-foreground table-fixed w-full`,children:[n(`tr`,{children:[t(`td`,{className:`font-semibold w-20`,children:o(`user.key`)}),t(`td`,{className:`truncate max-w-0`,children:s?.name})]}),n(`tr`,{children:[t(`td`,{className:`font-semibold w-20`,children:o(`user.account`)}),t(`td`,{className:`truncate max-w-0`,children:s?.account})]}),n(`tr`,{children:[t(`td`,{className:`font-semibold w-20`,children:o(`user.project`)}),t(`td`,{className:`truncate max-w-0`,children:s?.project.name})]})]});return t(GZ,{title:l,description:d,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[u,i&&t(`div`,{className:`text-sm font-semibold`,children:s?.name||s?.account||s?.project.name||o(`user.unknown`)})]})})}function GZ({title:e,description:r,children:i}){return n(he,{hover:!0,children:[t(_e,{className:`cursor-pointer flex items-center inline-block`,children:t(`div`,{children:i})}),t(ge,{align:`center`,sideOffset:8,side:`right`,children:n(`div`,{className:`flex flex-col gap-1 rounded-md shadow-md p-2`,children:[t(`div`,{className:`text-base font-semibold`,children:e}),r]})})]})}function KZ({buckets:e,name:r,placeholder:i}){let a=e.map(e=>({value:e._id,label:`(${e.count})`}));return{name:r,placeholder:i||`${r.charAt(0).toUpperCase()+r.slice(1)}`,options:a,labelRenderer:r=>{if(r===`Unknown User`||!r)return`Unknown User (${e.find(e=>e._id===r)?.count||0})`;let i=e.find(e=>e._id===r);return n(`div`,{className:`flex items-center w-full gap-2`,children:[t(`div`,{className:`flex-1 min-w-0 flex items-center truncate`,children:t(BZ,{userRef:r,showTitle:!0,size:`sm`})}),n(`span`,{className:`text-muted flex-shrink-0`,children:[`(`,i?.count||0,`)`]})]})}}}function qZ({buckets:e,name:t,placeholder:n}){return KZ({buckets:e,name:t,placeholder:n})}Q();const JZ=uZ([`id`,`run_kind`,`interaction`,`status`,`initiated_by`,`start`,`end`]);function YZ(e){let t=[];return t.push({name:`id`,placeholder:`Agent Run ID`,type:`text`,multiple:!1}),t.push(CZ({buckets:e.kinds||[],name:`run_kind`,placeholder:`Kind`})),t.push(yZ({buckets:e.interactions||[],name:`interaction`,placeholder:`Interaction`})),t.push(CZ({buckets:e.statuses||[],name:`status`,placeholder:`Status`})),t.push(qZ({buckets:e.initiated_by||[],name:`initiated_by`,placeholder:`Initiated By`})),t.push({name:`start`,placeholder:`Started After`,type:`date`,multiple:!1}),t.push({name:`end`,placeholder:`Started Before`,type:`date`,multiple:!1}),t}function XZ(e){return t=>{e.clearFilters(!1,!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!JZ(t.name))return;let n=t.name;lZ(e,n,cZ(t))}}),e.search()}}function ZZ({facets:e,search:r,selectionCount:i,actions:a,filters:s,setFilters:c,filterGroups:l}){let[u,d]=G([]),f=s??u,p=c??d,m=W(!1),h=W(typeof window<`u`&&!!new URLSearchParams(window.location.search).get(`filters`)),g=YZ(e),_=l??g,v=U(()=>XZ(r),[r]);return H(()=>{if(!m.current){m.current=!0;return}if(h.current){h.current=!1;return}v(f)},[f,v]),t(I,{filterGroups:_,filters:f,setFilters:p,children:n(`div`,{className:`gap-2 items-center w-full`,children:[n(`div`,{className:`flex justify-between mb-1`,children:[t(P,{}),n(`div`,{className:`flex justify-end`,children:[!i&&t(`div`,{className:`flex items-center justify-between px-2 py-1`,children:t(`div`,{className:`text-sm text-muted`,children:r.initialized?`${r.totalCount} runs`:`Loading runs...`})}),a&&a.length>0?t(`div`,{className:`flex items-center gap-2 mb-1 me-2`,children:a.map((e,n)=>t(`div`,{children:e},`action-${n}`))}):null,t(o,{onClick:()=>{r.search()},variant:`outline`,title:`Refresh`,children:t(hy,{className:`size-5`})})]})]}),f.length>0&&n(`div`,{className:`flex items-center gap-2 mb-1`,children:[t(N,{}),t(F,{})]})]})})}var QZ=class{types;map={};constructor(e){this.types=e,e.sort((e,t)=>e.name.localeCompare(t.name));for(let t of e)this.map[t.id]=t}getType(e){return this.map[e]}getTypeLayout(e){let t=this.map[e];return t?t.table_layout:void 0}getTypeName(e){let t=this.map[e];return t?t.name:void 0}};const $Z=dt({registry:void 0,isLoading:!1,load:()=>Promise.resolve(),reload:()=>Promise.resolve()});function eQ({children:e}){let{store:n,project:r}=q(),[i,a]=G(),[o,s]=G(!1),c=W(!1),l=W(r?.id),u=V(async()=>{if(!(!r||c.current)){c.current=!0,s(!0);try{let e=await n.types.catalog.list({layout:!0});a(new QZ(e))}catch(e){console.error(`Failed to fetch types`,e)}finally{s(!1),c.current=!1}}},[n,r]),d=V(async()=>(c.current=!1,u()),[u]);return H(()=>{l.current!==r?.id&&(l.current=r?.id,a(void 0),c.current=!1)}),t($Z.Provider,{value:{registry:i,isLoading:o,load:u,reload:d},children:e})}function tQ(){let e=_t($Z);return H(()=>{!e.registry&&!e.isLoading&&e.load()},[e.registry,e.isLoading,e.load]),e}const nQ=uZ([`name`,`types`]);function rQ(e){let{registry:t}=tQ(),n=[];if(n.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t){let e=t.types.map(e=>({label:e.name,value:e.id})),r={name:`types`,placeholder:`Type`,type:`select`,multiple:!0,options:e,filterBy:(t,n)=>e.find(e=>e.value===t)?.label?.toLowerCase().includes(n.toLowerCase())??!1};n.push(r)}return n}function iQ(e){return t=>{if(t.length===0){e.clearFilters(!0);return}e.clearFilters(!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!nQ(t.name))return;let n=t.name;lZ(e,n,cZ(t))}}),e.search()}}function aQ({facets:e,search:r,filters:i,setFilters:a,filterGroups:o}){let[s,c]=G([]),l=rQ(e),u=iQ(r),d=i!==void 0&&a!==void 0;return t(I,{filterGroups:o??l,filters:d?i:s,setFilters:e=>{if(d){a(e);return}let t=typeof e==`function`?e(s):e;c(t),u(t)},children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function oQ({buckets:e,typeRegistry:r,type:i=`select`,multiple:a=!1}){let o=new Map;return r||console.warn(`Type names cannot be resolved`),e.forEach(e=>{let t,n=e._id;e._id==null?(n=`Document`,t=`Document`):(t=r?.getTypeName(e._id),t||=(console.warn(`Content Object Type not found`,e._id),e._id)),o.set(n,{name:t,count:e.count})}),{name:`types`,placeholder:`Types`,type:i,multiple:a,options:e.map(e=>{let t=e._id,n=t||`Document`,r=o.get(n);return{value:t,label:r?`${r.name} (${r.count})`:`Unknown (${e.count})`}}),labelRenderer:e=>{let r=o.get(e);return r?n(`div`,{className:`w-full flex items-center`,children:[t(`span`,{className:`text-sm truncate`,children:r.name}),n(`span`,{className:`ms-2 text-xs`,children:[`(`,r.count,`)`]})]}):(console.warn(`Type data not found for ${e}`),e)},filterBy:(e,t)=>{let n=o.get(e);return n?n.name.toLowerCase().includes(t.toLowerCase()):(console.warn(`Type name not found for ${e}`),!1)}}}const sQ=[`id`,`name`,`types`,`status`],cQ=[`tags`,`created_at`,`updated_at`],lQ=uZ(sQ),uQ=new Set(cQ);function dQ(e){return uQ.has(e)}function fQ(e){return Array.isArray(e)?e:[]}function pQ(e){let{registry:t}=tQ(),n=[];if(n.push({placeholder:`ID`,name:`id`,type:`text`,options:[]}),n.push({placeholder:`Name`,name:`name`,type:`text`,options:[]}),e.type){let r=oQ({buckets:fQ(e.type),typeRegistry:t,type:`select`,multiple:!0});n.push(r)}if(e.status){let t=CZ({buckets:fQ(e.status),name:`status`,placeholder:`Status`,type:`select`,multiple:!0});n.push(t)}return e.tags&&n.push({name:`tags`,placeholder:`Tags`,type:`stringList`,options:fQ(e.tags).map(e=>({label:e._id,value:e._id}))}),n.push({name:`created_at`,placeholder:`Created Date`,type:`date`,multiple:!0,options:[]}),n.push({name:`updated_at`,placeholder:`Updated Date`,type:`date`,multiple:!0,options:[]}),n}function mQ(e){return t=>{if(t.length===0){e.clearFilters();return}e.clearFilters(!1),t.forEach(t=>{if(t.value&&t.value.length>0){let n=t.name,r;if(t.type===`date`&&t.multiple){if(Array.isArray(t.value)&&t.value.length>0){if(t.value.length===1){let e=sZ(t.value[0]);r={gte:e,lte:e}}else t.value.length===2&&(r={gte:sZ(t.value[0]),lte:sZ(t.value[1])})}}else r=cZ(t);lQ(n)?lZ(e,n,r):dQ(n)&&r!==void 0&&(e.query.match={...e.query.match,[n]:r})}}),e.search()}}function hQ({facets:e,search:r}){let[i,a]=G([]),o=pQ(e),s=mQ(r),c=$e();return t(I,{filterGroups:o,filters:i,setFilters:e=>{let t=typeof e==`function`?e(i):e;a(t),s(t)},inModal:c,children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function gQ({search:e,buckets:n,placeholder:r=`All Environments`,className:i}){let{client:a}=q(),[o,s]=G([]),c=e.getFilterValue(`environment`),l=t=>{e.setFilterValue(`environment`,t?._id)};H(()=>{if(a){let e=n.map(async e=>{let t;return await a.environments.retrieve(e._id).then(e=>{t=e.name}).catch(()=>{t=`${e._id} (deleted)`}),t||=e._id,{...e,name:t}});Promise.all(e).then(e=>{e.sort((e,t)=>e.name.localeCompare(t.name)),s(e)})}},[n,a]);let u=o?.find(e=>e._id===c);return t(we,{filterBy:`name`,className:i,isClearable:!0,optionLabel:xZ,options:o,value:u,onChange:l,by:`_id`,placeholder:r})}const _Q=uZ([`name`,`prompt`,`model`,`tags`]);function vQ(e){let t=[];return t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t.push({name:`prompt`,placeholder:`Prompt Name`,type:`text`,multiple:!1}),t.push({name:`model`,placeholder:`Model`,type:`text`,multiple:!1}),t.push({name:`tags`,placeholder:`Tags`,type:`stringList`,multiple:!0}),t}function yQ(e){return t=>{if(t.length===0){e.clearFilters(!0,!0);return}e.clearFilters(!1,!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!_Q(t.name))return;let n=t.name;lZ(e,n,cZ(t))}}),e.search(!0)}}function bQ({facets:e,search:r,filters:i,setFilters:a,filterGroups:o}){let[s,c]=G([]),l=vQ(e),u=yQ(r),d=i!==void 0&&a!==void 0;return t(I,{filterGroups:o??l,filters:d?i:s,setFilters:e=>{if(d){a(e);return}let t=typeof e==`function`?e(s):e;c(t),u(t)},children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function xQ(e){let t=[];return t.push(CZ({buckets:e.statuses||[],name:`status`,placeholder:`Status`,multiple:!1})),t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t}function SQ({facets:e,filters:r,setFilters:i}){let a=xQ(e);return t(I,{filterGroups:a,filters:r,setFilters:i,children:n(`div`,{className:`flex items-center gap-2`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function CQ(e){let t=[];return t.push(CZ({buckets:e.statuses||[],name:`status`,placeholder:`Status`,multiple:!0})),t.push(qZ({buckets:e.started_by||[],name:`started_by`,placeholder:`Started By`})),t.push(CZ({buckets:e.run_type||[],name:`run_type`,placeholder:`Mode`,multiple:!0})),t.push(CZ({buckets:e.processes||[],name:`process`,placeholder:`Process`,multiple:!0})),t.push({name:`start`,placeholder:`Started After`,type:`date`,multiple:!1}),t.push({name:`end`,placeholder:`Started Before`,type:`date`,multiple:!1}),t}function wQ({facets:e,filters:r,setFilters:i}){let a=CQ(e);return t(I,{filterGroups:a,filters:r,setFilters:i,children:n(`div`,{className:`flex items-center gap-2`,children:[t(P,{}),t(N,{}),t(F,{})]})})}const TQ=uZ([`name`,`role`,`tags`]);function EQ(e,t){let n=e[t];return Array.isArray(n)?n:[]}function DQ(e){let t=EQ(e,`role`),n=[];if(n.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t.length>0){let e={name:`role`,placeholder:`Role`,type:`select`,options:t.map(e=>({label:e._id,value:e._id,count:e.count}))};n.push(e)}let r={name:`tags`,placeholder:`Tags`,type:`stringList`,multiple:!0,options:EQ(e,`tags`).map(e=>({label:e._id,value:e._id}))};return n.push(r),n}function OQ(e){return t=>{if(t.length===0){e.clearFilters(!0,!1);return}e.clearFilters(!1,!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!TQ(t.name))return;let n=t.name;lZ(e,n,cZ(t))}}),e.search()}}function kQ({facets:e,search:r,filters:i,setFilters:a,filterGroups:o}){let[s,c]=G([]),l=DQ(e),u=OQ(r),d=i!==void 0&&a!==void 0;return t(I,{filterGroups:o??l,filters:d?i:s,setFilters:e=>{if(d){a(e);return}let t=typeof e==`function`?e(s):e;c(t),u(t)},children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function AQ({buckets:e,name:r}){let i=e.map(e=>({label:`(${e.count})`,value:e._id}));return{name:`environment`,placeholder:r.charAt(0).toUpperCase()+r.slice(1),options:i,type:`select`,labelRenderer:r=>{let i=e.find(e=>e._id===r),a=i?.name||r;return n(`div`,{className:`w-full flex items-center`,children:[t(`span`,{className:`text-sm truncate`,children:a}),n(`span`,{className:`ms-2 text-xs`,children:[`(`,i?.count||0,`)`]})]})},filterBy:(t,n)=>(e.find(e=>e._id===t)?.name||t).toLowerCase().includes(n.toLowerCase())}}Q();const jQ=uZ([`run_ids`,`interaction`,`environment`,`tags`,`model`,`status`,`finish_reason`,`start`,`end`,`workflow_run_ids`,`workflow_ids`]);function MQ(e){return e.filter(e=>e._id!==null)}function NQ(e){let t=[];if(t.push({name:`run_ids`,placeholder:`Run ID`,type:`text`,multiple:!1}),e.interactions){let n=yZ({buckets:MQ(e.interactions),name:`interaction`,placeholder:`Interactions`});t.push(n)}if(e.environments){let n=AQ({buckets:MQ(e.environments),name:`environment`});t.push(n)}if(t.push({name:`tags`,placeholder:`Tags`,type:`stringList`,multiple:!0}),e.models){let n=CZ({buckets:MQ(e.models),name:`model`});t.push(n)}if(e.statuses){let n=CZ({buckets:MQ(e.statuses),name:`status`});t.push(n)}if(e.finish_reason){let n=CZ({buckets:e.finish_reason.map(e=>({...e,_id:e._id===null?`none`:e._id})),name:`finish_reason`,placeholder:`Finish Reason`});t.push(n)}return t.push({name:`start`,placeholder:`Date After`,type:`date`,multiple:!1}),t.push({name:`end`,placeholder:`Date Before`,type:`date`,multiple:!1}),t.push({name:`workflow_run_ids`,placeholder:`Workflow Run ID`,type:`text`,multiple:!1}),t.push({name:`workflow_ids`,placeholder:`Workflow ID`,type:`text`,multiple:!1}),t}function PQ(e){return t=>{if(t.length===0){e.clearFilters(!0,!1);return}e.clearFilters(!1,!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!jQ(t.name))return;let n=t.name,r=cZ(t);(n===`run_ids`||n===`workflow_run_ids`||n===`workflow_ids`)&&!Array.isArray(r)&&(r=[r]),lZ(e,n,r)}}),e.search()}}function FQ({facets:e,search:r,actions:i,selectionCount:a,filters:s,setFilters:c,filterGroups:l}){let[u,d]=G([]),f=NQ(e),p=PQ(r),m=s!==void 0&&c!==void 0,h=m?s:u;return t(I,{filterGroups:l??f,filters:h,setFilters:e=>{if(m){c(e);return}let t=typeof e==`function`?e(u):e;d(t),p(t)},children:n(`div`,{className:`gap-2 items-center w-full`,children:[n(`div`,{className:`flex justify-between mb-1`,children:[t(P,{}),n(`div`,{className:`flex justify-end`,children:[!a&&t(`div`,{className:`flex items-center justify-between px-2 py-1`,children:t(`div`,{className:`text-sm text-muted`,children:r.initialized?`${r.totalCount} calls`:`Loading calls...`})}),i&&i.length>0?t(`div`,{className:`flex items-center gap-2 mb-1 me-2`,children:i.map((e,n)=>t(`div`,{children:e},`action-${n}`))}):null,t(o,{onClick:()=>{r.search()},variant:`outline`,title:`Refresh`,children:t(hy,{className:`size-5`})})]})]}),h.length>0&&n(`div`,{className:`flex items-center gap-2 mb-1`,children:[t(N,{}),t(F,{})]})]})})}function IQ({search:e,buckets:n,name:r,placeholder:i,className:a}){let o=e.getFilterValue(r),s=t=>{e.setFilterValue(r,t?._id)},c=n?.find(e=>JSON.stringify(e._id)===JSON.stringify(o));return t(we,{filterBy:`_id`,className:a,isClearable:!0,optionLabel:bZ,options:n,value:c,onChange:s,by:`_id`,placeholder:i})}function LQ({search:e,name:n,placeholder:r,className:i}){let[a,o]=G([]);return H(()=>{e.setFilterValue(n,a)},[n,e,a]),t(ne,{className:i,value:a,onChange:o,placeholder:r})}function RQ(e){return`${e.name} (${e.count})`}function zQ({search:e,buckets:n,placeholder:r=`Filter by Type`,className:i}){let[a,o]=G([]),{registry:s}=tQ(),c=e.getFilterValue(`type`),l=t=>{e.setFilterValue(`type`,t?._id)};H(()=>{if(s){let e=n.map(e=>{let t;return e._id==null?(e._id=`Document`,t=`Document`):(t=s.getTypeName(e._id),t||=(console.warn(`Content Object Type not found`,e._id),e._id)),{...e,name:t}});e.sort((e,t)=>e.name.localeCompare(t.name)),o(e)}},[n,s]);let u=a?.find(e=>e._id===c);return t(we,{filterBy:`name`,className:i,isClearable:!0,optionLabel:RQ,options:a,value:u,onChange:l,by:`_id`,placeholder:r})}function BQ(e){let t=[];return t.push(CZ({buckets:e.tags||[],name:`tags`,placeholder:`Tags`,multiple:!0})),t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t}function VQ({facets:e,filters:r,setFilters:i}){let a=BQ(e);return t(I,{filterGroups:a,filters:r,setFilters:i,children:n(`div`,{className:`flex items-center gap-2`,children:[t(P,{}),t(N,{}),t(F,{})]})})}const HQ=uZ([`search_term`,`status`,`initiated_by`,`start`,`end`,`has_reported_errors`]);function UQ(e){let t=[];if(t.push({placeholder:`Workflow Name or Workflow Run ID`,name:`search_term`,type:`text`,options:[]}),e.status){let n=CZ({buckets:e.status||[],name:`status`,placeholder:`Status`});t.push({...n,name:`status`})}if(e.initiated_by){let n=qZ({buckets:e.initiated_by||[],name:`initiated_by`,placeholder:`Initiated By`});t.push({...n,name:`initiated_by`})}return t.push({name:`start`,placeholder:`Date After`,type:`date`,multiple:!1}),t.push({name:`end`,placeholder:`Date Before`,type:`date`,multiple:!1}),t.push({name:`has_reported_errors`,placeholder:`Has Reported Errors`,type:`select`,multiple:!1,options:[{label:`Yes`,value:`true`},{label:`No`,value:`false`}]}),t}function WQ(e){return t=>{if(t.length===0){e.clearFilters();return}e.clearFilters(!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!HQ(t.name))return;let n=t.name,r=cZ(t);if(n===`has_reported_errors`){let t=Array.isArray(r)?r[0]:r;(t===`true`||t===`false`)&&lZ(e,n,t===`true`)}else typeof r==`string`&&lZ(e,n,r)}}),e.search()}}function GQ({facets:e,search:r}){let[i,a]=G([]),o=UQ(e),s=WQ(r);return t(I,{filterGroups:o,filters:i,setFilters:e=>{let t=typeof e==`function`?e(i):e;a(t),s(t)},children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function KQ(e){let t=[];return t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t}function qQ({facets:e,filters:r,setFilters:i}){let a=KQ(e);return t(I,{filterGroups:a,filters:r,setFilters:i,children:n(`div`,{className:`flex items-center gap-2`,children:[t(P,{}),t(N,{}),t(F,{})]})})}var JQ=class e{object;objects;setState;collectionId;singleSelection=!1;constructor(e,t,n,r){this.object=e,this.objects=n,this.setState=r,this.singleSelection=Object.keys(this.objects).length===0,this.collectionId=t}isSingleSelection(){return this.singleSelection}hasSelection(){return this.object!==void 0||this.size()!==0}size(){return Object.keys(this.objects).length}getObjectIds(){return Object.keys(this.objects)}getObjectId(){return this.object?.id}clone(){return new e(this.object,this.collectionId,this.objects,this.setState)}add(e){this.objects[e.id]=e,this.singleSelection=Object.keys(this.objects).length===0,this.setState(this.clone())}remove(e){delete this.objects[e],this.singleSelection=Object.keys(this.objects).length===0,this.setState(this.clone())}addAll(e){for(let t of e)this.objects[t.id]=t;this.setState(this.clone())}isSelected(e){return this.objects[e]!==void 0}removeAll(){this.objects={},this.singleSelection=!0,this.setState(this.clone())}};const YQ=dt(void 0);function XQ(){let e=_t(YQ);if(!e)throw Error(`useObjectSelection must be used within a ObjectSelectionProvider`);return e}function ZQ(){return _t(YQ)}function QQ({value:e,collectionId:n,children:r}){let[i,a]=G();return H(()=>{let t=new JQ(e,n,{},a);a(t)},[n,e]),i&&t(YQ.Provider,{value:i,children:r})}Q();const $Q=dt(void 0);function e$({onFilter:e,children:n}){return t($Q.Provider,{value:e,children:n})}function t$(){return _t($Q)}const n$=`h-6 w-6 p-0 opacity-0 group-hover/field:opacity-100 text-muted hover:text-foreground transition-opacity shrink-0`;function r$({field:r,value:i,label:a,copyContent:s}){let c=t$(),l=Array.isArray(i)?i.length>0:i!==void 0&&i!==``;return n(e,{children:[s!==void 0&&s!==``&&t(x,{content:s,className:n$}),l&&i!==void 0&&t(o,{variant:`ghost`,size:`sm`,title:`Filter by ${a}`,className:n$,onClick:e=>{e.stopPropagation(),c?.(r,i)},children:t(l_,{className:`size-3`})})]})}const i$=`text/csv`,a$=`image/`,o$=`application/pdf`,s$=`video/`,c$=[`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,`application/msword`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`,`application/vnd.ms-powerpoint`],l$=e=>e===i$||i$.includes(e),u$=e=>e.startsWith(a$)||a$.includes(e),d$=e=>e===o$||o$.includes(e),f$=e=>e.startsWith(s$)||s$.includes(e),p$=e=>c$.includes(e);function m$(e,t){if(typeof window>`u`||typeof document>`u`)return!1;let n=document.createElement(`iframe`);n.style.position=`fixed`,n.style.right=`0`,n.style.bottom=`0`,n.style.width=`0`,n.style.height=`0`,n.style.border=`0`,n.style.visibility=`hidden`,document.body.appendChild(n);let r=n.contentWindow;if(!r)return n.parentNode?.removeChild(n),!1;let i=r.document;i.open(),i.write(`<!doctype html><html><head><title></title></head><body></body></html>`),i.close(),i.title=t,document.querySelectorAll(`link[rel="stylesheet"], style`).forEach(e=>{i.head.appendChild(e.cloneNode(!0))});let a=i.createElement(`style`);return a.textContent=`
1252
+ `}),s===`stacked`&&t(`div`,{className:z(`sticky top-0 z-10`,y&&`hidden`),children:t(OK,{workstreams:fe,activeWorkstream:R,onSelectWorkstream:ge,count:ve,completionStatus:it})}),ye.length===0&&Ve.length===0&&!ke&&!(se&&Ze)?R===`all`&&Ye?t(`div`,{className:`flex-1 px-2 py-6 sm:px-4`,children:t(bq,{label:F(`agent.preparing`),timestamp:Oe.current,className:b})}):t(`div`,{className:`flex items-center justify-center h-full text-center py-8`,children:t(`div`,{className:`flex items-center px-3 py-2 text-sm text-muted`,children:F(R===`all`?`agent.waitingForAgentResponse`:`agent.noMessagesInWorkstream`)})}):n(`div`,{className:z(`flex-1 flex flex-col justify-start w-full max-w-full`,se?`gap-6 px-2 py-6 sm:px-4`:`gap-3 pb-4`,x),children:[se&&R!==`all`&&pe&&t(`div`,{className:`sticky top-0 z-20 -mx-2 bg-background/95 px-2 pb-2 pt-1 backdrop-blur sm:-mx-4 sm:px-4`,children:n(`div`,{className:`mx-auto flex w-full max-w-3xl items-center gap-2 border-b border-border/70 pb-3`,children:[t(o,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8 shrink-0 text-muted hover:text-foreground`,title:F(`agent.backToMainAgent`),onClick:_e,children:t(wm,{className:`size-4`,"aria-hidden":`true`})}),t(`div`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-foreground`,children:pe})]})}),je&&t(yq,{data:T,schema:E,title:D,template:O,prependFriendlyMessage:w,timestamp:ye[0]?.timestamp??Date.now(),isSummaryView:se,messageItemClassNames:f,messageStyleOverrides:p,StoreLinkComponent:S,CollectionLinkComponent:C},`initial-request`),$e&&t(bq,{label:Qe,timestamp:rt,className:b}),s===`stacked`?n(e,{children:[Je.map((e,n)=>{let r=n===Je.length-1;if(e.type===`resource_summary`)return t(EG,{resources:e.resources,workflowRunId:v,className:`my-2`},e.key);if(e.type===`tool_group`){let n=e.messages[e.messages.length-1],i=e.toolStatus===`completed`||e.toolStatus===`error`||e.toolStatus===`warning`,a=!c&&r&&!YH.includes(n.type)&&!i;return h?.includes(s)?null:t(CJ,{status:e.toolStatus,children:t(wJ,{children:t(xK,{...m,messages:e.messages,showPulsatingCircle:a,toolRunId:e.toolRunId,toolStatus:e.toolStatus,preambleText:e.preambleText,preambleMessage:e.preambleMessage,rootClassName:z(`rounded-lg border border-border bg-background/60 shadow-none`,m?.rootClassName),headerClassName:z(`px-3 py-2`,m?.headerClassName),itemHeaderClassName:z(`hover:bg-mixer-muted/20`,m?.itemHeaderClassName)})})},qq(e))}if(e.type===`streaming`)return t(CJ,{children:t(MG,{...g,text:e.text,workstreamId:e.workstreamId,isComplete:e.isComplete,timestamp:e.startTimestamp,artifactRunId:v,cardClassName:z(`rounded-lg border border-border bg-background/60 shadow-none`,g?.cardClassName)})},qq(e));{let i=e.message;if(Te(i)||Ee(i))return null;if(QH(i))return t(CJ,{children:t(xJ,{message:i,startTimestamp:Jq(Je,n)??i.timestamp,endTimestamp:i.timestamp})},Kq(i,`stopped`));let a=!c&&r&&!YH.includes(i.type);return jK(i)?t(wJ,{children:t(YW,{message:i,batchData:i.details,isRunning:!i.details.completed_at,..._})},`batch-${i.details.batch_id}-${i.timestamp}`):t(CJ,{status:`message`,children:t(wJ,{children:t(yG,{...f,message:i,showPulsatingCircle:a,onSendMessage:u,onOpenArtifact:d,requestInputAnswered:eW(i,be),cardClassName:z(`rounded-lg border border-border bg-background/60 shadow-none`,f?.cardClassName),headerClassName:z(`px-3 py-2`,f?.headerClassName),contentClassName:z(`bg-transparent`,f?.contentClassName),messageStyleOverrides:p,StoreLinkComponent:S,CollectionLinkComponent:C})})},Kq(i))}}),Ve.map(({id:e,data:n})=>t(CJ,{children:t(MG,{...g,text:n.text,workstreamId:n.workstreamId,isComplete:n.isComplete,timestamp:n.startTimestamp,artifactRunId:v,cardClassName:z(`rounded-lg border border-border bg-background/60 shadow-none`,g?.cardClassName)})},`streaming-incomplete-${e}`)),Ye&&Ve.length===0&&!$e&&t(CJ,{children:n(`div`,{className:z(`flex items-center gap-2 py-2 text-sm text-muted`,b),children:[t(aW,{size:`sm`,color:`blue`}),t(`span`,{children:F(`agent.working`)})]})})]}):n(e,{children:[Ke.map(e=>{if(e.type===`resource_summary`)return t(EG,{resources:e.resources,workflowRunId:v,className:`my-2`},e.key);if(e.type===`work`){if(h?.includes(s))return null;let n=BK(e.messages);return t(SJ,{label:VK(e.isActive),status:e.status,timestamp:e.startTimestamp,durationSeconds:e.isActive?void 0:PK(e.startTimestamp,e.endTimestamp),showElapsed:!0,details:n?void 0:e.messages,defaultExpanded:e.isActive&&!n,disablePreambleCollapse:e.isActive,className:b,onSendMessage:u,answeredToolApprovalRequestInputKeys:Se,resolvedToolApprovalKeys:xe},`work-${e.id}-${e.isActive?`active`:`done`}-${e.status}`)}if(e.type===`stopped`)return t(xJ,{message:e.message,startTimestamp:e.startTimestamp,endTimestamp:e.endTimestamp},Kq(e.message,`stopped-summary`));let n=e.message;return Te(n)||Ee(n)?null:jK(n)?t(wJ,{children:t(YW,{message:n,batchData:n.details,isRunning:!n.details.completed_at,..._})},Kq(n,`batch`)):t(wJ,{children:t(uq,{message:n,onSendMessage:u,onOpenArtifact:d,onSelectWorkstream:ge,requestInputAnswered:eW(n,be),StoreLinkComponent:S,CollectionLinkComponent:C})},Kq(n,`summary`))}),Ve.map(({id:e,data:n})=>t(bJ,{text:n.text,workstreamId:n.workstreamId,artifactRunId:v},`streaming-incomplete-${e}`)),Xe&&t(`div`,{className:z(`mx-auto w-full max-w-3xl px-1 text-sm text-muted`,b),"data-testid":`post-tool-thinking-indicator`,children:F(`agent.thinking`)}),Ze&&!$e&&t(SJ,{label:Qe,status:`running`,timestamp:rt,showElapsed:!0,className:b})]}),t(`div`,{ref:a,className:`h-2`})]})]})}const DJ=(e,t)=>{if(e.type!==t.type||e.message!==t.message)return!1;let n=e.details,r=t.details;if(n?.tool_status!==`completed`||r?.tool_status!==`completed`)return!1;let i=typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime();return(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())-i<2e3},OJ=ot.memo(EJ);Q();function kJ(e){return e?new Map(e.streamingMessages.map((e,t)=>[e.id??e.activityId??`stream-${t}`,e])):new Map}function AJ(e,t){return e?.find(e=>e.cursor===t)}function jJ(e,t){if(t===0||e===`live`)return`live`;let n=fC(e,t);return n>=t-1?`live`:n+1}function MJ(e){let t=0,n=e.length;for(;t<n&&e[t]===`-`;)t++;for(;n>t&&e[n-1]===`-`;)n--;return e.slice(t,n)}function NJ(e){return MJ(e.trim().replace(/[^a-z0-9-_]+/gi,`-`)).slice(0,80)}function PJ(e,t){let n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}function FJ({fixture:e,cursor:r,initialCursor:i,onCursorChange:a,autoStepMs:s,repeat:c=1,viewMode:l,className:u,title:d,showHeader:f=!0}){let{t:p}=K(),m=e.messages,h=i??(m.length>0?0:`live`),[g,_]=G(()=>dC(h,m.length)),v=r??g,y=l??`sliding`,[b,x]=G(!!s),[S,C]=G(0),w=W(null),T=U(()=>hC(m,v,!0),[v,m]),E=T.displayedMessages,D=U(()=>kJ(AJ(e.streamingFrames,T.cursor)),[e.streamingFrames,T.cursor]),O=V(e=>{let t=dC(e,m.length);r===void 0&&_(t),a?.(t)},[r,m.length,a]);H(()=>{let e=dC(v,m.length);e!==v&&O(e)},[v,m.length,O]),H(()=>{if(!s||s<=0||!b)return;let e=window.setInterval(()=>{let e=jJ(v,m.length);if(e===`live`&&v===`live`){C(e=>{let t=e+1;return c>0&&t>=c?(x(!1),t):(O(m.length>0?0:`live`),t)});return}O(e)},s);return()=>window.clearInterval(e)},[s,v,b,m.length,c,O]);let k=E.length>0&&!ZH(E),A=U(()=>tW(E),[E]),j=d??e.metadata?.title??p(`agent.rewind.fixtureTitle`),M=V(()=>{let t={...e,metadata:{...e.metadata,title:j,exported_at:e.metadata?.exported_at??new Date().toISOString(),message_count:m.length}},n=e.metadata?.agent_run_id??`fixture`;PJ(`${NJ(j)||`agent-chat`}-${NJ(n)}.json`,t)},[e,m.length,j]),N=V(()=>{O(jJ(T.cursor,m.length))},[m.length,T.cursor,O]);return n(`div`,{className:z(`flex h-full min-h-0 w-full flex-col bg-background text-foreground`,u),"data-agent-test-playback-enabled":!0,"data-agent-playback-cursor":T.cursor,"data-agent-live-message-count":m.length,"data-agent-rendered-message-count":T.renderedMessageCount,"data-agent-replay-playing":b||void 0,"data-agent-replay-loop":S,children:[f&&n(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-b border-border px-3 py-2`,children:[n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`truncate text-sm font-medium`,children:j}),t(`div`,{className:`text-xs text-muted`,children:p(`agent.rewind.fixtureMeta`,{messageCount:m.length,loops:S})})]}),n(`div`,{className:`flex items-center gap-2`,children:[n(o,{type:`button`,variant:`secondary`,size:`sm`,onClick:M,children:[t(og,{className:`size-4`}),t(`span`,{className:`ms-1.5`,children:p(`agent.rewind.exportFixture`)})]}),s&&s>0&&n(o,{type:`button`,variant:`secondary`,size:`sm`,onClick:()=>x(e=>!e),children:[t(b?Gv:ry,{className:`size-4`}),t(`span`,{className:`ms-1.5`,children:p(b?`agent.rewind.pause`:`agent.rewind.resume`)})]})]})]}),t(`div`,{className:`flex flex-shrink-0 justify-end px-2 py-1.5`,children:t(xC,{cursor:T.cursor,messages:m,onChangeCursor:O})}),t(OJ,{messages:E,isCompleted:k,streamingMessages:D,bottomRef:w,artifactRunId:e.metadata?.agent_run_id??`agent-chat-fixture`,viewMode:y,renderRequestInputControls:!A}),A&&t(rW,{message:A,onSendMessage:N,isLoading:!1})]})}function IJ({className:e,inline:r=!1}){return n(`div`,{className:z(`flex items-center gap-1`,r?`inline-flex`:``,e),children:[t(`div`,{className:`w-2 h-2 bg-primary rounded-full animate-[jumping_1s_infinite_ease-in-out] hover:bg-primary`,style:{transform:`translateY(0)`,animationRange:`0px -8px`}}),t(`div`,{className:`w-2 h-2 bg-primary rounded-full animate-[jumping_1s_0.3s_infinite_ease-in-out] hover:bg-primary`,style:{transform:`translateY(0)`,animationRange:`0px -8px`}}),t(`div`,{className:`w-2 h-2 bg-primary rounded-full animate-[jumping_1s_0.6s_infinite_ease-in-out] hover:bg-primary`,style:{transform:`translateY(0)`,animationRange:`0px -8px`}})]})}function LJ(){let{client:e}=q(),[t,n]=G([]),[r,i]=G(!0),[a,o]=G(!1),s=W(0),c=V(async()=>{let t=s.current+1;s.current=t,i(!0),o(!1);try{let r=await e.apps.getInstalledApps(`tools`),a=[];for(let e of r){let t=e,n=t.oauth_collection_ids??[],r=t.manifest.oauth_providers??{};if(!t.manifest.tool_collections)continue;let i=t.manifest.tool_collections.map(e=>An(e)).filter(e=>e.type===`mcp`),o=i.filter(e=>e.auth!==`api_key`&&n.includes(e.id)),s=i.filter(e=>e.auth===`api_key`),c=new Map,l=new Map,u=[];for(let e of o)if(e.oauth_provider){let t=c.get(e.oauth_provider)??[];t.push(e),c.set(e.oauth_provider,t)}else if(e.oauth_app){let t=l.get(e.oauth_app)??[];t.push(e),l.set(e.oauth_app,t)}else u.push(e);for(let[e,n]of c){let i=n[0].id;for(let o of n)a.push({key:`${t.id}:provider:${e}:${o.id}`,appId:t.id,appName:t.manifest.title||t.manifest.name,label:o.name,representativeId:i,memberIds:[o.id],memberNames:[o.name],authType:`oauth`,oauthGrantType:r[e]?.grant_type})}for(let[e,n]of l){let r=n[0].id;for(let i of n)a.push({key:`${t.id}:oauthapp:${e}:${i.id}`,appId:t.id,appName:t.manifest.title||t.manifest.name,label:i.name,representativeId:r,memberIds:[i.id],memberNames:[i.name],authType:`oauth`})}for(let e of u)a.push({key:`${t.id}:individual:${e.id}`,appId:t.id,appName:t.manifest.title||t.manifest.name,label:e.name,representativeId:e.id,memberIds:[e.id],memberNames:[e.name],authType:`oauth`});for(let e of s)a.push({key:`${t.id}:api-key:${e.id}`,appId:t.id,appName:t.manifest.title||t.manifest.name,label:e.name,representativeId:e.id,memberIds:[e.id],memberNames:[e.name],authType:`api_key`})}if(s.current!==t||(n(a),i(!1),a.length===0))return;o(!0);let c=new Map,l=await Promise.all(a.map(async t=>{try{let n=c.get(t.appId);n||(n=e.remoteMcpConnections.getStatus(t.appId),c.set(t.appId,n));let r=(await n).find(e=>e.collection_id===t.representativeId);return{...t,authStatus:r}}catch{return t}}));if(s.current!==t)return;n(l)}catch(e){s.current===t&&(console.error(`Failed to load MCP tool collections:`,e),n([]))}finally{s.current===t&&(i(!1),o(!1))}},[e]);return H(()=>{c()},[c]),{groups:t,loading:r,statusLoading:a,reload:c}}function RJ(e,t){return t?.length?e.memberIds.every(e=>t.includes(e)):!1}function zJ(e,t,n){let r=new Set(t??[]);if(n)for(let t of e.memberIds)r.delete(t);else for(let t of e.memberIds)r.add(t);return Array.from(r)}function BJ(e,t){return e.filter(e=>e.authStatus?.authenticated===!0&&!RJ(e,t)).length}function VJ(e,t){return e.filter(e=>e.authStatus?.authenticated===!0&&!RJ(e,t)).map(e=>e.label)}Q();function HJ({isOpen:e,onClose:r,groups:i,loading:a,statusLoading:o=!1,reload:s,disabledCollections:c,onChange:l,onConnectionChange:u,readOnly:d=!1}){let{t:f}=K(),p=()=>{s(),u?.()};return n(mT,{isOpen:e,onClose:r,size:`md`,className:`max-w-[92vw] sm:max-w-[620px] lg:max-w-[620px]`,children:[t(hT,{children:f(`mcpConnections.title`)}),n(gT,{children:[t(`p`,{className:`mb-4 text-sm text-muted`,children:f(`mcpConnections.subtitle`)}),a?t(`div`,{className:`flex items-center justify-center py-8`,children:t(dO,{className:`size-5`})}):i.length===0?t(`div`,{className:`py-8 text-center text-sm text-muted`,children:f(`mcpConnections.empty`)}):t(`div`,{className:`space-y-1`,children:i.map(e=>{let r=!RJ(e,c),i=e.authStatus?.authenticated===!0,a=e.authType===`oauth`&&e.oauthGrantType!==`client_credentials`;return n(`div`,{className:`flex items-center justify-between gap-3 py-3`,children:[n(`div`,{className:`flex min-w-0 items-center gap-2`,children:[t(i?G_:H_,{className:`size-4 shrink-0 ${i?`text-success`:`text-muted`}`,"aria-hidden":`true`}),t(tT,{description:n(`div`,{className:`space-y-0.5`,children:[t(`div`,{className:`font-medium`,children:e.appName}),e.memberNames.length>1&&t(`div`,{className:`text-xs text-muted`,children:e.memberNames.join(` · `)})]}),placement:`top`,asChild:!0,children:t(`span`,{className:`truncate ${r?`text-foreground`:`text-muted line-through`}`,children:e.label})})]}),n(`div`,{className:`flex shrink-0 items-center gap-3`,children:[a&&o&&!e.authStatus?t(oT,{variant:`outline`,size:`sm`,disabled:!0,className:`h-6 w-32 justify-center px-2 text-xs`,title:f(`mcpConnections.checkingStatus`),children:t(dO,{className:`size-3`})}):a?t(mO,{appId:e.appId,collectionId:e.representativeId,collectionName:e.label,authenticated:e.authStatus?.authenticated,onAuthChange:p,variant:`compact`,showDisconnect:!0,readOnly:d}):e.authType===`oauth`?t(uT,{variant:`outline`,className:`h-6 w-32 justify-center px-2 text-xs`,children:f(`mcpConnections.managedByApp`)}):null,l&&t(lO,{size:`sm`,value:r,onChange:t=>l(zJ(e,c,t)),disabled:d,"aria-label":f(r?`mcpConnections.deactivateAria`:`mcpConnections.activateAria`,{name:e.label})})]})]},e.key)})})]})]})}Q();function UJ({disabledCollections:r,onChange:i,onConnectionChange:a,readOnly:o=!1,variant:s=`outline`,size:c=`sm`}){let{t:l}=K(),{groups:u,loading:d,statusLoading:f,reload:p}=LJ(),[m,h]=G(!1);if(!d&&u.length===0)return null;let g=BJ(u,r),_=VJ(u,r),v=_.slice(0,2),y=_.length-v.length,b=v.length>0?`${v.join(`, `)}${y>0?` +${y}`:``}`:void 0;return n(e,{children:[n(`div`,{className:`flex min-w-0 items-center gap-2`,children:[b&&t(`span`,{className:`max-w-48 truncate text-muted`,title:_.join(`, `),children:b}),n(oT,{variant:s,size:c,className:`shrink-0`,onClick:()=>h(!0),disabled:d,"aria-label":l(`mcpConnections.manage`),children:[t(`span`,{children:l(`mcpConnections.label`)}),g>0&&t(uT,{variant:`success`,children:g})]})]}),t(HJ,{isOpen:m,onClose:()=>h(!1),groups:u,loading:d,reload:p,statusLoading:f,disabledCollections:r,onChange:i,onConnectionChange:a,readOnly:o})]})}function WJ({disabledCollections:e,onChange:r,onConnectionChange:i,readOnly:a=!1}){let{t:o}=K(),{groups:s,loading:c,statusLoading:l,reload:u}=LJ();if(!c&&s.length===0)return null;let d=()=>{u(),i?.()};return c&&s.length===0?n(`div`,{className:`flex items-center gap-2 border-y border-border/70 py-2 text-sm text-muted`,children:[t(dO,{className:`size-4`}),t(`span`,{children:o(`mcpConnections.label`)})]}):t(`div`,{className:`space-y-1`,children:s.map(i=>{let s=!RJ(i,e),c=i.authStatus?.authenticated===!0,u=i.authType===`oauth`&&i.oauthGrantType!==`client_credentials`;return n(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 py-2 text-sm`,children:[n(`div`,{className:`flex min-w-36 flex-1 items-center gap-2`,children:[t(c?G_:H_,{className:`size-4 shrink-0 ${c?`text-success`:`text-muted`}`,"aria-hidden":`true`}),t(tT,{description:n(`div`,{className:`space-y-0.5`,children:[t(`div`,{className:`font-medium`,children:i.appName}),i.memberNames.length>1&&t(`div`,{className:`text-xs text-muted`,children:i.memberNames.join(` · `)})]}),placement:`top`,asChild:!0,children:t(`span`,{className:`block truncate ${s?`text-foreground`:`text-muted line-through`}`,children:i.label})})]}),u&&l&&!i.authStatus?t(oT,{variant:`outline`,size:`sm`,disabled:!0,className:`h-6 w-32 justify-center px-2 text-xs`,title:o(`mcpConnections.checkingStatus`),children:t(dO,{className:`size-3`})}):u?t(mO,{appId:i.appId,collectionId:i.representativeId,collectionName:i.label,authenticated:i.authStatus?.authenticated,onAuthChange:d,variant:`compact`,showDisconnect:!0,readOnly:a}):t(uT,{variant:`outline`,className:`h-6 w-32 justify-center px-2 text-xs`,children:i.authType===`api_key`?o(`mcpConnections.apiKey`):o(`mcpConnections.managedByApp`)}),r&&n(`div`,{className:`flex min-w-24 items-center justify-end gap-2 text-xs`,children:[t(`span`,{className:s?`text-muted`:`text-attention`,children:o(s?`mcpConnections.enabled`:`mcpConnections.disabled`)}),t(lO,{size:`sm`,value:s,onChange:t=>r(zJ(i,e,t)),disabled:a,"aria-label":o(s?`mcpConnections.deactivateAria`:`mcpConnections.activateAria`,{name:i.label})})]})]},i.key)})})}function GJ({disabledCollections:r,onChange:i,onConnectionChange:a,readOnly:o=!1}){let{t:s}=K(),{groups:c,loading:l,statusLoading:u,reload:d}=LJ(),[f,p]=G(!1);if(!l&&c.length===0)return null;let m=BJ(c,r);return n(e,{children:[t(HD,{align:`left`,trigger:t(oT,{variant:`ghost`,size:`icon`,className:`size-8 rounded-md text-muted hover:bg-muted`,title:s(`mcpConnections.settings`),disabled:l,children:t(`span`,{className:`flex size-5 items-center justify-center rounded-[3px] border border-muted text-sm font-semibold leading-none`,"aria-hidden":`true`,children:`/`})}),children:n(UD,{onClick:()=>p(!0),isDisabled:l,children:[t(`span`,{children:s(`mcpConnections.title`)}),m>0&&t(uT,{variant:`success`,children:m})]})}),t(HJ,{isOpen:f,onClose:()=>p(!1),groups:c,loading:l,reload:d,statusLoading:u,disabledCollections:r,onChange:i,onConnectionChange:a,readOnly:o})]})}const KJ=/(^|\/)(tool-inputs|tool-results|archive)(\/|$)/,qJ=/(^|\/)process\/(history|state)(\/|$)/,JJ=[/conversation\.json$/,/^conversation-checkpoint-\d+\.json$/,/^tools\.json$/,/^tool-input-refs\.json$/,/^toolu[_-]/i];function YJ(e){if(KJ.test(e)||qJ.test(e))return!0;let t=e.split(`/`).pop()??e;return JJ.some(e=>e.test(t))}function XJ(e){let t={name:``,path:``,isDirectory:!0,children:[]};for(let n of e){let e=n.split(`/`),r=t,i=``;for(let t=0;t<e.length;t++){let n=e[t];i=i?`${i}/${n}`:n;let a=t===e.length-1,o=r.children.find(e=>e.name===n);o||(o={name:n,path:i,isDirectory:!a,children:[]},r.children.push(o)),r=o}}let n=e=>{e.children.sort((e,t)=>e.isDirectory===t.isDirectory?e.name.localeCompare(t.name):e.isDirectory?-1:1),e.children.forEach(n)};return n(t),t.children}function ZJ(e,t){let n=`agents/${t}/`,r=e.indexOf(n);return r===-1?e.split(`/`).pop()??e:e.slice(r+n.length)}function QJ(e,t,n=0,r=!1){let[i,a]=G([]),[o,s]=G(!1),[c,l]=G(null),[u,d]=G(0),f=W(0),p=V(async()=>{if(!t)return;let n=++f.current;s(!0),l(null);try{let r=await e.files.listArtifacts(t);if(n!==f.current)return;let i=r.map(e=>ZJ(e,t)).filter(e=>!!e);a(i)}catch(e){if(n!==f.current)return;l(e instanceof Error?e.message:`Failed to list artifacts`),a([])}finally{n===f.current&&s(!1)}},[e,t]);H(()=>{p()},[p,n,u]);let m=U(()=>r?i:i.filter(e=>!YJ(e)),[i,r]),h=U(()=>XJ(m),[m]),g=i.length-m.length,_=V(()=>{d(e=>e+1)},[]);return{tree:h,flatFiles:m,totalCount:i.length,systemHiddenCount:g,isLoading:o,error:c,refresh:_}}function $J(){return eY||=import(`react-pdf`).then(e=>{let{pdfjs:t}=e;return t.GlobalWorkerOptions.workerSrc=`//unpkg.com/pdfjs-dist@${t.version}/build/pdf.worker.min.mjs`,e}),eY}var eY,tY,nY,rY=Y((()=>{tY=ht(()=>$J().then(({Document:e})=>({default:e}))),nY=ht(()=>$J().then(({Page:e})=>({default:e})))}));function iY({className:e,size:n=`md`}){return t(`div`,{className:`flex items-center justify-center ${e||``}`,children:t(ev,{className:`${{sm:`w-4 h-4`,md:`w-6 h-6`,lg:`w-8 h-8`}[n]} animate-spin text-muted`})})}function aY({pdfUrl:e,pageNumber:r,width:i,className:a,renderTextLayer:o=!1,renderAnnotationLayer:s=!1,onLoadSuccess:c,onError:l}){let[u,d]=G(!0),[f,p]=G(null);return f?t(`div`,{className:`flex items-center justify-center text-destructive text-sm ${a||``}`,children:`Failed to load PDF`}):n(`div`,{className:a,children:[u&&t(iY,{className:`py-4`,size:`md`}),t(ut,{fallback:null,children:t(tY,{file:e,onLoadSuccess:({numPages:e})=>{d(!1),c?.(e)},onLoadError:e=>{d(!1),p(e),l?.(e)},loading:null,children:t(nY,{pageNumber:r,width:i,renderTextLayer:o,renderAnnotationLayer:s,loading:t(iY,{className:`py-4`,size:`sm`})})})})]})}function oY({pdfUrl:e,urlLoading:n=!1,children:r,onLoadSuccess:i}){let[a,o]=G(0),[s,c]=G(!0),[l,u]=G(null),[d,f]=G(null),p=async e=>{o(e.numPages),i?.(e.numPages);try{let t=(await e.getPage(1)).getViewport({scale:1});f({width:t.width,height:t.height,aspectRatio:t.width/t.height})}catch(e){console.error(`Failed to get page dimensions:`,e)}c(!1)},m=e=>{c(!1),u(e)},h={pdfUrl:e,numPages:a,loading:n||!e||s,error:l,pageDimensions:d};return l?t(`div`,{className:`flex items-center justify-center text-destructive text-sm py-4`,children:`Failed to load PDF`}):t(pY.Provider,{value:h,children:e?t(ut,{fallback:t(iY,{className:`py-4`,size:`md`}),children:t(tY,{file:e,onLoadSuccess:p,onLoadError:m,loading:t(iY,{className:`py-4`,size:`md`}),children:r((e,n)=>t(nY,{pageNumber:e,width:n,renderTextLayer:!1,renderAnnotationLayer:!1,loading:t(iY,{className:`py-4`,size:`sm`})},e))})}):t(iY,{className:`py-4`,size:`md`})})}function sY(){return _t(pY)}function cY({pageNumber:e,width:n,className:r}){let i=sY(),a=i?.pageDimensions?.aspectRatio??mY,o=n?Math.round(n/a):200;return i?.loading?t(`div`,{className:`flex items-center justify-center bg-muted ${r||``}`,style:{height:o,width:n||`100%`},children:t(iY,{size:`md`})}):t(`div`,{className:r,children:t(nY,{pageNumber:e,width:n,renderTextLayer:!1,renderAnnotationLayer:!1,loading:t(iY,{className:`py-4`,size:`sm`})})})}function lY({pageNumber:e,width:n,isSelected:r,onSelect:i,renderThumbnail:a,aspectRatio:o=mY,rootMargin:s=`200px 0px`}){let c=W(null),[l,u]=G(!1);H(()=>{let e=c.current;if(!e)return;let t=new IntersectionObserver(e=>{e[0]?.isIntersecting&&u(!0)},{rootMargin:s,threshold:0});return t.observe(e),()=>t.disconnect()},[s]);let d=n?Math.round(n/o):200,f=l?t(nY,{pageNumber:e,width:n,renderTextLayer:!1,renderAnnotationLayer:!1,loading:t(`div`,{className:`flex items-center justify-center bg-muted`,style:{height:d},children:t(iY,{size:`sm`})})}):t(`div`,{className:`flex items-center justify-center bg-muted`,style:{height:d,width:n||`100%`},children:t(`span`,{className:`text-muted text-xs`,children:e})});return t(`div`,{ref:c,children:a({pageNumber:e,isSelected:r,pageElement:f,onSelect:i})})}function uY(e){if(!e)return null;let t=e.parentElement;for(;t;){let e=window.getComputedStyle(t).overflowY;if(e===`auto`||e===`scroll`)return t;t=t.parentElement}return null}function dY({pdfUrl:r,urlLoading:i=!1,pageCount:a,currentPage:o,thumbnailWidth:s,onPageSelect:c,renderThumbnail:l,scrollContainerRef:u,onAspectRatioChange:d,onItemHeightChange:f,calculateItemHeight:p,onPageCountChange:m}){let[h,g]=G(null),[_,v]=G({start:0,end:Math.min(15,a)}),[y,b]=G(null),x=W(null),S=V(e=>{g(e)},[]),C=V(async e=>{m?.(e.numPages);try{let t=(await e.getPage(1)).getViewport({scale:1}),n=t.width/t.height;b(n),d?.(n)}catch(e){console.error(`Failed to get page dimensions:`,e),b(mY),d?.(mY)}},[d,m]),w=y??mY,T=s?Math.round(s/w):200,E=p?p(T):T+16+24+8;if(H(()=>{E>0&&y!==null&&f?.(E)},[E,y,f]),H(()=>{let e=u?.current||uY(x.current);if(!e)return;let t=()=>{let t=e.scrollTop,n=e.clientHeight,r=Math.floor(t/E),i=Math.ceil((t+n)/E),o=Math.max(0,r-5),s=Math.min(a,i+5);v(e=>e.start!==o||e.end!==s?{start:o,end:s}:e)};return t(),e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[E,a,u]),h)return t(`div`,{className:`flex items-center justify-center text-destructive text-sm py-4`,children:`Failed to load PDF`});if(i||!r)return t(iY,{className:`py-4`,size:`md`});let D=_.start*E,O=(a-_.end)*E,k=y!==null;return t(`div`,{ref:x,children:t(ut,{fallback:t(iY,{className:`py-4`,size:`md`}),children:t(tY,{file:r,onLoadSuccess:C,onLoadError:S,loading:t(iY,{className:`py-4`,size:`md`}),children:k?n(e,{children:[D>0&&t(`div`,{style:{height:D}}),Array.from({length:_.end-_.start},(e,n)=>{let r=_.start+n+1;return t(`div`,{"data-page-index":r-1,style:{height:E,overflow:`hidden`},children:t(lY,{pageNumber:r,width:s,isSelected:r===o,onSelect:()=>c(r),renderThumbnail:l,aspectRatio:w})},r)}),O>0&&t(`div`,{style:{height:O}})]}):t(iY,{className:`py-4`,size:`md`})})})})}function fY({pdfUrl:e,pageNumber:r,width:i,height:a,className:o,renderTextLayer:s=!1,renderAnnotationLayer:c=!1,onPageChange:l}){let[u,d]=G(0),[f,p]=G(!0),[m,h]=G(null);return H(()=>{u>0&&l?.(r,u)},[r,u,l]),m?t(`div`,{className:`flex items-center justify-center text-destructive ${o||``}`,children:n(`span`,{children:[`Failed to load PDF: `,m.message]})}):n(`div`,{className:o,children:[f&&t(iY,{className:`py-8`,size:`lg`}),t(ut,{fallback:null,children:t(tY,{file:e,onLoadSuccess:({numPages:e})=>{d(e),p(!1)},onLoadError:e=>{p(!1),h(e)},loading:null,children:t(nY,{pageNumber:Math.min(r,u||1),width:i,height:a,renderTextLayer:s,renderAnnotationLayer:c,loading:t(iY,{className:`py-8`,size:`md`})})})})]})}var pY,mY,hY=Y((()=>{Q(),rY(),pY=dt(null),mY=210/297}));function gY({pdfUrl:r,pdfUrlLoading:i=!1,pageCount:a,currentPage:s,onChange:c,onPageCountChange:l,className:u,compact:d=!1,headerExtra:f}){let{t:m}=K(),h=W(null),g=W(null),[_,v]=G(void 0),[y,b]=G(xY),[x,S]=G(yY),[C,w]=G(null),T=W(null),E=_?Math.round(_*y/100):void 0,D=V(()=>{let e=bY.findIndex(e=>e>=y);e===-1&&(e=bY.length-1);let t=Math.min(e+1,bY.length-1);b(bY[t])},[y]),O=V(()=>{let e=bY.findIndex(e=>e>=y);e===-1&&(e=bY.length-1);let t=Math.max(e-1,0);b(bY[t])},[y]),k=V(()=>{b(xY)},[]),A=V(e=>e+(d?28:48),[d]),j=V((e,t)=>{let n=e?Math.round(e/t):200;return A(n)},[A]);H(()=>{let e=g.current;if(!e)return;let t=null,n=()=>e.clientWidth-16-16-4,r=()=>{let t=n();if(t<=0)return;let r=T.current;if(r&&r>0){let n=e.scrollTop,i=Math.round(n/r),a=j(t,x),o=i*a;v(t),requestAnimationFrame(()=>{e.scrollTo({top:o,behavior:`instant`})}),T.current=a}else v(t),T.current=j(t,x)},i=n();i>0&&(v(i),T.current=j(i,x));let a=new ResizeObserver(()=>{t&&clearTimeout(t),t=setTimeout(r,150)});return a.observe(e),()=>{t&&clearTimeout(t),a.disconnect()}},[x,j]);let M=W(!1),N=W(null),P=W(y);H(()=>{P.current!==y&&(P.current=y,N.current={targetPage:s},M.current=!0)},[y,s]),H(()=>{let e=g.current,t=N.current;if(t&&e&&C){N.current=null;let n=(t.targetPage-1)*C;requestAnimationFrame(()=>{e.scrollTo({top:n,behavior:`instant`}),requestAnimationFrame(()=>{M.current=!1})})}},[C]);let F=W(!1);H(()=>{let e=g.current;if(!(!e||!C||F.current)){if(s>1){F.current=!0,M.current=!0;let t=(s-1)*C;e.scrollTo({top:t,behavior:`instant`}),requestAnimationFrame(()=>{M.current=!1})}else F.current=!0}},[C,s]);let I=W(s);return H(()=>{let e=g.current;if(!(!e||!C)&&I.current!==s){I.current=s,M.current=!0;let t=(s-1)*C;e.scrollTo({top:t,behavior:`instant`}),requestAnimationFrame(()=>{M.current=!1})}},[s,C]),H(()=>{let e=g.current;if(!e||!C)return;let t=null,n=()=>{M.current||(t&&clearTimeout(t),t=setTimeout(()=>{let t=e.scrollTop,n=Math.round(t/C)+1,r=Math.max(1,Math.min(n,a));r!==s&&(I.current=r,c(r))},50))};return e.addEventListener(`scroll`,n,{passive:!0}),()=>{t&&clearTimeout(t),e.removeEventListener(`scroll`,n)}},[C,a,s,c]),n(`div`,{ref:h,className:it(`flex flex-col items-stretch`,d?`gap-y-1`:`gap-y-2`,u),children:[n(`div`,{className:it(`relative flex items-center justify-center px-2`,d?`h-6`:`h-9`),children:[t(o,{variant:`ghost`,size:`xs`,onClick:()=>{s>1&&c(s-1)},title:m(`pdf.previousPage`),children:t(Dh,{className:`size-4`})}),n(`div`,{className:`absolute start-2 flex items-center gap-x-1`,children:[t(vY,{zoom:y,onZoomIn:D,onZoomOut:O,onFitToView:k,canZoomIn:y<bY[bY.length-1],canZoomOut:y>bY[0]}),f&&n(e,{children:[t(`div`,{className:`w-px h-4 bg-border mx-1`}),f]})]}),t(`div`,{className:`absolute end-2`,children:t(_Y,{currentPage:s,totalPages:a,onChange:c})})]}),t(`div`,{ref:g,className:it(`flex flex-col items-center flex-1 overflow-y-auto px-2`,d?`gap-1`:`gap-2`),children:t(dY,{pdfUrl:r,urlLoading:i,pageCount:a,currentPage:s,thumbnailWidth:E,onPageSelect:c,onPageCountChange:l,scrollContainerRef:g,onAspectRatioChange:S,onItemHeightChange:w,calculateItemHeight:A,renderThumbnail:({pageNumber:e,isSelected:r,pageElement:i,onSelect:a})=>n(`div`,{className:it(`hover:bg-muted rounded-md w-full`,d?`p-1`:`p-2`),children:[t(o,{variant:`unstyled`,size:`none`,"aria-pressed":r,"aria-label":`Page ${e}`,className:it(`relative border-[2px] cursor-pointer overflow-hidden`,r?`border-primary`:`border-border`),onClick:a,children:i}),t(p,{className:it(`text-muted font-semibold`,d?`text-xs pt-0.5`:`text-sm pt-1`),children:e})]},e)})}),t(`div`,{className:it(`flex items-center justify-center`,d?`h-6`:`h-9`),children:t(o,{variant:`ghost`,size:`xs`,onClick:()=>{s<a&&c(s+1)},title:m(`pdf.nextPage`),children:t(hh,{className:`size-4`})})})]})}function _Y({currentPage:e,totalPages:r,onChange:i}){let{t:a}=K(),o=W(null),[s,c]=G(String(e));H(()=>{c(String(e))},[e]);let l=()=>{let t=parseInt(s,10);!Number.isNaN(t)&&t>=1&&t<=r?i(t):c(String(e))};return n(`div`,{className:`flex items-center gap-1 text-xs text-muted`,children:[t(`span`,{children:a(`pdf.page`)}),t(`input`,{ref:o,type:`text`,value:s,onChange:e=>c(e.target.value),onKeyDown:t=>{t.key===`Enter`?(l(),o.current?.blur()):t.key===`Escape`&&(c(String(e)),o.current?.blur())},onBlur:()=>{l()},className:`w-8 h-5 text-center text-xs px-1 py-0 bg-background border border-border rounded focus:outline-none focus:border-primary`}),n(`span`,{children:[`/ `,r]})]})}function vY({zoom:e,onZoomIn:r,onZoomOut:i,onFitToView:a,canZoomIn:s,canZoomOut:c}){let{t:l}=K();return n(`div`,{className:`flex items-center gap-x-0.5`,children:[t(o,{variant:`ghost`,size:`xs`,onClick:i,isDisabled:!c,title:l(`pdf.zoomOut`),children:t(Av,{})}),n(`span`,{className:`text-xs text-muted min-w-[32px] text-center`,children:[e,`%`]}),t(o,{variant:`ghost`,size:`xs`,onClick:r,isDisabled:!s,title:l(`pdf.zoomIn`),children:t(oy,{})}),t(o,{variant:`ghost`,size:`xs`,onClick:a,title:l(`pdf.fitToWidth`),className:e===xY?`text-muted/40`:void 0,children:t(fv,{})})]})}var yY,bY,xY,SY=Y((()=>{Q(),hY(),yY=210/297,bY=[50,75,100,125,150,200,300],xY=100}));function CY({object:e,url:r,source:i,className:a}){let{t:s}=K(),{client:c}=q(),[l,u]=G(1),[d,f]=G(r||``),[p,m]=G(!r),[h,g]=G(0),[_,v]=G(!1);H(()=>{if(r){f(r),m(!1);return}let t=i||e?.content?.source;if(!t){m(!1);return}m(!0),c.files.getDownloadUrl(t).then(e=>{f(e.url)}).catch(e=>{console.error(`Failed to get PDF URL:`,e)}).finally(()=>{m(!1)})},[r,i,e?.content?.source,c]),H(()=>{let t=e?.metadata,n=t?.pages||t?.page_count||0;n>0&&g(n)},[e?.metadata]);let y=e=>{g(e)};return p?t(`div`,{className:`flex items-center justify-center h-full`,children:t(je,{size:`lg`})}):d?_?n(`div`,{className:`fixed inset-0 bg-background z-50 flex flex-col overflow-hidden`,children:[t(`div`,{className:`flex h-9 items-center justify-end shrink-0 bg-sidebar px-2 border-b border-sidebar-border`,children:t(o,{variant:`ghost`,size:`xs`,onClick:()=>v(!1),title:s(`pdf.closeFullscreen`),children:t(Gb,{className:`size-4`})})}),t(gY,{pdfUrl:d,pdfUrlLoading:p,pageCount:h||100,currentPage:l,onChange:u,onPageCountChange:y,className:`flex-1 min-h-0`})]}):t(`div`,{className:`relative h-full flex flex-col`,children:t(gY,{pdfUrl:d,pdfUrlLoading:p,pageCount:h||100,currentPage:l,onChange:u,onPageCountChange:y,className:a,compact:!0,headerExtra:t(o,{title:s(`pdf.fullscreen`),tooltipPlacement:`bottom`,variant:`unstyled`,className:`p-1 rounded cursor-pointer transition-colors text-muted hover:text-foreground hover:bg-muted`,onClick:()=>v(!0),children:t(lv,{className:`size-4`})})})}):t(`div`,{className:`flex items-center justify-center h-full text-muted`,children:s(`pdf.noPdfAvailable`)})}var wY=Y((()=>{Q(),SY()})),TY=mr({UniversalDocumentViewer:()=>XY});function EY(e){return e.fileName||e.title||e.artifact?.path.split(`/`).pop()||e.sourcePath?.split(`/`).pop()||`Document`}function DY(e){let t=e.split(`?`)[0]||e;return t.includes(`.`)&&t.split(`.`).pop()?.toLowerCase()||``}function OY(e){return e.contentType===`application/pdf`||e.extension===`pdf`}function kY(e){return[`md`,`markdown`].includes(e.extension)||[`text/markdown`,`text/x-markdown`].includes(e.contentType||``)}function AY(e){return e.contentType?.startsWith(`image/`)||[`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`].includes(e.extension)}function jY(e){return e.contentType===`text/html`||[`html`,`htm`].includes(e.extension)}function MY(e){return[`application/xml`,`text/xml`].includes(e.contentType||``)||e.extension===`xml`}function NY(e){return e.contentType?.startsWith(`text/`)||[`css`,`csv`,`json`,`txt`,`tsx`,`ts`,`jsx`,`js`,`xml`,`yaml`,`yml`].includes(e.extension)}function PY(e){return[`tsx`,`jsx`].includes(e.extension)}function FY(e){return[`doc`,`docx`,`ppt`,`pptx`].includes(e.extension)||[`application/msword`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,`application/vnd.ms-powerpoint`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`].includes(e.contentType||``)}function IY({content:e,extension:n}){return t(`pre`,{className:`h-full overflow-auto rounded-md bg-muted/10 p-3 text-xs leading-5`,children:t(`code`,{className:n?`language-${n}`:void 0,children:e||``})})}function LY({message:e}){return n(`div`,{className:`flex h-full min-h-64 flex-col items-center justify-center gap-2 text-muted`,children:[t(Zg,{className:`size-8`}),t(`span`,{className:`text-sm`,children:e})]})}function RY(e,n){if(e.Component){let r=e.Component;return t(r,{context:n})}return e.render?.(n)??null}function zY(e,t){return e.includes(`.`)?e.replace(/\.[^/.]+$/,t):`${e}${t}`}function BY(e){return e.split(`/`).pop()||e}function VY(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function HY(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function UY(e){if(e!==void 0)return e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(+(e<1e4))} s`}function WY(e){return Array.isArray(e)?e.length:0}function GY(e){try{let t=VY(JSON.parse(e));if(!t)return;let n=VY(t.viewport);return{ok:typeof t.ok==`boolean`?t.ok:void 0,source_artifact:typeof t.source_artifact==`string`?t.source_artifact:void 0,screenshot_artifact:typeof t.screenshot_artifact==`string`?t.screenshot_artifact:void 0,rendered_at:typeof t.rendered_at==`string`?t.rendered_at:void 0,viewport:n?{width:HY(n.width),height:HY(n.height)}:void 0,dependencies_reused:typeof t.dependencies_reused==`boolean`?t.dependencies_reused:void 0,status:HY(t.status),title:typeof t.title==`string`?t.title:void 0,console_errors:Array.isArray(t.console_errors)?t.console_errors:void 0,page_errors:Array.isArray(t.page_errors)?t.page_errors:void 0,failed_requests:Array.isArray(t.failed_requests)?t.failed_requests:void 0,bad_responses:Array.isArray(t.bad_responses)?t.bad_responses:void 0,timings_ms:VY(t.timings_ms),error:t.error}}catch{return}}async function KY(e,t){let n=await fetch(e);if(!n.ok)throw Error(`Failed to load ${t}: ${n.statusText}`);return n.text()}function qY({metadata:e,sourcePath:t,fallbackPath:n,artifactMode:r}){let i=e?.screenshot_artifact?.replace(/^\/+/,``);if(!i)return n;if(r)return i;let a=e?.source_artifact?.replace(/^\/+/,``),o=t.replace(/^\/+/,``);if(a&&o.endsWith(a)){let e=o.slice(0,-a.length).replace(/\/+$/,``);return e?`${e}/${i}`:i}let s=o.includes(`/`)?o.slice(0,o.lastIndexOf(`/`)+1):``;return s?`${s}${BY(i)}`:n}function JY({metadata:e}){if(!e)return null;let r=HY(e.timings_ms?.total_before_cleanup),a=WY(e.console_errors)+WY(e.page_errors)+WY(e.failed_requests)+WY(e.bad_responses);return n(`div`,{className:`grid gap-2 border-b p-3 text-xs`,children:[n(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.ok!==void 0&&t(i,{variant:e.ok?`success`:`destructive`,children:e.ok?`render ok`:`render failed`}),e.dependencies_reused!==void 0&&n(i,{variant:e.dependencies_reused?`info`:`secondary`,children:[`deps `,e.dependencies_reused?`reused`:`installed`]}),e.status&&n(i,{variant:`secondary`,children:[`HTTP `,e.status]}),a>0&&n(i,{variant:`attention`,children:[a,` browser issue(s)`]})]}),n(`div`,{className:`grid gap-1 text-muted sm:grid-cols-2`,children:[e.viewport?.width&&e.viewport.height&&n(`div`,{children:[`Viewport `,e.viewport.width,` x `,e.viewport.height]}),UY(r)&&n(`div`,{children:[`Total `,UY(r)]}),e.rendered_at&&n(`div`,{children:[`Rendered `,new Date(e.rendered_at).toLocaleString()]}),e.title&&n(`div`,{className:`truncate`,children:[`Title `,e.title]})]}),typeof e.error==`string`&&t(`div`,{className:`text-destructive`,children:e.error})]})}function YY({context:e}){let{client:r}=q(),a=e.source.artifact,o=a?.path||e.source.sourcePath,s=!!a,c=e.content||``,[l,u]=G({isLoading:!1}),d=V(async(e,t)=>a?(await r.files.getArtifactDownloadUrl(a.runId,e,t)).url:(await r.files.getDownloadUrl(e,BY(e),t)).url,[a,r]);return H(()=>{if(!o){u({isLoading:!1,previewError:`No source path is available for this TSX artifact.`});return}let e=o,t=!1,n=zY(e,`.png`),r=zY(e,`.render.json`);async function i(){u({isLoading:!0});let i,a,o=n;try{i=GY(await KY(await d(r,`inline`),BY(r))),o=qY({metadata:i,sourcePath:e,fallbackPath:n,artifactMode:s})}catch(e){a=e instanceof Error?e.message:`Render metadata is not available`}let c,l;try{c=await d(o,`inline`)}catch(e){l=e instanceof Error?e.message:`Sandbox render image is not available`}t||u({isLoading:!1,imageUrl:c,metadata:i,metadataError:a,previewError:l})}return i(),()=>{t=!0}},[s,d,o]),n(`div`,{className:`flex h-full min-h-0 flex-col`,children:[n(`div`,{className:`flex min-h-10 flex-wrap items-center gap-2 border-b px-3 py-2 text-sm`,children:[t(D_,{className:`size-4 text-info`}),t(`span`,{className:`font-medium`,children:`Sandbox render`}),l.isLoading?t(i,{variant:`secondary`,children:`loading`}):l.imageUrl?t(i,{variant:`success`,children:`PNG preview`}):t(i,{variant:`attention`,children:`source only`}),l.metadata?.rendered_at&&t(`span`,{className:`text-xs text-muted`,children:new Date(l.metadata.rendered_at).toLocaleString()})]}),l.isLoading?n(`div`,{className:`flex h-full min-h-64 items-center justify-center gap-2 text-muted`,children:[t(ev,{className:`size-5 animate-spin`}),t(`span`,{className:`text-sm`,children:`Loading sandbox render...`})]}):l.imageUrl?n(`div`,{className:`grid min-h-0 flex-1 xl:grid-cols-[minmax(0,1fr)_minmax(24rem,0.7fr)]`,children:[t(`div`,{className:`flex min-h-0 items-center justify-center overflow-auto bg-muted/10 p-3`,children:t(`img`,{src:l.imageUrl,alt:`${e.fileName} sandbox render`,className:`max-h-full max-w-full rounded-md object-contain`})}),n(`div`,{className:`min-h-0 overflow-auto border-t xl:border-s xl:border-t-0`,children:[t(JY,{metadata:l.metadata}),t(`div`,{className:`p-3`,children:t(IY,{content:c,extension:e.extension})})]})]}):n(`div`,{className:`grid min-h-0 flex-1 grid-rows-[auto_minmax(0,1fr)]`,children:[n(`div`,{className:`border-b px-3 py-2 text-xs text-muted`,children:[`No sandbox-rendered PNG was found for this TSX artifact. Showing the source without executing it in Studio.`,l.previewError&&n(`span`,{className:`ms-1`,children:[`Preview lookup: `,l.previewError]}),!l.previewError&&l.metadataError&&n(`span`,{className:`ms-1`,children:[`Metadata lookup: `,l.metadataError]})]}),n(`div`,{className:`min-h-0 overflow-auto p-3`,children:[t(JY,{metadata:l.metadata}),t(IY,{content:c,extension:e.extension})]})]})]})}function XY({source:e,className:r,bodyClassName:i,renderers:a=[],converters:s=[],resolveUrl:c,loadText:l,createRendition:u,markdownComponents:d,showHeader:f=!1,onDownload:p}){let{client:m}=q(),h=U(()=>EY(e),[e]),g=U(()=>DY(h),[h]),[_,v]=G(e.url),[y,b]=G(e.content),[x,S]=G(null),[C,w]=G(!1),[T,E]=G(null),[D,O]=G(0),k=[e.id,e.title,e.fileName,e.contentType,e.url,e.sourcePath,e.content,e.artifact?.runId,e.artifact?.path].join(`\0`),A=V(async(e,t)=>e.url?e.url:e.artifact?(await m.files.getArtifactDownloadUrl(e.artifact.runId,e.artifact.path,t)).url:e.sourcePath?(await m.files.getDownloadUrl(e.sourcePath,e.fileName,t)).url:``,[m]),j=c||A,M=V(async e=>{if(e.content!==void 0)return e.content;let t=await j(e,`inline`);if(!t)return``;let n=await fetch(t);if(!n.ok)throw Error(`Failed to load ${EY(e)}: ${n.statusText}`);return n.text()},[j]),N=l||M,P={source:e,fileName:h,extension:g,contentType:e.contentType||x?.contentType,url:x?.url||_,content:x?.content||y,isLoading:C,error:T,reload:()=>O(e=>e+1)},F=a.find(e=>e.canRender(P)),I=!F&&(kY(P)||jY(P)||MY(P)||NY(P)),L=!F&&(OY(P)||AY(P)),ee={source:e,fileName:h,extension:g,contentType:e.contentType,target:`pdf`},R=!F&&!P.url?s.find(e=>e.target===`pdf`&&e.canConvert(ee)):void 0,te=!F&&!P.url&&(FY(P)||!!R)&&(!!R||!!u);H(()=>{let t=!1,n=e;E(null),v(n.url),b(n.content),S(null);async function r(){if(!(!I&&!L&&!te)){w(!0);try{if(te){let e=R?await R.convert({source:n,fileName:h,extension:g,contentType:n.contentType,target:`pdf`}):await u?.(n,`pdf`);t||S(e??null);return}if(I){let e=await N(n);t||b(e);return}if(L){let e=await j(n,`inline`);t||v(e)}}catch(e){t||E(e instanceof Error?e.message:`Failed to load document`)}finally{t||w(!1)}}}return r(),()=>{t=!0}},[u,g,h,N,te,I,L,D,j,R,e,k]);let ne={...P,url:x?.url||_,content:x?.content||y,contentType:x?.contentType||e.contentType,isLoading:C,error:T},re;return re=C?n(`div`,{className:`flex h-full min-h-64 items-center justify-center gap-2 text-muted`,children:[t(ev,{className:`size-5 animate-spin`}),t(`span`,{className:`text-sm`,children:`Loading preview...`})]}):T?n(`div`,{className:`flex h-full min-h-64 flex-col items-center justify-center gap-2 text-destructive`,children:[t(Ah,{className:`size-7`}),t(`span`,{className:`max-w-xl text-center text-sm`,children:T}),t(o,{variant:`outline`,size:`sm`,onClick:ne.reload,children:`Retry`})]}):F?RY(F,ne):(OY(ne)||x?.contentType===`application/pdf`)&&ne.url?t(CY,{url:ne.url,className:`h-full`}):AY(ne)&&ne.url?t(`div`,{className:`flex h-full min-h-0 items-center justify-center overflow-auto bg-muted/10 p-3`,children:t(`img`,{src:ne.url,alt:h,className:`max-h-full max-w-full rounded-md object-contain`})}):kY(ne)?t(`div`,{className:`prose prose-sm dark:prose-invert max-w-none px-5 py-4`,children:t(Nt,{artifactRunId:e.artifact?.runId,components:d,children:ne.content||``})}):jY(ne)?t(`iframe`,{title:h,className:`h-full min-h-96 w-full bg-white`,sandbox:``,srcDoc:ne.content||``}):MY(ne)?t(`div`,{className:`px-4 py-2`,children:t(Rt,{xml:ne.content||``,collapsible:!0})}):PY(ne)?t(YY,{context:ne}):NY(ne)?t(IY,{content:ne.content,extension:g}):FY(ne)&&!R&&!u?t(LY,{message:`This file needs a PDF rendition before it can be previewed.`}):t(LY,{message:`Preview is not available for this file type.`}),n(`div`,{className:z(`flex h-full min-h-0 flex-col overflow-hidden`,r),children:[f&&n(`div`,{className:`flex min-h-10 items-center justify-between gap-3 border-b py-2 ps-3 pe-16`,children:[n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`truncate text-sm font-medium`,title:h,children:h}),ne.contentType&&t(`div`,{className:`truncate text-xs text-muted`,children:ne.contentType})]}),p&&t(o,{variant:`outline`,size:`sm`,onClick:()=>p(e),children:`Download`})]}),t(`div`,{className:z(`min-h-0 flex-1 overflow-auto`,i),children:re})]})}var ZY=Y((()=>{Q(),wY()}));Q();const QY=ot.lazy(async()=>({default:(await Promise.resolve().then(()=>(ZY(),TY))).UniversalDocumentViewer})),$Y=new Set([`md`,`markdown`,`mdx`,`txt`]);function eX(e){let t=e.split(`.`).pop()?.toLowerCase();return t!==void 0&&$Y.has(t)}function tX(e){return e.replace(/[_-]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function nX({node:e,depth:r,runId:i,onOpen:a,onDownload:s,downloadingPath:c,forceExpanded:l=!1}){let{t:u}=K(),[d,f]=G(!1),p=l||d;if(e.isDirectory)return n(`div`,{className:`min-w-0`,children:[n(o,{variant:`unstyled`,className:`flex w-full max-w-full items-center justify-start gap-1.5 rounded px-1 py-1 text-start text-sm hover:bg-muted/30`,style:{paddingInlineStart:`${r*14+4}px`},onClick:()=>f(e=>!e),"aria-expanded":p,children:[p?t(rh,{className:`size-3.5 shrink-0 text-muted`}):t(lh,{className:`size-3.5 shrink-0 text-muted cn-rtl-flip`}),t(p?r_:o_,{className:`size-4 shrink-0 text-info`}),t(`span`,{className:`min-w-0 truncate font-medium`,title:e.path,children:tX(e.name)})]}),p&&e.children.map(e=>t(nX,{node:e,depth:r+1,runId:i,onOpen:a,onDownload:s,downloadingPath:c,forceExpanded:l},`${i}:${e.path}`))]});let m=c===e.path;return n(`div`,{className:`flex min-w-0 items-center gap-1`,children:[n(o,{variant:`unstyled`,className:`flex min-w-0 flex-1 items-center justify-start gap-1.5 rounded px-1 py-1 text-start text-sm hover:bg-muted/30`,style:{paddingInlineStart:`${r*14+4}px`},onClick:()=>a(e.path),title:e.path,children:[t(`span`,{className:`size-3.5 shrink-0`}),t(Zg,{className:`size-4 shrink-0 text-muted`}),t(`span`,{className:`min-w-0 truncate`,children:e.name})]}),t(o,{variant:`ghost`,size:`sm`,className:`h-7 w-7 shrink-0 p-0`,onClick:()=>s(e.path),disabled:m,"aria-label":u(`agent.download`),title:u(`agent.download`),children:m?t(ev,{className:`size-3.5 animate-spin text-info`}):t(xg,{className:`size-3.5`})})]})}function rX(e){return e.reduce((e,t)=>t.isDirectory?e+rX(t.children):e+1,0)}function iX(e,t){let n=t.trim().toLocaleLowerCase();return n?e.flatMap(e=>{let t=`${e.name} ${e.path}`.toLocaleLowerCase().includes(n);if(!e.isDirectory)return t?[e]:[];let r=iX(e.children,n);return t?[{...e}]:r.length>0?[{...e,children:r}]:[]}):e}function aX(e,t){let n=document.createElement(`a`);n.href=e,n.download=t,n.rel=`noopener noreferrer`,n.style.display=`none`,document.body.appendChild(n),n.click(),n.remove()}function oX(e){switch(e.split(`.`).pop()?.toLowerCase()){case`css`:return`text/css`;case`gif`:return`image/gif`;case`htm`:case`html`:return`text/html`;case`jpeg`:case`jpg`:return`image/jpeg`;case`json`:return`application/json`;case`md`:case`markdown`:return`text/markdown`;case`pdf`:return`application/pdf`;case`png`:return`image/png`;case`svg`:return`image/svg+xml`;case`ts`:case`tsx`:return`text/typescript`;case`txt`:return`text/plain`;case`webp`:return`image/webp`;default:return}}function sX({runId:e,path:r,onBack:i,onDownload:a,refreshKey:s,refreshDetails:c,onSendMessage:l}){let{t:u}=K(),[d,f]=G(`components`),[p,m]=G(`idle`);return n(`div`,{className:`flex h-full min-h-0 flex-col`,children:[n(`div`,{className:`flex shrink-0 items-center gap-1 border-b border-border/60 px-2 py-1`,children:[t(o,{variant:`ghost`,size:`sm`,className:`size-8 shrink-0 rounded-md p-0`,onClick:i,"aria-label":u(`agent.backToArtifacts`),title:u(`agent.backToArtifacts`),children:t(wm,{className:`size-4 cn-rtl-flip`})}),n(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[t(`span`,{className:`truncate text-sm font-medium`,title:r,children:r.split(`/`).pop()}),p===`saving`?t(We,{description:u(`agent.savingWorkingCopy`),asChild:!0,children:t(ev,{className:`size-3.5 shrink-0 animate-spin text-muted`,"aria-label":u(`agent.savingWorkingCopy`)})}):p===`saved`?t(We,{description:u(`agent.savedToWorkingCopy`),asChild:!0,children:t(eh,{className:`size-3.5 shrink-0 text-success`,"aria-label":u(`agent.savedToWorkingCopy`)})}):null]}),n(`div`,{className:`flex items-center gap-0.5`,children:[t(o,{variant:d===`components`?`primary`:`ghost`,size:`sm`,className:`size-8 shrink-0 rounded-md p-0`,onClick:()=>f(`components`),"aria-label":u(`agent.blockMode`),"aria-pressed":d===`components`,title:u(`agent.blockMode`),children:t(xy,{className:`size-4`})}),t(o,{variant:d===`document`?`primary`:`ghost`,size:`sm`,className:`size-8 shrink-0 rounded-md p-0`,onClick:()=>f(`document`),"aria-label":u(`agent.editMode`),"aria-pressed":d===`document`,title:u(`agent.editMode`),children:t(Jv,{className:`size-4`})})]}),t(o,{variant:`ghost`,size:`sm`,className:`size-8 shrink-0 rounded-md p-0`,onClick:()=>a(r),"aria-label":u(`agent.download`),title:u(`agent.download`),children:t(xg,{className:`size-4`})})]}),t(wt,{runId:e,path:r,viewMode:d,refreshKey:s,refreshDetails:c,readOnly:!l,onAction:e=>{if(!l)return;let t=e.anchor.block_type.replaceAll(`_`,` `);l(e.comment?.trim()||u(`agent.editedSelectionMessage`,{blockType:t}),{editing_action:e})},onSaveStatusChange:m,onSendMessage:l?e=>l(e):void 0,className:z(`relative min-h-0 flex-1`,d===`document`?`overflow-hidden`:`overflow-y-auto px-6 py-5`)})]})}function cX({icon:e,children:r,action:i}){return n(p,{className:`h-full min-h-[240px] flex-col text-center text-muted`,children:[e,t(`span`,{className:`text-sm`,children:r}),i]})}function lX({runId:r,refreshKey:i=0,refreshDetails:a,selectedPath:s,onSelectedPathChange:c,onSendMessage:l}){let{t:u}=K(),{client:d}=q(),[f,m]=G(!1),{tree:h,flatFiles:g,totalCount:_,systemHiddenCount:v,isLoading:y,error:b,refresh:x}=QJ(d,r,i,f),[S,C]=G(null),[w,T]=G(null),[E,D]=G(``),[O,k]=G(null),A=s===void 0?O:s,j=V(e=>{s===void 0&&k(e),c?.(e)},[c,s]),N=E.trim(),P=U(()=>iX(h,N),[h,N]),F=U(()=>rX(P),[P]),I=vt(),L=V(async e=>{if(r){C(e);try{let{url:t}=await d.files.getArtifactDownloadUrl(r,e,`attachment`);aX(t,e.split(`/`).pop()||`artifact`)}catch(e){console.error(`Failed to get artifact download URL:`,e)}finally{C(null)}}},[d,r]),ee=V(e=>{if(eX(e)){j(e);return}T(e)},[j]),R=r&&w?{title:w.split(`/`).pop()||w,fileName:w.split(`/`).pop()||w,contentType:oX(w),artifact:{runId:r,path:w}}:null;return r?y&&_===0?t(cX,{icon:t(ev,{className:`mb-2 size-6 animate-spin`}),children:u(`agent.loadingArtifacts`)}):b?t(`div`,{className:`flex flex-col items-center justify-center p-4 text-muted w-full`,children:n(M,{title:`Fail to load Artifacts`,className:`w-full`,action:x,actionLabel:n(e,{children:[t(hy,{className:`size-3.5 me-1.5`}),u(`agent.retry`)]}),children:[t(`span`,{className:`break-all text-muted`,children:b}),` `,t(`br`,{})]})}):_===0?t(cX,{icon:t(Iv,{className:`mb-2 size-8`}),action:n(o,{variant:`ghost`,size:`sm`,className:`mt-2`,onClick:x,children:[t(hy,{className:`size-3.5 me-1.5`}),u(`agent.refresh`)]}),children:u(`agent.noArtifactsYet`)}):A?t(sX,{runId:r,path:A,refreshKey:i,refreshDetails:a,onBack:()=>j(null),onDownload:e=>void L(e),onSendMessage:l}):n(`div`,{className:`flex flex-col h-full`,children:[n(`div`,{className:`flex shrink-0 flex-col gap-2 border-b px-3 py-2`,children:[n(`div`,{className:`flex items-center justify-between gap-2 text-xs text-muted`,children:[n(`span`,{children:[N?`${F} of ${g.length} file${g.length===1?``:`s`}`:`${g.length} file${g.length===1?``:`s`}`,!f&&v>0?` · ${v} hidden`:``]}),n(`div`,{className:`flex items-center gap-1`,children:[t(Ne,{size:`sm`,value:f,onChange:m,children:t(`span`,{className:`text-xs text-muted`,children:u(`agent.showSystemArtifacts`)})}),t(o,{variant:`ghost`,size:`sm`,onClick:x,disabled:y,className:`h-6 w-6 p-0`,children:t(hy,{className:`size-3.5 ${y?`animate-spin`:``}`})})]})]}),t(`label`,{htmlFor:I,className:`sr-only`,children:u(`form.filter`)}),t(te,{id:I,type:`text`,role:`searchbox`,autoComplete:`off`,placeholder:u(`store.searchPlaceholder`),value:E,onChange:D,clearable:!0})]}),t(`div`,{className:`flex-1 overflow-y-auto px-3 py-2`,children:P.length>0?t(`div`,{className:`min-w-0`,children:P.map(e=>t(nX,{node:e,depth:0,runId:r,onOpen:ee,onDownload:L,downloadingPath:S,forceExpanded:!!N},`${r}:${e.path}`))}):t(`div`,{className:`px-1 py-6 text-sm text-muted`,children:u(!f&&v>0?`agent.onlySystemArtifacts`:`agent.noContentAvailable`)})}),R&&n(se,{isOpen:!!w,onClose:()=>T(null),size:`xl`,className:`h-[90vh] p-0`,description:`Artifact preview`,children:[t(ue,{show:!1,children:R.fileName}),t(ce,{className:`h-full max-h-none p-0`,children:t(ot.Suspense,{fallback:t(p,{className:`h-full`,children:t(ev,{className:`size-6 animate-spin text-muted`})}),children:t(QY,{source:R,className:`h-full`,showHeader:!0,onDownload:()=>w&&void L(w)})})})]})]}):t(cX,{icon:t(Iv,{className:`mb-2 size-8`}),children:`No run selected`})}const uX=ot.memo(lX);Q();function dX(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function fX(e){if(!dX(e))return;let t=e.browseruse??e.browser_use;if(!dX(t))return;let n={widget:typeof t.widget==`string`?t.widget:void 0,browser_workflow_id:typeof t.browser_workflow_id==`string`?t.browser_workflow_id:void 0,workstream_id:typeof t.workstream_id==`string`?t.workstream_id:void 0,phase:typeof t.phase==`string`?t.phase:void 0,url:typeof t.url==`string`?t.url:void 0,title:typeof t.title==`string`?t.title:void 0,screenshot:typeof t.screenshot==`string`?t.screenshot:void 0,raw_screenshot:typeof t.raw_screenshot==`string`?t.raw_screenshot:void 0,prefer_raw_screenshot:typeof t.prefer_raw_screenshot==`boolean`?t.prefer_raw_screenshot:void 0,updated_at:typeof t.updated_at==`number`?t.updated_at:void 0};if(!(n.widget&&n.widget!==`browseruse`)&&!(!n.url&&!n.title&&!n.screenshot&&!n.raw_screenshot))return n}function pX(e){let t=new Map;for(let n of e){let e=fX(n.details);if(!e)continue;let r=e.workstream_id||n.workstream_id||`main`,i=e.updated_at??(typeof n.timestamp==`number`?n.timestamp:new Date(n.timestamp).getTime()),a=t.get(r);(!a||i>=a.timestamp)&&t.set(r,{state:{...e,workstream_id:r},timestamp:i})}return new Map(Array.from(t.entries()).map(([e,t])=>[e,t.state]))}function mX(e){return e.replace(/^artifact:\/\//,``).replace(/^artifact:/,``).replace(/^\/+/,``)}function hX(e){return e?e.replace(/_/g,` `):`browser`}function gX({state:e,runId:r,className:a,compact:o}){let{t:s}=K(),{client:c}=q(),l=VS(),{openImage:u}=DW(),[d,f]=G(),p=e.prefer_raw_screenshot===!1?e.screenshot||e.raw_screenshot:e.raw_screenshot||e.screenshot,m=e.title||e.url||s(`agent.browserUse`),h=U(()=>p&&mX(p).split(`/`).pop()||s(`agent.browserScreenshot`),[p,s]);return H(()=>{if(!p){f(void 0);return}if(p.startsWith(`http://`)||p.startsWith(`https://`)){f(p);return}if(!r){f(void 0);return}let e=!1;return(async()=>{let t=mX(p);try{let n=US(r,t,`inline`),i=l?await l.getOrFetch(n,async()=>(await c.files.getArtifactDownloadUrl(r,t,`inline`)).url):(await c.files.getArtifactDownloadUrl(r,t,`inline`)).url;e||f(i)}catch(n){console.error(`Failed to resolve browser screenshot ${t}`,n),e||f(void 0)}})(),()=>{e=!0}},[c,r,p,l]),o?n(`div`,{className:z(`overflow-hidden rounded-md border border-border/70 bg-transparent`,a),children:[n(`div`,{className:`flex items-center gap-2 px-2 py-1.5`,children:[t(Nv,{className:`size-3.5 shrink-0 text-info`}),n(`div`,{className:`min-w-0 flex-1`,children:[n(`div`,{className:`flex min-w-0 items-center gap-1`,children:[t(`span`,{className:`text-xs font-medium text-foreground`,children:s(`agent.browserPreview`)}),e.phase&&n(`span`,{className:`truncate text-[11px] capitalize text-muted`,children:[`· `,hX(e.phase)]})]}),t(`div`,{className:`truncate text-[11px] text-muted`,title:m,children:m})]}),e.url&&t(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,title:s(`agent.openInNewTab`),className:z(`inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md`,`text-muted hover:bg-muted hover:text-foreground`),children:t(Dg,{className:`size-3`})})]}),p&&(d?t(`button`,{type:`button`,className:`block w-full bg-mixer-muted/20 text-start`,onClick:()=>u(d,h),title:s(`agent.clickToEnlarge`),children:t(`img`,{src:d,alt:h,className:`block max-h-32 w-full object-contain`})}):n(`div`,{className:`flex min-h-16 items-center justify-center gap-2 bg-mixer-muted/20 px-3 py-4 text-xs text-muted`,children:[t(D_,{className:`size-4`}),t(`span`,{children:s(`agent.browserScreenshotPending`)})]}))]}):n(`div`,{className:z(`overflow-hidden rounded-md border border-muted bg-mixer-muted/10`,a),children:[n(`div`,{className:`flex items-start justify-between gap-2 border-b border-muted px-2.5 py-2`,children:[n(`div`,{className:`flex min-w-0 items-start gap-2`,children:[t(Nv,{className:`mt-0.5 size-4 shrink-0 text-info`}),n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`text-xs font-medium text-foreground`,children:s(`agent.browserUse`)}),t(`div`,{className:`truncate text-xs text-muted`,title:m,children:m})]})]}),t(i,{variant:`info`,className:`shrink-0 capitalize`,children:hX(e.phase)})]}),d?t(`button`,{type:`button`,className:`block w-full bg-mixer-muted/20 text-start`,onClick:()=>u(d,h),title:s(`agent.clickToEnlarge`),children:t(`img`,{src:d,alt:h,className:`block max-h-56 w-full object-contain`})}):n(`div`,{className:`flex min-h-28 items-center justify-center gap-2 bg-mixer-muted/20 px-3 py-6 text-xs text-muted`,children:[t(D_,{className:`size-4`}),t(`span`,{children:s(`agent.browserScreenshotPending`)})]}),e.url&&n(`div`,{className:`flex items-center gap-2 border-t border-muted px-2.5 py-1.5`,children:[t(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`min-w-0 flex-1 truncate text-xs text-info hover:underline`,title:e.url,children:e.url}),t(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,title:s(`agent.openInNewTab`),className:z(`inline-flex h-6 shrink-0 items-center justify-center rounded-md px-1.5`,`text-muted hover:bg-muted hover:text-foreground`),children:t(Dg,{className:`size-3`})})]})]})}Q();function _X({documentId:e,title:r,onBack:i,onUpdateDocumentTitle:a,refreshKey:s,runId:c}){let{client:l}=q(),{t:u}=K(),[d,f]=G(null),[p,m]=G(!1),[h,g]=G(null),[_,v]=G(null),y=V(async e=>{m(!0),g(null);try{let[t,n]=await Promise.all([l.store.objects.getObjectText(e),l.store.objects.retrieve(e)]);f(t.text??null);let r=n.name;v(r),r&&a?.(e,r)}catch(e){let t=e instanceof Error?e.message:u(`agent.failedToLoadDocument`);g(t),f(null)}finally{m(!1)}},[l,a,u]);return H(()=>{y(e)},[e,s,y]),n(`div`,{className:`h-full overflow-hidden flex flex-col`,children:[n(`div`,{className:`flex items-center justify-between gap-1 px-2 py-1 border-b border-border/60 shrink-0`,children:[t(o,{variant:`ghost`,size:`sm`,className:`size-8 shrink-0 rounded-md p-0`,onClick:i,"aria-label":u(`agent.backToDocuments`),title:u(`agent.backToDocuments`),children:t(wm,{className:`size-4 cn-rtl-flip`})}),n(`div`,{className:`flex items-center gap-1.5 min-w-0 flex-1`,children:[t(Gg,{className:`size-4 text-muted shrink-0`}),t(`span`,{className:`truncate text-sm font-medium`,title:_||r,children:_||r||u(`agent.document`)})]}),n(Zn,{href:`/store/objects/${e}#overview`,topLevelNav:!0,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted hover:bg-muted/20 hover:text-foreground`,children:[t(We,{description:u(`agent.openDocument`),placement:`top`,size:`xs`,asChild:!0,children:t(Dg,{className:`size-4`,"aria-hidden":`true`})}),t(`span`,{className:`sr-only`,children:u(`agent.openDocument`)})]})]}),t(`div`,{className:`flex-1 overflow-y-auto px-4 py-4`,children:p?n(`div`,{className:`flex items-center justify-center py-12`,children:[t(ev,{className:`size-5 animate-spin text-muted`}),t(`span`,{className:`ms-2 text-sm text-muted`,children:u(`agent.loadingDocument`)})]}):h?t(`div`,{className:`p-4 rounded-md bg-destructive/10 text-destructive text-sm`,children:h}):d?t(`div`,{className:`prose prose-sm dark:prose-invert max-w-none`,children:t(Nt,{artifactRunId:c,children:d})}):n(`div`,{className:`flex flex-col items-center justify-center py-12 text-muted`,children:[t(Gg,{className:`size-8 mb-2`}),t(`span`,{className:`text-sm`,children:u(`agent.noContentAvailable`)})]})})]})}const vX=ot.memo(_X);Q();function yX({documents:r,activeDocumentId:i,onSelectDocument:a,onUpdateDocumentTitle:s,refreshKey:c,runId:l}){let{t:u}=K(),[d,f]=G(``),p=vt(),m=d.trim().toLocaleLowerCase(),h=U(()=>m?r.filter(e=>e.title.toLocaleLowerCase().includes(m)):r,[r,m]),g=V(()=>a(null),[a]),_=i?r.find(e=>e.id===i):void 0;return i?t(vX,{documentId:i,title:_?.title,onBack:g,onUpdateDocumentTitle:s,refreshKey:c,runId:l}):n(`div`,{className:`flex flex-col h-full`,children:[n(`div`,{className:`flex shrink-0 flex-col gap-2 border-b px-3 py-2`,children:[t(`span`,{className:`text-xs text-muted`,children:m?u(`agent.documentsFiltered`,{visible:h.length,total:r.length}):u(`agent.documentCount`,{count:r.length})}),r.length>5&&n(e,{children:[t(`label`,{htmlFor:p,className:`sr-only`,children:u(`form.filter`)}),t(te,{id:p,type:`text`,role:`searchbox`,autoComplete:`off`,placeholder:u(`store.searchPlaceholder`),value:d,onChange:f,clearable:!0})]})]}),t(`div`,{className:`flex-1 overflow-y-auto px-3 py-2`,children:h.length>0?t(`div`,{className:`min-w-0`,children:h.map(e=>n(`div`,{className:`flex min-w-0 items-center gap-1`,children:[n(o,{variant:`unstyled`,className:`flex min-w-0 flex-1 items-center justify-start gap-1.5 rounded px-1 py-1 text-start text-sm hover:bg-muted/30`,onClick:()=>a(e.id),title:e.title,children:[t(Gg,{className:`size-4 shrink-0 text-muted`}),t(`span`,{className:`min-w-0 truncate`,children:e.title})]}),n(Zn,{href:`/store/objects/${e.id}#overview`,topLevelNav:!0,className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted hover:bg-muted/20 hover:text-foreground`,children:[t(We,{description:u(`agent.openDocument`),placement:`top`,size:`xs`,asChild:!0,children:t(Dg,{className:`size-3.5`,"aria-hidden":`true`})}),t(`span`,{className:`sr-only`,children:u(`agent.openDocument`)})]})]},e.id))}):t(`div`,{className:`px-1 py-6 text-sm text-muted`,children:u(`agent.noMatchingDocuments`)})})]})}const bX=ot.memo(yX);Q();function xX({plan:e,workstreamStatus:r,isOpen:i,onClose:a,plans:s=[],activePlanIndex:c=0,onChangePlan:l=()=>{}}){let{t:u}=K();if(!i)return null;let d=e.plan||[],f=d.length,m=d.reduce((e,t)=>t?.id&&(r.get(t.id.toString())===`completed`||t.status===`completed`)?e+1:e,0),h=f>0?Math.round(m/f*100):0,g=s.length>0?s.length-c:1,_=s[c]?.timestamp;return d.length===0?t(`div`,{className:`h-full overflow-hidden`,children:n(p,{className:`h-full min-h-[240px] flex-col text-center text-muted`,children:[t(eg,{className:`mb-2 size-8`}),t(`span`,{className:`text-sm`,children:u(`agent.noPlanAvailable`)})]})}):t(`div`,{className:`h-full overflow-hidden`,children:n(`div`,{className:`flex h-full flex-col gap-4 overflow-y-auto px-2 py-3`,children:[n(`div`,{className:`space-y-2`,children:[n(`div`,{className:`flex items-start justify-between gap-3`,children:[n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`text-sm font-medium text-foreground`,children:u(`agent.taskProgress`)}),t(`div`,{className:`text-xs text-muted`,children:u(`agent.tasksCompleted`,{completed:m,total:f})})]}),s.length>1&&n(`div`,{className:`flex shrink-0 items-center gap-1 text-xs text-muted`,children:[t(o,{variant:`ghost`,size:`icon`,className:`size-7`,onClick:()=>l(Math.min(s.length-1,c+1)),disabled:c>=s.length-1,"aria-label":u(`agent.olderPlan`),title:u(`agent.olderPlan`),children:t(oh,{className:`size-4`,"aria-hidden":`true`})}),n(`div`,{className:`min-w-20 text-center`,children:[n(`div`,{className:`font-medium text-foreground`,children:[g,`/`,s.length]}),t(`div`,{className:`truncate`,children:_?new Date(_).toLocaleTimeString():u(`agent.unknownTime`)})]}),t(o,{variant:`ghost`,size:`icon`,className:`size-7`,onClick:()=>l(Math.max(0,c-1)),disabled:c<=0,"aria-label":u(`agent.newerPlan`),title:u(`agent.newerPlan`),children:t(lh,{className:`size-4`,"aria-hidden":`true`})})]})]}),t(`div`,{className:`h-2 overflow-hidden rounded-full bg-mixer-muted/20`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":f,"aria-valuenow":m,"aria-label":u(`agent.taskProgress`),children:t(`div`,{className:`h-full rounded-full bg-success transition-all duration-300`,style:{width:`${h}%`}})})]}),t(`ol`,{className:`divide-y divide-border/60`,children:d.map((e,i)=>{let a=e.id?e.id.toString():`task-${i}`,o=e.goal||`Task ${i+1}`,s=e.id?`task-${e.id.toString()}`:`task-${o}-${e.status||`pending`}`,c=e.status||`pending`,l=r.get(a);l!==void 0&&(c=l);let d=Jh,f=`text-muted`;c===`in_progress`?(d=rg,f=`text-info`):c===`completed`&&(d=Nh,f=`text-success`);let p=u(c===`completed`?`agent.completed`:c===`in_progress`?`agent.inProgress`:`agent.pending`);return n(`li`,{className:`grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-3 px-1 py-3`,children:[t(`span`,{className:`mt-0.5 min-w-5 text-center text-xs font-medium tabular-nums text-muted/80`,children:a}),t(`span`,{className:`min-w-0 text-sm leading-5 text-foreground/85`,children:o}),n(`span`,{className:z(`flex items-center gap-1.5 text-xs font-medium`,f),children:[t(d,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t(`span`,{children:p})]})]},s)})}),(()=>{let e=new Set(d.filter(e=>e?.id).map(e=>e.id.toString())),i=Array.from(r.entries()).filter(([t])=>t!==`main`&&!e.has(t));return i.length>0?n(`div`,{className:`mt-1 px-1 py-2`,children:[t(`div`,{className:`mb-2 text-xs font-medium text-muted`,children:u(`agent.workstreams`)}),t(`div`,{className:`divide-y divide-border/60`,children:i.map(([e,r])=>{let i=Jh,a=`text-muted`,o=u(`agent.pending`);return r===`in_progress`?(i=rg,a=`text-info`,o=u(`agent.inProgress`)):r===`completed`&&(i=Nh,a=`text-success`,o=u(`agent.completed`)),n(`div`,{className:`flex items-center gap-2 py-2`,children:[t(i,{className:z(`size-3.5 shrink-0`,a)}),t(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium text-foreground/80`,children:e}),t(`span`,{className:`text-xs font-medium text-muted`,children:o})]},e)})})]}):null})()]})})}const SX=ot.memo(xX);Q();function CX({icon:e,children:r}){return n(p,{className:`h-full min-h-[240px] flex-col text-center text-muted`,children:[e,t(`span`,{className:`text-sm`,children:r})]})}function wX({files:e}){let{t:r}=K(),a=U(()=>e?Array.from(e.values()):[],[e]),o=e=>{switch(e){case pn.UPLOADING:case pn.PROCESSING:return t(ev,{className:`size-4 animate-spin text-info`});case pn.READY:return t(Nh,{className:`size-4 text-success`});case pn.ERROR:return t(Gh,{className:`size-4 text-destructive`});default:return t(Gg,{className:`size-4 text-muted`})}},s=e=>{switch(e){case pn.UPLOADING:return t(i,{variant:`info`,children:r(`agent.uploading`)});case pn.PROCESSING:return t(i,{variant:`info`,children:r(`agent.processing`)});case pn.READY:return t(i,{variant:`success`,children:r(`agent.ready`)});case pn.ERROR:return t(i,{variant:`destructive`,children:r(`agent.error`)});default:return null}};return t(`div`,{className:`h-full min-h-0`,children:a.length===0?t(CX,{icon:t(Gg,{className:`mb-2 size-8`}),children:r(`agent.noFilesUploadedYet`)}):t(`div`,{className:`space-y-2 p-2`,children:a.map(e=>n(`div`,{className:`flex items-start gap-2 p-2 border border-muted rounded-md`,children:[t(`div`,{className:`mt-0.5`,children:o(e.status)}),n(`div`,{className:`flex-1 min-w-0`,children:[n(`div`,{className:`flex items-center justify-between gap-2`,children:[t(`span`,{className:`text-sm font-medium truncate`,children:e.name}),s(e.status)]}),e.error&&t(`div`,{className:`text-xs text-destructive mt-1`,children:e.error})]})]},e.id))})})}var TX=class extends ot.Component{state={hasError:!1};static getDerivedStateFromError(e){return{hasError:!0,message:e instanceof Error?e.message:String(e)}}componentDidCatch(e,t){console.error(`Agent right panel section failed to render`,{error:e,componentStack:t.componentStack})}render(){return this.state.hasError?n(`div`,{className:z(`rounded-md border border-destructive bg-mixer-destructive/10 text-destructive`,this.props.compact?`p-2 text-xs`:`m-3 p-3 text-sm`),children:[t(`div`,{className:`font-medium`,children:this.props.title}),t(`div`,{className:`mt-1 text-xs text-muted`,children:this.props.description}),this.state.message&&t(`div`,{className:`mt-1 break-all text-[11px] text-muted`,children:this.state.message})]}):this.props.children}};function EX({workstreams:e,messages:r,runId:a}){let{t:s}=K(),{client:c}=q(),l=nt(),u=U(()=>pX(r),[r]),d=s(`agent.panelRenderErrorDescription`),f=V(e=>{navigator.clipboard.writeText(e),l({status:`success`,title:s(`agent.runIdCopied`),duration:2e3})},[s,l]),p=V(async e=>{try{let t=await iU(c,e);t&&window.open(t,`_blank`)}catch{l({status:`error`,title:s(`agent.failedToDownload`)})}},[c,s,l]);return e.length===0?t(CX,{icon:t(z_,{className:`mb-2 size-8`}),children:s(`agent.noActiveParallelTasks`)}):n(`div`,{className:`h-full min-h-0 overflow-y-auto px-2 py-2`,children:[t(`div`,{className:`px-1 pb-2 text-xs text-muted`,children:s(`agent.parallelWorkDescription`)}),t(`div`,{className:`divide-y divide-border/60`,children:e.map(e=>{let r=e.status===`running`||e.status===`canceling`,c=Math.round(e.elapsed_ms/1e3),l=Math.max(0,Math.round(e.remaining_ms/1e3)),m=e.deadline_ms>0?Math.min(100,Math.round(e.elapsed_ms/e.deadline_ms*100)):0,h=u.get(e.workstream_id),g=e.deadline_ms>0,_=e.child_workflow_run_id,v=[e.phase?NH(e.phase):void 0,c>0?s(`agent.elapsed`,{seconds:c}):void 0,g&&l>0?s(`agent.remaining`,{seconds:l}):void 0].filter(Boolean),y=(()=>{switch(e.status){case`running`:return t(i,{variant:`info`,children:s(`agent.running`)});case`canceling`:return t(i,{variant:`attention`,children:s(`agent.canceling`)});case`completed`:return t(i,{variant:`done`,children:s(`agent.completed`)});case`failed`:return t(i,{variant:`destructive`,children:s(`agent.failed`)});case`timeout`:return t(i,{variant:`destructive`,children:s(`agent.timeout`)});case`canceled`:return t(i,{variant:`destructive`,children:s(`agent.canceled`)})}})();return t(TX,{title:s(`agent.workstreamRenderError`),description:d,compact:!0,children:t(`div`,{className:`py-3`,children:n(`div`,{className:`flex items-start gap-2`,children:[t(`span`,{className:z(`mt-2 size-2 shrink-0 rounded-full`,VH(e.status)),"aria-hidden":`true`}),n(`div`,{className:`min-w-0 flex-1`,children:[n(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[t(`span`,{className:`min-w-0 truncate text-sm font-medium text-foreground`,title:e.workstream_id,children:NH(e.workstream_id)}),y]}),v.length>0&&t(`div`,{className:`mt-0.5 truncate text-xs text-muted`,children:v.join(` · `)}),r&&g&&t(`div`,{className:`mt-2 h-1 rounded-full bg-muted`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":m,"aria-valuetext":s(`agent.workstreamProgress`,{percent:m}),children:t(`div`,{className:`h-full rounded-full bg-info transition-all duration-500`,style:{width:`${m}%`}})}),h&&t(TX,{title:s(`agent.browserWidgetRenderError`),description:d,compact:!0,children:t(gX,{state:h,runId:a,compact:!0,className:`mt-2`})}),_&&n(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n(o,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs text-muted hover:text-foreground`,onClick:()=>f(_),children:[t(Zh,{className:`size-3 me-1`}),s(`agent.copyRunId`)]}),n(o,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs text-muted hover:text-foreground`,onClick:()=>p(_),children:[t(og,{className:`size-3 me-1`}),s(`agent.download`)]})]})]})]})})},e.launch_id)})})]})}function DX({plan:e,workstreamStatus:r,plans:i=[],activePlanIndex:a=0,onChangePlan:s,activeWorkstreams:c=[],messages:l=[],hideWorkstreams:u=!1,openDocuments:d=[],activeDocumentId:f,onSelectDocument:p,onUpdateDocumentTitle:m,docRefreshKey:h=0,runId:g,processingFiles:_,showArtifacts:v=!1,artifactRefreshKey:y=0,artifactRefreshDetails:b,selectedArtifactPath:x,onSelectedArtifactPathChange:S,onSendMessage:C,payloadContent:w,conversationContent:T,onClose:E,defaultTab:D,activeTab:O,onTabChange:k}){let{t:A}=K(),[j,M]=G(D||`plan`),N=O??j,P=e=>{M(e),k?.(e)},F=!u&&c.length>0,I=d.length>0,L=_?_.size>0:!1,ee=V((e,n)=>t(TX,{title:A(`agent.panelRenderError`,{name:e}),description:A(`agent.panelRenderErrorDescription`),children:n}),[A]),R={name:`conversation`,label:`Conversation`,content:T?ee(`Conversation`,t(`div`,{className:`flex flex-col h-full min-h-0`,children:T})):null,is_allowed:!!T},te=[...T?[R]:[],{name:`plan`,label:A(`agent.plan`),content:ee(A(`agent.plan`),e?t(SX,{plan:e,workstreamStatus:r||new Map,isOpen:!0,onClose:E,plans:i,activePlanIndex:a,onChangePlan:s}):t(CX,{icon:t(z_,{className:`mb-2 size-8`}),children:A(`agent.noPlanAvailable`)})),is_allowed:!0},{name:`workstreams`,label:F?n(`span`,{className:`inline-flex min-w-0 items-center gap-1 whitespace-nowrap`,children:[A(`agent.workstreams`),` `,t(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-full bg-info px-1.5 py-0.5 text-[10px] text-info`,children:c.length})]}):A(`agent.workstreams`),content:ee(A(`agent.workstreams`),t(EX,{workstreams:c,messages:l,runId:g})),is_allowed:!u},{name:`documents`,label:I?n(`span`,{className:`inline-flex min-w-0 items-center gap-1 whitespace-nowrap`,children:[A(`agent.documents`),` `,t(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-full bg-info px-1.5 py-0.5 text-[10px] text-info`,children:d.length})]}):A(`agent.documents`),content:ee(A(`agent.documents`),d.length>0&&p?t(bX,{documents:d,activeDocumentId:f??null,onSelectDocument:p,onUpdateDocumentTitle:m,refreshKey:h,runId:g}):t(CX,{icon:t(Gg,{className:`mb-2 size-8`}),children:A(`agent.noDocumentsOpen`)})),is_allowed:!0},{name:`uploads`,label:L?n(`span`,{className:`inline-flex min-w-0 items-center gap-1 whitespace-nowrap`,children:[A(`agent.uploads`),` `,t(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-info`})]}):A(`agent.uploads`),content:ee(A(`agent.uploads`),t(wX,{files:_})),is_allowed:!0},{name:`artifacts`,label:A(`agent.artifacts`),content:ee(A(`agent.artifacts`),t(uX,{runId:g,refreshKey:y,refreshDetails:b,selectedPath:x,onSelectedPathChange:S,onSendMessage:C})),is_allowed:v},{name:`payload`,label:A(`agent.payload`),content:w?ee(A(`agent.payload`),t(`div`,{className:`overflow-y-auto`,children:w})):null,is_allowed:!!w}],ne=te.filter(e=>e.is_allowed===void 0||e.is_allowed===!0);return n(ze,{tabs:te,current:N,onTabChange:P,fullHeight:!0,className:`px-0`,children:[n(`div`,{className:`flex items-end justify-between shrink-0 px-1 py-1 gap-1`,children:[t(pe,{tabs:ne,current:N,onTabChange:P,className:`min-w-0 flex-1`}),!T&&t(o,{variant:`ghost`,size:`sm`,className:`shrink-0 ms-1`,onClick:E,title:`Close Right Panel`,children:t(Gb,{className:`size-4`})})]}),t(Ve,{className:`flex-1 min-h-0 pt-0 pb-0`})]})}const OX=ot.memo(DX);function kX(e){if(!e)return[];let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r.kind!==`file`)continue;let i=r.getAsFile();if(i){if(r.type.startsWith(`image/`)&&(!i.name||i.name===`image.png`)){let e=r.type.split(`/`)[1]||`png`;t.push(new File([i],`pasted-image-${Date.now()}.${e}`,{type:i.type}))}else t.push(i)}}return t}function AX(e,t,n=!1){let[r,i]=G([]),[a,o]=G(0),[s,c]=G(new Map),[l,u]=G(t),[d,f]=G(!n),p=W(-1),m=W(new Set);H(()=>{e.length===0&&(i([]),o(0),c(new Map),f(!n),p.current=-1,m.current.clear())},[e.length,n]);let h=V(e=>{let n=e[e.length-1];n&&(n.type===J.TERMINATED?u(!1):u(t?!0:n.type===J.REQUEST_INPUT))},[t]);return H(()=>{if(e.length===0)return;let t=p.current+1;if(t>=e.length){h(e);return}let n=!1,r=[],a=[];for(let i=t;i<e.length;i++){let t=e[i];if(t.type===J.PLAN)try{let e=null;if(t.details&&typeof t.details==`object`&&t.details.plan&&Array.isArray(t.details.plan)&&(e={plan:t.details.plan}),e){let i=typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime();if(!m.current.has(i)){m.current.add(i),n=!0,r.push({plan:e,timestamp:i});let t=new Map;t.set(`main`,`in_progress`),Array.isArray(e.plan)&&e.plan.forEach(e=>{if(e&&typeof e==`object`&&e.id){let n=e.id.toString();t.set(n,e.status||`pending`)}}),a.push({timestamp:i,statusMap:t})}}}catch(e){console.error(`Failed to parse plan from message:`,e)}}p.current=e.length-1,n&&r.length>0&&(i(e=>[...[...r].reverse(),...e]),o(0),f(!0),a.length>0&&c(e=>{let t=new Map(e);for(let e of a)t.set(e.timestamp,e.statusMap);return t})),h(e)},[e,h]),H(()=>{if(r.length===1&&!d&&!sessionStorage.getItem(`plan-panel-shown`)){let e=setTimeout(()=>{f(!0),sessionStorage.setItem(`plan-panel-shown`,`true`)},500);return()=>clearTimeout(e)}},[r.length,d]),{plans:r,activePlanIndex:a,setActivePlanIndex:o,workstreamStatusMap:s,showInput:l,showSlidingPanel:d,setShowSlidingPanel:f}}function jX(e,t){return{...e,details:{...e.details??{},_deliveryStatus:t}}}function MX(e){let t=e.details,n=t?._messageId;if(typeof n==`string`&&n)return n;let r=t?.ack;return typeof r==`string`&&r?r:void 0}function NX(e,t){let n=e?.[t];return typeof n==`string`&&n?n:void 0}function PX(e){return e?.streaming_id_scope===`workflow_run`}function FX(e){return[J.COMPLETE,J.IDLE,J.TERMINATED,J.REQUEST_INPUT].includes(e.type)}function IX(e){if(e.type===J.STREAMING_CHUNK)return!1;if(e.type===J.UPDATE&&typeof e.details?.event_class==`string`)return!0;if(e.type===J.SYSTEM){let t=e.details;if(t?.system_type===`file_processing`&&t.files)return!1}return!!e.message||FX(e)||Dn(e).length>0}function LX(e){if(e)return{type:e.type,timestamp:e.timestamp,workstream_id:e.workstream_id,text:typeof e.message==`string`?e.message.slice(0,80):e.message?`[non-string]`:``,display_role:e.details?.display_role,source:e.details?.source}}function RX(e,t){if(e.find(e=>e.timestamp===t.timestamp))return e;if(!t.details?._optimistic&&(t.type===J.QUESTION||QH(t))){let n=typeof t.details?.ack==`string`?t.details.ack:void 0,r=n?jX(t,`consumed`):t;if(n){let i=e.filter(e=>!((e.type===t.type||QH(e))&&e.details?._optimistic&&MX(e)===n));return JH(i,r),i}if(t.type===J.QUESTION){let n=e.filter(e=>e.type===J.QUESTION&&e.details?._optimistic&&e.message===t.message&&(e.workstream_id??`main`)===(t.workstream_id??`main`));if(n.length===1){let r=e.filter(e=>e!==n[0]);return JH(r,t),r}}}let n=[...e];return JH(n,t),n}function zX(e){let t=e.details,n=NX(t,`streaming_id`),r=NX(t,`activity_id`);return n&&PX(t)?n:r??n}function BX(e){let t=e.details,n=NX(t,`streaming_id`),r=NX(t,`activity_id`),i=[];return n&&PX(t)&&i.push(n),r&&i.push(r),[...new Set(i)]}function VX(e,t,n){let[r,i]=G([]),[a,o]=G(!1),[s,c]=G(`loading`),[l,u]=G(null),[d,f]=G(null),p=W(n);p.current=n;let[m,h]=G(new Map),[g,_]=G(0),v=V(()=>_(e=>e+1),[]),y=W(null),b=W(0),[x,S]=G(new Map),C=W(new Map),w=W(null),[T,E]=G(!1),D=W(null),O=V(()=>{let e=w.current;e&&(e.mode===`raf`?cancelAnimationFrame(e.id):clearTimeout(e.id),w.current=null)},[]),k=V(()=>{C.current.size>0&&(S(new Map(C.current)),E(!0),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>E(!1),50)),w.current=null},[]);return H(()=>{o(!ZH(r))},[r]),H(()=>{qH(`stream state`,{agentRunId:t,messageCount:r.length,streamingCount:x.size,initialHistoryStatus:s,isCompleted:a,lastDeliveredTs:b.current,first:LX(r[0]),last:LX(r[r.length-1])})},[t,s,a,r,x.size]),H(()=>{let n=y.current!==t;y.current=t,n&&(i([]),c(`loading`),u(null),f(null),S(new Map),h(new Map),b.current=0);let r=new AbortController,a=n?void 0:b.current||void 0;return qH(`stream start`,{agentRunId:t,isNewConversation:n,since:a,streamNonce:g}),e.agents.getInternals(t).then(e=>{r.signal.aborted||(qH(`internals loaded`,{agentRunId:t,status:e.status,first_workflow_run_id:e.first_workflow_run_id}),u(e.status?.toUpperCase()??null),f(e.first_workflow_run_id??null))}).catch(e=>{r.signal.aborted||console.error(`Failed to check agent run status:`,e)}),e.agents.streamMessages(t,e=>{if(r.signal.aborted)return;let n=!!(e.timestamp&&e.timestamp<=b.current);if(n||p.current?.(e),qH(`stream message`,{agentRunId:t,type:e.type,timestamp:e.timestamp,workstream_id:e.workstream_id,hasMessage:!!e.message,display_role:e.details?.display_role,source:e.details?.source}),e.timestamp&&e.timestamp>b.current&&(b.current=e.timestamp),e.type===J.STREAMING_CHUNK){let t=e.details,n=zX(e);if(!n)return;let r=C.current.get(n)||{text:``,workstreamId:e.workstream_id,startTimestamp:Date.now(),activityId:t?.activity_id,streamingId:t?.streaming_id},i=r.text+(e.message||``);C.current.set(n,{text:i,workstreamId:e.workstream_id,isComplete:t.is_final,startTimestamp:r.startTimestamp,activityId:t?.activity_id,streamingId:t?.streaming_id}),w.current===null&&(document.hidden?w.current={mode:`timeout`,id:window.setTimeout(k,16)}:w.current={mode:`raf`,id:requestAnimationFrame(k)});return}if(e.type===J.SYSTEM){let t=e.details;if(t?.system_type===`file_processing`&&t.files){n||h(new Map(t.files.map(e=>[e.id,e])));return}}if(e.type===J.THOUGHT||e.type===J.ANSWER){let t=BX(e);if(t.length>0){for(let e of t)C.current.delete(e);S(e=>{let n=new Map(e),r=!1;for(let e of t)r=n.delete(e)||r;return r?n:e})}}(e.type===J.COMPLETE||e.type===J.IDLE)&&C.current.size>0&&k(),IX(e)&&i(t=>RX(t,e))},a,r.signal,{closeOnIdle:!1,onHistoryLoaded:e=>{if(r.signal.aborted)return;let n=e.filter(IX),o,s=-1/0;for(let t of e)if(t.timestamp&&t.timestamp>b.current&&(b.current=t.timestamp),t.type===J.SYSTEM){let e=t.details;if(e?.system_type===`file_processing`&&e.files){let n=t.timestamp??-1/0;(!o||n>=s)&&(o=e,s=n)}}o&&h(new Map(o.files.map(e=>[e.id,e]))),qH(`history loaded`,{agentRunId:t,count:e.length,timelineCount:n.length,since:a,first:LX(e[0]),last:LX(e[e.length-1])}),c(e.length>0?`has_messages`:`empty`),n.length>0&&i(e=>n.reduce((e,t)=>RX(e,t),e))},onHistoryError:e=>{r.signal.aborted||(qH(`history error`,{agentRunId:t,error:e instanceof Error?e.message:String(e)}),c(`error`))}}).then(()=>{if(!r.signal.aborted)return qH(`stream resolved`,{agentRunId:t}),e.agents.getInternals(t).then(e=>{r.signal.aborted||(qH(`internals refreshed after stream end`,{agentRunId:t,status:e.status}),u(e.status?.toUpperCase()??null))}).catch(e=>{r.signal.aborted||console.error(`Failed to refresh agent run status on stream end:`,e)})}).catch(e=>{r.signal.aborted||(qH(`stream failed`,{agentRunId:t,error:e instanceof Error?e.message:String(e)}),console.error(`Failed to stream agent messages:`,e))}),()=>{qH(`stream cleanup`,{agentRunId:t,streamNonce:g}),r.abort(),O(),C.current.clear(),D.current&&=(clearTimeout(D.current),null)}},[t,g,e.agents,k,O]),H(()=>{let e=()=>{!document.hidden&&C.current.size>0&&(O(),k())};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e)}},[k,O]),{messages:r,streamingMessages:x,isCompleted:a,initialHistoryStatus:s,debugChunkFlash:T,addOptimisticMessage:V(e=>{i(t=>{let n=[...t,e];return n.sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())),n})},[]),updateOptimisticMessageStatus:V((e,t)=>{i(n=>n.map(n=>n.details?._optimistic&&MX(n)===e?jX(n,t):n))},[]),removeOptimisticMessages:V(e=>{i(t=>t.filter(t=>!e(t)))},[]),reconnect:v,agentRunStatus:l,workflowRunId:d,serverFileUpdates:m}}function HX(e){if(typeof e==`string`&&e.trim().length>0)return e}function UX(e,t){let n=HX(e.revision_root_id)||HX(e.revision_root)||HX(e.root_document_id)||HX(e.root_id);if(n)return n;let r=e.revision_info;if(r&&typeof r==`object`){let e=HX(r.root);if(e)return e}return t}function WX(e,t){return e.revisionRootId&&t.revisionRootId?e.revisionRootId===t.revisionRootId:t.revisionRootId?e.id===t.revisionRootId:e.revisionRootId?e.revisionRootId===t.id:e.id===t.id}function GX(e){let[t,n]=G([]),[r,i]=G(null),[a,o]=G(!1),[s,c]=G(0),l=W(-1);return H(()=>{e.length===0&&(n([]),i(null),o(!1),c(0),l.current=-1)},[e.length]),H(()=>{let t=l.current+1;if(!(t>=e.length)){for(let r=t;r<e.length;r++){let t=e[r];if(t.type===J.UPDATE&&t.details){let e=t.details;if(e.event_class===`document_created`||e.event_class===`document_updated`){let t=HX(e.document_id),r=HX(e.updated_document_id)||t,a=e.title;if(r){let s=UX(e,t||r),l={id:r,title:a||`Document`,revisionRootId:s};n(e=>{let t=e.findIndex(e=>WX(e,l));if(t<0)return[...e,l];let n=e[t];if(n.id===l.id&&n.title===l.title&&n.revisionRootId===l.revisionRootId)return e;let r=[...e];return r[t]=l,r}),i(l.id),o(!0),e.event_class===`document_updated`&&c(e=>e+1)}}}}l.current=e.length-1}},[e]),{openDocuments:t,activeDocumentId:r,isDocPanelOpen:a,docRefreshKey:s,closeDocPanel:V(()=>{o(!1)},[]),selectDocument:V(e=>{i(e)},[]),openDocInPanel:V(e=>{n(t=>t.some(t=>t.id===e)?t:[...t,{id:e,title:`Document`,revisionRootId:e}]),i(e),o(!0)},[]),updateDocumentTitle:V((e,t)=>{n(n=>n.map(n=>n.id===e?{...n,title:t}:n))},[])}}function KX(e){return e.type.startsWith(`image/`)}function qX(e){if(!(!KX(e)||typeof URL>`u`||!URL.createObjectURL))return URL.createObjectURL(e)}function JX(e){typeof URL<`u`&&URL.revokeObjectURL&&URL.revokeObjectURL(e)}function YX(e,t,n,r,i){let a=Xt.getFixedT(null,Yt),[o,s]=G(new Map),[c,l]=G(new Set),u=W(new Set),d=W(new Map),f=W(t),p=W(o);p.current=o;let m=W(n);m.current=n;let h=V(e=>{let t=d.current.get(e);t&&(JX(t),d.current.delete(e))},[]);H(()=>{if(f.current!==t){f.current=t,d.current.forEach(JX),d.current.clear(),s(new Map);let e=new Set;u.current=e,l(e)}},[t]),H(()=>()=>{d.current.forEach(JX),d.current.clear()},[]);let g=U(()=>{let e=new Map;if(o.forEach((t,n)=>{c.has(n)||e.set(n,t)}),n.forEach((t,n)=>{if(t.consumed_at){e.delete(n);return}if(!c.has(n)){let r=o.get(n);e.set(n,{...t,artifact_path:t.artifact_path??r?.artifact_path,reference:t.reference??r?.reference,...r?.preview_url?{preview_url:r.preview_url}:{}})}}),i&&i.size>0)for(let[t,n]of e)(n.reference&&i.has(n.reference)||n.artifact_path&&i.has(n.artifact_path))&&e.delete(t);return e},[o,c,n,i]);return{processingFiles:g,hasProcessingFiles:U(()=>Array.from(g.values()).some(e=>e.status===pn.UPLOADING||e.status===pn.PROCESSING),[g]),handleFileUpload:V(async n=>{for(let i of n){let n=`file-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,o=`files/${i.name}`,c=qX(i);c&&d.current.set(n,c);let l={id:n,name:i.name,content_type:i.type||`application/octet-stream`,size:i.size,status:pn.UPLOADING,started_at:Date.now(),preview_url:c};s(e=>new Map(e).set(n,l));try{if(await e.agents.uploadArtifact(t,o,i),s(e=>{let t=new Map(e),r=t.get(n);return r&&(r.status=pn.PROCESSING,r.artifact_path=o,r.reference=`artifact:${o}`),t}),u.current.has(n))continue;await e.agents.sendSignal(t,`FileUploaded`,{id:n,name:i.name,content_type:i.type||`application/octet-stream`,reference:`artifact:${o}`,artifact_path:o})}catch(e){if(u.current.has(n))continue;s(t=>{let r=new Map(t),i=r.get(n);return i&&(i.status=pn.ERROR,i.error=e instanceof Error?e.message:`Upload failed`,i.completed_at=Date.now()),r}),r({status:`error`,title:a(`agent.uploadFailed`),description:e instanceof Error?e.message:`Failed to upload file`,duration:3e3})}}},[e,t,r,a]),removeProcessingFile:V(async n=>{l(e=>{if(e.has(n))return e;let t=new Set(e);return t.add(n),u.current=t,t}),s(e=>{if(!e.has(n))return e;let t=new Map(e);return t.delete(n),t}),h(n);try{await e.agents.sendSignal(t,`FileRemoved`,{id:n})}catch(e){r({status:`error`,title:a(`agent.removeFileFailed`),description:e instanceof Error?e.message:`Failed to remove file`,duration:3e3})}},[t,e,h,a,r]),clearProcessingFiles:V(()=>{d.current.forEach(JX),d.current.clear(),l(e=>{let t=new Set(e);for(let e of m.current.keys())t.add(e);for(let e of p.current.keys())t.add(e);return u.current=t,t}),s(new Map)},[])}}Q();function XX({activeWorkstreams:r,onSelectWorkstream:i,className:a}){let{t:s}=K(),[c,l]=G(!1),[u,d]=G(!1),f=vt(),p=U(()=>r.filter(e=>e.status===`running`||e.status===`canceling`),[r]),m=c?p:p.slice(0,3),h=Math.max(0,p.length-m.length),g=p.length>3;return H(()=>{g||l(!1)},[g]),p.length===0?null:t(`div`,{className:z(`mx-auto mb-2 w-full max-w-3xl px-1`,a),"data-agent-active-workstreams":!0,children:n(`output`,{className:`flex flex-col gap-1.5 rounded-2xl border border-border/70 bg-background/95 p-2 text-xs text-muted shadow-lg shadow-black/5`,"aria-live":`polite`,children:[n(`div`,{className:`flex items-center justify-between gap-2`,children:[n(`div`,{className:`flex min-w-0 items-center gap-2 px-1 font-medium`,children:[t(Am,{className:`size-3.5 shrink-0 text-muted`,"aria-hidden":`true`}),t(`span`,{className:`truncate`,children:s(`agent.activeWorkstreams`,{count:p.length})})]}),n(o,{variant:`ghost`,size:`icon`,onClick:()=>d(!u),title:s(u?`agent.showActiveWorkstreams`:`agent.hideActiveWorkstreams`),children:[t(u?fh:rh,{className:`size-4`}),s(u?`agent.showActiveWorkstreams`:`agent.hideActiveWorkstreams`)]})]}),u?null:n(e,{children:[t(`div`,{id:f,className:`flex flex-col gap-0.5`,children:m.map(r=>{let a=FH(r.workstream_id,r.interaction),s=n(e,{children:[t(`span`,{className:z(`size-1.5 shrink-0 rounded-full`,VH(r.status)),"aria-hidden":`true`}),t(`span`,{className:`truncate font-medium`,children:a}),r.phase&&t(`span`,{className:`truncate text-xs text-muted/75`,children:NH(r.phase)})]});return i?n(o,{type:`button`,variant:`ghost`,className:`h-auto min-w-0 justify-start gap-2 rounded-lg px-1 py-1 text-sm text-foreground/80`,title:a,onClick:()=>{l(!1),i(r.workstream_id)},children:[s,t(lh,{className:`ms-auto size-3.5 shrink-0 rtl:rotate-180`,"aria-hidden":`true`})]},r.launch_id||r.workstream_id):t(`div`,{className:`flex min-w-0 items-center gap-2 rounded-lg px-1 py-1 text-sm text-foreground/80`,title:a,children:s},r.launch_id||r.workstream_id)})}),g&&n(o,{type:`button`,variant:`ghost`,size:`sm`,className:`h-8 w-fit shrink-0 gap-1 rounded-xl px-2.5 text-xs text-muted`,"aria-expanded":c,"aria-controls":f,onClick:()=>l(e=>!e),children:[!c&&n(`span`,{children:[`+`,h]}),s(c?`agent.showLess`:`agent.showMore`),t(rh,{className:z(`size-3.5 transition-transform`,c&&`rotate-180`),"aria-hidden":`true`})]})]})]})})}const ZX=new er({strict:!1,validateFormats:!1});function QX(e){if(e!==wn.virtual_lb&&e!==wn.virtual_mediator&&e!==wn.test)return e}var $X=class{_listeners=new Set;snapshot;constructor(e){this.snapshot=new eZ(e,this)}subscribe=e=>(this._listeners.add(e),()=>{this._listeners.delete(e)});getSnapshot=()=>this.snapshot;notify(){this._listeners.forEach(e=>{e()})}},eZ=class e{vertesia;_interactive=!0;_debug_mode=!1;_non_blocking_subagents=!0;_checkpoint_tokens;_visibility;_user_channels;_collection;_disabled_mcp_collections;_start=!1;_preserveRunValues=!1;_interaction;_environment;_model=``;_model_options;_tool_names=[];_data;_mode=`start`;_scheduledWorkflowConfig;_interactionParamsSchema;_schemaVersion=0;_inputValidator;_store;constructor(e,t){this.vertesia=e,this._store=t}onStateChanged(){let e=this.clone();this._store.snapshot=e,this._store.notify()}clone(){let t=new e(this.vertesia,this._store);return t._interactionParamsSchema=this._interactionParamsSchema,t._schemaVersion=this._schemaVersion,t._interaction=this._interaction,t._data=this._data,t._environment=this._environment,t._model=this._model,t._model_options=this._model_options?{...this._model_options}:void 0,t._tool_names=[...this._tool_names],t._interactive=this._interactive,t._debug_mode=this._debug_mode,t._non_blocking_subagents=this._non_blocking_subagents,t._checkpoint_tokens=this._checkpoint_tokens,t._visibility=this._visibility,t._user_channels=this._user_channels?[...this._user_channels]:void 0,t._inputValidator=this._inputValidator,t._start=this._start,t._collection=this._collection,t._disabled_mcp_collections=this._disabled_mcp_collections?[...this._disabled_mcp_collections]:void 0,t._preserveRunValues=this._preserveRunValues,t._mode=this._mode,t._scheduledWorkflowConfig=this._scheduledWorkflowConfig,t}set mode(e){e!==this._mode&&(this._mode=e,e===`schedule`&&!this._scheduledWorkflowConfig&&(this._scheduledWorkflowConfig={name:``,description:``,cron_expression:`0 9 * * *`,timezone:`UTC`}),this.onStateChanged())}get mode(){return this._mode}set scheduledWorkflowConfig(e){this._scheduledWorkflowConfig=e,this.onStateChanged()}get scheduledWorkflowConfig(){return this._scheduledWorkflowConfig}updateScheduledWorkflowConfig(e){this._scheduledWorkflowConfig={...this._scheduledWorkflowConfig,...e},this.onStateChanged()}get interactive(){return this._interactive}set interactive(e){e!==this._interactive&&(this._interactive=e,this.onStateChanged())}get debug_mode(){return this._debug_mode}set debug_mode(e){e!==this._debug_mode&&(this._debug_mode=e,this.onStateChanged())}get non_blocking_subagents(){return this._non_blocking_subagents}set non_blocking_subagents(e){e!==this._non_blocking_subagents&&(this._non_blocking_subagents=e,this.onStateChanged())}get checkpoint_tokens(){return this._checkpoint_tokens}set checkpoint_tokens(e){e!==this._checkpoint_tokens&&(this._checkpoint_tokens=e,this.onStateChanged())}get visibility(){return this._visibility}set visibility(e){e!==this._visibility&&(this._visibility=e,this.onStateChanged())}get user_channels(){return this._user_channels}set user_channels(e){this._user_channels=e,this.onStateChanged()}get collection(){return this._collection}set collection(e){e!==this._collection&&(this._collection=e,this.onStateChanged())}get disabled_mcp_collections(){return this._disabled_mcp_collections}set disabled_mcp_collections(e){this._disabled_mcp_collections=e&&e.length>0?e:void 0,this.onStateChanged()}get search_scope(){return this._collection?ln.Collection:void 0}async restoreConversation(e){let t=e.interaction;e.version&&(/^[a-fA-F0-9]{24}$/.test(t)||(t=`${t}@${e.version}`));let n=await this.vertesia.interactions.catalog.resolve(t),r=n.runtime?.environment||e.config?.environment,i=e.config?.model,a=await(r?this.vertesia.environments.retrieve(r).catch(()=>void 0):Promise.resolve(void 0));this._data=e.data,this.interaction=n,e.interactionParamsSchema!=null&&(this.interactionParamsSchema=e.interactionParamsSchema),this._tool_names=e.tool_names||[],this._interactive=e.interactive,this._debug_mode=e.debug_mode??!1,this._non_blocking_subagents=e.non_blocking_subagents??!0,this._checkpoint_tokens=e.checkpoint_tokens,this._user_channels=e.user_channels,this._disabled_mcp_collections=e.disabled_mcp_collections,this._model_options=e.config?.model_options,this.collection=e.collection_id??void 0,this._model_options=e.config?.model_options,this.environment=a,i&&(this._model=i),this.onStateChanged()}get interaction(){return this._interaction}set interaction(e){if(e?.id!==this._interaction?.id){if(this._interaction=e,this.interactionParamsSchema=e?On(e.prompts):void 0,this._inputValidator=void 0,e&&!this._preserveRunValues&&(this._model_options=e.model_options,e.runtime?.environment)){let t=e.runtime.environment;this.vertesia.environments.retrieve(t).then(e=>this.environment=e)}this.onStateChanged()}}get environment(){return this._environment}set environment(e){if(e?.id!==this._environment?.id){if(this._environment=e,!this._preserveRunValues){let t=e?QX(e.provider):void 0,n=this.interaction?.runtime?.model;this._model=n&&t&&jn(n,t)?n:e?.default_model&&t&&jn(e.default_model,t)?e.default_model:``}this.onStateChanged()}}get model(){return this._model}set model(e){e!==this._model&&(this._model=e||``,this.onStateChanged())}get model_options(){return this._model_options}set model_options(e){JSON.stringify(e)!==JSON.stringify(this._model_options)&&(this._model_options=e,this.onStateChanged())}get tool_names(){return this._tool_names}set tool_names(e){this._tool_names=e,this.onStateChanged()}get data(){return this._data}set data(e){this._data=e,this.onStateChanged()}set run(e){console.log(`run`,e),this.onStateChanged()}set start(e){this._start!==e&&(this._start=e,this.onStateChanged())}markStarted(){this.start=!0}setMode(e){this.mode=e}setInteraction(e){this.interaction=e}setEnvironment(e){this.environment=e}setModel(e){this.model=e}setModelOptions(e){this.model_options=e}setToolNames(e){this.tool_names=e}setCollection(e){this.collection=e}setDisabledMcpCollections(e){this.disabled_mcp_collections=e}setInteractive(e){this.interactive=e}setDebugMode(e){this.debug_mode=e}setUserChannels(e){this.user_channels=e}setCheckpointTokens(e){this.checkpoint_tokens=e}setVisibility(e){this.visibility=e}setData(e){this.data=e}setDraftData(e){this._data=e}setPreserveRunValues(e){this.preserveRunValues=e}get start(){return this._start}get preserveRunValues(){return this._preserveRunValues}set preserveRunValues(e){this._preserveRunValues=e}get schemaVersion(){return this._schemaVersion}get interactionParamsSchema(){return this._interactionParamsSchema}set interactionParamsSchema(e){this._interactionParamsSchema!==e&&(this._interactionParamsSchema=e,this._schemaVersion+=1,e&&(this._data=this.initializeBooleanDefaults(this._data||{},e)),this.onStateChanged())}initializeBooleanDefaults(e,t){if(!t.properties)return e;let n={...e};for(let[e,r]of Object.entries(t.properties)){let t=r;t.type===`boolean`&&n[e]===void 0?n[e]=!1:t.type===`object`&&t.properties&&(n[e]=this.initializeBooleanDefaults(n[e]||{},t))}return n}reset(){if(this._start=!1,this._interactive=!0,this._debug_mode=!1,this._non_blocking_subagents=!0,this._checkpoint_tokens=void 0,this._visibility=void 0,this._user_channels=void 0,this._collection=void 0,this._disabled_mcp_collections=void 0,this._preserveRunValues=!1,this._model=``,this._model_options=void 0,this._environment=void 0,this._tool_names=[],this._interaction=void 0,this._data=void 0,this._interactionParamsSchema=null,this._inputValidator=void 0,this.model=void 0,this.environment=void 0,this.onStateChanged(),location.hash){let e=window.location.origin+window.location.pathname+window.location.search;history.replaceState(null,``,e),location.hash=``}}validateInput(){if(!this._interactionParamsSchema)return{isValid:!0};(!this._inputValidator||this._inputValidator.schema!==this._interactionParamsSchema)&&(this._inputValidator={validate:ZX.compile(this._interactionParamsSchema),schema:this._interactionParamsSchema});let e=this._data||{};return this._inputValidator.validate(e)?{isValid:!0}:{isValid:!1,errorMessage:this._inputValidator.validate.errors?this._inputValidator.validate.errors.map(e=>`${e.instancePath}: ${e.message}`).join(`, `):`Invalid payload data`}}};const tZ=dt(void 0);function nZ({children:e}){let{client:n}=q(),[r]=G(()=>new $X(n)),i=xt(r.subscribe,r.getSnapshot);return t(tZ.Provider,{value:i,children:e})}function rZ(){let e=_t(tZ);if(!e)throw Error(`usePayloadBuilder must be used within a PayloadProvider`);return e}Q();function iZ(){let{router:e}=$n();return t=>{let n=t.startsWith(`/`)?e.getTopRouter().navigator.addStickyParams(t):t;return window.open(n,`_blank`,`noopener,noreferrer`),n}}function aZ({title:e,variant:r=`full`,isTerminal:i=!1,onClose:a,isModal:s,agentRunId:c,workflowRunId:l,viewMode:u,onViewModeChange:d,showPlanPanel:f,showPlanButton:p=!0,onTogglePlanPanel:m,showPlaybackButton:h=!1,isPlaybackEnabled:g=!1,onTogglePlayback:_,onDownload:v,onExportFixture:y,resetWorkflow:b,onExportPdf:x,onShowDetails:S,allowWorkflowControl:C=!0,onClone:w,isReceivingChunks:T=!1,className:E}){let{t:D}=K(),O=iZ(),k=r===`compact`,A=u===`sliding`?`stacked`:`sliding`,j=D(`agent.verbose`),M=D(`agent.summary`),N=A===`stacked`?j:M,P=n(`div`,{className:z(k?`flex flex-row items-center gap-1 lg:flex-col`:`flex justify-end items-center gap-2 ms-auto`),children:[p&&t(`div`,{className:`relative`,children:n(o,{size:r===`compact`?`icon`:`sm`,variant:f?`primary`:`ghost`,onClick:m,className:z(`transition-all duration-200 rounded-md`,r===`compact`&&`size-8 rounded-lg`),title:D(`agent.toggleRightSidebar`),children:[t(eg,{className:z(`size-4`,r===`full`&&`me-1.5`)}),r===`full`?t(`span`,{className:`font-medium text-xs`,children:D(f?`agent.hideSidebar`:`agent.showSidebar`)}):t(`span`,{className:`sr-only`,children:D(f?`agent.hideSidebar`:`agent.showSidebar`)})]})}),k?t(o,{variant:`ghost`,size:`icon`,onClick:()=>d(A),className:`size-8 rounded-lg`,title:N,"aria-label":N,children:t(A===`stacked`?xy:vv,{className:`size-4`})}):n(`div`,{className:`flex items-center gap-1 bg-muted rounded p-0.5 mt-2 lg:mt-0`,children:[n(o,{variant:u===`stacked`?`outline`:`ghost`,size:`xs`,onClick:()=>d(`stacked`),"aria-pressed":u===`stacked`,className:`gap-1.5`,children:[t(xy,{className:`size-3.5`}),j]}),n(o,{variant:u===`sliding`?`outline`:`ghost`,size:`xs`,onClick:()=>d(`sliding`),"aria-pressed":u===`sliding`,className:`gap-1.5`,children:[t(vv,{className:`size-3.5`}),M]})]}),h&&_&&n(o,{type:`button`,size:r===`compact`?`icon`:`sm`,variant:g?`primary`:`ghost`,onClick:_,"aria-pressed":g,title:D(`agent.rewind.label`),className:z(`transition-all duration-200 rounded-md`,r===`compact`&&`size-8 rounded-lg`),children:[t(Gm,{className:z(`size-4`,r===`full`&&`me-1.5`)}),r===`full`?t(`span`,{className:`font-medium text-xs`,children:D(`agent.rewind.label`)}):t(`span`,{className:`sr-only`,children:D(`agent.rewind.label`)})]}),c&&t(o,{type:`button`,size:k?`icon`:`xs`,variant:`ghost`,onClick:()=>O(`/store/agent-runner/${c}`),title:D(`agent.openInNewTab`),className:z(`transition-all duration-200 rounded-md`,k&&`size-8 rounded-lg`),children:t(Dg,{className:`size-4`})}),b&&t(o,{type:`button`,size:r===`compact`?`icon`:`sm`,variant:`ghost`,onClick:b,title:D(`agent.startNewConversation`),className:z(`transition-all duration-200 rounded-md`,r===`compact`&&`size-8 rounded-lg`),children:t(hv,{className:z(`size-4`,r===`full`&&`me-1.5`)})}),t(oZ,{compact:k,agentRunId:c,workflowRunId:l,isModal:s,isTerminal:i,onClose:a,onDownload:v,onExportFixture:y,resetWorkflow:b,onExportPdf:x,onShowDetails:S,allowWorkflowControl:C,onClone:w}),a&&!s&&t(o,{size:`xs`,variant:`ghost`,onClick:a,"aria-label":D(`agent.close`),children:t(Gb,{className:`size-4`})})]});return r===`compact`?t(nZ,{children:t(`div`,{className:z(`inline-flex items-center rounded-xl border border-border/70 bg-background/90 p-1 shadow-lg shadow-black/10 backdrop-blur`,E),children:P})}):t(nZ,{children:n(`div`,{className:z(`flex flex-wrap items-center justify-between py-1.5 px-2 border-b shadow-sm flex-shrink-0`,E),children:[n(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n(`div`,{className:`flex items-center gap-1`,children:[t(Am,{className:`size-5 text-muted`}),t(`span`,{className:`font-medium`,children:e})]}),n(`span`,{className:`text-xs text-muted ms-1 flex items-center gap-1.5`,children:[`(Agent Run ID: `,c,`)`,t(`span`,{className:z(`w-2 h-2 rounded-full transition-colors duration-200`,T?`bg-purple-500 shadow-[0_0_6px_2px_rgba(168,85,247,0.6)]`:`bg-muted`)})]})]}),P]})})}function oZ({compact:e=!1,agentRunId:r,workflowRunId:i,isModal:a,isTerminal:s,onClose:c,onDownload:l,onExportFixture:u,resetWorkflow:d,onExportPdf:f,onShowDetails:p,allowWorkflowControl:m=!0,onClone:h}){let{t:g}=K(),_=nt(),{client:v}=q(),y=rZ();return t(w,{align:`right`,trigger:t(o,{size:e?`icon`:`xs`,variant:`ghost`,title:g(`agent.moreActions`),className:e?`size-8 rounded-lg`:void 0,children:t(wg,{className:`size-4`})}),children:n(ie,{label:`Actions`,children:[n(ae,{onClick:()=>{navigator.clipboard.writeText(r),_({status:`success`,title:g(`agent.agentRunIdCopied`),duration:2e3})},children:[t(fg,{className:`size-3.5 text-muted`}),` `,g(`agent.copyAgentRunId`)]}),n(ae,{onClick:()=>{navigator.clipboard.writeText(i),_({status:`success`,title:g(`agent.workflowRunIdCopied`),duration:2e3})},children:[t(fg,{className:`size-3.5 text-muted`}),` `,g(`agent.copyWorkflowRunId`)]}),p&&n(ae,{onClick:p,children:[t(A_,{className:`size-3.5 text-muted`}),` `,g(`agent.details`)]}),n(ae,{onClick:()=>{l?l():iU(v,r).then(e=>window.open(e,`_blank`))},children:[t(og,{className:`size-3.5 text-muted`}),` `,g(`agent.downloadConversation`)]}),f&&n(ae,{onClick:f,children:[t(og,{className:`size-3.5 text-muted`}),` `,g(`agent.exportAsPdf`)]}),u&&n(ae,{onClick:u,children:[t(og,{className:`size-3.5 text-muted`}),` `,g(`agent.rewind.exportFixture`)]}),c&&a&&n(ae,{onClick:c,children:[t(Gb,{className:`size-3.5 text-muted`}),` `,g(`agent.close`)]}),h&&n(ae,{onClick:async()=>{try{let e=await v.agents.fork(r);_({status:`success`,title:g(`agent.conversationCloned`),duration:2e3}),h?.(e)}catch{_({status:`error`,title:g(`agent.failedToCloneConversation`),duration:2e3})}},children:[t(v_,{className:`size-3.5 text-muted`}),` `,g(`agent.cloneConversation`)]}),m&&!s&&n(ae,{onClick:async()=>{try{return await v.agents.terminate(r,`cancel`),_({status:`success`,title:g(`agent.workflowCancelled`),duration:2e3}),y.reset(),d?.(),!0}catch{return _({status:`error`,title:g(`agent.failedToCancelWorkflow`),duration:2e3}),!1}},variant:`destructive`,children:[t(Gb,{className:`size-3.5`}),` `,g(`agent.cancelWorkflow`)]})]})})}function sZ(e){return typeof e==`object`&&!!e&&`value`in e}function cZ(e){return sZ(e)?e.value:e}function lZ(e){if(e.type===`stringList`)return e.value.map(e=>typeof e==`string`?e:cZ(e));if(e.multiple)return e.value.map(cZ);let t=e.value[0];return t===void 0?void 0:cZ(t)}function uZ(e,t,n){e.query[t]=n}function dZ(e){let t=new Set(e);return e=>t.has(e)}const fZ=[`sys`,`app`,`tmp`],pZ=/^[0-9a-fA-F]{24}$/;function mZ(e){let t=e.indexOf(`:`),n=t>0?e.slice(0,t):void 0;return n&&fZ.includes(n)?{type:n,label:e.slice(t+1)}:{label:e}}function hZ(e,...t){let n=[e?.name,...t].filter(e=>!!e),r=n.find(e=>!pZ.test(e));if(r)return r;let i=n[0];return i?`Deleted interaction (~${i.slice(-8)})`:void 0}function gZ(e){return!!e&&e.version===0&&e.status===hn.unknown}function _Z({interaction:e,className:n}){let r=`success`;switch(e.status){case hn.published:r=`success`;break;case hn.archived:r=`destructive`;break;case hn.code:r=`info`}let a=[e.version?`v${e.version}`:``,e.status&&e.status!==hn.unknown?e.status:``].filter(Boolean).join(` `);return a?t(i,{variant:r,className:n,children:a}):null}function vZ({interaction:r,fallbacks:a=[],fallbackNode:o=null}){let s=hZ(r,...a);if(!s)return t(e,{children:o});let{type:c,label:l}=mZ(s),u=!!r&&!gZ(r);return n(e,{children:[l,(c||u)&&n(`div`,{className:`flex items-center mt-1.5 shrink-0 gap-2`,children:[c&&t(i,{variant:`secondary`,children:c}),u&&r&&t(_Z,{interaction:r})]})]})}function yZ(e,t){return hZ(e,t)??t}function bZ({buckets:e,name:r,placeholder:a}){let o=e.map(e=>({label:`(${e.count})`,value:e._id}));return{name:r,placeholder:a||`${r.charAt(0).toUpperCase()+r.slice(1)}`,options:o,type:`select`,labelRenderer:r=>{let a=e.find(e=>e._id===r),{type:o,label:s}=mZ(yZ(a,r));return n(`div`,{className:`w-full flex items-center justify-between`,children:[n(`div`,{className:`flex flex-row flex-wrap items-center gap-2 min-w-0 flex-1`,children:[t(`span`,{className:`text-sm truncate`,children:s}),o&&t(i,{variant:`secondary`,className:`text-xs w-fit`,children:o}),a&&t(_Z,{interaction:a,className:`text-xs w-fit`})]}),(a?.count??0)>0&&n(`span`,{className:`ms-2 text-xs shrink-0`,children:[`(`,a?.count,`)`]})]})},filterBy:(t,n)=>yZ(e.find(e=>e._id===t),t).toLowerCase().includes(n.toLowerCase())}}function xZ(e){return`${e._id} (${e.count})`}function SZ(e){return`${e.name} (${e.count})`}function CZ({buckets:e,name:t,placeholder:n,type:r=`select`,multiple:i=!1}){return{name:t,options:e.map(e=>({label:xZ(e),value:e._id})),type:r,multiple:i,placeholder:`${n??`${t.charAt(0).toUpperCase()+t.slice(1)}`}`,allowCreate:!1}}function wZ({buckets:e,name:t,placeholder:n,type:r,multiple:i}){return CZ({buckets:e,name:t,placeholder:n,type:r,multiple:i})}Q();const TZ={},EZ={},DZ={};function OZ(e){return typeof e==`object`&&!!e&&`status`in e&&e.status===404}function kZ(e,t,n){let r=e[t];return r||(r=n().catch(n=>{throw OZ(n)||delete e[t],n}),e[t]=r),r}function AZ(e){let{client:t}=q();return Ye(()=>kZ(TZ,e,()=>t.users.retrieve(e)),{deps:[e],condition:()=>!!e})}function jZ(e){let{client:t}=q();return Ye(()=>kZ(EZ,e,()=>t.iam.groups.retrieve(e)),{deps:[e],condition:()=>!!e})}function MZ(e){let{client:t}=q();return Ye(()=>kZ(DZ,e,()=>t.apikeys.retrieve(e)),{deps:[e],condition:()=>!!e})}function NZ(){return t(`div`,{className:`size-8`})}function PZ({showTitle:e=!1,size:i=`md`}){let{t:a}=K();return t(KZ,{title:a(`user.systemUser`),description:a(`user.systemUserDescription`),children:n(`div`,{className:`flex gap-2 items-center`,children:[t(r,{src:`/icon.svg`,size:i}),e&&t(`div`,{className:`text-sm font-semibold ps-2`,children:a(`user.systemUser`)})]})})}function FZ({showTitle:e=!1,size:r=`md`}){let{t:i}=K();return t(KZ,{title:i(`user.allProjectMembers`),description:i(`user.allProjectMembersDescription`),children:n(`div`,{className:`flex gap-2 items-center`,children:[t(Ab,{className:`size-4`,size:r}),e&&t(`div`,{className:`text-sm font-semibold ps-2`,children:i(`user.allProjectMembers`)})]})})}function IZ({accountId:i,showTitle:a=!1,size:o=`md`}){let{t:s}=K(),c=n(e,{children:[t(`div`,{children:s(`user.serviceAccountDescription`)}),n(`div`,{className:`text-muted text-sm`,children:[t(`span`,{className:`font-semibold`,children:`ID:`}),` `,i]})]});return t(KZ,{title:s(`user.serviceAccount`),description:c,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[t(r,{src:`/cloud.svg`,name:`SA`,color:`bg-amber-500`,className:`px-[5px] text-white`,size:o}),a&&n(`div`,{className:`text-sm font-semibold ps-2 truncate`,children:[s(`user.serviceAccount`),` : ~`,i.slice(-6)]})]})})}function LZ({email:i,showTitle:a=!1,size:o=`md`}){let{t:s}=K(),c=n(e,{children:[t(`div`,{children:s(`user.agentOnBehalfOf`)}),n(`div`,{className:`text-muted text-sm`,children:[t(`span`,{className:`font-semibold`,children:`Email:`}),` `,i]})]});return t(KZ,{title:`Email Agent`,description:c,children:n(`div`,{className:`flex items-center gap-2`,children:[n(`div`,{className:`flex items-center -space-x-2`,children:[t(r,{src:`/cloud.svg`,color:`bg-amber-500`,className:`px-[5px] text-white border-2 border-background`,size:o}),t(r,{name:i,size:o,className:`border-2 border-background`})]}),a&&n(`div`,{className:`text-sm font-semibold truncate`,children:[`Agent (`,i,`)`]})]})})}function RZ({agentId:i,onBehalfOfType:a,onBehalfOfId:o,showTitle:s=!1,size:c=`md`,isScheduleAgent:l=!1}){let{t:u}=K(),d=a===`user`&&o,f=a===`apikey`&&o,p=AZ(o||``),m=MZ(o||``),h=d?p.data:void 0,g=f?m.data:void 0,_=i.slice(-6),v=h?u(`user.agentOnBehalfOf`):g?u(`user.agentOnBehalfOfApiKey`):`${u(`user.serviceAccount`)}~${_}`,y=l?u(`user.schedule`,{title:v}):v,b=n(`div`,{className:`space-y-2`,children:[h&&n(`div`,{className:`flex items-center gap-2`,children:[t(r,{src:h.picture,name:h.name,size:`sm`}),n(`div`,{children:[t(`div`,{className:`font-medium`,children:h.name||h.email}),h.email&&h.name&&t(`div`,{className:`text-xs text-muted`,children:h.email})]})]}),g&&n(`div`,{children:[t(`div`,{className:`font-medium`,children:g.name}),n(`div`,{className:`text-xs text-muted`,children:[`Key ID: `,g.id]})]}),!h&&!g&&n(e,{children:[t(`div`,{children:u(`user.serviceAccountDescription`)}),n(`div`,{className:`text-foreground dark:text-muted text-sm`,children:[t(`span`,{className:`font-semibold`,children:`ID:`}),` `,i]})]})]});return t(KZ,{title:y,description:b,children:n(`div`,{className:`flex items-center gap-2`,children:[n(`div`,{className:`flex items-center -space-x-2`,children:[t(r,{src:`/cloud.svg`,color:`bg-amber-500`,className:`px-[5px] text-white border-2 border-background`,size:c}),h&&t(r,{src:h.picture,name:h.name,size:c,className:`border-2 border-background`}),g&&t(r,{name:`API`,color:`bg-gray-400`,size:c,className:`border-2 border-background`})]}),s&&t(`div`,{className:`text-sm font-semibold truncate`,children:h?`Agent (${h.name||h.email})`:g?`Agent (${g.name})`:v})]})})}function zZ({title:e=`Error`,error:n,showTitle:r=!1,size:i=`md`}){return t(HZ,{title:e,message:Ge(n),color:`bg-red-500`,showTitle:r,size:i})}function BZ({showTitle:e=!1,size:n=`md`,color:r}){let{t:i}=K();return t(HZ,{title:i(`user.unknownUser`),message:i(`user.unknownUserDescription`),color:r,showTitle:e,size:n})}function VZ({userRef:e,showTitle:n=!1,size:r=`md`}){let{t:i}=K();if(!e)return t(HZ,{title:i(`user.unknownUser`),message:i(`user.unknownUserDescription`),showTitle:n,size:r});let a=e.split(`:`),o=a[0];switch(o){case bn.User:return t(WZ,{userId:a[1],showTitle:n,size:r});case bn.Group:return t(UZ,{userId:a[1],showTitle:n,size:r});case`system`:return t(PZ,{showTitle:n,size:r});case bn.ServiceAccount:return t(IZ,{accountId:a.slice(1).join(`:`),showTitle:n,size:r});case bn.Agent:{let e,i,o;return a[1]===`agent`?(e=a.slice(2,5).join(`:`),i=a[5],o=a[6]):(e=a.slice(1,4).join(`:`),i=a[4],o=a[5]),t(RZ,{agentId:e,onBehalfOfType:i,onBehalfOfId:o,showTitle:n,size:r})}case bn.Schedule:{let e=a[2]===`agent`?a.slice(3,6).join(`:`):`unknown-agent`,i=a[6],o=a[7];return t(RZ,{agentId:e,onBehalfOfType:i,onBehalfOfId:o,showTitle:n,size:r,isScheduleAgent:!0})}case`email`:return t(LZ,{email:a[1],showTitle:n,size:r});case bn.ApiKey:return t(GZ,{keyId:a[1],size:r,showTitle:n});case`project`:if(a[1]===`*`)return t(FZ,{showTitle:n,size:r});break;default:return t(zZ,{title:i(`user.unknownUser`),error:`Invalid user ref type: ${o}`,showTitle:n,size:r})}}function HZ({title:e,message:i,color:a,size:o=`md`,showTitle:s=!1}){return t(KZ,{title:e,description:i,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[t(r,{color:a,size:o}),s&&t(`div`,{className:`text-sm font-semibold ps-1`,children:e})]})})}function UZ({userId:e,showTitle:r=!1,size:i=`md`}){let{t:a}=K(),{data:o,error:s}=jZ(e);if(s)return OZ(s)?t(BZ,{showTitle:r,size:i,color:`bg-indigo-500`}):t(zZ,{title:a(`user.failedToFetchGroup`),error:s,showTitle:r,size:i});if(!o)return t(NZ,{});let c=n(`div`,{className:`space-y-1`,children:[o.description&&t(`div`,{className:`text-sm`,children:o.description}),t(`div`,{className:`text-xs text-muted`,children:a(`user.groupId`,{id:o.id})}),o.tags&&o.tags.length>0&&t(`div`,{className:`flex flex-wrap gap-1`,children:o.tags.map(e=>t(`span`,{className:`px-1.5 py-0.5 bg-muted rounded text-xs`,children:e},e))})]});return t(KZ,{title:o.name||a(`user.unnamedGroup`),description:c,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[t(Nb,{className:`size-6 text-info`,size:i}),r&&t(`div`,{className:`text-sm font-semibold ps-2`,children:o.name||a(`user.unnamedGroup`)})]})})}function WZ({userId:e,showTitle:i=!1,size:a=`md`}){let{t:o}=K(),{data:s,error:c}=AZ(e);if(c)return OZ(c)?t(BZ,{showTitle:i,size:a,color:`bg-indigo-500`}):t(zZ,{title:o(`user.failedToFetchUser`),error:c,showTitle:i,size:a});if(!s)return t(NZ,{});let l=t(`div`,{className:`truncate`,title:s.email,children:s.email});return t(KZ,{title:s.name||s.email||s.username||o(`user.unknown`),description:l,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[t(r,{src:s.picture,name:s.name,color:`bg-indigo-500`,size:a}),i&&t(`div`,{className:`text-sm font-semibold ps-2`,children:s.name||s.email||s.username||o(`user.unknown`)})]})})}function GZ({keyId:e,showTitle:i=!1,size:a=`md`}){let{t:o}=K(),{data:s,error:c}=MZ(e);if(c)return OZ(c)?t(BZ,{showTitle:i,size:a,color:`bg-pink-500`}):t(zZ,{title:o(`user.failedToFetchApiKey`),error:c,showTitle:i,size:a});if(!s)return t(NZ,{});let l=o(`user.privateKey`),u=t(r,{name:`PK`,color:`bg-pink-500`,size:a}),d=n(Le,{className:`dark:bg-muted dark:text-foreground table-fixed w-full`,children:[n(`tr`,{children:[t(`td`,{className:`font-semibold w-20`,children:o(`user.key`)}),t(`td`,{className:`truncate max-w-0`,children:s?.name})]}),n(`tr`,{children:[t(`td`,{className:`font-semibold w-20`,children:o(`user.account`)}),t(`td`,{className:`truncate max-w-0`,children:s?.account})]}),n(`tr`,{children:[t(`td`,{className:`font-semibold w-20`,children:o(`user.project`)}),t(`td`,{className:`truncate max-w-0`,children:s?.project.name})]})]});return t(KZ,{title:l,description:d,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[u,i&&t(`div`,{className:`text-sm font-semibold`,children:s?.name||s?.account||s?.project.name||o(`user.unknown`)})]})})}function KZ({title:e,description:r,children:i}){return n(he,{hover:!0,children:[t(_e,{className:`cursor-pointer flex items-center inline-block`,children:t(`div`,{children:i})}),t(ge,{align:`center`,sideOffset:8,side:`right`,children:n(`div`,{className:`flex flex-col gap-1 rounded-md shadow-md p-2`,children:[t(`div`,{className:`text-base font-semibold`,children:e}),r]})})]})}function qZ({buckets:e,name:r,placeholder:i}){let a=e.map(e=>({value:e._id,label:`(${e.count})`}));return{name:r,placeholder:i||`${r.charAt(0).toUpperCase()+r.slice(1)}`,options:a,labelRenderer:r=>{if(r===`Unknown User`||!r)return`Unknown User (${e.find(e=>e._id===r)?.count||0})`;let i=e.find(e=>e._id===r);return n(`div`,{className:`flex items-center w-full gap-2`,children:[t(`div`,{className:`flex-1 min-w-0 flex items-center truncate`,children:t(VZ,{userRef:r,showTitle:!0,size:`sm`})}),n(`span`,{className:`text-muted flex-shrink-0`,children:[`(`,i?.count||0,`)`]})]})}}}function JZ({buckets:e,name:t,placeholder:n}){return qZ({buckets:e,name:t,placeholder:n})}Q();const YZ=dZ([`id`,`run_kind`,`interaction`,`status`,`initiated_by`,`start`,`end`]);function XZ(e){let t=[];return t.push({name:`id`,placeholder:`Agent Run ID`,type:`text`,multiple:!1}),t.push(wZ({buckets:e.kinds||[],name:`run_kind`,placeholder:`Kind`})),t.push(bZ({buckets:e.interactions||[],name:`interaction`,placeholder:`Interaction`})),t.push(wZ({buckets:e.statuses||[],name:`status`,placeholder:`Status`})),t.push(JZ({buckets:e.initiated_by||[],name:`initiated_by`,placeholder:`Initiated By`})),t.push({name:`start`,placeholder:`Started After`,type:`date`,multiple:!1}),t.push({name:`end`,placeholder:`Started Before`,type:`date`,multiple:!1}),t}function ZZ(e){return t=>{e.clearFilters(!1,!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!YZ(t.name))return;let n=t.name;uZ(e,n,lZ(t))}}),e.search()}}function QZ({facets:e,search:r,selectionCount:i,actions:a,filters:s,setFilters:c,filterGroups:l}){let[u,d]=G([]),f=s??u,p=c??d,m=W(!1),h=W(typeof window<`u`&&!!new URLSearchParams(window.location.search).get(`filters`)),g=XZ(e),_=l??g,v=U(()=>ZZ(r),[r]);return H(()=>{if(!m.current){m.current=!0;return}if(h.current){h.current=!1;return}v(f)},[f,v]),t(I,{filterGroups:_,filters:f,setFilters:p,children:n(`div`,{className:`gap-2 items-center w-full`,children:[n(`div`,{className:`flex justify-between mb-1`,children:[t(P,{}),n(`div`,{className:`flex justify-end`,children:[!i&&t(`div`,{className:`flex items-center justify-between px-2 py-1`,children:t(`div`,{className:`text-sm text-muted`,children:r.initialized?`${r.totalCount} runs`:`Loading runs...`})}),a&&a.length>0?t(`div`,{className:`flex items-center gap-2 mb-1 me-2`,children:a.map((e,n)=>t(`div`,{children:e},`action-${n}`))}):null,t(o,{onClick:()=>{r.search()},variant:`outline`,title:`Refresh`,children:t(hy,{className:`size-5`})})]})]}),f.length>0&&n(`div`,{className:`flex items-center gap-2 mb-1`,children:[t(N,{}),t(F,{})]})]})})}var $Z=class{types;map={};constructor(e){this.types=e,e.sort((e,t)=>e.name.localeCompare(t.name));for(let t of e)this.map[t.id]=t}getType(e){return this.map[e]}getTypeLayout(e){let t=this.map[e];return t?t.table_layout:void 0}getTypeName(e){let t=this.map[e];return t?t.name:void 0}};const eQ=dt({registry:void 0,isLoading:!1,load:()=>Promise.resolve(),reload:()=>Promise.resolve()});function tQ({children:e}){let{store:n,project:r}=q(),[i,a]=G(),[o,s]=G(!1),c=W(!1),l=W(r?.id),u=V(async()=>{if(!(!r||c.current)){c.current=!0,s(!0);try{let e=await n.types.catalog.list({layout:!0});a(new $Z(e))}catch(e){console.error(`Failed to fetch types`,e)}finally{s(!1),c.current=!1}}},[n,r]),d=V(async()=>(c.current=!1,u()),[u]);return H(()=>{l.current!==r?.id&&(l.current=r?.id,a(void 0),c.current=!1)}),t(eQ.Provider,{value:{registry:i,isLoading:o,load:u,reload:d},children:e})}function nQ(){let e=_t(eQ);return H(()=>{!e.registry&&!e.isLoading&&e.load()},[e.registry,e.isLoading,e.load]),e}const rQ=dZ([`name`,`types`]);function iQ(e){let{registry:t}=nQ(),n=[];if(n.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t){let e=t.types.map(e=>({label:e.name,value:e.id})),r={name:`types`,placeholder:`Type`,type:`select`,multiple:!0,options:e,filterBy:(t,n)=>e.find(e=>e.value===t)?.label?.toLowerCase().includes(n.toLowerCase())??!1};n.push(r)}return n}function aQ(e){return t=>{if(t.length===0){e.clearFilters(!0);return}e.clearFilters(!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!rQ(t.name))return;let n=t.name;uZ(e,n,lZ(t))}}),e.search()}}function oQ({facets:e,search:r,filters:i,setFilters:a,filterGroups:o}){let[s,c]=G([]),l=iQ(e),u=aQ(r),d=i!==void 0&&a!==void 0;return t(I,{filterGroups:o??l,filters:d?i:s,setFilters:e=>{if(d){a(e);return}let t=typeof e==`function`?e(s):e;c(t),u(t)},children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function sQ({buckets:e,typeRegistry:r,type:i=`select`,multiple:a=!1}){let o=new Map;return r||console.warn(`Type names cannot be resolved`),e.forEach(e=>{let t,n=e._id;e._id==null?(n=`Document`,t=`Document`):(t=r?.getTypeName(e._id),t||=(console.warn(`Content Object Type not found`,e._id),e._id)),o.set(n,{name:t,count:e.count})}),{name:`types`,placeholder:`Types`,type:i,multiple:a,options:e.map(e=>{let t=e._id,n=t||`Document`,r=o.get(n);return{value:t,label:r?`${r.name} (${r.count})`:`Unknown (${e.count})`}}),labelRenderer:e=>{let r=o.get(e);return r?n(`div`,{className:`w-full flex items-center`,children:[t(`span`,{className:`text-sm truncate`,children:r.name}),n(`span`,{className:`ms-2 text-xs`,children:[`(`,r.count,`)`]})]}):(console.warn(`Type data not found for ${e}`),e)},filterBy:(e,t)=>{let n=o.get(e);return n?n.name.toLowerCase().includes(t.toLowerCase()):(console.warn(`Type name not found for ${e}`),!1)}}}const cQ=[`id`,`name`,`types`,`status`],lQ=[`tags`,`created_at`,`updated_at`],uQ=dZ(cQ),dQ=new Set(lQ);function fQ(e){return dQ.has(e)}function pQ(e){return Array.isArray(e)?e:[]}function mQ(e){let{registry:t}=nQ(),n=[];if(n.push({placeholder:`ID`,name:`id`,type:`text`,options:[]}),n.push({placeholder:`Name`,name:`name`,type:`text`,options:[]}),e.type){let r=sQ({buckets:pQ(e.type),typeRegistry:t,type:`select`,multiple:!0});n.push(r)}if(e.status){let t=wZ({buckets:pQ(e.status),name:`status`,placeholder:`Status`,type:`select`,multiple:!0});n.push(t)}return e.tags&&n.push({name:`tags`,placeholder:`Tags`,type:`stringList`,options:pQ(e.tags).map(e=>({label:e._id,value:e._id}))}),n.push({name:`created_at`,placeholder:`Created Date`,type:`date`,multiple:!0,options:[]}),n.push({name:`updated_at`,placeholder:`Updated Date`,type:`date`,multiple:!0,options:[]}),n}function hQ(e){return t=>{if(t.length===0){e.clearFilters();return}e.clearFilters(!1),t.forEach(t=>{if(t.value&&t.value.length>0){let n=t.name,r;if(t.type===`date`&&t.multiple){if(Array.isArray(t.value)&&t.value.length>0){if(t.value.length===1){let e=cZ(t.value[0]);r={gte:e,lte:e}}else t.value.length===2&&(r={gte:cZ(t.value[0]),lte:cZ(t.value[1])})}}else r=lZ(t);uQ(n)?uZ(e,n,r):fQ(n)&&r!==void 0&&(e.query.match={...e.query.match,[n]:r})}}),e.search()}}function gQ({facets:e,search:r}){let[i,a]=G([]),o=mQ(e),s=hQ(r),c=$e();return t(I,{filterGroups:o,filters:i,setFilters:e=>{let t=typeof e==`function`?e(i):e;a(t),s(t)},inModal:c,children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function _Q({search:e,buckets:n,placeholder:r=`All Environments`,className:i}){let{client:a}=q(),[o,s]=G([]),c=e.getFilterValue(`environment`),l=t=>{e.setFilterValue(`environment`,t?._id)};H(()=>{if(a){let e=n.map(async e=>{let t;return await a.environments.retrieve(e._id).then(e=>{t=e.name}).catch(()=>{t=`${e._id} (deleted)`}),t||=e._id,{...e,name:t}});Promise.all(e).then(e=>{e.sort((e,t)=>e.name.localeCompare(t.name)),s(e)})}},[n,a]);let u=o?.find(e=>e._id===c);return t(we,{filterBy:`name`,className:i,isClearable:!0,optionLabel:SZ,options:o,value:u,onChange:l,by:`_id`,placeholder:r})}const vQ=dZ([`name`,`prompt`,`model`,`tags`]);function yQ(e){let t=[];return t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t.push({name:`prompt`,placeholder:`Prompt Name`,type:`text`,multiple:!1}),t.push({name:`model`,placeholder:`Model`,type:`text`,multiple:!1}),t.push({name:`tags`,placeholder:`Tags`,type:`stringList`,multiple:!0}),t}function bQ(e){return t=>{if(t.length===0){e.clearFilters(!0,!0);return}e.clearFilters(!1,!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!vQ(t.name))return;let n=t.name;uZ(e,n,lZ(t))}}),e.search(!0)}}function xQ({facets:e,search:r,filters:i,setFilters:a,filterGroups:o}){let[s,c]=G([]),l=yQ(e),u=bQ(r),d=i!==void 0&&a!==void 0;return t(I,{filterGroups:o??l,filters:d?i:s,setFilters:e=>{if(d){a(e);return}let t=typeof e==`function`?e(s):e;c(t),u(t)},children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function SQ(e){let t=[];return t.push(wZ({buckets:e.statuses||[],name:`status`,placeholder:`Status`,multiple:!1})),t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t}function CQ({facets:e,filters:r,setFilters:i}){let a=SQ(e);return t(I,{filterGroups:a,filters:r,setFilters:i,children:n(`div`,{className:`flex items-center gap-2`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function wQ(e){let t=[];return t.push(wZ({buckets:e.statuses||[],name:`status`,placeholder:`Status`,multiple:!0})),t.push(JZ({buckets:e.started_by||[],name:`started_by`,placeholder:`Started By`})),t.push(wZ({buckets:e.run_type||[],name:`run_type`,placeholder:`Mode`,multiple:!0})),t.push(wZ({buckets:e.processes||[],name:`process`,placeholder:`Process`,multiple:!0})),t.push({name:`start`,placeholder:`Started After`,type:`date`,multiple:!1}),t.push({name:`end`,placeholder:`Started Before`,type:`date`,multiple:!1}),t}function TQ({facets:e,filters:r,setFilters:i}){let a=wQ(e);return t(I,{filterGroups:a,filters:r,setFilters:i,children:n(`div`,{className:`flex items-center gap-2`,children:[t(P,{}),t(N,{}),t(F,{})]})})}const EQ=dZ([`name`,`role`,`tags`]);function DQ(e,t){let n=e[t];return Array.isArray(n)?n:[]}function OQ(e){let t=DQ(e,`role`),n=[];if(n.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t.length>0){let e={name:`role`,placeholder:`Role`,type:`select`,options:t.map(e=>({label:e._id,value:e._id,count:e.count}))};n.push(e)}let r={name:`tags`,placeholder:`Tags`,type:`stringList`,multiple:!0,options:DQ(e,`tags`).map(e=>({label:e._id,value:e._id}))};return n.push(r),n}function kQ(e){return t=>{if(t.length===0){e.clearFilters(!0,!1);return}e.clearFilters(!1,!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!EQ(t.name))return;let n=t.name;uZ(e,n,lZ(t))}}),e.search()}}function AQ({facets:e,search:r,filters:i,setFilters:a,filterGroups:o}){let[s,c]=G([]),l=OQ(e),u=kQ(r),d=i!==void 0&&a!==void 0;return t(I,{filterGroups:o??l,filters:d?i:s,setFilters:e=>{if(d){a(e);return}let t=typeof e==`function`?e(s):e;c(t),u(t)},children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function jQ({buckets:e,name:r}){let i=e.map(e=>({label:`(${e.count})`,value:e._id}));return{name:`environment`,placeholder:r.charAt(0).toUpperCase()+r.slice(1),options:i,type:`select`,labelRenderer:r=>{let i=e.find(e=>e._id===r),a=i?.name||r;return n(`div`,{className:`w-full flex items-center`,children:[t(`span`,{className:`text-sm truncate`,children:a}),n(`span`,{className:`ms-2 text-xs`,children:[`(`,i?.count||0,`)`]})]})},filterBy:(t,n)=>(e.find(e=>e._id===t)?.name||t).toLowerCase().includes(n.toLowerCase())}}Q();const MQ=dZ([`run_ids`,`interaction`,`environment`,`tags`,`model`,`status`,`finish_reason`,`start`,`end`,`workflow_run_ids`,`workflow_ids`]);function NQ(e){return e.filter(e=>e._id!==null)}function PQ(e){let t=[];if(t.push({name:`run_ids`,placeholder:`Run ID`,type:`text`,multiple:!1}),e.interactions){let n=bZ({buckets:NQ(e.interactions),name:`interaction`,placeholder:`Interactions`});t.push(n)}if(e.environments){let n=jQ({buckets:NQ(e.environments),name:`environment`});t.push(n)}if(t.push({name:`tags`,placeholder:`Tags`,type:`stringList`,multiple:!0}),e.models){let n=wZ({buckets:NQ(e.models),name:`model`});t.push(n)}if(e.statuses){let n=wZ({buckets:NQ(e.statuses),name:`status`});t.push(n)}if(e.finish_reason){let n=wZ({buckets:e.finish_reason.map(e=>({...e,_id:e._id===null?`none`:e._id})),name:`finish_reason`,placeholder:`Finish Reason`});t.push(n)}return t.push({name:`start`,placeholder:`Date After`,type:`date`,multiple:!1}),t.push({name:`end`,placeholder:`Date Before`,type:`date`,multiple:!1}),t.push({name:`workflow_run_ids`,placeholder:`Workflow Run ID`,type:`text`,multiple:!1}),t.push({name:`workflow_ids`,placeholder:`Workflow ID`,type:`text`,multiple:!1}),t}function FQ(e){return t=>{if(t.length===0){e.clearFilters(!0,!1);return}e.clearFilters(!1,!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!MQ(t.name))return;let n=t.name,r=lZ(t);(n===`run_ids`||n===`workflow_run_ids`||n===`workflow_ids`)&&!Array.isArray(r)&&(r=[r]),uZ(e,n,r)}}),e.search()}}function IQ({facets:e,search:r,actions:i,selectionCount:a,filters:s,setFilters:c,filterGroups:l}){let[u,d]=G([]),f=PQ(e),p=FQ(r),m=s!==void 0&&c!==void 0,h=m?s:u;return t(I,{filterGroups:l??f,filters:h,setFilters:e=>{if(m){c(e);return}let t=typeof e==`function`?e(u):e;d(t),p(t)},children:n(`div`,{className:`gap-2 items-center w-full`,children:[n(`div`,{className:`flex justify-between mb-1`,children:[t(P,{}),n(`div`,{className:`flex justify-end`,children:[!a&&t(`div`,{className:`flex items-center justify-between px-2 py-1`,children:t(`div`,{className:`text-sm text-muted`,children:r.initialized?`${r.totalCount} calls`:`Loading calls...`})}),i&&i.length>0?t(`div`,{className:`flex items-center gap-2 mb-1 me-2`,children:i.map((e,n)=>t(`div`,{children:e},`action-${n}`))}):null,t(o,{onClick:()=>{r.search()},variant:`outline`,title:`Refresh`,children:t(hy,{className:`size-5`})})]})]}),h.length>0&&n(`div`,{className:`flex items-center gap-2 mb-1`,children:[t(N,{}),t(F,{})]})]})})}function LQ({search:e,buckets:n,name:r,placeholder:i,className:a}){let o=e.getFilterValue(r),s=t=>{e.setFilterValue(r,t?._id)},c=n?.find(e=>JSON.stringify(e._id)===JSON.stringify(o));return t(we,{filterBy:`_id`,className:a,isClearable:!0,optionLabel:xZ,options:n,value:c,onChange:s,by:`_id`,placeholder:i})}function RQ({search:e,name:n,placeholder:r,className:i}){let[a,o]=G([]);return H(()=>{e.setFilterValue(n,a)},[n,e,a]),t(ne,{className:i,value:a,onChange:o,placeholder:r})}function zQ(e){return`${e.name} (${e.count})`}function BQ({search:e,buckets:n,placeholder:r=`Filter by Type`,className:i}){let[a,o]=G([]),{registry:s}=nQ(),c=e.getFilterValue(`type`),l=t=>{e.setFilterValue(`type`,t?._id)};H(()=>{if(s){let e=n.map(e=>{let t;return e._id==null?(e._id=`Document`,t=`Document`):(t=s.getTypeName(e._id),t||=(console.warn(`Content Object Type not found`,e._id),e._id)),{...e,name:t}});e.sort((e,t)=>e.name.localeCompare(t.name)),o(e)}},[n,s]);let u=a?.find(e=>e._id===c);return t(we,{filterBy:`name`,className:i,isClearable:!0,optionLabel:zQ,options:a,value:u,onChange:l,by:`_id`,placeholder:r})}function VQ(e){let t=[];return t.push(wZ({buckets:e.tags||[],name:`tags`,placeholder:`Tags`,multiple:!0})),t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t}function HQ({facets:e,filters:r,setFilters:i}){let a=VQ(e);return t(I,{filterGroups:a,filters:r,setFilters:i,children:n(`div`,{className:`flex items-center gap-2`,children:[t(P,{}),t(N,{}),t(F,{})]})})}const UQ=dZ([`search_term`,`status`,`initiated_by`,`start`,`end`,`has_reported_errors`]);function WQ(e){let t=[];if(t.push({placeholder:`Workflow Name or Workflow Run ID`,name:`search_term`,type:`text`,options:[]}),e.status){let n=wZ({buckets:e.status||[],name:`status`,placeholder:`Status`});t.push({...n,name:`status`})}if(e.initiated_by){let n=JZ({buckets:e.initiated_by||[],name:`initiated_by`,placeholder:`Initiated By`});t.push({...n,name:`initiated_by`})}return t.push({name:`start`,placeholder:`Date After`,type:`date`,multiple:!1}),t.push({name:`end`,placeholder:`Date Before`,type:`date`,multiple:!1}),t.push({name:`has_reported_errors`,placeholder:`Has Reported Errors`,type:`select`,multiple:!1,options:[{label:`Yes`,value:`true`},{label:`No`,value:`false`}]}),t}function GQ(e){return t=>{if(t.length===0){e.clearFilters();return}e.clearFilters(!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!UQ(t.name))return;let n=t.name,r=lZ(t);if(n===`has_reported_errors`){let t=Array.isArray(r)?r[0]:r;(t===`true`||t===`false`)&&uZ(e,n,t===`true`)}else typeof r==`string`&&uZ(e,n,r)}}),e.search()}}function KQ({facets:e,search:r}){let[i,a]=G([]),o=WQ(e),s=GQ(r);return t(I,{filterGroups:o,filters:i,setFilters:e=>{let t=typeof e==`function`?e(i):e;a(t),s(t)},children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function qQ(e){let t=[];return t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t}function JQ({facets:e,filters:r,setFilters:i}){let a=qQ(e);return t(I,{filterGroups:a,filters:r,setFilters:i,children:n(`div`,{className:`flex items-center gap-2`,children:[t(P,{}),t(N,{}),t(F,{})]})})}var YQ=class e{object;objects;setState;collectionId;singleSelection=!1;constructor(e,t,n,r){this.object=e,this.objects=n,this.setState=r,this.singleSelection=Object.keys(this.objects).length===0,this.collectionId=t}isSingleSelection(){return this.singleSelection}hasSelection(){return this.object!==void 0||this.size()!==0}size(){return Object.keys(this.objects).length}getObjectIds(){return Object.keys(this.objects)}getObjectId(){return this.object?.id}clone(){return new e(this.object,this.collectionId,this.objects,this.setState)}add(e){this.objects[e.id]=e,this.singleSelection=Object.keys(this.objects).length===0,this.setState(this.clone())}remove(e){delete this.objects[e],this.singleSelection=Object.keys(this.objects).length===0,this.setState(this.clone())}addAll(e){for(let t of e)this.objects[t.id]=t;this.setState(this.clone())}isSelected(e){return this.objects[e]!==void 0}removeAll(){this.objects={},this.singleSelection=!0,this.setState(this.clone())}};const XQ=dt(void 0);function ZQ(){let e=_t(XQ);if(!e)throw Error(`useObjectSelection must be used within a ObjectSelectionProvider`);return e}function QQ(){return _t(XQ)}function $Q({value:e,collectionId:n,children:r}){let[i,a]=G();return H(()=>{let t=new YQ(e,n,{},a);a(t)},[n,e]),i&&t(XQ.Provider,{value:i,children:r})}Q();const e$=dt(void 0);function t$({onFilter:e,children:n}){return t(e$.Provider,{value:e,children:n})}function n$(){return _t(e$)}const r$=`h-6 w-6 p-0 opacity-0 group-hover/field:opacity-100 text-muted hover:text-foreground transition-opacity shrink-0`;function i$({field:r,value:i,label:a,copyContent:s}){let c=n$(),l=Array.isArray(i)?i.length>0:i!==void 0&&i!==``;return n(e,{children:[s!==void 0&&s!==``&&t(x,{content:s,className:r$}),l&&i!==void 0&&t(o,{variant:`ghost`,size:`sm`,title:`Filter by ${a}`,className:r$,onClick:e=>{e.stopPropagation(),c?.(r,i)},children:t(l_,{className:`size-3`})})]})}const a$=`text/csv`,o$=`image/`,s$=`application/pdf`,c$=`video/`,l$=[`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,`application/msword`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`,`application/vnd.ms-powerpoint`],u$=e=>e===a$||a$.includes(e),d$=e=>e.startsWith(o$)||o$.includes(e),f$=e=>e===s$||s$.includes(e),p$=e=>e.startsWith(c$)||c$.includes(e),m$=e=>l$.includes(e);function h$(e,t){if(typeof window>`u`||typeof document>`u`)return!1;let n=document.createElement(`iframe`);n.style.position=`fixed`,n.style.right=`0`,n.style.bottom=`0`,n.style.width=`0`,n.style.height=`0`,n.style.border=`0`,n.style.visibility=`hidden`,document.body.appendChild(n);let r=n.contentWindow;if(!r)return n.parentNode?.removeChild(n),!1;let i=r.document;i.open(),i.write(`<!doctype html><html><head><title></title></head><body></body></html>`),i.close(),i.title=t,document.querySelectorAll(`link[rel="stylesheet"], style`).forEach(e=>{i.head.appendChild(e.cloneNode(!0))});let a=i.createElement(`style`);return a.textContent=`
1253
1253
  @media print {
1254
1254
  body {
1255
1255
  margin: 24px;
@@ -1374,30 +1374,30 @@ $&`)),t.includes(` - `)&&(t=t.replace(/(^|\S)\s+-\s+/g,`$1
1374
1374
  page-break-inside: avoid;
1375
1375
  }
1376
1376
  }
1377
- `,i.head.appendChild(a),i.body.innerHTML=e.innerHTML,r.focus(),r.print(),setTimeout(()=>{n.parentNode?.removeChild(n)},1e3),!0}const h$={max_hw:import.meta.env?.VITE_RENDITION_HW||256,format:mn.jpeg,generate_if_missing:!0},g$=`vertesia.content_store.renditionId`;async function _$(e,t,n,r,i){if(!t?.content?.type||!(u$(t.content.type)||f$(t.content.type)||d$(t.content.type))){i(`No preview available`);return}i(`Preparing preview...`);let a=Date.now()/1e3,o=localStorage.getItem(`${g$}_${t.id}_${h$.max_hw}`),s=localStorage.getItem(`${g$}_${t.id}_${h$.max_hw}_time`);if(o?.length&&s&&Math.abs(a-parseInt(s,10))<=900)return n(o),r(`${t.name} Rendition`),i(`ready`),o;i(`Preparing preview...`),e.objects.getRendition(t.id,h$).then(a=>{if(a.status===`generating`)i(`Preparing preview...`),n(``),r(``),setTimeout(()=>_$(e,t,n,r,i),6e4);else if(a.status===`failed`){i(`No preview available`),n(``),r(``);return}else{if(!a?.renditions?.length){i(`No preview available`),n(``),r(``);return}let e=a.renditions[0];localStorage.setItem(`${g$}_${t.id}_${h$.max_hw}`,e),localStorage.setItem(`${g$}_${t.id}_${h$.max_hw}_time`,(Date.now()/1e3).toString()),n(e),r(`${t.name} Rendition`),i(`ready`),console.log(`Rendition for document ${t.id} retrieved successfully: ${e}`)}}).catch(e=>{i(`No preview available`),console.warn(`Failed to retrieve rendition:`,e),n(``),r(``)})}function v$(e,t=7){return e?`~${e.slice(-t)}`:``}function y$(e,t){return e.length>t?`${e.substring(0,t)}...`:e}function b$(e){switch(e){case Tn.RUNNING:return`text-info`;case Tn.COMPLETED:return`text-success`;case Tn.FAILED:return`text-destructive`;case Tn.TERMINATED:case Tn.CANCELED:return`text-attention`;default:return`text-muted`}}function x$(e){switch(e){case Tn.RUNNING:return`Running`;case Tn.COMPLETED:return`Completed`;case Tn.FAILED:return`Failed`;case Tn.CONTINUED_AS_NEW:return`Continued As New`;case Tn.TERMINATED:return`Terminated`;case Tn.TIMED_OUT:return`Timed Out`;case Tn.CANCELED:return`Canceled`;default:return`Unknown`}}Q();function S$(e){return typeof e==`object`&&!!e}function C$(e,t){if(!S$(e))return;let n=e[t];return typeof n==`string`?n:void 0}function w$(e){return typeof e==`string`?e:C$(e,`id`)||``}function T$(e){return e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`?e:String(e)}const E$={string(e,r){let i=[];if(e){let t=e.get(`slice`);t&&i.push(e=>e.slice(parseInt(t,10)));let n=e.get(`max_length`);n&&i.push(e=>e.slice(0,parseInt(n,10))),e.has(`upper`)&&i.push(e=>e.toUpperCase()),e.has(`lower`)&&i.push(e=>e.toLowerCase()),e.has(`capitalize`)&&i.push(e=>e[0].toUpperCase()+e.substring(1)),e.has(`ellipsis`)&&i.push(e=>`${e}...`)}return(e,r,a)=>{let o;if(e){if(o=String(e),i.length>0)for(let e of i)o=e(o)}else o=``;return t(`td`,{className:`group/field`,children:a?n(`div`,{className:`flex items-center gap-2 min-w-0`,children:[t(`span`,{className:`truncate`,children:o}),a]}):o},r)}},fileSize(e,n){return(e,n)=>{let r=``;if(e){let t=Number(e);if(Number.isNaN(t))r=String(e);else{let e=[`Bytes`,`KB`,`MB`,`GB`,`TB`];if(t===0)r=`0 Bytes`;else{let n=Math.floor(Math.log(t)/Math.log(1024));r=`${(t/1024**n).toFixed(2)} ${e[n]}`}}}return t(`td`,{className:`group/field`,children:r},n)}},number(e,n){let r,i;e&&(r=e.get(`currency`)||void 0,i=e.get(`decimals`)||void 0);let a=i?parseInt(i,10):2;return(e,n)=>{let i=Number(e),o=new Intl.NumberFormat(`en-US`,{style:r?`currency`:`decimal`,currency:r,maximumFractionDigits:a}).format(Number.isFinite(i)?i:0);return t(`td`,{className:`group/field`,children:o},n)}},objectId(e,r){let i=[],a=!1;if(e){let t=e.get(`slice`);t&&(a=!0,i.push(e=>e.slice(parseInt(t,10))))}return(e,s,c)=>{let l=w$(e),u=i.reduce((e,t)=>t(e),l);return n(`td`,{className:`flex justify-start items-center gap-2 group/field`,children:[t(o,{variant:`ghost`,title:`Preview Object`,onClick:e=>{e.stopPropagation(),r?.(l)},children:t(Ag,{className:`size-4`})}),a?`~`:``,u,c]},s)}},objectName(e,r){let i=`title`;return e&&(i=e.get(`title`)||`title`),(e,r,a)=>{let o=(S$(e)&&S$(e.properties)?e.properties:void 0)?.[i],s=T$(o),c=C$(e,`name`),l=C$(e,`id`),u=s||c||(l?v$(l):``);return t(`td`,{className:`group/field`,children:a?n(`div`,{className:`flex items-center gap-2 min-w-0`,children:[t(`span`,{className:`truncate`,children:u}),a]}):u},r)}},objectLink(e,r){let i=[];return i.push(e=>e.slice(-7)),(e,a)=>{let s=w$(e),c=i.reduce((e,t)=>t(e),s);return n(`td`,{className:`flex justify-between items-center gap-2 max-w-48 group/field`,children:[`~`,c,t(o,{variant:`ghost`,title:`Preview Object`,onClick:e=>{e.stopPropagation(),r?.(s)},children:t(Ag,{className:`size-4`})})]},a)}},typeLink(e,r){return(e,r,i)=>{let a=C$(e,`name`)||`n/a`;return t(`td`,{className:`group/field`,children:i?n(`div`,{className:`flex items-center gap-2 min-w-0`,children:[t(`span`,{className:`truncate`,children:a}),i]}):a},r)}},revision(e,r){return(e,r)=>{let i=S$(e)&&S$(e.revision)?e.revision:void 0;if(!i)return t(`td`,{},r);let a=C$(i,`root`),o=C$(i,`label`);return t(`td`,{className:`group/field`,children:n(`div`,{className:`flex flex-col gap-0.5`,children:[a&&n(`div`,{className:`flex items-center gap-1`,children:[n(`span`,{className:`text-xs text-muted font-mono`,children:[`root: ~`,a.slice(-7)]}),t(`a`,{href:`/store/objects/${a}`,onClick:e=>e.stopPropagation(),children:t(Dg,{className:`size-3 text-muted`})})]}),o&&n(`span`,{className:`text-xs text-muted`,children:[`label: `,o]})]})},r)}},date(e,r){let i=`fromNow`,a;if(e){let t=e.get(`localized`);if(t)i=`format`,a=t;else{let t=e.get(`relative`);t&&(i=t)}}return(e,r,o)=>{let s=typeof e==`string`||typeof e==`number`||e instanceof Date?e:void 0;if(s===void 0)return t(`td`,{children:o},r);let c=WD(s),l=i===`format`?c.format(a):i===`toNow`?c.toNow():c.fromNow();return t(`td`,{className:`group/field`,children:n(`div`,{className:`flex items-center gap-2`,children:[t(We,{description:c.format(`LLL`),children:l}),o]})},r)}}},D$=E$.string();function O$(e){return typeof e==`object`&&!!e}function k$(e,t){let n=e;if(!n)return;if(!t.length)return n;let r=t.length-1;for(let e=0;e<r;e++)if(!O$(n)||(n=n[t[e]],!n))return;if(O$(n))return n[t[r]]}function A$(e){return!e||e===`.`?[]:e.split(`.`)}var j$=class{layout;renderer=D$;path;fallbackPath;previewObject;constructor(e,t){if(this.layout=e,this.path=A$(e.field||``),this.fallbackPath=e.fallback?A$(e.fallback):void 0,this.previewObject=t,e.render)this.renderer=(e,t)=>null;else{let t=e.type||`string`,n=t.indexOf(`?`);if(n>0){let e=t.substring(0,n),r=new URLSearchParams(t.substring(n+1));this.renderer=E$[e](r)}else this.renderer=E$[t]()}}get name(){return this.layout.name}resolveValue(e){let t=k$(e,this.path);return t===void 0&&this.fallbackPath&&(t=k$(e,this.fallbackPath)),t===void 0&&(t=this.layout.default),t}render(e,n){if(this.layout.render)return t(`td`,{className:`whitespace-nowrap px-3 py-4 text-sm group`,children:this.layout.render(e)},n);let r=this.layout.type||`string`,i=r.indexOf(`?`)>0?r.substring(0,r.indexOf(`?`)):r,a=this.buildActions(e,i);if((i===`objectId`||i===`objectLink`)&&this.previewObject){let t=r.indexOf(`?`),o=t>0?new URLSearchParams(r.substring(t+1)):void 0;return E$[i](o,t=>{this.previewObject?.(e.id)})(e,n,a)}return this.renderer(this.resolveValue(e),n,a)}buildActions(e,n){let r=this.layout.field;if(n===`objectId`||n===`objectLink`||r===`id`)return t(r$,{field:`id`,value:e.id,label:e.id,copyContent:e.id});if(n===`objectName`||r===`name`)return t(r$,{field:`name`,value:e.name,label:e.name??e.id});if(n===`typeLink`||r===`type.name`||r===`type`){let n=e.type?.id;return t(r$,{field:`type`,value:n,label:e.type?.name??n??`type`})}if(r===`status`)return t(r$,{field:`status`,value:e.status,label:e.status})}};Q();function M$({isLoading:e=!1,counts:r=6}){return e?t(`div`,{className:`flex flex-wrap gap-2 justify-between`,children:Array(r).fill(0).map((e,r)=>t(`div`,{className:`w-[15vw] animate-pulse`,children:n(s,{className:`relative flex flex-col border h-fit`,children:[t(`div`,{className:`h-48 bg-muted rounded-t-xl flex items-center justify-center text-muted`,children:`\xA0`}),t(Ee,{className:`bg-muted h-[2px]`}),n(c,{className:`p-2 flex flex-col`,children:[n(`div`,{className:`flex flex-col overflow-hidden`,children:[t(`div`,{className:`h-5 bg-muted rounded w-3/4 mb-2`}),t(`div`,{className:`h-4 bg-muted rounded w-1/2`})]}),t(`div`,{className:`text-xs text-muted w-full flex justify-end mt-2`,children:t(`div`,{className:`h-3 bg-muted rounded w-1/4`})})]})]})},`skeleton-${r}`))}):null}function N$({selection:e,document:r,onSelectionChange:i,onRowClick:a,highlightRow:l,previewObject:u,selectedObject:d}){let{client:f}=q(),[p,m]=G(void 0),[h,g]=G(void 0),[_,v]=G(void 0),y=typeof r.properties?.title==`string`?r.properties.title:r.name,b=e=>{e.stopPropagation(),i(r,e)};H(()=>{r?.content&&_$(f,r,m,g,v)},[f,r]);let x=l?.(r);return n(s,{className:`relative flex flex-col border h-fit w-full ${d?.id===r.id?`border-attention border-4`:``} ${x?`border-info bg-info/50 dark:bg-info/20`:``}`,onClick:()=>a?.(r),children:[x&&t(`div`,{className:`absolute top-2 end-8 z-10`,children:t(eh,{className:`size-4 text-info`})}),e&&t(`div`,{className:`absolute top-2 start-2 z-10 flex flex-col items-center gap-1`,children:t(`input`,{checked:e.isSelected(r.id),type:`checkbox`,onChange:b,onClick:e=>e.stopPropagation()})}),t(`div`,{className:`absolute top-1 end-1 z-10 flex flex-col items-center`,children:t(o,{variant:`ghost`,size:`sm`,title:`Preview Object`,onClick:e=>{e.stopPropagation(),u?.(r.id)},children:t(Ag,{className:`size-4 ${_===`ready`?`text-muted`:`text-white`}`})})}),p&&_===`ready`?t(`img`,{src:p,alt:h,className:`w-auto h-48 object-cover rounded-t-xl`}):t(`div`,{className:`h-48 bg-muted rounded-t-xl flex items-center justify-center text-muted`,children:_}),t(Ee,{className:`bg-muted h-[2px]`}),n(c,{className:`p-2 flex flex-col`,children:[n(`div`,{className:`flex flex-col overflow-hidden`,children:[t(We,{placement:`top`,description:y,children:t(`h3`,{className:`text-start font-medium leading-none truncate`,children:y})}),r?.type?.name?t(We,{placement:`bottom`,size:`xs`,description:r?.type?.name,children:t(`p`,{className:`text-start text-xs text-muted truncate`,children:r?.type?.name})}):t(`p`,{className:`text-xs text-muted`,children:` `})]}),r.score&&n(`div`,{className:`text-xs text-muted w-full flex justify-end`,children:[`Score: `,r.score.toFixed(4)??`-`]})]})]})}Q();function P$({objects:e,selection:r,isLoading:i,columns:a,onRowClick:o,highlightRow:s,selectedObject:c,toggleAll:l,onSelectionChange:u}){let{t:d}=K();return n(Le,{className:`w-full`,children:[t(Fe,{children:n(`tr`,{children:[r&&t(`th`,{children:t(`input`,{type:`checkbox`,onChange:l})}),a.map(e=>t(`th`,{children:e.name},e.name))]})}),n(Pe,{isLoading:i,columns:a.length+1,children:[e?.map(e=>{let i=s?.(e);return n(`tr`,{className:`group cursor-pointer hover:bg-muted ${c?.id===e.id?`bg-muted`:``} ${i?`bg-info`:``}`,onClick:()=>{o?.(e)},children:[r&&t(`td`,{onClick:e=>e.stopPropagation(),children:t(`input`,{checked:r.isSelected(e.id),type:`checkbox`,className:`${r.isSelected(e.id)?``:`hidden group-hover:block`}`,onChange:t=>u(e,t)})}),a.map((t,n)=>t.render(e,n)),t(`td`,{className:`w-8 text-center`,children:i&&t(eh,{className:`size-4 text-info inline-block`})})]},e.id)}),e.length===0&&t(`tr`,{children:t(`td`,{colSpan:a.length+ +!!r,className:`text-center`,children:d(`store.noObjectsDragAndDrop`)})})]})]})}function F$({objects:r,selection:i,isLoading:a,onSelectionChange:o,onRowClick:s,highlightRow:c,previewObject:l,selectedObject:u}){return n(e,{children:[t(M$,{isLoading:a}),t(`div`,{className:`w-full gap-2 grid xs:grid-cols-1 sm:grid-cols-2 md:grid-cols-4 lg:grid-cols-6 @xs:grid-cols-1 @sm:grid-cols-2 @md:grid-cols-3 @lg:grid-cols-4`,children:r.map(e=>t(N$,{document:e,selection:i,onSelectionChange:o,onRowClick:s,highlightRow:c,previewObject:l,selectedObject:u},e.id))})]})}var I$=class{client;limit;collectionId;facets=new De({});result=new De({objects:[],isLoading:!1});initialized=!1;facetSpecs=[];query={};deletedIds=new Set;loadedCount=0;constructor(e,t=100){this.client=e,this.limit=t}withFacets(e){return this.facetSpecs=e,this}get objects(){return this.result.value.objects}get error(){return this.result.value.error}get isRunning(){return this.result.value.isLoading}get hasMore(){return this.result.value.hasMore||!1}getFilterValue(e){return this.query[e]}setFilterValue(e,t){this.query[e]=t,this.search()}setDefaultKeys(e){}clearFilters(e=!0){let{parent:t,full_text:n,vector:r,weights:i,score_aggregation:a,dynamic_scaling:o,limit:s,all_revisions:c}=this.query;this.query={parent:t,...n!==void 0&&{full_text:n},...r!==void 0&&{vector:r},...i!==void 0&&{weights:i},...a!==void 0&&{score_aggregation:a},...o!==void 0&&{dynamic_scaling:o},...s!==void 0&&{limit:s},...c!==void 0&&{all_revisions:c}},e&&this.search()}getFacetBuckets(e){let t=this.facets.value[e];return Array.isArray(t)?t:[]}resetFacets(){this.query={}}removeDeletedObjects(e){if(e.length===0)return;for(let t of e)this.deletedIds.add(t);let t=this.result.value,n=t.objects.filter(e=>!this.deletedIds.has(e.id)),r=t.objects.length-n.length;this.result.value={...t,objects:n};let i=this.facets.value;r>0&&typeof i.total==`number`&&(this.facets.value={...i,total:Math.max(0,i.total-r)})}reset(e=!1){this.initialized=!1,this.deletedIds.clear(),this.loadedCount=0,this.result.value={objects:[],isLoading:e,hasMore:!0}}_updateRunningState(e){let t=this.result.value;this.result.value={objects:t.objects,isLoading:e,error:t.error,hasMore:t.hasMore}}_searchRequest(e,t,n,r=!0){let i={limit:t,offset:n,query:e,facets:r?this.facetSpecs:void 0};return this.collectionId?this.client.collections.searchMembers(this.collectionId,i):this.client.objects.search(i)}_facetsRequest(){let e={facets:this.facetSpecs,query:this.query};return this.collectionId?this.client.collections.computeFacets(this.collectionId,e):this.client.objects.computeFacets(e)}computeFacets(e){this._facetsRequest().then(e=>{this.facets.value=e})}async _search(e=!1,t=!1){if(this.isRunning&&e)return!1;let n=this.result.value;e||(this.initialized=!0),this.result.value={isLoading:!0,objects:e?this.objects:[],hasMore:!e||this.result.value.hasMore};let r=this.limit,i=e?this.loadedCount:0;try{let n=await this._searchRequest(this.query,r,i,!t),a=n.results||[],o=n.facets||{};if(this.loadedCount=e?this.loadedCount+a.length:a.length,!e&&this.deletedIds.size>0)for(let e of[...this.deletedIds])a.some(t=>t.id===e)||this.deletedIds.delete(e);let s=this.deletedIds.size>0?a.filter(e=>!this.deletedIds.has(e.id)):a;return this.result.value={isLoading:!1,objects:e?this.objects.concat(s):s,hasMore:a.length===r},!t&&o&&Object.keys(o).length>0&&(this.facets.value=o),!0}catch(e){if(typeof e==`object`&&e&&`status`in e&&e.status===404)return this.result.value={isLoading:!1,objects:[],hasMore:!1},!1;let t=e instanceof Error?e:Error(String(e));return this.result.value={error:t,isLoading:!1,objects:n.objects,hasMore:!1},!1}}search(e=!1){return this.isRunning?Promise.resolve(!1):this._search(!1,e)}loadMore(e=!1){return this.isRunning||!this.hasMore||this.query.vector?Promise.resolve(!1):(this.objects.length>0&&(e=!0),this._search(!0,e))}};const L$=dt(void 0);function R$(){return _t(L$)}function z$(){return rt(R$().facets)}function B$(){let e=R$();return{...rt(e.result),search:e}}function V$(){let e=R$();return rt(e.facets).total}const H$=Xt.getFixedT(null,Yt);var U$;(function(e){e.CREATE=`create`,e.SKIP=`skip`,e.UPDATE=`update`})(U$||={});async function W$(e){try{let t=await e.arrayBuffer(),n=new nr;return n.appendByteArray(new Uint8Array(t)),n.end()?.toString()}catch(e){console.error(`Error calculating file hash:`,e);return}}async function G$(e,t){let n=[];for(let r=0;r<e.length;r+=5){let i=e.slice(r,r+5),a=await Promise.all(i.map(async e=>{let n=t||`/`;if(e.webkitRelativePath){let r=e.webkitRelativePath.split(`/`);if(r.length>1){let e=r.slice(0,-1).join(`/`);n=t?`${t}/${e}`:e}}return{file:e,hash:await W$(e),name:e.name,size:e.size,location:n}}));n.push(...a)}return n}function K$(){let{client:e}=q(),t=nt();return{checkDocumentProcessing:V(async(n,r,i)=>{try{console.log(`Preparing metadata for ${n.length} files...`);let t=await G$(n,r);return await(async()=>{let n=t.map(e=>e.hash).filter(Boolean);if(n.length===0)return;let r={"content.etag":{$in:n}},a;if(i){let t={query:{match:r},select:`id content.etag`};a=(await e.store.collections.searchMembers(i,t)).results.filter(e=>typeof e.id==`string`)}else{let t={query:r,select:`id content.etag`};a=(await e.store.objects.find(t)).flatMap(e=>typeof e.id==`string`?[{id:e.id,content:e.content}]:[])}for(let e of a){let n=t.find(t=>t.hash===e.content?.etag);n&&(n.existingId=e.id,n.action=U$.SKIP)}})(),await(async()=>{let n=t.filter(e=>e.action!==U$.SKIP),r=n.map(e=>e.location),a=Array.from(new Set(r)),o=[];for(let t of a){let r={"content.name":{$in:n.filter(e=>e.location===t).map(e=>e.name)},location:t||`/`};if(i){let t=e.store.collections.searchMembers(i,{query:{match:r},select:`id content.name location`}).then(e=>e.results);o.push(t)}else{let t=e.store.objects.find({query:r,select:`id content.name location`});o.push(t)}}let s=(await Promise.all(o)).flat();console.log(`Found ${s.length} document to update`,s);for(let e of s){let n=t.find(t=>t.name===e.content?.name&&(t.location?t.location===e.location:e.location===`/`));n&&(n.existingId=e.id,n.action=U$.UPDATE)}console.log(`Reconciled ${t.filter(e=>e.action===U$.UPDATE).length}`)})(),t.forEach(e=>{e.action||=U$.CREATE}),console.log(`Document processing check results:`,{totalFiles:n.length,toCreate:t.filter(e=>e.action===U$.CREATE).length,toUpdate:t.filter(e=>e.action===U$.UPDATE).length,toSkip:t.filter(e=>e.action===U$.SKIP).length}),t}catch(e){throw t({title:H$(`store.errorInUploadProcessingCheck`),status:`error`,description:Ge(e)}),console.log(`Error in file upload processing check`,e),Error(`Error in file upload processing check: ${Ge(e)}`,{cause:e})}},[e,t])}}Q();function q$({isOpen:r,onClose:i,files:a,collectionId:s,selectedFolder:c,title:l,children:u,onUploadComplete:d,hideFileSelection:f=!1,showTypeSelectionOnly:p=!1,allowFolders:m=!0,initialTypeId:h,defaultProperties:g}){let{client:_}=q(),{registry:v}=tQ(),y=nt(),{t:b}=K(),x=l??b(`upload.uploadFiles`),[S,C]=G([]),[w,T]=G([]),[E,D]=G(!1),[O,k]=G(null),[A,j]=G([]),[M,N]=G(!1),[P,F]=G(!1),[I,L]=G(0),[ee,R]=G(Date.now()),[te,ne]=G(void 0),[re,ie]=G(null),[ae,de]=G(x),[fe,pe]=G(``);H(()=>{s&&_.store.collections.retrieve(s).then(ne)},[_.store.collections.retrieve,s]),H(()=>{M?(de(b(`upload.uploadingFiles`)),pe(`${Math.round(I)}% complete`)):P?(de(b(`upload.uploadComplete`)),pe(``)):E?(de(b(`upload.fileAnalysisResults`)),pe(`${S.length} file${S.length===1?``:`s`}`)):S.length>0?(de(x),pe(b(`upload.checkingForDuplicates`))):(de(x),pe(``))},[M,P,E,x,I,S.length,b]);let me=()=>!te&&!c?null:n(oe,{className:`mb-4`,status:`default`,icon:t(o_,{className:`size-5`}),children:[t(`div`,{className:`flex items-center`,children:t(`span`,{className:`font-medium`,children:b(`upload.uploadLocation`)})}),n(`div`,{className:`text-sm mt-1`,children:[te&&n(`div`,{className:`flex items-center`,children:[t(`span`,{className:`me-1`,children:b(`upload.collectionLabel`)}),t(`span`,{className:`font-medium`,children:te.name})]}),c&&n(`div`,{className:`flex items-center mt-1`,children:[t(`span`,{className:`me-1`,children:b(`upload.folderLabel`)}),t(`span`,{className:`font-medium`,children:c})]})]})]}),[he,ge]=G({toCreate:0,toUpdate:0,toSkip:0}),{checkDocumentProcessing:_e}=K$(),ve=U(()=>v?.types||[],[v?.types]),ye=V(async e=>{if(e.length)try{console.log(`Processing ${e.length} files to determine required actions...`);let t=await _e(e,c,s);T(t);let n=t.filter(e=>e.action===U$.CREATE).length,r=t.filter(e=>e.action===U$.UPDATE).length,i=t.filter(e=>e.action===U$.SKIP).length;ge({toCreate:n,toUpdate:r,toSkip:i}),y({title:b(`upload.filesAnalyzed`),description:`${e.length} file(s): ${n} new, ${r} to update, ${i} to skip`,status:`info`,duration:4e3}),D(!0)}catch(e){console.error(`Error processing files:`,e),y({title:b(`agent.error`),description:b(`upload.errorAnalyzingFiles`),status:`error`,duration:5e3})}},[_e,s,c,b,y]);H(()=>{r&&(T([]),D(!1),k(h?v?.getType(h)??null:null),j([]),N(!1),F(!1),L(0),ge({toCreate:0,toUpdate:0,toSkip:0}),ie(null),de(x),pe(``),a&&a.length>0?(C(a),ye(a)):C([]),R(Date.now()))},[a,h,r,ye,x,v]);let be=()=>{C([]),T([]),D(!1),k(null),j([]),N(!1),F(!1),L(0),ge({toCreate:0,toUpdate:0,toSkip:0}),ie(null),de(x),pe(``),R(Date.now()),i()},xe=e=>{e&&e.length>0&&(C(e),ye(e))},Se=async()=>{if(!w.length)return;let e=O?.id||null,t=w.map(e=>({file:e.file,status:`pending`,progress:0,action:e.action===U$.CREATE?`create`:e.action===U$.UPDATE?`update`:`skip`}));j(t),N(!0),F(!1);let n=w.filter(e=>e.action===U$.SKIP),r=w.filter(e=>e.action===U$.UPDATE),i=w.filter(e=>e.action===U$.CREATE),a={success:!0,objectIds:[],uploadedFiles:[],skippedFiles:[],failedFiles:[]};for(let t of n)t.existingId&&(a.objectIds.push(t.existingId),a.skippedFiles.push({id:t.existingId,name:t.name,type:e,status:`skipped`,location:t.location}),j(e=>e.map(e=>e.file===t.file?{...e,status:`success`,progress:100,id:t.existingId}:e)));let o=async(t,n)=>{let r=[];for(let e=0;e<t.length;e+=50)r.push(t.slice(e,e+50));for(let i=0;i<r.length;i++){let o=r[i];if(console.log(`Processing ${n} batch ${i+1}/${r.length} (${o.length} files)`),t.length>50){let e=i*50;y({title:b(`upload.processingFilesAction`,{action:n}),description:b(`upload.processedCount`,{processed:e,total:t.length}),status:`info`,duration:2e3})}let c=0;await Promise.all(o.map(async t=>{try{if(j(e=>e.map(e=>e.file===t.file?{...e,status:`uploading`,progress:20}:e)),n===`update`&&t.existingId)await _.store.objects.update(t.existingId,{type:e||void 0,content:t.file,location:t.location,name:t.name},{createRevision:!0,revisionLabel:`upload on ${new Date().toISOString()}`}),j(e=>e.map(e=>e.file===t.file?{...e,status:`success`,progress:100,id:t.existingId}:e)),a.objectIds.push(t.existingId),a.uploadedFiles.push({id:t.existingId,name:t.name,type:e,status:`updated`,location:t.location});else{let n=await _.store.objects.create({type:e||void 0,content:t.file,location:t.location||t.file.webkitRelativePath||t.name,properties:g},{collection_id:s});j(e=>e.map(e=>e.file===t.file?{...e,status:`success`,progress:100,id:n.id}:e)),a.objectIds.push(n.id),a.uploadedFiles.push({id:n.id,name:t.name,type:e,status:`created`,location:t.location})}}catch(n){console.error(`Failed to process file ${t.name}:`,n),j(e=>e.map(e=>e.file===t.file?{...e,status:`error`,progress:100,message:Ge(n,`Unknown error`)}:e)),a.failedFiles.push({name:t.name,error:Ge(n,`Unknown error`),status:`failed`,location:t.location,type:e}),a.success=!1}c++,(c%5==0||c===o.length)&&j(e=>{let t=e.filter(e=>e.status===`success`||e.status===`error`).length,n=e.length,r=n>0?Math.round(t/n*100):0;return L(r),e})}))}};r.length>0&&await o(r,`update`),i.length>0&&await o(i,`create`),j(e=>{let t=e.filter(e=>e.status===`pending`).map(e=>({...e,status:`error`,progress:100,message:b(`upload.uploadProcessInterrupted`)}));return t.length>0?(t.forEach(e=>{a.failedFiles.push({name:e.file.name,error:b(`upload.uploadProcessInterrupted`),status:`failed`,type:O?.id||null})}),a.success=!1,e.map(e=>e.status===`pending`?{...e,status:`error`,progress:100,message:b(`upload.uploadProcessInterrupted`)}:e)):e}),N(!1),F(!0);let c=a.uploadedFiles.filter(e=>e.status===`created`).length,l=a.uploadedFiles.filter(e=>e.status===`updated`).length,u=a.skippedFiles.length,d=a.failedFiles.length,f=``;c>0&&(f+=`${c} file${c===1?``:`s`} uploaded`),l>0&&(f+=f?`, `:``,f+=`${l} file${l===1?``:`s`} updated`),u>0&&(f+=f?`, `:``,f+=`${u} file${u===1?``:`s`} skipped`),d>0&&(f+=f?`, `:``,f+=`${d} file${d===1?``:`s`} failed`),y({title:b(`upload.uploadComplete`),description:f,status:d>0?`warning`:`success`,duration:5e3}),ie(a)},Ce=()=>n(`div`,{className:`mb-4`,children:[n(`div`,{className:`block text-sm font-medium mb-2`,children:[b(`store.contentType`),` `,t(`span`,{className:`text-muted font-normal`,children:b(`store.optional`)}),t(We,{description:b(`upload.contentTypeTooltip`),placement:`top`,size:`xs`,children:t(A_,{className:`size-3 ms-2`})})]}),t(we,{options:ve,value:O,optionLabel:e=>e?e.name:b(`store.selectContentTypeLabel`),placeholder:b(`store.selectContentTypeAuto`),onChange:e=>k(e===void 0?null:e),filterBy:`name`,isClearable:!0}),!O&&t(`div`,{className:`p-2 rounded-md`,children:n(`div`,{className:`flex items-center text-attention`,children:[t(Nh,{className:`size-4 me-1`}),b(`store.automaticTypeDetection`),t(We,{description:b(`store.automaticTypeDetectionDescription`),placement:`top`,size:`xs`,children:t(A_,{className:`size-3 ms-2`})})]})})]});return n(se,{isOpen:r,onClose:be,className:`mx-auto`,disableCloseOnClickOutside:!0,children:[t(ue,{description:fe,children:ae}),p?n(ce,{children:[u,me(),Ce()]}):S.length===0&&!f?n(ce,{className:`flex flex-col items-center justify-center p-8`,children:[me(),t(Ot,{onDrop:xe,message:b(`upload.dragAndDrop`),buttonLabel:b(`upload.selectFiles`),className:`w-full h-64`,allowFolders:m}),u]}):!M&&!P?t(ce,{children:E?n(e,{children:[me(),t(`div`,{className:`mb-4`,children:t(`div`,{className:`p-4 rounded-md mb-4`,children:n(`div`,{className:`grid grid-cols-3 gap-4`,children:[n(`div`,{className:`flex flex-col items-center`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(wb,{className:`size-5 text-primary`}),t(`span`,{className:`font-medium`,children:b(`upload.new`)})]}),t(`div`,{className:`text-2xl font-semibold`,children:he.toCreate})]}),n(`div`,{className:`flex flex-col items-center`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(Nh,{className:`size-5 text-success`}),t(`span`,{className:`font-medium`,children:b(`upload.update`)})]}),t(`div`,{className:`text-2xl font-semibold`,children:he.toUpdate})]}),n(`div`,{className:`flex flex-col items-center`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(Ah,{className:`size-5 text-mixer-attention/40`}),t(`span`,{className:`font-medium`,children:b(`upload.skip`)})]}),t(`div`,{className:`text-2xl font-semibold`,children:he.toSkip})]})]})})}),Ce(),t(oe,{className:`mb-4`,status:`info`,children:he.toCreate+he.toUpdate>0?n(`div`,{className:`space-y-1`,children:[t(`p`,{children:b(`upload.filesReadyToProcess`,{count:he.toCreate+he.toUpdate})}),t(`p`,{children:he.toSkip>0&&b(`upload.filesToSkip`,{count:he.toSkip})})]}):he.toSkip>0?t(`span`,{children:b(`upload.allFilesExist`,{count:he.toSkip})}):t(`span`,{children:b(`upload.noFilesToProcess`)})})]}):n(`div`,{className:`flex flex-col items-center justify-center py-4`,children:[t(je,{size:`lg`,className:`mb-4`}),t(`div`,{className:`text-lg font-medium`,children:b(`upload.analyzingFiles`)})]})}):M?n(ce,{children:[me(),t(`div`,{className:`mb-4`,children:t(`div`,{className:`h-2 bg-muted/20 rounded-full overflow-hidden`,children:t(`div`,{className:`h-full bg-primary rounded-full`,style:{width:`${I}%`}})})}),t(`div`,{className:`max-h-96 overflow-y-auto`,children:A.map((e,r)=>n(`div`,{className:`flex items-center py-2 border-b border-border last:border-b-0`,children:[n(`div`,{className:`me-3`,children:[e.status===`pending`&&t(Zg,{className:`size-5 text-muted`}),e.status===`uploading`&&t(je,{size:`sm`}),e.status===`success`&&t(Nh,{className:`size-5 text-success`}),e.status===`error`&&t(Gh,{className:`size-5 text-destructive`})]}),n(`div`,{className:`flex-1 min-w-0`,children:[t(`div`,{className:`truncate font-medium`,children:e.file.name}),n(`div`,{className:`text-xs text-muted`,children:[e.status===`pending`&&b(`agent.waiting`),e.status===`uploading`&&b(`agent.uploading`),e.status===`success`&&(e.action===`create`?b(`store.created`):e.action===`update`?b(`store.updated`):b(`upload.skip`)),e.status===`error`&&e.message]})]})]},`${e.file.name}-${e.file.size}-${e.file.lastModified}`))})]}):t(ce,{children:n(`div`,{className:`mb-4`,children:[me(),t(Lt,{files:A.map(e=>{let t;return t=e.status===`success`?e.action===`create`?`success`:e.action===`update`?`updated`:`skipped`:`failed`,{name:e.file.name,status:t,error:e.status===`error`?e.message:void 0}}),location:c||void 0,collection:te?.name})]})}),(()=>{if(p)return n(le,{children:[t(o,{variant:`ghost`,onClick:be,children:b(`modal.cancel`)}),t(o,{onClick:()=>{let e={success:!0,objectIds:[],uploadedFiles:[{name:`type-selection`,type:O?.id||null,status:`created`}],skippedFiles:[],failedFiles:[]};d&&d(e),be()},children:O?b(`upload.useTypeName`,{typeName:O.name}):b(`upload.useAutoDetection`)})]});if(S.length===0&&!f)return t(le,{children:t(o,{variant:`ghost`,onClick:be,children:b(`modal.cancel`)})});if(!M&&!P){let e=E;return n(le,{children:[t(o,{variant:`ghost`,onClick:be,children:b(`modal.cancel`)}),t(o,{disabled:!e,onClick:Se,children:he.toCreate+he.toUpdate>0?b(`agent.upload`):b(`upload.continue`)})]})}return M?t(le,{children:t(o,{variant:`ghost`,disabled:!0,children:b(`agent.uploading`)})}):n(le,{children:[t(o,{variant:`ghost`,onClick:()=>{C([]),T([]),D(!1),k(null),j([]),N(!1),F(!1),L(0),ge({toCreate:0,toUpdate:0,toSkip:0})},children:b(`upload.uploadMore`)}),t(o,{onClick:()=>{d&&re&&d(re),be()},children:b(`agent.close`)})]})})()]},ee)}function J$(e){let t=typeof e==`function`?e:e.onUploadDone,{client:n,project:r,store:i}=q(),a=R$(),o=nt(),s=Xt.getFixedT(null,Yt),{checkDocumentProcessing:c}=K$();return async(e,l,u)=>{let d={success:!1,objectIds:[],uploadedFiles:[],skippedFiles:[],failedFiles:[]};if(!r)return o({status:`error`,title:s(`store.noProjectSelected`),duration:3e3}),d;if(!e||e.length===0)return o({status:`warning`,title:s(`store.noFilesSelected`),duration:3e3}),d;let f=Array.from(e).filter(e=>e.size>0);if(f.length===0)return o({status:`error`,title:s(`store.noValidFilesSelected`),description:s(`store.pleaseSelectValidFiles`),duration:5e3}),d;let p=[],m=[],h=[];console.log(`Processing ${f.length} files with smart file processing...`);let g=await c(f,null,u),_=g.filter(e=>e.action===U$.CREATE).length,v=g.filter(e=>e.action===U$.UPDATE).length,y=g.filter(e=>e.action===U$.SKIP).length;o({title:s(`store.filesAnalyzedTitle`),description:`${f.length} file(s): ${_} new, ${v} to update, ${y} to skip`,status:`info`,duration:4e3});for(let e of g.filter(e=>e.action===U$.SKIP&&e.existingId))p.push({id:e.existingId,name:e.name,type:l,status:`skipped`,location:e.location});let b=g.filter(e=>(e.action===U$.CREATE||e.action===U$.UPDATE)&&e.file);if(b.length>0){console.log(`Processing ${b.length} files (${b.filter(e=>e.action===U$.CREATE).length} create, ${b.filter(e=>e.action===U$.UPDATE).length} update)...`);let e=[];for(let t=0;t<b.length;t+=50)e.push(b.slice(t,t+50));for(let t=0;t<e.length;t++){let r=e[t],a=t*50;console.log(`Processing batch ${t+1}/${e.length} (${r.length} files)`),b.length>50&&o({title:s(`store.processingFiles`),description:`Processed ${a}/${b.length} files...`,status:`info`,duration:2e3});let c=await Promise.all(r.map(async e=>{try{if(e.action===U$.UPDATE&&e.existingId){let t=await n.store.objects.update(e.existingId,{type:l||void 0,content:e.file,location:e.location,name:e.name},{createRevision:!0,revisionLabel:`upload on ${new Date().toISOString()}`});return m.push({id:e.existingId,name:e.name,type:l,status:`updated`,location:e.location}),d.objectIds.push(e.existingId),{success:!0,id:t.id,name:e.name,action:`update`}}{let t=u?{collection_id:u}:void 0,n=await i.objects.create({type:l||void 0,content:e.file,location:e.location||e.file.webkitRelativePath||e.name},t);m.push({id:n.id,name:e.name,type:l,status:`created`,location:e.location})}}catch(t){console.error(`Failed to process file ${e.name}:`,t),h.push({name:e.name,error:Ge(t,`Unknown error`),status:`failed`,location:e.location,type:l}),o({status:`error`,title:s(`store.processingFailedFor`,{name:e.name}),description:Ge(t),duration:4e3})}})),f=m.filter(e=>e.status===`created`),p=m.filter(e=>e.status===`updated`),g=m.filter(e=>e.status===`failed`);console.log(`Batch ${t+1} results:`,{creates:f,updates:p,failures:g,total:c.length})}}let x=m.filter(e=>e.status===`created`).length,S=m.filter(e=>e.status===`updated`).length,C=m.filter(e=>e.status===`failed`).length,w=m.filter(e=>e.status===`skipped`).length;t&&(console.log(`Upload complete:`,{totalObjectIds:d.objectIds.length,uploadedFiles:x,updatedFiles:S,skippedFiles:w,failedFiles:C}),await t(d.objectIds));let T=``;return x>0&&(T+=`${x} file${x===1?``:`s`} uploaded`),S>0&&(T+=T?`, `:``,T+=`${S} file${S===1?``:`s`} updated`),w>0&&(T+=T?`, `:``,T+=`${w} file${w===1?``:`s`} skipped (already existed)`),C>0&&(T+=T?`, `:``,T+=`${C} file${C===1?``:`s`} failed`),T&&o({status:C>0?`warning`:`success`,title:T,duration:4e3}),a.search(),d}}const Y$=[{name:`ID`,field:`id`,type:`objectId?slice=-7`},{name:`Name`,field:`.`,type:`objectName`},{name:`Type`,field:`type.name`,type:`string`},{name:`Status`,field:`status`,type:`string`},{name:`Updated At`,field:`updated_at`,type:`date`}];function X$({isGridView:e=!1,onUpload:n,collectionId:r,...i}){return n?t(Z$,{...i,onUpload:n,isGridView:e,collectionId:r}):t(Q$,{...i,isGridView:e})}function Z$({isGridView:e,onUpload:r,collectionId:i,skipTypeModal:a=!1,...o}){let[s,c]=G(!1),[l,u]=G([]),[d,f]=G(!1),[p,m]=G(null),[h,g]=G(!1),_=R$(),v=nt(),{t:y}=K(),{checkDocumentProcessing:b}=K$(),x=async(e,t)=>{console.log(`Files dropped on ObjectTable:`,e.length,t),c(!0);try{if(i){let t=await b(e,null,i);m(t);let n=t.filter(e=>e.action===`create`).length,r=t.filter(e=>e.action===`update`).length,a=t.filter(e=>e.action===`skip`).length;v({title:y(`store.filesReadyToProcess`),description:`${e.length} file(s): ${n} new, ${r} to update, ${a} to skip`,status:`info`,duration:4e3})}else m(null)}catch(e){console.error(`Error processing files:`,e),v({title:y(`store.errorProcessingFiles`),description:y(`store.errorCheckingDuplicates`),status:`error`,duration:4e3}),m(null)}finally{if(c(!1),u(e),f(!1),a){console.log(`Skipping type modal and calling onUpload directly`,{filesLength:e.length,processedFilesLength:p?.length});let t=r(e,null,i);t&&typeof t==`object`&&(t.processedFiles=p)}else console.log(`Setting typeSelectionOpen to true`,{filesLength:e.length}),g(!0)}},S=e=>{let t=[...l];u([]),m(null),g(!1),t.length>0&&e!==void 0&&(c(!0),console.log(`Starting upload with`,{typeId:e,filesCount:t.length,hasProcessingResults:!!p,collectionId:i}),r(t,e,i).finally(()=>{c(!1),_.search()}))},C=e=>{e.preventDefault(),e.stopPropagation(),f(!0)};return n(`div`,{className:`min-h-[400px] relative`,onDragOver:C,onDragEnter:C,onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),!e.currentTarget.contains(e.relatedTarget)&&f(!1)},onDrop:e=>{if(e.preventDefault(),e.stopPropagation(),f(!1),e.dataTransfer.items){let t=[];for(let n=0;n<e.dataTransfer.items.length;n++){let r=e.dataTransfer.items[n];if(r.kind===`file`){let e=r.getAsFile();e&&t.push(e)}}if(t.length>0){let e={count:t.length,message:`Preparing to upload ${t.length} file${t.length===1?``:`s`}...`};x(t,e)}}},children:[t(`div`,{className:it(`bg-white dark:bg-muted opacity-40 absolute inset-0 z-50 flex justify-center items-center`,s?`block`:`hidden`),children:t(je,{size:`xl`})}),t(Q$,{...o,isGridView:e}),t(`div`,{className:it(`absolute inset-0 pointer-events-none`,d?`z-40`:`-z-10`),children:t(`div`,{className:`w-full h-full relative`,children:t(Ot,{onDrop:x,message:`Drop files or folders here to upload`,className:it(`absolute inset-0 bg-white/90 dark:bg-muted/90 pointer-events-auto`,d?`flex`:`hidden`),buttonLabel:`Select Files or Folders`,allowFolders:!0})})}),t(q$,{isOpen:h&&l.length>0,onClose:()=>{u([]),m(null),g(!1),S(void 0)},files:l,collectionId:i,selectedFolder:null,title:`Upload Files`,onUploadComplete:e=>{if(e){if(e.failedFiles&&e.failedFiles.length>0&&v({title:y(`store.uploadIssues`),description:`${e.failedFiles.length} file(s) failed to upload`,status:`warning`,duration:5e3}),e.success){let t=e.uploadedFiles.filter(e=>e.status===`created`).length,n=e.uploadedFiles.filter(e=>e.status===`updated`).length,r=e.skippedFiles.length;(t>0||n>0)&&v({title:y(`store.uploadComplete`),description:`${t>0?`${t} created`:``}${t>0&&n>0?`, `:``}${n>0?`${n} updated`:``}${r>0?`, ${r} skipped`:``}`,status:`success`,duration:5e3})}_.search()}u([]),m(null),g(!1),e?.success&&e.objectIds.length>0?S(null):S(void 0)}})]})}function Q$({objects:e,layout:n=Y$,isLoading:r,onRowClick:i,onSelectionChange:a,highlightRow:o,previewObject:s,selectedObject:c,isGridView:l}){let u=ZQ(),d=(t,n)=>{if(u){let r=n.nativeEvent instanceof MouseEvent&&n.nativeEvent.shiftKey;if(!n.target.checked)u.remove(t.id);else if(u.add(t),r){let n=e.findIndex(e=>e.id===t.id),r=$$(e,n,u);if(r>-1&&r<n-1){let t=[];for(let i=r+1;i<n;i++)t.push(e[i]);u.addAll(t)}else{let t=e1(e,n,u);if(t>-1&&t>n+1){let r=[];for(let i=n+1;i<t;i++)r.push(e[i]);u.addAll(r)}}}a?.(u)}},f=t=>{u&&(t.target.checked?u.addAll(e):u.removeAll())},p=U(()=>{let e=n.length>0?n:Y$;return console.log(`Using layout with columns:`,e.map(e=>e.name).join(`, `)),e.map(e=>new j$(e,s))},[n,s]);return t(l?F$:P$,{objects:e,isLoading:r,columns:p,onRowClick:i,highlightRow:o,previewObject:s,selectedObject:c,selection:u,toggleAll:f,onSelectionChange:d})}function $$(e,t,n){for(let r=t-1;r>=0;r--)if(n.isSelected(e[r].id))return r;return-1}function e1(e,t,n){let r=e.length;for(let i=t+1;i<r;i++)if(n.isSelected(e[i].id))return i;return-1}function t1({children:e,limit:n,parent:r,typeId:i,facets:a,name:o,collectionId:s}){let{store:c}=q(),l=U(()=>{let e;a?e=a:(e=[{name:`status`,field:`status`},{name:`location`,field:`location`}],i||e.unshift({name:`type`,field:`type`}));let t=new I$(c,n).withFacets(e);return t.collectionId=s,t.query.type=i,t.query.parent=r,t.query.name=o,s&&(t.query.all_revisions=!0),t},[s,a,n,o,r,c,i]);return t(L$.Provider,{value:l,children:e})}Q();const n1=`vertesia.content_store.lastDisplayedView`;function r1({onUpdate:e}){let{t:n}=K(),[r,i]=G(localStorage.getItem(n1)===`grid`),a=()=>{r?c():s()},s=()=>{localStorage.setItem(n1,`grid`),i(!0),e(!0)},c=()=>{localStorage.setItem(n1,`table`),i(!1),e(!1)};return t(o,{variant:`outline`,onClick:a,title:n(r?`misc.tableView`:`misc.thumbnailView`),children:t(r?ob:I_,{})})}r1.LAST_DISPLAYED_VIEW=n1,Q();const i1=[{name:`Name`,field:`properties.title`,type:`string`,fallback:`name`},{name:`Type`,field:`type.name`,type:`string`},{name:`Status`,field:`status`,type:`string`},{name:`Created At`,field:`created_at`,type:`date`}];function a1({onChange:e,selectedIds:n}){return t(t1,{children:t(o1,{onRowClick:t=>{e(t||void 0)},selectedIds:n})})}function o1({onRowClick:e,selectedIds:r}){let{t:i}=K(),a=V(e=>!!r?.has(e.id),[r]),[s,c]=G(!1),[l,u]=G(localStorage.getItem(`vertesia.content_store.lastDisplayedView`)===`grid`),{search:d,isLoading:f,error:p,objects:m,hasMore:h}=B$(),g=W(null);Qe(g,()=>{s&&h&&!f&&(c(!1),d.loadMore(!0).finally(()=>{c(!0)}))},{threshold:.1,deps:[s,h,f]}),H(()=>{d.search().finally(()=>{c(!0)})},[d]);let _=z$(),v=R$();return p?t(M,{title:i(`store.searchFailed`),children:p.message}):n(`div`,{className:`flex flex-col gap-2 h-full w-full`,children:[n(`div`,{className:`flex justify-between items-center flex-shrink-0`,children:[t(hQ,{facets:_,search:v}),n(`div`,{className:`flex items-center gap-2`,children:[t(o,{variant:`outline`,onClick:()=>{c(!1),d.search().then(()=>c(!0))},"aria-label":`Refresh`,children:t(hy,{size:16})}),t(r1,{onUpdate:u})]})]}),n(`div`,{className:`@container relative flex-1 overflow-y-auto`,children:[t(X$,{objects:m||[],isLoading:!m.length&&f,layout:i1,onRowClick:e,highlightRow:r?.size?a:void 0,isGridView:l}),t(`div`,{ref:g,className:`h-4 w-full`})]})]})}Q();function s1(e){let t=Math.max(0,e)/1e3,n=+(t>0&&t<10&&!Number.isInteger(t));return`${new Intl.NumberFormat(void 0,{maximumFractionDigits:n}).format(t)}K`}function c1({onSend:e,onStop:r,approvalModeSlot:i,mcpSlot:a,disabled:s=!1,isSending:c=!1,isStopping:l=!1,isStreaming:u=!1,isCompleted:d=!1,contextWindowUsage:f,onCompactContext:p,isCompactingContext:m=!1,activeTaskCount:h=0,activeWorkstreams:g=[],onSelectWorkstream:_,placeholder:v,onFilesSelected:y,uploadedFiles:b=[],onRemoveFile:x,onRemoveProcessingFile:S,acceptedFileTypes:C,maxFiles:T=5,processingFiles:E,artifactRunId:D,hasProcessingFiles:O=!1,renderDocumentSearch:k,selectedDocuments:A=[],onRemoveDocument:j,hideObjectLinking:M=!1,hideFileUpload:N=!1,disableDropZone:P=!1,className:F,inputClassName:I}){let{t:L}=K(),ee=v??L(`agent.typeYourMessage`),R=W(null),te=W(null),[ne,re]=G(``),[ie,oe]=G(!1),[le,de]=G(!1),[fe,pe]=G(!1),me=!!(y&&!N),he=me&&!P,ge=!M||me||!!k,_e=b.length>=T,ve=S??x,ye=U(()=>g.filter(e=>e.status===`running`||e.status===`canceling`),[g]),be=ye.length||h,xe=f?L(`agent.contextUsageCompactLabel`,{percent:f.usedPercent}):void 0,Se=f?L(`agent.contextTokenUsage`,{used:s1(f.usedTokens),limit:s1(f.checkpointTokens)}):void 0,Ce=U(()=>{let e=[];if(!N&&E)for(let t of E.values()){let n=t.preview_url,r=t.status===pn.UPLOADING?L(`agent.uploading`):t.status===pn.PROCESSING?L(`agent.processing`):t.status===pn.ERROR?L(`agent.error`):t.status===pn.READY?L(`agent.ready`):t.status;e.push({id:t.id,name:t.name,contentType:t.content_type,artifactPath:t.artifact_path,previewUrl:n,removable:!!ve,statusLabel:r,statusTone:t.status===pn.ERROR?`destructive`:t.status===pn.READY?`success`:`attention`})}if(!N)for(let t of b)e.push({id:t.id,name:t.name,contentType:t.type,artifactPath:t.artifact_path,previewUrl:t.previewUrl,removable:!!x,statusLabel:L(`agent.ready`),statusTone:`success`});for(let t of A)e.push({id:t.id,name:t.name,href:`/store/objects/${t.id}`,removable:!!j,statusTone:`info`});return e},[ve,N,j,x,E,A,L,b]);H(()=>{!s&&d&&R.current?.focus()},[s,d]);let we=V(e=>{if(!me||!y)return;let t=Array.from(e),n=T-b.length,r=t.slice(0,n);r.length>0&&y(r)},[me,y,T,b.length]),Te=V(e=>{e.preventDefault(),e.stopPropagation(),he&&pe(!0)},[he]),Ee=V(e=>{e.preventDefault(),e.stopPropagation(),pe(!1)},[]),De=V(e=>{e.preventDefault(),e.stopPropagation(),pe(!1),he&&e.dataTransfer?.files&&e.dataTransfer.files.length>0&&we(e.dataTransfer.files)},[he,we]),Oe=V(e=>{if(!me)return;let t=OX(e.clipboardData?.items);t.length>0&&we(t)},[me,we]),ke=V(e=>{me&&e.target.files&&e.target.files.length>0&&(we(e.target.files),e.target.value=``)},[me,we]),Ae=V(()=>{te.current?.click()},[]),Me=V(()=>de(!1),[]),Ne=V(e=>de(!1),[]),Pe=()=>{let t=ne.trim();!t||s||c||O||(e(t),re(``))},Fe=()=>{r&&!l&&r()},Ie=W(0),Le=e=>{if(e.key===`Enter`){if(!(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)){e.preventDefault(),ne.trim().length>0&&Pe();return}e.shiftKey||(e.preventDefault(),Ke(e.currentTarget,re));return}if(e.key===`Escape`&&u&&r){let e=Date.now();e-Ie.current<500?(Fe(),Ie.current=0):Ie.current=e}},Re=V(()=>{let e=R.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`)},[]);return H(()=>{Re()},[ne,Re]),n(`div`,{className:z(`px-3 py-3 flex-shrink-0 transition-all fixed lg:sticky bottom-0 start-0 end-0 lg:start-auto lg:end-auto w-full bg-background/95 backdrop-blur z-10`,fe&&he&&`bg-info/10 border-info`,F),onDragOver:he?Te:void 0,onDragLeave:he?Ee:void 0,onDrop:he?De:void 0,children:[fe&&he&&t(`div`,{className:`absolute inset-0 flex items-center justify-center bg-info/80 dark:bg-info/40 rounded-lg z-10 pointer-events-none`,children:n(`div`,{className:`text-info font-medium flex items-center gap-2`,children:[t(wb,{className:`size-5`}),L(`agent.dropFilesToUpload`)]})}),me&&t(`input`,{ref:te,type:`file`,multiple:!0,accept:C,onChange:ke,className:`hidden`}),t(YX,{activeWorkstreams:g,onSelectWorkstream:_}),n(`div`,{className:`mx-auto flex max-w-3xl flex-col gap-2 rounded-2xl border border-border/70 bg-mixer-muted/15 p-2.5 shadow-lg shadow-black/5`,children:[Ce.length>0&&t(BW,{items:Ce,artifactRunId:D,variant:`composer`,onRemove:e=>{E?.has(e)?ve?.(e):b.some(t=>t.id===e)?x?.(e):j?.(e)},className:`gap-1.5`}),t(`div`,{className:`flex min-w-0 flex-1`,children:t(Ue,{ref:R,value:ne,onKeyDown:Le,onChange:e=>re(e.target.value),onPaste:Oe,disabled:s,"aria-label":ee,placeholder:ee,rows:1,style:{maxHeight:`160px`},className:z(`min-h-[44px] resize-none border-0 bg-transparent px-0 py-0 text-sm leading-6 shadow-none focus-visible:ring-0`,I)})}),n(`div`,{className:`flex items-center justify-between gap-3`,children:[n(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[ge&&n(w,{align:`left`,trigger:t(o,{variant:`ghost`,size:`icon`,className:`size-8 rounded-full text-muted hover:bg-muted`,title:L(`agent.addAttachment`),children:t(oy,{className:`size-4`})}),children:[!M&&n(ae,{onClick:()=>oe(!0),isDisabled:!d,children:[t(Hv,{className:`size-4`}),L(`agent.linkObject`)]}),me&&n(ae,{onClick:Ae,isDisabled:_e,children:[t(wb,{className:`size-4`}),L(`agent.upload`)]}),k&&n(ae,{onClick:()=>de(!0),children:[t(Gg,{className:`size-4`}),t(`span`,{children:L(`agent.searchDocuments`)}),A.length>0&&t(`span`,{className:`ms-auto inline-flex items-center justify-center rounded-full bg-info/20 px-1.5 py-0.5 text-[10px] font-medium text-info`,children:A.length})]})]}),i,a,f&&t(We,{asChild:!0,placement:`top`,size:`md`,className:`text-foreground shadow-lg`,description:n(`span`,{className:`block max-w-56 text-start text-sm leading-6`,children:[t(`span`,{className:`block`,children:L(`agent.contextRemainingUntilCompact`,{percent:f.remainingPercent})}),Se&&t(`span`,{className:`mt-1 block text-foreground/80`,children:Se})]}),children:t(o,{type:`button`,variant:`ghost`,size:`icon`,className:z(`size-8 rounded-lg text-info hover:bg-muted hover:text-info disabled:opacity-60`,`focus-visible:ring-2 focus-visible:ring-info/40`),"aria-label":xe,onClick:p,disabled:!p||m,children:m?t(je,{size:`sm`}):n(`svg`,{viewBox:`0 0 24 24`,className:z(`size-8 -rotate-90`,f.usedPercent>=90?`text-destructive`:f.usedPercent>=70?`text-attention`:`text-info`),"aria-hidden":`true`,children:[t(`circle`,{cx:`12`,cy:`12`,r:`9.75`,fill:`none`,strokeWidth:`4.5`,className:`stroke-current text-muted/50`}),t(`circle`,{cx:`12`,cy:`12`,r:`9.75`,fill:`none`,pathLength:100,strokeWidth:`4.5`,strokeLinecap:`round`,strokeDasharray:100,style:{strokeDashoffset:100-f.usedPercent},className:`stroke-current`})]})})}),ye.length===0&&be>0&&t(`output`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,"aria-live":`polite`,children:n(`span`,{className:`inline-flex h-8 items-center gap-1 rounded-full px-2 text-xs text-muted`,children:[t(xm,{className:`size-3 text-attention`}),L(`agent.activeWorkstreams`,{count:be})]})})]}),u&&r&&!ne.trim()?t(o,{onClick:Fe,disabled:l,variant:`ghost`,size:`icon`,className:z(`size-9 rounded-full border border-border/60 bg-foreground text-background shadow-sm`,`hover:bg-foreground/90 hover:text-background`,`disabled:bg-mixer-muted/25 disabled:text-muted disabled:opacity-100`,`[&_svg]:text-destructive disabled:[&_svg]:text-muted`),title:L(`agent.stopTooltip`),children:l?t(je,{size:`sm`}):t(rb,{className:`size-3 fill-current stroke-current`})}):t(o,{onClick:Pe,disabled:s||c||!ne.trim()||O,variant:`ghost`,size:`icon`,className:z(`size-9 rounded-full border border-border/60 bg-foreground text-background shadow-sm`,`hover:bg-foreground/90 hover:text-background`,`disabled:bg-mixer-muted/25 disabled:text-muted disabled:opacity-100`),title:L(O?`agent.waitForFiles`:`agent.sendTooltip`),"aria-label":L(O?`agent.waitForFiles`:`agent.send`),children:c?t(je,{size:`sm`}):t(Dm,{className:`size-4`})})]})]}),n(se,{isOpen:ie,onClose:()=>oe(!1),className:`min-w-[60vw]`,children:[t(ue,{children:L(`agent.linkObject`)}),t(ce,{className:`pb-6`,children:t(a1,{onChange:e=>{let t=`[${e.properties?.title||e.name||`Object`}](store:${e.id})`,n=ne||``,r=R.current?.selectionStart||n.length,i=n.substring(0,r)+t+n.substring(r);re(i),oe(!1),setTimeout(()=>{if(R.current){R.current.focus();let e=r+t.length;R.current.setSelectionRange(e,e)}},100)}})})]}),k?.({isOpen:le,onClose:Me,onSelect:Ne})]})}function l1({code:e}){let{onProposalSelect:n,onProposalSubmit:r}=qt(),i=U(()=>Wt(e),[e]),a=U(()=>{if(i)return null;try{let t=e.trim(),i=JSON.parse(t);if(!i.options||!i.question&&!i.title)return null;let a={question:i.question||i.title||``,description:i.description,options:Array.isArray(i.options)?i.options.map(e=>({id:e.id||e.value||``,label:e.label||``,description:e.description})):void 0,allowFreeResponse:i.allowFreeResponse??i.multiple,variant:i.variant,onSelect:n,onSubmit:r};return!a.question||!a.options?.length?null:a}catch{return null}},[e,n,r,i]);return i?t(Et,{type:`proposal`,message:`Loading options...`}):a?t(Tt,{type:`proposal`,fallbackCode:e,children:t(AH,{...a})}):t(Et,{type:`proposal`,error:`Invalid proposal specification`})}const u1=gt(function({code:e}){let n=U(()=>{try{let t=JSON.parse(e);return t?.library===`vega-lite`&&t?.spec&&typeof t.spec==`object`?t:typeof t?.$schema==`string`&&t.$schema.includes(`vega`)?{library:`vega-lite`,spec:t}:null}catch{return null}},[e]);return n?t(oC,{spec:n}):null}),d1=gt(function({code:e}){let n=U(()=>{try{return{library:`vega-lite`,spec:JSON.parse(e)}}catch{return null}},[e]);return n?t(oC,{spec:n}):null}),f1={chart:u1,"vega-lite":d1,vegalite:d1,"fusion-fragment":Jn,proposal:l1,askuser:l1};function p1({url:e,code:n}){let[r,i]=G(null);return H(()=>{import(e).then(e=>{i(()=>e.default)}).catch(t=>{console.error(`Failed to load remote widget component from `,e,t)})},[e]),r?t(r,{code:n}):null}async function m1(e){let n=await e.apps.getInstalledApps(`tools`),r=new Set;for(let e of n){if(e.manifest.tool_collections&&e.manifest.tool_collections.length>0)for(let t of e.manifest.tool_collections||[]){let e=An(t).url;if(e.startsWith(`http://`)||e.startsWith(`https://`)){let t=e.indexOf(`/api/`);if(t>0){let n=e.substring(0,t);r.add(`${n}/api/widgets`)}}}e.manifest.endpoint&&e.manifest.capabilities?.includes(`tools`)&&r.add(new URL(`/api/widgets`,e.manifest.endpoint).toString())}let i=await Promise.all(Array.from(r).map(e=>fetch(e).then(e=>{if(!e.ok)throw Error(`Failed to fetch widgets: ${e.status} ${e.statusText}`);return e.json()}).then(e=>{let n=[],r=e.widgets;for(let[e,i]of Object.entries(r))n.push({name:e,component:e=>t(p1,{url:i.url,code:e.code})});return n}).catch(()=>(console.error(`Failed to fetch skill widgets from `,e),null)))),a={};for(let e of i.flat())e&&(a[e.name]=e.component);return a}function h1({children:e}){let{client:n}=q(),[r,i]=G(f1);return H(()=>{m1(n).then(e=>{i({...f1,...e})})},[n]),t(Dt,{components:r,children:e})}Q();const g1=new Map,_1=[400,1200];async function v1(e,t,n){for(let r=0;;r++)try{return await e.agents.sendSignal(t,`FileBatchClosed`,n),!0}catch(e){if(r>=_1.length)return console.error(`Failed to close staged file batch:`,e),!1;await new Promise(e=>setTimeout(e,_1[r]))}}function y1(e){if(typeof e==`number`)return e;if(!e)return Date.now();let t=new Date(e).getTime();return Number.isFinite(t)?t:Date.now()}function b1(e){return e===`running`||e===`canceling`}function x1(e){return!b1(e)}function S1(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function C1(e){for(let t=e.length-1;t>=0;t--){let n=e[t].details;if(!n)continue;let r=n.token_usage,i=S1(r?.prompt),a=i&&i>0?i:S1(r?.total),o=S1(n.checkpoint_threshold)??S1(n.checkpoint_at);if(typeof a!=`number`||typeof o!=`number`||o<=0)continue;let s=Math.max(0,Math.min(100,Math.round(a/o*100)));return{usedTokens:a,checkpointTokens:o,usedPercent:s,remainingPercent:Math.max(0,100-s)}}}function w1(e,t){return!x1(e.status)||!b1(t.status)?{...e,...t}:{...e,interaction:e.interaction??t.interaction,elapsed_ms:Math.max(e.elapsed_ms,t.elapsed_ms),deadline_ms:Math.max(e.deadline_ms,t.deadline_ms),remaining_ms:0,phase:e.phase??t.phase,child_workflow_id:e.child_workflow_id??t.child_workflow_id,child_workflow_run_id:e.child_workflow_run_id??t.child_workflow_run_id}}function T1(e){let t=e.details,n=typeof t?.workstream_id==`string`&&t.workstream_id.trim()?t.workstream_id:$H(e);return n===`main`||n===`all`?null:{workstreamId:n,launchId:typeof t?.launch_id==`string`?t.launch_id:void 0,interaction:typeof t?.interaction==`string`?t.interaction:void 0,childWorkflowId:typeof t?.child_workflow_id==`string`?t.child_workflow_id:void 0,childWorkflowRunId:typeof t?.child_workflow_run_id==`string`?t.child_workflow_run_id:void 0}}function E1(e){if(e.type!==J.ERROR)return!1;let t=e.details;if(t?.event_class!==`activity`||t.workstream_event)return!1;let n=typeof e.workstream_id==`string`&&e.workstream_id.trim()?e.workstream_id.trim():typeof t.workstream_id==`string`?t.workstream_id.trim():``,r=n.toLowerCase();return!n||r===`main`||r===`all`?!1:!(t.tool||t.tool_status||t.tool_run_id||t.activity_group_id||t.tool_event)}function D1(e,t,n,r,i,a){if(r){let a=t.get(n);if(a?.startsWith(`message-derived:`)){let t=e.get(a);t&&(e.delete(a),e.set(r,{...t,launch_id:r,updated_at:Math.max(t.updated_at,i)}))}t.set(n,r)}let o=r??t.get(n)??`message-derived:${n}`,s=e.get(o);if(s)return s;let c={workstream_id:n,launch_id:o,elapsed_ms:0,deadline_ms:0,remaining_ms:0,status:`running`,started_at:i,updated_at:i,order:a};return e.set(o,c),t.has(n)||t.set(n,o),c}function O1(e){let t=new Map,n=new Map;return e.forEach((e,r)=>{let i=y1(e.timestamp),a=T1(e),o=HH(e),s=o?.workstreamId??a?.workstreamId;if(!s)return;let c=o?.launchId??a?.launchId,l=zH(e);if(!o&&!c&&l&&!n.has(s))return;let u=D1(t,n,s,c,i,r);o?(u.interaction=o.interaction??u.interaction,u.child_workflow_id=o.childWorkflowId??u.child_workflow_id,u.child_workflow_run_id=o.childWorkflowRunId??u.child_workflow_run_id,u.status=`running`):(u.interaction=a?.interaction??u.interaction,u.child_workflow_id=a?.childWorkflowId??u.child_workflow_id,u.child_workflow_run_id=a?.childWorkflowRunId??u.child_workflow_run_id);let d=VH(e);d?u.status=d:l||(E1(e)?u.status=`failed`:(e.type===J.COMPLETE||e.type===J.IDLE)&&(u.status=`completed`)),!l&&(u.updated_at=Math.max(u.updated_at,i),b1(u.status)?u.elapsed_ms=Math.max(u.elapsed_ms,i-u.started_at):(u.elapsed_ms=Math.max(u.elapsed_ms,i-u.started_at),u.remaining_ms=0))}),Array.from(t.values()).sort((e,t)=>{let n=Number(!b1(e.status))-Number(!b1(t.status));return n===0?b1(e.status)?e.order-t.order:t.updated_at-e.updated_at||e.order-t.order:n}).map(({started_at:e,updated_at:t,order:n,...r})=>r)}function k1(e){return{workstream_id:e.workstream_id,launch_id:e.launch_id,interaction:e.interaction,elapsed_ms:e.elapsed_ms,deadline_ms:e.deadline_ms,remaining_ms:Math.max(0,e.deadline_ms-e.elapsed_ms),status:e.status,phase:e.latest_progress?.phase,child_workflow_id:e.child_workflow_id,child_workflow_run_id:e.child_workflow_run_id}}function A1(e){return{workstream_id:e.workstream_id,launch_id:e.launch_id,interaction:e.interaction,elapsed_ms:e.duration_ms??0,deadline_ms:0,remaining_ms:0,status:e.status,phase:e.last_progress?.phase,child_workflow_id:e.child_workflow_id,child_workflow_run_id:e.child_workflow_run_id}}function j1(e,t){let n=e.findIndex(e=>e.launch_id===t.launch_id);if(n>=0){e[n]=w1(e[n],t);return}let r=e.findIndex(e=>e.workstream_id===t.workstream_id&&e.launch_id.startsWith(`message-derived:`));if(r>=0&&!t.launch_id.startsWith(`message-derived:`)){e[r]=w1(e[r],t);return}e.push(t)}function M1(e){if(e<60)return`${e}s`;let t=Math.floor(e/60),n=e%60;return n>0?`${t}m ${n}s`:`${t}m`}function N1(e,t=!0){let[n,r]=G(()=>Math.max(0,Math.floor((Date.now()-y1(e))/1e3)));return H(()=>{if(!t)return;let n=()=>{r(Math.max(0,Math.floor((Date.now()-y1(e))/1e3)))};n();let i=window.setInterval(n,1e3);return()=>window.clearInterval(i)},[t,e]),n}function P1(e=!0){let[t,n]=G(0);return H(()=>{if(!e)return;let t=window.setInterval(()=>{n(()=>Math.floor(Math.random()*SW.length))},4e3);return()=>window.clearInterval(t)},[e]),t}function F1({message:e,startedAt:r}){let{t:i}=K(),a=N1(r),o=P1();return n(`div`,{className:`mx-auto flex min-h-full w-full max-w-3xl flex-col justify-end gap-6 px-1 py-8`,children:[t(`div`,{className:`flex w-full justify-end`,children:t(`div`,{className:z(`max-w-[min(44rem,82%)] rounded-[1.35rem] bg-mixer-muted/35 px-4 py-2.5`,`break-words text-sm font-normal leading-6 text-foreground/90 shadow-sm shadow-black/5`,`dark:bg-mixer-muted/15 dark:text-foreground/88 dark:shadow-none [overflow-wrap:anywhere]`),children:t(`div`,{className:`whitespace-pre-wrap`,children:e})})}),n(`div`,{className:`border-b border-border/70 pb-4 text-sm text-muted`,children:[n(`div`,{className:`flex items-center gap-3`,children:[t(iW,{size:`sm`,color:`blue`}),n(`div`,{className:`min-w-0`,children:[n(`div`,{children:[t(`span`,{className:`font-medium`,children:i(`agent.preparing`)}),n(`span`,{className:`ms-2 text-muted/75`,children:[`for `,M1(a)]})]}),t(`div`,{className:`mt-1 truncate text-muted/80`,children:SW[o]})]})]}),t(`div`,{className:`mt-3 ps-6`,children:t(rW,{color:`blue`})})]})]})}function I1(e,t){if(typeof window>`u`||typeof document>`u`)return!1;let n=document.createElement(`iframe`);n.style.position=`fixed`,n.style.right=`0`,n.style.bottom=`0`,n.style.width=`0`,n.style.height=`0`,n.style.border=`0`,n.style.visibility=`hidden`,document.body.appendChild(n);let r=n.contentWindow;if(!r)return n.parentNode?.removeChild(n),!1;let i=r.document;return i.open(),i.write(`<!doctype html><html><head><title></title></head><body></body></html>`),i.close(),i.title=t,document.querySelectorAll(`link[rel="stylesheet"], style`).forEach(e=>{i.head.appendChild(e.cloneNode(!0))}),i.body.innerHTML=e.innerHTML,r.focus(),r.print(),setTimeout(()=>{n.parentNode?.removeChild(n)},1e3),!0}function L1(e){let t=0,n=e.length;for(;t<n&&e[t]===`-`;)t++;for(;n>t&&e[n-1]===`-`;)n--;return e.slice(t,n)}function R1(e){return L1(e.trim().replace(/[^a-z0-9-_]+/gi,`-`)).slice(0,80)}function z1(e,t){let n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}function B1(e){let{agentRunId:n,startWorkflow:r,resourceResolver:i}=e;if(n){let r=t(h1,{children:t(U1,{...e,agentRunId:n})});return i?t(Ct,{value:i,children:r}):r}return r?t(H1,{...e}):t(V1,{})}function V1(){let{t:e}=K();return n(oe,{status:`info`,icon:t(Am,{className:`size-16 text-muted mb-4`}),children:[t(`div`,{className:`text-base font-medium text-muted`,children:e(`agent.noAgentRunning`)}),t(`div`,{className:`mt-3 text-sm text-muted`,children:e(`agent.selectInteraction`)})]})}function H1({initialMessage:e,interactive:r=!0,startWorkflow:i,onClose:a,isModal:s=!1,fullWidth:c=!1,placeholder:l,startButtonText:u,title:d,getAttachedDocs:f,onAttachmentsSent:p,acceptedFileTypes:m,maxFiles:h=5,hideHeader:g=!1,hideFileUpload:_=!1,hideObjectLinking:v,headerVariant:y,startViewVariant:b=`default`,inputContainerClassName:x,inputClassName:S,className:C,allowWorkflowControl:w,initialToolApprovalMode:T,onAgentWorkingChange:E}){let{t:D}=K(),O=b!=="default",k=b===`expanded-composer`,A=!_,j=l??D(`agent.typeYourMessage`),M=u??D(`agent.startAgent`),N=d??D(`agent.startNewConversation`),{client:P}=q(),[F,I]=G(``),[L,ee]=G(!1),[R,te]=G(null),[ne,re]=G(null),[ie,ae]=G(null),[oe,se]=G(()=>kn(T,r)),ce=nt(),le=W(null),ue=W(null),[de,fe]=G([]),[pe,me]=G(!1),he=pe?de:de.slice(0,3),ge=de.length-3;H(()=>{E?.(L)},[L,E]);let[_e,ve]=G(!1),ye=W(0),be=V(e=>{A&&(e.preventDefault(),e.stopPropagation(),ye.current++,e.dataTransfer?.types?.includes(`Files`)&&ve(!0))},[A]),xe=V(e=>{A&&(e.preventDefault(),e.stopPropagation())},[A]),Se=V(e=>{A&&(e.preventDefault(),e.stopPropagation(),ye.current--,ye.current===0&&ve(!1))},[A]),Ce=V(e=>{if(A&&(e.preventDefault(),e.stopPropagation(),ye.current=0,ve(!1),e.dataTransfer?.files&&e.dataTransfer.files.length>0)){let t=Array.from(e.dataTransfer.files);fe(e=>[...e,...t].slice(0,h))}},[h,A]),we=V(e=>{if(!A)return;let t=OX(e.clipboardData?.items);t.length>0&&fe(e=>[...e,...t].slice(0,h))},[A,h]),Te=V(e=>{if(e.target.files&&e.target.files.length>0){let t=Array.from(e.target.files);fe(e=>[...e,...t].slice(0,h))}e.target.value=``},[h]),Ee=V(e=>{fe(t=>t.filter((t,n)=>n!==e))},[]);H(()=>{de.length<=3&&me(!1)},[de.length]),H(()=>{le.current&&le.current.focus()},[]);let De=async()=>{if(!i)return;let e=F.trim();if(!(!e||L)){ee(!0);try{sessionStorage.removeItem(`plan-panel-shown`),ce({title:A&&de.length>0?D(`agent.startingAgentUploading`):D(`agent.startingAgent`),status:`info`,duration:3e3});let t=f?.()||[],n=e;if(t.length>0&&!/store:\S+/.test(e)&&(n=[e,``,`Attachments:`,...t.map(e=>`[${e.name}](/store/objects/${e.id})`)].join(`
1377
+ `,i.head.appendChild(a),i.body.innerHTML=e.innerHTML,r.focus(),r.print(),setTimeout(()=>{n.parentNode?.removeChild(n)},1e3),!0}const g$={max_hw:import.meta.env?.VITE_RENDITION_HW||256,format:mn.jpeg,generate_if_missing:!0},_$=`vertesia.content_store.renditionId`;async function v$(e,t,n,r,i){if(!t?.content?.type||!(d$(t.content.type)||p$(t.content.type)||f$(t.content.type))){i(`No preview available`);return}i(`Preparing preview...`);let a=Date.now()/1e3,o=localStorage.getItem(`${_$}_${t.id}_${g$.max_hw}`),s=localStorage.getItem(`${_$}_${t.id}_${g$.max_hw}_time`);if(o?.length&&s&&Math.abs(a-parseInt(s,10))<=900)return n(o),r(`${t.name} Rendition`),i(`ready`),o;i(`Preparing preview...`),e.objects.getRendition(t.id,g$).then(a=>{if(a.status===`generating`)i(`Preparing preview...`),n(``),r(``),setTimeout(()=>v$(e,t,n,r,i),6e4);else if(a.status===`failed`){i(`No preview available`),n(``),r(``);return}else{if(!a?.renditions?.length){i(`No preview available`),n(``),r(``);return}let e=a.renditions[0];localStorage.setItem(`${_$}_${t.id}_${g$.max_hw}`,e),localStorage.setItem(`${_$}_${t.id}_${g$.max_hw}_time`,(Date.now()/1e3).toString()),n(e),r(`${t.name} Rendition`),i(`ready`),console.log(`Rendition for document ${t.id} retrieved successfully: ${e}`)}}).catch(e=>{i(`No preview available`),console.warn(`Failed to retrieve rendition:`,e),n(``),r(``)})}function y$(e,t=7){return e?`~${e.slice(-t)}`:``}function b$(e,t){return e.length>t?`${e.substring(0,t)}...`:e}function x$(e){switch(e){case Tn.RUNNING:return`text-info`;case Tn.COMPLETED:return`text-success`;case Tn.FAILED:return`text-destructive`;case Tn.TERMINATED:case Tn.CANCELED:return`text-attention`;default:return`text-muted`}}function S$(e){switch(e){case Tn.RUNNING:return`Running`;case Tn.COMPLETED:return`Completed`;case Tn.FAILED:return`Failed`;case Tn.CONTINUED_AS_NEW:return`Continued As New`;case Tn.TERMINATED:return`Terminated`;case Tn.TIMED_OUT:return`Timed Out`;case Tn.CANCELED:return`Canceled`;default:return`Unknown`}}Q();function C$(e){return typeof e==`object`&&!!e}function w$(e,t){if(!C$(e))return;let n=e[t];return typeof n==`string`?n:void 0}function T$(e){return typeof e==`string`?e:w$(e,`id`)||``}function E$(e){return e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`?e:String(e)}const D$={string(e,r){let i=[];if(e){let t=e.get(`slice`);t&&i.push(e=>e.slice(parseInt(t,10)));let n=e.get(`max_length`);n&&i.push(e=>e.slice(0,parseInt(n,10))),e.has(`upper`)&&i.push(e=>e.toUpperCase()),e.has(`lower`)&&i.push(e=>e.toLowerCase()),e.has(`capitalize`)&&i.push(e=>e[0].toUpperCase()+e.substring(1)),e.has(`ellipsis`)&&i.push(e=>`${e}...`)}return(e,r,a)=>{let o;if(e){if(o=String(e),i.length>0)for(let e of i)o=e(o)}else o=``;return t(`td`,{className:`group/field`,children:a?n(`div`,{className:`flex items-center gap-2 min-w-0`,children:[t(`span`,{className:`truncate`,children:o}),a]}):o},r)}},fileSize(e,n){return(e,n)=>{let r=``;if(e){let t=Number(e);if(Number.isNaN(t))r=String(e);else{let e=[`Bytes`,`KB`,`MB`,`GB`,`TB`];if(t===0)r=`0 Bytes`;else{let n=Math.floor(Math.log(t)/Math.log(1024));r=`${(t/1024**n).toFixed(2)} ${e[n]}`}}}return t(`td`,{className:`group/field`,children:r},n)}},number(e,n){let r,i;e&&(r=e.get(`currency`)||void 0,i=e.get(`decimals`)||void 0);let a=i?parseInt(i,10):2;return(e,n)=>{let i=Number(e),o=new Intl.NumberFormat(`en-US`,{style:r?`currency`:`decimal`,currency:r,maximumFractionDigits:a}).format(Number.isFinite(i)?i:0);return t(`td`,{className:`group/field`,children:o},n)}},objectId(e,r){let i=[],a=!1;if(e){let t=e.get(`slice`);t&&(a=!0,i.push(e=>e.slice(parseInt(t,10))))}return(e,s,c)=>{let l=T$(e),u=i.reduce((e,t)=>t(e),l);return n(`td`,{className:`flex justify-start items-center gap-2 group/field`,children:[t(o,{variant:`ghost`,title:`Preview Object`,onClick:e=>{e.stopPropagation(),r?.(l)},children:t(Ag,{className:`size-4`})}),a?`~`:``,u,c]},s)}},objectName(e,r){let i=`title`;return e&&(i=e.get(`title`)||`title`),(e,r,a)=>{let o=(C$(e)&&C$(e.properties)?e.properties:void 0)?.[i],s=E$(o),c=w$(e,`name`),l=w$(e,`id`),u=s||c||(l?y$(l):``);return t(`td`,{className:`group/field`,children:a?n(`div`,{className:`flex items-center gap-2 min-w-0`,children:[t(`span`,{className:`truncate`,children:u}),a]}):u},r)}},objectLink(e,r){let i=[];return i.push(e=>e.slice(-7)),(e,a)=>{let s=T$(e),c=i.reduce((e,t)=>t(e),s);return n(`td`,{className:`flex justify-between items-center gap-2 max-w-48 group/field`,children:[`~`,c,t(o,{variant:`ghost`,title:`Preview Object`,onClick:e=>{e.stopPropagation(),r?.(s)},children:t(Ag,{className:`size-4`})})]},a)}},typeLink(e,r){return(e,r,i)=>{let a=w$(e,`name`)||`n/a`;return t(`td`,{className:`group/field`,children:i?n(`div`,{className:`flex items-center gap-2 min-w-0`,children:[t(`span`,{className:`truncate`,children:a}),i]}):a},r)}},revision(e,r){return(e,r)=>{let i=C$(e)&&C$(e.revision)?e.revision:void 0;if(!i)return t(`td`,{},r);let a=w$(i,`root`),o=w$(i,`label`);return t(`td`,{className:`group/field`,children:n(`div`,{className:`flex flex-col gap-0.5`,children:[a&&n(`div`,{className:`flex items-center gap-1`,children:[n(`span`,{className:`text-xs text-muted font-mono`,children:[`root: ~`,a.slice(-7)]}),t(`a`,{href:`/store/objects/${a}`,onClick:e=>e.stopPropagation(),children:t(Dg,{className:`size-3 text-muted`})})]}),o&&n(`span`,{className:`text-xs text-muted`,children:[`label: `,o]})]})},r)}},date(e,r){let i=`fromNow`,a;if(e){let t=e.get(`localized`);if(t)i=`format`,a=t;else{let t=e.get(`relative`);t&&(i=t)}}return(e,r,o)=>{let s=typeof e==`string`||typeof e==`number`||e instanceof Date?e:void 0;if(s===void 0)return t(`td`,{children:o},r);let c=WD(s),l=i===`format`?c.format(a):i===`toNow`?c.toNow():c.fromNow();return t(`td`,{className:`group/field`,children:n(`div`,{className:`flex items-center gap-2`,children:[t(We,{description:c.format(`LLL`),children:l}),o]})},r)}}},O$=D$.string();function k$(e){return typeof e==`object`&&!!e}function A$(e,t){let n=e;if(!n)return;if(!t.length)return n;let r=t.length-1;for(let e=0;e<r;e++)if(!k$(n)||(n=n[t[e]],!n))return;if(k$(n))return n[t[r]]}function j$(e){return!e||e===`.`?[]:e.split(`.`)}var M$=class{layout;renderer=O$;path;fallbackPath;previewObject;constructor(e,t){if(this.layout=e,this.path=j$(e.field||``),this.fallbackPath=e.fallback?j$(e.fallback):void 0,this.previewObject=t,e.render)this.renderer=(e,t)=>null;else{let t=e.type||`string`,n=t.indexOf(`?`);if(n>0){let e=t.substring(0,n),r=new URLSearchParams(t.substring(n+1));this.renderer=D$[e](r)}else this.renderer=D$[t]()}}get name(){return this.layout.name}resolveValue(e){let t=A$(e,this.path);return t===void 0&&this.fallbackPath&&(t=A$(e,this.fallbackPath)),t===void 0&&(t=this.layout.default),t}render(e,n){if(this.layout.render)return t(`td`,{className:`whitespace-nowrap px-3 py-4 text-sm group`,children:this.layout.render(e)},n);let r=this.layout.type||`string`,i=r.indexOf(`?`)>0?r.substring(0,r.indexOf(`?`)):r,a=this.buildActions(e,i);if((i===`objectId`||i===`objectLink`)&&this.previewObject){let t=r.indexOf(`?`),o=t>0?new URLSearchParams(r.substring(t+1)):void 0;return D$[i](o,t=>{this.previewObject?.(e.id)})(e,n,a)}return this.renderer(this.resolveValue(e),n,a)}buildActions(e,n){let r=this.layout.field;if(n===`objectId`||n===`objectLink`||r===`id`)return t(i$,{field:`id`,value:e.id,label:e.id,copyContent:e.id});if(n===`objectName`||r===`name`)return t(i$,{field:`name`,value:e.name,label:e.name??e.id});if(n===`typeLink`||r===`type.name`||r===`type`){let n=e.type?.id;return t(i$,{field:`type`,value:n,label:e.type?.name??n??`type`})}if(r===`status`)return t(i$,{field:`status`,value:e.status,label:e.status})}};Q();function N$({isLoading:e=!1,counts:r=6}){return e?t(`div`,{className:`flex flex-wrap gap-2 justify-between`,children:Array(r).fill(0).map((e,r)=>t(`div`,{className:`w-[15vw] animate-pulse`,children:n(s,{className:`relative flex flex-col border h-fit`,children:[t(`div`,{className:`h-48 bg-muted rounded-t-xl flex items-center justify-center text-muted`,children:`\xA0`}),t(Ee,{className:`bg-muted h-[2px]`}),n(c,{className:`p-2 flex flex-col`,children:[n(`div`,{className:`flex flex-col overflow-hidden`,children:[t(`div`,{className:`h-5 bg-muted rounded w-3/4 mb-2`}),t(`div`,{className:`h-4 bg-muted rounded w-1/2`})]}),t(`div`,{className:`text-xs text-muted w-full flex justify-end mt-2`,children:t(`div`,{className:`h-3 bg-muted rounded w-1/4`})})]})]})},`skeleton-${r}`))}):null}function P$({selection:e,document:r,onSelectionChange:i,onRowClick:a,highlightRow:l,previewObject:u,selectedObject:d}){let{client:f}=q(),[p,m]=G(void 0),[h,g]=G(void 0),[_,v]=G(void 0),y=typeof r.properties?.title==`string`?r.properties.title:r.name,b=e=>{e.stopPropagation(),i(r,e)};H(()=>{r?.content&&v$(f,r,m,g,v)},[f,r]);let x=l?.(r);return n(s,{className:`relative flex flex-col border h-fit w-full ${d?.id===r.id?`border-attention border-4`:``} ${x?`border-info bg-info/50 dark:bg-info/20`:``}`,onClick:()=>a?.(r),children:[x&&t(`div`,{className:`absolute top-2 end-8 z-10`,children:t(eh,{className:`size-4 text-info`})}),e&&t(`div`,{className:`absolute top-2 start-2 z-10 flex flex-col items-center gap-1`,children:t(`input`,{checked:e.isSelected(r.id),type:`checkbox`,onChange:b,onClick:e=>e.stopPropagation()})}),t(`div`,{className:`absolute top-1 end-1 z-10 flex flex-col items-center`,children:t(o,{variant:`ghost`,size:`sm`,title:`Preview Object`,onClick:e=>{e.stopPropagation(),u?.(r.id)},children:t(Ag,{className:`size-4 ${_===`ready`?`text-muted`:`text-white`}`})})}),p&&_===`ready`?t(`img`,{src:p,alt:h,className:`w-auto h-48 object-cover rounded-t-xl`}):t(`div`,{className:`h-48 bg-muted rounded-t-xl flex items-center justify-center text-muted`,children:_}),t(Ee,{className:`bg-muted h-[2px]`}),n(c,{className:`p-2 flex flex-col`,children:[n(`div`,{className:`flex flex-col overflow-hidden`,children:[t(We,{placement:`top`,description:y,children:t(`h3`,{className:`text-start font-medium leading-none truncate`,children:y})}),r?.type?.name?t(We,{placement:`bottom`,size:`xs`,description:r?.type?.name,children:t(`p`,{className:`text-start text-xs text-muted truncate`,children:r?.type?.name})}):t(`p`,{className:`text-xs text-muted`,children:` `})]}),r.score&&n(`div`,{className:`text-xs text-muted w-full flex justify-end`,children:[`Score: `,r.score.toFixed(4)??`-`]})]})]})}Q();function F$({objects:e,selection:r,isLoading:i,columns:a,onRowClick:o,highlightRow:s,selectedObject:c,toggleAll:l,onSelectionChange:u}){let{t:d}=K();return n(Le,{className:`w-full`,children:[t(Fe,{children:n(`tr`,{children:[r&&t(`th`,{children:t(`input`,{type:`checkbox`,onChange:l})}),a.map(e=>t(`th`,{children:e.name},e.name))]})}),n(Pe,{isLoading:i,columns:a.length+1,children:[e?.map(e=>{let i=s?.(e);return n(`tr`,{className:`group cursor-pointer hover:bg-muted ${c?.id===e.id?`bg-muted`:``} ${i?`bg-info`:``}`,onClick:()=>{o?.(e)},children:[r&&t(`td`,{onClick:e=>e.stopPropagation(),children:t(`input`,{checked:r.isSelected(e.id),type:`checkbox`,className:`${r.isSelected(e.id)?``:`hidden group-hover:block`}`,onChange:t=>u(e,t)})}),a.map((t,n)=>t.render(e,n)),t(`td`,{className:`w-8 text-center`,children:i&&t(eh,{className:`size-4 text-info inline-block`})})]},e.id)}),e.length===0&&t(`tr`,{children:t(`td`,{colSpan:a.length+ +!!r,className:`text-center`,children:d(`store.noObjectsDragAndDrop`)})})]})]})}function I$({objects:r,selection:i,isLoading:a,onSelectionChange:o,onRowClick:s,highlightRow:c,previewObject:l,selectedObject:u}){return n(e,{children:[t(N$,{isLoading:a}),t(`div`,{className:`w-full gap-2 grid xs:grid-cols-1 sm:grid-cols-2 md:grid-cols-4 lg:grid-cols-6 @xs:grid-cols-1 @sm:grid-cols-2 @md:grid-cols-3 @lg:grid-cols-4`,children:r.map(e=>t(P$,{document:e,selection:i,onSelectionChange:o,onRowClick:s,highlightRow:c,previewObject:l,selectedObject:u},e.id))})]})}var L$=class{client;limit;collectionId;facets=new De({});result=new De({objects:[],isLoading:!1});initialized=!1;facetSpecs=[];query={};deletedIds=new Set;loadedCount=0;constructor(e,t=100){this.client=e,this.limit=t}withFacets(e){return this.facetSpecs=e,this}get objects(){return this.result.value.objects}get error(){return this.result.value.error}get isRunning(){return this.result.value.isLoading}get hasMore(){return this.result.value.hasMore||!1}getFilterValue(e){return this.query[e]}setFilterValue(e,t){this.query[e]=t,this.search()}setDefaultKeys(e){}clearFilters(e=!0){let{parent:t,full_text:n,vector:r,weights:i,score_aggregation:a,dynamic_scaling:o,limit:s,all_revisions:c}=this.query;this.query={parent:t,...n!==void 0&&{full_text:n},...r!==void 0&&{vector:r},...i!==void 0&&{weights:i},...a!==void 0&&{score_aggregation:a},...o!==void 0&&{dynamic_scaling:o},...s!==void 0&&{limit:s},...c!==void 0&&{all_revisions:c}},e&&this.search()}getFacetBuckets(e){let t=this.facets.value[e];return Array.isArray(t)?t:[]}resetFacets(){this.query={}}removeDeletedObjects(e){if(e.length===0)return;for(let t of e)this.deletedIds.add(t);let t=this.result.value,n=t.objects.filter(e=>!this.deletedIds.has(e.id)),r=t.objects.length-n.length;this.result.value={...t,objects:n};let i=this.facets.value;r>0&&typeof i.total==`number`&&(this.facets.value={...i,total:Math.max(0,i.total-r)})}reset(e=!1){this.initialized=!1,this.deletedIds.clear(),this.loadedCount=0,this.result.value={objects:[],isLoading:e,hasMore:!0}}_updateRunningState(e){let t=this.result.value;this.result.value={objects:t.objects,isLoading:e,error:t.error,hasMore:t.hasMore}}_searchRequest(e,t,n,r=!0){let i={limit:t,offset:n,query:e,facets:r?this.facetSpecs:void 0};return this.collectionId?this.client.collections.searchMembers(this.collectionId,i):this.client.objects.search(i)}_facetsRequest(){let e={facets:this.facetSpecs,query:this.query};return this.collectionId?this.client.collections.computeFacets(this.collectionId,e):this.client.objects.computeFacets(e)}computeFacets(e){this._facetsRequest().then(e=>{this.facets.value=e})}async _search(e=!1,t=!1){if(this.isRunning&&e)return!1;let n=this.result.value;e||(this.initialized=!0),this.result.value={isLoading:!0,objects:e?this.objects:[],hasMore:!e||this.result.value.hasMore};let r=this.limit,i=e?this.loadedCount:0;try{let n=await this._searchRequest(this.query,r,i,!t),a=n.results||[],o=n.facets||{};if(this.loadedCount=e?this.loadedCount+a.length:a.length,!e&&this.deletedIds.size>0)for(let e of[...this.deletedIds])a.some(t=>t.id===e)||this.deletedIds.delete(e);let s=this.deletedIds.size>0?a.filter(e=>!this.deletedIds.has(e.id)):a;return this.result.value={isLoading:!1,objects:e?this.objects.concat(s):s,hasMore:a.length===r},!t&&o&&Object.keys(o).length>0&&(this.facets.value=o),!0}catch(e){if(typeof e==`object`&&e&&`status`in e&&e.status===404)return this.result.value={isLoading:!1,objects:[],hasMore:!1},!1;let t=e instanceof Error?e:Error(String(e));return this.result.value={error:t,isLoading:!1,objects:n.objects,hasMore:!1},!1}}search(e=!1){return this.isRunning?Promise.resolve(!1):this._search(!1,e)}loadMore(e=!1){return this.isRunning||!this.hasMore||this.query.vector?Promise.resolve(!1):(this.objects.length>0&&(e=!0),this._search(!0,e))}};const R$=dt(void 0);function z$(){return _t(R$)}function B$(){return rt(z$().facets)}function V$(){let e=z$();return{...rt(e.result),search:e}}function H$(){let e=z$();return rt(e.facets).total}const U$=Xt.getFixedT(null,Yt);var W$;(function(e){e.CREATE=`create`,e.SKIP=`skip`,e.UPDATE=`update`})(W$||={});async function G$(e){try{let t=await e.arrayBuffer(),n=new nr;return n.appendByteArray(new Uint8Array(t)),n.end()?.toString()}catch(e){console.error(`Error calculating file hash:`,e);return}}async function K$(e,t){let n=[];for(let r=0;r<e.length;r+=5){let i=e.slice(r,r+5),a=await Promise.all(i.map(async e=>{let n=t||`/`;if(e.webkitRelativePath){let r=e.webkitRelativePath.split(`/`);if(r.length>1){let e=r.slice(0,-1).join(`/`);n=t?`${t}/${e}`:e}}return{file:e,hash:await G$(e),name:e.name,size:e.size,location:n}}));n.push(...a)}return n}function q$(){let{client:e}=q(),t=nt();return{checkDocumentProcessing:V(async(n,r,i)=>{try{console.log(`Preparing metadata for ${n.length} files...`);let t=await K$(n,r);return await(async()=>{let n=t.map(e=>e.hash).filter(Boolean);if(n.length===0)return;let r={"content.etag":{$in:n}},a;if(i){let t={query:{match:r},select:`id content.etag`};a=(await e.store.collections.searchMembers(i,t)).results.filter(e=>typeof e.id==`string`)}else{let t={query:r,select:`id content.etag`};a=(await e.store.objects.find(t)).flatMap(e=>typeof e.id==`string`?[{id:e.id,content:e.content}]:[])}for(let e of a){let n=t.find(t=>t.hash===e.content?.etag);n&&(n.existingId=e.id,n.action=W$.SKIP)}})(),await(async()=>{let n=t.filter(e=>e.action!==W$.SKIP),r=n.map(e=>e.location),a=Array.from(new Set(r)),o=[];for(let t of a){let r={"content.name":{$in:n.filter(e=>e.location===t).map(e=>e.name)},location:t||`/`};if(i){let t=e.store.collections.searchMembers(i,{query:{match:r},select:`id content.name location`}).then(e=>e.results);o.push(t)}else{let t=e.store.objects.find({query:r,select:`id content.name location`});o.push(t)}}let s=(await Promise.all(o)).flat();console.log(`Found ${s.length} document to update`,s);for(let e of s){let n=t.find(t=>t.name===e.content?.name&&(t.location?t.location===e.location:e.location===`/`));n&&(n.existingId=e.id,n.action=W$.UPDATE)}console.log(`Reconciled ${t.filter(e=>e.action===W$.UPDATE).length}`)})(),t.forEach(e=>{e.action||=W$.CREATE}),console.log(`Document processing check results:`,{totalFiles:n.length,toCreate:t.filter(e=>e.action===W$.CREATE).length,toUpdate:t.filter(e=>e.action===W$.UPDATE).length,toSkip:t.filter(e=>e.action===W$.SKIP).length}),t}catch(e){throw t({title:U$(`store.errorInUploadProcessingCheck`),status:`error`,description:Ge(e)}),console.log(`Error in file upload processing check`,e),Error(`Error in file upload processing check: ${Ge(e)}`,{cause:e})}},[e,t])}}Q();function J$({isOpen:r,onClose:i,files:a,collectionId:s,selectedFolder:c,title:l,children:u,onUploadComplete:d,hideFileSelection:f=!1,showTypeSelectionOnly:p=!1,allowFolders:m=!0,initialTypeId:h,defaultProperties:g}){let{client:_}=q(),{registry:v}=nQ(),y=nt(),{t:b}=K(),x=l??b(`upload.uploadFiles`),[S,C]=G([]),[w,T]=G([]),[E,D]=G(!1),[O,k]=G(null),[A,j]=G([]),[M,N]=G(!1),[P,F]=G(!1),[I,L]=G(0),[ee,R]=G(Date.now()),[te,ne]=G(void 0),[re,ie]=G(null),[ae,de]=G(x),[fe,pe]=G(``);H(()=>{s&&_.store.collections.retrieve(s).then(ne)},[_.store.collections.retrieve,s]),H(()=>{M?(de(b(`upload.uploadingFiles`)),pe(`${Math.round(I)}% complete`)):P?(de(b(`upload.uploadComplete`)),pe(``)):E?(de(b(`upload.fileAnalysisResults`)),pe(`${S.length} file${S.length===1?``:`s`}`)):S.length>0?(de(x),pe(b(`upload.checkingForDuplicates`))):(de(x),pe(``))},[M,P,E,x,I,S.length,b]);let me=()=>!te&&!c?null:n(oe,{className:`mb-4`,status:`default`,icon:t(o_,{className:`size-5`}),children:[t(`div`,{className:`flex items-center`,children:t(`span`,{className:`font-medium`,children:b(`upload.uploadLocation`)})}),n(`div`,{className:`text-sm mt-1`,children:[te&&n(`div`,{className:`flex items-center`,children:[t(`span`,{className:`me-1`,children:b(`upload.collectionLabel`)}),t(`span`,{className:`font-medium`,children:te.name})]}),c&&n(`div`,{className:`flex items-center mt-1`,children:[t(`span`,{className:`me-1`,children:b(`upload.folderLabel`)}),t(`span`,{className:`font-medium`,children:c})]})]})]}),[he,ge]=G({toCreate:0,toUpdate:0,toSkip:0}),{checkDocumentProcessing:_e}=q$(),ve=U(()=>v?.types||[],[v?.types]),ye=V(async e=>{if(e.length)try{console.log(`Processing ${e.length} files to determine required actions...`);let t=await _e(e,c,s);T(t);let n=t.filter(e=>e.action===W$.CREATE).length,r=t.filter(e=>e.action===W$.UPDATE).length,i=t.filter(e=>e.action===W$.SKIP).length;ge({toCreate:n,toUpdate:r,toSkip:i}),y({title:b(`upload.filesAnalyzed`),description:`${e.length} file(s): ${n} new, ${r} to update, ${i} to skip`,status:`info`,duration:4e3}),D(!0)}catch(e){console.error(`Error processing files:`,e),y({title:b(`agent.error`),description:b(`upload.errorAnalyzingFiles`),status:`error`,duration:5e3})}},[_e,s,c,b,y]);H(()=>{r&&(T([]),D(!1),k(h?v?.getType(h)??null:null),j([]),N(!1),F(!1),L(0),ge({toCreate:0,toUpdate:0,toSkip:0}),ie(null),de(x),pe(``),a&&a.length>0?(C(a),ye(a)):C([]),R(Date.now()))},[a,h,r,ye,x,v]);let be=()=>{C([]),T([]),D(!1),k(null),j([]),N(!1),F(!1),L(0),ge({toCreate:0,toUpdate:0,toSkip:0}),ie(null),de(x),pe(``),R(Date.now()),i()},xe=e=>{e&&e.length>0&&(C(e),ye(e))},Se=async()=>{if(!w.length)return;let e=O?.id||null,t=w.map(e=>({file:e.file,status:`pending`,progress:0,action:e.action===W$.CREATE?`create`:e.action===W$.UPDATE?`update`:`skip`}));j(t),N(!0),F(!1);let n=w.filter(e=>e.action===W$.SKIP),r=w.filter(e=>e.action===W$.UPDATE),i=w.filter(e=>e.action===W$.CREATE),a={success:!0,objectIds:[],uploadedFiles:[],skippedFiles:[],failedFiles:[]};for(let t of n)t.existingId&&(a.objectIds.push(t.existingId),a.skippedFiles.push({id:t.existingId,name:t.name,type:e,status:`skipped`,location:t.location}),j(e=>e.map(e=>e.file===t.file?{...e,status:`success`,progress:100,id:t.existingId}:e)));let o=async(t,n)=>{let r=[];for(let e=0;e<t.length;e+=50)r.push(t.slice(e,e+50));for(let i=0;i<r.length;i++){let o=r[i];if(console.log(`Processing ${n} batch ${i+1}/${r.length} (${o.length} files)`),t.length>50){let e=i*50;y({title:b(`upload.processingFilesAction`,{action:n}),description:b(`upload.processedCount`,{processed:e,total:t.length}),status:`info`,duration:2e3})}let c=0;await Promise.all(o.map(async t=>{try{if(j(e=>e.map(e=>e.file===t.file?{...e,status:`uploading`,progress:20}:e)),n===`update`&&t.existingId)await _.store.objects.update(t.existingId,{type:e||void 0,content:t.file,location:t.location,name:t.name},{createRevision:!0,revisionLabel:`upload on ${new Date().toISOString()}`}),j(e=>e.map(e=>e.file===t.file?{...e,status:`success`,progress:100,id:t.existingId}:e)),a.objectIds.push(t.existingId),a.uploadedFiles.push({id:t.existingId,name:t.name,type:e,status:`updated`,location:t.location});else{let n=await _.store.objects.create({type:e||void 0,content:t.file,location:t.location||t.file.webkitRelativePath||t.name,properties:g},{collection_id:s});j(e=>e.map(e=>e.file===t.file?{...e,status:`success`,progress:100,id:n.id}:e)),a.objectIds.push(n.id),a.uploadedFiles.push({id:n.id,name:t.name,type:e,status:`created`,location:t.location})}}catch(n){console.error(`Failed to process file ${t.name}:`,n),j(e=>e.map(e=>e.file===t.file?{...e,status:`error`,progress:100,message:Ge(n,`Unknown error`)}:e)),a.failedFiles.push({name:t.name,error:Ge(n,`Unknown error`),status:`failed`,location:t.location,type:e}),a.success=!1}c++,(c%5==0||c===o.length)&&j(e=>{let t=e.filter(e=>e.status===`success`||e.status===`error`).length,n=e.length,r=n>0?Math.round(t/n*100):0;return L(r),e})}))}};r.length>0&&await o(r,`update`),i.length>0&&await o(i,`create`),j(e=>{let t=e.filter(e=>e.status===`pending`).map(e=>({...e,status:`error`,progress:100,message:b(`upload.uploadProcessInterrupted`)}));return t.length>0?(t.forEach(e=>{a.failedFiles.push({name:e.file.name,error:b(`upload.uploadProcessInterrupted`),status:`failed`,type:O?.id||null})}),a.success=!1,e.map(e=>e.status===`pending`?{...e,status:`error`,progress:100,message:b(`upload.uploadProcessInterrupted`)}:e)):e}),N(!1),F(!0);let c=a.uploadedFiles.filter(e=>e.status===`created`).length,l=a.uploadedFiles.filter(e=>e.status===`updated`).length,u=a.skippedFiles.length,d=a.failedFiles.length,f=``;c>0&&(f+=`${c} file${c===1?``:`s`} uploaded`),l>0&&(f+=f?`, `:``,f+=`${l} file${l===1?``:`s`} updated`),u>0&&(f+=f?`, `:``,f+=`${u} file${u===1?``:`s`} skipped`),d>0&&(f+=f?`, `:``,f+=`${d} file${d===1?``:`s`} failed`),y({title:b(`upload.uploadComplete`),description:f,status:d>0?`warning`:`success`,duration:5e3}),ie(a)},Ce=()=>n(`div`,{className:`mb-4`,children:[n(`div`,{className:`block text-sm font-medium mb-2`,children:[b(`store.contentType`),` `,t(`span`,{className:`text-muted font-normal`,children:b(`store.optional`)}),t(We,{description:b(`upload.contentTypeTooltip`),placement:`top`,size:`xs`,children:t(A_,{className:`size-3 ms-2`})})]}),t(we,{options:ve,value:O,optionLabel:e=>e?e.name:b(`store.selectContentTypeLabel`),placeholder:b(`store.selectContentTypeAuto`),onChange:e=>k(e===void 0?null:e),filterBy:`name`,isClearable:!0}),!O&&t(`div`,{className:`p-2 rounded-md`,children:n(`div`,{className:`flex items-center text-attention`,children:[t(Nh,{className:`size-4 me-1`}),b(`store.automaticTypeDetection`),t(We,{description:b(`store.automaticTypeDetectionDescription`),placement:`top`,size:`xs`,children:t(A_,{className:`size-3 ms-2`})})]})})]});return n(se,{isOpen:r,onClose:be,className:`mx-auto`,disableCloseOnClickOutside:!0,children:[t(ue,{description:fe,children:ae}),p?n(ce,{children:[u,me(),Ce()]}):S.length===0&&!f?n(ce,{className:`flex flex-col items-center justify-center p-8`,children:[me(),t(Ot,{onDrop:xe,message:b(`upload.dragAndDrop`),buttonLabel:b(`upload.selectFiles`),className:`w-full h-64`,allowFolders:m}),u]}):!M&&!P?t(ce,{children:E?n(e,{children:[me(),t(`div`,{className:`mb-4`,children:t(`div`,{className:`p-4 rounded-md mb-4`,children:n(`div`,{className:`grid grid-cols-3 gap-4`,children:[n(`div`,{className:`flex flex-col items-center`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(wb,{className:`size-5 text-info`}),t(`span`,{className:`font-medium`,children:b(`upload.new`)})]}),t(`div`,{className:`text-2xl font-semibold`,children:he.toCreate})]}),n(`div`,{className:`flex flex-col items-center`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(Nh,{className:`size-5 text-success`}),t(`span`,{className:`font-medium`,children:b(`upload.update`)})]}),t(`div`,{className:`text-2xl font-semibold`,children:he.toUpdate})]}),n(`div`,{className:`flex flex-col items-center`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(Ah,{className:`size-5 text-mixer-attention/40`}),t(`span`,{className:`font-medium`,children:b(`upload.skip`)})]}),t(`div`,{className:`text-2xl font-semibold`,children:he.toSkip})]})]})})}),Ce(),t(oe,{className:`mb-4`,status:`info`,children:he.toCreate+he.toUpdate>0?n(`div`,{className:`space-y-1`,children:[t(`p`,{children:b(`upload.filesReadyToProcess`,{count:he.toCreate+he.toUpdate})}),t(`p`,{children:he.toSkip>0&&b(`upload.filesToSkip`,{count:he.toSkip})})]}):he.toSkip>0?t(`span`,{children:b(`upload.allFilesExist`,{count:he.toSkip})}):t(`span`,{children:b(`upload.noFilesToProcess`)})})]}):n(`div`,{className:`flex flex-col items-center justify-center py-4`,children:[t(je,{size:`lg`,className:`mb-4`}),t(`div`,{className:`text-lg font-medium`,children:b(`upload.analyzingFiles`)})]})}):M?n(ce,{children:[me(),t(`div`,{className:`mb-4`,children:t(`div`,{className:`h-2 bg-muted/20 rounded-full overflow-hidden`,children:t(`div`,{className:`h-full bg-primary rounded-full`,style:{width:`${I}%`}})})}),t(`div`,{className:`max-h-96 overflow-y-auto`,children:A.map((e,r)=>n(`div`,{className:`flex items-center py-2 border-b border-border last:border-b-0`,children:[n(`div`,{className:`me-3`,children:[e.status===`pending`&&t(Zg,{className:`size-5 text-muted`}),e.status===`uploading`&&t(je,{size:`sm`}),e.status===`success`&&t(Nh,{className:`size-5 text-success`}),e.status===`error`&&t(Gh,{className:`size-5 text-destructive`})]}),n(`div`,{className:`flex-1 min-w-0`,children:[t(`div`,{className:`truncate font-medium`,children:e.file.name}),n(`div`,{className:`text-xs text-muted`,children:[e.status===`pending`&&b(`agent.waiting`),e.status===`uploading`&&b(`agent.uploading`),e.status===`success`&&(e.action===`create`?b(`store.created`):e.action===`update`?b(`store.updated`):b(`upload.skip`)),e.status===`error`&&e.message]})]})]},`${e.file.name}-${e.file.size}-${e.file.lastModified}`))})]}):t(ce,{children:n(`div`,{className:`mb-4`,children:[me(),t(Lt,{files:A.map(e=>{let t;return t=e.status===`success`?e.action===`create`?`success`:e.action===`update`?`updated`:`skipped`:`failed`,{name:e.file.name,status:t,error:e.status===`error`?e.message:void 0}}),location:c||void 0,collection:te?.name})]})}),(()=>{if(p)return n(le,{children:[t(o,{variant:`ghost`,onClick:be,children:b(`modal.cancel`)}),t(o,{onClick:()=>{let e={success:!0,objectIds:[],uploadedFiles:[{name:`type-selection`,type:O?.id||null,status:`created`}],skippedFiles:[],failedFiles:[]};d&&d(e),be()},children:O?b(`upload.useTypeName`,{typeName:O.name}):b(`upload.useAutoDetection`)})]});if(S.length===0&&!f)return t(le,{children:t(o,{variant:`ghost`,onClick:be,children:b(`modal.cancel`)})});if(!M&&!P){let e=E;return n(le,{children:[t(o,{variant:`ghost`,onClick:be,children:b(`modal.cancel`)}),t(o,{disabled:!e,onClick:Se,children:he.toCreate+he.toUpdate>0?b(`agent.upload`):b(`upload.continue`)})]})}return M?t(le,{children:t(o,{variant:`ghost`,disabled:!0,children:b(`agent.uploading`)})}):n(le,{children:[t(o,{variant:`ghost`,onClick:()=>{C([]),T([]),D(!1),k(null),j([]),N(!1),F(!1),L(0),ge({toCreate:0,toUpdate:0,toSkip:0})},children:b(`upload.uploadMore`)}),t(o,{onClick:()=>{d&&re&&d(re),be()},children:b(`agent.close`)})]})})()]},ee)}function Y$(e){let t=typeof e==`function`?e:e.onUploadDone,{client:n,project:r,store:i}=q(),a=z$(),o=nt(),s=Xt.getFixedT(null,Yt),{checkDocumentProcessing:c}=q$();return async(e,l,u)=>{let d={success:!1,objectIds:[],uploadedFiles:[],skippedFiles:[],failedFiles:[]};if(!r)return o({status:`error`,title:s(`store.noProjectSelected`),duration:3e3}),d;if(!e||e.length===0)return o({status:`warning`,title:s(`store.noFilesSelected`),duration:3e3}),d;let f=Array.from(e).filter(e=>e.size>0);if(f.length===0)return o({status:`error`,title:s(`store.noValidFilesSelected`),description:s(`store.pleaseSelectValidFiles`),duration:5e3}),d;let p=[],m=[],h=[];console.log(`Processing ${f.length} files with smart file processing...`);let g=await c(f,null,u),_=g.filter(e=>e.action===W$.CREATE).length,v=g.filter(e=>e.action===W$.UPDATE).length,y=g.filter(e=>e.action===W$.SKIP).length;o({title:s(`store.filesAnalyzedTitle`),description:`${f.length} file(s): ${_} new, ${v} to update, ${y} to skip`,status:`info`,duration:4e3});for(let e of g.filter(e=>e.action===W$.SKIP&&e.existingId))p.push({id:e.existingId,name:e.name,type:l,status:`skipped`,location:e.location});let b=g.filter(e=>(e.action===W$.CREATE||e.action===W$.UPDATE)&&e.file);if(b.length>0){console.log(`Processing ${b.length} files (${b.filter(e=>e.action===W$.CREATE).length} create, ${b.filter(e=>e.action===W$.UPDATE).length} update)...`);let e=[];for(let t=0;t<b.length;t+=50)e.push(b.slice(t,t+50));for(let t=0;t<e.length;t++){let r=e[t],a=t*50;console.log(`Processing batch ${t+1}/${e.length} (${r.length} files)`),b.length>50&&o({title:s(`store.processingFiles`),description:`Processed ${a}/${b.length} files...`,status:`info`,duration:2e3});let c=await Promise.all(r.map(async e=>{try{if(e.action===W$.UPDATE&&e.existingId){let t=await n.store.objects.update(e.existingId,{type:l||void 0,content:e.file,location:e.location,name:e.name},{createRevision:!0,revisionLabel:`upload on ${new Date().toISOString()}`});return m.push({id:e.existingId,name:e.name,type:l,status:`updated`,location:e.location}),d.objectIds.push(e.existingId),{success:!0,id:t.id,name:e.name,action:`update`}}{let t=u?{collection_id:u}:void 0,n=await i.objects.create({type:l||void 0,content:e.file,location:e.location||e.file.webkitRelativePath||e.name},t);m.push({id:n.id,name:e.name,type:l,status:`created`,location:e.location})}}catch(t){console.error(`Failed to process file ${e.name}:`,t),h.push({name:e.name,error:Ge(t,`Unknown error`),status:`failed`,location:e.location,type:l}),o({status:`error`,title:s(`store.processingFailedFor`,{name:e.name}),description:Ge(t),duration:4e3})}})),f=m.filter(e=>e.status===`created`),p=m.filter(e=>e.status===`updated`),g=m.filter(e=>e.status===`failed`);console.log(`Batch ${t+1} results:`,{creates:f,updates:p,failures:g,total:c.length})}}let x=m.filter(e=>e.status===`created`).length,S=m.filter(e=>e.status===`updated`).length,C=m.filter(e=>e.status===`failed`).length,w=m.filter(e=>e.status===`skipped`).length;t&&(console.log(`Upload complete:`,{totalObjectIds:d.objectIds.length,uploadedFiles:x,updatedFiles:S,skippedFiles:w,failedFiles:C}),await t(d.objectIds));let T=``;return x>0&&(T+=`${x} file${x===1?``:`s`} uploaded`),S>0&&(T+=T?`, `:``,T+=`${S} file${S===1?``:`s`} updated`),w>0&&(T+=T?`, `:``,T+=`${w} file${w===1?``:`s`} skipped (already existed)`),C>0&&(T+=T?`, `:``,T+=`${C} file${C===1?``:`s`} failed`),T&&o({status:C>0?`warning`:`success`,title:T,duration:4e3}),a.search(),d}}const X$=[{name:`ID`,field:`id`,type:`objectId?slice=-7`},{name:`Name`,field:`.`,type:`objectName`},{name:`Type`,field:`type.name`,type:`string`},{name:`Status`,field:`status`,type:`string`},{name:`Updated At`,field:`updated_at`,type:`date`}];function Z$({isGridView:e=!1,onUpload:n,collectionId:r,...i}){return n?t(Q$,{...i,onUpload:n,isGridView:e,collectionId:r}):t($$,{...i,isGridView:e})}function Q$({isGridView:e,onUpload:r,collectionId:i,skipTypeModal:a=!1,...o}){let[s,c]=G(!1),[l,u]=G([]),[d,f]=G(!1),[p,m]=G(null),[h,g]=G(!1),_=z$(),v=nt(),{t:y}=K(),{checkDocumentProcessing:b}=q$(),x=async(e,t)=>{console.log(`Files dropped on ObjectTable:`,e.length,t),c(!0);try{if(i){let t=await b(e,null,i);m(t);let n=t.filter(e=>e.action===`create`).length,r=t.filter(e=>e.action===`update`).length,a=t.filter(e=>e.action===`skip`).length;v({title:y(`store.filesReadyToProcess`),description:`${e.length} file(s): ${n} new, ${r} to update, ${a} to skip`,status:`info`,duration:4e3})}else m(null)}catch(e){console.error(`Error processing files:`,e),v({title:y(`store.errorProcessingFiles`),description:y(`store.errorCheckingDuplicates`),status:`error`,duration:4e3}),m(null)}finally{if(c(!1),u(e),f(!1),a){console.log(`Skipping type modal and calling onUpload directly`,{filesLength:e.length,processedFilesLength:p?.length});let t=r(e,null,i);t&&typeof t==`object`&&(t.processedFiles=p)}else console.log(`Setting typeSelectionOpen to true`,{filesLength:e.length}),g(!0)}},S=e=>{let t=[...l];u([]),m(null),g(!1),t.length>0&&e!==void 0&&(c(!0),console.log(`Starting upload with`,{typeId:e,filesCount:t.length,hasProcessingResults:!!p,collectionId:i}),r(t,e,i).finally(()=>{c(!1),_.search()}))},C=e=>{e.preventDefault(),e.stopPropagation(),f(!0)};return n(`div`,{className:`min-h-[400px] relative`,onDragOver:C,onDragEnter:C,onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),!e.currentTarget.contains(e.relatedTarget)&&f(!1)},onDrop:e=>{if(e.preventDefault(),e.stopPropagation(),f(!1),e.dataTransfer.items){let t=[];for(let n=0;n<e.dataTransfer.items.length;n++){let r=e.dataTransfer.items[n];if(r.kind===`file`){let e=r.getAsFile();e&&t.push(e)}}if(t.length>0){let e={count:t.length,message:`Preparing to upload ${t.length} file${t.length===1?``:`s`}...`};x(t,e)}}},children:[t(`div`,{className:it(`bg-white dark:bg-muted opacity-40 absolute inset-0 z-50 flex justify-center items-center`,s?`block`:`hidden`),children:t(je,{size:`xl`})}),t($$,{...o,isGridView:e}),t(`div`,{className:it(`absolute inset-0 pointer-events-none`,d?`z-40`:`-z-10`),children:t(`div`,{className:`w-full h-full relative`,children:t(Ot,{onDrop:x,message:`Drop files or folders here to upload`,className:it(`absolute inset-0 bg-white/90 dark:bg-muted/90 pointer-events-auto`,d?`flex`:`hidden`),buttonLabel:`Select Files or Folders`,allowFolders:!0})})}),t(J$,{isOpen:h&&l.length>0,onClose:()=>{u([]),m(null),g(!1),S(void 0)},files:l,collectionId:i,selectedFolder:null,title:`Upload Files`,onUploadComplete:e=>{if(e){if(e.failedFiles&&e.failedFiles.length>0&&v({title:y(`store.uploadIssues`),description:`${e.failedFiles.length} file(s) failed to upload`,status:`warning`,duration:5e3}),e.success){let t=e.uploadedFiles.filter(e=>e.status===`created`).length,n=e.uploadedFiles.filter(e=>e.status===`updated`).length,r=e.skippedFiles.length;(t>0||n>0)&&v({title:y(`store.uploadComplete`),description:`${t>0?`${t} created`:``}${t>0&&n>0?`, `:``}${n>0?`${n} updated`:``}${r>0?`, ${r} skipped`:``}`,status:`success`,duration:5e3})}_.search()}u([]),m(null),g(!1),e?.success&&e.objectIds.length>0?S(null):S(void 0)}})]})}function $$({objects:e,layout:n=X$,isLoading:r,onRowClick:i,onSelectionChange:a,highlightRow:o,previewObject:s,selectedObject:c,isGridView:l}){let u=QQ(),d=(t,n)=>{if(u){let r=n.nativeEvent instanceof MouseEvent&&n.nativeEvent.shiftKey;if(!n.target.checked)u.remove(t.id);else if(u.add(t),r){let n=e.findIndex(e=>e.id===t.id),r=e1(e,n,u);if(r>-1&&r<n-1){let t=[];for(let i=r+1;i<n;i++)t.push(e[i]);u.addAll(t)}else{let t=t1(e,n,u);if(t>-1&&t>n+1){let r=[];for(let i=n+1;i<t;i++)r.push(e[i]);u.addAll(r)}}}a?.(u)}},f=t=>{u&&(t.target.checked?u.addAll(e):u.removeAll())},p=U(()=>{let e=n.length>0?n:X$;return console.log(`Using layout with columns:`,e.map(e=>e.name).join(`, `)),e.map(e=>new M$(e,s))},[n,s]);return t(l?I$:F$,{objects:e,isLoading:r,columns:p,onRowClick:i,highlightRow:o,previewObject:s,selectedObject:c,selection:u,toggleAll:f,onSelectionChange:d})}function e1(e,t,n){for(let r=t-1;r>=0;r--)if(n.isSelected(e[r].id))return r;return-1}function t1(e,t,n){let r=e.length;for(let i=t+1;i<r;i++)if(n.isSelected(e[i].id))return i;return-1}function n1({children:e,limit:n,parent:r,typeId:i,facets:a,name:o,collectionId:s}){let{store:c}=q(),l=U(()=>{let e;a?e=a:(e=[{name:`status`,field:`status`},{name:`location`,field:`location`}],i||e.unshift({name:`type`,field:`type`}));let t=new L$(c,n).withFacets(e);return t.collectionId=s,t.query.type=i,t.query.parent=r,t.query.name=o,s&&(t.query.all_revisions=!0),t},[s,a,n,o,r,c,i]);return t(R$.Provider,{value:l,children:e})}Q();const r1=`vertesia.content_store.lastDisplayedView`;function i1({onUpdate:e}){let{t:n}=K(),[r,i]=G(localStorage.getItem(r1)===`grid`),a=()=>{r?c():s()},s=()=>{localStorage.setItem(r1,`grid`),i(!0),e(!0)},c=()=>{localStorage.setItem(r1,`table`),i(!1),e(!1)};return t(o,{variant:`outline`,onClick:a,title:n(r?`misc.tableView`:`misc.thumbnailView`),children:t(r?ob:I_,{})})}i1.LAST_DISPLAYED_VIEW=r1,Q();const a1=[{name:`Name`,field:`properties.title`,type:`string`,fallback:`name`},{name:`Type`,field:`type.name`,type:`string`},{name:`Status`,field:`status`,type:`string`},{name:`Created At`,field:`created_at`,type:`date`}];function o1({onChange:e,selectedIds:n}){return t(n1,{children:t(s1,{onRowClick:t=>{e(t||void 0)},selectedIds:n})})}function s1({onRowClick:e,selectedIds:r}){let{t:i}=K(),a=V(e=>!!r?.has(e.id),[r]),[s,c]=G(!1),[l,u]=G(localStorage.getItem(`vertesia.content_store.lastDisplayedView`)===`grid`),{search:d,isLoading:f,error:p,objects:m,hasMore:h}=V$(),g=W(null);Qe(g,()=>{s&&h&&!f&&(c(!1),d.loadMore(!0).finally(()=>{c(!0)}))},{threshold:.1,deps:[s,h,f]}),H(()=>{d.search().finally(()=>{c(!0)})},[d]);let _=B$(),v=z$();return p?t(M,{title:i(`store.searchFailed`),children:p.message}):n(`div`,{className:`flex flex-col gap-2 h-full w-full`,children:[n(`div`,{className:`flex justify-between items-center flex-shrink-0`,children:[t(gQ,{facets:_,search:v}),n(`div`,{className:`flex items-center gap-2`,children:[t(o,{variant:`outline`,onClick:()=>{c(!1),d.search().then(()=>c(!0))},"aria-label":`Refresh`,children:t(hy,{size:16})}),t(i1,{onUpdate:u})]})]}),n(`div`,{className:`@container relative flex-1 overflow-y-auto`,children:[t(Z$,{objects:m||[],isLoading:!m.length&&f,layout:a1,onRowClick:e,highlightRow:r?.size?a:void 0,isGridView:l}),t(`div`,{ref:g,className:`h-4 w-full`})]})]})}Q();function c1(e){let t=Math.max(0,e)/1e3,n=+(t>0&&t<10&&!Number.isInteger(t));return`${new Intl.NumberFormat(void 0,{maximumFractionDigits:n}).format(t)}K`}function l1({onSend:e,onStop:r,approvalModeSlot:i,mcpSlot:a,disabled:s=!1,isSending:c=!1,isStopping:l=!1,isStreaming:u=!1,isCompleted:d=!1,contextWindowUsage:f,onCompactContext:p,isCompactingContext:m=!1,activeTaskCount:h=0,activeWorkstreams:g=[],onSelectWorkstream:_,placeholder:v,onFilesSelected:y,uploadedFiles:b=[],onRemoveFile:x,onRemoveProcessingFile:S,acceptedFileTypes:C,maxFiles:T=5,processingFiles:E,artifactRunId:D,hasProcessingFiles:O=!1,renderDocumentSearch:k,selectedDocuments:A=[],onRemoveDocument:j,hideObjectLinking:M=!1,hideFileUpload:N=!1,disableDropZone:P=!1,className:F,inputClassName:I}){let{t:L}=K(),ee=v??L(`agent.typeYourMessage`),R=W(null),te=W(null),[ne,re]=G(``),[ie,oe]=G(!1),[le,de]=G(!1),[fe,pe]=G(!1),me=!!(y&&!N),he=me&&!P,ge=!M||me||!!k,_e=b.length>=T,ve=S??x,ye=U(()=>g.filter(e=>e.status===`running`||e.status===`canceling`),[g]),be=ye.length||h,xe=f?L(`agent.contextUsageCompactLabel`,{percent:f.usedPercent}):void 0,Se=f?L(`agent.contextTokenUsage`,{used:c1(f.usedTokens),limit:c1(f.checkpointTokens)}):void 0,Ce=U(()=>{let e=[];if(!N&&E)for(let t of E.values()){let n=t.preview_url,r=t.status===pn.UPLOADING?L(`agent.uploading`):t.status===pn.PROCESSING?L(`agent.processing`):t.status===pn.ERROR?L(`agent.error`):t.status===pn.READY?L(`agent.ready`):t.status;e.push({id:t.id,name:t.name,contentType:t.content_type,artifactPath:t.artifact_path,previewUrl:n,removable:!!ve,statusLabel:r,statusTone:t.status===pn.ERROR?`destructive`:t.status===pn.READY?`success`:`attention`})}if(!N)for(let t of b)e.push({id:t.id,name:t.name,contentType:t.type,artifactPath:t.artifact_path,previewUrl:t.previewUrl,removable:!!x,statusLabel:L(`agent.ready`),statusTone:`success`});for(let t of A)e.push({id:t.id,name:t.name,href:`/store/objects/${t.id}`,removable:!!j,statusTone:`info`});return e},[ve,N,j,x,E,A,L,b]);H(()=>{!s&&d&&R.current?.focus()},[s,d]);let we=V(e=>{if(!me||!y)return;let t=Array.from(e),n=T-b.length,r=t.slice(0,n);r.length>0&&y(r)},[me,y,T,b.length]),Te=V(e=>{e.preventDefault(),e.stopPropagation(),he&&pe(!0)},[he]),Ee=V(e=>{e.preventDefault(),e.stopPropagation(),pe(!1)},[]),De=V(e=>{e.preventDefault(),e.stopPropagation(),pe(!1),he&&e.dataTransfer?.files&&e.dataTransfer.files.length>0&&we(e.dataTransfer.files)},[he,we]),Oe=V(e=>{if(!me)return;let t=kX(e.clipboardData?.items);t.length>0&&we(t)},[me,we]),ke=V(e=>{me&&e.target.files&&e.target.files.length>0&&(we(e.target.files),e.target.value=``)},[me,we]),Ae=V(()=>{te.current?.click()},[]),Me=V(()=>de(!1),[]),Ne=V(e=>de(!1),[]),Pe=()=>{let t=ne.trim();!t||s||c||O||(e(t),re(``))},Fe=()=>{r&&!l&&r()},Ie=W(0),Le=e=>{if(e.key===`Enter`){if(!(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)){e.preventDefault(),ne.trim().length>0&&Pe();return}e.shiftKey||(e.preventDefault(),Ke(e.currentTarget,re));return}if(e.key===`Escape`&&u&&r){let e=Date.now();e-Ie.current<500?(Fe(),Ie.current=0):Ie.current=e}},Re=V(()=>{let e=R.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`)},[]);return H(()=>{Re()},[ne,Re]),n(`div`,{className:z(`px-3 py-3 flex-shrink-0 transition-all fixed lg:sticky bottom-0 start-0 end-0 lg:start-auto lg:end-auto w-full bg-background/95 backdrop-blur z-10`,fe&&he&&`bg-info/10 border-info`,F),onDragOver:he?Te:void 0,onDragLeave:he?Ee:void 0,onDrop:he?De:void 0,children:[fe&&he&&t(`div`,{className:`absolute inset-0 flex items-center justify-center bg-info/80 dark:bg-info/40 rounded-lg z-10 pointer-events-none`,children:n(`div`,{className:`text-info font-medium flex items-center gap-2`,children:[t(wb,{className:`size-5`}),L(`agent.dropFilesToUpload`)]})}),me&&t(`input`,{ref:te,type:`file`,multiple:!0,accept:C,onChange:ke,className:`hidden`}),t(XX,{activeWorkstreams:g,onSelectWorkstream:_}),n(`div`,{className:`mx-auto flex max-w-3xl flex-col gap-2 rounded-2xl border border-border/70 bg-mixer-muted/15 p-2.5 shadow-lg shadow-black/5`,children:[Ce.length>0&&t(VW,{items:Ce,artifactRunId:D,variant:`composer`,onRemove:e=>{E?.has(e)?ve?.(e):b.some(t=>t.id===e)?x?.(e):j?.(e)},className:`gap-1.5`}),t(`div`,{className:`flex min-w-0 flex-1`,children:t(Ue,{ref:R,value:ne,onKeyDown:Le,onChange:e=>re(e.target.value),onPaste:Oe,disabled:s,"aria-label":ee,placeholder:ee,rows:1,style:{maxHeight:`160px`},className:z(`min-h-[44px] resize-none border-0 bg-transparent px-0 py-0 text-sm leading-6 shadow-none focus-visible:ring-0`,I)})}),n(`div`,{className:`flex items-center justify-between gap-3`,children:[n(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[ge&&n(w,{align:`left`,trigger:t(o,{variant:`ghost`,size:`icon`,className:`size-8 rounded-full text-muted hover:bg-muted`,title:L(`agent.addAttachment`),children:t(oy,{className:`size-4`})}),children:[!M&&n(ae,{onClick:()=>oe(!0),isDisabled:!d,children:[t(Hv,{className:`size-4`}),L(`agent.linkObject`)]}),me&&n(ae,{onClick:Ae,isDisabled:_e,children:[t(wb,{className:`size-4`}),L(`agent.upload`)]}),k&&n(ae,{onClick:()=>de(!0),children:[t(Gg,{className:`size-4`}),t(`span`,{children:L(`agent.searchDocuments`)}),A.length>0&&t(`span`,{className:`ms-auto inline-flex items-center justify-center rounded-full bg-info/20 px-1.5 py-0.5 text-[10px] font-medium text-info`,children:A.length})]})]}),i,a,f&&t(We,{asChild:!0,placement:`top`,size:`md`,className:`text-foreground shadow-lg`,description:n(`span`,{className:`block max-w-56 text-start text-sm leading-6`,children:[t(`span`,{className:`block`,children:L(`agent.contextRemainingUntilCompact`,{percent:f.remainingPercent})}),Se&&t(`span`,{className:`mt-1 block text-foreground/80`,children:Se})]}),children:t(o,{type:`button`,variant:`ghost`,size:`icon`,className:z(`size-8 rounded-lg text-info hover:bg-muted hover:text-info disabled:opacity-60`,`focus-visible:ring-2 focus-visible:ring-info/40`),"aria-label":xe,onClick:p,disabled:!p||m,children:m?t(je,{size:`sm`}):n(`svg`,{viewBox:`0 0 24 24`,className:z(`size-8 -rotate-90`,f.usedPercent>=90?`text-destructive`:f.usedPercent>=70?`text-attention`:`text-info`),"aria-hidden":`true`,children:[t(`circle`,{cx:`12`,cy:`12`,r:`9.75`,fill:`none`,strokeWidth:`4.5`,className:`stroke-current text-muted/50`}),t(`circle`,{cx:`12`,cy:`12`,r:`9.75`,fill:`none`,pathLength:100,strokeWidth:`4.5`,strokeLinecap:`round`,strokeDasharray:100,style:{strokeDashoffset:100-f.usedPercent},className:`stroke-current`})]})})}),ye.length===0&&be>0&&t(`output`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,"aria-live":`polite`,children:n(`span`,{className:`inline-flex h-8 items-center gap-1 rounded-full px-2 text-xs text-muted`,children:[t(xm,{className:`size-3 text-attention`}),L(`agent.activeWorkstreams`,{count:be})]})})]}),u&&r&&!ne.trim()?t(o,{onClick:Fe,disabled:l,variant:`ghost`,size:`icon`,className:z(`size-9 rounded-full border border-border/60 bg-foreground text-background shadow-sm`,`hover:bg-foreground/90 hover:text-background`,`disabled:bg-mixer-muted/25 disabled:text-muted disabled:opacity-100`,`[&_svg]:text-destructive disabled:[&_svg]:text-muted`),title:L(`agent.stopTooltip`),children:l?t(je,{size:`sm`}):t(rb,{className:`size-3 fill-current stroke-current`})}):t(o,{onClick:Pe,disabled:s||c||!ne.trim()||O,variant:`ghost`,size:`icon`,className:z(`size-9 rounded-full border border-border/60 bg-foreground text-background shadow-sm`,`hover:bg-foreground/90 hover:text-background`,`disabled:bg-mixer-muted/25 disabled:text-muted disabled:opacity-100`),title:L(O?`agent.waitForFiles`:`agent.sendTooltip`),"aria-label":L(O?`agent.waitForFiles`:`agent.send`),children:c?t(je,{size:`sm`}):t(Dm,{className:`size-4`})})]})]}),n(se,{isOpen:ie,onClose:()=>oe(!1),className:`min-w-[60vw]`,children:[t(ue,{children:L(`agent.linkObject`)}),t(ce,{className:`pb-6`,children:t(o1,{onChange:e=>{let t=`[${e.properties?.title||e.name||`Object`}](store:${e.id})`,n=ne||``,r=R.current?.selectionStart||n.length,i=n.substring(0,r)+t+n.substring(r);re(i),oe(!1),setTimeout(()=>{if(R.current){R.current.focus();let e=r+t.length;R.current.setSelectionRange(e,e)}},100)}})})]}),k?.({isOpen:le,onClose:Me,onSelect:Ne})]})}function u1({code:e}){let{onProposalSelect:n,onProposalSubmit:r}=qt(),i=U(()=>Wt(e),[e]),a=U(()=>{if(i)return null;try{let t=e.trim(),i=JSON.parse(t);if(!i.options||!i.question&&!i.title)return null;let a={question:i.question||i.title||``,description:i.description,options:Array.isArray(i.options)?i.options.map(e=>({id:e.id||e.value||``,label:e.label||``,description:e.description})):void 0,allowFreeResponse:i.allowFreeResponse??i.multiple,variant:i.variant,onSelect:n,onSubmit:r};return!a.question||!a.options?.length?null:a}catch{return null}},[e,n,r,i]);return i?t(Et,{type:`proposal`,message:`Loading options...`}):a?t(Tt,{type:`proposal`,fallbackCode:e,children:t(jH,{...a})}):t(Et,{type:`proposal`,error:`Invalid proposal specification`})}const d1=gt(function({code:e}){let n=U(()=>{try{let t=JSON.parse(e);return t?.library===`vega-lite`&&t?.spec&&typeof t.spec==`object`?t:typeof t?.$schema==`string`&&t.$schema.includes(`vega`)?{library:`vega-lite`,spec:t}:null}catch{return null}},[e]);return n?t(oC,{spec:n}):null}),f1=gt(function({code:e}){let n=U(()=>{try{return{library:`vega-lite`,spec:JSON.parse(e)}}catch{return null}},[e]);return n?t(oC,{spec:n}):null}),p1={chart:d1,"vega-lite":f1,vegalite:f1,"fusion-fragment":Jn,proposal:u1,askuser:u1};function m1({url:e,code:n}){let[r,i]=G(null);return H(()=>{import(e).then(e=>{i(()=>e.default)}).catch(t=>{console.error(`Failed to load remote widget component from `,e,t)})},[e]),r?t(r,{code:n}):null}async function h1(e){let n=await e.apps.getInstalledApps(`tools`),r=new Set;for(let e of n){if(e.manifest.tool_collections&&e.manifest.tool_collections.length>0)for(let t of e.manifest.tool_collections||[]){let e=An(t).url;if(e.startsWith(`http://`)||e.startsWith(`https://`)){let t=e.indexOf(`/api/`);if(t>0){let n=e.substring(0,t);r.add(`${n}/api/widgets`)}}}e.manifest.endpoint&&e.manifest.capabilities?.includes(`tools`)&&r.add(new URL(`/api/widgets`,e.manifest.endpoint).toString())}let i=await Promise.all(Array.from(r).map(e=>fetch(e).then(e=>{if(!e.ok)throw Error(`Failed to fetch widgets: ${e.status} ${e.statusText}`);return e.json()}).then(e=>{let n=[],r=e.widgets;for(let[e,i]of Object.entries(r))n.push({name:e,component:e=>t(m1,{url:i.url,code:e.code})});return n}).catch(()=>(console.error(`Failed to fetch skill widgets from `,e),null)))),a={};for(let e of i.flat())e&&(a[e.name]=e.component);return a}function g1({children:e}){let{client:n}=q(),[r,i]=G(p1);return H(()=>{h1(n).then(e=>{i({...p1,...e})})},[n]),t(Dt,{components:r,children:e})}Q();const _1=new Map,v1=[400,1200];async function y1(e,t,n){for(let r=0;;r++)try{return await e.agents.sendSignal(t,`FileBatchClosed`,n),!0}catch(e){if(r>=v1.length)return console.error(`Failed to close staged file batch:`,e),!1;await new Promise(e=>setTimeout(e,v1[r]))}}function b1(e){if(typeof e==`number`)return e;if(!e)return Date.now();let t=new Date(e).getTime();return Number.isFinite(t)?t:Date.now()}function x1(e){return e===`running`||e===`canceling`}function S1(e){return!x1(e)}function C1(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function w1(e){for(let t=e.length-1;t>=0;t--){let n=e[t].details;if(!n)continue;let r=n.token_usage,i=C1(r?.prompt),a=i&&i>0?i:C1(r?.total),o=C1(n.checkpoint_threshold)??C1(n.checkpoint_at);if(typeof a!=`number`||typeof o!=`number`||o<=0)continue;let s=Math.max(0,Math.min(100,Math.round(a/o*100)));return{usedTokens:a,checkpointTokens:o,usedPercent:s,remainingPercent:Math.max(0,100-s)}}}function T1(e,t){return!S1(e.status)||!x1(t.status)?{...e,...t}:{...e,interaction:e.interaction??t.interaction,elapsed_ms:Math.max(e.elapsed_ms,t.elapsed_ms),deadline_ms:Math.max(e.deadline_ms,t.deadline_ms),remaining_ms:0,phase:e.phase??t.phase,child_workflow_id:e.child_workflow_id??t.child_workflow_id,child_workflow_run_id:e.child_workflow_run_id??t.child_workflow_run_id}}function E1(e){let t=e.details,n=typeof t?.workstream_id==`string`&&t.workstream_id.trim()?t.workstream_id:eU(e);return n===`main`||n===`all`?null:{workstreamId:n,launchId:typeof t?.launch_id==`string`?t.launch_id:void 0,interaction:typeof t?.interaction==`string`?t.interaction:void 0,childWorkflowId:typeof t?.child_workflow_id==`string`?t.child_workflow_id:void 0,childWorkflowRunId:typeof t?.child_workflow_run_id==`string`?t.child_workflow_run_id:void 0}}function D1(e){if(e.type!==J.ERROR)return!1;let t=e.details;if(t?.event_class!==`activity`||t.workstream_event)return!1;let n=typeof e.workstream_id==`string`&&e.workstream_id.trim()?e.workstream_id.trim():typeof t.workstream_id==`string`?t.workstream_id.trim():``,r=n.toLowerCase();return!n||r===`main`||r===`all`?!1:!(t.tool||t.tool_status||t.tool_run_id||t.activity_group_id||t.tool_event)}function O1(e,t,n,r,i,a){if(r){let a=t.get(n);if(a?.startsWith(`message-derived:`)){let t=e.get(a);t&&(e.delete(a),e.set(r,{...t,launch_id:r,updated_at:Math.max(t.updated_at,i)}))}t.set(n,r)}let o=r??t.get(n)??`message-derived:${n}`,s=e.get(o);if(s)return s;let c={workstream_id:n,launch_id:o,elapsed_ms:0,deadline_ms:0,remaining_ms:0,status:`running`,started_at:i,updated_at:i,order:a};return e.set(o,c),t.has(n)||t.set(n,o),c}function k1(e){let t=new Map,n=new Map;return e.forEach((e,r)=>{let i=b1(e.timestamp),a=E1(e),o=UH(e),s=o?.workstreamId??a?.workstreamId;if(!s)return;let c=o?.launchId??a?.launchId,l=BH(e);if(!o&&!c&&l&&!n.has(s))return;let u=O1(t,n,s,c,i,r);o?(u.interaction=o.interaction??u.interaction,u.child_workflow_id=o.childWorkflowId??u.child_workflow_id,u.child_workflow_run_id=o.childWorkflowRunId??u.child_workflow_run_id,u.status=`running`):(u.interaction=a?.interaction??u.interaction,u.child_workflow_id=a?.childWorkflowId??u.child_workflow_id,u.child_workflow_run_id=a?.childWorkflowRunId??u.child_workflow_run_id);let d=HH(e);d?u.status=d:l||(D1(e)?u.status=`failed`:(e.type===J.COMPLETE||e.type===J.IDLE)&&(u.status=`completed`)),!l&&(u.updated_at=Math.max(u.updated_at,i),x1(u.status)?u.elapsed_ms=Math.max(u.elapsed_ms,i-u.started_at):(u.elapsed_ms=Math.max(u.elapsed_ms,i-u.started_at),u.remaining_ms=0))}),Array.from(t.values()).sort((e,t)=>{let n=Number(!x1(e.status))-Number(!x1(t.status));return n===0?x1(e.status)?e.order-t.order:t.updated_at-e.updated_at||e.order-t.order:n}).map(({started_at:e,updated_at:t,order:n,...r})=>r)}function A1(e){return{workstream_id:e.workstream_id,launch_id:e.launch_id,interaction:e.interaction,elapsed_ms:e.elapsed_ms,deadline_ms:e.deadline_ms,remaining_ms:Math.max(0,e.deadline_ms-e.elapsed_ms),status:e.status,phase:e.latest_progress?.phase,child_workflow_id:e.child_workflow_id,child_workflow_run_id:e.child_workflow_run_id}}function j1(e){return{workstream_id:e.workstream_id,launch_id:e.launch_id,interaction:e.interaction,elapsed_ms:e.duration_ms??0,deadline_ms:0,remaining_ms:0,status:e.status,phase:e.last_progress?.phase,child_workflow_id:e.child_workflow_id,child_workflow_run_id:e.child_workflow_run_id}}function M1(e,t){let n=e.findIndex(e=>e.launch_id===t.launch_id);if(n>=0){e[n]=T1(e[n],t);return}let r=e.findIndex(e=>e.workstream_id===t.workstream_id&&e.launch_id.startsWith(`message-derived:`));if(r>=0&&!t.launch_id.startsWith(`message-derived:`)){e[r]=T1(e[r],t);return}e.push(t)}function N1(e){if(e<60)return`${e}s`;let t=Math.floor(e/60),n=e%60;return n>0?`${t}m ${n}s`:`${t}m`}function P1(e,t=!0){let[n,r]=G(()=>Math.max(0,Math.floor((Date.now()-b1(e))/1e3)));return H(()=>{if(!t)return;let n=()=>{r(Math.max(0,Math.floor((Date.now()-b1(e))/1e3)))};n();let i=window.setInterval(n,1e3);return()=>window.clearInterval(i)},[t,e]),n}function F1(e=!0){let[t,n]=G(0);return H(()=>{if(!e)return;let t=window.setInterval(()=>{n(()=>Math.floor(Math.random()*CW.length))},4e3);return()=>window.clearInterval(t)},[e]),t}function I1({message:e,startedAt:r}){let{t:i}=K(),a=P1(r),o=F1();return n(`div`,{className:`mx-auto flex min-h-full w-full max-w-3xl flex-col justify-end gap-6 px-1 py-8`,children:[t(`div`,{className:`flex w-full justify-end`,children:t(`div`,{className:z(`max-w-[min(44rem,82%)] rounded-[1.35rem] bg-mixer-muted/35 px-4 py-2.5`,`break-words text-sm font-normal leading-6 text-foreground/90 shadow-sm shadow-black/5`,`dark:bg-mixer-muted/15 dark:text-foreground/88 dark:shadow-none [overflow-wrap:anywhere]`),children:t(`div`,{className:`whitespace-pre-wrap`,children:e})})}),n(`div`,{className:`border-b border-border/70 pb-4 text-sm text-muted`,children:[n(`div`,{className:`flex items-center gap-3`,children:[t(aW,{size:`sm`,color:`blue`}),n(`div`,{className:`min-w-0`,children:[n(`div`,{children:[t(`span`,{className:`font-medium`,children:i(`agent.preparing`)}),n(`span`,{className:`ms-2 text-muted/75`,children:[`for `,N1(a)]})]}),t(`div`,{className:`mt-1 truncate text-muted/80`,children:CW[o]})]})]}),t(`div`,{className:`mt-3 ps-6`,children:t(iW,{color:`blue`})})]})]})}function L1(e,t){if(typeof window>`u`||typeof document>`u`)return!1;let n=document.createElement(`iframe`);n.style.position=`fixed`,n.style.right=`0`,n.style.bottom=`0`,n.style.width=`0`,n.style.height=`0`,n.style.border=`0`,n.style.visibility=`hidden`,document.body.appendChild(n);let r=n.contentWindow;if(!r)return n.parentNode?.removeChild(n),!1;let i=r.document;return i.open(),i.write(`<!doctype html><html><head><title></title></head><body></body></html>`),i.close(),i.title=t,document.querySelectorAll(`link[rel="stylesheet"], style`).forEach(e=>{i.head.appendChild(e.cloneNode(!0))}),i.body.innerHTML=e.innerHTML,r.focus(),r.print(),setTimeout(()=>{n.parentNode?.removeChild(n)},1e3),!0}function R1(e){let t=0,n=e.length;for(;t<n&&e[t]===`-`;)t++;for(;n>t&&e[n-1]===`-`;)n--;return e.slice(t,n)}function z1(e){return R1(e.trim().replace(/[^a-z0-9-_]+/gi,`-`)).slice(0,80)}function B1(e,t){let n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}function V1(e){let{agentRunId:n,startWorkflow:r,resourceResolver:i}=e;if(n){let r=t(g1,{children:t(W1,{...e,agentRunId:n})});return i?t(Ct,{value:i,children:r}):r}return r?t(U1,{...e}):t(H1,{})}function H1(){let{t:e}=K();return n(oe,{status:`info`,icon:t(Am,{className:`size-16 text-muted mb-4`}),children:[t(`div`,{className:`text-base font-medium text-muted`,children:e(`agent.noAgentRunning`)}),t(`div`,{className:`mt-3 text-sm text-muted`,children:e(`agent.selectInteraction`)})]})}function U1({initialMessage:e,interactive:r=!0,startWorkflow:i,onClose:a,isModal:s=!1,fullWidth:c=!1,placeholder:l,startButtonText:u,title:d,getAttachedDocs:f,onAttachmentsSent:p,acceptedFileTypes:m,maxFiles:h=5,hideHeader:g=!1,hideFileUpload:_=!1,hideObjectLinking:v,headerVariant:y,startViewVariant:b=`default`,inputContainerClassName:x,inputClassName:S,className:C,allowWorkflowControl:w,initialToolApprovalMode:T,onAgentWorkingChange:E}){let{t:D}=K(),O=b!=="default",k=b===`expanded-composer`,A=!_,j=l??D(`agent.typeYourMessage`),M=u??D(`agent.startAgent`),N=d??D(`agent.startNewConversation`),{client:P}=q(),[F,I]=G(``),[L,ee]=G(!1),[R,te]=G(null),[ne,re]=G(null),[ie,ae]=G(null),[oe,se]=G(()=>kn(T,r)),ce=nt(),le=W(null),ue=W(null),[de,fe]=G([]),[pe,me]=G(!1),he=pe?de:de.slice(0,3),ge=de.length-3;H(()=>{E?.(L)},[L,E]);let[_e,ve]=G(!1),ye=W(0),be=V(e=>{A&&(e.preventDefault(),e.stopPropagation(),ye.current++,e.dataTransfer?.types?.includes(`Files`)&&ve(!0))},[A]),xe=V(e=>{A&&(e.preventDefault(),e.stopPropagation())},[A]),Se=V(e=>{A&&(e.preventDefault(),e.stopPropagation(),ye.current--,ye.current===0&&ve(!1))},[A]),Ce=V(e=>{if(A&&(e.preventDefault(),e.stopPropagation(),ye.current=0,ve(!1),e.dataTransfer?.files&&e.dataTransfer.files.length>0)){let t=Array.from(e.dataTransfer.files);fe(e=>[...e,...t].slice(0,h))}},[h,A]),we=V(e=>{if(!A)return;let t=kX(e.clipboardData?.items);t.length>0&&fe(e=>[...e,...t].slice(0,h))},[A,h]),Te=V(e=>{if(e.target.files&&e.target.files.length>0){let t=Array.from(e.target.files);fe(e=>[...e,...t].slice(0,h))}e.target.value=``},[h]),Ee=V(e=>{fe(t=>t.filter((t,n)=>n!==e))},[]);H(()=>{de.length<=3&&me(!1)},[de.length]),H(()=>{le.current&&le.current.focus()},[]);let De=async()=>{if(!i)return;let e=F.trim();if(!(!e||L)){ee(!0);try{sessionStorage.removeItem(`plan-panel-shown`),ce({title:A&&de.length>0?D(`agent.startingAgentUploading`):D(`agent.startingAgent`),status:`info`,duration:3e3});let t=f?.()||[],n=e;if(t.length>0&&!/store:\S+/.test(e)&&(n=[e,``,`Attachments:`,...t.map(e=>`[${e.name}](/store/objects/${e.id})`)].join(`
1378
1378
  `)),A&&de.length>0){let e=de.map(e=>e.name).join(`, `);n=[n,``,`[System: ${de.length} file(s) are being uploaded: ${e}. Please wait for the "Files Ready" notification before processing them.]`].join(`
1379
- `)}let r=await i(n,{tool_approval_mode:oe});if(!r){re(null),ae(null);return}re(n),ae(Date.now());let a=r.agent_run_id,o=!0;if(A&&de.length>0){let e=`batch-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,t=[],n=[];for(let e of de)try{let n=`files/${e.name}`;await P.agents.uploadArtifact(a,n,e);let r=`file-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;await P.agents.sendSignal(a,`FileUploaded`,{id:r,name:e.name,content_type:e.type||`application/octet-stream`,reference:`artifact:${n}`,artifact_path:n}),t.push(r)}catch(t){console.error(`Failed to upload staged file ${e.name}:`,t),n.push({name:e.name,error:t instanceof Error?t.message:String(t)})}o=await v1(P,a,{batch_id:e,file_ids:t,failed_uploads:n.length>0?n:void 0}),o&&fe([]),n.length>0&&ce({title:D(`agent.stagedFilesUploadFailed`),status:`warning`,duration:6e3,description:n.map(e=>e.name).join(`, `)})}p?.(),te(a),I(``),ce(o?{title:D(`agent.agentStarted`),status:`success`,duration:3e3}:{title:D(`agent.stagedFilesNotDelivered`),status:`error`,duration:8e3,description:D(`agent.stagedFilesNotDeliveredDescription`)})}catch(e){re(null),ae(null),ce({title:D(`agent.errorStarting`),status:`error`,duration:3e3,description:e instanceof Error?e.message:D(`agent.unknownError`)})}finally{ee(!1)}}},Oe=e=>{if(e.key===`Enter`){if(!(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)){e.preventDefault(),De();return}e.shiftKey||(e.preventDefault(),Ke(e.currentTarget,I))}},ke=V(()=>{let e=le.current;if(e){if(k){e.style.height=`100%`;return}e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`}},[k]);return H(()=>{ke()},[F,ke]),R?t(U1,{onClose:a,isModal:s,initialMessage:e,placeholder:l,fullWidth:c,hideHeader:g,headerVariant:y,hideFileUpload:_,hideObjectLinking:v,inputContainerClassName:x,inputClassName:S,className:C,allowWorkflowControl:w,onAgentWorkingChange:E,agentRunId:R,title:d,pendingStartMessage:ne??void 0,pendingStartTimestamp:ie??void 0,initialToolApprovalMode:oe}):t(`div`,{className:z(`flex flex-col items-center bg-background`,O&&!k?``:`h-full`,C),children:n(`div`,{className:z(`relative flex w-full flex-col overflow-hidden border-0`,O&&!k?``:`h-full`,c?``:`max-w-4xl`),onDragEnter:A?be:void 0,onDragOver:A?xe:void 0,onDragLeave:A?Se:void 0,onDrop:A?Ce:void 0,children:[A&&_e&&t(`div`,{className:`absolute inset-0 flex items-center justify-center bg-info-background z-50 pointer-events-none rounded-lg`,children:n(`div`,{className:`text-info font-medium flex items-center gap-2 text-lg`,children:[t(wb,{className:`size-6`}),`Drop files to stage for upload`]})}),A&&t(`input`,{ref:ue,type:`file`,multiple:!0,accept:m,onChange:Te,className:`hidden`}),!g&&n(`div`,{className:`flex items-center justify-between border-b border-border/60 bg-background px-3 py-2`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(`div`,{className:`p-1`,children:t(hg,{className:`size-3.5 text-muted`})}),t(`span`,{className:`text-sm font-medium text-foreground`,children:N})]}),a&&!s&&t(o,{size:`xs`,variant:`ghost`,onClick:a,title:D(`agent.close`),className:`text-muted hover:text-foreground`,children:t(Gb,{className:`size-4`})})]}),t(`div`,{className:z(`flex flex-col items-center justify-end bg-background px-4`,O?`shrink-0 pt-3`:`flex-1 overflow-y-auto`),children:ne&&ie?t(F1,{message:ne,startedAt:ie}):t(`div`,{className:z(`mx-auto flex w-full max-w-3xl flex-col justify-end`,O?``:`min-h-full py-8`),children:e&&t(`div`,{className:`text-[15px] leading-relaxed text-foreground/80`,children:e})})}),t(`div`,{className:z(`bg-background px-4 pb-safe-area-4 pt-2`,k?`flex min-h-0 flex-1 flex-col`:`shrink-0`),children:n(`div`,{className:z(`mx-auto flex max-w-3xl flex-col gap-3 rounded-2xl border border-border/70 bg-mixer-muted/15 p-3 shadow-lg shadow-black/5`,k&&`min-h-0 w-full flex-1`,x),children:[A&&de.length>0&&n(`div`,{className:`flex flex-wrap gap-2`,children:[he.map((e,r)=>n(`div`,{className:`flex items-center gap-1.5 rounded-md bg-attention/10 px-2 py-1 text-sm text-attention`,title:D(`agent.fileStagedTooltip`),children:[t(Gg,{className:`size-3.5`}),t(`span`,{className:`max-w-[120px] truncate`,children:e.name}),t(`span`,{className:`text-xs opacity-70`,children:D(`agent.staged`)}),t(o,{variant:`unstyled`,"aria-label":`Remove staged file ${e.name}`,onClick:()=>Ee(r),className:`ms-1 rounded p-0.5 hover:bg-attention/20`,children:t(Gb,{className:`size-3`})})]},`${e.name}-${e.size}-${e.lastModified}`)),de.length>3&&n(o,{type:`button`,variant:`ghost`,size:`sm`,"aria-expanded":pe,onClick:()=>me(e=>!e),className:`h-8 shrink-0 gap-1 rounded-xl px-2.5 text-xs text-muted`,children:[!pe&&n(`span`,{children:[`+`,ge]}),D(pe?`agent.showLess`:`agent.showMore`),t(rh,{className:z(`size-3.5 transition-transform`,pe&&`rotate-180`),"aria-hidden":`true`})]})]}),t(Ue,{ref:le,value:F,onChange:e=>I(e.target.value),onKeyDown:Oe,onPaste:we,placeholder:j,disabled:L,rows:2,className:z(`min-h-[72px] resize-none border-0 bg-transparent px-0 py-0 text-sm leading-6 shadow-none focus-visible:ring-0`,k?`min-h-0 flex-1 overflow-y-auto`:`overflow-hidden`,S),style:k?{minHeight:`72px`,maxHeight:`none`}:{minHeight:`72px`,maxHeight:`200px`}}),n(`div`,{className:`flex items-center justify-between gap-3`,children:[n(`div`,{className:`flex min-w-0 items-center gap-2`,children:[A&&t(o,{variant:`ghost`,size:`icon`,onClick:()=>ue.current?.click(),disabled:L||de.length>=h,"aria-label":D(`agent.upload`),className:`rounded-full text-muted`,title:D(`agent.upload`),children:t(wb,{className:`size-4`})}),r&&t(Yb,{mode:oe,onChange:se,disabled:L})]}),t(o,{onClick:De,disabled:!F.trim()||L,variant:`ghost`,size:`icon`,className:z(`size-9 rounded-full border border-border/60 bg-foreground text-background shadow-sm`,`hover:bg-foreground/90 hover:text-background`,`disabled:bg-mixer-muted/25 disabled:text-muted disabled:opacity-100`),title:M,children:L?t(je,{size:`sm`}):t(Dm,{className:`size-4`})})]})]})})]})})}function U1({agentRunId:r,title:i,interactive:a=!0,onClose:s,isModal:c=!1,fullWidth:l=!1,placeholder:u,resetWorkflow:d,onRestart:f,onClone:p,onShowDetails:m,allowWorkflowControl:h=!0,uploadedFiles:g,onRemoveFile:_,acceptedFileTypes:v,maxFiles:y,renderDocumentSearch:b,selectedDocuments:x,onRemoveDocument:S,hideObjectLinking:C,hideHeader:w,headerVariant:T=`full`,hideMessageInput:E,failedAction:D,hidePlanPanel:O,hideWorkstreamTabs:k,showRightPanel:A=!0,hideFileUpload:j,showArtifacts:M=!1,hideDocumentPanel:N,hiddenMessageTypes:P,getAttachedDocs:F,onAttachmentsSent:I,isUploading:L=!1,getMessageContext:ee,className:R,inputContainerClassName:te,inputClassName:ne,composerContext:re,fusionData:ie,fileUploadRef:ae,sendMessageRef:de,onMessage:fe,onAgentWorkingChange:pe,onProcessingFilesChange:me,processingFiles:he,onPlansChange:ge,onWorkstreamStatusChange:_e,viewMode:ve,onViewModeChange:ye,onShowInputChange:be,stopRef:xe,onStoppingChange:Se,messageItemClassNames:Ce,messageStyleOverrides:we,toolCallGroupClassNames:Te,hideToolCallsInViewMode:Ee,streamingMessageClassNames:De,batchProgressPanelClassNames:Oe,workingIndicatorClassName:ke,messageListClassName:Ae,StoreLinkComponent:je,CollectionLinkComponent:Me,prependFriendlyMessage:Ne,initialRequestData:Pe,initialRequestSchema:Fe,initialRequestTitle:Ie,initialRequestTemplate:Le,payloadContent:Re,conversationContent:ze,conversationTab:Be=!1,pendingStartMessage:Ve,pendingStartTimestamp:He,initialToolApprovalMode:Ue,enablePlayback:We,showPlaybackToggle:Ge=!0,messageFilter:Ke,initialWorkstream:qe}){let{t:Je}=K(),{client:Ye}=q(),Xe=nt(),{messages:Ze,streamingMessages:Qe,isCompleted:$e,initialHistoryStatus:et,debugChunkFlash:tt,addOptimisticMessage:rt,updateOptimisticMessageStatus:it,reconnect:at,agentRunStatus:B,workflowRunId:ot,serverFileUpdates:st}=BX(Ye,r,fe),{plans:ct,activePlanIndex:lt,setActivePlanIndex:ut,workstreamStatusMap:dt,showInput:ft,showSlidingPanel:pt,setShowSlidingPanel:mt}=kX(Ze,a,c),{openDocuments:ht,activeDocumentId:gt,isDocPanelOpen:_t,docRefreshKey:vt,closeDocPanel:yt,selectDocument:bt,openDocInPanel:xt,updateDocumentTitle:St}=WX(Ze),{processingFiles:Ct,hasProcessingFiles:wt,handleFileUpload:Tt,removeProcessingFile:Et,clearProcessingFiles:Dt}=JX(Ye,r,st,Xe,U(()=>KW(Ze),[Ze])),Ot=a&&!j,kt=V(e=>{Et(e)},[Et]),At=W(null),jt=W(null),Mt=W(null),[Nt,Pt]=G(!1),[Ft,It]=G(!1),[Lt,Rt]=G(`sliding`),zt=ve??Lt,Bt=V(e=>{ye?ye(e):Rt(e)},[ye]),[Vt,Ht]=G(!1),[Wt,Gt]=G(!1),[Kt,qt]=G(qe||`all`),Jt=W(qe);H(()=>{qe&&qe!==Jt.current&&(Jt.current=qe,qt(qe))},[qe]);let[Yt,Xt]=G(`live`),[Zt,Qt]=G(!1),[$t,en]=G(0),[tn,nn]=G([]),[rn,an]=G([]),[on,sn]=G(!1),cn=U(()=>Ue===void 0&&a?void 0:kn(Ue,a),[Ue,a]),[ln,un]=G(cn),dn=W(!1),fn=W(0),mn=W(!1),hn=W(0),gn=W(null);H(()=>{un(cn)},[cn]);let _n=W(Nt);_n.current=Nt;let vn=W(wt);vn.current=wt;let yn=W(Ct);yn.current=Ct;let bn=U(()=>{let e=Ze.filter(e=>(e.workstream_id||`main`)===`main`);return e[e.length-1]},[Ze]),xn=U(()=>bn?.type===J.TERMINATED?`TERMINATED`:bn?.type===J.COMPLETE&&(!B||B===`RUNNING`)?`COMPLETED`:B,[bn,B]),Sn=U(()=>{let e=xn?.toUpperCase();return e===`COMPLETED`||e===`FAILED`||e===`CANCELED`||e===`CANCELLED`||e===`TERMINATED`||e===`TIMED_OUT`},[xn]),Cn=U(()=>Sn&&xn?.toUpperCase()!==`FAILED`&&!!f,[Sn,xn,f]),wn=!E||Cn,Tn=U(()=>xn?.toUpperCase()===`FAILED`||B?.toUpperCase()===`FAILED`,[xn,B]),En=U(()=>{for(let e=Ze.length-1;e>=0;e--){let t=Ze[e];if(t.type!==J.ERROR||$H(t)!==`main`)continue;let n=typeof t.message==`string`?t.message.trim():``;if(n)return n}},[Ze]),Dn=W(Sn);Dn.current=Sn;let On=W(Cn);On.current=Cn;let An=U(()=>{let e=ct[lt]||{plan:{plan:[]},timestamp:0},t=dt.get(e.timestamp)||new Map;return{plan:e.plan,workstreamStatus:t}},[ct,lt,dt]),jn=U(()=>O1(Ze),[Ze]),Mn=U(()=>{let e=[...jn];for(let t of rn)j1(e,A1(t));for(let t of tn)j1(e,k1(t));return e.map((e,t)=>({workstream:e,index:t})).sort((e,t)=>Number(!b1(e.workstream.status))-Number(!b1(t.workstream.status))||e.index-t.index).map(({workstream:e})=>e)},[jn,tn,rn]),Nn=U(()=>Mn.filter(e=>b1(e.status)),[Mn]),Pn=U(()=>Nn.filter(e=>e.status===`running`).length,[Nn]),Fn=U(()=>{if(Kt===`all`)return;let e=Mn.find(e=>e.workstream_id===Kt||e.launch_id===Kt);return e?PH(e.workstream_id,e.interaction):PH(Kt)},[Kt,Mn]),In=U(()=>{if(u)return u;if(Fn)return Je(`agent.messageMainAgentWhileViewingWorkstream`,{workstream:Fn})},[Fn,u,Je]),Ln=Ge&&We===void 0&&_C(),Rn=We??(vC()||Zt),zn=U(()=>Ze.filter(e=>!YH(e)&&!(P?.includes(e.type)??!1)),[P,Ze]),Bn=U(()=>nU(zn,Kt),[Kt,zn]),Vn=U(()=>hC(Bn,Yt,Rn),[Rn,Yt,Bn]),Hn=Vn.cursor,Un=Vn.isLive,Wn=Rn&&!Un&&Vn.cursorIndex===Bn.length-1,Gn=Vn.displayedMessages,Kn=U(()=>Ke?Gn.filter(e=>Ke(e)):Gn,[Gn,Ke]),qn=U(()=>Ke?zn.filter(e=>Ke(e)):zn,[Ke,zn]),Jn=Un?Qe:g1,Xn=U(()=>O1(Gn),[Gn]),Zn=U(()=>Xn.filter(e=>b1(e.status)),[Xn]),Qn=U(()=>$e||!XH(Ze),[$e,Ze]),$n=Un||Wn?Qn:!1,er=!Qn&&!Sn;H(()=>{pe?.(er)},[er,pe]);let tr=U(()=>{let e=new Set;for(let t of Gn)MU(r,t)&&e.add(OU(t));return eW(Gn,`main`,e)},[r,Gn]),nr=!!tr&&!Tn&&(!Sn||Cn),rr=Rn&&!Un,ir=wn&&!rr,ar=U(()=>C1(Ze),[Ze]),or=h&&!Sn&&Un&&!!ar;H(()=>{KH(`conversation render state`,{agentRunId:r,messageCount:Ze.length,playbackMessageCount:Bn.length,displayedMessageCount:Kn.length,streamingCount:Qe.size,displayedStreamingCount:Jn.size,initialHistoryStatus:et,isCompleted:$e,effectiveIsCompleted:Qn,displayedIsCompleted:$n,agentRunStatus:B,effectiveWorkflowStatus:xn,isWorkflowTerminal:Sn,playbackCursor:Hn,isPlaybackEnabled:Rn,isPlaybackLive:Un,isPlaybackAtLatest:Wn,activeWorkstream:Kt,showInitialRequest:et===`empty`&&Ze.length===0,pendingStartVisible:Ze.length===0&&!Qn&&!!Ve})},[Kt,r,B,Hn,$n,Kn.length,Jn.size,Qn,xn,et,$e,Wn,Rn,Un,Sn,Ze.length,Ve,Bn.length,Qe.size]);let sr=V(()=>{Qt(e=>!e)},[]),cr=V(e=>{let t=fC(Hn,Bn.length),n=fC(e,Bn.length);Rn&&(n>t||e===`live`&&Hn!==`live`)&&(mn.current=!0,en(e=>e+1)),Xt(e)},[Hn,Rn,Bn.length]);H(()=>{if(!Rn){Yt!==`live`&&Xt(`live`);return}Hn!==Yt&&Xt(Hn)},[Hn,Rn,Yt]),H(()=>{if(!Rn||!mn.current)return;mn.current=!1;let e=window.requestAnimationFrame(()=>{At.current?.scrollIntoView({behavior:`smooth`,block:`end`})});return()=>window.cancelAnimationFrame(e)},[Rn,$t]);let lr=V(e=>{ut(e)},[ut]),[ur,dr]=G(ze||Be?`conversation`:`plan`),[fr,Y]=G(null),[pr,mr]=G(400),[hr,gr]=G(!1),[_r,vr]=G(!1),yr=A&&!_r&&(pt||_t||!k&&Mn.length>0||!!ze||Be),br=W(_t);H(()=>{_t&&!br.current&&vr(!1),br.current=_t},[_t]);let xr=V(()=>{yr?(vr(!0),mt(!1)):(vr(!1),mt(!0),sessionStorage.setItem(`plan-panel-shown`,`true`))},[yr,mt]);H(()=>{!yr&&hr&&gr(!1)},[yr,hr]),H(()=>{if(!hr)return;let e=e=>{let t=Mt.current;if(!t)return;let n=t.getBoundingClientRect(),r=Math.max(300,n.width-420),i=n.right-e.clientX;mr(Math.min(Math.max(i,300),r))},t=()=>{gr(!1)};return window.addEventListener(`mousemove`,e),window.addEventListener(`mouseup`,t),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,()=>{window.removeEventListener(`mousemove`,e),window.removeEventListener(`mouseup`,t),document.body.style.cursor=``,document.body.style.userSelect=``}},[hr]);let Sr=V(()=>{vr(!0),mt(!1),yt()},[mt,yt]),Cr=V(e=>{/\.md$/i.test(e)&&(vr(!1),Y(e),dr(`artifacts`),mt(!0))},[mt]),wr=W(null);H(()=>{let e,t;for(let n of Ze){let r=n.details;r?.event_class===`display_artifact`&&typeof r.path==`string`&&(e=r.path,t=`${n.timestamp??``}:${r.path}`)}!e||!t||t===wr.current||(wr.current=t,vr(!1),Y(e),dr(`artifacts`),mt(!0))},[Ze,mt]);let Tr=V(({href:e,documentId:n,children:r})=>t(`a`,{href:e,className:`text-info underline cursor-pointer hover:text-info/80`,onClick:e=>{e.preventDefault(),e.stopPropagation(),xt(n),dr(`documents`)},children:r}),[xt]),Er=je??Tr;H(()=>(ae&&(ae.current=Ot?Tt:null),()=>{ae&&(ae.current=null)}),[ae,Tt,Ot]),H(()=>{me?.(Ct)},[Ct,me]),H(()=>{ge?.(ct,lt)},[ct,lt,ge]),H(()=>{_e?.(dt)},[dt,_e]),H(()=>{Y(null),dn.current=!1,sn(!1),nn([]),an([])},[r]),H(()=>{let e=et!==`loading`&&!Qn&&!Sn&&!on;if(KH(`active workstreams poll state`,{agentRunId:r,shouldPoll:e,initialHistoryStatus:et,effectiveIsCompleted:Qn,isWorkflowTerminal:Sn,isWorkstreamQueryUnavailable:on}),!e){nn(e=>e.length===0?e:[]);return}let t=!1,n=!1,i=async()=>{if(n){KH(`active workstreams fetch skipped while previous request is pending`,{agentRunId:r});return}n=!0;try{KH(`active workstreams fetch start`,{agentRunId:r});let e=await Ye.agents.getActiveWorkstreams(r);if(t)return;if(KH(`active workstreams fetch success`,{agentRunId:r,runningCount:e.running?.length??0,completedCount:e.completed?.length??0,unavailable:e.unavailable===!0}),nn(e.running??[]),an(e.completed??[]),e.unavailable){sn(!0);return}dn.current=!1}catch(e){if(t)return;nn(e=>e.length===0?e:[]),sn(!0),KH(`active workstreams fetch failed`,{agentRunId:r,error:e instanceof Error?e.message:String(e)}),dn.current||=(console.warn(`Failed to fetch active workstreams:`,e),!0)}finally{n=!1}};i();let a=window.setInterval(i,1e4);return()=>{t=!0,window.clearInterval(a)}},[Ye.agents,r,Qn,et,Sn,on]),H(()=>{if(Ze.length!==0){if(Cn){be?.(!0);return}if(!ft){be?.(!1);return}if(xn&&xn!==`RUNNING`){be?.(!1);return}xn!==null&&be?.(!0)}},[ft,xn,Ze.length,be,Cn]);let Dr=V(async()=>{let e=gn.current;e&&await e},[]),Or=V((e,t)=>{let n=e.trim();if(!n||_n.current||Dn.current&&!On.current)return;if(vn.current){Xe({status:`warning`,title:Je(`agent.filesProcessing`),description:Je(`agent.waitForFilesProcessing`),duration:3e3});return}let i=RU(t);Pt(!0);let a=F?.()||[],o=ee?.()||{},s=n;a.length>0&&!/store:\S+/.test(n)&&(s=[n,``,`Attachments:`,...a.map(e=>`[${e.name}](/store/objects/${e.id})`)].join(`
1379
+ `)}let r=await i(n,{tool_approval_mode:oe});if(!r){re(null),ae(null);return}re(n),ae(Date.now());let a=r.agent_run_id,o=!0;if(A&&de.length>0){let e=`batch-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,t=[],n=[];for(let e of de)try{let n=`files/${e.name}`;await P.agents.uploadArtifact(a,n,e);let r=`file-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;await P.agents.sendSignal(a,`FileUploaded`,{id:r,name:e.name,content_type:e.type||`application/octet-stream`,reference:`artifact:${n}`,artifact_path:n}),t.push(r)}catch(t){console.error(`Failed to upload staged file ${e.name}:`,t),n.push({name:e.name,error:t instanceof Error?t.message:String(t)})}o=await y1(P,a,{batch_id:e,file_ids:t,failed_uploads:n.length>0?n:void 0}),o&&fe([]),n.length>0&&ce({title:D(`agent.stagedFilesUploadFailed`),status:`warning`,duration:6e3,description:n.map(e=>e.name).join(`, `)})}p?.(),te(a),I(``),ce(o?{title:D(`agent.agentStarted`),status:`success`,duration:3e3}:{title:D(`agent.stagedFilesNotDelivered`),status:`error`,duration:8e3,description:D(`agent.stagedFilesNotDeliveredDescription`)})}catch(e){re(null),ae(null),ce({title:D(`agent.errorStarting`),status:`error`,duration:3e3,description:e instanceof Error?e.message:D(`agent.unknownError`)})}finally{ee(!1)}}},Oe=e=>{if(e.key===`Enter`){if(!(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)){e.preventDefault(),De();return}e.shiftKey||(e.preventDefault(),Ke(e.currentTarget,I))}},ke=V(()=>{let e=le.current;if(e){if(k){e.style.height=`100%`;return}e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`}},[k]);return H(()=>{ke()},[F,ke]),R?t(W1,{onClose:a,isModal:s,initialMessage:e,placeholder:l,fullWidth:c,hideHeader:g,headerVariant:y,hideFileUpload:_,hideObjectLinking:v,inputContainerClassName:x,inputClassName:S,className:C,allowWorkflowControl:w,onAgentWorkingChange:E,agentRunId:R,title:d,pendingStartMessage:ne??void 0,pendingStartTimestamp:ie??void 0,initialToolApprovalMode:oe}):t(`div`,{className:z(`flex flex-col items-center bg-background`,O&&!k?``:`h-full`,C),children:n(`div`,{className:z(`relative flex w-full flex-col overflow-hidden border-0`,O&&!k?``:`h-full`,c?``:`max-w-4xl`),onDragEnter:A?be:void 0,onDragOver:A?xe:void 0,onDragLeave:A?Se:void 0,onDrop:A?Ce:void 0,children:[A&&_e&&t(`div`,{className:`absolute inset-0 flex items-center justify-center bg-info-background z-50 pointer-events-none rounded-lg`,children:n(`div`,{className:`text-info font-medium flex items-center gap-2 text-lg`,children:[t(wb,{className:`size-6`}),`Drop files to stage for upload`]})}),A&&t(`input`,{ref:ue,type:`file`,multiple:!0,accept:m,onChange:Te,className:`hidden`}),!g&&n(`div`,{className:`flex items-center justify-between border-b border-border/60 bg-background px-3 py-2`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(`div`,{className:`p-1`,children:t(hg,{className:`size-3.5 text-muted`})}),t(`span`,{className:`text-sm font-medium text-foreground`,children:N})]}),a&&!s&&t(o,{size:`xs`,variant:`ghost`,onClick:a,title:D(`agent.close`),className:`text-muted hover:text-foreground`,children:t(Gb,{className:`size-4`})})]}),t(`div`,{className:z(`flex flex-col items-center justify-end bg-background px-4`,O?`shrink-0 pt-3`:`flex-1 overflow-y-auto`),children:ne&&ie?t(I1,{message:ne,startedAt:ie}):t(`div`,{className:z(`mx-auto flex w-full max-w-3xl flex-col justify-end`,O?``:`min-h-full py-8`),children:e&&t(`div`,{className:`text-[15px] leading-relaxed text-foreground/80`,children:e})})}),t(`div`,{className:z(`bg-background px-4 pb-safe-area-4 pt-2`,k?`flex min-h-0 flex-1 flex-col`:`shrink-0`),children:n(`div`,{className:z(`mx-auto flex max-w-3xl flex-col gap-3 rounded-2xl border border-border/70 bg-mixer-muted/15 p-3 shadow-lg shadow-black/5`,k&&`min-h-0 w-full flex-1`,x),children:[A&&de.length>0&&n(`div`,{className:`flex flex-wrap gap-2`,children:[he.map((e,r)=>n(`div`,{className:`flex items-center gap-1.5 rounded-md bg-attention/10 px-2 py-1 text-sm text-attention`,title:D(`agent.fileStagedTooltip`),children:[t(Gg,{className:`size-3.5`}),t(`span`,{className:`max-w-[120px] truncate`,children:e.name}),t(`span`,{className:`text-xs opacity-70`,children:D(`agent.staged`)}),t(o,{variant:`unstyled`,"aria-label":`Remove staged file ${e.name}`,onClick:()=>Ee(r),className:`ms-1 rounded p-0.5 hover:bg-attention/20`,children:t(Gb,{className:`size-3`})})]},`${e.name}-${e.size}-${e.lastModified}`)),de.length>3&&n(o,{type:`button`,variant:`ghost`,size:`sm`,"aria-expanded":pe,onClick:()=>me(e=>!e),className:`h-8 shrink-0 gap-1 rounded-xl px-2.5 text-xs text-muted`,children:[!pe&&n(`span`,{children:[`+`,ge]}),D(pe?`agent.showLess`:`agent.showMore`),t(rh,{className:z(`size-3.5 transition-transform`,pe&&`rotate-180`),"aria-hidden":`true`})]})]}),t(Ue,{ref:le,value:F,onChange:e=>I(e.target.value),onKeyDown:Oe,onPaste:we,placeholder:j,disabled:L,rows:2,className:z(`min-h-[72px] resize-none border-0 bg-transparent px-0 py-0 text-sm leading-6 shadow-none focus-visible:ring-0`,k?`min-h-0 flex-1 overflow-y-auto`:`overflow-hidden`,S),style:k?{minHeight:`72px`,maxHeight:`none`}:{minHeight:`72px`,maxHeight:`200px`}}),n(`div`,{className:`flex items-center justify-between gap-3`,children:[n(`div`,{className:`flex min-w-0 items-center gap-2`,children:[A&&t(o,{variant:`ghost`,size:`icon`,onClick:()=>ue.current?.click(),disabled:L||de.length>=h,"aria-label":D(`agent.upload`),className:`rounded-full text-muted`,title:D(`agent.upload`),children:t(wb,{className:`size-4`})}),r&&t(Yb,{mode:oe,onChange:se,disabled:L})]}),t(o,{onClick:De,disabled:!F.trim()||L,variant:`ghost`,size:`icon`,className:z(`size-9 rounded-full border border-border/60 bg-foreground text-background shadow-sm`,`hover:bg-foreground/90 hover:text-background`,`disabled:bg-mixer-muted/25 disabled:text-muted disabled:opacity-100`),title:M,children:L?t(je,{size:`sm`}):t(Dm,{className:`size-4`})})]})]})})]})})}function W1({agentRunId:r,title:i,interactive:a=!0,onClose:s,isModal:c=!1,fullWidth:l=!1,placeholder:u,resetWorkflow:d,onRestart:f,onClone:p,onShowDetails:m,allowWorkflowControl:h=!0,uploadedFiles:g,onRemoveFile:_,acceptedFileTypes:v,maxFiles:y,renderDocumentSearch:b,selectedDocuments:x,onRemoveDocument:S,hideObjectLinking:C,hideHeader:w,headerVariant:T=`full`,hideMessageInput:E,failedAction:D,hidePlanPanel:O,hideWorkstreamTabs:k,showRightPanel:A=!0,hideFileUpload:j,showArtifacts:M=!1,hideDocumentPanel:N,hiddenMessageTypes:P,getAttachedDocs:F,onAttachmentsSent:I,isUploading:L=!1,getMessageContext:ee,className:R,inputContainerClassName:te,inputClassName:ne,composerContext:re,fusionData:ie,fileUploadRef:ae,sendMessageRef:de,onMessage:fe,onAgentWorkingChange:pe,onProcessingFilesChange:me,processingFiles:he,onPlansChange:ge,onWorkstreamStatusChange:_e,viewMode:ve,onViewModeChange:ye,onShowInputChange:be,stopRef:xe,onStoppingChange:Se,messageItemClassNames:Ce,messageStyleOverrides:we,toolCallGroupClassNames:Te,hideToolCallsInViewMode:Ee,streamingMessageClassNames:De,batchProgressPanelClassNames:Oe,workingIndicatorClassName:ke,messageListClassName:Ae,StoreLinkComponent:je,CollectionLinkComponent:Me,prependFriendlyMessage:Ne,initialRequestData:Pe,initialRequestSchema:Fe,initialRequestTitle:Ie,initialRequestTemplate:Le,payloadContent:Re,conversationContent:ze,conversationTab:Be=!1,pendingStartMessage:Ve,pendingStartTimestamp:He,initialToolApprovalMode:Ue,enablePlayback:We,showPlaybackToggle:Ge=!0,messageFilter:Ke,initialWorkstream:qe}){let{t:Je}=K(),{client:Ye}=q(),Xe=nt(),{messages:Ze,streamingMessages:Qe,isCompleted:$e,initialHistoryStatus:et,debugChunkFlash:tt,addOptimisticMessage:rt,updateOptimisticMessageStatus:it,reconnect:at,agentRunStatus:B,workflowRunId:ot,serverFileUpdates:st}=VX(Ye,r,fe),{plans:ct,activePlanIndex:lt,setActivePlanIndex:ut,workstreamStatusMap:dt,showInput:ft,showSlidingPanel:pt,setShowSlidingPanel:mt}=AX(Ze,a,c),{openDocuments:ht,activeDocumentId:gt,isDocPanelOpen:_t,docRefreshKey:vt,closeDocPanel:yt,selectDocument:bt,openDocInPanel:xt,updateDocumentTitle:St}=GX(Ze),{processingFiles:Ct,hasProcessingFiles:wt,handleFileUpload:Tt,removeProcessingFile:Et,clearProcessingFiles:Dt}=YX(Ye,r,st,Xe,U(()=>qW(Ze),[Ze])),Ot=a&&!j,kt=V(e=>{Et(e)},[Et]),At=W(null),jt=W(null),Mt=W(null),[Nt,Pt]=G(!1),[Ft,It]=G(!1),[Lt,Rt]=G(`sliding`),zt=ve??Lt,Bt=V(e=>{ye?ye(e):Rt(e)},[ye]),[Vt,Ht]=G(!1),[Wt,Gt]=G(!1),[Kt,qt]=G(qe||`all`),Jt=W(qe);H(()=>{qe&&qe!==Jt.current&&(Jt.current=qe,qt(qe))},[qe]);let[Yt,Xt]=G(`live`),[Zt,Qt]=G(!1),[$t,en]=G(0),[tn,nn]=G([]),[rn,an]=G([]),[on,sn]=G(!1),cn=U(()=>Ue===void 0&&a?void 0:kn(Ue,a),[Ue,a]),[ln,un]=G(cn),dn=W(!1),fn=W(0),mn=W(!1),hn=W(0),gn=W(null);H(()=>{un(cn)},[cn]);let _n=W(Nt);_n.current=Nt;let vn=W(wt);vn.current=wt;let yn=W(Ct);yn.current=Ct;let bn=U(()=>{let e=Ze.filter(e=>(e.workstream_id||`main`)===`main`);return e[e.length-1]},[Ze]),xn=U(()=>bn?.type===J.TERMINATED?`TERMINATED`:bn?.type===J.COMPLETE&&(!B||B===`RUNNING`)?`COMPLETED`:B,[bn,B]),Sn=U(()=>{let e=xn?.toUpperCase();return e===`COMPLETED`||e===`FAILED`||e===`CANCELED`||e===`CANCELLED`||e===`TERMINATED`||e===`TIMED_OUT`},[xn]),Cn=U(()=>Sn&&xn?.toUpperCase()!==`FAILED`&&!!f,[Sn,xn,f]),wn=!E||Cn,Tn=U(()=>xn?.toUpperCase()===`FAILED`||B?.toUpperCase()===`FAILED`,[xn,B]),En=U(()=>{for(let e=Ze.length-1;e>=0;e--){let t=Ze[e];if(t.type!==J.ERROR||eU(t)!==`main`)continue;let n=typeof t.message==`string`?t.message.trim():``;if(n)return n}},[Ze]),Dn=W(Sn);Dn.current=Sn;let On=W(Cn);On.current=Cn;let An=U(()=>{let e=ct[lt]||{plan:{plan:[]},timestamp:0},t=dt.get(e.timestamp)||new Map;return{plan:e.plan,workstreamStatus:t}},[ct,lt,dt]),jn=U(()=>k1(Ze),[Ze]),Mn=U(()=>{let e=[...jn];for(let t of rn)M1(e,j1(t));for(let t of tn)M1(e,A1(t));return e.map((e,t)=>({workstream:e,index:t})).sort((e,t)=>Number(!x1(e.workstream.status))-Number(!x1(t.workstream.status))||e.index-t.index).map(({workstream:e})=>e)},[jn,tn,rn]),Nn=U(()=>Mn.filter(e=>x1(e.status)),[Mn]),Pn=U(()=>Nn.filter(e=>e.status===`running`).length,[Nn]),Fn=U(()=>{if(Kt===`all`)return;let e=Mn.find(e=>e.workstream_id===Kt||e.launch_id===Kt);return e?FH(e.workstream_id,e.interaction):FH(Kt)},[Kt,Mn]),In=U(()=>{if(u)return u;if(Fn)return Je(`agent.messageMainAgentWhileViewingWorkstream`,{workstream:Fn})},[Fn,u,Je]),Ln=Ge&&We===void 0&&_C(),Rn=We??(vC()||Zt),zn=U(()=>Ze.filter(e=>!XH(e)&&!(P?.includes(e.type)??!1)),[P,Ze]),Bn=U(()=>rU(zn,Kt),[Kt,zn]),Vn=U(()=>hC(Bn,Yt,Rn),[Rn,Yt,Bn]),Hn=Vn.cursor,Un=Vn.isLive,Wn=Rn&&!Un&&Vn.cursorIndex===Bn.length-1,Gn=Vn.displayedMessages,Kn=U(()=>Ke?Gn.filter(e=>Ke(e)):Gn,[Gn,Ke]),qn=U(()=>Ke?zn.filter(e=>Ke(e)):zn,[Ke,zn]),Jn=Un?Qe:_1,Xn=U(()=>k1(Gn),[Gn]),Zn=U(()=>Xn.filter(e=>x1(e.status)),[Xn]),Qn=U(()=>$e||!ZH(Ze),[$e,Ze]),$n=Un||Wn?Qn:!1,er=!Qn&&!Sn;H(()=>{pe?.(er)},[er,pe]);let tr=U(()=>{let e=new Set;for(let t of Gn)NU(r,t)&&e.add(kU(t));return tW(Gn,`main`,e)},[r,Gn]),nr=!!tr&&!Tn&&(!Sn||Cn),rr=Rn&&!Un,ir=wn&&!rr,ar=U(()=>w1(Ze),[Ze]),or=h&&!Sn&&Un&&!!ar;H(()=>{qH(`conversation render state`,{agentRunId:r,messageCount:Ze.length,playbackMessageCount:Bn.length,displayedMessageCount:Kn.length,streamingCount:Qe.size,displayedStreamingCount:Jn.size,initialHistoryStatus:et,isCompleted:$e,effectiveIsCompleted:Qn,displayedIsCompleted:$n,agentRunStatus:B,effectiveWorkflowStatus:xn,isWorkflowTerminal:Sn,playbackCursor:Hn,isPlaybackEnabled:Rn,isPlaybackLive:Un,isPlaybackAtLatest:Wn,activeWorkstream:Kt,showInitialRequest:et===`empty`&&Ze.length===0,pendingStartVisible:Ze.length===0&&!Qn&&!!Ve})},[Kt,r,B,Hn,$n,Kn.length,Jn.size,Qn,xn,et,$e,Wn,Rn,Un,Sn,Ze.length,Ve,Bn.length,Qe.size]);let sr=V(()=>{Qt(e=>!e)},[]),cr=V(e=>{let t=fC(Hn,Bn.length),n=fC(e,Bn.length);Rn&&(n>t||e===`live`&&Hn!==`live`)&&(mn.current=!0,en(e=>e+1)),Xt(e)},[Hn,Rn,Bn.length]);H(()=>{if(!Rn){Yt!==`live`&&Xt(`live`);return}Hn!==Yt&&Xt(Hn)},[Hn,Rn,Yt]),H(()=>{if(!Rn||!mn.current)return;mn.current=!1;let e=window.requestAnimationFrame(()=>{At.current?.scrollIntoView({behavior:`smooth`,block:`end`})});return()=>window.cancelAnimationFrame(e)},[Rn,$t]);let lr=V(e=>{ut(e)},[ut]),[ur,dr]=G(ze||Be?`conversation`:`plan`),[fr,Y]=G(null),[pr,mr]=G(400),[hr,gr]=G(!1),[_r,vr]=G(!1),yr=A&&!_r&&(pt||_t||!k&&Mn.length>0||!!ze||Be),br=W(_t);H(()=>{_t&&!br.current&&vr(!1),br.current=_t},[_t]);let xr=V(()=>{yr?(vr(!0),mt(!1)):(vr(!1),mt(!0),sessionStorage.setItem(`plan-panel-shown`,`true`))},[yr,mt]);H(()=>{!yr&&hr&&gr(!1)},[yr,hr]),H(()=>{if(!hr)return;let e=e=>{let t=Mt.current;if(!t)return;let n=t.getBoundingClientRect(),r=Math.max(300,n.width-420),i=n.right-e.clientX;mr(Math.min(Math.max(i,300),r))},t=()=>{gr(!1)};return window.addEventListener(`mousemove`,e),window.addEventListener(`mouseup`,t),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,()=>{window.removeEventListener(`mousemove`,e),window.removeEventListener(`mouseup`,t),document.body.style.cursor=``,document.body.style.userSelect=``}},[hr]);let Sr=V(()=>{vr(!0),mt(!1),yt()},[mt,yt]),Cr=V(e=>{/\.md$/i.test(e)&&(vr(!1),Y(e),dr(`artifacts`),mt(!0))},[mt]),wr=W(null);H(()=>{let e,t;for(let n of Ze){let r=n.details;r?.event_class===`display_artifact`&&typeof r.path==`string`&&(e=r.path,t=`${n.timestamp??``}:${r.path}`)}!e||!t||t===wr.current||(wr.current=t,vr(!1),Y(e),dr(`artifacts`),mt(!0))},[Ze,mt]);let Tr=V(({href:e,documentId:n,children:r})=>t(`a`,{href:e,className:`text-info underline cursor-pointer hover:text-info/80`,onClick:e=>{e.preventDefault(),e.stopPropagation(),xt(n),dr(`documents`)},children:r}),[xt]),Er=je??Tr;H(()=>(ae&&(ae.current=Ot?Tt:null),()=>{ae&&(ae.current=null)}),[ae,Tt,Ot]),H(()=>{me?.(Ct)},[Ct,me]),H(()=>{ge?.(ct,lt)},[ct,lt,ge]),H(()=>{_e?.(dt)},[dt,_e]),H(()=>{Y(null),dn.current=!1,sn(!1),nn([]),an([])},[r]),H(()=>{let e=et!==`loading`&&!Qn&&!Sn&&!on;if(qH(`active workstreams poll state`,{agentRunId:r,shouldPoll:e,initialHistoryStatus:et,effectiveIsCompleted:Qn,isWorkflowTerminal:Sn,isWorkstreamQueryUnavailable:on}),!e){nn(e=>e.length===0?e:[]);return}let t=!1,n=!1,i=async()=>{if(n){qH(`active workstreams fetch skipped while previous request is pending`,{agentRunId:r});return}n=!0;try{qH(`active workstreams fetch start`,{agentRunId:r});let e=await Ye.agents.getActiveWorkstreams(r);if(t)return;if(qH(`active workstreams fetch success`,{agentRunId:r,runningCount:e.running?.length??0,completedCount:e.completed?.length??0,unavailable:e.unavailable===!0}),nn(e.running??[]),an(e.completed??[]),e.unavailable){sn(!0);return}dn.current=!1}catch(e){if(t)return;nn(e=>e.length===0?e:[]),sn(!0),qH(`active workstreams fetch failed`,{agentRunId:r,error:e instanceof Error?e.message:String(e)}),dn.current||=(console.warn(`Failed to fetch active workstreams:`,e),!0)}finally{n=!1}};i();let a=window.setInterval(i,1e4);return()=>{t=!0,window.clearInterval(a)}},[Ye.agents,r,Qn,et,Sn,on]),H(()=>{if(Ze.length!==0){if(Cn){be?.(!0);return}if(!ft){be?.(!1);return}if(xn&&xn!==`RUNNING`){be?.(!1);return}xn!==null&&be?.(!0)}},[ft,xn,Ze.length,be,Cn]);let Dr=V(async()=>{let e=gn.current;e&&await e},[]),Or=V((e,t)=>{let n=e.trim();if(!n||_n.current||Dn.current&&!On.current)return;if(vn.current){Xe({status:`warning`,title:Je(`agent.filesProcessing`),description:Je(`agent.waitForFilesProcessing`),duration:3e3});return}let i=zU(t);Pt(!0);let a=F?.()||[],o=ee?.()||{},s=n;a.length>0&&!/store:\S+/.test(n)&&(s=[n,``,`Attachments:`,...a.map(e=>`[${e.name}](/store/objects/${e.id})`)].join(`
1380
1380
  `));let c=Array.from(yn.current.values()).filter(e=>e.status===pn.READY).map(e=>{let t=e.reference?.startsWith(`artifact:`)?e.reference:e.artifact_path?`artifact:${e.artifact_path}`:void 0;return t?`[${e.name}](${t})`:void 0}).filter(e=>!!e);c.length>0&&(s=[s,``,`Uploaded artifacts:`,...c].join(`
1381
- `));let l=`msg-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,u={timestamp:Date.now(),workflow_run_id:r,type:J.QUESTION,message:s,workstream_id:`main`,details:{_optimistic:!0,_messageId:l,_deliveryStatus:`sending`,...t?.editing_action?{editing_action:t.editing_action}:{},...t?.request_input_response?{request_input_response:t.request_input_response}:{}}};rt(u);let d={...a.length>0?{attached_docs:a.map(e=>e.id)}:{},...o,...t,id:l,_messageId:l},f=()=>Ye.agents.sendSignal(r,`UserInput`,{message:s,client_message_id:l,metadata:d}),p=()=>{it(l,`received`),I?.(),Dt()};i&&AU(r,i),(async()=>{await Dr(),Dn.current&&(await Ye.agents.restart(r),at()),await f(),p()})().catch(e=>{i&&jU(r,i),it(l,`failed`),Xe({status:`error`,title:Je(`agent.failedToSend`),description:e instanceof Error?e.message:Je(`agent.unknownError`),duration:3e3})}).finally(()=>{Pt(!1)})},[r,Ye,Xe,F,ee,I,Dt,at,rt,it,Je,Dr]);H(()=>(de&&(de.current=Or),()=>{de?.current===Or&&(de.current=null)}),[Or,de]);let kr=V(async(e,t)=>{try{await Ye.agents.sendSignal(r,`McpConfigChanged`,{})}catch(e){console.error(`Failed to signal MCP config change`,e)}Or(Je(`agent.mcpConnectedMessage`,{name:e.name}),t)},[Ye,r,Or,Je]),[Ar,jr]=G(void 0);H(()=>{let e=!1,t=hn.current;return Ye.agents.retrieve(r).then(n=>{e||(jr(n.disabled_mcp_collections),hn.current===t&&(n.tool_approval_mode!==void 0||n.interactive!==void 0)&&un(kn(n.tool_approval_mode,n.interactive)))}).catch(()=>{}),()=>{e=!0}},[Ye,r]);let Mr=V(e=>{let t=e.length>0?e:void 0;jr(t),Ye.agents.sendSignal(r,`McpConfigChanged`,{disabled_mcp_collections:e}).catch(e=>console.error(`Failed to signal MCP config change`,e))},[Ye,r]),Nr=V(()=>{Ye.agents.sendSignal(r,`McpConfigChanged`,{}).catch(e=>console.error(`Failed to signal MCP config change`,e))},[Ye,r]),Pr=V(e=>{let t=kn(e,a),n=ln;hn.current+=1,un(t);let i=Ye.agents.sendSignal(r,`ToolApprovalModeChanged`,{mode:t}).then(()=>void 0).catch(e=>{un(e=>e===t?n:e),Xe({status:`error`,title:Je(`agent.approvalMode.changeFailed`),description:e instanceof Error?e.message:Je(`agent.unknownError`),duration:3e3})});gn.current=i,i.finally(()=>{gn.current===i&&(gn.current=null)})},[r,Ye,a,Je,Xe,ln]),Fr=V(e=>{Ot&&(e.preventDefault(),e.stopPropagation(),fn.current++,e.dataTransfer?.types?.includes(`Files`)&&Gt(!0))},[Ot]),Ir=V(e=>{Ot&&(e.preventDefault(),e.stopPropagation())},[Ot]),Lr=V(e=>{Ot&&(e.preventDefault(),e.stopPropagation(),fn.current--,fn.current===0&&Gt(!1))},[Ot]),Rr=V(e=>{if(Ot&&(e.preventDefault(),e.stopPropagation(),fn.current=0,Gt(!1),e.dataTransfer?.files&&e.dataTransfer.files.length>0)){let t=Array.from(e.dataTransfer.files);Tt(t)}},[Tt,Ot]),zr=V(async()=>{if(Vt)return;let e=`stop-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,t={timestamp:Date.now(),workflow_run_id:r,type:J.IDLE,message:`Stopped. Waiting for your command...`,workstream_id:`main`,details:{_optimistic:!0,_messageId:e,_deliveryStatus:`sending`,display_role:`user_stopped`,status_reason:`user_stopped`}};rt(t),Ht(!0);try{await Ye.agents.sendSignal(r,`Stop`,{message:`User requested stop`,client_message_id:e,metadata:{id:e,_messageId:e}}),it(e,`received`)}catch(t){Xe({status:`error`,title:Je(`agent.failedToInterrupt`),description:t instanceof Error?t.message:Je(`agent.unknownError`),duration:3e3}),it(e,`failed`)}finally{Ht(!1)}},[Vt,r,rt,Ye.agents,Xe,Je,it]),Br=V(async()=>{if(!(Ft||Qn||!Un)){It(!0);try{await Ye.agents.sendSignal(r,`TriggerCheckpoint`,{reason:`manual user request`})}catch(e){Xe({status:`error`,title:Je(`agent.failedToCompactContext`),description:e instanceof Error?e.message:Je(`agent.unknownError`),duration:3e3})}finally{It(!1)}}},[r,Ye.agents,Qn,Ft,Un,Je,Xe]);H(()=>(xe&&(xe.current=h&&!Qn?zr:null),()=>{xe&&(xe.current=null)}),[xe,Qn,zr,h]),H(()=>{Se?.(Vt)},[Vt,Se]);let Vr=i||Je(`agent.agentConversation`),Hr=async()=>{try{let e=await rU(Ye,r);e&&window.open(e,`_blank`)}catch(e){console.error(`Failed to download conversation`,e),Xe({status:`error`,title:Je(`agent.failedToDownload`),duration:3e3})}},Ur=V(()=>{let e=new Date().toISOString(),t=Qe.size>0?[{cursor:`live`,streamingMessages:Array.from(Qe,([e,t])=>({id:e,...t}))}]:void 0,n={metadata:{title:Vr,agent_run_id:r,exported_at:e,message_count:Ze.length},messages:Ze,...t?{streamingFrames:t}:{}};z1(`${R1(Vr)||`agent-chat`}-${R1(r)}.json`,n),Xe({status:`success`,title:Je(`agent.rewind.fixtureExported`),duration:2e3})},[Vr,r,Ze,Qe,Je,Xe]),[Wr,Gr]=G(!1),Kr=()=>{if(!jt.current){Xe({status:`error`,title:Je(`agent.pdfExportFailed`),description:Je(`agent.noConversationContent`),duration:3e3});return}Gr(!0)},qr=()=>{if(!jt.current){Xe({status:`error`,title:Je(`agent.pdfExportFailed`),description:Je(`agent.noConversationContent`),duration:3e3});return}let e=`${Vr} - ${r}`;if(!I1(jt.current,e)){Xe({status:`error`,title:Je(`agent.pdfExportFailed`),description:Je(`agent.unableToOpenPrint`),duration:4e3});return}Xe({status:`success`,title:Je(`agent.pdfExportReady`),description:Je(`agent.printDialogDescription`),duration:4e3}),Gr(!1)},Jr=U(()=>Ze.filter(e=>e.type===J.COMPLETE||e.type===J.THOUGHT&&e.details?.tool_status===`completed`).length,[Ze]),Yr=U(()=>{if(!fr)return{key:Jr,details:void 0};let e=0,t;for(let n of Ze){let r=n.details;Ut(r,fr)&&(e++,t=r)}return{key:e,details:t}},[Jr,Ze,fr]),Xr=a&&Un&&xn?.toUpperCase()===`RUNNING`,Zr=U(()=>An.plan.plan?.reduce((e,t)=>(t.id&&t.goal&&e.set(t.id.toString(),t.goal),e),new Map),[An.plan]),Qr=e=>t(iZ,{title:Vr,variant:e,isCompleted:Qn,isTerminal:Sn,onClose:s,isModal:c,agentRunId:r,workflowRunId:ot||``,viewMode:zt,onViewModeChange:Bt,showPlanPanel:yr,hasPlan:A&&ct.length>0,showPlanButton:A&&!Be,onTogglePlanPanel:xr,showPlaybackButton:Ln,isPlaybackEnabled:Rn,onTogglePlayback:sr,onDownload:Hr,onExportFixture:Ur,resetWorkflow:d,onClone:p,onShowDetails:m,allowWorkflowControl:h,onExportPdf:Kr,isReceivingChunks:tt}),$r=n(`div`,{ref:jt,"data-agent-playback-enabled":Rn||void 0,"data-agent-playback-cursor":Rn?Hn:void 0,"data-agent-live-message-count":Ze.length,"data-agent-rendered-message-count":Kn.length,className:z(`flex flex-col min-h-0 min-w-0 border-0`,Be?`flex-1 h-full`:yr?`w-full flex-1 min-h-[50vh]`:l?`flex-1 w-full`:`flex-1 mx-auto ${c?``:`max-w-4xl`}`),children:[!w&&T===`compact`&&t(`div`,{className:`flex flex-shrink-0 justify-end border-b border-border/60 px-2 py-1 lg:hidden`,children:Qr(`compact`)}),!w&&T!==`compact`&&t(`div`,{className:`flex-shrink-0`,children:Qr(T)}),Rn&&t(`div`,{className:`flex flex-shrink-0 justify-end px-2 py-1.5`,children:t(xC,{cursor:Hn,messages:Bn,onChangeCursor:cr})}),Ze.length===0&&!Qn&&Ve&&He?t(F1,{message:Ve,startedAt:He}):t(DJ,{messages:Kn,workstreamSourceMessages:qn,bottomRef:At,isCompleted:$n,plan:An.plan,workstreamStatus:An.workstreamStatus,showPlanPanel:A&&pt,onTogglePlanPanel:xr,plans:ct,activePlanIndex:lt,onChangePlan:lr,taskLabels:Zr,streamingMessages:Jn,onSendMessage:Un?Or:void 0,onOpenArtifact:M?Cr:void 0,messageItemClassNames:Ce,messageStyleOverrides:we,toolCallGroupClassNames:Te,hideToolCallsInViewMode:Ee,streamingMessageClassNames:De,batchProgressPanelClassNames:Oe,artifactRunId:r,viewMode:zt,hideWorkstreamTabs:k,workingIndicatorClassName:ke,messageListClassName:Ae,StoreLinkComponent:Er,CollectionLinkComponent:Me,prependFriendlyMessage:Ne,initialRequestData:Pe,initialRequestSchema:Fe,initialRequestTitle:Ie,initialRequestTemplate:Le,showInitialRequest:et===`empty`&&Ze.length===0,hiddenMessageTypes:P,disableAutoScroll:!Un,renderRequestInputControls:!nr,activeWorkstream:Kt,onActiveWorkstreamChange:qt}),nr?t(nW,{message:tr,onSendMessage:Un?Or:void 0,onMcpConnected:Un?kr:void 0,disabled:L||!Un,isLoading:Nt||L}):rr&&Zn.length>0?t(`div`,{className:`flex-shrink-0 pb-safe-area`,children:t(YX,{activeWorkstreams:Zn,onSelectWorkstream:qt})}):ir&&t(`div`,{className:`flex-shrink-0 pb-safe-area`,children:Tn?D??t(oe,{status:`error`,title:Je(`agent.failed`),className:`m-2`,children:En??Je(`agent.error`)}):xn&&xn!==`RUNNING`&&!Cn?zt===`sliding`&&xn===`COMPLETED`?t(`div`,{className:`mx-auto w-full max-w-3xl px-4 py-3 text-sm text-muted`,children:n(`div`,{className:`flex items-center gap-2 border-t border-success/25 pt-3 text-success`,children:[t(Nh,{className:`size-4`}),t(`span`,{className:`font-medium`,children:`Workflow completed`})]})}):n(oe,{status:xn===`COMPLETED`?`success`:`done`,icon:null,className:`m-2`,children:[`This Workflow is `,xn]}):(ft||Cn)&&n(e,{children:[re,t(c1,{onSend:Or,onStop:h?zr:void 0,approvalModeSlot:a&&ln?t(Yb,{mode:ln,onChange:Pr,disabled:!Un||Sn||!h}):void 0,mcpSlot:t(WJ,{disabledCollections:Ar,onChange:Mr,onConnectionChange:Nr}),disabled:L||!Un,isSending:Nt||L,isStopping:Vt,isStreaming:!Qn,isCompleted:Qn,contextWindowUsage:or?ar:void 0,onCompactContext:or?Br:void 0,isCompactingContext:Ft,activeTaskCount:Pn,activeWorkstreams:Nn,onSelectWorkstream:qt,placeholder:In,onFilesSelected:Ot?Tt:void 0,uploadedFiles:g,onRemoveFile:_,onRemoveProcessingFile:kt,acceptedFileTypes:v,maxFiles:y,processingFiles:Ct,artifactRunId:r,hasProcessingFiles:wt,renderDocumentSearch:b,selectedDocuments:x,onRemoveDocument:S,hideObjectLinking:C,hideFileUpload:!Ot,disableDropZone:Ot,className:te,inputClassName:ne})]})})]}),ei=t(BS,{children:t(DW,{children:n(`div`,{ref:Mt,className:z(`flex flex-col lg:flex-row gap-2 w-full h-full relative overflow-hidden`,Ot&&Wt&&`ring-2 ring-info ring-inset`,R),onDragEnter:Ot?Fr:void 0,onDragOver:Ot?Ir:void 0,onDragLeave:Ot?Lr:void 0,onDrop:Ot?Rr:void 0,children:[Ot&&Wt&&t(`div`,{className:`absolute inset-0 flex items-center justify-center bg-info/80 dark:bg-info/40 z-50 pointer-events-none rounded-lg`,children:n(`div`,{className:`text-info font-medium flex items-center gap-2 text-lg`,children:[t(wb,{className:`size-6`}),`Drop files to upload`]})}),!Be&&$r,!Be&&T===`compact`&&!w&&t(`div`,{className:`hidden h-full w-12 shrink-0 items-start justify-center px-1 pt-2 lg:flex`,children:Qr(`compact`)}),yr&&n(e,{children:[!Be&&t(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize right panel`,"aria-valuenow":Math.round(pr),"aria-valuemin":300,"aria-valuetext":`${Math.round(pr)} pixels`,tabIndex:0,className:`hidden lg:block lg:w-1 lg:shrink-0 cursor-col-resize bg-border/70 hover:bg-border transition-colors`,onMouseDown:()=>gr(!0),onKeyDown:e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let t=e.shiftKey?32:16,n=e.key===`ArrowLeft`?t:-t,r=Mt.current,i=r?Math.max(300,r.getBoundingClientRect().width-420):900;mr(e=>Math.min(Math.max(e+n,300),i))}}),t(`div`,{className:Be?`w-full h-full overflow-auto`:`w-full lg:w-[var(--agent-right-panel-width)] lg:shrink-0 min-h-[50vh] lg:h-full border-t lg:border-t-0`,style:Be?void 0:{"--agent-right-panel-width":`${pr}px`},children:t(DX,{plan:An.plan,workstreamStatus:An.workstreamStatus,plans:ct,activePlanIndex:lt,onChangePlan:lr,showPlan:!O&&pt,activeWorkstreams:Mn,hideWorkstreams:k,openDocuments:ht,activeDocumentId:gt,onSelectDocument:bt,onUpdateDocumentTitle:St,docRefreshKey:vt,runId:r,processingFiles:he??Ct,showArtifacts:M,artifactRefreshKey:Yr.key,artifactRefreshDetails:Yr.details,selectedArtifactPath:fr,onSelectedArtifactPathChange:Y,onSendMessage:Xr?Or:void 0,messages:Ze,payloadContent:Re,conversationContent:Be?$r:ze,onClose:Sr,defaultTab:ur,activeTab:ur,onTabChange:dr})})]}),n(se,{isOpen:Wr,onClose:()=>Gr(!1),children:[t(ue,{children:`Export conversation as PDF`}),n(ce,{children:[t(`p`,{className:`mb-2`,children:`This will open your browser's print dialog with the current conversation.`}),t(`p`,{className:`text-sm text-muted`,children:`To save a PDF, choose "Save as PDF" or a similar option in the print dialog.`})]}),n(le,{align:`right`,children:[t(o,{variant:`ghost`,size:`sm`,onClick:()=>Gr(!1),children:`Cancel`}),t(o,{size:`sm`,onClick:qr,children:`Open print dialog`})]})]})]})})});return ie?t(Yn,{data:ie,sendMessage:Or,ChartComponent:oC,artifactRunId:r,children:ei}):ei}function W1({messages:e}){let n=ot.useMemo(()=>[...e].sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())),[e]);return t(`div`,{className:`flex flex-col overflow-y-auto space-y-6 py-4`,children:n.map(e=>t(vG,{message:e,showPulsatingCircle:!1},`${e.workstream_id??`main`}-${e.timestamp}-${e.type}`))})}function G1({messages:e,bottomRef:n,className:r,messagesClassName:i,emptyClassName:a}){let o=ot.useRef(null);H(()=>{n.current&&n.current.scrollIntoView({behavior:`smooth`})},[e,n]);let s=ot.useMemo(()=>[...e].sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())),[e]);return t(`div`,{ref:o,className:`flex-1 min-h-0 h-full overflow-y-auto py-4 px-4 sm:px-6 lg:px-8 bg-white flex flex-col ${r||``}`,"data-testid":`messages-container`,children:s.length===0?t(`div`,{className:`flex items-center justify-center h-full text-center py-8 ${a||``}`,children:t(`div`,{className:`flex items-center px-4 py-3 text-muted`,children:`Waiting for agent response...`})}):t(`div`,{className:`flex-1 flex flex-col justify-start h-full min-h-0 ${i||``}`,children:t(W1,{messages:s,isCompleted:!1})})})}function K1(e){return e.name}function q1({isClearable:e=!1,onChange:n,ignoreVirtuals:r=!1,selectedEnvId:i,disabled:a=!1}){let{t:o}=K(),{client:s}=q(),[c,l]=G(),{data:u,isLoading:d}=Xe(()=>s.environments.list().then(e=>(r?e.filter(e=>!e.provider.startsWith(`virtual_`)):e).slice().sort((e,t)=>e.name.localeCompare(t.name))));return H(()=>{l(u?.find(e=>e.id===i))},[u,i]),t(we,{isClearable:e,optionLabel:K1,options:u??[],value:c,onChange:e=>{l(e),n(e)},placeholder:o(`intakePolicy.placeholder.environment`),filterBy:`name`,disabled:a,isLoading:d})}function J1(e){return e.name}function Y1(e){return e?.length?n=>{let r=e.some(e=>e.id===n.id);return t(`span`,{className:r?`opacity-50`:``,children:n.name})}:J1}function X1({envId:e,isClearable:n,onChange:r,selectedModelId:i,disabled:a=!1,greyedModels:o,onModelsLoaded:s}){let{t:c}=K(),{client:l}=q(),[u,d]=G(),{data:f,isLoading:p}=Ye(async()=>{if(!e)return[];try{return[...(await l.environments.retrieve(e)).enabled_models??[]].sort((e,t)=>e.name.localeCompare(t.name))}catch{return[]}},[e]);return H(()=>{if(!i){d(void 0);return}let e=f?.find(e=>e.id===i);d(e??{id:i,name:i,provider:`unknown`})},[f,i]),H(()=>{f&&s?.(f)},[f,s]),t(we,{isClearable:n,by:`id`,optionLabel:Y1(o),options:f??[],value:u,onChange:e=>{d(e),r(e)},placeholder:c(`intakePolicy.placeholder.model`),disabled:a,isLoading:p})}function Z1({env:e,isClearable:n,onChange:r}){let{t:i}=K(),{client:a}=q(),[o,s]=G(),{data:c,isLoading:l}=Ye(async()=>{if(!e)return[];try{return a.environments.listTrainableModels(e.id)}catch{return[]}},[e?.id]);return t(we,{isClearable:n,by:`id`,optionLabel:J1,options:c??[],value:o,onChange:e=>{s(e),r(e)},placeholder:i(`intakePolicy.placeholder.model`),disabled:!e,isLoading:l})}function Q1({children:e,fallback:n}){return $1?t($1,{fallback:n,children:e}):t(rr,{FallbackComponent:n,children:e})}let $1=null;function e0(e){$1=e}function t0({children:e}){return t(Q1,{fallback:n0,children:e})}function n0({error:e}){let{t:r}=K(),i=e instanceof Error?e.message:void 0;return n(oe,{status:`error`,title:r(`errors.somethingWentWrong`),children:[n(`div`,{className:`mb-4`,children:[r(`errors.teamNotifiedLine1`),` `,r(`errors.teamNotifiedLine2`),`\xA0`,t(`a`,{className:`text-info`,href:`mailto:support@vertesiahq.com`,children:`support@vertesiahq.com`}),`.`]}),i&&t(`code`,{className:`w-full mt-4 text-sm text-muted break-words`,children:i})]})}function r0({children:e}){return t(Q1,{fallback:i0,children:e})}function i0({error:e}){let r=e instanceof Error?e.message:void 0;return t(`tr`,{children:n(`td`,{colSpan:100,children:[t(`span`,{className:`text-xs`,children:` Cannot display row`}),t(`br`,{}),t(`span`,{className:`bg-muted`,children:r})]})})}function a0({children:e}){return t(Q1,{fallback:o0,children:e})}function o0({error:e}){let r=e instanceof Error?e.message:void 0;return console.log(`WidgetError`,e),n(`div`,{className:`text-sm`,children:[`Sorry, this area cannot be loaded or rendered.`,r&&t(`pre`,{children:r})]})}Q();const s0=/^[a-f0-9]{24}$|^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$|^(?=.*\d)(?=.*[a-zA-Z])[a-zA-Z0-9_-]{8,}$/i;function c0(e){return s0.test(e)}function l0({className:e,children:r,title:i,description:o,actions:s,breadcrumbs:c,useDynamicBreadcrumbs:l=!0,parentPath:u,parentLabel:d}){let f=Qn();function p(e){return e.replace(/[-_]/g,` `).split(` `).map(e=>qn(e)).join(` `)}let m=e=>{if(e?.title)return e.title;let t=e?.href||``;if(!t)return`Page`;let n=t.split(`#`)[0].split(`?`)[0].split(`/`).filter(e=>e.length>0);return n.length>=1?p(n[n.length-1]):`Page`},h=(()=>{let e=[];if(l&&typeof window<`u`){let t=window.history.state?.historyChain;if(Array.isArray(t))t.forEach((n,r)=>{let i=t.length-r;e.push({label:m(n),href:n.href,onClick:()=>f(n.href,{stepsBack:i})})});else if(u)e.push({label:d??m({href:u}),href:u,onClick:()=>f(u,{isBasePathNested:!1,replace:!0})});else{let t=window.location.pathname.split(`/`).filter(e=>e.length>0);for(let n=0;n<t.length;n++)if(c0(t[n])){let r=`/${t.slice(0,n).join(`/`)}`;e.push({label:p(t[n-1]||r),href:r,onClick:()=>f(r,{isBasePathNested:!1})})}}}return c&&c.length>0&&c.forEach(t=>{let n=t.props?.children||t,r=t.props?.href;e.push(r?{href:r,label:n,onClick:()=>f(r,{replace:t.props.clearBreadcrumbs})}:{label:n})}),e})(),g=!!i&&h.length===0;return n(`div`,{className:it(`pb-0 ps-4 pe-2 py-2 flex flex-col`,e),children:[n(`div`,{className:`flex items-start gap-4`,children:[n(`div`,{className:`w-full flex place-content-between h-auto min-h-8 flex-col items-start justify-center`,children:[n(`nav`,{className:`flex-1 flex justify-start text-sm`,children:[h.length>0&&t(a,{path:h,separator:t(lh,{className:`size-3.5 cn-rtl-flip`}),maxItems:4}),o&&!g&&t(We,{description:o,children:t(A_,{className:`size-4 text-muted ms-4`})})]}),i&&n(`div`,{className:`flex gap-2 items-center`,children:[t(`h1`,{className:`text-xl font-semibold break-all`,children:i}),o&&g&&t(We,{description:o,children:t(A_,{className:`size-4 text-muted`})})]})]}),t(`div`,{className:`flex gap-x-2 shrink-0 items-center`,children:s})]}),r&&t(`div`,{className:`w-full flex items-center`,children:r})]})}function u0(){let{t:e}=K();return n(`div`,{className:`text-center pt-32`,children:[t(`h1`,{className:`text-3xl font-bold text-destructive`,children:`404`}),t(`p`,{className:`text-2xl`,children:e(`layout.pageNotFound`)})]})}Q();const d0=`magic-pdf`;function f0(e){return e.replace(/^\$\.?/,``).replace(/^data\./,``)}function p0(e){let{client:t}=q(),[n,r]=G(!1);return H(()=>{let n=!1;return r(!1),t.files.getDownloadUrl(`${d0}/${e}/grounded-extraction.json`).then(e=>fetch(e.url,{method:`HEAD`})).then(e=>{n||r(e.ok)}).catch(()=>{}),()=>{n=!0}},[t,e]),n}function m0(e){let{client:t}=q(),[n,r]=G(null);return H(()=>{let n=!1;return r(null),t.files.getDownloadUrl(`${d0}/${e}/grounded-extraction.json`).then(e=>fetch(e.url)).then(e=>e.ok?e.json():null).then(e=>{n||!e?.citations||r({confidence:e.confidence,verified:e.citations.filter(e=>e.verified).length,total:e.citations.length,verdict:e.verdict,verdict_reason:e.verdict_reason})}).catch(()=>{}),()=>{n=!0}},[t,e]),n}function h0({objectId:e,onClose:r}){let{t:i}=K(),{client:a}=q(),{data:s,error:c,isLoading:l}=Ye(async()=>{let t=await a.files.getDownloadUrl(`${d0}/${e}/grounded-extraction.json`),n=await fetch(t.url);if(!n.ok)throw Error(i(`grounded.notFound`));return n.json()},[e]);return c?t(`div`,{className:`flex h-full items-center justify-center`,children:n(`div`,{className:`flex flex-col items-center gap-4 p-8 max-w-md`,children:[t(M,{title:i(`grounded.failedToLoad`),children:Ge(c)}),r&&t(o,{variant:`outline`,onClick:r,children:i(`pdf.close`)})]})}):l||!s?t(`div`,{className:`flex h-full items-center justify-center`,children:t(je,{size:`lg`})}):t(`div`,{className:`relative h-full`,children:t(_0,{extraction:s,objectId:e,onClose:r})})}function g0({objectId:e,onClose:n}){return t(`div`,{className:`fixed inset-0 bg-background z-50`,children:t(h0,{objectId:e,onClose:n})})}function _0({extraction:r,objectId:a,onClose:s}){let{t:c}=K(),{client:l}=q(),u=U(()=>Object.keys(r.pages).map(e=>parseInt(e,10)).sort((e,t)=>e-t),[r.pages]),d=e=>{l.files.getDownloadUrl(`${d0}/${a}/${e}`).then(e=>window.open(e.url,`_blank`)).catch(()=>{})},[f,p]=G(u[0]??1),[m,h]=G(void 0),[g,_]=G(!1),[v,y]=G(`original`),b=U(()=>{let e={digital:0,ocr:0,reviewerConfirmed:0,snapped:0,imageRead:0},t=[];for(let n of r.citations)n.verified?n.snapped?e.snapped++:(n.confidence??0)>=1?e.digital++:e.ocr++:n.reviewed?e.reviewerConfirmed++:(e.imageRead++,t.push(n));let n=e.digital+e.ocr+e.snapped,i=e.reviewerConfirmed;return{groups:e,unverified:t,digitallyVerified:n,modelVerified:i,totalVerified:n+i}},[r.citations]),x=U(()=>{let e=new Map;for(let t of r.citations){let n=f0(t.path),r=e.get(n)??[];r.push(t),e.set(n,r)}return e},[r.citations]),S=r.citations.length,C=b.totalVerified===S,T=e=>{h(e);let t=x.get(f0(e))?.[0];t&&p(t.page)},E=u.indexOf(f),D=m?x.get(f0(m))?.find(e=>e.page===f):void 0,O=D?.cells?D.cells.start===D.cells.end?D.cells.start:`${D.cells.start}:${D.cells.end}`:void 0;return n(Ce,{direction:`horizontal`,className:`absolute inset-0`,children:[n(Se,{defaultSize:55,minSize:25,className:`flex flex-col bg-muted`,children:[n(`div`,{className:`relative flex h-9 shrink-0 items-center justify-center bg-sidebar px-2 border-b border-sidebar-border`,children:[O&&t(i,{variant:`secondary`,className:`absolute start-2 max-w-32 truncate font-mono text-[11px]`,title:O,children:O}),n(`div`,{className:`flex items-center gap-2`,children:[t(o,{variant:`ghost`,size:`xs`,"aria-label":c(`grounded.previousPage`),disabled:E<=0,onClick:()=>p(u[E-1]),children:t(oh,{className:`size-4`})}),t(`span`,{className:`text-xs text-muted`,children:c(`pdf.pageOf`,{pageNumber:f,totalPages:u.length})}),t(o,{variant:`ghost`,size:`xs`,"aria-label":c(`grounded.nextPage`),disabled:E>=u.length-1,onClick:()=>p(u[E+1]),children:t(lh,{className:`size-4`})})]}),n(`fieldset`,{className:`absolute end-2 flex items-center gap-0.5 rounded border-0 bg-muted p-0.5`,children:[t(`legend`,{className:`sr-only`,children:c(`grounded.checkerboard`)}),t(We,{description:c(`pdf.originalImages`),placement:`bottom`,size:`xs`,asChild:!0,children:n(o,{variant:v===`original`?`outline`:`ghost`,size:`xs`,"aria-label":c(`pdf.originalImages`),"aria-pressed":v===`original`,className:`h-6 gap-1 px-1.5`,onClick:()=>y(`original`),children:[t(D_,{className:`size-3.5`}),t(`span`,{className:`hidden sm:inline`,children:c(`pdf.page`)})]})}),t(We,{description:c(`grounded.checkerboard`),placement:`bottom`,size:`xs`,asChild:!0,children:n(o,{variant:v===`grid`?`outline`:`ghost`,size:`xs`,"aria-label":c(`grounded.checkerboard`),"aria-pressed":v===`grid`,className:`h-6 gap-1 px-1.5`,onClick:()=>y(`grid`),children:[t(x_,{className:`size-3.5`}),t(`span`,{className:`hidden sm:inline`,children:c(`grounded.checkerboard`)})]})})]})]}),t(`div`,{className:`flex-1 overflow-auto p-2`,children:t(v0,{objectId:a,page:f,dims:r.pages[String(f)],citations:r.citations.filter(e=>e.page===f),selectedPath:m,onSelectPath:h,imageMode:v})})]}),t(xe,{className:`w-[4px] bg-border cursor-ew-resize`}),n(Se,{defaultSize:45,minSize:20,className:`flex flex-col`,children:[n(`div`,{className:`flex h-9 items-center justify-between shrink-0 bg-sidebar px-2 border-b border-sidebar-border`,children:[t(`span`,{className:`text-sm font-medium`,children:c(`grounded.title`)}),n(`div`,{className:`flex items-center gap-2`,children:[S>0&&t(We,{description:c(`grounded.confidenceHint`),placement:`bottom`,size:`xs`,asChild:!0,children:n(i,{variant:C?`success`:`attention`,className:`gap-1 text-nowrap cursor-pointer`,onClick:()=>_(e=>!e),"aria-expanded":g,children:[t(C?Ih:Ag,{className:`size-3.5`}),c(`grounded.verifiedOf`,{verified:b.totalVerified,total:S})]})}),n(w,{align:`right`,trigger:t(o,{variant:`ghost`,size:`xs`,"aria-label":c(`pdf.download`),title:c(`pdf.download`),children:t(xg,{className:`size-4`})}),children:[n(ae,{className:`text-xs`,onClick:()=>d(`grounded-extraction.json`),children:[t(Ng,{className:`size-4`}),c(`grounded.downloadCitations`)]}),n(ae,{className:`text-xs`,onClick:()=>d(`pages/page-${f}.json`),children:[t(Gg,{className:`size-4`}),c(`grounded.downloadBlocks`)]}),n(ae,{className:`text-xs`,onClick:()=>d(`grounded-annotated.pdf`),children:[t(Ig,{className:`size-4`}),c(`grounded.downloadAnnotated`)]})]}),!!s&&t(o,{variant:`ghost`,size:`xs`,onClick:s,"aria-label":c(`pdf.close`),children:t(Gb,{className:`size-4`})})]})]}),g&&n(`div`,{className:`shrink-0 border-b border-border bg-background px-3 py-2 text-sm max-h-72 overflow-auto`,children:[n(`div`,{className:`mb-1 flex items-center gap-1`,children:[t(`span`,{className:`font-medium`,children:c(`grounded.breakdownTitle`)}),t(We,{description:c(`grounded.breakdownVerificationHelp`),size:`xs`,children:t(A_,{className:`size-3 text-muted`})})]}),n(`div`,{className:`grid grid-cols-2 gap-x-4 text-xs`,children:[t(`span`,{className:`col-span-2 mt-1 font-medium text-success`,children:c(`grounded.digitalVerifiedOf`,{count:b.digitallyVerified,total:S})}),t(`span`,{className:`ps-2 text-muted`,children:c(`grounded.breakdownDigital`)}),t(`span`,{className:`text-end text-success`,children:b.groups.digital}),t(`span`,{className:`ps-2 text-muted`,children:c(`grounded.breakdownOcr`)}),t(`span`,{className:`text-end text-success`,children:b.groups.ocr}),t(`span`,{className:`ps-2 text-muted`,children:c(`grounded.breakdownSnapped`)}),t(`span`,{className:`text-end text-success`,children:b.groups.snapped}),t(`span`,{className:`col-span-2 mt-2 font-medium text-success`,children:c(`grounded.modelVerifiedOf`,{count:b.modelVerified,total:S})}),t(`span`,{className:`ps-2 text-muted`,children:c(`grounded.breakdownReviewer`)}),t(`span`,{className:`text-end text-success`,children:b.groups.reviewerConfirmed}),b.groups.imageRead>0&&n(e,{children:[t(`span`,{className:`col-span-2 mt-2 font-medium text-attention`,children:c(`grounded.unverifiedCount`,{count:b.groups.imageRead})}),t(`span`,{className:`ps-2 text-muted`,children:c(`grounded.breakdownImageRead`)}),t(`span`,{className:`text-end text-attention`,children:b.groups.imageRead})]})]}),typeof r.hardness?.score==`number`&&n(`p`,{className:`mt-2 text-xs text-muted`,title:c(`grounded.hardnessHint`),children:[c(`grounded.hardness`,{percent:Math.round(r.hardness.score*100)}),r.hardness.escalated?` ↑`:``]}),(r.verdict_reason??r.review?.verdict_reason)&&t(`p`,{className:`mt-2 text-xs`,children:r.verdict_reason??r.review?.verdict_reason}),r.review?.summary&&n(`p`,{className:`mt-2 text-xs text-muted`,children:[n(`span`,{className:`font-medium text-foreground`,children:[c(`grounded.reviewSummary`),`: `]}),r.review.summary]}),typeof r.review?.corrections_applied==`number`&&r.review.corrections_applied>0&&t(`p`,{className:`mt-1 text-xs text-info`,children:c(`grounded.reviewCorrections`,{count:r.review.corrections_applied})}),b.unverified.length>0&&n(`div`,{className:`mt-2`,children:[t(`div`,{className:`text-xs font-medium text-muted mb-1`,children:c(`grounded.breakdownUnverifiedList`)}),t(`ul`,{className:`space-y-0.5`,children:b.unverified.map(e=>t(`li`,{children:n(`button`,{type:`button`,className:`w-full text-start text-xs rounded px-1 py-0.5 hover:bg-muted cursor-pointer`,onClick:()=>{T(e.path),_(!1)},children:[t(`span`,{className:`text-muted`,children:e.path}),` `,t(`span`,{children:String(e.value??``)})]})},e.path))})]})]}),n(`div`,{className:`flex-1 overflow-auto p-3`,children:[t(y0,{value:r.data,path:``,citationsByPath:x,selectedPath:m,onSelect:T}),r.conflicts&&r.conflicts.length>0&&t(`div`,{className:`mt-4 text-xs text-attention`,children:c(`grounded.conflicts`,{count:r.conflicts.length})})]})]})]})}function v0({objectId:e,page:r,dims:i,citations:a,selectedPath:o,onSelectPath:s,imageMode:c}){let{t:l}=K(),{client:u}=q(),[d,f]=G(void 0);if(H(()=>{let t=!1;return f(void 0),u.files.getDownloadUrl(`${d0}/${e}/pages/page-${r}.${c}.jpg`).then(e=>{t||f(e.url)}).catch(e=>console.warn(`Failed to load page image`,e)),()=>{t=!0}},[u,c,e,r]),!d||!i)return t(`div`,{className:`flex items-center justify-center h-64`,children:t(je,{})});let p=a.flatMap(e=>e.boxes.map((r,a)=>{let c=o!==void 0&&f0(o)===f0(e.path),l=e.cells?e.cells.start===e.cells.end?e.cells.start:`${e.cells.start}:${e.cells.end}`:void 0;return t(We,{description:n(`span`,{className:`flex flex-col gap-0.5`,children:[t(`span`,{className:`flex items-center gap-1 font-medium`,children:S0(e.path).map((e,r)=>n(lt,{children:[r>0&&t(lh,{className:`size-3 shrink-0 cn-rtl-flip`}),e]},`${r}:${e}`))}),l&&t(`span`,{className:`font-mono`,children:l}),e.source_text&&t(`span`,{children:e.source_text})]}),size:`xs`,asChild:!0,children:t(`button`,{type:`button`,"aria-label":e.path,onClick:()=>s(f0(e.path)),className:z(`absolute cursor-pointer border rounded-[1px] transition-colors`,e.misaligned&&`border-dashed`,c?`border-2 border-primary bg-primary/20 z-10`:e.verified?`border-success/70 hover:bg-success/20`:e.reviewed?`border-info/70 hover:bg-info/20`:`border-attention/80 hover:bg-attention/20`),style:{position:`absolute`,left:`${r.x/i.width*100}%`,top:`${r.y/i.height*100}%`,width:`${r.w/i.width*100}%`,height:`${r.h/i.height*100}%`}})},`${e.path}-${a}`)})),m=((i.rotation??0)%360+360)%360;if(m!==0){let e=m===90||m===270;return n(`div`,{className:`relative w-full`,style:{aspectRatio:`${i.width} / ${i.height}`},children:[t(`img`,{src:d,alt:l(`grounded.pageAlt`,{page:r}),className:`absolute select-none`,style:{left:`50%`,top:`50%`,width:`${(e?i.height/i.width:1)*100}%`,height:`${(e?i.width/i.height:1)*100}%`,maxWidth:`none`,transform:`translate(-50%, -50%) rotate(${m}deg)`,transformOrigin:`center center`}}),p]})}return n(`div`,{className:`relative w-full`,children:[t(`img`,{src:d,alt:l(`grounded.pageAlt`,{page:r}),className:`w-full select-none`}),p]})}function y0({value:e,path:r,citationsByPath:i,selectedPath:a,onSelect:o}){return Array.isArray(e)?e.length>0&&e.every(e=>typeof e==`object`&&!!e)?t(b0,{items:e,path:r,citationsByPath:i,selectedPath:a,onSelect:o}):t(`div`,{className:`space-y-1`,children:e.map((e,n)=>t(y0,{value:e,path:`${r}[${n}]`,citationsByPath:i,selectedPath:a,onSelect:o},`${r}[${n}]`))}):typeof e==`object`&&e?t(`div`,{className:r?`ps-3 border-s border-border space-y-0.5`:`space-y-0.5`,children:Object.entries(e).map(([e,s])=>{let c=r?`${r}.${e}`:e;if(typeof s!=`object`||!s)return t(x0,{label:e,value:s,path:c,citationsByPath:i,selectedPath:a,onSelect:o},c);let l=Array.isArray(s)&&s.length>0&&s.every(e=>typeof e==`object`&&!!e);return n(`div`,{className:`pt-1`,children:[!l&&t(`div`,{className:`text-sm font-semibold`,children:C0(e)}),t(y0,{value:s,path:c,citationsByPath:i,selectedPath:a,onSelect:o})]},c)})}):null}function b0({items:e,path:r,citationsByPath:i,selectedPath:a,onSelect:o}){let{t:s}=K(),c=U(()=>{let t=new Set;for(let n of e)for(let e of Object.keys(n))t.add(e);return Array.from(t)},[e]);return n(`div`,{className:`pt-1`,children:[n(`div`,{className:`text-sm font-semibold`,children:[C0(r.split(`.`).pop()),` (`,e.length,`)`]}),t(`div`,{className:`overflow-x-auto`,children:n(`table`,{className:`w-full text-xs`,children:[t(`thead`,{children:t(`tr`,{className:`text-start text-muted`,children:c.map(e=>t(`th`,{scope:`col`,className:`py-1 pe-2 font-medium`,children:C0(e)},e))})}),t(`tbody`,{children:e.map((e,l)=>t(`tr`,{className:`border-t border-border/50`,children:c.map(c=>{let u=`${r}[${l}].${c}`,d=i.get(u)?.[0];return t(`td`,{className:`py-0.5 pe-2`,children:n(`button`,{type:`button`,onClick:()=>o(u),className:z(`text-start rounded px-1 w-full`,a===u?`bg-primary/15 ring-1 ring-primary`:d?`hover:bg-muted cursor-pointer`:`text-muted cursor-default`),children:[E0(e[c]),d&&typeof d.confidence==`number`&&t(`span`,{className:z(`ms-1 text-[10px]`,T0(d.confidence)),title:s(`grounded.scoreHint`),children:w0(d.confidence)})]})},c)})},`${r}[${l}]`))})]})})]})}function x0({label:e,value:r,path:i,citationsByPath:a,selectedPath:o,onSelect:s}){let{t:c}=K(),l=a.get(i)?.[0];return n(`button`,{type:`button`,onClick:()=>l&&s(i),className:z(`flex items-center gap-2 w-full text-start text-sm rounded px-1.5 py-0.5`,o===i?`bg-primary/15 ring-1 ring-primary`:l?`hover:bg-muted`:``,!l&&`cursor-default`),children:[n(`span`,{className:`min-w-28 shrink-0 font-semibold`,children:[C0(e),`:`]}),t(`span`,{className:`flex-1 wrap-break-word`,children:E0(r)}),l&&typeof l.confidence==`number`&&t(`span`,{className:z(`text-xs shrink-0`,T0(l.confidence)),title:c(`grounded.scoreHint`),children:w0(l.confidence)}),l&&(l.verified?t(Ih,{"aria-label":c(`grounded.verified`),className:`size-3.5 shrink-0 text-success`}):l.reviewed?t(Jy,{"aria-label":c(`grounded.aiVerified`),className:`size-3.5 shrink-0 text-info`}):t(Ag,{"aria-label":c(`grounded.readFromImage`),className:`size-3.5 shrink-0 text-attention`}))]})}function S0(e){return f0(e).split(`.`).map(e=>C0(e.replace(/\[\d+\]/g,``))).filter(Boolean)}function C0(e){return e?zt(e):``}function w0(e){let t=e*100;return Number.isInteger(t)?`${t}%`:`${(Math.floor(t*100)/100).toFixed(2)}%`}function T0(e){return e>=.95?`text-success`:e>=.7?`text-attention`:`text-destructive`}function E0(e){return e==null||e===``?`—`:typeof e==`boolean`?e?`true`:`false`:typeof e==`object`?JSON.stringify(e):String(e)}const D0=`magic-pdf`;var O0;(function(e){e.original=`original`,e.instrumented=`instrumented`})(O0||={});var k0=class{client;objectId;totalPages;cache=new Map;pending=new Map;constructor(e,t,n){this.client=e,this.objectId=t,this.totalPages=n}getCacheKey(e,t){return`${t}-${e}`}async getPageImageUrl(e,t){let n=this.getCacheKey(e,t),r=this.cache.get(n);if(r)return r;let i=this.pending.get(n);if(i)return i;let a=this.fetchImageUrl(e,t);this.pending.set(n,a);try{let e=await a;return this.cache.set(n,e),e}finally{this.pending.delete(n)}}async fetchImageUrl(e,t){let n=this.getImagePath(e,t);return(await this.client.files.getDownloadUrl(n)).url}getImagePath(e,t){let n=`${D0}/${this.objectId}/pages`;switch(t){case O0.original:return`${n}/page-${e}.original.jpg`;case O0.instrumented:return`${n}/page-${e}.instrumented.jpg`}}},A0=class{client;objectId;totalPages;cache=new Map;pending=new Map;constructor(e,t,n){this.client=e,this.objectId=t,this.totalPages=n}async getPageLayout(e){let t=this.cache.get(e);if(t!==void 0)return t;let n=this.pending.get(e);if(n)return n;let r=this.fetchPageLayout(e);this.pending.set(e,r);try{let t=await r;return this.cache.set(e,t),t}finally{this.pending.delete(e)}}async fetchPageLayout(e){let t=`${D0}/${this.objectId}/pages/page-${e}.layout.json`,n=await this.client.files.getDownloadUrl(t),r=await fetch(n.url,{method:`GET`});if(!r.ok)throw Error(`Failed to fetch json layout: ${r.statusText}`);return r.text()}},j0=class{totalPages;pages=[];constructor(e){this.totalPages=e}initFromContent(e){this.pages=M0(e,this.totalPages)}async loadUrls(e,t){}async getPageMarkdown(e){let t=e-1;return t<0||t>=this.pages.length?``:this.pages[t]}};function M0(e,t){let n=Array(t).fill(``),r=/<!--\s*\{\s*"page"\s*:\s*(\d+)\s*\}\s*-->/g,i=[];for(let t of e.matchAll(r))i.push({page:parseInt(t[1],10),index:t.index+t[0].length});for(let r=0;r<i.length;r++){let a=i[r],o=a.page-1;if(o<0||o>=t)continue;let s=a.index,c=e.slice(s).match(/<!--\s*\{\s*"page"\s*:\s*\d+\s*\}\s*-->/),l=c&&c.index!==void 0?s+c.index:e.length,u=e.slice(s,l).trim();u=u.replace(/\n---\s*$/,``).trim(),n[o]=u}return n}const N0=dt(void 0);function P0({children:e,object:n}){let{client:r}=q(),i=n.metadata.page_count||10,[a,o]=G(()=>{let e=new j0(i);return n.text&&e.initFromContent(n.text),{count:i,layoutProvider:new A0(r,n.id,i),markdownProvider:e,imageProvider:new k0(r,n.id,i),pdfUrl:``,pdfUrlLoading:!0}});return H(()=>{let e=n.metadata?.renditions?.find(e=>e.name===_n),t=n.content?.type===`application/pdf`,i=e?.content?.source||(t?n.content?.source:void 0);i?r.store.objects.getDownloadUrl(i,void 0,`inline`).then(e=>{o(t=>({...t,pdfUrl:e.url,pdfUrlLoading:!1}))}).catch(e=>{console.warn(`Failed to get PDF URL:`,e),o(e=>({...e,pdfUrlLoading:!1}))}):o(e=>({...e,pdfUrlLoading:!1}))},[r,n.metadata,n.content?.type,n.content?.source]),t(N0.Provider,{value:a,children:e})}function F0(e,t,n){return e.files.getDownloadUrl(`${D0}/${t}/${n}`).then(e=>e.url)}function I0(){let e=ot.useContext(N0);if(!e)throw Error(`useMagicPdfContext must be used within a MagicPdfProvider`);return e}Q();function L0({object:e}){let{t:n}=K(),{client:r}=q(),i=t=>{F0(r,e.id,t).then(e=>window.open(e,`_blank`))};return t(o,{variant:`ghost`,size:`xs`,onClick:()=>i(`document.md`),title:n(`pdf.download`),children:t(xg,{className:`size-4`})})}Q();function R0({className:e}){return t(`div`,{className:`flex items-center justify-center ${e||``}`,children:t(ev,{className:`w-6 h-6 animate-spin text-muted`})})}function z0({viewType:e,pageNumber:n}){switch(e){case`json`:return t(B0,{pageNumber:n});case`markdown`:return t(V0,{pageNumber:n});default:return t(V0,{pageNumber:n})}}function B0({pageNumber:e}){let[n,r]=G(null),[i,a]=G(!0),[o,s]=G(null),{layoutProvider:c}=I0();return H(()=>{a(!0),s(null),c.getPageLayout(e).then(e=>{r(e?JSON.parse(e):null),a(!1)}).catch(e=>{console.error(e),s(e.message||`Failed to load layout`),a(!1)})},[e,c]),i?t(`div`,{className:`px-4 py-8`,children:t(R0,{})}):o?t(`div`,{className:`px-4 py-2 text-destructive text-sm`,children:o}):n?t(At,{className:`w-full`,data:n}):null}function V0({pageNumber:e}){let[r,i]=G(null),[a,o]=G(!0),[s,c]=G(null),{markdownProvider:l}=I0();return H(()=>{o(!0),c(null),l.getPageMarkdown(e).then(e=>{i(e),o(!1)}).catch(e=>{console.error(e),c(e.message||`Failed to load markdown`),o(!1)})},[e,l]),a?n(`div`,{className:`h-full flex flex-col items-center justify-center gap-2`,children:[t(R0,{}),t(`span`,{className:`text-sm text-muted`,children:`Loading...`})]}):s?t(`div`,{className:`px-4 py-2 text-destructive text-sm`,children:s}):t(`div`,{className:`px-4 py-2 prose prose-sm max-w-none dark:prose-invert`,children:r?t(Nt,{children:r}):t(`div`,{children:`No markdown content available`})})}Q(),xY();var H0=class extends ct{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`PDF View error:`,e,t)}render(){return this.state.hasError?t(`div`,{className:`fixed inset-0 bg-background z-50 flex items-center justify-center`,children:n(`div`,{className:`flex flex-col items-center gap-4 p-8 max-w-md`,children:[t(M,{title:Xt.t(`pdf.failedToLoadViewer`,{ns:Yt}),children:this.state.error?.message||`An unexpected error occurred`}),this.props.onClose&&t(o,{variant:`outline`,onClick:this.props.onClose,children:`Close`})]})}):this.props.children}};function U0({objectId:e,onClose:r}){let{t:i}=K(),{client:a}=q(),{data:s,error:c}=Ye(()=>a.store.objects.retrieve(e,`+text`),[e]);return c?t(`div`,{className:`fixed inset-0 bg-background z-50 flex items-center justify-center`,children:n(`div`,{className:`flex flex-col items-center gap-4 p-8 max-w-md`,children:[t(M,{title:i(`pdf.fetchingDocumentFailed`),children:Ge(c)}),r&&t(o,{variant:`outline`,onClick:r,children:`Close`})]})}):s?t(H0,{onClose:r,children:t(`div`,{className:`fixed inset-0 bg-background z-50 flex items-center justify-center`,children:t(P0,{object:s,children:t(W0,{object:s,onClose:r})})})}):n(`div`,{className:`fixed inset-0 bg-background z-50 flex flex-col`,children:[t(`div`,{className:`flex h-9 items-center justify-end shrink-0 bg-sidebar px-2 border-b border-sidebar-border`,children:r&&t(o,{variant:`ghost`,size:`xs`,onClick:r,title:i(`pdf.close`),children:t(Gb,{className:`size-4`})})}),t(`div`,{className:`flex-1 flex items-center justify-center`,children:t(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-primary`})})]})}function W0({object:e,onClose:r}){let{t:i}=K(),{count:a,pdfUrl:s,pdfUrlLoading:c}=I0(),[l,u]=G(1);return n(Ce,{direction:`horizontal`,className:`absolute inset-0`,children:[t(Se,{defaultSize:50,minSize:20,maxSize:80,className:`bg-muted`,children:t(hY,{pdfUrl:s,pdfUrlLoading:c,pageCount:a,className:`h-full`,currentPage:l,onChange:u})}),t(xe,{className:`w-[4px] bg-border cursor-ew-resize`}),n(Se,{defaultSize:50,minSize:20,className:`flex flex-col`,children:[n(`div`,{className:`flex h-9 items-center justify-between shrink-0 bg-sidebar px-2 border-b border-sidebar-border`,children:[t(`div`,{className:`flex items-center gap-x-2`,children:t(L0,{object:e})}),t(`span`,{className:`text-xs text-muted`,children:i(`pdf.pageOf`,{pageNumber:l,totalPages:a})}),t(`div`,{className:`flex items-center gap-x-2`,children:!!r&&t(o,{variant:`ghost`,size:`xs`,onClick:r,title:i(`pdf.close`),children:t(Gb,{className:`size-4`})})})]}),t(`div`,{className:`flex-1 overflow-auto px-2`,children:t(z0,{pageNumber:l,viewType:`markdown`})})]})]})}const G0=[`image/jpeg`,`image/jpg`,`image/png`,`image/gif`,`image/webp`,`image/svg+xml`],K0=[`video/mp4`,`video/webm`],q0=[`audio/mp4`,`audio/m4a`,`audio/x-m4a`,`audio/mpeg`,`audio/ogg`,`audio/wav`,`audio/webm`];function J0(e){let t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=Math.floor(e%60);return t>0?`${t}:${n.toString().padStart(2,`0`)}:${r.toString().padStart(2,`0`)}`:`${n}:${r.toString().padStart(2,`0`)}`}function Y0({url:e,source:r,object:i,className:a}){let{t:o}=K(),{client:s}=q(),[c,l]=G(e),[u,d]=G(!e&&(!!r||!!i)),f=i?.metadata,p=(f?.renditions||[]).find(e=>e.name===cn),m=i?.content?.type&&q0.includes(i.content.type),h=!!i&&i.metadata?.type===un.Audio&&!p&&!m;return H(()=>{if(e){l(e),d(!1);return}l(void 0),r||i?(d(!0),(async()=>{try{if(r){let e=await s.files.getDownloadUrl(r);l(e.url);return}if(!i||i.metadata?.type!==un.Audio)return;let e;p?.content?.source?e=await s.files.getDownloadUrl(p.content.source):m&&i.content?.source&&(e=await s.files.getDownloadUrl(i.content.source)),e&&l(e.url)}catch(e){console.error(`Failed to get audio URL`,e)}finally{d(!1)}})()):d(!1)},[e,r,i,p,m,s]),h?t(`div`,{className:`flex justify-center items-center h-[200px] text-muted ${a??``}`.trim(),children:n(`div`,{className:`text-center`,children:[t(`p`,{children:o(`store.noAudioRendition`)}),t(`p`,{className:`text-sm mt-2`,children:o(`store.audioFormatRequired`)})]})}):u?t(`div`,{className:`flex justify-center items-center h-[200px] ${a??``}`.trim(),children:t(je,{size:`md`})}):c?n(`div`,{className:`flex flex-col items-center gap-4 ${a??``}`.trim(),children:[t(`audio`,{src:c,controls:!0,className:`w-full max-w-2xl`,children:`Your browser does not support the audio tag.`}),f?.duration&&n(`div`,{className:`text-sm text-muted`,children:[`Duration: `,J0(f.duration)]})]}):t(`div`,{className:`flex justify-center items-center h-[200px] text-muted ${a??``}`.trim(),children:`Failed to load audio`})}function X0({url:e,source:n,object:r,className:i}){let{client:a}=q(),[o,s]=G(e),[c,l]=G(!e&&(!!n||!!r));return H(()=>{if(e){s(e),l(!1);return}s(void 0),n||r?(l(!0),(async()=>{try{if(n){let e=await a.files.getDownloadUrl(n);s(e.url);return}if(!r||r.metadata?.type!==un.Image)return;let e=r.content?.type&&G0.includes(r.content.type);try{let e=await a.objects.getRendition(r.id,{format:mn.jpeg,generate_if_missing:!1,sign_url:!0});if(e.status===`found`&&e.renditions?.length){s(e.renditions[0]);return}}catch{}if(e&&r.content?.source){let e=await a.files.getDownloadUrl(r.content.source);s(e.url)}}finally{l(!1)}})()):l(!1)},[e,n,r,a]),c?t(`div`,{className:i,children:t(je,{size:`md`})}):o?t(`img`,{src:o,alt:r?.name,className:`w-full object-contain ${i??``}`.trim()}):null}function Z0({url:e,source:r,object:i,className:a}){let{t:o}=K(),{client:s}=q(),[c,l]=G(e),[u,d]=G(),[f,p]=G(!e&&(!!r||!!i)),m=i?.metadata?.renditions||[],h=m.find(e=>e.content.type===`video/mp4`)||m.find(e=>e.content.type===`video/webm`),g=i?.content?.type&&K0.includes(i.content.type),_=m.find(e=>e.name===vn),v=!!i&&i.metadata?.type===un.Video&&!h&&!g;return H(()=>{if(e){l(e),p(!1);return}l(void 0),d(void 0),r||i?(p(!0),(async()=>{try{if(r){let e=await s.files.getDownloadUrl(r);l(e.url);return}if(!i||i.metadata?.type!==un.Video)return;let e;h?.content?.source?e=await s.files.getDownloadUrl(h.content.source):g&&i.content?.source&&(e=await s.files.getDownloadUrl(i.content.source)),e&&l(e.url)}catch(e){console.error(`Failed to get video URL`,e)}finally{p(!1)}})()):p(!1)},[e,r,i,h,g,s]),H(()=>{_?.content?.source&&s.files.getDownloadUrl(_.content.source).then(e=>d(e.url)).catch(e=>console.error(`Failed to load poster image`,e))},[_,s]),v?t(`div`,{className:`flex justify-center items-center h-[400px] text-muted ${a??``}`.trim(),children:n(`div`,{className:`text-center`,children:[t(`p`,{children:o(`store.noVideoRendition`)}),t(`p`,{className:`text-sm mt-2`,children:o(`store.videoFormatRequired`)})]})}):f?t(`div`,{className:`flex justify-center items-center h-[400px] ${a??``}`.trim(),children:t(je,{size:`md`})}):c?t(`video`,{src:c,poster:u,controls:!0,className:`w-full h-full object-contain ${a??``}`.trim(),children:`Your browser does not support the video tag.`}):t(`div`,{className:`flex justify-center items-center h-[400px] text-muted ${a??``}`.trim(),children:`Failed to load video`})}Q();function Q0({oauthProviderId:r,onAuthChange:i}){let{client:a}=q(),{t:o}=K(),[s,c]=G(null),[l,u]=G(!0),[d,f]=G(!1),[p,m]=G(!1),h=V(async()=>{try{u(!0);let e=await a.oauthProviders.getStatus(r);c(e)}catch(e){console.error(`Failed to load OAuth provider status:`,e)}finally{u(!1)}},[a,r]);H(()=>{h()},[h]);let{openOAuthPopup:g}=pO({onComplete:()=>{f(!1),h(),i?.()},onError:e=>{console.error(`OAuth provider auth failed:`,e),f(!1)}});return l?t(dO,{className:`size-4`}):s?.authenticated?n(`div`,{className:`flex items-center gap-2`,children:[n(`div`,{className:`flex items-center gap-1 text-success text-sm`,children:[t(Ih,{className:`size-4`}),t(`span`,{children:o(`oauthProvider.connected`)})]}),t(oT,{variant:`outline`,size:`sm`,onClick:async()=>{if(!p)try{m(!0),await a.oauthProviders.disconnect(r),await h(),i?.()}catch(e){console.error(`Failed to disconnect OAuth provider:`,e)}finally{m(!1)}},disabled:p,children:p?t(dO,{className:`size-3`}):o(`oauthProvider.disconnect`)})]}):t(oT,{variant:`outline`,size:`sm`,onClick:async()=>{if(!d)try{f(!0);let e=await a.oauthProviders.authorize(r);e.authorization_url&&g(e.authorization_url)}catch(e){console.error(`Failed to authorize OAuth provider:`,e),f(!1)}},disabled:d,children:d?n(e,{children:[t(dO,{className:`size-4`}),t(`span`,{children:o(`oauthProvider.authenticating`)})]}):n(e,{children:[t(Dg,{className:`size-4 me-1`}),t(`span`,{children:o(`oauthProvider.authenticate`)})]})})}function $0(...e){let t=Array.from(e);return t.__AnyOf__=!0,t}function e2(...e){return Array.from(e)}function t2(e){return e.__AnyOf__===!0}function n2(e){if(e&&typeof e==`object`&&`status`in e&&typeof e.status==`number`)return e.status}function r2(e){let t=n2(e);return t===0||t===502||t===503||t===504||e instanceof Error&&e.name===`TimeoutError`}function i2(e,t){let n=U(()=>t?JSON.stringify(t):void 0,[t]),r=!!(t&&!t.permissions),[i,a]=G(0),[o,s]=G(),c=V(()=>a(e=>e+1),[]);return H(()=>{if(!r)return;let t=new AbortController,a=!1,o=0,c,l,u=t=>s({client:e,tokenKey:n,attempt:i,state:t}),d=()=>{a=!0,clearTimeout(f),clearTimeout(p),clearTimeout(l),t.abort()},f=setTimeout(()=>u({status:`retrying`}),5e3),p=setTimeout(()=>{d(),u({status:`error`,error:c})},6e4),m=async()=>{try{let n=await e.iam.roles.listSystem({signal:t.signal,timeoutMs:15e3,retryPolicy:!1});if(a)return;d(),u({status:`ready`,roles:n})}catch(e){if(a)return;if(c=e,!r2(e)){d(),u({status:`error`,error:e});return}u({status:`retrying`});let t=Math.min(1e3*2**o++,8e3)*(.5+Math.random()*.5);l=setTimeout(()=>{m()},t)}};return u({status:`loading`}),m(),d},[e,n,r,i]),{state:o?.client===e&&o.tokenKey===n&&o.attempt===i?o.state:{status:`loading`},retry:c}}var a2=class{system_roles;roles;permissions;constructor(e,t=[]){this.system_roles=t;let n=[...e.account_roles||[],...e.project_roles||[]],r=new Set(n);this.roles=r;let i=e.permissions??o2(n,t),a=e.type===bn.OAuthAccess?new Set(e.permissions??[]):void 0;this.permissions=new Set(a?i.filter(e=>a.has(e)):i)}hasPermission(e){if(typeof e==`string`)return this.permissions.has(e);if(t2(e))return e.some(e=>this.permissions.has(e));for(let t of e)if(!this.permissions.has(t))return!1;return!0}};function o2(e,t){let n=new Map(t.map(e=>[e.name,e.permissions])),r=new Set;for(let t of e)for(let e of n.get(t)??[])r.add(e);return Array.from(r)}const s2=dt(void 0);function c2(){let e=_t(s2);if(!e)throw Error(`UserPermissionContext cannot be used outside UserPermissionProvider`);return e}function l2({children:r,loadingIcon:i}){let{t:a}=K(),s=q(),c=s.authToken,{state:l,retry:u}=i2(s.client,c),d=U(()=>{if(c){if(c.permissions)return new a2(c);if(l.status===`ready`)return new a2(c,l.roles)}},[c,l]);if(c&&!d){let r=l.status===`error`,c=r?n2(l.error):void 0,d=c===401,f=c===403,p=a(d?`auth.recovery.credential.title`:f?`shell.accessDenied`:r?`permissions.connectionFailed`:`permissions.connecting`);return t(`div`,{className:`flex min-h-dvh items-center justify-center bg-background px-6 text-foreground`,children:n(`div`,{className:`w-full max-w-md space-y-6 text-center`,children:[t(`div`,{"aria-hidden":`true`,className:`flex justify-center`,children:i||!r&&t(je,{size:`2xl`,className:`text-primary`})}),n(`div`,{role:r?`alert`:`status`,"aria-live":r?`assertive`:`polite`,className:`space-y-2`,children:[t(`h1`,{className:`text-xl font-semibold`,children:p}),t(`p`,{className:`text-muted`,children:d?a(`auth.recovery.credential.body`):f?a(`permissions.accessDenied`):r?a(`permissions.tryAgainLater`):l.status===`retrying`?a(`permissions.retrying`):a(`permissions.loadingPermissions`)})]}),r&&n(e,{children:[t(o,{variant:`outline`,onClick:d||f?()=>s.signOut():u,children:a(d||f?`auth.recovery.useDifferentAccount`:`auth.recovery.tryAgain`)}),l.error!=null&&n(`details`,{className:`text-start text-sm text-muted`,children:[t(`summary`,{className:`cursor-pointer`,children:a(`auth.recovery.technicalDetails`)}),t(`pre`,{className:`mt-2 max-h-48 overflow-auto whitespace-pre-wrap wrap-break-word`,children:Ge(l.error)})]})]})]})})}return d&&t(s2.Provider,{value:d,children:r})}function u2({permission:e,isDisabled:n,title:r,children:i,...a}){return c2().hasPermission(e)?t(o,{isDisabled:n,title:r,...a,children:i}):null}function d2({permission:e,...n}){return c2().hasPermission(e)?t(ar,{...n}):null}const f2=new WeakMap;function p2(e,t){let n=f2.get(e);n||(n=new Map,f2.set(e,n));let r=n.get(t);return r||(r=e.types.catalog.resolve(t).then(e=>e??void 0,()=>{f2.get(e)?.delete(t)}),n.set(t,r)),r}function m2(e,t){let n=f2.get(e);n&&(t?n.delete(t):n.clear())}Q();function h2(e){let t=e.configuration?.defaults?.system?.agent??e.configuration?.defaults?.base;return{environment:t?.environment,model:t?.model}}function g2(e){return e.name}function _2(e){return e.name}function v2(e){return e.split(`/`).filter(Boolean).pop()||e}function y2({value:e,onChange:r,disabled:i=!1,isLoading:a=!1}){let{client:s}=q(),{t:c}=K(),[l,u]=G([]),[d,f]=G([]),[p,m]=G(!0),[h,g]=G(!1),_=W(void 0);H(()=>{let e=!1;return m(!0),s.environments.list().then(t=>{e||u(t.slice().sort((e,t)=>e.name.localeCompare(t.name)))}).catch(t=>{console.warn(`Failed to list document editing environments`,t),e||u([])}).finally(()=>{e||m(!1)}),()=>{e=!0}},[s]),H(()=>{if(!e.environment){f([]),g(!1);return}let t=!1,n=e.environment;return g(!0),s.environments.retrieve(n).then(e=>{t||f((e.enabled_models??[]).map(e=>({id:e.id,name:e.name||e.id})).sort((e,t)=>e.name.localeCompare(t.name)))}).catch(e=>{console.warn(`Failed to load document editing models`,e),t||f([])}).finally(()=>{t||g(!1)}),()=>{t=!0}},[s,e.environment]);let v=l.find(t=>t.id===e.environment),y=U(()=>{if(e.model)return d.find(t=>t.id===e.model)??{id:e.model,name:v2(e.model)}},[d,e.model]),b=e=>{_.current=e.id,r({environment:e.id}),s.environments.retrieve(e.id).then(t=>{if(_.current!==e.id)return;let n=t.default_model??t.enabled_models?.[0]?.id;r({environment:e.id,model:n})}).catch(e=>{console.warn(`Failed to select a default document editing model`,e)})},x=t=>{_.current=void 0,r({environment:e.environment,model:t.id})},S=y?.name||c(`agent.documentEditingSelectModel`);return n(he,{children:[t(_e,{asChild:!0,children:n(o,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 max-w-[15rem] gap-1.5 px-2 text-xs`,"aria-label":c(`agent.documentEditingConfiguration`),title:c(`agent.documentEditingConfiguration`),children:[a?t(je,{size:`sm`}):t(Gy,{className:`size-3.5 shrink-0`}),t(`span`,{className:`min-w-0 truncate`,children:S}),t(rh,{className:`size-3.5 shrink-0 opacity-70`})]})}),n(ge,{align:`end`,className:`z-[1000000] w-80 space-y-3 p-3`,children:[n(`div`,{children:[t(`div`,{className:`text-sm font-semibold text-foreground`,children:c(`agent.documentEditingConfiguration`)}),t(`div`,{className:`mt-0.5 text-xs leading-4 text-muted`,children:c(i?`agent.documentEditingConfigurationLocked`:`agent.documentEditingConfigurationDescription`)})]}),n(`div`,{className:`space-y-1`,children:[t(`label`,{className:`text-xs font-medium text-foreground`,htmlFor:`document-editing-environment`,children:c(`agent.environment`)}),t(we,{id:`document-editing-environment`,by:`id`,options:l,value:v,optionLabel:g2,filterBy:`name`,placeholder:c(`agent.documentEditingSelectEnvironment`),onChange:b,disabled:i,isLoading:p})]}),n(`div`,{className:`space-y-1`,children:[t(`label`,{className:`text-xs font-medium text-foreground`,htmlFor:`document-editing-model`,children:c(`agent.model`)}),t(we,{id:`document-editing-model`,by:`id`,options:d,value:y,optionLabel:_2,filterBy:`name`,placeholder:c(`agent.documentEditingSelectModel`),onChange:x,disabled:i||!e.environment,isLoading:h,warnOnMissingValue:!1})]})]})]})}Q();function b2({isLocked:e,onToggleLock:r}){let{t:i}=K(),a=i(e?`agent.editingLockedTitle`:`agent.editingManuallyUnlockedTitle`),s=i(e?`agent.editingLockedDescription`:`agent.editingManuallyUnlockedDescription`),c=i(e?`agent.unlockEditing`:`agent.lockEditing`);return n(`div`,{className:`flex h-8 max-w-64 shrink-0 items-center gap-1 rounded-md border border-mixer-attention/30 bg-mixer-attention/10 ps-2 pe-1 text-attention`,role:e?`status`:`alert`,"aria-live":`polite`,children:[e?t(rv,{className:`size-3.5 shrink-0 animate-pulse`}):t(ov,{className:`size-3.5 shrink-0`}),t(We,{description:s,asChild:!0,children:t(`span`,{className:`min-w-0 truncate text-xs font-medium text-foreground`,children:a})}),t(`span`,{className:`sr-only`,children:s}),t(We,{description:c,asChild:!0,children:t(o,{variant:`ghost`,size:`sm`,className:`size-6 shrink-0 rounded p-0 text-attention hover:bg-mixer-attention/15`,onClick:r,"aria-label":c,children:t(e?ov:rv,{className:`size-3.5`})})})]})}const x2=/artifact:(?!agents\/)(?!documents\/)([^\s)\]"]+)/g;function S2(e){let t=new Set;for(let n of e.matchAll(x2))t.add(n[1].replace(/^\/+/,``));return[...t]}async function C2(e,t,n,r){let i=S2(t);if(i.length===0)return{content:t,persisted:[],failed:[]};let a=new Map,o=[],s=[];for(let t of i){let i=`documents/${r}/${t}`;try{await e.copyFile(`agents/${n}/${t}`,i),a.set(t,i),o.push({from:t,to:i})}catch(e){console.warn(`Failed to persist a referenced artifact; keeping a run-scoped link`,{artifact_path:t,error:e instanceof Error?e.message:String(e)}),a.set(t,`agents/${n}/${t}`),s.push(t)}}return{content:t.replace(x2,(e,t)=>{let n=a.get(t.replace(/^\/+/,``));return n?`artifact:${n}`:e}),persisted:o,failed:s}}const w2=[`ask_user`,`think`,`plan`,`update_plan`,`end_conversation`,`learn_artifact_operations`,`learn_code_execution`,`learn_content_authoring`,`learn_document_management`,`learn_document_search`,`learn_image_analysis`,`execute_shell`,`fetch_document`],T2=[`artifact_operations`,`code_execution`],E2=[`update_document`,`update_document_properties`,`create_document`,`set_document_type`,`merge_documents`,`import_file`,`create_or_update_object_type`,`disable_type`,`batch_execute`];function D2(e,t){return[`Direct edits are already saved to '${e}'. Use this compact unified diff as context only;`,`do not re-apply it. The artifact remains the current source of truth.`,"```diff",`--- a/${e}`,`+++ b/${e}`,t,"```"].join(`
1382
- `)}const O2=`document-editing`,k2=`sys:GeneralAgent`,A2=new Set,j2=new Set([`text/markdown`,`text/x-markdown`]),M2=new Set([...j2,`text/plain`]);function N2(e,t){return`${e}:${t}`}function P2(e){return A2.has(e)}function F2(e,t){t?A2.add(e):A2.delete(e)}function I2(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:void 0}function L2(e){return`document-root:${e}`}function R2(e){return`document:${e}`}function z2(e,t){return{tags:[O2,L2(t),R2(e)],properties:{resource_kind:`store_document`,document_id:e,document_root_id:t}}}function B2(e,t){return{canEdit:e,canCollaborate:t}}function V2(e){return e?.split(`;`,1)[0]?.trim().toLowerCase()||void 0}function H2(e){let t=V2(e);return t!==void 0&&j2.has(t)}function U2(e){let t=V2(e);return t!==void 0&&M2.has(t)}function W2(e,t,n,r,i=k2){if(e.interaction!==i||e.started_by!==r||e.status===`cancelled`)return!1;let a=e.tags??[];if(!a.includes(O2))return!1;let o=I2(e.properties);return a.includes(L2(n))?o?.resource_kind===`store_document`&&o.document_root_id===n:a.includes(R2(n))||a.includes(R2(t))}async function G2(e,t,n,r,i,a){for(let o of t)try{let t=await e.retrieve(o);if(W2(t,n,r,i,a))return t}catch{}}async function K2(e,t,n,r,i=k2){let a=[L2(n),R2(n),R2(t)],o=new Set;for(let s of new Set(a))try{let a=(await e.search({interaction:i,started_by:r,tags:[s],limit:20,sort:[`updated_at:desc`]})).hits.map(e=>e.id).filter(e=>!o.has(e));for(let e of a)o.add(e);let c=await G2(e,a,t,n,r,i);if(c)return c}catch{break}return(await e.list({interaction:i,started_by:r,limit:100,sort:`updated_at`,order:`desc`})).items.find(e=>e.run_kind===`agent`&&W2(e,t,n,r,i))}var q2=class extends Error{constructor(e,t){super(e,t===void 0?void 0:{cause:t}),this.name=`DocumentEditingTargetError`}};async function J2(e,t){let n=await e.retrieve(t),r=n;if(n.revision&&!n.revision.head){let i=(await e.getRevisions(n.id)).filter(e=>e.revision?.head===!0);if(i.length!==1)throw new q2(`Expected one head revision for document ${t}, found ${i.length}`);if(r=await e.retrieve(i[0].id),r.revision?.head!==!0)throw new q2(`Resolved document ${r.id} is no longer the current head`)}let i=r.content?.etag;if(!i)throw new q2(`Document ${r.id} has no content ETag`);let a=await e.getObjectText(r.id);if(typeof a.text!=`string`)throw new q2(`Document ${r.id} has no text content`);return{id:r.id,etag:i,content:a.text}}var Y2=class extends be{idOf(e){return e.id}labelOf(e){return e.label}descriptionOf(e){return e.description}selectedClassName(e){return`border-3 border-primary`}};function X2({isOpen:e,onClose:r,onConfirm:i,isLoading:a,uploadedFileName:s}){let{t:c}=K(),l=U(()=>[{id:`update`,label:c(`modal.saveVersion.updateCurrent`),description:c(s?`modal.saveVersion.updateWithFileDescription`:`modal.saveVersion.updateDescription`)},{id:`new-version`,label:c(`modal.saveVersion.createNew`),description:c(s?`modal.saveVersion.createWithFileDescription`:`modal.saveVersion.createDescription`)}],[c,s]),u=s?l[1]:l[0],[d,f]=G(u),[p,m]=G(``),h=new Y2;H(()=>{e&&(f(u),m(``))},[u,e]);let g=d?.id===`new-version`;return n(se,{isOpen:e,onClose:r,className:`sm:max-w-md`,children:[t(ue,{children:c(`modal.saveChanges`)}),t(ce,{children:n(`div`,{className:`space-y-4`,children:[s&&t(`div`,{className:`mb-4 p-3 bg-info rounded-md`,children:n(`p`,{className:`text-sm text-info font-medium`,children:[c(`modal.saveVersion.replaceFile`),` `,t(`span`,{className:`font-bold`,children:s})]})}),t(`p`,{className:`text-sm text-mixer-muted/5`,children:c(`modal.saveVersion.howToSave`)}),t(ye,{adapter:h,options:l,selected:d,onSelect:e=>{f(e)}}),g&&t(L,{label:c(`modal.saveVersion.versionLabel`),description:c(`modal.saveVersion.versionLabelDescription`),className:`mt-3 ps-8`,children:t(te,{value:p,onChange:m,placeholder:c(`modal.saveVersion.versionLabelPlaceholder`),className:`w-full`})})]})}),n(le,{children:[t(o,{variant:`secondary`,onClick:r,disabled:a,children:c(`modal.cancel`)}),t(o,{variant:`primary`,onClick:async()=>{await i(g,g?p:void 0)},isLoading:a,children:c(`modal.save`)})]})]})}Q();function Z2(e){return e.length>12?`${e.slice(0,4)}…${e.slice(-4)}`:e}function Q2(e){return`drafts/${e}.md`}function $2(e,t,n,r,i){return[`You are collaborating with the user on one specific Markdown document in Vertesia.`,`Canonical document: [${e.name||e.content?.name||`Document`}](store:${t})`,`Canonical base revision ID: ${t}`,`Canonical base ETag: ${n??`unavailable`}`,`Working copy artifact: ${r}`,``,`The working copy was hydrated and read before your first turn. It is the source of truth for this editing`,`session. Apply requested changes only to that artifact using edit_artifact. Preserve all unrelated content`,`exactly. User block edits may already be applied to the artifact; acknowledge them and continue from the`,`current artifact generation. Attachments may contain review comments to apply in bulk.`,``,`Do not call update_document, create_document, or write_artifact for this working copy. The user publishes`,`the artifact back to the canonical document with the Save to document button, which enforces the base ETag.`,``,`You may use execute_shell to regenerate charts, diagrams, and other derived assets. Write generated files`,`under '/home/daytona/out/' so they sync back to the run, then reference them from Markdown with a run-local`,`link such as 'artifact:out/chart.png'. Saving the document persists and rewrites those links automatically.`,``,`Images: never inline image data as base64 data URIs — it bloats the document and cannot be reliably edited.`,`Keep existing image references (e.g. 'artifact:documents/…' URLs) exactly as they are: they point to durable`,`storage that outlives this session. Files already in this run's artifact space may be referenced with`,`run-local links like 'artifact:files/photo.png' — publishing copies them into durable storage and rewrites`,`the links automatically.`,``,`User request: ${i}`].join(`
1383
- `)}function e4(e,t,n){return[`The canonical document was updated outside this session, so publishing the working copy was rejected.`,`1) Fetch the latest canonical revision ${t} with fetch_document into 'drafts/${e}.theirs.md'.`,`2) Compare it with the working copy '${n}' and merge the external changes into the working copy with edit_artifact, preserving this session's edits.`,`3) Reply with a short list of what was merged, plus any conflicting passages and how you resolved them, so I can review before saving again.`].join(`
1384
- `)}function t4(e,t,n){return[`Summarize the changes in the working copy '${n}' relative to the original document revision ${t}.`,`If you no longer have the original content, fetch it with fetch_document into 'drafts/${e}.base.md'.`,`Do not modify the working copy.`,`Reply with a concise changelog: grouped bullets, most important first, suitable for a revision note.`].join(`
1385
- `)}function n4(e){if(!(!e||typeof e!=`object`||!(`status`in e)))return typeof e.status==`number`?e.status:void 0}function r4({original:e,workingCopy:r}){let i=U(()=>Vt(e,r),[e,r]),a=U(()=>({added:i.reduce((e,t)=>e+(t.type===`added`?t.text.length:0),0),removed:i.reduce((e,t)=>e+(t.type===`removed`?t.text.length:0),0)}),[i]);return n(`div`,{className:`flex h-full min-h-0 flex-col bg-muted/10`,children:[n(`div`,{className:`flex shrink-0 items-center justify-end gap-3 border-b border-mixer-muted/20 px-5 py-2 text-xs`,children:[n(`span`,{className:`text-destructive`,children:[`−`,a.removed]}),n(`span`,{className:`text-success`,children:[`+`,a.added]})]}),t(`div`,{className:`min-h-0 flex-1 overflow-auto p-5`,children:t(`pre`,{className:`mx-auto max-w-5xl whitespace-pre-wrap break-words rounded-lg border border-mixer-muted/25 bg-background p-5 font-mono text-xs leading-6 shadow-sm`,children:i.map((e,n)=>e.type===`removed`?t(`del`,{className:`bg-mixer-destructive/15 text-destructive line-through decoration-destructive/50`,children:e.text},n):e.type===`added`?t(`ins`,{className:`bg-mixer-success/15 text-success no-underline`,children:e.text},n):t(`span`,{children:e.text},n))})})]})}function i4({object:r,initialContent:i=``,onDocumentUpdated:a,onClose:s,sendMessageRef:c,model:l,startImmediately:u=!1}){let{client:d,project:f,store:m,user:h}=q(),{t:g}=K(),_=nt(),v=W(null),y=c??v,[x,S]=G(),[C,w]=G(!1),[T,E]=G(!1),[D,O]=G(!0),[k,A]=G(!0),[j,M]=G(!1),[N,P]=G(0),[F,I]=G(!1),L=JSON.stringify(l?{environment:l.env,model:l.model,model_options:l.options}:{}),ee=l!==void 0,R=U(()=>JSON.parse(L),[L]),[te,ne]=G(!ee),[re,ie]=G(!1),[ae,oe]=G(!1),[se,ce]=G(!1),[le,ue]=G(!1),[de,fe]=G(!1),[pe,me]=G(!1),[he,ge]=G({key:0}),[_e,ve]=G(i),[ye,be]=G(!1),[we,Te]=G(i),[Ee,De]=G(i),[Oe,ke]=G(`document`),[Ae,Me]=G(),[Ne,Pe]=G(r.id),[Fe,Ie]=G(r.content?.etag),[Le,Re]=G(),[ze,Be]=G(R),Ve=W(ee?`host`:`none`),He=W(void 0),Ue=W(new Set),z=W(void 0),Ke=W(!1),qe=W(null),Je=r.revision?.root||r.id,Ye=U(()=>Q2(Je),[Je]),Xe=h?.sub?`user:${h.sub}`:void 0,Ze=`${f?.id??`no-project`}:${Je}`,Qe=`${Ze}:${r.type?.id??`no-type`}`,$e=Le?.key===Qe?Le.interaction:void 0,et=W(Ze),tt=W({editingScopeKey:Ze,id:r.id}),rt=W({documentId:r.id,documentRootId:Je}),it=ye&&_e!==Ee,at=le&&!de;rt.current.documentRootId!==Je&&(rt.current={documentId:r.id,documentRootId:Je}),tt.current.editingScopeKey!==Ze&&(tt.current={editingScopeKey:Ze,id:r.id}),H(()=>{et.current!==Ze&&(et.current=Ze,Ve.current=ee?`host`:`none`,Be(R),ne(!ee),Ue.current.clear(),ve(i),Te(i),De(i),be(!1),me(!1),ue(!1),fe(!1),Ke.current=!1,ke(`document`),Pe(r.id),Ie(r.content?.etag))},[Ze,ee,i,r.content?.etag,r.id,R]),H(()=>{let e=!1,t=Ze,n=tt.current.id;return A(!0),M(!1),J2(m.objects,n).then(n=>{e||tt.current.editingScopeKey!==t||(tt.current={editingScopeKey:t,id:n.id},rt.current={documentId:n.id,documentRootId:Je},Pe(n.id),Ie(n.etag),Te(n.content),De(n.content))}).catch(n=>{console.warn(`Failed to resolve the document editing target`,{error:n,attempt:N}),!e&&tt.current.editingScopeKey===t&&M(!0)}).finally(()=>{!e&&tt.current.editingScopeKey===t&&A(!1)}),()=>{e=!0}},[Je,Ze,m.objects,N]),H(()=>{let e=!1,t=r.type?.id;if(!t){Re({key:Qe,interaction:k2});return}return p2(d,t).then(t=>{e||Re({key:Qe,interaction:t?.editing?.interaction?.trim()||`sys:GeneralAgent`})}),()=>{e=!0}},[d,Qe,r.type?.id]),H(()=>{x||Ve.current===`run`||(ee?(Ve.current=`host`,Be(R),ne(!1)):Ve.current===`host`&&(Ve.current=`none`,Be({})))},[x,ee,R]),H(()=>{if(ee){ne(!1);return}if(!f){ne(!1);return}let e=!1,t=Ze;return ne(!0),d.projects.retrieve(f.id).then(n=>{e||et.current!==t||Ve.current!==`none`||(Ve.current=`project`,Be(h2(n)))}).catch(e=>{console.warn(`Failed to load the default document editing model`,e)}).finally(()=>{e||ne(!1)}),()=>{e=!0}},[d,Ze,ee,f]),H(()=>{if(S(void 0),!Xe||!$e){O(!1);return}let e=!1;return O(!0),K2(d.agents,rt.current.documentId,Je,Xe,$e).then(t=>{e||!t||(S(t.id),t.config?.environment&&t.config.model&&(Ve.current=`run`,Be({environment:t.config.environment,model:t.config.model,model_options:t.config.model_options})))}).catch(e=>{console.warn(`Failed to look up an existing document editing run`,e)}).finally(()=>{e||O(!1)}),()=>{e=!0}},[d,Je,$e,Xe]);let B=V(e=>{Ve.current=`user`,Be(e)},[]),ot=V(()=>{x&&navigator.clipboard.writeText(x).then(()=>_({status:`success`,title:g(`agent.runIdCopied`),duration:2e3})).catch(e=>console.warn(`Failed to copy the agent run id`,e))},[x,g,_]),st=V(async()=>{if(!(!x||T)){E(!0);try{await d.agents.terminate(x,`cancel`),_({status:`success`,title:g(`agent.workflowCancelled`),duration:2e3})}catch(e){console.warn(`Failed to terminate the document editing run`,e)}finally{E(!1)}Ue.current.clear(),S(void 0),be(!1),ve(Ee),me(!1),Ke.current=!1,ue(!1),fe(!1)}},[x,d.agents,T,Ee,g,_]),ct=V(async(e,t)=>{if(!(!f||!$e||D||k||j||C||te)){w(!0);try{if(!ze.environment||!ze.model){_({status:`error`,title:g(`agent.documentEditingDefaultsRequired`),duration:5e3});return}let n=$2(r,Ne,Fe,Ye,e?.trim()||g(`agent.documentEditingInitialRequest`)),i=z2(Ne,Je),a={interaction:$e,interactive:!0,tool_approval_mode:t?.tool_approval_mode,tool_names:w2,excluded_tools:E2,initial_skills:T2,initial_tool_calls:[{id:`hydrate-working-copy`,tool:`fetch_document`,input:{id:Ne,mode:`content`,output_artifact:{path:Ye}}},{id:`read-working-copy`,tool:`read_artifact`,input:{path:Ye}}],data:{user_prompt:n},config:{environment:ze.environment,model:ze.model,model_options:ze.model_options},started_by:Xe,tags:i.tags,properties:i.properties},o=await d.agents.start(a);return S(o.id),{agent_run_id:o.id}}catch(e){console.error(`Failed to start document editing agent`,e),_({status:`error`,title:g(`agent.documentEditingStartFailed`),description:e instanceof Error?e.message:void 0,duration:5e3});return}finally{w(!1)}}},[d.agents,Je,Ye,ze,$e,te,D,k,C,r,f,Xe,g,Ne,Fe,j,_]),lt=V((e,t)=>{z.current=t,ve(e),be(!0)},[]);H(()=>{if(!u||x||!f||!$e||D||k||j||C||te||!ze.environment||!ze.model)return;let e=JSON.stringify({scope:Ze,interaction:$e,document:Ne,configuration:ze});He.current!==e&&(He.current=e,ct(g(`agent.documentEditingStartRequest`),{tool_approval_mode:`full_control`}))},[x,$e,Ze,ze,te,D,k,C,f,u,ct,g,Ne,j]);let ut=V(e=>{let t=Ke.current;Ke.current=e,ue(e),e||(fe(!1),t&&ge(e=>({key:e.key+1})))},[]),dt=V((e,t)=>{let n=y.current;if(!n){_({status:`warning`,title:g(`agent.artifactEditingUnavailable`),duration:3e3});return}n(e,t)},[y,g,_]),ft=V(e=>{let t=e.anchor.block_type.replaceAll(`_`,` `),n=e.comment?.trim()||g(`agent.editedSelectionMessage`,{blockType:t});dt(n,{editing_action:e})},[dt,g]),pt=V(async(e,t)=>{if(!(!ye||!Fe||!it||at||re||k||j)){ie(!0);try{let n=_e;x&&(n=(await C2(d.files,n,x,crypto.randomUUID())).content);let i=r.content?.type||`text/markdown`,o=r.content?.name||`content.md`,s=new File([new Blob([n],{type:i})],o,{type:i}),c=await m.objects.update(Ne,{content:s},{createRevision:e,revisionLabel:t,ifMatch:Fe});if(Pe(c.id),Ie(c.content?.etag),De(n),Me(void 0),oe(!1),a?.(c.id,e),_({status:`success`,title:g(`store.textSaved`),duration:2500}),x&&n!==_e&&z.current)try{await d.agents.updateArtifactContent(x,Ye,{content:n,generation:z.current}),ge(e=>({key:e.key+1}))}catch(e){console.warn(`Failed to sync persisted artifact links into the working copy`,e)}}catch(e){let t=n4(e),n=t===412;if(t===412||t===400)try{let e=await J2(m.objects,Ne);(e.id!==Ne||t===412)&&(n=!0,Pe(e.id),Ie(e.etag),Me({headId:e.id}))}catch(e){console.warn(`Failed to resolve the new head after a save conflict`,e)}_({status:`error`,title:g(`store.errorSavingText`),description:n?g(`store.textConflict`):Ge(e,g(`store.errorSavingTextDefault`)),duration:5e3})}finally{ie(!1)}}},[x,_e,ye,d.agents,d.files,Ye,it,at,k,re,r.content?.name,r.content?.type,a,m.objects,g,Ne,Fe,j,_]),mt=V(()=>{let e=y.current;if(!e||!Ae){_({status:`warning`,title:g(`agent.artifactEditingUnavailable`),duration:3e3});return}e(e4(Je,Ae.headId,Ye)),Me(void 0),ke(`document`)},[Je,Ye,y,Ae,g,_]),ht=V(()=>{let e=y.current;if(!e){_({status:`warning`,title:g(`agent.artifactEditingUnavailable`),duration:3e3});return}e(t4(Je,tt.current.id,Ye))},[Je,Ye,y,g,_]),gt=V(async()=>Oe!==`editor`||!pe||!!await qe.current?.(),[pe,Oe]),_t=V(async e=>{e!==Oe&&await gt()&&ke(e)},[gt,Oe]),vt=V(async()=>{await gt()&&s?.()},[gt,s]),yt=V(async()=>{let e=y.current;if(!e||!x||at||se){_({status:`warning`,title:g(`agent.artifactEditingUnavailable`),duration:3e3});return}ce(!0);try{let t=await qe.current?.();if(!t)return;let n=Bt(t.previous,t.current,{context:1});n&&e(D2(Ye,n)),me(!1),_({status:`success`,title:g(`agent.changesSentToAgent`),duration:2e3})}finally{ce(!1)}},[x,Ye,at,se,y,g,_]);return n(`div`,{className:`flex h-full min-h-0 flex-col`,children:[n(`div`,{className:`flex h-14 shrink-0 items-center justify-between gap-3 border-b border-mixer-muted/20 px-4`,children:[n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`truncate font-semibold`,children:r.name||r.content?.name}),n(`div`,{className:`flex items-center gap-2 text-xs text-muted`,children:[n(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[it?t(`span`,{"aria-hidden":!0,className:`size-1.5 rounded-full bg-attention`}):ye?t(eh,{className:`size-3 text-success`}):null,g(it?`store.unsavedChanges`:`store.textSaved`)]}),t(`span`,{"aria-hidden":!0,className:`text-mixer-muted/60`,children:`·`}),t(We,{description:`${g(`agent.workingCopy`)}: ${Ye}`,asChild:!0,children:n(`span`,{className:`min-w-0 truncate font-mono`,children:[`drafts/`,Z2(Je),`.md`]})}),t(`span`,{"aria-hidden":!0,className:`text-mixer-muted/60`,children:`·`}),t(We,{description:`${g(`agent.originalDocument`)}: ${tt.current.id}`,asChild:!0,children:n(`span`,{className:`shrink-0 font-mono`,children:[g(`agent.originalDocument`).toLowerCase(),` `,Z2(tt.current.id)]})})]})]}),n(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[n(`div`,{className:`flex items-center rounded-md border border-mixer-muted/25 bg-muted/10 p-0.5`,children:[n(o,{variant:Oe===`document`?`secondary`:`ghost`,size:`sm`,className:`h-7 gap-1.5`,onClick:()=>void _t(`document`),children:[t(Gg,{className:`size-3.5`}),g(`agent.document`)]}),n(o,{variant:Oe===`editor`?`secondary`:`ghost`,size:`sm`,className:`h-7 gap-1.5`,onClick:()=>void _t(`editor`),children:[t(zg,{className:`size-3.5`}),g(`agent.fullEditor`)]}),n(o,{variant:Oe===`diff`?`secondary`:`ghost`,size:`sm`,className:`h-7 gap-1.5`,onClick:()=>void _t(`diff`),disabled:!ye||_e===we,children:[t(h_,{className:`size-3.5`}),g(`agent.reviewChanges`)]})]}),Oe===`diff`?n(o,{variant:`ghost`,size:`sm`,className:`h-8 gap-1.5`,onClick:ht,disabled:!ye||_e===we,children:[t(Z_,{className:`size-3.5`}),g(`agent.summarizeChanges`)]}):null,t(We,{description:g(`agent.refresh`),asChild:!0,children:t(o,{variant:`ghost`,size:`sm`,onClick:()=>ge(e=>({key:e.key+1})),disabled:!x,"aria-label":g(`agent.refresh`),children:t(hy,{className:`size-4`})})}),t(`div`,{"aria-hidden":!0,className:`mx-1 h-6 w-px bg-mixer-muted/25`}),t(y2,{value:ze,onChange:B,disabled:!!x||C||D,isLoading:te}),x?null:n(o,{variant:`primary`,size:`sm`,className:`h-8 gap-1.5`,onClick:()=>void ct(g(`agent.documentEditingStartRequest`)),disabled:C||D||k||te||j||!f||!$e||!ze.environment||!ze.model,children:[C?t(je,{size:`sm`}):t(Jy,{className:`size-4`}),g(C?`agent.startingAgent`:`agent.documentEditingStart`)]}),x?n(e,{children:[t(We,{description:x,asChild:!0,children:t(o,{variant:`ghost`,size:`sm`,className:`font-mono text-[11px] text-muted`,onClick:ot,"aria-label":g(`agent.copyRunId`),children:Z2(x)})}),t(We,{description:g(`agent.startNewConversation`),asChild:!0,children:t(o,{variant:`ghost`,size:`sm`,onClick:()=>{it?I(!0):st()},disabled:T,"aria-label":g(`agent.startNewConversation`),children:t(vy,{className:`size-4`})})})]}):null,t(`div`,{"aria-hidden":!0,className:`mx-1 h-6 w-px bg-mixer-muted/25`}),n(o,{variant:`primary`,className:`min-w-36 gap-2`,onClick:()=>oe(!0),disabled:!it||!Fe||at||re||k||j,children:[re?t(je,{size:`sm`}):t(wy,{className:`size-4`}),g(`agent.saveToDocument`)]}),s?t(o,{variant:`ghost`,size:`sm`,onClick:()=>void vt(),"aria-label":g(`agent.close`),children:t(Gb,{className:`size-4`})}):null]})]}),Ae?n(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-mixer-attention/30 bg-mixer-attention/10 px-4 py-2 text-sm`,children:[t(`span`,{className:`min-w-0 truncate text-attention`,children:g(`agent.saveConflictNotice`)}),n(`div`,{className:`flex shrink-0 items-center gap-2`,children:[t(o,{variant:`outline`,size:`sm`,onClick:mt,children:g(`agent.askAgentToReconcile`)}),t(o,{variant:`ghost`,size:`sm`,onClick:()=>Me(void 0),"aria-label":g(`agent.close`),children:t(Gb,{className:`size-4`})})]})]}):null,n(Ce,{direction:`horizontal`,className:`min-h-0 flex-1`,children:[t(Se,{defaultSize:65,minSize:35,className:`min-w-0 bg-background`,children:t(`div`,{className:`flex h-full min-h-0 flex-col`,children:t(`div`,{className:`min-h-0 flex-1`,children:Oe===`diff`?t(r4,{original:we,workingCopy:_e}):t(wt,{runId:x,path:Ye,viewMode:Oe===`editor`?`document`:`components`,baselineContent:we,initialContent:Ee,refreshKey:he.key,refreshDetails:he.details,readOnly:at,allowComments:!!x,onContentChange:lt,onAction:ft,onSendMessage:dt,onSendChangesToAgent:yt,hasUnsentChanges:it&&pe,isSendingChanges:se,sendChangesDisabled:!x||at,toolbarStatus:le?t(b2,{isLocked:at,onToggleLock:()=>fe(e=>!e)}):void 0,onDocumentEdit:()=>me(!0),flushChangesRef:qe})})})}),t(xe,{withHandle:!0}),t(Se,{defaultSize:35,minSize:25,className:`min-w-[320px]`,children:D||k?t(p,{className:`h-full`,children:t(je,{size:`lg`})}):j?n(p,{className:`h-full flex-col gap-3 px-6 text-center`,children:[t(`div`,{className:`text-sm text-muted`,children:g(`agent.failedToLoadDocument`)}),t(o,{variant:`outline`,size:`sm`,onClick:()=>P(e=>e+1),children:g(`agent.retry`)})]}):t(B1,{agentRunId:x,startWorkflow:ct,resetWorkflow:()=>S(void 0),onRestart:e=>S(e.id),sendMessageRef:y,onMessage:e=>{let t=e.details;if(!Ut(t,Ye))return;let n=`${e.timestamp}:${t?.path}:${t?.generation??``}`;Ue.current.has(n)||(Ue.current.add(n),ge(e=>({key:e.key+1,details:t})))},onAgentWorkingChange:ut,title:g(`agent.documentEditing`),initialMessage:g(`agent.documentEditingWelcome`),startButtonText:g(C?`agent.startingAgent`:`agent.startAgent`),placeholder:g(`agent.documentEditingPlaceholder`),initialToolApprovalMode:`full_control`,hideObjectLinking:!0,hideHeader:!0,showRightPanel:!1,fullWidth:!0,interactive:!0})})]}),t(b,{isOpen:F,title:g(`agent.newSessionDiscardTitle`),content:g(`agent.newSessionDiscardDescription`),onConfirm:()=>{I(!1),st()},onCancel:()=>I(!1)}),t(X2,{isOpen:ae,onClose:()=>oe(!1),onConfirm:pt,isLoading:re})]})}function a4({object:e,initialContent:n,onClose:r,onDocumentUpdated:i,sendMessageRef:a,model:o,startImmediately:s}){let{t:c}=K();return t(se,{isOpen:!0,onClose:r,size:`full`,noCloseButton:!0,disableCloseOnClickOutside:!0,className:`gap-0 overflow-hidden p-0`,description:c(`agent.documentEditingWelcome`),children:t(i4,{object:e,initialContent:n,onClose:r,onDocumentUpdated:i,sendMessageRef:a,model:o,startImmediately:s})})}function o4({isOpen:r,onClose:i,object:a,refetch:s}){let{client:c,store:l}=q(),u=nt(),{t:d}=K(),{theme:f}=tt(),p=Qn(),[m,h]=G(!1),[g,_]=G(``),[v,y]=G(!1),[b,x]=G(null),S=W(void 0),[C,w]=G(null),[T,E]=G(null),D=V(async e=>{try{let t=await l.types.retrieve(e);t.object_schema&&w(t.object_schema)}catch(e){console.error(`Failed to fetch JSON schema:`,e)}},[l.types]);H(()=>{r&&(_(JSON.stringify(a.properties||{},null,2)),a.type?.id&&D(a.type.id))},[r,a,D]);let O=e=>{C&&e.json.jsonDefaults.setDiagnosticsOptions({validate:!0,schemas:[{uri:`http://myserver/object-schema.json`,fileMatch:[`*`],schema:C}]})};function k(){if(!S.current)return;let e=S.current.getValue();try{let t=JSON.parse(e);x(t),y(!0)}catch{u({status:`error`,title:d(`store.invalidJson`),description:d(`store.pleaseFixJsonSyntax`),duration:5e3})}}let A=e=>{_(e)};async function j(e,t){try{h(!0);let n=b||JSON.parse(g);if(e){let e=await c.objects.update(a.id,{properties:n},{createRevision:!0,revisionLabel:t});e.id!==a.id&&E(e.id),u({status:`success`,title:d(`store.newVersionCreated`),description:d(`store.newVersionCreatedDesc`),duration:2e3}),y(!1),i(),e.id!==a.id&&setTimeout(()=>{p(`/objects/${e.id}`),u({status:`info`,title:d(`store.viewingNewVersion`),description:t?d(`store.viewingVersionLabel`,{label:t}):d(`store.viewingNewVersionDefault`),duration:3e3})},100)}else await l.objects.update(a.id,{properties:n}),u({status:`success`,title:d(`store.propertiesUpdated`),description:d(`store.propertiesUpdatedDesc`),duration:2e3}),s&&await s(),y(!1),i()}catch(e){u({status:`error`,title:d(`store.errorUpdatingProperties`),description:Ge(e,d(`store.errorUpdatingPropertiesDefault`)),duration:5e3}),h(!1)}}function M(){y(!1)}return n(e,{children:[n(se,{isOpen:r,onClose:i,className:`sm:max-w-[90%] md:max-w-[80%] lg:max-w-[75%] xl:max-w-[70%]`,children:[t(ue,{children:d(`store.editProperties`)}),n(ce,{children:[n(`div`,{className:`mb-2 text-sm text-muted`,children:[a.type?.name?n(`span`,{children:[`Editing properties for object type: `,t(`strong`,{children:a.type.name})]}):t(`span`,{children:d(`store.editingGenericDocument`)}),C!==null&&t(`span`,{className:`ms-2 text-success`,children:`(JSON schema validation enabled)`})]}),t(`div`,{className:`h-[75vh] border rounded-md overflow-hidden`,children:t(Pt,{value:g,language:`json`,editorRef:S,onChange:e=>A(e.state.doc.toString()),beforeMount:O,theme:f===`dark`?`vs-dark`:`vs`})})]}),n(le,{children:[t(o,{variant:`secondary`,onClick:i,children:`Cancel`}),t(o,{variant:`primary`,onClick:k,children:`Save Changes`})]})]}),t(X2,{isOpen:v,onClose:M,onConfirm:j,isLoading:m})]})}const s4=ht(()=>import(`@vertesia/ui/rich-text`).then(e=>({default:e.VertesiaMarkdownDocumentEditor})));function c4(e){switch(e){case`text/markdown`:case`text/x-markdown`:return`markdown`;case`application/json`:return`json`;case`application/xml`:case`text/xml`:return`xml`;default:return`plaintext`}}function l4({object:r,text:i,onClose:a,onSaved:s}){let{store:c}=q(),l=nt(),{t:u}=K(),{theme:d}=tt(),f=Qn(),p=W(void 0),[m,h]=G(i),[g,_]=G(!1),[v,y]=G(!1),[b,x]=G(!1),S=c4(r.content?.type),C=H2(r.content?.type);H(()=>{h(i),_(!1)},[i]);let w=V(()=>{g||_(!0)},[g]),T=V(e=>{h(e),_(e!==i)},[i]);function E(){!C&&!p.current||x(!0)}async function D(e,t){if(!C&&!p.current)return;let n=C?m:p.current?.getValue();if(n===void 0)return;let i=r.content?.type||`text/plain`,o=r.content?.name||`content.txt`;try{y(!0);let d=new Blob([n],{type:i}),p=new File([d],o,{type:i}),m=await c.objects.update(r.id,{content:p},{createRevision:e,revisionLabel:t,ifMatch:r.content?.etag});l({status:`success`,title:u(`store.textSaved`),duration:2e3}),x(!1),e&&m.id!==r.id?(a(),setTimeout(()=>{f(`/objects/${m.id}`)},100)):s()}catch(e){let t=Ge(e,u(`store.errorSavingTextDefault`)),n=(typeof e==`object`&&e&&`status`in e?e.status:void 0)===412||t.includes(`412`);l({status:`error`,title:u(`store.errorSavingText`),description:n?u(`store.textConflict`):t,duration:5e3})}finally{y(!1)}}return n(e,{children:[n(`div`,{className:`flex items-center gap-2 px-2 py-1 shrink-0`,children:[g&&t(`span`,{className:`text-xs text-attention`,children:u(`store.unsavedChanges`)}),t(`div`,{className:`flex-1`}),t(o,{variant:`ghost`,size:`sm`,onClick:a,disabled:v,children:u(`store.cancelEdit`)}),t(o,{variant:`secondary`,size:`sm`,onClick:E,disabled:!g,isLoading:v,children:u(`store.saveText`)})]}),t(`div`,{className:`flex-1 min-h-0 border rounded-md overflow-hidden mx-2 mb-2`,children:C?t(ut,{fallback:t(`div`,{className:`h-full w-full`}),children:t(s4,{value:m,onChange:T})}):t(Pt,{value:i,language:S,editorRef:p,onChange:w,theme:d===`dark`?`vs-dark`:`vs`,options:{wordWrap:`on`,minimap:{enabled:!1},lineNumbers:`on`,scrollBeyondLastLine:!1}})}),t(X2,{isOpen:b,onClose:()=>x(!1),onConfirm:D,isLoading:v})]})}const u4=131072;function d4(e,t,n=!1,r=e){let{store:i}=q(),[a,o]=G(t),[s,c]=G(()=>t&&t.length>u4?t.substring(0,u4):t),[l,u]=G(!1),[d,f]=G(()=>!!t&&t.length>u4),[p,m]=G(),h=W(t),g=W(e),_=W(r),v=W(!1),y=V((e,t=!0)=>{let n=h.current;t&&n&&e&&n!==e?m(e=>({previousText:n,version:(e?.version??0)+1})):t||m(void 0),h.current=e,o(e),e&&e.length>u4?(c(e.substring(0,u4)),f(!0)):(c(e),f(!1))},[]),b=V(()=>{let t=e,n=r;u(!0),i.objects.getObjectText(e).then(e=>{if(g.current!==t)return;let r=_.current===n&&!v.current;y(e.text,r),v.current=!1}).catch(e=>{console.error(`Failed to load text`,e)}).finally(()=>{g.current===t&&u(!1)})},[y,r,e,i]);return bt(()=>{let i=g.current!==e,a=_.current!==r;g.current=e,_.current=r,a&&(v.current=!0),t!==void 0&&(y(t,!a),v.current=!1),n&&t===void 0&&(i||h.current===void 0)&&b()},[y,r,t,n,b,e]),{fullText:a,displayText:s,isLoading:l,isCropped:d,changeHighlight:p,loadText:b}}function f4(e,t){let{client:n}=q(),[r,i]=G({isComplete:!1});return H(()=>{if(!t)return;let r=!1,a,o=(e,t,n)=>{i(r=>{let i=JSON.stringify(r.progress??null),a=JSON.stringify(e??null);return r.status===t&&r.isComplete===n&&i===a?r:{progress:e,status:t,isComplete:n}})};function s(){r||n.objects.analyze(e).getStatus().then(e=>{e.status===Tn.RUNNING?(o(e.progress,e.status,!1),r||(a=setTimeout(s,2e3))):o(e.progress,e.status,!0)}).catch(()=>{r||(a=setTimeout(s,1e4))})}return s(),()=>{r=!0,a&&clearTimeout(a)}},[t,e,n]),{progress:r.progress,status:r.status,isComplete:r.isComplete}}function p4(e,t){let{client:n}=q(),r=Xt.getFixedT(null,Yt),[i,a]=G(),[o,s]=G(!1),[c,l]=G();return{pdfUrl:i,isConverting:o,error:c,triggerConversion:V(async()=>{if(!t||o)return;s(!0),l(void 0);let i=async t=>{try{let o=await n.objects.getRendition(e,{format:gn.pdf,generate_if_missing:t,sign_url:!0,block_on_generation:!1});o.status===`generating`?setTimeout(()=>i(!1),5e3):o.status===`found`&&o.renditions?.length?(a(o.renditions[0]),s(!1)):o.status===`failed`&&(l(r(`store.pdfConversionFailed`)),s(!1))}catch(e){console.error(`Failed to convert Office document to PDF:`,e),l(r(`store.failedToConvertToPdf`)),s(!1)}};await i(!0)},[e,t,o,n,r])}}Q(),XY();const m4=()=>({a:({node:e,...n})=>{let r=n.href||``;return r.includes(`/store/objects/`)?t(Zn,{topLevelNav:!0,href:r,className:`text-info`,children:n.children}):t(`a`,{...n,target:`_blank`,rel:`noopener noreferrer`})},p:({node:e,...n})=>t(`p`,{...n,className:`my-0`}),pre:({node:e,...n})=>t(`pre`,{...n,className:`my-2 p-2 rounded`}),code:({node:e,className:n,children:r,...i})=>{let a=!/language-(\w+)/.exec(n||``);return t(`code`,{...i,className:a?`px-1.5 py-0.5 rounded`:`text-muted`,children:r})},h1:({node:e,...n})=>t(`h1`,{...n,className:`font-bold text-2xl my-2`}),h2:({node:e,...n})=>t(`h2`,{...n,className:`font-bold text-xl my-2`}),h3:({node:e,...n})=>t(`h3`,{...n,className:`font-bold text-lg my-2`}),li:({node:e,...n})=>t(`li`,{...n})});function h4(e){return e===dn.created||e===dn.processing}function g4(e){return e.metadata?.content_processor?.type}function _4(e){return e?e.includes(`
1381
+ `));let l=`msg-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,u={timestamp:Date.now(),workflow_run_id:r,type:J.QUESTION,message:s,workstream_id:`main`,details:{_optimistic:!0,_messageId:l,_deliveryStatus:`sending`,...t?.editing_action?{editing_action:t.editing_action}:{},...t?.request_input_response?{request_input_response:t.request_input_response}:{}}};rt(u);let d={...a.length>0?{attached_docs:a.map(e=>e.id)}:{},...o,...t,id:l,_messageId:l},f=()=>Ye.agents.sendSignal(r,`UserInput`,{message:s,client_message_id:l,metadata:d}),p=()=>{it(l,`received`),I?.(),Dt()};i&&jU(r,i),(async()=>{await Dr(),Dn.current&&(await Ye.agents.restart(r),at()),await f(),p()})().catch(e=>{i&&MU(r,i),it(l,`failed`),Xe({status:`error`,title:Je(`agent.failedToSend`),description:e instanceof Error?e.message:Je(`agent.unknownError`),duration:3e3})}).finally(()=>{Pt(!1)})},[r,Ye,Xe,F,ee,I,Dt,at,rt,it,Je,Dr]);H(()=>(de&&(de.current=Or),()=>{de?.current===Or&&(de.current=null)}),[Or,de]);let kr=V(async(e,t)=>{try{await Ye.agents.sendSignal(r,`McpConfigChanged`,{})}catch(e){console.error(`Failed to signal MCP config change`,e)}Or(Je(`agent.mcpConnectedMessage`,{name:e.name}),t)},[Ye,r,Or,Je]),[Ar,jr]=G(void 0);H(()=>{let e=!1,t=hn.current;return Ye.agents.retrieve(r).then(n=>{e||(jr(n.disabled_mcp_collections),hn.current===t&&(n.tool_approval_mode!==void 0||n.interactive!==void 0)&&un(kn(n.tool_approval_mode,n.interactive)))}).catch(()=>{}),()=>{e=!0}},[Ye,r]);let Mr=V(e=>{let t=e.length>0?e:void 0;jr(t),Ye.agents.sendSignal(r,`McpConfigChanged`,{disabled_mcp_collections:e}).catch(e=>console.error(`Failed to signal MCP config change`,e))},[Ye,r]),Nr=V(()=>{Ye.agents.sendSignal(r,`McpConfigChanged`,{}).catch(e=>console.error(`Failed to signal MCP config change`,e))},[Ye,r]),Pr=V(e=>{let t=kn(e,a),n=ln;hn.current+=1,un(t);let i=Ye.agents.sendSignal(r,`ToolApprovalModeChanged`,{mode:t}).then(()=>void 0).catch(e=>{un(e=>e===t?n:e),Xe({status:`error`,title:Je(`agent.approvalMode.changeFailed`),description:e instanceof Error?e.message:Je(`agent.unknownError`),duration:3e3})});gn.current=i,i.finally(()=>{gn.current===i&&(gn.current=null)})},[r,Ye,a,Je,Xe,ln]),Fr=V(e=>{Ot&&(e.preventDefault(),e.stopPropagation(),fn.current++,e.dataTransfer?.types?.includes(`Files`)&&Gt(!0))},[Ot]),Ir=V(e=>{Ot&&(e.preventDefault(),e.stopPropagation())},[Ot]),Lr=V(e=>{Ot&&(e.preventDefault(),e.stopPropagation(),fn.current--,fn.current===0&&Gt(!1))},[Ot]),Rr=V(e=>{if(Ot&&(e.preventDefault(),e.stopPropagation(),fn.current=0,Gt(!1),e.dataTransfer?.files&&e.dataTransfer.files.length>0)){let t=Array.from(e.dataTransfer.files);Tt(t)}},[Tt,Ot]),zr=V(async()=>{if(Vt)return;let e=`stop-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,t={timestamp:Date.now(),workflow_run_id:r,type:J.IDLE,message:`Stopped. Waiting for your command...`,workstream_id:`main`,details:{_optimistic:!0,_messageId:e,_deliveryStatus:`sending`,display_role:`user_stopped`,status_reason:`user_stopped`}};rt(t),Ht(!0);try{await Ye.agents.sendSignal(r,`Stop`,{message:`User requested stop`,client_message_id:e,metadata:{id:e,_messageId:e}}),it(e,`received`)}catch(t){Xe({status:`error`,title:Je(`agent.failedToInterrupt`),description:t instanceof Error?t.message:Je(`agent.unknownError`),duration:3e3}),it(e,`failed`)}finally{Ht(!1)}},[Vt,r,rt,Ye.agents,Xe,Je,it]),Br=V(async()=>{if(!(Ft||Qn||!Un)){It(!0);try{await Ye.agents.sendSignal(r,`TriggerCheckpoint`,{reason:`manual user request`})}catch(e){Xe({status:`error`,title:Je(`agent.failedToCompactContext`),description:e instanceof Error?e.message:Je(`agent.unknownError`),duration:3e3})}finally{It(!1)}}},[r,Ye.agents,Qn,Ft,Un,Je,Xe]);H(()=>(xe&&(xe.current=h&&!Qn?zr:null),()=>{xe&&(xe.current=null)}),[xe,Qn,zr,h]),H(()=>{Se?.(Vt)},[Vt,Se]);let Vr=i||Je(`agent.agentConversation`),Hr=async()=>{try{let e=await iU(Ye,r);e&&window.open(e,`_blank`)}catch(e){console.error(`Failed to download conversation`,e),Xe({status:`error`,title:Je(`agent.failedToDownload`),duration:3e3})}},Ur=V(()=>{let e=new Date().toISOString(),t=Qe.size>0?[{cursor:`live`,streamingMessages:Array.from(Qe,([e,t])=>({id:e,...t}))}]:void 0,n={metadata:{title:Vr,agent_run_id:r,exported_at:e,message_count:Ze.length},messages:Ze,...t?{streamingFrames:t}:{}};B1(`${z1(Vr)||`agent-chat`}-${z1(r)}.json`,n),Xe({status:`success`,title:Je(`agent.rewind.fixtureExported`),duration:2e3})},[Vr,r,Ze,Qe,Je,Xe]),[Wr,Gr]=G(!1),Kr=()=>{if(!jt.current){Xe({status:`error`,title:Je(`agent.pdfExportFailed`),description:Je(`agent.noConversationContent`),duration:3e3});return}Gr(!0)},qr=()=>{if(!jt.current){Xe({status:`error`,title:Je(`agent.pdfExportFailed`),description:Je(`agent.noConversationContent`),duration:3e3});return}let e=`${Vr} - ${r}`;if(!L1(jt.current,e)){Xe({status:`error`,title:Je(`agent.pdfExportFailed`),description:Je(`agent.unableToOpenPrint`),duration:4e3});return}Xe({status:`success`,title:Je(`agent.pdfExportReady`),description:Je(`agent.printDialogDescription`),duration:4e3}),Gr(!1)},Jr=U(()=>Ze.filter(e=>e.type===J.COMPLETE||e.type===J.THOUGHT&&e.details?.tool_status===`completed`).length,[Ze]),Yr=U(()=>{if(!fr)return{key:Jr,details:void 0};let e=0,t;for(let n of Ze){let r=n.details;Ut(r,fr)&&(e++,t=r)}return{key:e,details:t}},[Jr,Ze,fr]),Xr=a&&Un&&xn?.toUpperCase()===`RUNNING`,Zr=U(()=>An.plan.plan?.reduce((e,t)=>(t.id&&t.goal&&e.set(t.id.toString(),t.goal),e),new Map),[An.plan]),Qr=e=>t(aZ,{title:Vr,variant:e,isCompleted:Qn,isTerminal:Sn,onClose:s,isModal:c,agentRunId:r,workflowRunId:ot||``,viewMode:zt,onViewModeChange:Bt,showPlanPanel:yr,hasPlan:A&&ct.length>0,showPlanButton:A&&!Be,onTogglePlanPanel:xr,showPlaybackButton:Ln,isPlaybackEnabled:Rn,onTogglePlayback:sr,onDownload:Hr,onExportFixture:Ur,resetWorkflow:d,onClone:p,onShowDetails:m,allowWorkflowControl:h,onExportPdf:Kr,isReceivingChunks:tt}),$r=n(`div`,{ref:jt,"data-agent-playback-enabled":Rn||void 0,"data-agent-playback-cursor":Rn?Hn:void 0,"data-agent-live-message-count":Ze.length,"data-agent-rendered-message-count":Kn.length,className:z(`flex flex-col min-h-0 min-w-0 border-0`,Be?`flex-1 h-full`:yr?`w-full flex-1 min-h-[50vh]`:l?`flex-1 w-full`:`flex-1 mx-auto ${c?``:`max-w-4xl`}`),children:[!w&&T===`compact`&&t(`div`,{className:`flex flex-shrink-0 justify-end border-b border-border/60 px-2 py-1 lg:hidden`,children:Qr(`compact`)}),!w&&T!==`compact`&&t(`div`,{className:`flex-shrink-0`,children:Qr(T)}),Rn&&t(`div`,{className:`flex flex-shrink-0 justify-end px-2 py-1.5`,children:t(xC,{cursor:Hn,messages:Bn,onChangeCursor:cr})}),Ze.length===0&&!Qn&&Ve&&He?t(I1,{message:Ve,startedAt:He}):t(OJ,{messages:Kn,workstreamSourceMessages:qn,bottomRef:At,isCompleted:$n,plan:An.plan,workstreamStatus:An.workstreamStatus,showPlanPanel:A&&pt,onTogglePlanPanel:xr,plans:ct,activePlanIndex:lt,onChangePlan:lr,taskLabels:Zr,streamingMessages:Jn,onSendMessage:Un?Or:void 0,onOpenArtifact:M?Cr:void 0,messageItemClassNames:Ce,messageStyleOverrides:we,toolCallGroupClassNames:Te,hideToolCallsInViewMode:Ee,streamingMessageClassNames:De,batchProgressPanelClassNames:Oe,artifactRunId:r,viewMode:zt,hideWorkstreamTabs:k,workingIndicatorClassName:ke,messageListClassName:Ae,StoreLinkComponent:Er,CollectionLinkComponent:Me,prependFriendlyMessage:Ne,initialRequestData:Pe,initialRequestSchema:Fe,initialRequestTitle:Ie,initialRequestTemplate:Le,showInitialRequest:et===`empty`&&Ze.length===0,hiddenMessageTypes:P,disableAutoScroll:!Un,renderRequestInputControls:!nr,activeWorkstream:Kt,onActiveWorkstreamChange:qt}),nr?t(rW,{message:tr,onSendMessage:Un?Or:void 0,onMcpConnected:Un?kr:void 0,disabled:L||!Un,isLoading:Nt||L}):rr&&Zn.length>0?t(`div`,{className:`flex-shrink-0 pb-safe-area`,children:t(XX,{activeWorkstreams:Zn,onSelectWorkstream:qt})}):ir&&t(`div`,{className:`flex-shrink-0 pb-safe-area`,children:Tn?D??t(oe,{status:`error`,title:Je(`agent.failed`),className:`m-2`,children:En??Je(`agent.error`)}):xn&&xn!==`RUNNING`&&!Cn?zt===`sliding`&&xn===`COMPLETED`?t(`div`,{className:`mx-auto w-full max-w-3xl px-4 py-3 text-sm text-muted`,children:n(`div`,{className:`flex items-center gap-2 border-t border-success/25 pt-3 text-success`,children:[t(Nh,{className:`size-4`}),t(`span`,{className:`font-medium`,children:`Workflow completed`})]})}):n(oe,{status:xn===`COMPLETED`?`success`:`done`,icon:null,className:`m-2`,children:[`This Workflow is `,xn]}):(ft||Cn)&&n(e,{children:[re,t(l1,{onSend:Or,onStop:h?zr:void 0,approvalModeSlot:a&&ln?t(Yb,{mode:ln,onChange:Pr,disabled:!Un||Sn||!h}):void 0,mcpSlot:t(GJ,{disabledCollections:Ar,onChange:Mr,onConnectionChange:Nr}),disabled:L||!Un,isSending:Nt||L,isStopping:Vt,isStreaming:!Qn,isCompleted:Qn,contextWindowUsage:or?ar:void 0,onCompactContext:or?Br:void 0,isCompactingContext:Ft,activeTaskCount:Pn,activeWorkstreams:Nn,onSelectWorkstream:qt,placeholder:In,onFilesSelected:Ot?Tt:void 0,uploadedFiles:g,onRemoveFile:_,onRemoveProcessingFile:kt,acceptedFileTypes:v,maxFiles:y,processingFiles:Ct,artifactRunId:r,hasProcessingFiles:wt,renderDocumentSearch:b,selectedDocuments:x,onRemoveDocument:S,hideObjectLinking:C,hideFileUpload:!Ot,disableDropZone:Ot,className:te,inputClassName:ne})]})})]}),ei=t(BS,{children:t(OW,{children:n(`div`,{ref:Mt,className:z(`flex flex-col lg:flex-row gap-2 w-full h-full relative overflow-hidden`,Ot&&Wt&&`ring-2 ring-info ring-inset`,R),onDragEnter:Ot?Fr:void 0,onDragOver:Ot?Ir:void 0,onDragLeave:Ot?Lr:void 0,onDrop:Ot?Rr:void 0,children:[Ot&&Wt&&t(`div`,{className:`absolute inset-0 flex items-center justify-center bg-info/80 dark:bg-info/40 z-50 pointer-events-none rounded-lg`,children:n(`div`,{className:`text-info font-medium flex items-center gap-2 text-lg`,children:[t(wb,{className:`size-6`}),`Drop files to upload`]})}),!Be&&$r,!Be&&T===`compact`&&!w&&t(`div`,{className:`hidden h-full w-12 shrink-0 items-start justify-center px-1 pt-2 lg:flex`,children:Qr(`compact`)}),yr&&n(e,{children:[!Be&&t(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize right panel`,"aria-valuenow":Math.round(pr),"aria-valuemin":300,"aria-valuetext":`${Math.round(pr)} pixels`,tabIndex:0,className:`hidden lg:block lg:w-1 lg:shrink-0 cursor-col-resize bg-border/70 hover:bg-border transition-colors`,onMouseDown:()=>gr(!0),onKeyDown:e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let t=e.shiftKey?32:16,n=e.key===`ArrowLeft`?t:-t,r=Mt.current,i=r?Math.max(300,r.getBoundingClientRect().width-420):900;mr(e=>Math.min(Math.max(e+n,300),i))}}),t(`div`,{className:Be?`w-full h-full overflow-auto`:`w-full lg:w-[var(--agent-right-panel-width)] lg:shrink-0 min-h-[50vh] lg:h-full border-t lg:border-t-0`,style:Be?void 0:{"--agent-right-panel-width":`${pr}px`},children:t(OX,{plan:An.plan,workstreamStatus:An.workstreamStatus,plans:ct,activePlanIndex:lt,onChangePlan:lr,showPlan:!O&&pt,activeWorkstreams:Mn,hideWorkstreams:k,openDocuments:ht,activeDocumentId:gt,onSelectDocument:bt,onUpdateDocumentTitle:St,docRefreshKey:vt,runId:r,processingFiles:he??Ct,showArtifacts:M,artifactRefreshKey:Yr.key,artifactRefreshDetails:Yr.details,selectedArtifactPath:fr,onSelectedArtifactPathChange:Y,onSendMessage:Xr?Or:void 0,messages:Ze,payloadContent:Re,conversationContent:Be?$r:ze,onClose:Sr,defaultTab:ur,activeTab:ur,onTabChange:dr})})]}),n(se,{isOpen:Wr,onClose:()=>Gr(!1),children:[t(ue,{children:`Export conversation as PDF`}),n(ce,{children:[t(`p`,{className:`mb-2`,children:`This will open your browser's print dialog with the current conversation.`}),t(`p`,{className:`text-sm text-muted`,children:`To save a PDF, choose "Save as PDF" or a similar option in the print dialog.`})]}),n(le,{align:`right`,children:[t(o,{variant:`ghost`,size:`sm`,onClick:()=>Gr(!1),children:`Cancel`}),t(o,{size:`sm`,onClick:qr,children:`Open print dialog`})]})]})]})})});return ie?t(Yn,{data:ie,sendMessage:Or,ChartComponent:oC,artifactRunId:r,children:ei}):ei}function G1({messages:e}){let n=ot.useMemo(()=>[...e].sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())),[e]);return t(`div`,{className:`flex flex-col overflow-y-auto space-y-6 py-4`,children:n.map(e=>t(yG,{message:e,showPulsatingCircle:!1},`${e.workstream_id??`main`}-${e.timestamp}-${e.type}`))})}function K1({messages:e,bottomRef:n,className:r,messagesClassName:i,emptyClassName:a}){let o=ot.useRef(null);H(()=>{n.current&&n.current.scrollIntoView({behavior:`smooth`})},[e,n]);let s=ot.useMemo(()=>[...e].sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())),[e]);return t(`div`,{ref:o,className:`flex-1 min-h-0 h-full overflow-y-auto py-4 px-4 sm:px-6 lg:px-8 bg-white flex flex-col ${r||``}`,"data-testid":`messages-container`,children:s.length===0?t(`div`,{className:`flex items-center justify-center h-full text-center py-8 ${a||``}`,children:t(`div`,{className:`flex items-center px-4 py-3 text-muted`,children:`Waiting for agent response...`})}):t(`div`,{className:`flex-1 flex flex-col justify-start h-full min-h-0 ${i||``}`,children:t(G1,{messages:s,isCompleted:!1})})})}function q1(e){return e.name}function J1({isClearable:e=!1,onChange:n,ignoreVirtuals:r=!1,selectedEnvId:i,disabled:a=!1}){let{t:o}=K(),{client:s}=q(),[c,l]=G(),{data:u,isLoading:d}=Xe(()=>s.environments.list().then(e=>(r?e.filter(e=>!e.provider.startsWith(`virtual_`)):e).slice().sort((e,t)=>e.name.localeCompare(t.name))));return H(()=>{l(u?.find(e=>e.id===i))},[u,i]),t(we,{isClearable:e,optionLabel:q1,options:u??[],value:c,onChange:e=>{l(e),n(e)},placeholder:o(`intakePolicy.placeholder.environment`),filterBy:`name`,disabled:a,isLoading:d})}function Y1(e){return e.name}function X1(e){return e?.length?n=>{let r=e.some(e=>e.id===n.id);return t(`span`,{className:r?`opacity-50`:``,children:n.name})}:Y1}function Z1({envId:e,isClearable:n,onChange:r,selectedModelId:i,disabled:a=!1,greyedModels:o,onModelsLoaded:s}){let{t:c}=K(),{client:l}=q(),[u,d]=G(),{data:f,isLoading:p}=Ye(async()=>{if(!e)return[];try{return[...(await l.environments.retrieve(e)).enabled_models??[]].sort((e,t)=>e.name.localeCompare(t.name))}catch{return[]}},[e]);return H(()=>{if(!i){d(void 0);return}let e=f?.find(e=>e.id===i);d(e??{id:i,name:i,provider:`unknown`})},[f,i]),H(()=>{f&&s?.(f)},[f,s]),t(we,{isClearable:n,by:`id`,optionLabel:X1(o),options:f??[],value:u,onChange:e=>{d(e),r(e)},placeholder:c(`intakePolicy.placeholder.model`),disabled:a,isLoading:p})}function Q1({env:e,isClearable:n,onChange:r}){let{t:i}=K(),{client:a}=q(),[o,s]=G(),{data:c,isLoading:l}=Ye(async()=>{if(!e)return[];try{return a.environments.listTrainableModels(e.id)}catch{return[]}},[e?.id]);return t(we,{isClearable:n,by:`id`,optionLabel:Y1,options:c??[],value:o,onChange:e=>{s(e),r(e)},placeholder:i(`intakePolicy.placeholder.model`),disabled:!e,isLoading:l})}function $1({children:e,fallback:n}){return e0?t(e0,{fallback:n,children:e}):t(rr,{FallbackComponent:n,children:e})}let e0=null;function t0(e){e0=e}function n0({children:e}){return t($1,{fallback:r0,children:e})}function r0({error:e}){let{t:r}=K(),i=e instanceof Error?e.message:void 0;return n(oe,{status:`error`,title:r(`errors.somethingWentWrong`),children:[n(`div`,{className:`mb-4`,children:[r(`errors.teamNotifiedLine1`),` `,r(`errors.teamNotifiedLine2`),`\xA0`,t(`a`,{className:`text-info`,href:`mailto:support@vertesiahq.com`,children:`support@vertesiahq.com`}),`.`]}),i&&t(`code`,{className:`w-full mt-4 text-sm text-muted break-words`,children:i})]})}function i0({children:e}){return t($1,{fallback:a0,children:e})}function a0({error:e}){let r=e instanceof Error?e.message:void 0;return t(`tr`,{children:n(`td`,{colSpan:100,children:[t(`span`,{className:`text-xs`,children:` Cannot display row`}),t(`br`,{}),t(`span`,{className:`bg-muted`,children:r})]})})}function o0({children:e}){return t($1,{fallback:s0,children:e})}function s0({error:e}){let r=e instanceof Error?e.message:void 0;return console.log(`WidgetError`,e),n(`div`,{className:`text-sm`,children:[`Sorry, this area cannot be loaded or rendered.`,r&&t(`pre`,{children:r})]})}Q();const c0=/^[a-f0-9]{24}$|^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$|^(?=.*\d)(?=.*[a-zA-Z])[a-zA-Z0-9_-]{8,}$/i;function l0(e){return c0.test(e)}function u0({className:e,children:r,title:i,description:o,actions:s,breadcrumbs:c,useDynamicBreadcrumbs:l=!0,parentPath:u,parentLabel:d}){let f=Qn();function p(e){return e.replace(/[-_]/g,` `).split(` `).map(e=>qn(e)).join(` `)}let m=e=>{if(e?.title)return e.title;let t=e?.href||``;if(!t)return`Page`;let n=t.split(`#`)[0].split(`?`)[0].split(`/`).filter(e=>e.length>0);return n.length>=1?p(n[n.length-1]):`Page`},h=(()=>{let e=[];if(l&&typeof window<`u`){let t=window.history.state?.historyChain;if(Array.isArray(t))t.forEach((n,r)=>{let i=t.length-r;e.push({label:m(n),href:n.href,onClick:()=>f(n.href,{stepsBack:i})})});else if(u)e.push({label:d??m({href:u}),href:u,onClick:()=>f(u,{isBasePathNested:!1,replace:!0})});else{let t=window.location.pathname.split(`/`).filter(e=>e.length>0);for(let n=0;n<t.length;n++)if(l0(t[n])){let r=`/${t.slice(0,n).join(`/`)}`;e.push({label:p(t[n-1]||r),href:r,onClick:()=>f(r,{isBasePathNested:!1})})}}}return Array.isArray(c)&&c.forEach(t=>{let n=t.props?.children||t,r=t.props?.href;e.push(r?{href:r,label:n,onClick:()=>f(r,{replace:t.props.clearBreadcrumbs})}:{label:n})}),e})(),g=!!i&&h.length===0;return n(`div`,{className:it(`pb-0 ps-4 pe-2 py-2 flex flex-col`,e),children:[n(`div`,{className:`flex items-start gap-4`,children:[n(`div`,{className:`w-full flex place-content-between h-auto min-h-8 flex-col items-start justify-center`,children:[n(`nav`,{className:`flex-1 flex justify-start text-sm`,children:[h.length>0&&t(a,{path:h,separator:t(lh,{className:`size-3.5 cn-rtl-flip`}),maxItems:4}),o&&!g&&t(We,{description:o,children:t(A_,{className:`size-4 text-muted ms-4`})})]}),i&&n(`div`,{className:`flex gap-2 items-center`,children:[t(`h1`,{className:`text-xl font-semibold break-all`,children:i}),o&&g&&t(We,{description:o,children:t(A_,{className:`size-4 text-muted`})})]})]}),t(`div`,{className:`flex gap-x-2 shrink-0 items-center`,children:s})]}),r&&t(`div`,{className:`w-full flex items-center`,children:r})]})}function d0(){let{t:e}=K();return n(`div`,{className:`text-center pt-32`,children:[t(`h1`,{className:`text-3xl font-bold text-destructive`,children:`404`}),t(`p`,{className:`text-2xl`,children:e(`layout.pageNotFound`)})]})}Q();const f0=`magic-pdf`;function p0(e){return e.replace(/^\$\.?/,``).replace(/^data\./,``)}function m0(e){let{client:t}=q(),[n,r]=G(!1);return H(()=>{let n=!1;return r(!1),t.files.getDownloadUrl(`${f0}/${e}/grounded-extraction.json`).then(e=>fetch(e.url,{method:`HEAD`})).then(e=>{n||r(e.ok)}).catch(()=>{}),()=>{n=!0}},[t,e]),n}function h0(e){let{client:t}=q(),[n,r]=G(null);return H(()=>{let n=!1;return r(null),t.files.getDownloadUrl(`${f0}/${e}/grounded-extraction.json`).then(e=>fetch(e.url)).then(e=>e.ok?e.json():null).then(e=>{n||!e?.citations||r({confidence:e.confidence,verified:e.citations.filter(e=>e.verified).length,total:e.citations.length,verdict:e.verdict,verdict_reason:e.verdict_reason})}).catch(()=>{}),()=>{n=!0}},[t,e]),n}function g0({objectId:e,onClose:r}){let{t:i}=K(),{client:a}=q(),{data:s,error:c,isLoading:l}=Ye(async()=>{let t=await a.files.getDownloadUrl(`${f0}/${e}/grounded-extraction.json`),n=await fetch(t.url);if(!n.ok)throw Error(i(`grounded.notFound`));return n.json()},[e]);return c?t(`div`,{className:`flex h-full items-center justify-center`,children:n(`div`,{className:`flex flex-col items-center gap-4 p-8 max-w-md`,children:[t(M,{title:i(`grounded.failedToLoad`),children:Ge(c)}),r&&t(o,{variant:`outline`,onClick:r,children:i(`pdf.close`)})]})}):l||!s?t(`div`,{className:`flex h-full items-center justify-center`,children:t(je,{size:`lg`})}):t(`div`,{className:`relative h-full`,children:t(v0,{extraction:s,objectId:e,onClose:r})})}function _0({objectId:e,onClose:n}){return t(`div`,{className:`fixed inset-0 bg-background z-50`,children:t(g0,{objectId:e,onClose:n})})}function v0({extraction:r,objectId:a,onClose:s}){let{t:c}=K(),{client:l}=q(),u=U(()=>Object.keys(r.pages).map(e=>parseInt(e,10)).sort((e,t)=>e-t),[r.pages]),d=e=>{l.files.getDownloadUrl(`${f0}/${a}/${e}`).then(e=>window.open(e.url,`_blank`)).catch(()=>{})},[f,p]=G(u[0]??1),[m,h]=G(void 0),[g,_]=G(!1),[v,y]=G(`original`),b=U(()=>{let e={digital:0,ocr:0,reviewerConfirmed:0,snapped:0,imageRead:0},t=[];for(let n of r.citations)n.verified?n.snapped?e.snapped++:(n.confidence??0)>=1?e.digital++:e.ocr++:n.reviewed?e.reviewerConfirmed++:(e.imageRead++,t.push(n));let n=e.digital+e.ocr+e.snapped,i=e.reviewerConfirmed;return{groups:e,unverified:t,digitallyVerified:n,modelVerified:i,totalVerified:n+i}},[r.citations]),x=U(()=>{let e=new Map;for(let t of r.citations){let n=p0(t.path),r=e.get(n)??[];r.push(t),e.set(n,r)}return e},[r.citations]),S=r.citations.length,C=b.totalVerified===S,T=e=>{h(e);let t=x.get(p0(e))?.[0];t&&p(t.page)},E=u.indexOf(f),D=m?x.get(p0(m))?.find(e=>e.page===f):void 0,O=D?.cells?D.cells.start===D.cells.end?D.cells.start:`${D.cells.start}:${D.cells.end}`:void 0;return n(Ce,{direction:`horizontal`,className:`absolute inset-0`,children:[n(Se,{defaultSize:55,minSize:25,className:`flex flex-col bg-muted`,children:[n(`div`,{className:`relative flex h-9 shrink-0 items-center justify-center bg-sidebar px-2 border-b border-sidebar-border`,children:[O&&t(i,{variant:`secondary`,className:`absolute start-2 max-w-32 truncate font-mono text-[11px]`,title:O,children:O}),n(`div`,{className:`flex items-center gap-2`,children:[t(o,{variant:`ghost`,size:`xs`,"aria-label":c(`grounded.previousPage`),disabled:E<=0,onClick:()=>p(u[E-1]),children:t(oh,{className:`size-4`})}),t(`span`,{className:`text-xs text-muted`,children:c(`pdf.pageOf`,{pageNumber:f,totalPages:u.length})}),t(o,{variant:`ghost`,size:`xs`,"aria-label":c(`grounded.nextPage`),disabled:E>=u.length-1,onClick:()=>p(u[E+1]),children:t(lh,{className:`size-4`})})]}),n(`fieldset`,{className:`absolute end-2 flex items-center gap-0.5 rounded border-0 bg-muted p-0.5`,children:[t(`legend`,{className:`sr-only`,children:c(`grounded.checkerboard`)}),t(We,{description:c(`pdf.originalImages`),placement:`bottom`,size:`xs`,asChild:!0,children:n(o,{variant:v===`original`?`outline`:`ghost`,size:`xs`,"aria-label":c(`pdf.originalImages`),"aria-pressed":v===`original`,className:`h-6 gap-1 px-1.5`,onClick:()=>y(`original`),children:[t(D_,{className:`size-3.5`}),t(`span`,{className:`hidden sm:inline`,children:c(`pdf.page`)})]})}),t(We,{description:c(`grounded.checkerboard`),placement:`bottom`,size:`xs`,asChild:!0,children:n(o,{variant:v===`grid`?`outline`:`ghost`,size:`xs`,"aria-label":c(`grounded.checkerboard`),"aria-pressed":v===`grid`,className:`h-6 gap-1 px-1.5`,onClick:()=>y(`grid`),children:[t(x_,{className:`size-3.5`}),t(`span`,{className:`hidden sm:inline`,children:c(`grounded.checkerboard`)})]})})]})]}),t(`div`,{className:`flex-1 overflow-auto p-2`,children:t(y0,{objectId:a,page:f,dims:r.pages[String(f)],citations:r.citations.filter(e=>e.page===f),selectedPath:m,onSelectPath:h,imageMode:v})})]}),t(xe,{className:`w-[4px] bg-border cursor-ew-resize`}),n(Se,{defaultSize:45,minSize:20,className:`flex flex-col`,children:[n(`div`,{className:`flex h-9 items-center justify-between shrink-0 bg-sidebar px-2 border-b border-sidebar-border`,children:[t(`span`,{className:`text-sm font-medium`,children:c(`grounded.title`)}),n(`div`,{className:`flex items-center gap-2`,children:[S>0&&t(We,{description:c(`grounded.confidenceHint`),placement:`bottom`,size:`xs`,asChild:!0,children:n(i,{variant:C?`success`:`attention`,className:`gap-1 text-nowrap cursor-pointer`,onClick:()=>_(e=>!e),"aria-expanded":g,children:[t(C?Ih:Ag,{className:`size-3.5`}),c(`grounded.verifiedOf`,{verified:b.totalVerified,total:S})]})}),n(w,{align:`right`,trigger:t(o,{variant:`ghost`,size:`xs`,"aria-label":c(`pdf.download`),title:c(`pdf.download`),children:t(xg,{className:`size-4`})}),children:[n(ae,{className:`text-xs`,onClick:()=>d(`grounded-extraction.json`),children:[t(Ng,{className:`size-4`}),c(`grounded.downloadCitations`)]}),n(ae,{className:`text-xs`,onClick:()=>d(`pages/page-${f}.json`),children:[t(Gg,{className:`size-4`}),c(`grounded.downloadBlocks`)]}),n(ae,{className:`text-xs`,onClick:()=>d(`grounded-annotated.pdf`),children:[t(Ig,{className:`size-4`}),c(`grounded.downloadAnnotated`)]})]}),!!s&&t(o,{variant:`ghost`,size:`xs`,onClick:s,"aria-label":c(`pdf.close`),children:t(Gb,{className:`size-4`})})]})]}),g&&n(`div`,{className:`shrink-0 border-b border-border bg-background px-3 py-2 text-sm max-h-72 overflow-auto`,children:[n(`div`,{className:`mb-1 flex items-center gap-1`,children:[t(`span`,{className:`font-medium`,children:c(`grounded.breakdownTitle`)}),t(We,{description:c(`grounded.breakdownVerificationHelp`),size:`xs`,children:t(A_,{className:`size-3 text-muted`})})]}),n(`div`,{className:`grid grid-cols-2 gap-x-4 text-xs`,children:[t(`span`,{className:`col-span-2 mt-1 font-medium text-success`,children:c(`grounded.digitalVerifiedOf`,{count:b.digitallyVerified,total:S})}),t(`span`,{className:`ps-2 text-muted`,children:c(`grounded.breakdownDigital`)}),t(`span`,{className:`text-end text-success`,children:b.groups.digital}),t(`span`,{className:`ps-2 text-muted`,children:c(`grounded.breakdownOcr`)}),t(`span`,{className:`text-end text-success`,children:b.groups.ocr}),t(`span`,{className:`ps-2 text-muted`,children:c(`grounded.breakdownSnapped`)}),t(`span`,{className:`text-end text-success`,children:b.groups.snapped}),t(`span`,{className:`col-span-2 mt-2 font-medium text-success`,children:c(`grounded.modelVerifiedOf`,{count:b.modelVerified,total:S})}),t(`span`,{className:`ps-2 text-muted`,children:c(`grounded.breakdownReviewer`)}),t(`span`,{className:`text-end text-success`,children:b.groups.reviewerConfirmed}),b.groups.imageRead>0&&n(e,{children:[t(`span`,{className:`col-span-2 mt-2 font-medium text-attention`,children:c(`grounded.unverifiedCount`,{count:b.groups.imageRead})}),t(`span`,{className:`ps-2 text-muted`,children:c(`grounded.breakdownImageRead`)}),t(`span`,{className:`text-end text-attention`,children:b.groups.imageRead})]})]}),typeof r.hardness?.score==`number`&&n(`p`,{className:`mt-2 text-xs text-muted`,title:c(`grounded.hardnessHint`),children:[c(`grounded.hardness`,{percent:Math.round(r.hardness.score*100)}),r.hardness.escalated?` ↑`:``]}),(r.verdict_reason??r.review?.verdict_reason)&&t(`p`,{className:`mt-2 text-xs`,children:r.verdict_reason??r.review?.verdict_reason}),r.review?.summary&&n(`p`,{className:`mt-2 text-xs text-muted`,children:[n(`span`,{className:`font-medium text-foreground`,children:[c(`grounded.reviewSummary`),`: `]}),r.review.summary]}),typeof r.review?.corrections_applied==`number`&&r.review.corrections_applied>0&&t(`p`,{className:`mt-1 text-xs text-info`,children:c(`grounded.reviewCorrections`,{count:r.review.corrections_applied})}),b.unverified.length>0&&n(`div`,{className:`mt-2`,children:[t(`div`,{className:`text-xs font-medium text-muted mb-1`,children:c(`grounded.breakdownUnverifiedList`)}),t(`ul`,{className:`space-y-0.5`,children:b.unverified.map(e=>t(`li`,{children:n(`button`,{type:`button`,className:`w-full text-start text-xs rounded px-1 py-0.5 hover:bg-muted cursor-pointer`,onClick:()=>{T(e.path),_(!1)},children:[t(`span`,{className:`text-muted`,children:e.path}),` `,t(`span`,{children:String(e.value??``)})]})},e.path))})]})]}),n(`div`,{className:`flex-1 overflow-auto p-3`,children:[t(b0,{value:r.data,path:``,citationsByPath:x,selectedPath:m,onSelect:T}),r.conflicts&&r.conflicts.length>0&&t(`div`,{className:`mt-4 text-xs text-attention`,children:c(`grounded.conflicts`,{count:r.conflicts.length})})]})]})]})}function y0({objectId:e,page:r,dims:i,citations:a,selectedPath:o,onSelectPath:s,imageMode:c}){let{t:l}=K(),{client:u}=q(),[d,f]=G(void 0);if(H(()=>{let t=!1;return f(void 0),u.files.getDownloadUrl(`${f0}/${e}/pages/page-${r}.${c}.jpg`).then(e=>{t||f(e.url)}).catch(e=>console.warn(`Failed to load page image`,e)),()=>{t=!0}},[u,c,e,r]),!d||!i)return t(`div`,{className:`flex items-center justify-center h-64`,children:t(je,{})});let p=a.flatMap(e=>e.boxes.map((r,a)=>{let c=o!==void 0&&p0(o)===p0(e.path),l=e.cells?e.cells.start===e.cells.end?e.cells.start:`${e.cells.start}:${e.cells.end}`:void 0;return t(We,{description:n(`span`,{className:`flex flex-col gap-0.5`,children:[t(`span`,{className:`flex items-center gap-1 font-medium`,children:C0(e.path).map((e,r)=>n(lt,{children:[r>0&&t(lh,{className:`size-3 shrink-0 cn-rtl-flip`}),e]},`${r}:${e}`))}),l&&t(`span`,{className:`font-mono`,children:l}),e.source_text&&t(`span`,{children:e.source_text})]}),size:`xs`,asChild:!0,children:t(`button`,{type:`button`,"aria-label":e.path,onClick:()=>s(p0(e.path)),className:z(`absolute cursor-pointer border rounded-[1px] transition-colors`,e.misaligned&&`border-dashed`,c?`border-2 border-info bg-info z-10`:e.verified?`border-success/70 hover:bg-success/20`:e.reviewed?`border-info/70 hover:bg-info/20`:`border-attention/80 hover:bg-attention/20`),style:{position:`absolute`,left:`${r.x/i.width*100}%`,top:`${r.y/i.height*100}%`,width:`${r.w/i.width*100}%`,height:`${r.h/i.height*100}%`}})},`${e.path}-${a}`)})),m=((i.rotation??0)%360+360)%360;if(m!==0){let e=m===90||m===270;return n(`div`,{className:`relative w-full`,style:{aspectRatio:`${i.width} / ${i.height}`},children:[t(`img`,{src:d,alt:l(`grounded.pageAlt`,{page:r}),className:`absolute select-none`,style:{left:`50%`,top:`50%`,width:`${(e?i.height/i.width:1)*100}%`,height:`${(e?i.width/i.height:1)*100}%`,maxWidth:`none`,transform:`translate(-50%, -50%) rotate(${m}deg)`,transformOrigin:`center center`}}),p]})}return n(`div`,{className:`relative w-full`,children:[t(`img`,{src:d,alt:l(`grounded.pageAlt`,{page:r}),className:`w-full select-none`}),p]})}function b0({value:e,path:r,citationsByPath:i,selectedPath:a,onSelect:o}){return Array.isArray(e)?e.length>0&&e.every(e=>typeof e==`object`&&!!e)?t(x0,{items:e,path:r,citationsByPath:i,selectedPath:a,onSelect:o}):t(`div`,{className:`space-y-1`,children:e.map((e,n)=>t(b0,{value:e,path:`${r}[${n}]`,citationsByPath:i,selectedPath:a,onSelect:o},`${r}[${n}]`))}):typeof e==`object`&&e?t(`div`,{className:r?`ps-3 border-s border-border space-y-0.5`:`space-y-0.5`,children:Object.entries(e).map(([e,s])=>{let c=r?`${r}.${e}`:e;if(typeof s!=`object`||!s)return t(S0,{label:e,value:s,path:c,citationsByPath:i,selectedPath:a,onSelect:o},c);let l=Array.isArray(s)&&s.length>0&&s.every(e=>typeof e==`object`&&!!e);return n(`div`,{className:`pt-1`,children:[!l&&t(`div`,{className:`text-sm font-semibold`,children:w0(e)}),t(b0,{value:s,path:c,citationsByPath:i,selectedPath:a,onSelect:o})]},c)})}):null}function x0({items:e,path:r,citationsByPath:i,selectedPath:a,onSelect:o}){let{t:s}=K(),c=U(()=>{let t=new Set;for(let n of e)for(let e of Object.keys(n))t.add(e);return Array.from(t)},[e]);return n(`div`,{className:`pt-1`,children:[n(`div`,{className:`text-sm font-semibold`,children:[w0(r.split(`.`).pop()),` (`,e.length,`)`]}),t(`div`,{className:`overflow-x-auto`,children:n(`table`,{className:`w-full text-xs`,children:[t(`thead`,{children:t(`tr`,{className:`text-start text-muted`,children:c.map(e=>t(`th`,{scope:`col`,className:`py-1 pe-2 font-medium`,children:w0(e)},e))})}),t(`tbody`,{children:e.map((e,l)=>t(`tr`,{className:`border-t border-border/50`,children:c.map(c=>{let u=`${r}[${l}].${c}`,d=i.get(u)?.[0];return t(`td`,{className:`py-0.5 pe-2`,children:n(`button`,{type:`button`,onClick:()=>o(u),className:z(`text-start rounded px-1 w-full`,a===u?`bg-info ring-1 ring-primary`:d?`hover:bg-muted cursor-pointer`:`text-muted cursor-default`),children:[D0(e[c]),d&&typeof d.confidence==`number`&&t(`span`,{className:z(`ms-1 text-[10px]`,E0(d.confidence)),title:s(`grounded.scoreHint`),children:T0(d.confidence)})]})},c)})},`${r}[${l}]`))})]})})]})}function S0({label:e,value:r,path:i,citationsByPath:a,selectedPath:o,onSelect:s}){let{t:c}=K(),l=a.get(i)?.[0];return n(`button`,{type:`button`,onClick:()=>l&&s(i),className:z(`flex items-center gap-2 w-full text-start text-sm rounded px-1.5 py-0.5`,o===i?`bg-info ring-1 ring-primary`:l?`hover:bg-muted`:``,!l&&`cursor-default`),children:[n(`span`,{className:`min-w-28 shrink-0 font-semibold`,children:[w0(e),`:`]}),t(`span`,{className:`flex-1 wrap-break-word`,children:D0(r)}),l&&typeof l.confidence==`number`&&t(`span`,{className:z(`text-xs shrink-0`,E0(l.confidence)),title:c(`grounded.scoreHint`),children:T0(l.confidence)}),l&&(l.verified?t(Ih,{"aria-label":c(`grounded.verified`),className:`size-3.5 shrink-0 text-success`}):l.reviewed?t(Jy,{"aria-label":c(`grounded.aiVerified`),className:`size-3.5 shrink-0 text-info`}):t(Ag,{"aria-label":c(`grounded.readFromImage`),className:`size-3.5 shrink-0 text-attention`}))]})}function C0(e){return p0(e).split(`.`).map(e=>w0(e.replace(/\[\d+\]/g,``))).filter(Boolean)}function w0(e){return e?zt(e):``}function T0(e){let t=e*100;return Number.isInteger(t)?`${t}%`:`${(Math.floor(t*100)/100).toFixed(2)}%`}function E0(e){return e>=.95?`text-success`:e>=.7?`text-attention`:`text-destructive`}function D0(e){return e==null||e===``?`—`:typeof e==`boolean`?e?`true`:`false`:typeof e==`object`?JSON.stringify(e):String(e)}const O0=`magic-pdf`;var k0;(function(e){e.original=`original`,e.instrumented=`instrumented`})(k0||={});var A0=class{client;objectId;totalPages;cache=new Map;pending=new Map;constructor(e,t,n){this.client=e,this.objectId=t,this.totalPages=n}getCacheKey(e,t){return`${t}-${e}`}async getPageImageUrl(e,t){let n=this.getCacheKey(e,t),r=this.cache.get(n);if(r)return r;let i=this.pending.get(n);if(i)return i;let a=this.fetchImageUrl(e,t);this.pending.set(n,a);try{let e=await a;return this.cache.set(n,e),e}finally{this.pending.delete(n)}}async fetchImageUrl(e,t){let n=this.getImagePath(e,t);return(await this.client.files.getDownloadUrl(n)).url}getImagePath(e,t){let n=`${O0}/${this.objectId}/pages`;switch(t){case k0.original:return`${n}/page-${e}.original.jpg`;case k0.instrumented:return`${n}/page-${e}.instrumented.jpg`}}},j0=class{client;objectId;totalPages;cache=new Map;pending=new Map;constructor(e,t,n){this.client=e,this.objectId=t,this.totalPages=n}async getPageLayout(e){let t=this.cache.get(e);if(t!==void 0)return t;let n=this.pending.get(e);if(n)return n;let r=this.fetchPageLayout(e);this.pending.set(e,r);try{let t=await r;return this.cache.set(e,t),t}finally{this.pending.delete(e)}}async fetchPageLayout(e){let t=`${O0}/${this.objectId}/pages/page-${e}.layout.json`,n=await this.client.files.getDownloadUrl(t),r=await fetch(n.url,{method:`GET`});if(!r.ok)throw Error(`Failed to fetch json layout: ${r.statusText}`);return r.text()}},M0=class{totalPages;pages=[];constructor(e){this.totalPages=e}initFromContent(e){this.pages=N0(e,this.totalPages)}async loadUrls(e,t){}async getPageMarkdown(e){let t=e-1;return t<0||t>=this.pages.length?``:this.pages[t]}};function N0(e,t){let n=Array(t).fill(``),r=/<!--\s*\{\s*"page"\s*:\s*(\d+)\s*\}\s*-->/g,i=[];for(let t of e.matchAll(r))i.push({page:parseInt(t[1],10),index:t.index+t[0].length});for(let r=0;r<i.length;r++){let a=i[r],o=a.page-1;if(o<0||o>=t)continue;let s=a.index,c=e.slice(s).match(/<!--\s*\{\s*"page"\s*:\s*\d+\s*\}\s*-->/),l=c&&c.index!==void 0?s+c.index:e.length,u=e.slice(s,l).trim();u=u.replace(/\n---\s*$/,``).trim(),n[o]=u}return n}const P0=dt(void 0);function F0({children:e,object:n}){let{client:r}=q(),i=n.metadata.page_count||10,[a,o]=G(()=>{let e=new M0(i);return n.text&&e.initFromContent(n.text),{count:i,layoutProvider:new j0(r,n.id,i),markdownProvider:e,imageProvider:new A0(r,n.id,i),pdfUrl:``,pdfUrlLoading:!0}});return H(()=>{let e=n.metadata?.renditions?.find(e=>e.name===_n),t=n.content?.type===`application/pdf`,i=e?.content?.source||(t?n.content?.source:void 0);i?r.store.objects.getDownloadUrl(i,void 0,`inline`).then(e=>{o(t=>({...t,pdfUrl:e.url,pdfUrlLoading:!1}))}).catch(e=>{console.warn(`Failed to get PDF URL:`,e),o(e=>({...e,pdfUrlLoading:!1}))}):o(e=>({...e,pdfUrlLoading:!1}))},[r,n.metadata,n.content?.type,n.content?.source]),t(P0.Provider,{value:a,children:e})}function I0(e,t,n){return e.files.getDownloadUrl(`${O0}/${t}/${n}`).then(e=>e.url)}function L0(){let e=ot.useContext(P0);if(!e)throw Error(`useMagicPdfContext must be used within a MagicPdfProvider`);return e}Q();function R0({object:e}){let{t:n}=K(),{client:r}=q(),i=t=>{I0(r,e.id,t).then(e=>window.open(e,`_blank`))};return t(o,{variant:`ghost`,size:`xs`,onClick:()=>i(`document.md`),title:n(`pdf.download`),children:t(xg,{className:`size-4`})})}Q();function z0({className:e}){return t(`div`,{className:`flex items-center justify-center ${e||``}`,children:t(ev,{className:`w-6 h-6 animate-spin text-muted`})})}function B0({viewType:e,pageNumber:n}){switch(e){case`json`:return t(V0,{pageNumber:n});case`markdown`:return t(H0,{pageNumber:n});default:return t(H0,{pageNumber:n})}}function V0({pageNumber:e}){let[n,r]=G(null),[i,a]=G(!0),[o,s]=G(null),{layoutProvider:c}=L0();return H(()=>{a(!0),s(null),c.getPageLayout(e).then(e=>{r(e?JSON.parse(e):null),a(!1)}).catch(e=>{console.error(e),s(e.message||`Failed to load layout`),a(!1)})},[e,c]),i?t(`div`,{className:`px-4 py-8`,children:t(z0,{})}):o?t(`div`,{className:`px-4 py-2 text-destructive text-sm`,children:o}):n?t(At,{className:`w-full`,data:n}):null}function H0({pageNumber:e}){let[r,i]=G(null),[a,o]=G(!0),[s,c]=G(null),{markdownProvider:l}=L0();return H(()=>{o(!0),c(null),l.getPageMarkdown(e).then(e=>{i(e),o(!1)}).catch(e=>{console.error(e),c(e.message||`Failed to load markdown`),o(!1)})},[e,l]),a?n(`div`,{className:`h-full flex flex-col items-center justify-center gap-2`,children:[t(z0,{}),t(`span`,{className:`text-sm text-muted`,children:`Loading...`})]}):s?t(`div`,{className:`px-4 py-2 text-destructive text-sm`,children:s}):t(`div`,{className:`px-4 py-2 prose prose-sm max-w-none dark:prose-invert`,children:r?t(Nt,{children:r}):t(`div`,{children:`No markdown content available`})})}Q(),SY();var U0=class extends ct{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`PDF View error:`,e,t)}render(){return this.state.hasError?t(`div`,{className:`fixed inset-0 bg-background z-50 flex items-center justify-center`,children:n(`div`,{className:`flex flex-col items-center gap-4 p-8 max-w-md`,children:[t(M,{title:Xt.t(`pdf.failedToLoadViewer`,{ns:Yt}),children:this.state.error?.message||`An unexpected error occurred`}),this.props.onClose&&t(o,{variant:`outline`,onClick:this.props.onClose,children:`Close`})]})}):this.props.children}};function W0({objectId:e,onClose:r}){let{t:i}=K(),{client:a}=q(),{data:s,error:c}=Ye(()=>a.store.objects.retrieve(e,`+text`),[e]);return c?t(`div`,{className:`fixed inset-0 bg-background z-50 flex items-center justify-center`,children:n(`div`,{className:`flex flex-col items-center gap-4 p-8 max-w-md`,children:[t(M,{title:i(`pdf.fetchingDocumentFailed`),children:Ge(c)}),r&&t(o,{variant:`outline`,onClick:r,children:`Close`})]})}):s?t(U0,{onClose:r,children:t(`div`,{className:`fixed inset-0 bg-background z-50 flex items-center justify-center`,children:t(F0,{object:s,children:t(G0,{object:s,onClose:r})})})}):n(`div`,{className:`fixed inset-0 bg-background z-50 flex flex-col`,children:[t(`div`,{className:`flex h-9 items-center justify-end shrink-0 bg-sidebar px-2 border-b border-sidebar-border`,children:r&&t(o,{variant:`ghost`,size:`xs`,onClick:r,title:i(`pdf.close`),children:t(Gb,{className:`size-4`})})}),t(`div`,{className:`flex-1 flex items-center justify-center`,children:t(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-primary`})})]})}function G0({object:e,onClose:r}){let{t:i}=K(),{count:a,pdfUrl:s,pdfUrlLoading:c}=L0(),[l,u]=G(1);return n(Ce,{direction:`horizontal`,className:`absolute inset-0`,children:[t(Se,{defaultSize:50,minSize:20,maxSize:80,className:`bg-muted`,children:t(gY,{pdfUrl:s,pdfUrlLoading:c,pageCount:a,className:`h-full`,currentPage:l,onChange:u})}),t(xe,{className:`w-[4px] bg-border cursor-ew-resize`}),n(Se,{defaultSize:50,minSize:20,className:`flex flex-col`,children:[n(`div`,{className:`flex h-9 items-center justify-between shrink-0 bg-sidebar px-2 border-b border-sidebar-border`,children:[t(`div`,{className:`flex items-center gap-x-2`,children:t(R0,{object:e})}),t(`span`,{className:`text-xs text-muted`,children:i(`pdf.pageOf`,{pageNumber:l,totalPages:a})}),t(`div`,{className:`flex items-center gap-x-2`,children:!!r&&t(o,{variant:`ghost`,size:`xs`,onClick:r,title:i(`pdf.close`),children:t(Gb,{className:`size-4`})})})]}),t(`div`,{className:`flex-1 overflow-auto px-2`,children:t(B0,{pageNumber:l,viewType:`markdown`})})]})]})}const K0=[`image/jpeg`,`image/jpg`,`image/png`,`image/gif`,`image/webp`,`image/svg+xml`],q0=[`video/mp4`,`video/webm`],J0=[`audio/mp4`,`audio/m4a`,`audio/x-m4a`,`audio/mpeg`,`audio/ogg`,`audio/wav`,`audio/webm`];function Y0(e){let t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=Math.floor(e%60);return t>0?`${t}:${n.toString().padStart(2,`0`)}:${r.toString().padStart(2,`0`)}`:`${n}:${r.toString().padStart(2,`0`)}`}function X0({url:e,source:r,object:i,className:a}){let{t:o}=K(),{client:s}=q(),[c,l]=G(e),[u,d]=G(!e&&(!!r||!!i)),f=i?.metadata,p=(f?.renditions||[]).find(e=>e.name===cn),m=i?.content?.type&&J0.includes(i.content.type),h=!!i&&i.metadata?.type===un.Audio&&!p&&!m;return H(()=>{if(e){l(e),d(!1);return}l(void 0),r||i?(d(!0),(async()=>{try{if(r){let e=await s.files.getDownloadUrl(r);l(e.url);return}if(!i||i.metadata?.type!==un.Audio)return;let e;p?.content?.source?e=await s.files.getDownloadUrl(p.content.source):m&&i.content?.source&&(e=await s.files.getDownloadUrl(i.content.source)),e&&l(e.url)}catch(e){console.error(`Failed to get audio URL`,e)}finally{d(!1)}})()):d(!1)},[e,r,i,p,m,s]),h?t(`div`,{className:`flex justify-center items-center h-[200px] text-muted ${a??``}`.trim(),children:n(`div`,{className:`text-center`,children:[t(`p`,{children:o(`store.noAudioRendition`)}),t(`p`,{className:`text-sm mt-2`,children:o(`store.audioFormatRequired`)})]})}):u?t(`div`,{className:`flex justify-center items-center h-[200px] ${a??``}`.trim(),children:t(je,{size:`md`})}):c?n(`div`,{className:`flex flex-col items-center gap-4 ${a??``}`.trim(),children:[t(`audio`,{src:c,controls:!0,className:`w-full max-w-2xl`,children:`Your browser does not support the audio tag.`}),f?.duration&&n(`div`,{className:`text-sm text-muted`,children:[`Duration: `,Y0(f.duration)]})]}):t(`div`,{className:`flex justify-center items-center h-[200px] text-muted ${a??``}`.trim(),children:`Failed to load audio`})}function Z0({url:e,source:n,object:r,className:i}){let{client:a}=q(),[o,s]=G(e),[c,l]=G(!e&&(!!n||!!r));return H(()=>{if(e){s(e),l(!1);return}s(void 0),n||r?(l(!0),(async()=>{try{if(n){let e=await a.files.getDownloadUrl(n);s(e.url);return}if(!r||r.metadata?.type!==un.Image)return;let e=r.content?.type&&K0.includes(r.content.type);try{let e=await a.objects.getRendition(r.id,{format:mn.jpeg,generate_if_missing:!1,sign_url:!0});if(e.status===`found`&&e.renditions?.length){s(e.renditions[0]);return}}catch{}if(e&&r.content?.source){let e=await a.files.getDownloadUrl(r.content.source);s(e.url)}}finally{l(!1)}})()):l(!1)},[e,n,r,a]),c?t(`div`,{className:i,children:t(je,{size:`md`})}):o?t(`img`,{src:o,alt:r?.name,className:`w-full object-contain ${i??``}`.trim()}):null}function Q0({url:e,source:r,object:i,className:a}){let{t:o}=K(),{client:s}=q(),[c,l]=G(e),[u,d]=G(),[f,p]=G(!e&&(!!r||!!i)),m=i?.metadata?.renditions||[],h=m.find(e=>e.content.type===`video/mp4`)||m.find(e=>e.content.type===`video/webm`),g=i?.content?.type&&q0.includes(i.content.type),_=m.find(e=>e.name===vn),v=!!i&&i.metadata?.type===un.Video&&!h&&!g;return H(()=>{if(e){l(e),p(!1);return}l(void 0),d(void 0),r||i?(p(!0),(async()=>{try{if(r){let e=await s.files.getDownloadUrl(r);l(e.url);return}if(!i||i.metadata?.type!==un.Video)return;let e;h?.content?.source?e=await s.files.getDownloadUrl(h.content.source):g&&i.content?.source&&(e=await s.files.getDownloadUrl(i.content.source)),e&&l(e.url)}catch(e){console.error(`Failed to get video URL`,e)}finally{p(!1)}})()):p(!1)},[e,r,i,h,g,s]),H(()=>{_?.content?.source&&s.files.getDownloadUrl(_.content.source).then(e=>d(e.url)).catch(e=>console.error(`Failed to load poster image`,e))},[_,s]),v?t(`div`,{className:`flex justify-center items-center h-[400px] text-muted ${a??``}`.trim(),children:n(`div`,{className:`text-center`,children:[t(`p`,{children:o(`store.noVideoRendition`)}),t(`p`,{className:`text-sm mt-2`,children:o(`store.videoFormatRequired`)})]})}):f?t(`div`,{className:`flex justify-center items-center h-[400px] ${a??``}`.trim(),children:t(je,{size:`md`})}):c?t(`video`,{src:c,poster:u,controls:!0,className:`w-full h-full object-contain ${a??``}`.trim(),children:`Your browser does not support the video tag.`}):t(`div`,{className:`flex justify-center items-center h-[400px] text-muted ${a??``}`.trim(),children:`Failed to load video`})}Q();function $0({oauthProviderId:r,onAuthChange:i}){let{client:a}=q(),{t:o}=K(),[s,c]=G(null),[l,u]=G(!0),[d,f]=G(!1),[p,m]=G(!1),h=V(async()=>{try{u(!0);let e=await a.oauthProviders.getStatus(r);c(e)}catch(e){console.error(`Failed to load OAuth provider status:`,e)}finally{u(!1)}},[a,r]);H(()=>{h()},[h]);let{openOAuthPopup:g}=pO({onComplete:()=>{f(!1),h(),i?.()},onError:e=>{console.error(`OAuth provider auth failed:`,e),f(!1)}});return l?t(dO,{className:`size-4`}):s?.authenticated?n(`div`,{className:`flex items-center gap-2`,children:[n(`div`,{className:`flex items-center gap-1 text-success text-sm`,children:[t(Ih,{className:`size-4`}),t(`span`,{children:o(`oauthProvider.connected`)})]}),t(oT,{variant:`outline`,size:`sm`,onClick:async()=>{if(!p)try{m(!0),await a.oauthProviders.disconnect(r),await h(),i?.()}catch(e){console.error(`Failed to disconnect OAuth provider:`,e)}finally{m(!1)}},disabled:p,children:p?t(dO,{className:`size-3`}):o(`oauthProvider.disconnect`)})]}):t(oT,{variant:`outline`,size:`sm`,onClick:async()=>{if(!d)try{f(!0);let e=await a.oauthProviders.authorize(r);e.authorization_url&&g(e.authorization_url)}catch(e){console.error(`Failed to authorize OAuth provider:`,e),f(!1)}},disabled:d,children:d?n(e,{children:[t(dO,{className:`size-4`}),t(`span`,{children:o(`oauthProvider.authenticating`)})]}):n(e,{children:[t(Dg,{className:`size-4 me-1`}),t(`span`,{children:o(`oauthProvider.authenticate`)})]})})}function e2(...e){let t=Array.from(e);return t.__AnyOf__=!0,t}function t2(...e){return Array.from(e)}function n2(e){return e.__AnyOf__===!0}function r2(e){if(e&&typeof e==`object`&&`status`in e&&typeof e.status==`number`)return e.status}function i2(e){let t=r2(e);return t===0||t===502||t===503||t===504||e instanceof Error&&e.name===`TimeoutError`}function a2(e,t){let n=U(()=>t?JSON.stringify(t):void 0,[t]),r=!!(t&&!t.permissions),[i,a]=G(0),[o,s]=G(),c=V(()=>a(e=>e+1),[]);return H(()=>{if(!r)return;let t=new AbortController,a=!1,o=0,c,l,u=t=>s({client:e,tokenKey:n,attempt:i,state:t}),d=()=>{a=!0,clearTimeout(f),clearTimeout(p),clearTimeout(l),t.abort()},f=setTimeout(()=>u({status:`retrying`}),5e3),p=setTimeout(()=>{d(),u({status:`error`,error:c})},6e4),m=async()=>{try{let n=await e.iam.roles.listSystem({signal:t.signal,timeoutMs:15e3,retryPolicy:!1});if(a)return;d(),u({status:`ready`,roles:n})}catch(e){if(a)return;if(c=e,!i2(e)){d(),u({status:`error`,error:e});return}u({status:`retrying`});let t=Math.min(1e3*2**o++,8e3)*(.5+Math.random()*.5);l=setTimeout(()=>{m()},t)}};return u({status:`loading`}),m(),d},[e,n,r,i]),{state:o?.client===e&&o.tokenKey===n&&o.attempt===i?o.state:{status:`loading`},retry:c}}var o2=class{system_roles;roles;permissions;constructor(e,t=[]){this.system_roles=t;let n=[...e.account_roles||[],...e.project_roles||[]],r=new Set(n);this.roles=r;let i=e.permissions??s2(n,t),a=e.type===bn.OAuthAccess?new Set(e.permissions??[]):void 0;this.permissions=new Set(a?i.filter(e=>a.has(e)):i)}hasPermission(e){if(typeof e==`string`)return this.permissions.has(e);if(n2(e))return e.some(e=>this.permissions.has(e));for(let t of e)if(!this.permissions.has(t))return!1;return!0}};function s2(e,t){let n=new Map(t.map(e=>[e.name,e.permissions])),r=new Set;for(let t of e)for(let e of n.get(t)??[])r.add(e);return Array.from(r)}const c2=dt(void 0);function l2(){let e=_t(c2);if(!e)throw Error(`UserPermissionContext cannot be used outside UserPermissionProvider`);return e}function u2({children:r,loadingIcon:i}){let{t:a}=K(),s=q(),c=s.authToken,{state:l,retry:u}=a2(s.client,c),d=U(()=>{if(c){if(c.permissions)return new o2(c);if(l.status===`ready`)return new o2(c,l.roles)}},[c,l]);if(c&&!d){let r=l.status===`error`,c=r?r2(l.error):void 0,d=c===401,f=c===403,p=a(d?`auth.recovery.credential.title`:f?`shell.accessDenied`:r?`permissions.connectionFailed`:`permissions.connecting`);return t(`div`,{className:`flex min-h-dvh items-center justify-center bg-background px-6 text-foreground`,children:n(`div`,{className:`w-full max-w-md space-y-6 text-center`,children:[t(`div`,{"aria-hidden":`true`,className:`flex justify-center`,children:i||!r&&t(je,{size:`2xl`,className:`text-info`})}),n(`div`,{role:r?`alert`:`status`,"aria-live":r?`assertive`:`polite`,className:`space-y-2`,children:[t(`h1`,{className:`text-xl font-semibold`,children:p}),t(`p`,{className:`text-muted`,children:d?a(`auth.recovery.credential.body`):f?a(`permissions.accessDenied`):r?a(`permissions.tryAgainLater`):l.status===`retrying`?a(`permissions.retrying`):a(`permissions.loadingPermissions`)})]}),r&&n(e,{children:[t(o,{variant:`outline`,onClick:d||f?()=>s.signOut():u,children:a(d||f?`auth.recovery.useDifferentAccount`:`auth.recovery.tryAgain`)}),l.error!=null&&n(`details`,{className:`text-start text-sm text-muted`,children:[t(`summary`,{className:`cursor-pointer`,children:a(`auth.recovery.technicalDetails`)}),t(`pre`,{className:`mt-2 max-h-48 overflow-auto whitespace-pre-wrap wrap-break-word`,children:Ge(l.error)})]})]})]})})}return d&&t(c2.Provider,{value:d,children:r})}function d2({permission:e,isDisabled:n,title:r,children:i,...a}){return l2().hasPermission(e)?t(o,{isDisabled:n,title:r,...a,children:i}):null}function f2({permission:e,...n}){return l2().hasPermission(e)?t(ar,{...n}):null}const p2=new WeakMap;function m2(e,t){let n=p2.get(e);n||(n=new Map,p2.set(e,n));let r=n.get(t);return r||(r=e.types.catalog.resolve(t).then(e=>e??void 0,()=>{p2.get(e)?.delete(t)}),n.set(t,r)),r}function h2(e,t){let n=p2.get(e);n&&(t?n.delete(t):n.clear())}Q();function g2(e){let t=e.configuration?.defaults?.system?.agent??e.configuration?.defaults?.base;return{environment:t?.environment,model:t?.model}}function _2(e){return e.name}function v2(e){return e.name}function y2(e){return e.split(`/`).filter(Boolean).pop()||e}function b2({value:e,onChange:r,disabled:i=!1,isLoading:a=!1}){let{client:s}=q(),{t:c}=K(),[l,u]=G([]),[d,f]=G([]),[p,m]=G(!0),[h,g]=G(!1),_=W(void 0);H(()=>{let e=!1;return m(!0),s.environments.list().then(t=>{e||u(t.slice().sort((e,t)=>e.name.localeCompare(t.name)))}).catch(t=>{console.warn(`Failed to list document editing environments`,t),e||u([])}).finally(()=>{e||m(!1)}),()=>{e=!0}},[s]),H(()=>{if(!e.environment){f([]),g(!1);return}let t=!1,n=e.environment;return g(!0),s.environments.retrieve(n).then(e=>{t||f((e.enabled_models??[]).map(e=>({id:e.id,name:e.name||e.id})).sort((e,t)=>e.name.localeCompare(t.name)))}).catch(e=>{console.warn(`Failed to load document editing models`,e),t||f([])}).finally(()=>{t||g(!1)}),()=>{t=!0}},[s,e.environment]);let v=l.find(t=>t.id===e.environment),y=U(()=>{if(e.model)return d.find(t=>t.id===e.model)??{id:e.model,name:y2(e.model)}},[d,e.model]),b=e=>{_.current=e.id,r({environment:e.id}),s.environments.retrieve(e.id).then(t=>{if(_.current!==e.id)return;let n=t.default_model??t.enabled_models?.[0]?.id;r({environment:e.id,model:n})}).catch(e=>{console.warn(`Failed to select a default document editing model`,e)})},x=t=>{_.current=void 0,r({environment:e.environment,model:t.id})},S=y?.name||c(`agent.documentEditingSelectModel`);return n(he,{children:[t(_e,{asChild:!0,children:n(o,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 max-w-[15rem] gap-1.5 px-2 text-xs`,"aria-label":c(`agent.documentEditingConfiguration`),title:c(`agent.documentEditingConfiguration`),children:[a?t(je,{size:`sm`}):t(Gy,{className:`size-3.5 shrink-0`}),t(`span`,{className:`min-w-0 truncate`,children:S}),t(rh,{className:`size-3.5 shrink-0 opacity-70`})]})}),n(ge,{align:`end`,className:`z-[1000000] w-80 space-y-3 p-3`,children:[n(`div`,{children:[t(`div`,{className:`text-sm font-semibold text-foreground`,children:c(`agent.documentEditingConfiguration`)}),t(`div`,{className:`mt-0.5 text-xs leading-4 text-muted`,children:c(i?`agent.documentEditingConfigurationLocked`:`agent.documentEditingConfigurationDescription`)})]}),n(`div`,{className:`space-y-1`,children:[t(`label`,{className:`text-xs font-medium text-foreground`,htmlFor:`document-editing-environment`,children:c(`agent.environment`)}),t(we,{id:`document-editing-environment`,by:`id`,options:l,value:v,optionLabel:_2,filterBy:`name`,placeholder:c(`agent.documentEditingSelectEnvironment`),onChange:b,disabled:i,isLoading:p})]}),n(`div`,{className:`space-y-1`,children:[t(`label`,{className:`text-xs font-medium text-foreground`,htmlFor:`document-editing-model`,children:c(`agent.model`)}),t(we,{id:`document-editing-model`,by:`id`,options:d,value:y,optionLabel:v2,filterBy:`name`,placeholder:c(`agent.documentEditingSelectModel`),onChange:x,disabled:i||!e.environment,isLoading:h,warnOnMissingValue:!1})]})]})]})}Q();function x2({isLocked:e,onToggleLock:r}){let{t:i}=K(),a=i(e?`agent.editingLockedTitle`:`agent.editingManuallyUnlockedTitle`),s=i(e?`agent.editingLockedDescription`:`agent.editingManuallyUnlockedDescription`),c=i(e?`agent.unlockEditing`:`agent.lockEditing`);return n(`div`,{className:`flex h-8 max-w-64 shrink-0 items-center gap-1 rounded-md border border-mixer-attention/30 bg-mixer-attention/10 ps-2 pe-1 text-attention`,role:e?`status`:`alert`,"aria-live":`polite`,children:[e?t(rv,{className:`size-3.5 shrink-0 animate-pulse`}):t(ov,{className:`size-3.5 shrink-0`}),t(We,{description:s,asChild:!0,children:t(`span`,{className:`min-w-0 truncate text-xs font-medium text-foreground`,children:a})}),t(`span`,{className:`sr-only`,children:s}),t(We,{description:c,asChild:!0,children:t(o,{variant:`ghost`,size:`sm`,className:`size-6 shrink-0 rounded p-0 text-attention hover:bg-mixer-attention/15`,onClick:r,"aria-label":c,children:t(e?ov:rv,{className:`size-3.5`})})})]})}const S2=/artifact:(?!agents\/)(?!documents\/)([^\s)\]"]+)/g;function C2(e){let t=new Set;for(let n of e.matchAll(S2))t.add(n[1].replace(/^\/+/,``));return[...t]}async function w2(e,t,n,r){let i=C2(t);if(i.length===0)return{content:t,persisted:[],failed:[]};let a=new Map,o=[],s=[];for(let t of i){let i=`documents/${r}/${t}`;try{await e.copyFile(`agents/${n}/${t}`,i),a.set(t,i),o.push({from:t,to:i})}catch(e){console.warn(`Failed to persist a referenced artifact; keeping a run-scoped link`,{artifact_path:t,error:e instanceof Error?e.message:String(e)}),a.set(t,`agents/${n}/${t}`),s.push(t)}}return{content:t.replace(S2,(e,t)=>{let n=a.get(t.replace(/^\/+/,``));return n?`artifact:${n}`:e}),persisted:o,failed:s}}const T2=[`ask_user`,`think`,`plan`,`update_plan`,`end_conversation`,`learn_artifact_operations`,`learn_code_execution`,`learn_content_authoring`,`learn_document_management`,`learn_document_search`,`learn_image_analysis`,`execute_shell`,`fetch_document`],E2=[`artifact_operations`,`code_execution`],D2=[`update_document`,`update_document_properties`,`create_document`,`set_document_type`,`merge_documents`,`import_file`,`create_or_update_object_type`,`disable_type`,`batch_execute`];function O2(e,t){return[`Direct edits are already saved to '${e}'. Use this compact unified diff as context only;`,`do not re-apply it. The artifact remains the current source of truth.`,"```diff",`--- a/${e}`,`+++ b/${e}`,t,"```"].join(`
1382
+ `)}const k2=`document-editing`,A2=`sys:GeneralAgent`,j2=new Set,M2=new Set([`text/markdown`,`text/x-markdown`]),N2=new Set([...M2,`text/plain`]);function P2(e,t){return`${e}:${t}`}function F2(e){return j2.has(e)}function I2(e,t){t?j2.add(e):j2.delete(e)}function L2(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:void 0}function R2(e){return`document-root:${e}`}function z2(e){return`document:${e}`}function B2(e,t){return{tags:[k2,R2(t),z2(e)],properties:{resource_kind:`store_document`,document_id:e,document_root_id:t}}}function V2(e,t){return{canEdit:e,canCollaborate:t}}function H2(e){return e?.split(`;`,1)[0]?.trim().toLowerCase()||void 0}function U2(e){let t=H2(e);return t!==void 0&&M2.has(t)}function W2(e){let t=H2(e);return t!==void 0&&N2.has(t)}function G2(e,t,n,r,i=A2){if(e.interaction!==i||e.started_by!==r||e.status===`cancelled`)return!1;let a=e.tags??[];if(!a.includes(k2))return!1;let o=L2(e.properties);return a.includes(R2(n))?o?.resource_kind===`store_document`&&o.document_root_id===n:a.includes(z2(n))||a.includes(z2(t))}async function K2(e,t,n,r,i,a){for(let o of t)try{let t=await e.retrieve(o);if(G2(t,n,r,i,a))return t}catch{}}async function q2(e,t,n,r,i=A2){let a=[R2(n),z2(n),z2(t)],o=new Set;for(let s of new Set(a))try{let a=(await e.search({interaction:i,started_by:r,tags:[s],limit:20,sort:[`updated_at:desc`]})).hits.map(e=>e.id).filter(e=>!o.has(e));for(let e of a)o.add(e);let c=await K2(e,a,t,n,r,i);if(c)return c}catch{break}return(await e.list({interaction:i,started_by:r,limit:100,sort:`updated_at`,order:`desc`})).items.find(e=>e.run_kind===`agent`&&G2(e,t,n,r,i))}var J2=class extends Error{constructor(e,t){super(e,t===void 0?void 0:{cause:t}),this.name=`DocumentEditingTargetError`}};async function Y2(e,t){let n=await e.retrieve(t),r=n;if(n.revision&&!n.revision.head){let i=(await e.getRevisions(n.id)).filter(e=>e.revision?.head===!0);if(i.length!==1)throw new J2(`Expected one head revision for document ${t}, found ${i.length}`);if(r=await e.retrieve(i[0].id),r.revision?.head!==!0)throw new J2(`Resolved document ${r.id} is no longer the current head`)}let i=r.content?.etag;if(!i)throw new J2(`Document ${r.id} has no content ETag`);let a=await e.getObjectText(r.id);if(typeof a.text!=`string`)throw new J2(`Document ${r.id} has no text content`);return{id:r.id,etag:i,content:a.text}}var X2=class extends be{idOf(e){return e.id}labelOf(e){return e.label}descriptionOf(e){return e.description}selectedClassName(e){return`border-3 border-primary`}};function Z2({isOpen:e,onClose:r,onConfirm:i,isLoading:a,uploadedFileName:s}){let{t:c}=K(),l=U(()=>[{id:`update`,label:c(`modal.saveVersion.updateCurrent`),description:c(s?`modal.saveVersion.updateWithFileDescription`:`modal.saveVersion.updateDescription`)},{id:`new-version`,label:c(`modal.saveVersion.createNew`),description:c(s?`modal.saveVersion.createWithFileDescription`:`modal.saveVersion.createDescription`)}],[c,s]),u=s?l[1]:l[0],[d,f]=G(u),[p,m]=G(``),h=new X2;H(()=>{e&&(f(u),m(``))},[u,e]);let g=d?.id===`new-version`;return n(se,{isOpen:e,onClose:r,className:`sm:max-w-md`,children:[t(ue,{children:c(`modal.saveChanges`)}),t(ce,{children:n(`div`,{className:`space-y-4`,children:[s&&t(`div`,{className:`mb-4 p-3 bg-info rounded-md`,children:n(`p`,{className:`text-sm text-info font-medium`,children:[c(`modal.saveVersion.replaceFile`),` `,t(`span`,{className:`font-bold`,children:s})]})}),t(`p`,{className:`text-sm text-mixer-muted/5`,children:c(`modal.saveVersion.howToSave`)}),t(ye,{adapter:h,options:l,selected:d,onSelect:e=>{f(e)}}),g&&t(L,{label:c(`modal.saveVersion.versionLabel`),description:c(`modal.saveVersion.versionLabelDescription`),className:`mt-3 ps-8`,children:t(te,{value:p,onChange:m,placeholder:c(`modal.saveVersion.versionLabelPlaceholder`),className:`w-full`})})]})}),n(le,{children:[t(o,{variant:`secondary`,onClick:r,disabled:a,children:c(`modal.cancel`)}),t(o,{variant:`primary`,onClick:async()=>{await i(g,g?p:void 0)},isLoading:a,children:c(`modal.save`)})]})]})}Q();function Q2(e){return e.length>12?`${e.slice(0,4)}…${e.slice(-4)}`:e}function $2(e){return`drafts/${e}.md`}function e4(e,t,n,r,i){return[`You are collaborating with the user on one specific Markdown document in Vertesia.`,`Canonical document: [${e.name||e.content?.name||`Document`}](store:${t})`,`Canonical base revision ID: ${t}`,`Canonical base ETag: ${n??`unavailable`}`,`Working copy artifact: ${r}`,``,`The working copy was hydrated and read before your first turn. It is the source of truth for this editing`,`session. Apply requested changes only to that artifact using edit_artifact. Preserve all unrelated content`,`exactly. User block edits may already be applied to the artifact; acknowledge them and continue from the`,`current artifact generation. Attachments may contain review comments to apply in bulk.`,``,`Do not call update_document, create_document, or write_artifact for this working copy. The user publishes`,`the artifact back to the canonical document with the Save to document button, which enforces the base ETag.`,``,`You may use execute_shell to regenerate charts, diagrams, and other derived assets. Write generated files`,`under '/home/daytona/out/' so they sync back to the run, then reference them from Markdown with a run-local`,`link such as 'artifact:out/chart.png'. Saving the document persists and rewrites those links automatically.`,``,`Images: never inline image data as base64 data URIs — it bloats the document and cannot be reliably edited.`,`Keep existing image references (e.g. 'artifact:documents/…' URLs) exactly as they are: they point to durable`,`storage that outlives this session. Files already in this run's artifact space may be referenced with`,`run-local links like 'artifact:files/photo.png' — publishing copies them into durable storage and rewrites`,`the links automatically.`,``,`User request: ${i}`].join(`
1383
+ `)}function t4(e,t,n){return[`The canonical document was updated outside this session, so publishing the working copy was rejected.`,`1) Fetch the latest canonical revision ${t} with fetch_document into 'drafts/${e}.theirs.md'.`,`2) Compare it with the working copy '${n}' and merge the external changes into the working copy with edit_artifact, preserving this session's edits.`,`3) Reply with a short list of what was merged, plus any conflicting passages and how you resolved them, so I can review before saving again.`].join(`
1384
+ `)}function n4(e,t,n){return[`Summarize the changes in the working copy '${n}' relative to the original document revision ${t}.`,`If you no longer have the original content, fetch it with fetch_document into 'drafts/${e}.base.md'.`,`Do not modify the working copy.`,`Reply with a concise changelog: grouped bullets, most important first, suitable for a revision note.`].join(`
1385
+ `)}function r4(e){if(!(!e||typeof e!=`object`||!(`status`in e)))return typeof e.status==`number`?e.status:void 0}function i4({original:e,workingCopy:r}){let i=U(()=>Vt(e,r),[e,r]),a=U(()=>({added:i.reduce((e,t)=>e+(t.type===`added`?t.text.length:0),0),removed:i.reduce((e,t)=>e+(t.type===`removed`?t.text.length:0),0)}),[i]);return n(`div`,{className:`flex h-full min-h-0 flex-col bg-muted/10`,children:[n(`div`,{className:`flex shrink-0 items-center justify-end gap-3 border-b border-mixer-muted/20 px-5 py-2 text-xs`,children:[n(`span`,{className:`text-destructive`,children:[`−`,a.removed]}),n(`span`,{className:`text-success`,children:[`+`,a.added]})]}),t(`div`,{className:`min-h-0 flex-1 overflow-auto p-5`,children:t(`pre`,{className:`mx-auto max-w-5xl whitespace-pre-wrap break-words rounded-lg border border-mixer-muted/25 bg-background p-5 font-mono text-xs leading-6 shadow-sm`,children:i.map((e,n)=>e.type===`removed`?t(`del`,{className:`bg-mixer-destructive/15 text-destructive line-through decoration-destructive/50`,children:e.text},n):e.type===`added`?t(`ins`,{className:`bg-mixer-success/15 text-success no-underline`,children:e.text},n):t(`span`,{children:e.text},n))})})]})}function a4({object:r,initialContent:i=``,onDocumentUpdated:a,onClose:s,sendMessageRef:c,model:l,startImmediately:u=!1}){let{client:d,project:f,store:m,user:h}=q(),{t:g}=K(),_=nt(),v=W(null),y=c??v,[x,S]=G(),[C,w]=G(!1),[T,E]=G(!1),[D,O]=G(!0),[k,A]=G(!0),[j,M]=G(!1),[N,P]=G(0),[F,I]=G(!1),L=JSON.stringify(l?{environment:l.env,model:l.model,model_options:l.options}:{}),ee=l!==void 0,R=U(()=>JSON.parse(L),[L]),[te,ne]=G(!ee),[re,ie]=G(!1),[ae,oe]=G(!1),[se,ce]=G(!1),[le,ue]=G(!1),[de,fe]=G(!1),[pe,me]=G(!1),[he,ge]=G({key:0}),[_e,ve]=G(i),[ye,be]=G(!1),[we,Te]=G(i),[Ee,De]=G(i),[Oe,ke]=G(`document`),[Ae,Me]=G(),[Ne,Pe]=G(r.id),[Fe,Ie]=G(r.content?.etag),[Le,Re]=G(),[ze,Be]=G(R),Ve=W(ee?`host`:`none`),He=W(void 0),Ue=W(new Set),z=W(void 0),Ke=W(!1),qe=W(null),Je=r.revision?.root||r.id,Ye=U(()=>$2(Je),[Je]),Xe=h?.sub?`user:${h.sub}`:void 0,Ze=`${f?.id??`no-project`}:${Je}`,Qe=`${Ze}:${r.type?.id??`no-type`}`,$e=Le?.key===Qe?Le.interaction:void 0,et=W(Ze),tt=W({editingScopeKey:Ze,id:r.id}),rt=W({documentId:r.id,documentRootId:Je}),it=ye&&_e!==Ee,at=le&&!de;rt.current.documentRootId!==Je&&(rt.current={documentId:r.id,documentRootId:Je}),tt.current.editingScopeKey!==Ze&&(tt.current={editingScopeKey:Ze,id:r.id}),H(()=>{et.current!==Ze&&(et.current=Ze,Ve.current=ee?`host`:`none`,Be(R),ne(!ee),Ue.current.clear(),ve(i),Te(i),De(i),be(!1),me(!1),ue(!1),fe(!1),Ke.current=!1,ke(`document`),Pe(r.id),Ie(r.content?.etag))},[Ze,ee,i,r.content?.etag,r.id,R]),H(()=>{let e=!1,t=Ze,n=tt.current.id;return A(!0),M(!1),Y2(m.objects,n).then(n=>{e||tt.current.editingScopeKey!==t||(tt.current={editingScopeKey:t,id:n.id},rt.current={documentId:n.id,documentRootId:Je},Pe(n.id),Ie(n.etag),Te(n.content),De(n.content))}).catch(n=>{console.warn(`Failed to resolve the document editing target`,{error:n,attempt:N}),!e&&tt.current.editingScopeKey===t&&M(!0)}).finally(()=>{!e&&tt.current.editingScopeKey===t&&A(!1)}),()=>{e=!0}},[Je,Ze,m.objects,N]),H(()=>{let e=!1,t=r.type?.id;if(!t){Re({key:Qe,interaction:A2});return}return m2(d,t).then(t=>{e||Re({key:Qe,interaction:t?.editing?.interaction?.trim()||`sys:GeneralAgent`})}),()=>{e=!0}},[d,Qe,r.type?.id]),H(()=>{x||Ve.current===`run`||(ee?(Ve.current=`host`,Be(R),ne(!1)):Ve.current===`host`&&(Ve.current=`none`,Be({})))},[x,ee,R]),H(()=>{if(ee){ne(!1);return}if(!f){ne(!1);return}let e=!1,t=Ze;return ne(!0),d.projects.retrieve(f.id).then(n=>{e||et.current!==t||Ve.current!==`none`||(Ve.current=`project`,Be(g2(n)))}).catch(e=>{console.warn(`Failed to load the default document editing model`,e)}).finally(()=>{e||ne(!1)}),()=>{e=!0}},[d,Ze,ee,f]),H(()=>{if(S(void 0),!Xe||!$e){O(!1);return}let e=!1;return O(!0),q2(d.agents,rt.current.documentId,Je,Xe,$e).then(t=>{e||!t||(S(t.id),t.config?.environment&&t.config.model&&(Ve.current=`run`,Be({environment:t.config.environment,model:t.config.model,model_options:t.config.model_options})))}).catch(e=>{console.warn(`Failed to look up an existing document editing run`,e)}).finally(()=>{e||O(!1)}),()=>{e=!0}},[d,Je,$e,Xe]);let B=V(e=>{Ve.current=`user`,Be(e)},[]),ot=V(()=>{x&&navigator.clipboard.writeText(x).then(()=>_({status:`success`,title:g(`agent.runIdCopied`),duration:2e3})).catch(e=>console.warn(`Failed to copy the agent run id`,e))},[x,g,_]),st=V(async()=>{if(!(!x||T)){E(!0);try{await d.agents.terminate(x,`cancel`),_({status:`success`,title:g(`agent.workflowCancelled`),duration:2e3})}catch(e){console.warn(`Failed to terminate the document editing run`,e)}finally{E(!1)}Ue.current.clear(),S(void 0),be(!1),ve(Ee),me(!1),Ke.current=!1,ue(!1),fe(!1)}},[x,d.agents,T,Ee,g,_]),ct=V(async(e,t)=>{if(!(!f||!$e||D||k||j||C||te)){w(!0);try{if(!ze.environment||!ze.model){_({status:`error`,title:g(`agent.documentEditingDefaultsRequired`),duration:5e3});return}let n=e4(r,Ne,Fe,Ye,e?.trim()||g(`agent.documentEditingInitialRequest`)),i=B2(Ne,Je),a={interaction:$e,interactive:!0,tool_approval_mode:t?.tool_approval_mode,tool_names:T2,excluded_tools:D2,initial_skills:E2,initial_tool_calls:[{id:`hydrate-working-copy`,tool:`fetch_document`,input:{id:Ne,mode:`content`,output_artifact:{path:Ye}}},{id:`read-working-copy`,tool:`read_artifact`,input:{path:Ye}}],data:{user_prompt:n},config:{environment:ze.environment,model:ze.model,model_options:ze.model_options},started_by:Xe,tags:i.tags,properties:i.properties},o=await d.agents.start(a);return S(o.id),{agent_run_id:o.id}}catch(e){console.error(`Failed to start document editing agent`,e),_({status:`error`,title:g(`agent.documentEditingStartFailed`),description:e instanceof Error?e.message:void 0,duration:5e3});return}finally{w(!1)}}},[d.agents,Je,Ye,ze,$e,te,D,k,C,r,f,Xe,g,Ne,Fe,j,_]),lt=V((e,t)=>{z.current=t,ve(e),be(!0)},[]);H(()=>{if(!u||x||!f||!$e||D||k||j||C||te||!ze.environment||!ze.model)return;let e=JSON.stringify({scope:Ze,interaction:$e,document:Ne,configuration:ze});He.current!==e&&(He.current=e,ct(g(`agent.documentEditingStartRequest`),{tool_approval_mode:`full_control`}))},[x,$e,Ze,ze,te,D,k,C,f,u,ct,g,Ne,j]);let ut=V(e=>{let t=Ke.current;Ke.current=e,ue(e),e||(fe(!1),t&&ge(e=>({key:e.key+1})))},[]),dt=V((e,t)=>{let n=y.current;if(!n){_({status:`warning`,title:g(`agent.artifactEditingUnavailable`),duration:3e3});return}n(e,t)},[y,g,_]),ft=V(e=>{let t=e.anchor.block_type.replaceAll(`_`,` `),n=e.comment?.trim()||g(`agent.editedSelectionMessage`,{blockType:t});dt(n,{editing_action:e})},[dt,g]),pt=V(async(e,t)=>{if(!(!ye||!Fe||!it||at||re||k||j)){ie(!0);try{let n=_e;x&&(n=(await w2(d.files,n,x,crypto.randomUUID())).content);let i=r.content?.type||`text/markdown`,o=r.content?.name||`content.md`,s=new File([new Blob([n],{type:i})],o,{type:i}),c=await m.objects.update(Ne,{content:s},{createRevision:e,revisionLabel:t,ifMatch:Fe});if(Pe(c.id),Ie(c.content?.etag),De(n),Me(void 0),oe(!1),a?.(c.id,e),_({status:`success`,title:g(`store.textSaved`),duration:2500}),x&&n!==_e&&z.current)try{await d.agents.updateArtifactContent(x,Ye,{content:n,generation:z.current}),ge(e=>({key:e.key+1}))}catch(e){console.warn(`Failed to sync persisted artifact links into the working copy`,e)}}catch(e){let t=r4(e),n=t===412;if(t===412||t===400)try{let e=await Y2(m.objects,Ne);(e.id!==Ne||t===412)&&(n=!0,Pe(e.id),Ie(e.etag),Me({headId:e.id}))}catch(e){console.warn(`Failed to resolve the new head after a save conflict`,e)}_({status:`error`,title:g(`store.errorSavingText`),description:n?g(`store.textConflict`):Ge(e,g(`store.errorSavingTextDefault`)),duration:5e3})}finally{ie(!1)}}},[x,_e,ye,d.agents,d.files,Ye,it,at,k,re,r.content?.name,r.content?.type,a,m.objects,g,Ne,Fe,j,_]),mt=V(()=>{let e=y.current;if(!e||!Ae){_({status:`warning`,title:g(`agent.artifactEditingUnavailable`),duration:3e3});return}e(t4(Je,Ae.headId,Ye)),Me(void 0),ke(`document`)},[Je,Ye,y,Ae,g,_]),ht=V(()=>{let e=y.current;if(!e){_({status:`warning`,title:g(`agent.artifactEditingUnavailable`),duration:3e3});return}e(n4(Je,tt.current.id,Ye))},[Je,Ye,y,g,_]),gt=V(async()=>Oe!==`editor`||!pe||!!await qe.current?.(),[pe,Oe]),_t=V(async e=>{e!==Oe&&await gt()&&ke(e)},[gt,Oe]),vt=V(async()=>{await gt()&&s?.()},[gt,s]),yt=V(async()=>{let e=y.current;if(!e||!x||at||se){_({status:`warning`,title:g(`agent.artifactEditingUnavailable`),duration:3e3});return}ce(!0);try{let t=await qe.current?.();if(!t)return;let n=Bt(t.previous,t.current,{context:1});n&&e(O2(Ye,n)),me(!1),_({status:`success`,title:g(`agent.changesSentToAgent`),duration:2e3})}finally{ce(!1)}},[x,Ye,at,se,y,g,_]);return n(`div`,{className:`flex h-full min-h-0 flex-col`,children:[n(`div`,{className:`flex h-14 shrink-0 items-center justify-between gap-3 border-b border-mixer-muted/20 px-4`,children:[n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`truncate font-semibold`,children:r.name||r.content?.name}),n(`div`,{className:`flex items-center gap-2 text-xs text-muted`,children:[n(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[it?t(`span`,{"aria-hidden":!0,className:`size-1.5 rounded-full bg-attention`}):ye?t(eh,{className:`size-3 text-success`}):null,g(it?`store.unsavedChanges`:`store.textSaved`)]}),t(`span`,{"aria-hidden":!0,className:`text-mixer-muted/60`,children:`·`}),t(We,{description:`${g(`agent.workingCopy`)}: ${Ye}`,asChild:!0,children:n(`span`,{className:`min-w-0 truncate font-mono`,children:[`drafts/`,Q2(Je),`.md`]})}),t(`span`,{"aria-hidden":!0,className:`text-mixer-muted/60`,children:`·`}),t(We,{description:`${g(`agent.originalDocument`)}: ${tt.current.id}`,asChild:!0,children:n(`span`,{className:`shrink-0 font-mono`,children:[g(`agent.originalDocument`).toLowerCase(),` `,Q2(tt.current.id)]})})]})]}),n(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[n(`div`,{className:`flex items-center rounded-md border border-mixer-muted/25 bg-muted/10 p-0.5`,children:[n(o,{variant:Oe===`document`?`secondary`:`ghost`,size:`sm`,className:`h-7 gap-1.5`,onClick:()=>void _t(`document`),children:[t(Gg,{className:`size-3.5`}),g(`agent.document`)]}),n(o,{variant:Oe===`editor`?`secondary`:`ghost`,size:`sm`,className:`h-7 gap-1.5`,onClick:()=>void _t(`editor`),children:[t(zg,{className:`size-3.5`}),g(`agent.fullEditor`)]}),n(o,{variant:Oe===`diff`?`secondary`:`ghost`,size:`sm`,className:`h-7 gap-1.5`,onClick:()=>void _t(`diff`),disabled:!ye||_e===we,children:[t(h_,{className:`size-3.5`}),g(`agent.reviewChanges`)]})]}),Oe===`diff`?n(o,{variant:`ghost`,size:`sm`,className:`h-8 gap-1.5`,onClick:ht,disabled:!ye||_e===we,children:[t(Z_,{className:`size-3.5`}),g(`agent.summarizeChanges`)]}):null,t(We,{description:g(`agent.refresh`),asChild:!0,children:t(o,{variant:`ghost`,size:`sm`,onClick:()=>ge(e=>({key:e.key+1})),disabled:!x,"aria-label":g(`agent.refresh`),children:t(hy,{className:`size-4`})})}),t(`div`,{"aria-hidden":!0,className:`mx-1 h-6 w-px bg-mixer-muted/25`}),t(b2,{value:ze,onChange:B,disabled:!!x||C||D,isLoading:te}),x?null:n(o,{variant:`primary`,size:`sm`,className:`h-8 gap-1.5`,onClick:()=>void ct(g(`agent.documentEditingStartRequest`)),disabled:C||D||k||te||j||!f||!$e||!ze.environment||!ze.model,children:[C?t(je,{size:`sm`}):t(Jy,{className:`size-4`}),g(C?`agent.startingAgent`:`agent.documentEditingStart`)]}),x?n(e,{children:[t(We,{description:x,asChild:!0,children:t(o,{variant:`ghost`,size:`sm`,className:`font-mono text-[11px] text-muted`,onClick:ot,"aria-label":g(`agent.copyRunId`),children:Q2(x)})}),t(We,{description:g(`agent.startNewConversation`),asChild:!0,children:t(o,{variant:`ghost`,size:`sm`,onClick:()=>{it?I(!0):st()},disabled:T,"aria-label":g(`agent.startNewConversation`),children:t(vy,{className:`size-4`})})})]}):null,t(`div`,{"aria-hidden":!0,className:`mx-1 h-6 w-px bg-mixer-muted/25`}),n(o,{variant:`primary`,className:`min-w-36 gap-2`,onClick:()=>oe(!0),disabled:!it||!Fe||at||re||k||j,children:[re?t(je,{size:`sm`}):t(wy,{className:`size-4`}),g(`agent.saveToDocument`)]}),s?t(o,{variant:`ghost`,size:`sm`,onClick:()=>void vt(),"aria-label":g(`agent.close`),children:t(Gb,{className:`size-4`})}):null]})]}),Ae?n(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-mixer-attention/30 bg-mixer-attention/10 px-4 py-2 text-sm`,children:[t(`span`,{className:`min-w-0 truncate text-attention`,children:g(`agent.saveConflictNotice`)}),n(`div`,{className:`flex shrink-0 items-center gap-2`,children:[t(o,{variant:`outline`,size:`sm`,onClick:mt,children:g(`agent.askAgentToReconcile`)}),t(o,{variant:`ghost`,size:`sm`,onClick:()=>Me(void 0),"aria-label":g(`agent.close`),children:t(Gb,{className:`size-4`})})]})]}):null,n(Ce,{direction:`horizontal`,className:`min-h-0 flex-1`,children:[t(Se,{defaultSize:65,minSize:35,className:`min-w-0 bg-background`,children:t(`div`,{className:`flex h-full min-h-0 flex-col`,children:t(`div`,{className:`min-h-0 flex-1`,children:Oe===`diff`?t(i4,{original:we,workingCopy:_e}):t(wt,{runId:x,path:Ye,viewMode:Oe===`editor`?`document`:`components`,baselineContent:we,initialContent:Ee,refreshKey:he.key,refreshDetails:he.details,readOnly:at,allowComments:!!x,onContentChange:lt,onAction:ft,onSendMessage:dt,onSendChangesToAgent:yt,hasUnsentChanges:it&&pe,isSendingChanges:se,sendChangesDisabled:!x||at,toolbarStatus:le?t(x2,{isLocked:at,onToggleLock:()=>fe(e=>!e)}):void 0,onDocumentEdit:()=>me(!0),flushChangesRef:qe})})})}),t(xe,{withHandle:!0}),t(Se,{defaultSize:35,minSize:25,className:`min-w-[320px]`,children:D||k?t(p,{className:`h-full`,children:t(je,{size:`lg`})}):j?n(p,{className:`h-full flex-col gap-3 px-6 text-center`,children:[t(`div`,{className:`text-sm text-muted`,children:g(`agent.failedToLoadDocument`)}),t(o,{variant:`outline`,size:`sm`,onClick:()=>P(e=>e+1),children:g(`agent.retry`)})]}):t(V1,{agentRunId:x,startWorkflow:ct,resetWorkflow:()=>S(void 0),onRestart:e=>S(e.id),sendMessageRef:y,onMessage:e=>{let t=e.details;if(!Ut(t,Ye))return;let n=`${e.timestamp}:${t?.path}:${t?.generation??``}`;Ue.current.has(n)||(Ue.current.add(n),ge(e=>({key:e.key+1,details:t})))},onAgentWorkingChange:ut,title:g(`agent.documentEditing`),initialMessage:g(`agent.documentEditingWelcome`),startButtonText:g(C?`agent.startingAgent`:`agent.startAgent`),placeholder:g(`agent.documentEditingPlaceholder`),initialToolApprovalMode:`full_control`,hideObjectLinking:!0,hideHeader:!0,showRightPanel:!1,fullWidth:!0,interactive:!0})})]}),t(b,{isOpen:F,title:g(`agent.newSessionDiscardTitle`),content:g(`agent.newSessionDiscardDescription`),onConfirm:()=>{I(!1),st()},onCancel:()=>I(!1)}),t(Z2,{isOpen:ae,onClose:()=>oe(!1),onConfirm:pt,isLoading:re})]})}function o4({object:e,initialContent:n,onClose:r,onDocumentUpdated:i,sendMessageRef:a,model:o,startImmediately:s}){let{t:c}=K();return t(se,{isOpen:!0,onClose:r,size:`full`,noCloseButton:!0,disableCloseOnClickOutside:!0,className:`gap-0 overflow-hidden p-0`,description:c(`agent.documentEditingWelcome`),children:t(a4,{object:e,initialContent:n,onClose:r,onDocumentUpdated:i,sendMessageRef:a,model:o,startImmediately:s})})}function s4({isOpen:r,onClose:i,object:a,refetch:s}){let{client:c,store:l}=q(),u=nt(),{t:d}=K(),{theme:f}=tt(),p=Qn(),[m,h]=G(!1),[g,_]=G(``),[v,y]=G(!1),[b,x]=G(null),S=W(void 0),[C,w]=G(null),[T,E]=G(null),D=V(async e=>{try{let t=await l.types.retrieve(e);t.object_schema&&w(t.object_schema)}catch(e){console.error(`Failed to fetch JSON schema:`,e)}},[l.types]);H(()=>{r&&(_(JSON.stringify(a.properties||{},null,2)),a.type?.id&&D(a.type.id))},[r,a,D]);let O=e=>{C&&e.json.jsonDefaults.setDiagnosticsOptions({validate:!0,schemas:[{uri:`http://myserver/object-schema.json`,fileMatch:[`*`],schema:C}]})};function k(){if(!S.current)return;let e=S.current.getValue();try{let t=JSON.parse(e);x(t),y(!0)}catch{u({status:`error`,title:d(`store.invalidJson`),description:d(`store.pleaseFixJsonSyntax`),duration:5e3})}}let A=e=>{_(e)};async function j(e,t){try{h(!0);let n=b||JSON.parse(g);if(e){let e=await c.objects.update(a.id,{properties:n},{createRevision:!0,revisionLabel:t});e.id!==a.id&&E(e.id),u({status:`success`,title:d(`store.newVersionCreated`),description:d(`store.newVersionCreatedDesc`),duration:2e3}),y(!1),i(),e.id!==a.id&&setTimeout(()=>{p(`/objects/${e.id}`),u({status:`info`,title:d(`store.viewingNewVersion`),description:t?d(`store.viewingVersionLabel`,{label:t}):d(`store.viewingNewVersionDefault`),duration:3e3})},100)}else await l.objects.update(a.id,{properties:n}),u({status:`success`,title:d(`store.propertiesUpdated`),description:d(`store.propertiesUpdatedDesc`),duration:2e3}),s&&await s(),y(!1),i()}catch(e){u({status:`error`,title:d(`store.errorUpdatingProperties`),description:Ge(e,d(`store.errorUpdatingPropertiesDefault`)),duration:5e3}),h(!1)}}function M(){y(!1)}return n(e,{children:[n(se,{isOpen:r,onClose:i,className:`sm:max-w-[90%] md:max-w-[80%] lg:max-w-[75%] xl:max-w-[70%]`,children:[t(ue,{children:d(`store.editProperties`)}),n(ce,{children:[n(`div`,{className:`mb-2 text-sm text-muted`,children:[a.type?.name?n(`span`,{children:[`Editing properties for object type: `,t(`strong`,{children:a.type.name})]}):t(`span`,{children:d(`store.editingGenericDocument`)}),C!==null&&t(`span`,{className:`ms-2 text-success`,children:`(JSON schema validation enabled)`})]}),t(`div`,{className:`h-[75vh] border rounded-md overflow-hidden`,children:t(Pt,{value:g,language:`json`,editorRef:S,onChange:e=>A(e.state.doc.toString()),beforeMount:O,theme:f===`dark`?`vs-dark`:`vs`})})]}),n(le,{children:[t(o,{variant:`secondary`,onClick:i,children:`Cancel`}),t(o,{variant:`primary`,onClick:k,children:`Save Changes`})]})]}),t(Z2,{isOpen:v,onClose:M,onConfirm:j,isLoading:m})]})}const c4=ht(()=>import(`@vertesia/ui/rich-text`).then(e=>({default:e.VertesiaMarkdownDocumentEditor})));function l4(e){switch(e){case`text/markdown`:case`text/x-markdown`:return`markdown`;case`application/json`:return`json`;case`application/xml`:case`text/xml`:return`xml`;default:return`plaintext`}}function u4({object:r,text:i,onClose:a,onSaved:s}){let{store:c}=q(),l=nt(),{t:u}=K(),{theme:d}=tt(),f=Qn(),p=W(void 0),[m,h]=G(i),[g,_]=G(!1),[v,y]=G(!1),[b,x]=G(!1),S=l4(r.content?.type),C=U2(r.content?.type);H(()=>{h(i),_(!1)},[i]);let w=V(()=>{g||_(!0)},[g]),T=V(e=>{h(e),_(e!==i)},[i]);function E(){!C&&!p.current||x(!0)}async function D(e,t){if(!C&&!p.current)return;let n=C?m:p.current?.getValue();if(n===void 0)return;let i=r.content?.type||`text/plain`,o=r.content?.name||`content.txt`;try{y(!0);let d=new Blob([n],{type:i}),p=new File([d],o,{type:i}),m=await c.objects.update(r.id,{content:p},{createRevision:e,revisionLabel:t,ifMatch:r.content?.etag});l({status:`success`,title:u(`store.textSaved`),duration:2e3}),x(!1),e&&m.id!==r.id?(a(),setTimeout(()=>{f(`/objects/${m.id}`)},100)):s()}catch(e){let t=Ge(e,u(`store.errorSavingTextDefault`)),n=(typeof e==`object`&&e&&`status`in e?e.status:void 0)===412||t.includes(`412`);l({status:`error`,title:u(`store.errorSavingText`),description:n?u(`store.textConflict`):t,duration:5e3})}finally{y(!1)}}return n(e,{children:[n(`div`,{className:`flex items-center gap-2 px-2 py-1 shrink-0`,children:[g&&t(`span`,{className:`text-xs text-attention`,children:u(`store.unsavedChanges`)}),t(`div`,{className:`flex-1`}),t(o,{variant:`ghost`,size:`sm`,onClick:a,disabled:v,children:u(`store.cancelEdit`)}),t(o,{variant:`secondary`,size:`sm`,onClick:E,disabled:!g,isLoading:v,children:u(`store.saveText`)})]}),t(`div`,{className:`flex-1 min-h-0 border rounded-md overflow-hidden mx-2 mb-2`,children:C?t(ut,{fallback:t(`div`,{className:`h-full w-full`}),children:t(c4,{value:m,onChange:T})}):t(Pt,{value:i,language:S,editorRef:p,onChange:w,theme:d===`dark`?`vs-dark`:`vs`,options:{wordWrap:`on`,minimap:{enabled:!1},lineNumbers:`on`,scrollBeyondLastLine:!1}})}),t(Z2,{isOpen:b,onClose:()=>x(!1),onConfirm:D,isLoading:v})]})}const d4=131072;function f4(e,t,n=!1,r=e){let{store:i}=q(),[a,o]=G(t),[s,c]=G(()=>t&&t.length>d4?t.substring(0,d4):t),[l,u]=G(!1),[d,f]=G(()=>!!t&&t.length>d4),[p,m]=G(),h=W(t),g=W(e),_=W(r),v=W(!1),y=V((e,t=!0)=>{let n=h.current;t&&n&&e&&n!==e?m(e=>({previousText:n,version:(e?.version??0)+1})):t||m(void 0),h.current=e,o(e),e&&e.length>d4?(c(e.substring(0,d4)),f(!0)):(c(e),f(!1))},[]),b=V(()=>{let t=e,n=r;u(!0),i.objects.getObjectText(e).then(e=>{if(g.current!==t)return;let r=_.current===n&&!v.current;y(e.text,r),v.current=!1}).catch(e=>{console.error(`Failed to load text`,e)}).finally(()=>{g.current===t&&u(!1)})},[y,r,e,i]);return bt(()=>{let i=g.current!==e,a=_.current!==r;g.current=e,_.current=r,a&&(v.current=!0),t!==void 0&&(y(t,!a),v.current=!1),n&&t===void 0&&(i||h.current===void 0)&&b()},[y,r,t,n,b,e]),{fullText:a,displayText:s,isLoading:l,isCropped:d,changeHighlight:p,loadText:b}}function p4(e,t){let{client:n}=q(),[r,i]=G({isComplete:!1});return H(()=>{if(!t)return;let r=!1,a,o=(e,t,n)=>{i(r=>{let i=JSON.stringify(r.progress??null),a=JSON.stringify(e??null);return r.status===t&&r.isComplete===n&&i===a?r:{progress:e,status:t,isComplete:n}})};function s(){r||n.objects.analyze(e).getStatus().then(e=>{e.status===Tn.RUNNING?(o(e.progress,e.status,!1),r||(a=setTimeout(s,2e3))):o(e.progress,e.status,!0)}).catch(()=>{r||(a=setTimeout(s,1e4))})}return s(),()=>{r=!0,a&&clearTimeout(a)}},[t,e,n]),{progress:r.progress,status:r.status,isComplete:r.isComplete}}function m4(e,t){let{client:n}=q(),r=Xt.getFixedT(null,Yt),[i,a]=G(),[o,s]=G(!1),[c,l]=G();return{pdfUrl:i,isConverting:o,error:c,triggerConversion:V(async()=>{if(!t||o)return;s(!0),l(void 0);let i=async t=>{try{let o=await n.objects.getRendition(e,{format:gn.pdf,generate_if_missing:t,sign_url:!0,block_on_generation:!1});o.status===`generating`?setTimeout(()=>i(!1),5e3):o.status===`found`&&o.renditions?.length?(a(o.renditions[0]),s(!1)):o.status===`failed`&&(l(r(`store.pdfConversionFailed`)),s(!1))}catch(e){console.error(`Failed to convert Office document to PDF:`,e),l(r(`store.failedToConvertToPdf`)),s(!1)}};await i(!0)},[e,t,o,n,r])}}Q(),ZY();const h4=()=>({a:({node:e,...n})=>{let r=n.href||``;return r.includes(`/store/objects/`)?t(Zn,{topLevelNav:!0,href:r,className:`text-info`,children:n.children}):t(`a`,{...n,target:`_blank`,rel:`noopener noreferrer`})},p:({node:e,...n})=>t(`p`,{...n,className:`my-0`}),pre:({node:e,...n})=>t(`pre`,{...n,className:`my-2 p-2 rounded`}),code:({node:e,className:n,children:r,...i})=>{let a=!/language-(\w+)/.exec(n||``);return t(`code`,{...i,className:a?`px-1.5 py-0.5 rounded`:`text-muted`,children:r})},h1:({node:e,...n})=>t(`h1`,{...n,className:`font-bold text-2xl my-2`}),h2:({node:e,...n})=>t(`h2`,{...n,className:`font-bold text-xl my-2`}),h3:({node:e,...n})=>t(`h3`,{...n,className:`font-bold text-lg my-2`}),li:({node:e,...n})=>t(`li`,{...n})});function g4(e){return e===dn.created||e===dn.processing}function _4(e){return e.metadata?.content_processor?.type}function v4(e){return e?e.includes(`
1386
1386
  # `)||e.includes(`
1387
1387
  ## `)||e.includes(`
1388
1388
  ### `)||e.includes(`
1389
1389
  * `)||e.includes(`
1390
1390
  - `)||e.includes(`
1391
- + `)||e.includes(`![`)||e.includes(`](`):!1}function v4(e){return e?`h-full overflow-auto`:`hidden`}var y4;(function(e){e.Text=`text`,e.Image=`image`,e.Video=`video`,e.Audio=`audio`,e.Pdf=`pdf`,e.Transcript=`transcript`})(y4||={});function b4({object:r,loadText:i,refetch:a,canEditProperties:o=!0,canCollaborate:s=!1}){let c=nt(),{t:l}=K(),{project:u,store:d}=q(),f=Qn(),p=r.revision?.root||r.id,m=u?.id?N2(u.id,p):void 0,[h,g]=G(r),[_,v]=G(()=>m?P2(m):!1),y=W(null),b=W(r.id),x=W(r.id),S=W(m);H(()=>{S.current!==m&&(S.current=m,v(m?P2(m):!1))},[m]);let C=V(()=>{v(e=>{let t=!e;return m&&F2(m,t),t})},[m]),w=V(()=>{m&&F2(m,!1),v(!1)},[m]);H(()=>{let e=x.current!==r.id;x.current=r.id,g(t=>!e&&t.id!==r.id?t:(b.current=r.id,t.id===r.id&&t.text&&!r.text?{...r,text:t.text}:r))},[r]);let T=V(async(e,t)=>{b.current=e;try{let[t,n]=await Promise.all([d.objects.retrieve(e),d.objects.getObjectText(e)]);b.current===e&&g({...t,text:n.text})}catch(e){console.error(`Failed to load the updated document revision`,e),c({status:`error`,title:l(`agent.failedToLoadDocument`),description:e instanceof Error?e.message:void 0,duration:5e3})}finally{t&&f(`/objects/${e}`)}},[f,d.objects,l,c]),E=async(e,t)=>{try{await navigator.clipboard.writeText(e),c({status:`success`,title:l(`store.contentCopied`,{type:l(t===`text`?`store.contentType`:`store.properties`)}),description:l(`store.successfullyCopied`,{type:t}),duration:2e3})}catch(e){console.error(`Failed to copy ${t}:`,e),c({status:`error`,title:l(`store.copyFailed`),description:l(`store.failedToCopy`,{type:t}),duration:5e3})}};return n(e,{children:[n(Ce,{direction:`horizontal`,className:`h-full`,children:[t(Se,{defaultSize:67,className:`min-w-[100px]`,children:t(S4,{object:h,loadText:i??!1,handleCopyContent:E,refetch:a,canCollaborate:s,isCollaborating:_,onToggleCollaborate:C})}),t(xe,{withHandle:!0}),t(Se,{defaultSize:33,className:`min-w-[100px]`,children:t(x4,{object:h,refetch:a??(()=>Promise.resolve()),handleCopyContent:E,canEditProperties:o})})]}),_?t(a4,{object:h,initialContent:h.text??``,onClose:w,onDocumentUpdated:(e,t)=>void T(e,t),sendMessageRef:y}):null]})}function x4({object:r,refetch:i,handleCopyContent:a,canEditProperties:s}){let{t:c}=K(),[l,u]=G(!1),[d,f]=G(!1);return n(e,{children:[n(`div`,{className:`flex flex-col h-full`,children:[n(`div`,{className:`flex justify-between items-center px-2`,children:[n(`div`,{className:`flex items-center gap-1 bg-muted mb-2 p-1 rounded`,children:[t(o,{variant:`${l?`ghost`:`primary`}`,size:`sm`,title:c(`store.previewProperties`),onClick:()=>u(!l),children:`Properties`}),t(o,{variant:`${l?`primary`:`ghost`}`,size:`sm`,title:c(`store.viewInJsonFormat`),onClick:()=>u(!l),children:`JSON`})]}),n(`div`,{className:`flex items-center gap-2`,children:[r.properties&&t(o,{variant:`ghost`,size:`sm`,title:`Copy properties`,onClick:()=>a(JSON.stringify(r.properties,null,2),`properties`),children:t(fg,{className:`size-4`})}),s&&t(u2,{permission:yn.content_write,variant:`ghost`,size:`sm`,onClick:()=>{f(!0)},title:`Edit properties`,className:`flex items-center gap-2`,children:t(Zy,{className:`size-4`})})]})]}),r.properties?t(`div`,{className:`flex-1 min-h-0 px-2`,children:t(jt,{value:r.properties,viewCode:l})}):t(`div`,{className:`flex-1 min-h-0 px-2`,children:t(`div`,{children:c(`store.noPropertiesDefined`)})})]}),t(o4,{isOpen:d,onClose:()=>{f(!1)},object:r,refetch:i})]})}function S4(e){let{client:n}=q(),r=e.object.type,i=r?.id,a=r?.default_view,{data:o}=Ye(async()=>!i||a?null:(await p2(n,i))?.intake?.default_view??null,[i,a]),s=a??o;return i&&!a&&o===void 0?t(`div`,{className:`flex h-full items-center justify-center`,children:t(je,{size:`lg`})}):t(C4,{...e,defaultView:s??void 0})}function C4({object:e,loadText:r,handleCopyContent:i,refetch:a,defaultView:s,canCollaborate:c,isCollaborating:l,onToggleCollaborate:u}){let{client:d}=q(),{t:f}=K(),p=e?.metadata?.type===un.Image,m=e?.metadata?.type===un.Video,h=e?.metadata?.type===un.Audio,g=e?.content?.type===`application/pdf`,_=e?.content?.type?p$(e.content.type):!1,v=h4(e?.status),y=!!(e.transcript&&(m||h)),b=e.metadata?.renditions?.find(e=>e.name===_n),x=()=>{switch(s){case`text`:return y4.Text;case`pdf`:if(g||_||b)return y4.Pdf;break;case`image`:if(p)return y4.Image;break;case`properties`:return y4.Text}return m?y4.Video:h?y4.Audio:p?y4.Image:y4.Text},S=p0(e.id),[C,w]=G(x()),[T,E]=G(C===y4.Pdf);H(()=>{C===y4.Pdf&&E(!0)},[C]);let[D,O]=G(!1),k=B2(!!(e.content?.type&&!e.is_locked&&e.user_permissions?.can_write!==!1&&(e.content.type.startsWith(`text/`)||e.content.type===`application/json`||e.content.type===`application/xml`)),c),{fullText:A,displayText:j,isLoading:M,isCropped:N,loadText:P}=d4(e.id,e.text,r,e.revision?.root||e.id),F=(g||_)&&v&&(C===y4.Text||C===y4.Pdf),{progress:I,status:L,isComplete:ee}=f4(e.id,F),{pdfUrl:R,isConverting:te,error:ne,triggerConversion:re}=p4(e.id,_),ie=U(()=>[{id:`office-pdf-rendition`,target:`pdf`,canConvert:({contentType:e,extension:t})=>_||(e?p$(e):!1)||[`doc`,`docx`,`ppt`,`pptx`].includes(t),convert:async()=>{let t=await d.objects.getRendition(e.id,{format:gn.pdf,generate_if_missing:!0,sign_url:!0,block_on_generation:!0});return t.status===`found`&&t.renditions?.length?{url:t.renditions[0],contentType:`application/pdf`,fileName:`${e.name||`document`}.pdf`}:null}}],[d,_,e.id,e.name]);H(()=>{ee&&L===Tn.COMPLETED&&P()},[ee,L,P]);let ae=(g||_)&&v&&!ee&&L===Tn.RUNNING,oe=C===y4.Pdf&&!ae,se=ae&&(C===y4.Text||C===y4.Pdf),ce=T&&!ae,le=W(null);return n(`div`,{className:`flex flex-col h-full`,children:[n(`div`,{className:`flex justify-between items-center px-2 shrink-0`,children:[n(`div`,{className:`flex items-center gap-2 mb-2`,children:[n(`div`,{className:`flex items-center gap-1 bg-muted p-1 rounded`,children:[p&&t(o,{variant:C===y4.Image?`primary`:`ghost`,size:`sm`,title:f(`store.viewImage`),onClick:()=>w(y4.Image),children:`Image`}),m&&t(o,{variant:C===y4.Video?`primary`:`ghost`,size:`sm`,title:f(`store.viewVideo`),onClick:()=>w(y4.Video),children:`Video`}),h&&t(o,{variant:C===y4.Audio?`primary`:`ghost`,size:`sm`,title:f(`store.viewAudio`),onClick:()=>w(y4.Audio),children:`Audio`}),y&&t(o,{variant:C===y4.Transcript?`primary`:`ghost`,size:`sm`,title:f(`store.viewTranscript`),onClick:()=>w(y4.Transcript),children:`Transcript`}),t(o,{variant:C===y4.Text?`primary`:`ghost`,size:`sm`,title:f(`store.viewText`),onClick:()=>w(y4.Text),children:`Text`}),g&&t(o,{variant:C===y4.Pdf?`primary`:`ghost`,size:`sm`,title:f(`store.viewPdf`),onClick:()=>w(y4.Pdf),children:`PDF`}),_&&t(o,{variant:C===y4.Pdf?`primary`:`ghost`,size:`sm`,title:f(`store.viewAsPdf`),onClick:()=>{w(y4.Pdf),!b&&!R&&!te&&re()},disabled:te,children:te?t(je,{size:`sm`}):`PDF`})]}),n(`div`,{className:`flex items-center gap-1`,children:[t(D4,{object:e}),t(O4,{objectId:e.id,available:S})]})]}),C===y4.Text&&!ae&&!D&&t(w4,{object:e,text:j,fullText:A,handleCopyContent:i,textContainerRef:le,isEditing:D,onToggleEdit:()=>O(!0),canEdit:k.canEdit,isCollaborating:l,onToggleCollaborate:u,canCollaborate:k.canCollaborate}),C===y4.Pdf&&_&&(b||R)&&t(k4,{object:e,pdfRendition:b,officePdfUrl:R})]}),C===y4.Image&&t(`div`,{className:v4(!0),children:t(X0,{object:e})}),C===y4.Video&&t(`div`,{className:v4(!0),children:t(Z0,{object:e})}),C===y4.Audio&&t(`div`,{className:v4(!0),children:t(Y0,{object:e})}),y&&C===y4.Transcript&&t(`div`,{className:v4(!0),children:t(E4,{object:e,handleCopyContent:i})}),g&&ce&&t(`div`,{className:v4(oe),children:t(A4,{object:e})}),_&&ce&&t(`div`,{className:v4(oe),children:t(j4,{object:e,pdfRendition:b,officePdfUrl:R,converters:ie,officePdfConverting:te,officePdfError:ne})}),se&&t(`div`,{className:v4(!0),children:t(M4,{progress:I,status:L})}),C===y4.Text&&!ae&&!D&&M&&!j&&t(`div`,{className:v4(!0),children:t(`div`,{className:`flex justify-center items-center flex-1`,children:t(je,{size:`lg`})})}),C===y4.Text&&!ae&&!D&&(!M||j)&&t(`div`,{className:v4(!0),children:t(T4,{object:e,text:j,isTextCropped:N,textContainerRef:le})}),D&&C===y4.Text&&A!=null&&t(l4,{object:e,text:A,onClose:()=>O(!1),onSaved:()=>{O(!1),P(),a?.()}})]})}function w4({object:r,text:i,fullText:a,handleCopyContent:s,onToggleEdit:c,canEdit:l,isCollaborating:u,onToggleCollaborate:d,canCollaborate:f}){let{client:p,project:m}=q(),h=nt(),{t:g}=K(),_=r.content,{renderDocument:v,isDownloading:y}=tG({client:p,toast:h}),{data:b}=Ye(()=>m?p.projects.retrieve(m.id):Promise.resolve(void 0),[m?.id]),x=b?.configuration?.pdf_template_object_id??void 0,S=H2(_?.type),C=U2(_?.type),T=async(e,t)=>{if(y)return;h({status:`info`,title:`Preparing ${e.toUpperCase()}`,description:g(`store.renderingDocument`),duration:2e3});let n=t===!1?void 0:x;await v(r.id,{format:e,title:r.name||`document`,useDefaultTemplate:t,templateObjectId:n})};return t(`div`,{className:`h-[41px] text-lg font-semibold flex justify-between items-center px-2`,children:n(`div`,{className:`flex items-center gap-2`,children:[a&&t(o,{variant:`ghost`,size:`sm`,title:`Copy text`,onClick:()=>s(a,`text`),children:t(fg,{className:`size-4`})}),y?t(o,{variant:`ghost`,size:`sm`,disabled:!0,className:`h-8 w-8 p-0`,title:g(`agent.download`),"aria-label":g(`agent.download`),children:t(je,{size:`sm`})}):n(w,{trigger:t(o,{variant:`ghost`,size:`sm`,disabled:!i,className:`h-8 w-8 p-0`,title:g(`agent.download`),"aria-label":g(`agent.download`),children:t(xg,{className:`size-4`})}),children:[a&&t(ae,{onClick:e=>{if(e.preventDefault(),e.stopPropagation(),!a)return;let t=`txt`,n=`text/plain`;_?.type===`application/xml`||_?.type===`text/xml`?(t=`xml`,n=`text/xml`):S&&(t=`md`,n=`text/markdown`);let i=new Blob([a],{type:n}),o=URL.createObjectURL(i),s=`${r.name||`document`}.${t}`,c=document.createElement(`a`);c.href=o,c.download=s,c.style.display=`none`,setTimeout(()=>{c.click(),URL.revokeObjectURL(o)},0)},children:n(`div`,{className:`flex items-center gap-2`,children:[t(xg,{className:`size-4`}),`Download Text`]})}),S&&i&&n(e,{children:[t(ae,{onClick:()=>T(gn.docx),children:n(`div`,{className:`flex items-center gap-2`,children:[t(xg,{className:`size-4`}),`Export as DOCX`]})}),t(ae,{onClick:()=>T(gn.pdf,!1),children:n(`div`,{className:`flex items-center gap-2`,children:[t(xg,{className:`size-4`}),`Export as PDF`]})}),t(ae,{onClick:()=>T(gn.pdf),children:n(`div`,{className:`flex items-center gap-2`,children:[t(xg,{className:`size-4`}),`Export as Branded PDF`]})})]})]}),a&&n(e,{children:[l&&c&&t(u2,{permission:yn.content_write,variant:`ghost`,size:`sm`,onClick:c,title:g(`store.editText`),"aria-label":g(`store.editText`),className:`h-8 w-8 p-0`,children:t(Zy,{className:`size-4`})}),f&&d&&C&&t(o,{variant:u?`primary`:`ghost`,size:`sm`,onClick:d,title:g(`agent.editWithAI`),"aria-label":g(`agent.editWithAI`),className:`h-8 w-8 p-0`,children:t(Jy,{className:`size-4`})})]})]})})}const T4=gt(({object:r,text:i,isTextCropped:a,textContainerRef:o})=>{let{t:s}=K(),c=h4(r?.status),l=r.content,u=g4(r)===`xml`||l?.type===`application/xml`||l?.type===`text/xml`,d=U2(l?.type),f=!u&&(d||_4(i)),p={id:r.id,title:r.name,fileName:r.content?.name||r.name,contentType:u?`text/xml`:f?`text/markdown`:r.content?.type,content:i,sourcePath:r.content?.source};return i?n(e,{children:[a&&t(`div`,{className:`px-2 py-2 bg-attention/10 border-s-4 border-attention mx-2 mb-2 rounded`,children:n(`div`,{className:`flex items-center gap-2 text-attention`,children:[t(vb,{className:`size-4`}),t(`span`,{className:`text-sm font-semibold`,children:s(`store.showingFirst128K`)})]})}),t(`div`,{className:`max-w-7xl px-2 h-full overflow-auto`,ref:o,children:t(YY,{source:p,className:`h-full`,bodyClassName:`overflow-auto`,markdownComponents:m4()})})]}):t(`div`,{className:`px-2`,children:t(`div`,{children:c?`Extracting content...`:`No content`})})});function E4({object:e,handleCopyContent:r}){let{t:i}=K(),a=e.transcript,s=a?.text,c=a?.segments,l=s||(c?c.map(e=>e.text).join(` `):``),u=e=>{let t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=Math.floor(e%60);return t>0?`${t}:${n.toString().padStart(2,`0`)}:${r.toString().padStart(2,`0`)}`:`${n}:${r.toString().padStart(2,`0`)}`};return n(`div`,{className:`flex flex-col h-full`,children:[t(`div`,{className:`flex justify-end items-center px-2 mb-2`,children:l&&t(o,{variant:`ghost`,size:`sm`,title:`Copy transcript`,onClick:()=>r(l,`text`),children:t(fg,{className:`size-4`})})}),t(`div`,{className:`h-full} overflow-auto px-2`,children:c&&c.length>0?t(`div`,{className:`space-y-2`,children:c.map((e,r)=>n(`div`,{className:`flex gap-3 text-sm`,children:[n(`span`,{className:`text-muted font-mono text-xs shrink-0 pt-0.5`,children:[u(e.start),e.end&&` - ${u(e.end)}`]}),t(`span`,{className:`flex-1`,children:e.text})]},`segment-${r}`))}):s?t(`pre`,{className:`text-wrap bg-muted text-muted p-2 whitespace-pre-wrap`,children:s}):t(`div`,{className:`text-muted`,children:i(`store.noTranscriptAvailable`)})})]})}function D4({object:r}){let[i,a]=G(!1);return g4(r)===`markdown`?n(e,{children:[t(o,{variant:`ghost`,size:`sm`,onClick:()=>a(!0),title:`Side by side view`,children:t(Hg,{className:`size-4`})}),i&&t(ve,{children:t(U0,{objectId:r.id,onClose:()=>a(!1)})})]}):null}function O4({objectId:r,available:i}){let{t:a}=K(),[s,c]=G(!1);return i?n(e,{children:[t(o,{variant:`ghost`,size:`sm`,onClick:()=>c(!0),title:a(`grounded.title`),"aria-label":a(`grounded.title`),children:t(Dy,{className:`size-4`})}),s&&t(ve,{children:t(g0,{objectId:r,onClose:()=>c(!1)})})]}):null}function k4({object:e,pdfRendition:n,officePdfUrl:r}){let{client:i}=q(),a=nt(),{t:s}=K(),[c,l]=G(!1);return t(`div`,{className:`flex items-center gap-2`,children:t(o,{variant:`ghost`,size:`sm`,onClick:async()=>{l(!0);try{let t=r;!t&&n?.content?.source&&(t=(await i.files.getDownloadUrl(n.content.source,`${e.name||`document`}.pdf`,`attachment`)).url),t&&window.open(t,`_blank`)}catch(e){console.error(`Failed to download PDF:`,e),a({status:`error`,title:s(`store.downloadFailed`),description:s(`store.failedToDownloadPdf`),duration:5e3})}finally{l(!1)}},disabled:c,title:`Download PDF`,children:c?t(je,{size:`sm`}):t(xg,{className:`size-4`})})})}function A4({object:e}){let n={id:e.id,title:e.name,fileName:e.content?.name||e.name,contentType:e.content?.type,sourcePath:e.content?.source};return t(`div`,{className:`h-full`,children:t(YY,{source:n,className:`h-full`,showHeader:!1})})}function j4({object:e,pdfRendition:r,officePdfUrl:i,converters:a,officePdfConverting:o,officePdfError:s}){let{t:c}=K();if(o)return n(`div`,{className:`flex flex-col justify-center items-center flex-1 gap-2`,children:[t(je,{size:`lg`}),t(`span`,{className:`text-muted`,children:c(`store.convertingToPdf`)})]});if(s)return n(`div`,{className:`flex flex-col justify-center items-center flex-1 gap-2 text-destructive`,children:[t(vb,{className:`size-8`}),t(`span`,{children:s})]});if(r?.content?.source){let n={id:e.id,title:e.name,fileName:`${e.name||`document`}.pdf`,contentType:`application/pdf`,sourcePath:r.content.source};return t(`div`,{className:`h-full`,children:t(YY,{source:n,className:`h-full`})})}if(i){let n={id:e.id,title:e.name,fileName:`${e.name||`document`}.pdf`,contentType:`application/pdf`,url:i};return t(`div`,{className:`h-full`,children:t(YY,{source:n,className:`h-full`})})}let l={id:e.id,title:e.name,fileName:e.content?.name||e.name,contentType:e.content?.type,sourcePath:e.content?.source};return t(`div`,{className:`h-full`,children:t(YY,{source:l,converters:a,className:`h-full`})})}function M4({progress:r,status:i}){let{t:a}=K(),o=b$(i),s=x$(i),c=r?.phase===`grounded_extraction`,l=r?.percent!=null&&!Number.isNaN(r.percent)?r.percent:0;return n(`div`,{className:`px-4 py-4`,children:[r&&n(`div`,{className:`space-y-2`,children:[n(`div`,{className:`flex flex-col gap-1`,children:[t(N4,{name:c?`Prepare Evidence`:`Analyze Page`,progress:r.pages}),c&&n(e,{children:[t(N4,{name:`Run OCR`,progress:r.images}),t(N4,{name:`Extract Grounded Data`,progress:r.tables}),t(N4,{name:`Review and Annotate`,progress:r.visuals})]})]}),n(`div`,{className:`pt-2 text-sm text-muted`,children:[`Progress: `,l,`%`,t(`span`,{className:`px-2`,children:`•`}),t(`span`,{className:o,children:s}),r.started_at&&n(e,{children:[t(`span`,{className:`px-2`,children:`•`}),n(`span`,{children:[((Date.now()-r.started_at)/1e3).toFixed(0),` sec. elapsed`]})]})]}),t(Ft,{percent:l})]}),!r&&n(`div`,{className:`flex items-center gap-2 text-muted`,children:[t(je,{size:`sm`}),t(`span`,{children:a(`store.loadingProcessingStatus`)})]})]})}function N4({name:e,progress:t}){return n(`div`,{className:`flex gap-2 text-sm`,children:[n(`span`,{className:`text-muted min-w-36`,children:[e,`:`]}),n(`span`,{children:[t.processed,` of `,t.total]})]})}Q();const P4=Object.values(xn),F4=Object.values(Cn);function I4({onChange:e,isLoading:r,refresh:i,searchTypes:a}){let{client:s,project:c}=q(),{t:l}=K(),u=nt(),[d,f]=G(void 0),[p,h]=G(void 0),g=!!c&&(!!p?.embeddings.text||!!p?.embeddings.image),[_,v]=G(void 0),y=W(i),b=W(void 0),[x,S]=G(!1),[C,w]=G(a||P4),[T,E]=G(100);H(()=>{a&&w(a)},[a]);let D={},O=!1,k=!1;C.forEach(e=>{e===xn.full_text?O=!0:k=!0,F4.includes(e)&&(D[e]=!0)}),H(()=>{y.current!==i&&(y.current=i,f(void 0),v(void 0))}),H(()=>{c&&s.projects.retrieve(c.id).then(e=>{h(e.configuration)})},[s.projects.retrieve,c]),H(()=>{_&&u({title:_,status:`success`,duration:2e3})},[_,u]),H(()=>{let t=b.current;b.current=d,t&&(!d||d.length===0)&&e(void 0)},[e,d]);let A=()=>{!g||!d||(e({vector:k?{text:d,config:D}:void 0,full_text:O?d:void 0,limit:T}),v(`Searching...`))},j=e=>{e.key===`Enter`&&A()},M=e=>t=>{w(t?t=>Array.from(new Set([...t,e])):t=>t.filter(t=>t!==e))};return n(`div`,{className:`flex gap-1 items-center`,children:[t(te,{placeholder:l(`store.searchPlaceholder`),value:d,onChange:f,onKeyDown:j,className:`min-w-[200px]`}),t(o,{variant:`ghost`,onClick:()=>S(!0),title:l(`store.semanticSearchSettings`),className:`ms-1`,children:t(Iy,{size:18})}),n(se,{isOpen:x,onClose:()=>S(!1),children:[t(ue,{children:l(`store.searchTypes`)}),t(ce,{children:n(`div`,{className:`flex flex-col gap-2`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(m,{id:`search-type-full_text`,checked:C.includes(xn.full_text),onCheckedChange:M(xn.full_text)}),t(re,{htmlFor:`search-type-full_text`,children:l(`store.fullText`)})]}),t(`div`,{className:`font-semibold mt-2 mb-1`,children:l(`store.embeddings`)}),F4.map(e=>n(`div`,{className:`flex items-center gap-2`,children:[t(m,{id:`search-type-${e}`,checked:C.includes(e),onCheckedChange:M(e)}),t(re,{htmlFor:`search-type-${e}`,children:e.charAt(0).toUpperCase()+e.slice(1)})]},e)),n(`div`,{className:`mt-3`,children:[t(`span`,{className:`me-2`,children:l(`store.limit`)}),t(de,{type:`number`,min:1,value:T,onChange:e=>E(Number(e??100)),style:{width:80}})]})]})}),t(le,{children:t(o,{variant:`outline`,onClick:()=>S(!1),children:l(`store.close`)})})]}),t(o,{variant:`secondary`,isLoading:r,onClick:A,isDisabled:!g,title:l(`store.semanticSearch`),children:l(`store.search`)})]})}Q();const L4=[{name:`ID`,field:`id`,type:`objectId?slice=-7`},{name:`Name`,field:`.`,type:`objectName`},{name:`Type`,field:`type.name`,type:`string`},{name:`Status`,field:`status`,type:`string`},{name:`Updated At`,field:`updated_at`,type:`date`}];function R4(e,t){return(t?e.getTypeLayout(t):L4)??L4}function z4({onUploadDone:e=async()=>{},layout:n,toolbarActions:r}){let i=R$(),a=nt(),{t:o}=K(),s=J$(V(async t=>{await e(t),setTimeout(()=>{console.log(`Delayed refresh after upload to ensure backend consistency`),i.search().then(e=>{e&&a({title:o(`store.documentListRefreshed`),description:o(`store.documentListRefreshedDesc`),status:`info`,duration:3e3})}).catch(e=>{console.error(`Failed to refresh search results:`,e)})},1e3)},[e,i,o,a])),c=V((e,t)=>{let n=i.collectionId;return s(e,t,n)},[i,s]);return t(B4,{layout:n,onUpload:c,toolbarActions:r})}function B4({layout:e,onUpload:r,allowFilter:i=!0,allowSearch:a=!0,toolbarActions:o}){let{t:s}=K(),c=R$(),[l,u]=G(!1),[d,f]=G(null),{registry:p}=tQ(),{search:m,isLoading:h,error:g,objects:_,hasMore:v}=B$(),[y,b]=G(p?e||R4(p,m.query.type):L4);H(()=>{e&&b(e)},[e]);let[x,S]=G(0),[C,w]=G(0),[T,E]=G(localStorage.getItem(r1.LAST_DISPLAYED_VIEW)===`grid`),[D,O]=G([]),k=W(null),A=W(null),j=V((e,t)=>{u(!1),e.catch(e=>{console.error(t,e)}).finally(()=>{u(!0)})},[]);H(()=>{let e=!1;return m.initialized?(u(!0),()=>{e=!0}):(u(!1),w(0),m.search().catch(t=>{e||console.error(`Initial search failed:`,t)}).finally(()=>{e||u(!0)}),()=>{e=!0})},[m]),H(()=>{_.length<C&&w(_.length)},[_.length,C]),Qe(k,()=>{l&&_.length>0&&_.length!==C&&(u(!1),m.loadMore().catch(e=>{console.error(`Failed to load more search results:`,e)}).finally(()=>{w(_.length),u(!0)}))},{deps:[l,_.length]});let N=e=>{if(e?.vector){if(m.query.vector=e.vector,m.query.full_text=e.full_text,m.query.weights=e.weights,m.query.score_aggregation=e.score_aggregation,m.query.dynamic_scaling=e.dynamic_scaling,e.limit!==void 0&&(m.limit=e.limit,m.query.limit=e.limit),!y.find(e=>e.name===`Search Score`)){let e=[...y,{name:`Search Score`,field:`score`,render:e=>typeof e.score==`number`?e.score.toFixed(4):`0.0000`}];b(e)}j(m.search(),`Vector search failed:`)}else e?.full_text?(m.query.full_text=e.full_text,e.limit!==void 0&&(m.limit=e.limit,m.query.limit=e.limit),j(m.search(),`Text search failed:`)):e===void 0&&l&&(delete m.query.vector,delete m.query.full_text,j(m.search(),`Search reset failed:`))},P=z$(),F=R$(),I=()=>{j(m.search(),`Search refresh failed:`)},L=pQ(P),ee=mQ(F),R=e=>{let t=typeof e==`function`?e(D):e;O(t),ee(t)},te=(e,t)=>{let n=L.find(t=>t.name===e),r={name:e,type:n?.type,placeholder:n?.placeholder,multiple:n?.multiple};R(i=>{let a=i.filter(t=>t.name!==e);if(n?.type===`stringList`||Array.isArray(t)){let n=Array.isArray(t)?t:[t],o=i.find(t=>t.name===e)?.value??[];return[...a,{...r,value:Array.from(new Set([...o,...n]))}]}return[...a,{...r,value:[{value:t,label:t}]}]})},ne=new URL(window.location.href),re=ne.searchParams.get(`filters`);if(re)try{let e=re.split(`;`),t=e.filter(e=>{let[t]=e.split(`:`),n=decodeURIComponent(t);return n!==`start`&&n!==`end`});if(t.length!==e.length){let e=t.length>0?t.join(`;`):``;e?ne.searchParams.set(`filters`,e):ne.searchParams.delete(`filters`),window.history.replaceState(window.history.state||{},``,ne.toString())}}catch(e){console.error(`Failed to clean start/end filters from URL:`,e)}let ie=Qn();return n(`div`,{className:`flex flex-col gap-y-2 flex-1 min-h-0 `,children:[t(H4,{object:d,onClose:()=>f(null)}),g&&t(M,{title:s(`store.error`),children:g.message}),t(V4,{isLoading:h,refreshTrigger:x,allowFilter:i,allowSearch:a,filterGroups:L,filters:D,handleFilterChange:R,handleVectorSearch:N,handleRefetch:I,setIsGridView:E,toolbarActions:o}),t(`div`,{className:`flex flex-col w-full flex-1 min-h-0 border rounded-md mb-2`,children:n(`div`,{ref:A,className:`flex-1 min-h-0 overflow-y-auto`,children:[t(e$,{onFilter:te,children:t(X$,{objects:_,isLoading:!_.length&&h,layout:y,onRowClick:e=>{ie(`/objects/${e.id}`)},previewObject:e=>{let t=_.find(t=>t.id===e)||null;f(t)},selectedObject:d,onUpload:r,isGridView:T,collectionId:c.collectionId})}),v?t(`div`,{ref:k,className:`w-full flex justify-center`,children:t(je,{size:`xl`})}):t(`div`,{className:`text-muted text-center text-sm py-1`,children:`All ${_.length} objects loaded.`})]})})]})}function V4(e){let{t:r}=K(),{isLoading:i,refreshTrigger:a,allowFilter:s,allowSearch:c,filterGroups:l,filters:u,handleFilterChange:d,handleVectorSearch:f,handleRefetch:p,setIsGridView:m,toolbarActions:h}=e;return n(`div`,{className:`sticky top-0 z-10 bg-background py-2 flex justify-between items-center`,children:[s?t(I,{filterGroups:l,filters:u,setFilters:d,children:n(`div`,{children:[t(`div`,{className:`flex flex-row gap-4 items-center justify-between w-full`,children:n(`div`,{className:`flex gap-2 items-center w-2/3`,children:[c&&t(I4,{onChange:f,isLoading:i,refresh:a,className:`w-full`}),t(P,{})]})}),n(`div`,{className:`flex gap-2 items-center pt-2`,children:[t(N,{}),t(F,{})]})]})}):t(`div`,{className:`flex flex-row gap-4 items-center justify-between w-full`,children:t(`div`,{className:`flex gap-2 items-center w-2/3`,children:c&&t(I4,{onChange:f,isLoading:i,refresh:a})})}),n(`div`,{className:`flex gap-1 items-center`,children:[h,t(o,{variant:`outline`,onClick:p,title:r(`store.refresh`),children:t(hy,{size:16})}),t(r1,{onUpdate:m})]})]})}function H4({object:e,onClose:r}){let{store:i}=q(),a=nt(),s=Qn(),{downloadFromContentSource:c}=tG({client:i,toast:a}),l=e?.content?.source,u=typeof e?.properties?.title==`string`?e.properties.title:e?.name;return e?n(Oe,{title:u,isOpen:!0,onClose:r,children:[n(`div`,{className:`flex items-center gap-x-2`,children:[t(o,{variant:`ghost`,size:`sm`,title:`Open Object`,onClick:()=>s(`/objects/${e.id}`),children:t(Dg,{className:`size-4`})}),l&&t(o,{variant:`ghost`,size:`sm`,title:`Download`,onClick:()=>c(l,eG(e)),children:t(xg,{className:`size-4`})})]}),t(C,{className:`my-2`}),t(`div`,{className:`pt-2`,children:t(b4,{object:e,loadText:!0},e.id)})]}):null}const U4=[{name:`ID`,field:`id`,type:`objectId?slice=-7`},{name:`Name`,field:`.`,type:`objectName`},{name:`Revision`,field:`.`,type:`revision`},{name:`Type`,field:`type.name`,type:`string`},{name:`Status`,field:`status`,type:`string`},{name:`Updated At`,field:`updated_at`,type:`date`}];function W4({collection:e}){let n=nt(),{client:r}=q(),{registry:i}=tQ(),a=async t=>{t.length>0&&await r.store.collections.addMembers(e.id,t).catch(e=>{n({title:`Failed to add objects to collection`,description:e.message,status:`error`})})},o=G4(e,i);return t(`div`,{className:`flex flex-col h-full`,children:e.dynamic?t(B4,{layout:o}):t(z4,{onUploadDone:a,layout:o})})}function G4(e,t){let n=e.table_layout;return n&&n.length>0||(e.type&&t&&(n=t?.getTypeLayout(En(e.type))),n&&n.length>0)?n:U4}function K4({className:e,defaultValue:r,onChange:i,isClearable:a,multiple:o}){let{t:s}=K(),{registry:c}=tQ(),[l,u]=G(!1),d=e=>e===null?s(`store.none`):n(`div`,{children:[t(`div`,{className:`text-sm`,children:e.name}),t(`div`,{className:`text-xs text-muted truncate`,children:e.description})]}),[f,p]=G(),[m,h]=G([]);return H(()=>{if(!l&&(u(!0),c&&r)){if(o&&Array.isArray(r)){let e=c.types.filter(e=>r.includes(e.id));h(e)}let e=c.types.find(e=>e.id===r);e&&p(e)}},[l,c,r,o]),o?t(`div`,{className:`flex flex-col gap-4 content-between`,children:t(we,{options:c?.types||[],value:m,onChange:e=>{h(e),i(e)},placeholder:s(`store.chooseContentTypes`),optionLabel:d,className:e||`text-sm bg-background`,filterBy:`name`,isClearable:a||!1,multiple:!0})}):t(`div`,{className:`flex flex-col gap-4 content-between`,children:t(we,{options:c?.types||[],value:f,onChange:e=>{p(e||void 0),i(e)},placeholder:s(`store.chooseContentType`),optionLabel:d,className:e||`text-sm bg-background`,filterBy:`name`,isClearable:a||!1})})}function q4({onClose:r,redirect:i=!0,onAddToCollection:a}){let s=Qn(),c=nt(),{t:l}=K(),[u,d]=G(!1),{client:f}=q(),[p,m]=G({dynamic:!1,name:``,description:``});function h(e,t){m({...p,[e]:t})}return n(e,{children:[t(ce,{children:n(`form`,{onSubmit:e=>e.preventDefault(),children:[t(L,{label:l(`type.name`),required:!0,children:t(te,{type:`text`,value:p.name||``,onChange:e=>h(`name`,e)})}),t(L,{label:l(`type.description`),className:`mt-2`,children:t(Ue,{value:p.description||``,onChange:e=>h(`description`,e.target.value)})}),t(L,{label:l(`store.dynamicCollection`),className:`mt-2`,direction:`row`,description:l(`store.dynamicCollectionDescription`),children:t(Ne,{value:p.dynamic||!1,onChange:e=>h(`dynamic`,e)})}),!p.dynamic&&t(L,{label:l(`store.allowedContentTypes`),className:`mt-4`,description:l(`store.allowedContentTypesOptionalDescription`),children:t(K4,{defaultValue:p.allowed_types||null,onChange:e=>{Array.isArray(e)?h(`allowed_types`,e.map(e=>e.id)):h(`allowed_types`,e?[e.id]:[])},isClearable:!0,multiple:!0})}),t(L,{label:l(`store.contentType`),className:`mt-2`,description:l(`store.typeDescription`),children:t(K4,{defaultValue:p.type||null,onChange:e=>{Array.isArray(e)?h(`type`,e.length>0?e[0].id:null):h(`type`,e?.id||null)},isClearable:!0})})]})}),t(le,{children:t(o,{isDisabled:u,onClick:()=>{if(!p?.name?.trim()){c({title:l(`type.nameRequired`),description:l(`store.pleaseProvideName`),status:`error`,duration:5e3});return}p.name=p.name.trim(),p.description&&=p.description.trim(),p.dynamic??=!1,d(!0),f.store.collections.create(p).then(e=>{r(),c({title:l(`store.collectionCreated`),description:`Collection "${e.name}" created successfully`,status:`success`,duration:3e3}),i&&s(`/collections/${e.id}`),a&&a(e.id)}).catch(e=>{c({title:l(`store.failedToCreateCollection`),description:e.message,status:`error`,duration:5e3})}).finally(()=>d(!1))},children:l(`store.createCollection`)})})]})}function J4({isOpen:e,onClose:r}){let{t:i}=K();return n(se,{onClose:r,isOpen:e,children:[t(ue,{children:i(`store.createACollection`)}),t(q4,{onClose:r})]})}Q();function Y4(){let{client:r}=q(),i=nt(),{t:a}=K(),[s,c]=G(),[l,u]=G(!0),[d,f]=G(!1),{data:p,error:m,refetch:h}=Ye(()=>r.store.collections.search({}),[]);return H(()=>{(p||m)&&u(!1)},[p,m]),m?t(M,{title:a(`store.collectionFetchFailed`),children:Ge(m)}):n(e,{children:[p&&(p.length>0?n(Le,{className:`w-full`,children:[t(`thead`,{children:n(`tr`,{children:[t(`th`,{children:a(`type.name`)}),t(`th`,{children:a(`type.type`)}),t(`th`,{children:a(`store.created`)}),t(`th`,{})]})}),t(Pe,{columns:4,isLoading:l,children:p.map(e=>n(Ie,{children:[t(`td`,{children:n(`div`,{className:`flex items-center gap-2`,children:[t(X4,{isDynamic:e.dynamic}),t(Zn,{href:`/collections/${e.id}`,children:e.name})]})}),t(`td`,{children:e.type?.name||`-`}),t(`td`,{children:WD(e.created_at).fromNow()}),t(`td`,{className:`text-end`,children:t(o,{variant:`destructive`,size:`sm`,onClick:()=>c(e.id),children:t(hb,{className:`size-4`})})})]},e.id))})]}):t(j,{title:a(`store.noCollections`),buttonLabel:a(`store.newCollections`),onClick:()=>f(!0),children:a(`store.getStartedCollections`)})),t(J4,{isOpen:d,onClose:()=>f(!1)}),t(b,{isOpen:!!s,title:a(`store.deleteCollection`),content:a(`store.areYouSureDeleteCollection`),onConfirm:async()=>{if(s)try{await r.store.collections.delete(s),i({title:a(`store.collectionDeleted`),status:`success`,duration:3e3}),h()}catch(e){console.error(`Failed to delete collection:`,e),i({title:a(`store.failedToDeleteCollection`),description:Ge(e),status:`error`,duration:5e3})}finally{c(void 0)}},onCancel:()=>c(void 0)})]})}function X4({isDynamic:e}){let{t:n}=K(),r=n(e?`store.dynamicCollection`:`store.staticCollection`),i=t(e?Ay:e_,{className:`size-5`});return t(We,{description:r,className:`me-2`,children:i})}Q();const Z4=`h-6 w-6 p-0 opacity-0 group-hover/field:opacity-100 text-muted hover:text-foreground transition-opacity shrink-0`;function Q4({objects:e,isLoading:r,onFilter:i,selectedIds:a,onToggleOne:s,allSelected:c,onToggleAll:l}){let{t:u}=K(),d=Qn(),f=!!s;return n(Le,{className:`w-full`,children:[t(Fe,{children:n(`tr`,{children:[f&&t(`th`,{className:`w-[5%]`,children:t(`input`,{type:`checkbox`,checked:!!c,"aria-label":u(`store.actions.selectAllTypes`),onChange:e=>l?.(e.target.checked)})}),t(`th`,{children:u(`store.name`)}),t(`th`,{children:u(`store.strictMode`)}),t(`th`,{children:u(`store.semanticChunking`)}),t(`th`,{children:u(`store.updatedAt`)})]})}),t(Pe,{isLoading:r&&(!e||e.length===0),columns:f?5:4,children:e?.map(e=>n(`tr`,{onClick:()=>d(`/types/${e.id}`),className:`group cursor-pointer hover:bg-muted`,children:[f&&t(`td`,{className:`w-[5%]`,children:t(`input`,{type:`checkbox`,className:it(`checkbox group-hover:inline-block`,a?.includes(e.id)?`inline-block`:`hidden`),checked:a?.includes(e.id)??!1,"aria-label":u(`store.actions.selectType`,{name:e.name}),onClick:e=>e.stopPropagation(),onChange:t=>s?.(e.id,t.target.checked)})}),t(`td`,{className:`group/field`,children:n(`div`,{className:`flex items-center gap-2 min-w-0`,children:[t(`span`,{className:`truncate`,children:e.name}),t(x,{content:e.id,className:Z4}),i&&t(o,{variant:`ghost`,size:`sm`,title:`Filter by ${e.name}`,className:Z4,onClick:t=>{t.stopPropagation(),i(`name`,e.name)},children:t(l_,{className:`size-3`})})]})}),t(`td`,{children:e.strict_mode?`Yes`:`No`}),t(`td`,{children:e.is_chunkable?`Yes`:`No`}),t(`td`,{children:t(We,{description:WD(e.updated_at).format(`YYYY-MM-DD HH:mm:ss`),children:WD(e.updated_at).fromNow()})})]},e.id))})]})}function $4({title:e,isOpen:r,onClose:i,okLabel:a,initialPayload:s,isLoading:c}){let{t:l}=K(),u=nt(),[d,f]=G(s?.name),[p,m]=G(s?.description),h=s?.strict_mode??!1,g=()=>{if(!d){u({status:`error`,title:l(`type.nameRequired`),duration:5e3});return}i({name:d,description:p,strict_mode:h}).then(()=>i())};return n(se,{isOpen:r,onClose:()=>i(),children:[t(ue,{children:e}),t(ce,{className:`pt-0`,children:n(`div`,{className:`h-full flex flex-col gap-4 content-between`,children:[n(`div`,{children:[t(`div`,{className:`block text-sm font-medium text-muted`,children:l(`type.name`)}),t(te,{value:d,onChange:f})]}),n(`div`,{children:[t(`div`,{className:`block text-sm font-medium text-muted`,children:l(`type.description`)}),t(Ue,{value:p,onChange:e=>m(e.target.value),minLines:5})]})]})}),t(le,{children:n(`div`,{className:`flex justify-end gap-4`,children:[t(o,{variant:`secondary`,onClick:()=>i(),children:l(`modal.cancel`)}),t(o,{variant:`primary`,onClick:()=>g(),isLoading:c,children:a})]})})]})}var e3=class{client;limit;result=new De({objects:[],isLoading:!1});query={};constructor(e,t=100){this.client=e,this.limit=t}get objects(){return this.result.value.objects}get error(){return this.result.value.error}get isRunning(){return this.result.value.isLoading}getFilterValue(e){return this.query[e]}setFilterValue(e,t){this.query[e]=t,this.search()}reset(e=!1){this.result.value={objects:[],isLoading:e}}_updateRunningState(e){let t=this.result.value;this.result.value={objects:t.objects,isLoading:e,error:t.error}}async _search(e=!1){if(this.isRunning)return Promise.resolve(!1);this.result.value={isLoading:!0,objects:e?this.objects:[]};let t=this.limit,n=this.objects.length;return this.client.types.list({limit:t,offset:n,query:this.query}).then(async e=>(this.result.value={isLoading:!1,objects:this.objects.concat(e)},!0)).catch(e=>{throw this.result.value={error:e,isLoading:!1,objects:this.objects},e})}search(){return this.isRunning?Promise.resolve(!1):this._search(!1)}loadMore(){return this.isRunning?Promise.resolve(!1):this._search(!0)}};const t3=dt(void 0);function n3(){return _t(t3)}function r3(){let e=n3();return{...rt(e.result),search:e}}function i3(){return n3().objects.length}Q();var a3;(function(e){e.true=`Yes`,e.false=`No`})(a3||={});function o3({isDirty:r=!1}){let{store:i}=q(),{reload:a}=tQ(),{t:s}=K(),c=nt(),[l,u]=G(!1),{search:d,isLoading:f,error:p,objects:m}=r3(),[h,g]=G([]),[_,v]=G(!1),[y,x]=G(!1),S=h.length,C=!!m&&m.length>0&&m.every(e=>h.includes(e.id)),w=m?.filter(e=>h.includes(e.id))??[],T=(e,t)=>{g(n=>t?n.includes(e)?n:[...n,e]:n.filter(t=>t!==e))},E=e=>{g(e&&m?m.map(e=>e.id):[])},D=async()=>{if(!y){x(!0);try{let e=await Promise.allSettled(h.map(e=>i.types.delete(e))),t=e.filter(e=>e.status===`rejected`).length,n=e.length-t;v(!1),g([]),a(),await d.search(),c(t===0?{status:`success`,title:s(`store.actions.typeDeleted`,{count:n}),duration:3e3}:{status:`error`,title:s(`store.actions.typeDeletePartial`,{succeeded:n,failed:t}),duration:5e3})}catch(e){c({status:`error`,title:s(`store.actions.failedToDeleteTypes`),description:e instanceof Error?e.message:void 0,duration:5e3})}finally{x(!1)}}},[O,k]=G(``),A=Je(O,500),N=W(null);Qe(N,()=>{l&&d.loadMore()},{deps:[l,d]}),H(()=>{d.search().then(()=>u(!0))},[d]),H(()=>{d.query.name=A,d.search().then(()=>u(!0))},[A,d]);let[P,F]=G(void 0),I=e=>{F(e)};H(()=>{d.query.chunkable=P?P===`Yes`:void 0,d.search().then(()=>u(!0))},[P,d]),H(()=>{r&&l&&d.search().then(()=>u(!0))},[r,l,d]);let[L,ee]=G(!1);return p?t(M,{title:s(`store.failedToFetchTypes`),children:p.message}):n(`div`,{className:`flex flex-col flex-1 min-h-0`,children:[n(`div`,{className:`flex flex-shrink-0 gap-4 items-center`,children:[t(te,{placeholder:s(`store.filterByName`),value:O,onChange:k}),t(we,{className:`w-60`,isClearable:!0,options:Object.values(a3),value:P,onChange:I,placeholder:s(`store.isChunkable`)}),S>0&&n(`div`,{className:`flex items-center gap-2 ms-auto`,children:[t(`span`,{className:`text-sm font-medium whitespace-nowrap`,children:s(`store.actions.selectedCount`,{n:S})}),t(We,{description:s(`store.actions.clearSelection`),asChild:!0,children:t(o,{variant:`ghost`,"aria-label":s(`store.actions.clearSelection`),onClick:()=>g([]),children:t(Gb,{className:`size-4`})})}),t(o,{variant:`destructive`,isDisabled:y,onClick:()=>v(!0),children:s(y?`store.actions.deleting`:`store.actions.deleteSelected`)})]})]}),t(`div`,{className:`flex flex-col w-full flex-1 min-h-0 border rounded-md my-2`,children:n(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:[!f&&m?.length===0?t(j,{title:s(`store.noType`),buttonLabel:s(`store.createType`),onClick:()=>{ee(!0)},children:s(`store.getStartedTypes`)}):n(e,{children:[t(Q4,{objects:m,isLoading:f,onFilter:(e,t)=>{e===`name`&&k(t)},selectedIds:h,onToggleOne:T,allSelected:C,onToggleAll:E}),t(`div`,{ref:N,className:`h-4 w-full`})]}),t($4,{okLabel:`Create`,title:s(`store.createType`),isOpen:L,onClose:async e=>e?i.types.create(e).then(async()=>{c({status:`success`,title:s(`store.typeCreated`),duration:2e3}),a(),d.search().then(()=>u(!0))}).catch(e=>{c({status:`error`,title:s(`store.errorCreatingType`),description:e.message,duration:5e3})}):(ee(!1),Promise.resolve())}),t(b,{isOpen:_,title:s(`store.actions.deleteType`,{count:S}),content:n(`div`,{children:[t(`p`,{children:s(`store.actions.deleteTypeConfirm`,{count:S})}),w.length>0&&n(e,{children:[t(`div`,{className:`mt-2`,children:s(`store.actions.affectedItems`)}),t(`ul`,{className:`mt-1 max-h-40 overflow-y-auto rounded-md border p-2 text-sm`,children:w.map(e=>t(`li`,{className:`truncate py-0.5`,children:e.name||e.id},e.id))})]})]}),onConfirm:D,onCancel:()=>v(!1),confirmationValue:`delete`,confirmationLabel:s(`store.actions.typeToConfirmDelete`),confirmationPlaceholder:`delete`})]})})]})}function s3(e,t,n){if(t.length===0)return e;let r=structuredClone(e),i=[r],a=r;for(let e of t.slice(0,-1)){let t=a[e],n=f3(t)?t:{};a[e]=n,a=n,i.push(a)}let o=t[t.length-1];return n===void 0||n===``?(delete a[o],d3(i,t)):a[o]=n,r}function c3(e,t,n,r){let i=e?.map(e=>[e[0]??1,e[1]??1])??[],a=i[t]??[1,1];return a[n]=r,i[t]=a,i}function l3(e,t){let n={...e,environment:t};return delete n.model,delete n.model_options,p3(n)?n:void 0}function u3(e,t){let n={...e,model:t};return t!==e?.model&&delete n.model_options,p3(n)?n:void 0}function d3(e,t){for(let n=e.length-1;n>0;--n){let r=e[n];if(Object.keys(r).length>0)break;delete e[n-1][t[n-1]]}}function f3(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function p3(e){return Object.values(e).some(e=>e!==void 0)}Q();function m3({policy:e,section:r,onChange:i,readonly:a=!1}){let{t:o}=K(),s=(t,n)=>i(s3(e,t,n));if(r===`classification`)return n(h3,{children:[n(g3,{title:o(`intakePolicy.section.classification`),description:o(`intakePolicy.help.section.classification`),children:[n(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[t(b3,{label:o(`intakePolicy.field.mode`),description:o(`intakePolicy.help.mode`),value:e.mode,options:T3(o,[`programmatic`,`agentic`]),onChange:e=>s([`mode`],e),readonly:a}),t(b3,{label:o(`intakePolicy.field.defaultView`),value:e.default_view,options:T3(o,[`auto`,`text`,`pdf`,`image`,`properties`]),onChange:e=>s([`default_view`],e),readonly:a})]}),t(v3,{label:o(`intakePolicy.field.identificationGuidance`),description:o(`intakePolicy.help.identificationGuidance`),value:e.identification?.guidance,onChange:e=>s([`identification`,`guidance`],e),readonly:a}),t(v3,{label:o(`intakePolicy.field.distinguishFrom`),description:o(`intakePolicy.help.distinguishFrom`),value:e.identification?.distinguish_from,onChange:e=>s([`identification`,`distinguish_from`],e),readonly:a}),t(L,{label:o(`intakePolicy.field.examples`),description:o(`intakePolicy.help.examples`),children:t(He,{options:e.identification?.examples??[],value:e.identification?.examples??[],onChange:e=>s([`identification`,`examples`],e.length?e:void 0),onOptionsChange:e=>s([`identification`,`examples`],e.length?e:void 0),creatable:!0,disabled:a,placeholder:o(`intakePolicy.placeholder.objectId`)})})]}),n(g3,{title:o(`intakePolicy.section.locate`),description:o(`intakePolicy.help.section.locate`),last:!0,children:[t(v3,{label:o(`intakePolicy.field.locateInstructions`),description:o(`intakePolicy.help.locateInstructions`),value:e.locate?.instructions,onChange:t=>s([`locate`],t?{...e.locate,instructions:t}:void 0),readonly:a}),n(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[t(b3,{label:o(`intakePolicy.field.contactSheetDetail`),description:o(`intakePolicy.help.contactSheetDetail`),value:e.locate?.detail,options:[{value:8,label:o(`intakePolicy.option.pagesPerSheet`,{count:8})},{value:16,label:o(`intakePolicy.option.pagesPerSheet`,{count:16})}],onChange:e=>s([`locate`,`detail`],e),readonly:a||!e.locate}),t(y3,{label:o(`intakePolicy.field.locateMinPages`),description:o(`intakePolicy.help.locateMinPages`),value:e.locate?.min_pages,min:0,onChange:e=>s([`locate`,`min_pages`],e),readonly:a||!e.locate})]})]})]});if(r===`conversion`)return n(h3,{children:[n(g3,{title:o(`intakePolicy.section.conversion`),description:o(`intakePolicy.help.section.conversion`),children:[n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:[t(x3,{label:o(`intakePolicy.field.enabled`),value:e.text_conversion?.enabled,onChange:e=>s([`text_conversion`,`enabled`],e),readonly:a}),t(b3,{label:o(`intakePolicy.field.method`),description:o(`intakePolicy.help.method`),value:e.text_conversion?.method,options:T3(o,[`auto`,`basic`,`llm`,`custom`]),onChange:e=>s([`text_conversion`,`method`],e),readonly:a}),t(b3,{label:o(`intakePolicy.field.outputFormat`),value:e.text_conversion?.output_format,options:T3(o,[`markdown`,`text`]),onChange:e=>s([`text_conversion`,`output_format`],e),readonly:a}),t(b3,{label:o(`intakePolicy.field.pageScope`),description:o(`intakePolicy.help.pageScope`),value:e.text_conversion?.scope,options:T3(o,[`all`,`located`]),onChange:e=>s([`text_conversion`,`scope`],e),readonly:a}),t(y3,{label:o(`intakePolicy.field.renderDpi`),description:o(`intakePolicy.help.renderDpi`),value:e.text_conversion?.render_dpi,min:72,onChange:e=>s([`text_conversion`,`render_dpi`],e),readonly:a})]}),t(v3,{label:o(`intakePolicy.field.instructions`),value:e.text_conversion?.instructions,onChange:e=>s([`text_conversion`,`instructions`],e),readonly:a})]}),t(g3,{title:o(`intakePolicy.section.conversionModel`),description:o(`intakePolicy.help.section.conversionModel`),children:t(w3,{title:o(`intakePolicy.field.model`),config:e.text_conversion?.config,onChange:e=>s([`text_conversion`,`config`],e),readonly:a})}),e.text_conversion?.method===`custom`&&t(g3,{title:o(`intakePolicy.section.customConversion`),description:o(`intakePolicy.help.section.customConversion`),children:n(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[t(_3,{label:o(`intakePolicy.field.interaction`),value:e.text_conversion.custom?.interaction,onChange:e=>s([`text_conversion`,`custom`,`interaction`],e),readonly:a}),t(_3,{label:o(`intakePolicy.field.agent`),value:e.text_conversion.custom?.agent,onChange:e=>s([`text_conversion`,`custom`,`agent`],e),readonly:a})]})}),t(g3,{title:o(`intakePolicy.section.pageRanges`),description:o(`intakePolicy.help.section.pageRanges`),last:!0,children:t(C3,{value:e.text_conversion?.page_ranges,onChange:e=>s([`text_conversion`,`page_ranges`],e),readonly:a})})]});if(r===`extraction`)return n(h3,{children:[n(g3,{title:o(`intakePolicy.section.extraction`),description:o(`intakePolicy.help.section.extraction`),children:[n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:[t(x3,{label:o(`intakePolicy.field.enabled`),value:e.extraction?.enabled,onChange:e=>s([`extraction`,`enabled`],e),readonly:a}),t(b3,{label:o(`intakePolicy.field.source`),description:o(`intakePolicy.help.extractionSource`),value:e.extraction?.source,options:T3(o,[`auto`,`text`,`vision`,`mixed`]),onChange:e=>s([`extraction`,`source`],e),readonly:a}),t(b3,{label:o(`intakePolicy.field.pageScope`),description:o(`intakePolicy.help.pageScope`),value:e.extraction?.scope,options:T3(o,[`all`,`located`]),onChange:e=>s([`extraction`,`scope`],e),readonly:a}),t(y3,{label:o(`intakePolicy.field.maxPages`),description:o(`intakePolicy.help.extractionMaxPages`),value:e.extraction?.max_pages,min:1,onChange:e=>s([`extraction`,`max_pages`],e),readonly:a})]}),t(_3,{label:o(`intakePolicy.field.interaction`),description:o(`intakePolicy.help.extractionInteraction`),value:e.extraction?.interaction,onChange:e=>s([`extraction`,`interaction`],e),readonly:a}),t(v3,{label:o(`intakePolicy.field.instructions`),value:e.extraction?.instructions,onChange:e=>s([`extraction`,`instructions`],e),readonly:a}),t(C3,{value:e.extraction?.page_ranges,onChange:e=>s([`extraction`,`page_ranges`],e),readonly:a})]}),t(g3,{title:o(`intakePolicy.section.extractionModel`),description:o(`intakePolicy.help.section.extractionModel`),children:t(w3,{title:o(`intakePolicy.field.model`),config:e.extraction?.config,onChange:e=>s([`extraction`,`config`],e),readonly:a})}),t(g3,{title:o(`intakePolicy.section.visionBudget`),description:o(`intakePolicy.help.section.visionBudget`),last:!0,children:n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:[t(b3,{label:o(`intakePolicy.field.defaultDetail`),description:o(`intakePolicy.help.visionDetail`),value:e.extraction?.vision?.default_detail,options:T3(o,[`low`,`standard`,`high`]),onChange:e=>s([`extraction`,`vision`,`default_detail`],e),readonly:a}),t(S3,{description:o(`intakePolicy.help.visionDetail`),value:e.extraction?.vision?.allowed_details,onChange:e=>s([`extraction`,`vision`,`allowed_details`],e),readonly:a}),t(y3,{label:o(`intakePolicy.field.maxImageTokens`),description:o(`intakePolicy.help.maxImageTokens`),value:e.extraction?.vision?.max_image_tokens,min:1,onChange:e=>s([`extraction`,`vision`,`max_image_tokens`],e),readonly:a}),t(y3,{label:o(`intakePolicy.field.maxPayloadMb`),description:o(`intakePolicy.help.maxPayloadMb`),value:e.extraction?.vision?.max_payload_mb,min:1,onChange:e=>s([`extraction`,`vision`,`max_payload_mb`],e),readonly:a}),t(y3,{label:o(`intakePolicy.field.maxPagesPerCall`),value:e.extraction?.vision?.max_pages_per_call,min:1,onChange:e=>s([`extraction`,`vision`,`max_pages_per_call`],e),readonly:a})]})})]});if(r===`grounding`){let r=e.extraction?.grounding,i=r?.review;return n(h3,{children:[n(g3,{title:o(`intakePolicy.section.grounding`),description:o(`intakePolicy.help.section.grounding`),children:[n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:[t(x3,{label:o(`intakePolicy.field.enabled`),value:r?.enabled,onChange:e=>s([`extraction`,`grounding`,`enabled`],e),readonly:a}),t(y3,{label:o(`intakePolicy.field.maxPages`),value:r?.max_pages,min:1,onChange:e=>s([`extraction`,`grounding`,`max_pages`],e),readonly:a}),t(y3,{label:o(`intakePolicy.field.windowPages`),description:o(`intakePolicy.help.windowPages`),value:r?.window_pages,min:1,onChange:e=>s([`extraction`,`grounding`,`window_pages`],e),readonly:a}),t(_3,{label:o(`intakePolicy.field.interaction`),value:r?.interaction,onChange:e=>s([`extraction`,`grounding`,`interaction`],e),readonly:a})]}),n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:[t(x3,{label:o(`intakePolicy.field.useVision`),description:o(`intakePolicy.help.useVision`),value:r?.use_vision,onChange:e=>s([`extraction`,`grounding`,`use_vision`],e),readonly:a}),t(x3,{label:o(`intakePolicy.field.forceOcr`),description:o(`intakePolicy.help.forceOcr`),value:r?.force_ocr,onChange:e=>s([`extraction`,`grounding`,`force_ocr`],e),readonly:a}),t(x3,{label:o(`intakePolicy.field.refreshOcr`),description:o(`intakePolicy.help.refreshOcr`),value:r?.refresh_ocr,onChange:e=>s([`extraction`,`grounding`,`refresh_ocr`],e),readonly:a}),t(x3,{label:o(`intakePolicy.field.omitBlockBoxes`),description:o(`intakePolicy.help.omitBlockBoxes`),value:r?.omit_block_boxes,onChange:e=>s([`extraction`,`grounding`,`omit_block_boxes`],e),readonly:a}),t(x3,{label:o(`intakePolicy.field.updateProperties`),description:o(`intakePolicy.help.updateProperties`),value:r?.update_properties,onChange:e=>s([`extraction`,`grounding`,`update_properties`],e),readonly:a})]})]}),n(g3,{title:o(`intakePolicy.section.models`),description:o(`intakePolicy.help.section.models`),children:[t(w3,{title:o(`intakePolicy.field.primaryModel`),config:r?.config,onChange:e=>s([`extraction`,`grounding`,`config`],e),readonly:a}),t(w3,{title:o(`intakePolicy.field.hardModel`),config:r?.hard_config,onChange:e=>s([`extraction`,`grounding`,`hard_config`],e),readonly:a}),n(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[t(y3,{label:o(`intakePolicy.field.hardnessThreshold`),description:o(`intakePolicy.help.hardnessThreshold`),value:r?.hardness_threshold,min:0,max:1,step:.05,onChange:e=>s([`extraction`,`grounding`,`hardness_threshold`],e),readonly:a}),t(y3,{label:o(`intakePolicy.field.minCitationDensity`),description:o(`intakePolicy.help.minCitationDensity`),value:r?.min_citation_density,min:0,max:1,step:.05,onChange:e=>s([`extraction`,`grounding`,`min_citation_density`],e),readonly:a})]})]}),n(g3,{title:o(`intakePolicy.section.review`),description:o(`intakePolicy.help.section.review`),last:!0,children:[n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:[t(x3,{label:o(`intakePolicy.field.enabled`),value:i?.enabled,onChange:e=>s([`extraction`,`grounding`,`review`,`enabled`],e),readonly:a}),t(x3,{label:o(`intakePolicy.field.forceReview`),description:o(`intakePolicy.help.forceReview`),value:i?.force,onChange:e=>s([`extraction`,`grounding`,`review`,`force`],e),readonly:a}),t(y3,{label:o(`intakePolicy.field.reviewThreshold`),value:i?.threshold,min:0,max:1,step:.05,onChange:e=>s([`extraction`,`grounding`,`review`,`threshold`],e),readonly:a}),t(y3,{label:o(`intakePolicy.field.coverageThreshold`),description:o(`intakePolicy.help.coverageThreshold`),value:i?.coverage_threshold,min:0,max:1,step:.05,onChange:e=>s([`extraction`,`grounding`,`review`,`coverage_threshold`],e),readonly:a})]}),t(w3,{title:o(`intakePolicy.field.reviewModel`),config:i?.config,onChange:e=>s([`extraction`,`grounding`,`review`,`config`],e),readonly:a})]})]})}return n(h3,{children:[t(g3,{title:o(`intakePolicy.section.rendering`),description:o(`intakePolicy.help.section.rendering`),children:t(v3,{label:o(`intakePolicy.field.renderingTemplate`),description:o(`intakePolicy.help.renderingTemplate`),value:e.rendering_template,onChange:e=>s([`rendering_template`],e),readonly:a,monospace:!0,minLines:8})}),t(g3,{title:o(`intakePolicy.section.embeddings`),description:o(`intakePolicy.help.section.embeddings`),last:!0,children:n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:[t(x3,{label:o(`intakePolicy.field.textEmbedding`),value:e.embeddings?.text,onChange:e=>s([`embeddings`,`text`],e),readonly:a}),t(x3,{label:o(`intakePolicy.field.imageEmbedding`),value:e.embeddings?.image,onChange:e=>s([`embeddings`,`image`],e),readonly:a}),t(x3,{label:o(`intakePolicy.field.propertiesEmbedding`),value:e.embeddings?.properties,onChange:e=>s([`embeddings`,`properties`],e),readonly:a}),t(x3,{label:o(`intakePolicy.field.generateToc`),value:e.generate_toc,onChange:e=>s([`generate_toc`],e),readonly:a})]})})]})}function h3({children:e}){return t(`div`,{className:`w-full px-1 py-4`,children:e})}function g3({title:e,description:r,children:i,last:a=!1}){return n(`section`,{className:a?`pb-3`:`mb-6 border-b pb-6`,children:[n(`div`,{className:`mb-4 flex items-center gap-2`,children:[t(`h3`,{className:`text-sm font-semibold`,children:e}),t(R,{description:r})]}),t(`div`,{className:`space-y-4`,children:i})]})}function _3({label:e,value:n,onChange:r,readonly:i,description:a}){return t(L,{label:e,description:a,children:t(te,{value:n??``,onChange:e=>r(e||void 0),disabled:i})})}function v3({label:e,value:n,onChange:r,readonly:i,description:a,minLines:o=3,monospace:s=!1}){return t(L,{label:e,description:a,children:t(Ue,{value:n??``,onChange:e=>r(e.target.value||void 0),disabled:i,minLines:o,maxLines:14,className:s?`font-mono`:void 0})})}function y3({label:e,description:n,value:r,onChange:i,readonly:a,min:o,max:s,step:c}){return t(L,{label:e,description:n,children:t(de,{value:r,onChange:e=>i(e===void 0||Number.isFinite(e)?e:void 0),disabled:a,min:o,max:s,step:c??1,noScroll:!0})})}function b3({label:e,description:n,value:r,options:i,onChange:a,readonly:o}){let{t:s}=K(),c=[{value:`__inherit__`,label:s(`intakePolicy.option.inherit`)},...i],l=c.find(e=>e.value===r)??c[0];return t(L,{label:e,description:n,children:t(we,{options:c,value:l,by:`value`,optionLabel:e=>e.label,onChange:e=>a(e.value===`__inherit__`?void 0:e.value),disabled:o})})}function x3({label:e,description:n,value:r,onChange:i,readonly:a}){let{t:o}=K(),s=[{value:`inherit`,label:o(`intakePolicy.option.inherit`)},{value:`enabled`,label:o(`intakePolicy.option.enabled`)},{value:`disabled`,label:o(`intakePolicy.option.disabled`)}],c=r===void 0?`inherit`:r?`enabled`:`disabled`;return t(L,{label:e,description:n,children:t(we,{options:[...s],value:s.find(e=>e.value===c),by:`value`,optionLabel:e=>e.label,onChange:e=>i(e.value===`inherit`?void 0:e.value===`enabled`),disabled:a})})}function S3({description:e,value:n,onChange:r,readonly:i}){let{t:a}=K(),o=T3(a,[`low`,`standard`,`high`]);return t(L,{label:a(`intakePolicy.field.allowedDetails`),description:e,children:t(we,{multiple:!0,options:o,value:o.filter(e=>n?.includes(e.value)),by:`value`,optionLabel:e=>e.label,onChange:e=>r(e.length?e.map(e=>e.value):void 0),disabled:i})})}function C3({value:e,onChange:r,readonly:i}){let{t:a}=K(),s=t=>{let n=e?.filter((e,n)=>n!==t);r(n?.length?n:void 0)};return t(L,{label:a(`intakePolicy.field.pageRanges`),description:a(`intakePolicy.help.pageRanges`),children:n(`div`,{className:`space-y-2`,children:[e?.map((c,l)=>n(`div`,{className:`grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_2.25rem] gap-2`,children:[t(de,{"aria-label":a(`intakePolicy.field.rangeStart`),value:c[0],onChange:t=>{t!==void 0&&Number.isFinite(t)&&r(c3(e,l,0,t))},disabled:i,step:1,noScroll:!0}),t(de,{"aria-label":a(`intakePolicy.field.rangeEnd`),value:c[1],onChange:t=>{t!==void 0&&Number.isFinite(t)&&r(c3(e,l,1,t))},disabled:i,step:1,noScroll:!0}),t(We,{description:a(`intakePolicy.action.removeRange`),children:t(o,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":a(`intakePolicy.action.removeRange`),onClick:()=>s(l),disabled:i,children:t(hb,{className:`size-4`})})})]},`${l}`)),n(o,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r([...e??[],[1,1]]),disabled:i,children:[t(oy,{className:`size-4`}),a(`intakePolicy.action.addRange`)]})]})})}function w3({title:e,config:r,onChange:i,readonly:a}){let{t:o}=K();return n(`div`,{children:[t(`div`,{className:`mb-2 text-xs font-medium text-muted`,children:e}),n(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[t(L,{label:o(`intakePolicy.field.environment`),children:t(q1,{selectedEnvId:r?.environment,onChange:e=>i(l3(r,e?.id)),isClearable:!0,disabled:a})}),t(L,{label:o(`intakePolicy.field.model`),children:t(X1,{envId:r?.environment,selectedModelId:r?.model,onChange:e=>i(u3(r,e?.id)),isClearable:!0,disabled:a||!r?.environment})})]})]})}function T3(e,t){return t.map(t=>({value:t,label:e(`intakePolicy.option.${t}`)}))}Q();const E3=[{key:`minimal`,value:{identification:{guidance:`Documents that match this content type.`,distinguish_from:`Do not select this type for unrelated documents.`}}},{key:`extraction_only`,value:{text_conversion:{enabled:!1},extraction:{enabled:!0,source:`vision`,instructions:`Extract required fields only. Ignore cover pages, appendices, legal boilerplate, and marketing content.`},rendering_template:`# {{properties.title}}
1391
+ + `)||e.includes(`![`)||e.includes(`](`):!1}function y4(e){return e?`h-full overflow-auto`:`hidden`}var b4;(function(e){e.Text=`text`,e.Image=`image`,e.Video=`video`,e.Audio=`audio`,e.Pdf=`pdf`,e.Transcript=`transcript`})(b4||={});function x4({object:r,loadText:i,refetch:a,canEditProperties:o=!0,canCollaborate:s=!1}){let c=nt(),{t:l}=K(),{project:u,store:d}=q(),f=Qn(),p=r.revision?.root||r.id,m=u?.id?P2(u.id,p):void 0,[h,g]=G(r),[_,v]=G(()=>m?F2(m):!1),y=W(null),b=W(r.id),x=W(r.id),S=W(m);H(()=>{S.current!==m&&(S.current=m,v(m?F2(m):!1))},[m]);let C=V(()=>{v(e=>{let t=!e;return m&&I2(m,t),t})},[m]),w=V(()=>{m&&I2(m,!1),v(!1)},[m]);H(()=>{let e=x.current!==r.id;x.current=r.id,g(t=>!e&&t.id!==r.id?t:(b.current=r.id,t.id===r.id&&t.text&&!r.text?{...r,text:t.text}:r))},[r]);let T=V(async(e,t)=>{b.current=e;try{let[t,n]=await Promise.all([d.objects.retrieve(e),d.objects.getObjectText(e)]);b.current===e&&g({...t,text:n.text})}catch(e){console.error(`Failed to load the updated document revision`,e),c({status:`error`,title:l(`agent.failedToLoadDocument`),description:e instanceof Error?e.message:void 0,duration:5e3})}finally{t&&f(`/objects/${e}`)}},[f,d.objects,l,c]),E=async(e,t)=>{try{await navigator.clipboard.writeText(e),c({status:`success`,title:l(`store.contentCopied`,{type:l(t===`text`?`store.contentType`:`store.properties`)}),description:l(`store.successfullyCopied`,{type:t}),duration:2e3})}catch(e){console.error(`Failed to copy ${t}:`,e),c({status:`error`,title:l(`store.copyFailed`),description:l(`store.failedToCopy`,{type:t}),duration:5e3})}};return n(e,{children:[n(Ce,{direction:`horizontal`,className:`h-full`,children:[t(Se,{defaultSize:67,className:`min-w-[100px]`,children:t(C4,{object:h,loadText:i??!1,handleCopyContent:E,refetch:a,canCollaborate:s,isCollaborating:_,onToggleCollaborate:C})}),t(xe,{withHandle:!0}),t(Se,{defaultSize:33,className:`min-w-[100px]`,children:t(S4,{object:h,refetch:a??(()=>Promise.resolve()),handleCopyContent:E,canEditProperties:o})})]}),_?t(o4,{object:h,initialContent:h.text??``,onClose:w,onDocumentUpdated:(e,t)=>void T(e,t),sendMessageRef:y}):null]})}function S4({object:r,refetch:i,handleCopyContent:a,canEditProperties:s}){let{t:c}=K(),[l,u]=G(!1),[d,f]=G(!1);return n(e,{children:[n(`div`,{className:`flex flex-col h-full`,children:[n(`div`,{className:`flex justify-between items-center px-2`,children:[n(`div`,{className:`flex items-center gap-1 bg-muted mb-2 p-1 rounded`,children:[t(o,{variant:`${l?`ghost`:`primary`}`,size:`sm`,title:c(`store.previewProperties`),onClick:()=>u(!l),children:`Properties`}),t(o,{variant:`${l?`primary`:`ghost`}`,size:`sm`,title:c(`store.viewInJsonFormat`),onClick:()=>u(!l),children:`JSON`})]}),n(`div`,{className:`flex items-center gap-2`,children:[r.properties&&t(o,{variant:`ghost`,size:`sm`,title:`Copy properties`,onClick:()=>a(JSON.stringify(r.properties,null,2),`properties`),children:t(fg,{className:`size-4`})}),s&&t(d2,{permission:yn.content_write,variant:`ghost`,size:`sm`,onClick:()=>{f(!0)},title:`Edit properties`,className:`flex items-center gap-2`,children:t(Zy,{className:`size-4`})})]})]}),r.properties?t(`div`,{className:`flex-1 min-h-0 px-2`,children:t(jt,{value:r.properties,viewCode:l})}):t(`div`,{className:`flex-1 min-h-0 px-2`,children:t(`div`,{children:c(`store.noPropertiesDefined`)})})]}),t(s4,{isOpen:d,onClose:()=>{f(!1)},object:r,refetch:i})]})}function C4(e){let{client:n}=q(),r=e.object.type,i=r?.id,a=r?.default_view,{data:o}=Ye(async()=>!i||a?null:(await m2(n,i))?.intake?.default_view??null,[i,a]),s=a??o;return i&&!a&&o===void 0?t(`div`,{className:`flex h-full items-center justify-center`,children:t(je,{size:`lg`})}):t(w4,{...e,defaultView:s??void 0})}function w4({object:e,loadText:r,handleCopyContent:i,refetch:a,defaultView:s,canCollaborate:c,isCollaborating:l,onToggleCollaborate:u}){let{client:d}=q(),{t:f}=K(),p=e?.metadata?.type===un.Image,m=e?.metadata?.type===un.Video,h=e?.metadata?.type===un.Audio,g=e?.content?.type===`application/pdf`,_=e?.content?.type?m$(e.content.type):!1,v=g4(e?.status),y=!!(e.transcript&&(m||h)),b=e.metadata?.renditions?.find(e=>e.name===_n),x=()=>{switch(s){case`text`:return b4.Text;case`pdf`:if(g||_||b)return b4.Pdf;break;case`image`:if(p)return b4.Image;break;case`properties`:return b4.Text}return m?b4.Video:h?b4.Audio:p?b4.Image:b4.Text},S=m0(e.id),[C,w]=G(x()),[T,E]=G(C===b4.Pdf);H(()=>{C===b4.Pdf&&E(!0)},[C]);let[D,O]=G(!1),k=V2(!!(e.content?.type&&!e.is_locked&&e.user_permissions?.can_write!==!1&&(e.content.type.startsWith(`text/`)||e.content.type===`application/json`||e.content.type===`application/xml`)),c),{fullText:A,displayText:j,isLoading:M,isCropped:N,loadText:P}=f4(e.id,e.text,r,e.revision?.root||e.id),F=(g||_)&&v&&(C===b4.Text||C===b4.Pdf),{progress:I,status:L,isComplete:ee}=p4(e.id,F),{pdfUrl:R,isConverting:te,error:ne,triggerConversion:re}=m4(e.id,_),ie=U(()=>[{id:`office-pdf-rendition`,target:`pdf`,canConvert:({contentType:e,extension:t})=>_||(e?m$(e):!1)||[`doc`,`docx`,`ppt`,`pptx`].includes(t),convert:async()=>{let t=await d.objects.getRendition(e.id,{format:gn.pdf,generate_if_missing:!0,sign_url:!0,block_on_generation:!0});return t.status===`found`&&t.renditions?.length?{url:t.renditions[0],contentType:`application/pdf`,fileName:`${e.name||`document`}.pdf`}:null}}],[d,_,e.id,e.name]);H(()=>{ee&&L===Tn.COMPLETED&&P()},[ee,L,P]);let ae=(g||_)&&v&&!ee&&L===Tn.RUNNING,oe=C===b4.Pdf&&!ae,se=ae&&(C===b4.Text||C===b4.Pdf),ce=T&&!ae,le=W(null);return n(`div`,{className:`flex flex-col h-full`,children:[n(`div`,{className:`flex justify-between items-center px-2 shrink-0`,children:[n(`div`,{className:`flex items-center gap-2 mb-2`,children:[n(`div`,{className:`flex items-center gap-1 bg-muted p-1 rounded`,children:[p&&t(o,{variant:C===b4.Image?`primary`:`ghost`,size:`sm`,title:f(`store.viewImage`),onClick:()=>w(b4.Image),children:`Image`}),m&&t(o,{variant:C===b4.Video?`primary`:`ghost`,size:`sm`,title:f(`store.viewVideo`),onClick:()=>w(b4.Video),children:`Video`}),h&&t(o,{variant:C===b4.Audio?`primary`:`ghost`,size:`sm`,title:f(`store.viewAudio`),onClick:()=>w(b4.Audio),children:`Audio`}),y&&t(o,{variant:C===b4.Transcript?`primary`:`ghost`,size:`sm`,title:f(`store.viewTranscript`),onClick:()=>w(b4.Transcript),children:`Transcript`}),t(o,{variant:C===b4.Text?`primary`:`ghost`,size:`sm`,title:f(`store.viewText`),onClick:()=>w(b4.Text),children:`Text`}),g&&t(o,{variant:C===b4.Pdf?`primary`:`ghost`,size:`sm`,title:f(`store.viewPdf`),onClick:()=>w(b4.Pdf),children:`PDF`}),_&&t(o,{variant:C===b4.Pdf?`primary`:`ghost`,size:`sm`,title:f(`store.viewAsPdf`),onClick:()=>{w(b4.Pdf),!b&&!R&&!te&&re()},disabled:te,children:te?t(je,{size:`sm`}):`PDF`})]}),n(`div`,{className:`flex items-center gap-1`,children:[t(O4,{object:e}),t(k4,{objectId:e.id,available:S})]})]}),C===b4.Text&&!ae&&!D&&t(T4,{object:e,text:j,fullText:A,handleCopyContent:i,textContainerRef:le,isEditing:D,onToggleEdit:()=>O(!0),canEdit:k.canEdit,isCollaborating:l,onToggleCollaborate:u,canCollaborate:k.canCollaborate}),C===b4.Pdf&&_&&(b||R)&&t(A4,{object:e,pdfRendition:b,officePdfUrl:R})]}),C===b4.Image&&t(`div`,{className:y4(!0),children:t(Z0,{object:e})}),C===b4.Video&&t(`div`,{className:y4(!0),children:t(Q0,{object:e})}),C===b4.Audio&&t(`div`,{className:y4(!0),children:t(X0,{object:e})}),y&&C===b4.Transcript&&t(`div`,{className:y4(!0),children:t(D4,{object:e,handleCopyContent:i})}),g&&ce&&t(`div`,{className:y4(oe),children:t(j4,{object:e})}),_&&ce&&t(`div`,{className:y4(oe),children:t(M4,{object:e,pdfRendition:b,officePdfUrl:R,converters:ie,officePdfConverting:te,officePdfError:ne})}),se&&t(`div`,{className:y4(!0),children:t(N4,{progress:I,status:L})}),C===b4.Text&&!ae&&!D&&M&&!j&&t(`div`,{className:y4(!0),children:t(`div`,{className:`flex justify-center items-center flex-1`,children:t(je,{size:`lg`})})}),C===b4.Text&&!ae&&!D&&(!M||j)&&t(`div`,{className:y4(!0),children:t(E4,{object:e,text:j,isTextCropped:N,textContainerRef:le})}),D&&C===b4.Text&&A!=null&&t(u4,{object:e,text:A,onClose:()=>O(!1),onSaved:()=>{O(!1),P(),a?.()}})]})}function T4({object:r,text:i,fullText:a,handleCopyContent:s,onToggleEdit:c,canEdit:l,isCollaborating:u,onToggleCollaborate:d,canCollaborate:f}){let{client:p,project:m}=q(),h=nt(),{t:g}=K(),_=r.content,{renderDocument:v,isDownloading:y}=nG({client:p,toast:h}),{data:b}=Ye(()=>m?p.projects.retrieve(m.id):Promise.resolve(void 0),[m?.id]),x=b?.configuration?.pdf_template_object_id??void 0,S=U2(_?.type),C=W2(_?.type),T=async(e,t)=>{if(y)return;h({status:`info`,title:`Preparing ${e.toUpperCase()}`,description:g(`store.renderingDocument`),duration:2e3});let n=t===!1?void 0:x;await v(r.id,{format:e,title:r.name||`document`,useDefaultTemplate:t,templateObjectId:n})};return t(`div`,{className:`h-[41px] text-lg font-semibold flex justify-between items-center px-2`,children:n(`div`,{className:`flex items-center gap-2`,children:[a&&t(o,{variant:`ghost`,size:`sm`,title:`Copy text`,onClick:()=>s(a,`text`),children:t(fg,{className:`size-4`})}),y?t(o,{variant:`ghost`,size:`sm`,disabled:!0,className:`h-8 w-8 p-0`,title:g(`agent.download`),"aria-label":g(`agent.download`),children:t(je,{size:`sm`})}):n(w,{trigger:t(o,{variant:`ghost`,size:`sm`,disabled:!i,className:`h-8 w-8 p-0`,title:g(`agent.download`),"aria-label":g(`agent.download`),children:t(xg,{className:`size-4`})}),children:[a&&t(ae,{onClick:e=>{if(e.preventDefault(),e.stopPropagation(),!a)return;let t=`txt`,n=`text/plain`;_?.type===`application/xml`||_?.type===`text/xml`?(t=`xml`,n=`text/xml`):S&&(t=`md`,n=`text/markdown`);let i=new Blob([a],{type:n}),o=URL.createObjectURL(i),s=`${r.name||`document`}.${t}`,c=document.createElement(`a`);c.href=o,c.download=s,c.style.display=`none`,setTimeout(()=>{c.click(),URL.revokeObjectURL(o)},0)},children:n(`div`,{className:`flex items-center gap-2`,children:[t(xg,{className:`size-4`}),`Download Text`]})}),S&&i&&n(e,{children:[t(ae,{onClick:()=>T(gn.docx),children:n(`div`,{className:`flex items-center gap-2`,children:[t(xg,{className:`size-4`}),`Export as DOCX`]})}),t(ae,{onClick:()=>T(gn.pdf,!1),children:n(`div`,{className:`flex items-center gap-2`,children:[t(xg,{className:`size-4`}),`Export as PDF`]})}),t(ae,{onClick:()=>T(gn.pdf),children:n(`div`,{className:`flex items-center gap-2`,children:[t(xg,{className:`size-4`}),`Export as Branded PDF`]})})]})]}),a&&n(e,{children:[l&&c&&t(d2,{permission:yn.content_write,variant:`ghost`,size:`sm`,onClick:c,title:g(`store.editText`),"aria-label":g(`store.editText`),className:`h-8 w-8 p-0`,children:t(Zy,{className:`size-4`})}),f&&d&&C&&t(o,{variant:u?`primary`:`ghost`,size:`sm`,onClick:d,title:g(`agent.editWithAI`),"aria-label":g(`agent.editWithAI`),className:`h-8 w-8 p-0`,children:t(Jy,{className:`size-4`})})]})]})})}const E4=gt(({object:r,text:i,isTextCropped:a,textContainerRef:o})=>{let{t:s}=K(),c=g4(r?.status),l=r.content,u=_4(r)===`xml`||l?.type===`application/xml`||l?.type===`text/xml`,d=W2(l?.type),f=!u&&(d||v4(i)),p={id:r.id,title:r.name,fileName:r.content?.name||r.name,contentType:u?`text/xml`:f?`text/markdown`:r.content?.type,content:i,sourcePath:r.content?.source};return i?n(e,{children:[a&&t(`div`,{className:`px-2 py-2 bg-attention/10 border-s-4 border-attention mx-2 mb-2 rounded`,children:n(`div`,{className:`flex items-center gap-2 text-attention`,children:[t(vb,{className:`size-4`}),t(`span`,{className:`text-sm font-semibold`,children:s(`store.showingFirst128K`)})]})}),t(`div`,{className:`max-w-7xl px-2 h-full overflow-auto`,ref:o,children:t(XY,{source:p,className:`h-full`,bodyClassName:`overflow-auto`,markdownComponents:h4()})})]}):t(`div`,{className:`px-2`,children:t(`div`,{children:c?`Extracting content...`:`No content`})})});function D4({object:e,handleCopyContent:r}){let{t:i}=K(),a=e.transcript,s=a?.text,c=a?.segments,l=s||(c?c.map(e=>e.text).join(` `):``),u=e=>{let t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=Math.floor(e%60);return t>0?`${t}:${n.toString().padStart(2,`0`)}:${r.toString().padStart(2,`0`)}`:`${n}:${r.toString().padStart(2,`0`)}`};return n(`div`,{className:`flex flex-col h-full`,children:[t(`div`,{className:`flex justify-end items-center px-2 mb-2`,children:l&&t(o,{variant:`ghost`,size:`sm`,title:`Copy transcript`,onClick:()=>r(l,`text`),children:t(fg,{className:`size-4`})})}),t(`div`,{className:`h-full} overflow-auto px-2`,children:c&&c.length>0?t(`div`,{className:`space-y-2`,children:c.map((e,r)=>n(`div`,{className:`flex gap-3 text-sm`,children:[n(`span`,{className:`text-muted font-mono text-xs shrink-0 pt-0.5`,children:[u(e.start),e.end&&` - ${u(e.end)}`]}),t(`span`,{className:`flex-1`,children:e.text})]},`segment-${r}`))}):s?t(`pre`,{className:`text-wrap bg-muted text-muted p-2 whitespace-pre-wrap`,children:s}):t(`div`,{className:`text-muted`,children:i(`store.noTranscriptAvailable`)})})]})}function O4({object:r}){let[i,a]=G(!1);return _4(r)===`markdown`?n(e,{children:[t(o,{variant:`ghost`,size:`sm`,onClick:()=>a(!0),title:`Side by side view`,children:t(Hg,{className:`size-4`})}),i&&t(ve,{children:t(W0,{objectId:r.id,onClose:()=>a(!1)})})]}):null}function k4({objectId:r,available:i}){let{t:a}=K(),[s,c]=G(!1);return i?n(e,{children:[t(o,{variant:`ghost`,size:`sm`,onClick:()=>c(!0),title:a(`grounded.title`),"aria-label":a(`grounded.title`),children:t(Dy,{className:`size-4`})}),s&&t(ve,{children:t(_0,{objectId:r,onClose:()=>c(!1)})})]}):null}function A4({object:e,pdfRendition:n,officePdfUrl:r}){let{client:i}=q(),a=nt(),{t:s}=K(),[c,l]=G(!1);return t(`div`,{className:`flex items-center gap-2`,children:t(o,{variant:`ghost`,size:`sm`,onClick:async()=>{l(!0);try{let t=r;!t&&n?.content?.source&&(t=(await i.files.getDownloadUrl(n.content.source,`${e.name||`document`}.pdf`,`attachment`)).url),t&&window.open(t,`_blank`)}catch(e){console.error(`Failed to download PDF:`,e),a({status:`error`,title:s(`store.downloadFailed`),description:s(`store.failedToDownloadPdf`),duration:5e3})}finally{l(!1)}},disabled:c,title:`Download PDF`,children:c?t(je,{size:`sm`}):t(xg,{className:`size-4`})})})}function j4({object:e}){let n={id:e.id,title:e.name,fileName:e.content?.name||e.name,contentType:e.content?.type,sourcePath:e.content?.source};return t(`div`,{className:`h-full`,children:t(XY,{source:n,className:`h-full`,showHeader:!1})})}function M4({object:e,pdfRendition:r,officePdfUrl:i,converters:a,officePdfConverting:o,officePdfError:s}){let{t:c}=K();if(o)return n(`div`,{className:`flex flex-col justify-center items-center flex-1 gap-2`,children:[t(je,{size:`lg`}),t(`span`,{className:`text-muted`,children:c(`store.convertingToPdf`)})]});if(s)return n(`div`,{className:`flex flex-col justify-center items-center flex-1 gap-2 text-destructive`,children:[t(vb,{className:`size-8`}),t(`span`,{children:s})]});if(r?.content?.source){let n={id:e.id,title:e.name,fileName:`${e.name||`document`}.pdf`,contentType:`application/pdf`,sourcePath:r.content.source};return t(`div`,{className:`h-full`,children:t(XY,{source:n,className:`h-full`})})}if(i){let n={id:e.id,title:e.name,fileName:`${e.name||`document`}.pdf`,contentType:`application/pdf`,url:i};return t(`div`,{className:`h-full`,children:t(XY,{source:n,className:`h-full`})})}let l={id:e.id,title:e.name,fileName:e.content?.name||e.name,contentType:e.content?.type,sourcePath:e.content?.source};return t(`div`,{className:`h-full`,children:t(XY,{source:l,converters:a,className:`h-full`})})}function N4({progress:r,status:i}){let{t:a}=K(),o=x$(i),s=S$(i),c=r?.phase===`grounded_extraction`,l=r?.percent!=null&&!Number.isNaN(r.percent)?r.percent:0;return n(`div`,{className:`px-4 py-4`,children:[r&&n(`div`,{className:`space-y-2`,children:[n(`div`,{className:`flex flex-col gap-1`,children:[t(P4,{name:c?`Prepare Evidence`:`Analyze Page`,progress:r.pages}),c&&n(e,{children:[t(P4,{name:`Run OCR`,progress:r.images}),t(P4,{name:`Extract Grounded Data`,progress:r.tables}),t(P4,{name:`Review and Annotate`,progress:r.visuals})]})]}),n(`div`,{className:`pt-2 text-sm text-muted`,children:[`Progress: `,l,`%`,t(`span`,{className:`px-2`,children:`•`}),t(`span`,{className:o,children:s}),r.started_at&&n(e,{children:[t(`span`,{className:`px-2`,children:`•`}),n(`span`,{children:[((Date.now()-r.started_at)/1e3).toFixed(0),` sec. elapsed`]})]})]}),t(Ft,{percent:l})]}),!r&&n(`div`,{className:`flex items-center gap-2 text-muted`,children:[t(je,{size:`sm`}),t(`span`,{children:a(`store.loadingProcessingStatus`)})]})]})}function P4({name:e,progress:t}){return n(`div`,{className:`flex gap-2 text-sm`,children:[n(`span`,{className:`text-muted min-w-36`,children:[e,`:`]}),n(`span`,{children:[t.processed,` of `,t.total]})]})}Q();const F4=Object.values(xn),I4=Object.values(Cn);function L4({onChange:e,isLoading:r,refresh:i,searchTypes:a}){let{client:s,project:c}=q(),{t:l}=K(),u=nt(),[d,f]=G(void 0),[p,h]=G(void 0),g=!!c&&(!!p?.embeddings.text||!!p?.embeddings.image),[_,v]=G(void 0),y=W(i),b=W(void 0),[x,S]=G(!1),[C,w]=G(a||F4),[T,E]=G(100);H(()=>{a&&w(a)},[a]);let D={},O=!1,k=!1;C.forEach(e=>{e===xn.full_text?O=!0:k=!0,I4.includes(e)&&(D[e]=!0)}),H(()=>{y.current!==i&&(y.current=i,f(void 0),v(void 0))}),H(()=>{c&&s.projects.retrieve(c.id).then(e=>{h(e.configuration)})},[s.projects.retrieve,c]),H(()=>{_&&u({title:_,status:`success`,duration:2e3})},[_,u]),H(()=>{let t=b.current;b.current=d,t&&(!d||d.length===0)&&e(void 0)},[e,d]);let A=()=>{!g||!d||(e({vector:k?{text:d,config:D}:void 0,full_text:O?d:void 0,limit:T}),v(`Searching...`))},j=e=>{e.key===`Enter`&&A()},M=e=>t=>{w(t?t=>Array.from(new Set([...t,e])):t=>t.filter(t=>t!==e))};return n(`div`,{className:`flex gap-1 items-center`,children:[t(te,{placeholder:l(`store.searchPlaceholder`),value:d,onChange:f,onKeyDown:j,className:`min-w-[200px]`}),t(o,{variant:`ghost`,onClick:()=>S(!0),title:l(`store.semanticSearchSettings`),className:`ms-1`,children:t(Iy,{size:18})}),n(se,{isOpen:x,onClose:()=>S(!1),children:[t(ue,{children:l(`store.searchTypes`)}),t(ce,{children:n(`div`,{className:`flex flex-col gap-2`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(m,{id:`search-type-full_text`,checked:C.includes(xn.full_text),onCheckedChange:M(xn.full_text)}),t(re,{htmlFor:`search-type-full_text`,children:l(`store.fullText`)})]}),t(`div`,{className:`font-semibold mt-2 mb-1`,children:l(`store.embeddings`)}),I4.map(e=>n(`div`,{className:`flex items-center gap-2`,children:[t(m,{id:`search-type-${e}`,checked:C.includes(e),onCheckedChange:M(e)}),t(re,{htmlFor:`search-type-${e}`,children:e.charAt(0).toUpperCase()+e.slice(1)})]},e)),n(`div`,{className:`mt-3`,children:[t(`span`,{className:`me-2`,children:l(`store.limit`)}),t(de,{type:`number`,min:1,value:T,onChange:e=>E(Number(e??100)),style:{width:80}})]})]})}),t(le,{children:t(o,{variant:`outline`,onClick:()=>S(!1),children:l(`store.close`)})})]}),t(o,{variant:`secondary`,isLoading:r,onClick:A,isDisabled:!g,title:l(`store.semanticSearch`),children:l(`store.search`)})]})}Q();const R4=[{name:`ID`,field:`id`,type:`objectId?slice=-7`},{name:`Name`,field:`.`,type:`objectName`},{name:`Type`,field:`type.name`,type:`string`},{name:`Status`,field:`status`,type:`string`},{name:`Updated At`,field:`updated_at`,type:`date`}];function z4(e,t){return(t?e.getTypeLayout(t):R4)??R4}function B4({onUploadDone:e=async()=>{},layout:n,toolbarActions:r}){let i=z$(),a=nt(),{t:o}=K(),s=Y$(V(async t=>{await e(t),setTimeout(()=>{console.log(`Delayed refresh after upload to ensure backend consistency`),i.search().then(e=>{e&&a({title:o(`store.documentListRefreshed`),description:o(`store.documentListRefreshedDesc`),status:`info`,duration:3e3})}).catch(e=>{console.error(`Failed to refresh search results:`,e)})},1e3)},[e,i,o,a])),c=V((e,t)=>{let n=i.collectionId;return s(e,t,n)},[i,s]);return t(V4,{layout:n,onUpload:c,toolbarActions:r})}function V4({layout:e,onUpload:r,allowFilter:i=!0,allowSearch:a=!0,toolbarActions:o}){let{t:s}=K(),c=z$(),[l,u]=G(!1),[d,f]=G(null),{registry:p}=nQ(),{search:m,isLoading:h,error:g,objects:_,hasMore:v}=V$(),[y,b]=G(p?e||z4(p,m.query.type):R4);H(()=>{e&&b(e)},[e]);let[x,S]=G(0),[C,w]=G(0),[T,E]=G(localStorage.getItem(i1.LAST_DISPLAYED_VIEW)===`grid`),[D,O]=G([]),k=W(null),A=W(null),j=V((e,t)=>{u(!1),e.catch(e=>{console.error(t,e)}).finally(()=>{u(!0)})},[]);H(()=>{let e=!1;return m.initialized?(u(!0),()=>{e=!0}):(u(!1),w(0),m.search().catch(t=>{e||console.error(`Initial search failed:`,t)}).finally(()=>{e||u(!0)}),()=>{e=!0})},[m]),H(()=>{_.length<C&&w(_.length)},[_.length,C]),Qe(k,()=>{l&&_.length>0&&_.length!==C&&(u(!1),m.loadMore().catch(e=>{console.error(`Failed to load more search results:`,e)}).finally(()=>{w(_.length),u(!0)}))},{deps:[l,_.length]});let N=e=>{if(e?.vector){if(m.query.vector=e.vector,m.query.full_text=e.full_text,m.query.weights=e.weights,m.query.score_aggregation=e.score_aggregation,m.query.dynamic_scaling=e.dynamic_scaling,e.limit!==void 0&&(m.limit=e.limit,m.query.limit=e.limit),!y.find(e=>e.name===`Search Score`)){let e=[...y,{name:`Search Score`,field:`score`,render:e=>typeof e.score==`number`?e.score.toFixed(4):`0.0000`}];b(e)}j(m.search(),`Vector search failed:`)}else e?.full_text?(m.query.full_text=e.full_text,e.limit!==void 0&&(m.limit=e.limit,m.query.limit=e.limit),j(m.search(),`Text search failed:`)):e===void 0&&l&&(delete m.query.vector,delete m.query.full_text,j(m.search(),`Search reset failed:`))},P=B$(),F=z$(),I=()=>{j(m.search(),`Search refresh failed:`)},L=mQ(P),ee=hQ(F),R=e=>{let t=typeof e==`function`?e(D):e;O(t),ee(t)},te=(e,t)=>{let n=L.find(t=>t.name===e),r={name:e,type:n?.type,placeholder:n?.placeholder,multiple:n?.multiple};R(i=>{let a=i.filter(t=>t.name!==e);if(n?.type===`stringList`||Array.isArray(t)){let n=Array.isArray(t)?t:[t],o=i.find(t=>t.name===e)?.value??[];return[...a,{...r,value:Array.from(new Set([...o,...n]))}]}return[...a,{...r,value:[{value:t,label:t}]}]})},ne=new URL(window.location.href),re=ne.searchParams.get(`filters`);if(re)try{let e=re.split(`;`),t=e.filter(e=>{let[t]=e.split(`:`),n=decodeURIComponent(t);return n!==`start`&&n!==`end`});if(t.length!==e.length){let e=t.length>0?t.join(`;`):``;e?ne.searchParams.set(`filters`,e):ne.searchParams.delete(`filters`),window.history.replaceState(window.history.state||{},``,ne.toString())}}catch(e){console.error(`Failed to clean start/end filters from URL:`,e)}let ie=Qn();return n(`div`,{className:`flex flex-col gap-y-2 flex-1 min-h-0 `,children:[t(U4,{object:d,onClose:()=>f(null)}),g&&t(M,{title:s(`store.error`),children:g.message}),t(H4,{isLoading:h,refreshTrigger:x,allowFilter:i,allowSearch:a,filterGroups:L,filters:D,handleFilterChange:R,handleVectorSearch:N,handleRefetch:I,setIsGridView:E,toolbarActions:o}),t(`div`,{className:`flex flex-col w-full flex-1 min-h-0 border rounded-md mb-2`,children:n(`div`,{ref:A,className:`flex-1 min-h-0 overflow-y-auto`,children:[t(t$,{onFilter:te,children:t(Z$,{objects:_,isLoading:!_.length&&h,layout:y,onRowClick:e=>{ie(`/objects/${e.id}`)},previewObject:e=>{let t=_.find(t=>t.id===e)||null;f(t)},selectedObject:d,onUpload:r,isGridView:T,collectionId:c.collectionId})}),v?t(`div`,{ref:k,className:`w-full flex justify-center`,children:t(je,{size:`xl`})}):t(`div`,{className:`text-muted text-center text-sm py-1`,children:`All ${_.length} objects loaded.`})]})})]})}function H4(e){let{t:r}=K(),{isLoading:i,refreshTrigger:a,allowFilter:s,allowSearch:c,filterGroups:l,filters:u,handleFilterChange:d,handleVectorSearch:f,handleRefetch:p,setIsGridView:m,toolbarActions:h}=e;return n(`div`,{className:`sticky top-0 z-10 bg-background py-2 flex justify-between items-center`,children:[s?t(I,{filterGroups:l,filters:u,setFilters:d,children:n(`div`,{children:[t(`div`,{className:`flex flex-row gap-4 items-center justify-between w-full`,children:n(`div`,{className:`flex gap-2 items-center w-2/3`,children:[c&&t(L4,{onChange:f,isLoading:i,refresh:a,className:`w-full`}),t(P,{})]})}),n(`div`,{className:`flex gap-2 items-center pt-2`,children:[t(N,{}),t(F,{})]})]})}):t(`div`,{className:`flex flex-row gap-4 items-center justify-between w-full`,children:t(`div`,{className:`flex gap-2 items-center w-2/3`,children:c&&t(L4,{onChange:f,isLoading:i,refresh:a})})}),n(`div`,{className:`flex gap-1 items-center`,children:[h,t(o,{variant:`outline`,onClick:p,title:r(`store.refresh`),children:t(hy,{size:16})}),t(i1,{onUpdate:m})]})]})}function U4({object:e,onClose:r}){let{store:i}=q(),a=nt(),s=Qn(),{downloadFromContentSource:c}=nG({client:i,toast:a}),l=e?.content?.source,u=typeof e?.properties?.title==`string`?e.properties.title:e?.name;return e?n(Oe,{title:u,isOpen:!0,onClose:r,children:[n(`div`,{className:`flex items-center gap-x-2`,children:[t(o,{variant:`ghost`,size:`sm`,title:`Open Object`,onClick:()=>s(`/objects/${e.id}`),children:t(Dg,{className:`size-4`})}),l&&t(o,{variant:`ghost`,size:`sm`,title:`Download`,onClick:()=>c(l,tG(e)),children:t(xg,{className:`size-4`})})]}),t(C,{className:`my-2`}),t(`div`,{className:`pt-2`,children:t(x4,{object:e,loadText:!0},e.id)})]}):null}const W4=[{name:`ID`,field:`id`,type:`objectId?slice=-7`},{name:`Name`,field:`.`,type:`objectName`},{name:`Revision`,field:`.`,type:`revision`},{name:`Type`,field:`type.name`,type:`string`},{name:`Status`,field:`status`,type:`string`},{name:`Updated At`,field:`updated_at`,type:`date`}];function G4({collection:e}){let n=nt(),{client:r}=q(),{registry:i}=nQ(),a=async t=>{t.length>0&&await r.store.collections.addMembers(e.id,t).catch(e=>{n({title:`Failed to add objects to collection`,description:e.message,status:`error`})})},o=K4(e,i);return t(`div`,{className:`flex flex-col h-full`,children:e.dynamic?t(V4,{layout:o}):t(B4,{onUploadDone:a,layout:o})})}function K4(e,t){let n=e.table_layout;return n&&n.length>0||(e.type&&t&&(n=t?.getTypeLayout(En(e.type))),n&&n.length>0)?n:W4}function q4({className:e,defaultValue:r,onChange:i,isClearable:a,multiple:o}){let{t:s}=K(),{registry:c}=nQ(),[l,u]=G(!1),d=e=>e===null?s(`store.none`):n(`div`,{children:[t(`div`,{className:`text-sm`,children:e.name}),t(`div`,{className:`text-xs text-muted truncate`,children:e.description})]}),[f,p]=G(),[m,h]=G([]);return H(()=>{if(!l&&(u(!0),c&&r)){if(o&&Array.isArray(r)){let e=c.types.filter(e=>r.includes(e.id));h(e)}let e=c.types.find(e=>e.id===r);e&&p(e)}},[l,c,r,o]),o?t(`div`,{className:`flex flex-col gap-4 content-between`,children:t(we,{options:c?.types||[],value:m,onChange:e=>{h(e),i(e)},placeholder:s(`store.chooseContentTypes`),optionLabel:d,className:e||`text-sm bg-background`,filterBy:`name`,isClearable:a||!1,multiple:!0})}):t(`div`,{className:`flex flex-col gap-4 content-between`,children:t(we,{options:c?.types||[],value:f,onChange:e=>{p(e||void 0),i(e)},placeholder:s(`store.chooseContentType`),optionLabel:d,className:e||`text-sm bg-background`,filterBy:`name`,isClearable:a||!1})})}function J4({onClose:r,redirect:i=!0,onAddToCollection:a}){let s=Qn(),c=nt(),{t:l}=K(),[u,d]=G(!1),{client:f}=q(),[p,m]=G({dynamic:!1,name:``,description:``});function h(e,t){m({...p,[e]:t})}return n(e,{children:[t(ce,{children:n(`form`,{onSubmit:e=>e.preventDefault(),children:[t(L,{label:l(`type.name`),required:!0,children:t(te,{type:`text`,value:p.name||``,onChange:e=>h(`name`,e)})}),t(L,{label:l(`type.description`),className:`mt-2`,children:t(Ue,{value:p.description||``,onChange:e=>h(`description`,e.target.value)})}),t(L,{label:l(`store.dynamicCollection`),className:`mt-2`,direction:`row`,description:l(`store.dynamicCollectionDescription`),children:t(Ne,{value:p.dynamic||!1,onChange:e=>h(`dynamic`,e)})}),!p.dynamic&&t(L,{label:l(`store.allowedContentTypes`),className:`mt-4`,description:l(`store.allowedContentTypesOptionalDescription`),children:t(q4,{defaultValue:p.allowed_types||null,onChange:e=>{Array.isArray(e)?h(`allowed_types`,e.map(e=>e.id)):h(`allowed_types`,e?[e.id]:[])},isClearable:!0,multiple:!0})}),t(L,{label:l(`store.contentType`),className:`mt-2`,description:l(`store.typeDescription`),children:t(q4,{defaultValue:p.type||null,onChange:e=>{Array.isArray(e)?h(`type`,e.length>0?e[0].id:null):h(`type`,e?.id||null)},isClearable:!0})})]})}),t(le,{children:t(o,{isDisabled:u,onClick:()=>{if(!p?.name?.trim()){c({title:l(`type.nameRequired`),description:l(`store.pleaseProvideName`),status:`error`,duration:5e3});return}p.name=p.name.trim(),p.description&&=p.description.trim(),p.dynamic??=!1,d(!0),f.store.collections.create(p).then(e=>{r(),c({title:l(`store.collectionCreated`),description:`Collection "${e.name}" created successfully`,status:`success`,duration:3e3}),i&&s(`/collections/${e.id}`),a&&a(e.id)}).catch(e=>{c({title:l(`store.failedToCreateCollection`),description:e.message,status:`error`,duration:5e3})}).finally(()=>d(!1))},children:l(`store.createCollection`)})})]})}function Y4({isOpen:e,onClose:r}){let{t:i}=K();return n(se,{onClose:r,isOpen:e,children:[t(ue,{children:i(`store.createACollection`)}),t(J4,{onClose:r})]})}Q();function X4(){let{client:r}=q(),i=nt(),{t:a}=K(),[s,c]=G(),[l,u]=G(!0),[d,f]=G(!1),{data:p,error:m,refetch:h}=Ye(()=>r.store.collections.search({}),[]);return H(()=>{(p||m)&&u(!1)},[p,m]),m?t(M,{title:a(`store.collectionFetchFailed`),children:Ge(m)}):n(e,{children:[p&&(p.length>0?n(Le,{className:`w-full`,children:[t(`thead`,{children:n(`tr`,{children:[t(`th`,{children:a(`type.name`)}),t(`th`,{children:a(`type.type`)}),t(`th`,{children:a(`store.created`)}),t(`th`,{})]})}),t(Pe,{columns:4,isLoading:l,children:p.map(e=>n(Ie,{children:[t(`td`,{children:n(`div`,{className:`flex items-center gap-2`,children:[t(Z4,{isDynamic:e.dynamic}),t(Zn,{href:`/collections/${e.id}`,children:e.name})]})}),t(`td`,{children:e.type?.name||`-`}),t(`td`,{children:WD(e.created_at).fromNow()}),t(`td`,{className:`text-end`,children:t(o,{variant:`destructive`,size:`sm`,onClick:()=>c(e.id),children:t(hb,{className:`size-4`})})})]},e.id))})]}):t(j,{title:a(`store.noCollections`),buttonLabel:a(`store.newCollections`),onClick:()=>f(!0),children:a(`store.getStartedCollections`)})),t(Y4,{isOpen:d,onClose:()=>f(!1)}),t(b,{isOpen:!!s,title:a(`store.deleteCollection`),content:a(`store.areYouSureDeleteCollection`),onConfirm:async()=>{if(s)try{await r.store.collections.delete(s),i({title:a(`store.collectionDeleted`),status:`success`,duration:3e3}),h()}catch(e){console.error(`Failed to delete collection:`,e),i({title:a(`store.failedToDeleteCollection`),description:Ge(e),status:`error`,duration:5e3})}finally{c(void 0)}},onCancel:()=>c(void 0)})]})}function Z4({isDynamic:e}){let{t:n}=K(),r=n(e?`store.dynamicCollection`:`store.staticCollection`),i=t(e?Ay:e_,{className:`size-5`});return t(We,{description:r,className:`me-2`,children:i})}Q();const Q4=`h-6 w-6 p-0 opacity-0 group-hover/field:opacity-100 text-muted hover:text-foreground transition-opacity shrink-0`;function $4({objects:e,isLoading:r,onFilter:i,selectedIds:a,onToggleOne:s,allSelected:c,onToggleAll:l}){let{t:u}=K(),d=Qn(),f=!!s;return n(Le,{className:`w-full`,children:[t(Fe,{children:n(`tr`,{children:[f&&t(`th`,{className:`w-[5%]`,children:t(`input`,{type:`checkbox`,checked:!!c,"aria-label":u(`store.actions.selectAllTypes`),onChange:e=>l?.(e.target.checked)})}),t(`th`,{children:u(`store.name`)}),t(`th`,{children:u(`store.strictMode`)}),t(`th`,{children:u(`store.semanticChunking`)}),t(`th`,{children:u(`store.updatedAt`)})]})}),t(Pe,{isLoading:r&&(!e||e.length===0),columns:f?5:4,children:e?.map(e=>n(`tr`,{onClick:()=>d(`/types/${e.id}`),className:`group cursor-pointer hover:bg-muted`,children:[f&&t(`td`,{className:`w-[5%]`,children:t(`input`,{type:`checkbox`,className:it(`checkbox group-hover:inline-block`,a?.includes(e.id)?`inline-block`:`hidden`),checked:a?.includes(e.id)??!1,"aria-label":u(`store.actions.selectType`,{name:e.name}),onClick:e=>e.stopPropagation(),onChange:t=>s?.(e.id,t.target.checked)})}),t(`td`,{className:`group/field`,children:n(`div`,{className:`flex items-center gap-2 min-w-0`,children:[t(`span`,{className:`truncate`,children:e.name}),t(x,{content:e.id,className:Q4}),i&&t(o,{variant:`ghost`,size:`sm`,title:`Filter by ${e.name}`,className:Q4,onClick:t=>{t.stopPropagation(),i(`name`,e.name)},children:t(l_,{className:`size-3`})})]})}),t(`td`,{children:e.strict_mode?`Yes`:`No`}),t(`td`,{children:e.is_chunkable?`Yes`:`No`}),t(`td`,{children:t(We,{description:WD(e.updated_at).format(`YYYY-MM-DD HH:mm:ss`),children:WD(e.updated_at).fromNow()})})]},e.id))})]})}function e3({title:e,isOpen:r,onClose:i,okLabel:a,initialPayload:s,isLoading:c}){let{t:l}=K(),u=nt(),[d,f]=G(s?.name),[p,m]=G(s?.description),h=s?.strict_mode??!1,g=()=>{if(!d){u({status:`error`,title:l(`type.nameRequired`),duration:5e3});return}i({name:d,description:p,strict_mode:h}).then(()=>i())};return n(se,{isOpen:r,onClose:()=>i(),children:[t(ue,{children:e}),t(ce,{className:`pt-0`,children:n(`div`,{className:`h-full flex flex-col gap-4 content-between`,children:[n(`div`,{children:[t(`div`,{className:`block text-sm font-medium text-muted`,children:l(`type.name`)}),t(te,{value:d,onChange:f})]}),n(`div`,{children:[t(`div`,{className:`block text-sm font-medium text-muted`,children:l(`type.description`)}),t(Ue,{value:p,onChange:e=>m(e.target.value),minLines:5})]})]})}),t(le,{children:n(`div`,{className:`flex justify-end gap-4`,children:[t(o,{variant:`secondary`,onClick:()=>i(),children:l(`modal.cancel`)}),t(o,{variant:`primary`,onClick:()=>g(),isLoading:c,children:a})]})})]})}var t3=class{client;limit;result=new De({objects:[],isLoading:!1});query={};constructor(e,t=100){this.client=e,this.limit=t}get objects(){return this.result.value.objects}get error(){return this.result.value.error}get isRunning(){return this.result.value.isLoading}getFilterValue(e){return this.query[e]}setFilterValue(e,t){this.query[e]=t,this.search()}reset(e=!1){this.result.value={objects:[],isLoading:e}}_updateRunningState(e){let t=this.result.value;this.result.value={objects:t.objects,isLoading:e,error:t.error}}async _search(e=!1){if(this.isRunning)return Promise.resolve(!1);this.result.value={isLoading:!0,objects:e?this.objects:[]};let t=this.limit,n=this.objects.length;return this.client.types.list({limit:t,offset:n,query:this.query}).then(async e=>(this.result.value={isLoading:!1,objects:this.objects.concat(e)},!0)).catch(e=>{throw this.result.value={error:e,isLoading:!1,objects:this.objects},e})}search(){return this.isRunning?Promise.resolve(!1):this._search(!1)}loadMore(){return this.isRunning?Promise.resolve(!1):this._search(!0)}};const n3=dt(void 0);function r3(){return _t(n3)}function i3(){let e=r3();return{...rt(e.result),search:e}}function a3(){return r3().objects.length}Q();var o3;(function(e){e.true=`Yes`,e.false=`No`})(o3||={});function s3({isDirty:r=!1}){let{store:i}=q(),{reload:a}=nQ(),{t:s}=K(),c=nt(),[l,u]=G(!1),{search:d,isLoading:f,error:p,objects:m}=i3(),[h,g]=G([]),[_,v]=G(!1),[y,x]=G(!1),S=h.length,C=!!m&&m.length>0&&m.every(e=>h.includes(e.id)),w=m?.filter(e=>h.includes(e.id))??[],T=(e,t)=>{g(n=>t?n.includes(e)?n:[...n,e]:n.filter(t=>t!==e))},E=e=>{g(e&&m?m.map(e=>e.id):[])},D=async()=>{if(!y){x(!0);try{let e=await Promise.allSettled(h.map(e=>i.types.delete(e))),t=e.filter(e=>e.status===`rejected`).length,n=e.length-t;v(!1),g([]),a(),await d.search(),c(t===0?{status:`success`,title:s(`store.actions.typeDeleted`,{count:n}),duration:3e3}:{status:`error`,title:s(`store.actions.typeDeletePartial`,{succeeded:n,failed:t}),duration:5e3})}catch(e){c({status:`error`,title:s(`store.actions.failedToDeleteTypes`),description:e instanceof Error?e.message:void 0,duration:5e3})}finally{x(!1)}}},[O,k]=G(``),A=Je(O,500),N=W(null);Qe(N,()=>{l&&d.loadMore()},{deps:[l,d]}),H(()=>{d.search().then(()=>u(!0))},[d]),H(()=>{d.query.name=A,d.search().then(()=>u(!0))},[A,d]);let[P,F]=G(void 0),I=e=>{F(e)};H(()=>{d.query.chunkable=P?P===`Yes`:void 0,d.search().then(()=>u(!0))},[P,d]),H(()=>{r&&l&&d.search().then(()=>u(!0))},[r,l,d]);let[L,ee]=G(!1);return p?t(M,{title:s(`store.failedToFetchTypes`),children:p.message}):n(`div`,{className:`flex flex-col flex-1 min-h-0`,children:[n(`div`,{className:`flex flex-shrink-0 gap-4 items-center`,children:[t(te,{placeholder:s(`store.filterByName`),value:O,onChange:k}),t(we,{className:`w-60`,isClearable:!0,options:Object.values(o3),value:P,onChange:I,placeholder:s(`store.isChunkable`)}),S>0&&n(`div`,{className:`flex items-center gap-2 ms-auto`,children:[t(`span`,{className:`text-sm font-medium whitespace-nowrap`,children:s(`store.actions.selectedCount`,{n:S})}),t(We,{description:s(`store.actions.clearSelection`),asChild:!0,children:t(o,{variant:`ghost`,"aria-label":s(`store.actions.clearSelection`),onClick:()=>g([]),children:t(Gb,{className:`size-4`})})}),t(o,{variant:`destructive`,isDisabled:y,onClick:()=>v(!0),children:s(y?`store.actions.deleting`:`store.actions.deleteSelected`)})]})]}),t(`div`,{className:`flex flex-col w-full flex-1 min-h-0 border rounded-md my-2`,children:n(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:[!f&&m?.length===0?t(j,{title:s(`store.noType`),buttonLabel:s(`store.createType`),onClick:()=>{ee(!0)},children:s(`store.getStartedTypes`)}):n(e,{children:[t($4,{objects:m,isLoading:f,onFilter:(e,t)=>{e===`name`&&k(t)},selectedIds:h,onToggleOne:T,allSelected:C,onToggleAll:E}),t(`div`,{ref:N,className:`h-4 w-full`})]}),t(e3,{okLabel:`Create`,title:s(`store.createType`),isOpen:L,onClose:async e=>e?i.types.create(e).then(async()=>{c({status:`success`,title:s(`store.typeCreated`),duration:2e3}),a(),d.search().then(()=>u(!0))}).catch(e=>{c({status:`error`,title:s(`store.errorCreatingType`),description:e.message,duration:5e3})}):(ee(!1),Promise.resolve())}),t(b,{isOpen:_,title:s(`store.actions.deleteType`,{count:S}),content:n(`div`,{children:[t(`p`,{children:s(`store.actions.deleteTypeConfirm`,{count:S})}),w.length>0&&n(e,{children:[t(`div`,{className:`mt-2`,children:s(`store.actions.affectedItems`)}),t(`ul`,{className:`mt-1 max-h-40 overflow-y-auto rounded-md border p-2 text-sm`,children:w.map(e=>t(`li`,{className:`truncate py-0.5`,children:e.name||e.id},e.id))})]})]}),onConfirm:D,onCancel:()=>v(!1),confirmationValue:`delete`,confirmationLabel:s(`store.actions.typeToConfirmDelete`),confirmationPlaceholder:`delete`})]})})]})}function c3(e,t,n){if(t.length===0)return e;let r=structuredClone(e),i=[r],a=r;for(let e of t.slice(0,-1)){let t=a[e],n=p3(t)?t:{};a[e]=n,a=n,i.push(a)}let o=t[t.length-1];return n===void 0||n===``?(delete a[o],f3(i,t)):a[o]=n,r}function l3(e,t,n,r){let i=e?.map(e=>[e[0]??1,e[1]??1])??[],a=i[t]??[1,1];return a[n]=r,i[t]=a,i}function u3(e,t){let n={...e,environment:t};return delete n.model,delete n.model_options,m3(n)?n:void 0}function d3(e,t){let n={...e,model:t};return t!==e?.model&&delete n.model_options,m3(n)?n:void 0}function f3(e,t){for(let n=e.length-1;n>0;--n){let r=e[n];if(Object.keys(r).length>0)break;delete e[n-1][t[n-1]]}}function p3(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function m3(e){return Object.values(e).some(e=>e!==void 0)}Q();function h3({policy:e,section:r,onChange:i,readonly:a=!1}){let{t:o}=K(),s=(t,n)=>i(c3(e,t,n));if(r===`classification`)return n(g3,{children:[n(_3,{title:o(`intakePolicy.section.classification`),description:o(`intakePolicy.help.section.classification`),children:[n(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[t(x3,{label:o(`intakePolicy.field.mode`),description:o(`intakePolicy.help.mode`),value:e.mode,options:E3(o,[`programmatic`,`agentic`]),onChange:e=>s([`mode`],e),readonly:a}),t(x3,{label:o(`intakePolicy.field.defaultView`),value:e.default_view,options:E3(o,[`auto`,`text`,`pdf`,`image`,`properties`]),onChange:e=>s([`default_view`],e),readonly:a})]}),t(y3,{label:o(`intakePolicy.field.identificationGuidance`),description:o(`intakePolicy.help.identificationGuidance`),value:e.identification?.guidance,onChange:e=>s([`identification`,`guidance`],e),readonly:a}),t(y3,{label:o(`intakePolicy.field.distinguishFrom`),description:o(`intakePolicy.help.distinguishFrom`),value:e.identification?.distinguish_from,onChange:e=>s([`identification`,`distinguish_from`],e),readonly:a}),t(L,{label:o(`intakePolicy.field.examples`),description:o(`intakePolicy.help.examples`),children:t(He,{options:e.identification?.examples??[],value:e.identification?.examples??[],onChange:e=>s([`identification`,`examples`],e.length?e:void 0),onOptionsChange:e=>s([`identification`,`examples`],e.length?e:void 0),creatable:!0,disabled:a,placeholder:o(`intakePolicy.placeholder.objectId`)})})]}),n(_3,{title:o(`intakePolicy.section.locate`),description:o(`intakePolicy.help.section.locate`),last:!0,children:[t(y3,{label:o(`intakePolicy.field.locateInstructions`),description:o(`intakePolicy.help.locateInstructions`),value:e.locate?.instructions,onChange:t=>s([`locate`],t?{...e.locate,instructions:t}:void 0),readonly:a}),n(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[t(x3,{label:o(`intakePolicy.field.contactSheetDetail`),description:o(`intakePolicy.help.contactSheetDetail`),value:e.locate?.detail,options:[{value:8,label:o(`intakePolicy.option.pagesPerSheet`,{count:8})},{value:16,label:o(`intakePolicy.option.pagesPerSheet`,{count:16})}],onChange:e=>s([`locate`,`detail`],e),readonly:a||!e.locate}),t(b3,{label:o(`intakePolicy.field.locateMinPages`),description:o(`intakePolicy.help.locateMinPages`),value:e.locate?.min_pages,min:0,onChange:e=>s([`locate`,`min_pages`],e),readonly:a||!e.locate})]})]})]});if(r===`conversion`)return n(g3,{children:[n(_3,{title:o(`intakePolicy.section.conversion`),description:o(`intakePolicy.help.section.conversion`),children:[n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:[t(S3,{label:o(`intakePolicy.field.enabled`),value:e.text_conversion?.enabled,onChange:e=>s([`text_conversion`,`enabled`],e),readonly:a}),t(x3,{label:o(`intakePolicy.field.method`),description:o(`intakePolicy.help.method`),value:e.text_conversion?.method,options:E3(o,[`auto`,`basic`,`llm`,`custom`]),onChange:e=>s([`text_conversion`,`method`],e),readonly:a}),t(x3,{label:o(`intakePolicy.field.outputFormat`),value:e.text_conversion?.output_format,options:E3(o,[`markdown`,`text`]),onChange:e=>s([`text_conversion`,`output_format`],e),readonly:a}),t(x3,{label:o(`intakePolicy.field.pageScope`),description:o(`intakePolicy.help.pageScope`),value:e.text_conversion?.scope,options:E3(o,[`all`,`located`]),onChange:e=>s([`text_conversion`,`scope`],e),readonly:a}),t(b3,{label:o(`intakePolicy.field.renderDpi`),description:o(`intakePolicy.help.renderDpi`),value:e.text_conversion?.render_dpi,min:72,onChange:e=>s([`text_conversion`,`render_dpi`],e),readonly:a})]}),t(y3,{label:o(`intakePolicy.field.instructions`),value:e.text_conversion?.instructions,onChange:e=>s([`text_conversion`,`instructions`],e),readonly:a})]}),t(_3,{title:o(`intakePolicy.section.conversionModel`),description:o(`intakePolicy.help.section.conversionModel`),children:t(T3,{title:o(`intakePolicy.field.model`),config:e.text_conversion?.config,onChange:e=>s([`text_conversion`,`config`],e),readonly:a})}),e.text_conversion?.method===`custom`&&t(_3,{title:o(`intakePolicy.section.customConversion`),description:o(`intakePolicy.help.section.customConversion`),children:n(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[t(v3,{label:o(`intakePolicy.field.interaction`),value:e.text_conversion.custom?.interaction,onChange:e=>s([`text_conversion`,`custom`,`interaction`],e),readonly:a}),t(v3,{label:o(`intakePolicy.field.agent`),value:e.text_conversion.custom?.agent,onChange:e=>s([`text_conversion`,`custom`,`agent`],e),readonly:a})]})}),t(_3,{title:o(`intakePolicy.section.pageRanges`),description:o(`intakePolicy.help.section.pageRanges`),last:!0,children:t(w3,{value:e.text_conversion?.page_ranges,onChange:e=>s([`text_conversion`,`page_ranges`],e),readonly:a})})]});if(r===`extraction`)return n(g3,{children:[n(_3,{title:o(`intakePolicy.section.extraction`),description:o(`intakePolicy.help.section.extraction`),children:[n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:[t(S3,{label:o(`intakePolicy.field.enabled`),value:e.extraction?.enabled,onChange:e=>s([`extraction`,`enabled`],e),readonly:a}),t(x3,{label:o(`intakePolicy.field.source`),description:o(`intakePolicy.help.extractionSource`),value:e.extraction?.source,options:E3(o,[`auto`,`text`,`vision`,`mixed`]),onChange:e=>s([`extraction`,`source`],e),readonly:a}),t(x3,{label:o(`intakePolicy.field.pageScope`),description:o(`intakePolicy.help.pageScope`),value:e.extraction?.scope,options:E3(o,[`all`,`located`]),onChange:e=>s([`extraction`,`scope`],e),readonly:a}),t(b3,{label:o(`intakePolicy.field.maxPages`),description:o(`intakePolicy.help.extractionMaxPages`),value:e.extraction?.max_pages,min:1,onChange:e=>s([`extraction`,`max_pages`],e),readonly:a})]}),t(v3,{label:o(`intakePolicy.field.interaction`),description:o(`intakePolicy.help.extractionInteraction`),value:e.extraction?.interaction,onChange:e=>s([`extraction`,`interaction`],e),readonly:a}),t(y3,{label:o(`intakePolicy.field.instructions`),value:e.extraction?.instructions,onChange:e=>s([`extraction`,`instructions`],e),readonly:a}),t(w3,{value:e.extraction?.page_ranges,onChange:e=>s([`extraction`,`page_ranges`],e),readonly:a})]}),t(_3,{title:o(`intakePolicy.section.extractionModel`),description:o(`intakePolicy.help.section.extractionModel`),children:t(T3,{title:o(`intakePolicy.field.model`),config:e.extraction?.config,onChange:e=>s([`extraction`,`config`],e),readonly:a})}),t(_3,{title:o(`intakePolicy.section.visionBudget`),description:o(`intakePolicy.help.section.visionBudget`),last:!0,children:n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:[t(x3,{label:o(`intakePolicy.field.defaultDetail`),description:o(`intakePolicy.help.visionDetail`),value:e.extraction?.vision?.default_detail,options:E3(o,[`low`,`standard`,`high`]),onChange:e=>s([`extraction`,`vision`,`default_detail`],e),readonly:a}),t(C3,{description:o(`intakePolicy.help.visionDetail`),value:e.extraction?.vision?.allowed_details,onChange:e=>s([`extraction`,`vision`,`allowed_details`],e),readonly:a}),t(b3,{label:o(`intakePolicy.field.maxImageTokens`),description:o(`intakePolicy.help.maxImageTokens`),value:e.extraction?.vision?.max_image_tokens,min:1,onChange:e=>s([`extraction`,`vision`,`max_image_tokens`],e),readonly:a}),t(b3,{label:o(`intakePolicy.field.maxPayloadMb`),description:o(`intakePolicy.help.maxPayloadMb`),value:e.extraction?.vision?.max_payload_mb,min:1,onChange:e=>s([`extraction`,`vision`,`max_payload_mb`],e),readonly:a}),t(b3,{label:o(`intakePolicy.field.maxPagesPerCall`),value:e.extraction?.vision?.max_pages_per_call,min:1,onChange:e=>s([`extraction`,`vision`,`max_pages_per_call`],e),readonly:a})]})})]});if(r===`grounding`){let r=e.extraction?.grounding,i=r?.review;return n(g3,{children:[n(_3,{title:o(`intakePolicy.section.grounding`),description:o(`intakePolicy.help.section.grounding`),children:[n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:[t(S3,{label:o(`intakePolicy.field.enabled`),value:r?.enabled,onChange:e=>s([`extraction`,`grounding`,`enabled`],e),readonly:a}),t(b3,{label:o(`intakePolicy.field.maxPages`),value:r?.max_pages,min:1,onChange:e=>s([`extraction`,`grounding`,`max_pages`],e),readonly:a}),t(b3,{label:o(`intakePolicy.field.windowPages`),description:o(`intakePolicy.help.windowPages`),value:r?.window_pages,min:1,onChange:e=>s([`extraction`,`grounding`,`window_pages`],e),readonly:a}),t(v3,{label:o(`intakePolicy.field.interaction`),value:r?.interaction,onChange:e=>s([`extraction`,`grounding`,`interaction`],e),readonly:a})]}),n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:[t(S3,{label:o(`intakePolicy.field.useVision`),description:o(`intakePolicy.help.useVision`),value:r?.use_vision,onChange:e=>s([`extraction`,`grounding`,`use_vision`],e),readonly:a}),t(S3,{label:o(`intakePolicy.field.forceOcr`),description:o(`intakePolicy.help.forceOcr`),value:r?.force_ocr,onChange:e=>s([`extraction`,`grounding`,`force_ocr`],e),readonly:a}),t(S3,{label:o(`intakePolicy.field.refreshOcr`),description:o(`intakePolicy.help.refreshOcr`),value:r?.refresh_ocr,onChange:e=>s([`extraction`,`grounding`,`refresh_ocr`],e),readonly:a}),t(S3,{label:o(`intakePolicy.field.omitBlockBoxes`),description:o(`intakePolicy.help.omitBlockBoxes`),value:r?.omit_block_boxes,onChange:e=>s([`extraction`,`grounding`,`omit_block_boxes`],e),readonly:a}),t(S3,{label:o(`intakePolicy.field.updateProperties`),description:o(`intakePolicy.help.updateProperties`),value:r?.update_properties,onChange:e=>s([`extraction`,`grounding`,`update_properties`],e),readonly:a})]})]}),n(_3,{title:o(`intakePolicy.section.models`),description:o(`intakePolicy.help.section.models`),children:[t(T3,{title:o(`intakePolicy.field.primaryModel`),config:r?.config,onChange:e=>s([`extraction`,`grounding`,`config`],e),readonly:a}),t(T3,{title:o(`intakePolicy.field.hardModel`),config:r?.hard_config,onChange:e=>s([`extraction`,`grounding`,`hard_config`],e),readonly:a}),n(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[t(b3,{label:o(`intakePolicy.field.hardnessThreshold`),description:o(`intakePolicy.help.hardnessThreshold`),value:r?.hardness_threshold,min:0,max:1,step:.05,onChange:e=>s([`extraction`,`grounding`,`hardness_threshold`],e),readonly:a}),t(b3,{label:o(`intakePolicy.field.minCitationDensity`),description:o(`intakePolicy.help.minCitationDensity`),value:r?.min_citation_density,min:0,max:1,step:.05,onChange:e=>s([`extraction`,`grounding`,`min_citation_density`],e),readonly:a})]})]}),n(_3,{title:o(`intakePolicy.section.review`),description:o(`intakePolicy.help.section.review`),last:!0,children:[n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:[t(S3,{label:o(`intakePolicy.field.enabled`),value:i?.enabled,onChange:e=>s([`extraction`,`grounding`,`review`,`enabled`],e),readonly:a}),t(S3,{label:o(`intakePolicy.field.forceReview`),description:o(`intakePolicy.help.forceReview`),value:i?.force,onChange:e=>s([`extraction`,`grounding`,`review`,`force`],e),readonly:a}),t(b3,{label:o(`intakePolicy.field.reviewThreshold`),value:i?.threshold,min:0,max:1,step:.05,onChange:e=>s([`extraction`,`grounding`,`review`,`threshold`],e),readonly:a}),t(b3,{label:o(`intakePolicy.field.coverageThreshold`),description:o(`intakePolicy.help.coverageThreshold`),value:i?.coverage_threshold,min:0,max:1,step:.05,onChange:e=>s([`extraction`,`grounding`,`review`,`coverage_threshold`],e),readonly:a})]}),t(T3,{title:o(`intakePolicy.field.reviewModel`),config:i?.config,onChange:e=>s([`extraction`,`grounding`,`review`,`config`],e),readonly:a})]})]})}return n(g3,{children:[t(_3,{title:o(`intakePolicy.section.rendering`),description:o(`intakePolicy.help.section.rendering`),children:t(y3,{label:o(`intakePolicy.field.renderingTemplate`),description:o(`intakePolicy.help.renderingTemplate`),value:e.rendering_template,onChange:e=>s([`rendering_template`],e),readonly:a,monospace:!0,minLines:8})}),t(_3,{title:o(`intakePolicy.section.embeddings`),description:o(`intakePolicy.help.section.embeddings`),last:!0,children:n(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:[t(S3,{label:o(`intakePolicy.field.textEmbedding`),value:e.embeddings?.text,onChange:e=>s([`embeddings`,`text`],e),readonly:a}),t(S3,{label:o(`intakePolicy.field.imageEmbedding`),value:e.embeddings?.image,onChange:e=>s([`embeddings`,`image`],e),readonly:a}),t(S3,{label:o(`intakePolicy.field.propertiesEmbedding`),value:e.embeddings?.properties,onChange:e=>s([`embeddings`,`properties`],e),readonly:a}),t(S3,{label:o(`intakePolicy.field.generateToc`),value:e.generate_toc,onChange:e=>s([`generate_toc`],e),readonly:a})]})})]})}function g3({children:e}){return t(`div`,{className:`w-full px-1 py-4`,children:e})}function _3({title:e,description:r,children:i,last:a=!1}){return n(`section`,{className:a?`pb-3`:`mb-6 border-b pb-6`,children:[n(`div`,{className:`mb-4 flex items-center gap-2`,children:[t(`h3`,{className:`text-sm font-semibold`,children:e}),t(R,{description:r})]}),t(`div`,{className:`space-y-4`,children:i})]})}function v3({label:e,value:n,onChange:r,readonly:i,description:a}){return t(L,{label:e,description:a,children:t(te,{value:n??``,onChange:e=>r(e||void 0),disabled:i})})}function y3({label:e,value:n,onChange:r,readonly:i,description:a,minLines:o=3,monospace:s=!1}){return t(L,{label:e,description:a,children:t(Ue,{value:n??``,onChange:e=>r(e.target.value||void 0),disabled:i,minLines:o,maxLines:14,className:s?`font-mono`:void 0})})}function b3({label:e,description:n,value:r,onChange:i,readonly:a,min:o,max:s,step:c}){return t(L,{label:e,description:n,children:t(de,{value:r,onChange:e=>i(e===void 0||Number.isFinite(e)?e:void 0),disabled:a,min:o,max:s,step:c??1,noScroll:!0})})}function x3({label:e,description:n,value:r,options:i,onChange:a,readonly:o}){let{t:s}=K(),c=[{value:`__inherit__`,label:s(`intakePolicy.option.inherit`)},...i],l=c.find(e=>e.value===r)??c[0];return t(L,{label:e,description:n,children:t(we,{options:c,value:l,by:`value`,optionLabel:e=>e.label,onChange:e=>a(e.value===`__inherit__`?void 0:e.value),disabled:o})})}function S3({label:e,description:n,value:r,onChange:i,readonly:a}){let{t:o}=K(),s=[{value:`inherit`,label:o(`intakePolicy.option.inherit`)},{value:`enabled`,label:o(`intakePolicy.option.enabled`)},{value:`disabled`,label:o(`intakePolicy.option.disabled`)}],c=r===void 0?`inherit`:r?`enabled`:`disabled`;return t(L,{label:e,description:n,children:t(we,{options:[...s],value:s.find(e=>e.value===c),by:`value`,optionLabel:e=>e.label,onChange:e=>i(e.value===`inherit`?void 0:e.value===`enabled`),disabled:a})})}function C3({description:e,value:n,onChange:r,readonly:i}){let{t:a}=K(),o=E3(a,[`low`,`standard`,`high`]);return t(L,{label:a(`intakePolicy.field.allowedDetails`),description:e,children:t(we,{multiple:!0,options:o,value:o.filter(e=>n?.includes(e.value)),by:`value`,optionLabel:e=>e.label,onChange:e=>r(e.length?e.map(e=>e.value):void 0),disabled:i})})}function w3({value:e,onChange:r,readonly:i}){let{t:a}=K(),s=t=>{let n=e?.filter((e,n)=>n!==t);r(n?.length?n:void 0)};return t(L,{label:a(`intakePolicy.field.pageRanges`),description:a(`intakePolicy.help.pageRanges`),children:n(`div`,{className:`space-y-2`,children:[e?.map((c,l)=>n(`div`,{className:`grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_2.25rem] gap-2`,children:[t(de,{"aria-label":a(`intakePolicy.field.rangeStart`),value:c[0],onChange:t=>{t!==void 0&&Number.isFinite(t)&&r(l3(e,l,0,t))},disabled:i,step:1,noScroll:!0}),t(de,{"aria-label":a(`intakePolicy.field.rangeEnd`),value:c[1],onChange:t=>{t!==void 0&&Number.isFinite(t)&&r(l3(e,l,1,t))},disabled:i,step:1,noScroll:!0}),t(We,{description:a(`intakePolicy.action.removeRange`),children:t(o,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":a(`intakePolicy.action.removeRange`),onClick:()=>s(l),disabled:i,children:t(hb,{className:`size-4`})})})]},`${l}`)),n(o,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r([...e??[],[1,1]]),disabled:i,children:[t(oy,{className:`size-4`}),a(`intakePolicy.action.addRange`)]})]})})}function T3({title:e,config:r,onChange:i,readonly:a}){let{t:o}=K();return n(`div`,{children:[t(`div`,{className:`mb-2 text-xs font-medium text-muted`,children:e}),n(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[t(L,{label:o(`intakePolicy.field.environment`),children:t(J1,{selectedEnvId:r?.environment,onChange:e=>i(u3(r,e?.id)),isClearable:!0,disabled:a})}),t(L,{label:o(`intakePolicy.field.model`),children:t(Z1,{envId:r?.environment,selectedModelId:r?.model,onChange:e=>i(d3(r,e?.id)),isClearable:!0,disabled:a||!r?.environment})})]})]})}function E3(e,t){return t.map(t=>({value:t,label:e(`intakePolicy.option.${t}`)}))}Q();const D3=[{key:`minimal`,value:{identification:{guidance:`Documents that match this content type.`,distinguish_from:`Do not select this type for unrelated documents.`}}},{key:`extraction_only`,value:{text_conversion:{enabled:!1},extraction:{enabled:!0,source:`vision`,instructions:`Extract required fields only. Ignore cover pages, appendices, legal boilerplate, and marketing content.`},rendering_template:`# {{properties.title}}
1392
1392
 
1393
1393
  {{properties.summary}}`,embeddings:{text:!0,properties:!0},default_view:`pdf`}},{key:`grounded`,value:{extraction:{enabled:!0,grounding:{enabled:!0,use_vision:!0,config:{model:`publishers/google/models/gemini-3.5-flash`,model_options:{_option_id:`vertexai-gemini`,max_tokens:32e3,thinking_level:`LOW`,temperature:0}},hard_config:{model:`publishers/google/models/gemini-3.1-pro-preview`,model_options:{_option_id:`vertexai-gemini`,max_tokens:32e3,thinking_level:`LOW`,temperature:0}},hardness_threshold:.5,min_citation_density:.3,window_pages:3,review:{enabled:!0,config:{model:`publishers/google/models/gemini-3.5-flash`,model_options:{_option_id:`vertexai-gemini`,thinking_level:`MEDIUM`,max_tokens:32e3,temperature:0}},coverage_threshold:.2}}},default_view:`pdf`}},{key:`visual_first`,value:{identification:{guidance:`Presentation decks or visual reports with slides, charts, diagrams, tables, or callouts.`},text_conversion:{enabled:!0,method:`auto`},extraction:{enabled:!0,source:`auto`,instructions:`Use visual evidence when layout, charts, diagrams, or slide structure contain material information.`},default_view:`pdf`}},{key:`structured_spreadsheet`,value:{text_conversion:{enabled:!0,method:`auto`,instructions:`Preserve sheet names, headers, row labels, totals, and period columns.`},extraction:{enabled:!0,source:`text`,instructions:`Extract values from worksheet text. Do not infer values from charts.`},default_view:`properties`}},{key:`media_no_transcript`,value:{text_conversion:{enabled:!1},extraction:{enabled:!0,source:`auto`,instructions:`Analyze available metadata and source evidence without creating a transcript.`},default_view:`properties`}},{key:`full_reference`,value:{mode:`programmatic`,identification:{guidance:`Supplier invoices: billing documents with an invoice number, line items, amounts due, tax breakdown, and payment terms.`,distinguish_from:`Quotes and estimates are offers, not payment requests. Credit notes carry negative amounts. Receipts confirm a payment already made.`,examples:[]},text_conversion:{enabled:!0,method:`auto`,instructions:`Keep the commercial terms and totals. Drop boilerplate and legal footers.`,output_format:`markdown`,custom:{interaction:`my-project:ConvertSpecialDocument`,agent:`my-project:DocumentConversionAgent`}},extraction:{enabled:!0,source:`auto`,instructions:`Extract totals from the summary block, not from line items. Amounts include currency. Dates use ISO 8601.`,interaction:`sys:ExtractInformation`,verification:{enabled:!1,model:`publishers/anthropic/models/claude-sonnet`,environment:`default`,materiality:`Amounts, dates, identifiers, and party names are material. Typos in free text are not.`,threshold:.85,max_retries:1,on_fail:`flag`},grounding:{enabled:!0,interaction:`sys:ExtractInformationGrounded`,max_pages:20,force_ocr:!1,use_vision:!0,omit_block_boxes:!1,config:{model:`publishers/google/models/gemini-3.5-flash`},hard_config:{model:`publishers/google/models/gemini-3.1-pro-preview`},hardness_threshold:.5,window_pages:3,update_properties:!0,min_citation_density:.3,refresh_ocr:!1,review:{enabled:!0,config:{model:`publishers/google/models/gemini-3.5-flash`},coverage_threshold:.2}}},rendering_template:`# Invoice {{properties.invoice_number}}
1394
1394
 
1395
1395
  - Vendor: {{properties.vendor_name}}
1396
1396
  - Total: {{properties.currency}} {{properties.total_amount}}
1397
- - Due: {{properties.due_date}}`,embeddings:{text:!0,image:!1,properties:!0},generate_toc:!1,default_view:`auto`}}],D3={};function O3({objectType:r,value:a,onSave:s,onIntakeUpdate:c,leadingTabs:l,readonly:u=!1}){let{store:d}=q(),{t:f}=K(),p=nt(),{theme:m}=tt(),h=W(void 0),g=U(()=>I3(),[]),[_,v]=G(!1),y=r?.intake??a,[b,x]=G(()=>F3(y)),[S,C]=G(()=>F3(y)),[T,E]=G(void 0),[D,O]=G(l?.[0]?.name??`classification`),k=b!==S,A=U(()=>{let e=L3(b,g);return e.ok?e.policy:void 0},[b,g]),j=A??y??D3,M=e=>{let t=e,n=t.languages?.json?.jsonDefaults??t.json?.jsonDefaults,r=structuredClone(fn);n?.setDiagnosticsOptions({validate:!0,allowComments:!1,schemas:[{uri:`vertesia://schemas/content-type-intake-policy.json`,fileMatch:[`*`],schema:r}]})},N=()=>{let e=L3(D===`json`?h.current?.getValue()??b:b,g);if(!e.ok){E(e.message);return}return E(void 0),e.policy},P=()=>{let e=N();if(!e)return;let t=s??(r?e=>d.types.update(r.id,{intake:e,...r.edit_revision===void 0?{}:{expected_edit_revision:r.edit_revision}}).then(e=>(r.edit_revision=e.edit_revision,e.intake)):void 0);t&&(v(!0),t(e).then(t=>{let n=F3(t??e);x(n),C(n),c?.(t??e),p({status:`success`,title:f(`intakePolicy.toast.updated`),description:f(`intakePolicy.toast.saved`),duration:2e3})}).catch(e=>{p({status:`error`,title:f(`intakePolicy.toast.updateFailed`),description:Ge(e),duration:5e3})}).finally(()=>{v(!1)}))},F=()=>{let e=L3(D===`json`?h.current?.getValue()??b:b,g);E(e.ok?void 0:e.message),p({status:e.ok?`success`:`error`,title:e.ok?f(`intakePolicy.toast.valid`):f(`intakePolicy.toast.invalid`),description:e.ok?f(`intakePolicy.toast.schemaValid`):e.message,duration:3e3})},I=()=>{x(S),h.current?.setValue(S),E(void 0)},L=()=>{let e=N();if(!e)return;let t=F3(e);x(t),h.current?.setValue(t)},ee=e=>{let t=F3(e.value);x(t),h.current?.setValue(t),E(void 0),O(`classification`)},R=e=>{x(F3(e)),E(void 0)},te=e=>{if(l?.some(t=>t.name===e)){O(e);return}let t=e;if(t!==`json`&&!A){E(f(`intakePolicy.error.fixJsonBeforeForm`)),O(`json`);return}O(t)},ne=n(`div`,{className:`flex items-center gap-2`,children:[t(`div`,{children:f(`intakePolicy.title`)}),k&&t(i,{variant:`attention`,children:f(`intakePolicy.status.unsaved`)})]}),re=u?void 0:n(e,{children:[t(w,{align:`right`,trigger:n(o,{variant:`outline`,size:`md`,children:[t(Ib,{className:`size-4`}),f(`intakePolicy.action.examples`)]}),children:t(ie,{label:f(`intakePolicy.action.insertExample`),children:E3.map(e=>n(ae,{onClick:()=>ee(e),children:[t(Gg,{className:`size-4`}),n(`div`,{className:`flex flex-col`,children:[t(`span`,{children:f(`intakePolicy.example.${e.key}.label`)}),t(`span`,{className:`text-xs text-muted`,children:f(`intakePolicy.example.${e.key}.description`)})]})]},e.key))})}),D===`json`&&n(e,{children:[n(o,{variant:`outline`,size:`md`,onClick:L,children:[t(Im,{className:`size-4`}),f(`intakePolicy.action.format`)]}),n(o,{variant:`outline`,size:`md`,onClick:F,children:[t(Ih,{className:`size-4`}),f(`intakePolicy.action.validate`)]})]}),n(o,{variant:`outline`,size:`md`,onClick:I,disabled:!k,children:[t(vy,{className:`size-4`}),f(`intakePolicy.action.revert`)]}),t(o,{isLoading:_,size:`md`,onClick:P,disabled:!k,children:f(`intakePolicy.action.save`)})]}),oe=k3(f,A??D3,u,R,b,{editorRef:h,beforeMount:M,onChange:e=>{x(e),E(void 0)},theme:m},e=>t(me,{title:ne,className:`bg-background! h-full`,action:re,children:n(`div`,{className:`flex h-full min-h-0 flex-col gap-3`,children:[T&&t(`div`,{className:`rounded-sm border border-destructive bg-mixer-destructive/10 px-3 py-2 text-sm whitespace-pre-line text-destructive`,children:T}),e]})}));return n(`div`,{className:`flex h-full min-h-0 w-full flex-col gap-3`,children:[t(A3,{policy:j}),n(ze,{tabs:l?[...l,...oe]:oe,current:D,onTabChange:te,updateHash:!1,fullHeight:!0,className:`px-0 min-h-0 flex-1 flex-row!`,children:[t(Be,{className:`py-2 w-48 shrink-0`,direction:`vertical`}),t(Ve,{className:`min-h-0 min-w-0 flex-1 overflow-auto ps-4`})]})]})}function k3(e,r,i,a,o,s,c){let l=(e,n)=>({name:e,label:n,content:c(t(m3,{policy:r,section:e,onChange:a,readonly:i}))});return[l(`classification`,e(`intakePolicy.tab.classification`)),l(`conversion`,e(`intakePolicy.tab.conversion`)),l(`extraction`,e(`intakePolicy.tab.extraction`)),l(`grounding`,e(`intakePolicy.tab.grounding`)),l(`output`,e(`intakePolicy.tab.output`)),{name:`json`,label:e(`intakePolicy.tab.json`),content:c(n(`div`,{className:`flex h-full min-h-[36rem] gap-4 py-3`,children:[t(`div`,{className:`min-w-0 flex-1 overflow-hidden rounded-sm border`,children:t(Pt,{value:o,language:`json`,editorRef:s.editorRef,beforeMount:s.beforeMount,onChange:e=>s.onChange(e.state.doc.toString()),theme:s.theme===`dark`?`vs-dark`:`vs`,options:{readOnly:i,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:`on`,lineNumbers:`on`,automaticLayout:!0,formatOnPaste:!0,formatOnType:!0,tabSize:2}})}),t(j3,{})]}))}]}function A3({policy:e}){let{t:r}=K(),a=e.extraction?.grounding,o=[[r(`intakePolicy.summary.mode`),P3(r,e.mode)],[r(`intakePolicy.summary.conversion`),N3(r,e.text_conversion?.enabled)],[r(`intakePolicy.summary.method`),P3(r,e.text_conversion?.method)],[r(`intakePolicy.summary.source`),P3(r,e.extraction?.source)],[r(`intakePolicy.summary.extraction`),N3(r,e.extraction?.enabled)],[r(`intakePolicy.summary.grounding`),N3(r,a?.enabled)],[r(`intakePolicy.summary.defaultView`),P3(r,e.default_view)],[r(`intakePolicy.summary.toc`),N3(r,e.generate_toc)],[r(`intakePolicy.summary.template`),e.rendering_template?r(`intakePolicy.option.set`):r(`intakePolicy.option.inherit`)]];return t(`div`,{className:`flex flex-wrap gap-2`,children:o.map(([e,r])=>n(i,{variant:`outline`,className:`gap-1`,children:[n(`span`,{className:`text-muted`,children:[e,`:`]}),t(`span`,{children:r})]},e))})}function j3(){let{t:e}=K();return n(`aside`,{className:`hidden w-80 shrink-0 overflow-y-auto rounded-sm border bg-mixer-muted/20 p-3 text-sm lg:block`,children:[t(`div`,{className:`mb-3 font-semibold`,children:e(`intakePolicy.help.title`)}),n(`div`,{className:`space-y-3 text-muted`,children:[t(M3,{label:`identification`,text:e(`intakePolicy.help.identification`)}),t(M3,{label:`text_conversion`,text:e(`intakePolicy.help.textConversion`)}),t(M3,{label:`extraction.source`,text:e(`intakePolicy.help.extractionSource`)}),t(M3,{label:`extraction.grounding`,text:e(`intakePolicy.help.grounding`)}),t(M3,{label:`extraction.grounding.review`,text:e(`intakePolicy.help.review`)}),t(M3,{label:`rendering_template`,text:e(`intakePolicy.help.renderingTemplate`)}),t(M3,{label:`embeddings`,text:e(`intakePolicy.help.embeddings`)}),t(M3,{label:`default_view`,text:e(`intakePolicy.help.defaultView`)})]})]})}function M3({label:e,text:r}){return n(`div`,{children:[t(`div`,{className:`font-medium text-foreground`,children:e}),t(`div`,{children:r})]})}function N3(e,t){return e(t===!0?`intakePolicy.option.enabled`:t===!1?`intakePolicy.option.disabled`:`intakePolicy.option.inherit`)}function P3(e,t){return e(t?`intakePolicy.option.${t}`:`intakePolicy.option.inherit`)}function F3(e){return JSON.stringify(e??D3,null,2)}function I3(){let e=new er({strict:!1,allErrors:!0});return or(e),e.compile(fn)}function L3(e,t){let n;try{n=e.trim()?JSON.parse(e):{}}catch(e){return{ok:!1,message:`Invalid JSON: ${Ge(e)}`}}return t(n)?{ok:!0,policy:n}:{ok:!1,message:R3(t.errors)}}function R3(e){return e?.length?e.map(e=>`${e.instancePath||`/`} ${e.message??`is invalid`}`).join(`
1398
- `):`The intake policy does not match the schema.`}function z3({objectType:e,onSchemaUpdate:r,readonly:i=!1}){let{store:a}=q(),{t:s}=K(),c=nt(),{theme:l}=tt(),[u,d]=G(!1),f=Jt(e.object_schema),p=W(void 0),[m,h]=G(!1),g=U(()=>B3(f.schema),[f]),_=()=>{m&&!y()||(d(!0),a.types.update(e.id,{object_schema:f.schema,...e.edit_revision===void 0?{}:{expected_edit_revision:e.edit_revision}}).then(t=>{e.edit_revision=t.edit_revision,r(f),c({status:`success`,title:s(`store.schemaUpdated`),description:s(`store.schemaUpdatedSuccess`),duration:2e3})}).catch(e=>{c({status:`error`,title:s(`store.failedToUpdateSchema`),description:e.message,duration:5e3})}).finally(()=>{d(!1)}))},v=()=>{m&&!y()||h(e=>!e)},y=()=>{if(p.current){let e=p.current.getValue();try{let t=V3(e);H3(t),f.replaceSchema(t)}catch(e){return c({status:`error`,title:s(`store.invalidJsonSchema`),description:Ge(e),duration:5e3}),!1}}return!0},b=n(`div`,{className:`flex gap-2 items-center`,children:[t(`div`,{className:`text-base font-semibold`,children:s(`store.schemaEditor`)}),!i&&t(`div`,{children:t(o,{variant:`outline`,size:`sm`,onClick:v,children:s(m?`store.editSchema`:`store.editJson`)})})]});return t(me,{title:b,className:`bg-background! h-full`,action:i?void 0:t(o,{isLoading:u,variant:`outline`,size:`sm`,onClick:_,children:s(`modal.saveChanges`)}),children:m?t(Pt,{value:g,language:`json`,editorRef:p,theme:l===`dark`?`vs-dark`:`vs`,options:{readOnly:i}}):t(It,{schema:f,readonly:i})})}function B3(e){return e?JSON.stringify(e,null,2):``}function V3(e){if(e?.trim())return JSON.parse(e.trim())}const H3=e=>{try{new tr({strict:!1}).compile(e)}catch(e){throw Error(`Invalid JSON Schema definition: ${Ge(e)}`,{cause:e})}};Q();function U3({isOpen:e,onClose:r,title:i,children:a,initialSelectedType:s=null,allowNone:c=!0}){let{t:l}=K(),u=i??l(`store.selectContentType`),{registry:d}=tQ(),[f,p]=G(s),m=d?.types||[],h=()=>{r(void 0)};return n(se,{isOpen:e,onClose:h,className:`w-full max-w-xl mx-auto`,children:[t(ue,{children:u}),n(ce,{children:[a,n(`div`,{className:`mb-4 mt-4`,children:[n(`div`,{className:`block text-sm font-medium mb-2`,children:[l(`store.contentType`),` `,c&&t(`span`,{className:`text-muted font-normal`,children:l(`store.optional`)})]}),c?t(we,{options:m,value:f,optionLabel:e=>e?e.name:l(`store.selectContentTypeLabel`),placeholder:l(`store.selectContentTypeAuto`),onChange:e=>p(e||null),filterBy:`name`,isClearable:!0}):t(we,{options:m,value:f,optionLabel:e=>e?e.name:l(`store.selectContentTypeLabel`),placeholder:l(`store.selectContentTypeLabel`),onChange:e=>p(e||null),filterBy:`name`})]}),!f&&n(`div`,{className:`flex items-center text-attention`,children:[t(Nh,{className:`size-4 me-1`}),l(`store.automaticTypeDetection`),t(We,{description:l(`store.automaticTypeDetectionDescription`),placement:`top`,size:`xs`,children:t(A_,{className:`size-3 ms-2`})})]})]}),n(le,{children:[t(o,{variant:`ghost`,onClick:h,title:l(`modal.cancel`),children:l(`modal.cancel`)}),t(o,{onClick:()=>{r(f?.id??null),p(null)},title:l(`store.confirmSelection`),children:l(`modal.confirm`)})]})]})}function W3({children:e,limit:n,name:r,chunkable:i}){let{store:a}=q(),o=U(()=>{let e=new e3(a,n);return e.query.name=r,e.query.chunkable=i,e},[i,n,r,a]);return t(t3.Provider,{value:o,children:e})}function G3({objectType:e,onLayoutUpdate:n,readonly:r=!1}){let i=nt(),{theme:a}=tt(),{t:s}=K(),[c,l]=G(!1),{store:u}=q(),d=W(void 0),f=U(()=>K3(e.table_layout),[e.table_layout]),p=(e,t)=>{i({status:`error`,title:e,description:t,duration:5e3})};return t(me,{title:`Table Layout Editor`,className:`bg-background! h-full`,action:r?void 0:t(o,{isLoading:c,variant:`outline`,size:`sm`,onClick:()=>{if(!d.current)return;let t=d.current.getValue(),r;if(!t)r=null;else try{r=JSON.parse(t)}catch(e){return p(`Invalid JSON`,Ge(e))}if(!Array.isArray(r))return p(`Invalid JSON`,`The table layout must be an array`);if(r.some(e=>!e?.name||!e.field))return p(`Invalid JSON`,`A table layout entry must contain the following properties:] {field, name, converter?}`);l(!0),u.types.update(e.id,{...e.edit_revision===void 0?{}:{expected_edit_revision:e.edit_revision},table_layout:r}).then(t=>{e.edit_revision=t.edit_revision,i({status:`success`,title:s(`store.tableLayoutUpdated`),description:s(`store.tableLayoutUpdatedDesc`),duration:2e3}),n(t.table_layout)}).catch(e=>{i({status:`error`,title:s(`store.failedToUpdateTableLayout`),description:e.message,duration:5e3})}).finally(()=>{l(!1)})},children:s(`store.saveChanges`)}),children:t(`div`,{className:`h-full`,children:t(Pt,{value:f,language:`json`,editorRef:d,theme:a===`dark`?`vs-dark`:`vs`,options:{readOnly:r}})})})}function K3(e){return e?JSON.stringify(e,null,2):`[
1397
+ - Due: {{properties.due_date}}`,embeddings:{text:!0,image:!1,properties:!0},generate_toc:!1,default_view:`auto`}}],O3={};function k3({objectType:r,value:a,onSave:s,onIntakeUpdate:c,leadingTabs:l,readonly:u=!1}){let{store:d}=q(),{t:f}=K(),p=nt(),{theme:m}=tt(),h=W(void 0),g=U(()=>L3(),[]),[_,v]=G(!1),y=r?.intake??a,[b,x]=G(()=>I3(y)),[S,C]=G(()=>I3(y)),[T,E]=G(void 0),[D,O]=G(l?.[0]?.name??`classification`),k=b!==S,A=U(()=>{let e=R3(b,g);return e.ok?e.policy:void 0},[b,g]),j=A??y??O3,M=e=>{let t=e,n=t.languages?.json?.jsonDefaults??t.json?.jsonDefaults,r=structuredClone(fn);n?.setDiagnosticsOptions({validate:!0,allowComments:!1,schemas:[{uri:`vertesia://schemas/content-type-intake-policy.json`,fileMatch:[`*`],schema:r}]})},N=()=>{let e=R3(D===`json`?h.current?.getValue()??b:b,g);if(!e.ok){E(e.message);return}return E(void 0),e.policy},P=()=>{let e=N();if(!e)return;let t=s??(r?e=>d.types.update(r.id,{intake:e,...r.edit_revision===void 0?{}:{expected_edit_revision:r.edit_revision}}).then(e=>(r.edit_revision=e.edit_revision,e.intake)):void 0);t&&(v(!0),t(e).then(t=>{let n=I3(t??e);x(n),C(n),c?.(t??e),p({status:`success`,title:f(`intakePolicy.toast.updated`),description:f(`intakePolicy.toast.saved`),duration:2e3})}).catch(e=>{p({status:`error`,title:f(`intakePolicy.toast.updateFailed`),description:Ge(e),duration:5e3})}).finally(()=>{v(!1)}))},F=()=>{let e=R3(D===`json`?h.current?.getValue()??b:b,g);E(e.ok?void 0:e.message),p({status:e.ok?`success`:`error`,title:e.ok?f(`intakePolicy.toast.valid`):f(`intakePolicy.toast.invalid`),description:e.ok?f(`intakePolicy.toast.schemaValid`):e.message,duration:3e3})},I=()=>{x(S),h.current?.setValue(S),E(void 0)},L=()=>{let e=N();if(!e)return;let t=I3(e);x(t),h.current?.setValue(t)},ee=e=>{let t=I3(e.value);x(t),h.current?.setValue(t),E(void 0),O(`classification`)},R=e=>{x(I3(e)),E(void 0)},te=e=>{if(l?.some(t=>t.name===e)){O(e);return}let t=e;if(t!==`json`&&!A){E(f(`intakePolicy.error.fixJsonBeforeForm`)),O(`json`);return}O(t)},ne=n(`div`,{className:`flex items-center gap-2`,children:[t(`div`,{children:f(`intakePolicy.title`)}),k&&t(i,{variant:`attention`,children:f(`intakePolicy.status.unsaved`)})]}),re=u?void 0:n(e,{children:[t(w,{align:`right`,trigger:n(o,{variant:`outline`,size:`md`,children:[t(Ib,{className:`size-4`}),f(`intakePolicy.action.examples`)]}),children:t(ie,{label:f(`intakePolicy.action.insertExample`),children:D3.map(e=>n(ae,{onClick:()=>ee(e),children:[t(Gg,{className:`size-4`}),n(`div`,{className:`flex flex-col`,children:[t(`span`,{children:f(`intakePolicy.example.${e.key}.label`)}),t(`span`,{className:`text-xs text-muted`,children:f(`intakePolicy.example.${e.key}.description`)})]})]},e.key))})}),D===`json`&&n(e,{children:[n(o,{variant:`outline`,size:`md`,onClick:L,children:[t(Im,{className:`size-4`}),f(`intakePolicy.action.format`)]}),n(o,{variant:`outline`,size:`md`,onClick:F,children:[t(Ih,{className:`size-4`}),f(`intakePolicy.action.validate`)]})]}),n(o,{variant:`outline`,size:`md`,onClick:I,disabled:!k,children:[t(vy,{className:`size-4`}),f(`intakePolicy.action.revert`)]}),t(o,{isLoading:_,size:`md`,onClick:P,disabled:!k,children:f(`intakePolicy.action.save`)})]}),oe=A3(f,A??O3,u,R,b,{editorRef:h,beforeMount:M,onChange:e=>{x(e),E(void 0)},theme:m},e=>t(me,{title:ne,className:`bg-background! h-full`,action:re,children:n(`div`,{className:`flex h-full min-h-0 flex-col gap-3`,children:[T&&t(`div`,{className:`rounded-sm border border-destructive bg-mixer-destructive/10 px-3 py-2 text-sm whitespace-pre-line text-destructive`,children:T}),e]})}));return n(`div`,{className:`flex h-full min-h-0 w-full flex-col gap-3`,children:[t(j3,{policy:j}),n(ze,{tabs:l?[...l,...oe]:oe,current:D,onTabChange:te,updateHash:!1,fullHeight:!0,className:`px-0 min-h-0 flex-1 flex-row!`,children:[t(Be,{className:`py-2 w-48 shrink-0`,direction:`vertical`}),t(Ve,{className:`min-h-0 min-w-0 flex-1 overflow-auto ps-4`})]})]})}function A3(e,r,i,a,o,s,c){let l=(e,n)=>({name:e,label:n,content:c(t(h3,{policy:r,section:e,onChange:a,readonly:i}))});return[l(`classification`,e(`intakePolicy.tab.classification`)),l(`conversion`,e(`intakePolicy.tab.conversion`)),l(`extraction`,e(`intakePolicy.tab.extraction`)),l(`grounding`,e(`intakePolicy.tab.grounding`)),l(`output`,e(`intakePolicy.tab.output`)),{name:`json`,label:e(`intakePolicy.tab.json`),content:c(n(`div`,{className:`flex h-full min-h-[36rem] gap-4 py-3`,children:[t(`div`,{className:`min-w-0 flex-1 overflow-hidden rounded-sm border`,children:t(Pt,{value:o,language:`json`,editorRef:s.editorRef,beforeMount:s.beforeMount,onChange:e=>s.onChange(e.state.doc.toString()),theme:s.theme===`dark`?`vs-dark`:`vs`,options:{readOnly:i,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:`on`,lineNumbers:`on`,automaticLayout:!0,formatOnPaste:!0,formatOnType:!0,tabSize:2}})}),t(M3,{})]}))}]}function j3({policy:e}){let{t:r}=K(),a=e.extraction?.grounding,o=[[r(`intakePolicy.summary.mode`),F3(r,e.mode)],[r(`intakePolicy.summary.conversion`),P3(r,e.text_conversion?.enabled)],[r(`intakePolicy.summary.method`),F3(r,e.text_conversion?.method)],[r(`intakePolicy.summary.source`),F3(r,e.extraction?.source)],[r(`intakePolicy.summary.extraction`),P3(r,e.extraction?.enabled)],[r(`intakePolicy.summary.grounding`),P3(r,a?.enabled)],[r(`intakePolicy.summary.defaultView`),F3(r,e.default_view)],[r(`intakePolicy.summary.toc`),P3(r,e.generate_toc)],[r(`intakePolicy.summary.template`),e.rendering_template?r(`intakePolicy.option.set`):r(`intakePolicy.option.inherit`)]];return t(`div`,{className:`flex flex-wrap gap-2`,children:o.map(([e,r])=>n(i,{variant:`outline`,className:`gap-1`,children:[n(`span`,{className:`text-muted`,children:[e,`:`]}),t(`span`,{children:r})]},e))})}function M3(){let{t:e}=K();return n(`aside`,{className:`hidden w-80 shrink-0 overflow-y-auto rounded-sm border bg-mixer-muted/20 p-3 text-sm lg:block`,children:[t(`div`,{className:`mb-3 font-semibold`,children:e(`intakePolicy.help.title`)}),n(`div`,{className:`space-y-3 text-muted`,children:[t(N3,{label:`identification`,text:e(`intakePolicy.help.identification`)}),t(N3,{label:`text_conversion`,text:e(`intakePolicy.help.textConversion`)}),t(N3,{label:`extraction.source`,text:e(`intakePolicy.help.extractionSource`)}),t(N3,{label:`extraction.grounding`,text:e(`intakePolicy.help.grounding`)}),t(N3,{label:`extraction.grounding.review`,text:e(`intakePolicy.help.review`)}),t(N3,{label:`rendering_template`,text:e(`intakePolicy.help.renderingTemplate`)}),t(N3,{label:`embeddings`,text:e(`intakePolicy.help.embeddings`)}),t(N3,{label:`default_view`,text:e(`intakePolicy.help.defaultView`)})]})]})}function N3({label:e,text:r}){return n(`div`,{children:[t(`div`,{className:`font-medium text-foreground`,children:e}),t(`div`,{children:r})]})}function P3(e,t){return e(t===!0?`intakePolicy.option.enabled`:t===!1?`intakePolicy.option.disabled`:`intakePolicy.option.inherit`)}function F3(e,t){return e(t?`intakePolicy.option.${t}`:`intakePolicy.option.inherit`)}function I3(e){return JSON.stringify(e??O3,null,2)}function L3(){let e=new er({strict:!1,allErrors:!0});return or(e),e.compile(fn)}function R3(e,t){let n;try{n=e.trim()?JSON.parse(e):{}}catch(e){return{ok:!1,message:`Invalid JSON: ${Ge(e)}`}}return t(n)?{ok:!0,policy:n}:{ok:!1,message:z3(t.errors)}}function z3(e){return e?.length?e.map(e=>`${e.instancePath||`/`} ${e.message??`is invalid`}`).join(`
1398
+ `):`The intake policy does not match the schema.`}function B3({objectType:e,onSchemaUpdate:r,readonly:i=!1}){let{store:a}=q(),{t:s}=K(),c=nt(),{theme:l}=tt(),[u,d]=G(!1),f=Jt(e.object_schema),p=W(void 0),[m,h]=G(!1),g=U(()=>V3(f.schema),[f]),_=()=>{m&&!y()||(d(!0),a.types.update(e.id,{object_schema:f.schema,...e.edit_revision===void 0?{}:{expected_edit_revision:e.edit_revision}}).then(t=>{e.edit_revision=t.edit_revision,r(f),c({status:`success`,title:s(`store.schemaUpdated`),description:s(`store.schemaUpdatedSuccess`),duration:2e3})}).catch(e=>{c({status:`error`,title:s(`store.failedToUpdateSchema`),description:e.message,duration:5e3})}).finally(()=>{d(!1)}))},v=()=>{m&&!y()||h(e=>!e)},y=()=>{if(p.current){let e=p.current.getValue();try{let t=H3(e);U3(t),f.replaceSchema(t)}catch(e){return c({status:`error`,title:s(`store.invalidJsonSchema`),description:Ge(e),duration:5e3}),!1}}return!0},b=n(`div`,{className:`flex gap-2 items-center`,children:[t(`div`,{className:`text-base font-semibold`,children:s(`store.schemaEditor`)}),!i&&t(`div`,{children:t(o,{variant:`outline`,size:`sm`,onClick:v,children:s(m?`store.editSchema`:`store.editJson`)})})]});return t(me,{title:b,className:`bg-background! h-full`,action:i?void 0:t(o,{isLoading:u,variant:`outline`,size:`sm`,onClick:_,children:s(`modal.saveChanges`)}),children:m?t(Pt,{value:g,language:`json`,editorRef:p,theme:l===`dark`?`vs-dark`:`vs`,options:{readOnly:i}}):t(It,{schema:f,readonly:i})})}function V3(e){return e?JSON.stringify(e,null,2):``}function H3(e){if(e?.trim())return JSON.parse(e.trim())}const U3=e=>{try{new tr({strict:!1}).compile(e)}catch(e){throw Error(`Invalid JSON Schema definition: ${Ge(e)}`,{cause:e})}};Q();function W3({isOpen:e,onClose:r,title:i,children:a,initialSelectedType:s=null,allowNone:c=!0}){let{t:l}=K(),u=i??l(`store.selectContentType`),{registry:d}=nQ(),[f,p]=G(s),m=d?.types||[],h=()=>{r(void 0)};return n(se,{isOpen:e,onClose:h,className:`w-full max-w-xl mx-auto`,children:[t(ue,{children:u}),n(ce,{children:[a,n(`div`,{className:`mb-4 mt-4`,children:[n(`div`,{className:`block text-sm font-medium mb-2`,children:[l(`store.contentType`),` `,c&&t(`span`,{className:`text-muted font-normal`,children:l(`store.optional`)})]}),c?t(we,{options:m,value:f,optionLabel:e=>e?e.name:l(`store.selectContentTypeLabel`),placeholder:l(`store.selectContentTypeAuto`),onChange:e=>p(e||null),filterBy:`name`,isClearable:!0}):t(we,{options:m,value:f,optionLabel:e=>e?e.name:l(`store.selectContentTypeLabel`),placeholder:l(`store.selectContentTypeLabel`),onChange:e=>p(e||null),filterBy:`name`})]}),!f&&n(`div`,{className:`flex items-center text-attention`,children:[t(Nh,{className:`size-4 me-1`}),l(`store.automaticTypeDetection`),t(We,{description:l(`store.automaticTypeDetectionDescription`),placement:`top`,size:`xs`,children:t(A_,{className:`size-3 ms-2`})})]})]}),n(le,{children:[t(o,{variant:`ghost`,onClick:h,title:l(`modal.cancel`),children:l(`modal.cancel`)}),t(o,{onClick:()=>{r(f?.id??null),p(null)},title:l(`store.confirmSelection`),children:l(`modal.confirm`)})]})]})}function G3({children:e,limit:n,name:r,chunkable:i}){let{store:a}=q(),o=U(()=>{let e=new t3(a,n);return e.query.name=r,e.query.chunkable=i,e},[i,n,r,a]);return t(n3.Provider,{value:o,children:e})}function K3({objectType:e,onLayoutUpdate:n,readonly:r=!1}){let i=nt(),{theme:a}=tt(),{t:s}=K(),[c,l]=G(!1),{store:u}=q(),d=W(void 0),f=U(()=>q3(e.table_layout),[e.table_layout]),p=(e,t)=>{i({status:`error`,title:e,description:t,duration:5e3})};return t(me,{title:`Table Layout Editor`,className:`bg-background! h-full`,action:r?void 0:t(o,{isLoading:c,variant:`outline`,size:`sm`,onClick:()=>{if(!d.current)return;let t=d.current.getValue(),r;if(!t)r=null;else try{r=JSON.parse(t)}catch(e){return p(`Invalid JSON`,Ge(e))}if(!Array.isArray(r))return p(`Invalid JSON`,`The table layout must be an array`);if(r.some(e=>!e?.name||!e.field))return p(`Invalid JSON`,`A table layout entry must contain the following properties:] {field, name, converter?}`);l(!0),u.types.update(e.id,{...e.edit_revision===void 0?{}:{expected_edit_revision:e.edit_revision},table_layout:r}).then(t=>{e.edit_revision=t.edit_revision,i({status:`success`,title:s(`store.tableLayoutUpdated`),description:s(`store.tableLayoutUpdatedDesc`),duration:2e3}),n(t.table_layout)}).catch(e=>{i({status:`error`,title:s(`store.failedToUpdateTableLayout`),description:e.message,duration:5e3})}).finally(()=>{l(!1)})},children:s(`store.saveChanges`)}),children:t(`div`,{className:`h-full`,children:t(Pt,{value:f,language:`json`,editorRef:d,theme:a===`dark`?`vs-dark`:`vs`,options:{readOnly:r}})})})}function q3(e){return e?JSON.stringify(e,null,2):`[
1399
1399
 
1400
- ]`}function q3({collection:e}){let{client:n}=q(),{t:r}=K(),[i,a]=G(void 0),[s,c]=G(e.shared_properties||[]),l=nt();H(()=>{e.type?.id&&n.store.types.retrieve(e.type.id).then(a)},[n.store.types.retrieve,e.type?.id]);let u=i?Object.keys(i.object_schema?.properties||{}):[];return t(me,{title:r(`store.sharedProperties`),description:r(`store.sharedPropertiesDescription`),action:t(o,{size:`lg`,isLoading:!1,onClick:()=>{n.store.collections.update(e.id,{shared_properties:s}).then(()=>{l({title:r(`store.updatedSharedProperties`),status:`success`})}).catch(e=>{l({title:r(`store.failedToUpdateSharedProperties`),description:e.message,status:`error`})})},children:r(`modal.save`)}),children:t(`div`,{className:``,children:t(He,{value:s,onChange:e=>{c(e)},options:u,placeholder:r(`store.selectPropertiesToShare`)})})})}function J3({collection:e}){let{client:n}=q(),{t:r}=K(),[i,a]=G(e.skip_head_sync??!1),[o,s]=G(!1),c=nt();return t(me,{title:r(`store.syncMemberHeads`),description:r(`store.syncMemberHeadsDescription`),children:t(Ne,{disabled:o,value:!i,onChange:t=>{let i=!t;s(!0),n.store.collections.update(e.id,{skip_head_sync:i}).then(()=>{c({title:r(`store.updatedSkipHeadSync`),status:`success`}),a(i)}).catch(e=>{c({title:r(`store.failedToUpdateSkipHeadSync`),description:e.message,status:`error`})}).finally(()=>{s(!1)})},children:r(`store.enableSyncMemberHeads`)})})}function Y3(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function X3({refetch:r,collection:a}){let{t:s}=K(),c=a.type?En(a.type):void 0,l=W(void 0),u=nt(),{theme:d}=tt(),{client:f}=q(),p=_t(L$),[m,h]=G(!1),[g,_]=G({name:a.name,description:a.description||``,query:a.query?JSON.stringify(a.query,null,2):``,tags:a.tags||[],type:a.type?En(a.type):``,allowed_types:a.allowed_types||[],sensitivity:a.sensitivity,compartments:a.compartments||[]}),[v,y]=G(``),b=U(()=>K3(a.table_layout),[a.table_layout]),x=()=>{let e;try{let t=g.query?JSON.parse(g.query):void 0;if(t!==void 0&&!Y3(t))throw Error(s(`store.invalidQueryJson`));e=t}catch(e){u({title:s(`store.invalidQueryJson`),description:Ge(e),status:`error`,duration:5e3});return}let t={name:g.name,description:g.description,query:e,tags:g.tags,type:g.type,allowed_types:g.allowed_types,sensitivity:g.sensitivity,compartments:g.compartments},n;if(t.name||(n=s(`type.nameRequired`)),t.type||=null,n){u({title:s(`store.validationFailed`),description:n,status:`error`,duration:5e3});return}if(l.current){let e=l.current.getValue();if(e)try{t.table_layout=JSON.parse(e)}catch(e){u({title:s(`store.invalidTableLayout`),description:Ge(e),status:`error`,duration:5e3});return}else t.table_layout=null}h(!0),f.store.collections.update(a.id,t).then(()=>{r(),a.dynamic&&p&&(p.reset(),p.search()),u({title:s(`store.collectionUpdated`),description:s(`store.collectionUpdatedSuccess`),status:`success`,duration:3e3})}).catch(e=>{u({title:s(`store.failedToUpdateCollection`),description:Ge(e),status:`error`,duration:5e3})}).finally(()=>{h(!1)})},S=(e,t)=>{_({...g,[e]:t})};return n(`div`,{className:`flex flex-col gap-4 py-2`,children:[n(me,{title:s(`store.configuration`),action:t(o,{size:`lg`,isDisabled:m,onClick:x,children:s(`modal.save`)}),children:[n(`div`,{className:`flex justify-between mb-2`,children:[n(`div`,{className:`w-1/2 gap-2 flex flex-col`,children:[t(`div`,{className:`text-sm font-medium mb-1`,children:s(`store.createdBy`)}),n(`div`,{className:`gap-2 flex items-center`,children:[t(BZ,{userRef:a.created_by,showTitle:!0}),n(`span`,{children:[`at `,WD(a.created_at).format(`YYYY-MM-DD HH:mm:ss`)]})]})]}),n(`div`,{className:`w-1/2 gap-2 flex flex-col`,children:[t(`div`,{className:`text-sm font-medium mb-1`,children:s(`store.updatedBy`)}),n(`div`,{className:`gap-2 flex items-center`,children:[t(BZ,{userRef:a.updated_by,showTitle:!0}),n(`span`,{children:[`at `,WD(a.updated_at).format(`YYYY-MM-DD HH:mm:ss`)]})]})]})]}),t(L,{label:s(`type.name`),required:!0,children:t(te,{value:g.name,onChange:e=>S(`name`,e)})}),t(L,{label:s(`type.description`),children:t(Ue,{value:g.description,onChange:e=>S(`description`,e.target.value)})}),!a.dynamic&&t(L,{label:s(`store.allowedContentTypes`),description:s(`store.allowedContentTypesSelectDescription`),children:t(K4,{defaultValue:g.allowed_types||null,onChange:e=>{Array.isArray(e)?S(`allowed_types`,e.map(e=>e.id)):S(`allowed_types`,e?[e.id]:[])},isClearable:!0,multiple:!0})}),a.dynamic&&t(L,{label:s(`store.query`),description:s(`store.queryDescription`),children:t(Ue,{className:Me.INPUT,minLines:1,maxLines:12,value:g.query,onChange:e=>S(`query`,e.target.value)})}),t(L,{label:s(`store.tableLayout`),description:s(`store.tableLayoutDescription`),className:`h-[200px]`,children:t(Pt,{className:`border-1 rounded-md border-border`,value:b,language:`json`,editorRef:l,theme:d===`dark`?`vs-dark`:`vs`})}),t(L,{label:s(`store.contentType`),description:s(`store.typeSelectDescription`),children:t(K4,{defaultValue:g.type||null,onChange:e=>{Array.isArray(e)?S(`type`,e.length>0?e[0].id:null):S(`type`,e?.id||null)},isClearable:!0})}),t(L,{label:`Sensitivity`,description:`BLP sensitivity level — propagated to member documents (max across collections)`,children:t(we,{options:Sn.map((e,t)=>({label:`${t} — ${e}`,value:t})),value:g.sensitivity===void 0?void 0:{label:`${g.sensitivity} — ${Sn[g.sensitivity]??`Unknown`}`,value:g.sensitivity},onChange:e=>S(`sensitivity`,e.value),optionLabel:e=>e.label,by:`value`,placeholder:`Not set`})}),n(L,{label:`Compartments`,description:`Security compartments — propagated to member documents (union across collections)`,children:[n(`div`,{className:`flex gap-2`,children:[t(te,{value:v,onChange:y,placeholder:`Add a compartment`,onKeyDown:e=>{if(e.key===`Enter`){e.preventDefault();let t=v.trim();t&&!g.compartments.includes(t)&&(S(`compartments`,[...g.compartments,t]),y(``))}}}),t(o,{type:`button`,variant:`outline`,onClick:()=>{let e=v.trim();e&&!g.compartments.includes(e)&&(S(`compartments`,[...g.compartments,e]),y(``))},children:`Add`})]}),t(`div`,{className:`flex gap-1 flex-wrap mt-2`,children:g.compartments.map(e=>n(i,{variant:`secondary`,className:`cursor-pointer`,onClick:()=>S(`compartments`,g.compartments.filter(t=>t!==e)),children:[e,` ×`]},e))})]})]}),c&&t(Z3,{typeId:c,collection:a}),!a.dynamic&&n(e,{children:[t(J3,{collection:a}),t(q3,{collection:a})]})]})}function Z3({typeId:e,collection:n}){let{t:r}=K(),[i,a]=G({}),s=nt(),{client:c}=q(),[l,u]=G(!1),{data:d,error:f}=Ye(()=>c.store.types.catalog.resolve(e),[e]),p=d?.object_schema||{},m=U(()=>new Mt(p,n.properties||{}),[p,n.properties]);if(f)return t(M,{title:r(`store.failedToLoadType`),children:Ge(f)});if(!d)return null;let h=e=>{if(!e||!Object.keys(e).length)return;let t={properties:e||{}};u(!0),c.store.collections.update(n.id,t).then(()=>{s({title:r(`store.collectionPropertiesUpdated`),description:r(`store.collectionUpdatedSuccess`),status:`success`,duration:3e3})}).catch(e=>{s({title:r(`store.failedToUpdateCollectionProperties`),description:Ge(e),status:`error`,duration:5e3})}).finally(()=>{u(!1)})};return t(me,{title:r(`store.properties`),action:t(o,{size:`lg`,isLoading:l,type:`submit`,onClick:()=>h(i),children:r(`modal.save`)}),children:t(kt,{object:m,onChange:e=>{e instanceof Mt&&a(e.value)}})})}Q();function Q3({onChange:e,value:r,disabled:i=!1,placeholder:a,searchPlaceholder:s,filterOut:c,allowDynamic:l=!0,multiple:u=!1}){let{client:d}=q(),{t:f}=K(),p=a??f(`store.selectACollection`),m=s??f(`store.searchCollections`),[b,x]=G(``),[S,C]=G(!1),[w,T]=G(!1),E=Je(b,300),D=V(async e=>{C(!0);let t=e.trim(),n=await d.store.collections.search({dynamic:l?void 0:!1,name:w&&t||void 0});return C(!1),!w&&n.length>=1e3&&T(!0),c&&c.length>0?n.filter(e=>!c.includes(e.id)):n},[d,l,c,w]),{data:O,error:k}=Ye(()=>D(w?E:``),[w?E:``,D]),A=U(()=>O?u&&Array.isArray(r)?O.filter(e=>r.includes(e.id)):!u&&typeof r==`string`?O.find(e=>e.id===r):u?[]:void 0:u?[]:void 0,[O,r,u]),j=V(t=>{if(u){let n=Array.isArray(r)?r:[];if(n.includes(t.id)){let r=n.filter(e=>e!==t.id);e(r,O?.filter(e=>r.includes(e.id))||[])}else{let r=[...n,t.id];e(r,O?.filter(e=>r.includes(e.id))||[])}}else e(t.id,t)},[e,r,O,u]),N=V(()=>{e(void 0,void 0)},[e]),P=V(e=>{x(e)},[]),F=b.trim().length>0,I=U(()=>{if(!O)return[];if(w||!F)return O;let e=b.toLowerCase();return O.filter(t=>t.name.toLowerCase().includes(e))},[O,w,F,b]),L=u?Array.isArray(A)&&A.length>0:!!A;return k?t(M,{title:f(`store.collectionFetchFailed`),children:Ge(k)}):n(he,{children:[t(_e,{asChild:!0,children:n(o,{variant:`outline`,role:`combobox`,"aria-haspopup":`listbox`,className:z(`w-full justify-between min-w-0`),disabled:i,children:[t(`span`,{className:`truncate flex-1 text-start min-w-0`,children:u&&Array.isArray(A)&&A.length>0?A.length===1?A[0].name:f(`store.collectionsSelected`,{count:A.length}):!u&&A&&!Array.isArray(A)?A.name:p}),L&&!i?t(o,{variant:`unstyled`,"aria-label":`Clear selection`,className:`ms-2 shrink-0 opacity-50 hover:opacity-100 hover:text-destructive cursor-pointer`,onClick:e=>{e.stopPropagation(),N()},children:t(Gb,{className:`h-4 w-4`})}):t(wh,{className:`ms-2 h-4 w-4 shrink-0 opacity-50`})]})}),t(ge,{className:`mt-2 mb-2 w-[var(--radix-popover-trigger-width)] p-0`,align:`start`,children:n(h,{shouldFilter:!1,children:[n(`div`,{className:`flex justify-between items-center border-b px-3`,"cmdk-input-wrapper":``,children:[t(v,{placeholder:m,value:b,onValueChange:P,className:`flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted disabled:cursor-not-allowed disabled:opacity-50`}),S&&t(`div`,{className:`me-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent`})]}),t(g,{children:f(S?`store.searching`:F?`store.noCollectionsFound`:`store.noCollectionsAvailable`)}),n(_,{className:`max-h-[300px] overflow-auto`,children:[L&&!F&&t(y,{value:`__clear__`,onSelect:N,className:`text-destructive`,children:`Remove collection selection(s)`}),F&&t(y,{value:`__clear_search__`,onSelect:()=>x(``),className:`text-muted`,children:f(`store.clearSelection`)}),I.map(e=>{let i=u&&Array.isArray(r)?r.includes(e.id):r===e.id;return n(y,{value:e.id,onSelect:()=>j(e),className:`flex items-center justify-between`,children:[t(`span`,{className:`truncate`,children:e.name}),i&&t(eh,{className:`ms-2 h-4 w-4 shrink-0`})]},e.id)})]})]})})]})}function $3({isOpen:e,onClose:r}){return n(se,{onClose:()=>r(),isOpen:!!e,className:`min-w-[60vw]`,children:[t(ue,{children:`Select Content`}),t(ce,{className:`pt-0 overflow-y-auto max-h-[80vh] min-h-[80vh]`,children:e&&t(a1,{onChange:r})})]})}Q();const e6=/store:([a-f0-9]+)/;function t6({object:e}){let{client:r}=q(),{off:i,on:a,isOn:s}=Ze(),[c,l]=G(e.value==null?``:String(e.value)),[u,d]=G(void 0),f=t=>{let n=t.target.value;l(n),e.value=n},p=V(()=>{l(``),e.value=``,d(void 0)},[e]);return H(()=>{if(!c||u)return;let e=c.match(e6);e&&r.objects.retrieve(e[1]).then(e=>{d(e)}).catch(()=>{p()})},[c,r.objects.retrieve,p,u]),n(`div`,{children:[n(`div`,{className:`relative`,children:[t(`input`,{value:c,onChange:f,className:it(Me.INPUT,`pe-10 w-full`)}),u&&t(`div`,{className:`absolute inset-y-0 end-10 flex items-center justify-center `,children:t(o,{onClick:p,variant:`unstyled`,className:`hover:text-destructive hover:bg-muted`,children:t(Gb,{className:`size-5`})})}),t(`div`,{className:`absolute inset-y-0 end-0 flex items-center justify-center`,children:t(o,{onClick:a,variant:`unstyled`,className:`hover:bg-muted`,children:t(wh,{className:`size-5`})})}),t($3,{value:c,isOpen:s,onClose:t=>{if(t){let n=`store:${t.id}`;l(n),d(t||void 0),e.value=n}i()}})]}),u&&t(`div`,{className:`p-1 semibold text-sm text-muted dark:text-foreground`,children:typeof u.properties?.title==`string`?u.properties.title:u.name})]})}Q();function n6({objectId:e,isOpen:r,onClose:i}){let a=Qn(),{client:s,store:c}=q(),[l,u]=G(null),[d,f]=G(!1),[p,m]=G(!1),[h,g]=G(),[_,v]=G(),[y,b]=G(`preview`),{t:x}=K(),S=nt(),C=V(async e=>{m(!0);try{let t=await c.objects.getObjectText(e);g(t.text)}catch(e){console.error(`Error loading text:`,e)}finally{m(!1)}},[c.objects]),w=V(async e=>{if(e.content?.source)try{(await s.objects.getRendition(e.id,{format:mn.jpeg,generate_if_missing:!1})).status===`found`&&console.log(`Found rendition`);let t=await s.files.getDownloadUrl(e.content.source);v(t.url)}catch(e){console.error(`Error loading image:`,e)}},[s.files,s.objects]);H(()=>{e&&r?(f(!0),c.objects.retrieve(e,`+embeddings`).then(e=>{u(e),e.text?g(e.text):C(e.id);let t=e.content;t?.source&&t.type?.startsWith(`image/`)&&w(e)}).catch(e=>{console.error(`Error loading object:`,e),S({title:x(`agent.error`),description:x(`store.failedToLoadDocument`),status:`error`,duration:3e3})}).finally(()=>{f(!1)})):(u(null),g(void 0),v(void 0))},[e,r,c.objects,C,w,x,S]);let T=()=>{l&&(a(`/legal/objects/${l.id}`),i())},E=h&&(h.startsWith(`#`)||h.includes(`
1400
+ ]`}function J3({collection:e}){let{client:n}=q(),{t:r}=K(),[i,a]=G(void 0),[s,c]=G(e.shared_properties||[]),l=nt();H(()=>{e.type?.id&&n.store.types.retrieve(e.type.id).then(a)},[n.store.types.retrieve,e.type?.id]);let u=i?Object.keys(i.object_schema?.properties||{}):[];return t(me,{title:r(`store.sharedProperties`),description:r(`store.sharedPropertiesDescription`),action:t(o,{size:`lg`,isLoading:!1,onClick:()=>{n.store.collections.update(e.id,{shared_properties:s}).then(()=>{l({title:r(`store.updatedSharedProperties`),status:`success`})}).catch(e=>{l({title:r(`store.failedToUpdateSharedProperties`),description:e.message,status:`error`})})},children:r(`modal.save`)}),children:t(`div`,{className:``,children:t(He,{value:s,onChange:e=>{c(e)},options:u,placeholder:r(`store.selectPropertiesToShare`)})})})}function Y3({collection:e}){let{client:n}=q(),{t:r}=K(),[i,a]=G(e.skip_head_sync??!1),[o,s]=G(!1),c=nt();return t(me,{title:r(`store.syncMemberHeads`),description:r(`store.syncMemberHeadsDescription`),children:t(Ne,{disabled:o,value:!i,onChange:t=>{let i=!t;s(!0),n.store.collections.update(e.id,{skip_head_sync:i}).then(()=>{c({title:r(`store.updatedSkipHeadSync`),status:`success`}),a(i)}).catch(e=>{c({title:r(`store.failedToUpdateSkipHeadSync`),description:e.message,status:`error`})}).finally(()=>{s(!1)})},children:r(`store.enableSyncMemberHeads`)})})}function X3(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z3({refetch:r,collection:a}){let{t:s}=K(),c=a.type?En(a.type):void 0,l=W(void 0),u=nt(),{theme:d}=tt(),{client:f}=q(),p=_t(R$),[m,h]=G(!1),[g,_]=G({name:a.name,description:a.description||``,query:a.query?JSON.stringify(a.query,null,2):``,tags:a.tags||[],type:a.type?En(a.type):``,allowed_types:a.allowed_types||[],sensitivity:a.sensitivity,compartments:a.compartments||[]}),[v,y]=G(``),b=U(()=>q3(a.table_layout),[a.table_layout]),x=()=>{let e;try{let t=g.query?JSON.parse(g.query):void 0;if(t!==void 0&&!X3(t))throw Error(s(`store.invalidQueryJson`));e=t}catch(e){u({title:s(`store.invalidQueryJson`),description:Ge(e),status:`error`,duration:5e3});return}let t={name:g.name,description:g.description,query:e,tags:g.tags,type:g.type,allowed_types:g.allowed_types,sensitivity:g.sensitivity,compartments:g.compartments},n;if(t.name||(n=s(`type.nameRequired`)),t.type||=null,n){u({title:s(`store.validationFailed`),description:n,status:`error`,duration:5e3});return}if(l.current){let e=l.current.getValue();if(e)try{t.table_layout=JSON.parse(e)}catch(e){u({title:s(`store.invalidTableLayout`),description:Ge(e),status:`error`,duration:5e3});return}else t.table_layout=null}h(!0),f.store.collections.update(a.id,t).then(()=>{r(),a.dynamic&&p&&(p.reset(),p.search()),u({title:s(`store.collectionUpdated`),description:s(`store.collectionUpdatedSuccess`),status:`success`,duration:3e3})}).catch(e=>{u({title:s(`store.failedToUpdateCollection`),description:Ge(e),status:`error`,duration:5e3})}).finally(()=>{h(!1)})},S=(e,t)=>{_({...g,[e]:t})};return n(`div`,{className:`flex flex-col gap-4 py-2`,children:[n(me,{title:s(`store.configuration`),action:t(o,{size:`lg`,isDisabled:m,onClick:x,children:s(`modal.save`)}),children:[n(`div`,{className:`flex justify-between mb-2`,children:[n(`div`,{className:`w-1/2 gap-2 flex flex-col`,children:[t(`div`,{className:`text-sm font-medium mb-1`,children:s(`store.createdBy`)}),n(`div`,{className:`gap-2 flex items-center`,children:[t(VZ,{userRef:a.created_by,showTitle:!0}),n(`span`,{children:[`at `,WD(a.created_at).format(`YYYY-MM-DD HH:mm:ss`)]})]})]}),n(`div`,{className:`w-1/2 gap-2 flex flex-col`,children:[t(`div`,{className:`text-sm font-medium mb-1`,children:s(`store.updatedBy`)}),n(`div`,{className:`gap-2 flex items-center`,children:[t(VZ,{userRef:a.updated_by,showTitle:!0}),n(`span`,{children:[`at `,WD(a.updated_at).format(`YYYY-MM-DD HH:mm:ss`)]})]})]})]}),t(L,{label:s(`type.name`),required:!0,children:t(te,{value:g.name,onChange:e=>S(`name`,e)})}),t(L,{label:s(`type.description`),children:t(Ue,{value:g.description,onChange:e=>S(`description`,e.target.value)})}),!a.dynamic&&t(L,{label:s(`store.allowedContentTypes`),description:s(`store.allowedContentTypesSelectDescription`),children:t(q4,{defaultValue:g.allowed_types||null,onChange:e=>{Array.isArray(e)?S(`allowed_types`,e.map(e=>e.id)):S(`allowed_types`,e?[e.id]:[])},isClearable:!0,multiple:!0})}),a.dynamic&&t(L,{label:s(`store.query`),description:s(`store.queryDescription`),children:t(Ue,{className:Me.INPUT,minLines:1,maxLines:12,value:g.query,onChange:e=>S(`query`,e.target.value)})}),t(L,{label:s(`store.tableLayout`),description:s(`store.tableLayoutDescription`),className:`h-[200px]`,children:t(Pt,{className:`border-1 rounded-md border-border`,value:b,language:`json`,editorRef:l,theme:d===`dark`?`vs-dark`:`vs`})}),t(L,{label:s(`store.contentType`),description:s(`store.typeSelectDescription`),children:t(q4,{defaultValue:g.type||null,onChange:e=>{Array.isArray(e)?S(`type`,e.length>0?e[0].id:null):S(`type`,e?.id||null)},isClearable:!0})}),t(L,{label:`Sensitivity`,description:`BLP sensitivity level — propagated to member documents (max across collections)`,children:t(we,{options:Sn.map((e,t)=>({label:`${t} — ${e}`,value:t})),value:g.sensitivity===void 0?void 0:{label:`${g.sensitivity} — ${Sn[g.sensitivity]??`Unknown`}`,value:g.sensitivity},onChange:e=>S(`sensitivity`,e.value),optionLabel:e=>e.label,by:`value`,placeholder:`Not set`})}),n(L,{label:`Compartments`,description:`Security compartments — propagated to member documents (union across collections)`,children:[n(`div`,{className:`flex gap-2`,children:[t(te,{value:v,onChange:y,placeholder:`Add a compartment`,onKeyDown:e=>{if(e.key===`Enter`){e.preventDefault();let t=v.trim();t&&!g.compartments.includes(t)&&(S(`compartments`,[...g.compartments,t]),y(``))}}}),t(o,{type:`button`,variant:`outline`,onClick:()=>{let e=v.trim();e&&!g.compartments.includes(e)&&(S(`compartments`,[...g.compartments,e]),y(``))},children:`Add`})]}),t(`div`,{className:`flex gap-1 flex-wrap mt-2`,children:g.compartments.map(e=>n(i,{variant:`secondary`,className:`cursor-pointer`,onClick:()=>S(`compartments`,g.compartments.filter(t=>t!==e)),children:[e,` ×`]},e))})]})]}),c&&t(Q3,{typeId:c,collection:a}),!a.dynamic&&n(e,{children:[t(Y3,{collection:a}),t(J3,{collection:a})]})]})}function Q3({typeId:e,collection:n}){let{t:r}=K(),[i,a]=G({}),s=nt(),{client:c}=q(),[l,u]=G(!1),{data:d,error:f}=Ye(()=>c.store.types.catalog.resolve(e),[e]),p=d?.object_schema||{},m=U(()=>new Mt(p,n.properties||{}),[p,n.properties]);if(f)return t(M,{title:r(`store.failedToLoadType`),children:Ge(f)});if(!d)return null;let h=e=>{if(!e||!Object.keys(e).length)return;let t={properties:e||{}};u(!0),c.store.collections.update(n.id,t).then(()=>{s({title:r(`store.collectionPropertiesUpdated`),description:r(`store.collectionUpdatedSuccess`),status:`success`,duration:3e3})}).catch(e=>{s({title:r(`store.failedToUpdateCollectionProperties`),description:Ge(e),status:`error`,duration:5e3})}).finally(()=>{u(!1)})};return t(me,{title:r(`store.properties`),action:t(o,{size:`lg`,isLoading:l,type:`submit`,onClick:()=>h(i),children:r(`modal.save`)}),children:t(kt,{object:m,onChange:e=>{e instanceof Mt&&a(e.value)}})})}Q();function $3({onChange:e,value:r,disabled:i=!1,placeholder:a,searchPlaceholder:s,filterOut:c,allowDynamic:l=!0,multiple:u=!1}){let{client:d}=q(),{t:f}=K(),p=a??f(`store.selectACollection`),m=s??f(`store.searchCollections`),[b,x]=G(``),[S,C]=G(!1),[w,T]=G(!1),E=Je(b,300),D=V(async e=>{C(!0);let t=e.trim(),n=await d.store.collections.search({dynamic:l?void 0:!1,name:w&&t||void 0});return C(!1),!w&&n.length>=1e3&&T(!0),c&&c.length>0?n.filter(e=>!c.includes(e.id)):n},[d,l,c,w]),{data:O,error:k}=Ye(()=>D(w?E:``),[w?E:``,D]),A=U(()=>O?u&&Array.isArray(r)?O.filter(e=>r.includes(e.id)):!u&&typeof r==`string`?O.find(e=>e.id===r):u?[]:void 0:u?[]:void 0,[O,r,u]),j=V(t=>{if(u){let n=Array.isArray(r)?r:[];if(n.includes(t.id)){let r=n.filter(e=>e!==t.id);e(r,O?.filter(e=>r.includes(e.id))||[])}else{let r=[...n,t.id];e(r,O?.filter(e=>r.includes(e.id))||[])}}else e(t.id,t)},[e,r,O,u]),N=V(()=>{e(void 0,void 0)},[e]),P=V(e=>{x(e)},[]),F=b.trim().length>0,I=U(()=>{if(!O)return[];if(w||!F)return O;let e=b.toLowerCase();return O.filter(t=>t.name.toLowerCase().includes(e))},[O,w,F,b]),L=u?Array.isArray(A)&&A.length>0:!!A;return k?t(M,{title:f(`store.collectionFetchFailed`),children:Ge(k)}):n(he,{children:[t(_e,{asChild:!0,children:n(o,{variant:`outline`,role:`combobox`,"aria-haspopup":`listbox`,className:z(`w-full justify-between min-w-0`),disabled:i,children:[t(`span`,{className:`truncate flex-1 text-start min-w-0`,children:u&&Array.isArray(A)&&A.length>0?A.length===1?A[0].name:f(`store.collectionsSelected`,{count:A.length}):!u&&A&&!Array.isArray(A)?A.name:p}),L&&!i?t(o,{variant:`unstyled`,"aria-label":`Clear selection`,className:`ms-2 shrink-0 opacity-50 hover:opacity-100 hover:text-destructive cursor-pointer`,onClick:e=>{e.stopPropagation(),N()},children:t(Gb,{className:`h-4 w-4`})}):t(wh,{className:`ms-2 h-4 w-4 shrink-0 opacity-50`})]})}),t(ge,{className:`mt-2 mb-2 w-[var(--radix-popover-trigger-width)] p-0`,align:`start`,children:n(h,{shouldFilter:!1,children:[n(`div`,{className:`flex justify-between items-center border-b px-3`,"cmdk-input-wrapper":``,children:[t(v,{placeholder:m,value:b,onValueChange:P,className:`flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted disabled:cursor-not-allowed disabled:opacity-50`}),S&&t(`div`,{className:`me-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent`})]}),t(g,{children:f(S?`store.searching`:F?`store.noCollectionsFound`:`store.noCollectionsAvailable`)}),n(_,{className:`max-h-[300px] overflow-auto`,children:[L&&!F&&t(y,{value:`__clear__`,onSelect:N,className:`text-destructive`,children:`Remove collection selection(s)`}),F&&t(y,{value:`__clear_search__`,onSelect:()=>x(``),className:`text-muted`,children:f(`store.clearSelection`)}),I.map(e=>{let i=u&&Array.isArray(r)?r.includes(e.id):r===e.id;return n(y,{value:e.id,onSelect:()=>j(e),className:`flex items-center justify-between`,children:[t(`span`,{className:`truncate`,children:e.name}),i&&t(eh,{className:`ms-2 h-4 w-4 shrink-0`})]},e.id)})]})]})})]})}function e6({isOpen:e,onClose:r}){return n(se,{onClose:()=>r(),isOpen:!!e,className:`min-w-[60vw]`,children:[t(ue,{children:`Select Content`}),t(ce,{className:`pt-0 overflow-y-auto max-h-[80vh] min-h-[80vh]`,children:e&&t(o1,{onChange:r})})]})}Q();const t6=/store:([a-f0-9]+)/;function n6({object:e}){let{client:r}=q(),{off:i,on:a,isOn:s}=Ze(),[c,l]=G(e.value==null?``:String(e.value)),[u,d]=G(void 0),f=t=>{let n=t.target.value;l(n),e.value=n},p=V(()=>{l(``),e.value=``,d(void 0)},[e]);return H(()=>{if(!c||u)return;let e=c.match(t6);e&&r.objects.retrieve(e[1]).then(e=>{d(e)}).catch(()=>{p()})},[c,r.objects.retrieve,p,u]),n(`div`,{children:[n(`div`,{className:`relative`,children:[t(`input`,{value:c,onChange:f,className:it(Me.INPUT,`pe-10 w-full`)}),u&&t(`div`,{className:`absolute inset-y-0 end-10 flex items-center justify-center `,children:t(o,{onClick:p,variant:`unstyled`,className:`hover:text-destructive hover:bg-muted`,children:t(Gb,{className:`size-5`})})}),t(`div`,{className:`absolute inset-y-0 end-0 flex items-center justify-center`,children:t(o,{onClick:a,variant:`unstyled`,className:`hover:bg-muted`,children:t(wh,{className:`size-5`})})}),t(e6,{value:c,isOpen:s,onClose:t=>{if(t){let n=`store:${t.id}`;l(n),d(t||void 0),e.value=n}i()}})]}),u&&t(`div`,{className:`p-1 font-semibold text-sm text-muted dark:text-foreground`,children:typeof u.properties?.title==`string`?u.properties.title:u.name})]})}Q();function r6({objectId:e,isOpen:r,onClose:i}){let a=Qn(),{client:s,store:c}=q(),[l,u]=G(null),[d,f]=G(!1),[p,m]=G(!1),[h,g]=G(),[_,v]=G(),[y,b]=G(`preview`),{t:x}=K(),S=nt(),C=V(async e=>{m(!0);try{let t=await c.objects.getObjectText(e);g(t.text)}catch(e){console.error(`Error loading text:`,e)}finally{m(!1)}},[c.objects]),w=V(async e=>{if(e.content?.source)try{(await s.objects.getRendition(e.id,{format:mn.jpeg,generate_if_missing:!1})).status===`found`&&console.log(`Found rendition`);let t=await s.files.getDownloadUrl(e.content.source);v(t.url)}catch(e){console.error(`Error loading image:`,e)}},[s.files,s.objects]);H(()=>{e&&r?(f(!0),c.objects.retrieve(e,`+embeddings`).then(e=>{u(e),e.text?g(e.text):C(e.id);let t=e.content;t?.source&&t.type?.startsWith(`image/`)&&w(e)}).catch(e=>{console.error(`Error loading object:`,e),S({title:x(`agent.error`),description:x(`store.failedToLoadDocument`),status:`error`,duration:3e3})}).finally(()=>{f(!1)})):(u(null),g(void 0),v(void 0))},[e,r,c.objects,C,w,x,S]);let T=()=>{l&&(a(`/legal/objects/${l.id}`),i())},E=h&&(h.startsWith(`#`)||h.includes(`
1401
1401
  #`)||h.includes(`
1402
- *`)),D=l?.content?.type?.startsWith(`image/`),O=l?.content?.type===`application/pdf`;return r?n(`div`,{className:`fixed inset-y-0 end-0 w-2/5 dark:bg-muted shadow-xl z-50 flex flex-col transition-transform duration-300 transform ${r?`translate-x-0`:`translate-x-full rtl:-translate-x-full`}`,children:[n(`div`,{className:`flex items-center justify-between px-4 py-3 border-b dark:border-border bg-gradient-to-r from-indigo-50 to-gray-50 dark:from-gray-800 dark:to-gray-900`,children:[n(`div`,{className:`flex items-center`,children:[t(Gg,{className:`h-5 w-5 text-primary me-2`}),t(`h2`,{className:`text-lg font-semibold text-foreground truncate`,children:d?x(`store.loadingDocument`):l?.name||x(`store.documentPreview`)})]}),n(`div`,{className:`flex items-center gap-2`,children:[n(o,{variant:`ghost`,size:`sm`,onClick:T,className:`flex items-center gap-1 text-primary hover:text-primary`,children:[t(lv,{className:`h-4 w-4`}),t(`span`,{children:x(`store.fullView`)})]}),t(o,{variant:`ghost`,size:`sm`,onClick:i,className:`flex items-center text-muted hover:text-foreground dark:text-foreground`,children:t(Gb,{className:`h-5 w-5`})})]})]}),d?t(`div`,{className:`flex-1 flex items-center justify-center`,children:n(`div`,{className:`text-center`,children:[t(je,{size:`lg`,className:`text-primary mb-2`}),t(`p`,{className:`text-muted`,children:x(`store.loadingDocument`)})]})}):n(`div`,{className:`flex-1 flex flex-col h-full`,children:[t(`div`,{className:`border-b`,children:n(`div`,{className:`flex px-4`,children:[t(o,{variant:`unstyled`,className:`py-2 px-4 font-medium border-b-2 ${y===`preview`?`border-primary text-primary`:`border-transparent text-muted hover:text-foreground`}`,onClick:()=>b(`preview`),children:n(`div`,{className:`flex items-center gap-1`,children:[t(I_,{className:`h-4 w-4`}),t(`span`,{children:x(`store.preview`)})]})}),t(o,{variant:`unstyled`,className:`py-2 px-4 font-medium border-b-2 ${y===`properties`?`border-primary text-primary`:`border-transparent text-muted hover:text-foreground`}`,onClick:()=>b(`properties`),children:n(`div`,{className:`flex items-center gap-1`,children:[t(A_,{className:`h-4 w-4`}),t(`span`,{children:x(`store.properties`)})]})})]})}),n(`div`,{className:`flex-1 overflow-auto p-4`,children:[y===`preview`&&n(`div`,{className:`h-full`,children:[p?t(`div`,{className:`flex items-center justify-center h-40`,children:t(je,{size:`md`,className:`text-primary`})}):h?t(`div`,{className:`shadow rounded-md p-4 border border-border bg-white dark:bg-muted`,children:E?t(`div`,{className:`prose prose-sm max-w-none prose-p:my-2 prose-pre:bg-muted prose-pre:my-2 prose-headings:text-primary dark:prose-invert`,children:t(Nt,{children:h})}):t(`pre`,{className:`text-wrap whitespace-pre-wrap dark:text-foreground`,children:h})}):null,D&&t(`div`,{className:`mt-4`,children:_?t(`div`,{className:`border border-border rounded-md p-2 bg-white dark:bg-muted`,children:t(`img`,{src:_,alt:l?.name,className:`mx-auto max-h-[70vh] object-contain`})}):t(`div`,{className:`flex items-center justify-center h-40`,children:t(je,{size:`md`,className:`text-primary`})})}),O&&n(`div`,{className:`flex flex-col items-center justify-center h-64 border border-border rounded-md p-4 bg-muted`,children:[t(Gg,{className:`h-16 w-16 text-primary mb-4`}),t(`p`,{className:`text-muted text-center mb-4`,children:x(`store.pdfPreviewFullView`)}),t(o,{onClick:T,className:`bg-primary hover:bg-primary text-white`,children:x(`store.openFullDocumentView`)})]}),!D&&!h&&!O&&!p&&n(`div`,{className:`flex flex-col items-center justify-center h-64 border border-border rounded-md p-4 bg-muted`,children:[t(Gg,{className:`h-16 w-16 text-foreground dark:text-muted mb-4`}),t(`p`,{className:`text-muted text-center`,children:x(`store.noPreviewAvailable`)})]})]}),y===`properties`&&l&&n(`div`,{className:`h-full`,children:[l.properties?t(`div`,{className:`shadow rounded-md p-4 border border-border bg-white dark:bg-muted`,children:t(jt,{value:l.properties})}):n(`div`,{className:`flex flex-col items-center justify-center h-64 border border-border rounded-md p-4 bg-muted`,children:[t(A_,{className:`h-16 w-16 text-foreground dark:text-muted mb-4`}),t(`p`,{className:`text-muted text-center`,children:x(`store.noPropertiesAvailable`)})]}),n(`div`,{className:`mt-4`,children:[t(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:x(`store.documentInformation`)}),t(`div`,{className:`shadow rounded-md p-4 border border-border bg-white dark:bg-muted`,children:n(`div`,{className:`grid grid-cols-2 gap-y-2 gap-x-4 text-sm`,children:[t(`div`,{className:`text-muted`,children:x(`store.id`)}),t(`div`,{className:`font-medium dark:text-foreground`,children:l.id}),t(`div`,{className:`text-muted`,children:x(`store.contentType`)}),t(`div`,{className:`font-medium dark:text-foreground`,children:l.type?.name||x(`store.unknown`)}),t(`div`,{className:`text-muted`,children:x(`store.contentType`)}),t(`div`,{className:`font-medium dark:text-foreground`,children:l.content?.type||x(`store.na`)}),t(`div`,{className:`text-muted`,children:x(`store.size`)}),t(`div`,{className:`font-medium`,children:l.content&&`size`in l.content?r6(l.content.size):x(`store.unknown`)}),t(`div`,{className:`text-muted`,children:x(`store.created`)}),t(`div`,{className:`font-medium`,children:l.created_at?new Date(l.created_at).toLocaleString():x(`store.na`)}),t(`div`,{className:`text-muted`,children:x(`store.updated`)}),t(`div`,{className:`font-medium`,children:l.updated_at?new Date(l.updated_at).toLocaleString():x(`store.na`)})]})})]})]})]})]}),n(`div`,{className:`flex items-center justify-between p-4 border-t bg-muted dark:border-border`,children:[t(`div`,{children:l?.content?.source&&n(o,{onClick:()=>{l?.content?.source&&s.files.getDownloadUrl(l.content.source).then(e=>{window.open(e.url,`_blank`)}).catch(e=>{console.error(`Error getting download URL:`,e),S({title:x(`agent.error`),description:x(`store.failedToDownloadFile`),status:`error`,duration:3e3})})},variant:`outline`,className:`text-primary border-primary hover:bg-info`,children:[t(xg,{className:`h-4 w-4 me-2`}),x(`pdf.download`)]})}),n(o,{onClick:T,className:`bg-primary hover:bg-primary text-white`,children:[x(`store.openFullDocument`),t(lh,{className:`h-4 w-4 ms-2 cn-rtl-flip`})]})]})]}):null}function r6(e){if(e===0)return`0 Bytes`;let t=1024,n=[`Bytes`,`KB`,`MB`,`GB`,`TB`],r=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/t**r).toFixed(2))} ${n[r]}`}var i6;(function(e){e.CSV=`CSV`,e.JSON=`JSON`})(i6||={});function a6({isExporting:e,isOpen:r,onClose:i,allowExportAll:a=!0}){return n(se,{onClose:()=>i(void 0),isOpen:r,children:[t(ue,{children:`Export Object Properties`}),n(ce,{children:[!e&&t(o6,{onClose:i,allowExportAll:a}),e&&t(s6,{})]})]})}function o6({onClose:e,allowExportAll:r}){let{t:i}=K(),[a,s]=G(void 0),c=[`Export selected objects`,`Export all objects`],[l,u]=G(r?void 0:c[0]),d=e=>e===c[1];return n(ce,{className:`min-h-[104px] pt-0 flex flex-col gap-y-4`,children:[r&&t(`div`,{className:`h-1/3`,children:t(we,{options:c,value:l,onChange:u,placeholder:i(`store.chooseWhatToExport`),className:`h-full w-full text-sm`,filterBy:`name`,isClearable:!0})}),n(`div`,{className:`h-1/2 flex flex-col gap-y-8 content-between`,children:[t(we,{options:Object.values(i6),value:a,onChange:s,placeholder:i(`store.chooseAFormat`),className:`h-full w-full text-sm`,filterBy:`name`,isClearable:!0}),t(o,{className:`w-full`,isDisabled:!a||!l,onClick:()=>{e(a,d(l))},children:i(`store.actions.exportProperties`)})]})]})}function s6(){let{t:e}=K();return t(ce,{className:`min-h-[84px] pt-0`,children:n(`div`,{className:`h-full grid flex-col gap-y-2 content-between justify-items-center`,children:[n(`div`,{className:`text-sm flex flex-col gap-x-2`,children:[t(`p`,{children:e(`store.exportInProgress`)}),t(`p`,{className:`pt-2 grid justify-items-center`,children:e(`store.pleaseWait`)})]}),t(je,{size:`lg`})]})})}const c6=dt(void 0);function l6(){let e=_t(c6);if(!e)throw Error(`You cannot use useActionContext outside an ActionProvider`);return e}function u6(e,t){let n=l6();return H(()=>n.registerCallback(e,t),[n,e,t]),n}function d6({action:e,objectIds:n}){let[r,i]=G(!1),a=V(()=>(n.length>0&&i(!0),Promise.resolve(!0)),[n]);return u6(e.id,a),r&&t(ve,{children:t(m6,{objectIds:n,isOpen:r,onClose:()=>{i(!1)}})})}const f6=Xt.getFixedT(null,Yt),p6={id:`addToCollection`,name:f6(`store.actions.addToCollection`),description:f6(`store.actions.addToCollectionDesc`),confirm:!1,component:d6};function m6({isOpen:e,onClose:r,objectIds:i}){let{t:a}=K();return n(se,{isOpen:e,onClose:r,className:`max-w-lg w-full min-w-0 overflow-hidden`,children:[t(ue,{className:`flex flex-col min-w-0 overflow-hidden`,children:a(`store.actions.addToCollectionTitle`)}),t(S,{className:`min-w-0 overflow-hidden`,children:a(`store.actions.addToCollectionBody`)}),t(`div`,{className:`min-w-0 max-w-full overflow-hidden`,children:t(h6,{onClose:r,objectIds:i})})]})}function h6({onClose:e,objectIds:r}){let{t:i}=K(),a=nt(),{client:s}=q(),[c,l]=G(),u=({collectionId:t})=>{!t||!r?.length||s.store.collections.addMembers(t,r).then(()=>{a({title:i(`store.actions.addToCollectionSuccess`),status:`success`,description:i(`store.actions.addToCollectionSuccessDesc`,{count:r.length}),duration:3e3}),e()}).catch(()=>{a({title:i(`store.actions.addToCollectionFailure`),status:`error`,description:i(`store.actions.addToCollectionFailureDesc`),duration:5e3})})},d=[{name:`select`,label:i(`store.actions.selectCollection`),content:n(`div`,{className:`p-4 min-w-0 max-w-full overflow-hidden`,children:[t(ee,{level:5,children:i(`store.actions.chooseExistingCollections`)}),t(ce,{className:`min-w-0 max-w-full overflow-hidden`,children:t(`div`,{className:`mb-4 min-w-0 max-w-full overflow-hidden`,children:t(Q3,{onChange:(e,t)=>{typeof e==`string`||e===void 0?l(e):Array.isArray(e)&&e.length>0?l(e[0]):l(void 0)},value:c})})}),t(le,{children:t(o,{isDisabled:!c,onClick:()=>c&&u({collectionId:c}),children:i(`store.actions.addToCollectionButton`)})})]})},{name:`create`,label:i(`store.actions.createNew`),content:t(`div`,{className:`p-4`,children:t(q4,{onClose:e,onAddToCollection:e=>u({collectionId:e}),redirect:!1})})}];return n(ze,{defaultValue:`select`,tabs:d,fullWidth:!0,children:[t(Be,{}),t(Ve,{})]})}function g6({action:e,objectIds:r,children:i}){let{t:a}=K(),{store:o}=q(),s=nt(),[c,l]=G(!1),u=V(()=>(l(!0),Promise.resolve(!0)),[]);return u6(e.id,u),n(`div`,{children:[i,t(U3,{isOpen:c,onClose:e=>{l(!1),e!==void 0&&o.runOperation({name:`change_type`,ids:r,params:{typeId:e}}).then(e=>{s({status:`success`,title:a(`store.actions.changeType`),description:`Change the type of ${r.length} objects is ${e.status===`in_progress`?`in progress`:`completed`}`,duration:2e3})}).catch(e=>{s({status:`error`,title:a(`store.actions.errorChangingType`),description:e.message,duration:5e3})})},title:`Change Content Type`,confirmLabel:`Change Type`,children:n(`p`,{className:`pt-2 text-xs`,children:[`Note: This action will raise the `,t(`code`,{children:`change_type`}),` event and will trigger the standard intake workflows which may reset the object properties.`]})})]})}const _6=Xt.getFixedT(null,Yt),v6={id:`changeType`,name:_6(`store.actions.changeContentType`),description:_6(`store.actions.changeContentTypeDesc`),confirm:!1,component:g6};function y6({action:r,callback:i,children:a}){let{t:o}=K(),[s,c]=G(!1),l=r.confirmationText||`Are you sure you want to ${r.name}?`,u=V(e=>r.confirm?(c(!0),Promise.resolve(!0)):i(e),[r.confirm,i]),d=u6(r.id,u);return n(e,{children:[a,t(b,{onConfirm:()=>{c(!1),i({...d.params,action:r})},onCancel:()=>c(!1),title:o(`store.actions.areYouSure`),content:l,isOpen:s})]})}function b6({action:r,objectIds:i,children:a}){let{t:o}=K(),s=l6(),c=nt(),{client:l}=q(),u=R$(),d=Qn(),[f,p]=G(!1),m=i?.length??0,h=s.params?.type?.name??`object`,g=V(()=>(p(!0),Promise.resolve(!0)),[]);u6(r.id,g);let _=V(()=>(p(!1),i?.length?l.store.objects.delete(i).then(e=>{let t=e.deleted>1?`s`:``;if(c({status:`success`,title:`${e.deleted} object${t} deleted`,duration:2e3}),e.failed.length>0&&c({status:`warning`,title:`${e.failed.length} object(s) could not be deleted`,duration:3e3}),u){s.params?.selection?.removeAll();let t=JSON.parse(JSON.stringify(u.facets));i.length===t._value.total&&u.resetFacets();let n=new Set(e.failed);u.removeDeletedObjects(i.filter(e=>!n.has(e))),u.search()}else d(`/objects`)}).catch(e=>{c({status:`error`,title:o(`store.actions.errorDeletingObjects`),description:e.message,duration:5e3})}):(c({status:`error`,title:o(`store.actions.noObjectsSelected`),description:o(`store.actions.pleaseSelectObjectsToDelete`),duration:3e3}),Promise.resolve(!1))),[l.store.objects.delete,s.params?.selection?.removeAll,d,i,u,u?.facets,u?.resetFacets,u?.search,o,c]);return n(e,{children:[a,t(b,{isOpen:f,title:m===1?`Delete ${h}`:`Delete ${h}s`,content:n(`div`,{children:[n(`p`,{children:[`Delete `,m,` selected `,h,m===1?``:`s`,`? `,m===1?`This ${h}`:`These ${h}s`,` will be permanently removed.`]}),t(`p`,{children:t(`span`,{className:`text-destructive`,children:`This action cannot be undone.`})})]}),onConfirm:_,onCancel:()=>p(!1),confirmationValue:`delete`,confirmationLabel:`Type "delete" to confirm`,confirmationPlaceholder:`delete`})]})}const x6=Xt.getFixedT(null,Yt),S6={id:`delete`,name:x6(`store.actions.delete`),description:x6(`store.actions.deleteTheSelectedObjects`),confirm:!0,confirmationText:x6(`store.actions.confirmDeleteAll`),component:b6,destructive:!0},C6={id:`deleteFromCollections`,name:x6(`store.actions.deleteObjects`),description:x6(`store.actions.deleteTheSelectedObjects`),confirm:!0,confirmationText:x6(`store.actions.confirmDeleteSelected`),component:b6,destructive:!0};function w6({action:e,objectIds:n}){let{t:r}=K(),{store:i}=q(),a=nt(),[o,s]=G(!1),[c,l]=G(!1),u=V(()=>(s(!0),Promise.resolve(!0)),[]),d=u6(e.id,u);return t(a6,{isExporting:c,isOpen:o,onClose:(e,t)=>{if(e&&(t||n.length>0)){l(!0);let o=d.params?.search?.query||{},c=d.params?.search?.result?.value?.objects?.map(e=>e.id)||void 0,u=async e=>i.objects.list({query:{parent:e}}).then(e=>e.map(e=>e.id)),f=async()=>t?c?o.vector?c:[]:n.length===0?[]:(await u(n[0])).concat(n):n,p=d.params?.type?.id??o.type,m=d.params?.type?.table_layout??void 0;f().then(c=>{i.objects.exportProperties({objectIds:c,type:e,query:t&&!o.vector?{...o,type:p}:{type:p},table_layout:m}).then(e=>{let i=new Blob([e.data],{type:e.type}),o=window.URL.createObjectURL(i),s=document.createElement(`a`);s.download=e.name,s.href=o,s.click(),a({status:`success`,title:r(`store.actions.exportProperties`),description:t?`Export the properties of all objects completed`:`Export the properties of ${n.length} object${n.length>1?`s`:``} is completed`,duration:2e3})}).catch(e=>{a({status:`error`,title:r(`store.actions.errorExportProperties`),description:e.message,duration:5e3})}).finally(()=>{l(!1),s(!1)})})}else s(!1),a({status:`error`,title:r(`store.actions.errorExportProperties`),description:`No objects selected for export`,duration:5e3})}})}const T6=Xt.getFixedT(null,Yt),E6={id:`exportProperties`,name:T6(`store.actions.exportProperties`),description:T6(`store.actions.exportAllObjectProperties`),confirm:!1,component:w6};function D6({action:e,objectIds:n,collectionId:r}){let{t:i}=K(),a=l6(),o=nt(),{client:s}=q(),c=R$(),l=V(()=>n?.length?r?s.store.collections.deleteMembers(r,n).then(()=>{let e=n.length>1?`s`:``;o({status:`success`,title:`${n.length} object${e} removed from collection`,description:`Objects have been removed from the collection`,duration:2e3}),c&&(a.params?.selection?.removeAll(),c.search())}).catch(e=>{o({status:`error`,title:i(`store.actions.errorRemovingObjects`),description:Ge(e),duration:5e3})}):(o({status:`error`,title:i(`store.actions.noCollectionContext`),description:i(`store.actions.cannotRemoveNoCollection`),duration:3e3}),Promise.resolve(!1)):(o({status:`error`,title:i(`store.actions.noObjectsSelected`),description:i(`store.actions.pleaseSelectObjectsToRemove`),duration:3e3}),Promise.resolve(!1)),[s.store.collections.deleteMembers,r,a.params?.selection?.removeAll,n,c,c?.search,i,o]);return t(y6,{action:e,callback:l})}const O6=Xt.getFixedT(null,Yt),k6={id:`removeFromCollection`,name:O6(`store.actions.removeFromCollection`),description:O6(`store.actions.removeFromCollectionDesc`),confirm:!0,confirmationText:O6(`store.actions.confirmRemoveFromCollection`),component:D6,destructive:!0};var A6=class{params;allActions=[];callbacks={};constructor(e){this.params=e}get actions(){return this.params.selection?.collectionId?this.allActions.filter(e=>e.id!==`addToCollection`&&e.id!==`delete`):this.allActions.filter(e=>e.id!==`removeFromCollection`&&e.id!==`deleteFromCollections`)}registerCallback(e,t){return this.callbacks[e]=t,()=>{delete this.callbacks[e]}}unregisterCallback(e){delete this.callbacks[e]}findAction(e){return this.allActions.find(t=>t.id===e)}async run(e){let t=this.findAction(e);if(!t)throw Error(`Action ${e} not found`);let n={...this.params,action:t},r=this.callbacks[e];if(r)return r(n);throw Error(`No action callback set`)}};const j6=[E6,v6,p6,S6,k6,C6];function M6({children:e,type:r}){let i=XQ(),a=nt(),{client:o}=q(),s=R$(),c=U(()=>{let e=new A6({selection:i,toast:a,client:o,search:s,type:r});return e.allActions=j6,e},[o,s,i,a,r]);return c&&n(c6.Provider,{value:c,children:[t(N6,{}),e]})}function N6(){let e=l6(),n=e.params.selection,r=n.getObjectId(),i=n.isSingleSelection()&&r?[r]:n.getObjectIds();return t(`div`,{style:{display:`none`},children:e.allActions.map(e=>t(e.component,{action:e,objectIds:i,collectionId:n.collectionId},e.id))})}function P6(){let{t:r}=K(),i=XQ(),[a,s]=G(!1);return i?.hasSelection()?n(e,{children:[t(o,{onClick:()=>s(!0),children:r(`store.actions.startWorkflow`)}),a&&t(F6,{objectIds:i.getObjectIds(),onClose:()=>s(!1)})]}):null}function F6({objectIds:e,onClose:r}){let{t:i}=K(),{client:a}=q(),s=nt(),[c,l]=G(void 0),[u,d]=G(!1),{data:f,isLoading:p}=Ye(()=>a.store.workflows.rules.list(),[]);return n(se,{isOpen:!0,onClose:r,size:`lg`,children:[t(ue,{children:i(`store.actions.startWorkflowByRule`)}),n(ce,{children:[t(`div`,{className:`pb-2`,children:i(`store.actions.chooseWorkflowRule`)}),p?t(`div`,{className:`flex justify-center py-4`,children:t(je,{})}):t(`div`,{className:`max-h-[420px] overflow-y-auto border-border border rounded-md`,children:t(Te,{className:`text-start w-full`,options:f??[],value:c,onChange:l,optionLayout:e=>({label:e.name})})})]}),n(le,{align:`right`,children:[t(o,{variant:`outline`,onClick:r,disabled:u,children:`Cancel`}),t(o,{onClick:async()=>{if(!(!c||u)){d(!0);try{await a.store.workflows.rules.execute(c.id,e),s({title:i(`store.actions.workflowStarted`),status:`success`,duration:3e3}),r()}catch(e){s({title:i(`store.actions.errorStartingWorkflow`),description:e instanceof Error?e.message:void 0,status:`error`,duration:9e3})}finally{d(!1)}}},isDisabled:!c||u,isLoading:u,children:`Start`})]})]})}Q();function I6({type:e,allowMutations:r=!0,allowDelete:i=!0,allowWorkflowRun:a=!1}){let s=XQ(),c=s.size(),l=c>1?`s`:``,u=s?.hasSelection(),d=s?.isSingleSelection();return t(M6,{type:e,children:n(`div`,{className:`flex items-center gap-x-2`,children:[u&&!d&&n(`div`,{className:`flex items-center gap-x-1 shrink-0`,children:[n(`div`,{className:`text-sm nowrap`,children:[c,` document`,l,` selected`]}),t(o,{title:`Clear selection`,variant:`ghost`,onClick:()=>{s?.removeAll()},children:t(Gb,{className:`size-4`})})]}),a&&t(P6,{}),t(z6,{selection:s,allowMutations:r,allowDelete:i,children:e=>e.length>0?t(o,{variant:`ghost`,title:`More action`,size:`sm`,children:t(wg,{size:16})}):null})]})})}function L6({collectionId:r,allowFolders:i=!0}){let{t:a}=K(),[s,c]=G([]),[l,u]=G(!1);return n(e,{children:[t(o,{onClick:()=>u(!0),children:a(`store.upload`)}),t(q$,{collectionId:r??``,isOpen:l,onClose:()=>{u(!1),c([])},files:s,title:`Upload Files`,onUploadComplete:e=>{e?.success&&c([])},allowFolders:i})]})}function R6(e){return{label:e.name,className:it(`flex-1 px-2 py-2 hover:bg-muted nowrap`,e.destructive?`text-destructive`:``)}}function z6({selection:e,children:r,allowMutations:i=!0,allowDelete:a=!0}){let o=l6(),s=e=>{o.run(e.id)},c=V6(o.actions,e,{allowMutations:i,allowDelete:a}),l=r(c);return l?n(he,{hover:!0,children:[t(_e,{children:l}),t(ge,{className:`p-0 w-50`,align:`end`,sideOffset:6,children:t(B6,{executeAction:s,actions:c})})]}):null}function B6({executeAction:e,actions:n}){return t(`div`,{className:`rounded-md shadow-md py-2`,children:t(`div`,{className:`px-1 text-sm`,children:t(Te,{options:n,optionLayout:R6,onChange:t=>{e(t)},noCheck:!0})})})}function V6(e,t,n){return t?.hasSelection()?e.filter(e=>e.hideInList?!1:e.id===`delete`||e.id===`deleteFromCollections`?n.allowDelete:e.id===`changeType`||e.id===`addToCollection`||e.id===`removeFromCollection`?n.allowMutations:!0):[E6]}function H6({user:e}){return n(`div`,{className:`flex items-center`,children:[t(`div`,{className:`w-9 h-9`,children:(()=>{if(e.picture)return t(`img`,{className:`inline-block h-9 w-9 rounded-full`,src:e.picture,alt:e.name});{let n=e.name.split(` `).map(e=>e[0]).join(``);return t(`span`,{className:`inline-flex h-8 w-8 items-center justify-center rounded-full bg-primary`,children:t(`span`,{className:`text-sm font-medium leading-none text-white`,children:n})})}})()}),n(`div`,{className:`ms-3`,children:[t(`p`,{className:`text-sm font-medium text-foreground group-hover:text-foreground`,children:e.name??`Deleted User`}),t(`p`,{className:`text-xs font-medium text-muted dark:text-foreground group-hover:text-foreground`,children:e.email??`Deleted User`})]})]})}Q();const U6=dt(void 0);function W6(){return _t(U6)}function G6(e,t){let n=e.requires_selection??(e.placement===`toolbar`?`none`:`any`);return n===`none`?!0:n===`single`?t.length===1:n===`multiple`?t.length>1:t.length>0}function K6(e){let t=window.URL.createObjectURL(new Blob([e.data],{type:e.type})),n=document.createElement(`a`);n.download=e.name,n.href=t,n.click(),window.setTimeout(()=>window.URL.revokeObjectURL(t),0)}function q6({children:e,definition:r,request:i,result:a,selection:o,contributions:s,client:c,canDelete:l,refresh:u}){let{t:d}=K(),f=nt(),[p,m]=G(),[h,g]=G(),[_,v]=G(!1),[y,x]=G(),S=W(!1),C=r.results?.actions,w=U(()=>({definition:r,request:i,result:a,refresh:u,clearSelection:()=>o?.clear()}),[r,u,i,a,o]),T=U(()=>{let e=(C?.items??[]).filter(e=>{let t=s?.actions?.[e.handler];return t!==void 0&&(t.isAvailable?.(w)??!0)});if(!o||C?.include_defaults===!1||!c)return e;let t=new Set(C?.exclude_defaults??[]),n=[];return t.has(`export`)||n.push({id:`export`,label:d(`store.actions.exportProperties`),handler:`export`,placement:`selection`,requires_selection:`any`}),l&&!t.has(`delete`)&&n.push({id:`delete`,label:d(`store.actions.delete`),handler:`delete`,placement:`selection`,requires_selection:`any`,destructive:!0,confirm:!0}),[...n,...e]},[C,w,l,c,s?.actions,o,d]),E=V(async({action:e,hits:t})=>{if(!S.current){S.current=!0,x(e.id);try{if(e.handler===`delete`){if(!c)return;let e=await c.store.objects.delete(t.map(e=>e.id));f({status:e.failed.length>0?`warning`:`success`,title:d(`view.deletedObjects`,{count:e.deleted})}),o?.clear(),await u();return}let n=s?.actions?.[e.handler];if(!n)return;await n.run({...w,action:e,hits:t})}catch(e){console.error(`View action failed:`,e),f({status:`error`,title:d(`view.actionFailed`),description:d(`view.actionFailedDescription`)})}finally{S.current=!1,x(void 0),m(void 0)}}},[w,c,s?.actions,u,o,d,f]),D=V((e,t)=>{if(!(!G6(e,t)||S.current)){if(e.handler===`export`){g(t);return}if(e.confirm){m({action:e,hits:t});return}E({action:e,hits:t})}},[E]),O=V(e=>{if(!e||!h?.length||!c){g(void 0);return}v(!0),c.store.objects.exportProperties({objectIds:h.map(e=>e.id),type:e}).then(e=>{K6(e),f({status:`success`,title:d(`store.actions.exportProperties`)}),g(void 0)}).catch(e=>{console.error(`View export failed:`,e),f({status:`error`,title:d(`store.actions.errorExportProperties`),description:d(`view.actionFailedDescription`)})}).finally(()=>v(!1))},[c,h,d,f]),k=U(()=>({actions:T,runningActionId:y,run:D}),[T,D,y]);return n(U6.Provider,{value:k,children:[e,t(a6,{isOpen:h!==void 0,isExporting:_,onClose:O,allowExportAll:!1}),t(b,{isOpen:p!==void 0,title:p?.action.label??d(`modal.confirm`),content:d(`view.confirmAction`,{action:p?.action.label??``,count:p?.hits.length??0}),isLoading:y!==void 0,onConfirm:()=>{p&&E(p)},onCancel:()=>m(void 0),confirmationValue:p?.action.handler===`delete`?`delete`:void 0,confirmationLabel:p?.action.handler===`delete`?d(`view.typeDeleteToConfirm`):void 0,confirmationPlaceholder:p?.action.handler===`delete`?`delete`:void 0})]})}function J6({selection:r,page:i,showSelectPage:a=!1}){let{t:s}=K(),c=W6(),l=vt();if(!c)return null;let u=r?.selectedHits??[],d=r?i.filter(e=>r.isSelected(e.id)).length:0,f=i.length>0&&d===i.length,p=a&&r?.selectAll&&i.length>0,h=c.actions.filter(e=>((e.placement??`selection`)===`toolbar`||(e.placement??`selection`)===`selection`&&u.length>0)&&G6(e,u));return h.length===0&&u.length===0&&!p?null:n(`div`,{className:`flex flex-wrap items-center gap-2`,children:[p&&r&&n(`div`,{className:`flex items-center gap-2`,children:[t(m,{id:l,checked:f?!0:d>0&&`indeterminate`,onCheckedChange:e=>r.togglePage(i,e===!0)}),t(`label`,{htmlFor:l,className:`text-sm text-muted`,children:s(`view.selectPage`)})]}),u.length>0&&n(e,{children:[t(`span`,{className:`text-sm text-muted`,children:s(`view.selectedCount`,{count:u.length})}),t(o,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":s(`view.clearSelection`),onClick:r?.clear,children:t(Gb,{className:`size-4`})})]}),h.map(e=>n(o,{type:`button`,variant:e.destructive?`destructive`:`outline`,size:`sm`,disabled:c.runningActionId!==void 0,onClick:()=>c.run(e,u),children:[e.handler===`export`&&t(xg,{className:`size-4`}),e.handler===`delete`&&t(hb,{className:`size-4`}),e.label]},e.id))]})}function Y6({hit:e}){let{t:r}=K(),i=W6(),a=i?.actions.filter(t=>(t.placement??`selection`)===`row`&&G6(t,[e]));return!i||!a?.length?null:n(he,{children:[t(_e,{children:t(o,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":r(`view.actions`),children:t(wg,{className:`size-4`})})}),t(ge,{className:`w-52 p-1`,align:`end`,sideOffset:6,children:t(Te,{options:a,optionLayout:e=>({label:e.label,className:e.destructive?`text-destructive`:void 0}),onChange:t=>i.run(t,[e]),noCheck:!0})})]})}function X6(e){return e.dataTransfer.items?Array.from(e.dataTransfer.items).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>e!==null):Array.from(e.dataTransfer.files)}function Z6({children:r,definition:i,request:a,result:o,contribution:s,canWrite:c,refresh:l}){let{t:u}=K(),d=nt(),f=i.results?.drop,p=f?.handler===`upload`&&c,m=s!==void 0||p,[h,g]=G(!1),[_,v]=G(!1),[y,b]=G([]),x=W(!1),S=V(async e=>{if(e.length){if(s){if(x.current)return;x.current=!0,v(!0);try{await s.run({configuration:f,files:e,definition:i,request:a,result:o,refresh:l})}catch(e){console.error(`View drop action failed:`,e),d({status:`error`,title:u(`view.dropFailed`),description:u(`view.actionFailedDescription`)})}finally{x.current=!1,v(!1)}return}p&&b(e)}},[p,f,s,i,l,a,o,u,d]);if(!m)return r;let C=f?.params;return n(e,{children:[n(`div`,{className:`relative min-h-48`,onDragEnter:e=>{e.preventDefault(),g(!0)},onDragOver:e=>{e.preventDefault(),g(!0)},onDragLeave:e=>{e.preventDefault(),e.currentTarget.contains(e.relatedTarget)||g(!1)},onDrop:e=>{e.preventDefault(),e.stopPropagation(),g(!1),!e.target.closest(`[data-view-drop-zone]`)&&S(X6(e))},children:[r,_&&t(`div`,{className:`absolute inset-0 z-40 flex items-center justify-center bg-background/80`,children:t(je,{size:`xl`})}),t(`div`,{"data-view-drop-zone":!0,className:`pointer-events-none absolute inset-0 ${h?`z-50`:`-z-10`}`,children:t(Ot,{onDrop:e=>void S(e),message:u(`view.dropFiles`),buttonLabel:u(`view.selectFiles`),allowFolders:C?.allow_folders??!0,className:`pointer-events-auto absolute inset-0 bg-background/90 ${h?`flex`:`hidden`}`})})]}),p&&t(q$,{isOpen:y.length>0,onClose:()=>b([]),files:y,collectionId:C?.collection_id,selectedFolder:C?.location,initialTypeId:C?.type_id,defaultProperties:C?.properties,allowFolders:C?.allow_folders??!0,title:u(`view.uploadToView`),onUploadComplete:e=>{e.success&&l()}})]})}Q();function Q6(e,t,n,r){return n?r===!1?[t]:e.includes(t)?e:[...e,t]:e.filter(e=>e!==t)}function $6({node:e}){return n(`span`,{className:`flex min-w-0 flex-1 items-center justify-between gap-2`,children:[t(`span`,{className:`truncate`,children:e.label}),t(`span`,{className:`text-xs tabular-nums text-muted`,children:e.count})]})}function e8({configuration:e,result:r,isLoading:i,onChange:a,onQueryChange:s}){let{t:c}=K(),l=vt(),u=e.presentation??(e.source===`location`||e.source===`hierarchy`?`tree`:`list`),d=e.source!==`hierarchy`&&e.multi_select,f=r.breadcrumbs??[],[p,h]=G(r.query??``);H(()=>{h(r.query??``)},[r.query]);let g=(e,t)=>{a(Q6(r.selected,e,t,d))};return n(`section`,{className:`space-y-2`,"aria-labelledby":`${l}-label`,children:[n(`div`,{className:`flex items-center justify-between gap-2`,children:[t(`h2`,{id:`${l}-label`,className:`text-sm font-semibold`,children:e.label}),r.selected.length>0&&n(o,{type:`button`,variant:`ghost`,size:`sm`,disabled:i,onClick:()=>a([]),"aria-label":`${c(`filter.clearAll`)}: ${e.label}`,children:[t(Gb,{className:`size-3.5`}),c(`filter.clearAll`)]})]}),e.source===`collection`&&s&&n(`form`,{className:`flex items-center gap-1`,onSubmit:e=>{e.preventDefault(),s?.(p.trim())},children:[t(te,{value:p,onChange:h,disabled:i,placeholder:c(`view.filterNavigation`,{label:e.label}),"aria-label":c(`view.filterNavigation`,{label:e.label})}),t(o,{type:`submit`,variant:`outline`,size:`icon`,disabled:i,"aria-label":c(`view.searchNavigation`,{label:e.label}),children:t(Ay,{"aria-hidden":`true`,className:`size-4`})})]}),f.length>0&&t(`nav`,{"aria-label":`${e.label} path`,children:t(`ol`,{className:`flex flex-wrap items-center gap-1 text-sm`,children:f.map((e,r)=>n(`li`,{className:`flex items-center gap-1`,children:[r>0&&t(lh,{"aria-hidden":`true`,className:`size-3.5 text-muted`}),t(o,{type:`button`,variant:`ghost`,size:`sm`,disabled:i,onClick:()=>a([e.id]),"aria-current":r===f.length-1?`page`:void 0,children:e.label})]},e.id))})}),r.selected.length>0&&f.length===0&&(e.source===`location`||e.source===`collection`)&&t(`div`,{className:`flex flex-wrap gap-1`,children:r.selected.map(e=>{let a=r.nodes.find(t=>t.id===e)?.label??e;return n(o,{type:`button`,variant:`secondary`,size:`sm`,disabled:i,onClick:()=>g(e,!1),"aria-label":c(`view.removeSelection`,{value:a}),children:[a,t(Gb,{"aria-hidden":`true`,className:`size-3.5`})]},e)})}),u===`select`&&d===!1?t(we,{options:r.nodes,value:r.nodes.find(e=>r.selected.includes(e.id)),onChange:e=>a([e.id]),optionLabel:e=>`${e.label} (${e.count})`,by:`id`,disabled:i,placeholder:e.label,"aria-label":e.label}):u===`select`?t(we,{multiple:!0,options:r.nodes,value:r.nodes.filter(e=>r.selected.includes(e.id)),onChange:e=>a(e.map(e=>e.id)),optionLabel:e=>`${e.label} (${e.count})`,by:`id`,disabled:i,placeholder:e.label,"aria-label":e.label}):u===`chips`?t(`div`,{className:`flex flex-wrap gap-2`,children:r.nodes.map(e=>n(o,{type:`button`,variant:r.selected.includes(e.id)?`secondary`:`outline`,size:`sm`,disabled:i,onClick:()=>g(e.id,!r.selected.includes(e.id)),children:[e.label,t(`span`,{className:`text-xs tabular-nums text-muted`,children:e.count})]},e.id))}):e.source===`hierarchy`?t(`div`,{className:`space-y-1`,children:r.nodes.map(e=>n(o,{type:`button`,variant:r.selected.includes(e.id)?`secondary`:`ghost`,className:`w-full justify-start`,disabled:i,onClick:()=>a([e.id]),children:[t($6,{node:e}),e.expandable&&t(lh,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted`})]},e.id))}):t(`div`,{className:`space-y-1`,children:r.nodes.map((e,a)=>{let o=`${l}-${a}`;return n(`div`,{className:`flex items-center gap-2 rounded-md px-2 py-1.5 hover:bg-muted`,children:[t(m,{id:o,checked:r.selected.includes(e.id),disabled:i,onCheckedChange:t=>g(e.id,t===!0)}),t(`label`,{htmlFor:o,className:`flex min-w-0 flex-1 cursor-pointer text-sm`,children:t($6,{node:e})})]},e.id)})}),r.nodes.length===0&&t(`p`,{className:`text-sm text-muted`,children:c(`filter.noAvailableFilters`)})]})}const t8=`display`,n8=`sort`,r8=`offset`;function i8(e){if(e===null||e.trim()===``)return;let t=Number(e);return Number.isSafeInteger(t)&&t>=0?t:void 0}function a8(e,t){let n={};for(let r of new Set(e.keys())){if(!r.startsWith(t)||r.length===t.length)continue;let i=e.getAll(r).filter(e=>e!==``);i.length>0&&(n[r.slice(t.length)]=i)}return Object.keys(n).length>0?n:void 0}function o8(e,t){let n={};for(let r of new Set(e.keys())){if(!r.startsWith(t)||r.length===t.length)continue;let i=e.get(r)?.trim();i&&(n[r.slice(t.length)]=i)}return Object.keys(n).length>0?n:void 0}function s8(e){let t=new URLSearchParams(e.startsWith(`?`)?e.slice(1):e),n=t.get(`q`)?.trim(),r=t.get(t8)?.trim(),i=t.get(n8)?.trim(),a=i8(t.get(r8)),o=a8(t,`t.`),s=a8(t,`n.`),c=o8(t,`nq.`);return{...n?{query:n}:{},...o?{key_terms:o}:{},...s?{navigation:s}:{},...c?{navigation_queries:c}:{},...r?{display:r}:{},...i?{sort:i}:{},...a?{offset:a}:{}}}function c8(e){for(let t of[...e.keys()])(t===`q`||t===t8||t===n8||t===r8||t.startsWith(`t.`)||t.startsWith(`nq.`)||t.startsWith(`n.`))&&e.delete(t)}function l8(e,t,n){if(n)for(let[r,i]of Object.entries(n).sort(([e],[t])=>e.localeCompare(t)))for(let n of i)n!==``&&e.append(`${t}${r}`,n)}function u8(e,t,n){if(n)for(let[r,i]of Object.entries(n).sort(([e],[t])=>e.localeCompare(t)))i.trim()&&e.set(`${t}${r}`,i.trim())}function d8(e,t=``){let n=new URLSearchParams(t.startsWith(`?`)?t.slice(1):t);c8(n),e.query?.trim()&&n.set(`q`,e.query.trim()),e.display&&n.set(t8,e.display),e.sort&&n.set(n8,e.sort),e.offset&&e.offset>0&&n.set(r8,String(e.offset)),l8(n,`t.`,e.key_terms),l8(n,`n.`,e.navigation),u8(n,`nq.`,e.navigation_queries);let r=n.toString();return r?`?${r}`:``}function f8(e){let t=Object.fromEntries(Object.entries(e.navigation).filter(([,e])=>e.selected.length>0).map(([e,t])=>[e,t.selected]));return Object.keys(t).length>0?t:void 0}function p8(e){let t={};for(let[n,r]of Object.entries(e.navigation))r.query&&(t[n]=r.query);return Object.keys(t).length>0?t:void 0}function m8(e,t){let n=new Set(t.definition.search?.key_terms?.map(e=>e.id)??[]),r=e.key_terms?Object.fromEntries(Object.entries(e.key_terms).filter(([e,t])=>n.has(e)&&t.length)):void 0,i=f8(t),a=p8(t);return{...e.query?.trim()?{query:e.query.trim()}:{},...r&&Object.keys(r).length>0?{key_terms:r}:{},...i?{navigation:i}:{},...a?{navigation_queries:a}:{},...t.display?{display:t.display}:{},...t.sort?{sort:t.sort}:{},...e.offset&&e.offset>0?{offset:e.offset}:{},...e.limit?{limit:e.limit}:{}}}function h8(e,t,n){return t.sort??e.sort??(e.query?.trim()?void 0:n)}function g8(e){if(typeof window>`u`)return;let t=d8(e,window.location.search);window.history.replaceState(window.history.state||{},``,`${window.location.pathname}${t}`)}Q();function _8(e,t){return!t||t===`.`?e:t.split(`.`).reduce((e,t)=>{if(!(!e||typeof e!=`object`||Array.isArray(e)))return e[t]},e)}function v8(e,t){return t===`score`?e.score:t.startsWith(`annotation.`)?_8(e.annotation,t.slice(11)):t.startsWith(`document.`)?_8(e.document,t.slice(9)):_8(e.document,t)}const y8=dt(void 0);function b8(e){if(e!=null&&e!==``)return Array.isArray(e)?e.map(b8).filter(Boolean).join(`, `):typeof e==`object`?JSON.stringify(e):String(e)}function x8(e,t,n){let r=v8(e,t.field),i=t.fallback??``;if(r==null||r===``)return i;if(t.format===`date`){let e=String(r),t=/^\d{4}-\d{2}-\d{2}$/.test(e),a=new Date(e);if(Number.isNaN(a.getTime()))return b8(r)??i;let o={year:`numeric`,month:`numeric`,day:`numeric`,...t?{timeZone:`UTC`}:{}};return n?.formatDate(a,o)??new Intl.DateTimeFormat(void 0,o).format(a)}if(t.format===`number`){let e=typeof r==`number`?r:Number(r);return Number.isFinite(e)?n?.formatNumber(e)??new Intl.NumberFormat().format(e):b8(r)??i}return b8(r)??i}function S8({hit:e,field:n,className:r}){let a=x8(e,n,_t(y8));return a?n.format===`badge`||n.format===`content_type`?t(i,{className:r,children:a}):t(`span`,{className:r,children:a}):null}function C8({hit:e,onOpenHit:r,compact:i=!1}){let{t:a}=K();return r?i?t(We,{description:a(`agent.openDocument`),asChild:!0,children:t(o,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":a(`agent.openDocument`),onClick:()=>r(e),children:t(Dg,{className:`size-4`})})}):n(o,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r(e),children:[t(Dg,{className:`size-4`}),a(`agent.openDocument`)]}):null}function w8(e,t){if(t.source!==`property`||!t.field)return;let n=b8(v8(e,t.field));if(n)try{let e=new URL(n,typeof window>`u`?`https://localhost`:window.location.origin);return e.protocol===`http:`||e.protocol===`https:`?e.toString():void 0}catch{return}}const T8=new WeakMap,E8=[2e3,4e3,8e3];function D8(e){let t=T8.get(e);if(t)return t;let n=new Map;return T8.set(e,n),n}function O8(e,t,n){let r=D8(e),i=r.get(t);if(i)return i;let a=n().finally(()=>{r.delete(t)});return r.set(t,a),a}function k8({hit:e,media:n,resolveMedia:r,className:i}){let a=n?w8(e,n):void 0,[o,s]=G(),[c,l]=G(!1),u=!a&&n?`${e.id}|${JSON.stringify(n)}`:void 0,d=W(e),f=W(n);d.current=e,f.current=n,H(()=>{if(s(void 0),l(!1),!u||!r)return;let e=!0,t,n=i=>{O8(r,u,async()=>r(d.current,f.current)).then(r=>{if(!e)return;if(r){s(r);return}let a=E8[i];a!==void 0&&(t=setTimeout(()=>n(i+1),a))}).catch(()=>{e&&l(!0)})};return n(0),()=>{e=!1,t&&clearTimeout(t)}},[u,r,a]);let p=c?void 0:a??o,m=n?.fit===`contain`?`object-contain`:`object-cover`;if(p)return t(`img`,{src:p,alt:``,className:`${m} ${i??``}`,onError:()=>l(!0)});let h=n?.source===`type_icon`?`type_icon`:n?.fallback??`type_icon`;return h===`none`?null:t(`div`,{className:`flex items-center justify-center bg-muted ${i??``}`,"aria-hidden":`true`,children:t(h===`placeholder`?D_:Gg,{className:`size-10 text-muted`})})}function A8({hit:e}){let n=e.annotation?.why_match??e.annotation?.answer??e.annotation?.excerpt;return n?t(`p`,{className:`text-sm text-info`,children:n}):null}function j8({hit:e,page:n,selection:r}){let{t:i}=K(),a=W(!1);return r?t(m,{checked:r.isSelected(e.id),"aria-label":i(`view.selectResult`,{name:e.document.name}),onClick:e=>{a.current=e.shiftKey,e.stopPropagation()},onCheckedChange:t=>{r.toggle(e,t===!0,{page:n,range:r.mode===`multiple`&&a.current}),a.current=!1}}):null}function M8({hit:e,fields:n}){return n?.length?t(`div`,{className:`flex flex-wrap gap-1`,children:n.map(n=>t(S8,{hit:e,field:n},`${n.field}-${n.label??``}`))}):null}function N8({hit:e,fields:r}){let i=_t(y8);return r?.length?t(`dl`,{className:`space-y-1 text-sm`,children:r.map(r=>{let a=x8(e,r,i);return a?n(`div`,{className:`flex gap-2`,children:[r.label&&t(`dt`,{className:`shrink-0 text-muted`,children:r.label}),t(`dd`,{className:`min-w-0 truncate`,children:a})]},`${r.field}-${r.label??``}`):null})}):null}function P8({display:e,hits:r,onOpenHit:i,resolveMedia:a,selection:o}){return t(`div`,{className:`divide-y divide-border rounded-md border`,children:r.map(s=>n(`article`,{className:`flex gap-4 p-4 ${o?.isSelected(s.id)?`bg-muted/40`:``}`,children:[o&&t(`div`,{className:`pt-1`,children:t(j8,{hit:s,page:r,selection:o})}),e.media&&t(k8,{hit:s,media:e.media,resolveMedia:a,className:`size-20 shrink-0 rounded-md`}),n(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[n(`div`,{children:[t(`h3`,{className:`font-semibold`,children:t(S8,{hit:s,field:e.title})}),e.subtitle&&t(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1 text-sm text-muted`,children:e.subtitle.map(e=>t(S8,{hit:s,field:e},e.field))})]}),e.description&&t(`p`,{className:`line-clamp-3 text-sm text-muted`,children:t(S8,{hit:s,field:e.description})}),t(M8,{hit:s,fields:e.badges}),t(A8,{hit:s})]}),n(`div`,{className:`shrink-0 self-center`,children:[t(C8,{hit:s,onOpenHit:i,compact:!0}),t(Y6,{hit:s})]})]},s.id))})}function F8({display:e,hits:r,isLoading:i,onOpenHit:a,sortOptions:o,currentSort:s,onSortChange:c,selection:l}){let{t:u}=K(),d=W6()?.actions.some(e=>e.placement===`row`)??!1,f=l?r.filter(e=>l.isSelected(e.id)).length:0,p=r.length>0&&f===r.length;return t(`div`,{className:`overflow-x-auto rounded-md border`,children:n(Le,{className:`w-full`,children:[t(Fe,{children:n(`tr`,{children:[l&&t(Re,{className:`w-0`,children:l.selectAll&&t(m,{checked:p?!0:f>0&&`indeterminate`,"aria-label":u(`view.selectPage`),onCheckedChange:e=>l.togglePage(r,e===!0)})}),e.columns.map(e=>{let n=e.sort_option?o?.find(t=>t.id===e.sort_option):void 0;if(!e.sortable||!n)return t(Re,{children:e.label??e.field},`${e.field}-${e.label??``}`);let r=s===n.id?n.sort[0]?.order===`desc`?`descending`:`ascending`:`none`;return t(Ae,{sortDirection:r,onSort:()=>c?.(n.id),disabled:i||!c,sortIndicator:e=>e===`ascending`?t(fh,{className:`size-3`,"aria-hidden":`true`}):e===`descending`?t(rh,{className:`size-3`,"aria-hidden":`true`}):t(wh,{className:`size-3 text-muted`,"aria-hidden":`true`}),children:e.label??e.field},`${e.field}-${e.label??``}`)}),(a||d)&&t(Re,{className:`w-0`,children:t(`span`,{className:`sr-only`,children:u(d?`view.actions`:`agent.openDocument`)})})]})}),t(Pe,{isLoading:i&&r.length===0,columns:e.columns.length+ +!!l+(a||d?1:0),children:r.map(i=>n(`tr`,{className:l?.isSelected(i.id)?`bg-muted/40`:void 0,children:[l&&t(`td`,{className:`w-0`,children:t(j8,{hit:i,page:r,selection:l})}),e.columns.map(e=>t(`td`,{style:e.width?{width:e.width}:void 0,children:t(S8,{hit:i,field:e})},`${i.id}-${e.field}`)),(a||d)&&t(`td`,{className:`w-0 whitespace-nowrap text-end`,children:n(`div`,{className:`flex items-center justify-end gap-1`,children:[t(C8,{hit:i,onOpenHit:a,compact:!0}),t(Y6,{hit:i})]})})]},i.id))})]})})}const I8={2:`md:grid-cols-2`,3:`md:grid-cols-2 xl:grid-cols-3`,4:`md:grid-cols-2 xl:grid-cols-4`,5:`md:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-5`,6:`md:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-6`};function L8({hit:e,configuration:r,onOpenHit:i,resolveMedia:a,selection:o,page:p}){let m=W6()?.actions.some(e=>e.placement===`row`)??!1;return n(s,{className:`relative flex h-full min-w-0 flex-col overflow-hidden ${o?.isSelected(e.id)?`ring-2 ring-primary`:``}`,children:[o&&t(`div`,{className:`absolute start-2 top-2 z-10 rounded bg-background/80 p-1`,children:t(j8,{hit:e,page:p,selection:o})}),r.media&&t(k8,{hit:e,media:r.media,resolveMedia:a,className:`h-40 w-full border-b`}),n(d,{className:`gap-2 p-4`,children:[t(M8,{hit:e,fields:r.badges}),t(f,{className:`truncate text-base`,children:t(S8,{hit:e,field:r.title})}),r.description&&t(l,{className:`line-clamp-3`,children:t(S8,{hit:e,field:r.description})})]}),n(c,{className:`flex-1 p-4 pt-0`,children:[t(N8,{hit:e,fields:r.fields}),t(A8,{hit:e})]}),(i||m)&&n(u,{className:`justify-end p-4 pt-0`,children:[t(C8,{hit:e,onOpenHit:i}),t(Y6,{hit:e})]})]})}function R8({display:e,hits:n,onOpenHit:r,resolveMedia:i,selection:a}){return t(`div`,{className:`grid grid-cols-1 gap-4 ${I8[e.columns??3]}`,children:n.map(o=>t(L8,{hit:o,configuration:e,onOpenHit:r,resolveMedia:i,selection:a,page:n},o.id))})}function z8({display:e,hits:r,onOpenHit:i,resolveMedia:a,selection:o}){return t(`div`,{className:`grid grid-cols-1 gap-4 ${I8[e.columns??4]}`,children:r.map(l=>n(s,{className:`relative overflow-hidden ${o?.isSelected(l.id)?`ring-2 ring-primary`:``}`,children:[o&&t(`div`,{className:`absolute start-2 top-2 z-10 rounded bg-background/80 p-1`,children:t(j8,{hit:l,page:r,selection:o})}),t(k8,{hit:l,media:e.media,resolveMedia:a,className:`aspect-square w-full border-b`}),n(c,{className:`space-y-2 p-3`,children:[t(`h3`,{className:`truncate font-semibold`,children:t(S8,{hit:l,field:e.title})}),e.caption&&t(`div`,{className:`space-y-1 text-sm text-muted`,children:e.caption.map(e=>t(`div`,{className:`truncate`,children:t(S8,{hit:l,field:e})},e.field))}),n(`div`,{className:`flex items-center justify-end gap-1`,children:[t(C8,{hit:l,onOpenHit:i}),t(Y6,{hit:l})]})]})]},l.id))})}function B8({display:e,hits:r,onOpenHit:a,resolveMedia:o,selection:s}){let c=new Map;for(let t of r){let n=b8(v8(t,e.group_by))??``;c.set(n,[...c.get(n)??[],t])}let l=e.columns?.length?[...e.columns].sort((e,t)=>(e.order??0)-(t.order??0)):[...c.keys()].sort().map(e=>({value:e,label:e||`—`}));return t(`div`,{className:`flex min-w-max gap-4 overflow-x-auto pb-2`,children:l.map(l=>{let u=c.get(l.value)??[];return n(`section`,{className:`w-80 shrink-0 space-y-3 rounded-lg bg-muted/40 p-3`,children:[n(`div`,{className:`flex items-center justify-between gap-2`,children:[t(`h3`,{className:`font-semibold`,children:l.label}),t(i,{children:u.length})]}),t(`div`,{className:`space-y-3`,children:u.map(n=>t(L8,{hit:n,configuration:e.card,onOpenHit:a,resolveMedia:o,selection:s,page:r},n.id))})]},l.value)})})}function V8(e,n,r,i,a,o,s,c,l){return e.type===`table`?t(F8,{display:e,hits:n,isLoading:r,onOpenHit:i,sortOptions:o,currentSort:s,onSortChange:c,selection:l}):e.type===`cards`?t(R8,{display:e,hits:n,onOpenHit:i,resolveMedia:a,selection:l}):e.type===`gallery`?t(z8,{display:e,hits:n,onOpenHit:i,resolveMedia:a,selection:l}):e.type===`board`?t(B8,{display:e,hits:n,onOpenHit:i,resolveMedia:a,selection:l}):t(P8,{display:e,hits:n,onOpenHit:i,resolveMedia:a,selection:l})}function H8({configuration:e,definition:n,request:r,result:i,isLoading:a,onSortChange:o,onOpenHit:s,resolveMedia:c,selection:l}){let{t:u}=K(),d=Zt();return!a&&i.hits.length===0?t(`p`,{className:`py-12 text-center text-sm text-muted`,children:u(`filter.noResultsFound`)}):t(y8.Provider,{value:d,children:V8(e,i.hits,a,s,c,n.results?.sort_options,h8(r,i,n.results?.default_sort),o,l)})}Q();function U8(e,t){return t?`text`:e===`number`?`number`:e===`date`?`date`:`text`}function W8(e){let[t=``,n=``]=(e[0]??``).split(`..`,2);return[t,n]}function G8(e,t){return e||t?[`${e}..${t}`]:[]}function K8(e,t){return t?e.join(`, `):e[0]??``}function q8(e,t){return t?e.split(`,`).map(e=>e.trim()).filter(Boolean):e.trim()?[e.trim()]:[]}function J8({term:e,values:n,isLoading:r,onChange:i}){let a=W(!1),o=W(void 0),[s,c]=G(()=>K8(n,e.multiple)),l=K8(n,e.multiple);return H(()=>{a.current&&o.current===l||c(l),o.current=void 0},[l]),t(L,{label:e.label,children:t(te,{type:U8(e.type,e.multiple),name:`view-key-term-${e.id}`,autoComplete:`off`,value:s,onFocus:()=>{a.current=!0},onBlur:()=>{a.current=!1;let t=q8(s,e.multiple);c(K8(t,e.multiple))},onChange:t=>{c(t);let n=q8(t,e.multiple);o.current=K8(n,e.multiple),i(n)},placeholder:e.label,disabled:r})})}function Y8({configuration:e,query:r,keyTerms:i,isLoading:a,onQueryChange:s,onKeyTermsChange:c,onSubmit:l}){let{t:u}=K(),d=vt(),f=e.key_terms?.filter(e=>e.operator!==`range`)??[],p=e.key_terms?.filter(e=>e.operator===`range`)??[];return n(`form`,{className:`flex flex-col gap-3`,"aria-label":u(`layout.search`),autoComplete:`off`,onSubmit:e=>{e.preventDefault(),l()},children:[n(`div`,{className:`flex items-center gap-2`,children:[t(`label`,{htmlFor:d,className:`sr-only`,children:u(`layout.search`)}),t(te,{id:d,name:`view-query`,autoComplete:`off`,value:r,onChange:s,placeholder:e.placeholder??u(`store.searchPlaceholder`),disabled:a}),n(o,{type:`submit`,disabled:a,className:`shrink-0`,children:[t(Ay,{className:`size-4`}),u(a?`store.searching`:`store.search`)]})]}),e.key_terms&&e.key_terms.length>0&&n(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:[f.length>0&&n(`fieldset`,{className:`rounded-md border border-mixer-muted/30 bg-mixer-muted/5 p-3 ${p.length===0?`lg:col-span-2`:``}`,children:[t(`legend`,{className:`px-1 text-xs font-medium text-muted`,children:u(`view.searchFields`)}),t(`div`,{className:`grid gap-3 sm:grid-cols-2 ${p.length===0?`lg:grid-cols-4`:``}`,children:f.map(e=>t(J8,{term:e,values:i[e.id]??[],isLoading:a,onChange:t=>c(e.id,t)},e.id))})]}),p.length>0&&n(`fieldset`,{className:`rounded-md border border-mixer-muted/30 bg-mixer-muted/5 p-3 ${f.length===0?`lg:col-span-2`:``}`,children:[t(`legend`,{className:`px-1 text-xs font-medium text-muted`,children:u(`view.ranges`)}),t(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:p.map(e=>{let[r,o]=W8(i[e.id]??[]),s=e.type===`number`?`number`:e.type===`date`?`date`:`text`;return n(`fieldset`,{className:`min-w-0`,children:[t(`legend`,{className:`mb-1 text-sm font-medium`,children:e.label}),n(`div`,{className:`grid grid-cols-2 gap-2`,children:[t(te,{type:s,name:`view-key-term-${e.id}-from`,autoComplete:`off`,"aria-label":`${e.label}: ${u(`view.from`)}`,value:r,onChange:t=>c(e.id,G8(t.trim(),o)),placeholder:u(`view.from`),disabled:a}),t(te,{type:s,name:`view-key-term-${e.id}-to`,autoComplete:`off`,"aria-label":`${e.label}: ${u(`view.to`)}`,value:o,onChange:t=>c(e.id,G8(r,t.trim())),placeholder:u(`view.to`),disabled:a})]})]},e.id)})})]})]})]})}Q();const X8={id:`default`,label:`Results`,type:`list`,title:{field:`name`},subtitle:[{field:`type.name`,format:`content_type`},{field:`location`,format:`location`}],description:{field:`description`}};function Z8(e){return!e||typeof window>`u`?{}:s8(window.location.search)}function Q8(e){let t=Object.fromEntries(Object.entries(e).filter(([,e])=>e.length>0));return Object.keys(t).length>0?t:void 0}function $8(e){let t=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.trim()]).filter(([,e])=>e.length>0));return Object.keys(t).length>0?t:void 0}function e5(e){let{client:n}=q(),r=_t(s2),i=V(t=>n.views.execute(e.viewId,t),[n,e.viewId]),a=V(async(e,t)=>{if(t.source!==`content_thumbnail`)return;let r=e.document.content;try{let t=await n.objects.getRenditionSafe(e.id,r?.type,{format:mn.jpeg,max_hw:512,generate_if_missing:!1,sign_url:!0});if(t?.status===`found`&&t.renditions?.length)return t.renditions[0]}catch{}if(r?.source&&r.type?.startsWith(`image/`))return(await n.files.getDownloadUrl(r.source)).url},[n]),o=e=>r!==void 0&&e.some(e=>r.hasPermission(e));return t(n5,{...e,execute:i,resolveMedia:e.resolveMedia??a,client:n,canDelete:o([yn.content_delete,yn.content_admin,yn.content_superadmin]),canWrite:o([yn.content_write,yn.content_admin,yn.content_superadmin])})}function t5({execute:e,...n}){return e?t(n5,{...n,execute:e},n.viewId):t(e5,{...n},n.viewId)}function n5({execute:e,renderers:r,contributions:i,onOpenHit:a,resolveMedia:s,syncUrl:c=!0,showHeader:l=!0,className:u,client:d,canDelete:f=!1,canWrite:p=!1}){let{t:m}=K(),h=W(e);h.current=e;let g=W(0),[_,v]=G(()=>Z8(c)),[y,b]=G(_.query??``),[x,S]=G(_.key_terms??{}),[C,w]=G(),[T,E]=G(!0),[D,O]=G(),[k,A]=G({}),j=W(void 0),N=V(()=>{j.current=void 0,A({})},[]),P=V((e,t,n=!1)=>{let r=++g.current;return n||N(),v(e),t&&c&&g8(e),E(!0),O(void 0),h.current(e).then(t=>{if(r===g.current){let n=m8(e,t);v(n),c&&g8(n),w(t)}}).catch(e=>{r===g.current&&O(e instanceof Error?e:Error(String(e)))}).finally(()=>{r===g.current&&E(!1)})},[N,c]),F=V(()=>{let e=Z8(c);return b(e.query??``),S(e.key_terms??{}),P(e,!1)},[P,c]);H(()=>(F(),()=>{g.current+=1}),[F]),H(()=>{if(!c||typeof window>`u`)return;let e=()=>void F();return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[F,c]);let I=C?.definition,L=U(()=>[...I?.navigation??[]].sort((e,t)=>(e.order??0)-(t.order??0)),[I?.navigation]),ee=I?.results,R=ee?.selection,te=C?.display??_.display??ee?.default_display,ne=ee?.displays.find(e=>e.id===te)??X8,re=C?h8(_,C,ee?.default_sort):_.sort,ie=e=>{P(e,!0)},ae=(e,t)=>{let n=Q8({..._.navigation??{},[e.id]:t});ie({..._,navigation:n,offset:void 0})},se=(e,t)=>{let n=$8({..._.navigation_queries??{},[e.id]:t});ie({..._,navigation_queries:n,offset:void 0})},ce=()=>{ie({..._,query:y.trim()||void 0,key_terms:Q8(x),offset:void 0})},le=U(()=>{if(!R)return;let e=Object.keys(k);return{mode:R.mode,selectAll:R.mode===`multiple`&&R.select_all===`page`,selectedIds:e,selectedHits:e.map(e=>k[e]).filter(e=>e!==void 0),isSelected:e=>k[e]!==void 0,toggle:(e,t,n)=>{A(r=>{if(!t){let t={...r};return delete t[e.id],t}if(R.mode===`single`)return j.current=e.id,{[e.id]:e};let i={...r,[e.id]:e};if(n?.range&&n.page&&j.current){let t=n.page.findIndex(e=>e.id===j.current),r=n.page.findIndex(t=>t.id===e.id);if(t>=0&&r>=0){let e=Math.min(t,r),a=Math.max(t,r);for(let t of n.page.slice(e,a+1))i[t.id]=t}}return j.current=e.id,i})},togglePage:(e,t)=>{R.mode===`multiple`&&A(n=>{let r={...n};for(let n of e)t?r[n.id]=n:delete r[n.id];return r})},clear:N}},[N,k,R]);if(!C&&T)return t(`div`,{className:`flex h-full min-h-48 items-center justify-center`,children:t(je,{size:`xl`})});if(!C||!I)return t(`div`,{className:`flex h-full min-h-48 items-center justify-center p-4`,children:t(M,{title:m(`store.searchFailed`),action:()=>void F(),actionLabel:m(`agent.retry`),children:m(`store.searchFailed`)})});let ue=I.search?.renderer?r?.search?.[I.search.renderer]??Y8:Y8,de=ne.renderer?r?.results?.[ne.renderer]??H8:H8,fe=L.length>0&&I.layout?.navigation_position!==`top`,pe=I.layout?.mode===`worklist`,me=_.offset??0,he=_.limit??ne.page_size??20,ge=me>0,_e=me+C.hits.length<C.total,ve=L.map(e=>{let n=C.navigation[e.id]??{id:e.id,selected:[],nodes:[]},i=e.renderer?r?.navigation?.[e.renderer]??e8:e8;return t(i,{configuration:e,result:n,isLoading:T,onChange:t=>ae(e,t),onQueryChange:e.source===`collection`?t=>se(e,t):void 0},e.id)}),ye=()=>P(_,!1,!0),be=n(ir,{className:u,children:[l&&t(l0,{title:I.name,description:I.description}),n(ir.Fixed,{heightClass:`h-auto`,className:`space-y-3 border-b p-3`,children:[I.search&&t(ue,{configuration:I.search,query:y,keyTerms:x,isLoading:T,onQueryChange:b,onKeyTermsChange:(e,t)=>S(n=>({...n,[e]:t})),onSubmit:ce}),L.length>0&&I.layout?.navigation_position===`top`&&t(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:ve})]}),t(ir.Body,{className:`p-0`,children:n(`div`,{className:fe?pe?`grid min-h-full lg:grid-cols-[minmax(0,1fr)_18rem]`:`grid min-h-full lg:grid-cols-[18rem_minmax(0,1fr)]`:`min-h-full`,children:[fe&&t(`aside`,{className:pe?`space-y-5 border-b p-4 lg:order-2 lg:border-s lg:border-b-0`:`space-y-5 border-b p-4 lg:border-e lg:border-b-0`,children:ve}),n(`main`,{className:`min-w-0 space-y-4 p-4 ${pe?`lg:order-1`:``}`,children:[D&&t(M,{title:m(`store.searchFailed`),action:()=>void P(_,!1),actionLabel:m(`agent.retry`),children:m(`store.searchFailed`)}),C.search.warnings.length>0&&t(oe,{status:`warning`,title:m(`view.warning`),children:t(`ul`,{className:`list-disc space-y-1 ps-4`,children:C.search.warnings.map(e=>t(`li`,{children:e.message},`${e.code}-${e.path??``}`))})}),n(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[n(`div`,{className:`flex items-center gap-2 text-sm text-muted`,children:[t(`span`,{children:m(`view.resultsCount`,{count:C.total})}),T&&t(je,{size:`sm`})]}),n(`div`,{className:`flex flex-wrap items-center gap-3`,children:[t(J6,{selection:le,page:C.hits,showSelectPage:ne.type!==`table`}),ee?.allow_display_switch&&ee.displays.length>1&&n(`div`,{className:`flex items-center gap-2`,children:[t(`span`,{className:`text-sm text-muted`,children:m(`view.display`)}),t(we,{options:ee.displays,value:ne,onChange:e=>void P({..._,display:e.id,offset:void 0},!0,!0),optionLabel:e=>e.label,by:`id`,disabled:T,"aria-label":m(`view.display`),className:`min-w-36`})]}),ee?.sort_options&&ee.sort_options.length>0&&n(`div`,{className:`flex items-center gap-2`,children:[t(`span`,{className:`text-sm text-muted`,children:m(`view.sort`)}),t(we,{options:ee.sort_options,value:ee.sort_options.find(e=>e.id===re),onChange:e=>void P({..._,sort:e.id,offset:void 0},!0,!0),optionLabel:e=>e.label,by:`id`,disabled:T,"aria-label":m(`view.sort`),className:`min-w-44`})]})]})]}),t(Z6,{definition:I,request:_,result:C,contribution:i?.drop,canWrite:p,refresh:ye,children:t(de,{configuration:ne,definition:I,request:_,result:C,isLoading:T,onSortChange:e=>void P({..._,sort:e,offset:void 0},!0,!0),onOpenHit:a,resolveMedia:s,selection:le})}),(ge||_e)&&n(`nav`,{className:`flex items-center justify-center gap-2`,"aria-label":m(`view.pagination`),children:[n(o,{type:`button`,variant:`outline`,disabled:!ge||T,onClick:()=>void P({..._,offset:Math.max(0,me-he)||void 0},!0,!0),children:[t(oh,{className:`size-4 cn-rtl-flip`}),m(`grounded.previousPage`)]}),n(o,{type:`button`,variant:`outline`,disabled:!_e||T,onClick:()=>void P({..._,offset:me+he},!0,!0),children:[m(`grounded.nextPage`),t(lh,{className:`size-4 cn-rtl-flip`})]})]})]})]})})]});return t(q6,{definition:I,request:_,result:C,selection:le,contributions:i,client:d,canDelete:f,refresh:ye,children:be})}mY(),xY(),CY(),XY();export{Jp as ActivitiesDoc,Xp as ActivityDoc,p6 as AddToCollectionAction,d6 as AddToCollectionActionComponent,Yb as AgentApprovalModeSelector,uC as AgentChart,PJ as AgentChatFixtureReplay,xC as AgentChatPlaybackControls,St as AgentResourceResolverProvider,ZZ as AgentRunnerFacetsNav,e2 as AllOf,rW as AnimatedThinkingDots,$0 as AnyOf,WZ as ApiKeyAvatar,AH as AskUserWidget,Y0 as AudioPanel,W4 as BrowseCollectionView,v6 as ChangeTypeAction,g6 as ChangeTypeActionComponent,X4 as CollectionIcon,aQ as CollectionsFacetsNav,Y4 as CollectionsTable,jH as ConfirmationWidget,r1 as ContentDispositionButton,o3 as ContentObjectTypesSearch,Q4 as ContentObjectTypesTable,b4 as ContentOverview,q4 as CreateCollectionForm,J4 as CreateCollectionModal,$4 as CreateOrUpdateTypeModal,e8 as DefaultViewNavigation,H8 as DefaultViewResults,Y8 as DefaultViewSearch,S6 as DeleteObjectsAction,b6 as DeleteObjectsActionComponent,C6 as DeleteObjectsFromCollectionsAction,a4 as DocumentEditingPanel,i4 as DocumentEditingWorkspace,F$ as DocumentGridView,N$ as DocumentIcon,M$ as DocumentIconSkeleton,t6 as DocumentInput,n6 as DocumentPreviewPanel,I$ as DocumentSearch,t1 as DocumentSearchProvider,B4 as DocumentSearchResults,z4 as DocumentSearchResultsWithDropZone,JQ as DocumentSelection,QQ as DocumentSelectionProvider,X$ as DocumentTable,j$ as DocumentTableColumn,P$ as DocumentTableView,q$ as DocumentUploadModal,hQ as DocumentsFacetsNav,X3 as EditCollectionView,gQ as EnvironmentFacet,E6 as ExportPropertiesAction,w6 as ExportPropertiesComponent,a6 as ExportPropertiesModal,i6 as ExportTypes,U$ as FileUploadAction,l0 as GenericPageNavHeader,h0 as GroundedExtractionPanel,g0 as GroundedExtractionView,iZ as Header,X0 as ImagePanel,O3 as IntakePolicyEditor,_Z as InteractionLabel,gZ as InteractionStatusBadge,bQ as InteractionsFacetsNav,FJ as JumpingDots,gG as MESSAGE_STYLES,U0 as MagicPdfView,WJ as McpConnectionsActionMenu,HJ as McpConnectionsButton,VJ as McpConnectionsDialog,UJ as McpConnectionsInlineList,vG as MessageItem,G1 as MessagesContainer,B1 as ModernAgentConversation,u0 as NotFoundView,Q0 as OAuthProviderConnectButton,z3 as ObjectSchemaEditor,e3 as ObjectTypeSearch,t3 as ObjectTypeSearchContext,W3 as ObjectTypeSearchProvider,M6 as ObjectsActionContextProvider,t0 as PanelErrorBoundary,$X as PayloadBuilder,tZ as PayloadBuilderProvider,QX as PayloadBuilderStore,eZ as PayloadContext,dY as PdfDocumentRenderer,iY as PdfPageRenderer,hY as PdfPageSlider,uY as PdfThumbnailList,SQ as ProcessDefinitionsFacetsNav,wQ as ProcessRunsFacetsNav,kQ as PromptsFacetsNav,o4 as PropertiesEditorModal,iW as PulsatingCircle,oW as PulsingMessageLoader,mO as RemoteMcpConnectionButton,k6 as RemoveFromCollectionAction,D6 as RemoveFromCollectionActionComponent,r0 as RowErrorBoundary,FQ as RunsFacetsNav,X2 as SaveVersionConfirmModal,L$ as SearchContext,u2 as SecureButton,d2 as SecureSidebarItem,Q3 as SelectCollection,K4 as SelectContentType,U3 as SelectContentTypeModal,a1 as SelectDocument,$3 as SelectDocumentModal,q1 as SelectEnvironment,X1 as SelectModel,Z1 as SelectTrainingModel,I6 as SelectionActions,aY as SharedPdfProvider,q3 as SharedPropsEditor,sY as SimplePdfPage,SY as SimplePdfViewer,h1 as SkillWidgetProvider,jG as StreamingMessage,IQ as StringFacet,LQ as StringListFacet,J3 as SyncMemberHeadsToggle,G3 as TableLayoutEditor,sW as ThinkingBar,SW as ThinkingMessages,zQ as TypeFacet,QZ as TypeRegistry,eQ as TypeRegistryProvider,aW as TypedDots,YY as UniversalDocumentViewer,L6 as UploadObjectsButton,H6 as UserAvatar,BZ as UserInfo,l2 as UserPermissionProvider,a2 as UserPermissions,s2 as UserPermissionsContext,yZ as VInteractionFacet,CZ as VStringFacet,oQ as VTypeFacet,qZ as VUserFacet,oC as VegaLiteChart,Q1 as VertesiaErrorBoundary,Z0 as VideoPanel,q6 as ViewActionsProvider,J6 as ViewActionsToolbar,t5 as ViewExperience,Y6 as ViewRowActions,q0 as WEB_SUPPORTED_AUDIO_FORMATS,G0 as WEB_SUPPORTED_IMAGE_FORMATS,K0 as WEB_SUPPORTED_VIDEO_FORMATS,cW as WavyThinking,a0 as WidgetErrorBoundary,VQ as WorkflowDefinitionsFacetsNav,GQ as WorkflowExecutionsFacetsNav,qQ as WorkflowRulesFacetsNav,m8 as canonicalizeViewState,dC as clampPlaybackCursor,zJ as countConnectedActiveGroups,XZ as createAgentRunnerFilterHandler,t4 as createDocumentChangeSummaryPrompt,e4 as createDocumentReconcilePrompt,hC as createPlaybackState,uZ as createSearchQueryKeyGuard,cZ as filterValueToQueryValue,J0 as formatDuration,x8 as formatViewFieldValue,BJ as getConnectedActiveGroupLabels,eG as getContentObjectDownloadName,mC as getNextUserTurnIndex,fC as getPlaybackCursorIndex,pC as getPreviousUserTurnIndex,v8 as getViewFieldValue,b$ as getWorkflowStatusColor,x$ as getWorkflowStatusName,m2 as invalidateTypeCache,_C as isAgentChatPlaybackAvailable,vC as isAgentChatPlaybackEnabled,t2 as isAnyOf,l$ as isCsv,LJ as isGroupDisabled,u$ as isImage,yC as isLocalhostAgentChatPlaybackAvailable,bC as isLocalhostAgentChatPlaybackEnabled,d$ as isPdf,p$ as isPreviewableAsPdf,cC as isRechartsSpec,hZ as isUnresolvedInteractionRef,sC as isVegaLiteSpec,f$ as isVideo,s8 as parseViewState,m$ as printElementToPdf,g8 as replaceViewStateInUrl,mZ as resolveInteractionName,p2 as resolveTypeCached,h8 as resolveViewSort,_$ as retrieveRendition,d8 as serializeViewState,e0 as setErrorBoundaryComponent,lZ as setSearchQueryValue,v$ as shortId,y$ as shortenString,pZ as splitInteractionType,K3 as stringifyTableLayout,RJ as toggleGroupDisabled,sZ as unwrapFilterOptionValue,Gt as useAgentResourceResolver,YZ as useAgentRunnerFilterGroups,rQ as useCollectionsFilterGroups,iQ as useCollectionsFilterHandler,pQ as useDocumentFilterGroups,mQ as useDocumentFilterHandler,R$ as useDocumentSearch,V$ as useDocumentSearchCount,XQ as useDocumentSelection,J$ as useDocumentUploadHandler,tG as useDownloadFile,jZ as useFetchApiKeyInfo,AZ as useFetchGroupInfo,kZ as useFetchUserInfo,p0 as useGroundedExtractionAvailable,m0 as useGroundedSummary,vQ as useInteractionsFilterGroups,yQ as useInteractionsFilterHandler,IJ as useMcpConnections,pO as useOAuthPopup,ZQ as useOptionalDocumentSelection,nZ as usePayloadBuilder,xQ as useProcessDefinitionsFilterGroups,CQ as useProcessRunsFilterGroups,DQ as usePromptsFilterGroups,OQ as usePromptsFilterHandler,NQ as useRunsFilterGroups,PQ as useRunsFilterHandler,n3 as useSearch,i3 as useSearchCount,oY as useSharedPdf,K$ as useSmartFileUploadProcessing,tQ as useTypeRegistry,c2 as useUserPermissions,W6 as useViewActions,z$ as useWatchDocumentSearchFacets,B$ as useWatchDocumentSearchResult,r3 as useWatchSearchResult,BQ as useWorkflowDefinitionsFilterGroups,UQ as useWorkflowExecutionsFilterGroups,WQ as useWorkflowExecutionsFilterHandler,KQ as useWorkflowRulesFilterGroups};
1402
+ *`)),D=l?.content?.type?.startsWith(`image/`),O=l?.content?.type===`application/pdf`;return r?n(`div`,{className:`fixed inset-y-0 end-0 w-2/5 dark:bg-muted shadow-xl z-50 flex flex-col transition-transform duration-300 transform ${r?`translate-x-0`:`translate-x-full rtl:-translate-x-full`}`,children:[n(`div`,{className:`flex items-center justify-between px-4 py-3 border-b dark:border-border bg-gradient-to-r from-indigo-50 to-gray-50 dark:from-gray-800 dark:to-gray-900`,children:[n(`div`,{className:`flex items-center`,children:[t(Gg,{className:`h-5 w-5 text-info me-2`}),t(`h2`,{className:`text-lg font-semibold text-foreground truncate`,children:d?x(`store.loadingDocument`):l?.name||x(`store.documentPreview`)})]}),n(`div`,{className:`flex items-center gap-2`,children:[n(o,{variant:`ghost`,size:`sm`,onClick:T,className:`flex items-center gap-1 text-info hover:text-info`,children:[t(lv,{className:`h-4 w-4`}),t(`span`,{children:x(`store.fullView`)})]}),t(o,{variant:`ghost`,size:`sm`,onClick:i,className:`flex items-center text-muted hover:text-foreground dark:text-foreground`,children:t(Gb,{className:`h-5 w-5`})})]})]}),d?t(`div`,{className:`flex-1 flex items-center justify-center`,children:n(`div`,{className:`text-center`,children:[t(je,{size:`lg`,className:`text-info mb-2`}),t(`p`,{className:`text-muted`,children:x(`store.loadingDocument`)})]})}):n(`div`,{className:`flex-1 flex flex-col h-full`,children:[t(`div`,{className:`border-b`,children:n(`div`,{className:`flex px-4`,children:[t(o,{variant:`unstyled`,className:`py-2 px-4 font-medium border-b-2 ${y===`preview`?`border-primary text-info`:`border-transparent text-muted hover:text-foreground`}`,onClick:()=>b(`preview`),children:n(`div`,{className:`flex items-center gap-1`,children:[t(I_,{className:`h-4 w-4`}),t(`span`,{children:x(`store.preview`)})]})}),t(o,{variant:`unstyled`,className:`py-2 px-4 font-medium border-b-2 ${y===`properties`?`border-primary text-info`:`border-transparent text-muted hover:text-foreground`}`,onClick:()=>b(`properties`),children:n(`div`,{className:`flex items-center gap-1`,children:[t(A_,{className:`h-4 w-4`}),t(`span`,{children:x(`store.properties`)})]})})]})}),n(`div`,{className:`flex-1 overflow-auto p-4`,children:[y===`preview`&&n(`div`,{className:`h-full`,children:[p?t(`div`,{className:`flex items-center justify-center h-40`,children:t(je,{size:`md`,className:`text-info`})}):h?t(`div`,{className:`shadow rounded-md p-4 border border-border bg-white dark:bg-muted`,children:E?t(`div`,{className:`prose prose-sm max-w-none prose-p:my-2 prose-pre:bg-muted prose-pre:my-2 prose-headings:text-info dark:prose-invert`,children:t(Nt,{children:h})}):t(`pre`,{className:`text-wrap whitespace-pre-wrap dark:text-foreground`,children:h})}):null,D&&t(`div`,{className:`mt-4`,children:_?t(`div`,{className:`border border-border rounded-md p-2 bg-white dark:bg-muted`,children:t(`img`,{src:_,alt:l?.name,className:`mx-auto max-h-[70vh] object-contain`})}):t(`div`,{className:`flex items-center justify-center h-40`,children:t(je,{size:`md`,className:`text-info`})})}),O&&n(`div`,{className:`flex flex-col items-center justify-center h-64 border border-border rounded-md p-4 bg-muted`,children:[t(Gg,{className:`h-16 w-16 text-info mb-4`}),t(`p`,{className:`text-muted text-center mb-4`,children:x(`store.pdfPreviewFullView`)}),t(o,{onClick:T,className:`bg-primary hover:bg-primary text-white`,children:x(`store.openFullDocumentView`)})]}),!D&&!h&&!O&&!p&&n(`div`,{className:`flex flex-col items-center justify-center h-64 border border-border rounded-md p-4 bg-muted`,children:[t(Gg,{className:`h-16 w-16 text-foreground dark:text-muted mb-4`}),t(`p`,{className:`text-muted text-center`,children:x(`store.noPreviewAvailable`)})]})]}),y===`properties`&&l&&n(`div`,{className:`h-full`,children:[l.properties?t(`div`,{className:`shadow rounded-md p-4 border border-border bg-white dark:bg-muted`,children:t(jt,{value:l.properties})}):n(`div`,{className:`flex flex-col items-center justify-center h-64 border border-border rounded-md p-4 bg-muted`,children:[t(A_,{className:`h-16 w-16 text-foreground dark:text-muted mb-4`}),t(`p`,{className:`text-muted text-center`,children:x(`store.noPropertiesAvailable`)})]}),n(`div`,{className:`mt-4`,children:[t(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:x(`store.documentInformation`)}),t(`div`,{className:`shadow rounded-md p-4 border border-border bg-white dark:bg-muted`,children:n(`div`,{className:`grid grid-cols-2 gap-y-2 gap-x-4 text-sm`,children:[t(`div`,{className:`text-muted`,children:x(`store.id`)}),t(`div`,{className:`font-medium dark:text-foreground`,children:l.id}),t(`div`,{className:`text-muted`,children:x(`store.contentType`)}),t(`div`,{className:`font-medium dark:text-foreground`,children:l.type?.name||x(`store.unknown`)}),t(`div`,{className:`text-muted`,children:x(`store.contentType`)}),t(`div`,{className:`font-medium dark:text-foreground`,children:l.content?.type||x(`store.na`)}),t(`div`,{className:`text-muted`,children:x(`store.size`)}),t(`div`,{className:`font-medium`,children:l.content&&`size`in l.content?i6(l.content.size):x(`store.unknown`)}),t(`div`,{className:`text-muted`,children:x(`store.created`)}),t(`div`,{className:`font-medium`,children:l.created_at?new Date(l.created_at).toLocaleString():x(`store.na`)}),t(`div`,{className:`text-muted`,children:x(`store.updated`)}),t(`div`,{className:`font-medium`,children:l.updated_at?new Date(l.updated_at).toLocaleString():x(`store.na`)})]})})]})]})]})]}),n(`div`,{className:`flex items-center justify-between p-4 border-t bg-muted dark:border-border`,children:[t(`div`,{children:l?.content?.source&&n(o,{onClick:()=>{l?.content?.source&&s.files.getDownloadUrl(l.content.source).then(e=>{window.open(e.url,`_blank`)}).catch(e=>{console.error(`Error getting download URL:`,e),S({title:x(`agent.error`),description:x(`store.failedToDownloadFile`),status:`error`,duration:3e3})})},variant:`outline`,className:`text-info border-primary hover:bg-info`,children:[t(xg,{className:`h-4 w-4 me-2`}),x(`pdf.download`)]})}),n(o,{onClick:T,className:`bg-primary hover:bg-primary text-white`,children:[x(`store.openFullDocument`),t(lh,{className:`h-4 w-4 ms-2 cn-rtl-flip`})]})]})]}):null}function i6(e){if(e===0)return`0 Bytes`;let t=1024,n=[`Bytes`,`KB`,`MB`,`GB`,`TB`],r=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/t**r).toFixed(2))} ${n[r]}`}var a6;(function(e){e.CSV=`CSV`,e.JSON=`JSON`})(a6||={});function o6({isExporting:e,isOpen:r,onClose:i,allowExportAll:a=!0}){return n(se,{onClose:()=>i(void 0),isOpen:r,children:[t(ue,{children:`Export Object Properties`}),n(ce,{children:[!e&&t(s6,{onClose:i,allowExportAll:a}),e&&t(c6,{})]})]})}function s6({onClose:e,allowExportAll:r}){let{t:i}=K(),[a,s]=G(void 0),c=[`Export selected objects`,`Export all objects`],[l,u]=G(r?void 0:c[0]),d=e=>e===c[1];return n(ce,{className:`min-h-[104px] pt-0 flex flex-col gap-y-4`,children:[r&&t(`div`,{className:`h-1/3`,children:t(we,{options:c,value:l,onChange:u,placeholder:i(`store.chooseWhatToExport`),className:`h-full w-full text-sm`,filterBy:`name`,isClearable:!0})}),n(`div`,{className:`h-1/2 flex flex-col gap-y-8 content-between`,children:[t(we,{options:Object.values(a6),value:a,onChange:s,placeholder:i(`store.chooseAFormat`),className:`h-full w-full text-sm`,filterBy:`name`,isClearable:!0}),t(o,{className:`w-full`,isDisabled:!a||!l,onClick:()=>{e(a,d(l))},children:i(`store.actions.exportProperties`)})]})]})}function c6(){let{t:e}=K();return t(ce,{className:`min-h-[84px] pt-0`,children:n(`div`,{className:`h-full grid flex-col gap-y-2 content-between justify-items-center`,children:[n(`div`,{className:`text-sm flex flex-col gap-x-2`,children:[t(`p`,{children:e(`store.exportInProgress`)}),t(`p`,{className:`pt-2 grid justify-items-center`,children:e(`store.pleaseWait`)})]}),t(je,{size:`lg`})]})})}const l6=dt(void 0);function u6(){let e=_t(l6);if(!e)throw Error(`You cannot use useActionContext outside an ActionProvider`);return e}function d6(e,t){let n=u6();return H(()=>n.registerCallback(e,t),[n,e,t]),n}function f6({action:e,objectIds:n}){let[r,i]=G(!1),a=V(()=>(n.length>0&&i(!0),Promise.resolve(!0)),[n]);return d6(e.id,a),r&&t(ve,{children:t(h6,{objectIds:n,isOpen:r,onClose:()=>{i(!1)}})})}const p6=Xt.getFixedT(null,Yt),m6={id:`addToCollection`,name:p6(`store.actions.addToCollection`),description:p6(`store.actions.addToCollectionDesc`),confirm:!1,component:f6};function h6({isOpen:e,onClose:r,objectIds:i}){let{t:a}=K();return n(se,{isOpen:e,onClose:r,className:`max-w-lg w-full min-w-0 overflow-hidden`,children:[t(ue,{className:`flex flex-col min-w-0 overflow-hidden`,children:a(`store.actions.addToCollectionTitle`)}),t(S,{className:`min-w-0 overflow-hidden`,children:a(`store.actions.addToCollectionBody`)}),t(`div`,{className:`min-w-0 max-w-full overflow-hidden`,children:t(g6,{onClose:r,objectIds:i})})]})}function g6({onClose:e,objectIds:r}){let{t:i}=K(),a=nt(),{client:s}=q(),[c,l]=G(),u=({collectionId:t})=>{!t||!r?.length||s.store.collections.addMembers(t,r).then(()=>{a({title:i(`store.actions.addToCollectionSuccess`),status:`success`,description:i(`store.actions.addToCollectionSuccessDesc`,{count:r.length}),duration:3e3}),e()}).catch(()=>{a({title:i(`store.actions.addToCollectionFailure`),status:`error`,description:i(`store.actions.addToCollectionFailureDesc`),duration:5e3})})},d=[{name:`select`,label:i(`store.actions.selectCollection`),content:n(`div`,{className:`p-4 min-w-0 max-w-full overflow-hidden`,children:[t(ee,{level:5,children:i(`store.actions.chooseExistingCollections`)}),t(ce,{className:`min-w-0 max-w-full overflow-hidden`,children:t(`div`,{className:`mb-4 min-w-0 max-w-full overflow-hidden`,children:t($3,{onChange:(e,t)=>{typeof e==`string`||e===void 0?l(e):Array.isArray(e)&&e.length>0?l(e[0]):l(void 0)},value:c})})}),t(le,{children:t(o,{isDisabled:!c,onClick:()=>c&&u({collectionId:c}),children:i(`store.actions.addToCollectionButton`)})})]})},{name:`create`,label:i(`store.actions.createNew`),content:t(`div`,{className:`p-4`,children:t(J4,{onClose:e,onAddToCollection:e=>u({collectionId:e}),redirect:!1})})}];return n(ze,{defaultValue:`select`,tabs:d,fullWidth:!0,children:[t(Be,{}),t(Ve,{})]})}function _6({action:e,objectIds:r,children:i}){let{t:a}=K(),{store:o}=q(),s=nt(),[c,l]=G(!1),u=V(()=>(l(!0),Promise.resolve(!0)),[]);return d6(e.id,u),n(`div`,{children:[i,t(W3,{isOpen:c,onClose:e=>{l(!1),e!==void 0&&o.runOperation({name:`change_type`,ids:r,params:{typeId:e}}).then(e=>{s({status:`success`,title:a(`store.actions.changeType`),description:`Change the type of ${r.length} objects is ${e.status===`in_progress`?`in progress`:`completed`}`,duration:2e3})}).catch(e=>{s({status:`error`,title:a(`store.actions.errorChangingType`),description:e.message,duration:5e3})})},title:`Change Content Type`,confirmLabel:`Change Type`,children:n(`p`,{className:`pt-2 text-xs`,children:[`Note: This action will raise the `,t(`code`,{children:`change_type`}),` event and will trigger the standard intake workflows which may reset the object properties.`]})})]})}const v6=Xt.getFixedT(null,Yt),y6={id:`changeType`,name:v6(`store.actions.changeContentType`),description:v6(`store.actions.changeContentTypeDesc`),confirm:!1,component:_6};function b6({action:r,callback:i,children:a}){let{t:o}=K(),[s,c]=G(!1),l=r.confirmationText||`Are you sure you want to ${r.name}?`,u=V(e=>r.confirm?(c(!0),Promise.resolve(!0)):i(e),[r.confirm,i]),d=d6(r.id,u);return n(e,{children:[a,t(b,{onConfirm:()=>{c(!1),i({...d.params,action:r})},onCancel:()=>c(!1),title:o(`store.actions.areYouSure`),content:l,isOpen:s})]})}function x6({action:r,objectIds:i,children:a}){let{t:o}=K(),s=u6(),c=nt(),{client:l}=q(),u=z$(),d=Qn(),[f,p]=G(!1),m=i?.length??0,h=s.params?.type?.name??`object`,g=V(()=>(p(!0),Promise.resolve(!0)),[]);d6(r.id,g);let _=V(()=>(p(!1),i?.length?l.store.objects.delete(i).then(e=>{let t=e.deleted>1?`s`:``;if(c({status:`success`,title:`${e.deleted} object${t} deleted`,duration:2e3}),e.failed.length>0&&c({status:`warning`,title:`${e.failed.length} object(s) could not be deleted`,duration:3e3}),u){s.params?.selection?.removeAll();let t=JSON.parse(JSON.stringify(u.facets));i.length===t._value.total&&u.resetFacets();let n=new Set(e.failed);u.removeDeletedObjects(i.filter(e=>!n.has(e))),u.search()}else d(`/objects`)}).catch(e=>{c({status:`error`,title:o(`store.actions.errorDeletingObjects`),description:e.message,duration:5e3})}):(c({status:`error`,title:o(`store.actions.noObjectsSelected`),description:o(`store.actions.pleaseSelectObjectsToDelete`),duration:3e3}),Promise.resolve(!1))),[l.store.objects.delete,s.params?.selection?.removeAll,d,i,u,u?.facets,u?.resetFacets,u?.search,o,c]);return n(e,{children:[a,t(b,{isOpen:f,title:m===1?`Delete ${h}`:`Delete ${h}s`,content:n(`div`,{children:[n(`p`,{children:[`Delete `,m,` selected `,h,m===1?``:`s`,`? `,m===1?`This ${h}`:`These ${h}s`,` will be permanently removed.`]}),t(`p`,{children:t(`span`,{className:`text-destructive`,children:`This action cannot be undone.`})})]}),onConfirm:_,onCancel:()=>p(!1),confirmationValue:`delete`,confirmationLabel:`Type "delete" to confirm`,confirmationPlaceholder:`delete`})]})}const S6=Xt.getFixedT(null,Yt),C6={id:`delete`,name:S6(`store.actions.delete`),description:S6(`store.actions.deleteTheSelectedObjects`),confirm:!0,confirmationText:S6(`store.actions.confirmDeleteAll`),component:x6,destructive:!0},w6={id:`deleteFromCollections`,name:S6(`store.actions.deleteObjects`),description:S6(`store.actions.deleteTheSelectedObjects`),confirm:!0,confirmationText:S6(`store.actions.confirmDeleteSelected`),component:x6,destructive:!0};function T6({action:e,objectIds:n}){let{t:r}=K(),{store:i}=q(),a=nt(),[o,s]=G(!1),[c,l]=G(!1),u=V(()=>(s(!0),Promise.resolve(!0)),[]),d=d6(e.id,u);return t(o6,{isExporting:c,isOpen:o,onClose:(e,t)=>{if(e&&(t||n.length>0)){l(!0);let o=d.params?.search?.query||{},c=d.params?.search?.result?.value?.objects?.map(e=>e.id)||void 0,u=async e=>i.objects.list({query:{parent:e}}).then(e=>e.map(e=>e.id)),f=async()=>t?c?o.vector?c:[]:n.length===0?[]:(await u(n[0])).concat(n):n,p=d.params?.type?.id??o.type,m=d.params?.type?.table_layout??void 0;f().then(c=>{i.objects.exportProperties({objectIds:c,type:e,query:t&&!o.vector?{...o,type:p}:{type:p},table_layout:m}).then(e=>{let i=new Blob([e.data],{type:e.type}),o=window.URL.createObjectURL(i),s=document.createElement(`a`);s.download=e.name,s.href=o,s.click(),a({status:`success`,title:r(`store.actions.exportProperties`),description:t?`Export the properties of all objects completed`:`Export the properties of ${n.length} object${n.length>1?`s`:``} is completed`,duration:2e3})}).catch(e=>{a({status:`error`,title:r(`store.actions.errorExportProperties`),description:e.message,duration:5e3})}).finally(()=>{l(!1),s(!1)})})}else s(!1),a({status:`error`,title:r(`store.actions.errorExportProperties`),description:`No objects selected for export`,duration:5e3})}})}const E6=Xt.getFixedT(null,Yt),D6={id:`exportProperties`,name:E6(`store.actions.exportProperties`),description:E6(`store.actions.exportAllObjectProperties`),confirm:!1,component:T6};function O6({action:e,objectIds:n,collectionId:r}){let{t:i}=K(),a=u6(),o=nt(),{client:s}=q(),c=z$(),l=V(()=>n?.length?r?s.store.collections.deleteMembers(r,n).then(()=>{let e=n.length>1?`s`:``;o({status:`success`,title:`${n.length} object${e} removed from collection`,description:`Objects have been removed from the collection`,duration:2e3}),c&&(a.params?.selection?.removeAll(),c.search())}).catch(e=>{o({status:`error`,title:i(`store.actions.errorRemovingObjects`),description:Ge(e),duration:5e3})}):(o({status:`error`,title:i(`store.actions.noCollectionContext`),description:i(`store.actions.cannotRemoveNoCollection`),duration:3e3}),Promise.resolve(!1)):(o({status:`error`,title:i(`store.actions.noObjectsSelected`),description:i(`store.actions.pleaseSelectObjectsToRemove`),duration:3e3}),Promise.resolve(!1)),[s.store.collections.deleteMembers,r,a.params?.selection?.removeAll,n,c,c?.search,i,o]);return t(b6,{action:e,callback:l})}const k6=Xt.getFixedT(null,Yt),A6={id:`removeFromCollection`,name:k6(`store.actions.removeFromCollection`),description:k6(`store.actions.removeFromCollectionDesc`),confirm:!0,confirmationText:k6(`store.actions.confirmRemoveFromCollection`),component:O6,destructive:!0};var j6=class{params;allActions=[];callbacks={};constructor(e){this.params=e}get actions(){return this.params.selection?.collectionId?this.allActions.filter(e=>e.id!==`addToCollection`&&e.id!==`delete`):this.allActions.filter(e=>e.id!==`removeFromCollection`&&e.id!==`deleteFromCollections`)}registerCallback(e,t){return this.callbacks[e]=t,()=>{delete this.callbacks[e]}}unregisterCallback(e){delete this.callbacks[e]}findAction(e){return this.allActions.find(t=>t.id===e)}async run(e){let t=this.findAction(e);if(!t)throw Error(`Action ${e} not found`);let n={...this.params,action:t},r=this.callbacks[e];if(r)return r(n);throw Error(`No action callback set`)}};const M6=[D6,y6,m6,C6,A6,w6];function N6({children:e,type:r}){let i=ZQ(),a=nt(),{client:o}=q(),s=z$(),c=U(()=>{let e=new j6({selection:i,toast:a,client:o,search:s,type:r});return e.allActions=M6,e},[o,s,i,a,r]);return c&&n(l6.Provider,{value:c,children:[t(P6,{}),e]})}function P6(){let e=u6(),n=e.params.selection,r=n.getObjectId(),i=n.isSingleSelection()&&r?[r]:n.getObjectIds();return t(`div`,{style:{display:`none`},children:e.allActions.map(e=>t(e.component,{action:e,objectIds:i,collectionId:n.collectionId},e.id))})}function F6(){let{t:r}=K(),i=ZQ(),[a,s]=G(!1);return i?.hasSelection()?n(e,{children:[t(o,{onClick:()=>s(!0),children:r(`store.actions.startWorkflow`)}),a&&t(I6,{objectIds:i.getObjectIds(),onClose:()=>s(!1)})]}):null}function I6({objectIds:e,onClose:r}){let{t:i}=K(),{client:a}=q(),s=nt(),[c,l]=G(void 0),[u,d]=G(!1),{data:f,isLoading:p}=Ye(()=>a.store.workflows.rules.list(),[]);return n(se,{isOpen:!0,onClose:r,size:`lg`,children:[t(ue,{children:i(`store.actions.startWorkflowByRule`)}),n(ce,{children:[t(`div`,{className:`pb-2`,children:i(`store.actions.chooseWorkflowRule`)}),p?t(`div`,{className:`flex justify-center py-4`,children:t(je,{})}):t(`div`,{className:`max-h-[420px] overflow-y-auto border-border border rounded-md`,children:t(Te,{className:`text-start w-full`,options:f??[],value:c,onChange:l,optionLayout:e=>({label:e.name})})})]}),n(le,{align:`right`,children:[t(o,{variant:`outline`,onClick:r,disabled:u,children:`Cancel`}),t(o,{onClick:async()=>{if(!(!c||u)){d(!0);try{await a.store.workflows.rules.execute(c.id,e),s({title:i(`store.actions.workflowStarted`),status:`success`,duration:3e3}),r()}catch(e){s({title:i(`store.actions.errorStartingWorkflow`),description:e instanceof Error?e.message:void 0,status:`error`,duration:9e3})}finally{d(!1)}}},isDisabled:!c||u,isLoading:u,children:`Start`})]})]})}Q();function L6({type:e,allowMutations:r=!0,allowDelete:i=!0,allowWorkflowRun:a=!1}){let s=ZQ(),c=s.size(),l=c>1?`s`:``,u=s?.hasSelection(),d=s?.isSingleSelection();return t(N6,{type:e,children:n(`div`,{className:`flex items-center gap-x-2`,children:[u&&!d&&n(`div`,{className:`flex items-center gap-x-1 shrink-0`,children:[n(`div`,{className:`text-sm nowrap`,children:[c,` document`,l,` selected`]}),t(o,{title:`Clear selection`,variant:`ghost`,onClick:()=>{s?.removeAll()},children:t(Gb,{className:`size-4`})})]}),a&&t(F6,{}),t(B6,{selection:s,allowMutations:r,allowDelete:i,children:e=>e.length>0?t(o,{variant:`ghost`,title:`More action`,size:`sm`,children:t(wg,{size:16})}):null})]})})}function R6({collectionId:r,allowFolders:i=!0}){let{t:a}=K(),[s,c]=G([]),[l,u]=G(!1);return n(e,{children:[t(o,{onClick:()=>u(!0),children:a(`store.upload`)}),t(J$,{collectionId:r??``,isOpen:l,onClose:()=>{u(!1),c([])},files:s,title:`Upload Files`,onUploadComplete:e=>{e?.success&&c([])},allowFolders:i})]})}function z6(e){return{label:e.name,className:it(`flex-1 px-2 py-2 hover:bg-muted nowrap`,e.destructive?`text-destructive`:``)}}function B6({selection:e,children:r,allowMutations:i=!0,allowDelete:a=!0}){let o=u6(),s=e=>{o.run(e.id)},c=H6(o.actions,e,{allowMutations:i,allowDelete:a}),l=r(c);return l?n(he,{hover:!0,children:[t(_e,{children:l}),t(ge,{className:`p-0 w-50`,align:`end`,sideOffset:6,children:t(V6,{executeAction:s,actions:c})})]}):null}function V6({executeAction:e,actions:n}){return t(`div`,{className:`rounded-md shadow-md py-2`,children:t(`div`,{className:`px-1 text-sm`,children:t(Te,{options:n,optionLayout:z6,onChange:t=>{e(t)},noCheck:!0})})})}function H6(e,t,n){return t?.hasSelection()?e.filter(e=>e.hideInList?!1:e.id===`delete`||e.id===`deleteFromCollections`?n.allowDelete:e.id===`changeType`||e.id===`addToCollection`||e.id===`removeFromCollection`?n.allowMutations:!0):[D6]}function U6({user:e}){return n(`div`,{className:`flex items-center`,children:[t(`div`,{className:`w-9 h-9`,children:(()=>{if(e.picture)return t(`img`,{className:`inline-block h-9 w-9 rounded-full`,src:e.picture,alt:e.name});{let n=e.name.split(` `).map(e=>e[0]).join(``);return t(`span`,{className:`inline-flex h-8 w-8 items-center justify-center rounded-full bg-primary`,children:t(`span`,{className:`text-sm font-medium leading-none text-white`,children:n})})}})()}),n(`div`,{className:`ms-3`,children:[t(`p`,{className:`text-sm font-medium text-foreground group-hover:text-foreground`,children:e.name??`Deleted User`}),t(`p`,{className:`text-xs font-medium text-muted dark:text-foreground group-hover:text-foreground`,children:e.email??`Deleted User`})]})]})}Q();const W6=dt(void 0);function G6(){return _t(W6)}function K6(e,t){let n=e.requires_selection??(e.placement===`toolbar`?`none`:`any`);return n===`none`?!0:n===`single`?t.length===1:n===`multiple`?t.length>1:t.length>0}function q6(e){let t=window.URL.createObjectURL(new Blob([e.data],{type:e.type})),n=document.createElement(`a`);n.download=e.name,n.href=t,n.click(),window.setTimeout(()=>window.URL.revokeObjectURL(t),0)}function J6({children:e,definition:r,request:i,result:a,selection:o,contributions:s,client:c,canDelete:l,refresh:u}){let{t:d}=K(),f=nt(),[p,m]=G(),[h,g]=G(),[_,v]=G(!1),[y,x]=G(),S=W(!1),C=r.results?.actions,w=U(()=>({definition:r,request:i,result:a,refresh:u,clearSelection:()=>o?.clear()}),[r,u,i,a,o]),T=U(()=>{let e=(C?.items??[]).filter(e=>{let t=s?.actions?.[e.handler];return t!==void 0&&(t.isAvailable?.(w)??!0)});if(!o||C?.include_defaults===!1||!c)return e;let t=new Set(C?.exclude_defaults??[]),n=[];return t.has(`export`)||n.push({id:`export`,label:d(`store.actions.exportProperties`),handler:`export`,placement:`selection`,requires_selection:`any`}),l&&!t.has(`delete`)&&n.push({id:`delete`,label:d(`store.actions.delete`),handler:`delete`,placement:`selection`,requires_selection:`any`,destructive:!0,confirm:!0}),[...n,...e]},[C,w,l,c,s?.actions,o,d]),E=V(async({action:e,hits:t})=>{if(!S.current){S.current=!0,x(e.id);try{if(e.handler===`delete`){if(!c)return;let e=await c.store.objects.delete(t.map(e=>e.id));f({status:e.failed.length>0?`warning`:`success`,title:d(`view.deletedObjects`,{count:e.deleted})}),o?.clear(),await u();return}let n=s?.actions?.[e.handler];if(!n)return;await n.run({...w,action:e,hits:t})}catch(e){console.error(`View action failed:`,e),f({status:`error`,title:d(`view.actionFailed`),description:d(`view.actionFailedDescription`)})}finally{S.current=!1,x(void 0),m(void 0)}}},[w,c,s?.actions,u,o,d,f]),D=V((e,t)=>{if(!(!K6(e,t)||S.current)){if(e.handler===`export`){g(t);return}if(e.confirm){m({action:e,hits:t});return}E({action:e,hits:t})}},[E]),O=V(e=>{if(!e||!h?.length||!c){g(void 0);return}v(!0),c.store.objects.exportProperties({objectIds:h.map(e=>e.id),type:e}).then(e=>{q6(e),f({status:`success`,title:d(`store.actions.exportProperties`)}),g(void 0)}).catch(e=>{console.error(`View export failed:`,e),f({status:`error`,title:d(`store.actions.errorExportProperties`),description:d(`view.actionFailedDescription`)})}).finally(()=>v(!1))},[c,h,d,f]),k=U(()=>({actions:T,runningActionId:y,run:D}),[T,D,y]);return n(W6.Provider,{value:k,children:[e,t(o6,{isOpen:h!==void 0,isExporting:_,onClose:O,allowExportAll:!1}),t(b,{isOpen:p!==void 0,title:p?.action.label??d(`modal.confirm`),content:d(`view.confirmAction`,{action:p?.action.label??``,count:p?.hits.length??0}),isLoading:y!==void 0,onConfirm:()=>{p&&E(p)},onCancel:()=>m(void 0),confirmationValue:p?.action.handler===`delete`?`delete`:void 0,confirmationLabel:p?.action.handler===`delete`?d(`view.typeDeleteToConfirm`):void 0,confirmationPlaceholder:p?.action.handler===`delete`?`delete`:void 0})]})}function Y6({selection:r,page:i,showSelectPage:a=!1}){let{t:s}=K(),c=G6(),l=vt();if(!c)return null;let u=r?.selectedHits??[],d=r?i.filter(e=>r.isSelected(e.id)).length:0,f=i.length>0&&d===i.length,p=a&&r?.selectAll&&i.length>0,h=c.actions.filter(e=>((e.placement??`selection`)===`toolbar`||(e.placement??`selection`)===`selection`&&u.length>0)&&K6(e,u));return h.length===0&&u.length===0&&!p?null:n(`div`,{className:`flex flex-wrap items-center gap-2`,children:[p&&r&&n(`div`,{className:`flex items-center gap-2`,children:[t(m,{id:l,checked:f?!0:d>0&&`indeterminate`,onCheckedChange:e=>r.togglePage(i,e===!0)}),t(`label`,{htmlFor:l,className:`text-sm text-muted`,children:s(`view.selectPage`)})]}),u.length>0&&n(e,{children:[t(`span`,{className:`text-sm text-muted`,children:s(`view.selectedCount`,{count:u.length})}),t(o,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":s(`view.clearSelection`),onClick:r?.clear,children:t(Gb,{className:`size-4`})})]}),h.map(e=>n(o,{type:`button`,variant:e.destructive?`destructive`:`outline`,size:`sm`,disabled:c.runningActionId!==void 0,onClick:()=>c.run(e,u),children:[e.handler===`export`&&t(xg,{className:`size-4`}),e.handler===`delete`&&t(hb,{className:`size-4`}),e.label]},e.id))]})}function X6({hit:e}){let{t:r}=K(),i=G6(),a=i?.actions.filter(t=>(t.placement??`selection`)===`row`&&K6(t,[e]));return!i||!a?.length?null:n(he,{children:[t(_e,{children:t(o,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":r(`view.actions`),children:t(wg,{className:`size-4`})})}),t(ge,{className:`w-52 p-1`,align:`end`,sideOffset:6,children:t(Te,{options:a,optionLayout:e=>({label:e.label,className:e.destructive?`text-destructive`:void 0}),onChange:t=>i.run(t,[e]),noCheck:!0})})]})}function Z6(e){return e.dataTransfer.items?Array.from(e.dataTransfer.items).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>e!==null):Array.from(e.dataTransfer.files)}function Q6({children:r,definition:i,request:a,result:o,contribution:s,canWrite:c,refresh:l}){let{t:u}=K(),d=nt(),f=i.results?.drop,p=f?.handler===`upload`&&c,m=s!==void 0||p,[h,g]=G(!1),[_,v]=G(!1),[y,b]=G([]),x=W(!1),S=V(async e=>{if(e.length){if(s){if(x.current)return;x.current=!0,v(!0);try{await s.run({configuration:f,files:e,definition:i,request:a,result:o,refresh:l})}catch(e){console.error(`View drop action failed:`,e),d({status:`error`,title:u(`view.dropFailed`),description:u(`view.actionFailedDescription`)})}finally{x.current=!1,v(!1)}return}p&&b(e)}},[p,f,s,i,l,a,o,u,d]);if(!m)return r;let C=f?.params;return n(e,{children:[n(`div`,{className:`relative min-h-48`,onDragEnter:e=>{e.preventDefault(),g(!0)},onDragOver:e=>{e.preventDefault(),g(!0)},onDragLeave:e=>{e.preventDefault(),e.currentTarget.contains(e.relatedTarget)||g(!1)},onDrop:e=>{e.preventDefault(),e.stopPropagation(),g(!1),!e.target.closest(`[data-view-drop-zone]`)&&S(Z6(e))},children:[r,_&&t(`div`,{className:`absolute inset-0 z-40 flex items-center justify-center bg-background/80`,children:t(je,{size:`xl`})}),t(`div`,{"data-view-drop-zone":!0,className:`pointer-events-none absolute inset-0 ${h?`z-50`:`-z-10`}`,children:t(Ot,{onDrop:e=>void S(e),message:u(`view.dropFiles`),buttonLabel:u(`view.selectFiles`),allowFolders:C?.allow_folders??!0,className:`pointer-events-auto absolute inset-0 bg-background/90 ${h?`flex`:`hidden`}`})})]}),p&&t(J$,{isOpen:y.length>0,onClose:()=>b([]),files:y,collectionId:C?.collection_id,selectedFolder:C?.location,initialTypeId:C?.type_id,defaultProperties:C?.properties,allowFolders:C?.allow_folders??!0,title:u(`view.uploadToView`),onUploadComplete:e=>{e.success&&l()}})]})}Q();function $6(e,t,n,r){return n?r===!1?[t]:e.includes(t)?e:[...e,t]:e.filter(e=>e!==t)}function e8({node:e}){return n(`span`,{className:`flex min-w-0 flex-1 items-center justify-between gap-2`,children:[t(`span`,{className:`truncate`,children:e.label}),t(`span`,{className:`text-xs tabular-nums text-muted`,children:e.count})]})}function t8({configuration:e,result:r,isLoading:i,onChange:a,onQueryChange:s}){let{t:c}=K(),l=vt(),u=e.presentation??(e.source===`location`||e.source===`hierarchy`?`tree`:`list`),d=e.source!==`hierarchy`&&e.multi_select,f=r.breadcrumbs??[],[p,h]=G(r.query??``);H(()=>{h(r.query??``)},[r.query]);let g=(e,t)=>{a($6(r.selected,e,t,d))};return n(`section`,{className:`space-y-2`,"aria-labelledby":`${l}-label`,children:[n(`div`,{className:`flex items-center justify-between gap-2`,children:[t(`h2`,{id:`${l}-label`,className:`text-sm font-semibold`,children:e.label}),r.selected.length>0&&n(o,{type:`button`,variant:`ghost`,size:`sm`,disabled:i,onClick:()=>a([]),"aria-label":`${c(`filter.clearAll`)}: ${e.label}`,children:[t(Gb,{className:`size-3.5`}),c(`filter.clearAll`)]})]}),e.source===`collection`&&s&&n(`form`,{className:`flex items-center gap-1`,onSubmit:e=>{e.preventDefault(),s?.(p.trim())},children:[t(te,{value:p,onChange:h,disabled:i,placeholder:c(`view.filterNavigation`,{label:e.label}),"aria-label":c(`view.filterNavigation`,{label:e.label})}),t(o,{type:`submit`,variant:`outline`,size:`icon`,disabled:i,"aria-label":c(`view.searchNavigation`,{label:e.label}),children:t(Ay,{"aria-hidden":`true`,className:`size-4`})})]}),f.length>0&&t(`nav`,{"aria-label":`${e.label} path`,children:t(`ol`,{className:`flex flex-wrap items-center gap-1 text-sm`,children:f.map((e,r)=>n(`li`,{className:`flex items-center gap-1`,children:[r>0&&t(lh,{"aria-hidden":`true`,className:`size-3.5 text-muted`}),t(o,{type:`button`,variant:`ghost`,size:`sm`,disabled:i,onClick:()=>a([e.id]),"aria-current":r===f.length-1?`page`:void 0,children:e.label})]},e.id))})}),r.selected.length>0&&f.length===0&&(e.source===`location`||e.source===`collection`)&&t(`div`,{className:`flex flex-wrap gap-1`,children:r.selected.map(e=>{let a=r.nodes.find(t=>t.id===e)?.label??e;return n(o,{type:`button`,variant:`secondary`,size:`sm`,disabled:i,onClick:()=>g(e,!1),"aria-label":c(`view.removeSelection`,{value:a}),children:[a,t(Gb,{"aria-hidden":`true`,className:`size-3.5`})]},e)})}),u===`select`&&d===!1?t(we,{options:r.nodes,value:r.nodes.find(e=>r.selected.includes(e.id)),onChange:e=>a([e.id]),optionLabel:e=>`${e.label} (${e.count})`,by:`id`,disabled:i,placeholder:e.label,"aria-label":e.label}):u===`select`?t(we,{multiple:!0,options:r.nodes,value:r.nodes.filter(e=>r.selected.includes(e.id)),onChange:e=>a(e.map(e=>e.id)),optionLabel:e=>`${e.label} (${e.count})`,by:`id`,disabled:i,placeholder:e.label,"aria-label":e.label}):u===`chips`?t(`div`,{className:`flex flex-wrap gap-2`,children:r.nodes.map(e=>n(o,{type:`button`,variant:r.selected.includes(e.id)?`secondary`:`outline`,size:`sm`,disabled:i,onClick:()=>g(e.id,!r.selected.includes(e.id)),children:[e.label,t(`span`,{className:`text-xs tabular-nums text-muted`,children:e.count})]},e.id))}):e.source===`hierarchy`?t(`div`,{className:`space-y-1`,children:r.nodes.map(e=>n(o,{type:`button`,variant:r.selected.includes(e.id)?`secondary`:`ghost`,className:`w-full justify-start`,disabled:i,onClick:()=>a([e.id]),children:[t(e8,{node:e}),e.expandable&&t(lh,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted`})]},e.id))}):t(`div`,{className:`space-y-1`,children:r.nodes.map((e,a)=>{let o=`${l}-${a}`;return n(`div`,{className:`flex items-center gap-2 rounded-md px-2 py-1.5 hover:bg-muted`,children:[t(m,{id:o,checked:r.selected.includes(e.id),disabled:i,onCheckedChange:t=>g(e.id,t===!0)}),t(`label`,{htmlFor:o,className:`flex min-w-0 flex-1 cursor-pointer text-sm`,children:t(e8,{node:e})})]},e.id)})}),r.nodes.length===0&&t(`p`,{className:`text-sm text-muted`,children:c(`filter.noAvailableFilters`)})]})}const n8=`display`,r8=`sort`,i8=`offset`;function a8(e){if(e===null||e.trim()===``)return;let t=Number(e);return Number.isSafeInteger(t)&&t>=0?t:void 0}function o8(e,t){let n={};for(let r of new Set(e.keys())){if(!r.startsWith(t)||r.length===t.length)continue;let i=e.getAll(r).filter(e=>e!==``);i.length>0&&(n[r.slice(t.length)]=i)}return Object.keys(n).length>0?n:void 0}function s8(e,t){let n={};for(let r of new Set(e.keys())){if(!r.startsWith(t)||r.length===t.length)continue;let i=e.get(r)?.trim();i&&(n[r.slice(t.length)]=i)}return Object.keys(n).length>0?n:void 0}function c8(e){let t=new URLSearchParams(e.startsWith(`?`)?e.slice(1):e),n=t.get(`q`)?.trim(),r=t.get(n8)?.trim(),i=t.get(r8)?.trim(),a=a8(t.get(i8)),o=o8(t,`t.`),s=o8(t,`n.`),c=s8(t,`nq.`);return{...n?{query:n}:{},...o?{key_terms:o}:{},...s?{navigation:s}:{},...c?{navigation_queries:c}:{},...r?{display:r}:{},...i?{sort:i}:{},...a?{offset:a}:{}}}function l8(e){for(let t of[...e.keys()])(t===`q`||t===n8||t===r8||t===i8||t.startsWith(`t.`)||t.startsWith(`nq.`)||t.startsWith(`n.`))&&e.delete(t)}function u8(e,t,n){if(n)for(let[r,i]of Object.entries(n).sort(([e],[t])=>e.localeCompare(t)))for(let n of i)n!==``&&e.append(`${t}${r}`,n)}function d8(e,t,n){if(n)for(let[r,i]of Object.entries(n).sort(([e],[t])=>e.localeCompare(t)))i.trim()&&e.set(`${t}${r}`,i.trim())}function f8(e,t=``){let n=new URLSearchParams(t.startsWith(`?`)?t.slice(1):t);l8(n),e.query?.trim()&&n.set(`q`,e.query.trim()),e.display&&n.set(n8,e.display),e.sort&&n.set(r8,e.sort),e.offset&&e.offset>0&&n.set(i8,String(e.offset)),u8(n,`t.`,e.key_terms),u8(n,`n.`,e.navigation),d8(n,`nq.`,e.navigation_queries);let r=n.toString();return r?`?${r}`:``}function p8(e){let t=Object.fromEntries(Object.entries(e.navigation).filter(([,e])=>e.selected.length>0).map(([e,t])=>[e,t.selected]));return Object.keys(t).length>0?t:void 0}function m8(e){let t={};for(let[n,r]of Object.entries(e.navigation))r.query&&(t[n]=r.query);return Object.keys(t).length>0?t:void 0}function h8(e,t){let n=new Set(t.definition.search?.key_terms?.map(e=>e.id)??[]),r=e.key_terms?Object.fromEntries(Object.entries(e.key_terms).filter(([e,t])=>n.has(e)&&t.length)):void 0,i=p8(t),a=m8(t);return{...e.query?.trim()?{query:e.query.trim()}:{},...r&&Object.keys(r).length>0?{key_terms:r}:{},...i?{navigation:i}:{},...a?{navigation_queries:a}:{},...t.display?{display:t.display}:{},...t.sort?{sort:t.sort}:{},...e.offset&&e.offset>0?{offset:e.offset}:{},...e.limit?{limit:e.limit}:{}}}function g8(e,t,n){return t.sort??e.sort??(e.query?.trim()?void 0:n)}function _8(e){if(typeof window>`u`)return;let t=f8(e,window.location.search);window.history.replaceState(window.history.state||{},``,`${window.location.pathname}${t}`)}Q();function v8(e,t){return!t||t===`.`?e:t.split(`.`).reduce((e,t)=>{if(!(!e||typeof e!=`object`||Array.isArray(e)))return e[t]},e)}function y8(e,t){return t===`score`?e.score:t.startsWith(`annotation.`)?v8(e.annotation,t.slice(11)):t.startsWith(`document.`)?v8(e.document,t.slice(9)):v8(e.document,t)}const b8=dt(void 0);function x8(e){if(e!=null&&e!==``)return Array.isArray(e)?e.map(x8).filter(Boolean).join(`, `):typeof e==`object`?JSON.stringify(e):String(e)}function S8(e,t,n){let r=y8(e,t.field),i=t.fallback??``;if(r==null||r===``)return i;if(t.format===`date`){let e=String(r),t=/^\d{4}-\d{2}-\d{2}$/.test(e),a=new Date(e);if(Number.isNaN(a.getTime()))return x8(r)??i;let o={year:`numeric`,month:`numeric`,day:`numeric`,...t?{timeZone:`UTC`}:{}};return n?.formatDate(a,o)??new Intl.DateTimeFormat(void 0,o).format(a)}if(t.format===`number`){let e=typeof r==`number`?r:Number(r);return Number.isFinite(e)?n?.formatNumber(e)??new Intl.NumberFormat().format(e):x8(r)??i}return x8(r)??i}function C8({hit:e,field:n,className:r}){let a=S8(e,n,_t(b8));return a?n.format===`badge`||n.format===`content_type`?t(i,{className:r,children:a}):t(`span`,{className:r,children:a}):null}function w8({hit:e,onOpenHit:r,compact:i=!1}){let{t:a}=K();return r?i?t(We,{description:a(`agent.openDocument`),asChild:!0,children:t(o,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":a(`agent.openDocument`),onClick:()=>r(e),children:t(Dg,{className:`size-4`})})}):n(o,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r(e),children:[t(Dg,{className:`size-4`}),a(`agent.openDocument`)]}):null}function T8(e,t){if(t.source!==`property`||!t.field)return;let n=x8(y8(e,t.field));if(n)try{let e=new URL(n,typeof window>`u`?`https://localhost`:window.location.origin);return e.protocol===`http:`||e.protocol===`https:`?e.toString():void 0}catch{return}}const E8=new WeakMap,D8=[2e3,4e3,8e3];function O8(e){let t=E8.get(e);if(t)return t;let n=new Map;return E8.set(e,n),n}function k8(e,t,n){let r=O8(e),i=r.get(t);if(i)return i;let a=n().finally(()=>{r.delete(t)});return r.set(t,a),a}function A8({hit:e,media:n,resolveMedia:r,className:i}){let a=n?T8(e,n):void 0,[o,s]=G(),[c,l]=G(!1),u=!a&&n?`${e.id}|${JSON.stringify(n)}`:void 0,d=W(e),f=W(n);d.current=e,f.current=n,H(()=>{if(s(void 0),l(!1),!u||!r)return;let e=!0,t,n=i=>{k8(r,u,async()=>r(d.current,f.current)).then(r=>{if(!e)return;if(r){s(r);return}let a=D8[i];a!==void 0&&(t=setTimeout(()=>n(i+1),a))}).catch(()=>{e&&l(!0)})};return n(0),()=>{e=!1,t&&clearTimeout(t)}},[u,r,a]);let p=c?void 0:a??o,m=n?.fit===`contain`?`object-contain`:`object-cover`;if(p)return t(`img`,{src:p,alt:``,className:`${m} ${i??``}`,onError:()=>l(!0)});let h=n?.source===`type_icon`?`type_icon`:n?.fallback??`type_icon`;return h===`none`?null:t(`div`,{className:`flex items-center justify-center bg-muted ${i??``}`,"aria-hidden":`true`,children:t(h===`placeholder`?D_:Gg,{className:`size-10 text-muted`})})}function j8({hit:e}){let n=e.annotation?.why_match??e.annotation?.answer??e.annotation?.excerpt;return n?t(`p`,{className:`text-sm text-info`,children:n}):null}function M8({hit:e,page:n,selection:r}){let{t:i}=K(),a=W(!1);return r?t(m,{checked:r.isSelected(e.id),"aria-label":i(`view.selectResult`,{name:e.document.name}),onClick:e=>{a.current=e.shiftKey,e.stopPropagation()},onCheckedChange:t=>{r.toggle(e,t===!0,{page:n,range:r.mode===`multiple`&&a.current}),a.current=!1}}):null}function N8({hit:e,fields:n}){return n?.length?t(`div`,{className:`flex flex-wrap gap-1`,children:n.map(n=>t(C8,{hit:e,field:n},`${n.field}-${n.label??``}`))}):null}function P8({hit:e,fields:r}){let i=_t(b8);return r?.length?t(`dl`,{className:`space-y-1 text-sm`,children:r.map(r=>{let a=S8(e,r,i);return a?n(`div`,{className:`flex gap-2`,children:[r.label&&t(`dt`,{className:`shrink-0 text-muted`,children:r.label}),t(`dd`,{className:`min-w-0 truncate`,children:a})]},`${r.field}-${r.label??``}`):null})}):null}function F8({display:e,hits:r,onOpenHit:i,resolveMedia:a,selection:o}){return t(`div`,{className:`divide-y divide-border rounded-md border`,children:r.map(s=>n(`article`,{className:`flex gap-4 p-4 ${o?.isSelected(s.id)?`bg-muted/40`:``}`,children:[o&&t(`div`,{className:`pt-1`,children:t(M8,{hit:s,page:r,selection:o})}),e.media&&t(A8,{hit:s,media:e.media,resolveMedia:a,className:`size-20 shrink-0 rounded-md`}),n(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[n(`div`,{children:[t(`h3`,{className:`font-semibold`,children:t(C8,{hit:s,field:e.title})}),e.subtitle&&t(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1 text-sm text-muted`,children:e.subtitle.map(e=>t(C8,{hit:s,field:e},e.field))})]}),e.description&&t(`p`,{className:`line-clamp-3 text-sm text-muted`,children:t(C8,{hit:s,field:e.description})}),t(N8,{hit:s,fields:e.badges}),t(j8,{hit:s})]}),n(`div`,{className:`shrink-0 self-center`,children:[t(w8,{hit:s,onOpenHit:i,compact:!0}),t(X6,{hit:s})]})]},s.id))})}function I8({display:e,hits:r,isLoading:i,onOpenHit:a,sortOptions:o,currentSort:s,onSortChange:c,selection:l}){let{t:u}=K(),d=G6()?.actions.some(e=>e.placement===`row`)??!1,f=l?r.filter(e=>l.isSelected(e.id)).length:0,p=r.length>0&&f===r.length;return t(`div`,{className:`overflow-x-auto rounded-md border`,children:n(Le,{className:`w-full`,children:[t(Fe,{children:n(`tr`,{children:[l&&t(Re,{className:`w-0`,children:l.selectAll&&t(m,{checked:p?!0:f>0&&`indeterminate`,"aria-label":u(`view.selectPage`),onCheckedChange:e=>l.togglePage(r,e===!0)})}),e.columns.map(e=>{let n=e.sort_option?o?.find(t=>t.id===e.sort_option):void 0;if(!e.sortable||!n)return t(Re,{children:e.label??e.field},`${e.field}-${e.label??``}`);let r=s===n.id?n.sort[0]?.order===`desc`?`descending`:`ascending`:`none`;return t(Ae,{sortDirection:r,onSort:()=>c?.(n.id),disabled:i||!c,sortIndicator:e=>e===`ascending`?t(fh,{className:`size-3`,"aria-hidden":`true`}):e===`descending`?t(rh,{className:`size-3`,"aria-hidden":`true`}):t(wh,{className:`size-3 text-muted`,"aria-hidden":`true`}),children:e.label??e.field},`${e.field}-${e.label??``}`)}),(a||d)&&t(Re,{className:`w-0`,children:t(`span`,{className:`sr-only`,children:u(d?`view.actions`:`agent.openDocument`)})})]})}),t(Pe,{isLoading:i&&r.length===0,columns:e.columns.length+ +!!l+(a||d?1:0),children:r.map(i=>n(`tr`,{className:l?.isSelected(i.id)?`bg-muted/40`:void 0,children:[l&&t(`td`,{className:`w-0`,children:t(M8,{hit:i,page:r,selection:l})}),e.columns.map(e=>t(`td`,{style:e.width?{width:e.width}:void 0,children:t(C8,{hit:i,field:e})},`${i.id}-${e.field}`)),(a||d)&&t(`td`,{className:`w-0 whitespace-nowrap text-end`,children:n(`div`,{className:`flex items-center justify-end gap-1`,children:[t(w8,{hit:i,onOpenHit:a,compact:!0}),t(X6,{hit:i})]})})]},i.id))})]})})}const L8={2:`md:grid-cols-2`,3:`md:grid-cols-2 xl:grid-cols-3`,4:`md:grid-cols-2 xl:grid-cols-4`,5:`md:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-5`,6:`md:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-6`};function R8({hit:e,configuration:r,onOpenHit:i,resolveMedia:a,selection:o,page:p}){let m=G6()?.actions.some(e=>e.placement===`row`)??!1;return n(s,{className:`relative flex h-full min-w-0 flex-col overflow-hidden ${o?.isSelected(e.id)?`ring-2 ring-primary`:``}`,children:[o&&t(`div`,{className:`absolute start-2 top-2 z-10 rounded bg-background/80 p-1`,children:t(M8,{hit:e,page:p,selection:o})}),r.media&&t(A8,{hit:e,media:r.media,resolveMedia:a,className:`h-40 w-full border-b`}),n(d,{className:`gap-2 p-4`,children:[t(N8,{hit:e,fields:r.badges}),t(f,{className:`truncate text-base`,children:t(C8,{hit:e,field:r.title})}),r.description&&t(l,{className:`line-clamp-3`,children:t(C8,{hit:e,field:r.description})})]}),n(c,{className:`flex-1 p-4 pt-0`,children:[t(P8,{hit:e,fields:r.fields}),t(j8,{hit:e})]}),(i||m)&&n(u,{className:`justify-end p-4 pt-0`,children:[t(w8,{hit:e,onOpenHit:i}),t(X6,{hit:e})]})]})}function z8({display:e,hits:n,onOpenHit:r,resolveMedia:i,selection:a}){return t(`div`,{className:`grid grid-cols-1 gap-4 ${L8[e.columns??3]}`,children:n.map(o=>t(R8,{hit:o,configuration:e,onOpenHit:r,resolveMedia:i,selection:a,page:n},o.id))})}function B8({display:e,hits:r,onOpenHit:i,resolveMedia:a,selection:o}){return t(`div`,{className:`grid grid-cols-1 gap-4 ${L8[e.columns??4]}`,children:r.map(l=>n(s,{className:`relative overflow-hidden ${o?.isSelected(l.id)?`ring-2 ring-primary`:``}`,children:[o&&t(`div`,{className:`absolute start-2 top-2 z-10 rounded bg-background/80 p-1`,children:t(M8,{hit:l,page:r,selection:o})}),t(A8,{hit:l,media:e.media,resolveMedia:a,className:`aspect-square w-full border-b`}),n(c,{className:`space-y-2 p-3`,children:[t(`h3`,{className:`truncate font-semibold`,children:t(C8,{hit:l,field:e.title})}),e.caption&&t(`div`,{className:`space-y-1 text-sm text-muted`,children:e.caption.map(e=>t(`div`,{className:`truncate`,children:t(C8,{hit:l,field:e})},e.field))}),n(`div`,{className:`flex items-center justify-end gap-1`,children:[t(w8,{hit:l,onOpenHit:i}),t(X6,{hit:l})]})]})]},l.id))})}function V8({display:e,hits:r,onOpenHit:a,resolveMedia:o,selection:s}){let c=new Map;for(let t of r){let n=x8(y8(t,e.group_by))??``;c.set(n,[...c.get(n)??[],t])}let l=e.columns?.length?[...e.columns].sort((e,t)=>(e.order??0)-(t.order??0)):[...c.keys()].sort().map(e=>({value:e,label:e||`—`}));return t(`div`,{className:`flex min-w-max gap-4 overflow-x-auto pb-2`,children:l.map(l=>{let u=c.get(l.value)??[];return n(`section`,{className:`w-80 shrink-0 space-y-3 rounded-lg bg-muted/40 p-3`,children:[n(`div`,{className:`flex items-center justify-between gap-2`,children:[t(`h3`,{className:`font-semibold`,children:l.label}),t(i,{children:u.length})]}),t(`div`,{className:`space-y-3`,children:u.map(n=>t(R8,{hit:n,configuration:e.card,onOpenHit:a,resolveMedia:o,selection:s,page:r},n.id))})]},l.value)})})}function H8(e,n,r,i,a,o,s,c,l){return e.type===`table`?t(I8,{display:e,hits:n,isLoading:r,onOpenHit:i,sortOptions:o,currentSort:s,onSortChange:c,selection:l}):e.type===`cards`?t(z8,{display:e,hits:n,onOpenHit:i,resolveMedia:a,selection:l}):e.type===`gallery`?t(B8,{display:e,hits:n,onOpenHit:i,resolveMedia:a,selection:l}):e.type===`board`?t(V8,{display:e,hits:n,onOpenHit:i,resolveMedia:a,selection:l}):t(F8,{display:e,hits:n,onOpenHit:i,resolveMedia:a,selection:l})}function U8({configuration:e,definition:n,request:r,result:i,isLoading:a,onSortChange:o,onOpenHit:s,resolveMedia:c,selection:l}){let{t:u}=K(),d=Zt();return!a&&i.hits.length===0?t(`p`,{className:`py-12 text-center text-sm text-muted`,children:u(`filter.noResultsFound`)}):t(b8.Provider,{value:d,children:H8(e,i.hits,a,s,c,n.results?.sort_options,g8(r,i,n.results?.default_sort),o,l)})}Q();function W8(e,t){return t?`text`:e===`number`?`number`:e===`date`?`date`:`text`}function G8(e){let[t=``,n=``]=(e[0]??``).split(`..`,2);return[t,n]}function K8(e,t){return e||t?[`${e}..${t}`]:[]}function q8(e,t){return t?e.join(`, `):e[0]??``}function J8(e,t){return t?e.split(`,`).map(e=>e.trim()).filter(Boolean):e.trim()?[e.trim()]:[]}function Y8({term:e,values:n,isLoading:r,onChange:i}){let a=W(!1),o=W(void 0),[s,c]=G(()=>q8(n,e.multiple)),l=q8(n,e.multiple);return H(()=>{a.current&&o.current===l||c(l),o.current=void 0},[l]),t(L,{label:e.label,children:t(te,{type:W8(e.type,e.multiple),name:`view-key-term-${e.id}`,autoComplete:`off`,value:s,onFocus:()=>{a.current=!0},onBlur:()=>{a.current=!1;let t=J8(s,e.multiple);c(q8(t,e.multiple))},onChange:t=>{c(t);let n=J8(t,e.multiple);o.current=q8(n,e.multiple),i(n)},placeholder:e.label,disabled:r})})}function X8({configuration:e,query:r,keyTerms:i,isLoading:a,onQueryChange:s,onKeyTermsChange:c,onSubmit:l}){let{t:u}=K(),d=vt(),f=e.key_terms?.filter(e=>e.operator!==`range`)??[],p=e.key_terms?.filter(e=>e.operator===`range`)??[];return n(`form`,{className:`flex flex-col gap-3`,"aria-label":u(`layout.search`),autoComplete:`off`,onSubmit:e=>{e.preventDefault(),l()},children:[n(`div`,{className:`flex items-center gap-2`,children:[t(`label`,{htmlFor:d,className:`sr-only`,children:u(`layout.search`)}),t(te,{id:d,name:`view-query`,autoComplete:`off`,value:r,onChange:s,placeholder:e.placeholder??u(`store.searchPlaceholder`),disabled:a}),n(o,{type:`submit`,disabled:a,className:`shrink-0`,children:[t(Ay,{className:`size-4`}),u(a?`store.searching`:`store.search`)]})]}),e.key_terms&&e.key_terms.length>0&&n(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:[f.length>0&&n(`fieldset`,{className:`rounded-md border border-mixer-muted/30 bg-mixer-muted/5 p-3 ${p.length===0?`lg:col-span-2`:``}`,children:[t(`legend`,{className:`px-1 text-xs font-medium text-muted`,children:u(`view.searchFields`)}),t(`div`,{className:`grid gap-3 sm:grid-cols-2 ${p.length===0?`lg:grid-cols-4`:``}`,children:f.map(e=>t(Y8,{term:e,values:i[e.id]??[],isLoading:a,onChange:t=>c(e.id,t)},e.id))})]}),p.length>0&&n(`fieldset`,{className:`rounded-md border border-mixer-muted/30 bg-mixer-muted/5 p-3 ${f.length===0?`lg:col-span-2`:``}`,children:[t(`legend`,{className:`px-1 text-xs font-medium text-muted`,children:u(`view.ranges`)}),t(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:p.map(e=>{let[r,o]=G8(i[e.id]??[]),s=e.type===`number`?`number`:e.type===`date`?`date`:`text`;return n(`fieldset`,{className:`min-w-0`,children:[t(`legend`,{className:`mb-1 text-sm font-medium`,children:e.label}),n(`div`,{className:`grid grid-cols-2 gap-2`,children:[t(te,{type:s,name:`view-key-term-${e.id}-from`,autoComplete:`off`,"aria-label":`${e.label}: ${u(`view.from`)}`,value:r,onChange:t=>c(e.id,K8(t.trim(),o)),placeholder:u(`view.from`),disabled:a}),t(te,{type:s,name:`view-key-term-${e.id}-to`,autoComplete:`off`,"aria-label":`${e.label}: ${u(`view.to`)}`,value:o,onChange:t=>c(e.id,K8(r,t.trim())),placeholder:u(`view.to`),disabled:a})]})]},e.id)})})]})]})]})}Q();const Z8={id:`default`,label:`Results`,type:`list`,title:{field:`name`},subtitle:[{field:`type.name`,format:`content_type`},{field:`location`,format:`location`}],description:{field:`description`}};function Q8(e){return!e||typeof window>`u`?{}:c8(window.location.search)}function $8(e){let t=Object.fromEntries(Object.entries(e).filter(([,e])=>e.length>0));return Object.keys(t).length>0?t:void 0}function e5(e){let t=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.trim()]).filter(([,e])=>e.length>0));return Object.keys(t).length>0?t:void 0}function t5(e){let{client:n}=q(),r=_t(c2),i=V(t=>n.views.execute(e.viewId,t),[n,e.viewId]),a=V(async(e,t)=>{if(t.source!==`content_thumbnail`)return;let r=e.document.content;try{let t=await n.objects.getRenditionSafe(e.id,r?.type,{format:mn.jpeg,max_hw:512,generate_if_missing:!1,sign_url:!0});if(t?.status===`found`&&t.renditions?.length)return t.renditions[0]}catch{}if(r?.source&&r.type?.startsWith(`image/`))return(await n.files.getDownloadUrl(r.source)).url},[n]),o=e=>r!==void 0&&e.some(e=>r.hasPermission(e));return t(r5,{...e,execute:i,resolveMedia:e.resolveMedia??a,client:n,canDelete:o([yn.content_delete,yn.content_admin,yn.content_superadmin]),canWrite:o([yn.content_write,yn.content_admin,yn.content_superadmin])})}function n5({execute:e,...n}){return e?t(r5,{...n,execute:e},n.viewId):t(t5,{...n},n.viewId)}function r5({execute:e,renderers:r,contributions:i,onOpenHit:a,resolveMedia:s,syncUrl:c=!0,showHeader:l=!0,className:u,client:d,canDelete:f=!1,canWrite:p=!1}){let{t:m}=K(),h=W(e);h.current=e;let g=W(0),[_,v]=G(()=>Q8(c)),[y,b]=G(_.query??``),[x,S]=G(_.key_terms??{}),[C,w]=G(),[T,E]=G(!0),[D,O]=G(),[k,A]=G({}),j=W(void 0),N=V(()=>{j.current=void 0,A({})},[]),P=V((e,t,n=!1)=>{let r=++g.current;return n||N(),v(e),t&&c&&_8(e),E(!0),O(void 0),h.current(e).then(t=>{if(r===g.current){let n=h8(e,t);v(n),c&&_8(n),w(t)}}).catch(e=>{r===g.current&&O(e instanceof Error?e:Error(String(e)))}).finally(()=>{r===g.current&&E(!1)})},[N,c]),F=V(()=>{let e=Q8(c);return b(e.query??``),S(e.key_terms??{}),P(e,!1)},[P,c]);H(()=>(F(),()=>{g.current+=1}),[F]),H(()=>{if(!c||typeof window>`u`)return;let e=()=>void F();return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[F,c]);let I=C?.definition,L=U(()=>[...I?.navigation??[]].sort((e,t)=>(e.order??0)-(t.order??0)),[I?.navigation]),ee=I?.results,R=ee?.selection,te=C?.display??_.display??ee?.default_display,ne=ee?.displays.find(e=>e.id===te)??Z8,re=C?g8(_,C,ee?.default_sort):_.sort,ie=e=>{P(e,!0)},ae=(e,t)=>{let n=$8({..._.navigation??{},[e.id]:t});ie({..._,navigation:n,offset:void 0})},se=(e,t)=>{let n=e5({..._.navigation_queries??{},[e.id]:t});ie({..._,navigation_queries:n,offset:void 0})},ce=()=>{ie({..._,query:y.trim()||void 0,key_terms:$8(x),offset:void 0})},le=U(()=>{if(!R)return;let e=Object.keys(k);return{mode:R.mode,selectAll:R.mode===`multiple`&&R.select_all===`page`,selectedIds:e,selectedHits:e.map(e=>k[e]).filter(e=>e!==void 0),isSelected:e=>k[e]!==void 0,toggle:(e,t,n)=>{A(r=>{if(!t){let t={...r};return delete t[e.id],t}if(R.mode===`single`)return j.current=e.id,{[e.id]:e};let i={...r,[e.id]:e};if(n?.range&&n.page&&j.current){let t=n.page.findIndex(e=>e.id===j.current),r=n.page.findIndex(t=>t.id===e.id);if(t>=0&&r>=0){let e=Math.min(t,r),a=Math.max(t,r);for(let t of n.page.slice(e,a+1))i[t.id]=t}}return j.current=e.id,i})},togglePage:(e,t)=>{R.mode===`multiple`&&A(n=>{let r={...n};for(let n of e)t?r[n.id]=n:delete r[n.id];return r})},clear:N}},[N,k,R]);if(!C&&T)return t(`div`,{className:`flex h-full min-h-48 items-center justify-center`,children:t(je,{size:`xl`})});if(!C||!I)return t(`div`,{className:`flex h-full min-h-48 items-center justify-center p-4`,children:t(M,{title:m(`store.searchFailed`),action:()=>void F(),actionLabel:m(`agent.retry`),children:m(`store.searchFailed`)})});let ue=I.search?.renderer?r?.search?.[I.search.renderer]??X8:X8,de=ne.renderer?r?.results?.[ne.renderer]??U8:U8,fe=L.length>0&&I.layout?.navigation_position!==`top`,pe=I.layout?.mode===`worklist`,me=_.offset??0,he=_.limit??ne.page_size??20,ge=me>0,_e=me+C.hits.length<C.total,ve=L.map(e=>{let n=C.navigation[e.id]??{id:e.id,selected:[],nodes:[]},i=e.renderer?r?.navigation?.[e.renderer]??t8:t8;return t(i,{configuration:e,result:n,isLoading:T,onChange:t=>ae(e,t),onQueryChange:e.source===`collection`?t=>se(e,t):void 0},e.id)}),ye=()=>P(_,!1,!0),be=n(ir,{className:u,children:[l&&t(u0,{title:I.name,description:I.description}),n(ir.Fixed,{heightClass:`h-auto`,className:`space-y-3 border-b p-3`,children:[I.search&&t(ue,{configuration:I.search,query:y,keyTerms:x,isLoading:T,onQueryChange:b,onKeyTermsChange:(e,t)=>S(n=>({...n,[e]:t})),onSubmit:ce}),L.length>0&&I.layout?.navigation_position===`top`&&t(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:ve})]}),t(ir.Body,{className:`p-0`,children:n(`div`,{className:fe?pe?`grid min-h-full lg:grid-cols-[minmax(0,1fr)_18rem]`:`grid min-h-full lg:grid-cols-[18rem_minmax(0,1fr)]`:`min-h-full`,children:[fe&&t(`aside`,{className:pe?`space-y-5 border-b p-4 lg:order-2 lg:border-s lg:border-b-0`:`space-y-5 border-b p-4 lg:border-e lg:border-b-0`,children:ve}),n(`main`,{className:`min-w-0 space-y-4 p-4 ${pe?`lg:order-1`:``}`,children:[D&&t(M,{title:m(`store.searchFailed`),action:()=>void P(_,!1),actionLabel:m(`agent.retry`),children:m(`store.searchFailed`)}),C.search.warnings.length>0&&t(oe,{status:`warning`,title:m(`view.warning`),children:t(`ul`,{className:`list-disc space-y-1 ps-4`,children:C.search.warnings.map(e=>t(`li`,{children:e.message},`${e.code}-${e.path??``}`))})}),n(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[n(`div`,{className:`flex items-center gap-2 text-sm text-muted`,children:[t(`span`,{children:m(`view.resultsCount`,{count:C.total})}),T&&t(je,{size:`sm`})]}),n(`div`,{className:`flex flex-wrap items-center gap-3`,children:[t(Y6,{selection:le,page:C.hits,showSelectPage:ne.type!==`table`}),ee?.allow_display_switch&&ee.displays.length>1&&n(`div`,{className:`flex items-center gap-2`,children:[t(`span`,{className:`text-sm text-muted`,children:m(`view.display`)}),t(we,{options:ee.displays,value:ne,onChange:e=>void P({..._,display:e.id,offset:void 0},!0,!0),optionLabel:e=>e.label,by:`id`,disabled:T,"aria-label":m(`view.display`),className:`min-w-36`})]}),ee?.sort_options&&ee.sort_options.length>0&&n(`div`,{className:`flex items-center gap-2`,children:[t(`span`,{className:`text-sm text-muted`,children:m(`view.sort`)}),t(we,{options:ee.sort_options,value:ee.sort_options.find(e=>e.id===re),onChange:e=>void P({..._,sort:e.id,offset:void 0},!0,!0),optionLabel:e=>e.label,by:`id`,disabled:T,"aria-label":m(`view.sort`),className:`min-w-44`})]})]})]}),t(Q6,{definition:I,request:_,result:C,contribution:i?.drop,canWrite:p,refresh:ye,children:t(de,{configuration:ne,definition:I,request:_,result:C,isLoading:T,onSortChange:e=>void P({..._,sort:e,offset:void 0},!0,!0),onOpenHit:a,resolveMedia:s,selection:le})}),(ge||_e)&&n(`nav`,{className:`flex items-center justify-center gap-2`,"aria-label":m(`view.pagination`),children:[n(o,{type:`button`,variant:`outline`,disabled:!ge||T,onClick:()=>void P({..._,offset:Math.max(0,me-he)||void 0},!0,!0),children:[t(oh,{className:`size-4 cn-rtl-flip`}),m(`grounded.previousPage`)]}),n(o,{type:`button`,variant:`outline`,disabled:!_e||T,onClick:()=>void P({..._,offset:me+he},!0,!0),children:[m(`grounded.nextPage`),t(lh,{className:`size-4 cn-rtl-flip`})]})]})]})]})})]});return t(J6,{definition:I,request:_,result:C,selection:le,contributions:i,client:d,canDelete:f,refresh:ye,children:be})}hY(),SY(),wY(),ZY();export{Jp as ActivitiesDoc,Xp as ActivityDoc,m6 as AddToCollectionAction,f6 as AddToCollectionActionComponent,Yb as AgentApprovalModeSelector,uC as AgentChart,FJ as AgentChatFixtureReplay,xC as AgentChatPlaybackControls,St as AgentResourceResolverProvider,QZ as AgentRunnerFacetsNav,t2 as AllOf,iW as AnimatedThinkingDots,e2 as AnyOf,GZ as ApiKeyAvatar,jH as AskUserWidget,X0 as AudioPanel,G4 as BrowseCollectionView,y6 as ChangeTypeAction,_6 as ChangeTypeActionComponent,Z4 as CollectionIcon,oQ as CollectionsFacetsNav,X4 as CollectionsTable,MH as ConfirmationWidget,i1 as ContentDispositionButton,s3 as ContentObjectTypesSearch,$4 as ContentObjectTypesTable,x4 as ContentOverview,J4 as CreateCollectionForm,Y4 as CreateCollectionModal,e3 as CreateOrUpdateTypeModal,t8 as DefaultViewNavigation,U8 as DefaultViewResults,X8 as DefaultViewSearch,C6 as DeleteObjectsAction,x6 as DeleteObjectsActionComponent,w6 as DeleteObjectsFromCollectionsAction,o4 as DocumentEditingPanel,a4 as DocumentEditingWorkspace,I$ as DocumentGridView,P$ as DocumentIcon,N$ as DocumentIconSkeleton,n6 as DocumentInput,r6 as DocumentPreviewPanel,L$ as DocumentSearch,n1 as DocumentSearchProvider,V4 as DocumentSearchResults,B4 as DocumentSearchResultsWithDropZone,YQ as DocumentSelection,$Q as DocumentSelectionProvider,Z$ as DocumentTable,M$ as DocumentTableColumn,F$ as DocumentTableView,J$ as DocumentUploadModal,gQ as DocumentsFacetsNav,Z3 as EditCollectionView,_Q as EnvironmentFacet,D6 as ExportPropertiesAction,T6 as ExportPropertiesComponent,o6 as ExportPropertiesModal,a6 as ExportTypes,W$ as FileUploadAction,u0 as GenericPageNavHeader,g0 as GroundedExtractionPanel,_0 as GroundedExtractionView,aZ as Header,Z0 as ImagePanel,k3 as IntakePolicyEditor,vZ as InteractionLabel,_Z as InteractionStatusBadge,xQ as InteractionsFacetsNav,IJ as JumpingDots,_G as MESSAGE_STYLES,W0 as MagicPdfView,GJ as McpConnectionsActionMenu,UJ as McpConnectionsButton,HJ as McpConnectionsDialog,WJ as McpConnectionsInlineList,yG as MessageItem,K1 as MessagesContainer,V1 as ModernAgentConversation,d0 as NotFoundView,$0 as OAuthProviderConnectButton,B3 as ObjectSchemaEditor,t3 as ObjectTypeSearch,n3 as ObjectTypeSearchContext,G3 as ObjectTypeSearchProvider,N6 as ObjectsActionContextProvider,n0 as PanelErrorBoundary,eZ as PayloadBuilder,nZ as PayloadBuilderProvider,$X as PayloadBuilderStore,tZ as PayloadContext,fY as PdfDocumentRenderer,aY as PdfPageRenderer,gY as PdfPageSlider,dY as PdfThumbnailList,CQ as ProcessDefinitionsFacetsNav,TQ as ProcessRunsFacetsNav,AQ as PromptsFacetsNav,s4 as PropertiesEditorModal,aW as PulsatingCircle,sW as PulsingMessageLoader,mO as RemoteMcpConnectionButton,A6 as RemoveFromCollectionAction,O6 as RemoveFromCollectionActionComponent,i0 as RowErrorBoundary,IQ as RunsFacetsNav,Z2 as SaveVersionConfirmModal,R$ as SearchContext,d2 as SecureButton,f2 as SecureSidebarItem,$3 as SelectCollection,q4 as SelectContentType,W3 as SelectContentTypeModal,o1 as SelectDocument,e6 as SelectDocumentModal,J1 as SelectEnvironment,Z1 as SelectModel,Q1 as SelectTrainingModel,L6 as SelectionActions,oY as SharedPdfProvider,J3 as SharedPropsEditor,cY as SimplePdfPage,CY as SimplePdfViewer,g1 as SkillWidgetProvider,MG as StreamingMessage,LQ as StringFacet,RQ as StringListFacet,Y3 as SyncMemberHeadsToggle,K3 as TableLayoutEditor,cW as ThinkingBar,CW as ThinkingMessages,BQ as TypeFacet,$Z as TypeRegistry,tQ as TypeRegistryProvider,oW as TypedDots,XY as UniversalDocumentViewer,R6 as UploadObjectsButton,U6 as UserAvatar,VZ as UserInfo,u2 as UserPermissionProvider,o2 as UserPermissions,c2 as UserPermissionsContext,bZ as VInteractionFacet,wZ as VStringFacet,sQ as VTypeFacet,JZ as VUserFacet,oC as VegaLiteChart,$1 as VertesiaErrorBoundary,Q0 as VideoPanel,J6 as ViewActionsProvider,Y6 as ViewActionsToolbar,n5 as ViewExperience,X6 as ViewRowActions,J0 as WEB_SUPPORTED_AUDIO_FORMATS,K0 as WEB_SUPPORTED_IMAGE_FORMATS,q0 as WEB_SUPPORTED_VIDEO_FORMATS,lW as WavyThinking,o0 as WidgetErrorBoundary,HQ as WorkflowDefinitionsFacetsNav,KQ as WorkflowExecutionsFacetsNav,JQ as WorkflowRulesFacetsNav,h8 as canonicalizeViewState,dC as clampPlaybackCursor,BJ as countConnectedActiveGroups,ZZ as createAgentRunnerFilterHandler,n4 as createDocumentChangeSummaryPrompt,t4 as createDocumentReconcilePrompt,hC as createPlaybackState,dZ as createSearchQueryKeyGuard,lZ as filterValueToQueryValue,Y0 as formatDuration,S8 as formatViewFieldValue,VJ as getConnectedActiveGroupLabels,tG as getContentObjectDownloadName,mC as getNextUserTurnIndex,fC as getPlaybackCursorIndex,pC as getPreviousUserTurnIndex,y8 as getViewFieldValue,x$ as getWorkflowStatusColor,S$ as getWorkflowStatusName,h2 as invalidateTypeCache,_C as isAgentChatPlaybackAvailable,vC as isAgentChatPlaybackEnabled,n2 as isAnyOf,u$ as isCsv,RJ as isGroupDisabled,d$ as isImage,yC as isLocalhostAgentChatPlaybackAvailable,bC as isLocalhostAgentChatPlaybackEnabled,f$ as isPdf,m$ as isPreviewableAsPdf,cC as isRechartsSpec,gZ as isUnresolvedInteractionRef,sC as isVegaLiteSpec,p$ as isVideo,c8 as parseViewState,h$ as printElementToPdf,_8 as replaceViewStateInUrl,hZ as resolveInteractionName,m2 as resolveTypeCached,g8 as resolveViewSort,v$ as retrieveRendition,f8 as serializeViewState,t0 as setErrorBoundaryComponent,uZ as setSearchQueryValue,y$ as shortId,b$ as shortenString,mZ as splitInteractionType,q3 as stringifyTableLayout,zJ as toggleGroupDisabled,cZ as unwrapFilterOptionValue,Gt as useAgentResourceResolver,XZ as useAgentRunnerFilterGroups,iQ as useCollectionsFilterGroups,aQ as useCollectionsFilterHandler,mQ as useDocumentFilterGroups,hQ as useDocumentFilterHandler,z$ as useDocumentSearch,H$ as useDocumentSearchCount,ZQ as useDocumentSelection,Y$ as useDocumentUploadHandler,nG as useDownloadFile,MZ as useFetchApiKeyInfo,jZ as useFetchGroupInfo,AZ as useFetchUserInfo,m0 as useGroundedExtractionAvailable,h0 as useGroundedSummary,yQ as useInteractionsFilterGroups,bQ as useInteractionsFilterHandler,LJ as useMcpConnections,pO as useOAuthPopup,QQ as useOptionalDocumentSelection,rZ as usePayloadBuilder,SQ as useProcessDefinitionsFilterGroups,wQ as useProcessRunsFilterGroups,OQ as usePromptsFilterGroups,kQ as usePromptsFilterHandler,PQ as useRunsFilterGroups,FQ as useRunsFilterHandler,r3 as useSearch,a3 as useSearchCount,sY as useSharedPdf,q$ as useSmartFileUploadProcessing,nQ as useTypeRegistry,l2 as useUserPermissions,G6 as useViewActions,B$ as useWatchDocumentSearchFacets,V$ as useWatchDocumentSearchResult,i3 as useWatchSearchResult,VQ as useWorkflowDefinitionsFilterGroups,WQ as useWorkflowExecutionsFilterGroups,GQ as useWorkflowExecutionsFilterHandler,qQ as useWorkflowRulesFilterGroups};
1403
1403
  //# sourceMappingURL=vertesia-ui-features.js.map