@aginies/embed 0.3.0 → 0.3.1
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/aginies.js +9 -7
- package/dist/aginies.js.map +1 -1
- package/package.json +1 -1
package/dist/aginies.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
"use strict";var Aginies=(()=>{var ve=Object.defineProperty;var In=Object.getOwnPropertyDescriptor;var zn=Object.getOwnPropertyNames;var Un=Object.prototype.hasOwnProperty;var Hn=(t,e,n)=>e in t?ve(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var On=(t,e)=>{for(var n in e)ve(t,n,{get:e[n],enumerable:!0})},Dn=(t,e,n,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of zn(e))!Un.call(t,r)&&r!==n&&ve(t,r,{get:()=>e[r],enumerable:!(a=In(e,r))||a.enumerable});return t};var qn=t=>Dn(ve({},"__esModule",{value:!0}),t);var G=(t,e,n)=>Hn(t,typeof e!="symbol"?e+"":e,n);var $a={};On($a,{approval:()=>Tn,autoload:()=>Mn,chat:()=>Pn,init:()=>Rn,version:()=>Da});var Fe,k,_t,jn,ne,gt,bt,ht,ze,ye,ge,vt,De,Ue,He,xt,we={},Ce=[],$n=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,fe=Array.isArray;function Y(t,e){for(var n in e)t[n]=e[n];return t}function qe(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function Q(t,e,n){var a,r,i,l={};for(i in e)i=="key"?a=e[i]:i=="ref"?r=e[i]:l[i]=e[i];if(arguments.length>2&&(l.children=arguments.length>3?Fe.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(i in t.defaultProps)l[i]===void 0&&(l[i]=t.defaultProps[i]);return ke(t,l,a,r,null)}function ke(t,e,n,a,r){var i={type:t,props:e,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r??++_t,__i:-1,__u:0};return r==null&&k.vnode!=null&&k.vnode(i),i}function T(t){return t.children}function K(t,e){this.props=t,this.context=e}function le(t,e){if(e==null)return t.__?le(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"?le(t):null}function Vn(t){if(t.__P&&t.__d){var e=t.__v,n=e.__e,a=[],r=[],i=Y({},e);i.__v=e.__v+1,k.vnode&&k.vnode(i),je(t.__P,i,e,t.__n,t.__P.namespaceURI,32&e.__u?[n]:null,a,n??le(e),!!(32&e.__u),r),i.__v=e.__v,i.__.__k[i.__i]=i,At(a,i,r),e.__e=e.__=null,i.__e!=n&&yt(i)}}function yt(t){if((t=t.__)!=null&&t.__c!=null)return t.__e=t.__c.base=null,t.__k.some(function(e){if(e!=null&&e.__e!=null)return t.__e=t.__c.base=e.__e}),yt(t)}function Oe(t){(!t.__d&&(t.__d=!0)&&ne.push(t)&&!Ae.__r++||gt!=k.debounceRendering)&&((gt=k.debounceRendering)||bt)(Ae)}function Ae(){try{for(var t,e=1;ne.length;)ne.length>e&&ne.sort(ht),t=ne.shift(),e=ne.length,Vn(t)}finally{ne.length=Ae.__r=0}}function kt(t,e,n,a,r,i,l,c,d,u,p){var b,s,g,f,C,w,y=a&&a.__k||Ce,m=e.length;for(d=Wn(n,e,y,d,m),b=0;b<m;b++)(g=n.__k[b])!=null&&(s=g.__i!=-1&&y[g.__i]||we,g.__i=b,w=je(t,g,s,r,i,l,c,d,u,p),f=g.__e,g.ref&&s.ref!=g.ref&&(s.ref&&$e(s.ref,null,g),p.push(g.ref,g.__c||f,g)),C==null&&f!=null&&(C=f),4&g.__u?(d=wt(g,d,t),s.__e&&(s.__e=null)):typeof g.type=="function"&&w!==void 0?d=w:f&&(d=f.nextSibling),g.__u&=-7);return n.__e=C,d}function Wn(t,e,n,a,r){var i,l,c,d,u,p=n.length,b=p,s=0;for(t.__k=new Array(r),i=0;i<r;i++)(l=e[i])!=null&&typeof l!="boolean"&&typeof l!="function"?(typeof l=="string"||typeof l=="number"||typeof l=="bigint"||l.constructor==String?l=t.__k[i]=ke(null,l,null,null,null):fe(l)?l=t.__k[i]=ke(T,{children:l},null,null,null):l.constructor===void 0&&l.__b>0?l=t.__k[i]=ke(l.type,l.props,l.key,l.ref?l.ref:null,l.__v):t.__k[i]=l,d=i+s,l.__=t,l.__b=t.__b+1,c=null,(u=l.__i=Jn(l,n,d,b))!=-1&&(b--,(c=n[u])&&(c.__u|=2)),c==null||c.__v==null?(u==-1&&(r>p?s--:r<p&&s++),typeof l.type!="function"&&(l.__u|=4)):u!=d&&(u==d-1?s--:u==d+1?s++:(u>d?s--:s++,l.__u|=4))):t.__k[i]=null;if(b)for(i=0;i<p;i++)(c=n[i])!=null&&(2&c.__u)==0&&(c.__e==a&&(a=le(c)),St(c,c));return a}function wt(t,e,n){var a,r;if(typeof t.type=="function"){for(a=t.__k,r=0;a&&r<a.length;r++)a[r]&&(a[r].__=t,e=wt(a[r],e,n));return e}t.__e!=e&&(e&&t.type&&!e.parentNode&&(e=le(t)),e=n.insertBefore(t.__e,e||null));do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function me(t,e){return e=e||[],t==null||typeof t=="boolean"||(fe(t)?t.some(function(n){me(n,e)}):e.push(t)),e}function Jn(t,e,n,a){var r,i,l,c=t.key,d=t.type,u=e[n],p=u!=null&&(2&u.__u)==0;if(u===null&&c==null||p&&c==u.key&&d==u.type)return n;if(a>(p?1:0)){for(r=n-1,i=n+1;r>=0||i<e.length;)if((u=e[l=r>=0?r--:i++])!=null&&(2&u.__u)==0&&c==u.key&&d==u.type)return l}return-1}function ft(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||$n.test(e)?n:n+"px"}function xe(t,e,n,a,r){var i,l;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof a=="string"&&(t.style.cssText=a=""),a)for(e in a)n&&e in n||ft(t.style,e,"");if(n)for(e in n)a&&n[e]==a[e]||ft(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")i=e!=(e=e.replace(vt,"$1")),l=e.toLowerCase(),e=l in t||e=="onFocusOut"||e=="onFocusIn"?l.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+i]=n,n?a?n[ge]=a[ge]:(n[ge]=De,t.addEventListener(e,i?He:Ue,i)):t.removeEventListener(e,i?He:Ue,i);else{if(r=="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 mt(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e[ye]==null)e[ye]=De++;else if(e[ye]<n[ge])return;return n(k.event?k.event(e):e)}}}function je(t,e,n,a,r,i,l,c,d,u){var p,b,s,g,f,C,w,y,m,v,h,A,L,V,$,S,_=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(d=!!(32&n.__u),i=[c=e.__e=n.__e]),(p=k.__b)&&p(e);e:if(typeof _=="function"){b=l.length;try{if(m=e.props,v=_.prototype&&_.prototype.render,h=(p=_.contextType)&&a[p.__c],A=p?h?h.props.value:p.__:a,n.__c?y=(s=e.__c=n.__c).__=s.__E:(v?e.__c=s=new _(m,A):(e.__c=s=new K(m,A),s.constructor=_,s.render=Kn),h&&h.sub(s),s.state||(s.state={}),s.__n=a,g=s.__d=!0,s.__h=[],s._sb=[]),v&&s.__s==null&&(s.__s=s.state),v&&_.getDerivedStateFromProps!=null&&(s.__s==s.state&&(s.__s=Y({},s.__s)),Y(s.__s,_.getDerivedStateFromProps(m,s.__s))),f=s.props,C=s.state,s.__v=e,g)v&&_.getDerivedStateFromProps==null&&s.componentWillMount!=null&&s.componentWillMount(),v&&s.componentDidMount!=null&&s.__h.push(s.componentDidMount);else{if(v&&_.getDerivedStateFromProps==null&&m!==f&&s.componentWillReceiveProps!=null&&s.componentWillReceiveProps(m,A),e.__v==n.__v||!s.__e&&s.shouldComponentUpdate!=null&&s.shouldComponentUpdate(m,s.__s,A)===!1){e.__v!=n.__v&&(s.props=m,s.state=s.__s,s.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(R){R&&(R.__=e)}),Ce.push.apply(s.__h,s._sb),s._sb=[],s.__h.length&&l.push(s),c=le(n);break e}s.componentWillUpdate!=null&&s.componentWillUpdate(m,s.__s,A),v&&s.componentDidUpdate!=null&&s.__h.push(function(){s.componentDidUpdate(f,C,w)})}if(s.context=A,s.props=m,s.__P=t,s.__e=!1,L=k.__r,V=0,v)s.state=s.__s,s.__d=!1,L&&L(e),p=s.render(s.props,s.state,s.context),Ce.push.apply(s.__h,s._sb),s._sb=[];else do s.__d=!1,L&&L(e),p=s.render(s.props,s.state,s.context),s.state=s.__s;while(s.__d&&++V<25);s.state=s.__s,s.getChildContext!=null&&(a=Y(Y({},a),s.getChildContext())),v&&!g&&s.getSnapshotBeforeUpdate!=null&&(w=s.getSnapshotBeforeUpdate(f,C)),$=p!=null&&p.type===T&&p.key==null?Ft(p.props.children):p,c=kt(t,fe($)?$:[$],e,n,a,r,i,l,c,d,u),s.base=e.__e,e.__u&=-161,s.__h.length&&l.push(s),y&&(s.__E=s.__=null)}catch(R){if(l.length=b,e.__v=null,d||i!=null){if(R.then){for(e.__u|=d?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;i!=null&&(i[i.indexOf(c)]=null),e.__e=c}else if(i!=null)for(S=i.length;S--;)qe(i[S])}else e.__e=n.__e;e.__k==null&&(e.__k=n.__k||[]),R.then||Ct(e),k.__e(R,e,n)}}else i==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):c=e.__e=Gn(n.__e,e,n,a,r,i,l,d,u);return(p=k.diffed)&&p(e),128&e.__u?void 0:c}function Ct(t){t&&(t.__c&&(t.__c.__e=!0),t.__k&&t.__k.some(Ct))}function At(t,e,n){for(var a=0;a<n.length;a++)$e(n[a],n[++a],n[++a]);k.__c&&k.__c(e,t),t.some(function(r){try{t=r.__h,r.__h=[],t.some(function(i){i.call(r)})}catch(i){k.__e(i,r.__v)}})}function Ft(t){return typeof t!="object"||t==null||t.__b>0?t:fe(t)?t.map(Ft):t.constructor!==void 0?null:Y({},t)}function Gn(t,e,n,a,r,i,l,c,d){var u,p,b,s,g,f,C,w=n.props||we,y=e.props,m=e.type;if(m=="svg"?r="http://www.w3.org/2000/svg":m=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),i!=null){for(u=0;u<i.length;u++)if((g=i[u])&&"setAttribute"in g==!!m&&(m?g.localName==m:g.nodeType==3)){t=g,i[u]=null;break}}if(t==null){if(m==null)return document.createTextNode(y);t=document.createElementNS(r,m,y.is&&y),c&&(k.__m&&k.__m(e,i),c=!1),i=null}if(m==null)w===y||c&&t.data==y||(t.data=y);else{if(i=m=="textarea"&&y.defaultValue!=null?null:i&&Fe.call(t.childNodes),!c&&i!=null)for(w={},u=0;u<t.attributes.length;u++)w[(g=t.attributes[u]).name]=g.value;for(u in w)g=w[u],u=="dangerouslySetInnerHTML"?b=g:u=="children"||u in y||u=="value"&&"defaultValue"in y||u=="checked"&&"defaultChecked"in y||xe(t,u,null,g,r);for(u in y)g=y[u],u=="children"?s=g:u=="dangerouslySetInnerHTML"?p=g:u=="value"?f=g:u=="checked"?C=g:c&&typeof g!="function"||w[u]===g||xe(t,u,g,w[u],r);if(p)c||b&&(p.__html==b.__html||p.__html==t.innerHTML)||(t.innerHTML=p.__html),e.__k=[];else if(b&&(t.innerHTML=""),kt(e.type=="template"?t.content:t,fe(s)?s:[s],e,n,a,m=="foreignObject"?"http://www.w3.org/1999/xhtml":r,i,l,i?i[0]:n.__k&&le(n,0),c,d),i!=null)for(u=i.length;u--;)qe(i[u]);c&&m!="textarea"||(u="value",m=="progress"&&f==null?t.removeAttribute("value"):f!=null&&(f!==t[u]||m=="progress"&&!f||m=="option"&&f!=w[u])&&xe(t,u,f,w[u],r),u="checked",C!=null&&C!=t[u]&&xe(t,u,C,w[u],r))}return t}function $e(t,e,n){try{if(typeof t=="function"){var a=typeof t.__u=="function";a&&t.__u(),a&&e==null||(t.__u=t(e))}else t.current=e}catch(r){k.__e(r,n)}}function St(t,e,n){var a,r;if(k.unmount&&k.unmount(t),(a=t.ref)&&(a.current&&a.current!=t.__e||$e(a,null,e)),(a=t.__c)!=null){if(a.componentWillUnmount)try{a.componentWillUnmount()}catch(i){k.__e(i,e)}a.base=a.__P=a.__n=null}if(a=t.__k)for(r=0;r<a.length;r++)a[r]&&St(a[r],e,n||typeof t.type!="function");n||qe(t.__e),t.__c=t.__=t.__e=void 0}function Kn(t,e,n){return this.constructor(t,n)}function Ve(t,e,n){var a,r,i,l;e==document&&(e=document.documentElement),k.__&&k.__(t,e),r=(a=typeof n=="function")?null:n&&n.__k||e.__k,i=[],l=[],je(e,t=(!a&&n||e).__k=Q(T,null,[t]),r||we,we,e.namespaceURI,!a&&n?[n]:r?null:e.firstChild?Fe.call(e.childNodes):null,i,!a&&n?n:r?r.__e:e.firstChild,a,l),At(i,t,l),t.props.children=null}function Se(t){function e(n){var a,r;return this.getChildContext||(a=new Set,(r={})[e.__c]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){a=null},this.shouldComponentUpdate=function(i){this.props.value!=i.value&&a.forEach(function(l){l.__e=!0,Oe(l)})},this.sub=function(i){a.add(i);var l=i.componentWillUnmount;i.componentWillUnmount=function(){a&&a.delete(i),l&&l.call(i)}}),n.children}return e.__c="__cC"+xt++,e.__=t,e.Provider=e.__l=(e.Consumer=function(n,a){return n.children(a)}).contextType=e,e}Fe=Ce.slice,k={__e:function(t,e,n,a){for(var r,i,l;e=e.__;)if((r=e.__c)&&!r.__)try{if((i=r.constructor)&&i.getDerivedStateFromError!=null&&(r.setState(i.getDerivedStateFromError(t)),l=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(t,a||{}),l=r.__d),l)return r.__E=r}catch(c){t=c}throw t}},_t=0,jn=function(t){return t!=null&&t.constructor===void 0},K.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Y({},this.state),typeof t=="function"&&(t=t(Y({},n),this.props)),t&&Y(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),Oe(this))},K.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),Oe(this))},K.prototype.render=T,ne=[],bt=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,ht=function(t,e){return t.__v.__b-e.__v.__b},Ae.__r=0,ze=Math.random().toString(8),ye="__d"+ze,ge="__a"+ze,vt=/(PointerCapture)$|Capture$/i,De=0,Ue=mt(!1),He=mt(!0),xt=0;var ue,N,We,Et,_e=0,It=[],z=k,Rt=z.__b,Pt=z.__r,Tt=z.diffed,Nt=z.__c,Mt=z.unmount,Bt=z.__;function Re(t,e){z.__h&&z.__h(N,t,_e||e),_e=0;var n=N.__H||(N.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function F(t){return _e=1,zt(Ht,t)}function zt(t,e,n){var a=Re(ue++,2);if(a.t=t,!a.__c&&(a.__=[n?n(e):Ht(void 0,e),function(c){var d=a.__N?a.__N[0]:a.__[0],u=a.t(d,c);d!==u&&(a.__N=[u,a.__[1]],a.__c.setState({}))}],a.__c=N,!N.__f)){var r=function(c,d,u){if(!a.__c.__H)return!0;var p=!1,b=a.__c.props!==c;if(a.__c.__H.__.some(function(g){if(g.__N){p=!0;var f=g.__[0];g.__=g.__N,g.__N=void 0,f!==g.__[0]&&(b=!0)}}),i){var s=i.call(this,c,d,u);return p?s||b:s}return!p||b};N.__f=!0;var i=N.shouldComponentUpdate,l=N.componentWillUpdate;N.componentWillUpdate=function(c,d,u){if(this.__e){var p=i;i=void 0,r(c,d,u),i=p}l&&l.call(this,c,d,u)},N.shouldComponentUpdate=r}return a.__N||a.__}function q(t,e){var n=Re(ue++,3);!z.__s&&Ut(n.__H,e)&&(n.__=t,n.u=e,N.__H.__h.push(n))}function M(t){return _e=5,ae(function(){return{current:t}},[])}function ae(t,e){var n=Re(ue++,7);return Ut(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function B(t,e){return _e=8,ae(function(){return t},e)}function Ge(t){var e=N.context[t.__c],n=Re(ue++,9);return n.c=t,e?(n.__==null&&(n.__=!0,e.sub(N)),e.props.value):t.__}function Qn(){for(var t;t=It.shift();){var e=t.__H;if(t.__P&&e)try{e.__h.some(Ee),e.__h.some(Je),e.__h=[]}catch(n){e.__h=[],z.__e(n,t.__v)}}}z.__b=function(t){N=null,Rt&&Rt(t)},z.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),Bt&&Bt(t,e)},z.__r=function(t){Pt&&Pt(t),ue=0;var e=(N=t.__c).__H;e&&(We===N?(e.__h=[],N.__h=[],e.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.some(Ee),e.__h.some(Je),e.__h=[],ue=0)),We=N},z.diffed=function(t){Tt&&Tt(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(It.push(e)!==1&&Et===z.requestAnimationFrame||((Et=z.requestAnimationFrame)||Yn)(Qn)),e.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),We=N=null},z.__c=function(t,e){e.some(function(n){try{n.__h.some(Ee),n.__h=n.__h.filter(function(a){return!a.__||Je(a)})}catch(a){e.some(function(r){r.__h&&(r.__h=[])}),e=[],z.__e(a,n.__v)}}),Nt&&Nt(t,e)},z.unmount=function(t){Mt&&Mt(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.some(function(a){try{Ee(a)}catch(r){e=r}}),n.__H=void 0,e&&z.__e(e,n.__v))};var Lt=typeof requestAnimationFrame=="function";function Yn(t){var e,n=function(){clearTimeout(a),Lt&&cancelAnimationFrame(e),setTimeout(t)},a=setTimeout(n,35);Lt&&(e=requestAnimationFrame(n))}function Ee(t){var e=N,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),N=e}function Je(t){var e=N;t.__c=t.__(),N=e}function Ut(t,e){return!t||t.length!==e.length||e.some(function(n,a){return n!==t[a]})}function Ht(t,e){return typeof e=="function"?e(t):e}function Kt(t,e){for(var n in e)t[n]=e[n];return t}function Ot(t,e){for(var n in t)if(n!=="__source"&&!(n in e))return!0;for(var a in e)if(a!=="__source"&&t[a]!==e[a])return!0;return!1}function Dt(t,e){this.props=t,this.context=e}(Dt.prototype=new K).isPureReactComponent=!0,Dt.prototype.shouldComponentUpdate=function(t,e){return Ot(this.props,t)||Ot(this.state,e)};var qt=k.__b;k.__b=function(t){t.type&&t.type.__f&&t.ref&&(t.props.ref=t.ref,t.ref=null),qt&&qt(t)};var Xn=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function Te(t){function e(n){var a=Kt({},n);return delete a.ref,t(a,n.ref||null)}return e.$$typeof=Xn,e.render=t,e.prototype.isReactComponent=e.__f=!0,e.displayName="ForwardRef("+(t.displayName||t.name)+")",e}var ea=k.__e;k.__e=function(t,e,n,a){if(t.then){for(var r,i=e;i=i.__;)if((r=i.__c)&&r.__c)return e.__e==null&&(e.__e=n.__e,e.__k=n.__k||[]),r.__c(t,e)}ea(t,e,n,a)};var jt=k.unmount;function Qt(t,e,n){return t&&(t.__c&&t.__c.__H&&(t.__c.__H.__.forEach(function(a){typeof a.__c=="function"&&a.__c()}),t.__c.__H=null),(t=Kt({},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(a){return Qt(a,e,n)})),t}function Yt(t,e,n){return t&&n&&(t.__v=null,t.__k=t.__k&&t.__k.map(function(a){return Yt(a,e,n)}),t.__c&&t.__c.__P===e&&(t.__e&&n.appendChild(t.__e),t.__c.__e=!0,t.__c.__P=n)),t}function Ke(){this.__u=0,this.o=null,this.__b=null}function Zt(t){var e=t.__&&t.__.__c;return e&&e.__a&&e.__a(t)}function Pe(){this.i=null,this.l=null}k.unmount=function(t){var e=t.__c;e&&(e.__z=!0),e&&e.__R&&e.__R(),e&&32&t.__u&&(t.type=null),jt&&jt(t)},(Ke.prototype=new K).__c=function(t,e){var n=e.__c,a=this;a.o==null&&(a.o=[]),a.o.push(n);var r=Zt(a.__v),i=!1,l=function(){i||a.__z||(i=!0,n.__R=null,r?r(d):d())};n.__R=l;var c=n.__P;n.__P=null;var d=function(){if(!--a.__u){if(a.state.__a){var u=a.state.__a;a.__v.__k[0]=Yt(u,u.__c.__P,u.__c.__O)}var p;for(a.setState({__a:a.__b=null});p=a.o.pop();)p.__P=c,p.forceUpdate()}};a.__u++||32&e.__u||a.setState({__a:a.__b=a.__v.__k[0]}),t.then(l,l)},Ke.prototype.componentWillUnmount=function(){this.o=[]},Ke.prototype.render=function(t,e){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),a=this.__v.__k[0].__c;this.__v.__k[0]=Qt(this.__b,n,a.__O=a.__P)}this.__b=null}var r=e.__a&&Q(T,null,t.fallback);return r&&(r.__u&=-33),[Q(T,null,e.__a?null:t.children),r]};var $t=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]}};(Pe.prototype=new K).__a=function(t){var e=this,n=Zt(e.__v),a=e.l.get(t);return a[0]++,function(r){var i=function(){e.props.revealOrder?(a.push(r),$t(e,t,a)):r()};n?n(i):i()}},Pe.prototype.render=function(t){this.i=null,this.l=new Map;var e=me(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},Pe.prototype.componentDidUpdate=Pe.prototype.componentDidMount=function(){var t=this;this.l.forEach(function(e,n){$t(t,n,e)})};var ta=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,na=/^(?: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]/,aa=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,ra=/[A-Z0-9]/g,ia=typeof document<"u",oa=function(t){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(t)};function Xt(t,e,n){return e.__k==null&&(e.textContent=""),Ve(t,e),typeof n=="function"&&n(),t?t.__c:null}K.prototype.isReactComponent=!0,["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(t){Object.defineProperty(K.prototype,t,{configurable:!0,get:function(){return this["UNSAFE_"+t]},set:function(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})});var Vt=k.event;k.event=function(t){return Vt&&(t=Vt(t)),t.persist=function(){},t.isPropagationStopped=function(){return this.cancelBubble},t.isDefaultPrevented=function(){return this.defaultPrevented},t.nativeEvent=t};var en,sa={configurable:!0,get:function(){return this.class}},Wt=k.vnode;k.vnode=function(t){typeof t.type=="string"&&(function(e){var n=e.props,a=e.type,r={},i=a.indexOf("-")==-1;for(var l in n){var c=n[l];if(!(l==="value"&&"defaultValue"in n&&c==null||ia&&l==="children"&&a==="noscript"||l==="class"||l==="className")){var d=l.toLowerCase();l==="defaultValue"&&"value"in n&&n.value==null?l="value":l==="download"&&c===!0?c="":d==="translate"&&c==="no"?c=!1:d[0]==="o"&&d[1]==="n"?d==="ondoubleclick"?l="ondblclick":d!=="onchange"||a!=="input"&&a!=="textarea"||oa(n.type)?d==="onfocus"?l="onfocusin":d==="onblur"?l="onfocusout":aa.test(l)&&(l=d):d=l="oninput":i&&na.test(l)?l=l.replace(ra,"-$&").toLowerCase():c===null&&(c=void 0),d==="oninput"&&r[l=d]&&(l="oninputCapture"),r[l]=c}}a=="select"&&(r.multiple&&Array.isArray(r.value)&&(r.value=me(n.children).forEach(function(u){u.props.selected=r.value.indexOf(u.props.value)!=-1})),r.defaultValue!=null&&(r.value=me(n.children).forEach(function(u){u.props.selected=r.multiple?r.defaultValue.indexOf(u.props.value)!=-1:r.defaultValue==u.props.value}))),n.class&&!n.className?(r.class=n.class,Object.defineProperty(r,"className",sa)):n.className&&(r.class=r.className=n.className),e.props=r})(t),t.$$typeof=ta,Wt&&Wt(t)};var Jt=k.__r;k.__r=function(t){Jt&&Jt(t),en=t.__c};var Gt=k.diffed;k.diffed=function(t){Gt&&Gt(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),en=null};function tn(t){return!!t.__k&&(Ve(null,t),!0)}var I=class extends Error{constructor(n,a,r){super(n);G(this,"status");G(this,"code");this.name="AginiesError",this.status=a,this.code=r}},la=t=>t.replace(/\/+$/,""),Ne=class{constructor(e){G(this,"baseUrl");G(this,"token");G(this,"hosted");G(this,"locale");G(this,"fetchImpl");G(this,"state",{status:"idle"});G(this,"listeners",new Set);G(this,"activation",null);G(this,"session",null);if(!e?.baseUrl)throw new I("baseUrl is required",0,"MISSING_BASE_URL");if(!e?.token&&!e?.hosted)throw new I("token is required",0,"MISSING_TOKEN");this.baseUrl=la(e.baseUrl),this.token=e.token??null,this.hosted=e.hosted===!0,this.locale=e.locale??ca(),this.fetchImpl=e.fetch??((...n)=>fetch(...n))}getState(){return this.state}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}setState(e){this.state=e;for(let n of this.listeners)n(e)}activate(){return this.activation?this.activation:(this.setState({status:"activating"}),this.activation=(async()=>{try{let e=await this.fetchImpl(`${this.baseUrl}/api/ui/activate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(this.hosted?{hosted:!0}:{token:this.token})});if(!e.ok){let a=await be(e),r=a&&a.error||`HTTP ${e.status}`;return this.setState({status:"rejected",reason:r}),this.state}let n=await e.json();return!n.activated||!n.config?(this.setState({status:"rejected",reason:"Activation refused"}),this.state):(this.session=n.session??null,this.setState({status:"active",config:n.config}),this.state)}catch(e){return this.setState({status:"rejected",reason:e instanceof Error?e.message:"Activation failed"}),this.state}})(),this.activation)}assertActive(){if(this.state.status!=="active")throw new I("Client is not activated",0,"NOT_ACTIVATED")}getSession(){return this.session}hasModule(e){if(this.state.status!=="active")return!1;let n=this.state.config.modules??[];return n.length===0||n.includes(e)}async renewSession(){return this.activation=null,(await this.activate()).status==="active"&&this.session!==null}withSession(e){if(!this.session)return e;let n=new Headers(e.headers??{});return n.has("Authorization")||n.set("Authorization",`Bearer ${this.session.token}`),{...e,headers:n}}async request(e,n={}){let a=`${this.baseUrl}${e.startsWith("/")?e:`/${e}`}`,r=()=>this.fetchImpl(a,this.withSession({credentials:"include",...n})),i=await r();return this.session&&(i.status===401||i.status===403)&&this.session.expiresAt*1e3<=Date.now()+5e3&&await this.renewSession()&&(i=await r()),i}fetchRaw(e,n={}){return this.assertActive(),this.request(e,n)}async transcribe(e,n,a="turn.webm",r){this.assertActive();let i=new FormData;i.append("file",n,a),r&&i.append("language",r);let l=await this.request(`/api/chat/${encodeURIComponent(e)}/voice/transcribe`,{method:"POST",body:i});if(!l.ok)throw await an(l);return await l.json()}async speak(e,n){this.assertActive();let a=await this.request(`/api/chat/${encodeURIComponent(e)}/voice/speak`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:n})});if(!a.ok)throw await an(a);return a.blob()}async getChat(e){this.assertActive();let n=await this.request(`/api/chat/${encodeURIComponent(e)}`),a=await be(n);if(n.status===401&&a&&typeof a.authRequired=="string")return a;if(!n.ok)throw new I(a?.error||`HTTP ${n.status}`,n.status);return a}async*sendMessage(e,n,a){this.assertActive();let r=await this.request(`/api/chat/${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n),signal:a});if(!r.ok){let l=await be(r);throw r.status===401&&l&&typeof l.authRequired=="string"?new I("Authentication required",401,"AUTH_REQUIRED"):new I(l?.error||`HTTP ${r.status}`,r.status)}if(!(r.headers.get("content-type")??"").includes("text/event-stream")){yield{type:"final",data:await be(r)},yield{type:"done"};return}yield*ua(r.body)}};async function*ua(t){let e=t.getReader(),n=new TextDecoder,a="";try{for(;;){let{done:i,value:l}=await e.read();if(i)break;a+=n.decode(l,{stream:!0});let c=a.indexOf(`
|
|
1
|
+
"use strict";var Aginies=(()=>{var ve=Object.defineProperty;var Ln=Object.getOwnPropertyDescriptor;var zn=Object.getOwnPropertyNames;var Un=Object.prototype.hasOwnProperty;var On=(t,e,n)=>e in t?ve(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Hn=(t,e)=>{for(var n in e)ve(t,n,{get:e[n],enumerable:!0})},Dn=(t,e,n,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of zn(e))!Un.call(t,r)&&r!==n&&ve(t,r,{get:()=>e[r],enumerable:!(a=Ln(e,r))||a.enumerable});return t};var qn=t=>Dn(ve({},"__esModule",{value:!0}),t);var G=(t,e,n)=>On(t,typeof e!="symbol"?e+"":e,n);var Wa={};Hn(Wa,{approval:()=>Tn,autoload:()=>Mn,chat:()=>Pn,init:()=>Rn,version:()=>ja});var Se,x,_t,jn,ne,gt,ht,bt,ze,ye,ge,vt,De,Ue,Oe,xt,we={},Ce=[],$n=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,fe=Array.isArray;function Z(t,e){for(var n in e)t[n]=e[n];return t}function qe(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function Y(t,e,n){var a,r,i,s={};for(i in e)i=="key"?a=e[i]:i=="ref"?r=e[i]:s[i]=e[i];if(arguments.length>2&&(s.children=arguments.length>3?Se.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(i in t.defaultProps)s[i]===void 0&&(s[i]=t.defaultProps[i]);return ke(t,s,a,r,null)}function ke(t,e,n,a,r){var i={type:t,props:e,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r??++_t,__i:-1,__u:0};return r==null&&x.vnode!=null&&x.vnode(i),i}function N(t){return t.children}function Q(t,e){this.props=t,this.context=e}function se(t,e){if(e==null)return t.__?se(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"?se(t):null}function Vn(t){if(t.__P&&t.__d){var e=t.__v,n=e.__e,a=[],r=[],i=Z({},e);i.__v=e.__v+1,x.vnode&&x.vnode(i),je(t.__P,i,e,t.__n,t.__P.namespaceURI,32&e.__u?[n]:null,a,n??se(e),!!(32&e.__u),r),i.__v=e.__v,i.__.__k[i.__i]=i,At(a,i,r),e.__e=e.__=null,i.__e!=n&&yt(i)}}function yt(t){if((t=t.__)!=null&&t.__c!=null)return t.__e=t.__c.base=null,t.__k.some(function(e){if(e!=null&&e.__e!=null)return t.__e=t.__c.base=e.__e}),yt(t)}function He(t){(!t.__d&&(t.__d=!0)&&ne.push(t)&&!Ae.__r++||gt!=x.debounceRendering)&&((gt=x.debounceRendering)||ht)(Ae)}function Ae(){try{for(var t,e=1;ne.length;)ne.length>e&&ne.sort(bt),t=ne.shift(),e=ne.length,Vn(t)}finally{ne.length=Ae.__r=0}}function kt(t,e,n,a,r,i,s,c,p,u,g){var h,l,d,f,w,y,k=a&&a.__k||Ce,m=e.length;for(p=Wn(n,e,k,p,m),h=0;h<m;h++)(d=n.__k[h])!=null&&(l=d.__i!=-1&&k[d.__i]||we,d.__i=h,y=je(t,d,l,r,i,s,c,p,u,g),f=d.__e,d.ref&&l.ref!=d.ref&&(l.ref&&$e(l.ref,null,d),g.push(d.ref,d.__c||f,d)),w==null&&f!=null&&(w=f),4&d.__u?(p=wt(d,p,t),l.__e&&(l.__e=null)):typeof d.type=="function"&&y!==void 0?p=y:f&&(p=f.nextSibling),d.__u&=-7);return n.__e=w,p}function Wn(t,e,n,a,r){var i,s,c,p,u,g=n.length,h=g,l=0;for(t.__k=new Array(r),i=0;i<r;i++)(s=e[i])!=null&&typeof s!="boolean"&&typeof s!="function"?(typeof s=="string"||typeof s=="number"||typeof s=="bigint"||s.constructor==String?s=t.__k[i]=ke(null,s,null,null,null):fe(s)?s=t.__k[i]=ke(N,{children:s},null,null,null):s.constructor===void 0&&s.__b>0?s=t.__k[i]=ke(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):t.__k[i]=s,p=i+l,s.__=t,s.__b=t.__b+1,c=null,(u=s.__i=Jn(s,n,p,h))!=-1&&(h--,(c=n[u])&&(c.__u|=2)),c==null||c.__v==null?(u==-1&&(r>g?l--:r<g&&l++),typeof s.type!="function"&&(s.__u|=4)):u!=p&&(u==p-1?l--:u==p+1?l++:(u>p?l--:l++,s.__u|=4))):t.__k[i]=null;if(h)for(i=0;i<g;i++)(c=n[i])!=null&&(2&c.__u)==0&&(c.__e==a&&(a=se(c)),Ft(c,c));return a}function wt(t,e,n){var a,r;if(typeof t.type=="function"){for(a=t.__k,r=0;a&&r<a.length;r++)a[r]&&(a[r].__=t,e=wt(a[r],e,n));return e}t.__e!=e&&(e&&t.type&&!e.parentNode&&(e=se(t)),e=n.insertBefore(t.__e,e||null));do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function me(t,e){return e=e||[],t==null||typeof t=="boolean"||(fe(t)?t.some(function(n){me(n,e)}):e.push(t)),e}function Jn(t,e,n,a){var r,i,s,c=t.key,p=t.type,u=e[n],g=u!=null&&(2&u.__u)==0;if(u===null&&c==null||g&&c==u.key&&p==u.type)return n;if(a>(g?1:0)){for(r=n-1,i=n+1;r>=0||i<e.length;)if((u=e[s=r>=0?r--:i++])!=null&&(2&u.__u)==0&&c==u.key&&p==u.type)return s}return-1}function ft(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||$n.test(e)?n:n+"px"}function xe(t,e,n,a,r){var i,s;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof a=="string"&&(t.style.cssText=a=""),a)for(e in a)n&&e in n||ft(t.style,e,"");if(n)for(e in n)a&&n[e]==a[e]||ft(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")i=e!=(e=e.replace(vt,"$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+i]=n,n?a?n[ge]=a[ge]:(n[ge]=De,t.addEventListener(e,i?Oe:Ue,i)):t.removeEventListener(e,i?Oe:Ue,i);else{if(r=="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 mt(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e[ye]==null)e[ye]=De++;else if(e[ye]<n[ge])return;return n(x.event?x.event(e):e)}}}function je(t,e,n,a,r,i,s,c,p,u){var g,h,l,d,f,w,y,k,m,v,b,S,L,W,q,j,_=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(p=!!(32&n.__u),i=[c=e.__e=n.__e]),(g=x.__b)&&g(e);e:if(typeof _=="function"){h=s.length;try{if(m=e.props,v=_.prototype&&_.prototype.render,b=(g=_.contextType)&&a[g.__c],S=g?b?b.props.value:g.__:a,n.__c?k=(l=e.__c=n.__c).__=l.__E:(v?e.__c=l=new _(m,S):(e.__c=l=new Q(m,S),l.constructor=_,l.render=Kn),b&&b.sub(l),l.state||(l.state={}),l.__n=a,d=l.__d=!0,l.__h=[],l._sb=[]),v&&l.__s==null&&(l.__s=l.state),v&&_.getDerivedStateFromProps!=null&&(l.__s==l.state&&(l.__s=Z({},l.__s)),Z(l.__s,_.getDerivedStateFromProps(m,l.__s))),f=l.props,w=l.state,l.__v=e,d)v&&_.getDerivedStateFromProps==null&&l.componentWillMount!=null&&l.componentWillMount(),v&&l.componentDidMount!=null&&l.__h.push(l.componentDidMount);else{if(v&&_.getDerivedStateFromProps==null&&m!==f&&l.componentWillReceiveProps!=null&&l.componentWillReceiveProps(m,S),e.__v==n.__v||!l.__e&&l.shouldComponentUpdate!=null&&l.shouldComponentUpdate(m,l.__s,S)===!1){e.__v!=n.__v&&(l.props=m,l.state=l.__s,l.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(C){C&&(C.__=e)}),Ce.push.apply(l.__h,l._sb),l._sb=[],l.__h.length&&s.push(l),c=se(n);break e}l.componentWillUpdate!=null&&l.componentWillUpdate(m,l.__s,S),v&&l.componentDidUpdate!=null&&l.__h.push(function(){l.componentDidUpdate(f,w,y)})}if(l.context=S,l.props=m,l.__P=t,l.__e=!1,L=x.__r,W=0,v)l.state=l.__s,l.__d=!1,L&&L(e),g=l.render(l.props,l.state,l.context),Ce.push.apply(l.__h,l._sb),l._sb=[];else do l.__d=!1,L&&L(e),g=l.render(l.props,l.state,l.context),l.state=l.__s;while(l.__d&&++W<25);l.state=l.__s,l.getChildContext!=null&&(a=Z(Z({},a),l.getChildContext())),v&&!d&&l.getSnapshotBeforeUpdate!=null&&(y=l.getSnapshotBeforeUpdate(f,w)),q=g!=null&&g.type===N&&g.key==null?St(g.props.children):g,c=kt(t,fe(q)?q:[q],e,n,a,r,i,s,c,p,u),l.base=e.__e,e.__u&=-161,l.__h.length&&s.push(l),k&&(l.__E=l.__=null)}catch(C){if(s.length=h,e.__v=null,p||i!=null){if(C.then){for(e.__u|=p?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;i!=null&&(i[i.indexOf(c)]=null),e.__e=c}else if(i!=null)for(j=i.length;j--;)qe(i[j])}else e.__e=n.__e;e.__k==null&&(e.__k=n.__k||[]),C.then||Ct(e),x.__e(C,e,n)}}else i==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):c=e.__e=Gn(n.__e,e,n,a,r,i,s,p,u);return(g=x.diffed)&&g(e),128&e.__u?void 0:c}function Ct(t){t&&(t.__c&&(t.__c.__e=!0),t.__k&&t.__k.some(Ct))}function At(t,e,n){for(var a=0;a<n.length;a++)$e(n[a],n[++a],n[++a]);x.__c&&x.__c(e,t),t.some(function(r){try{t=r.__h,r.__h=[],t.some(function(i){i.call(r)})}catch(i){x.__e(i,r.__v)}})}function St(t){return typeof t!="object"||t==null||t.__b>0?t:fe(t)?t.map(St):t.constructor!==void 0?null:Z({},t)}function Gn(t,e,n,a,r,i,s,c,p){var u,g,h,l,d,f,w,y=n.props||we,k=e.props,m=e.type;if(m=="svg"?r="http://www.w3.org/2000/svg":m=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),i!=null){for(u=0;u<i.length;u++)if((d=i[u])&&"setAttribute"in d==!!m&&(m?d.localName==m:d.nodeType==3)){t=d,i[u]=null;break}}if(t==null){if(m==null)return document.createTextNode(k);t=document.createElementNS(r,m,k.is&&k),c&&(x.__m&&x.__m(e,i),c=!1),i=null}if(m==null)y===k||c&&t.data==k||(t.data=k);else{if(i=m=="textarea"&&k.defaultValue!=null?null:i&&Se.call(t.childNodes),!c&&i!=null)for(y={},u=0;u<t.attributes.length;u++)y[(d=t.attributes[u]).name]=d.value;for(u in y)d=y[u],u=="dangerouslySetInnerHTML"?h=d:u=="children"||u in k||u=="value"&&"defaultValue"in k||u=="checked"&&"defaultChecked"in k||xe(t,u,null,d,r);for(u in k)d=k[u],u=="children"?l=d:u=="dangerouslySetInnerHTML"?g=d:u=="value"?f=d:u=="checked"?w=d:c&&typeof d!="function"||y[u]===d||xe(t,u,d,y[u],r);if(g)c||h&&(g.__html==h.__html||g.__html==t.innerHTML)||(t.innerHTML=g.__html),e.__k=[];else if(h&&(t.innerHTML=""),kt(e.type=="template"?t.content:t,fe(l)?l:[l],e,n,a,m=="foreignObject"?"http://www.w3.org/1999/xhtml":r,i,s,i?i[0]:n.__k&&se(n,0),c,p),i!=null)for(u=i.length;u--;)qe(i[u]);c&&m!="textarea"||(u="value",m=="progress"&&f==null?t.removeAttribute("value"):f!=null&&(f!==t[u]||m=="progress"&&!f||m=="option"&&f!=y[u])&&xe(t,u,f,y[u],r),u="checked",w!=null&&w!=t[u]&&xe(t,u,w,y[u],r))}return t}function $e(t,e,n){try{if(typeof t=="function"){var a=typeof t.__u=="function";a&&t.__u(),a&&e==null||(t.__u=t(e))}else t.current=e}catch(r){x.__e(r,n)}}function Ft(t,e,n){var a,r;if(x.unmount&&x.unmount(t),(a=t.ref)&&(a.current&&a.current!=t.__e||$e(a,null,e)),(a=t.__c)!=null){if(a.componentWillUnmount)try{a.componentWillUnmount()}catch(i){x.__e(i,e)}a.base=a.__P=a.__n=null}if(a=t.__k)for(r=0;r<a.length;r++)a[r]&&Ft(a[r],e,n||typeof t.type!="function");n||qe(t.__e),t.__c=t.__=t.__e=void 0}function Kn(t,e,n){return this.constructor(t,n)}function Ve(t,e,n){var a,r,i,s;e==document&&(e=document.documentElement),x.__&&x.__(t,e),r=(a=typeof n=="function")?null:n&&n.__k||e.__k,i=[],s=[],je(e,t=(!a&&n||e).__k=Y(N,null,[t]),r||we,we,e.namespaceURI,!a&&n?[n]:r?null:e.firstChild?Se.call(e.childNodes):null,i,!a&&n?n:r?r.__e:e.firstChild,a,s),At(i,t,s),t.props.children=null}function Fe(t){function e(n){var a,r;return this.getChildContext||(a=new Set,(r={})[e.__c]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){a=null},this.shouldComponentUpdate=function(i){this.props.value!=i.value&&a.forEach(function(s){s.__e=!0,He(s)})},this.sub=function(i){a.add(i);var s=i.componentWillUnmount;i.componentWillUnmount=function(){a&&a.delete(i),s&&s.call(i)}}),n.children}return e.__c="__cC"+xt++,e.__=t,e.Provider=e.__l=(e.Consumer=function(n,a){return n.children(a)}).contextType=e,e}Se=Ce.slice,x={__e:function(t,e,n,a){for(var r,i,s;e=e.__;)if((r=e.__c)&&!r.__)try{if((i=r.constructor)&&i.getDerivedStateFromError!=null&&(r.setState(i.getDerivedStateFromError(t)),s=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(t,a||{}),s=r.__d),s)return r.__E=r}catch(c){t=c}throw t}},_t=0,jn=function(t){return t!=null&&t.constructor===void 0},Q.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),He(this))},Q.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),He(this))},Q.prototype.render=N,ne=[],ht=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,bt=function(t,e){return t.__v.__b-e.__v.__b},Ae.__r=0,ze=Math.random().toString(8),ye="__d"+ze,ge="__a"+ze,vt=/(PointerCapture)$|Capture$/i,De=0,Ue=mt(!1),Oe=mt(!0),xt=0;var ue,M,We,Et,_e=0,Lt=[],U=x,Rt=U.__b,Pt=U.__r,Tt=U.diffed,Nt=U.__c,Mt=U.unmount,Bt=U.__;function Re(t,e){U.__h&&U.__h(M,t,_e||e),_e=0;var n=M.__H||(M.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function A(t){return _e=1,zt(Ot,t)}function zt(t,e,n){var a=Re(ue++,2);if(a.t=t,!a.__c&&(a.__=[n?n(e):Ot(void 0,e),function(c){var p=a.__N?a.__N[0]:a.__[0],u=a.t(p,c);p!==u&&(a.__N=[u,a.__[1]],a.__c.setState({}))}],a.__c=M,!M.__f)){var r=function(c,p,u){if(!a.__c.__H)return!0;var g=!1,h=a.__c.props!==c;if(a.__c.__H.__.some(function(d){if(d.__N){g=!0;var f=d.__[0];d.__=d.__N,d.__N=void 0,f!==d.__[0]&&(h=!0)}}),i){var l=i.call(this,c,p,u);return g?l||h:l}return!g||h};M.__f=!0;var i=M.shouldComponentUpdate,s=M.componentWillUpdate;M.componentWillUpdate=function(c,p,u){if(this.__e){var g=i;i=void 0,r(c,p,u),i=g}s&&s.call(this,c,p,u)},M.shouldComponentUpdate=r}return a.__N||a.__}function $(t,e){var n=Re(ue++,3);!U.__s&&Ut(n.__H,e)&&(n.__=t,n.u=e,M.__H.__h.push(n))}function B(t){return _e=5,ae(function(){return{current:t}},[])}function ae(t,e){var n=Re(ue++,7);return Ut(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function T(t,e){return _e=8,ae(function(){return t},e)}function Ge(t){var e=M.context[t.__c],n=Re(ue++,9);return n.c=t,e?(n.__==null&&(n.__=!0,e.sub(M)),e.props.value):t.__}function Qn(){for(var t;t=Lt.shift();){var e=t.__H;if(t.__P&&e)try{e.__h.some(Ee),e.__h.some(Je),e.__h=[]}catch(n){e.__h=[],U.__e(n,t.__v)}}}U.__b=function(t){M=null,Rt&&Rt(t)},U.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),Bt&&Bt(t,e)},U.__r=function(t){Pt&&Pt(t),ue=0;var e=(M=t.__c).__H;e&&(We===M?(e.__h=[],M.__h=[],e.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.some(Ee),e.__h.some(Je),e.__h=[],ue=0)),We=M},U.diffed=function(t){Tt&&Tt(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Lt.push(e)!==1&&Et===U.requestAnimationFrame||((Et=U.requestAnimationFrame)||Yn)(Qn)),e.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),We=M=null},U.__c=function(t,e){e.some(function(n){try{n.__h.some(Ee),n.__h=n.__h.filter(function(a){return!a.__||Je(a)})}catch(a){e.some(function(r){r.__h&&(r.__h=[])}),e=[],U.__e(a,n.__v)}}),Nt&&Nt(t,e)},U.unmount=function(t){Mt&&Mt(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.some(function(a){try{Ee(a)}catch(r){e=r}}),n.__H=void 0,e&&U.__e(e,n.__v))};var It=typeof requestAnimationFrame=="function";function Yn(t){var e,n=function(){clearTimeout(a),It&&cancelAnimationFrame(e),setTimeout(t)},a=setTimeout(n,35);It&&(e=requestAnimationFrame(n))}function Ee(t){var e=M,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),M=e}function Je(t){var e=M;t.__c=t.__(),M=e}function Ut(t,e){return!t||t.length!==e.length||e.some(function(n,a){return n!==t[a]})}function Ot(t,e){return typeof e=="function"?e(t):e}function Kt(t,e){for(var n in e)t[n]=e[n];return t}function Ht(t,e){for(var n in t)if(n!=="__source"&&!(n in e))return!0;for(var a in e)if(a!=="__source"&&t[a]!==e[a])return!0;return!1}function Dt(t,e){this.props=t,this.context=e}(Dt.prototype=new Q).isPureReactComponent=!0,Dt.prototype.shouldComponentUpdate=function(t,e){return Ht(this.props,t)||Ht(this.state,e)};var qt=x.__b;x.__b=function(t){t.type&&t.type.__f&&t.ref&&(t.props.ref=t.ref,t.ref=null),qt&&qt(t)};var Xn=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function Te(t){function e(n){var a=Kt({},n);return delete a.ref,t(a,n.ref||null)}return e.$$typeof=Xn,e.render=t,e.prototype.isReactComponent=e.__f=!0,e.displayName="ForwardRef("+(t.displayName||t.name)+")",e}var ea=x.__e;x.__e=function(t,e,n,a){if(t.then){for(var r,i=e;i=i.__;)if((r=i.__c)&&r.__c)return e.__e==null&&(e.__e=n.__e,e.__k=n.__k||[]),r.__c(t,e)}ea(t,e,n,a)};var jt=x.unmount;function Qt(t,e,n){return t&&(t.__c&&t.__c.__H&&(t.__c.__H.__.forEach(function(a){typeof a.__c=="function"&&a.__c()}),t.__c.__H=null),(t=Kt({},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(a){return Qt(a,e,n)})),t}function Yt(t,e,n){return t&&n&&(t.__v=null,t.__k=t.__k&&t.__k.map(function(a){return Yt(a,e,n)}),t.__c&&t.__c.__P===e&&(t.__e&&n.appendChild(t.__e),t.__c.__e=!0,t.__c.__P=n)),t}function Ke(){this.__u=0,this.o=null,this.__b=null}function Zt(t){var e=t.__&&t.__.__c;return e&&e.__a&&e.__a(t)}function Pe(){this.i=null,this.l=null}x.unmount=function(t){var e=t.__c;e&&(e.__z=!0),e&&e.__R&&e.__R(),e&&32&t.__u&&(t.type=null),jt&&jt(t)},(Ke.prototype=new Q).__c=function(t,e){var n=e.__c,a=this;a.o==null&&(a.o=[]),a.o.push(n);var r=Zt(a.__v),i=!1,s=function(){i||a.__z||(i=!0,n.__R=null,r?r(p):p())};n.__R=s;var c=n.__P;n.__P=null;var p=function(){if(!--a.__u){if(a.state.__a){var u=a.state.__a;a.__v.__k[0]=Yt(u,u.__c.__P,u.__c.__O)}var g;for(a.setState({__a:a.__b=null});g=a.o.pop();)g.__P=c,g.forceUpdate()}};a.__u++||32&e.__u||a.setState({__a:a.__b=a.__v.__k[0]}),t.then(s,s)},Ke.prototype.componentWillUnmount=function(){this.o=[]},Ke.prototype.render=function(t,e){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),a=this.__v.__k[0].__c;this.__v.__k[0]=Qt(this.__b,n,a.__O=a.__P)}this.__b=null}var r=e.__a&&Y(N,null,t.fallback);return r&&(r.__u&=-33),[Y(N,null,e.__a?null:t.children),r]};var $t=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]}};(Pe.prototype=new Q).__a=function(t){var e=this,n=Zt(e.__v),a=e.l.get(t);return a[0]++,function(r){var i=function(){e.props.revealOrder?(a.push(r),$t(e,t,a)):r()};n?n(i):i()}},Pe.prototype.render=function(t){this.i=null,this.l=new Map;var e=me(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},Pe.prototype.componentDidUpdate=Pe.prototype.componentDidMount=function(){var t=this;this.l.forEach(function(e,n){$t(t,n,e)})};var ta=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,na=/^(?: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]/,aa=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,ra=/[A-Z0-9]/g,ia=typeof document<"u",oa=function(t){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(t)};function Xt(t,e,n){return e.__k==null&&(e.textContent=""),Ve(t,e),typeof n=="function"&&n(),t?t.__c:null}Q.prototype.isReactComponent=!0,["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(t){Object.defineProperty(Q.prototype,t,{configurable:!0,get:function(){return this["UNSAFE_"+t]},set:function(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})});var Vt=x.event;x.event=function(t){return Vt&&(t=Vt(t)),t.persist=function(){},t.isPropagationStopped=function(){return this.cancelBubble},t.isDefaultPrevented=function(){return this.defaultPrevented},t.nativeEvent=t};var en,sa={configurable:!0,get:function(){return this.class}},Wt=x.vnode;x.vnode=function(t){typeof t.type=="string"&&(function(e){var n=e.props,a=e.type,r={},i=a.indexOf("-")==-1;for(var s in n){var c=n[s];if(!(s==="value"&&"defaultValue"in n&&c==null||ia&&s==="children"&&a==="noscript"||s==="class"||s==="className")){var p=s.toLowerCase();s==="defaultValue"&&"value"in n&&n.value==null?s="value":s==="download"&&c===!0?c="":p==="translate"&&c==="no"?c=!1:p[0]==="o"&&p[1]==="n"?p==="ondoubleclick"?s="ondblclick":p!=="onchange"||a!=="input"&&a!=="textarea"||oa(n.type)?p==="onfocus"?s="onfocusin":p==="onblur"?s="onfocusout":aa.test(s)&&(s=p):p=s="oninput":i&&na.test(s)?s=s.replace(ra,"-$&").toLowerCase():c===null&&(c=void 0),p==="oninput"&&r[s=p]&&(s="oninputCapture"),r[s]=c}}a=="select"&&(r.multiple&&Array.isArray(r.value)&&(r.value=me(n.children).forEach(function(u){u.props.selected=r.value.indexOf(u.props.value)!=-1})),r.defaultValue!=null&&(r.value=me(n.children).forEach(function(u){u.props.selected=r.multiple?r.defaultValue.indexOf(u.props.value)!=-1:r.defaultValue==u.props.value}))),n.class&&!n.className?(r.class=n.class,Object.defineProperty(r,"className",sa)):n.className&&(r.class=r.className=n.className),e.props=r})(t),t.$$typeof=ta,Wt&&Wt(t)};var Jt=x.__r;x.__r=function(t){Jt&&Jt(t),en=t.__c};var Gt=x.diffed;x.diffed=function(t){Gt&&Gt(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),en=null};function tn(t){return!!t.__k&&(Ve(null,t),!0)}var I=class extends Error{constructor(n,a,r){super(n);G(this,"status");G(this,"code");this.name="AginiesError",this.status=a,this.code=r}},la=t=>t.replace(/\/+$/,""),Ne=class{constructor(e){G(this,"baseUrl");G(this,"token");G(this,"hosted");G(this,"locale");G(this,"fetchImpl");G(this,"state",{status:"idle"});G(this,"listeners",new Set);G(this,"activation",null);G(this,"session",null);if(!e?.baseUrl)throw new I("baseUrl is required",0,"MISSING_BASE_URL");if(!e?.token&&!e?.hosted)throw new I("token is required",0,"MISSING_TOKEN");this.baseUrl=la(e.baseUrl),this.token=e.token??null,this.hosted=e.hosted===!0,this.locale=e.locale??ca(),this.fetchImpl=e.fetch??((...n)=>fetch(...n))}getState(){return this.state}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}setState(e){this.state=e;for(let n of this.listeners)n(e)}activate(){return this.activation?this.activation:(this.setState({status:"activating"}),this.activation=(async()=>{try{let e=await this.fetchImpl(`${this.baseUrl}/api/ui/activate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(this.hosted?{hosted:!0}:{token:this.token})});if(!e.ok){let a=await he(e),r=a&&a.error||`HTTP ${e.status}`;return this.setState({status:"rejected",reason:r}),this.state}let n=await e.json();return!n.activated||!n.config?(this.setState({status:"rejected",reason:"Activation refused"}),this.state):(this.session=n.session??null,this.setState({status:"active",config:n.config}),this.state)}catch(e){return this.setState({status:"rejected",reason:e instanceof Error?e.message:"Activation failed"}),this.state}})(),this.activation)}assertActive(){if(this.state.status!=="active")throw new I("Client is not activated",0,"NOT_ACTIVATED")}getSession(){return this.session}hasModule(e){if(this.state.status!=="active")return!1;let n=this.state.config.modules??[];return n.length===0||n.includes(e)}async renewSession(){return this.activation=null,(await this.activate()).status==="active"&&this.session!==null}withSession(e){if(!this.session)return e;let n=new Headers(e.headers??{});return n.has("Authorization")||n.set("Authorization",`Bearer ${this.session.token}`),{...e,headers:n}}async request(e,n={}){let a=`${this.baseUrl}${e.startsWith("/")?e:`/${e}`}`,r=()=>this.fetchImpl(a,this.withSession({credentials:"include",...n})),i=await r();return this.session&&(i.status===401||i.status===403)&&this.session.expiresAt*1e3<=Date.now()+5e3&&await this.renewSession()&&(i=await r()),i}fetchRaw(e,n={}){return this.assertActive(),this.request(e,n)}async transcribe(e,n,a="turn.webm",r){this.assertActive();let i=new FormData;i.append("file",n,a),r&&i.append("language",r);let s=await this.request(`/api/chat/${encodeURIComponent(e)}/voice/transcribe`,{method:"POST",body:i});if(!s.ok)throw await an(s);return await s.json()}async speak(e,n){this.assertActive();let a=await this.request(`/api/chat/${encodeURIComponent(e)}/voice/speak`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:n})});if(!a.ok)throw await an(a);return a.blob()}async getChat(e){this.assertActive();let n=await this.request(`/api/chat/${encodeURIComponent(e)}`),a=await he(n);if(n.status===401&&a&&typeof a.authRequired=="string")return a;if(!n.ok)throw new I(a?.error||`HTTP ${n.status}`,n.status);return a}async*sendMessage(e,n,a){this.assertActive();let r=await this.request(`/api/chat/${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n),signal:a});if(!r.ok){let s=await he(r);throw r.status===401&&s&&typeof s.authRequired=="string"?new I("Authentication required",401,"AUTH_REQUIRED"):new I(s?.error||`HTTP ${r.status}`,r.status)}if(!(r.headers.get("content-type")??"").includes("text/event-stream")){yield{type:"final",data:await he(r)},yield{type:"done"};return}yield*ua(r.body)}};async function*ua(t){let e=t.getReader(),n=new TextDecoder,a="";try{for(;;){let{done:i,value:s}=await e.read();if(i)break;a+=n.decode(s,{stream:!0});let c=a.indexOf(`
|
|
2
2
|
|
|
3
|
-
`);for(;c!==-1;){let
|
|
3
|
+
`);for(;c!==-1;){let p=a.slice(0,c);a=a.slice(c+2);let u=nn(p);u&&(yield u),c=a.indexOf(`
|
|
4
4
|
|
|
5
5
|
`)}}let r=nn(a);r&&(yield r)}finally{e.releaseLock()}yield{type:"done"}}function nn(t){let e=t.split(`
|
|
6
|
-
`).find(r=>r.startsWith("data:"));if(!e)return null;let n=e.slice(5).trim();if(!n||n==="[DONE]")return null;let a;try{a=JSON.parse(n)}catch{return{type:"chunk",text:n}}return a.event==="error"?{type:"error",message:a.error||"Stream error"}:a.event==="final"?{type:"final",data:a.data}:typeof a.chunk=="string"?{type:"chunk",blockId:a.blockId,text:a.chunk}:null}async function an(t){let e=await be(t);return t.status===401&&e&&typeof e.authRequired=="string"?new I("Authentication required",401,"AUTH_REQUIRED"):t.status===503?new I("Voice is not available",503,"VOICE_UNAVAILABLE"):new I(e?.error||`HTTP ${t.status}`,t.status)}async function be(t){try{return await t.json()}catch{return null}}function ca(){return typeof document<"u"&&(document.documentElement.lang?.toLowerCase()??"").startsWith("tr")||typeof navigator<"u"&&navigator.language?.toLowerCase().startsWith("tr")?"tr":"en"}var rn=(t,e,n)=>`/api/resume/${encodeURIComponent(t)}/${encodeURIComponent(e)}${n?`/${encodeURIComponent(n)}`:""}`;async function on(t){let e=null;try{e=await t.json()}catch{}if(!t.ok){let n=e?.error;throw new I(n||`HTTP ${t.status}`,t.status,t.status===404?"NOT_FOUND":t.status===403?"FORBIDDEN":void 0)}return e}function sn(t,e,n){return t.fetchRaw(rn(e,n)).then(a=>on(a))}function ln(t,e,n,a,r){return t.fetchRaw(rn(e,n,a),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r?{input:{submission:r}}:{})}).then(i=>on(i))}function Me(t){let e=t?.response?.data?.inputFormat;return Array.isArray(e)?e.map((n,a)=>{if(!n||typeof n!="object")return null;let r=n,i=typeof r.name=="string"?r.name.trim():"";if(!i)return null;let l=c=>typeof c=="string"&&c.trim()?c.trim():void 0;return{id:l(r.id)??`field_${a}`,name:i,label:l(r.label)??i,type:l(r.type)??"string",description:l(r.description),placeholder:l(r.placeholder),value:r.value,required:r.required===!0,options:Array.isArray(r.options)?r.options:void 0,rows:typeof r.rows=="number"?r.rows:void 0}}).filter(n=>n!==null):[]}function un(t){let e=t?.response?.data;if(!e||typeof e!="object")return{};let{inputFormat:n,resumeLinks:a,...r}=e;return r}function da(t,e){if(e==null)return"";switch(t.type){case"boolean":return typeof e=="boolean"?e?"true":"false":typeof e=="string"&&["true","false"].includes(e.trim().toLowerCase())?e.trim().toLowerCase():"";case"number":return typeof e=="number"?Number.isFinite(e)?String(e):"":String(e);case"array":case"object":case"files":if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return""}default:return typeof e=="string"?e:JSON.stringify(e)}}function pa(t,e){let n=e.trim();switch(t.type){case"boolean":return{value:n==="true"};case"number":{let a=Number(n);return Number.isFinite(a)?{value:a}:{error:"number"}}case"array":case"object":case"files":try{return{value:JSON.parse(n)}}catch{return{error:"json"}}default:return{value:e}}}function Qe(t){return Object.fromEntries(t.map(e=>[e.name,da(e,e.value)]))}function cn(t,e){let n={},a={};for(let r of t){let i=e[r.name]??"";if(!(r.type==="boolean"?i==="true"||i==="false":i.trim()!=="")){r.required&&(a[r.name]="required");continue}let{value:c,error:d}=pa(r,i);d?a[r.name]=d:c!==void 0&&(n[r.name]=c)}return{submission:n,errors:a}}var ga=0;function o(t,e,n,a,r,i){e||(e={});var l,c,d=e;if("ref"in d)for(c in d={},e)c=="ref"?l=e[c]:d[c]=e[c];var u={type:t,props:d,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ga,__i:-1,__u:0,__source:r,__self:i};if(typeof t=="function"&&(l=t.defaultProps))for(c in l)d[c]===void 0&&(d[c]=l[c]);return k.vnode&&k.vnode(u),u}function H(...t){return t.filter(Boolean).join(" ")}var D=Te(function({variant:e="outline",size:n="md",className:a,type:r="button",...i},l){return o("button",{ref:l,type:r,className:H("agi-btn",`agi-btn--${e}`,`agi-btn--${n}`,a),...i})});function Be({tone:t="default",className:e,...n}){return o("span",{className:H("agi-tag",t!=="default"&&`agi-tag--${t}`,e),...n})}function dn({level:t=1,className:e,...n}){return o("div",{className:H("agi-panel",t===2&&"agi-panel--2",e),...n})}function pn({className:t,quiet:e,...n}){return o("p",{className:H("agi-eyebrow",e&&"agi-eyebrow--quiet",t),...n})}function ce({label:t,hint:e,error:n,className:a,children:r,...i}){return o("label",{className:H("agi-field",a),...i,children:[o("span",{className:"agi-field__label",children:t}),r,n?o("span",{className:"agi-field__error",children:n}):e&&o("span",{className:"agi-field__hint",children:e})]})}var re=Te(function({className:e,...n},a){return o("input",{ref:a,className:H("agi-input",e),...n})}),Ye=Te(function({className:e,...n},a){return o("textarea",{ref:a,className:H("agi-input","agi-textarea",e),...n})});function ie({className:t,label:e}){return o("output",{className:H("agi-spinner",t),"aria-label":e,children:[o("span",{}),o("span",{}),o("span",{})]})}var fa={chat:{open:{tr:"Sohbeti a\xE7",en:"Open chat"},close:{tr:"Kapat",en:"Close"},placeholder:{tr:"Mesaj\u0131n\u0131z\u0131 yaz\u0131n\u2026",en:"Type your message\u2026"},send:{tr:"G\xF6nder",en:"Send"},stop:{tr:"Durdur",en:"Stop"},attach:{tr:"Dosya ekle",en:"Attach file"},attachments:{tr:"Ekler",en:"Attachments"},removeFile:{tr:"Dosyay\u0131 kald\u0131r",en:"Remove file"},tooManyFiles:{tr:"En fazla 5 dosya ekleyebilirsiniz.",en:"You can attach up to 5 files."},fileTooLarge:{tr:"Dosyalar 10 MB'tan k\xFC\xE7\xFCk olmal\u0131.",en:"Files must be smaller than 10 MB."},welcome:{tr:"Merhaba! Size nas\u0131l yard\u0131mc\u0131 olabilirim?",en:"Hi there! How can I help you today?"},thinking:{tr:"Yan\u0131t haz\u0131rlan\u0131yor",en:"Working on it"},stopped:{tr:"Yan\u0131t durduruldu.",en:"Response stopped."},error:{tr:"Bir sorun olu\u015Ftu. L\xFCtfen tekrar deneyin.",en:"Something went wrong. Please try again."},unavailable:{tr:"Bu sohbet \u015Fu anda kullan\u0131lam\u0131yor.",en:"This chat is currently unavailable."},poweredBy:{tr:"Aginies ile",en:"Powered by Aginies"},you:{tr:"Siz",en:"You"},assistant:{tr:"Ajan",en:"Agent"}},auth:{passwordTitle:{tr:"Bu sohbet parola korumal\u0131",en:"This chat is password protected"},passwordHint:{tr:"Devam etmek i\xE7in parolay\u0131 girin.",en:"Enter the password to continue."},password:{tr:"Parola",en:"Password"},emailTitle:{tr:"E-posta ile do\u011Frulama",en:"Verify with your e-mail"},emailHint:{tr:"\u0130\u015F e-postan\u0131z\u0131 girin; size bir kod g\xF6nderece\u011Fiz.",en:"Enter your work e-mail; we will send you a code."},email:{tr:"E-posta",en:"E-mail"},code:{tr:"Do\u011Frulama kodu",en:"Verification code"},codeHint:{tr:"E-postan\u0131za gelen 6 haneli kodu girin.",en:"Enter the 6-digit code from your e-mail."},continue:{tr:"Devam et",en:"Continue"},sendCode:{tr:"Kod g\xF6nder",en:"Send code"},verify:{tr:"Do\u011Frula",en:"Verify"},back:{tr:"Geri",en:"Back"},invalidPassword:{tr:"Parola yanl\u0131\u015F.",en:"Wrong password."},invalidEmail:{tr:"Bu e-posta adresi yetkili de\u011Fil.",en:"This e-mail address is not allowed."},invalidCode:{tr:"Kod ge\xE7ersiz veya s\xFCresi dolmu\u015F.",en:"The code is invalid or has expired."},codeSent:{tr:"Kod g\xF6nderildi.",en:"Code sent."},codeError:{tr:"Kod g\xF6nderilemedi. L\xFCtfen tekrar deneyin.",en:"The code could not be sent. Please try again."},resend:{tr:"Kodu yeniden g\xF6nder",en:"Resend code"},ssoTitle:{tr:"Kurumsal giri\u015F gerekli",en:"Sign in with your organisation"},ssoHint:{tr:"Bu sohbet kurumsal kimlikle a\xE7\u0131l\u0131r.",en:"This chat opens with your organisation account."},ssoButton:{tr:"Kurumsal giri\u015F",en:"Sign in"}},voice:{talk:{tr:"Konu\u015Fmak i\xE7in dokunun",en:"Tap to talk"},stopTalking:{tr:"Bitirmek i\xE7in dokunun",en:"Tap when done"},dictate:{tr:"Sesle yaz",en:"Dictate"},handsFree:{tr:"Sesli sohbet",en:"Voice conversation"},exit:{tr:"Sesli sohbetten \xE7\u0131k",en:"Leave voice conversation"},listening:{tr:"Dinliyor",en:"Listening"},transcribing:{tr:"Yaz\u0131ya d\xF6k\xFCl\xFCyor",en:"Transcribing"},thinking:{tr:"Yan\u0131t haz\u0131rlan\u0131yor",en:"Working on it"},speaking:{tr:"Konu\u015Fuyor",en:"Speaking"},idle:{tr:"Haz\u0131r",en:"Ready"},interrupt:{tr:"S\xF6z\xFCn\xFC kesmek i\xE7in dokunun",en:"Tap to interrupt"},micDenied:{tr:"Mikrofon izni verilmedi. Taray\u0131c\u0131 ayarlar\u0131ndan izin verin.",en:"Microphone access was denied. Allow it in your browser settings."},unsupported:{tr:"Bu taray\u0131c\u0131 ses kayd\u0131n\u0131 desteklemiyor.",en:"This browser cannot record audio."},unavailable:{tr:"Ses \xF6zelli\u011Fi bu sohbet i\xE7in a\xE7\u0131k de\u011Fil.",en:"Voice is not enabled for this chat."},error:{tr:"Ses i\u015Flenemedi. L\xFCtfen tekrar deneyin.",en:"Voice could not be processed. Please try again."}},run:{submit:{tr:"\xC7al\u0131\u015Ft\u0131r",en:"Run"},cancel:{tr:"\u0130ptal",en:"Cancel"},running:{tr:"\xC7al\u0131\u015F\u0131yor",en:"Running"},done:{tr:"Tamamland\u0131",en:"Completed"},error:{tr:"Hata",en:"Error"},failed:{tr:"\xC7al\u0131\u015Ft\u0131rma ba\u015Far\u0131s\u0131z oldu.",en:"The run failed."},unauthorized:{tr:"API anahtar\u0131 reddedildi.",en:"The API key was rejected."},steps:{tr:"Ad\u0131mlar",en:"Steps"},execution:{tr:"\xE7al\u0131\u015Ft\u0131rma",en:"execution"}},approval:{eyebrow:{tr:"\u0130nsan onay\u0131",en:"Human approval"},title:{tr:"Onay bekleyen ad\u0131m",en:"A step is waiting for approval"},execution:{tr:"\xE7al\u0131\u015Ft\u0131rma",en:"execution"},pausedAt:{tr:"duraklat\u0131ld\u0131",en:"paused"},points:{tr:"Onay noktalar\u0131",en:"Approval points"},point:{tr:"Nokta",en:"Point"},output:{tr:"Ajan\u0131n \xF6nerisi",en:"What the agent proposes"},queuePosition:{tr:"S\u0131ra",en:"Queue position"},submit:{tr:"Onayla ve devam et",en:"Approve and continue"},submitting:{tr:"G\xF6nderiliyor",en:"Submitting"},refresh:{tr:"Yenile",en:"Refresh"},required:{tr:"Bu alan zorunlu.",en:"This field is required."},notANumber:{tr:"Say\u0131 girin.",en:"Enter a number."},notJson:{tr:"Ge\xE7erli JSON girin.",en:"Enter valid JSON."},notFound:{tr:"Bu onay bulunamad\u0131; s\xFCresi dolmu\u015F veya tamamlanm\u0131\u015F olabilir.",en:"This approval could not be found; it may have expired or been completed."},loadError:{tr:"Onay y\xFCklenemedi.",en:"The approval could not be loaded."},resumeError:{tr:"Devam ettirilemedi.",en:"The run could not be resumed."},resumedMessage:{tr:"Ajan kald\u0131\u011F\u0131 yerden devam ediyor.",en:"The agent is continuing from where it paused."},queuedMessage:{tr:"Onay s\u0131raya al\u0131nd\u0131; \xF6nceki devam i\u015Flemleri bitince \xE7al\u0131\u015Facak.",en:"The approval is queued; it runs after the earlier resumes finish."},paused:{tr:"Onay bekliyor",en:"Awaiting approval"},queued:{tr:"S\u0131rada",en:"Queued"},resuming:{tr:"Devam ediyor",en:"Resuming"},resumed:{tr:"Devam etti",en:"Resumed"},failed:{tr:"Ba\u015Far\u0131s\u0131z",en:"Failed"}},common:{loading:{tr:"Y\xFCkleniyor",en:"Loading"},retry:{tr:"Tekrar dene",en:"Retry"},notActivated:{tr:"Aginies UI paketi etkinle\u015Ftirilmedi.",en:"The Aginies UI package is not activated."}}};function gn(t){return function(n,a){let r=fa[n][a];return r[t]??r.en}}var Le=null;function Ze(t){return Le=new Ne(t),Le.activate(),Le}var fn=Se(null);function he(t){let{client:e}=j(),n=e.hasModule(t);return q(()=>{!n&&typeof console<"u"&&console.warn(`[aginies] the "${t}" module is not enabled for this activation key`)},[n,t]),n}function Ie({client:t,locale:e,fallback:n=null,children:a}){let r=t??Le,[i,l]=F(r?.getState()??{status:"rejected",reason:"init() was not called"});q(()=>{if(!r)return;l(r.getState());let d=r.subscribe(l);return r.activate(),d},[r]),q(()=>{i.status==="rejected"&&typeof console<"u"&&console.warn(`[aginies] UI kit not activated: ${i.reason}`)},[i]);let c=ae(()=>{if(!r)return null;let d=e??r.locale;return{client:r,state:i,locale:d,t:gn(d)}},[r,i,e]);return c?i.status==="idle"||i.status==="activating"?o(T,{children:n}):i.status==="rejected"?null:o(fn.Provider,{value:c,children:a}):null}function j(){let t=Ge(fn);if(!t)throw new Error("[aginies] useAginies must be used inside <AginiesProvider> after init()");return t}function _n(t,e,n){let{client:a,t:r}=j(),[i,l]=F("loading"),[c,d]=F(null),[u,p]=F(n??null),[b,s]=F({}),[g,f]=F({}),[C,w]=F(null),[y,m]=F(null),v=M(n??null),h=ae(()=>c?c.pausePoints.find(_=>_.contextId===u)??c.pausePoints.find(_=>_.resumeStatus==="paused")??c.pausePoints[0]??null:null,[c,u]),A=ae(()=>Me(h),[h]),L=B(async()=>{l("loading"),w(null);try{let _=await sn(a,t,e);d(_);let R=n??v.current,E=_.pausePoints.find(W=>W.contextId===R)??_.pausePoints.find(W=>W.resumeStatus==="paused")??_.pausePoints[0];E&&(v.current=E.contextId,p(E.contextId),s(Qe(Me(E)))),f({}),l("ready")}catch(_){_ instanceof I&&_.code==="NOT_FOUND"?l("not-found"):(w(_ instanceof Error?_.message:r("approval","loadError")),l("error"))}},[a,t,e,n,r]);q(()=>{L()},[L]);let V=B(_=>{v.current=_,p(_);let R=c?.pausePoints.find(E=>E.contextId===_);s(Qe(Me(R))),f({})},[c]),$=B((_,R)=>{s(E=>({...E,[_]:R})),f(E=>{if(!(_ in E))return E;let{[_]:W,...X}=E;return X})},[]),S=B(async()=>{if(!h||i==="submitting")return;let{submission:_,errors:R}=cn(A,b);if(Object.keys(R).length>0){f(Object.fromEntries(Object.entries(R).map(([E,W])=>[E,W==="required"?r("approval","required"):W==="number"?r("approval","notANumber"):r("approval","notJson")])));return}l("submitting"),w(null);try{let E=await ln(a,t,e,h.contextId,A.length>0?_:null);m(E),l(E.status==="queued"?"queued":"resumed")}catch(E){w(E instanceof Error?E.message:r("approval","resumeError")),l("ready")}},[a,t,e,h,A,b,i,r]);return{status:i,execution:c,pausePoint:h,fields:A,values:b,errors:g,error:C,outcome:y,select:V,setValue:$,submit:S,reload:L}}var mn={paused:"warn",queued:"signal",resuming:"signal",resumed:"ok",failed:"bad"};function Xe({workflowId:t,executionId:e,contextId:n,title:a,description:r,submitLabel:i,onResumed:l,hideOutput:c=!1,className:d}){let{t:u,locale:p}=j(),b=he("approval"),s=_n(t,e,n),g=M(l);if(g.current=l,q(()=>{(s.status==="resumed"||s.status==="queued")&&s.outcome&&g.current?.(s.outcome)},[s.status,s.outcome]),!b)return null;let f=s.pausePoint,C=c?{}:un(f),w=Object.entries(C),y=f?.resumeStatus==="paused"&&s.status==="ready",m=h=>h?new Date(h).toLocaleString(p==="tr"?"tr-TR":"en-GB"):"",v=h=>{h.preventDefault(),s.submit()};return o(dn,{className:H("agi-approval",d),"aria-busy":s.status==="loading",children:[o("header",{className:"agi-approval__head",children:[o(pn,{children:u("approval","eyebrow")}),o("h3",{className:"agi-approval__title",children:a??u("approval","title")}),r&&o("p",{className:"agi-approval__desc",children:r}),s.execution&&o("p",{className:"agi-approval__meta",children:[u("approval","execution")," ",o("span",{className:"agi-approval__meta-value",children:s.execution.executionId.slice(0,8)}),s.execution.pausedAt&&o(T,{children:[" \xB7 ",u("approval","pausedAt")," ",m(s.execution.pausedAt)]})]})]}),s.status==="loading"&&o("div",{className:"agi-approval__state",children:[o(ie,{label:u("common","loading")})," ",u("common","loading")]}),s.status==="not-found"&&o("div",{className:"agi-approval__state",children:o("p",{children:u("approval","notFound")})}),s.status==="error"&&o("div",{className:"agi-approval__state",children:[o("p",{className:"agi-approval__error",children:s.error}),o(D,{variant:"outline",size:"sm",onClick:()=>{s.reload()},children:u("common","retry")})]}),s.execution&&s.execution.pausePoints.length>1&&o("nav",{className:"agi-approval__points","aria-label":u("approval","points"),children:s.execution.pausePoints.map((h,A)=>o("button",{type:"button",className:H("agi-approval__point",h.contextId===f?.contextId&&"is-selected"),onClick:()=>s.select(h.contextId),children:[o("span",{children:[u("approval","point")," ",A+1]}),o(Be,{tone:mn[h.resumeStatus]??"default",children:u("approval",h.resumeStatus)})]},h.contextId))}),f&&s.status!=="loading"&&o(T,{children:[o("div",{className:"agi-approval__status",children:[o(Be,{tone:mn[f.resumeStatus]??"default",children:u("approval",f.resumeStatus)}),typeof f.queuePosition=="number"&&f.queuePosition>0&&o("span",{className:"agi-approval__queue",children:[u("approval","queuePosition")," ",f.queuePosition]})]}),w.length>0&&o("section",{className:"agi-approval__output","aria-label":u("approval","output"),children:[o("div",{className:"agi-approval__output-label",children:u("approval","output")}),o("dl",{className:"agi-approval__kv",children:w.map(([h,A])=>o("div",{className:"agi-approval__kv-row",children:[o("dt",{children:h}),o("dd",{children:typeof A=="string"?A:JSON.stringify(A,null,2)})]},h))})]}),(s.status==="resumed"||s.status==="queued")&&s.outcome?o("output",{className:"agi-approval__done",children:[o(Be,{tone:s.status==="queued"?"signal":"ok",children:u("approval",s.status==="queued"?"queued":"resumed")}),o("p",{children:s.status==="queued"?u("approval","queuedMessage"):u("approval","resumedMessage")})]}):o("form",{className:"agi-approval__form",onSubmit:v,children:[s.fields.map(h=>o(ce,{label:h.label,hint:h.description,error:s.errors[h.name],children:ma(h,s.values[h.name]??"",A=>s.setValue(h.name,A),!y)},h.id)),s.error&&o("p",{className:"agi-approval__error",children:s.error}),o("div",{className:"agi-approval__actions",children:[o(D,{variant:"signal",type:"submit",disabled:!y,children:s.status==="submitting"?o(T,{children:[o(ie,{label:u("approval","submitting")})," ",u("approval","submitting")]}):i??u("approval","submit")}),o(D,{variant:"outline",type:"button",onClick:()=>{s.reload()},disabled:s.status==="submitting",children:u("approval","refresh")})]})]})]})]})}function ma(t,e,n,a){switch(t.type){case"boolean":return o("select",{className:"agi-input",value:e,disabled:a,onChange:r=>n(r.target.value),children:[o("option",{value:"",children:"\u2014"}),o("option",{value:"true",children:"true"}),o("option",{value:"false",children:"false"})]});case"number":return o(re,{type:"number",value:e,placeholder:t.placeholder,required:t.required,disabled:a,onChange:r=>n(r.target.value)});case"array":case"object":case"files":return o(Ye,{value:e,rows:t.rows??4,placeholder:t.placeholder??"{ }",required:t.required,disabled:a,className:"agi-approval__json",onChange:r=>n(r.target.value)});default:return Array.isArray(t.options)&&t.options.length>0?o("select",{className:"agi-input",value:e,disabled:a,onChange:r=>n(r.target.value),children:[o("option",{value:"",children:"\u2014"}),t.options.map(r=>{let i=typeof r=="object"&&r!==null?r:{value:r,label:r},l=String(i.value??"");return o("option",{value:l,children:String(i.label??l)},l)})]}):(t.rows??1)>1?o(Ye,{value:e,rows:t.rows,placeholder:t.placeholder,required:t.required,disabled:a,onChange:r=>n(r.target.value)}):o(re,{value:e,placeholder:t.placeholder,required:t.required,disabled:a,onChange:r=>n(r.target.value)})}}function at({text:t,className:e}){return o("div",{className:e,children:xn(vn(t))})}var _a=/^\s*(`{3,}|~{3,})\s*([\w+-]*)\s*$/,ba=/^(#{1,6})\s+(.*?)\s*#*\s*$/,ha=/^\s*([-*_])(?:\s*\1){2,}\s*$/,et=/^\s*>\s?(.*)$/,tt=/^\s*(?:([-*+])|(\d{1,9})[.)])\s+(.*)$/,va=/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/;function vn(t){let e=t.replace(/\r\n?/g,`
|
|
6
|
+
`).find(r=>r.startsWith("data:"));if(!e)return null;let n=e.slice(5).trim();if(!n||n==="[DONE]")return null;let a;try{a=JSON.parse(n)}catch{return{type:"chunk",text:n}}return a.event==="error"?{type:"error",message:a.error||"Stream error"}:a.event==="final"?{type:"final",data:a.data}:typeof a.chunk=="string"?{type:"chunk",blockId:a.blockId,text:a.chunk}:null}async function an(t){let e=await he(t);return t.status===401&&e&&typeof e.authRequired=="string"?new I("Authentication required",401,"AUTH_REQUIRED"):t.status===503?new I("Voice is not available",503,"VOICE_UNAVAILABLE"):new I(e?.error||`HTTP ${t.status}`,t.status)}async function he(t){try{return await t.json()}catch{return null}}function ca(){return typeof document<"u"&&(document.documentElement.lang?.toLowerCase()??"").startsWith("tr")||typeof navigator<"u"&&navigator.language?.toLowerCase().startsWith("tr")?"tr":"en"}var rn=(t,e,n)=>`/api/resume/${encodeURIComponent(t)}/${encodeURIComponent(e)}${n?`/${encodeURIComponent(n)}`:""}`;async function on(t){let e=null;try{e=await t.json()}catch{}if(!t.ok){let n=e?.error;throw new I(n||`HTTP ${t.status}`,t.status,t.status===404?"NOT_FOUND":t.status===403?"FORBIDDEN":void 0)}return e}function sn(t,e,n){return t.fetchRaw(rn(e,n)).then(a=>on(a))}function ln(t,e,n,a,r){return t.fetchRaw(rn(e,n,a),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r?{input:{submission:r}}:{})}).then(i=>on(i))}function Me(t){let e=t?.response?.data?.inputFormat;return Array.isArray(e)?e.map((n,a)=>{if(!n||typeof n!="object")return null;let r=n,i=typeof r.name=="string"?r.name.trim():"";if(!i)return null;let s=c=>typeof c=="string"&&c.trim()?c.trim():void 0;return{id:s(r.id)??`field_${a}`,name:i,label:s(r.label)??i,type:s(r.type)??"string",description:s(r.description),placeholder:s(r.placeholder),value:r.value,required:r.required===!0,options:Array.isArray(r.options)?r.options:void 0,rows:typeof r.rows=="number"?r.rows:void 0}}).filter(n=>n!==null):[]}function un(t){let e=t?.response?.data;if(!e||typeof e!="object")return{};let{inputFormat:n,resumeLinks:a,...r}=e;return r}function da(t,e){if(e==null)return"";switch(t.type){case"boolean":return typeof e=="boolean"?e?"true":"false":typeof e=="string"&&["true","false"].includes(e.trim().toLowerCase())?e.trim().toLowerCase():"";case"number":return typeof e=="number"?Number.isFinite(e)?String(e):"":String(e);case"array":case"object":case"files":if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return""}default:return typeof e=="string"?e:JSON.stringify(e)}}function pa(t,e){let n=e.trim();switch(t.type){case"boolean":return{value:n==="true"};case"number":{let a=Number(n);return Number.isFinite(a)?{value:a}:{error:"number"}}case"array":case"object":case"files":try{return{value:JSON.parse(n)}}catch{return{error:"json"}}default:return{value:e}}}function Qe(t){return Object.fromEntries(t.map(e=>[e.name,da(e,e.value)]))}function cn(t,e){let n={},a={};for(let r of t){let i=e[r.name]??"";if(!(r.type==="boolean"?i==="true"||i==="false":i.trim()!=="")){r.required&&(a[r.name]="required");continue}let{value:c,error:p}=pa(r,i);p?a[r.name]=p:c!==void 0&&(n[r.name]=c)}return{submission:n,errors:a}}var ga=0;function o(t,e,n,a,r,i){e||(e={});var s,c,p=e;if("ref"in p)for(c in p={},e)c=="ref"?s=e[c]:p[c]=e[c];var u={type:t,props:p,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ga,__i:-1,__u:0,__source:r,__self:i};if(typeof t=="function"&&(s=t.defaultProps))for(c in s)p[c]===void 0&&(p[c]=s[c]);return x.vnode&&x.vnode(u),u}function H(...t){return t.filter(Boolean).join(" ")}var D=Te(function({variant:e="outline",size:n="md",className:a,type:r="button",...i},s){return o("button",{ref:s,type:r,className:H("agi-btn",`agi-btn--${e}`,`agi-btn--${n}`,a),...i})});function Be({tone:t="default",className:e,...n}){return o("span",{className:H("agi-tag",t!=="default"&&`agi-tag--${t}`,e),...n})}function dn({level:t=1,className:e,...n}){return o("div",{className:H("agi-panel",t===2&&"agi-panel--2",e),...n})}function pn({className:t,quiet:e,...n}){return o("p",{className:H("agi-eyebrow",e&&"agi-eyebrow--quiet",t),...n})}function le({label:t,hint:e,error:n,className:a,children:r,...i}){return o("label",{className:H("agi-field",a),...i,children:[o("span",{className:"agi-field__label",children:t}),r,n?o("span",{className:"agi-field__error",children:n}):e&&o("span",{className:"agi-field__hint",children:e})]})}var X=Te(function({className:e,...n},a){return o("input",{ref:a,className:H("agi-input",e),...n})}),Ye=Te(function({className:e,...n},a){return o("textarea",{ref:a,className:H("agi-input","agi-textarea",e),...n})});function re({className:t,label:e}){return o("output",{className:H("agi-spinner",t),"aria-label":e,children:[o("span",{}),o("span",{}),o("span",{})]})}var fa={chat:{open:{tr:"Sohbeti a\xE7",en:"Open chat"},close:{tr:"Kapat",en:"Close"},placeholder:{tr:"Mesaj\u0131n\u0131z\u0131 yaz\u0131n\u2026",en:"Type your message\u2026"},send:{tr:"G\xF6nder",en:"Send"},stop:{tr:"Durdur",en:"Stop"},attach:{tr:"Dosya ekle",en:"Attach file"},attachments:{tr:"Ekler",en:"Attachments"},removeFile:{tr:"Dosyay\u0131 kald\u0131r",en:"Remove file"},tooManyFiles:{tr:"En fazla 5 dosya ekleyebilirsiniz.",en:"You can attach up to 5 files."},fileTooLarge:{tr:"Dosyalar 10 MB'tan k\xFC\xE7\xFCk olmal\u0131.",en:"Files must be smaller than 10 MB."},welcome:{tr:"Merhaba! Size nas\u0131l yard\u0131mc\u0131 olabilirim?",en:"Hi there! How can I help you today?"},thinking:{tr:"Yan\u0131t haz\u0131rlan\u0131yor",en:"Working on it"},stopped:{tr:"Yan\u0131t durduruldu.",en:"Response stopped."},error:{tr:"Bir sorun olu\u015Ftu. L\xFCtfen tekrar deneyin.",en:"Something went wrong. Please try again."},unavailable:{tr:"Bu sohbet \u015Fu anda kullan\u0131lam\u0131yor.",en:"This chat is currently unavailable."},poweredBy:{tr:"Aginies ile",en:"Powered by Aginies"},you:{tr:"Siz",en:"You"},assistant:{tr:"Ajan",en:"Agent"}},auth:{passwordTitle:{tr:"Bu sohbet parola korumal\u0131",en:"This chat is password protected"},passwordHint:{tr:"Devam etmek i\xE7in parolay\u0131 girin.",en:"Enter the password to continue."},password:{tr:"Parola",en:"Password"},emailTitle:{tr:"E-posta ile do\u011Frulama",en:"Verify with your e-mail"},emailHint:{tr:"\u0130\u015F e-postan\u0131z\u0131 girin; size bir kod g\xF6nderece\u011Fiz.",en:"Enter your work e-mail; we will send you a code."},email:{tr:"E-posta",en:"E-mail"},code:{tr:"Do\u011Frulama kodu",en:"Verification code"},codeHint:{tr:"E-postan\u0131za gelen 6 haneli kodu girin.",en:"Enter the 6-digit code from your e-mail."},continue:{tr:"Devam et",en:"Continue"},sendCode:{tr:"Kod g\xF6nder",en:"Send code"},verify:{tr:"Do\u011Frula",en:"Verify"},back:{tr:"Geri",en:"Back"},invalidPassword:{tr:"Parola yanl\u0131\u015F.",en:"Wrong password."},invalidEmail:{tr:"Bu e-posta adresi yetkili de\u011Fil.",en:"This e-mail address is not allowed."},invalidCode:{tr:"Kod ge\xE7ersiz veya s\xFCresi dolmu\u015F.",en:"The code is invalid or has expired."},codeSent:{tr:"Kod g\xF6nderildi.",en:"Code sent."},codeError:{tr:"Kod g\xF6nderilemedi. L\xFCtfen tekrar deneyin.",en:"The code could not be sent. Please try again."},resend:{tr:"Kodu yeniden g\xF6nder",en:"Resend code"},ssoTitle:{tr:"Kurumsal giri\u015F gerekli",en:"Sign in with your organisation"},ssoHint:{tr:"Bu sohbet kurumsal kimlikle a\xE7\u0131l\u0131r.",en:"This chat opens with your organisation account."},ssoButton:{tr:"Kurumsal giri\u015F",en:"Sign in"},ssoRetry:{tr:"Giri\u015F yapt\u0131m, yenile",en:"I have signed in, refresh"}},voice:{talk:{tr:"Konu\u015Fmak i\xE7in dokunun",en:"Tap to talk"},stopTalking:{tr:"Bitirmek i\xE7in dokunun",en:"Tap when done"},dictate:{tr:"Sesle yaz",en:"Dictate"},handsFree:{tr:"Sesli sohbet",en:"Voice conversation"},exit:{tr:"Sesli sohbetten \xE7\u0131k",en:"Leave voice conversation"},listening:{tr:"Dinliyor",en:"Listening"},transcribing:{tr:"Yaz\u0131ya d\xF6k\xFCl\xFCyor",en:"Transcribing"},thinking:{tr:"Yan\u0131t haz\u0131rlan\u0131yor",en:"Working on it"},speaking:{tr:"Konu\u015Fuyor",en:"Speaking"},idle:{tr:"Haz\u0131r",en:"Ready"},interrupt:{tr:"S\xF6z\xFCn\xFC kesmek i\xE7in dokunun",en:"Tap to interrupt"},micDenied:{tr:"Mikrofon izni verilmedi. Taray\u0131c\u0131 ayarlar\u0131ndan izin verin.",en:"Microphone access was denied. Allow it in your browser settings."},unsupported:{tr:"Bu taray\u0131c\u0131 ses kayd\u0131n\u0131 desteklemiyor.",en:"This browser cannot record audio."},unavailable:{tr:"Ses \xF6zelli\u011Fi bu sohbet i\xE7in a\xE7\u0131k de\u011Fil.",en:"Voice is not enabled for this chat."},error:{tr:"Ses i\u015Flenemedi. L\xFCtfen tekrar deneyin.",en:"Voice could not be processed. Please try again."}},run:{submit:{tr:"\xC7al\u0131\u015Ft\u0131r",en:"Run"},cancel:{tr:"\u0130ptal",en:"Cancel"},running:{tr:"\xC7al\u0131\u015F\u0131yor",en:"Running"},done:{tr:"Tamamland\u0131",en:"Completed"},error:{tr:"Hata",en:"Error"},failed:{tr:"\xC7al\u0131\u015Ft\u0131rma ba\u015Far\u0131s\u0131z oldu.",en:"The run failed."},unauthorized:{tr:"API anahtar\u0131 reddedildi.",en:"The API key was rejected."},steps:{tr:"Ad\u0131mlar",en:"Steps"},execution:{tr:"\xE7al\u0131\u015Ft\u0131rma",en:"execution"}},approval:{eyebrow:{tr:"\u0130nsan onay\u0131",en:"Human approval"},title:{tr:"Onay bekleyen ad\u0131m",en:"A step is waiting for approval"},execution:{tr:"\xE7al\u0131\u015Ft\u0131rma",en:"execution"},pausedAt:{tr:"duraklat\u0131ld\u0131",en:"paused"},points:{tr:"Onay noktalar\u0131",en:"Approval points"},point:{tr:"Nokta",en:"Point"},output:{tr:"Ajan\u0131n \xF6nerisi",en:"What the agent proposes"},queuePosition:{tr:"S\u0131ra",en:"Queue position"},submit:{tr:"Onayla ve devam et",en:"Approve and continue"},submitting:{tr:"G\xF6nderiliyor",en:"Submitting"},refresh:{tr:"Yenile",en:"Refresh"},required:{tr:"Bu alan zorunlu.",en:"This field is required."},notANumber:{tr:"Say\u0131 girin.",en:"Enter a number."},notJson:{tr:"Ge\xE7erli JSON girin.",en:"Enter valid JSON."},notFound:{tr:"Bu onay bulunamad\u0131; s\xFCresi dolmu\u015F veya tamamlanm\u0131\u015F olabilir.",en:"This approval could not be found; it may have expired or been completed."},loadError:{tr:"Onay y\xFCklenemedi.",en:"The approval could not be loaded."},resumeError:{tr:"Devam ettirilemedi.",en:"The run could not be resumed."},resumedMessage:{tr:"Ajan kald\u0131\u011F\u0131 yerden devam ediyor.",en:"The agent is continuing from where it paused."},queuedMessage:{tr:"Onay s\u0131raya al\u0131nd\u0131; \xF6nceki devam i\u015Flemleri bitince \xE7al\u0131\u015Facak.",en:"The approval is queued; it runs after the earlier resumes finish."},paused:{tr:"Onay bekliyor",en:"Awaiting approval"},queued:{tr:"S\u0131rada",en:"Queued"},resuming:{tr:"Devam ediyor",en:"Resuming"},resumed:{tr:"Devam etti",en:"Resumed"},failed:{tr:"Ba\u015Far\u0131s\u0131z",en:"Failed"}},common:{loading:{tr:"Y\xFCkleniyor",en:"Loading"},retry:{tr:"Tekrar dene",en:"Retry"},notActivated:{tr:"Aginies UI paketi etkinle\u015Ftirilmedi.",en:"The Aginies UI package is not activated."}}};function gn(t){return function(n,a){let r=fa[n][a];return r[t]??r.en}}var Ie=null;function Ze(t){return Ie=new Ne(t),Ie.activate(),Ie}var fn=Fe(null);function be(t){let{client:e}=V(),n=e.hasModule(t);return $(()=>{!n&&typeof console<"u"&&console.warn(`[aginies] the "${t}" module is not enabled for this activation key`)},[n,t]),n}function Le({client:t,locale:e,fallback:n=null,children:a}){let r=t??Ie,[i,s]=A(r?.getState()??{status:"rejected",reason:"init() was not called"});$(()=>{if(!r)return;s(r.getState());let p=r.subscribe(s);return r.activate(),p},[r]),$(()=>{i.status==="rejected"&&typeof console<"u"&&console.warn(`[aginies] UI kit not activated: ${i.reason}`)},[i]);let c=ae(()=>{if(!r)return null;let p=e??r.locale;return{client:r,state:i,locale:p,t:gn(p)}},[r,i,e]);return c?i.status==="idle"||i.status==="activating"?o(N,{children:n}):i.status==="rejected"?null:o(fn.Provider,{value:c,children:a}):null}function V(){let t=Ge(fn);if(!t)throw new Error("[aginies] useAginies must be used inside <AginiesProvider> after init()");return t}function _n(t,e,n){let{client:a,t:r}=V(),[i,s]=A("loading"),[c,p]=A(null),[u,g]=A(n??null),[h,l]=A({}),[d,f]=A({}),[w,y]=A(null),[k,m]=A(null),v=B(n??null),b=ae(()=>c?c.pausePoints.find(_=>_.contextId===u)??c.pausePoints.find(_=>_.resumeStatus==="paused")??c.pausePoints[0]??null:null,[c,u]),S=ae(()=>Me(b),[b]),L=T(async()=>{s("loading"),y(null);try{let _=await sn(a,t,e);p(_);let C=n??v.current,E=_.pausePoints.find(O=>O.contextId===C)??_.pausePoints.find(O=>O.resumeStatus==="paused")??_.pausePoints[0];E&&(v.current=E.contextId,g(E.contextId),l(Qe(Me(E)))),f({}),s("ready")}catch(_){_ instanceof I&&_.code==="NOT_FOUND"?s("not-found"):(y(_ instanceof Error?_.message:r("approval","loadError")),s("error"))}},[a,t,e,n,r]);$(()=>{L()},[L]);let W=T(_=>{v.current=_,g(_);let C=c?.pausePoints.find(E=>E.contextId===_);l(Qe(Me(C))),f({})},[c]),q=T((_,C)=>{l(E=>({...E,[_]:C})),f(E=>{if(!(_ in E))return E;let{[_]:O,...oe}=E;return oe})},[]),j=T(async()=>{if(!b||i==="submitting")return;let{submission:_,errors:C}=cn(S,h);if(Object.keys(C).length>0){f(Object.fromEntries(Object.entries(C).map(([E,O])=>[E,O==="required"?r("approval","required"):O==="number"?r("approval","notANumber"):r("approval","notJson")])));return}s("submitting"),y(null);try{let E=await ln(a,t,e,b.contextId,S.length>0?_:null);m(E),s(E.status==="queued"?"queued":"resumed")}catch(E){y(E instanceof Error?E.message:r("approval","resumeError")),s("ready")}},[a,t,e,b,S,h,i,r]);return{status:i,execution:c,pausePoint:b,fields:S,values:h,errors:d,error:w,outcome:k,select:W,setValue:q,submit:j,reload:L}}var mn={paused:"warn",queued:"signal",resuming:"signal",resumed:"ok",failed:"bad"};function Xe({workflowId:t,executionId:e,contextId:n,title:a,description:r,submitLabel:i,onResumed:s,hideOutput:c=!1,className:p}){let{t:u,locale:g}=V(),h=be("approval"),l=_n(t,e,n),d=B(s);if(d.current=s,$(()=>{(l.status==="resumed"||l.status==="queued")&&l.outcome&&d.current?.(l.outcome)},[l.status,l.outcome]),!h)return null;let f=l.pausePoint,w=c?{}:un(f),y=Object.entries(w),k=f?.resumeStatus==="paused"&&l.status==="ready",m=b=>b?new Date(b).toLocaleString(g==="tr"?"tr-TR":"en-GB"):"",v=b=>{b.preventDefault(),l.submit()};return o(dn,{className:H("agi-approval",p),"aria-busy":l.status==="loading",children:[o("header",{className:"agi-approval__head",children:[o(pn,{children:u("approval","eyebrow")}),o("h3",{className:"agi-approval__title",children:a??u("approval","title")}),r&&o("p",{className:"agi-approval__desc",children:r}),l.execution&&o("p",{className:"agi-approval__meta",children:[u("approval","execution")," ",o("span",{className:"agi-approval__meta-value",children:l.execution.executionId.slice(0,8)}),l.execution.pausedAt&&o(N,{children:[" \xB7 ",u("approval","pausedAt")," ",m(l.execution.pausedAt)]})]})]}),l.status==="loading"&&o("div",{className:"agi-approval__state",children:[o(re,{label:u("common","loading")})," ",u("common","loading")]}),l.status==="not-found"&&o("div",{className:"agi-approval__state",children:o("p",{children:u("approval","notFound")})}),l.status==="error"&&o("div",{className:"agi-approval__state",children:[o("p",{className:"agi-approval__error",children:l.error}),o(D,{variant:"outline",size:"sm",onClick:()=>{l.reload()},children:u("common","retry")})]}),l.execution&&l.execution.pausePoints.length>1&&o("nav",{className:"agi-approval__points","aria-label":u("approval","points"),children:l.execution.pausePoints.map((b,S)=>o("button",{type:"button",className:H("agi-approval__point",b.contextId===f?.contextId&&"is-selected"),onClick:()=>l.select(b.contextId),children:[o("span",{children:[u("approval","point")," ",S+1]}),o(Be,{tone:mn[b.resumeStatus]??"default",children:u("approval",b.resumeStatus)})]},b.contextId))}),f&&l.status!=="loading"&&o(N,{children:[o("div",{className:"agi-approval__status",children:[o(Be,{tone:mn[f.resumeStatus]??"default",children:u("approval",f.resumeStatus)}),typeof f.queuePosition=="number"&&f.queuePosition>0&&o("span",{className:"agi-approval__queue",children:[u("approval","queuePosition")," ",f.queuePosition]})]}),y.length>0&&o("section",{className:"agi-approval__output","aria-label":u("approval","output"),children:[o("div",{className:"agi-approval__output-label",children:u("approval","output")}),o("dl",{className:"agi-approval__kv",children:y.map(([b,S])=>o("div",{className:"agi-approval__kv-row",children:[o("dt",{children:b}),o("dd",{children:typeof S=="string"?S:JSON.stringify(S,null,2)})]},b))})]}),(l.status==="resumed"||l.status==="queued")&&l.outcome?o("output",{className:"agi-approval__done",children:[o(Be,{tone:l.status==="queued"?"signal":"ok",children:u("approval",l.status==="queued"?"queued":"resumed")}),o("p",{children:l.status==="queued"?u("approval","queuedMessage"):u("approval","resumedMessage")})]}):o("form",{className:"agi-approval__form",onSubmit:v,children:[l.fields.map(b=>o(le,{label:b.label,hint:b.description,error:l.errors[b.name],children:ma(b,l.values[b.name]??"",S=>l.setValue(b.name,S),!k)},b.id)),l.error&&o("p",{className:"agi-approval__error",children:l.error}),o("div",{className:"agi-approval__actions",children:[o(D,{variant:"signal",type:"submit",disabled:!k,children:l.status==="submitting"?o(N,{children:[o(re,{label:u("approval","submitting")})," ",u("approval","submitting")]}):i??u("approval","submit")}),o(D,{variant:"outline",type:"button",onClick:()=>{l.reload()},disabled:l.status==="submitting",children:u("approval","refresh")})]})]})]})]})}function ma(t,e,n,a){switch(t.type){case"boolean":return o("select",{className:"agi-input",value:e,disabled:a,onChange:r=>n(r.target.value),children:[o("option",{value:"",children:"\u2014"}),o("option",{value:"true",children:"true"}),o("option",{value:"false",children:"false"})]});case"number":return o(X,{type:"number",value:e,placeholder:t.placeholder,required:t.required,disabled:a,onChange:r=>n(r.target.value)});case"array":case"object":case"files":return o(Ye,{value:e,rows:t.rows??4,placeholder:t.placeholder??"{ }",required:t.required,disabled:a,className:"agi-approval__json",onChange:r=>n(r.target.value)});default:return Array.isArray(t.options)&&t.options.length>0?o("select",{className:"agi-input",value:e,disabled:a,onChange:r=>n(r.target.value),children:[o("option",{value:"",children:"\u2014"}),t.options.map(r=>{let i=typeof r=="object"&&r!==null?r:{value:r,label:r},s=String(i.value??"");return o("option",{value:s,children:String(i.label??s)},s)})]}):(t.rows??1)>1?o(Ye,{value:e,rows:t.rows,placeholder:t.placeholder,required:t.required,disabled:a,onChange:r=>n(r.target.value)}):o(X,{value:e,placeholder:t.placeholder,required:t.required,disabled:a,onChange:r=>n(r.target.value)})}}function at({text:t,className:e}){return o("div",{className:e,children:xn(vn(t))})}var _a=/^\s*(`{3,}|~{3,})\s*([\w+-]*)\s*$/,ha=/^(#{1,6})\s+(.*?)\s*#*\s*$/,ba=/^\s*([-*_])(?:\s*\1){2,}\s*$/,et=/^\s*>\s?(.*)$/,tt=/^\s*(?:([-*+])|(\d{1,9})[.)])\s+(.*)$/,va=/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/;function vn(t){let e=t.replace(/\r\n?/g,`
|
|
7
7
|
`).split(`
|
|
8
|
-
`),n=[],a=0,r=[],i=()=>{r.length>0&&(n.push({kind:"paragraph",lines:r}),r=[])};for(;a<e.length;){let
|
|
9
|
-
`)});continue}let
|
|
10
|
-
`))});continue}let u=tt.exec(l);if(u){i();let p=u[2]!==void 0,b=p?Number.parseInt(u[2],10):1,s=[];for(;a<e.length;){let g=tt.exec(e[a]);if(g&&g[2]!==void 0===p)s.push(g[3]??""),a+=1;else if(s.length>0&&e[a].trim()!==""&&/^\s{2,}/.test(e[a])&&!tt.test(e[a]))s[s.length-1]=`${s[s.length-1]} ${e[a].trim()}`,a+=1;else break}n.push({kind:"list",ordered:p,start:b,items:s});continue}if(l.includes("|")&&a+1<e.length&&va.test(e[a+1])){i();let p=nt(l),b=nt(e[a+1]).map(g=>{let f=g.startsWith(":"),C=g.endsWith(":");return f&&C?"center":C?"right":f?"left":null}),s=[];for(a+=2;a<e.length&&e[a].includes("|");)s.push(nt(e[a])),a+=1;n.push({kind:"table",header:p,align:b,rows:s});continue}r.push(l),a+=1}return i(),n}function nt(t){return t.trim().replace(/^\|/,"").replace(/\|$/,"").split(/(?<!\\)\|/).map(n=>n.replace(/\\\|/g,"|").trim())}function xn(t){return t.map((e,n)=>{switch(e.kind){case"paragraph":return o("p",{children:e.lines.map((a,r)=>o(T,{children:[r>0&&o("br",{}),Z(a)]},r))},n);case"heading":{let a=`h${Math.min(e.level+2,6)}`;return o(a,{children:Z(e.text)},n)}case"code":return o("pre",{"data-lang":e.lang||void 0,children:o("code",{children:e.code})},n);case"quote":return o("blockquote",{children:xn(e.blocks)},n);case"list":{let a=e.items.map((r,i)=>o("li",{children:Z(r)},i));return e.ordered?o("ol",{start:e.start===1?void 0:e.start,children:a},n):o("ul",{children:a},n)}case"table":return o("div",{className:"agi-md__table",children:o("table",{children:[o("thead",{children:o("tr",{children:e.header.map((a,r)=>o("th",{style:bn(e.align[r]),children:Z(a)},r))})}),o("tbody",{children:e.rows.map((a,r)=>o("tr",{children:e.header.map((i,l)=>o("td",{style:bn(e.align[l]),children:Z(a[l]??"")},l))},r))})]})},n);case"rule":return o("hr",{},n)}})}function bn(t){return t?{textAlign:t}:void 0}var xa=/(`+)([\s\S]*?)\1|\*\*([\s\S]+?)\*\*|(?<![\w`])__([\s\S]+?)__(?![\w])|~~([\s\S]+?)~~|\*([^*\n]+?)\*|(?<![\w`])_([^_\n]+?)_(?![\w])|\[([^\]]+)\]\(([^)\s]+)(?:\s+"[^"]*")?\)|(https?:\/\/[^\s<]*[^\s<.,;:!?)\]'"])/g;function Z(t){let e=[],n=0,a=0,r=new RegExp(xa.source,"g"),i=r.exec(t);for(;i;){i.index>n&&e.push(t.slice(n,i.index));let[,,l,c,d,u,p,b,s,g,f]=i;l!==void 0?e.push(o("code",{children:l.trim()},a++)):c!==void 0||d!==void 0?e.push(o("strong",{children:Z(c??d)},a++)):u!==void 0?e.push(o("del",{children:Z(u)},a++)):p!==void 0||b!==void 0?e.push(o("em",{children:Z(p??b)},a++)):s!==void 0&&g!==void 0?e.push(hn(a++,g,Z(s))):f!==void 0&&e.push(hn(a++,f,f)),n=i.index+i[0].length,i=r.exec(t)}return n<t.length&&e.push(t.slice(n)),e}var ya=/^(https?:\/\/|mailto:)/i;function hn(t,e,n){return ya.test(e)?o("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:n},t):o(T,{children:n},t)}var oe=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),rt=t=>Array.isArray(t)&&t.every(e=>typeof e=="string"),ka=t=>Array.isArray(t)&&t.every(e=>typeof e=="number");function wa(t){return oe(t)&&typeof t.title=="string"&&typeof t.subtitle=="string"&&typeof t.body=="string"&&typeof t.image=="string"}function Ca(t){if(!oe(t))return null;let e=t.text,n=t.buttons,a=t.table,r=t.pie,i=t.image,l=Array.isArray(t.cards)?t.cards:t.card?[t.card]:[];return!oe(e)||typeof e.content!="string"||!Array.isArray(n)||!n.every(c=>oe(c)&&typeof c.label=="string"&&typeof c.action=="string")||!oe(a)||!rt(a.headers)||!Array.isArray(a.rows)||!a.rows.every(rt)||!l.every(wa)||!oe(r)||!rt(r.labels)||!ka(r.data)||!oe(i)||typeof i.url!="string"||typeof i.caption!="string"?null:{text:{content:e.content},buttons:n,table:a,cards:l,pie:r,image:i}}function yn(t){let e;try{e=JSON.parse(t)}catch{return null}let n=Array.isArray(e)?e:oe(e)&&Array.isArray(e.items)?e.items:null;if(!n)return null;let a=n.map(Ca);return a.some(r=>r===null)?null:{items:a}}function kn({response:t,onAction:e}){return o("div",{className:"agi-sui",children:t.items.map((n,a)=>o("div",{className:"agi-sui__item",children:[n.text.content&&o("p",{className:"agi-sui__text",children:n.text.content}),n.image.url&&o("figure",{className:"agi-sui__figure",children:[o("img",{src:n.image.url,alt:n.image.caption}),n.image.caption&&o("figcaption",{children:n.image.caption})]}),n.cards.length>0&&o("div",{className:"agi-sui__cards",children:n.cards.map((r,i)=>o("div",{className:"agi-panel agi-sui__card",children:[r.image&&o("img",{src:r.image,alt:""}),o("div",{children:[o("div",{className:"agi-sui__card-title",children:r.title}),r.subtitle&&o("div",{className:"agi-sui__card-sub",children:r.subtitle}),r.body&&o("p",{children:r.body})]})]},i))}),n.table.headers.length>0&&o("div",{className:"agi-sui__scroll",children:o("table",{className:"agi-table",children:[o("thead",{children:o("tr",{children:n.table.headers.map((r,i)=>o("th",{children:r},i))})}),o("tbody",{children:n.table.rows.map((r,i)=>o("tr",{children:r.map((l,c)=>o("td",{children:l},c))},i))})]})}),n.pie.labels.length>0&&o(Aa,{labels:n.pie.labels,data:n.pie.data}),n.buttons.length>0&&o("div",{className:"agi-sui__actions",children:n.buttons.map((r,i)=>o("button",{type:"button",className:"agi-chip",onClick:()=>e?.(r.action),children:r.label},i))})]},a))})}function Aa({labels:t,data:e}){let n=e.reduce((l,c)=>l+Math.max(0,c),0);if(n<=0)return null;let a=0,r=t.map((l,c)=>{let d=Math.max(0,e[c]??0),u=a;return a+=d/n*360,{label:l,value:d,start:u,end:a,color:`var(--data-${c%6+1})`}}),i=(l,c)=>{let b=(l-90)*Math.PI/180,s=(c-90)*Math.PI/180,g=c-l>180?1:0,f=50+48*Math.cos(b),C=50+48*Math.sin(b),w=50+48*Math.cos(s),y=50+48*Math.sin(s);return c-l>=360?`M50 2 A48 48 0 1 1 ${50-.01} 2 Z`:`M50 50 L${f} ${C} A48 48 0 ${g} 1 ${w} ${y} Z`};return o("div",{className:"agi-sui__pie",children:[o("svg",{viewBox:"0 0 100 100",role:"img","aria-label":t.join(", "),children:[o("title",{children:t.join(", ")}),r.map(l=>o("path",{d:i(l.start,l.end),fill:l.color},l.label))]}),o("ul",{children:r.map(l=>o("li",{children:[o("span",{style:{background:l.color}}),l.label,o("b",{children:[Math.round(l.value/n*100),"%"]})]},l.label))})]})}var Fa=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus"],Sa=800,Ea=.02;function Ra(){return typeof window<"u"&&typeof navigator<"u"&&!!navigator.mediaDevices?.getUserMedia&&typeof MediaRecorder<"u"}function wn({identifier:t,onTranscript:e,language:n,silenceMs:a=1400,maxMs:r=6e4}){let{client:i,t:l}=j(),c=Ra(),[d,u]=F(c?"idle":"unsupported"),[p,b]=F(null),[s,g]=F(0),f=M(null),C=M(null),w=M([]),y=M(!1),m=M([]),v=M(null),h=M(null),A=M(null),L=M(!1),V=M(e);V.current=e;let $=B(()=>{for(let x of m.current)window.clearTimeout(x);m.current=[],v.current&&(window.clearInterval(v.current.interval),v.current.ctx.close().catch(()=>{}),v.current=null),g(0)},[]),S=B(()=>{for(let x of C.current?.getTracks()??[])x.stop();C.current=null},[]),_=B(()=>{let x=h.current;x&&(x.pause(),x.src="",h.current=null),A.current&&(URL.revokeObjectURL(A.current),A.current=null),u(P=>P==="speaking"?"idle":P)},[]),R=B(x=>{x.stop()},[]),E=B(()=>{let x=f.current;!x||x.state==="inactive"||(y.current=!1,R(x))},[R]),W=B(()=>{let x=f.current;!x||x.state==="inactive"||(y.current=!0,R(x))},[R]),X=B((x,P)=>{let O=typeof AudioContext<"u"?AudioContext:window.webkitAudioContext;if(O)try{let U=new O,J=U.createAnalyser();J.fftSize=2048,U.createMediaStreamSource(x).connect(J);let pe=new Uint8Array(J.fftSize),te=!1,ut=Date.now(),Bn=window.setInterval(()=>{J.getByteTimeDomainData(pe);let ct=0;for(let Ln of pe){let pt=(Ln-128)/128;ct+=pt*pt}let dt=Math.sqrt(ct/pe.length);g(Math.min(1,dt*6)),dt>Ea?(te=!0,ut=Date.now()):te&&Date.now()-ut>a&&P()},100);v.current={ctx:U,interval:Bn}}catch{}},[a]),ee=B(async()=>{if(!c){u("unsupported");return}if(L.current||f.current&&f.current.state!=="inactive")return;L.current=!0,_(),b(null);let x;try{x=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{L.current=!1,u("denied"),b(l("voice","micDenied"));return}L.current=!1,C.current=x;let P=Fa.find(U=>MediaRecorder.isTypeSupported?.(U)),O=new MediaRecorder(x,P?{mimeType:P}:void 0);f.current=O,w.current=[],y.current=!1,O.ondataavailable=U=>{U.data&&U.data.size>0&&w.current.push(U.data)},O.onstop=()=>{$(),S(),f.current=null;let U=O.mimeType||P||"audio/webm",J=new Blob(w.current,{type:U});if(w.current=[],y.current||J.size<Sa){u("idle");return}u("transcribing");let pe=U.includes("mp4")?"m4a":U.includes("ogg")?"ogg":"webm";i.transcribe(t,J,`turn.${pe}`,n).then(te=>{u("idle"),te.transcript&&V.current(te.transcript)}).catch(te=>{u("idle"),b(te instanceof I&&te.code==="VOICE_UNAVAILABLE"?l("voice","unavailable"):l("voice","error"))})},O.start(250),u("listening"),X(x,()=>E()),m.current.push(window.setTimeout(()=>E(),r))},[c,_,l,i,t,n,r,E,$,S,X]),se=B(async x=>{_(),b(null),u("speaking");try{let P=await i.speak(t,x),O=URL.createObjectURL(P);A.current=O;let U=new Audio(O);h.current=U,await new Promise(J=>{U.onended=()=>J(),U.onerror=()=>J(),U.onpause=()=>J(),U.play().catch(()=>J())})}catch(P){b(P instanceof I&&P.code==="VOICE_UNAVAILABLE"?l("voice","unavailable"):l("voice","error"))}finally{A.current&&URL.revokeObjectURL(A.current),A.current=null,h.current=null,u(P=>P==="speaking"?"idle":P)}},[i,t,_,l]);return q(()=>()=>{y.current=!0,f.current&&f.current.state!=="inactive"&&f.current.stop(),$(),S();let x=h.current;x&&x.pause(),A.current&&URL.revokeObjectURL(A.current)},[$,S]),{state:d,error:p,supported:c,level:s,startListening:ee,stopListening:E,cancelListening:W,speak:se,stopSpeaking:_}}var ot={maxFiles:5,maxBytes:10*1024*1024};function Cn(t,e=!0){let{client:n,t:a}=j(),[r,i]=F(null),[l,c]=F(null),[d,u]=F(),[p,b]=F(null),[s,g]=F([]),[f,C]=F(!1),[w]=F(()=>it()),y=M(null),m=B(async()=>{b(null);try{let S=await n.getChat(t);if("authRequired"in S){c(S.authRequired==="public"?null:S.authRequired),u(S.title);return}i(S),c(null)}catch(S){b(S instanceof I&&S.status===403?a("chat","unavailable"):a("chat","error"))}},[n,t,a]);q(()=>{e&&m()},[m,e]);let v=`/api/chat/${encodeURIComponent(t)}`,h=B(async({password:S})=>(await n.fetchRaw(v,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:S,conversationId:w})})).ok?(await m(),!0):!1,[n,v,w,m]),A=B(async S=>{let _=await n.fetchRaw(`${v}/otp`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:S})});return _.ok?"sent":_.status===403?"unauthorized":"error"},[n,v]),L=B(async(S,_)=>(await n.fetchRaw(`${v}/otp`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:S,otp:_})})).ok?(await m(),!0):!1,[n,v,m]),V=B(()=>{y.current?.abort(),y.current=null,C(!1),g(S=>{let _=S[S.length-1];return!_||_.role!=="assistant"||!_.streaming?S:[...S.slice(0,-1),{..._,streaming:!1,content:_.content||a("chat","stopped")}]})},[a]),$=B(async(S,_=[])=>{let R=S.trim();if(!R&&_.length===0||f)return;let E={id:it(),role:"user",content:R,attachments:_.map(({name:x,type:P,size:O})=>({name:x,type:P,size:O}))},W=it();g(x=>[...x,E,{id:W,role:"assistant",content:"",streaming:!0}]),C(!0);let X=new AbortController;y.current=X;let ee="",se=x=>g(P=>P.map(O=>O.id===W?{...O,...x}:O));try{for await(let x of n.sendMessage(t,{input:R,conversationId:w,files:_},X.signal))if(x.type==="chunk")ee+=x.text,se({content:ee});else if(x.type==="final"){let P=Pa(x.data);P&&!ee&&(ee=P,se({content:ee}))}else x.type==="error"&&se({content:x.message,error:!0,streaming:!1});se({streaming:!1,structured:yn(ee)})}catch(x){if(X.signal.aborted)return;let P=x instanceof I&&x.code==="AUTH_REQUIRED"?a("chat","unavailable"):a("chat","error");se({content:P,error:!0,streaming:!1}),x instanceof I&&x.code==="AUTH_REQUIRED"&&m()}finally{y.current=null,C(!1)}},[f,n,t,w,a,m]);return{config:r,authNeed:l,authTitle:d,loadError:p,messages:s,busy:f,send:$,stop:V,authenticate:h,requestCode:A,verifyCode:L,reload:m}}function Pa(t){if(!t||typeof t!="object")return null;let e=t;if(!e.output)return null;for(let n of Object.values(e.output))if(n&&typeof n=="object"){let a=n;if(typeof a.content=="string")return a.content;if(typeof a.result=="string")return a.result}return null}function it(){return typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function st({identifier:t,mode:e="inline",position:n="right",launcherLabel:a,defaultOpen:r=!1,theme:i="auto",voice:l=!0,className:c}){let[d,u]=F(r||e!=="bubble"),{t:p}=j(),b=he("chat"),s=Cn(t,b),[g,f]=F(!1),[C,w]=F(null),y=M(g);y.current=g;let m=M(s.send);m.current=s.send;let v=wn({identifier:t,onTranscript:_=>{y.current?m.current(_):w({id:Date.now(),text:_})}}),h=s.config?.voice,A=l&&v.supported&&h?.stt===!0,L=s.config?.title??s.authTitle??a??"Aginies",V=i==="auto"?void 0:i==="dark"?"dark":"light";if(!b)return null;let $=()=>{v.cancelListening(),v.stopSpeaking(),f(!1)},S=o("section",{className:H("agi-chat",`agi-chat--${e}`,V,c),"data-theme":V,"aria-label":L,children:[o("header",{className:"agi-chat__head",children:[o("div",{className:"agi-chat__title",children:[s.config?.customizations.imageUrl&&o("img",{src:s.config.customizations.imageUrl,alt:""}),o("div",{children:[o("div",{className:"agi-chat__name",children:L}),s.config?.description&&o("div",{className:"agi-chat__desc",children:s.config.description})]})]}),e==="bubble"&&o("button",{type:"button",className:"agi-chat__close",onClick:()=>u(!1),"aria-label":p("chat","close"),children:"\xD7"})]}),s.loadError?o("div",{className:"agi-chat__state",children:[o("p",{children:s.loadError}),o(D,{variant:"outline",size:"sm",onClick:()=>{s.reload()},children:p("common","retry")})]}):s.authNeed?o(za,{need:s.authNeed,onPassword:s.authenticate,onRequestCode:s.requestCode,onVerifyCode:s.verifyCode}):s.config?g?o(Ma,{messages:s.messages,busy:s.busy,voice:v,speakReplies:h?.tts===!0,onExit:$}):o(T,{children:[o(Ta,{messages:s.messages,welcome:s.config.customizations.welcomeMessage||p("chat","welcome"),onAction:_=>{s.send(_)}}),o(Na,{busy:s.busy,onSend:s.send,onStop:s.stop,dictation:C,voice:A?{state:v.state,error:v.error,start:v.startListening,stop:v.stopListening,onHandsFree:()=>f(!0)}:void 0})]}):o("div",{className:"agi-chat__state",children:o(ie,{label:p("common","loading")})}),o("footer",{className:"agi-chat__foot",children:o("a",{href:"https://www.aginies.com",target:"_blank",rel:"noreferrer",children:p("chat","poweredBy")})})]});return e!=="bubble"?S:o("div",{className:H("agi-bubble",`agi-bubble--${n}`,V),"data-theme":V,children:[d&&S,o("button",{type:"button",className:H("agi-bubble__launcher",d&&"agi-bubble__launcher--open"),onClick:()=>u(_=>!_),"aria-expanded":d,"aria-label":d?p("chat","close"):p("chat","open"),children:[o("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o("path",{d:"M4 5.5A2.5 2.5 0 0 1 6.5 3h11A2.5 2.5 0 0 1 20 5.5v8a2.5 2.5 0 0 1-2.5 2.5H10l-5 4v-4H6.5A2.5 2.5 0 0 1 4 13.5v-8z"}),o("path",{d:"M8 8h8M8 11.5h5"})]}),!d&&o("span",{children:a??L})]})]})}function Ta({messages:t,welcome:e,onAction:n}){let{t:a}=j(),r=M(null);return q(()=>{r.current?.scrollIntoView?.({block:"end"})},[]),o("div",{className:"agi-chat__messages",role:"log","aria-live":"polite",children:[o("div",{className:"agi-msg agi-msg--assistant",children:[o("span",{className:"agi-msg__who",children:a("chat","assistant")}),o("div",{className:"agi-msg__body",children:e})]}),t.map(i=>o("div",{className:H("agi-msg",`agi-msg--${i.role}`,i.error&&"agi-msg--error"),children:[o("span",{className:"agi-msg__who",children:i.role==="user"?a("chat","you"):a("chat","assistant")}),o("div",{className:"agi-msg__body",children:[i.structured?o(kn,{response:i.structured,onAction:n}):i.content?i.role==="assistant"&&!i.error?o(at,{className:"agi-md",text:i.content}):o("p",{children:i.content}):i.streaming?o("span",{className:"agi-msg__thinking",children:[o(ie,{label:a("chat","thinking")})," ",a("chat","thinking")]}):null,i.attachments&&i.attachments.length>0&&o("ul",{className:"agi-msg__files","aria-label":a("chat","attachments"),children:i.attachments.map((l,c)=>o("li",{className:"agi-file",children:[o(Fn,{}),o("span",{className:"agi-file__name",children:l.name}),o("span",{className:"agi-file__size",children:Ia(l.size)})]},c))})]})]},i.id)),o("div",{ref:r})]})}function Na({busy:t,onSend:e,onStop:n,voice:a,dictation:r}){let{t:i}=j(),[l,c]=F(""),[d,u]=F([]),[p,b]=F(null),s=M(null);q(()=>{r&&c(m=>m.trim()?`${m.trimEnd()} ${r.text}`:r.text)},[r]);let g=a?.state==="listening",f=a?.state==="transcribing",C=m=>{if(m.preventDefault(),t)return;let v=l,h=d;c(""),u([]),b(null),e(v,h)},w=async m=>{let v=Array.from(m.target.files??[]);if(m.target.value="",v.length===0)return;if(d.length+v.length>ot.maxFiles){b(i("chat","tooManyFiles"));return}if(v.some(A=>A.size>ot.maxBytes)){b(i("chat","fileTooLarge"));return}b(null);let h=await Promise.all(v.map(La));u(A=>[...A,...h])},y=l.trim().length>0||d.length>0;return o("form",{className:"agi-chat__composer",onSubmit:C,children:[(d.length>0||p)&&o("div",{className:"agi-chat__pending",children:[d.map((m,v)=>o("span",{className:"agi-file agi-file--pending",children:[o(Fn,{}),o("span",{className:"agi-file__name",children:m.name}),o("button",{type:"button",className:"agi-file__remove","aria-label":`${i("chat","removeFile")}: ${m.name}`,onClick:()=>u(h=>h.filter((A,L)=>L!==v)),children:"\xD7"})]},v)),p&&o("span",{className:"agi-chat__file-error",children:p})]}),a?.error&&o("div",{className:"agi-chat__file-error",children:a.error}),o("div",{className:"agi-chat__row",children:[o("input",{ref:s,type:"file",multiple:!0,hidden:!0,onChange:w,"data-testid":"agi-file-input"}),o(D,{variant:"ghost",type:"button","aria-label":i("chat","attach"),title:i("chat","attach"),disabled:t,onClick:()=>s.current?.click(),children:o("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:o("path",{d:"M21 12.5 12.8 20.7a5.5 5.5 0 0 1-7.8-7.8l8.6-8.6a3.5 3.5 0 0 1 5 5l-8.6 8.6a1.5 1.5 0 0 1-2.1-2.1L15.5 8",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}),o(re,{value:l,onChange:m=>c(m.target.value),placeholder:i("chat","placeholder"),"aria-label":i("chat","placeholder"),autoComplete:"off"}),a&&o(T,{children:[o(D,{variant:"ghost",type:"button",className:H("agi-chat__mic",g&&"agi-chat__mic--on"),"aria-label":g?i("voice","stopTalking"):i("voice","dictate"),"aria-pressed":g,title:g?i("voice","stopTalking"):i("voice","dictate"),disabled:t||f,onClick:()=>g?a.stop():void a.start(),children:f?o(ie,{label:i("voice","transcribing")}):o(An,{})}),o(D,{variant:"ghost",type:"button","aria-label":i("voice","handsFree"),title:i("voice","handsFree"),disabled:t||g||f,onClick:a.onHandsFree,children:o(Ba,{})})]}),t?o(D,{variant:"outline",onClick:n,children:i("chat","stop")}):o(D,{variant:"signal",type:"submit",disabled:!y,children:i("chat","send")})]})]})}function Ma({messages:t,busy:e,voice:n,speakReplies:a,onExit:r}){let{t:i}=j(),l=M(null),c=M(!0),d=[...t].reverse().find(C=>C.role==="assistant"),u=[...t].reverse().find(C=>C.role==="user");q(()=>(c.current=!0,l.current=d?.id??null,n.startListening(),()=>{c.current=!1}),[]);let p=d?.id,b=d?.streaming===!0;q(()=>{if(!d||b||p===l.current)return;l.current=p??null,(async()=>(a&&d.content&&!d.error&&await n.speak(d.content),c.current&&await n.startListening()))()},[p,b]);let s=n.state==="listening"?i("voice","listening"):n.state==="transcribing"?i("voice","transcribing"):n.state==="speaking"?i("voice","speaking"):e?i("voice","thinking"):i("voice","idle"),g=n.state==="listening"?i("voice","stopTalking"):n.state==="speaking"?i("voice","interrupt"):n.state==="transcribing"||e?"":i("voice","talk"),f=()=>{n.state==="listening"?n.stopListening():n.state==="speaking"?(n.stopSpeaking(),n.startListening()):n.state==="idle"&&!e&&n.startListening()};return o("section",{className:"agi-voice","aria-label":i("voice","handsFree"),children:[o("button",{type:"button",className:"agi-voice__exit",onClick:r,"aria-label":i("voice","exit"),children:"\xD7"}),o("div",{className:"agi-voice__status","aria-live":"polite",children:s}),u?.content&&o("p",{className:"agi-voice__you",children:u.content}),o("div",{className:"agi-voice__reply",children:d?.content?o(at,{className:"agi-md",text:d.content}):e?o(ie,{label:i("voice","thinking")}):null}),o("button",{type:"button",className:H("agi-voice__orb",`agi-voice__orb--${n.state}`,e&&"agi-voice__orb--busy"),style:{"--agi-level":n.level},onClick:f,"aria-label":g||s,disabled:n.state==="transcribing"||n.state==="unsupported",children:o(An,{size:28})}),o("div",{className:"agi-voice__hint",children:g}),n.error&&o("div",{className:"agi-voice__error",children:n.error})]})}function An({size:t=16}){return o("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),o("path",{d:"M5 11a7 7 0 0 0 14 0M12 18v3M9 21h6"})]})}function Ba(){return o("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o("path",{d:"M4 14v-2a8 8 0 0 1 16 0v2"}),o("rect",{x:"3",y:"13",width:"4",height:"6",rx:"1.5"}),o("rect",{x:"17",y:"13",width:"4",height:"6",rx:"1.5"}),o("path",{d:"M19 19v1a2 2 0 0 1-2 2h-3"})]})}function La(t){return new Promise((e,n)=>{let a=new FileReader;a.onload=()=>e({name:t.name,type:t.type||"application/octet-stream",size:t.size,data:String(a.result),lastModified:t.lastModified}),a.onerror=()=>n(a.error),a.readAsDataURL(t)})}function Ia(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(0)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Fn(){return o("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[o("path",{d:"M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8l-5-5z",stroke:"currentColor",strokeWidth:"1.8",strokeLinejoin:"round"}),o("path",{d:"M14 3v5h5",stroke:"currentColor",strokeWidth:"1.8",strokeLinejoin:"round"})]})}function za({need:t,onPassword:e,onRequestCode:n,onVerifyCode:a}){let{t:r,client:i}=j();return t==="sso"?o("div",{className:"agi-chat__state",children:[o("h3",{children:r("auth","ssoTitle")}),o("p",{children:r("auth","ssoHint")}),o(D,{variant:"signal",onClick:()=>window.open(`${i.baseUrl}/chat/`,"_blank","noopener"),children:r("auth","ssoButton")})]}):t==="email"?o(Ha,{onRequestCode:n,onVerifyCode:a}):o(Ua,{onPassword:e})}function Ua({onPassword:t}){let{t:e}=j(),[n,a]=F(""),[r,i]=F(null),[l,c]=F(!1);return o("form",{className:"agi-chat__state agi-chat__auth",onSubmit:async u=>{u.preventDefault(),c(!0),i(null);let p=await t({password:n});c(!1),p||i(e("auth","invalidPassword"))},children:[o("h3",{children:e("auth","passwordTitle")}),o("p",{children:e("auth","passwordHint")}),o(ce,{label:e("auth","password"),error:r??void 0,children:o(re,{type:"password",value:n,onChange:u=>a(u.target.value),required:!0,autoComplete:"current-password"})}),o(D,{variant:"signal",type:"submit",disabled:l||!n,children:e("auth","continue")})]})}function Ha({onRequestCode:t,onVerifyCode:e}){let{t:n}=j(),[a,r]=F(""),[i,l]=F(""),[c,d]=F("email"),[u,p]=F(null),[b,s]=F(null),[g,f]=F(!1),C=async()=>{f(!0),p(null),s(null);let m=await t(a.trim());f(!1),m==="sent"?(d("code"),s(n("auth","codeSent"))):p(n("auth",m==="unauthorized"?"invalidEmail":"codeError"))},w=async()=>{f(!0),p(null),s(null);let m=await e(a.trim(),i.trim());f(!1),m||p(n("auth","invalidCode"))},y=m=>{m.preventDefault(),c==="email"?C():w()};return c==="code"?o("form",{className:"agi-chat__state agi-chat__auth",onSubmit:y,children:[o("h3",{children:n("auth","emailTitle")}),o("p",{children:[n("auth","codeHint")," ",o("strong",{children:a})]}),o(ce,{label:n("auth","code"),error:u??void 0,hint:b??void 0,children:o(re,{inputMode:"numeric",autoComplete:"one-time-code",pattern:"[0-9]{6}",maxLength:6,value:i,onChange:m=>l(m.target.value.replace(/\D/g,"")),required:!0})}),o("div",{className:"agi-chat__auth-actions",children:[o(D,{variant:"signal",type:"submit",disabled:g||i.length!==6,children:n("auth","verify")}),o(D,{variant:"ghost",type:"button",disabled:g,onClick:()=>{C()},children:n("auth","resend")}),o(D,{variant:"ghost",type:"button",disabled:g,onClick:()=>{d("email"),l(""),p(null),s(null)},children:n("auth","back")})]})]}):o("form",{className:"agi-chat__state agi-chat__auth",onSubmit:y,children:[o("h3",{children:n("auth","emailTitle")}),o("p",{children:n("auth","emailHint")}),o(ce,{label:n("auth","email"),error:u??void 0,children:o(re,{type:"email",value:a,onChange:m=>r(m.target.value),required:!0,autoComplete:"email"})}),o(D,{variant:"signal",type:"submit",disabled:g||!a.trim(),children:n("auth","sendCode")})]})}var Sn=`/* @aginies/tokens v0.1.0 \u2014 generated from src/tokens.ts. Do not edit by hand. */
|
|
8
|
+
`),n=[],a=0,r=[],i=()=>{r.length>0&&(n.push({kind:"paragraph",lines:r}),r=[])};for(;a<e.length;){let s=e[a];if(s.trim()===""){i(),a+=1;continue}let c=_a.exec(s);if(c){i();let g=c[1],h=c[2]??"",l=[];for(a+=1;a<e.length&&!e[a].trim().startsWith(g);)l.push(e[a]),a+=1;a+=1,n.push({kind:"code",lang:h,code:l.join(`
|
|
9
|
+
`)});continue}let p=ha.exec(s);if(p){i(),n.push({kind:"heading",level:p[1].length,text:p[2]??""}),a+=1;continue}if(ba.test(s)){i(),n.push({kind:"rule"}),a+=1;continue}if(et.test(s)){i();let g=[];for(;a<e.length&&et.test(e[a]);)g.push(et.exec(e[a])[1]??""),a+=1;n.push({kind:"quote",blocks:vn(g.join(`
|
|
10
|
+
`))});continue}let u=tt.exec(s);if(u){i();let g=u[2]!==void 0,h=g?Number.parseInt(u[2],10):1,l=[];for(;a<e.length;){let d=tt.exec(e[a]);if(d&&d[2]!==void 0===g)l.push(d[3]??""),a+=1;else if(l.length>0&&e[a].trim()!==""&&/^\s{2,}/.test(e[a])&&!tt.test(e[a]))l[l.length-1]=`${l[l.length-1]} ${e[a].trim()}`,a+=1;else break}n.push({kind:"list",ordered:g,start:h,items:l});continue}if(s.includes("|")&&a+1<e.length&&va.test(e[a+1])){i();let g=nt(s),h=nt(e[a+1]).map(d=>{let f=d.startsWith(":"),w=d.endsWith(":");return f&&w?"center":w?"right":f?"left":null}),l=[];for(a+=2;a<e.length&&e[a].includes("|");)l.push(nt(e[a])),a+=1;n.push({kind:"table",header:g,align:h,rows:l});continue}r.push(s),a+=1}return i(),n}function nt(t){return t.trim().replace(/^\|/,"").replace(/\|$/,"").split(/(?<!\\)\|/).map(n=>n.replace(/\\\|/g,"|").trim())}function xn(t){return t.map((e,n)=>{switch(e.kind){case"paragraph":return o("p",{children:e.lines.map((a,r)=>o(N,{children:[r>0&&o("br",{}),ee(a)]},r))},n);case"heading":{let a=`h${Math.min(e.level+2,6)}`;return o(a,{children:ee(e.text)},n)}case"code":return o("pre",{"data-lang":e.lang||void 0,children:o("code",{children:e.code})},n);case"quote":return o("blockquote",{children:xn(e.blocks)},n);case"list":{let a=e.items.map((r,i)=>o("li",{children:ee(r)},i));return e.ordered?o("ol",{start:e.start===1?void 0:e.start,children:a},n):o("ul",{children:a},n)}case"table":return o("div",{className:"agi-md__table",children:o("table",{children:[o("thead",{children:o("tr",{children:e.header.map((a,r)=>o("th",{style:hn(e.align[r]),children:ee(a)},r))})}),o("tbody",{children:e.rows.map((a,r)=>o("tr",{children:e.header.map((i,s)=>o("td",{style:hn(e.align[s]),children:ee(a[s]??"")},s))},r))})]})},n);case"rule":return o("hr",{},n)}})}function hn(t){return t?{textAlign:t}:void 0}var xa=/(`+)([\s\S]*?)\1|\*\*([\s\S]+?)\*\*|(?<![\w`])__([\s\S]+?)__(?![\w])|~~([\s\S]+?)~~|\*([^*\n]+?)\*|(?<![\w`])_([^_\n]+?)_(?![\w])|\[([^\]]+)\]\(([^)\s]+)(?:\s+"[^"]*")?\)|(https?:\/\/[^\s<]*[^\s<.,;:!?)\]'"])/g;function ee(t){let e=[],n=0,a=0,r=new RegExp(xa.source,"g"),i=r.exec(t);for(;i;){i.index>n&&e.push(t.slice(n,i.index));let[,,s,c,p,u,g,h,l,d,f]=i;s!==void 0?e.push(o("code",{children:s.trim()},a++)):c!==void 0||p!==void 0?e.push(o("strong",{children:ee(c??p)},a++)):u!==void 0?e.push(o("del",{children:ee(u)},a++)):g!==void 0||h!==void 0?e.push(o("em",{children:ee(g??h)},a++)):l!==void 0&&d!==void 0?e.push(bn(a++,d,ee(l))):f!==void 0&&e.push(bn(a++,f,f)),n=i.index+i[0].length,i=r.exec(t)}return n<t.length&&e.push(t.slice(n)),e}var ya=/^(https?:\/\/|mailto:)/i;function bn(t,e,n){return ya.test(e)?o("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:n},t):o(N,{children:n},t)}var ie=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),rt=t=>Array.isArray(t)&&t.every(e=>typeof e=="string"),ka=t=>Array.isArray(t)&&t.every(e=>typeof e=="number");function wa(t){return ie(t)&&typeof t.title=="string"&&typeof t.subtitle=="string"&&typeof t.body=="string"&&typeof t.image=="string"}function Ca(t){if(!ie(t))return null;let e=t.text,n=t.buttons,a=t.table,r=t.pie,i=t.image,s=Array.isArray(t.cards)?t.cards:t.card?[t.card]:[];return!ie(e)||typeof e.content!="string"||!Array.isArray(n)||!n.every(c=>ie(c)&&typeof c.label=="string"&&typeof c.action=="string")||!ie(a)||!rt(a.headers)||!Array.isArray(a.rows)||!a.rows.every(rt)||!s.every(wa)||!ie(r)||!rt(r.labels)||!ka(r.data)||!ie(i)||typeof i.url!="string"||typeof i.caption!="string"?null:{text:{content:e.content},buttons:n,table:a,cards:s,pie:r,image:i}}function yn(t){let e;try{e=JSON.parse(t)}catch{return null}let n=Array.isArray(e)?e:ie(e)&&Array.isArray(e.items)?e.items:null;if(!n)return null;let a=n.map(Ca);return a.some(r=>r===null)?null:{items:a}}function kn({response:t,onAction:e}){return o("div",{className:"agi-sui",children:t.items.map((n,a)=>o("div",{className:"agi-sui__item",children:[n.text.content&&o("p",{className:"agi-sui__text",children:n.text.content}),n.image.url&&o("figure",{className:"agi-sui__figure",children:[o("img",{src:n.image.url,alt:n.image.caption}),n.image.caption&&o("figcaption",{children:n.image.caption})]}),n.cards.length>0&&o("div",{className:"agi-sui__cards",children:n.cards.map((r,i)=>o("div",{className:"agi-panel agi-sui__card",children:[r.image&&o("img",{src:r.image,alt:""}),o("div",{children:[o("div",{className:"agi-sui__card-title",children:r.title}),r.subtitle&&o("div",{className:"agi-sui__card-sub",children:r.subtitle}),r.body&&o("p",{children:r.body})]})]},i))}),n.table.headers.length>0&&o("div",{className:"agi-sui__scroll",children:o("table",{className:"agi-table",children:[o("thead",{children:o("tr",{children:n.table.headers.map((r,i)=>o("th",{children:r},i))})}),o("tbody",{children:n.table.rows.map((r,i)=>o("tr",{children:r.map((s,c)=>o("td",{children:s},c))},i))})]})}),n.pie.labels.length>0&&o(Aa,{labels:n.pie.labels,data:n.pie.data}),n.buttons.length>0&&o("div",{className:"agi-sui__actions",children:n.buttons.map((r,i)=>o("button",{type:"button",className:"agi-chip",onClick:()=>e?.(r.action),children:r.label},i))})]},a))})}function Aa({labels:t,data:e}){let n=e.reduce((s,c)=>s+Math.max(0,c),0);if(n<=0)return null;let a=0,r=t.map((s,c)=>{let p=Math.max(0,e[c]??0),u=a;return a+=p/n*360,{label:s,value:p,start:u,end:a,color:`var(--data-${c%6+1})`}}),i=(s,c)=>{let h=(s-90)*Math.PI/180,l=(c-90)*Math.PI/180,d=c-s>180?1:0,f=50+48*Math.cos(h),w=50+48*Math.sin(h),y=50+48*Math.cos(l),k=50+48*Math.sin(l);return c-s>=360?`M50 2 A48 48 0 1 1 ${50-.01} 2 Z`:`M50 50 L${f} ${w} A48 48 0 ${d} 1 ${y} ${k} Z`};return o("div",{className:"agi-sui__pie",children:[o("svg",{viewBox:"0 0 100 100",role:"img","aria-label":t.join(", "),children:[o("title",{children:t.join(", ")}),r.map(s=>o("path",{d:i(s.start,s.end),fill:s.color},s.label))]}),o("ul",{children:r.map(s=>o("li",{children:[o("span",{style:{background:s.color}}),s.label,o("b",{children:[Math.round(s.value/n*100),"%"]})]},s.label))})]})}var Sa=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus"],Fa=800,Ea=.02;function Ra(){return typeof window<"u"&&typeof navigator<"u"&&!!navigator.mediaDevices?.getUserMedia&&typeof MediaRecorder<"u"}function wn({identifier:t,onTranscript:e,language:n,silenceMs:a=1400,maxMs:r=6e4}){let{client:i,t:s}=V(),c=Ra(),[p,u]=A(c?"idle":"unsupported"),[g,h]=A(null),[l,d]=A(0),f=B(null),w=B(null),y=B([]),k=B(!1),m=B([]),v=B(null),b=B(null),S=B(null),L=B(!1),W=B(e);W.current=e;let q=T(()=>{for(let F of m.current)window.clearTimeout(F);m.current=[],v.current&&(window.clearInterval(v.current.interval),v.current.ctx.close().catch(()=>{}),v.current=null),d(0)},[]),j=T(()=>{for(let F of w.current?.getTracks()??[])F.stop();w.current=null},[]),_=T(()=>{let F=b.current;F&&(F.pause(),F.src="",b.current=null),S.current&&(URL.revokeObjectURL(S.current),S.current=null),u(R=>R==="speaking"?"idle":R)},[]),C=T(F=>{F.stop()},[]),E=T(()=>{let F=f.current;!F||F.state==="inactive"||(k.current=!1,C(F))},[C]),O=T(()=>{let F=f.current;!F||F.state==="inactive"||(k.current=!0,C(F))},[C]),oe=T((F,R)=>{let z=typeof AudioContext<"u"?AudioContext:window.webkitAudioContext;if(z)try{let P=new z,J=P.createAnalyser();J.fftSize=2048,P.createMediaStreamSource(F).connect(J);let pe=new Uint8Array(J.fftSize),te=!1,ut=Date.now(),Bn=window.setInterval(()=>{J.getByteTimeDomainData(pe);let ct=0;for(let In of pe){let pt=(In-128)/128;ct+=pt*pt}let dt=Math.sqrt(ct/pe.length);d(Math.min(1,dt*6)),dt>Ea?(te=!0,ut=Date.now()):te&&Date.now()-ut>a&&R()},100);v.current={ctx:P,interval:Bn}}catch{}},[a]),de=T(async()=>{if(!c){u("unsupported");return}if(L.current||f.current&&f.current.state!=="inactive")return;L.current=!0,_(),h(null);let F;try{F=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{L.current=!1,u("denied"),h(s("voice","micDenied"));return}L.current=!1,w.current=F;let R=Sa.find(P=>MediaRecorder.isTypeSupported?.(P)),z=new MediaRecorder(F,R?{mimeType:R}:void 0);f.current=z,y.current=[],k.current=!1,z.ondataavailable=P=>{P.data&&P.data.size>0&&y.current.push(P.data)},z.onstop=()=>{q(),j(),f.current=null;let P=z.mimeType||R||"audio/webm",J=new Blob(y.current,{type:P});if(y.current=[],k.current||J.size<Fa){u("idle");return}u("transcribing");let pe=P.includes("mp4")?"m4a":P.includes("ogg")?"ogg":"webm";i.transcribe(t,J,`turn.${pe}`,n).then(te=>{u("idle"),te.transcript&&W.current(te.transcript)}).catch(te=>{u("idle"),h(te instanceof I&&te.code==="VOICE_UNAVAILABLE"?s("voice","unavailable"):s("voice","error"))})},z.start(250),u("listening"),oe(F,()=>E()),m.current.push(window.setTimeout(()=>E(),r))},[c,_,s,i,t,n,r,E,q,j,oe]),K=T(async F=>{_(),h(null),u("speaking");try{let R=await i.speak(t,F),z=URL.createObjectURL(R);S.current=z;let P=new Audio(z);b.current=P,await new Promise(J=>{P.onended=()=>J(),P.onerror=()=>J(),P.onpause=()=>J(),P.play().catch(()=>J())})}catch(R){h(R instanceof I&&R.code==="VOICE_UNAVAILABLE"?s("voice","unavailable"):s("voice","error"))}finally{S.current&&URL.revokeObjectURL(S.current),S.current=null,b.current=null,u(R=>R==="speaking"?"idle":R)}},[i,t,_,s]);return $(()=>()=>{k.current=!0,f.current&&f.current.state!=="inactive"&&f.current.stop(),q(),j();let F=b.current;F&&F.pause(),S.current&&URL.revokeObjectURL(S.current)},[q,j]),{state:p,error:g,supported:c,level:l,startListening:de,stopListening:E,cancelListening:O,speak:K,stopSpeaking:_}}var ot={maxFiles:5,maxBytes:10*1024*1024};function Cn(t,e=!0){let{client:n,t:a}=V(),[r,i]=A(null),[s,c]=A(null),[p,u]=A(),[g,h]=A(null),[l,d]=A([]),[f,w]=A(!1),[y]=A(()=>it()),k=B(null),m=T(async()=>{h(null);try{let _=await n.getChat(t);if("authRequired"in _){c(_.authRequired==="public"?null:_.authRequired),u(_.title);return}i(_),c(null)}catch(_){h(_ instanceof I&&_.status===403?a("chat","unavailable"):a("chat","error"))}},[n,t,a]);$(()=>{e&&m()},[m,e]);let v=`/api/chat/${encodeURIComponent(t)}`,b=T(async({password:_})=>(await n.fetchRaw(v,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:_,conversationId:y})})).ok?(await m(),!0):!1,[n,v,y,m]),S=T(async _=>{let C=await n.fetchRaw(v,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:_,checkSSOAccess:!0})});if(!C.ok)return C.status===401||C.status===403?"unauthorized":"error";let E=`${n.baseUrl}/chat/${encodeURIComponent(t)}`;return n.hosted?window.location.assign(`${n.baseUrl}/sso?email=${encodeURIComponent(_)}&callbackUrl=${encodeURIComponent(window.location.pathname)}`):window.open(E,"_blank","noopener"),"redirected"},[n,v,t]),L=T(async _=>{let C=await n.fetchRaw(`${v}/otp`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:_})});return C.ok?"sent":C.status===403?"unauthorized":"error"},[n,v]),W=T(async(_,C)=>(await n.fetchRaw(`${v}/otp`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:_,otp:C})})).ok?(await m(),!0):!1,[n,v,m]),q=T(()=>{k.current?.abort(),k.current=null,w(!1),d(_=>{let C=_[_.length-1];return!C||C.role!=="assistant"||!C.streaming?_:[..._.slice(0,-1),{...C,streaming:!1,content:C.content||a("chat","stopped")}]})},[a]),j=T(async(_,C=[])=>{let E=_.trim();if(!E&&C.length===0||f)return;let O={id:it(),role:"user",content:E,attachments:C.map(({name:R,type:z,size:P})=>({name:R,type:z,size:P}))},oe=it();d(R=>[...R,O,{id:oe,role:"assistant",content:"",streaming:!0}]),w(!0);let de=new AbortController;k.current=de;let K="",F=R=>d(z=>z.map(P=>P.id===oe?{...P,...R}:P));try{for await(let R of n.sendMessage(t,{input:E,conversationId:y,files:C},de.signal))if(R.type==="chunk")K+=R.text,F({content:K});else if(R.type==="final"){let z=Pa(R.data);if(z&&!K)K=z,F({content:K});else if(!K){let P=Ta(R.data);P&&(K=`\`\`\`json
|
|
11
|
+
${P}
|
|
12
|
+
\`\`\``,F({content:K}))}}else R.type==="error"&&F({content:R.message,error:!0,streaming:!1});F({streaming:!1,structured:yn(K)})}catch(R){if(de.signal.aborted)return;let z=R instanceof I&&R.code==="AUTH_REQUIRED"?a("chat","unavailable"):a("chat","error");F({content:z,error:!0,streaming:!1}),R instanceof I&&R.code==="AUTH_REQUIRED"&&m()}finally{k.current=null,w(!1)}},[f,n,t,y,a,m]);return{config:r,authNeed:s,authTitle:p,loadError:g,messages:l,busy:f,send:j,stop:q,authenticate:b,requestCode:L,verifyCode:W,signInWithSso:S,reload:m}}function Pa(t){if(!t||typeof t!="object")return null;let e=t;if(!e.output)return null;for(let n of Object.values(e.output))if(n&&typeof n=="object"){let a=n;if(typeof a.content=="string")return a.content;if(typeof a.result=="string")return a.result}return null}function Ta(t){if(!t||typeof t!="object")return null;let e=t,n=e.output??e.error;if(n==null)return null;let a=typeof n=="string"?n:JSON.stringify(n,null,2);return a.trim()?a:null}function it(){return typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function st({identifier:t,mode:e="inline",position:n="right",launcherLabel:a,defaultOpen:r=!1,theme:i="auto",voice:s=!0,className:c}){let[p,u]=A(r||e!=="bubble"),{t:g,client:h}=V(),l=be("chat"),d=Cn(t,l),[f,w]=A(!1),[y,k]=A(null),m=B(f);m.current=f;let v=B(d.send);v.current=d.send;let b=wn({identifier:t,onTranscript:O=>{m.current?v.current(O):k({id:Date.now(),text:O})}}),S=d.config?.voice,L=s&&b.supported&&S?.stt===!0,W=h.getState(),q=W.status==="active"?W.config.brand:{name:"Aginies",logoUrl:null},j=d.config?.title??d.authTitle??a??"Aginies",_=i==="auto"?void 0:i==="dark"?"dark":"light";if(!l)return null;let C=()=>{b.cancelListening(),b.stopSpeaking(),w(!1)},E=o("section",{className:H("agi-chat",`agi-chat--${e}`,_,c),"data-theme":_,"aria-label":j,children:[o("header",{className:"agi-chat__head",children:[o("div",{className:"agi-chat__title",children:[d.config?.customizations.imageUrl&&o("img",{src:d.config.customizations.imageUrl,alt:""}),o("div",{children:[o("div",{className:"agi-chat__name",children:j}),d.config?.description&&o("div",{className:"agi-chat__desc",children:d.config.description})]})]}),e==="bubble"&&o("button",{type:"button",className:"agi-chat__close",onClick:()=>u(!1),"aria-label":g("chat","close"),children:"\xD7"})]}),d.loadError?o("div",{className:"agi-chat__state",children:[o("p",{children:d.loadError}),o(D,{variant:"outline",size:"sm",onClick:()=>{d.reload()},children:g("common","retry")})]}):d.authNeed?o(Ua,{need:d.authNeed,onPassword:d.authenticate,onRequestCode:d.requestCode,onVerifyCode:d.verifyCode,onSso:d.signInWithSso,onRetry:()=>{d.reload()}}):d.config?f?o(Ba,{messages:d.messages,busy:d.busy,voice:b,speakReplies:S?.tts===!0,onExit:C}):o(N,{children:[o(Na,{messages:d.messages,welcome:d.config.customizations.welcomeMessage||g("chat","welcome"),onAction:O=>{d.send(O)}}),o(Ma,{busy:d.busy,onSend:d.send,onStop:d.stop,dictation:y,voice:L?{state:b.state,error:b.error,start:b.startListening,stop:b.stopListening,onHandsFree:()=>w(!0)}:void 0})]}):o("div",{className:"agi-chat__state",children:o(re,{label:g("common","loading")})}),q.poweredBy!==!1&&o("footer",{className:"agi-chat__foot",children:o("a",{href:q.siteUrl??"https://www.aginies.com",target:"_blank",rel:"noreferrer",children:g("chat","poweredBy")})})]});return e!=="bubble"?E:o("div",{className:H("agi-bubble",`agi-bubble--${n}`,_),"data-theme":_,children:[p&&E,o("button",{type:"button",className:H("agi-bubble__launcher",p&&"agi-bubble__launcher--open"),onClick:()=>u(O=>!O),"aria-expanded":p,"aria-label":p?g("chat","close"):g("chat","open"),children:[o("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o("path",{d:"M4 5.5A2.5 2.5 0 0 1 6.5 3h11A2.5 2.5 0 0 1 20 5.5v8a2.5 2.5 0 0 1-2.5 2.5H10l-5 4v-4H6.5A2.5 2.5 0 0 1 4 13.5v-8z"}),o("path",{d:"M8 8h8M8 11.5h5"})]}),!p&&o("span",{children:a??j})]})]})}function Na({messages:t,welcome:e,onAction:n}){let{t:a}=V(),r=B(null);return $(()=>{r.current?.scrollIntoView?.({block:"end"})},[]),o("div",{className:"agi-chat__messages",role:"log","aria-live":"polite",children:[o("div",{className:"agi-msg agi-msg--assistant",children:[o("span",{className:"agi-msg__who",children:a("chat","assistant")}),o("div",{className:"agi-msg__body",children:e})]}),t.map(i=>o("div",{className:H("agi-msg",`agi-msg--${i.role}`,i.error&&"agi-msg--error"),children:[o("span",{className:"agi-msg__who",children:i.role==="user"?a("chat","you"):a("chat","assistant")}),o("div",{className:"agi-msg__body",children:[i.structured?o(kn,{response:i.structured,onAction:n}):i.content?i.role==="assistant"&&!i.error?o(at,{className:"agi-md",text:i.content}):o("p",{children:i.content}):i.streaming?o("span",{className:"agi-msg__thinking",children:[o(re,{label:a("chat","thinking")})," ",a("chat","thinking")]}):null,i.attachments&&i.attachments.length>0&&o("ul",{className:"agi-msg__files","aria-label":a("chat","attachments"),children:i.attachments.map((s,c)=>o("li",{className:"agi-file",children:[o(Sn,{}),o("span",{className:"agi-file__name",children:s.name}),o("span",{className:"agi-file__size",children:za(s.size)})]},c))})]})]},i.id)),o("div",{ref:r})]})}function Ma({busy:t,onSend:e,onStop:n,voice:a,dictation:r}){let{t:i}=V(),[s,c]=A(""),[p,u]=A([]),[g,h]=A(null),l=B(null);$(()=>{r&&c(m=>m.trim()?`${m.trimEnd()} ${r.text}`:r.text)},[r]);let d=a?.state==="listening",f=a?.state==="transcribing",w=m=>{if(m.preventDefault(),t)return;let v=s,b=p;c(""),u([]),h(null),e(v,b)},y=async m=>{let v=Array.from(m.target.files??[]);if(m.target.value="",v.length===0)return;if(p.length+v.length>ot.maxFiles){h(i("chat","tooManyFiles"));return}if(v.some(S=>S.size>ot.maxBytes)){h(i("chat","fileTooLarge"));return}h(null);let b=await Promise.all(v.map(La));u(S=>[...S,...b])},k=s.trim().length>0||p.length>0;return o("form",{className:"agi-chat__composer",onSubmit:w,children:[(p.length>0||g)&&o("div",{className:"agi-chat__pending",children:[p.map((m,v)=>o("span",{className:"agi-file agi-file--pending",children:[o(Sn,{}),o("span",{className:"agi-file__name",children:m.name}),o("button",{type:"button",className:"agi-file__remove","aria-label":`${i("chat","removeFile")}: ${m.name}`,onClick:()=>u(b=>b.filter((S,L)=>L!==v)),children:"\xD7"})]},v)),g&&o("span",{className:"agi-chat__file-error",children:g})]}),a?.error&&o("div",{className:"agi-chat__file-error",children:a.error}),o("div",{className:"agi-chat__row",children:[o("input",{ref:l,type:"file",multiple:!0,hidden:!0,onChange:y,"data-testid":"agi-file-input"}),o(D,{variant:"ghost",type:"button","aria-label":i("chat","attach"),title:i("chat","attach"),disabled:t,onClick:()=>l.current?.click(),children:o("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:o("path",{d:"M21 12.5 12.8 20.7a5.5 5.5 0 0 1-7.8-7.8l8.6-8.6a3.5 3.5 0 0 1 5 5l-8.6 8.6a1.5 1.5 0 0 1-2.1-2.1L15.5 8",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}),o(X,{value:s,onChange:m=>c(m.target.value),placeholder:i("chat","placeholder"),"aria-label":i("chat","placeholder"),autoComplete:"off"}),a&&o(N,{children:[o(D,{variant:"ghost",type:"button",className:H("agi-chat__mic",d&&"agi-chat__mic--on"),"aria-label":d?i("voice","stopTalking"):i("voice","dictate"),"aria-pressed":d,title:d?i("voice","stopTalking"):i("voice","dictate"),disabled:t||f,onClick:()=>d?a.stop():void a.start(),children:f?o(re,{label:i("voice","transcribing")}):o(An,{})}),o(D,{variant:"ghost",type:"button","aria-label":i("voice","handsFree"),title:i("voice","handsFree"),disabled:t||d||f,onClick:a.onHandsFree,children:o(Ia,{})})]}),t?o(D,{variant:"outline",onClick:n,children:i("chat","stop")}):o(D,{variant:"signal",type:"submit",disabled:!k,children:i("chat","send")})]})]})}function Ba({messages:t,busy:e,voice:n,speakReplies:a,onExit:r}){let{t:i}=V(),s=B(null),c=B(!0),p=[...t].reverse().find(w=>w.role==="assistant"),u=[...t].reverse().find(w=>w.role==="user");$(()=>(c.current=!0,s.current=p?.id??null,n.startListening(),()=>{c.current=!1}),[]);let g=p?.id,h=p?.streaming===!0;$(()=>{if(!p||h||g===s.current)return;s.current=g??null,(async()=>(a&&p.content&&!p.error&&await n.speak(p.content),c.current&&await n.startListening()))()},[g,h]);let l=n.state==="listening"?i("voice","listening"):n.state==="transcribing"?i("voice","transcribing"):n.state==="speaking"?i("voice","speaking"):e?i("voice","thinking"):i("voice","idle"),d=n.state==="listening"?i("voice","stopTalking"):n.state==="speaking"?i("voice","interrupt"):n.state==="transcribing"||e?"":i("voice","talk"),f=()=>{n.state==="listening"?n.stopListening():n.state==="speaking"?(n.stopSpeaking(),n.startListening()):n.state==="idle"&&!e&&n.startListening()};return o("section",{className:"agi-voice","aria-label":i("voice","handsFree"),children:[o("button",{type:"button",className:"agi-voice__exit",onClick:r,"aria-label":i("voice","exit"),children:"\xD7"}),o("div",{className:"agi-voice__status","aria-live":"polite",children:l}),u?.content&&o("p",{className:"agi-voice__you",children:u.content}),o("div",{className:"agi-voice__reply",children:p?.content?o(at,{className:"agi-md",text:p.content}):e?o(re,{label:i("voice","thinking")}):null}),o("button",{type:"button",className:H("agi-voice__orb",`agi-voice__orb--${n.state}`,e&&"agi-voice__orb--busy"),style:{"--agi-level":n.level},onClick:f,"aria-label":d||l,disabled:n.state==="transcribing"||n.state==="unsupported",children:o(An,{size:28})}),o("div",{className:"agi-voice__hint",children:d}),n.error&&o("div",{className:"agi-voice__error",children:n.error})]})}function An({size:t=16}){return o("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),o("path",{d:"M5 11a7 7 0 0 0 14 0M12 18v3M9 21h6"})]})}function Ia(){return o("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o("path",{d:"M4 14v-2a8 8 0 0 1 16 0v2"}),o("rect",{x:"3",y:"13",width:"4",height:"6",rx:"1.5"}),o("rect",{x:"17",y:"13",width:"4",height:"6",rx:"1.5"}),o("path",{d:"M19 19v1a2 2 0 0 1-2 2h-3"})]})}function La(t){return new Promise((e,n)=>{let a=new FileReader;a.onload=()=>e({name:t.name,type:t.type||"application/octet-stream",size:t.size,data:String(a.result),lastModified:t.lastModified}),a.onerror=()=>n(a.error),a.readAsDataURL(t)})}function za(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(0)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Sn(){return o("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[o("path",{d:"M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8l-5-5z",stroke:"currentColor",strokeWidth:"1.8",strokeLinejoin:"round"}),o("path",{d:"M14 3v5h5",stroke:"currentColor",strokeWidth:"1.8",strokeLinejoin:"round"})]})}function Ua({need:t,onPassword:e,onRequestCode:n,onVerifyCode:a,onSso:r,onRetry:i}){return t==="sso"?o(Oa,{onSso:r,onRetry:i}):t==="email"?o(Da,{onRequestCode:n,onVerifyCode:a}):o(Ha,{onPassword:e})}function Oa({onSso:t,onRetry:e}){let{t:n}=V(),[a,r]=A(""),[i,s]=A(null),[c,p]=A(!1),[u,g]=A(!1);return o("form",{className:"agi-chat__state agi-chat__auth",onSubmit:async l=>{l.preventDefault(),p(!0),s(null);let d=await t(a.trim());p(!1),d==="redirected"?g(!0):s(n("auth",d==="unauthorized"?"invalidEmail":"codeError"))},children:[o("h3",{children:n("auth","ssoTitle")}),o("p",{children:n("auth","ssoHint")}),o(le,{label:n("auth","email"),error:i??void 0,children:o(X,{type:"email",value:a,onChange:l=>r(l.target.value),required:!0,autoComplete:"email"})}),o("div",{className:"agi-chat__auth-actions",children:[o(D,{variant:"signal",type:"submit",disabled:c||!a.trim(),children:n("auth","ssoButton")}),u&&o(D,{variant:"ghost",type:"button",onClick:e,children:n("auth","ssoRetry")})]})]})}function Ha({onPassword:t}){let{t:e}=V(),[n,a]=A(""),[r,i]=A(null),[s,c]=A(!1);return o("form",{className:"agi-chat__state agi-chat__auth",onSubmit:async u=>{u.preventDefault(),c(!0),i(null);let g=await t({password:n});c(!1),g||i(e("auth","invalidPassword"))},children:[o("h3",{children:e("auth","passwordTitle")}),o("p",{children:e("auth","passwordHint")}),o(le,{label:e("auth","password"),error:r??void 0,children:o(X,{type:"password",value:n,onChange:u=>a(u.target.value),required:!0,autoComplete:"current-password"})}),o(D,{variant:"signal",type:"submit",disabled:s||!n,children:e("auth","continue")})]})}function Da({onRequestCode:t,onVerifyCode:e}){let{t:n}=V(),[a,r]=A(""),[i,s]=A(""),[c,p]=A("email"),[u,g]=A(null),[h,l]=A(null),[d,f]=A(!1),w=async()=>{f(!0),g(null),l(null);let m=await t(a.trim());f(!1),m==="sent"?(p("code"),l(n("auth","codeSent"))):g(n("auth",m==="unauthorized"?"invalidEmail":"codeError"))},y=async()=>{f(!0),g(null),l(null);let m=await e(a.trim(),i.trim());f(!1),m||g(n("auth","invalidCode"))},k=m=>{m.preventDefault(),c==="email"?w():y()};return c==="code"?o("form",{className:"agi-chat__state agi-chat__auth",onSubmit:k,children:[o("h3",{children:n("auth","emailTitle")}),o("p",{children:[n("auth","codeHint")," ",o("strong",{children:a})]}),o(le,{label:n("auth","code"),error:u??void 0,hint:h??void 0,children:o(X,{inputMode:"numeric",autoComplete:"one-time-code",pattern:"[0-9]{6}",maxLength:6,value:i,onChange:m=>s(m.target.value.replace(/\D/g,"")),required:!0})}),o("div",{className:"agi-chat__auth-actions",children:[o(D,{variant:"signal",type:"submit",disabled:d||i.length!==6,children:n("auth","verify")}),o(D,{variant:"ghost",type:"button",disabled:d,onClick:()=>{w()},children:n("auth","resend")}),o(D,{variant:"ghost",type:"button",disabled:d,onClick:()=>{p("email"),s(""),g(null),l(null)},children:n("auth","back")})]})]}):o("form",{className:"agi-chat__state agi-chat__auth",onSubmit:k,children:[o("h3",{children:n("auth","emailTitle")}),o("p",{children:n("auth","emailHint")}),o(le,{label:n("auth","email"),error:u??void 0,children:o(X,{type:"email",value:a,onChange:m=>r(m.target.value),required:!0,autoComplete:"email"})}),o(D,{variant:"signal",type:"submit",disabled:d||!a.trim(),children:n("auth","sendCode")})]})}var Fn=`/* @aginies/tokens v0.1.0 \u2014 generated from src/tokens.ts. Do not edit by hand. */
|
|
11
13
|
|
|
12
14
|
/* Static tokens: type, shape, spacing, motion, layout. */
|
|
13
15
|
:root {
|
|
@@ -2394,5 +2396,5 @@
|
|
|
2394
2396
|
font-size: 10.5px;
|
|
2395
2397
|
color: var(--mute);
|
|
2396
2398
|
}
|
|
2397
|
-
`;function lt(t){return{render:function(e){Xt(e,t)},unmount:function(){tn(t)}}}var
|
|
2399
|
+
`;function lt(t){return{render:function(e){Xt(e,t)},unmount:function(){tn(t)}}}var ja="0.1.0",En="aginies-embed-styles",ce=null;function $a(){if(typeof document>"u"||document.getElementById(En))return;let t=document.createElement("style");t.id=En,t.textContent=Fn,document.head.appendChild(t)}function Rn(t){return $a(),ce=Ze(t),ce}function Pn(t){if(!ce)throw new Error("[aginies] call Aginies.init({ baseUrl, token }) before Aginies.chat()");let{container:e,mode:n="bubble",...a}=t,r=Nn(e,n),i=lt(r);return i.render(Y(Le,{client:ce,children:Y(st,{...a,mode:n})})),{element:r,unmount:()=>{i.unmount(),r.dataset.aginiesOwned==="true"&&r.remove()}}}function Tn(t){if(!ce)throw new Error("[aginies] call Aginies.init({ baseUrl, token }) before Aginies.approval()");let{container:e,...n}=t,a=Nn(e,"approval"),r=lt(a);return r.render(Y(Le,{client:ce,children:Y(Xe,n)})),{element:a,unmount:()=>{r.unmount(),a.dataset.aginiesOwned==="true"&&a.remove()}}}function Nn(t,e){if(t){let a=typeof t=="string"?document.querySelector(t):t;if(!a)throw new Error(`[aginies] container not found: ${String(t)}`);return a}let n=document.createElement("div");return n.dataset.aginiesOwned="true",n.dataset.aginiesMode=e,document.body.appendChild(n),n}function Mn(t=Va()){if(!t)return null;let e=t.dataset;if(!e.baseUrl||!e.token)return null;if(Rn({baseUrl:e.baseUrl,token:e.token,locale:e.locale==="tr"||e.locale==="en"?e.locale:void 0}),e.approval){let[a,r,i]=e.approval.split("/");if(!a||!r)return null;let s=()=>Tn({workflowId:a,executionId:r,contextId:i,container:e.container});return document.readyState==="loading"?(document.addEventListener("DOMContentLoaded",()=>s(),{once:!0}),null):s()}if(!e.chat)return null;let n=()=>Pn({identifier:e.chat,mode:e.mode??"bubble",position:e.position??"right",theme:e.theme??"auto",launcherLabel:e.label,container:e.container});return document.readyState==="loading"?(document.addEventListener("DOMContentLoaded",()=>n(),{once:!0}),null):n()}function Va(){return typeof document>"u"?null:document.currentScript??null}typeof window<"u"&&Mn();return qn(Wa);})();
|
|
2398
2400
|
//# sourceMappingURL=aginies.js.map
|