@autoai-ui/autoui 0.2.5 â 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +107 -55
- package/dist/index.mjs +2186 -2085
- package/dist/lib/index.d.ts +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("react"),Fo=require("react-dom");function Mn(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:()=>e[o]})}}return t.default=e,Object.freeze(t)}const Mt=Mn(I);var bt={exports:{}},ot={};var fo;function Vn(){if(fo)return ot;fo=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function o(n,s,r){var a=null;if(r!==void 0&&(a=""+r),s.key!==void 0&&(a=""+s.key),"key"in s){r={};for(var i in s)i!=="key"&&(r[i]=s[i])}else r=s;return s=r.ref,{$$typeof:e,type:n,key:a,ref:s!==void 0?s:null,props:r}}return ot.Fragment=t,ot.jsx=o,ot.jsxs=o,ot}var nt={};var mo;function Nn(){return mo||(mo=1,process.env.NODE_ENV!=="production"&&(function(){function e(E){if(E==null)return null;if(typeof E=="function")return E.$$typeof===j?null:E.displayName||E.name||null;if(typeof E=="string")return E;switch(E){case x:return"Fragment";case p:return"Profiler";case y:return"StrictMode";case C:return"Suspense";case d:return"SuspenseList";case A:return"Activity"}if(typeof E=="object")switch(typeof E.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),E.$$typeof){case v:return"Portal";case $:return E.displayName||"Context";case g:return(E._context.displayName||"Context")+".Consumer";case b:var F=E.render;return E=E.displayName,E||(E=F.displayName||F.name||"",E=E!==""?"ForwardRef("+E+")":"ForwardRef"),E;case w:return F=E.displayName||null,F!==null?F:e(E.type)||"Memo";case k:F=E._payload,E=E._init;try{return e(E(F))}catch{}}return null}function t(E){return""+E}function o(E){try{t(E);var F=!1}catch{F=!0}if(F){F=console;var G=F.error,K=typeof Symbol=="function"&&Symbol.toStringTag&&E[Symbol.toStringTag]||E.constructor.name||"Object";return G.call(F,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",K),t(E)}}function n(E){if(E===x)return"<>";if(typeof E=="object"&&E!==null&&E.$$typeof===k)return"<...>";try{var F=e(E);return F?"<"+F+">":"<...>"}catch{return"<...>"}}function s(){var E=M.A;return E===null?null:E.getOwner()}function r(){return Error("react-stack-top-frame")}function a(E){if(z.call(E,"key")){var F=Object.getOwnPropertyDescriptor(E,"key").get;if(F&&F.isReactWarning)return!1}return E.key!==void 0}function i(E,F){function G(){Y||(Y=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",F))}G.isReactWarning=!0,Object.defineProperty(E,"key",{get:G,configurable:!0})}function l(){var E=e(this.type);return Q[E]||(Q[E]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),E=this.props.ref,E!==void 0?E:null}function c(E,F,G,K,Le,Me){var ee=G.ref;return E={$$typeof:T,type:E,key:F,props:G,_owner:K},(ee!==void 0?ee:null)!==null?Object.defineProperty(E,"ref",{enumerable:!1,get:l}):Object.defineProperty(E,"ref",{enumerable:!1,value:null}),E._store={},Object.defineProperty(E._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(E,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(E,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:Le}),Object.defineProperty(E,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Me}),Object.freeze&&(Object.freeze(E.props),Object.freeze(E)),E}function u(E,F,G,K,Le,Me){var ee=F.children;if(ee!==void 0)if(K)if(V(ee)){for(K=0;K<ee.length;K++)m(ee[K]);Object.freeze&&Object.freeze(ee)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else m(ee);if(z.call(F,"key")){ee=e(E);var P=Object.keys(F).filter(function(ne){return ne!=="key"});K=0<P.length?"{key: someKey, "+P.join(": ..., ")+": ...}":"{key: someKey}",be[ee+K]||(P=0<P.length?"{"+P.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,K,ee,P,ee),ve[ee+K]=!0)}if(ee=null,G!==void 0&&(o(G),ee=""+G),a(_)&&(o(_.key),ee=""+_.key),"key"in _){G={};for(var J in _)J!=="key"&&(G[J]=_[J])}else G=_;return ee&&i(G,typeof I=="function"?I.displayName||I.name||"Unknown":I),c(I,ee,G,r(),Le,Me)}function p(I){m(I)?I._store&&(I._store.validated=1):typeof I=="object"&&I!==null&&I.$$typeof===k&&(I._payload.status==="fulfilled"?m(I._payload.value)&&I._payload.value._store&&(I._payload.value._store.validated=1):I._store&&(I._store.validated=1))}function m(I){return typeof I=="object"&&I!==null&&I.$$typeof===$}var h=C,$=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),d=Symbol.for("react.profiler"),g=Symbol.for("react.consumer"),T=Symbol.for("react.context"),b=Symbol.for("react.forward_ref"),E=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),v=Symbol.for("react.memo"),k=Symbol.for("react.lazy"),A=Symbol.for("react.activity"),j=Symbol.for("react.client.reference"),N=h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,z=Object.prototype.hasOwnProperty,V=Array.isArray,D=console.createTask?console.createTask:function(){return null};h={react_stack_bottom_frame:function(I){return I()}};var X,Q={},we=h.react_stack_bottom_frame.bind(h,s)(),xe=D(n(s)),ve={};nt.Fragment=w,nt.jsx=function(I,_,G){var K=1e4>N.recentlyCreatedOwnerStacks++;return u(I,_,G,!1,K?Error("react-stack-top-frame"):we,K?D(n(I)):xe)},nt.jsxs=function(I,_,G){var K=1e4>N.recentlyCreatedOwnerStacks++;return u(I,_,G,!0,K?Error("react-stack-top-frame"):we,K?D(n(I)):xe)}})()),nt}var ho;function zn(){return ho||(ho=1,process.env.NODE_ENV==="production"?xt.exports=Vn():xt.exports=Nn()),xt.exports}var S=zn();function Ho(e){var t,o,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(o=Ho(e[t]))&&(n&&(n+=" "),n+=o)}else for(o in e)e[o]&&(n&&(n+=" "),n+=o);return n}function ye(){for(var e,t,o=0,n="",r=arguments.length;o<r;o++)(e=arguments[o])&&(t=Ho(e))&&(n&&(n+=" "),n+=t);return n}const _n=C.forwardRef(({variant:e="default",label:t,className:o,classNames:n={},color:r="currentColor",...s},a)=>{const i=C.useMemo(()=>{switch(e){case"wave":case"dots":return S.jsx("div",{className:ye("spinner-dots-wrapper",n.wrapper),children:[0,1,2].map(l=>S.jsx("i",{className:ye("spinner-dot",n.dots),style:{animationDelay:`${l*.2}s`,backgroundColor:r}},l))});case"simple":return S.jsxs("svg",{className:ye("spinner-simple",n.wrapper),width:"24",height:"24",fill:"none",viewBox:"0 0 24 24",style:{color:r},children:[S.jsx("circle",{className:ye("spinner-simple-circle1",n.circle1),cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),S.jsx("path",{className:ye("spinner-simple-circle2",n.circle2),fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.37 0 0 5.37 0 12h4z"})]});case"spinner":return S.jsx("div",{className:ye("spinner-bars-wrapper",n.wrapper),children:[...Array(12)].map((l,c)=>S.jsx("i",{className:ye("spinner-bar",n.spinnerBars),style:{transform:`rotate(${c*30}deg) translateY(-8px)`,animationDelay:`${c*.1}s`,backgroundColor:r}},c))});default:return S.jsxs("div",{className:ye("spinner-default",n.wrapper),children:[S.jsx("i",{className:ye("spinner-default-circle1",n.circle1),style:{borderColor:r}}),S.jsx("i",{className:ye("spinner-default-circle2",n.circle2),style:{borderColor:r}})]})}},[e,n,r]);return S.jsxs("div",{ref:a,className:ye("spinner-base",o),"aria-label":t||"Loading",...s,children:[i,t&&S.jsx("span",{className:ye("spinner-label",n.label),children:t})]})}),Bo=C.createContext(void 0),Hn=({children:e,value:t,config:o})=>S.jsx(Bo.Provider,{value:{...t,config:o},children:e}),Ge=()=>{const e=C.useContext(Bo);if(!e)throw new Error("useChatContext must be used within a ChatProvider");return e};function Ae(...e){return e.filter(Boolean).join(" ")}const Fo="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3c!--%20Uploaded%20to:%20SVG%20Repo,%20www.svgrepo.com,%20Generator:%20SVG%20Repo%20Mixer%20Tools%20--%3e%3csvg%20width='800px'%20height='800px'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4%2012H20M12%204V20'%20stroke='%23000000'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",Do="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20640%20640'%3e%3c!--!Font%20Awesome%20Free%207.1.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license/free%20Copyright%202025%20Fonticons,%20Inc.--%3e%3cpath%20d='M183.1%20137.4C170.6%20124.9%20150.3%20124.9%20137.8%20137.4C125.3%20149.9%20125.3%20170.2%20137.8%20182.7L275.2%20320L137.9%20457.4C125.4%20469.9%20125.4%20490.2%20137.9%20502.7C150.4%20515.2%20170.7%20515.2%20183.2%20502.7L320.5%20365.3L457.9%20502.6C470.4%20515.1%20490.7%20515.1%20503.2%20502.6C515.7%20490.1%20515.7%20469.8%20503.2%20457.3L365.8%20320L503.1%20182.6C515.6%20170.1%20515.6%20149.8%20503.1%20137.3C490.6%20124.8%20470.3%20124.8%20457.8%20137.3L320.5%20274.7L183.1%20137.4z'/%3e%3c/svg%3e",Uo="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3c!--%20Uploaded%20to:%20SVG%20Repo,%20www.svgrepo.com,%20Generator:%20SVG%20Repo%20Mixer%20Tools%20--%3e%3csvg%20width='800px'%20height='800px'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M12%206V18M12%206L7%2011M12%206L17%2011'%20stroke='%23000000'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",Bn="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3c!--%20Uploaded%20to:%20SVG%20Repo,%20www.svgrepo.com,%20Generator:%20SVG%20Repo%20Mixer%20Tools%20--%3e%3csvg%20width='800px'%20height='800px'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4%2018L20%2018'%20stroke='%23000000'%20stroke-width='2'%20stroke-linecap='round'/%3e%3cpath%20d='M4%2012L20%2012'%20stroke='%23000000'%20stroke-width='2'%20stroke-linecap='round'/%3e%3cpath%20d='M4%206L20%206'%20stroke='%23000000'%20stroke-width='2'%20stroke-linecap='round'/%3e%3c/svg%3e",Fn="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3c!--%20Uploaded%20to:%20SVG%20Repo,%20www.svgrepo.com,%20Generator:%20SVG%20Repo%20Mixer%20Tools%20--%3e%3csvg%20width='800px'%20height='800px'%20viewBox='0%200%201024%201024'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill='%23000000'%20d='M352%20192V95.936a32%2032%200%200%201%2032-32h256a32%2032%200%200%201%2032%2032V192h256a32%2032%200%201%201%200%2064H96a32%2032%200%200%201%200-64h256zm64%200h192v-64H416v64zM192%20960a32%2032%200%200%201-32-32V256h704v672a32%2032%200%200%201-32%2032H192zm224-192a32%2032%200%200%200%2032-32V416a32%2032%200%200%200-64%200v320a32%2032%200%200%200%2032%2032zm192%200a32%2032%200%200%200%2032-32V416a32%2032%200%200%200-64%200v320a32%2032%200%200%200%2032%2032z'/%3e%3c/svg%3e",Dn="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20640%20640'%3e%3c!--!Font%20Awesome%20Free%207.1.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license/free%20Copyright%202025%20Fonticons,%20Inc.--%3e%3cpath%20d='M210.2%2053.9C217.6%2050.8%20226%2051.7%20232.7%2056.1L320.5%20114.3L408.3%2056.1C415%2051.7%20423.4%2050.9%20430.8%2053.9C438.2%2056.9%20443.4%2063.5%20445%2071.3L465.9%20174.5L569.1%20195.4C576.9%20197%20583.5%20202.4%20586.5%20209.7C589.5%20217%20588.7%20225.5%20584.3%20232.2L526.1%20320L584.3%20407.8C588.7%20414.5%20589.5%20422.9%20586.5%20430.3C583.5%20437.7%20576.9%20443.1%20569.1%20444.6L465.8%20465.4L445%20568.7C443.4%20576.5%20438%20583.1%20430.7%20586.1C423.4%20589.1%20414.9%20588.3%20408.2%20583.9L320.4%20525.7L232.6%20583.9C225.9%20588.3%20217.5%20589.1%20210.1%20586.1C202.7%20583.1%20197.3%20576.5%20195.8%20568.7L175%20465.4L71.7%20444.5C63.9%20442.9%2057.3%20437.5%2054.3%20430.2C51.3%20422.9%2052.1%20414.4%2056.5%20407.7L114.7%20320L56.5%20232.2C52.1%20225.5%2051.3%20217.1%2054.3%20209.7C57.3%20202.3%2063.9%20196.9%2071.7%20195.4L175%20174.6L195.9%2071.3C197.5%2063.5%20202.9%2056.9%20210.2%2053.9zM239.6%20320C239.6%20275.6%20275.6%20239.6%20320%20239.6C364.4%20239.6%20400.4%20275.6%20400.4%20320C400.4%20364.4%20364.4%20400.4%20320%20400.4C275.6%20400.4%20239.6%20364.4%20239.6%20320zM448.4%20320C448.4%20249.1%20390.9%20191.6%20320%20191.6C249.1%20191.6%20191.6%20249.1%20191.6%20320C191.6%20390.9%20249.1%20448.4%20320%20448.4C390.9%20448.4%20448.4%20390.9%20448.4%20320z'/%3e%3c/svg%3e",Un="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20640%20640'%3e%3c!--!Font%20Awesome%20Free%207.1.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license/free%20Copyright%202025%20Fonticons,%20Inc.--%3e%3cpath%20d='M320%2064C178.6%2064%2064%20178.6%2064%20320C64%20461.4%20178.6%20576%20320%20576C388.8%20576%20451.3%20548.8%20497.3%20504.6C504.6%20497.6%20506.7%20486.7%20502.6%20477.5C498.5%20468.3%20488.9%20462.6%20478.8%20463.4C473.9%20463.8%20469%20464%20464%20464C362.4%20464%20280%20381.6%20280%20280C280%20207.9%20321.5%20145.4%20382.1%20115.2C391.2%20110.7%20396.4%20100.9%20395.2%2090.8C394%2080.7%20386.6%2072.5%20376.7%2070.3C358.4%2066.2%20339.4%2064%20320%2064z'/%3e%3c/svg%3e",Wn="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20640%20640'%3e%3c!--!Font%20Awesome%20Free%207.1.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license/free%20Copyright%202025%20Fonticons,%20Inc.--%3e%3cpath%20d='M320%2064C267%2064%20224%20107%20224%20160L224%20288C224%20341%20267%20384%20320%20384C373%20384%20416%20341%20416%20288L416%20160C416%20107%20373%2064%20320%2064zM176%20248C176%20234.7%20165.3%20224%20152%20224C138.7%20224%20128%20234.7%20128%20248L128%20288C128%20385.9%20201.3%20466.7%20296%20478.5L296%20528L248%20528C234.7%20528%20224%20538.7%20224%20552C224%20565.3%20234.7%20576%20248%20576L392%20576C405.3%20576%20416%20565.3%20416%20552C416%20538.7%20405.3%20528%20392%20528L344%20528L344%20478.5C438.7%20466.7%20512%20385.9%20512%20288L512%20248C512%20234.7%20501.3%20224%20488%20224C474.7%20224%20464%20234.7%20464%20248L464%20288C464%20367.5%20399.5%20432%20320%20432C240.5%20432%20176%20367.5%20176%20288L176%20248z'/%3e%3c/svg%3e",Jn=({isOpen:e,onClose:t,triggerRef:o,children:n,styles:r,position:s="top-center"})=>{const a=C.useRef(null);if(C.useEffect(()=>{const c=u=>{a.current&&!a.current.contains(u.target)&&!o.current?.contains(u.target)&&t()};return e&&document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[e,t,o]),!e||!o.current)return null;const i=o.current.getBoundingClientRect();let l={};switch(s){case"top-center":l={width:"50%",transform:"translate(-2.5%, -110%)"};break;case"bottom-left":l={top:i.bottom+6+window.scrollY,left:i.left+window.scrollX};break;case"bottom-right":l={top:i.bottom+6+window.scrollY,left:i.right+window.scrollX,transform:"translateX(-100%)"};break}return S.jsx("div",{ref:a,style:{position:"absolute",zIndex:9999,...l,...r},children:n})};function qn({isSelected:e,disableAnimation:t,...o}){return S.jsx("svg",{"aria-hidden":"true","data-selected":e,role:"presentation",viewBox:"0 0 17 18",...o,children:S.jsx("polyline",{fill:"none",points:"1 9 7 14 15 4",stroke:"currentColor",strokeDasharray:22,strokeDashoffset:e?44:66,strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,style:t?{}:{transition:"stroke-dashoffset 200ms ease"}})})}const Gn=({label:e,description:t,shortcut:o,startContent:n,endContent:r,isSelected:s,isDisabled:a,onSelect:i,disableAnimation:l,hideSelectedIcon:c,selectedIcon:u})=>{const p=C.useMemo(()=>{const m=S.jsx(qn,{disableAnimation:l,isSelected:!!s});return typeof u=="function"?u({icon:m,isSelected:s,isDisabled:a}):u||m},[u,s,a,l]);return S.jsxs("li",{className:`hero-menu-item ${s?"selected":""} ${a?"disabled":""}`,onClick:()=>{console.log(1),!a&&i?.()},children:[n&&S.jsx("span",{className:"start",children:n}),S.jsxs("div",{className:"content",children:[S.jsx("span",{className:"label",children:e}),t&&S.jsx("span",{className:"description",children:t})]}),o&&S.jsx("kbd",{className:"shortcut",children:o}),!c&&S.jsx("span",{className:"selected-icon",children:p}),r&&S.jsx("span",{className:"end",children:r})]})},Yn=({items:e,defaultSelectedKey:t,onSelectionChange:o})=>{const[n,r]=C.useState(t),s=a=>{r(a),o?.(a)};return S.jsx("ul",{className:"hero-menu",children:e.map(a=>S.jsx(Gn,{label:a.label,description:a.description,shortcut:a.shortcut,startContent:a.startContent,endContent:a.endContent,isSelected:a.key===n,isDisabled:a.isDisabled,onSelect:()=>{a?.onSelect?.(),s(a.key)}},a.key))})},Xn=({items:e,button:t,popoverStyles:o,defaultSelectedKey:n,closeAfterSelect:r,onSelectionChange:s})=>{const a=C.useRef(null),[i,l]=C.useState(!1),c={ref:a,onClick:()=>{l(u=>!u)},style:{cursor:"pointer"}};return S.jsxs(S.Fragment,{children:[t?C.cloneElement(t,c):S.jsx("button",{ref:a,onClick:()=>l(u=>!u),style:{cursor:"pointer"},children:S.jsx("img",{src:Bn,alt:"menu"})}),S.jsx(Jn,{styles:o,isOpen:i,onClose:()=>l(!1),triggerRef:a,children:S.jsx("div",{style:{borderRadius:10,zIndex:9999,boxShadow:"0 4px 12px rgba(0,0,0,0.12)"},children:S.jsx(Yn,{items:e,defaultSelectedKey:n,onSelectionChange:u=>{s?.(u),r?.(u)&&l(!1)}})})})]})},Zn=Mt.forwardRef(function({checked:t,defaultChecked:o,onCheckedChange:n,disabled:r=!1,required:s=!1,name:a,value:i,id:l,label:c,description:u,size:p="md",className:m,trackClassName:h,thumbClassName:$,labelClassName:x,startContent:w,endContent:y,thumb:d,"aria-label":g,"aria-labelledby":T},b){const E=typeof t=="boolean",[f,v]=Mt.useState(!!o),k=E?!!t:f,A=l??Mt.useId(),j=z=>{const V=z.target.checked;E||v(V),n?.(V,z)},N=d?.({checked:k,disabled:r,size:p})??(k?y:w);return S.jsxs("label",{className:Ae("autoui-switch",`autoui-switch--${p}`,r&&"is-disabled",m),htmlFor:A,children:[S.jsxs("span",{className:Ae("autoui-switch__control",h),"aria-hidden":"true",children:[S.jsx("input",{ref:b,id:A,className:"autoui-switch__input",type:"checkbox",checked:k,defaultChecked:o,onChange:j,disabled:r,required:s,name:a,value:i,"aria-label":g,"aria-labelledby":T}),S.jsx("span",{className:Ae("autoui-switch__track")}),S.jsx("span",{className:Ae("autoui-switch__thumb",$),children:N?S.jsx("span",{className:"autoui-switch__thumbContent",children:N}):null})]}),(c||u)&&S.jsxs("span",{className:Ae("autoui-switch__text",x),children:[c&&S.jsx("span",{className:"autoui-switch__label",children:c}),u&&S.jsx("span",{className:"autoui-switch__description",children:u})]})]})}),Qn=()=>{const{handleClear:e,setTheme:t,theme:o}=Ge();return S.jsx(Xn,{popoverStyles:{position:"absolute"},button:S.jsx("button",{type:"button",className:"autoui-chat-input-start",children:S.jsx("img",{src:Fo,alt:"menu",width:20,height:20,style:{filter:"var(--icon-filter-text)"}})}),items:[{startContent:S.jsx("img",{src:Fn,width:16,height:16,style:{filter:"var(--icon-filter-text)"}}),key:"clear",label:"Clear Messages",onSelect:e},{key:"switchTheme",label:S.jsx(Zn,{defaultChecked:o==="light",onCheckedChange:n=>{t?.(n?"light":"dark")},label:"Theme mode",thumb:({checked:n})=>S.jsx(S.Fragment,{children:n?S.jsx("img",{src:Dn,width:14,height:14,style:{filter:"var(--icon-filter-accent)"}}):S.jsx("img",{src:Un,width:14,height:14,style:{filter:"var(--icon-filter-text)"}})})})}],closeAfterSelect:n=>n!=="switchTheme",onSelectionChange:n=>console.log("Selected:",n)})},Kn=({value:e,setValue:t})=>{const{classNames:o}=Ge();return S.jsx("input",{role:"input",className:Ae("autoui-chat-textbox",o?.input),type:"text",value:e,autoFocus:!0,onChange:n=>t(n.target.value),placeholder:"Type a message...","aria-label":"Message input"})},er=()=>{const{classNames:e}=Ge();return S.jsx("button",{role:"inputButton",type:"submit",className:Ae("autoui-chat-send",e?.inputButton),"aria-label":"Send message",children:S.jsx("img",{src:Uo,alt:"arrow up",width:24,height:24,style:{filter:"var(--icon-filter-text)"}})})},tr=({lang:e="en-us"}={})=>{const t=C.useRef(null),[o,n]=C.useState(""),[r,s]=C.useState(!1),a=typeof window<"u"&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window),i=C.useCallback(()=>{if(!a||r)return;const c=window.SpeechRecognition||window.webkitSpeechRecognition;if(!c)return;const u=new c;u.lang=e,u.continuous=!1,u.interimResults=!1,u.onstart=()=>s(!0),u.onend=()=>s(!1),u.onresult=p=>{const m=p.results[0][0].transcript;n(m),s(!1)},u.onerror=()=>{u.stop(),s(!1)},t.current=u,u.start()},[a,r,e]),l=C.useCallback(()=>{t.current?.stop(),s(!1)},[]);return{start:i,stop:l,text:o,listening:r,isSupported:a}},or=({active:e,onClick:t})=>S.jsx("button",{type:"button",className:`chat-mic-btn ${e?"is-active":""}`,onClick:t,"aria-label":"Voice input",children:S.jsx("img",{src:Wn,width:20,height:20,style:{filter:"var(--icon-filter-text)"}})}),nr=()=>{const{classNames:e,handleSend:t}=Ge(),[o,n]=C.useState(""),r=tr({lang:"en-us"});C.useEffect(()=>{r.text&&n(a=>a?`${a} ${r.text}`:r.text)},[r.text]);const s=a=>{a.preventDefault(),t(o),n("")};return S.jsxs("form",{className:Ae("autoui-chat-input",e?.inputWrapper),onSubmit:s,children:[S.jsx(Qn,{}),S.jsx(Kn,{value:o,setValue:n}),r.isSupported&&S.jsx(or,{active:r.listening,onClick:()=>{r.listening?r.stop():r.start()}}),S.jsx(er,{})]})},rr=({message:e})=>{const t=e.role==="user",{classNames:o}=Ge(),n=typeof e.content=="string"||e.content instanceof String;return S.jsx("div",{role:"message",className:ye("autoui-chat-message",t?"user":"assistant",o?.message),"aria-label":t?"User message":"Assistant message",children:S.jsx("div",{className:`autoui-chat-bubble ${n?"autoui-chat-bubble--string":"autoui-chat-bubble--react-node"}`,children:e.content})})},Ot=0,Be=1,et=2,Wo=4;function go(e){return()=>e}function sr(e){e()}function Jo(e,t){return o=>e(t(o))}function yo(e,t){return()=>e(t)}function ir(e,t){return o=>e(t,o)}function qt(e){return e!==void 0}function ar(...e){return()=>{e.map(sr)}}function tt(){}function At(e,t){return t(e),e}function lr(e,t){return t(e)}function ie(...e){return e}function Z(e,t){return e(Be,t)}function U(e,t){e(Ot,t)}function Gt(e){e(et)}function le(e){return e(Wo)}function M(e,t){return Z(e,ir(t,Ot))}function je(e,t){const o=e(Be,n=>{o(),t(n)});return o}function wo(e){let t,o;return n=>r=>{t=r,o&&clearTimeout(o),o=setTimeout(()=>{n(t)},e)}}function qo(e,t){return e===t}function se(e=qo){let t;return o=>n=>{e(t,n)||(t=n,o(n))}}function B(e){return t=>o=>{e(o)&&t(o)}}function L(e){return t=>Jo(t,e)}function Ve(e){return t=>()=>{t(e)}}function R(e,...t){const o=cr(...t);return(n,r)=>{switch(n){case et:Gt(e);return;case Be:return Z(e,o(r))}}}function Ne(e,t){return o=>n=>{o(t=e(t,n))}}function qe(e){return t=>o=>{e>0?e--:t(o)}}function _e(e){let t=null,o;return n=>r=>{t=r,!o&&(o=setTimeout(()=>{o=void 0,n(t)},e))}}function W(...e){const t=new Array(e.length);let o=0,n=null;const r=Math.pow(2,e.length)-1;return e.forEach((s,a)=>{const i=Math.pow(2,a);Z(s,l=>{const c=o;o=o|i,t[a]=l,c!==r&&o===r&&n&&(n(),n=null)})}),s=>a=>{const i=()=>{s([a].concat(t))};o===r?i():n=i}}function cr(...e){return t=>e.reduceRight(lr,t)}function ur(e){let t,o;const n=()=>t?.();return function(r,s){switch(r){case Be:return s?o===s?void 0:(n(),o=s,t=Z(e,s),t):(n(),tt);case et:n(),o=null;return}}}function O(e){let t=e;const o=q();return(n,r)=>{switch(n){case Ot:t=r;break;case Be:{r(t);break}case Wo:return t}return o(n,r)}}function be(e,t){return At(O(t),o=>M(e,o))}function q(){const e=[];return(t,o)=>{switch(t){case Ot:e.slice().forEach(n=>{n(o)});return;case et:e.splice(0,e.length);return;case Be:return e.push(o),()=>{const n=e.indexOf(o);n>-1&&e.splice(n,1)}}}}function $e(e){return At(q(),t=>M(e,t))}function Y(e,t=[],{singleton:o}={singleton:!0}){return{constructor:e,dependencies:t,id:dr(),singleton:o}}const dr=()=>Symbol();function pr(e){const t=new Map,o=({constructor:n,dependencies:r,id:s,singleton:a})=>{if(a&&t.has(s))return t.get(s);const i=n(r.map(l=>o(l)));return a&&t.set(s,i),i};return o(e)}function de(...e){const t=q(),o=new Array(e.length);let n=0;const r=Math.pow(2,e.length)-1;return e.forEach((s,a)=>{const i=Math.pow(2,a);Z(s,l=>{o[a]=l,n=n|i,n===r&&U(t,o)})}),function(s,a){switch(s){case et:{Gt(t);return}case Be:return n===r&&a(o),Z(t,a)}}}function H(e,t=qo){return R(e,se(t))}function Bt(...e){return function(t,o){switch(t){case et:return;case Be:return ar(...e.map(n=>Z(n,o)))}}}var Ce=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Ce||{});const fr={0:"debug",3:"error",1:"log",2:"warn"},mr=()=>typeof globalThis>"u"?window:globalThis,Fe=Y(()=>{const e=O(3);return{log:O((t,o,n=1)=>{var r;const s=(r=mr().VIRTUOSO_LOG_LEVEL)!=null?r:le(e);n>=s&&console[fr[n]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,o)}),logLevel:e}},[],{singleton:!0});function Ye(e,t,o){return Yt(e,t,o).callbackRef}function Yt(e,t,o){const n=C.useRef(null);let r=a=>{};const s=C.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(a=>{const i=()=>{const l=a[0].target;l.offsetParent!==null&&e(l)};o?i():requestAnimationFrame(i)}):null,[e,o]);return r=a=>{a&&t?(s?.observe(a),n.current=a):(n.current&&s?.unobserve(n.current),n.current=null)},{callbackRef:r,ref:n}}function hr(e,t,o,n,r,s,a,i,l){const c=C.useCallback(u=>{const p=gr(u.children,t,i?"offsetWidth":"offsetHeight",r);let m=u.parentElement;for(;!m.dataset.virtuosoScroller;)m=m.parentElement;const h=m.lastElementChild.dataset.viewportType==="window";let $;h&&($=m.ownerDocument.defaultView);const x=a?i?a.scrollLeft:a.scrollTop:h?i?$.scrollX||$.document.documentElement.scrollLeft:$.scrollY||$.document.documentElement.scrollTop:i?m.scrollLeft:m.scrollTop,w=a?i?a.scrollWidth:a.scrollHeight:h?i?$.document.documentElement.scrollWidth:$.document.documentElement.scrollHeight:i?m.scrollWidth:m.scrollHeight,y=a?i?a.offsetWidth:a.offsetHeight:h?i?$.innerWidth:$.innerHeight:i?m.offsetWidth:m.offsetHeight;n({scrollHeight:w,scrollTop:Math.max(x,0),viewportHeight:y}),s?.(i?xo("column-gap",getComputedStyle(u).columnGap,r):xo("row-gap",getComputedStyle(u).rowGap,r)),p!==null&&e(p)},[e,t,r,s,a,n,i]);return Yt(c,o,l)}function gr(e,t,o,n){const r=e.length;if(r===0)return null;const s=[];for(let a=0;a<r;a++){const i=e.item(a);if(i.dataset.index===void 0)continue;const l=parseInt(i.dataset.index),c=parseFloat(i.dataset.knownSize),u=t(i,o);if(u===0&&n("Zero-sized element, this should not happen",{child:i},Ce.ERROR),u===c)continue;const p=s[s.length-1];s.length===0||p.size!==u||p.endIndex!==l-1?s.push({endIndex:l,size:u,startIndex:l}):s[s.length-1].endIndex++}return s}function xo(e,t,o){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&o(`${e} was not resolved to pixel value correctly`,t,Ce.WARN),t==="normal"?0:parseInt(t??"0",10)}function Go(e,t,o){const n=C.useRef(null),r=C.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const c=l.getBoundingClientRect(),u=c.width;let p,m;if(t){const h=t.getBoundingClientRect(),$=c.top-h.top;m=h.height-Math.max(0,$),p=$+t.scrollTop}else{const h=a.current.ownerDocument.defaultView;m=h.innerHeight-Math.max(0,c.top),p=c.top+h.scrollY}n.current={offsetTop:p,visibleHeight:m,visibleWidth:u},e(n.current)},[e,t]),{callbackRef:s,ref:a}=Yt(r,!0,o),i=C.useCallback(()=>{r(a.current)},[r,a]);return C.useEffect(()=>{var l;if(t){t.addEventListener("scroll",i);const c=new ResizeObserver(()=>{requestAnimationFrame(i)});return c.observe(t),()=>{t.removeEventListener("scroll",i),c.unobserve(t)}}else{const c=(l=a.current)==null?void 0:l.ownerDocument.defaultView;return c?.addEventListener("scroll",i),c?.addEventListener("resize",i),()=>{c?.removeEventListener("scroll",i),c?.removeEventListener("resize",i)}}},[i,t,a]),s}const Te=Y(()=>{const e=q(),t=q(),o=O(0),n=q(),r=O(0),s=q(),a=q(),i=O(0),l=O(0),c=O(0),u=O(0),p=q(),m=q(),h=O(!1),$=O(!1),x=O(!1);return M(R(e,L(({scrollTop:w})=>w)),t),M(R(e,L(({scrollHeight:w})=>w)),a),M(t,r),{deviation:o,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:u,headerHeight:i,horizontalDirection:$,scrollBy:m,scrollContainerState:e,scrollHeight:a,scrollingInProgress:h,scrollTo:p,scrollTop:t,skipAnimationFrameInResizeObserver:x,smoothScrollTargetReached:n,statefulScrollTop:r,viewportHeight:s}},[],{singleton:!0}),at={lvl:0};function Yo(e,t){const o=e.length;if(o===0)return[];let{index:n,value:r}=t(e[0]);const s=[];for(let a=1;a<o;a++){const{index:i,value:l}=t(e[a]);s.push({end:i-1,start:n,value:r}),n=i,r=l}return s.push({end:1/0,start:n,value:r}),s}function oe(e){return e===at}function lt(e,t){if(!oe(e))return t===e.k?e.v:t<e.k?lt(e.l,t):lt(e.r,t)}function Pe(e,t,o="k"){if(oe(e))return[-1/0,void 0];if(Number(e[o])===t)return[e.k,e.v];if(Number(e[o])<t){const n=Pe(e.r,t,o);return n[0]===-1/0?[e.k,e.v]:n}return Pe(e.l,t,o)}function Ie(e,t,o){return oe(e)?Qo(t,o,1):t===e.k?fe(e,{k:t,v:o}):t<e.k?vo(fe(e,{l:Ie(e.l,t,o)})):vo(fe(e,{r:Ie(e.r,t,o)}))}function Qe(){return at}function Ke(e,t,o){if(oe(e))return[];const n=Pe(e,t)[0];return yr(Dt(e,n,o))}function Ft(e,t){if(oe(e))return at;const{k:o,l:n,r}=e;if(t===o){if(oe(n))return r;if(oe(r))return n;{const[s,a]=Zo(n);return Tt(fe(e,{k:s,l:Xo(n),v:a}))}}else return t<o?Tt(fe(e,{l:Ft(n,t)})):Tt(fe(e,{r:Ft(r,t)}))}function We(e){return oe(e)?[]:[...We(e.l),{k:e.k,v:e.v},...We(e.r)]}function Dt(e,t,o){if(oe(e))return[];const{k:n,l:r,r:s,v:a}=e;let i=[];return n>t&&(i=i.concat(Dt(r,t,o))),n>=t&&n<=o&&i.push({k:n,v:a}),n<=o&&(i=i.concat(Dt(s,t,o))),i}function Tt(e){const{l:t,lvl:o,r:n}=e;if(n.lvl>=o-1&&t.lvl>=o-1)return e;if(o>n.lvl+1){if(Vt(t))return Ko(fe(e,{lvl:o-1}));if(!oe(t)&&!oe(t.r))return fe(t.r,{l:fe(t,{r:t.r.l}),lvl:o,r:fe(e,{l:t.r.r,lvl:o-1})});throw new Error("Unexpected empty nodes")}else{if(Vt(e))return Ut(fe(e,{lvl:o-1}));if(!oe(n)&&!oe(n.l)){const r=n.l,s=Vt(r)?n.lvl-1:n.lvl;return fe(r,{l:fe(e,{lvl:o-1,r:r.l}),lvl:r.lvl+1,r:Ut(fe(n,{l:r.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function fe(e,t){return Qo(t.k!==void 0?t.k:e.k,t.v!==void 0?t.v:e.v,t.lvl!==void 0?t.lvl:e.lvl,t.l!==void 0?t.l:e.l,t.r!==void 0?t.r:e.r)}function Xo(e){return oe(e.r)?e.l:Tt(fe(e,{r:Xo(e.r)}))}function Vt(e){return oe(e)||e.lvl>e.r.lvl}function Zo(e){return oe(e.r)?[e.k,e.v]:Zo(e.r)}function Qo(e,t,o,n=at,r=at){return{k:e,l:n,lvl:o,r,v:t}}function vo(e){return Ut(Ko(e))}function Ko(e){const{l:t}=e;return!oe(t)&&t.lvl===e.lvl?fe(t,{r:fe(e,{l:t.r})}):e}function Ut(e){const{lvl:t,r:o}=e;return!oe(o)&&!oe(o.r)&&o.lvl===t&&o.r.lvl===t?fe(o,{l:fe(e,{r:o.l}),lvl:t+1}):e}function yr(e){return Yo(e,({k:t,v:o})=>({index:t,value:o}))}function en(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function ct(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Xt=Y(()=>({recalcInProgress:O(!1)}),[],{singleton:!0});function tn(e,t,o){return e[It(e,t,o)]}function It(e,t,o,n=0){let r=e.length-1;for(;n<=r;){const s=Math.floor((n+r)/2),a=e[s],i=o(a,t);if(i===0)return s;if(i===-1){if(r-n<2)return s-1;r=s-1}else{if(r===n)return s;n=s+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function wr(e,t,o,n){const r=It(e,t,n),s=It(e,o,n,r);return e.slice(r,s+1)}function He(e,t){return Math.round(e.getBoundingClientRect()[t])}function jt(e){return!oe(e.groupOffsetTree)}function Zt({index:e},t){return t===e?0:t<e?-1:1}function xr(){return{groupIndices:[],groupOffsetTree:Qe(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Qe()}}function vr(e,t){let o=oe(e)?0:1/0;for(const n of t){const{endIndex:r,size:s,startIndex:a}=n;if(o=Math.min(o,a),oe(e)){e=Ie(e,0,s);continue}const i=Ke(e,a-1,r+1);if(i.some(Er(n)))continue;let l=!1,c=!1;for(const{end:u,start:p,value:m}of i)l?(r>=p||s===m)&&(e=Ft(e,p)):(c=m!==s,l=!0),u>r&&r>=p&&m!==s&&(e=Ie(e,r+1,m));c&&(e=Ie(e,a,s))}return[e,o]}function Sr(e){return typeof e.groupIndex<"u"}function br({offset:e},t){return t===e?0:t<e?-1:1}function ut(e,t,o){if(t.length===0)return 0;const{index:n,offset:r,size:s}=tn(t,e,Zt),a=e-n,i=s*a+(a-1)*o+r;return i>0?i+o:i}function on(e,t){if(!jt(t))return e;let o=0;for(;t.groupIndices[o]<=e+o;)o++;return e+o}function nn(e,t,o){if(Sr(e))return t.groupIndices[e.groupIndex]+1;{const n=e.index==="LAST"?o:e.index;let r=on(n,t);return r=Math.max(0,r,Math.min(o,r)),r}}function Tr(e,t,o,n=0){return n>0&&(t=Math.max(t,tn(e,n,Zt).offset)),Yo(wr(e,t,o,br),$r)}function Cr(e,[t,o,n,r]){t.length>0&&n("received item sizes",t,Ce.DEBUG);const s=e.sizeTree;let a=s,i=0;if(o.length>0&&oe(s)&&t.length===2){const m=t[0].size,h=t[1].size;a=o.reduce(($,x)=>Ie(Ie($,x,m),x+1,h),a)}else[a,i]=vr(a,t);if(a===s)return e;const{lastIndex:l,lastOffset:c,lastSize:u,offsetTree:p}=Wt(e.offsetTree,i,a,r);return{groupIndices:o,groupOffsetTree:o.reduce((m,h)=>Ie(m,h,ut(h,p,r)),Qe()),lastIndex:l,lastOffset:c,lastSize:u,offsetTree:p,sizeTree:a}}function Ir(e){return We(e).map(({k:t,v:o},n,r)=>{const s=r[n+1];return{endIndex:s?s.k-1:1/0,size:o,startIndex:t}})}function So(e,t){let o=0,n=0;for(;o<e;)o+=t[n+1]-t[n]-1,n++;return n-(o===e?0:1)}function Wt(e,t,o,n){let r=e,s=0,a=0,i=0,l=0;if(t!==0){l=It(r,t-1,Zt),i=r[l].offset;const c=Pe(o,t-1);s=c[0],a=c[1],r.length&&r[l].size===Pe(o,t)[1]&&(l-=1),r=r.slice(0,l+1)}else r=[];for(const{start:c,value:u}of Ke(o,t,1/0)){const p=c-s,m=p*a+i+p*n;r.push({index:c,offset:m,size:u}),s=c,i=m,a=u}return{lastIndex:s,lastOffset:i,lastSize:a,offsetTree:r}}function $r(e){return{index:e.index,value:e}}function Er(e){const{endIndex:t,size:o,startIndex:n}=e;return r=>r.start===n&&(r.end===t||r.end===1/0)&&r.value===o}const Rr={offsetHeight:"height",offsetWidth:"width"},ze=Y(([{log:e},{recalcInProgress:t}])=>{const o=q(),n=q(),r=be(n,0),s=q(),a=q(),i=O(0),l=O([]),c=O(void 0),u=O(void 0),p=O(void 0),m=O(void 0),h=O((f,v)=>He(f,Rr[v])),$=O(void 0),x=O(0),w=xr(),y=be(R(o,W(l,e,x),Ne(Cr,w),se()),w),d=be(R(l,se(),Ne((f,v)=>({current:v,prev:f.current}),{current:[],prev:[]}),L(({prev:f})=>f)),[]);M(R(l,B(f=>f.length>0),W(y,x),L(([f,v,k])=>{const A=f.reduce((j,N,z)=>Ie(j,N,ut(N,v.offsetTree,k)||z),Qe());return{...v,groupIndices:f,groupOffsetTree:A}})),y),M(R(n,W(y),B(([f,{lastIndex:v}])=>f<v),L(([f,{lastIndex:v,lastSize:k}])=>[{endIndex:v,size:k,startIndex:f}])),o),M(c,u);const g=be(R(c,L(f=>f===void 0)),!0);M(R(u,B(f=>f!==void 0&&oe(le(y).sizeTree)),L(f=>{const v=le(p),k=le(l).length>0;return v?k?[{endIndex:0,size:v,startIndex:0},{endIndex:1,size:f,startIndex:1}]:[]:[{endIndex:0,size:f,startIndex:0}]})),o),M(R(m,B(f=>f!==void 0&&f.length>0&&oe(le(y).sizeTree)),L(f=>{const v=[];let k=f[0],A=0;for(let j=1;j<f.length;j++){const N=f[j];N!==k&&(v.push({endIndex:j-1,size:k,startIndex:A}),k=N,A=j)}return v.push({endIndex:f.length-1,size:k,startIndex:A}),v})),o),M(R(l,W(p,u),B(([,f,v])=>f!==void 0&&v!==void 0),L(([f,v,k])=>{const A=[];for(let j=0;j<f.length;j++){const N=f[j],z=f[j+1];A.push({startIndex:N,endIndex:N,size:v}),z!==void 0&&A.push({startIndex:N+1,endIndex:z-1,size:k})}return A})),o);const T=$e(R(o,W(y),Ne(({sizes:f},[v,k])=>({changed:k!==f,sizes:k}),{changed:!1,sizes:w}),L(f=>f.changed)));Z(R(i,Ne((f,v)=>({diff:f.prev-v,prev:v}),{diff:0,prev:0}),L(f=>f.diff)),f=>{const{groupIndices:v}=le(y);if(f>0)U(t,!0),U(s,f+So(f,v));else if(f<0){const k=le(d);k.length>0&&(f-=So(-f,k)),U(a,f)}}),Z(R(i,W(e)),([f,v])=>{f<0&&v("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:i},Ce.ERROR)});const b=$e(s);M(R(s,W(y),L(([f,v])=>{const k=v.groupIndices.length>0,A=[],j=v.lastSize;if(k){const N=lt(v.sizeTree,0);let z=0,V=0;for(;z<f;){const X=v.groupIndices[V],Q=v.groupIndices.length===V+1?1/0:v.groupIndices[V+1]-X-1;A.push({endIndex:X,size:N,startIndex:X}),A.push({endIndex:X+1+Q-1,size:j,startIndex:X+1}),V++,z+=Q+1}const D=We(v.sizeTree);return z!==f&&D.shift(),D.reduce((X,{k:Q,v:we})=>{let xe=X.ranges;return X.prevSize!==0&&(xe=[...X.ranges,{endIndex:Q+f-1,size:X.prevSize,startIndex:X.prevIndex}]),{prevIndex:Q+f,prevSize:we,ranges:xe}},{prevIndex:f,prevSize:0,ranges:A}).ranges}return We(v.sizeTree).reduce((N,{k:z,v:V})=>({prevIndex:z+f,prevSize:V,ranges:[...N.ranges,{endIndex:z+f-1,size:N.prevSize,startIndex:N.prevIndex}]}),{prevIndex:0,prevSize:j,ranges:[]}).ranges})),o);const E=$e(R(a,W(y,x),L(([f,{offsetTree:v},k])=>{const A=-f;return ut(A,v,k)})));return M(R(a,W(y,x),L(([f,v,k])=>{if(v.groupIndices.length>0){if(oe(v.sizeTree))return v;let A=Qe();const j=le(d);let N=0,z=0,V=0;for(;N<-f;){V=j[z];const D=j[z+1]-V-1;z++,N+=D+1}if(A=We(v.sizeTree).reduce((D,{k:X,v:Q})=>Ie(D,Math.max(0,X+f),Q),A),N!==-f){const D=lt(v.sizeTree,V);A=Ie(A,0,D);const X=Pe(v.sizeTree,-f+1)[1];A=Ie(A,1,X)}return{...v,sizeTree:A,...Wt(v.offsetTree,0,A,k)}}else{const A=We(v.sizeTree).reduce((j,{k:N,v:z})=>Ie(j,Math.max(0,N+f),z),Qe());return{...v,sizeTree:A,...Wt(v.offsetTree,0,A,k)}}})),y),{beforeUnshiftWith:b,data:$,defaultItemSize:u,firstItemIndex:i,fixedItemSize:c,fixedGroupSize:p,gap:x,groupIndices:l,heightEstimates:m,itemSize:h,listRefresh:T,shiftWith:a,shiftWithOffset:E,sizeRanges:o,sizes:y,statefulTotalCount:r,totalCount:n,trackItemSizes:g,unshiftWith:s}},ie(Fe,Xt),{singleton:!0});function kr(e){return e.reduce((t,o)=>(t.groupIndices.push(t.totalCount),t.totalCount+=o+1,t),{groupIndices:[],totalCount:0})}const rn=Y(([{groupIndices:e,sizes:t,totalCount:o},{headerHeight:n,scrollTop:r}])=>{const s=q(),a=q(),i=$e(R(s,L(kr)));return M(R(i,L(l=>l.totalCount)),o),M(R(i,L(l=>l.groupIndices)),e),M(R(de(r,t,n),B(([l,c])=>jt(c)),L(([l,c,u])=>Pe(c.groupOffsetTree,Math.max(l-u,0),"v")[0]),se(),L(l=>[l])),a),{groupCounts:s,topItemsIndexes:a}},ie(ze,Te)),De=Y(([{log:e}])=>{const t=O(!1),o=$e(R(t,B(n=>n),se()));return Z(t,n=>{n&&le(e)("props updated",{},Ce.DEBUG)}),{didMount:o,propsReady:t}},ie(Fe),{singleton:!0}),Or=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function sn(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Or)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const ht=Y(([{gap:e,listRefresh:t,sizes:o,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:s,footerHeight:a,headerHeight:i,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:u,viewportHeight:p},{log:m}])=>{const h=q(),$=q(),x=O(0);let w=null,y=null,d=null;function g(){w&&(w(),w=null),d&&(d(),d=null),y&&(clearTimeout(y),y=null),U(l,!1)}return M(R(h,W(o,p,n,x,i,a,m),W(e,s,r),L(([[T,b,E,f,v,k,A,j],N,z,V])=>{const D=sn(T),{align:X,behavior:Q,offset:we}=D,xe=f-1,ve=nn(D,b,xe);let I=ut(ve,b.offsetTree,N)+k;X==="end"?(I+=z+Pe(b.sizeTree,ve)[1]-E+V,ve===xe&&(I+=A)):X==="center"?I+=(z+Pe(b.sizeTree,ve)[1]-E+V)/2:I-=v,we&&(I+=we);const _=G=>{g(),G?(j("retrying to scroll to",{location:T},Ce.DEBUG),U(h,T)):(U($,!0),j("list did not change, scroll successful",{},Ce.DEBUG))};if(g(),Q==="smooth"){let G=!1;d=Z(t,K=>{G=G||K}),w=je(u,()=>{_(G)})}else w=je(R(t,Ar(150)),_);return y=setTimeout(()=>{g()},1200),U(l,!0),j("scrolling from index to",{behavior:Q,index:ve,top:I},Ce.DEBUG),{behavior:Q,top:I}})),c),{scrollTargetReached:$,scrollToIndex:h,topListHeight:x}},ie(ze,Te,Fe),{singleton:!0});function Ar(e){return t=>{const o=setTimeout(()=>{t(!1)},e);return n=>{n&&(t(!0),clearTimeout(o))}}}function Qt(e,t){e==0?t():requestAnimationFrame(()=>{Qt(e-1,t)})}function Kt(e,t){const o=t-1;return typeof e=="number"?e:e.index==="LAST"?o:e.index}const gt=Y(([{defaultItemSize:e,listRefresh:t,sizes:o},{scrollTop:n},{scrollTargetReached:r,scrollToIndex:s},{didMount:a}])=>{const i=O(!0),l=O(0),c=O(!0);return M(R(a,W(l),B(([u,p])=>!!p),Ve(!1)),i),M(R(a,W(l),B(([u,p])=>!!p),Ve(!1)),c),Z(R(de(t,a),W(i,o,e,c),B(([[,u],p,{sizeTree:m},h,$])=>u&&(!oe(m)||qt(h))&&!p&&!$),W(l)),([,u])=>{je(r,()=>{U(c,!0)}),Qt(4,()=>{je(n,()=>{U(i,!0)}),U(s,u)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:i}},ie(ze,Te,ht,De),{singleton:!0});function an(e,t){return Math.abs(e-t)<1.01}const dt="up",rt="down",jr="none",Pr={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Lr=0,yt=Y(([{footerHeight:e,headerHeight:t,scrollBy:o,scrollContainerState:n,scrollTop:r,viewportHeight:s}])=>{const a=O(!1),i=O(!0),l=q(),c=q(),u=O(4),p=O(Lr),m=be(R(Bt(R(H(r),qe(1),Ve(!0)),R(H(r),qe(1),Ve(!1),wo(100))),se()),!1),h=be(R(Bt(R(o,Ve(!0)),R(o,Ve(!1),wo(200))),se()),!1);M(R(de(H(r),H(p)),L(([d,g])=>d<=g),se()),i),M(R(i,_e(50)),c);const $=$e(R(de(n,H(s),H(t),H(e),H(u)),Ne((d,[{scrollHeight:g,scrollTop:T},b,E,f,v])=>{const k=T+b-g>-v,A={scrollHeight:g,scrollTop:T,viewportHeight:b};if(k){let N,z;return T>d.state.scrollTop?(N="SCROLLED_DOWN",z=d.state.scrollTop-T):(N="SIZE_DECREASED",z=d.state.scrollTop-T||d.scrollTopDelta),{atBottom:!0,atBottomBecause:N,scrollTopDelta:z,state:A}}let j;return A.scrollHeight>d.state.scrollHeight?j="SIZE_INCREASED":b<d.state.viewportHeight?j="VIEWPORT_HEIGHT_DECREASING":T<d.state.scrollTop?j="SCROLLING_UPWARDS":j="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:j,state:A}},Pr),se((d,g)=>d&&d.atBottom===g.atBottom))),x=be(R(n,Ne((d,{scrollHeight:g,scrollTop:T,viewportHeight:b})=>{if(an(d.scrollHeight,g))return{changed:!1,jump:0,scrollHeight:g,scrollTop:T};{const E=g-(T+b)<1;return d.scrollTop!==T&&E?{changed:!0,jump:d.scrollTop-T,scrollHeight:g,scrollTop:T}:{changed:!0,jump:0,scrollHeight:g,scrollTop:T}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),B(d=>d.changed),L(d=>d.jump)),0);M(R($,L(d=>d.atBottom)),a),M(R(a,_e(50)),l);const w=O(rt);M(R(n,L(({scrollTop:d})=>d),se(),Ne((d,g)=>le(h)?{direction:d.direction,prevScrollTop:g}:{direction:g<d.prevScrollTop?dt:rt,prevScrollTop:g},{direction:rt,prevScrollTop:0}),L(d=>d.direction)),w),M(R(n,_e(50),Ve(jr)),w);const y=O(0);return M(R(m,B(d=>!d),Ve(0)),y),M(R(r,_e(100),W(m),B(([d,g])=>!!g),Ne(([d,g],[T])=>[g,T],[0,0]),L(([d,g])=>g-d)),y),{atBottomState:$,atBottomStateChange:l,atBottomThreshold:u,atTopStateChange:c,atTopThreshold:p,isAtBottom:a,isAtTop:i,isScrolling:m,lastJumpDueToItemResize:x,scrollDirection:w,scrollVelocity:y}},ie(Te)),pt="top",ft="bottom",bo="none";function To(e,t,o){return typeof e=="number"?o===dt&&t===pt||o===rt&&t===ft?e:0:o===dt?t===pt?e.main:e.reverse:t===ft?e.main:e.reverse}function Co(e,t){var o;return typeof e=="number"?e:(o=e[t])!=null?o:0}const eo=Y(([{deviation:e,fixedHeaderHeight:t,headerHeight:o,scrollTop:n,viewportHeight:r}])=>{const s=q(),a=O(0),i=O(0),l=O(0),c=be(R(de(H(n),H(r),H(o),H(s,ct),H(l),H(a),H(t),H(e),H(i)),L(([u,p,m,[h,$],x,w,y,d,g])=>{const T=u-d,b=w+y,E=Math.max(m-T,0);let f=bo;const v=Co(g,pt),k=Co(g,ft);return h-=d,h+=m+y,$+=m+y,$-=d,h>u+b-v&&(f=dt),$<u-E+p+k&&(f=rt),f!==bo?[Math.max(T-m-To(x,pt,f)-v,0),T-E-y+p+To(x,ft,f)+k]:null}),B(u=>u!=null),se(ct)),[0,0]);return{increaseViewportBy:i,listBoundary:s,overscan:l,topListHeight:a,visibleRange:c}},ie(Te),{singleton:!0});function Mr(e,t,o){if(jt(t)){const n=on(e,t);return[{index:Pe(t.groupOffsetTree,n)[0],offset:0,size:0},{data:o?.[0],index:n,offset:0,size:0}]}return[{data:o?.[0],index:e,offset:0,size:0}]}const Nt={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ct(e,t,o,n,r,s){const{lastIndex:a,lastOffset:i,lastSize:l}=r;let c=0,u=0;if(e.length>0){c=e[0].offset;const x=e[e.length-1];u=x.offset+x.size}const p=o-a,m=i+p*l+(p-1)*n,h=c,$=m-u;return{bottom:u,firstItemIndex:s,items:Io(e,r,s),offsetBottom:$,offsetTop:c,top:h,topItems:Io(t,r,s),topListHeight:t.reduce((x,w)=>w.size+x,0),totalCount:o}}function ln(e,t,o,n,r,s){let a=0;if(o.groupIndices.length>0)for(const u of o.groupIndices){if(u-a>=e)break;a++}const i=e+a,l=Kt(t,i),c=Array.from({length:i}).map((u,p)=>({data:s[p+l],index:p+l,offset:0,size:0}));return Ct(c,[],i,r,o,n)}function Io(e,t,o){if(e.length===0)return[];if(!jt(t))return e.map(c=>({...c,index:c.index+o,originalIndex:c.index}));const n=e[0].index,r=e[e.length-1].index,s=[],a=Ke(t.groupOffsetTree,n,r);let i,l=0;for(const c of e){(!i||i.end<c.index)&&(i=a.shift(),l=t.groupIndices.indexOf(i.start));let u;c.index===i.start?u={index:l,type:"group"}:u={groupIndex:l,index:c.index-(l+1)+o},s.push({...u,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return s}function $o(e,t){var o;return e===void 0?0:typeof e=="number"?e:(o=e[t])!=null?o:0}const Xe=Y(([{data:e,firstItemIndex:t,gap:o,sizes:n,totalCount:r},s,{listBoundary:a,topListHeight:i,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:u},{topListHeight:p},m,{didMount:h},{recalcInProgress:$}])=>{const x=O([]),w=O(0),y=q(),d=O(0);M(s.topItemsIndexes,x);const g=be(R(de(h,$,H(l,ct),H(r),H(n),H(c),u,H(x),H(t),H(o),H(d),e),B(([f,v,,k,,,,,,,,A])=>{const j=A&&A.length!==k;return f&&!v&&!j}),L(([,,[f,v],k,A,j,N,z,V,D,X,Q])=>{var we,xe,ve,I;const _=A,{offsetTree:G,sizeTree:K}=_,Le=le(w);if(k===0)return{...Nt,totalCount:k};if(f===0&&v===0)return Le===0?{...Nt,totalCount:k}:ln(Le,j,A,V,D,Q||[]);if(oe(K))return Le>0?null:Ct(Mr(Kt(j,k),_,Q),[],k,D,_,V);const Me=[];if(z.length>0){const pe=z[0],ce=z[z.length-1];let me=0;for(const ue of Ke(K,pe,ce)){const te=ue.value,re=Math.max(ue.start,pe),Re=Math.min(ue.end,ce);for(let ge=re;ge<=Re;ge++)Me.push({data:Q?.[ge],index:ge,offset:me,size:te}),me+=te}}if(!N)return Ct([],Me,k,D,_,V);const ee=z.length>0?z[z.length-1]+1:0,P=Tr(G,f,v,ee);if(P.length===0)return null;const J=k-1,ne=At([],pe=>{for(const ce of P){const me=ce.value;let ue=me.offset,te=ce.start;const re=me.size;if(me.offset<f){te+=Math.floor((f-me.offset+D)/(re+D));const ge=te-ce.start;ue+=ge*re+ge*D}te<ee&&(ue+=(ee-te)*re,te=ee);const Re=Math.min(ce.end,J);for(let ge=te;ge<=Re&&!(ue>=v);ge++)pe.push({data:Q?.[ge],index:ge,offset:ue,size:re}),ue+=re+D}}),he=$o(X,pt),Ee=$o(X,ft);if(ne.length>0&&(he>0||Ee>0)){const pe=ne[0],ce=ne[ne.length-1];if(he>0&&pe.index>ee){const me=Math.min(he,pe.index-ee),ue=[];let te=pe.offset;for(let re=pe.index-1;re>=pe.index-me;re--){const Re=(xe=(we=Ke(K,re,re)[0])==null?void 0:we.value)!=null?xe:pe.size;te-=Re+D,ue.unshift({data:Q?.[re],index:re,offset:te,size:Re})}ne.unshift(...ue)}if(Ee>0&&ce.index<J){const me=Math.min(Ee,J-ce.index);let ue=ce.offset+ce.size+D;for(let te=ce.index+1;te<=ce.index+me;te++){const re=(I=(ve=Ke(K,te,te)[0])==null?void 0:ve.value)!=null?I:ce.size;ne.push({data:Q?.[te],index:te,offset:ue,size:re}),ue+=re+D}}}return Ct(ne,Me,k,D,_,V)}),B(f=>f!==null),se()),Nt);M(R(e,B(qt),L(f=>f?.length)),r),M(R(g,L(f=>f.topListHeight)),p),M(p,i),M(R(g,L(f=>[f.top,f.bottom])),a),M(R(g,L(f=>f.items)),y);const T=$e(R(g,B(({items:f})=>f.length>0),W(r,e),B(([{items:f},v])=>f[f.length-1].originalIndex===v-1),L(([,f,v])=>[f-1,v]),se(ct),L(([f])=>f))),b=$e(R(g,_e(200),B(({items:f,topItems:v})=>f.length>0&&f[0].originalIndex===v.length),L(({items:f})=>f[0].index),se())),E=$e(R(g,B(({items:f})=>f.length>0),L(({items:f})=>{let v=0,k=f.length-1;for(;f[v].type==="group"&&v<k;)v++;for(;f[k].type==="group"&&k>v;)k--;return{endIndex:f[k].index,startIndex:f[v].index}}),se(en)));return{endReached:T,initialItemCount:w,itemsRendered:y,listState:g,minOverscanItemCount:d,rangeChanged:E,startReached:b,topItemsIndexes:x,...m}},ie(ze,rn,eo,gt,ht,yt,De,Xt),{singleton:!0}),cn=Y(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:o,headerHeight:n},{listState:r}])=>{const s=q(),a=be(R(de(o,e,n,t,r),L(([i,l,c,u,p])=>i+l+c+u+p.offsetBottom+p.bottom)),0);return M(H(a),s),{totalListHeight:a,totalListHeightChanged:s}},ie(Te,Xe),{singleton:!0}),Vr=Y(([{viewportHeight:e},{totalListHeight:t}])=>{const o=O(!1),n=be(R(de(o,e,t),B(([r])=>r),L(([,r,s])=>Math.max(0,r-s)),_e(0),se()),0);return{alignToBottom:o,paddingTopAddition:n}},ie(Te,cn),{singleton:!0}),un=Y(()=>({context:O(null)})),Nr=({itemBottom:e,itemTop:t,locationParams:{align:o,behavior:n,...r},viewportBottom:s,viewportTop:a})=>t<a?{...r,align:o??"start",behavior:n}:e>s?{...r,align:o??"end",behavior:n}:null,dn=Y(([{gap:e,sizes:t,totalCount:o},{fixedFooterHeight:n,fixedHeaderHeight:r,headerHeight:s,scrollingInProgress:a,scrollTop:i,viewportHeight:l},{scrollToIndex:c}])=>{const u=q();return M(R(u,W(t,l,o,s,r,n,i),W(e),L(([[p,m,h,$,x,w,y,d],g])=>{const{align:T,behavior:b,calculateViewLocation:E=Nr,done:f,...v}=p,k=nn(p,m,$-1),A=ut(k,m.offsetTree,g)+x+w,j=A+Pe(m.sizeTree,k)[1],N=d+w,z=d+h-y,V=E({itemBottom:j,itemTop:A,locationParams:{align:T,behavior:b,...v},viewportBottom:z,viewportTop:N});return V?f&&je(R(a,B(D=>!D),qe(le(a)?1:2)),f):f&&f(),V}),B(p=>p!==null)),c),{scrollIntoView:u}},ie(ze,Te,ht,Xe,Fe),{singleton:!0});function Eo(e){return e?e==="smooth"?"smooth":"auto":!1}const zr=(e,t)=>typeof e=="function"?Eo(e(t)):t&&Eo(e),_r=Y(([{listRefresh:e,totalCount:t,fixedItemSize:o,data:n},{atBottomState:r,isAtBottom:s},{scrollToIndex:a},{scrolledToInitialItem:i},{didMount:l,propsReady:c},{log:u},{scrollingInProgress:p},{context:m},{scrollIntoView:h}])=>{const $=O(!1),x=q();let w=null;function y(b){U(a,{align:"end",behavior:b,index:"LAST"})}Z(R(de(R(H(t),qe(1)),l),W(H($),s,i,p),L(([[b,E],f,v,k,A])=>{let j=E&&k,N="auto";return j&&(N=zr(f,v||A),j=j&&!!N),{followOutputBehavior:N,shouldFollow:j,totalCount:b}}),B(({shouldFollow:b})=>b)),({followOutputBehavior:b,totalCount:E})=>{w&&(w(),w=null),le(o)?requestAnimationFrame(()=>{le(u)("following output to ",{totalCount:E},Ce.DEBUG),y(b)}):w=je(e,()=>{le(u)("following output to ",{totalCount:E},Ce.DEBUG),y(b),w=null})});function d(b){const E=je(r,f=>{b&&!f.atBottom&&f.notAtBottomBecause==="SIZE_INCREASED"&&!w&&(le(u)("scrolling to bottom due to increased size",{},Ce.DEBUG),y("auto"))});setTimeout(E,100)}Z(R(de(H($),t,c),B(([b,,E])=>b&&E),Ne(({value:b},[,E])=>({refreshed:b===E,value:E}),{refreshed:!1,value:0}),B(({refreshed:b})=>b),W($,t)),([,b])=>{le(i)&&d(b!==!1)}),Z(x,()=>{d(le($)!==!1)}),Z(de(H($),r),([b,E])=>{b&&!E.atBottom&&E.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const g=O(null),T=q();return M(Bt(R(H(n),L(b=>{var E;return(E=b?.length)!=null?E:0})),R(H(t))),T),Z(R(de(R(T,qe(1)),l),W(H(g),i,p,m),L(([[b,E],f,v,k,A])=>E&&v&&f?.({context:A,totalCount:b,scrollingInProgress:k})),B(b=>!!b),_e(0)),b=>{w&&(w(),w=null),le(o)?requestAnimationFrame(()=>{le(u)("scrolling into view",{}),U(h,b)}):w=je(e,()=>{le(u)("scrolling into view",{}),U(h,b),w=null})}),{autoscrollToBottom:x,followOutput:$,scrollIntoViewOnChange:g}},ie(ze,yt,ht,gt,De,Fe,Te,un,dn)),Hr=Y(([{data:e,firstItemIndex:t,gap:o,sizes:n},{initialTopMostItemIndex:r},{initialItemCount:s,listState:a},{didMount:i}])=>(M(R(i,W(s),B(([,l])=>l!==0),W(r,n,t,o,e),L(([[,l],c,u,p,m,h=[]])=>ln(l,c,u,p,m,h))),a),{}),ie(ze,gt,Xe,De),{singleton:!0}),Br=Y(([{didMount:e},{scrollTo:t},{listState:o}])=>{const n=O(0);return Z(R(e,W(n),B(([,r])=>r!==0),L(([,r])=>({top:r}))),r=>{je(R(o,qe(1),B(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{U(t,r)})})}),{initialScrollTop:n}},ie(De,Te,Xe),{singleton:!0}),pn=Y(([{scrollVelocity:e}])=>{const t=O(!1),o=q(),n=O(!1);return M(R(e,W(n,t,o),B(([r,s])=>!!s),L(([r,s,a,i])=>{const{enter:l,exit:c}=s;if(a){if(c(r,i))return!1}else if(l(r,i))return!0;return a}),se()),t),Z(R(de(t,e,o),W(n)),([[r,s,a],i])=>{r&&i&&i.change&&i.change(s,a)}),{isSeeking:t,scrollSeekConfiguration:n,scrollSeekRangeChanged:o,scrollVelocity:e}},ie(yt),{singleton:!0}),to=Y(([{scrollContainerState:e,scrollTo:t}])=>{const o=q(),n=q(),r=q(),s=O(!1),a=O(void 0);return M(R(de(o,n),L(([{scrollHeight:i,scrollTop:l,viewportHeight:c},{offsetTop:u}])=>({scrollHeight:i,scrollTop:Math.max(0,l-u),viewportHeight:c}))),e),M(R(t,W(n),L(([i,{offsetTop:l}])=>({...i,top:i.top+l}))),r),{customScrollParent:a,useWindowScroll:s,windowScrollContainerState:o,windowScrollTo:r,windowViewportRect:n}},ie(Te)),Fr=Y(([{sizeRanges:e,sizes:t},{headerHeight:o,scrollTop:n},{initialTopMostItemIndex:r},{didMount:s},{useWindowScroll:a,windowScrollContainerState:i,windowViewportRect:l}])=>{const c=q(),u=O(void 0),p=O(null),m=O(null);return M(i,p),M(l,m),Z(R(c,W(t,n,a,p,m,o)),([h,$,x,w,y,d,g])=>{const T=Ir($.sizeTree);w&&y!==null&&d!==null&&(x=y.scrollTop-d.offsetTop),x-=g,h({ranges:T,scrollTop:x})}),M(R(u,B(qt),L(Dr)),r),M(R(s,W(u),B(([,h])=>h!==void 0),se(),L(([,h])=>h.ranges)),e),{getState:c,restoreStateFrom:u}},ie(ze,Te,gt,De,to));function Dr(e){return{align:"start",index:0,offset:e.scrollTop}}const Ur=Y(([{topItemsIndexes:e}])=>{const t=O(0);return M(R(t,B(o=>o>=0),L(o=>Array.from({length:o}).map((n,r)=>r))),e),{topItemCount:t}},ie(Xe));function fn(e){let t=!1,o;return()=>(t||(t=!0,o=e()),o)}const Wr=fn(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Jr=Y(([{deviation:e,scrollBy:t,scrollingInProgress:o,scrollTop:n},{isAtBottom:r,isScrolling:s,lastJumpDueToItemResize:a,scrollDirection:i},{listState:l},{beforeUnshiftWith:c,gap:u,shiftWithOffset:p,sizes:m},{log:h},{recalcInProgress:$}])=>{const x=$e(R(l,W(a),Ne(([,y,d,g],[{bottom:T,items:b,offsetBottom:E,totalCount:f},v])=>{const k=T+E;let A=0;return d===f&&y.length>0&&b.length>0&&(b[0].originalIndex===0&&y[0].originalIndex===0||(A=k-g,A!==0&&(A+=v))),[A,b,f,k]},[0,[],0,0]),B(([y])=>y!==0),W(n,i,o,r,h,$),B(([,y,d,g,,,T])=>!T&&!g&&y!==0&&d===dt),L(([[y],,,,,d])=>(d("Upward scrolling compensation",{amount:y},Ce.DEBUG),y))));function w(y){y>0?(U(t,{behavior:"auto",top:-y}),U(e,0)):(U(e,0),U(t,{behavior:"auto",top:-y}))}return Z(R(x,W(e,s)),([y,d,g])=>{g&&Wr()?U(e,d-y):w(-y)}),Z(R(de(be(s,!1),e,$),B(([y,d,g])=>!y&&!g&&d!==0),L(([y,d])=>d),_e(1)),w),M(R(p,L(y=>({top:-y}))),t),Z(R(c,W(m,u),L(([y,{groupIndices:d,lastSize:g,sizeTree:T},b])=>{function E(f){return f*(g+b)}if(d.length===0)return E(y);{let f=0;const v=lt(T,0);let k=0,A=0;for(;k<y;){k++,f+=v;let j=d.length===A+1?1/0:d[A+1]-d[A]-1;k+j>y&&(f-=v,j=y-k+1),k+=j,f+=E(j),A++}return f}})),y=>{U(e,y),requestAnimationFrame(()=>{U(t,{top:y}),requestAnimationFrame(()=>{U(e,0),U($,!1)})})}),{deviation:e}},ie(Te,yt,Xe,ze,Fe,Xt)),qr=Y(([e,t,o,n,r,s,a,i,l,c,u])=>({...e,...t,...o,...n,...r,...s,...a,...i,...l,...c,...u}),ie(eo,Hr,De,pn,cn,Br,Vr,to,dn,Fe,un)),mn=Y(([{data:e,defaultItemSize:t,firstItemIndex:o,fixedItemSize:n,fixedGroupSize:r,gap:s,groupIndices:a,heightEstimates:i,itemSize:l,sizeRanges:c,sizes:u,statefulTotalCount:p,totalCount:m,trackItemSizes:h},{initialItemFinalLocationReached:$,initialTopMostItemIndex:x,scrolledToInitialItem:w},y,d,g,T,{scrollToIndex:b},E,{topItemCount:f},{groupCounts:v},k])=>{const{listState:A,minOverscanItemCount:j,topItemsIndexes:N,rangeChanged:z,...V}=T;return M(z,k.scrollSeekRangeChanged),M(R(k.windowViewportRect,L(D=>D.visibleHeight)),y.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:o,fixedItemHeight:n,fixedGroupHeight:r,gap:s,groupCounts:v,heightEstimates:i,initialItemFinalLocationReached:$,initialTopMostItemIndex:x,scrolledToInitialItem:w,sizeRanges:c,topItemCount:f,topItemsIndexes:N,totalCount:m,...g,groupIndices:a,itemSize:l,listState:A,minOverscanItemCount:j,scrollToIndex:b,statefulTotalCount:p,trackItemSizes:h,rangeChanged:z,...V,...k,...y,sizes:u,...d}},ie(ze,gt,Te,Fr,_r,Xe,ht,Jr,Ur,rn,qr));function Gr(e,t){const o={},n={};let r=0;const s=e.length;for(;r<s;)n[e[r]]=1,r+=1;for(const a in t)Object.hasOwn(n,a)||(o[a]=t[a]);return o}const vt=typeof document<"u"?C.useLayoutEffect:C.useEffect;function hn(e,t,o){const n=Object.keys(t.required||{}),r=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),a=Object.keys(t.events||{}),i=C.createContext({});function l(w,y){w.propsReady&&U(w.propsReady,!1);for(const d of n){const g=w[t.required[d]];U(g,y[d])}for(const d of r)if(d in y){const g=w[t.optional[d]];U(g,y[d])}w.propsReady&&U(w.propsReady,!0)}function c(w){return s.reduce((y,d)=>(y[d]=g=>{const T=w[t.methods[d]];U(T,g)},y),{})}function u(w){return a.reduce((y,d)=>(y[d]=ur(w[t.events[d]]),y),{})}const p=C.forwardRef((w,y)=>{const{children:d,...g}=w,[T]=C.useState(()=>At(pr(e),f=>{l(f,g)})),[b]=C.useState(yo(u,T));vt(()=>{for(const f of a)f in g&&Z(b[f],g[f]);return()=>{Object.values(b).map(Gt)}},[g,b,T]),vt(()=>{l(T,g)}),C.useImperativeHandle(y,go(c(T)));const E=o;return S.jsx(i.Provider,{value:T,children:o?S.jsx(E,{...Gr([...n,...r,...a],g),children:d}):d})}),m=w=>{const y=C.useContext(i);return C.useCallback(d=>{U(y[w],d)},[y,w])},h=w=>{const y=C.useContext(i)[w],d=C.useCallback(g=>Z(y,g),[y]);return C.useSyncExternalStore(d,()=>le(y),()=>le(y))},$=w=>{const y=C.useContext(i)[w],[d,g]=C.useState(yo(le,y));return vt(()=>Z(y,T=>{T!==d&&g(go(T))}),[y,d]),d},x=C.version.startsWith("18")?h:$;return{Component:p,useEmitter:(w,y)=>{const d=C.useContext(i)[w];vt(()=>Z(d,y),[y,d])},useEmitterValue:x,usePublisher:m}}const gn=C.createContext(void 0),yn=C.createContext(void 0),wn=typeof document<"u"?C.useLayoutEffect:C.useEffect;function zt(e){return"self"in e}function Yr(e){return"body"in e}function xn(e,t,o,n=tt,r,s){const a=C.useRef(null),i=C.useRef(null),l=C.useRef(null),c=C.useCallback(m=>{let h,$,x;const w=m.target;if(Yr(w)||zt(w)){const d=zt(w)?w:w.defaultView;x=s?d.scrollX:d.scrollY,h=s?d.document.documentElement.scrollWidth:d.document.documentElement.scrollHeight,$=s?d.innerWidth:d.innerHeight}else x=s?w.scrollLeft:w.scrollTop,h=s?w.scrollWidth:w.scrollHeight,$=s?w.offsetWidth:w.offsetHeight;const y=()=>{e({scrollHeight:h,scrollTop:Math.max(x,0),viewportHeight:$})};m.suppressFlushSync?y():_o.flushSync(y),i.current!==null&&(x===i.current||x<=0||x===h-$)&&(i.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);C.useEffect(()=>{const m=r||a.current;return n(r||a.current),c({suppressFlushSync:!0,target:m}),m.addEventListener("scroll",c,{passive:!0}),()=>{n(null),m.removeEventListener("scroll",c)}},[a,c,o,n,r]);function u(m){const h=a.current;if(!h||(s?"offsetWidth"in h&&h.offsetWidth===0:"offsetHeight"in h&&h.offsetHeight===0))return;const $=m.behavior==="smooth";let x,w,y;zt(h)?(w=Math.max(He(h.document.documentElement,s?"width":"height"),s?h.document.documentElement.scrollWidth:h.document.documentElement.scrollHeight),x=s?h.innerWidth:h.innerHeight,y=s?window.scrollX:window.scrollY):(w=h[s?"scrollWidth":"scrollHeight"],x=He(h,s?"width":"height"),y=h[s?"scrollLeft":"scrollTop"]);const d=w-x;if(m.top=Math.ceil(Math.max(Math.min(d,m.top),0)),an(x,w)||m.top===y){e({scrollHeight:w,scrollTop:y,viewportHeight:x}),$&&t(!0);return}$?(i.current=m.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,i.current=null,t(!0)},1e3)):i.current=null,s&&(m={behavior:m.behavior,left:m.top}),h.scrollTo(m)}function p(m){s&&(m={behavior:m.behavior,left:m.top}),a.current.scrollBy(m)}return{scrollByCallback:p,scrollerRef:a,scrollToCallback:u}}const _t="-webkit-sticky",Ro="sticky",oo=fn(()=>{if(typeof document>"u")return Ro;const e=document.createElement("div");return e.style.position=_t,e.style.position===_t?_t:Ro});function no(e){return e}const Xr=Y(()=>{const e=O(i=>`Item ${i}`),t=O(i=>`Group ${i}`),o=O({}),n=O(no),r=O("div"),s=O(tt),a=(i,l=null)=>be(R(o,L(c=>c[i]),se()),l);return{components:o,computeItemKey:n,EmptyPlaceholder:a("EmptyPlaceholder"),FooterComponent:a("Footer"),GroupComponent:a("Group","div"),groupContent:t,HeaderComponent:a("Header"),HeaderFooterTag:r,ItemComponent:a("Item","div"),itemContent:e,ListComponent:a("List","div"),ScrollerComponent:a("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:a("ScrollSeekPlaceholder"),TopItemListComponent:a("TopItemList")}}),Zr=Y(([e,t])=>({...e,...t}),ie(mn,Xr)),Qr=({height:e})=>S.jsx("div",{style:{height:e}}),Kr={overflowAnchor:"none",position:oo(),zIndex:1},vn={overflowAnchor:"none"},es={...vn,display:"inline-block",height:"100%"},ko=C.memo(function({showTopList:e=!1}){const t=F("listState"),o=ke("sizeRanges"),n=F("useWindowScroll"),r=F("customScrollParent"),s=ke("windowScrollContainerState"),a=ke("scrollContainerState"),i=r||n?s:a,l=F("itemContent"),c=F("context"),u=F("groupContent"),p=F("trackItemSizes"),m=F("itemSize"),h=F("log"),$=ke("gap"),x=F("horizontalDirection"),{callbackRef:w}=hr(o,m,p,e?tt:i,h,$,r,x,F("skipAnimationFrameInResizeObserver")),[y,d]=C.useState(0);ro("deviation",V=>{y!==V&&d(V)});const g=F("EmptyPlaceholder"),T=F("ScrollSeekPlaceholder")||Qr,b=F("ListComponent"),E=F("ItemComponent"),f=F("GroupComponent"),v=F("computeItemKey"),k=F("isSeeking"),A=F("groupIndices").length>0,j=F("alignToBottom"),N=F("initialItemFinalLocationReached"),z=e?{}:{boxSizing:"border-box",...x?{display:"inline-block",height:"100%",marginLeft:y!==0?y:j?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:j?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...N?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&g?S.jsx(g,{...Se(g,c)}):S.jsx(b,{...Se(b,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:w,style:z,children:(e?t.topItems:t.items).map(V=>{const D=V.originalIndex,X=v(D+t.firstItemIndex,V.data,c);return k?C.createElement(T,{...Se(T,c),height:V.size,index:V.index,key:X,type:V.type||"item",...V.type==="group"?{}:{groupIndex:V.groupIndex}}):V.type==="group"?C.createElement(f,{...Se(f,c),"data-index":D,"data-item-index":V.index,"data-known-size":V.size,key:X,style:Kr},u(V.index,c)):C.createElement(E,{...Se(E,c),...rs(E,V.data),"data-index":D,"data-item-group-index":V.groupIndex,"data-item-index":V.index,"data-known-size":V.size,key:X,style:x?es:vn},A?l(V.index,V.groupIndex,V.data,c):l(V.index,V.data,c))})})}),ts={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},os={outline:"none",overflowX:"auto",position:"relative"},Pt=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),ns={position:oo(),top:0,width:"100%",zIndex:1};function Se(e,t){if(typeof e!="string")return{context:t}}function rs(e,t){return{item:typeof e=="string"?void 0:t}}const ss=C.memo(function(){const e=F("HeaderComponent"),t=ke("headerHeight"),o=F("HeaderFooterTag"),n=Ye(C.useMemo(()=>s=>{t(He(s,"height"))},[t]),!0,F("skipAnimationFrameInResizeObserver")),r=F("context");return e?S.jsx(o,{ref:n,children:S.jsx(e,{...Se(e,r)})}):null}),is=C.memo(function(){const e=F("FooterComponent"),t=ke("footerHeight"),o=F("HeaderFooterTag"),n=Ye(C.useMemo(()=>s=>{t(He(s,"height"))},[t]),!0,F("skipAnimationFrameInResizeObserver")),r=F("context");return e?S.jsx(o,{ref:n,children:S.jsx(e,{...Se(e,r)})}):null});function Sn({useEmitter:e,useEmitterValue:t,usePublisher:o}){return C.memo(function({children:n,style:r,context:s,...a}){const i=o("scrollContainerState"),l=t("ScrollerComponent"),c=o("smoothScrollTargetReached"),u=t("scrollerRef"),p=t("horizontalDirection")||!1,{scrollByCallback:m,scrollerRef:h,scrollToCallback:$}=xn(i,c,l,u,void 0,p);return e("scrollTo",$),e("scrollBy",m),S.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:h,style:{...p?os:ts,...r},tabIndex:0,...a,...Se(l,s),children:n})})}function bn({useEmitter:e,useEmitterValue:t,usePublisher:o}){return C.memo(function({children:n,style:r,context:s,...a}){const i=o("windowScrollContainerState"),l=t("ScrollerComponent"),c=o("smoothScrollTargetReached"),u=t("totalListHeight"),p=t("deviation"),m=t("customScrollParent"),h=C.useRef(null),$=t("scrollerRef"),{scrollByCallback:x,scrollerRef:w,scrollToCallback:y}=xn(i,c,l,$,m);return wn(()=>{var d;return w.current=m||((d=h.current)==null?void 0:d.ownerDocument.defaultView),()=>{w.current=null}},[w,m]),e("windowScrollTo",y),e("scrollBy",x),S.jsx(l,{ref:h,"data-virtuoso-scroller":!0,style:{position:"relative",...r,...u!==0?{height:u+p}:{}},...a,...Se(l,s),children:n})})}const as=({children:e})=>{const t=C.useContext(gn),o=ke("viewportHeight"),n=ke("fixedItemHeight"),r=F("alignToBottom"),s=F("horizontalDirection"),a=C.useMemo(()=>Jo(o,l=>He(l,s?"width":"height")),[o,s]),i=Ye(a,!0,F("skipAnimationFrameInResizeObserver"));return C.useEffect(()=>{t&&(o(t.viewportHeight),n(t.itemHeight))},[t,o,n]),S.jsx("div",{"data-viewport-type":"element",ref:i,style:Pt(r),children:e})},ls=({children:e})=>{const t=C.useContext(gn),o=ke("windowViewportRect"),n=ke("fixedItemHeight"),r=F("customScrollParent"),s=Go(o,r,F("skipAnimationFrameInResizeObserver")),a=F("alignToBottom");return C.useEffect(()=>{t&&(n(t.itemHeight),o({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,o,n]),S.jsx("div",{"data-viewport-type":"window",ref:s,style:Pt(a),children:e})},cs=({children:e})=>{const t=F("TopItemListComponent")||"div",o=F("headerHeight"),n={...ns,marginTop:`${o}px`},r=F("context");return S.jsx(t,{style:n,...Se(t,r),children:e})},us=C.memo(function(e){const t=F("useWindowScroll"),o=F("topItemsIndexes").length>0,n=F("customScrollParent"),r=F("context");return S.jsxs(n||t?fs:ps,{...e,context:r,children:[o&&S.jsx(cs,{children:S.jsx(ko,{showTopList:!0})}),S.jsxs(n||t?ls:as,{children:[S.jsx(ss,{}),S.jsx(ko,{}),S.jsx(is,{})]})]})}),{Component:ds,useEmitter:ro,useEmitterValue:F,usePublisher:ke}=hn(Zr,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",minOverscanItemCount:"minOverscanItemCount",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedGroupHeight:"fixedGroupHeight",fixedItemHeight:"fixedItemHeight",heightEstimates:"heightEstimates",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},us),ps=Sn({useEmitter:ro,useEmitterValue:F,usePublisher:ke}),fs=bn({useEmitter:ro,useEmitterValue:F,usePublisher:ke}),ms=ds,hs=Y(()=>{const e=O(c=>S.jsxs("td",{children:["Item $",c]})),t=O(null),o=O(c=>S.jsxs("td",{colSpan:1e3,children:["Group ",c]})),n=O(null),r=O(null),s=O({}),a=O(no),i=O(tt),l=(c,u=null)=>be(R(s,L(p=>p[c]),se()),u);return{components:s,computeItemKey:a,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:r,fixedHeaderContent:n,itemContent:e,groupContent:o,ScrollerComponent:l("Scroller","div"),scrollerRef:i,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}});ie(mn,hs);oo();const Oo={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},gs={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Ao,floor:$t,max:st,min:Ht,round:jo}=Math;function Po(e,t,o){return Array.from({length:t-e+1}).map((n,r)=>({data:o===null?null:o[r+e],index:r+e}))}function ys(e){return{...gs,items:e}}function St(e,t){return e&&e.width===t.width&&e.height===t.height}function ws(e,t){return e&&e.column===t.column&&e.row===t.row}const xs=Y(([{increaseViewportBy:e,listBoundary:t,overscan:o,visibleRange:n},{footerHeight:r,headerHeight:s,scrollBy:a,scrollContainerState:i,scrollTo:l,scrollTop:c,smoothScrollTargetReached:u,viewportHeight:p},m,h,{didMount:$,propsReady:x},{customScrollParent:w,useWindowScroll:y,windowScrollContainerState:d,windowScrollTo:g,windowViewportRect:T},b])=>{const E=O(0),f=O(0),v=O(Oo),k=O({height:0,width:0}),A=O({height:0,width:0}),j=q(),N=q(),z=O(0),V=O(null),D=O({column:0,row:0}),X=q(),Q=q(),we=O(!1),xe=O(0),ve=O(!0),I=O(!1),_=O(!1);Z(R($,W(xe),B(([P,J])=>!!J)),()=>{U(ve,!1)}),Z(R(de($,ve,A,k,xe,I),B(([P,J,ne,he,,Ee])=>P&&!J&&ne.height!==0&&he.height!==0&&!Ee)),([,,,,P])=>{U(I,!0),Qt(1,()=>{U(j,P)}),je(R(c),()=>{U(t,[0,0]),U(ve,!0)})}),M(R(Q,B(P=>P!=null&&P.scrollTop>0),Ve(0)),f),Z(R($,W(Q),B(([,P])=>P!=null)),([,P])=>{P&&(U(k,P.viewport),U(A,P.item),U(D,P.gap),P.scrollTop>0&&(U(we,!0),je(R(c,qe(1)),J=>{U(we,!1)}),U(l,{top:P.scrollTop})))}),M(R(k,L(({height:P})=>P)),p),M(R(de(H(k,St),H(A,St),H(D,(P,J)=>P&&P.column===J.column&&P.row===J.row),H(c)),L(([P,J,ne,he])=>({gap:ne,item:J,scrollTop:he,viewport:P}))),X),M(R(de(H(E),n,H(D,ws),H(A,St),H(k,St),H(V),H(f),H(we),H(ve),H(xe)),B(([,,,,,,,P])=>!P),L(([P,[J,ne],he,Ee,pe,ce,me,,ue,te])=>{const{column:re,row:Re}=he,{height:ge,width:Lt}=Ee,{width:io}=pe;if(me===0&&(P===0||io===0))return Oo;if(Lt===0){const po=Kt(te,P),Ln=po+Math.max(me-1,0);return ys(Po(po,Ln,ce))}const wt=Tn(io,Lt,re);let Ze,Ue;ue?J===0&&ne===0&&me>0?(Ze=0,Ue=me-1):(Ze=wt*$t((J+Re)/(ge+Re)),Ue=wt*Ao((ne+Re)/(ge+Re))-1,Ue=Ht(P-1,st(Ue,wt-1)),Ze=Ht(Ue,st(0,Ze))):(Ze=0,Ue=-1);const ao=Po(Ze,Ue,ce),{bottom:lo,top:co}=Lo(pe,he,Ee,ao),uo=Ao(P/wt),Pn=uo*ge+(uo-1)*Re-lo;return{bottom:lo,itemHeight:ge,items:ao,itemWidth:Lt,offsetBottom:Pn,offsetTop:co,top:co}})),v),M(R(V,B(P=>P!==null),L(P=>P.length)),E),M(R(de(k,A,v,D),B(([P,J,{items:ne}])=>ne.length>0&&J.height!==0&&P.height!==0),L(([P,J,{items:ne},he])=>{const{bottom:Ee,top:pe}=Lo(P,he,J,ne);return[pe,Ee]}),se(ct)),t);const G=O(!1);M(R(c,W(G),L(([P,J])=>J||P!==0)),G);const K=$e(R(de(v,E),B(([{items:P}])=>P.length>0),W(G),B(([[P,J],ne])=>{const he=P.items[P.items.length-1].index===J-1;return(ne||P.bottom>0&&P.itemHeight>0&&P.offsetBottom===0&&P.items.length===J)&&he}),L(([[,P]])=>P-1),se())),Le=$e(R(H(v),B(({items:P})=>P.length>0&&P[0].index===0),Ve(0),se())),Me=$e(R(H(v),W(we),B(([{items:P},J])=>P.length>0&&!J),L(([{items:P}])=>({endIndex:P[P.length-1].index,startIndex:P[0].index})),se(en),_e(0)));M(Me,h.scrollSeekRangeChanged),M(R(j,W(k,A,E,D),L(([P,J,ne,he,Ee])=>{const pe=sn(P),{align:ce,behavior:me,offset:ue}=pe;let te=pe.index;te==="LAST"&&(te=he-1),te=st(0,te,Ht(he-1,te));let re=Jt(J,Ee,ne,te);return ce==="end"?re=jo(re-J.height+ne.height):ce==="center"&&(re=jo(re-J.height/2+ne.height/2)),ue&&(re+=ue),{behavior:me,top:re}})),l);const ee=be(R(v,L(P=>P.offsetBottom+P.bottom)),0);return M(R(T,L(P=>({height:P.visibleHeight,width:P.visibleWidth}))),k),{customScrollParent:w,data:V,deviation:z,footerHeight:r,gap:D,headerHeight:s,increaseViewportBy:e,initialItemCount:f,itemDimensions:A,overscan:o,restoreStateFrom:Q,scrollBy:a,scrollContainerState:i,scrollHeight:N,scrollTo:l,scrollToIndex:j,scrollTop:c,smoothScrollTargetReached:u,totalCount:E,useWindowScroll:y,viewportDimensions:k,windowScrollContainerState:d,windowScrollTo:g,windowViewportRect:T,...h,gridState:v,horizontalDirection:_,initialTopMostItemIndex:xe,totalListHeight:ee,...m,endReached:K,propsReady:x,rangeChanged:Me,startReached:Le,stateChanged:X,stateRestoreInProgress:we,...b}},ie(eo,Te,yt,pn,De,to,Fe));function Tn(e,t,o){return st(1,$t((e+o)/($t(t)+o)))}function Lo(e,t,o,n){const{height:r}=o;if(r===void 0||n.length===0)return{bottom:0,top:0};const s=Jt(e,t,o,n[0].index);return{bottom:Jt(e,t,o,n[n.length-1].index)+r,top:s}}function Jt(e,t,o,n){const r=Tn(e.width,o.width,t.column),s=$t(n/r),a=s*o.height+st(0,s-1)*t.row;return a>0?a+t.row:a}const vs=Y(()=>{const e=O(p=>`Item ${p}`),t=O({}),o=O(null),n=O("virtuoso-grid-item"),r=O("virtuoso-grid-list"),s=O(no),a=O("div"),i=O(tt),l=(p,m=null)=>be(R(t,L(h=>h[p]),se()),m),c=O(!1),u=O(!1);return M(H(u),c),{components:t,computeItemKey:s,context:o,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:a,itemClassName:n,ItemComponent:l("Item","div"),itemContent:e,listClassName:r,ListComponent:l("List","div"),readyStateChanged:c,reportReadyState:u,ScrollerComponent:l("Scroller","div"),scrollerRef:i,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),Ss=Y(([e,t])=>({...e,...t}),ie(xs,vs)),bs=C.memo(function(){const e=ae("gridState"),t=ae("listClassName"),o=ae("itemClassName"),n=ae("itemContent"),r=ae("computeItemKey"),s=ae("isSeeking"),a=Oe("scrollHeight"),i=ae("ItemComponent"),l=ae("ListComponent"),c=ae("ScrollSeekPlaceholder"),u=ae("context"),p=Oe("itemDimensions"),m=Oe("gap"),h=ae("log"),$=ae("stateRestoreInProgress"),x=Oe("reportReadyState"),w=Ye(C.useMemo(()=>y=>{const d=y.parentElement.parentElement.scrollHeight;a(d);const g=y.firstChild;if(g){const{height:T,width:b}=g.getBoundingClientRect();p({height:T,width:b})}m({column:Mo("column-gap",getComputedStyle(y).columnGap,h),row:Mo("row-gap",getComputedStyle(y).rowGap,h)})},[a,p,m,h]),!0,!1);return wn(()=>{e.itemHeight>0&&e.itemWidth>0&&x(!0)},[e]),$?null:S.jsx(l,{className:t,ref:w,...Se(l,u),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(y=>{const d=r(y.index,y.data,u);return s?S.jsx(c,{...Se(c,u),height:e.itemHeight,index:y.index,width:e.itemWidth},d):C.createElement(i,{...Se(i,u),className:o,"data-index":y.index,key:d},n(y.index,y.data,u))})})}),Ts=C.memo(function(){const e=ae("HeaderComponent"),t=Oe("headerHeight"),o=ae("headerFooterTag"),n=Ye(C.useMemo(()=>s=>{t(He(s,"height"))},[t]),!0,!1),r=ae("context");return e?S.jsx(o,{ref:n,children:S.jsx(e,{...Se(e,r)})}):null}),Cs=C.memo(function(){const e=ae("FooterComponent"),t=Oe("footerHeight"),o=ae("headerFooterTag"),n=Ye(C.useMemo(()=>s=>{t(He(s,"height"))},[t]),!0,!1),r=ae("context");return e?S.jsx(o,{ref:n,children:S.jsx(e,{...Se(e,r)})}):null}),Is=({children:e})=>{const t=C.useContext(yn),o=Oe("itemDimensions"),n=Oe("viewportDimensions"),r=Ye(C.useMemo(()=>s=>{n(s.getBoundingClientRect())},[n]),!0,!1);return C.useEffect(()=>{t&&(n({height:t.viewportHeight,width:t.viewportWidth}),o({height:t.itemHeight,width:t.itemWidth}))},[t,n,o]),S.jsx("div",{ref:r,style:Pt(!1),children:e})},$s=({children:e})=>{const t=C.useContext(yn),o=Oe("windowViewportRect"),n=Oe("itemDimensions"),r=ae("customScrollParent"),s=Go(o,r,!1);return C.useEffect(()=>{t&&(n({height:t.itemHeight,width:t.itemWidth}),o({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,o,n]),S.jsx("div",{ref:s,style:Pt(!1),children:e})},Es=C.memo(function({...e}){const t=ae("useWindowScroll"),o=ae("customScrollParent"),n=o||t?ks:Rs,r=o||t?$s:Is,s=ae("context");return S.jsx(n,{...e,...Se(n,s),children:S.jsxs(r,{children:[S.jsx(Ts,{}),S.jsx(bs,{}),S.jsx(Cs,{})]})})}),{useEmitter:Cn,useEmitterValue:ae,usePublisher:Oe}=hn(Ss,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},Es),Rs=Sn({useEmitter:Cn,useEmitterValue:ae,usePublisher:Oe}),ks=bn({useEmitter:Cn,useEmitterValue:ae,usePublisher:Oe});function Mo(e,t,o){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&o(`${e} was not resolved to pixel value correctly`,t,Ce.WARN),t==="normal"?0:parseInt(t??"0",10)}const Os=({visible:e,onClick:t})=>e?S.jsx("button",{type:"button",className:"chat-scroll-bottom",onClick:t,"aria-label":"Scroll to bottom",children:S.jsx("img",{src:Uo,alt:"arrow up",width:24,height:24,style:{transform:"rotate(180deg)",filter:"var(--icon-filter-text)"}})}):null,As=()=>{const{messages:e=[],classNames:t,isOpen:o,isLoading:n}=Ge(),[r,s]=C.useState(!1),a=C.useRef(null),i=()=>{a.current?.scrollToIndex({index:e.length-1,behavior:"smooth"})},l=e?.length??1;return C.useEffect(()=>{o&&setTimeout(i,0)},[o]),C.useEffect(()=>{i()},[e?.length]),S.jsxs("div",{className:Ae("autoui-chat-messages",t?.messageList),children:[S.jsx(ms,{ref:a,data:e,overscan:100,followOutput:"smooth",atBottomStateChange:c=>s(!c),components:{EmptyPlaceholder:()=>S.jsxs("div",{className:"empty__palceholder",children:[S.jsx("span",{className:"empty__palceholder--main",children:"Nothing here yet"}),S.jsx("span",{className:"empty__palceholder--secondary",children:"Start the conversation!"})]})},initialTopMostItemIndex:l-1,itemContent:(c,u)=>S.jsx("div",{className:Ae("autoui-message-row",u.role==="user"&&"is-user",u.role==="assistant"&&"is-assistant"),children:S.jsx(rr,{message:u})})}),S.jsx(Os,{visible:r,onClick:i}),n&&S.jsx(_n,{variant:"dots",color:"#0a84ff"})]})};async function js(e){const t=e.getReader(),o=new TextDecoder;let n="",r="";for(;;){const{value:a,done:i}=await t.read();if(i)break;n+=o.decode(a,{stream:!0});const l=n.split(`
|
|
6
|
+
<%s key={someKey} {...props} />`,K,ee,P,ee),be[ee+K]=!0)}if(ee=null,G!==void 0&&(o(G),ee=""+G),a(F)&&(o(F.key),ee=""+F.key),"key"in F){G={};for(var J in F)J!=="key"&&(G[J]=F[J])}else G=F;return ee&&i(G,typeof E=="function"?E.displayName||E.name||"Unknown":E),c(E,ee,G,s(),Le,Me)}function m(E){f(E)?E._store&&(E._store.validated=1):typeof E=="object"&&E!==null&&E.$$typeof===k&&(E._payload.status==="fulfilled"?f(E._payload.value)&&E._payload.value._store&&(E._payload.value._store.validated=1):E._store&&(E._store.validated=1))}function f(E){return typeof E=="object"&&E!==null&&E.$$typeof===T}var h=I,T=Symbol.for("react.transitional.element"),v=Symbol.for("react.portal"),x=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),p=Symbol.for("react.profiler"),g=Symbol.for("react.consumer"),$=Symbol.for("react.context"),b=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),w=Symbol.for("react.memo"),k=Symbol.for("react.lazy"),A=Symbol.for("react.activity"),j=Symbol.for("react.client.reference"),M=h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,z=Object.prototype.hasOwnProperty,V=Array.isArray,H=console.createTask?console.createTask:function(){return null};h={react_stack_bottom_frame:function(E){return E()}};var Y,Q={},we=h.react_stack_bottom_frame.bind(h,r)(),xe=H(n(r)),be={};nt.Fragment=x,nt.jsx=function(E,F,G){var K=1e4>M.recentlyCreatedOwnerStacks++;return u(E,F,G,!1,K?Error("react-stack-top-frame"):we,K?H(n(E)):xe)},nt.jsxs=function(E,F,G){var K=1e4>M.recentlyCreatedOwnerStacks++;return u(E,F,G,!0,K?Error("react-stack-top-frame"):we,K?H(n(E)):xe)}})()),nt}var ho;function zn(){return ho||(ho=1,process.env.NODE_ENV==="production"?bt.exports=Vn():bt.exports=Nn()),bt.exports}var S=zn();function Bo(e){var t,o,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(t=0;t<s;t++)e[t]&&(o=Bo(e[t]))&&(n&&(n+=" "),n+=o)}else for(o in e)e[o]&&(n&&(n+=" "),n+=o);return n}function ye(){for(var e,t,o=0,n="",s=arguments.length;o<s;o++)(e=arguments[o])&&(t=Bo(e))&&(n&&(n+=" "),n+=t);return n}const Fn=I.forwardRef(({variant:e="default",label:t,className:o,classNames:n={},color:s="currentColor",...r},a)=>{const i=I.useMemo(()=>{switch(e){case"wave":case"dots":return S.jsx("div",{className:ye("spinner-dots-wrapper",n.wrapper),children:[0,1,2].map(l=>S.jsx("i",{className:ye("spinner-dot",n.dots),style:{animationDelay:`${l*.2}s`,backgroundColor:s}},l))});case"simple":return S.jsxs("svg",{className:ye("spinner-simple",n.wrapper),width:"24",height:"24",fill:"none",viewBox:"0 0 24 24",style:{color:s},children:[S.jsx("circle",{className:ye("spinner-simple-circle1",n.circle1),cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),S.jsx("path",{className:ye("spinner-simple-circle2",n.circle2),fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.37 0 0 5.37 0 12h4z"})]});case"spinner":return S.jsx("div",{className:ye("spinner-bars-wrapper",n.wrapper),children:[...Array(12)].map((l,c)=>S.jsx("i",{className:ye("spinner-bar",n.spinnerBars),style:{transform:`rotate(${c*30}deg) translateY(-8px)`,animationDelay:`${c*.1}s`,backgroundColor:s}},c))});default:return S.jsxs("div",{className:ye("spinner-default",n.wrapper),children:[S.jsx("i",{className:ye("spinner-default-circle1",n.circle1),style:{borderColor:s}}),S.jsx("i",{className:ye("spinner-default-circle2",n.circle2),style:{borderColor:s}})]})}},[e,n,s]);return S.jsxs("div",{ref:a,className:ye("spinner-base",o),"aria-label":t||"Loading",...r,children:[i,t&&S.jsx("span",{className:ye("spinner-label",n.label),children:t})]})}),_o=I.createContext(void 0),Bn=({children:e,value:t,config:o})=>S.jsx(_o.Provider,{value:{...t,config:o},children:e}),Ge=()=>{const e=I.useContext(_o);if(!e)throw new Error("useChatContext must be used within a ChatProvider");return e};function Oe(...e){return e.filter(Boolean).join(" ")}const Ho="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3c!--%20Uploaded%20to:%20SVG%20Repo,%20www.svgrepo.com,%20Generator:%20SVG%20Repo%20Mixer%20Tools%20--%3e%3csvg%20width='800px'%20height='800px'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4%2012H20M12%204V20'%20stroke='%23000000'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",Do="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20640%20640'%3e%3c!--!Font%20Awesome%20Free%207.1.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license/free%20Copyright%202025%20Fonticons,%20Inc.--%3e%3cpath%20d='M183.1%20137.4C170.6%20124.9%20150.3%20124.9%20137.8%20137.4C125.3%20149.9%20125.3%20170.2%20137.8%20182.7L275.2%20320L137.9%20457.4C125.4%20469.9%20125.4%20490.2%20137.9%20502.7C150.4%20515.2%20170.7%20515.2%20183.2%20502.7L320.5%20365.3L457.9%20502.6C470.4%20515.1%20490.7%20515.1%20503.2%20502.6C515.7%20490.1%20515.7%20469.8%20503.2%20457.3L365.8%20320L503.1%20182.6C515.6%20170.1%20515.6%20149.8%20503.1%20137.3C490.6%20124.8%20470.3%20124.8%20457.8%20137.3L320.5%20274.7L183.1%20137.4z'/%3e%3c/svg%3e",Uo="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3c!--%20Uploaded%20to:%20SVG%20Repo,%20www.svgrepo.com,%20Generator:%20SVG%20Repo%20Mixer%20Tools%20--%3e%3csvg%20width='800px'%20height='800px'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M12%206V18M12%206L7%2011M12%206L17%2011'%20stroke='%23000000'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",_n="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3c!--%20Uploaded%20to:%20SVG%20Repo,%20www.svgrepo.com,%20Generator:%20SVG%20Repo%20Mixer%20Tools%20--%3e%3csvg%20width='800px'%20height='800px'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4%2018L20%2018'%20stroke='%23000000'%20stroke-width='2'%20stroke-linecap='round'/%3e%3cpath%20d='M4%2012L20%2012'%20stroke='%23000000'%20stroke-width='2'%20stroke-linecap='round'/%3e%3cpath%20d='M4%206L20%206'%20stroke='%23000000'%20stroke-width='2'%20stroke-linecap='round'/%3e%3c/svg%3e",Hn="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3c!--%20Uploaded%20to:%20SVG%20Repo,%20www.svgrepo.com,%20Generator:%20SVG%20Repo%20Mixer%20Tools%20--%3e%3csvg%20width='800px'%20height='800px'%20viewBox='0%200%201024%201024'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill='%23000000'%20d='M352%20192V95.936a32%2032%200%200%201%2032-32h256a32%2032%200%200%201%2032%2032V192h256a32%2032%200%201%201%200%2064H96a32%2032%200%200%201%200-64h256zm64%200h192v-64H416v64zM192%20960a32%2032%200%200%201-32-32V256h704v672a32%2032%200%200%201-32%2032H192zm224-192a32%2032%200%200%200%2032-32V416a32%2032%200%200%200-64%200v320a32%2032%200%200%200%2032%2032zm192%200a32%2032%200%200%200%2032-32V416a32%2032%200%200%200-64%200v320a32%2032%200%200%200%2032%2032z'/%3e%3c/svg%3e",Dn="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20640%20640'%3e%3c!--!Font%20Awesome%20Free%207.1.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license/free%20Copyright%202025%20Fonticons,%20Inc.--%3e%3cpath%20d='M210.2%2053.9C217.6%2050.8%20226%2051.7%20232.7%2056.1L320.5%20114.3L408.3%2056.1C415%2051.7%20423.4%2050.9%20430.8%2053.9C438.2%2056.9%20443.4%2063.5%20445%2071.3L465.9%20174.5L569.1%20195.4C576.9%20197%20583.5%20202.4%20586.5%20209.7C589.5%20217%20588.7%20225.5%20584.3%20232.2L526.1%20320L584.3%20407.8C588.7%20414.5%20589.5%20422.9%20586.5%20430.3C583.5%20437.7%20576.9%20443.1%20569.1%20444.6L465.8%20465.4L445%20568.7C443.4%20576.5%20438%20583.1%20430.7%20586.1C423.4%20589.1%20414.9%20588.3%20408.2%20583.9L320.4%20525.7L232.6%20583.9C225.9%20588.3%20217.5%20589.1%20210.1%20586.1C202.7%20583.1%20197.3%20576.5%20195.8%20568.7L175%20465.4L71.7%20444.5C63.9%20442.9%2057.3%20437.5%2054.3%20430.2C51.3%20422.9%2052.1%20414.4%2056.5%20407.7L114.7%20320L56.5%20232.2C52.1%20225.5%2051.3%20217.1%2054.3%20209.7C57.3%20202.3%2063.9%20196.9%2071.7%20195.4L175%20174.6L195.9%2071.3C197.5%2063.5%20202.9%2056.9%20210.2%2053.9zM239.6%20320C239.6%20275.6%20275.6%20239.6%20320%20239.6C364.4%20239.6%20400.4%20275.6%20400.4%20320C400.4%20364.4%20364.4%20400.4%20320%20400.4C275.6%20400.4%20239.6%20364.4%20239.6%20320zM448.4%20320C448.4%20249.1%20390.9%20191.6%20320%20191.6C249.1%20191.6%20191.6%20249.1%20191.6%20320C191.6%20390.9%20249.1%20448.4%20320%20448.4C390.9%20448.4%20448.4%20390.9%20448.4%20320z'/%3e%3c/svg%3e",Un="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20640%20640'%3e%3c!--!Font%20Awesome%20Free%207.1.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license/free%20Copyright%202025%20Fonticons,%20Inc.--%3e%3cpath%20d='M320%2064C178.6%2064%2064%20178.6%2064%20320C64%20461.4%20178.6%20576%20320%20576C388.8%20576%20451.3%20548.8%20497.3%20504.6C504.6%20497.6%20506.7%20486.7%20502.6%20477.5C498.5%20468.3%20488.9%20462.6%20478.8%20463.4C473.9%20463.8%20469%20464%20464%20464C362.4%20464%20280%20381.6%20280%20280C280%20207.9%20321.5%20145.4%20382.1%20115.2C391.2%20110.7%20396.4%20100.9%20395.2%2090.8C394%2080.7%20386.6%2072.5%20376.7%2070.3C358.4%2066.2%20339.4%2064%20320%2064z'/%3e%3c/svg%3e",Wn="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20640%20640'%3e%3c!--!Font%20Awesome%20Free%207.1.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license/free%20Copyright%202025%20Fonticons,%20Inc.--%3e%3cpath%20d='M320%2064C267%2064%20224%20107%20224%20160L224%20288C224%20341%20267%20384%20320%20384C373%20384%20416%20341%20416%20288L416%20160C416%20107%20373%2064%20320%2064zM176%20248C176%20234.7%20165.3%20224%20152%20224C138.7%20224%20128%20234.7%20128%20248L128%20288C128%20385.9%20201.3%20466.7%20296%20478.5L296%20528L248%20528C234.7%20528%20224%20538.7%20224%20552C224%20565.3%20234.7%20576%20248%20576L392%20576C405.3%20576%20416%20565.3%20416%20552C416%20538.7%20405.3%20528%20392%20528L344%20528L344%20478.5C438.7%20466.7%20512%20385.9%20512%20288L512%20248C512%20234.7%20501.3%20224%20488%20224C474.7%20224%20464%20234.7%20464%20248L464%20288C464%20367.5%20399.5%20432%20320%20432C240.5%20432%20176%20367.5%20176%20288L176%20248z'/%3e%3c/svg%3e",Jn=({isOpen:e,onClose:t,triggerRef:o,children:n,styles:s,position:r="top-center"})=>{const a=I.useRef(null);if(I.useEffect(()=>{const c=u=>{a.current&&!a.current.contains(u.target)&&!o.current?.contains(u.target)&&t()};return e&&document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[e,t,o]),!e||!o.current)return null;const i=o.current.getBoundingClientRect();let l={};switch(r){case"top-center":l={width:"50%",transform:"translate(-2.5%, -110%)"};break;case"bottom-left":l={top:i.bottom+6+window.scrollY,left:i.left+window.scrollX};break;case"bottom-right":l={top:i.bottom+6+window.scrollY,left:i.right+window.scrollX,transform:"translateX(-100%)"};break}return S.jsx("div",{ref:a,style:{position:"absolute",zIndex:9999,...l,...s},children:n})};function qn({isSelected:e,disableAnimation:t,...o}){return S.jsx("svg",{"aria-hidden":"true","data-selected":e,role:"presentation",viewBox:"0 0 17 18",...o,children:S.jsx("polyline",{fill:"none",points:"1 9 7 14 15 4",stroke:"currentColor",strokeDasharray:22,strokeDashoffset:e?44:66,strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,style:t?{}:{transition:"stroke-dashoffset 200ms ease"}})})}const Gn=({label:e,description:t,shortcut:o,startContent:n,endContent:s,isSelected:r,isDisabled:a,onSelect:i,disableAnimation:l,hideSelectedIcon:c,selectedIcon:u})=>{const m=I.useMemo(()=>{const f=S.jsx(qn,{disableAnimation:l,isSelected:!!r});return typeof u=="function"?u({icon:f,isSelected:r,isDisabled:a}):u||f},[u,r,a,l]);return S.jsxs("li",{className:`hero-menu-item ${r?"selected":""} ${a?"disabled":""}`,onClick:()=>{console.log(1),!a&&i?.()},children:[n&&S.jsx("span",{className:"start",children:n}),S.jsxs("div",{className:"content",children:[S.jsx("span",{className:"label",children:e}),t&&S.jsx("span",{className:"description",children:t})]}),o&&S.jsx("kbd",{className:"shortcut",children:o}),!c&&S.jsx("span",{className:"selected-icon",children:m}),s&&S.jsx("span",{className:"end",children:s})]})},Yn=({items:e,defaultSelectedKey:t,onSelectionChange:o})=>{const[n,s]=I.useState(t),r=a=>{s(a),o?.(a)};return S.jsx("ul",{className:"hero-menu",children:e.map(a=>S.jsx(Gn,{label:a.label,description:a.description,shortcut:a.shortcut,startContent:a.startContent,endContent:a.endContent,isSelected:a.key===n,isDisabled:a.isDisabled,onSelect:()=>{a?.onSelect?.(),r(a.key)}},a.key))})},Xn=({items:e,button:t,popoverStyles:o,defaultSelectedKey:n,closeAfterSelect:s,onSelectionChange:r})=>{const a=I.useRef(null),[i,l]=I.useState(!1),c={ref:a,onClick:()=>{l(u=>!u)},style:{cursor:"pointer"}};return S.jsxs(S.Fragment,{children:[t?I.cloneElement(t,c):S.jsx("button",{ref:a,onClick:()=>l(u=>!u),style:{cursor:"pointer"},children:S.jsx("img",{src:_n,alt:"menu"})}),S.jsx(Jn,{styles:o,isOpen:i,onClose:()=>l(!1),triggerRef:a,children:S.jsx("div",{style:{borderRadius:10,zIndex:9999,boxShadow:"0 4px 12px rgba(0,0,0,0.12)"},children:S.jsx(Yn,{items:e,defaultSelectedKey:n,onSelectionChange:u=>{r?.(u),s?.(u)&&l(!1)}})})})]})},Zn=Mt.forwardRef(function({checked:t,defaultChecked:o,onCheckedChange:n,disabled:s=!1,required:r=!1,name:a,value:i,id:l,label:c,description:u,size:m="md",className:f,trackClassName:h,thumbClassName:T,labelClassName:v,startContent:x,endContent:y,thumb:p,"aria-label":g,"aria-labelledby":$},b){const C=typeof t=="boolean",[d,w]=Mt.useState(!!o),k=C?!!t:d,A=l??Mt.useId(),j=z=>{const V=z.target.checked;C||w(V),n?.(V,z)},M=p?.({checked:k,disabled:s,size:m})??(k?y:x);return S.jsxs("label",{className:Oe("autoui-switch",`autoui-switch--${m}`,s&&"is-disabled",f),htmlFor:A,children:[S.jsxs("span",{className:Oe("autoui-switch__control",h),"aria-hidden":"true",children:[S.jsx("input",{ref:b,id:A,className:"autoui-switch__input",type:"checkbox",checked:k,defaultChecked:o,onChange:j,disabled:s,required:r,name:a,value:i,"aria-label":g,"aria-labelledby":$}),S.jsx("span",{className:Oe("autoui-switch__track")}),S.jsx("span",{className:Oe("autoui-switch__thumb",T),children:M?S.jsx("span",{className:"autoui-switch__thumbContent",children:M}):null})]}),(c||u)&&S.jsxs("span",{className:Oe("autoui-switch__text",v),children:[c&&S.jsx("span",{className:"autoui-switch__label",children:c}),u&&S.jsx("span",{className:"autoui-switch__description",children:u})]})]})}),Qn=()=>{const{handleClear:e,setTheme:t,theme:o}=Ge();return S.jsx(Xn,{popoverStyles:{position:"absolute"},button:S.jsx("button",{type:"button",className:"autoui-chat-input-start",children:S.jsx("img",{src:Ho,alt:"menu",width:20,height:20,style:{filter:"var(--icon-filter-text)"}})}),items:[{startContent:S.jsx("img",{src:Hn,width:16,height:16,style:{filter:"var(--icon-filter-text)"}}),key:"clear",label:"Clear Messages",onSelect:e},{key:"switchTheme",label:S.jsx(Zn,{defaultChecked:o==="light",onCheckedChange:n=>{t?.(n?"light":"dark")},label:"Theme mode",thumb:({checked:n})=>S.jsx(S.Fragment,{children:n?S.jsx("img",{src:Dn,width:14,height:14,style:{filter:"var(--icon-filter-accent)"}}):S.jsx("img",{src:Un,width:14,height:14,style:{filter:"var(--icon-filter-text)"}})})})}],closeAfterSelect:n=>n!=="switchTheme",onSelectionChange:n=>console.log("Selected:",n)})},Kn=({value:e,setValue:t})=>{const{classNames:o}=Ge();return S.jsx("input",{role:"input",className:Oe("autoui-chat-textbox",o?.input),type:"text",value:e,autoFocus:!0,onChange:n=>t(n.target.value),placeholder:"Type a message...","aria-label":"Message input"})},er=()=>{const{classNames:e}=Ge();return S.jsx("button",{role:"inputButton",type:"submit",className:Oe("autoui-chat-send",e?.inputButton),"aria-label":"Send message",children:S.jsx("img",{src:Uo,alt:"arrow up",width:24,height:24,style:{filter:"var(--icon-filter-text)"}})})},tr=({lang:e="en-us"}={})=>{const t=I.useRef(null),[o,n]=I.useState(""),[s,r]=I.useState(!1),a=typeof window<"u"&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window),i=I.useCallback(()=>{if(!a||s)return;const c=window.SpeechRecognition||window.webkitSpeechRecognition;if(!c)return;const u=new c;u.lang=e,u.continuous=!1,u.interimResults=!1,u.onstart=()=>r(!0),u.onend=()=>r(!1),u.onresult=m=>{const f=m.results[0][0].transcript;n(f),r(!1)},u.onerror=()=>{u.stop(),r(!1)},t.current=u,u.start()},[a,s,e]),l=I.useCallback(()=>{t.current?.stop(),r(!1)},[]);return{start:i,stop:l,text:o,listening:s,isSupported:a}},or=({active:e,onClick:t})=>S.jsx("button",{type:"button",className:`chat-mic-btn ${e?"is-active":""}`,onClick:t,"aria-label":"Voice input",children:S.jsx("img",{src:Wn,width:20,height:20,style:{filter:"var(--icon-filter-text)"}})}),nr=()=>{const{classNames:e,handleSend:t}=Ge(),[o,n]=I.useState(""),s=tr({lang:"en-us"});I.useEffect(()=>{s.text&&n(a=>a?`${a} ${s.text}`:s.text)},[s.text]);const r=a=>{a.preventDefault(),t(o),n("")};return S.jsxs("form",{className:Oe("autoui-chat-input",e?.inputWrapper),onSubmit:r,children:[S.jsx(Qn,{}),S.jsx(Kn,{value:o,setValue:n}),s.isSupported&&S.jsx(or,{active:s.listening,onClick:()=>{s.listening?s.stop():s.start()}}),S.jsx(er,{})]})},rr=({message:e})=>{const t=e.role==="user",{classNames:o}=Ge(),n=typeof e.content=="string"||e.content instanceof String;return S.jsx("div",{role:"message",className:ye("autoui-chat-message",t?"user":"assistant",o?.message),"aria-label":t?"User message":"Assistant message",children:S.jsx("div",{className:`autoui-chat-bubble ${n?"autoui-chat-bubble--string":"autoui-chat-bubble--react-node"}`,children:e.content})})},At=0,_e=1,et=2,Wo=4;function go(e){return()=>e}function sr(e){e()}function Jo(e,t){return o=>e(t(o))}function yo(e,t){return()=>e(t)}function ir(e,t){return o=>e(t,o)}function qt(e){return e!==void 0}function ar(...e){return()=>{e.map(sr)}}function tt(){}function Ot(e,t){return t(e),e}function lr(e,t){return t(e)}function ie(...e){return e}function Z(e,t){return e(_e,t)}function U(e,t){e(At,t)}function Gt(e){e(et)}function le(e){return e(Wo)}function N(e,t){return Z(e,ir(t,At))}function je(e,t){const o=e(_e,n=>{o(),t(n)});return o}function wo(e){let t,o;return n=>s=>{t=s,o&&clearTimeout(o),o=setTimeout(()=>{n(t)},e)}}function qo(e,t){return e===t}function se(e=qo){let t;return o=>n=>{e(t,n)||(t=n,o(n))}}function _(e){return t=>o=>{e(o)&&t(o)}}function L(e){return t=>Jo(t,e)}function Ve(e){return t=>()=>{t(e)}}function R(e,...t){const o=cr(...t);return(n,s)=>{switch(n){case et:Gt(e);return;case _e:return Z(e,o(s))}}}function Ne(e,t){return o=>n=>{o(t=e(t,n))}}function qe(e){return t=>o=>{e>0?e--:t(o)}}function Fe(e){let t=null,o;return n=>s=>{t=s,!o&&(o=setTimeout(()=>{o=void 0,n(t)},e))}}function W(...e){const t=new Array(e.length);let o=0,n=null;const s=Math.pow(2,e.length)-1;return e.forEach((r,a)=>{const i=Math.pow(2,a);Z(r,l=>{const c=o;o=o|i,t[a]=l,c!==s&&o===s&&n&&(n(),n=null)})}),r=>a=>{const i=()=>{r([a].concat(t))};o===s?i():n=i}}function cr(...e){return t=>e.reduceRight(lr,t)}function ur(e){let t,o;const n=()=>t?.();return function(s,r){switch(s){case _e:return r?o===r?void 0:(n(),o=r,t=Z(e,r),t):(n(),tt);case et:n(),o=null;return}}}function O(e){let t=e;const o=q();return(n,s)=>{switch(n){case At:t=s;break;case _e:{s(t);break}case Wo:return t}return o(n,s)}}function Se(e,t){return Ot(O(t),o=>N(e,o))}function q(){const e=[];return(t,o)=>{switch(t){case At:e.slice().forEach(n=>{n(o)});return;case et:e.splice(0,e.length);return;case _e:return e.push(o),()=>{const n=e.indexOf(o);n>-1&&e.splice(n,1)}}}}function Ie(e){return Ot(q(),t=>N(e,t))}function X(e,t=[],{singleton:o}={singleton:!0}){return{constructor:e,dependencies:t,id:dr(),singleton:o}}const dr=()=>Symbol();function pr(e){const t=new Map,o=({constructor:n,dependencies:s,id:r,singleton:a})=>{if(a&&t.has(r))return t.get(r);const i=n(s.map(l=>o(l)));return a&&t.set(r,i),i};return o(e)}function de(...e){const t=q(),o=new Array(e.length);let n=0;const s=Math.pow(2,e.length)-1;return e.forEach((r,a)=>{const i=Math.pow(2,a);Z(r,l=>{o[a]=l,n=n|i,n===s&&U(t,o)})}),function(r,a){switch(r){case et:{Gt(t);return}case _e:return n===s&&a(o),Z(t,a)}}}function B(e,t=qo){return R(e,se(t))}function _t(...e){return function(t,o){switch(t){case et:return;case _e:return ar(...e.map(n=>Z(n,o)))}}}var Ce=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Ce||{});const fr={0:"debug",3:"error",1:"log",2:"warn"},mr=()=>typeof globalThis>"u"?window:globalThis,He=X(()=>{const e=O(3);return{log:O((t,o,n=1)=>{var s;const r=(s=mr().VIRTUOSO_LOG_LEVEL)!=null?s:le(e);n>=r&&console[fr[n]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,o)}),logLevel:e}},[],{singleton:!0});function Ye(e,t,o){return Yt(e,t,o).callbackRef}function Yt(e,t,o){const n=I.useRef(null);let s=a=>{};const r=I.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(a=>{const i=()=>{const l=a[0].target;l.offsetParent!==null&&e(l)};o?i():requestAnimationFrame(i)}):null,[e,o]);return s=a=>{a&&t?(r?.observe(a),n.current=a):(n.current&&r?.unobserve(n.current),n.current=null)},{callbackRef:s,ref:n}}function hr(e,t,o,n,s,r,a,i,l){const c=I.useCallback(u=>{const m=gr(u.children,t,i?"offsetWidth":"offsetHeight",s);let f=u.parentElement;for(;!f.dataset.virtuosoScroller;)f=f.parentElement;const h=f.lastElementChild.dataset.viewportType==="window";let T;h&&(T=f.ownerDocument.defaultView);const v=a?i?a.scrollLeft:a.scrollTop:h?i?T.scrollX||T.document.documentElement.scrollLeft:T.scrollY||T.document.documentElement.scrollTop:i?f.scrollLeft:f.scrollTop,x=a?i?a.scrollWidth:a.scrollHeight:h?i?T.document.documentElement.scrollWidth:T.document.documentElement.scrollHeight:i?f.scrollWidth:f.scrollHeight,y=a?i?a.offsetWidth:a.offsetHeight:h?i?T.innerWidth:T.innerHeight:i?f.offsetWidth:f.offsetHeight;n({scrollHeight:x,scrollTop:Math.max(v,0),viewportHeight:y}),r?.(i?xo("column-gap",getComputedStyle(u).columnGap,s):xo("row-gap",getComputedStyle(u).rowGap,s)),m!==null&&e(m)},[e,t,s,r,a,n,i]);return Yt(c,o,l)}function gr(e,t,o,n){const s=e.length;if(s===0)return null;const r=[];for(let a=0;a<s;a++){const i=e.item(a);if(i.dataset.index===void 0)continue;const l=parseInt(i.dataset.index),c=parseFloat(i.dataset.knownSize),u=t(i,o);if(u===0&&n("Zero-sized element, this should not happen",{child:i},Ce.ERROR),u===c)continue;const m=r[r.length-1];r.length===0||m.size!==u||m.endIndex!==l-1?r.push({endIndex:l,size:u,startIndex:l}):r[r.length-1].endIndex++}return r}function xo(e,t,o){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&o(`${e} was not resolved to pixel value correctly`,t,Ce.WARN),t==="normal"?0:parseInt(t??"0",10)}function Go(e,t,o){const n=I.useRef(null),s=I.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const c=l.getBoundingClientRect(),u=c.width;let m,f;if(t){const h=t.getBoundingClientRect(),T=c.top-h.top;f=h.height-Math.max(0,T),m=T+t.scrollTop}else{const h=a.current.ownerDocument.defaultView;f=h.innerHeight-Math.max(0,c.top),m=c.top+h.scrollY}n.current={offsetTop:m,visibleHeight:f,visibleWidth:u},e(n.current)},[e,t]),{callbackRef:r,ref:a}=Yt(s,!0,o),i=I.useCallback(()=>{s(a.current)},[s,a]);return I.useEffect(()=>{var l;if(t){t.addEventListener("scroll",i);const c=new ResizeObserver(()=>{requestAnimationFrame(i)});return c.observe(t),()=>{t.removeEventListener("scroll",i),c.unobserve(t)}}else{const c=(l=a.current)==null?void 0:l.ownerDocument.defaultView;return c?.addEventListener("scroll",i),c?.addEventListener("resize",i),()=>{c?.removeEventListener("scroll",i),c?.removeEventListener("resize",i)}}},[i,t,a]),r}const Te=X(()=>{const e=q(),t=q(),o=O(0),n=q(),s=O(0),r=q(),a=q(),i=O(0),l=O(0),c=O(0),u=O(0),m=q(),f=q(),h=O(!1),T=O(!1),v=O(!1);return N(R(e,L(({scrollTop:x})=>x)),t),N(R(e,L(({scrollHeight:x})=>x)),a),N(t,s),{deviation:o,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:u,headerHeight:i,horizontalDirection:T,scrollBy:f,scrollContainerState:e,scrollHeight:a,scrollingInProgress:h,scrollTo:m,scrollTop:t,skipAnimationFrameInResizeObserver:v,smoothScrollTargetReached:n,statefulScrollTop:s,viewportHeight:r}},[],{singleton:!0}),lt={lvl:0};function Yo(e,t){const o=e.length;if(o===0)return[];let{index:n,value:s}=t(e[0]);const r=[];for(let a=1;a<o;a++){const{index:i,value:l}=t(e[a]);r.push({end:i-1,start:n,value:s}),n=i,s=l}return r.push({end:1/0,start:n,value:s}),r}function oe(e){return e===lt}function ct(e,t){if(!oe(e))return t===e.k?e.v:t<e.k?ct(e.l,t):ct(e.r,t)}function Pe(e,t,o="k"){if(oe(e))return[-1/0,void 0];if(Number(e[o])===t)return[e.k,e.v];if(Number(e[o])<t){const n=Pe(e.r,t,o);return n[0]===-1/0?[e.k,e.v]:n}return Pe(e.l,t,o)}function $e(e,t,o){return oe(e)?Qo(t,o,1):t===e.k?fe(e,{k:t,v:o}):t<e.k?bo(fe(e,{l:$e(e.l,t,o)})):bo(fe(e,{r:$e(e.r,t,o)}))}function Qe(){return lt}function Ke(e,t,o){if(oe(e))return[];const n=Pe(e,t)[0];return yr(Dt(e,n,o))}function Ht(e,t){if(oe(e))return lt;const{k:o,l:n,r:s}=e;if(t===o){if(oe(n))return s;if(oe(s))return n;{const[r,a]=Zo(n);return Ct(fe(e,{k:r,l:Xo(n),v:a}))}}else return t<o?Ct(fe(e,{l:Ht(n,t)})):Ct(fe(e,{r:Ht(s,t)}))}function We(e){return oe(e)?[]:[...We(e.l),{k:e.k,v:e.v},...We(e.r)]}function Dt(e,t,o){if(oe(e))return[];const{k:n,l:s,r,v:a}=e;let i=[];return n>t&&(i=i.concat(Dt(s,t,o))),n>=t&&n<=o&&i.push({k:n,v:a}),n<=o&&(i=i.concat(Dt(r,t,o))),i}function Ct(e){const{l:t,lvl:o,r:n}=e;if(n.lvl>=o-1&&t.lvl>=o-1)return e;if(o>n.lvl+1){if(Vt(t))return Ko(fe(e,{lvl:o-1}));if(!oe(t)&&!oe(t.r))return fe(t.r,{l:fe(t,{r:t.r.l}),lvl:o,r:fe(e,{l:t.r.r,lvl:o-1})});throw new Error("Unexpected empty nodes")}else{if(Vt(e))return Ut(fe(e,{lvl:o-1}));if(!oe(n)&&!oe(n.l)){const s=n.l,r=Vt(s)?n.lvl-1:n.lvl;return fe(s,{l:fe(e,{lvl:o-1,r:s.l}),lvl:s.lvl+1,r:Ut(fe(n,{l:s.r,lvl:r}))})}else throw new Error("Unexpected empty nodes")}}function fe(e,t){return Qo(t.k!==void 0?t.k:e.k,t.v!==void 0?t.v:e.v,t.lvl!==void 0?t.lvl:e.lvl,t.l!==void 0?t.l:e.l,t.r!==void 0?t.r:e.r)}function Xo(e){return oe(e.r)?e.l:Ct(fe(e,{r:Xo(e.r)}))}function Vt(e){return oe(e)||e.lvl>e.r.lvl}function Zo(e){return oe(e.r)?[e.k,e.v]:Zo(e.r)}function Qo(e,t,o,n=lt,s=lt){return{k:e,l:n,lvl:o,r:s,v:t}}function bo(e){return Ut(Ko(e))}function Ko(e){const{l:t}=e;return!oe(t)&&t.lvl===e.lvl?fe(t,{r:fe(e,{l:t.r})}):e}function Ut(e){const{lvl:t,r:o}=e;return!oe(o)&&!oe(o.r)&&o.lvl===t&&o.r.lvl===t?fe(o,{l:fe(e,{r:o.l}),lvl:t+1}):e}function yr(e){return Yo(e,({k:t,v:o})=>({index:t,value:o}))}function en(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function ut(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Xt=X(()=>({recalcInProgress:O(!1)}),[],{singleton:!0});function tn(e,t,o){return e[It(e,t,o)]}function It(e,t,o,n=0){let s=e.length-1;for(;n<=s;){const r=Math.floor((n+s)/2),a=e[r],i=o(a,t);if(i===0)return r;if(i===-1){if(s-n<2)return r-1;s=r-1}else{if(s===n)return r;n=r+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function wr(e,t,o,n){const s=It(e,t,n),r=It(e,o,n,s);return e.slice(s,r+1)}function Be(e,t){return Math.round(e.getBoundingClientRect()[t])}function jt(e){return!oe(e.groupOffsetTree)}function Zt({index:e},t){return t===e?0:t<e?-1:1}function xr(){return{groupIndices:[],groupOffsetTree:Qe(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Qe()}}function br(e,t){let o=oe(e)?0:1/0;for(const n of t){const{endIndex:s,size:r,startIndex:a}=n;if(o=Math.min(o,a),oe(e)){e=$e(e,0,r);continue}const i=Ke(e,a-1,s+1);if(i.some(Er(n)))continue;let l=!1,c=!1;for(const{end:u,start:m,value:f}of i)l?(s>=m||r===f)&&(e=Ht(e,m)):(c=f!==r,l=!0),u>s&&s>=m&&f!==r&&(e=$e(e,s+1,f));c&&(e=$e(e,a,r))}return[e,o]}function vr(e){return typeof e.groupIndex<"u"}function Sr({offset:e},t){return t===e?0:t<e?-1:1}function dt(e,t,o){if(t.length===0)return 0;const{index:n,offset:s,size:r}=tn(t,e,Zt),a=e-n,i=r*a+(a-1)*o+s;return i>0?i+o:i}function on(e,t){if(!jt(t))return e;let o=0;for(;t.groupIndices[o]<=e+o;)o++;return e+o}function nn(e,t,o){if(vr(e))return t.groupIndices[e.groupIndex]+1;{const n=e.index==="LAST"?o:e.index;let s=on(n,t);return s=Math.max(0,s,Math.min(o,s)),s}}function Tr(e,t,o,n=0){return n>0&&(t=Math.max(t,tn(e,n,Zt).offset)),Yo(wr(e,t,o,Sr),Ir)}function Cr(e,[t,o,n,s]){t.length>0&&n("received item sizes",t,Ce.DEBUG);const r=e.sizeTree;let a=r,i=0;if(o.length>0&&oe(r)&&t.length===2){const f=t[0].size,h=t[1].size;a=o.reduce((T,v)=>$e($e(T,v,f),v+1,h),a)}else[a,i]=br(a,t);if(a===r)return e;const{lastIndex:l,lastOffset:c,lastSize:u,offsetTree:m}=Wt(e.offsetTree,i,a,s);return{groupIndices:o,groupOffsetTree:o.reduce((f,h)=>$e(f,h,dt(h,m,s)),Qe()),lastIndex:l,lastOffset:c,lastSize:u,offsetTree:m,sizeTree:a}}function $r(e){return We(e).map(({k:t,v:o},n,s)=>{const r=s[n+1];return{endIndex:r?r.k-1:1/0,size:o,startIndex:t}})}function vo(e,t){let o=0,n=0;for(;o<e;)o+=t[n+1]-t[n]-1,n++;return n-(o===e?0:1)}function Wt(e,t,o,n){let s=e,r=0,a=0,i=0,l=0;if(t!==0){l=It(s,t-1,Zt),i=s[l].offset;const c=Pe(o,t-1);r=c[0],a=c[1],s.length&&s[l].size===Pe(o,t)[1]&&(l-=1),s=s.slice(0,l+1)}else s=[];for(const{start:c,value:u}of Ke(o,t,1/0)){const m=c-r,f=m*a+i+m*n;s.push({index:c,offset:f,size:u}),r=c,i=f,a=u}return{lastIndex:r,lastOffset:i,lastSize:a,offsetTree:s}}function Ir(e){return{index:e.index,value:e}}function Er(e){const{endIndex:t,size:o,startIndex:n}=e;return s=>s.start===n&&(s.end===t||s.end===1/0)&&s.value===o}const kr={offsetHeight:"height",offsetWidth:"width"},ze=X(([{log:e},{recalcInProgress:t}])=>{const o=q(),n=q(),s=Se(n,0),r=q(),a=q(),i=O(0),l=O([]),c=O(void 0),u=O(void 0),m=O(void 0),f=O(void 0),h=O((d,w)=>Be(d,kr[w])),T=O(void 0),v=O(0),x=xr(),y=Se(R(o,W(l,e,v),Ne(Cr,x),se()),x),p=Se(R(l,se(),Ne((d,w)=>({current:w,prev:d.current}),{current:[],prev:[]}),L(({prev:d})=>d)),[]);N(R(l,_(d=>d.length>0),W(y,v),L(([d,w,k])=>{const A=d.reduce((j,M,z)=>$e(j,M,dt(M,w.offsetTree,k)||z),Qe());return{...w,groupIndices:d,groupOffsetTree:A}})),y),N(R(n,W(y),_(([d,{lastIndex:w}])=>d<w),L(([d,{lastIndex:w,lastSize:k}])=>[{endIndex:w,size:k,startIndex:d}])),o),N(c,u);const g=Se(R(c,L(d=>d===void 0)),!0);N(R(u,_(d=>d!==void 0&&oe(le(y).sizeTree)),L(d=>{const w=le(m),k=le(l).length>0;return w?k?[{endIndex:0,size:w,startIndex:0},{endIndex:1,size:d,startIndex:1}]:[]:[{endIndex:0,size:d,startIndex:0}]})),o),N(R(f,_(d=>d!==void 0&&d.length>0&&oe(le(y).sizeTree)),L(d=>{const w=[];let k=d[0],A=0;for(let j=1;j<d.length;j++){const M=d[j];M!==k&&(w.push({endIndex:j-1,size:k,startIndex:A}),k=M,A=j)}return w.push({endIndex:d.length-1,size:k,startIndex:A}),w})),o),N(R(l,W(m,u),_(([,d,w])=>d!==void 0&&w!==void 0),L(([d,w,k])=>{const A=[];for(let j=0;j<d.length;j++){const M=d[j],z=d[j+1];A.push({startIndex:M,endIndex:M,size:w}),z!==void 0&&A.push({startIndex:M+1,endIndex:z-1,size:k})}return A})),o);const $=Ie(R(o,W(y),Ne(({sizes:d},[w,k])=>({changed:k!==d,sizes:k}),{changed:!1,sizes:x}),L(d=>d.changed)));Z(R(i,Ne((d,w)=>({diff:d.prev-w,prev:w}),{diff:0,prev:0}),L(d=>d.diff)),d=>{const{groupIndices:w}=le(y);if(d>0)U(t,!0),U(r,d+vo(d,w));else if(d<0){const k=le(p);k.length>0&&(d-=vo(-d,k)),U(a,d)}}),Z(R(i,W(e)),([d,w])=>{d<0&&w("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:i},Ce.ERROR)});const b=Ie(r);N(R(r,W(y),L(([d,w])=>{const k=w.groupIndices.length>0,A=[],j=w.lastSize;if(k){const M=ct(w.sizeTree,0);let z=0,V=0;for(;z<d;){const Y=w.groupIndices[V],Q=w.groupIndices.length===V+1?1/0:w.groupIndices[V+1]-Y-1;A.push({endIndex:Y,size:M,startIndex:Y}),A.push({endIndex:Y+1+Q-1,size:j,startIndex:Y+1}),V++,z+=Q+1}const H=We(w.sizeTree);return z!==d&&H.shift(),H.reduce((Y,{k:Q,v:we})=>{let xe=Y.ranges;return Y.prevSize!==0&&(xe=[...Y.ranges,{endIndex:Q+d-1,size:Y.prevSize,startIndex:Y.prevIndex}]),{prevIndex:Q+d,prevSize:we,ranges:xe}},{prevIndex:d,prevSize:0,ranges:A}).ranges}return We(w.sizeTree).reduce((M,{k:z,v:V})=>({prevIndex:z+d,prevSize:V,ranges:[...M.ranges,{endIndex:z+d-1,size:M.prevSize,startIndex:M.prevIndex}]}),{prevIndex:0,prevSize:j,ranges:[]}).ranges})),o);const C=Ie(R(a,W(y,v),L(([d,{offsetTree:w},k])=>{const A=-d;return dt(A,w,k)})));return N(R(a,W(y,v),L(([d,w,k])=>{if(w.groupIndices.length>0){if(oe(w.sizeTree))return w;let A=Qe();const j=le(p);let M=0,z=0,V=0;for(;M<-d;){V=j[z];const H=j[z+1]-V-1;z++,M+=H+1}if(A=We(w.sizeTree).reduce((H,{k:Y,v:Q})=>$e(H,Math.max(0,Y+d),Q),A),M!==-d){const H=ct(w.sizeTree,V);A=$e(A,0,H);const Y=Pe(w.sizeTree,-d+1)[1];A=$e(A,1,Y)}return{...w,sizeTree:A,...Wt(w.offsetTree,0,A,k)}}else{const A=We(w.sizeTree).reduce((j,{k:M,v:z})=>$e(j,Math.max(0,M+d),z),Qe());return{...w,sizeTree:A,...Wt(w.offsetTree,0,A,k)}}})),y),{beforeUnshiftWith:b,data:T,defaultItemSize:u,firstItemIndex:i,fixedItemSize:c,fixedGroupSize:m,gap:v,groupIndices:l,heightEstimates:f,itemSize:h,listRefresh:$,shiftWith:a,shiftWithOffset:C,sizeRanges:o,sizes:y,statefulTotalCount:s,totalCount:n,trackItemSizes:g,unshiftWith:r}},ie(He,Xt),{singleton:!0});function Rr(e){return e.reduce((t,o)=>(t.groupIndices.push(t.totalCount),t.totalCount+=o+1,t),{groupIndices:[],totalCount:0})}const rn=X(([{groupIndices:e,sizes:t,totalCount:o},{headerHeight:n,scrollTop:s}])=>{const r=q(),a=q(),i=Ie(R(r,L(Rr)));return N(R(i,L(l=>l.totalCount)),o),N(R(i,L(l=>l.groupIndices)),e),N(R(de(s,t,n),_(([l,c])=>jt(c)),L(([l,c,u])=>Pe(c.groupOffsetTree,Math.max(l-u,0),"v")[0]),se(),L(l=>[l])),a),{groupCounts:r,topItemsIndexes:a}},ie(ze,Te)),De=X(([{log:e}])=>{const t=O(!1),o=Ie(R(t,_(n=>n),se()));return Z(t,n=>{n&&le(e)("props updated",{},Ce.DEBUG)}),{didMount:o,propsReady:t}},ie(He),{singleton:!0}),Ar=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function sn(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Ar)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const gt=X(([{gap:e,listRefresh:t,sizes:o,totalCount:n},{fixedFooterHeight:s,fixedHeaderHeight:r,footerHeight:a,headerHeight:i,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:u,viewportHeight:m},{log:f}])=>{const h=q(),T=q(),v=O(0);let x=null,y=null,p=null;function g(){x&&(x(),x=null),p&&(p(),p=null),y&&(clearTimeout(y),y=null),U(l,!1)}return N(R(h,W(o,m,n,v,i,a,f),W(e,r,s),L(([[$,b,C,d,w,k,A,j],M,z,V])=>{const H=sn($),{align:Y,behavior:Q,offset:we}=H,xe=d-1,be=nn(H,b,xe);let E=dt(be,b.offsetTree,M)+k;Y==="end"?(E+=z+Pe(b.sizeTree,be)[1]-C+V,be===xe&&(E+=A)):Y==="center"?E+=(z+Pe(b.sizeTree,be)[1]-C+V)/2:E-=w,we&&(E+=we);const F=G=>{g(),G?(j("retrying to scroll to",{location:$},Ce.DEBUG),U(h,$)):(U(T,!0),j("list did not change, scroll successful",{},Ce.DEBUG))};if(g(),Q==="smooth"){let G=!1;p=Z(t,K=>{G=G||K}),x=je(u,()=>{F(G)})}else x=je(R(t,Or(150)),F);return y=setTimeout(()=>{g()},1200),U(l,!0),j("scrolling from index to",{behavior:Q,index:be,top:E},Ce.DEBUG),{behavior:Q,top:E}})),c),{scrollTargetReached:T,scrollToIndex:h,topListHeight:v}},ie(ze,Te,He),{singleton:!0});function Or(e){return t=>{const o=setTimeout(()=>{t(!1)},e);return n=>{n&&(t(!0),clearTimeout(o))}}}function Qt(e,t){e==0?t():requestAnimationFrame(()=>{Qt(e-1,t)})}function Kt(e,t){const o=t-1;return typeof e=="number"?e:e.index==="LAST"?o:e.index}const yt=X(([{defaultItemSize:e,listRefresh:t,sizes:o},{scrollTop:n},{scrollTargetReached:s,scrollToIndex:r},{didMount:a}])=>{const i=O(!0),l=O(0),c=O(!0);return N(R(a,W(l),_(([u,m])=>!!m),Ve(!1)),i),N(R(a,W(l),_(([u,m])=>!!m),Ve(!1)),c),Z(R(de(t,a),W(i,o,e,c),_(([[,u],m,{sizeTree:f},h,T])=>u&&(!oe(f)||qt(h))&&!m&&!T),W(l)),([,u])=>{je(s,()=>{U(c,!0)}),Qt(4,()=>{je(n,()=>{U(i,!0)}),U(r,u)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:i}},ie(ze,Te,gt,De),{singleton:!0});function an(e,t){return Math.abs(e-t)<1.01}const pt="up",rt="down",jr="none",Pr={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Lr=0,wt=X(([{footerHeight:e,headerHeight:t,scrollBy:o,scrollContainerState:n,scrollTop:s,viewportHeight:r}])=>{const a=O(!1),i=O(!0),l=q(),c=q(),u=O(4),m=O(Lr),f=Se(R(_t(R(B(s),qe(1),Ve(!0)),R(B(s),qe(1),Ve(!1),wo(100))),se()),!1),h=Se(R(_t(R(o,Ve(!0)),R(o,Ve(!1),wo(200))),se()),!1);N(R(de(B(s),B(m)),L(([p,g])=>p<=g),se()),i),N(R(i,Fe(50)),c);const T=Ie(R(de(n,B(r),B(t),B(e),B(u)),Ne((p,[{scrollHeight:g,scrollTop:$},b,C,d,w])=>{const k=$+b-g>-w,A={scrollHeight:g,scrollTop:$,viewportHeight:b};if(k){let M,z;return $>p.state.scrollTop?(M="SCROLLED_DOWN",z=p.state.scrollTop-$):(M="SIZE_DECREASED",z=p.state.scrollTop-$||p.scrollTopDelta),{atBottom:!0,atBottomBecause:M,scrollTopDelta:z,state:A}}let j;return A.scrollHeight>p.state.scrollHeight?j="SIZE_INCREASED":b<p.state.viewportHeight?j="VIEWPORT_HEIGHT_DECREASING":$<p.state.scrollTop?j="SCROLLING_UPWARDS":j="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:j,state:A}},Pr),se((p,g)=>p&&p.atBottom===g.atBottom))),v=Se(R(n,Ne((p,{scrollHeight:g,scrollTop:$,viewportHeight:b})=>{if(an(p.scrollHeight,g))return{changed:!1,jump:0,scrollHeight:g,scrollTop:$};{const C=g-($+b)<1;return p.scrollTop!==$&&C?{changed:!0,jump:p.scrollTop-$,scrollHeight:g,scrollTop:$}:{changed:!0,jump:0,scrollHeight:g,scrollTop:$}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),_(p=>p.changed),L(p=>p.jump)),0);N(R(T,L(p=>p.atBottom)),a),N(R(a,Fe(50)),l);const x=O(rt);N(R(n,L(({scrollTop:p})=>p),se(),Ne((p,g)=>le(h)?{direction:p.direction,prevScrollTop:g}:{direction:g<p.prevScrollTop?pt:rt,prevScrollTop:g},{direction:rt,prevScrollTop:0}),L(p=>p.direction)),x),N(R(n,Fe(50),Ve(jr)),x);const y=O(0);return N(R(f,_(p=>!p),Ve(0)),y),N(R(s,Fe(100),W(f),_(([p,g])=>!!g),Ne(([p,g],[$])=>[g,$],[0,0]),L(([p,g])=>g-p)),y),{atBottomState:T,atBottomStateChange:l,atBottomThreshold:u,atTopStateChange:c,atTopThreshold:m,isAtBottom:a,isAtTop:i,isScrolling:f,lastJumpDueToItemResize:v,scrollDirection:x,scrollVelocity:y}},ie(Te)),ft="top",mt="bottom",So="none";function To(e,t,o){return typeof e=="number"?o===pt&&t===ft||o===rt&&t===mt?e:0:o===pt?t===ft?e.main:e.reverse:t===mt?e.main:e.reverse}function Co(e,t){var o;return typeof e=="number"?e:(o=e[t])!=null?o:0}const eo=X(([{deviation:e,fixedHeaderHeight:t,headerHeight:o,scrollTop:n,viewportHeight:s}])=>{const r=q(),a=O(0),i=O(0),l=O(0),c=Se(R(de(B(n),B(s),B(o),B(r,ut),B(l),B(a),B(t),B(e),B(i)),L(([u,m,f,[h,T],v,x,y,p,g])=>{const $=u-p,b=x+y,C=Math.max(f-$,0);let d=So;const w=Co(g,ft),k=Co(g,mt);return h-=p,h+=f+y,T+=f+y,T-=p,h>u+b-w&&(d=pt),T<u-C+m+k&&(d=rt),d!==So?[Math.max($-f-To(v,ft,d)-w,0),$-C-y+m+To(v,mt,d)+k]:null}),_(u=>u!=null),se(ut)),[0,0]);return{increaseViewportBy:i,listBoundary:r,overscan:l,topListHeight:a,visibleRange:c}},ie(Te),{singleton:!0});function Mr(e,t,o){if(jt(t)){const n=on(e,t);return[{index:Pe(t.groupOffsetTree,n)[0],offset:0,size:0},{data:o?.[0],index:n,offset:0,size:0}]}return[{data:o?.[0],index:e,offset:0,size:0}]}const Nt={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function $t(e,t,o,n,s,r){const{lastIndex:a,lastOffset:i,lastSize:l}=s;let c=0,u=0;if(e.length>0){c=e[0].offset;const v=e[e.length-1];u=v.offset+v.size}const m=o-a,f=i+m*l+(m-1)*n,h=c,T=f-u;return{bottom:u,firstItemIndex:r,items:$o(e,s,r),offsetBottom:T,offsetTop:c,top:h,topItems:$o(t,s,r),topListHeight:t.reduce((v,x)=>x.size+v,0),totalCount:o}}function ln(e,t,o,n,s,r){let a=0;if(o.groupIndices.length>0)for(const u of o.groupIndices){if(u-a>=e)break;a++}const i=e+a,l=Kt(t,i),c=Array.from({length:i}).map((u,m)=>({data:r[m+l],index:m+l,offset:0,size:0}));return $t(c,[],i,s,o,n)}function $o(e,t,o){if(e.length===0)return[];if(!jt(t))return e.map(c=>({...c,index:c.index+o,originalIndex:c.index}));const n=e[0].index,s=e[e.length-1].index,r=[],a=Ke(t.groupOffsetTree,n,s);let i,l=0;for(const c of e){(!i||i.end<c.index)&&(i=a.shift(),l=t.groupIndices.indexOf(i.start));let u;c.index===i.start?u={index:l,type:"group"}:u={groupIndex:l,index:c.index-(l+1)+o},r.push({...u,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return r}function Io(e,t){var o;return e===void 0?0:typeof e=="number"?e:(o=e[t])!=null?o:0}const Xe=X(([{data:e,firstItemIndex:t,gap:o,sizes:n,totalCount:s},r,{listBoundary:a,topListHeight:i,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:u},{topListHeight:m},f,{didMount:h},{recalcInProgress:T}])=>{const v=O([]),x=O(0),y=q(),p=O(0);N(r.topItemsIndexes,v);const g=Se(R(de(h,T,B(l,ut),B(s),B(n),B(c),u,B(v),B(t),B(o),B(p),e),_(([d,w,,k,,,,,,,,A])=>{const j=A&&A.length!==k;return d&&!w&&!j}),L(([,,[d,w],k,A,j,M,z,V,H,Y,Q])=>{var we,xe,be,E;const F=A,{offsetTree:G,sizeTree:K}=F,Le=le(x);if(k===0)return{...Nt,totalCount:k};if(d===0&&w===0)return Le===0?{...Nt,totalCount:k}:ln(Le,j,A,V,H,Q||[]);if(oe(K))return Le>0?null:$t(Mr(Kt(j,k),F,Q),[],k,H,F,V);const Me=[];if(z.length>0){const pe=z[0],ce=z[z.length-1];let me=0;for(const ue of Ke(K,pe,ce)){const te=ue.value,re=Math.max(ue.start,pe),ke=Math.min(ue.end,ce);for(let ge=re;ge<=ke;ge++)Me.push({data:Q?.[ge],index:ge,offset:me,size:te}),me+=te}}if(!M)return $t([],Me,k,H,F,V);const ee=z.length>0?z[z.length-1]+1:0,P=Tr(G,d,w,ee);if(P.length===0)return null;const J=k-1,ne=Ot([],pe=>{for(const ce of P){const me=ce.value;let ue=me.offset,te=ce.start;const re=me.size;if(me.offset<d){te+=Math.floor((d-me.offset+H)/(re+H));const ge=te-ce.start;ue+=ge*re+ge*H}te<ee&&(ue+=(ee-te)*re,te=ee);const ke=Math.min(ce.end,J);for(let ge=te;ge<=ke&&!(ue>=w);ge++)pe.push({data:Q?.[ge],index:ge,offset:ue,size:re}),ue+=re+H}}),he=Io(Y,ft),Ee=Io(Y,mt);if(ne.length>0&&(he>0||Ee>0)){const pe=ne[0],ce=ne[ne.length-1];if(he>0&&pe.index>ee){const me=Math.min(he,pe.index-ee),ue=[];let te=pe.offset;for(let re=pe.index-1;re>=pe.index-me;re--){const ke=(xe=(we=Ke(K,re,re)[0])==null?void 0:we.value)!=null?xe:pe.size;te-=ke+H,ue.unshift({data:Q?.[re],index:re,offset:te,size:ke})}ne.unshift(...ue)}if(Ee>0&&ce.index<J){const me=Math.min(Ee,J-ce.index);let ue=ce.offset+ce.size+H;for(let te=ce.index+1;te<=ce.index+me;te++){const re=(E=(be=Ke(K,te,te)[0])==null?void 0:be.value)!=null?E:ce.size;ne.push({data:Q?.[te],index:te,offset:ue,size:re}),ue+=re+H}}}return $t(ne,Me,k,H,F,V)}),_(d=>d!==null),se()),Nt);N(R(e,_(qt),L(d=>d?.length)),s),N(R(g,L(d=>d.topListHeight)),m),N(m,i),N(R(g,L(d=>[d.top,d.bottom])),a),N(R(g,L(d=>d.items)),y);const $=Ie(R(g,_(({items:d})=>d.length>0),W(s,e),_(([{items:d},w])=>d[d.length-1].originalIndex===w-1),L(([,d,w])=>[d-1,w]),se(ut),L(([d])=>d))),b=Ie(R(g,Fe(200),_(({items:d,topItems:w})=>d.length>0&&d[0].originalIndex===w.length),L(({items:d})=>d[0].index),se())),C=Ie(R(g,_(({items:d})=>d.length>0),L(({items:d})=>{let w=0,k=d.length-1;for(;d[w].type==="group"&&w<k;)w++;for(;d[k].type==="group"&&k>w;)k--;return{endIndex:d[k].index,startIndex:d[w].index}}),se(en)));return{endReached:$,initialItemCount:x,itemsRendered:y,listState:g,minOverscanItemCount:p,rangeChanged:C,startReached:b,topItemsIndexes:v,...f}},ie(ze,rn,eo,yt,gt,wt,De,Xt),{singleton:!0}),cn=X(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:o,headerHeight:n},{listState:s}])=>{const r=q(),a=Se(R(de(o,e,n,t,s),L(([i,l,c,u,m])=>i+l+c+u+m.offsetBottom+m.bottom)),0);return N(B(a),r),{totalListHeight:a,totalListHeightChanged:r}},ie(Te,Xe),{singleton:!0}),Vr=X(([{viewportHeight:e},{totalListHeight:t}])=>{const o=O(!1),n=Se(R(de(o,e,t),_(([s])=>s),L(([,s,r])=>Math.max(0,s-r)),Fe(0),se()),0);return{alignToBottom:o,paddingTopAddition:n}},ie(Te,cn),{singleton:!0}),un=X(()=>({context:O(null)})),Nr=({itemBottom:e,itemTop:t,locationParams:{align:o,behavior:n,...s},viewportBottom:r,viewportTop:a})=>t<a?{...s,align:o??"start",behavior:n}:e>r?{...s,align:o??"end",behavior:n}:null,dn=X(([{gap:e,sizes:t,totalCount:o},{fixedFooterHeight:n,fixedHeaderHeight:s,headerHeight:r,scrollingInProgress:a,scrollTop:i,viewportHeight:l},{scrollToIndex:c}])=>{const u=q();return N(R(u,W(t,l,o,r,s,n,i),W(e),L(([[m,f,h,T,v,x,y,p],g])=>{const{align:$,behavior:b,calculateViewLocation:C=Nr,done:d,...w}=m,k=nn(m,f,T-1),A=dt(k,f.offsetTree,g)+v+x,j=A+Pe(f.sizeTree,k)[1],M=p+x,z=p+h-y,V=C({itemBottom:j,itemTop:A,locationParams:{align:$,behavior:b,...w},viewportBottom:z,viewportTop:M});return V?d&&je(R(a,_(H=>!H),qe(le(a)?1:2)),d):d&&d(),V}),_(m=>m!==null)),c),{scrollIntoView:u}},ie(ze,Te,gt,Xe,He),{singleton:!0});function Eo(e){return e?e==="smooth"?"smooth":"auto":!1}const zr=(e,t)=>typeof e=="function"?Eo(e(t)):t&&Eo(e),Fr=X(([{listRefresh:e,totalCount:t,fixedItemSize:o,data:n},{atBottomState:s,isAtBottom:r},{scrollToIndex:a},{scrolledToInitialItem:i},{didMount:l,propsReady:c},{log:u},{scrollingInProgress:m},{context:f},{scrollIntoView:h}])=>{const T=O(!1),v=q();let x=null;function y(b){U(a,{align:"end",behavior:b,index:"LAST"})}Z(R(de(R(B(t),qe(1)),l),W(B(T),r,i,m),L(([[b,C],d,w,k,A])=>{let j=C&&k,M="auto";return j&&(M=zr(d,w||A),j=j&&!!M),{followOutputBehavior:M,shouldFollow:j,totalCount:b}}),_(({shouldFollow:b})=>b)),({followOutputBehavior:b,totalCount:C})=>{x&&(x(),x=null),le(o)?requestAnimationFrame(()=>{le(u)("following output to ",{totalCount:C},Ce.DEBUG),y(b)}):x=je(e,()=>{le(u)("following output to ",{totalCount:C},Ce.DEBUG),y(b),x=null})});function p(b){const C=je(s,d=>{b&&!d.atBottom&&d.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(le(u)("scrolling to bottom due to increased size",{},Ce.DEBUG),y("auto"))});setTimeout(C,100)}Z(R(de(B(T),t,c),_(([b,,C])=>b&&C),Ne(({value:b},[,C])=>({refreshed:b===C,value:C}),{refreshed:!1,value:0}),_(({refreshed:b})=>b),W(T,t)),([,b])=>{le(i)&&p(b!==!1)}),Z(v,()=>{p(le(T)!==!1)}),Z(de(B(T),s),([b,C])=>{b&&!C.atBottom&&C.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const g=O(null),$=q();return N(_t(R(B(n),L(b=>{var C;return(C=b?.length)!=null?C:0})),R(B(t))),$),Z(R(de(R($,qe(1)),l),W(B(g),i,m,f),L(([[b,C],d,w,k,A])=>C&&w&&d?.({context:A,totalCount:b,scrollingInProgress:k})),_(b=>!!b),Fe(0)),b=>{x&&(x(),x=null),le(o)?requestAnimationFrame(()=>{le(u)("scrolling into view",{}),U(h,b)}):x=je(e,()=>{le(u)("scrolling into view",{}),U(h,b),x=null})}),{autoscrollToBottom:v,followOutput:T,scrollIntoViewOnChange:g}},ie(ze,wt,gt,yt,De,He,Te,un,dn)),Br=X(([{data:e,firstItemIndex:t,gap:o,sizes:n},{initialTopMostItemIndex:s},{initialItemCount:r,listState:a},{didMount:i}])=>(N(R(i,W(r),_(([,l])=>l!==0),W(s,n,t,o,e),L(([[,l],c,u,m,f,h=[]])=>ln(l,c,u,m,f,h))),a),{}),ie(ze,yt,Xe,De),{singleton:!0}),_r=X(([{didMount:e},{scrollTo:t},{listState:o}])=>{const n=O(0);return Z(R(e,W(n),_(([,s])=>s!==0),L(([,s])=>({top:s}))),s=>{je(R(o,qe(1),_(r=>r.items.length>1)),()=>{requestAnimationFrame(()=>{U(t,s)})})}),{initialScrollTop:n}},ie(De,Te,Xe),{singleton:!0}),pn=X(([{scrollVelocity:e}])=>{const t=O(!1),o=q(),n=O(!1);return N(R(e,W(n,t,o),_(([s,r])=>!!r),L(([s,r,a,i])=>{const{enter:l,exit:c}=r;if(a){if(c(s,i))return!1}else if(l(s,i))return!0;return a}),se()),t),Z(R(de(t,e,o),W(n)),([[s,r,a],i])=>{s&&i&&i.change&&i.change(r,a)}),{isSeeking:t,scrollSeekConfiguration:n,scrollSeekRangeChanged:o,scrollVelocity:e}},ie(wt),{singleton:!0}),to=X(([{scrollContainerState:e,scrollTo:t}])=>{const o=q(),n=q(),s=q(),r=O(!1),a=O(void 0);return N(R(de(o,n),L(([{scrollHeight:i,scrollTop:l,viewportHeight:c},{offsetTop:u}])=>({scrollHeight:i,scrollTop:Math.max(0,l-u),viewportHeight:c}))),e),N(R(t,W(n),L(([i,{offsetTop:l}])=>({...i,top:i.top+l}))),s),{customScrollParent:a,useWindowScroll:r,windowScrollContainerState:o,windowScrollTo:s,windowViewportRect:n}},ie(Te)),Hr=X(([{sizeRanges:e,sizes:t},{headerHeight:o,scrollTop:n},{initialTopMostItemIndex:s},{didMount:r},{useWindowScroll:a,windowScrollContainerState:i,windowViewportRect:l}])=>{const c=q(),u=O(void 0),m=O(null),f=O(null);return N(i,m),N(l,f),Z(R(c,W(t,n,a,m,f,o)),([h,T,v,x,y,p,g])=>{const $=$r(T.sizeTree);x&&y!==null&&p!==null&&(v=y.scrollTop-p.offsetTop),v-=g,h({ranges:$,scrollTop:v})}),N(R(u,_(qt),L(Dr)),s),N(R(r,W(u),_(([,h])=>h!==void 0),se(),L(([,h])=>h.ranges)),e),{getState:c,restoreStateFrom:u}},ie(ze,Te,yt,De,to));function Dr(e){return{align:"start",index:0,offset:e.scrollTop}}const Ur=X(([{topItemsIndexes:e}])=>{const t=O(0);return N(R(t,_(o=>o>=0),L(o=>Array.from({length:o}).map((n,s)=>s))),e),{topItemCount:t}},ie(Xe));function fn(e){let t=!1,o;return()=>(t||(t=!0,o=e()),o)}const Wr=fn(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Jr=X(([{deviation:e,scrollBy:t,scrollingInProgress:o,scrollTop:n},{isAtBottom:s,isScrolling:r,lastJumpDueToItemResize:a,scrollDirection:i},{listState:l},{beforeUnshiftWith:c,gap:u,shiftWithOffset:m,sizes:f},{log:h},{recalcInProgress:T}])=>{const v=Ie(R(l,W(a),Ne(([,y,p,g],[{bottom:$,items:b,offsetBottom:C,totalCount:d},w])=>{const k=$+C;let A=0;return p===d&&y.length>0&&b.length>0&&(b[0].originalIndex===0&&y[0].originalIndex===0||(A=k-g,A!==0&&(A+=w))),[A,b,d,k]},[0,[],0,0]),_(([y])=>y!==0),W(n,i,o,s,h,T),_(([,y,p,g,,,$])=>!$&&!g&&y!==0&&p===pt),L(([[y],,,,,p])=>(p("Upward scrolling compensation",{amount:y},Ce.DEBUG),y))));function x(y){y>0?(U(t,{behavior:"auto",top:-y}),U(e,0)):(U(e,0),U(t,{behavior:"auto",top:-y}))}return Z(R(v,W(e,r)),([y,p,g])=>{g&&Wr()?U(e,p-y):x(-y)}),Z(R(de(Se(r,!1),e,T),_(([y,p,g])=>!y&&!g&&p!==0),L(([y,p])=>p),Fe(1)),x),N(R(m,L(y=>({top:-y}))),t),Z(R(c,W(f,u),L(([y,{groupIndices:p,lastSize:g,sizeTree:$},b])=>{function C(d){return d*(g+b)}if(p.length===0)return C(y);{let d=0;const w=ct($,0);let k=0,A=0;for(;k<y;){k++,d+=w;let j=p.length===A+1?1/0:p[A+1]-p[A]-1;k+j>y&&(d-=w,j=y-k+1),k+=j,d+=C(j),A++}return d}})),y=>{U(e,y),requestAnimationFrame(()=>{U(t,{top:y}),requestAnimationFrame(()=>{U(e,0),U(T,!1)})})}),{deviation:e}},ie(Te,wt,Xe,ze,He,Xt)),qr=X(([e,t,o,n,s,r,a,i,l,c,u])=>({...e,...t,...o,...n,...s,...r,...a,...i,...l,...c,...u}),ie(eo,Br,De,pn,cn,_r,Vr,to,dn,He,un)),mn=X(([{data:e,defaultItemSize:t,firstItemIndex:o,fixedItemSize:n,fixedGroupSize:s,gap:r,groupIndices:a,heightEstimates:i,itemSize:l,sizeRanges:c,sizes:u,statefulTotalCount:m,totalCount:f,trackItemSizes:h},{initialItemFinalLocationReached:T,initialTopMostItemIndex:v,scrolledToInitialItem:x},y,p,g,$,{scrollToIndex:b},C,{topItemCount:d},{groupCounts:w},k])=>{const{listState:A,minOverscanItemCount:j,topItemsIndexes:M,rangeChanged:z,...V}=$;return N(z,k.scrollSeekRangeChanged),N(R(k.windowViewportRect,L(H=>H.visibleHeight)),y.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:o,fixedItemHeight:n,fixedGroupHeight:s,gap:r,groupCounts:w,heightEstimates:i,initialItemFinalLocationReached:T,initialTopMostItemIndex:v,scrolledToInitialItem:x,sizeRanges:c,topItemCount:d,topItemsIndexes:M,totalCount:f,...g,groupIndices:a,itemSize:l,listState:A,minOverscanItemCount:j,scrollToIndex:b,statefulTotalCount:m,trackItemSizes:h,rangeChanged:z,...V,...k,...y,sizes:u,...p}},ie(ze,yt,Te,Hr,Fr,Xe,gt,Jr,Ur,rn,qr));function Gr(e,t){const o={},n={};let s=0;const r=e.length;for(;s<r;)n[e[s]]=1,s+=1;for(const a in t)Object.hasOwn(n,a)||(o[a]=t[a]);return o}const vt=typeof document<"u"?I.useLayoutEffect:I.useEffect;function hn(e,t,o){const n=Object.keys(t.required||{}),s=Object.keys(t.optional||{}),r=Object.keys(t.methods||{}),a=Object.keys(t.events||{}),i=I.createContext({});function l(x,y){x.propsReady&&U(x.propsReady,!1);for(const p of n){const g=x[t.required[p]];U(g,y[p])}for(const p of s)if(p in y){const g=x[t.optional[p]];U(g,y[p])}x.propsReady&&U(x.propsReady,!0)}function c(x){return r.reduce((y,p)=>(y[p]=g=>{const $=x[t.methods[p]];U($,g)},y),{})}function u(x){return a.reduce((y,p)=>(y[p]=ur(x[t.events[p]]),y),{})}const m=I.forwardRef((x,y)=>{const{children:p,...g}=x,[$]=I.useState(()=>Ot(pr(e),d=>{l(d,g)})),[b]=I.useState(yo(u,$));vt(()=>{for(const d of a)d in g&&Z(b[d],g[d]);return()=>{Object.values(b).map(Gt)}},[g,b,$]),vt(()=>{l($,g)}),I.useImperativeHandle(y,go(c($)));const C=o;return S.jsx(i.Provider,{value:$,children:o?S.jsx(C,{...Gr([...n,...s,...a],g),children:p}):p})}),f=x=>{const y=I.useContext(i);return I.useCallback(p=>{U(y[x],p)},[y,x])},h=x=>{const y=I.useContext(i)[x],p=I.useCallback(g=>Z(y,g),[y]);return I.useSyncExternalStore(p,()=>le(y),()=>le(y))},T=x=>{const y=I.useContext(i)[x],[p,g]=I.useState(yo(le,y));return vt(()=>Z(y,$=>{$!==p&&g(go($))}),[y,p]),p},v=I.version.startsWith("18")?h:T;return{Component:m,useEmitter:(x,y)=>{const p=I.useContext(i)[x];vt(()=>Z(p,y),[y,p])},useEmitterValue:v,usePublisher:f}}const gn=I.createContext(void 0),yn=I.createContext(void 0),wn=typeof document<"u"?I.useLayoutEffect:I.useEffect;function zt(e){return"self"in e}function Yr(e){return"body"in e}function xn(e,t,o,n=tt,s,r){const a=I.useRef(null),i=I.useRef(null),l=I.useRef(null),c=I.useCallback(f=>{let h,T,v;const x=f.target;if(Yr(x)||zt(x)){const p=zt(x)?x:x.defaultView;v=r?p.scrollX:p.scrollY,h=r?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight,T=r?p.innerWidth:p.innerHeight}else v=r?x.scrollLeft:x.scrollTop,h=r?x.scrollWidth:x.scrollHeight,T=r?x.offsetWidth:x.offsetHeight;const y=()=>{e({scrollHeight:h,scrollTop:Math.max(v,0),viewportHeight:T})};f.suppressFlushSync?y():Fo.flushSync(y),i.current!==null&&(v===i.current||v<=0||v===h-T)&&(i.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,r]);I.useEffect(()=>{const f=s||a.current;return n(s||a.current),c({suppressFlushSync:!0,target:f}),f.addEventListener("scroll",c,{passive:!0}),()=>{n(null),f.removeEventListener("scroll",c)}},[a,c,o,n,s]);function u(f){const h=a.current;if(!h||(r?"offsetWidth"in h&&h.offsetWidth===0:"offsetHeight"in h&&h.offsetHeight===0))return;const T=f.behavior==="smooth";let v,x,y;zt(h)?(x=Math.max(Be(h.document.documentElement,r?"width":"height"),r?h.document.documentElement.scrollWidth:h.document.documentElement.scrollHeight),v=r?h.innerWidth:h.innerHeight,y=r?window.scrollX:window.scrollY):(x=h[r?"scrollWidth":"scrollHeight"],v=Be(h,r?"width":"height"),y=h[r?"scrollLeft":"scrollTop"]);const p=x-v;if(f.top=Math.ceil(Math.max(Math.min(p,f.top),0)),an(v,x)||f.top===y){e({scrollHeight:x,scrollTop:y,viewportHeight:v}),T&&t(!0);return}T?(i.current=f.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,i.current=null,t(!0)},1e3)):i.current=null,r&&(f={behavior:f.behavior,left:f.top}),h.scrollTo(f)}function m(f){r&&(f={behavior:f.behavior,left:f.top}),a.current.scrollBy(f)}return{scrollByCallback:m,scrollerRef:a,scrollToCallback:u}}const Ft="-webkit-sticky",ko="sticky",oo=fn(()=>{if(typeof document>"u")return ko;const e=document.createElement("div");return e.style.position=Ft,e.style.position===Ft?Ft:ko});function no(e){return e}const Xr=X(()=>{const e=O(i=>`Item ${i}`),t=O(i=>`Group ${i}`),o=O({}),n=O(no),s=O("div"),r=O(tt),a=(i,l=null)=>Se(R(o,L(c=>c[i]),se()),l);return{components:o,computeItemKey:n,EmptyPlaceholder:a("EmptyPlaceholder"),FooterComponent:a("Footer"),GroupComponent:a("Group","div"),groupContent:t,HeaderComponent:a("Header"),HeaderFooterTag:s,ItemComponent:a("Item","div"),itemContent:e,ListComponent:a("List","div"),ScrollerComponent:a("Scroller","div"),scrollerRef:r,ScrollSeekPlaceholder:a("ScrollSeekPlaceholder"),TopItemListComponent:a("TopItemList")}}),Zr=X(([e,t])=>({...e,...t}),ie(mn,Xr)),Qr=({height:e})=>S.jsx("div",{style:{height:e}}),Kr={overflowAnchor:"none",position:oo(),zIndex:1},bn={overflowAnchor:"none"},es={...bn,display:"inline-block",height:"100%"},Ro=I.memo(function({showTopList:e=!1}){const t=D("listState"),o=Re("sizeRanges"),n=D("useWindowScroll"),s=D("customScrollParent"),r=Re("windowScrollContainerState"),a=Re("scrollContainerState"),i=s||n?r:a,l=D("itemContent"),c=D("context"),u=D("groupContent"),m=D("trackItemSizes"),f=D("itemSize"),h=D("log"),T=Re("gap"),v=D("horizontalDirection"),{callbackRef:x}=hr(o,f,m,e?tt:i,h,T,s,v,D("skipAnimationFrameInResizeObserver")),[y,p]=I.useState(0);ro("deviation",V=>{y!==V&&p(V)});const g=D("EmptyPlaceholder"),$=D("ScrollSeekPlaceholder")||Qr,b=D("ListComponent"),C=D("ItemComponent"),d=D("GroupComponent"),w=D("computeItemKey"),k=D("isSeeking"),A=D("groupIndices").length>0,j=D("alignToBottom"),M=D("initialItemFinalLocationReached"),z=e?{}:{boxSizing:"border-box",...v?{display:"inline-block",height:"100%",marginLeft:y!==0?y:j?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:j?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...M?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&g?S.jsx(g,{...ve(g,c)}):S.jsx(b,{...ve(b,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:z,children:(e?t.topItems:t.items).map(V=>{const H=V.originalIndex,Y=w(H+t.firstItemIndex,V.data,c);return k?I.createElement($,{...ve($,c),height:V.size,index:V.index,key:Y,type:V.type||"item",...V.type==="group"?{}:{groupIndex:V.groupIndex}}):V.type==="group"?I.createElement(d,{...ve(d,c),"data-index":H,"data-item-index":V.index,"data-known-size":V.size,key:Y,style:Kr},u(V.index,c)):I.createElement(C,{...ve(C,c),...rs(C,V.data),"data-index":H,"data-item-group-index":V.groupIndex,"data-item-index":V.index,"data-known-size":V.size,key:Y,style:v?es:bn},A?l(V.index,V.groupIndex,V.data,c):l(V.index,V.data,c))})})}),ts={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},os={outline:"none",overflowX:"auto",position:"relative"},Pt=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),ns={position:oo(),top:0,width:"100%",zIndex:1};function ve(e,t){if(typeof e!="string")return{context:t}}function rs(e,t){return{item:typeof e=="string"?void 0:t}}const ss=I.memo(function(){const e=D("HeaderComponent"),t=Re("headerHeight"),o=D("HeaderFooterTag"),n=Ye(I.useMemo(()=>r=>{t(Be(r,"height"))},[t]),!0,D("skipAnimationFrameInResizeObserver")),s=D("context");return e?S.jsx(o,{ref:n,children:S.jsx(e,{...ve(e,s)})}):null}),is=I.memo(function(){const e=D("FooterComponent"),t=Re("footerHeight"),o=D("HeaderFooterTag"),n=Ye(I.useMemo(()=>r=>{t(Be(r,"height"))},[t]),!0,D("skipAnimationFrameInResizeObserver")),s=D("context");return e?S.jsx(o,{ref:n,children:S.jsx(e,{...ve(e,s)})}):null});function vn({useEmitter:e,useEmitterValue:t,usePublisher:o}){return I.memo(function({children:n,style:s,context:r,...a}){const i=o("scrollContainerState"),l=t("ScrollerComponent"),c=o("smoothScrollTargetReached"),u=t("scrollerRef"),m=t("horizontalDirection")||!1,{scrollByCallback:f,scrollerRef:h,scrollToCallback:T}=xn(i,c,l,u,void 0,m);return e("scrollTo",T),e("scrollBy",f),S.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:h,style:{...m?os:ts,...s},tabIndex:0,...a,...ve(l,r),children:n})})}function Sn({useEmitter:e,useEmitterValue:t,usePublisher:o}){return I.memo(function({children:n,style:s,context:r,...a}){const i=o("windowScrollContainerState"),l=t("ScrollerComponent"),c=o("smoothScrollTargetReached"),u=t("totalListHeight"),m=t("deviation"),f=t("customScrollParent"),h=I.useRef(null),T=t("scrollerRef"),{scrollByCallback:v,scrollerRef:x,scrollToCallback:y}=xn(i,c,l,T,f);return wn(()=>{var p;return x.current=f||((p=h.current)==null?void 0:p.ownerDocument.defaultView),()=>{x.current=null}},[x,f]),e("windowScrollTo",y),e("scrollBy",v),S.jsx(l,{ref:h,"data-virtuoso-scroller":!0,style:{position:"relative",...s,...u!==0?{height:u+m}:{}},...a,...ve(l,r),children:n})})}const as=({children:e})=>{const t=I.useContext(gn),o=Re("viewportHeight"),n=Re("fixedItemHeight"),s=D("alignToBottom"),r=D("horizontalDirection"),a=I.useMemo(()=>Jo(o,l=>Be(l,r?"width":"height")),[o,r]),i=Ye(a,!0,D("skipAnimationFrameInResizeObserver"));return I.useEffect(()=>{t&&(o(t.viewportHeight),n(t.itemHeight))},[t,o,n]),S.jsx("div",{"data-viewport-type":"element",ref:i,style:Pt(s),children:e})},ls=({children:e})=>{const t=I.useContext(gn),o=Re("windowViewportRect"),n=Re("fixedItemHeight"),s=D("customScrollParent"),r=Go(o,s,D("skipAnimationFrameInResizeObserver")),a=D("alignToBottom");return I.useEffect(()=>{t&&(n(t.itemHeight),o({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,o,n]),S.jsx("div",{"data-viewport-type":"window",ref:r,style:Pt(a),children:e})},cs=({children:e})=>{const t=D("TopItemListComponent")||"div",o=D("headerHeight"),n={...ns,marginTop:`${o}px`},s=D("context");return S.jsx(t,{style:n,...ve(t,s),children:e})},us=I.memo(function(e){const t=D("useWindowScroll"),o=D("topItemsIndexes").length>0,n=D("customScrollParent"),s=D("context");return S.jsxs(n||t?fs:ps,{...e,context:s,children:[o&&S.jsx(cs,{children:S.jsx(Ro,{showTopList:!0})}),S.jsxs(n||t?ls:as,{children:[S.jsx(ss,{}),S.jsx(Ro,{}),S.jsx(is,{})]})]})}),{Component:ds,useEmitter:ro,useEmitterValue:D,usePublisher:Re}=hn(Zr,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",minOverscanItemCount:"minOverscanItemCount",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedGroupHeight:"fixedGroupHeight",fixedItemHeight:"fixedItemHeight",heightEstimates:"heightEstimates",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},us),ps=vn({useEmitter:ro,useEmitterValue:D,usePublisher:Re}),fs=Sn({useEmitter:ro,useEmitterValue:D,usePublisher:Re}),ms=ds,hs=X(()=>{const e=O(c=>S.jsxs("td",{children:["Item $",c]})),t=O(null),o=O(c=>S.jsxs("td",{colSpan:1e3,children:["Group ",c]})),n=O(null),s=O(null),r=O({}),a=O(no),i=O(tt),l=(c,u=null)=>Se(R(r,L(m=>m[c]),se()),u);return{components:r,computeItemKey:a,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:s,fixedHeaderContent:n,itemContent:e,groupContent:o,ScrollerComponent:l("Scroller","div"),scrollerRef:i,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}});ie(mn,hs);oo();const Ao={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},gs={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Oo,floor:Et,max:st,min:Bt,round:jo}=Math;function Po(e,t,o){return Array.from({length:t-e+1}).map((n,s)=>({data:o===null?null:o[s+e],index:s+e}))}function ys(e){return{...gs,items:e}}function St(e,t){return e&&e.width===t.width&&e.height===t.height}function ws(e,t){return e&&e.column===t.column&&e.row===t.row}const xs=X(([{increaseViewportBy:e,listBoundary:t,overscan:o,visibleRange:n},{footerHeight:s,headerHeight:r,scrollBy:a,scrollContainerState:i,scrollTo:l,scrollTop:c,smoothScrollTargetReached:u,viewportHeight:m},f,h,{didMount:T,propsReady:v},{customScrollParent:x,useWindowScroll:y,windowScrollContainerState:p,windowScrollTo:g,windowViewportRect:$},b])=>{const C=O(0),d=O(0),w=O(Ao),k=O({height:0,width:0}),A=O({height:0,width:0}),j=q(),M=q(),z=O(0),V=O(null),H=O({column:0,row:0}),Y=q(),Q=q(),we=O(!1),xe=O(0),be=O(!0),E=O(!1),F=O(!1);Z(R(T,W(xe),_(([P,J])=>!!J)),()=>{U(be,!1)}),Z(R(de(T,be,A,k,xe,E),_(([P,J,ne,he,,Ee])=>P&&!J&&ne.height!==0&&he.height!==0&&!Ee)),([,,,,P])=>{U(E,!0),Qt(1,()=>{U(j,P)}),je(R(c),()=>{U(t,[0,0]),U(be,!0)})}),N(R(Q,_(P=>P!=null&&P.scrollTop>0),Ve(0)),d),Z(R(T,W(Q),_(([,P])=>P!=null)),([,P])=>{P&&(U(k,P.viewport),U(A,P.item),U(H,P.gap),P.scrollTop>0&&(U(we,!0),je(R(c,qe(1)),J=>{U(we,!1)}),U(l,{top:P.scrollTop})))}),N(R(k,L(({height:P})=>P)),m),N(R(de(B(k,St),B(A,St),B(H,(P,J)=>P&&P.column===J.column&&P.row===J.row),B(c)),L(([P,J,ne,he])=>({gap:ne,item:J,scrollTop:he,viewport:P}))),Y),N(R(de(B(C),n,B(H,ws),B(A,St),B(k,St),B(V),B(d),B(we),B(be),B(xe)),_(([,,,,,,,P])=>!P),L(([P,[J,ne],he,Ee,pe,ce,me,,ue,te])=>{const{column:re,row:ke}=he,{height:ge,width:Lt}=Ee,{width:io}=pe;if(me===0&&(P===0||io===0))return Ao;if(Lt===0){const po=Kt(te,P),Ln=po+Math.max(me-1,0);return ys(Po(po,Ln,ce))}const xt=Tn(io,Lt,re);let Ze,Ue;ue?J===0&&ne===0&&me>0?(Ze=0,Ue=me-1):(Ze=xt*Et((J+ke)/(ge+ke)),Ue=xt*Oo((ne+ke)/(ge+ke))-1,Ue=Bt(P-1,st(Ue,xt-1)),Ze=Bt(Ue,st(0,Ze))):(Ze=0,Ue=-1);const ao=Po(Ze,Ue,ce),{bottom:lo,top:co}=Lo(pe,he,Ee,ao),uo=Oo(P/xt),Pn=uo*ge+(uo-1)*ke-lo;return{bottom:lo,itemHeight:ge,items:ao,itemWidth:Lt,offsetBottom:Pn,offsetTop:co,top:co}})),w),N(R(V,_(P=>P!==null),L(P=>P.length)),C),N(R(de(k,A,w,H),_(([P,J,{items:ne}])=>ne.length>0&&J.height!==0&&P.height!==0),L(([P,J,{items:ne},he])=>{const{bottom:Ee,top:pe}=Lo(P,he,J,ne);return[pe,Ee]}),se(ut)),t);const G=O(!1);N(R(c,W(G),L(([P,J])=>J||P!==0)),G);const K=Ie(R(de(w,C),_(([{items:P}])=>P.length>0),W(G),_(([[P,J],ne])=>{const he=P.items[P.items.length-1].index===J-1;return(ne||P.bottom>0&&P.itemHeight>0&&P.offsetBottom===0&&P.items.length===J)&&he}),L(([[,P]])=>P-1),se())),Le=Ie(R(B(w),_(({items:P})=>P.length>0&&P[0].index===0),Ve(0),se())),Me=Ie(R(B(w),W(we),_(([{items:P},J])=>P.length>0&&!J),L(([{items:P}])=>({endIndex:P[P.length-1].index,startIndex:P[0].index})),se(en),Fe(0)));N(Me,h.scrollSeekRangeChanged),N(R(j,W(k,A,C,H),L(([P,J,ne,he,Ee])=>{const pe=sn(P),{align:ce,behavior:me,offset:ue}=pe;let te=pe.index;te==="LAST"&&(te=he-1),te=st(0,te,Bt(he-1,te));let re=Jt(J,Ee,ne,te);return ce==="end"?re=jo(re-J.height+ne.height):ce==="center"&&(re=jo(re-J.height/2+ne.height/2)),ue&&(re+=ue),{behavior:me,top:re}})),l);const ee=Se(R(w,L(P=>P.offsetBottom+P.bottom)),0);return N(R($,L(P=>({height:P.visibleHeight,width:P.visibleWidth}))),k),{customScrollParent:x,data:V,deviation:z,footerHeight:s,gap:H,headerHeight:r,increaseViewportBy:e,initialItemCount:d,itemDimensions:A,overscan:o,restoreStateFrom:Q,scrollBy:a,scrollContainerState:i,scrollHeight:M,scrollTo:l,scrollToIndex:j,scrollTop:c,smoothScrollTargetReached:u,totalCount:C,useWindowScroll:y,viewportDimensions:k,windowScrollContainerState:p,windowScrollTo:g,windowViewportRect:$,...h,gridState:w,horizontalDirection:F,initialTopMostItemIndex:xe,totalListHeight:ee,...f,endReached:K,propsReady:v,rangeChanged:Me,startReached:Le,stateChanged:Y,stateRestoreInProgress:we,...b}},ie(eo,Te,wt,pn,De,to,He));function Tn(e,t,o){return st(1,Et((e+o)/(Et(t)+o)))}function Lo(e,t,o,n){const{height:s}=o;if(s===void 0||n.length===0)return{bottom:0,top:0};const r=Jt(e,t,o,n[0].index);return{bottom:Jt(e,t,o,n[n.length-1].index)+s,top:r}}function Jt(e,t,o,n){const s=Tn(e.width,o.width,t.column),r=Et(n/s),a=r*o.height+st(0,r-1)*t.row;return a>0?a+t.row:a}const bs=X(()=>{const e=O(m=>`Item ${m}`),t=O({}),o=O(null),n=O("virtuoso-grid-item"),s=O("virtuoso-grid-list"),r=O(no),a=O("div"),i=O(tt),l=(m,f=null)=>Se(R(t,L(h=>h[m]),se()),f),c=O(!1),u=O(!1);return N(B(u),c),{components:t,computeItemKey:r,context:o,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:a,itemClassName:n,ItemComponent:l("Item","div"),itemContent:e,listClassName:s,ListComponent:l("List","div"),readyStateChanged:c,reportReadyState:u,ScrollerComponent:l("Scroller","div"),scrollerRef:i,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),vs=X(([e,t])=>({...e,...t}),ie(xs,bs)),Ss=I.memo(function(){const e=ae("gridState"),t=ae("listClassName"),o=ae("itemClassName"),n=ae("itemContent"),s=ae("computeItemKey"),r=ae("isSeeking"),a=Ae("scrollHeight"),i=ae("ItemComponent"),l=ae("ListComponent"),c=ae("ScrollSeekPlaceholder"),u=ae("context"),m=Ae("itemDimensions"),f=Ae("gap"),h=ae("log"),T=ae("stateRestoreInProgress"),v=Ae("reportReadyState"),x=Ye(I.useMemo(()=>y=>{const p=y.parentElement.parentElement.scrollHeight;a(p);const g=y.firstChild;if(g){const{height:$,width:b}=g.getBoundingClientRect();m({height:$,width:b})}f({column:Mo("column-gap",getComputedStyle(y).columnGap,h),row:Mo("row-gap",getComputedStyle(y).rowGap,h)})},[a,m,f,h]),!0,!1);return wn(()=>{e.itemHeight>0&&e.itemWidth>0&&v(!0)},[e]),T?null:S.jsx(l,{className:t,ref:x,...ve(l,u),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(y=>{const p=s(y.index,y.data,u);return r?S.jsx(c,{...ve(c,u),height:e.itemHeight,index:y.index,width:e.itemWidth},p):I.createElement(i,{...ve(i,u),className:o,"data-index":y.index,key:p},n(y.index,y.data,u))})})}),Ts=I.memo(function(){const e=ae("HeaderComponent"),t=Ae("headerHeight"),o=ae("headerFooterTag"),n=Ye(I.useMemo(()=>r=>{t(Be(r,"height"))},[t]),!0,!1),s=ae("context");return e?S.jsx(o,{ref:n,children:S.jsx(e,{...ve(e,s)})}):null}),Cs=I.memo(function(){const e=ae("FooterComponent"),t=Ae("footerHeight"),o=ae("headerFooterTag"),n=Ye(I.useMemo(()=>r=>{t(Be(r,"height"))},[t]),!0,!1),s=ae("context");return e?S.jsx(o,{ref:n,children:S.jsx(e,{...ve(e,s)})}):null}),$s=({children:e})=>{const t=I.useContext(yn),o=Ae("itemDimensions"),n=Ae("viewportDimensions"),s=Ye(I.useMemo(()=>r=>{n(r.getBoundingClientRect())},[n]),!0,!1);return I.useEffect(()=>{t&&(n({height:t.viewportHeight,width:t.viewportWidth}),o({height:t.itemHeight,width:t.itemWidth}))},[t,n,o]),S.jsx("div",{ref:s,style:Pt(!1),children:e})},Is=({children:e})=>{const t=I.useContext(yn),o=Ae("windowViewportRect"),n=Ae("itemDimensions"),s=ae("customScrollParent"),r=Go(o,s,!1);return I.useEffect(()=>{t&&(n({height:t.itemHeight,width:t.itemWidth}),o({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,o,n]),S.jsx("div",{ref:r,style:Pt(!1),children:e})},Es=I.memo(function({...e}){const t=ae("useWindowScroll"),o=ae("customScrollParent"),n=o||t?Rs:ks,s=o||t?Is:$s,r=ae("context");return S.jsx(n,{...e,...ve(n,r),children:S.jsxs(s,{children:[S.jsx(Ts,{}),S.jsx(Ss,{}),S.jsx(Cs,{})]})})}),{useEmitter:Cn,useEmitterValue:ae,usePublisher:Ae}=hn(vs,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},Es),ks=vn({useEmitter:Cn,useEmitterValue:ae,usePublisher:Ae}),Rs=Sn({useEmitter:Cn,useEmitterValue:ae,usePublisher:Ae});function Mo(e,t,o){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&o(`${e} was not resolved to pixel value correctly`,t,Ce.WARN),t==="normal"?0:parseInt(t??"0",10)}const As=({visible:e,onClick:t})=>e?S.jsx("button",{type:"button",className:"chat-scroll-bottom",onClick:t,"aria-label":"Scroll to bottom",children:S.jsx("img",{src:Uo,alt:"arrow up",width:24,height:24,style:{transform:"rotate(180deg)",filter:"var(--icon-filter-text)"}})}):null,Os=()=>{const{messages:e=[],classNames:t,isOpen:o,isLoading:n}=Ge(),[s,r]=I.useState(!1),a=I.useRef(null),i=()=>{a.current?.scrollToIndex({index:e.length-1,behavior:"smooth"})},l=e?.length??1;return I.useEffect(()=>{o&&setTimeout(i,0)},[o]),I.useEffect(()=>{i()},[e?.length]),S.jsxs("div",{className:Oe("autoui-chat-messages",t?.messageList),children:[S.jsx(ms,{ref:a,data:e,overscan:100,followOutput:"smooth",atBottomStateChange:c=>r(!c),components:{EmptyPlaceholder:()=>S.jsxs("div",{className:"empty__palceholder",children:[S.jsx("span",{className:"empty__palceholder--main",children:"Nothing here yet"}),S.jsx("span",{className:"empty__palceholder--secondary",children:"Start the conversation!"})]})},initialTopMostItemIndex:l-1,itemContent:(c,u)=>S.jsx("div",{className:Oe("autoui-message-row",u.role==="user"&&"is-user",u.role==="assistant"&&"is-assistant"),children:S.jsx(rr,{message:u})})}),S.jsx(As,{visible:s,onClick:i}),n&&S.jsx(Fn,{variant:"dots",color:"#0a84ff"})]})};async function js(e){const t=e.getReader(),o=new TextDecoder;let n="",s="";for(;;){const{value:a,done:i}=await t.read();if(i)break;n+=o.decode(a,{stream:!0});const l=n.split(`
|
|
7
7
|
|
|
8
|
-
`);n=l.pop()??"";for(const c of l){if(!c.startsWith("data:"))continue;const u=c.slice(5).trim();if(u==="[DONE]"){t.cancel();break}try{const
|
|
8
|
+
`);n=l.pop()??"";for(const c of l){if(!c.startsWith("data:"))continue;const u=c.slice(5).trim();if(u==="[DONE]"){t.cancel();break}try{const f=JSON.parse(u).choices?.[0]?.delta?.content;f&&(s+=f)}catch(m){console.error(m)}}}const r=s.match(/\{[\s\S]*\}$/);if(!r)throw new Error("LLM did not return valid JSON InstructionPlan");return JSON.parse(r[0])}function Ps(e,t,o){const n=Object.entries(t.functions).map(([a,i])=>{const l=i.params?Object.entries(i.params).map(([u,m])=>` ${u}: ${m}`).join(`
|
|
9
9
|
`):" (no params)",c=i.canShareDataWithLLM?`
|
|
10
10
|
[Can share data with LLM - set hasToShareDataWithLLM based on user intent]`:"";return`${a}:
|
|
11
11
|
${i.prompt}
|
|
12
12
|
Params:
|
|
13
|
-
${l}${c}`}),
|
|
14
|
-
`):" (no props)"
|
|
13
|
+
${l}${c}`}),s=Object.entries(t.components).map(([a,i])=>{const l=i.props?Object.entries(i.props).map(([u,m])=>` ${u}: ${m}`).join(`
|
|
14
|
+
`):" (no props)",c=i.callbacks?Object.entries(i.callbacks).map(([u,m])=>{const f=typeof m=="function"?{description:"Callback handler"}:m,h=f.whenToUse?`
|
|
15
|
+
When to use: ${f.whenToUse}`:"",T=f.example?`
|
|
16
|
+
Example: ${f.example}`:"";return` ${u}: ${f.description}${h}${T}`}).join(`
|
|
17
|
+
`):" (no callbacks)";return`${a}:
|
|
15
18
|
${i.prompt}
|
|
16
19
|
Props:
|
|
17
|
-
${l}
|
|
20
|
+
${l}
|
|
21
|
+
Available Callbacks:
|
|
22
|
+
${c}`});return`You are an Intent Planner. Analyze available functions/components, user message, and message history to create an InstructionPlan.
|
|
18
23
|
|
|
19
24
|
OUTPUT SCHEMA:
|
|
20
25
|
{
|
|
@@ -30,7 +35,8 @@ OUTPUT SCHEMA:
|
|
|
30
35
|
{
|
|
31
36
|
"type": "component",
|
|
32
37
|
"name": "<component name>",
|
|
33
|
-
"props": { /* may reference {{contextKey}} */ }
|
|
38
|
+
"props": { /* may reference {{contextKey}} */ },
|
|
39
|
+
"callbacks": { /* optional: explicitly map callback props to callback names */ }
|
|
34
40
|
},
|
|
35
41
|
{
|
|
36
42
|
"type": "text",
|
|
@@ -46,8 +52,12 @@ RULES:
|
|
|
46
52
|
Example: If step 1 has assign: "tasks", and step 2 function needs "tasks" param, use params: { "tasks": "{{tasks}}" }
|
|
47
53
|
3. hasToShareDataWithLLM: Set to true if user requests FILTERED/SPECIFIC data (criteria, conditions, analysis, explanations) OR false if user wants ALL/COMPLETE data.
|
|
48
54
|
4. Extract component props from user message or use context variables. Function params can also use context variables with {{contextKey}} syntax.
|
|
49
|
-
5.
|
|
50
|
-
|
|
55
|
+
5. For component callbacks: Use the "callbacks" field to explicitly specify which callback handlers to use.
|
|
56
|
+
- Format: { "onAction": "callbackName" } where callbackName matches a callback from "Available Callbacks"
|
|
57
|
+
- You can also pass callback names directly in props (e.g., { "onAddToCart": "addToCart" })
|
|
58
|
+
- The callbacks field takes precedence over props for callback resolution
|
|
59
|
+
6. Be minimal - only include necessary steps.
|
|
60
|
+
7. Return ONLY valid JSON, no markdown or comments.
|
|
51
61
|
|
|
52
62
|
${t.llm.appDescriptionPrompt?`
|
|
53
63
|
APP CONTEXT:
|
|
@@ -59,7 +69,7 @@ ${n.join(`
|
|
|
59
69
|
`)}
|
|
60
70
|
|
|
61
71
|
AVAILABLE COMPONENTS:
|
|
62
|
-
${
|
|
72
|
+
${s.join(`
|
|
63
73
|
|
|
64
74
|
`)}
|
|
65
75
|
|
|
@@ -106,21 +116,47 @@ User: "fetch tasks and then summarize them"
|
|
|
106
116
|
}
|
|
107
117
|
Note: The second function uses {{tasks}} in params to reference the assign key from the first step.
|
|
108
118
|
|
|
119
|
+
EXAMPLE 3 (Component with callbacks):
|
|
120
|
+
User: "show products and let me add them to cart"
|
|
121
|
+
{
|
|
122
|
+
"type": "sequence",
|
|
123
|
+
"steps": [
|
|
124
|
+
{
|
|
125
|
+
"type": "function",
|
|
126
|
+
"name": "fetchProducts",
|
|
127
|
+
"params": {},
|
|
128
|
+
"assign": "products"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"type": "component",
|
|
132
|
+
"name": "ProductGallery",
|
|
133
|
+
"props": { "products": "{{products}}" },
|
|
134
|
+
"callbacks": { "onAddToCart": "addToCart" }
|
|
135
|
+
}
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
Note: The callbacks field explicitly maps the onAddToCart prop to the "addToCart" callback handler.
|
|
139
|
+
Alternatively, you can use: props: { "onAddToCart": "addToCart" } or props: { "onAction": "addToCart" }
|
|
140
|
+
|
|
109
141
|
MESSAGE HISTORY:
|
|
110
142
|
${o||"(none)"}
|
|
111
143
|
|
|
112
144
|
CURRENT USER MESSAGE:
|
|
113
145
|
"${e}"
|
|
114
146
|
|
|
115
|
-
Return InstructionPlan JSON:`.trim()}async function Ls(e,t,o){const n=t.llm.proxyUrl??"https://autoui-proxy.onrender.com",
|
|
116
|
-
REQUIRED PROPS: ${
|
|
117
|
-
OPTIONAL PROPS: ${
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
147
|
+
Return InstructionPlan JSON:`.trim()}async function Ls(e,t,o){const n=t.llm.proxyUrl??"https://autoui-proxy.onrender.com",s=Ps(e,t,o),r=await fetch(`${n}/chat/create`,{method:"POST",headers:{"Content-Type":"application/json","X-AUTOUI-APP-ID":t.appId,...t.llm.sharedSecret&&{"X-AUTOUI-SECRET":t.llm.sharedSecret,authorization:"Bearer "+t.llm.sharedSecret}},body:JSON.stringify({messages:[{role:"user",content:s}],temperature:t.llm.temperature,maxTokens:t.llm.maxTokens,appDescriptionPrompt:t.llm.appDescriptionPrompt,appId:t.appId})});if(!r.ok||!r.body)throw new Error(`AutoUI proxy error: ${r.status}`);return console.log("Response received from LLM proxy for instruction plan.: ",JSON.stringify(r.body)),js(r.body)}function Ms(e){return{processMessage:I.useCallback(async(o,n)=>{let s=await Ls(o,e,n);if(console.log("RAW PLAN FROM LLM:",s),typeof s=="string")try{s=JSON.parse(s)}catch{throw console.error("â Failed to parse plan JSON:",s),new Error("Invalid plan format: could not parse JSON")}if(!s||typeof s!="object"||!s.type||!s.steps)throw console.error("â Invalid plan structure:",s),new Error("Plan must be an object with 'type' and 'steps'.");return s},[e])}}function it(e,t,o,n){if(e==null)return e;if(typeof e=="string"){if(e.startsWith("{{")&&e.endsWith("}}")){const s=e.slice(2,-2).trim(),r=t[s];return r===void 0&&console.warn(`â ī¸ [ResolveProps] Context key "${s}" not found. Available keys:`,Object.keys(t)),r}return e}if(Array.isArray(e))return e.map(s=>it(s,t,o,n));if(typeof e=="object"){const s={};for(const[r,a]of Object.entries(e))if(typeof a=="string"&&/^on[A-Z]/.test(r)){let i=!1;if(n?.callbacks?.[a]){const l=n.callbacks[a];s[r]=typeof l=="function"?l:l.callFunc,console.log(`đ [ResolveProps] Resolved dynamic callback "${r}" â "${a}" from component config`),i=!0}else if(n?.callbacks?.[r]){const l=n.callbacks[r];s[r]=typeof l=="function"?l:l.callFunc,console.log(`đ [ResolveProps] Resolved direct callback "${r}" from component config`),i=!0}else if(o.functions[a]){const l=a;s[r]=async(...c)=>await o.functions[l].callFunc({args:c}),console.log(`đ [ResolveProps] Resolved callback "${r}" â function "${l}"`),i=!0}i||(console.warn(`â ī¸ [ResolveProps] Callback "${r}" with value "${a}" not found. Available callbacks:`,n?.callbacks?Object.keys(n.callbacks):"none"),s[r]=it(a,t,o,n))}else s[r]=it(a,t,o,n);return s}return e}const Vs=(e,t,o)=>{e(n=>t?.children?[...n,{id:`${Date.now()}-a`,role:"assistant",kind:"ui",ui:{t:"fragment",children:t.children}}]:[...n,{id:`${Date.now()}-a`,role:"assistant",kind:"ui",ui:{t:"component",name:o.name,props:t}}])},Ns=e=>!!e&&typeof e=="object"&&!Array.isArray(e),zs=async(e,t)=>{const o=e.callFunc,n=t,s=Array.isArray(n.args),r=!!n.params&&typeof n.params=="object";let a;if(s){let i=n.args;if(i.length===1&&Ns(i[0])&&Array.isArray(e.params)&&e.params.length>0){const l=i[0];i=e.params.map(c=>l[c])}try{a=await o(...i)}catch{a=await o(i)}}else r?a=await o(n.params):a=await o();return a};function $n(e,t){return e?e.type==="component"?JSON.stringify(e.props??{}).includes(`{{${t}}}`):e.type==="function"?JSON.stringify(e.params??{}).includes(`{{${t}}}`)||JSON.stringify(e.args??[]).includes(`{{${t}}}`):!1:!1}function In(e,t){if(!e)return null;if(e.type==="component"){const o=t.components[e.name];return o?.props?{parseTo:"object",schema:o.props}:null}if(e.type==="function"){const o=t.functions[e.name];return o?.params?{parseTo:"object",schema:o.params}:null}return null}async function Fs(e,t,o){for(const n of t)if($n(n,e)){let s;if(n.type==="function"){const i=n.params??{};s=Object.keys(i).find(l=>{const c=i[l];return typeof c=="string"&&c.includes(`{{${e}}}`)})}else if(n.type==="component"){const i=n.props??{};s=Object.keys(i).find(l=>{const c=i[l];return typeof c=="string"&&c.includes(`{{${e}}}`)})}const r=await Promise.resolve().then(()=>ht),a=await r.getRuntimeSchemaAsync(o);if(a&&s){if(n.type==="function"){const i=a.functions.find(l=>l.name===n.name);if(i&&i.params[s]){const l=i.params[s],c=r.resolveType(l.type,a);if(c){let u="primitive";return c.type==="array"?u="array":c.type==="object"&&(u="object"),{parseTo:u,schema:c,paramName:s}}}}else if(n.type==="component"){const i=a.components.find(l=>l.name===n.name);if(i&&i.props[s]){const l=i.props[s],c=r.resolveType(l.type,a);if(c){let u="primitive";return c.type==="array"?u="array":c.type==="object"&&(u="object"),{parseTo:u,schema:c,paramName:s}}}}}return In(n,o)}return null}function En(e,t){if(!e||e.type!=="component")return[];const o=e.props??{};return Object.entries(o).filter(([,n])=>typeof n=="string"&&n.includes(`{{${t}}}`)).map(([n])=>n)}function kn(e,t){return t.length===1&&e&&typeof e=="object"&&!Array.isArray(e)&&t[0]in e?e[t[0]]:e}const Bs=Object.freeze(Object.defineProperty({__proto__:null,getConsumerKeysForAssign:En,getExpectedSchemaForAssignKey:Fs,getExpectedSchemaForStep:In,normalizeForCtx:kn,stepConsumesAssign:$n},Symbol.toStringTag,{value:"Module"})),_s=async(e,t,o,n,s,r,a,i)=>{const l=i?.parseTo??"primitive",c=s.steps.slice(a+1),u={type:s.type,steps:c},m=i&&i.parseTo!=="primitive"?JSON.stringify(i.schema,null,2):null;let f=e;if(JSON.stringify(e).length>2e3){if(Array.isArray(e))f={_type:"array",_length:e.length,_preview:e.slice(0,3),_note:`... and ${e.length-3} more items`};else if(typeof e=="object"&&e!==null){const p=Object.keys(e);f={_type:"object",_keys:p,_preview:Object.fromEntries(p.slice(0,5).map(g=>[g,e[g]])),_note:p.length>5?`... and ${p.length-5} more properties`:""}}}const T=n&&n.length>0&&n.length<500,v=new Set,x=new Set;c.forEach(p=>{p.type==="component"?v.add(p.name):p.type==="function"&&x.add(p.name)});let y="";if(v.size>0||x.size>0){const{getRuntimeSchemaAsync:p}=await Promise.resolve().then(()=>ht),g=await p(t);if(g){const $=[];v.size>0&&v.forEach(b=>{const C=g.components.find(w=>w.name===b),d=t.components[b];if(C){const w=Object.entries(C.props).filter(([j,M])=>M.required).map(([j,M])=>`${j} (${M.type}${M.required?", required":""})`),k=Object.entries(C.props).filter(([j,M])=>!M.required).map(([j,M])=>`${j} (${M.type}, optional)`);let A=`COMPONENT "${b}":`;if(w.length>0&&(A+=`
|
|
148
|
+
REQUIRED PROPS: ${w.join(", ")}`),k.length>0&&(A+=`
|
|
149
|
+
OPTIONAL PROPS: ${k.join(", ")}`),d?.callbacks){const j=Object.keys(d.callbacks);if(j.length>0){A+=`
|
|
150
|
+
AVAILABLE CALLBACKS: ${j.join(", ")}`;const M=Object.entries(d.callbacks).map(([z,V])=>{if(typeof V=="function")return` ${z}: Callback handler`;const H=V,Y="whenToUse"in H&&H.whenToUse?` (use when: ${H.whenToUse})`:"";return` ${z}: ${H.description}${Y}`}).join(`
|
|
151
|
+
`);A+=`
|
|
152
|
+
Callback Details:
|
|
153
|
+
${M}`}}$.push(A)}}),x.size>0&&x.forEach(b=>{const C=g.functions.find(d=>d.name===b);if(C){const d=Object.entries(C.params).filter(([A,j])=>j.required).map(([A,j])=>`${A} (${j.type}${j.required?", required":""})`),w=Object.entries(C.params).filter(([A,j])=>!j.required).map(([A,j])=>`${A} (${j.type}, optional)`);let k=`FUNCTION "${b}":`;d.length>0&&(k+=`
|
|
154
|
+
REQUIRED PARAMS: ${d.join(", ")}`),w.length>0&&(k+=`
|
|
155
|
+
OPTIONAL PARAMS: ${w.join(", ")}`),k+=`
|
|
156
|
+
RETURNS: ${C.returns.type}`,$.push(k)}}),$.length>0&&(y=`
|
|
121
157
|
|
|
122
158
|
AVAILABLE COMPONENTS/FUNCTIONS IN PLAN (use ONLY these props/params):
|
|
123
|
-
${
|
|
159
|
+
${$.join(`
|
|
124
160
|
|
|
125
161
|
`)}
|
|
126
162
|
`)}}return`You are AutoUI Data Analyzer. Analyze function output and refine downstream steps.
|
|
@@ -145,16 +181,16 @@ CRITICAL: FILTER AND TRANSFORM DATA BASED ON USER INTENT
|
|
|
145
181
|
|
|
146
182
|
CONTEXT:
|
|
147
183
|
User: "${o}"
|
|
148
|
-
${
|
|
184
|
+
${T?`Previous: ${n.substring(0,300)}`:""}
|
|
149
185
|
|
|
150
186
|
REMAINING STEPS (modify only these):
|
|
151
187
|
${JSON.stringify(u,null,2)}
|
|
152
188
|
|
|
153
189
|
FUNCTION OUTPUT:
|
|
154
|
-
${JSON.stringify(
|
|
155
|
-
${
|
|
190
|
+
${JSON.stringify(f,null,2)}
|
|
191
|
+
${m?`
|
|
156
192
|
EXPECTED SCHEMA:
|
|
157
|
-
${
|
|
193
|
+
${m}`:""}
|
|
158
194
|
${y}
|
|
159
195
|
|
|
160
196
|
CRITICAL RULES FOR newInstructionPlan:
|
|
@@ -163,61 +199,74 @@ CRITICAL RULES FOR newInstructionPlan:
|
|
|
163
199
|
- DO NOT create props/params that don't exist in the schema above
|
|
164
200
|
- Use context variables ({{contextKey}}) to reference data from previous steps
|
|
165
201
|
- If a component requires a prop (marked as required), you MUST include it in the props object
|
|
202
|
+
- For component callbacks: Use the "callbacks" field to specify callback handlers, or pass callback names in props
|
|
203
|
+
- Format: { "callbacks": { "onAction": "callbackName" } } or props: { "onAddToCart": "addToCart" }
|
|
204
|
+
- Use callback names from "AVAILABLE CALLBACKS" listed above
|
|
166
205
|
- Example: If TaskStats requires "tasks" prop, use: { "tasks": "{{tasks}}" } NOT { "filter": "food" }
|
|
206
|
+
- Example: If ProductCard has "addToCart" callback, use: { "callbacks": { "onAction": "addToCart" } } or props: { "onAddToCart": "addToCart" }
|
|
167
207
|
|
|
168
|
-
Return JSON only.`.trim()};function Fs(e){if(e==null)throw new Error("Invalid LLM response: null or undefined");if(typeof e=="string"){let s=e;const a=s.match(/^```(?:json)?\s*([\s\S]*?)\s*```$/);a&&(s=a[1].trim());try{e=JSON.parse(s)}catch{throw new Error(`Invalid LLM response: content is a string but not valid JSON: ${e.substring(0,100)}`)}}if(typeof e!="object"||Array.isArray(e))throw new Error(`Invalid LLM response: expected object but got ${typeof e}${Array.isArray(e)?" (array)":""}`);const{parseTo:t,data:o,newInstructionPlan:n}=e;if(o===void 0)throw new Error("Invalid LLM response: missing data field");let r;if(t==="array")if(Array.isArray(o))r=o;else if(typeof o=="object"&&o!==null&&!Array.isArray(o)){const s=Object.values(o);if(s.length!==1)throw new Error(`LLM data object must contain exactly one value when parseTo is 'array', got ${s.length}`);if(r=s[0],!Array.isArray(r))throw new Error(`Expected array but got ${typeof r}`)}else throw new Error(`Expected array or object containing array, got ${typeof o}`);else if(t==="object"){if(typeof o!="object"||o===null||Array.isArray(o))throw new Error(`Expected object but got ${Array.isArray(o)?"array":typeof o}`);const s=Object.values(o);if(s.length!==1)throw new Error(`LLM data object must contain exactly one value when parseTo is 'object', got ${s.length}`);r=s[0]}else r=o;return{parseTo:t??"primitive",data:r,newInstructionPlan:n??null}}const Ds=async(e,t,o,n,r,s,a,i)=>{try{const l=await Bs(e,t,o,n,r,s,a,i);console.log(`đ¤ [ExtraAnalysis] Sending request to LLM (prompt length: ${l.length} chars)`);const c=t.llm.proxyUrl??"https://autoui-proxy.onrender.com",u=await fetch(`${c}/chat/extraAnalysis`,{method:"POST",headers:{"Content-Type":"application/json","X-AUTOUI-APP-ID":t.appId,...t.llm.sharedSecret&&{"X-AUTOUI-SECRET":t.llm.sharedSecret}},body:JSON.stringify({messages:[{role:"user",content:l}],temperature:t.llm.temperature??.2,appId:t.appId})});if(!u.ok){const x=await u.text();throw console.error(`â [ExtraAnalysis] API error ${u.status}:`,x),new Error(`AutoUI proxy error: ${u.status} - ${x}`)}let p=await u.text();console.log("â
[ExtraAnalysis] Raw response received (text):",p.substring(0,200));const m=p.match(/^```(?:json)?\s*([\s\S]*?)\s*```$/);m&&(p=m[1].trim(),console.log("â
[ExtraAnalysis] Stripped markdown code blocks"));let h;try{h=JSON.parse(p),console.log("â
[ExtraAnalysis] Parsed JSON response")}catch(x){throw console.error("â [ExtraAnalysis] Response is not valid JSON:",x),console.error("â [ExtraAnalysis] Response text:",p),new Error(`Invalid JSON response from LLM: ${p.substring(0,200)}`)}if(h&&typeof h=="object"){if("content"in h&&typeof h.content=="string")try{let x=h.content;const w=x.match(/^```(?:json)?\s*([\s\S]*?)\s*```$/);w&&(x=w[1].trim(),console.log("â
[ExtraAnalysis] Stripped markdown code blocks from nested content")),h=JSON.parse(x),console.log("â
[ExtraAnalysis] Extracted and parsed content from wrapper")}catch{console.warn("â ī¸ [ExtraAnalysis] content.content is not JSON, using original")}else if("response"in h)if(typeof h.response=="string"){let x=h.response;const w=x.match(/^```(?:json)?\s*([\s\S]*?)\s*```$/);if(w){x=w[1].trim();try{h=JSON.parse(x),console.log("â
[ExtraAnalysis] Extracted and parsed response from wrapper (stripped markdown)")}catch{h=x,console.log("â
[ExtraAnalysis] Extracted response from wrapper (as string)")}}else h=h.response,console.log("â
[ExtraAnalysis] Extracted response from wrapper")}else h=h.response,console.log("â
[ExtraAnalysis] Extracted response from wrapper");else if("message"in h&&typeof h.message=="string")try{let x=h.message;const w=x.match(/^```(?:json)?\s*([\s\S]*?)\s*```$/);w&&(x=w[1].trim(),console.log("â
[ExtraAnalysis] Stripped markdown code blocks from message")),h=JSON.parse(x),console.log("â
[ExtraAnalysis] Extracted and parsed message from wrapper")}catch{console.warn("â ī¸ [ExtraAnalysis] message is not JSON, using original")}}console.log("â
[ExtraAnalysis] Final content to parse:",typeof h,h);const $=Fs(h);return console.log("â
[ExtraAnalysis] Parsed response:",{hasData:!!$.data,hasNewPlan:!!$.newInstructionPlan,parseTo:$.parseTo}),$}catch(l){return console.error("â [ExtraAnalysis] Error during analysis:",l),{parseTo:i?.parseTo??"primitive",data:e,newInstructionPlan:null}}},Us=async(e,t,o,n,r,s,a,i,l,c,u,p,m)=>{console.log(`đ [AnalyzeDataStep] Starting analysis for step "${n.name}" at index ${r}`),console.log("đ [AnalyzeDataStep] Output data type:",typeof t,Array.isArray(t)?"array":"object"),console.log("đ [AnalyzeDataStep] Assign key:",o),console.log("đ [AnalyzeDataStep] Next step:",s?.type,s?.type==="component"||s?.type==="function"?s.name:"");const h=c.steps.slice(r+1);let $=null;if(o&&h.length>0){const{getExpectedSchemaForAssignKey:x}=await Promise.resolve().then(()=>Hs);$=await x(o,h,e),$?console.log(`đ [AnalyzeDataStep] Expected schema found for assign key "${o}":`,$):console.log(`âšī¸ [AnalyzeDataStep] No expected schema - no remaining steps consume assign key "${o}"`)}else console.log("âšī¸ [AnalyzeDataStep] No expected schema - no assign key or no remaining steps");try{console.log("đ [AnalyzeDataStep] Calling extraAnalysisWithLLM...");const x=await Ds(t,e,a,i,c,n,r,$);console.log("â
[AnalyzeDataStep] Received analysis result:",{hasData:!!x.data,hasNewPlan:!!x.newInstructionPlan,parseTo:x.parseTo});const w=En(s,o),y=Rn(x.data,w);if(console.log("Extra analysis data received from LLM:",x),console.log("Normalized ctx value:",y),o&&(l[o]=y),x.newInstructionPlan!=null&&x.newInstructionPlan!=""){if(console.log("analyzed.newInstructionPlan: ",x.newInstructionPlan),o){const d=JSON.parse(JSON.stringify(x.newInstructionPlan));d.steps&&d.steps.forEach(g=>{g.type==="component"&&g.props&&Object.keys(g.props).forEach(T=>{typeof g.props[T]=="string"&&g.props[T]==="{{data}}"&&(g.props[T]=`{{${o}}}`)})}),kt(d,e,u,p,m,a,i,l)}else kt(x.newInstructionPlan,e,u,p,m,a,i,l);return!0}return!1}catch(x){return console.error(x),!0}},bt=new Map,Vo=new Set;async function Ws(e){const t=e;if(Vo.has(t))return bt.get(t)||null;Vo.add(t);try{let o;if(t.startsWith("http://")||t.startsWith("https://")){console.log(`đĨ [Runtime Validation] Fetching schema from URL: ${t}`);const n=await fetch(t);if(!n.ok)throw new Error(`Failed to fetch schema: ${n.status} ${n.statusText}`);o=await n.json()}else{const n=[t.startsWith("/")?t:`/${t}`,`/public/${t}`,t];let r=null;for(const s of n)try{console.log(`đĨ [Runtime Validation] Trying to fetch schema from: ${s}`);const a=await fetch(s);if(a.ok){o=await a.json(),console.log(`â
[Runtime Validation] Successfully loaded schema from: ${s}`);break}else r=new Error(`HTTP ${a.status}: ${a.statusText}`)}catch(a){r=a instanceof Error?a:new Error(String(a));continue}if(!o)throw r||new Error(`Failed to load schema from any path: ${n.join(", ")}`)}return o&&o.types&&o.components&&o.functions?(console.log("â
[Runtime Validation] Runtime schema loaded successfully",{path:t,types:Object.keys(o.types).length,components:o.components.length,functions:o.functions.length}),bt.set(t,o),o):(console.warn("â ī¸ [Runtime Validation] Runtime schema has invalid structure"),bt.set(t,null),null)}catch(o){return console.warn(`â ī¸ [Runtime Validation] Runtime schema file not found at "${t}":`,o),bt.set(t,null),null}}async function so(e){const t=e?.runtime?.runtimeSchemaPath||".autoui-runtime-schema.json";return await Ws(t)}function Je(e,t){return t.types[e]||null}function it(e,t,o,n,r=""){const s=[],a=r||"value",i=" ".repeat((r.match(/\./g)||[]).length+1);if(console.log(`${i}đ [Type Validation] Validating "${a}" against type "${o}"`),console.log(`${i} đĻ Value:`,e),console.log(`${i} đ Value type: ${typeof e}, isArray: ${Array.isArray(e)}, isNull: ${e===null}`),console.log(`${i} đ Type definition:`,JSON.stringify(t,null,2)),e==null)return console.log(`${i} âšī¸ Value is ${e===void 0?"undefined":"null"} - skipping (optionality checked at prop/param level)`),s;switch(t.type){case"primitive":if(console.log(`${i} đ Checking primitive type: "${o}"`),o==="string"&&typeof e!="string"){const l=`${a} must be a string, got ${typeof e}`;console.log(`${i} â ${l}`),s.push(l)}else if(o==="number"&&(typeof e!="number"||isNaN(e))){const l=`${a} must be a number, got ${typeof e}`;console.log(`${i} â ${l}`),s.push(l)}else if(o==="boolean"&&typeof e!="boolean"){const l=`${a} must be a boolean, got ${typeof e}`;console.log(`${i} â ${l}`),s.push(l)}else console.log(`${i} â
Primitive type check passed`);break;case"enum":if(console.log(`${i} đ Checking enum type with values:`,t.values),t.values&&Array.isArray(t.values))if(t.values.includes(e))console.log(`${i} â
Enum value check passed`);else{const l=`${a} must be one of: ${t.values.join(", ")}, got: ${e}`;console.log(`${i} â ${l}`),s.push(l)}break;case"array":if(console.log(`${i} đ Checking array type`),Array.isArray(e)){if(console.log(`${i} â
Array type check passed (length: ${e.length})`),t.items){const l=t.items.type;console.log(`${i} đ Validating array items against type: "${l}"`);const c=Je(l,n);c?e.forEach((u,p)=>{console.log(`${i} đĻ Validating item [${p}]:`,u);const m=it(u,c,l,n,`${r}[${p}]`);s.push(...m)}):console.log(`${i} â ī¸ Item type "${l}" not found in schema`)}}else{const l=`${a} must be an array, got ${typeof e}`;if(console.log(`${i} â ${l}`),console.log(`${i} đĄ Value is:`,e),console.log(`${i} đĄ Value constructor:`,e?.constructor?.name),typeof e=="string"){console.log(`${i} đĄ String value might be JSON - attempting to parse...`);try{const c=JSON.parse(e);console.log(`${i} đĄ Parsed successfully! Type: ${typeof c}, isArray: ${Array.isArray(c)}`),Array.isArray(c)&&console.log(`${i} â ī¸ WARNING: Value is a JSON string that should be parsed before validation!`)}catch{console.log(`${i} đĄ String is not valid JSON`)}}s.push(l)}break;case"object":if(console.log(`${i} đ Checking object type`),typeof e!="object"||e===null||Array.isArray(e)){const l=`${a} must be an object, got ${typeof e}`;console.log(`${i} â ${l}`),s.push(l)}else t.properties&&(console.log(`${i} â
Object type check passed`),console.log(`${i} đ Validating object properties:`,Object.keys(t.properties)),Object.entries(t.properties).forEach(([l,c])=>{const u=e[l],p=r?`${r}.${l}`:l;if(console.log(`${i} đĻ Property "${l}":`,u),c.required&&u==null){const m=`${p} is required but was ${u===void 0?"undefined":"null"}`;console.log(`${i} â ${m}`),s.push(m)}if(u!=null){const m=Je(c.type,n);if(m){const h=it(u,m,c.type,n,p);s.push(...h)}}}));break;case"union":if(console.log(`${i} đ Checking union type with members:`,t.refs),t.refs&&t.refs.length>0){const l=[];for(const u of t.refs){console.log(`${i} đ Trying union member: "${u}"`);const p=Je(u,n);if(p){const m=it(e,p,u,n,r);if(m.length===0)return console.log(`${i} â
Union member "${u}" validated successfully`),[];console.log(`${i} â Union member "${u}" failed:`,m),l.push(...m)}}const c=`${a} does not match any union member. Errors: ${l.join("; ")}`;console.log(`${i} â ${c}`),s.push(c)}break}return s.length===0?console.log(`${i} â
Type validation passed for "${a}"`):console.log(`${i} â Type validation failed for "${a}" with ${s.length} error(s)`),s}function Js(e,t,o){const n=[];console.log(`
|
|
169
|
-
đ [Runtime Validation] ==========================================`),console.log(`đ [Runtime Validation] Starting validation for component: "${e}"`),console.log("đ [Runtime Validation] Raw props received:",JSON.stringify(t,null,2)),console.log("đ [Runtime Validation] Props type check:",Object.entries(t).map(([
|
|
170
|
-
đ [Runtime Validation] Validating prop: "${
|
|
208
|
+
Return JSON only.`.trim()};function Hs(e){if(e==null)throw new Error("Invalid LLM response: null or undefined");if(typeof e=="string"){let r=e;const a=r.match(/^```(?:json)?\s*([\s\S]*?)\s*```$/);a&&(r=a[1].trim());try{e=JSON.parse(r)}catch{throw new Error(`Invalid LLM response: content is a string but not valid JSON: ${e.substring(0,100)}`)}}if(typeof e!="object"||Array.isArray(e))throw new Error(`Invalid LLM response: expected object but got ${typeof e}${Array.isArray(e)?" (array)":""}`);const{parseTo:t,data:o,newInstructionPlan:n}=e;if(o===void 0)throw new Error("Invalid LLM response: missing data field");let s;if(t==="array")if(Array.isArray(o))s=o;else if(typeof o=="object"&&o!==null&&!Array.isArray(o)){const r=Object.values(o);if(r.length!==1)throw new Error(`LLM data object must contain exactly one value when parseTo is 'array', got ${r.length}`);if(s=r[0],!Array.isArray(s))throw new Error(`Expected array but got ${typeof s}`)}else throw new Error(`Expected array or object containing array, got ${typeof o}`);else if(t==="object"){if(typeof o!="object"||o===null||Array.isArray(o))throw new Error(`Expected object but got ${Array.isArray(o)?"array":typeof o}`);const r=Object.values(o);if(r.length!==1)throw new Error(`LLM data object must contain exactly one value when parseTo is 'object', got ${r.length}`);s=r[0]}else s=o;return{parseTo:t??"primitive",data:s,newInstructionPlan:n??null}}const Ds=async(e,t,o,n,s,r,a,i)=>{try{const l=await _s(e,t,o,n,s,r,a,i);console.log(`đ¤ [ExtraAnalysis] Sending request to LLM (prompt length: ${l.length} chars)`);const c=t.llm.proxyUrl??"https://autoui-proxy.onrender.com",u=await fetch(`${c}/chat/extraAnalysis`,{method:"POST",headers:{"Content-Type":"application/json","X-AUTOUI-APP-ID":t.appId,...t.llm.sharedSecret&&{"X-AUTOUI-SECRET":t.llm.sharedSecret}},body:JSON.stringify({messages:[{role:"user",content:l}],temperature:t.llm.temperature??.2,appId:t.appId})});if(!u.ok){const v=await u.text();throw console.error(`â [ExtraAnalysis] API error ${u.status}:`,v),new Error(`AutoUI proxy error: ${u.status} - ${v}`)}let m=await u.text();console.log("â
[ExtraAnalysis] Raw response received (text):",m.substring(0,200));const f=m.match(/^```(?:json)?\s*([\s\S]*?)\s*```$/);f&&(m=f[1].trim(),console.log("â
[ExtraAnalysis] Stripped markdown code blocks"));let h;try{h=JSON.parse(m),console.log("â
[ExtraAnalysis] Parsed JSON response")}catch(v){throw console.error("â [ExtraAnalysis] Response is not valid JSON:",v),console.error("â [ExtraAnalysis] Response text:",m),new Error(`Invalid JSON response from LLM: ${m.substring(0,200)}`)}if(h&&typeof h=="object"){if("content"in h&&typeof h.content=="string")try{let v=h.content;const x=v.match(/^```(?:json)?\s*([\s\S]*?)\s*```$/);x&&(v=x[1].trim(),console.log("â
[ExtraAnalysis] Stripped markdown code blocks from nested content")),h=JSON.parse(v),console.log("â
[ExtraAnalysis] Extracted and parsed content from wrapper")}catch{console.warn("â ī¸ [ExtraAnalysis] content.content is not JSON, using original")}else if("response"in h)if(typeof h.response=="string"){let v=h.response;const x=v.match(/^```(?:json)?\s*([\s\S]*?)\s*```$/);if(x){v=x[1].trim();try{h=JSON.parse(v),console.log("â
[ExtraAnalysis] Extracted and parsed response from wrapper (stripped markdown)")}catch{h=v,console.log("â
[ExtraAnalysis] Extracted response from wrapper (as string)")}}else h=h.response,console.log("â
[ExtraAnalysis] Extracted response from wrapper")}else h=h.response,console.log("â
[ExtraAnalysis] Extracted response from wrapper");else if("message"in h&&typeof h.message=="string")try{let v=h.message;const x=v.match(/^```(?:json)?\s*([\s\S]*?)\s*```$/);x&&(v=x[1].trim(),console.log("â
[ExtraAnalysis] Stripped markdown code blocks from message")),h=JSON.parse(v),console.log("â
[ExtraAnalysis] Extracted and parsed message from wrapper")}catch{console.warn("â ī¸ [ExtraAnalysis] message is not JSON, using original")}}console.log("â
[ExtraAnalysis] Final content to parse:",typeof h,h);const T=Hs(h);return console.log("â
[ExtraAnalysis] Parsed response:",{hasData:!!T.data,hasNewPlan:!!T.newInstructionPlan,parseTo:T.parseTo}),T}catch(l){return console.error("â [ExtraAnalysis] Error during analysis:",l),{parseTo:i?.parseTo??"primitive",data:e,newInstructionPlan:null}}},Us=async(e,t,o,n,s,r,a,i,l,c,u,m,f)=>{console.log(`đ [AnalyzeDataStep] Starting analysis for step "${n.name}" at index ${s}`),console.log("đ [AnalyzeDataStep] Output data type:",typeof t,Array.isArray(t)?"array":"object"),console.log("đ [AnalyzeDataStep] Assign key:",o),console.log("đ [AnalyzeDataStep] Next step:",r?.type,r?.type==="component"||r?.type==="function"?r.name:"");const h=c.steps.slice(s+1);let T=null;if(o&&h.length>0){const{getExpectedSchemaForAssignKey:v}=await Promise.resolve().then(()=>Bs);T=await v(o,h,e),T?console.log(`đ [AnalyzeDataStep] Expected schema found for assign key "${o}":`,T):console.log(`âšī¸ [AnalyzeDataStep] No expected schema - no remaining steps consume assign key "${o}"`)}else console.log("âšī¸ [AnalyzeDataStep] No expected schema - no assign key or no remaining steps");try{console.log("đ [AnalyzeDataStep] Calling extraAnalysisWithLLM...");const v=await Ds(t,e,a,i,c,n,s,T);console.log("â
[AnalyzeDataStep] Received analysis result:",{hasData:!!v.data,hasNewPlan:!!v.newInstructionPlan,parseTo:v.parseTo});const x=En(r,o),y=kn(v.data,x);if(console.log("Extra analysis data received from LLM:",v),console.log("Normalized ctx value:",y),o&&(l[o]=y),v.newInstructionPlan!=null&&v.newInstructionPlan!=""){if(console.log("analyzed.newInstructionPlan: ",v.newInstructionPlan),o){const p=JSON.parse(JSON.stringify(v.newInstructionPlan));p.steps&&p.steps.forEach(g=>{g.type==="component"&&g.props&&Object.keys(g.props).forEach($=>{typeof g.props[$]=="string"&&g.props[$]==="{{data}}"&&(g.props[$]=`{{${o}}}`)})}),Rt(p,e,u,m,f,a,i,l)}else Rt(v.newInstructionPlan,e,u,m,f,a,i,l);return!0}return!1}catch(v){return console.error(v),!0}},Tt=new Map,Vo=new Set;async function Ws(e){const t=e;if(Vo.has(t))return Tt.get(t)||null;Vo.add(t);try{let o;if(t.startsWith("http://")||t.startsWith("https://")){console.log(`đĨ [Runtime Validation] Fetching schema from URL: ${t}`);const n=await fetch(t);if(!n.ok)throw new Error(`Failed to fetch schema: ${n.status} ${n.statusText}`);o=await n.json()}else{const n=[t.startsWith("/")?t:`/${t}`,`/public/${t}`,t];let s=null;for(const r of n)try{console.log(`đĨ [Runtime Validation] Trying to fetch schema from: ${r}`);const a=await fetch(r);if(a.ok){o=await a.json(),console.log(`â
[Runtime Validation] Successfully loaded schema from: ${r}`);break}else s=new Error(`HTTP ${a.status}: ${a.statusText}`)}catch(a){s=a instanceof Error?a:new Error(String(a));continue}if(!o)throw s||new Error(`Failed to load schema from any path: ${n.join(", ")}`)}return o&&o.types&&o.components&&o.functions?(console.log("â
[Runtime Validation] Runtime schema loaded successfully",{path:t,types:Object.keys(o.types).length,components:o.components.length,functions:o.functions.length}),Tt.set(t,o),o):(console.warn("â ī¸ [Runtime Validation] Runtime schema has invalid structure"),Tt.set(t,null),null)}catch(o){return console.warn(`â ī¸ [Runtime Validation] Runtime schema file not found at "${t}":`,o),Tt.set(t,null),null}}async function so(e){const t=e?.runtime?.runtimeSchemaPath||".autoui-runtime-schema.json";return await Ws(t)}function Je(e,t){return t.types[e]||null}function at(e,t,o,n,s=""){const r=[],a=s||"value",i=" ".repeat((s.match(/\./g)||[]).length+1);if(console.log(`${i}đ [Type Validation] Validating "${a}" against type "${o}"`),console.log(`${i} đĻ Value:`,e),console.log(`${i} đ Value type: ${typeof e}, isArray: ${Array.isArray(e)}, isNull: ${e===null}`),console.log(`${i} đ Type definition:`,JSON.stringify(t,null,2)),e==null)return console.log(`${i} âšī¸ Value is ${e===void 0?"undefined":"null"} - skipping (optionality checked at prop/param level)`),r;switch(t.type){case"primitive":if(console.log(`${i} đ Checking primitive type: "${o}"`),o==="string"&&typeof e!="string"){const l=`${a} must be a string, got ${typeof e}`;console.log(`${i} â ${l}`),r.push(l)}else if(o==="number"&&(typeof e!="number"||isNaN(e))){const l=`${a} must be a number, got ${typeof e}`;console.log(`${i} â ${l}`),r.push(l)}else if(o==="boolean"&&typeof e!="boolean"){const l=`${a} must be a boolean, got ${typeof e}`;console.log(`${i} â ${l}`),r.push(l)}else console.log(`${i} â
Primitive type check passed`);break;case"enum":if(console.log(`${i} đ Checking enum type with values:`,t.values),t.values&&Array.isArray(t.values))if(t.values.includes(e))console.log(`${i} â
Enum value check passed`);else{const l=`${a} must be one of: ${t.values.join(", ")}, got: ${e}`;console.log(`${i} â ${l}`),r.push(l)}break;case"array":if(console.log(`${i} đ Checking array type`),Array.isArray(e)){if(console.log(`${i} â
Array type check passed (length: ${e.length})`),t.items){const l=t.items.type;console.log(`${i} đ Validating array items against type: "${l}"`);const c=Je(l,n);c?e.forEach((u,m)=>{console.log(`${i} đĻ Validating item [${m}]:`,u);const f=at(u,c,l,n,`${s}[${m}]`);r.push(...f)}):console.log(`${i} â ī¸ Item type "${l}" not found in schema`)}}else{const l=`${a} must be an array, got ${typeof e}`;if(console.log(`${i} â ${l}`),console.log(`${i} đĄ Value is:`,e),console.log(`${i} đĄ Value constructor:`,e?.constructor?.name),typeof e=="string"){console.log(`${i} đĄ String value might be JSON - attempting to parse...`);try{const c=JSON.parse(e);console.log(`${i} đĄ Parsed successfully! Type: ${typeof c}, isArray: ${Array.isArray(c)}`),Array.isArray(c)&&console.log(`${i} â ī¸ WARNING: Value is a JSON string that should be parsed before validation!`)}catch{console.log(`${i} đĄ String is not valid JSON`)}}r.push(l)}break;case"object":if(console.log(`${i} đ Checking object type`),typeof e!="object"||e===null||Array.isArray(e)){const l=`${a} must be an object, got ${typeof e}`;console.log(`${i} â ${l}`),r.push(l)}else t.properties&&(console.log(`${i} â
Object type check passed`),console.log(`${i} đ Validating object properties:`,Object.keys(t.properties)),Object.entries(t.properties).forEach(([l,c])=>{const u=e[l],m=s?`${s}.${l}`:l;if(console.log(`${i} đĻ Property "${l}":`,u),c.required&&u==null){const f=`${m} is required but was ${u===void 0?"undefined":"null"}`;console.log(`${i} â ${f}`),r.push(f)}if(u!=null){const f=Je(c.type,n);if(f){const h=at(u,f,c.type,n,m);r.push(...h)}}}));break;case"union":if(console.log(`${i} đ Checking union type with members:`,t.refs),t.refs&&t.refs.length>0){const l=[];for(const u of t.refs){console.log(`${i} đ Trying union member: "${u}"`);const m=Je(u,n);if(m){const f=at(e,m,u,n,s);if(f.length===0)return console.log(`${i} â
Union member "${u}" validated successfully`),[];console.log(`${i} â Union member "${u}" failed:`,f),l.push(...f)}}const c=`${a} does not match any union member. Errors: ${l.join("; ")}`;console.log(`${i} â ${c}`),r.push(c)}break}return r.length===0?console.log(`${i} â
Type validation passed for "${a}"`):console.log(`${i} â Type validation failed for "${a}" with ${r.length} error(s)`),r}function Js(e,t,o){const n=[];console.log(`
|
|
209
|
+
đ [Runtime Validation] ==========================================`),console.log(`đ [Runtime Validation] Starting validation for component: "${e}"`),console.log("đ [Runtime Validation] Raw props received:",JSON.stringify(t,null,2)),console.log("đ [Runtime Validation] Props type check:",Object.entries(t).map(([r,a])=>`${r}: ${typeof a} (${Array.isArray(a)?"array":typeof a})`));const s=o.components.find(r=>r.name===e);return s?(console.log(`â
[Runtime Validation] Found component schema for "${e}"`),console.log("đ [Runtime Validation] Component schema:",JSON.stringify(s.props,null,2)),Object.entries(s.props).forEach(([r,a])=>{console.log(`
|
|
210
|
+
đ [Runtime Validation] Validating prop: "${r}"`),console.log(" đĨ [Runtime Validation] Prop reference:",JSON.stringify(a,null,2));const i=t[r];if(console.log(" đĻ [Runtime Validation] Prop value received:",i),console.log(` đ [Runtime Validation] Prop value type: ${typeof i}`),console.log(` đ [Runtime Validation] Prop value isArray: ${Array.isArray(i)}`),console.log(` đ [Runtime Validation] Prop value isNull: ${i===null}`),console.log(` đ [Runtime Validation] Prop value isUndefined: ${i===void 0}`),typeof i=="string"){console.log(` đ [Runtime Validation] String value length: ${i.length}`),console.log(` đ [Runtime Validation] String preview: ${i.substring(0,100)}${i.length>100?"...":""}`);try{const l=JSON.parse(i);console.log(" đ [Runtime Validation] String appears to be JSON! Parsed as:",typeof l),Array.isArray(l)&&console.log(` đ [Runtime Validation] Parsed JSON is an array with ${l.length} items`)}catch{console.log(" âšī¸ [Runtime Validation] String is not valid JSON")}}if(a.required&&i==null){const l=`Prop "${r}" is required but was ${i===void 0?"undefined":"null"}`;console.log(` â [Runtime Validation] ${l}`),n.push(l);return}if(i!=null){console.log(` đ [Runtime Validation] Resolving type: "${a.type}"`);const l=Je(a.type,o);if(l){console.log(" â
[Runtime Validation] Type definition found:",JSON.stringify(l,null,2)),console.log(" đ [Runtime Validation] Starting type validation...");const c=at(i,l,a.type,o,r);c.length>0?console.log(` â [Runtime Validation] Validation failed with ${c.length} error(s):`,c):console.log(` â
[Runtime Validation] Prop "${r}" passed validation`),n.push(...c)}else console.warn(` â ī¸ [Runtime Validation] Type "${a.type}" not found in schema for prop "${r}"`),console.log(" đ [Runtime Validation] Available types:",Object.keys(o.types).slice(0,10))}else console.log(` âšī¸ [Runtime Validation] Prop "${r}" is ${i===void 0?"undefined":"null"} - skipping validation`)}),console.log(`
|
|
171
211
|
đ [Runtime Validation] Validation summary for "${e}":`),n.length===0?console.log(" â
All props validated successfully"):console.log(` â Found ${n.length} validation error(s):`,n),console.log(`đ [Runtime Validation] ==========================================
|
|
172
|
-
`),n):(console.warn(`â ī¸ [Runtime Validation] Component "${e}" not found in schema`),console.log(" Available components:",o.components.map(
|
|
173
|
-
đ [Runtime Validation] ==========================================`),console.log(`đ [Runtime Validation] Starting validation for function: "${e}"`),console.log("đ [Runtime Validation] Raw params received:",JSON.stringify(t,null,2)),console.log("đ [Runtime Validation] Params type check:",Object.entries(t).map(([
|
|
174
|
-
đ [Runtime Validation] Validating param: "${
|
|
212
|
+
`),n):(console.warn(`â ī¸ [Runtime Validation] Component "${e}" not found in schema`),console.log(" Available components:",o.components.map(r=>r.name)),n)}function qs(e,t,o){const n=[],s=[],r={...e},a=o.components.find(i=>i.name===t);return a?(Object.entries(a.props).forEach(([i,l])=>{const c=r[i];if(typeof c=="string"){const u=Je(l.type,o);if(u&&(u.type==="array"||u.type==="object")){const m=u.type,f=c.length>100?`${c.substring(0,100)}... (${c.length} chars)`:c;console.log(`đ [Parse Props] Attempting to parse prop "${i}" (expected type: ${m}, value: "${f}")`);try{const h=JSON.parse(c);if(m==="array"&&Array.isArray(h))console.log(`â
[Parse Props] Successfully parsed JSON string for prop "${i}" as array (${h.length} items)`),r[i]=h;else if(m==="object"&&typeof h=="object"&&h!==null&&!Array.isArray(h))console.log(`â
[Parse Props] Successfully parsed JSON string for prop "${i}" as object`),r[i]=h;else{const T=Array.isArray(h)?"array":typeof h;n.push({propName:i,expectedType:m,receivedValue:c,errorType:"type_mismatch",message:`Prop "${i}" was parsed as JSON but type doesn't match. Expected ${m}, got ${T}`,suggestion:`Ensure the context variable contains a valid ${m} JSON string (e.g., ${m==="array"?"[...]":"{...}"})`}),console.warn(`â ī¸ [Parse Props] ${n[n.length-1].message}`)}}catch(h){const T=c.trim().startsWith("[")||c.trim().startsWith("{"),v=h instanceof Error?h.message:String(h);T?(n.push({propName:i,expectedType:m,receivedValue:c,errorType:"parsing_failed",message:`Prop "${i}" appears to be JSON but failed to parse: ${v}`,suggestion:`Check that the JSON string is valid. Received: "${f}"`}),console.error(`â [Parse Props] Failed to parse JSON string for prop "${i}" (expected ${m}): ${v}`)):(n.push({propName:i,expectedType:m,receivedValue:c,errorType:"invalid_json",message:`Prop "${i}" is a string but not in JSON format. Expected ${m}, got: "${c}"`,suggestion:l.required?`The prop "${i}" is required and should be a ${m} (array or object). Check that the context variable contains the correct data structure.`:`The prop "${i}" should be a ${m} if provided. Current value: "${c}"`}),console.warn(`â ī¸ [Parse Props] Prop "${i}" is a string but not JSON format (expected ${m}, got: "${c}")`))}}}}),{props:r,errors:n,warnings:s}):(s.push(`Component "${t}" not found in schema - skipping JSON parsing`),{props:r,errors:n,warnings:s})}function Gs(e,t,o){const n=[];console.log(`
|
|
213
|
+
đ [Runtime Validation] ==========================================`),console.log(`đ [Runtime Validation] Starting validation for function: "${e}"`),console.log("đ [Runtime Validation] Raw params received:",JSON.stringify(t,null,2)),console.log("đ [Runtime Validation] Params type check:",Object.entries(t).map(([r,a])=>`${r}: ${typeof a} (${Array.isArray(a)?"array":typeof a})`));const s=o.functions.find(r=>r.name===e);return s?(console.log(`â
[Runtime Validation] Found function schema for "${e}"`),console.log("đ [Runtime Validation] Function schema:",JSON.stringify(s.params,null,2)),Object.entries(s.params).forEach(([r,a])=>{console.log(`
|
|
214
|
+
đ [Runtime Validation] Validating param: "${r}"`),console.log(" đĨ [Runtime Validation] Param reference:",JSON.stringify(a,null,2));const i=t[r];if(console.log(" đĻ [Runtime Validation] Param value received:",i),console.log(` đ [Runtime Validation] Param value type: ${typeof i}`),console.log(` đ [Runtime Validation] Param value isArray: ${Array.isArray(i)}`),a.required&&i==null){const l=`Param "${r}" is required but was ${i===void 0?"undefined":"null"}`;console.log(` â [Runtime Validation] ${l}`),n.push(l);return}if(i!=null){console.log(` đ [Runtime Validation] Resolving type: "${a.type}"`);const l=Je(a.type,o);if(l){console.log(" â
[Runtime Validation] Type definition found:",JSON.stringify(l,null,2)),console.log(" đ [Runtime Validation] Starting type validation...");const c=at(i,l,a.type,o,r);c.length>0?console.log(` â [Runtime Validation] Validation failed with ${c.length} error(s):`,c):console.log(` â
[Runtime Validation] Param "${r}" passed validation`),n.push(...c)}else console.warn(` â ī¸ [Runtime Validation] Type "${a.type}" not found in schema for param "${r}"`)}else console.log(` âšī¸ [Runtime Validation] Param "${r}" is ${i===void 0?"undefined":"null"} - skipping validation`)}),console.log(`
|
|
175
215
|
đ [Runtime Validation] Validation summary for "${e}":`),n.length===0?console.log(" â
All params validated successfully"):console.log(` â Found ${n.length} validation error(s):`,n),console.log(`đ [Runtime Validation] ==========================================
|
|
176
|
-
`),n):(console.warn(`â ī¸ [Runtime Validation] Function "${e}" not found in schema`),console.log(" Available functions:",o.functions.map(
|
|
177
|
-
đ [Validation] Validating prop "${n}":`),console.log(" Value:",
|
|
178
|
-
đ [Validation] Component "${t.name}" validation summary:`),o.length===0?console.log(" â
All props validated successfully"):console.log(` â Found ${o.length} validation error(s):`,o),o}const Zs=async(e,t,o)=>{const n=await Ks(e,t,o),
|
|
216
|
+
`),n):(console.warn(`â ī¸ [Runtime Validation] Function "${e}" not found in schema`),console.log(" Available functions:",o.functions.map(r=>r.name)),n)}async function Rn(e,t,o){const n=await so(e);if(!n)return console.warn("â ī¸ [Runtime Validation] Runtime schema not available"),null;const s=e.metadata?.appVersion||"1.0.0";(n.appId!==e.appId||n.version!==s)&&console.warn(`â ī¸ [Runtime Validation] Schema version mismatch. Expected: ${e.appId}@${s}, Got: ${n.appId}@${n.version}`);const r=o?n.components.filter(i=>i.name===o):n.components,a=t?n.functions.filter(i=>i.name===t):n.functions;return{components:r.map(i=>({name:i.name,props:i.props})),functions:a.map(i=>({name:i.name,params:i.params,returns:i.returns}))}}const ht=Object.freeze(Object.defineProperty({__proto__:null,getRuntimeSchemaAsync:so,getValidationSchemaRuntime:Rn,parseJsonStringsInProps:qs,resolveType:Je,validateComponentPropsRuntime:Js,validateFunctionParamsRuntime:Gs},Symbol.toStringTag,{value:"Module"}));async function No(e,t,o){try{if(!await so(e))return console.warn("â ī¸ [Validation] Runtime schema not found. Make sure .autoui-runtime-schema.json is generated and accessible."),console.warn(" The schema is generated at build-time by the AutoUI plugin."),console.warn(" Check that the plugin is configured and the schema file exists."),null;console.log("đž [Validation] Using runtime schema (client-side validation, no backend needed)");const s=await Rn(e,t,o);return s?{components:s.components.map(r=>({name:r.name,props:Object.fromEntries(Object.entries(r.props).map(([a,i])=>[a,{type:"object",optional:!i.required}]))})),functions:s.functions.map(r=>({name:r.name,params:Object.fromEntries(Object.entries(r.params).map(([a,i])=>[a,{type:"object",optional:!i.required}])),returns:{type:"object"}}))}:null}catch(n){return console.warn("â ī¸ [Validation] Error getting validation schema:",n),null}}function kt(e,t,o=""){const n=[],s=o||"value";if(t.optional&&e==null)return console.log(` â [Validation] ${s} is optional and ${e===void 0?"undefined":"null"} - skipping validation`),n;if(!t.optional&&e==null){const r=`${s} is required but was ${e===void 0?"undefined":"null"}`;return n.push(r),console.log(` â [Validation] ${r}`),n}switch(console.log(` đ [Validation] Validating ${s} as type "${t.type}"`),t.type){case"string":if(typeof e!="string"){const r=`${s} must be a string, got ${typeof e}`;n.push(r),console.log(` â [Validation] ${r}`)}else console.log(` â [Validation] ${s} is a valid string`);break;case"number":if(typeof e!="number"||isNaN(e)){const r=`${s} must be a number, got ${typeof e}`;n.push(r),console.log(` â [Validation] ${r}`)}else console.log(` â [Validation] ${s} is a valid number: ${e}`);break;case"boolean":if(typeof e!="boolean"){const r=`${s} must be a boolean, got ${typeof e}`;n.push(r),console.log(` â [Validation] ${r}`)}else console.log(` â [Validation] ${s} is a valid boolean: ${e}`);break;case"array":if(Array.isArray(e))console.log(` â [Validation] ${s} is an array with ${e.length} item(s)`),t.items&&(console.log(` đ [Validation] Validating array items of ${s}...`),e.forEach((r,a)=>{const i=kt(r,t.items,`${o}[${a}]`);n.push(...i)}));else{const r=`${s} must be an array, got ${typeof e}`;n.push(r),console.log(` â [Validation] ${r}`)}break;case"object":if(typeof e!="object"||e===null||Array.isArray(e)){const r=`${s} must be an object, got ${typeof e}`;n.push(r),console.log(` â [Validation] ${r}`)}else t.properties?(console.log(` â [Validation] ${s} is an object, validating properties...`),Object.entries(t.properties).forEach(([r,a])=>{const i=e[r],l=o?`${o}.${r}`:r,c=kt(i,a,l);n.push(...c)})):console.log(` â [Validation] ${s} is an object (no properties schema to validate)`);break}return n}function Ys(e,t){const o=[];return console.log(`đ [Validation] Validating function "${t.name}" parameters:`,e),console.log("đ [Validation] Using schema:",JSON.stringify(t.params,null,2)),Object.entries(t.params).forEach(([n,s])=>{const r=e[n],a=kt(r,s,n);o.push(...a)}),o.length===0?console.log(`â
[Validation] Function "${t.name}" parameters validated successfully`):console.log(`â [Validation] Function "${t.name}" parameter validation found ${o.length} error(s):`,o),o}function Xs(e,t){const o=[];return console.log(`đ [Validation] Validating component "${t.name}" props:`,e),console.log("đ [Validation] Using schema:",JSON.stringify(t.props,null,2)),Object.entries(t.props).forEach(([n,s])=>{const r=e[n];console.log(`
|
|
217
|
+
đ [Validation] Validating prop "${n}":`),console.log(" Value:",r,`(type: ${typeof r})`),console.log(" Schema:",JSON.stringify(s,null,2));const a=kt(r,s,n);a.length===0?console.log(` â
[Validation] Prop "${n}" passed validation`):console.log(` â [Validation] Prop "${n}" failed validation:`,a),o.push(...a)}),console.log(`
|
|
218
|
+
đ [Validation] Component "${t.name}" validation summary:`),o.length===0?console.log(" â
All props validated successfully"):console.log(` â Found ${o.length} validation error(s):`,o),o}const Zs=async(e,t,o)=>{const n=await Ks(e,t,o),s=o.llm.proxyUrl??"https://autoui-proxy.onrender.com",r=await fetch(`${s}/chat/errorHandling`,{method:"POST",headers:{"Content-Type":"application/json","X-AUTOUI-APP-ID":o.appId,...o.llm.sharedSecret&&{"X-AUTOUI-SECRET":o.llm.sharedSecret}},body:JSON.stringify({messages:[{role:"user",content:n}],temperature:o.llm.temperature??.2,appId:o.appId})});if(!r.ok){console.error(`[Error Handling] API failed with status ${r.status}. Technical errors:`,e.failedStep.errors);let a="",i="complete";if(e.failedStep.step.type==="component"){const c=e.failedStep.step,u=o.components[c.name];if(u){a=u.prompt;const m=a.toLowerCase();m.includes("show")||m.includes("display")?i="show you":m.includes("load")||m.includes("fetch")?i="load":(m.includes("point")||m.includes("highlight"))&&(i="point to")}}else if(e.failedStep.step.type==="function"){const c=e.failedStep.step,u=o.functions[c.name];if(u){a=u.prompt;const m=a.toLowerCase();m.includes("fetch")||m.includes("load")||m.includes("get")?i="fetch":(m.includes("save")||m.includes("update"))&&(i="save")}}let l=`I couldn't ${i} ${a||"that"} for you. `;return e.failedStep.errorType==="validation"?e.failedStep.errors.some(u=>u.toLowerCase().includes("required")||u.toLowerCase().includes("missing"))?(l+="I need a bit more information to help you with that. ",a.toLowerCase().includes("point")||a.toLowerCase().includes("highlight")?l+="Could you tell me exactly which element you'd like me to point to? For example, you could say 'show me where the filters are' or 'point to the search button'.":a.toLowerCase().includes("show")||a.toLowerCase().includes("display")?l+="Could you be more specific about what you'd like to see? For example, you could say 'show me all tasks' or 'display my completed items'.":l+="Could you provide more details about what you're looking for?"):l+="The information provided doesn't quite match what I need. Could you try rephrasing your request?":l+="Could you try rephrasing your request or being more specific about what you'd like me to do?",{errorMessage:l,shouldRetry:!1}}try{const a=await r.json();if(console.log("Error handling response:",a),typeof a=="string")try{return JSON.parse(a)}catch{return{errorMessage:a,shouldRetry:!1}}return{newInstructionPlan:a.newInstructionPlan??null,errorMessage:a.errorMessage??null,shouldRetry:a.shouldRetry??!1,modifiedContext:a.modifiedContext??null,fallbackSuggestion:a.fallbackSuggestion??null}}catch(a){console.error("[Error Handling] Failed to parse response. Technical error:",a),console.error("[Error Handling] Original errors:",e.failedStep.errors);let i="",l="complete";if(e.failedStep.step.type==="component"){const u=e.failedStep.step,m=o.components[u.name];if(m){i=m.prompt;const f=i.toLowerCase();f.includes("show")||f.includes("display")?l="show you":f.includes("load")||f.includes("fetch")?l="load":(f.includes("point")||f.includes("highlight"))&&(l="point to")}}else if(e.failedStep.step.type==="function"){const u=e.failedStep.step,m=o.functions[u.name];if(m){i=m.prompt;const f=i.toLowerCase();f.includes("fetch")||f.includes("load")||f.includes("get")?l="fetch":(f.includes("save")||f.includes("update"))&&(l="save")}}let c=`I couldn't ${l} ${i||"that"} for you. `;return e.failedStep.errorType==="validation"&&e.failedStep.errors.some(u=>u.includes("required"))?(c+="I need a bit more information to help you with that. ",i.toLowerCase().includes("point")||i.toLowerCase().includes("highlight")?c+="Could you tell me exactly which element you'd like me to point to? For example, you could say 'show me where the filters are' or 'point to the search button'.":i.toLowerCase().includes("show")||i.toLowerCase().includes("display")?c+="Could you be more specific about what you'd like to see? For example, you could say 'show me all tasks' or 'display my completed items'.":c+="Could you provide more details about what you're looking for?"):c+="Could you try rephrasing your request or being more specific about what you'd like me to do?",{errorMessage:c,shouldRetry:!1}}};function Qs(e,t,o){const n=e.errorType,s=e.errors;let r="";if(n==="validation")if(s.some(i=>i.toLowerCase().includes("required")||i.toLowerCase().includes("missing"))){r=`The ${e.step.type==="component"?"component":"function"} needs some information that wasn't provided. `;const i=[];s.forEach(l=>{const c=l.match(/['"]([^'"]+)['"]/);c&&i.push(c[1])}),i.length>0&&(r+=`Specifically, information about: ${i.join(", ")}. `),r+="This information needs to be extracted from the user's request or provided explicitly."}else r=`The ${e.step.type==="component"?"component":"function"} received information that doesn't match what it expects. `,r+="This might be because the user's request wasn't specific enough or the information couldn't be extracted correctly.";else n==="runtime"?(r=`The ${e.step.type==="component"?"component":"function"} encountered a problem while trying to execute. `,r+="This could be because the requested data isn't available, the operation isn't possible right now, or there's a temporary issue."):n==="component_render"?(r="The component couldn't be displayed. ",r+="This might be because some required information is missing or the component needs different information than what was provided."):(r=`Something went wrong while trying to ${t||"complete the action"}. `,r+="The user's request might need to be more specific or rephrased.");return o&&(r+=`
|
|
179
219
|
|
|
180
|
-
The user's request was: "${o}". Consider this context when suggesting how they can rephrase or provide more information.`),
|
|
181
|
-
`):" (no params)";c.push(`${
|
|
220
|
+
The user's request was: "${o}". Consider this context when suggesting how they can rephrase or provide more information.`),r}async function Ks(e,t,o){const{userMessage:n,plan:s,executedSteps:r,failedStep:a}=e,i=new Set,l=new Set;s.steps.forEach(p=>{p.type==="function"?i.add(p.name):p.type==="component"&&l.add(p.name)});const c=[],u=[];i.forEach(p=>{const g=o.functions[p];if(g){const $=g.params?Object.entries(g.params).map(([b,C])=>` ${b}: ${C}`).join(`
|
|
221
|
+
`):" (no params)";c.push(`${p}:
|
|
182
222
|
${g.prompt}
|
|
183
223
|
Params:
|
|
184
|
-
${
|
|
185
|
-
`):" (no props)"
|
|
224
|
+
${$}`)}}),l.forEach(p=>{const g=o.components[p];if(g){const $=g.props?Object.entries(g.props).map(([C,d])=>` ${C}: ${d}`).join(`
|
|
225
|
+
`):" (no props)",b=g.callbacks?Object.entries(g.callbacks).map(([C,d])=>{if(typeof d=="function")return` ${C}: Callback handler`;const w=d,k="whenToUse"in w&&w.whenToUse?`
|
|
226
|
+
When to use: ${w.whenToUse}`:"",A="example"in w&&w.example?`
|
|
227
|
+
Example: ${w.example}`:"";return` ${C}: ${w.description}${k}${A}`}).join(`
|
|
228
|
+
`):" (no callbacks)";u.push(`${p}:
|
|
186
229
|
${g.prompt}
|
|
187
230
|
Props:
|
|
188
|
-
${
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
231
|
+
${$}
|
|
232
|
+
Available Callbacks:
|
|
233
|
+
${b}`)}});let m="",f="";if(a.step.type==="component"){const p=a.step;f=p.name;const g=o.components[p.name];g&&(m=g.prompt)}else if(a.step.type==="function"){const p=a.step;f=p.name;const g=o.functions[p.name];g&&(m=g.prompt)}else a.step.type==="text"&&(m="displaying text message",f="text step");const{getRuntimeSchemaAsync:h}=await Promise.resolve().then(()=>ht),T=await h(o),v=[];T&&(i.forEach(p=>{const g=T.functions.find($=>$.name===p);if(g){const $=Object.entries(g.params).filter(([d,w])=>w.required).map(([d,w])=>`${d} (${w.type})`),b=Object.entries(g.params).filter(([d,w])=>!w.required).map(([d,w])=>`${d} (${w.type})`);let C=`FUNCTION "${p}":`;$.length>0&&(C+=`
|
|
234
|
+
REQUIRED PARAMS: ${$.join(", ")}`),b.length>0&&(C+=`
|
|
235
|
+
OPTIONAL PARAMS: ${b.join(", ")}`),C+=`
|
|
236
|
+
RETURNS: ${g.returns.type}`,v.push(C)}}),l.forEach(p=>{const g=T.components.find(b=>b.name===p),$=o.components[p];if(g){const b=Object.entries(g.props).filter(([w,k])=>k.required).map(([w,k])=>`${w} (${k.type})`),C=Object.entries(g.props).filter(([w,k])=>!k.required).map(([w,k])=>`${w} (${k.type})`);let d=`COMPONENT "${p}":`;if(b.length>0&&(d+=`
|
|
237
|
+
REQUIRED PROPS: ${b.join(", ")}`),C.length>0&&(d+=`
|
|
238
|
+
OPTIONAL PROPS: ${C.join(", ")}`),$?.callbacks){const w=Object.keys($.callbacks);if(w.length>0){d+=`
|
|
239
|
+
AVAILABLE CALLBACKS: ${w.join(", ")}`;const k=Object.entries($.callbacks).map(([A,j])=>{if(typeof j=="function")return` ${A}: Callback handler`;const M=j,z="whenToUse"in M&&M.whenToUse?` (use when: ${M.whenToUse})`:"";return` ${A}: ${M.description}${z}`}).join(`
|
|
240
|
+
`);d+=`
|
|
241
|
+
Callback Details:
|
|
242
|
+
${k}`}}v.push(d)}}));const x=r.map((p,g)=>{let $=` ${g+1}. ${p.type}`;if(p.type==="function"){const b=p;$+=`: ${b.name}`,b.params&&Object.keys(b.params).length>0&&($+=` (params: ${JSON.stringify(b.params)})`)}else if(p.type==="component"){const b=p;$+=`: ${b.name}`,b.props&&Object.keys(b.props).length>0&&($+=` (props: ${JSON.stringify(b.props)})`)}else if(p.type==="text"){const b=p;$+=`: "${b.text.substring(0,50)}${b.text.length>50?"...":""}"`}return $}).join(`
|
|
243
|
+
`),y=Qs(a,m,n);return`You are an error handling assistant for an AutoUI application. A step in the instruction plan has failed.
|
|
195
244
|
|
|
196
245
|
USER'S ORIGINAL REQUEST: "${n}"
|
|
197
246
|
|
|
198
247
|
WHAT THE USER WAS TRYING TO DO:
|
|
199
|
-
The user wanted to: ${
|
|
200
|
-
Failed step: ${
|
|
248
|
+
The user wanted to: ${m||"perform an action"}
|
|
249
|
+
Failed step: ${f}
|
|
201
250
|
|
|
202
251
|
WHAT ACTUALLY HAPPENED:
|
|
203
252
|
${y}
|
|
204
253
|
|
|
205
254
|
ORIGINAL PLAN:
|
|
206
|
-
${JSON.stringify(
|
|
255
|
+
${JSON.stringify(s,null,2)}
|
|
207
256
|
|
|
208
|
-
SUCCESSFULLY EXECUTED STEPS (${
|
|
209
|
-
${
|
|
257
|
+
SUCCESSFULLY EXECUTED STEPS (${r.length}):
|
|
258
|
+
${x||" (none)"}
|
|
210
259
|
|
|
211
260
|
FAILED STEP DETAILS:
|
|
212
261
|
Type: ${a.step.type}
|
|
213
|
-
Name: ${
|
|
214
|
-
Description: ${
|
|
262
|
+
Name: ${f}
|
|
263
|
+
Description: ${m}
|
|
215
264
|
Step Details:
|
|
216
265
|
${JSON.stringify(a.step,null,2)}
|
|
217
266
|
|
|
218
267
|
ERROR TYPE: ${a.errorType}
|
|
219
268
|
SPECIFIC ERROR (for context only - DO NOT mention technical details to the user):
|
|
220
|
-
${a.errors.map(
|
|
269
|
+
${a.errors.map(p=>` - ${p}`).join(`
|
|
221
270
|
`)}
|
|
222
271
|
|
|
223
272
|
CURRENT CONTEXT:
|
|
@@ -238,7 +287,7 @@ ${u.length>0?u.join(`
|
|
|
238
287
|
`):" (none)"}
|
|
239
288
|
|
|
240
289
|
TYPE SCHEMAS (only for functions/components in the plan):
|
|
241
|
-
${
|
|
290
|
+
${v.length>0?v.join(`
|
|
242
291
|
|
|
243
292
|
`):" (none)"}
|
|
244
293
|
|
|
@@ -249,6 +298,9 @@ Analyze what went wrong and provide a helpful response to the user.
|
|
|
249
298
|
- Keeps all successfully executed steps (they should not be repeated)
|
|
250
299
|
- Modifies or replaces the failed step with corrected information
|
|
251
300
|
- Continues with the remaining steps if applicable
|
|
301
|
+
- For component steps: Use the "callbacks" field to specify callback handlers, or pass callback names in props
|
|
302
|
+
* Format: { "callbacks": { "onAction": "callbackName" } } or props: { "onAddToCart": "addToCart" }
|
|
303
|
+
* Use callback names from "Available Callbacks" listed in component configs above
|
|
252
304
|
- When providing a newInstructionPlan, ALSO provide a fallbackSuggestion message that will be shown if the retry also fails
|
|
253
305
|
|
|
254
306
|
2. If the error cannot be fixed by retrying, return an errorMessage and set shouldRetry to false.
|
|
@@ -299,8 +351,8 @@ Important:
|
|
|
299
351
|
- ALWAYS mention the specific action that failed in plain language
|
|
300
352
|
- ALWAYS include suggestions or questions in error messages - never just state what went wrong
|
|
301
353
|
- NEVER use technical terms - translate everything to user-friendly language
|
|
302
|
-
- Do not include steps that were already successfully executed in the newInstructionPlan`}async function
|
|
303
|
-
â [Parse Props] Found ${
|
|
304
|
-
Error ${
|
|
305
|
-
â [Component Props] Component "${e.name}" has ${
|
|
306
|
-
`)};function ii({config:e,theme:t,mode:o,setTheme:n,onError:
|
|
354
|
+
- Do not include steps that were already successfully executed in the newInstructionPlan`}async function Rt(e,t,o,n,s,r,a,i,l=0,c){console.log("Running instruction plan:",e,"userMessage: ",r);const u=i??{};console.log("đĻ [ExecutePlanSteps] Context vars:",Object.keys(u),"Values:",u);const m=[],f=2;for(let h=0;h<e.steps.length;h++){const T=e.steps[h];try{const v=await ei(T,u,t,o,n,s,r,a,e,h);if(m.push(T),v)break}catch(v){const x=v instanceof Error?v.message:String(v);console.error(`â [Step Execution] Step ${h+1} failed:`,x);const y=t.runtime?.errorHandling?.retryOnFail??!1,p=t.runtime?.errorHandling?.showToUser??!0;if(y&&l<f){let g="validation";x.includes("failed to render")?g="component_render":x.includes("validation failed")?g="validation":g="runtime";const $={step:T,stepIndex:h,errorType:g,errors:[x],context:{...u}};T.type==="component"&&"props"in T&&($.props=T.props);let b=null;try{if(b=await Zs({userMessage:r,prevMessagesForContext:a,plan:e,executedSteps:m,failedStep:$},u,t),b){const C=b;if(C.shouldRetry&&C.newInstructionPlan){console.log(`đ [Error Recovery] Retrying with modified plan (attempt ${l+1}/${f})`),C.modifiedContext&&Object.assign(u,C.modifiedContext);try{return await Rt(C.newInstructionPlan,t,o,n,s,r,a,u,l+1,C.fallbackSuggestion)}catch(d){if(C.fallbackSuggestion&&p)return console.log("â ī¸ [Error Recovery] Retry failed, using fallback suggestion"),s(w=>[...w,{id:`${Date.now()}-error-fallback`,role:"assistant",kind:"text",text:C.fallbackSuggestion}]),n(C.fallbackSuggestion),u;throw d}}else if(C.errorMessage&&p)return s(d=>[...d,{id:`${Date.now()}-error`,role:"assistant",kind:"text",text:C.errorMessage}]),n(C.errorMessage),u}}catch(C){console.error("Error handling API failed:",C)}if(b&&b.errorMessage&&p)return s(C=>[...C,{id:`${Date.now()}-error`,role:"assistant",kind:"text",text:b.errorMessage}]),n(b.errorMessage),u}if(p){const g=c||"I couldn't complete that action. Could you try rephrasing your request or providing more details?";s($=>[...$,{id:`${Date.now()}-error`,role:"assistant",kind:"text",text:g}]),n(g)}return u}}return u}async function ei(e,t,o,n,s,r,a,i,l,c){if(e.type==="function"){const m=o.functions[e.name];if(!m)throw new Error(`Unknown function: ${e.name}`);const f=e;let h={};f.params&&typeof f.params=="object"&&!Array.isArray(f.params)?h=f.params:Array.isArray(f.args)&&f.args.length===1&&typeof f.args[0]=="object"&&(h=f.args[0]),h=it(h,t,o),console.log("đ§ [ResolveProps] Function params after resolution:",h),e.params=h;const{getRuntimeSchemaAsync:T,validateFunctionParamsRuntime:v}=await Promise.resolve().then(()=>ht),x=await T(o);if(x){console.log(`đ [Runtime Validation] Validating function "${e.name}" params...`);const g=v(e.name,h,x);g.length>0&&console.warn(`â ī¸ [Runtime Validation] Function ${e.name} parameter validation errors:`,g)}else{console.log(`đ [Validation] Checking for validation schema for function: "${e.name}"`);const g=await No(o,e.name);if(g){const $=g.functions.find(b=>b.name===e.name);if($){console.log(`â
[Validation] Found schema for function "${e.name}", validating parameters...`);const b=Ys(h,$);b.length>0&&console.warn(`â ī¸ [Validation] Function ${e.name} parameter validation errors:`,b)}}}let y=await zs(m,e);if(m.canShareDataWithLLM&&e.hasToShareDataWithLLM){console.log(`đ [Extra Analysis] Function "${e.name}" returned data, starting LLM analysis...`);const g=e.assign,$=l.steps.indexOf(e),b=l.steps[$+1],C=await Us(o,y,g,e,$,b,a,i,t,l,n,s,r);return console.log("â
[Extra Analysis] Analysis complete, result:",C),C}else return e.assign&&(t[e.assign]=y,console.log(`đĻ [Context] Stored function output in context key: "${e.assign}"`)),m.canShareDataWithLLM?e.hasToShareDataWithLLM||console.log("âšī¸ [Extra Analysis] Skipped - step has hasToShareDataWithLLM=false"):console.log(`âšī¸ [Extra Analysis] Skipped - function "${e.name}" has canShareDataWithLLM=false`),!1}if(e.type==="component"){const m=o.components[e.name],f=e;let h={...e.props??{}};f.callbacks&&(console.log("đ [ComponentStep] Merging explicit callbacks:",f.callbacks),Object.assign(h,f.callbacks)),console.log("đ§ [ResolveProps] Before resolution - step.props:",e.props,"callbacks:",f.callbacks,"ctx:",t);let T=it(h,t,o,m);console.log("đ§ [ResolveProps] After resolution - props:",T);const{getRuntimeSchemaAsync:v,validateComponentPropsRuntime:x,parseJsonStringsInProps:y}=await Promise.resolve().then(()=>ht),p=await v(o);if(p){console.log(`đ [Runtime Validation] Validating component "${e.name}" props...`);const g=y(T,e.name,p);T=g.props,g.warnings.length>0&&g.warnings.forEach(C=>console.warn(`â ī¸ [Parse Props] ${C}`)),g.errors.length>0&&(console.error(`
|
|
355
|
+
â [Parse Props] Found ${g.errors.length} error(s) while parsing props for component "${e.name}":`),g.errors.forEach((C,d)=>{console.error(`
|
|
356
|
+
Error ${d+1}: ${C.message}`),console.error(` Prop: "${C.propName}"`),console.error(` Expected Type: ${C.expectedType}`),console.error(` Received Value: ${typeof C.receivedValue=="string"&&C.receivedValue.length>100?`"${C.receivedValue.substring(0,100)}..." (${C.receivedValue.length} chars)`:JSON.stringify(C.receivedValue)}`),C.suggestion&&console.error(` đĄ Suggestion: ${C.suggestion}`)}));const $=x(e.name,T,p),b=[...g.errors.map(C=>C.message),...$];if(b.length>0&&(console.error(`
|
|
357
|
+
â [Component Props] Component "${e.name}" has ${b.length} total error(s):`),b.forEach((d,w)=>{console.error(` ${w+1}. ${d}`)}),g.errors.some(d=>d.errorType==="type_mismatch"||d.errorType==="parsing_failed")||$.length>0)){console.error(`[Validation] Component "${e.name}" validation failed with errors:`,b);const d=`Component "${e.name}" validation failed: ${b.join("; ")}`;throw new Error(d)}}else{console.log(`đ [Validation] Checking for validation schema for component: "${e.name}"`);const g=await No(o,void 0,e.name);if(g){const $=g.components.find(b=>b.name===e.name);if($){console.log(`â
[Validation] Found schema for component "${e.name}", validating props...`);const b=Xs(T,$);b.length>0&&console.warn(`â ī¸ [Validation] Component ${e.name} prop validation errors:`,b)}}}try{const g=n(e.name,T);s(g),Vs(r,T,e)}catch(g){const $=`Component "${e.name}" failed to render: ${g instanceof Error?g.message:String(g)}`;throw console.error("[Component Render] Technical error:",$),new Error($)}return!1}if(e.type==="text"){const m=e;return r(f=>[...f,{id:`${Date.now()}-a`,role:"assistant",kind:"text",text:m.text}]),s(m.text??""),!1}return e}function ti(e){if(typeof e!="object"||e===null)throw new Error("Plan must be an object.");if(e.type!=="sequence")throw new Error('Plan.type must be "sequence".');if(!Array.isArray(e.steps))throw new Error("Plan.steps must be an array.");const t=new Set(["function","component","text"]);e.steps.forEach((o,n)=>{if(typeof o!="object"||o===null)throw new Error(`Step[${n}] must be an object.`);if(!t.has(o.type))throw new Error(`Step[${n}].type must be one of "function" | "component" | "text".`);if(o.type==="function"){if(typeof o.name!="string"||!o.name)throw new Error(`Step[${n}].name (function) must be a non-empty string.`);if(o.params!==void 0&&typeof o.params!="object")throw new Error(`Step[${n}].params (function) must be an object if provided.`);if(o.assign!==void 0&&typeof o.assign!="string")throw new Error(`Step[${n}].assign (function) must be a string if provided.`)}if(o.type==="component"){if(typeof o.name!="string"||!o.name)throw new Error(`Step[${n}].name (component) must be a non-empty string.`);if(o.props!==void 0&&typeof o.props!="object")throw new Error(`Step[${n}].props (component) must be an object if provided.`)}if(o.type==="text"&&typeof o.text!="string")throw new Error(`Step[${n}].text (text) must be a string.`)})}async function oi(e,t,o,n,s,r,a,i){return ti(e),await Rt(e,t,o,n,s,r,a)}const ni=(e,t,o)=>{let n=[];for(let s of e){if(s.kind=="ui"){const{t:r}=s.ui;let a=r=="component"?t(s.ui.name,s.ui.props):"unsuccessful rerender";a&&o(a),n.push({id:s.id,role:s.role,content:a})}s.kind=="text"&&(o(s.text),n.push({id:s.id,role:s.role,content:s.text}))}return n};function An(e){const t=I.useRef(null),o=I.useCallback(r=>{t.current=r},[]),n=I.useCallback((r,a)=>{const i=e?.components?.[r];if(!i?.callComponent)return;const l=i.callComponent,c={...i.defaults,...a};return S.jsx(l,{...c})},[e?.components]),s=I.useCallback(r=>{t.current?.(r)},[]);return{setUIRenderer:o,resolveComponent:n,setUI:s}}function ri(e,t){const{resolveComponent:o,setUI:n}=An(t),[s,r]=I.useState(()=>{try{const l=sessionStorage.getItem(e);return l?JSON.parse(l):[]}catch{return[]}}),a=I.useRef(!1);I.useEffect(()=>{a.current=!0},[]),I.useEffect(()=>{try{const l=sessionStorage.getItem(e);r(l?JSON.parse(l):[])}catch{r([])}},[e]);const i=I.useMemo(()=>ni(s,o,n),[s,o,n]);return I.useEffect(()=>{if(!a.current)return;const l=setTimeout(()=>{sessionStorage.setItem(e,JSON.stringify(s))},50);return()=>clearTimeout(l)},[s,e]),{messages:i,serializedMessages:s,setSerializedMessages:r}}const si=e=>{if(!e?.length)return"";const t=e.map((r,a)=>({m:r,index:a})),o=t.filter(({m:r})=>r.role==="user").slice(-8),n=t.filter(({m:r})=>r.role==="assistant").slice(-7);return[...o,...n].sort((r,a)=>r.index-a.index).map(({m:r},a)=>{const i=r.role==="user"?"from user":"from ai assistant";if(r.kind==="text")return`${a}. ${i} text: ${r.text}`;const l=r.ui;if(!l)return`${a}. ${i} ui`;if(l.t==="component"){const c=l.props?Object.keys(l.props).join(","):"",u=l.children?.length??0;return`${a}. ${i} ui: component ${l.name}`+(c?` props:${c}`:"")+(u?` children:${u}`:"")}return l.t==="fragment"?`${a}. ${i} ui: fragment children:${l.children?.length??0}`:`${a}. ${i} ui: text`}).join(`
|
|
358
|
+
`)};function ii({config:e,theme:t,mode:o,setTheme:n,onError:s,onClose:r,storageKey:a="autoui_chat_history",title:i,classNames:l,isOpen:c}){const{messages:u,serializedMessages:m,setSerializedMessages:f}=ri(a,e),{processMessage:h}=Ms(e),{resolveComponent:T,setUI:v}=An(e),[x,y]=I.useState(!1),p=I.useCallback(async w=>{if(!w.trim())return;const A={id:Date.now().toString(),role:"user",kind:"text",text:w,ts:Date.now()};f(j=>[...j,A]);try{y(!0);let j=m?si(m):"";const M=await h(w,j);await oi(M,e,T,v,f,w,j,{validate:!0})}catch(j){console.error("[Chat] Error during plan execution:",j);const M="I encountered an issue while processing your request. Could you try rephrasing it?";f(z=>[...z,{id:`${Date.now()}-e`,role:"assistant",kind:"text",text:`â ī¸ ${M}`,ts:Date.now()}]),s?.(j)}finally{y(!1)}},[h,e,T,v,f,s]),g=I.useCallback(()=>{f([]),sessionStorage.removeItem(a)},[f,a]),$=I.useCallback(()=>({onSend:p,disabled:x}),[p,x]),b=I.useCallback(()=>({title:"AutoUI Chat",onClose:r}),[r]),C=I.useCallback(()=>({messages:u}),[u]);return I.useMemo(()=>({config:e,isOpen:c,title:i,theme:t,mode:o,classNames:l,messages:u,isLoading:x,setTheme:n,handleSend:p,onClose:r,handleClear:g,getChatInputProps:$,getChatHeaderProps:b,getMessageListProps:C}),[e,c,i,l,u,x,p,r,g,$,b,C])}const ai=()=>{const{title:e,classNames:t,onClose:o,closeIcon:n}=Ge();return S.jsxs("header",{role:"header",className:ye("autoui-chat-header",t?.header),children:[S.jsx("h2",{role:"title",className:ye("autoui-chat-title",t?.title),children:e}),o&&S.jsx("button",{role:"closeButton",className:ye("autoui-chat-closebtn",t?.closeButton),onClick:o,children:n??S.jsx("img",{src:Do,alt:"Open char",width:20,height:20,style:{filter:"var(--icon-filter-text)"}})})]})},zo="theme-mode",li=()=>{const e=()=>window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",t=()=>typeof window>"u"?"auto":localStorage.getItem(zo)||"auto",[o,n]=I.useState(t),[s,r]=I.useState(o==="auto"?e():o),a=I.useCallback(i=>{const l=i==="auto"?e():i;n(i),r(l),localStorage.setItem(zo,i),document.documentElement.dataset.theme=l},[]);return I.useEffect(()=>{a(o)},[o,a]),I.useEffect(()=>{if(o!=="auto")return;const i=window.matchMedia("(prefers-color-scheme: dark)"),l=()=>{const c=i.matches?"dark":"light";r(c),document.documentElement.dataset.theme=c};return i.addEventListener("change",l),()=>i.removeEventListener("change",l)},[o]),{mode:o,theme:s,setTheme:a}},On=I.memo(({config:e,title:t="AutoUI Chat",isOpen:o=!0,classNames:n,onClose:s,onError:r,closeIcon:a})=>{const{theme:i,mode:l,setTheme:c}=li(),u=ii({config:e,title:t,isOpen:o,classNames:n,onClose:s,theme:i,mode:l,setTheme:c,onError:r});return o?S.jsx(Bn,{config:e,value:u,children:S.jsxs("section",{role:"base",className:ye("autoui-chat",n?.base),"aria-label":"Chat",children:[S.jsx(ai,{}),S.jsx(Os,{}),S.jsx(nr,{})]})}):null}),ci=Object.freeze(Object.defineProperty({__proto__:null,Chat:On},Symbol.toStringTag,{value:"Module"})),jn=I.createContext(void 0),ui=({config:e,children:t})=>{const[o,n]=I.useState({isOpen:!1}),s=I.useMemo(()=>({value:o,setValue:n,config:e}),[o,n,e]);return S.jsx(jn.Provider,{value:s,children:t})},di=()=>{const e=I.useContext(jn);if(!e)throw new Error("useModalChatContext must be used within a ModalChatProvider");return e},pi=({onOpenChange:e,isOpen:t,className:o})=>{const n=t??!0,s=n?Do:Ho;return S.jsx("button",{onClick:e,className:Oe("autoui-chat-open-btn",o),children:S.jsx("img",{src:s,alt:n?"Close chat":"Open chat",width:24,height:24,style:{filter:"var(--icon-filter-text)"}})})},fi=I.lazy(()=>Promise.resolve().then(()=>ci).then(e=>({default:e.Chat}))),mi=I.memo(({config:e,portalContainer:t})=>S.jsx(ui,{config:e,children:S.jsx(hi,{config:e,portalContainer:t})})),hi=({config:e,portalContainer:t})=>{const{value:o,setValue:n}=di(),{isOpen:s}=o,r=()=>n(l=>({...l,isOpen:!1})),a=()=>n(l=>({...l,isOpen:!l.isOpen})),i=t??document.body;return S.jsxs(S.Fragment,{children:[S.jsx(pi,{onOpenChange:a,isOpen:s}),s&&Fo.createPortal(S.jsx("div",{className:"autoui-chat-portal",children:S.jsx("div",{className:"autoui-chat-wrapper",children:S.jsx(fi,{config:e,...o,onClose:r})})}),i)]})};function gi(e){}function yi(e){}exports.Chat=On;exports.ModalChat=mi;exports.autouiRegisterComponentPropsSchema=gi;exports.autouiRegisterFunctionParamsSchema=yi;
|