@evelan/jexity-widget 0.13.1 โ 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +3038 -2038
- package/dist/index.mjs.map +1 -1
- package/dist/react.mjs +3012 -2012
- package/dist/react.mjs.map +1 -1
- package/dist/types/features/chat/components/MagiclineFormMessage.d.ts +29 -0
- package/dist/types/features/chat/components/MagiclineFormMessage.d.ts.map +1 -0
- package/dist/types/features/chat/components/MessageList.d.ts.map +1 -1
- package/dist/types/features/chat/components/magicline/TrialSessionBookingForm.d.ts +34 -0
- package/dist/types/features/chat/components/magicline/TrialSessionBookingForm.d.ts.map +1 -0
- package/dist/types/features/chat/components/magicline/buildWizardSteps.d.ts +26 -0
- package/dist/types/features/chat/components/magicline/buildWizardSteps.d.ts.map +1 -0
- package/dist/types/features/chat/components/magicline/formUtils.d.ts +23 -0
- package/dist/types/features/chat/components/magicline/formUtils.d.ts.map +1 -0
- package/dist/types/features/chat/components/magicline/magiclineConstants.d.ts +21 -0
- package/dist/types/features/chat/components/magicline/magiclineConstants.d.ts.map +1 -0
- package/dist/types/features/chat/components/magicline/useTrialBookingState.d.ts +87 -0
- package/dist/types/features/chat/components/magicline/useTrialBookingState.d.ts.map +1 -0
- package/dist/types/features/chat/hooks/useMagicline.d.ts +88 -0
- package/dist/types/features/chat/hooks/useMagicline.d.ts.map +1 -0
- package/dist/types/i18n/locales/de.d.ts.map +1 -1
- package/dist/types/i18n/locales/en.d.ts +63 -0
- package/dist/types/i18n/locales/en.d.ts.map +1 -1
- package/dist/widget.js +32 -32
- package/dist/widget.js.map +1 -1
- package/package.json +6 -4
package/dist/widget.js
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
(function(){"use strict";var Ue,y,Wn,Jn,de,Gn,Kn,Zn,Yn,Ut,Ft,Qt,Xn,Fe={},er=[],wo=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Qe=Array.isArray;function Z(t,e){for(var n in e)t[n]=e[n];return t}function Dt(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function D(t,e,n){var r,i,o,s={};for(o in e)o=="key"?r=e[o]:o=="ref"?i=e[o]:s[o]=e[o];if(arguments.length>2&&(s.children=arguments.length>3?Ue.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(o in t.defaultProps)s[o]===void 0&&(s[o]=t.defaultProps[o]);return De(t,s,r,i,null)}function De(t,e,n,r,i){var o={type:t,props:e,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Wn,__i:-1,__u:0};return i==null&&y.vnode!=null&&y.vnode(o),o}function _o(){return{current:null}}function U(t){return t.children}function W(t,e){this.props=t,this.context=e}function ke(t,e){if(e==null)return t.__?ke(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?ke(t):null}function tr(t){var e,n;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null){t.__e=t.__c.base=n.__e;break}return tr(t)}}function Vt(t){(!t.__d&&(t.__d=!0)&&de.push(t)&&!ht.__r++||Gn!=y.debounceRendering)&&((Gn=y.debounceRendering)||Kn)(ht)}function ht(){for(var t,e,n,r,i,o,s,l=1;de.length;)de.length>l&&de.sort(Zn),t=de.shift(),l=de.length,t.__d&&(n=void 0,r=void 0,i=(r=(e=t).__v).__e,o=[],s=[],e.__P&&((n=Z({},r)).__v=r.__v+1,y.vnode&&y.vnode(n),Ht(e.__P,n,r,e.__n,e.__P.namespaceURI,32&r.__u?[i]:null,o,i??ke(r),!!(32&r.__u),s),n.__v=r.__v,n.__.__k[n.__i]=n,sr(o,n,s),r.__e=r.__=null,n.__e!=i&&tr(n)));ht.__r=0}function nr(t,e,n,r,i,o,s,l,a,u,d){var h,f,p,g,m,x,b,v=r&&r.__k||er,L=e.length;for(a=ko(n,e,v,a,L),h=0;h<L;h++)(p=n.__k[h])!=null&&(f=p.__i==-1?Fe:v[p.__i]||Fe,p.__i=h,x=Ht(t,p,f,i,o,s,l,a,u,d),g=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&Jt(f.ref,null,p),d.push(p.ref,p.__c||g,p)),m==null&&g!=null&&(m=g),(b=!!(4&p.__u))||f.__k===p.__k?a=rr(p,a,t,b):typeof p.type=="function"&&x!==void 0?a=x:g&&(a=g.nextSibling),p.__u&=-7);return n.__e=m,a}function ko(t,e,n,r,i){var o,s,l,a,u,d=n.length,h=d,f=0;for(t.__k=new Array(i),o=0;o<i;o++)(s=e[o])!=null&&typeof s!="boolean"&&typeof s!="function"?(a=o+f,(s=t.__k[o]=typeof s=="string"||typeof s=="number"||typeof s=="bigint"||s.constructor==String?De(null,s,null,null,null):Qe(s)?De(U,{children:s},null,null,null):s.constructor==null&&s.__b>0?De(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):s).__=t,s.__b=t.__b+1,l=null,(u=s.__i=jo(s,n,a,h))!=-1&&(h--,(l=n[u])&&(l.__u|=2)),l==null||l.__v==null?(u==-1&&(i>d?f--:i<d&&f++),typeof s.type!="function"&&(s.__u|=4)):u!=a&&(u==a-1?f--:u==a+1?f++:(u>a?f--:f++,s.__u|=4))):t.__k[o]=null;if(h)for(o=0;o<d;o++)(l=n[o])!=null&&(2&l.__u)==0&&(l.__e==r&&(r=ke(l)),lr(l,l));return r}function rr(t,e,n,r){var i,o;if(typeof t.type=="function"){for(i=t.__k,o=0;i&&o<i.length;o++)i[o]&&(i[o].__=t,e=rr(i[o],e,n,r));return e}t.__e!=e&&(r&&(e&&t.type&&!e.parentNode&&(e=ke(t)),n.insertBefore(t.__e,e||null)),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function Y(t,e){return e=e||[],t==null||typeof t=="boolean"||(Qe(t)?t.some(function(n){Y(n,e)}):e.push(t)),e}function jo(t,e,n,r){var i,o,s,l=t.key,a=t.type,u=e[n],d=u!=null&&(2&u.__u)==0;if(u===null&&t.key==null||d&&l==u.key&&a==u.type)return n;if(r>(d?1:0)){for(i=n-1,o=n+1;i>=0||o<e.length;)if((u=e[s=i>=0?i--:o++])!=null&&(2&u.__u)==0&&l==u.key&&a==u.type)return s}return-1}function ir(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||wo.test(e)?n:n+"px"}function dt(t,e,n,r,i){var o,s;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof r=="string"&&(t.style.cssText=r=""),r)for(e in r)n&&e in n||ir(t.style,e,"");if(n)for(e in n)r&&n[e]==r[e]||ir(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")o=e!=(e=e.replace(Yn,"$1")),s=e.toLowerCase(),e=s in t||e=="onFocusOut"||e=="onFocusIn"?s.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+o]=n,n?r?n.u=r.u:(n.u=Ut,t.addEventListener(e,o?Qt:Ft,o)):t.removeEventListener(e,o?Qt:Ft,o);else{if(i=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function or(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=Ut++;else if(e.t<n.u)return;return n(y.event?y.event(e):e)}}}function Ht(t,e,n,r,i,o,s,l,a,u){var d,h,f,p,g,m,x,b,v,L,M,F,Q,vo,Bt,ut,Dn,re=e.type;if(e.constructor!=null)return null;128&n.__u&&(a=!!(32&n.__u),o=[l=e.__e=n.__e]),(d=y.__b)&&d(e);e:if(typeof re=="function")try{if(b=e.props,v="prototype"in re&&re.prototype.render,L=(d=re.contextType)&&r[d.__c],M=d?L?L.props.value:d.__:r,n.__c?x=(h=e.__c=n.__c).__=h.__E:(v?e.__c=h=new re(b,M):(e.__c=h=new W(b,M),h.constructor=re,h.render=Co),L&&L.sub(h),h.props=b,h.state||(h.state={}),h.context=M,h.__n=r,f=h.__d=!0,h.__h=[],h._sb=[]),v&&h.__s==null&&(h.__s=h.state),v&&re.getDerivedStateFromProps!=null&&(h.__s==h.state&&(h.__s=Z({},h.__s)),Z(h.__s,re.getDerivedStateFromProps(b,h.__s))),p=h.props,g=h.state,h.__v=e,f)v&&re.getDerivedStateFromProps==null&&h.componentWillMount!=null&&h.componentWillMount(),v&&h.componentDidMount!=null&&h.__h.push(h.componentDidMount);else{if(v&&re.getDerivedStateFromProps==null&&b!==p&&h.componentWillReceiveProps!=null&&h.componentWillReceiveProps(b,M),!h.__e&&h.shouldComponentUpdate!=null&&h.shouldComponentUpdate(b,h.__s,M)===!1||e.__v==n.__v){for(e.__v!=n.__v&&(h.props=b,h.state=h.__s,h.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(Be){Be&&(Be.__=e)}),F=0;F<h._sb.length;F++)h.__h.push(h._sb[F]);h._sb=[],h.__h.length&&s.push(h);break e}h.componentWillUpdate!=null&&h.componentWillUpdate(b,h.__s,M),v&&h.componentDidUpdate!=null&&h.__h.push(function(){h.componentDidUpdate(p,g,m)})}if(h.context=M,h.props=b,h.__P=t,h.__e=!1,Q=y.__r,vo=0,v){for(h.state=h.__s,h.__d=!1,Q&&Q(e),d=h.render(h.props,h.state,h.context),Bt=0;Bt<h._sb.length;Bt++)h.__h.push(h._sb[Bt]);h._sb=[]}else do h.__d=!1,Q&&Q(e),d=h.render(h.props,h.state,h.context),h.state=h.__s;while(h.__d&&++vo<25);h.state=h.__s,h.getChildContext!=null&&(r=Z(Z({},r),h.getChildContext())),v&&!f&&h.getSnapshotBeforeUpdate!=null&&(m=h.getSnapshotBeforeUpdate(p,g)),ut=d,d!=null&&d.type===U&&d.key==null&&(ut=ar(d.props.children)),l=nr(t,Qe(ut)?ut:[ut],e,n,r,i,o,s,l,a,u),h.base=e.__e,e.__u&=-161,h.__h.length&&s.push(h),x&&(h.__E=h.__=null)}catch(Be){if(e.__v=null,a||o!=null)if(Be.then){for(e.__u|=a?160:128;l&&l.nodeType==8&&l.nextSibling;)l=l.nextSibling;o[o.indexOf(l)]=null,e.__e=l}else{for(Dn=o.length;Dn--;)Dt(o[Dn]);Wt(e)}else e.__e=n.__e,e.__k=n.__k,Be.then||Wt(e);y.__e(Be,e,n)}else o==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):l=e.__e=So(n.__e,e,n,r,i,o,s,a,u);return(d=y.diffed)&&d(e),128&e.__u?void 0:l}function Wt(t){t&&t.__c&&(t.__c.__e=!0),t&&t.__k&&t.__k.forEach(Wt)}function sr(t,e,n){for(var r=0;r<n.length;r++)Jt(n[r],n[++r],n[++r]);y.__c&&y.__c(e,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(o){o.call(i)})}catch(o){y.__e(o,i.__v)}})}function ar(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:Qe(t)?t.map(ar):Z({},t)}function So(t,e,n,r,i,o,s,l,a){var u,d,h,f,p,g,m,x=n.props,b=e.props,v=e.type;if(v=="svg"?i="http://www.w3.org/2000/svg":v=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),o!=null){for(u=0;u<o.length;u++)if((p=o[u])&&"setAttribute"in p==!!v&&(v?p.localName==v:p.nodeType==3)){t=p,o[u]=null;break}}if(t==null){if(v==null)return document.createTextNode(b);t=document.createElementNS(i,v,b.is&&b),l&&(y.__m&&y.__m(e,o),l=!1),o=null}if(v==null)x===b||l&&t.data==b||(t.data=b);else{if(o=o&&Ue.call(t.childNodes),x=n.props||Fe,!l&&o!=null)for(x={},u=0;u<t.attributes.length;u++)x[(p=t.attributes[u]).name]=p.value;for(u in x)if(p=x[u],u!="children"){if(u=="dangerouslySetInnerHTML")h=p;else if(!(u in b)){if(u=="value"&&"defaultValue"in b||u=="checked"&&"defaultChecked"in b)continue;dt(t,u,null,p,i)}}for(u in b)p=b[u],u=="children"?f=p:u=="dangerouslySetInnerHTML"?d=p:u=="value"?g=p:u=="checked"?m=p:l&&typeof p!="function"||x[u]===p||dt(t,u,p,x[u],i);if(d)l||h&&(d.__html==h.__html||d.__html==t.innerHTML)||(t.innerHTML=d.__html),e.__k=[];else if(h&&(t.innerHTML=""),nr(e.type=="template"?t.content:t,Qe(f)?f:[f],e,n,r,v=="foreignObject"?"http://www.w3.org/1999/xhtml":i,o,s,o?o[0]:n.__k&&ke(n,0),l,a),o!=null)for(u=o.length;u--;)Dt(o[u]);l||(u="value",v=="progress"&&g==null?t.removeAttribute("value"):g!=null&&(g!==t[u]||v=="progress"&&!g||v=="option"&&g!=x[u])&&dt(t,u,g,x[u],i),u="checked",m!=null&&m!=t[u]&&dt(t,u,m,x[u],i))}return t}function Jt(t,e,n){try{if(typeof t=="function"){var r=typeof t.__u=="function";r&&t.__u(),r&&e==null||(t.__u=t(e))}else t.current=e}catch(i){y.__e(i,n)}}function lr(t,e,n){var r,i;if(y.unmount&&y.unmount(t),(r=t.ref)&&(r.current&&r.current!=t.__e||Jt(r,null,e)),(r=t.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(o){y.__e(o,e)}r.base=r.__P=null}if(r=t.__k)for(i=0;i<r.length;i++)r[i]&&lr(r[i],e,n||typeof t.type!="function");n||Dt(t.__e),t.__c=t.__=t.__e=void 0}function Co(t,e,n){return this.constructor(t,n)}function fe(t,e,n){var r,i,o,s;e==document&&(e=document.documentElement),y.__&&y.__(t,e),i=(r=typeof n=="function")?null:n&&n.__k||e.__k,o=[],s=[],Ht(e,t=(!r&&n||e).__k=D(U,null,[t]),i||Fe,Fe,e.namespaceURI,!r&&n?[n]:i?null:e.firstChild?Ue.call(e.childNodes):null,o,!r&&n?n:i?i.__e:e.firstChild,r,s),sr(o,t,s)}function cr(t,e){fe(t,e,cr)}function To(t,e,n){var r,i,o,s,l=Z({},t.props);for(o in t.type&&t.type.defaultProps&&(s=t.type.defaultProps),e)o=="key"?r=e[o]:o=="ref"?i=e[o]:l[o]=e[o]===void 0&&s!=null?s[o]:e[o];return arguments.length>2&&(l.children=arguments.length>3?Ue.call(arguments,2):n),De(t.type,l,r||t.key,i||t.ref,null)}function Ro(t){function e(n){var r,i;return this.getChildContext||(r=new Set,(i={})[e.__c]=this,this.getChildContext=function(){return i},this.componentWillUnmount=function(){r=null},this.shouldComponentUpdate=function(o){this.props.value!=o.value&&r.forEach(function(s){s.__e=!0,Vt(s)})},this.sub=function(o){r.add(o);var s=o.componentWillUnmount;o.componentWillUnmount=function(){r&&r.delete(o),s&&s.call(o)}}),n.children}return e.__c="__cC"+Xn++,e.__=t,e.Provider=e.__l=(e.Consumer=function(n,r){return n.children(r)}).contextType=e,e}Ue=er.slice,y={__e:function(t,e,n,r){for(var i,o,s;e=e.__;)if((i=e.__c)&&!i.__)try{if((o=i.constructor)&&o.getDerivedStateFromError!=null&&(i.setState(o.getDerivedStateFromError(t)),s=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,r||{}),s=i.__d),s)return i.__E=i}catch(l){t=l}throw t}},Wn=0,Jn=function(t){return t!=null&&t.constructor==null},W.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Z({},this.state),typeof t=="function"&&(t=t(Z({},n),this.props)),t&&Z(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),Vt(this))},W.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),Vt(this))},W.prototype.render=U,de=[],Kn=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Zn=function(t,e){return t.__v.__b-e.__v.__b},ht.__r=0,Yn=/(PointerCapture)$|Capture$/i,Ut=0,Ft=or(!1),Qt=or(!0),Xn=0;var $o=0;function c(t,e,n,r,i,o){e||(e={});var s,l,a=e;if("ref"in a)for(l in a={},e)l=="ref"?s=e[l]:a[l]=e[l];var u={type:t,props:a,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--$o,__i:-1,__u:0,__source:i,__self:o};if(typeof t=="function"&&(s=t.defaultProps))for(l in s)a[l]===void 0&&(a[l]=s[l]);return y.vnode&&y.vnode(u),u}var ae,j,Gt,ur,je=0,hr=[],T=y,dr=T.__b,fr=T.__r,pr=T.diffed,gr=T.__c,mr=T.unmount,xr=T.__;function Se(t,e){T.__h&&T.__h(j,t,je||e),je=0;var n=j.__H||(j.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function C(t){return je=1,Kt(_r,t)}function Kt(t,e,n){var r=Se(ae++,2);if(r.t=t,!r.__c&&(r.__=[n?n(e):_r(void 0,e),function(l){var a=r.__N?r.__N[0]:r.__[0],u=r.t(a,l);a!==u&&(r.__N=[u,r.__[1]],r.__c.setState({}))}],r.__c=j,!j.__f)){var i=function(l,a,u){if(!r.__c.__H)return!0;var d=r.__c.__H.__.filter(function(f){return!!f.__c});if(d.every(function(f){return!f.__N}))return!o||o.call(this,l,a,u);var h=r.__c.props!==l;return d.forEach(function(f){if(f.__N){var p=f.__[0];f.__=f.__N,f.__N=void 0,p!==f.__[0]&&(h=!0)}}),o&&o.call(this,l,a,u)||h};j.__f=!0;var o=j.shouldComponentUpdate,s=j.componentWillUpdate;j.componentWillUpdate=function(l,a,u){if(this.__e){var d=o;o=void 0,i(l,a,u),o=d}s&&s.call(this,l,a,u)},j.shouldComponentUpdate=i}return r.__N||r.__}function S(t,e){var n=Se(ae++,3);!T.__s&&Yt(n.__H,e)&&(n.__=t,n.u=e,j.__H.__h.push(n))}function Ve(t,e){var n=Se(ae++,4);!T.__s&&Yt(n.__H,e)&&(n.__=t,n.u=e,j.__h.push(n))}function le(t){return je=5,J(function(){return{current:t}},[])}function br(t,e,n){je=6,Ve(function(){if(typeof t=="function"){var r=t(e());return function(){t(null),r&&typeof r=="function"&&r()}}if(t)return t.current=e(),function(){return t.current=null}},n==null?n:n.concat(t))}function J(t,e){var n=Se(ae++,7);return Yt(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function Ce(t,e){return je=8,J(function(){return t},e)}function ft(t){var e=j.context[t.__c],n=Se(ae++,9);return n.c=t,e?(n.__==null&&(n.__=!0,e.sub(j)),e.props.value):t.__}function yr(t,e){T.useDebugValue&&T.useDebugValue(e?e(t):t)}function vr(){var t=Se(ae++,11);if(!t.__){for(var e=j.__v;e!==null&&!e.__m&&e.__!==null;)e=e.__;var n=e.__m||(e.__m=[0,0]);t.__="P"+n[0]+"-"+n[1]++}return t.__}function Ao(){for(var t;t=hr.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(pt),t.__H.__h.forEach(Zt),t.__H.__h=[]}catch(e){t.__H.__h=[],T.__e(e,t.__v)}}T.__b=function(t){j=null,dr&&dr(t)},T.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),xr&&xr(t,e)},T.__r=function(t){fr&&fr(t),ae=0;var e=(j=t.__c).__H;e&&(Gt===j?(e.__h=[],j.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.forEach(pt),e.__h.forEach(Zt),e.__h=[],ae=0)),Gt=j},T.diffed=function(t){pr&&pr(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(hr.push(e)!==1&&ur===T.requestAnimationFrame||((ur=T.requestAnimationFrame)||Eo)(Ao)),e.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),Gt=j=null},T.__c=function(t,e){e.some(function(n){try{n.__h.forEach(pt),n.__h=n.__h.filter(function(r){return!r.__||Zt(r)})}catch(r){e.some(function(i){i.__h&&(i.__h=[])}),e=[],T.__e(r,n.__v)}}),gr&&gr(t,e)},T.unmount=function(t){mr&&mr(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(r){try{pt(r)}catch(i){e=i}}),n.__H=void 0,e&&T.__e(e,n.__v))};var wr=typeof requestAnimationFrame=="function";function Eo(t){var e,n=function(){clearTimeout(r),wr&&cancelAnimationFrame(e),setTimeout(t)},r=setTimeout(n,35);wr&&(e=requestAnimationFrame(n))}function pt(t){var e=j,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),j=e}function Zt(t){var e=j;t.__c=t.__(),j=e}function Yt(t,e){return!t||t.length!==e.length||e.some(function(n,r){return n!==t[r]})}function _r(t,e){return typeof e=="function"?e(t):e}function kr(t,e){for(var n in e)t[n]=e[n];return t}function Xt(t,e){for(var n in t)if(n!=="__source"&&!(n in e))return!0;for(var r in e)if(r!=="__source"&&t[r]!==e[r])return!0;return!1}function jr(t,e){var n=e(),r=C({t:{__:n,u:e}}),i=r[0].t,o=r[1];return Ve(function(){i.__=n,i.u=e,en(i)&&o({t:i})},[t,n,e]),S(function(){return en(i)&&o({t:i}),t(function(){en(i)&&o({t:i})})},[t]),n}function en(t){var e,n,r=t.u,i=t.__;try{var o=r();return!((e=i)===(n=o)&&(e!==0||1/e==1/n)||e!=e&&n!=n)}catch{return!0}}function Sr(t){t()}function Cr(t){return t}function Tr(){return[!1,Sr]}var Rr=Ve;function tn(t,e){this.props=t,this.context=e}function Po(t,e){function n(i){var o=this.props.ref,s=o==i.ref;return!s&&o&&(o.call?o(null):o.current=null),e?!e(this.props,i)||!s:Xt(this.props,i)}function r(i){return this.shouldComponentUpdate=n,D(t,i)}return r.displayName="Memo("+(t.displayName||t.name)+")",r.prototype.isReactComponent=!0,r.__f=!0,r.type=t,r}(tn.prototype=new W).isPureReactComponent=!0,tn.prototype.shouldComponentUpdate=function(t,e){return Xt(this.props,t)||Xt(this.state,e)};var $r=y.__b;y.__b=function(t){t.type&&t.type.__f&&t.ref&&(t.props.ref=t.ref,t.ref=null),$r&&$r(t)};var Io=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function Lo(t){function e(n){var r=kr({},n);return delete r.ref,t(r,n.ref||null)}return e.$$typeof=Io,e.render=t,e.prototype.isReactComponent=e.__f=!0,e.displayName="ForwardRef("+(t.displayName||t.name)+")",e}var Ar=function(t,e){return t==null?null:Y(Y(t).map(e))},Mo={map:Ar,forEach:Ar,count:function(t){return t?Y(t).length:0},only:function(t){var e=Y(t);if(e.length!==1)throw"Children.only";return e[0]},toArray:Y},qo=y.__e;y.__e=function(t,e,n,r){if(t.then){for(var i,o=e;o=o.__;)if((i=o.__c)&&i.__c)return e.__e==null&&(e.__e=n.__e,e.__k=n.__k),i.__c(t,e)}qo(t,e,n,r)};var Er=y.unmount;function Pr(t,e,n){return t&&(t.__c&&t.__c.__H&&(t.__c.__H.__.forEach(function(r){typeof r.__c=="function"&&r.__c()}),t.__c.__H=null),(t=kr({},t)).__c!=null&&(t.__c.__P===n&&(t.__c.__P=e),t.__c.__e=!0,t.__c=null),t.__k=t.__k&&t.__k.map(function(r){return Pr(r,e,n)})),t}function Ir(t,e,n){return t&&n&&(t.__v=null,t.__k=t.__k&&t.__k.map(function(r){return Ir(r,e,n)}),t.__c&&t.__c.__P===e&&(t.__e&&n.appendChild(t.__e),t.__c.__e=!0,t.__c.__P=n)),t}function gt(){this.__u=0,this.o=null,this.__b=null}function Lr(t){var e=t.__.__c;return e&&e.__a&&e.__a(t)}function Oo(t){var e,n,r;function i(o){if(e||(e=t()).then(function(s){n=s.default||s},function(s){r=s}),r)throw r;if(!n)throw e;return D(n,o)}return i.displayName="Lazy",i.__f=!0,i}function He(){this.i=null,this.l=null}y.unmount=function(t){var e=t.__c;e&&e.__R&&e.__R(),e&&32&t.__u&&(t.type=null),Er&&Er(t)},(gt.prototype=new W).__c=function(t,e){var n=e.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var i=Lr(r.__v),o=!1,s=function(){o||(o=!0,n.__R=null,i?i(l):l())};n.__R=s;var l=function(){if(!--r.__u){if(r.state.__a){var a=r.state.__a;r.__v.__k[0]=Ir(a,a.__c.__P,a.__c.__O)}var u;for(r.setState({__a:r.__b=null});u=r.o.pop();)u.forceUpdate()}};r.__u++||32&e.__u||r.setState({__a:r.__b=r.__v.__k[0]}),t.then(s,s)},gt.prototype.componentWillUnmount=function(){this.o=[]},gt.prototype.render=function(t,e){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),r=this.__v.__k[0].__c;this.__v.__k[0]=Pr(this.__b,n,r.__O=r.__P)}this.__b=null}var i=e.__a&&D(U,null,t.fallback);return i&&(i.__u&=-33),[D(U,null,e.__a?null:t.children),i]};var Mr=function(t,e,n){if(++n[1]===n[0]&&t.l.delete(e),t.props.revealOrder&&(t.props.revealOrder[0]!=="t"||!t.l.size))for(n=t.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;t.i=n=n[2]}};function No(t){return this.getChildContext=function(){return t.context},t.children}function zo(t){var e=this,n=t.h;if(e.componentWillUnmount=function(){fe(null,e.v),e.v=null,e.h=null},e.h&&e.h!==n&&e.componentWillUnmount(),!e.v){for(var r=e.__v;r!==null&&!r.__m&&r.__!==null;)r=r.__;e.h=n,e.v={nodeType:1,parentNode:n,childNodes:[],__k:{__m:r.__m},contains:function(){return!0},insertBefore:function(i,o){this.childNodes.push(i),e.h.insertBefore(i,o)},removeChild:function(i){this.childNodes.splice(this.childNodes.indexOf(i)>>>1,1),e.h.removeChild(i)}}}fe(D(No,{context:e.context},t.__v),e.v)}function Bo(t,e){var n=D(zo,{__v:t,h:e});return n.containerInfo=e,n}(He.prototype=new W).__a=function(t){var e=this,n=Lr(e.__v),r=e.l.get(t);return r[0]++,function(i){var o=function(){e.props.revealOrder?(r.push(i),Mr(e,t,r)):i()};n?n(o):o()}},He.prototype.render=function(t){this.i=null,this.l=new Map;var e=Y(t.children);t.revealOrder&&t.revealOrder[0]==="b"&&e.reverse();for(var n=e.length;n--;)this.l.set(e[n],this.i=[1,0,this.i]);return t.children},He.prototype.componentDidUpdate=He.prototype.componentDidMount=function(){var t=this;this.l.forEach(function(e,n){Mr(t,n,e)})};var qr=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,Uo=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,Fo=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Qo=/[A-Z0-9]/g,Do=typeof document<"u",Vo=function(t){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(t)};function Ho(t,e,n){return e.__k==null&&(e.textContent=""),fe(t,e),typeof n=="function"&&n(),t?t.__c:null}function Wo(t,e,n){return cr(t,e),typeof n=="function"&&n(),t?t.__c:null}W.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(t){Object.defineProperty(W.prototype,t,{configurable:!0,get:function(){return this["UNSAFE_"+t]},set:function(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})});var Or=y.event;function Jo(){}function Go(){return this.cancelBubble}function Ko(){return this.defaultPrevented}y.event=function(t){return Or&&(t=Or(t)),t.persist=Jo,t.isPropagationStopped=Go,t.isDefaultPrevented=Ko,t.nativeEvent=t};var nn,Zo={enumerable:!1,configurable:!0,get:function(){return this.class}},Nr=y.vnode;y.vnode=function(t){typeof t.type=="string"&&(function(e){var n=e.props,r=e.type,i={},o=r.indexOf("-")===-1;for(var s in n){var l=n[s];if(!(s==="value"&&"defaultValue"in n&&l==null||Do&&s==="children"&&r==="noscript"||s==="class"||s==="className")){var a=s.toLowerCase();s==="defaultValue"&&"value"in n&&n.value==null?s="value":s==="download"&&l===!0?l="":a==="translate"&&l==="no"?l=!1:a[0]==="o"&&a[1]==="n"?a==="ondoubleclick"?s="ondblclick":a!=="onchange"||r!=="input"&&r!=="textarea"||Vo(n.type)?a==="onfocus"?s="onfocusin":a==="onblur"?s="onfocusout":Fo.test(s)&&(s=a):a=s="oninput":o&&Uo.test(s)?s=s.replace(Qo,"-$&").toLowerCase():l===null&&(l=void 0),a==="oninput"&&i[s=a]&&(s="oninputCapture"),i[s]=l}}r=="select"&&i.multiple&&Array.isArray(i.value)&&(i.value=Y(n.children).forEach(function(u){u.props.selected=i.value.indexOf(u.props.value)!=-1})),r=="select"&&i.defaultValue!=null&&(i.value=Y(n.children).forEach(function(u){u.props.selected=i.multiple?i.defaultValue.indexOf(u.props.value)!=-1:i.defaultValue==u.props.value})),n.class&&!n.className?(i.class=n.class,Object.defineProperty(i,"className",Zo)):(n.className&&!n.class||n.class&&n.className)&&(i.class=i.className=n.className),e.props=i})(t),t.$$typeof=qr,Nr&&Nr(t)};var zr=y.__r;y.__r=function(t){zr&&zr(t),nn=t.__c};var Br=y.diffed;y.diffed=function(t){Br&&Br(t);var e=t.props,n=t.__e;n!=null&&t.type==="textarea"&&"value"in e&&e.value!==n.value&&(n.value=e.value==null?"":e.value),nn=null};var Yo={ReactCurrentDispatcher:{current:{readContext:function(t){return nn.__n[t.__c].props.value},useCallback:Ce,useContext:ft,useDebugValue:yr,useDeferredValue:Cr,useEffect:S,useId:vr,useImperativeHandle:br,useInsertionEffect:Rr,useLayoutEffect:Ve,useMemo:J,useReducer:Kt,useRef:le,useState:C,useSyncExternalStore:jr,useTransition:Tr}}};function Xo(t){return D.bind(null,t)}function mt(t){return!!t&&t.$$typeof===qr}function es(t){return mt(t)&&t.type===U}function ts(t){return!!t&&!!t.displayName&&(typeof t.displayName=="string"||t.displayName instanceof String)&&t.displayName.startsWith("Memo(")}function ns(t){return mt(t)?To.apply(null,arguments):t}function rs(t){return!!t.__k&&(fe(null,t),!0)}function is(t){return t&&(t.base||t.nodeType===1&&t)||null}for(var os=function(t,e){return t(e)},ss=function(t,e){return t(e)},as=U,ls=mt,rn={useState:C,useId:vr,useReducer:Kt,useEffect:S,useLayoutEffect:Ve,useInsertionEffect:Rr,useTransition:Tr,useDeferredValue:Cr,useSyncExternalStore:jr,startTransition:Sr,useRef:le,useImperativeHandle:br,useMemo:J,useCallback:Ce,useContext:ft,useDebugValue:yr,version:"18.3.1",Children:Mo,render:Ho,hydrate:Wo,unmountComponentAtNode:rs,createPortal:Bo,createElement:D,createContext:Ro,createFactory:Xo,cloneElement:ns,createRef:_o,Fragment:U,isValidElement:mt,isElement:ls,isFragment:es,isMemo:ts,findDOMNode:is,Component:W,PureComponent:tn,memo:Po,forwardRef:Lo,flushSync:ss,unstable_batchedUpdates:os,StrictMode:as,Suspense:gt,SuspenseList:He,lazy:Oo,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:Yo},X=[],V=[],cs=Uint8Array,on="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Te=0,us=on.length;Te<us;++Te)X[Te]=on[Te],V[on.charCodeAt(Te)]=Te;V[45]=62,V[95]=63;function hs(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");n===-1&&(n=e);var r=n===e?0:4-n%4;return[n,r]}function ds(t,e,n){return(e+n)*3/4-n}function We(t){var e,n=hs(t),r=n[0],i=n[1],o=new cs(ds(t,r,i)),s=0,l=i>0?r-4:r,a;for(a=0;a<l;a+=4)e=V[t.charCodeAt(a)]<<18|V[t.charCodeAt(a+1)]<<12|V[t.charCodeAt(a+2)]<<6|V[t.charCodeAt(a+3)],o[s++]=e>>16&255,o[s++]=e>>8&255,o[s++]=e&255;return i===2&&(e=V[t.charCodeAt(a)]<<2|V[t.charCodeAt(a+1)]>>4,o[s++]=e&255),i===1&&(e=V[t.charCodeAt(a)]<<10|V[t.charCodeAt(a+1)]<<4|V[t.charCodeAt(a+2)]>>2,o[s++]=e>>8&255,o[s++]=e&255),o}function fs(t){return X[t>>18&63]+X[t>>12&63]+X[t>>6&63]+X[t&63]}function ps(t,e,n){for(var r,i=[],o=e;o<n;o+=3)r=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(t[o+2]&255),i.push(fs(r));return i.join("")}function Je(t){for(var e,n=t.length,r=n%3,i=[],o=16383,s=0,l=n-r;s<l;s+=o)i.push(ps(t,s,s+o>l?l:s+o));return r===1?(e=t[n-1],i.push(X[e>>2]+X[e<<4&63]+"==")):r===2&&(e=(t[n-2]<<8)+t[n-1],i.push(X[e>>10]+X[e>>4&63]+X[e<<2&63]+"=")),i.join("")}function ie(t){if(t===void 0)return{};if(!Ur(t))throw new Error(`The arguments to a Convex function must be an object. Received: ${t}`);return t}function gs(t){if(typeof t>"u")throw new Error("Client created with undefined deployment address. If you used an environment variable, check that it's set.");if(typeof t!="string")throw new Error(`Invalid deployment address: found ${t}".`);if(!(t.startsWith("http:")||t.startsWith("https:")))throw new Error(`Invalid deployment address: Must start with "https://" or "http://". Found "${t}".`);try{new URL(t)}catch{throw new Error(`Invalid deployment address: "${t}" is not a valid URL. If you believe this URL is correct, use the \`skipConvexDeploymentUrlCheck\` option to bypass this.`)}if(t.endsWith(".convex.site"))throw new Error(`Invalid deployment address: "${t}" ends with .convex.site, which is used for HTTP Actions. Convex deployment URLs typically end with .convex.cloud? If you believe this URL is correct, use the \`skipConvexDeploymentUrlCheck\` option to bypass this.`)}function Ur(t){const e=typeof t=="object",n=Object.getPrototypeOf(t),r=n===null||n===Object.prototype||n?.constructor?.name==="Object";return e&&r}const Fr=!0,Re=BigInt("-9223372036854775808"),sn=BigInt("9223372036854775807"),an=BigInt("0"),ms=BigInt("8"),xs=BigInt("256");function Qr(t){return Number.isNaN(t)||!Number.isFinite(t)||Object.is(t,-0)}function bs(t){t<an&&(t-=Re+Re);let e=t.toString(16);e.length%2===1&&(e="0"+e);const n=new Uint8Array(new ArrayBuffer(8));let r=0;for(const i of e.match(/.{2}/g).reverse())n.set([parseInt(i,16)],r++),t>>=ms;return Je(n)}function ys(t){const e=We(t);if(e.byteLength!==8)throw new Error(`Received ${e.byteLength} bytes, expected 8 for $integer`);let n=an,r=an;for(const i of e)n+=BigInt(i)*xs**r,r++;return n>sn&&(n+=Re+Re),n}function vs(t){if(t<Re||sn<t)throw new Error(`BigInt ${t} does not fit into a 64-bit signed integer.`);const e=new ArrayBuffer(8);return new DataView(e).setBigInt64(0,t,!0),Je(new Uint8Array(e))}function ws(t){const e=We(t);if(e.byteLength!==8)throw new Error(`Received ${e.byteLength} bytes, expected 8 for $integer`);return new DataView(e.buffer).getBigInt64(0,!0)}const _s=DataView.prototype.setBigInt64?vs:bs,ks=DataView.prototype.getBigInt64?ws:ys,Dr=1024;function Vr(t){if(t.length>Dr)throw new Error(`Field name ${t} exceeds maximum field name length ${Dr}.`);if(t.startsWith("$"))throw new Error(`Field name ${t} starts with a '$', which is reserved.`);for(let e=0;e<t.length;e+=1){const n=t.charCodeAt(e);if(n<32||n>=127)throw new Error(`Field name ${t} has invalid character '${t[e]}': Field names can only contain non-control ASCII characters`)}}function $e(t){if(t===null||typeof t=="boolean"||typeof t=="number"||typeof t=="string")return t;if(Array.isArray(t))return t.map(r=>$e(r));if(typeof t!="object")throw new Error(`Unexpected type of ${t}`);const e=Object.entries(t);if(e.length===1){const r=e[0][0];if(r==="$bytes"){if(typeof t.$bytes!="string")throw new Error(`Malformed $bytes field on ${t}`);return We(t.$bytes).buffer}if(r==="$integer"){if(typeof t.$integer!="string")throw new Error(`Malformed $integer field on ${t}`);return ks(t.$integer)}if(r==="$float"){if(typeof t.$float!="string")throw new Error(`Malformed $float field on ${t}`);const i=We(t.$float);if(i.byteLength!==8)throw new Error(`Received ${i.byteLength} bytes, expected 8 for $float`);const s=new DataView(i.buffer).getFloat64(0,Fr);if(!Qr(s))throw new Error(`Float ${s} should be encoded as a number`);return s}if(r==="$set")throw new Error("Received a Set which is no longer supported as a Convex type.");if(r==="$map")throw new Error("Received a Map which is no longer supported as a Convex type.")}const n={};for(const[r,i]of Object.entries(t))Vr(r),n[r]=$e(i);return n}const Hr=16384;function Ge(t){const e=JSON.stringify(t,(n,r)=>r===void 0?"undefined":typeof r=="bigint"?`${r.toString()}n`:r);if(e.length>Hr){const n="[...truncated]";let r=Hr-n.length;const i=e.codePointAt(r-1);return i!==void 0&&i>65535&&(r-=1),e.substring(0,r)+n}return e}function ln(t,e,n,r){if(t===void 0){const s=n&&` (present at path ${n} in original object ${Ge(e)})`;throw new Error(`undefined is not a valid Convex value${s}. To learn about Convex's supported types, see https://docs.convex.dev/using/types.`)}if(t===null)return t;if(typeof t=="bigint"){if(t<Re||sn<t)throw new Error(`BigInt ${t} does not fit into a 64-bit signed integer.`);return{$integer:_s(t)}}if(typeof t=="number")if(Qr(t)){const s=new ArrayBuffer(8);return new DataView(s).setFloat64(0,t,Fr),{$float:Je(new Uint8Array(s))}}else return t;if(typeof t=="boolean"||typeof t=="string")return t;if(t instanceof ArrayBuffer)return{$bytes:Je(new Uint8Array(t))};if(Array.isArray(t))return t.map((s,l)=>ln(s,e,n+`[${l}]`));if(t instanceof Set)throw new Error(cn(n,"Set",[...t],e));if(t instanceof Map)throw new Error(cn(n,"Map",[...t],e));if(!Ur(t)){const s=t?.constructor?.name,l=s?`${s} `:"";throw new Error(cn(n,l,t,e))}const i={},o=Object.entries(t);o.sort(([s,l],[a,u])=>s===a?0:s<a?-1:1);for(const[s,l]of o)l!==void 0&&(Vr(s),i[s]=ln(l,e,n+`.${s}`));return i}function cn(t,e,n,r){return t?`${e}${Ge(n)} is not a supported Convex type (present at path ${t} in original object ${Ge(r)}). To learn about Convex's supported types, see https://docs.convex.dev/using/types.`:`${e}${Ge(n)} is not a supported Convex type.`}function ee(t){return ln(t,t,"")}var js=Object.defineProperty,Ss=(t,e,n)=>e in t?js(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,un=(t,e,n)=>Ss(t,typeof e!="symbol"?e+"":e,n),Wr,Jr;const Cs=Symbol.for("ConvexError");class xt extends(Jr=Error,Wr=Cs,Jr){constructor(e){super(typeof e=="string"?e:Ge(e)),un(this,"name","ConvexError"),un(this,"data"),un(this,Wr,!0),this.data=e}}const Gr=()=>Array.from({length:4},()=>0);Gr(),Gr();const Kr="1.39.1";var Ts=Object.defineProperty,Rs=(t,e,n)=>e in t?Ts(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Zr=(t,e,n)=>Rs(t,typeof e!="symbol"?e+"":e,n);const $s="color:rgb(0, 145, 255)";function Yr(t){switch(t){case"query":return"Q";case"mutation":return"M";case"action":return"A";case"any":return"?"}}class Xr{constructor(e){Zr(this,"_onLogLineFuncs"),Zr(this,"_verbose"),this._onLogLineFuncs={},this._verbose=e.verbose}addLogLineListener(e){let n=Math.random().toString(36).substring(2,15);for(let r=0;r<10&&this._onLogLineFuncs[n]!==void 0;r++)n=Math.random().toString(36).substring(2,15);return this._onLogLineFuncs[n]=e,()=>{delete this._onLogLineFuncs[n]}}logVerbose(...e){if(this._verbose)for(const n of Object.values(this._onLogLineFuncs))n("debug",`${new Date().toISOString()}`,...e)}log(...e){for(const n of Object.values(this._onLogLineFuncs))n("info",...e)}warn(...e){for(const n of Object.values(this._onLogLineFuncs))n("warn",...e)}error(...e){for(const n of Object.values(this._onLogLineFuncs))n("error",...e)}}function ei(t){const e=new Xr(t);return e.addLogLineListener((n,...r)=>{switch(n){case"debug":console.debug(...r);break;case"info":console.log(...r);break;case"warn":console.warn(...r);break;case"error":console.error(...r);break;default:console.log(...r)}}),e}function ti(t){return new Xr(t)}function bt(t,e,n,r,i){const o=Yr(n);if(typeof i=="object"&&(i=`ConvexError ${JSON.stringify(i.errorData,null,2)}`),e==="info"){const s=i.match(/^\[.*?\] /);if(s===null){t.error(`[CONVEX ${o}(${r})] Could not parse console.log`);return}const l=i.slice(1,s[0].length-2),a=i.slice(s[0].length);t.log(`%c[CONVEX ${o}(${r})] [${l}]`,$s,a)}else t.error(`[CONVEX ${o}(${r})] ${i}`)}function As(t,e){const n=`[CONVEX FATAL ERROR] ${e}`;return t.error(n),new Error(n)}function Ae(t,e,n){return`[CONVEX ${Yr(t)}(${e})] ${n.errorMessage}
|
|
2
|
-
Called by client`}function hn(t,e){return e.data=t.errorData,e}function pe(t){const e=t.split(":");let n,r;return e.length===1?(n=e[0],r="default"):(n=e.slice(0,e.length-1).join(":"),r=e[e.length-1]),n.endsWith(".js")&&(n=n.slice(0,-3)),`${n}:${r}`}function ge(t,e){return JSON.stringify({udfPath:pe(t),args:ee(e)})}function ni(t,e,n){const{initialNumItems:r,id:i}=n;return JSON.stringify({type:"paginated",udfPath:pe(t),args:ee(e),options:ee({initialNumItems:r,id:i})})}var Es=Object.defineProperty,Ps=(t,e,n)=>e in t?Es(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,te=(t,e,n)=>Ps(t,typeof e!="symbol"?e+"":e,n);class Is{constructor(){te(this,"nextQueryId"),te(this,"querySetVersion"),te(this,"querySet"),te(this,"queryIdToToken"),te(this,"identityVersion"),te(this,"auth"),te(this,"outstandingQueriesOlderThanRestart"),te(this,"outstandingAuthOlderThanRestart"),te(this,"paused"),te(this,"pendingQuerySetModifications"),this.nextQueryId=0,this.querySetVersion=0,this.identityVersion=0,this.querySet=new Map,this.queryIdToToken=new Map,this.outstandingQueriesOlderThanRestart=new Set,this.outstandingAuthOlderThanRestart=!1,this.paused=!1,this.pendingQuerySetModifications=new Map}hasSyncedPastLastReconnect(){return this.outstandingQueriesOlderThanRestart.size===0&&!this.outstandingAuthOlderThanRestart}markAuthCompletion(){this.outstandingAuthOlderThanRestart=!1}subscribe(e,n,r,i){const o=pe(e),s=ge(o,n),l=this.querySet.get(s);if(l!==void 0)return l.numSubscribers+=1,{queryToken:s,modification:null,unsubscribe:()=>this.removeSubscriber(s)};{const a=this.nextQueryId++,u={id:a,canonicalizedUdfPath:o,args:n,numSubscribers:1,journal:r,componentPath:i};this.querySet.set(s,u),this.queryIdToToken.set(a,s);const d=this.querySetVersion,h=this.querySetVersion+1,f={type:"Add",queryId:a,udfPath:o,args:[ee(n)],journal:r,componentPath:i};return this.paused?this.pendingQuerySetModifications.set(a,f):this.querySetVersion=h,{queryToken:s,modification:{type:"ModifyQuerySet",baseVersion:d,newVersion:h,modifications:[f]},unsubscribe:()=>this.removeSubscriber(s)}}}transition(e){for(const n of e.modifications)switch(n.type){case"QueryUpdated":case"QueryFailed":{this.outstandingQueriesOlderThanRestart.delete(n.queryId);const r=n.journal;if(r!==void 0){const i=this.queryIdToToken.get(n.queryId);i!==void 0&&(this.querySet.get(i).journal=r)}break}case"QueryRemoved":{this.outstandingQueriesOlderThanRestart.delete(n.queryId);break}default:throw new Error(`Invalid modification ${n.type}`)}}queryId(e,n){const r=pe(e),i=ge(r,n),o=this.querySet.get(i);return o!==void 0?o.id:null}isCurrentOrNewerAuthVersion(e){return e>=this.identityVersion}getAuth(){return this.auth}setAuth(e){this.auth={tokenType:"User",value:e};const n=this.identityVersion;return this.paused||(this.identityVersion=n+1),{type:"Authenticate",baseVersion:n,...this.auth}}setAdminAuth(e,n){const r={tokenType:"Admin",value:e,impersonating:n};this.auth=r;const i=this.identityVersion;return this.paused||(this.identityVersion=i+1),{type:"Authenticate",baseVersion:i,...r}}clearAuth(){this.auth=void 0,this.markAuthCompletion();const e=this.identityVersion;return this.paused||(this.identityVersion=e+1),{type:"Authenticate",tokenType:"None",baseVersion:e}}hasAuth(){return!!this.auth}isNewAuth(e){return this.auth?.value!==e}queryPath(e){const n=this.queryIdToToken.get(e);return n?this.querySet.get(n).canonicalizedUdfPath:null}queryArgs(e){const n=this.queryIdToToken.get(e);return n?this.querySet.get(n).args:null}queryToken(e){return this.queryIdToToken.get(e)??null}queryJournal(e){return this.querySet.get(e)?.journal}restart(){this.unpause(),this.outstandingQueriesOlderThanRestart.clear();const e=[];for(const i of this.querySet.values()){const o={type:"Add",queryId:i.id,udfPath:i.canonicalizedUdfPath,args:[ee(i.args)],journal:i.journal,componentPath:i.componentPath};e.push(o),this.outstandingQueriesOlderThanRestart.add(i.id)}this.querySetVersion=1;const n={type:"ModifyQuerySet",baseVersion:0,newVersion:1,modifications:e};if(!this.auth)return this.identityVersion=0,[n,void 0];this.outstandingAuthOlderThanRestart=!0;const r={type:"Authenticate",baseVersion:0,...this.auth};return this.identityVersion=1,[n,r]}pause(){this.paused=!0}resume(){const e=this.pendingQuerySetModifications.size>0?{type:"ModifyQuerySet",baseVersion:this.querySetVersion,newVersion:++this.querySetVersion,modifications:Array.from(this.pendingQuerySetModifications.values())}:void 0,n=this.auth!==void 0?{type:"Authenticate",baseVersion:this.identityVersion++,...this.auth}:void 0;return this.unpause(),[e,n]}unpause(){this.paused=!1,this.pendingQuerySetModifications.clear()}removeSubscriber(e){const n=this.querySet.get(e);if(n.numSubscribers>1)return n.numSubscribers-=1,null;{this.querySet.delete(e),this.queryIdToToken.delete(n.id),this.outstandingQueriesOlderThanRestart.delete(n.id);const r=this.querySetVersion,i=this.querySetVersion+1,o={type:"Remove",queryId:n.id};return this.paused?this.pendingQuerySetModifications.has(n.id)?this.pendingQuerySetModifications.delete(n.id):this.pendingQuerySetModifications.set(n.id,o):this.querySetVersion=i,{type:"ModifyQuerySet",baseVersion:r,newVersion:i,modifications:[o]}}}}var Ls=Object.defineProperty,Ms=(t,e,n)=>e in t?Ls(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,yt=(t,e,n)=>Ms(t,typeof e!="symbol"?e+"":e,n);class qs{constructor(e,n){this.logger=e,this.markConnectionStateDirty=n,yt(this,"inflightRequests"),yt(this,"requestsOlderThanRestart"),yt(this,"inflightMutationsCount",0),yt(this,"inflightActionsCount",0),this.inflightRequests=new Map,this.requestsOlderThanRestart=new Set}request(e,n){const r=new Promise(i=>{const o=n?"Requested":"NotSent";this.inflightRequests.set(e.requestId,{message:e,status:{status:o,requestedAt:new Date,onResult:i}}),e.type==="Mutation"?this.inflightMutationsCount++:e.type==="Action"&&this.inflightActionsCount++});return this.markConnectionStateDirty(),r}onResponse(e){const n=this.inflightRequests.get(e.requestId);if(n===void 0||n.status.status==="Completed")return null;const r=n.message.type==="Mutation"?"mutation":"action",i=n.message.udfPath;for(const a of e.logLines)bt(this.logger,"info",r,i,a);const o=n.status;let s,l;if(e.success)s={success:!0,logLines:e.logLines,value:$e(e.result)},l=()=>o.onResult(s);else{const a=e.result,{errorData:u}=e;bt(this.logger,"error",r,i,a),s={success:!1,errorMessage:a,errorData:u!==void 0?$e(u):void 0,logLines:e.logLines},l=()=>o.onResult(s)}return e.type==="ActionResponse"||!e.success?(l(),this.inflightRequests.delete(e.requestId),this.requestsOlderThanRestart.delete(e.requestId),n.message.type==="Action"?this.inflightActionsCount--:n.message.type==="Mutation"&&this.inflightMutationsCount--,this.markConnectionStateDirty(),{requestId:e.requestId,result:s}):(n.status={status:"Completed",result:s,ts:e.ts,onResolve:l},null)}removeCompleted(e){const n=new Map;for(const[r,i]of this.inflightRequests.entries()){const o=i.status;o.status==="Completed"&&o.ts.lessThanOrEqual(e)&&(o.onResolve(),n.set(r,o.result),i.message.type==="Mutation"?this.inflightMutationsCount--:i.message.type==="Action"&&this.inflightActionsCount--,this.inflightRequests.delete(r),this.requestsOlderThanRestart.delete(r))}return n.size>0&&this.markConnectionStateDirty(),n}restart(){this.requestsOlderThanRestart=new Set(this.inflightRequests.keys());const e=[];for(const[n,r]of this.inflightRequests){if(r.status.status==="NotSent"){r.status.status="Requested",e.push(r.message);continue}if(r.message.type==="Mutation")e.push(r.message);else if(r.message.type==="Action"){if(this.inflightRequests.delete(n),this.requestsOlderThanRestart.delete(n),this.inflightActionsCount--,r.status.status==="Completed")throw new Error("Action should never be in 'Completed' state");r.status.onResult({success:!1,errorMessage:"Connection lost while action was in flight",logLines:[]})}}return this.markConnectionStateDirty(),e}resume(){const e=[];for(const[,n]of this.inflightRequests)if(n.status.status==="NotSent"){n.status.status="Requested",e.push(n.message);continue}return e}hasIncompleteRequests(){for(const e of this.inflightRequests.values())if(e.status.status==="Requested")return!0;return!1}hasInflightRequests(){return this.inflightRequests.size>0}hasSyncedPastLastReconnect(){return this.requestsOlderThanRestart.size===0}timeOfOldestInflightRequest(){if(this.inflightRequests.size===0)return null;let e=Date.now();for(const n of this.inflightRequests.values())n.status.status!=="Completed"&&n.status.requestedAt.getTime()<e&&(e=n.status.requestedAt.getTime());return new Date(e)}inflightMutations(){return this.inflightMutationsCount}inflightActions(){return this.inflightActionsCount}}const Ke=Symbol.for("functionName"),Os=Symbol.for("toReferencePath");function Ns(t){return t[Os]??null}function zs(t){return t.startsWith("function://")}function Bs(t){let e;if(typeof t=="string")zs(t)?e={functionHandle:t}:e={name:t};else if(t[Ke])e={name:t[Ke]};else{const n=Ns(t);if(!n)throw new Error(`${t} is not a functionReference`);e={reference:n}}return e}function O(t){const e=Bs(t);if(e.name===void 0)throw e.functionHandle!==void 0?new Error(`Expected function reference like "api.file.func" or "internal.file.func", but received function handle ${e.functionHandle}`):e.reference!==void 0?new Error(`Expected function reference in the current component like "api.file.func" or "internal.file.func", but received reference ${e.reference}`):new Error(`Expected function reference like "api.file.func" or "internal.file.func", but received ${JSON.stringify(e)}`);if(typeof t=="string")return t;const n=t[Ke];if(!n)throw new Error(`${t} is not a functionReference`);return n}function ri(t){return{[Ke]:t}}function ii(t=[]){const e={get(n,r){if(typeof r=="string"){const i=[...t,r];return ii(i)}else if(r===Ke){if(t.length<2){const s=["api",...t].join(".");throw new Error(`API path is expected to be of the form \`api.moduleName.functionName\`. Found: \`${s}\``)}const i=t.slice(0,-1).join("/"),o=t[t.length-1];return o==="default"?i:i+":"+o}else return r===Symbol.toStringTag?"FunctionReference":void 0}};return new Proxy({},e)}ii();var Us=Object.defineProperty,Fs=(t,e,n)=>e in t?Us(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,vt=(t,e,n)=>Fs(t,typeof e!="symbol"?e+"":e,n);class Ze{constructor(e){vt(this,"queryResults"),vt(this,"modifiedQueries"),this.queryResults=e,this.modifiedQueries=[]}getQuery(e,...n){const r=ie(n[0]),i=O(e),o=this.queryResults.get(ge(i,r));if(o!==void 0)return Ze.queryValue(o.result)}getAllQueries(e){const n=[],r=O(e);for(const i of this.queryResults.values())i.udfPath===pe(r)&&n.push({args:i.args,value:Ze.queryValue(i.result)});return n}setQuery(e,n,r){const i=ie(n),o=O(e),s=ge(o,i);let l;r===void 0?l=void 0:l={success:!0,value:r,logLines:[]};const a={udfPath:o,args:i,result:l};this.queryResults.set(s,a),this.modifiedQueries.push(s)}static queryValue(e){if(e!==void 0)return e.success?e.value:void 0}}class Qs{constructor(){vt(this,"queryResults"),vt(this,"optimisticUpdates"),this.queryResults=new Map,this.optimisticUpdates=[]}ingestQueryResultsFromServer(e,n){this.optimisticUpdates=this.optimisticUpdates.filter(s=>!n.has(s.mutationId));const r=this.queryResults;this.queryResults=new Map(e);const i=new Ze(this.queryResults);for(const s of this.optimisticUpdates)s.update(i);const o=[];for(const[s,l]of this.queryResults){const a=r.get(s);(a===void 0||a.result!==l.result)&&o.push(s)}return o}applyOptimisticUpdate(e,n){this.optimisticUpdates.push({update:e,mutationId:n});const r=new Ze(this.queryResults);return e(r),r.modifiedQueries}rawQueryResult(e){const n=this.queryResults.get(e);if(n!==void 0)return n.result}queryResult(e){const n=this.queryResults.get(e);if(n===void 0)return;const r=n.result;if(r!==void 0){if(r.success)return r.value;throw r.errorData!==void 0?hn(r,new xt(Ae("query",n.udfPath,r))):new Error(Ae("query",n.udfPath,r))}}hasQueryResult(e){return this.queryResults.get(e)!==void 0}queryLogs(e){return this.queryResults.get(e)?.result?.logLines}}var Ds=Object.defineProperty,Vs=(t,e,n)=>e in t?Ds(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,dn=(t,e,n)=>Vs(t,typeof e!="symbol"?e+"":e,n);class N{constructor(e,n){dn(this,"low"),dn(this,"high"),dn(this,"__isUnsignedLong__"),this.low=e|0,this.high=n|0,this.__isUnsignedLong__=!0}static isLong(e){return(e&&e.__isUnsignedLong__)===!0}static fromBytesLE(e){return new N(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24)}toBytesLE(){const e=this.high,n=this.low;return[n&255,n>>>8&255,n>>>16&255,n>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]}static fromNumber(e){return isNaN(e)||e<0?oi:e>=Hs?Ws:new N(e%Ye|0,e/Ye|0)}toString(){return(BigInt(this.high)*BigInt(Ye)+BigInt(this.low)).toString()}equals(e){return N.isLong(e)||(e=N.fromValue(e)),this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low}notEquals(e){return!this.equals(e)}comp(e){return N.isLong(e)||(e=N.fromValue(e)),this.equals(e)?0:e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1}lessThanOrEqual(e){return this.comp(e)<=0}static fromValue(e){return typeof e=="number"?N.fromNumber(e):new N(e.low,e.high)}}const oi=new N(0,0),si=65536,Ye=si*si,Hs=Ye*Ye,Ws=new N(-1,-1);var Js=Object.defineProperty,Gs=(t,e,n)=>e in t?Js(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,wt=(t,e,n)=>Gs(t,typeof e!="symbol"?e+"":e,n);class ai{constructor(e,n){wt(this,"version"),wt(this,"remoteQuerySet"),wt(this,"queryPath"),wt(this,"logger"),this.version={querySet:0,ts:N.fromNumber(0),identity:0},this.remoteQuerySet=new Map,this.queryPath=e,this.logger=n}transition(e){const n=e.startVersion;if(this.version.querySet!==n.querySet||this.version.ts.notEquals(n.ts)||this.version.identity!==n.identity)throw new Error(`Invalid start version: ${n.ts.toString()}:${n.querySet}:${n.identity}, transitioning from ${this.version.ts.toString()}:${this.version.querySet}:${this.version.identity}`);for(const r of e.modifications)switch(r.type){case"QueryUpdated":{const i=this.queryPath(r.queryId);if(i)for(const s of r.logLines)bt(this.logger,"info","query",i,s);const o=$e(r.value??null);this.remoteQuerySet.set(r.queryId,{success:!0,value:o,logLines:r.logLines});break}case"QueryFailed":{const i=this.queryPath(r.queryId);if(i)for(const s of r.logLines)bt(this.logger,"info","query",i,s);const{errorData:o}=r;this.remoteQuerySet.set(r.queryId,{success:!1,errorMessage:r.errorMessage,errorData:o!==void 0?$e(o):void 0,logLines:r.logLines});break}case"QueryRemoved":{this.remoteQuerySet.delete(r.queryId);break}default:throw new Error(`Invalid modification ${r.type}`)}this.version=e.endVersion}remoteQueryResults(){return this.remoteQuerySet}timestamp(){return this.version.ts}}function fn(t){const e=We(t);return N.fromBytesLE(Array.from(e))}function Ks(t){const e=new Uint8Array(t.toBytesLE());return Je(e)}function li(t){switch(t.type){case"FatalError":case"AuthError":case"ActionResponse":case"TransitionChunk":case"Ping":return{...t};case"MutationResponse":return t.success?{...t,ts:fn(t.ts)}:{...t};case"Transition":return{...t,startVersion:{...t.startVersion,ts:fn(t.startVersion.ts)},endVersion:{...t.endVersion,ts:fn(t.endVersion.ts)}}}}function Zs(t){switch(t.type){case"Authenticate":case"ModifyQuerySet":case"Mutation":case"Action":case"Event":return{...t};case"Connect":return t.maxObservedTimestamp!==void 0?{...t,maxObservedTimestamp:Ks(t.maxObservedTimestamp)}:{...t,maxObservedTimestamp:void 0}}}var Ys=Object.defineProperty,Xs=(t,e,n)=>e in t?Ys(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,A=(t,e,n)=>Xs(t,typeof e!="symbol"?e+"":e,n);const ea=1e3,ta=1001,na=1005,ra=4040;let _t;function Ee(){return _t===void 0&&(_t=Date.now()),typeof performance>"u"||!performance.now?Date.now():Math.round(_t+performance.now())}function ci(){return`t=${Math.round((Ee()-_t)/100)/10}s`}const ui={InternalServerError:{timeout:1e3},SubscriptionsWorkerFullError:{timeout:3e3},TooManyConcurrentRequests:{timeout:3e3},CommitterFullError:{timeout:3e3},AwsTooManyRequestsException:{timeout:3e3},ExecuteFullError:{timeout:3e3},SystemTimeoutError:{timeout:3e3},ExpiredInQueue:{timeout:3e3},VectorIndexesUnavailable:{timeout:1e3},SearchIndexesUnavailable:{timeout:1e3},TableSummariesUnavailable:{timeout:1e3},VectorIndexTooLarge:{timeout:3e3},SearchIndexTooLarge:{timeout:3e3},TooManyWritesInTimePeriod:{timeout:3e3}};function ia(t){if(t===void 0)return"Unknown";for(const e of Object.keys(ui))if(t.startsWith(e))return e;return"Unknown"}class oa{constructor(e,n,r,i,o,s){this.markConnectionStateDirty=o,this.debug=s,A(this,"socket"),A(this,"connectionCount"),A(this,"_hasEverConnected",!1),A(this,"lastCloseReason"),A(this,"transitionChunkBuffer",null),A(this,"defaultInitialBackoff"),A(this,"maxBackoff"),A(this,"retries"),A(this,"serverInactivityThreshold"),A(this,"reconnectDueToServerInactivityTimeout"),A(this,"scheduledReconnect",null),A(this,"networkOnlineHandler",null),A(this,"pendingNetworkRecoveryInfo",null),A(this,"uri"),A(this,"onOpen"),A(this,"onResume"),A(this,"onMessage"),A(this,"webSocketConstructor"),A(this,"logger"),A(this,"onServerDisconnectError"),this.webSocketConstructor=r,this.socket={state:"disconnected"},this.connectionCount=0,this.lastCloseReason="InitialConnect",this.defaultInitialBackoff=1e3,this.maxBackoff=16e3,this.retries=0,this.serverInactivityThreshold=6e4,this.reconnectDueToServerInactivityTimeout=null,this.uri=e,this.onOpen=n.onOpen,this.onResume=n.onResume,this.onMessage=n.onMessage,this.onServerDisconnectError=n.onServerDisconnectError,this.logger=i,this.setupNetworkListener(),this.connect()}setSocketState(e){this.socket=e,this._logVerbose(`socket state changed: ${this.socket.state}, paused: ${"paused"in this.socket?this.socket.paused:void 0}`),this.markConnectionStateDirty()}setupNetworkListener(){typeof window>"u"||typeof window.addEventListener!="function"||this.networkOnlineHandler===null&&(this.networkOnlineHandler=()=>{this._logVerbose("network online event detected"),this.tryReconnectImmediately()},window.addEventListener("online",this.networkOnlineHandler),this._logVerbose("network online event listener registered"))}cleanupNetworkListener(){this.networkOnlineHandler&&typeof window<"u"&&typeof window.removeEventListener=="function"&&(window.removeEventListener("online",this.networkOnlineHandler),this.networkOnlineHandler=null,this._logVerbose("network online event listener removed"))}assembleTransition(e){if(e.partNumber<0||e.partNumber>=e.totalParts||e.totalParts===0||this.transitionChunkBuffer&&(this.transitionChunkBuffer.totalParts!==e.totalParts||this.transitionChunkBuffer.transitionId!==e.transitionId))throw this.transitionChunkBuffer=null,new Error("Invalid TransitionChunk");if(this.transitionChunkBuffer===null&&(this.transitionChunkBuffer={chunks:[],totalParts:e.totalParts,transitionId:e.transitionId}),e.partNumber!==this.transitionChunkBuffer.chunks.length){const n=this.transitionChunkBuffer.chunks.length;throw this.transitionChunkBuffer=null,new Error(`TransitionChunk received out of order: expected part ${n}, got ${e.partNumber}`)}if(this.transitionChunkBuffer.chunks.push(e.chunk),this.transitionChunkBuffer.chunks.length===e.totalParts){const n=this.transitionChunkBuffer.chunks.join("");this.transitionChunkBuffer=null;const r=li(JSON.parse(n));if(r.type!=="Transition")throw new Error(`Expected Transition, got ${r.type} after assembling chunks`);return r}return null}connect(){if(this.socket.state==="terminated")return;if(this.socket.state!=="disconnected"&&this.socket.state!=="stopped")throw new Error("Didn't start connection from disconnected state: "+this.socket.state);const e=new this.webSocketConstructor(this.uri);this._logVerbose("constructed WebSocket"),this.setSocketState({state:"connecting",ws:e,paused:"no"}),this.resetServerInactivityTimeout(),e.onopen=()=>{if(this.logger.logVerbose("begin ws.onopen"),this.socket.state!=="connecting")throw new Error("onopen called with socket not in connecting state");if(this.setSocketState({state:"ready",ws:e,paused:this.socket.paused==="yes"?"uninitialized":"no"}),this.resetServerInactivityTimeout(),this.socket.paused==="no"&&(this._hasEverConnected=!0,this.onOpen({connectionCount:this.connectionCount,lastCloseReason:this.lastCloseReason,clientTs:Ee()})),this.lastCloseReason!=="InitialConnect"&&(this.lastCloseReason?this.logger.log("WebSocket reconnected at",ci(),"after disconnect due to",this.lastCloseReason):this.logger.log("WebSocket reconnected at",ci())),this.connectionCount+=1,this.lastCloseReason=null,this.pendingNetworkRecoveryInfo!==null){const{timeSavedMs:n}=this.pendingNetworkRecoveryInfo;this.pendingNetworkRecoveryInfo=null,this.sendMessage({type:"Event",eventType:"NetworkRecoveryReconnect",event:{timeSavedMs:n}}),this.logger.log(`Network recovery reconnect saved ~${Math.round(n/1e3)}s of waiting`)}},e.onerror=n=>{this.transitionChunkBuffer=null;const r=n.message;r&&this.logger.log(`WebSocket error message: ${r}`)},e.onmessage=n=>{this.resetServerInactivityTimeout();const r=n.data.length;let i=li(JSON.parse(n.data));if(this._logVerbose(`received ws message with type ${i.type}`),i.type==="Ping")return;if(i.type==="TransitionChunk"){const s=this.assembleTransition(i);if(!s)return;i=s,this._logVerbose(`assembled full ws message of type ${i.type}`)}this.transitionChunkBuffer!==null&&(this.transitionChunkBuffer=null,this.logger.log(`Received unexpected ${i.type} while buffering TransitionChunks`)),i.type==="Transition"&&this.reportLargeTransition({messageLength:r,transition:i}),this.onMessage(i).hasSyncedPastLastReconnect&&(this.retries=0,this.markConnectionStateDirty())},e.onclose=n=>{if(this._logVerbose("begin ws.onclose"),this.transitionChunkBuffer=null,this.lastCloseReason===null&&(this.lastCloseReason=n.reason||`closed with code ${n.code}`),n.code!==ea&&n.code!==ta&&n.code!==na&&n.code!==ra){let i=`WebSocket closed with code ${n.code}`;n.reason&&(i+=`: ${n.reason}`),this.logger.log(i),this.onServerDisconnectError&&n.reason&&this.onServerDisconnectError(i)}const r=ia(n.reason);this.scheduleReconnect(r)}}socketState(){return this.socket.state}sendMessage(e){const n={type:e.type,...e.type==="Authenticate"&&e.tokenType==="User"?{value:`...${e.value.slice(-7)}`}:{}};if(this.socket.state==="ready"&&this.socket.paused==="no"){const r=Zs(e),i=JSON.stringify(r);let o=!1;try{this.socket.ws.send(i),o=!0}catch(s){this.logger.log(`Failed to send message on WebSocket, reconnecting: ${s}`),this.closeAndReconnect("FailedToSendMessage")}return this._logVerbose(`${o?"sent":"failed to send"} message with type ${e.type}: ${JSON.stringify(n)}`),!0}return this._logVerbose(`message not sent (socket state: ${this.socket.state}, paused: ${"paused"in this.socket?this.socket.paused:void 0}): ${JSON.stringify(n)}`),!1}resetServerInactivityTimeout(){this.socket.state!=="terminated"&&(this.reconnectDueToServerInactivityTimeout!==null&&(clearTimeout(this.reconnectDueToServerInactivityTimeout),this.reconnectDueToServerInactivityTimeout=null),this.reconnectDueToServerInactivityTimeout=setTimeout(()=>{this.closeAndReconnect("InactiveServer")},this.serverInactivityThreshold))}scheduleReconnect(e){this.scheduledReconnect&&(clearTimeout(this.scheduledReconnect.timeout),this.scheduledReconnect=null),this.socket={state:"disconnected"};const n=this.nextBackoff(e);this.markConnectionStateDirty(),this.logger.log(`Attempting reconnect in ${Math.round(n)}ms`);const r=Ee(),i=setTimeout(()=>{this.scheduledReconnect?.timeout===i&&(this.scheduledReconnect=null,this.connect())},n);this.scheduledReconnect={timeout:i,scheduledAt:r,backoffMs:n}}closeAndReconnect(e){switch(this._logVerbose(`begin closeAndReconnect with reason ${e}`),this.socket.state){case"disconnected":case"terminated":case"stopped":return;case"connecting":case"ready":{this.lastCloseReason=e,this.close(),this.scheduleReconnect("client");return}default:this.socket}}close(){switch(this.transitionChunkBuffer=null,this.socket.state){case"disconnected":case"terminated":case"stopped":return Promise.resolve();case"connecting":{const e=this.socket.ws;return e.onmessage=n=>{this._logVerbose("Ignoring message received after close")},new Promise(n=>{e.onclose=()=>{this._logVerbose("Closed after connecting"),n()},e.onopen=()=>{this._logVerbose("Opened after connecting"),e.close()}})}case"ready":{this._logVerbose("ws.close called");const e=this.socket.ws;e.onmessage=r=>{this._logVerbose("Ignoring message received after close")};const n=new Promise(r=>{e.onclose=()=>{r()}});return e.close(),n}default:return this.socket,Promise.resolve()}}terminate(){switch(this.reconnectDueToServerInactivityTimeout&&clearTimeout(this.reconnectDueToServerInactivityTimeout),this.scheduledReconnect&&(clearTimeout(this.scheduledReconnect.timeout),this.scheduledReconnect=null),this.cleanupNetworkListener(),this.socket.state){case"terminated":case"stopped":case"disconnected":case"connecting":case"ready":{const e=this.close();return this.setSocketState({state:"terminated"}),e}default:throw this.socket,new Error(`Invalid websocket state: ${this.socket.state}`)}}stop(){switch(this.socket.state){case"terminated":return Promise.resolve();case"connecting":case"stopped":case"disconnected":case"ready":{this.cleanupNetworkListener();const e=this.close();return this.socket={state:"stopped"},e}default:return this.socket,Promise.resolve()}}tryRestart(){switch(this.socket.state){case"stopped":break;case"terminated":case"connecting":case"ready":case"disconnected":this.logger.logVerbose("Restart called without stopping first");return;default:this.socket}this.setupNetworkListener(),this.connect()}pause(){switch(this.socket.state){case"disconnected":case"stopped":case"terminated":return;case"connecting":case"ready":{this.socket={...this.socket,paused:"yes"};return}default:{this.socket;return}}}tryReconnectImmediately(){if(this._logVerbose("tryReconnectImmediately called"),this.socket.state!=="disconnected"){this._logVerbose(`tryReconnectImmediately called but socket state is ${this.socket.state}, no action taken`);return}let e=null;if(this.scheduledReconnect){const n=Ee()-this.scheduledReconnect.scheduledAt;e=Math.max(0,this.scheduledReconnect.backoffMs-n),this._logVerbose(`would have waited ${Math.round(e)}ms more (backoff was ${Math.round(this.scheduledReconnect.backoffMs)}ms, elapsed ${Math.round(n)}ms)`),clearTimeout(this.scheduledReconnect.timeout),this.scheduledReconnect=null,this._logVerbose("canceled scheduled reconnect")}this.logger.log("Network recovery detected, reconnecting immediately"),this.pendingNetworkRecoveryInfo=e!==null?{timeSavedMs:e}:null,this.connect()}resume(){switch(this.socket.state){case"connecting":this.socket={...this.socket,paused:"no"};return;case"ready":this.socket.paused==="uninitialized"?(this.socket={...this.socket,paused:"no"},this._hasEverConnected=!0,this.onOpen({connectionCount:this.connectionCount,lastCloseReason:this.lastCloseReason,clientTs:Ee()})):this.socket.paused==="yes"&&(this.socket={...this.socket,paused:"no"},this.onResume());return;case"terminated":case"stopped":case"disconnected":return;default:this.socket}this.connect()}connectionState(){return{isConnected:this.socket.state==="ready",hasEverConnected:this._hasEverConnected,connectionCount:this.connectionCount,connectionRetries:this.retries}}_logVerbose(e){this.logger.logVerbose(e)}nextBackoff(e){const r=(e==="client"?100:e==="Unknown"?this.defaultInitialBackoff:ui[e].timeout)*Math.pow(2,this.retries);this.retries+=1;const i=Math.min(r,this.maxBackoff),o=i*(Math.random()-.5);return i+o}reportLargeTransition({transition:e,messageLength:n}){if(e.clientClockSkew===void 0||e.serverTs===void 0)return;const r=Ee()-e.clientClockSkew-e.serverTs/1e6,i=`${Math.round(r)}ms`,o=`${Math.round(n/1e4)/100}MB`,s=n/(r/1e3),l=`${Math.round(s/1e4)/100}MB per second`;this._logVerbose(`received ${o} transition in ${i} at ${l}`),n>2e7?this.logger.log(`received query results totaling more that 20MB (${o}) which will take a long time to download on slower connections`):r>2e4&&this.logger.log(`received query results totaling ${o} which took more than 20s to arrive (${i})`),this.debug&&this.sendMessage({type:"Event",eventType:"ClientReceivedTransition",event:{transitionTransitTime:r,messageLength:n}})}}function sa(){return aa()}function aa(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}class Xe extends Error{}Xe.prototype.name="InvalidTokenError";function la(t){return decodeURIComponent(atob(t).replace(/(.)/g,(e,n)=>{let r=n.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r}))}function ca(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return la(e)}catch{return atob(e)}}function hi(t,e){if(typeof t!="string")throw new Xe("Invalid token specified: must be a string");e||(e={});const n=e.header===!0?0:1,r=t.split(".")[n];if(typeof r!="string")throw new Xe(`Invalid token specified: missing part #${n+1}`);let i;try{i=ca(r)}catch(o){throw new Xe(`Invalid token specified: invalid base64 for part #${n+1} (${o.message})`)}try{return JSON.parse(i)}catch(o){throw new Xe(`Invalid token specified: invalid json for part #${n+1} (${o.message})`)}}var ua=Object.defineProperty,ha=(t,e,n)=>e in t?ua(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,H=(t,e,n)=>ha(t,typeof e!="symbol"?e+"":e,n);const da=480*60*60*1e3,di=2;class fa{constructor(e,n,r){H(this,"authState",{state:"noAuth"}),H(this,"configVersion",0),H(this,"syncState"),H(this,"authenticate"),H(this,"stopSocket"),H(this,"tryRestartSocket"),H(this,"pauseSocket"),H(this,"resumeSocket"),H(this,"clearAuth"),H(this,"logger"),H(this,"refreshTokenLeewaySeconds"),H(this,"tokenConfirmationAttempts",0),this.syncState=e,this.authenticate=n.authenticate,this.stopSocket=n.stopSocket,this.tryRestartSocket=n.tryRestartSocket,this.pauseSocket=n.pauseSocket,this.resumeSocket=n.resumeSocket,this.clearAuth=n.clearAuth,this.logger=r.logger,this.refreshTokenLeewaySeconds=r.refreshTokenLeewaySeconds}async setConfig(e,n){this.resetAuthState(),this._logVerbose("pausing WS for auth token fetch"),this.pauseSocket();const r=await this.fetchTokenAndGuardAgainstRace(e,{forceRefreshToken:!1});r.isFromOutdatedConfig||(r.value?(this.setAuthState({state:"waitingForServerConfirmationOfCachedToken",config:{fetchToken:e,onAuthChange:n},hasRetried:!1}),this.authenticate(r.value)):(this.setAuthState({state:"initialRefetch",config:{fetchToken:e,onAuthChange:n}}),await this.refetchToken()),this._logVerbose("resuming WS after auth token fetch"),this.resumeSocket())}onTransition(e){if(this.syncState.isCurrentOrNewerAuthVersion(e.endVersion.identity)&&!(e.endVersion.identity<=e.startVersion.identity)){if(this._logVerbose(`auth state is ${this.authState.state} when handling transition`),this.syncState.markAuthCompletion(),this.authState.state==="waitingForServerConfirmationOfCachedToken"){this._logVerbose("server confirmed auth token is valid"),this.refetchToken(),this.authState.config.onAuthChange(!0);return}this.authState.state==="waitingForServerConfirmationOfFreshToken"&&(this._logVerbose("server confirmed new auth token is valid"),this.scheduleTokenRefetch(this.authState.token),this.tokenConfirmationAttempts=0,this.authState.hadAuth||this.authState.config.onAuthChange(!0))}}onAuthError(e){if(e.authUpdateAttempted===!1&&(this.authState.state==="waitingForServerConfirmationOfFreshToken"||this.authState.state==="waitingForServerConfirmationOfCachedToken")){this._logVerbose("ignoring non-auth token expired error");return}const{baseVersion:n}=e;if(!this.syncState.isCurrentOrNewerAuthVersion(n+1)){this._logVerbose("ignoring auth error for previous auth attempt");return}this.tryToReauthenticate(e)}async tryToReauthenticate(e){if(this._logVerbose(`attempting to reauthenticate: ${e.error}`),this.authState.state==="noAuth"||this.authState.state==="waitingForServerConfirmationOfFreshToken"&&this.tokenConfirmationAttempts>=di){this.logger.error(`Failed to authenticate: "${e.error}", check your server auth config`),this.syncState.hasAuth()&&this.syncState.clearAuth(),this.authState.state!=="noAuth"&&this.setAndReportAuthFailed(this.authState.config.onAuthChange);return}this.authState.state==="waitingForServerConfirmationOfFreshToken"&&(this.tokenConfirmationAttempts++,this._logVerbose(`retrying reauthentication, ${di-this.tokenConfirmationAttempts} attempts remaining`)),await this.stopSocket();const n=await this.fetchTokenAndGuardAgainstRace(this.authState.config.fetchToken,{forceRefreshToken:!0});n.isFromOutdatedConfig||(n.value&&this.syncState.isNewAuth(n.value)?(this.authenticate(n.value),this.setAuthState({state:"waitingForServerConfirmationOfFreshToken",config:this.authState.config,token:n.value,hadAuth:this.authState.state==="notRefetching"||this.authState.state==="waitingForScheduledRefetch"})):(this._logVerbose("reauthentication failed, could not fetch a new token"),this.syncState.hasAuth()&&this.syncState.clearAuth(),this.setAndReportAuthFailed(this.authState.config.onAuthChange)),this.tryRestartSocket())}async refetchToken(){if(this.authState.state==="noAuth")return;this._logVerbose("refetching auth token");const e=await this.fetchTokenAndGuardAgainstRace(this.authState.config.fetchToken,{forceRefreshToken:!0});e.isFromOutdatedConfig||(e.value?this.syncState.isNewAuth(e.value)?(this.setAuthState({state:"waitingForServerConfirmationOfFreshToken",hadAuth:this.syncState.hasAuth(),token:e.value,config:this.authState.config}),this.authenticate(e.value)):this.setAuthState({state:"notRefetching",config:this.authState.config}):(this._logVerbose("refetching token failed"),this.syncState.hasAuth()&&this.clearAuth(),this.setAndReportAuthFailed(this.authState.config.onAuthChange)),this._logVerbose("restarting WS after auth token fetch (if currently stopped)"),this.tryRestartSocket())}scheduleTokenRefetch(e){if(this.authState.state==="noAuth")return;const n=this.decodeToken(e);if(!n){this.logger.error("Auth token is not a valid JWT, cannot refetch the token");return}const{iat:r,exp:i}=n;if(!r||!i){this.logger.error("Auth token does not have required fields, cannot refetch the token");return}const o=i-r;if(o<=2){this.logger.error("Auth token does not live long enough, cannot refetch the token");return}let s=Math.min(da,(o-this.refreshTokenLeewaySeconds)*1e3);s<=0&&(this.logger.warn(`Refetching auth token immediately, configured leeway ${this.refreshTokenLeewaySeconds}s is larger than the token's lifetime ${o}s`),s=0);const l=setTimeout(()=>{this._logVerbose("running scheduled token refetch"),this.refetchToken()},s);this.setAuthState({state:"waitingForScheduledRefetch",refetchTokenTimeoutId:l,config:this.authState.config}),this._logVerbose(`scheduled preemptive auth token refetching in ${s}ms`)}async fetchTokenAndGuardAgainstRace(e,n){const r=++this.configVersion;this._logVerbose(`fetching token with config version ${r}`);const i=await e(n);return this.configVersion!==r?(this._logVerbose(`stale config version, expected ${r}, got ${this.configVersion}`),{isFromOutdatedConfig:!0}):{isFromOutdatedConfig:!1,value:i}}stop(){this.resetAuthState(),this.configVersion++,this._logVerbose(`config version bumped to ${this.configVersion}`)}setAndReportAuthFailed(e){e(!1),this.resetAuthState()}resetAuthState(){this.setAuthState({state:"noAuth"})}setAuthState(e){const n=e.state==="waitingForServerConfirmationOfFreshToken"?{hadAuth:e.hadAuth,state:e.state,token:`...${e.token.slice(-7)}`}:{state:e.state};switch(this._logVerbose(`setting auth state to ${JSON.stringify(n)}`),e.state){case"waitingForScheduledRefetch":case"notRefetching":case"noAuth":this.tokenConfirmationAttempts=0;break}this.authState.state==="waitingForScheduledRefetch"&&clearTimeout(this.authState.refetchTokenTimeoutId),this.authState=e}decodeToken(e){try{return hi(e)}catch(n){return this._logVerbose(`Error decoding token: ${n instanceof Error?n.message:"Unknown error"}`),null}}_logVerbose(e){this.logger.logVerbose(`${e} [v${this.configVersion}]`)}}const pa=["convexClientConstructed","convexWebSocketOpen","convexFirstMessageReceived"];function ga(t,e){const n={sessionId:e};typeof performance>"u"||!performance.mark||performance.mark(t,{detail:n})}function ma(t){let e=t.name.slice(6);return e=e.charAt(0).toLowerCase()+e.slice(1),{name:e,startTime:t.startTime}}function xa(t){if(typeof performance>"u"||!performance.getEntriesByName)return[];const e=[];for(const n of pa){const r=performance.getEntriesByName(n).filter(i=>i.entryType==="mark").filter(i=>i.detail.sessionId===t);e.push(...r)}return e.map(ma)}var ba=Object.defineProperty,ya=(t,e,n)=>e in t?ba(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,E=(t,e,n)=>ya(t,typeof e!="symbol"?e+"":e,n);class va{constructor(e,n,r){if(E(this,"address"),E(this,"state"),E(this,"requestManager"),E(this,"webSocketManager"),E(this,"authenticationManager"),E(this,"remoteQuerySet"),E(this,"optimisticQueryResults"),E(this,"_transitionHandlerCounter",0),E(this,"_nextRequestId"),E(this,"_onTransitionFns",new Map),E(this,"_sessionId"),E(this,"firstMessageReceived",!1),E(this,"debug"),E(this,"logger"),E(this,"maxObservedTimestamp"),E(this,"connectionStateSubscribers",new Map),E(this,"nextConnectionStateSubscriberId",0),E(this,"_lastPublishedConnectionState"),E(this,"markConnectionStateDirty",()=>{Promise.resolve().then(()=>{const p=this.connectionState();if(JSON.stringify(p)!==JSON.stringify(this._lastPublishedConnectionState)){this._lastPublishedConnectionState=p;for(const g of this.connectionStateSubscribers.values())g(p)}})}),E(this,"mark",p=>{this.debug&&ga(p,this.sessionId)}),typeof e=="object")throw new Error("Passing a ClientConfig object is no longer supported. Pass the URL of the Convex deployment as a string directly.");r?.skipConvexDeploymentUrlCheck!==!0&&gs(e),r={...r};const i=r.authRefreshTokenLeewaySeconds??10;let o=r.webSocketConstructor;if(!o&&typeof WebSocket>"u")throw new Error("No WebSocket global variable defined! To use Convex in an environment without WebSocket try the HTTP client: https://docs.convex.dev/api/classes/browser.ConvexHttpClient");o=o||WebSocket,this.debug=r.reportDebugInfoToConvex??!1,this.address=e,this.logger=r.logger===!1?ti({verbose:r.verbose??!1}):r.logger!==!0&&r.logger?r.logger:ei({verbose:r.verbose??!1});const s=e.search("://");if(s===-1)throw new Error("Provided address was not an absolute URL.");const l=e.substring(s+3),a=e.substring(0,s);let u;if(a==="http")u="ws";else if(a==="https")u="wss";else throw new Error(`Unknown parent protocol ${a}`);const d=`${u}://${l}/api/${Kr}/sync`;this.state=new Is,this.remoteQuerySet=new ai(p=>this.state.queryPath(p),this.logger),this.requestManager=new qs(this.logger,this.markConnectionStateDirty);const h=()=>{this.webSocketManager.pause(),this.state.pause()};this.authenticationManager=new fa(this.state,{authenticate:p=>{const g=this.state.setAuth(p);return this.webSocketManager.sendMessage(g),g.baseVersion},stopSocket:()=>this.webSocketManager.stop(),tryRestartSocket:()=>this.webSocketManager.tryRestart(),pauseSocket:h,resumeSocket:()=>this.webSocketManager.resume(),clearAuth:()=>{this.clearAuth()}},{logger:this.logger,refreshTokenLeewaySeconds:i}),this.optimisticQueryResults=new Qs,this.addOnTransitionHandler(p=>{n(p.queries.map(g=>g.token))}),this._nextRequestId=0,this._sessionId=sa();const{unsavedChangesWarning:f}=r;if(typeof window>"u"||typeof window.addEventListener>"u"){if(f===!0)throw new Error("unsavedChangesWarning requested, but window.addEventListener not found! Remove {unsavedChangesWarning: true} from Convex client options.")}else f!==!1&&window.addEventListener("beforeunload",p=>{if(this.requestManager.hasIncompleteRequests()){p.preventDefault();const g="Are you sure you want to leave? Your changes may not be saved.";return(p||window.event).returnValue=g,g}});this.webSocketManager=new oa(d,{onOpen:p=>{this.mark("convexWebSocketOpen"),this.webSocketManager.sendMessage({...p,type:"Connect",sessionId:this._sessionId,maxObservedTimestamp:this.maxObservedTimestamp}),this.remoteQuerySet=new ai(x=>this.state.queryPath(x),this.logger);const[g,m]=this.state.restart();m&&this.webSocketManager.sendMessage(m),this.webSocketManager.sendMessage(g);for(const x of this.requestManager.restart())this.webSocketManager.sendMessage(x)},onResume:()=>{const[p,g]=this.state.resume();g&&this.webSocketManager.sendMessage(g),p&&this.webSocketManager.sendMessage(p);for(const m of this.requestManager.resume())this.webSocketManager.sendMessage(m)},onMessage:p=>{switch(this.firstMessageReceived||(this.firstMessageReceived=!0,this.mark("convexFirstMessageReceived"),this.reportMarks()),p.type){case"Transition":{this.observedTimestamp(p.endVersion.ts),this.authenticationManager.onTransition(p),this.remoteQuerySet.transition(p),this.state.transition(p);const g=this.requestManager.removeCompleted(this.remoteQuerySet.timestamp());this.notifyOnQueryResultChanges(g);break}case"MutationResponse":{p.success&&this.observedTimestamp(p.ts);const g=this.requestManager.onResponse(p);g!==null&&this.notifyOnQueryResultChanges(new Map([[g.requestId,g.result]]));break}case"ActionResponse":{this.requestManager.onResponse(p);break}case"AuthError":{this.authenticationManager.onAuthError(p);break}case"FatalError":{const g=As(this.logger,p.error);throw this.webSocketManager.terminate(),g}}return{hasSyncedPastLastReconnect:this.hasSyncedPastLastReconnect()}},onServerDisconnectError:r.onServerDisconnectError},o,this.logger,this.markConnectionStateDirty,this.debug),this.mark("convexClientConstructed"),r.expectAuth&&h()}hasSyncedPastLastReconnect(){return this.requestManager.hasSyncedPastLastReconnect()&&this.state.hasSyncedPastLastReconnect()}observedTimestamp(e){(this.maxObservedTimestamp===void 0||this.maxObservedTimestamp.lessThanOrEqual(e))&&(this.maxObservedTimestamp=e)}getMaxObservedTimestamp(){return this.maxObservedTimestamp}notifyOnQueryResultChanges(e){const n=this.remoteQuerySet.remoteQueryResults(),r=new Map;for(const[o,s]of n){const l=this.state.queryToken(o);if(l!==null){const a={result:s,udfPath:this.state.queryPath(o),args:this.state.queryArgs(o)};r.set(l,a)}}const i=this.optimisticQueryResults.ingestQueryResultsFromServer(r,new Set(e.keys()));this.handleTransition({queries:i.map(o=>{const s=this.optimisticQueryResults.rawQueryResult(o);return{token:o,modification:{kind:"Updated",result:s}}}),reflectedMutations:Array.from(e).map(([o,s])=>({requestId:o,result:s})),timestamp:this.remoteQuerySet.timestamp()})}handleTransition(e){for(const n of this._onTransitionFns.values())n(e)}addOnTransitionHandler(e){const n=this._transitionHandlerCounter++;return this._onTransitionFns.set(n,e),()=>this._onTransitionFns.delete(n)}getCurrentAuthClaims(){const e=this.state.getAuth();let n={};if(e&&e.tokenType==="User")try{n=e?hi(e.value):{}}catch{n={}}else return;return{token:e.value,decoded:n}}setAuth(e,n){this.authenticationManager.setConfig(e,n)}hasAuth(){return this.state.hasAuth()}setAdminAuth(e,n){const r=this.state.setAdminAuth(e,n);this.webSocketManager.sendMessage(r)}clearAuth(){const e=this.state.clearAuth();this.webSocketManager.sendMessage(e)}subscribe(e,n,r){const i=ie(n),{modification:o,queryToken:s,unsubscribe:l}=this.state.subscribe(e,i,r?.journal,r?.componentPath);return o!==null&&this.webSocketManager.sendMessage(o),{queryToken:s,unsubscribe:()=>{const a=l();a&&this.webSocketManager.sendMessage(a)}}}localQueryResult(e,n){const r=ie(n),i=ge(e,r);return this.optimisticQueryResults.queryResult(i)}localQueryResultByToken(e){return this.optimisticQueryResults.queryResult(e)}hasLocalQueryResultByToken(e){return this.optimisticQueryResults.hasQueryResult(e)}localQueryLogs(e,n){const r=ie(n),i=ge(e,r);return this.optimisticQueryResults.queryLogs(i)}queryJournal(e,n){const r=ie(n),i=ge(e,r);return this.state.queryJournal(i)}connectionState(){const e=this.webSocketManager.connectionState();return{hasInflightRequests:this.requestManager.hasInflightRequests(),isWebSocketConnected:e.isConnected,hasEverConnected:e.hasEverConnected,connectionCount:e.connectionCount,connectionRetries:e.connectionRetries,timeOfOldestInflightRequest:this.requestManager.timeOfOldestInflightRequest(),inflightMutations:this.requestManager.inflightMutations(),inflightActions:this.requestManager.inflightActions()}}subscribeToConnectionState(e){const n=this.nextConnectionStateSubscriberId++;return this.connectionStateSubscribers.set(n,e),()=>{this.connectionStateSubscribers.delete(n)}}async mutation(e,n,r){const i=await this.mutationInternal(e,n,r);if(!i.success)throw i.errorData!==void 0?hn(i,new xt(Ae("mutation",e,i))):new Error(Ae("mutation",e,i));return i.value}async mutationInternal(e,n,r,i){const{mutationPromise:o}=this.enqueueMutation(e,n,r,i);return o}enqueueMutation(e,n,r,i){const o=ie(n);this.tryReportLongDisconnect();const s=this.nextRequestId;if(this._nextRequestId++,r!==void 0){const d=r.optimisticUpdate;if(d!==void 0){const h=g=>{d(g,o)instanceof Promise&&this.logger.warn("Optimistic update handler returned a Promise. Optimistic updates should be synchronous.")},p=this.optimisticQueryResults.applyOptimisticUpdate(h,s).map(g=>{const m=this.localQueryResultByToken(g);return{token:g,modification:{kind:"Updated",result:m===void 0?void 0:{success:!0,value:m,logLines:[]}}}});this.handleTransition({queries:p,reflectedMutations:[],timestamp:this.remoteQuerySet.timestamp()})}}const l={type:"Mutation",requestId:s,udfPath:e,componentPath:i,args:[ee(o)]},a=this.webSocketManager.sendMessage(l),u=this.requestManager.request(l,a);return{requestId:s,mutationPromise:u}}async action(e,n){const r=await this.actionInternal(e,n);if(!r.success)throw r.errorData!==void 0?hn(r,new xt(Ae("action",e,r))):new Error(Ae("action",e,r));return r.value}async actionInternal(e,n,r){const i=ie(n),o=this.nextRequestId;this._nextRequestId++,this.tryReportLongDisconnect();const s={type:"Action",requestId:o,udfPath:e,componentPath:r,args:[ee(i)]},l=this.webSocketManager.sendMessage(s);return this.requestManager.request(s,l)}async close(){return this.authenticationManager.stop(),this.webSocketManager.terminate()}get url(){return this.address}get nextRequestId(){return this._nextRequestId}get sessionId(){return this._sessionId}reportMarks(){if(this.debug){const e=xa(this.sessionId);this.webSocketManager.sendMessage({type:"Event",eventType:"ClientConnect",event:e})}}tryReportLongDisconnect(){if(!this.debug)return;const e=this.connectionState().timeOfOldestInflightRequest;if(e===null||Date.now()-e.getTime()<=60*1e3)return;const n=`${this.address}/api/debug_event`;fetch(n,{method:"POST",headers:{"Content-Type":"application/json","Convex-Client":`npm-${Kr}`},body:JSON.stringify({event:"LongWebsocketDisconnect"})}).then(r=>{r.ok||this.logger.warn("Analytics request failed with response:",r.body)}).catch(r=>{this.logger.warn("Analytics response failed with error:",r)})}}function pn(t){if(typeof t!="object"||t===null||!Array.isArray(t.page)||typeof t.isDone!="boolean"||typeof t.continueCursor!="string")throw new Error(`Not a valid paginated query result: ${t?.toString()}`);return t}var wa=Object.defineProperty,_a=(t,e,n)=>e in t?wa(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,fi=(t,e,n)=>_a(t,typeof e!="symbol"?e+"":e,n);class ka{constructor(e,n){this.client=e,this.onTransition=n,fi(this,"paginatedQuerySet",new Map),fi(this,"lastTransitionTs"),this.lastTransitionTs=N.fromNumber(0),this.client.addOnTransitionHandler(r=>this.onBaseTransition(r))}subscribe(e,n,r){const i=pe(e),o=ni(i,n,r),s=()=>this.removePaginatedQuerySubscriber(o),l=this.paginatedQuerySet.get(o);return l?(l.numSubscribers+=1,{paginatedQueryToken:o,unsubscribe:s}):(this.paginatedQuerySet.set(o,{token:o,canonicalizedUdfPath:i,args:n,numSubscribers:1,options:{initialNumItems:r.initialNumItems},nextPageKey:0,pageKeys:[],pageKeyToQuery:new Map,ongoingSplits:new Map,skip:!1,id:r.id}),this.addPageToPaginatedQuery(o,null,r.initialNumItems),{paginatedQueryToken:o,unsubscribe:s})}localQueryResult(e,n,r){const i=pe(e),o=ni(i,n,r);return this.localQueryResultByToken(o)}localQueryResultByToken(e){const n=this.paginatedQuerySet.get(e);if(!n)return;const r=this.activePageQueryTokens(n);if(r.length===0)return{results:[],status:"LoadingFirstPage",loadMore:a=>this.loadMoreOfPaginatedQuery(e,a)};let i=[],o=!1,s=!1;for(const a of r){const u=this.client.localQueryResultByToken(a);if(u===void 0){o=!0,s=!1;continue}const d=pn(u);i=i.concat(d.page),s=!!d.isDone}let l;return o?l=i.length===0?"LoadingFirstPage":"LoadingMore":s?l="Exhausted":l="CanLoadMore",{results:i,status:l,loadMore:a=>this.loadMoreOfPaginatedQuery(e,a)}}onBaseTransition(e){const n=e.queries.map(s=>s.token),r=this.queriesContainingTokens(n);let i=[];r.length>0&&(this.processPaginatedQuerySplits(r,s=>this.client.localQueryResultByToken(s)),i=r.map(s=>({token:s,modification:{kind:"Updated",result:this.localQueryResultByToken(s)}})));const o={...e,paginatedQueries:i};this.onTransition(o)}loadMoreOfPaginatedQuery(e,n){this.mustGetPaginatedQuery(e);const r=this.queryTokenForLastPageOfPaginatedQuery(e),i=this.client.localQueryResultByToken(r);if(!i)return!1;const o=pn(i);if(o.isDone)return!1;this.addPageToPaginatedQuery(e,o.continueCursor,n);const s={timestamp:this.lastTransitionTs,reflectedMutations:[],queries:[],paginatedQueries:[{token:e,modification:{kind:"Updated",result:this.localQueryResultByToken(e)}}]};return this.onTransition(s),!0}queriesContainingTokens(e){if(e.length===0)return[];const n=[],r=new Set(e);for(const[i,o]of this.paginatedQuerySet)for(const s of this.allQueryTokens(o))if(r.has(s)){n.push(i);break}return n}processPaginatedQuerySplits(e,n){for(const r of e){const i=this.mustGetPaginatedQuery(r),{ongoingSplits:o,pageKeyToQuery:s,pageKeys:l}=i;for(const[a,[u,d]]of o)n(s.get(u).queryToken)!==void 0&&n(s.get(d).queryToken)!==void 0&&this.completePaginatedQuerySplit(i,a,u,d);for(const a of l){if(o.has(a))continue;const u=s.get(a).queryToken,d=n(u);if(!d)continue;const h=pn(d);h.splitCursor&&(h.pageStatus==="SplitRecommended"||h.pageStatus==="SplitRequired"||h.page.length>i.options.initialNumItems*2)&&this.splitPaginatedQueryPage(i,a,h.splitCursor,h.continueCursor)}}}splitPaginatedQueryPage(e,n,r,i){const o=e.nextPageKey++,s=e.nextPageKey++,l={cursor:i,numItems:e.options.initialNumItems,id:e.id},a=this.client.subscribe(e.canonicalizedUdfPath,{...e.args,paginationOpts:{...l,cursor:null,endCursor:r}});e.pageKeyToQuery.set(o,a);const u=this.client.subscribe(e.canonicalizedUdfPath,{...e.args,paginationOpts:{...l,cursor:r,endCursor:i}});e.pageKeyToQuery.set(s,u),e.ongoingSplits.set(n,[o,s])}addPageToPaginatedQuery(e,n,r){const i=this.mustGetPaginatedQuery(e),o=i.nextPageKey++,s={cursor:n,numItems:r,id:i.id},l={...i.args,paginationOpts:s},a=this.client.subscribe(i.canonicalizedUdfPath,l);return i.pageKeys.push(o),i.pageKeyToQuery.set(o,a),a}removePaginatedQuerySubscriber(e){const n=this.paginatedQuerySet.get(e);if(n&&(n.numSubscribers-=1,!(n.numSubscribers>0))){for(const r of n.pageKeyToQuery.values())r.unsubscribe();this.paginatedQuerySet.delete(e)}}completePaginatedQuerySplit(e,n,r,i){const o=e.pageKeyToQuery.get(n);e.pageKeyToQuery.delete(n);const s=e.pageKeys.indexOf(n);e.pageKeys.splice(s,1,r,i),e.ongoingSplits.delete(n),o.unsubscribe()}activePageQueryTokens(e){return e.pageKeys.map(n=>e.pageKeyToQuery.get(n).queryToken)}allQueryTokens(e){return Array.from(e.pageKeyToQuery.values()).map(n=>n.queryToken)}queryTokenForLastPageOfPaginatedQuery(e){const n=this.mustGetPaginatedQuery(e),r=n.pageKeys[n.pageKeys.length-1];if(r===void 0)throw new Error(`No pages for paginated query ${e}`);return n.pageKeyToQuery.get(r).queryToken}mustGetPaginatedQuery(e){const n=this.paginatedQuerySet.get(e);if(!n)throw new Error("paginated query no longer exists for token "+e);return n}}function ja({getCurrentValue:t,subscribe:e}){const[n,r]=C(()=>({getCurrentValue:t,subscribe:e,value:t()}));let i=n.value;return(n.getCurrentValue!==t||n.subscribe!==e)&&(i=t(),r({getCurrentValue:t,subscribe:e,value:i})),S(()=>{let o=!1;const s=()=>{o||r(a=>{if(a.getCurrentValue!==t||a.subscribe!==e)return a;const u=t();return a.value===u?a:{...a,value:u}})},l=e(s);return s(),()=>{o=!0,l()}},[t,e]),i}var Sa=Object.defineProperty,Ca=(t,e,n)=>e in t?Sa(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,oe=(t,e,n)=>Ca(t,typeof e!="symbol"?e+"":e,n);const Ta=5e3;if(typeof rn>"u")throw new Error("Required dependency 'react' not found");function pi(t,e,n){function r(i){return Ea(i),e.mutation(t,i,{optimisticUpdate:n})}return r.withOptimisticUpdate=function(o){if(n!==void 0)throw new Error(`Already specified optimistic update for mutation ${O(t)}`);return pi(t,e,o)},r}class Ra{constructor(e,n){if(oe(this,"address"),oe(this,"cachedSync"),oe(this,"cachedPaginatedQueryClient"),oe(this,"listeners"),oe(this,"options"),oe(this,"closed",!1),oe(this,"_logger"),oe(this,"adminAuth"),oe(this,"fakeUserIdentity"),e===void 0)throw new Error("No address provided to ConvexReactClient.\nIf trying to deploy to production, make sure to follow all the instructions found at https://docs.convex.dev/production/hosting/\nIf running locally, make sure to run `convex dev` and ensure the .env.local file is populated.");if(typeof e!="string")throw new Error(`ConvexReactClient requires a URL like 'https://happy-otter-123.convex.cloud', received something of type ${typeof e} instead.`);if(!e.includes("://"))throw new Error("Provided address was not an absolute URL.");this.address=e,this.listeners=new Map,this._logger=n?.logger===!1?ti({verbose:n?.verbose??!1}):n?.logger!==!0&&n?.logger?n.logger:ei({verbose:n?.verbose??!1}),this.options={...n,logger:this._logger}}get url(){return this.address}get sync(){if(this.closed)throw new Error("ConvexReactClient has already been closed.");return this.cachedSync?this.cachedSync:(this.cachedSync=new va(this.address,()=>{},this.options),this.adminAuth&&this.cachedSync.setAdminAuth(this.adminAuth,this.fakeUserIdentity),this.cachedPaginatedQueryClient=new ka(this.cachedSync,e=>this.handleTransition(e)),this.cachedSync)}get paginatedQueryClient(){if(this.sync,this.cachedPaginatedQueryClient)return this.cachedPaginatedQueryClient;throw new Error("Should already be instantiated")}setAuth(e,n){if(typeof e=="string")throw new Error("Passing a string to ConvexReactClient.setAuth is no longer supported, please upgrade to passing in an async function to handle reauthentication.");this.sync.setAuth(e,n??(()=>{}))}clearAuth(){this.sync.clearAuth()}setAdminAuth(e,n){if(this.adminAuth=e,this.fakeUserIdentity=n,this.closed)throw new Error("ConvexReactClient has already been closed.");this.cachedSync&&this.sync.setAdminAuth(e,n)}watchQuery(e,...n){const[r,i]=n,o=O(e);return{onUpdate:s=>{const{queryToken:l,unsubscribe:a}=this.sync.subscribe(o,r,i),u=this.listeners.get(l);return u!==void 0?u.add(s):this.listeners.set(l,new Set([s])),()=>{if(this.closed)return;const d=this.listeners.get(l);d.delete(s),d.size===0&&this.listeners.delete(l),a()}},localQueryResult:()=>{if(this.cachedSync)return this.cachedSync.localQueryResult(o,r)},localQueryLogs:()=>{if(this.cachedSync)return this.cachedSync.localQueryLogs(o,r)},journal:()=>{if(this.cachedSync)return this.cachedSync.queryJournal(o,r)}}}prewarmQuery(e){const n=e.extendSubscriptionFor??Ta,i=this.watchQuery(e.query,e.args||{}).onUpdate(()=>{});setTimeout(i,n)}watchPaginatedQuery(e,n,r){const i=O(e);return{onUpdate:o=>{const{paginatedQueryToken:s,unsubscribe:l}=this.paginatedQueryClient.subscribe(i,n||{},r),a=this.listeners.get(s);return a!==void 0?a.add(o):this.listeners.set(s,new Set([o])),()=>{if(this.closed)return;const u=this.listeners.get(s);u.delete(o),u.size===0&&this.listeners.delete(s),l()}},localQueryResult:()=>this.paginatedQueryClient.localQueryResult(i,n,r)}}mutation(e,...n){const[r,i]=n,o=O(e);return this.sync.mutation(o,r,i)}action(e,...n){const r=O(e);return this.sync.action(r,...n)}query(e,...n){const r=this.watchQuery(e,...n),i=r.localQueryResult();return i!==void 0?Promise.resolve(i):new Promise((o,s)=>{const l=r.onUpdate(()=>{l();try{o(r.localQueryResult())}catch(a){s(a)}})})}connectionState(){return this.sync.connectionState()}subscribeToConnectionState(e){return this.sync.subscribeToConnectionState(e)}get logger(){return this._logger}async close(){if(this.closed=!0,this.listeners=new Map,this.cachedPaginatedQueryClient&&(this.cachedPaginatedQueryClient=void 0),this.cachedSync){const e=this.cachedSync;this.cachedSync=void 0,await e.close()}}handleTransition(e){const n=e.queries.map(i=>i.token),r=e.paginatedQueries.map(i=>i.token);this.transition([...n,...r])}transition(e){for(const n of e){const r=this.listeners.get(n);if(r)for(const i of r)i()}}}const gn=rn.createContext(void 0);function $a(){return ft(gn)}const Aa=({client:t,children:e})=>rn.createElement(gn.Provider,{value:t},e);function gi(t,...e){const n=e[0]==="skip",r=e[0]==="skip"?{}:ie(e[0]),i=typeof t=="string"?ri(t):t,o=O(i),s=J(()=>n?{}:{query:{query:i,args:r}},[JSON.stringify(ee(r)),o,n]),a=Ma(s).query;if(a instanceof Error)throw a;return a}function kt(t){const e=typeof t=="string"?ri(t):t,n=ft(gn);if(n===void 0)throw new Error("Could not find Convex client! `useMutation` must be used in the React component tree under `ConvexProvider`. Did you forget it? See https://docs.convex.dev/quick-start#set-up-convex-in-your-react-app");return J(()=>pi(e,n),[n,O(e)])}function Ea(t){if(typeof t=="object"&&t!==null&&"bubbles"in t&&"persist"in t&&"isDefaultPrevented"in t)throw new Error("Convex function called with SyntheticEvent object. Did you use a Convex function as an event handler directly? Event handlers like onClick receive an event object as their first argument. These SyntheticEvent objects are not valid Convex values. Try wrapping the function like `const handler = () => myMutation();` and using `handler` in the event handler.")}var Pa=Object.defineProperty,Ia=(t,e,n)=>e in t?Pa(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,mn=(t,e,n)=>Ia(t,typeof e!="symbol"?e+"":e,n);class La{constructor(e){mn(this,"createWatch"),mn(this,"queries"),mn(this,"listeners"),this.createWatch=e,this.queries={},this.listeners=new Set}setQueries(e){for(const n of Object.keys(e)){const{query:r,args:i,paginationOptions:o}=e[n];if(O(r),this.queries[n]===void 0)this.addQuery(n,r,i,o?{paginationOptions:o}:{});else{const s=this.queries[n];(O(r)!==O(s.query)||JSON.stringify(ee(i))!==JSON.stringify(ee(s.args))||JSON.stringify(o)!==JSON.stringify(s.paginationOptions))&&(this.removeQuery(n),this.addQuery(n,r,i,o?{paginationOptions:o}:{}))}}for(const n of Object.keys(this.queries))e[n]===void 0&&this.removeQuery(n)}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}getLocalResults(e){const n={};for(const r of Object.keys(e)){const{query:i,args:o}=e[r],s=e[r].paginationOptions;O(i);const l=this.createWatch(i,o,s?{paginationOptions:s}:{});let a;try{a=l.localQueryResult()}catch(u){if(u instanceof Error)a=u;else throw u}n[r]=a}return n}setCreateWatch(e){this.createWatch=e;for(const n of Object.keys(this.queries)){const{query:r,args:i,watch:o,paginationOptions:s}=this.queries[n],l="journal"in o?o.journal():void 0;this.removeQuery(n),this.addQuery(n,r,i,{...l?{journal:l}:[],...s?{paginationOptions:s}:{}})}}destroy(){for(const e of Object.keys(this.queries))this.removeQuery(e);this.listeners=new Set}addQuery(e,n,r,{paginationOptions:i,journal:o}){if(this.queries[e]!==void 0)throw new Error(`Tried to add a new query with identifier ${e} when it already exists.`);const s=this.createWatch(n,r,{...o?{journal:o}:[],...i?{paginationOptions:i}:{}}),l=s.onUpdate(()=>this.notifyListeners());this.queries[e]={query:n,args:r,watch:s,unsubscribe:l,...i?{paginationOptions:i}:{}}}removeQuery(e){const n=this.queries[e];if(n===void 0)throw new Error(`No query found with identifier ${e}.`);n.unsubscribe(),delete this.queries[e]}notifyListeners(){for(const e of this.listeners)e()}}function Ma(t){const e=$a();if(e===void 0)throw new Error("Could not find Convex client! `useQuery` must be used in the React component tree under `ConvexProvider`. Did you forget it? See https://docs.convex.dev/quick-start#set-up-convex-in-your-react-app");const n=J(()=>(r,i,{journal:o,paginationOptions:s})=>s?e.watchPaginatedQuery(r,i,s):e.watchQuery(r,i,o?{journal:o}:{}),[e]);return qa(t,n)}function qa(t,e){const[n]=C(()=>new La(e));n.createWatch!==e&&n.setCreateWatch(e),S(()=>()=>n.destroy(),[n]);const r=J(()=>({getCurrentValue:()=>n.getLocalResults(t),subscribe:i=>(n.setQueries(t),n.subscribe(i))}),[n,t]);return ja(r)}var Oa=Symbol.for("preact-signals");function jt(){if(ce>1)ce--;else{for(var t,e=!1;et!==void 0;){var n=et;for(et=void 0,xn++;n!==void 0;){var r=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&bi(n))try{n.c()}catch(i){e||(t=i,e=!0)}n=r}}if(xn=0,ce--,e)throw t}}function Na(t){if(ce>0)return t();ce++;try{return t()}finally{jt()}}var _=void 0;function mi(t){var e=_;_=void 0;try{return t()}finally{_=e}}var et=void 0,ce=0,xn=0,St=0;function xi(t){if(_!==void 0){var e=t.n;if(e===void 0||e.t!==_)return e={i:0,S:t,p:_.s,n:void 0,t:_,e:void 0,x:void 0,r:e},_.s!==void 0&&(_.s.n=e),_.s=e,t.n=e,32&_.f&&t.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=_.s,e.n=void 0,_.s.n=e,_.s=e),e}}function I(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}I.prototype.brand=Oa,I.prototype.h=function(){return!0},I.prototype.S=function(t){var e=this,n=this.t;n!==t&&t.e===void 0&&(t.x=n,this.t=t,n!==void 0?n.e=t:mi(function(){var r;(r=e.W)==null||r.call(e)}))},I.prototype.U=function(t){var e=this;if(this.t!==void 0){var n=t.e,r=t.x;n!==void 0&&(n.x=r,t.e=void 0),r!==void 0&&(r.e=n,t.x=void 0),t===this.t&&(this.t=r,r===void 0&&mi(function(){var i;(i=e.Z)==null||i.call(e)}))}},I.prototype.subscribe=function(t){var e=this;return tt(function(){var n=e.value,r=_;_=void 0;try{t(n)}finally{_=r}},{name:"sub"})},I.prototype.valueOf=function(){return this.value},I.prototype.toString=function(){return this.value+""},I.prototype.toJSON=function(){return this.value},I.prototype.peek=function(){var t=_;_=void 0;try{return this.value}finally{_=t}},Object.defineProperty(I.prototype,"value",{get:function(){var t=xi(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(xn>100)throw new Error("Cycle detected");this.v=t,this.i++,St++,ce++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{jt()}}}});function R(t,e){return new I(t,e)}function bi(t){for(var e=t.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function yi(t){for(var e=t.s;e!==void 0;e=e.n){var n=e.S.n;if(n!==void 0&&(e.r=n),e.S.n=e,e.i=-1,e.n===void 0){t.s=e;break}}}function vi(t){for(var e=t.s,n=void 0;e!==void 0;){var r=e.p;e.i===-1?(e.S.U(e),r!==void 0&&(r.n=e.n),e.n!==void 0&&(e.n.p=r)):n=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=r}t.s=n}function me(t,e){I.call(this,void 0),this.x=t,this.s=void 0,this.g=St-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}me.prototype=new I,me.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===St))return!0;if(this.g=St,this.f|=1,this.i>0&&!bi(this))return this.f&=-2,!0;var t=_;try{yi(this),_=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return _=t,vi(this),this.f&=-2,!0},me.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}I.prototype.S.call(this,t)},me.prototype.U=function(t){if(this.t!==void 0&&(I.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}},me.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;t!==void 0;t=t.x)t.t.N()}},Object.defineProperty(me.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=xi(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});function bn(t,e){return new me(t,e)}function wi(t){var e=t.u;if(t.u=void 0,typeof e=="function"){ce++;var n=_;_=void 0;try{e()}catch(r){throw t.f&=-2,t.f|=8,yn(t),r}finally{_=n,jt()}}}function yn(t){for(var e=t.s;e!==void 0;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,wi(t)}function za(t){if(_!==this)throw new Error("Out-of-order effect");vi(this),_=t,this.f&=-2,8&this.f&&yn(this),jt()}function Pe(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=e?.name}Pe.prototype.c=function(){var t=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.u=e)}finally{t()}},Pe.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,wi(this),yi(this),ce++;var t=_;return _=this,za.bind(this,t)},Pe.prototype.N=function(){2&this.f||(this.f|=2,this.o=et,et=this)},Pe.prototype.d=function(){this.f|=8,1&this.f||yn(this)},Pe.prototype.dispose=function(){this.d()};function tt(t,e){var n=new Pe(t,e);try{n.c()}catch(i){throw n.d(),i}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var _i,Ct,Ba=typeof window<"u"&&!!window.__PREACT_SIGNALS_DEVTOOLS__,ki=[];tt(function(){_i=this.N})();function Ie(t,e){y[t]=e.bind(null,y[t]||function(){})}function Tt(t){if(Ct){var e=Ct;Ct=void 0,e()}Ct=t&&t.S()}function ji(t){var e=this,n=t.data,r=Le(n);r.value=n;var i=J(function(){for(var l=e,a=e.__v;a=a.__;)if(a.__c){a.__c.__$f|=4;break}var u=bn(function(){var p=r.value.value;return p===0?0:p===!0?"":p||""}),d=bn(function(){return!Array.isArray(u.value)&&!Jn(u.value)}),h=tt(function(){if(this.N=Si,d.value){var p=u.value;l.__v&&l.__v.__e&&l.__v.__e.nodeType===3&&(l.__v.__e.data=p)}}),f=e.__$u.d;return e.__$u.d=function(){h(),f.call(this)},[d,u]},[]),o=i[0],s=i[1];return o.value?s.peek():s.value}ji.displayName="ReactiveTextNode",Object.defineProperties(I.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:ji},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}}),Ie("__b",function(t,e){if(typeof e.type=="string"){var n,r=e.props;for(var i in r)if(i!=="children"){var o=r[i];o instanceof I&&(n||(e.__np=n={}),n[i]=o,r[i]=o.peek())}}t(e)}),Ie("__r",function(t,e){if(t(e),e.type!==U){Tt();var n,r=e.__c;r&&(r.__$f&=-2,(n=r.__$u)===void 0&&(r.__$u=n=(function(i,o){var s;return tt(function(){s=this},{name:o}),s.c=i,s})(function(){var i;Ba&&((i=n.y)==null||i.call(n)),r.__$f|=1,r.setState({})},typeof e.type=="function"?e.type.displayName||e.type.name:""))),Tt(n)}}),Ie("__e",function(t,e,n,r){Tt(),t(e,n,r)}),Ie("diffed",function(t,e){Tt();var n;if(typeof e.type=="string"&&(n=e.__e)){var r=e.__np,i=e.props;if(r){var o=n.U;if(o)for(var s in o){var l=o[s];l!==void 0&&!(s in r)&&(l.d(),o[s]=void 0)}else o={},n.U=o;for(var a in r){var u=o[a],d=r[a];u===void 0?(u=Ua(n,a,d,i),o[a]=u):u.o(d,i)}}}t(e)});function Ua(t,e,n,r){var i=e in t&&t.ownerSVGElement===void 0,o=R(n);return{o:function(s,l){o.value=s,r=l},d:tt(function(){this.N=Si;var s=o.value.value;r[e]!==s&&(r[e]=s,i?t[e]=s:s!=null&&(s!==!1||e[4]==="-")?t.setAttribute(e,s):t.removeAttribute(e))})}}Ie("unmount",function(t,e){if(typeof e.type=="string"){var n=e.__e;if(n){var r=n.U;if(r){n.U=void 0;for(var i in r){var o=r[i];o&&o.d()}}}}else{var s=e.__c;if(s){var l=s.__$u;l&&(s.__$u=void 0,l.d())}}t(e)}),Ie("__h",function(t,e,n,r){(r<3||r===9)&&(e.__$f|=2),t(e,n,r)}),W.prototype.shouldComponentUpdate=function(t,e){if(this.__R)return!0;var n=this.__$u,r=n&&n.s!==void 0;for(var i in e)return!0;if(this.__f||typeof this.u=="boolean"&&this.u===!0){var o=2&this.__$f;if(!(r||o||4&this.__$f)||1&this.__$f)return!0}else if(!(r||4&this.__$f)||3&this.__$f)return!0;for(var s in t)if(s!=="__source"&&t[s]!==this.props[s])return!0;for(var l in this.props)if(!(l in t))return!0;return!1};function Le(t,e){return J(function(){return R(t,e)},[])}var Fa=function(t){queueMicrotask(function(){queueMicrotask(t)})};function Qa(){Na(function(){for(var t;t=ki.shift();)_i.call(t)})}function Si(){ki.push(this)===1&&(y.requestAnimationFrame||Fa)(Qa)}const P=R(!1),Rt=R(void 0),$t="https://jexitychat.de/privacy",At=R($t),Ci=R("chip"),ue=R(void 0),vn=R([]),wn=R([]),Ti=R(null);function Da(t){return t.replace(/\.convex\.site\b/,".convex.cloud")}function _n(t){return t.replace(/\.convex\.cloud\b/,".convex.site")}function Va(t){const e=t?.trim();if(e)try{const n=new URL(e);if(n.protocol==="http:"||n.protocol==="https:")return e}catch{return}}function Ha(t,e){const n=t.title??e?.title??"Assistant",r=t.privacyPolicyMode??e?.privacyPolicyMode??"platform",i=Wa(t.privacyNoticeStyle??e?.privacyNoticeStyle);return{title:n,greeting:t.greeting??e?.welcomeMessage??`Hi! I'm ${n}. How can I help?`,locale:t.locale??e?.locale,position:t.position??e?.position,colorScheme:t.colorScheme??e?.colorScheme,hideBranding:t.hideBranding??e?.hideBranding??!1,privacyPolicyMode:r,privacyPolicyUrl:r==="custom"?Va(t.privacyPolicyUrl??e?.privacyPolicyUrl):void 0,privacyNoticeStyle:i,triggerIcon:t.triggerIcon??e?.triggerIcon??"chat",triggerRadius:t.triggerRadius??e?.triggerRadius??"full",triggerLabel:t.triggerLabel??e?.triggerLabel??"Chatte mit uns",mode:t.mode??"floating",primaryColor:t.primaryColor??e?.primaryColor,accentColor:t.accentColor??e?.accentColor,fontFamily:t.fontFamily??e?.fontFamily,fontSize:t.fontSize??e?.fontSize,borderRadius:t.borderRadius??e?.borderRadius,windowWidth:t.windowWidth??e?.windowWidth,windowHeight:t.windowHeight??e?.windowHeight}}function Wa(t){return t==="explicit"||t==="sheet"?"explicit":"chip"}async function Ja(t,e,n,r){const i=new URL(`${t}/widget/config`);i.searchParams.set("orgSlug",e),r&&i.searchParams.set("projSlug",r);const o=await fetch(i.toString(),{signal:n});return o.ok?o.json():null}function Ga(t,e,n){const[r,i]=C(null);return S(()=>{i(null);const o=n??"https://festive-mouse-978.eu-west-1.convex.cloud",s=o?_n(o):void 0;if(!s||!t)return;const l=new AbortController;async function a(u){try{const d=await Ja(u,t,l.signal,e);d&&i(d)}catch(d){if(d instanceof Error&&d.name==="AbortError")return}}return a(s),()=>{l.abort()}},[t,e,n]),r}async function kn(t,e,n){try{const r=await fetch(`${e}/widget/bootstrap`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n?{orgSlug:t,projSlug:n}:{orgSlug:t}),credentials:"omit"});if(r.ok){const i=await r.json(),o=i.allowedUrls??(i.allowedUrl?[i.allowedUrl]:[]);return{ok:!0,token:i.token,excludePaths:i.excludePaths,allowedUrls:o}}return r.status===403?{ok:!1,error:"unauthorized"}:r.status===404?{ok:!1,error:"not_found"}:r.status===429?{ok:!1,error:"rate_limited",retryAfterSec:Number(r.headers.get("Retry-After"))||60}:{ok:!1,error:"network"}}catch{return{ok:!1,error:"network"}}}function Ka(t,e){return e.some(n=>n==="/"?t==="/":t===n||t.startsWith(n+"/"))}function jn(t,e){try{const n=new URL(t),r=new URL(e);if(n.origin!==r.origin)return!1;const i=r.pathname.replace(/\/$/,"");if(!i)return!0;const o=n.pathname.replace(/\/$/,"");return o===i||o.startsWith(i+"/")}catch{return!1}}function Za({orgSlug:t,projSlug:e,preToken:n,convexUrl:r,preAllowedUrls:i,preExcludedPaths:o}){S(()=>{const s=r??"https://festive-mouse-978.eu-west-1.convex.cloud",l=s?_n(s):void 0;if(!l||!t)return;if(Ti.value={orgSlug:t,projSlug:e,siteUrl:l},n){vn.value=i??[],wn.value=o??[];return}let a=!1;return(async()=>{const u=await kn(t,l,e);if(!a)if(u.ok)ue.value=u.token,vn.value=u.allowedUrls,wn.value=u.excludePaths;else{const d=e?`project '${t}/${e}'`:`org '${t}'`;u.error==="unauthorized"?console.warn(`[JexityChat] Domain not authorized for ${d}. Check the widget's domain rules.`):u.error==="not_found"?console.error(`[JexityChat] No active widget config found for ${d}.`):u.error==="rate_limited"?console.error(`[JexityChat] Bootstrap rate-limited for ${d}. Retry after ${u.retryAfterSec??60}s.`):console.error(`[JexityChat] Bootstrap failed: ${u.error}`)}})(),()=>{a=!0}},[t,e,n,r])}const Et=new Set;let Ri=!1;function Ya(){if(Ri)return;Ri=!0;const t=history.pushState.bind(history),e=history.replaceState.bind(history);history.pushState=function(...n){t(...n),Et.forEach(r=>r())},history.replaceState=function(...n){e(...n),Et.forEach(r=>r())}}function Xa(t){return Et.add(t),window.addEventListener("popstate",t),Ya(),()=>{Et.delete(t),window.removeEventListener("popstate",t)}}function el(){const t=Le(window.location.href);S(()=>Xa(()=>{t.value=window.location.href}),[]);const e=vn.value,n=wn.value,r=new URL(t.value).pathname,i=Ka(r,n);return S(()=>{i?console.warn(`[JexityChat] Widget hidden โ current path is in the exclude list: ${r}`):e.length>0&&!e.some(o=>jn(t.value,o))&&console.warn(`[JexityChat] Widget hidden โ current page does not match path rule. Allowed: ${e.join(", ")}`)},[t.value,e,n]),i?!1:e.length===0?!0:e.some(o=>jn(t.value,o))}const $i={title:"Assistant",statusOnline:"Online ยท Responds in seconds",inputPlaceholder:"Type a messageโฆ",aiThinking:"AI is respondingโฆ",sendAriaLabel:"Send message",attachImagesAriaLabel:"Attach images",attachComingSoon:"File attachments โ coming soon",removeAttachmentAriaLabel:"Remove attachment",openChatAriaLabel:"Open chat",closeChatAriaLabel:"Close chat",errorNetwork:"Network error. Please try again.",errorQuota:"Message limit reached. Please try again later.",errorRateLimited:"Too many messages. Try again in {seconds}s.",errorSessionNoToken:"Could not connect to chat. Check your connection and try again.",errorSessionUnauthorized:"This chat is not authorised on this page. Please reload.",localeLabelDe:"DE",localeLabelEn:"EN",resumeConversation:"Resuming conversationโฆ",startingConversation:"Starting conversationโฆ",sessionNotFound:"Your previous session was not found. Starting a new conversation.",startNewConversation:"Start new conversation",chatWith:"Chat with {title}",haveReferenceNumber:"Have a reference number?",referencePlaceholder:"e.g. JEX-A3B7C2",resume:"Resume",howCanWeHelp:"How can we help?",getInstantHelp:"Get instant help",submitTicket:"Submit a ticket",replyByEmail:"We'll reply by email",ticketSubmitted:"Ticket submitted",yourReferenceNumber:"Your reference number:",sentToEmailHint:"We've sent it to your email. Use this number to follow up.",done:"Done",submittingTicket:"Submitting your ticketโฆ",yourName:"Your name",yourEmail:"Your email",submit:"Submit",back:"Go back",escalationFormTitle:"Leave your details",escalationSubtitle:"Our team will get back to you by email so you donโt have to wait here.",escalationNameLabel:"Your name",escalationEmailLabel:"Your email",escalationSubmit:"Send to team",escalationSubmitting:"Sendingโฆ",escalationSubmitted:"Request submitted",escalationConsent:"By submitting, you agree to our",escalationPrivacyLinkText:"Privacy Policy",escalationSkip:"Skip, Iโll wait here",escalationPromptTitle:"Talk to our team",escalationPromptSubtitle:"We can notify you by email when our team replies.",escalationPromptSubmit:"Leave details",escalationSubmitFailed:"Failed to submit. Please try again.",sessionNotFoundPrompt:"Session not found. Would you like to start a new conversation?",sessionLocked:"For your privacy, this conversation was closed after a period of inactivity. Enter your reference to resume, or start a new conversation.",sessionResolved:"This conversation has been resolved.",tryAgain:"Try again",goBack:"Go back",somethingWentWrong:"Something went wrong",fabLabel:"Chat with us",chatNoLongerAvailable:"This chat is no longer available.",talkToHuman:"Talk to human",talkToHumanAria:"Talk to a human agent",handoffPending:"Connecting you to a human agentโฆ",handoffFailed:"Could not request a human agent. Try again.",handoffRateLimited:"You requested an agent recently. Please wait before trying again.",resumeListLabel:"Continue conversation",resumeListTimestamp:"{minutes}m ago",noticeAgentJoined:"{name} has joined the conversation.",noticeHumanRequested:"You requested to speak with a human agent.",noticeHumanRequestedForm:"You requested to speak with a human agent. Please share your contact details below.",noticeEscalationConfirmed:`Thank you {name}! A human agent will be available soon.
|
|
1
|
+
(function(){"use strict";var Ze,y,nr,rr,ke,ir,or,sr,ar,Zt,Yt,Xt,lr,Ye={},cr=[],Io=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Xe=Array.isArray;function re(t,e){for(var n in e)t[n]=e[n];return t}function en(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function G(t,e,n){var r,i,o,s={};for(o in e)o=="key"?r=e[o]:o=="ref"?i=e[o]:s[o]=e[o];if(arguments.length>2&&(s.children=arguments.length>3?Ze.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(o in t.defaultProps)s[o]===void 0&&(s[o]=t.defaultProps[o]);return et(t,s,r,i,null)}function et(t,e,n,r,i){var o={type:t,props:e,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++nr,__i:-1,__u:0};return i==null&&y.vnode!=null&&y.vnode(o),o}function qo(){return{current:null}}function M(t){return t.children}function ee(t,e){this.props=t,this.context=e}function Me(t,e){if(e==null)return t.__?Me(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?Me(t):null}function ur(t){var e,n;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null){t.__e=t.__c.base=n.__e;break}return ur(t)}}function tn(t){(!t.__d&&(t.__d=!0)&&ke.push(t)&&!jt.__r++||ir!=y.debounceRendering)&&((ir=y.debounceRendering)||or)(jt)}function jt(){for(var t,e,n,r,i,o,s,a=1;ke.length;)ke.length>a&&ke.sort(sr),t=ke.shift(),a=ke.length,t.__d&&(n=void 0,r=void 0,i=(r=(e=t).__v).__e,o=[],s=[],e.__P&&((n=re({},r)).__v=r.__v+1,y.vnode&&y.vnode(n),nn(e.__P,n,r,e.__n,e.__P.namespaceURI,32&r.__u?[i]:null,o,i??Me(r),!!(32&r.__u),s),n.__v=r.__v,n.__.__k[n.__i]=n,gr(o,n,s),r.__e=r.__=null,n.__e!=i&&ur(n)));jt.__r=0}function dr(t,e,n,r,i,o,s,a,c,u,h){var d,f,p,g,x,v,m,b=r&&r.__k||cr,E=e.length;for(c=Lo(n,e,b,c,E),d=0;d<E;d++)(p=n.__k[d])!=null&&(f=p.__i==-1?Ye:b[p.__i]||Ye,p.__i=d,v=nn(t,p,f,i,o,s,a,c,u,h),g=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&on(f.ref,null,p),h.push(p.ref,p.__c||g,p)),x==null&&g!=null&&(x=g),(m=!!(4&p.__u))||f.__k===p.__k?c=hr(p,c,t,m):typeof p.type=="function"&&v!==void 0?c=v:g&&(c=g.nextSibling),p.__u&=-7);return n.__e=x,c}function Lo(t,e,n,r,i){var o,s,a,c,u,h=n.length,d=h,f=0;for(t.__k=new Array(i),o=0;o<i;o++)(s=e[o])!=null&&typeof s!="boolean"&&typeof s!="function"?(c=o+f,(s=t.__k[o]=typeof s=="string"||typeof s=="number"||typeof s=="bigint"||s.constructor==String?et(null,s,null,null,null):Xe(s)?et(M,{children:s},null,null,null):s.constructor==null&&s.__b>0?et(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):s).__=t,s.__b=t.__b+1,a=null,(u=s.__i=Mo(s,n,c,d))!=-1&&(d--,(a=n[u])&&(a.__u|=2)),a==null||a.__v==null?(u==-1&&(i>h?f--:i<h&&f++),typeof s.type!="function"&&(s.__u|=4)):u!=c&&(u==c-1?f--:u==c+1?f++:(u>c?f--:f++,s.__u|=4))):t.__k[o]=null;if(d)for(o=0;o<h;o++)(a=n[o])!=null&&(2&a.__u)==0&&(a.__e==r&&(r=Me(a)),xr(a,a));return r}function hr(t,e,n,r){var i,o;if(typeof t.type=="function"){for(i=t.__k,o=0;i&&o<i.length;o++)i[o]&&(i[o].__=t,e=hr(i[o],e,n,r));return e}t.__e!=e&&(r&&(e&&t.type&&!e.parentNode&&(e=Me(t)),n.insertBefore(t.__e,e||null)),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function ie(t,e){return e=e||[],t==null||typeof t=="boolean"||(Xe(t)?t.some(function(n){ie(n,e)}):e.push(t)),e}function Mo(t,e,n,r){var i,o,s,a=t.key,c=t.type,u=e[n],h=u!=null&&(2&u.__u)==0;if(u===null&&t.key==null||h&&a==u.key&&c==u.type)return n;if(r>(h?1:0)){for(i=n-1,o=n+1;i>=0||o<e.length;)if((u=e[s=i>=0?i--:o++])!=null&&(2&u.__u)==0&&a==u.key&&c==u.type)return s}return-1}function fr(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||Io.test(e)?n:n+"px"}function St(t,e,n,r,i){var o,s;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof r=="string"&&(t.style.cssText=r=""),r)for(e in r)n&&e in n||fr(t.style,e,"");if(n)for(e in n)r&&n[e]==r[e]||fr(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")o=e!=(e=e.replace(ar,"$1")),s=e.toLowerCase(),e=s in t||e=="onFocusOut"||e=="onFocusIn"?s.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+o]=n,n?r?n.u=r.u:(n.u=Zt,t.addEventListener(e,o?Xt:Yt,o)):t.removeEventListener(e,o?Xt:Yt,o);else{if(i=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function pr(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=Zt++;else if(e.t<n.u)return;return n(y.event?y.event(e):e)}}}function nn(t,e,n,r,i,o,s,a,c,u){var h,d,f,p,g,x,v,m,b,E,q,z,L,Z,Ie,we,qe,Y=e.type;if(e.constructor!=null)return null;128&n.__u&&(c=!!(32&n.__u),o=[a=e.__e=n.__e]),(h=y.__b)&&h(e);e:if(typeof Y=="function")try{if(m=e.props,b="prototype"in Y&&Y.prototype.render,E=(h=Y.contextType)&&r[h.__c],q=h?E?E.props.value:h.__:r,n.__c?v=(d=e.__c=n.__c).__=d.__E:(b?e.__c=d=new Y(m,q):(e.__c=d=new ee(m,q),d.constructor=Y,d.render=zo),E&&E.sub(d),d.props=m,d.state||(d.state={}),d.context=q,d.__n=r,f=d.__d=!0,d.__h=[],d._sb=[]),b&&d.__s==null&&(d.__s=d.state),b&&Y.getDerivedStateFromProps!=null&&(d.__s==d.state&&(d.__s=re({},d.__s)),re(d.__s,Y.getDerivedStateFromProps(m,d.__s))),p=d.props,g=d.state,d.__v=e,f)b&&Y.getDerivedStateFromProps==null&&d.componentWillMount!=null&&d.componentWillMount(),b&&d.componentDidMount!=null&&d.__h.push(d.componentDidMount);else{if(b&&Y.getDerivedStateFromProps==null&&m!==p&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(m,q),!d.__e&&d.shouldComponentUpdate!=null&&d.shouldComponentUpdate(m,d.__s,q)===!1||e.__v==n.__v){for(e.__v!=n.__v&&(d.props=m,d.state=d.__s,d.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(X){X&&(X.__=e)}),z=0;z<d._sb.length;z++)d.__h.push(d._sb[z]);d._sb=[],d.__h.length&&s.push(d);break e}d.componentWillUpdate!=null&&d.componentWillUpdate(m,d.__s,q),b&&d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(p,g,x)})}if(d.context=q,d.props=m,d.__P=t,d.__e=!1,L=y.__r,Z=0,b){for(d.state=d.__s,d.__d=!1,L&&L(e),h=d.render(d.props,d.state,d.context),Ie=0;Ie<d._sb.length;Ie++)d.__h.push(d._sb[Ie]);d._sb=[]}else do d.__d=!1,L&&L(e),h=d.render(d.props,d.state,d.context),d.state=d.__s;while(d.__d&&++Z<25);d.state=d.__s,d.getChildContext!=null&&(r=re(re({},r),d.getChildContext())),b&&!f&&d.getSnapshotBeforeUpdate!=null&&(x=d.getSnapshotBeforeUpdate(p,g)),we=h,h!=null&&h.type===M&&h.key==null&&(we=mr(h.props.children)),a=dr(t,Xe(we)?we:[we],e,n,r,i,o,s,a,c,u),d.base=e.__e,e.__u&=-161,d.__h.length&&s.push(d),v&&(d.__E=d.__=null)}catch(X){if(e.__v=null,c||o!=null)if(X.then){for(e.__u|=c?160:128;a&&a.nodeType==8&&a.nextSibling;)a=a.nextSibling;o[o.indexOf(a)]=null,e.__e=a}else{for(qe=o.length;qe--;)en(o[qe]);rn(e)}else e.__e=n.__e,e.__k=n.__k,X.then||rn(e);y.__e(X,e,n)}else o==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):a=e.__e=No(n.__e,e,n,r,i,o,s,c,u);return(h=y.diffed)&&h(e),128&e.__u?void 0:a}function rn(t){t&&t.__c&&(t.__c.__e=!0),t&&t.__k&&t.__k.forEach(rn)}function gr(t,e,n){for(var r=0;r<n.length;r++)on(n[r],n[++r],n[++r]);y.__c&&y.__c(e,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(o){o.call(i)})}catch(o){y.__e(o,i.__v)}})}function mr(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:Xe(t)?t.map(mr):re({},t)}function No(t,e,n,r,i,o,s,a,c){var u,h,d,f,p,g,x,v=n.props,m=e.props,b=e.type;if(b=="svg"?i="http://www.w3.org/2000/svg":b=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),o!=null){for(u=0;u<o.length;u++)if((p=o[u])&&"setAttribute"in p==!!b&&(b?p.localName==b:p.nodeType==3)){t=p,o[u]=null;break}}if(t==null){if(b==null)return document.createTextNode(m);t=document.createElementNS(i,b,m.is&&m),a&&(y.__m&&y.__m(e,o),a=!1),o=null}if(b==null)v===m||a&&t.data==m||(t.data=m);else{if(o=o&&Ze.call(t.childNodes),v=n.props||Ye,!a&&o!=null)for(v={},u=0;u<t.attributes.length;u++)v[(p=t.attributes[u]).name]=p.value;for(u in v)if(p=v[u],u!="children"){if(u=="dangerouslySetInnerHTML")d=p;else if(!(u in m)){if(u=="value"&&"defaultValue"in m||u=="checked"&&"defaultChecked"in m)continue;St(t,u,null,p,i)}}for(u in m)p=m[u],u=="children"?f=p:u=="dangerouslySetInnerHTML"?h=p:u=="value"?g=p:u=="checked"?x=p:a&&typeof p!="function"||v[u]===p||St(t,u,p,v[u],i);if(h)a||d&&(h.__html==d.__html||h.__html==t.innerHTML)||(t.innerHTML=h.__html),e.__k=[];else if(d&&(t.innerHTML=""),dr(e.type=="template"?t.content:t,Xe(f)?f:[f],e,n,r,b=="foreignObject"?"http://www.w3.org/1999/xhtml":i,o,s,o?o[0]:n.__k&&Me(n,0),a,c),o!=null)for(u=o.length;u--;)en(o[u]);a||(u="value",b=="progress"&&g==null?t.removeAttribute("value"):g!=null&&(g!==t[u]||b=="progress"&&!g||b=="option"&&g!=v[u])&&St(t,u,g,v[u],i),u="checked",x!=null&&x!=t[u]&&St(t,u,x,v[u],i))}return t}function on(t,e,n){try{if(typeof t=="function"){var r=typeof t.__u=="function";r&&t.__u(),r&&e==null||(t.__u=t(e))}else t.current=e}catch(i){y.__e(i,n)}}function xr(t,e,n){var r,i;if(y.unmount&&y.unmount(t),(r=t.ref)&&(r.current&&r.current!=t.__e||on(r,null,e)),(r=t.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(o){y.__e(o,e)}r.base=r.__P=null}if(r=t.__k)for(i=0;i<r.length;i++)r[i]&&xr(r[i],e,n||typeof t.type!="function");n||en(t.__e),t.__c=t.__=t.__e=void 0}function zo(t,e,n){return this.constructor(t,n)}function _e(t,e,n){var r,i,o,s;e==document&&(e=document.documentElement),y.__&&y.__(t,e),i=(r=typeof n=="function")?null:n&&n.__k||e.__k,o=[],s=[],nn(e,t=(!r&&n||e).__k=G(M,null,[t]),i||Ye,Ye,e.namespaceURI,!r&&n?[n]:i?null:e.firstChild?Ze.call(e.childNodes):null,o,!r&&n?n:i?i.__e:e.firstChild,r,s),gr(o,t,s)}function br(t,e){_e(t,e,br)}function Oo(t,e,n){var r,i,o,s,a=re({},t.props);for(o in t.type&&t.type.defaultProps&&(s=t.type.defaultProps),e)o=="key"?r=e[o]:o=="ref"?i=e[o]:a[o]=e[o]===void 0&&s!=null?s[o]:e[o];return arguments.length>2&&(a.children=arguments.length>3?Ze.call(arguments,2):n),et(t.type,a,r||t.key,i||t.ref,null)}function Bo(t){function e(n){var r,i;return this.getChildContext||(r=new Set,(i={})[e.__c]=this,this.getChildContext=function(){return i},this.componentWillUnmount=function(){r=null},this.shouldComponentUpdate=function(o){this.props.value!=o.value&&r.forEach(function(s){s.__e=!0,tn(s)})},this.sub=function(o){r.add(o);var s=o.componentWillUnmount;o.componentWillUnmount=function(){r&&r.delete(o),s&&s.call(o)}}),n.children}return e.__c="__cC"+lr++,e.__=t,e.Provider=e.__l=(e.Consumer=function(n,r){return n.children(r)}).contextType=e,e}Ze=cr.slice,y={__e:function(t,e,n,r){for(var i,o,s;e=e.__;)if((i=e.__c)&&!i.__)try{if((o=i.constructor)&&o.getDerivedStateFromError!=null&&(i.setState(o.getDerivedStateFromError(t)),s=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,r||{}),s=i.__d),s)return i.__E=i}catch(a){t=a}throw t}},nr=0,rr=function(t){return t!=null&&t.constructor==null},ee.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=re({},this.state),typeof t=="function"&&(t=t(re({},n),this.props)),t&&re(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),tn(this))},ee.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),tn(this))},ee.prototype.render=M,ke=[],or=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,sr=function(t,e){return t.__v.__b-e.__v.__b},jt.__r=0,ar=/(PointerCapture)$|Capture$/i,Zt=0,Yt=pr(!1),Xt=pr(!0),lr=0;var Do=0;function l(t,e,n,r,i,o){e||(e={});var s,a,c=e;if("ref"in c)for(a in c={},e)a=="ref"?s=e[a]:c[a]=e[a];var u={type:t,props:c,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Do,__i:-1,__u:0,__source:i,__self:o};if(typeof t=="function"&&(s=t.defaultProps))for(a in s)c[a]===void 0&&(c[a]=s[a]);return y.vnode&&y.vnode(u),u}var ge,R,sn,vr,Ne=0,yr=[],A=y,wr=A.__b,kr=A.__r,_r=A.diffed,jr=A.__c,Sr=A.unmount,Cr=A.__;function ze(t,e){A.__h&&A.__h(R,t,Ne||e),Ne=0;var n=R.__H||(R.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function C(t){return Ne=1,je(Er,t)}function je(t,e,n){var r=ze(ge++,2);if(r.t=t,!r.__c&&(r.__=[n?n(e):Er(void 0,e),function(a){var c=r.__N?r.__N[0]:r.__[0],u=r.t(c,a);c!==u&&(r.__N=[u,r.__[1]],r.__c.setState({}))}],r.__c=R,!R.__f)){var i=function(a,c,u){if(!r.__c.__H)return!0;var h=r.__c.__H.__.filter(function(f){return!!f.__c});if(h.every(function(f){return!f.__N}))return!o||o.call(this,a,c,u);var d=r.__c.props!==a;return h.forEach(function(f){if(f.__N){var p=f.__[0];f.__=f.__N,f.__N=void 0,p!==f.__[0]&&(d=!0)}}),o&&o.call(this,a,c,u)||d};R.__f=!0;var o=R.shouldComponentUpdate,s=R.componentWillUpdate;R.componentWillUpdate=function(a,c,u){if(this.__e){var h=o;o=void 0,i(a,c,u),o=h}s&&s.call(this,a,c,u)},R.shouldComponentUpdate=i}return r.__N||r.__}function T(t,e){var n=ze(ge++,3);!A.__s&&ln(n.__H,e)&&(n.__=t,n.u=e,R.__H.__h.push(n))}function tt(t,e){var n=ze(ge++,4);!A.__s&&ln(n.__H,e)&&(n.__=t,n.u=e,R.__h.push(n))}function me(t){return Ne=5,D(function(){return{current:t}},[])}function Tr(t,e,n){Ne=6,tt(function(){if(typeof t=="function"){var r=t(e());return function(){t(null),r&&typeof r=="function"&&r()}}if(t)return t.current=e(),function(){return t.current=null}},n==null?n:n.concat(t))}function D(t,e){var n=ze(ge++,7);return ln(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function ue(t,e){return Ne=8,D(function(){return t},e)}function nt(t){var e=R.context[t.__c],n=ze(ge++,9);return n.c=t,e?(n.__==null&&(n.__=!0,e.sub(R)),e.props.value):t.__}function Rr(t,e){A.useDebugValue&&A.useDebugValue(e?e(t):t)}function Ar(){var t=ze(ge++,11);if(!t.__){for(var e=R.__v;e!==null&&!e.__m&&e.__!==null;)e=e.__;var n=e.__m||(e.__m=[0,0]);t.__="P"+n[0]+"-"+n[1]++}return t.__}function Uo(){for(var t;t=yr.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(Ct),t.__H.__h.forEach(an),t.__H.__h=[]}catch(e){t.__H.__h=[],A.__e(e,t.__v)}}A.__b=function(t){R=null,wr&&wr(t)},A.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),Cr&&Cr(t,e)},A.__r=function(t){kr&&kr(t),ge=0;var e=(R=t.__c).__H;e&&(sn===R?(e.__h=[],R.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.forEach(Ct),e.__h.forEach(an),e.__h=[],ge=0)),sn=R},A.diffed=function(t){_r&&_r(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(yr.push(e)!==1&&vr===A.requestAnimationFrame||((vr=A.requestAnimationFrame)||Fo)(Uo)),e.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),sn=R=null},A.__c=function(t,e){e.some(function(n){try{n.__h.forEach(Ct),n.__h=n.__h.filter(function(r){return!r.__||an(r)})}catch(r){e.some(function(i){i.__h&&(i.__h=[])}),e=[],A.__e(r,n.__v)}}),jr&&jr(t,e)},A.unmount=function(t){Sr&&Sr(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(r){try{Ct(r)}catch(i){e=i}}),n.__H=void 0,e&&A.__e(e,n.__v))};var $r=typeof requestAnimationFrame=="function";function Fo(t){var e,n=function(){clearTimeout(r),$r&&cancelAnimationFrame(e),setTimeout(t)},r=setTimeout(n,35);$r&&(e=requestAnimationFrame(n))}function Ct(t){var e=R,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),R=e}function an(t){var e=R;t.__c=t.__(),R=e}function ln(t,e){return!t||t.length!==e.length||e.some(function(n,r){return n!==t[r]})}function Er(t,e){return typeof e=="function"?e(t):e}function Pr(t,e){for(var n in e)t[n]=e[n];return t}function cn(t,e){for(var n in t)if(n!=="__source"&&!(n in e))return!0;for(var r in e)if(r!=="__source"&&t[r]!==e[r])return!0;return!1}function Ir(t,e){var n=e(),r=C({t:{__:n,u:e}}),i=r[0].t,o=r[1];return tt(function(){i.__=n,i.u=e,un(i)&&o({t:i})},[t,n,e]),T(function(){return un(i)&&o({t:i}),t(function(){un(i)&&o({t:i})})},[t]),n}function un(t){var e,n,r=t.u,i=t.__;try{var o=r();return!((e=i)===(n=o)&&(e!==0||1/e==1/n)||e!=e&&n!=n)}catch{return!0}}function qr(t){t()}function Lr(t){return t}function Mr(){return[!1,qr]}var Nr=tt;function dn(t,e){this.props=t,this.context=e}function Qo(t,e){function n(i){var o=this.props.ref,s=o==i.ref;return!s&&o&&(o.call?o(null):o.current=null),e?!e(this.props,i)||!s:cn(this.props,i)}function r(i){return this.shouldComponentUpdate=n,G(t,i)}return r.displayName="Memo("+(t.displayName||t.name)+")",r.prototype.isReactComponent=!0,r.__f=!0,r.type=t,r}(dn.prototype=new ee).isPureReactComponent=!0,dn.prototype.shouldComponentUpdate=function(t,e){return cn(this.props,t)||cn(this.state,e)};var zr=y.__b;y.__b=function(t){t.type&&t.type.__f&&t.ref&&(t.props.ref=t.ref,t.ref=null),zr&&zr(t)};var Vo=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function Wo(t){function e(n){var r=Pr({},n);return delete r.ref,t(r,n.ref||null)}return e.$$typeof=Vo,e.render=t,e.prototype.isReactComponent=e.__f=!0,e.displayName="ForwardRef("+(t.displayName||t.name)+")",e}var Or=function(t,e){return t==null?null:ie(ie(t).map(e))},Ho={map:Or,forEach:Or,count:function(t){return t?ie(t).length:0},only:function(t){var e=ie(t);if(e.length!==1)throw"Children.only";return e[0]},toArray:ie},Go=y.__e;y.__e=function(t,e,n,r){if(t.then){for(var i,o=e;o=o.__;)if((i=o.__c)&&i.__c)return e.__e==null&&(e.__e=n.__e,e.__k=n.__k),i.__c(t,e)}Go(t,e,n,r)};var Br=y.unmount;function Dr(t,e,n){return t&&(t.__c&&t.__c.__H&&(t.__c.__H.__.forEach(function(r){typeof r.__c=="function"&&r.__c()}),t.__c.__H=null),(t=Pr({},t)).__c!=null&&(t.__c.__P===n&&(t.__c.__P=e),t.__c.__e=!0,t.__c=null),t.__k=t.__k&&t.__k.map(function(r){return Dr(r,e,n)})),t}function Ur(t,e,n){return t&&n&&(t.__v=null,t.__k=t.__k&&t.__k.map(function(r){return Ur(r,e,n)}),t.__c&&t.__c.__P===e&&(t.__e&&n.appendChild(t.__e),t.__c.__e=!0,t.__c.__P=n)),t}function Tt(){this.__u=0,this.o=null,this.__b=null}function Fr(t){var e=t.__.__c;return e&&e.__a&&e.__a(t)}function Jo(t){var e,n,r;function i(o){if(e||(e=t()).then(function(s){n=s.default||s},function(s){r=s}),r)throw r;if(!n)throw e;return G(n,o)}return i.displayName="Lazy",i.__f=!0,i}function rt(){this.i=null,this.l=null}y.unmount=function(t){var e=t.__c;e&&e.__R&&e.__R(),e&&32&t.__u&&(t.type=null),Br&&Br(t)},(Tt.prototype=new ee).__c=function(t,e){var n=e.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var i=Fr(r.__v),o=!1,s=function(){o||(o=!0,n.__R=null,i?i(a):a())};n.__R=s;var a=function(){if(!--r.__u){if(r.state.__a){var c=r.state.__a;r.__v.__k[0]=Ur(c,c.__c.__P,c.__c.__O)}var u;for(r.setState({__a:r.__b=null});u=r.o.pop();)u.forceUpdate()}};r.__u++||32&e.__u||r.setState({__a:r.__b=r.__v.__k[0]}),t.then(s,s)},Tt.prototype.componentWillUnmount=function(){this.o=[]},Tt.prototype.render=function(t,e){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),r=this.__v.__k[0].__c;this.__v.__k[0]=Dr(this.__b,n,r.__O=r.__P)}this.__b=null}var i=e.__a&&G(M,null,t.fallback);return i&&(i.__u&=-33),[G(M,null,e.__a?null:t.children),i]};var Qr=function(t,e,n){if(++n[1]===n[0]&&t.l.delete(e),t.props.revealOrder&&(t.props.revealOrder[0]!=="t"||!t.l.size))for(n=t.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;t.i=n=n[2]}};function Ko(t){return this.getChildContext=function(){return t.context},t.children}function Zo(t){var e=this,n=t.h;if(e.componentWillUnmount=function(){_e(null,e.v),e.v=null,e.h=null},e.h&&e.h!==n&&e.componentWillUnmount(),!e.v){for(var r=e.__v;r!==null&&!r.__m&&r.__!==null;)r=r.__;e.h=n,e.v={nodeType:1,parentNode:n,childNodes:[],__k:{__m:r.__m},contains:function(){return!0},insertBefore:function(i,o){this.childNodes.push(i),e.h.insertBefore(i,o)},removeChild:function(i){this.childNodes.splice(this.childNodes.indexOf(i)>>>1,1),e.h.removeChild(i)}}}_e(G(Ko,{context:e.context},t.__v),e.v)}function Yo(t,e){var n=G(Zo,{__v:t,h:e});return n.containerInfo=e,n}(rt.prototype=new ee).__a=function(t){var e=this,n=Fr(e.__v),r=e.l.get(t);return r[0]++,function(i){var o=function(){e.props.revealOrder?(r.push(i),Qr(e,t,r)):i()};n?n(o):o()}},rt.prototype.render=function(t){this.i=null,this.l=new Map;var e=ie(t.children);t.revealOrder&&t.revealOrder[0]==="b"&&e.reverse();for(var n=e.length;n--;)this.l.set(e[n],this.i=[1,0,this.i]);return t.children},rt.prototype.componentDidUpdate=rt.prototype.componentDidMount=function(){var t=this;this.l.forEach(function(e,n){Qr(t,n,e)})};var Vr=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,Xo=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,es=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,ts=/[A-Z0-9]/g,ns=typeof document<"u",rs=function(t){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(t)};function is(t,e,n){return e.__k==null&&(e.textContent=""),_e(t,e),typeof n=="function"&&n(),t?t.__c:null}function os(t,e,n){return br(t,e),typeof n=="function"&&n(),t?t.__c:null}ee.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(t){Object.defineProperty(ee.prototype,t,{configurable:!0,get:function(){return this["UNSAFE_"+t]},set:function(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})});var Wr=y.event;function ss(){}function as(){return this.cancelBubble}function ls(){return this.defaultPrevented}y.event=function(t){return Wr&&(t=Wr(t)),t.persist=ss,t.isPropagationStopped=as,t.isDefaultPrevented=ls,t.nativeEvent=t};var hn,cs={enumerable:!1,configurable:!0,get:function(){return this.class}},Hr=y.vnode;y.vnode=function(t){typeof t.type=="string"&&(function(e){var n=e.props,r=e.type,i={},o=r.indexOf("-")===-1;for(var s in n){var a=n[s];if(!(s==="value"&&"defaultValue"in n&&a==null||ns&&s==="children"&&r==="noscript"||s==="class"||s==="className")){var c=s.toLowerCase();s==="defaultValue"&&"value"in n&&n.value==null?s="value":s==="download"&&a===!0?a="":c==="translate"&&a==="no"?a=!1:c[0]==="o"&&c[1]==="n"?c==="ondoubleclick"?s="ondblclick":c!=="onchange"||r!=="input"&&r!=="textarea"||rs(n.type)?c==="onfocus"?s="onfocusin":c==="onblur"?s="onfocusout":es.test(s)&&(s=c):c=s="oninput":o&&Xo.test(s)?s=s.replace(ts,"-$&").toLowerCase():a===null&&(a=void 0),c==="oninput"&&i[s=c]&&(s="oninputCapture"),i[s]=a}}r=="select"&&i.multiple&&Array.isArray(i.value)&&(i.value=ie(n.children).forEach(function(u){u.props.selected=i.value.indexOf(u.props.value)!=-1})),r=="select"&&i.defaultValue!=null&&(i.value=ie(n.children).forEach(function(u){u.props.selected=i.multiple?i.defaultValue.indexOf(u.props.value)!=-1:i.defaultValue==u.props.value})),n.class&&!n.className?(i.class=n.class,Object.defineProperty(i,"className",cs)):(n.className&&!n.class||n.class&&n.className)&&(i.class=i.className=n.className),e.props=i})(t),t.$$typeof=Vr,Hr&&Hr(t)};var Gr=y.__r;y.__r=function(t){Gr&&Gr(t),hn=t.__c};var Jr=y.diffed;y.diffed=function(t){Jr&&Jr(t);var e=t.props,n=t.__e;n!=null&&t.type==="textarea"&&"value"in e&&e.value!==n.value&&(n.value=e.value==null?"":e.value),hn=null};var us={ReactCurrentDispatcher:{current:{readContext:function(t){return hn.__n[t.__c].props.value},useCallback:ue,useContext:nt,useDebugValue:Rr,useDeferredValue:Lr,useEffect:T,useId:Ar,useImperativeHandle:Tr,useInsertionEffect:Nr,useLayoutEffect:tt,useMemo:D,useReducer:je,useRef:me,useState:C,useSyncExternalStore:Ir,useTransition:Mr}}};function ds(t){return G.bind(null,t)}function Rt(t){return!!t&&t.$$typeof===Vr}function hs(t){return Rt(t)&&t.type===M}function fs(t){return!!t&&!!t.displayName&&(typeof t.displayName=="string"||t.displayName instanceof String)&&t.displayName.startsWith("Memo(")}function ps(t){return Rt(t)?Oo.apply(null,arguments):t}function gs(t){return!!t.__k&&(_e(null,t),!0)}function ms(t){return t&&(t.base||t.nodeType===1&&t)||null}for(var xs=function(t,e){return t(e)},bs=function(t,e){return t(e)},vs=M,ys=Rt,fn={useState:C,useId:Ar,useReducer:je,useEffect:T,useLayoutEffect:tt,useInsertionEffect:Nr,useTransition:Mr,useDeferredValue:Lr,useSyncExternalStore:Ir,startTransition:qr,useRef:me,useImperativeHandle:Tr,useMemo:D,useCallback:ue,useContext:nt,useDebugValue:Rr,version:"18.3.1",Children:Ho,render:is,hydrate:os,unmountComponentAtNode:gs,createPortal:Yo,createElement:G,createContext:Bo,createFactory:ds,cloneElement:ps,createRef:qo,Fragment:M,isValidElement:Rt,isElement:ys,isFragment:hs,isMemo:fs,findDOMNode:ms,Component:ee,PureComponent:dn,memo:Qo,forwardRef:Wo,flushSync:bs,unstable_batchedUpdates:xs,StrictMode:vs,Suspense:Tt,SuspenseList:rt,lazy:Jo,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:us},oe=[],J=[],ws=Uint8Array,pn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Oe=0,ks=pn.length;Oe<ks;++Oe)oe[Oe]=pn[Oe],J[pn.charCodeAt(Oe)]=Oe;J[45]=62,J[95]=63;function _s(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");n===-1&&(n=e);var r=n===e?0:4-n%4;return[n,r]}function js(t,e,n){return(e+n)*3/4-n}function it(t){var e,n=_s(t),r=n[0],i=n[1],o=new ws(js(t,r,i)),s=0,a=i>0?r-4:r,c;for(c=0;c<a;c+=4)e=J[t.charCodeAt(c)]<<18|J[t.charCodeAt(c+1)]<<12|J[t.charCodeAt(c+2)]<<6|J[t.charCodeAt(c+3)],o[s++]=e>>16&255,o[s++]=e>>8&255,o[s++]=e&255;return i===2&&(e=J[t.charCodeAt(c)]<<2|J[t.charCodeAt(c+1)]>>4,o[s++]=e&255),i===1&&(e=J[t.charCodeAt(c)]<<10|J[t.charCodeAt(c+1)]<<4|J[t.charCodeAt(c+2)]>>2,o[s++]=e>>8&255,o[s++]=e&255),o}function Ss(t){return oe[t>>18&63]+oe[t>>12&63]+oe[t>>6&63]+oe[t&63]}function Cs(t,e,n){for(var r,i=[],o=e;o<n;o+=3)r=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(t[o+2]&255),i.push(Ss(r));return i.join("")}function ot(t){for(var e,n=t.length,r=n%3,i=[],o=16383,s=0,a=n-r;s<a;s+=o)i.push(Cs(t,s,s+o>a?a:s+o));return r===1?(e=t[n-1],i.push(oe[e>>2]+oe[e<<4&63]+"==")):r===2&&(e=(t[n-2]<<8)+t[n-1],i.push(oe[e>>10]+oe[e>>4&63]+oe[e<<2&63]+"=")),i.join("")}function de(t){if(t===void 0)return{};if(!Kr(t))throw new Error(`The arguments to a Convex function must be an object. Received: ${t}`);return t}function Ts(t){if(typeof t>"u")throw new Error("Client created with undefined deployment address. If you used an environment variable, check that it's set.");if(typeof t!="string")throw new Error(`Invalid deployment address: found ${t}".`);if(!(t.startsWith("http:")||t.startsWith("https:")))throw new Error(`Invalid deployment address: Must start with "https://" or "http://". Found "${t}".`);try{new URL(t)}catch{throw new Error(`Invalid deployment address: "${t}" is not a valid URL. If you believe this URL is correct, use the \`skipConvexDeploymentUrlCheck\` option to bypass this.`)}if(t.endsWith(".convex.site"))throw new Error(`Invalid deployment address: "${t}" ends with .convex.site, which is used for HTTP Actions. Convex deployment URLs typically end with .convex.cloud? If you believe this URL is correct, use the \`skipConvexDeploymentUrlCheck\` option to bypass this.`)}function Kr(t){const e=typeof t=="object",n=Object.getPrototypeOf(t),r=n===null||n===Object.prototype||n?.constructor?.name==="Object";return e&&r}const Zr=!0,Be=BigInt("-9223372036854775808"),gn=BigInt("9223372036854775807"),mn=BigInt("0"),Rs=BigInt("8"),As=BigInt("256");function Yr(t){return Number.isNaN(t)||!Number.isFinite(t)||Object.is(t,-0)}function $s(t){t<mn&&(t-=Be+Be);let e=t.toString(16);e.length%2===1&&(e="0"+e);const n=new Uint8Array(new ArrayBuffer(8));let r=0;for(const i of e.match(/.{2}/g).reverse())n.set([parseInt(i,16)],r++),t>>=Rs;return ot(n)}function Es(t){const e=it(t);if(e.byteLength!==8)throw new Error(`Received ${e.byteLength} bytes, expected 8 for $integer`);let n=mn,r=mn;for(const i of e)n+=BigInt(i)*As**r,r++;return n>gn&&(n+=Be+Be),n}function Ps(t){if(t<Be||gn<t)throw new Error(`BigInt ${t} does not fit into a 64-bit signed integer.`);const e=new ArrayBuffer(8);return new DataView(e).setBigInt64(0,t,!0),ot(new Uint8Array(e))}function Is(t){const e=it(t);if(e.byteLength!==8)throw new Error(`Received ${e.byteLength} bytes, expected 8 for $integer`);return new DataView(e.buffer).getBigInt64(0,!0)}const qs=DataView.prototype.setBigInt64?Ps:$s,Ls=DataView.prototype.getBigInt64?Is:Es,Xr=1024;function ei(t){if(t.length>Xr)throw new Error(`Field name ${t} exceeds maximum field name length ${Xr}.`);if(t.startsWith("$"))throw new Error(`Field name ${t} starts with a '$', which is reserved.`);for(let e=0;e<t.length;e+=1){const n=t.charCodeAt(e);if(n<32||n>=127)throw new Error(`Field name ${t} has invalid character '${t[e]}': Field names can only contain non-control ASCII characters`)}}function De(t){if(t===null||typeof t=="boolean"||typeof t=="number"||typeof t=="string")return t;if(Array.isArray(t))return t.map(r=>De(r));if(typeof t!="object")throw new Error(`Unexpected type of ${t}`);const e=Object.entries(t);if(e.length===1){const r=e[0][0];if(r==="$bytes"){if(typeof t.$bytes!="string")throw new Error(`Malformed $bytes field on ${t}`);return it(t.$bytes).buffer}if(r==="$integer"){if(typeof t.$integer!="string")throw new Error(`Malformed $integer field on ${t}`);return Ls(t.$integer)}if(r==="$float"){if(typeof t.$float!="string")throw new Error(`Malformed $float field on ${t}`);const i=it(t.$float);if(i.byteLength!==8)throw new Error(`Received ${i.byteLength} bytes, expected 8 for $float`);const s=new DataView(i.buffer).getFloat64(0,Zr);if(!Yr(s))throw new Error(`Float ${s} should be encoded as a number`);return s}if(r==="$set")throw new Error("Received a Set which is no longer supported as a Convex type.");if(r==="$map")throw new Error("Received a Map which is no longer supported as a Convex type.")}const n={};for(const[r,i]of Object.entries(t))ei(r),n[r]=De(i);return n}const ti=16384;function st(t){const e=JSON.stringify(t,(n,r)=>r===void 0?"undefined":typeof r=="bigint"?`${r.toString()}n`:r);if(e.length>ti){const n="[...truncated]";let r=ti-n.length;const i=e.codePointAt(r-1);return i!==void 0&&i>65535&&(r-=1),e.substring(0,r)+n}return e}function xn(t,e,n,r){if(t===void 0){const s=n&&` (present at path ${n} in original object ${st(e)})`;throw new Error(`undefined is not a valid Convex value${s}. To learn about Convex's supported types, see https://docs.convex.dev/using/types.`)}if(t===null)return t;if(typeof t=="bigint"){if(t<Be||gn<t)throw new Error(`BigInt ${t} does not fit into a 64-bit signed integer.`);return{$integer:qs(t)}}if(typeof t=="number")if(Yr(t)){const s=new ArrayBuffer(8);return new DataView(s).setFloat64(0,t,Zr),{$float:ot(new Uint8Array(s))}}else return t;if(typeof t=="boolean"||typeof t=="string")return t;if(t instanceof ArrayBuffer)return{$bytes:ot(new Uint8Array(t))};if(Array.isArray(t))return t.map((s,a)=>xn(s,e,n+`[${a}]`));if(t instanceof Set)throw new Error(bn(n,"Set",[...t],e));if(t instanceof Map)throw new Error(bn(n,"Map",[...t],e));if(!Kr(t)){const s=t?.constructor?.name,a=s?`${s} `:"";throw new Error(bn(n,a,t,e))}const i={},o=Object.entries(t);o.sort(([s,a],[c,u])=>s===c?0:s<c?-1:1);for(const[s,a]of o)a!==void 0&&(ei(s),i[s]=xn(a,e,n+`.${s}`));return i}function bn(t,e,n,r){return t?`${e}${st(n)} is not a supported Convex type (present at path ${t} in original object ${st(r)}). To learn about Convex's supported types, see https://docs.convex.dev/using/types.`:`${e}${st(n)} is not a supported Convex type.`}function se(t){return xn(t,t,"")}var Ms=Object.defineProperty,Ns=(t,e,n)=>e in t?Ms(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,vn=(t,e,n)=>Ns(t,typeof e!="symbol"?e+"":e,n),ni,ri;const zs=Symbol.for("ConvexError");class At extends(ri=Error,ni=zs,ri){constructor(e){super(typeof e=="string"?e:st(e)),vn(this,"name","ConvexError"),vn(this,"data"),vn(this,ni,!0),this.data=e}}const ii=()=>Array.from({length:4},()=>0);ii(),ii();const oi="1.40.0";var Os=Object.defineProperty,Bs=(t,e,n)=>e in t?Os(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,si=(t,e,n)=>Bs(t,typeof e!="symbol"?e+"":e,n);const Ds="color:rgb(0, 145, 255)";function ai(t){switch(t){case"query":return"Q";case"mutation":return"M";case"action":return"A";case"any":return"?"}}class li{constructor(e){si(this,"_onLogLineFuncs"),si(this,"_verbose"),this._onLogLineFuncs={},this._verbose=e.verbose}addLogLineListener(e){let n=Math.random().toString(36).substring(2,15);for(let r=0;r<10&&this._onLogLineFuncs[n]!==void 0;r++)n=Math.random().toString(36).substring(2,15);return this._onLogLineFuncs[n]=e,()=>{delete this._onLogLineFuncs[n]}}logVerbose(...e){if(this._verbose)for(const n of Object.values(this._onLogLineFuncs))n("debug",`${new Date().toISOString()}`,...e)}log(...e){for(const n of Object.values(this._onLogLineFuncs))n("info",...e)}warn(...e){for(const n of Object.values(this._onLogLineFuncs))n("warn",...e)}error(...e){for(const n of Object.values(this._onLogLineFuncs))n("error",...e)}}function ci(t){const e=new li(t);return e.addLogLineListener((n,...r)=>{switch(n){case"debug":console.debug(...r);break;case"info":console.log(...r);break;case"warn":console.warn(...r);break;case"error":console.error(...r);break;default:console.log(...r)}}),e}function ui(t){return new li(t)}function $t(t,e,n,r,i){const o=ai(n);if(typeof i=="object"&&(i=`ConvexError ${JSON.stringify(i.errorData,null,2)}`),e==="info"){const s=i.match(/^\[.*?\] /);if(s===null){t.error(`[CONVEX ${o}(${r})] Could not parse console.log`);return}const a=i.slice(1,s[0].length-2),c=i.slice(s[0].length);t.log(`%c[CONVEX ${o}(${r})] [${a}]`,Ds,c)}else t.error(`[CONVEX ${o}(${r})] ${i}`)}function Us(t,e){const n=`[CONVEX FATAL ERROR] ${e}`;return t.error(n),new Error(n)}function Ue(t,e,n){return`[CONVEX ${ai(t)}(${e})] ${n.errorMessage}
|
|
2
|
+
Called by client`}function yn(t,e){return e.data=t.errorData,e}function Se(t){const e=t.split(":");let n,r;return e.length===1?(n=e[0],r="default"):(n=e.slice(0,e.length-1).join(":"),r=e[e.length-1]),n.endsWith(".js")&&(n=n.slice(0,-3)),`${n}:${r}`}function Ce(t,e){return JSON.stringify({udfPath:Se(t),args:se(e)})}function di(t,e,n){const{initialNumItems:r,id:i}=n;return JSON.stringify({type:"paginated",udfPath:Se(t),args:se(e),options:se({initialNumItems:r,id:i})})}var Fs=Object.defineProperty,Qs=(t,e,n)=>e in t?Fs(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,ae=(t,e,n)=>Qs(t,typeof e!="symbol"?e+"":e,n);class Vs{constructor(){ae(this,"nextQueryId"),ae(this,"querySetVersion"),ae(this,"querySet"),ae(this,"queryIdToToken"),ae(this,"identityVersion"),ae(this,"auth"),ae(this,"outstandingQueriesOlderThanRestart"),ae(this,"outstandingAuthOlderThanRestart"),ae(this,"paused"),ae(this,"pendingQuerySetModifications"),this.nextQueryId=0,this.querySetVersion=0,this.identityVersion=0,this.querySet=new Map,this.queryIdToToken=new Map,this.outstandingQueriesOlderThanRestart=new Set,this.outstandingAuthOlderThanRestart=!1,this.paused=!1,this.pendingQuerySetModifications=new Map}hasSyncedPastLastReconnect(){return this.outstandingQueriesOlderThanRestart.size===0&&!this.outstandingAuthOlderThanRestart}markAuthCompletion(){this.outstandingAuthOlderThanRestart=!1}subscribe(e,n,r,i){const o=Se(e),s=Ce(o,n),a=this.querySet.get(s);if(a!==void 0)return a.numSubscribers+=1,{queryToken:s,modification:null,unsubscribe:()=>this.removeSubscriber(s)};{const c=this.nextQueryId++,u={id:c,canonicalizedUdfPath:o,args:n,numSubscribers:1,journal:r,componentPath:i};this.querySet.set(s,u),this.queryIdToToken.set(c,s);const h=this.querySetVersion,d=this.querySetVersion+1,f={type:"Add",queryId:c,udfPath:o,args:[se(n)],journal:r,componentPath:i};return this.paused?this.pendingQuerySetModifications.set(c,f):this.querySetVersion=d,{queryToken:s,modification:{type:"ModifyQuerySet",baseVersion:h,newVersion:d,modifications:[f]},unsubscribe:()=>this.removeSubscriber(s)}}}transition(e){for(const n of e.modifications)switch(n.type){case"QueryUpdated":case"QueryFailed":{this.outstandingQueriesOlderThanRestart.delete(n.queryId);const r=n.journal;if(r!==void 0){const i=this.queryIdToToken.get(n.queryId);i!==void 0&&(this.querySet.get(i).journal=r)}break}case"QueryRemoved":{this.outstandingQueriesOlderThanRestart.delete(n.queryId);break}default:throw new Error(`Invalid modification ${n.type}`)}}queryId(e,n){const r=Se(e),i=Ce(r,n),o=this.querySet.get(i);return o!==void 0?o.id:null}isCurrentOrNewerAuthVersion(e){return e>=this.identityVersion}getAuth(){return this.auth}setAuth(e){this.auth={tokenType:"User",value:e};const n=this.identityVersion;return this.paused||(this.identityVersion=n+1),{type:"Authenticate",baseVersion:n,...this.auth}}setAdminAuth(e,n){const r={tokenType:"Admin",value:e,impersonating:n};this.auth=r;const i=this.identityVersion;return this.paused||(this.identityVersion=i+1),{type:"Authenticate",baseVersion:i,...r}}clearAuth(){this.auth=void 0,this.markAuthCompletion();const e=this.identityVersion;return this.paused||(this.identityVersion=e+1),{type:"Authenticate",tokenType:"None",baseVersion:e}}hasAuth(){return!!this.auth}isNewAuth(e){return this.auth?.value!==e}queryPath(e){const n=this.queryIdToToken.get(e);return n?this.querySet.get(n).canonicalizedUdfPath:null}queryArgs(e){const n=this.queryIdToToken.get(e);return n?this.querySet.get(n).args:null}queryToken(e){return this.queryIdToToken.get(e)??null}queryJournal(e){return this.querySet.get(e)?.journal}restart(){this.unpause(),this.outstandingQueriesOlderThanRestart.clear();const e=[];for(const i of this.querySet.values()){const o={type:"Add",queryId:i.id,udfPath:i.canonicalizedUdfPath,args:[se(i.args)],journal:i.journal,componentPath:i.componentPath};e.push(o),this.outstandingQueriesOlderThanRestart.add(i.id)}this.querySetVersion=1;const n={type:"ModifyQuerySet",baseVersion:0,newVersion:1,modifications:e};if(!this.auth)return this.identityVersion=0,[n,void 0];this.outstandingAuthOlderThanRestart=!0;const r={type:"Authenticate",baseVersion:0,...this.auth};return this.identityVersion=1,[n,r]}pause(){this.paused=!0}resume(){const e=this.pendingQuerySetModifications.size>0?{type:"ModifyQuerySet",baseVersion:this.querySetVersion,newVersion:++this.querySetVersion,modifications:Array.from(this.pendingQuerySetModifications.values())}:void 0,n=this.auth!==void 0?{type:"Authenticate",baseVersion:this.identityVersion++,...this.auth}:void 0;return this.unpause(),[e,n]}unpause(){this.paused=!1,this.pendingQuerySetModifications.clear()}removeSubscriber(e){const n=this.querySet.get(e);if(n.numSubscribers>1)return n.numSubscribers-=1,null;{this.querySet.delete(e),this.queryIdToToken.delete(n.id),this.outstandingQueriesOlderThanRestart.delete(n.id);const r=this.querySetVersion,i=this.querySetVersion+1,o={type:"Remove",queryId:n.id};return this.paused?this.pendingQuerySetModifications.has(n.id)?this.pendingQuerySetModifications.delete(n.id):this.pendingQuerySetModifications.set(n.id,o):this.querySetVersion=i,{type:"ModifyQuerySet",baseVersion:r,newVersion:i,modifications:[o]}}}}var Ws=Object.defineProperty,Hs=(t,e,n)=>e in t?Ws(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Et=(t,e,n)=>Hs(t,typeof e!="symbol"?e+"":e,n);class Gs{constructor(e,n){this.logger=e,this.markConnectionStateDirty=n,Et(this,"inflightRequests"),Et(this,"requestsOlderThanRestart"),Et(this,"inflightMutationsCount",0),Et(this,"inflightActionsCount",0),this.inflightRequests=new Map,this.requestsOlderThanRestart=new Set}request(e,n){const r=new Promise(i=>{const o=n?"Requested":"NotSent";this.inflightRequests.set(e.requestId,{message:e,status:{status:o,requestedAt:new Date,onResult:i}}),e.type==="Mutation"?this.inflightMutationsCount++:e.type==="Action"&&this.inflightActionsCount++});return this.markConnectionStateDirty(),r}onResponse(e){const n=this.inflightRequests.get(e.requestId);if(n===void 0||n.status.status==="Completed")return null;const r=n.message.type==="Mutation"?"mutation":"action",i=n.message.udfPath;for(const c of e.logLines)$t(this.logger,"info",r,i,c);const o=n.status;let s,a;if(e.success)s={success:!0,logLines:e.logLines,value:De(e.result)},a=()=>o.onResult(s);else{const c=e.result,{errorData:u}=e;$t(this.logger,"error",r,i,c),s={success:!1,errorMessage:c,errorData:u!==void 0?De(u):void 0,logLines:e.logLines},a=()=>o.onResult(s)}return e.type==="ActionResponse"||!e.success?(a(),this.inflightRequests.delete(e.requestId),this.requestsOlderThanRestart.delete(e.requestId),n.message.type==="Action"?this.inflightActionsCount--:n.message.type==="Mutation"&&this.inflightMutationsCount--,this.markConnectionStateDirty(),{requestId:e.requestId,result:s}):(n.status={status:"Completed",result:s,ts:e.ts,onResolve:a},null)}removeCompleted(e){const n=new Map;for(const[r,i]of this.inflightRequests.entries()){const o=i.status;o.status==="Completed"&&o.ts.lessThanOrEqual(e)&&(o.onResolve(),n.set(r,o.result),i.message.type==="Mutation"?this.inflightMutationsCount--:i.message.type==="Action"&&this.inflightActionsCount--,this.inflightRequests.delete(r),this.requestsOlderThanRestart.delete(r))}return n.size>0&&this.markConnectionStateDirty(),n}restart(){this.requestsOlderThanRestart=new Set(this.inflightRequests.keys());const e=[];for(const[n,r]of this.inflightRequests){if(r.status.status==="NotSent"){r.status.status="Requested",e.push(r.message);continue}if(r.message.type==="Mutation")e.push(r.message);else if(r.message.type==="Action"){if(this.inflightRequests.delete(n),this.requestsOlderThanRestart.delete(n),this.inflightActionsCount--,r.status.status==="Completed")throw new Error("Action should never be in 'Completed' state");r.status.onResult({success:!1,errorMessage:"Connection lost while action was in flight",logLines:[]})}}return this.markConnectionStateDirty(),e}resume(){const e=[];for(const[,n]of this.inflightRequests)if(n.status.status==="NotSent"){n.status.status="Requested",e.push(n.message);continue}return e}hasIncompleteRequests(){for(const e of this.inflightRequests.values())if(e.status.status==="Requested")return!0;return!1}hasInflightRequests(){return this.inflightRequests.size>0}hasSyncedPastLastReconnect(){return this.requestsOlderThanRestart.size===0}timeOfOldestInflightRequest(){if(this.inflightRequests.size===0)return null;let e=Date.now();for(const n of this.inflightRequests.values())n.status.status!=="Completed"&&n.status.requestedAt.getTime()<e&&(e=n.status.requestedAt.getTime());return new Date(e)}inflightMutations(){return this.inflightMutationsCount}inflightActions(){return this.inflightActionsCount}}const at=Symbol.for("functionName"),hi=Symbol.for("toReferencePath");function Js(t){return t[hi]??null}function Ks(t){return t.startsWith("function://")}function Zs(t){let e;if(typeof t=="string")Ks(t)?e={functionHandle:t}:e={name:t};else if(t[at])e={name:t[at]};else{const n=Js(t);if(!n)throw new Error(`${t} is not a functionReference`);e={reference:n}}return e}function U(t){const e=Zs(t);if(e.name===void 0)throw e.functionHandle!==void 0?new Error(`Expected function reference like "api.file.func" or "internal.file.func", but received function handle ${e.functionHandle}`):e.reference!==void 0?new Error(`Expected function reference in the current component like "api.file.func" or "internal.file.func", but received reference ${e.reference}`):new Error(`Expected function reference like "api.file.func" or "internal.file.func", but received ${JSON.stringify(e)}`);if(typeof t=="string")return t;const n=t[at];if(!n)throw new Error(`${t} is not a functionReference`);return n}function wn(t){return{[at]:t}}function fi(t=[]){const e={get(n,r){if(typeof r=="string"){const i=[...t,r];return fi(i)}else if(r===at){if(t.length<2){const s=["api",...t].join(".");throw new Error(`API path is expected to be of the form \`api.moduleName.functionName\`. Found: \`${s}\``)}const i=t.slice(0,-1).join("/"),o=t[t.length-1];return o==="default"?i:i+":"+o}else return r===Symbol.toStringTag?"FunctionReference":void 0}};return new Proxy({},e)}const Ys=fi();var Xs=Object.defineProperty,ea=(t,e,n)=>e in t?Xs(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Pt=(t,e,n)=>ea(t,typeof e!="symbol"?e+"":e,n);class lt{constructor(e){Pt(this,"queryResults"),Pt(this,"modifiedQueries"),this.queryResults=e,this.modifiedQueries=[]}getQuery(e,...n){const r=de(n[0]),i=U(e),o=this.queryResults.get(Ce(i,r));if(o!==void 0)return lt.queryValue(o.result)}getAllQueries(e){const n=[],r=U(e);for(const i of this.queryResults.values())i.udfPath===Se(r)&&n.push({args:i.args,value:lt.queryValue(i.result)});return n}setQuery(e,n,r){const i=de(n),o=U(e),s=Ce(o,i);let a;r===void 0?a=void 0:a={success:!0,value:r,logLines:[]};const c={udfPath:o,args:i,result:a};this.queryResults.set(s,c),this.modifiedQueries.push(s)}static queryValue(e){if(e!==void 0)return e.success?e.value:void 0}}class ta{constructor(){Pt(this,"queryResults"),Pt(this,"optimisticUpdates"),this.queryResults=new Map,this.optimisticUpdates=[]}ingestQueryResultsFromServer(e,n){this.optimisticUpdates=this.optimisticUpdates.filter(s=>!n.has(s.mutationId));const r=this.queryResults;this.queryResults=new Map(e);const i=new lt(this.queryResults);for(const s of this.optimisticUpdates)s.update(i);const o=[];for(const[s,a]of this.queryResults){const c=r.get(s);(c===void 0||c.result!==a.result)&&o.push(s)}return o}applyOptimisticUpdate(e,n){this.optimisticUpdates.push({update:e,mutationId:n});const r=new lt(this.queryResults);return e(r),r.modifiedQueries}rawQueryResult(e){const n=this.queryResults.get(e);if(n!==void 0)return n.result}queryResult(e){const n=this.queryResults.get(e);if(n===void 0)return;const r=n.result;if(r!==void 0){if(r.success)return r.value;throw r.errorData!==void 0?yn(r,new At(Ue("query",n.udfPath,r))):new Error(Ue("query",n.udfPath,r))}}hasQueryResult(e){return this.queryResults.get(e)!==void 0}queryLogs(e){return this.queryResults.get(e)?.result?.logLines}}var na=Object.defineProperty,ra=(t,e,n)=>e in t?na(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,kn=(t,e,n)=>ra(t,typeof e!="symbol"?e+"":e,n);class Q{constructor(e,n){kn(this,"low"),kn(this,"high"),kn(this,"__isUnsignedLong__"),this.low=e|0,this.high=n|0,this.__isUnsignedLong__=!0}static isLong(e){return(e&&e.__isUnsignedLong__)===!0}static fromBytesLE(e){return new Q(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24)}toBytesLE(){const e=this.high,n=this.low;return[n&255,n>>>8&255,n>>>16&255,n>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]}static fromNumber(e){return isNaN(e)||e<0?pi:e>=ia?oa:new Q(e%ct|0,e/ct|0)}toString(){return(BigInt(this.high)*BigInt(ct)+BigInt(this.low)).toString()}equals(e){return Q.isLong(e)||(e=Q.fromValue(e)),this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low}notEquals(e){return!this.equals(e)}comp(e){return Q.isLong(e)||(e=Q.fromValue(e)),this.equals(e)?0:e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1}lessThanOrEqual(e){return this.comp(e)<=0}static fromValue(e){return typeof e=="number"?Q.fromNumber(e):new Q(e.low,e.high)}}const pi=new Q(0,0),gi=65536,ct=gi*gi,ia=ct*ct,oa=new Q(-1,-1);var sa=Object.defineProperty,aa=(t,e,n)=>e in t?sa(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,It=(t,e,n)=>aa(t,typeof e!="symbol"?e+"":e,n);class mi{constructor(e,n){It(this,"version"),It(this,"remoteQuerySet"),It(this,"queryPath"),It(this,"logger"),this.version={querySet:0,ts:Q.fromNumber(0),identity:0},this.remoteQuerySet=new Map,this.queryPath=e,this.logger=n}transition(e){const n=e.startVersion;if(this.version.querySet!==n.querySet||this.version.ts.notEquals(n.ts)||this.version.identity!==n.identity)throw new Error(`Invalid start version: ${n.ts.toString()}:${n.querySet}:${n.identity}, transitioning from ${this.version.ts.toString()}:${this.version.querySet}:${this.version.identity}`);for(const r of e.modifications)switch(r.type){case"QueryUpdated":{const i=this.queryPath(r.queryId);if(i)for(const s of r.logLines)$t(this.logger,"info","query",i,s);const o=De(r.value??null);this.remoteQuerySet.set(r.queryId,{success:!0,value:o,logLines:r.logLines});break}case"QueryFailed":{const i=this.queryPath(r.queryId);if(i)for(const s of r.logLines)$t(this.logger,"info","query",i,s);const{errorData:o}=r;this.remoteQuerySet.set(r.queryId,{success:!1,errorMessage:r.errorMessage,errorData:o!==void 0?De(o):void 0,logLines:r.logLines});break}case"QueryRemoved":{this.remoteQuerySet.delete(r.queryId);break}default:throw new Error(`Invalid modification ${r.type}`)}this.version=e.endVersion}remoteQueryResults(){return this.remoteQuerySet}timestamp(){return this.version.ts}}function _n(t){const e=it(t);return Q.fromBytesLE(Array.from(e))}function la(t){const e=new Uint8Array(t.toBytesLE());return ot(e)}function xi(t){switch(t.type){case"FatalError":case"AuthError":case"ActionResponse":case"TransitionChunk":case"Ping":return{...t};case"MutationResponse":return t.success?{...t,ts:_n(t.ts)}:{...t};case"Transition":return{...t,startVersion:{...t.startVersion,ts:_n(t.startVersion.ts)},endVersion:{...t.endVersion,ts:_n(t.endVersion.ts)}}}}function ca(t){switch(t.type){case"Authenticate":case"ModifyQuerySet":case"Mutation":case"Action":case"Event":return{...t};case"Connect":return t.maxObservedTimestamp!==void 0?{...t,maxObservedTimestamp:la(t.maxObservedTimestamp)}:{...t,maxObservedTimestamp:void 0}}}var ua=Object.defineProperty,da=(t,e,n)=>e in t?ua(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,P=(t,e,n)=>da(t,typeof e!="symbol"?e+"":e,n);const ha=1e3,fa=1001,pa=1005,ga=4040;let qt;function Fe(){return qt===void 0&&(qt=Date.now()),typeof performance>"u"||!performance.now?Date.now():Math.round(qt+performance.now())}function bi(){return`t=${Math.round((Fe()-qt)/100)/10}s`}const vi={InternalServerError:{timeout:1e3},SubscriptionsWorkerFullError:{timeout:3e3},TooManyConcurrentRequests:{timeout:3e3},CommitterFullError:{timeout:3e3},AwsTooManyRequestsException:{timeout:3e3},ExecuteFullError:{timeout:3e3},SystemTimeoutError:{timeout:3e3},ExpiredInQueue:{timeout:3e3},VectorIndexesUnavailable:{timeout:1e3},SearchIndexesUnavailable:{timeout:1e3},TableSummariesUnavailable:{timeout:1e3},VectorIndexTooLarge:{timeout:3e3},SearchIndexTooLarge:{timeout:3e3},TooManyWritesInTimePeriod:{timeout:3e3}};function ma(t){if(t===void 0)return"Unknown";for(const e of Object.keys(vi))if(t.startsWith(e))return e;return"Unknown"}class xa{constructor(e,n,r,i,o,s){this.markConnectionStateDirty=o,this.debug=s,P(this,"socket"),P(this,"connectionCount"),P(this,"_hasEverConnected",!1),P(this,"lastCloseReason"),P(this,"transitionChunkBuffer",null),P(this,"defaultInitialBackoff"),P(this,"maxBackoff"),P(this,"retries"),P(this,"serverInactivityThreshold"),P(this,"reconnectDueToServerInactivityTimeout"),P(this,"scheduledReconnect",null),P(this,"networkOnlineHandler",null),P(this,"pendingNetworkRecoveryInfo",null),P(this,"uri"),P(this,"onOpen"),P(this,"onResume"),P(this,"onMessage"),P(this,"webSocketConstructor"),P(this,"logger"),P(this,"onServerDisconnectError"),this.webSocketConstructor=r,this.socket={state:"disconnected"},this.connectionCount=0,this.lastCloseReason="InitialConnect",this.defaultInitialBackoff=1e3,this.maxBackoff=16e3,this.retries=0,this.serverInactivityThreshold=6e4,this.reconnectDueToServerInactivityTimeout=null,this.uri=e,this.onOpen=n.onOpen,this.onResume=n.onResume,this.onMessage=n.onMessage,this.onServerDisconnectError=n.onServerDisconnectError,this.logger=i,this.setupNetworkListener(),this.connect()}setSocketState(e){this.socket=e,this._logVerbose(`socket state changed: ${this.socket.state}, paused: ${"paused"in this.socket?this.socket.paused:void 0}`),this.markConnectionStateDirty()}setupNetworkListener(){typeof window>"u"||typeof window.addEventListener!="function"||this.networkOnlineHandler===null&&(this.networkOnlineHandler=()=>{this._logVerbose("network online event detected"),this.tryReconnectImmediately()},window.addEventListener("online",this.networkOnlineHandler),this._logVerbose("network online event listener registered"))}cleanupNetworkListener(){this.networkOnlineHandler&&typeof window<"u"&&typeof window.removeEventListener=="function"&&(window.removeEventListener("online",this.networkOnlineHandler),this.networkOnlineHandler=null,this._logVerbose("network online event listener removed"))}assembleTransition(e){if(e.partNumber<0||e.partNumber>=e.totalParts||e.totalParts===0||this.transitionChunkBuffer&&(this.transitionChunkBuffer.totalParts!==e.totalParts||this.transitionChunkBuffer.transitionId!==e.transitionId))throw this.transitionChunkBuffer=null,new Error("Invalid TransitionChunk");if(this.transitionChunkBuffer===null&&(this.transitionChunkBuffer={chunks:[],totalParts:e.totalParts,transitionId:e.transitionId}),e.partNumber!==this.transitionChunkBuffer.chunks.length){const n=this.transitionChunkBuffer.chunks.length;throw this.transitionChunkBuffer=null,new Error(`TransitionChunk received out of order: expected part ${n}, got ${e.partNumber}`)}if(this.transitionChunkBuffer.chunks.push(e.chunk),this.transitionChunkBuffer.chunks.length===e.totalParts){const n=this.transitionChunkBuffer.chunks.join("");this.transitionChunkBuffer=null;const r=xi(JSON.parse(n));if(r.type!=="Transition")throw new Error(`Expected Transition, got ${r.type} after assembling chunks`);return r}return null}connect(){if(this.socket.state==="terminated")return;if(this.socket.state!=="disconnected"&&this.socket.state!=="stopped")throw new Error("Didn't start connection from disconnected state: "+this.socket.state);const e=new this.webSocketConstructor(this.uri);this._logVerbose("constructed WebSocket"),this.setSocketState({state:"connecting",ws:e,paused:"no"}),this.resetServerInactivityTimeout(),e.onopen=()=>{if(this.logger.logVerbose("begin ws.onopen"),this.socket.state!=="connecting")throw new Error("onopen called with socket not in connecting state");if(this.setSocketState({state:"ready",ws:e,paused:this.socket.paused==="yes"?"uninitialized":"no"}),this.resetServerInactivityTimeout(),this.socket.paused==="no"&&(this._hasEverConnected=!0,this.onOpen({connectionCount:this.connectionCount,lastCloseReason:this.lastCloseReason,clientTs:Fe()})),this.lastCloseReason!=="InitialConnect"&&(this.lastCloseReason?this.logger.log("WebSocket reconnected at",bi(),"after disconnect due to",this.lastCloseReason):this.logger.log("WebSocket reconnected at",bi())),this.connectionCount+=1,this.lastCloseReason=null,this.pendingNetworkRecoveryInfo!==null){const{timeSavedMs:n}=this.pendingNetworkRecoveryInfo;this.pendingNetworkRecoveryInfo=null,this.sendMessage({type:"Event",eventType:"NetworkRecoveryReconnect",event:{timeSavedMs:n}}),this.logger.log(`Network recovery reconnect saved ~${Math.round(n/1e3)}s of waiting`)}},e.onerror=n=>{this.transitionChunkBuffer=null;const r=n.message;r&&this.logger.log(`WebSocket error message: ${r}`)},e.onmessage=n=>{this.resetServerInactivityTimeout();const r=n.data.length;let i=xi(JSON.parse(n.data));if(this._logVerbose(`received ws message with type ${i.type}`),i.type==="Ping")return;if(i.type==="TransitionChunk"){const s=this.assembleTransition(i);if(!s)return;i=s,this._logVerbose(`assembled full ws message of type ${i.type}`)}this.transitionChunkBuffer!==null&&(this.transitionChunkBuffer=null,this.logger.log(`Received unexpected ${i.type} while buffering TransitionChunks`)),i.type==="Transition"&&this.reportLargeTransition({messageLength:r,transition:i}),this.onMessage(i).hasSyncedPastLastReconnect&&(this.retries=0,this.markConnectionStateDirty())},e.onclose=n=>{if(this._logVerbose("begin ws.onclose"),this.transitionChunkBuffer=null,this.lastCloseReason===null&&(this.lastCloseReason=n.reason||`closed with code ${n.code}`),n.code!==ha&&n.code!==fa&&n.code!==pa&&n.code!==ga){let i=`WebSocket closed with code ${n.code}`;n.reason&&(i+=`: ${n.reason}`),this.logger.log(i),this.onServerDisconnectError&&n.reason&&this.onServerDisconnectError(i)}const r=ma(n.reason);this.scheduleReconnect(r)}}socketState(){return this.socket.state}sendMessage(e){const n={type:e.type,...e.type==="Authenticate"&&e.tokenType==="User"?{value:`...${e.value.slice(-7)}`}:{}};if(this.socket.state==="ready"&&this.socket.paused==="no"){const r=ca(e),i=JSON.stringify(r);let o=!1;try{this.socket.ws.send(i),o=!0}catch(s){this.logger.log(`Failed to send message on WebSocket, reconnecting: ${s}`),this.closeAndReconnect("FailedToSendMessage")}return this._logVerbose(`${o?"sent":"failed to send"} message with type ${e.type}: ${JSON.stringify(n)}`),!0}return this._logVerbose(`message not sent (socket state: ${this.socket.state}, paused: ${"paused"in this.socket?this.socket.paused:void 0}): ${JSON.stringify(n)}`),!1}resetServerInactivityTimeout(){this.socket.state!=="terminated"&&(this.reconnectDueToServerInactivityTimeout!==null&&(clearTimeout(this.reconnectDueToServerInactivityTimeout),this.reconnectDueToServerInactivityTimeout=null),this.reconnectDueToServerInactivityTimeout=setTimeout(()=>{this.closeAndReconnect("InactiveServer")},this.serverInactivityThreshold))}scheduleReconnect(e){this.scheduledReconnect&&(clearTimeout(this.scheduledReconnect.timeout),this.scheduledReconnect=null),this.socket={state:"disconnected"};const n=this.nextBackoff(e);this.markConnectionStateDirty(),this.logger.log(`Attempting reconnect in ${Math.round(n)}ms`);const r=Fe(),i=setTimeout(()=>{this.scheduledReconnect?.timeout===i&&(this.scheduledReconnect=null,this.connect())},n);this.scheduledReconnect={timeout:i,scheduledAt:r,backoffMs:n}}closeAndReconnect(e){switch(this._logVerbose(`begin closeAndReconnect with reason ${e}`),this.socket.state){case"disconnected":case"terminated":case"stopped":return;case"connecting":case"ready":{this.lastCloseReason=e,this.close(),this.scheduleReconnect("client");return}default:this.socket}}close(){switch(this.transitionChunkBuffer=null,this.socket.state){case"disconnected":case"terminated":case"stopped":return Promise.resolve();case"connecting":{const e=this.socket.ws;return e.onmessage=n=>{this._logVerbose("Ignoring message received after close")},new Promise(n=>{e.onclose=()=>{this._logVerbose("Closed after connecting"),n()},e.onopen=()=>{this._logVerbose("Opened after connecting"),e.close()}})}case"ready":{this._logVerbose("ws.close called");const e=this.socket.ws;e.onmessage=r=>{this._logVerbose("Ignoring message received after close")};const n=new Promise(r=>{e.onclose=()=>{r()}});return e.close(),n}default:return this.socket,Promise.resolve()}}terminate(){switch(this.reconnectDueToServerInactivityTimeout&&clearTimeout(this.reconnectDueToServerInactivityTimeout),this.scheduledReconnect&&(clearTimeout(this.scheduledReconnect.timeout),this.scheduledReconnect=null),this.cleanupNetworkListener(),this.socket.state){case"terminated":case"stopped":case"disconnected":case"connecting":case"ready":{const e=this.close();return this.setSocketState({state:"terminated"}),e}default:throw this.socket,new Error(`Invalid websocket state: ${this.socket.state}`)}}stop(){switch(this.socket.state){case"terminated":return Promise.resolve();case"connecting":case"stopped":case"disconnected":case"ready":{this.cleanupNetworkListener();const e=this.close();return this.socket={state:"stopped"},e}default:return this.socket,Promise.resolve()}}tryRestart(){switch(this.socket.state){case"stopped":break;case"terminated":case"connecting":case"ready":case"disconnected":this.logger.logVerbose("Restart called without stopping first");return;default:this.socket}this.setupNetworkListener(),this.connect()}pause(){switch(this.socket.state){case"disconnected":case"stopped":case"terminated":return;case"connecting":case"ready":{this.socket={...this.socket,paused:"yes"};return}default:{this.socket;return}}}tryReconnectImmediately(){if(this._logVerbose("tryReconnectImmediately called"),this.socket.state!=="disconnected"){this._logVerbose(`tryReconnectImmediately called but socket state is ${this.socket.state}, no action taken`);return}let e=null;if(this.scheduledReconnect){const n=Fe()-this.scheduledReconnect.scheduledAt;e=Math.max(0,this.scheduledReconnect.backoffMs-n),this._logVerbose(`would have waited ${Math.round(e)}ms more (backoff was ${Math.round(this.scheduledReconnect.backoffMs)}ms, elapsed ${Math.round(n)}ms)`),clearTimeout(this.scheduledReconnect.timeout),this.scheduledReconnect=null,this._logVerbose("canceled scheduled reconnect")}this.logger.log("Network recovery detected, reconnecting immediately"),this.pendingNetworkRecoveryInfo=e!==null?{timeSavedMs:e}:null,this.connect()}resume(){switch(this.socket.state){case"connecting":this.socket={...this.socket,paused:"no"};return;case"ready":this.socket.paused==="uninitialized"?(this.socket={...this.socket,paused:"no"},this._hasEverConnected=!0,this.onOpen({connectionCount:this.connectionCount,lastCloseReason:this.lastCloseReason,clientTs:Fe()})):this.socket.paused==="yes"&&(this.socket={...this.socket,paused:"no"},this.onResume());return;case"terminated":case"stopped":case"disconnected":return;default:this.socket}this.connect()}connectionState(){return{isConnected:this.socket.state==="ready",hasEverConnected:this._hasEverConnected,connectionCount:this.connectionCount,connectionRetries:this.retries}}_logVerbose(e){this.logger.logVerbose(e)}nextBackoff(e){const r=(e==="client"?100:e==="Unknown"?this.defaultInitialBackoff:vi[e].timeout)*Math.pow(2,this.retries);this.retries+=1;const i=Math.min(r,this.maxBackoff),o=i*(Math.random()-.5);return i+o}reportLargeTransition({transition:e,messageLength:n}){if(e.clientClockSkew===void 0||e.serverTs===void 0)return;const r=Fe()-e.clientClockSkew-e.serverTs/1e6,i=`${Math.round(r)}ms`,o=`${Math.round(n/1e4)/100}MB`,s=n/(r/1e3),a=`${Math.round(s/1e4)/100}MB per second`;this._logVerbose(`received ${o} transition in ${i} at ${a}`),n>2e7?this.logger.log(`received query results totaling more that 20MB (${o}) which will take a long time to download on slower connections`):r>2e4&&this.logger.log(`received query results totaling ${o} which took more than 20s to arrive (${i})`),this.debug&&this.sendMessage({type:"Event",eventType:"ClientReceivedTransition",event:{transitionTransitTime:r,messageLength:n}})}}function ba(){return va()}function va(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}class ut extends Error{}ut.prototype.name="InvalidTokenError";function ya(t){return decodeURIComponent(atob(t).replace(/(.)/g,(e,n)=>{let r=n.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r}))}function wa(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return ya(e)}catch{return atob(e)}}function yi(t,e){if(typeof t!="string")throw new ut("Invalid token specified: must be a string");e||(e={});const n=e.header===!0?0:1,r=t.split(".")[n];if(typeof r!="string")throw new ut(`Invalid token specified: missing part #${n+1}`);let i;try{i=wa(r)}catch(o){throw new ut(`Invalid token specified: invalid base64 for part #${n+1} (${o.message})`)}try{return JSON.parse(i)}catch(o){throw new ut(`Invalid token specified: invalid json for part #${n+1} (${o.message})`)}}var ka=Object.defineProperty,_a=(t,e,n)=>e in t?ka(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,H=(t,e,n)=>_a(t,typeof e!="symbol"?e+"":e,n);const ja=480*60*60*1e3,wi=2;class Sa{constructor(e,n,r){H(this,"authState",{state:"noAuth"}),H(this,"configVersion",0),H(this,"syncState"),H(this,"authenticate"),H(this,"stopSocket"),H(this,"tryRestartSocket"),H(this,"pauseSocket"),H(this,"resumeSocket"),H(this,"clearAuth"),H(this,"logger"),H(this,"refreshTokenLeewaySeconds"),H(this,"lastRefreshChange"),H(this,"tokenConfirmationAttempts",0),this.syncState=e,this.authenticate=n.authenticate,this.stopSocket=n.stopSocket,this.tryRestartSocket=n.tryRestartSocket,this.pauseSocket=n.pauseSocket,this.resumeSocket=n.resumeSocket,this.clearAuth=n.clearAuth,this.logger=r.logger,this.refreshTokenLeewaySeconds=r.refreshTokenLeewaySeconds,this.lastRefreshChange=!1}notifyRefreshChange(e){this.authState.state!=="noAuth"&&this.authState.state!=="initialRefetch"&&this.authState.config.onRefreshChange&&this.lastRefreshChange!==e&&(this.lastRefreshChange=e,this.authState.config.onRefreshChange(e))}async setConfig(e,n,r){this.resetAuthState(),this._logVerbose("pausing WS for auth token fetch"),this.pauseSocket();const i=await this.fetchTokenAndGuardAgainstRace(e,{forceRefreshToken:!1});if(i.isFromOutdatedConfig)return;const o={fetchToken:e,onAuthChange:n,onRefreshChange:r};i.value?(this.setAuthState({state:"waitingForServerConfirmationOfCachedToken",config:o,hasRetried:!1}),this.authenticate(i.value)):(this.setAuthState({state:"initialRefetch",config:o}),await this.refetchToken()),this._logVerbose("resuming WS after auth token fetch"),this.resumeSocket()}onTransition(e){if(this.syncState.isCurrentOrNewerAuthVersion(e.endVersion.identity)&&!(e.endVersion.identity<=e.startVersion.identity)){if(this._logVerbose(`auth state is ${this.authState.state} when handling transition`),this.syncState.markAuthCompletion(),this.authState.state==="waitingForServerConfirmationOfCachedToken"){this._logVerbose("server confirmed auth token is valid"),this.refetchToken(),this.authState.config.onAuthChange(!0);return}this.authState.state==="waitingForServerConfirmationOfFreshToken"&&(this._logVerbose("server confirmed new auth token is valid"),this.notifyRefreshChange(!1),this.scheduleTokenRefetch(this.authState.token),this.tokenConfirmationAttempts=0,this.authState.hadAuth||this.authState.config.onAuthChange(!0))}}onAuthError(e){if(e.authUpdateAttempted===!1&&(this.authState.state==="waitingForServerConfirmationOfFreshToken"||this.authState.state==="waitingForServerConfirmationOfCachedToken")){this._logVerbose("ignoring non-auth token expired error");return}const{baseVersion:n}=e;if(!this.syncState.isCurrentOrNewerAuthVersion(n+1)){this._logVerbose("ignoring auth error for previous auth attempt");return}this.tryToReauthenticate(e)}async tryToReauthenticate(e){if(this._logVerbose(`attempting to reauthenticate: ${e.error}`),this.authState.state==="noAuth"||this.authState.state==="waitingForServerConfirmationOfFreshToken"&&this.tokenConfirmationAttempts>=wi){this.logger.error(`Failed to authenticate: "${e.error}", check your server auth config`),this.syncState.hasAuth()&&this.syncState.clearAuth(),this.authState.state!=="noAuth"&&this.setAndReportAuthFailed(this.authState.config.onAuthChange);return}if(this.authState.state==="waitingForServerConfirmationOfFreshToken"&&(this.tokenConfirmationAttempts++,this._logVerbose(`retrying reauthentication, ${wi-this.tokenConfirmationAttempts} attempts remaining`)),this.notifyRefreshChange(!0),await this.stopSocket(),this.authState.state==="noAuth")return;const n=await this.fetchTokenAndGuardAgainstRace(this.authState.config.fetchToken,{forceRefreshToken:!0});n.isFromOutdatedConfig||(n.value&&this.syncState.isNewAuth(n.value)?(this.authenticate(n.value),this.setAuthState({state:"waitingForServerConfirmationOfFreshToken",config:this.authState.config,token:n.value,hadAuth:this.authState.state==="notRefetching"||this.authState.state==="waitingForScheduledRefetch"})):(this._logVerbose("reauthentication failed, could not fetch a new token"),this.syncState.hasAuth()&&this.syncState.clearAuth(),this.setAndReportAuthFailed(this.authState.config.onAuthChange)),this.tryRestartSocket())}async refetchToken(){if(this.authState.state==="noAuth")return;this._logVerbose("refetching auth token");const e=await this.fetchTokenAndGuardAgainstRace(this.authState.config.fetchToken,{forceRefreshToken:!0});e.isFromOutdatedConfig||(e.value?this.syncState.isNewAuth(e.value)?(this.setAuthState({state:"waitingForServerConfirmationOfFreshToken",hadAuth:this.syncState.hasAuth(),token:e.value,config:this.authState.config}),this.authenticate(e.value)):this.setAuthState({state:"notRefetching",config:this.authState.config}):(this._logVerbose("refetching token failed"),this.syncState.hasAuth()&&this.clearAuth(),this.setAndReportAuthFailed(this.authState.config.onAuthChange)),this._logVerbose("restarting WS after auth token fetch (if currently stopped)"),this.tryRestartSocket())}scheduleTokenRefetch(e){if(this.authState.state==="noAuth")return;const n=this.decodeToken(e);if(!n){this.logger.error("Auth token is not a valid JWT, cannot refetch the token");return}const{iat:r,exp:i}=n;if(!r||!i){this.logger.error("Auth token does not have required fields, cannot refetch the token");return}const o=i-r;if(o<=2){this.logger.error("Auth token does not live long enough, cannot refetch the token");return}let s=Math.min(ja,(o-this.refreshTokenLeewaySeconds)*1e3);s<=0&&(this.logger.warn(`Refetching auth token immediately, configured leeway ${this.refreshTokenLeewaySeconds}s is larger than the token's lifetime ${o}s`),s=0);const a=setTimeout(()=>{this._logVerbose("running scheduled token refetch"),this.refetchToken()},s);this.setAuthState({state:"waitingForScheduledRefetch",refetchTokenTimeoutId:a,config:this.authState.config}),this._logVerbose(`scheduled preemptive auth token refetching in ${s}ms`)}async fetchTokenAndGuardAgainstRace(e,n){const r=++this.configVersion;this._logVerbose(`fetching token with config version ${r}`);const i=await e(n);return this.configVersion!==r?(this._logVerbose(`stale config version, expected ${r}, got ${this.configVersion}`),{isFromOutdatedConfig:!0}):{isFromOutdatedConfig:!1,value:i}}stop(){this.resetAuthState(),this.configVersion++,this._logVerbose(`config version bumped to ${this.configVersion}`)}setAndReportAuthFailed(e){e(!1),this.resetAuthState()}resetAuthState(){this.notifyRefreshChange(!1),this.setAuthState({state:"noAuth"})}setAuthState(e){const n=e.state==="waitingForServerConfirmationOfFreshToken"?{hadAuth:e.hadAuth,state:e.state,token:`...${e.token.slice(-7)}`}:{state:e.state};switch(this._logVerbose(`setting auth state to ${JSON.stringify(n)}`),e.state){case"waitingForScheduledRefetch":case"notRefetching":case"noAuth":this.tokenConfirmationAttempts=0;break}this.authState.state==="waitingForScheduledRefetch"&&clearTimeout(this.authState.refetchTokenTimeoutId),this.authState=e}decodeToken(e){try{return yi(e)}catch(n){return this._logVerbose(`Error decoding token: ${n instanceof Error?n.message:"Unknown error"}`),null}}_logVerbose(e){this.logger.logVerbose(`${e} [v${this.configVersion}]`)}}const Ca=["convexClientConstructed","convexWebSocketOpen","convexFirstMessageReceived"];function Ta(t,e){const n={sessionId:e};typeof performance>"u"||!performance.mark||performance.mark(t,{detail:n})}function Ra(t){let e=t.name.slice(6);return e=e.charAt(0).toLowerCase()+e.slice(1),{name:e,startTime:t.startTime}}function Aa(t){if(typeof performance>"u"||!performance.getEntriesByName)return[];const e=[];for(const n of Ca){const r=performance.getEntriesByName(n).filter(i=>i.entryType==="mark").filter(i=>i.detail.sessionId===t);e.push(...r)}return e.map(Ra)}var $a=Object.defineProperty,Ea=(t,e,n)=>e in t?$a(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,I=(t,e,n)=>Ea(t,typeof e!="symbol"?e+"":e,n);class Pa{constructor(e,n,r){if(I(this,"address"),I(this,"state"),I(this,"requestManager"),I(this,"webSocketManager"),I(this,"authenticationManager"),I(this,"remoteQuerySet"),I(this,"optimisticQueryResults"),I(this,"_transitionHandlerCounter",0),I(this,"_nextRequestId"),I(this,"_onTransitionFns",new Map),I(this,"_sessionId"),I(this,"firstMessageReceived",!1),I(this,"debug"),I(this,"logger"),I(this,"maxObservedTimestamp"),I(this,"connectionStateSubscribers",new Map),I(this,"nextConnectionStateSubscriberId",0),I(this,"_lastPublishedConnectionState"),I(this,"markConnectionStateDirty",()=>{Promise.resolve().then(()=>{const p=this.connectionState();if(JSON.stringify(p)!==JSON.stringify(this._lastPublishedConnectionState)){this._lastPublishedConnectionState=p;for(const g of this.connectionStateSubscribers.values())g(p)}})}),I(this,"mark",p=>{this.debug&&Ta(p,this.sessionId)}),typeof e=="object")throw new Error("Passing a ClientConfig object is no longer supported. Pass the URL of the Convex deployment as a string directly.");r?.skipConvexDeploymentUrlCheck!==!0&&Ts(e),r={...r};const i=r.authRefreshTokenLeewaySeconds??10;let o=r.webSocketConstructor;if(!o&&typeof WebSocket>"u")throw new Error("No WebSocket global variable defined! To use Convex in an environment without WebSocket try the HTTP client: https://docs.convex.dev/api/classes/browser.ConvexHttpClient");o=o||WebSocket,this.debug=r.reportDebugInfoToConvex??!1,this.address=e,this.logger=r.logger===!1?ui({verbose:r.verbose??!1}):r.logger!==!0&&r.logger?r.logger:ci({verbose:r.verbose??!1});const s=e.search("://");if(s===-1)throw new Error("Provided address was not an absolute URL.");const a=e.substring(s+3),c=e.substring(0,s);let u;if(c==="http")u="ws";else if(c==="https")u="wss";else throw new Error(`Unknown parent protocol ${c}`);const h=`${u}://${a}/api/${oi}/sync`;this.state=new Vs,this.remoteQuerySet=new mi(p=>this.state.queryPath(p),this.logger),this.requestManager=new Gs(this.logger,this.markConnectionStateDirty);const d=()=>{this.webSocketManager.pause(),this.state.pause()};this.authenticationManager=new Sa(this.state,{authenticate:p=>{const g=this.state.setAuth(p);return this.webSocketManager.sendMessage(g),g.baseVersion},stopSocket:()=>this.webSocketManager.stop(),tryRestartSocket:()=>this.webSocketManager.tryRestart(),pauseSocket:d,resumeSocket:()=>this.webSocketManager.resume(),clearAuth:()=>{this.clearAuth()}},{logger:this.logger,refreshTokenLeewaySeconds:i}),this.optimisticQueryResults=new ta,this.addOnTransitionHandler(p=>{n(p.queries.map(g=>g.token))}),this._nextRequestId=0,this._sessionId=ba();const{unsavedChangesWarning:f}=r;if(typeof window>"u"||typeof window.addEventListener>"u"){if(f===!0)throw new Error("unsavedChangesWarning requested, but window.addEventListener not found! Remove {unsavedChangesWarning: true} from Convex client options.")}else f!==!1&&window.addEventListener("beforeunload",p=>{if(this.requestManager.hasIncompleteRequests()){p.preventDefault();const g="Are you sure you want to leave? Your changes may not be saved.";return(p||window.event).returnValue=g,g}});this.webSocketManager=new xa(h,{onOpen:p=>{this.mark("convexWebSocketOpen"),this.webSocketManager.sendMessage({...p,type:"Connect",sessionId:this._sessionId,maxObservedTimestamp:this.maxObservedTimestamp}),this.remoteQuerySet=new mi(v=>this.state.queryPath(v),this.logger);const[g,x]=this.state.restart();x&&this.webSocketManager.sendMessage(x),this.webSocketManager.sendMessage(g);for(const v of this.requestManager.restart())this.webSocketManager.sendMessage(v)},onResume:()=>{const[p,g]=this.state.resume();g&&this.webSocketManager.sendMessage(g),p&&this.webSocketManager.sendMessage(p);for(const x of this.requestManager.resume())this.webSocketManager.sendMessage(x)},onMessage:p=>{switch(this.firstMessageReceived||(this.firstMessageReceived=!0,this.mark("convexFirstMessageReceived"),this.reportMarks()),p.type){case"Transition":{this.observedTimestamp(p.endVersion.ts),this.authenticationManager.onTransition(p),this.remoteQuerySet.transition(p),this.state.transition(p);const g=this.requestManager.removeCompleted(this.remoteQuerySet.timestamp());this.notifyOnQueryResultChanges(g);break}case"MutationResponse":{p.success&&this.observedTimestamp(p.ts);const g=this.requestManager.onResponse(p);g!==null&&this.notifyOnQueryResultChanges(new Map([[g.requestId,g.result]]));break}case"ActionResponse":{this.requestManager.onResponse(p);break}case"AuthError":{this.authenticationManager.onAuthError(p);break}case"FatalError":{const g=Us(this.logger,p.error);throw this.webSocketManager.terminate(),g}}return{hasSyncedPastLastReconnect:this.hasSyncedPastLastReconnect()}},onServerDisconnectError:r.onServerDisconnectError},o,this.logger,this.markConnectionStateDirty,this.debug),this.mark("convexClientConstructed"),r.expectAuth&&d()}hasSyncedPastLastReconnect(){return this.requestManager.hasSyncedPastLastReconnect()&&this.state.hasSyncedPastLastReconnect()}observedTimestamp(e){(this.maxObservedTimestamp===void 0||this.maxObservedTimestamp.lessThanOrEqual(e))&&(this.maxObservedTimestamp=e)}getMaxObservedTimestamp(){return this.maxObservedTimestamp}notifyOnQueryResultChanges(e){const n=this.remoteQuerySet.remoteQueryResults(),r=new Map;for(const[o,s]of n){const a=this.state.queryToken(o);if(a!==null){const c={result:s,udfPath:this.state.queryPath(o),args:this.state.queryArgs(o)};r.set(a,c)}}const i=this.optimisticQueryResults.ingestQueryResultsFromServer(r,new Set(e.keys()));this.handleTransition({queries:i.map(o=>{const s=this.optimisticQueryResults.rawQueryResult(o);return{token:o,modification:{kind:"Updated",result:s}}}),reflectedMutations:Array.from(e).map(([o,s])=>({requestId:o,result:s})),timestamp:this.remoteQuerySet.timestamp()})}handleTransition(e){for(const n of this._onTransitionFns.values())n(e)}addOnTransitionHandler(e){const n=this._transitionHandlerCounter++;return this._onTransitionFns.set(n,e),()=>this._onTransitionFns.delete(n)}getCurrentAuthClaims(){const e=this.state.getAuth();let n={};if(e&&e.tokenType==="User")try{n=e?yi(e.value):{}}catch{n={}}else return;return{token:e.value,decoded:n}}setAuth(e,n,r){this.authenticationManager.setConfig(e,n,r)}hasAuth(){return this.state.hasAuth()}setAdminAuth(e,n){const r=this.state.setAdminAuth(e,n);this.webSocketManager.sendMessage(r)}clearAuth(){const e=this.state.clearAuth();this.webSocketManager.sendMessage(e)}subscribe(e,n,r){const i=de(n),{modification:o,queryToken:s,unsubscribe:a}=this.state.subscribe(e,i,r?.journal,r?.componentPath);return o!==null&&this.webSocketManager.sendMessage(o),{queryToken:s,unsubscribe:()=>{const c=a();c&&this.webSocketManager.sendMessage(c)}}}localQueryResult(e,n){const r=de(n),i=Ce(e,r);return this.optimisticQueryResults.queryResult(i)}localQueryResultByToken(e){return this.optimisticQueryResults.queryResult(e)}hasLocalQueryResultByToken(e){return this.optimisticQueryResults.hasQueryResult(e)}localQueryLogs(e,n){const r=de(n),i=Ce(e,r);return this.optimisticQueryResults.queryLogs(i)}queryJournal(e,n){const r=de(n),i=Ce(e,r);return this.state.queryJournal(i)}connectionState(){const e=this.webSocketManager.connectionState();return{hasInflightRequests:this.requestManager.hasInflightRequests(),isWebSocketConnected:e.isConnected,hasEverConnected:e.hasEverConnected,connectionCount:e.connectionCount,connectionRetries:e.connectionRetries,timeOfOldestInflightRequest:this.requestManager.timeOfOldestInflightRequest(),inflightMutations:this.requestManager.inflightMutations(),inflightActions:this.requestManager.inflightActions()}}subscribeToConnectionState(e){const n=this.nextConnectionStateSubscriberId++;return this.connectionStateSubscribers.set(n,e),()=>{this.connectionStateSubscribers.delete(n)}}async mutation(e,n,r){const i=await this.mutationInternal(e,n,r);if(!i.success)throw i.errorData!==void 0?yn(i,new At(Ue("mutation",e,i))):new Error(Ue("mutation",e,i));return i.value}async mutationInternal(e,n,r,i){const{mutationPromise:o}=this.enqueueMutation(e,n,r,i);return o}enqueueMutation(e,n,r,i){const o=de(n);this.tryReportLongDisconnect();const s=this.nextRequestId;if(this._nextRequestId++,r!==void 0){const h=r.optimisticUpdate;if(h!==void 0){const d=g=>{h(g,o)instanceof Promise&&this.logger.warn("Optimistic update handler returned a Promise. Optimistic updates should be synchronous.")},p=this.optimisticQueryResults.applyOptimisticUpdate(d,s).map(g=>{const x=this.localQueryResultByToken(g);return{token:g,modification:{kind:"Updated",result:x===void 0?void 0:{success:!0,value:x,logLines:[]}}}});this.handleTransition({queries:p,reflectedMutations:[],timestamp:this.remoteQuerySet.timestamp()})}}const a={type:"Mutation",requestId:s,udfPath:e,componentPath:i,args:[se(o)]},c=this.webSocketManager.sendMessage(a),u=this.requestManager.request(a,c);return{requestId:s,mutationPromise:u}}async action(e,n){const r=await this.actionInternal(e,n);if(!r.success)throw r.errorData!==void 0?yn(r,new At(Ue("action",e,r))):new Error(Ue("action",e,r));return r.value}async actionInternal(e,n,r){const i=de(n),o=this.nextRequestId;this._nextRequestId++,this.tryReportLongDisconnect();const s={type:"Action",requestId:o,udfPath:e,componentPath:r,args:[se(i)]},a=this.webSocketManager.sendMessage(s);return this.requestManager.request(s,a)}async close(){return this.authenticationManager.stop(),this.webSocketManager.terminate()}get url(){return this.address}get nextRequestId(){return this._nextRequestId}get sessionId(){return this._sessionId}reportMarks(){if(this.debug){const e=Aa(this.sessionId);this.webSocketManager.sendMessage({type:"Event",eventType:"ClientConnect",event:e})}}tryReportLongDisconnect(){if(!this.debug)return;const e=this.connectionState().timeOfOldestInflightRequest;if(e===null||Date.now()-e.getTime()<=60*1e3)return;const n=`${this.address}/api/debug_event`;fetch(n,{method:"POST",headers:{"Content-Type":"application/json","Convex-Client":`npm-${oi}`},body:JSON.stringify({event:"LongWebsocketDisconnect"})}).then(r=>{r.ok||this.logger.warn("Analytics request failed with response:",r.body)}).catch(r=>{this.logger.warn("Analytics response failed with error:",r)})}}function jn(t){if(typeof t!="object"||t===null||!Array.isArray(t.page)||typeof t.isDone!="boolean"||typeof t.continueCursor!="string")throw new Error(`Not a valid paginated query result: ${t?.toString()}`);return t}var Ia=Object.defineProperty,qa=(t,e,n)=>e in t?Ia(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,ki=(t,e,n)=>qa(t,typeof e!="symbol"?e+"":e,n);class La{constructor(e,n){this.client=e,this.onTransition=n,ki(this,"paginatedQuerySet",new Map),ki(this,"lastTransitionTs"),this.lastTransitionTs=Q.fromNumber(0),this.client.addOnTransitionHandler(r=>this.onBaseTransition(r))}subscribe(e,n,r){const i=Se(e),o=di(i,n,r),s=()=>this.removePaginatedQuerySubscriber(o),a=this.paginatedQuerySet.get(o);return a?(a.numSubscribers+=1,{paginatedQueryToken:o,unsubscribe:s}):(this.paginatedQuerySet.set(o,{token:o,canonicalizedUdfPath:i,args:n,numSubscribers:1,options:{initialNumItems:r.initialNumItems},nextPageKey:0,pageKeys:[],pageKeyToQuery:new Map,ongoingSplits:new Map,skip:!1,id:r.id}),this.addPageToPaginatedQuery(o,null,r.initialNumItems),{paginatedQueryToken:o,unsubscribe:s})}localQueryResult(e,n,r){const i=Se(e),o=di(i,n,r);return this.localQueryResultByToken(o)}localQueryResultByToken(e){const n=this.paginatedQuerySet.get(e);if(!n)return;const r=this.activePageQueryTokens(n);if(r.length===0)return{results:[],status:"LoadingFirstPage",loadMore:c=>this.loadMoreOfPaginatedQuery(e,c)};let i=[],o=!1,s=!1;for(const c of r){const u=this.client.localQueryResultByToken(c);if(u===void 0){o=!0,s=!1;continue}const h=jn(u);i=i.concat(h.page),s=!!h.isDone}let a;return o?a=i.length===0?"LoadingFirstPage":"LoadingMore":s?a="Exhausted":a="CanLoadMore",{results:i,status:a,loadMore:c=>this.loadMoreOfPaginatedQuery(e,c)}}onBaseTransition(e){const n=e.queries.map(s=>s.token),r=this.queriesContainingTokens(n);let i=[];r.length>0&&(this.processPaginatedQuerySplits(r,s=>this.client.localQueryResultByToken(s)),i=r.map(s=>({token:s,modification:{kind:"Updated",result:this.localQueryResultByToken(s)}})));const o={...e,paginatedQueries:i};this.onTransition(o)}loadMoreOfPaginatedQuery(e,n){this.mustGetPaginatedQuery(e);const r=this.queryTokenForLastPageOfPaginatedQuery(e),i=this.client.localQueryResultByToken(r);if(!i)return!1;const o=jn(i);if(o.isDone)return!1;this.addPageToPaginatedQuery(e,o.continueCursor,n);const s={timestamp:this.lastTransitionTs,reflectedMutations:[],queries:[],paginatedQueries:[{token:e,modification:{kind:"Updated",result:this.localQueryResultByToken(e)}}]};return this.onTransition(s),!0}queriesContainingTokens(e){if(e.length===0)return[];const n=[],r=new Set(e);for(const[i,o]of this.paginatedQuerySet)for(const s of this.allQueryTokens(o))if(r.has(s)){n.push(i);break}return n}processPaginatedQuerySplits(e,n){for(const r of e){const i=this.mustGetPaginatedQuery(r),{ongoingSplits:o,pageKeyToQuery:s,pageKeys:a}=i;for(const[c,[u,h]]of o)n(s.get(u).queryToken)!==void 0&&n(s.get(h).queryToken)!==void 0&&this.completePaginatedQuerySplit(i,c,u,h);for(const c of a){if(o.has(c))continue;const u=s.get(c).queryToken,h=n(u);if(!h)continue;const d=jn(h);d.splitCursor&&(d.pageStatus==="SplitRecommended"||d.pageStatus==="SplitRequired"||d.page.length>i.options.initialNumItems*2)&&this.splitPaginatedQueryPage(i,c,d.splitCursor,d.continueCursor)}}}splitPaginatedQueryPage(e,n,r,i){const o=e.nextPageKey++,s=e.nextPageKey++,a={cursor:i,numItems:e.options.initialNumItems,id:e.id},c=this.client.subscribe(e.canonicalizedUdfPath,{...e.args,paginationOpts:{...a,cursor:null,endCursor:r}});e.pageKeyToQuery.set(o,c);const u=this.client.subscribe(e.canonicalizedUdfPath,{...e.args,paginationOpts:{...a,cursor:r,endCursor:i}});e.pageKeyToQuery.set(s,u),e.ongoingSplits.set(n,[o,s])}addPageToPaginatedQuery(e,n,r){const i=this.mustGetPaginatedQuery(e),o=i.nextPageKey++,s={cursor:n,numItems:r,id:i.id},a={...i.args,paginationOpts:s},c=this.client.subscribe(i.canonicalizedUdfPath,a);return i.pageKeys.push(o),i.pageKeyToQuery.set(o,c),c}removePaginatedQuerySubscriber(e){const n=this.paginatedQuerySet.get(e);if(n&&(n.numSubscribers-=1,!(n.numSubscribers>0))){for(const r of n.pageKeyToQuery.values())r.unsubscribe();this.paginatedQuerySet.delete(e)}}completePaginatedQuerySplit(e,n,r,i){const o=e.pageKeyToQuery.get(n);e.pageKeyToQuery.delete(n);const s=e.pageKeys.indexOf(n);e.pageKeys.splice(s,1,r,i),e.ongoingSplits.delete(n),o.unsubscribe()}activePageQueryTokens(e){return e.pageKeys.map(n=>e.pageKeyToQuery.get(n).queryToken)}allQueryTokens(e){return Array.from(e.pageKeyToQuery.values()).map(n=>n.queryToken)}queryTokenForLastPageOfPaginatedQuery(e){const n=this.mustGetPaginatedQuery(e),r=n.pageKeys[n.pageKeys.length-1];if(r===void 0)throw new Error(`No pages for paginated query ${e}`);return n.pageKeyToQuery.get(r).queryToken}mustGetPaginatedQuery(e){const n=this.paginatedQuerySet.get(e);if(!n)throw new Error("paginated query no longer exists for token "+e);return n}}function Ma({getCurrentValue:t,subscribe:e}){const[n,r]=C(()=>({getCurrentValue:t,subscribe:e,value:t()}));let i=n.value;return(n.getCurrentValue!==t||n.subscribe!==e)&&(i=t(),r({getCurrentValue:t,subscribe:e,value:i})),T(()=>{let o=!1;const s=()=>{o||r(c=>{if(c.getCurrentValue!==t||c.subscribe!==e)return c;const u=t();return c.value===u?c:{...c,value:u}})},a=e(s);return s(),()=>{o=!0,a()}},[t,e]),i}var Na=Object.defineProperty,za=(t,e,n)=>e in t?Na(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,he=(t,e,n)=>za(t,typeof e!="symbol"?e+"":e,n);const Oa=5e3;if(typeof fn>"u")throw new Error("Required dependency 'react' not found");function _i(t,e,n){function r(i){return Qa(i),e.mutation(t,i,{optimisticUpdate:n})}return r.withOptimisticUpdate=function(o){if(n!==void 0)throw new Error(`Already specified optimistic update for mutation ${U(t)}`);return _i(t,e,o)},r}function Ba(t,e){return function(n){return e.action(t,n)}}class Da{constructor(e,n){if(he(this,"address"),he(this,"cachedSync"),he(this,"cachedPaginatedQueryClient"),he(this,"listeners"),he(this,"options"),he(this,"closed",!1),he(this,"_logger"),he(this,"adminAuth"),he(this,"fakeUserIdentity"),e===void 0)throw new Error("No address provided to ConvexReactClient.\nIf trying to deploy to production, make sure to follow all the instructions found at https://docs.convex.dev/production/hosting/\nIf running locally, make sure to run `convex dev` and ensure the .env.local file is populated.");if(typeof e!="string")throw new Error(`ConvexReactClient requires a URL like 'https://happy-otter-123.convex.cloud', received something of type ${typeof e} instead.`);if(!e.includes("://"))throw new Error("Provided address was not an absolute URL.");this.address=e,this.listeners=new Map,this._logger=n?.logger===!1?ui({verbose:n?.verbose??!1}):n?.logger!==!0&&n?.logger?n.logger:ci({verbose:n?.verbose??!1}),this.options={...n,logger:this._logger}}get url(){return this.address}get sync(){if(this.closed)throw new Error("ConvexReactClient has already been closed.");return this.cachedSync?this.cachedSync:(this.cachedSync=new Pa(this.address,()=>{},this.options),this.adminAuth&&this.cachedSync.setAdminAuth(this.adminAuth,this.fakeUserIdentity),this.cachedPaginatedQueryClient=new La(this.cachedSync,e=>this.handleTransition(e)),this.cachedSync)}get paginatedQueryClient(){if(this.sync,this.cachedPaginatedQueryClient)return this.cachedPaginatedQueryClient;throw new Error("Should already be instantiated")}setAuth(e,n,r){if(typeof e=="string")throw new Error("Passing a string to ConvexReactClient.setAuth is no longer supported, please upgrade to passing in an async function to handle reauthentication.");this.sync.setAuth(e,n??(()=>{}),r)}clearAuth(){this.sync.clearAuth()}setAdminAuth(e,n){if(this.adminAuth=e,this.fakeUserIdentity=n,this.closed)throw new Error("ConvexReactClient has already been closed.");this.cachedSync&&this.sync.setAdminAuth(e,n)}watchQuery(e,...n){const[r,i]=n,o=U(e);return{onUpdate:s=>{const{queryToken:a,unsubscribe:c}=this.sync.subscribe(o,r,i),u=this.listeners.get(a);return u!==void 0?u.add(s):this.listeners.set(a,new Set([s])),()=>{if(this.closed)return;const h=this.listeners.get(a);h.delete(s),h.size===0&&this.listeners.delete(a),c()}},localQueryResult:()=>{if(this.cachedSync)return this.cachedSync.localQueryResult(o,r)},localQueryLogs:()=>{if(this.cachedSync)return this.cachedSync.localQueryLogs(o,r)},journal:()=>{if(this.cachedSync)return this.cachedSync.queryJournal(o,r)}}}prewarmQuery(e){const n=e.extendSubscriptionFor??Oa,i=this.watchQuery(e.query,e.args||{}).onUpdate(()=>{});setTimeout(i,n)}watchPaginatedQuery(e,n,r){const i=U(e);return{onUpdate:o=>{const{paginatedQueryToken:s,unsubscribe:a}=this.paginatedQueryClient.subscribe(i,n||{},r),c=this.listeners.get(s);return c!==void 0?c.add(o):this.listeners.set(s,new Set([o])),()=>{if(this.closed)return;const u=this.listeners.get(s);u.delete(o),u.size===0&&this.listeners.delete(s),a()}},localQueryResult:()=>this.paginatedQueryClient.localQueryResult(i,n,r)}}mutation(e,...n){const[r,i]=n,o=U(e);return this.sync.mutation(o,r,i)}action(e,...n){const r=U(e);return this.sync.action(r,...n)}query(e,...n){const r=this.watchQuery(e,...n),i=r.localQueryResult();return i!==void 0?Promise.resolve(i):new Promise((o,s)=>{const a=r.onUpdate(()=>{a();try{o(r.localQueryResult())}catch(c){s(c)}})})}connectionState(){return this.sync.connectionState()}subscribeToConnectionState(e){return this.sync.subscribeToConnectionState(e)}get logger(){return this._logger}async close(){if(this.closed=!0,this.listeners=new Map,this.cachedPaginatedQueryClient&&(this.cachedPaginatedQueryClient=void 0),this.cachedSync){const e=this.cachedSync;this.cachedSync=void 0,await e.close()}}handleTransition(e){const n=e.queries.map(i=>i.token),r=e.paginatedQueries.map(i=>i.token);this.transition([...n,...r])}transition(e){for(const n of e){const r=this.listeners.get(n);if(r)for(const i of r)i()}}}const Lt=fn.createContext(void 0);function Ua(){return nt(Lt)}const Fa=({client:t,children:e})=>fn.createElement(Lt.Provider,{value:t},e);function Sn(t,...e){const n=e[0]==="skip",r=e[0]==="skip"?{}:de(e[0]),i=typeof t=="string"?wn(t):t,o=U(i),s=D(()=>n?{}:{query:{query:i,args:r}},[JSON.stringify(se(r)),o,n]),c=Ga(s).query;if(c instanceof Error)throw c;return c}function dt(t){const e=typeof t=="string"?wn(t):t,n=nt(Lt);if(n===void 0)throw new Error("Could not find Convex client! `useMutation` must be used in the React component tree under `ConvexProvider`. Did you forget it? See https://docs.convex.dev/quick-start#set-up-convex-in-your-react-app");return D(()=>_i(e,n),[n,U(e)])}function ji(t){const e=nt(Lt),n=typeof t=="string"?wn(t):t;if(e===void 0)throw new Error("Could not find Convex client! `useAction` must be used in the React component tree under `ConvexProvider`. Did you forget it? See https://docs.convex.dev/quick-start#set-up-convex-in-your-react-app");return D(()=>Ba(n,e),[e,U(n)])}function Qa(t){if(typeof t=="object"&&t!==null&&"bubbles"in t&&"persist"in t&&"isDefaultPrevented"in t)throw new Error("Convex function called with SyntheticEvent object. Did you use a Convex function as an event handler directly? Event handlers like onClick receive an event object as their first argument. These SyntheticEvent objects are not valid Convex values. Try wrapping the function like `const handler = () => myMutation();` and using `handler` in the event handler.")}var Va=Object.defineProperty,Wa=(t,e,n)=>e in t?Va(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Cn=(t,e,n)=>Wa(t,typeof e!="symbol"?e+"":e,n);class Ha{constructor(e){Cn(this,"createWatch"),Cn(this,"queries"),Cn(this,"listeners"),this.createWatch=e,this.queries={},this.listeners=new Set}setQueries(e){for(const n of Object.keys(e)){const{query:r,args:i,paginationOptions:o}=e[n];if(U(r),this.queries[n]===void 0)this.addQuery(n,r,i,o?{paginationOptions:o}:{});else{const s=this.queries[n];(U(r)!==U(s.query)||JSON.stringify(se(i))!==JSON.stringify(se(s.args))||JSON.stringify(o)!==JSON.stringify(s.paginationOptions))&&(this.removeQuery(n),this.addQuery(n,r,i,o?{paginationOptions:o}:{}))}}for(const n of Object.keys(this.queries))e[n]===void 0&&this.removeQuery(n)}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}getLocalResults(e){const n={};for(const r of Object.keys(e)){const{query:i,args:o}=e[r],s=e[r].paginationOptions;U(i);const a=this.createWatch(i,o,s?{paginationOptions:s}:{});let c;try{c=a.localQueryResult()}catch(u){if(u instanceof Error)c=u;else throw u}n[r]=c}return n}setCreateWatch(e){this.createWatch=e;for(const n of Object.keys(this.queries)){const{query:r,args:i,watch:o,paginationOptions:s}=this.queries[n],a="journal"in o?o.journal():void 0;this.removeQuery(n),this.addQuery(n,r,i,{...a?{journal:a}:[],...s?{paginationOptions:s}:{}})}}destroy(){for(const e of Object.keys(this.queries))this.removeQuery(e);this.listeners=new Set}addQuery(e,n,r,{paginationOptions:i,journal:o}){if(this.queries[e]!==void 0)throw new Error(`Tried to add a new query with identifier ${e} when it already exists.`);const s=this.createWatch(n,r,{...o?{journal:o}:[],...i?{paginationOptions:i}:{}}),a=s.onUpdate(()=>this.notifyListeners());this.queries[e]={query:n,args:r,watch:s,unsubscribe:a,...i?{paginationOptions:i}:{}}}removeQuery(e){const n=this.queries[e];if(n===void 0)throw new Error(`No query found with identifier ${e}.`);n.unsubscribe(),delete this.queries[e]}notifyListeners(){for(const e of this.listeners)e()}}function Ga(t){const e=Ua();if(e===void 0)throw new Error("Could not find Convex client! `useQuery` must be used in the React component tree under `ConvexProvider`. Did you forget it? See https://docs.convex.dev/quick-start#set-up-convex-in-your-react-app");const n=D(()=>(r,i,{journal:o,paginationOptions:s})=>s?e.watchPaginatedQuery(r,i,s):e.watchQuery(r,i,o?{journal:o}:{}),[e]);return Ja(t,n)}function Ja(t,e){const[n]=C(()=>new Ha(e));n.createWatch!==e&&n.setCreateWatch(e),T(()=>()=>n.destroy(),[n]);const r=D(()=>({getCurrentValue:()=>n.getLocalResults(t),subscribe:i=>(n.setQueries(t),n.subscribe(i))}),[n,t]);return Ma(r)}var Ka=Symbol.for("preact-signals");function Mt(){if(xe>1)xe--;else{for(var t,e=!1;ht!==void 0;){var n=ht;for(ht=void 0,Tn++;n!==void 0;){var r=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&Ti(n))try{n.c()}catch(i){e||(t=i,e=!0)}n=r}}if(Tn=0,xe--,e)throw t}}function Za(t){if(xe>0)return t();xe++;try{return t()}finally{Mt()}}var k=void 0;function Si(t){var e=k;k=void 0;try{return t()}finally{k=e}}var ht=void 0,xe=0,Tn=0,Nt=0;function Ci(t){if(k!==void 0){var e=t.n;if(e===void 0||e.t!==k)return e={i:0,S:t,p:k.s,n:void 0,t:k,e:void 0,x:void 0,r:e},k.s!==void 0&&(k.s.n=e),k.s=e,t.n=e,32&k.f&&t.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=k.s,e.n=void 0,k.s.n=e,k.s=e),e}}function O(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}O.prototype.brand=Ka,O.prototype.h=function(){return!0},O.prototype.S=function(t){var e=this,n=this.t;n!==t&&t.e===void 0&&(t.x=n,this.t=t,n!==void 0?n.e=t:Si(function(){var r;(r=e.W)==null||r.call(e)}))},O.prototype.U=function(t){var e=this;if(this.t!==void 0){var n=t.e,r=t.x;n!==void 0&&(n.x=r,t.e=void 0),r!==void 0&&(r.e=n,t.x=void 0),t===this.t&&(this.t=r,r===void 0&&Si(function(){var i;(i=e.Z)==null||i.call(e)}))}},O.prototype.subscribe=function(t){var e=this;return ft(function(){var n=e.value,r=k;k=void 0;try{t(n)}finally{k=r}},{name:"sub"})},O.prototype.valueOf=function(){return this.value},O.prototype.toString=function(){return this.value+""},O.prototype.toJSON=function(){return this.value},O.prototype.peek=function(){var t=k;k=void 0;try{return this.value}finally{k=t}},Object.defineProperty(O.prototype,"value",{get:function(){var t=Ci(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(Tn>100)throw new Error("Cycle detected");this.v=t,this.i++,Nt++,xe++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{Mt()}}}});function $(t,e){return new O(t,e)}function Ti(t){for(var e=t.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function Ri(t){for(var e=t.s;e!==void 0;e=e.n){var n=e.S.n;if(n!==void 0&&(e.r=n),e.S.n=e,e.i=-1,e.n===void 0){t.s=e;break}}}function Ai(t){for(var e=t.s,n=void 0;e!==void 0;){var r=e.p;e.i===-1?(e.S.U(e),r!==void 0&&(r.n=e.n),e.n!==void 0&&(e.n.p=r)):n=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=r}t.s=n}function Te(t,e){O.call(this,void 0),this.x=t,this.s=void 0,this.g=Nt-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}Te.prototype=new O,Te.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Nt))return!0;if(this.g=Nt,this.f|=1,this.i>0&&!Ti(this))return this.f&=-2,!0;var t=k;try{Ri(this),k=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return k=t,Ai(this),this.f&=-2,!0},Te.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}O.prototype.S.call(this,t)},Te.prototype.U=function(t){if(this.t!==void 0&&(O.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}},Te.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;t!==void 0;t=t.x)t.t.N()}},Object.defineProperty(Te.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=Ci(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});function Rn(t,e){return new Te(t,e)}function $i(t){var e=t.u;if(t.u=void 0,typeof e=="function"){xe++;var n=k;k=void 0;try{e()}catch(r){throw t.f&=-2,t.f|=8,An(t),r}finally{k=n,Mt()}}}function An(t){for(var e=t.s;e!==void 0;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,$i(t)}function Ya(t){if(k!==this)throw new Error("Out-of-order effect");Ai(this),k=t,this.f&=-2,8&this.f&&An(this),Mt()}function Qe(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=e?.name}Qe.prototype.c=function(){var t=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.u=e)}finally{t()}},Qe.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,$i(this),Ri(this),xe++;var t=k;return k=this,Ya.bind(this,t)},Qe.prototype.N=function(){2&this.f||(this.f|=2,this.o=ht,ht=this)},Qe.prototype.d=function(){this.f|=8,1&this.f||An(this)},Qe.prototype.dispose=function(){this.d()};function ft(t,e){var n=new Qe(t,e);try{n.c()}catch(i){throw n.d(),i}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Ei,zt,Xa=typeof window<"u"&&!!window.__PREACT_SIGNALS_DEVTOOLS__,Pi=[];ft(function(){Ei=this.N})();function Ve(t,e){y[t]=e.bind(null,y[t]||function(){})}function Ot(t){if(zt){var e=zt;zt=void 0,e()}zt=t&&t.S()}function Ii(t){var e=this,n=t.data,r=We(n);r.value=n;var i=D(function(){for(var a=e,c=e.__v;c=c.__;)if(c.__c){c.__c.__$f|=4;break}var u=Rn(function(){var p=r.value.value;return p===0?0:p===!0?"":p||""}),h=Rn(function(){return!Array.isArray(u.value)&&!rr(u.value)}),d=ft(function(){if(this.N=qi,h.value){var p=u.value;a.__v&&a.__v.__e&&a.__v.__e.nodeType===3&&(a.__v.__e.data=p)}}),f=e.__$u.d;return e.__$u.d=function(){d(),f.call(this)},[h,u]},[]),o=i[0],s=i[1];return o.value?s.peek():s.value}Ii.displayName="ReactiveTextNode",Object.defineProperties(O.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:Ii},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}}),Ve("__b",function(t,e){if(typeof e.type=="string"){var n,r=e.props;for(var i in r)if(i!=="children"){var o=r[i];o instanceof O&&(n||(e.__np=n={}),n[i]=o,r[i]=o.peek())}}t(e)}),Ve("__r",function(t,e){if(t(e),e.type!==M){Ot();var n,r=e.__c;r&&(r.__$f&=-2,(n=r.__$u)===void 0&&(r.__$u=n=(function(i,o){var s;return ft(function(){s=this},{name:o}),s.c=i,s})(function(){var i;Xa&&((i=n.y)==null||i.call(n)),r.__$f|=1,r.setState({})},typeof e.type=="function"?e.type.displayName||e.type.name:""))),Ot(n)}}),Ve("__e",function(t,e,n,r){Ot(),t(e,n,r)}),Ve("diffed",function(t,e){Ot();var n;if(typeof e.type=="string"&&(n=e.__e)){var r=e.__np,i=e.props;if(r){var o=n.U;if(o)for(var s in o){var a=o[s];a!==void 0&&!(s in r)&&(a.d(),o[s]=void 0)}else o={},n.U=o;for(var c in r){var u=o[c],h=r[c];u===void 0?(u=el(n,c,h,i),o[c]=u):u.o(h,i)}}}t(e)});function el(t,e,n,r){var i=e in t&&t.ownerSVGElement===void 0,o=$(n);return{o:function(s,a){o.value=s,r=a},d:ft(function(){this.N=qi;var s=o.value.value;r[e]!==s&&(r[e]=s,i?t[e]=s:s!=null&&(s!==!1||e[4]==="-")?t.setAttribute(e,s):t.removeAttribute(e))})}}Ve("unmount",function(t,e){if(typeof e.type=="string"){var n=e.__e;if(n){var r=n.U;if(r){n.U=void 0;for(var i in r){var o=r[i];o&&o.d()}}}}else{var s=e.__c;if(s){var a=s.__$u;a&&(s.__$u=void 0,a.d())}}t(e)}),Ve("__h",function(t,e,n,r){(r<3||r===9)&&(e.__$f|=2),t(e,n,r)}),ee.prototype.shouldComponentUpdate=function(t,e){if(this.__R)return!0;var n=this.__$u,r=n&&n.s!==void 0;for(var i in e)return!0;if(this.__f||typeof this.u=="boolean"&&this.u===!0){var o=2&this.__$f;if(!(r||o||4&this.__$f)||1&this.__$f)return!0}else if(!(r||4&this.__$f)||3&this.__$f)return!0;for(var s in t)if(s!=="__source"&&t[s]!==this.props[s])return!0;for(var a in this.props)if(!(a in t))return!0;return!1};function We(t,e){return D(function(){return $(t,e)},[])}var tl=function(t){queueMicrotask(function(){queueMicrotask(t)})};function nl(){Za(function(){for(var t;t=Pi.shift();)Ei.call(t)})}function qi(){Pi.push(this)===1&&(y.requestAnimationFrame||tl)(nl)}const N=$(!1),Bt=$(void 0),pt="https://jexitychat.de/privacy",gt=$(pt),Li=$("chip"),be=$(void 0),$n=$([]),En=$([]),Mi=$(null);function rl(t){return t.replace(/\.convex\.site\b/,".convex.cloud")}function Pn(t){return t.replace(/\.convex\.cloud\b/,".convex.site")}function il(t){const e=t?.trim();if(e)try{const n=new URL(e);if(n.protocol==="http:"||n.protocol==="https:")return e}catch{return}}function ol(t,e){const n=t.title??e?.title??"Assistant",r=t.privacyPolicyMode??e?.privacyPolicyMode??"platform",i=sl(t.privacyNoticeStyle??e?.privacyNoticeStyle);return{title:n,greeting:t.greeting??e?.welcomeMessage??`Hi! I'm ${n}. How can I help?`,locale:t.locale??e?.locale,position:t.position??e?.position,colorScheme:t.colorScheme??e?.colorScheme,hideBranding:t.hideBranding??e?.hideBranding??!1,privacyPolicyMode:r,privacyPolicyUrl:r==="custom"?il(t.privacyPolicyUrl??e?.privacyPolicyUrl):void 0,privacyNoticeStyle:i,triggerIcon:t.triggerIcon??e?.triggerIcon??"chat",triggerRadius:t.triggerRadius??e?.triggerRadius??"full",triggerLabel:t.triggerLabel??e?.triggerLabel??"Chatte mit uns",mode:t.mode??"floating",primaryColor:t.primaryColor??e?.primaryColor,accentColor:t.accentColor??e?.accentColor,fontFamily:t.fontFamily??e?.fontFamily,fontSize:t.fontSize??e?.fontSize,borderRadius:t.borderRadius??e?.borderRadius,windowWidth:t.windowWidth??e?.windowWidth,windowHeight:t.windowHeight??e?.windowHeight}}function sl(t){return t==="explicit"||t==="sheet"?"explicit":"chip"}async function al(t,e,n,r){const i=new URL(`${t}/widget/config`);i.searchParams.set("orgSlug",e),r&&i.searchParams.set("projSlug",r);const o=await fetch(i.toString(),{signal:n});return o.ok?o.json():null}function ll(t,e,n){const[r,i]=C(null);return T(()=>{i(null);const o=n??"https://festive-mouse-978.eu-west-1.convex.cloud",s=o?Pn(o):void 0;if(!s||!t)return;const a=new AbortController;async function c(u){try{const h=await al(u,t,a.signal,e);h&&i(h)}catch(h){if(h instanceof Error&&h.name==="AbortError")return}}return c(s),()=>{a.abort()}},[t,e,n]),r}async function In(t,e,n){try{const r=await fetch(`${e}/widget/bootstrap`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n?{orgSlug:t,projSlug:n}:{orgSlug:t}),credentials:"omit"});if(r.ok){const i=await r.json(),o=i.allowedUrls??(i.allowedUrl?[i.allowedUrl]:[]);return{ok:!0,token:i.token,excludePaths:i.excludePaths,allowedUrls:o}}return r.status===403?{ok:!1,error:"unauthorized"}:r.status===404?{ok:!1,error:"not_found"}:r.status===429?{ok:!1,error:"rate_limited",retryAfterSec:Number(r.headers.get("Retry-After"))||60}:{ok:!1,error:"network"}}catch{return{ok:!1,error:"network"}}}function cl(t,e){return e.some(n=>n==="/"?t==="/":t===n||t.startsWith(n+"/"))}function qn(t,e){try{const n=new URL(t),r=new URL(e);if(n.origin!==r.origin)return!1;const i=r.pathname.replace(/\/$/,"");if(!i)return!0;const o=n.pathname.replace(/\/$/,"");return o===i||o.startsWith(i+"/")}catch{return!1}}function ul({orgSlug:t,projSlug:e,preToken:n,convexUrl:r,preAllowedUrls:i,preExcludedPaths:o}){T(()=>{const s=r??"https://festive-mouse-978.eu-west-1.convex.cloud",a=s?Pn(s):void 0;if(!a||!t)return;if(Mi.value={orgSlug:t,projSlug:e,siteUrl:a},n){$n.value=i??[],En.value=o??[];return}let c=!1;return(async()=>{const u=await In(t,a,e);if(!c)if(u.ok)be.value=u.token,$n.value=u.allowedUrls,En.value=u.excludePaths;else{const h=e?`project '${t}/${e}'`:`org '${t}'`;u.error==="unauthorized"?console.warn(`[JexityChat] Domain not authorized for ${h}. Check the widget's domain rules.`):u.error==="not_found"?console.error(`[JexityChat] No active widget config found for ${h}.`):u.error==="rate_limited"?console.error(`[JexityChat] Bootstrap rate-limited for ${h}. Retry after ${u.retryAfterSec??60}s.`):console.error(`[JexityChat] Bootstrap failed: ${u.error}`)}})(),()=>{c=!0}},[t,e,n,r])}const Dt=new Set;let Ni=!1;function dl(){if(Ni)return;Ni=!0;const t=history.pushState.bind(history),e=history.replaceState.bind(history);history.pushState=function(...n){t(...n),Dt.forEach(r=>r())},history.replaceState=function(...n){e(...n),Dt.forEach(r=>r())}}function hl(t){return Dt.add(t),window.addEventListener("popstate",t),dl(),()=>{Dt.delete(t),window.removeEventListener("popstate",t)}}function fl(){const t=We(window.location.href);T(()=>hl(()=>{t.value=window.location.href}),[]);const e=$n.value,n=En.value,r=new URL(t.value).pathname,i=cl(r,n);return T(()=>{i?console.warn(`[JexityChat] Widget hidden โ current path is in the exclude list: ${r}`):e.length>0&&!e.some(o=>qn(t.value,o))&&console.warn(`[JexityChat] Widget hidden โ current page does not match path rule. Allowed: ${e.join(", ")}`)},[t.value,e,n]),i?!1:e.length===0?!0:e.some(o=>qn(t.value,o))}const zi={title:"Assistant",statusOnline:"Online ยท Responds in seconds",inputPlaceholder:"Type a messageโฆ",aiThinking:"AI is respondingโฆ",sendAriaLabel:"Send message",attachImagesAriaLabel:"Attach images",attachComingSoon:"File attachments โ coming soon",removeAttachmentAriaLabel:"Remove attachment",openChatAriaLabel:"Open chat",closeChatAriaLabel:"Close chat",errorNetwork:"Network error. Please try again.",errorQuota:"Message limit reached. Please try again later.",errorRateLimited:"Too many messages. Try again in {seconds}s.",errorSessionNoToken:"Could not connect to chat. Check your connection and try again.",errorSessionUnauthorized:"This chat is not authorised on this page. Please reload.",localeLabelDe:"DE",localeLabelEn:"EN",resumeConversation:"Resuming conversationโฆ",startingConversation:"Starting conversationโฆ",sessionNotFound:"Your previous session was not found. Starting a new conversation.",startNewConversation:"Start new conversation",chatWith:"Chat with {title}",haveReferenceNumber:"Have a reference number?",referencePlaceholder:"e.g. JEX-A3B7C2",resume:"Resume",howCanWeHelp:"How can we help?",getInstantHelp:"Get instant help",submitTicket:"Submit a ticket",replyByEmail:"We'll reply by email",ticketSubmitted:"Ticket submitted",yourReferenceNumber:"Your reference number:",sentToEmailHint:"We've sent it to your email. Use this number to follow up.",done:"Done",submittingTicket:"Submitting your ticketโฆ",yourName:"Your name",yourEmail:"Your email",submit:"Submit",back:"Go back",escalationFormTitle:"Leave your details",escalationSubtitle:"Our team will get back to you by email so you donโt have to wait here.",escalationNameLabel:"Your name",escalationEmailLabel:"Your email",escalationSubmit:"Send to team",escalationSubmitting:"Sendingโฆ",escalationSubmitted:"Request submitted",escalationConsent:"By submitting, you agree to our",escalationPrivacyLinkText:"Privacy Policy",escalationSkip:"Skip, Iโll wait here",escalationPromptTitle:"Talk to our team",escalationPromptSubtitle:"We can notify you by email when our team replies.",escalationPromptSubmit:"Leave details",escalationSubmitFailed:"Failed to submit. Please try again.",sessionNotFoundPrompt:"Session not found. Would you like to start a new conversation?",sessionLocked:"For your privacy, this conversation was closed after a period of inactivity. Enter your reference to resume, or start a new conversation.",sessionResolved:"This conversation has been resolved.",tryAgain:"Try again",goBack:"Go back",somethingWentWrong:"Something went wrong",fabLabel:"Chat with us",chatNoLongerAvailable:"This chat is no longer available.",talkToHuman:"Talk to human",talkToHumanAria:"Talk to a human agent",handoffPending:"Connecting you to a human agentโฆ",handoffFailed:"Could not request a human agent. Try again.",handoffRateLimited:"You requested an agent recently. Please wait before trying again.",resumeListLabel:"Continue conversation",resumeListTimestamp:"{minutes}m ago",noticeAgentJoined:"{name} has joined the conversation.",noticeHumanRequested:"You requested to speak with a human agent.",noticeHumanRequestedForm:"You requested to speak with a human agent. Please share your contact details below.",noticeEscalationConfirmed:`Thank you {name}! A human agent will be available soon.
|
|
3
3
|
We will contact you at {email} when an agent is ready.
|
|
4
4
|
|
|
5
5
|
Your reference: **{ref}**
|
|
6
|
-
Use it to resume this conversation from any device.`,noticeMessageReceived:"Your message has been received. A team member will respond shortly.",noticeAgentHandling:"Your conversation is with a human agent who will respond shortly.",replyTo:"Reply to {name}",sourcesCountOne:"{count} source",sourcesCountOther:"{count} sources",privacyNoticePre:"By chatting, you agree to our",privacyPolicyLinkText:"Privacy Policy",privacyChipText:"We respect your privacy - read our policy",privacyExplicitTitle:"Before you send",privacyExplicitBodyPre:"Messages are processed to assist you. By continuing you agree to our",privacyExplicitButton:"Got it, continue"},
|
|
6
|
+
Use it to resume this conversation from any device.`,noticeMessageReceived:"Your message has been received. A team member will respond shortly.",noticeAgentHandling:"Your conversation is with a human agent who will respond shortly.",replyTo:"Reply to {name}",sourcesCountOne:"{count} source",sourcesCountOther:"{count} sources",privacyNoticePre:"By chatting, you agree to our",privacyPolicyLinkText:"Privacy Policy",privacyChipText:"We respect your privacy - read our policy",privacyExplicitTitle:"Before you send",privacyExplicitBodyPre:"Messages are processed to assist you. By continuing you agree to our",privacyExplicitButton:"Got it, continue",magiclineTrialTitle:"Book a trial session",magiclineLeadTitle:"Request more information",magiclineFirstName:"First name",magiclineLastName:"Last name",magiclineEmail:"Email",magiclinePhone:"Phone",magiclineBirthDate:"Date of birth",magiclineInterest:"What are you interested in? (optional)",magiclineMessage:"Message (optional)",magiclineSlotLabel:"Preferred time",magiclineSlotPlaceholder:"Select a timeโฆ",magiclineLoadingSlots:"Loading available timesโฆ",magiclineNoSlots:"No trial times are available right now. Please check back later or ask us for help.",magiclineSubmit:"Submit",magiclineSubmitting:"Submittingโฆ",magiclineSubmitted:"Request submitted",magiclineSubmittedDetail:"Weโve received your request and will be in touch shortly.",magiclineFailed:"Submission failed",magiclineFailedDetail:"Something went wrong submitting your request. Please try again.",magiclineConsent:"I agree to the processing of my data in accordance with the",magiclinePrivacyLinkText:"Privacy Policy",magiclineRequiredError:"Please fill in all required fields.",magiclineEmailError:"Please enter a valid email address.",magiclineConsentError:"Please accept the privacy policy to continue.",magiclineConfigLoading:"Loading the booking formโฆ",magiclineConfigUnsupported:"Online trial booking is not supported for this studio. Please ask us for help.",magiclineConfigInconsistent:"The booking form is temporarily misconfigured. Please ask us for help.",magiclineConfigUnavailable:"Trial booking is not available right now. Please try again later or ask us for help.",magiclineGender:"Gender",magiclineGenderPlaceholder:"Select genderโฆ",magiclineGenderMale:"Male",magiclineGenderFemale:"Female",magiclineGenderUnisex:"Diverse",magiclineStreet:"Street",magiclineHouseNumber:"House number",magiclineZip:"Postal code",magiclineCity:"City",magiclineCountry:"Country",magiclineCountryPlaceholder:"Select a countryโฆ",magiclineNote:"Note (optional)",magiclineOptionalSuffix:" (optional)",magiclineTrainerRequired:"I want a trainer present",magiclineMinAgeError:"You must be at least {age} years old to book a trial.",magiclineSlotRequiredError:"Please select an available time.",magiclineSlotUnavailableNotice:"That time is no longer available. Please pick another time below.",magiclineStepTrainer:"Trainer",magiclineStepSlot:"Choose a time",magiclineStepPersonal:"Your details",magiclineStepAddress:"Your address",magiclineStepConfirm:"Confirm",magiclineStepCounter:"Step {n} of {total}",magiclineWizardBack:"Back",magiclineWizardNext:"Next",magiclineTrainerWith:"Trial session with trainer",magiclineTrainerWithout:"Trial session without trainer",magiclineSummaryTrainer:"Trainer",magiclineSummarySlot:"Time",magiclineSummaryName:"Name",magiclineRetry:"Try again",magiclineSlotsError:"We couldnโt load available times right now. Please try again."},pl={title:"Assistent",statusOnline:"Online ยท Antwortet in Sekunden",inputPlaceholder:"Nachricht eingebenโฆ",aiThinking:"KI antwortetโฆ",sendAriaLabel:"Nachricht senden",attachImagesAriaLabel:"Bilder anhรคngen",attachComingSoon:"Dateianhรคnge โ bald verfรผgbar",removeAttachmentAriaLabel:"Anhang entfernen",openChatAriaLabel:"Chat รถffnen",closeChatAriaLabel:"Chat schlieรen",errorNetwork:"Netzwerkfehler. Bitte versuche es erneut.",errorQuota:"Nachrichtenlimit erreicht. Bitte versuche es spรคter erneut.",errorRateLimited:"Zu viele Nachrichten. Bitte in {seconds} Sek. erneut versuchen.",errorSessionNoToken:"Verbindung zum Chat fehlgeschlagen. Bitte Internet prรผfen und erneut versuchen.",errorSessionUnauthorized:"Dieser Chat ist auf dieser Seite nicht autorisiert. Bitte neu laden.",localeLabelDe:"DE",localeLabelEn:"EN",resumeConversation:"Gesprรคch wird fortgesetztโฆ",startingConversation:"Konversation wird gestartetโฆ",sessionNotFound:"Ihre vorherige Sitzung wurde nicht gefunden. Ein neues Gesprรคch wird gestartet.",startNewConversation:"Neues Gesprรคch beginnen",chatWith:"Chatte mit {title}",haveReferenceNumber:"Hast du eine Referenznummer?",referencePlaceholder:"z.B. JEX-A3B7C2",resume:"Fortsetzen",howCanWeHelp:"Wie kรถnnen wir helfen?",getInstantHelp:"Soforthilfe erhalten",submitTicket:"Ticket einreichen",replyByEmail:"Wir antworten per E-Mail",ticketSubmitted:"Ticket eingereicht",yourReferenceNumber:"Deine Referenznummer:",sentToEmailHint:"Wir haben sie an deine E-Mail gesendet. Verwende diese Nummer fรผr Rรผckfragen.",done:"Fertig",submittingTicket:"Dein Ticket wird รผbermitteltโฆ",yourName:"Dein Name",yourEmail:"Deine E-Mail",submit:"Absenden",back:"Zurรผck",escalationFormTitle:"Hinterlassen Sie Ihre Daten",escalationSubtitle:"Unser Team meldet sich per E-Mail bei Ihnen โ Sie mรผssen nicht hier warten.",escalationNameLabel:"Ihr Name",escalationEmailLabel:"Ihre E-Mail",escalationSubmit:"An Team senden",escalationSubmitting:"Wird gesendetโฆ",escalationSubmitted:"Anfrage gesendet",escalationConsent:"Mit dem Absenden stimmen Sie unserer",escalationPrivacyLinkText:"Datenschutzerklรคrung",escalationSkip:"รberspringen, ich warte hier",escalationPromptTitle:"Sprechen Sie mit unserem Team",escalationPromptSubtitle:"Wir benachrichtigen Sie per E-Mail, wenn wir antworten.",escalationPromptSubmit:"Daten hinterlassen",escalationSubmitFailed:"Senden fehlgeschlagen. Bitte versuche es erneut.",sessionNotFoundPrompt:"Sitzung nicht gefunden. Mรถchten Sie ein neues Gesprรคch beginnen?",sessionLocked:"Aus Datenschutzgrรผnden wurde dieses Gesprรคch nach einer Inaktivitรคtszeit geschlossen. Geben Sie Ihre Referenz ein, um fortzufahren, oder beginnen Sie ein neues Gesprรคch.",sessionResolved:"Diese Unterhaltung wurde abgeschlossen.",tryAgain:"Erneut versuchen",goBack:"Zurรผck",somethingWentWrong:"Etwas ist schiefgelaufen",fabLabel:"Chatte mit uns",chatNoLongerAvailable:"Dieser Chat ist nicht mehr verfรผgbar.",talkToHuman:"Mit Mitarbeiter sprechen",talkToHumanAria:"Mit einem menschlichen Mitarbeiter sprechen",handoffPending:"Sie werden mit einem Mitarbeiter verbundenโฆ",handoffFailed:"Anfrage konnte nicht gesendet werden. Erneut versuchen.",handoffRateLimited:"Sie haben kรผrzlich einen Mitarbeiter angefragt. Bitte warten Sie.",resumeListLabel:"Unterhaltung fortsetzen",resumeListTimestamp:"vor {minutes} Min.",noticeAgentJoined:"{name} ist der Unterhaltung beigetreten.",noticeHumanRequested:"Sie haben darum gebeten, mit einem Mitarbeiter zu sprechen.",noticeHumanRequestedForm:"Sie haben darum gebeten, mit einem Mitarbeiter zu sprechen. Bitte teilen Sie unten Ihre Kontaktdaten mit.",noticeEscalationConfirmed:`Vielen Dank, {name}! Ein Mitarbeiter wird in Kรผrze verfรผgbar sein.
|
|
7
7
|
Wir kontaktieren Sie unter {email}, sobald ein Mitarbeiter bereit ist.
|
|
8
8
|
|
|
9
9
|
Ihre Referenz: **{ref}**
|
|
10
|
-
Verwenden Sie sie, um diese Unterhaltung auf jedem Gerรคt fortzusetzen.`,noticeMessageReceived:"Ihre Nachricht ist eingegangen. Ein Mitarbeiter wird in Kรผrze antworten.",noticeAgentHandling:"Ihre Unterhaltung wird von einem menschlichen Mitarbeiter betreut, der in Kรผrze antwortet.",replyTo:"Antworten an {name}",sourcesCountOne:"{count} Quelle",sourcesCountOther:"{count} Quellen",privacyNoticePre:"Mit dem Chatten stimmst du unserer",privacyPolicyLinkText:"Datenschutzerklรคrung",privacyChipText:"Wir respektieren Ihre Privatsphรคre - Richtlinie lesen",privacyExplicitTitle:"Vor dem Senden",privacyExplicitBodyPre:"Nachrichten werden verarbeitet, um Ihnen zu helfen. Durch Fortfahren stimmen Sie unserer",privacyExplicitButton:"Verstanden, fortfahren"},nl=[{value:"de",label:"Deutsch",flag:"๐ฉ๐ช"},{value:"en",label:"English",flag:"๐ฌ๐ง"}],rl="de",il="jex-locale",xe=R("de"),ol={en:$i,de:tl};function $(){return ol[xe.value]??$i}function Sn(t){if(!t)return null;const e=(t.split("-")[0]??"").toLowerCase();return nl.some(r=>r.value===e)?e:null}function Ai(t){const e=Sn(t);if(e)return e;try{const n=Sn(localStorage.getItem(il));if(n)return n}catch{}if(typeof navigator<"u"){const n=Sn(navigator.language);if(n)return n}return rl}function sl(t){S(()=>{function e(n){const r=t??window.location.origin;if(n.origin!==r||n.data?.type!=="jexity:config")return;const{locale:i}=n.data.payload;i&&(xe.value=Ai(i))}return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}},[t])}const Ei="jex-session-history",Pi=Ei,Ii=3600*1e3,z=R([]),be=R(null),Li=bn(()=>z.value.length>0),nt=R(null);function al(){return"JEX-"+Math.random().toString(36).slice(2,8).toUpperCase()}function ll(t){try{const e=sessionStorage.getItem(Pi);if(!e)return[];const n=JSON.parse(e);return n.v!==1||!Array.isArray(n.entries)?[]:n.entries.filter(r=>t-r.lastActivityAt<=Ii)}catch{return[]}}function Pt(t){try{const e={v:1,entries:t};sessionStorage.setItem(Pi,JSON.stringify(e))}catch{}}function cl(){const t=Date.now(),e=ll(t);z.value=e,Pt(e),be.value=e[e.length-1]?.ref??null}function Mi(){const t=al(),e=Date.now(),n=[...z.value,{ref:t,startedAt:e,lastActivityAt:e}];return z.value=n,be.value=t,Pt(n),t}function qi(t){const e=Date.now(),n=z.value.map(r=>r.ref===t?{...r,lastActivityAt:e}:r);z.value=n,be.value=t,Pt(n)}function Cn(t){if(!t)return;const e=Date.now(),n=z.value.map(r=>r.ref===t?{...r,lastActivityAt:e}:r);z.value=n,Pt(n)}const B=R(Oi());function Oi(){return Li.value?[{id:"home"}]:[{id:"chat"}]}function ul(){B.value=Oi()}const hl=R("screen");function ye(t){B.value=[...B.value,t]}function It(){B.value.length>1&&(B.value=B.value.slice(0,-1))}function Tn(t){B.value=[...B.value.slice(0,-1),t]}const dl=6e4,rt=R(!1),Rn=R(!1),$n=new Set;function fl(t){return $n.add(t),()=>{$n.delete(t)}}function pl(){const t=be.value;return t?z.value.find(n=>n.ref===t)?.lastActivityAt??null:null}function gl(t){const e=pl();return e===null?!1:Date.now()-e>t}function Ni(){if(!(rt.value&&z.value.length===0)){z.value=[],be.value=null;try{sessionStorage.removeItem(Ei)}catch(t){console.warn("[JexityChat] Idle-lock storage clear failed:",t)}for(const t of $n)try{t()}catch(e){console.warn("[JexityChat] Lock reset callback threw:",e)}B.value=[{id:"home"}],rt.value=!0}}function An(){rt.value&&(rt.value=!1)}function ml(t=Ii){let e=null;const n=()=>{if(document.visibilityState==="hidden"){e=Date.now();return}e!==null&&Date.now()-e>t&&Ni(),e=null};document.addEventListener("visibilitychange",n);const r=setInterval(()=>{Rn.value||gl(t)&&Ni()},dl);return()=>{document.removeEventListener("visibilitychange",n),clearInterval(r),e=null}}function xl(t){const e={},{primaryColor:n,theme:r}=t;if(n&&(e["--jex-primary"]=n,e["--jex-bg-trigger"]=n,e["--jex-bg-header"]=n,e["--jex-bg-msg-user"]=n,e["--jex-bg-send-btn"]=n),t.accentColor&&(e["--jex-accent"]=t.accentColor),r?.bg){const i=r.bg;i.trigger&&(e["--jex-bg-trigger"]=i.trigger),i.header&&(e["--jex-bg-header"]=i.header),i.msgUser&&(e["--jex-bg-msg-user"]=i.msgUser),i.msgBot&&(e["--jex-bg-msg-bot"]=i.msgBot),i.window&&(e["--jex-bg-window"]=i.window),i.sendBtn&&(e["--jex-bg-send-btn"]=i.sendBtn)}if(r?.text){const i=r.text;i.header&&(e["--jex-text-header"]=i.header),i.msgUser&&(e["--jex-text-msg-user"]=i.msgUser),i.msgBot&&(e["--jex-text-msg-bot"]=i.msgBot),i.main&&(e["--jex-text-main"]=i.main),i.muted&&(e["--jex-text-muted"]=i.muted)}if(r?.border){const i=r.border;i.window&&(e["--jex-border-window"]=i.window),i.input&&(e["--jex-border-input"]=i.input)}return t.fontFamily&&(e["--jex-font-family"]=t.fontFamily),t.fontSize&&(e["--jex-font-size"]=`${t.fontSize}px`),t.borderRadius&&(e["--jex-radius"]=t.borderRadius),t.windowWidth&&(e["--jex-window-width"]=`${t.windowWidth}px`),t.windowHeight&&(e["--jex-window-height"]=`${t.windowHeight}px`),Object.keys(e).length>0?e:void 0}function En({size:t=24}){return c("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:[c("path",{d:"M12 8V4H8"}),c("rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}),c("path",{d:"M2 14h2"}),c("path",{d:"M20 14h2"}),c("path",{d:"M15 13v2"}),c("path",{d:"M9 13v2"})]})}function bl(){const t=$();return B.value.length>1?c("button",{class:"jex-header-back",onClick:It,"aria-label":t.back||"Go back",children:c("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:c("path",{d:"m15 18-6-6 6-6"})})}):c(En,{size:24})}function yl({title:t}){const e=$();return c("div",{class:"jex-header-info",children:[c("h3",{children:t}),c("p",{children:e.statusOnline})]})}function zi({size:t=28}){return c("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:[c("path",{d:"M18 6 6 18"}),c("path",{d:"m6 6 12 12"})]})}function vl(){const t=$();return c("button",{class:"jex-header-close",type:"button",onClick:()=>{P.value=!1},"aria-label":t.closeChatAriaLabel,title:t.closeChatAriaLabel,children:c(zi,{size:18})})}function wl({action:t,showClose:e=!0}){return!t&&!e?null:c("div",{class:"jex-header-right",children:[t,e&&c(vl,{})]})}function Bi({title:t,rightAction:e,showClose:n=!0}){return c("header",{class:"jex-chat-header",children:[c(bl,{}),c(yl,{title:t}),c(wl,{action:e,showClose:n})]})}function _l({size:t=14}){return c("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:c("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})})}function Ui(){return c("div",{class:"jex-widget-footer",children:c("a",{href:"https://jexitychat.de",target:"_blank",rel:"noopener noreferrer",class:"jex-branding",children:[c(_l,{size:14}),c("span",{children:["Powered by ",c("strong",{children:"Jexity"})]})]})})}function Fi({size:t=28}){return c("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:c("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function kl({size:t=24,...e}){return c("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...e,children:c("path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z"})})}const jl={chat:c(Fi,{size:28}),bot:c(En,{size:28}),sparkles:c(kl,{size:28})},Sl={none:"0px",sm:"0.5rem",md:"0.75rem",lg:"1.25rem",full:"9999px"};function Cl({radius:t="full",iconOption:e="chat",label:n}){const r=$(),i=n??r.fabLabel,o=i!=="";return c("button",{class:`jex-floating-button ${!P.value&&o?"jex-has-label":""}`,style:{borderRadius:Sl[t]??"9999px"},onClick:()=>{P.value=!P.value},"aria-label":P.value?r.closeChatAriaLabel:r.openChatAriaLabel,children:P.value?c(zi,{size:28}):c("div",{class:"jex-fab-inner",children:[jl[e],o&&c("span",{class:"jex-fab-label",children:i})]})})}function Tl({title:t,onStartFresh:e,onResetSession:n}){const r=$(),[i,o]=C("");function s(){An(),nt.value="fresh",n(),e(),ye({id:"chat"})}function l(u){An(),nt.value="resume",n(),qi(u),ye({id:"chat"})}function a(u){u.preventDefault();const d=i.trim().toUpperCase();d&&(An(),nt.value="resume",n(),qi(d),ye({id:"chat"}))}return c("div",{class:"jex-home",children:[rt.value&&c("div",{class:"jex-session-prompt",role:"status",children:c("div",{class:"jex-session-prompt-text",children:r.sessionLocked})}),c("div",{class:"jex-home-hero",children:[c("div",{class:"jex-home-avatar",children:[c(Fi,{size:24}),c("span",{class:"jex-home-status-dot"})]}),c("div",{class:"jex-home-hero-text",children:[c("h2",{class:"jex-home-title",children:t}),c("span",{class:"jex-home-status",children:r.statusOnline})]})]}),c("form",{class:"jex-home-lookup",onSubmit:a,children:[c("input",{class:"jex-home-lookup-input",type:"text",placeholder:r.referencePlaceholder,value:i,onInput:u=>{o(u.currentTarget.value)}}),c("button",{class:"jex-home-lookup-submit",type:"submit",disabled:!i.trim(),children:r.resume})]}),c("div",{class:"jex-home-actions",children:[z.value.length>0&&c("div",{class:"jex-home-history",children:z.value.slice().reverse().map(u=>c("button",{class:"jex-home-resume-card",onClick:()=>{l(u.ref)},children:[c("div",{class:"jex-home-resume-top",children:[c("span",{class:"jex-home-resume-label",children:r.resumeListLabel}),c("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",class:"jex-home-resume-arrow",children:c("path",{d:"M6 3l5 5-5 5",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})})]}),c("span",{class:"jex-home-resume-ref",children:u.ref}),c("span",{class:"jex-home-resume-meta",children:r.resumeListTimestamp.replace("{minutes}",String(Math.max(1,Math.round((Date.now()-u.lastActivityAt)/6e4))))})]},u.ref))}),c("button",{class:"jex-home-new-btn",onClick:s,children:z.value.length>0?r.startNewConversation:r.chatWith.replace("{title}",t)})]})]})}function Rl({title:t}){const e=$();return c("div",{class:"jex-selection",children:[c("h2",{class:"jex-selection-title",children:e.howCanWeHelp}),c("div",{class:"jex-selection-options",children:[c("button",{class:"jex-selection-option",onClick:()=>ye({id:"chat"}),children:[c("span",{class:"jex-selection-icon",children:"๐ฌ"}),c("span",{class:"jex-selection-label",children:e.chatWith.replace("{title}",t)}),c("span",{class:"jex-selection-sub",children:e.getInstantHelp})]}),c("button",{class:"jex-selection-option",onClick:()=>ye({id:"form"}),children:[c("span",{class:"jex-selection-icon",children:"๐"}),c("span",{class:"jex-selection-label",children:e.submitTicket}),c("span",{class:"jex-selection-sub",children:e.replyByEmail})]})]})]})}const $l=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();const Qi=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const Al=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase());const Di=t=>{const e=Al(t);return e.charAt(0).toUpperCase()+e.slice(1)};var El={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"};const Pl=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1};const Il=({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,children:i,iconNode:o,class:s="",...l})=>D("svg",{...El,width:String(e),height:e,stroke:t,"stroke-width":r?Number(n)*24/Number(e):n,class:["lucide",s].join(" "),...!i&&!Pl(l)&&{"aria-hidden":"true"},...l},[...o.map(([a,u])=>D(a,u)),...Y(i)]);const Ll=(t,e)=>{const n=({class:r="",className:i="",children:o,...s})=>D(Il,{...s,iconNode:e,class:$l(`lucide-${Qi(Di(t))}`,`lucide-${Qi(t)}`,r,i)},o);return n.displayName=Di(t),n};const Ml=Ll("corner-up-left",[["path",{d:"M20 20v-7a4 4 0 0 0-4-4H4",key:"1nkjon"}],["path",{d:"M9 14 4 9l5-5",key:"102s5s"}]]);function Pn(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ve=Pn();function Vi(t){ve=t}var we={exec:()=>null};function w(t,e=""){let n=typeof t=="string"?t:t.source,r={replace:(i,o)=>{let s=typeof o=="string"?o:o.source;return s=s.replace(q.caret,"$1"),n=n.replace(i,s),r},getRegex:()=>new RegExp(n,e)};return r}var ql=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),q={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}>`)},Ol=/^(?:[ \t]*(?:\n|$))+/,Nl=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,zl=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,it=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Bl=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,In=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Hi=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Wi=w(Hi).replace(/bull/g,In).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Ul=w(Hi).replace(/bull/g,In).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Ln=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Fl=/^[^\n]+/,Mn=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Ql=w(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Mn).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Dl=w(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,In).getRegex(),Lt="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",qn=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Vl=w("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",qn).replace("tag",Lt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ji=w(Ln).replace("hr",it).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Lt).getRegex(),Hl=w(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Ji).getRegex(),On={blockquote:Hl,code:Nl,def:Ql,fences:zl,heading:Bl,hr:it,html:Vl,lheading:Wi,list:Dl,newline:Ol,paragraph:Ji,table:we,text:Fl},Gi=w("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",it).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Lt).getRegex(),Wl={...On,lheading:Ul,table:Gi,paragraph:w(Ln).replace("hr",it).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Gi).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Lt).getRegex()},Jl={...On,html:w(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",qn).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:we,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:w(Ln).replace("hr",it).replace("heading",` *#{1,6} *[^
|
|
11
|
-
]`).replace("lheading",
|
|
12
|
-
`).map(o=>{let s=o.match(n.other.beginningSpace);if(s===null)return o;let[
|
|
13
|
-
`)}var
|
|
14
|
-
`)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],r=
|
|
15
|
-
`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=
|
|
10
|
+
Verwenden Sie sie, um diese Unterhaltung auf jedem Gerรคt fortzusetzen.`,noticeMessageReceived:"Ihre Nachricht ist eingegangen. Ein Mitarbeiter wird in Kรผrze antworten.",noticeAgentHandling:"Ihre Unterhaltung wird von einem menschlichen Mitarbeiter betreut, der in Kรผrze antwortet.",replyTo:"Antworten an {name}",sourcesCountOne:"{count} Quelle",sourcesCountOther:"{count} Quellen",privacyNoticePre:"Mit dem Chatten stimmst du unserer",privacyPolicyLinkText:"Datenschutzerklรคrung",privacyChipText:"Wir respektieren Ihre Privatsphรคre - Richtlinie lesen",privacyExplicitTitle:"Vor dem Senden",privacyExplicitBodyPre:"Nachrichten werden verarbeitet, um Ihnen zu helfen. Durch Fortfahren stimmen Sie unserer",privacyExplicitButton:"Verstanden, fortfahren",magiclineTrialTitle:"Probetraining buchen",magiclineLeadTitle:"Weitere Informationen anfordern",magiclineFirstName:"Vorname",magiclineLastName:"Nachname",magiclineEmail:"E-Mail",magiclinePhone:"Telefon",magiclineBirthDate:"Geburtsdatum",magiclineInterest:"Wofรผr interessieren Sie sich? (optional)",magiclineMessage:"Nachricht (optional)",magiclineSlotLabel:"Wunschtermin",magiclineSlotPlaceholder:"Termin auswรคhlenโฆ",magiclineLoadingSlots:"Verfรผgbare Termine werden geladenโฆ",magiclineNoSlots:"Derzeit sind keine Probetermine verfรผgbar. Bitte versuchen Sie es spรคter erneut oder fragen Sie uns um Hilfe.",magiclineSubmit:"Absenden",magiclineSubmitting:"Wird gesendetโฆ",magiclineSubmitted:"Anfrage gesendet",magiclineSubmittedDetail:"Wir haben Ihre Anfrage erhalten und melden uns in Kรผrze bei Ihnen.",magiclineFailed:"Senden fehlgeschlagen",magiclineFailedDetail:"Beim Senden Ihrer Anfrage ist ein Fehler aufgetreten. Bitte versuchen Sie es erneut.",magiclineConsent:"Ich stimme der Verarbeitung meiner Daten gemรคร der",magiclinePrivacyLinkText:"Datenschutzerklรคrung",magiclineRequiredError:"Bitte fรผllen Sie alle Pflichtfelder aus.",magiclineEmailError:"Bitte geben Sie eine gรผltige E-Mail-Adresse ein.",magiclineConsentError:"Bitte akzeptieren Sie die Datenschutzerklรคrung, um fortzufahren.",magiclineConfigLoading:"Buchungsformular wird geladenโฆ",magiclineConfigUnsupported:"Die Online-Buchung eines Probetrainings wird fรผr dieses Studio nicht unterstรผtzt. Bitte fragen Sie uns um Hilfe.",magiclineConfigInconsistent:"Das Buchungsformular ist vorรผbergehend falsch konfiguriert. Bitte fragen Sie uns um Hilfe.",magiclineConfigUnavailable:"Die Buchung eines Probetrainings ist derzeit nicht verfรผgbar. Bitte versuchen Sie es spรคter erneut oder fragen Sie uns um Hilfe.",magiclineGender:"Geschlecht",magiclineGenderPlaceholder:"Geschlecht auswรคhlenโฆ",magiclineGenderMale:"Mรคnnlich",magiclineGenderFemale:"Weiblich",magiclineGenderUnisex:"Divers",magiclineStreet:"Straรe",magiclineHouseNumber:"Hausnummer",magiclineZip:"Postleitzahl",magiclineCity:"Stadt",magiclineCountry:"Land",magiclineCountryPlaceholder:"Land auswรคhlenโฆ",magiclineNote:"Anmerkung (optional)",magiclineOptionalSuffix:" (optional)",magiclineTrainerRequired:"Ich wรผnsche einen Trainer vor Ort",magiclineMinAgeError:"Sie mรผssen mindestens {age} Jahre alt sein, um ein Probetraining zu buchen.",magiclineSlotRequiredError:"Bitte wรคhlen Sie einen verfรผgbaren Termin aus.",magiclineSlotUnavailableNotice:"Dieser Termin ist nicht mehr verfรผgbar. Bitte wรคhlen Sie unten einen anderen Termin aus.",magiclineStepTrainer:"Trainer",magiclineStepSlot:"Termin wรคhlen",magiclineStepPersonal:"Ihre Daten",magiclineStepAddress:"Ihre Adresse",magiclineStepConfirm:"Bestรคtigen",magiclineStepCounter:"Schritt {n} von {total}",magiclineWizardBack:"Zurรผck",magiclineWizardNext:"Weiter",magiclineTrainerWith:"Probetraining mit Trainer",magiclineTrainerWithout:"Probetraining ohne Trainer",magiclineSummaryTrainer:"Trainer",magiclineSummarySlot:"Termin",magiclineSummaryName:"Name",magiclineRetry:"Erneut versuchen",magiclineSlotsError:"Die verfรผgbaren Termine konnten gerade nicht geladen werden. Bitte versuchen Sie es erneut."},gl=[{value:"de",label:"Deutsch",flag:"๐ฉ๐ช"},{value:"en",label:"English",flag:"๐ฌ๐ง"}],ml="de",xl="jex-locale",fe=$("de"),bl={en:zi,de:pl};function _(){return bl[fe.value]??zi}function Ln(t){if(!t)return null;const e=(t.split("-")[0]??"").toLowerCase();return gl.some(r=>r.value===e)?e:null}function Oi(t){const e=Ln(t);if(e)return e;try{const n=Ln(localStorage.getItem(xl));if(n)return n}catch{}if(typeof navigator<"u"){const n=Ln(navigator.language);if(n)return n}return ml}function vl(t){T(()=>{function e(n){const r=t??window.location.origin;if(n.origin!==r||n.data?.type!=="jexity:config")return;const{locale:i}=n.data.payload;i&&(fe.value=Oi(i))}return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}},[t])}const Bi="jex-session-history",Di=Bi,Ui=3600*1e3,V=$([]),Re=$(null),Fi=Rn(()=>V.value.length>0),mt=$(null);function yl(){return"JEX-"+Math.random().toString(36).slice(2,8).toUpperCase()}function wl(t){try{const e=sessionStorage.getItem(Di);if(!e)return[];const n=JSON.parse(e);return n.v!==1||!Array.isArray(n.entries)?[]:n.entries.filter(r=>t-r.lastActivityAt<=Ui)}catch{return[]}}function Ut(t){try{const e={v:1,entries:t};sessionStorage.setItem(Di,JSON.stringify(e))}catch{}}function kl(){const t=Date.now(),e=wl(t);V.value=e,Ut(e),Re.value=e[e.length-1]?.ref??null}function Qi(){const t=yl(),e=Date.now(),n=[...V.value,{ref:t,startedAt:e,lastActivityAt:e}];return V.value=n,Re.value=t,Ut(n),t}function Vi(t){const e=Date.now(),n=V.value.map(r=>r.ref===t?{...r,lastActivityAt:e}:r);V.value=n,Re.value=t,Ut(n)}function Mn(t){if(!t)return;const e=Date.now(),n=V.value.map(r=>r.ref===t?{...r,lastActivityAt:e}:r);V.value=n,Ut(n)}const W=$(Wi());function Wi(){return Fi.value?[{id:"home"}]:[{id:"chat"}]}function _l(){W.value=Wi()}const jl=$("screen");function Ae(t){W.value=[...W.value,t]}function Ft(){W.value.length>1&&(W.value=W.value.slice(0,-1))}function Nn(t){W.value=[...W.value.slice(0,-1),t]}const Sl=6e4,xt=$(!1),zn=$(!1),On=new Set;function Cl(t){return On.add(t),()=>{On.delete(t)}}function Tl(){const t=Re.value;return t?V.value.find(n=>n.ref===t)?.lastActivityAt??null:null}function Rl(t){const e=Tl();return e===null?!1:Date.now()-e>t}function Hi(){if(!(xt.value&&V.value.length===0)){V.value=[],Re.value=null;try{sessionStorage.removeItem(Bi)}catch(t){console.warn("[JexityChat] Idle-lock storage clear failed:",t)}for(const t of On)try{t()}catch(e){console.warn("[JexityChat] Lock reset callback threw:",e)}W.value=[{id:"home"}],xt.value=!0}}function Bn(){xt.value&&(xt.value=!1)}function Al(t=Ui){let e=null;const n=()=>{if(document.visibilityState==="hidden"){e=Date.now();return}e!==null&&Date.now()-e>t&&Hi(),e=null};document.addEventListener("visibilitychange",n);const r=setInterval(()=>{zn.value||Rl(t)&&Hi()},Sl);return()=>{document.removeEventListener("visibilitychange",n),clearInterval(r),e=null}}function $l(t){const e={},{primaryColor:n,theme:r}=t;if(n&&(e["--jex-primary"]=n,e["--jex-bg-trigger"]=n,e["--jex-bg-header"]=n,e["--jex-bg-msg-user"]=n,e["--jex-bg-send-btn"]=n),t.accentColor&&(e["--jex-accent"]=t.accentColor),r?.bg){const i=r.bg;i.trigger&&(e["--jex-bg-trigger"]=i.trigger),i.header&&(e["--jex-bg-header"]=i.header),i.msgUser&&(e["--jex-bg-msg-user"]=i.msgUser),i.msgBot&&(e["--jex-bg-msg-bot"]=i.msgBot),i.window&&(e["--jex-bg-window"]=i.window),i.sendBtn&&(e["--jex-bg-send-btn"]=i.sendBtn)}if(r?.text){const i=r.text;i.header&&(e["--jex-text-header"]=i.header),i.msgUser&&(e["--jex-text-msg-user"]=i.msgUser),i.msgBot&&(e["--jex-text-msg-bot"]=i.msgBot),i.main&&(e["--jex-text-main"]=i.main),i.muted&&(e["--jex-text-muted"]=i.muted)}if(r?.border){const i=r.border;i.window&&(e["--jex-border-window"]=i.window),i.input&&(e["--jex-border-input"]=i.input)}return t.fontFamily&&(e["--jex-font-family"]=t.fontFamily),t.fontSize&&(e["--jex-font-size"]=`${t.fontSize}px`),t.borderRadius&&(e["--jex-radius"]=t.borderRadius),t.windowWidth&&(e["--jex-window-width"]=`${t.windowWidth}px`),t.windowHeight&&(e["--jex-window-height"]=`${t.windowHeight}px`),Object.keys(e).length>0?e:void 0}function Dn({size:t=24}){return l("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:[l("path",{d:"M12 8V4H8"}),l("rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}),l("path",{d:"M2 14h2"}),l("path",{d:"M20 14h2"}),l("path",{d:"M15 13v2"}),l("path",{d:"M9 13v2"})]})}function El(){const t=_();return W.value.length>1?l("button",{class:"jex-header-back",onClick:Ft,"aria-label":t.back||"Go back",children:l("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:l("path",{d:"m15 18-6-6 6-6"})})}):l(Dn,{size:24})}function Pl({title:t}){const e=_();return l("div",{class:"jex-header-info",children:[l("h3",{children:t}),l("p",{children:e.statusOnline})]})}function Gi({size:t=28}){return l("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:[l("path",{d:"M18 6 6 18"}),l("path",{d:"m6 6 12 12"})]})}function Il(){const t=_();return l("button",{class:"jex-header-close",type:"button",onClick:()=>{N.value=!1},"aria-label":t.closeChatAriaLabel,title:t.closeChatAriaLabel,children:l(Gi,{size:18})})}function ql({action:t,showClose:e=!0}){return!t&&!e?null:l("div",{class:"jex-header-right",children:[t,e&&l(Il,{})]})}function Ji({title:t,rightAction:e,showClose:n=!0}){return l("header",{class:"jex-chat-header",children:[l(El,{}),l(Pl,{title:t}),l(ql,{action:e,showClose:n})]})}function Ll({size:t=14}){return l("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:l("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})})}function Ki(){return l("div",{class:"jex-widget-footer",children:l("a",{href:"https://jexitychat.de",target:"_blank",rel:"noopener noreferrer",class:"jex-branding",children:[l(Ll,{size:14}),l("span",{children:["Powered by ",l("strong",{children:"Jexity"})]})]})})}function Zi({size:t=28}){return l("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:l("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function Ml({size:t=24,...e}){return l("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...e,children:l("path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z"})})}const Nl={chat:l(Zi,{size:28}),bot:l(Dn,{size:28}),sparkles:l(Ml,{size:28})},zl={none:"0px",sm:"0.5rem",md:"0.75rem",lg:"1.25rem",full:"9999px"};function Ol({radius:t="full",iconOption:e="chat",label:n}){const r=_(),i=n??r.fabLabel,o=i!=="";return l("button",{class:`jex-floating-button ${!N.value&&o?"jex-has-label":""}`,style:{borderRadius:zl[t]??"9999px"},onClick:()=>{N.value=!N.value},"aria-label":N.value?r.closeChatAriaLabel:r.openChatAriaLabel,children:N.value?l(Gi,{size:28}):l("div",{class:"jex-fab-inner",children:[Nl[e],o&&l("span",{class:"jex-fab-label",children:i})]})})}function Bl({title:t,onStartFresh:e,onResetSession:n}){const r=_(),[i,o]=C("");function s(){Bn(),mt.value="fresh",n(),e(),Ae({id:"chat"})}function a(u){Bn(),mt.value="resume",n(),Vi(u),Ae({id:"chat"})}function c(u){u.preventDefault();const h=i.trim().toUpperCase();h&&(Bn(),mt.value="resume",n(),Vi(h),Ae({id:"chat"}))}return l("div",{class:"jex-home",children:[xt.value&&l("div",{class:"jex-session-prompt",role:"status",children:l("div",{class:"jex-session-prompt-text",children:r.sessionLocked})}),l("div",{class:"jex-home-hero",children:[l("div",{class:"jex-home-avatar",children:[l(Zi,{size:24}),l("span",{class:"jex-home-status-dot"})]}),l("div",{class:"jex-home-hero-text",children:[l("h2",{class:"jex-home-title",children:t}),l("span",{class:"jex-home-status",children:r.statusOnline})]})]}),l("form",{class:"jex-home-lookup",onSubmit:c,children:[l("input",{class:"jex-home-lookup-input",type:"text",placeholder:r.referencePlaceholder,value:i,onInput:u=>{o(u.currentTarget.value)}}),l("button",{class:"jex-home-lookup-submit",type:"submit",disabled:!i.trim(),children:r.resume})]}),l("div",{class:"jex-home-actions",children:[V.value.length>0&&l("div",{class:"jex-home-history",children:V.value.slice().reverse().map(u=>l("button",{class:"jex-home-resume-card",onClick:()=>{a(u.ref)},children:[l("div",{class:"jex-home-resume-top",children:[l("span",{class:"jex-home-resume-label",children:r.resumeListLabel}),l("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",class:"jex-home-resume-arrow",children:l("path",{d:"M6 3l5 5-5 5",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})})]}),l("span",{class:"jex-home-resume-ref",children:u.ref}),l("span",{class:"jex-home-resume-meta",children:r.resumeListTimestamp.replace("{minutes}",String(Math.max(1,Math.round((Date.now()-u.lastActivityAt)/6e4))))})]},u.ref))}),l("button",{class:"jex-home-new-btn",onClick:s,children:V.value.length>0?r.startNewConversation:r.chatWith.replace("{title}",t)})]})]})}function Dl({title:t}){const e=_();return l("div",{class:"jex-selection",children:[l("h2",{class:"jex-selection-title",children:e.howCanWeHelp}),l("div",{class:"jex-selection-options",children:[l("button",{class:"jex-selection-option",onClick:()=>Ae({id:"chat"}),children:[l("span",{class:"jex-selection-icon",children:"๐ฌ"}),l("span",{class:"jex-selection-label",children:e.chatWith.replace("{title}",t)}),l("span",{class:"jex-selection-sub",children:e.getInstantHelp})]}),l("button",{class:"jex-selection-option",onClick:()=>Ae({id:"form"}),children:[l("span",{class:"jex-selection-icon",children:"๐"}),l("span",{class:"jex-selection-label",children:e.submitTicket}),l("span",{class:"jex-selection-sub",children:e.replyByEmail})]})]})]})}const Ul=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();const Yi=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const Fl=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase());const Xi=t=>{const e=Fl(t);return e.charAt(0).toUpperCase()+e.slice(1)};var Ql={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"};const Vl=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1};const Wl=({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,children:i,iconNode:o,class:s="",...a})=>G("svg",{...Ql,width:String(e),height:e,stroke:t,"stroke-width":r?Number(n)*24/Number(e):n,class:["lucide",s].join(" "),...!i&&!Vl(a)&&{"aria-hidden":"true"},...a},[...o.map(([c,u])=>G(c,u)),...ie(i)]);const Hl=(t,e)=>{const n=({class:r="",className:i="",children:o,...s})=>G(Wl,{...s,iconNode:e,class:Ul(`lucide-${Yi(Xi(t))}`,`lucide-${Yi(t)}`,r,i)},o);return n.displayName=Xi(t),n};const Gl=Hl("corner-up-left",[["path",{d:"M20 20v-7a4 4 0 0 0-4-4H4",key:"1nkjon"}],["path",{d:"M9 14 4 9l5-5",key:"102s5s"}]]);function Un(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var $e=Un();function eo(t){$e=t}var Ee={exec:()=>null};function w(t,e=""){let n=typeof t=="string"?t:t.source,r={replace:(i,o)=>{let s=typeof o=="string"?o:o.source;return s=s.replace(F.caret,"$1"),n=n.replace(i,s),r},getRegex:()=>new RegExp(n,e)};return r}var Jl=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),F={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}>`)},Kl=/^(?:[ \t]*(?:\n|$))+/,Zl=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Yl=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,bt=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Xl=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Fn=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,to=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,no=w(to).replace(/bull/g,Fn).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),ec=w(to).replace(/bull/g,Fn).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Qn=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,tc=/^[^\n]+/,Vn=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,nc=w(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Vn).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),rc=w(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Fn).getRegex(),Qt="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Wn=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,ic=w("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Wn).replace("tag",Qt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ro=w(Qn).replace("hr",bt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Qt).getRegex(),oc=w(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",ro).getRegex(),Hn={blockquote:oc,code:Zl,def:nc,fences:Yl,heading:Xl,hr:bt,html:ic,lheading:no,list:rc,newline:Kl,paragraph:ro,table:Ee,text:tc},io=w("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",bt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Qt).getRegex(),sc={...Hn,lheading:ec,table:io,paragraph:w(Qn).replace("hr",bt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",io).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Qt).getRegex()},ac={...Hn,html:w(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Wn).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Ee,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:w(Qn).replace("hr",bt).replace("heading",` *#{1,6} *[^
|
|
11
|
+
]`).replace("lheading",no).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},lc=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,cc=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,oo=/^( {2,}|\\)\n(?!\s*$)/,uc=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,He=/[\p{P}\p{S}]/u,Vt=/[\s\p{P}\p{S}]/u,Gn=/[^\s\p{P}\p{S}]/u,dc=w(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Vt).getRegex(),so=/(?!~)[\p{P}\p{S}]/u,hc=/(?!~)[\s\p{P}\p{S}]/u,fc=/(?:[^\s\p{P}\p{S}]|~)/u,pc=w(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Jl?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),ao=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,gc=w(ao,"u").replace(/punct/g,He).getRegex(),mc=w(ao,"u").replace(/punct/g,so).getRegex(),lo="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",xc=w(lo,"gu").replace(/notPunctSpace/g,Gn).replace(/punctSpace/g,Vt).replace(/punct/g,He).getRegex(),bc=w(lo,"gu").replace(/notPunctSpace/g,fc).replace(/punctSpace/g,hc).replace(/punct/g,so).getRegex(),vc=w("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Gn).replace(/punctSpace/g,Vt).replace(/punct/g,He).getRegex(),yc=w(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,He).getRegex(),wc="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",kc=w(wc,"gu").replace(/notPunctSpace/g,Gn).replace(/punctSpace/g,Vt).replace(/punct/g,He).getRegex(),_c=w(/\\(punct)/,"gu").replace(/punct/g,He).getRegex(),jc=w(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Sc=w(Wn).replace("(?:-->|$)","-->").getRegex(),Cc=w("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Sc).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Wt=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Tc=w(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Wt).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),co=w(/^!?\[(label)\]\[(ref)\]/).replace("label",Wt).replace("ref",Vn).getRegex(),uo=w(/^!?\[(ref)\](?:\[\])?/).replace("ref",Vn).getRegex(),Rc=w("reflink|nolink(?!\\()","g").replace("reflink",co).replace("nolink",uo).getRegex(),ho=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Jn={_backpedal:Ee,anyPunctuation:_c,autolink:jc,blockSkip:pc,br:oo,code:cc,del:Ee,delLDelim:Ee,delRDelim:Ee,emStrongLDelim:gc,emStrongRDelimAst:xc,emStrongRDelimUnd:vc,escape:lc,link:Tc,nolink:uo,punctuation:dc,reflink:co,reflinkSearch:Rc,tag:Cc,text:uc,url:Ee},Ac={...Jn,link:w(/^!?\[(label)\]\((.*?)\)/).replace("label",Wt).getRegex(),reflink:w(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Wt).getRegex()},Kn={...Jn,emStrongRDelimAst:bc,emStrongLDelim:mc,delLDelim:yc,delRDelim:kc,url:w(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",ho).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:w(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",ho).getRegex()},$c={...Kn,br:w(oo).replace("{2,}","*").getRegex(),text:w(Kn.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ht={normal:Hn,gfm:sc,pedantic:ac},vt={normal:Jn,gfm:Kn,breaks:$c,pedantic:Ac},Ec={"&":"&","<":"<",">":">",'"':""","'":"'"},fo=t=>Ec[t];function le(t,e){if(e){if(F.escapeTest.test(t))return t.replace(F.escapeReplace,fo)}else if(F.escapeTestNoEncode.test(t))return t.replace(F.escapeReplaceNoEncode,fo);return t}function po(t){try{t=encodeURI(t).replace(F.percentDecode,"%")}catch{return null}return t}function go(t,e){let n=t.replace(F.findPipe,(o,s,a)=>{let c=!1,u=s;for(;--u>=0&&a[u]==="\\";)c=!c;return c?"|":" |"}),r=n.split(F.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(F.slashPipe,"|");return r}function yt(t,e,n){let r=t.length;if(r===0)return"";let i=0;for(;i<r&&t.charAt(r-i-1)===e;)i++;return t.slice(0,r-i)}function Pc(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function Ic(t,e=0){let n=e,r="";for(let i of t)if(i===" "){let o=4-n%4;r+=" ".repeat(o),n+=o}else r+=i,n++;return r}function mo(t,e,n,r,i){let o=e.href,s=e.title||null,a=t[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let c={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:o,title:s,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,c}function qc(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let i=r[1];return e.split(`
|
|
12
|
+
`).map(o=>{let s=o.match(n.other.beginningSpace);if(s===null)return o;let[a]=s;return a.length>=i.length?o.slice(i.length):o}).join(`
|
|
13
|
+
`)}var Gt=class{options;rules;lexer;constructor(t){this.options=t||$e}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let n=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?n:yt(n,`
|
|
14
|
+
`)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],r=qc(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){let r=yt(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:yt(e[0],`
|
|
15
|
+
`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=yt(e[0],`
|
|
16
16
|
`).split(`
|
|
17
|
-
`),r="",i="",o=[];for(;n.length>0;){let s=!1,
|
|
18
|
-
`),
|
|
17
|
+
`),r="",i="",o=[];for(;n.length>0;){let s=!1,a=[],c;for(c=0;c<n.length;c++)if(this.rules.other.blockquoteStart.test(n[c]))a.push(n[c]),s=!0;else if(!s)a.push(n[c]);else break;n=n.slice(c);let u=a.join(`
|
|
18
|
+
`),h=u.replace(this.rules.other.blockquoteSetextReplace,`
|
|
19
19
|
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
20
20
|
${u}`:u,i=i?`${i}
|
|
21
|
-
${
|
|
21
|
+
${h}`:h;let d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,o,!0),this.lexer.state.top=d,n.length===0)break;let f=o.at(-1);if(f?.type==="code")break;if(f?.type==="blockquote"){let p=f,g=p.raw+`
|
|
22
22
|
`+n.join(`
|
|
23
|
-
`),
|
|
23
|
+
`),x=this.blockquote(g);o[o.length-1]=x,r=r.substring(0,r.length-p.raw.length)+x.raw,i=i.substring(0,i.length-p.text.length)+x.text;break}else if(f?.type==="list"){let p=f,g=p.raw+`
|
|
24
24
|
`+n.join(`
|
|
25
|
-
`),
|
|
26
|
-
`);continue}}return{type:"blockquote",raw:r,tokens:o,text:i}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[1].trim(),r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let o=this.rules.other.listItemRegex(n),s=!1;for(;t;){let
|
|
25
|
+
`),x=this.list(g);o[o.length-1]=x,r=r.substring(0,r.length-f.raw.length)+x.raw,i=i.substring(0,i.length-p.raw.length)+x.raw,n=g.substring(o.at(-1).raw.length).split(`
|
|
26
|
+
`);continue}}return{type:"blockquote",raw:r,tokens:o,text:i}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[1].trim(),r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let o=this.rules.other.listItemRegex(n),s=!1;for(;t;){let c=!1,u="",h="";if(!(e=o.exec(t))||this.rules.block.hr.test(t))break;u=e[0],t=t.substring(u.length);let d=Ic(e[2].split(`
|
|
27
27
|
`,1)[0],e[1].length),f=t.split(`
|
|
28
|
-
`,1)[0],p=!
|
|
29
|
-
`,t=t.substring(f.length+1),
|
|
30
|
-
`,1)[0],
|
|
31
|
-
`+
|
|
32
|
-
`+f}p=!f.trim(),u+=
|
|
33
|
-
`,t=t.substring(
|
|
34
|
-
`):[],o={type:"table",raw:e[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let s of r)this.rules.other.tableAlignRight.test(s)?o.align.push("right"):this.rules.other.tableAlignCenter.test(s)?o.align.push("center"):this.rules.other.tableAlignLeft.test(s)?o.align.push("left"):o.align.push(null);for(let s=0;s<n.length;s++)o.header.push({text:n[s],tokens:this.lexer.inline(n[s]),header:!0,align:o.align[s]});for(let s of i)o.rows.push(
|
|
35
|
-
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let o=
|
|
36
|
-
`),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],r=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(
|
|
28
|
+
`,1)[0],p=!d.trim(),g=0;if(this.options.pedantic?(g=2,h=d.trimStart()):p?g=e[1].length+1:(g=d.search(this.rules.other.nonSpaceChar),g=g>4?1:g,h=d.slice(g),g+=e[1].length),p&&this.rules.other.blankLine.test(f)&&(u+=f+`
|
|
29
|
+
`,t=t.substring(f.length+1),c=!0),!c){let x=this.rules.other.nextBulletRegex(g),v=this.rules.other.hrRegex(g),m=this.rules.other.fencesBeginRegex(g),b=this.rules.other.headingBeginRegex(g),E=this.rules.other.htmlBeginRegex(g),q=this.rules.other.blockquoteBeginRegex(g);for(;t;){let z=t.split(`
|
|
30
|
+
`,1)[0],L;if(f=z,this.options.pedantic?(f=f.replace(this.rules.other.listReplaceNesting," "),L=f):L=f.replace(this.rules.other.tabCharGlobal," "),m.test(f)||b.test(f)||E.test(f)||q.test(f)||x.test(f)||v.test(f))break;if(L.search(this.rules.other.nonSpaceChar)>=g||!f.trim())h+=`
|
|
31
|
+
`+L.slice(g);else{if(p||d.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||m.test(d)||b.test(d)||v.test(d))break;h+=`
|
|
32
|
+
`+f}p=!f.trim(),u+=z+`
|
|
33
|
+
`,t=t.substring(z.length+1),d=L.slice(g)}}i.loose||(s?i.loose=!0:this.rules.other.doubleBlankLine.test(u)&&(s=!0)),i.items.push({type:"list_item",raw:u,task:!!this.options.gfm&&this.rules.other.listIsTask.test(h),loose:!1,text:h,tokens:[]}),i.raw+=u}let a=i.items.at(-1);if(a)a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let c of i.items){if(this.lexer.state.top=!1,c.tokens=this.lexer.blockTokens(c.text,[]),c.task){if(c.text=c.text.replace(this.rules.other.listReplaceTask,""),c.tokens[0]?.type==="text"||c.tokens[0]?.type==="paragraph"){c.tokens[0].raw=c.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),c.tokens[0].text=c.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let h=this.lexer.inlineQueue.length-1;h>=0;h--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)){this.lexer.inlineQueue[h].src=this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask,"");break}}let u=this.rules.other.listTaskCheckbox.exec(c.raw);if(u){let h={type:"checkbox",raw:u[0]+" ",checked:u[0]!=="[ ]"};c.checked=h.checked,i.loose?c.tokens[0]&&["paragraph","text"].includes(c.tokens[0].type)&&"tokens"in c.tokens[0]&&c.tokens[0].tokens?(c.tokens[0].raw=h.raw+c.tokens[0].raw,c.tokens[0].text=h.raw+c.tokens[0].text,c.tokens[0].tokens.unshift(h)):c.tokens.unshift({type:"paragraph",raw:h.raw,text:h.raw,tokens:[h]}):c.tokens.unshift(h)}}if(!i.loose){let u=c.tokens.filter(d=>d.type==="space"),h=u.length>0&&u.some(d=>this.rules.other.anyLine.test(d.raw));i.loose=h}}if(i.loose)for(let c of i.items){c.loose=!0;for(let u of c.tokens)u.type==="text"&&(u.type="paragraph")}return i}}html(t){let e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){let e=this.rules.block.def.exec(t);if(e){let n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:e[0],href:r,title:i}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=go(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
34
|
+
`):[],o={type:"table",raw:e[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let s of r)this.rules.other.tableAlignRight.test(s)?o.align.push("right"):this.rules.other.tableAlignCenter.test(s)?o.align.push("center"):this.rules.other.tableAlignLeft.test(s)?o.align.push("left"):o.align.push(null);for(let s=0;s<n.length;s++)o.header.push({text:n[s],tokens:this.lexer.inline(n[s]),header:!0,align:o.align[s]});for(let s of i)o.rows.push(go(s,o.header.length).map((a,c)=>({text:a,tokens:this.lexer.inline(a),header:!1,align:o.align[c]})));return o}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let n=e[1].trim();return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let n=e[1].charAt(e[1].length-1)===`
|
|
35
|
+
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let o=yt(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=Pc(e[2],"()");if(o===-2)return;if(o>-1){let s=(e[0].indexOf("!")===0?5:4)+e[1].length+o;e[2]=e[2].substring(0,o),e[0]=e[0].substring(0,s).trim(),e[3]=""}}let r=e[2],i="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(r);o&&(r=o[1],i=o[3])}else i=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),mo(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=e[r.toLowerCase()];if(!i){let o=n[0].charAt(0);return{type:"text",raw:o,text:o}}return mo(n,i,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let r=this.rules.inline.emStrongLDelim.exec(t);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,o,s,a=i,c=0,u=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,e=e.slice(-1*t.length+i);(r=u.exec(e))!=null;){if(o=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!o)continue;if(s=[...o].length,r[3]||r[4]){a+=s;continue}else if((r[5]||r[6])&&i%3&&!((i+s)%3)){c+=s;continue}if(a-=s,a>0)continue;s=Math.min(s,s+a+c);let h=[...r[0]][0].length,d=t.slice(0,i+r.index+h+s);if(Math.min(i,s)%2){let p=d.slice(1,-1);return{type:"em",raw:d,text:p,tokens:this.lexer.inlineTokens(p)}}let f=d.slice(2,-2);return{type:"strong",raw:d,text:f,tokens:this.lexer.inlineTokens(f)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,n=""){let r=this.rules.inline.delLDelim.exec(t);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,o,s,a=i,c=this.rules.inline.delRDelim;for(c.lastIndex=0,e=e.slice(-1*t.length+i);(r=c.exec(e))!=null;){if(o=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!o||(s=[...o].length,s!==i))continue;if(r[3]||r[4]){a+=s;continue}if(a-=s,a>0)continue;s=Math.min(s,s+a);let u=[...r[0]][0].length,h=t.slice(0,i+r.index+u+s),d=h.slice(i,-i);return{type:"del",raw:h,text:d,tokens:this.lexer.inlineTokens(d)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let n,r;return e[2]==="@"?(n=e[1],r="mailto:"+n):(n=e[1],r=n),{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let n,r;if(e[2]==="@")n=e[0],r="mailto:"+n;else{let i;do i=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(i!==e[0]);n=e[0],e[1]==="www."?r="http://"+e[0]:r=e[0]}return{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:n}}}},te=class er{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||$e,this.options.tokenizer=this.options.tokenizer||new Gt,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:F,block:Ht.normal,inline:vt.normal};this.options.pedantic?(n.block=Ht.pedantic,n.inline=vt.pedantic):this.options.gfm&&(n.block=Ht.gfm,this.options.breaks?n.inline=vt.breaks:n.inline=vt.gfm),this.tokenizer.rules=n}static get rules(){return{block:Ht,inline:vt}}static lex(e,n){return new er(n).lex(e)}static lexInline(e,n){return new er(n).inlineTokens(e)}lex(e){e=e.replace(F.carriageReturn,`
|
|
36
|
+
`),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],r=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(F.tabCharGlobal," ").replace(F.spaceLine,""));e;){let i;if(this.options.extensions?.block?.some(s=>(i=s.call({lexer:this},e,n))?(e=e.substring(i.raw.length),n.push(i),!0):!1))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let s=n.at(-1);i.raw.length===1&&s!==void 0?s.raw+=`
|
|
37
37
|
`:n.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let s=n.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(`
|
|
38
38
|
`)?"":`
|
|
39
39
|
`)+i.raw,s.text+=`
|
|
40
40
|
`+i.text,this.inlineQueue.at(-1).src=s.text):n.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);let s=n.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(`
|
|
41
41
|
`)?"":`
|
|
42
42
|
`)+i.raw,s.text+=`
|
|
43
|
-
`+i.raw,this.inlineQueue.at(-1).src=s.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},n.push(i));continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),n.push(i);continue}let o=e;if(this.options.extensions?.startBlock){let s=1/0,
|
|
43
|
+
`+i.raw,this.inlineQueue.at(-1).src=s.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},n.push(i));continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),n.push(i);continue}let o=e;if(this.options.extensions?.startBlock){let s=1/0,a=e.slice(1),c;this.options.extensions.startBlock.forEach(u=>{c=u.call({lexer:this},a),typeof c=="number"&&c>=0&&(s=Math.min(s,c))}),s<1/0&&s>=0&&(o=e.substring(0,s+1))}if(this.state.top&&(i=this.tokenizer.paragraph(o))){let s=n.at(-1);r&&s?.type==="paragraph"?(s.raw+=(s.raw.endsWith(`
|
|
44
44
|
`)?"":`
|
|
45
45
|
`)+i.raw,s.text+=`
|
|
46
46
|
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):n.push(i),r=o.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let s=n.at(-1);s?.type==="text"?(s.raw+=(s.raw.endsWith(`
|
|
47
47
|
`)?"":`
|
|
48
48
|
`)+i.raw,s.text+=`
|
|
49
|
-
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):n.push(i);continue}if(e){let s="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(s);break}else throw new Error(s)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){this.tokenizer.lexer=this;let r=e,i=null;if(this.tokens.links){let
|
|
50
|
-
`;return r?'<pre><code class="language-'+
|
|
51
|
-
`:"<pre><code>"+(n?i:
|
|
49
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):n.push(i);continue}if(e){let s="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(s);break}else throw new Error(s)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){this.tokenizer.lexer=this;let r=e,i=null;if(this.tokens.links){let c=Object.keys(this.tokens.links);if(c.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)c.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,i.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let o;for(;(i=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)o=i[2]?i[2].length:0,r=r.slice(0,i.index+o)+"["+"a".repeat(i[0].length-o-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let s=!1,a="";for(;e;){s||(a=""),s=!1;let c;if(this.options.extensions?.inline?.some(h=>(c=h.call({lexer:this},e,n))?(e=e.substring(c.raw.length),n.push(c),!0):!1))continue;if(c=this.tokenizer.escape(e)){e=e.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.tag(e)){e=e.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.link(e)){e=e.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(c.raw.length);let h=n.at(-1);c.type==="text"&&h?.type==="text"?(h.raw+=c.raw,h.text+=c.text):n.push(c);continue}if(c=this.tokenizer.emStrong(e,r,a)){e=e.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.codespan(e)){e=e.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.br(e)){e=e.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.del(e,r,a)){e=e.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.autolink(e)){e=e.substring(c.raw.length),n.push(c);continue}if(!this.state.inLink&&(c=this.tokenizer.url(e))){e=e.substring(c.raw.length),n.push(c);continue}let u=e;if(this.options.extensions?.startInline){let h=1/0,d=e.slice(1),f;this.options.extensions.startInline.forEach(p=>{f=p.call({lexer:this},d),typeof f=="number"&&f>=0&&(h=Math.min(h,f))}),h<1/0&&h>=0&&(u=e.substring(0,h+1))}if(c=this.tokenizer.inlineText(u)){e=e.substring(c.raw.length),c.raw.slice(-1)!=="_"&&(a=c.raw.slice(-1)),s=!0;let h=n.at(-1);h?.type==="text"?(h.raw+=c.raw,h.text+=c.text):n.push(c);continue}if(e){let h="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(h);break}else throw new Error(h)}}return n}},Jt=class{options;parser;constructor(t){this.options=t||$e}space(t){return""}code({text:t,lang:e,escaped:n}){let r=(e||"").match(F.notSpaceStart)?.[0],i=t.replace(F.endingNewline,"")+`
|
|
50
|
+
`;return r?'<pre><code class="language-'+le(r)+'">'+(n?i:le(i,!0))+`</code></pre>
|
|
51
|
+
`:"<pre><code>"+(n?i:le(i,!0))+`</code></pre>
|
|
52
52
|
`}blockquote({tokens:t}){return`<blockquote>
|
|
53
53
|
${this.parser.parse(t)}</blockquote>
|
|
54
54
|
`}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
|
|
55
55
|
`}hr(t){return`<hr>
|
|
56
|
-
`}list(t){let e=t.ordered,n=t.start,r="";for(let s=0;s<t.items.length;s++){let
|
|
56
|
+
`}list(t){let e=t.ordered,n=t.start,r="";for(let s=0;s<t.items.length;s++){let a=t.items[s];r+=this.listitem(a)}let i=e?"ol":"ul",o=e&&n!==1?' start="'+n+'"':"";return"<"+i+o+`>
|
|
57
57
|
`+r+"</"+i+`>
|
|
58
58
|
`}listitem(t){return`<li>${this.parser.parse(t.tokens)}</li>
|
|
59
59
|
`}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
|
|
@@ -64,7 +64,7 @@ ${this.parser.parse(t)}</blockquote>
|
|
|
64
64
|
`}tablerow({text:t}){return`<tr>
|
|
65
65
|
${t}</tr>
|
|
66
66
|
`}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
|
|
67
|
-
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${
|
|
68
|
-
Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+ne(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},_e=new _c;function k(t,e){return _e.parse(t,e)}k.options=k.setOptions=function(t){return _e.setOptions(t),k.defaults=_e.defaults,Vi(k.defaults),k},k.getDefaults=Pn,k.defaults=ve,k.use=function(...t){return _e.use(...t),k.defaults=_e.defaults,Vi(k.defaults),k},k.walkTokens=function(t,e){return _e.walkTokens(t,e)},k.parseInline=_e.parseInline,k.Parser=K,k.parser=K.parse,k.Renderer=zt,k.TextRenderer=Un,k.Lexer=G,k.lexer=G.lex,k.Tokenizer=Nt,k.Hooks=at,k.parse=k,k.options,k.setOptions,k.use,k.walkTokens,k.parseInline,K.parse,G.lex,k.setOptions({breaks:!0,gfm:!0});function kc({text:t}){const e=J(()=>{if(!t)return"";const n=k.parse(t);return typeof n=="string"?n:""},[t]);return c("div",{class:"jex-md",dangerouslySetInnerHTML:{__html:e}})}const qe=R("");function jc(t){if(!t)return;const e=t.trim().split(/\s+/)[0];if(!e)return;const n=`@${e} `,r=qe.value;r.includes(n)||r.includes(`@${e}`)||(qe.value=r.trimStart()?`${n}${r.trimStart()}`:n)}const lt=R(null),ao=R(Date.now()),se=R([]),Sc=4,Cc=8*1024*1024;function Tc(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`att-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,11)}`}function Rc(t){const e=Array.from(t).filter(i=>i.type.startsWith("image/")&&i.size<=Cc);if(e.length===0)return;const n=Sc-se.value.length;if(n<=0)return;const r=e.slice(0,n).map(i=>({id:Tc(),file:i,previewUrl:URL.createObjectURL(i)}));se.value=[...se.value,...r]}function $c(t){const e=se.value.find(n=>n.id===t);e&&URL.revokeObjectURL(e.previewUrl),se.value=se.value.filter(n=>n.id!==t)}function Ac(){for(const t of se.value)URL.revokeObjectURL(t.previewUrl);se.value=[]}BigInt("-9223372036854775808"),BigInt("9223372036854775807"),BigInt("0"),BigInt("8"),BigInt("256");const Ec=Symbol.for("functionName"),Pc=Symbol.for("toReferencePath");function lo(t=[]){const e={get(n,r){if(typeof r=="string"){const i=[...t,r];return lo(i)}else if(r===Ec){if(t.length<2){const s=["api",...t].join(".");throw new Error(`API path is expected to be of the form \`api.moduleName.functionName\`. Found: \`${s}\``)}const i=t.slice(0,-1).join("/"),o=t[t.length-1];return o==="default"?i:i+":"+o}else return r===Symbol.toStringTag?"FunctionReference":void 0}};return new Proxy({},e)}const Ic=lo();function co(t,e){const n={get(r,i){if(typeof i=="string"){const o=[...e,i];return co(t,o)}else if(i===Pc){if(e.length<1){const o=[t,...e].join(".");throw new Error(`API path is expected to be of the form \`${t}.childComponent.functionName\`. Found: \`${o}\``)}return"_reference/childComponent/"+e.join("/")}else return}};return new Proxy({},n)}const Lc=()=>co("components",[]),Oe=Ic;Lc();function Mc({sessionId:t,visitorId:e,ensureSession:n}){const r=kt(Oe.functions.chat.public.conversations.send);return async function(o){const s=t&&e?{sessionId:t,visitorId:e}:await n();if(s){qe.value="",Ac();try{const l=await r({sessionId:s.sessionId,visitorId:s.visitorId,content:o});l.ok?Cn(s.visitorId):l.reason==="rate_limited"&&(lt.value=Date.now()+l.retryAfterMs)}catch(l){console.error("[jexity] Failed to send message:",l)}}}}function qc(){const t=lt.value,e=ao.value;S(()=>{if(t===null)return;const i=setInterval(()=>{ao.value=Date.now()},1e3),o=setTimeout(()=>{lt.value=null},Math.max(0,t-Date.now()));return()=>{clearInterval(i),clearTimeout(o)}},[t]);const n=t!==null,r=n?Math.max(0,Math.ceil((t-e)/1e3)):0;return{isActive:n,remainingSeconds:r}}function Oc(){const t=$(),{isActive:e,remainingSeconds:n}=qc();return e?c("div",{class:"jex-rate-limit-notice",role:"status","aria-live":"polite",children:t.errorRateLimited.replace("{seconds}",String(n))}):null}const Ne=R(null);function Nc(){const t=$(),e=Ne.value;if(e===null)return null;const n=e==="no-token"?t.errorSessionNoToken:e==="unauthorized"?t.errorSessionUnauthorized:e==="network"?t.errorNetwork:t.somethingWentWrong;return c("div",{class:"jex-session-error-notice",role:"alert","aria-live":"assertive",children:n})}function zc({size:t=18}){return c("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:[c("path",{d:"M22 2 11 13"}),c("path",{d:"M22 2 15 22 11 13 2 9l20-7z"})]})}const uo=132;function Bc({onSend:t}){const e=le(null),n=le(null);S(()=>{const l=e.current;if(!l)return;l.style.height="0";const a=Math.min(l.scrollHeight,uo);l.style.height=`${a}px`,l.style.overflowY=l.scrollHeight>uo?"auto":"hidden"},[qe.value]);function r(l){l.key==="Enter"&&!l.shiftKey&&(l.preventDefault(),t())}function i(){n.current?.click()}function o(l){const a=l.currentTarget;a.files&&a.files.length>0&&Rc(a.files),a.value=""}function s(l){const a=l.target;(a===l.currentTarget||!a.closest("button, textarea, img"))&&e.current?.focus()}return{textareaRef:e,fileInputRef:n,onKeyDown:r,onAttachClick:i,onFilesPicked:o,onCardClick:s}}function Uc({isStreaming:t,disabled:e,inputDisabled:n,onSend:r,onFocus:i}){const o=$(),s=qe,l=se,{textareaRef:a,fileInputRef:u,onKeyDown:d,onAttachClick:h,onFilesPicked:f,onCardClick:p}=Bc({onSend:r}),g=s.value.trim().length>0,m=l.value.length>0,x=(g||m)&&!e;return c("div",{class:"jex-composer-card",onClick:p,children:[m&&c("div",{class:"jex-composer-attachments",role:"list",children:l.value.map(b=>c("div",{class:"jex-attachment-chip",role:"listitem",children:[c("img",{src:b.previewUrl,alt:b.file.name,class:"jex-attachment-thumb"}),c("button",{type:"button",class:"jex-attachment-remove","aria-label":o.removeAttachmentAriaLabel,onClick:()=>{$c(b.id)},children:c("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:[c("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),c("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},b.id))}),c("textarea",{ref:a,class:"jex-composer-textarea","aria-label":o.inputPlaceholder,placeholder:t?o.aiThinking:o.inputPlaceholder,value:s.value,rows:1,onInput:b=>{s.value=b.currentTarget.value},onKeyDown:d,onFocus:i,disabled:n}),c("div",{class:"jex-composer-actions",children:[c("div",{class:"jex-composer-actions-left",children:[c("input",{ref:u,class:"jex-visually-hidden",type:"file",accept:"image/*",multiple:!0,onChange:f,tabIndex:-1,"aria-hidden":"true"}),c("button",{type:"button",class:"jex-attach-btn","aria-label":o.attachComingSoon,title:o.attachComingSoon,disabled:!0,onClick:h,children:c("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:c("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})})})]}),c("button",{class:`jex-send-btn${x?" jex-send-btn-active":""}`,type:"button",onClick:r,"aria-label":o.sendAriaLabel,disabled:e||!g&&!m,children:c(zc,{size:16})})]})]})}function ho({variant:t,isOpen:e=!1,onAcknowledge:n}){const r=$(),i=At.value;return t==="explicit"?e?c("div",{class:"jex-privacy-explicit",role:"dialog","aria-label":r.privacyExplicitTitle,children:[c("div",{class:"jex-privacy-explicit-content",children:[c("div",{class:"jex-privacy-explicit-icon","aria-hidden":"true",children:c("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:c("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"})})}),c("div",{class:"jex-privacy-explicit-copy",children:[c("div",{class:"jex-privacy-explicit-title",children:r.privacyExplicitTitle}),c("p",{class:"jex-privacy-explicit-body",children:[r.privacyExplicitBodyPre," ",c("a",{href:i,target:"_blank",rel:"noopener noreferrer",class:"jex-privacy-notice-link",children:r.privacyPolicyLinkText}),"."]})]})]}),c("button",{type:"button",class:"jex-privacy-explicit-button",onClick:n,children:r.privacyExplicitButton})]}):null:c("p",{class:"jex-privacy-chip",children:[c("span",{class:"jex-privacy-chip-icon","aria-hidden":"true",children:c("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:c("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"})})}),c("a",{href:i,target:"_blank",rel:"noopener noreferrer",class:"jex-privacy-chip-link",children:r.privacyChipText})]})}function Fc({sessionId:t,visitorId:e,isLoading:n,isStreaming:r,sessionStatus:i,ensureSession:o,onStartFresh:s}){const l=$(),a=qe,u=Ci.value,[d,h]=C({open:!1,acknowledged:!1}),f=Mc({sessionId:t,visitorId:e,ensureSession:o}),p=lt.value!==null&<.value>Date.now(),g=n||r||p,m=u==="explicit"&&!d.acknowledged,x=u==="explicit"&&d.open;function b(){m&&h(M=>({...M,open:!0}))}function v(){h({open:!1,acknowledged:!0})}if(S(()=>{h({open:!1,acknowledged:!1})},[t]),i==="resolved")return c("div",{class:"jex-chat-input-resolved",children:[c("div",{class:"jex-resolved-notice",children:l.sessionResolved}),c("button",{class:"jex-resolved-new-btn",type:"button",onClick:()=>{s()},children:l.startNewConversation})]});async function L(){const M=a.value.trim();if(!(!M||g)){if(m){h(F=>({...F,open:!0}));return}await f(M)}}return c("div",{class:"jex-chat-input",children:[c(Oc,{}),c(Nc,{}),u==="chip"&&c(ho,{variant:"chip"}),c("div",{class:`jex-chat-input-composer-gate${x?" jex-chat-input-composer-gate-open":""}`,children:[c(Uc,{isStreaming:r,disabled:g,inputDisabled:n||r||x,onSend:L,onFocus:b}),u==="explicit"&&c(ho,{variant:"explicit",isOpen:d.open,onAcknowledge:v})]})]})}function Qc(t){const e=t.trim().split(/\s+/).filter(Boolean);return e.length===0?"?":e.map(n=>n[0]).join("").slice(0,2).toUpperCase()}function ze({text:t,streaming:e,error:n,authorId:r,authorName:i,authorImage:o,botAvatarUrl:s}){const l=$(),a=!!r,[u,d]=C(!1),h=Ce(()=>d(!0),[]),f=l.replyTo.replace("{name}",i??""),p=["jex-message bot",n?"jex-message-error":""].filter(Boolean).join(" ");return c("div",{class:"jex-message-row bot",children:[c("div",{class:`jex-avatar ${a?"jex-avatar-agent":"jex-avatar-bot"}`,children:a&&o&&!u?c("img",{src:o,alt:i??"",class:"jex-avatar-img",onError:h}):a?c("span",{class:"jex-avatar-initials",children:Qc(i??"")}):s&&!u?c("img",{src:s,alt:"",class:"jex-avatar-img",onError:h}):c(En,{size:14})}),c("div",{class:"jex-message-content",children:[c("div",{class:p,children:[c(kc,{text:t}),e&&c("span",{class:"jex-streaming-cursor"})]}),a&&i&&c("div",{class:"jex-message-author-row",children:[c("span",{class:"jex-message-author",children:i}),c("button",{type:"button",class:"jex-reply-tag-btn","aria-label":f,title:f,onClick:()=>{jc(i)},children:c(Ml,{size:12})})]})]})]})}function Dc({text:t}){return c("div",{class:"jex-message user",children:t})}function fo(){return kt(Oe.functions.chat.public.helpdesk.submitEscalation)}function Vc({message:t,sessionId:e,visitorId:n}){const r=$();return t.formData?c("div",{class:"jex-inline-form-submitted",children:[c("span",{class:"jex-inline-form-check",children:"โ"}),c("div",{children:[c("div",{class:"jex-inline-form-submitted-title",children:r.escalationSubmitted}),c("div",{class:"jex-inline-form-submitted-detail",children:[t.formData.visitorName," ยท ",t.formData.visitorEmail]})]})]}):c("div",{class:"jex-message-row bot",children:c(Hc,{messageId:t._id,sessionId:e,visitorId:n})})}function Hc({messageId:t,sessionId:e,visitorId:n}){const r=$(),[i,o]=C(""),[s,l]=C(""),[a,u]=C(!1),d=At.value,h=/^https?:\/\//i.test(d)?d:$t,f=fo();async function p(g){if(g.preventDefault(),!a){u(!0);try{await f({sessionId:e,visitorId:n,formMessageId:t,visitorName:i.trim(),visitorEmail:s.trim(),locale:xe.value})}catch(m){console.error("[FormMessage] Submit failed:",m),u(!1)}}}return c("div",{class:"jex-inline-form",children:[c("div",{class:"jex-inline-form-title",children:r.escalationFormTitle}),c("form",{class:"jex-form",onSubmit:g=>{p(g)},children:[c("input",{class:"jex-form-input",type:"text",placeholder:r.escalationNameLabel,value:i,required:!0,disabled:a,onInput:g=>{o(g.currentTarget.value)}}),c("input",{class:"jex-form-input",type:"email",placeholder:r.escalationEmailLabel,value:s,required:!0,disabled:a,onInput:g=>{l(g.currentTarget.value)}}),c("button",{class:"jex-form-submit",type:"submit",disabled:a,children:a?r.escalationSubmitting:r.escalationSubmit})]}),c("div",{class:"jex-inline-form-consent",children:[r.escalationConsent," ",c("a",{href:h,target:"_blank",rel:"noopener noreferrer",class:"jex-privacy-notice-link",children:r.escalationPrivacyLinkText}),"."]})]})}const Wc={crawl:"๐",file:"๐",snippet:"๐ก",qa:"โ"};function Jc({sources:t}){const e=$(),[n,r]=C(!1);return t.length===0?null:c("div",{class:"jex-sources-row",children:[c("button",{type:"button",class:"jex-sources-toggle",onClick:()=>{r(i=>!i)},"aria-expanded":n,children:[c("span",{class:"jex-sources-icon",children:"๐"}),c("span",{children:(t.length===1?e.sourcesCountOne:e.sourcesCountOther).replace("{count}",String(t.length))}),c("span",{class:`jex-sources-chevron${n?" jex-sources-chevron--open":""}`,children:"โพ"})]}),n?c("div",{class:"jex-sources-pills",children:t.map((i,o)=>{const s=i.sourceType==="crawl",l=Gc(i),a=s&&i.url?`${i.title}
|
|
69
|
-
${i.url}`:i.title,u=c(U,{children:[typeof i.id=="number"?c("span",{class:"jex-source-id",children:i.id}):null,c("span",{class:"jex-source-type",children:Wc[i.sourceType]}),c("span",{class:"jex-source-label",children:l}),c("span",{class:"jex-source-score",children:["ยท ",i.score.toFixed(2)]})]});return s&&i.url?c("a",{class:"jex-source-pill",href:i.url,target:"_blank",rel:"noopener noreferrer",title:a,children:u},o):c("span",{class:"jex-source-pill",title:a,children:u},o)})}):null]})}function Gc(t){if(t.sourceType==="crawl"&&t.url)try{const e=new URL(t.url);return!e.pathname||e.pathname==="/"?e.hostname:e.pathname}catch{}return t.title}function Kc(){return c("div",{class:"jex-typing",children:[c("span",{}),c("span",{}),c("span",{})]})}const Zc=/\s?\[\d+\]/g;function po(t){return t.replace(Zc,"")}function Yc({conversations:t,greeting:e,sessionNotFound:n,resumeFailed:r,onStartFresh:i,sessionId:o,visitorId:s}){const l=$(),a=le(null),[u,d]=C(null),h=le(null);return S(()=>{if(!s||!t||t.length===0)return;const f=t[t.length-1];f.role==="assistant"&&f.status!=="streaming"&&f._id!==h.current&&(h.current=f._id,Cn(s))},[t,s]),S(()=>{a.current?.scrollIntoView({behavior:"smooth"})},[t?.length,t?.at(-1)?.content]),c("div",{class:"jex-chat-messages",children:[c(ze,{text:e}),n&&r&&i?c("div",{class:"jex-session-prompt",children:[c("div",{class:"jex-session-prompt-text",children:l.sessionNotFoundPrompt}),c("button",{class:"jex-session-prompt-btn",type:"button",onClick:()=>{i()},children:l.startNewConversation})]}):n?c("div",{class:"jex-session-notice",children:l.sessionNotFound}):null,t?.map(f=>{if(f.contentType==="human-notice"){const g=f.noticeKind==="agent-joined"?l.noticeAgentJoined.replace("{name}",f.noticeData?.agentName??""):f.noticeKind==="human-requested"?l.noticeHumanRequested:f.noticeKind==="human-requested-form"?l.noticeHumanRequestedForm:f.noticeKind==="message-received"?l.noticeMessageReceived:f.noticeKind==="agent-handling"?l.noticeAgentHandling:f.content;return c(ze,{text:g},f._id)}if(f.contentType==="escalation-form"&&o&&s)return hl.value==="screen"&&!f.formData?u===f._id?null:c("div",{class:"jex-inline-form jex-inline-form-card",children:[c("div",{class:"jex-inline-form-title",children:l.escalationPromptTitle}),c("div",{class:"jex-inline-form-subtitle",children:l.escalationPromptSubtitle}),c("button",{class:"jex-form-submit",type:"button",onClick:()=>{ye({id:"escalation-form",formMessageId:f._id,sessionId:o,visitorId:s})},children:l.escalationPromptSubmit}),c("button",{class:"jex-escalation-skip",type:"button",onClick:()=>{d(f._id)},children:l.escalationSkip})]},f._id):c(Vc,{message:f,sessionId:o,visitorId:s},f._id);if(f.contentType==="escalation-confirm"){const g=f.noticeKind==="escalation-confirmed"?l.noticeEscalationConfirmed.replace("{name}",f.noticeData?.visitorName??"").replace("{email}",f.noticeData?.visitorEmail??"").replace("{ref}",f.noticeData?.visitorId??""):f.content;return c(ze,{text:g},f._id)}if(f.role==="user")return c(Dc,{text:f.content},f._id);const p={authorId:f.authorId,authorName:f.authorName,authorImage:f.authorImage};return f.status==="streaming"&&f.content===""?c(Kc,{},f._id):f.status==="streaming"?c(ze,{text:po(f.content),streaming:!0,...p},f._id):f.status==="error"?c(ze,{text:f.errorMessage??`${l.somethingWentWrong}. ${l.tryAgain}.`,error:!0,...p},f._id):c("div",{children:[c(ze,{text:po(f.content),...p}),f.sources&&f.sources.length>0?c(Jc,{sources:f.sources}):null]},f._id)}),c("div",{ref:a})]})}function Fn({message:t}){const[e,n]=C(!1);return S(()=>{const r=setTimeout(()=>{n(!0)},80);return()=>{clearTimeout(r)}},[]),e?c("div",{class:"jex-overlay jex-loading",children:[c("div",{class:"jex-loading-spinner","aria-hidden":"true"}),t&&c("p",{class:"jex-loading-message",children:t})]}):null}function Xc({sessionId:t,visitorId:e}){const n=gi(Oe.functions.chat.public.conversations.listBySession,t&&e?{sessionId:t,visitorId:e}:"skip"),r=gi(Oe.functions.chat.public.sessions.getSessionStatus,t&&e?{sessionId:t,visitorId:e}:"skip"),i=t!==null&&n===void 0,o=n?.some(s=>s.status==="streaming")??!1;return{conversations:n,sessionStatus:r??null,isLoading:i,isStreaming:o}}function eu({greeting:t,sessionId:e,visitorId:n,isLoading:r,sessionNotFound:i,resumeFailed:o,isOrgDeleted:s,ensureSession:l,startFresh:a}){const u=$(),{conversations:d,sessionStatus:h,isLoading:f,isStreaming:p}=Xc({sessionId:e,visitorId:n}),g=le((()=>{const b=nt.peek();return b!==null?b:Li.peek()?"resume":"fresh"})()).current;if(S(()=>{nt.value=null},[]),S(()=>{l()},[l]),S(()=>{n&&Cn(n)},[n]),s)return c("div",{class:"jex-chat-messages",children:c("div",{class:"jex-session-notice",children:u.chatNoLongerAvailable})});const m=g==="fresh"&&!e,x=g==="resume"&&(!e||f);return m?c(Fn,{message:u.startingConversation}):x?c(Fn,{message:u.resumeConversation}):c(U,{children:[c(Yc,{conversations:d,greeting:t,sessionNotFound:i,resumeFailed:o,onStartFresh:a,sessionId:e,visitorId:n}),c(Fc,{sessionId:e,visitorId:n,isLoading:r,isStreaming:p,sessionStatus:h,ensureSession:l,onStartFresh:a})]})}function tu({formMessageId:t,sessionId:e,visitorId:n}){const r=$(),i=At.value,o=/^https?:\/\//i.test(i)?i:$t,[s,l]=C(""),[a,u]=C(""),d=fo(),[h,f]=C(!1),[p,g]=C(null);async function m(x){x.preventDefault(),f(!0),g(null);try{await d({sessionId:e,visitorId:n,formMessageId:t,visitorName:s.trim(),visitorEmail:a.trim(),locale:xe.value}),It()}catch(b){console.error("[EscalationFormScreen] Submit failed:",b),g(r.escalationSubmitFailed)}finally{f(!1)}}return c("div",{class:"jex-form-screen",children:[c("h2",{class:"jex-form-title",children:r.escalationFormTitle}),c("p",{class:"jex-escalation-subtitle",children:r.escalationSubtitle}),p&&c("div",{class:"jex-form-error",role:"alert",children:p}),c("form",{class:"jex-form",onSubmit:x=>{m(x)},children:[c("input",{class:"jex-form-input",type:"text",placeholder:r.escalationNameLabel,value:s,required:!0,onInput:x=>{l(x.currentTarget.value)}}),c("input",{class:"jex-form-input",type:"email",placeholder:r.escalationEmailLabel,value:a,required:!0,onInput:x=>{u(x.currentTarget.value)}}),c("button",{class:"jex-form-submit",type:"submit",disabled:h,children:r.escalationSubmit})]}),c("div",{class:"jex-inline-form-consent",style:{textAlign:"center",margin:"16px 0 8px 0"},children:[r.escalationConsent," ",c("a",{href:o,target:"_blank",rel:"noopener noreferrer",class:"jex-privacy-notice-link",children:r.escalationPrivacyLinkText}),"."]}),c("button",{class:"jex-escalation-skip",type:"button",onClick:()=>{It()},children:r.escalationSkip})]})}function nu(){return kt(Oe.functions.chat.public.helpdesk.createEscalationRequest)}function go({sessionId:t,visitorId:e}){const n=$(),[r,i]=C(!1),[o,s]=C(null),l=nu();async function a(){if(!t||!e)return;const u=ue.value;if(u){i(!0),s(null);try{const d=await l({sessionId:t,visitorId:e,bootstrapToken:u,locale:xe.value});if(d.skipForm)return;ye({id:"escalation-form",formMessageId:d.formMessageId,sessionId:t,visitorId:e})}catch(d){const h=d instanceof Error?d.message:String(d);s(/RATE_LIMITED|Too many/.test(h)?n.handoffRateLimited:n.handoffFailed)}finally{i(!1)}}}return c(U,{children:[c("button",{class:"jex-header-handoff",type:"button",onClick:()=>{a()},disabled:r||!t||!e,"aria-label":n.talkToHumanAria,title:n.talkToHuman,children:c("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:[c("path",{d:"M3 14v-3a9 9 0 0 1 18 0v3"}),c("path",{d:"M21 14a2 2 0 0 1-2 2h-1a1 1 0 0 1-1-1v-4a1 1 0 0 1 1-1h3z"}),c("path",{d:"M3 14a2 2 0 0 0 2 2h1a1 1 0 0 0 1-1v-4a1 1 0 0 0-1-1H3z"}),c("path",{d:"M21 14v3a4 4 0 0 1-4 4h-3"})]})}),o&&c("div",{class:"jex-handoff-error",role:"alert",children:o})]})}async function ru(){const t=Ti.value;if(!t)return console.warn("[JexityChat] Bootstrap refresh skipped โ inputs missing"),{ok:!1,reason:"no-inputs"};const e=await kn(t.orgSlug,t.siteUrl,t.projSlug);if(!e.ok)return console.warn("[JexityChat] Bootstrap refresh failed:",e.error),{ok:!1,reason:e.error};const n=e.token;return ue.value=n,{ok:!0,token:n}}function mo(t){return xo(t)?"unauthorized":t instanceof Error&&/network|fetch|failed to fetch/i.test(t.message)?"network":"unknown"}function xo(t){return t instanceof xt?t.data?.code==="UNAUTHORIZED_ORIGIN":!1}function iu(t=1e4){return ue.value?Promise.resolve(ue.value):new Promise(e=>{let n=!1;const r=s=>{n||(n=!0,clearTimeout(i),o(),e(s))},i=setTimeout(()=>{r(null)},t),o=ue.subscribe(s=>{s&&r(s)})})}function ou(t,e){const n=le(null),r=Le(!1),i=Le(!1),o=Le(!1),s=Le(null),l=kt(Oe.functions.chat.public.sessions.createOrResume),a=async p=>{const g=await iu();if(!g)return console.warn("[JexityChat] No bootstrap token after 10s โ session creation blocked."),Ne.value="no-token",null;const m=v=>({orgSlug:t,...e?{projSlug:e}:{},visitorId:p,bootstrapToken:v,locale:xe.value,...Rt.value?{source:Rt.value}:{}});Rn.value=!0;let x;try{try{x=await l(m(g))}catch(v){if(!xo(v))throw v;const L=await ru();if(!L.ok)return Ne.value=L.reason==="rate_limited"?"network":"unauthorized",null;x=await l(m(L.token))}}finally{Rn.value=!1}Ne.value=null,s.value=x.status;const b={sessionId:x.sessionId,visitorId:p};return n.current=b,{session:b,result:x}},u=Ce(async()=>{if(n.current)return n.current;if(o.value)return null;r.value=!0;const p=be.value!==null,g=be.value??Mi();try{const m=await a(g);return m?(p&&m.result.isNew&&(i.value=!0,o.value=!0),m.session):null}catch(m){return console.error("[JexityChat] Failed to create session:",m),Ne.value=mo(m),null}finally{r.value=!1}},[t,e,l,r,i,o]),d=Ce(()=>{n.current=null,i.value=!1,o.value=!1},[i,o]);S(()=>fl(d),[d]);const h=Ce(async()=>{n.current=null,o.value=!1,i.value=!1;const p=Mi();r.value=!0;try{return(await a(p))?.session??null}catch(g){return console.error("[JexityChat] Failed to create fresh session:",g),Ne.value=mo(g),null}finally{r.value=!1}},[t,e,l,r,i,o,s]),f=n.current;return{sessionId:f?.sessionId??null,visitorId:f?.visitorId??null,isLoading:r.value,sessionNotFound:i.value,resumeFailed:o.value,sessionStatus:s.value,isOrgDeleted:s.value==="org_deleted",ensureSession:u,startFresh:h,resetSession:d}}function su(){const t=$(),[e,n]=C(""),[r,i]=C(""),[o,s]=C("");async function l(a){a.preventDefault(),Tn({id:"loading",message:t.submittingTicket}),await new Promise(d=>{setTimeout(d,1200)});const u="JEX-"+Math.random().toString(36).slice(2,8).toUpperCase();Tn({id:"confirmation",ref:u})}return c("div",{class:"jex-form-screen",children:[c("h2",{class:"jex-form-title",children:t.submitTicket}),c("form",{class:"jex-form",onSubmit:a=>{l(a)},children:[c("input",{class:"jex-form-input",type:"text",placeholder:t.yourName,value:e,required:!0,onInput:a=>{n(a.currentTarget.value)}}),c("input",{class:"jex-form-input",type:"email",placeholder:t.yourEmail,value:r,required:!0,onInput:a=>{i(a.currentTarget.value)}}),c("textarea",{class:"jex-form-textarea",placeholder:t.howCanWeHelp,value:o,required:!0,onInput:a=>{s(a.currentTarget.value)}}),c("button",{class:"jex-form-submit",type:"submit",children:t.submit})]})]})}function au({ticketRef:t}){const e=$();return c("div",{class:"jex-confirmation",children:[c("div",{class:"jex-confirmation-icon","aria-hidden":"true",children:"โ"}),c("h2",{class:"jex-confirmation-title",children:e.ticketSubmitted}),c("p",{class:"jex-confirmation-body",children:e.yourReferenceNumber}),c("div",{class:"jex-confirmation-ref",children:t}),c("p",{class:"jex-confirmation-hint",children:e.sentToEmailHint}),c("button",{class:"jex-confirmation-done",onClick:()=>{P.value=!1},children:e.done})]})}function lu({message:t,onRetry:e,onBack:n}){const r=$();return c("div",{class:"jex-overlay jex-error",children:[c("p",{class:"jex-error-message",children:t}),c("div",{class:"jex-error-actions",children:[e&&c("button",{class:"jex-error-retry",onClick:e,children:r.tryAgain}),n&&c("button",{class:"jex-error-back",onClick:n,children:r.goBack})]})]})}function bo({greeting:t,title:e,sessionId:n,visitorId:r,isLoading:i,sessionNotFound:o,resumeFailed:s,isOrgDeleted:l,ensureSession:a,startFresh:u,resetSession:d}){const h=B.value,f=h[h.length-1],p=[...h].reverse().find(g=>g.id==="confirmation");return c("div",{class:"jex-screen-container",children:[f.id==="home"&&c(Tl,{greeting:t,title:e,onStartFresh:u,onResetSession:d}),f.id==="selection"&&c(Rl,{title:e}),f.id==="form"&&c(su,{}),f.id==="escalation-form"&&c(tu,{formMessageId:f.formMessageId,sessionId:f.sessionId,visitorId:f.visitorId}),f.id==="confirmation"&&p&&c(au,{ticketRef:p.ref}),f.id==="chat"&&c(eu,{greeting:t,sessionId:n,visitorId:r,isLoading:i,sessionNotFound:o,resumeFailed:s,isOrgDeleted:l,ensureSession:a,startFresh:u}),f.id==="loading"&&c(Fn,{message:f.message}),f.id==="error"&&c(lu,{message:f.message,onRetry:()=>Tn({id:"loading"}),onBack:It})]})}function cu({options:t}){return Za({orgSlug:t.orgSlug,projSlug:t.projSlug,preToken:t.bootstrapToken,convexUrl:t.convexUrl,preAllowedUrls:t.allowedUrls??[],preExcludedPaths:t.excludePaths}),el()?c(uu,{options:t}):null}function uu({options:t}){const e=Ga(t.orgSlug,t.projSlug,t.convexUrl);sl(t.parentOrigin),S(()=>{cl(),ul()},[]);const{sessionId:n,visitorId:r,isLoading:i,sessionNotFound:o,resumeFailed:s,isOrgDeleted:l,ensureSession:a,startFresh:u,resetSession:d}=ou(t.orgSlug,t.projSlug),h=Ha(t,e);S(()=>{xe.value=Ai(h.locale)},[h.locale]),S(()=>{At.value=h.privacyPolicyUrl??$t,Ci.value=h.privacyNoticeStyle},[h.privacyNoticeStyle,h.privacyPolicyUrl]),S(()=>{if(!P.value||h.mode==="embedded"||!window.matchMedia("(max-width: 480px), (pointer: coarse) and (max-width: 768px)").matches)return;const Q=document.documentElement.style.overflow;return document.documentElement.style.overflow="hidden",()=>{document.documentElement.style.overflow=Q}},[P.value,h.mode]),S(()=>{if(h.mode!=="embedded")try{return ml()}catch(F){console.warn("[JexityChat] Idle-lock watcher failed to start:",F);return}},[h.mode]);const f=h.position==="bottom-left",p=h.colorScheme==="dark"||h.colorScheme==="light"?h.colorScheme:"",g=xl({...t,primaryColor:h.primaryColor,accentColor:h.accentColor,fontFamily:h.fontFamily,fontSize:h.fontSize,borderRadius:h.borderRadius,windowWidth:h.windowWidth,windowHeight:h.windowHeight}),m=h.mode==="embedded",x=B.value,v=x[x.length-1]?.id==="chat",M=e!==null||m||!!t.parentOrigin?g:{...g,visibility:"hidden"};return c("div",{class:`jex-widget ${p}`.trim(),style:M,children:m?c("div",{class:"jex-embedded",children:[c(Bi,{title:h.title,rightAction:v?c(go,{sessionId:n,visitorId:r}):null,showClose:!m}),c(bo,{greeting:h.greeting,title:h.title,orgSlug:t.orgSlug,projSlug:t.projSlug,sessionId:n,visitorId:r,isLoading:i,sessionNotFound:o,resumeFailed:s,isOrgDeleted:l,ensureSession:a,startFresh:u,resetSession:d}),!h.hideBranding&&c(Ui,{})]}):c("div",{class:`jex-container${f?" jex-pos-left":""}`,children:[P.value&&c("div",{class:"jex-chat-window",children:[c(Bi,{title:h.title,rightAction:v?c(go,{sessionId:n,visitorId:r}):null}),c(bo,{greeting:h.greeting,title:h.title,orgSlug:t.orgSlug,projSlug:t.projSlug,sessionId:n,visitorId:r,isLoading:i,sessionNotFound:o,resumeFailed:s,isOrgDeleted:l,ensureSession:a,startFresh:u,resetSession:d}),!h.hideBranding&&c(Ui,{})]}),c(Cl,{iconOption:h.triggerIcon,radius:h.triggerRadius,label:h.triggerLabel})]})})}const hu='.jex-widget{--jex-primary: #115A62;--jex-primary-hover: var(--jex-accent, color-mix(in srgb, var(--jex-primary) 85%, #000));--jex-radius: .75rem;--jex-font-family: "Inter", system-ui, -apple-system, sans-serif;--jex-font-size: 14px;--jex-window-width: 380px;--jex-window-height: 600px;--jex-shadow: 0 16px 48px -12px rgba(13, 127, 138, .25), 0 4px 16px rgba(0, 0, 0, .08);pointer-events:auto;--jex-bg-trigger: var(--jex-primary);--jex-bg-header: var(--jex-primary);--jex-bg-msg-user: var(--jex-primary);--jex-bg-send-btn: var(--jex-primary);--jex-bg-window: rgba(255, 255, 255, .95);--jex-bg-msg-bot: #f1f5f9;--jex-bg-input: rgba(247, 253, 253, .6);--jex-text-header: #ffffff;--jex-text-msg-user: #ffffff;--jex-text-msg-bot: #0f172a;--jex-text-main: #0f172a;--jex-text-muted: #64748b;--jex-bg-avatar-agent: #d1fae5;--jex-text-avatar-agent: #065f46;--jex-border-window: rgba(226, 232, 240, .8);--jex-border-input: rgba(203, 213, 225, .8);--jex-bg-glass: var(--jex-bg-window);--jex-border-glass: var(--jex-border-window);font-family:var(--jex-font-family);-webkit-font-smoothing:antialiased}.dark .jex-widget,.jex-widget.dark{--jex-primary: #1cb0bf;--jex-primary-hover: var(--jex-accent, color-mix(in srgb, var(--jex-primary) 85%, #000));--jex-bg-window: rgba(10, 15, 26, .95);--jex-bg-msg-bot: #233146;--jex-bg-input: rgba(10, 15, 26, .6);--jex-text-msg-bot: #f8fafc;--jex-text-main: #f8fafc;--jex-text-muted: #94a3b8;--jex-border-window: rgba(30, 41, 59, .8);--jex-border-input: rgba(51, 65, 85, .9);--jex-bg-avatar-agent: #064e3b;--jex-text-avatar-agent: #6ee7b7;--jex-bg-error: #3b1318;--jex-border-error: #5c1d24;--jex-text-error: #fca5a5}@media(prefers-color-scheme:dark){:host:not(.light) .jex-widget:not(.light){--jex-primary: #1cb0bf;--jex-primary-hover: var(--jex-accent, color-mix(in srgb, var(--jex-primary) 85%, #000));--jex-bg-window: rgba(10, 15, 26, .95);--jex-bg-msg-bot: #233146;--jex-bg-input: rgba(10, 15, 26, .6);--jex-text-msg-bot: #f8fafc;--jex-text-main: #f8fafc;--jex-text-muted: #94a3b8;--jex-border-window: rgba(30, 41, 59, .8);--jex-border-input: rgba(51, 65, 85, .9);--jex-bg-error: #3b1318;--jex-border-error: #5c1d24;--jex-text-error: #fca5a5}}.jex-widget *{box-sizing:border-box;margin:0;padding:0}.jex-container{position:fixed;bottom:24px;right:24px;display:flex;flex-direction:column;align-items:flex-end;gap:16px;z-index:9999}.jex-container.jex-pos-left{right:auto;left:24px;align-items:flex-start}:host(.jex-mode-embedded){display:block;width:100%;height:100%}:host(.jex-mode-embedded) .jex-widget{width:100%;height:100%}.jex-embedded{display:flex;flex-direction:column;width:100%;height:100%;background:var(--jex-bg-window);border:1px solid var(--jex-border-window);overflow:hidden}.jex-embedded .jex-screen-container{flex:1;overflow:hidden;display:flex;flex-direction:column}.jex-floating-button{height:56px;min-width:56px;padding:0;background:var(--jex-bg-trigger);color:var(--jex-text-header);border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:var(--jex-shadow);transition:transform .3s cubic-bezier(.175,.885,.32,1.275),background .2s,width .3s ease,border-radius .3s ease}.jex-floating-button.jex-has-label{min-width:110px;padding:0 20px}.jex-fab-inner{display:flex;align-items:center;gap:12px}.jex-fab-label{font-size:15px;font-weight:600;white-space:nowrap}.jex-floating-button:hover{transform:scale(1.1);background:var(--jex-primary-hover)}.jex-floating-button:active{transform:scale(.95)}.jex-chat-window{width:var(--jex-window-width);height:var(--jex-window-height);max-height:calc(100vh - 120px);background:var(--jex-bg-window);backdrop-filter:blur(24px);-webkit-backdrop-filter:blur(24px);border:1px solid var(--jex-border-window);border-radius:calc(var(--jex-radius) * 2);box-shadow:var(--jex-shadow);display:flex;flex-direction:column;overflow:hidden;animation:jexSlideUp .4s cubic-bezier(.16,1,.3,1);transform-origin:bottom right;touch-action:manipulation}@keyframes jexSlideUp{0%{opacity:0;transform:scale(.8) translateY(20px)}to{opacity:1;transform:scale(1) translateY(0)}}@media(max-width:480px),(pointer:coarse)and (max-width:768px){.jex-chat-window{position:fixed;inset:0;width:100vw;height:100vh;height:100dvh;max-height:none;border:none;border-radius:0;animation:jexSlideUpMobile .3s cubic-bezier(.16,1,.3,1);transform-origin:bottom center}.jex-container:has(.jex-chat-window) .jex-floating-button{display:none}}@keyframes jexSlideUpMobile{0%{opacity:0;transform:translateY(100%)}to{opacity:1;transform:translateY(0)}}.jex-chat-header{padding:20px;background:var(--jex-bg-header);color:var(--jex-text-header);display:flex;align-items:center;gap:12px;flex-shrink:0}.jex-header-info h3{font-size:16px;font-weight:600;color:var(--jex-text-header);margin:0}.jex-header-info p{font-size:12px;opacity:.8;color:var(--jex-text-header);margin:0}.jex-header-right{margin-left:auto;display:flex;align-items:center;gap:4px}.jex-header-handoff{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;background:transparent;border:1px solid color-mix(in srgb,currentColor 50%,transparent);border-radius:999px;padding:0;color:inherit;cursor:pointer;transition:background .15s ease,border-color .15s ease}.jex-header-handoff:hover:not(:disabled){background:color-mix(in srgb,currentColor 12%,transparent);border-color:currentColor}.jex-header-handoff:disabled{opacity:.5;cursor:not-allowed}.jex-header-close{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;background:transparent;border:none;border-radius:999px;padding:0;color:inherit;cursor:pointer;transition:background .15s ease}.jex-header-close:hover{background:color-mix(in srgb,currentColor 14%,transparent)}.jex-handoff-error{position:absolute;top:100%;right:8px;background:#fee;color:#b00;padding:4px 8px;font-size:12px;border-radius:4px}.jex-header-back{background:none;border:none;color:var(--jex-text-header);cursor:pointer;padding:4px;display:flex;align-items:center;opacity:.8;transition:opacity .2s;flex-shrink:0}.jex-header-back:hover{opacity:1}.jex-screen-container{flex:1;overflow:hidden;display:flex;flex-direction:column}.jex-home{flex:1;display:flex;flex-direction:column;padding:24px;gap:20px;overflow-y:auto}.jex-home-hero{display:flex;align-items:center;gap:14px;animation:jexFadeIn .4s ease both}.jex-home-avatar{position:relative;width:48px;height:48px;border-radius:14px;background:var(--jex-primary);color:var(--jex-text-header);display:flex;align-items:center;justify-content:center;flex-shrink:0;box-shadow:0 4px 12px color-mix(in srgb,var(--jex-primary) 30%,transparent)}.jex-home-status-dot{position:absolute;bottom:-2px;right:-2px;width:14px;height:14px;border-radius:50%;background:#22c55e;border:2.5px solid var(--jex-bg-window);animation:jexPulse 2s ease-in-out infinite}@keyframes jexPulse{0%,to{box-shadow:0 0 #22c55e66}50%{box-shadow:0 0 0 6px #22c55e00}}.jex-home-hero-text{display:flex;flex-direction:column;gap:2px;min-width:0}.jex-home-title{font-size:17px;font-weight:700;color:var(--jex-text-main);margin:0;line-height:1.2;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.jex-home-status{font-size:12px;font-weight:500;color:#22c55e;letter-spacing:.02em}.jex-home-greeting{background:var(--jex-bg-msg-bot);border:1px solid var(--jex-border-window);border-radius:4px 16px 16px;padding:16px 18px;font-size:14px;line-height:1.55;color:var(--jex-text-main);animation:jexFadeIn .4s .1s ease both}.jex-home-greeting p{margin:0}@keyframes jexFadeIn{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.jex-home-actions{display:flex;flex-direction:column;gap:10px;animation:jexFadeIn .4s .2s ease both}.jex-home-start-btn{background:var(--jex-bg-send-btn);color:var(--jex-text-header);border:none;border-radius:12px;padding:14px 20px;font-size:15px;font-weight:600;cursor:pointer;font-family:inherit;transition:background .2s,transform .15s,box-shadow .2s;width:100%;box-shadow:0 2px 8px color-mix(in srgb,var(--jex-primary) 25%,transparent)}.jex-home-start-btn:hover{background:var(--jex-primary-hover);transform:translateY(-1px);box-shadow:0 4px 16px color-mix(in srgb,var(--jex-primary) 35%,transparent)}.jex-home-start-btn:active{transform:translateY(0);box-shadow:0 1px 4px color-mix(in srgb,var(--jex-primary) 20%,transparent)}.jex-home-resume-card{display:flex;flex-direction:column;gap:8px;width:100%;text-align:left;padding:16px 18px;border-radius:14px;border:1.5px solid var(--jex-primary);background:color-mix(in srgb,var(--jex-primary) 6%,var(--jex-bg-window));cursor:pointer;font-family:inherit;transition:background .2s,border-color .2s,transform .15s,box-shadow .2s;box-shadow:0 2px 8px color-mix(in srgb,var(--jex-primary) 12%,transparent)}.jex-home-resume-card:hover{background:color-mix(in srgb,var(--jex-primary) 10%,var(--jex-bg-window));transform:translateY(-1px);box-shadow:0 4px 16px color-mix(in srgb,var(--jex-primary) 20%,transparent)}.jex-home-resume-card:active{transform:translateY(0)}.jex-home-resume-top{display:flex;align-items:center;justify-content:space-between}.jex-home-resume-label{font-size:14px;font-weight:600;color:var(--jex-primary)}.jex-home-resume-arrow{color:var(--jex-primary);opacity:.6;transition:opacity .2s,transform .2s}.jex-home-resume-card:hover .jex-home-resume-arrow{opacity:1;transform:translate(2px)}.jex-home-resume-ref{font-family:ui-monospace,Cascadia Code,Fira Code,monospace;font-size:13px;font-weight:600;letter-spacing:.06em;color:var(--jex-text-muted)}.jex-home-history{display:flex;flex-direction:column;gap:8px}.jex-home-resume-meta{font-size:11px;opacity:.7;margin-top:4px}.jex-home-new-btn{background:transparent;color:var(--jex-text-muted);border:1px solid var(--jex-border-input);border-radius:12px;padding:12px 20px;font-size:14px;font-weight:500;cursor:pointer;font-family:inherit;transition:color .2s,border-color .2s,background .2s;width:100%}.jex-home-new-btn:hover{color:var(--jex-text-main);border-color:var(--jex-text-muted);background:color-mix(in srgb,var(--jex-primary) 3%,transparent)}.jex-session-ref{display:flex;align-items:center;gap:8px;padding:8px 12px;background:var(--jex-bg-msg-bot);border:1px solid var(--jex-border-window);border-radius:8px;font-size:12px}.jex-session-ref-label{color:var(--jex-text-muted);font-weight:500}.jex-session-ref-code{color:var(--jex-primary);font-weight:700;font-family:ui-monospace,Cascadia Code,monospace;letter-spacing:.05em}.jex-chat-messages{flex:1;padding:20px;overflow-y:auto;display:flex;flex-direction:column;gap:12px}.jex-message-row{display:flex;align-items:flex-end;gap:8px;max-width:85%}.jex-message-row.bot{align-self:flex-start}.jex-message-content{flex:1;min-width:0}.jex-avatar{width:24px;height:24px;border-radius:50%;flex-shrink:0;display:flex;align-items:center;justify-content:center;font-size:12px;margin-bottom:2px}.jex-avatar-bot{background:var(--jex-bg-msg-bot);color:var(--jex-primary)}.jex-avatar-agent{background:var(--jex-bg-avatar-agent)}.jex-avatar-img{width:100%;height:100%;border-radius:50%;object-fit:cover}.jex-avatar-initials{font-size:9px;font-weight:700;color:var(--jex-text-avatar-agent)}.jex-message-author-row{display:flex;align-items:center;gap:6px;margin-top:2px;padding-left:4px}.jex-message-author{font-size:10px;color:var(--jex-text-muted)}.jex-reply-tag-btn{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;padding:0;border:none;border-radius:4px;background:transparent;color:var(--jex-text-muted, #6b7280);cursor:pointer;transition:background .15s,color .15s}.jex-reply-tag-btn:hover{background:#0000000f;color:var(--jex-primary, #115A62)}.jex-reply-tag-btn:focus-visible{outline:2px solid var(--jex-primary, #115A62);outline-offset:1px}.jex-message{padding:12px 16px;border-radius:18px;font-size:14px;line-height:1.4}.jex-message.bot{background:var(--jex-bg-msg-bot);border:1px solid var(--jex-border-window);color:var(--jex-text-msg-bot);border-bottom-left-radius:4px}.jex-message.user{align-self:flex-end;max-width:80%;background:var(--jex-bg-msg-user);color:var(--jex-text-msg-user);border-bottom-right-radius:4px}.jex-typing{align-self:flex-start;display:flex;gap:4px;padding:12px 16px}.jex-typing span{width:8px;height:8px;border-radius:50%;background:var(--jex-text-muted);animation:jexTypingDot 1.2s infinite ease-in-out}.jex-typing span:nth-child(2){animation-delay:.2s}.jex-typing span:nth-child(3){animation-delay:.4s}@keyframes jexTypingDot{0%,80%,to{transform:scale(.8);opacity:.4}40%{transform:scale(1);opacity:1}}.jex-md{word-break:break-word;overflow-wrap:anywhere}.jex-md p{margin:0 0 8px}.jex-md p:last-child{margin-bottom:0}.jex-md strong{font-weight:600}.jex-md em{font-style:italic}.jex-md ul,.jex-md ol{margin:0 0 8px;padding-left:20px}.jex-md ul:last-child,.jex-md ol:last-child{margin-bottom:0}.jex-md ul{list-style-type:disc}.jex-md ol{list-style-type:decimal}.jex-md li{margin-bottom:2px}.jex-md li:last-child{margin-bottom:0}.jex-md a{color:var(--jex-primary);text-decoration:underline;text-underline-offset:2px}.jex-md a:hover{opacity:.8}.jex-md code{background:#00000014;padding:1px 5px;border-radius:4px;font-size:.9em;font-family:ui-monospace,Cascadia Code,Fira Code,monospace}.jex-md pre{background:#0000000f;border-radius:8px;padding:10px 12px;margin:0 0 8px;overflow-x:auto;font-size:.85em}.jex-md pre:last-child{margin-bottom:0}.jex-md pre code{background:none;padding:0;border-radius:0;font-size:inherit}.jex-md h1,.jex-md h2,.jex-md h3,.jex-md h4{font-weight:600;margin:8px 0 4px}.jex-md h1:first-child,.jex-md h2:first-child,.jex-md h3:first-child,.jex-md h4:first-child{margin-top:0}.jex-md h3{font-size:1em}.jex-md h4{font-size:.95em}.jex-md hr{border:none;border-top:1px solid var(--jex-border-window);margin:8px 0}.jex-md blockquote{border-left:3px solid var(--jex-primary);margin:0 0 8px;padding:4px 12px;color:var(--jex-text-muted)}.jex-md blockquote:last-child{margin-bottom:0}.dark .jex-md code,.jex-widget.dark .jex-md code{background:#ffffff1a}.dark .jex-md pre,.jex-widget.dark .jex-md pre{background:#ffffff14}@media(prefers-color-scheme:dark){:host:not(.light) .jex-widget:not(.light) .jex-md code{background:#ffffff1a}:host:not(.light) .jex-widget:not(.light) .jex-md pre{background:#ffffff14}}.jex-streaming-cursor:after{content:"โ";margin-left:2px;animation:jexBlinkCursor .8s ease-in-out infinite}@keyframes jexBlinkCursor{0%,to{opacity:1}50%{opacity:0}}.jex-session-notice{align-self:center;text-align:center;padding:8px 16px;margin:8px 0;font-size:12px;color:var(--jex-text-muted);background:var(--jex-bg-input, #f1f5f9);border-radius:8px;line-height:1.4}.jex-message-error{background:var(--jex-bg-error, #fef2f2)!important;border-color:var(--jex-border-error, #fecaca)!important;color:var(--jex-text-error, #991b1b)!important}.jex-chat-input{padding:12px 16px;border-top:1px solid var(--jex-border-window);display:flex;flex-direction:column;gap:8px;flex-shrink:0}.jex-chat-input-composer-gate{position:relative}.jex-chat-input-composer-gate-open{z-index:2}.jex-chat-input-composer-gate-open .jex-composer-card{pointer-events:none}.jex-composer-card{display:flex;flex-direction:column;gap:6px;padding:10px 12px 8px;background:var(--jex-bg-input);border:1px solid var(--jex-border-input);border-radius:16px;cursor:text;transition:border-color .15s ease,background .15s ease,box-shadow .15s ease}.jex-composer-card:focus-within{border-color:var(--jex-primary);background:var(--jex-bg-window);box-shadow:0 0 0 3px color-mix(in srgb,var(--jex-primary, #115A62) 14%,transparent)}.jex-composer-attachments{display:flex;flex-wrap:wrap;gap:6px;padding:2px 2px 4px}.jex-attachment-chip{position:relative;width:44px;height:44px;border-radius:8px;overflow:hidden;background:var(--jex-bg-msg-bot, #f1f5f9);flex-shrink:0;box-shadow:0 1px 2px #0000000f}.jex-attachment-thumb{width:100%;height:100%;object-fit:cover;display:block;pointer-events:none}.jex-attachment-remove{position:absolute;top:2px;right:2px;width:16px;height:16px;padding:0;border:none;border-radius:50%;background:#0f172ac7;color:#fff;display:inline-flex;align-items:center;justify-content:center;cursor:pointer;opacity:0;transition:opacity .12s ease,transform .12s ease}.jex-attachment-chip:hover .jex-attachment-remove,.jex-attachment-chip:focus-within .jex-attachment-remove{opacity:1}.jex-attachment-remove:hover{transform:scale(1.08)}.jex-composer-textarea{width:100%;min-height:22px;background:transparent;border:none;outline:none;resize:none;padding:2px 4px;color:var(--jex-text-main);font-family:inherit;font-size:16px;line-height:1.45;overflow-y:hidden}.jex-composer-textarea::placeholder{color:var(--jex-text-muted);opacity:.85}.jex-composer-textarea:disabled{cursor:not-allowed;opacity:.7}.jex-composer-actions{display:flex;align-items:center;justify-content:space-between;gap:8px}.jex-composer-actions-left{display:inline-flex;align-items:center;gap:4px}.jex-attach-btn{width:30px;height:30px;padding:0;border:none;border-radius:50%;background:transparent;color:var(--jex-text-muted);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;transition:background .12s ease,color .12s ease,transform .12s ease}.jex-attach-btn:hover:not(:disabled){background:color-mix(in srgb,var(--jex-text-muted, #64748b) 12%,transparent);color:var(--jex-text-main)}.jex-attach-btn:active:not(:disabled){transform:scale(.92)}.jex-attach-btn:disabled{opacity:.4;cursor:not-allowed}.jex-visually-hidden{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.jex-rate-limit-notice{flex:1 0 100%;order:-1;margin-bottom:8px;padding:8px 12px;border-radius:10px;background:var(--jex-bg-msg-bot, #f1f5f9);color:var(--jex-text-muted, #64748b);font-size:12px;line-height:1.4;text-align:center}.jex-session-error-notice{flex:1 0 100%;order:-1;margin-bottom:8px;padding:8px 12px;border-radius:10px;background:var(--jex-bg-error, #fef2f2);border:1px solid var(--jex-border-error, #fecaca);color:var(--jex-text-error, #991b1b);font-size:12px;line-height:1.4;text-align:center}.jex-chat-input input{flex:1;background:var(--jex-bg-input);border:1px solid var(--jex-border-input);border-radius:12px;padding:10px 14px;color:var(--jex-text-main);outline:none;font-family:inherit;font-size:14px}.jex-chat-input input:focus{border-color:var(--jex-primary)}.jex-send-btn{background:color-mix(in srgb,var(--jex-text-muted, #64748b) 18%,transparent);color:var(--jex-text-muted);border:none;border-radius:999px;width:30px;height:30px;display:inline-flex;align-items:center;justify-content:center;cursor:pointer;transition:background .15s ease,color .15s ease,opacity .15s ease,transform .15s ease;flex-shrink:0}.jex-send-btn-active{background:var(--jex-bg-send-btn, var(--jex-primary));color:var(--jex-text-header, #fff)}.jex-send-btn-active:hover:not(:disabled){background:var(--jex-primary-hover)}.jex-send-btn:active:not(:disabled){transform:scale(.9)}.jex-send-btn:disabled{opacity:.45;cursor:default}.jex-widget-footer{display:flex;align-items:center;justify-content:center;padding:8px 16px;border-top:1px solid var(--jex-border-glass);background:#00000005;flex-shrink:0}.jex-widget.dark .jex-widget-footer{background:#ffffff05}@media(prefers-color-scheme:dark){:host:not(.light) .jex-widget:not(.light) .jex-widget-footer{background:#ffffff05}}.jex-branding{display:flex;align-items:center;gap:6px;text-decoration:none;color:var(--jex-text-muted);font-size:11px;font-weight:500;transition:color .2s}.jex-branding:hover{color:var(--jex-text-main)}.jex-branding-icon{color:var(--jex-primary)}.jex-branding span strong{font-weight:700;color:var(--jex-text-main)}.jex-privacy-notice-link,.jex-privacy-chip-link{color:var(--jex-primary);text-decoration:underline;text-underline-offset:2px;text-decoration-color:color-mix(in srgb,var(--jex-primary) 50%,transparent);transition:text-decoration-color .15s}.jex-privacy-notice-link:hover,.jex-privacy-chip-link:hover{text-decoration-color:var(--jex-primary)}.jex-privacy-chip{align-self:center;display:inline-flex;align-items:center;gap:6px;max-width:100%;margin:0;padding:5px 10px;border-radius:999px;background:color-mix(in srgb,var(--jex-primary) 10%,var(--jex-bg-window));color:var(--jex-primary);font-size:10px;font-weight:650;line-height:1.2}.jex-privacy-chip-icon{display:inline-flex;flex-shrink:0}.jex-privacy-chip-link{color:inherit;text-decoration:none}.jex-privacy-explicit{position:absolute;left:0;right:0;bottom:0;z-index:3;display:flex;flex-direction:column;gap:10px;min-height:100%;padding:10px 12px 12px;border:1px solid var(--jex-border-window);border-radius:14px 14px 10px 10px;background:var(--jex-bg-window);box-shadow:0 -12px 36px #0f172a24;pointer-events:auto}.jex-privacy-explicit-content{display:flex;align-items:flex-start;gap:10px}.jex-privacy-explicit-icon{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;border-radius:8px;background:color-mix(in srgb,var(--jex-primary) 10%,var(--jex-bg-window));color:var(--jex-primary);flex-shrink:0}.jex-privacy-explicit-copy{min-width:0;flex:1}.jex-privacy-explicit-title{color:var(--jex-text-main);font-size:12px;font-weight:750;line-height:1.2;margin-bottom:3px}.jex-privacy-explicit-body{margin:0;color:var(--jex-text-muted);font-size:10px;line-height:1.35}.jex-privacy-explicit-button{width:100%;border:none;border-radius:10px;background:var(--jex-bg-send-btn);color:var(--jex-text-header);cursor:pointer;font-family:inherit;font-size:12px;font-weight:750;padding:9px 12px;transition:background .15s ease,transform .12s ease}.jex-privacy-explicit-button:hover{background:var(--jex-primary-hover)}.jex-privacy-explicit-button:active{transform:scale(.98)}.jex-locale-select-wrapper{position:relative;display:flex;align-items:center}.jex-locale-select{appearance:none;-webkit-appearance:none;background:transparent;border:1px solid transparent;padding:4px 20px 4px 6px;border-radius:6px;font-family:inherit;font-size:11px;font-weight:600;color:var(--jex-text-muted);background-color:transparent;cursor:pointer;outline:none;transition:all .2s ease}.jex-locale-select option{background-color:#fff;color:#0f172a}.jex-locale-select:hover,.jex-locale-select:focus-visible{color:var(--jex-text-main);background:#0000000a}.jex-widget.dark .jex-locale-select:hover,.jex-widget.dark .jex-locale-select:focus-visible{background:#ffffff0d}.jex-widget.dark .jex-locale-select option{background-color:#0f172a;color:#f8fafc}@media(prefers-color-scheme:dark){:host:not(.light) .jex-widget:not(.light) .jex-locale-select:hover,:host:not(.light) .jex-widget:not(.light) .jex-locale-select:focus-visible{background:#ffffff0d}:host:not(.light) .jex-widget:not(.light) .jex-locale-select option{background-color:#0f172a;color:#f8fafc}}.jex-locale-select:focus-visible{border-color:var(--jex-primary)}.jex-locale-chevron{position:absolute;right:4px;pointer-events:none;color:var(--jex-text-muted);transition:color .2s ease}.jex-locale-select-wrapper:hover .jex-locale-chevron{color:var(--jex-text-main)}.jex-overlay{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;background:var(--jex-bg-window, #fff);z-index:10;padding:24px;text-align:center}.jex-loading-spinner{width:32px;height:32px;border:3px solid var(--jex-border-input, #e2e8f0);border-top-color:var(--jex-primary, #115A62);border-radius:50%;animation:jex-spin .7s linear infinite}@keyframes jex-spin{to{transform:rotate(360deg)}}.jex-loading-message{font-size:14px;color:var(--jex-text-muted, #64748b)}.jex-error-message{font-size:14px;color:var(--jex-text-main, #334155)}.jex-error-actions{display:flex;gap:8px}.jex-error-retry,.jex-error-back{padding:8px 16px;border-radius:8px;font-size:13px;font-weight:600;cursor:pointer;border:none}.jex-error-retry{background:var(--jex-primary, #115A62);color:#fff}.jex-error-back{background:transparent;color:var(--jex-text-muted, #64748b);border:1px solid var(--jex-border-input, #e2e8f0)}.jex-selection{display:flex;flex-direction:column;gap:12px;padding:24px 16px;height:100%}.jex-selection-title{font-size:16px;font-weight:700;color:var(--jex-text-main, #0f172a);margin:0 0 8px}.jex-selection-options{display:flex;flex-direction:column;gap:10px}.jex-selection-option{display:flex;flex-direction:column;align-items:flex-start;gap:2px;padding:16px;border-radius:12px;border:1px solid var(--jex-border-window, #e2e8f0);background:transparent;cursor:pointer;text-align:left;transition:border-color .15s ease,background .15s ease}.jex-selection-option:hover{border-color:var(--jex-primary, #115A62);background:color-mix(in srgb,var(--jex-primary, #115A62) 5%,transparent)}.jex-selection-icon{font-size:20px}.jex-selection-label{font-size:14px;font-weight:600;color:var(--jex-text-main, #0f172a)}.jex-selection-sub{font-size:12px;color:var(--jex-text-muted, #64748b)}.jex-form-screen{display:flex;flex-direction:column;padding:20px 16px;height:100%;overflow-y:auto}.jex-form-title{font-size:16px;font-weight:700;color:var(--jex-text-main, #0f172a);margin:0 0 16px}.jex-form{display:flex;flex-direction:column;gap:10px}.jex-form-input,.jex-form-textarea{padding:10px 12px;border-radius:8px;border:1px solid var(--jex-border-input, #e2e8f0);font-size:14px;background:transparent;color:var(--jex-text-main, #0f172a);outline:none}@media(pointer:coarse){.jex-form-input,.jex-form-textarea{font-size:16px}}.jex-form-input:focus,.jex-form-textarea:focus{border-color:var(--jex-primary, #115A62)}.jex-form-textarea{min-height:80px;resize:vertical}.jex-form-submit{padding:10px;border-radius:8px;border:none;background:var(--jex-primary, #115A62);color:#fff;font-size:14px;font-weight:600;cursor:pointer;margin-top:4px}.jex-inline-form{display:flex;flex-direction:column;gap:8px;padding:12px;background:var(--jex-bg-msg-bot, #f1f5f9);border:1px solid var(--jex-border-input, #e2e8f0);border-radius:var(--jex-radius, .75rem);width:100%}.jex-inline-form-title{font-weight:600;font-size:15px;color:var(--jex-text-main, #0f172a);margin:0}.jex-inline-form-subtitle{font-size:13px;color:var(--jex-text-muted, #64748b);line-height:1.4;margin:0 0 4px}.jex-inline-form-consent{font-size:11px;color:var(--jex-text-muted, #64748b);line-height:1.3;margin-top:4px;text-align:center}.jex-inline-form .jex-form-submit:disabled{opacity:.7;cursor:not-allowed}.jex-escalation-subtitle{font-size:13px;color:var(--jex-text-muted, #64748b);line-height:1.45;margin:0 0 8px}.jex-escalation-skip{padding:8px 12px;border:none;background:transparent;color:var(--jex-text-muted, #64748b);font-size:13px;cursor:pointer;text-decoration:underline;text-underline-offset:2px;text-align:center}.jex-escalation-skip:hover{color:var(--jex-text-main, #0f172a)}.jex-inline-form-card{position:relative;padding:14px;gap:8px}.jex-inline-form-dismiss{position:absolute;top:10px;right:10px;width:24px;height:24px;border-radius:50%;border:1px solid var(--jex-border-input, #e2e8f0);background:var(--jex-bg-window, #fff);color:var(--jex-text-muted, #64748b);font-size:12px;cursor:pointer;display:flex;align-items:center;justify-content:center;line-height:1}.jex-inline-form-dismiss:hover{background:var(--jex-bg-msg-bot, #f1f5f9);color:var(--jex-text-main, #0f172a)}.jex-inline-form-submitted{display:flex;align-items:center;gap:10px;padding:10px 12px;background:var(--jex-bg-msg-bot, #f1f5f9);border:1px solid var(--jex-border-input, #e2e8f0);border-radius:var(--jex-radius, .75rem);width:100%}.jex-inline-form-check{display:flex;align-items:center;justify-content:center;width:24px;height:24px;border-radius:50%;background:color-mix(in srgb,var(--jex-primary) 15%,transparent);color:var(--jex-primary, #115A62);font-size:14px;font-weight:700;flex-shrink:0}.jex-inline-form-submitted-title{font-weight:600;font-size:var(--jex-font-size, 14px);color:var(--jex-text-main, #0f172a)}.jex-inline-form-submitted-detail{font-size:12px;color:var(--jex-text-muted, #64748b);margin-top:2px}.jex-escalation-confirm{border-left:3px solid var(--jex-primary, #115A62);padding-left:8px}.jex-session-prompt{display:flex;flex-direction:column;align-items:center;gap:8px;padding:12px 16px;margin:8px 0;text-align:center}.jex-session-prompt-text{font-size:13px;color:var(--jex-text-muted, #64748b)}.jex-session-prompt-btn{padding:8px 16px;border-radius:8px;border:1px solid var(--jex-primary, #115A62);background:transparent;color:var(--jex-primary, #115A62);font-size:13px;font-weight:600;cursor:pointer}.jex-session-prompt-btn:hover{background:color-mix(in srgb,var(--jex-primary) 10%,transparent)}.jex-chat-input-resolved{display:flex;flex-direction:column;align-items:center;gap:10px;padding:14px 16px;border-top:1px solid var(--jex-border-input, #e2e8f0);background:var(--jex-bg-msg-bot, #f1f5f9);text-align:center}.jex-resolved-notice{font-size:13px;font-weight:500;color:var(--jex-text-muted, #64748b)}.jex-resolved-new-btn{padding:10px 20px;border-radius:8px;border:none;background:var(--jex-primary, #115A62);color:#fff;font-size:13px;font-weight:600;cursor:pointer;width:100%}.jex-resolved-new-btn:hover{opacity:.9}.jex-confirmation{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:32px 24px;height:100%;text-align:center}.jex-confirmation-icon{width:48px;height:48px;border-radius:50%;background:color-mix(in srgb,var(--jex-primary, #115A62) 15%,transparent);color:var(--jex-primary, #115A62);font-size:22px;display:flex;align-items:center;justify-content:center}.jex-confirmation-title{font-size:18px;font-weight:700;color:var(--jex-text-main, #0f172a);margin:0}.jex-confirmation-body{font-size:13px;color:var(--jex-text-muted, #64748b);margin:0}.jex-confirmation-ref{font-size:20px;font-weight:700;letter-spacing:.05em;color:var(--jex-primary, #115A62);background:color-mix(in srgb,var(--jex-primary, #115A62) 10%,transparent);padding:10px 20px;border-radius:10px}.jex-confirmation-hint{font-size:12px;color:var(--jex-text-muted, #64748b);margin:0}.jex-confirmation-done{margin-top:8px;padding:10px 28px;border-radius:8px;border:none;background:var(--jex-primary, #115A62);color:#fff;font-size:14px;font-weight:600;cursor:pointer}.jex-home-lookup-link{background:none;border:none;font-size:12px;color:var(--jex-text-muted, #64748b);cursor:pointer;text-decoration:underline;padding:0;align-self:center}.jex-home-lookup{display:flex;gap:8px;width:100%;animation:jexFadeIn .4s .1s ease both}.jex-home-lookup-input{flex:1;padding:10px 14px;border-radius:10px;border:1px solid var(--jex-border-input, #e2e8f0);background:var(--jex-bg-input);color:var(--jex-text-main);font-size:14px;font-family:ui-monospace,Cascadia Code,Fira Code,monospace;letter-spacing:.04em;outline:none;transition:border-color .2s}@media(pointer:coarse){.jex-home-lookup-input{font-size:16px}}.jex-home-lookup-input::placeholder{font-family:inherit;letter-spacing:.04em;color:var(--jex-text-muted);opacity:.7}.jex-home-lookup-input:focus{border-color:var(--jex-primary, #115A62)}.jex-home-lookup-submit{padding:10px 16px;border-radius:10px;border:none;background:var(--jex-primary, #115A62);color:#fff;font-size:13px;font-weight:600;cursor:pointer;font-family:inherit;transition:background .2s,opacity .2s;flex-shrink:0}.jex-home-lookup-submit:hover:not(:disabled){background:var(--jex-primary-hover)}.jex-home-lookup-submit:disabled{opacity:.4;cursor:default}.jex-sources-row{margin-top:6px;margin-left:32px;display:flex;flex-direction:column;gap:6px}.jex-sources-toggle{display:inline-flex;align-items:center;gap:4px;padding:2px 8px;background:transparent;border:none;border-radius:6px;cursor:pointer;font-size:11px;color:var(--jex-text-muted, #6b7280);font-family:inherit;align-self:flex-start;transition:background .15s,color .15s}.jex-sources-toggle:hover{background:#0000000a;color:inherit}.jex-sources-icon{font-size:12px;line-height:1}.jex-sources-chevron{display:inline-block;font-size:10px;transition:transform .15s}.jex-sources-chevron--open{transform:rotate(180deg)}.jex-sources-pills{display:flex;flex-wrap:wrap;align-items:center;gap:6px}.jex-source-pill{display:inline-flex;align-items:center;gap:6px;max-width:240px;padding:2px 8px;border-radius:999px;border:1px solid rgba(0,0,0,.1);background:#0000000a;color:var(--jex-text-muted, #6b7280);font-size:11px;text-decoration:none;cursor:pointer;transition:background .15s,color .15s}.jex-source-pill:hover{background:#00000014;color:inherit}.jex-source-id{display:inline-flex;align-items:center;justify-content:center;min-width:16px;height:16px;padding:0 4px;border-radius:4px;background:var(--jex-primary, #115A62);color:#fff;font-size:10px;font-weight:600;line-height:1;flex-shrink:0;font-variant-numeric:tabular-nums}.jex-source-type{font-size:10px;flex-shrink:0}.jex-source-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:500}.jex-source-score{opacity:.6;flex-shrink:0;font-variant-numeric:tabular-nums}';function du(t){const e=document.createElement("style");e.textContent=hu,t.appendChild(e)}const fu="https://festive-mouse-978.eu-west-1.convex.cloud";let Qn=null;function pu(t){const e=t??fu;if(!e)throw new Error("[jexity] No Convex URL โ set VITE_CONVEX_URL at build time or data-convex-url on the script tag");return Qn||(Qn=new Ra(Da(e))),Qn}function gu(t,e){const n=t.shadowRoot??t.attachShadow({mode:"open"});for(;n.firstChild;)n.removeChild(n.firstChild);du(n),Rt.value=e.source,ue.value=e.bootstrapToken,B.value=[{id:"home"}],e.mode==="embedded"&&(t.classList.add("jex-mode-embedded"),P.value=!0);const r=document.createElement("div");return e.mode==="embedded"&&(r.style.cssText="width:100%;height:100%"),n.appendChild(r),fe(c(Aa,{client:pu(e.convexUrl),children:c(cu,{options:e})}),r),function(){fe(null,r),P.value=!1,Rt.value=void 0,ue.value=void 0,B.value=[{id:"home"}]}}function mu(t,e,n){const r=gu(t,e),i=new Set,o=P.subscribe(l=>{for(const a of i)a(l)});return{shutdown(){o(),i.clear(),r(),n&&n()},open(){P.value=!0},close(){P.value=!1},toggle(){P.value=!P.value},get isOpen(){return P.value},subscribe(l){return i.add(l),()=>{i.delete(l)}}}}let ct=null;function xu(t){ct&&ct.shutdown();let e;t.container?e=typeof t.container=="string"?document.querySelector(t.container):t.container:(e=document.createElement("div"),e.id="jexity-chat-widget",document.body.appendChild(e));const n=mu(e,t,()=>{t.container||e.remove(),ct===n&&(ct=null)});return ct=n,n}function he(t,e){return t.getAttribute(e)??void 0}async function yo(){const t=document.currentScript??document.querySelector("script[data-org-slug]")??document.querySelector("script[data-org-id]");if(!t)return;const e=t.getAttribute("data-org-slug")??t.getAttribute("data-org-id")??"default-org",n=t.getAttribute("data-proj-slug")??void 0,r=he(t,"data-convex-url")??"https://festive-mouse-978.eu-west-1.convex.cloud"??"",i=_n(r),o=await kn(e,i,n);if(!o.ok){const l=window.location.origin,a=n?`project '${e}/${n}'`:`org '${e}'`;o.error==="unauthorized"?console.warn(`[JexityChat] This domain is not authorized for ${a}. Add '${l}' under Allowed Domains in your Jexity dashboard.`):o.error==="not_found"?console.warn(`[JexityChat] No active widget config found for ${a}. Check that the org slug is correct and the widget is enabled.`):o.error==="rate_limited"?console.warn(`[JexityChat] Bootstrap rate-limited for ${a}. Retry after ${o.retryAfterSec??60}s.`):console.warn(`[JexityChat] Bootstrap failed (network error). Check that the Convex deployment is reachable at ${i}.`);return}if(o.allowedUrls.length>0&&!o.allowedUrls.some(l=>jn(window.location.href,l))){const l=n?`project '${e}/${n}'`:`org '${e}'`;console.warn(`[JexityChat] Widget hidden for ${l} โ current page does not match path rule. Allowed: ${o.allowedUrls.join(", ")}`);return}const s={orgSlug:e,projSlug:n,bootstrapToken:o.token,allowedUrls:o.allowedUrls,excludePaths:o.excludePaths,position:he(t,"data-position")??void 0,theme:he(t,"data-theme")??void 0,greeting:he(t,"data-greeting"),title:he(t,"data-title"),primaryColor:he(t,"data-primary-color"),locale:he(t,"data-locale"),convexUrl:he(t,"data-convex-url")};window.JexityChat=xu(s)}document.readyState==="complete"?yo():window.addEventListener("load",yo)})();
|
|
67
|
+
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${le(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let r=this.parser.parseInline(n),i=po(t);if(i===null)return r;t=i;let o='<a href="'+t+'"';return e&&(o+=' title="'+le(e)+'"'),o+=">"+r+"</a>",o}image({href:t,title:e,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=po(t);if(i===null)return le(n);t=i;let o=`<img src="${t}" alt="${le(n)}"`;return e&&(o+=` title="${le(e)}"`),o+=">",o}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:le(t.text)}},Zn=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},ne=class tr{options;renderer;textRenderer;constructor(e){this.options=e||$e,this.options.renderer=this.options.renderer||new Jt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Zn}static parse(e,n){return new tr(n).parse(e)}static parseInline(e,n){return new tr(n).parseInline(e)}parse(e){this.renderer.parser=this;let n="";for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let s=i,a=this.options.extensions.renderers[s.type].call({parser:this},s);if(a!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(s.type)){n+=a||"";continue}}let o=i;switch(o.type){case"space":{n+=this.renderer.space(o);break}case"hr":{n+=this.renderer.hr(o);break}case"heading":{n+=this.renderer.heading(o);break}case"code":{n+=this.renderer.code(o);break}case"table":{n+=this.renderer.table(o);break}case"blockquote":{n+=this.renderer.blockquote(o);break}case"list":{n+=this.renderer.list(o);break}case"checkbox":{n+=this.renderer.checkbox(o);break}case"html":{n+=this.renderer.html(o);break}case"def":{n+=this.renderer.def(o);break}case"paragraph":{n+=this.renderer.paragraph(o);break}case"text":{n+=this.renderer.text(o);break}default:{let s='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return n}parseInline(e,n=this.renderer){this.renderer.parser=this;let r="";for(let i=0;i<e.length;i++){let o=e[i];if(this.options.extensions?.renderers?.[o.type]){let a=this.options.extensions.renderers[o.type].call({parser:this},o);if(a!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(o.type)){r+=a||"";continue}}let s=o;switch(s.type){case"escape":{r+=n.text(s);break}case"html":{r+=n.html(s);break}case"link":{r+=n.link(s);break}case"image":{r+=n.image(s);break}case"checkbox":{r+=n.checkbox(s);break}case"strong":{r+=n.strong(s);break}case"em":{r+=n.em(s);break}case"codespan":{r+=n.codespan(s);break}case"br":{r+=n.br(s);break}case"del":{r+=n.del(s);break}case"text":{r+=n.text(s);break}default:{let a='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return r}},wt=class{options;block;constructor(t){this.options=t||$e}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?te.lex:te.lexInline}provideParser(){return this.block?ne.parse:ne.parseInline}},Lc=class{defaults=Un();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=ne;Renderer=Jt;TextRenderer=Zn;Lexer=te;Tokenizer=Gt;Hooks=wt;constructor(...t){this.use(...t)}walkTokens(t,e){let n=[];for(let r of t)switch(n=n.concat(e.call(this,r)),r.type){case"table":{let i=r;for(let o of i.header)n=n.concat(this.walkTokens(o.tokens,e));for(let o of i.rows)for(let s of o)n=n.concat(this.walkTokens(s.tokens,e));break}case"list":{let i=r;n=n.concat(this.walkTokens(i.items,e));break}default:{let i=r;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(o=>{let s=i[o].flat(1/0);n=n.concat(this.walkTokens(s,e))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let o=e.renderers[i.name];o?e.renderers[i.name]=function(...s){let a=i.renderer.apply(this,s);return a===!1&&(a=o.apply(this,s)),a}:e.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=e[i.level];o?o.unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),r.extensions=e),n.renderer){let i=this.defaults.renderer||new Jt(this.defaults);for(let o in n.renderer){if(!(o in i))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let s=o,a=n.renderer[s],c=i[s];i[s]=(...u)=>{let h=a.apply(i,u);return h===!1&&(h=c.apply(i,u)),h||""}}r.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new Gt(this.defaults);for(let o in n.tokenizer){if(!(o in i))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let s=o,a=n.tokenizer[s],c=i[s];i[s]=(...u)=>{let h=a.apply(i,u);return h===!1&&(h=c.apply(i,u)),h}}r.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new wt;for(let o in n.hooks){if(!(o in i))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let s=o,a=n.hooks[s],c=i[s];wt.passThroughHooks.has(o)?i[s]=u=>{if(this.defaults.async&&wt.passThroughHooksRespectAsync.has(o))return(async()=>{let d=await a.call(i,u);return c.call(i,d)})();let h=a.call(i,u);return c.call(i,h)}:i[s]=(...u)=>{if(this.defaults.async)return(async()=>{let d=await a.apply(i,u);return d===!1&&(d=await c.apply(i,u)),d})();let h=a.apply(i,u);return h===!1&&(h=c.apply(i,u)),h}}r.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,o=n.walkTokens;r.walkTokens=function(s){let a=[];return a.push(o.call(this,s)),i&&(a=a.concat(i.call(this,s))),a}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return te.lex(t,e??this.defaults)}parser(t,e){return ne.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let r={...n},i={...this.defaults,...r},o=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=t),i.async)return(async()=>{let s=i.hooks?await i.hooks.preprocess(e):e,a=await(i.hooks?await i.hooks.provideLexer():t?te.lex:te.lexInline)(s,i),c=i.hooks?await i.hooks.processAllTokens(a):a;i.walkTokens&&await Promise.all(this.walkTokens(c,i.walkTokens));let u=await(i.hooks?await i.hooks.provideParser():t?ne.parse:ne.parseInline)(c,i);return i.hooks?await i.hooks.postprocess(u):u})().catch(o);try{i.hooks&&(e=i.hooks.preprocess(e));let s=(i.hooks?i.hooks.provideLexer():t?te.lex:te.lexInline)(e,i);i.hooks&&(s=i.hooks.processAllTokens(s)),i.walkTokens&&this.walkTokens(s,i.walkTokens);let a=(i.hooks?i.hooks.provideParser():t?ne.parse:ne.parseInline)(s,i);return i.hooks&&(a=i.hooks.postprocess(a)),a}catch(s){return o(s)}}}onError(t,e){return n=>{if(n.message+=`
|
|
68
|
+
Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+le(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},Pe=new Lc;function j(t,e){return Pe.parse(t,e)}j.options=j.setOptions=function(t){return Pe.setOptions(t),j.defaults=Pe.defaults,eo(j.defaults),j},j.getDefaults=Un,j.defaults=$e,j.use=function(...t){return Pe.use(...t),j.defaults=Pe.defaults,eo(j.defaults),j},j.walkTokens=function(t,e){return Pe.walkTokens(t,e)},j.parseInline=Pe.parseInline,j.Parser=ne,j.parser=ne.parse,j.Renderer=Jt,j.TextRenderer=Zn,j.Lexer=te,j.lexer=te.lex,j.Tokenizer=Gt,j.Hooks=wt,j.parse=j,j.options,j.setOptions,j.use,j.walkTokens,j.parseInline,ne.parse,te.lex,j.setOptions({breaks:!0,gfm:!0});function Mc({text:t}){const e=D(()=>{if(!t)return"";const n=j.parse(t);return typeof n=="string"?n:""},[t]);return l("div",{class:"jex-md",dangerouslySetInnerHTML:{__html:e}})}const Ge=$("");function Nc(t){if(!t)return;const e=t.trim().split(/\s+/)[0];if(!e)return;const n=`@${e} `,r=Ge.value;r.includes(n)||r.includes(`@${e}`)||(Ge.value=r.trimStart()?`${n}${r.trimStart()}`:n)}const kt=$(null),xo=$(Date.now()),pe=$([]),zc=4,Oc=8*1024*1024;function Bc(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`att-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,11)}`}function Dc(t){const e=Array.from(t).filter(i=>i.type.startsWith("image/")&&i.size<=Oc);if(e.length===0)return;const n=zc-pe.value.length;if(n<=0)return;const r=e.slice(0,n).map(i=>({id:Bc(),file:i,previewUrl:URL.createObjectURL(i)}));pe.value=[...pe.value,...r]}function Uc(t){const e=pe.value.find(n=>n.id===t);e&&URL.revokeObjectURL(e.previewUrl),pe.value=pe.value.filter(n=>n.id!==t)}function Fc(){for(const t of pe.value)URL.revokeObjectURL(t.previewUrl);pe.value=[]}function bo(t,e){const n={get(r,i){if(typeof i=="string"){const o=[...e,i];return bo(t,o)}else if(i===hi){if(e.length<1){const o=[t,...e].join(".");throw new Error(`API path is expected to be of the form \`${t}.childComponent.functionName\`. Found: \`${o}\``)}return"_reference/childComponent/"+e.join("/")}else return}};return new Proxy({},n)}const Qc=()=>bo("components",[]),ce=Ys;Qc();function Vc({sessionId:t,visitorId:e,ensureSession:n}){const r=dt(ce.functions.chat.public.conversations.send);return async function(o){const s=t&&e?{sessionId:t,visitorId:e}:await n();if(s){Ge.value="",Fc();try{const a=await r({sessionId:s.sessionId,visitorId:s.visitorId,content:o});a.ok?Mn(s.visitorId):a.reason==="rate_limited"&&(kt.value=Date.now()+a.retryAfterMs)}catch(a){console.error("[jexity] Failed to send message:",a)}}}}function Wc(){const t=kt.value,e=xo.value;T(()=>{if(t===null)return;const i=setInterval(()=>{xo.value=Date.now()},1e3),o=setTimeout(()=>{kt.value=null},Math.max(0,t-Date.now()));return()=>{clearInterval(i),clearTimeout(o)}},[t]);const n=t!==null,r=n?Math.max(0,Math.ceil((t-e)/1e3)):0;return{isActive:n,remainingSeconds:r}}function Hc(){const t=_(),{isActive:e,remainingSeconds:n}=Wc();return e?l("div",{class:"jex-rate-limit-notice",role:"status","aria-live":"polite",children:t.errorRateLimited.replace("{seconds}",String(n))}):null}const Je=$(null);function Gc(){const t=_(),e=Je.value;if(e===null)return null;const n=e==="no-token"?t.errorSessionNoToken:e==="unauthorized"?t.errorSessionUnauthorized:e==="network"?t.errorNetwork:t.somethingWentWrong;return l("div",{class:"jex-session-error-notice",role:"alert","aria-live":"assertive",children:n})}function Jc({size:t=18}){return l("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:[l("path",{d:"M22 2 11 13"}),l("path",{d:"M22 2 15 22 11 13 2 9l20-7z"})]})}const vo=132;function Kc({onSend:t}){const e=me(null),n=me(null);T(()=>{const a=e.current;if(!a)return;a.style.height="0";const c=Math.min(a.scrollHeight,vo);a.style.height=`${c}px`,a.style.overflowY=a.scrollHeight>vo?"auto":"hidden"},[Ge.value]);function r(a){a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),t())}function i(){n.current?.click()}function o(a){const c=a.currentTarget;c.files&&c.files.length>0&&Dc(c.files),c.value=""}function s(a){const c=a.target;(c===a.currentTarget||!c.closest("button, textarea, img"))&&e.current?.focus()}return{textareaRef:e,fileInputRef:n,onKeyDown:r,onAttachClick:i,onFilesPicked:o,onCardClick:s}}function Zc({isStreaming:t,disabled:e,inputDisabled:n,onSend:r,onFocus:i}){const o=_(),s=Ge,a=pe,{textareaRef:c,fileInputRef:u,onKeyDown:h,onAttachClick:d,onFilesPicked:f,onCardClick:p}=Kc({onSend:r}),g=s.value.trim().length>0,x=a.value.length>0,v=(g||x)&&!e;return l("div",{class:"jex-composer-card",onClick:p,children:[x&&l("div",{class:"jex-composer-attachments",role:"list",children:a.value.map(m=>l("div",{class:"jex-attachment-chip",role:"listitem",children:[l("img",{src:m.previewUrl,alt:m.file.name,class:"jex-attachment-thumb"}),l("button",{type:"button",class:"jex-attachment-remove","aria-label":o.removeAttachmentAriaLabel,onClick:()=>{Uc(m.id)},children:l("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:[l("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),l("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},m.id))}),l("textarea",{ref:c,class:"jex-composer-textarea","aria-label":o.inputPlaceholder,placeholder:t?o.aiThinking:o.inputPlaceholder,value:s.value,rows:1,onInput:m=>{s.value=m.currentTarget.value},onKeyDown:h,onFocus:i,disabled:n}),l("div",{class:"jex-composer-actions",children:[l("div",{class:"jex-composer-actions-left",children:[l("input",{ref:u,class:"jex-visually-hidden",type:"file",accept:"image/*",multiple:!0,onChange:f,tabIndex:-1,"aria-hidden":"true"}),l("button",{type:"button",class:"jex-attach-btn","aria-label":o.attachComingSoon,title:o.attachComingSoon,disabled:!0,onClick:d,children:l("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:l("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})})})]}),l("button",{class:`jex-send-btn${v?" jex-send-btn-active":""}`,type:"button",onClick:r,"aria-label":o.sendAriaLabel,disabled:e||!g&&!x,children:l(Jc,{size:16})})]})]})}function yo({variant:t,isOpen:e=!1,onAcknowledge:n}){const r=_(),i=gt.value;return t==="explicit"?e?l("div",{class:"jex-privacy-explicit",role:"dialog","aria-label":r.privacyExplicitTitle,children:[l("div",{class:"jex-privacy-explicit-content",children:[l("div",{class:"jex-privacy-explicit-icon","aria-hidden":"true",children:l("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:l("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"})})}),l("div",{class:"jex-privacy-explicit-copy",children:[l("div",{class:"jex-privacy-explicit-title",children:r.privacyExplicitTitle}),l("p",{class:"jex-privacy-explicit-body",children:[r.privacyExplicitBodyPre," ",l("a",{href:i,target:"_blank",rel:"noopener noreferrer",class:"jex-privacy-notice-link",children:r.privacyPolicyLinkText}),"."]})]})]}),l("button",{type:"button",class:"jex-privacy-explicit-button",onClick:n,children:r.privacyExplicitButton})]}):null:l("p",{class:"jex-privacy-chip",children:[l("span",{class:"jex-privacy-chip-icon","aria-hidden":"true",children:l("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:l("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"})})}),l("a",{href:i,target:"_blank",rel:"noopener noreferrer",class:"jex-privacy-chip-link",children:r.privacyChipText})]})}function Yc({sessionId:t,visitorId:e,isLoading:n,isStreaming:r,sessionStatus:i,ensureSession:o,onStartFresh:s}){const a=_(),c=Ge,u=Li.value,[h,d]=C({open:!1,acknowledged:!1}),f=Vc({sessionId:t,visitorId:e,ensureSession:o}),p=kt.value!==null&&kt.value>Date.now(),g=n||r||p,x=u==="explicit"&&!h.acknowledged,v=u==="explicit"&&h.open;function m(){x&&d(q=>({...q,open:!0}))}function b(){d({open:!1,acknowledged:!0})}if(T(()=>{d({open:!1,acknowledged:!1})},[t]),i==="resolved")return l("div",{class:"jex-chat-input-resolved",children:[l("div",{class:"jex-resolved-notice",children:a.sessionResolved}),l("button",{class:"jex-resolved-new-btn",type:"button",onClick:()=>{s()},children:a.startNewConversation})]});async function E(){const q=c.value.trim();if(!(!q||g)){if(x){d(z=>({...z,open:!0}));return}await f(q)}}return l("div",{class:"jex-chat-input",children:[l(Hc,{}),l(Gc,{}),u==="chip"&&l(yo,{variant:"chip"}),l("div",{class:`jex-chat-input-composer-gate${v?" jex-chat-input-composer-gate-open":""}`,children:[l(Zc,{isStreaming:r,disabled:g,inputDisabled:n||r||v,onSend:E,onFocus:m}),u==="explicit"&&l(yo,{variant:"explicit",isOpen:h.open,onAcknowledge:b})]})]})}function Xc(t){const e=t.trim().split(/\s+/).filter(Boolean);return e.length===0?"?":e.map(n=>n[0]).join("").slice(0,2).toUpperCase()}function Ke({text:t,streaming:e,error:n,authorId:r,authorName:i,authorImage:o,botAvatarUrl:s}){const a=_(),c=!!r,[u,h]=C(!1),d=ue(()=>h(!0),[]),f=a.replyTo.replace("{name}",i??""),p=["jex-message bot",n?"jex-message-error":""].filter(Boolean).join(" ");return l("div",{class:"jex-message-row bot",children:[l("div",{class:`jex-avatar ${c?"jex-avatar-agent":"jex-avatar-bot"}`,children:c&&o&&!u?l("img",{src:o,alt:i??"",class:"jex-avatar-img",onError:d}):c?l("span",{class:"jex-avatar-initials",children:Xc(i??"")}):s&&!u?l("img",{src:s,alt:"",class:"jex-avatar-img",onError:d}):l(Dn,{size:14})}),l("div",{class:"jex-message-content",children:[l("div",{class:p,children:[l(Mc,{text:t}),e&&l("span",{class:"jex-streaming-cursor"})]}),c&&i&&l("div",{class:"jex-message-author-row",children:[l("span",{class:"jex-message-author",children:i}),l("button",{type:"button",class:"jex-reply-tag-btn","aria-label":f,title:f,onClick:()=>{Nc(i)},children:l(Gl,{size:12})})]})]})]})}function eu({text:t}){return l("div",{class:"jex-message user",children:t})}function wo(){return dt(ce.functions.chat.public.helpdesk.submitEscalation)}function tu({message:t,sessionId:e,visitorId:n}){const r=_();return t.formData?l("div",{class:"jex-inline-form-submitted",children:[l("span",{class:"jex-inline-form-check",children:"โ"}),l("div",{children:[l("div",{class:"jex-inline-form-submitted-title",children:r.escalationSubmitted}),l("div",{class:"jex-inline-form-submitted-detail",children:[t.formData.visitorName," ยท ",t.formData.visitorEmail]})]})]}):l("div",{class:"jex-message-row bot",children:l(nu,{messageId:t._id,sessionId:e,visitorId:n})})}function nu({messageId:t,sessionId:e,visitorId:n}){const r=_(),[i,o]=C(""),[s,a]=C(""),[c,u]=C(!1),h=gt.value,d=/^https?:\/\//i.test(h)?h:pt,f=wo();async function p(g){if(g.preventDefault(),!c){u(!0);try{await f({sessionId:e,visitorId:n,formMessageId:t,visitorName:i.trim(),visitorEmail:s.trim(),locale:fe.value})}catch(x){console.error("[FormMessage] Submit failed:",x),u(!1)}}}return l("div",{class:"jex-inline-form",children:[l("div",{class:"jex-inline-form-title",children:r.escalationFormTitle}),l("form",{class:"jex-form",onSubmit:g=>{p(g)},children:[l("input",{class:"jex-form-input",type:"text",placeholder:r.escalationNameLabel,value:i,required:!0,disabled:c,onInput:g=>{o(g.currentTarget.value)}}),l("input",{class:"jex-form-input",type:"email",placeholder:r.escalationEmailLabel,value:s,required:!0,disabled:c,onInput:g=>{a(g.currentTarget.value)}}),l("button",{class:"jex-form-submit",type:"submit",disabled:c,children:c?r.escalationSubmitting:r.escalationSubmit})]}),l("div",{class:"jex-inline-form-consent",children:[r.escalationConsent," ",l("a",{href:d,target:"_blank",rel:"noopener noreferrer",class:"jex-privacy-notice-link",children:r.escalationPrivacyLinkText}),"."]})]})}function ru(){return dt(ce.functions.magicline.public.submitForm)}function iu(){return ji(ce.functions.magicline.actions.getTrialConfig)}function ou(){return ji(ce.functions.magicline.actions.listTrialSlots)}const su=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function au(t){return su.test(t.trim())}function lu(t,e=new Date){const n=t.trim();if(n==="")return null;const r=n.split("-");if(r.length!==3)return null;const i=Number(r[0]),o=Number(r[1]),s=Number(r[2]);if(!Number.isInteger(i)||!Number.isInteger(o)||!Number.isInteger(s)||o<1||o>12||s<1||s>31)return null;let a=e.getFullYear()-i;const c=e.getMonth()+1-o;return(c<0||c===0&&e.getDate()<s)&&(a-=1),a}function cu(t=new Date){const e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${r}`}function uu(){const t=gt.value;return/^https?:\/\//i.test(t)?t:pt}const du=["MALE","FEMALE","UNISEX"],hu=[{code:"DE",label:"Germany / Deutschland"},{code:"AT",label:"Austria / รsterreich"},{code:"CH",label:"Switzerland / Schweiz"},{code:"LI",label:"Liechtenstein"},{code:"LU",label:"Luxembourg / Luxemburg"},{code:"NL",label:"Netherlands / Niederlande"},{code:"BE",label:"Belgium / Belgien"},{code:"FR",label:"France / Frankreich"},{code:"IT",label:"Italy / Italien"},{code:"ES",label:"Spain / Spanien"},{code:"PL",label:"Poland / Polen"},{code:"CZ",label:"Czechia / Tschechien"},{code:"DK",label:"Denmark / Dรคnemark"},{code:"GB",label:"United Kingdom"},{code:"US",label:"United States"}];function fu(t,e){const n=[];return e&&n.push("trainer"),n.push("slot"),n.push("personal"),(t.address.visible||t.zip.visible)&&n.push("address"),n.push("confirm"),n}const pu={firstName:"",lastName:"",email:"",phone:"",birthDate:"",gender:"",street:"",houseNumber:"",zip:"",city:"",country:"",note:"",slotId:"",consent:!1,trainerRequired:!0};function gu(t,e){switch(e.type){case"set":return{...t,[e.key]:e.value};case"setTrainer":return{...t,trainerRequired:e.trainerRequired,slotId:""};case"clearSlotIfAbsent":return t.slotId!==""&&!e.available.includes(t.slotId)?{...t,slotId:""}:t;default:return t}}function mu({sessionId:t,visitorId:e}){const n=iu(),r=ou(),[i,o]=je(gu,pu),[s,a]=je((m,b)=>b,{phase:"loading"}),[c,u]=je((m,b)=>b,{phase:"loading"}),[h,d]=je(m=>m+1,0),f=ue((m,b)=>{o({type:"set",key:m,value:b})},[]),p=ue(m=>{o({type:"setTrainer",trainerRequired:m}),d()},[]),g=ue(()=>{d()},[]);T(()=>{let m=!1;return(async()=>{try{const b=await n({sessionId:t,visitorId:e});if(m)return;b.status==="ok"?a({phase:"ready",config:{plan:b.plan,minimumAge:b.minimumAge,bookingWithoutTrainerAllowed:b.bookingWithoutTrainerAllowed,studioZoneId:b.studioZoneId}}):a({phase:"error",code:b.status,backendMessage:b.message})}catch{m||a({phase:"error",code:"unavailable",backendMessage:""})}})(),()=>{m=!0}},[n,t,e]);const x=s.phase==="ready",{trainerRequired:v}=i;return T(()=>{if(!x)return;let m=!1;return u({phase:"loading"}),(async()=>{try{const b=await r({sessionId:t,visitorId:e,trainerRequired:v});if(m)return;b.status==="ok"?b.slots.length>0?(u({phase:"ready",slots:b.slots}),o({type:"clearSlotIfAbsent",available:b.slots.map(E=>E.startDateTime)})):u({phase:"empty"}):u({phase:"error"})}catch{m||u({phase:"error"})}})(),()=>{m=!0}},[x,r,t,e,v,h]),{fields:i,setField:f,setTrainerRequired:p,configState:s,slotsState:c,refetchSlots:g}}function xu({formMessageId:t,sessionId:e,visitorId:n,slotUnavailable:r=!1,retryPending:i=!1}){const o=_(),s=ru(),{fields:a,setField:c,setTrainerRequired:u,configState:h,slotsState:d,refetchSlots:f}=mu({sessionId:e,visitorId:n});return h.phase==="loading"?l("div",{class:"jex-inline-form jex-magicline-form",children:[l("div",{class:"jex-inline-form-title",children:o.magiclineTrialTitle}),l("div",{class:"jex-magicline-slots-hint",children:o.magiclineConfigLoading})]}):h.phase==="error"?l("div",{class:"jex-inline-form jex-magicline-form",children:[l("div",{class:"jex-inline-form-title",children:o.magiclineTrialTitle}),l("div",{class:"jex-magicline-slots-hint",role:"alert",children:Su(h.code,h.backendMessage,o)})]}):l(bu,{formMessageId:t,sessionId:e,visitorId:n,slotUnavailable:r,retryPending:i,config:h.config,fields:a,setField:c,setTrainerRequired:u,slotsState:d,refetchSlots:f,submitForm:s})}function bu({formMessageId:t,sessionId:e,visitorId:n,slotUnavailable:r,retryPending:i,config:o,fields:s,setField:a,setTrainerRequired:c,slotsState:u,refetchSlots:h,submitForm:d}){const f=_(),{plan:p,minimumAge:g,bookingWithoutTrainerAllowed:x,studioZoneId:v}=o,m=D(()=>fu(p,x),[p,x]),b=r?Math.max(m.indexOf("slot"),0):0,[E,q]=C(b),[z,L]=C({}),[Z,Ie]=C(!1),[we,qe]=C(null),Y=D(()=>uu(),[]),X=Math.min(E,m.length-1),Le=m[X],$o=X===m.length-1,ed=X===0;function Eo(B){const S={};if(B==="slot")return s.slotId===""&&(S.slotId=f.magiclineSlotRequiredError),S;if(B==="personal"){if(s.firstName.trim()===""&&(S.firstName=f.magiclineRequiredError),s.lastName.trim()===""&&(S.lastName=f.magiclineRequiredError),p.email.visible&&p.email.required&&s.email.trim()===""&&(S.email=f.magiclineRequiredError),s.email.trim()!==""&&!au(s.email)&&(S.email=f.magiclineEmailError),p.phone.visible&&p.phone.required&&s.phone.trim()===""&&(S.phone=f.magiclineRequiredError),p.gender.visible&&p.gender.required&&s.gender===""&&(S.gender=f.magiclineRequiredError),p.dateOfBirth.visible&&(p.dateOfBirth.required&&s.birthDate.trim()===""&&(S.birthDate=f.magiclineRequiredError),s.birthDate.trim()!=="")){const Kt=lu(s.birthDate);Kt!==null&&Kt<0?S.birthDate=f.magiclineRequiredError:g>0&&Kt!==null&&Kt<g&&(S.birthDate=f.magiclineMinAgeError.replace("{age}",String(g)))}return S}return B==="address"?(p.address.visible&&p.address.required&&(s.street.trim()===""&&(S.street=f.magiclineRequiredError),s.houseNumber.trim()===""&&(S.houseNumber=f.magiclineRequiredError),s.city.trim()===""&&(S.city=f.magiclineRequiredError),s.country===""&&(S.country=f.magiclineRequiredError)),p.zip.visible&&p.zip.required&&s.zip.trim()===""&&(S.zip=f.magiclineRequiredError),S):(B==="confirm"&&(s.consent||(S.consent=f.magiclineConsentError)),S)}function td(){const B=Eo(Le);if(Object.keys(B).length>0){L(B);return}L({}),q(S=>Math.min(S+1,m.length-1))}function nd(){L({}),qe(null),q(B=>Math.max(B-1,0))}async function rd(){if(Z)return;const B=Eo("confirm");if(Object.keys(B).length>0){L(B);return}L({}),qe(null),Ie(!0);try{const S=Cu(p,s);await d({sessionId:e,visitorId:n,formMessageId:t,action:"trialSessionBooking",fields:S})}catch(S){console.error("[TrialSessionBookingForm] Submit failed:",S),qe(f.magiclineFailedDetail),Ie(!1)}}function id(){$o?rd():td()}const Po=ju(Le,f),od=`jex-ml-consent-${t}`;return l("div",{class:"jex-inline-form jex-magicline-form",children:[l("div",{class:"jex-magicline-wizard-header",children:[l("div",{class:"jex-inline-form-title",children:f.magiclineTrialTitle}),l("div",{class:"jex-magicline-wizard-progress",children:[l("span",{class:"jex-magicline-wizard-step-label",children:Po}),l("span",{class:"jex-magicline-wizard-counter",children:f.magiclineStepCounter.replace("{n}",String(X+1)).replace("{total}",String(m.length))})]}),l("div",{class:"jex-magicline-wizard-dots","aria-hidden":"true",children:m.map((B,S)=>l("span",{class:S===X?"jex-magicline-wizard-dot jex-magicline-wizard-dot-active":"jex-magicline-wizard-dot"},B))})]}),l("div",{class:"jex-form",role:"group","aria-label":Po,children:[Le==="trainer"?l(vu,{formMessageId:t,trainerRequired:s.trainerRequired,disabled:Z,onChange:c}):null,Le==="slot"?l(yu,{slotsState:u,slotId:s.slotId,studioZoneId:v,disabled:Z,retryPending:i,slotUnavailable:r,error:z.slotId,onSelect:B=>{a("slotId",B)},onRetry:h}):null,Le==="personal"?l(wu,{plan:p,fields:s,errors:z,disabled:Z,setField:a}):null,Le==="address"?l(ku,{plan:p,fields:s,errors:z,disabled:Z,setField:a}):null,Le==="confirm"?l(_u,{consentId:od,privacyUrl:Y,studioZoneId:v,fields:s,disabled:Z,consentError:z.consent,setField:a}):null,we!==null?l("div",{class:"jex-magicline-error",role:"alert",children:we}):null,l("div",{class:"jex-magicline-wizard-nav",children:[ed?null:l("button",{type:"button",class:"jex-magicline-wizard-back",disabled:Z,onClick:nd,children:f.magiclineWizardBack}),l("button",{type:"button",class:"jex-form-submit jex-magicline-wizard-next",disabled:Z,onClick:id,children:$o?Z?f.magiclineSubmitting:f.magiclineSubmit:f.magiclineWizardNext})]})]})]})}function vu({formMessageId:t,trainerRequired:e,disabled:n,onChange:r}){const i=_(),o=`jex-ml-trainer-${t}`;return l("div",{class:"jex-magicline-radio-group",role:"radiogroup","aria-label":i.magiclineStepTrainer,children:[l("label",{class:e?"jex-magicline-radio-card jex-magicline-radio-card-active":"jex-magicline-radio-card",children:[l("input",{type:"radio",name:o,checked:e,disabled:n,onChange:()=>{r(!0)}}),l("span",{children:i.magiclineTrainerWith})]}),l("label",{class:e?"jex-magicline-radio-card":"jex-magicline-radio-card jex-magicline-radio-card-active",children:[l("input",{type:"radio",name:o,checked:!e,disabled:n,onChange:()=>{r(!1)}}),l("span",{children:i.magiclineTrainerWithout})]})]})}function yu({slotsState:t,slotId:e,studioZoneId:n,disabled:r,retryPending:i,slotUnavailable:o,error:s,onSelect:a,onRetry:c}){const u=_();return l(M,{children:[o?l("div",{class:"jex-magicline-error",role:"alert",children:u.magiclineSlotUnavailableNotice}):null,i||t.phase==="loading"?l("div",{class:"jex-magicline-slots-hint","aria-live":"polite",children:u.magiclineLoadingSlots}):t.phase==="ready"?l("select",{class:"jex-form-input jex-magicline-select","aria-label":u.magiclineSlotLabel,value:e,required:!0,disabled:r,"aria-invalid":s!==void 0,onChange:h=>{a(h.currentTarget.value)},children:[l("option",{value:"",disabled:!0,children:u.magiclineSlotPlaceholder}),t.slots.map(h=>l("option",{value:h.startDateTime,children:_o(h.startDateTime,fe.value,n)},h.startDateTime))]}):t.phase==="error"?l("div",{class:"jex-magicline-slots-error",children:[l("div",{class:"jex-magicline-slots-hint",role:"alert","aria-live":"polite",children:u.magiclineSlotsError}),l("button",{type:"button",class:"jex-magicline-retry",disabled:r,onClick:c,children:u.magiclineRetry})]}):l("div",{class:"jex-magicline-slots-hint",role:"alert","aria-live":"polite",children:u.magiclineNoSlots}),s!==void 0?l("div",{class:"jex-magicline-error",role:"alert",children:s}):null]})}function wu({plan:t,fields:e,errors:n,disabled:r,setField:i}){const o=_(),s=D(()=>cu(),[]);return l(M,{children:[l("div",{class:"jex-magicline-row",children:[l(ve,{label:o.magiclineFirstName,value:e.firstName,required:!0,disabled:r,error:n.firstName,fieldKey:"firstName",onInput:a=>{i("firstName",a)}}),l(ve,{label:o.magiclineLastName,value:e.lastName,required:!0,disabled:r,error:n.lastName,fieldKey:"lastName",onInput:a=>{i("lastName",a)}})]}),t.email.visible?l(ve,{label:K(o.magiclineEmail,t.email.required,o),type:"email",value:e.email,required:t.email.required,disabled:r,error:n.email,fieldKey:"email",onInput:a=>{i("email",a)}}):null,t.phone.visible?l(ve,{label:K(o.magiclinePhone,t.phone.required,o),type:"tel",value:e.phone,required:t.phone.required,disabled:r,error:n.phone,fieldKey:"phone",onInput:a=>{i("phone",a)}}):null,t.dateOfBirth.visible?l("label",{class:"jex-magicline-field",children:[l("span",{class:"jex-magicline-field-label",children:K(o.magiclineBirthDate,t.dateOfBirth.required,o)}),l("input",{class:"jex-form-input",type:"date","aria-label":K(o.magiclineBirthDate,t.dateOfBirth.required,o),value:e.birthDate,max:s,required:t.dateOfBirth.required,disabled:r,"aria-invalid":n.birthDate!==void 0,onInput:a=>{i("birthDate",a.currentTarget.value)}}),n.birthDate!==void 0?l("span",{class:"jex-magicline-error",role:"alert",children:n.birthDate}):null]}):null,t.gender.visible?l(ko,{label:K(o.magiclineGender,t.gender.required,o),value:e.gender,required:t.gender.required,disabled:r,placeholder:K(o.magiclineGenderPlaceholder,t.gender.required,o),error:n.gender,onChange:a=>{i("gender",a)},options:du.map(a=>({value:a,label:Tu(a,o)}))}):null]})}function ku({plan:t,fields:e,errors:n,disabled:r,setField:i}){const o=_();return l(M,{children:[t.address.visible?l(M,{children:[l("div",{class:"jex-magicline-row",children:[l(ve,{label:K(o.magiclineStreet,t.address.required,o),value:e.street,required:t.address.required,disabled:r,error:n.street,fieldKey:"street",onInput:s=>{i("street",s)}}),l(ve,{label:K(o.magiclineHouseNumber,t.address.required,o),value:e.houseNumber,required:t.address.required,disabled:r,error:n.houseNumber,fieldKey:"houseNumber",onInput:s=>{i("houseNumber",s)}})]}),l(ve,{label:K(o.magiclineCity,t.address.required,o),value:e.city,required:t.address.required,disabled:r,error:n.city,fieldKey:"city",onInput:s=>{i("city",s)}}),l(ko,{label:K(o.magiclineCountry,t.address.required,o),value:e.country,required:t.address.required,disabled:r,placeholder:K(o.magiclineCountryPlaceholder,t.address.required,o),error:n.country,onChange:s=>{i("country",s)},options:hu.map(s=>({value:s.code,label:s.label}))})]}):null,t.zip.visible?l(ve,{label:K(o.magiclineZip,t.zip.required,o),value:e.zip,required:t.zip.required,disabled:r,error:n.zip,fieldKey:"zip",onInput:s=>{i("zip",s)}}):null]})}function _u({consentId:t,privacyUrl:e,studioZoneId:n,fields:r,disabled:i,consentError:o,setField:s}){const a=_(),c=r.slotId!==""?_o(r.slotId,fe.value,n):"โ",u=`${r.firstName} ${r.lastName}`.trim();return l(M,{children:[l("dl",{class:"jex-magicline-summary",children:[l("div",{class:"jex-magicline-summary-row",children:[l("dt",{children:a.magiclineSummaryTrainer}),l("dd",{children:r.trainerRequired?a.magiclineTrainerWith:a.magiclineTrainerWithout})]}),l("div",{class:"jex-magicline-summary-row",children:[l("dt",{children:a.magiclineSummarySlot}),l("dd",{children:c})]}),l("div",{class:"jex-magicline-summary-row",children:[l("dt",{children:a.magiclineSummaryName}),l("dd",{children:u!==""?u:"โ"})]})]}),l("textarea",{class:"jex-form-textarea","aria-label":a.magiclineNote,placeholder:a.magiclineNote,value:r.note,disabled:i,onInput:h=>{s("note",h.currentTarget.value)}}),l("label",{class:"jex-magicline-consent",for:t,children:[l("input",{id:t,type:"checkbox",checked:r.consent,disabled:i,"aria-invalid":o!==void 0,onChange:h=>{s("consent",h.currentTarget.checked)}}),l("span",{children:[a.magiclineConsent," ",l("a",{href:e,target:"_blank",rel:"noopener noreferrer",class:"jex-privacy-notice-link",children:a.magiclinePrivacyLinkText}),"."]})]}),o!==void 0?l("div",{class:"jex-magicline-error",role:"alert",children:o}):null]})}function ve({label:t,value:e,fieldKey:n,type:r="text",required:i=!1,disabled:o,error:s,onInput:a}){const c=s!==void 0?`jex-ml-err-${n}`:void 0;return l("div",{class:"jex-magicline-field",children:[l("input",{class:"jex-form-input",type:r,"aria-label":t,placeholder:t,value:e,required:i,disabled:o,"aria-invalid":s!==void 0,"aria-describedby":c,onInput:u=>{a(u.currentTarget.value)}}),s!==void 0?l("span",{id:c,class:"jex-magicline-error",role:"alert",children:s}):null]})}function ko({label:t,value:e,required:n,disabled:r,placeholder:i,error:o,options:s,onChange:a}){return l("div",{class:"jex-magicline-field",children:[l("select",{class:"jex-form-input jex-magicline-select","aria-label":t,value:e,required:n,disabled:r,"aria-invalid":o!==void 0,onChange:c=>{a(c.currentTarget.value)},children:[l("option",{value:"",disabled:n,children:i}),s.map(c=>l("option",{value:c.value,children:c.label},c.value))]}),o!==void 0?l("span",{class:"jex-magicline-error",role:"alert",children:o}):null]})}function K(t,e,n){return e?t:t+n.magiclineOptionalSuffix}function ju(t,e){switch(t){case"trainer":return e.magiclineStepTrainer;case"slot":return e.magiclineStepSlot;case"personal":return e.magiclineStepPersonal;case"address":return e.magiclineStepAddress;case"confirm":return e.magiclineStepConfirm;default:return""}}function Su(t,e,n){return e.trim()!==""?e:t==="unsupported"?n.magiclineConfigUnsupported:t==="inconsistent"?n.magiclineConfigInconsistent:n.magiclineConfigUnavailable}function Cu(t,e){const n={firstname:e.firstName.trim(),lastname:e.lastName.trim(),slotId:e.slotId,trainerRequired:e.trainerRequired,privacyConsent:e.consent};return t.email.visible&&e.email.trim()!==""&&(n.email=e.email.trim()),t.phone.visible&&e.phone.trim()!==""&&(n.phone=e.phone.trim()),t.dateOfBirth.visible&&e.birthDate.trim()!==""&&(n.dateOfBirth=e.birthDate.trim()),t.gender.visible&&e.gender!==""&&(n.gender=e.gender),t.address.visible&&(e.street.trim()!==""&&(n.street=e.street.trim()),e.houseNumber.trim()!==""&&(n.houseNumber=e.houseNumber.trim()),e.city.trim()!==""&&(n.city=e.city.trim()),e.country!==""&&(n.country=e.country)),t.zip.visible&&e.zip.trim()!==""&&(n.zip=e.zip.trim()),e.note.trim()!==""&&(n.note=e.note.trim()),n}function Tu(t,e){return t==="MALE"?e.magiclineGenderMale:t==="FEMALE"?e.magiclineGenderFemale:e.magiclineGenderUnisex}function _o(t,e,n){const r=e==="de"?"de-DE":"en-GB",i=t.match(/\[([^\]]+)\]\s*$/),o=i?i[1]:n??void 0,s=t.replace(/\[[^\]]+\]\s*$/,""),a=new Date(s);if(Number.isNaN(a.getTime()))return t;try{return a.toLocaleString(r,{weekday:"short",day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",...o?{timeZone:o,timeZoneName:"short"}:{timeZoneName:"short"}})}catch{return a.toLocaleString(r,{weekday:"short",day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",timeZoneName:"short"})}}function Ru({message:t,sessionId:e,visitorId:n}){const r=_(),i=t.magiclineForm,o=!!i&&i.status==="open"&&!!i.submissionId,s=Sn(ce.functions.magicline.public.getSubmissionStatus,o&&i?.submissionId?{sessionId:e,visitorId:n,submissionId:i.submissionId}:"skip");if(!i)return null;if(i.status==="submitted")return l("div",{class:"jex-inline-form-submitted",children:[l("span",{class:"jex-inline-form-check",children:"โ"}),l("div",{children:[l("div",{class:"jex-inline-form-submitted-title",children:r.magiclineSubmitted}),l("div",{class:"jex-inline-form-submitted-detail",children:r.magiclineSubmittedDetail})]})]});if(i.status==="failed")return l("div",{class:"jex-inline-form-submitted jex-magicline-failed",children:[l("span",{class:"jex-inline-form-check jex-magicline-failed-icon",children:"!"}),l("div",{children:[l("div",{class:"jex-inline-form-submitted-title",children:r.magiclineFailed}),l("div",{class:"jex-inline-form-submitted-detail",children:r.magiclineFailedDetail})]})]});if(i.action!=="trialSessionBooking")return null;const a=s!=null&&s.errorCode==="slot_unavailable",c=o&&s===void 0;return l(xu,{formMessageId:t._id,sessionId:e,visitorId:n,slotUnavailable:a,retryPending:c})}const Au={crawl:"๐",file:"๐",snippet:"๐ก",qa:"โ"};function $u({sources:t}){const e=_(),[n,r]=C(!1);return t.length===0?null:l("div",{class:"jex-sources-row",children:[l("button",{type:"button",class:"jex-sources-toggle",onClick:()=>{r(i=>!i)},"aria-expanded":n,children:[l("span",{class:"jex-sources-icon",children:"๐"}),l("span",{children:(t.length===1?e.sourcesCountOne:e.sourcesCountOther).replace("{count}",String(t.length))}),l("span",{class:`jex-sources-chevron${n?" jex-sources-chevron--open":""}`,children:"โพ"})]}),n?l("div",{class:"jex-sources-pills",children:t.map((i,o)=>{const s=i.sourceType==="crawl",a=Eu(i),c=s&&i.url?`${i.title}
|
|
69
|
+
${i.url}`:i.title,u=l(M,{children:[typeof i.id=="number"?l("span",{class:"jex-source-id",children:i.id}):null,l("span",{class:"jex-source-type",children:Au[i.sourceType]}),l("span",{class:"jex-source-label",children:a}),l("span",{class:"jex-source-score",children:["ยท ",i.score.toFixed(2)]})]});return s&&i.url?l("a",{class:"jex-source-pill",href:i.url,target:"_blank",rel:"noopener noreferrer",title:c,children:u},o):l("span",{class:"jex-source-pill",title:c,children:u},o)})}):null]})}function Eu(t){if(t.sourceType==="crawl"&&t.url)try{const e=new URL(t.url);return!e.pathname||e.pathname==="/"?e.hostname:e.pathname}catch{}return t.title}function Pu(){return l("div",{class:"jex-typing",children:[l("span",{}),l("span",{}),l("span",{})]})}const Iu=/\s?\[\d+\]/g;function jo(t){return t.replace(Iu,"")}function qu({conversations:t,greeting:e,sessionNotFound:n,resumeFailed:r,onStartFresh:i,sessionId:o,visitorId:s}){const a=_(),c=me(null),[u,h]=C(null),d=me(null);return T(()=>{if(!s||!t||t.length===0)return;const f=t[t.length-1];f.role==="assistant"&&f.status!=="streaming"&&f._id!==d.current&&(d.current=f._id,Mn(s))},[t,s]),T(()=>{c.current?.scrollIntoView({behavior:"smooth"})},[t?.length,t?.at(-1)?.content]),l("div",{class:"jex-chat-messages",children:[l(Ke,{text:e}),n&&r&&i?l("div",{class:"jex-session-prompt",children:[l("div",{class:"jex-session-prompt-text",children:a.sessionNotFoundPrompt}),l("button",{class:"jex-session-prompt-btn",type:"button",onClick:()=>{i()},children:a.startNewConversation})]}):n?l("div",{class:"jex-session-notice",children:a.sessionNotFound}):null,t?.map(f=>{if(f.contentType==="human-notice"){const g=f.noticeKind==="agent-joined"?a.noticeAgentJoined.replace("{name}",f.noticeData?.agentName??""):f.noticeKind==="human-requested"?a.noticeHumanRequested:f.noticeKind==="human-requested-form"?a.noticeHumanRequestedForm:f.noticeKind==="message-received"?a.noticeMessageReceived:f.noticeKind==="agent-handling"?a.noticeAgentHandling:f.content;return l(Ke,{text:g},f._id)}if(f.contentType==="escalation-form"&&o&&s)return jl.value==="screen"&&!f.formData?u===f._id?null:l("div",{class:"jex-inline-form jex-inline-form-card",children:[l("div",{class:"jex-inline-form-title",children:a.escalationPromptTitle}),l("div",{class:"jex-inline-form-subtitle",children:a.escalationPromptSubtitle}),l("button",{class:"jex-form-submit",type:"button",onClick:()=>{Ae({id:"escalation-form",formMessageId:f._id,sessionId:o,visitorId:s})},children:a.escalationPromptSubmit}),l("button",{class:"jex-escalation-skip",type:"button",onClick:()=>{h(f._id)},children:a.escalationSkip})]},f._id):l(tu,{message:f,sessionId:o,visitorId:s},f._id);if(f.contentType==="magicline-form"&&o&&s)return l(Ru,{message:f,sessionId:o,visitorId:s},f._id);if(f.contentType==="escalation-confirm"){const g=f.noticeKind==="escalation-confirmed"?a.noticeEscalationConfirmed.replace("{name}",f.noticeData?.visitorName??"").replace("{email}",f.noticeData?.visitorEmail??"").replace("{ref}",f.noticeData?.visitorId??""):f.content;return l(Ke,{text:g},f._id)}if(f.role==="user")return l(eu,{text:f.content},f._id);const p={authorId:f.authorId,authorName:f.authorName,authorImage:f.authorImage};return f.status==="streaming"&&f.content===""?l(Pu,{},f._id):f.status==="streaming"?l(Ke,{text:jo(f.content),streaming:!0,...p},f._id):f.status==="error"?l(Ke,{text:f.errorMessage??`${a.somethingWentWrong}. ${a.tryAgain}.`,error:!0,...p},f._id):l("div",{children:[l(Ke,{text:jo(f.content),...p}),f.sources&&f.sources.length>0?l($u,{sources:f.sources}):null]},f._id)}),l("div",{ref:c})]})}function Yn({message:t}){const[e,n]=C(!1);return T(()=>{const r=setTimeout(()=>{n(!0)},80);return()=>{clearTimeout(r)}},[]),e?l("div",{class:"jex-overlay jex-loading",children:[l("div",{class:"jex-loading-spinner","aria-hidden":"true"}),t&&l("p",{class:"jex-loading-message",children:t})]}):null}function Lu({sessionId:t,visitorId:e}){const n=Sn(ce.functions.chat.public.conversations.listBySession,t&&e?{sessionId:t,visitorId:e}:"skip"),r=Sn(ce.functions.chat.public.sessions.getSessionStatus,t&&e?{sessionId:t,visitorId:e}:"skip"),i=t!==null&&n===void 0,o=n?.some(s=>s.status==="streaming")??!1;return{conversations:n,sessionStatus:r??null,isLoading:i,isStreaming:o}}function Mu({greeting:t,sessionId:e,visitorId:n,isLoading:r,sessionNotFound:i,resumeFailed:o,isOrgDeleted:s,ensureSession:a,startFresh:c}){const u=_(),{conversations:h,sessionStatus:d,isLoading:f,isStreaming:p}=Lu({sessionId:e,visitorId:n}),g=me((()=>{const m=mt.peek();return m!==null?m:Fi.peek()?"resume":"fresh"})()).current;if(T(()=>{mt.value=null},[]),T(()=>{a()},[a]),T(()=>{n&&Mn(n)},[n]),s)return l("div",{class:"jex-chat-messages",children:l("div",{class:"jex-session-notice",children:u.chatNoLongerAvailable})});const x=g==="fresh"&&!e,v=g==="resume"&&(!e||f);return x?l(Yn,{message:u.startingConversation}):v?l(Yn,{message:u.resumeConversation}):l(M,{children:[l(qu,{conversations:h,greeting:t,sessionNotFound:i,resumeFailed:o,onStartFresh:c,sessionId:e,visitorId:n}),l(Yc,{sessionId:e,visitorId:n,isLoading:r,isStreaming:p,sessionStatus:d,ensureSession:a,onStartFresh:c})]})}function Nu({formMessageId:t,sessionId:e,visitorId:n}){const r=_(),i=gt.value,o=/^https?:\/\//i.test(i)?i:pt,[s,a]=C(""),[c,u]=C(""),h=wo(),[d,f]=C(!1),[p,g]=C(null);async function x(v){v.preventDefault(),f(!0),g(null);try{await h({sessionId:e,visitorId:n,formMessageId:t,visitorName:s.trim(),visitorEmail:c.trim(),locale:fe.value}),Ft()}catch(m){console.error("[EscalationFormScreen] Submit failed:",m),g(r.escalationSubmitFailed)}finally{f(!1)}}return l("div",{class:"jex-form-screen",children:[l("h2",{class:"jex-form-title",children:r.escalationFormTitle}),l("p",{class:"jex-escalation-subtitle",children:r.escalationSubtitle}),p&&l("div",{class:"jex-form-error",role:"alert",children:p}),l("form",{class:"jex-form",onSubmit:v=>{x(v)},children:[l("input",{class:"jex-form-input",type:"text",placeholder:r.escalationNameLabel,value:s,required:!0,onInput:v=>{a(v.currentTarget.value)}}),l("input",{class:"jex-form-input",type:"email",placeholder:r.escalationEmailLabel,value:c,required:!0,onInput:v=>{u(v.currentTarget.value)}}),l("button",{class:"jex-form-submit",type:"submit",disabled:d,children:r.escalationSubmit})]}),l("div",{class:"jex-inline-form-consent",style:{textAlign:"center",margin:"16px 0 8px 0"},children:[r.escalationConsent," ",l("a",{href:o,target:"_blank",rel:"noopener noreferrer",class:"jex-privacy-notice-link",children:r.escalationPrivacyLinkText}),"."]}),l("button",{class:"jex-escalation-skip",type:"button",onClick:()=>{Ft()},children:r.escalationSkip})]})}function zu(){return dt(ce.functions.chat.public.helpdesk.createEscalationRequest)}function So({sessionId:t,visitorId:e}){const n=_(),[r,i]=C(!1),[o,s]=C(null),a=zu();async function c(){if(!t||!e)return;const u=be.value;if(u){i(!0),s(null);try{const h=await a({sessionId:t,visitorId:e,bootstrapToken:u,locale:fe.value});if(h.skipForm)return;Ae({id:"escalation-form",formMessageId:h.formMessageId,sessionId:t,visitorId:e})}catch(h){const d=h instanceof Error?h.message:String(h);s(/RATE_LIMITED|Too many/.test(d)?n.handoffRateLimited:n.handoffFailed)}finally{i(!1)}}}return l(M,{children:[l("button",{class:"jex-header-handoff",type:"button",onClick:()=>{c()},disabled:r||!t||!e,"aria-label":n.talkToHumanAria,title:n.talkToHuman,children:l("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:[l("path",{d:"M3 14v-3a9 9 0 0 1 18 0v3"}),l("path",{d:"M21 14a2 2 0 0 1-2 2h-1a1 1 0 0 1-1-1v-4a1 1 0 0 1 1-1h3z"}),l("path",{d:"M3 14a2 2 0 0 0 2 2h1a1 1 0 0 0 1-1v-4a1 1 0 0 0-1-1H3z"}),l("path",{d:"M21 14v3a4 4 0 0 1-4 4h-3"})]})}),o&&l("div",{class:"jex-handoff-error",role:"alert",children:o})]})}async function Ou(){const t=Mi.value;if(!t)return console.warn("[JexityChat] Bootstrap refresh skipped โ inputs missing"),{ok:!1,reason:"no-inputs"};const e=await In(t.orgSlug,t.siteUrl,t.projSlug);if(!e.ok)return console.warn("[JexityChat] Bootstrap refresh failed:",e.error),{ok:!1,reason:e.error};const n=e.token;return be.value=n,{ok:!0,token:n}}function Co(t){return To(t)?"unauthorized":t instanceof Error&&/network|fetch|failed to fetch/i.test(t.message)?"network":"unknown"}function To(t){return t instanceof At?t.data?.code==="UNAUTHORIZED_ORIGIN":!1}function Bu(t=1e4){return be.value?Promise.resolve(be.value):new Promise(e=>{let n=!1;const r=s=>{n||(n=!0,clearTimeout(i),o(),e(s))},i=setTimeout(()=>{r(null)},t),o=be.subscribe(s=>{s&&r(s)})})}function Du(t,e){const n=me(null),r=We(!1),i=We(!1),o=We(!1),s=We(null),a=dt(ce.functions.chat.public.sessions.createOrResume),c=async p=>{const g=await Bu();if(!g)return console.warn("[JexityChat] No bootstrap token after 10s โ session creation blocked."),Je.value="no-token",null;const x=b=>({orgSlug:t,...e?{projSlug:e}:{},visitorId:p,bootstrapToken:b,locale:fe.value,...Bt.value?{source:Bt.value}:{}});zn.value=!0;let v;try{try{v=await a(x(g))}catch(b){if(!To(b))throw b;const E=await Ou();if(!E.ok)return Je.value=E.reason==="rate_limited"?"network":"unauthorized",null;v=await a(x(E.token))}}finally{zn.value=!1}Je.value=null,s.value=v.status;const m={sessionId:v.sessionId,visitorId:p};return n.current=m,{session:m,result:v}},u=ue(async()=>{if(n.current)return n.current;if(o.value)return null;r.value=!0;const p=Re.value!==null,g=Re.value??Qi();try{const x=await c(g);return x?(p&&x.result.isNew&&(i.value=!0,o.value=!0),x.session):null}catch(x){return console.error("[JexityChat] Failed to create session:",x),Je.value=Co(x),null}finally{r.value=!1}},[t,e,a,r,i,o]),h=ue(()=>{n.current=null,i.value=!1,o.value=!1},[i,o]);T(()=>Cl(h),[h]);const d=ue(async()=>{n.current=null,o.value=!1,i.value=!1;const p=Qi();r.value=!0;try{return(await c(p))?.session??null}catch(g){return console.error("[JexityChat] Failed to create fresh session:",g),Je.value=Co(g),null}finally{r.value=!1}},[t,e,a,r,i,o,s]),f=n.current;return{sessionId:f?.sessionId??null,visitorId:f?.visitorId??null,isLoading:r.value,sessionNotFound:i.value,resumeFailed:o.value,sessionStatus:s.value,isOrgDeleted:s.value==="org_deleted",ensureSession:u,startFresh:d,resetSession:h}}function Uu(){const t=_(),[e,n]=C(""),[r,i]=C(""),[o,s]=C("");async function a(c){c.preventDefault(),Nn({id:"loading",message:t.submittingTicket}),await new Promise(h=>{setTimeout(h,1200)});const u="JEX-"+Math.random().toString(36).slice(2,8).toUpperCase();Nn({id:"confirmation",ref:u})}return l("div",{class:"jex-form-screen",children:[l("h2",{class:"jex-form-title",children:t.submitTicket}),l("form",{class:"jex-form",onSubmit:c=>{a(c)},children:[l("input",{class:"jex-form-input",type:"text",placeholder:t.yourName,value:e,required:!0,onInput:c=>{n(c.currentTarget.value)}}),l("input",{class:"jex-form-input",type:"email",placeholder:t.yourEmail,value:r,required:!0,onInput:c=>{i(c.currentTarget.value)}}),l("textarea",{class:"jex-form-textarea",placeholder:t.howCanWeHelp,value:o,required:!0,onInput:c=>{s(c.currentTarget.value)}}),l("button",{class:"jex-form-submit",type:"submit",children:t.submit})]})]})}function Fu({ticketRef:t}){const e=_();return l("div",{class:"jex-confirmation",children:[l("div",{class:"jex-confirmation-icon","aria-hidden":"true",children:"โ"}),l("h2",{class:"jex-confirmation-title",children:e.ticketSubmitted}),l("p",{class:"jex-confirmation-body",children:e.yourReferenceNumber}),l("div",{class:"jex-confirmation-ref",children:t}),l("p",{class:"jex-confirmation-hint",children:e.sentToEmailHint}),l("button",{class:"jex-confirmation-done",onClick:()=>{N.value=!1},children:e.done})]})}function Qu({message:t,onRetry:e,onBack:n}){const r=_();return l("div",{class:"jex-overlay jex-error",children:[l("p",{class:"jex-error-message",children:t}),l("div",{class:"jex-error-actions",children:[e&&l("button",{class:"jex-error-retry",onClick:e,children:r.tryAgain}),n&&l("button",{class:"jex-error-back",onClick:n,children:r.goBack})]})]})}function Ro({greeting:t,title:e,sessionId:n,visitorId:r,isLoading:i,sessionNotFound:o,resumeFailed:s,isOrgDeleted:a,ensureSession:c,startFresh:u,resetSession:h}){const d=W.value,f=d[d.length-1],p=[...d].reverse().find(g=>g.id==="confirmation");return l("div",{class:"jex-screen-container",children:[f.id==="home"&&l(Bl,{greeting:t,title:e,onStartFresh:u,onResetSession:h}),f.id==="selection"&&l(Dl,{title:e}),f.id==="form"&&l(Uu,{}),f.id==="escalation-form"&&l(Nu,{formMessageId:f.formMessageId,sessionId:f.sessionId,visitorId:f.visitorId}),f.id==="confirmation"&&p&&l(Fu,{ticketRef:p.ref}),f.id==="chat"&&l(Mu,{greeting:t,sessionId:n,visitorId:r,isLoading:i,sessionNotFound:o,resumeFailed:s,isOrgDeleted:a,ensureSession:c,startFresh:u}),f.id==="loading"&&l(Yn,{message:f.message}),f.id==="error"&&l(Qu,{message:f.message,onRetry:()=>Nn({id:"loading"}),onBack:Ft})]})}function Vu({options:t}){return ul({orgSlug:t.orgSlug,projSlug:t.projSlug,preToken:t.bootstrapToken,convexUrl:t.convexUrl,preAllowedUrls:t.allowedUrls??[],preExcludedPaths:t.excludePaths}),fl()?l(Wu,{options:t}):null}function Wu({options:t}){const e=ll(t.orgSlug,t.projSlug,t.convexUrl);vl(t.parentOrigin),T(()=>{kl(),_l()},[]);const{sessionId:n,visitorId:r,isLoading:i,sessionNotFound:o,resumeFailed:s,isOrgDeleted:a,ensureSession:c,startFresh:u,resetSession:h}=Du(t.orgSlug,t.projSlug),d=ol(t,e);T(()=>{fe.value=Oi(d.locale)},[d.locale]),T(()=>{gt.value=d.privacyPolicyUrl??pt,Li.value=d.privacyNoticeStyle},[d.privacyNoticeStyle,d.privacyPolicyUrl]),T(()=>{if(!N.value||d.mode==="embedded"||!window.matchMedia("(max-width: 480px), (pointer: coarse) and (max-width: 768px)").matches)return;const L=document.documentElement.style.overflow;return document.documentElement.style.overflow="hidden",()=>{document.documentElement.style.overflow=L}},[N.value,d.mode]),T(()=>{if(d.mode!=="embedded")try{return Al()}catch(z){console.warn("[JexityChat] Idle-lock watcher failed to start:",z);return}},[d.mode]);const f=d.position==="bottom-left",p=d.colorScheme==="dark"||d.colorScheme==="light"?d.colorScheme:"",g=$l({...t,primaryColor:d.primaryColor,accentColor:d.accentColor,fontFamily:d.fontFamily,fontSize:d.fontSize,borderRadius:d.borderRadius,windowWidth:d.windowWidth,windowHeight:d.windowHeight}),x=d.mode==="embedded",v=W.value,b=v[v.length-1]?.id==="chat",q=e!==null||x||!!t.parentOrigin?g:{...g,visibility:"hidden"};return l("div",{class:`jex-widget ${p}`.trim(),style:q,children:x?l("div",{class:"jex-embedded",children:[l(Ji,{title:d.title,rightAction:b?l(So,{sessionId:n,visitorId:r}):null,showClose:!x}),l(Ro,{greeting:d.greeting,title:d.title,orgSlug:t.orgSlug,projSlug:t.projSlug,sessionId:n,visitorId:r,isLoading:i,sessionNotFound:o,resumeFailed:s,isOrgDeleted:a,ensureSession:c,startFresh:u,resetSession:h}),!d.hideBranding&&l(Ki,{})]}):l("div",{class:`jex-container${f?" jex-pos-left":""}`,children:[N.value&&l("div",{class:"jex-chat-window",children:[l(Ji,{title:d.title,rightAction:b?l(So,{sessionId:n,visitorId:r}):null}),l(Ro,{greeting:d.greeting,title:d.title,orgSlug:t.orgSlug,projSlug:t.projSlug,sessionId:n,visitorId:r,isLoading:i,sessionNotFound:o,resumeFailed:s,isOrgDeleted:a,ensureSession:c,startFresh:u,resetSession:h}),!d.hideBranding&&l(Ki,{})]}),l(Ol,{iconOption:d.triggerIcon,radius:d.triggerRadius,label:d.triggerLabel})]})})}const Hu=`.jex-widget{--jex-primary: #115A62;--jex-primary-hover: var(--jex-accent, color-mix(in srgb, var(--jex-primary) 85%, #000));--jex-radius: .75rem;--jex-font-family: "Inter", system-ui, -apple-system, sans-serif;--jex-font-size: 14px;--jex-window-width: 380px;--jex-window-height: 600px;--jex-shadow: 0 16px 48px -12px rgba(13, 127, 138, .25), 0 4px 16px rgba(0, 0, 0, .08);pointer-events:auto;--jex-bg-trigger: var(--jex-primary);--jex-bg-header: var(--jex-primary);--jex-bg-msg-user: var(--jex-primary);--jex-bg-send-btn: var(--jex-primary);--jex-bg-window: rgba(255, 255, 255, .95);--jex-bg-msg-bot: #f1f5f9;--jex-bg-input: rgba(247, 253, 253, .6);--jex-text-header: #ffffff;--jex-text-msg-user: #ffffff;--jex-text-msg-bot: #0f172a;--jex-text-main: #0f172a;--jex-text-muted: #64748b;--jex-bg-avatar-agent: #d1fae5;--jex-text-avatar-agent: #065f46;--jex-border-window: rgba(226, 232, 240, .8);--jex-border-input: rgba(203, 213, 225, .8);--jex-bg-glass: var(--jex-bg-window);--jex-border-glass: var(--jex-border-window);font-family:var(--jex-font-family);-webkit-font-smoothing:antialiased}.dark .jex-widget,.jex-widget.dark{--jex-primary: #1cb0bf;--jex-primary-hover: var(--jex-accent, color-mix(in srgb, var(--jex-primary) 85%, #000));--jex-bg-window: rgba(10, 15, 26, .95);--jex-bg-msg-bot: #233146;--jex-bg-input: rgba(10, 15, 26, .6);--jex-text-msg-bot: #f8fafc;--jex-text-main: #f8fafc;--jex-text-muted: #94a3b8;--jex-border-window: rgba(30, 41, 59, .8);--jex-border-input: rgba(51, 65, 85, .9);--jex-bg-avatar-agent: #064e3b;--jex-text-avatar-agent: #6ee7b7;--jex-bg-error: #3b1318;--jex-border-error: #5c1d24;--jex-text-error: #fca5a5}@media(prefers-color-scheme:dark){:host:not(.light) .jex-widget:not(.light){--jex-primary: #1cb0bf;--jex-primary-hover: var(--jex-accent, color-mix(in srgb, var(--jex-primary) 85%, #000));--jex-bg-window: rgba(10, 15, 26, .95);--jex-bg-msg-bot: #233146;--jex-bg-input: rgba(10, 15, 26, .6);--jex-text-msg-bot: #f8fafc;--jex-text-main: #f8fafc;--jex-text-muted: #94a3b8;--jex-border-window: rgba(30, 41, 59, .8);--jex-border-input: rgba(51, 65, 85, .9);--jex-bg-error: #3b1318;--jex-border-error: #5c1d24;--jex-text-error: #fca5a5}}.jex-widget *{box-sizing:border-box;margin:0;padding:0}.jex-container{position:fixed;bottom:24px;right:24px;display:flex;flex-direction:column;align-items:flex-end;gap:16px;z-index:9999}.jex-container.jex-pos-left{right:auto;left:24px;align-items:flex-start}:host(.jex-mode-embedded){display:block;width:100%;height:100%}:host(.jex-mode-embedded) .jex-widget{width:100%;height:100%}.jex-embedded{display:flex;flex-direction:column;width:100%;height:100%;background:var(--jex-bg-window);border:1px solid var(--jex-border-window);overflow:hidden}.jex-embedded .jex-screen-container{flex:1;overflow:hidden;display:flex;flex-direction:column}.jex-floating-button{height:56px;min-width:56px;padding:0;background:var(--jex-bg-trigger);color:var(--jex-text-header);border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:var(--jex-shadow);transition:transform .3s cubic-bezier(.175,.885,.32,1.275),background .2s,width .3s ease,border-radius .3s ease}.jex-floating-button.jex-has-label{min-width:110px;padding:0 20px}.jex-fab-inner{display:flex;align-items:center;gap:12px}.jex-fab-label{font-size:15px;font-weight:600;white-space:nowrap}.jex-floating-button:hover{transform:scale(1.1);background:var(--jex-primary-hover)}.jex-floating-button:active{transform:scale(.95)}.jex-chat-window{width:var(--jex-window-width);height:var(--jex-window-height);max-height:calc(100vh - 120px);background:var(--jex-bg-window);backdrop-filter:blur(24px);-webkit-backdrop-filter:blur(24px);border:1px solid var(--jex-border-window);border-radius:calc(var(--jex-radius) * 2);box-shadow:var(--jex-shadow);display:flex;flex-direction:column;overflow:hidden;animation:jexSlideUp .4s cubic-bezier(.16,1,.3,1);transform-origin:bottom right;touch-action:manipulation}@keyframes jexSlideUp{0%{opacity:0;transform:scale(.8) translateY(20px)}to{opacity:1;transform:scale(1) translateY(0)}}@media(max-width:480px),(pointer:coarse)and (max-width:768px){.jex-chat-window{position:fixed;inset:0;width:100vw;height:100vh;height:100dvh;max-height:none;border:none;border-radius:0;animation:jexSlideUpMobile .3s cubic-bezier(.16,1,.3,1);transform-origin:bottom center}.jex-container:has(.jex-chat-window) .jex-floating-button{display:none}}@keyframes jexSlideUpMobile{0%{opacity:0;transform:translateY(100%)}to{opacity:1;transform:translateY(0)}}.jex-chat-header{padding:20px;background:var(--jex-bg-header);color:var(--jex-text-header);display:flex;align-items:center;gap:12px;flex-shrink:0}.jex-header-info h3{font-size:16px;font-weight:600;color:var(--jex-text-header);margin:0}.jex-header-info p{font-size:12px;opacity:.8;color:var(--jex-text-header);margin:0}.jex-header-right{margin-left:auto;display:flex;align-items:center;gap:4px}.jex-header-handoff{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;background:transparent;border:1px solid color-mix(in srgb,currentColor 50%,transparent);border-radius:999px;padding:0;color:inherit;cursor:pointer;transition:background .15s ease,border-color .15s ease}.jex-header-handoff:hover:not(:disabled){background:color-mix(in srgb,currentColor 12%,transparent);border-color:currentColor}.jex-header-handoff:disabled{opacity:.5;cursor:not-allowed}.jex-header-close{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;background:transparent;border:none;border-radius:999px;padding:0;color:inherit;cursor:pointer;transition:background .15s ease}.jex-header-close:hover{background:color-mix(in srgb,currentColor 14%,transparent)}.jex-handoff-error{position:absolute;top:100%;right:8px;background:#fee;color:#b00;padding:4px 8px;font-size:12px;border-radius:4px}.jex-header-back{background:none;border:none;color:var(--jex-text-header);cursor:pointer;padding:4px;display:flex;align-items:center;opacity:.8;transition:opacity .2s;flex-shrink:0}.jex-header-back:hover{opacity:1}.jex-screen-container{flex:1;overflow:hidden;display:flex;flex-direction:column}.jex-home{flex:1;display:flex;flex-direction:column;padding:24px;gap:20px;overflow-y:auto}.jex-home-hero{display:flex;align-items:center;gap:14px;animation:jexFadeIn .4s ease both}.jex-home-avatar{position:relative;width:48px;height:48px;border-radius:14px;background:var(--jex-primary);color:var(--jex-text-header);display:flex;align-items:center;justify-content:center;flex-shrink:0;box-shadow:0 4px 12px color-mix(in srgb,var(--jex-primary) 30%,transparent)}.jex-home-status-dot{position:absolute;bottom:-2px;right:-2px;width:14px;height:14px;border-radius:50%;background:#22c55e;border:2.5px solid var(--jex-bg-window);animation:jexPulse 2s ease-in-out infinite}@keyframes jexPulse{0%,to{box-shadow:0 0 #22c55e66}50%{box-shadow:0 0 0 6px #22c55e00}}.jex-home-hero-text{display:flex;flex-direction:column;gap:2px;min-width:0}.jex-home-title{font-size:17px;font-weight:700;color:var(--jex-text-main);margin:0;line-height:1.2;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.jex-home-status{font-size:12px;font-weight:500;color:#22c55e;letter-spacing:.02em}.jex-home-greeting{background:var(--jex-bg-msg-bot);border:1px solid var(--jex-border-window);border-radius:4px 16px 16px;padding:16px 18px;font-size:14px;line-height:1.55;color:var(--jex-text-main);animation:jexFadeIn .4s .1s ease both}.jex-home-greeting p{margin:0}@keyframes jexFadeIn{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.jex-home-actions{display:flex;flex-direction:column;gap:10px;animation:jexFadeIn .4s .2s ease both}.jex-home-start-btn{background:var(--jex-bg-send-btn);color:var(--jex-text-header);border:none;border-radius:12px;padding:14px 20px;font-size:15px;font-weight:600;cursor:pointer;font-family:inherit;transition:background .2s,transform .15s,box-shadow .2s;width:100%;box-shadow:0 2px 8px color-mix(in srgb,var(--jex-primary) 25%,transparent)}.jex-home-start-btn:hover{background:var(--jex-primary-hover);transform:translateY(-1px);box-shadow:0 4px 16px color-mix(in srgb,var(--jex-primary) 35%,transparent)}.jex-home-start-btn:active{transform:translateY(0);box-shadow:0 1px 4px color-mix(in srgb,var(--jex-primary) 20%,transparent)}.jex-home-resume-card{display:flex;flex-direction:column;gap:8px;width:100%;text-align:left;padding:16px 18px;border-radius:14px;border:1.5px solid var(--jex-primary);background:color-mix(in srgb,var(--jex-primary) 6%,var(--jex-bg-window));cursor:pointer;font-family:inherit;transition:background .2s,border-color .2s,transform .15s,box-shadow .2s;box-shadow:0 2px 8px color-mix(in srgb,var(--jex-primary) 12%,transparent)}.jex-home-resume-card:hover{background:color-mix(in srgb,var(--jex-primary) 10%,var(--jex-bg-window));transform:translateY(-1px);box-shadow:0 4px 16px color-mix(in srgb,var(--jex-primary) 20%,transparent)}.jex-home-resume-card:active{transform:translateY(0)}.jex-home-resume-top{display:flex;align-items:center;justify-content:space-between}.jex-home-resume-label{font-size:14px;font-weight:600;color:var(--jex-primary)}.jex-home-resume-arrow{color:var(--jex-primary);opacity:.6;transition:opacity .2s,transform .2s}.jex-home-resume-card:hover .jex-home-resume-arrow{opacity:1;transform:translate(2px)}.jex-home-resume-ref{font-family:ui-monospace,Cascadia Code,Fira Code,monospace;font-size:13px;font-weight:600;letter-spacing:.06em;color:var(--jex-text-muted)}.jex-home-history{display:flex;flex-direction:column;gap:8px}.jex-home-resume-meta{font-size:11px;opacity:.7;margin-top:4px}.jex-home-new-btn{background:transparent;color:var(--jex-text-muted);border:1px solid var(--jex-border-input);border-radius:12px;padding:12px 20px;font-size:14px;font-weight:500;cursor:pointer;font-family:inherit;transition:color .2s,border-color .2s,background .2s;width:100%}.jex-home-new-btn:hover{color:var(--jex-text-main);border-color:var(--jex-text-muted);background:color-mix(in srgb,var(--jex-primary) 3%,transparent)}.jex-session-ref{display:flex;align-items:center;gap:8px;padding:8px 12px;background:var(--jex-bg-msg-bot);border:1px solid var(--jex-border-window);border-radius:8px;font-size:12px}.jex-session-ref-label{color:var(--jex-text-muted);font-weight:500}.jex-session-ref-code{color:var(--jex-primary);font-weight:700;font-family:ui-monospace,Cascadia Code,monospace;letter-spacing:.05em}.jex-chat-messages{flex:1;padding:20px;overflow-y:auto;display:flex;flex-direction:column;gap:12px}.jex-message-row{display:flex;align-items:flex-end;gap:8px;max-width:85%}.jex-message-row.bot{align-self:flex-start}.jex-message-content{flex:1;min-width:0}.jex-avatar{width:24px;height:24px;border-radius:50%;flex-shrink:0;display:flex;align-items:center;justify-content:center;font-size:12px;margin-bottom:2px}.jex-avatar-bot{background:var(--jex-bg-msg-bot);color:var(--jex-primary)}.jex-avatar-agent{background:var(--jex-bg-avatar-agent)}.jex-avatar-img{width:100%;height:100%;border-radius:50%;object-fit:cover}.jex-avatar-initials{font-size:9px;font-weight:700;color:var(--jex-text-avatar-agent)}.jex-message-author-row{display:flex;align-items:center;gap:6px;margin-top:2px;padding-left:4px}.jex-message-author{font-size:10px;color:var(--jex-text-muted)}.jex-reply-tag-btn{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;padding:0;border:none;border-radius:4px;background:transparent;color:var(--jex-text-muted, #6b7280);cursor:pointer;transition:background .15s,color .15s}.jex-reply-tag-btn:hover{background:#0000000f;color:var(--jex-primary, #115A62)}.jex-reply-tag-btn:focus-visible{outline:2px solid var(--jex-primary, #115A62);outline-offset:1px}.jex-message{padding:12px 16px;border-radius:18px;font-size:14px;line-height:1.4}.jex-message.bot{background:var(--jex-bg-msg-bot);border:1px solid var(--jex-border-window);color:var(--jex-text-msg-bot);border-bottom-left-radius:4px}.jex-message.user{align-self:flex-end;max-width:80%;background:var(--jex-bg-msg-user);color:var(--jex-text-msg-user);border-bottom-right-radius:4px}.jex-typing{align-self:flex-start;display:flex;gap:4px;padding:12px 16px}.jex-typing span{width:8px;height:8px;border-radius:50%;background:var(--jex-text-muted);animation:jexTypingDot 1.2s infinite ease-in-out}.jex-typing span:nth-child(2){animation-delay:.2s}.jex-typing span:nth-child(3){animation-delay:.4s}@keyframes jexTypingDot{0%,80%,to{transform:scale(.8);opacity:.4}40%{transform:scale(1);opacity:1}}.jex-md{word-break:break-word;overflow-wrap:anywhere}.jex-md p{margin:0 0 8px}.jex-md p:last-child{margin-bottom:0}.jex-md strong{font-weight:600}.jex-md em{font-style:italic}.jex-md ul,.jex-md ol{margin:0 0 8px;padding-left:20px}.jex-md ul:last-child,.jex-md ol:last-child{margin-bottom:0}.jex-md ul{list-style-type:disc}.jex-md ol{list-style-type:decimal}.jex-md li{margin-bottom:2px}.jex-md li:last-child{margin-bottom:0}.jex-md a{color:var(--jex-primary);text-decoration:underline;text-underline-offset:2px}.jex-md a:hover{opacity:.8}.jex-md code{background:#00000014;padding:1px 5px;border-radius:4px;font-size:.9em;font-family:ui-monospace,Cascadia Code,Fira Code,monospace}.jex-md pre{background:#0000000f;border-radius:8px;padding:10px 12px;margin:0 0 8px;overflow-x:auto;font-size:.85em}.jex-md pre:last-child{margin-bottom:0}.jex-md pre code{background:none;padding:0;border-radius:0;font-size:inherit}.jex-md h1,.jex-md h2,.jex-md h3,.jex-md h4{font-weight:600;margin:8px 0 4px}.jex-md h1:first-child,.jex-md h2:first-child,.jex-md h3:first-child,.jex-md h4:first-child{margin-top:0}.jex-md h3{font-size:1em}.jex-md h4{font-size:.95em}.jex-md hr{border:none;border-top:1px solid var(--jex-border-window);margin:8px 0}.jex-md blockquote{border-left:3px solid var(--jex-primary);margin:0 0 8px;padding:4px 12px;color:var(--jex-text-muted)}.jex-md blockquote:last-child{margin-bottom:0}.dark .jex-md code,.jex-widget.dark .jex-md code{background:#ffffff1a}.dark .jex-md pre,.jex-widget.dark .jex-md pre{background:#ffffff14}@media(prefers-color-scheme:dark){:host:not(.light) .jex-widget:not(.light) .jex-md code{background:#ffffff1a}:host:not(.light) .jex-widget:not(.light) .jex-md pre{background:#ffffff14}}.jex-streaming-cursor:after{content:"โ";margin-left:2px;animation:jexBlinkCursor .8s ease-in-out infinite}@keyframes jexBlinkCursor{0%,to{opacity:1}50%{opacity:0}}.jex-session-notice{align-self:center;text-align:center;padding:8px 16px;margin:8px 0;font-size:12px;color:var(--jex-text-muted);background:var(--jex-bg-input, #f1f5f9);border-radius:8px;line-height:1.4}.jex-message-error{background:var(--jex-bg-error, #fef2f2)!important;border-color:var(--jex-border-error, #fecaca)!important;color:var(--jex-text-error, #991b1b)!important}.jex-chat-input{padding:12px 16px;border-top:1px solid var(--jex-border-window);display:flex;flex-direction:column;gap:8px;flex-shrink:0}.jex-chat-input-composer-gate{position:relative}.jex-chat-input-composer-gate-open{z-index:2}.jex-chat-input-composer-gate-open .jex-composer-card{pointer-events:none}.jex-composer-card{display:flex;flex-direction:column;gap:6px;padding:10px 12px 8px;background:var(--jex-bg-input);border:1px solid var(--jex-border-input);border-radius:16px;cursor:text;transition:border-color .15s ease,background .15s ease,box-shadow .15s ease}.jex-composer-card:focus-within{border-color:var(--jex-primary);background:var(--jex-bg-window);box-shadow:0 0 0 3px color-mix(in srgb,var(--jex-primary, #115A62) 14%,transparent)}.jex-composer-attachments{display:flex;flex-wrap:wrap;gap:6px;padding:2px 2px 4px}.jex-attachment-chip{position:relative;width:44px;height:44px;border-radius:8px;overflow:hidden;background:var(--jex-bg-msg-bot, #f1f5f9);flex-shrink:0;box-shadow:0 1px 2px #0000000f}.jex-attachment-thumb{width:100%;height:100%;object-fit:cover;display:block;pointer-events:none}.jex-attachment-remove{position:absolute;top:2px;right:2px;width:16px;height:16px;padding:0;border:none;border-radius:50%;background:#0f172ac7;color:#fff;display:inline-flex;align-items:center;justify-content:center;cursor:pointer;opacity:0;transition:opacity .12s ease,transform .12s ease}.jex-attachment-chip:hover .jex-attachment-remove,.jex-attachment-chip:focus-within .jex-attachment-remove{opacity:1}.jex-attachment-remove:hover{transform:scale(1.08)}.jex-composer-textarea{width:100%;min-height:22px;background:transparent;border:none;outline:none;resize:none;padding:2px 4px;color:var(--jex-text-main);font-family:inherit;font-size:16px;line-height:1.45;overflow-y:hidden}.jex-composer-textarea::placeholder{color:var(--jex-text-muted);opacity:.85}.jex-composer-textarea:disabled{cursor:not-allowed;opacity:.7}.jex-composer-actions{display:flex;align-items:center;justify-content:space-between;gap:8px}.jex-composer-actions-left{display:inline-flex;align-items:center;gap:4px}.jex-attach-btn{width:30px;height:30px;padding:0;border:none;border-radius:50%;background:transparent;color:var(--jex-text-muted);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;transition:background .12s ease,color .12s ease,transform .12s ease}.jex-attach-btn:hover:not(:disabled){background:color-mix(in srgb,var(--jex-text-muted, #64748b) 12%,transparent);color:var(--jex-text-main)}.jex-attach-btn:active:not(:disabled){transform:scale(.92)}.jex-attach-btn:disabled{opacity:.4;cursor:not-allowed}.jex-visually-hidden{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.jex-rate-limit-notice{flex:1 0 100%;order:-1;margin-bottom:8px;padding:8px 12px;border-radius:10px;background:var(--jex-bg-msg-bot, #f1f5f9);color:var(--jex-text-muted, #64748b);font-size:12px;line-height:1.4;text-align:center}.jex-session-error-notice{flex:1 0 100%;order:-1;margin-bottom:8px;padding:8px 12px;border-radius:10px;background:var(--jex-bg-error, #fef2f2);border:1px solid var(--jex-border-error, #fecaca);color:var(--jex-text-error, #991b1b);font-size:12px;line-height:1.4;text-align:center}.jex-chat-input input{flex:1;background:var(--jex-bg-input);border:1px solid var(--jex-border-input);border-radius:12px;padding:10px 14px;color:var(--jex-text-main);outline:none;font-family:inherit;font-size:14px}.jex-chat-input input:focus{border-color:var(--jex-primary)}.jex-send-btn{background:color-mix(in srgb,var(--jex-text-muted, #64748b) 18%,transparent);color:var(--jex-text-muted);border:none;border-radius:999px;width:30px;height:30px;display:inline-flex;align-items:center;justify-content:center;cursor:pointer;transition:background .15s ease,color .15s ease,opacity .15s ease,transform .15s ease;flex-shrink:0}.jex-send-btn-active{background:var(--jex-bg-send-btn, var(--jex-primary));color:var(--jex-text-header, #fff)}.jex-send-btn-active:hover:not(:disabled){background:var(--jex-primary-hover)}.jex-send-btn:active:not(:disabled){transform:scale(.9)}.jex-send-btn:disabled{opacity:.45;cursor:default}.jex-widget-footer{display:flex;align-items:center;justify-content:center;padding:8px 16px;border-top:1px solid var(--jex-border-glass);background:#00000005;flex-shrink:0}.jex-widget.dark .jex-widget-footer{background:#ffffff05}@media(prefers-color-scheme:dark){:host:not(.light) .jex-widget:not(.light) .jex-widget-footer{background:#ffffff05}}.jex-branding{display:flex;align-items:center;gap:6px;text-decoration:none;color:var(--jex-text-muted);font-size:11px;font-weight:500;transition:color .2s}.jex-branding:hover{color:var(--jex-text-main)}.jex-branding-icon{color:var(--jex-primary)}.jex-branding span strong{font-weight:700;color:var(--jex-text-main)}.jex-privacy-notice-link,.jex-privacy-chip-link{color:var(--jex-primary);text-decoration:underline;text-underline-offset:2px;text-decoration-color:color-mix(in srgb,var(--jex-primary) 50%,transparent);transition:text-decoration-color .15s}.jex-privacy-notice-link:hover,.jex-privacy-chip-link:hover{text-decoration-color:var(--jex-primary)}.jex-privacy-chip{align-self:center;display:inline-flex;align-items:center;gap:6px;max-width:100%;margin:0;padding:5px 10px;border-radius:999px;background:color-mix(in srgb,var(--jex-primary) 10%,var(--jex-bg-window));color:var(--jex-primary);font-size:10px;font-weight:650;line-height:1.2}.jex-privacy-chip-icon{display:inline-flex;flex-shrink:0}.jex-privacy-chip-link{color:inherit;text-decoration:none}.jex-privacy-explicit{position:absolute;left:0;right:0;bottom:0;z-index:3;display:flex;flex-direction:column;gap:10px;min-height:100%;padding:10px 12px 12px;border:1px solid var(--jex-border-window);border-radius:14px 14px 10px 10px;background:var(--jex-bg-window);box-shadow:0 -12px 36px #0f172a24;pointer-events:auto}.jex-privacy-explicit-content{display:flex;align-items:flex-start;gap:10px}.jex-privacy-explicit-icon{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;border-radius:8px;background:color-mix(in srgb,var(--jex-primary) 10%,var(--jex-bg-window));color:var(--jex-primary);flex-shrink:0}.jex-privacy-explicit-copy{min-width:0;flex:1}.jex-privacy-explicit-title{color:var(--jex-text-main);font-size:12px;font-weight:750;line-height:1.2;margin-bottom:3px}.jex-privacy-explicit-body{margin:0;color:var(--jex-text-muted);font-size:10px;line-height:1.35}.jex-privacy-explicit-button{width:100%;border:none;border-radius:10px;background:var(--jex-bg-send-btn);color:var(--jex-text-header);cursor:pointer;font-family:inherit;font-size:12px;font-weight:750;padding:9px 12px;transition:background .15s ease,transform .12s ease}.jex-privacy-explicit-button:hover{background:var(--jex-primary-hover)}.jex-privacy-explicit-button:active{transform:scale(.98)}.jex-locale-select-wrapper{position:relative;display:flex;align-items:center}.jex-locale-select{appearance:none;-webkit-appearance:none;background:transparent;border:1px solid transparent;padding:4px 20px 4px 6px;border-radius:6px;font-family:inherit;font-size:11px;font-weight:600;color:var(--jex-text-muted);background-color:transparent;cursor:pointer;outline:none;transition:all .2s ease}.jex-locale-select option{background-color:#fff;color:#0f172a}.jex-locale-select:hover,.jex-locale-select:focus-visible{color:var(--jex-text-main);background:#0000000a}.jex-widget.dark .jex-locale-select:hover,.jex-widget.dark .jex-locale-select:focus-visible{background:#ffffff0d}.jex-widget.dark .jex-locale-select option{background-color:#0f172a;color:#f8fafc}@media(prefers-color-scheme:dark){:host:not(.light) .jex-widget:not(.light) .jex-locale-select:hover,:host:not(.light) .jex-widget:not(.light) .jex-locale-select:focus-visible{background:#ffffff0d}:host:not(.light) .jex-widget:not(.light) .jex-locale-select option{background-color:#0f172a;color:#f8fafc}}.jex-locale-select:focus-visible{border-color:var(--jex-primary)}.jex-locale-chevron{position:absolute;right:4px;pointer-events:none;color:var(--jex-text-muted);transition:color .2s ease}.jex-locale-select-wrapper:hover .jex-locale-chevron{color:var(--jex-text-main)}.jex-overlay{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;background:var(--jex-bg-window, #fff);z-index:10;padding:24px;text-align:center}.jex-loading-spinner{width:32px;height:32px;border:3px solid var(--jex-border-input, #e2e8f0);border-top-color:var(--jex-primary, #115A62);border-radius:50%;animation:jex-spin .7s linear infinite}@keyframes jex-spin{to{transform:rotate(360deg)}}.jex-loading-message{font-size:14px;color:var(--jex-text-muted, #64748b)}.jex-error-message{font-size:14px;color:var(--jex-text-main, #334155)}.jex-error-actions{display:flex;gap:8px}.jex-error-retry,.jex-error-back{padding:8px 16px;border-radius:8px;font-size:13px;font-weight:600;cursor:pointer;border:none}.jex-error-retry{background:var(--jex-primary, #115A62);color:#fff}.jex-error-back{background:transparent;color:var(--jex-text-muted, #64748b);border:1px solid var(--jex-border-input, #e2e8f0)}.jex-selection{display:flex;flex-direction:column;gap:12px;padding:24px 16px;height:100%}.jex-selection-title{font-size:16px;font-weight:700;color:var(--jex-text-main, #0f172a);margin:0 0 8px}.jex-selection-options{display:flex;flex-direction:column;gap:10px}.jex-selection-option{display:flex;flex-direction:column;align-items:flex-start;gap:2px;padding:16px;border-radius:12px;border:1px solid var(--jex-border-window, #e2e8f0);background:transparent;cursor:pointer;text-align:left;transition:border-color .15s ease,background .15s ease}.jex-selection-option:hover{border-color:var(--jex-primary, #115A62);background:color-mix(in srgb,var(--jex-primary, #115A62) 5%,transparent)}.jex-selection-icon{font-size:20px}.jex-selection-label{font-size:14px;font-weight:600;color:var(--jex-text-main, #0f172a)}.jex-selection-sub{font-size:12px;color:var(--jex-text-muted, #64748b)}.jex-form-screen{display:flex;flex-direction:column;padding:20px 16px;height:100%;overflow-y:auto}.jex-form-title{font-size:16px;font-weight:700;color:var(--jex-text-main, #0f172a);margin:0 0 16px}.jex-form{display:flex;flex-direction:column;gap:10px}.jex-form-input,.jex-form-textarea{padding:10px 12px;border-radius:8px;border:1px solid var(--jex-border-input, #e2e8f0);font-size:14px;background:transparent;color:var(--jex-text-main, #0f172a);outline:none}@media(pointer:coarse){.jex-form-input,.jex-form-textarea{font-size:16px}}.jex-form-input:focus,.jex-form-textarea:focus{border-color:var(--jex-primary, #115A62)}.jex-form-textarea{min-height:80px;resize:vertical}.jex-form-submit{padding:10px;border-radius:8px;border:none;background:var(--jex-primary, #115A62);color:#fff;font-size:14px;font-weight:600;cursor:pointer;margin-top:4px}.jex-inline-form{display:flex;flex-direction:column;gap:8px;padding:12px;background:var(--jex-bg-msg-bot, #f1f5f9);border:1px solid var(--jex-border-input, #e2e8f0);border-radius:var(--jex-radius, .75rem);width:100%}.jex-inline-form-title{font-weight:600;font-size:15px;color:var(--jex-text-main, #0f172a);margin:0}.jex-inline-form-subtitle{font-size:13px;color:var(--jex-text-muted, #64748b);line-height:1.4;margin:0 0 4px}.jex-inline-form-consent{font-size:11px;color:var(--jex-text-muted, #64748b);line-height:1.3;margin-top:4px;text-align:center}.jex-inline-form .jex-form-submit:disabled{opacity:.7;cursor:not-allowed}.jex-escalation-subtitle{font-size:13px;color:var(--jex-text-muted, #64748b);line-height:1.45;margin:0 0 8px}.jex-escalation-skip{padding:8px 12px;border:none;background:transparent;color:var(--jex-text-muted, #64748b);font-size:13px;cursor:pointer;text-decoration:underline;text-underline-offset:2px;text-align:center}.jex-escalation-skip:hover{color:var(--jex-text-main, #0f172a)}.jex-inline-form-card{position:relative;padding:14px;gap:8px}.jex-inline-form-dismiss{position:absolute;top:10px;right:10px;width:24px;height:24px;border-radius:50%;border:1px solid var(--jex-border-input, #e2e8f0);background:var(--jex-bg-window, #fff);color:var(--jex-text-muted, #64748b);font-size:12px;cursor:pointer;display:flex;align-items:center;justify-content:center;line-height:1}.jex-inline-form-dismiss:hover{background:var(--jex-bg-msg-bot, #f1f5f9);color:var(--jex-text-main, #0f172a)}.jex-inline-form-submitted{display:flex;align-items:center;gap:10px;padding:10px 12px;background:var(--jex-bg-msg-bot, #f1f5f9);border:1px solid var(--jex-border-input, #e2e8f0);border-radius:var(--jex-radius, .75rem);width:100%}.jex-inline-form-check{display:flex;align-items:center;justify-content:center;width:24px;height:24px;border-radius:50%;background:color-mix(in srgb,var(--jex-primary) 15%,transparent);color:var(--jex-primary, #115A62);font-size:14px;font-weight:700;flex-shrink:0}.jex-inline-form-submitted-title{font-weight:600;font-size:var(--jex-font-size, 14px);color:var(--jex-text-main, #0f172a)}.jex-inline-form-submitted-detail{font-size:12px;color:var(--jex-text-muted, #64748b);margin-top:2px}.jex-magicline-row{display:flex;flex-direction:column;gap:8px}.jex-magicline-row>*{min-width:0}.jex-magicline-field{display:flex;flex-direction:column;gap:4px}.jex-magicline-field-label{font-size:12px;font-weight:500;color:var(--jex-text-muted, #64748b)}.jex-magicline-select{width:100%;appearance:none;cursor:pointer;padding-right:32px;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 10px center;background-size:16px 16px}.jex-magicline-slots-hint{font-size:12px;color:var(--jex-text-muted, #64748b);line-height:1.4;padding:2px 0}.jex-magicline-consent{display:flex;align-items:flex-start;gap:8px;font-size:11px;line-height:1.35;color:var(--jex-text-muted, #64748b);margin-top:2px;cursor:pointer}.jex-magicline-consent input[type=checkbox]{flex-shrink:0;margin-top:1px;accent-color:var(--jex-primary, #115A62)}.jex-magicline-error{font-size:12px;color:#dc2626;line-height:1.35}.jex-magicline-failed{border-color:color-mix(in srgb,#dc2626 35%,var(--jex-border-input, #e2e8f0))}.jex-magicline-failed-icon{background:color-mix(in srgb,#dc2626 15%,transparent);color:#dc2626}.jex-magicline-wizard-header{display:flex;flex-direction:column;gap:6px}.jex-magicline-wizard-progress{display:flex;align-items:baseline;justify-content:space-between;gap:8px}.jex-magicline-wizard-step-label{font-size:13px;font-weight:600;color:var(--jex-text-main, #0f172a)}.jex-magicline-wizard-counter{font-size:11px;color:var(--jex-text-muted, #64748b);flex-shrink:0}.jex-magicline-wizard-dots{display:flex;gap:6px}.jex-magicline-wizard-dot{width:7px;height:7px;border-radius:50%;background:color-mix(in srgb,var(--jex-text-muted, #64748b) 35%,transparent)}.jex-magicline-wizard-dot-active{background:var(--jex-primary, #115A62)}.jex-magicline-wizard-nav{display:flex;align-items:center;gap:8px;margin-top:4px}.jex-magicline-wizard-next{flex:1;margin-top:0}.jex-magicline-wizard-back{padding:10px 14px;border-radius:8px;border:1px solid var(--jex-border-input, #e2e8f0);background:transparent;color:var(--jex-text-main, #0f172a);font-size:14px;font-weight:600;cursor:pointer}.jex-magicline-wizard-back:hover{background:var(--jex-bg-window, #fff)}.jex-magicline-wizard-back:disabled,.jex-magicline-wizard-next:disabled{opacity:.7;cursor:not-allowed}.jex-magicline-radio-group{display:flex;flex-direction:column;gap:8px}.jex-magicline-radio-card{display:flex;align-items:center;gap:10px;padding:12px;border-radius:10px;border:1px solid var(--jex-border-input, #e2e8f0);font-size:14px;color:var(--jex-text-main, #0f172a);cursor:pointer}.jex-magicline-radio-card-active{border-color:var(--jex-primary, #115A62);background:color-mix(in srgb,var(--jex-primary, #115A62) 8%,transparent)}.jex-magicline-radio-card input[type=radio]{flex-shrink:0;accent-color:var(--jex-primary, #115A62)}.jex-magicline-slots-error{display:flex;flex-direction:column;gap:6px}.jex-magicline-retry{align-self:flex-start;padding:6px 12px;border-radius:8px;border:1px solid var(--jex-border-input, #e2e8f0);background:transparent;color:var(--jex-text-main, #0f172a);font-size:13px;font-weight:600;cursor:pointer}.jex-magicline-retry:hover{background:var(--jex-bg-window, #fff)}.jex-magicline-retry:disabled{opacity:.7;cursor:not-allowed}.jex-magicline-summary{display:flex;flex-direction:column;gap:6px;margin:0;padding:10px 12px;border-radius:8px;background:var(--jex-bg-window, #fff);border:1px solid var(--jex-border-input, #e2e8f0)}.jex-magicline-summary-row{display:flex;align-items:baseline;justify-content:space-between;gap:12px}.jex-magicline-summary-row dt{font-size:12px;color:var(--jex-text-muted, #64748b);flex-shrink:0}.jex-magicline-summary-row dd{margin:0;font-size:13px;font-weight:500;color:var(--jex-text-main, #0f172a);text-align:right}.jex-escalation-confirm{border-left:3px solid var(--jex-primary, #115A62);padding-left:8px}.jex-session-prompt{display:flex;flex-direction:column;align-items:center;gap:8px;padding:12px 16px;margin:8px 0;text-align:center}.jex-session-prompt-text{font-size:13px;color:var(--jex-text-muted, #64748b)}.jex-session-prompt-btn{padding:8px 16px;border-radius:8px;border:1px solid var(--jex-primary, #115A62);background:transparent;color:var(--jex-primary, #115A62);font-size:13px;font-weight:600;cursor:pointer}.jex-session-prompt-btn:hover{background:color-mix(in srgb,var(--jex-primary) 10%,transparent)}.jex-chat-input-resolved{display:flex;flex-direction:column;align-items:center;gap:10px;padding:14px 16px;border-top:1px solid var(--jex-border-input, #e2e8f0);background:var(--jex-bg-msg-bot, #f1f5f9);text-align:center}.jex-resolved-notice{font-size:13px;font-weight:500;color:var(--jex-text-muted, #64748b)}.jex-resolved-new-btn{padding:10px 20px;border-radius:8px;border:none;background:var(--jex-primary, #115A62);color:#fff;font-size:13px;font-weight:600;cursor:pointer;width:100%}.jex-resolved-new-btn:hover{opacity:.9}.jex-confirmation{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:32px 24px;height:100%;text-align:center}.jex-confirmation-icon{width:48px;height:48px;border-radius:50%;background:color-mix(in srgb,var(--jex-primary, #115A62) 15%,transparent);color:var(--jex-primary, #115A62);font-size:22px;display:flex;align-items:center;justify-content:center}.jex-confirmation-title{font-size:18px;font-weight:700;color:var(--jex-text-main, #0f172a);margin:0}.jex-confirmation-body{font-size:13px;color:var(--jex-text-muted, #64748b);margin:0}.jex-confirmation-ref{font-size:20px;font-weight:700;letter-spacing:.05em;color:var(--jex-primary, #115A62);background:color-mix(in srgb,var(--jex-primary, #115A62) 10%,transparent);padding:10px 20px;border-radius:10px}.jex-confirmation-hint{font-size:12px;color:var(--jex-text-muted, #64748b);margin:0}.jex-confirmation-done{margin-top:8px;padding:10px 28px;border-radius:8px;border:none;background:var(--jex-primary, #115A62);color:#fff;font-size:14px;font-weight:600;cursor:pointer}.jex-home-lookup-link{background:none;border:none;font-size:12px;color:var(--jex-text-muted, #64748b);cursor:pointer;text-decoration:underline;padding:0;align-self:center}.jex-home-lookup{display:flex;gap:8px;width:100%;animation:jexFadeIn .4s .1s ease both}.jex-home-lookup-input{flex:1;padding:10px 14px;border-radius:10px;border:1px solid var(--jex-border-input, #e2e8f0);background:var(--jex-bg-input);color:var(--jex-text-main);font-size:14px;font-family:ui-monospace,Cascadia Code,Fira Code,monospace;letter-spacing:.04em;outline:none;transition:border-color .2s}@media(pointer:coarse){.jex-home-lookup-input{font-size:16px}}.jex-home-lookup-input::placeholder{font-family:inherit;letter-spacing:.04em;color:var(--jex-text-muted);opacity:.7}.jex-home-lookup-input:focus{border-color:var(--jex-primary, #115A62)}.jex-home-lookup-submit{padding:10px 16px;border-radius:10px;border:none;background:var(--jex-primary, #115A62);color:#fff;font-size:13px;font-weight:600;cursor:pointer;font-family:inherit;transition:background .2s,opacity .2s;flex-shrink:0}.jex-home-lookup-submit:hover:not(:disabled){background:var(--jex-primary-hover)}.jex-home-lookup-submit:disabled{opacity:.4;cursor:default}.jex-sources-row{margin-top:6px;margin-left:32px;display:flex;flex-direction:column;gap:6px}.jex-sources-toggle{display:inline-flex;align-items:center;gap:4px;padding:2px 8px;background:transparent;border:none;border-radius:6px;cursor:pointer;font-size:11px;color:var(--jex-text-muted, #6b7280);font-family:inherit;align-self:flex-start;transition:background .15s,color .15s}.jex-sources-toggle:hover{background:#0000000a;color:inherit}.jex-sources-icon{font-size:12px;line-height:1}.jex-sources-chevron{display:inline-block;font-size:10px;transition:transform .15s}.jex-sources-chevron--open{transform:rotate(180deg)}.jex-sources-pills{display:flex;flex-wrap:wrap;align-items:center;gap:6px}.jex-source-pill{display:inline-flex;align-items:center;gap:6px;max-width:240px;padding:2px 8px;border-radius:999px;border:1px solid rgba(0,0,0,.1);background:#0000000a;color:var(--jex-text-muted, #6b7280);font-size:11px;text-decoration:none;cursor:pointer;transition:background .15s,color .15s}.jex-source-pill:hover{background:#00000014;color:inherit}.jex-source-id{display:inline-flex;align-items:center;justify-content:center;min-width:16px;height:16px;padding:0 4px;border-radius:4px;background:var(--jex-primary, #115A62);color:#fff;font-size:10px;font-weight:600;line-height:1;flex-shrink:0;font-variant-numeric:tabular-nums}.jex-source-type{font-size:10px;flex-shrink:0}.jex-source-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:500}.jex-source-score{opacity:.6;flex-shrink:0;font-variant-numeric:tabular-nums}`;function Gu(t){const e=document.createElement("style");e.textContent=Hu,t.appendChild(e)}const Ju="https://festive-mouse-978.eu-west-1.convex.cloud";let Xn=null;function Ku(t){const e=t??Ju;if(!e)throw new Error("[jexity] No Convex URL โ set VITE_CONVEX_URL at build time or data-convex-url on the script tag");return Xn||(Xn=new Da(rl(e))),Xn}function Zu(t,e){const n=t.shadowRoot??t.attachShadow({mode:"open"});for(;n.firstChild;)n.removeChild(n.firstChild);Gu(n),Bt.value=e.source,be.value=e.bootstrapToken,W.value=[{id:"home"}],e.mode==="embedded"&&(t.classList.add("jex-mode-embedded"),N.value=!0);const r=document.createElement("div");return e.mode==="embedded"&&(r.style.cssText="width:100%;height:100%"),n.appendChild(r),_e(l(Fa,{client:Ku(e.convexUrl),children:l(Vu,{options:e})}),r),function(){_e(null,r),N.value=!1,Bt.value=void 0,be.value=void 0,W.value=[{id:"home"}]}}function Yu(t,e,n){const r=Zu(t,e),i=new Set,o=N.subscribe(a=>{for(const c of i)c(a)});return{shutdown(){o(),i.clear(),r(),n&&n()},open(){N.value=!0},close(){N.value=!1},toggle(){N.value=!N.value},get isOpen(){return N.value},subscribe(a){return i.add(a),()=>{i.delete(a)}}}}let _t=null;function Xu(t){_t&&_t.shutdown();let e;t.container?e=typeof t.container=="string"?document.querySelector(t.container):t.container:(e=document.createElement("div"),e.id="jexity-chat-widget",document.body.appendChild(e));const n=Yu(e,t,()=>{t.container||e.remove(),_t===n&&(_t=null)});return _t=n,n}function ye(t,e){return t.getAttribute(e)??void 0}async function Ao(){const t=document.currentScript??document.querySelector("script[data-org-slug]")??document.querySelector("script[data-org-id]");if(!t)return;const e=t.getAttribute("data-org-slug")??t.getAttribute("data-org-id")??"default-org",n=t.getAttribute("data-proj-slug")??void 0,r=ye(t,"data-convex-url")??"https://festive-mouse-978.eu-west-1.convex.cloud"??"",i=Pn(r),o=await In(e,i,n);if(!o.ok){const a=window.location.origin,c=n?`project '${e}/${n}'`:`org '${e}'`;o.error==="unauthorized"?console.warn(`[JexityChat] This domain is not authorized for ${c}. Add '${a}' under Allowed Domains in your Jexity dashboard.`):o.error==="not_found"?console.warn(`[JexityChat] No active widget config found for ${c}. Check that the org slug is correct and the widget is enabled.`):o.error==="rate_limited"?console.warn(`[JexityChat] Bootstrap rate-limited for ${c}. Retry after ${o.retryAfterSec??60}s.`):console.warn(`[JexityChat] Bootstrap failed (network error). Check that the Convex deployment is reachable at ${i}.`);return}if(o.allowedUrls.length>0&&!o.allowedUrls.some(a=>qn(window.location.href,a))){const a=n?`project '${e}/${n}'`:`org '${e}'`;console.warn(`[JexityChat] Widget hidden for ${a} โ current page does not match path rule. Allowed: ${o.allowedUrls.join(", ")}`);return}const s={orgSlug:e,projSlug:n,bootstrapToken:o.token,allowedUrls:o.allowedUrls,excludePaths:o.excludePaths,position:ye(t,"data-position")??void 0,theme:ye(t,"data-theme")??void 0,greeting:ye(t,"data-greeting"),title:ye(t,"data-title"),primaryColor:ye(t,"data-primary-color"),locale:ye(t,"data-locale"),convexUrl:ye(t,"data-convex-url")};window.JexityChat=Xu(s)}document.readyState==="complete"?Ao():window.addEventListener("load",Ao)})();
|
|
70
70
|
//# sourceMappingURL=widget.js.map
|