@astermind/chatbot-template 2.2.72 → 2.3.4

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.
@@ -1,4 +1,4 @@
1
- var AsterMindChatbot=function(e){"use strict";var t="undefined"!=typeof document?document.currentScript:null;function n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var r,a,o={exports:{}},i={};function s(){if(r)return i;r=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),h=Symbol.iterator;var p={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},m=Object.assign,g={};function y(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||p}function v(){}function b(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||p}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},v.prototype=y.prototype;var w=b.prototype=new v;w.constructor=b,m(w,y.prototype),w.isPureReactComponent=!0;var S=Array.isArray,k=Object.prototype.hasOwnProperty,x={current:null},C={key:!0,ref:!0,__self:!0,__source:!0};function E(t,n,r){var a,o={},i=null,s=null;if(null!=n)for(a in void 0!==n.ref&&(s=n.ref),void 0!==n.key&&(i=""+n.key),n)k.call(n,a)&&!C.hasOwnProperty(a)&&(o[a]=n[a]);var l=arguments.length-2;if(1===l)o.children=r;else if(1<l){for(var c=Array(l),u=0;u<l;u++)c[u]=arguments[u+2];o.children=c}if(t&&t.defaultProps)for(a in l=t.defaultProps)void 0===o[a]&&(o[a]=l[a]);return{$$typeof:e,type:t,key:i,ref:s,props:o,_owner:x.current}}function _(t){return"object"==typeof t&&null!==t&&t.$$typeof===e}var M=/\/+/g;function R(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(e){return t[e]})}(""+e.key):t.toString(36)}function A(n,r,a,o,i){var s=typeof n;"undefined"!==s&&"boolean"!==s||(n=null);var l=!1;if(null===n)l=!0;else switch(s){case"string":case"number":l=!0;break;case"object":switch(n.$$typeof){case e:case t:l=!0}}if(l)return i=i(l=n),n=""===o?"."+R(l,0):o,S(i)?(a="",null!=n&&(a=n.replace(M,"$&/")+"/"),A(i,r,a,"",function(e){return e})):null!=i&&(_(i)&&(i=function(t,n){return{$$typeof:e,type:t.type,key:n,ref:t.ref,props:t.props,_owner:t._owner}}(i,a+(!i.key||l&&l.key===i.key?"":(""+i.key).replace(M,"$&/")+"/")+n)),r.push(i)),1;if(l=0,o=""===o?".":o+":",S(n))for(var c=0;c<n.length;c++){var u=o+R(s=n[c],c);l+=A(s,r,a,u,i)}else if(u=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=h&&e[h]||e["@@iterator"])?e:null}(n),"function"==typeof u)for(n=u.call(n),c=0;!(s=n.next()).done;)l+=A(s=s.value,r,a,u=o+R(s,c++),i);else if("object"===s)throw r=String(n),Error("Objects are not valid as a React child (found: "+("[object Object]"===r?"object with keys {"+Object.keys(n).join(", ")+"}":r)+"). If you meant to render a collection of children, use an array instead.");return l}function I(e,t,n){if(null==e)return e;var r=[],a=0;return A(e,r,"","",function(e){return t.call(n,e,a++)}),r}function P(e){if(-1===e._status){var t=e._result;(t=t()).then(function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)},function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)}),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var L={current:null},T={transition:null},D={ReactCurrentDispatcher:L,ReactCurrentBatchConfig:T,ReactCurrentOwner:x};function N(){throw Error("act(...) is not supported in production builds of React.")}return i.Children={map:I,forEach:function(e,t,n){I(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return I(e,function(){t++}),t},toArray:function(e){return I(e,function(e){return e})||[]},only:function(e){if(!_(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},i.Component=y,i.Fragment=n,i.Profiler=o,i.PureComponent=b,i.StrictMode=a,i.Suspense=u,i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=D,i.act=N,i.cloneElement=function(t,n,r){if(null==t)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+t+".");var a=m({},t.props),o=t.key,i=t.ref,s=t._owner;if(null!=n){if(void 0!==n.ref&&(i=n.ref,s=x.current),void 0!==n.key&&(o=""+n.key),t.type&&t.type.defaultProps)var l=t.type.defaultProps;for(c in n)k.call(n,c)&&!C.hasOwnProperty(c)&&(a[c]=void 0===n[c]&&void 0!==l?l[c]:n[c])}var c=arguments.length-2;if(1===c)a.children=r;else if(1<c){l=Array(c);for(var u=0;u<c;u++)l[u]=arguments[u+2];a.children=l}return{$$typeof:e,type:t.type,key:o,ref:i,props:a,_owner:s}},i.createContext=function(e){return(e={$$typeof:l,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null}).Provider={$$typeof:s,_context:e},e.Consumer=e},i.createElement=E,i.createFactory=function(e){var t=E.bind(null,e);return t.type=e,t},i.createRef=function(){return{current:null}},i.forwardRef=function(e){return{$$typeof:c,render:e}},i.isValidElement=_,i.lazy=function(e){return{$$typeof:f,_payload:{_status:-1,_result:e},_init:P}},i.memo=function(e,t){return{$$typeof:d,type:e,compare:void 0===t?null:t}},i.startTransition=function(e){var t=T.transition;T.transition={};try{e()}finally{T.transition=t}},i.unstable_act=N,i.useCallback=function(e,t){return L.current.useCallback(e,t)},i.useContext=function(e){return L.current.useContext(e)},i.useDebugValue=function(){},i.useDeferredValue=function(e){return L.current.useDeferredValue(e)},i.useEffect=function(e,t){return L.current.useEffect(e,t)},i.useId=function(){return L.current.useId()},i.useImperativeHandle=function(e,t,n){return L.current.useImperativeHandle(e,t,n)},i.useInsertionEffect=function(e,t){return L.current.useInsertionEffect(e,t)},i.useLayoutEffect=function(e,t){return L.current.useLayoutEffect(e,t)},i.useMemo=function(e,t){return L.current.useMemo(e,t)},i.useReducer=function(e,t,n){return L.current.useReducer(e,t,n)},i.useRef=function(e){return L.current.useRef(e)},i.useState=function(e){return L.current.useState(e)},i.useSyncExternalStore=function(e,t,n){return L.current.useSyncExternalStore(e,t,n)},i.useTransition=function(){return L.current.useTransition()},i.version="18.3.1",i}function l(){return a||(a=1,o.exports=s()),o.exports}var c,u,d,f,h,p=l(),m=n(p),g={},y={exports:{}},v={},b={exports:{}},w={};function S(){return u||(u=1,b.exports=(c||(c=1,function(e){function t(e,t){var n=e.length;e.push(t);e:for(;0<n;){var r=n-1>>>1,o=e[r];if(!(0<a(o,t)))break e;e[r]=t,e[n]=o,n=r}}function n(e){return 0===e.length?null:e[0]}function r(e){if(0===e.length)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;e:for(var r=0,o=e.length,i=o>>>1;r<i;){var s=2*(r+1)-1,l=e[s],c=s+1,u=e[c];if(0>a(l,n))c<o&&0>a(u,l)?(e[r]=u,e[c]=n,r=c):(e[r]=l,e[s]=n,r=s);else{if(!(c<o&&0>a(u,n)))break e;e[r]=u,e[c]=n,r=c}}}return t}function a(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}if("object"==typeof performance&&"function"==typeof performance.now){var o=performance;e.unstable_now=function(){return o.now()}}else{var i=Date,s=i.now();e.unstable_now=function(){return i.now()-s}}var l=[],c=[],u=1,d=null,f=3,h=!1,p=!1,m=!1,g="function"==typeof setTimeout?setTimeout:null,y="function"==typeof clearTimeout?clearTimeout:null,v="undefined"!=typeof setImmediate?setImmediate:null;function b(e){for(var a=n(c);null!==a;){if(null===a.callback)r(c);else{if(!(a.startTime<=e))break;r(c),a.sortIndex=a.expirationTime,t(l,a)}a=n(c)}}function w(e){if(m=!1,b(e),!p)if(null!==n(l))p=!0,L(S);else{var t=n(c);null!==t&&T(w,t.startTime-e)}}function S(t,a){p=!1,m&&(m=!1,y(E),E=-1),h=!0;var o=f;try{for(b(a),d=n(l);null!==d&&(!(d.expirationTime>a)||t&&!R());){var i=d.callback;if("function"==typeof i){d.callback=null,f=d.priorityLevel;var s=i(d.expirationTime<=a);a=e.unstable_now(),"function"==typeof s?d.callback=s:d===n(l)&&r(l),b(a)}else r(l);d=n(l)}if(null!==d)var u=!0;else{var g=n(c);null!==g&&T(w,g.startTime-a),u=!1}return u}finally{d=null,f=o,h=!1}}"undefined"!=typeof navigator&&void 0!==navigator.scheduling&&void 0!==navigator.scheduling.isInputPending&&navigator.scheduling.isInputPending.bind(navigator.scheduling);var k,x=!1,C=null,E=-1,_=5,M=-1;function R(){return!(e.unstable_now()-M<_)}function A(){if(null!==C){var t=e.unstable_now();M=t;var n=!0;try{n=C(!0,t)}finally{n?k():(x=!1,C=null)}}else x=!1}if("function"==typeof v)k=function(){v(A)};else if("undefined"!=typeof MessageChannel){var I=new MessageChannel,P=I.port2;I.port1.onmessage=A,k=function(){P.postMessage(null)}}else k=function(){g(A,0)};function L(e){C=e,x||(x=!0,k())}function T(t,n){E=g(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_continueExecution=function(){p||h||(p=!0,L(S))},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):_=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_getFirstCallbackNode=function(){return n(l)},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,a,o){var i=e.unstable_now();switch(o="object"==typeof o&&null!==o&&"number"==typeof(o=o.delay)&&0<o?i+o:i,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return r={id:u++,callback:a,priorityLevel:r,startTime:o,expirationTime:s=o+s,sortIndex:-1},o>i?(r.sortIndex=o,t(c,r),null===n(l)&&r===n(c)&&(m?(y(E),E=-1):m=!0,T(w,o-i))):(r.sortIndex=s,t(l,r),p||h||(p=!0,L(S))),r},e.unstable_shouldYield=R,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}}(w)),w)),b.exports}
1
+ var AsterMindChatbot=function(e){"use strict";var t="undefined"!=typeof document?document.currentScript:null;function n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var r,a,o={exports:{}},i={};function s(){if(r)return i;r=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),h=Symbol.iterator;var p={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},m=Object.assign,g={};function y(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||p}function v(){}function b(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||p}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},v.prototype=y.prototype;var w=b.prototype=new v;w.constructor=b,m(w,y.prototype),w.isPureReactComponent=!0;var S=Array.isArray,k=Object.prototype.hasOwnProperty,x={current:null},C={key:!0,ref:!0,__self:!0,__source:!0};function E(t,n,r){var a,o={},i=null,s=null;if(null!=n)for(a in void 0!==n.ref&&(s=n.ref),void 0!==n.key&&(i=""+n.key),n)k.call(n,a)&&!C.hasOwnProperty(a)&&(o[a]=n[a]);var l=arguments.length-2;if(1===l)o.children=r;else if(1<l){for(var c=Array(l),u=0;u<l;u++)c[u]=arguments[u+2];o.children=c}if(t&&t.defaultProps)for(a in l=t.defaultProps)void 0===o[a]&&(o[a]=l[a]);return{$$typeof:e,type:t,key:i,ref:s,props:o,_owner:x.current}}function _(t){return"object"==typeof t&&null!==t&&t.$$typeof===e}var M=/\/+/g;function R(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(e){return t[e]})}(""+e.key):t.toString(36)}function A(n,r,a,o,i){var s=typeof n;"undefined"!==s&&"boolean"!==s||(n=null);var l=!1;if(null===n)l=!0;else switch(s){case"string":case"number":l=!0;break;case"object":switch(n.$$typeof){case e:case t:l=!0}}if(l)return i=i(l=n),n=""===o?"."+R(l,0):o,S(i)?(a="",null!=n&&(a=n.replace(M,"$&/")+"/"),A(i,r,a,"",function(e){return e})):null!=i&&(_(i)&&(i=function(t,n){return{$$typeof:e,type:t.type,key:n,ref:t.ref,props:t.props,_owner:t._owner}}(i,a+(!i.key||l&&l.key===i.key?"":(""+i.key).replace(M,"$&/")+"/")+n)),r.push(i)),1;if(l=0,o=""===o?".":o+":",S(n))for(var c=0;c<n.length;c++){var u=o+R(s=n[c],c);l+=A(s,r,a,u,i)}else if(u=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=h&&e[h]||e["@@iterator"])?e:null}(n),"function"==typeof u)for(n=u.call(n),c=0;!(s=n.next()).done;)l+=A(s=s.value,r,a,u=o+R(s,c++),i);else if("object"===s)throw r=String(n),Error("Objects are not valid as a React child (found: "+("[object Object]"===r?"object with keys {"+Object.keys(n).join(", ")+"}":r)+"). If you meant to render a collection of children, use an array instead.");return l}function I(e,t,n){if(null==e)return e;var r=[],a=0;return A(e,r,"","",function(e){return t.call(n,e,a++)}),r}function P(e){if(-1===e._status){var t=e._result;(t=t()).then(function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)},function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)}),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var T={current:null},L={transition:null},N={ReactCurrentDispatcher:T,ReactCurrentBatchConfig:L,ReactCurrentOwner:x};function D(){throw Error("act(...) is not supported in production builds of React.")}return i.Children={map:I,forEach:function(e,t,n){I(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return I(e,function(){t++}),t},toArray:function(e){return I(e,function(e){return e})||[]},only:function(e){if(!_(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},i.Component=y,i.Fragment=n,i.Profiler=o,i.PureComponent=b,i.StrictMode=a,i.Suspense=u,i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=N,i.act=D,i.cloneElement=function(t,n,r){if(null==t)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+t+".");var a=m({},t.props),o=t.key,i=t.ref,s=t._owner;if(null!=n){if(void 0!==n.ref&&(i=n.ref,s=x.current),void 0!==n.key&&(o=""+n.key),t.type&&t.type.defaultProps)var l=t.type.defaultProps;for(c in n)k.call(n,c)&&!C.hasOwnProperty(c)&&(a[c]=void 0===n[c]&&void 0!==l?l[c]:n[c])}var c=arguments.length-2;if(1===c)a.children=r;else if(1<c){l=Array(c);for(var u=0;u<c;u++)l[u]=arguments[u+2];a.children=l}return{$$typeof:e,type:t.type,key:o,ref:i,props:a,_owner:s}},i.createContext=function(e){return(e={$$typeof:l,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null}).Provider={$$typeof:s,_context:e},e.Consumer=e},i.createElement=E,i.createFactory=function(e){var t=E.bind(null,e);return t.type=e,t},i.createRef=function(){return{current:null}},i.forwardRef=function(e){return{$$typeof:c,render:e}},i.isValidElement=_,i.lazy=function(e){return{$$typeof:f,_payload:{_status:-1,_result:e},_init:P}},i.memo=function(e,t){return{$$typeof:d,type:e,compare:void 0===t?null:t}},i.startTransition=function(e){var t=L.transition;L.transition={};try{e()}finally{L.transition=t}},i.unstable_act=D,i.useCallback=function(e,t){return T.current.useCallback(e,t)},i.useContext=function(e){return T.current.useContext(e)},i.useDebugValue=function(){},i.useDeferredValue=function(e){return T.current.useDeferredValue(e)},i.useEffect=function(e,t){return T.current.useEffect(e,t)},i.useId=function(){return T.current.useId()},i.useImperativeHandle=function(e,t,n){return T.current.useImperativeHandle(e,t,n)},i.useInsertionEffect=function(e,t){return T.current.useInsertionEffect(e,t)},i.useLayoutEffect=function(e,t){return T.current.useLayoutEffect(e,t)},i.useMemo=function(e,t){return T.current.useMemo(e,t)},i.useReducer=function(e,t,n){return T.current.useReducer(e,t,n)},i.useRef=function(e){return T.current.useRef(e)},i.useState=function(e){return T.current.useState(e)},i.useSyncExternalStore=function(e,t,n){return T.current.useSyncExternalStore(e,t,n)},i.useTransition=function(){return T.current.useTransition()},i.version="18.3.1",i}function l(){return a||(a=1,o.exports=s()),o.exports}var c,u,d,f,h,p=l(),m=n(p),g={},y={exports:{}},v={},b={exports:{}},w={};function S(){return u||(u=1,b.exports=(c||(c=1,function(e){function t(e,t){var n=e.length;e.push(t);e:for(;0<n;){var r=n-1>>>1,o=e[r];if(!(0<a(o,t)))break e;e[r]=t,e[n]=o,n=r}}function n(e){return 0===e.length?null:e[0]}function r(e){if(0===e.length)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;e:for(var r=0,o=e.length,i=o>>>1;r<i;){var s=2*(r+1)-1,l=e[s],c=s+1,u=e[c];if(0>a(l,n))c<o&&0>a(u,l)?(e[r]=u,e[c]=n,r=c):(e[r]=l,e[s]=n,r=s);else{if(!(c<o&&0>a(u,n)))break e;e[r]=u,e[c]=n,r=c}}}return t}function a(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}if("object"==typeof performance&&"function"==typeof performance.now){var o=performance;e.unstable_now=function(){return o.now()}}else{var i=Date,s=i.now();e.unstable_now=function(){return i.now()-s}}var l=[],c=[],u=1,d=null,f=3,h=!1,p=!1,m=!1,g="function"==typeof setTimeout?setTimeout:null,y="function"==typeof clearTimeout?clearTimeout:null,v="undefined"!=typeof setImmediate?setImmediate:null;function b(e){for(var a=n(c);null!==a;){if(null===a.callback)r(c);else{if(!(a.startTime<=e))break;r(c),a.sortIndex=a.expirationTime,t(l,a)}a=n(c)}}function w(e){if(m=!1,b(e),!p)if(null!==n(l))p=!0,T(S);else{var t=n(c);null!==t&&L(w,t.startTime-e)}}function S(t,a){p=!1,m&&(m=!1,y(E),E=-1),h=!0;var o=f;try{for(b(a),d=n(l);null!==d&&(!(d.expirationTime>a)||t&&!R());){var i=d.callback;if("function"==typeof i){d.callback=null,f=d.priorityLevel;var s=i(d.expirationTime<=a);a=e.unstable_now(),"function"==typeof s?d.callback=s:d===n(l)&&r(l),b(a)}else r(l);d=n(l)}if(null!==d)var u=!0;else{var g=n(c);null!==g&&L(w,g.startTime-a),u=!1}return u}finally{d=null,f=o,h=!1}}"undefined"!=typeof navigator&&void 0!==navigator.scheduling&&void 0!==navigator.scheduling.isInputPending&&navigator.scheduling.isInputPending.bind(navigator.scheduling);var k,x=!1,C=null,E=-1,_=5,M=-1;function R(){return!(e.unstable_now()-M<_)}function A(){if(null!==C){var t=e.unstable_now();M=t;var n=!0;try{n=C(!0,t)}finally{n?k():(x=!1,C=null)}}else x=!1}if("function"==typeof v)k=function(){v(A)};else if("undefined"!=typeof MessageChannel){var I=new MessageChannel,P=I.port2;I.port1.onmessage=A,k=function(){P.postMessage(null)}}else k=function(){g(A,0)};function T(e){C=e,x||(x=!0,k())}function L(t,n){E=g(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_continueExecution=function(){p||h||(p=!0,T(S))},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):_=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_getFirstCallbackNode=function(){return n(l)},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,a,o){var i=e.unstable_now();switch(o="object"==typeof o&&null!==o&&"number"==typeof(o=o.delay)&&0<o?i+o:i,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return r={id:u++,callback:a,priorityLevel:r,startTime:o,expirationTime:s=o+s,sortIndex:-1},o>i?(r.sortIndex=o,t(c,r),null===n(l)&&r===n(c)&&(m?(y(E),E=-1):m=!0,L(w,o-i))):(r.sortIndex=s,t(l,r),p||h||(p=!0,T(S))),r},e.unstable_shouldYield=R,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}}(w)),w)),b.exports}
2
2
  /**
3
3
  * @license React
4
4
  * react-dom.production.min.js
@@ -7,5 +7,5 @@ var AsterMindChatbot=function(e){"use strict";var t="undefined"!=typeof document
7
7
  *
8
8
  * This source code is licensed under the MIT license found in the
9
9
  * LICENSE file in the root directory of this source tree.
10
- */function k(){if(d)return v;d=1;var e=l(),t=S();function n(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,a={};function o(e,t){i(e,t),i(e+"Capture",t)}function i(e,t){for(a[e]=t,e=0;e<t.length;e++)r.add(t[e])}var s=!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement),c=Object.prototype.hasOwnProperty,u=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,f={},h={};function p(e,t,n,r,a,o,i){this.acceptsBooleans=2===t||3===t||4===t,this.attributeName=r,this.attributeNamespace=a,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=i}var m={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){m[e]=new p(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];m[t]=new p(t,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){m[e]=new p(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){m[e]=new p(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){m[e]=new p(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){m[e]=new p(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){m[e]=new p(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){m[e]=new p(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){m[e]=new p(e,5,!1,e.toLowerCase(),null,!1,!1)});var g=/[\-:]([a-z])/g;function y(e){return e[1].toUpperCase()}function b(e,t,n,r){var a=m.hasOwnProperty(t)?m[t]:null;(null!==a?0!==a.type:r||!(2<t.length)||"o"!==t[0]&&"O"!==t[0]||"n"!==t[1]&&"N"!==t[1])&&(function(e,t,n,r){if(null==t||function(e,t,n,r){if(null!==n&&0===n.type)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return!r&&(null!==n?!n.acceptsBooleans:"data-"!==(e=e.toLowerCase().slice(0,5))&&"aria-"!==e);default:return!1}}(e,t,n,r))return!0;if(r)return!1;if(null!==n)switch(n.type){case 3:return!t;case 4:return!1===t;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}(t,n,a,r)&&(n=null),r||null===a?function(e){return!!c.call(h,e)||!c.call(f,e)&&(u.test(e)?h[e]=!0:(f[e]=!0,!1))}(t)&&(null===n?e.removeAttribute(t):e.setAttribute(t,""+n)):a.mustUseProperty?e[a.propertyName]=null===n?3!==a.type&&"":n:(t=a.attributeName,r=a.attributeNamespace,null===n?e.removeAttribute(t):(n=3===(a=a.type)||4===a&&!0===n?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(g,y);m[t]=new p(t,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(g,y);m[t]=new p(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(g,y);m[t]=new p(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){m[e]=new p(e,1,!1,e.toLowerCase(),null,!1,!1)}),m.xlinkHref=new p("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){m[e]=new p(e,1,!1,e.toLowerCase(),null,!0,!0)});var w=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,k=Symbol.for("react.element"),x=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),_=Symbol.for("react.profiler"),M=Symbol.for("react.provider"),R=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),T=Symbol.for("react.lazy"),D=Symbol.for("react.offscreen"),N=Symbol.iterator;function z(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=N&&e[N]||e["@@iterator"])?e:null}var F,O=Object.assign;function $(e){if(void 0===F)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);F=t&&t[1]||""}return"\n"+F+e}var j=!1;function U(e,t){if(!e||j)return"";j=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(t,[])}catch(e){var r=e}Reflect.construct(e,[],t)}else{try{t.call()}catch(e){r=e}e.call(t.prototype)}else{try{throw Error()}catch(e){r=e}e()}}catch(t){if(t&&r&&"string"==typeof t.stack){for(var a=t.stack.split("\n"),o=r.stack.split("\n"),i=a.length-1,s=o.length-1;1<=i&&0<=s&&a[i]!==o[s];)s--;for(;1<=i&&0<=s;i--,s--)if(a[i]!==o[s]){if(1!==i||1!==s)do{if(i--,0>--s||a[i]!==o[s]){var l="\n"+a[i].replace(" at new "," at ");return e.displayName&&l.includes("<anonymous>")&&(l=l.replace("<anonymous>",e.displayName)),l}}while(1<=i&&0<=s);break}}}finally{j=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?$(e):""}function B(e){switch(e.tag){case 5:return $(e.type);case 16:return $("Lazy");case 13:return $("Suspense");case 19:return $("SuspenseList");case 0:case 2:case 15:return e=U(e.type,!1);case 11:return e=U(e.type.render,!1);case 1:return e=U(e.type,!0);default:return""}}function W(e){if(null==e)return null;if("function"==typeof e)return e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case C:return"Fragment";case x:return"Portal";case _:return"Profiler";case E:return"StrictMode";case I:return"Suspense";case P:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case R:return(e.displayName||"Context")+".Consumer";case M:return(e._context.displayName||"Context")+".Provider";case A:var t=e.render;return(e=e.displayName)||(e=""!==(e=t.displayName||t.name||"")?"ForwardRef("+e+")":"ForwardRef"),e;case L:return null!==(t=e.displayName||null)?t:W(e.type)||"Memo";case T:t=e._payload,e=e._init;try{return W(e(t))}catch(e){}}return null}function V(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=(e=t.render).displayName||e.name||"",t.displayName||(""!==e?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return W(t);case 8:return t===E?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if("function"==typeof t)return t.displayName||t.name||null;if("string"==typeof t)return t}return null}function H(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":case"object":return e;default:return""}}function K(e){var t=e.type;return(e=e.nodeName)&&"input"===e.toLowerCase()&&("checkbox"===t||"radio"===t)}function q(e){e._valueTracker||(e._valueTracker=function(e){var t=K(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&void 0!==n&&"function"==typeof n.get&&"function"==typeof n.set){var a=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return a.call(this)},set:function(e){r=""+e,o.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(e){r=""+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}(e))}function G(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=K(e)?e.checked?"true":"false":e.value),(e=r)!==n&&(t.setValue(e),!0)}function Q(e){if(void 0===(e=e||("undefined"!=typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}}function Y(e,t){var n=t.checked;return O({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:null!=n?n:e._wrapperState.initialChecked})}function X(e,t){var n=null==t.defaultValue?"":t.defaultValue,r=null!=t.checked?t.checked:t.defaultChecked;n=H(null!=t.value?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:"checkbox"===t.type||"radio"===t.type?null!=t.checked:null!=t.value}}function J(e,t){null!=(t=t.checked)&&b(e,"checked",t,!1)}function Z(e,t){J(e,t);var n=H(t.value),r=t.type;if(null!=n)"number"===r?(0===n&&""===e.value||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if("submit"===r||"reset"===r)return void e.removeAttribute("value");t.hasOwnProperty("value")?te(e,t.type,n):t.hasOwnProperty("defaultValue")&&te(e,t.type,H(t.defaultValue)),null==t.checked&&null!=t.defaultChecked&&(e.defaultChecked=!!t.defaultChecked)}function ee(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!("submit"!==r&&"reset"!==r||void 0!==t.value&&null!==t.value))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}""!==(n=e.name)&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,""!==n&&(e.name=n)}function te(e,t,n){"number"===t&&Q(e.ownerDocument)===e||(null==n?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var ne=Array.isArray;function re(e,t,n,r){if(e=e.options,t){t={};for(var a=0;a<n.length;a++)t["$"+n[a]]=!0;for(n=0;n<e.length;n++)a=t.hasOwnProperty("$"+e[n].value),e[n].selected!==a&&(e[n].selected=a),a&&r&&(e[n].defaultSelected=!0)}else{for(n=""+H(n),t=null,a=0;a<e.length;a++){if(e[a].value===n)return e[a].selected=!0,void(r&&(e[a].defaultSelected=!0));null!==t||e[a].disabled||(t=e[a])}null!==t&&(t.selected=!0)}}function ae(e,t){if(null!=t.dangerouslySetInnerHTML)throw Error(n(91));return O({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function oe(e,t){var r=t.value;if(null==r){if(r=t.children,t=t.defaultValue,null!=r){if(null!=t)throw Error(n(92));if(ne(r)){if(1<r.length)throw Error(n(93));r=r[0]}t=r}null==t&&(t=""),r=t}e._wrapperState={initialValue:H(r)}}function ie(e,t){var n=H(t.value),r=H(t.defaultValue);null!=n&&((n=""+n)!==e.value&&(e.value=n),null==t.defaultValue&&e.defaultValue!==n&&(e.defaultValue=n)),null!=r&&(e.defaultValue=""+r)}function se(e){var t=e.textContent;t===e._wrapperState.initialValue&&""!==t&&null!==t&&(e.value=t)}function le(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function ce(e,t){return null==e||"http://www.w3.org/1999/xhtml"===e?le(t):"http://www.w3.org/2000/svg"===e&&"foreignObject"===t?"http://www.w3.org/1999/xhtml":e}var ue,de,fe=(de=function(e,t){if("http://www.w3.org/2000/svg"!==e.namespaceURI||"innerHTML"in e)e.innerHTML=t;else{for((ue=ue||document.createElement("div")).innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=ue.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}},"undefined"!=typeof MSApp&&MSApp.execUnsafeLocalFunction?function(e,t,n,r){MSApp.execUnsafeLocalFunction(function(){return de(e,t)})}:de);function he(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&3===n.nodeType)return void(n.nodeValue=t)}e.textContent=t}var pe={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},me=["Webkit","ms","Moz","O"];function ge(e,t,n){return null==t||"boolean"==typeof t||""===t?"":n||"number"!=typeof t||0===t||pe.hasOwnProperty(e)&&pe[e]?(""+t).trim():t+"px"}function ye(e,t){for(var n in e=e.style,t)if(t.hasOwnProperty(n)){var r=0===n.indexOf("--"),a=ge(n,t[n],r);"float"===n&&(n="cssFloat"),r?e.setProperty(n,a):e[n]=a}}Object.keys(pe).forEach(function(e){me.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),pe[t]=pe[e]})});var ve=O({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function be(e,t){if(t){if(ve[e]&&(null!=t.children||null!=t.dangerouslySetInnerHTML))throw Error(n(137,e));if(null!=t.dangerouslySetInnerHTML){if(null!=t.children)throw Error(n(60));if("object"!=typeof t.dangerouslySetInnerHTML||!("__html"in t.dangerouslySetInnerHTML))throw Error(n(61))}if(null!=t.style&&"object"!=typeof t.style)throw Error(n(62))}}function we(e,t){if(-1===e.indexOf("-"))return"string"==typeof t.is;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Se=null;function ke(e){return(e=e.target||e.srcElement||window).correspondingUseElement&&(e=e.correspondingUseElement),3===e.nodeType?e.parentNode:e}var xe=null,Ce=null,Ee=null;function _e(e){if(e=wa(e)){if("function"!=typeof xe)throw Error(n(280));var t=e.stateNode;t&&(t=ka(t),xe(e.stateNode,e.type,t))}}function Me(e){Ce?Ee?Ee.push(e):Ee=[e]:Ce=e}function Re(){if(Ce){var e=Ce,t=Ee;if(Ee=Ce=null,_e(e),t)for(e=0;e<t.length;e++)_e(t[e])}}function Ae(e,t){return e(t)}function Ie(){}var Pe=!1;function Le(e,t,n){if(Pe)return e(t,n);Pe=!0;try{return Ae(e,t,n)}finally{Pe=!1,(null!==Ce||null!==Ee)&&(Ie(),Re())}}function Te(e,t){var r=e.stateNode;if(null===r)return null;var a=ka(r);if(null===a)return null;r=a[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(a=!a.disabled)||(a=!("button"===(e=e.type)||"input"===e||"select"===e||"textarea"===e)),e=!a;break e;default:e=!1}if(e)return null;if(r&&"function"!=typeof r)throw Error(n(231,t,typeof r));return r}var De=!1;if(s)try{var Ne={};Object.defineProperty(Ne,"passive",{get:function(){De=!0}}),window.addEventListener("test",Ne,Ne),window.removeEventListener("test",Ne,Ne)}catch(de){De=!1}function ze(e,t,n,r,a,o,i,s,l){var c=Array.prototype.slice.call(arguments,3);try{t.apply(n,c)}catch(e){this.onError(e)}}var Fe=!1,Oe=null,$e=!1,je=null,Ue={onError:function(e){Fe=!0,Oe=e}};function Be(e,t,n,r,a,o,i,s,l){Fe=!1,Oe=null,ze.apply(Ue,arguments)}function We(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do{!!(4098&(t=e).flags)&&(n=t.return),e=t.return}while(e)}return 3===t.tag?n:null}function Ve(e){if(13===e.tag){var t=e.memoizedState;if(null===t&&(null!==(e=e.alternate)&&(t=e.memoizedState)),null!==t)return t.dehydrated}return null}function He(e){if(We(e)!==e)throw Error(n(188))}function Ke(e){return null!==(e=function(e){var t=e.alternate;if(!t){if(null===(t=We(e)))throw Error(n(188));return t!==e?null:e}for(var r=e,a=t;;){var o=r.return;if(null===o)break;var i=o.alternate;if(null===i){if(null!==(a=o.return)){r=a;continue}break}if(o.child===i.child){for(i=o.child;i;){if(i===r)return He(o),e;if(i===a)return He(o),t;i=i.sibling}throw Error(n(188))}if(r.return!==a.return)r=o,a=i;else{for(var s=!1,l=o.child;l;){if(l===r){s=!0,r=o,a=i;break}if(l===a){s=!0,a=o,r=i;break}l=l.sibling}if(!s){for(l=i.child;l;){if(l===r){s=!0,r=i,a=o;break}if(l===a){s=!0,a=i,r=o;break}l=l.sibling}if(!s)throw Error(n(189))}}if(r.alternate!==a)throw Error(n(190))}if(3!==r.tag)throw Error(n(188));return r.stateNode.current===r?e:t}(e))?qe(e):null}function qe(e){if(5===e.tag||6===e.tag)return e;for(e=e.child;null!==e;){var t=qe(e);if(null!==t)return t;e=e.sibling}return null}var Ge=t.unstable_scheduleCallback,Qe=t.unstable_cancelCallback,Ye=t.unstable_shouldYield,Xe=t.unstable_requestPaint,Je=t.unstable_now,Ze=t.unstable_getCurrentPriorityLevel,et=t.unstable_ImmediatePriority,tt=t.unstable_UserBlockingPriority,nt=t.unstable_NormalPriority,rt=t.unstable_LowPriority,at=t.unstable_IdlePriority,ot=null,it=null;var st=Math.clz32?Math.clz32:function(e){return e>>>=0,0===e?32:31-(lt(e)/ct|0)|0},lt=Math.log,ct=Math.LN2;var ut=64,dt=4194304;function ft(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return 4194240&e;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return 130023424&e;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function ht(e,t){var n=e.pendingLanes;if(0===n)return 0;var r=0,a=e.suspendedLanes,o=e.pingedLanes,i=268435455&n;if(0!==i){var s=i&~a;0!==s?r=ft(s):0!==(o&=i)&&(r=ft(o))}else 0!==(i=n&~a)?r=ft(i):0!==o&&(r=ft(o));if(0===r)return 0;if(0!==t&&t!==r&&0===(t&a)&&((a=r&-r)>=(o=t&-t)||16===a&&4194240&o))return t;if(4&r&&(r|=16&n),0!==(t=e.entangledLanes))for(e=e.entanglements,t&=r;0<t;)a=1<<(n=31-st(t)),r|=e[n],t&=~a;return r}function pt(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;default:return-1}}function mt(e){return 0!==(e=-1073741825&e.pendingLanes)?e:1073741824&e?1073741824:0}function gt(){var e=ut;return!(4194240&(ut<<=1))&&(ut=64),e}function yt(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function vt(e,t,n){e.pendingLanes|=t,536870912!==t&&(e.suspendedLanes=0,e.pingedLanes=0),(e=e.eventTimes)[t=31-st(t)]=n}function bt(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-st(n),a=1<<r;a&t|e[r]&t&&(e[r]|=t),n&=~a}}var wt=0;function St(e){return 1<(e&=-e)?4<e?268435455&e?16:536870912:4:1}var kt,xt,Ct,Et,_t,Mt=!1,Rt=[],At=null,It=null,Pt=null,Lt=new Map,Tt=new Map,Dt=[],Nt="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function zt(e,t){switch(e){case"focusin":case"focusout":At=null;break;case"dragenter":case"dragleave":It=null;break;case"mouseover":case"mouseout":Pt=null;break;case"pointerover":case"pointerout":Lt.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Tt.delete(t.pointerId)}}function Ft(e,t,n,r,a,o){return null===e||e.nativeEvent!==o?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:o,targetContainers:[a]},null!==t&&(null!==(t=wa(t))&&xt(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,null!==a&&-1===t.indexOf(a)&&t.push(a),e)}function Ot(e){var t=ba(e.target);if(null!==t){var n=We(t);if(null!==n)if(13===(t=n.tag)){if(null!==(t=Ve(n)))return e.blockedOn=t,void _t(e.priority,function(){Ct(n)})}else if(3===t&&n.stateNode.current.memoizedState.isDehydrated)return void(e.blockedOn=3===n.tag?n.stateNode.containerInfo:null)}e.blockedOn=null}function $t(e){if(null!==e.blockedOn)return!1;for(var t=e.targetContainers;0<t.length;){var n=Yt(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(null!==n)return null!==(t=wa(n))&&xt(t),e.blockedOn=n,!1;var r=new(n=e.nativeEvent).constructor(n.type,n);Se=r,n.target.dispatchEvent(r),Se=null,t.shift()}return!0}function jt(e,t,n){$t(e)&&n.delete(t)}function Ut(){Mt=!1,null!==At&&$t(At)&&(At=null),null!==It&&$t(It)&&(It=null),null!==Pt&&$t(Pt)&&(Pt=null),Lt.forEach(jt),Tt.forEach(jt)}function Bt(e,n){e.blockedOn===n&&(e.blockedOn=null,Mt||(Mt=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Ut)))}function Wt(e){function t(t){return Bt(t,e)}if(0<Rt.length){Bt(Rt[0],e);for(var n=1;n<Rt.length;n++){var r=Rt[n];r.blockedOn===e&&(r.blockedOn=null)}}for(null!==At&&Bt(At,e),null!==It&&Bt(It,e),null!==Pt&&Bt(Pt,e),Lt.forEach(t),Tt.forEach(t),n=0;n<Dt.length;n++)(r=Dt[n]).blockedOn===e&&(r.blockedOn=null);for(;0<Dt.length&&null===(n=Dt[0]).blockedOn;)Ot(n),null===n.blockedOn&&Dt.shift()}var Vt=w.ReactCurrentBatchConfig,Ht=!0;function Kt(e,t,n,r){var a=wt,o=Vt.transition;Vt.transition=null;try{wt=1,Gt(e,t,n,r)}finally{wt=a,Vt.transition=o}}function qt(e,t,n,r){var a=wt,o=Vt.transition;Vt.transition=null;try{wt=4,Gt(e,t,n,r)}finally{wt=a,Vt.transition=o}}function Gt(e,t,n,r){if(Ht){var a=Yt(e,t,n,r);if(null===a)Hr(e,t,r,Qt,n),zt(e,r);else if(function(e,t,n,r,a){switch(t){case"focusin":return At=Ft(At,e,t,n,r,a),!0;case"dragenter":return It=Ft(It,e,t,n,r,a),!0;case"mouseover":return Pt=Ft(Pt,e,t,n,r,a),!0;case"pointerover":var o=a.pointerId;return Lt.set(o,Ft(Lt.get(o)||null,e,t,n,r,a)),!0;case"gotpointercapture":return o=a.pointerId,Tt.set(o,Ft(Tt.get(o)||null,e,t,n,r,a)),!0}return!1}(a,e,t,n,r))r.stopPropagation();else if(zt(e,r),4&t&&-1<Nt.indexOf(e)){for(;null!==a;){var o=wa(a);if(null!==o&&kt(o),null===(o=Yt(e,t,n,r))&&Hr(e,t,r,Qt,n),o===a)break;a=o}null!==a&&r.stopPropagation()}else Hr(e,t,r,null,n)}}var Qt=null;function Yt(e,t,n,r){if(Qt=null,null!==(e=ba(e=ke(r))))if(null===(t=We(e)))e=null;else if(13===(n=t.tag)){if(null!==(e=Ve(t)))return e;e=null}else if(3===n){if(t.stateNode.current.memoizedState.isDehydrated)return 3===t.tag?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return Qt=e,null}function Xt(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Ze()){case et:return 1;case tt:return 4;case nt:case rt:return 16;case at:return 536870912;default:return 16}default:return 16}}var Jt=null,Zt=null,en=null;function tn(){if(en)return en;var e,t,n=Zt,r=n.length,a="value"in Jt?Jt.value:Jt.textContent,o=a.length;for(e=0;e<r&&n[e]===a[e];e++);var i=r-e;for(t=1;t<=i&&n[r-t]===a[o-t];t++);return en=a.slice(e,1<t?1-t:void 0)}function nn(e){var t=e.keyCode;return"charCode"in e?0===(e=e.charCode)&&13===t&&(e=13):e=t,10===e&&(e=13),32<=e||13===e?e:0}function rn(){return!0}function an(){return!1}function on(e){function t(t,n,r,a,o){for(var i in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=a,this.target=o,this.currentTarget=null,e)e.hasOwnProperty(i)&&(t=e[i],this[i]=t?t(a):a[i]);return this.isDefaultPrevented=(null!=a.defaultPrevented?a.defaultPrevented:!1===a.returnValue)?rn:an,this.isPropagationStopped=an,this}return O(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():"unknown"!=typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=rn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():"unknown"!=typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=rn)},persist:function(){},isPersistent:rn}),t}var sn,ln,cn,un={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},dn=on(un),fn=O({},un,{view:0,detail:0}),hn=on(fn),pn=O({},fn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:_n,button:0,buttons:0,relatedTarget:function(e){return void 0===e.relatedTarget?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==cn&&(cn&&"mousemove"===e.type?(sn=e.screenX-cn.screenX,ln=e.screenY-cn.screenY):ln=sn=0,cn=e),sn)},movementY:function(e){return"movementY"in e?e.movementY:ln}}),mn=on(pn),gn=on(O({},pn,{dataTransfer:0})),yn=on(O({},fn,{relatedTarget:0})),vn=on(O({},un,{animationName:0,elapsedTime:0,pseudoElement:0})),bn=O({},un,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),wn=on(bn),Sn=on(O({},un,{data:0})),kn={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},xn={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},Cn={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function En(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):!!(e=Cn[e])&&!!t[e]}function _n(){return En}var Mn=O({},fn,{key:function(e){if(e.key){var t=kn[e.key]||e.key;if("Unidentified"!==t)return t}return"keypress"===e.type?13===(e=nn(e))?"Enter":String.fromCharCode(e):"keydown"===e.type||"keyup"===e.type?xn[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:_n,charCode:function(e){return"keypress"===e.type?nn(e):0},keyCode:function(e){return"keydown"===e.type||"keyup"===e.type?e.keyCode:0},which:function(e){return"keypress"===e.type?nn(e):"keydown"===e.type||"keyup"===e.type?e.keyCode:0}}),Rn=on(Mn),An=on(O({},pn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),In=on(O({},fn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:_n})),Pn=on(O({},un,{propertyName:0,elapsedTime:0,pseudoElement:0})),Ln=O({},pn,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),Tn=on(Ln),Dn=[9,13,27,32],Nn=s&&"CompositionEvent"in window,zn=null;s&&"documentMode"in document&&(zn=document.documentMode);var Fn=s&&"TextEvent"in window&&!zn,On=s&&(!Nn||zn&&8<zn&&11>=zn),$n=String.fromCharCode(32),jn=!1;function Un(e,t){switch(e){case"keyup":return-1!==Dn.indexOf(t.keyCode);case"keydown":return 229!==t.keyCode;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Bn(e){return"object"==typeof(e=e.detail)&&"data"in e?e.data:null}var Wn=!1;var Vn={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Hn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return"input"===t?!!Vn[e.type]:"textarea"===t}function Kn(e,t,n,r){Me(r),0<(t=qr(t,"onChange")).length&&(n=new dn("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var qn=null,Gn=null;function Qn(e){$r(e,0)}function Yn(e){if(G(Sa(e)))return e}function Xn(e,t){if("change"===e)return t}var Jn=!1;if(s){var Zn;if(s){var er="oninput"in document;if(!er){var tr=document.createElement("div");tr.setAttribute("oninput","return;"),er="function"==typeof tr.oninput}Zn=er}else Zn=!1;Jn=Zn&&(!document.documentMode||9<document.documentMode)}function nr(){qn&&(qn.detachEvent("onpropertychange",rr),Gn=qn=null)}function rr(e){if("value"===e.propertyName&&Yn(Gn)){var t=[];Kn(t,Gn,e,ke(e)),Le(Qn,t)}}function ar(e,t,n){"focusin"===e?(nr(),Gn=n,(qn=t).attachEvent("onpropertychange",rr)):"focusout"===e&&nr()}function or(e){if("selectionchange"===e||"keyup"===e||"keydown"===e)return Yn(Gn)}function ir(e,t){if("click"===e)return Yn(t)}function sr(e,t){if("input"===e||"change"===e)return Yn(t)}var lr="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t};function cr(e,t){if(lr(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var a=n[r];if(!c.call(t,a)||!lr(e[a],t[a]))return!1}return!0}function ur(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function dr(e,t){var n,r=ur(e);for(e=0;r;){if(3===r.nodeType){if(n=e+r.textContent.length,e<=t&&n>=t)return{node:r,offset:t-e};e=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=ur(r)}}function fr(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?fr(e,t.parentNode):"contains"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function hr(){for(var e=window,t=Q();t instanceof e.HTMLIFrameElement;){try{var n="string"==typeof t.contentWindow.location.href}catch(e){n=!1}if(!n)break;t=Q((e=t.contentWindow).document)}return t}function pr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&("input"===t&&("text"===e.type||"search"===e.type||"tel"===e.type||"url"===e.type||"password"===e.type)||"textarea"===t||"true"===e.contentEditable)}function mr(e){var t=hr(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&fr(n.ownerDocument.documentElement,n)){if(null!==r&&pr(n))if(t=r.start,void 0===(e=r.end)&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if((e=(t=n.ownerDocument||document)&&t.defaultView||window).getSelection){e=e.getSelection();var a=n.textContent.length,o=Math.min(r.start,a);r=void 0===r.end?o:Math.min(r.end,a),!e.extend&&o>r&&(a=r,r=o,o=a),a=dr(n,o);var i=dr(n,r);a&&i&&(1!==e.rangeCount||e.anchorNode!==a.node||e.anchorOffset!==a.offset||e.focusNode!==i.node||e.focusOffset!==i.offset)&&((t=t.createRange()).setStart(a.node,a.offset),e.removeAllRanges(),o>r?(e.addRange(t),e.extend(i.node,i.offset)):(t.setEnd(i.node,i.offset),e.addRange(t)))}for(t=[],e=n;e=e.parentNode;)1===e.nodeType&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for("function"==typeof n.focus&&n.focus(),n=0;n<t.length;n++)(e=t[n]).element.scrollLeft=e.left,e.element.scrollTop=e.top}}var gr=s&&"documentMode"in document&&11>=document.documentMode,yr=null,vr=null,br=null,wr=!1;function Sr(e,t,n){var r=n.window===n?n.document:9===n.nodeType?n:n.ownerDocument;wr||null==yr||yr!==Q(r)||("selectionStart"in(r=yr)&&pr(r)?r={start:r.selectionStart,end:r.selectionEnd}:r={anchorNode:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset},br&&cr(br,r)||(br=r,0<(r=qr(vr,"onSelect")).length&&(t=new dn("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=yr)))}function kr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var xr={animationend:kr("Animation","AnimationEnd"),animationiteration:kr("Animation","AnimationIteration"),animationstart:kr("Animation","AnimationStart"),transitionend:kr("Transition","TransitionEnd")},Cr={},Er={};function _r(e){if(Cr[e])return Cr[e];if(!xr[e])return e;var t,n=xr[e];for(t in n)if(n.hasOwnProperty(t)&&t in Er)return Cr[e]=n[t];return e}s&&(Er=document.createElement("div").style,"AnimationEvent"in window||(delete xr.animationend.animation,delete xr.animationiteration.animation,delete xr.animationstart.animation),"TransitionEvent"in window||delete xr.transitionend.transition);var Mr=_r("animationend"),Rr=_r("animationiteration"),Ar=_r("animationstart"),Ir=_r("transitionend"),Pr=new Map,Lr="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Tr(e,t){Pr.set(e,t),o(t,[e])}for(var Dr=0;Dr<Lr.length;Dr++){var Nr=Lr[Dr];Tr(Nr.toLowerCase(),"on"+(Nr[0].toUpperCase()+Nr.slice(1)))}Tr(Mr,"onAnimationEnd"),Tr(Rr,"onAnimationIteration"),Tr(Ar,"onAnimationStart"),Tr("dblclick","onDoubleClick"),Tr("focusin","onFocus"),Tr("focusout","onBlur"),Tr(Ir,"onTransitionEnd"),i("onMouseEnter",["mouseout","mouseover"]),i("onMouseLeave",["mouseout","mouseover"]),i("onPointerEnter",["pointerout","pointerover"]),i("onPointerLeave",["pointerout","pointerover"]),o("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),o("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),o("onBeforeInput",["compositionend","keypress","textInput","paste"]),o("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),o("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),o("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var zr="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Fr=new Set("cancel close invalid load scroll toggle".split(" ").concat(zr));function Or(e,t,r){var a=e.type||"unknown-event";e.currentTarget=r,function(e,t,r,a,o,i,s,l,c){if(Be.apply(this,arguments),Fe){if(!Fe)throw Error(n(198));var u=Oe;Fe=!1,Oe=null,$e||($e=!0,je=u)}}(a,t,void 0,e),e.currentTarget=null}function $r(e,t){t=!!(4&t);for(var n=0;n<e.length;n++){var r=e[n],a=r.event;r=r.listeners;e:{var o=void 0;if(t)for(var i=r.length-1;0<=i;i--){var s=r[i],l=s.instance,c=s.currentTarget;if(s=s.listener,l!==o&&a.isPropagationStopped())break e;Or(a,s,c),o=l}else for(i=0;i<r.length;i++){if(l=(s=r[i]).instance,c=s.currentTarget,s=s.listener,l!==o&&a.isPropagationStopped())break e;Or(a,s,c),o=l}}}if($e)throw e=je,$e=!1,je=null,e}function jr(e,t){var n=t[ga];void 0===n&&(n=t[ga]=new Set);var r=e+"__bubble";n.has(r)||(Vr(t,e,2,!1),n.add(r))}function Ur(e,t,n){var r=0;t&&(r|=4),Vr(n,e,r,t)}var Br="_reactListening"+Math.random().toString(36).slice(2);function Wr(e){if(!e[Br]){e[Br]=!0,r.forEach(function(t){"selectionchange"!==t&&(Fr.has(t)||Ur(t,!1,e),Ur(t,!0,e))});var t=9===e.nodeType?e:e.ownerDocument;null===t||t[Br]||(t[Br]=!0,Ur("selectionchange",!1,t))}}function Vr(e,t,n,r){switch(Xt(t)){case 1:var a=Kt;break;case 4:a=qt;break;default:a=Gt}n=a.bind(null,t,n,e),a=void 0,!De||"touchstart"!==t&&"touchmove"!==t&&"wheel"!==t||(a=!0),r?void 0!==a?e.addEventListener(t,n,{capture:!0,passive:a}):e.addEventListener(t,n,!0):void 0!==a?e.addEventListener(t,n,{passive:a}):e.addEventListener(t,n,!1)}function Hr(e,t,n,r,a){var o=r;if(!(1&t||2&t||null===r))e:for(;;){if(null===r)return;var i=r.tag;if(3===i||4===i){var s=r.stateNode.containerInfo;if(s===a||8===s.nodeType&&s.parentNode===a)break;if(4===i)for(i=r.return;null!==i;){var l=i.tag;if((3===l||4===l)&&((l=i.stateNode.containerInfo)===a||8===l.nodeType&&l.parentNode===a))return;i=i.return}for(;null!==s;){if(null===(i=ba(s)))return;if(5===(l=i.tag)||6===l){r=o=i;continue e}s=s.parentNode}}r=r.return}Le(function(){var r=o,a=ke(n),i=[];e:{var s=Pr.get(e);if(void 0!==s){var l=dn,c=e;switch(e){case"keypress":if(0===nn(n))break e;case"keydown":case"keyup":l=Rn;break;case"focusin":c="focus",l=yn;break;case"focusout":c="blur",l=yn;break;case"beforeblur":case"afterblur":l=yn;break;case"click":if(2===n.button)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":l=mn;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":l=gn;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":l=In;break;case Mr:case Rr:case Ar:l=vn;break;case Ir:l=Pn;break;case"scroll":l=hn;break;case"wheel":l=Tn;break;case"copy":case"cut":case"paste":l=wn;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":l=An}var u=!!(4&t),d=!u&&"scroll"===e,f=u?null!==s?s+"Capture":null:s;u=[];for(var h,p=r;null!==p;){var m=(h=p).stateNode;if(5===h.tag&&null!==m&&(h=m,null!==f&&(null!=(m=Te(p,f))&&u.push(Kr(p,m,h)))),d)break;p=p.return}0<u.length&&(s=new l(s,c,null,n,a),i.push({event:s,listeners:u}))}}if(!(7&t)){if(l="mouseout"===e||"pointerout"===e,(!(s="mouseover"===e||"pointerover"===e)||n===Se||!(c=n.relatedTarget||n.fromElement)||!ba(c)&&!c[ma])&&(l||s)&&(s=a.window===a?a:(s=a.ownerDocument)?s.defaultView||s.parentWindow:window,l?(l=r,null!==(c=(c=n.relatedTarget||n.toElement)?ba(c):null)&&(c!==(d=We(c))||5!==c.tag&&6!==c.tag)&&(c=null)):(l=null,c=r),l!==c)){if(u=mn,m="onMouseLeave",f="onMouseEnter",p="mouse","pointerout"!==e&&"pointerover"!==e||(u=An,m="onPointerLeave",f="onPointerEnter",p="pointer"),d=null==l?s:Sa(l),h=null==c?s:Sa(c),(s=new u(m,p+"leave",l,n,a)).target=d,s.relatedTarget=h,m=null,ba(a)===r&&((u=new u(f,p+"enter",c,n,a)).target=h,u.relatedTarget=d,m=u),d=m,l&&c)e:{for(f=c,p=0,h=u=l;h;h=Gr(h))p++;for(h=0,m=f;m;m=Gr(m))h++;for(;0<p-h;)u=Gr(u),p--;for(;0<h-p;)f=Gr(f),h--;for(;p--;){if(u===f||null!==f&&u===f.alternate)break e;u=Gr(u),f=Gr(f)}u=null}else u=null;null!==l&&Qr(i,s,l,u,!1),null!==c&&null!==d&&Qr(i,d,c,u,!0)}if("select"===(l=(s=r?Sa(r):window).nodeName&&s.nodeName.toLowerCase())||"input"===l&&"file"===s.type)var g=Xn;else if(Hn(s))if(Jn)g=sr;else{g=or;var y=ar}else(l=s.nodeName)&&"input"===l.toLowerCase()&&("checkbox"===s.type||"radio"===s.type)&&(g=ir);switch(g&&(g=g(e,r))?Kn(i,g,n,a):(y&&y(e,s,r),"focusout"===e&&(y=s._wrapperState)&&y.controlled&&"number"===s.type&&te(s,"number",s.value)),y=r?Sa(r):window,e){case"focusin":(Hn(y)||"true"===y.contentEditable)&&(yr=y,vr=r,br=null);break;case"focusout":br=vr=yr=null;break;case"mousedown":wr=!0;break;case"contextmenu":case"mouseup":case"dragend":wr=!1,Sr(i,n,a);break;case"selectionchange":if(gr)break;case"keydown":case"keyup":Sr(i,n,a)}var v;if(Nn)e:{switch(e){case"compositionstart":var b="onCompositionStart";break e;case"compositionend":b="onCompositionEnd";break e;case"compositionupdate":b="onCompositionUpdate";break e}b=void 0}else Wn?Un(e,n)&&(b="onCompositionEnd"):"keydown"===e&&229===n.keyCode&&(b="onCompositionStart");b&&(On&&"ko"!==n.locale&&(Wn||"onCompositionStart"!==b?"onCompositionEnd"===b&&Wn&&(v=tn()):(Zt="value"in(Jt=a)?Jt.value:Jt.textContent,Wn=!0)),0<(y=qr(r,b)).length&&(b=new Sn(b,e,null,n,a),i.push({event:b,listeners:y}),v?b.data=v:null!==(v=Bn(n))&&(b.data=v))),(v=Fn?function(e,t){switch(e){case"compositionend":return Bn(t);case"keypress":return 32!==t.which?null:(jn=!0,$n);case"textInput":return(e=t.data)===$n&&jn?null:e;default:return null}}(e,n):function(e,t){if(Wn)return"compositionend"===e||!Nn&&Un(e,t)?(e=tn(),en=Zt=Jt=null,Wn=!1,e):null;switch(e){case"paste":default:return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return On&&"ko"!==t.locale?null:t.data}}(e,n))&&(0<(r=qr(r,"onBeforeInput")).length&&(a=new Sn("onBeforeInput","beforeinput",null,n,a),i.push({event:a,listeners:r}),a.data=v))}$r(i,t)})}function Kr(e,t,n){return{instance:e,listener:t,currentTarget:n}}function qr(e,t){for(var n=t+"Capture",r=[];null!==e;){var a=e,o=a.stateNode;5===a.tag&&null!==o&&(a=o,null!=(o=Te(e,n))&&r.unshift(Kr(e,o,a)),null!=(o=Te(e,t))&&r.push(Kr(e,o,a))),e=e.return}return r}function Gr(e){if(null===e)return null;do{e=e.return}while(e&&5!==e.tag);return e||null}function Qr(e,t,n,r,a){for(var o=t._reactName,i=[];null!==n&&n!==r;){var s=n,l=s.alternate,c=s.stateNode;if(null!==l&&l===r)break;5===s.tag&&null!==c&&(s=c,a?null!=(l=Te(n,o))&&i.unshift(Kr(n,l,s)):a||null!=(l=Te(n,o))&&i.push(Kr(n,l,s))),n=n.return}0!==i.length&&e.push({event:t,listeners:i})}var Yr=/\r\n?/g,Xr=/\u0000|\uFFFD/g;function Jr(e){return("string"==typeof e?e:""+e).replace(Yr,"\n").replace(Xr,"")}function Zr(e,t,r){if(t=Jr(t),Jr(e)!==t&&r)throw Error(n(425))}function ea(){}var ta=null,na=null;function ra(e,t){return"textarea"===e||"noscript"===e||"string"==typeof t.children||"number"==typeof t.children||"object"==typeof t.dangerouslySetInnerHTML&&null!==t.dangerouslySetInnerHTML&&null!=t.dangerouslySetInnerHTML.__html}var aa="function"==typeof setTimeout?setTimeout:void 0,oa="function"==typeof clearTimeout?clearTimeout:void 0,ia="function"==typeof Promise?Promise:void 0,sa="function"==typeof queueMicrotask?queueMicrotask:void 0!==ia?function(e){return ia.resolve(null).then(e).catch(la)}:aa;function la(e){setTimeout(function(){throw e})}function ca(e,t){var n=t,r=0;do{var a=n.nextSibling;if(e.removeChild(n),a&&8===a.nodeType)if("/$"===(n=a.data)){if(0===r)return e.removeChild(a),void Wt(t);r--}else"$"!==n&&"$?"!==n&&"$!"!==n||r++;n=a}while(n);Wt(t)}function ua(e){for(;null!=e;e=e.nextSibling){var t=e.nodeType;if(1===t||3===t)break;if(8===t){if("$"===(t=e.data)||"$!"===t||"$?"===t)break;if("/$"===t)return null}}return e}function da(e){e=e.previousSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if("$"===n||"$!"===n||"$?"===n){if(0===t)return e;t--}else"/$"===n&&t++}e=e.previousSibling}return null}var fa=Math.random().toString(36).slice(2),ha="__reactFiber$"+fa,pa="__reactProps$"+fa,ma="__reactContainer$"+fa,ga="__reactEvents$"+fa,ya="__reactListeners$"+fa,va="__reactHandles$"+fa;function ba(e){var t=e[ha];if(t)return t;for(var n=e.parentNode;n;){if(t=n[ma]||n[ha]){if(n=t.alternate,null!==t.child||null!==n&&null!==n.child)for(e=da(e);null!==e;){if(n=e[ha])return n;e=da(e)}return t}n=(e=n).parentNode}return null}function wa(e){return!(e=e[ha]||e[ma])||5!==e.tag&&6!==e.tag&&13!==e.tag&&3!==e.tag?null:e}function Sa(e){if(5===e.tag||6===e.tag)return e.stateNode;throw Error(n(33))}function ka(e){return e[pa]||null}var xa=[],Ca=-1;function Ea(e){return{current:e}}function _a(e){0>Ca||(e.current=xa[Ca],xa[Ca]=null,Ca--)}function Ma(e,t){Ca++,xa[Ca]=e.current,e.current=t}var Ra={},Aa=Ea(Ra),Ia=Ea(!1),Pa=Ra;function La(e,t){var n=e.type.contextTypes;if(!n)return Ra;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var a,o={};for(a in n)o[a]=t[a];return r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=o),o}function Ta(e){return null!=(e=e.childContextTypes)}function Da(){_a(Ia),_a(Aa)}function Na(e,t,r){if(Aa.current!==Ra)throw Error(n(168));Ma(Aa,t),Ma(Ia,r)}function za(e,t,r){var a=e.stateNode;if(t=t.childContextTypes,"function"!=typeof a.getChildContext)return r;for(var o in a=a.getChildContext())if(!(o in t))throw Error(n(108,V(e)||"Unknown",o));return O({},r,a)}function Fa(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Ra,Pa=Aa.current,Ma(Aa,e),Ma(Ia,Ia.current),!0}function Oa(e,t,r){var a=e.stateNode;if(!a)throw Error(n(169));r?(e=za(e,t,Pa),a.__reactInternalMemoizedMergedChildContext=e,_a(Ia),_a(Aa),Ma(Aa,e)):_a(Ia),Ma(Ia,r)}var $a=null,ja=!1,Ua=!1;function Ba(e){null===$a?$a=[e]:$a.push(e)}function Wa(){if(!Ua&&null!==$a){Ua=!0;var e=0,t=wt;try{var n=$a;for(wt=1;e<n.length;e++){var r=n[e];do{r=r(!0)}while(null!==r)}$a=null,ja=!1}catch(t){throw null!==$a&&($a=$a.slice(e+1)),Ge(et,Wa),t}finally{wt=t,Ua=!1}}return null}var Va=[],Ha=0,Ka=null,qa=0,Ga=[],Qa=0,Ya=null,Xa=1,Ja="";function Za(e,t){Va[Ha++]=qa,Va[Ha++]=Ka,Ka=e,qa=t}function eo(e,t,n){Ga[Qa++]=Xa,Ga[Qa++]=Ja,Ga[Qa++]=Ya,Ya=e;var r=Xa;e=Ja;var a=32-st(r)-1;r&=~(1<<a),n+=1;var o=32-st(t)+a;if(30<o){var i=a-a%5;o=(r&(1<<i)-1).toString(32),r>>=i,a-=i,Xa=1<<32-st(t)+a|n<<a|r,Ja=o+e}else Xa=1<<o|n<<a|r,Ja=e}function to(e){null!==e.return&&(Za(e,1),eo(e,1,0))}function no(e){for(;e===Ka;)Ka=Va[--Ha],Va[Ha]=null,qa=Va[--Ha],Va[Ha]=null;for(;e===Ya;)Ya=Ga[--Qa],Ga[Qa]=null,Ja=Ga[--Qa],Ga[Qa]=null,Xa=Ga[--Qa],Ga[Qa]=null}var ro=null,ao=null,oo=!1,io=null;function so(e,t){var n=Lc(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,null===(t=e.deletions)?(e.deletions=[n],e.flags|=16):t.push(n)}function lo(e,t){switch(e.tag){case 5:var n=e.type;return null!==(t=1!==t.nodeType||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t)&&(e.stateNode=t,ro=e,ao=ua(t.firstChild),!0);case 6:return null!==(t=""===e.pendingProps||3!==t.nodeType?null:t)&&(e.stateNode=t,ro=e,ao=null,!0);case 13:return null!==(t=8!==t.nodeType?null:t)&&(n=null!==Ya?{id:Xa,overflow:Ja}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},(n=Lc(18,null,null,0)).stateNode=t,n.return=e,e.child=n,ro=e,ao=null,!0);default:return!1}}function co(e){return!(!(1&e.mode)||128&e.flags)}function uo(e){if(oo){var t=ao;if(t){var r=t;if(!lo(e,t)){if(co(e))throw Error(n(418));t=ua(r.nextSibling);var a=ro;t&&lo(e,t)?so(a,r):(e.flags=-4097&e.flags|2,oo=!1,ro=e)}}else{if(co(e))throw Error(n(418));e.flags=-4097&e.flags|2,oo=!1,ro=e}}}function fo(e){for(e=e.return;null!==e&&5!==e.tag&&3!==e.tag&&13!==e.tag;)e=e.return;ro=e}function ho(e){if(e!==ro)return!1;if(!oo)return fo(e),oo=!0,!1;var t;if((t=3!==e.tag)&&!(t=5!==e.tag)&&(t="head"!==(t=e.type)&&"body"!==t&&!ra(e.type,e.memoizedProps)),t&&(t=ao)){if(co(e))throw po(),Error(n(418));for(;t;)so(e,t),t=ua(t.nextSibling)}if(fo(e),13===e.tag){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(n(317));e:{for(e=e.nextSibling,t=0;e;){if(8===e.nodeType){var r=e.data;if("/$"===r){if(0===t){ao=ua(e.nextSibling);break e}t--}else"$"!==r&&"$!"!==r&&"$?"!==r||t++}e=e.nextSibling}ao=null}}else ao=ro?ua(e.stateNode.nextSibling):null;return!0}function po(){for(var e=ao;e;)e=ua(e.nextSibling)}function mo(){ao=ro=null,oo=!1}function go(e){null===io?io=[e]:io.push(e)}var yo=w.ReactCurrentBatchConfig;function vo(e,t,r){if(null!==(e=r.ref)&&"function"!=typeof e&&"object"!=typeof e){if(r._owner){if(r=r._owner){if(1!==r.tag)throw Error(n(309));var a=r.stateNode}if(!a)throw Error(n(147,e));var o=a,i=""+e;return null!==t&&null!==t.ref&&"function"==typeof t.ref&&t.ref._stringRef===i?t.ref:(t=function(e){var t=o.refs;null===e?delete t[i]:t[i]=e},t._stringRef=i,t)}if("string"!=typeof e)throw Error(n(284));if(!r._owner)throw Error(n(290,e))}return e}function bo(e,t){throw e=Object.prototype.toString.call(t),Error(n(31,"[object Object]"===e?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function wo(e){return(0,e._init)(e._payload)}function So(e){function t(t,n){if(e){var r=t.deletions;null===r?(t.deletions=[n],t.flags|=16):r.push(n)}}function r(n,r){if(!e)return null;for(;null!==r;)t(n,r),r=r.sibling;return null}function a(e,t){for(e=new Map;null!==t;)null!==t.key?e.set(t.key,t):e.set(t.index,t),t=t.sibling;return e}function o(e,t){return(e=Dc(e,t)).index=0,e.sibling=null,e}function i(t,n,r){return t.index=r,e?null!==(r=t.alternate)?(r=r.index)<n?(t.flags|=2,n):r:(t.flags|=2,n):(t.flags|=1048576,n)}function s(t){return e&&null===t.alternate&&(t.flags|=2),t}function l(e,t,n,r){return null===t||6!==t.tag?((t=Oc(n,e.mode,r)).return=e,t):((t=o(t,n)).return=e,t)}function c(e,t,n,r){var a=n.type;return a===C?d(e,t,n.props.children,r,n.key):null!==t&&(t.elementType===a||"object"==typeof a&&null!==a&&a.$$typeof===T&&wo(a)===t.type)?((r=o(t,n.props)).ref=vo(e,t,n),r.return=e,r):((r=Nc(n.type,n.key,n.props,null,e.mode,r)).ref=vo(e,t,n),r.return=e,r)}function u(e,t,n,r){return null===t||4!==t.tag||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?((t=$c(n,e.mode,r)).return=e,t):((t=o(t,n.children||[])).return=e,t)}function d(e,t,n,r,a){return null===t||7!==t.tag?((t=zc(n,e.mode,r,a)).return=e,t):((t=o(t,n)).return=e,t)}function f(e,t,n){if("string"==typeof t&&""!==t||"number"==typeof t)return(t=Oc(""+t,e.mode,n)).return=e,t;if("object"==typeof t&&null!==t){switch(t.$$typeof){case k:return(n=Nc(t.type,t.key,t.props,null,e.mode,n)).ref=vo(e,null,t),n.return=e,n;case x:return(t=$c(t,e.mode,n)).return=e,t;case T:return f(e,(0,t._init)(t._payload),n)}if(ne(t)||z(t))return(t=zc(t,e.mode,n,null)).return=e,t;bo(e,t)}return null}function h(e,t,n,r){var a=null!==t?t.key:null;if("string"==typeof n&&""!==n||"number"==typeof n)return null!==a?null:l(e,t,""+n,r);if("object"==typeof n&&null!==n){switch(n.$$typeof){case k:return n.key===a?c(e,t,n,r):null;case x:return n.key===a?u(e,t,n,r):null;case T:return h(e,t,(a=n._init)(n._payload),r)}if(ne(n)||z(n))return null!==a?null:d(e,t,n,r,null);bo(e,n)}return null}function p(e,t,n,r,a){if("string"==typeof r&&""!==r||"number"==typeof r)return l(t,e=e.get(n)||null,""+r,a);if("object"==typeof r&&null!==r){switch(r.$$typeof){case k:return c(t,e=e.get(null===r.key?n:r.key)||null,r,a);case x:return u(t,e=e.get(null===r.key?n:r.key)||null,r,a);case T:return p(e,t,n,(0,r._init)(r._payload),a)}if(ne(r)||z(r))return d(t,e=e.get(n)||null,r,a,null);bo(t,r)}return null}function m(n,o,s,l){for(var c=null,u=null,d=o,m=o=0,g=null;null!==d&&m<s.length;m++){d.index>m?(g=d,d=null):g=d.sibling;var y=h(n,d,s[m],l);if(null===y){null===d&&(d=g);break}e&&d&&null===y.alternate&&t(n,d),o=i(y,o,m),null===u?c=y:u.sibling=y,u=y,d=g}if(m===s.length)return r(n,d),oo&&Za(n,m),c;if(null===d){for(;m<s.length;m++)null!==(d=f(n,s[m],l))&&(o=i(d,o,m),null===u?c=d:u.sibling=d,u=d);return oo&&Za(n,m),c}for(d=a(n,d);m<s.length;m++)null!==(g=p(d,n,m,s[m],l))&&(e&&null!==g.alternate&&d.delete(null===g.key?m:g.key),o=i(g,o,m),null===u?c=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(n,e)}),oo&&Za(n,m),c}function g(o,s,l,c){var u=z(l);if("function"!=typeof u)throw Error(n(150));if(null==(l=u.call(l)))throw Error(n(151));for(var d=u=null,m=s,g=s=0,y=null,v=l.next();null!==m&&!v.done;g++,v=l.next()){m.index>g?(y=m,m=null):y=m.sibling;var b=h(o,m,v.value,c);if(null===b){null===m&&(m=y);break}e&&m&&null===b.alternate&&t(o,m),s=i(b,s,g),null===d?u=b:d.sibling=b,d=b,m=y}if(v.done)return r(o,m),oo&&Za(o,g),u;if(null===m){for(;!v.done;g++,v=l.next())null!==(v=f(o,v.value,c))&&(s=i(v,s,g),null===d?u=v:d.sibling=v,d=v);return oo&&Za(o,g),u}for(m=a(o,m);!v.done;g++,v=l.next())null!==(v=p(m,o,g,v.value,c))&&(e&&null!==v.alternate&&m.delete(null===v.key?g:v.key),s=i(v,s,g),null===d?u=v:d.sibling=v,d=v);return e&&m.forEach(function(e){return t(o,e)}),oo&&Za(o,g),u}return function e(n,a,i,l){if("object"==typeof i&&null!==i&&i.type===C&&null===i.key&&(i=i.props.children),"object"==typeof i&&null!==i){switch(i.$$typeof){case k:e:{for(var c=i.key,u=a;null!==u;){if(u.key===c){if((c=i.type)===C){if(7===u.tag){r(n,u.sibling),(a=o(u,i.props.children)).return=n,n=a;break e}}else if(u.elementType===c||"object"==typeof c&&null!==c&&c.$$typeof===T&&wo(c)===u.type){r(n,u.sibling),(a=o(u,i.props)).ref=vo(n,u,i),a.return=n,n=a;break e}r(n,u);break}t(n,u),u=u.sibling}i.type===C?((a=zc(i.props.children,n.mode,l,i.key)).return=n,n=a):((l=Nc(i.type,i.key,i.props,null,n.mode,l)).ref=vo(n,a,i),l.return=n,n=l)}return s(n);case x:e:{for(u=i.key;null!==a;){if(a.key===u){if(4===a.tag&&a.stateNode.containerInfo===i.containerInfo&&a.stateNode.implementation===i.implementation){r(n,a.sibling),(a=o(a,i.children||[])).return=n,n=a;break e}r(n,a);break}t(n,a),a=a.sibling}(a=$c(i,n.mode,l)).return=n,n=a}return s(n);case T:return e(n,a,(u=i._init)(i._payload),l)}if(ne(i))return m(n,a,i,l);if(z(i))return g(n,a,i,l);bo(n,i)}return"string"==typeof i&&""!==i||"number"==typeof i?(i=""+i,null!==a&&6===a.tag?(r(n,a.sibling),(a=o(a,i)).return=n,n=a):(r(n,a),(a=Oc(i,n.mode,l)).return=n,n=a),s(n)):r(n,a)}}var ko=So(!0),xo=So(!1),Co=Ea(null),Eo=null,_o=null,Mo=null;function Ro(){Mo=_o=Eo=null}function Ao(e){var t=Co.current;_a(Co),e._currentValue=t}function Io(e,t,n){for(;null!==e;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,null!==r&&(r.childLanes|=t)):null!==r&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Po(e,t){Eo=e,Mo=_o=null,null!==(e=e.dependencies)&&null!==e.firstContext&&(0!==(e.lanes&t)&&(ws=!0),e.firstContext=null)}function Lo(e){var t=e._currentValue;if(Mo!==e)if(e={context:e,memoizedValue:t,next:null},null===_o){if(null===Eo)throw Error(n(308));_o=e,Eo.dependencies={lanes:0,firstContext:e}}else _o=_o.next=e;return t}var To=null;function Do(e){null===To?To=[e]:To.push(e)}function No(e,t,n,r){var a=t.interleaved;return null===a?(n.next=n,Do(t)):(n.next=a.next,a.next=n),t.interleaved=n,zo(e,r)}function zo(e,t){e.lanes|=t;var n=e.alternate;for(null!==n&&(n.lanes|=t),n=e,e=e.return;null!==e;)e.childLanes|=t,null!==(n=e.alternate)&&(n.childLanes|=t),n=e,e=e.return;return 3===n.tag?n.stateNode:null}var Fo=!1;function Oo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function $o(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function jo(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Uo(e,t,n){var r=e.updateQueue;if(null===r)return null;if(r=r.shared,2&Al){var a=r.pending;return null===a?t.next=t:(t.next=a.next,a.next=t),r.pending=t,zo(e,n)}return null===(a=r.interleaved)?(t.next=t,Do(r)):(t.next=a.next,a.next=t),r.interleaved=t,zo(e,n)}function Bo(e,t,n){if(null!==(t=t.updateQueue)&&(t=t.shared,4194240&n)){var r=t.lanes;n|=r&=e.pendingLanes,t.lanes=n,bt(e,n)}}function Wo(e,t){var n=e.updateQueue,r=e.alternate;if(null!==r&&n===(r=r.updateQueue)){var a=null,o=null;if(null!==(n=n.firstBaseUpdate)){do{var i={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};null===o?a=o=i:o=o.next=i,n=n.next}while(null!==n);null===o?a=o=t:o=o.next=t}else a=o=t;return n={baseState:r.baseState,firstBaseUpdate:a,lastBaseUpdate:o,shared:r.shared,effects:r.effects},void(e.updateQueue=n)}null===(e=n.lastBaseUpdate)?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Vo(e,t,n,r){var a=e.updateQueue;Fo=!1;var o=a.firstBaseUpdate,i=a.lastBaseUpdate,s=a.shared.pending;if(null!==s){a.shared.pending=null;var l=s,c=l.next;l.next=null,null===i?o=c:i.next=c,i=l;var u=e.alternate;null!==u&&((s=(u=u.updateQueue).lastBaseUpdate)!==i&&(null===s?u.firstBaseUpdate=c:s.next=c,u.lastBaseUpdate=l))}if(null!==o){var d=a.baseState;for(i=0,u=c=l=null,s=o;;){var f=s.lane,h=s.eventTime;if((r&f)===f){null!==u&&(u=u.next={eventTime:h,lane:0,tag:s.tag,payload:s.payload,callback:s.callback,next:null});e:{var p=e,m=s;switch(f=t,h=n,m.tag){case 1:if("function"==typeof(p=m.payload)){d=p.call(h,d,f);break e}d=p;break e;case 3:p.flags=-65537&p.flags|128;case 0:if(null==(f="function"==typeof(p=m.payload)?p.call(h,d,f):p))break e;d=O({},d,f);break e;case 2:Fo=!0}}null!==s.callback&&0!==s.lane&&(e.flags|=64,null===(f=a.effects)?a.effects=[s]:f.push(s))}else h={eventTime:h,lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},null===u?(c=u=h,l=d):u=u.next=h,i|=f;if(null===(s=s.next)){if(null===(s=a.shared.pending))break;s=(f=s).next,f.next=null,a.lastBaseUpdate=f,a.shared.pending=null}}if(null===u&&(l=d),a.baseState=l,a.firstBaseUpdate=c,a.lastBaseUpdate=u,null!==(t=a.shared.interleaved)){a=t;do{i|=a.lane,a=a.next}while(a!==t)}else null===o&&(a.shared.lanes=0);Fl|=i,e.lanes=i,e.memoizedState=d}}function Ho(e,t,r){if(e=t.effects,t.effects=null,null!==e)for(t=0;t<e.length;t++){var a=e[t],o=a.callback;if(null!==o){if(a.callback=null,a=r,"function"!=typeof o)throw Error(n(191,o));o.call(a)}}}var Ko={},qo=Ea(Ko),Go=Ea(Ko),Qo=Ea(Ko);function Yo(e){if(e===Ko)throw Error(n(174));return e}function Xo(e,t){switch(Ma(Qo,t),Ma(Go,e),Ma(qo,Ko),e=t.nodeType){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:ce(null,"");break;default:t=ce(t=(e=8===e?t.parentNode:t).namespaceURI||null,e=e.tagName)}_a(qo),Ma(qo,t)}function Jo(){_a(qo),_a(Go),_a(Qo)}function Zo(e){Yo(Qo.current);var t=Yo(qo.current),n=ce(t,e.type);t!==n&&(Ma(Go,e),Ma(qo,n))}function ei(e){Go.current===e&&(_a(qo),_a(Go))}var ti=Ea(0);function ni(e){for(var t=e;null!==t;){if(13===t.tag){var n=t.memoizedState;if(null!==n&&(null===(n=n.dehydrated)||"$?"===n.data||"$!"===n.data))return t}else if(19===t.tag&&void 0!==t.memoizedProps.revealOrder){if(128&t.flags)return t}else if(null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var ri=[];function ai(){for(var e=0;e<ri.length;e++)ri[e]._workInProgressVersionPrimary=null;ri.length=0}var oi=w.ReactCurrentDispatcher,ii=w.ReactCurrentBatchConfig,si=0,li=null,ci=null,ui=null,di=!1,fi=!1,hi=0,pi=0;function mi(){throw Error(n(321))}function gi(e,t){if(null===t)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!lr(e[n],t[n]))return!1;return!0}function yi(e,t,r,a,o,i){if(si=i,li=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,oi.current=null===e||null===e.memoizedState?es:ts,e=r(a,o),fi){i=0;do{if(fi=!1,hi=0,25<=i)throw Error(n(301));i+=1,ui=ci=null,t.updateQueue=null,oi.current=ns,e=r(a,o)}while(fi)}if(oi.current=Zi,t=null!==ci&&null!==ci.next,si=0,ui=ci=li=null,di=!1,t)throw Error(n(300));return e}function vi(){var e=0!==hi;return hi=0,e}function bi(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===ui?li.memoizedState=ui=e:ui=ui.next=e,ui}function wi(){if(null===ci){var e=li.alternate;e=null!==e?e.memoizedState:null}else e=ci.next;var t=null===ui?li.memoizedState:ui.next;if(null!==t)ui=t,ci=e;else{if(null===e)throw Error(n(310));e={memoizedState:(ci=e).memoizedState,baseState:ci.baseState,baseQueue:ci.baseQueue,queue:ci.queue,next:null},null===ui?li.memoizedState=ui=e:ui=ui.next=e}return ui}function Si(e,t){return"function"==typeof t?t(e):t}function ki(e){var t=wi(),r=t.queue;if(null===r)throw Error(n(311));r.lastRenderedReducer=e;var a=ci,o=a.baseQueue,i=r.pending;if(null!==i){if(null!==o){var s=o.next;o.next=i.next,i.next=s}a.baseQueue=o=i,r.pending=null}if(null!==o){i=o.next,a=a.baseState;var l=s=null,c=null,u=i;do{var d=u.lane;if((si&d)===d)null!==c&&(c=c.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),a=u.hasEagerState?u.eagerState:e(a,u.action);else{var f={lane:d,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};null===c?(l=c=f,s=a):c=c.next=f,li.lanes|=d,Fl|=d}u=u.next}while(null!==u&&u!==i);null===c?s=a:c.next=l,lr(a,t.memoizedState)||(ws=!0),t.memoizedState=a,t.baseState=s,t.baseQueue=c,r.lastRenderedState=a}if(null!==(e=r.interleaved)){o=e;do{i=o.lane,li.lanes|=i,Fl|=i,o=o.next}while(o!==e)}else null===o&&(r.lanes=0);return[t.memoizedState,r.dispatch]}function xi(e){var t=wi(),r=t.queue;if(null===r)throw Error(n(311));r.lastRenderedReducer=e;var a=r.dispatch,o=r.pending,i=t.memoizedState;if(null!==o){r.pending=null;var s=o=o.next;do{i=e(i,s.action),s=s.next}while(s!==o);lr(i,t.memoizedState)||(ws=!0),t.memoizedState=i,null===t.baseQueue&&(t.baseState=i),r.lastRenderedState=i}return[i,a]}function Ci(){}function Ei(e,t){var r=li,a=wi(),o=t(),i=!lr(a.memoizedState,o);if(i&&(a.memoizedState=o,ws=!0),a=a.queue,Fi(Ri.bind(null,r,a,e),[e]),a.getSnapshot!==t||i||null!==ui&&1&ui.memoizedState.tag){if(r.flags|=2048,Li(9,Mi.bind(null,r,a,o,t),void 0,null),null===Il)throw Error(n(349));30&si||_i(r,t,o)}return o}function _i(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},null===(t=li.updateQueue)?(t={lastEffect:null,stores:null},li.updateQueue=t,t.stores=[e]):null===(n=t.stores)?t.stores=[e]:n.push(e)}function Mi(e,t,n,r){t.value=n,t.getSnapshot=r,Ai(t)&&Ii(e)}function Ri(e,t,n){return n(function(){Ai(t)&&Ii(e)})}function Ai(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!lr(e,n)}catch(e){return!0}}function Ii(e){var t=zo(e,1);null!==t&&rc(t,e,1,-1)}function Pi(e){var t=bi();return"function"==typeof e&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Si,lastRenderedState:e},t.queue=e,e=e.dispatch=Qi.bind(null,li,e),[t.memoizedState,e]}function Li(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},null===(t=li.updateQueue)?(t={lastEffect:null,stores:null},li.updateQueue=t,t.lastEffect=e.next=e):null===(n=t.lastEffect)?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function Ti(){return wi().memoizedState}function Di(e,t,n,r){var a=bi();li.flags|=e,a.memoizedState=Li(1|t,n,void 0,void 0===r?null:r)}function Ni(e,t,n,r){var a=wi();r=void 0===r?null:r;var o=void 0;if(null!==ci){var i=ci.memoizedState;if(o=i.destroy,null!==r&&gi(r,i.deps))return void(a.memoizedState=Li(t,n,o,r))}li.flags|=e,a.memoizedState=Li(1|t,n,o,r)}function zi(e,t){return Di(8390656,8,e,t)}function Fi(e,t){return Ni(2048,8,e,t)}function Oi(e,t){return Ni(4,2,e,t)}function $i(e,t){return Ni(4,4,e,t)}function ji(e,t){return"function"==typeof t?(e=e(),t(e),function(){t(null)}):null!=t?(e=e(),t.current=e,function(){t.current=null}):void 0}function Ui(e,t,n){return n=null!=n?n.concat([e]):null,Ni(4,4,ji.bind(null,t,e),n)}function Bi(){}function Wi(e,t){var n=wi();t=void 0===t?null:t;var r=n.memoizedState;return null!==r&&null!==t&&gi(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Vi(e,t){var n=wi();t=void 0===t?null:t;var r=n.memoizedState;return null!==r&&null!==t&&gi(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function Hi(e,t,n){return 21&si?(lr(n,t)||(n=gt(),li.lanes|=n,Fl|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,ws=!0),e.memoizedState=n)}function Ki(e,t){var n=wt;wt=0!==n&&4>n?n:4,e(!0);var r=ii.transition;ii.transition={};try{e(!1),t()}finally{wt=n,ii.transition=r}}function qi(){return wi().memoizedState}function Gi(e,t,n){var r=nc(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Yi(e))Xi(t,n);else if(null!==(n=No(e,t,n,r))){rc(n,e,r,tc()),Ji(n,t,r)}}function Qi(e,t,n){var r=nc(e),a={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Yi(e))Xi(t,a);else{var o=e.alternate;if(0===e.lanes&&(null===o||0===o.lanes)&&null!==(o=t.lastRenderedReducer))try{var i=t.lastRenderedState,s=o(i,n);if(a.hasEagerState=!0,a.eagerState=s,lr(s,i)){var l=t.interleaved;return null===l?(a.next=a,Do(t)):(a.next=l.next,l.next=a),void(t.interleaved=a)}}catch(e){}null!==(n=No(e,t,a,r))&&(rc(n,e,r,a=tc()),Ji(n,t,r))}}function Yi(e){var t=e.alternate;return e===li||null!==t&&t===li}function Xi(e,t){fi=di=!0;var n=e.pending;null===n?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Ji(e,t,n){if(4194240&n){var r=t.lanes;n|=r&=e.pendingLanes,t.lanes=n,bt(e,n)}}var Zi={readContext:Lo,useCallback:mi,useContext:mi,useEffect:mi,useImperativeHandle:mi,useInsertionEffect:mi,useLayoutEffect:mi,useMemo:mi,useReducer:mi,useRef:mi,useState:mi,useDebugValue:mi,useDeferredValue:mi,useTransition:mi,useMutableSource:mi,useSyncExternalStore:mi,useId:mi,unstable_isNewReconciler:!1},es={readContext:Lo,useCallback:function(e,t){return bi().memoizedState=[e,void 0===t?null:t],e},useContext:Lo,useEffect:zi,useImperativeHandle:function(e,t,n){return n=null!=n?n.concat([e]):null,Di(4194308,4,ji.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Di(4194308,4,e,t)},useInsertionEffect:function(e,t){return Di(4,2,e,t)},useMemo:function(e,t){var n=bi();return t=void 0===t?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=bi();return t=void 0!==n?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Gi.bind(null,li,e),[r.memoizedState,e]},useRef:function(e){return e={current:e},bi().memoizedState=e},useState:Pi,useDebugValue:Bi,useDeferredValue:function(e){return bi().memoizedState=e},useTransition:function(){var e=Pi(!1),t=e[0];return e=Ki.bind(null,e[1]),bi().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,r){var a=li,o=bi();if(oo){if(void 0===r)throw Error(n(407));r=r()}else{if(r=t(),null===Il)throw Error(n(349));30&si||_i(a,t,r)}o.memoizedState=r;var i={value:r,getSnapshot:t};return o.queue=i,zi(Ri.bind(null,a,i,e),[e]),a.flags|=2048,Li(9,Mi.bind(null,a,i,r,t),void 0,null),r},useId:function(){var e=bi(),t=Il.identifierPrefix;if(oo){var n=Ja;t=":"+t+"R"+(n=(Xa&~(1<<32-st(Xa)-1)).toString(32)+n),0<(n=hi++)&&(t+="H"+n.toString(32)),t+=":"}else t=":"+t+"r"+(n=pi++).toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},ts={readContext:Lo,useCallback:Wi,useContext:Lo,useEffect:Fi,useImperativeHandle:Ui,useInsertionEffect:Oi,useLayoutEffect:$i,useMemo:Vi,useReducer:ki,useRef:Ti,useState:function(){return ki(Si)},useDebugValue:Bi,useDeferredValue:function(e){return Hi(wi(),ci.memoizedState,e)},useTransition:function(){return[ki(Si)[0],wi().memoizedState]},useMutableSource:Ci,useSyncExternalStore:Ei,useId:qi,unstable_isNewReconciler:!1},ns={readContext:Lo,useCallback:Wi,useContext:Lo,useEffect:Fi,useImperativeHandle:Ui,useInsertionEffect:Oi,useLayoutEffect:$i,useMemo:Vi,useReducer:xi,useRef:Ti,useState:function(){return xi(Si)},useDebugValue:Bi,useDeferredValue:function(e){var t=wi();return null===ci?t.memoizedState=e:Hi(t,ci.memoizedState,e)},useTransition:function(){return[xi(Si)[0],wi().memoizedState]},useMutableSource:Ci,useSyncExternalStore:Ei,useId:qi,unstable_isNewReconciler:!1};function rs(e,t){if(e&&e.defaultProps){for(var n in t=O({},t),e=e.defaultProps)void 0===t[n]&&(t[n]=e[n]);return t}return t}function as(e,t,n,r){n=null==(n=n(r,t=e.memoizedState))?t:O({},t,n),e.memoizedState=n,0===e.lanes&&(e.updateQueue.baseState=n)}var os={isMounted:function(e){return!!(e=e._reactInternals)&&We(e)===e},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=tc(),a=nc(e),o=jo(r,a);o.payload=t,null!=n&&(o.callback=n),null!==(t=Uo(e,o,a))&&(rc(t,e,a,r),Bo(t,e,a))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=tc(),a=nc(e),o=jo(r,a);o.tag=1,o.payload=t,null!=n&&(o.callback=n),null!==(t=Uo(e,o,a))&&(rc(t,e,a,r),Bo(t,e,a))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=tc(),r=nc(e),a=jo(n,r);a.tag=2,null!=t&&(a.callback=t),null!==(t=Uo(e,a,r))&&(rc(t,e,r,n),Bo(t,e,r))}};function is(e,t,n,r,a,o,i){return"function"==typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(r,o,i):!t.prototype||!t.prototype.isPureReactComponent||(!cr(n,r)||!cr(a,o))}function ss(e,t,n){var r=!1,a=Ra,o=t.contextType;return"object"==typeof o&&null!==o?o=Lo(o):(a=Ta(t)?Pa:Aa.current,o=(r=null!=(r=t.contextTypes))?La(e,a):Ra),t=new t(n,o),e.memoizedState=null!==t.state&&void 0!==t.state?t.state:null,t.updater=os,e.stateNode=t,t._reactInternals=e,r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=a,e.__reactInternalMemoizedMaskedChildContext=o),t}function ls(e,t,n,r){e=t.state,"function"==typeof t.componentWillReceiveProps&&t.componentWillReceiveProps(n,r),"function"==typeof t.UNSAFE_componentWillReceiveProps&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&os.enqueueReplaceState(t,t.state,null)}function cs(e,t,n,r){var a=e.stateNode;a.props=n,a.state=e.memoizedState,a.refs={},Oo(e);var o=t.contextType;"object"==typeof o&&null!==o?a.context=Lo(o):(o=Ta(t)?Pa:Aa.current,a.context=La(e,o)),a.state=e.memoizedState,"function"==typeof(o=t.getDerivedStateFromProps)&&(as(e,t,o,n),a.state=e.memoizedState),"function"==typeof t.getDerivedStateFromProps||"function"==typeof a.getSnapshotBeforeUpdate||"function"!=typeof a.UNSAFE_componentWillMount&&"function"!=typeof a.componentWillMount||(t=a.state,"function"==typeof a.componentWillMount&&a.componentWillMount(),"function"==typeof a.UNSAFE_componentWillMount&&a.UNSAFE_componentWillMount(),t!==a.state&&os.enqueueReplaceState(a,a.state,null),Vo(e,n,a,r),a.state=e.memoizedState),"function"==typeof a.componentDidMount&&(e.flags|=4194308)}function us(e,t){try{var n="",r=t;do{n+=B(r),r=r.return}while(r);var a=n}catch(e){a="\nError generating stack: "+e.message+"\n"+e.stack}return{value:e,source:t,stack:a,digest:null}}function ds(e,t,n){return{value:e,source:null,stack:null!=n?n:null,digest:null!=t?t:null}}function fs(e,t){try{console.error(t.value)}catch(e){setTimeout(function(){throw e})}}var hs="function"==typeof WeakMap?WeakMap:Map;function ps(e,t,n){(n=jo(-1,n)).tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){Hl||(Hl=!0,Kl=r),fs(0,t)},n}function ms(e,t,n){(n=jo(-1,n)).tag=3;var r=e.type.getDerivedStateFromError;if("function"==typeof r){var a=t.value;n.payload=function(){return r(a)},n.callback=function(){fs(0,t)}}var o=e.stateNode;return null!==o&&"function"==typeof o.componentDidCatch&&(n.callback=function(){fs(0,t),"function"!=typeof r&&(null===ql?ql=new Set([this]):ql.add(this));var e=t.stack;this.componentDidCatch(t.value,{componentStack:null!==e?e:""})}),n}function gs(e,t,n){var r=e.pingCache;if(null===r){r=e.pingCache=new hs;var a=new Set;r.set(t,a)}else void 0===(a=r.get(t))&&(a=new Set,r.set(t,a));a.has(n)||(a.add(n),e=_c.bind(null,e,t,n),t.then(e,e))}function ys(e){do{var t;if((t=13===e.tag)&&(t=null===(t=e.memoizedState)||null!==t.dehydrated),t)return e;e=e.return}while(null!==e);return null}function vs(e,t,n,r,a){return 1&e.mode?(e.flags|=65536,e.lanes=a,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,1===n.tag&&(null===n.alternate?n.tag=17:((t=jo(-1,1)).tag=2,Uo(n,t,1))),n.lanes|=1),e)}var bs=w.ReactCurrentOwner,ws=!1;function Ss(e,t,n,r){t.child=null===e?xo(t,null,n,r):ko(t,e.child,n,r)}function ks(e,t,n,r,a){n=n.render;var o=t.ref;return Po(t,a),r=yi(e,t,n,r,o,a),n=vi(),null===e||ws?(oo&&n&&to(t),t.flags|=1,Ss(e,t,r,a),t.child):(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,Hs(e,t,a))}function xs(e,t,n,r,a){if(null===e){var o=n.type;return"function"!=typeof o||Tc(o)||void 0!==o.defaultProps||null!==n.compare||void 0!==n.defaultProps?((e=Nc(n.type,null,r,t,t.mode,a)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=o,Cs(e,t,o,r,a))}if(o=e.child,0===(e.lanes&a)){var i=o.memoizedProps;if((n=null!==(n=n.compare)?n:cr)(i,r)&&e.ref===t.ref)return Hs(e,t,a)}return t.flags|=1,(e=Dc(o,r)).ref=t.ref,e.return=t,t.child=e}function Cs(e,t,n,r,a){if(null!==e){var o=e.memoizedProps;if(cr(o,r)&&e.ref===t.ref){if(ws=!1,t.pendingProps=r=o,0===(e.lanes&a))return t.lanes=e.lanes,Hs(e,t,a);131072&e.flags&&(ws=!0)}}return Ms(e,t,n,r,a)}function Es(e,t,n){var r=t.pendingProps,a=r.children,o=null!==e?e.memoizedState:null;if("hidden"===r.mode)if(1&t.mode){if(!(1073741824&n))return e=null!==o?o.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,Ma(Dl,Tl),Tl|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=null!==o?o.baseLanes:n,Ma(Dl,Tl),Tl|=r}else t.memoizedState={baseLanes:0,cachePool:null,transitions:null},Ma(Dl,Tl),Tl|=n;else null!==o?(r=o.baseLanes|n,t.memoizedState=null):r=n,Ma(Dl,Tl),Tl|=r;return Ss(e,t,a,n),t.child}function _s(e,t){var n=t.ref;(null===e&&null!==n||null!==e&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Ms(e,t,n,r,a){var o=Ta(n)?Pa:Aa.current;return o=La(t,o),Po(t,a),n=yi(e,t,n,r,o,a),r=vi(),null===e||ws?(oo&&r&&to(t),t.flags|=1,Ss(e,t,n,a),t.child):(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,Hs(e,t,a))}function Rs(e,t,n,r,a){if(Ta(n)){var o=!0;Fa(t)}else o=!1;if(Po(t,a),null===t.stateNode)Vs(e,t),ss(t,n,r),cs(t,n,r,a),r=!0;else if(null===e){var i=t.stateNode,s=t.memoizedProps;i.props=s;var l=i.context,c=n.contextType;"object"==typeof c&&null!==c?c=Lo(c):c=La(t,c=Ta(n)?Pa:Aa.current);var u=n.getDerivedStateFromProps,d="function"==typeof u||"function"==typeof i.getSnapshotBeforeUpdate;d||"function"!=typeof i.UNSAFE_componentWillReceiveProps&&"function"!=typeof i.componentWillReceiveProps||(s!==r||l!==c)&&ls(t,i,r,c),Fo=!1;var f=t.memoizedState;i.state=f,Vo(t,r,i,a),l=t.memoizedState,s!==r||f!==l||Ia.current||Fo?("function"==typeof u&&(as(t,n,u,r),l=t.memoizedState),(s=Fo||is(t,n,s,r,f,l,c))?(d||"function"!=typeof i.UNSAFE_componentWillMount&&"function"!=typeof i.componentWillMount||("function"==typeof i.componentWillMount&&i.componentWillMount(),"function"==typeof i.UNSAFE_componentWillMount&&i.UNSAFE_componentWillMount()),"function"==typeof i.componentDidMount&&(t.flags|=4194308)):("function"==typeof i.componentDidMount&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),i.props=r,i.state=l,i.context=c,r=s):("function"==typeof i.componentDidMount&&(t.flags|=4194308),r=!1)}else{i=t.stateNode,$o(e,t),s=t.memoizedProps,c=t.type===t.elementType?s:rs(t.type,s),i.props=c,d=t.pendingProps,f=i.context,"object"==typeof(l=n.contextType)&&null!==l?l=Lo(l):l=La(t,l=Ta(n)?Pa:Aa.current);var h=n.getDerivedStateFromProps;(u="function"==typeof h||"function"==typeof i.getSnapshotBeforeUpdate)||"function"!=typeof i.UNSAFE_componentWillReceiveProps&&"function"!=typeof i.componentWillReceiveProps||(s!==d||f!==l)&&ls(t,i,r,l),Fo=!1,f=t.memoizedState,i.state=f,Vo(t,r,i,a);var p=t.memoizedState;s!==d||f!==p||Ia.current||Fo?("function"==typeof h&&(as(t,n,h,r),p=t.memoizedState),(c=Fo||is(t,n,c,r,f,p,l)||!1)?(u||"function"!=typeof i.UNSAFE_componentWillUpdate&&"function"!=typeof i.componentWillUpdate||("function"==typeof i.componentWillUpdate&&i.componentWillUpdate(r,p,l),"function"==typeof i.UNSAFE_componentWillUpdate&&i.UNSAFE_componentWillUpdate(r,p,l)),"function"==typeof i.componentDidUpdate&&(t.flags|=4),"function"==typeof i.getSnapshotBeforeUpdate&&(t.flags|=1024)):("function"!=typeof i.componentDidUpdate||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),"function"!=typeof i.getSnapshotBeforeUpdate||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),i.props=r,i.state=p,i.context=l,r=c):("function"!=typeof i.componentDidUpdate||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),"function"!=typeof i.getSnapshotBeforeUpdate||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return As(e,t,n,r,o,a)}function As(e,t,n,r,a,o){_s(e,t);var i=!!(128&t.flags);if(!r&&!i)return a&&Oa(t,n,!1),Hs(e,t,o);r=t.stateNode,bs.current=t;var s=i&&"function"!=typeof n.getDerivedStateFromError?null:r.render();return t.flags|=1,null!==e&&i?(t.child=ko(t,e.child,null,o),t.child=ko(t,null,s,o)):Ss(e,t,s,o),t.memoizedState=r.state,a&&Oa(t,n,!0),t.child}function Is(e){var t=e.stateNode;t.pendingContext?Na(0,t.pendingContext,t.pendingContext!==t.context):t.context&&Na(0,t.context,!1),Xo(e,t.containerInfo)}function Ps(e,t,n,r,a){return mo(),go(a),t.flags|=256,Ss(e,t,n,r),t.child}var Ls,Ts,Ds,Ns,zs={dehydrated:null,treeContext:null,retryLane:0};function Fs(e){return{baseLanes:e,cachePool:null,transitions:null}}function Os(e,t,r){var a,o=t.pendingProps,i=ti.current,s=!1,l=!!(128&t.flags);if((a=l)||(a=(null===e||null!==e.memoizedState)&&!!(2&i)),a?(s=!0,t.flags&=-129):null!==e&&null===e.memoizedState||(i|=1),Ma(ti,1&i),null===e)return uo(t),null!==(e=t.memoizedState)&&null!==(e=e.dehydrated)?(1&t.mode?"$!"===e.data?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(l=o.children,e=o.fallback,s?(o=t.mode,s=t.child,l={mode:"hidden",children:l},1&o||null===s?s=Fc(l,o,0,null):(s.childLanes=0,s.pendingProps=l),e=zc(e,o,r,null),s.return=t,e.return=t,s.sibling=e,t.child=s,t.child.memoizedState=Fs(r),t.memoizedState=zs,e):$s(t,l));if(null!==(i=e.memoizedState)&&null!==(a=i.dehydrated))return function(e,t,r,a,o,i,s){if(r)return 256&t.flags?(t.flags&=-257,js(e,t,s,a=ds(Error(n(422))))):null!==t.memoizedState?(t.child=e.child,t.flags|=128,null):(i=a.fallback,o=t.mode,a=Fc({mode:"visible",children:a.children},o,0,null),(i=zc(i,o,s,null)).flags|=2,a.return=t,i.return=t,a.sibling=i,t.child=a,1&t.mode&&ko(t,e.child,null,s),t.child.memoizedState=Fs(s),t.memoizedState=zs,i);if(!(1&t.mode))return js(e,t,s,null);if("$!"===o.data){if(a=o.nextSibling&&o.nextSibling.dataset)var l=a.dgst;return a=l,js(e,t,s,a=ds(i=Error(n(419)),a,void 0))}if(l=0!==(s&e.childLanes),ws||l){if(null!==(a=Il)){switch(s&-s){case 4:o=2;break;case 16:o=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:o=32;break;case 536870912:o=268435456;break;default:o=0}0!==(o=0!==(o&(a.suspendedLanes|s))?0:o)&&o!==i.retryLane&&(i.retryLane=o,zo(e,o),rc(a,e,o,-1))}return gc(),js(e,t,s,a=ds(Error(n(421))))}return"$?"===o.data?(t.flags|=128,t.child=e.child,t=Rc.bind(null,e),o._reactRetry=t,null):(e=i.treeContext,ao=ua(o.nextSibling),ro=t,oo=!0,io=null,null!==e&&(Ga[Qa++]=Xa,Ga[Qa++]=Ja,Ga[Qa++]=Ya,Xa=e.id,Ja=e.overflow,Ya=t),t=$s(t,a.children),t.flags|=4096,t)}(e,t,l,o,a,i,r);if(s){s=o.fallback,l=t.mode,a=(i=e.child).sibling;var c={mode:"hidden",children:o.children};return 1&l||t.child===i?(o=Dc(i,c)).subtreeFlags=14680064&i.subtreeFlags:((o=t.child).childLanes=0,o.pendingProps=c,t.deletions=null),null!==a?s=Dc(a,s):(s=zc(s,l,r,null)).flags|=2,s.return=t,o.return=t,o.sibling=s,t.child=o,o=s,s=t.child,l=null===(l=e.child.memoizedState)?Fs(r):{baseLanes:l.baseLanes|r,cachePool:null,transitions:l.transitions},s.memoizedState=l,s.childLanes=e.childLanes&~r,t.memoizedState=zs,o}return e=(s=e.child).sibling,o=Dc(s,{mode:"visible",children:o.children}),!(1&t.mode)&&(o.lanes=r),o.return=t,o.sibling=null,null!==e&&(null===(r=t.deletions)?(t.deletions=[e],t.flags|=16):r.push(e)),t.child=o,t.memoizedState=null,o}function $s(e,t){return(t=Fc({mode:"visible",children:t},e.mode,0,null)).return=e,e.child=t}function js(e,t,n,r){return null!==r&&go(r),ko(t,e.child,null,n),(e=$s(t,t.pendingProps.children)).flags|=2,t.memoizedState=null,e}function Us(e,t,n){e.lanes|=t;var r=e.alternate;null!==r&&(r.lanes|=t),Io(e.return,t,n)}function Bs(e,t,n,r,a){var o=e.memoizedState;null===o?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=a)}function Ws(e,t,n){var r=t.pendingProps,a=r.revealOrder,o=r.tail;if(Ss(e,t,r.children,n),2&(r=ti.current))r=1&r|2,t.flags|=128;else{if(null!==e&&128&e.flags)e:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&Us(e,n,t);else if(19===e.tag)Us(e,n,t);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;null===e.sibling;){if(null===e.return||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(Ma(ti,r),1&t.mode)switch(a){case"forwards":for(n=t.child,a=null;null!==n;)null!==(e=n.alternate)&&null===ni(e)&&(a=n),n=n.sibling;null===(n=a)?(a=t.child,t.child=null):(a=n.sibling,n.sibling=null),Bs(t,!1,a,n,o);break;case"backwards":for(n=null,a=t.child,t.child=null;null!==a;){if(null!==(e=a.alternate)&&null===ni(e)){t.child=a;break}e=a.sibling,a.sibling=n,n=a,a=e}Bs(t,!0,n,null,o);break;case"together":Bs(t,!1,null,null,void 0);break;default:t.memoizedState=null}else t.memoizedState=null;return t.child}function Vs(e,t){!(1&t.mode)&&null!==e&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Hs(e,t,r){if(null!==e&&(t.dependencies=e.dependencies),Fl|=t.lanes,0===(r&t.childLanes))return null;if(null!==e&&t.child!==e.child)throw Error(n(153));if(null!==t.child){for(r=Dc(e=t.child,e.pendingProps),t.child=r,r.return=t;null!==e.sibling;)e=e.sibling,(r=r.sibling=Dc(e,e.pendingProps)).return=t;r.sibling=null}return t.child}function Ks(e,t){if(!oo)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;null!==t;)null!==t.alternate&&(n=t),t=t.sibling;null===n?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;null!==n;)null!==n.alternate&&(r=n),n=n.sibling;null===r?t||null===e.tail?e.tail=null:e.tail.sibling=null:r.sibling=null}}function qs(e){var t=null!==e.alternate&&e.alternate.child===e.child,n=0,r=0;if(t)for(var a=e.child;null!==a;)n|=a.lanes|a.childLanes,r|=14680064&a.subtreeFlags,r|=14680064&a.flags,a.return=e,a=a.sibling;else for(a=e.child;null!==a;)n|=a.lanes|a.childLanes,r|=a.subtreeFlags,r|=a.flags,a.return=e,a=a.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Gs(e,t,r){var o=t.pendingProps;switch(no(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return qs(t),null;case 1:case 17:return Ta(t.type)&&Da(),qs(t),null;case 3:return o=t.stateNode,Jo(),_a(Ia),_a(Aa),ai(),o.pendingContext&&(o.context=o.pendingContext,o.pendingContext=null),null!==e&&null!==e.child||(ho(t)?t.flags|=4:null===e||e.memoizedState.isDehydrated&&!(256&t.flags)||(t.flags|=1024,null!==io&&(sc(io),io=null))),Ts(e,t),qs(t),null;case 5:ei(t);var i=Yo(Qo.current);if(r=t.type,null!==e&&null!=t.stateNode)Ds(e,t,r,o,i),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!o){if(null===t.stateNode)throw Error(n(166));return qs(t),null}if(e=Yo(qo.current),ho(t)){o=t.stateNode,r=t.type;var s=t.memoizedProps;switch(o[ha]=t,o[pa]=s,e=!!(1&t.mode),r){case"dialog":jr("cancel",o),jr("close",o);break;case"iframe":case"object":case"embed":jr("load",o);break;case"video":case"audio":for(i=0;i<zr.length;i++)jr(zr[i],o);break;case"source":jr("error",o);break;case"img":case"image":case"link":jr("error",o),jr("load",o);break;case"details":jr("toggle",o);break;case"input":X(o,s),jr("invalid",o);break;case"select":o._wrapperState={wasMultiple:!!s.multiple},jr("invalid",o);break;case"textarea":oe(o,s),jr("invalid",o)}for(var l in be(r,s),i=null,s)if(s.hasOwnProperty(l)){var c=s[l];"children"===l?"string"==typeof c?o.textContent!==c&&(!0!==s.suppressHydrationWarning&&Zr(o.textContent,c,e),i=["children",c]):"number"==typeof c&&o.textContent!==""+c&&(!0!==s.suppressHydrationWarning&&Zr(o.textContent,c,e),i=["children",""+c]):a.hasOwnProperty(l)&&null!=c&&"onScroll"===l&&jr("scroll",o)}switch(r){case"input":q(o),ee(o,s,!0);break;case"textarea":q(o),se(o);break;case"select":case"option":break;default:"function"==typeof s.onClick&&(o.onclick=ea)}o=i,t.updateQueue=o,null!==o&&(t.flags|=4)}else{l=9===i.nodeType?i:i.ownerDocument,"http://www.w3.org/1999/xhtml"===e&&(e=le(r)),"http://www.w3.org/1999/xhtml"===e?"script"===r?((e=l.createElement("div")).innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):"string"==typeof o.is?e=l.createElement(r,{is:o.is}):(e=l.createElement(r),"select"===r&&(l=e,o.multiple?l.multiple=!0:o.size&&(l.size=o.size))):e=l.createElementNS(e,r),e[ha]=t,e[pa]=o,Ls(e,t,!1,!1),t.stateNode=e;e:{switch(l=we(r,o),r){case"dialog":jr("cancel",e),jr("close",e),i=o;break;case"iframe":case"object":case"embed":jr("load",e),i=o;break;case"video":case"audio":for(i=0;i<zr.length;i++)jr(zr[i],e);i=o;break;case"source":jr("error",e),i=o;break;case"img":case"image":case"link":jr("error",e),jr("load",e),i=o;break;case"details":jr("toggle",e),i=o;break;case"input":X(e,o),i=Y(e,o),jr("invalid",e);break;case"option":default:i=o;break;case"select":e._wrapperState={wasMultiple:!!o.multiple},i=O({},o,{value:void 0}),jr("invalid",e);break;case"textarea":oe(e,o),i=ae(e,o),jr("invalid",e)}for(s in be(r,i),c=i)if(c.hasOwnProperty(s)){var u=c[s];"style"===s?ye(e,u):"dangerouslySetInnerHTML"===s?null!=(u=u?u.__html:void 0)&&fe(e,u):"children"===s?"string"==typeof u?("textarea"!==r||""!==u)&&he(e,u):"number"==typeof u&&he(e,""+u):"suppressContentEditableWarning"!==s&&"suppressHydrationWarning"!==s&&"autoFocus"!==s&&(a.hasOwnProperty(s)?null!=u&&"onScroll"===s&&jr("scroll",e):null!=u&&b(e,s,u,l))}switch(r){case"input":q(e),ee(e,o,!1);break;case"textarea":q(e),se(e);break;case"option":null!=o.value&&e.setAttribute("value",""+H(o.value));break;case"select":e.multiple=!!o.multiple,null!=(s=o.value)?re(e,!!o.multiple,s,!1):null!=o.defaultValue&&re(e,!!o.multiple,o.defaultValue,!0);break;default:"function"==typeof i.onClick&&(e.onclick=ea)}switch(r){case"button":case"input":case"select":case"textarea":o=!!o.autoFocus;break e;case"img":o=!0;break e;default:o=!1}}o&&(t.flags|=4)}null!==t.ref&&(t.flags|=512,t.flags|=2097152)}return qs(t),null;case 6:if(e&&null!=t.stateNode)Ns(e,t,e.memoizedProps,o);else{if("string"!=typeof o&&null===t.stateNode)throw Error(n(166));if(r=Yo(Qo.current),Yo(qo.current),ho(t)){if(o=t.stateNode,r=t.memoizedProps,o[ha]=t,(s=o.nodeValue!==r)&&null!==(e=ro))switch(e.tag){case 3:Zr(o.nodeValue,r,!!(1&e.mode));break;case 5:!0!==e.memoizedProps.suppressHydrationWarning&&Zr(o.nodeValue,r,!!(1&e.mode))}s&&(t.flags|=4)}else(o=(9===r.nodeType?r:r.ownerDocument).createTextNode(o))[ha]=t,t.stateNode=o}return qs(t),null;case 13:if(_a(ti),o=t.memoizedState,null===e||null!==e.memoizedState&&null!==e.memoizedState.dehydrated){if(oo&&null!==ao&&1&t.mode&&!(128&t.flags))po(),mo(),t.flags|=98560,s=!1;else if(s=ho(t),null!==o&&null!==o.dehydrated){if(null===e){if(!s)throw Error(n(318));if(!(s=null!==(s=t.memoizedState)?s.dehydrated:null))throw Error(n(317));s[ha]=t}else mo(),!(128&t.flags)&&(t.memoizedState=null),t.flags|=4;qs(t),s=!1}else null!==io&&(sc(io),io=null),s=!0;if(!s)return 65536&t.flags?t:null}return 128&t.flags?(t.lanes=r,t):((o=null!==o)!==(null!==e&&null!==e.memoizedState)&&o&&(t.child.flags|=8192,1&t.mode&&(null===e||1&ti.current?0===Nl&&(Nl=3):gc())),null!==t.updateQueue&&(t.flags|=4),qs(t),null);case 4:return Jo(),Ts(e,t),null===e&&Wr(t.stateNode.containerInfo),qs(t),null;case 10:return Ao(t.type._context),qs(t),null;case 19:if(_a(ti),null===(s=t.memoizedState))return qs(t),null;if(o=!!(128&t.flags),null===(l=s.rendering))if(o)Ks(s,!1);else{if(0!==Nl||null!==e&&128&e.flags)for(e=t.child;null!==e;){if(null!==(l=ni(e))){for(t.flags|=128,Ks(s,!1),null!==(o=l.updateQueue)&&(t.updateQueue=o,t.flags|=4),t.subtreeFlags=0,o=r,r=t.child;null!==r;)e=o,(s=r).flags&=14680066,null===(l=s.alternate)?(s.childLanes=0,s.lanes=e,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=l.childLanes,s.lanes=l.lanes,s.child=l.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=l.memoizedProps,s.memoizedState=l.memoizedState,s.updateQueue=l.updateQueue,s.type=l.type,e=l.dependencies,s.dependencies=null===e?null:{lanes:e.lanes,firstContext:e.firstContext}),r=r.sibling;return Ma(ti,1&ti.current|2),t.child}e=e.sibling}null!==s.tail&&Je()>Wl&&(t.flags|=128,o=!0,Ks(s,!1),t.lanes=4194304)}else{if(!o)if(null!==(e=ni(l))){if(t.flags|=128,o=!0,null!==(r=e.updateQueue)&&(t.updateQueue=r,t.flags|=4),Ks(s,!0),null===s.tail&&"hidden"===s.tailMode&&!l.alternate&&!oo)return qs(t),null}else 2*Je()-s.renderingStartTime>Wl&&1073741824!==r&&(t.flags|=128,o=!0,Ks(s,!1),t.lanes=4194304);s.isBackwards?(l.sibling=t.child,t.child=l):(null!==(r=s.last)?r.sibling=l:t.child=l,s.last=l)}return null!==s.tail?(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=Je(),t.sibling=null,r=ti.current,Ma(ti,o?1&r|2:1&r),t):(qs(t),null);case 22:case 23:return fc(),o=null!==t.memoizedState,null!==e&&null!==e.memoizedState!==o&&(t.flags|=8192),o&&1&t.mode?!!(1073741824&Tl)&&(qs(t),6&t.subtreeFlags&&(t.flags|=8192)):qs(t),null;case 24:case 25:return null}throw Error(n(156,t.tag))}function Qs(e,t){switch(no(t),t.tag){case 1:return Ta(t.type)&&Da(),65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 3:return Jo(),_a(Ia),_a(Aa),ai(),65536&(e=t.flags)&&!(128&e)?(t.flags=-65537&e|128,t):null;case 5:return ei(t),null;case 13:if(_a(ti),null!==(e=t.memoizedState)&&null!==e.dehydrated){if(null===t.alternate)throw Error(n(340));mo()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 19:return _a(ti),null;case 4:return Jo(),null;case 10:return Ao(t.type._context),null;case 22:case 23:return fc(),null;default:return null}}Ls=function(e,t){for(var n=t.child;null!==n;){if(5===n.tag||6===n.tag)e.appendChild(n.stateNode);else if(4!==n.tag&&null!==n.child){n.child.return=n,n=n.child;continue}if(n===t)break;for(;null===n.sibling;){if(null===n.return||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}},Ts=function(){},Ds=function(e,t,n,r){var o=e.memoizedProps;if(o!==r){e=t.stateNode,Yo(qo.current);var i,s=null;switch(n){case"input":o=Y(e,o),r=Y(e,r),s=[];break;case"select":o=O({},o,{value:void 0}),r=O({},r,{value:void 0}),s=[];break;case"textarea":o=ae(e,o),r=ae(e,r),s=[];break;default:"function"!=typeof o.onClick&&"function"==typeof r.onClick&&(e.onclick=ea)}for(u in be(n,r),n=null,o)if(!r.hasOwnProperty(u)&&o.hasOwnProperty(u)&&null!=o[u])if("style"===u){var l=o[u];for(i in l)l.hasOwnProperty(i)&&(n||(n={}),n[i]="")}else"dangerouslySetInnerHTML"!==u&&"children"!==u&&"suppressContentEditableWarning"!==u&&"suppressHydrationWarning"!==u&&"autoFocus"!==u&&(a.hasOwnProperty(u)?s||(s=[]):(s=s||[]).push(u,null));for(u in r){var c=r[u];if(l=null!=o?o[u]:void 0,r.hasOwnProperty(u)&&c!==l&&(null!=c||null!=l))if("style"===u)if(l){for(i in l)!l.hasOwnProperty(i)||c&&c.hasOwnProperty(i)||(n||(n={}),n[i]="");for(i in c)c.hasOwnProperty(i)&&l[i]!==c[i]&&(n||(n={}),n[i]=c[i])}else n||(s||(s=[]),s.push(u,n)),n=c;else"dangerouslySetInnerHTML"===u?(c=c?c.__html:void 0,l=l?l.__html:void 0,null!=c&&l!==c&&(s=s||[]).push(u,c)):"children"===u?"string"!=typeof c&&"number"!=typeof c||(s=s||[]).push(u,""+c):"suppressContentEditableWarning"!==u&&"suppressHydrationWarning"!==u&&(a.hasOwnProperty(u)?(null!=c&&"onScroll"===u&&jr("scroll",e),s||l===c||(s=[])):(s=s||[]).push(u,c))}n&&(s=s||[]).push("style",n);var u=s;(t.updateQueue=u)&&(t.flags|=4)}},Ns=function(e,t,n,r){n!==r&&(t.flags|=4)};var Ys=!1,Xs=!1,Js="function"==typeof WeakSet?WeakSet:Set,Zs=null;function el(e,t){var n=e.ref;if(null!==n)if("function"==typeof n)try{n(null)}catch(n){Ec(e,t,n)}else n.current=null}function tl(e,t,n){try{n()}catch(n){Ec(e,t,n)}}var nl=!1;function rl(e,t,n){var r=t.updateQueue;if(null!==(r=null!==r?r.lastEffect:null)){var a=r=r.next;do{if((a.tag&e)===e){var o=a.destroy;a.destroy=void 0,void 0!==o&&tl(t,n,o)}a=a.next}while(a!==r)}}function al(e,t){if(null!==(t=null!==(t=t.updateQueue)?t.lastEffect:null)){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function ol(e){var t=e.ref;if(null!==t){var n=e.stateNode;e.tag,e=n,"function"==typeof t?t(e):t.current=e}}function il(e){var t=e.alternate;null!==t&&(e.alternate=null,il(t)),e.child=null,e.deletions=null,e.sibling=null,5===e.tag&&(null!==(t=e.stateNode)&&(delete t[ha],delete t[pa],delete t[ga],delete t[ya],delete t[va])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function sl(e){return 5===e.tag||3===e.tag||4===e.tag}function ll(e){e:for(;;){for(;null===e.sibling;){if(null===e.return||sl(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;5!==e.tag&&6!==e.tag&&18!==e.tag;){if(2&e.flags)continue e;if(null===e.child||4===e.tag)continue e;e.child.return=e,e=e.child}if(!(2&e.flags))return e.stateNode}}function cl(e,t,n){var r=e.tag;if(5===r||6===r)e=e.stateNode,t?8===n.nodeType?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(8===n.nodeType?(t=n.parentNode).insertBefore(e,n):(t=n).appendChild(e),null!=(n=n._reactRootContainer)||null!==t.onclick||(t.onclick=ea));else if(4!==r&&null!==(e=e.child))for(cl(e,t,n),e=e.sibling;null!==e;)cl(e,t,n),e=e.sibling}function ul(e,t,n){var r=e.tag;if(5===r||6===r)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(4!==r&&null!==(e=e.child))for(ul(e,t,n),e=e.sibling;null!==e;)ul(e,t,n),e=e.sibling}var dl=null,fl=!1;function hl(e,t,n){for(n=n.child;null!==n;)pl(e,t,n),n=n.sibling}function pl(e,t,n){if(it&&"function"==typeof it.onCommitFiberUnmount)try{it.onCommitFiberUnmount(ot,n)}catch(e){}switch(n.tag){case 5:Xs||el(n,t);case 6:var r=dl,a=fl;dl=null,hl(e,t,n),fl=a,null!==(dl=r)&&(fl?(e=dl,n=n.stateNode,8===e.nodeType?e.parentNode.removeChild(n):e.removeChild(n)):dl.removeChild(n.stateNode));break;case 18:null!==dl&&(fl?(e=dl,n=n.stateNode,8===e.nodeType?ca(e.parentNode,n):1===e.nodeType&&ca(e,n),Wt(e)):ca(dl,n.stateNode));break;case 4:r=dl,a=fl,dl=n.stateNode.containerInfo,fl=!0,hl(e,t,n),dl=r,fl=a;break;case 0:case 11:case 14:case 15:if(!Xs&&(null!==(r=n.updateQueue)&&null!==(r=r.lastEffect))){a=r=r.next;do{var o=a,i=o.destroy;o=o.tag,void 0!==i&&(2&o||4&o)&&tl(n,t,i),a=a.next}while(a!==r)}hl(e,t,n);break;case 1:if(!Xs&&(el(n,t),"function"==typeof(r=n.stateNode).componentWillUnmount))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(e){Ec(n,t,e)}hl(e,t,n);break;case 21:hl(e,t,n);break;case 22:1&n.mode?(Xs=(r=Xs)||null!==n.memoizedState,hl(e,t,n),Xs=r):hl(e,t,n);break;default:hl(e,t,n)}}function ml(e){var t=e.updateQueue;if(null!==t){e.updateQueue=null;var n=e.stateNode;null===n&&(n=e.stateNode=new Js),t.forEach(function(t){var r=Ac.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))})}}function gl(e,t){var r=t.deletions;if(null!==r)for(var a=0;a<r.length;a++){var o=r[a];try{var i=e,s=t,l=s;e:for(;null!==l;){switch(l.tag){case 5:dl=l.stateNode,fl=!1;break e;case 3:case 4:dl=l.stateNode.containerInfo,fl=!0;break e}l=l.return}if(null===dl)throw Error(n(160));pl(i,s,o),dl=null,fl=!1;var c=o.alternate;null!==c&&(c.return=null),o.return=null}catch(e){Ec(o,t,e)}}if(12854&t.subtreeFlags)for(t=t.child;null!==t;)yl(t,e),t=t.sibling}function yl(e,t){var r=e.alternate,a=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(gl(t,e),vl(e),4&a){try{rl(3,e,e.return),al(3,e)}catch(t){Ec(e,e.return,t)}try{rl(5,e,e.return)}catch(t){Ec(e,e.return,t)}}break;case 1:gl(t,e),vl(e),512&a&&null!==r&&el(r,r.return);break;case 5:if(gl(t,e),vl(e),512&a&&null!==r&&el(r,r.return),32&e.flags){var o=e.stateNode;try{he(o,"")}catch(t){Ec(e,e.return,t)}}if(4&a&&null!=(o=e.stateNode)){var i=e.memoizedProps,s=null!==r?r.memoizedProps:i,l=e.type,c=e.updateQueue;if(e.updateQueue=null,null!==c)try{"input"===l&&"radio"===i.type&&null!=i.name&&J(o,i),we(l,s);var u=we(l,i);for(s=0;s<c.length;s+=2){var d=c[s],f=c[s+1];"style"===d?ye(o,f):"dangerouslySetInnerHTML"===d?fe(o,f):"children"===d?he(o,f):b(o,d,f,u)}switch(l){case"input":Z(o,i);break;case"textarea":ie(o,i);break;case"select":var h=o._wrapperState.wasMultiple;o._wrapperState.wasMultiple=!!i.multiple;var p=i.value;null!=p?re(o,!!i.multiple,p,!1):h!==!!i.multiple&&(null!=i.defaultValue?re(o,!!i.multiple,i.defaultValue,!0):re(o,!!i.multiple,i.multiple?[]:"",!1))}o[pa]=i}catch(t){Ec(e,e.return,t)}}break;case 6:if(gl(t,e),vl(e),4&a){if(null===e.stateNode)throw Error(n(162));o=e.stateNode,i=e.memoizedProps;try{o.nodeValue=i}catch(t){Ec(e,e.return,t)}}break;case 3:if(gl(t,e),vl(e),4&a&&null!==r&&r.memoizedState.isDehydrated)try{Wt(t.containerInfo)}catch(t){Ec(e,e.return,t)}break;case 4:default:gl(t,e),vl(e);break;case 13:gl(t,e),vl(e),8192&(o=e.child).flags&&(i=null!==o.memoizedState,o.stateNode.isHidden=i,!i||null!==o.alternate&&null!==o.alternate.memoizedState||(Bl=Je())),4&a&&ml(e);break;case 22:if(d=null!==r&&null!==r.memoizedState,1&e.mode?(Xs=(u=Xs)||d,gl(t,e),Xs=u):gl(t,e),vl(e),8192&a){if(u=null!==e.memoizedState,(e.stateNode.isHidden=u)&&!d&&1&e.mode)for(Zs=e,d=e.child;null!==d;){for(f=Zs=d;null!==Zs;){switch(p=(h=Zs).child,h.tag){case 0:case 11:case 14:case 15:rl(4,h,h.return);break;case 1:el(h,h.return);var m=h.stateNode;if("function"==typeof m.componentWillUnmount){a=h,r=h.return;try{t=a,m.props=t.memoizedProps,m.state=t.memoizedState,m.componentWillUnmount()}catch(e){Ec(a,r,e)}}break;case 5:el(h,h.return);break;case 22:if(null!==h.memoizedState){kl(f);continue}}null!==p?(p.return=h,Zs=p):kl(f)}d=d.sibling}e:for(d=null,f=e;;){if(5===f.tag){if(null===d){d=f;try{o=f.stateNode,u?"function"==typeof(i=o.style).setProperty?i.setProperty("display","none","important"):i.display="none":(l=f.stateNode,s=null!=(c=f.memoizedProps.style)&&c.hasOwnProperty("display")?c.display:null,l.style.display=ge("display",s))}catch(t){Ec(e,e.return,t)}}}else if(6===f.tag){if(null===d)try{f.stateNode.nodeValue=u?"":f.memoizedProps}catch(t){Ec(e,e.return,t)}}else if((22!==f.tag&&23!==f.tag||null===f.memoizedState||f===e)&&null!==f.child){f.child.return=f,f=f.child;continue}if(f===e)break e;for(;null===f.sibling;){if(null===f.return||f.return===e)break e;d===f&&(d=null),f=f.return}d===f&&(d=null),f.sibling.return=f.return,f=f.sibling}}break;case 19:gl(t,e),vl(e),4&a&&ml(e);case 21:}}function vl(e){var t=e.flags;if(2&t){try{e:{for(var r=e.return;null!==r;){if(sl(r)){var a=r;break e}r=r.return}throw Error(n(160))}switch(a.tag){case 5:var o=a.stateNode;32&a.flags&&(he(o,""),a.flags&=-33),ul(e,ll(e),o);break;case 3:case 4:var i=a.stateNode.containerInfo;cl(e,ll(e),i);break;default:throw Error(n(161))}}catch(t){Ec(e,e.return,t)}e.flags&=-3}4096&t&&(e.flags&=-4097)}function bl(e,t,n){Zs=e,wl(e)}function wl(e,t,n){for(var r=!!(1&e.mode);null!==Zs;){var a=Zs,o=a.child;if(22===a.tag&&r){var i=null!==a.memoizedState||Ys;if(!i){var s=a.alternate,l=null!==s&&null!==s.memoizedState||Xs;s=Ys;var c=Xs;if(Ys=i,(Xs=l)&&!c)for(Zs=a;null!==Zs;)l=(i=Zs).child,22===i.tag&&null!==i.memoizedState?xl(a):null!==l?(l.return=i,Zs=l):xl(a);for(;null!==o;)Zs=o,wl(o),o=o.sibling;Zs=a,Ys=s,Xs=c}Sl(e)}else 8772&a.subtreeFlags&&null!==o?(o.return=a,Zs=o):Sl(e)}}function Sl(e){for(;null!==Zs;){var t=Zs;if(8772&t.flags){var r=t.alternate;try{if(8772&t.flags)switch(t.tag){case 0:case 11:case 15:Xs||al(5,t);break;case 1:var a=t.stateNode;if(4&t.flags&&!Xs)if(null===r)a.componentDidMount();else{var o=t.elementType===t.type?r.memoizedProps:rs(t.type,r.memoizedProps);a.componentDidUpdate(o,r.memoizedState,a.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;null!==i&&Ho(t,i,a);break;case 3:var s=t.updateQueue;if(null!==s){if(r=null,null!==t.child)switch(t.child.tag){case 5:case 1:r=t.child.stateNode}Ho(t,s,r)}break;case 5:var l=t.stateNode;if(null===r&&4&t.flags){r=l;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&r.focus();break;case"img":c.src&&(r.src=c.src)}}break;case 6:case 4:case 12:case 19:case 17:case 21:case 22:case 23:case 25:break;case 13:if(null===t.memoizedState){var u=t.alternate;if(null!==u){var d=u.memoizedState;if(null!==d){var f=d.dehydrated;null!==f&&Wt(f)}}}break;default:throw Error(n(163))}Xs||512&t.flags&&ol(t)}catch(e){Ec(t,t.return,e)}}if(t===e){Zs=null;break}if(null!==(r=t.sibling)){r.return=t.return,Zs=r;break}Zs=t.return}}function kl(e){for(;null!==Zs;){var t=Zs;if(t===e){Zs=null;break}var n=t.sibling;if(null!==n){n.return=t.return,Zs=n;break}Zs=t.return}}function xl(e){for(;null!==Zs;){var t=Zs;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{al(4,t)}catch(e){Ec(t,n,e)}break;case 1:var r=t.stateNode;if("function"==typeof r.componentDidMount){var a=t.return;try{r.componentDidMount()}catch(e){Ec(t,a,e)}}var o=t.return;try{ol(t)}catch(e){Ec(t,o,e)}break;case 5:var i=t.return;try{ol(t)}catch(e){Ec(t,i,e)}}}catch(e){Ec(t,t.return,e)}if(t===e){Zs=null;break}var s=t.sibling;if(null!==s){s.return=t.return,Zs=s;break}Zs=t.return}}var Cl,El=Math.ceil,_l=w.ReactCurrentDispatcher,Ml=w.ReactCurrentOwner,Rl=w.ReactCurrentBatchConfig,Al=0,Il=null,Pl=null,Ll=0,Tl=0,Dl=Ea(0),Nl=0,zl=null,Fl=0,Ol=0,$l=0,jl=null,Ul=null,Bl=0,Wl=1/0,Vl=null,Hl=!1,Kl=null,ql=null,Gl=!1,Ql=null,Yl=0,Xl=0,Jl=null,Zl=-1,ec=0;function tc(){return 6&Al?Je():-1!==Zl?Zl:Zl=Je()}function nc(e){return 1&e.mode?2&Al&&0!==Ll?Ll&-Ll:null!==yo.transition?(0===ec&&(ec=gt()),ec):0!==(e=wt)?e:e=void 0===(e=window.event)?16:Xt(e.type):1}function rc(e,t,r,a){if(50<Xl)throw Xl=0,Jl=null,Error(n(185));vt(e,r,a),2&Al&&e===Il||(e===Il&&(!(2&Al)&&(Ol|=r),4===Nl&&lc(e,Ll)),ac(e,a),1===r&&0===Al&&!(1&t.mode)&&(Wl=Je()+500,ja&&Wa()))}function ac(e,t){var n=e.callbackNode;!function(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,a=e.expirationTimes,o=e.pendingLanes;0<o;){var i=31-st(o),s=1<<i,l=a[i];-1===l?0!==(s&n)&&0===(s&r)||(a[i]=pt(s,t)):l<=t&&(e.expiredLanes|=s),o&=~s}}(e,t);var r=ht(e,e===Il?Ll:0);if(0===r)null!==n&&Qe(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(null!=n&&Qe(n),1===t)0===e.tag?function(e){ja=!0,Ba(e)}(cc.bind(null,e)):Ba(cc.bind(null,e)),sa(function(){!(6&Al)&&Wa()}),n=null;else{switch(St(r)){case 1:n=et;break;case 4:n=tt;break;case 16:default:n=nt;break;case 536870912:n=at}n=Ic(n,oc.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function oc(e,t){if(Zl=-1,ec=0,6&Al)throw Error(n(327));var r=e.callbackNode;if(xc()&&e.callbackNode!==r)return null;var a=ht(e,e===Il?Ll:0);if(0===a)return null;if(30&a||0!==(a&e.expiredLanes)||t)t=yc(e,a);else{t=a;var o=Al;Al|=2;var i=mc();for(Il===e&&Ll===t||(Vl=null,Wl=Je()+500,hc(e,t));;)try{bc();break}catch(t){pc(e,t)}Ro(),_l.current=i,Al=o,null!==Pl?t=0:(Il=null,Ll=0,t=Nl)}if(0!==t){if(2===t&&(0!==(o=mt(e))&&(a=o,t=ic(e,o))),1===t)throw r=zl,hc(e,0),lc(e,a),ac(e,Je()),r;if(6===t)lc(e,a);else{if(o=e.current.alternate,!(30&a||function(e){for(var t=e;;){if(16384&t.flags){var n=t.updateQueue;if(null!==n&&null!==(n=n.stores))for(var r=0;r<n.length;r++){var a=n[r],o=a.getSnapshot;a=a.value;try{if(!lr(o(),a))return!1}catch(e){return!1}}}if(n=t.child,16384&t.subtreeFlags&&null!==n)n.return=t,t=n;else{if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}(o)||(t=yc(e,a),2===t&&(i=mt(e),0!==i&&(a=i,t=ic(e,i))),1!==t)))throw r=zl,hc(e,0),lc(e,a),ac(e,Je()),r;switch(e.finishedWork=o,e.finishedLanes=a,t){case 0:case 1:throw Error(n(345));case 2:case 5:kc(e,Ul,Vl);break;case 3:if(lc(e,a),(130023424&a)===a&&10<(t=Bl+500-Je())){if(0!==ht(e,0))break;if(((o=e.suspendedLanes)&a)!==a){tc(),e.pingedLanes|=e.suspendedLanes&o;break}e.timeoutHandle=aa(kc.bind(null,e,Ul,Vl),t);break}kc(e,Ul,Vl);break;case 4:if(lc(e,a),(4194240&a)===a)break;for(t=e.eventTimes,o=-1;0<a;){var s=31-st(a);i=1<<s,(s=t[s])>o&&(o=s),a&=~i}if(a=o,10<(a=(120>(a=Je()-a)?120:480>a?480:1080>a?1080:1920>a?1920:3e3>a?3e3:4320>a?4320:1960*El(a/1960))-a)){e.timeoutHandle=aa(kc.bind(null,e,Ul,Vl),a);break}kc(e,Ul,Vl);break;default:throw Error(n(329))}}}return ac(e,Je()),e.callbackNode===r?oc.bind(null,e):null}function ic(e,t){var n=jl;return e.current.memoizedState.isDehydrated&&(hc(e,t).flags|=256),2!==(e=yc(e,t))&&(t=Ul,Ul=n,null!==t&&sc(t)),e}function sc(e){null===Ul?Ul=e:Ul.push.apply(Ul,e)}function lc(e,t){for(t&=~$l,t&=~Ol,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-st(t),r=1<<n;e[n]=-1,t&=~r}}function cc(e){if(6&Al)throw Error(n(327));xc();var t=ht(e,0);if(!(1&t))return ac(e,Je()),null;var r=yc(e,t);if(0!==e.tag&&2===r){var a=mt(e);0!==a&&(t=a,r=ic(e,a))}if(1===r)throw r=zl,hc(e,0),lc(e,t),ac(e,Je()),r;if(6===r)throw Error(n(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,kc(e,Ul,Vl),ac(e,Je()),null}function uc(e,t){var n=Al;Al|=1;try{return e(t)}finally{0===(Al=n)&&(Wl=Je()+500,ja&&Wa())}}function dc(e){null!==Ql&&0===Ql.tag&&!(6&Al)&&xc();var t=Al;Al|=1;var n=Rl.transition,r=wt;try{if(Rl.transition=null,wt=1,e)return e()}finally{wt=r,Rl.transition=n,!(6&(Al=t))&&Wa()}}function fc(){Tl=Dl.current,_a(Dl)}function hc(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(-1!==n&&(e.timeoutHandle=-1,oa(n)),null!==Pl)for(n=Pl.return;null!==n;){var r=n;switch(no(r),r.tag){case 1:null!=(r=r.type.childContextTypes)&&Da();break;case 3:Jo(),_a(Ia),_a(Aa),ai();break;case 5:ei(r);break;case 4:Jo();break;case 13:case 19:_a(ti);break;case 10:Ao(r.type._context);break;case 22:case 23:fc()}n=n.return}if(Il=e,Pl=e=Dc(e.current,null),Ll=Tl=t,Nl=0,zl=null,$l=Ol=Fl=0,Ul=jl=null,null!==To){for(t=0;t<To.length;t++)if(null!==(r=(n=To[t]).interleaved)){n.interleaved=null;var a=r.next,o=n.pending;if(null!==o){var i=o.next;o.next=a,r.next=i}n.pending=r}To=null}return e}function pc(e,t){for(;;){var r=Pl;try{if(Ro(),oi.current=Zi,di){for(var a=li.memoizedState;null!==a;){var o=a.queue;null!==o&&(o.pending=null),a=a.next}di=!1}if(si=0,ui=ci=li=null,fi=!1,hi=0,Ml.current=null,null===r||null===r.return){Nl=1,zl=t,Pl=null;break}e:{var i=e,s=r.return,l=r,c=t;if(t=Ll,l.flags|=32768,null!==c&&"object"==typeof c&&"function"==typeof c.then){var u=c,d=l,f=d.tag;if(!(1&d.mode||0!==f&&11!==f&&15!==f)){var h=d.alternate;h?(d.updateQueue=h.updateQueue,d.memoizedState=h.memoizedState,d.lanes=h.lanes):(d.updateQueue=null,d.memoizedState=null)}var p=ys(s);if(null!==p){p.flags&=-257,vs(p,s,l,0,t),1&p.mode&&gs(i,u,t),c=u;var m=(t=p).updateQueue;if(null===m){var g=new Set;g.add(c),t.updateQueue=g}else m.add(c);break e}if(!(1&t)){gs(i,u,t),gc();break e}c=Error(n(426))}else if(oo&&1&l.mode){var y=ys(s);if(null!==y){!(65536&y.flags)&&(y.flags|=256),vs(y,s,l,0,t),go(us(c,l));break e}}i=c=us(c,l),4!==Nl&&(Nl=2),null===jl?jl=[i]:jl.push(i),i=s;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t,Wo(i,ps(0,c,t));break e;case 1:l=c;var v=i.type,b=i.stateNode;if(!(128&i.flags||"function"!=typeof v.getDerivedStateFromError&&(null===b||"function"!=typeof b.componentDidCatch||null!==ql&&ql.has(b)))){i.flags|=65536,t&=-t,i.lanes|=t,Wo(i,ms(i,l,t));break e}}i=i.return}while(null!==i)}Sc(r)}catch(e){t=e,Pl===r&&null!==r&&(Pl=r=r.return);continue}break}}function mc(){var e=_l.current;return _l.current=Zi,null===e?Zi:e}function gc(){0!==Nl&&3!==Nl&&2!==Nl||(Nl=4),null===Il||!(268435455&Fl)&&!(268435455&Ol)||lc(Il,Ll)}function yc(e,t){var r=Al;Al|=2;var a=mc();for(Il===e&&Ll===t||(Vl=null,hc(e,t));;)try{vc();break}catch(t){pc(e,t)}if(Ro(),Al=r,_l.current=a,null!==Pl)throw Error(n(261));return Il=null,Ll=0,Nl}function vc(){for(;null!==Pl;)wc(Pl)}function bc(){for(;null!==Pl&&!Ye();)wc(Pl)}function wc(e){var t=Cl(e.alternate,e,Tl);e.memoizedProps=e.pendingProps,null===t?Sc(e):Pl=t,Ml.current=null}function Sc(e){var t=e;do{var n=t.alternate;if(e=t.return,32768&t.flags){if(null!==(n=Qs(n,t)))return n.flags&=32767,void(Pl=n);if(null===e)return Nl=6,void(Pl=null);e.flags|=32768,e.subtreeFlags=0,e.deletions=null}else if(null!==(n=Gs(n,t,Tl)))return void(Pl=n);if(null!==(t=t.sibling))return void(Pl=t);Pl=t=e}while(null!==t);0===Nl&&(Nl=5)}function kc(e,t,r){var a=wt,o=Rl.transition;try{Rl.transition=null,wt=1,function(e,t,r,a){do{xc()}while(null!==Ql);if(6&Al)throw Error(n(327));r=e.finishedWork;var o=e.finishedLanes;if(null===r)return null;if(e.finishedWork=null,e.finishedLanes=0,r===e.current)throw Error(n(177));e.callbackNode=null,e.callbackPriority=0;var i=r.lanes|r.childLanes;if(function(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var a=31-st(n),o=1<<a;t[a]=0,r[a]=-1,e[a]=-1,n&=~o}}(e,i),e===Il&&(Pl=Il=null,Ll=0),!(2064&r.subtreeFlags)&&!(2064&r.flags)||Gl||(Gl=!0,Ic(nt,function(){return xc(),null})),i=!!(15990&r.flags),!!(15990&r.subtreeFlags)||i){i=Rl.transition,Rl.transition=null;var s=wt;wt=1;var l=Al;Al|=4,Ml.current=null,function(e,t){if(ta=Ht,pr(e=hr())){if("selectionStart"in e)var r={start:e.selectionStart,end:e.selectionEnd};else e:{var a=(r=(r=e.ownerDocument)&&r.defaultView||window).getSelection&&r.getSelection();if(a&&0!==a.rangeCount){r=a.anchorNode;var o=a.anchorOffset,i=a.focusNode;a=a.focusOffset;try{r.nodeType,i.nodeType}catch(e){r=null;break e}var s=0,l=-1,c=-1,u=0,d=0,f=e,h=null;t:for(;;){for(var p;f!==r||0!==o&&3!==f.nodeType||(l=s+o),f!==i||0!==a&&3!==f.nodeType||(c=s+a),3===f.nodeType&&(s+=f.nodeValue.length),null!==(p=f.firstChild);)h=f,f=p;for(;;){if(f===e)break t;if(h===r&&++u===o&&(l=s),h===i&&++d===a&&(c=s),null!==(p=f.nextSibling))break;h=(f=h).parentNode}f=p}r=-1===l||-1===c?null:{start:l,end:c}}else r=null}r=r||{start:0,end:0}}else r=null;for(na={focusedElem:e,selectionRange:r},Ht=!1,Zs=t;null!==Zs;)if(e=(t=Zs).child,1028&t.subtreeFlags&&null!==e)e.return=t,Zs=e;else for(;null!==Zs;){t=Zs;try{var m=t.alternate;if(1024&t.flags)switch(t.tag){case 0:case 11:case 15:case 5:case 6:case 4:case 17:break;case 1:if(null!==m){var g=m.memoizedProps,y=m.memoizedState,v=t.stateNode,b=v.getSnapshotBeforeUpdate(t.elementType===t.type?g:rs(t.type,g),y);v.__reactInternalSnapshotBeforeUpdate=b}break;case 3:var w=t.stateNode.containerInfo;1===w.nodeType?w.textContent="":9===w.nodeType&&w.documentElement&&w.removeChild(w.documentElement);break;default:throw Error(n(163))}}catch(e){Ec(t,t.return,e)}if(null!==(e=t.sibling)){e.return=t.return,Zs=e;break}Zs=t.return}m=nl,nl=!1}(e,r),yl(r,e),mr(na),Ht=!!ta,na=ta=null,e.current=r,bl(r),Xe(),Al=l,wt=s,Rl.transition=i}else e.current=r;if(Gl&&(Gl=!1,Ql=e,Yl=o),i=e.pendingLanes,0===i&&(ql=null),function(e){if(it&&"function"==typeof it.onCommitFiberRoot)try{it.onCommitFiberRoot(ot,e,void 0,!(128&~e.current.flags))}catch(e){}}(r.stateNode),ac(e,Je()),null!==t)for(a=e.onRecoverableError,r=0;r<t.length;r++)o=t[r],a(o.value,{componentStack:o.stack,digest:o.digest});if(Hl)throw Hl=!1,e=Kl,Kl=null,e;!!(1&Yl)&&0!==e.tag&&xc(),i=e.pendingLanes,1&i?e===Jl?Xl++:(Xl=0,Jl=e):Xl=0,Wa()}(e,t,r,a)}finally{Rl.transition=o,wt=a}return null}function xc(){if(null!==Ql){var e=St(Yl),t=Rl.transition,r=wt;try{if(Rl.transition=null,wt=16>e?16:e,null===Ql)var a=!1;else{if(e=Ql,Ql=null,Yl=0,6&Al)throw Error(n(331));var o=Al;for(Al|=4,Zs=e.current;null!==Zs;){var i=Zs,s=i.child;if(16&Zs.flags){var l=i.deletions;if(null!==l){for(var c=0;c<l.length;c++){var u=l[c];for(Zs=u;null!==Zs;){var d=Zs;switch(d.tag){case 0:case 11:case 15:rl(8,d,i)}var f=d.child;if(null!==f)f.return=d,Zs=f;else for(;null!==Zs;){var h=(d=Zs).sibling,p=d.return;if(il(d),d===u){Zs=null;break}if(null!==h){h.return=p,Zs=h;break}Zs=p}}}var m=i.alternate;if(null!==m){var g=m.child;if(null!==g){m.child=null;do{var y=g.sibling;g.sibling=null,g=y}while(null!==g)}}Zs=i}}if(2064&i.subtreeFlags&&null!==s)s.return=i,Zs=s;else e:for(;null!==Zs;){if(2048&(i=Zs).flags)switch(i.tag){case 0:case 11:case 15:rl(9,i,i.return)}var v=i.sibling;if(null!==v){v.return=i.return,Zs=v;break e}Zs=i.return}}var b=e.current;for(Zs=b;null!==Zs;){var w=(s=Zs).child;if(2064&s.subtreeFlags&&null!==w)w.return=s,Zs=w;else e:for(s=b;null!==Zs;){if(2048&(l=Zs).flags)try{switch(l.tag){case 0:case 11:case 15:al(9,l)}}catch(e){Ec(l,l.return,e)}if(l===s){Zs=null;break e}var S=l.sibling;if(null!==S){S.return=l.return,Zs=S;break e}Zs=l.return}}if(Al=o,Wa(),it&&"function"==typeof it.onPostCommitFiberRoot)try{it.onPostCommitFiberRoot(ot,e)}catch(e){}a=!0}return a}finally{wt=r,Rl.transition=t}}return!1}function Cc(e,t,n){e=Uo(e,t=ps(0,t=us(n,t),1),1),t=tc(),null!==e&&(vt(e,1,t),ac(e,t))}function Ec(e,t,n){if(3===e.tag)Cc(e,e,n);else for(;null!==t;){if(3===t.tag){Cc(t,e,n);break}if(1===t.tag){var r=t.stateNode;if("function"==typeof t.type.getDerivedStateFromError||"function"==typeof r.componentDidCatch&&(null===ql||!ql.has(r))){t=Uo(t,e=ms(t,e=us(n,e),1),1),e=tc(),null!==t&&(vt(t,1,e),ac(t,e));break}}t=t.return}}function _c(e,t,n){var r=e.pingCache;null!==r&&r.delete(t),t=tc(),e.pingedLanes|=e.suspendedLanes&n,Il===e&&(Ll&n)===n&&(4===Nl||3===Nl&&(130023424&Ll)===Ll&&500>Je()-Bl?hc(e,0):$l|=n),ac(e,t)}function Mc(e,t){0===t&&(1&e.mode?(t=dt,!(130023424&(dt<<=1))&&(dt=4194304)):t=1);var n=tc();null!==(e=zo(e,t))&&(vt(e,t,n),ac(e,n))}function Rc(e){var t=e.memoizedState,n=0;null!==t&&(n=t.retryLane),Mc(e,n)}function Ac(e,t){var r=0;switch(e.tag){case 13:var a=e.stateNode,o=e.memoizedState;null!==o&&(r=o.retryLane);break;case 19:a=e.stateNode;break;default:throw Error(n(314))}null!==a&&a.delete(t),Mc(e,r)}function Ic(e,t){return Ge(e,t)}function Pc(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Lc(e,t,n,r){return new Pc(e,t,n,r)}function Tc(e){return!(!(e=e.prototype)||!e.isReactComponent)}function Dc(e,t){var n=e.alternate;return null===n?((n=Lc(e.tag,t,e.key,e.mode)).elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=14680064&e.flags,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Nc(e,t,r,a,o,i){var s=2;if(a=e,"function"==typeof e)Tc(e)&&(s=1);else if("string"==typeof e)s=5;else e:switch(e){case C:return zc(r.children,o,i,t);case E:s=8,o|=8;break;case _:return(e=Lc(12,r,t,2|o)).elementType=_,e.lanes=i,e;case I:return(e=Lc(13,r,t,o)).elementType=I,e.lanes=i,e;case P:return(e=Lc(19,r,t,o)).elementType=P,e.lanes=i,e;case D:return Fc(r,o,i,t);default:if("object"==typeof e&&null!==e)switch(e.$$typeof){case M:s=10;break e;case R:s=9;break e;case A:s=11;break e;case L:s=14;break e;case T:s=16,a=null;break e}throw Error(n(130,null==e?e:typeof e,""))}return(t=Lc(s,r,t,o)).elementType=e,t.type=a,t.lanes=i,t}function zc(e,t,n,r){return(e=Lc(7,e,r,t)).lanes=n,e}function Fc(e,t,n,r){return(e=Lc(22,e,r,t)).elementType=D,e.lanes=n,e.stateNode={isHidden:!1},e}function Oc(e,t,n){return(e=Lc(6,e,null,t)).lanes=n,e}function $c(e,t,n){return(t=Lc(4,null!==e.children?e.children:[],e.key,t)).lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function jc(e,t,n,r,a){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=yt(0),this.expirationTimes=yt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=yt(0),this.identifierPrefix=r,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function Uc(e,t,n,r,a,o,i,s,l){return e=new jc(e,t,n,s,l),1===t?(t=1,!0===o&&(t|=8)):t=0,o=Lc(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Oo(o),e}function Bc(e){if(!e)return Ra;e:{if(We(e=e._reactInternals)!==e||1!==e.tag)throw Error(n(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(Ta(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(null!==t);throw Error(n(171))}if(1===e.tag){var r=e.type;if(Ta(r))return za(e,r,t)}return t}function Wc(e,t,n,r,a,o,i,s,l){return(e=Uc(n,r,!0,e,0,o,0,s,l)).context=Bc(null),n=e.current,(o=jo(r=tc(),a=nc(n))).callback=null!=t?t:null,Uo(n,o,a),e.current.lanes=a,vt(e,a,r),ac(e,r),e}function Vc(e,t,n,r){var a=t.current,o=tc(),i=nc(a);return n=Bc(n),null===t.context?t.context=n:t.pendingContext=n,(t=jo(o,i)).payload={element:e},null!==(r=void 0===r?null:r)&&(t.callback=r),null!==(e=Uo(a,t,i))&&(rc(e,a,i,o),Bo(e,a,i)),i}function Hc(e){return(e=e.current).child?(e.child.tag,e.child.stateNode):null}function Kc(e,t){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var n=e.retryLane;e.retryLane=0!==n&&n<t?n:t}}function qc(e,t){Kc(e,t),(e=e.alternate)&&Kc(e,t)}Cl=function(e,t,r){if(null!==e)if(e.memoizedProps!==t.pendingProps||Ia.current)ws=!0;else{if(0===(e.lanes&r)&&!(128&t.flags))return ws=!1,function(e,t,n){switch(t.tag){case 3:Is(t),mo();break;case 5:Zo(t);break;case 1:Ta(t.type)&&Fa(t);break;case 4:Xo(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,a=t.memoizedProps.value;Ma(Co,r._currentValue),r._currentValue=a;break;case 13:if(null!==(r=t.memoizedState))return null!==r.dehydrated?(Ma(ti,1&ti.current),t.flags|=128,null):0!==(n&t.child.childLanes)?Os(e,t,n):(Ma(ti,1&ti.current),null!==(e=Hs(e,t,n))?e.sibling:null);Ma(ti,1&ti.current);break;case 19:if(r=0!==(n&t.childLanes),128&e.flags){if(r)return Ws(e,t,n);t.flags|=128}if(null!==(a=t.memoizedState)&&(a.rendering=null,a.tail=null,a.lastEffect=null),Ma(ti,ti.current),r)break;return null;case 22:case 23:return t.lanes=0,Es(e,t,n)}return Hs(e,t,n)}(e,t,r);ws=!!(131072&e.flags)}else ws=!1,oo&&1048576&t.flags&&eo(t,qa,t.index);switch(t.lanes=0,t.tag){case 2:var a=t.type;Vs(e,t),e=t.pendingProps;var o=La(t,Aa.current);Po(t,r),o=yi(null,t,a,e,o,r);var i=vi();return t.flags|=1,"object"==typeof o&&null!==o&&"function"==typeof o.render&&void 0===o.$$typeof?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Ta(a)?(i=!0,Fa(t)):i=!1,t.memoizedState=null!==o.state&&void 0!==o.state?o.state:null,Oo(t),o.updater=os,t.stateNode=o,o._reactInternals=t,cs(t,a,e,r),t=As(null,t,a,!0,i,r)):(t.tag=0,oo&&i&&to(t),Ss(null,t,o,r),t=t.child),t;case 16:a=t.elementType;e:{switch(Vs(e,t),e=t.pendingProps,a=(o=a._init)(a._payload),t.type=a,o=t.tag=function(e){if("function"==typeof e)return Tc(e)?1:0;if(null!=e){if((e=e.$$typeof)===A)return 11;if(e===L)return 14}return 2}(a),e=rs(a,e),o){case 0:t=Ms(null,t,a,e,r);break e;case 1:t=Rs(null,t,a,e,r);break e;case 11:t=ks(null,t,a,e,r);break e;case 14:t=xs(null,t,a,rs(a.type,e),r);break e}throw Error(n(306,a,""))}return t;case 0:return a=t.type,o=t.pendingProps,Ms(e,t,a,o=t.elementType===a?o:rs(a,o),r);case 1:return a=t.type,o=t.pendingProps,Rs(e,t,a,o=t.elementType===a?o:rs(a,o),r);case 3:e:{if(Is(t),null===e)throw Error(n(387));a=t.pendingProps,o=(i=t.memoizedState).element,$o(e,t),Vo(t,a,null,r);var s=t.memoizedState;if(a=s.element,i.isDehydrated){if(i={element:a,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=i,t.memoizedState=i,256&t.flags){t=Ps(e,t,a,r,o=us(Error(n(423)),t));break e}if(a!==o){t=Ps(e,t,a,r,o=us(Error(n(424)),t));break e}for(ao=ua(t.stateNode.containerInfo.firstChild),ro=t,oo=!0,io=null,r=xo(t,null,a,r),t.child=r;r;)r.flags=-3&r.flags|4096,r=r.sibling}else{if(mo(),a===o){t=Hs(e,t,r);break e}Ss(e,t,a,r)}t=t.child}return t;case 5:return Zo(t),null===e&&uo(t),a=t.type,o=t.pendingProps,i=null!==e?e.memoizedProps:null,s=o.children,ra(a,o)?s=null:null!==i&&ra(a,i)&&(t.flags|=32),_s(e,t),Ss(e,t,s,r),t.child;case 6:return null===e&&uo(t),null;case 13:return Os(e,t,r);case 4:return Xo(t,t.stateNode.containerInfo),a=t.pendingProps,null===e?t.child=ko(t,null,a,r):Ss(e,t,a,r),t.child;case 11:return a=t.type,o=t.pendingProps,ks(e,t,a,o=t.elementType===a?o:rs(a,o),r);case 7:return Ss(e,t,t.pendingProps,r),t.child;case 8:case 12:return Ss(e,t,t.pendingProps.children,r),t.child;case 10:e:{if(a=t.type._context,o=t.pendingProps,i=t.memoizedProps,s=o.value,Ma(Co,a._currentValue),a._currentValue=s,null!==i)if(lr(i.value,s)){if(i.children===o.children&&!Ia.current){t=Hs(e,t,r);break e}}else for(null!==(i=t.child)&&(i.return=t);null!==i;){var l=i.dependencies;if(null!==l){s=i.child;for(var c=l.firstContext;null!==c;){if(c.context===a){if(1===i.tag){(c=jo(-1,r&-r)).tag=2;var u=i.updateQueue;if(null!==u){var d=(u=u.shared).pending;null===d?c.next=c:(c.next=d.next,d.next=c),u.pending=c}}i.lanes|=r,null!==(c=i.alternate)&&(c.lanes|=r),Io(i.return,r,t),l.lanes|=r;break}c=c.next}}else if(10===i.tag)s=i.type===t.type?null:i.child;else if(18===i.tag){if(null===(s=i.return))throw Error(n(341));s.lanes|=r,null!==(l=s.alternate)&&(l.lanes|=r),Io(s,r,t),s=i.sibling}else s=i.child;if(null!==s)s.return=i;else for(s=i;null!==s;){if(s===t){s=null;break}if(null!==(i=s.sibling)){i.return=s.return,s=i;break}s=s.return}i=s}Ss(e,t,o.children,r),t=t.child}return t;case 9:return o=t.type,a=t.pendingProps.children,Po(t,r),a=a(o=Lo(o)),t.flags|=1,Ss(e,t,a,r),t.child;case 14:return o=rs(a=t.type,t.pendingProps),xs(e,t,a,o=rs(a.type,o),r);case 15:return Cs(e,t,t.type,t.pendingProps,r);case 17:return a=t.type,o=t.pendingProps,o=t.elementType===a?o:rs(a,o),Vs(e,t),t.tag=1,Ta(a)?(e=!0,Fa(t)):e=!1,Po(t,r),ss(t,a,o),cs(t,a,o,r),As(null,t,a,!0,e,r);case 19:return Ws(e,t,r);case 22:return Es(e,t,r)}throw Error(n(156,t.tag))};var Gc="function"==typeof reportError?reportError:function(e){console.error(e)};function Qc(e){this._internalRoot=e}function Yc(e){this._internalRoot=e}function Xc(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType)}function Jc(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType&&(8!==e.nodeType||" react-mount-point-unstable "!==e.nodeValue))}function Zc(){}function eu(e,t,n,r,a){var o=n._reactRootContainer;if(o){var i=o;if("function"==typeof a){var s=a;a=function(){var e=Hc(i);s.call(e)}}Vc(t,i,e,a)}else i=function(e,t,n,r,a){if(a){if("function"==typeof r){var o=r;r=function(){var e=Hc(i);o.call(e)}}var i=Wc(t,r,e,0,null,!1,0,"",Zc);return e._reactRootContainer=i,e[ma]=i.current,Wr(8===e.nodeType?e.parentNode:e),dc(),i}for(;a=e.lastChild;)e.removeChild(a);if("function"==typeof r){var s=r;r=function(){var e=Hc(l);s.call(e)}}var l=Uc(e,0,!1,null,0,!1,0,"",Zc);return e._reactRootContainer=l,e[ma]=l.current,Wr(8===e.nodeType?e.parentNode:e),dc(function(){Vc(t,l,n,r)}),l}(n,t,e,a,r);return Hc(i)}Yc.prototype.render=Qc.prototype.render=function(e){var t=this._internalRoot;if(null===t)throw Error(n(409));Vc(e,t,null,null)},Yc.prototype.unmount=Qc.prototype.unmount=function(){var e=this._internalRoot;if(null!==e){this._internalRoot=null;var t=e.containerInfo;dc(function(){Vc(null,e,null,null)}),t[ma]=null}},Yc.prototype.unstable_scheduleHydration=function(e){if(e){var t=Et();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Dt.length&&0!==t&&t<Dt[n].priority;n++);Dt.splice(n,0,e),0===n&&Ot(e)}},kt=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=ft(t.pendingLanes);0!==n&&(bt(t,1|n),ac(t,Je()),!(6&Al)&&(Wl=Je()+500,Wa()))}break;case 13:dc(function(){var t=zo(e,1);if(null!==t){var n=tc();rc(t,e,1,n)}}),qc(e,1)}},xt=function(e){if(13===e.tag){var t=zo(e,134217728);if(null!==t)rc(t,e,134217728,tc());qc(e,134217728)}},Ct=function(e){if(13===e.tag){var t=nc(e),n=zo(e,t);if(null!==n)rc(n,e,t,tc());qc(e,t)}},Et=function(){return wt},_t=function(e,t){var n=wt;try{return wt=e,t()}finally{wt=n}},xe=function(e,t,r){switch(t){case"input":if(Z(e,r),t=r.name,"radio"===r.type&&null!=t){for(r=e;r.parentNode;)r=r.parentNode;for(r=r.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<r.length;t++){var a=r[t];if(a!==e&&a.form===e.form){var o=ka(a);if(!o)throw Error(n(90));G(a),Z(a,o)}}}break;case"textarea":ie(e,r);break;case"select":null!=(t=r.value)&&re(e,!!r.multiple,t,!1)}},Ae=uc,Ie=dc;var tu={usingClientEntryPoint:!1,Events:[wa,Sa,ka,Me,Re,uc]},nu={findFiberByHostInstance:ba,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},ru={bundleType:nu.bundleType,version:nu.version,rendererPackageName:nu.rendererPackageName,rendererConfig:nu.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:w.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return null===(e=Ke(e))?null:e.stateNode},findFiberByHostInstance:nu.findFiberByHostInstance||function(){return null},findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__){var au=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!au.isDisabled&&au.supportsFiber)try{ot=au.inject(ru),it=au}catch(de){}}return v.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=tu,v.createPortal=function(e,t){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;if(!Xc(t))throw Error(n(200));return function(e,t,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return{$$typeof:x,key:null==r?null:""+r,children:e,containerInfo:t,implementation:n}}(e,t,null,r)},v.createRoot=function(e,t){if(!Xc(e))throw Error(n(299));var r=!1,a="",o=Gc;return null!=t&&(!0===t.unstable_strictMode&&(r=!0),void 0!==t.identifierPrefix&&(a=t.identifierPrefix),void 0!==t.onRecoverableError&&(o=t.onRecoverableError)),t=Uc(e,1,!1,null,0,r,0,a,o),e[ma]=t.current,Wr(8===e.nodeType?e.parentNode:e),new Qc(t)},v.findDOMNode=function(e){if(null==e)return null;if(1===e.nodeType)return e;var t=e._reactInternals;if(void 0===t){if("function"==typeof e.render)throw Error(n(188));throw e=Object.keys(e).join(","),Error(n(268,e))}return e=null===(e=Ke(t))?null:e.stateNode},v.flushSync=function(e){return dc(e)},v.hydrate=function(e,t,r){if(!Jc(t))throw Error(n(200));return eu(null,e,t,!0,r)},v.hydrateRoot=function(e,t,r){if(!Xc(e))throw Error(n(405));var a=null!=r&&r.hydratedSources||null,o=!1,i="",s=Gc;if(null!=r&&(!0===r.unstable_strictMode&&(o=!0),void 0!==r.identifierPrefix&&(i=r.identifierPrefix),void 0!==r.onRecoverableError&&(s=r.onRecoverableError)),t=Wc(t,null,e,1,null!=r?r:null,o,0,i,s),e[ma]=t.current,Wr(e),a)for(e=0;e<a.length;e++)o=(o=(r=a[e])._getVersion)(r._source),null==t.mutableSourceEagerHydrationData?t.mutableSourceEagerHydrationData=[r,o]:t.mutableSourceEagerHydrationData.push(r,o);return new Yc(t)},v.render=function(e,t,r){if(!Jc(t))throw Error(n(200));return eu(null,e,t,!1,r)},v.unmountComponentAtNode=function(e){if(!Jc(e))throw Error(n(40));return!!e._reactRootContainer&&(dc(function(){eu(null,null,e,!1,function(){e._reactRootContainer=null,e[ma]=null})}),!0)},v.unstable_batchedUpdates=uc,v.unstable_renderSubtreeIntoContainer=function(e,t,r,a){if(!Jc(r))throw Error(n(200));if(null==e||void 0===e._reactInternals)throw Error(n(38));return eu(e,t,r,!1,a)},v.version="18.3.1-next-f1338f8080-20240426",v}var x,C,E=function(){if(h)return g;h=1;var e=(f||(f=1,function e(){if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(e){console.error(e)}}(),y.exports=k()),y.exports);return g.createRoot=e.createRoot,g.hydrateRoot=e.hydrateRoot,g}(),_={exports:{}},M={};var R=(C||(C=1,_.exports=function(){if(x)return M;x=1;var e=l(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,a=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function i(e,n,i){var s,l={},c=null,u=null;for(s in void 0!==i&&(c=""+i),void 0!==n.key&&(c=""+n.key),void 0!==n.ref&&(u=n.ref),n)r.call(n,s)&&!o.hasOwnProperty(s)&&(l[s]=n[s]);if(e&&e.defaultProps)for(s in n=e.defaultProps)void 0===l[s]&&(l[s]=n[s]);return{$$typeof:t,type:e,key:c,ref:u,props:l,_owner:a.current}}return M.Fragment=n,M.jsx=i,M.jsxs=i,M}()),_.exports);function A(e){return{title:e.title||e.heading||"Document",snippet:e.content||"",relevance:e.score??0,documentId:e.documentId,fullContent:e.fullContent,downloadUrl:e.downloadUrl,documentName:e.documentName,sourceType:e.sourceType,chunkId:e.chunkId}}class I{constructor(e,t){this.baseUrl=e.replace(/\/$/,""),this.apiKey=t}async chat(e,t){const n=await fetch(`${this.baseUrl}/api/external/chat`,{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.apiKey},body:JSON.stringify({message:e,sessionId:t?.sessionId,context:t?.context})});if(!n.ok){const e=await n.json().catch(()=>({}));throw new Error(e.message||`HTTP ${n.status}: ${n.statusText}`)}const r=await n.json();return{...r,reply:r.reply||r.answer||"",sources:(r.sources||[]).map(A)}}async chatStream(e,t){const n=await fetch(`${this.baseUrl}/api/external/chat/stream`,{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.apiKey},body:JSON.stringify({message:e,sessionId:t?.sessionId,context:t?.context})});if(!n.ok){const e=await n.json().catch(()=>({}));throw new Error(e.message||`HTTP ${n.status}`)}const r=n.body?.getReader();if(!r)throw new Error("Streaming not supported");const a=new TextDecoder;let o,i,s="",l="",c=[];try{for(;;){const{done:e,value:n}=await r.read();if(e)break;s+=a.decode(n,{stream:!0});const u=s.split("\n");s=u.pop()||"";for(const e of u)if(e.startsWith("event: "));else if(e.startsWith("data: "))try{const n=JSON.parse(e.slice(6));void 0!==n.text?(l+=n.text,t.onToken?.(n.text)):void 0!==n.sources?(c=(n.sources||[]).map(A),t.onSources?.(c)):void 0!==n.sessionId&&(o=n.sessionId,i=n.messageId)}catch{}}t.onComplete?.({fullText:l,sessionId:o,messageId:i,sources:c})}catch(e){t.onError?.(e)}}async getGeneralDocs(e){const t=new URLSearchParams;e&&t.set("since",e);const n=`${this.baseUrl}/api/external/docs${t.toString()?"?"+t:""}`,r=await fetch(n,{headers:{"X-API-Key":this.apiKey}});if(!r.ok)throw new Error(`HTTP ${r.status}`);return((await r.json()).documents||[]).map(e=>({id:e.id,title:e.title||e.name||"Untitled",updatedAt:e.updatedAt||e.updated_at||(new Date).toISOString()}))}async getStatus(){const e=await fetch(`${this.baseUrl}/api/external/status`,{headers:{"X-API-Key":this.apiKey}});if(!e.ok)throw new Error(`HTTP ${e.status}`);const t=await e.json(),n=t.apiKey||t.key||{},r=n.scopes||n.permissions||["chat"],a=t.quota||{},o=a.perMinute||{limit:n.rateLimit?.limit||a.rateLimitPerMinute||30,remaining:n.rateLimit?.remaining??a.rateLimitPerMinute??30},i=a.perDay||{limit:a.rateLimitPerDay||60*o.limit*24,remaining:a.rateLimitPerDay||60*o.limit*24},s=t.systemSettings||t.system||{},l=s.cacheRetentionHours??(s.cacheRetentionDays?24*s.cacheRetentionDays:void 0);return{status:t.status||"active",apiKey:{id:n.id||"",scopes:r},quota:{perMinute:o,perDay:i},systemSettings:{cacheRetentionHours:l??720,maintenanceMode:s.maintenanceMode??!1,maintenanceMessage:s.maintenanceMessage,forceOfflineClients:s.forceOfflineClients??!1}}}async health(){const e=await fetch(`${this.baseUrl}/api/external/health`);if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}}let P,L;const T=new WeakMap,D=new WeakMap,N=new WeakMap,z=new WeakMap,F=new WeakMap;let O={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return D.get(e);if("objectStoreNames"===t)return e.objectStoreNames||N.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return U(e[t])},set:(e,t,n)=>(e[t]=n,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function $(e){return e!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(L||(L=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(B(this),t),U(T.get(this))}:function(...t){return U(e.apply(B(this),t))}:function(t,...n){const r=e.call(B(this),t,...n);return N.set(r,t.sort?t.sort():[t]),U(r)}}function j(e){return"function"==typeof e?$(e):(e instanceof IDBTransaction&&function(e){if(D.has(e))return;const t=new Promise((t,n)=>{const r=()=>{e.removeEventListener("complete",a),e.removeEventListener("error",o),e.removeEventListener("abort",o)},a=()=>{t(),r()},o=()=>{n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",a),e.addEventListener("error",o),e.addEventListener("abort",o)});D.set(e,t)}(e),t=e,(P||(P=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])).some(e=>t instanceof e)?new Proxy(e,O):e);var t}function U(e){if(e instanceof IDBRequest)return function(e){const t=new Promise((t,n)=>{const r=()=>{e.removeEventListener("success",a),e.removeEventListener("error",o)},a=()=>{t(U(e.result)),r()},o=()=>{n(e.error),r()};e.addEventListener("success",a),e.addEventListener("error",o)});return t.then(t=>{t instanceof IDBCursor&&T.set(t,e)}).catch(()=>{}),F.set(t,e),t}(e);if(z.has(e))return z.get(e);const t=j(e);return t!==e&&(z.set(e,t),F.set(t,e)),t}const B=e=>F.get(e);function W(e,t,{blocked:n,upgrade:r,blocking:a,terminated:o}={}){const i=indexedDB.open(e,t),s=U(i);return r&&i.addEventListener("upgradeneeded",e=>{r(U(i.result),e.oldVersion,e.newVersion,U(i.transaction),e)}),n&&i.addEventListener("blocked",e=>n(e.oldVersion,e.newVersion,e)),s.then(e=>{o&&e.addEventListener("close",()=>o()),a&&e.addEventListener("versionchange",e=>a(e.oldVersion,e.newVersion,e))}).catch(()=>{}),s}const V=["get","getKey","getAll","getAllKeys","count"],H=["put","add","delete","clear"],K=new Map;function q(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(K.get(t))return K.get(t);const n=t.replace(/FromIndex$/,""),r=t!==n,a=H.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!a&&!V.includes(n))return;const o=async function(e,...t){const o=this.transaction(e,a?"readwrite":"readonly");let i=o.store;return r&&(i=i.index(t.shift())),(await Promise.all([i[n](...t),a&&o.done]))[0]};return K.set(t,o),o}O=(e=>({...e,get:(t,n,r)=>q(t,n)||e.get(t,n,r),has:(t,n)=>!!q(t,n)||e.has(t,n)}))(O);class G{constructor(e){this.db=null,this.dbPromise=null,this.documentCount=0,this.lastSyncAt=null,this.config=e,"indexeddb"===e.storage&&"undefined"!=typeof indexedDB?this.dbPromise=this.initDB():"localstorage"===e.storage&&this.loadLocalStorageMetadata()}loadLocalStorageMetadata(){try{const e=localStorage.getItem("cybernetic-cache-meta");if(e){const t=JSON.parse(e);this.documentCount=t.documentCount||0,this.lastSyncAt=t.lastSyncAt||null}}catch{}}async initDB(){return this.db=await W("cybernetic-cache",1,{upgrade(e){if(!e.objectStoreNames.contains("documents")){e.createObjectStore("documents",{keyPath:"id"}).createIndex("by-updated","updatedAt")}e.objectStoreNames.contains("metadata")||e.createObjectStore("metadata",{keyPath:"key"})}}),await this.loadMetadata(),this.db}async getDB(){if(this.db)return this.db;if(this.dbPromise)return this.dbPromise;throw new Error("Database not available")}async loadMetadata(){if(!this.db)return;const e=await this.db.get("metadata","documentCount");this.documentCount=e?.value||0;const t=await this.db.get("metadata","lastSyncAt");this.lastSyncAt=t?.value||null}async store(e){if("localstorage"===this.config.storage)return this.storeLocalStorage(e);const t=(await this.getDB()).transaction(["documents","metadata"],"readwrite");for(const n of e)await t.objectStore("documents").put(n);this.documentCount=await t.objectStore("documents").count(),this.lastSyncAt=(new Date).toISOString(),await t.objectStore("metadata").put({key:"documentCount",value:this.documentCount}),await t.objectStore("metadata").put({key:"lastSyncAt",value:this.lastSyncAt}),await t.done}async retrieve(){if("localstorage"===this.config.storage)return this.retrieveLocalStorage();return(await this.getDB()).getAll("documents")}async getLastSync(){return this.lastSyncAt}getStatus(){const e=Date.now()-(this.lastSyncAt?new Date(this.lastSyncAt).getTime():0)>this.config.maxAge;return{documentCount:this.documentCount,lastSyncAt:this.lastSyncAt,cacheSize:5e3*this.documentCount,isStale:e}}async clear(){if("localstorage"===this.config.storage)return localStorage.removeItem("cybernetic-cache-docs"),localStorage.removeItem("cybernetic-cache-meta"),this.documentCount=0,void(this.lastSyncAt=null);const e=(await this.getDB()).transaction(["documents","metadata"],"readwrite");await e.objectStore("documents").clear(),await e.objectStore("metadata").clear(),await e.done,this.documentCount=0,this.lastSyncAt=null}storeLocalStorage(e){try{localStorage.setItem("cybernetic-cache-docs",JSON.stringify(e)),this.documentCount=e.length,this.lastSyncAt=(new Date).toISOString(),localStorage.setItem("cybernetic-cache-meta",JSON.stringify({documentCount:this.documentCount,lastSyncAt:this.lastSyncAt}))}catch{localStorage.removeItem("cybernetic-cache-docs");const t=e.slice(0,50);localStorage.setItem("cybernetic-cache-docs",JSON.stringify(t)),this.documentCount=t.length}}retrieveLocalStorage(){try{const e=localStorage.getItem("cybernetic-cache-docs");return e?JSON.parse(e):[]}catch{return[]}}}class Q{constructor(){this.documents=[],this.idf=new Map,this.indexed=!1,this.loadedFromExport=!1,this.vocabulary=new Map}isIndexed(){return this.indexed&&this.documents.length>0}async index(e){this.documents=[],this.idf=new Map;const t=new Map;for(const n of e){if(!n.content)continue;const e=this.tokenize(n.content),r=new Set(e);for(const e of r)t.set(e,(t.get(e)||0)+1);this.documents.push({id:n.id,title:n.title,content:n.content,tokens:e,tfidf:new Map})}const n=e.length;for(const[e,r]of t)this.idf.set(e,Math.log((n+1)/(r+1))+1);for(const e of this.documents){const t=this.computeTermFrequency(e.tokens);for(const[n,r]of t){const t=this.idf.get(n)||1;e.tfidf.set(n,r*t)}}this.indexed=!0}async ask(e){if(!this.indexed||0===this.documents.length)return{answer:"I don't have any information available offline.",sources:[],topScore:0};const t=this.tokenize(e),n=this.computeTermFrequency(t),r=new Map;for(const[e,t]of n){const n=this.idf.get(e)||1;r.set(e,t*n)}const a=this.documents.map(e=>({doc:e,score:this.cosineSimilarity(r,e.tfidf)}));a.sort((e,t)=>t.score-e.score);const o=a.slice(0,3).filter(e=>e.score>.1);if(0===o.length)return{answer:"I couldn't find relevant information for your question in my offline data.",sources:[],topScore:a[0]?.score||0};const i=o[0].doc;return{answer:this.extractRelevantSnippet(i.content,t),sources:o.map(e=>({title:e.doc.title,snippet:e.doc.content.substring(0,200)+"...",score:e.score})),topScore:o[0].score}}reset(){this.documents=[],this.idf=new Map,this.vocabulary=new Map,this.indexed=!1,this.loadedFromExport=!1,this.exportVersion=void 0,this.exportedAt=void 0}async loadFromExport(e){this.reset(),this.idf=new Map(Object.entries(e.tfidfIndex.idf));let t=0;for(const e of this.idf.keys())this.vocabulary.set(e,t++);for(const t of e.documents){const e=new Map;for(const[n,r]of t.tfidfVector)for(const[t,a]of this.vocabulary)if(a===n){e.set(t,r);break}this.documents.push({id:t.id,title:t.title,content:t.content,tokens:[],tfidf:e})}this.indexed=!0,this.loadedFromExport=!0,this.exportVersion=e.version,this.exportedAt=e.meta.exportedAt,console.log(`[CyberneticLocalRAG] Loaded ${this.documents.length} documents from export (v${e.version})`)}getExportStatus(){return{loaded:this.indexed,loadedFromExport:this.loadedFromExport,documentCount:this.documents.length,chunkCount:this.documents.length,exportVersion:this.exportVersion,exportedAt:this.exportedAt}}tokenize(e){return e&&"string"==typeof e?e.toLowerCase().replace(/[^\w\s]/g," ").split(/\s+/).filter(e=>e.length>2&&!this.isStopWord(e)):[]}computeTermFrequency(e){const t=new Map;for(const n of e)t.set(n,(t.get(n)||0)+1);const n=Math.max(...t.values());if(n>0)for(const[e,r]of t)t.set(e,r/n);return t}cosineSimilarity(e,t){let n=0,r=0,a=0;for(const[a,o]of e){n+=o*(t.get(a)||0),r+=o*o}for(const e of t.values())a+=e*e;return 0===r||0===a?0:n/(Math.sqrt(r)*Math.sqrt(a))}extractRelevantSnippet(e,t){const n=e.split(/[.!?]+/).filter(e=>e.trim().length>0).map(e=>{const n=new Set(this.tokenize(e));let r=0;for(const e of t)n.has(e)&&r++;return{sentence:e.trim(),score:r}});n.sort((e,t)=>t.score-e.score);const r=n.slice(0,3).filter(e=>e.score>0);return 0===r.length?e.substring(0,300)+"...":r.map(e=>e.sentence).join(". ")+"."}isStopWord(e){return new Set(["the","a","an","and","or","but","in","on","at","to","for","of","with","by","from","up","about","into","through","during","is","are","was","were","be","been","being","have","has","had","do","does","did","will","would","could","should","may","might","this","that","these","those","it","its","they","them","their","what","which","who","whom","when","where","why","how","all","each","every","both","few","more","most","other","some","such","no","not","only","same","so","than","too","very"]).has(e)}}class Y{constructor(){this.db=null,this.dbPromise=null,this.dbName="cybernetic-offline-vectors",this.dbVersion=1}async initDB(){return this.db?this.db:this.dbPromise?this.dbPromise:(this.dbPromise=W(this.dbName,this.dbVersion,{upgrade(e){e.objectStoreNames.contains("vectors")||e.createObjectStore("vectors",{keyPath:"id"})}}),this.db=await this.dbPromise,this.db)}async store(e,t){const n=await this.getDB();await n.put("vectors",{id:e,exportVersion:t.version,exportedAt:t.meta.exportedAt,type:t.type,data:t}),console.log(`[CyberneticOfflineStorage] Stored ${t.meta.chunkCount} chunks`)}async retrieve(e){const t=await this.getDB(),n=await t.get("vectors",e);return n?.data??null}async isValid(e,t){const n=await this.getDB(),r=await n.get("vectors",e);if(!r)return!1;const a=new Date(r.exportedAt).getTime();return Date.now()-a<t}async getMeta(e){const t=await this.getDB(),n=await t.get("vectors",e);return n?{version:n.exportVersion,exportedAt:n.exportedAt,documentCount:n.data.meta.documentCount,chunkCount:n.data.meta.chunkCount,type:n.type}:null}async hasData(){const e=await this.getDB();return await e.count("vectors")>0}async getStoredIds(){return(await this.getDB()).getAllKeys("vectors")}async delete(e){const t=await this.getDB();await t.delete("vectors",e)}async clear(){const e=await this.getDB();await e.clear("vectors"),console.log("[CyberneticOfflineStorage] Cache cleared")}async getDB(){return this.db?this.db:this.initDB()}close(){this.db&&(this.db.close(),this.db=null,this.dbPromise=null)}}class X{constructor(e,t,n){this.ws=null,this.state="disconnected",this.reconnectAttempts=0,this.connectionPromise=null,this.activeCallbacks=null,this.activeFullText="",this.beforeUnloadHandler=null,this._resolveStream=null,this._rejectStream=null,this.wsUrl=e,this.apiKey=t,this.maxReconnectAttempts=n?.maxReconnectAttempts??3,this.reconnectDelay=n?.reconnectDelay??1e3,this.connectionTimeout=n?.connectionTimeout??1e4}getState(){return this.state}isConnected(){return"connected"===this.state&&this.ws?.readyState===WebSocket.OPEN}connect(){return this.isConnected()?Promise.resolve():(this.connectionPromise||(this.state="connecting",this.connectionPromise=new Promise((e,t)=>{try{const n=this.wsUrl.includes("?")?"&":"?",r=`${this.wsUrl}${n}apiKey=${encodeURIComponent(this.apiKey)}`,a=new WebSocket(r);this.ws=a;const o=setTimeout(()=>{a.readyState!==WebSocket.OPEN&&(a.close(),this.state="error",this.connectionPromise=null,t(new Error("WebSocket connection timed out")))},this.connectionTimeout);a.onopen=()=>{clearTimeout(o),this.state="connected",this.reconnectAttempts=0,this.connectionPromise=null,this.registerCleanup(),e()},a.onmessage=e=>{this.handleMessage(e)},a.onerror=()=>{clearTimeout(o),this.state="error",this.connectionPromise=null},a.onclose=e=>{clearTimeout(o);const n="connected"===this.state;this.state="disconnected",this.connectionPromise=null,this.unregisterCleanup(),this.activeCallbacks&&(this.activeCallbacks.onError?.({code:"WS_ERROR",message:e.reason||`WebSocket closed (code: ${e.code})`}),this.clearActiveRequest()),n||t(new Error(e.reason||`WebSocket closed (code: ${e.code})`))}}catch(e){this.state="error",this.connectionPromise=null,t(e)}})),this.connectionPromise)}async chatStream(e,t){const{sessionId:n,context:r,wordLimit:a,onToken:o,onSources:i,onComplete:s,onError:l}=t;try{await this.connect()}catch(e){throw l?.({code:"WS_ERROR",message:`Failed to connect: ${e instanceof Error?e.message:String(e)}`}),e}if(!this.ws||this.ws.readyState!==WebSocket.OPEN){const e={code:"WS_ERROR",message:"WebSocket not connected"};throw l?.(e),new Error(e.message)}this.activeCallbacks={onToken:o,onSources:i,onComplete:s,onError:l},this.activeFullText="",this.activeSessionId=n;const c={type:"sendMessage",message:e};return n&&(c.sessionId=n),a&&(c.wordLimit=a),r&&(c.context=r),new Promise((e,t)=>{this._resolveStream=e,this._rejectStream=t,this.ws.send(JSON.stringify(c))})}disconnect(){this.unregisterCleanup(),this.ws&&(this.ws.onclose=null,this.ws.onerror=null,this.ws.onmessage=null,this.ws.close(),this.ws=null),this.state="disconnected",this.connectionPromise=null,this.clearActiveRequest()}async reconnect(){if(this.reconnectAttempts>=this.maxReconnectAttempts)throw this.state="error",new Error(`Max reconnection attempts (${this.maxReconnectAttempts}) exceeded`);const e=this.reconnectDelay*Math.pow(2,this.reconnectAttempts);return this.reconnectAttempts++,console.log(`[Cybernetic WS] Reconnecting in ${e}ms (attempt ${this.reconnectAttempts}/${this.maxReconnectAttempts})`),await new Promise(t=>setTimeout(t,e)),this.ws&&(this.ws.onclose=null,this.ws.onerror=null,this.ws.close(),this.ws=null),this.connect()}handleMessage(e){if(this.activeCallbacks)try{const t=JSON.parse(e.data);switch(t.type){case"typing":break;case"chunk":t.content&&(this.activeFullText+=t.content,this.activeCallbacks.onToken?.(t.content));break;case"done":{const e=this.mapSources(t.sources||[]);this.activeCallbacks.onSources?.(e);const n={reply:this.activeFullText,confidence:"high",sources:e,offline:!1,sessionId:t.sessionId||this.activeSessionId};this.activeCallbacks.onComplete?.(n),this._resolveStream?.(),this.clearActiveRequest();break}case"error":{const e={code:"WS_ERROR",message:t.error||"Unknown WebSocket error"};this.activeCallbacks.onError?.(e),this._rejectStream?.(new Error(e.message)),this.clearActiveRequest();break}default:console.warn("[Cybernetic WS] Unknown message type:",t.type)}}catch(t){console.error("[Cybernetic WS] Failed to parse message:",t,e.data)}}mapSources(e){return Array.isArray(e)?e.map(e=>({title:e.title||e.heading||e.documentName||"Document",snippet:e.content||"",relevance:e.score??0,documentId:e.documentId,documentName:e.documentName,sourceType:e.sourceType||"document",chunkId:e.chunkId,downloadUrl:e.downloadUrl})):[]}clearActiveRequest(){this.activeCallbacks=null,this.activeFullText="",this._resolveStream=null,this._rejectStream=null}registerCleanup(){"undefined"==typeof window||this.beforeUnloadHandler||(this.beforeUnloadHandler=()=>this.disconnect(),window.addEventListener("beforeunload",this.beforeUnloadHandler))}unregisterCleanup(){"undefined"!=typeof window&&this.beforeUnloadHandler&&(window.removeEventListener("beforeunload",this.beforeUnloadHandler),this.beforeUnloadHandler=null)}}const J={enabled:!0,storageKey:"astermind_session",sessionTtl:18e5,persistMessages:!0,maxMessages:50};class Z{constructor(e){this.cachedSession=null,this.config={...J,...e},this.config.enabled&&this.isAvailable()&&(this.cachedSession=this.loadFromStorage())}isAvailable(){if("undefined"==typeof window)return!1;try{const e="__astermind_test__";return window.sessionStorage.setItem(e,"test"),window.sessionStorage.removeItem(e),!0}catch{return!1}}getSessionId(){if(!this.config.enabled)return null;const e=this.getSession();return e?.sessionId??null}getSession(){if(!this.config.enabled)return null;if(this.cachedSession)return this.isSessionValid(this.cachedSession)?this.cachedSession:(this.clear(),null);const e=this.loadFromStorage();return e&&this.isSessionValid(e)?(this.cachedSession=e,e):null}saveSessionId(e){if(!this.config.enabled||!e)return;const t=this.getSession(),n={sessionId:e,updatedAt:Date.now(),messages:t?.messages??[]};this.saveToStorage(n),this.cachedSession=n}addMessage(e){if(!this.config.enabled||!this.config.persistMessages)return;const t=this.getSession();if(!t)return;const n={...e,id:this.generateMessageId(),timestamp:Date.now()};t.messages=t.messages??[],t.messages.push(n),t.messages.length>this.config.maxMessages&&(t.messages=t.messages.slice(-this.config.maxMessages)),t.updatedAt=Date.now(),this.saveToStorage(t),this.cachedSession=t}getMessages(){if(!this.config.enabled||!this.config.persistMessages)return[];const e=this.getSession();return e?.messages??[]}clear(){if(this.cachedSession=null,this.isAvailable())try{window.sessionStorage.removeItem(this.config.storageKey)}catch(e){console.warn("[CyberneticSessionStorage] Failed to clear session:",e)}}startNewSession(e){this.clear(),e&&this.saveSessionId(e)}hasValidSession(){return null!==this.getSession()}getSessionInfo(){const e=this.getSession();if(!e)return{hasSession:!1,sessionId:null,messageCount:0,lastUpdated:null,ttlRemaining:null};const t=Math.max(0,this.config.sessionTtl-(Date.now()-e.updatedAt));return{hasSession:!0,sessionId:e.sessionId,messageCount:e.messages?.length??0,lastUpdated:new Date(e.updatedAt),ttlRemaining:t}}isSessionValid(e){return Date.now()-e.updatedAt<this.config.sessionTtl}loadFromStorage(){if(!this.isAvailable())return null;try{const e=window.sessionStorage.getItem(this.config.storageKey);if(!e)return null;const t=JSON.parse(e);return t.sessionId&&"number"==typeof t.updatedAt?t:null}catch(e){return console.warn("[CyberneticSessionStorage] Failed to load session:",e),null}}saveToStorage(e){if(this.isAvailable())try{window.sessionStorage.setItem(this.config.storageKey,JSON.stringify(e))}catch(e){console.warn("[CyberneticSessionStorage] Failed to save session:",e)}}generateMessageId(){return`msg_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}}function ee(e){if(e.wsUrl)return e.wsUrl;if("rest"===e.transport)return;const t=function(){try{const e=globalThis.import?.meta?.env;if(e?.VITE_ASTERMIND_RAG_WS_URL)return e.VITE_ASTERMIND_RAG_WS_URL}catch{}if("undefined"!=typeof process&&process.env){if(process.env.ASTERMIND_RAG_WS_URL)return process.env.ASTERMIND_RAG_WS_URL;if(process.env.REACT_APP_ASTERMIND_RAG_WS_URL)return process.env.REACT_APP_ASTERMIND_RAG_WS_URL}if("undefined"!=typeof window){const e=window.__ASTERMIND_CONFIG__;if(e?.wsUrl)return e.wsUrl;const t=window.astermindConfig;if(t?.wsUrl)return t.wsUrl}if("undefined"!=typeof document){const e=document.querySelector("script[data-astermind-ws-url]");if(e){const t=e.getAttribute("data-astermind-ws-url");if(t)return t}}}();return t||function(e){try{const t=new URL(e),n=t.hostname.match(/^chatapi(-[\w]+)?\.astermind\.ai$/);if(n)return`wss://chatws${n[1]||""}.astermind.ai`;if("api.astermind.ai"===t.hostname)return"wss://chatws.astermind.ai"}catch{}}(e.apiUrl)}function te(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");const n=t.length%4;n&&(t+="=".repeat(4-n));const r=atob(t),a=new Uint8Array(r.length);for(let e=0;e<r.length;e++)a[e]=r.charCodeAt(e);return a}function ne(e){const t=te(e);return(new TextDecoder).decode(t)}async function re(e,t,n){try{const r=await async function(e){const t=e.replace(/-----BEGIN PUBLIC KEY-----/,"").replace(/-----END PUBLIC KEY-----/,"").replace(/\s/g,""),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return crypto.subtle.importKey("spki",r.buffer,{name:"ECDSA",namedCurve:"P-256"},!1,["verify"])}(n),a=(new TextEncoder).encode(e),o=new Uint8Array(t).buffer;return await crypto.subtle.verify({name:"ECDSA",hash:"SHA-256"},r,o,a)}catch(e){return console.warn("[License] Signature verification failed:",e),!1}}async function ae(e,t){if(!e||""===e.trim())return{status:"missing",payload:null,error:"No license key provided",inGracePeriod:!1,daysRemaining:null};const n=function(e){try{const t=e.split(".");if(3!==t.length)return null;const[n,r,a]=t;return{header:JSON.parse(ne(n)),payload:JSON.parse(ne(r)),signature:te(a),signedContent:`${n}.${r}`}}catch{return null}}(e);if(!n)return{status:"invalid",payload:null,error:"Invalid license key format",inGracePeriod:!1,daysRemaining:null};const r=function(e){return"string"!=typeof e.iss||"string"!=typeof e.sub||"string"!=typeof e.aud||"number"!=typeof e.iat||"number"!=typeof e.exp||"string"!=typeof e.plan||"number"!=typeof e.seats?null:Array.isArray(e.features)?"number"!=typeof e.licenseVersion?null:{iss:e.iss,sub:e.sub,aud:e.aud,iat:e.iat,exp:e.exp,plan:e.plan,org:"string"==typeof e.org?e.org:void 0,seats:e.seats,features:e.features,graceUntil:"number"==typeof e.graceUntil?e.graceUntil:void 0,licenseVersion:e.licenseVersion}:null}(n.payload);if(!r)return{status:"invalid",payload:null,error:"Invalid license payload structure",inGracePeriod:!1,daysRemaining:null};if("astermind"!==r.iss)return{status:"invalid",payload:null,error:"Invalid license issuer",inGracePeriod:!1,daysRemaining:null};if("cybernetic-chatbot"!==r.aud&&"*"!==r.aud)return{status:"invalid",payload:null,error:"License not valid for this product",inGracePeriod:!1,daysRemaining:null};if("undefined"!=typeof crypto&&crypto.subtle){const e=t||"-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEhLW7MXHQ0Fuk1OKt9D5CbRw7fUMN\nLJ5AZXvOhHaXdHzMuYKX5BpK4w7TqbPvJ6QPvKmLKvHh1VKcUJ6mJQgJJw==\n-----END PUBLIC KEY-----";if(!await re(n.signedContent,n.signature,e))return{status:"invalid",payload:null,error:"License signature verification failed",inGracePeriod:!1,daysRemaining:null}}const a=Math.floor(Date.now()/1e3),o=function(e){const t=e-Math.floor(Date.now()/1e3);return Math.floor(t/86400)}(r.exp);return r.exp<a?r.graceUntil&&r.graceUntil>a?{status:"valid",payload:r,inGracePeriod:!0,daysRemaining:o}:{status:"expired",payload:r,error:"License has expired",inGracePeriod:!1,daysRemaining:o}:"eval"===r.plan?{status:"eval",payload:r,inGracePeriod:!1,daysRemaining:o}:{status:"valid",payload:r,inGracePeriod:!1,daysRemaining:o}}const oe="cybernetic-chatbot-client",ie="agentic";class se{constructor(e={}){this.state=null,this.verificationPromise=null,this.hasLoggedWarning=!1,this.loggedMissingFeatures=new Set,this.config=e,this.environment=e.environment||function(){if("undefined"==typeof window)return"production"===process?.env?.NODE_ENV?"production":"development";const e=window.location?.hostname||"",t=["localhost","127.0.0.1","0.0.0.0",".local",".dev",".test",":3000",":5173",":8080",":4200"];for(const n of t)if(e.includes(n)||window.location?.port===n.replace(":",""))return"development";if("file:"===window.location?.protocol)return"development";const n=["staging.","preview.","-preview.",".vercel.app",".netlify.app",".pages.dev"];for(const t of n)if(e.includes(t))return"production";return"production"}(),this.enforcementMode="development"===this.environment?"soft":"hard"}async verify(){if(this.state)return this.state;if(this.verificationPromise)return this.verificationPromise;this.verificationPromise=ae(this.config.licenseKey,this.config.publicKey);try{return this.state=await this.verificationPromise,this.config.onStatusChange?.(this.state),this.logLicenseStatus(),this.state}finally{this.verificationPromise=null}}getState(){return this.state}isValid(){return!!this.state&&("valid"===this.state.status||"eval"===this.state.status)}requiresAction(){return!this.state||("expired"===this.state.status||"missing"===this.state.status||"invalid"===this.state.status)}getEnvironment(){return this.environment}getEnforcementMode(){return this.enforcementMode}processResponse(e){return this.state?this.isValid()&&!this.state.inGracePeriod?e:"soft"===this.enforcementMode?(this.hasLoggedWarning||(this.logDevelopmentWarning(),this.hasLoggedWarning=!0),e):e+"\n\n---\n⚠️ License Notice: Your AsterMind license key needs to be updated. Please contact support@astermind.ai or visit https://astermind.ai/license to renew your license.":e}getStatusMessage(){if(!this.state)return"License not verified";switch(this.state.status){case"valid":return this.state.inGracePeriod?`License expired but in grace period (${Math.abs(this.state.daysRemaining||0)} days overdue)`:`License valid (${this.state.daysRemaining} days remaining)`;case"eval":return`Evaluation license (${this.state.daysRemaining} days remaining)`;case"expired":return`License expired ${Math.abs(this.state.daysRemaining||0)} days ago`;case"missing":return"No license key provided";case"invalid":return`Invalid license: ${this.state.error}`;default:return"Unknown license status"}}async reVerify(){return this.state=null,this.hasLoggedWarning=!1,this.loggedMissingFeatures.clear(),this.verify()}hasFeature(e){return!!this.state?.payload&&this.state.payload.features.includes(e)}getFeatures(){return this.state?.payload?.features||[]}checkClientFeature(){return this.checkFeatureWithLog(oe,"CyberneticClient")}checkAgenticFeature(){return this.checkFeatureWithLog(ie,"Agentic capabilities")}checkFeatureWithLog(e,t){if(!this.state?.payload)return!0;const n=this.state.payload.features.includes(e);return n||this.loggedMissingFeatures.has(e)||(this.loggedMissingFeatures.add(e),this.logMissingFeature(e,t)),n}logMissingFeature(e,t){const n=this.getFeatures(),r=this.state?.payload?.plan||"unknown";console.warn(`[Cybernetic License] ${t} requires the '${e}' feature, which is not included in your license.`),console.info(`[Cybernetic License] Current license plan: ${r}`),console.info(`[Cybernetic License] Licensed features: ${n.length>0?n.join(", "):"(none)"}`),console.info("[Cybernetic License] To add this feature, upgrade your license at https://astermind.ai/license")}logLicenseStatus(){if(!this.state)return;const e="[Cybernetic License]";switch(this.state.status){case"valid":this.state.inGracePeriod?console.warn(`${e} License expired but in grace period. Please renew at https://astermind.ai/license`):null!==this.state.daysRemaining&&this.state.daysRemaining<=30&&console.info(`${e} License expires in ${this.state.daysRemaining} days`);break;case"eval":console.info(`${e} Evaluation license - ${this.state.daysRemaining} days remaining`);break;case"expired":console.error(`${e} License expired. Enforcement mode: ${this.enforcementMode}. Renew at https://astermind.ai/license`);break;case"missing":console.warn(`${e} No license key provided. Enforcement mode: ${this.enforcementMode}. Get a license at https://astermind.ai/license`);break;case"invalid":console.error(`${e} Invalid license: ${this.state.error}. Enforcement mode: ${this.enforcementMode}`)}}logDevelopmentWarning(){console.warn(`[Cybernetic License] Running in development mode with ${this.state?.status||"unknown"} license. In production, a warning will be appended to chatbot responses. Get a license at https://astermind.ai/license`)}}class le{constructor(e){this.wsTransport=null,this.status="connecting",this.lastError=null,this.systemSettings=null,this.settingsLastChecked=0,this.SETTINGS_CHECK_INTERVAL=3e5,this.agenticCapabilities=null,this.offlineStorage=null,this.omegaRAG=null,this.offlineWarningShown=!1;const t=ee(e),n=e.transport??"auto";this.config={apiUrl:e.apiUrl,apiKey:e.apiKey,wsUrl:t,transport:n,fallback:{enabled:e.fallback?.enabled??!0,cacheMaxAge:e.fallback?.cacheMaxAge??864e5,cacheOnConnect:e.fallback?.cacheOnConnect??!0,cacheStorage:e.fallback?.cacheStorage??"indexeddb"},retry:{maxRetries:e.retry?.maxRetries??2,initialDelay:e.retry?.initialDelay??1e3,exponentialBackoff:e.retry?.exponentialBackoff??!0},agentic:e.agentic??null,offline:e.offline??null,sitemap:e.sitemap??null,sources:{enabled:e.sources?.enabled??!0,showSummary:e.sources?.showSummary??!0,showDownload:e.sources?.showDownload??!0,includeFullContent:e.sources?.includeFullContent??!1,maxSources:e.sources?.maxSources??5},onStatusChange:e.onStatusChange||(()=>{}),onError:e.onError||(()=>{})},this.apiClient=new I(this.config.apiUrl,this.config.apiKey),this.cache=new G({storage:this.config.fallback.cacheStorage,maxAge:this.config.fallback.cacheMaxAge}),this.localRAG=new Q,this.licenseManager=new se({licenseKey:e.licenseKey,environment:e.environment}),this.sessionStorage=new Z(e.session),this.licenseManager.verify().then(()=>{this.licenseManager.checkClientFeature()}).catch(()=>{}),t&&"rest"!==n&&"undefined"!=typeof WebSocket&&(this.wsTransport=new X(t,e.apiKey,e.websocket),console.log(`[Cybernetic] WebSocket transport enabled: ${t}`)),this.monitorConnection(),this.config.fallback.enabled&&this.config.fallback.cacheOnConnect&&this.syncCache().catch(()=>{}),this.config.offline?.enabled&&this.initializeOffline(this.config.offline).catch(e=>{console.warn("[Cybernetic] Failed to initialize offline vectors:",e)})}registerAgentic(e){this.agenticCapabilities=e,console.log("[Cybernetic] Agentic capabilities registered")}isAgenticEnabled(){return null!==this.agenticCapabilities&&!0===this.config.agentic?.enabled&&(this.licenseManager.checkAgenticFeature(),!0)}getAgenticCapabilities(){return this.agenticCapabilities}getAgenticConfig(){return this.config.agentic}getSourcesConfig(){return{...this.config.sources}}isSourceFeatureAvailable(e){return!!this.config.sources.enabled&&("summary"===e?this.config.sources.showSummary:"download"===e&&(this.config.sources.showDownload&&"online"===this.status))}classifyIntent(e){if(!this.isAgenticEnabled()||!this.agenticCapabilities)return null;const t=this.config.agentic;return new(0,this.agenticCapabilities.agent)(t).interpretIntent(e)}async executeAction(e){if(!this.isAgenticEnabled()||!this.agenticCapabilities)return{success:!1,message:"Agentic capabilities not enabled"};const t=this.config.agentic;return new(0,this.agenticCapabilities.agent)(t).executeAction(e)}async smartAsk(e,t){const n=this.classifyIntent(e);if(n&&n.action&&!n.shouldEscalate){if(!1!==this.config.agentic?.requireConfirmation)return{action:n.action};const e=await this.executeAction(n.action);return{action:n.action,actionResult:e}}return{response:await this.ask(e,t)}}async initializeOffline(e){const t=e.storageMode??"hybrid",n=e.cacheMaxAge??6048e5;if("memory"!==t&&(this.offlineStorage=new Y),this.offlineStorage&&"memory"!==t){const e="default";if(await this.offlineStorage.isValid(e,n)){console.log("[Cybernetic] Loading vectors from IndexedDB cache");const t=await this.offlineStorage.retrieve(e);if(t)return await this.localRAG.loadFromExport(t),void console.log("[Cybernetic] Loaded vectors from IndexedDB cache")}}if(e.vectorFileUrl)try{const n=await fetch(e.vectorFileUrl);if(!n.ok)throw new Error(`Failed to fetch vectors: ${n.status}`);const r=await n.json();return this.offlineStorage&&"memory"!==t&&await this.offlineStorage.store("default",r),await this.localRAG.loadFromExport(r),e.omega?.enabled&&await this.initializeOmega(e),void console.log("[Cybernetic] Loaded vectors from URL:",e.vectorFileUrl)}catch(e){console.error("[Cybernetic] Failed to load offline vectors from URL:",e)}if(e.vectorData)return await this.localRAG.loadFromExport(e.vectorData),e.omega?.enabled&&await this.initializeOmega(e),void console.log("[Cybernetic] Loaded inline vector data");this.offlineWarningShown||(console.warn("[Cybernetic] Offline functionality is enabled but no vectors are loaded. Offline responses will be limited. To enable full offline functionality, export vectors from the AsterMind admin panel and configure the vectorFileUrl or vectorData option."),this.offlineWarningShown=!0)}async initializeOmega(e){if(e.omega?.enabled)try{const{OmegaOfflineRAG:t}=await Promise.resolve().then(function(){return He});this.omegaRAG=new t({reranking:e.omega.reranking,topK:5,verbose:!1}),e.omega.modelUrl?await this.omegaRAG.loadModelFromUrl(e.omega.modelUrl):e.omega.modelData&&await this.omegaRAG.loadModel(e.omega.modelData),console.log("[Cybernetic] Omega RAG initialized")}catch(e){console.warn("[Cybernetic] Failed to initialize Omega RAG:",e),this.omegaRAG=null}}async reloadOfflineVectors(){this.config.offline?.enabled?(this.localRAG.reset(),this.offlineStorage&&await this.offlineStorage.clear(),this.omegaRAG&&this.omegaRAG.clear(),await this.initializeOffline(this.config.offline)):console.warn("[Cybernetic] Offline mode is not enabled")}isOmegaOfflineEnabled(){return this.omegaRAG?.isReady()??!1}getOfflineModelInfo(){return this.omegaRAG?.getModelInfo()??null}getLocalRAGStatus(){return this.localRAG.getExportStatus()}getOfflineStorage(){return this.offlineStorage}getStoredMessages(){return this.sessionStorage.getMessages()}hasStoredSession(){return this.sessionStorage.hasValidSession()}getSessionInfo(){return this.sessionStorage.getSessionInfo()}clearSession(){this.sessionStorage.clear()}startNewSession(e){this.sessionStorage.startNewSession(e)}async ask(e,t){if(!e||"string"!=typeof e)return this.createErrorResponse("Message is required","none");const n=t?.sessionId??this.sessionStorage.getSessionId()??void 0,r=n?{...t,sessionId:n}:t,a=await this.checkSystemStatus();if(a.maintenanceMode||a.forceOfflineClients)return console.log("[Cybernetic] Maintenance mode active, using cached data"),this.isCacheValid()?await this.fallbackAsk(e):{reply:a.maintenanceMessage||"The service is currently under maintenance. Please try again later.",confidence:"none",sources:[],offline:!0,degradedReason:"Maintenance mode active, no valid cache available"};try{const t=await this.apiWithRetry(e,r);this.setStatus("online");const n=this.licenseManager.processResponse(t.reply);return t.sessionId&&this.sessionStorage.saveSessionId(t.sessionId),this.sessionStorage.addMessage({role:"user",content:e}),this.sessionStorage.addMessage({role:"assistant",content:n,confidence:"high",sources:t.sources||[]}),{reply:n,confidence:"high",sources:t.sources||[],offline:!1,sessionId:t.sessionId}}catch(n){const r=this.normalizeError(n);return this.lastError=r,this.config.onError(r),"RATE_LIMIT"===r.code?{reply:"I'm receiving too many requests right now. Please try again in a moment.",confidence:"none",sources:[],offline:!1,retryAfter:r.retryAfter}:this.config.fallback.enabled&&!t?.skipFallback?await this.fallbackAsk(e):this.createErrorResponse("Unable to connect to the chatbot service. Please try again later.","none",r.retryAfter)}}async askStream(e,t,n){if(!e||"string"!=typeof e)return void t.onError?.({code:"LOCAL_RAG_ERROR",message:"Message is required"});const r=n?.sessionId??this.sessionStorage.getSessionId()??void 0,a=r?{...n,sessionId:r}:n;this.sessionStorage.addMessage({role:"user",content:e});const o=await this.checkSystemStatus();if(o.maintenanceMode||o.forceOfflineClients){console.log("[Cybernetic] Maintenance mode active, falling back to offline");const n=await this.fallbackAsk(e);return void t.onComplete?.(n)}if(this.wsTransport&&"rest"!==this.config.transport)try{return void await this.wsTransport.chatStream(e,{sessionId:a?.sessionId,context:a?.context,onToken:t.onToken,onSources:t.onSources,onComplete:e=>{this.setStatus("online");const n=this.licenseManager.processResponse(e.reply);e.sessionId&&this.sessionStorage.saveSessionId(e.sessionId),this.sessionStorage.addMessage({role:"assistant",content:n,confidence:"high",sources:e.sources}),t.onComplete?.({...e,reply:n})},onError:n=>{if("auto"===this.config.transport)console.warn("[Cybernetic] WebSocket error, falling back to SSE:",n.message),this.streamViaSSE(e,t,a);else{const e=this.normalizeError(n);this.config.onError(e),t.onError?.(e)}}})}catch(e){if("websocket"===this.config.transport){const n=this.normalizeError(e);return this.lastError=n,this.config.onError(n),void t.onError?.(n)}console.warn("[Cybernetic] WebSocket connect failed, using SSE fallback")}await this.streamViaSSE(e,t,a)}async streamViaSSE(e,t,n){try{await this.apiClient.chatStream(e,{sessionId:n?.sessionId,context:n?.context,onToken:t.onToken,onSources:t.onSources,onComplete:e=>{this.setStatus("online");const n=this.licenseManager.processResponse(e.fullText);e.sessionId&&this.sessionStorage.saveSessionId(e.sessionId),this.sessionStorage.addMessage({role:"assistant",content:n,confidence:"high",sources:e.sources||[]}),t.onComplete?.({reply:n,confidence:"high",sources:e.sources||[],offline:!1,sessionId:e.sessionId,messageId:e.messageId})},onError:e=>{const n=this.normalizeError(e);this.config.onError(n),t.onError?.(n)}})}catch(r){const a=this.normalizeError(r);if(this.lastError=a,this.config.onError(a),this.config.fallback.enabled&&!n?.skipFallback){const n=await this.fallbackAsk(e);t.onComplete?.(n)}else t.onError?.(a)}}async syncCache(){try{const e=await this.cache.getLastSync(),t=await this.apiClient.getGeneralDocs(e);t.length>0&&(await this.cache.store(t),await this.localRAG.index(t),console.log(`[Cybernetic] Cache synced: ${t.length} documents`)),this.setStatus("online")}catch(e){console.warn("[Cybernetic] Cache sync failed:",e)}}getStatus(){return{connection:this.status,cache:this.cache.getStatus(),lastError:this.lastError,systemSettings:this.systemSettings,license:this.licenseManager.getState()}}getLicenseManager(){return this.licenseManager}async clearCache(){await this.cache.clear(),this.localRAG.reset()}destroy(){this.wsTransport&&(this.wsTransport.disconnect(),this.wsTransport=null)}async checkConnection(){try{return await this.apiClient.getStatus(),this.setStatus("online"),!0}catch{return this.setStatus("offline"),!1}}async checkSystemStatus(){if(this.systemSettings&&Date.now()-this.settingsLastChecked<this.SETTINGS_CHECK_INTERVAL)return this.systemSettings;try{const e=await this.apiClient.getStatus();return this.systemSettings={cacheRetentionHours:e.systemSettings?.cacheRetentionHours??168,maintenanceMode:e.systemSettings?.maintenanceMode??!1,maintenanceMessage:e.systemSettings?.maintenanceMessage,forceOfflineClients:e.systemSettings?.forceOfflineClients??!1},this.settingsLastChecked=Date.now(),this.systemSettings}catch{return this.systemSettings||{cacheRetentionHours:168,maintenanceMode:!1,forceOfflineClients:!1}}}isMaintenanceMode(){return this.systemSettings?.maintenanceMode??!1}getMaintenanceMessage(){return this.systemSettings?.maintenanceMessage}isCacheValid(){const e=this.cache.getStatus();if(!e.lastSyncAt)return!1;const t=60*(this.systemSettings?.cacheRetentionHours||168)*60*1e3,n=new Date(e.lastSyncAt).getTime();return Date.now()-n<t}async apiWithRetry(e,t){const{maxRetries:n,initialDelay:r,exponentialBackoff:a}=this.config.retry;let o=null;for(let i=0;i<=n;i++)try{return await this.apiClient.chat(e,{sessionId:t?.sessionId,context:t?.context})}catch(e){o=e;const t=this.normalizeError(e);if("AUTH_ERROR"===t.code||"RATE_LIMIT"===t.code)throw e;if(i<n){const e=a?r*Math.pow(2,i):r;await this.sleep(e)}}throw o}async fallbackAsk(e){if(this.setStatus("offline"),this.omegaRAG?.isReady())try{const t=await this.omegaRAG.ask(e);if(!t.degraded){return{reply:this.licenseManager.processResponse(t.answer),confidence:t.confidence,sources:t.sources.map(e=>({title:e.heading,snippet:e.content.substring(0,200)+"...",relevance:e.score})),offline:!0,degradedReason:"Omega hybrid retrieval (offline)"}}}catch(e){console.warn("[Cybernetic] Omega RAG failed, falling back to TF-IDF:",e)}const t=this.localRAG.getExportStatus();if(t.loaded&&t.documentCount>0)try{const n=await this.localRAG.ask(e);let r="medium";n.topScore<.3?r="low":n.topScore>.7&&(r="medium");return{reply:this.licenseManager.processResponse(n.answer),confidence:r,sources:n.sources.map(e=>({title:e.title,snippet:e.snippet,relevance:e.score})),offline:!0,degradedReason:t.loadedFromExport?"Using pre-exported vectors (offline)":"Processed locally with TF-IDF"}}catch(e){console.error("[Cybernetic] Local RAG error:",e)}const n=this.cache.getStatus();if(0===n.documentCount&&!t.loaded)return{reply:"I'm currently offline and don't have any cached information. Please check your connection and try again.",confidence:"none",sources:[],offline:!0,degradedReason:"No cached documents or offline vectors available"};try{const t=await this.cache.retrieve();this.localRAG.isIndexed()||await this.localRAG.index(t);const r=await this.localRAG.ask(e);let a="medium";r.topScore<.3?a="low":r.topScore>.7&&(a="medium");return{reply:this.licenseManager.processResponse(r.answer),confidence:a,sources:r.sources.map(e=>({title:e.title,snippet:e.snippet,relevance:e.score})),offline:!0,degradedReason:n.isStale?"Using stale cached data":"Processed locally without server"}}catch(e){return console.error("[Cybernetic] Local RAG error:",e),{reply:"I'm having trouble processing your request offline. Please try again when you're back online.",confidence:"none",sources:[],offline:!0,degradedReason:"Local RAG processing failed"}}}monitorConnection(){"undefined"!=typeof window&&(window.addEventListener("online",()=>{this.syncCache().catch(()=>{})}),window.addEventListener("offline",()=>{this.setStatus("offline")}),navigator.onLine||this.setStatus("offline"))}setStatus(e){this.status!==e&&(this.status=e,this.config.onStatusChange(e))}normalizeError(e){if(e instanceof Error){if(e.message.includes("401")||e.message.includes("Unauthorized"))return{code:"AUTH_ERROR",message:"Invalid or expired API key",originalError:e};if(e.message.includes("429")||e.message.includes("Rate limit")){const t=e.message.match(/retry after (\d+)/i);return{code:"RATE_LIMIT",message:"Rate limit exceeded",retryAfter:t?parseInt(t[1],10):60,originalError:e}}return e.message.includes("5")||e.message.includes("Server")?{code:"SERVER_ERROR",message:"Server error occurred",originalError:e}:{code:"NETWORK_ERROR",message:e.message||"Network error",originalError:e}}return{code:"NETWORK_ERROR",message:"Unknown error occurred"}}createErrorResponse(e,t,n){return{reply:e,confidence:t,sources:[],offline:!1,retryAfter:n}}sleep(e){return new Promise(t=>setTimeout(t,e))}}const ce=["nav a[href]",'[role="navigation"] a[href]',"header a[href]",".nav a[href]",".navbar a[href]",".navigation a[href]",".sidebar a[href]",".side-nav a[href]",".sidenav a[href]",".menu a[href]",".main-menu a[href]",".top-menu a[href]","[data-nav] a[href]","[data-menu] a[href]","[data-navigation] a[href]",'[aria-label*="navigation" i] a[href]','[aria-label*="menu" i] a[href]','[aria-label*="breadcrumb" i] a[href]',".breadcrumb a[href]",".breadcrumbs a[href]",'a[href^="/"]'],ue=["/login","/logout","/signin","/signout","/sign-in","/sign-out","/register","/signup","/sign-up","/forgot-password","/reset-password","/auth/*","/oauth/*","/callback/*","/sso/*","/api/*","/_next/*","/_nuxt/*","/__*","javascript:*","mailto:*","tel:*","#*"];class de{constructor(e,t,n){this.staticEntries=[],this.discoveredEntries=[],this.backendEntries=[],this.backendCache=null,this.isInitialized=!1,this.initPromise=null,this.detectedFramework="generic",this.popstateHandler=null,this.config=e,this.apiUrl=t,this.apiKey=n,e.static&&(this.staticEntries=this.enhanceEntries(e.static,"props"))}async initialize(){if(!this.isInitialized){if(this.initPromise)return this.initPromise;this.initPromise=this.performInitialization(),await this.initPromise,this.isInitialized=!0}}async performInitialization(){await this.waitForDOMReady();const e=this.loadFromLocalStorage();if(e)return this.discoveredEntries=e,console.log(`[SiteMapDiscovery] Loaded ${e.length} entries from cache`),void this.refreshInBackground();const t=[];!1!==this.config.discovery?.enabled&&t.push(this.discoverFromFramework()),!1!==this.config.backend?.enabled&&this.config.backend?.endpoint&&t.push(this.fetchFromBackend());const n=await Promise.allSettled(t);for(const e of n)if("fulfilled"===e.status){const{entries:t,source:n}=e.value;"discovery"===n?(this.discoveredEntries=t,this.saveToLocalStorage(t)):"backend"===n&&(this.backendEntries=t)}else console.warn("[SiteMapDiscovery] Source failed:",e.reason);this.setupPopstateListener();const r=this.staticEntries.length+this.discoveredEntries.length+this.backendEntries.length;console.log(`[SiteMapDiscovery] Initialized with ${r} total entries (${this.staticEntries.length} static, ${this.discoveredEntries.length} discovered, ${this.backendEntries.length} backend)`)}async waitForDOMReady(){if("undefined"!=typeof document){if("complete"!==document.readyState&&"interactive"!==document.readyState)return new Promise(e=>{document.addEventListener("DOMContentLoaded",()=>e(),{once:!0})});await new Promise(e=>setTimeout(e,0))}}setupPopstateListener(){"undefined"!=typeof window&&(this.popstateHandler=()=>{setTimeout(()=>{this.refreshInBackground()},100)},window.addEventListener("popstate",this.popstateHandler))}async refreshInBackground(){try{const e=await this.discoverFromFramework();e.entries.length>0&&(this.discoveredEntries=e.entries,this.saveToLocalStorage(e.entries))}catch(e){console.debug("[SiteMapDiscovery] Background refresh failed:",e)}}getCacheKey(){return"undefined"==typeof window?"astermind-sitemap":`astermind-sitemap-${window.location.origin}`}loadFromLocalStorage(){if("undefined"==typeof localStorage)return null;try{const e=this.getCacheKey(),t=localStorage.getItem(e);if(!t)return null;const n=JSON.parse(t);if("1"!==n.version)return localStorage.removeItem(e),null;const r=this.config.discovery?.cacheTtl??3e5;return Date.now()-n.timestamp>r?(localStorage.removeItem(e),null):(this.detectedFramework=n.framework,n.entries)}catch(e){return console.debug("[SiteMapDiscovery] Failed to load from cache:",e),null}}saveToLocalStorage(e){if("undefined"!=typeof localStorage&&!1!==this.config.discovery?.cacheRoutes)try{const t=this.getCacheKey(),n={entries:e,url:"undefined"!=typeof window?window.location.href:"",timestamp:Date.now(),framework:this.detectedFramework,version:"1"};localStorage.setItem(t,JSON.stringify(n))}catch(e){console.debug("[SiteMapDiscovery] Failed to save to cache:",e)}}clearCache(){"undefined"!=typeof localStorage&&localStorage.removeItem(this.getCacheKey())}dispose(){this.popstateHandler&&"undefined"!=typeof window&&(window.removeEventListener("popstate",this.popstateHandler),this.popstateHandler=null)}getDetectedFramework(){return this.detectedFramework}getMergedEntries(){return this.mergeEntries(this.staticEntries,this.discoveredEntries,this.backendEntries)}getLegacyEntries(){return this.getMergedEntries().map(e=>({path:e.path,name:e.name,description:e.description,params:e.params,dynamicParams:e.dynamicParams,aliases:e.aliases}))}async discoverFromFramework(){const e=this.config.discovery||{},t=[];try{const n=e.framework||this.detectFramework();this.detectedFramework=n;let r=[];switch(n){case"react-router":r=this.discoverReactRouter();break;case"vue-router":r=this.discoverVueRouter();break;case"next":r=this.discoverNextRoutes();break;case"angular":r=this.discoverAngularRoutes();break;default:!1!==e.domFallback&&(r=this.discoverFromDOM(e.navSelectors))}for(const n of r){if(this.shouldExcludeRoute(n.path,e.excludePaths))continue;let r;r=e.transformRoute?e.transformRoute(n):this.defaultRouteTransform(n),r&&t.push(this.enhanceEntry(r,"discovery"))}console.log(`[SiteMapDiscovery] Discovered ${t.length} routes from ${n}`)}catch(e){return console.warn("[SiteMapDiscovery] Framework discovery failed:",e),{entries:[],source:"discovery",timestamp:Date.now(),error:String(e)}}return{entries:t,source:"discovery",timestamp:Date.now()}}detectFramework(){if("undefined"==typeof window)return"generic";const e=window;return e.__REACT_ROUTER_DATA_ROUTER__||e.__reactRouterContext?"react-router":e.__VUE_ROUTER__||e.__VUE_APP__?.$router?"vue-router":e.__NEXT_DATA__?"next":e.ng||document.querySelector("[ng-version]")?"angular":"generic"}discoverReactRouter(){const e=[];if("undefined"==typeof window)return e;const t=window.__REACT_ROUTER_DATA_ROUTER__;return t?.routes?(this.extractRoutesFromConfig(t.routes,e,""),e):e}extractRoutesFromConfig(e,t,n){for(const r of e){const e=this.normalizePath(n,r.path||""),a={path:e,name:r.handle?.name||r.handle?.title||r.id,meta:r.handle||{},children:[]};(r.path||r.index)&&t.push(a),r.children&&this.extractRoutesFromConfig(r.children,t,e)}}discoverVueRouter(){const e=[];if("undefined"==typeof window)return e;const t=window,n=t.__VUE_APP__,r=n?.$router||t.__VUE_ROUTER__;if(r?.getRoutes){const t=r.getRoutes();for(const n of t)e.push({path:n.path,name:n.name?.toString(),meta:n.meta||{},component:n.components?.default?.name})}return e}discoverNextRoutes(){const e=[];if("undefined"==typeof window)return e;const t=window.__NEXT_DATA__;if(!t)return e;const n=t.buildManifest?.pages||{};for(const t of Object.keys(n))t.startsWith("/_")||e.push({path:t,name:this.pathToName(t)});return e}discoverAngularRoutes(){return[]}discoverFromDOM(e){const t=[];if("undefined"==typeof document)return t;const n=e||ce,r=this.config.discovery?.maxDomLinks??200,a=this.config.discovery?.excludePaths||[],o=[...ue,...a],i=new Set;let s=0;for(const e of n){if(s>=r)break;try{const n=document.querySelectorAll(e);for(const e of n){if(s>=r)break;const n=e.getAttribute("href");if(!n)continue;if(n.startsWith("http")&&!n.startsWith(window.location.origin))continue;let a=n;if(n.startsWith("http"))try{a=new URL(n).pathname}catch{continue}else n.startsWith("/")||(a=`/${n}`);const l=a.split("?")[0].split("#")[0];i.has(l)||"/"!==l&&(this.shouldExcludeRoute(l,o)||(i.add(l),s++,t.push({path:l,name:e.textContent?.trim()||this.pathToName(l)})))}}catch(e){}}return console.log(`[SiteMapDiscovery] DOM scan found ${t.length} routes (limit: ${r})`),t}async fetchFromBackend(){const e=this.config.backend||{},t=e.endpoint||"/api/external/sitemap";if(this.backendCache&&Date.now()<this.backendCache.expiresAt)return{entries:this.backendCache.entries,source:"backend",timestamp:this.backendCache.fetchedAt};try{const n=new URL(t,this.apiUrl);!1!==e.tenantScoped&&n.searchParams.set("tenantScoped","true"),!1!==e.includeGeneral&&n.searchParams.set("includeGeneral","true");const r=await fetch(n.toString(),{method:"GET",headers:{"X-API-Key":this.apiKey,"Content-Type":"application/json",...e.headers}});if(!r.ok)throw new Error(`Backend sitemap fetch failed: ${r.status}`);const a=await r.json(),o=this.transformBackendResponse(a),i=e.cacheTtl||3e5;return this.backendCache={entries:o,fetchedAt:Date.now(),expiresAt:Date.now()+i},console.log(`[SiteMapDiscovery] Loaded ${o.length} routes from backend`),{entries:o,source:"backend",timestamp:Date.now()}}catch(e){return console.warn("[SiteMapDiscovery] Backend fetch failed:",e),{entries:this.backendCache?.entries||[],source:"backend",timestamp:Date.now(),error:String(e)}}}transformBackendResponse(e){return(Array.isArray(e)?e:e.entries||e.sitemap||e.routes||[]).map(e=>this.enhanceEntry({path:e.url||e.path,name:e.title||e.name,description:e.description,aliases:e.keywords||e.aliases,params:e.params,dynamicParams:e.dynamicParams},"backend"))}mergeEntries(...e){const t=this.config.merge||{},n=t.sourcePriority||["props","backend","discovery"],r=t.deduplication||"path",a=new Map;n.forEach((e,t)=>{a.set(e,n.length-t)});const o=[];for(const t of e)for(const e of t){const t=a.get(e._source||"props")||0;o.push({...e,_priority:t})}o.sort((e,t)=>(t._priority||0)-(e._priority||0));const i=new Map;for(const e of o){let n;switch(r){case"name":n=e.name.toLowerCase();break;case"both":n=`${e.path}|${e.name.toLowerCase()}`;break;default:n=this.normalizePath("",e.path)}if(i.has(n)){if(!1!==t.keepNonConflicting){const t=i.get(n);!t.description&&e.description&&(t.description=e.description),!t.aliases?.length&&e.aliases?.length&&(t.aliases=e.aliases)}}else i.set(n,e)}return Array.from(i.values())}enhanceEntries(e,t){return e.map(e=>this.enhanceEntry(e,t))}enhanceEntry(e,t){return{...e,_source:t,_discoveredAt:Date.now()}}defaultRouteTransform(e){return e.path&&"*"!==e.path&&"**"!==e.path?{path:e.path,name:e.name||e.meta?.title||this.pathToName(e.path),description:e.meta?.description,aliases:e.meta?.keywords||e.meta?.aliases,dynamicParams:e.path.includes(":")||e.path.includes("[")}:null}normalizePath(e,t){return t&&"/"!==t?t.startsWith("/")?t:e&&"/"!==e?`${e}/${t}`.replace(/\/+/g,"/"):`/${t}`:e||"/"}pathToName(e){const t=e.split("/").filter(Boolean);return(t[t.length-1]||"Home").replace(/[-_]/g," ").replace(/\[.*?\]/g,"").replace(/:/g,"").split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ").trim()||"Page"}shouldExcludeRoute(e,t){if(!t?.length)return!1;for(const n of t){if(new RegExp("^"+n.replace(/\*/g,".*").replace(/\?/g,".")+"$").test(e))return!0}return!1}async refresh(){this.backendCache=null,this.isInitialized=!1,this.initPromise=null,await this.initialize()}isReady(){return this.isInitialized}getStats(){return{static:this.staticEntries.length,discovered:this.discoveredEntries.length,backend:this.backendEntries.length,merged:this.getMergedEntries().length}}}const fe={navigate:[{pattern:/^(go to|navigate to|take me to|open|show me|bring up)\s+(.+)/i,type:"navigate",weight:.9},{pattern:/^(i want to see|i need to go to|let me see)\s+(.+)/i,type:"navigate",weight:.85},{pattern:/^(where is|how do i get to)\s+(.+)/i,type:"navigate",weight:.6}],fillForm:[{pattern:/^(search for|find|look up|search)\s+(.+)/i,type:"fillForm",weight:.88},{pattern:/^(filter by|set .+ to|change .+ to)\s+(.+)/i,type:"fillForm",weight:.85},{pattern:/^(enter|type|put)\s+(.+)\s+(in|into)\s+(.+)/i,type:"fillForm",weight:.9}],clickElement:[{pattern:/^(click|press|hit|tap)\s+(the\s+)?(.+)\s+(button|link)/i,type:"clickElement",weight:.9},{pattern:/^(submit|send|confirm|save|cancel|delete)/i,type:"clickElement",weight:.85}],triggerModal:[{pattern:/^(open|show|display)\s+(the\s+)?(.+)\s+(modal|dialog|popup|window)/i,type:"triggerModal",weight:.9},{pattern:/^(open|show)\s+(help|settings|preferences|options)/i,type:"triggerModal",weight:.85}],scroll:[{pattern:/^(scroll to|jump to|go to)\s+(the\s+)?(.+)\s+(section|area|part)/i,type:"scroll",weight:.85},{pattern:/^(show me|take me to)\s+(the\s+)?(bottom|top|end|beginning)/i,type:"scroll",weight:.8}],highlight:[{pattern:/^(highlight|show me|point to|where is)\s+(the\s+)?(.+)/i,type:"highlight",weight:.7}],custom:[{pattern:/^(export|download|refresh|reload|sync)/i,type:"custom",weight:.85}]};class he{constructor(e,t="",n=""){this.categories=[],this.topicKeywords=new Map,this.siteMapDiscovery=null,this.config=e,this.siteMapIndex=new Map,this.formIndex=new Map,this.modalIndex=new Map,this.buildIndexes();const r=e.siteMapConfig??(e.enabled&&!e.siteMap?.length?{discovery:{enabled:!0}}:void 0);r&&(this.siteMapDiscovery=new de(r,t,n),!e.siteMapConfig&&e.enabled&&console.log("[CyberneticIntentClassifier] Zero-config mode: auto-discovery enabled"))}buildIndexes(){if(this.config.siteMap)for(const e of this.config.siteMap){const t=[e.name.toLowerCase(),e.path.toLowerCase(),...(e.aliases||[]).map(e=>e.toLowerCase())];for(const n of t)this.siteMapIndex.set(n,e)}if(this.config.forms)for(const[e,t]of Object.entries(this.config.forms)){const n=[e.toLowerCase(),t.name.toLowerCase(),...(t.aliases||[]).map(e=>e.toLowerCase())];for(const e of n)this.formIndex.set(e,t)}if(this.config.modals)for(const[e,t]of Object.entries(this.config.modals)){const n=[e.toLowerCase(),t.id.toLowerCase(),...(t.aliases||[]).map(e=>e.toLowerCase())];for(const e of n)this.modalIndex.set(e,t)}}classify(e){if(!this.config.enabled)return{action:null,shouldEscalate:!0,rawConfidence:0};const t=e.trim().toLowerCase();for(const[t,n]of Object.entries(fe))for(const{pattern:r,weight:a}of n){const n=e.match(r);if(n){const e=this.buildAction(t,n,a);if(e)return e}}const n=this.fuzzyMatchSiteMap(t);if(n)return n;const r=this.matchCustomAction(t);return r||{action:null,shouldEscalate:!0,rawConfidence:0,matchedPatterns:[]}}buildAction(e,t,n){const r=this.config.confidenceThreshold??.8;switch(e){case"navigate":{const e=this.extractTarget(t),a=this.findSiteMapMatch(e);if(a){const e=n*a.similarity;return{action:{id:`action-${Date.now()}`,type:"navigate",target:a.entry.path,confidence:e,explanation:`Navigate to ${a.entry.name}`},shouldEscalate:e<r,rawConfidence:e,matchedPatterns:["navigate",a.entry.name]}}break}case"fillForm":{const e=this.extractTarget(t),{field:a,value:o}=this.parseFormIntent(t);if(a){const e=.95*n;return{action:{id:`action-${Date.now()}`,type:"fillForm",target:a.selector,params:{value:o},confidence:e,explanation:`Fill "${a.name}" with "${o}"`},shouldEscalate:e<r,rawConfidence:e,matchedPatterns:["fillForm",a.name]}}if(this.config.forms?.search){const t=.9*n;return{action:{id:`action-${Date.now()}`,type:"fillForm",target:this.config.forms.search.selector,params:{value:e},confidence:t,explanation:`Search for "${e}"`},shouldEscalate:t<r,rawConfidence:t,matchedPatterns:["fillForm","search"]}}break}case"clickElement":{const e=this.extractTarget(t),a=this.findButtonSelector(e);if(a){const t=.95*n;return{action:{id:`action-${Date.now()}`,type:"clickElement",target:a,confidence:t,explanation:`Click "${e}" button`},shouldEscalate:t<r,rawConfidence:t,matchedPatterns:["clickElement",e]}}break}case"triggerModal":{const e=this.extractTarget(t),a=this.findModalConfig(e);if(a){const e=.95*n;return{action:{id:`action-${Date.now()}`,type:"triggerModal",target:a.trigger,confidence:e,explanation:`Open ${a.id} modal`},shouldEscalate:e<r,rawConfidence:e,matchedPatterns:["triggerModal",a.id]}}break}case"scroll":{const e=this.extractTarget(t),a=this.findScrollTarget(e);if(a){const t=.9*n;return{action:{id:`action-${Date.now()}`,type:"scroll",target:a,confidence:t,explanation:`Scroll to ${e}`},shouldEscalate:t<r,rawConfidence:t,matchedPatterns:["scroll",e]}}break}case"highlight":{const e=this.extractTarget(t),a=this.findElementByDescription(e);if(a){const t=.85*n;return{action:{id:`action-${Date.now()}`,type:"highlight",target:a,confidence:t,explanation:`Highlight ${e}`},shouldEscalate:t<r,rawConfidence:t,matchedPatterns:["highlight",e]}}break}case"custom":{const e=t[1]?.toLowerCase();if(this.config.customActions?.[e]){const t=.95*n;return{action:{id:`action-${Date.now()}`,type:"custom",target:e,confidence:t,explanation:`Execute ${e} action`},shouldEscalate:t<r,rawConfidence:t,matchedPatterns:["custom",e]}}break}}return null}extractTarget(e){for(let t=e.length-1;t>=1;t--)if(e[t])return e[t].trim();return""}stripArticles(e){return e.replace(/^(the|a|an|my|our|your|this|that)\s+/gi,"").replace(/\s+(page|section|screen|view)$/gi,"").trim()}findSiteMapMatch(e){const t=e.toLowerCase().replace(/[^a-z0-9\s]/g,""),n=this.stripArticles(t),r=this.siteMapIndex.get(t)||this.siteMapIndex.get(n);if(r)return{entry:r,similarity:1};let a=null,o=0;for(const[e,r]of this.siteMapIndex){const i=this.calculateSimilarity(t,e),s=this.calculateSimilarity(n,e),l=Math.max(i,s);l>o&&l>.5&&(o=l,a=r)}return a?{entry:a,similarity:o}:null}fuzzyMatchSiteMap(e){const t=this.config.confidenceThreshold??.8;for(const[n,r]of this.siteMapIndex)if(e.includes(n)){const e=.75;return{action:{id:`action-${Date.now()}`,type:"navigate",target:r.path,confidence:e,explanation:`Navigate to ${r.name}`},shouldEscalate:e<t,rawConfidence:e,matchedPatterns:["fuzzy-sitemap",n]}}return null}matchCustomAction(e){if(!this.config.customActions)return null;const t=this.config.confidenceThreshold??.8;for(const n of Object.keys(this.config.customActions))if(e.includes(n.toLowerCase())){const e=.85;return{action:{id:`action-${Date.now()}`,type:"custom",target:n,confidence:e,explanation:`Execute ${n}`},shouldEscalate:e<t,rawConfidence:e,matchedPatterns:["custom",n]}}return null}parseFormIntent(e){const t=e[0];for(const[,e]of this.formIndex)if(t.toLowerCase().includes(e.name.toLowerCase())){const n=t.match(new RegExp(`${e.name}[^a-z]*(.+)`,"i"));return{field:e,value:n?.[1]?.trim()||""}}return{field:null,value:this.extractTarget(e)}}findButtonSelector(e){const t=e.toLowerCase();if("undefined"==typeof document)return`button:contains("${e}")`;const n=[`[data-action="${t}"]`,`[aria-label*="${t}" i]`,`.btn-${t}`,`#${t}-button`,`button.${t}`];for(const e of n)try{if(document.querySelector(e))return e}catch{}const r=document.querySelectorAll('button, [role="button"], a.btn');for(const e of r)if(e.textContent?.toLowerCase().includes(t))return this.generateUniqueSelector(e);return null}findModalConfig(e){return this.modalIndex.get(e.toLowerCase())||null}findScrollTarget(e){const t=e.toLowerCase();if("top"===t||"beginning"===t)return"body";if("bottom"===t||"end"===t)return"body:last-child";if("undefined"==typeof document)return`#${t.replace(/\s+/g,"-")}`;const n=[`#${t.replace(/\s+/g,"-")}`,`[data-section="${t}"]`,`.${t.replace(/\s+/g,"-")}-section`,`section[aria-label*="${t}" i]`];for(const e of n)try{if(document.querySelector(e))return e}catch{continue}return null}findElementByDescription(e){const t=e.toLowerCase();if("undefined"==typeof document)return`[aria-label*="${t}" i]`;const n=[`[aria-label*="${t}" i]`,`[data-testid*="${t}" i]`,`[title*="${t}" i]`];for(const e of n)try{if(document.querySelector(e))return e}catch{continue}return null}generateUniqueSelector(e){if(e.id)return`#${e.id}`;if(e.getAttribute("data-testid"))return`[data-testid="${e.getAttribute("data-testid")}"]`;const t=[];let n=e;for(;n&&n!==document.body;){let e=n.tagName.toLowerCase();if(n.className&&"string"==typeof n.className){const t=n.className.split(" ").filter(e=>e&&!e.includes(" "));t.length>0&&(e+=`.${t.slice(0,2).join(".")}`)}t.unshift(e),n=n.parentElement}return t.join(" > ")}calculateSimilarity(e,t){const n=new Set(e.split(/\s+/)),r=new Set(t.split(/\s+/)),a=new Set([...n].filter(e=>r.has(e))),o=new Set([...n,...r]);return a.size/o.size}getConfig(){return this.config}async trainFromExport(e){if(e.categories){this.categories=e.categories;for(const t of e.categories)for(const e of t.keywords){const n=this.topicKeywords.get(t.name)||[];n.push(e.toLowerCase()),this.topicKeywords.set(t.name,n)}}const t=this.extractTopicsFromDocuments(e.documents);for(const[e,n]of t){const t=this.topicKeywords.get(e)||[];t.push(...n),this.topicKeywords.set(e,[...new Set(t)])}e.sitemap&&this.loadSitemapEntries(e.sitemap),console.log(`[CyberneticIntentClassifier] Trained with ${this.categories.length} categories, ${this.topicKeywords.size} topics`)}async loadSitemap(e){if(e.enabled)if(e.sitemapData)this.loadSitemapEntries(e.sitemapData);else if(e.sitemapUrl)try{const t=await fetch(e.sitemapUrl);if(!t.ok)throw new Error(`Failed to fetch sitemap: ${t.status}`);const n=await t.json();this.loadSitemapEntries(n)}catch(e){console.error("[CyberneticIntentClassifier] Failed to load sitemap:",e)}}loadSitemapEntries(e){for(const t of e){const e={path:t.url,name:t.title,description:t.description,aliases:t.keywords},n=[t.title.toLowerCase(),t.url.toLowerCase(),...(t.keywords||[]).map(e=>e.toLowerCase())];if(t.description){const e=t.description.toLowerCase().split(/\s+/).filter(e=>e.length>4);n.push(...e)}for(const t of n)this.siteMapIndex.set(t,e)}console.log(`[CyberneticIntentClassifier] Loaded ${e.length} sitemap entries`)}extractTopicsFromDocuments(e){const t=new Map;for(const n of e){const e=n.title.toLowerCase(),r=[];n.metadata?.keywords&&r.push(...n.metadata.keywords.map(e=>e.toLowerCase()));const a=n.title.toLowerCase().replace(/[^a-z0-9\s]/g,"").split(/\s+/).filter(e=>e.length>3&&!this.isStopWord(e));r.push(...a);const o=n.content.toLowerCase().replace(/[^a-z0-9\s]/g,"").split(/\s+/).filter(e=>e.length>4&&!this.isStopWord(e)),i=new Map;for(const e of o)i.set(e,(i.get(e)||0)+1);const s=[...i.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e])=>e);r.push(...s),t.set(e,[...new Set(r)])}return t}isStopWord(e){return new Set(["the","a","an","and","or","but","in","on","at","to","for","of","with","by","from","up","about","into","through","during","is","are","was","were","be","been","being","have","has","had","do","does","did","will","would","could","should","may","might","this","that","these","those","it","its","they","them","their","what","which","who","whom","when","where","why","how","all","each","every","both","few","more","most","other","some","such","no","not","only","same","so","than","too","very","can","just","dont","now","here","there","also","your","you"]).has(e)}getCategories(){return this.categories}getTopicKeywords(){return this.topicKeywords}isTrained(){return this.categories.length>0||this.topicKeywords.size>0}async initializeDiscovery(){if(this.siteMapDiscovery)try{await this.siteMapDiscovery.initialize(),this.rebuildIndexesFromDiscovery(),console.log(`[CyberneticIntentClassifier] Discovery complete, indexed ${this.siteMapIndex.size} entries`)}catch(e){console.error("[CyberneticIntentClassifier] Discovery initialization failed:",e)}else console.log("[CyberneticIntentClassifier] No siteMapConfig provided, skipping discovery")}rebuildIndexesFromDiscovery(){if(!this.siteMapDiscovery)return;const e=this.siteMapDiscovery.getLegacyEntries();this.siteMapIndex.clear();for(const t of e){const e={path:t.path,name:t.name,description:t.description,params:t.params,aliases:t.aliases},n=[t.name.toLowerCase(),t.path.toLowerCase(),...(t.aliases||[]).map(e=>e.toLowerCase())];if(t.description){const e=t.description.toLowerCase().split(/\s+/).filter(e=>e.length>4&&!this.isStopWord(e));n.push(...e)}for(const t of n)this.siteMapIndex.set(t,e)}}isSiteMapReady(){return this.siteMapDiscovery?this.siteMapDiscovery.isReady():this.siteMapIndex.size>0||(this.config.siteMap?.length??0)>0}async ensureSiteMapReady(){this.isSiteMapReady()||await this.initializeDiscovery()}async refreshSiteMap(){this.siteMapDiscovery?(await this.siteMapDiscovery.refresh(),this.rebuildIndexesFromDiscovery()):console.log("[CyberneticIntentClassifier] No siteMapConfig provided, cannot refresh")}getSiteMapDiscovery(){return this.siteMapDiscovery}getSiteMapEntries(){return this.siteMapDiscovery?this.siteMapDiscovery.getLegacyEntries():this.config.siteMap||[]}}class pe{constructor(e){this.highlightOverlay=null,this.actionCount=0,this.lastActionReset=Date.now(),this.config=e,this.classifier=new he(e),"undefined"!=typeof document&&this.injectStyles()}interpretIntent(e){return this.classifier.classify(e)}async executeAction(e){const t=Date.now();t-this.lastActionReset>6e4&&(this.actionCount=0,this.lastActionReset=t);const n=this.config.maxActionsPerTurn??5;if(this.actionCount>=n)return{success:!1,message:`Rate limit exceeded. Maximum ${n} actions per minute.`};if(!this.isActionAllowed(e))return{success:!1,message:`Action type "${e.type}" is not allowed`};switch(this.actionCount++,e.type){case"navigate":return this.navigate(e.target,e.params);case"fillForm":return this.fillForm(e.target,e.params?.value);case"clickElement":return this.clickElement(e.target);case"triggerModal":return this.triggerModal(e.target);case"scroll":return this.scrollToElement(e.target);case"highlight":return this.highlightElement(e.target);case"custom":return this.executeCustomAction(e.target,e.params);default:return{success:!1,message:`Unknown action type: ${e.type}`}}}isActionAllowed(e){const t=this.config.allowedActions;if(!t)return!0;const n={navigate:"navigate",fillForm:"fill",clickElement:"click",scroll:"scroll",highlight:"click",triggerModal:"click",custom:"click"}[e.type];return t.includes(n)}isSelectorAllowed(e){if(this.config.blockedSelectors)for(const t of this.config.blockedSelectors)if(e.includes(t))return!1;return!(this.config.allowedSelectors&&this.config.allowedSelectors.length>0)||this.config.allowedSelectors.some(t=>e.includes(t))}async navigate(e,t){try{if(!this.validateNavigationUrl(e))return{success:!1,message:"Invalid or blocked URL"};let n=e;if(t){const e=new URLSearchParams;for(const[n,r]of Object.entries(t))null!=r&&e.set(n,String(r));const r=e.toString();r&&(n+=(n.includes("?")?"&":"?")+r)}return"undefined"==typeof window?{success:!0,message:`Navigation to ${e} would be executed (server-side)`}:this.isInternalUrl(n)?this.tryClientSideNavigation(n)?{success:!0,message:`Navigated to ${e}`}:(window.location.href=n,{success:!0,message:`Navigating to ${e}...`}):(window.open(n,"_blank","noopener,noreferrer"),{success:!0,message:`Opened ${n} in new tab`})}catch(e){return{success:!1,message:"Navigation failed",error:String(e)}}}async fillForm(e,t){if(!this.isSelectorAllowed(e))return{success:!1,message:`Selector "${e}" is not allowed`};const n=this.sanitizeSelector(e);if("undefined"==typeof document)return{success:!0,message:`Form fill would set "${n}" to "${t}" (server-side)`};try{const e=document.querySelector(n);if(!e)return{success:!1,message:`Element not found: ${n}`};if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement))return{success:!1,message:"Element is not a form field"};if(e.focus(),e instanceof HTMLSelectElement){const n=Array.from(e.options).find(e=>e.value.toLowerCase()===t.toLowerCase()||e.text.toLowerCase()===t.toLowerCase());if(!n)return{success:!1,message:`Option "${t}" not found`};e.value=n.value}else e.value=t;e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0}));const r=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value")?.set;return r&&e instanceof HTMLInputElement&&(r.call(e,t),e.dispatchEvent(new Event("input",{bubbles:!0}))),{success:!0,message:`Filled field with "${t}"`}}catch(e){return{success:!1,message:"Failed to fill form field",error:String(e)}}}async clickElement(e){if(!this.isSelectorAllowed(e))return{success:!1,message:`Selector "${e}" is not allowed`};const t=this.sanitizeSelector(e);if("undefined"==typeof document)return{success:!0,message:`Click on "${t}" would be executed (server-side)`};try{const e=document.querySelector(t);return e?e instanceof HTMLElement?(e.scrollIntoView({behavior:"smooth",block:"center"}),await this.sleep(300),e.click(),{success:!0,message:"Element clicked"}):{success:!1,message:"Element is not clickable"}:{success:!1,message:`Element not found: ${t}`}}catch(e){return{success:!1,message:"Failed to click element",error:String(e)}}}async triggerModal(e){return this.clickElement(e)}async scrollToElement(e){if("undefined"==typeof window)return{success:!0,message:`Scroll to "${e}" would be executed (server-side)`};try{if("body"===e)return window.scrollTo({top:0,behavior:"smooth"}),{success:!0,message:"Scrolled to top"};if("body:last-child"===e)return window.scrollTo({top:document.body.scrollHeight,behavior:"smooth"}),{success:!0,message:"Scrolled to bottom"};const t=document.querySelector(e);return t?(t.scrollIntoView({behavior:"smooth",block:"start"}),{success:!0,message:"Scrolled to element"}):{success:!1,message:`Element not found: ${e}`}}catch(e){return{success:!1,message:"Failed to scroll",error:String(e)}}}async highlightElement(e){if(!this.isSelectorAllowed(e))return{success:!1,message:`Selector "${e}" is not allowed`};if("undefined"==typeof document)return{success:!0,message:`Highlight on "${e}" would be shown (server-side)`};try{const t=document.querySelector(e);if(!t)return{success:!1,message:`Element not found: ${e}`};this.removeHighlight(),t.scrollIntoView({behavior:"smooth",block:"center"}),await this.sleep(300);const n=t.getBoundingClientRect(),r=document.createElement("div");return r.className="astermind-highlight-overlay",r.style.cssText=`\n position: fixed;\n top: ${n.top-4}px;\n left: ${n.left-4}px;\n width: ${n.width+8}px;\n height: ${n.height+8}px;\n border: 3px solid #4F46E5;\n border-radius: 4px;\n pointer-events: none;\n z-index: 999999;\n animation: astermind-highlight-pulse 1s ease-in-out 3;\n `,document.body.appendChild(r),this.highlightOverlay=r,setTimeout(()=>this.removeHighlight(),3e3),{success:!0,message:"Element highlighted"}}catch(e){return{success:!1,message:"Failed to highlight element",error:String(e)}}}async executeCustomAction(e,t){if(!this.isAllowedCustomAction(e))return{success:!1,message:`Custom action "${e}" not found`};const n=this.config.customActions[e];try{return await n(t)}catch(t){return{success:!1,message:`Custom action "${e}" failed`,error:String(t)}}}isInternalUrl(e){if(e.startsWith("/")||e.startsWith("./")||e.startsWith("../"))return!0;if("undefined"==typeof window)return!0;try{return new URL(e,window.location.href).origin===window.location.origin}catch{return!0}}tryClientSideNavigation(e){if("undefined"==typeof window)return!1;try{return window.history.pushState({},"",e),window.dispatchEvent(new PopStateEvent("popstate")),e.includes("#")&&window.dispatchEvent(new HashChangeEvent("hashchange")),!0}catch{return!1}}validateNavigationUrl(e){if(/^(javascript|data):/i.test(e))return!1;if("undefined"==typeof window)return!0;try{return new URL(e,window.location.href).origin===window.location.origin||e.startsWith("/")}catch{return e.startsWith("/")}}sanitizeSelector(e){return e.replace(/[<>'"]/g,"").replace(/javascript:/gi,"").replace(/data:/gi,"").trim()}isAllowedCustomAction(e){return void 0!==this.config.customActions&&Object.prototype.hasOwnProperty.call(this.config.customActions,e)}removeHighlight(){this.highlightOverlay&&(this.highlightOverlay.remove(),this.highlightOverlay=null)}injectStyles(){if("undefined"==typeof document)return;if(document.getElementById("astermind-agent-styles"))return;const e=document.createElement("style");e.id="astermind-agent-styles",e.textContent="\n @keyframes astermind-highlight-pulse {\n 0%, 100% {\n box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.4);\n }\n 50% {\n box-shadow: 0 0 0 10px rgba(79, 70, 229, 0);\n }\n }\n\n .astermind-highlight-overlay {\n transition: all 0.2s ease-out;\n }\n ",document.head.appendChild(e)}sleep(e){return new Promise(t=>setTimeout(t,e))}getConfig(){return this.config}getClassifier(){return this.classifier}resetActionCount(){this.actionCount=0,this.lastActionReset=Date.now()}}const me={hiddenUnits:50,activation:"relu",ridgeLambda:.01,weightInit:"xavier",seed:1337,dropout:0,log:{verbose:!0,toFile:!1,modelName:"Unnamed ELM Model",level:"info"}};function ge(e){let t=0,n=0;for(;0===t;)t=e();for(;0===n;)n=e();return Math.sqrt(-2*Math.log(t))*Math.cos(2*Math.PI*n)}Object.assign(Object.assign({},me),{useTokenizer:!1}),Object.assign(Object.assign({},me),{useTokenizer:!0,maxLen:30,charSet:"abcdefghijklmnopqrstuvwxyz",tokenizerDelimiter:/\s+/});class ye{constructor(e,t,n=1e-4){this.p=e,this.m=t,this.lambda=n,this.Ainv=new Float64Array(e*e),this.Beta=new Float64Array(e*t);const r=1/Math.max(1e-12,n);for(let t=0;t<e;t++)this.Ainv[t*e+t]=r}update(e,t){const{p:n,m:r,Ainv:a,Beta:o}=this,i=new Float64Array(n);for(let t=0;t<n;t++){let r=0,o=t*n;for(let t=0;t<n;t++)r+=a[o+t]*e[t];i[t]=r}let s=1;for(let t=0;t<n;t++)s+=e[t]*i[t];s=Math.max(s,1e-12);const l=1/s;for(let e=0;e<n;e++){const t=i[e]*l;for(let r=0;r<n;r++)a[e*n+r]-=t*i[r]}for(let t=0;t<n;t++){let r=0,o=t*n;for(let t=0;t<n;t++)r+=a[o+t]*e[t];i[t]=r}for(let e=0;e<n;e++){const n=i[e];for(let a=0;a<r;a++)o[e*r+a]+=n*t[a]}}predict(e){const{p:t,m:n,Beta:r}=this,a=new Float64Array(n);for(let o=0;o<n;o++){let i=0;for(let a=0;a<t;a++)i+=e[a]*r[a*n+o];a[o]=i}return a}}function ve(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n]*e[n];return Math.sqrt(Math.max(0,t))}function be(e,t){var n,r;const a=Math.min(e.length,t.length);if(0===a)return 0;let o=0,i=0,s=0;for(let l=0;l<a;l++){const a=null!==(n=e[l])&&void 0!==n?n:0,c=null!==(r=t[l])&&void 0!==r?r:0;o+=a*c,i+=a*a,s+=c*c}const l=o/Math.sqrt(Math.max(i*s,1e-12));return Number.isFinite(l)?l:0}function we(e,t,n,r){return new(n||(n=Promise))(function(a,o){function i(e){try{l(r.next(e))}catch(e){o(e)}}function s(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(i,s)}l((r=r.apply(e,t||[])).next())})}function Se(e){return e.replace(/\s+/g," ").split(/(?<=[.?!])\s+/).map(e=>e.trim()).filter(e=>e.length>8&&/\w/.test(e))}function ke(e){return e.replace(/```[\s\S]*?```/g," ").replace(/`[^`]+`/g," ").replace(/\[[^\]]*\]\([^)]*\)/g,"").replace(/[-–>•→]/g," ").replace(/\s+/g," ").trim()}function xe(e,t){return we(this,arguments,void 0,function*(e,t,n={}){if(!(null==t?void 0:t.length))return"No results found.";const{dim:r=64,features:a=32,sigma:o=1,rounds:i=3,topSentences:s=8,personality:l="neutral"}=n;let c=Se(t.map(e=>ke(e.content)).join(" ")).filter(e=>!function(e){return/^(\*|#)/.test(e)||/chapter/i.test(e)||/part\s*\d+/i.test(e)||/section/i.test(e)||/^\s*[A-Z]\)\s*$/.test(e)||e.length<15}(e)).slice(0,120);if(0===c.length)return ke(t[0].content).slice(0,400);const u=function(e,t,n=1,r=Math.random){const a=new Float64Array(t*e),o=new Float64Array(t),i=1/Math.max(1e-12,n);for(let n=0;n<t*e;n++)a[n]=ge(r)*i;for(let e=0;e<t;e++)o[e]=2*r()*Math.PI;return{W:a,b:o,D:t,d:e,sigma:n}}(r,a,o),d=new ye(2*a,1,.001),f=e=>{const t=new Float64Array(r),n=Math.min(e.length,r);for(let r=0;r<n;r++)t[r]=e.charCodeAt(r)/255;return function(e,t){const{W:n,b:r,D:a,d:o}=e,i=new Float64Array(2*a);for(let e=0;e<a;e++){let s=r[e];const l=e*o;for(let e=0;e<o;e++)s+=n[l+e]*(t[e]||0);i[e]=Math.cos(s),i[a+e]=Math.sin(s)}let s=0;for(let e=0;e<i.length;e++)s+=i[e]*i[e];const l=1/Math.sqrt(Math.max(s,1e-12));for(let e=0;e<i.length;e++)i[e]*=l;return i}(u,function(e,t=1e-12){const n=ve(e);if(!(n>t&&Number.isFinite(n)))return new Float64Array(e.length);const r=new Float64Array(e.length),a=1/n;for(let t=0;t<e.length;t++)r[t]=e[t]*a;return r}(t))},h=f(e),p=e.toLowerCase().split(/\W+/).filter(e=>e.length>2),m=c.map(e=>{const t=f(e);let n=be(t,h);const r=e.toLowerCase();for(const e of p)r.includes(e)&&(n+=.02);return{s:e,v:t,w:n}});m.sort((e,t)=>t.w-e.w);let g=m.slice(0,s).map(e=>e.s).join(" "),y=new Float64Array(2*a);for(let e=0;e<i;e++){const e=Se(g).slice(0,s),t=e.map(e=>f(e)),n=t.map(e=>be(e,h));for(let e=0;e<t.length;e++)d.update(t[e],new Float64Array([n[e]]));y.fill(0);for(let e=0;e<t.length;e++){const r=t[e],a=n[e];for(let e=0;e<r.length;e++)y[e]+=r[e]*a}const r=ve(y)||1;for(let e=0;e<y.length;e++)y[e]/=r;const a=e.map(e=>({s:e,w:be(f(e),y)}));a.sort((e,t)=>t.w-e.w),g=a.slice(0,Math.max(3,Math.floor(s/2))).map(e=>e.s).join(" ")}g=function(e){return e.replace(/\s+[-–>•→]\s+/g," ").replace(/\s+\.\s+/g,". ").replace(/([a-z]) - ([a-z])/gi,"$1-$2").replace(/\s{2,}/g," ").trim()}(g);return`${"teacher"===l?"Here’s a simple way to think about it:\n\n":"scientist"===l?"From the retrieved material, we can infer:\n\n":""}${g.charAt(0).toUpperCase()+g.slice(1)}\n\n(${t[0].heading||"Answer"}, Ω-synthesized)`})}function Ce(e,t){let n=0;for(let r=0;r<e.length;r++)n+=e[r]*t[r];return n}function Ee(e,t,n,r){if("cosine"===n){const n=Ce(e,t),r=Math.hypot(...e),a=Math.hypot(...t);return r&&a?n/(r*a):0}if("poly2"===n){const n=Ce(e,t);return Math.pow(n+1,2)}{let n=0;for(let r=0;r<e.length;r++){const a=e[r]-t[r];n+=a*a}return Math.exp(-n/Math.max(1e-9,2*r*r))}}function _e(e,t,n,r,a){const o=function(e,t){const n=new Float64Array(t);for(const[t,r]of e)n[t]=r;return n}(e,t),i=new Float64Array(n.length);for(let e=0;e<n.length;e++){const t=n[e];i[e]=Ee(o,t,r,a)}const s=Math.hypot(...i);if(s>0)for(let e=0;e<i.length;e++)i[e]/=s;return i}"function"==typeof SuppressedError&&SuppressedError;const Me=new Map;function Re(e){const t=e,n=Me.get(t);if(n)return n;let r=e.toLowerCase();if(r=r.replace(/^[^a-z0-9]+|[^a-z0-9]+$/g,""),r.length<=2)return Me.set(t,r),r;r.endsWith("ies")&&r.length>4?r=r.slice(0,-3)+"y":/(xes|ches|shes|zes|sses)$/.test(r)&&r.length>4?r=r.replace(/(xes|ches|shes|zes|sses)$/,e=>"sses"===e?"ss":e.replace(/es$/,"")):r.endsWith("s")&&!/(ss|us)$/.test(r)&&r.length>3&&(r=r.slice(0,-1));const a=[[/ization$|isation$/,"ize"],[/ational$/,"ate"],[/fulness$/,"ful"],[/ousness$/,"ous"],[/iveness$/,"ive"],[/ability$/,"able"],[/ness$/,""],[/ment$/,""],[/ations?$/,"ate"],[/izer$|iser$/,"ize"],[/ally$/,"al"],[/ically$/,"ic"],[/ingly$|edly$/,""],[/ing$|ed$/,""]];for(const[e,t]of a)if(e.test(r)&&r.length-t.length>=4){r=r.replace(e,t);break}return Me.set(t,r),r}function Ae(e,t){const n=Array.from(e,(e,t)=>t);return n.sort((t,n)=>e[n]-e[t]),n.slice(0,t)}function Ie(e){const{query:t,chunks:n,vocabMap:r,idf:a,tfidfDocs:o,denseDocs:i,landmarksIdx:s,landmarkMat:l,vocabSize:c,kernel:u,sigma:d,alpha:f,beta:h,ridge:p,headingW:m,useStem:g,expandQuery:y,topK:v,prefilter:b}=e,w=function(e,t,n,r=1){const a=new Map;for(let t=0;t<e.length;t++){const o=e[t],i=n.get(o);if(void 0===i)continue;const s=t<8?r:1;a.set(i,(a.get(i)||0)+s)}const o=Math.max(1,...a.values()),i=new Map;for(const[e,n]of a){const r=.5+n/o*.5;i.set(e,r*(t[e]||0))}return i}(function(e,t){const n=e.toLowerCase().replace(/[`*_>~]/g," ").replace(/[^a-z0-9]+/g," ").split(/\s+/).filter(Boolean);if(!t)return n;const r=[];for(const e of n){const t=Re(e);t&&t.length>1&&r.push(t)}return r}(y?function(e){const t=[];return/\bmap\b/.test(e)&&t.push("dict key value make"),/\bchan|channel\b/.test(e)&&t.push("goroutine concurrency select buffer"),/\berror\b/.test(e)&&t.push("fmt wrap unwrap sentinel try catch"),/\bstruct\b/.test(e)&&t.push("field method receiver init zero value"),e+" "+t.join(" ")}(t):t,g),a,r,m),S=_e(w,c,l,u,d),k=o.map(e=>function(e,t){let n=0,r=0,a=0;for(const[a,o]of e){r+=o*o;const e=t.get(a);e&&(n+=o*e)}for(const[,e]of t)a+=e*e;return r&&a?n/(Math.sqrt(r)*Math.sqrt(a)):0}(e,w)),x=i.map(e=>function(e,t,n,r){if("cosine"===n){const n=Ce(e,t),r=Math.hypot(...e),a=Math.hypot(...t);return r&&a?n/(r*a):0}if("poly2"===n){const n=Ce(e,t);return Math.pow(n+1,2)}{let n=0;for(let r=0;r<e.length;r++){const a=e[r]-t[r];n+=a*a}return Math.exp(-n/Math.max(1e-9,2*r*r))}}(e,S,u,d)),C=function(e,t){const n=Array.from(new Set(t.toLowerCase().split(/\W+/).filter(e=>e.length>2))),r=/\b(define|declare|syntax|example|function|struct|map|interface)\b/i.test(t);return e.map(e=>{const t=e.rich||e.content||"",a=t.toLowerCase();let o=0;for(const e of n)a.includes(e)&&o++;return r&&/```/.test(t)&&(o+=5),Math.min(1,.03*o)})}(n,t),E=(_=f,M=0,R=1,Math.max(M,Math.min(R,_)));var _,M,R;const A=null!=p?p:.08,I=x.map((e,t)=>{const n=k[t],r=h*C[t],a=1/(1+A*(e*e+n*n+.5*r*r))*(E*e+(1-E)*n+r);return Math.tanh(a)}),P=Math.max(v,null!=b?b:0),L=Ae(I,P),T=Ae(L.map(e=>I[e]),v).map(e=>L[e]);return{items:T.map(e=>{const t=n[e],r=t.rich&&t.rich.trim()||t.content&&t.content.trim()||"(see subsections)";return{score:I[e],heading:t.heading,content:r,index:e}}),scores:T.map(e=>I[e]),indices:T,tfidfScores:T.map(e=>k[e]),denseScores:T.map(e=>x[e])}}const Pe=new Set(["a","an","the","and","or","but","if","then","else","for","to","of","in","on","at","by","with","is","are","was","were","be","been","being","as","from","that","this","it","its","you","your","i","we","they","he","she","them","his","her","our","us","do","does","did","done","not","no","yes","can","could","should","would","may","might","into","about","over","under","between"]);function Le(e){return e.toLowerCase().replace(/[`*_#>~=\[\]{}()!?.:,;'"<>|/\\+-]+/g," ").split(/\s+/).filter(e=>e&&!Pe.has(e))}function Te(e){const t=new Map,n=[],r=[];let a=0;for(const o of e){const e=Le(o);r.push(e.length);const i=new Map;for(const n of e){let e=t.get(n);void 0===e&&(e=a++,t.set(n,e)),i.set(e,(i.get(e)||0)+1)}n.push(i)}const o=e.length,i=Array(a).fill(0);for(const e of n)for(const t of e.keys())i[t]+=1;return{stats:{vocab:t,idf:i.map(e=>Math.log((o+1)/(e+1))+1),avgLen:r.reduce((e,t)=>e+t,0)/Math.max(1,o),df:i},tf:n,docLens:r}}function De(e,t){const n=new Map;let r=0;for(const[a,o]of e){const e=o*(t[a]||0);n.set(a,e),r+=e*e}const a=Math.sqrt(r)||1e-12;for(const[e,t]of n)n.set(e,t/a);return n}function Ne(e,t){const[n,r]=e.size<t.size?[e,t]:[t,e];let a=0;for(const[e,t]of n){const n=r.get(e);void 0!==n&&(a+=t*n)}return a}function ze(e,t,n=1337){const r=new Float64Array(t);for(const[n,a]of e){let e=2654435761*n>>>0;for(let n=0;n<t;n++){e^=e<<13,e^=e>>>17,e^=e<<5;const t=(e>>>0)/4294967296*2-1;r[n]+=a*t}}let a=0;for(let e=0;e<t;e++)a+=r[e]*r[e];const o=Math.sqrt(a)||1e-12;for(let e=0;e<t;e++)r[e]/=o;return r}function Fe(e){return/```+\s*go([\s\S]*?)```/i.test(e)||/\bfunc\s+\w+\s*\(.*\)\s*\w*\s*{/.test(e)}function Oe(e){return/```+/.test(e)||/{[^}]*}/.test(e)}function $e(e,t){const n=(r=Le(e),Array.from(new Set(r)));var r;const a=new Set(Le(t));if(0===n.length||0===a.size)return 0;let o=0;for(const e of n)a.has(e)&&o++;return o/n.length}function je(e,t,n,r,a,o,i,s,l,c){var u;const d=[],f=[],h=Ne(n,r);d.push(h),f.push("cosine_tfidf");const p=function(e,t,n,r,a=1.5,o=.75){let i=0;for(const[s]of e){const e=t.get(s)||0;e<=0||(i+=Math.log(((n.df[s]||0)+.5)/(n.idf.length-(n.df[s]||0)+.5)+1)*(e*(a+1)/(e+a*(1-o+o*(r/(n.avgLen||1)))||1e-12)))}return i}(a,o,i,s);d.push(p),f.push("bm25");const m=$e(t.heading||"",e);d.push(m),f.push("heading_match_frac");const g=function(e,t){const n=new Set(Le(e)),r=new Set(Le(t));let a=0;for(const e of n)r.has(e)&&a++;const o=n.size+r.size-a;return 0===o?0:a/o}(e,t.content||"");d.push(g),f.push("jaccard_tokens");const y=Fe(t.rich||t.content||""),v=Oe(t.rich||t.content||"");var b;d.push(y?1:0),f.push("flag_go_code"),d.push(v?1:0),f.push("flag_any_code"),d.push((b=t.content||"",!/(golang\.org|go\.dev|pkg\.go\.dev)/i.test(b)?0:1)),f.push("flag_go_spec_link"),d.push(null!==(u=t.score_base)&&void 0!==u?u:0),f.push("prior_score_base");const w=(t.content||"").length;if(d.push(1/Math.sqrt(1+w)),f.push("len_inv_sqrt"),l&&c){let e=0,t=0;for(let n=0;n<l.length;n++)e+=l[n]*c[n],t+=Math.abs(l[n]-c[n]);d.push(e),f.push("proj_dot"),d.push(t/l.length),f.push("proj_l1mean")}return{names:f,values:d}}class Ue{constructor(){this.w=null,this.mu=null,this.sigma=null}fit(e,t,n=.01){var r;const a=e.length,o=(null===(r=e[0])||void 0===r?void 0:r.length)||0;if(0===a||0===o)return void(this.w=new Float64Array(o));const i=new Float64Array(o),s=new Float64Array(o);for(let t=0;t<o;t++){let n=0;for(let r=0;r<a;r++)n+=e[r][t];n/=a,i[t]=n;let r=0;for(let o=0;o<a;o++){const a=e[o][t]-n;r+=a*a}s[t]=Math.sqrt(r/a)||1}const l=Array.from({length:a},(e,t)=>new Float64Array(o));for(let t=0;t<a;t++)for(let n=0;n<o;n++)l[t][n]=(e[t][n]-i[n])/s[n];const c=Array.from({length:o},()=>new Float64Array(o)),u=new Float64Array(o);for(let e=0;e<a;e++){const n=l[e],r=t[e];for(let e=0;e<o;e++){u[e]+=n[e]*r;const t=n[e];for(let r=0;r<=e;r++)c[e][r]+=t*n[r]}}for(let e=0;e<o;e++){for(let t=0;t<e;t++)c[t][e]=c[e][t];c[e][e]+=n}const d=Array.from({length:o},()=>new Float64Array(o));for(let e=0;e<o;e++)for(let t=0;t<=e;t++){let n=c[e][t];for(let r=0;r<t;r++)n-=d[e][r]*d[t][r];d[e][t]=e===t?Math.sqrt(Math.max(n,1e-12)):n/(d[t][t]||1e-12)}const f=new Float64Array(o);for(let e=0;e<o;e++){let t=u[e];for(let n=0;n<e;n++)t-=d[e][n]*f[n];f[e]=t/(d[e][e]||1e-12)}const h=new Float64Array(o);for(let e=o-1;e>=0;e--){let t=f[e];for(let n=e+1;n<o;n++)t-=d[n][e]*h[n];h[e]=t/(d[e][e]||1e-12)}this.w=h,this.mu=i,this.sigma=s}predict(e){if(!this.w||!this.mu||!this.sigma)return 0;let t=0;for(let n=0;n<this.w.length;n++){const r=(e[n]-this.mu[n])/this.sigma[n];t+=this.w[n]*r}return t}}function Be(e,t,n){var r;const a=t.rich||t.content||"";let o=0;/\bgo\b/.test(e.toLowerCase())&&/(define|declare|function|func)/i.test(e)&&Fe(a)&&(o=Math.max(o,1));$e(t.heading||"",e)>=.34&&Oe(a)&&(o=Math.max(o,.8));const i=n.names.indexOf("cosine_tfidf"),s=n.names.indexOf("bm25"),l=i>=0?n.values[i]:0,c=s>=0?n.values[s]:0;l>.25&&(o=Math.max(o,.6)),c>1&&(o=Math.max(o,.6));const u=n.names.indexOf("prior_score_base"),d=u>=0?n.values[u]:0;return(null!==(r=t.score_base)&&void 0!==r?r:0)>0&&(o=Math.max(o,Math.min(.6,.2+.5*d))),o}function We(e,t,n={}){var r,a;const{lambdaRidge:o=.01,randomProjDim:i=32,exposeFeatures:s=!0,attachFeatureNames:l=!1}=n,c=[e,...t.map(e=>e.content||"")],{stats:u,tf:d,docLens:f}=Te(c),h=d.map(e=>De(e,u.idf)),p=d[0],m=h[0],g=i>0?ze(m,i):void 0,y=[],v=[],b=[];for(let n=0;n<t.length;n++){const r=t[n],a=d[n+1],o=h[n+1],s=i>0?ze(o,i,1337+n):void 0,l=je(e,r,m,o,p,a,u,f[n+1]||1,g,s);b.push(l),y.push(l.values);const c=Be(e,r,l);v.push(c)}if(v.every(e=>Math.abs(e-v[0])<1e-9)){const e=b[0].names.indexOf("cosine_tfidf");if(e>=0)for(let t=0;t<v.length;t++)v[t]=Math.max(0,Math.min(1,.2+.6*y[t][e]))}const w=new Ue;w.fit(y,v,o);let S=1/0,k=-1/0;const x=y.map(e=>w.predict(e));for(const e of x)e<S&&(S=e),e>k&&(k=e);const C=Math.max(1e-9,k-S),E=l?null!==(a=null===(r=b[0])||void 0===r?void 0:r.names)&&void 0!==a?a:[]:void 0,_=t.map((e,t)=>{const n=(x[t]-S)/C,r=function(e){if(e>=0)return 1/(1+Math.exp(-e));{const t=Math.exp(e);return t/(1+t)}}((x[t]-.5*(S+k))/(.2*C+1e-6)),a=Object.assign(Object.assign({},e),{score_rr:n,p_relevant:r});return s&&(a._features=y[t]),E&&(a._feature_names=E),a});return _.sort((e,t)=>t.score_rr-e.score_rr),_}function Ve(e,t={}){const{probThresh:n=.45,epsilonTop:r=.05,useMMR:a=!0,mmrLambda:o=.7,budgetChars:i=1200}=t;if(0===e.length)return[];const s=e[0].score_rr,l=e.filter(e=>e.p_relevant>=n&&e.score_rr>=s-r),c=l.length>0?l:[e[0]];if(!a){const e=[];let t=0;for(const n of c){const r=(n.content||"").length;if(t+r>i&&e.length>0)break;e.push(n),t+=r}return e}return function(e,t=.7,n=1200){const r=[],a=e.map(e=>e.content||""),{stats:o,tf:i}=Te(a),s=i.map(e=>De(e,o.idf)),l=new Set;let c=0;for(;l.size<e.length;){let a=-1,o=-1/0;for(let n=0;n<e.length;n++){if(l.has(n))continue;const r=e[n];let i=0;for(const e of l){const t=Ne(s[n],s[e]);t>i&&(i=t)}const c=t*r.score_rr-(1-t)*i;c>o&&(o=c,a=n)}if(a<0)break;const i=e[a],u=(i.content||"").length;if(c+u>n&&r.length>0)break;r.push(i),c+=u,l.add(a)}return r}(e.map(e=>Object.assign(Object.assign({},e),{score_rr:c.includes(e)?e.score_rr+.01:e.score_rr})),o,i)}var He=Object.freeze({__proto__:null,OmegaOfflineRAG:class{constructor(e){this.modelState=null,this.model=null,this.config={reranking:{enabled:e?.reranking?.enabled??!0,lambdaRidge:e?.reranking?.lambdaRidge??.1,useMMR:e?.reranking?.useMMR??!0,mmrLambda:e?.reranking?.mmrLambda??.5,probThresh:e?.reranking?.probThresh??.1},topK:e?.topK??5,verbose:e?.verbose??!1}}async loadModel(e){const t=performance.now();if(this.model=e,this.modelState=function(e){if("astermind-pro-v1"!==e.version&&"astermind-elm-v1"!==e.version)throw new Error(`Unsupported model version: ${e.version}. Expected 'astermind-pro-v1' or 'astermind-elm-v1'`);const t=JSON.parse(JSON.stringify(e.settings||{})),n=new Map(e.vocab),r=Float64Array.from(e.idf),a=e.chunks.map(e=>({heading:e.heading,content:e.content||"",rich:e.rich,level:e.level,secId:e.secId})),o=e.tfidfDocs.map(e=>{const t=new Map;for(const[n,r]of e)t.set(n,r);return t}),i=Array.from(e.landmarksIdx),s=e.landmarkMat.map(e=>Float64Array.from(e));let l;if(!e.denseDocs||e.denseDocs.length!==o.length)throw new Error("recomputeDense=true but buildDense function not provided");return l=e.denseDocs.map(e=>Float64Array.from(e)),{settings:t,vocabMap:n,idf:r,chunks:a,tfidfDocs:o,landmarksIdx:i,landmarkMat:s,denseDocs:l}}(e),this.config.verbose){const e=performance.now()-t;console.log(`[OmegaOfflineRAG] Model loaded in ${e.toFixed(0)}ms`),console.log(`[OmegaOfflineRAG] ${this.modelState.chunks.length} chunks, ${this.modelState.vocabMap.size} vocab`)}}async loadModelFromUrl(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch model from ${e}: ${t.status}`);const n=await t.json();await this.loadModel(n)}isReady(){return null!==this.modelState}getModelInfo(){return this.model&&this.modelState?{version:this.model.version,savedAt:this.model.savedAt,documentCount:this.modelState.chunks.length,vocabularySize:this.modelState.vocabMap.size,landmarkCount:this.modelState.landmarksIdx.length,hasDenseVectors:this.modelState.denseDocs.length>0,settings:this.model.settings}:null}async ask(e){const t=performance.now();if(!this.modelState||!this.model)return{answer:"Omega model not loaded. Please load a model first.",confidence:"none",sources:[],processingTime:0,degraded:!0,degradedReason:"Model not loaded"};try{const n=this.model.settings,r=n.kernel??"rbf",a=n.sigma??1,o=n.alpha??.5,i=n.beta??.3,s=n.ridge??.001,l=n.headingW??.2,c=n.useStem??!0,u=n.expandQuery??!1,d=n.prefilter??100,f=Ie({query:e,chunks:this.modelState.chunks,vocabMap:this.modelState.vocabMap,idf:this.modelState.idf,tfidfDocs:this.modelState.tfidfDocs,denseDocs:this.modelState.denseDocs,landmarksIdx:this.modelState.landmarksIdx,landmarkMat:this.modelState.landmarkMat,vocabSize:this.modelState.vocabMap.size,kernel:r,sigma:a,alpha:o,beta:i,ridge:s,headingW:l,useStem:c,expandQuery:u,topK:2*this.config.topK,prefilter:d});let h;if(this.config.reranking.enabled&&f.items.length>0){const t=function(e,t,n={}){return Ve(We(e,t,n),n)}(e,f.items.map((e,t)=>({heading:e.heading,content:e.content,rich:e.rich,score_base:f.scores[t]})),{lambdaRidge:this.config.reranking.lambdaRidge,useMMR:this.config.reranking.useMMR,mmrLambda:this.config.reranking.mmrLambda,probThresh:this.config.reranking.probThresh});h=t.slice(0,this.config.topK).map(e=>({heading:e.heading,content:e.content,rich:e.rich,score:e.score_base??0,rerankScore:e.score_rr,probability:e.p_relevant}))}else h=f.items.slice(0,this.config.topK).map((e,t)=>({heading:e.heading,content:e.content,rich:e.rich,score:f.scores[t]}));const p=await xe(e,h.map(e=>({heading:e.heading,content:e.content,score:e.score}))),m=performance.now()-t,g=h[0]?.score??0,y=this.determineConfidence(g,h.length);return{answer:p,confidence:y,sources:h,processingTime:m,degraded:!1,queryClassification:this.classifyQuery(e)}}catch(e){const n=performance.now()-t;return console.error("[OmegaOfflineRAG] Error during retrieval:",e),{answer:"An error occurred while processing your question offline.",confidence:"none",sources:[],processingTime:n,degraded:!0,degradedReason:e instanceof Error?e.message:"Unknown error"}}}async retrieve(e,t){if(!this.modelState||!this.model)return[];const n=t??this.config.topK,r=this.model.settings,a=r.kernel??"rbf",o=r.sigma??1,i=r.alpha??.5,s=r.beta??.3,l=r.ridge??.001,c=r.headingW??.2,u=r.useStem??!0,d=r.expandQuery??!1,f=r.prefilter??100,h=Ie({query:e,chunks:this.modelState.chunks,vocabMap:this.modelState.vocabMap,idf:this.modelState.idf,tfidfDocs:this.modelState.tfidfDocs,denseDocs:this.modelState.denseDocs,landmarksIdx:this.modelState.landmarksIdx,landmarkMat:this.modelState.landmarkMat,vocabSize:this.modelState.vocabMap.size,kernel:a,sigma:o,alpha:i,beta:s,ridge:l,headingW:c,useStem:u,expandQuery:d,topK:n,prefilter:f});return h.items.map((e,t)=>({heading:e.heading,content:e.content,rich:e.rich,score:h.scores[t]}))}classifyQuery(e){const t=e.toLowerCase(),n=t.split(/\s+/),r=["what","who","when","where","which","is","are","was","were"],a=["how","steps","guide","tutorial","process","procedure"],o=["why","explain","describe","meaning","definition","concept"],i=["go to","navigate","find","page","link","take me","show me"];let s="unknown",l=.5;const c=[];for(const e of i)if(t.includes(e)){s="navigational",l=.8,c.push(e);break}if("unknown"===s){const e=n[0];a.includes(e)||a.some(e=>t.includes(e))?(s="procedural",l=.7,c.push(...a.filter(e=>t.includes(e)))):o.includes(e)||o.some(e=>t.includes(e))?(s="conceptual",l=.7,c.push(...o.filter(e=>t.includes(e)))):r.includes(e)&&(s="factual",l=.7,c.push(e))}return{type:s,confidence:l,keywords:c}}determineConfidence(e,t){return 0===t?"none":e>=.7||e>=.4?"medium":"low"}clear(){this.modelState=null,this.model=null}}});function Ke({onClick:e,position:t,unreadCount:n=0}){return R.jsxs("button",{className:`astermind-bubble astermind-bubble--${t}`,onClick:e,"aria-label":"Open chat",type:"button",children:[R.jsx("svg",{className:"astermind-bubble__icon",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:R.jsx("path",{d:"M21 11.5C21.0034 12.8199 20.6951 14.1219 20.1 15.3C19.3944 16.7118 18.3098 17.8992 16.9674 18.7293C15.6251 19.5594 14.0782 19.9994 12.5 20C11.1801 20.0035 9.87812 19.6951 8.7 19.1L3 21L4.9 15.3C4.30493 14.1219 3.99656 12.8199 4 11.5C4.00061 9.92179 4.44061 8.37488 5.27072 7.03258C6.10083 5.69028 7.28825 4.6056 8.7 3.90003C9.87812 3.30496 11.1801 2.99659 12.5 3.00003H13C15.0843 3.11502 17.053 3.99479 18.5291 5.47089C20.0052 6.94699 20.885 8.91568 21 11V11.5Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),n>0&&R.jsx("span",{className:"astermind-bubble__badge",children:n})]})}function qe({title:e,subtitle:t,onClose:n,children:r}){return R.jsxs("div",{className:"astermind-header",children:[R.jsxs("div",{className:"astermind-header__info",children:[R.jsx("h3",{className:"astermind-header__title",children:e}),t&&R.jsx("p",{className:"astermind-header__subtitle",children:t})]}),R.jsxs("div",{className:"astermind-header__actions",children:[r,R.jsx("button",{className:"astermind-header__close",onClick:n,"aria-label":"Close chat",type:"button",children:R.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:R.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]})]})}function Ge(e){if(!e)return"";return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/`(.+?)`/g,"<code>$1</code>").replace(/\[(.+?)\]\((.+?)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>').replace(/\n/g,"<br />")}function Qe(){return R.jsxs("svg",{className:"astermind-source__icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[R.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),R.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function Ye(){return R.jsxs("svg",{className:"astermind-source__icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[R.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),R.jsx("polyline",{points:"7 10 12 15 17 10"}),R.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}function Xe({source:e,showSummaryButton:t,showDownloadButton:n,onViewSummary:r,onDownload:a}){const[o,i]=p.useState(!1);return R.jsxs("div",{className:"astermind-source",children:[R.jsxs("div",{className:"astermind-source__header",children:[R.jsx("span",{className:"astermind-source__title",children:e.documentName||e.title}),R.jsxs("div",{className:"astermind-source__actions",children:[t&&R.jsx("button",{className:"astermind-source__action-btn",onClick:t=>{t.stopPropagation(),e.fullContent&&i(!o),r?.(e)},title:"View summary","aria-label":"View source summary",children:R.jsx(Qe,{})}),n&&R.jsx("button",{className:"astermind-source__action-btn",onClick:t=>{t.stopPropagation(),a?.(e)},title:"Download source","aria-label":"Download source file",children:R.jsx(Ye,{})}),R.jsxs("span",{className:"astermind-source__relevance",children:[Math.round(100*e.relevance),"%"]})]})]}),R.jsx("p",{className:"astermind-source__snippet",children:e.snippet}),o&&e.fullContent&&R.jsx("div",{className:"astermind-source__full-content",dangerouslySetInnerHTML:{__html:Ge(e.fullContent)}})]})}function Je({sources:e,config:t={},isOnline:n=!0,onViewSummary:r,onDownload:a}){const{enabled:o=!0,showSummary:i=!0,showDownload:s=!0}=t;return o&&0!==e.length?R.jsx("div",{className:"astermind-sources",children:e.map((e,t)=>{const o=i&&!!e.fullContent,l=s&&n&&!!e.downloadUrl;return R.jsx(Xe,{source:e,showSummaryButton:o,showDownloadButton:l,onViewSummary:r,onDownload:a},e.chunkId||e.documentId||t)})}):null}function Ze(e){const t=new Date,n=t.getTime()-e.getTime();if(n<6e4)return"Just now";if(n<36e5){return`${Math.floor(n/6e4)}m ago`}return e.toDateString()===t.toDateString()?e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):e.toLocaleDateString([],{month:"short",day:"numeric"})}function et({message:e,sourceConfig:t,isOnline:n=!0,onViewSourceSummary:r,onDownloadSource:a}){const[o,i]=p.useState(!1);return R.jsxs("div",{className:`astermind-message astermind-message--${e.role}`,children:[R.jsx("div",{className:"astermind-message__bubble",children:e.isStreaming&&!e.content?R.jsxs("span",{className:"astermind-message__typing",children:[R.jsx("span",{}),R.jsx("span",{}),R.jsx("span",{})]}):R.jsx("div",{className:"astermind-message__content",dangerouslySetInnerHTML:{__html:Ge(e.content)}})}),R.jsxs("div",{className:"astermind-message__meta",children:[R.jsx("span",{className:"astermind-message__time",children:Ze(e.timestamp)}),e.offline&&R.jsx("span",{className:"astermind-message__offline",title:"Offline response",children:"offline"}),e.confidence&&"high"!==e.confidence&&R.jsx("span",{className:`astermind-message__confidence astermind-message__confidence--${e.confidence}`,title:`Confidence: ${e.confidence}`,children:e.confidence})]}),e.sources&&e.sources.length>0&&R.jsxs("div",{className:"astermind-message__sources",children:[R.jsxs("button",{className:"astermind-message__sources-toggle",onClick:()=>i(!o),type:"button",children:[o?"Hide":"Show"," sources (",e.sources.length,")"]}),o&&R.jsx(Je,{sources:e.sources,config:t,isOnline:n,onViewSummary:r,onDownload:a})]})]})}function tt(){return R.jsxs("div",{className:"astermind-typing",children:[R.jsx("span",{}),R.jsx("span",{}),R.jsx("span",{})]})}function nt({messages:e,isProcessing:t,sourceConfig:n,isOnline:r=!0,onViewSourceSummary:a,onDownloadSource:o}){const i=p.useRef(null);return p.useEffect(()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight)},[e,t]),R.jsxs("div",{className:"astermind-messages",ref:i,children:[e.map(e=>R.jsx(et,{message:e,sourceConfig:n,isOnline:r,onViewSourceSummary:a,onDownloadSource:o},e.id)),t&&""===e[e.length-1]?.content&&R.jsx(tt,{})]})}function rt({placeholder:e,disabled:t=!1,onSend:n}){const[r,a]=p.useState(""),o=p.useRef(null),i=()=>{r.trim()&&!t&&(n(r.trim()),a(""),o.current?.focus())};return R.jsxs("div",{className:"astermind-input",children:[R.jsx("textarea",{ref:o,className:"astermind-input__textarea",value:r,onChange:e=>{const t=e.target;a(t.value),t.style.height="auto",t.style.height=Math.min(t.scrollHeight,120)+"px"},onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),i())},placeholder:e,disabled:t,rows:1,"aria-label":"Message input"}),R.jsx("button",{className:"astermind-input__send",onClick:i,disabled:t||!r.trim(),"aria-label":"Send message",type:"button",children:R.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:R.jsx("path",{d:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"})})})]})}function at({action:e,onConfirm:t,onCancel:n}){return R.jsxs("div",{className:"astermind-action-card",children:[R.jsxs("div",{className:"astermind-action-card__header",children:[R.jsx("div",{className:"astermind-action-card__icon",children:(e=>{switch(e){case"navigate":return R.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[R.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),R.jsx("polyline",{points:"15,3 21,3 21,9"}),R.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]});case"fillForm":return R.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[R.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),R.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]});case"clickElement":return R.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[R.jsx("path",{d:"M15 15l-2 5L9 9l11 4-5 2z"}),R.jsx("path",{d:"M15 15l5 5"})]});default:return R.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[R.jsx("circle",{cx:"12",cy:"12",r:"10"}),R.jsx("polyline",{points:"12,6 12,12 16,14"})]})}})(e.type)}),R.jsxs("div",{className:"astermind-action-card__title",children:[R.jsx("span",{className:"astermind-action-card__label",children:(e=>{switch(e){case"navigate":return"Navigate to";case"fillForm":return"Fill form field";case"clickElement":return"Click";case"triggerModal":return"Open modal";case"scroll":return"Scroll to";case"highlight":return"Highlight";case"custom":return"Execute action";default:return"Perform action"}})(e.type)}),R.jsx("span",{className:"astermind-action-card__target",children:e.target})]})]}),e.explanation&&R.jsx("p",{className:"astermind-action-card__explanation",children:e.explanation}),R.jsxs("div",{className:"astermind-action-card__confidence",children:[R.jsx("div",{className:"astermind-action-card__confidence-bar",style:{width:100*e.confidence+"%"}}),R.jsxs("span",{children:[Math.round(100*e.confidence),"% confident"]})]}),R.jsxs("div",{className:"astermind-action-card__actions",children:[R.jsx("button",{className:"astermind-action-card__cancel",onClick:n,type:"button",children:"Cancel"}),R.jsx("button",{className:"astermind-action-card__confirm",onClick:t,type:"button",children:"Confirm"})]})]})}function ot({status:e}){return R.jsxs("div",{className:`astermind-status astermind-status--${e}`,children:[R.jsx("span",{className:"astermind-status__dot"}),R.jsx("span",{className:"astermind-status__label",children:(()=>{switch(e){case"online":return"Online";case"offline":return"Offline";case"connecting":return"Connecting...";case"error":return"Error";default:return"Unknown"}})()})]})}function it({messages:e,isProcessing:t,connectionStatus:n,pendingAction:r,headerTitle:a,headerSubtitle:o,placeholder:i,showPoweredBy:s,sourceConfig:l,onClose:c,onSendMessage:u,onActionConfirm:d,onActionCancel:f,onViewSourceSummary:h,onDownloadSource:p}){const m="online"===n;return R.jsxs("div",{className:"astermind-window",children:[R.jsx(qe,{title:a,subtitle:o,onClose:c,children:R.jsx(ot,{status:n})}),R.jsxs("div",{className:"astermind-window__body",children:[R.jsx(nt,{messages:e,isProcessing:t,sourceConfig:l,isOnline:m,onViewSourceSummary:h,onDownloadSource:p}),r&&R.jsx(at,{action:r,onConfirm:()=>d(r),onCancel:f})]}),R.jsxs("div",{className:"astermind-window__footer",children:[R.jsx(rt,{placeholder:i,disabled:t||"error"===n,onSend:u}),s&&R.jsxs("div",{className:"astermind-powered-by",children:["Powered by ",R.jsx("a",{href:"https://astermind.ai",target:"_blank",rel:"noopener noreferrer",children:"AsterMind"})]})]})]})}const st={primaryColor:"#4F46E5",primaryHover:"#4338CA",backgroundColor:"#ffffff",surfaceColor:"#f3f4f6",textColor:"#1f2937",textMuted:"#6b7280",borderColor:"#e5e7eb",userBubbleBackground:"#4F46E5",userBubbleText:"#ffffff",botBubbleBackground:"#f3f4f6",botBubbleText:"#1f2937",widgetWidth:"380px",widgetHeight:"75vh",bubbleSize:"60px",borderRadius:"12px",fontFamily:"'Inter', system-ui, -apple-system, sans-serif",fontSize:"14px",shadow:"0 4px 20px rgba(0, 0, 0, 0.15)"};const lt=p.createContext(null);function ct({theme:e,children:t}){const n=function(e){const t=p.useMemo(()=>({...st,...e}),[e]),n=p.useMemo(()=>({"--astermind-primary":t.primaryColor,"--astermind-primary-hover":t.primaryHover,"--astermind-background":t.backgroundColor,"--astermind-surface":t.surfaceColor,"--astermind-text":t.textColor,"--astermind-text-muted":t.textMuted,"--astermind-border":t.borderColor,"--astermind-user-bg":t.userBubbleBackground,"--astermind-user-text":t.userBubbleText,"--astermind-bot-bg":t.botBubbleBackground,"--astermind-bot-text":t.botBubbleText,"--astermind-widget-width":t.widgetWidth,"--astermind-widget-height":t.widgetHeight,"--astermind-bubble-size":t.bubbleSize,"--astermind-border-radius":t.borderRadius,"--astermind-font-family":t.fontFamily,"--astermind-font-size":t.fontSize,"--astermind-shadow":t.shadow}),[t]);return{theme:t,cssVariables:n}}(e);return R.jsx(lt.Provider,{value:n,children:R.jsx("div",{style:n.cssVariables,children:t})})}function ut(e){const n=p.useMemo(()=>function(){let e="",n="https://api.astermind.ai";try{t&&"SCRIPT"===t.tagName.toUpperCase()&&t.src||new URL("astermind-chatbot.min.js",document.baseURI).href}catch{}if(!e&&"undefined"!=typeof process&&process.env&&(e=process.env.REACT_APP_ASTERMIND_RAG_API_KEY||e,n=process.env.REACT_APP_ASTERMIND_RAG_API_SERVER_URL||n),"undefined"!=typeof window){const t=window.__ASTERMIND_CONFIG__;t&&"object"==typeof t&&(e=t.apiKey||e,n=t.apiUrl||n)}return{apiKey:e,apiUrl:n}}(),[]),{apiKey:r,apiUrl:a,wsUrl:o,transport:i,environment:s,throwOnMissingKey:l=!0,position:c="bottom-right",theme:u={},greeting:d="Hi! How can I help you today?",placeholder:f="Type your message...",agent:h,fallback:m={enabled:!0},sourceDisplay:g,showPoweredBy:y=!0,headerTitle:v="AsterMind",headerSubtitle:b="AI Assistant",defaultOpen:w=!1,zIndex:S=9999,onReady:k,onMessage:x,onAction:C,onError:E,onToggle:_}=e,M=r||n.apiKey,A=a||n.apiUrl,[I,P]=p.useState(w),[L,T]=p.useState(null),[D,N]=p.useState([]),[z,F]=p.useState(!1),[O,$]=p.useState(),[j,U]=p.useState(),[B,W]=p.useState("connecting"),V=p.useMemo(()=>{const e=L?.getSourcesConfig?.()||{};return{enabled:g?.enabled??e.enabled??!0,showSummary:g?.showSummary??e.showSummary??!0,showDownload:g?.showDownload??e.showDownload??!0}},[L,g]),H=p.useCallback(e=>{console.log("[AsterMind] View source summary:",e.title)},[]),K=p.useCallback(async e=>{if(e.downloadUrl)try{const t=e.downloadUrl.startsWith("http")?e.downloadUrl:`${A}${e.downloadUrl}`,n=await fetch(t,{headers:{"X-API-Key":M}});if(!n.ok)return void console.error("[AsterMind] Download failed:",n.status,n.statusText);if((n.headers.get("Content-Type")||"").includes("application/json")){const t=await n.json();if(t.downloadUrl){const n=document.createElement("a");n.href=t.downloadUrl,n.download=t.filename||e.documentName||e.title||"download",n.rel="noopener",document.body.appendChild(n),n.click(),document.body.removeChild(n)}else console.error("[AsterMind] Presigned URL response missing downloadUrl")}else{const t=n.headers.get("Content-Disposition");let r=e.documentName||e.title||"download";if(t){const e=t.match(/filename="?(.+?)"?$/);e&&(r=e[1])}const a=await n.blob(),o=window.URL.createObjectURL(a),i=document.createElement("a");i.href=o,i.download=r,document.body.appendChild(i),i.click(),window.URL.revokeObjectURL(o),document.body.removeChild(i)}}catch(e){console.error("[AsterMind] Download error:",e)}else console.warn("[AsterMind] No download URL for source:",e.title)},[A,M]);p.useEffect(()=>{if(!M){const e='AsterMind API key is required. Configure using one of these methods:\n 1. Pass apiKey prop: <ChatbotWidget apiKey="am_..." />\n 2. Set VITE_ASTERMIND_RAG_API_KEY environment variable (Vite)\n 3. Set REACT_APP_ASTERMIND_RAG_API_KEY environment variable (CRA)\n 4. Set window.__ASTERMIND_CONFIG__ = { apiKey: "am_...", apiUrl: "..." }';if(l)throw new Error(e);console.warn("[AsterMind] "+e)}},[M,l]);const q=p.useMemo(()=>{if(h?.enabled)return{enabled:!0,confidenceThreshold:h.confidenceThreshold??.8,siteMap:h.siteMap,siteMapConfig:h.siteMapConfig,customActions:h.customActions,requireConfirmation:!0}},[h]);p.useEffect(()=>{if(!M)return;const e=new le({apiUrl:A,apiKey:M,wsUrl:o,transport:i,environment:s,fallback:{enabled:m?.enabled??!0,cacheOnConnect:!0},agentic:q,onStatusChange:e=>{W(e)},onError:e=>{E?.(new Error(e.message))}});q?.enabled&&(!function(e){const t={agent:pe,intentClassifier:he};e.registerAgentic(t)}(e),console.log("[AsterMind] Agentic capabilities enabled (auto-discovery handled by client)")),T(e);const t=e.getStoredMessages();if(t.length>0){N(t.map(e=>({id:e.id,role:e.role,content:e.content,timestamp:new Date(e.timestamp),offline:e.offline,confidence:e.confidence,sources:e.sources,isStreaming:!1})));const n=e.getSessionInfo();n.sessionId&&$(n.sessionId)}else if(d){const e={id:"greeting",role:"assistant",content:d,timestamp:new Date};N([e])}return k?.(),()=>{e.destroy?.()}},[M,A,o,i,m?.enabled,q,d,E,k]);const G=p.useCallback(()=>{const e=!I;P(e),_?.(e)},[I,_]),Q=p.useCallback(()=>{P(!1),_?.(!1)},[_]),Y=p.useCallback(async e=>{if(!L||!e.trim()||z)return;const t={id:`user-${Date.now()}`,role:"user",content:e.trim(),timestamp:new Date};if(N(e=>[...e,t]),x?.(t),F(!0),L.isAgenticEnabled())try{const t=await L.smartAsk(e,{sessionId:O});if(t.action&&!t.response){const e={id:t.action.id,type:t.action.type,target:t.action.target,params:t.action.params,confidence:t.action.confidence,explanation:t.action.explanation,status:"pending"};return U(e),C?.(e),void F(!1)}if(t.actionResult){const e={id:t.action.id,type:t.action.type,target:t.action.target,params:t.action?.params,confidence:t.action.confidence,explanation:t.action?.explanation,status:t.actionResult.success?"executed":"failed",result:t.actionResult},n={id:`assistant-${Date.now()}`,role:"assistant",content:t.actionResult.success?`✓ ${t.action?.explanation||"Action completed"}`:`✗ ${t.actionResult.message}`,timestamp:new Date,isStreaming:!1};return N(e=>[...e,n]),C?.(e),void F(!1)}if(t.response){const e={id:`assistant-${Date.now()}`,role:"assistant",content:t.response.reply,timestamp:new Date,sources:t.response.sources,confidence:t.response.confidence,offline:t.response.offline,isStreaming:!1};return N(t=>[...t,e]),$(t.response.sessionId),x?.(e),void F(!1)}}catch(e){console.error("[AsterMind] smartAsk error, falling back to standard ask:",e)}const n=`assistant-${Date.now()}`,r={id:n,role:"assistant",content:"",timestamp:new Date,isStreaming:!0};N(e=>[...e,r]);try{let t="";await L.askStream(e,{onToken:e=>{t+=e,N(e=>e.map(e=>e.id===n?{...e,content:t}:e))},onSources:e=>{N(t=>t.map(t=>t.id===n?{...t,sources:e}:t))},onComplete:e=>{const t={id:n,role:"assistant",content:e.reply,timestamp:new Date,sources:e.sources,confidence:e.confidence,offline:e.offline,isStreaming:!1};N(e=>e.map(e=>e.id===n?t:e)),$(e.sessionId),x?.(t)},onError:()=>{X(L,e,n)}},{sessionId:O})}catch{const e={id:n,role:"assistant",content:"I encountered an error processing your request. Please try again.",timestamp:new Date,isStreaming:!1};N(t=>t.map(t=>t.id===n?e:t)),E?.(new Error("Failed to process message"))}finally{F(!1)}},[L,z,O,x,E,C]),X=async(e,t,n)=>{try{const r=await e.ask(t,{sessionId:O}),a={id:n,role:"assistant",content:r.reply,timestamp:new Date,sources:r.sources,confidence:r.confidence,offline:r.offline,isStreaming:!1};N(e=>e.map(e=>e.id===n?a:e)),$(r.sessionId),x?.(a)}catch{const e={id:n,role:"assistant",content:"I'm having trouble connecting. Please try again later.",timestamp:new Date,isStreaming:!1};N(t=>t.map(t=>t.id===n?e:t))}},J=p.useCallback(async e=>{if(!L)return;const t={...e,status:"confirmed"};U(t);try{const t=await L.executeAction({id:e.id,type:e.type,target:e.target,confidence:e.confidence,params:e.params}),n={...e,status:t.success?"executed":"failed",result:t},r={id:`assistant-${Date.now()}`,role:"assistant",content:t.success?`✓ ${e.explanation||t.message}`:`✗ ${t.message}${t.error?`: ${t.error}`:""}`,timestamp:new Date,isStreaming:!1};N(e=>[...e,r]),U(void 0),C?.(n)}catch(t){const n={...e,status:"failed",result:{success:!1,message:"Failed to execute action",error:String(t)}},r={id:`assistant-${Date.now()}`,role:"assistant",content:`✗ Failed to execute action: ${String(t)}`,timestamp:new Date,isStreaming:!1};N(e=>[...e,r]),U(void 0),C?.(n)}},[j,L,C]),Z=p.useCallback(()=>{if(!j)return;const e={...j,status:"cancelled"};U(void 0),C?.(e)},[j,C]);return R.jsx(ct,{theme:u,children:R.jsxs("div",{className:`astermind-chatbot astermind-chatbot--${c}`,style:{zIndex:S},children:[!I&&R.jsx(Ke,{onClick:G,position:c}),I&&R.jsx(it,{messages:D,isProcessing:z,connectionStatus:B,pendingAction:j,headerTitle:v,headerSubtitle:b,placeholder:f,showPoweredBy:y,sourceConfig:V,onClose:Q,onSendMessage:Y,onActionConfirm:J,onActionCancel:Z,onViewSourceSummary:H,onDownloadSource:K})]})})}let dt=null;function ft(e){const t=function(){if("undefined"==typeof document)return{};const e=document.querySelector("script[data-astermind-key]");if(!e)return{};const t={},n=e.getAttribute("data-astermind-key");n&&(t.apiKey=n);const r=e.getAttribute("data-astermind-url");r&&(t.apiUrl=r);const a=e.getAttribute("data-astermind-position");a&&["bottom-right","bottom-left","top-right","top-left"].includes(a)&&(t.position=a);const o=e.getAttribute("data-astermind-greeting");o&&(t.greeting=o);const i=e.getAttribute("data-astermind-title");i&&(t.headerTitle=i);const s=e.getAttribute("data-astermind-subtitle");return s&&(t.headerSubtitle=s),"true"===e.getAttribute("data-astermind-auto-open")&&(t.defaultOpen=!0),t}(),n={...t,...function(){if("undefined"==typeof window)return{};const e=window.astermindConfig;return e&&"object"==typeof e?e:{}}(),...e||{}},{container:r=document.body,...a}=n;a.apiKey||console.warn('[AsterMindChatbot] No API key found. Configure using one of these methods:\n 1. AsterMindChatbot.init({ apiKey: "am_..." })\n 2. window.astermindConfig = { apiKey: "am_..." }\n 3. <script data-astermind-key="am_..." ...>\n 4. Set VITE_ASTERMIND_RAG_API_KEY environment variable (if bundled)');const o="string"==typeof r?document.querySelector(r):r;if(!o)return void console.error("[AsterMindChatbot] Container not found:",r);const i=document.createElement("div");i.id="astermind-chatbot-root",o.appendChild(i),dt=E.createRoot(i),dt.render(m.createElement(ut,a)),console.log("[AsterMindChatbot] Initialized")}function ht(){dt&&(dt.unmount(),dt=null);const e=document.getElementById("astermind-chatbot-root");e&&e.remove(),console.log("[AsterMindChatbot] Destroyed")}function pt(){return null!==dt}return"undefined"!=typeof window&&(window.AsterMindChatbot={init:ft,destroy:ht,isInitialized:pt}),e.destroy=ht,e.init=ft,e.isInitialized=pt,e}({});
10
+ */function k(){if(d)return v;d=1;var e=l(),t=S();function n(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,a={};function o(e,t){i(e,t),i(e+"Capture",t)}function i(e,t){for(a[e]=t,e=0;e<t.length;e++)r.add(t[e])}var s=!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement),c=Object.prototype.hasOwnProperty,u=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,f={},h={};function p(e,t,n,r,a,o,i){this.acceptsBooleans=2===t||3===t||4===t,this.attributeName=r,this.attributeNamespace=a,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=i}var m={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){m[e]=new p(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];m[t]=new p(t,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){m[e]=new p(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){m[e]=new p(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){m[e]=new p(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){m[e]=new p(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){m[e]=new p(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){m[e]=new p(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){m[e]=new p(e,5,!1,e.toLowerCase(),null,!1,!1)});var g=/[\-:]([a-z])/g;function y(e){return e[1].toUpperCase()}function b(e,t,n,r){var a=m.hasOwnProperty(t)?m[t]:null;(null!==a?0!==a.type:r||!(2<t.length)||"o"!==t[0]&&"O"!==t[0]||"n"!==t[1]&&"N"!==t[1])&&(function(e,t,n,r){if(null==t||function(e,t,n,r){if(null!==n&&0===n.type)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return!r&&(null!==n?!n.acceptsBooleans:"data-"!==(e=e.toLowerCase().slice(0,5))&&"aria-"!==e);default:return!1}}(e,t,n,r))return!0;if(r)return!1;if(null!==n)switch(n.type){case 3:return!t;case 4:return!1===t;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}(t,n,a,r)&&(n=null),r||null===a?function(e){return!!c.call(h,e)||!c.call(f,e)&&(u.test(e)?h[e]=!0:(f[e]=!0,!1))}(t)&&(null===n?e.removeAttribute(t):e.setAttribute(t,""+n)):a.mustUseProperty?e[a.propertyName]=null===n?3!==a.type&&"":n:(t=a.attributeName,r=a.attributeNamespace,null===n?e.removeAttribute(t):(n=3===(a=a.type)||4===a&&!0===n?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(g,y);m[t]=new p(t,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(g,y);m[t]=new p(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(g,y);m[t]=new p(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){m[e]=new p(e,1,!1,e.toLowerCase(),null,!1,!1)}),m.xlinkHref=new p("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){m[e]=new p(e,1,!1,e.toLowerCase(),null,!0,!0)});var w=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,k=Symbol.for("react.element"),x=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),_=Symbol.for("react.profiler"),M=Symbol.for("react.provider"),R=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),T=Symbol.for("react.memo"),L=Symbol.for("react.lazy"),N=Symbol.for("react.offscreen"),D=Symbol.iterator;function z(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=D&&e[D]||e["@@iterator"])?e:null}var F,O=Object.assign;function $(e){if(void 0===F)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);F=t&&t[1]||""}return"\n"+F+e}var j=!1;function U(e,t){if(!e||j)return"";j=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(t,[])}catch(e){var r=e}Reflect.construct(e,[],t)}else{try{t.call()}catch(e){r=e}e.call(t.prototype)}else{try{throw Error()}catch(e){r=e}e()}}catch(t){if(t&&r&&"string"==typeof t.stack){for(var a=t.stack.split("\n"),o=r.stack.split("\n"),i=a.length-1,s=o.length-1;1<=i&&0<=s&&a[i]!==o[s];)s--;for(;1<=i&&0<=s;i--,s--)if(a[i]!==o[s]){if(1!==i||1!==s)do{if(i--,0>--s||a[i]!==o[s]){var l="\n"+a[i].replace(" at new "," at ");return e.displayName&&l.includes("<anonymous>")&&(l=l.replace("<anonymous>",e.displayName)),l}}while(1<=i&&0<=s);break}}}finally{j=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?$(e):""}function B(e){switch(e.tag){case 5:return $(e.type);case 16:return $("Lazy");case 13:return $("Suspense");case 19:return $("SuspenseList");case 0:case 2:case 15:return e=U(e.type,!1);case 11:return e=U(e.type.render,!1);case 1:return e=U(e.type,!0);default:return""}}function V(e){if(null==e)return null;if("function"==typeof e)return e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case C:return"Fragment";case x:return"Portal";case _:return"Profiler";case E:return"StrictMode";case I:return"Suspense";case P:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case R:return(e.displayName||"Context")+".Consumer";case M:return(e._context.displayName||"Context")+".Provider";case A:var t=e.render;return(e=e.displayName)||(e=""!==(e=t.displayName||t.name||"")?"ForwardRef("+e+")":"ForwardRef"),e;case T:return null!==(t=e.displayName||null)?t:V(e.type)||"Memo";case L:t=e._payload,e=e._init;try{return V(e(t))}catch(e){}}return null}function W(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=(e=t.render).displayName||e.name||"",t.displayName||(""!==e?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return V(t);case 8:return t===E?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if("function"==typeof t)return t.displayName||t.name||null;if("string"==typeof t)return t}return null}function H(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":case"object":return e;default:return""}}function K(e){var t=e.type;return(e=e.nodeName)&&"input"===e.toLowerCase()&&("checkbox"===t||"radio"===t)}function q(e){e._valueTracker||(e._valueTracker=function(e){var t=K(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&void 0!==n&&"function"==typeof n.get&&"function"==typeof n.set){var a=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return a.call(this)},set:function(e){r=""+e,o.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(e){r=""+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}(e))}function G(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=K(e)?e.checked?"true":"false":e.value),(e=r)!==n&&(t.setValue(e),!0)}function Q(e){if(void 0===(e=e||("undefined"!=typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}}function Y(e,t){var n=t.checked;return O({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:null!=n?n:e._wrapperState.initialChecked})}function X(e,t){var n=null==t.defaultValue?"":t.defaultValue,r=null!=t.checked?t.checked:t.defaultChecked;n=H(null!=t.value?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:"checkbox"===t.type||"radio"===t.type?null!=t.checked:null!=t.value}}function J(e,t){null!=(t=t.checked)&&b(e,"checked",t,!1)}function Z(e,t){J(e,t);var n=H(t.value),r=t.type;if(null!=n)"number"===r?(0===n&&""===e.value||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if("submit"===r||"reset"===r)return void e.removeAttribute("value");t.hasOwnProperty("value")?te(e,t.type,n):t.hasOwnProperty("defaultValue")&&te(e,t.type,H(t.defaultValue)),null==t.checked&&null!=t.defaultChecked&&(e.defaultChecked=!!t.defaultChecked)}function ee(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!("submit"!==r&&"reset"!==r||void 0!==t.value&&null!==t.value))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}""!==(n=e.name)&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,""!==n&&(e.name=n)}function te(e,t,n){"number"===t&&Q(e.ownerDocument)===e||(null==n?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var ne=Array.isArray;function re(e,t,n,r){if(e=e.options,t){t={};for(var a=0;a<n.length;a++)t["$"+n[a]]=!0;for(n=0;n<e.length;n++)a=t.hasOwnProperty("$"+e[n].value),e[n].selected!==a&&(e[n].selected=a),a&&r&&(e[n].defaultSelected=!0)}else{for(n=""+H(n),t=null,a=0;a<e.length;a++){if(e[a].value===n)return e[a].selected=!0,void(r&&(e[a].defaultSelected=!0));null!==t||e[a].disabled||(t=e[a])}null!==t&&(t.selected=!0)}}function ae(e,t){if(null!=t.dangerouslySetInnerHTML)throw Error(n(91));return O({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function oe(e,t){var r=t.value;if(null==r){if(r=t.children,t=t.defaultValue,null!=r){if(null!=t)throw Error(n(92));if(ne(r)){if(1<r.length)throw Error(n(93));r=r[0]}t=r}null==t&&(t=""),r=t}e._wrapperState={initialValue:H(r)}}function ie(e,t){var n=H(t.value),r=H(t.defaultValue);null!=n&&((n=""+n)!==e.value&&(e.value=n),null==t.defaultValue&&e.defaultValue!==n&&(e.defaultValue=n)),null!=r&&(e.defaultValue=""+r)}function se(e){var t=e.textContent;t===e._wrapperState.initialValue&&""!==t&&null!==t&&(e.value=t)}function le(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function ce(e,t){return null==e||"http://www.w3.org/1999/xhtml"===e?le(t):"http://www.w3.org/2000/svg"===e&&"foreignObject"===t?"http://www.w3.org/1999/xhtml":e}var ue,de,fe=(de=function(e,t){if("http://www.w3.org/2000/svg"!==e.namespaceURI||"innerHTML"in e)e.innerHTML=t;else{for((ue=ue||document.createElement("div")).innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=ue.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}},"undefined"!=typeof MSApp&&MSApp.execUnsafeLocalFunction?function(e,t,n,r){MSApp.execUnsafeLocalFunction(function(){return de(e,t)})}:de);function he(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&3===n.nodeType)return void(n.nodeValue=t)}e.textContent=t}var pe={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},me=["Webkit","ms","Moz","O"];function ge(e,t,n){return null==t||"boolean"==typeof t||""===t?"":n||"number"!=typeof t||0===t||pe.hasOwnProperty(e)&&pe[e]?(""+t).trim():t+"px"}function ye(e,t){for(var n in e=e.style,t)if(t.hasOwnProperty(n)){var r=0===n.indexOf("--"),a=ge(n,t[n],r);"float"===n&&(n="cssFloat"),r?e.setProperty(n,a):e[n]=a}}Object.keys(pe).forEach(function(e){me.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),pe[t]=pe[e]})});var ve=O({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function be(e,t){if(t){if(ve[e]&&(null!=t.children||null!=t.dangerouslySetInnerHTML))throw Error(n(137,e));if(null!=t.dangerouslySetInnerHTML){if(null!=t.children)throw Error(n(60));if("object"!=typeof t.dangerouslySetInnerHTML||!("__html"in t.dangerouslySetInnerHTML))throw Error(n(61))}if(null!=t.style&&"object"!=typeof t.style)throw Error(n(62))}}function we(e,t){if(-1===e.indexOf("-"))return"string"==typeof t.is;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Se=null;function ke(e){return(e=e.target||e.srcElement||window).correspondingUseElement&&(e=e.correspondingUseElement),3===e.nodeType?e.parentNode:e}var xe=null,Ce=null,Ee=null;function _e(e){if(e=wa(e)){if("function"!=typeof xe)throw Error(n(280));var t=e.stateNode;t&&(t=ka(t),xe(e.stateNode,e.type,t))}}function Me(e){Ce?Ee?Ee.push(e):Ee=[e]:Ce=e}function Re(){if(Ce){var e=Ce,t=Ee;if(Ee=Ce=null,_e(e),t)for(e=0;e<t.length;e++)_e(t[e])}}function Ae(e,t){return e(t)}function Ie(){}var Pe=!1;function Te(e,t,n){if(Pe)return e(t,n);Pe=!0;try{return Ae(e,t,n)}finally{Pe=!1,(null!==Ce||null!==Ee)&&(Ie(),Re())}}function Le(e,t){var r=e.stateNode;if(null===r)return null;var a=ka(r);if(null===a)return null;r=a[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(a=!a.disabled)||(a=!("button"===(e=e.type)||"input"===e||"select"===e||"textarea"===e)),e=!a;break e;default:e=!1}if(e)return null;if(r&&"function"!=typeof r)throw Error(n(231,t,typeof r));return r}var Ne=!1;if(s)try{var De={};Object.defineProperty(De,"passive",{get:function(){Ne=!0}}),window.addEventListener("test",De,De),window.removeEventListener("test",De,De)}catch(de){Ne=!1}function ze(e,t,n,r,a,o,i,s,l){var c=Array.prototype.slice.call(arguments,3);try{t.apply(n,c)}catch(e){this.onError(e)}}var Fe=!1,Oe=null,$e=!1,je=null,Ue={onError:function(e){Fe=!0,Oe=e}};function Be(e,t,n,r,a,o,i,s,l){Fe=!1,Oe=null,ze.apply(Ue,arguments)}function Ve(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do{!!(4098&(t=e).flags)&&(n=t.return),e=t.return}while(e)}return 3===t.tag?n:null}function We(e){if(13===e.tag){var t=e.memoizedState;if(null===t&&(null!==(e=e.alternate)&&(t=e.memoizedState)),null!==t)return t.dehydrated}return null}function He(e){if(Ve(e)!==e)throw Error(n(188))}function Ke(e){return null!==(e=function(e){var t=e.alternate;if(!t){if(null===(t=Ve(e)))throw Error(n(188));return t!==e?null:e}for(var r=e,a=t;;){var o=r.return;if(null===o)break;var i=o.alternate;if(null===i){if(null!==(a=o.return)){r=a;continue}break}if(o.child===i.child){for(i=o.child;i;){if(i===r)return He(o),e;if(i===a)return He(o),t;i=i.sibling}throw Error(n(188))}if(r.return!==a.return)r=o,a=i;else{for(var s=!1,l=o.child;l;){if(l===r){s=!0,r=o,a=i;break}if(l===a){s=!0,a=o,r=i;break}l=l.sibling}if(!s){for(l=i.child;l;){if(l===r){s=!0,r=i,a=o;break}if(l===a){s=!0,a=i,r=o;break}l=l.sibling}if(!s)throw Error(n(189))}}if(r.alternate!==a)throw Error(n(190))}if(3!==r.tag)throw Error(n(188));return r.stateNode.current===r?e:t}(e))?qe(e):null}function qe(e){if(5===e.tag||6===e.tag)return e;for(e=e.child;null!==e;){var t=qe(e);if(null!==t)return t;e=e.sibling}return null}var Ge=t.unstable_scheduleCallback,Qe=t.unstable_cancelCallback,Ye=t.unstable_shouldYield,Xe=t.unstable_requestPaint,Je=t.unstable_now,Ze=t.unstable_getCurrentPriorityLevel,et=t.unstable_ImmediatePriority,tt=t.unstable_UserBlockingPriority,nt=t.unstable_NormalPriority,rt=t.unstable_LowPriority,at=t.unstable_IdlePriority,ot=null,it=null;var st=Math.clz32?Math.clz32:function(e){return e>>>=0,0===e?32:31-(lt(e)/ct|0)|0},lt=Math.log,ct=Math.LN2;var ut=64,dt=4194304;function ft(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return 4194240&e;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return 130023424&e;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function ht(e,t){var n=e.pendingLanes;if(0===n)return 0;var r=0,a=e.suspendedLanes,o=e.pingedLanes,i=268435455&n;if(0!==i){var s=i&~a;0!==s?r=ft(s):0!==(o&=i)&&(r=ft(o))}else 0!==(i=n&~a)?r=ft(i):0!==o&&(r=ft(o));if(0===r)return 0;if(0!==t&&t!==r&&0===(t&a)&&((a=r&-r)>=(o=t&-t)||16===a&&4194240&o))return t;if(4&r&&(r|=16&n),0!==(t=e.entangledLanes))for(e=e.entanglements,t&=r;0<t;)a=1<<(n=31-st(t)),r|=e[n],t&=~a;return r}function pt(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;default:return-1}}function mt(e){return 0!==(e=-1073741825&e.pendingLanes)?e:1073741824&e?1073741824:0}function gt(){var e=ut;return!(4194240&(ut<<=1))&&(ut=64),e}function yt(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function vt(e,t,n){e.pendingLanes|=t,536870912!==t&&(e.suspendedLanes=0,e.pingedLanes=0),(e=e.eventTimes)[t=31-st(t)]=n}function bt(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-st(n),a=1<<r;a&t|e[r]&t&&(e[r]|=t),n&=~a}}var wt=0;function St(e){return 1<(e&=-e)?4<e?268435455&e?16:536870912:4:1}var kt,xt,Ct,Et,_t,Mt=!1,Rt=[],At=null,It=null,Pt=null,Tt=new Map,Lt=new Map,Nt=[],Dt="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function zt(e,t){switch(e){case"focusin":case"focusout":At=null;break;case"dragenter":case"dragleave":It=null;break;case"mouseover":case"mouseout":Pt=null;break;case"pointerover":case"pointerout":Tt.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Lt.delete(t.pointerId)}}function Ft(e,t,n,r,a,o){return null===e||e.nativeEvent!==o?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:o,targetContainers:[a]},null!==t&&(null!==(t=wa(t))&&xt(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,null!==a&&-1===t.indexOf(a)&&t.push(a),e)}function Ot(e){var t=ba(e.target);if(null!==t){var n=Ve(t);if(null!==n)if(13===(t=n.tag)){if(null!==(t=We(n)))return e.blockedOn=t,void _t(e.priority,function(){Ct(n)})}else if(3===t&&n.stateNode.current.memoizedState.isDehydrated)return void(e.blockedOn=3===n.tag?n.stateNode.containerInfo:null)}e.blockedOn=null}function $t(e){if(null!==e.blockedOn)return!1;for(var t=e.targetContainers;0<t.length;){var n=Yt(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(null!==n)return null!==(t=wa(n))&&xt(t),e.blockedOn=n,!1;var r=new(n=e.nativeEvent).constructor(n.type,n);Se=r,n.target.dispatchEvent(r),Se=null,t.shift()}return!0}function jt(e,t,n){$t(e)&&n.delete(t)}function Ut(){Mt=!1,null!==At&&$t(At)&&(At=null),null!==It&&$t(It)&&(It=null),null!==Pt&&$t(Pt)&&(Pt=null),Tt.forEach(jt),Lt.forEach(jt)}function Bt(e,n){e.blockedOn===n&&(e.blockedOn=null,Mt||(Mt=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Ut)))}function Vt(e){function t(t){return Bt(t,e)}if(0<Rt.length){Bt(Rt[0],e);for(var n=1;n<Rt.length;n++){var r=Rt[n];r.blockedOn===e&&(r.blockedOn=null)}}for(null!==At&&Bt(At,e),null!==It&&Bt(It,e),null!==Pt&&Bt(Pt,e),Tt.forEach(t),Lt.forEach(t),n=0;n<Nt.length;n++)(r=Nt[n]).blockedOn===e&&(r.blockedOn=null);for(;0<Nt.length&&null===(n=Nt[0]).blockedOn;)Ot(n),null===n.blockedOn&&Nt.shift()}var Wt=w.ReactCurrentBatchConfig,Ht=!0;function Kt(e,t,n,r){var a=wt,o=Wt.transition;Wt.transition=null;try{wt=1,Gt(e,t,n,r)}finally{wt=a,Wt.transition=o}}function qt(e,t,n,r){var a=wt,o=Wt.transition;Wt.transition=null;try{wt=4,Gt(e,t,n,r)}finally{wt=a,Wt.transition=o}}function Gt(e,t,n,r){if(Ht){var a=Yt(e,t,n,r);if(null===a)Hr(e,t,r,Qt,n),zt(e,r);else if(function(e,t,n,r,a){switch(t){case"focusin":return At=Ft(At,e,t,n,r,a),!0;case"dragenter":return It=Ft(It,e,t,n,r,a),!0;case"mouseover":return Pt=Ft(Pt,e,t,n,r,a),!0;case"pointerover":var o=a.pointerId;return Tt.set(o,Ft(Tt.get(o)||null,e,t,n,r,a)),!0;case"gotpointercapture":return o=a.pointerId,Lt.set(o,Ft(Lt.get(o)||null,e,t,n,r,a)),!0}return!1}(a,e,t,n,r))r.stopPropagation();else if(zt(e,r),4&t&&-1<Dt.indexOf(e)){for(;null!==a;){var o=wa(a);if(null!==o&&kt(o),null===(o=Yt(e,t,n,r))&&Hr(e,t,r,Qt,n),o===a)break;a=o}null!==a&&r.stopPropagation()}else Hr(e,t,r,null,n)}}var Qt=null;function Yt(e,t,n,r){if(Qt=null,null!==(e=ba(e=ke(r))))if(null===(t=Ve(e)))e=null;else if(13===(n=t.tag)){if(null!==(e=We(t)))return e;e=null}else if(3===n){if(t.stateNode.current.memoizedState.isDehydrated)return 3===t.tag?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return Qt=e,null}function Xt(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Ze()){case et:return 1;case tt:return 4;case nt:case rt:return 16;case at:return 536870912;default:return 16}default:return 16}}var Jt=null,Zt=null,en=null;function tn(){if(en)return en;var e,t,n=Zt,r=n.length,a="value"in Jt?Jt.value:Jt.textContent,o=a.length;for(e=0;e<r&&n[e]===a[e];e++);var i=r-e;for(t=1;t<=i&&n[r-t]===a[o-t];t++);return en=a.slice(e,1<t?1-t:void 0)}function nn(e){var t=e.keyCode;return"charCode"in e?0===(e=e.charCode)&&13===t&&(e=13):e=t,10===e&&(e=13),32<=e||13===e?e:0}function rn(){return!0}function an(){return!1}function on(e){function t(t,n,r,a,o){for(var i in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=a,this.target=o,this.currentTarget=null,e)e.hasOwnProperty(i)&&(t=e[i],this[i]=t?t(a):a[i]);return this.isDefaultPrevented=(null!=a.defaultPrevented?a.defaultPrevented:!1===a.returnValue)?rn:an,this.isPropagationStopped=an,this}return O(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():"unknown"!=typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=rn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():"unknown"!=typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=rn)},persist:function(){},isPersistent:rn}),t}var sn,ln,cn,un={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},dn=on(un),fn=O({},un,{view:0,detail:0}),hn=on(fn),pn=O({},fn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:_n,button:0,buttons:0,relatedTarget:function(e){return void 0===e.relatedTarget?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==cn&&(cn&&"mousemove"===e.type?(sn=e.screenX-cn.screenX,ln=e.screenY-cn.screenY):ln=sn=0,cn=e),sn)},movementY:function(e){return"movementY"in e?e.movementY:ln}}),mn=on(pn),gn=on(O({},pn,{dataTransfer:0})),yn=on(O({},fn,{relatedTarget:0})),vn=on(O({},un,{animationName:0,elapsedTime:0,pseudoElement:0})),bn=O({},un,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),wn=on(bn),Sn=on(O({},un,{data:0})),kn={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},xn={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},Cn={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function En(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):!!(e=Cn[e])&&!!t[e]}function _n(){return En}var Mn=O({},fn,{key:function(e){if(e.key){var t=kn[e.key]||e.key;if("Unidentified"!==t)return t}return"keypress"===e.type?13===(e=nn(e))?"Enter":String.fromCharCode(e):"keydown"===e.type||"keyup"===e.type?xn[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:_n,charCode:function(e){return"keypress"===e.type?nn(e):0},keyCode:function(e){return"keydown"===e.type||"keyup"===e.type?e.keyCode:0},which:function(e){return"keypress"===e.type?nn(e):"keydown"===e.type||"keyup"===e.type?e.keyCode:0}}),Rn=on(Mn),An=on(O({},pn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),In=on(O({},fn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:_n})),Pn=on(O({},un,{propertyName:0,elapsedTime:0,pseudoElement:0})),Tn=O({},pn,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),Ln=on(Tn),Nn=[9,13,27,32],Dn=s&&"CompositionEvent"in window,zn=null;s&&"documentMode"in document&&(zn=document.documentMode);var Fn=s&&"TextEvent"in window&&!zn,On=s&&(!Dn||zn&&8<zn&&11>=zn),$n=String.fromCharCode(32),jn=!1;function Un(e,t){switch(e){case"keyup":return-1!==Nn.indexOf(t.keyCode);case"keydown":return 229!==t.keyCode;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Bn(e){return"object"==typeof(e=e.detail)&&"data"in e?e.data:null}var Vn=!1;var Wn={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Hn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return"input"===t?!!Wn[e.type]:"textarea"===t}function Kn(e,t,n,r){Me(r),0<(t=qr(t,"onChange")).length&&(n=new dn("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var qn=null,Gn=null;function Qn(e){$r(e,0)}function Yn(e){if(G(Sa(e)))return e}function Xn(e,t){if("change"===e)return t}var Jn=!1;if(s){var Zn;if(s){var er="oninput"in document;if(!er){var tr=document.createElement("div");tr.setAttribute("oninput","return;"),er="function"==typeof tr.oninput}Zn=er}else Zn=!1;Jn=Zn&&(!document.documentMode||9<document.documentMode)}function nr(){qn&&(qn.detachEvent("onpropertychange",rr),Gn=qn=null)}function rr(e){if("value"===e.propertyName&&Yn(Gn)){var t=[];Kn(t,Gn,e,ke(e)),Te(Qn,t)}}function ar(e,t,n){"focusin"===e?(nr(),Gn=n,(qn=t).attachEvent("onpropertychange",rr)):"focusout"===e&&nr()}function or(e){if("selectionchange"===e||"keyup"===e||"keydown"===e)return Yn(Gn)}function ir(e,t){if("click"===e)return Yn(t)}function sr(e,t){if("input"===e||"change"===e)return Yn(t)}var lr="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t};function cr(e,t){if(lr(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var a=n[r];if(!c.call(t,a)||!lr(e[a],t[a]))return!1}return!0}function ur(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function dr(e,t){var n,r=ur(e);for(e=0;r;){if(3===r.nodeType){if(n=e+r.textContent.length,e<=t&&n>=t)return{node:r,offset:t-e};e=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=ur(r)}}function fr(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?fr(e,t.parentNode):"contains"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function hr(){for(var e=window,t=Q();t instanceof e.HTMLIFrameElement;){try{var n="string"==typeof t.contentWindow.location.href}catch(e){n=!1}if(!n)break;t=Q((e=t.contentWindow).document)}return t}function pr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&("input"===t&&("text"===e.type||"search"===e.type||"tel"===e.type||"url"===e.type||"password"===e.type)||"textarea"===t||"true"===e.contentEditable)}function mr(e){var t=hr(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&fr(n.ownerDocument.documentElement,n)){if(null!==r&&pr(n))if(t=r.start,void 0===(e=r.end)&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if((e=(t=n.ownerDocument||document)&&t.defaultView||window).getSelection){e=e.getSelection();var a=n.textContent.length,o=Math.min(r.start,a);r=void 0===r.end?o:Math.min(r.end,a),!e.extend&&o>r&&(a=r,r=o,o=a),a=dr(n,o);var i=dr(n,r);a&&i&&(1!==e.rangeCount||e.anchorNode!==a.node||e.anchorOffset!==a.offset||e.focusNode!==i.node||e.focusOffset!==i.offset)&&((t=t.createRange()).setStart(a.node,a.offset),e.removeAllRanges(),o>r?(e.addRange(t),e.extend(i.node,i.offset)):(t.setEnd(i.node,i.offset),e.addRange(t)))}for(t=[],e=n;e=e.parentNode;)1===e.nodeType&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for("function"==typeof n.focus&&n.focus(),n=0;n<t.length;n++)(e=t[n]).element.scrollLeft=e.left,e.element.scrollTop=e.top}}var gr=s&&"documentMode"in document&&11>=document.documentMode,yr=null,vr=null,br=null,wr=!1;function Sr(e,t,n){var r=n.window===n?n.document:9===n.nodeType?n:n.ownerDocument;wr||null==yr||yr!==Q(r)||("selectionStart"in(r=yr)&&pr(r)?r={start:r.selectionStart,end:r.selectionEnd}:r={anchorNode:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset},br&&cr(br,r)||(br=r,0<(r=qr(vr,"onSelect")).length&&(t=new dn("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=yr)))}function kr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var xr={animationend:kr("Animation","AnimationEnd"),animationiteration:kr("Animation","AnimationIteration"),animationstart:kr("Animation","AnimationStart"),transitionend:kr("Transition","TransitionEnd")},Cr={},Er={};function _r(e){if(Cr[e])return Cr[e];if(!xr[e])return e;var t,n=xr[e];for(t in n)if(n.hasOwnProperty(t)&&t in Er)return Cr[e]=n[t];return e}s&&(Er=document.createElement("div").style,"AnimationEvent"in window||(delete xr.animationend.animation,delete xr.animationiteration.animation,delete xr.animationstart.animation),"TransitionEvent"in window||delete xr.transitionend.transition);var Mr=_r("animationend"),Rr=_r("animationiteration"),Ar=_r("animationstart"),Ir=_r("transitionend"),Pr=new Map,Tr="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Lr(e,t){Pr.set(e,t),o(t,[e])}for(var Nr=0;Nr<Tr.length;Nr++){var Dr=Tr[Nr];Lr(Dr.toLowerCase(),"on"+(Dr[0].toUpperCase()+Dr.slice(1)))}Lr(Mr,"onAnimationEnd"),Lr(Rr,"onAnimationIteration"),Lr(Ar,"onAnimationStart"),Lr("dblclick","onDoubleClick"),Lr("focusin","onFocus"),Lr("focusout","onBlur"),Lr(Ir,"onTransitionEnd"),i("onMouseEnter",["mouseout","mouseover"]),i("onMouseLeave",["mouseout","mouseover"]),i("onPointerEnter",["pointerout","pointerover"]),i("onPointerLeave",["pointerout","pointerover"]),o("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),o("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),o("onBeforeInput",["compositionend","keypress","textInput","paste"]),o("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),o("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),o("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var zr="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Fr=new Set("cancel close invalid load scroll toggle".split(" ").concat(zr));function Or(e,t,r){var a=e.type||"unknown-event";e.currentTarget=r,function(e,t,r,a,o,i,s,l,c){if(Be.apply(this,arguments),Fe){if(!Fe)throw Error(n(198));var u=Oe;Fe=!1,Oe=null,$e||($e=!0,je=u)}}(a,t,void 0,e),e.currentTarget=null}function $r(e,t){t=!!(4&t);for(var n=0;n<e.length;n++){var r=e[n],a=r.event;r=r.listeners;e:{var o=void 0;if(t)for(var i=r.length-1;0<=i;i--){var s=r[i],l=s.instance,c=s.currentTarget;if(s=s.listener,l!==o&&a.isPropagationStopped())break e;Or(a,s,c),o=l}else for(i=0;i<r.length;i++){if(l=(s=r[i]).instance,c=s.currentTarget,s=s.listener,l!==o&&a.isPropagationStopped())break e;Or(a,s,c),o=l}}}if($e)throw e=je,$e=!1,je=null,e}function jr(e,t){var n=t[ga];void 0===n&&(n=t[ga]=new Set);var r=e+"__bubble";n.has(r)||(Wr(t,e,2,!1),n.add(r))}function Ur(e,t,n){var r=0;t&&(r|=4),Wr(n,e,r,t)}var Br="_reactListening"+Math.random().toString(36).slice(2);function Vr(e){if(!e[Br]){e[Br]=!0,r.forEach(function(t){"selectionchange"!==t&&(Fr.has(t)||Ur(t,!1,e),Ur(t,!0,e))});var t=9===e.nodeType?e:e.ownerDocument;null===t||t[Br]||(t[Br]=!0,Ur("selectionchange",!1,t))}}function Wr(e,t,n,r){switch(Xt(t)){case 1:var a=Kt;break;case 4:a=qt;break;default:a=Gt}n=a.bind(null,t,n,e),a=void 0,!Ne||"touchstart"!==t&&"touchmove"!==t&&"wheel"!==t||(a=!0),r?void 0!==a?e.addEventListener(t,n,{capture:!0,passive:a}):e.addEventListener(t,n,!0):void 0!==a?e.addEventListener(t,n,{passive:a}):e.addEventListener(t,n,!1)}function Hr(e,t,n,r,a){var o=r;if(!(1&t||2&t||null===r))e:for(;;){if(null===r)return;var i=r.tag;if(3===i||4===i){var s=r.stateNode.containerInfo;if(s===a||8===s.nodeType&&s.parentNode===a)break;if(4===i)for(i=r.return;null!==i;){var l=i.tag;if((3===l||4===l)&&((l=i.stateNode.containerInfo)===a||8===l.nodeType&&l.parentNode===a))return;i=i.return}for(;null!==s;){if(null===(i=ba(s)))return;if(5===(l=i.tag)||6===l){r=o=i;continue e}s=s.parentNode}}r=r.return}Te(function(){var r=o,a=ke(n),i=[];e:{var s=Pr.get(e);if(void 0!==s){var l=dn,c=e;switch(e){case"keypress":if(0===nn(n))break e;case"keydown":case"keyup":l=Rn;break;case"focusin":c="focus",l=yn;break;case"focusout":c="blur",l=yn;break;case"beforeblur":case"afterblur":l=yn;break;case"click":if(2===n.button)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":l=mn;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":l=gn;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":l=In;break;case Mr:case Rr:case Ar:l=vn;break;case Ir:l=Pn;break;case"scroll":l=hn;break;case"wheel":l=Ln;break;case"copy":case"cut":case"paste":l=wn;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":l=An}var u=!!(4&t),d=!u&&"scroll"===e,f=u?null!==s?s+"Capture":null:s;u=[];for(var h,p=r;null!==p;){var m=(h=p).stateNode;if(5===h.tag&&null!==m&&(h=m,null!==f&&(null!=(m=Le(p,f))&&u.push(Kr(p,m,h)))),d)break;p=p.return}0<u.length&&(s=new l(s,c,null,n,a),i.push({event:s,listeners:u}))}}if(!(7&t)){if(l="mouseout"===e||"pointerout"===e,(!(s="mouseover"===e||"pointerover"===e)||n===Se||!(c=n.relatedTarget||n.fromElement)||!ba(c)&&!c[ma])&&(l||s)&&(s=a.window===a?a:(s=a.ownerDocument)?s.defaultView||s.parentWindow:window,l?(l=r,null!==(c=(c=n.relatedTarget||n.toElement)?ba(c):null)&&(c!==(d=Ve(c))||5!==c.tag&&6!==c.tag)&&(c=null)):(l=null,c=r),l!==c)){if(u=mn,m="onMouseLeave",f="onMouseEnter",p="mouse","pointerout"!==e&&"pointerover"!==e||(u=An,m="onPointerLeave",f="onPointerEnter",p="pointer"),d=null==l?s:Sa(l),h=null==c?s:Sa(c),(s=new u(m,p+"leave",l,n,a)).target=d,s.relatedTarget=h,m=null,ba(a)===r&&((u=new u(f,p+"enter",c,n,a)).target=h,u.relatedTarget=d,m=u),d=m,l&&c)e:{for(f=c,p=0,h=u=l;h;h=Gr(h))p++;for(h=0,m=f;m;m=Gr(m))h++;for(;0<p-h;)u=Gr(u),p--;for(;0<h-p;)f=Gr(f),h--;for(;p--;){if(u===f||null!==f&&u===f.alternate)break e;u=Gr(u),f=Gr(f)}u=null}else u=null;null!==l&&Qr(i,s,l,u,!1),null!==c&&null!==d&&Qr(i,d,c,u,!0)}if("select"===(l=(s=r?Sa(r):window).nodeName&&s.nodeName.toLowerCase())||"input"===l&&"file"===s.type)var g=Xn;else if(Hn(s))if(Jn)g=sr;else{g=or;var y=ar}else(l=s.nodeName)&&"input"===l.toLowerCase()&&("checkbox"===s.type||"radio"===s.type)&&(g=ir);switch(g&&(g=g(e,r))?Kn(i,g,n,a):(y&&y(e,s,r),"focusout"===e&&(y=s._wrapperState)&&y.controlled&&"number"===s.type&&te(s,"number",s.value)),y=r?Sa(r):window,e){case"focusin":(Hn(y)||"true"===y.contentEditable)&&(yr=y,vr=r,br=null);break;case"focusout":br=vr=yr=null;break;case"mousedown":wr=!0;break;case"contextmenu":case"mouseup":case"dragend":wr=!1,Sr(i,n,a);break;case"selectionchange":if(gr)break;case"keydown":case"keyup":Sr(i,n,a)}var v;if(Dn)e:{switch(e){case"compositionstart":var b="onCompositionStart";break e;case"compositionend":b="onCompositionEnd";break e;case"compositionupdate":b="onCompositionUpdate";break e}b=void 0}else Vn?Un(e,n)&&(b="onCompositionEnd"):"keydown"===e&&229===n.keyCode&&(b="onCompositionStart");b&&(On&&"ko"!==n.locale&&(Vn||"onCompositionStart"!==b?"onCompositionEnd"===b&&Vn&&(v=tn()):(Zt="value"in(Jt=a)?Jt.value:Jt.textContent,Vn=!0)),0<(y=qr(r,b)).length&&(b=new Sn(b,e,null,n,a),i.push({event:b,listeners:y}),v?b.data=v:null!==(v=Bn(n))&&(b.data=v))),(v=Fn?function(e,t){switch(e){case"compositionend":return Bn(t);case"keypress":return 32!==t.which?null:(jn=!0,$n);case"textInput":return(e=t.data)===$n&&jn?null:e;default:return null}}(e,n):function(e,t){if(Vn)return"compositionend"===e||!Dn&&Un(e,t)?(e=tn(),en=Zt=Jt=null,Vn=!1,e):null;switch(e){case"paste":default:return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return On&&"ko"!==t.locale?null:t.data}}(e,n))&&(0<(r=qr(r,"onBeforeInput")).length&&(a=new Sn("onBeforeInput","beforeinput",null,n,a),i.push({event:a,listeners:r}),a.data=v))}$r(i,t)})}function Kr(e,t,n){return{instance:e,listener:t,currentTarget:n}}function qr(e,t){for(var n=t+"Capture",r=[];null!==e;){var a=e,o=a.stateNode;5===a.tag&&null!==o&&(a=o,null!=(o=Le(e,n))&&r.unshift(Kr(e,o,a)),null!=(o=Le(e,t))&&r.push(Kr(e,o,a))),e=e.return}return r}function Gr(e){if(null===e)return null;do{e=e.return}while(e&&5!==e.tag);return e||null}function Qr(e,t,n,r,a){for(var o=t._reactName,i=[];null!==n&&n!==r;){var s=n,l=s.alternate,c=s.stateNode;if(null!==l&&l===r)break;5===s.tag&&null!==c&&(s=c,a?null!=(l=Le(n,o))&&i.unshift(Kr(n,l,s)):a||null!=(l=Le(n,o))&&i.push(Kr(n,l,s))),n=n.return}0!==i.length&&e.push({event:t,listeners:i})}var Yr=/\r\n?/g,Xr=/\u0000|\uFFFD/g;function Jr(e){return("string"==typeof e?e:""+e).replace(Yr,"\n").replace(Xr,"")}function Zr(e,t,r){if(t=Jr(t),Jr(e)!==t&&r)throw Error(n(425))}function ea(){}var ta=null,na=null;function ra(e,t){return"textarea"===e||"noscript"===e||"string"==typeof t.children||"number"==typeof t.children||"object"==typeof t.dangerouslySetInnerHTML&&null!==t.dangerouslySetInnerHTML&&null!=t.dangerouslySetInnerHTML.__html}var aa="function"==typeof setTimeout?setTimeout:void 0,oa="function"==typeof clearTimeout?clearTimeout:void 0,ia="function"==typeof Promise?Promise:void 0,sa="function"==typeof queueMicrotask?queueMicrotask:void 0!==ia?function(e){return ia.resolve(null).then(e).catch(la)}:aa;function la(e){setTimeout(function(){throw e})}function ca(e,t){var n=t,r=0;do{var a=n.nextSibling;if(e.removeChild(n),a&&8===a.nodeType)if("/$"===(n=a.data)){if(0===r)return e.removeChild(a),void Vt(t);r--}else"$"!==n&&"$?"!==n&&"$!"!==n||r++;n=a}while(n);Vt(t)}function ua(e){for(;null!=e;e=e.nextSibling){var t=e.nodeType;if(1===t||3===t)break;if(8===t){if("$"===(t=e.data)||"$!"===t||"$?"===t)break;if("/$"===t)return null}}return e}function da(e){e=e.previousSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if("$"===n||"$!"===n||"$?"===n){if(0===t)return e;t--}else"/$"===n&&t++}e=e.previousSibling}return null}var fa=Math.random().toString(36).slice(2),ha="__reactFiber$"+fa,pa="__reactProps$"+fa,ma="__reactContainer$"+fa,ga="__reactEvents$"+fa,ya="__reactListeners$"+fa,va="__reactHandles$"+fa;function ba(e){var t=e[ha];if(t)return t;for(var n=e.parentNode;n;){if(t=n[ma]||n[ha]){if(n=t.alternate,null!==t.child||null!==n&&null!==n.child)for(e=da(e);null!==e;){if(n=e[ha])return n;e=da(e)}return t}n=(e=n).parentNode}return null}function wa(e){return!(e=e[ha]||e[ma])||5!==e.tag&&6!==e.tag&&13!==e.tag&&3!==e.tag?null:e}function Sa(e){if(5===e.tag||6===e.tag)return e.stateNode;throw Error(n(33))}function ka(e){return e[pa]||null}var xa=[],Ca=-1;function Ea(e){return{current:e}}function _a(e){0>Ca||(e.current=xa[Ca],xa[Ca]=null,Ca--)}function Ma(e,t){Ca++,xa[Ca]=e.current,e.current=t}var Ra={},Aa=Ea(Ra),Ia=Ea(!1),Pa=Ra;function Ta(e,t){var n=e.type.contextTypes;if(!n)return Ra;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var a,o={};for(a in n)o[a]=t[a];return r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=o),o}function La(e){return null!=(e=e.childContextTypes)}function Na(){_a(Ia),_a(Aa)}function Da(e,t,r){if(Aa.current!==Ra)throw Error(n(168));Ma(Aa,t),Ma(Ia,r)}function za(e,t,r){var a=e.stateNode;if(t=t.childContextTypes,"function"!=typeof a.getChildContext)return r;for(var o in a=a.getChildContext())if(!(o in t))throw Error(n(108,W(e)||"Unknown",o));return O({},r,a)}function Fa(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Ra,Pa=Aa.current,Ma(Aa,e),Ma(Ia,Ia.current),!0}function Oa(e,t,r){var a=e.stateNode;if(!a)throw Error(n(169));r?(e=za(e,t,Pa),a.__reactInternalMemoizedMergedChildContext=e,_a(Ia),_a(Aa),Ma(Aa,e)):_a(Ia),Ma(Ia,r)}var $a=null,ja=!1,Ua=!1;function Ba(e){null===$a?$a=[e]:$a.push(e)}function Va(){if(!Ua&&null!==$a){Ua=!0;var e=0,t=wt;try{var n=$a;for(wt=1;e<n.length;e++){var r=n[e];do{r=r(!0)}while(null!==r)}$a=null,ja=!1}catch(t){throw null!==$a&&($a=$a.slice(e+1)),Ge(et,Va),t}finally{wt=t,Ua=!1}}return null}var Wa=[],Ha=0,Ka=null,qa=0,Ga=[],Qa=0,Ya=null,Xa=1,Ja="";function Za(e,t){Wa[Ha++]=qa,Wa[Ha++]=Ka,Ka=e,qa=t}function eo(e,t,n){Ga[Qa++]=Xa,Ga[Qa++]=Ja,Ga[Qa++]=Ya,Ya=e;var r=Xa;e=Ja;var a=32-st(r)-1;r&=~(1<<a),n+=1;var o=32-st(t)+a;if(30<o){var i=a-a%5;o=(r&(1<<i)-1).toString(32),r>>=i,a-=i,Xa=1<<32-st(t)+a|n<<a|r,Ja=o+e}else Xa=1<<o|n<<a|r,Ja=e}function to(e){null!==e.return&&(Za(e,1),eo(e,1,0))}function no(e){for(;e===Ka;)Ka=Wa[--Ha],Wa[Ha]=null,qa=Wa[--Ha],Wa[Ha]=null;for(;e===Ya;)Ya=Ga[--Qa],Ga[Qa]=null,Ja=Ga[--Qa],Ga[Qa]=null,Xa=Ga[--Qa],Ga[Qa]=null}var ro=null,ao=null,oo=!1,io=null;function so(e,t){var n=Tc(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,null===(t=e.deletions)?(e.deletions=[n],e.flags|=16):t.push(n)}function lo(e,t){switch(e.tag){case 5:var n=e.type;return null!==(t=1!==t.nodeType||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t)&&(e.stateNode=t,ro=e,ao=ua(t.firstChild),!0);case 6:return null!==(t=""===e.pendingProps||3!==t.nodeType?null:t)&&(e.stateNode=t,ro=e,ao=null,!0);case 13:return null!==(t=8!==t.nodeType?null:t)&&(n=null!==Ya?{id:Xa,overflow:Ja}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},(n=Tc(18,null,null,0)).stateNode=t,n.return=e,e.child=n,ro=e,ao=null,!0);default:return!1}}function co(e){return!(!(1&e.mode)||128&e.flags)}function uo(e){if(oo){var t=ao;if(t){var r=t;if(!lo(e,t)){if(co(e))throw Error(n(418));t=ua(r.nextSibling);var a=ro;t&&lo(e,t)?so(a,r):(e.flags=-4097&e.flags|2,oo=!1,ro=e)}}else{if(co(e))throw Error(n(418));e.flags=-4097&e.flags|2,oo=!1,ro=e}}}function fo(e){for(e=e.return;null!==e&&5!==e.tag&&3!==e.tag&&13!==e.tag;)e=e.return;ro=e}function ho(e){if(e!==ro)return!1;if(!oo)return fo(e),oo=!0,!1;var t;if((t=3!==e.tag)&&!(t=5!==e.tag)&&(t="head"!==(t=e.type)&&"body"!==t&&!ra(e.type,e.memoizedProps)),t&&(t=ao)){if(co(e))throw po(),Error(n(418));for(;t;)so(e,t),t=ua(t.nextSibling)}if(fo(e),13===e.tag){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(n(317));e:{for(e=e.nextSibling,t=0;e;){if(8===e.nodeType){var r=e.data;if("/$"===r){if(0===t){ao=ua(e.nextSibling);break e}t--}else"$"!==r&&"$!"!==r&&"$?"!==r||t++}e=e.nextSibling}ao=null}}else ao=ro?ua(e.stateNode.nextSibling):null;return!0}function po(){for(var e=ao;e;)e=ua(e.nextSibling)}function mo(){ao=ro=null,oo=!1}function go(e){null===io?io=[e]:io.push(e)}var yo=w.ReactCurrentBatchConfig;function vo(e,t,r){if(null!==(e=r.ref)&&"function"!=typeof e&&"object"!=typeof e){if(r._owner){if(r=r._owner){if(1!==r.tag)throw Error(n(309));var a=r.stateNode}if(!a)throw Error(n(147,e));var o=a,i=""+e;return null!==t&&null!==t.ref&&"function"==typeof t.ref&&t.ref._stringRef===i?t.ref:(t=function(e){var t=o.refs;null===e?delete t[i]:t[i]=e},t._stringRef=i,t)}if("string"!=typeof e)throw Error(n(284));if(!r._owner)throw Error(n(290,e))}return e}function bo(e,t){throw e=Object.prototype.toString.call(t),Error(n(31,"[object Object]"===e?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function wo(e){return(0,e._init)(e._payload)}function So(e){function t(t,n){if(e){var r=t.deletions;null===r?(t.deletions=[n],t.flags|=16):r.push(n)}}function r(n,r){if(!e)return null;for(;null!==r;)t(n,r),r=r.sibling;return null}function a(e,t){for(e=new Map;null!==t;)null!==t.key?e.set(t.key,t):e.set(t.index,t),t=t.sibling;return e}function o(e,t){return(e=Nc(e,t)).index=0,e.sibling=null,e}function i(t,n,r){return t.index=r,e?null!==(r=t.alternate)?(r=r.index)<n?(t.flags|=2,n):r:(t.flags|=2,n):(t.flags|=1048576,n)}function s(t){return e&&null===t.alternate&&(t.flags|=2),t}function l(e,t,n,r){return null===t||6!==t.tag?((t=Oc(n,e.mode,r)).return=e,t):((t=o(t,n)).return=e,t)}function c(e,t,n,r){var a=n.type;return a===C?d(e,t,n.props.children,r,n.key):null!==t&&(t.elementType===a||"object"==typeof a&&null!==a&&a.$$typeof===L&&wo(a)===t.type)?((r=o(t,n.props)).ref=vo(e,t,n),r.return=e,r):((r=Dc(n.type,n.key,n.props,null,e.mode,r)).ref=vo(e,t,n),r.return=e,r)}function u(e,t,n,r){return null===t||4!==t.tag||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?((t=$c(n,e.mode,r)).return=e,t):((t=o(t,n.children||[])).return=e,t)}function d(e,t,n,r,a){return null===t||7!==t.tag?((t=zc(n,e.mode,r,a)).return=e,t):((t=o(t,n)).return=e,t)}function f(e,t,n){if("string"==typeof t&&""!==t||"number"==typeof t)return(t=Oc(""+t,e.mode,n)).return=e,t;if("object"==typeof t&&null!==t){switch(t.$$typeof){case k:return(n=Dc(t.type,t.key,t.props,null,e.mode,n)).ref=vo(e,null,t),n.return=e,n;case x:return(t=$c(t,e.mode,n)).return=e,t;case L:return f(e,(0,t._init)(t._payload),n)}if(ne(t)||z(t))return(t=zc(t,e.mode,n,null)).return=e,t;bo(e,t)}return null}function h(e,t,n,r){var a=null!==t?t.key:null;if("string"==typeof n&&""!==n||"number"==typeof n)return null!==a?null:l(e,t,""+n,r);if("object"==typeof n&&null!==n){switch(n.$$typeof){case k:return n.key===a?c(e,t,n,r):null;case x:return n.key===a?u(e,t,n,r):null;case L:return h(e,t,(a=n._init)(n._payload),r)}if(ne(n)||z(n))return null!==a?null:d(e,t,n,r,null);bo(e,n)}return null}function p(e,t,n,r,a){if("string"==typeof r&&""!==r||"number"==typeof r)return l(t,e=e.get(n)||null,""+r,a);if("object"==typeof r&&null!==r){switch(r.$$typeof){case k:return c(t,e=e.get(null===r.key?n:r.key)||null,r,a);case x:return u(t,e=e.get(null===r.key?n:r.key)||null,r,a);case L:return p(e,t,n,(0,r._init)(r._payload),a)}if(ne(r)||z(r))return d(t,e=e.get(n)||null,r,a,null);bo(t,r)}return null}function m(n,o,s,l){for(var c=null,u=null,d=o,m=o=0,g=null;null!==d&&m<s.length;m++){d.index>m?(g=d,d=null):g=d.sibling;var y=h(n,d,s[m],l);if(null===y){null===d&&(d=g);break}e&&d&&null===y.alternate&&t(n,d),o=i(y,o,m),null===u?c=y:u.sibling=y,u=y,d=g}if(m===s.length)return r(n,d),oo&&Za(n,m),c;if(null===d){for(;m<s.length;m++)null!==(d=f(n,s[m],l))&&(o=i(d,o,m),null===u?c=d:u.sibling=d,u=d);return oo&&Za(n,m),c}for(d=a(n,d);m<s.length;m++)null!==(g=p(d,n,m,s[m],l))&&(e&&null!==g.alternate&&d.delete(null===g.key?m:g.key),o=i(g,o,m),null===u?c=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(n,e)}),oo&&Za(n,m),c}function g(o,s,l,c){var u=z(l);if("function"!=typeof u)throw Error(n(150));if(null==(l=u.call(l)))throw Error(n(151));for(var d=u=null,m=s,g=s=0,y=null,v=l.next();null!==m&&!v.done;g++,v=l.next()){m.index>g?(y=m,m=null):y=m.sibling;var b=h(o,m,v.value,c);if(null===b){null===m&&(m=y);break}e&&m&&null===b.alternate&&t(o,m),s=i(b,s,g),null===d?u=b:d.sibling=b,d=b,m=y}if(v.done)return r(o,m),oo&&Za(o,g),u;if(null===m){for(;!v.done;g++,v=l.next())null!==(v=f(o,v.value,c))&&(s=i(v,s,g),null===d?u=v:d.sibling=v,d=v);return oo&&Za(o,g),u}for(m=a(o,m);!v.done;g++,v=l.next())null!==(v=p(m,o,g,v.value,c))&&(e&&null!==v.alternate&&m.delete(null===v.key?g:v.key),s=i(v,s,g),null===d?u=v:d.sibling=v,d=v);return e&&m.forEach(function(e){return t(o,e)}),oo&&Za(o,g),u}return function e(n,a,i,l){if("object"==typeof i&&null!==i&&i.type===C&&null===i.key&&(i=i.props.children),"object"==typeof i&&null!==i){switch(i.$$typeof){case k:e:{for(var c=i.key,u=a;null!==u;){if(u.key===c){if((c=i.type)===C){if(7===u.tag){r(n,u.sibling),(a=o(u,i.props.children)).return=n,n=a;break e}}else if(u.elementType===c||"object"==typeof c&&null!==c&&c.$$typeof===L&&wo(c)===u.type){r(n,u.sibling),(a=o(u,i.props)).ref=vo(n,u,i),a.return=n,n=a;break e}r(n,u);break}t(n,u),u=u.sibling}i.type===C?((a=zc(i.props.children,n.mode,l,i.key)).return=n,n=a):((l=Dc(i.type,i.key,i.props,null,n.mode,l)).ref=vo(n,a,i),l.return=n,n=l)}return s(n);case x:e:{for(u=i.key;null!==a;){if(a.key===u){if(4===a.tag&&a.stateNode.containerInfo===i.containerInfo&&a.stateNode.implementation===i.implementation){r(n,a.sibling),(a=o(a,i.children||[])).return=n,n=a;break e}r(n,a);break}t(n,a),a=a.sibling}(a=$c(i,n.mode,l)).return=n,n=a}return s(n);case L:return e(n,a,(u=i._init)(i._payload),l)}if(ne(i))return m(n,a,i,l);if(z(i))return g(n,a,i,l);bo(n,i)}return"string"==typeof i&&""!==i||"number"==typeof i?(i=""+i,null!==a&&6===a.tag?(r(n,a.sibling),(a=o(a,i)).return=n,n=a):(r(n,a),(a=Oc(i,n.mode,l)).return=n,n=a),s(n)):r(n,a)}}var ko=So(!0),xo=So(!1),Co=Ea(null),Eo=null,_o=null,Mo=null;function Ro(){Mo=_o=Eo=null}function Ao(e){var t=Co.current;_a(Co),e._currentValue=t}function Io(e,t,n){for(;null!==e;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,null!==r&&(r.childLanes|=t)):null!==r&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Po(e,t){Eo=e,Mo=_o=null,null!==(e=e.dependencies)&&null!==e.firstContext&&(0!==(e.lanes&t)&&(ws=!0),e.firstContext=null)}function To(e){var t=e._currentValue;if(Mo!==e)if(e={context:e,memoizedValue:t,next:null},null===_o){if(null===Eo)throw Error(n(308));_o=e,Eo.dependencies={lanes:0,firstContext:e}}else _o=_o.next=e;return t}var Lo=null;function No(e){null===Lo?Lo=[e]:Lo.push(e)}function Do(e,t,n,r){var a=t.interleaved;return null===a?(n.next=n,No(t)):(n.next=a.next,a.next=n),t.interleaved=n,zo(e,r)}function zo(e,t){e.lanes|=t;var n=e.alternate;for(null!==n&&(n.lanes|=t),n=e,e=e.return;null!==e;)e.childLanes|=t,null!==(n=e.alternate)&&(n.childLanes|=t),n=e,e=e.return;return 3===n.tag?n.stateNode:null}var Fo=!1;function Oo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function $o(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function jo(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Uo(e,t,n){var r=e.updateQueue;if(null===r)return null;if(r=r.shared,2&Al){var a=r.pending;return null===a?t.next=t:(t.next=a.next,a.next=t),r.pending=t,zo(e,n)}return null===(a=r.interleaved)?(t.next=t,No(r)):(t.next=a.next,a.next=t),r.interleaved=t,zo(e,n)}function Bo(e,t,n){if(null!==(t=t.updateQueue)&&(t=t.shared,4194240&n)){var r=t.lanes;n|=r&=e.pendingLanes,t.lanes=n,bt(e,n)}}function Vo(e,t){var n=e.updateQueue,r=e.alternate;if(null!==r&&n===(r=r.updateQueue)){var a=null,o=null;if(null!==(n=n.firstBaseUpdate)){do{var i={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};null===o?a=o=i:o=o.next=i,n=n.next}while(null!==n);null===o?a=o=t:o=o.next=t}else a=o=t;return n={baseState:r.baseState,firstBaseUpdate:a,lastBaseUpdate:o,shared:r.shared,effects:r.effects},void(e.updateQueue=n)}null===(e=n.lastBaseUpdate)?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Wo(e,t,n,r){var a=e.updateQueue;Fo=!1;var o=a.firstBaseUpdate,i=a.lastBaseUpdate,s=a.shared.pending;if(null!==s){a.shared.pending=null;var l=s,c=l.next;l.next=null,null===i?o=c:i.next=c,i=l;var u=e.alternate;null!==u&&((s=(u=u.updateQueue).lastBaseUpdate)!==i&&(null===s?u.firstBaseUpdate=c:s.next=c,u.lastBaseUpdate=l))}if(null!==o){var d=a.baseState;for(i=0,u=c=l=null,s=o;;){var f=s.lane,h=s.eventTime;if((r&f)===f){null!==u&&(u=u.next={eventTime:h,lane:0,tag:s.tag,payload:s.payload,callback:s.callback,next:null});e:{var p=e,m=s;switch(f=t,h=n,m.tag){case 1:if("function"==typeof(p=m.payload)){d=p.call(h,d,f);break e}d=p;break e;case 3:p.flags=-65537&p.flags|128;case 0:if(null==(f="function"==typeof(p=m.payload)?p.call(h,d,f):p))break e;d=O({},d,f);break e;case 2:Fo=!0}}null!==s.callback&&0!==s.lane&&(e.flags|=64,null===(f=a.effects)?a.effects=[s]:f.push(s))}else h={eventTime:h,lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},null===u?(c=u=h,l=d):u=u.next=h,i|=f;if(null===(s=s.next)){if(null===(s=a.shared.pending))break;s=(f=s).next,f.next=null,a.lastBaseUpdate=f,a.shared.pending=null}}if(null===u&&(l=d),a.baseState=l,a.firstBaseUpdate=c,a.lastBaseUpdate=u,null!==(t=a.shared.interleaved)){a=t;do{i|=a.lane,a=a.next}while(a!==t)}else null===o&&(a.shared.lanes=0);Fl|=i,e.lanes=i,e.memoizedState=d}}function Ho(e,t,r){if(e=t.effects,t.effects=null,null!==e)for(t=0;t<e.length;t++){var a=e[t],o=a.callback;if(null!==o){if(a.callback=null,a=r,"function"!=typeof o)throw Error(n(191,o));o.call(a)}}}var Ko={},qo=Ea(Ko),Go=Ea(Ko),Qo=Ea(Ko);function Yo(e){if(e===Ko)throw Error(n(174));return e}function Xo(e,t){switch(Ma(Qo,t),Ma(Go,e),Ma(qo,Ko),e=t.nodeType){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:ce(null,"");break;default:t=ce(t=(e=8===e?t.parentNode:t).namespaceURI||null,e=e.tagName)}_a(qo),Ma(qo,t)}function Jo(){_a(qo),_a(Go),_a(Qo)}function Zo(e){Yo(Qo.current);var t=Yo(qo.current),n=ce(t,e.type);t!==n&&(Ma(Go,e),Ma(qo,n))}function ei(e){Go.current===e&&(_a(qo),_a(Go))}var ti=Ea(0);function ni(e){for(var t=e;null!==t;){if(13===t.tag){var n=t.memoizedState;if(null!==n&&(null===(n=n.dehydrated)||"$?"===n.data||"$!"===n.data))return t}else if(19===t.tag&&void 0!==t.memoizedProps.revealOrder){if(128&t.flags)return t}else if(null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var ri=[];function ai(){for(var e=0;e<ri.length;e++)ri[e]._workInProgressVersionPrimary=null;ri.length=0}var oi=w.ReactCurrentDispatcher,ii=w.ReactCurrentBatchConfig,si=0,li=null,ci=null,ui=null,di=!1,fi=!1,hi=0,pi=0;function mi(){throw Error(n(321))}function gi(e,t){if(null===t)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!lr(e[n],t[n]))return!1;return!0}function yi(e,t,r,a,o,i){if(si=i,li=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,oi.current=null===e||null===e.memoizedState?es:ts,e=r(a,o),fi){i=0;do{if(fi=!1,hi=0,25<=i)throw Error(n(301));i+=1,ui=ci=null,t.updateQueue=null,oi.current=ns,e=r(a,o)}while(fi)}if(oi.current=Zi,t=null!==ci&&null!==ci.next,si=0,ui=ci=li=null,di=!1,t)throw Error(n(300));return e}function vi(){var e=0!==hi;return hi=0,e}function bi(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===ui?li.memoizedState=ui=e:ui=ui.next=e,ui}function wi(){if(null===ci){var e=li.alternate;e=null!==e?e.memoizedState:null}else e=ci.next;var t=null===ui?li.memoizedState:ui.next;if(null!==t)ui=t,ci=e;else{if(null===e)throw Error(n(310));e={memoizedState:(ci=e).memoizedState,baseState:ci.baseState,baseQueue:ci.baseQueue,queue:ci.queue,next:null},null===ui?li.memoizedState=ui=e:ui=ui.next=e}return ui}function Si(e,t){return"function"==typeof t?t(e):t}function ki(e){var t=wi(),r=t.queue;if(null===r)throw Error(n(311));r.lastRenderedReducer=e;var a=ci,o=a.baseQueue,i=r.pending;if(null!==i){if(null!==o){var s=o.next;o.next=i.next,i.next=s}a.baseQueue=o=i,r.pending=null}if(null!==o){i=o.next,a=a.baseState;var l=s=null,c=null,u=i;do{var d=u.lane;if((si&d)===d)null!==c&&(c=c.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),a=u.hasEagerState?u.eagerState:e(a,u.action);else{var f={lane:d,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};null===c?(l=c=f,s=a):c=c.next=f,li.lanes|=d,Fl|=d}u=u.next}while(null!==u&&u!==i);null===c?s=a:c.next=l,lr(a,t.memoizedState)||(ws=!0),t.memoizedState=a,t.baseState=s,t.baseQueue=c,r.lastRenderedState=a}if(null!==(e=r.interleaved)){o=e;do{i=o.lane,li.lanes|=i,Fl|=i,o=o.next}while(o!==e)}else null===o&&(r.lanes=0);return[t.memoizedState,r.dispatch]}function xi(e){var t=wi(),r=t.queue;if(null===r)throw Error(n(311));r.lastRenderedReducer=e;var a=r.dispatch,o=r.pending,i=t.memoizedState;if(null!==o){r.pending=null;var s=o=o.next;do{i=e(i,s.action),s=s.next}while(s!==o);lr(i,t.memoizedState)||(ws=!0),t.memoizedState=i,null===t.baseQueue&&(t.baseState=i),r.lastRenderedState=i}return[i,a]}function Ci(){}function Ei(e,t){var r=li,a=wi(),o=t(),i=!lr(a.memoizedState,o);if(i&&(a.memoizedState=o,ws=!0),a=a.queue,Fi(Ri.bind(null,r,a,e),[e]),a.getSnapshot!==t||i||null!==ui&&1&ui.memoizedState.tag){if(r.flags|=2048,Ti(9,Mi.bind(null,r,a,o,t),void 0,null),null===Il)throw Error(n(349));30&si||_i(r,t,o)}return o}function _i(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},null===(t=li.updateQueue)?(t={lastEffect:null,stores:null},li.updateQueue=t,t.stores=[e]):null===(n=t.stores)?t.stores=[e]:n.push(e)}function Mi(e,t,n,r){t.value=n,t.getSnapshot=r,Ai(t)&&Ii(e)}function Ri(e,t,n){return n(function(){Ai(t)&&Ii(e)})}function Ai(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!lr(e,n)}catch(e){return!0}}function Ii(e){var t=zo(e,1);null!==t&&rc(t,e,1,-1)}function Pi(e){var t=bi();return"function"==typeof e&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Si,lastRenderedState:e},t.queue=e,e=e.dispatch=Qi.bind(null,li,e),[t.memoizedState,e]}function Ti(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},null===(t=li.updateQueue)?(t={lastEffect:null,stores:null},li.updateQueue=t,t.lastEffect=e.next=e):null===(n=t.lastEffect)?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function Li(){return wi().memoizedState}function Ni(e,t,n,r){var a=bi();li.flags|=e,a.memoizedState=Ti(1|t,n,void 0,void 0===r?null:r)}function Di(e,t,n,r){var a=wi();r=void 0===r?null:r;var o=void 0;if(null!==ci){var i=ci.memoizedState;if(o=i.destroy,null!==r&&gi(r,i.deps))return void(a.memoizedState=Ti(t,n,o,r))}li.flags|=e,a.memoizedState=Ti(1|t,n,o,r)}function zi(e,t){return Ni(8390656,8,e,t)}function Fi(e,t){return Di(2048,8,e,t)}function Oi(e,t){return Di(4,2,e,t)}function $i(e,t){return Di(4,4,e,t)}function ji(e,t){return"function"==typeof t?(e=e(),t(e),function(){t(null)}):null!=t?(e=e(),t.current=e,function(){t.current=null}):void 0}function Ui(e,t,n){return n=null!=n?n.concat([e]):null,Di(4,4,ji.bind(null,t,e),n)}function Bi(){}function Vi(e,t){var n=wi();t=void 0===t?null:t;var r=n.memoizedState;return null!==r&&null!==t&&gi(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Wi(e,t){var n=wi();t=void 0===t?null:t;var r=n.memoizedState;return null!==r&&null!==t&&gi(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function Hi(e,t,n){return 21&si?(lr(n,t)||(n=gt(),li.lanes|=n,Fl|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,ws=!0),e.memoizedState=n)}function Ki(e,t){var n=wt;wt=0!==n&&4>n?n:4,e(!0);var r=ii.transition;ii.transition={};try{e(!1),t()}finally{wt=n,ii.transition=r}}function qi(){return wi().memoizedState}function Gi(e,t,n){var r=nc(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Yi(e))Xi(t,n);else if(null!==(n=Do(e,t,n,r))){rc(n,e,r,tc()),Ji(n,t,r)}}function Qi(e,t,n){var r=nc(e),a={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Yi(e))Xi(t,a);else{var o=e.alternate;if(0===e.lanes&&(null===o||0===o.lanes)&&null!==(o=t.lastRenderedReducer))try{var i=t.lastRenderedState,s=o(i,n);if(a.hasEagerState=!0,a.eagerState=s,lr(s,i)){var l=t.interleaved;return null===l?(a.next=a,No(t)):(a.next=l.next,l.next=a),void(t.interleaved=a)}}catch(e){}null!==(n=Do(e,t,a,r))&&(rc(n,e,r,a=tc()),Ji(n,t,r))}}function Yi(e){var t=e.alternate;return e===li||null!==t&&t===li}function Xi(e,t){fi=di=!0;var n=e.pending;null===n?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Ji(e,t,n){if(4194240&n){var r=t.lanes;n|=r&=e.pendingLanes,t.lanes=n,bt(e,n)}}var Zi={readContext:To,useCallback:mi,useContext:mi,useEffect:mi,useImperativeHandle:mi,useInsertionEffect:mi,useLayoutEffect:mi,useMemo:mi,useReducer:mi,useRef:mi,useState:mi,useDebugValue:mi,useDeferredValue:mi,useTransition:mi,useMutableSource:mi,useSyncExternalStore:mi,useId:mi,unstable_isNewReconciler:!1},es={readContext:To,useCallback:function(e,t){return bi().memoizedState=[e,void 0===t?null:t],e},useContext:To,useEffect:zi,useImperativeHandle:function(e,t,n){return n=null!=n?n.concat([e]):null,Ni(4194308,4,ji.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ni(4194308,4,e,t)},useInsertionEffect:function(e,t){return Ni(4,2,e,t)},useMemo:function(e,t){var n=bi();return t=void 0===t?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=bi();return t=void 0!==n?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Gi.bind(null,li,e),[r.memoizedState,e]},useRef:function(e){return e={current:e},bi().memoizedState=e},useState:Pi,useDebugValue:Bi,useDeferredValue:function(e){return bi().memoizedState=e},useTransition:function(){var e=Pi(!1),t=e[0];return e=Ki.bind(null,e[1]),bi().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,r){var a=li,o=bi();if(oo){if(void 0===r)throw Error(n(407));r=r()}else{if(r=t(),null===Il)throw Error(n(349));30&si||_i(a,t,r)}o.memoizedState=r;var i={value:r,getSnapshot:t};return o.queue=i,zi(Ri.bind(null,a,i,e),[e]),a.flags|=2048,Ti(9,Mi.bind(null,a,i,r,t),void 0,null),r},useId:function(){var e=bi(),t=Il.identifierPrefix;if(oo){var n=Ja;t=":"+t+"R"+(n=(Xa&~(1<<32-st(Xa)-1)).toString(32)+n),0<(n=hi++)&&(t+="H"+n.toString(32)),t+=":"}else t=":"+t+"r"+(n=pi++).toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},ts={readContext:To,useCallback:Vi,useContext:To,useEffect:Fi,useImperativeHandle:Ui,useInsertionEffect:Oi,useLayoutEffect:$i,useMemo:Wi,useReducer:ki,useRef:Li,useState:function(){return ki(Si)},useDebugValue:Bi,useDeferredValue:function(e){return Hi(wi(),ci.memoizedState,e)},useTransition:function(){return[ki(Si)[0],wi().memoizedState]},useMutableSource:Ci,useSyncExternalStore:Ei,useId:qi,unstable_isNewReconciler:!1},ns={readContext:To,useCallback:Vi,useContext:To,useEffect:Fi,useImperativeHandle:Ui,useInsertionEffect:Oi,useLayoutEffect:$i,useMemo:Wi,useReducer:xi,useRef:Li,useState:function(){return xi(Si)},useDebugValue:Bi,useDeferredValue:function(e){var t=wi();return null===ci?t.memoizedState=e:Hi(t,ci.memoizedState,e)},useTransition:function(){return[xi(Si)[0],wi().memoizedState]},useMutableSource:Ci,useSyncExternalStore:Ei,useId:qi,unstable_isNewReconciler:!1};function rs(e,t){if(e&&e.defaultProps){for(var n in t=O({},t),e=e.defaultProps)void 0===t[n]&&(t[n]=e[n]);return t}return t}function as(e,t,n,r){n=null==(n=n(r,t=e.memoizedState))?t:O({},t,n),e.memoizedState=n,0===e.lanes&&(e.updateQueue.baseState=n)}var os={isMounted:function(e){return!!(e=e._reactInternals)&&Ve(e)===e},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=tc(),a=nc(e),o=jo(r,a);o.payload=t,null!=n&&(o.callback=n),null!==(t=Uo(e,o,a))&&(rc(t,e,a,r),Bo(t,e,a))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=tc(),a=nc(e),o=jo(r,a);o.tag=1,o.payload=t,null!=n&&(o.callback=n),null!==(t=Uo(e,o,a))&&(rc(t,e,a,r),Bo(t,e,a))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=tc(),r=nc(e),a=jo(n,r);a.tag=2,null!=t&&(a.callback=t),null!==(t=Uo(e,a,r))&&(rc(t,e,r,n),Bo(t,e,r))}};function is(e,t,n,r,a,o,i){return"function"==typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(r,o,i):!t.prototype||!t.prototype.isPureReactComponent||(!cr(n,r)||!cr(a,o))}function ss(e,t,n){var r=!1,a=Ra,o=t.contextType;return"object"==typeof o&&null!==o?o=To(o):(a=La(t)?Pa:Aa.current,o=(r=null!=(r=t.contextTypes))?Ta(e,a):Ra),t=new t(n,o),e.memoizedState=null!==t.state&&void 0!==t.state?t.state:null,t.updater=os,e.stateNode=t,t._reactInternals=e,r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=a,e.__reactInternalMemoizedMaskedChildContext=o),t}function ls(e,t,n,r){e=t.state,"function"==typeof t.componentWillReceiveProps&&t.componentWillReceiveProps(n,r),"function"==typeof t.UNSAFE_componentWillReceiveProps&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&os.enqueueReplaceState(t,t.state,null)}function cs(e,t,n,r){var a=e.stateNode;a.props=n,a.state=e.memoizedState,a.refs={},Oo(e);var o=t.contextType;"object"==typeof o&&null!==o?a.context=To(o):(o=La(t)?Pa:Aa.current,a.context=Ta(e,o)),a.state=e.memoizedState,"function"==typeof(o=t.getDerivedStateFromProps)&&(as(e,t,o,n),a.state=e.memoizedState),"function"==typeof t.getDerivedStateFromProps||"function"==typeof a.getSnapshotBeforeUpdate||"function"!=typeof a.UNSAFE_componentWillMount&&"function"!=typeof a.componentWillMount||(t=a.state,"function"==typeof a.componentWillMount&&a.componentWillMount(),"function"==typeof a.UNSAFE_componentWillMount&&a.UNSAFE_componentWillMount(),t!==a.state&&os.enqueueReplaceState(a,a.state,null),Wo(e,n,a,r),a.state=e.memoizedState),"function"==typeof a.componentDidMount&&(e.flags|=4194308)}function us(e,t){try{var n="",r=t;do{n+=B(r),r=r.return}while(r);var a=n}catch(e){a="\nError generating stack: "+e.message+"\n"+e.stack}return{value:e,source:t,stack:a,digest:null}}function ds(e,t,n){return{value:e,source:null,stack:null!=n?n:null,digest:null!=t?t:null}}function fs(e,t){try{console.error(t.value)}catch(e){setTimeout(function(){throw e})}}var hs="function"==typeof WeakMap?WeakMap:Map;function ps(e,t,n){(n=jo(-1,n)).tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){Hl||(Hl=!0,Kl=r),fs(0,t)},n}function ms(e,t,n){(n=jo(-1,n)).tag=3;var r=e.type.getDerivedStateFromError;if("function"==typeof r){var a=t.value;n.payload=function(){return r(a)},n.callback=function(){fs(0,t)}}var o=e.stateNode;return null!==o&&"function"==typeof o.componentDidCatch&&(n.callback=function(){fs(0,t),"function"!=typeof r&&(null===ql?ql=new Set([this]):ql.add(this));var e=t.stack;this.componentDidCatch(t.value,{componentStack:null!==e?e:""})}),n}function gs(e,t,n){var r=e.pingCache;if(null===r){r=e.pingCache=new hs;var a=new Set;r.set(t,a)}else void 0===(a=r.get(t))&&(a=new Set,r.set(t,a));a.has(n)||(a.add(n),e=_c.bind(null,e,t,n),t.then(e,e))}function ys(e){do{var t;if((t=13===e.tag)&&(t=null===(t=e.memoizedState)||null!==t.dehydrated),t)return e;e=e.return}while(null!==e);return null}function vs(e,t,n,r,a){return 1&e.mode?(e.flags|=65536,e.lanes=a,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,1===n.tag&&(null===n.alternate?n.tag=17:((t=jo(-1,1)).tag=2,Uo(n,t,1))),n.lanes|=1),e)}var bs=w.ReactCurrentOwner,ws=!1;function Ss(e,t,n,r){t.child=null===e?xo(t,null,n,r):ko(t,e.child,n,r)}function ks(e,t,n,r,a){n=n.render;var o=t.ref;return Po(t,a),r=yi(e,t,n,r,o,a),n=vi(),null===e||ws?(oo&&n&&to(t),t.flags|=1,Ss(e,t,r,a),t.child):(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,Hs(e,t,a))}function xs(e,t,n,r,a){if(null===e){var o=n.type;return"function"!=typeof o||Lc(o)||void 0!==o.defaultProps||null!==n.compare||void 0!==n.defaultProps?((e=Dc(n.type,null,r,t,t.mode,a)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=o,Cs(e,t,o,r,a))}if(o=e.child,0===(e.lanes&a)){var i=o.memoizedProps;if((n=null!==(n=n.compare)?n:cr)(i,r)&&e.ref===t.ref)return Hs(e,t,a)}return t.flags|=1,(e=Nc(o,r)).ref=t.ref,e.return=t,t.child=e}function Cs(e,t,n,r,a){if(null!==e){var o=e.memoizedProps;if(cr(o,r)&&e.ref===t.ref){if(ws=!1,t.pendingProps=r=o,0===(e.lanes&a))return t.lanes=e.lanes,Hs(e,t,a);131072&e.flags&&(ws=!0)}}return Ms(e,t,n,r,a)}function Es(e,t,n){var r=t.pendingProps,a=r.children,o=null!==e?e.memoizedState:null;if("hidden"===r.mode)if(1&t.mode){if(!(1073741824&n))return e=null!==o?o.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,Ma(Nl,Ll),Ll|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=null!==o?o.baseLanes:n,Ma(Nl,Ll),Ll|=r}else t.memoizedState={baseLanes:0,cachePool:null,transitions:null},Ma(Nl,Ll),Ll|=n;else null!==o?(r=o.baseLanes|n,t.memoizedState=null):r=n,Ma(Nl,Ll),Ll|=r;return Ss(e,t,a,n),t.child}function _s(e,t){var n=t.ref;(null===e&&null!==n||null!==e&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Ms(e,t,n,r,a){var o=La(n)?Pa:Aa.current;return o=Ta(t,o),Po(t,a),n=yi(e,t,n,r,o,a),r=vi(),null===e||ws?(oo&&r&&to(t),t.flags|=1,Ss(e,t,n,a),t.child):(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,Hs(e,t,a))}function Rs(e,t,n,r,a){if(La(n)){var o=!0;Fa(t)}else o=!1;if(Po(t,a),null===t.stateNode)Ws(e,t),ss(t,n,r),cs(t,n,r,a),r=!0;else if(null===e){var i=t.stateNode,s=t.memoizedProps;i.props=s;var l=i.context,c=n.contextType;"object"==typeof c&&null!==c?c=To(c):c=Ta(t,c=La(n)?Pa:Aa.current);var u=n.getDerivedStateFromProps,d="function"==typeof u||"function"==typeof i.getSnapshotBeforeUpdate;d||"function"!=typeof i.UNSAFE_componentWillReceiveProps&&"function"!=typeof i.componentWillReceiveProps||(s!==r||l!==c)&&ls(t,i,r,c),Fo=!1;var f=t.memoizedState;i.state=f,Wo(t,r,i,a),l=t.memoizedState,s!==r||f!==l||Ia.current||Fo?("function"==typeof u&&(as(t,n,u,r),l=t.memoizedState),(s=Fo||is(t,n,s,r,f,l,c))?(d||"function"!=typeof i.UNSAFE_componentWillMount&&"function"!=typeof i.componentWillMount||("function"==typeof i.componentWillMount&&i.componentWillMount(),"function"==typeof i.UNSAFE_componentWillMount&&i.UNSAFE_componentWillMount()),"function"==typeof i.componentDidMount&&(t.flags|=4194308)):("function"==typeof i.componentDidMount&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),i.props=r,i.state=l,i.context=c,r=s):("function"==typeof i.componentDidMount&&(t.flags|=4194308),r=!1)}else{i=t.stateNode,$o(e,t),s=t.memoizedProps,c=t.type===t.elementType?s:rs(t.type,s),i.props=c,d=t.pendingProps,f=i.context,"object"==typeof(l=n.contextType)&&null!==l?l=To(l):l=Ta(t,l=La(n)?Pa:Aa.current);var h=n.getDerivedStateFromProps;(u="function"==typeof h||"function"==typeof i.getSnapshotBeforeUpdate)||"function"!=typeof i.UNSAFE_componentWillReceiveProps&&"function"!=typeof i.componentWillReceiveProps||(s!==d||f!==l)&&ls(t,i,r,l),Fo=!1,f=t.memoizedState,i.state=f,Wo(t,r,i,a);var p=t.memoizedState;s!==d||f!==p||Ia.current||Fo?("function"==typeof h&&(as(t,n,h,r),p=t.memoizedState),(c=Fo||is(t,n,c,r,f,p,l)||!1)?(u||"function"!=typeof i.UNSAFE_componentWillUpdate&&"function"!=typeof i.componentWillUpdate||("function"==typeof i.componentWillUpdate&&i.componentWillUpdate(r,p,l),"function"==typeof i.UNSAFE_componentWillUpdate&&i.UNSAFE_componentWillUpdate(r,p,l)),"function"==typeof i.componentDidUpdate&&(t.flags|=4),"function"==typeof i.getSnapshotBeforeUpdate&&(t.flags|=1024)):("function"!=typeof i.componentDidUpdate||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),"function"!=typeof i.getSnapshotBeforeUpdate||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),i.props=r,i.state=p,i.context=l,r=c):("function"!=typeof i.componentDidUpdate||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),"function"!=typeof i.getSnapshotBeforeUpdate||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return As(e,t,n,r,o,a)}function As(e,t,n,r,a,o){_s(e,t);var i=!!(128&t.flags);if(!r&&!i)return a&&Oa(t,n,!1),Hs(e,t,o);r=t.stateNode,bs.current=t;var s=i&&"function"!=typeof n.getDerivedStateFromError?null:r.render();return t.flags|=1,null!==e&&i?(t.child=ko(t,e.child,null,o),t.child=ko(t,null,s,o)):Ss(e,t,s,o),t.memoizedState=r.state,a&&Oa(t,n,!0),t.child}function Is(e){var t=e.stateNode;t.pendingContext?Da(0,t.pendingContext,t.pendingContext!==t.context):t.context&&Da(0,t.context,!1),Xo(e,t.containerInfo)}function Ps(e,t,n,r,a){return mo(),go(a),t.flags|=256,Ss(e,t,n,r),t.child}var Ts,Ls,Ns,Ds,zs={dehydrated:null,treeContext:null,retryLane:0};function Fs(e){return{baseLanes:e,cachePool:null,transitions:null}}function Os(e,t,r){var a,o=t.pendingProps,i=ti.current,s=!1,l=!!(128&t.flags);if((a=l)||(a=(null===e||null!==e.memoizedState)&&!!(2&i)),a?(s=!0,t.flags&=-129):null!==e&&null===e.memoizedState||(i|=1),Ma(ti,1&i),null===e)return uo(t),null!==(e=t.memoizedState)&&null!==(e=e.dehydrated)?(1&t.mode?"$!"===e.data?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(l=o.children,e=o.fallback,s?(o=t.mode,s=t.child,l={mode:"hidden",children:l},1&o||null===s?s=Fc(l,o,0,null):(s.childLanes=0,s.pendingProps=l),e=zc(e,o,r,null),s.return=t,e.return=t,s.sibling=e,t.child=s,t.child.memoizedState=Fs(r),t.memoizedState=zs,e):$s(t,l));if(null!==(i=e.memoizedState)&&null!==(a=i.dehydrated))return function(e,t,r,a,o,i,s){if(r)return 256&t.flags?(t.flags&=-257,js(e,t,s,a=ds(Error(n(422))))):null!==t.memoizedState?(t.child=e.child,t.flags|=128,null):(i=a.fallback,o=t.mode,a=Fc({mode:"visible",children:a.children},o,0,null),(i=zc(i,o,s,null)).flags|=2,a.return=t,i.return=t,a.sibling=i,t.child=a,1&t.mode&&ko(t,e.child,null,s),t.child.memoizedState=Fs(s),t.memoizedState=zs,i);if(!(1&t.mode))return js(e,t,s,null);if("$!"===o.data){if(a=o.nextSibling&&o.nextSibling.dataset)var l=a.dgst;return a=l,js(e,t,s,a=ds(i=Error(n(419)),a,void 0))}if(l=0!==(s&e.childLanes),ws||l){if(null!==(a=Il)){switch(s&-s){case 4:o=2;break;case 16:o=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:o=32;break;case 536870912:o=268435456;break;default:o=0}0!==(o=0!==(o&(a.suspendedLanes|s))?0:o)&&o!==i.retryLane&&(i.retryLane=o,zo(e,o),rc(a,e,o,-1))}return gc(),js(e,t,s,a=ds(Error(n(421))))}return"$?"===o.data?(t.flags|=128,t.child=e.child,t=Rc.bind(null,e),o._reactRetry=t,null):(e=i.treeContext,ao=ua(o.nextSibling),ro=t,oo=!0,io=null,null!==e&&(Ga[Qa++]=Xa,Ga[Qa++]=Ja,Ga[Qa++]=Ya,Xa=e.id,Ja=e.overflow,Ya=t),t=$s(t,a.children),t.flags|=4096,t)}(e,t,l,o,a,i,r);if(s){s=o.fallback,l=t.mode,a=(i=e.child).sibling;var c={mode:"hidden",children:o.children};return 1&l||t.child===i?(o=Nc(i,c)).subtreeFlags=14680064&i.subtreeFlags:((o=t.child).childLanes=0,o.pendingProps=c,t.deletions=null),null!==a?s=Nc(a,s):(s=zc(s,l,r,null)).flags|=2,s.return=t,o.return=t,o.sibling=s,t.child=o,o=s,s=t.child,l=null===(l=e.child.memoizedState)?Fs(r):{baseLanes:l.baseLanes|r,cachePool:null,transitions:l.transitions},s.memoizedState=l,s.childLanes=e.childLanes&~r,t.memoizedState=zs,o}return e=(s=e.child).sibling,o=Nc(s,{mode:"visible",children:o.children}),!(1&t.mode)&&(o.lanes=r),o.return=t,o.sibling=null,null!==e&&(null===(r=t.deletions)?(t.deletions=[e],t.flags|=16):r.push(e)),t.child=o,t.memoizedState=null,o}function $s(e,t){return(t=Fc({mode:"visible",children:t},e.mode,0,null)).return=e,e.child=t}function js(e,t,n,r){return null!==r&&go(r),ko(t,e.child,null,n),(e=$s(t,t.pendingProps.children)).flags|=2,t.memoizedState=null,e}function Us(e,t,n){e.lanes|=t;var r=e.alternate;null!==r&&(r.lanes|=t),Io(e.return,t,n)}function Bs(e,t,n,r,a){var o=e.memoizedState;null===o?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=a)}function Vs(e,t,n){var r=t.pendingProps,a=r.revealOrder,o=r.tail;if(Ss(e,t,r.children,n),2&(r=ti.current))r=1&r|2,t.flags|=128;else{if(null!==e&&128&e.flags)e:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&Us(e,n,t);else if(19===e.tag)Us(e,n,t);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;null===e.sibling;){if(null===e.return||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(Ma(ti,r),1&t.mode)switch(a){case"forwards":for(n=t.child,a=null;null!==n;)null!==(e=n.alternate)&&null===ni(e)&&(a=n),n=n.sibling;null===(n=a)?(a=t.child,t.child=null):(a=n.sibling,n.sibling=null),Bs(t,!1,a,n,o);break;case"backwards":for(n=null,a=t.child,t.child=null;null!==a;){if(null!==(e=a.alternate)&&null===ni(e)){t.child=a;break}e=a.sibling,a.sibling=n,n=a,a=e}Bs(t,!0,n,null,o);break;case"together":Bs(t,!1,null,null,void 0);break;default:t.memoizedState=null}else t.memoizedState=null;return t.child}function Ws(e,t){!(1&t.mode)&&null!==e&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Hs(e,t,r){if(null!==e&&(t.dependencies=e.dependencies),Fl|=t.lanes,0===(r&t.childLanes))return null;if(null!==e&&t.child!==e.child)throw Error(n(153));if(null!==t.child){for(r=Nc(e=t.child,e.pendingProps),t.child=r,r.return=t;null!==e.sibling;)e=e.sibling,(r=r.sibling=Nc(e,e.pendingProps)).return=t;r.sibling=null}return t.child}function Ks(e,t){if(!oo)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;null!==t;)null!==t.alternate&&(n=t),t=t.sibling;null===n?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;null!==n;)null!==n.alternate&&(r=n),n=n.sibling;null===r?t||null===e.tail?e.tail=null:e.tail.sibling=null:r.sibling=null}}function qs(e){var t=null!==e.alternate&&e.alternate.child===e.child,n=0,r=0;if(t)for(var a=e.child;null!==a;)n|=a.lanes|a.childLanes,r|=14680064&a.subtreeFlags,r|=14680064&a.flags,a.return=e,a=a.sibling;else for(a=e.child;null!==a;)n|=a.lanes|a.childLanes,r|=a.subtreeFlags,r|=a.flags,a.return=e,a=a.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Gs(e,t,r){var o=t.pendingProps;switch(no(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return qs(t),null;case 1:case 17:return La(t.type)&&Na(),qs(t),null;case 3:return o=t.stateNode,Jo(),_a(Ia),_a(Aa),ai(),o.pendingContext&&(o.context=o.pendingContext,o.pendingContext=null),null!==e&&null!==e.child||(ho(t)?t.flags|=4:null===e||e.memoizedState.isDehydrated&&!(256&t.flags)||(t.flags|=1024,null!==io&&(sc(io),io=null))),Ls(e,t),qs(t),null;case 5:ei(t);var i=Yo(Qo.current);if(r=t.type,null!==e&&null!=t.stateNode)Ns(e,t,r,o,i),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!o){if(null===t.stateNode)throw Error(n(166));return qs(t),null}if(e=Yo(qo.current),ho(t)){o=t.stateNode,r=t.type;var s=t.memoizedProps;switch(o[ha]=t,o[pa]=s,e=!!(1&t.mode),r){case"dialog":jr("cancel",o),jr("close",o);break;case"iframe":case"object":case"embed":jr("load",o);break;case"video":case"audio":for(i=0;i<zr.length;i++)jr(zr[i],o);break;case"source":jr("error",o);break;case"img":case"image":case"link":jr("error",o),jr("load",o);break;case"details":jr("toggle",o);break;case"input":X(o,s),jr("invalid",o);break;case"select":o._wrapperState={wasMultiple:!!s.multiple},jr("invalid",o);break;case"textarea":oe(o,s),jr("invalid",o)}for(var l in be(r,s),i=null,s)if(s.hasOwnProperty(l)){var c=s[l];"children"===l?"string"==typeof c?o.textContent!==c&&(!0!==s.suppressHydrationWarning&&Zr(o.textContent,c,e),i=["children",c]):"number"==typeof c&&o.textContent!==""+c&&(!0!==s.suppressHydrationWarning&&Zr(o.textContent,c,e),i=["children",""+c]):a.hasOwnProperty(l)&&null!=c&&"onScroll"===l&&jr("scroll",o)}switch(r){case"input":q(o),ee(o,s,!0);break;case"textarea":q(o),se(o);break;case"select":case"option":break;default:"function"==typeof s.onClick&&(o.onclick=ea)}o=i,t.updateQueue=o,null!==o&&(t.flags|=4)}else{l=9===i.nodeType?i:i.ownerDocument,"http://www.w3.org/1999/xhtml"===e&&(e=le(r)),"http://www.w3.org/1999/xhtml"===e?"script"===r?((e=l.createElement("div")).innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):"string"==typeof o.is?e=l.createElement(r,{is:o.is}):(e=l.createElement(r),"select"===r&&(l=e,o.multiple?l.multiple=!0:o.size&&(l.size=o.size))):e=l.createElementNS(e,r),e[ha]=t,e[pa]=o,Ts(e,t,!1,!1),t.stateNode=e;e:{switch(l=we(r,o),r){case"dialog":jr("cancel",e),jr("close",e),i=o;break;case"iframe":case"object":case"embed":jr("load",e),i=o;break;case"video":case"audio":for(i=0;i<zr.length;i++)jr(zr[i],e);i=o;break;case"source":jr("error",e),i=o;break;case"img":case"image":case"link":jr("error",e),jr("load",e),i=o;break;case"details":jr("toggle",e),i=o;break;case"input":X(e,o),i=Y(e,o),jr("invalid",e);break;case"option":default:i=o;break;case"select":e._wrapperState={wasMultiple:!!o.multiple},i=O({},o,{value:void 0}),jr("invalid",e);break;case"textarea":oe(e,o),i=ae(e,o),jr("invalid",e)}for(s in be(r,i),c=i)if(c.hasOwnProperty(s)){var u=c[s];"style"===s?ye(e,u):"dangerouslySetInnerHTML"===s?null!=(u=u?u.__html:void 0)&&fe(e,u):"children"===s?"string"==typeof u?("textarea"!==r||""!==u)&&he(e,u):"number"==typeof u&&he(e,""+u):"suppressContentEditableWarning"!==s&&"suppressHydrationWarning"!==s&&"autoFocus"!==s&&(a.hasOwnProperty(s)?null!=u&&"onScroll"===s&&jr("scroll",e):null!=u&&b(e,s,u,l))}switch(r){case"input":q(e),ee(e,o,!1);break;case"textarea":q(e),se(e);break;case"option":null!=o.value&&e.setAttribute("value",""+H(o.value));break;case"select":e.multiple=!!o.multiple,null!=(s=o.value)?re(e,!!o.multiple,s,!1):null!=o.defaultValue&&re(e,!!o.multiple,o.defaultValue,!0);break;default:"function"==typeof i.onClick&&(e.onclick=ea)}switch(r){case"button":case"input":case"select":case"textarea":o=!!o.autoFocus;break e;case"img":o=!0;break e;default:o=!1}}o&&(t.flags|=4)}null!==t.ref&&(t.flags|=512,t.flags|=2097152)}return qs(t),null;case 6:if(e&&null!=t.stateNode)Ds(e,t,e.memoizedProps,o);else{if("string"!=typeof o&&null===t.stateNode)throw Error(n(166));if(r=Yo(Qo.current),Yo(qo.current),ho(t)){if(o=t.stateNode,r=t.memoizedProps,o[ha]=t,(s=o.nodeValue!==r)&&null!==(e=ro))switch(e.tag){case 3:Zr(o.nodeValue,r,!!(1&e.mode));break;case 5:!0!==e.memoizedProps.suppressHydrationWarning&&Zr(o.nodeValue,r,!!(1&e.mode))}s&&(t.flags|=4)}else(o=(9===r.nodeType?r:r.ownerDocument).createTextNode(o))[ha]=t,t.stateNode=o}return qs(t),null;case 13:if(_a(ti),o=t.memoizedState,null===e||null!==e.memoizedState&&null!==e.memoizedState.dehydrated){if(oo&&null!==ao&&1&t.mode&&!(128&t.flags))po(),mo(),t.flags|=98560,s=!1;else if(s=ho(t),null!==o&&null!==o.dehydrated){if(null===e){if(!s)throw Error(n(318));if(!(s=null!==(s=t.memoizedState)?s.dehydrated:null))throw Error(n(317));s[ha]=t}else mo(),!(128&t.flags)&&(t.memoizedState=null),t.flags|=4;qs(t),s=!1}else null!==io&&(sc(io),io=null),s=!0;if(!s)return 65536&t.flags?t:null}return 128&t.flags?(t.lanes=r,t):((o=null!==o)!==(null!==e&&null!==e.memoizedState)&&o&&(t.child.flags|=8192,1&t.mode&&(null===e||1&ti.current?0===Dl&&(Dl=3):gc())),null!==t.updateQueue&&(t.flags|=4),qs(t),null);case 4:return Jo(),Ls(e,t),null===e&&Vr(t.stateNode.containerInfo),qs(t),null;case 10:return Ao(t.type._context),qs(t),null;case 19:if(_a(ti),null===(s=t.memoizedState))return qs(t),null;if(o=!!(128&t.flags),null===(l=s.rendering))if(o)Ks(s,!1);else{if(0!==Dl||null!==e&&128&e.flags)for(e=t.child;null!==e;){if(null!==(l=ni(e))){for(t.flags|=128,Ks(s,!1),null!==(o=l.updateQueue)&&(t.updateQueue=o,t.flags|=4),t.subtreeFlags=0,o=r,r=t.child;null!==r;)e=o,(s=r).flags&=14680066,null===(l=s.alternate)?(s.childLanes=0,s.lanes=e,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=l.childLanes,s.lanes=l.lanes,s.child=l.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=l.memoizedProps,s.memoizedState=l.memoizedState,s.updateQueue=l.updateQueue,s.type=l.type,e=l.dependencies,s.dependencies=null===e?null:{lanes:e.lanes,firstContext:e.firstContext}),r=r.sibling;return Ma(ti,1&ti.current|2),t.child}e=e.sibling}null!==s.tail&&Je()>Vl&&(t.flags|=128,o=!0,Ks(s,!1),t.lanes=4194304)}else{if(!o)if(null!==(e=ni(l))){if(t.flags|=128,o=!0,null!==(r=e.updateQueue)&&(t.updateQueue=r,t.flags|=4),Ks(s,!0),null===s.tail&&"hidden"===s.tailMode&&!l.alternate&&!oo)return qs(t),null}else 2*Je()-s.renderingStartTime>Vl&&1073741824!==r&&(t.flags|=128,o=!0,Ks(s,!1),t.lanes=4194304);s.isBackwards?(l.sibling=t.child,t.child=l):(null!==(r=s.last)?r.sibling=l:t.child=l,s.last=l)}return null!==s.tail?(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=Je(),t.sibling=null,r=ti.current,Ma(ti,o?1&r|2:1&r),t):(qs(t),null);case 22:case 23:return fc(),o=null!==t.memoizedState,null!==e&&null!==e.memoizedState!==o&&(t.flags|=8192),o&&1&t.mode?!!(1073741824&Ll)&&(qs(t),6&t.subtreeFlags&&(t.flags|=8192)):qs(t),null;case 24:case 25:return null}throw Error(n(156,t.tag))}function Qs(e,t){switch(no(t),t.tag){case 1:return La(t.type)&&Na(),65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 3:return Jo(),_a(Ia),_a(Aa),ai(),65536&(e=t.flags)&&!(128&e)?(t.flags=-65537&e|128,t):null;case 5:return ei(t),null;case 13:if(_a(ti),null!==(e=t.memoizedState)&&null!==e.dehydrated){if(null===t.alternate)throw Error(n(340));mo()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 19:return _a(ti),null;case 4:return Jo(),null;case 10:return Ao(t.type._context),null;case 22:case 23:return fc(),null;default:return null}}Ts=function(e,t){for(var n=t.child;null!==n;){if(5===n.tag||6===n.tag)e.appendChild(n.stateNode);else if(4!==n.tag&&null!==n.child){n.child.return=n,n=n.child;continue}if(n===t)break;for(;null===n.sibling;){if(null===n.return||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}},Ls=function(){},Ns=function(e,t,n,r){var o=e.memoizedProps;if(o!==r){e=t.stateNode,Yo(qo.current);var i,s=null;switch(n){case"input":o=Y(e,o),r=Y(e,r),s=[];break;case"select":o=O({},o,{value:void 0}),r=O({},r,{value:void 0}),s=[];break;case"textarea":o=ae(e,o),r=ae(e,r),s=[];break;default:"function"!=typeof o.onClick&&"function"==typeof r.onClick&&(e.onclick=ea)}for(u in be(n,r),n=null,o)if(!r.hasOwnProperty(u)&&o.hasOwnProperty(u)&&null!=o[u])if("style"===u){var l=o[u];for(i in l)l.hasOwnProperty(i)&&(n||(n={}),n[i]="")}else"dangerouslySetInnerHTML"!==u&&"children"!==u&&"suppressContentEditableWarning"!==u&&"suppressHydrationWarning"!==u&&"autoFocus"!==u&&(a.hasOwnProperty(u)?s||(s=[]):(s=s||[]).push(u,null));for(u in r){var c=r[u];if(l=null!=o?o[u]:void 0,r.hasOwnProperty(u)&&c!==l&&(null!=c||null!=l))if("style"===u)if(l){for(i in l)!l.hasOwnProperty(i)||c&&c.hasOwnProperty(i)||(n||(n={}),n[i]="");for(i in c)c.hasOwnProperty(i)&&l[i]!==c[i]&&(n||(n={}),n[i]=c[i])}else n||(s||(s=[]),s.push(u,n)),n=c;else"dangerouslySetInnerHTML"===u?(c=c?c.__html:void 0,l=l?l.__html:void 0,null!=c&&l!==c&&(s=s||[]).push(u,c)):"children"===u?"string"!=typeof c&&"number"!=typeof c||(s=s||[]).push(u,""+c):"suppressContentEditableWarning"!==u&&"suppressHydrationWarning"!==u&&(a.hasOwnProperty(u)?(null!=c&&"onScroll"===u&&jr("scroll",e),s||l===c||(s=[])):(s=s||[]).push(u,c))}n&&(s=s||[]).push("style",n);var u=s;(t.updateQueue=u)&&(t.flags|=4)}},Ds=function(e,t,n,r){n!==r&&(t.flags|=4)};var Ys=!1,Xs=!1,Js="function"==typeof WeakSet?WeakSet:Set,Zs=null;function el(e,t){var n=e.ref;if(null!==n)if("function"==typeof n)try{n(null)}catch(n){Ec(e,t,n)}else n.current=null}function tl(e,t,n){try{n()}catch(n){Ec(e,t,n)}}var nl=!1;function rl(e,t,n){var r=t.updateQueue;if(null!==(r=null!==r?r.lastEffect:null)){var a=r=r.next;do{if((a.tag&e)===e){var o=a.destroy;a.destroy=void 0,void 0!==o&&tl(t,n,o)}a=a.next}while(a!==r)}}function al(e,t){if(null!==(t=null!==(t=t.updateQueue)?t.lastEffect:null)){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function ol(e){var t=e.ref;if(null!==t){var n=e.stateNode;e.tag,e=n,"function"==typeof t?t(e):t.current=e}}function il(e){var t=e.alternate;null!==t&&(e.alternate=null,il(t)),e.child=null,e.deletions=null,e.sibling=null,5===e.tag&&(null!==(t=e.stateNode)&&(delete t[ha],delete t[pa],delete t[ga],delete t[ya],delete t[va])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function sl(e){return 5===e.tag||3===e.tag||4===e.tag}function ll(e){e:for(;;){for(;null===e.sibling;){if(null===e.return||sl(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;5!==e.tag&&6!==e.tag&&18!==e.tag;){if(2&e.flags)continue e;if(null===e.child||4===e.tag)continue e;e.child.return=e,e=e.child}if(!(2&e.flags))return e.stateNode}}function cl(e,t,n){var r=e.tag;if(5===r||6===r)e=e.stateNode,t?8===n.nodeType?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(8===n.nodeType?(t=n.parentNode).insertBefore(e,n):(t=n).appendChild(e),null!=(n=n._reactRootContainer)||null!==t.onclick||(t.onclick=ea));else if(4!==r&&null!==(e=e.child))for(cl(e,t,n),e=e.sibling;null!==e;)cl(e,t,n),e=e.sibling}function ul(e,t,n){var r=e.tag;if(5===r||6===r)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(4!==r&&null!==(e=e.child))for(ul(e,t,n),e=e.sibling;null!==e;)ul(e,t,n),e=e.sibling}var dl=null,fl=!1;function hl(e,t,n){for(n=n.child;null!==n;)pl(e,t,n),n=n.sibling}function pl(e,t,n){if(it&&"function"==typeof it.onCommitFiberUnmount)try{it.onCommitFiberUnmount(ot,n)}catch(e){}switch(n.tag){case 5:Xs||el(n,t);case 6:var r=dl,a=fl;dl=null,hl(e,t,n),fl=a,null!==(dl=r)&&(fl?(e=dl,n=n.stateNode,8===e.nodeType?e.parentNode.removeChild(n):e.removeChild(n)):dl.removeChild(n.stateNode));break;case 18:null!==dl&&(fl?(e=dl,n=n.stateNode,8===e.nodeType?ca(e.parentNode,n):1===e.nodeType&&ca(e,n),Vt(e)):ca(dl,n.stateNode));break;case 4:r=dl,a=fl,dl=n.stateNode.containerInfo,fl=!0,hl(e,t,n),dl=r,fl=a;break;case 0:case 11:case 14:case 15:if(!Xs&&(null!==(r=n.updateQueue)&&null!==(r=r.lastEffect))){a=r=r.next;do{var o=a,i=o.destroy;o=o.tag,void 0!==i&&(2&o||4&o)&&tl(n,t,i),a=a.next}while(a!==r)}hl(e,t,n);break;case 1:if(!Xs&&(el(n,t),"function"==typeof(r=n.stateNode).componentWillUnmount))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(e){Ec(n,t,e)}hl(e,t,n);break;case 21:hl(e,t,n);break;case 22:1&n.mode?(Xs=(r=Xs)||null!==n.memoizedState,hl(e,t,n),Xs=r):hl(e,t,n);break;default:hl(e,t,n)}}function ml(e){var t=e.updateQueue;if(null!==t){e.updateQueue=null;var n=e.stateNode;null===n&&(n=e.stateNode=new Js),t.forEach(function(t){var r=Ac.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))})}}function gl(e,t){var r=t.deletions;if(null!==r)for(var a=0;a<r.length;a++){var o=r[a];try{var i=e,s=t,l=s;e:for(;null!==l;){switch(l.tag){case 5:dl=l.stateNode,fl=!1;break e;case 3:case 4:dl=l.stateNode.containerInfo,fl=!0;break e}l=l.return}if(null===dl)throw Error(n(160));pl(i,s,o),dl=null,fl=!1;var c=o.alternate;null!==c&&(c.return=null),o.return=null}catch(e){Ec(o,t,e)}}if(12854&t.subtreeFlags)for(t=t.child;null!==t;)yl(t,e),t=t.sibling}function yl(e,t){var r=e.alternate,a=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(gl(t,e),vl(e),4&a){try{rl(3,e,e.return),al(3,e)}catch(t){Ec(e,e.return,t)}try{rl(5,e,e.return)}catch(t){Ec(e,e.return,t)}}break;case 1:gl(t,e),vl(e),512&a&&null!==r&&el(r,r.return);break;case 5:if(gl(t,e),vl(e),512&a&&null!==r&&el(r,r.return),32&e.flags){var o=e.stateNode;try{he(o,"")}catch(t){Ec(e,e.return,t)}}if(4&a&&null!=(o=e.stateNode)){var i=e.memoizedProps,s=null!==r?r.memoizedProps:i,l=e.type,c=e.updateQueue;if(e.updateQueue=null,null!==c)try{"input"===l&&"radio"===i.type&&null!=i.name&&J(o,i),we(l,s);var u=we(l,i);for(s=0;s<c.length;s+=2){var d=c[s],f=c[s+1];"style"===d?ye(o,f):"dangerouslySetInnerHTML"===d?fe(o,f):"children"===d?he(o,f):b(o,d,f,u)}switch(l){case"input":Z(o,i);break;case"textarea":ie(o,i);break;case"select":var h=o._wrapperState.wasMultiple;o._wrapperState.wasMultiple=!!i.multiple;var p=i.value;null!=p?re(o,!!i.multiple,p,!1):h!==!!i.multiple&&(null!=i.defaultValue?re(o,!!i.multiple,i.defaultValue,!0):re(o,!!i.multiple,i.multiple?[]:"",!1))}o[pa]=i}catch(t){Ec(e,e.return,t)}}break;case 6:if(gl(t,e),vl(e),4&a){if(null===e.stateNode)throw Error(n(162));o=e.stateNode,i=e.memoizedProps;try{o.nodeValue=i}catch(t){Ec(e,e.return,t)}}break;case 3:if(gl(t,e),vl(e),4&a&&null!==r&&r.memoizedState.isDehydrated)try{Vt(t.containerInfo)}catch(t){Ec(e,e.return,t)}break;case 4:default:gl(t,e),vl(e);break;case 13:gl(t,e),vl(e),8192&(o=e.child).flags&&(i=null!==o.memoizedState,o.stateNode.isHidden=i,!i||null!==o.alternate&&null!==o.alternate.memoizedState||(Bl=Je())),4&a&&ml(e);break;case 22:if(d=null!==r&&null!==r.memoizedState,1&e.mode?(Xs=(u=Xs)||d,gl(t,e),Xs=u):gl(t,e),vl(e),8192&a){if(u=null!==e.memoizedState,(e.stateNode.isHidden=u)&&!d&&1&e.mode)for(Zs=e,d=e.child;null!==d;){for(f=Zs=d;null!==Zs;){switch(p=(h=Zs).child,h.tag){case 0:case 11:case 14:case 15:rl(4,h,h.return);break;case 1:el(h,h.return);var m=h.stateNode;if("function"==typeof m.componentWillUnmount){a=h,r=h.return;try{t=a,m.props=t.memoizedProps,m.state=t.memoizedState,m.componentWillUnmount()}catch(e){Ec(a,r,e)}}break;case 5:el(h,h.return);break;case 22:if(null!==h.memoizedState){kl(f);continue}}null!==p?(p.return=h,Zs=p):kl(f)}d=d.sibling}e:for(d=null,f=e;;){if(5===f.tag){if(null===d){d=f;try{o=f.stateNode,u?"function"==typeof(i=o.style).setProperty?i.setProperty("display","none","important"):i.display="none":(l=f.stateNode,s=null!=(c=f.memoizedProps.style)&&c.hasOwnProperty("display")?c.display:null,l.style.display=ge("display",s))}catch(t){Ec(e,e.return,t)}}}else if(6===f.tag){if(null===d)try{f.stateNode.nodeValue=u?"":f.memoizedProps}catch(t){Ec(e,e.return,t)}}else if((22!==f.tag&&23!==f.tag||null===f.memoizedState||f===e)&&null!==f.child){f.child.return=f,f=f.child;continue}if(f===e)break e;for(;null===f.sibling;){if(null===f.return||f.return===e)break e;d===f&&(d=null),f=f.return}d===f&&(d=null),f.sibling.return=f.return,f=f.sibling}}break;case 19:gl(t,e),vl(e),4&a&&ml(e);case 21:}}function vl(e){var t=e.flags;if(2&t){try{e:{for(var r=e.return;null!==r;){if(sl(r)){var a=r;break e}r=r.return}throw Error(n(160))}switch(a.tag){case 5:var o=a.stateNode;32&a.flags&&(he(o,""),a.flags&=-33),ul(e,ll(e),o);break;case 3:case 4:var i=a.stateNode.containerInfo;cl(e,ll(e),i);break;default:throw Error(n(161))}}catch(t){Ec(e,e.return,t)}e.flags&=-3}4096&t&&(e.flags&=-4097)}function bl(e,t,n){Zs=e,wl(e)}function wl(e,t,n){for(var r=!!(1&e.mode);null!==Zs;){var a=Zs,o=a.child;if(22===a.tag&&r){var i=null!==a.memoizedState||Ys;if(!i){var s=a.alternate,l=null!==s&&null!==s.memoizedState||Xs;s=Ys;var c=Xs;if(Ys=i,(Xs=l)&&!c)for(Zs=a;null!==Zs;)l=(i=Zs).child,22===i.tag&&null!==i.memoizedState?xl(a):null!==l?(l.return=i,Zs=l):xl(a);for(;null!==o;)Zs=o,wl(o),o=o.sibling;Zs=a,Ys=s,Xs=c}Sl(e)}else 8772&a.subtreeFlags&&null!==o?(o.return=a,Zs=o):Sl(e)}}function Sl(e){for(;null!==Zs;){var t=Zs;if(8772&t.flags){var r=t.alternate;try{if(8772&t.flags)switch(t.tag){case 0:case 11:case 15:Xs||al(5,t);break;case 1:var a=t.stateNode;if(4&t.flags&&!Xs)if(null===r)a.componentDidMount();else{var o=t.elementType===t.type?r.memoizedProps:rs(t.type,r.memoizedProps);a.componentDidUpdate(o,r.memoizedState,a.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;null!==i&&Ho(t,i,a);break;case 3:var s=t.updateQueue;if(null!==s){if(r=null,null!==t.child)switch(t.child.tag){case 5:case 1:r=t.child.stateNode}Ho(t,s,r)}break;case 5:var l=t.stateNode;if(null===r&&4&t.flags){r=l;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&r.focus();break;case"img":c.src&&(r.src=c.src)}}break;case 6:case 4:case 12:case 19:case 17:case 21:case 22:case 23:case 25:break;case 13:if(null===t.memoizedState){var u=t.alternate;if(null!==u){var d=u.memoizedState;if(null!==d){var f=d.dehydrated;null!==f&&Vt(f)}}}break;default:throw Error(n(163))}Xs||512&t.flags&&ol(t)}catch(e){Ec(t,t.return,e)}}if(t===e){Zs=null;break}if(null!==(r=t.sibling)){r.return=t.return,Zs=r;break}Zs=t.return}}function kl(e){for(;null!==Zs;){var t=Zs;if(t===e){Zs=null;break}var n=t.sibling;if(null!==n){n.return=t.return,Zs=n;break}Zs=t.return}}function xl(e){for(;null!==Zs;){var t=Zs;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{al(4,t)}catch(e){Ec(t,n,e)}break;case 1:var r=t.stateNode;if("function"==typeof r.componentDidMount){var a=t.return;try{r.componentDidMount()}catch(e){Ec(t,a,e)}}var o=t.return;try{ol(t)}catch(e){Ec(t,o,e)}break;case 5:var i=t.return;try{ol(t)}catch(e){Ec(t,i,e)}}}catch(e){Ec(t,t.return,e)}if(t===e){Zs=null;break}var s=t.sibling;if(null!==s){s.return=t.return,Zs=s;break}Zs=t.return}}var Cl,El=Math.ceil,_l=w.ReactCurrentDispatcher,Ml=w.ReactCurrentOwner,Rl=w.ReactCurrentBatchConfig,Al=0,Il=null,Pl=null,Tl=0,Ll=0,Nl=Ea(0),Dl=0,zl=null,Fl=0,Ol=0,$l=0,jl=null,Ul=null,Bl=0,Vl=1/0,Wl=null,Hl=!1,Kl=null,ql=null,Gl=!1,Ql=null,Yl=0,Xl=0,Jl=null,Zl=-1,ec=0;function tc(){return 6&Al?Je():-1!==Zl?Zl:Zl=Je()}function nc(e){return 1&e.mode?2&Al&&0!==Tl?Tl&-Tl:null!==yo.transition?(0===ec&&(ec=gt()),ec):0!==(e=wt)?e:e=void 0===(e=window.event)?16:Xt(e.type):1}function rc(e,t,r,a){if(50<Xl)throw Xl=0,Jl=null,Error(n(185));vt(e,r,a),2&Al&&e===Il||(e===Il&&(!(2&Al)&&(Ol|=r),4===Dl&&lc(e,Tl)),ac(e,a),1===r&&0===Al&&!(1&t.mode)&&(Vl=Je()+500,ja&&Va()))}function ac(e,t){var n=e.callbackNode;!function(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,a=e.expirationTimes,o=e.pendingLanes;0<o;){var i=31-st(o),s=1<<i,l=a[i];-1===l?0!==(s&n)&&0===(s&r)||(a[i]=pt(s,t)):l<=t&&(e.expiredLanes|=s),o&=~s}}(e,t);var r=ht(e,e===Il?Tl:0);if(0===r)null!==n&&Qe(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(null!=n&&Qe(n),1===t)0===e.tag?function(e){ja=!0,Ba(e)}(cc.bind(null,e)):Ba(cc.bind(null,e)),sa(function(){!(6&Al)&&Va()}),n=null;else{switch(St(r)){case 1:n=et;break;case 4:n=tt;break;case 16:default:n=nt;break;case 536870912:n=at}n=Ic(n,oc.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function oc(e,t){if(Zl=-1,ec=0,6&Al)throw Error(n(327));var r=e.callbackNode;if(xc()&&e.callbackNode!==r)return null;var a=ht(e,e===Il?Tl:0);if(0===a)return null;if(30&a||0!==(a&e.expiredLanes)||t)t=yc(e,a);else{t=a;var o=Al;Al|=2;var i=mc();for(Il===e&&Tl===t||(Wl=null,Vl=Je()+500,hc(e,t));;)try{bc();break}catch(t){pc(e,t)}Ro(),_l.current=i,Al=o,null!==Pl?t=0:(Il=null,Tl=0,t=Dl)}if(0!==t){if(2===t&&(0!==(o=mt(e))&&(a=o,t=ic(e,o))),1===t)throw r=zl,hc(e,0),lc(e,a),ac(e,Je()),r;if(6===t)lc(e,a);else{if(o=e.current.alternate,!(30&a||function(e){for(var t=e;;){if(16384&t.flags){var n=t.updateQueue;if(null!==n&&null!==(n=n.stores))for(var r=0;r<n.length;r++){var a=n[r],o=a.getSnapshot;a=a.value;try{if(!lr(o(),a))return!1}catch(e){return!1}}}if(n=t.child,16384&t.subtreeFlags&&null!==n)n.return=t,t=n;else{if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}(o)||(t=yc(e,a),2===t&&(i=mt(e),0!==i&&(a=i,t=ic(e,i))),1!==t)))throw r=zl,hc(e,0),lc(e,a),ac(e,Je()),r;switch(e.finishedWork=o,e.finishedLanes=a,t){case 0:case 1:throw Error(n(345));case 2:case 5:kc(e,Ul,Wl);break;case 3:if(lc(e,a),(130023424&a)===a&&10<(t=Bl+500-Je())){if(0!==ht(e,0))break;if(((o=e.suspendedLanes)&a)!==a){tc(),e.pingedLanes|=e.suspendedLanes&o;break}e.timeoutHandle=aa(kc.bind(null,e,Ul,Wl),t);break}kc(e,Ul,Wl);break;case 4:if(lc(e,a),(4194240&a)===a)break;for(t=e.eventTimes,o=-1;0<a;){var s=31-st(a);i=1<<s,(s=t[s])>o&&(o=s),a&=~i}if(a=o,10<(a=(120>(a=Je()-a)?120:480>a?480:1080>a?1080:1920>a?1920:3e3>a?3e3:4320>a?4320:1960*El(a/1960))-a)){e.timeoutHandle=aa(kc.bind(null,e,Ul,Wl),a);break}kc(e,Ul,Wl);break;default:throw Error(n(329))}}}return ac(e,Je()),e.callbackNode===r?oc.bind(null,e):null}function ic(e,t){var n=jl;return e.current.memoizedState.isDehydrated&&(hc(e,t).flags|=256),2!==(e=yc(e,t))&&(t=Ul,Ul=n,null!==t&&sc(t)),e}function sc(e){null===Ul?Ul=e:Ul.push.apply(Ul,e)}function lc(e,t){for(t&=~$l,t&=~Ol,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-st(t),r=1<<n;e[n]=-1,t&=~r}}function cc(e){if(6&Al)throw Error(n(327));xc();var t=ht(e,0);if(!(1&t))return ac(e,Je()),null;var r=yc(e,t);if(0!==e.tag&&2===r){var a=mt(e);0!==a&&(t=a,r=ic(e,a))}if(1===r)throw r=zl,hc(e,0),lc(e,t),ac(e,Je()),r;if(6===r)throw Error(n(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,kc(e,Ul,Wl),ac(e,Je()),null}function uc(e,t){var n=Al;Al|=1;try{return e(t)}finally{0===(Al=n)&&(Vl=Je()+500,ja&&Va())}}function dc(e){null!==Ql&&0===Ql.tag&&!(6&Al)&&xc();var t=Al;Al|=1;var n=Rl.transition,r=wt;try{if(Rl.transition=null,wt=1,e)return e()}finally{wt=r,Rl.transition=n,!(6&(Al=t))&&Va()}}function fc(){Ll=Nl.current,_a(Nl)}function hc(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(-1!==n&&(e.timeoutHandle=-1,oa(n)),null!==Pl)for(n=Pl.return;null!==n;){var r=n;switch(no(r),r.tag){case 1:null!=(r=r.type.childContextTypes)&&Na();break;case 3:Jo(),_a(Ia),_a(Aa),ai();break;case 5:ei(r);break;case 4:Jo();break;case 13:case 19:_a(ti);break;case 10:Ao(r.type._context);break;case 22:case 23:fc()}n=n.return}if(Il=e,Pl=e=Nc(e.current,null),Tl=Ll=t,Dl=0,zl=null,$l=Ol=Fl=0,Ul=jl=null,null!==Lo){for(t=0;t<Lo.length;t++)if(null!==(r=(n=Lo[t]).interleaved)){n.interleaved=null;var a=r.next,o=n.pending;if(null!==o){var i=o.next;o.next=a,r.next=i}n.pending=r}Lo=null}return e}function pc(e,t){for(;;){var r=Pl;try{if(Ro(),oi.current=Zi,di){for(var a=li.memoizedState;null!==a;){var o=a.queue;null!==o&&(o.pending=null),a=a.next}di=!1}if(si=0,ui=ci=li=null,fi=!1,hi=0,Ml.current=null,null===r||null===r.return){Dl=1,zl=t,Pl=null;break}e:{var i=e,s=r.return,l=r,c=t;if(t=Tl,l.flags|=32768,null!==c&&"object"==typeof c&&"function"==typeof c.then){var u=c,d=l,f=d.tag;if(!(1&d.mode||0!==f&&11!==f&&15!==f)){var h=d.alternate;h?(d.updateQueue=h.updateQueue,d.memoizedState=h.memoizedState,d.lanes=h.lanes):(d.updateQueue=null,d.memoizedState=null)}var p=ys(s);if(null!==p){p.flags&=-257,vs(p,s,l,0,t),1&p.mode&&gs(i,u,t),c=u;var m=(t=p).updateQueue;if(null===m){var g=new Set;g.add(c),t.updateQueue=g}else m.add(c);break e}if(!(1&t)){gs(i,u,t),gc();break e}c=Error(n(426))}else if(oo&&1&l.mode){var y=ys(s);if(null!==y){!(65536&y.flags)&&(y.flags|=256),vs(y,s,l,0,t),go(us(c,l));break e}}i=c=us(c,l),4!==Dl&&(Dl=2),null===jl?jl=[i]:jl.push(i),i=s;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t,Vo(i,ps(0,c,t));break e;case 1:l=c;var v=i.type,b=i.stateNode;if(!(128&i.flags||"function"!=typeof v.getDerivedStateFromError&&(null===b||"function"!=typeof b.componentDidCatch||null!==ql&&ql.has(b)))){i.flags|=65536,t&=-t,i.lanes|=t,Vo(i,ms(i,l,t));break e}}i=i.return}while(null!==i)}Sc(r)}catch(e){t=e,Pl===r&&null!==r&&(Pl=r=r.return);continue}break}}function mc(){var e=_l.current;return _l.current=Zi,null===e?Zi:e}function gc(){0!==Dl&&3!==Dl&&2!==Dl||(Dl=4),null===Il||!(268435455&Fl)&&!(268435455&Ol)||lc(Il,Tl)}function yc(e,t){var r=Al;Al|=2;var a=mc();for(Il===e&&Tl===t||(Wl=null,hc(e,t));;)try{vc();break}catch(t){pc(e,t)}if(Ro(),Al=r,_l.current=a,null!==Pl)throw Error(n(261));return Il=null,Tl=0,Dl}function vc(){for(;null!==Pl;)wc(Pl)}function bc(){for(;null!==Pl&&!Ye();)wc(Pl)}function wc(e){var t=Cl(e.alternate,e,Ll);e.memoizedProps=e.pendingProps,null===t?Sc(e):Pl=t,Ml.current=null}function Sc(e){var t=e;do{var n=t.alternate;if(e=t.return,32768&t.flags){if(null!==(n=Qs(n,t)))return n.flags&=32767,void(Pl=n);if(null===e)return Dl=6,void(Pl=null);e.flags|=32768,e.subtreeFlags=0,e.deletions=null}else if(null!==(n=Gs(n,t,Ll)))return void(Pl=n);if(null!==(t=t.sibling))return void(Pl=t);Pl=t=e}while(null!==t);0===Dl&&(Dl=5)}function kc(e,t,r){var a=wt,o=Rl.transition;try{Rl.transition=null,wt=1,function(e,t,r,a){do{xc()}while(null!==Ql);if(6&Al)throw Error(n(327));r=e.finishedWork;var o=e.finishedLanes;if(null===r)return null;if(e.finishedWork=null,e.finishedLanes=0,r===e.current)throw Error(n(177));e.callbackNode=null,e.callbackPriority=0;var i=r.lanes|r.childLanes;if(function(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var a=31-st(n),o=1<<a;t[a]=0,r[a]=-1,e[a]=-1,n&=~o}}(e,i),e===Il&&(Pl=Il=null,Tl=0),!(2064&r.subtreeFlags)&&!(2064&r.flags)||Gl||(Gl=!0,Ic(nt,function(){return xc(),null})),i=!!(15990&r.flags),!!(15990&r.subtreeFlags)||i){i=Rl.transition,Rl.transition=null;var s=wt;wt=1;var l=Al;Al|=4,Ml.current=null,function(e,t){if(ta=Ht,pr(e=hr())){if("selectionStart"in e)var r={start:e.selectionStart,end:e.selectionEnd};else e:{var a=(r=(r=e.ownerDocument)&&r.defaultView||window).getSelection&&r.getSelection();if(a&&0!==a.rangeCount){r=a.anchorNode;var o=a.anchorOffset,i=a.focusNode;a=a.focusOffset;try{r.nodeType,i.nodeType}catch(e){r=null;break e}var s=0,l=-1,c=-1,u=0,d=0,f=e,h=null;t:for(;;){for(var p;f!==r||0!==o&&3!==f.nodeType||(l=s+o),f!==i||0!==a&&3!==f.nodeType||(c=s+a),3===f.nodeType&&(s+=f.nodeValue.length),null!==(p=f.firstChild);)h=f,f=p;for(;;){if(f===e)break t;if(h===r&&++u===o&&(l=s),h===i&&++d===a&&(c=s),null!==(p=f.nextSibling))break;h=(f=h).parentNode}f=p}r=-1===l||-1===c?null:{start:l,end:c}}else r=null}r=r||{start:0,end:0}}else r=null;for(na={focusedElem:e,selectionRange:r},Ht=!1,Zs=t;null!==Zs;)if(e=(t=Zs).child,1028&t.subtreeFlags&&null!==e)e.return=t,Zs=e;else for(;null!==Zs;){t=Zs;try{var m=t.alternate;if(1024&t.flags)switch(t.tag){case 0:case 11:case 15:case 5:case 6:case 4:case 17:break;case 1:if(null!==m){var g=m.memoizedProps,y=m.memoizedState,v=t.stateNode,b=v.getSnapshotBeforeUpdate(t.elementType===t.type?g:rs(t.type,g),y);v.__reactInternalSnapshotBeforeUpdate=b}break;case 3:var w=t.stateNode.containerInfo;1===w.nodeType?w.textContent="":9===w.nodeType&&w.documentElement&&w.removeChild(w.documentElement);break;default:throw Error(n(163))}}catch(e){Ec(t,t.return,e)}if(null!==(e=t.sibling)){e.return=t.return,Zs=e;break}Zs=t.return}m=nl,nl=!1}(e,r),yl(r,e),mr(na),Ht=!!ta,na=ta=null,e.current=r,bl(r),Xe(),Al=l,wt=s,Rl.transition=i}else e.current=r;if(Gl&&(Gl=!1,Ql=e,Yl=o),i=e.pendingLanes,0===i&&(ql=null),function(e){if(it&&"function"==typeof it.onCommitFiberRoot)try{it.onCommitFiberRoot(ot,e,void 0,!(128&~e.current.flags))}catch(e){}}(r.stateNode),ac(e,Je()),null!==t)for(a=e.onRecoverableError,r=0;r<t.length;r++)o=t[r],a(o.value,{componentStack:o.stack,digest:o.digest});if(Hl)throw Hl=!1,e=Kl,Kl=null,e;!!(1&Yl)&&0!==e.tag&&xc(),i=e.pendingLanes,1&i?e===Jl?Xl++:(Xl=0,Jl=e):Xl=0,Va()}(e,t,r,a)}finally{Rl.transition=o,wt=a}return null}function xc(){if(null!==Ql){var e=St(Yl),t=Rl.transition,r=wt;try{if(Rl.transition=null,wt=16>e?16:e,null===Ql)var a=!1;else{if(e=Ql,Ql=null,Yl=0,6&Al)throw Error(n(331));var o=Al;for(Al|=4,Zs=e.current;null!==Zs;){var i=Zs,s=i.child;if(16&Zs.flags){var l=i.deletions;if(null!==l){for(var c=0;c<l.length;c++){var u=l[c];for(Zs=u;null!==Zs;){var d=Zs;switch(d.tag){case 0:case 11:case 15:rl(8,d,i)}var f=d.child;if(null!==f)f.return=d,Zs=f;else for(;null!==Zs;){var h=(d=Zs).sibling,p=d.return;if(il(d),d===u){Zs=null;break}if(null!==h){h.return=p,Zs=h;break}Zs=p}}}var m=i.alternate;if(null!==m){var g=m.child;if(null!==g){m.child=null;do{var y=g.sibling;g.sibling=null,g=y}while(null!==g)}}Zs=i}}if(2064&i.subtreeFlags&&null!==s)s.return=i,Zs=s;else e:for(;null!==Zs;){if(2048&(i=Zs).flags)switch(i.tag){case 0:case 11:case 15:rl(9,i,i.return)}var v=i.sibling;if(null!==v){v.return=i.return,Zs=v;break e}Zs=i.return}}var b=e.current;for(Zs=b;null!==Zs;){var w=(s=Zs).child;if(2064&s.subtreeFlags&&null!==w)w.return=s,Zs=w;else e:for(s=b;null!==Zs;){if(2048&(l=Zs).flags)try{switch(l.tag){case 0:case 11:case 15:al(9,l)}}catch(e){Ec(l,l.return,e)}if(l===s){Zs=null;break e}var S=l.sibling;if(null!==S){S.return=l.return,Zs=S;break e}Zs=l.return}}if(Al=o,Va(),it&&"function"==typeof it.onPostCommitFiberRoot)try{it.onPostCommitFiberRoot(ot,e)}catch(e){}a=!0}return a}finally{wt=r,Rl.transition=t}}return!1}function Cc(e,t,n){e=Uo(e,t=ps(0,t=us(n,t),1),1),t=tc(),null!==e&&(vt(e,1,t),ac(e,t))}function Ec(e,t,n){if(3===e.tag)Cc(e,e,n);else for(;null!==t;){if(3===t.tag){Cc(t,e,n);break}if(1===t.tag){var r=t.stateNode;if("function"==typeof t.type.getDerivedStateFromError||"function"==typeof r.componentDidCatch&&(null===ql||!ql.has(r))){t=Uo(t,e=ms(t,e=us(n,e),1),1),e=tc(),null!==t&&(vt(t,1,e),ac(t,e));break}}t=t.return}}function _c(e,t,n){var r=e.pingCache;null!==r&&r.delete(t),t=tc(),e.pingedLanes|=e.suspendedLanes&n,Il===e&&(Tl&n)===n&&(4===Dl||3===Dl&&(130023424&Tl)===Tl&&500>Je()-Bl?hc(e,0):$l|=n),ac(e,t)}function Mc(e,t){0===t&&(1&e.mode?(t=dt,!(130023424&(dt<<=1))&&(dt=4194304)):t=1);var n=tc();null!==(e=zo(e,t))&&(vt(e,t,n),ac(e,n))}function Rc(e){var t=e.memoizedState,n=0;null!==t&&(n=t.retryLane),Mc(e,n)}function Ac(e,t){var r=0;switch(e.tag){case 13:var a=e.stateNode,o=e.memoizedState;null!==o&&(r=o.retryLane);break;case 19:a=e.stateNode;break;default:throw Error(n(314))}null!==a&&a.delete(t),Mc(e,r)}function Ic(e,t){return Ge(e,t)}function Pc(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Tc(e,t,n,r){return new Pc(e,t,n,r)}function Lc(e){return!(!(e=e.prototype)||!e.isReactComponent)}function Nc(e,t){var n=e.alternate;return null===n?((n=Tc(e.tag,t,e.key,e.mode)).elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=14680064&e.flags,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Dc(e,t,r,a,o,i){var s=2;if(a=e,"function"==typeof e)Lc(e)&&(s=1);else if("string"==typeof e)s=5;else e:switch(e){case C:return zc(r.children,o,i,t);case E:s=8,o|=8;break;case _:return(e=Tc(12,r,t,2|o)).elementType=_,e.lanes=i,e;case I:return(e=Tc(13,r,t,o)).elementType=I,e.lanes=i,e;case P:return(e=Tc(19,r,t,o)).elementType=P,e.lanes=i,e;case N:return Fc(r,o,i,t);default:if("object"==typeof e&&null!==e)switch(e.$$typeof){case M:s=10;break e;case R:s=9;break e;case A:s=11;break e;case T:s=14;break e;case L:s=16,a=null;break e}throw Error(n(130,null==e?e:typeof e,""))}return(t=Tc(s,r,t,o)).elementType=e,t.type=a,t.lanes=i,t}function zc(e,t,n,r){return(e=Tc(7,e,r,t)).lanes=n,e}function Fc(e,t,n,r){return(e=Tc(22,e,r,t)).elementType=N,e.lanes=n,e.stateNode={isHidden:!1},e}function Oc(e,t,n){return(e=Tc(6,e,null,t)).lanes=n,e}function $c(e,t,n){return(t=Tc(4,null!==e.children?e.children:[],e.key,t)).lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function jc(e,t,n,r,a){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=yt(0),this.expirationTimes=yt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=yt(0),this.identifierPrefix=r,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function Uc(e,t,n,r,a,o,i,s,l){return e=new jc(e,t,n,s,l),1===t?(t=1,!0===o&&(t|=8)):t=0,o=Tc(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Oo(o),e}function Bc(e){if(!e)return Ra;e:{if(Ve(e=e._reactInternals)!==e||1!==e.tag)throw Error(n(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(La(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(null!==t);throw Error(n(171))}if(1===e.tag){var r=e.type;if(La(r))return za(e,r,t)}return t}function Vc(e,t,n,r,a,o,i,s,l){return(e=Uc(n,r,!0,e,0,o,0,s,l)).context=Bc(null),n=e.current,(o=jo(r=tc(),a=nc(n))).callback=null!=t?t:null,Uo(n,o,a),e.current.lanes=a,vt(e,a,r),ac(e,r),e}function Wc(e,t,n,r){var a=t.current,o=tc(),i=nc(a);return n=Bc(n),null===t.context?t.context=n:t.pendingContext=n,(t=jo(o,i)).payload={element:e},null!==(r=void 0===r?null:r)&&(t.callback=r),null!==(e=Uo(a,t,i))&&(rc(e,a,i,o),Bo(e,a,i)),i}function Hc(e){return(e=e.current).child?(e.child.tag,e.child.stateNode):null}function Kc(e,t){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var n=e.retryLane;e.retryLane=0!==n&&n<t?n:t}}function qc(e,t){Kc(e,t),(e=e.alternate)&&Kc(e,t)}Cl=function(e,t,r){if(null!==e)if(e.memoizedProps!==t.pendingProps||Ia.current)ws=!0;else{if(0===(e.lanes&r)&&!(128&t.flags))return ws=!1,function(e,t,n){switch(t.tag){case 3:Is(t),mo();break;case 5:Zo(t);break;case 1:La(t.type)&&Fa(t);break;case 4:Xo(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,a=t.memoizedProps.value;Ma(Co,r._currentValue),r._currentValue=a;break;case 13:if(null!==(r=t.memoizedState))return null!==r.dehydrated?(Ma(ti,1&ti.current),t.flags|=128,null):0!==(n&t.child.childLanes)?Os(e,t,n):(Ma(ti,1&ti.current),null!==(e=Hs(e,t,n))?e.sibling:null);Ma(ti,1&ti.current);break;case 19:if(r=0!==(n&t.childLanes),128&e.flags){if(r)return Vs(e,t,n);t.flags|=128}if(null!==(a=t.memoizedState)&&(a.rendering=null,a.tail=null,a.lastEffect=null),Ma(ti,ti.current),r)break;return null;case 22:case 23:return t.lanes=0,Es(e,t,n)}return Hs(e,t,n)}(e,t,r);ws=!!(131072&e.flags)}else ws=!1,oo&&1048576&t.flags&&eo(t,qa,t.index);switch(t.lanes=0,t.tag){case 2:var a=t.type;Ws(e,t),e=t.pendingProps;var o=Ta(t,Aa.current);Po(t,r),o=yi(null,t,a,e,o,r);var i=vi();return t.flags|=1,"object"==typeof o&&null!==o&&"function"==typeof o.render&&void 0===o.$$typeof?(t.tag=1,t.memoizedState=null,t.updateQueue=null,La(a)?(i=!0,Fa(t)):i=!1,t.memoizedState=null!==o.state&&void 0!==o.state?o.state:null,Oo(t),o.updater=os,t.stateNode=o,o._reactInternals=t,cs(t,a,e,r),t=As(null,t,a,!0,i,r)):(t.tag=0,oo&&i&&to(t),Ss(null,t,o,r),t=t.child),t;case 16:a=t.elementType;e:{switch(Ws(e,t),e=t.pendingProps,a=(o=a._init)(a._payload),t.type=a,o=t.tag=function(e){if("function"==typeof e)return Lc(e)?1:0;if(null!=e){if((e=e.$$typeof)===A)return 11;if(e===T)return 14}return 2}(a),e=rs(a,e),o){case 0:t=Ms(null,t,a,e,r);break e;case 1:t=Rs(null,t,a,e,r);break e;case 11:t=ks(null,t,a,e,r);break e;case 14:t=xs(null,t,a,rs(a.type,e),r);break e}throw Error(n(306,a,""))}return t;case 0:return a=t.type,o=t.pendingProps,Ms(e,t,a,o=t.elementType===a?o:rs(a,o),r);case 1:return a=t.type,o=t.pendingProps,Rs(e,t,a,o=t.elementType===a?o:rs(a,o),r);case 3:e:{if(Is(t),null===e)throw Error(n(387));a=t.pendingProps,o=(i=t.memoizedState).element,$o(e,t),Wo(t,a,null,r);var s=t.memoizedState;if(a=s.element,i.isDehydrated){if(i={element:a,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=i,t.memoizedState=i,256&t.flags){t=Ps(e,t,a,r,o=us(Error(n(423)),t));break e}if(a!==o){t=Ps(e,t,a,r,o=us(Error(n(424)),t));break e}for(ao=ua(t.stateNode.containerInfo.firstChild),ro=t,oo=!0,io=null,r=xo(t,null,a,r),t.child=r;r;)r.flags=-3&r.flags|4096,r=r.sibling}else{if(mo(),a===o){t=Hs(e,t,r);break e}Ss(e,t,a,r)}t=t.child}return t;case 5:return Zo(t),null===e&&uo(t),a=t.type,o=t.pendingProps,i=null!==e?e.memoizedProps:null,s=o.children,ra(a,o)?s=null:null!==i&&ra(a,i)&&(t.flags|=32),_s(e,t),Ss(e,t,s,r),t.child;case 6:return null===e&&uo(t),null;case 13:return Os(e,t,r);case 4:return Xo(t,t.stateNode.containerInfo),a=t.pendingProps,null===e?t.child=ko(t,null,a,r):Ss(e,t,a,r),t.child;case 11:return a=t.type,o=t.pendingProps,ks(e,t,a,o=t.elementType===a?o:rs(a,o),r);case 7:return Ss(e,t,t.pendingProps,r),t.child;case 8:case 12:return Ss(e,t,t.pendingProps.children,r),t.child;case 10:e:{if(a=t.type._context,o=t.pendingProps,i=t.memoizedProps,s=o.value,Ma(Co,a._currentValue),a._currentValue=s,null!==i)if(lr(i.value,s)){if(i.children===o.children&&!Ia.current){t=Hs(e,t,r);break e}}else for(null!==(i=t.child)&&(i.return=t);null!==i;){var l=i.dependencies;if(null!==l){s=i.child;for(var c=l.firstContext;null!==c;){if(c.context===a){if(1===i.tag){(c=jo(-1,r&-r)).tag=2;var u=i.updateQueue;if(null!==u){var d=(u=u.shared).pending;null===d?c.next=c:(c.next=d.next,d.next=c),u.pending=c}}i.lanes|=r,null!==(c=i.alternate)&&(c.lanes|=r),Io(i.return,r,t),l.lanes|=r;break}c=c.next}}else if(10===i.tag)s=i.type===t.type?null:i.child;else if(18===i.tag){if(null===(s=i.return))throw Error(n(341));s.lanes|=r,null!==(l=s.alternate)&&(l.lanes|=r),Io(s,r,t),s=i.sibling}else s=i.child;if(null!==s)s.return=i;else for(s=i;null!==s;){if(s===t){s=null;break}if(null!==(i=s.sibling)){i.return=s.return,s=i;break}s=s.return}i=s}Ss(e,t,o.children,r),t=t.child}return t;case 9:return o=t.type,a=t.pendingProps.children,Po(t,r),a=a(o=To(o)),t.flags|=1,Ss(e,t,a,r),t.child;case 14:return o=rs(a=t.type,t.pendingProps),xs(e,t,a,o=rs(a.type,o),r);case 15:return Cs(e,t,t.type,t.pendingProps,r);case 17:return a=t.type,o=t.pendingProps,o=t.elementType===a?o:rs(a,o),Ws(e,t),t.tag=1,La(a)?(e=!0,Fa(t)):e=!1,Po(t,r),ss(t,a,o),cs(t,a,o,r),As(null,t,a,!0,e,r);case 19:return Vs(e,t,r);case 22:return Es(e,t,r)}throw Error(n(156,t.tag))};var Gc="function"==typeof reportError?reportError:function(e){console.error(e)};function Qc(e){this._internalRoot=e}function Yc(e){this._internalRoot=e}function Xc(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType)}function Jc(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType&&(8!==e.nodeType||" react-mount-point-unstable "!==e.nodeValue))}function Zc(){}function eu(e,t,n,r,a){var o=n._reactRootContainer;if(o){var i=o;if("function"==typeof a){var s=a;a=function(){var e=Hc(i);s.call(e)}}Wc(t,i,e,a)}else i=function(e,t,n,r,a){if(a){if("function"==typeof r){var o=r;r=function(){var e=Hc(i);o.call(e)}}var i=Vc(t,r,e,0,null,!1,0,"",Zc);return e._reactRootContainer=i,e[ma]=i.current,Vr(8===e.nodeType?e.parentNode:e),dc(),i}for(;a=e.lastChild;)e.removeChild(a);if("function"==typeof r){var s=r;r=function(){var e=Hc(l);s.call(e)}}var l=Uc(e,0,!1,null,0,!1,0,"",Zc);return e._reactRootContainer=l,e[ma]=l.current,Vr(8===e.nodeType?e.parentNode:e),dc(function(){Wc(t,l,n,r)}),l}(n,t,e,a,r);return Hc(i)}Yc.prototype.render=Qc.prototype.render=function(e){var t=this._internalRoot;if(null===t)throw Error(n(409));Wc(e,t,null,null)},Yc.prototype.unmount=Qc.prototype.unmount=function(){var e=this._internalRoot;if(null!==e){this._internalRoot=null;var t=e.containerInfo;dc(function(){Wc(null,e,null,null)}),t[ma]=null}},Yc.prototype.unstable_scheduleHydration=function(e){if(e){var t=Et();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Nt.length&&0!==t&&t<Nt[n].priority;n++);Nt.splice(n,0,e),0===n&&Ot(e)}},kt=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=ft(t.pendingLanes);0!==n&&(bt(t,1|n),ac(t,Je()),!(6&Al)&&(Vl=Je()+500,Va()))}break;case 13:dc(function(){var t=zo(e,1);if(null!==t){var n=tc();rc(t,e,1,n)}}),qc(e,1)}},xt=function(e){if(13===e.tag){var t=zo(e,134217728);if(null!==t)rc(t,e,134217728,tc());qc(e,134217728)}},Ct=function(e){if(13===e.tag){var t=nc(e),n=zo(e,t);if(null!==n)rc(n,e,t,tc());qc(e,t)}},Et=function(){return wt},_t=function(e,t){var n=wt;try{return wt=e,t()}finally{wt=n}},xe=function(e,t,r){switch(t){case"input":if(Z(e,r),t=r.name,"radio"===r.type&&null!=t){for(r=e;r.parentNode;)r=r.parentNode;for(r=r.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<r.length;t++){var a=r[t];if(a!==e&&a.form===e.form){var o=ka(a);if(!o)throw Error(n(90));G(a),Z(a,o)}}}break;case"textarea":ie(e,r);break;case"select":null!=(t=r.value)&&re(e,!!r.multiple,t,!1)}},Ae=uc,Ie=dc;var tu={usingClientEntryPoint:!1,Events:[wa,Sa,ka,Me,Re,uc]},nu={findFiberByHostInstance:ba,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},ru={bundleType:nu.bundleType,version:nu.version,rendererPackageName:nu.rendererPackageName,rendererConfig:nu.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:w.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return null===(e=Ke(e))?null:e.stateNode},findFiberByHostInstance:nu.findFiberByHostInstance||function(){return null},findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__){var au=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!au.isDisabled&&au.supportsFiber)try{ot=au.inject(ru),it=au}catch(de){}}return v.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=tu,v.createPortal=function(e,t){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;if(!Xc(t))throw Error(n(200));return function(e,t,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return{$$typeof:x,key:null==r?null:""+r,children:e,containerInfo:t,implementation:n}}(e,t,null,r)},v.createRoot=function(e,t){if(!Xc(e))throw Error(n(299));var r=!1,a="",o=Gc;return null!=t&&(!0===t.unstable_strictMode&&(r=!0),void 0!==t.identifierPrefix&&(a=t.identifierPrefix),void 0!==t.onRecoverableError&&(o=t.onRecoverableError)),t=Uc(e,1,!1,null,0,r,0,a,o),e[ma]=t.current,Vr(8===e.nodeType?e.parentNode:e),new Qc(t)},v.findDOMNode=function(e){if(null==e)return null;if(1===e.nodeType)return e;var t=e._reactInternals;if(void 0===t){if("function"==typeof e.render)throw Error(n(188));throw e=Object.keys(e).join(","),Error(n(268,e))}return e=null===(e=Ke(t))?null:e.stateNode},v.flushSync=function(e){return dc(e)},v.hydrate=function(e,t,r){if(!Jc(t))throw Error(n(200));return eu(null,e,t,!0,r)},v.hydrateRoot=function(e,t,r){if(!Xc(e))throw Error(n(405));var a=null!=r&&r.hydratedSources||null,o=!1,i="",s=Gc;if(null!=r&&(!0===r.unstable_strictMode&&(o=!0),void 0!==r.identifierPrefix&&(i=r.identifierPrefix),void 0!==r.onRecoverableError&&(s=r.onRecoverableError)),t=Vc(t,null,e,1,null!=r?r:null,o,0,i,s),e[ma]=t.current,Vr(e),a)for(e=0;e<a.length;e++)o=(o=(r=a[e])._getVersion)(r._source),null==t.mutableSourceEagerHydrationData?t.mutableSourceEagerHydrationData=[r,o]:t.mutableSourceEagerHydrationData.push(r,o);return new Yc(t)},v.render=function(e,t,r){if(!Jc(t))throw Error(n(200));return eu(null,e,t,!1,r)},v.unmountComponentAtNode=function(e){if(!Jc(e))throw Error(n(40));return!!e._reactRootContainer&&(dc(function(){eu(null,null,e,!1,function(){e._reactRootContainer=null,e[ma]=null})}),!0)},v.unstable_batchedUpdates=uc,v.unstable_renderSubtreeIntoContainer=function(e,t,r,a){if(!Jc(r))throw Error(n(200));if(null==e||void 0===e._reactInternals)throw Error(n(38));return eu(e,t,r,!1,a)},v.version="18.3.1-next-f1338f8080-20240426",v}var x,C,E=function(){if(h)return g;h=1;var e=(f||(f=1,function e(){if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(e){console.error(e)}}(),y.exports=k()),y.exports);return g.createRoot=e.createRoot,g.hydrateRoot=e.hydrateRoot,g}(),_={exports:{}},M={};var R=(C||(C=1,_.exports=function(){if(x)return M;x=1;var e=l(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,a=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function i(e,n,i){var s,l={},c=null,u=null;for(s in void 0!==i&&(c=""+i),void 0!==n.key&&(c=""+n.key),void 0!==n.ref&&(u=n.ref),n)r.call(n,s)&&!o.hasOwnProperty(s)&&(l[s]=n[s]);if(e&&e.defaultProps)for(s in n=e.defaultProps)void 0===l[s]&&(l[s]=n[s]);return{$$typeof:t,type:e,key:c,ref:u,props:l,_owner:a.current}}return M.Fragment=n,M.jsx=i,M.jsxs=i,M}()),_.exports);function A(e){return{title:e.title||e.heading||"Document",snippet:e.content||"",relevance:e.score??0,documentId:e.documentId,fullContent:e.fullContent,downloadUrl:e.downloadUrl,documentName:e.documentName,sourceType:e.sourceType,chunkId:e.chunkId}}class I{constructor(e,t){this.baseUrl=e.replace(/\/$/,""),this.apiKey=t}async chat(e,t){const n=await fetch(`${this.baseUrl}/api/external/chat`,{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.apiKey},body:JSON.stringify({message:e,sessionId:t?.sessionId,context:t?.context})});if(!n.ok){const e=await n.json().catch(()=>({}));throw new Error(e.message||`HTTP ${n.status}: ${n.statusText}`)}const r=await n.json();return{...r,reply:r.reply||r.answer||"",sources:(r.sources||[]).map(A)}}async chatStream(e,t){const n=await fetch(`${this.baseUrl}/api/external/chat/stream`,{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.apiKey},body:JSON.stringify({message:e,sessionId:t?.sessionId,context:t?.context})});if(!n.ok){const e=await n.json().catch(()=>({}));throw new Error(e.message||`HTTP ${n.status}`)}const r=n.body?.getReader();if(!r)throw new Error("Streaming not supported");const a=new TextDecoder;let o,i,s="",l="",c=[];try{for(;;){const{done:e,value:n}=await r.read();if(e)break;s+=a.decode(n,{stream:!0});const u=s.split("\n");s=u.pop()||"";for(const e of u)if(e.startsWith("event: "));else if(e.startsWith("data: "))try{const n=JSON.parse(e.slice(6));void 0!==n.text?(l+=n.text,t.onToken?.(n.text)):void 0!==n.sources?(c=(n.sources||[]).map(A),t.onSources?.(c)):void 0!==n.sessionId&&(o=n.sessionId,i=n.messageId)}catch{}}t.onComplete?.({fullText:l,sessionId:o,messageId:i,sources:c})}catch(e){t.onError?.(e)}}async getGeneralDocs(e){const t=new URLSearchParams;e&&t.set("since",e);const n=`${this.baseUrl}/api/external/docs${t.toString()?"?"+t:""}`,r=await fetch(n,{headers:{"X-API-Key":this.apiKey}});if(!r.ok)throw new Error(`HTTP ${r.status}`);return((await r.json()).documents||[]).map(e=>({id:e.id,title:e.title||e.name||"Untitled",updatedAt:e.updatedAt||e.updated_at||(new Date).toISOString()}))}async getStatus(){const e=await fetch(`${this.baseUrl}/api/external/status`,{headers:{"X-API-Key":this.apiKey}});if(!e.ok)throw new Error(`HTTP ${e.status}`);const t=await e.json(),n=t.apiKey||t.key||{},r=n.scopes||n.permissions||["chat"],a=t.quota||{},o=a.perMinute||{limit:n.rateLimit?.limit||a.rateLimitPerMinute||30,remaining:n.rateLimit?.remaining??a.rateLimitPerMinute??30},i=a.perDay||{limit:a.rateLimitPerDay||60*o.limit*24,remaining:a.rateLimitPerDay||60*o.limit*24},s=t.systemSettings||t.system||{},l=s.cacheRetentionHours??(s.cacheRetentionDays?24*s.cacheRetentionDays:void 0);return{status:t.status||"active",apiKey:{id:n.id||"",scopes:r},quota:{perMinute:o,perDay:i},systemSettings:{cacheRetentionHours:l??720,maintenanceMode:s.maintenanceMode??!1,maintenanceMessage:s.maintenanceMessage,forceOfflineClients:s.forceOfflineClients??!1}}}async health(){const e=await fetch(`${this.baseUrl}/api/external/health`);if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}}class P{constructor(e,t){this.baseUrl=e.replace(/\/$/,""),this.apiKey=t}async initVisitor(e,t,n,r){return this.post("visitor/init",{visitorId:e,pageUrl:t,referrer:n,utmParams:r})}async trackPageView(e,t,n,r,a){return this.post("visitor/pageview",{visitorId:e,url:t,title:n,timeOnPageMs:r,scrollDepth:a})}async identifyVisitor(e,t){return this.post("visitor/identify",{visitorId:e,...t})}async salesChat(e,t={}){return this.post("chat",{message:e,...t})}async captureLeadForm(e){return this.post("lead/capture",e)}async post(e,t){const n=`${this.baseUrl}/api/external/sales/${e}`,r=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json","X-Api-Key":this.apiKey},body:JSON.stringify(t)});if(!r.ok){const e=await r.json().catch(()=>({error:"Unknown error"}));throw new Error(e.error||`Sales API error: ${r.status}`)}return r.json()}}let T,L;const N=new WeakMap,D=new WeakMap,z=new WeakMap,F=new WeakMap,O=new WeakMap;let $={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return D.get(e);if("objectStoreNames"===t)return e.objectStoreNames||z.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return B(e[t])},set:(e,t,n)=>(e[t]=n,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function j(e){return e!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(L||(L=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(V(this),t),B(N.get(this))}:function(...t){return B(e.apply(V(this),t))}:function(t,...n){const r=e.call(V(this),t,...n);return z.set(r,t.sort?t.sort():[t]),B(r)}}function U(e){return"function"==typeof e?j(e):(e instanceof IDBTransaction&&function(e){if(D.has(e))return;const t=new Promise((t,n)=>{const r=()=>{e.removeEventListener("complete",a),e.removeEventListener("error",o),e.removeEventListener("abort",o)},a=()=>{t(),r()},o=()=>{n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",a),e.addEventListener("error",o),e.addEventListener("abort",o)});D.set(e,t)}(e),t=e,(T||(T=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])).some(e=>t instanceof e)?new Proxy(e,$):e);var t}function B(e){if(e instanceof IDBRequest)return function(e){const t=new Promise((t,n)=>{const r=()=>{e.removeEventListener("success",a),e.removeEventListener("error",o)},a=()=>{t(B(e.result)),r()},o=()=>{n(e.error),r()};e.addEventListener("success",a),e.addEventListener("error",o)});return t.then(t=>{t instanceof IDBCursor&&N.set(t,e)}).catch(()=>{}),O.set(t,e),t}(e);if(F.has(e))return F.get(e);const t=U(e);return t!==e&&(F.set(e,t),O.set(t,e)),t}const V=e=>O.get(e);function W(e,t,{blocked:n,upgrade:r,blocking:a,terminated:o}={}){const i=indexedDB.open(e,t),s=B(i);return r&&i.addEventListener("upgradeneeded",e=>{r(B(i.result),e.oldVersion,e.newVersion,B(i.transaction),e)}),n&&i.addEventListener("blocked",e=>n(e.oldVersion,e.newVersion,e)),s.then(e=>{o&&e.addEventListener("close",()=>o()),a&&e.addEventListener("versionchange",e=>a(e.oldVersion,e.newVersion,e))}).catch(()=>{}),s}const H=["get","getKey","getAll","getAllKeys","count"],K=["put","add","delete","clear"],q=new Map;function G(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(q.get(t))return q.get(t);const n=t.replace(/FromIndex$/,""),r=t!==n,a=K.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!a&&!H.includes(n))return;const o=async function(e,...t){const o=this.transaction(e,a?"readwrite":"readonly");let i=o.store;return r&&(i=i.index(t.shift())),(await Promise.all([i[n](...t),a&&o.done]))[0]};return q.set(t,o),o}$=(e=>({...e,get:(t,n,r)=>G(t,n)||e.get(t,n,r),has:(t,n)=>!!G(t,n)||e.has(t,n)}))($);class Q{constructor(e){this.db=null,this.dbPromise=null,this.documentCount=0,this.lastSyncAt=null,this.config=e,"indexeddb"===e.storage&&"undefined"!=typeof indexedDB?this.dbPromise=this.initDB():"localstorage"===e.storage&&this.loadLocalStorageMetadata()}loadLocalStorageMetadata(){try{const e=localStorage.getItem("cybernetic-cache-meta");if(e){const t=JSON.parse(e);this.documentCount=t.documentCount||0,this.lastSyncAt=t.lastSyncAt||null}}catch{}}async initDB(){return this.db=await W("cybernetic-cache",1,{upgrade(e){if(!e.objectStoreNames.contains("documents")){e.createObjectStore("documents",{keyPath:"id"}).createIndex("by-updated","updatedAt")}e.objectStoreNames.contains("metadata")||e.createObjectStore("metadata",{keyPath:"key"})}}),await this.loadMetadata(),this.db}async getDB(){if(this.db)return this.db;if(this.dbPromise)return this.dbPromise;throw new Error("Database not available")}async loadMetadata(){if(!this.db)return;const e=await this.db.get("metadata","documentCount");this.documentCount=e?.value||0;const t=await this.db.get("metadata","lastSyncAt");this.lastSyncAt=t?.value||null}async store(e){if("localstorage"===this.config.storage)return this.storeLocalStorage(e);const t=(await this.getDB()).transaction(["documents","metadata"],"readwrite");for(const n of e)await t.objectStore("documents").put(n);this.documentCount=await t.objectStore("documents").count(),this.lastSyncAt=(new Date).toISOString(),await t.objectStore("metadata").put({key:"documentCount",value:this.documentCount}),await t.objectStore("metadata").put({key:"lastSyncAt",value:this.lastSyncAt}),await t.done}async retrieve(){if("localstorage"===this.config.storage)return this.retrieveLocalStorage();return(await this.getDB()).getAll("documents")}async getLastSync(){return this.lastSyncAt}getStatus(){const e=Date.now()-(this.lastSyncAt?new Date(this.lastSyncAt).getTime():0)>this.config.maxAge;return{documentCount:this.documentCount,lastSyncAt:this.lastSyncAt,cacheSize:5e3*this.documentCount,isStale:e}}async clear(){if("localstorage"===this.config.storage)return localStorage.removeItem("cybernetic-cache-docs"),localStorage.removeItem("cybernetic-cache-meta"),this.documentCount=0,void(this.lastSyncAt=null);const e=(await this.getDB()).transaction(["documents","metadata"],"readwrite");await e.objectStore("documents").clear(),await e.objectStore("metadata").clear(),await e.done,this.documentCount=0,this.lastSyncAt=null}storeLocalStorage(e){try{localStorage.setItem("cybernetic-cache-docs",JSON.stringify(e)),this.documentCount=e.length,this.lastSyncAt=(new Date).toISOString(),localStorage.setItem("cybernetic-cache-meta",JSON.stringify({documentCount:this.documentCount,lastSyncAt:this.lastSyncAt}))}catch{localStorage.removeItem("cybernetic-cache-docs");const t=e.slice(0,50);localStorage.setItem("cybernetic-cache-docs",JSON.stringify(t)),this.documentCount=t.length}}retrieveLocalStorage(){try{const e=localStorage.getItem("cybernetic-cache-docs");return e?JSON.parse(e):[]}catch{return[]}}}class Y{constructor(){this.documents=[],this.idf=new Map,this.indexed=!1,this.loadedFromExport=!1,this.vocabulary=new Map}isIndexed(){return this.indexed&&this.documents.length>0}async index(e){this.documents=[],this.idf=new Map;const t=new Map;for(const n of e){if(!n.content)continue;const e=this.tokenize(n.content),r=new Set(e);for(const e of r)t.set(e,(t.get(e)||0)+1);this.documents.push({id:n.id,title:n.title,content:n.content,tokens:e,tfidf:new Map})}const n=e.length;for(const[e,r]of t)this.idf.set(e,Math.log((n+1)/(r+1))+1);for(const e of this.documents){const t=this.computeTermFrequency(e.tokens);for(const[n,r]of t){const t=this.idf.get(n)||1;e.tfidf.set(n,r*t)}}this.indexed=!0}async ask(e){if(!this.indexed||0===this.documents.length)return{answer:"I don't have any information available offline.",sources:[],topScore:0};const t=this.tokenize(e),n=this.computeTermFrequency(t),r=new Map;for(const[e,t]of n){const n=this.idf.get(e)||1;r.set(e,t*n)}const a=this.documents.map(e=>({doc:e,score:this.cosineSimilarity(r,e.tfidf)}));a.sort((e,t)=>t.score-e.score);const o=a.slice(0,3).filter(e=>e.score>.1);if(0===o.length)return{answer:"I couldn't find relevant information for your question in my offline data.",sources:[],topScore:a[0]?.score||0};const i=o[0].doc;return{answer:this.extractRelevantSnippet(i.content,t),sources:o.map(e=>({title:e.doc.title,snippet:e.doc.content.substring(0,200)+"...",score:e.score})),topScore:o[0].score}}reset(){this.documents=[],this.idf=new Map,this.vocabulary=new Map,this.indexed=!1,this.loadedFromExport=!1,this.exportVersion=void 0,this.exportedAt=void 0}async loadFromExport(e){this.reset(),this.idf=new Map(Object.entries(e.tfidfIndex.idf));let t=0;for(const e of this.idf.keys())this.vocabulary.set(e,t++);for(const t of e.documents){const e=new Map;for(const[n,r]of t.tfidfVector)for(const[t,a]of this.vocabulary)if(a===n){e.set(t,r);break}this.documents.push({id:t.id,title:t.title,content:t.content,tokens:[],tfidf:e})}this.indexed=!0,this.loadedFromExport=!0,this.exportVersion=e.version,this.exportedAt=e.meta.exportedAt,console.log(`[CyberneticLocalRAG] Loaded ${this.documents.length} documents from export (v${e.version})`)}getExportStatus(){return{loaded:this.indexed,loadedFromExport:this.loadedFromExport,documentCount:this.documents.length,chunkCount:this.documents.length,exportVersion:this.exportVersion,exportedAt:this.exportedAt}}tokenize(e){return e&&"string"==typeof e?e.toLowerCase().replace(/[^\w\s]/g," ").split(/\s+/).filter(e=>e.length>2&&!this.isStopWord(e)):[]}computeTermFrequency(e){const t=new Map;for(const n of e)t.set(n,(t.get(n)||0)+1);const n=Math.max(...t.values());if(n>0)for(const[e,r]of t)t.set(e,r/n);return t}cosineSimilarity(e,t){let n=0,r=0,a=0;for(const[a,o]of e){n+=o*(t.get(a)||0),r+=o*o}for(const e of t.values())a+=e*e;return 0===r||0===a?0:n/(Math.sqrt(r)*Math.sqrt(a))}extractRelevantSnippet(e,t){const n=e.split(/[.!?]+/).filter(e=>e.trim().length>0).map(e=>{const n=new Set(this.tokenize(e));let r=0;for(const e of t)n.has(e)&&r++;return{sentence:e.trim(),score:r}});n.sort((e,t)=>t.score-e.score);const r=n.slice(0,3).filter(e=>e.score>0);return 0===r.length?e.substring(0,300)+"...":r.map(e=>e.sentence).join(". ")+"."}isStopWord(e){return new Set(["the","a","an","and","or","but","in","on","at","to","for","of","with","by","from","up","about","into","through","during","is","are","was","were","be","been","being","have","has","had","do","does","did","will","would","could","should","may","might","this","that","these","those","it","its","they","them","their","what","which","who","whom","when","where","why","how","all","each","every","both","few","more","most","other","some","such","no","not","only","same","so","than","too","very"]).has(e)}}class X{constructor(){this.db=null,this.dbPromise=null,this.dbName="cybernetic-offline-vectors",this.dbVersion=1}async initDB(){return this.db?this.db:this.dbPromise?this.dbPromise:(this.dbPromise=W(this.dbName,this.dbVersion,{upgrade(e){e.objectStoreNames.contains("vectors")||e.createObjectStore("vectors",{keyPath:"id"})}}),this.db=await this.dbPromise,this.db)}async store(e,t){const n=await this.getDB();await n.put("vectors",{id:e,exportVersion:t.version,exportedAt:t.meta.exportedAt,type:t.type,data:t}),console.log(`[CyberneticOfflineStorage] Stored ${t.meta.chunkCount} chunks`)}async retrieve(e){const t=await this.getDB(),n=await t.get("vectors",e);return n?.data??null}async isValid(e,t){const n=await this.getDB(),r=await n.get("vectors",e);if(!r)return!1;const a=new Date(r.exportedAt).getTime();return Date.now()-a<t}async getMeta(e){const t=await this.getDB(),n=await t.get("vectors",e);return n?{version:n.exportVersion,exportedAt:n.exportedAt,documentCount:n.data.meta.documentCount,chunkCount:n.data.meta.chunkCount,type:n.type}:null}async hasData(){const e=await this.getDB();return await e.count("vectors")>0}async getStoredIds(){return(await this.getDB()).getAllKeys("vectors")}async delete(e){const t=await this.getDB();await t.delete("vectors",e)}async clear(){const e=await this.getDB();await e.clear("vectors"),console.log("[CyberneticOfflineStorage] Cache cleared")}async getDB(){return this.db?this.db:this.initDB()}close(){this.db&&(this.db.close(),this.db=null,this.dbPromise=null)}}class J{constructor(e,t,n){this.ws=null,this.state="disconnected",this.reconnectAttempts=0,this.connectionPromise=null,this.activeCallbacks=null,this.activeFullText="",this.beforeUnloadHandler=null,this._resolveStream=null,this._rejectStream=null,this.wsUrl=e,this.apiKey=t,this.maxReconnectAttempts=n?.maxReconnectAttempts??3,this.reconnectDelay=n?.reconnectDelay??1e3,this.connectionTimeout=n?.connectionTimeout??1e4}getState(){return this.state}isConnected(){return"connected"===this.state&&this.ws?.readyState===WebSocket.OPEN}connect(){return this.isConnected()?Promise.resolve():(this.connectionPromise||(this.state="connecting",this.connectionPromise=new Promise((e,t)=>{try{const n=this.wsUrl.includes("?")?"&":"?",r=`${this.wsUrl}${n}apiKey=${encodeURIComponent(this.apiKey)}`,a=new WebSocket(r);this.ws=a;const o=setTimeout(()=>{a.readyState!==WebSocket.OPEN&&(a.close(),this.state="error",this.connectionPromise=null,t(new Error("WebSocket connection timed out")))},this.connectionTimeout);a.onopen=()=>{clearTimeout(o),this.state="connected",this.reconnectAttempts=0,this.connectionPromise=null,this.registerCleanup(),e()},a.onmessage=e=>{this.handleMessage(e)},a.onerror=()=>{clearTimeout(o),this.state="error",this.connectionPromise=null},a.onclose=e=>{clearTimeout(o);const n="connected"===this.state;this.state="disconnected",this.connectionPromise=null,this.unregisterCleanup(),this.activeCallbacks&&(this.activeCallbacks.onError?.({code:"WS_ERROR",message:e.reason||`WebSocket closed (code: ${e.code})`}),this.clearActiveRequest()),n||t(new Error(e.reason||`WebSocket closed (code: ${e.code})`))}}catch(e){this.state="error",this.connectionPromise=null,t(e)}})),this.connectionPromise)}async chatStream(e,t){const{sessionId:n,context:r,wordLimit:a,onToken:o,onSources:i,onComplete:s,onError:l}=t;try{await this.connect()}catch(e){throw l?.({code:"WS_ERROR",message:`Failed to connect: ${e instanceof Error?e.message:String(e)}`}),e}if(!this.ws||this.ws.readyState!==WebSocket.OPEN){const e={code:"WS_ERROR",message:"WebSocket not connected"};throw l?.(e),new Error(e.message)}this.activeCallbacks={onToken:o,onSources:i,onComplete:s,onError:l},this.activeFullText="",this.activeSessionId=n;const c={type:"sendMessage",message:e};return n&&(c.sessionId=n),a&&(c.wordLimit=a),r&&(c.context=r),new Promise((e,t)=>{this._resolveStream=e,this._rejectStream=t,this.ws.send(JSON.stringify(c))})}disconnect(){this.unregisterCleanup(),this.ws&&(this.ws.onclose=null,this.ws.onerror=null,this.ws.onmessage=null,this.ws.close(),this.ws=null),this.state="disconnected",this.connectionPromise=null,this.clearActiveRequest()}async reconnect(){if(this.reconnectAttempts>=this.maxReconnectAttempts)throw this.state="error",new Error(`Max reconnection attempts (${this.maxReconnectAttempts}) exceeded`);const e=this.reconnectDelay*Math.pow(2,this.reconnectAttempts);return this.reconnectAttempts++,console.log(`[Cybernetic WS] Reconnecting in ${e}ms (attempt ${this.reconnectAttempts}/${this.maxReconnectAttempts})`),await new Promise(t=>setTimeout(t,e)),this.ws&&(this.ws.onclose=null,this.ws.onerror=null,this.ws.close(),this.ws=null),this.connect()}handleMessage(e){if(this.activeCallbacks)try{const t=JSON.parse(e.data);switch(t.type){case"typing":break;case"chunk":t.content&&(this.activeFullText+=t.content,this.activeCallbacks.onToken?.(t.content));break;case"done":{const e=this.mapSources(t.sources||[]);this.activeCallbacks.onSources?.(e);const n={reply:this.activeFullText,confidence:"high",sources:e,offline:!1,sessionId:t.sessionId||this.activeSessionId};this.activeCallbacks.onComplete?.(n),this._resolveStream?.(),this.clearActiveRequest();break}case"error":{const e={code:"WS_ERROR",message:t.error||"Unknown WebSocket error"};this.activeCallbacks.onError?.(e),this._rejectStream?.(new Error(e.message)),this.clearActiveRequest();break}default:console.warn("[Cybernetic WS] Unknown message type:",t.type)}}catch(t){console.error("[Cybernetic WS] Failed to parse message:",t,e.data)}}mapSources(e){return Array.isArray(e)?e.map(e=>({title:e.title||e.heading||e.documentName||"Document",snippet:e.content||"",relevance:e.score??0,documentId:e.documentId,documentName:e.documentName,sourceType:e.sourceType||"document",chunkId:e.chunkId,downloadUrl:e.downloadUrl})):[]}clearActiveRequest(){this.activeCallbacks=null,this.activeFullText="",this._resolveStream=null,this._rejectStream=null}registerCleanup(){"undefined"==typeof window||this.beforeUnloadHandler||(this.beforeUnloadHandler=()=>this.disconnect(),window.addEventListener("beforeunload",this.beforeUnloadHandler))}unregisterCleanup(){"undefined"!=typeof window&&this.beforeUnloadHandler&&(window.removeEventListener("beforeunload",this.beforeUnloadHandler),this.beforeUnloadHandler=null)}}const Z={enabled:!0,storageKey:"astermind_session",sessionTtl:18e5,persistMessages:!0,maxMessages:50};class ee{constructor(e){this.cachedSession=null,this.config={...Z,...e},this.config.enabled&&this.isAvailable()&&(this.cachedSession=this.loadFromStorage())}isAvailable(){if("undefined"==typeof window)return!1;try{const e="__astermind_test__";return window.sessionStorage.setItem(e,"test"),window.sessionStorage.removeItem(e),!0}catch{return!1}}getSessionId(){if(!this.config.enabled)return null;const e=this.getSession();return e?.sessionId??null}getSession(){if(!this.config.enabled)return null;if(this.cachedSession)return this.isSessionValid(this.cachedSession)?this.cachedSession:(this.clear(),null);const e=this.loadFromStorage();return e&&this.isSessionValid(e)?(this.cachedSession=e,e):null}saveSessionId(e){if(!this.config.enabled||!e)return;const t=this.getSession(),n={sessionId:e,updatedAt:Date.now(),messages:t?.messages??[]};this.saveToStorage(n),this.cachedSession=n}addMessage(e){if(!this.config.enabled||!this.config.persistMessages)return;const t=this.getSession();if(!t)return;const n={...e,id:this.generateMessageId(),timestamp:Date.now()};t.messages=t.messages??[],t.messages.push(n),t.messages.length>this.config.maxMessages&&(t.messages=t.messages.slice(-this.config.maxMessages)),t.updatedAt=Date.now(),this.saveToStorage(t),this.cachedSession=t}getMessages(){if(!this.config.enabled||!this.config.persistMessages)return[];const e=this.getSession();return e?.messages??[]}clear(){if(this.cachedSession=null,this.isAvailable())try{window.sessionStorage.removeItem(this.config.storageKey)}catch(e){console.warn("[CyberneticSessionStorage] Failed to clear session:",e)}}startNewSession(e){this.clear(),e&&this.saveSessionId(e)}hasValidSession(){return null!==this.getSession()}getSessionInfo(){const e=this.getSession();if(!e)return{hasSession:!1,sessionId:null,messageCount:0,lastUpdated:null,ttlRemaining:null};const t=Math.max(0,this.config.sessionTtl-(Date.now()-e.updatedAt));return{hasSession:!0,sessionId:e.sessionId,messageCount:e.messages?.length??0,lastUpdated:new Date(e.updatedAt),ttlRemaining:t}}isSessionValid(e){return Date.now()-e.updatedAt<this.config.sessionTtl}loadFromStorage(){if(!this.isAvailable())return null;try{const e=window.sessionStorage.getItem(this.config.storageKey);if(!e)return null;const t=JSON.parse(e);return t.sessionId&&"number"==typeof t.updatedAt?t:null}catch(e){return console.warn("[CyberneticSessionStorage] Failed to load session:",e),null}}saveToStorage(e){if(this.isAvailable())try{window.sessionStorage.setItem(this.config.storageKey,JSON.stringify(e))}catch(e){console.warn("[CyberneticSessionStorage] Failed to save session:",e)}}generateMessageId(){return`msg_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}}function te(e){if(e.wsUrl)return e.wsUrl;if("rest"===e.transport)return;const t=function(){try{const e=globalThis.import?.meta?.env;if(e?.VITE_ASTERMIND_RAG_WS_URL)return e.VITE_ASTERMIND_RAG_WS_URL}catch{}if("undefined"!=typeof process&&process.env){if(process.env.ASTERMIND_RAG_WS_URL)return process.env.ASTERMIND_RAG_WS_URL;if(process.env.REACT_APP_ASTERMIND_RAG_WS_URL)return process.env.REACT_APP_ASTERMIND_RAG_WS_URL}if("undefined"!=typeof window){const e=window.__ASTERMIND_CONFIG__;if(e?.wsUrl)return e.wsUrl;const t=window.astermindConfig;if(t?.wsUrl)return t.wsUrl}if("undefined"!=typeof document){const e=document.querySelector("script[data-astermind-ws-url]");if(e){const t=e.getAttribute("data-astermind-ws-url");if(t)return t}}}();return t||function(e){try{const t=new URL(e),n=t.hostname.match(/^chatapi(-[\w]+)?\.astermind\.ai$/);if(n)return`wss://chatws${n[1]||""}.astermind.ai`;if("api.astermind.ai"===t.hostname)return"wss://chatws.astermind.ai"}catch{}}(e.apiUrl)}function ne(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");const n=t.length%4;n&&(t+="=".repeat(4-n));const r=atob(t),a=new Uint8Array(r.length);for(let e=0;e<r.length;e++)a[e]=r.charCodeAt(e);return a}function re(e){const t=ne(e);return(new TextDecoder).decode(t)}async function ae(e,t,n){try{const r=await async function(e){const t=e.replace(/-----BEGIN PUBLIC KEY-----/,"").replace(/-----END PUBLIC KEY-----/,"").replace(/\s/g,""),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return crypto.subtle.importKey("spki",r.buffer,{name:"ECDSA",namedCurve:"P-256"},!1,["verify"])}(n),a=(new TextEncoder).encode(e),o=new Uint8Array(t).buffer;return await crypto.subtle.verify({name:"ECDSA",hash:"SHA-256"},r,o,a)}catch(e){return console.warn("[License] Signature verification failed:",e),!1}}async function oe(e,t){if(!e||""===e.trim())return{status:"missing",payload:null,error:"No license key provided",inGracePeriod:!1,daysRemaining:null};const n=function(e){try{const t=e.split(".");if(3!==t.length)return null;const[n,r,a]=t;return{header:JSON.parse(re(n)),payload:JSON.parse(re(r)),signature:ne(a),signedContent:`${n}.${r}`}}catch{return null}}(e);if(!n)return{status:"invalid",payload:null,error:"Invalid license key format",inGracePeriod:!1,daysRemaining:null};const r=function(e){return"string"!=typeof e.iss||"string"!=typeof e.sub||"string"!=typeof e.aud||"number"!=typeof e.iat||"number"!=typeof e.exp||"string"!=typeof e.plan||"number"!=typeof e.seats?null:Array.isArray(e.features)?"number"!=typeof e.licenseVersion?null:{iss:e.iss,sub:e.sub,aud:e.aud,iat:e.iat,exp:e.exp,plan:e.plan,org:"string"==typeof e.org?e.org:void 0,seats:e.seats,features:e.features,graceUntil:"number"==typeof e.graceUntil?e.graceUntil:void 0,licenseVersion:e.licenseVersion}:null}(n.payload);if(!r)return{status:"invalid",payload:null,error:"Invalid license payload structure",inGracePeriod:!1,daysRemaining:null};if("astermind"!==r.iss)return{status:"invalid",payload:null,error:"Invalid license issuer",inGracePeriod:!1,daysRemaining:null};if("cybernetic-chatbot"!==r.aud&&"*"!==r.aud)return{status:"invalid",payload:null,error:"License not valid for this product",inGracePeriod:!1,daysRemaining:null};if("undefined"!=typeof crypto&&crypto.subtle){const e=t||"-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEhLW7MXHQ0Fuk1OKt9D5CbRw7fUMN\nLJ5AZXvOhHaXdHzMuYKX5BpK4w7TqbPvJ6QPvKmLKvHh1VKcUJ6mJQgJJw==\n-----END PUBLIC KEY-----";if(!await ae(n.signedContent,n.signature,e))return{status:"invalid",payload:null,error:"License signature verification failed",inGracePeriod:!1,daysRemaining:null}}const a=Math.floor(Date.now()/1e3),o=function(e){const t=e-Math.floor(Date.now()/1e3);return Math.floor(t/86400)}(r.exp);return r.exp<a?r.graceUntil&&r.graceUntil>a?{status:"valid",payload:r,inGracePeriod:!0,daysRemaining:o}:{status:"expired",payload:r,error:"License has expired",inGracePeriod:!1,daysRemaining:o}:"eval"===r.plan?{status:"eval",payload:r,inGracePeriod:!1,daysRemaining:o}:{status:"valid",payload:r,inGracePeriod:!1,daysRemaining:o}}const ie="cybernetic-chatbot-client",se="agentic";class le{constructor(e={}){this.state=null,this.verificationPromise=null,this.loggedMissingFeatures=new Set,this.config=e,this.environment=e.environment||function(){if("undefined"==typeof window)return"production"===process?.env?.NODE_ENV?"production":"development";const e=window.location?.hostname||"",t=["localhost","127.0.0.1","0.0.0.0",".local",".dev",".test",":3000",":5173",":8080",":4200"];for(const n of t)if(e.includes(n)||window.location?.port===n.replace(":",""))return"development";if("file:"===window.location?.protocol)return"development";const n=["staging.","preview.","-preview.",".vercel.app",".netlify.app",".pages.dev"];for(const t of n)if(e.includes(t))return"production";return"production"}(),this.enforcementMode="development"===this.environment?"soft":"hard"}async verify(){if(this.state)return this.state;if(this.verificationPromise)return this.verificationPromise;this.verificationPromise=oe(this.config.licenseKey,this.config.publicKey);try{return this.state=await this.verificationPromise,this.config.onStatusChange?.(this.state),this.logLicenseStatus(),this.state}finally{this.verificationPromise=null}}getState(){return this.state}isValid(){return!!this.state&&("valid"===this.state.status||"eval"===this.state.status)}requiresAction(){return!this.state||("expired"===this.state.status||"missing"===this.state.status||"invalid"===this.state.status)}getEnvironment(){return this.environment}getEnforcementMode(){return this.enforcementMode}processResponse(e){return e}getStatusMessage(){if(!this.state)return"License not verified";switch(this.state.status){case"valid":return this.state.inGracePeriod?`License expired but in grace period (${Math.abs(this.state.daysRemaining||0)} days overdue)`:`License valid (${this.state.daysRemaining} days remaining)`;case"eval":return`Evaluation license (${this.state.daysRemaining} days remaining)`;case"expired":return`License expired ${Math.abs(this.state.daysRemaining||0)} days ago`;case"missing":return"No license key provided";case"invalid":return`Invalid license: ${this.state.error}`;default:return"Unknown license status"}}async reVerify(){return this.state=null,this.loggedMissingFeatures.clear(),this.verify()}hasFeature(e){return!!this.state?.payload&&this.state.payload.features.includes(e)}getFeatures(){return this.state?.payload?.features||[]}checkClientFeature(){return this.checkFeatureWithLog(ie,"CyberneticClient")}checkAgenticFeature(){return this.checkFeatureWithLog(se,"Agentic capabilities")}checkFeatureWithLog(e,t){if(!this.state?.payload)return!0;const n=this.state.payload.features.includes(e);return n||this.loggedMissingFeatures.has(e)||(this.loggedMissingFeatures.add(e),this.logMissingFeature(e,t)),n}logMissingFeature(e,t){const n=this.getFeatures(),r=this.state?.payload?.plan||"unknown";console.warn(`[Cybernetic License] ${t} requires the '${e}' feature, which is not included in your license.`),console.info(`[Cybernetic License] Current license plan: ${r}`),console.info(`[Cybernetic License] Licensed features: ${n.length>0?n.join(", "):"(none)"}`),console.info("[Cybernetic License] To add this feature, upgrade your license at https://astermind.ai/license")}logLicenseStatus(){if(!this.state)return;const e="[Cybernetic License]";switch(this.state.status){case"valid":this.state.inGracePeriod?console.warn(`${e} License expired but in grace period. Please renew at https://astermind.ai/license`):null!==this.state.daysRemaining&&this.state.daysRemaining<=30&&console.info(`${e} License expires in ${this.state.daysRemaining} days`);break;case"eval":console.info(`${e} Evaluation license - ${this.state.daysRemaining} days remaining`);break;case"expired":console.error(`${e} License expired. Enforcement mode: ${this.enforcementMode}. Renew at https://astermind.ai/license`);break;case"missing":console.warn(`${e} No license key provided. Enforcement mode: ${this.enforcementMode}. Get a license at https://astermind.ai/license`);break;case"invalid":console.error(`${e} Invalid license: ${this.state.error}. Enforcement mode: ${this.enforcementMode}`)}}}class ce{constructor(e){this.wsTransport=null,this.status="connecting",this.lastError=null,this.systemSettings=null,this.settingsLastChecked=0,this.SETTINGS_CHECK_INTERVAL=3e5,this.agenticCapabilities=null,this.offlineStorage=null,this.omegaRAG=null,this.salesClient=null,this.offlineWarningShown=!1;const t=te(e),n=e.transport??"auto";this.config={apiUrl:e.apiUrl,apiKey:e.apiKey,wsUrl:t,transport:n,fallback:{enabled:e.fallback?.enabled??!0,cacheMaxAge:e.fallback?.cacheMaxAge??864e5,cacheOnConnect:e.fallback?.cacheOnConnect??!0,cacheStorage:e.fallback?.cacheStorage??"indexeddb"},retry:{maxRetries:e.retry?.maxRetries??2,initialDelay:e.retry?.initialDelay??1e3,exponentialBackoff:e.retry?.exponentialBackoff??!0},agentic:e.agentic??null,offline:e.offline??null,sitemap:e.sitemap??null,sources:{enabled:e.sources?.enabled??!0,showSummary:e.sources?.showSummary??!0,showDownload:e.sources?.showDownload??!0,includeFullContent:e.sources?.includeFullContent??!1,maxSources:e.sources?.maxSources??5},onStatusChange:e.onStatusChange||(()=>{}),onError:e.onError||(()=>{})},this.apiClient=new I(this.config.apiUrl,this.config.apiKey),this.cache=new Q({storage:this.config.fallback.cacheStorage,maxAge:this.config.fallback.cacheMaxAge}),this.localRAG=new Y,this.licenseManager=new le({licenseKey:e.licenseKey,environment:e.environment}),this.sessionStorage=new ee(e.session),this.licenseManager.verify().then(()=>{this.licenseManager.checkClientFeature()}).catch(()=>{}),t&&"rest"!==n&&"undefined"!=typeof WebSocket&&(this.wsTransport=new J(t,e.apiKey,e.websocket),console.log(`[Cybernetic] WebSocket transport enabled: ${t}`)),this.monitorConnection(),this.config.fallback.enabled&&this.config.fallback.cacheOnConnect&&this.syncCache().catch(()=>{}),e.salesMode?.enabled&&(this.salesClient=new P(e.apiUrl,e.apiKey)),this.config.offline?.enabled&&this.initializeOffline(this.config.offline).catch(e=>{console.warn("[Cybernetic] Failed to initialize offline vectors:",e)})}registerAgentic(e){this.agenticCapabilities=e,console.log("[Cybernetic] Agentic capabilities registered")}isAgenticEnabled(){return null!==this.agenticCapabilities&&!0===this.config.agentic?.enabled&&(this.licenseManager.checkAgenticFeature(),!0)}getAgenticCapabilities(){return this.agenticCapabilities}getAgenticConfig(){return this.config.agentic}getSourcesConfig(){return{...this.config.sources}}isSourceFeatureAvailable(e){return!!this.config.sources.enabled&&("summary"===e?this.config.sources.showSummary:"download"===e&&(this.config.sources.showDownload&&"online"===this.status))}classifyIntent(e){if(!this.isAgenticEnabled()||!this.agenticCapabilities)return null;const t=this.config.agentic;return new(0,this.agenticCapabilities.agent)(t).interpretIntent(e)}async executeAction(e){if(!this.isAgenticEnabled()||!this.agenticCapabilities)return{success:!1,message:"Agentic capabilities not enabled"};const t=this.config.agentic;return new(0,this.agenticCapabilities.agent)(t).executeAction(e)}async smartAsk(e,t){const n=this.classifyIntent(e);if(n&&n.action&&!n.shouldEscalate){if(!1!==this.config.agentic?.requireConfirmation)return{action:n.action};const e=await this.executeAction(n.action);return{action:n.action,actionResult:e}}return{response:await this.ask(e,t)}}async initializeOffline(e){const t=e.storageMode??"hybrid",n=e.cacheMaxAge??6048e5;if("memory"!==t&&(this.offlineStorage=new X),this.offlineStorage&&"memory"!==t){const e="default";if(await this.offlineStorage.isValid(e,n)){console.log("[Cybernetic] Loading vectors from IndexedDB cache");const t=await this.offlineStorage.retrieve(e);if(t)return await this.localRAG.loadFromExport(t),void console.log("[Cybernetic] Loaded vectors from IndexedDB cache")}}if(e.vectorFileUrl)try{const n=await fetch(e.vectorFileUrl);if(!n.ok)throw new Error(`Failed to fetch vectors: ${n.status}`);const r=await n.json();return this.offlineStorage&&"memory"!==t&&await this.offlineStorage.store("default",r),await this.localRAG.loadFromExport(r),e.omega?.enabled&&await this.initializeOmega(e),void console.log("[Cybernetic] Loaded vectors from URL:",e.vectorFileUrl)}catch(e){console.error("[Cybernetic] Failed to load offline vectors from URL:",e)}if(e.vectorData)return await this.localRAG.loadFromExport(e.vectorData),e.omega?.enabled&&await this.initializeOmega(e),void console.log("[Cybernetic] Loaded inline vector data");this.offlineWarningShown||(console.warn("[Cybernetic] Offline functionality is enabled but no vectors are loaded. Offline responses will be limited. To enable full offline functionality, export vectors from the AsterMind admin panel and configure the vectorFileUrl or vectorData option."),this.offlineWarningShown=!0)}async initializeOmega(e){if(e.omega?.enabled)try{const{OmegaOfflineRAG:t}=await Promise.resolve().then(function(){return Ke});this.omegaRAG=new t({reranking:e.omega.reranking,topK:5,verbose:!1}),e.omega.modelUrl?await this.omegaRAG.loadModelFromUrl(e.omega.modelUrl):e.omega.modelData&&await this.omegaRAG.loadModel(e.omega.modelData),console.log("[Cybernetic] Omega RAG initialized")}catch(e){console.warn("[Cybernetic] Failed to initialize Omega RAG:",e),this.omegaRAG=null}}async reloadOfflineVectors(){this.config.offline?.enabled?(this.localRAG.reset(),this.offlineStorage&&await this.offlineStorage.clear(),this.omegaRAG&&this.omegaRAG.clear(),await this.initializeOffline(this.config.offline)):console.warn("[Cybernetic] Offline mode is not enabled")}isOmegaOfflineEnabled(){return this.omegaRAG?.isReady()??!1}getOfflineModelInfo(){return this.omegaRAG?.getModelInfo()??null}getLocalRAGStatus(){return this.localRAG.getExportStatus()}getOfflineStorage(){return this.offlineStorage}getStoredMessages(){return this.sessionStorage.getMessages()}hasStoredSession(){return this.sessionStorage.hasValidSession()}getSessionInfo(){return this.sessionStorage.getSessionInfo()}clearSession(){this.sessionStorage.clear()}startNewSession(e){this.sessionStorage.startNewSession(e)}isSalesModeEnabled(){return null!==this.salesClient}getSalesClient(){return this.salesClient}async salesChat(e,t={}){if(!this.salesClient)throw new Error("Sales mode is not enabled. Set salesMode.enabled = true in config.");return this.salesClient.salesChat(e,t)}async initVisitor(e,t,n,r){if(!this.salesClient)throw new Error("Sales mode is not enabled. Set salesMode.enabled = true in config.");return this.salesClient.initVisitor(e,t,n,r)}async trackPageView(e,t,n,r,a){if(!this.salesClient)throw new Error("Sales mode is not enabled. Set salesMode.enabled = true in config.");return this.salesClient.trackPageView(e,t,n,r,a)}async captureLeadForm(e){if(!this.salesClient)throw new Error("Sales mode is not enabled. Set salesMode.enabled = true in config.");return this.salesClient.captureLeadForm(e)}async ask(e,t){if(!e||"string"!=typeof e)return this.createErrorResponse("Message is required","none");const n=t?.sessionId??this.sessionStorage.getSessionId()??void 0,r=n?{...t,sessionId:n}:t,a=await this.checkSystemStatus();if(a.maintenanceMode||a.forceOfflineClients)return console.log("[Cybernetic] Maintenance mode active, using cached data"),this.isCacheValid()?await this.fallbackAsk(e):{reply:a.maintenanceMessage||"The service is currently under maintenance. Please try again later.",confidence:"none",sources:[],offline:!0,degradedReason:"Maintenance mode active, no valid cache available"};try{const t=await this.apiWithRetry(e,r);this.setStatus("online");const n=this.licenseManager.processResponse(t.reply);return t.sessionId&&this.sessionStorage.saveSessionId(t.sessionId),this.sessionStorage.addMessage({role:"user",content:e}),this.sessionStorage.addMessage({role:"assistant",content:n,confidence:"high",sources:t.sources||[]}),{reply:n,confidence:"high",sources:t.sources||[],offline:!1,sessionId:t.sessionId}}catch(n){const r=this.normalizeError(n);return this.lastError=r,this.config.onError(r),"RATE_LIMIT"===r.code?{reply:"I'm receiving too many requests right now. Please try again in a moment.",confidence:"none",sources:[],offline:!1,retryAfter:r.retryAfter}:this.config.fallback.enabled&&!t?.skipFallback?await this.fallbackAsk(e):this.createErrorResponse("Unable to connect to the chatbot service. Please try again later.","none",r.retryAfter)}}async askStream(e,t,n){if(!e||"string"!=typeof e)return void t.onError?.({code:"LOCAL_RAG_ERROR",message:"Message is required"});const r=n?.sessionId??this.sessionStorage.getSessionId()??void 0,a=r?{...n,sessionId:r}:n;this.sessionStorage.addMessage({role:"user",content:e});const o=await this.checkSystemStatus();if(o.maintenanceMode||o.forceOfflineClients){console.log("[Cybernetic] Maintenance mode active, falling back to offline");const n=await this.fallbackAsk(e);return void t.onComplete?.(n)}if(this.wsTransport&&"rest"!==this.config.transport)try{return void await this.wsTransport.chatStream(e,{sessionId:a?.sessionId,context:a?.context,onToken:t.onToken,onSources:t.onSources,onComplete:e=>{this.setStatus("online");const n=this.licenseManager.processResponse(e.reply);e.sessionId&&this.sessionStorage.saveSessionId(e.sessionId),this.sessionStorage.addMessage({role:"assistant",content:n,confidence:"high",sources:e.sources}),t.onComplete?.({...e,reply:n})},onError:n=>{if("auto"===this.config.transport)console.warn("[Cybernetic] WebSocket error, falling back to SSE:",n.message),this.streamViaSSE(e,t,a);else{const e=this.normalizeError(n);this.config.onError(e),t.onError?.(e)}}})}catch(e){if("websocket"===this.config.transport){const n=this.normalizeError(e);return this.lastError=n,this.config.onError(n),void t.onError?.(n)}console.warn("[Cybernetic] WebSocket connect failed, using SSE fallback")}await this.streamViaSSE(e,t,a)}async streamViaSSE(e,t,n){try{await this.apiClient.chatStream(e,{sessionId:n?.sessionId,context:n?.context,onToken:t.onToken,onSources:t.onSources,onComplete:e=>{this.setStatus("online");const n=this.licenseManager.processResponse(e.fullText);e.sessionId&&this.sessionStorage.saveSessionId(e.sessionId),this.sessionStorage.addMessage({role:"assistant",content:n,confidence:"high",sources:e.sources||[]}),t.onComplete?.({reply:n,confidence:"high",sources:e.sources||[],offline:!1,sessionId:e.sessionId,messageId:e.messageId})},onError:e=>{const n=this.normalizeError(e);this.config.onError(n),t.onError?.(n)}})}catch(r){const a=this.normalizeError(r);if(this.lastError=a,this.config.onError(a),this.config.fallback.enabled&&!n?.skipFallback){const n=await this.fallbackAsk(e);t.onComplete?.(n)}else t.onError?.(a)}}async syncCache(){try{const e=await this.cache.getLastSync(),t=await this.apiClient.getGeneralDocs(e);t.length>0&&(await this.cache.store(t),await this.localRAG.index(t),console.log(`[Cybernetic] Cache synced: ${t.length} documents`)),this.setStatus("online")}catch(e){console.warn("[Cybernetic] Cache sync failed:",e)}}getStatus(){return{connection:this.status,cache:this.cache.getStatus(),lastError:this.lastError,systemSettings:this.systemSettings,license:this.licenseManager.getState()}}getLicenseManager(){return this.licenseManager}async clearCache(){await this.cache.clear(),this.localRAG.reset()}destroy(){this.wsTransport&&(this.wsTransport.disconnect(),this.wsTransport=null)}async checkConnection(){try{return await this.apiClient.getStatus(),this.setStatus("online"),!0}catch{return this.setStatus("offline"),!1}}async checkSystemStatus(){if(this.systemSettings&&Date.now()-this.settingsLastChecked<this.SETTINGS_CHECK_INTERVAL)return this.systemSettings;try{const e=await this.apiClient.getStatus();return this.systemSettings={cacheRetentionHours:e.systemSettings?.cacheRetentionHours??168,maintenanceMode:e.systemSettings?.maintenanceMode??!1,maintenanceMessage:e.systemSettings?.maintenanceMessage,forceOfflineClients:e.systemSettings?.forceOfflineClients??!1},this.settingsLastChecked=Date.now(),this.systemSettings}catch{return this.systemSettings||{cacheRetentionHours:168,maintenanceMode:!1,forceOfflineClients:!1}}}isMaintenanceMode(){return this.systemSettings?.maintenanceMode??!1}getMaintenanceMessage(){return this.systemSettings?.maintenanceMessage}isCacheValid(){const e=this.cache.getStatus();if(!e.lastSyncAt)return!1;const t=60*(this.systemSettings?.cacheRetentionHours||168)*60*1e3,n=new Date(e.lastSyncAt).getTime();return Date.now()-n<t}async apiWithRetry(e,t){const{maxRetries:n,initialDelay:r,exponentialBackoff:a}=this.config.retry;let o=null;for(let i=0;i<=n;i++)try{return await this.apiClient.chat(e,{sessionId:t?.sessionId,context:t?.context})}catch(e){o=e;const t=this.normalizeError(e);if("AUTH_ERROR"===t.code||"RATE_LIMIT"===t.code)throw e;if(i<n){const e=a?r*Math.pow(2,i):r;await this.sleep(e)}}throw o}async fallbackAsk(e){if(this.setStatus("offline"),this.omegaRAG?.isReady())try{const t=await this.omegaRAG.ask(e);if(!t.degraded){return{reply:this.licenseManager.processResponse(t.answer),confidence:t.confidence,sources:t.sources.map(e=>({title:e.heading,snippet:e.content.substring(0,200)+"...",relevance:e.score})),offline:!0,degradedReason:"Omega hybrid retrieval (offline)"}}}catch(e){console.warn("[Cybernetic] Omega RAG failed, falling back to TF-IDF:",e)}const t=this.localRAG.getExportStatus();if(t.loaded&&t.documentCount>0)try{const n=await this.localRAG.ask(e);let r="medium";n.topScore<.3?r="low":n.topScore>.7&&(r="medium");return{reply:this.licenseManager.processResponse(n.answer),confidence:r,sources:n.sources.map(e=>({title:e.title,snippet:e.snippet,relevance:e.score})),offline:!0,degradedReason:t.loadedFromExport?"Using pre-exported vectors (offline)":"Processed locally with TF-IDF"}}catch(e){console.error("[Cybernetic] Local RAG error:",e)}const n=this.cache.getStatus();if(0===n.documentCount&&!t.loaded)return{reply:"I'm currently offline and don't have any cached information. Please check your connection and try again.",confidence:"none",sources:[],offline:!0,degradedReason:"No cached documents or offline vectors available"};try{const t=await this.cache.retrieve();this.localRAG.isIndexed()||await this.localRAG.index(t);const r=await this.localRAG.ask(e);let a="medium";r.topScore<.3?a="low":r.topScore>.7&&(a="medium");return{reply:this.licenseManager.processResponse(r.answer),confidence:a,sources:r.sources.map(e=>({title:e.title,snippet:e.snippet,relevance:e.score})),offline:!0,degradedReason:n.isStale?"Using stale cached data":"Processed locally without server"}}catch(e){return console.error("[Cybernetic] Local RAG error:",e),{reply:"I'm having trouble processing your request offline. Please try again when you're back online.",confidence:"none",sources:[],offline:!0,degradedReason:"Local RAG processing failed"}}}monitorConnection(){"undefined"!=typeof window&&(window.addEventListener("online",()=>{this.syncCache().catch(()=>{})}),window.addEventListener("offline",()=>{this.setStatus("offline")}),navigator.onLine||this.setStatus("offline"))}setStatus(e){this.status!==e&&(this.status=e,this.config.onStatusChange(e))}normalizeError(e){if(e instanceof Error){if(e.message.includes("401")||e.message.includes("Unauthorized"))return{code:"AUTH_ERROR",message:"Invalid or expired API key",originalError:e};if(e.message.includes("429")||e.message.includes("Rate limit")){const t=e.message.match(/retry after (\d+)/i);return{code:"RATE_LIMIT",message:"Rate limit exceeded",retryAfter:t?parseInt(t[1],10):60,originalError:e}}return e.message.includes("5")||e.message.includes("Server")?{code:"SERVER_ERROR",message:"Server error occurred",originalError:e}:{code:"NETWORK_ERROR",message:e.message||"Network error",originalError:e}}return{code:"NETWORK_ERROR",message:"Unknown error occurred"}}createErrorResponse(e,t,n){return{reply:e,confidence:t,sources:[],offline:!1,retryAfter:n}}sleep(e){return new Promise(t=>setTimeout(t,e))}}const ue=["nav a[href]",'[role="navigation"] a[href]',"header a[href]",".nav a[href]",".navbar a[href]",".navigation a[href]",".sidebar a[href]",".side-nav a[href]",".sidenav a[href]",".menu a[href]",".main-menu a[href]",".top-menu a[href]","[data-nav] a[href]","[data-menu] a[href]","[data-navigation] a[href]",'[aria-label*="navigation" i] a[href]','[aria-label*="menu" i] a[href]','[aria-label*="breadcrumb" i] a[href]',".breadcrumb a[href]",".breadcrumbs a[href]",'a[href^="/"]'],de=["/login","/logout","/signin","/signout","/sign-in","/sign-out","/register","/signup","/sign-up","/forgot-password","/reset-password","/auth/*","/oauth/*","/callback/*","/sso/*","/api/*","/_next/*","/_nuxt/*","/__*","javascript:*","mailto:*","tel:*","#*"];class fe{constructor(e,t,n){this.staticEntries=[],this.discoveredEntries=[],this.backendEntries=[],this.backendCache=null,this.isInitialized=!1,this.initPromise=null,this.detectedFramework="generic",this.popstateHandler=null,this.config=e,this.apiUrl=t,this.apiKey=n,e.static&&(this.staticEntries=this.enhanceEntries(e.static,"props"))}async initialize(){if(!this.isInitialized){if(this.initPromise)return this.initPromise;this.initPromise=this.performInitialization(),await this.initPromise,this.isInitialized=!0}}async performInitialization(){await this.waitForDOMReady();const e=this.loadFromLocalStorage();if(e)return this.discoveredEntries=e,console.log(`[SiteMapDiscovery] Loaded ${e.length} entries from cache`),void this.refreshInBackground();const t=[];!1!==this.config.discovery?.enabled&&t.push(this.discoverFromFramework()),!1!==this.config.backend?.enabled&&this.config.backend?.endpoint&&t.push(this.fetchFromBackend());const n=await Promise.allSettled(t);for(const e of n)if("fulfilled"===e.status){const{entries:t,source:n}=e.value;"discovery"===n?(this.discoveredEntries=t,this.saveToLocalStorage(t)):"backend"===n&&(this.backendEntries=t)}else console.warn("[SiteMapDiscovery] Source failed:",e.reason);this.setupPopstateListener();const r=this.staticEntries.length+this.discoveredEntries.length+this.backendEntries.length;console.log(`[SiteMapDiscovery] Initialized with ${r} total entries (${this.staticEntries.length} static, ${this.discoveredEntries.length} discovered, ${this.backendEntries.length} backend)`)}async waitForDOMReady(){if("undefined"!=typeof document){if("complete"!==document.readyState&&"interactive"!==document.readyState)return new Promise(e=>{document.addEventListener("DOMContentLoaded",()=>e(),{once:!0})});await new Promise(e=>setTimeout(e,0))}}setupPopstateListener(){"undefined"!=typeof window&&(this.popstateHandler=()=>{setTimeout(()=>{this.refreshInBackground()},100)},window.addEventListener("popstate",this.popstateHandler))}async refreshInBackground(){try{const e=await this.discoverFromFramework();e.entries.length>0&&(this.discoveredEntries=e.entries,this.saveToLocalStorage(e.entries))}catch(e){console.debug("[SiteMapDiscovery] Background refresh failed:",e)}}getCacheKey(){return"undefined"==typeof window?"astermind-sitemap":`astermind-sitemap-${window.location.origin}`}loadFromLocalStorage(){if("undefined"==typeof localStorage)return null;try{const e=this.getCacheKey(),t=localStorage.getItem(e);if(!t)return null;const n=JSON.parse(t);if("1"!==n.version)return localStorage.removeItem(e),null;const r=this.config.discovery?.cacheTtl??3e5;return Date.now()-n.timestamp>r?(localStorage.removeItem(e),null):(this.detectedFramework=n.framework,n.entries)}catch(e){return console.debug("[SiteMapDiscovery] Failed to load from cache:",e),null}}saveToLocalStorage(e){if("undefined"!=typeof localStorage&&!1!==this.config.discovery?.cacheRoutes)try{const t=this.getCacheKey(),n={entries:e,url:"undefined"!=typeof window?window.location.href:"",timestamp:Date.now(),framework:this.detectedFramework,version:"1"};localStorage.setItem(t,JSON.stringify(n))}catch(e){console.debug("[SiteMapDiscovery] Failed to save to cache:",e)}}clearCache(){"undefined"!=typeof localStorage&&localStorage.removeItem(this.getCacheKey())}dispose(){this.popstateHandler&&"undefined"!=typeof window&&(window.removeEventListener("popstate",this.popstateHandler),this.popstateHandler=null)}getDetectedFramework(){return this.detectedFramework}getMergedEntries(){return this.mergeEntries(this.staticEntries,this.discoveredEntries,this.backendEntries)}getLegacyEntries(){return this.getMergedEntries().map(e=>({path:e.path,name:e.name,description:e.description,params:e.params,dynamicParams:e.dynamicParams,aliases:e.aliases}))}async discoverFromFramework(){const e=this.config.discovery||{},t=[];try{const n=e.framework||this.detectFramework();this.detectedFramework=n;let r=[];switch(n){case"react-router":r=this.discoverReactRouter();break;case"vue-router":r=this.discoverVueRouter();break;case"next":r=this.discoverNextRoutes();break;case"angular":r=this.discoverAngularRoutes();break;default:!1!==e.domFallback&&(r=this.discoverFromDOM(e.navSelectors))}for(const n of r){if(this.shouldExcludeRoute(n.path,e.excludePaths))continue;let r;r=e.transformRoute?e.transformRoute(n):this.defaultRouteTransform(n),r&&t.push(this.enhanceEntry(r,"discovery"))}console.log(`[SiteMapDiscovery] Discovered ${t.length} routes from ${n}`)}catch(e){return console.warn("[SiteMapDiscovery] Framework discovery failed:",e),{entries:[],source:"discovery",timestamp:Date.now(),error:String(e)}}return{entries:t,source:"discovery",timestamp:Date.now()}}detectFramework(){if("undefined"==typeof window)return"generic";const e=window;return e.__REACT_ROUTER_DATA_ROUTER__||e.__reactRouterContext?"react-router":e.__VUE_ROUTER__||e.__VUE_APP__?.$router?"vue-router":e.__NEXT_DATA__?"next":e.ng||document.querySelector("[ng-version]")?"angular":"generic"}discoverReactRouter(){const e=[];if("undefined"==typeof window)return e;const t=window.__REACT_ROUTER_DATA_ROUTER__;return t?.routes?(this.extractRoutesFromConfig(t.routes,e,""),e):e}extractRoutesFromConfig(e,t,n){for(const r of e){const e=this.normalizePath(n,r.path||""),a={path:e,name:r.handle?.name||r.handle?.title||r.id,meta:r.handle||{},children:[]};(r.path||r.index)&&t.push(a),r.children&&this.extractRoutesFromConfig(r.children,t,e)}}discoverVueRouter(){const e=[];if("undefined"==typeof window)return e;const t=window,n=t.__VUE_APP__,r=n?.$router||t.__VUE_ROUTER__;if(r?.getRoutes){const t=r.getRoutes();for(const n of t)e.push({path:n.path,name:n.name?.toString(),meta:n.meta||{},component:n.components?.default?.name})}return e}discoverNextRoutes(){const e=[];if("undefined"==typeof window)return e;const t=window.__NEXT_DATA__;if(!t)return e;const n=t.buildManifest?.pages||{};for(const t of Object.keys(n))t.startsWith("/_")||e.push({path:t,name:this.pathToName(t)});return e}discoverAngularRoutes(){return[]}discoverFromDOM(e){const t=[];if("undefined"==typeof document)return t;const n=e||ue,r=this.config.discovery?.maxDomLinks??200,a=this.config.discovery?.excludePaths||[],o=[...de,...a],i=new Set;let s=0;for(const e of n){if(s>=r)break;try{const n=document.querySelectorAll(e);for(const e of n){if(s>=r)break;const n=e.getAttribute("href");if(!n)continue;if(n.startsWith("http")&&!n.startsWith(window.location.origin))continue;let a=n;if(n.startsWith("http"))try{a=new URL(n).pathname}catch{continue}else n.startsWith("/")||(a=`/${n}`);const l=a.split("?")[0].split("#")[0];i.has(l)||"/"!==l&&(this.shouldExcludeRoute(l,o)||(i.add(l),s++,t.push({path:l,name:e.textContent?.trim()||this.pathToName(l)})))}}catch(e){}}return console.log(`[SiteMapDiscovery] DOM scan found ${t.length} routes (limit: ${r})`),t}async fetchFromBackend(){const e=this.config.backend||{},t=e.endpoint||"/api/external/sitemap";if(this.backendCache&&Date.now()<this.backendCache.expiresAt)return{entries:this.backendCache.entries,source:"backend",timestamp:this.backendCache.fetchedAt};try{const n=new URL(t,this.apiUrl);!1!==e.tenantScoped&&n.searchParams.set("tenantScoped","true"),!1!==e.includeGeneral&&n.searchParams.set("includeGeneral","true");const r=await fetch(n.toString(),{method:"GET",headers:{"X-API-Key":this.apiKey,"Content-Type":"application/json",...e.headers}});if(!r.ok)throw new Error(`Backend sitemap fetch failed: ${r.status}`);const a=await r.json(),o=this.transformBackendResponse(a),i=e.cacheTtl||3e5;return this.backendCache={entries:o,fetchedAt:Date.now(),expiresAt:Date.now()+i},console.log(`[SiteMapDiscovery] Loaded ${o.length} routes from backend`),{entries:o,source:"backend",timestamp:Date.now()}}catch(e){return console.warn("[SiteMapDiscovery] Backend fetch failed:",e),{entries:this.backendCache?.entries||[],source:"backend",timestamp:Date.now(),error:String(e)}}}transformBackendResponse(e){return(Array.isArray(e)?e:e.entries||e.sitemap||e.routes||[]).map(e=>this.enhanceEntry({path:e.url||e.path,name:e.title||e.name,description:e.description,aliases:e.keywords||e.aliases,params:e.params,dynamicParams:e.dynamicParams},"backend"))}mergeEntries(...e){const t=this.config.merge||{},n=t.sourcePriority||["props","backend","discovery"],r=t.deduplication||"path",a=new Map;n.forEach((e,t)=>{a.set(e,n.length-t)});const o=[];for(const t of e)for(const e of t){const t=a.get(e._source||"props")||0;o.push({...e,_priority:t})}o.sort((e,t)=>(t._priority||0)-(e._priority||0));const i=new Map;for(const e of o){let n;switch(r){case"name":n=e.name.toLowerCase();break;case"both":n=`${e.path}|${e.name.toLowerCase()}`;break;default:n=this.normalizePath("",e.path)}if(i.has(n)){if(!1!==t.keepNonConflicting){const t=i.get(n);!t.description&&e.description&&(t.description=e.description),!t.aliases?.length&&e.aliases?.length&&(t.aliases=e.aliases)}}else i.set(n,e)}return Array.from(i.values())}enhanceEntries(e,t){return e.map(e=>this.enhanceEntry(e,t))}enhanceEntry(e,t){return{...e,_source:t,_discoveredAt:Date.now()}}defaultRouteTransform(e){return e.path&&"*"!==e.path&&"**"!==e.path?{path:e.path,name:e.name||e.meta?.title||this.pathToName(e.path),description:e.meta?.description,aliases:e.meta?.keywords||e.meta?.aliases,dynamicParams:e.path.includes(":")||e.path.includes("[")}:null}normalizePath(e,t){return t&&"/"!==t?t.startsWith("/")?t:e&&"/"!==e?`${e}/${t}`.replace(/\/+/g,"/"):`/${t}`:e||"/"}pathToName(e){const t=e.split("/").filter(Boolean);return(t[t.length-1]||"Home").replace(/[-_]/g," ").replace(/\[.*?\]/g,"").replace(/:/g,"").split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ").trim()||"Page"}shouldExcludeRoute(e,t){if(!t?.length)return!1;for(const n of t){if(new RegExp("^"+n.replace(/\*/g,".*").replace(/\?/g,".")+"$").test(e))return!0}return!1}async refresh(){this.backendCache=null,this.isInitialized=!1,this.initPromise=null,await this.initialize()}isReady(){return this.isInitialized}getStats(){return{static:this.staticEntries.length,discovered:this.discoveredEntries.length,backend:this.backendEntries.length,merged:this.getMergedEntries().length}}}const he={navigate:[{pattern:/^(go to|navigate to|take me to|open|show me|bring up)\s+(.+)/i,type:"navigate",weight:.9},{pattern:/^(i want to see|i need to go to|let me see)\s+(.+)/i,type:"navigate",weight:.85},{pattern:/^(where is|how do i get to)\s+(.+)/i,type:"navigate",weight:.6}],fillForm:[{pattern:/^(search for|find|look up|search)\s+(.+)/i,type:"fillForm",weight:.88},{pattern:/^(filter by|set .+ to|change .+ to)\s+(.+)/i,type:"fillForm",weight:.85},{pattern:/^(enter|type|put)\s+(.+)\s+(in|into)\s+(.+)/i,type:"fillForm",weight:.9}],clickElement:[{pattern:/^(click|press|hit|tap)\s+(the\s+)?(.+)\s+(button|link)/i,type:"clickElement",weight:.9},{pattern:/^(submit|send|confirm|save|cancel|delete)/i,type:"clickElement",weight:.85}],triggerModal:[{pattern:/^(open|show|display)\s+(the\s+)?(.+)\s+(modal|dialog|popup|window)/i,type:"triggerModal",weight:.9},{pattern:/^(open|show)\s+(help|settings|preferences|options)/i,type:"triggerModal",weight:.85}],scroll:[{pattern:/^(scroll to|jump to|go to)\s+(the\s+)?(.+)\s+(section|area|part)/i,type:"scroll",weight:.85},{pattern:/^(show me|take me to)\s+(the\s+)?(bottom|top|end|beginning)/i,type:"scroll",weight:.8}],highlight:[{pattern:/^(highlight|show me|point to|where is)\s+(the\s+)?(.+)/i,type:"highlight",weight:.7}],custom:[{pattern:/^(export|download|refresh|reload|sync)/i,type:"custom",weight:.85}]};class pe{constructor(e,t="",n=""){this.categories=[],this.topicKeywords=new Map,this.siteMapDiscovery=null,this.config=e,this.siteMapIndex=new Map,this.formIndex=new Map,this.modalIndex=new Map,this.buildIndexes();const r=e.siteMapConfig??(e.enabled&&!e.siteMap?.length?{discovery:{enabled:!0}}:void 0);r&&(this.siteMapDiscovery=new fe(r,t,n),!e.siteMapConfig&&e.enabled&&console.log("[CyberneticIntentClassifier] Zero-config mode: auto-discovery enabled"))}buildIndexes(){if(this.config.siteMap)for(const e of this.config.siteMap){const t=[e.name.toLowerCase(),e.path.toLowerCase(),...(e.aliases||[]).map(e=>e.toLowerCase())];for(const n of t)this.siteMapIndex.set(n,e)}if(this.config.forms)for(const[e,t]of Object.entries(this.config.forms)){const n=[e.toLowerCase(),t.name.toLowerCase(),...(t.aliases||[]).map(e=>e.toLowerCase())];for(const e of n)this.formIndex.set(e,t)}if(this.config.modals)for(const[e,t]of Object.entries(this.config.modals)){const n=[e.toLowerCase(),t.id.toLowerCase(),...(t.aliases||[]).map(e=>e.toLowerCase())];for(const e of n)this.modalIndex.set(e,t)}}classify(e){if(!this.config.enabled)return{action:null,shouldEscalate:!0,rawConfidence:0};const t=e.trim().toLowerCase();for(const[t,n]of Object.entries(he))for(const{pattern:r,weight:a}of n){const n=e.match(r);if(n){const e=this.buildAction(t,n,a);if(e)return e}}const n=this.fuzzyMatchSiteMap(t);if(n)return n;const r=this.matchCustomAction(t);return r||{action:null,shouldEscalate:!0,rawConfidence:0,matchedPatterns:[]}}buildAction(e,t,n){const r=this.config.confidenceThreshold??.8;switch(e){case"navigate":{const e=this.extractTarget(t),a=this.findSiteMapMatch(e);if(a){const e=n*a.similarity;return{action:{id:`action-${Date.now()}`,type:"navigate",target:a.entry.path,confidence:e,explanation:`Navigate to ${a.entry.name}`},shouldEscalate:e<r,rawConfidence:e,matchedPatterns:["navigate",a.entry.name]}}break}case"fillForm":{const e=this.extractTarget(t),{field:a,value:o}=this.parseFormIntent(t);if(a){const e=.95*n;return{action:{id:`action-${Date.now()}`,type:"fillForm",target:a.selector,params:{value:o},confidence:e,explanation:`Fill "${a.name}" with "${o}"`},shouldEscalate:e<r,rawConfidence:e,matchedPatterns:["fillForm",a.name]}}if(this.config.forms?.search){const t=.9*n;return{action:{id:`action-${Date.now()}`,type:"fillForm",target:this.config.forms.search.selector,params:{value:e},confidence:t,explanation:`Search for "${e}"`},shouldEscalate:t<r,rawConfidence:t,matchedPatterns:["fillForm","search"]}}break}case"clickElement":{const e=this.extractTarget(t),a=this.findButtonSelector(e);if(a){const t=.95*n;return{action:{id:`action-${Date.now()}`,type:"clickElement",target:a,confidence:t,explanation:`Click "${e}" button`},shouldEscalate:t<r,rawConfidence:t,matchedPatterns:["clickElement",e]}}break}case"triggerModal":{const e=this.extractTarget(t),a=this.findModalConfig(e);if(a){const e=.95*n;return{action:{id:`action-${Date.now()}`,type:"triggerModal",target:a.trigger,confidence:e,explanation:`Open ${a.id} modal`},shouldEscalate:e<r,rawConfidence:e,matchedPatterns:["triggerModal",a.id]}}break}case"scroll":{const e=this.extractTarget(t),a=this.findScrollTarget(e);if(a){const t=.9*n;return{action:{id:`action-${Date.now()}`,type:"scroll",target:a,confidence:t,explanation:`Scroll to ${e}`},shouldEscalate:t<r,rawConfidence:t,matchedPatterns:["scroll",e]}}break}case"highlight":{const e=this.extractTarget(t),a=this.findElementByDescription(e);if(a){const t=.85*n;return{action:{id:`action-${Date.now()}`,type:"highlight",target:a,confidence:t,explanation:`Highlight ${e}`},shouldEscalate:t<r,rawConfidence:t,matchedPatterns:["highlight",e]}}break}case"custom":{const e=t[1]?.toLowerCase();if(this.config.customActions?.[e]){const t=.95*n;return{action:{id:`action-${Date.now()}`,type:"custom",target:e,confidence:t,explanation:`Execute ${e} action`},shouldEscalate:t<r,rawConfidence:t,matchedPatterns:["custom",e]}}break}}return null}extractTarget(e){for(let t=e.length-1;t>=1;t--)if(e[t])return e[t].trim();return""}stripArticles(e){return e.replace(/^(the|a|an|my|our|your|this|that)\s+/gi,"").replace(/\s+(page|section|screen|view)$/gi,"").trim()}findSiteMapMatch(e){const t=e.toLowerCase().replace(/[^a-z0-9\s]/g,""),n=this.stripArticles(t),r=this.siteMapIndex.get(t)||this.siteMapIndex.get(n);if(r)return{entry:r,similarity:1};let a=null,o=0;for(const[e,r]of this.siteMapIndex){const i=this.calculateSimilarity(t,e),s=this.calculateSimilarity(n,e),l=Math.max(i,s);l>o&&l>.5&&(o=l,a=r)}return a?{entry:a,similarity:o}:null}fuzzyMatchSiteMap(e){const t=this.config.confidenceThreshold??.8;for(const[n,r]of this.siteMapIndex)if(e.includes(n)){const e=.75;return{action:{id:`action-${Date.now()}`,type:"navigate",target:r.path,confidence:e,explanation:`Navigate to ${r.name}`},shouldEscalate:e<t,rawConfidence:e,matchedPatterns:["fuzzy-sitemap",n]}}return null}matchCustomAction(e){if(!this.config.customActions)return null;const t=this.config.confidenceThreshold??.8;for(const n of Object.keys(this.config.customActions))if(e.includes(n.toLowerCase())){const e=.85;return{action:{id:`action-${Date.now()}`,type:"custom",target:n,confidence:e,explanation:`Execute ${n}`},shouldEscalate:e<t,rawConfidence:e,matchedPatterns:["custom",n]}}return null}parseFormIntent(e){const t=e[0];for(const[,e]of this.formIndex)if(t.toLowerCase().includes(e.name.toLowerCase())){const n=t.match(new RegExp(`${e.name}[^a-z]*(.+)`,"i"));return{field:e,value:n?.[1]?.trim()||""}}return{field:null,value:this.extractTarget(e)}}findButtonSelector(e){const t=e.toLowerCase();if("undefined"==typeof document)return`button:contains("${e}")`;const n=[`[data-action="${t}"]`,`[aria-label*="${t}" i]`,`.btn-${t}`,`#${t}-button`,`button.${t}`];for(const e of n)try{if(document.querySelector(e))return e}catch{}const r=document.querySelectorAll('button, [role="button"], a.btn');for(const e of r)if(e.textContent?.toLowerCase().includes(t))return this.generateUniqueSelector(e);return null}findModalConfig(e){return this.modalIndex.get(e.toLowerCase())||null}findScrollTarget(e){const t=e.toLowerCase();if("top"===t||"beginning"===t)return"body";if("bottom"===t||"end"===t)return"body:last-child";if("undefined"==typeof document)return`#${t.replace(/\s+/g,"-")}`;const n=[`#${t.replace(/\s+/g,"-")}`,`[data-section="${t}"]`,`.${t.replace(/\s+/g,"-")}-section`,`section[aria-label*="${t}" i]`];for(const e of n)try{if(document.querySelector(e))return e}catch{continue}return null}findElementByDescription(e){const t=e.toLowerCase();if("undefined"==typeof document)return`[aria-label*="${t}" i]`;const n=[`[aria-label*="${t}" i]`,`[data-testid*="${t}" i]`,`[title*="${t}" i]`];for(const e of n)try{if(document.querySelector(e))return e}catch{continue}return null}generateUniqueSelector(e){if(e.id)return`#${e.id}`;if(e.getAttribute("data-testid"))return`[data-testid="${e.getAttribute("data-testid")}"]`;const t=[];let n=e;for(;n&&n!==document.body;){let e=n.tagName.toLowerCase();if(n.className&&"string"==typeof n.className){const t=n.className.split(" ").filter(e=>e&&!e.includes(" "));t.length>0&&(e+=`.${t.slice(0,2).join(".")}`)}t.unshift(e),n=n.parentElement}return t.join(" > ")}calculateSimilarity(e,t){const n=new Set(e.split(/\s+/)),r=new Set(t.split(/\s+/)),a=new Set([...n].filter(e=>r.has(e))),o=new Set([...n,...r]);return a.size/o.size}getConfig(){return this.config}async trainFromExport(e){if(e.categories){this.categories=e.categories;for(const t of e.categories)for(const e of t.keywords){const n=this.topicKeywords.get(t.name)||[];n.push(e.toLowerCase()),this.topicKeywords.set(t.name,n)}}const t=this.extractTopicsFromDocuments(e.documents);for(const[e,n]of t){const t=this.topicKeywords.get(e)||[];t.push(...n),this.topicKeywords.set(e,[...new Set(t)])}e.sitemap&&this.loadSitemapEntries(e.sitemap),console.log(`[CyberneticIntentClassifier] Trained with ${this.categories.length} categories, ${this.topicKeywords.size} topics`)}async loadSitemap(e){if(e.enabled)if(e.sitemapData)this.loadSitemapEntries(e.sitemapData);else if(e.sitemapUrl)try{const t=await fetch(e.sitemapUrl);if(!t.ok)throw new Error(`Failed to fetch sitemap: ${t.status}`);const n=await t.json();this.loadSitemapEntries(n)}catch(e){console.error("[CyberneticIntentClassifier] Failed to load sitemap:",e)}}loadSitemapEntries(e){for(const t of e){const e={path:t.url,name:t.title,description:t.description,aliases:t.keywords},n=[t.title.toLowerCase(),t.url.toLowerCase(),...(t.keywords||[]).map(e=>e.toLowerCase())];if(t.description){const e=t.description.toLowerCase().split(/\s+/).filter(e=>e.length>4);n.push(...e)}for(const t of n)this.siteMapIndex.set(t,e)}console.log(`[CyberneticIntentClassifier] Loaded ${e.length} sitemap entries`)}extractTopicsFromDocuments(e){const t=new Map;for(const n of e){const e=n.title.toLowerCase(),r=[];n.metadata?.keywords&&r.push(...n.metadata.keywords.map(e=>e.toLowerCase()));const a=n.title.toLowerCase().replace(/[^a-z0-9\s]/g,"").split(/\s+/).filter(e=>e.length>3&&!this.isStopWord(e));r.push(...a);const o=n.content.toLowerCase().replace(/[^a-z0-9\s]/g,"").split(/\s+/).filter(e=>e.length>4&&!this.isStopWord(e)),i=new Map;for(const e of o)i.set(e,(i.get(e)||0)+1);const s=[...i.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e])=>e);r.push(...s),t.set(e,[...new Set(r)])}return t}isStopWord(e){return new Set(["the","a","an","and","or","but","in","on","at","to","for","of","with","by","from","up","about","into","through","during","is","are","was","were","be","been","being","have","has","had","do","does","did","will","would","could","should","may","might","this","that","these","those","it","its","they","them","their","what","which","who","whom","when","where","why","how","all","each","every","both","few","more","most","other","some","such","no","not","only","same","so","than","too","very","can","just","dont","now","here","there","also","your","you"]).has(e)}getCategories(){return this.categories}getTopicKeywords(){return this.topicKeywords}isTrained(){return this.categories.length>0||this.topicKeywords.size>0}async initializeDiscovery(){if(this.siteMapDiscovery)try{await this.siteMapDiscovery.initialize(),this.rebuildIndexesFromDiscovery(),console.log(`[CyberneticIntentClassifier] Discovery complete, indexed ${this.siteMapIndex.size} entries`)}catch(e){console.error("[CyberneticIntentClassifier] Discovery initialization failed:",e)}else console.log("[CyberneticIntentClassifier] No siteMapConfig provided, skipping discovery")}rebuildIndexesFromDiscovery(){if(!this.siteMapDiscovery)return;const e=this.siteMapDiscovery.getLegacyEntries();this.siteMapIndex.clear();for(const t of e){const e={path:t.path,name:t.name,description:t.description,params:t.params,aliases:t.aliases},n=[t.name.toLowerCase(),t.path.toLowerCase(),...(t.aliases||[]).map(e=>e.toLowerCase())];if(t.description){const e=t.description.toLowerCase().split(/\s+/).filter(e=>e.length>4&&!this.isStopWord(e));n.push(...e)}for(const t of n)this.siteMapIndex.set(t,e)}}isSiteMapReady(){return this.siteMapDiscovery?this.siteMapDiscovery.isReady():this.siteMapIndex.size>0||(this.config.siteMap?.length??0)>0}async ensureSiteMapReady(){this.isSiteMapReady()||await this.initializeDiscovery()}async refreshSiteMap(){this.siteMapDiscovery?(await this.siteMapDiscovery.refresh(),this.rebuildIndexesFromDiscovery()):console.log("[CyberneticIntentClassifier] No siteMapConfig provided, cannot refresh")}getSiteMapDiscovery(){return this.siteMapDiscovery}getSiteMapEntries(){return this.siteMapDiscovery?this.siteMapDiscovery.getLegacyEntries():this.config.siteMap||[]}}class me{constructor(e){this.highlightOverlay=null,this.actionCount=0,this.lastActionReset=Date.now(),this.config=e,this.classifier=new pe(e),"undefined"!=typeof document&&this.injectStyles()}interpretIntent(e){return this.classifier.classify(e)}async executeAction(e){const t=Date.now();t-this.lastActionReset>6e4&&(this.actionCount=0,this.lastActionReset=t);const n=this.config.maxActionsPerTurn??5;if(this.actionCount>=n)return{success:!1,message:`Rate limit exceeded. Maximum ${n} actions per minute.`};if(!this.isActionAllowed(e))return{success:!1,message:`Action type "${e.type}" is not allowed`};switch(this.actionCount++,e.type){case"navigate":return this.navigate(e.target,e.params);case"fillForm":return this.fillForm(e.target,e.params?.value);case"clickElement":return this.clickElement(e.target);case"triggerModal":return this.triggerModal(e.target);case"scroll":return this.scrollToElement(e.target);case"highlight":return this.highlightElement(e.target);case"custom":return this.executeCustomAction(e.target,e.params);default:return{success:!1,message:`Unknown action type: ${e.type}`}}}isActionAllowed(e){const t=this.config.allowedActions;if(!t)return!0;const n={navigate:"navigate",fillForm:"fill",clickElement:"click",scroll:"scroll",highlight:"click",triggerModal:"click",custom:"click"}[e.type];return t.includes(n)}isSelectorAllowed(e){if(this.config.blockedSelectors)for(const t of this.config.blockedSelectors)if(e.includes(t))return!1;return!(this.config.allowedSelectors&&this.config.allowedSelectors.length>0)||this.config.allowedSelectors.some(t=>e.includes(t))}async navigate(e,t){try{if(!this.validateNavigationUrl(e))return{success:!1,message:"Invalid or blocked URL"};let n=e;if(t){const e=new URLSearchParams;for(const[n,r]of Object.entries(t))null!=r&&e.set(n,String(r));const r=e.toString();r&&(n+=(n.includes("?")?"&":"?")+r)}return"undefined"==typeof window?{success:!0,message:`Navigation to ${e} would be executed (server-side)`}:this.isInternalUrl(n)?this.tryClientSideNavigation(n)?{success:!0,message:`Navigated to ${e}`}:(window.location.href=n,{success:!0,message:`Navigating to ${e}...`}):(window.open(n,"_blank","noopener,noreferrer"),{success:!0,message:`Opened ${n} in new tab`})}catch(e){return{success:!1,message:"Navigation failed",error:String(e)}}}async fillForm(e,t){if(!this.isSelectorAllowed(e))return{success:!1,message:`Selector "${e}" is not allowed`};const n=this.sanitizeSelector(e);if("undefined"==typeof document)return{success:!0,message:`Form fill would set "${n}" to "${t}" (server-side)`};try{const e=document.querySelector(n);if(!e)return{success:!1,message:`Element not found: ${n}`};if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement))return{success:!1,message:"Element is not a form field"};if(e.focus(),e instanceof HTMLSelectElement){const n=Array.from(e.options).find(e=>e.value.toLowerCase()===t.toLowerCase()||e.text.toLowerCase()===t.toLowerCase());if(!n)return{success:!1,message:`Option "${t}" not found`};e.value=n.value}else e.value=t;e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0}));const r=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value")?.set;return r&&e instanceof HTMLInputElement&&(r.call(e,t),e.dispatchEvent(new Event("input",{bubbles:!0}))),{success:!0,message:`Filled field with "${t}"`}}catch(e){return{success:!1,message:"Failed to fill form field",error:String(e)}}}async clickElement(e){if(!this.isSelectorAllowed(e))return{success:!1,message:`Selector "${e}" is not allowed`};const t=this.sanitizeSelector(e);if("undefined"==typeof document)return{success:!0,message:`Click on "${t}" would be executed (server-side)`};try{const e=document.querySelector(t);return e?e instanceof HTMLElement?(e.scrollIntoView({behavior:"smooth",block:"center"}),await this.sleep(300),e.click(),{success:!0,message:"Element clicked"}):{success:!1,message:"Element is not clickable"}:{success:!1,message:`Element not found: ${t}`}}catch(e){return{success:!1,message:"Failed to click element",error:String(e)}}}async triggerModal(e){return this.clickElement(e)}async scrollToElement(e){if("undefined"==typeof window)return{success:!0,message:`Scroll to "${e}" would be executed (server-side)`};try{if("body"===e)return window.scrollTo({top:0,behavior:"smooth"}),{success:!0,message:"Scrolled to top"};if("body:last-child"===e)return window.scrollTo({top:document.body.scrollHeight,behavior:"smooth"}),{success:!0,message:"Scrolled to bottom"};const t=document.querySelector(e);return t?(t.scrollIntoView({behavior:"smooth",block:"start"}),{success:!0,message:"Scrolled to element"}):{success:!1,message:`Element not found: ${e}`}}catch(e){return{success:!1,message:"Failed to scroll",error:String(e)}}}async highlightElement(e){if(!this.isSelectorAllowed(e))return{success:!1,message:`Selector "${e}" is not allowed`};if("undefined"==typeof document)return{success:!0,message:`Highlight on "${e}" would be shown (server-side)`};try{const t=document.querySelector(e);if(!t)return{success:!1,message:`Element not found: ${e}`};this.removeHighlight(),t.scrollIntoView({behavior:"smooth",block:"center"}),await this.sleep(300);const n=t.getBoundingClientRect(),r=document.createElement("div");return r.className="astermind-highlight-overlay",r.style.cssText=`\n position: fixed;\n top: ${n.top-4}px;\n left: ${n.left-4}px;\n width: ${n.width+8}px;\n height: ${n.height+8}px;\n border: 3px solid #4F46E5;\n border-radius: 4px;\n pointer-events: none;\n z-index: 999999;\n animation: astermind-highlight-pulse 1s ease-in-out 3;\n `,document.body.appendChild(r),this.highlightOverlay=r,setTimeout(()=>this.removeHighlight(),3e3),{success:!0,message:"Element highlighted"}}catch(e){return{success:!1,message:"Failed to highlight element",error:String(e)}}}async executeCustomAction(e,t){if(!this.isAllowedCustomAction(e))return{success:!1,message:`Custom action "${e}" not found`};const n=this.config.customActions[e];try{return await n(t)}catch(t){return{success:!1,message:`Custom action "${e}" failed`,error:String(t)}}}isInternalUrl(e){if(e.startsWith("/")||e.startsWith("./")||e.startsWith("../"))return!0;if("undefined"==typeof window)return!0;try{return new URL(e,window.location.href).origin===window.location.origin}catch{return!0}}tryClientSideNavigation(e){if("undefined"==typeof window)return!1;try{return window.history.pushState({},"",e),window.dispatchEvent(new PopStateEvent("popstate")),e.includes("#")&&window.dispatchEvent(new HashChangeEvent("hashchange")),!0}catch{return!1}}validateNavigationUrl(e){if(/^(javascript|data):/i.test(e))return!1;if("undefined"==typeof window)return!0;try{return new URL(e,window.location.href).origin===window.location.origin||e.startsWith("/")}catch{return e.startsWith("/")}}sanitizeSelector(e){return e.replace(/[<>'"]/g,"").replace(/javascript:/gi,"").replace(/data:/gi,"").trim()}isAllowedCustomAction(e){return void 0!==this.config.customActions&&Object.prototype.hasOwnProperty.call(this.config.customActions,e)}removeHighlight(){this.highlightOverlay&&(this.highlightOverlay.remove(),this.highlightOverlay=null)}injectStyles(){if("undefined"==typeof document)return;if(document.getElementById("astermind-agent-styles"))return;const e=document.createElement("style");e.id="astermind-agent-styles",e.textContent="\n @keyframes astermind-highlight-pulse {\n 0%, 100% {\n box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.4);\n }\n 50% {\n box-shadow: 0 0 0 10px rgba(79, 70, 229, 0);\n }\n }\n\n .astermind-highlight-overlay {\n transition: all 0.2s ease-out;\n }\n ",document.head.appendChild(e)}sleep(e){return new Promise(t=>setTimeout(t,e))}getConfig(){return this.config}getClassifier(){return this.classifier}resetActionCount(){this.actionCount=0,this.lastActionReset=Date.now()}}const ge={hiddenUnits:50,activation:"relu",ridgeLambda:.01,weightInit:"xavier",seed:1337,dropout:0,log:{verbose:!0,toFile:!1,modelName:"Unnamed ELM Model",level:"info"}};function ye(e){let t=0,n=0;for(;0===t;)t=e();for(;0===n;)n=e();return Math.sqrt(-2*Math.log(t))*Math.cos(2*Math.PI*n)}Object.assign(Object.assign({},ge),{useTokenizer:!1}),Object.assign(Object.assign({},ge),{useTokenizer:!0,maxLen:30,charSet:"abcdefghijklmnopqrstuvwxyz",tokenizerDelimiter:/\s+/});class ve{constructor(e,t,n=1e-4){this.p=e,this.m=t,this.lambda=n,this.Ainv=new Float64Array(e*e),this.Beta=new Float64Array(e*t);const r=1/Math.max(1e-12,n);for(let t=0;t<e;t++)this.Ainv[t*e+t]=r}update(e,t){const{p:n,m:r,Ainv:a,Beta:o}=this,i=new Float64Array(n);for(let t=0;t<n;t++){let r=0,o=t*n;for(let t=0;t<n;t++)r+=a[o+t]*e[t];i[t]=r}let s=1;for(let t=0;t<n;t++)s+=e[t]*i[t];s=Math.max(s,1e-12);const l=1/s;for(let e=0;e<n;e++){const t=i[e]*l;for(let r=0;r<n;r++)a[e*n+r]-=t*i[r]}for(let t=0;t<n;t++){let r=0,o=t*n;for(let t=0;t<n;t++)r+=a[o+t]*e[t];i[t]=r}for(let e=0;e<n;e++){const n=i[e];for(let a=0;a<r;a++)o[e*r+a]+=n*t[a]}}predict(e){const{p:t,m:n,Beta:r}=this,a=new Float64Array(n);for(let o=0;o<n;o++){let i=0;for(let a=0;a<t;a++)i+=e[a]*r[a*n+o];a[o]=i}return a}}function be(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n]*e[n];return Math.sqrt(Math.max(0,t))}function we(e,t){var n,r;const a=Math.min(e.length,t.length);if(0===a)return 0;let o=0,i=0,s=0;for(let l=0;l<a;l++){const a=null!==(n=e[l])&&void 0!==n?n:0,c=null!==(r=t[l])&&void 0!==r?r:0;o+=a*c,i+=a*a,s+=c*c}const l=o/Math.sqrt(Math.max(i*s,1e-12));return Number.isFinite(l)?l:0}function Se(e,t,n,r){return new(n||(n=Promise))(function(a,o){function i(e){try{l(r.next(e))}catch(e){o(e)}}function s(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(i,s)}l((r=r.apply(e,t||[])).next())})}function ke(e){return e.replace(/\s+/g," ").split(/(?<=[.?!])\s+/).map(e=>e.trim()).filter(e=>e.length>8&&/\w/.test(e))}function xe(e){return e.replace(/```[\s\S]*?```/g," ").replace(/`[^`]+`/g," ").replace(/\[[^\]]*\]\([^)]*\)/g,"").replace(/[-–>•→]/g," ").replace(/\s+/g," ").trim()}function Ce(e,t){return Se(this,arguments,void 0,function*(e,t,n={}){if(!(null==t?void 0:t.length))return"No results found.";const{dim:r=64,features:a=32,sigma:o=1,rounds:i=3,topSentences:s=8,personality:l="neutral"}=n;let c=ke(t.map(e=>xe(e.content)).join(" ")).filter(e=>!function(e){return/^(\*|#)/.test(e)||/chapter/i.test(e)||/part\s*\d+/i.test(e)||/section/i.test(e)||/^\s*[A-Z]\)\s*$/.test(e)||e.length<15}(e)).slice(0,120);if(0===c.length)return xe(t[0].content).slice(0,400);const u=function(e,t,n=1,r=Math.random){const a=new Float64Array(t*e),o=new Float64Array(t),i=1/Math.max(1e-12,n);for(let n=0;n<t*e;n++)a[n]=ye(r)*i;for(let e=0;e<t;e++)o[e]=2*r()*Math.PI;return{W:a,b:o,D:t,d:e,sigma:n}}(r,a,o),d=new ve(2*a,1,.001),f=e=>{const t=new Float64Array(r),n=Math.min(e.length,r);for(let r=0;r<n;r++)t[r]=e.charCodeAt(r)/255;return function(e,t){const{W:n,b:r,D:a,d:o}=e,i=new Float64Array(2*a);for(let e=0;e<a;e++){let s=r[e];const l=e*o;for(let e=0;e<o;e++)s+=n[l+e]*(t[e]||0);i[e]=Math.cos(s),i[a+e]=Math.sin(s)}let s=0;for(let e=0;e<i.length;e++)s+=i[e]*i[e];const l=1/Math.sqrt(Math.max(s,1e-12));for(let e=0;e<i.length;e++)i[e]*=l;return i}(u,function(e,t=1e-12){const n=be(e);if(!(n>t&&Number.isFinite(n)))return new Float64Array(e.length);const r=new Float64Array(e.length),a=1/n;for(let t=0;t<e.length;t++)r[t]=e[t]*a;return r}(t))},h=f(e),p=e.toLowerCase().split(/\W+/).filter(e=>e.length>2),m=c.map(e=>{const t=f(e);let n=we(t,h);const r=e.toLowerCase();for(const e of p)r.includes(e)&&(n+=.02);return{s:e,v:t,w:n}});m.sort((e,t)=>t.w-e.w);let g=m.slice(0,s).map(e=>e.s).join(" "),y=new Float64Array(2*a);for(let e=0;e<i;e++){const e=ke(g).slice(0,s),t=e.map(e=>f(e)),n=t.map(e=>we(e,h));for(let e=0;e<t.length;e++)d.update(t[e],new Float64Array([n[e]]));y.fill(0);for(let e=0;e<t.length;e++){const r=t[e],a=n[e];for(let e=0;e<r.length;e++)y[e]+=r[e]*a}const r=be(y)||1;for(let e=0;e<y.length;e++)y[e]/=r;const a=e.map(e=>({s:e,w:we(f(e),y)}));a.sort((e,t)=>t.w-e.w),g=a.slice(0,Math.max(3,Math.floor(s/2))).map(e=>e.s).join(" ")}g=function(e){return e.replace(/\s+[-–>•→]\s+/g," ").replace(/\s+\.\s+/g,". ").replace(/([a-z]) - ([a-z])/gi,"$1-$2").replace(/\s{2,}/g," ").trim()}(g);return`${"teacher"===l?"Here’s a simple way to think about it:\n\n":"scientist"===l?"From the retrieved material, we can infer:\n\n":""}${g.charAt(0).toUpperCase()+g.slice(1)}\n\n(${t[0].heading||"Answer"}, Ω-synthesized)`})}function Ee(e,t){let n=0;for(let r=0;r<e.length;r++)n+=e[r]*t[r];return n}function _e(e,t,n,r){if("cosine"===n){const n=Ee(e,t),r=Math.hypot(...e),a=Math.hypot(...t);return r&&a?n/(r*a):0}if("poly2"===n){const n=Ee(e,t);return Math.pow(n+1,2)}{let n=0;for(let r=0;r<e.length;r++){const a=e[r]-t[r];n+=a*a}return Math.exp(-n/Math.max(1e-9,2*r*r))}}function Me(e,t,n,r,a){const o=function(e,t){const n=new Float64Array(t);for(const[t,r]of e)n[t]=r;return n}(e,t),i=new Float64Array(n.length);for(let e=0;e<n.length;e++){const t=n[e];i[e]=_e(o,t,r,a)}const s=Math.hypot(...i);if(s>0)for(let e=0;e<i.length;e++)i[e]/=s;return i}"function"==typeof SuppressedError&&SuppressedError;const Re=new Map;function Ae(e){const t=e,n=Re.get(t);if(n)return n;let r=e.toLowerCase();if(r=r.replace(/^[^a-z0-9]+|[^a-z0-9]+$/g,""),r.length<=2)return Re.set(t,r),r;r.endsWith("ies")&&r.length>4?r=r.slice(0,-3)+"y":/(xes|ches|shes|zes|sses)$/.test(r)&&r.length>4?r=r.replace(/(xes|ches|shes|zes|sses)$/,e=>"sses"===e?"ss":e.replace(/es$/,"")):r.endsWith("s")&&!/(ss|us)$/.test(r)&&r.length>3&&(r=r.slice(0,-1));const a=[[/ization$|isation$/,"ize"],[/ational$/,"ate"],[/fulness$/,"ful"],[/ousness$/,"ous"],[/iveness$/,"ive"],[/ability$/,"able"],[/ness$/,""],[/ment$/,""],[/ations?$/,"ate"],[/izer$|iser$/,"ize"],[/ally$/,"al"],[/ically$/,"ic"],[/ingly$|edly$/,""],[/ing$|ed$/,""]];for(const[e,t]of a)if(e.test(r)&&r.length-t.length>=4){r=r.replace(e,t);break}return Re.set(t,r),r}function Ie(e,t){const n=Array.from(e,(e,t)=>t);return n.sort((t,n)=>e[n]-e[t]),n.slice(0,t)}function Pe(e){const{query:t,chunks:n,vocabMap:r,idf:a,tfidfDocs:o,denseDocs:i,landmarksIdx:s,landmarkMat:l,vocabSize:c,kernel:u,sigma:d,alpha:f,beta:h,ridge:p,headingW:m,useStem:g,expandQuery:y,topK:v,prefilter:b}=e,w=function(e,t,n,r=1){const a=new Map;for(let t=0;t<e.length;t++){const o=e[t],i=n.get(o);if(void 0===i)continue;const s=t<8?r:1;a.set(i,(a.get(i)||0)+s)}const o=Math.max(1,...a.values()),i=new Map;for(const[e,n]of a){const r=.5+n/o*.5;i.set(e,r*(t[e]||0))}return i}(function(e,t){const n=e.toLowerCase().replace(/[`*_>~]/g," ").replace(/[^a-z0-9]+/g," ").split(/\s+/).filter(Boolean);if(!t)return n;const r=[];for(const e of n){const t=Ae(e);t&&t.length>1&&r.push(t)}return r}(y?function(e){const t=[];return/\bmap\b/.test(e)&&t.push("dict key value make"),/\bchan|channel\b/.test(e)&&t.push("goroutine concurrency select buffer"),/\berror\b/.test(e)&&t.push("fmt wrap unwrap sentinel try catch"),/\bstruct\b/.test(e)&&t.push("field method receiver init zero value"),e+" "+t.join(" ")}(t):t,g),a,r,m),S=Me(w,c,l,u,d),k=o.map(e=>function(e,t){let n=0,r=0,a=0;for(const[a,o]of e){r+=o*o;const e=t.get(a);e&&(n+=o*e)}for(const[,e]of t)a+=e*e;return r&&a?n/(Math.sqrt(r)*Math.sqrt(a)):0}(e,w)),x=i.map(e=>function(e,t,n,r){if("cosine"===n){const n=Ee(e,t),r=Math.hypot(...e),a=Math.hypot(...t);return r&&a?n/(r*a):0}if("poly2"===n){const n=Ee(e,t);return Math.pow(n+1,2)}{let n=0;for(let r=0;r<e.length;r++){const a=e[r]-t[r];n+=a*a}return Math.exp(-n/Math.max(1e-9,2*r*r))}}(e,S,u,d)),C=function(e,t){const n=Array.from(new Set(t.toLowerCase().split(/\W+/).filter(e=>e.length>2))),r=/\b(define|declare|syntax|example|function|struct|map|interface)\b/i.test(t);return e.map(e=>{const t=e.rich||e.content||"",a=t.toLowerCase();let o=0;for(const e of n)a.includes(e)&&o++;return r&&/```/.test(t)&&(o+=5),Math.min(1,.03*o)})}(n,t),E=(_=f,M=0,R=1,Math.max(M,Math.min(R,_)));var _,M,R;const A=null!=p?p:.08,I=x.map((e,t)=>{const n=k[t],r=h*C[t],a=1/(1+A*(e*e+n*n+.5*r*r))*(E*e+(1-E)*n+r);return Math.tanh(a)}),P=Math.max(v,null!=b?b:0),T=Ie(I,P),L=Ie(T.map(e=>I[e]),v).map(e=>T[e]);return{items:L.map(e=>{const t=n[e],r=t.rich&&t.rich.trim()||t.content&&t.content.trim()||"(see subsections)";return{score:I[e],heading:t.heading,content:r,index:e}}),scores:L.map(e=>I[e]),indices:L,tfidfScores:L.map(e=>k[e]),denseScores:L.map(e=>x[e])}}const Te=new Set(["a","an","the","and","or","but","if","then","else","for","to","of","in","on","at","by","with","is","are","was","were","be","been","being","as","from","that","this","it","its","you","your","i","we","they","he","she","them","his","her","our","us","do","does","did","done","not","no","yes","can","could","should","would","may","might","into","about","over","under","between"]);function Le(e){return e.toLowerCase().replace(/[`*_#>~=\[\]{}()!?.:,;'"<>|/\\+-]+/g," ").split(/\s+/).filter(e=>e&&!Te.has(e))}function Ne(e){const t=new Map,n=[],r=[];let a=0;for(const o of e){const e=Le(o);r.push(e.length);const i=new Map;for(const n of e){let e=t.get(n);void 0===e&&(e=a++,t.set(n,e)),i.set(e,(i.get(e)||0)+1)}n.push(i)}const o=e.length,i=Array(a).fill(0);for(const e of n)for(const t of e.keys())i[t]+=1;return{stats:{vocab:t,idf:i.map(e=>Math.log((o+1)/(e+1))+1),avgLen:r.reduce((e,t)=>e+t,0)/Math.max(1,o),df:i},tf:n,docLens:r}}function De(e,t){const n=new Map;let r=0;for(const[a,o]of e){const e=o*(t[a]||0);n.set(a,e),r+=e*e}const a=Math.sqrt(r)||1e-12;for(const[e,t]of n)n.set(e,t/a);return n}function ze(e,t){const[n,r]=e.size<t.size?[e,t]:[t,e];let a=0;for(const[e,t]of n){const n=r.get(e);void 0!==n&&(a+=t*n)}return a}function Fe(e,t,n=1337){const r=new Float64Array(t);for(const[n,a]of e){let e=2654435761*n>>>0;for(let n=0;n<t;n++){e^=e<<13,e^=e>>>17,e^=e<<5;const t=(e>>>0)/4294967296*2-1;r[n]+=a*t}}let a=0;for(let e=0;e<t;e++)a+=r[e]*r[e];const o=Math.sqrt(a)||1e-12;for(let e=0;e<t;e++)r[e]/=o;return r}function Oe(e){return/```+\s*go([\s\S]*?)```/i.test(e)||/\bfunc\s+\w+\s*\(.*\)\s*\w*\s*{/.test(e)}function $e(e){return/```+/.test(e)||/{[^}]*}/.test(e)}function je(e,t){const n=(r=Le(e),Array.from(new Set(r)));var r;const a=new Set(Le(t));if(0===n.length||0===a.size)return 0;let o=0;for(const e of n)a.has(e)&&o++;return o/n.length}function Ue(e,t,n,r,a,o,i,s,l,c){var u;const d=[],f=[],h=ze(n,r);d.push(h),f.push("cosine_tfidf");const p=function(e,t,n,r,a=1.5,o=.75){let i=0;for(const[s]of e){const e=t.get(s)||0;e<=0||(i+=Math.log(((n.df[s]||0)+.5)/(n.idf.length-(n.df[s]||0)+.5)+1)*(e*(a+1)/(e+a*(1-o+o*(r/(n.avgLen||1)))||1e-12)))}return i}(a,o,i,s);d.push(p),f.push("bm25");const m=je(t.heading||"",e);d.push(m),f.push("heading_match_frac");const g=function(e,t){const n=new Set(Le(e)),r=new Set(Le(t));let a=0;for(const e of n)r.has(e)&&a++;const o=n.size+r.size-a;return 0===o?0:a/o}(e,t.content||"");d.push(g),f.push("jaccard_tokens");const y=Oe(t.rich||t.content||""),v=$e(t.rich||t.content||"");var b;d.push(y?1:0),f.push("flag_go_code"),d.push(v?1:0),f.push("flag_any_code"),d.push((b=t.content||"",!/(golang\.org|go\.dev|pkg\.go\.dev)/i.test(b)?0:1)),f.push("flag_go_spec_link"),d.push(null!==(u=t.score_base)&&void 0!==u?u:0),f.push("prior_score_base");const w=(t.content||"").length;if(d.push(1/Math.sqrt(1+w)),f.push("len_inv_sqrt"),l&&c){let e=0,t=0;for(let n=0;n<l.length;n++)e+=l[n]*c[n],t+=Math.abs(l[n]-c[n]);d.push(e),f.push("proj_dot"),d.push(t/l.length),f.push("proj_l1mean")}return{names:f,values:d}}class Be{constructor(){this.w=null,this.mu=null,this.sigma=null}fit(e,t,n=.01){var r;const a=e.length,o=(null===(r=e[0])||void 0===r?void 0:r.length)||0;if(0===a||0===o)return void(this.w=new Float64Array(o));const i=new Float64Array(o),s=new Float64Array(o);for(let t=0;t<o;t++){let n=0;for(let r=0;r<a;r++)n+=e[r][t];n/=a,i[t]=n;let r=0;for(let o=0;o<a;o++){const a=e[o][t]-n;r+=a*a}s[t]=Math.sqrt(r/a)||1}const l=Array.from({length:a},(e,t)=>new Float64Array(o));for(let t=0;t<a;t++)for(let n=0;n<o;n++)l[t][n]=(e[t][n]-i[n])/s[n];const c=Array.from({length:o},()=>new Float64Array(o)),u=new Float64Array(o);for(let e=0;e<a;e++){const n=l[e],r=t[e];for(let e=0;e<o;e++){u[e]+=n[e]*r;const t=n[e];for(let r=0;r<=e;r++)c[e][r]+=t*n[r]}}for(let e=0;e<o;e++){for(let t=0;t<e;t++)c[t][e]=c[e][t];c[e][e]+=n}const d=Array.from({length:o},()=>new Float64Array(o));for(let e=0;e<o;e++)for(let t=0;t<=e;t++){let n=c[e][t];for(let r=0;r<t;r++)n-=d[e][r]*d[t][r];d[e][t]=e===t?Math.sqrt(Math.max(n,1e-12)):n/(d[t][t]||1e-12)}const f=new Float64Array(o);for(let e=0;e<o;e++){let t=u[e];for(let n=0;n<e;n++)t-=d[e][n]*f[n];f[e]=t/(d[e][e]||1e-12)}const h=new Float64Array(o);for(let e=o-1;e>=0;e--){let t=f[e];for(let n=e+1;n<o;n++)t-=d[n][e]*h[n];h[e]=t/(d[e][e]||1e-12)}this.w=h,this.mu=i,this.sigma=s}predict(e){if(!this.w||!this.mu||!this.sigma)return 0;let t=0;for(let n=0;n<this.w.length;n++){const r=(e[n]-this.mu[n])/this.sigma[n];t+=this.w[n]*r}return t}}function Ve(e,t,n){var r;const a=t.rich||t.content||"";let o=0;/\bgo\b/.test(e.toLowerCase())&&/(define|declare|function|func)/i.test(e)&&Oe(a)&&(o=Math.max(o,1));je(t.heading||"",e)>=.34&&$e(a)&&(o=Math.max(o,.8));const i=n.names.indexOf("cosine_tfidf"),s=n.names.indexOf("bm25"),l=i>=0?n.values[i]:0,c=s>=0?n.values[s]:0;l>.25&&(o=Math.max(o,.6)),c>1&&(o=Math.max(o,.6));const u=n.names.indexOf("prior_score_base"),d=u>=0?n.values[u]:0;return(null!==(r=t.score_base)&&void 0!==r?r:0)>0&&(o=Math.max(o,Math.min(.6,.2+.5*d))),o}function We(e,t,n={}){var r,a;const{lambdaRidge:o=.01,randomProjDim:i=32,exposeFeatures:s=!0,attachFeatureNames:l=!1}=n,c=[e,...t.map(e=>e.content||"")],{stats:u,tf:d,docLens:f}=Ne(c),h=d.map(e=>De(e,u.idf)),p=d[0],m=h[0],g=i>0?Fe(m,i):void 0,y=[],v=[],b=[];for(let n=0;n<t.length;n++){const r=t[n],a=d[n+1],o=h[n+1],s=i>0?Fe(o,i,1337+n):void 0,l=Ue(e,r,m,o,p,a,u,f[n+1]||1,g,s);b.push(l),y.push(l.values);const c=Ve(e,r,l);v.push(c)}if(v.every(e=>Math.abs(e-v[0])<1e-9)){const e=b[0].names.indexOf("cosine_tfidf");if(e>=0)for(let t=0;t<v.length;t++)v[t]=Math.max(0,Math.min(1,.2+.6*y[t][e]))}const w=new Be;w.fit(y,v,o);let S=1/0,k=-1/0;const x=y.map(e=>w.predict(e));for(const e of x)e<S&&(S=e),e>k&&(k=e);const C=Math.max(1e-9,k-S),E=l?null!==(a=null===(r=b[0])||void 0===r?void 0:r.names)&&void 0!==a?a:[]:void 0,_=t.map((e,t)=>{const n=(x[t]-S)/C,r=function(e){if(e>=0)return 1/(1+Math.exp(-e));{const t=Math.exp(e);return t/(1+t)}}((x[t]-.5*(S+k))/(.2*C+1e-6)),a=Object.assign(Object.assign({},e),{score_rr:n,p_relevant:r});return s&&(a._features=y[t]),E&&(a._feature_names=E),a});return _.sort((e,t)=>t.score_rr-e.score_rr),_}function He(e,t={}){const{probThresh:n=.45,epsilonTop:r=.05,useMMR:a=!0,mmrLambda:o=.7,budgetChars:i=1200}=t;if(0===e.length)return[];const s=e[0].score_rr,l=e.filter(e=>e.p_relevant>=n&&e.score_rr>=s-r),c=l.length>0?l:[e[0]];if(!a){const e=[];let t=0;for(const n of c){const r=(n.content||"").length;if(t+r>i&&e.length>0)break;e.push(n),t+=r}return e}return function(e,t=.7,n=1200){const r=[],a=e.map(e=>e.content||""),{stats:o,tf:i}=Ne(a),s=i.map(e=>De(e,o.idf)),l=new Set;let c=0;for(;l.size<e.length;){let a=-1,o=-1/0;for(let n=0;n<e.length;n++){if(l.has(n))continue;const r=e[n];let i=0;for(const e of l){const t=ze(s[n],s[e]);t>i&&(i=t)}const c=t*r.score_rr-(1-t)*i;c>o&&(o=c,a=n)}if(a<0)break;const i=e[a],u=(i.content||"").length;if(c+u>n&&r.length>0)break;r.push(i),c+=u,l.add(a)}return r}(e.map(e=>Object.assign(Object.assign({},e),{score_rr:c.includes(e)?e.score_rr+.01:e.score_rr})),o,i)}var Ke=Object.freeze({__proto__:null,OmegaOfflineRAG:class{constructor(e){this.modelState=null,this.model=null,this.config={reranking:{enabled:e?.reranking?.enabled??!0,lambdaRidge:e?.reranking?.lambdaRidge??.1,useMMR:e?.reranking?.useMMR??!0,mmrLambda:e?.reranking?.mmrLambda??.5,probThresh:e?.reranking?.probThresh??.1},topK:e?.topK??5,verbose:e?.verbose??!1}}async loadModel(e){const t=performance.now();if(this.model=e,this.modelState=function(e){if("astermind-pro-v1"!==e.version&&"astermind-elm-v1"!==e.version)throw new Error(`Unsupported model version: ${e.version}. Expected 'astermind-pro-v1' or 'astermind-elm-v1'`);const t=JSON.parse(JSON.stringify(e.settings||{})),n=new Map(e.vocab),r=Float64Array.from(e.idf),a=e.chunks.map(e=>({heading:e.heading,content:e.content||"",rich:e.rich,level:e.level,secId:e.secId})),o=e.tfidfDocs.map(e=>{const t=new Map;for(const[n,r]of e)t.set(n,r);return t}),i=Array.from(e.landmarksIdx),s=e.landmarkMat.map(e=>Float64Array.from(e));let l;if(!e.denseDocs||e.denseDocs.length!==o.length)throw new Error("recomputeDense=true but buildDense function not provided");return l=e.denseDocs.map(e=>Float64Array.from(e)),{settings:t,vocabMap:n,idf:r,chunks:a,tfidfDocs:o,landmarksIdx:i,landmarkMat:s,denseDocs:l}}(e),this.config.verbose){const e=performance.now()-t;console.log(`[OmegaOfflineRAG] Model loaded in ${e.toFixed(0)}ms`),console.log(`[OmegaOfflineRAG] ${this.modelState.chunks.length} chunks, ${this.modelState.vocabMap.size} vocab`)}}async loadModelFromUrl(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch model from ${e}: ${t.status}`);const n=await t.json();await this.loadModel(n)}isReady(){return null!==this.modelState}getModelInfo(){return this.model&&this.modelState?{version:this.model.version,savedAt:this.model.savedAt,documentCount:this.modelState.chunks.length,vocabularySize:this.modelState.vocabMap.size,landmarkCount:this.modelState.landmarksIdx.length,hasDenseVectors:this.modelState.denseDocs.length>0,settings:this.model.settings}:null}async ask(e){const t=performance.now();if(!this.modelState||!this.model)return{answer:"Omega model not loaded. Please load a model first.",confidence:"none",sources:[],processingTime:0,degraded:!0,degradedReason:"Model not loaded"};try{const n=this.model.settings,r=n.kernel??"rbf",a=n.sigma??1,o=n.alpha??.5,i=n.beta??.3,s=n.ridge??.001,l=n.headingW??.2,c=n.useStem??!0,u=n.expandQuery??!1,d=n.prefilter??100,f=Pe({query:e,chunks:this.modelState.chunks,vocabMap:this.modelState.vocabMap,idf:this.modelState.idf,tfidfDocs:this.modelState.tfidfDocs,denseDocs:this.modelState.denseDocs,landmarksIdx:this.modelState.landmarksIdx,landmarkMat:this.modelState.landmarkMat,vocabSize:this.modelState.vocabMap.size,kernel:r,sigma:a,alpha:o,beta:i,ridge:s,headingW:l,useStem:c,expandQuery:u,topK:2*this.config.topK,prefilter:d});let h;if(this.config.reranking.enabled&&f.items.length>0){const t=function(e,t,n={}){return He(We(e,t,n),n)}(e,f.items.map((e,t)=>({heading:e.heading,content:e.content,rich:e.rich,score_base:f.scores[t]})),{lambdaRidge:this.config.reranking.lambdaRidge,useMMR:this.config.reranking.useMMR,mmrLambda:this.config.reranking.mmrLambda,probThresh:this.config.reranking.probThresh});h=t.slice(0,this.config.topK).map(e=>({heading:e.heading,content:e.content,rich:e.rich,score:e.score_base??0,rerankScore:e.score_rr,probability:e.p_relevant}))}else h=f.items.slice(0,this.config.topK).map((e,t)=>({heading:e.heading,content:e.content,rich:e.rich,score:f.scores[t]}));const p=await Ce(e,h.map(e=>({heading:e.heading,content:e.content,score:e.score}))),m=performance.now()-t,g=h[0]?.score??0,y=this.determineConfidence(g,h.length);return{answer:p,confidence:y,sources:h,processingTime:m,degraded:!1,queryClassification:this.classifyQuery(e)}}catch(e){const n=performance.now()-t;return console.error("[OmegaOfflineRAG] Error during retrieval:",e),{answer:"An error occurred while processing your question offline.",confidence:"none",sources:[],processingTime:n,degraded:!0,degradedReason:e instanceof Error?e.message:"Unknown error"}}}async retrieve(e,t){if(!this.modelState||!this.model)return[];const n=t??this.config.topK,r=this.model.settings,a=r.kernel??"rbf",o=r.sigma??1,i=r.alpha??.5,s=r.beta??.3,l=r.ridge??.001,c=r.headingW??.2,u=r.useStem??!0,d=r.expandQuery??!1,f=r.prefilter??100,h=Pe({query:e,chunks:this.modelState.chunks,vocabMap:this.modelState.vocabMap,idf:this.modelState.idf,tfidfDocs:this.modelState.tfidfDocs,denseDocs:this.modelState.denseDocs,landmarksIdx:this.modelState.landmarksIdx,landmarkMat:this.modelState.landmarkMat,vocabSize:this.modelState.vocabMap.size,kernel:a,sigma:o,alpha:i,beta:s,ridge:l,headingW:c,useStem:u,expandQuery:d,topK:n,prefilter:f});return h.items.map((e,t)=>({heading:e.heading,content:e.content,rich:e.rich,score:h.scores[t]}))}classifyQuery(e){const t=e.toLowerCase(),n=t.split(/\s+/),r=["what","who","when","where","which","is","are","was","were"],a=["how","steps","guide","tutorial","process","procedure"],o=["why","explain","describe","meaning","definition","concept"],i=["go to","navigate","find","page","link","take me","show me"];let s="unknown",l=.5;const c=[];for(const e of i)if(t.includes(e)){s="navigational",l=.8,c.push(e);break}if("unknown"===s){const e=n[0];a.includes(e)||a.some(e=>t.includes(e))?(s="procedural",l=.7,c.push(...a.filter(e=>t.includes(e)))):o.includes(e)||o.some(e=>t.includes(e))?(s="conceptual",l=.7,c.push(...o.filter(e=>t.includes(e)))):r.includes(e)&&(s="factual",l=.7,c.push(e))}return{type:s,confidence:l,keywords:c}}determineConfidence(e,t){return 0===t?"none":e>=.7||e>=.4?"medium":"low"}clear(){this.modelState=null,this.model=null}}});function qe({onClick:e,position:t,unreadCount:n=0}){return R.jsxs("button",{className:`astermind-bubble astermind-bubble--${t}`,onClick:e,"aria-label":"Open chat",type:"button",children:[R.jsx("svg",{className:"astermind-bubble__icon",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:R.jsx("path",{d:"M21 11.5C21.0034 12.8199 20.6951 14.1219 20.1 15.3C19.3944 16.7118 18.3098 17.8992 16.9674 18.7293C15.6251 19.5594 14.0782 19.9994 12.5 20C11.1801 20.0035 9.87812 19.6951 8.7 19.1L3 21L4.9 15.3C4.30493 14.1219 3.99656 12.8199 4 11.5C4.00061 9.92179 4.44061 8.37488 5.27072 7.03258C6.10083 5.69028 7.28825 4.6056 8.7 3.90003C9.87812 3.30496 11.1801 2.99659 12.5 3.00003H13C15.0843 3.11502 17.053 3.99479 18.5291 5.47089C20.0052 6.94699 20.885 8.91568 21 11V11.5Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),n>0&&R.jsx("span",{className:"astermind-bubble__badge",children:n})]})}function Ge({title:e,subtitle:t,onClose:n,children:r}){return R.jsxs("div",{className:"astermind-header",children:[R.jsxs("div",{className:"astermind-header__info",children:[R.jsx("h3",{className:"astermind-header__title",children:e}),t&&R.jsx("p",{className:"astermind-header__subtitle",children:t})]}),R.jsxs("div",{className:"astermind-header__actions",children:[r,R.jsx("button",{className:"astermind-header__close",onClick:n,"aria-label":"Close chat",type:"button",children:R.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:R.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]})]})}function Qe(e){if(!e)return"";return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/`(.+?)`/g,"<code>$1</code>").replace(/\[(.+?)\]\((.+?)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>').replace(/\n/g,"<br />")}function Ye(){return R.jsxs("svg",{className:"astermind-source__icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[R.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),R.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function Xe(){return R.jsxs("svg",{className:"astermind-source__icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[R.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),R.jsx("polyline",{points:"7 10 12 15 17 10"}),R.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}function Je({source:e,showSummaryButton:t,showDownloadButton:n,onViewSummary:r,onDownload:a}){const[o,i]=p.useState(!1);return R.jsxs("div",{className:"astermind-source",children:[R.jsxs("div",{className:"astermind-source__header",children:[R.jsx("span",{className:"astermind-source__title",children:e.documentName||e.title}),R.jsxs("div",{className:"astermind-source__actions",children:[t&&R.jsx("button",{className:"astermind-source__action-btn",onClick:t=>{t.stopPropagation(),e.fullContent&&i(!o),r?.(e)},title:"View summary","aria-label":"View source summary",children:R.jsx(Ye,{})}),n&&R.jsx("button",{className:"astermind-source__action-btn",onClick:t=>{t.stopPropagation(),a?.(e)},title:"Download source","aria-label":"Download source file",children:R.jsx(Xe,{})}),R.jsxs("span",{className:"astermind-source__relevance",children:[Math.round(100*e.relevance),"%"]})]})]}),R.jsx("p",{className:"astermind-source__snippet",children:e.snippet}),o&&e.fullContent&&R.jsx("div",{className:"astermind-source__full-content",dangerouslySetInnerHTML:{__html:Qe(e.fullContent)}})]})}function Ze({sources:e,config:t={},isOnline:n=!0,onViewSummary:r,onDownload:a}){const{enabled:o=!0,showSummary:i=!0,showDownload:s=!0}=t;return o&&0!==e.length?R.jsx("div",{className:"astermind-sources",children:e.map((e,t)=>{const o=i&&!!e.fullContent,l=s&&n&&!!e.downloadUrl;return R.jsx(Je,{source:e,showSummaryButton:o,showDownloadButton:l,onViewSummary:r,onDownload:a},e.chunkId||e.documentId||t)})}):null}function et(e){const t=new Date,n=t.getTime()-e.getTime();if(n<6e4)return"Just now";if(n<36e5){return`${Math.floor(n/6e4)}m ago`}return e.toDateString()===t.toDateString()?e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):e.toLocaleDateString([],{month:"short",day:"numeric"})}function tt({message:e,sourceConfig:t,isOnline:n=!0,onViewSourceSummary:r,onDownloadSource:a}){const[o,i]=p.useState(!1);return R.jsxs("div",{className:`astermind-message astermind-message--${e.role}`,children:[R.jsx("div",{className:"astermind-message__bubble",children:e.isStreaming&&!e.content?R.jsxs("span",{className:"astermind-message__typing",children:[R.jsx("span",{}),R.jsx("span",{}),R.jsx("span",{})]}):R.jsx("div",{className:"astermind-message__content",dangerouslySetInnerHTML:{__html:Qe(e.content)}})}),R.jsxs("div",{className:"astermind-message__meta",children:[R.jsx("span",{className:"astermind-message__time",children:et(e.timestamp)}),e.offline&&R.jsx("span",{className:"astermind-message__offline",title:"Offline response",children:"offline"}),e.confidence&&"high"!==e.confidence&&R.jsx("span",{className:`astermind-message__confidence astermind-message__confidence--${e.confidence}`,title:`Confidence: ${e.confidence}`,children:e.confidence})]}),e.sources&&e.sources.length>0&&R.jsxs("div",{className:"astermind-message__sources",children:[R.jsxs("button",{className:"astermind-message__sources-toggle",onClick:()=>i(!o),type:"button",children:[o?"Hide":"Show"," sources (",e.sources.length,")"]}),o&&R.jsx(Ze,{sources:e.sources,config:t,isOnline:n,onViewSummary:r,onDownload:a})]})]})}function nt(){return R.jsxs("div",{className:"astermind-typing",children:[R.jsx("span",{}),R.jsx("span",{}),R.jsx("span",{})]})}function rt({messages:e,isProcessing:t,sourceConfig:n,isOnline:r=!0,onViewSourceSummary:a,onDownloadSource:o}){const i=p.useRef(null);return p.useEffect(()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight)},[e,t]),R.jsxs("div",{className:"astermind-messages",ref:i,children:[e.map(e=>R.jsx(tt,{message:e,sourceConfig:n,isOnline:r,onViewSourceSummary:a,onDownloadSource:o},e.id)),t&&""===e[e.length-1]?.content&&R.jsx(nt,{})]})}function at({placeholder:e,disabled:t=!1,onSend:n}){const[r,a]=p.useState(""),o=p.useRef(null),i=()=>{r.trim()&&!t&&(n(r.trim()),a(""),o.current?.focus())};return R.jsxs("div",{className:"astermind-input",children:[R.jsx("textarea",{ref:o,className:"astermind-input__textarea",value:r,onChange:e=>{const t=e.target;a(t.value),t.style.height="auto",t.style.height=Math.min(t.scrollHeight,120)+"px"},onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),i())},placeholder:e,disabled:t,rows:1,"aria-label":"Message input"}),R.jsx("button",{className:"astermind-input__send",onClick:i,disabled:t||!r.trim(),"aria-label":"Send message",type:"button",children:R.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:R.jsx("path",{d:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"})})})]})}function ot({action:e,onConfirm:t,onCancel:n}){return R.jsxs("div",{className:"astermind-action-card",children:[R.jsxs("div",{className:"astermind-action-card__header",children:[R.jsx("div",{className:"astermind-action-card__icon",children:(e=>{switch(e){case"navigate":return R.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[R.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),R.jsx("polyline",{points:"15,3 21,3 21,9"}),R.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]});case"fillForm":return R.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[R.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),R.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]});case"clickElement":return R.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[R.jsx("path",{d:"M15 15l-2 5L9 9l11 4-5 2z"}),R.jsx("path",{d:"M15 15l5 5"})]});default:return R.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[R.jsx("circle",{cx:"12",cy:"12",r:"10"}),R.jsx("polyline",{points:"12,6 12,12 16,14"})]})}})(e.type)}),R.jsxs("div",{className:"astermind-action-card__title",children:[R.jsx("span",{className:"astermind-action-card__label",children:(e=>{switch(e){case"navigate":return"Navigate to";case"fillForm":return"Fill form field";case"clickElement":return"Click";case"triggerModal":return"Open modal";case"scroll":return"Scroll to";case"highlight":return"Highlight";case"custom":return"Execute action";default:return"Perform action"}})(e.type)}),R.jsx("span",{className:"astermind-action-card__target",children:e.target})]})]}),e.explanation&&R.jsx("p",{className:"astermind-action-card__explanation",children:e.explanation}),R.jsxs("div",{className:"astermind-action-card__confidence",children:[R.jsx("div",{className:"astermind-action-card__confidence-bar",style:{width:100*e.confidence+"%"}}),R.jsxs("span",{children:[Math.round(100*e.confidence),"% confident"]})]}),R.jsxs("div",{className:"astermind-action-card__actions",children:[R.jsx("button",{className:"astermind-action-card__cancel",onClick:n,type:"button",children:"Cancel"}),R.jsx("button",{className:"astermind-action-card__confirm",onClick:t,type:"button",children:"Confirm"})]})]})}function it({status:e}){return R.jsxs("div",{className:`astermind-status astermind-status--${e}`,children:[R.jsx("span",{className:"astermind-status__dot"}),R.jsx("span",{className:"astermind-status__label",children:(()=>{switch(e){case"online":return"Online";case"offline":return"Offline";case"connecting":return"Connecting...";case"error":return"Error";default:return"Unknown"}})()})]})}function st({messages:e,isProcessing:t,connectionStatus:n,pendingAction:r,headerTitle:a,headerSubtitle:o,placeholder:i,showPoweredBy:s,sourceConfig:l,onClose:c,onSendMessage:u,onActionConfirm:d,onActionCancel:f,onViewSourceSummary:h,onDownloadSource:p}){const m="online"===n;return R.jsxs("div",{className:"astermind-window",children:[R.jsx(Ge,{title:a,subtitle:o,onClose:c,children:R.jsx(it,{status:n})}),R.jsxs("div",{className:"astermind-window__body",children:[R.jsx(rt,{messages:e,isProcessing:t,sourceConfig:l,isOnline:m,onViewSourceSummary:h,onDownloadSource:p}),r&&R.jsx(ot,{action:r,onConfirm:()=>d(r),onCancel:f})]}),R.jsxs("div",{className:"astermind-window__footer",children:[R.jsx(at,{placeholder:i,disabled:t||"error"===n,onSend:u}),s&&R.jsxs("div",{className:"astermind-powered-by",children:["Powered by ",R.jsx("a",{href:"https://astermind.ai",target:"_blank",rel:"noopener noreferrer",children:"AsterMind"})]})]})]})}const lt={primaryColor:"#4F46E5",primaryHover:"#4338CA",backgroundColor:"#ffffff",surfaceColor:"#f3f4f6",textColor:"#1f2937",textMuted:"#6b7280",borderColor:"#e5e7eb",userBubbleBackground:"#4F46E5",userBubbleText:"#ffffff",botBubbleBackground:"#f3f4f6",botBubbleText:"#1f2937",widgetWidth:"380px",widgetHeight:"75vh",bubbleSize:"60px",borderRadius:"12px",fontFamily:"'Inter', system-ui, -apple-system, sans-serif",fontSize:"14px",shadow:"0 4px 20px rgba(0, 0, 0, 0.15)"};const ct=p.createContext(null);function ut({theme:e,children:t}){const n=function(e){const t=p.useMemo(()=>({...lt,...e}),[e]),n=p.useMemo(()=>({"--astermind-primary":t.primaryColor,"--astermind-primary-hover":t.primaryHover,"--astermind-background":t.backgroundColor,"--astermind-surface":t.surfaceColor,"--astermind-text":t.textColor,"--astermind-text-muted":t.textMuted,"--astermind-border":t.borderColor,"--astermind-user-bg":t.userBubbleBackground,"--astermind-user-text":t.userBubbleText,"--astermind-bot-bg":t.botBubbleBackground,"--astermind-bot-text":t.botBubbleText,"--astermind-widget-width":t.widgetWidth,"--astermind-widget-height":t.widgetHeight,"--astermind-bubble-size":t.bubbleSize,"--astermind-border-radius":t.borderRadius,"--astermind-font-family":t.fontFamily,"--astermind-font-size":t.fontSize,"--astermind-shadow":t.shadow}),[t]);return{theme:t,cssVariables:n}}(e);return R.jsx(ct.Provider,{value:n,children:R.jsx("div",{style:n.cssVariables,children:t})})}function dt(e){const n=p.useMemo(()=>function(){let e="",n="https://api.astermind.ai";try{t&&"SCRIPT"===t.tagName.toUpperCase()&&t.src||new URL("astermind-chatbot.min.js",document.baseURI).href}catch{}if(!e&&"undefined"!=typeof process&&process.env&&(e=process.env.REACT_APP_ASTERMIND_RAG_API_KEY||e,n=process.env.REACT_APP_ASTERMIND_RAG_API_SERVER_URL||n),"undefined"!=typeof window){const t=window.__ASTERMIND_CONFIG__;t&&"object"==typeof t&&(e=t.apiKey||e,n=t.apiUrl||n)}return{apiKey:e,apiUrl:n}}(),[]),{apiKey:r,apiUrl:a,wsUrl:o,transport:i,environment:s,throwOnMissingKey:l=!0,position:c="bottom-right",theme:u={},greeting:d="Hi! How can I help you today?",placeholder:f="Type your message...",agent:h,fallback:m={enabled:!0},sourceDisplay:g,showPoweredBy:y=!0,headerTitle:v="AsterMind",headerSubtitle:b="AI Assistant",defaultOpen:w=!1,zIndex:S=9999,onReady:k,onMessage:x,onAction:C,onError:E,onToggle:_}=e,M=r||n.apiKey,A=a||n.apiUrl,[I,P]=p.useState(w),[T,L]=p.useState(null),[N,D]=p.useState([]),[z,F]=p.useState(!1),[O,$]=p.useState(),[j,U]=p.useState(),[B,V]=p.useState("connecting"),W=p.useMemo(()=>{const e=T?.getSourcesConfig?.()||{};return{enabled:g?.enabled??e.enabled??!0,showSummary:g?.showSummary??e.showSummary??!0,showDownload:g?.showDownload??e.showDownload??!0}},[T,g]),H=p.useCallback(e=>{console.log("[AsterMind] View source summary:",e.title)},[]),K=p.useCallback(async e=>{if(e.downloadUrl)try{const t=e.downloadUrl.startsWith("http")?e.downloadUrl:`${A}${e.downloadUrl}`,n=await fetch(t,{headers:{"X-API-Key":M}});if(!n.ok)return void console.error("[AsterMind] Download failed:",n.status,n.statusText);if((n.headers.get("Content-Type")||"").includes("application/json")){const t=await n.json();if(t.downloadUrl){const n=document.createElement("a");n.href=t.downloadUrl,n.download=t.filename||e.documentName||e.title||"download",n.rel="noopener",document.body.appendChild(n),n.click(),document.body.removeChild(n)}else console.error("[AsterMind] Presigned URL response missing downloadUrl")}else{const t=n.headers.get("Content-Disposition");let r=e.documentName||e.title||"download";if(t){const e=t.match(/filename="?(.+?)"?$/);e&&(r=e[1])}const a=await n.blob(),o=window.URL.createObjectURL(a),i=document.createElement("a");i.href=o,i.download=r,document.body.appendChild(i),i.click(),window.URL.revokeObjectURL(o),document.body.removeChild(i)}}catch(e){console.error("[AsterMind] Download error:",e)}else console.warn("[AsterMind] No download URL for source:",e.title)},[A,M]);p.useEffect(()=>{if(!M){const e='AsterMind API key is required. Configure using one of these methods:\n 1. Pass apiKey prop: <ChatbotWidget apiKey="am_..." />\n 2. Set VITE_ASTERMIND_RAG_API_KEY environment variable (Vite)\n 3. Set REACT_APP_ASTERMIND_RAG_API_KEY environment variable (CRA)\n 4. Set window.__ASTERMIND_CONFIG__ = { apiKey: "am_...", apiUrl: "..." }';if(l)throw new Error(e);console.warn("[AsterMind] "+e)}},[M,l]);const q=p.useMemo(()=>{if(h?.enabled)return{enabled:!0,confidenceThreshold:h.confidenceThreshold??.8,siteMap:h.siteMap,siteMapConfig:h.siteMapConfig,customActions:h.customActions,requireConfirmation:!0}},[h]);p.useEffect(()=>{if(!M)return;const e=new ce({apiUrl:A,apiKey:M,wsUrl:o,transport:i,environment:s,fallback:{enabled:m?.enabled??!0,cacheOnConnect:!0},agentic:q,onStatusChange:e=>{V(e)},onError:e=>{E?.(new Error(e.message))}});q?.enabled&&(!function(e){const t={agent:me,intentClassifier:pe};e.registerAgentic(t)}(e),console.log("[AsterMind] Agentic capabilities enabled (auto-discovery handled by client)")),L(e);const t=e.getStoredMessages();if(t.length>0){D(t.map(e=>({id:e.id,role:e.role,content:e.content,timestamp:new Date(e.timestamp),offline:e.offline,confidence:e.confidence,sources:e.sources,isStreaming:!1})));const n=e.getSessionInfo();n.sessionId&&$(n.sessionId)}else if(d){const e={id:"greeting",role:"assistant",content:d,timestamp:new Date};D([e])}return k?.(),()=>{e.destroy?.()}},[M,A,o,i,m?.enabled,q,d,E,k]);const G=p.useCallback(()=>{const e=!I;P(e),_?.(e)},[I,_]),Q=p.useCallback(()=>{P(!1),_?.(!1)},[_]),Y=p.useCallback(async e=>{if(!T||!e.trim()||z)return;const t={id:`user-${Date.now()}`,role:"user",content:e.trim(),timestamp:new Date};if(D(e=>[...e,t]),x?.(t),F(!0),T.isAgenticEnabled())try{const t=await T.smartAsk(e,{sessionId:O});if(t.action&&!t.response){const e={id:t.action.id,type:t.action.type,target:t.action.target,params:t.action.params,confidence:t.action.confidence,explanation:t.action.explanation,status:"pending"};return U(e),C?.(e),void F(!1)}if(t.actionResult){const e={id:t.action.id,type:t.action.type,target:t.action.target,params:t.action?.params,confidence:t.action.confidence,explanation:t.action?.explanation,status:t.actionResult.success?"executed":"failed",result:t.actionResult},n={id:`assistant-${Date.now()}`,role:"assistant",content:t.actionResult.success?`✓ ${t.action?.explanation||"Action completed"}`:`✗ ${t.actionResult.message}`,timestamp:new Date,isStreaming:!1};return D(e=>[...e,n]),C?.(e),void F(!1)}if(t.response){const e={id:`assistant-${Date.now()}`,role:"assistant",content:t.response.reply,timestamp:new Date,sources:t.response.sources,confidence:t.response.confidence,offline:t.response.offline,isStreaming:!1};return D(t=>[...t,e]),$(t.response.sessionId),x?.(e),void F(!1)}}catch(e){console.error("[AsterMind] smartAsk error, falling back to standard ask:",e)}const n=`assistant-${Date.now()}`,r={id:n,role:"assistant",content:"",timestamp:new Date,isStreaming:!0};D(e=>[...e,r]);try{let t="";await T.askStream(e,{onToken:e=>{t+=e,D(e=>e.map(e=>e.id===n?{...e,content:t}:e))},onSources:e=>{D(t=>t.map(t=>t.id===n?{...t,sources:e}:t))},onComplete:e=>{const t={id:n,role:"assistant",content:e.reply,timestamp:new Date,sources:e.sources,confidence:e.confidence,offline:e.offline,isStreaming:!1};D(e=>e.map(e=>e.id===n?t:e)),$(e.sessionId),x?.(t)},onError:()=>{X(T,e,n)}},{sessionId:O})}catch{const e={id:n,role:"assistant",content:"I encountered an error processing your request. Please try again.",timestamp:new Date,isStreaming:!1};D(t=>t.map(t=>t.id===n?e:t)),E?.(new Error("Failed to process message"))}finally{F(!1)}},[T,z,O,x,E,C]),X=async(e,t,n)=>{try{const r=await e.ask(t,{sessionId:O}),a={id:n,role:"assistant",content:r.reply,timestamp:new Date,sources:r.sources,confidence:r.confidence,offline:r.offline,isStreaming:!1};D(e=>e.map(e=>e.id===n?a:e)),$(r.sessionId),x?.(a)}catch{const e={id:n,role:"assistant",content:"I'm having trouble connecting. Please try again later.",timestamp:new Date,isStreaming:!1};D(t=>t.map(t=>t.id===n?e:t))}},J=p.useCallback(async e=>{if(!T)return;const t={...e,status:"confirmed"};U(t);try{const t=await T.executeAction({id:e.id,type:e.type,target:e.target,confidence:e.confidence,params:e.params}),n={...e,status:t.success?"executed":"failed",result:t},r={id:`assistant-${Date.now()}`,role:"assistant",content:t.success?`✓ ${e.explanation||t.message}`:`✗ ${t.message}${t.error?`: ${t.error}`:""}`,timestamp:new Date,isStreaming:!1};D(e=>[...e,r]),U(void 0),C?.(n)}catch(t){const n={...e,status:"failed",result:{success:!1,message:"Failed to execute action",error:String(t)}},r={id:`assistant-${Date.now()}`,role:"assistant",content:`✗ Failed to execute action: ${String(t)}`,timestamp:new Date,isStreaming:!1};D(e=>[...e,r]),U(void 0),C?.(n)}},[j,T,C]),Z=p.useCallback(()=>{if(!j)return;const e={...j,status:"cancelled"};U(void 0),C?.(e)},[j,C]);return R.jsx(ut,{theme:u,children:R.jsxs("div",{className:`astermind-chatbot astermind-chatbot--${c}`,style:{zIndex:S},children:[!I&&R.jsx(qe,{onClick:G,position:c}),I&&R.jsx(st,{messages:N,isProcessing:z,connectionStatus:B,pendingAction:j,headerTitle:v,headerSubtitle:b,placeholder:f,showPoweredBy:y,sourceConfig:W,onClose:Q,onSendMessage:Y,onActionConfirm:J,onActionCancel:Z,onViewSourceSummary:H,onDownloadSource:K})]})})}let ft=null;function ht(e){const t=function(){if("undefined"==typeof document)return{};const e=document.querySelector("script[data-astermind-key]");if(!e)return{};const t={},n=e.getAttribute("data-astermind-key");n&&(t.apiKey=n);const r=e.getAttribute("data-astermind-url");r&&(t.apiUrl=r);const a=e.getAttribute("data-astermind-position");a&&["bottom-right","bottom-left","top-right","top-left"].includes(a)&&(t.position=a);const o=e.getAttribute("data-astermind-greeting");o&&(t.greeting=o);const i=e.getAttribute("data-astermind-title");i&&(t.headerTitle=i);const s=e.getAttribute("data-astermind-subtitle");return s&&(t.headerSubtitle=s),"true"===e.getAttribute("data-astermind-auto-open")&&(t.defaultOpen=!0),t}(),n={...t,...function(){if("undefined"==typeof window)return{};const e=window.astermindConfig;return e&&"object"==typeof e?e:{}}(),...e||{}},{container:r=document.body,...a}=n;a.apiKey||console.warn('[AsterMindChatbot] No API key found. Configure using one of these methods:\n 1. AsterMindChatbot.init({ apiKey: "am_..." })\n 2. window.astermindConfig = { apiKey: "am_..." }\n 3. <script data-astermind-key="am_..." ...>\n 4. Set VITE_ASTERMIND_RAG_API_KEY environment variable (if bundled)');const o="string"==typeof r?document.querySelector(r):r;if(!o)return void console.error("[AsterMindChatbot] Container not found:",r);const i=document.createElement("div");i.id="astermind-chatbot-root",o.appendChild(i),ft=E.createRoot(i),ft.render(m.createElement(dt,a)),console.log("[AsterMindChatbot] Initialized")}function pt(){ft&&(ft.unmount(),ft=null);const e=document.getElementById("astermind-chatbot-root");e&&e.remove(),console.log("[AsterMindChatbot] Destroyed")}function mt(){return null!==ft}return"undefined"!=typeof window&&(window.AsterMindChatbot={init:ht,destroy:pt,isInitialized:mt}),e.destroy=pt,e.init=ht,e.isInitialized=mt,e}({});
11
11
  //# sourceMappingURL=astermind-chatbot.min.js.map