@iai-lib/any-chat-widget 0.1.0-alpha.20 → 0.1.0-alpha.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,60 +1,69 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(K,q){typeof exports=="object"&&typeof module<"u"?q(exports):typeof define=="function"&&define.amd?define(["exports"],q):(K=typeof globalThis<"u"?globalThis:K||self,q(K.AnyChatbot={}))})(this,function(K){"use strict";var or=(K,q,ie)=>{if(!q.has(K))throw TypeError("Cannot "+ie)};var Dn=(K,q,ie)=>(or(K,q,"read from private field"),ie?ie.call(K):q.get(K)),Ci=(K,q,ie)=>{if(q.has(K))throw TypeError("Cannot add the same private member more than once");q instanceof WeakSet?q.add(K):q.set(K,ie)},De=(K,q,ie,ot)=>(or(K,q,"write to private field"),ot?ot.call(K,ie):q.set(K,ie),ie);/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2019 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
-
*/const
|
|
5
|
+
*/var Se,st;const q=globalThis,ie=q.ShadowRoot&&(q.ShadyCSS===void 0||q.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ot=Symbol(),Ai=new WeakMap;let Ii=class{constructor(e,t,n){if(this._$cssResult$=!0,n!==ot)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(ie&&e===void 0){const n=t!==void 0&&t.length===1;n&&(e=Ai.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&Ai.set(t,e))}return e}toString(){return this.cssText}};const lr=i=>new Ii(typeof i=="string"?i:i+"",void 0,ot),Ue=(i,...e)=>{const t=i.length===1?i[0]:e.reduce((n,s,r)=>n+(a=>{if(a._$cssResult$===!0)return a.cssText;if(typeof a=="number")return a;throw Error("Value passed to 'css' function must be a 'css' function result: "+a+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+i[r+1],i[0]);return new Ii(t,i,ot)},cr=(i,e)=>{if(ie)i.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const t of e){const n=document.createElement("style"),s=q.litNonce;s!==void 0&&n.setAttribute("nonce",s),n.textContent=t.cssText,i.appendChild(n)}},Oi=ie?i=>i:i=>i instanceof CSSStyleSheet?(e=>{let t="";for(const n of e.cssRules)t+=n.cssText;return lr(t)})(i):i;/**
|
|
6
6
|
* @license
|
|
7
7
|
* Copyright 2017 Google LLC
|
|
8
8
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
9
|
-
*/const{is:
|
|
9
|
+
*/const{is:dr,defineProperty:hr,getOwnPropertyDescriptor:ur,getOwnPropertyNames:pr,getOwnPropertySymbols:mr,getPrototypeOf:fr}=Object,lt=globalThis,Mi=lt.trustedTypes,gr=Mi?Mi.emptyScript:"",Ri=lt.reactiveElementPolyfillSupport,xt=(i,e)=>i,en={toAttribute(i,e){switch(e){case Boolean:i=i?gr:null;break;case Object:case Array:i=i==null?i:JSON.stringify(i)}return i},fromAttribute(i,e){let t=i;switch(e){case Boolean:t=i!==null;break;case Number:t=i===null?null:Number(i);break;case Object:case Array:try{t=JSON.parse(i)}catch{t=null}}return t}},Un=(i,e)=>!dr(i,e),Pi={attribute:!0,type:String,converter:en,reflect:!1,hasChanged:Un};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),lt.litPropertyMetadata??(lt.litPropertyMetadata=new WeakMap);class ct extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=Pi){if(t.state&&(t.attribute=!1),this._$Ei(),this.elementProperties.set(e,t),!t.noAccessor){const n=Symbol(),s=this.getPropertyDescriptor(e,n,t);s!==void 0&&hr(this.prototype,e,s)}}static getPropertyDescriptor(e,t,n){const{get:s,set:r}=ur(this.prototype,e)??{get(){return this[t]},set(a){this[t]=a}};return{get(){return s==null?void 0:s.call(this)},set(a){const o=s==null?void 0:s.call(this);r.call(this,a),this.requestUpdate(e,o,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Pi}static _$Ei(){if(this.hasOwnProperty(xt("elementProperties")))return;const e=fr(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(xt("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(xt("properties"))){const t=this.properties,n=[...pr(t),...mr(t)];for(const s of n)this.createProperty(s,t[s])}const e=this[Symbol.metadata];if(e!==null){const t=litPropertyMetadata.get(e);if(t!==void 0)for(const[n,s]of t)this.elementProperties.set(n,s)}this._$Eh=new Map;for(const[t,n]of this.elementProperties){const s=this._$Eu(t,n);s!==void 0&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const n=new Set(e.flat(1/0).reverse());for(const s of n)t.unshift(Oi(s))}else e!==void 0&&t.push(Oi(e));return t}static _$Eu(e,t){const n=t.attribute;return n===!1?void 0:typeof n=="string"?n:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(t=>t(this))}addController(e){var t;(this._$EO??(this._$EO=new Set)).add(e),this.renderRoot!==void 0&&this.isConnected&&((t=e.hostConnected)==null||t.call(e))}removeController(e){var t;(t=this._$EO)==null||t.delete(e)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const n of t.keys())this.hasOwnProperty(n)&&(e.set(n,this[n]),delete this[n]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return cr(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$EO)==null||e.forEach(t=>{var n;return(n=t.hostConnected)==null?void 0:n.call(t)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$EO)==null||e.forEach(t=>{var n;return(n=t.hostDisconnected)==null?void 0:n.call(t)})}attributeChangedCallback(e,t,n){this._$AK(e,n)}_$EC(e,t){var n;const s=this.constructor.elementProperties.get(e),r=this.constructor._$Eu(e,s);if(r!==void 0&&s.reflect===!0){const a=(((n=s.converter)==null?void 0:n.toAttribute)!==void 0?s.converter:en).toAttribute(t,s.type);this._$Em=e,a==null?this.removeAttribute(r):this.setAttribute(r,a),this._$Em=null}}_$AK(e,t){var n;const s=this.constructor,r=s._$Eh.get(e);if(r!==void 0&&this._$Em!==r){const a=s.getPropertyOptions(r),o=typeof a.converter=="function"?{fromAttribute:a.converter}:((n=a.converter)==null?void 0:n.fromAttribute)!==void 0?a.converter:en;this._$Em=r,this[r]=o.fromAttribute(t,a.type),this._$Em=null}}requestUpdate(e,t,n){if(e!==void 0){if(n??(n=this.constructor.getPropertyOptions(e)),!(n.hasChanged??Un)(this[e],t))return;this.P(e,t,n)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(e,t,n){this._$AL.has(e)||this._$AL.set(e,t),n.reflect===!0&&this._$Em!==e&&(this._$Ej??(this._$Ej=new Set)).add(e)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var e;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[r,a]of this._$Ep)this[r]=a;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[r,a]of s)a.wrapped!==!0||this._$AL.has(r)||this[r]===void 0||this.P(r,this[r],a)}let t=!1;const n=this._$AL;try{t=this.shouldUpdate(n),t?(this.willUpdate(n),(e=this._$EO)==null||e.forEach(s=>{var r;return(r=s.hostUpdate)==null?void 0:r.call(s)}),this.update(n)):this._$EU()}catch(s){throw t=!1,this._$EU(),s}t&&this._$AE(n)}willUpdate(e){}_$AE(e){var t;(t=this._$EO)==null||t.forEach(n=>{var s;return(s=n.hostUpdated)==null?void 0:s.call(n)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Ej&&(this._$Ej=this._$Ej.forEach(t=>this._$EC(t,this[t]))),this._$EU()}updated(e){}firstUpdated(e){}}ct.elementStyles=[],ct.shadowRootOptions={mode:"open"},ct[xt("elementProperties")]=new Map,ct[xt("finalized")]=new Map,Ri==null||Ri({ReactiveElement:ct}),(lt.reactiveElementVersions??(lt.reactiveElementVersions=[])).push("2.0.4");/**
|
|
10
10
|
* @license
|
|
11
11
|
* Copyright 2017 Google LLC
|
|
12
12
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
13
|
-
*/const
|
|
14
|
-
\f\r]
|
|
15
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),
|
|
13
|
+
*/const tn=globalThis,nn=tn.trustedTypes,Ni=nn?nn.createPolicy("lit-html",{createHTML:i=>i}):void 0,Hn="$lit$",ke=`lit$${(Math.random()+"").slice(9)}$`,Bn="?"+ke,yr=`<${Bn}>`,He=document,kt=()=>He.createComment(""),_t=i=>i===null||typeof i!="object"&&typeof i!="function",ji=Array.isArray,zi=i=>ji(i)||typeof(i==null?void 0:i[Symbol.iterator])=="function",Wn=`[
|
|
14
|
+
\f\r]`,$t=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Zi=/-->/g,Li=/>/g,Be=RegExp(`>|${Wn}(?:([^\\s"'>=/]+)(${Wn}*=${Wn}*(?:[^
|
|
15
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),Di=/'/g,Ui=/"/g,Hi=/^(?:script|style|textarea|title)$/i,vr=i=>(e,...t)=>({_$litType$:i,strings:e,values:t}),z=vr(1),fe=Symbol.for("lit-noChange"),J=Symbol.for("lit-nothing"),Bi=new WeakMap,We=He.createTreeWalker(He,129);function Wi(i,e){if(!Array.isArray(i)||!i.hasOwnProperty("raw"))throw Error("invalid template strings array");return Ni!==void 0?Ni.createHTML(e):e}const Fi=(i,e)=>{const t=i.length-1,n=[];let s,r=e===2?"<svg>":"",a=$t;for(let o=0;o<t;o++){const l=i[o];let d,h,p=-1,c=0;for(;c<l.length&&(a.lastIndex=c,h=a.exec(l),h!==null);)c=a.lastIndex,a===$t?h[1]==="!--"?a=Zi:h[1]!==void 0?a=Li:h[2]!==void 0?(Hi.test(h[2])&&(s=RegExp("</"+h[2],"g")),a=Be):h[3]!==void 0&&(a=Be):a===Be?h[0]===">"?(a=s??$t,p=-1):h[1]===void 0?p=-2:(p=a.lastIndex-h[2].length,d=h[1],a=h[3]===void 0?Be:h[3]==='"'?Ui:Di):a===Ui||a===Di?a=Be:a===Zi||a===Li?a=$t:(a=Be,s=void 0);const f=a===Be&&i[o+1].startsWith("/>")?" ":"";r+=a===$t?l+yr:p>=0?(n.push(d),l.slice(0,p)+Hn+l.slice(p)+ke+f):l+ke+(p===-2?o:f)}return[Wi(i,r+(i[t]||"<?>")+(e===2?"</svg>":"")),n]};class Tt{constructor({strings:e,_$litType$:t},n){let s;this.parts=[];let r=0,a=0;const o=e.length-1,l=this.parts,[d,h]=Fi(e,t);if(this.el=Tt.createElement(d,n),We.currentNode=this.el.content,t===2){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(s=We.nextNode())!==null&&l.length<o;){if(s.nodeType===1){if(s.hasAttributes())for(const p of s.getAttributeNames())if(p.endsWith(Hn)){const c=h[a++],f=s.getAttribute(p).split(ke),O=/([.?@])?(.*)/.exec(c);l.push({type:1,index:r,name:O[2],strings:f,ctor:O[1]==="."?qi:O[1]==="?"?Ki:O[1]==="@"?Ji:Et}),s.removeAttribute(p)}else p.startsWith(ke)&&(l.push({type:6,index:r}),s.removeAttribute(p));if(Hi.test(s.tagName)){const p=s.textContent.split(ke),c=p.length-1;if(c>0){s.textContent=nn?nn.emptyScript:"";for(let f=0;f<c;f++)s.append(p[f],kt()),We.nextNode(),l.push({type:2,index:++r});s.append(p[c],kt())}}}else if(s.nodeType===8)if(s.data===Bn)l.push({type:2,index:r});else{let p=-1;for(;(p=s.data.indexOf(ke,p+1))!==-1;)l.push({type:7,index:r}),p+=ke.length-1}r++}}static createElement(e,t){const n=He.createElement("template");return n.innerHTML=e,n}}function Fe(i,e,t=i,n){var s,r;if(e===fe)return e;let a=n!==void 0?(s=t._$Co)==null?void 0:s[n]:t._$Cl;const o=_t(e)?void 0:e._$litDirective$;return(a==null?void 0:a.constructor)!==o&&((r=a==null?void 0:a._$AO)==null||r.call(a,!1),o===void 0?a=void 0:(a=new o(i),a._$AT(i,t,n)),n!==void 0?(t._$Co??(t._$Co=[]))[n]=a:t._$Cl=a),a!==void 0&&(e=Fe(i,a._$AS(i,e.values),a,n)),e}let Vi=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:n}=this._$AD,s=((e==null?void 0:e.creationScope)??He).importNode(t,!0);We.currentNode=s;let r=We.nextNode(),a=0,o=0,l=n[0];for(;l!==void 0;){if(a===l.index){let d;l.type===2?d=new dt(r,r.nextSibling,this,e):l.type===1?d=new l.ctor(r,l.name,l.strings,this,e):l.type===6&&(d=new Gi(r,this,e)),this._$AV.push(d),l=n[++o]}a!==(l==null?void 0:l.index)&&(r=We.nextNode(),a++)}return We.currentNode=He,s}p(e){let t=0;for(const n of this._$AV)n!==void 0&&(n.strings!==void 0?(n._$AI(e,n,t),t+=n.strings.length-2):n._$AI(e[t])),t++}};class dt{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,n,s){this.type=2,this._$AH=J,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=Fe(this,e,t),_t(e)?e===J||e==null||e===""?(this._$AH!==J&&this._$AR(),this._$AH=J):e!==this._$AH&&e!==fe&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):zi(e)?this.k(e):this._(e)}S(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.S(e))}_(e){this._$AH!==J&&_t(this._$AH)?this._$AA.nextSibling.data=e:this.T(He.createTextNode(e)),this._$AH=e}$(e){var t;const{values:n,_$litType$:s}=e,r=typeof s=="number"?this._$AC(e):(s.el===void 0&&(s.el=Tt.createElement(Wi(s.h,s.h[0]),this.options)),s);if(((t=this._$AH)==null?void 0:t._$AD)===r)this._$AH.p(n);else{const a=new Vi(r,this),o=a.u(this.options);a.p(n),this.T(o),this._$AH=a}}_$AC(e){let t=Bi.get(e.strings);return t===void 0&&Bi.set(e.strings,t=new Tt(e)),t}k(e){ji(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let n,s=0;for(const r of e)s===t.length?t.push(n=new dt(this.S(kt()),this.S(kt()),this,this.options)):n=t[s],n._$AI(r),s++;s<t.length&&(this._$AR(n&&n._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){var n;for((n=this._$AP)==null?void 0:n.call(this,!1,!0,t);e&&e!==this._$AB;){const s=e.nextSibling;e.remove(),e=s}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}}class Et{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,n,s,r){this.type=1,this._$AH=J,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=r,n.length>2||n[0]!==""||n[1]!==""?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=J}_$AI(e,t=this,n,s){const r=this.strings;let a=!1;if(r===void 0)e=Fe(this,e,t,0),a=!_t(e)||e!==this._$AH&&e!==fe,a&&(this._$AH=e);else{const o=e;let l,d;for(e=r[0],l=0;l<r.length-1;l++)d=Fe(this,o[n+l],t,l),d===fe&&(d=this._$AH[l]),a||(a=!_t(d)||d!==this._$AH[l]),d===J?e=J:e!==J&&(e+=(d??"")+r[l+1]),this._$AH[l]=d}a&&!s&&this.j(e)}j(e){e===J?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}let qi=class extends Et{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===J?void 0:e}};class Ki extends Et{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==J)}}let Ji=class extends Et{constructor(e,t,n,s,r){super(e,t,n,s,r),this.type=5}_$AI(e,t=this){if((e=Fe(this,e,t,0)??J)===fe)return;const n=this._$AH,s=e===J&&n!==J||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,r=e!==J&&(n===J||s);s&&this.element.removeEventListener(this.name,this,n),r&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t;typeof this._$AH=="function"?this._$AH.call(((t=this.options)==null?void 0:t.host)??this.element,e):this._$AH.handleEvent(e)}};class Gi{constructor(e,t,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){Fe(this,e)}}const br={P:Hn,A:ke,C:Bn,M:1,L:Fi,R:Vi,D:zi,V:Fe,I:dt,H:Et,N:Ki,U:Ji,B:qi,F:Gi},Qi=tn.litHtmlPolyfillSupport;Qi==null||Qi(Tt,dt),(tn.litHtmlVersions??(tn.litHtmlVersions=[])).push("3.1.2");const wr=(i,e,t)=>{const n=(t==null?void 0:t.renderBefore)??e;let s=n._$litPart$;if(s===void 0){const r=(t==null?void 0:t.renderBefore)??null;n._$litPart$=s=new dt(e.insertBefore(kt(),r),r,void 0,t??{})}return s._$AI(i),s};/**
|
|
16
16
|
* @license
|
|
17
17
|
* Copyright 2017 Google LLC
|
|
18
18
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
19
|
-
*/let se=class extends
|
|
19
|
+
*/let se=class extends ct{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var i;const e=super.createRenderRoot();return(i=this.renderOptions).renderBefore??(i.renderBefore=e.firstChild),e}update(i){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(i),this._$Do=wr(e,this.renderRoot,this.renderOptions)}connectedCallback(){var i;super.connectedCallback(),(i=this._$Do)==null||i.setConnected(!0)}disconnectedCallback(){var i;super.disconnectedCallback(),(i=this._$Do)==null||i.setConnected(!1)}render(){return fe}};var Yi;se._$litElement$=!0,se.finalized=!0,(Yi=globalThis.litElementHydrateSupport)==null||Yi.call(globalThis,{LitElement:se});const Xi=globalThis.litElementPolyfillSupport;Xi==null||Xi({LitElement:se}),(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.0.4");/**
|
|
20
20
|
* @license
|
|
21
21
|
* Copyright 2017 Google LLC
|
|
22
22
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
23
|
-
*/const
|
|
23
|
+
*/const _e=i=>(e,t)=>{t!==void 0?t.addInitializer(()=>{customElements.define(i,e)}):customElements.define(i,e)};/**
|
|
24
24
|
* @license
|
|
25
25
|
* Copyright 2017 Google LLC
|
|
26
26
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
27
|
-
*/const
|
|
27
|
+
*/const xr={attribute:!0,type:String,converter:en,reflect:!1,hasChanged:Un},kr=(i=xr,e,t)=>{const{kind:n,metadata:s}=t;let r=globalThis.litPropertyMetadata.get(s);if(r===void 0&&globalThis.litPropertyMetadata.set(s,r=new Map),r.set(t.name,i),n==="accessor"){const{name:a}=t;return{set(o){const l=e.get.call(this);e.set.call(this,o),this.requestUpdate(a,l,i)},init(o){return o!==void 0&&this.P(a,void 0,i),o}}}if(n==="setter"){const{name:a}=t;return function(o){const l=this[a];e.call(this,o),this.requestUpdate(a,l,i)}}throw Error("Unsupported decorator location: "+n)};function V(i){return(e,t)=>typeof t=="object"?kr(i,e,t):((n,s,r)=>{const a=s.hasOwnProperty(r);return s.constructor.createProperty(r,a?{...n,wrapped:!0}:n),a?Object.getOwnPropertyDescriptor(s,r):void 0})(i,e,t)}/**
|
|
28
28
|
* @license
|
|
29
29
|
* Copyright 2017 Google LLC
|
|
30
30
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
31
|
-
*/
|
|
31
|
+
*/const es=(i,e,t)=>(t.configurable=!0,t.enumerable=!0,Reflect.decorate&&typeof e!="object"&&Object.defineProperty(i,e,t),t);/**
|
|
32
32
|
* @license
|
|
33
33
|
* Copyright 2017 Google LLC
|
|
34
34
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
35
|
-
*/
|
|
35
|
+
*/function sn(i,e){return(t,n,s)=>{const r=a=>{var o;return((o=a.renderRoot)==null?void 0:o.querySelector(i))??null};if(e){const{get:a,set:o}=typeof n=="object"?t:s??(()=>{const l=Symbol();return{get(){return this[l]},set(d){this[l]=d}}})();return es(t,n,{get(){let l=a.call(this);return l===void 0&&(l=r(this),(l!==null||this.hasUpdated)&&o.call(this,l)),l}})}return es(t,n,{get(){return r(this)}})}}/**
|
|
36
36
|
* @license
|
|
37
37
|
* Copyright 2017 Google LLC
|
|
38
38
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
39
|
-
*/function Nn(s,e){return(t,i,n)=>{const r=a=>{var o;return((o=a.renderRoot)==null?void 0:o.querySelector(s))??null};if(e){const{get:a,set:o}=typeof i=="object"?t:n??(()=>{const c=Symbol();return{get(){return this[c]},set(l){this[c]=l}}})();return Ei(t,i,{get(){let c=a.call(this);return c===void 0&&(c=r(this),(c!==null||this.hasUpdated)&&o.call(this,c)),c}})}return Ei(t,i,{get(){return r(this)}})}}/**
|
|
39
|
+
*/const rn={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},an=i=>(...e)=>({_$litDirective$:i,values:e});class on{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,n){this._$Ct=e,this._$AM=t,this._$Ci=n}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}const $e=Ue`*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: \"\"}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol,\"Noto Color Emoji\";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,[type=button],[type=reset],[type=submit]{-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.container{width:100%}@media (min-width: 640px){.container{max-width:640px}}@media (min-width: 768px){.container{max-width:768px}}@media (min-width: 1024px){.container{max-width:1024px}}@media (min-width: 1280px){.container{max-width:1280px}}@media (min-width: 1536px){.container{max-width:1536px}}.visible{visibility:visible}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.inset-0{top:0;right:0;bottom:0;left:0}.bottom-0{bottom:0}.bottom-8{bottom:2rem}.left-0{left:0}.left-8{left:2rem}.right-0{right:0}.right-8{right:2rem}.top-0{top:0}.z-50{z-index:50}.m-0{margin:0}.m-0\\.5{margin:.125rem}.m-2{margin:.5rem}.mx-4{margin-left:1rem;margin-right:1rem}.mx-auto{margin-left:auto;margin-right:auto}.my-auto{margin-top:auto;margin-bottom:auto}.mb-1{margin-bottom:.25rem}.mb-\\[-8px\\]{margin-bottom:-8px}.ml-1{margin-left:.25rem}.ml-2{margin-left:.5rem}.ml-20{margin-left:5rem}.mr-2{margin-right:.5rem}.mr-20{margin-right:5rem}.mt-4{margin-top:1rem}.block{display:block}.inline-block{display:inline-block}.flex{display:flex}.hidden{display:none}.h-0{height:0px}.h-2{height:.5rem}.h-2\\.5{height:.625rem}.h-3\\/5{height:60%}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-9{height:2.25rem}.h-fit{height:-moz-fit-content;height:fit-content}.h-full{height:100%}.max-h-20{max-height:5rem}.max-h-\\[90vh\\]{max-height:90vh}.w-0{width:0px}.w-2{width:.5rem}.w-2\\.5{width:.625rem}.w-3\\/5{width:60%}.w-5{width:1.25rem}.w-fit{width:-moz-fit-content;width:fit-content}.w-full{width:100%}.max-w-\\[90vw\\]{max-width:90vw}.flex-1{flex:1 1 0%}.flex-grow{flex-grow:1}.cursor-pointer{cursor:pointer}.resize-none{resize:none}.resize{resize:both}.snap-x{scroll-snap-type:x var(--tw-scroll-snap-strictness)}.snap-mandatory{--tw-scroll-snap-strictness: mandatory}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.items-end{align-items:flex-end}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.5rem * var(--tw-space-x-reverse));margin-left:calc(.5rem * calc(1 - var(--tw-space-x-reverse)))}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.whitespace-pre-wrap{white-space:pre-wrap}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-t-lg{border-top-left-radius:.5rem;border-top-right-radius:.5rem}.border{border-width:1px}.border-x-8{border-left-width:8px;border-right-width:8px}.border-t-8{border-top-width:8px}.border-white{--tw-border-opacity: 1;border-color:rgb(255 255 255 / var(--tw-border-opacity))}.border-x-transparent{border-left-color:transparent;border-right-color:transparent}.bg-black{--tw-bg-opacity: 1;background-color:rgb(0 0 0 / var(--tw-bg-opacity))}.bg-gray-400{--tw-bg-opacity: 1;background-color:rgb(156 163 175 / var(--tw-bg-opacity))}.bg-gray-600{--tw-bg-opacity: 1;background-color:rgb(75 85 99 / var(--tw-bg-opacity))}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity))}.bg-opacity-50{--tw-bg-opacity: .5}.p-0{padding:0}.p-2{padding:.5rem}.p-4{padding:1rem}.p-5{padding:1.25rem}.px-0{padding-left:0;padding-right:0}.px-4{padding-left:1rem;padding-right:1rem}.px-8{padding-left:2rem;padding-right:2rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.pb-0{padding-bottom:0}.pb-8{padding-bottom:2rem}.text-center{text-align:center}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.font-semibold{font-weight:600}.text-gray-400{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity))}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-md{--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}:host{font-size:16px;line-height:1.2;color:#000;text-align:left;--iai-chat-i-primary-color: var(--iai-chat-primary-color, #0B64F4);--iai-chat-i-text-color: var(--iai-chat-text-color, #FFF);--iai-chat-i-header-bg: var(--iai-chat-header-background-color, var(--iai-chat-i-primary-color));--iai-chat-i-header-fg: var(--iai-chat-header-text-color, var(--iai-chat-i-text-color));--iai-chat-i-button-bg: var(--iai-chat-button-background-color, var(--iai-chat-i-primary-color));--iai-chat-i-button-fg: var(--iai-chat-button-text-color, var(--iai-chat-i-text-color));--iai-chat-i-message-user-bg: var(--iai-chat-messages-user-background-color, var(--iai-chat-i-primary-color));--iai-chat-i-message-user-fg: var(--iai-chat-messages-user-text-color, var(--iai-chat-i-text-color));--iai-chat-i-message-assistant-bg: var(--iai-chat-messages-assistant-background-color, #6B7280);--iai-chat-i-message-assistant-fg: var(--iai-chat-messages-assistant-text-color, var(--iai-chat-i-text-color));--iai-chat-i-ocb-bg: var(--iai-chat-open-chat-button-background-color, var(--iai-chat-i-primary-color));--iai-chat-i-ocb-fg: var(--iai-chat-open-chat-button-icon-color, var(--iai-chat-i-text-color));--iai-chat-i-iframe-modal-header-bg: var(--iai-chat-iframe-modal-background-color, var(--iai-chat-i-primary-color));--iai-chat-i-iframe-modal-header-fg: var(--iai-chat-iframe-modal-text-color, var(--iai-chat-i-text-color))}input{background-color:#fff}h1{font-size:1.5em}h2{font-size:1.17em}h3{font-size:1em}ol,ul{display:flex;flex-direction:column;padding:0;margin-left:20px;gap:8px}ol{list-style-type:decimal}.focus\\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.disabled\\:bg-gray-200:disabled{--tw-bg-opacity: 1;background-color:rgb(229 231 235 / var(--tw-bg-opacity))}.disabled\\:opacity-50:disabled{opacity:.5}@media (min-width: 768px){.md\\:bottom-8{bottom:2rem}.md\\:left-8{left:2rem}.md\\:right-8{right:2rem}.md\\:flex{display:flex}.md\\:h-\\[500px\\]{height:500px}.md\\:h-fit{height:-moz-fit-content;height:fit-content}.md\\:w-\\[350px\\]{width:350px}.md\\:w-fit{width:-moz-fit-content;width:fit-content}.md\\:p-0{padding:0}.md\\:px-0{padding-left:0;padding-right:0}.md\\:pb-0{padding-bottom:0}}`;/**
|
|
40
|
+
* @license
|
|
41
|
+
* Copyright 2020 Google LLC
|
|
42
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
43
|
+
*/const{I:_r}=br,ts=()=>document.createComment(""),St=(i,e,t)=>{var n;const s=i._$AA.parentNode,r=e===void 0?i._$AB:e._$AA;if(t===void 0){const a=s.insertBefore(ts(),r),o=s.insertBefore(ts(),r);t=new _r(a,o,i,i.options)}else{const a=t._$AB.nextSibling,o=t._$AM,l=o!==i;if(l){let d;(n=t._$AQ)==null||n.call(t,i),t._$AM=i,t._$AP!==void 0&&(d=i._$AU)!==o._$AU&&t._$AP(d)}if(a!==r||l){let d=t._$AA;for(;d!==a;){const h=d.nextSibling;s.insertBefore(d,r),d=h}}}return t},Ve=(i,e,t=i)=>(i._$AI(e,t),i),$r={},Tr=(i,e=$r)=>i._$AH=e,Er=i=>i._$AH,Fn=i=>{var e;(e=i._$AP)==null||e.call(i,!1,!0);let t=i._$AA;const n=i._$AB.nextSibling;for(;t!==n;){const s=t.nextSibling;t.remove(),t=s}};/**
|
|
44
|
+
* @license
|
|
45
|
+
* Copyright 2017 Google LLC
|
|
46
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
47
|
+
*/const ns=(i,e,t)=>{const n=new Map;for(let s=e;s<=t;s++)n.set(i[s],s);return n},is=an(class extends on{constructor(i){if(super(i),i.type!==rn.CHILD)throw Error("repeat() can only be used in text expressions")}dt(i,e,t){let n;t===void 0?t=e:e!==void 0&&(n=e);const s=[],r=[];let a=0;for(const o of i)s[a]=n?n(o,a):a,r[a]=t(o,a),a++;return{values:r,keys:s}}render(i,e,t){return this.dt(i,e,t).values}update(i,[e,t,n]){const s=Er(i),{values:r,keys:a}=this.dt(e,t,n);if(!Array.isArray(s))return this.ut=a,r;const o=this.ut??(this.ut=[]),l=[];let d,h,p=0,c=s.length-1,f=0,O=r.length-1;for(;p<=c&&f<=O;)if(s[p]===null)p++;else if(s[c]===null)c--;else if(o[p]===a[f])l[f]=Ve(s[p],r[f]),p++,f++;else if(o[c]===a[O])l[O]=Ve(s[c],r[O]),c--,O--;else if(o[p]===a[O])l[O]=Ve(s[p],r[O]),St(i,l[O+1],s[p]),p++,O--;else if(o[c]===a[f])l[f]=Ve(s[c],r[f]),St(i,s[p],s[c]),c--,f++;else if(d===void 0&&(d=ns(a,f,O),h=ns(o,p,c)),d.has(o[p]))if(d.has(o[c])){const H=h.get(a[f]),Q=H!==void 0?s[H]:null;if(Q===null){const Ze=St(i,s[p]);Ve(Ze,r[f]),l[f]=Ze}else l[f]=Ve(Q,r[f]),St(i,s[p],Q),s[H]=null;f++}else Fn(s[c]),c--;else Fn(s[p]),p++;for(;f<=O;){const H=St(i,l[O+1]);Ve(H,r[f]),l[f++]=H}for(;p<=c;){const H=s[p++];H!==null&&Fn(H)}return this.ut=a,Tr(i,l),fe}});var Sr=Object.defineProperty,Cr=(i,e,t)=>e in i?Sr(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,W=(i,e,t)=>(Cr(i,typeof e!="symbol"?e+"":e,t),t),Ar=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ss=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Vn=(i,e,t)=>(Ar(i,e,"access private method"),t);function Ir(i){if(Array.isArray(i)){for(var e=0,t=Array(i.length);e<i.length;e++)t[e]=i[e];return t}else return Array.from(i)}var qn=!1;if(typeof window<"u"){var rs={get passive(){qn=!0}};window.addEventListener("testPassive",null,rs),window.removeEventListener("testPassive",null,rs)}var ln=typeof window<"u"&&window.navigator&&window.navigator.platform&&(/iP(ad|hone|od)/.test(window.navigator.platform)||window.navigator.platform==="MacIntel"&&window.navigator.maxTouchPoints>1),qe=[],cn=!1,as=-1,Ct=void 0,Ke=void 0,At=void 0,os=function(i){return qe.some(function(e){return!!(e.options.allowTouchMove&&e.options.allowTouchMove(i))})},Kn=function(i){var e=i||window.event;return os(e.target)||e.touches.length>1?!0:(e.preventDefault&&e.preventDefault(),!1)},Or=function(i){if(At===void 0){var e=!!i&&i.reserveScrollBarGap===!0,t=window.innerWidth-document.documentElement.clientWidth;if(e&&t>0){var n=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"),10);At=document.body.style.paddingRight,document.body.style.paddingRight=n+t+"px"}}Ct===void 0&&(Ct=document.body.style.overflow,document.body.style.overflow="hidden")},Mr=function(){At!==void 0&&(document.body.style.paddingRight=At,At=void 0),Ct!==void 0&&(document.body.style.overflow=Ct,Ct=void 0)},Rr=function(){return window.requestAnimationFrame(function(){if(Ke===void 0){Ke={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left};var i=window,e=i.scrollY,t=i.scrollX,n=i.innerHeight;document.body.style.position="fixed",document.body.style.top=-e,document.body.style.left=-t,setTimeout(function(){return window.requestAnimationFrame(function(){var s=n-window.innerHeight;s&&e>=n&&(document.body.style.top=-(e+s))})},300)}})},Pr=function(){if(Ke!==void 0){var i=-parseInt(document.body.style.top,10),e=-parseInt(document.body.style.left,10);document.body.style.position=Ke.position,document.body.style.top=Ke.top,document.body.style.left=Ke.left,window.scrollTo(e,i),Ke=void 0}},Nr=function(i){return i?i.scrollHeight-i.scrollTop<=i.clientHeight:!1},jr=function(i,e){var t=i.targetTouches[0].clientY-as;return os(i.target)?!1:e&&e.scrollTop===0&&t>0||Nr(e)&&t<0?Kn(i):(i.stopPropagation(),!0)},zr=function(i,e){if(!i){console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.");return}if(!qe.some(function(n){return n.targetElement===i})){var t={targetElement:i,options:e||{}};qe=[].concat(Ir(qe),[t]),ln?Rr():Or(e),ln&&(i.ontouchstart=function(n){n.targetTouches.length===1&&(as=n.targetTouches[0].clientY)},i.ontouchmove=function(n){n.targetTouches.length===1&&jr(n,i)},cn||(document.addEventListener("touchmove",Kn,qn?{passive:!1}:void 0),cn=!0))}},ls=function(i){if(!i){console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.");return}qe=qe.filter(function(e){return e.targetElement!==i}),ln&&(i.ontouchstart=null,i.ontouchmove=null,cn&&qe.length===0&&(document.removeEventListener("touchmove",Kn,qn?{passive:!1}:void 0),cn=!1)),ln?Pr():Mr()};/**
|
|
40
48
|
* @license
|
|
41
49
|
* Copyright 2017 Google LLC
|
|
42
50
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
43
|
-
*/
|
|
51
|
+
*/function ht(i){return V({...i,state:!0,attribute:!1})}/**
|
|
44
52
|
* @license
|
|
45
53
|
* Copyright 2018 Google LLC
|
|
46
54
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
47
|
-
*/const
|
|
55
|
+
*/const cs=an(class extends on{constructor(i){var e;if(super(i),i.type!==rn.ATTRIBUTE||i.name!=="class"||((e=i.strings)==null?void 0:e.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(i){return" "+Object.keys(i).filter(e=>i[e]).join(" ")+" "}update(i,[e]){var t,n;if(this.st===void 0){this.st=new Set,i.strings!==void 0&&(this.nt=new Set(i.strings.join(" ").split(/\s/).filter(r=>r!=="")));for(const r in e)e[r]&&!((t=this.nt)!=null&&t.has(r))&&this.st.add(r);return this.render(e)}const s=i.element.classList;for(const r of this.st)r in e||(s.remove(r),this.st.delete(r));for(const r in e){const a=!!e[r];a===this.st.has(r)||(n=this.nt)!=null&&n.has(r)||(a?(s.add(r),this.st.add(r)):(s.remove(r),this.st.delete(r)))}return fe}});/**
|
|
48
56
|
* @license
|
|
49
57
|
* Copyright 2018 Google LLC
|
|
50
58
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
51
|
-
*/const Si="important",Pn=" !"+Si,rt=Gt(class extends Yt{constructor(s){var e;if(super(s),s.type!==qt.ATTRIBUTE||s.name!=="style"||((e=s.strings)==null?void 0:e.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(s){return Object.keys(s).reduce((e,t)=>{const i=s[t];return i==null?e:e+`${t=t.includes("-")?t:t.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`},"")}update(s,[e]){const{style:t}=s.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(e)),this.render(e);for(const i of this.ft)e[i]==null&&(this.ft.delete(i),i.includes("-")?t.removeProperty(i):t[i]=null);for(const i in e){const n=e[i];if(n!=null){this.ft.add(i);const r=typeof n=="string"&&n.endsWith(Pn);i.includes("-")||r?t.setProperty(i,r?n.slice(0,-11):n,r?Si:""):t[i]=n}}return ue}});var jn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ci(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Ts={};(function(s){function e(o){o&&o.options&&clearTimeout(o.options.timer)}function t(o,c,l,h){var m={timer:void 0,lastArgs:[]},d=function(){for(var w=this,N=[],H=0;H<arguments.length;H++)N[H]=arguments[H];m.lastArgs=N,m.timer?clearTimeout(m.timer):c&&l.apply(this,m.lastArgs),m.timer=setTimeout(function(){c||l.apply(w,m.lastArgs),m.timer=void 0},o)};return h&&(d=d.bind(h)),d.options=m,d}function i(o,c,l,h){var m;Object.defineProperty(l,h,{configurable:!0,enumerable:!1,get:function(){return m},set:function(d){m=t(o,c,d,this)}})}function n(o,c,l){var h=l.value;return l.value=t(o,c,h),l}function r(o,c){for(var l=[],h=2;h<arguments.length;h++)l[h-2]=arguments[h];if(l.length===0)throw new Error("function applied debounce decorator should be a method");if(l.length===1)throw new Error("method applied debounce decorator should have valid name");var m=l[0],d=l[1],w=l.length===3&&l[2]?l[2]:Object.getOwnPropertyDescriptor(m,d);if(w)return n(o,c,w);i(o,c,m,d)}function a(){for(var o=[],c=0;c<arguments.length;c++)o[c]=arguments[c];var l=500,h=!1;if(o.length&&(typeof o[0]=="number"||typeof o[0]=="object"&&o[0].leading!==void 0)){typeof o[0]=="number"&&(l=o[0]);var m=void 0;return typeof o[0]=="object"&&o[0].leading!==void 0&&(m=o[0]),1<o.length&&typeof o[1]=="object"&&o[1].leading!==void 0&&(m=o[1]),m&&(h=m.leading),function(){for(var d=[],w=0;w<arguments.length;w++)d[w]=arguments[w];return r.apply(void 0,[l,h].concat(d))}}return r.apply(void 0,[l,h].concat(o))}Object.defineProperty(s,"__esModule",{value:!0}),s.cancel=e,s.debounce=a})(Ts);var j;(function(s){s.assertEqual=n=>n;function e(n){}s.assertIs=e;function t(n){throw new Error}s.assertNever=t,s.arrayToEnum=n=>{const r={};for(const a of n)r[a]=a;return r},s.getValidEnumValues=n=>{const r=s.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),a={};for(const o of r)a[o]=n[o];return s.objectValues(a)},s.objectValues=n=>s.objectKeys(n).map(function(r){return n[r]}),s.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const r=[];for(const a in n)Object.prototype.hasOwnProperty.call(n,a)&&r.push(a);return r},s.find=(n,r)=>{for(const a of n)if(r(a))return a},s.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&isFinite(n)&&Math.floor(n)===n;function i(n,r=" | "){return n.map(a=>typeof a=="string"?`'${a}'`:a).join(r)}s.joinValues=i,s.jsonStringifyReplacer=(n,r)=>typeof r=="bigint"?r.toString():r})(j||(j={}));var Ss;(function(s){s.mergeShapes=(e,t)=>({...e,...t})})(Ss||(Ss={}));const f=j.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),$e=s=>{switch(typeof s){case"undefined":return f.undefined;case"string":return f.string;case"number":return isNaN(s)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(s)?f.array:s===null?f.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?f.promise:typeof Map<"u"&&s instanceof Map?f.map:typeof Set<"u"&&s instanceof Set?f.set:typeof Date<"u"&&s instanceof Date?f.date:f.object;default:return f.unknown}},p=j.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Rn=s=>JSON.stringify(s,null,2).replace(/"([^"]+)":/g,"$1:");class ie extends Error{constructor(e){super(),this.issues=[],this.addIssue=i=>{this.issues=[...this.issues,i]},this.addIssues=(i=[])=>{this.issues=[...this.issues,...i]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(r){return r.message},i={_errors:[]},n=r=>{for(const a of r.issues)if(a.code==="invalid_union")a.unionErrors.map(n);else if(a.code==="invalid_return_type")n(a.returnTypeError);else if(a.code==="invalid_arguments")n(a.argumentsError);else if(a.path.length===0)i._errors.push(t(a));else{let o=i,c=0;for(;c<a.path.length;){const l=a.path[c];c===a.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(a))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return n(this),i}toString(){return this.message}get message(){return JSON.stringify(this.issues,j.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},i=[];for(const n of this.issues)n.path.length>0?(t[n.path[0]]=t[n.path[0]]||[],t[n.path[0]].push(e(n))):i.push(e(n));return{formErrors:i,fieldErrors:t}}get formErrors(){return this.flatten()}}ie.create=s=>new ie(s);const kt=(s,e)=>{let t;switch(s.code){case p.invalid_type:s.received===f.undefined?t="Required":t=`Expected ${s.expected}, received ${s.received}`;break;case p.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(s.expected,j.jsonStringifyReplacer)}`;break;case p.unrecognized_keys:t=`Unrecognized key(s) in object: ${j.joinValues(s.keys,", ")}`;break;case p.invalid_union:t="Invalid input";break;case p.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${j.joinValues(s.options)}`;break;case p.invalid_enum_value:t=`Invalid enum value. Expected ${j.joinValues(s.options)}, received '${s.received}'`;break;case p.invalid_arguments:t="Invalid function arguments";break;case p.invalid_return_type:t="Invalid function return type";break;case p.invalid_date:t="Invalid date";break;case p.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(t=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?t=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?t=`Invalid input: must end with "${s.validation.endsWith}"`:j.assertNever(s.validation):s.validation!=="regex"?t=`Invalid ${s.validation}`:t="Invalid";break;case p.too_small:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:t="Invalid input";break;case p.too_big:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?t=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:t="Invalid input";break;case p.custom:t="Invalid input";break;case p.invalid_intersection_types:t="Intersection results could not be merged";break;case p.not_multiple_of:t=`Number must be a multiple of ${s.multipleOf}`;break;case p.not_finite:t="Number must be finite";break;default:t=e.defaultError,j.assertNever(s)}return{message:t}};let $i=kt;function Zn(s){$i=s}function Xt(){return $i}const Qt=s=>{const{data:e,path:t,errorMaps:i,issueData:n}=s,r=[...t,...n.path||[]],a={...n,path:r};let o="";const c=i.filter(l=>!!l).slice().reverse();for(const l of c)o=l(a,{data:e,defaultError:o}).message;return{...n,path:r,message:n.message||o}},Dn=[];function g(s,e){const t=Qt({issueData:e,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,Xt(),kt].filter(i=>!!i)});s.common.issues.push(t)}class q{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const i=[];for(const n of t){if(n.status==="aborted")return C;n.status==="dirty"&&e.dirty(),i.push(n.value)}return{status:e.value,value:i}}static async mergeObjectAsync(e,t){const i=[];for(const n of t)i.push({key:await n.key,value:await n.value});return q.mergeObjectSync(e,i)}static mergeObjectSync(e,t){const i={};for(const n of t){const{key:r,value:a}=n;if(r.status==="aborted"||a.status==="aborted")return C;r.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),r.value!=="__proto__"&&(typeof a.value<"u"||n.alwaysSet)&&(i[r.value]=a.value)}return{status:e.value,value:i}}}const C=Object.freeze({status:"aborted"}),Ai=s=>({status:"dirty",value:s}),Y=s=>({status:"valid",value:s}),Cs=s=>s.status==="aborted",$s=s=>s.status==="dirty",Et=s=>s.status==="valid",es=s=>typeof Promise<"u"&&s instanceof Promise;var _;(function(s){s.errToObj=e=>typeof e=="string"?{message:e}:e||{},s.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(_||(_={}));class he{constructor(e,t,i,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=i,this._key=n}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Oi=(s,e)=>{if(Et(e))return{success:!0,data:e.value};if(!s.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new ie(s.common.issues);return this._error=t,this._error}}};function $(s){if(!s)return{};const{errorMap:e,invalid_type_error:t,required_error:i,description:n}=s;if(e&&(t||i))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(r,a)=>r.code!=="invalid_type"?{message:a.defaultError}:typeof a.data>"u"?{message:i??a.defaultError}:{message:t??a.defaultError},description:n}}class I{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return $e(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:$e(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new q,ctx:{common:e.parent.common,data:e.data,parsedType:$e(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(es(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const i=this.safeParse(e,t);if(i.success)return i.data;throw i.error}safeParse(e,t){var i;const n={common:{issues:[],async:(i=t==null?void 0:t.async)!==null&&i!==void 0?i:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$e(e)},r=this._parseSync({data:e,path:n.path,parent:n});return Oi(n,r)}async parseAsync(e,t){const i=await this.safeParseAsync(e,t);if(i.success)return i.data;throw i.error}async safeParseAsync(e,t){const i={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$e(e)},n=this._parse({data:e,path:i.path,parent:i}),r=await(es(n)?n:Promise.resolve(n));return Oi(i,r)}refine(e,t){const i=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,r)=>{const a=e(n),o=()=>r.addIssue({code:p.custom,...i(n)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((i,n)=>e(i)?!0:(n.addIssue(typeof t=="function"?t(i,n):t),!1))}_refinement(e){return new ae({schema:this,typeName:T.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ve.create(this,this._def)}nullable(){return Ke.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return re.create(this,this._def)}promise(){return dt.create(this,this._def)}or(e){return $t.create([this,e],this._def)}and(e){return At.create(this,e,this._def)}transform(e){return new ae({...$(this._def),schema:this,typeName:T.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Pt({...$(this._def),innerType:this,defaultValue:t,typeName:T.ZodDefault})}brand(){return new Mi({typeName:T.ZodBranded,type:this,...$(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new as({...$(this._def),innerType:this,catchValue:t,typeName:T.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return jt.create(this,e)}readonly(){return cs.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Ln=/^c[^\s-]{8,}$/i,zn=/^[a-z][a-z0-9]*$/,Un=/^[0-9A-HJKMNP-TV-Z]{26}$/,Hn=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Bn=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Wn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let As;const Fn=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,Vn=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Kn=s=>s.precision?s.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${s.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${s.precision}}Z$`):s.precision===0?s.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):s.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function Jn(s,e){return!!((e==="v4"||!e)&&Fn.test(s)||(e==="v6"||!e)&&Vn.test(s))}class ne extends I{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){const n=this._getOrReturnCtx(e);return g(n,{code:p.invalid_type,expected:f.string,received:n.parsedType}),C}const t=new q;let i;for(const n of this._def.checks)if(n.kind==="min")e.data.length<n.value&&(i=this._getOrReturnCtx(e,i),g(i,{code:p.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if(n.kind==="max")e.data.length>n.value&&(i=this._getOrReturnCtx(e,i),g(i,{code:p.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if(n.kind==="length"){const r=e.data.length>n.value,a=e.data.length<n.value;(r||a)&&(i=this._getOrReturnCtx(e,i),r?g(i,{code:p.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):a&&g(i,{code:p.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),t.dirty())}else if(n.kind==="email")Bn.test(e.data)||(i=this._getOrReturnCtx(e,i),g(i,{validation:"email",code:p.invalid_string,message:n.message}),t.dirty());else if(n.kind==="emoji")As||(As=new RegExp(Wn,"u")),As.test(e.data)||(i=this._getOrReturnCtx(e,i),g(i,{validation:"emoji",code:p.invalid_string,message:n.message}),t.dirty());else if(n.kind==="uuid")Hn.test(e.data)||(i=this._getOrReturnCtx(e,i),g(i,{validation:"uuid",code:p.invalid_string,message:n.message}),t.dirty());else if(n.kind==="cuid")Ln.test(e.data)||(i=this._getOrReturnCtx(e,i),g(i,{validation:"cuid",code:p.invalid_string,message:n.message}),t.dirty());else if(n.kind==="cuid2")zn.test(e.data)||(i=this._getOrReturnCtx(e,i),g(i,{validation:"cuid2",code:p.invalid_string,message:n.message}),t.dirty());else if(n.kind==="ulid")Un.test(e.data)||(i=this._getOrReturnCtx(e,i),g(i,{validation:"ulid",code:p.invalid_string,message:n.message}),t.dirty());else if(n.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),g(i,{validation:"url",code:p.invalid_string,message:n.message}),t.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),g(i,{validation:"regex",code:p.invalid_string,message:n.message}),t.dirty())):n.kind==="trim"?e.data=e.data.trim():n.kind==="includes"?e.data.includes(n.value,n.position)||(i=this._getOrReturnCtx(e,i),g(i,{code:p.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),t.dirty()):n.kind==="toLowerCase"?e.data=e.data.toLowerCase():n.kind==="toUpperCase"?e.data=e.data.toUpperCase():n.kind==="startsWith"?e.data.startsWith(n.value)||(i=this._getOrReturnCtx(e,i),g(i,{code:p.invalid_string,validation:{startsWith:n.value},message:n.message}),t.dirty()):n.kind==="endsWith"?e.data.endsWith(n.value)||(i=this._getOrReturnCtx(e,i),g(i,{code:p.invalid_string,validation:{endsWith:n.value},message:n.message}),t.dirty()):n.kind==="datetime"?Kn(n).test(e.data)||(i=this._getOrReturnCtx(e,i),g(i,{code:p.invalid_string,validation:"datetime",message:n.message}),t.dirty()):n.kind==="ip"?Jn(e.data,n.version)||(i=this._getOrReturnCtx(e,i),g(i,{validation:"ip",code:p.invalid_string,message:n.message}),t.dirty()):j.assertNever(n);return{status:t.value,value:e.data}}_regex(e,t,i){return this.refinement(n=>e.test(n),{validation:t,code:p.invalid_string,..._.errToObj(i)})}_addCheck(e){return new ne({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",..._.errToObj(e)})}url(e){return this._addCheck({kind:"url",..._.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",..._.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",..._.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",..._.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",..._.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",..._.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",..._.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,..._.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,..._.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,..._.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,..._.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,..._.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,..._.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,..._.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,..._.errToObj(t)})}nonempty(e){return this.min(1,_.errToObj(e))}trim(){return new ne({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ne({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ne({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ne.create=s=>{var e;return new ne({checks:[],typeName:T.ZodString,coerce:(e=s==null?void 0:s.coerce)!==null&&e!==void 0?e:!1,...$(s)})};function qn(s,e){const t=(s.toString().split(".")[1]||"").length,i=(e.toString().split(".")[1]||"").length,n=t>i?t:i,r=parseInt(s.toFixed(n).replace(".","")),a=parseInt(e.toFixed(n).replace(".",""));return r%a/Math.pow(10,n)}class Ae extends I{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==f.number){const n=this._getOrReturnCtx(e);return g(n,{code:p.invalid_type,expected:f.number,received:n.parsedType}),C}let t;const i=new q;for(const n of this._def.checks)n.kind==="int"?j.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),g(t,{code:p.invalid_type,expected:"integer",received:"float",message:n.message}),i.dirty()):n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),g(t,{code:p.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),i.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),g(t,{code:p.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),i.dirty()):n.kind==="multipleOf"?qn(e.data,n.value)!==0&&(t=this._getOrReturnCtx(e,t),g(t,{code:p.not_multiple_of,multipleOf:n.value,message:n.message}),i.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),g(t,{code:p.not_finite,message:n.message}),i.dirty()):j.assertNever(n);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,_.toString(t))}gt(e,t){return this.setLimit("min",e,!1,_.toString(t))}lte(e,t){return this.setLimit("max",e,!0,_.toString(t))}lt(e,t){return this.setLimit("max",e,!1,_.toString(t))}setLimit(e,t,i,n){return new Ae({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:i,message:_.toString(n)}]})}_addCheck(e){return new Ae({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:_.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:_.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:_.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:_.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:_.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&j.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const i of this._def.checks){if(i.kind==="finite"||i.kind==="int"||i.kind==="multipleOf")return!0;i.kind==="min"?(t===null||i.value>t)&&(t=i.value):i.kind==="max"&&(e===null||i.value<e)&&(e=i.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Ae.create=s=>new Ae({checks:[],typeName:T.ZodNumber,coerce:(s==null?void 0:s.coerce)||!1,...$(s)});class Oe extends I{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==f.bigint){const n=this._getOrReturnCtx(e);return g(n,{code:p.invalid_type,expected:f.bigint,received:n.parsedType}),C}let t;const i=new q;for(const n of this._def.checks)n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),g(t,{code:p.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),i.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),g(t,{code:p.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),i.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),g(t,{code:p.not_multiple_of,multipleOf:n.value,message:n.message}),i.dirty()):j.assertNever(n);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,_.toString(t))}gt(e,t){return this.setLimit("min",e,!1,_.toString(t))}lte(e,t){return this.setLimit("max",e,!0,_.toString(t))}lt(e,t){return this.setLimit("max",e,!1,_.toString(t))}setLimit(e,t,i,n){return new Oe({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:i,message:_.toString(n)}]})}_addCheck(e){return new Oe({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:_.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Oe.create=s=>{var e;return new Oe({checks:[],typeName:T.ZodBigInt,coerce:(e=s==null?void 0:s.coerce)!==null&&e!==void 0?e:!1,...$(s)})};class Tt extends I{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){const t=this._getOrReturnCtx(e);return g(t,{code:p.invalid_type,expected:f.boolean,received:t.parsedType}),C}return Y(e.data)}}Tt.create=s=>new Tt({typeName:T.ZodBoolean,coerce:(s==null?void 0:s.coerce)||!1,...$(s)});class We extends I{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){const n=this._getOrReturnCtx(e);return g(n,{code:p.invalid_type,expected:f.date,received:n.parsedType}),C}if(isNaN(e.data.getTime())){const n=this._getOrReturnCtx(e);return g(n,{code:p.invalid_date}),C}const t=new q;let i;for(const n of this._def.checks)n.kind==="min"?e.data.getTime()<n.value&&(i=this._getOrReturnCtx(e,i),g(i,{code:p.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),t.dirty()):n.kind==="max"?e.data.getTime()>n.value&&(i=this._getOrReturnCtx(e,i),g(i,{code:p.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),t.dirty()):j.assertNever(n);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new We({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:_.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:_.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}We.create=s=>new We({checks:[],coerce:(s==null?void 0:s.coerce)||!1,typeName:T.ZodDate,...$(s)});class ts extends I{_parse(e){if(this._getType(e)!==f.symbol){const t=this._getOrReturnCtx(e);return g(t,{code:p.invalid_type,expected:f.symbol,received:t.parsedType}),C}return Y(e.data)}}ts.create=s=>new ts({typeName:T.ZodSymbol,...$(s)});class St extends I{_parse(e){if(this._getType(e)!==f.undefined){const t=this._getOrReturnCtx(e);return g(t,{code:p.invalid_type,expected:f.undefined,received:t.parsedType}),C}return Y(e.data)}}St.create=s=>new St({typeName:T.ZodUndefined,...$(s)});class Ct extends I{_parse(e){if(this._getType(e)!==f.null){const t=this._getOrReturnCtx(e);return g(t,{code:p.invalid_type,expected:f.null,received:t.parsedType}),C}return Y(e.data)}}Ct.create=s=>new Ct({typeName:T.ZodNull,...$(s)});class at extends I{constructor(){super(...arguments),this._any=!0}_parse(e){return Y(e.data)}}at.create=s=>new at({typeName:T.ZodAny,...$(s)});class Fe extends I{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Y(e.data)}}Fe.create=s=>new Fe({typeName:T.ZodUnknown,...$(s)});class ye extends I{_parse(e){const t=this._getOrReturnCtx(e);return g(t,{code:p.invalid_type,expected:f.never,received:t.parsedType}),C}}ye.create=s=>new ye({typeName:T.ZodNever,...$(s)});class ss extends I{_parse(e){if(this._getType(e)!==f.undefined){const t=this._getOrReturnCtx(e);return g(t,{code:p.invalid_type,expected:f.void,received:t.parsedType}),C}return Y(e.data)}}ss.create=s=>new ss({typeName:T.ZodVoid,...$(s)});class re extends I{_parse(e){const{ctx:t,status:i}=this._processInputParams(e),n=this._def;if(t.parsedType!==f.array)return g(t,{code:p.invalid_type,expected:f.array,received:t.parsedType}),C;if(n.exactLength!==null){const a=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;(a||o)&&(g(t,{code:a?p.too_big:p.too_small,minimum:o?n.exactLength.value:void 0,maximum:a?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),i.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(g(t,{code:p.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),i.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(g(t,{code:p.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),i.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>n.type._parseAsync(new he(t,a,t.path,o)))).then(a=>q.mergeArray(i,a));const r=[...t.data].map((a,o)=>n.type._parseSync(new he(t,a,t.path,o)));return q.mergeArray(i,r)}get element(){return this._def.type}min(e,t){return new re({...this._def,minLength:{value:e,message:_.toString(t)}})}max(e,t){return new re({...this._def,maxLength:{value:e,message:_.toString(t)}})}length(e,t){return new re({...this._def,exactLength:{value:e,message:_.toString(t)}})}nonempty(e){return this.min(1,e)}}re.create=(s,e)=>new re({type:s,minLength:null,maxLength:null,exactLength:null,typeName:T.ZodArray,...$(e)});function ot(s){if(s instanceof U){const e={};for(const t in s.shape){const i=s.shape[t];e[t]=ve.create(ot(i))}return new U({...s._def,shape:()=>e})}else return s instanceof re?new re({...s._def,type:ot(s.element)}):s instanceof ve?ve.create(ot(s.unwrap())):s instanceof Ke?Ke.create(ot(s.unwrap())):s instanceof pe?pe.create(s.items.map(e=>ot(e))):s}class U extends I{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=j.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==f.object){const c=this._getOrReturnCtx(e);return g(c,{code:p.invalid_type,expected:f.object,received:c.parsedType}),C}const{status:t,ctx:i}=this._processInputParams(e),{shape:n,keys:r}=this._getCached(),a=[];if(!(this._def.catchall instanceof ye&&this._def.unknownKeys==="strip"))for(const c in i.data)r.includes(c)||a.push(c);const o=[];for(const c of r){const l=n[c],h=i.data[c];o.push({key:{status:"valid",value:c},value:l._parse(new he(i,h,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof ye){const c=this._def.unknownKeys;if(c==="passthrough")for(const l of a)o.push({key:{status:"valid",value:l},value:{status:"valid",value:i.data[l]}});else if(c==="strict")a.length>0&&(g(i,{code:p.unrecognized_keys,keys:a}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const l of a){const h=i.data[l];o.push({key:{status:"valid",value:l},value:c._parse(new he(i,h,i.path,l)),alwaysSet:l in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of o){const h=await l.key;c.push({key:h,value:await l.value,alwaysSet:l.alwaysSet})}return c}).then(c=>q.mergeObjectSync(t,c)):q.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return _.errToObj,new U({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,i)=>{var n,r,a,o;const c=(a=(r=(n=this._def).errorMap)===null||r===void 0?void 0:r.call(n,t,i).message)!==null&&a!==void 0?a:i.defaultError;return t.code==="unrecognized_keys"?{message:(o=_.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new U({...this._def,unknownKeys:"strip"})}passthrough(){return new U({...this._def,unknownKeys:"passthrough"})}extend(e){return new U({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new U({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:T.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new U({...this._def,catchall:e})}pick(e){const t={};return j.objectKeys(e).forEach(i=>{e[i]&&this.shape[i]&&(t[i]=this.shape[i])}),new U({...this._def,shape:()=>t})}omit(e){const t={};return j.objectKeys(this.shape).forEach(i=>{e[i]||(t[i]=this.shape[i])}),new U({...this._def,shape:()=>t})}deepPartial(){return ot(this)}partial(e){const t={};return j.objectKeys(this.shape).forEach(i=>{const n=this.shape[i];e&&!e[i]?t[i]=n:t[i]=n.optional()}),new U({...this._def,shape:()=>t})}required(e){const t={};return j.objectKeys(this.shape).forEach(i=>{if(e&&!e[i])t[i]=this.shape[i];else{let n=this.shape[i];for(;n instanceof ve;)n=n._def.innerType;t[i]=n}}),new U({...this._def,shape:()=>t})}keyof(){return Ii(j.objectKeys(this.shape))}}U.create=(s,e)=>new U({shape:()=>s,unknownKeys:"strip",catchall:ye.create(),typeName:T.ZodObject,...$(e)}),U.strictCreate=(s,e)=>new U({shape:()=>s,unknownKeys:"strict",catchall:ye.create(),typeName:T.ZodObject,...$(e)}),U.lazycreate=(s,e)=>new U({shape:s,unknownKeys:"strip",catchall:ye.create(),typeName:T.ZodObject,...$(e)});class $t extends I{_parse(e){const{ctx:t}=this._processInputParams(e),i=this._def.options;function n(r){for(const o of r)if(o.result.status==="valid")return o.result;for(const o of r)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=r.map(o=>new ie(o.ctx.common.issues));return g(t,{code:p.invalid_union,unionErrors:a}),C}if(t.common.async)return Promise.all(i.map(async r=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await r._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(n);{let r;const a=[];for(const c of i){const l={...t,common:{...t.common,issues:[]},parent:null},h=c._parseSync({data:t.data,path:t.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!r&&(r={result:h,ctx:l}),l.common.issues.length&&a.push(l.common.issues)}if(r)return t.common.issues.push(...r.ctx.common.issues),r.result;const o=a.map(c=>new ie(c));return g(t,{code:p.invalid_union,unionErrors:o}),C}}get options(){return this._def.options}}$t.create=(s,e)=>new $t({options:s,typeName:T.ZodUnion,...$(e)});const is=s=>s instanceof It?is(s.schema):s instanceof ae?is(s.innerType()):s instanceof Mt?[s.value]:s instanceof Ie?s.options:s instanceof Nt?Object.keys(s.enum):s instanceof Pt?is(s._def.innerType):s instanceof St?[void 0]:s instanceof Ct?[null]:null;class ns extends I{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.object)return g(t,{code:p.invalid_type,expected:f.object,received:t.parsedType}),C;const i=this.discriminator,n=t.data[i],r=this.optionsMap.get(n);return r?t.common.async?r._parseAsync({data:t.data,path:t.path,parent:t}):r._parseSync({data:t.data,path:t.path,parent:t}):(g(t,{code:p.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[i]}),C)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,i){const n=new Map;for(const r of t){const a=is(r.shape[e]);if(!a)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,r)}}return new ns({typeName:T.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...$(i)})}}function Os(s,e){const t=$e(s),i=$e(e);if(s===e)return{valid:!0,data:s};if(t===f.object&&i===f.object){const n=j.objectKeys(e),r=j.objectKeys(s).filter(o=>n.indexOf(o)!==-1),a={...s,...e};for(const o of r){const c=Os(s[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===f.array&&i===f.array){if(s.length!==e.length)return{valid:!1};const n=[];for(let r=0;r<s.length;r++){const a=s[r],o=e[r],c=Os(a,o);if(!c.valid)return{valid:!1};n.push(c.data)}return{valid:!0,data:n}}else return t===f.date&&i===f.date&&+s==+e?{valid:!0,data:s}:{valid:!1}}class At extends I{_parse(e){const{status:t,ctx:i}=this._processInputParams(e),n=(r,a)=>{if(Cs(r)||Cs(a))return C;const o=Os(r.value,a.value);return o.valid?(($s(r)||$s(a))&&t.dirty(),{status:t.value,value:o.data}):(g(i,{code:p.invalid_intersection_types}),C)};return i.common.async?Promise.all([this._def.left._parseAsync({data:i.data,path:i.path,parent:i}),this._def.right._parseAsync({data:i.data,path:i.path,parent:i})]).then(([r,a])=>n(r,a)):n(this._def.left._parseSync({data:i.data,path:i.path,parent:i}),this._def.right._parseSync({data:i.data,path:i.path,parent:i}))}}At.create=(s,e,t)=>new At({left:s,right:e,typeName:T.ZodIntersection,...$(t)});class pe extends I{_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==f.array)return g(i,{code:p.invalid_type,expected:f.array,received:i.parsedType}),C;if(i.data.length<this._def.items.length)return g(i,{code:p.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),C;!this._def.rest&&i.data.length>this._def.items.length&&(g(i,{code:p.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...i.data].map((r,a)=>{const o=this._def.items[a]||this._def.rest;return o?o._parse(new he(i,r,i.path,a)):null}).filter(r=>!!r);return i.common.async?Promise.all(n).then(r=>q.mergeArray(t,r)):q.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new pe({...this._def,rest:e})}}pe.create=(s,e)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new pe({items:s,typeName:T.ZodTuple,rest:null,...$(e)})};class Ot extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==f.object)return g(i,{code:p.invalid_type,expected:f.object,received:i.parsedType}),C;const n=[],r=this._def.keyType,a=this._def.valueType;for(const o in i.data)n.push({key:r._parse(new he(i,o,i.path,o)),value:a._parse(new he(i,i.data[o],i.path,o))});return i.common.async?q.mergeObjectAsync(t,n):q.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,i){return t instanceof I?new Ot({keyType:e,valueType:t,typeName:T.ZodRecord,...$(i)}):new Ot({keyType:ne.create(),valueType:e,typeName:T.ZodRecord,...$(t)})}}class rs extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==f.map)return g(i,{code:p.invalid_type,expected:f.map,received:i.parsedType}),C;const n=this._def.keyType,r=this._def.valueType,a=[...i.data.entries()].map(([o,c],l)=>({key:n._parse(new he(i,o,i.path,[l,"key"])),value:r._parse(new he(i,c,i.path,[l,"value"]))}));if(i.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const l=await c.key,h=await c.value;if(l.status==="aborted"||h.status==="aborted")return C;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const l=c.key,h=c.value;if(l.status==="aborted"||h.status==="aborted")return C;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}}}}rs.create=(s,e,t)=>new rs({valueType:e,keyType:s,typeName:T.ZodMap,...$(t)});class Ve extends I{_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.parsedType!==f.set)return g(i,{code:p.invalid_type,expected:f.set,received:i.parsedType}),C;const n=this._def;n.minSize!==null&&i.data.size<n.minSize.value&&(g(i,{code:p.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&i.data.size>n.maxSize.value&&(g(i,{code:p.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const r=this._def.valueType;function a(c){const l=new Set;for(const h of c){if(h.status==="aborted")return C;h.status==="dirty"&&t.dirty(),l.add(h.value)}return{status:t.value,value:l}}const o=[...i.data.values()].map((c,l)=>r._parse(new he(i,c,i.path,l)));return i.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new Ve({...this._def,minSize:{value:e,message:_.toString(t)}})}max(e,t){return new Ve({...this._def,maxSize:{value:e,message:_.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Ve.create=(s,e)=>new Ve({valueType:s,minSize:null,maxSize:null,typeName:T.ZodSet,...$(e)});class ct extends I{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.function)return g(t,{code:p.invalid_type,expected:f.function,received:t.parsedType}),C;function i(o,c){return Qt({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Xt(),kt].filter(l=>!!l),issueData:{code:p.invalid_arguments,argumentsError:c}})}function n(o,c){return Qt({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Xt(),kt].filter(l=>!!l),issueData:{code:p.invalid_return_type,returnTypeError:c}})}const r={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof dt){const o=this;return Y(async function(...c){const l=new ie([]),h=await o._def.args.parseAsync(c,r).catch(d=>{throw l.addIssue(i(c,d)),l}),m=await Reflect.apply(a,this,h);return await o._def.returns._def.type.parseAsync(m,r).catch(d=>{throw l.addIssue(n(m,d)),l})})}else{const o=this;return Y(function(...c){const l=o._def.args.safeParse(c,r);if(!l.success)throw new ie([i(c,l.error)]);const h=Reflect.apply(a,this,l.data),m=o._def.returns.safeParse(h,r);if(!m.success)throw new ie([n(h,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ct({...this._def,args:pe.create(e).rest(Fe.create())})}returns(e){return new ct({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,i){return new ct({args:e||pe.create([]).rest(Fe.create()),returns:t||Fe.create(),typeName:T.ZodFunction,...$(i)})}}class It extends I{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}It.create=(s,e)=>new It({getter:s,typeName:T.ZodLazy,...$(e)});class Mt extends I{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return g(t,{received:t.data,code:p.invalid_literal,expected:this._def.value}),C}return{status:"valid",value:e.data}}get value(){return this._def.value}}Mt.create=(s,e)=>new Mt({value:s,typeName:T.ZodLiteral,...$(e)});function Ii(s,e){return new Ie({values:s,typeName:T.ZodEnum,...$(e)})}class Ie extends I{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),i=this._def.values;return g(t,{expected:j.joinValues(i),received:t.parsedType,code:p.invalid_type}),C}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),i=this._def.values;return g(t,{received:t.data,code:p.invalid_enum_value,options:i}),C}return Y(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return Ie.create(e)}exclude(e){return Ie.create(this.options.filter(t=>!e.includes(t)))}}Ie.create=Ii;class Nt extends I{_parse(e){const t=j.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(e);if(i.parsedType!==f.string&&i.parsedType!==f.number){const n=j.objectValues(t);return g(i,{expected:j.joinValues(n),received:i.parsedType,code:p.invalid_type}),C}if(t.indexOf(e.data)===-1){const n=j.objectValues(t);return g(i,{received:i.data,code:p.invalid_enum_value,options:n}),C}return Y(e.data)}get enum(){return this._def.values}}Nt.create=(s,e)=>new Nt({values:s,typeName:T.ZodNativeEnum,...$(e)});class dt extends I{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.promise&&t.common.async===!1)return g(t,{code:p.invalid_type,expected:f.promise,received:t.parsedType}),C;const i=t.parsedType===f.promise?t.data:Promise.resolve(t.data);return Y(i.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}}dt.create=(s,e)=>new dt({type:s,typeName:T.ZodPromise,...$(e)});class ae extends I{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===T.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:i}=this._processInputParams(e),n=this._def.effect||null,r={addIssue:a=>{g(i,a),a.fatal?t.abort():t.dirty()},get path(){return i.path}};if(r.addIssue=r.addIssue.bind(r),n.type==="preprocess"){const a=n.transform(i.data,r);return i.common.issues.length?{status:"dirty",value:i.data}:i.common.async?Promise.resolve(a).then(o=>this._def.schema._parseAsync({data:o,path:i.path,parent:i})):this._def.schema._parseSync({data:a,path:i.path,parent:i})}if(n.type==="refinement"){const a=o=>{const c=n.refinement(o,r);if(i.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(i.common.async===!1){const o=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});return o.status==="aborted"?C:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(o=>o.status==="aborted"?C:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(n.type==="transform")if(i.common.async===!1){const a=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});if(!Et(a))return a;const o=n.transform(a.value,r);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(a=>Et(a)?Promise.resolve(n.transform(a.value,r)).then(o=>({status:t.value,value:o})):a);j.assertNever(n)}}ae.create=(s,e,t)=>new ae({schema:s,typeName:T.ZodEffects,effect:e,...$(t)}),ae.createWithPreprocess=(s,e,t)=>new ae({schema:e,effect:{type:"preprocess",transform:s},typeName:T.ZodEffects,...$(t)});class ve extends I{_parse(e){return this._getType(e)===f.undefined?Y(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ve.create=(s,e)=>new ve({innerType:s,typeName:T.ZodOptional,...$(e)});class Ke extends I{_parse(e){return this._getType(e)===f.null?Y(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ke.create=(s,e)=>new Ke({innerType:s,typeName:T.ZodNullable,...$(e)});class Pt extends I{_parse(e){const{ctx:t}=this._processInputParams(e);let i=t.data;return t.parsedType===f.undefined&&(i=this._def.defaultValue()),this._def.innerType._parse({data:i,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Pt.create=(s,e)=>new Pt({innerType:s,typeName:T.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...$(e)});class as extends I{_parse(e){const{ctx:t}=this._processInputParams(e),i={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:i.data,path:i.path,parent:{...i}});return es(n)?n.then(r=>({status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new ie(i.common.issues)},input:i.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new ie(i.common.issues)},input:i.data})}}removeCatch(){return this._def.innerType}}as.create=(s,e)=>new as({innerType:s,typeName:T.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...$(e)});class os extends I{_parse(e){if(this._getType(e)!==f.nan){const t=this._getOrReturnCtx(e);return g(t,{code:p.invalid_type,expected:f.nan,received:t.parsedType}),C}return{status:"valid",value:e.data}}}os.create=s=>new os({typeName:T.ZodNaN,...$(s)});const Gn=Symbol("zod_brand");class Mi extends I{_parse(e){const{ctx:t}=this._processInputParams(e),i=t.data;return this._def.type._parse({data:i,path:t.path,parent:t})}unwrap(){return this._def.type}}class jt extends I{_parse(e){const{status:t,ctx:i}=this._processInputParams(e);if(i.common.async)return(async()=>{const n=await this._def.in._parseAsync({data:i.data,path:i.path,parent:i});return n.status==="aborted"?C:n.status==="dirty"?(t.dirty(),Ai(n.value)):this._def.out._parseAsync({data:n.value,path:i.path,parent:i})})();{const n=this._def.in._parseSync({data:i.data,path:i.path,parent:i});return n.status==="aborted"?C:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:i.path,parent:i})}}static create(e,t){return new jt({in:e,out:t,typeName:T.ZodPipeline})}}class cs extends I{_parse(e){const t=this._def.innerType._parse(e);return Et(t)&&(t.value=Object.freeze(t.value)),t}}cs.create=(s,e)=>new cs({innerType:s,typeName:T.ZodReadonly,...$(e)});const Ni=(s,e={},t)=>s?at.create().superRefine((i,n)=>{var r,a;if(!s(i)){const o=typeof e=="function"?e(i):typeof e=="string"?{message:e}:e,c=(a=(r=o.fatal)!==null&&r!==void 0?r:t)!==null&&a!==void 0?a:!0,l=typeof o=="string"?{message:o}:o;n.addIssue({code:"custom",...l,fatal:c})}}):at.create(),Yn={object:U.lazycreate};var T;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly"})(T||(T={}));const Xn=(s,e={message:`Input not instance of ${s.name}`})=>Ni(t=>t instanceof s,e),Pi=ne.create,ji=Ae.create,Qn=os.create,er=Oe.create,Ri=Tt.create,tr=We.create,sr=ts.create,ir=St.create,nr=Ct.create,rr=at.create,ar=Fe.create,or=ye.create,cr=ss.create,dr=re.create,lr=U.create,ur=U.strictCreate,hr=$t.create,pr=ns.create,mr=At.create,fr=pe.create,gr=Ot.create,yr=rs.create,vr=Ve.create,br=ct.create,wr=It.create,_r=Mt.create,xr=Ie.create,kr=Nt.create,Er=dt.create,Zi=ae.create,Tr=ve.create,Sr=Ke.create,Cr=ae.createWithPreprocess,$r=jt.create;var b=Object.freeze({__proto__:null,defaultErrorMap:kt,setErrorMap:Zn,getErrorMap:Xt,makeIssue:Qt,EMPTY_PATH:Dn,addIssueToContext:g,ParseStatus:q,INVALID:C,DIRTY:Ai,OK:Y,isAborted:Cs,isDirty:$s,isValid:Et,isAsync:es,get util(){return j},get objectUtil(){return Ss},ZodParsedType:f,getParsedType:$e,ZodType:I,ZodString:ne,ZodNumber:Ae,ZodBigInt:Oe,ZodBoolean:Tt,ZodDate:We,ZodSymbol:ts,ZodUndefined:St,ZodNull:Ct,ZodAny:at,ZodUnknown:Fe,ZodNever:ye,ZodVoid:ss,ZodArray:re,ZodObject:U,ZodUnion:$t,ZodDiscriminatedUnion:ns,ZodIntersection:At,ZodTuple:pe,ZodRecord:Ot,ZodMap:rs,ZodSet:Ve,ZodFunction:ct,ZodLazy:It,ZodLiteral:Mt,ZodEnum:Ie,ZodNativeEnum:Nt,ZodPromise:dt,ZodEffects:ae,ZodTransformer:ae,ZodOptional:ve,ZodNullable:Ke,ZodDefault:Pt,ZodCatch:as,ZodNaN:os,BRAND:Gn,ZodBranded:Mi,ZodPipeline:jt,ZodReadonly:cs,custom:Ni,Schema:I,ZodSchema:I,late:Yn,get ZodFirstPartyTypeKind(){return T},coerce:{string:s=>ne.create({...s,coerce:!0}),number:s=>Ae.create({...s,coerce:!0}),boolean:s=>Tt.create({...s,coerce:!0}),bigint:s=>Oe.create({...s,coerce:!0}),date:s=>We.create({...s,coerce:!0})},any:rr,array:dr,bigint:er,boolean:Ri,date:tr,discriminatedUnion:pr,effect:Zi,enum:xr,function:br,instanceof:Xn,intersection:mr,lazy:wr,literal:_r,map:yr,nan:Qn,nativeEnum:kr,never:or,null:nr,nullable:Sr,number:ji,object:lr,oboolean:()=>Ri().optional(),onumber:()=>ji().optional(),optional:Tr,ostring:()=>Pi().optional(),pipeline:$r,preprocess:Cr,promise:Er,record:gr,set:vr,strictObject:ur,string:Pi,symbol:sr,transformer:Zi,tuple:fr,undefined:ir,union:hr,unknown:ar,void:cr,NEVER:C,ZodIssueCode:p,quotelessJson:Rn,ZodError:ie});const ds=b.object({assistantId:b.string(),params:b.record(b.any()).default({}),config:b.object({historyKey:b.string().refine(s=>s.replace(/-/g,"_")).nullable().default("main"),welcomeMessage:b.string().default("Hello! How can I help you today?"),inactivityWarningMessage:b.string().default("Are you still there? The chat will end soon if we don't hear from you."),chatEndedMessage:b.string().default("The chat has ended. Please restart the chat to continue."),initialReplyMessage:b.string().nullable().default(null),simulateDelays:b.boolean().default(!0),placement:b.enum(["left","right"]).default("right"),openChatButton:b.object({imageSrc:b.string().optional(),width:b.union([b.string(),b.number()]).default("48px"),height:b.union([b.string(),b.number()]).default("48px"),cta:b.string().optional()}).default({}),chatWindow:b.object({header:b.object({text:b.string().nullable().default("AI Chat"),imageSrc:b.string().optional()}).default({}),showCloseButton:b.boolean().default(!0)}).default({}),styles:b.object({primaryColor:b.string().optional(),textColor:b.string().optional(),openChatButton:b.object({backgroundColor:b.string().optional(),iconColor:b.string().optional()}).optional(),header:b.object({backgroundColor:b.string().optional(),textColor:b.string().optional()}).optional(),button:b.object({backgroundColor:b.string().optional(),textColor:b.string().optional()}).optional(),messages:b.object({user:b.object({backgroundColor:b.string().optional(),textColor:b.string().optional()}).optional(),assistant:b.object({backgroundColor:b.string().optional(),textColor:b.string().optional()}).optional()}).optional()}).default({})}).default({}),handlers:b.object({functionCalls:b.record(b.function().returns(b.union([b.any(),b.promise(b.any())]))).default({}),enhancedContent:b.record(b.function().returns(b.union([b.any(),b.promise(b.any())]))).default({})}).default({})}),Me=et`*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: \"\"}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol,\"Noto Color Emoji\";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,[type=button],[type=reset],[type=submit]{-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.visible{visibility:visible}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.inset-0{top:0;right:0;bottom:0;left:0}.bottom-0{bottom:0}.bottom-8{bottom:2rem}.left-0{left:0}.left-8{left:2rem}.right-0{right:0}.right-8{right:2rem}.top-0{top:0}.z-50{z-index:50}.m-0{margin:0}.m-0\\.5{margin:.125rem}.m-2{margin:.5rem}.mx-4{margin-left:1rem;margin-right:1rem}.mx-auto{margin-left:auto;margin-right:auto}.my-auto{margin-top:auto;margin-bottom:auto}.mb-1{margin-bottom:.25rem}.mb-\\[-8px\\]{margin-bottom:-8px}.ml-1{margin-left:.25rem}.ml-2{margin-left:.5rem}.ml-20{margin-left:5rem}.mr-2{margin-right:.5rem}.mr-20{margin-right:5rem}.mt-4{margin-top:1rem}.block{display:block}.flex{display:flex}.hidden{display:none}.h-0{height:0px}.h-3\\/5{height:60%}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-9{height:2.25rem}.h-fit{height:-moz-fit-content;height:fit-content}.h-full{height:100%}.max-h-\\[90vh\\]{max-height:90vh}.w-0{width:0px}.w-3\\/5{width:60%}.w-5{width:1.25rem}.w-fit{width:-moz-fit-content;width:fit-content}.w-full{width:100%}.max-w-\\[90vw\\]{max-width:90vw}.flex-1{flex:1 1 0%}.flex-grow{flex-grow:1}.resize{resize:both}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.items-end{align-items:flex-end}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.5rem * var(--tw-space-x-reverse));margin-left:calc(.5rem * calc(1 - var(--tw-space-x-reverse)))}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-t-lg{border-top-left-radius:.5rem;border-top-right-radius:.5rem}.border{border-width:1px}.border-x-8{border-left-width:8px;border-right-width:8px}.border-t-8{border-top-width:8px}.border-white{--tw-border-opacity: 1;border-color:rgb(255 255 255 / var(--tw-border-opacity))}.border-x-transparent{border-left-color:transparent;border-right-color:transparent}.bg-black{--tw-bg-opacity: 1;background-color:rgb(0 0 0 / var(--tw-bg-opacity))}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity))}.bg-opacity-50{--tw-bg-opacity: .5}.p-2{padding:.5rem}.p-4{padding:1rem}.p-5{padding:1.25rem}.px-0{padding-left:0;padding-right:0}.px-4{padding-left:1rem;padding-right:1rem}.px-8{padding-left:2rem;padding-right:2rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.pb-0{padding-bottom:0}.pb-8{padding-bottom:2rem}.text-center{text-align:center}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.font-semibold{font-weight:600}.text-gray-400{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity))}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-md{--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}:host{font-size:16px;line-height:1.2;color:#000;text-align:left;--iai-chat-i-primary-color: var(--iai-chat-primary-color, #3B82F6);--iai-chat-i-text-color: var(--iai-chat-text-color, #FFF);--iai-chat-i-header-bg: var(--iai-chat-header-background-color, var(--iai-chat-i-primary-color));--iai-chat-i-header-fg: var(--iai-chat-header-text-color, var(--iai-chat-i-text-color));--iai-chat-i-button-bg: var(--iai-chat-button-background-color, var(--iai-chat-i-primary-color));--iai-chat-i-button-fg: var(--iai-chat-button-text-color, var(--iai-chat-i-text-color));--iai-chat-i-message-user-bg: var(--iai-chat-messages-user-background-color, var(--iai-chat-i-primary-color));--iai-chat-i-message-user-fg: var(--iai-chat-messages-user-text-color, var(--iai-chat-i-text-color));--iai-chat-i-message-assistant-bg: var(--iai-chat-messages-assistant-background-color, #6B7280);--iai-chat-i-message-assistant-fg: var(--iai-chat-messages-assistant-text-color, var(--iai-chat-i-text-color));--iai-chat-i-ocb-bg: var(--iai-chat-open-chat-button-background-color, var(--iai-chat-i-primary-color));--iai-chat-i-ocb-fg: var(--iai-chat-open-chat-button-icon-color, var(--iai-chat-i-text-color));--iai-chat-i-iframe-modal-header-bg: var(--iai-chat-iframe-modal-background-color, var(--iai-chat-i-primary-color));--iai-chat-i-iframe-modal-header-fg: var(--iai-chat-iframe-modal-text-color, var(--iai-chat-i-text-color))}input{background-color:#fff}.focus\\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.disabled\\:bg-gray-200:disabled{--tw-bg-opacity: 1;background-color:rgb(229 231 235 / var(--tw-bg-opacity))}.disabled\\:opacity-50:disabled{opacity:.5}@media (min-width: 768px){.md\\:bottom-8{bottom:2rem}.md\\:left-8{left:2rem}.md\\:right-8{right:2rem}.md\\:flex{display:flex}.md\\:h-\\[500px\\]{height:500px}.md\\:h-fit{height:-moz-fit-content;height:fit-content}.md\\:w-\\[350px\\]{width:350px}.md\\:w-fit{width:-moz-fit-content;width:fit-content}.md\\:p-0{padding:0}.md\\:px-0{padding-left:0;padding-right:0}.md\\:pb-0{padding-bottom:0}}`;var Ar=Object.defineProperty,Or=Object.getOwnPropertyDescriptor,Rt=(s,e,t,i)=>{for(var n=i>1?void 0:i?Or(e,t):e,r=s.length-1,a;r>=0;r--)(a=s[r])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&Ar(e,t,n),n};let Je=class extends se{constructor(){super(...arguments),this.isOpen=!0,this.onResizeHandler=()=>{this.isOpen&&window.innerWidth<768?yn(this):Xs(this)}}connectedCallback(){super.connectedCallback(),this.cleanOptions=ds.parse(this.options),this.onResizeHandler(),window.addEventListener("resize",this.onResizeHandler,{passive:!0})}disconnectedCallback(){super.disconnectedCallback(),Xs(this),window.removeEventListener("resize",this.onResizeHandler)}render(){const s=this.cleanOptions.config.placement!=="left",e=Ti({fixed:!0,"bottom-0":!0,"w-full":this.isOpen,"h-full":this.isOpen,...s&&{"right-0":!0,"md:right-8":!0},...!s&&{"left-0":!0,"md:left-8":!0},"md:bottom-8":!0,"md:w-fit":!0,"md:h-fit":!0}),t=Ti({"mt-4":!0,"px-8":!0,"pb-8":!0,"w-full":!0,hidden:this.isOpen,flex:!this.isOpen,"md:px-0":!0,"md:pb-0":!0,"md:w-[350px]":!0,"md:flex":!0});return D`
|
|
59
|
+
*/const ds="important",Zr=" !"+ds,Je=an(class extends on{constructor(i){var e;if(super(i),i.type!==rn.ATTRIBUTE||i.name!=="style"||((e=i.strings)==null?void 0:e.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(i){return Object.keys(i).reduce((e,t)=>{const n=i[t];return n==null?e:e+`${t=t.includes("-")?t:t.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${n};`},"")}update(i,[e]){const{style:t}=i.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(e)),this.render(e);for(const n of this.ft)e[n]==null&&(this.ft.delete(n),n.includes("-")?t.removeProperty(n):t[n]=null);for(const n in e){const s=e[n];if(s!=null){this.ft.add(n);const r=typeof s=="string"&&s.endsWith(Zr);n.includes("-")||r?t.setProperty(n,r?s.slice(0,-11):s,r?ds:""):t[n]=s}}return fe}});function Lr(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Jn={};(function(i){function e(o){o&&o.options&&clearTimeout(o.options.timer)}function t(o,l,d,h){var p={timer:void 0,lastArgs:[]},c=function(){for(var f=this,O=[],H=0;H<arguments.length;H++)O[H]=arguments[H];p.lastArgs=O,p.timer?clearTimeout(p.timer):l&&d.apply(this,p.lastArgs),p.timer=setTimeout(function(){l||d.apply(f,p.lastArgs),p.timer=void 0},o)};return h&&(c=c.bind(h)),c.options=p,c}function n(o,l,d,h){var p;Object.defineProperty(d,h,{configurable:!0,enumerable:!1,get:function(){return p},set:function(c){p=t(o,l,c,this)}})}function s(o,l,d){var h=d.value;return d.value=t(o,l,h),d}function r(o,l){for(var d=[],h=2;h<arguments.length;h++)d[h-2]=arguments[h];if(d.length===0)throw new Error("function applied debounce decorator should be a method");if(d.length===1)throw new Error("method applied debounce decorator should have valid name");var p=d[0],c=d[1],f=d.length===3&&d[2]?d[2]:Object.getOwnPropertyDescriptor(p,c);if(f)return s(o,l,f);n(o,l,p,c)}function a(){for(var o=[],l=0;l<arguments.length;l++)o[l]=arguments[l];var d=500,h=!1;if(o.length&&(typeof o[0]=="number"||typeof o[0]=="object"&&o[0].leading!==void 0)){typeof o[0]=="number"&&(d=o[0]);var p=void 0;return typeof o[0]=="object"&&o[0].leading!==void 0&&(p=o[0]),1<o.length&&typeof o[1]=="object"&&o[1].leading!==void 0&&(p=o[1]),p&&(h=p.leading),function(){for(var c=[],f=0;f<arguments.length;f++)c[f]=arguments[f];return r.apply(void 0,[d,h].concat(c))}}return r.apply(void 0,[d,h].concat(o))}Object.defineProperty(i,"__esModule",{value:!0}),i.cancel=e,i.debounce=a})(Jn);var N;(function(i){i.assertEqual=s=>s;function e(s){}i.assertIs=e;function t(s){throw new Error}i.assertNever=t,i.arrayToEnum=s=>{const r={};for(const a of s)r[a]=a;return r},i.getValidEnumValues=s=>{const r=i.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(const o of r)a[o]=s[o];return i.objectValues(a)},i.objectValues=s=>i.objectKeys(s).map(function(r){return s[r]}),i.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const r=[];for(const a in s)Object.prototype.hasOwnProperty.call(s,a)&&r.push(a);return r},i.find=(s,r)=>{for(const a of s)if(r(a))return a},i.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,r=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(r)}i.joinValues=n,i.jsonStringifyReplacer=(s,r)=>typeof r=="bigint"?r.toString():r})(N||(N={}));var Gn;(function(i){i.mergeShapes=(e,t)=>({...e,...t})})(Gn||(Gn={}));const g=N.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Oe=i=>{switch(typeof i){case"undefined":return g.undefined;case"string":return g.string;case"number":return isNaN(i)?g.nan:g.number;case"boolean":return g.boolean;case"function":return g.function;case"bigint":return g.bigint;case"symbol":return g.symbol;case"object":return Array.isArray(i)?g.array:i===null?g.null:i.then&&typeof i.then=="function"&&i.catch&&typeof i.catch=="function"?g.promise:typeof Map<"u"&&i instanceof Map?g.map:typeof Set<"u"&&i instanceof Set?g.set:typeof Date<"u"&&i instanceof Date?g.date:g.object;default:return g.unknown}},m=N.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Dr=i=>JSON.stringify(i,null,2).replace(/"([^"]+)":/g,"$1:");class oe extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(r){return r.message},n={_errors:[]},s=r=>{for(const a of r.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)n._errors.push(t(a));else{let o=n,l=0;for(;l<a.path.length;){const d=a.path[l];l===a.path.length-1?(o[d]=o[d]||{_errors:[]},o[d]._errors.push(t(a))):o[d]=o[d]||{_errors:[]},o=o[d],l++}}};return s(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,N.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}oe.create=i=>new oe(i);const It=(i,e)=>{let t;switch(i.code){case m.invalid_type:i.received===g.undefined?t="Required":t=`Expected ${i.expected}, received ${i.received}`;break;case m.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(i.expected,N.jsonStringifyReplacer)}`;break;case m.unrecognized_keys:t=`Unrecognized key(s) in object: ${N.joinValues(i.keys,", ")}`;break;case m.invalid_union:t="Invalid input";break;case m.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${N.joinValues(i.options)}`;break;case m.invalid_enum_value:t=`Invalid enum value. Expected ${N.joinValues(i.options)}, received '${i.received}'`;break;case m.invalid_arguments:t="Invalid function arguments";break;case m.invalid_return_type:t="Invalid function return type";break;case m.invalid_date:t="Invalid date";break;case m.invalid_string:typeof i.validation=="object"?"includes"in i.validation?(t=`Invalid input: must include "${i.validation.includes}"`,typeof i.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${i.validation.position}`)):"startsWith"in i.validation?t=`Invalid input: must start with "${i.validation.startsWith}"`:"endsWith"in i.validation?t=`Invalid input: must end with "${i.validation.endsWith}"`:N.assertNever(i.validation):i.validation!=="regex"?t=`Invalid ${i.validation}`:t="Invalid";break;case m.too_small:i.type==="array"?t=`Array must contain ${i.exact?"exactly":i.inclusive?"at least":"more than"} ${i.minimum} element(s)`:i.type==="string"?t=`String must contain ${i.exact?"exactly":i.inclusive?"at least":"over"} ${i.minimum} character(s)`:i.type==="number"?t=`Number must be ${i.exact?"exactly equal to ":i.inclusive?"greater than or equal to ":"greater than "}${i.minimum}`:i.type==="date"?t=`Date must be ${i.exact?"exactly equal to ":i.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(i.minimum))}`:t="Invalid input";break;case m.too_big:i.type==="array"?t=`Array must contain ${i.exact?"exactly":i.inclusive?"at most":"less than"} ${i.maximum} element(s)`:i.type==="string"?t=`String must contain ${i.exact?"exactly":i.inclusive?"at most":"under"} ${i.maximum} character(s)`:i.type==="number"?t=`Number must be ${i.exact?"exactly":i.inclusive?"less than or equal to":"less than"} ${i.maximum}`:i.type==="bigint"?t=`BigInt must be ${i.exact?"exactly":i.inclusive?"less than or equal to":"less than"} ${i.maximum}`:i.type==="date"?t=`Date must be ${i.exact?"exactly":i.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(i.maximum))}`:t="Invalid input";break;case m.custom:t="Invalid input";break;case m.invalid_intersection_types:t="Intersection results could not be merged";break;case m.not_multiple_of:t=`Number must be a multiple of ${i.multipleOf}`;break;case m.not_finite:t="Number must be finite";break;default:t=e.defaultError,N.assertNever(i)}return{message:t}};let hs=It;function Ur(i){hs=i}function dn(){return hs}const hn=i=>{const{data:e,path:t,errorMaps:n,issueData:s}=i,r=[...t,...s.path||[]],a={...s,path:r};let o="";const l=n.filter(d=>!!d).slice().reverse();for(const d of l)o=d(a,{data:e,defaultError:o}).message;return{...s,path:r,message:s.message||o}},Hr=[];function y(i,e){const t=hn({issueData:e,data:i.data,path:i.path,errorMaps:[i.common.contextualErrorMap,i.schemaErrorMap,dn(),It].filter(n=>!!n)});i.common.issues.push(t)}class X{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return S;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t)n.push({key:await s.key,value:await s.value});return X.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:r,value:a}=s;if(r.status==="aborted"||a.status==="aborted")return S;r.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),r.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(n[r.value]=a.value)}return{status:e.value,value:n}}}const S=Object.freeze({status:"aborted"}),us=i=>({status:"dirty",value:i}),te=i=>({status:"valid",value:i}),Qn=i=>i.status==="aborted",Yn=i=>i.status==="dirty",Ot=i=>i.status==="valid",un=i=>typeof Promise<"u"&&i instanceof Promise;var x;(function(i){i.errToObj=e=>typeof e=="string"?{message:e}:e||{},i.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(x||(x={}));class ge{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const ps=(i,e)=>{if(Ot(e))return{success:!0,data:e.value};if(!i.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new oe(i.common.issues);return this._error=t,this._error}}};function C(i){if(!i)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=i;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(r,a)=>r.code!=="invalid_type"?{message:a.defaultError}:typeof a.data>"u"?{message:n??a.defaultError}:{message:t??a.defaultError},description:s}}class I{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Oe(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Oe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new X,ctx:{common:e.parent.common,data:e.data,parsedType:Oe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(un(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const s={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Oe(e)},r=this._parseSync({data:e,path:s.path,parent:s});return ps(s,r)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Oe(e)},s=this._parse({data:e,path:n.path,parent:n}),r=await(un(s)?s:Promise.resolve(s));return ps(n,r)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,r)=>{const a=e(s),o=()=>r.addIssue({code:m.custom,...n(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(l=>l?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new de({schema:this,typeName:T.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Ee.create(this,this._def)}nullable(){return Xe.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ce.create(this,this._def)}promise(){return ft.create(this,this._def)}or(e){return Nt.create([this,e],this._def)}and(e){return jt.create(this,e,this._def)}transform(e){return new de({...C(this._def),schema:this,typeName:T.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Ut({...C(this._def),innerType:this,defaultValue:t,typeName:T.ZodDefault})}brand(){return new fs({typeName:T.ZodBranded,type:this,...C(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new vn({...C(this._def),innerType:this,catchValue:t,typeName:T.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ht.create(this,e)}readonly(){return wn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Br=/^c[^\s-]{8,}$/i,Wr=/^[a-z][a-z0-9]*$/,Fr=/^[0-9A-HJKMNP-TV-Z]{26}$/,Vr=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,qr=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Kr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Xn;const Jr=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,Gr=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Qr=i=>i.precision?i.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${i.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${i.precision}}Z$`):i.precision===0?i.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):i.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function Yr(i,e){return!!((e==="v4"||!e)&&Jr.test(i)||(e==="v6"||!e)&&Gr.test(i))}class le extends I{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==g.string){const s=this._getOrReturnCtx(e);return y(s,{code:m.invalid_type,expected:g.string,received:s.parsedType}),S}const t=new X;let n;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(n=this._getOrReturnCtx(e,n),y(n,{code:m.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="max")e.data.length>s.value&&(n=this._getOrReturnCtx(e,n),y(n,{code:m.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="length"){const r=e.data.length>s.value,a=e.data.length<s.value;(r||a)&&(n=this._getOrReturnCtx(e,n),r?y(n,{code:m.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&y(n,{code:m.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if(s.kind==="email")qr.test(e.data)||(n=this._getOrReturnCtx(e,n),y(n,{validation:"email",code:m.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")Xn||(Xn=new RegExp(Kr,"u")),Xn.test(e.data)||(n=this._getOrReturnCtx(e,n),y(n,{validation:"emoji",code:m.invalid_string,message:s.message}),t.dirty());else if(s.kind==="uuid")Vr.test(e.data)||(n=this._getOrReturnCtx(e,n),y(n,{validation:"uuid",code:m.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid")Br.test(e.data)||(n=this._getOrReturnCtx(e,n),y(n,{validation:"cuid",code:m.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid2")Wr.test(e.data)||(n=this._getOrReturnCtx(e,n),y(n,{validation:"cuid2",code:m.invalid_string,message:s.message}),t.dirty());else if(s.kind==="ulid")Fr.test(e.data)||(n=this._getOrReturnCtx(e,n),y(n,{validation:"ulid",code:m.invalid_string,message:s.message}),t.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),y(n,{validation:"url",code:m.invalid_string,message:s.message}),t.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),y(n,{validation:"regex",code:m.invalid_string,message:s.message}),t.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(n=this._getOrReturnCtx(e,n),y(n,{code:m.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),t.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(n=this._getOrReturnCtx(e,n),y(n,{code:m.invalid_string,validation:{startsWith:s.value},message:s.message}),t.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(n=this._getOrReturnCtx(e,n),y(n,{code:m.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty()):s.kind==="datetime"?Qr(s).test(e.data)||(n=this._getOrReturnCtx(e,n),y(n,{code:m.invalid_string,validation:"datetime",message:s.message}),t.dirty()):s.kind==="ip"?Yr(e.data,s.version)||(n=this._getOrReturnCtx(e,n),y(n,{validation:"ip",code:m.invalid_string,message:s.message}),t.dirty()):N.assertNever(s);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:m.invalid_string,...x.errToObj(n)})}_addCheck(e){return new le({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...x.errToObj(e)})}url(e){return this._addCheck({kind:"url",...x.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...x.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...x.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...x.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...x.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...x.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...x.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,...x.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...x.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...x.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...x.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...x.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...x.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...x.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...x.errToObj(t)})}nonempty(e){return this.min(1,x.errToObj(e))}trim(){return new le({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new le({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new le({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}le.create=i=>{var e;return new le({checks:[],typeName:T.ZodString,coerce:(e=i==null?void 0:i.coerce)!==null&&e!==void 0?e:!1,...C(i)})};function Xr(i,e){const t=(i.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,r=parseInt(i.toFixed(s).replace(".","")),a=parseInt(e.toFixed(s).replace(".",""));return r%a/Math.pow(10,s)}class Me extends I{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==g.number){const s=this._getOrReturnCtx(e);return y(s,{code:m.invalid_type,expected:g.number,received:s.parsedType}),S}let t;const n=new X;for(const s of this._def.checks)s.kind==="int"?N.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),y(t,{code:m.invalid_type,expected:"integer",received:"float",message:s.message}),n.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),y(t,{code:m.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),y(t,{code:m.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="multipleOf"?Xr(e.data,s.value)!==0&&(t=this._getOrReturnCtx(e,t),y(t,{code:m.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),y(t,{code:m.not_finite,message:s.message}),n.dirty()):N.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,x.toString(t))}gt(e,t){return this.setLimit("min",e,!1,x.toString(t))}lte(e,t){return this.setLimit("max",e,!0,x.toString(t))}lt(e,t){return this.setLimit("max",e,!1,x.toString(t))}setLimit(e,t,n,s){return new Me({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:x.toString(s)}]})}_addCheck(e){return new Me({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:x.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:x.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:x.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:x.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:x.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:x.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:x.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:x.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:x.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&N.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Me.create=i=>new Me({checks:[],typeName:T.ZodNumber,coerce:(i==null?void 0:i.coerce)||!1,...C(i)});class Re extends I{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==g.bigint){const s=this._getOrReturnCtx(e);return y(s,{code:m.invalid_type,expected:g.bigint,received:s.parsedType}),S}let t;const n=new X;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),y(t,{code:m.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),y(t,{code:m.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),y(t,{code:m.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):N.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,x.toString(t))}gt(e,t){return this.setLimit("min",e,!1,x.toString(t))}lte(e,t){return this.setLimit("max",e,!0,x.toString(t))}lt(e,t){return this.setLimit("max",e,!1,x.toString(t))}setLimit(e,t,n,s){return new Re({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:x.toString(s)}]})}_addCheck(e){return new Re({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:x.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:x.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:x.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:x.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:x.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Re.create=i=>{var e;return new Re({checks:[],typeName:T.ZodBigInt,coerce:(e=i==null?void 0:i.coerce)!==null&&e!==void 0?e:!1,...C(i)})};class Mt extends I{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==g.boolean){const t=this._getOrReturnCtx(e);return y(t,{code:m.invalid_type,expected:g.boolean,received:t.parsedType}),S}return te(e.data)}}Mt.create=i=>new Mt({typeName:T.ZodBoolean,coerce:(i==null?void 0:i.coerce)||!1,...C(i)});class Ge extends I{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==g.date){const s=this._getOrReturnCtx(e);return y(s,{code:m.invalid_type,expected:g.date,received:s.parsedType}),S}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return y(s,{code:m.invalid_date}),S}const t=new X;let n;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(n=this._getOrReturnCtx(e,n),y(n,{code:m.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),t.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(n=this._getOrReturnCtx(e,n),y(n,{code:m.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):N.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ge({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:x.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:x.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}Ge.create=i=>new Ge({checks:[],coerce:(i==null?void 0:i.coerce)||!1,typeName:T.ZodDate,...C(i)});class pn extends I{_parse(e){if(this._getType(e)!==g.symbol){const t=this._getOrReturnCtx(e);return y(t,{code:m.invalid_type,expected:g.symbol,received:t.parsedType}),S}return te(e.data)}}pn.create=i=>new pn({typeName:T.ZodSymbol,...C(i)});class Rt extends I{_parse(e){if(this._getType(e)!==g.undefined){const t=this._getOrReturnCtx(e);return y(t,{code:m.invalid_type,expected:g.undefined,received:t.parsedType}),S}return te(e.data)}}Rt.create=i=>new Rt({typeName:T.ZodUndefined,...C(i)});class Pt extends I{_parse(e){if(this._getType(e)!==g.null){const t=this._getOrReturnCtx(e);return y(t,{code:m.invalid_type,expected:g.null,received:t.parsedType}),S}return te(e.data)}}Pt.create=i=>new Pt({typeName:T.ZodNull,...C(i)});class ut extends I{constructor(){super(...arguments),this._any=!0}_parse(e){return te(e.data)}}ut.create=i=>new ut({typeName:T.ZodAny,...C(i)});class Qe extends I{constructor(){super(...arguments),this._unknown=!0}_parse(e){return te(e.data)}}Qe.create=i=>new Qe({typeName:T.ZodUnknown,...C(i)});class Te extends I{_parse(e){const t=this._getOrReturnCtx(e);return y(t,{code:m.invalid_type,expected:g.never,received:t.parsedType}),S}}Te.create=i=>new Te({typeName:T.ZodNever,...C(i)});class mn extends I{_parse(e){if(this._getType(e)!==g.undefined){const t=this._getOrReturnCtx(e);return y(t,{code:m.invalid_type,expected:g.void,received:t.parsedType}),S}return te(e.data)}}mn.create=i=>new mn({typeName:T.ZodVoid,...C(i)});class ce extends I{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==g.array)return y(t,{code:m.invalid_type,expected:g.array,received:t.parsedType}),S;if(s.exactLength!==null){const a=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(a||o)&&(y(t,{code:a?m.too_big:m.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(y(t,{code:m.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(y(t,{code:m.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>s.type._parseAsync(new ge(t,a,t.path,o)))).then(a=>X.mergeArray(n,a));const r=[...t.data].map((a,o)=>s.type._parseSync(new ge(t,a,t.path,o)));return X.mergeArray(n,r)}get element(){return this._def.type}min(e,t){return new ce({...this._def,minLength:{value:e,message:x.toString(t)}})}max(e,t){return new ce({...this._def,maxLength:{value:e,message:x.toString(t)}})}length(e,t){return new ce({...this._def,exactLength:{value:e,message:x.toString(t)}})}nonempty(e){return this.min(1,e)}}ce.create=(i,e)=>new ce({type:i,minLength:null,maxLength:null,exactLength:null,typeName:T.ZodArray,...C(e)});function pt(i){if(i instanceof F){const e={};for(const t in i.shape){const n=i.shape[t];e[t]=Ee.create(pt(n))}return new F({...i._def,shape:()=>e})}else return i instanceof ce?new ce({...i._def,type:pt(i.element)}):i instanceof Ee?Ee.create(pt(i.unwrap())):i instanceof Xe?Xe.create(pt(i.unwrap())):i instanceof ye?ye.create(i.items.map(e=>pt(e))):i}class F extends I{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=N.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==g.object){const l=this._getOrReturnCtx(e);return y(l,{code:m.invalid_type,expected:g.object,received:l.parsedType}),S}const{status:t,ctx:n}=this._processInputParams(e),{shape:s,keys:r}=this._getCached(),a=[];if(!(this._def.catchall instanceof Te&&this._def.unknownKeys==="strip"))for(const l in n.data)r.includes(l)||a.push(l);const o=[];for(const l of r){const d=s[l],h=n.data[l];o.push({key:{status:"valid",value:l},value:d._parse(new ge(n,h,n.path,l)),alwaysSet:l in n.data})}if(this._def.catchall instanceof Te){const l=this._def.unknownKeys;if(l==="passthrough")for(const d of a)o.push({key:{status:"valid",value:d},value:{status:"valid",value:n.data[d]}});else if(l==="strict")a.length>0&&(y(n,{code:m.unrecognized_keys,keys:a}),t.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const d of a){const h=n.data[d];o.push({key:{status:"valid",value:d},value:l._parse(new ge(n,h,n.path,d)),alwaysSet:d in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const l=[];for(const d of o){const h=await d.key;l.push({key:h,value:await d.value,alwaysSet:d.alwaysSet})}return l}).then(l=>X.mergeObjectSync(t,l)):X.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return x.errToObj,new F({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,r,a,o;const l=(a=(r=(s=this._def).errorMap)===null||r===void 0?void 0:r.call(s,t,n).message)!==null&&a!==void 0?a:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=x.errToObj(e).message)!==null&&o!==void 0?o:l}:{message:l}}}:{}})}strip(){return new F({...this._def,unknownKeys:"strip"})}passthrough(){return new F({...this._def,unknownKeys:"passthrough"})}extend(e){return new F({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new F({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:T.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new F({...this._def,catchall:e})}pick(e){const t={};return N.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new F({...this._def,shape:()=>t})}omit(e){const t={};return N.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new F({...this._def,shape:()=>t})}deepPartial(){return pt(this)}partial(e){const t={};return N.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new F({...this._def,shape:()=>t})}required(e){const t={};return N.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof Ee;)s=s._def.innerType;t[n]=s}}),new F({...this._def,shape:()=>t})}keyof(){return ms(N.objectKeys(this.shape))}}F.create=(i,e)=>new F({shape:()=>i,unknownKeys:"strip",catchall:Te.create(),typeName:T.ZodObject,...C(e)}),F.strictCreate=(i,e)=>new F({shape:()=>i,unknownKeys:"strict",catchall:Te.create(),typeName:T.ZodObject,...C(e)}),F.lazycreate=(i,e)=>new F({shape:i,unknownKeys:"strip",catchall:Te.create(),typeName:T.ZodObject,...C(e)});class Nt extends I{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(r){for(const o of r)if(o.result.status==="valid")return o.result;for(const o of r)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=r.map(o=>new oe(o.ctx.common.issues));return y(t,{code:m.invalid_union,unionErrors:a}),S}if(t.common.async)return Promise.all(n.map(async r=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await r._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(s);{let r;const a=[];for(const l of n){const d={...t,common:{...t.common,issues:[]},parent:null},h=l._parseSync({data:t.data,path:t.path,parent:d});if(h.status==="valid")return h;h.status==="dirty"&&!r&&(r={result:h,ctx:d}),d.common.issues.length&&a.push(d.common.issues)}if(r)return t.common.issues.push(...r.ctx.common.issues),r.result;const o=a.map(l=>new oe(l));return y(t,{code:m.invalid_union,unionErrors:o}),S}}get options(){return this._def.options}}Nt.create=(i,e)=>new Nt({options:i,typeName:T.ZodUnion,...C(e)});const fn=i=>i instanceof Zt?fn(i.schema):i instanceof de?fn(i.innerType()):i instanceof Lt?[i.value]:i instanceof Pe?i.options:i instanceof Dt?Object.keys(i.enum):i instanceof Ut?fn(i._def.innerType):i instanceof Rt?[void 0]:i instanceof Pt?[null]:null;class gn extends I{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==g.object)return y(t,{code:m.invalid_type,expected:g.object,received:t.parsedType}),S;const n=this.discriminator,s=t.data[n],r=this.optionsMap.get(s);return r?t.common.async?r._parseAsync({data:t.data,path:t.path,parent:t}):r._parseSync({data:t.data,path:t.path,parent:t}):(y(t,{code:m.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),S)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const r of t){const a=fn(r.shape[e]);if(!a)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,r)}}return new gn({typeName:T.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...C(n)})}}function ei(i,e){const t=Oe(i),n=Oe(e);if(i===e)return{valid:!0,data:i};if(t===g.object&&n===g.object){const s=N.objectKeys(e),r=N.objectKeys(i).filter(o=>s.indexOf(o)!==-1),a={...i,...e};for(const o of r){const l=ei(i[o],e[o]);if(!l.valid)return{valid:!1};a[o]=l.data}return{valid:!0,data:a}}else if(t===g.array&&n===g.array){if(i.length!==e.length)return{valid:!1};const s=[];for(let r=0;r<i.length;r++){const a=i[r],o=e[r],l=ei(a,o);if(!l.valid)return{valid:!1};s.push(l.data)}return{valid:!0,data:s}}else return t===g.date&&n===g.date&&+i==+e?{valid:!0,data:i}:{valid:!1}}class jt extends I{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(r,a)=>{if(Qn(r)||Qn(a))return S;const o=ei(r.value,a.value);return o.valid?((Yn(r)||Yn(a))&&t.dirty(),{status:t.value,value:o.data}):(y(n,{code:m.invalid_intersection_types}),S)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([r,a])=>s(r,a)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}jt.create=(i,e,t)=>new jt({left:i,right:e,typeName:T.ZodIntersection,...C(t)});class ye extends I{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==g.array)return y(n,{code:m.invalid_type,expected:g.array,received:n.parsedType}),S;if(n.data.length<this._def.items.length)return y(n,{code:m.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),S;!this._def.rest&&n.data.length>this._def.items.length&&(y(n,{code:m.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((r,a)=>{const o=this._def.items[a]||this._def.rest;return o?o._parse(new ge(n,r,n.path,a)):null}).filter(r=>!!r);return n.common.async?Promise.all(s).then(r=>X.mergeArray(t,r)):X.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new ye({...this._def,rest:e})}}ye.create=(i,e)=>{if(!Array.isArray(i))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ye({items:i,typeName:T.ZodTuple,rest:null,...C(e)})};class zt extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==g.object)return y(n,{code:m.invalid_type,expected:g.object,received:n.parsedType}),S;const s=[],r=this._def.keyType,a=this._def.valueType;for(const o in n.data)s.push({key:r._parse(new ge(n,o,n.path,o)),value:a._parse(new ge(n,n.data[o],n.path,o))});return n.common.async?X.mergeObjectAsync(t,s):X.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof I?new zt({keyType:e,valueType:t,typeName:T.ZodRecord,...C(n)}):new zt({keyType:le.create(),valueType:e,typeName:T.ZodRecord,...C(t)})}}class yn extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==g.map)return y(n,{code:m.invalid_type,expected:g.map,received:n.parsedType}),S;const s=this._def.keyType,r=this._def.valueType,a=[...n.data.entries()].map(([o,l],d)=>({key:s._parse(new ge(n,o,n.path,[d,"key"])),value:r._parse(new ge(n,l,n.path,[d,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const l of a){const d=await l.key,h=await l.value;if(d.status==="aborted"||h.status==="aborted")return S;(d.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(d.value,h.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const l of a){const d=l.key,h=l.value;if(d.status==="aborted"||h.status==="aborted")return S;(d.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(d.value,h.value)}return{status:t.value,value:o}}}}yn.create=(i,e,t)=>new yn({valueType:e,keyType:i,typeName:T.ZodMap,...C(t)});class Ye extends I{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==g.set)return y(n,{code:m.invalid_type,expected:g.set,received:n.parsedType}),S;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(y(n,{code:m.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(y(n,{code:m.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const r=this._def.valueType;function a(l){const d=new Set;for(const h of l){if(h.status==="aborted")return S;h.status==="dirty"&&t.dirty(),d.add(h.value)}return{status:t.value,value:d}}const o=[...n.data.values()].map((l,d)=>r._parse(new ge(n,l,n.path,d)));return n.common.async?Promise.all(o).then(l=>a(l)):a(o)}min(e,t){return new Ye({...this._def,minSize:{value:e,message:x.toString(t)}})}max(e,t){return new Ye({...this._def,maxSize:{value:e,message:x.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Ye.create=(i,e)=>new Ye({valueType:i,minSize:null,maxSize:null,typeName:T.ZodSet,...C(e)});class mt extends I{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==g.function)return y(t,{code:m.invalid_type,expected:g.function,received:t.parsedType}),S;function n(o,l){return hn({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,dn(),It].filter(d=>!!d),issueData:{code:m.invalid_arguments,argumentsError:l}})}function s(o,l){return hn({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,dn(),It].filter(d=>!!d),issueData:{code:m.invalid_return_type,returnTypeError:l}})}const r={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof ft){const o=this;return te(async function(...l){const d=new oe([]),h=await o._def.args.parseAsync(l,r).catch(c=>{throw d.addIssue(n(l,c)),d}),p=await Reflect.apply(a,this,h);return await o._def.returns._def.type.parseAsync(p,r).catch(c=>{throw d.addIssue(s(p,c)),d})})}else{const o=this;return te(function(...l){const d=o._def.args.safeParse(l,r);if(!d.success)throw new oe([n(l,d.error)]);const h=Reflect.apply(a,this,d.data),p=o._def.returns.safeParse(h,r);if(!p.success)throw new oe([s(h,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new mt({...this._def,args:ye.create(e).rest(Qe.create())})}returns(e){return new mt({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new mt({args:e||ye.create([]).rest(Qe.create()),returns:t||Qe.create(),typeName:T.ZodFunction,...C(n)})}}class Zt extends I{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Zt.create=(i,e)=>new Zt({getter:i,typeName:T.ZodLazy,...C(e)});class Lt extends I{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return y(t,{received:t.data,code:m.invalid_literal,expected:this._def.value}),S}return{status:"valid",value:e.data}}get value(){return this._def.value}}Lt.create=(i,e)=>new Lt({value:i,typeName:T.ZodLiteral,...C(e)});function ms(i,e){return new Pe({values:i,typeName:T.ZodEnum,...C(e)})}class Pe extends I{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return y(t,{expected:N.joinValues(n),received:t.parsedType,code:m.invalid_type}),S}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),n=this._def.values;return y(t,{received:t.data,code:m.invalid_enum_value,options:n}),S}return te(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return Pe.create(e)}exclude(e){return Pe.create(this.options.filter(t=>!e.includes(t)))}}Pe.create=ms;class Dt extends I{_parse(e){const t=N.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==g.string&&n.parsedType!==g.number){const s=N.objectValues(t);return y(n,{expected:N.joinValues(s),received:n.parsedType,code:m.invalid_type}),S}if(t.indexOf(e.data)===-1){const s=N.objectValues(t);return y(n,{received:n.data,code:m.invalid_enum_value,options:s}),S}return te(e.data)}get enum(){return this._def.values}}Dt.create=(i,e)=>new Dt({values:i,typeName:T.ZodNativeEnum,...C(e)});class ft extends I{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==g.promise&&t.common.async===!1)return y(t,{code:m.invalid_type,expected:g.promise,received:t.parsedType}),S;const n=t.parsedType===g.promise?t.data:Promise.resolve(t.data);return te(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ft.create=(i,e)=>new ft({type:i,typeName:T.ZodPromise,...C(e)});class de extends I{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===T.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,r={addIssue:a=>{y(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(r.addIssue=r.addIssue.bind(r),s.type==="preprocess"){const a=s.transform(n.data,r);return n.common.issues.length?{status:"dirty",value:n.data}:n.common.async?Promise.resolve(a).then(o=>this._def.schema._parseAsync({data:o,path:n.path,parent:n})):this._def.schema._parseSync({data:a,path:n.path,parent:n})}if(s.type==="refinement"){const a=o=>{const l=s.refinement(o,r);if(n.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?S:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?S:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Ot(a))return a;const o=s.transform(a.value,r);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>Ot(a)?Promise.resolve(s.transform(a.value,r)).then(o=>({status:t.value,value:o})):a);N.assertNever(s)}}de.create=(i,e,t)=>new de({schema:i,typeName:T.ZodEffects,effect:e,...C(t)}),de.createWithPreprocess=(i,e,t)=>new de({schema:e,effect:{type:"preprocess",transform:i},typeName:T.ZodEffects,...C(t)});class Ee extends I{_parse(e){return this._getType(e)===g.undefined?te(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ee.create=(i,e)=>new Ee({innerType:i,typeName:T.ZodOptional,...C(e)});class Xe extends I{_parse(e){return this._getType(e)===g.null?te(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Xe.create=(i,e)=>new Xe({innerType:i,typeName:T.ZodNullable,...C(e)});class Ut extends I{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===g.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Ut.create=(i,e)=>new Ut({innerType:i,typeName:T.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...C(e)});class vn extends I{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return un(s)?s.then(r=>({status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new oe(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new oe(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}vn.create=(i,e)=>new vn({innerType:i,typeName:T.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...C(e)});class bn extends I{_parse(e){if(this._getType(e)!==g.nan){const t=this._getOrReturnCtx(e);return y(t,{code:m.invalid_type,expected:g.nan,received:t.parsedType}),S}return{status:"valid",value:e.data}}}bn.create=i=>new bn({typeName:T.ZodNaN,...C(i)});const ea=Symbol("zod_brand");class fs extends I{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class Ht extends I{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?S:s.status==="dirty"?(t.dirty(),us(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?S:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new Ht({in:e,out:t,typeName:T.ZodPipeline})}}class wn extends I{_parse(e){const t=this._def.innerType._parse(e);return Ot(t)&&(t.value=Object.freeze(t.value)),t}}wn.create=(i,e)=>new wn({innerType:i,typeName:T.ZodReadonly,...C(e)});const gs=(i,e={},t)=>i?ut.create().superRefine((n,s)=>{var r,a;if(!i(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,l=(a=(r=o.fatal)!==null&&r!==void 0?r:t)!==null&&a!==void 0?a:!0,d=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...d,fatal:l})}}):ut.create(),ta={object:F.lazycreate};var T;(function(i){i.ZodString="ZodString",i.ZodNumber="ZodNumber",i.ZodNaN="ZodNaN",i.ZodBigInt="ZodBigInt",i.ZodBoolean="ZodBoolean",i.ZodDate="ZodDate",i.ZodSymbol="ZodSymbol",i.ZodUndefined="ZodUndefined",i.ZodNull="ZodNull",i.ZodAny="ZodAny",i.ZodUnknown="ZodUnknown",i.ZodNever="ZodNever",i.ZodVoid="ZodVoid",i.ZodArray="ZodArray",i.ZodObject="ZodObject",i.ZodUnion="ZodUnion",i.ZodDiscriminatedUnion="ZodDiscriminatedUnion",i.ZodIntersection="ZodIntersection",i.ZodTuple="ZodTuple",i.ZodRecord="ZodRecord",i.ZodMap="ZodMap",i.ZodSet="ZodSet",i.ZodFunction="ZodFunction",i.ZodLazy="ZodLazy",i.ZodLiteral="ZodLiteral",i.ZodEnum="ZodEnum",i.ZodEffects="ZodEffects",i.ZodNativeEnum="ZodNativeEnum",i.ZodOptional="ZodOptional",i.ZodNullable="ZodNullable",i.ZodDefault="ZodDefault",i.ZodCatch="ZodCatch",i.ZodPromise="ZodPromise",i.ZodBranded="ZodBranded",i.ZodPipeline="ZodPipeline",i.ZodReadonly="ZodReadonly"})(T||(T={}));const na=(i,e={message:`Input not instance of ${i.name}`})=>gs(t=>t instanceof i,e),ys=le.create,vs=Me.create,ia=bn.create,sa=Re.create,bs=Mt.create,ra=Ge.create,aa=pn.create,oa=Rt.create,la=Pt.create,ca=ut.create,da=Qe.create,ha=Te.create,ua=mn.create,pa=ce.create,ma=F.create,fa=F.strictCreate,ga=Nt.create,ya=gn.create,va=jt.create,ba=ye.create,wa=zt.create,xa=yn.create,ka=Ye.create,_a=mt.create,$a=Zt.create,Ta=Lt.create,Ea=Pe.create,Sa=Dt.create,Ca=ft.create,ws=de.create,Aa=Ee.create,Ia=Xe.create,Oa=de.createWithPreprocess,Ma=Ht.create;var w=Object.freeze({__proto__:null,defaultErrorMap:It,setErrorMap:Ur,getErrorMap:dn,makeIssue:hn,EMPTY_PATH:Hr,addIssueToContext:y,ParseStatus:X,INVALID:S,DIRTY:us,OK:te,isAborted:Qn,isDirty:Yn,isValid:Ot,isAsync:un,get util(){return N},get objectUtil(){return Gn},ZodParsedType:g,getParsedType:Oe,ZodType:I,ZodString:le,ZodNumber:Me,ZodBigInt:Re,ZodBoolean:Mt,ZodDate:Ge,ZodSymbol:pn,ZodUndefined:Rt,ZodNull:Pt,ZodAny:ut,ZodUnknown:Qe,ZodNever:Te,ZodVoid:mn,ZodArray:ce,ZodObject:F,ZodUnion:Nt,ZodDiscriminatedUnion:gn,ZodIntersection:jt,ZodTuple:ye,ZodRecord:zt,ZodMap:yn,ZodSet:Ye,ZodFunction:mt,ZodLazy:Zt,ZodLiteral:Lt,ZodEnum:Pe,ZodNativeEnum:Dt,ZodPromise:ft,ZodEffects:de,ZodTransformer:de,ZodOptional:Ee,ZodNullable:Xe,ZodDefault:Ut,ZodCatch:vn,ZodNaN:bn,BRAND:ea,ZodBranded:fs,ZodPipeline:Ht,ZodReadonly:wn,custom:gs,Schema:I,ZodSchema:I,late:ta,get ZodFirstPartyTypeKind(){return T},coerce:{string:i=>le.create({...i,coerce:!0}),number:i=>Me.create({...i,coerce:!0}),boolean:i=>Mt.create({...i,coerce:!0}),bigint:i=>Re.create({...i,coerce:!0}),date:i=>Ge.create({...i,coerce:!0})},any:ca,array:pa,bigint:sa,boolean:bs,date:ra,discriminatedUnion:ya,effect:ws,enum:Ea,function:_a,instanceof:na,intersection:va,lazy:$a,literal:Ta,map:xa,nan:ia,nativeEnum:Sa,never:ha,null:la,nullable:Ia,number:vs,object:ma,oboolean:()=>bs().optional(),onumber:()=>vs().optional(),optional:Aa,ostring:()=>ys().optional(),pipeline:Ma,preprocess:Oa,promise:Ca,record:wa,set:ka,strictObject:fa,string:ys,symbol:aa,transformer:ws,tuple:ba,undefined:oa,union:ga,unknown:da,void:ua,NEVER:S,ZodIssueCode:m,quotelessJson:Dr,ZodError:oe});const xn=w.object({assistantId:w.string(),params:w.record(w.any()).default({}),config:w.object({historyKey:w.string().refine(i=>i.replace(/-/g,"_")).nullable().default("main"),welcomeMessage:w.string().default("Hello! How can I help you today?"),inactivityWarningMessage:w.string().default("Are you still there? The chat will end soon if we don't hear from you."),chatEndedMessage:w.string().default("The chat has ended. Please restart the chat to continue."),initialReplyMessage:w.string().nullable().default(null),simulateDelays:w.boolean().default(!0),placement:w.enum(["left","right"]).default("right"),openChatButton:w.object({imageSrc:w.string().optional(),width:w.union([w.string(),w.number()]).default("48px"),height:w.union([w.string(),w.number()]).default("48px"),cta:w.string().optional()}).default({}),chatWindow:w.object({header:w.object({text:w.string().nullable().default("AI Chat"),imageSrc:w.string().optional()}).default({}),showCloseButton:w.boolean().default(!0)}).default({}),styles:w.object({primaryColor:w.string().optional(),textColor:w.string().optional(),openChatButton:w.object({backgroundColor:w.string().optional(),iconColor:w.string().optional()}).optional(),header:w.object({backgroundColor:w.string().optional(),textColor:w.string().optional()}).optional(),button:w.object({backgroundColor:w.string().optional(),textColor:w.string().optional()}).optional(),messages:w.object({user:w.object({backgroundColor:w.string().optional(),textColor:w.string().optional()}).optional(),assistant:w.object({backgroundColor:w.string().optional(),textColor:w.string().optional()}).optional()}).optional()}).default({})}).default({}),handlers:w.object({functionCalls:w.record(w.function().returns(w.union([w.any(),w.promise(w.any())]))).default({}),enhancedContent:w.record(w.function().returns(w.union([w.any(),w.promise(w.any())]))).default({})}).default({})});var Ra=Object.defineProperty,Pa=Object.getOwnPropertyDescriptor,Bt=(i,e,t,n)=>{for(var s=n>1?void 0:n?Pa(e,t):e,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=(n?a(e,t,s):a(s))||s);return n&&s&&Ra(e,t,s),s};let et=class extends se{constructor(){super(...arguments),this.isOpen=!0,this.onResizeHandler=()=>{this.isOpen&&window.innerWidth<768?zr(this):ls(this)}}connectedCallback(){super.connectedCallback(),this.cleanOptions=xn.parse(this.options),this.onResizeHandler(),window.addEventListener("resize",this.onResizeHandler,{passive:!0})}disconnectedCallback(){super.disconnectedCallback(),ls(this),window.removeEventListener("resize",this.onResizeHandler)}render(){const i=this.cleanOptions.config.placement!=="left",e=cs({fixed:!0,"bottom-0":!0,"w-full":this.isOpen,"h-full":this.isOpen,...i&&{"right-0":!0,"md:right-8":!0},...!i&&{"left-0":!0,"md:left-8":!0},"md:bottom-8":!0,"md:w-fit":!0,"md:h-fit":!0}),t=cs({"mt-4":!0,"px-8":!0,"pb-8":!0,"w-full":!0,hidden:this.isOpen,flex:!this.isOpen,"md:px-0":!0,"md:pb-0":!0,"md:w-[350px]":!0,"md:flex":!0});return z`
|
|
52
60
|
<div
|
|
53
61
|
class=${e}
|
|
62
|
+
style=${Je({zIndex:"9999",colorScheme:"normal"})}
|
|
54
63
|
>
|
|
55
64
|
<div
|
|
56
65
|
class="w-full h-full p-2 md:w-[350px] md:h-[500px] md:p-0"
|
|
57
|
-
style=${
|
|
66
|
+
style=${Je({display:this.isOpen?"block":"none"})}
|
|
58
67
|
>
|
|
59
68
|
<iai-chat
|
|
60
69
|
.options=${this.options}
|
|
@@ -64,7 +73,7 @@
|
|
|
64
73
|
|
|
65
74
|
<div
|
|
66
75
|
class=${t}
|
|
67
|
-
style=${
|
|
76
|
+
style=${Je({justifyContent:i?"flex-end":"flex-start"})}
|
|
68
77
|
>
|
|
69
78
|
<iai-chat-open-chat-button
|
|
70
79
|
.options=${this.cleanOptions}
|
|
@@ -73,19 +82,11 @@
|
|
|
73
82
|
/>
|
|
74
83
|
</div>
|
|
75
84
|
</div>
|
|
76
|
-
`}toggleChat(){this.isOpen=!this.isOpen,this.onResizeHandler()}};
|
|
85
|
+
`}toggleChat(){this.isOpen=!this.isOpen,this.onResizeHandler()}};et.styles=[$e],Bt([V({type:Object})],et.prototype,"options",2),Bt([ht()],et.prototype,"isOpen",2),Bt([sn("iai-chat")],et.prototype,"chatWindow",2),Bt([Jn.debounce(250)],et.prototype,"onResizeHandler",2),et=Bt([_e("iai-chat-popup")],et);const ti="https://ai-dev.anyonehome.xyz";async function Na(i,e={}){return(await fetch(`${ti}/threads`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({assistantId:i,params:e})})).json()}async function ja(i,e){return(await fetch(`${ti}/threads/${i}/messages`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:e})})).json()}async function za(i,e,t,n=!1){return(await fetch(`${ti}/threads/${i}/functions/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({params:t,rerunLLM:n})})).json()}function Za(i){return{all:i=i||new Map,on:function(e,t){var n=i.get(e);n?n.push(t):i.set(e,[t])},off:function(e,t){var n=i.get(e);n&&(t?n.splice(n.indexOf(t)>>>0,1):i.set(e,[]))},emit:function(e,t){var n=i.get(e);n&&n.slice().map(function(s){s(t)}),(n=i.get("*"))&&n.slice().map(function(s){s(e,t)})}}}class La{constructor(e,t={}){if(this._assistantId="",this._conversationDetails=null,this._messages=[],this.isTyping=!1,this.inputDisabled=!1,this.chatEndingWarningSent=!1,this.chatEnded=!1,this.onStorageEvent=n=>{var s;const[r,a,o]=((s=n.key)==null?void 0:s.split("-"))||[];if(!(r!=="iaiChat"||a!==this.options.historyKey))switch(o){case"messageHistory":this.onMessageHistoryStorageEvent(n);break;case"conversation":this.setConversationDetails(JSON.parse(n.newValue||"null"),!0);break;case"lastActivity":this.keepAlive(JSON.parse(n.newValue||"null"),!0);break;case"chatEndingWarningSent":this.setChatEndingWarningSent(JSON.parse(n.newValue||"false"),!0);break;case"chatEnded":this.setChatEnded(JSON.parse(n.newValue||"false"),!0);break;case"typing":this.setTyping(JSON.parse(n.newValue||"false"),!0);break;case"inputDisabled":this.setInputDisabled(JSON.parse(n.newValue||"false"),!0);break}},this._assistantId=e,this.options={params:{},simulateDelays:!1,historyKey:"main",...t},this._emitter=Za(),this.on=this._emitter.on.bind(this._emitter),this.off=this._emitter.off.bind(this._emitter),t.events&&Object.entries(t.events).forEach(([n,s])=>{this._emitter.on(n,s)}),t.historyKey){this._messages=this.storageGet("messageHistory",[]);const n=this.storageGet("conversation");n&&this.setConversationDetails(n,!0);const s=this.storageGet("chatEndingWarningSent");s&&this.setChatEndingWarningSent(s,!0);const r=this.storageGet("chatEnded");r&&this.setChatEnded(r,!0);const a=this.storageGet("typing");a&&this.setTyping(a,!0);const o=this.storageGet("inputDisabled");o&&this.setInputDisabled(o,!0);const l=this.storageGet("lastActivity");l&&setTimeout(()=>this.keepAlive(l,!0),0),window.addEventListener("storage",this.onStorageEvent)}}onMessageHistoryStorageEvent(e){if(!e.newValue){this.reset();return}const t=JSON.parse(e.newValue),n=this._messages.map(r=>r.id),s=t.map(r=>r.id);this._messages.forEach(r=>{s.includes(r.id)||this._emitter.emit("messageRemoved",r.id)}),t.forEach(r=>{n.includes(r.id)||this._emitter.emit("message",r)}),this._messages=t}reset(){this._messages=[],this.setConversationDetails(null),this.setTyping(!1),this.setInputDisabled(!1),this.setChatEnded(!1),this.stopInactivityTimers(),this.storageRemoveAll(),this._emitter.emit("reset")}destroy(){this._emitter.all.clear(),window.removeEventListener("storage",this.onStorageEvent),this.stopInactivityTimers(),this._emitter.emit("destroy")}stopInactivityTimers(){this._inactivityTimeout&&(clearTimeout(this._inactivityTimeout),this._inactivityTimeout=null),this._inactivityWarningTimeout&&(clearTimeout(this._inactivityWarningTimeout),this._inactivityWarningTimeout=null)}keepAlive(e=Date.now(),t=!1){if(this.stopInactivityTimers(),this.chatEnded||!e)return;const{timeUntilChatEnds:n,timeUntilWarnAboutChatEnding:s}=this;if(!n)return;t||this.storageSet("lastActivity",e);const r=Date.now()-e;r>n?(this.chatEnded||this._emitter.emit("chatEnded"),this.setChatEnded(!0)):r>s?(this.sendChatEndingWarning(),this._inactivityTimeout=setTimeout(()=>{this.chatEnded||this._emitter.emit("chatEnded"),this.setChatEnded(!0)},n-r)):(this.setChatEndingWarningSent(!1),this._inactivityWarningTimeout=setTimeout(()=>this.sendChatEndingWarning(),s-r),this._inactivityTimeout=setTimeout(()=>{this.chatEnded||this._emitter.emit("chatEnded"),this.setChatEnded(!0)},n-r))}async startChat(){if(this.chatStarted)return;const{id:e,inactivityWaitTime:t,inactivityWarningTime:n}=await Na(this.assistantId,this.params);if(!e)throw new Error("Could not start chat");this.setConversationDetails({threadId:e,inactivityWaitTime:t,inactivityWarningTime:n})}addMessage(e){const t={...e,id:e.id||Math.random().toString(36).substring(7)};return this._messages.push(t),this.storageSet("messageHistory",this._messages),this._emitter.emit("message",t),t}removeMessage(e){this._messages=this._messages.filter(t=>t.id!==e),this.storageSet("messageHistory",this._messages),this._emitter.emit("messageRemoved",e)}async respondToFunctionCall(e,t,n){this.simulateDelay(1800).then(()=>this.setTyping(!0));const s=this.simulateDelay(2e3);this.keepAlive(),await this.insertMessagesWithSimulatedDelays(Promise.all([za(this.threadId,e,t,n),s]).then(([r])=>r))}async sendUserMessage(e){try{this.addMessage({role:"user",content:e}),this.simulateDelay(1800).then(()=>this.setTyping(!0));let t=this.simulateDelay(4800);if(!this.chatStarted){const{initialReplyMessage:r}=this.options;r&&(this.simulateDelay(3800).then(()=>{this.addMessage({role:"assistant",content:r}),this.setTyping(!1)}),this.simulateDelay(6200).then(()=>this.setTyping(!0)),t=this.simulateDelay(8200)),await this.startChat()}this.keepAlive();const{messages:n,functions:s}=await this.insertMessagesWithSimulatedDelays(Promise.all([ja(this.threadId,e),t]).then(([r])=>r));return{messages:n,functions:s}}catch(t){throw console.error("Error sending message:",t),new Error("There was an error sending the message")}}setTyping(e,t=!1){this.isTyping=e,this._emitter.emit("typing",e),t||this.storageSet("typing",e)}setConversationDetails(e,t=!1){this._conversationDetails=e,t||this.storageSet("conversation",e)}setInputDisabled(e,t=!1){this.inputDisabled=e,this._emitter.emit("inputDisabled",e),t||this.storageSet("inputDisabled",e)}setChatEnded(e,t=!1){this.chatEnded=e,t||this.storageSet("chatEnded",e)}setChatEndingWarningSent(e,t=!1){this.chatEndingWarningSent=e,t||this.storageSet("chatEndingWarningSent",e)}sendChatEndingWarning(){this.chatEndingWarningSent||(this._emitter.emit("inactivityWarning"),this.setChatEndingWarningSent(!0))}async insertMessagesWithSimulatedDelays(e){const t=await e;if(t.error)throw new Error(t.message);const{messages:n,functions:s}=t;return await Promise.all(n.map(async(r,a)=>(await this.simulateDelay(1e3*a),this.addMessage(r)))),this.setTyping(!1),s.forEach(r=>this._emitter.emit("functionCall",r)),{messages:n,functions:s}}simulateDelay(e){return this.options.simulateDelays?new Promise(t=>{setTimeout(t,e)}):Promise.resolve()}get assistantId(){return this._assistantId}get params(){return this.options.params}get threadId(){var e;return(e=this._conversationDetails)==null?void 0:e.threadId}get timeUntilChatEnds(){const{inactivityWaitTime:e}=this._conversationDetails||{};return e?e*60*1e3:null}get timeUntilWarnAboutChatEnding(){const{inactivityWaitTime:e=0,inactivityWarningTime:t=0}=this._conversationDetails||{};return(e-t)*60*1e3}get messages(){return this._messages}get chatStarted(){return!!this.threadId}storageSet(e,t){this.options.historyKey&&localStorage.setItem(`iaiChat-${this.options.historyKey}-${e}`,JSON.stringify(t))}storageGet(e,t=null){if(!this.options.historyKey)return null;const n=localStorage.getItem(`iaiChat-${this.options.historyKey}-${e}`);return n?JSON.parse(n):t}storageRemove(e){localStorage.removeItem(`iaiChat-${this.options.historyKey}-${e}`)}storageRemoveAll(){this.options.historyKey&&Object.keys(localStorage).forEach(e=>{e.startsWith(`iaiChat-${this.options.historyKey}-`)&&localStorage.removeItem(e)})}}/**
|
|
77
86
|
* @license
|
|
78
87
|
* Copyright 2021 Google LLC
|
|
79
88
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
80
|
-
*/function Ne(
|
|
81
|
-
* @license
|
|
82
|
-
* Copyright 2020 Google LLC
|
|
83
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
84
|
-
*/const{I:Rr}=An,Di=()=>document.createComment(""),Zt=(s,e,t)=>{var i;const n=s._$AA.parentNode,r=e===void 0?s._$AB:e._$AA;if(t===void 0){const a=n.insertBefore(Di(),r),o=n.insertBefore(Di(),r);t=new Rr(a,o,s,s.options)}else{const a=t._$AB.nextSibling,o=t._$AM,c=o!==s;if(c){let l;(i=t._$AQ)==null||i.call(t,s),t._$AM=s,t._$AP!==void 0&&(l=s._$AU)!==o._$AU&&t._$AP(l)}if(a!==r||c){let l=t._$AA;for(;l!==a;){const h=l.nextSibling;n.insertBefore(l,r),l=h}}}return t},qe=(s,e,t=s)=>(s._$AI(e,t),s),Zr={},Dr=(s,e=Zr)=>s._$AH=e,Lr=s=>s._$AH,Ms=s=>{var e;(e=s._$AP)==null||e.call(s,!1,!0);let t=s._$AA;const i=s._$AB.nextSibling;for(;t!==i;){const n=t.nextSibling;t.remove(),t=n}};/**
|
|
85
|
-
* @license
|
|
86
|
-
* Copyright 2017 Google LLC
|
|
87
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
88
|
-
*/const Li=(s,e,t)=>{const i=new Map;for(let n=e;n<=t;n++)i.set(s[n],n);return i},zr=Gt(class extends Yt{constructor(s){if(super(s),s.type!==qt.CHILD)throw Error("repeat() can only be used in text expressions")}dt(s,e,t){let i;t===void 0?t=e:e!==void 0&&(i=e);const n=[],r=[];let a=0;for(const o of s)n[a]=i?i(o,a):a,r[a]=t(o,a),a++;return{values:r,keys:n}}render(s,e,t){return this.dt(s,e,t).values}update(s,[e,t,i]){const n=Lr(s),{values:r,keys:a}=this.dt(e,t,i);if(!Array.isArray(n))return this.ut=a,r;const o=this.ut??(this.ut=[]),c=[];let l,h,m=0,d=n.length-1,w=0,N=r.length-1;for(;m<=d&&w<=N;)if(n[m]===null)m++;else if(n[d]===null)d--;else if(o[m]===a[w])c[w]=qe(n[m],r[w]),m++,w++;else if(o[d]===a[N])c[N]=qe(n[d],r[N]),d--,N--;else if(o[m]===a[N])c[N]=qe(n[m],r[N]),Zt(s,c[N+1],n[m]),m++,N--;else if(o[d]===a[w])c[w]=qe(n[d],r[w]),Zt(s,n[m],n[d]),d--,w++;else if(l===void 0&&(l=Li(a,w,N),h=Li(o,m,d)),l.has(o[m]))if(l.has(o[d])){const H=h.get(a[w]),ee=H!==void 0?n[H]:null;if(ee===null){const _e=Zt(s,n[m]);qe(_e,r[w]),c[w]=_e}else c[w]=qe(ee,r[w]),Zt(s,n[m],ee),n[H]=null;w++}else Ms(n[d]),d--;else Ms(n[m]),m++;for(;w<=N;){const H=Zt(s,c[N+1]);qe(H,r[w]),c[w++]=H}for(;m<=d;){const H=n[m++];H!==null&&Ms(H)}return this.ut=a,Dr(s,c),ue}});function Ur(s){return{all:s=s||new Map,on:function(e,t){var i=s.get(e);i?i.push(t):s.set(e,[t])},off:function(e,t){var i=s.get(e);i&&(t?i.splice(i.indexOf(t)>>>0,1):s.set(e,[]))},emit:function(e,t){var i=s.get(e);i&&i.slice().map(function(n){n(t)}),(i=s.get("*"))&&i.slice().map(function(n){n(e,t)})}}}const Dt=D`
|
|
89
|
+
*/function Ne(i,e,t){return i?e(i):t==null?void 0:t(i)}function Da(i){return{all:i=i||new Map,on:function(e,t){var n=i.get(e);n?n.push(t):i.set(e,[t])},off:function(e,t){var n=i.get(e);n&&(t?n.splice(n.indexOf(t)>>>0,1):i.set(e,[]))},emit:function(e,t){var n=i.get(e);n&&n.slice().map(function(s){s(t)}),(n=i.get("*"))&&n.slice().map(function(s){s(e,t)})}}}const Wt=z`
|
|
89
90
|
<svg
|
|
90
91
|
xmlns="http://www.w3.org/2000/svg"
|
|
91
92
|
viewBox="0 0 24 24"
|
|
@@ -97,7 +98,7 @@
|
|
|
97
98
|
<path
|
|
98
99
|
d="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z"/>
|
|
99
100
|
</svg>
|
|
100
|
-
`,
|
|
101
|
+
`,Ua=z`
|
|
101
102
|
<svg
|
|
102
103
|
xmlns="http://www.w3.org/2000/svg"
|
|
103
104
|
viewBox="0 0 24 24"
|
|
@@ -109,7 +110,7 @@
|
|
|
109
110
|
<path
|
|
110
111
|
d="M12,3C17.5,3 22,6.58 22,11C22,15.42 17.5,19 12,19C10.76,19 9.57,18.82 8.47,18.5C5.55,21 2,21 2,21C4.33,18.67 4.7,17.1 4.75,16.5C3.05,15.07 2,13.13 2,11C2,6.58 6.5,3 12,3Z"/>
|
|
111
112
|
</svg>
|
|
112
|
-
`,
|
|
113
|
+
`,Ha=z`
|
|
113
114
|
<svg
|
|
114
115
|
xmlns="http://www.w3.org/2000/svg"
|
|
115
116
|
viewBox="0 0 24 24"
|
|
@@ -120,7 +121,7 @@
|
|
|
120
121
|
<title>send</title>
|
|
121
122
|
<path d="M2,21L23,12L2,3V10L17,12L2,14V21Z"/>
|
|
122
123
|
</svg>
|
|
123
|
-
`,
|
|
124
|
+
`,Ba=z`
|
|
124
125
|
<svg
|
|
125
126
|
xmlns="http://www.w3.org/2000/svg"
|
|
126
127
|
viewBox="0 0 24 24"
|
|
@@ -131,30 +132,30 @@
|
|
|
131
132
|
<title>refresh</title>
|
|
132
133
|
<path d="M17.65,6.35C16.2,4.9 14.21,4 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20C15.73,20 18.84,17.45 19.73,14H17.65C16.83,16.33 14.61,18 12,18A6,6 0 0,1 6,12A6,6 0 0,1 12,6C13.66,6 15.14,6.69 16.22,7.78L13,11H20V4L17.65,6.35Z" />
|
|
133
134
|
</svg>
|
|
134
|
-
`;var
|
|
135
|
+
`;var Wa=Object.defineProperty,Fa=Object.getOwnPropertyDescriptor,he=(i,e,t,n)=>{for(var s=n>1?void 0:n?Fa(e,t):e,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=(n?a(e,t,s):a(s))||s);return n&&s&&Wa(e,t,s),s},xs=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},gt=(i,e,t)=>(xs(i,e,"read from private field"),t?t.call(i):e.get(i)),ks=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},_s=(i,e,t,n)=>(xs(i,e,"write to private field"),n?n.call(i,t):e.set(i,t),t),je,kn;let re=class extends se{constructor(){super(),ks(this,je,void 0),ks(this,kn,Promise.resolve()),this.disableInput=!1,this.showTyping=!1,this.messages=[],this.inputValue="",this.internalDisableInput=!1,this.internalShowTyping=!1,this._emitter=Da(),this._emitter.on("*",(i,e)=>this.dispatchEvent(new CustomEvent(`iai-chat-${i.toString()}`,{bubbles:!0,composed:!0,detail:e})))}connectedCallback(){super.connectedCallback(),this.cleanOptions=xn.parse(this.options||{});const{assistantId:i,params:e,config:t}=this.cleanOptions;_s(this,je,new La(i,{params:e,simulateDelays:t.simulateDelays,historyKey:t.historyKey,initialReplyMessage:t.initialReplyMessage})),this.updateMessages(gt(this,je).messages),this.showTyping=gt(this,je).isTyping,this.disableInput=gt(this,je).inputDisabled,this.chatManager.on("functionCall",({id:n,name:s,params:r})=>{const a=this.cleanOptions.handlers.functionCalls[s];if(!a){console.warn(`No function call handler found for ${s}`);return}a.call(this,{id:n,params:r,html:z,chatWindow:this})}),this.chatManager.on("typing",n=>{this.showTyping=n}),this.chatManager.on("inputDisabled",n=>{this.disableInput=n}),this.chatManager.on("inactivityWarning",()=>{this.addMessage({role:"assistant",content:t.inactivityWarningMessage})}),this.chatManager.on("chatEnded",()=>{this.addMessage({role:"system",content:t.chatEndedMessage}),this.setInputDisabled(!0)}),this.chatManager.on("message",n=>{this.updateMessages([...this.messages,n])}),this.chatManager.on("messageRemoved",n=>{this.updateMessages(this.messages.filter(s=>s.id!==n))}),this.chatManager.on("reset",()=>{this.updateMessages([])}),this.chatManager.on("*",this._emitter.emit)}disconnectedCallback(){super.disconnectedCallback(),this._emitter.all.clear(),gt(this,je).destroy()}firstUpdated(){this.focusOnInput()}updateMessages(i){this.messages=[...i],this.scrollChatToBottom()}render(){const{header:i,showCloseButton:e}=this.cleanOptions.config.chatWindow;return z`
|
|
135
136
|
<div class="flex flex-col h-full rounded-lg shadow-lg bg-white">
|
|
136
137
|
<div class="header rounded-t-lg text-lg p-2 flex justify-between items-center">
|
|
137
138
|
<div class="flex flex-row h-full items-center">
|
|
138
|
-
${Ne(
|
|
139
|
-
<img src="${
|
|
139
|
+
${Ne(i.imageSrc,()=>z`
|
|
140
|
+
<img src="${i.imageSrc}" alt="Logo" style="max-height: 100%" />
|
|
140
141
|
`)}
|
|
141
|
-
${Ne(
|
|
142
|
-
<span class="text-lg font-semibold ml-2">${
|
|
142
|
+
${Ne(i.text,()=>z`
|
|
143
|
+
<span class="text-lg font-semibold ml-2">${i.text}</span>
|
|
143
144
|
`)}
|
|
144
145
|
</div>
|
|
145
146
|
|
|
146
147
|
<div class="flex-grow"></div>
|
|
147
148
|
|
|
148
149
|
<button
|
|
149
|
-
class="mr-2 h-6
|
|
150
|
+
class="mr-2 h-6"
|
|
150
151
|
@click="${this.resetChat}"
|
|
151
152
|
>
|
|
152
|
-
${
|
|
153
|
+
${Ba}
|
|
153
154
|
</button>
|
|
154
155
|
|
|
155
|
-
${Ne(e,()=>
|
|
156
|
-
<button class="mr-2 h-6
|
|
157
|
-
${
|
|
156
|
+
${Ne(e,()=>z`
|
|
157
|
+
<button class="mr-2 h-6" @click="${this.closeChat}">
|
|
158
|
+
${Wt}
|
|
158
159
|
</button>
|
|
159
160
|
`)}
|
|
160
161
|
</div>
|
|
@@ -162,9 +163,9 @@
|
|
|
162
163
|
<div id="chat-container" class="flex-1 overflow-y-auto p-4 flex flex-col gap-2">
|
|
163
164
|
${this.chatMessage({id:"intro-message",role:"assistant",content:this.cleanOptions.config.welcomeMessage})}
|
|
164
165
|
|
|
165
|
-
${
|
|
166
|
+
${is(this.messages,t=>t.id,(t,n)=>z`
|
|
166
167
|
<div>
|
|
167
|
-
${this.nameLabel(
|
|
168
|
+
${this.nameLabel(n)}
|
|
168
169
|
${this.chatMessage(t)}
|
|
169
170
|
</div>
|
|
170
171
|
`)}
|
|
@@ -176,49 +177,51 @@
|
|
|
176
177
|
</div>
|
|
177
178
|
|
|
178
179
|
<form @submit="${this.sendUserMessage}">
|
|
179
|
-
<div class="flex items-
|
|
180
|
-
<
|
|
180
|
+
<div class="flex items-end space-x-2">
|
|
181
|
+
<textarea
|
|
181
182
|
id="message-input"
|
|
182
183
|
type="text"
|
|
183
|
-
class="flex-1 p-2 border rounded-lg
|
|
184
|
+
class="flex-1 p-2 border rounded-lg disabled:bg-gray-200 max-h-20 resize-none"
|
|
185
|
+
rows="1"
|
|
184
186
|
placeholder="Type your message..."
|
|
185
187
|
autocomplete="off"
|
|
186
188
|
.disabled="${this.internalDisableInput||this.disableInput}"
|
|
187
189
|
.value="${this.inputValue}"
|
|
188
|
-
@input="${
|
|
189
|
-
|
|
190
|
+
@input="${this.handleInput}"
|
|
191
|
+
@keydown="${t=>this.handleKeyDown(t)}"
|
|
192
|
+
></textarea>
|
|
190
193
|
<button
|
|
191
194
|
type="submit"
|
|
192
195
|
class="button rounded-lg p-2 disabled:opacity-50 h-9"
|
|
193
|
-
.disabled="${
|
|
196
|
+
.disabled="${this.isSubmitDisabled}"
|
|
194
197
|
>
|
|
195
|
-
${
|
|
198
|
+
${Ha}
|
|
196
199
|
</button>
|
|
197
200
|
</div>
|
|
198
201
|
</form>
|
|
199
202
|
</div>
|
|
200
203
|
</div>
|
|
201
|
-
`}get chatManager(){return
|
|
204
|
+
`}get isSubmitDisabled(){return!this.inputValue||this.internalDisableInput||this.disableInput}handleKeyDown(i){i.key==="Enter"&&!i.shiftKey&&(i.preventDefault(),!this.isSubmitDisabled&&this.sendUserMessage(i))}handleInput(){const{inputElement:i,chatContainer:e}=this;if(!i||!e)return;this.inputValue=i.value;const{scrollTop:t,clientHeight:n,scrollHeight:s}=e,r=t+n>=s;i.style.height="auto",i.style.height=`${i.scrollHeight+2}px`,r&&this.scrollChatToBottom()}get chatManager(){return gt(this,je)}resetChat(){this.chatManager.reset()}addMessage(i){return this.chatManager.addMessage(i)}removeMessage(i){this.chatManager.removeMessage(i)}setInputDisabled(i=!0){this.chatManager.setInputDisabled(i)}setTypingIndicatorVisible(i=!0){this.chatManager.setTyping(i)}async sendFunctionCallResponse(i,e,t=!1){try{await this.chatManager.respondToFunctionCall(i,e,t)}catch(n){console.error("sendFunctionCallResponse error",n),this.addMessage({role:"assistant",content:"An unexpected error occurred. Please try again later."})}}async sendUserMessage(i){i.preventDefault(),!(this.internalDisableInput||this.disableInput)&&(this.internalDisableInput=!0,this.dispatchEvent(new CustomEvent("iai-chat-send-user-message",{bubbles:!0,composed:!0,detail:{message:this.inputValue},cancelable:!0}))&&(await gt(this,kn),_s(this,kn,this.chatManager.sendUserMessage(this.inputValue))),this.inputValue="",this.inputElement&&(this.inputElement.style.height="auto"),this.internalDisableInput=!1,setTimeout(()=>{this.focusOnInput()},0))}focusOnInput(){var i;(i=this.inputElement)==null||i.focus()}scrollChatToBottom(){const{chatContainer:i}=this;i==null||i.scrollTo({top:i==null?void 0:i.scrollHeight,behavior:"smooth"})}nameLabel(i){const e=this.messages[i];if(e.role!=="assistant")return null;const t=e.name||"Assistant",n=this.messages[i-1];return((n==null?void 0:n.name)||"Assistant")===t?null:z`
|
|
202
205
|
<div class="name text-sm">${e.name||"Assistant"}</div>
|
|
203
|
-
`}chatMessage(
|
|
206
|
+
`}chatMessage(i){switch(i.role){case"assistant":return z`
|
|
204
207
|
<iai-chat-message-assistant
|
|
205
|
-
id="message-${
|
|
206
|
-
.content="${
|
|
208
|
+
id="message-${i.id}"
|
|
209
|
+
.content="${i.content}"
|
|
207
210
|
></iai-chat-message-assistant>
|
|
208
|
-
`;case"user":return
|
|
211
|
+
`;case"user":return z`
|
|
209
212
|
<iai-chat-message-user
|
|
210
|
-
id="message-${
|
|
211
|
-
.content="${
|
|
213
|
+
id="message-${i.id}"
|
|
214
|
+
.content="${i.content}"
|
|
212
215
|
></iai-chat-message-user>
|
|
213
|
-
`;case"system":return
|
|
216
|
+
`;case"system":return z`
|
|
214
217
|
<iai-chat-message-system
|
|
215
|
-
id="message-${
|
|
216
|
-
.content="${
|
|
217
|
-
.enhancedContent="${
|
|
218
|
-
.contentHtmlTemplate="${
|
|
218
|
+
id="message-${i.id}"
|
|
219
|
+
.content="${i.content}"
|
|
220
|
+
.enhancedContent="${i.enhancedContent}"
|
|
221
|
+
.contentHtmlTemplate="${i.contentHtmlTemplate}"
|
|
219
222
|
.options="${this.cleanOptions}"
|
|
220
223
|
></iai-chat-message-system>
|
|
221
|
-
`;default:return""}}closeChat(){this._emitter.emit("close")}};
|
|
224
|
+
`;default:return""}}closeChat(){this._emitter.emit("close")}};je=new WeakMap,kn=new WeakMap,re.styles=[$e,Ue`
|
|
222
225
|
.header {
|
|
223
226
|
background-color: var(--iai-chat-i-header-bg);
|
|
224
227
|
color: var(--iai-chat-i-header-fg);
|
|
@@ -234,11 +237,11 @@
|
|
|
234
237
|
.name {
|
|
235
238
|
color: #8c8c8c;
|
|
236
239
|
}
|
|
237
|
-
`],be([F({type:Object})],oe.prototype,"options",2),be([F()],oe.prototype,"disableInput",2),be([F()],oe.prototype,"showTyping",2),be([nt()],oe.prototype,"messages",2),be([nt()],oe.prototype,"inputValue",2),be([nt()],oe.prototype,"internalDisableInput",2),be([nt()],oe.prototype,"internalShowTyping",2),be([Ts.debounce(1)],oe.prototype,"scrollChatToBottom",1),oe=be([Ce("iai-chat")],oe);var Bi={exports:{}};(function(s){(function(e){if(typeof window>"u")return;var t=0,i=!1,n=!1,r="message",a=r.length,o="[iFrameSizer]",c=o.length,l=null,h=window.requestAnimationFrame,m=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),d={},w=null,N=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyMarginV1:8,bodyPadding:null,checkOrigin:!0,inPageLinks:!1,enablePublicMethods:!0,heightCalculationMethod:"bodyOffset",id:"iFrameResizer",interval:32,log:!1,maxHeight:1/0,maxWidth:1/0,minHeight:0,minWidth:0,mouseEvents:!0,resizeFrom:"parent",scrolling:!1,sizeHeight:!0,sizeWidth:!1,warningTimeout:5e3,tolerance:0,widthCalculationMethod:"scroll",onClose:function(){return!0},onClosed:function(){},onInit:function(){},onMessage:function(){ce("onMessage function not defined")},onMouseEnter:function(){},onMouseLeave:function(){},onResized:function(){},onScroll:function(){return!0}});function H(){return window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver}function ee(u,y,M){u.addEventListener(y,M,!1)}function _e(u,y,M){u.removeEventListener(y,M,!1)}function xe(){var u=["moz","webkit","o","ms"],y;for(y=0;y<u.length&&!h;y+=1)h=window[u[y]+"RequestAnimationFrame"];h?h=h.bind(window):O("setup","RequestAnimationFrame not supported")}function te(u){var y="Host page: "+u;return window.top!==window.self&&(y=window.parentIFrame&&window.parentIFrame.getId?window.parentIFrame.getId()+": "+u:"Nested host page: "+u),y}function pt(u){return o+"["+te(u)+"]"}function ke(u){return d[u]?d[u].log:i}function O(u,y){js("log",u,y,ke(u))}function Gi(u,y){js("info",u,y,ke(u))}function ce(u,y){js("warn",u,y,!0)}function js(u,y,M,x){x===!0&&typeof window.console=="object"&&console[u](pt(y),M)}function xa(u){function y(){function v(){sn(R),Qi(S),Qe("onResized",R)}Z("Height"),Z("Width"),nn(v,R,"init")}function M(){var v=le.slice(c).split(":"),A=v[1]?parseInt(v[1],10):0,L=d[v[0]]&&d[v[0]].iframe,z=getComputedStyle(L);return{iframe:L,id:v[0],height:A+x(z)+P(z),width:v[2],type:v[3]}}function x(v){if(v.boxSizing!=="border-box")return 0;var A=v.paddingTop?parseInt(v.paddingTop,10):0,L=v.paddingBottom?parseInt(v.paddingBottom,10):0;return A+L}function P(v){if(v.boxSizing!=="border-box")return 0;var A=v.borderTopWidth?parseInt(v.borderTopWidth,10):0,L=v.borderBottomWidth?parseInt(v.borderBottomWidth,10):0;return A+L}function Z(v){var A=Number(d[S]["max"+v]),L=Number(d[S]["min"+v]),z=v.toLowerCase(),J=Number(R[z]);O(S,"Checking "+z+" is in range "+L+"-"+A),J<L&&(J=L,O(S,"Set "+z+" to min value")),J>A&&(J=A,O(S,"Set "+z+" to max value")),R[z]=""+J}function fe(){function v(){function z(){var X=0,Se=!1;for(O(S,"Checking connection is from allowed list of origins: "+L);X<L.length;X++)if(L[X]===A){Se=!0;break}return Se}function J(){var X=d[S]&&d[S].remoteHost;return O(S,"Checking connection is from: "+X),A===X}return L.constructor===Array?z():J()}var A=u.origin,L=d[S]&&d[S].checkOrigin;if(L&&""+A!="null"&&!v())throw new Error("Unexpected message received from: "+A+" for "+R.iframe.id+". Message was: "+u.data+". This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.");return!0}function Xe(){return o===(""+le).slice(0,c)&&le.slice(c).split(":")[0]in d}function Ee(){var v=R.type in{true:1,false:1,undefined:1};return v&&O(S,"Ignoring init message from meta parent page"),v}function Te(v){return le.slice(le.indexOf(":")+a+v)}function Re(v){O(S,"onMessage passed: {iframe: "+R.iframe.id+", message: "+v+"}"),Qe("onMessage",{iframe:R.iframe,message:JSON.parse(v)}),O(S,"--")}function Us(){var v=document.body.getBoundingClientRect(),A=R.iframe.getBoundingClientRect();return JSON.stringify({iframeHeight:A.height,iframeWidth:A.width,clientHeight:Math.max(document.documentElement.clientHeight,window.innerHeight||0),clientWidth:Math.max(document.documentElement.clientWidth,window.innerWidth||0),offsetTop:parseInt(A.top-v.top,10),offsetLeft:parseInt(A.left-v.left,10),scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,documentHeight:document.documentElement.clientHeight,documentWidth:document.documentElement.clientWidth,windowHeight:window.innerHeight,windowWidth:window.innerWidth})}function gs(v,A){function L(){me("Send Page Info","pageInfo:"+Us(),v,A)}Ea(L,32,A)}function Hs(){function v(J,X){function Se(){d[z]?gs(d[z].iframe,z):A()}["scroll","resize"].forEach(function(dn){O(z,J+dn+" listener for sendPageInfo"),X(window,dn,Se)})}function A(){v("Remove ",_e)}function L(){v("Add ",ee)}var z=S;L(),d[z]&&(d[z].stopPageInfo=A)}function Bs(){d[S]&&d[S].stopPageInfo&&(d[S].stopPageInfo(),delete d[S].stopPageInfo)}function Ws(){var v=!0;return R.iframe===null&&(ce(S,"IFrame ("+R.id+") not found"),v=!1),v}function k(v){var A=v.getBoundingClientRect();return Xi(S),{x:Math.floor(Number(A.left)+Number(l.x)),y:Math.floor(Number(A.top)+Number(l.y))}}function E(v){function A(){l=X,V(),O(S,"--")}function L(){return{x:Number(R.width)+J.x,y:Number(R.height)+J.y}}function z(){window.parentIFrame?window.parentIFrame["scrollTo"+(v?"Offset":"")](X.x,X.y):ce(S,"Unable to scroll to requested position, window.parentIFrame not found")}var J=v?k(R.iframe):{x:0,y:0},X=L();O(S,"Reposition requested from iFrame (offset x:"+J.x+" y:"+J.y+")"),window.top===window.self?A():z()}function V(){Qe("onScroll",l)===!1?en():Qi(S)}function G(v){function A(){var Se=k(X);O(S,"Moving to in page link (#"+z+") at x: "+Se.x+" y: "+Se.y),l={x:Se.x,y:Se.y},V(),O(S,"--")}function L(){window.parentIFrame?window.parentIFrame.moveToAnchor(z):O(S,"In page link #"+z+" not found and window.parentIFrame not found")}var z=v.split("#")[1]||"",J=decodeURIComponent(z),X=document.getElementById(J)||document.getElementsByName(J)[0];X?A():window.top===window.self?O(S,"In page link #"+z+" not found"):L()}function de(v){var A={};if(Number(R.width)===0&&Number(R.height)===0){var L=Te(9).split(":");A={x:L[1],y:L[0]}}else A={x:R.width,y:R.height};Qe(v,{iframe:R.iframe,screenX:Number(A.x),screenY:Number(A.y),type:R.type})}function Qe(v,A){return Rs(S,v,A)}function Fs(){switch(d[S]&&d[S].firstRun&&Js(),R.type){case"close":{Zs(R.iframe);break}case"message":{Re(Te(6));break}case"mouseenter":{de("onMouseEnter");break}case"mouseleave":{de("onMouseLeave");break}case"autoResize":{d[S].autoResize=JSON.parse(Te(9));break}case"scrollTo":{E(!1);break}case"scrollToOffset":{E(!0);break}case"pageInfo":{gs(d[S]&&d[S].iframe,S),Hs();break}case"pageInfoStop":{Bs();break}case"inPageLink":{G(Te(9));break}case"reset":{tn(R);break}case"init":{y(),Qe("onInit",R.iframe);break}default:Number(R.width)===0&&Number(R.height)===0?ce("Unsupported message received ("+R.type+"), this is likely due to the iframe containing a later version of iframe-resizer than the parent page"):y()}}function Vs(v){var A=!0;return d[v]||(A=!1,ce(R.type+" No settings for "+v+". Message was: "+le)),A}function Ks(){for(var v in d)me("iFrame requested init",rn(v),d[v].iframe,v)}function Js(){d[S]&&(d[S].firstRun=!1)}var le=u.data,R={},S=null;le==="[iFrameResizerChild]Ready"?Ks():Xe()?(R=M(),S=R.id,d[S]&&(d[S].loaded=!0),!Ee()&&Vs(S)&&(O(S,"Received: "+le),Ws()&&fe()&&Fs())):Gi(S,"Ignored: "+le)}function Rs(u,y,M){var x=null,P=null;if(d[u])if(x=d[u][y],typeof x=="function")P=x(M);else throw new TypeError(y+" on iFrame["+u+"] is not a function");return P}function Yi(u){var y=u.id;delete d[y]}function Zs(u){var y=u.id;if(Rs(y,"onClose",y)===!1){O(y,"Close iframe cancelled by onClose event");return}O(y,"Removing iFrame: "+y);try{u.parentNode&&u.parentNode.removeChild(u)}catch(M){ce(M)}Rs(y,"onClosed",y),O(y,"--"),Yi(u)}function Xi(u){l===null&&(l={x:window.pageXOffset===e?document.documentElement.scrollLeft:window.pageXOffset,y:window.pageYOffset===e?document.documentElement.scrollTop:window.pageYOffset},O(u,"Get page position: "+l.x+","+l.y))}function Qi(u){l!==null&&(window.scrollTo(l.x,l.y),O(u,"Set page position: "+l.x+","+l.y),en())}function en(){l=null}function tn(u){function y(){sn(u),me("reset","reset",u.iframe,u.id)}O(u.id,"Size reset requested by "+(u.type==="init"?"host page":"iFrame")),Xi(u.id),nn(y,u,"reset")}function sn(u){function y(Z){if(!u.id){O("undefined","messageData id not set");return}u.iframe.style[Z]=u[Z]+"px",O(u.id,"IFrame ("+P+") "+Z+" set to "+u[Z]+"px")}function M(Z){!n&&u[Z]==="0"&&(n=!0,O(P,"Hidden iFrame detected, creating visibility listener"),Ta())}function x(Z){y(Z),M(Z)}var P=u.iframe.id;d[P]&&(d[P].sizeHeight&&x("height"),d[P].sizeWidth&&x("width"))}function nn(u,y,M){M!==y.type&&h&&!window.jasmine?(O(y.id,"Requesting animation frame"),h(u)):u()}function me(u,y,M,x,P){function Z(){var Re=d[x]&&d[x].targetOrigin;O(x,"["+u+"] Sending msg to iframe["+x+"] ("+y+") targetOrigin: "+Re),M.contentWindow.postMessage(o+y,Re)}function fe(){ce(x,"["+u+"] IFrame("+x+") not found")}function Xe(){M&&"contentWindow"in M&&M.contentWindow!==null?Z():fe()}function Ee(){function Re(){d[x]&&!d[x].loaded&&!Te&&(Te=!0,ce(x,"IFrame has not responded within "+d[x].warningTimeout/1e3+" seconds. Check iFrameResizer.contentWindow.js has been loaded in iFrame. This message can be ignored if everything is working, or you can set the warningTimeout option to a higher value or zero to suppress this warning."))}P&&d[x]&&d[x].warningTimeout&&(d[x].msgTimeout=setTimeout(Re,d[x].warningTimeout))}var Te=!1;x=x||M.id,d[x]&&(Xe(),Ee())}function rn(u){return u+":"+d[u].bodyMarginV1+":"+d[u].sizeWidth+":"+d[u].log+":"+d[u].interval+":"+d[u].enablePublicMethods+":"+d[u].autoResize+":"+d[u].bodyMargin+":"+d[u].heightCalculationMethod+":"+d[u].bodyBackground+":"+d[u].bodyPadding+":"+d[u].tolerance+":"+d[u].inPageLinks+":"+d[u].resizeFrom+":"+d[u].widthCalculationMethod+":"+d[u].mouseEvents}function ka(u){return typeof u=="number"}function an(u,y){function M(){function E(G){var de=d[k][G];de!==1/0&&de!==0&&(u.style[G]=ka(de)?de+"px":de,O(k,"Set "+G+" = "+u.style[G]))}function V(G){if(d[k]["min"+G]>d[k]["max"+G])throw new Error("Value for min"+G+" can not be greater than max"+G)}V("Height"),V("Width"),E("maxHeight"),E("minHeight"),E("maxWidth"),E("minWidth")}function x(){var E=y&&y.id||N.id+t++;return document.getElementById(E)!==null&&(E+=t++),E}function P(E){if(typeof E!="string")throw new TypeError("Invaild id for iFrame. Expected String");return E===""&&(u.id=E=x(),i=(y||{}).log,O(E,"Added missing iframe ID: "+E+" ("+u.src+")")),E}function Z(){switch(O(k,"IFrame scrolling "+(d[k]&&d[k].scrolling?"enabled":"disabled")+" for "+k),u.style.overflow=(d[k]&&d[k].scrolling)===!1?"hidden":"auto",d[k]&&d[k].scrolling){case"omit":break;case!0:{u.scrolling="yes";break}case!1:{u.scrolling="no";break}default:u.scrolling=d[k]?d[k].scrolling:"no"}}function fe(){(typeof(d[k]&&d[k].bodyMargin)=="number"||(d[k]&&d[k].bodyMargin)==="0")&&(d[k].bodyMarginV1=d[k].bodyMargin,d[k].bodyMargin=""+d[k].bodyMargin+"px")}function Xe(){var E=d[k]&&d[k].firstRun,V=d[k]&&d[k].heightCalculationMethod in m;!E&&V&&tn({iframe:u,height:0,width:0,type:"init"})}function Ee(){d[k]&&(d[k].iframe.iFrameResizer={close:Zs.bind(null,d[k].iframe),removeListeners:Yi.bind(null,d[k].iframe),resize:me.bind(null,"Window resize","resize",d[k].iframe),moveToAnchor:function(E){me("Move to anchor","moveToAnchor:"+E,d[k].iframe,k)},sendMessage:function(E){E=JSON.stringify(E),me("Send Message","message:"+E,d[k].iframe,k)}})}function Te(E){function V(){me("iFrame.onload",E,u,e,!0),Xe()}function G(Qe){if(u.parentNode){var Fs=new Qe(function(Vs){Vs.forEach(function(Ks){var Js=Array.prototype.slice.call(Ks.removedNodes);Js.forEach(function(le){le===u&&Zs(u)})})});Fs.observe(u.parentNode,{childList:!0})}}var de=H();de&&G(de),ee(u,"load",V),me("init",E,u,e,!0)}function Re(E){if(typeof E!="object")throw new TypeError("Options is not an object")}function Us(E){for(var V in N)Object.prototype.hasOwnProperty.call(N,V)&&(d[k][V]=Object.prototype.hasOwnProperty.call(E,V)?E[V]:N[V])}function gs(E){return E===""||E.match(/^(about:blank|javascript:|file:\/\/)/)!==null?"*":E}function Hs(E){var V=E.split("Callback");if(V.length===2){var G="on"+V[0].charAt(0).toUpperCase()+V[0].slice(1);this[G]=this[E],delete this[E],ce(k,"Deprecated: '"+E+"' has been renamed '"+G+"'. The old method will be removed in the next major version.")}}function Bs(E){E=E||{},d[k]=Object.create(null),d[k].iframe=u,d[k].firstRun=!0,d[k].remoteHost=u.src&&u.src.split("/").slice(0,3).join("/"),Re(E),Object.keys(E).forEach(Hs,E),Us(E),d[k]&&(d[k].targetOrigin=d[k].checkOrigin===!0?gs(d[k].remoteHost):"*")}function Ws(){return k in d&&"iFrameResizer"in u}var k=P(u.id);Ws()?ce(k,"Ignored iFrame, already setup."):(Bs(y),Z(),M(),fe(),Te(rn(k)),Ee())}function Ds(u,y){w===null&&(w=setTimeout(function(){w=null,u()},y))}var Ls={};function Ea(u,y,M){Ls[M]||(Ls[M]=setTimeout(function(){Ls[M]=null,u()},y))}function Ta(){function u(){function P(Z){function fe(Ee){return(d[Z]&&d[Z].iframe.style[Ee])==="0px"}function Xe(Ee){return Ee.offsetParent!==null}d[Z]&&Xe(d[Z].iframe)&&(fe("height")||fe("width"))&&me("Visibility change","resize",d[Z].iframe,Z)}Object.keys(d).forEach(function(Z){P(Z)})}function y(P){O("window","Mutation observed: "+P[0].target+" "+P[0].type),Ds(u,16)}function M(){var P=document.querySelector("body"),Z={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0},fe=new x(y);fe.observe(P,Z)}var x=H();x&&M()}function Sa(u){function y(){cn("Window "+u,"resize")}O("window","Trigger event: "+u),Ds(y,16)}function on(){function u(){cn("Tab Visible","resize")}document.visibilityState!=="hidden"&&(O("document","Trigger event: Visibility change"),Ds(u,16))}function cn(u,y){function M(x){return d[x]&&d[x].resizeFrom==="parent"&&d[x].autoResize&&!d[x].firstRun}Object.keys(d).forEach(function(x){M(x)&&me(u,y,d[x].iframe,x)})}function Ca(){ee(window,"message",xa),ee(window,"resize",function(){Sa("resize")}),ee(document,"visibilitychange",on),ee(document,"-webkit-visibilitychange",on)}function zs(){function u(x,P){function Z(){if(P.tagName){if(P.tagName.toUpperCase()!=="IFRAME")throw new TypeError("Expected <IFRAME> tag, found <"+P.tagName+">")}else throw new TypeError("Object is not a valid DOM element")}P&&(Z(),an(P,x),M.push(P))}function y(x){x&&x.enablePublicMethods&&ce("enablePublicMethods option has been removed, public methods are now always available in the iFrame")}var M;return xe(),Ca(),function(x,P){switch(M=[],y(x),typeof P){case"undefined":case"string":{Array.prototype.forEach.call(document.querySelectorAll(P||"iframe"),u.bind(e,x));break}case"object":{u(x,P);break}default:throw new TypeError("Unexpected data type ("+typeof P+")")}return M}}function $a(u){u.fn?u.fn.iFrameResize||(u.fn.iFrameResize=function(y){function M(x,P){an(P,y)}return this.filter("iframe").each(M).end()}):Gi("","Unable to bind to jQuery, it is not fully loaded.")}window.jQuery!==e&&$a(window.jQuery),typeof e=="function"&&e.amd?e([],zs):s.exports=zs(),window.iFrameResize=window.iFrameResize||zs()})()})(Bi);var Kr=Bi.exports;const Jr=Ci(Kr);var qr=Object.defineProperty,Gr=Object.getOwnPropertyDescriptor,Ns=(s,e,t,i)=>{for(var n=i>1?void 0:i?Gr(e,t):e,r=s.length-1,a;r>=0;r--)(a=s[r])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&qr(e,t,n),n};let Lt=class extends se{constructor(){super(...arguments),this.src="",this.showCloseButton=!1}async onLoad(s){Jr({log:!1,heightCalculationMethod:"max",onMessage:({message:e})=>{this.dispatchEvent(new CustomEvent("message-received",{bubbles:!0,composed:!0,detail:e}))}},s.target)}close(){this.dispatchEvent(new CustomEvent("close"))}render(){return D`
|
|
240
|
+
`],he([V({type:Object})],re.prototype,"options",2),he([V()],re.prototype,"disableInput",2),he([V()],re.prototype,"showTyping",2),he([ht()],re.prototype,"messages",2),he([ht()],re.prototype,"inputValue",2),he([ht()],re.prototype,"internalDisableInput",2),he([ht()],re.prototype,"internalShowTyping",2),he([sn("#chat-container")],re.prototype,"chatContainer",2),he([sn("#message-input")],re.prototype,"inputElement",2),he([Jn.debounce(1)],re.prototype,"scrollChatToBottom",1),re=he([_e("iai-chat")],re);var $s={exports:{}};(function(i){(function(e){if(typeof window>"u")return;var t=0,n=!1,s=!1,r="message",a=r.length,o="[iFrameSizer]",l=o.length,d=null,h=window.requestAnimationFrame,p=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),c={},f=null,O=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyMarginV1:8,bodyPadding:null,checkOrigin:!0,inPageLinks:!1,enablePublicMethods:!0,heightCalculationMethod:"bodyOffset",id:"iFrameResizer",interval:32,log:!1,maxHeight:1/0,maxWidth:1/0,minHeight:0,minWidth:0,mouseEvents:!0,resizeFrom:"parent",scrolling:!1,sizeHeight:!0,sizeWidth:!1,warningTimeout:5e3,tolerance:0,widthCalculationMethod:"scroll",onClose:function(){return!0},onClosed:function(){},onInit:function(){},onMessage:function(){ue("onMessage function not defined")},onMouseEnter:function(){},onMouseLeave:function(){},onResized:function(){},onScroll:function(){return!0}});function H(){return window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver}function Q(u,v,M){u.addEventListener(v,M,!1)}function Ze(u,v,M){u.removeEventListener(v,M,!1)}function jn(){var u=["moz","webkit","o","ms"],v;for(v=0;v<u.length&&!h;v+=1)h=window[u[v]+"RequestAnimationFrame"];h?h=h.bind(window):P("setup","RequestAnimationFrame not supported")}function zn(u){var v="Host page: "+u;return window.top!==window.self&&(v=window.parentIFrame&&window.parentIFrame.getId?window.parentIFrame.getId()+": "+u:"Nested host page: "+u),v}function Zn(u){return o+"["+zn(u)+"]"}function wt(u){return c[u]?c[u].log:n}function P(u,v){mi("log",u,v,wt(u))}function Ks(u,v){mi("info",u,v,wt(u))}function ue(u,v){mi("warn",u,v,!0)}function mi(u,v,M,k){k===!0&&typeof window.console=="object"&&console[u](Zn(v),M)}function sl(u){function v(){function b(){er(j),Qs(E),at("onResized",j)}L("Height"),L("Width"),tr(b,j,"init")}function M(){var b=me.slice(l).split(":"),A=b[1]?parseInt(b[1],10):0,U=c[b[0]]&&c[b[0]].iframe,B=getComputedStyle(U);return{iframe:U,id:b[0],height:A+k(B)+R(B),width:b[2],type:b[3]}}function k(b){if(b.boxSizing!=="border-box")return 0;var A=b.paddingTop?parseInt(b.paddingTop,10):0,U=b.paddingBottom?parseInt(b.paddingBottom,10):0;return A+U}function R(b){if(b.boxSizing!=="border-box")return 0;var A=b.borderTopWidth?parseInt(b.borderTopWidth,10):0,U=b.borderBottomWidth?parseInt(b.borderBottomWidth,10):0;return A+U}function L(b){var A=Number(c[E]["max"+b]),U=Number(c[E]["min"+b]),B=b.toLowerCase(),Y=Number(j[B]);P(E,"Checking "+B+" is in range "+U+"-"+A),Y<U&&(Y=U,P(E,"Set "+B+" to min value")),Y>A&&(Y=A,P(E,"Set "+B+" to max value")),j[B]=""+Y}function xe(){function b(){function B(){var ne=0,Ie=!1;for(P(E,"Checking connection is from allowed list of origins: "+U);ne<U.length;ne++)if(U[ne]===A){Ie=!0;break}return Ie}function Y(){var ne=c[E]&&c[E].remoteHost;return P(E,"Checking connection is from: "+ne),A===ne}return U.constructor===Array?B():Y()}var A=u.origin,U=c[E]&&c[E].checkOrigin;if(U&&""+A!="null"&&!b())throw new Error("Unexpected message received from: "+A+" for "+j.iframe.id+". Message was: "+u.data+". This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.");return!0}function rt(){return o===(""+me).slice(0,l)&&me.slice(l).split(":")[0]in c}function Ce(){var b=j.type in{true:1,false:1,undefined:1};return b&&P(E,"Ignoring init message from meta parent page"),b}function Ae(b){return me.slice(me.indexOf(":")+a+b)}function Le(b){P(E,"onMessage passed: {iframe: "+j.iframe.id+", message: "+b+"}"),at("onMessage",{iframe:j.iframe,message:JSON.parse(b)}),P(E,"--")}function wi(){var b=document.body.getBoundingClientRect(),A=j.iframe.getBoundingClientRect();return JSON.stringify({iframeHeight:A.height,iframeWidth:A.width,clientHeight:Math.max(document.documentElement.clientHeight,window.innerHeight||0),clientWidth:Math.max(document.documentElement.clientWidth,window.innerWidth||0),offsetTop:parseInt(A.top-b.top,10),offsetLeft:parseInt(A.left-b.left,10),scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,documentHeight:document.documentElement.clientHeight,documentWidth:document.documentElement.clientWidth,windowHeight:window.innerHeight,windowWidth:window.innerWidth})}function Ln(b,A){function U(){we("Send Page Info","pageInfo:"+wi(),b,A)}al(U,32,A)}function xi(){function b(Y,ne){function Ie(){c[B]?Ln(c[B].iframe,B):A()}["scroll","resize"].forEach(function(ar){P(B,Y+ar+" listener for sendPageInfo"),ne(window,ar,Ie)})}function A(){b("Remove ",Ze)}function U(){b("Add ",Q)}var B=E;U(),c[B]&&(c[B].stopPageInfo=A)}function ki(){c[E]&&c[E].stopPageInfo&&(c[E].stopPageInfo(),delete c[E].stopPageInfo)}function _i(){var b=!0;return j.iframe===null&&(ue(E,"IFrame ("+j.id+") not found"),b=!1),b}function _(b){var A=b.getBoundingClientRect();return Gs(E),{x:Math.floor(Number(A.left)+Number(d.x)),y:Math.floor(Number(A.top)+Number(d.y))}}function $(b){function A(){d=ne,G(),P(E,"--")}function U(){return{x:Number(j.width)+Y.x,y:Number(j.height)+Y.y}}function B(){window.parentIFrame?window.parentIFrame["scrollTo"+(b?"Offset":"")](ne.x,ne.y):ue(E,"Unable to scroll to requested position, window.parentIFrame not found")}var Y=b?_(j.iframe):{x:0,y:0},ne=U();P(E,"Reposition requested from iFrame (offset x:"+Y.x+" y:"+Y.y+")"),window.top===window.self?A():B()}function G(){at("onScroll",d)===!1?Ys():Qs(E)}function ee(b){function A(){var Ie=_(ne);P(E,"Moving to in page link (#"+B+") at x: "+Ie.x+" y: "+Ie.y),d={x:Ie.x,y:Ie.y},G(),P(E,"--")}function U(){window.parentIFrame?window.parentIFrame.moveToAnchor(B):P(E,"In page link #"+B+" not found and window.parentIFrame not found")}var B=b.split("#")[1]||"",Y=decodeURIComponent(B),ne=document.getElementById(Y)||document.getElementsByName(Y)[0];ne?A():window.top===window.self?P(E,"In page link #"+B+" not found"):U()}function pe(b){var A={};if(Number(j.width)===0&&Number(j.height)===0){var U=Ae(9).split(":");A={x:U[1],y:U[0]}}else A={x:j.width,y:j.height};at(b,{iframe:j.iframe,screenX:Number(A.x),screenY:Number(A.y),type:j.type})}function at(b,A){return fi(E,b,A)}function $i(){switch(c[E]&&c[E].firstRun&&Si(),j.type){case"close":{gi(j.iframe);break}case"message":{Le(Ae(6));break}case"mouseenter":{pe("onMouseEnter");break}case"mouseleave":{pe("onMouseLeave");break}case"autoResize":{c[E].autoResize=JSON.parse(Ae(9));break}case"scrollTo":{$(!1);break}case"scrollToOffset":{$(!0);break}case"pageInfo":{Ln(c[E]&&c[E].iframe,E),xi();break}case"pageInfoStop":{ki();break}case"inPageLink":{ee(Ae(9));break}case"reset":{Xs(j);break}case"init":{v(),at("onInit",j.iframe);break}default:Number(j.width)===0&&Number(j.height)===0?ue("Unsupported message received ("+j.type+"), this is likely due to the iframe containing a later version of iframe-resizer than the parent page"):v()}}function Ti(b){var A=!0;return c[b]||(A=!1,ue(j.type+" No settings for "+b+". Message was: "+me)),A}function Ei(){for(var b in c)we("iFrame requested init",nr(b),c[b].iframe,b)}function Si(){c[E]&&(c[E].firstRun=!1)}var me=u.data,j={},E=null;me==="[iFrameResizerChild]Ready"?Ei():rt()?(j=M(),E=j.id,c[E]&&(c[E].loaded=!0),!Ce()&&Ti(E)&&(P(E,"Received: "+me),_i()&&xe()&&$i())):Ks(E,"Ignored: "+me)}function fi(u,v,M){var k=null,R=null;if(c[u])if(k=c[u][v],typeof k=="function")R=k(M);else throw new TypeError(v+" on iFrame["+u+"] is not a function");return R}function Js(u){var v=u.id;delete c[v]}function gi(u){var v=u.id;if(fi(v,"onClose",v)===!1){P(v,"Close iframe cancelled by onClose event");return}P(v,"Removing iFrame: "+v);try{u.parentNode&&u.parentNode.removeChild(u)}catch(M){ue(M)}fi(v,"onClosed",v),P(v,"--"),Js(u)}function Gs(u){d===null&&(d={x:window.pageXOffset===e?document.documentElement.scrollLeft:window.pageXOffset,y:window.pageYOffset===e?document.documentElement.scrollTop:window.pageYOffset},P(u,"Get page position: "+d.x+","+d.y))}function Qs(u){d!==null&&(window.scrollTo(d.x,d.y),P(u,"Set page position: "+d.x+","+d.y),Ys())}function Ys(){d=null}function Xs(u){function v(){er(u),we("reset","reset",u.iframe,u.id)}P(u.id,"Size reset requested by "+(u.type==="init"?"host page":"iFrame")),Gs(u.id),tr(v,u,"reset")}function er(u){function v(L){if(!u.id){P("undefined","messageData id not set");return}u.iframe.style[L]=u[L]+"px",P(u.id,"IFrame ("+R+") "+L+" set to "+u[L]+"px")}function M(L){!s&&u[L]==="0"&&(s=!0,P(R,"Hidden iFrame detected, creating visibility listener"),ol())}function k(L){v(L),M(L)}var R=u.iframe.id;c[R]&&(c[R].sizeHeight&&k("height"),c[R].sizeWidth&&k("width"))}function tr(u,v,M){M!==v.type&&h&&!window.jasmine?(P(v.id,"Requesting animation frame"),h(u)):u()}function we(u,v,M,k,R){function L(){var Le=c[k]&&c[k].targetOrigin;P(k,"["+u+"] Sending msg to iframe["+k+"] ("+v+") targetOrigin: "+Le),M.contentWindow.postMessage(o+v,Le)}function xe(){ue(k,"["+u+"] IFrame("+k+") not found")}function rt(){M&&"contentWindow"in M&&M.contentWindow!==null?L():xe()}function Ce(){function Le(){c[k]&&!c[k].loaded&&!Ae&&(Ae=!0,ue(k,"IFrame has not responded within "+c[k].warningTimeout/1e3+" seconds. Check iFrameResizer.contentWindow.js has been loaded in iFrame. This message can be ignored if everything is working, or you can set the warningTimeout option to a higher value or zero to suppress this warning."))}R&&c[k]&&c[k].warningTimeout&&(c[k].msgTimeout=setTimeout(Le,c[k].warningTimeout))}var Ae=!1;k=k||M.id,c[k]&&(rt(),Ce())}function nr(u){return u+":"+c[u].bodyMarginV1+":"+c[u].sizeWidth+":"+c[u].log+":"+c[u].interval+":"+c[u].enablePublicMethods+":"+c[u].autoResize+":"+c[u].bodyMargin+":"+c[u].heightCalculationMethod+":"+c[u].bodyBackground+":"+c[u].bodyPadding+":"+c[u].tolerance+":"+c[u].inPageLinks+":"+c[u].resizeFrom+":"+c[u].widthCalculationMethod+":"+c[u].mouseEvents}function rl(u){return typeof u=="number"}function ir(u,v){function M(){function $(ee){var pe=c[_][ee];pe!==1/0&&pe!==0&&(u.style[ee]=rl(pe)?pe+"px":pe,P(_,"Set "+ee+" = "+u.style[ee]))}function G(ee){if(c[_]["min"+ee]>c[_]["max"+ee])throw new Error("Value for min"+ee+" can not be greater than max"+ee)}G("Height"),G("Width"),$("maxHeight"),$("minHeight"),$("maxWidth"),$("minWidth")}function k(){var $=v&&v.id||O.id+t++;return document.getElementById($)!==null&&($+=t++),$}function R($){if(typeof $!="string")throw new TypeError("Invaild id for iFrame. Expected String");return $===""&&(u.id=$=k(),n=(v||{}).log,P($,"Added missing iframe ID: "+$+" ("+u.src+")")),$}function L(){switch(P(_,"IFrame scrolling "+(c[_]&&c[_].scrolling?"enabled":"disabled")+" for "+_),u.style.overflow=(c[_]&&c[_].scrolling)===!1?"hidden":"auto",c[_]&&c[_].scrolling){case"omit":break;case!0:{u.scrolling="yes";break}case!1:{u.scrolling="no";break}default:u.scrolling=c[_]?c[_].scrolling:"no"}}function xe(){(typeof(c[_]&&c[_].bodyMargin)=="number"||(c[_]&&c[_].bodyMargin)==="0")&&(c[_].bodyMarginV1=c[_].bodyMargin,c[_].bodyMargin=""+c[_].bodyMargin+"px")}function rt(){var $=c[_]&&c[_].firstRun,G=c[_]&&c[_].heightCalculationMethod in p;!$&&G&&Xs({iframe:u,height:0,width:0,type:"init"})}function Ce(){c[_]&&(c[_].iframe.iFrameResizer={close:gi.bind(null,c[_].iframe),removeListeners:Js.bind(null,c[_].iframe),resize:we.bind(null,"Window resize","resize",c[_].iframe),moveToAnchor:function($){we("Move to anchor","moveToAnchor:"+$,c[_].iframe,_)},sendMessage:function($){$=JSON.stringify($),we("Send Message","message:"+$,c[_].iframe,_)}})}function Ae($){function G(){we("iFrame.onload",$,u,e,!0),rt()}function ee(at){if(u.parentNode){var $i=new at(function(Ti){Ti.forEach(function(Ei){var Si=Array.prototype.slice.call(Ei.removedNodes);Si.forEach(function(me){me===u&&gi(u)})})});$i.observe(u.parentNode,{childList:!0})}}var pe=H();pe&&ee(pe),Q(u,"load",G),we("init",$,u,e,!0)}function Le($){if(typeof $!="object")throw new TypeError("Options is not an object")}function wi($){for(var G in O)Object.prototype.hasOwnProperty.call(O,G)&&(c[_][G]=Object.prototype.hasOwnProperty.call($,G)?$[G]:O[G])}function Ln($){return $===""||$.match(/^(about:blank|javascript:|file:\/\/)/)!==null?"*":$}function xi($){var G=$.split("Callback");if(G.length===2){var ee="on"+G[0].charAt(0).toUpperCase()+G[0].slice(1);this[ee]=this[$],delete this[$],ue(_,"Deprecated: '"+$+"' has been renamed '"+ee+"'. The old method will be removed in the next major version.")}}function ki($){$=$||{},c[_]=Object.create(null),c[_].iframe=u,c[_].firstRun=!0,c[_].remoteHost=u.src&&u.src.split("/").slice(0,3).join("/"),Le($),Object.keys($).forEach(xi,$),wi($),c[_]&&(c[_].targetOrigin=c[_].checkOrigin===!0?Ln(c[_].remoteHost):"*")}function _i(){return _ in c&&"iFrameResizer"in u}var _=R(u.id);_i()?ue(_,"Ignored iFrame, already setup."):(ki(v),L(),M(),xe(),Ae(nr(_)),Ce())}function yi(u,v){f===null&&(f=setTimeout(function(){f=null,u()},v))}var vi={};function al(u,v,M){vi[M]||(vi[M]=setTimeout(function(){vi[M]=null,u()},v))}function ol(){function u(){function R(L){function xe(Ce){return(c[L]&&c[L].iframe.style[Ce])==="0px"}function rt(Ce){return Ce.offsetParent!==null}c[L]&&rt(c[L].iframe)&&(xe("height")||xe("width"))&&we("Visibility change","resize",c[L].iframe,L)}Object.keys(c).forEach(function(L){R(L)})}function v(R){P("window","Mutation observed: "+R[0].target+" "+R[0].type),yi(u,16)}function M(){var R=document.querySelector("body"),L={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0},xe=new k(v);xe.observe(R,L)}var k=H();k&&M()}function ll(u){function v(){rr("Window "+u,"resize")}P("window","Trigger event: "+u),yi(v,16)}function sr(){function u(){rr("Tab Visible","resize")}document.visibilityState!=="hidden"&&(P("document","Trigger event: Visibility change"),yi(u,16))}function rr(u,v){function M(k){return c[k]&&c[k].resizeFrom==="parent"&&c[k].autoResize&&!c[k].firstRun}Object.keys(c).forEach(function(k){M(k)&&we(u,v,c[k].iframe,k)})}function cl(){Q(window,"message",sl),Q(window,"resize",function(){ll("resize")}),Q(document,"visibilitychange",sr),Q(document,"-webkit-visibilitychange",sr)}function bi(){function u(k,R){function L(){if(R.tagName){if(R.tagName.toUpperCase()!=="IFRAME")throw new TypeError("Expected <IFRAME> tag, found <"+R.tagName+">")}else throw new TypeError("Object is not a valid DOM element")}R&&(L(),ir(R,k),M.push(R))}function v(k){k&&k.enablePublicMethods&&ue("enablePublicMethods option has been removed, public methods are now always available in the iFrame")}var M;return jn(),cl(),function(k,R){switch(M=[],v(k),typeof R){case"undefined":case"string":{Array.prototype.forEach.call(document.querySelectorAll(R||"iframe"),u.bind(e,k));break}case"object":{u(k,R);break}default:throw new TypeError("Unexpected data type ("+typeof R+")")}return M}}function dl(u){u.fn?u.fn.iFrameResize||(u.fn.iFrameResize=function(v){function M(k,R){ir(R,v)}return this.filter("iframe").each(M).end()}):Ks("","Unable to bind to jQuery, it is not fully loaded.")}window.jQuery!==e&&dl(window.jQuery),typeof e=="function"&&e.amd?e([],bi):i.exports=bi(),window.iFrameResize=window.iFrameResize||bi()})()})($s);var Va=$s.exports;const qa=Lr(Va);var Ka=Object.defineProperty,Ja=Object.getOwnPropertyDescriptor,ni=(i,e,t,n)=>{for(var s=n>1?void 0:n?Ja(e,t):e,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=(n?a(e,t,s):a(s))||s);return n&&s&&Ka(e,t,s),s};let Ft=class extends se{constructor(){super(...arguments),this.src="",this.showCloseButton=!1}async onLoad(i){qa({log:!1,heightCalculationMethod:"max",onMessage:({message:e})=>{this.dispatchEvent(new CustomEvent("message-received",{bubbles:!0,composed:!0,detail:e}))}},i.target)}close(){this.dispatchEvent(new CustomEvent("close"))}render(){return z`
|
|
238
241
|
<div class="relative">
|
|
239
|
-
${Ne(this.showCloseButton,()=>
|
|
242
|
+
${Ne(this.showCloseButton,()=>z`
|
|
240
243
|
<button class="absolute top-0 right-0 m-2 h-6 text-white focus:outline-none" @click="${this.close}">
|
|
241
|
-
${
|
|
244
|
+
${Wt}
|
|
242
245
|
</button>
|
|
243
246
|
`)}
|
|
244
247
|
|
|
@@ -248,21 +251,21 @@
|
|
|
248
251
|
@load=${this.onLoad}
|
|
249
252
|
></iframe>
|
|
250
253
|
</div>
|
|
251
|
-
`}};
|
|
254
|
+
`}};Ft.styles=[$e],ni([V({type:String})],Ft.prototype,"src",2),ni([V({type:Boolean})],Ft.prototype,"showCloseButton",2),Ft=ni([_e("iai-chat-iframe")],Ft);var Ga=Object.defineProperty,Qa=Object.getOwnPropertyDescriptor,yt=(i,e,t,n)=>{for(var s=n>1?void 0:n?Qa(e,t):e,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=(n?a(e,t,s):a(s))||s);return n&&s&&Ga(e,t,s),s};let ze=class extends se{constructor(){super(...arguments),this.title="",this.src="",this.width="500px",this.height=null,this.showHeader=!0}async connectedCallback(){super.connectedCallback()}close(){this.dispatchEvent(new CustomEvent("close"))}render(){const i=Je({width:this.width,height:this.height});return z`
|
|
252
255
|
<div class="fixed inset-0 z-50 bg-black bg-opacity-50 flex justify-center items-center">
|
|
253
256
|
<div
|
|
254
257
|
class="flex flex-col rounded-lg shadow-lg bg-white mx-auto my-auto max-h-[90vh] max-w-[90vw] overflow-hidden"
|
|
255
|
-
style=${
|
|
258
|
+
style=${i}
|
|
256
259
|
part="modal"
|
|
257
260
|
>
|
|
258
|
-
${Ne(this.showHeader,()=>
|
|
261
|
+
${Ne(this.showHeader,()=>z`
|
|
259
262
|
<div class="header text-lg p-2 flex justify-between items-center">
|
|
260
263
|
<div class="flex flex-row h-full items-center">
|
|
261
264
|
<span class="text-lg font-semibold ml-2">${this.title}</span>
|
|
262
265
|
</div>
|
|
263
266
|
|
|
264
267
|
<button class="mr-2 h-6 text-white focus:outline-none" @click="${this.close}">
|
|
265
|
-
${
|
|
268
|
+
${Wt}
|
|
266
269
|
</button>
|
|
267
270
|
</div>
|
|
268
271
|
`)}
|
|
@@ -276,103 +279,198 @@
|
|
|
276
279
|
</div>
|
|
277
280
|
</div>
|
|
278
281
|
</div>
|
|
279
|
-
`}};
|
|
282
|
+
`}};ze.styles=[$e,Ue`
|
|
280
283
|
.header {
|
|
281
284
|
background-color: var(--iai-chat-i-iframe-modal-header-bg);
|
|
282
285
|
color: var(--iai-chat-i-iframe-modal-header-fg);
|
|
283
286
|
height: 50px;
|
|
284
287
|
}
|
|
285
|
-
`],
|
|
288
|
+
`],yt([V({type:String})],ze.prototype,"title",2),yt([V({type:String})],ze.prototype,"src",2),yt([V({type:String})],ze.prototype,"width",2),yt([V({type:String})],ze.prototype,"height",2),yt([V({type:Boolean})],ze.prototype,"showHeader",2),ze=yt([_e("iai-chat-iframe-modal")],ze);/**
|
|
286
289
|
* @license
|
|
287
290
|
* Copyright 2017 Google LLC
|
|
288
291
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
289
|
-
*/class
|
|
290
|
-
`)
|
|
291
|
-
`)
|
|
292
|
-
|
|
292
|
+
*/class ii extends on{constructor(e){if(super(e),this.it=J,e.type!==rn.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===J||e==null)return this._t=void 0,this.it=e;if(e===fe)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;const t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}}ii.directiveName="unsafeHTML",ii.resultType=1;const Ts=an(ii);function si(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let tt=si();function Es(i){tt=i}const Ss=/[&<>"']/,Ya=new RegExp(Ss.source,"g"),Cs=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Xa=new RegExp(Cs.source,"g"),eo={"&":"&","<":"<",">":">",'"':""","'":"'"},As=i=>eo[i];function ae(i,e){if(e){if(Ss.test(i))return i.replace(Ya,As)}else if(Cs.test(i))return i.replace(Xa,As);return i}const to=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function no(i){return i.replace(to,(e,t)=>(t=t.toLowerCase(),t==="colon"?":":t.charAt(0)==="#"?t.charAt(1)==="x"?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""))}const io=/(^|[^\[])\^/g;function D(i,e){let t=typeof i=="string"?i:i.source;e=e||"";const n={replace:(s,r)=>{let a=typeof r=="string"?r:r.source;return a=a.replace(io,"$1"),t=t.replace(s,a),n},getRegex:()=>new RegExp(t,e)};return n}function Is(i){try{i=encodeURI(i).replace(/%25/g,"%")}catch{return null}return i}const Vt={exec:()=>null};function Os(i,e){const t=i.replace(/\|/g,(r,a,o)=>{let l=!1,d=a;for(;--d>=0&&o[d]==="\\";)l=!l;return l?"|":" |"}),n=t.split(/ \|/);let s=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),e)if(n.length>e)n.splice(e);else for(;n.length<e;)n.push("");for(;s<n.length;s++)n[s]=n[s].trim().replace(/\\\|/g,"|");return n}function _n(i,e,t){const n=i.length;if(n===0)return"";let s=0;for(;s<n;){const r=i.charAt(n-s-1);if(r===e&&!t)s++;else if(r!==e&&t)s++;else break}return i.slice(0,n-s)}function so(i,e){if(i.indexOf(e[1])===-1)return-1;let t=0;for(let n=0;n<i.length;n++)if(i[n]==="\\")n++;else if(i[n]===e[0])t++;else if(i[n]===e[1]&&(t--,t<0))return n;return-1}function Ms(i,e,t,n){const s=e.href,r=e.title?ae(e.title):null,a=i[1].replace(/\\([\[\]])/g,"$1");if(i[0].charAt(0)!=="!"){n.state.inLink=!0;const o={type:"link",raw:t,href:s,title:r,text:a,tokens:n.inlineTokens(a)};return n.state.inLink=!1,o}return{type:"image",raw:t,href:s,title:r,text:ae(a)}}function ro(i,e){const t=i.match(/^(\s+)(?:```)/);if(t===null)return e;const n=t[1];return e.split(`
|
|
293
|
+
`).map(s=>{const r=s.match(/^\s+/);if(r===null)return s;const[a]=r;return a.length>=n.length?s.slice(n.length):s}).join(`
|
|
294
|
+
`)}class $n{constructor(e){W(this,"options"),W(this,"rules"),W(this,"lexer"),this.options=e||tt}space(e){const t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){const t=this.rules.block.code.exec(e);if(t){const n=t[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:_n(n,`
|
|
295
|
+
`)}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const n=t[0],s=ro(n,t[3]||"");return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:s}}}heading(e){const t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(/#$/.test(n)){const s=_n(n,"#");(this.options.pedantic||!s||/ $/.test(s))&&(n=s.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){const t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:t[0]}}blockquote(e){const t=this.rules.block.blockquote.exec(e);if(t){let n=t[0].replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,`
|
|
296
|
+
$1`);n=_n(n.replace(/^ *>[ \t]?/gm,""),`
|
|
297
|
+
`);const s=this.lexer.state.top;this.lexer.state.top=!0;const r=this.lexer.blockTokens(n);return this.lexer.state.top=s,{type:"blockquote",raw:t[0],tokens:r,text:n}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim();const s=n.length>1,r={type:"list",raw:"",ordered:s,start:s?+n.slice(0,-1):"",loose:!1,items:[]};n=s?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=s?n:"[*+-]");const a=new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`);let o="",l="",d=!1;for(;e;){let h=!1;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;o=t[0],e=e.substring(o.length);let p=t[2].split(`
|
|
298
|
+
`,1)[0].replace(/^\t+/,Ze=>" ".repeat(3*Ze.length)),c=e.split(`
|
|
299
|
+
`,1)[0],f=0;this.options.pedantic?(f=2,l=p.trimStart()):(f=t[2].search(/[^ ]/),f=f>4?1:f,l=p.slice(f),f+=t[1].length);let O=!1;if(!p&&/^ *$/.test(c)&&(o+=c+`
|
|
300
|
+
`,e=e.substring(c.length+1),h=!0),!h){const Ze=new RegExp(`^ {0,${Math.min(3,f-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),jn=new RegExp(`^ {0,${Math.min(3,f-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),zn=new RegExp(`^ {0,${Math.min(3,f-1)}}(?:\`\`\`|~~~)`),Zn=new RegExp(`^ {0,${Math.min(3,f-1)}}#`);for(;e;){const wt=e.split(`
|
|
301
|
+
`,1)[0];if(c=wt,this.options.pedantic&&(c=c.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),zn.test(c)||Zn.test(c)||Ze.test(c)||jn.test(e))break;if(c.search(/[^ ]/)>=f||!c.trim())l+=`
|
|
302
|
+
`+c.slice(f);else{if(O||p.search(/[^ ]/)>=4||zn.test(p)||Zn.test(p)||jn.test(p))break;l+=`
|
|
303
|
+
`+c}!O&&!c.trim()&&(O=!0),o+=wt+`
|
|
304
|
+
`,e=e.substring(wt.length+1),p=c.slice(f)}}r.loose||(d?r.loose=!0:/\n *\n *$/.test(o)&&(d=!0));let H=null,Q;this.options.gfm&&(H=/^\[[ xX]\] /.exec(l),H&&(Q=H[0]!=="[ ] ",l=l.replace(/^\[[ xX]\] +/,""))),r.items.push({type:"list_item",raw:o,task:!!H,checked:Q,loose:!1,text:l,tokens:[]}),r.raw+=o}r.items[r.items.length-1].raw=o.trimEnd(),r.items[r.items.length-1].text=l.trimEnd(),r.raw=r.raw.trimEnd();for(let h=0;h<r.items.length;h++)if(this.lexer.state.top=!1,r.items[h].tokens=this.lexer.blockTokens(r.items[h].text,[]),!r.loose){const p=r.items[h].tokens.filter(f=>f.type==="space"),c=p.length>0&&p.some(f=>/\n.*\n/.test(f.raw));r.loose=c}if(r.loose)for(let h=0;h<r.items.length;h++)r.items[h].loose=!0;return r}}html(e){const t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){const t=this.rules.block.def.exec(e);if(t){const n=t[1].toLowerCase().replace(/\s+/g," "),s=t[2]?t[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:s,title:r}}}table(e){const t=this.rules.block.table.exec(e);if(!t||!/[:|]/.test(t[2]))return;const n=Os(t[1]),s=t[2].replace(/^\||\| *$/g,"").split("|"),r=t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,"").split(`
|
|
305
|
+
`):[],a={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===s.length){for(const o of s)/^ *-+: *$/.test(o)?a.align.push("right"):/^ *:-+: *$/.test(o)?a.align.push("center"):/^ *:-+ *$/.test(o)?a.align.push("left"):a.align.push(null);for(const o of n)a.header.push({text:o,tokens:this.lexer.inline(o)});for(const o of r)a.rows.push(Os(o,a.header.length).map(l=>({text:l,tokens:this.lexer.inline(l)})));return a}}lheading(e){const t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){const t=this.rules.block.paragraph.exec(e);if(t){const n=t[1].charAt(t[1].length-1)===`
|
|
306
|
+
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){const t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){const t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:ae(t[1])}}tag(e){const t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&/^<a /i.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){const t=this.rules.inline.link.exec(e);if(t){const n=t[2].trim();if(!this.options.pedantic&&/^</.test(n)){if(!/>$/.test(n))return;const a=_n(n.slice(0,-1),"\\");if((n.length-a.length)%2===0)return}else{const a=so(t[2],"()");if(a>-1){const o=(t[0].indexOf("!")===0?5:4)+t[1].length+a;t[2]=t[2].substring(0,a),t[0]=t[0].substring(0,o).trim(),t[3]=""}}let s=t[2],r="";if(this.options.pedantic){const a=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(s);a&&(s=a[1],r=a[3])}else r=t[3]?t[3].slice(1,-1):"";return s=s.trim(),/^</.test(s)&&(this.options.pedantic&&!/>$/.test(n)?s=s.slice(1):s=s.slice(1,-1)),Ms(t,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){const s=(n[2]||n[1]).replace(/\s+/g," "),r=t[s.toLowerCase()];if(!r){const a=n[0].charAt(0);return{type:"text",raw:a,text:a}}return Ms(n,r,n[0],this.lexer)}}emStrong(e,t,n=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!(!s||s[3]&&n.match(/[\p{L}\p{N}]/u))&&(!(s[1]||s[2])||!n||this.rules.inline.punctuation.exec(n))){const r=[...s[0]].length-1;let a,o,l=r,d=0;const h=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,t=t.slice(-1*e.length+r);(s=h.exec(t))!=null;){if(a=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!a)continue;if(o=[...a].length,s[3]||s[4]){l+=o;continue}else if((s[5]||s[6])&&r%3&&!((r+o)%3)){d+=o;continue}if(l-=o,l>0)continue;o=Math.min(o,o+l+d);const p=[...s[0]][0].length,c=e.slice(0,r+s.index+p+o);if(Math.min(r,o)%2){const O=c.slice(1,-1);return{type:"em",raw:c,text:O,tokens:this.lexer.inlineTokens(O)}}const f=c.slice(2,-2);return{type:"strong",raw:c,text:f,tokens:this.lexer.inlineTokens(f)}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(/\n/g," ");const s=/[^ ]/.test(n),r=/^ /.test(n)&&/ $/.test(n);return s&&r&&(n=n.substring(1,n.length-1)),n=ae(n,!0),{type:"codespan",raw:t[0],text:n}}}br(e){const t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){const t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){const t=this.rules.inline.autolink.exec(e);if(t){let n,s;return t[2]==="@"?(n=ae(t[1]),s="mailto:"+n):(n=ae(t[1]),s=n),{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var t;let n;if(n=this.rules.inline.url.exec(e)){let s,r;if(n[2]==="@")s=ae(n[0]),r="mailto:"+s;else{let a;do a=n[0],n[0]=((t=this.rules.inline._backpedal.exec(n[0]))==null?void 0:t[0])??"";while(a!==n[0]);s=ae(n[0]),n[1]==="www."?r="http://"+n[0]:r=n[0]}return{type:"link",raw:n[0],text:s,href:r,tokens:[{type:"text",raw:s,text:s}]}}}inlineText(e){const t=this.rules.inline.text.exec(e);if(t){let n;return this.lexer.state.inRawBlock?n=t[0]:n=ae(t[0]),{type:"text",raw:t[0],text:n}}}}const ao=/^(?: *(?:\n|$))+/,oo=/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,lo=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,qt=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,co=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Rs=/(?:[*+-]|\d{1,9}[.)])/,Ps=D(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,Rs).replace(/blockCode/g,/ {4}/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).getRegex(),ri=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,ho=/^[^\n]+/,ai=/(?!\s*\])(?:\\.|[^\[\]\\])+/,uo=D(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label",ai).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),po=D(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Rs).getRegex(),Tn="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",oi=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,mo=D("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))","i").replace("comment",oi).replace("tag",Tn).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ns=D(ri).replace("hr",qt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Tn).getRegex(),fo=D(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Ns).getRegex(),li={blockquote:fo,code:oo,def:uo,fences:lo,heading:co,hr:qt,html:mo,lheading:Ps,list:po,newline:ao,paragraph:Ns,table:Vt,text:ho},js=D("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",qt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Tn).getRegex(),go={...li,table:js,paragraph:D(ri).replace("hr",qt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",js).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Tn).getRegex()},yo={...li,html:D(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",oi).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Vt,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:D(ri).replace("hr",qt).replace("heading",` *#{1,6} *[^
|
|
307
|
+
]`).replace("lheading",Ps).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},zs=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,vo=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Zs=/^( {2,}|\\)\n(?!\s*$)/,bo=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Kt="\\p{P}\\p{S}",wo=D(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,Kt).getRegex(),xo=/\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g,ko=D(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,Kt).getRegex(),_o=D("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,Kt).getRegex(),$o=D("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,Kt).getRegex(),To=D(/\\([punct])/,"gu").replace(/punct/g,Kt).getRegex(),Eo=D(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),So=D(oi).replace("(?:-->|$)","-->").getRegex(),Co=D("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",So).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),En=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Ao=D(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",En).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ls=D(/^!?\[(label)\]\[(ref)\]/).replace("label",En).replace("ref",ai).getRegex(),Ds=D(/^!?\[(ref)\](?:\[\])?/).replace("ref",ai).getRegex(),Io=D("reflink|nolink(?!\\()","g").replace("reflink",Ls).replace("nolink",Ds).getRegex(),ci={_backpedal:Vt,anyPunctuation:To,autolink:Eo,blockSkip:xo,br:Zs,code:vo,del:Vt,emStrongLDelim:ko,emStrongRDelimAst:_o,emStrongRDelimUnd:$o,escape:zs,link:Ao,nolink:Ds,punctuation:wo,reflink:Ls,reflinkSearch:Io,tag:Co,text:bo,url:Vt},Oo={...ci,link:D(/^!?\[(label)\]\((.*?)\)/).replace("label",En).getRegex(),reflink:D(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",En).getRegex()},di={...ci,escape:D(zs).replace("])","~|])").getRegex(),url:D(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},Mo={...di,br:D(Zs).replace("{2,}","*").getRegex(),text:D(di.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Sn={normal:li,gfm:go,pedantic:yo},Jt={normal:ci,gfm:di,breaks:Mo,pedantic:Oo};class ve{constructor(e){W(this,"tokens"),W(this,"options"),W(this,"state"),W(this,"tokenizer"),W(this,"inlineQueue"),this.tokens=[],this.tokens.links=Object.create(null),this.options=e||tt,this.options.tokenizer=this.options.tokenizer||new $n,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const t={block:Sn.normal,inline:Jt.normal};this.options.pedantic?(t.block=Sn.pedantic,t.inline=Jt.pedantic):this.options.gfm&&(t.block=Sn.gfm,this.options.breaks?t.inline=Jt.breaks:t.inline=Jt.gfm),this.tokenizer.rules=t}static get rules(){return{block:Sn,inline:Jt}}static lex(e,t){return new ve(t).lex(e)}static lexInline(e,t){return new ve(t).inlineTokens(e)}lex(e){e=e.replace(/\r\n|\r/g,`
|
|
308
|
+
`),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){const n=this.inlineQueue[t];this.inlineTokens(n.src,n.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[]){this.options.pedantic?e=e.replace(/\t/g," ").replace(/^ +$/gm,""):e=e.replace(/^( *)(\t+)/gm,(o,l,d)=>l+" ".repeat(d.length));let n,s,r,a;for(;e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(o=>(n=o.call({lexer:this},e,t))?(e=e.substring(n.raw.length),t.push(n),!0):!1))){if(n=this.tokenizer.space(e)){e=e.substring(n.raw.length),n.raw.length===1&&t.length>0?t[t.length-1].raw+=`
|
|
309
|
+
`:t.push(n);continue}if(n=this.tokenizer.code(e)){e=e.substring(n.raw.length),s=t[t.length-1],s&&(s.type==="paragraph"||s.type==="text")?(s.raw+=`
|
|
310
|
+
`+n.raw,s.text+=`
|
|
311
|
+
`+n.text,this.inlineQueue[this.inlineQueue.length-1].src=s.text):t.push(n);continue}if(n=this.tokenizer.fences(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.heading(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.hr(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.blockquote(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.list(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.html(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.def(e)){e=e.substring(n.raw.length),s=t[t.length-1],s&&(s.type==="paragraph"||s.type==="text")?(s.raw+=`
|
|
312
|
+
`+n.raw,s.text+=`
|
|
313
|
+
`+n.raw,this.inlineQueue[this.inlineQueue.length-1].src=s.text):this.tokens.links[n.tag]||(this.tokens.links[n.tag]={href:n.href,title:n.title});continue}if(n=this.tokenizer.table(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.lheading(e)){e=e.substring(n.raw.length),t.push(n);continue}if(r=e,this.options.extensions&&this.options.extensions.startBlock){let o=1/0;const l=e.slice(1);let d;this.options.extensions.startBlock.forEach(h=>{d=h.call({lexer:this},l),typeof d=="number"&&d>=0&&(o=Math.min(o,d))}),o<1/0&&o>=0&&(r=e.substring(0,o+1))}if(this.state.top&&(n=this.tokenizer.paragraph(r))){s=t[t.length-1],a&&s.type==="paragraph"?(s.raw+=`
|
|
314
|
+
`+n.raw,s.text+=`
|
|
315
|
+
`+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=s.text):t.push(n),a=r.length!==e.length,e=e.substring(n.raw.length);continue}if(n=this.tokenizer.text(e)){e=e.substring(n.raw.length),s=t[t.length-1],s&&s.type==="text"?(s.raw+=`
|
|
316
|
+
`+n.raw,s.text+=`
|
|
317
|
+
`+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=s.text):t.push(n);continue}if(e){const o="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(o);break}else throw new Error(o)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n,s,r,a=e,o,l,d;if(this.tokens.links){const h=Object.keys(this.tokens.links);if(h.length>0)for(;(o=this.tokenizer.rules.inline.reflinkSearch.exec(a))!=null;)h.includes(o[0].slice(o[0].lastIndexOf("[")+1,-1))&&(a=a.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(o=this.tokenizer.rules.inline.blockSkip.exec(a))!=null;)a=a.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(o=this.tokenizer.rules.inline.anyPunctuation.exec(a))!=null;)a=a.slice(0,o.index)+"++"+a.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;e;)if(l||(d=""),l=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(h=>(n=h.call({lexer:this},e,t))?(e=e.substring(n.raw.length),t.push(n),!0):!1))){if(n=this.tokenizer.escape(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.tag(e)){e=e.substring(n.raw.length),s=t[t.length-1],s&&n.type==="text"&&s.type==="text"?(s.raw+=n.raw,s.text+=n.text):t.push(n);continue}if(n=this.tokenizer.link(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(n.raw.length),s=t[t.length-1],s&&n.type==="text"&&s.type==="text"?(s.raw+=n.raw,s.text+=n.text):t.push(n);continue}if(n=this.tokenizer.emStrong(e,a,d)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.codespan(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.br(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.del(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.autolink(e)){e=e.substring(n.raw.length),t.push(n);continue}if(!this.state.inLink&&(n=this.tokenizer.url(e))){e=e.substring(n.raw.length),t.push(n);continue}if(r=e,this.options.extensions&&this.options.extensions.startInline){let h=1/0;const p=e.slice(1);let c;this.options.extensions.startInline.forEach(f=>{c=f.call({lexer:this},p),typeof c=="number"&&c>=0&&(h=Math.min(h,c))}),h<1/0&&h>=0&&(r=e.substring(0,h+1))}if(n=this.tokenizer.inlineText(r)){e=e.substring(n.raw.length),n.raw.slice(-1)!=="_"&&(d=n.raw.slice(-1)),l=!0,s=t[t.length-1],s&&s.type==="text"?(s.raw+=n.raw,s.text+=n.text):t.push(n);continue}if(e){const h="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(h);break}else throw new Error(h)}}return t}}class Cn{constructor(e){W(this,"options"),this.options=e||tt}code(e,t,n){var s;const r=(s=(t||"").match(/^\S*/))==null?void 0:s[0];return e=e.replace(/\n$/,"")+`
|
|
318
|
+
`,r?'<pre><code class="language-'+ae(r)+'">'+(n?e:ae(e,!0))+`</code></pre>
|
|
319
|
+
`:"<pre><code>"+(n?e:ae(e,!0))+`</code></pre>
|
|
320
|
+
`}blockquote(e){return`<blockquote>
|
|
321
|
+
${e}</blockquote>
|
|
322
|
+
`}html(e,t){return e}heading(e,t,n){return`<h${t}>${e}</h${t}>
|
|
323
|
+
`}hr(){return`<hr>
|
|
324
|
+
`}list(e,t,n){const s=t?"ol":"ul",r=t&&n!==1?' start="'+n+'"':"";return"<"+s+r+`>
|
|
325
|
+
`+e+"</"+s+`>
|
|
326
|
+
`}listitem(e,t,n){return`<li>${e}</li>
|
|
327
|
+
`}checkbox(e){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph(e){return`<p>${e}</p>
|
|
328
|
+
`}table(e,t){return t&&(t=`<tbody>${t}</tbody>`),`<table>
|
|
329
|
+
<thead>
|
|
330
|
+
`+e+`</thead>
|
|
331
|
+
`+t+`</table>
|
|
332
|
+
`}tablerow(e){return`<tr>
|
|
333
|
+
${e}</tr>
|
|
334
|
+
`}tablecell(e,t){const n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
|
|
335
|
+
`}strong(e){return`<strong>${e}</strong>`}em(e){return`<em>${e}</em>`}codespan(e){return`<code>${e}</code>`}br(){return"<br>"}del(e){return`<del>${e}</del>`}link(e,t,n){const s=Is(e);if(s===null)return n;e=s;let r='<a href="'+e+'"';return t&&(r+=' title="'+t+'"'),r+=">"+n+"</a>",r}image(e,t,n){const s=Is(e);if(s===null)return n;e=s;let r=`<img src="${e}" alt="${n}"`;return t&&(r+=` title="${t}"`),r+=">",r}text(e){return e}}class hi{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,t,n){return""+n}image(e,t,n){return""+n}br(){return""}}class be{constructor(e){W(this,"options"),W(this,"renderer"),W(this,"textRenderer"),this.options=e||tt,this.options.renderer=this.options.renderer||new Cn,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new hi}static parse(e,t){return new be(t).parse(e)}static parseInline(e,t){return new be(t).parseInline(e)}parse(e,t=!0){let n="";for(let s=0;s<e.length;s++){const r=e[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[r.type]){const a=r,o=this.options.extensions.renderers[a.type].call({parser:this},a);if(o!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(a.type)){n+=o||"";continue}}switch(r.type){case"space":continue;case"hr":{n+=this.renderer.hr();continue}case"heading":{const a=r;n+=this.renderer.heading(this.parseInline(a.tokens),a.depth,no(this.parseInline(a.tokens,this.textRenderer)));continue}case"code":{const a=r;n+=this.renderer.code(a.text,a.lang,!!a.escaped);continue}case"table":{const a=r;let o="",l="";for(let h=0;h<a.header.length;h++)l+=this.renderer.tablecell(this.parseInline(a.header[h].tokens),{header:!0,align:a.align[h]});o+=this.renderer.tablerow(l);let d="";for(let h=0;h<a.rows.length;h++){const p=a.rows[h];l="";for(let c=0;c<p.length;c++)l+=this.renderer.tablecell(this.parseInline(p[c].tokens),{header:!1,align:a.align[c]});d+=this.renderer.tablerow(l)}n+=this.renderer.table(o,d);continue}case"blockquote":{const a=r,o=this.parse(a.tokens);n+=this.renderer.blockquote(o);continue}case"list":{const a=r,o=a.ordered,l=a.start,d=a.loose;let h="";for(let p=0;p<a.items.length;p++){const c=a.items[p],f=c.checked,O=c.task;let H="";if(c.task){const Q=this.renderer.checkbox(!!f);d?c.tokens.length>0&&c.tokens[0].type==="paragraph"?(c.tokens[0].text=Q+" "+c.tokens[0].text,c.tokens[0].tokens&&c.tokens[0].tokens.length>0&&c.tokens[0].tokens[0].type==="text"&&(c.tokens[0].tokens[0].text=Q+" "+c.tokens[0].tokens[0].text)):c.tokens.unshift({type:"text",text:Q+" "}):H+=Q+" "}H+=this.parse(c.tokens,d),h+=this.renderer.listitem(H,O,!!f)}n+=this.renderer.list(h,o,l);continue}case"html":{const a=r;n+=this.renderer.html(a.text,a.block);continue}case"paragraph":{const a=r;n+=this.renderer.paragraph(this.parseInline(a.tokens));continue}case"text":{let a=r,o=a.tokens?this.parseInline(a.tokens):a.text;for(;s+1<e.length&&e[s+1].type==="text";)a=e[++s],o+=`
|
|
336
|
+
`+(a.tokens?this.parseInline(a.tokens):a.text);n+=t?this.renderer.paragraph(o):o;continue}default:{const a='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return n}parseInline(e,t){t=t||this.renderer;let n="";for(let s=0;s<e.length;s++){const r=e[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[r.type]){const a=this.options.extensions.renderers[r.type].call({parser:this},r);if(a!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type)){n+=a||"";continue}}switch(r.type){case"escape":{const a=r;n+=t.text(a.text);break}case"html":{const a=r;n+=t.html(a.text);break}case"link":{const a=r;n+=t.link(a.href,a.title,this.parseInline(a.tokens,t));break}case"image":{const a=r;n+=t.image(a.href,a.title,a.text);break}case"strong":{const a=r;n+=t.strong(this.parseInline(a.tokens,t));break}case"em":{const a=r;n+=t.em(this.parseInline(a.tokens,t));break}case"codespan":{const a=r;n+=t.codespan(a.text);break}case"br":{n+=t.br();break}case"del":{const a=r;n+=t.del(this.parseInline(a.tokens,t));break}case"text":{const a=r;n+=t.text(a.text);break}default:{const a='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return n}}class Gt{constructor(e){W(this,"options"),this.options=e||tt}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}}W(Gt,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));var An,ui,pi,Us;class Ro{constructor(...e){ss(this,An),ss(this,pi),W(this,"defaults",si()),W(this,"options",this.setOptions),W(this,"parse",Vn(this,An,ui).call(this,ve.lex,be.parse)),W(this,"parseInline",Vn(this,An,ui).call(this,ve.lexInline,be.parseInline)),W(this,"Parser",be),W(this,"Renderer",Cn),W(this,"TextRenderer",hi),W(this,"Lexer",ve),W(this,"Tokenizer",$n),W(this,"Hooks",Gt),this.use(...e)}walkTokens(e,t){var n,s;let r=[];for(const a of e)switch(r=r.concat(t.call(this,a)),a.type){case"table":{const o=a;for(const l of o.header)r=r.concat(this.walkTokens(l.tokens,t));for(const l of o.rows)for(const d of l)r=r.concat(this.walkTokens(d.tokens,t));break}case"list":{const o=a;r=r.concat(this.walkTokens(o.items,t));break}default:{const o=a;(s=(n=this.defaults.extensions)==null?void 0:n.childTokens)!=null&&s[o.type]?this.defaults.extensions.childTokens[o.type].forEach(l=>{const d=o[l].flat(1/0);r=r.concat(this.walkTokens(d,t))}):o.tokens&&(r=r.concat(this.walkTokens(o.tokens,t)))}}return r}use(...e){const t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{const s={...n};if(s.async=this.defaults.async||s.async||!1,n.extensions&&(n.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){const a=t.renderers[r.name];a?t.renderers[r.name]=function(...o){let l=r.renderer.apply(this,o);return l===!1&&(l=a.apply(this,o)),l}:t.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const a=t[r.level];a?a.unshift(r.tokenizer):t[r.level]=[r.tokenizer],r.start&&(r.level==="block"?t.startBlock?t.startBlock.push(r.start):t.startBlock=[r.start]:r.level==="inline"&&(t.startInline?t.startInline.push(r.start):t.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(t.childTokens[r.name]=r.childTokens)}),s.extensions=t),n.renderer){const r=this.defaults.renderer||new Cn(this.defaults);for(const a in n.renderer){if(!(a in r))throw new Error(`renderer '${a}' does not exist`);if(a==="options")continue;const o=a,l=n.renderer[o],d=r[o];r[o]=(...h)=>{let p=l.apply(r,h);return p===!1&&(p=d.apply(r,h)),p||""}}s.renderer=r}if(n.tokenizer){const r=this.defaults.tokenizer||new $n(this.defaults);for(const a in n.tokenizer){if(!(a in r))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;const o=a,l=n.tokenizer[o],d=r[o];r[o]=(...h)=>{let p=l.apply(r,h);return p===!1&&(p=d.apply(r,h)),p}}s.tokenizer=r}if(n.hooks){const r=this.defaults.hooks||new Gt;for(const a in n.hooks){if(!(a in r))throw new Error(`hook '${a}' does not exist`);if(a==="options")continue;const o=a,l=n.hooks[o],d=r[o];Gt.passThroughHooks.has(a)?r[o]=h=>{if(this.defaults.async)return Promise.resolve(l.call(r,h)).then(c=>d.call(r,c));const p=l.call(r,h);return d.call(r,p)}:r[o]=(...h)=>{let p=l.apply(r,h);return p===!1&&(p=d.apply(r,h)),p}}s.hooks=r}if(n.walkTokens){const r=this.defaults.walkTokens,a=n.walkTokens;s.walkTokens=function(o){let l=[];return l.push(a.call(this,o)),r&&(l=l.concat(r.call(this,o))),l}}this.defaults={...this.defaults,...s}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return ve.lex(e,t??this.defaults)}parser(e,t){return be.parse(e,t??this.defaults)}}An=new WeakSet,ui=function(i,e){return(t,n)=>{const s={...n},r={...this.defaults,...s};this.defaults.async===!0&&s.async===!1&&(r.silent||console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."),r.async=!0);const a=Vn(this,pi,Us).call(this,!!r.silent,!!r.async);if(typeof t>"u"||t===null)return a(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(r.hooks&&(r.hooks.options=r),r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(t):t).then(o=>i(o,r)).then(o=>r.hooks?r.hooks.processAllTokens(o):o).then(o=>r.walkTokens?Promise.all(this.walkTokens(o,r.walkTokens)).then(()=>o):o).then(o=>e(o,r)).then(o=>r.hooks?r.hooks.postprocess(o):o).catch(a);try{r.hooks&&(t=r.hooks.preprocess(t));let o=i(t,r);r.hooks&&(o=r.hooks.processAllTokens(o)),r.walkTokens&&this.walkTokens(o,r.walkTokens);let l=e(o,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(o){return a(o)}}},pi=new WeakSet,Us=function(i,e){return t=>{if(t.message+=`
|
|
337
|
+
Please report this to https://github.com/markedjs/marked.`,i){const n="<p>An error occurred:</p><pre>"+ae(t.message+"",!0)+"</pre>";return e?Promise.resolve(n):n}if(e)return Promise.reject(t);throw t}};const nt=new Ro;function Z(i,e){return nt.parse(i,e)}Z.options=Z.setOptions=function(i){return nt.setOptions(i),Z.defaults=nt.defaults,Es(Z.defaults),Z},Z.getDefaults=si,Z.defaults=tt,Z.use=function(...i){return nt.use(...i),Z.defaults=nt.defaults,Es(Z.defaults),Z},Z.walkTokens=function(i,e){return nt.walkTokens(i,e)},Z.parseInline=nt.parseInline,Z.Parser=be,Z.parser=be.parse,Z.Renderer=Cn,Z.TextRenderer=hi,Z.Lexer=ve,Z.lexer=ve.lex,Z.Tokenizer=$n,Z.Hooks=Gt,Z.parse=Z,Z.options,Z.setOptions,Z.use,Z.walkTokens,Z.parseInline,be.parse,ve.lex;function Po(i){return i.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function Hs(i,e=""){return Object.keys(i).reduce((t,n)=>{const s=Po(n),r=e?`${e}-${s}`:s;return typeof i[n]=="object"&&i[n]!==null?Object.assign(t,Hs(i[n],r)):t[r]=i[n],t},{})}function No(i){const e={"&":"&","<":"<",">":">",'"':""","'":"'"};return i.replace(/[&<>"']/g,t=>e[t])}function Bs(i){const e=No(i);return Z.parse(e)}var jo=Object.defineProperty,zo=Object.getOwnPropertyDescriptor,Ws=(i,e,t,n)=>{for(var s=n>1?void 0:n?zo(e,t):e,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=(n?a(e,t,s):a(s))||s);return n&&s&&jo(e,t,s),s};let In=class extends se{constructor(){super(...arguments),this.content=""}get htmlContent(){return Bs(this.content)}render(){return z`
|
|
293
338
|
<div class="flex items-end mr-20">
|
|
294
339
|
<div class="message rounded-lg px-4 py-2 flex flex-col gap-3">
|
|
295
|
-
${
|
|
340
|
+
${Ts(this.htmlContent)}
|
|
296
341
|
</div>
|
|
297
342
|
</div>
|
|
298
|
-
`}};
|
|
343
|
+
`}};In.styles=[$e,Ue`
|
|
299
344
|
.message {
|
|
300
345
|
background-color: var(--iai-chat-i-message-assistant-bg);
|
|
301
346
|
color: var(--iai-chat-i-message-assistant-fg);
|
|
302
347
|
}
|
|
303
|
-
|
|
304
|
-
h1 {
|
|
305
|
-
font-size: 1.5em;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
h2 {
|
|
309
|
-
font-size: 1.17em;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
h3 {
|
|
313
|
-
font-size: 1em;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
ol, ul {
|
|
317
|
-
display: flex;
|
|
318
|
-
flex-direction: column;
|
|
319
|
-
padding: 0;
|
|
320
|
-
margin-left: 20px;
|
|
321
|
-
gap: 8px;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
ol {
|
|
325
|
-
list-style-type: decimal;
|
|
326
|
-
}
|
|
327
|
-
`],Fi([F({type:String})],us.prototype,"content",2),us=Fi([Ce("iai-chat-message-assistant")],us);async function na(s,e){const{type:t,params:i}=s,n=e[t];if(!n)throw new Error(`No handler for enhanced content type ${t}`);return n({params:i,html:D})}var ra=Object.defineProperty,aa=Object.getOwnPropertyDescriptor,zt=(s,e,t,i)=>{for(var n=i>1?void 0:i?aa(e,t):e,r=s.length-1,a;r>=0;r--)(a=s[r])&&(n=(i?a(e,t,n):a(n))||n);return i&&n&&ra(e,t,n),n};let Ge=class extends se{constructor(){super(...arguments),this.content=""}async connectedCallback(){if(super.connectedCallback(),this.enhancedContent)try{this.contentHtmlTemplate=await na(this.enhancedContent,this.options.handlers.enhancedContent)}catch(s){console.warn("Error processing enhanced content",s)}else this.contentHtmlTemplate||(this.contentHtmlTemplate=D`<p class="text-center text-gray-400 text-sm">${this.content}</p>`)}render(){return D`
|
|
348
|
+
`],Ws([V({type:String})],In.prototype,"content",2),In=Ws([_e("iai-chat-message-assistant")],In);async function Zo(i,e){const{type:t,params:n}=i,s=e[t];if(!s)throw new Error(`No handler for enhanced content type ${t}`);return s({params:n,html:z})}var Lo=Object.defineProperty,Do=Object.getOwnPropertyDescriptor,Qt=(i,e,t,n)=>{for(var s=n>1?void 0:n?Do(e,t):e,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=(n?a(e,t,s):a(s))||s);return n&&s&&Lo(e,t,s),s};let it=class extends se{constructor(){super(...arguments),this.content=""}async connectedCallback(){if(super.connectedCallback(),this.enhancedContent)try{this.contentHtmlTemplate=await Zo(this.enhancedContent,this.options.handlers.enhancedContent)}catch(i){console.warn("Error processing enhanced content",i)}this.contentHtmlTemplate||(this.contentHtmlTemplate=z`<p class="text-center text-gray-400 text-sm">${Ts(Bs(this.content))}</p>`)}render(){return z`
|
|
328
349
|
<div>
|
|
329
350
|
${this.contentHtmlTemplate}
|
|
330
351
|
</div>
|
|
331
|
-
`}};
|
|
352
|
+
`}};it.styles=[$e],Qt([V({type:Object})],it.prototype,"options",2),Qt([V({type:String})],it.prototype,"content",2),Qt([V({type:Object})],it.prototype,"enhancedContent",2),Qt([V()],it.prototype,"contentHtmlTemplate",2),it=Qt([_e("iai-chat-message-system")],it);var Uo=Object.defineProperty,Ho=Object.getOwnPropertyDescriptor,Fs=(i,e,t,n)=>{for(var s=n>1?void 0:n?Ho(e,t):e,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=(n?a(e,t,s):a(s))||s);return n&&s&&Uo(e,t,s),s};let On=class extends se{constructor(){super(...arguments),this.content=""}render(){return z`
|
|
332
353
|
<div class="flex items-end justify-end ml-20">
|
|
333
354
|
<div class="message rounded-lg px-4 py-2 flex gap-2">
|
|
334
|
-
<p>${this.content}</p>
|
|
355
|
+
<p class="whitespace-pre-wrap">${this.content}</p>
|
|
335
356
|
</div>
|
|
336
357
|
</div>
|
|
337
|
-
`}};
|
|
358
|
+
`}};On.styles=[$e,Ue`
|
|
338
359
|
.message {
|
|
339
360
|
background-color: var(--iai-chat-i-message-user-bg);
|
|
340
361
|
color: var(--iai-chat-i-message-user-fg);
|
|
341
362
|
}
|
|
342
|
-
`],
|
|
363
|
+
`],Fs([V({type:String})],On.prototype,"content",2),On=Fs([_e("iai-chat-message-user")],On);var Bo=Object.defineProperty,Wo=Object.getOwnPropertyDescriptor,Mn=(i,e,t,n)=>{for(var s=n>1?void 0:n?Wo(e,t):e,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=(n?a(e,t,s):a(s))||s);return n&&s&&Bo(e,t,s),s};let vt=class extends se{constructor(){super(...arguments),this.isChatWindowOpen=!1,this.isCtaOpen=!0}render(){const{openChatButton:{width:i,height:e,imageSrc:t,cta:n},placement:s}=this.options.config,r=Je({alignItems:s!=="left"?"end":"start"}),a=Je({width:i,height:e});return z`
|
|
343
364
|
<div class="flex flex-col gap-4" style=${r}>
|
|
344
|
-
${Ne(
|
|
365
|
+
${Ne(n&&this.isCtaOpen&&!this.isChatWindowOpen,()=>z`
|
|
345
366
|
<div class="relative rounded-lg p-5 shadow-md bg-white" style="max-width: 350px;">
|
|
346
367
|
<button
|
|
347
368
|
class="absolute top-0 right-0 w-5 h-5 m-0.5"
|
|
348
369
|
@click="${()=>this.isCtaOpen=!1}"
|
|
349
|
-
>${
|
|
370
|
+
>${Wt}</button>
|
|
350
371
|
|
|
351
|
-
<span>${
|
|
372
|
+
<span>${n}</span>
|
|
352
373
|
|
|
353
374
|
<div
|
|
354
375
|
class="absolute bottom-0 mx-4 mb-[-8px] w-0 h-0 border-x-8 border-t-8 border-x-transparent border-white"
|
|
355
|
-
style=${
|
|
376
|
+
style=${Je({[s]:0})}
|
|
356
377
|
/>
|
|
357
378
|
</div>
|
|
358
379
|
`)}
|
|
359
380
|
|
|
360
381
|
<button @click="${this.toggleChat}">
|
|
361
|
-
${Ne(t,()=>
|
|
382
|
+
${Ne(t,()=>z`<img src="${t}" alt="Chat Icon" style=${a}/>`,()=>z`
|
|
362
383
|
<div class="button rounded-full flex items-center justify-center" style=${a}>
|
|
363
384
|
<div class="h-3/5 w-3/5">
|
|
364
|
-
${Ne(this.isChatWindowOpen,()=>
|
|
385
|
+
${Ne(this.isChatWindowOpen,()=>Wt,()=>Ua)}
|
|
365
386
|
</div>
|
|
366
387
|
</div>
|
|
367
388
|
`)}
|
|
368
389
|
</button>
|
|
369
390
|
</div>
|
|
370
|
-
`}toggleChat(){this.dispatchEvent(new CustomEvent("toggle-chat"))}};
|
|
391
|
+
`}toggleChat(){this.dispatchEvent(new CustomEvent("toggle-chat"))}};vt.styles=[$e,Ue`
|
|
371
392
|
.button {
|
|
372
393
|
background-color: var(--iai-chat-i-ocb-bg);
|
|
373
394
|
color: var(--iai-chat-i-ocb-fg);
|
|
374
395
|
}
|
|
375
|
-
`],ps([F({type:Object})],ht.prototype,"options",2),ps([F({type:Boolean})],ht.prototype,"isChatWindowOpen",2),ps([nt()],ht.prototype,"isCtaOpen",2),ht=ps([Ce("iai-chat-open-chat-button")],ht);function ua(s){return s.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function Ki(s,e=""){return Object.keys(s).reduce((t,i)=>{const n=ua(i),r=e?`${e}-${n}`:n;return typeof s[i]=="object"&&s[i]!==null?Object.assign(t,Ki(s[i],r)):t[r]=s[i],t},{})}class ha{constructor(e){this.widget=null,this.options=ds.parse(e);const t=document.createElement("iai-chat-popup");t.options=this.options;const i=Ki(this.options.config.styles);Object.entries(i).forEach(([n,r])=>{t.style.setProperty(`--iai-chat-${n}`,r)}),document.body.appendChild(t),this.widget=t}get api(){if(!this.widget)throw new Error("Widget has not been initialized");return this.widget}destroy(){var e;(e=this.widget)==null||e.remove(),this.widget=null}}function pa(s){return async function({id:t,params:i,chatWindow:n}){n.setInputDisabled(!0);const r={...i.guestCardId&&{guestCardId:i.guestCardId},...i.customerFirstName&&{firstName:i.customerFirstName},...i.customerLastName&&{lastName:i.customerLastName},...i.customerEmail&&{email:i.customerEmail},...i.customerPhoneNumber&&{phone:i.customerPhoneNumber},...i.desiredMoveInDate&&{moveInDate:i.desiredMoveInDate}},a=document.createElement("iai-chat-iframe-modal");a.title="Schedule a Tour",a.src=`${s}?${new URLSearchParams(r).toString()}`,a.showHeader=!1;const o=()=>{a.remove(),window.removeEventListener("beforeunload",h),n.setInputDisabled(!1)},c=async({detail:m})=>{if(m.type!=="tourScheduled")return;const{tourType:d,tourDate:w,tourTime:N}=m;o(),n.addMessage({role:"system",content:"Your tour has been scheduled!"}),await n.sendFunctionCallResponse(t,{status:"scheduled",tourType:d,tourDate:w,tourTime:N},!0)},l=async()=>{o(),n.addMessage({role:"system",content:"Tour Scheduler Closed"}),await n.sendFunctionCallResponse(t,{status:"canceled"},!0)},h=async()=>{o(),n.addMessage({role:"system",content:"Tour Scheduler Closed"})};a.addEventListener("message-received",c),a.addEventListener("close",l),window.addEventListener("beforeunload",h),document.body.appendChild(a),n.addMessage({role:"system",content:"Tour Scheduler Opened"})}}function Ji(s){return{all:s=s||new Map,on:function(e,t){var i=s.get(e);i?i.push(t):s.set(e,[t])},off:function(e,t){var i=s.get(e);i&&(t?i.splice(i.indexOf(t)>>>0,1):s.set(e,[]))},emit:function(e,t){var i=s.get(e);i&&i.slice().map(function(n){n(t)}),(i=s.get("*"))&&i.slice().map(function(n){n(e,t)})}}}class ma{constructor(e){this.chatWsUrl=e,this._emitter=Ji(),this.on=this._emitter.on.bind(this._emitter),this.off=this._emitter.off.bind(this._emitter),this.reconnectCodes=new Set([1006]),this.reconnectAttempts=0,this.maxReconnectAttempts=10}connect(){const e=new WebSocket(this.chatWsUrl);e.onopen=async()=>{this.reconnectAttempts=0,e.send(JSON.stringify({type:"ready"}))},e.onmessage=t=>{const i=JSON.parse(t.data);this._emitter.emit(i.type,i.data)},e.onclose=t=>{console.log("Disconnected: ",t.code,t.reason||"No reason provided"),this._emitter.emit("disconnected",t),this.reconnectCodes.has(t.code)&&this.reconnectAttempts<this.maxReconnectAttempts&&(console.log("Reconnecting..."),this._emitter.emit("reconnecting"),this.reconnectAttempts++,setTimeout(()=>this.connect(),this.reconnectAttempts*1e3))},e.onerror=t=>{console.log("Error:",t),this._emitter.emit("error",t)},this.ws=e}reconnect(){this.reconnectAttempts=0,this.connect()}disconnect(){var e;(e=this.ws)==null||e.close()}destroy(){this.disconnect(),this._emitter.all.clear()}}var ms;(s=>{(e=>{e.TEXT="TEXT"})(s.MessageType||(s.MessageType={})),(e=>{e.DELIVERED="DELIVERED",e.READ="READ",e.FAILED="FAILED"})(s.AcknowledgeType||(s.AcknowledgeType={})),(e=>{e.GENERIC="GENERIC",e.SMS="SMS",e.RCS="RCS",e.FACEBOOK="FACEBOOK",e.TWITTER="TWITTER",e.WHATSAPP="WHATSAPP",e.WECHAT="WECHAT",e.QQMOBILE="QQMOBILE",e.APPLE_BUSINESS_CHAT="APPLE_BUSINESS_CHAT",e.SKYPE="SKYPE",e.SNAPCHAT="SNAPCHAT",e.VIBER="VIBER",e.LINE="LINE",e.TELEGRAM="TELEGRAM",e.KAKAO="KAKAO"})(s.ContentType||(s.ContentType={})),(e=>{e.SYSTEM="SYSTEM",e.USER="USER"})(s.ConversationEventOrigin||(s.ConversationEventOrigin={})),(e=>{e.PENDING="PENDING",e.ACTIVE="ACTIVE",e.TERMINATED="TERMINATED"})(s.ConversationStatus||(s.ConversationStatus={}))})(ms||(ms={}));const fa=ms.AcknowledgeType,ga="Anyone Home",ya="IB Chat Leasing - Development";let va="https://five9.ah.inhabit.work";const ba="https://five9.ah.inhabit.work".replace("http","ws").replace(/\/$/,""),Ht=class Ht{constructor(){qs(this,we,void 0);qs(this,Ye,void 0);this._emitter=Ji(),this.on=this._emitter.on.bind(this._emitter),this.off=this._emitter.off.bind(this._emitter),Ze(this,we,null),Ze(this,Ye,null),this.conversationStarted=!1}serialize(){return JSON.stringify({sessionToken:this.sessionToken,conversationId:this.conversationId,conversationStarted:this.conversationStarted})}static deserialize(e){const t=JSON.parse(e),i=new Ht;return t.sessionToken&&i.setSession(t.sessionToken),t.conversationId&&i.setConversationId(t.conversationId),i.conversationStarted=t.conversationStarted||!1,i}static generateBaseUrl(e){return`https://${e}/appsvcs/rs/svc`}async createSession(){const e=await fetch(`${Ht.generateBaseUrl("app-scl.five9.com")}/auth/anon?cookieless=true`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({tenantName:ga})});return Ze(this,we,await e.json()),ys(this,we)}setSession(e){Ze(this,we,e)}setConversationId(e){Ze(this,Ye,e),this.five9WebSocket&&(this.five9WebSocket.destroy(),this.five9WebSocket=void 0,e&&this.connectToWebSocket())}connect(){if(!this.sessionToken)throw new Error("Session not created");if(!this.conversationId)throw new Error("Conversation not started");this.connectToWebSocket()}connectToWebSocket(){if(!this.conversationId)throw new Error("Conversation not started");this.five9WebSocket&&this.five9WebSocket.destroy();const e=new ma(`${ba}/conversations/${this.conversationId}/ws`);e.on("*",(t,i)=>{this._emitter.emit(t,i)}),e.on("conversationCreated",t=>{this.conversationStarted=!0,console.log("Conversation Created:",t)}),e.on("conversationAccepted",t=>{console.log("Conversation Accepted:",t)}),e.on("agentJoined",t=>{console.log("Agent Joined:",t)}),e.on("agentTransferredConversation",t=>{console.log("Agent Transferred Conversation:",t)}),e.on("conversationTransferredToGroup",t=>{console.log("Conversation Transferred To Group:",t)}),e.on("agentLeftConversation",t=>{console.log("Agent Left Conversation:",t)}),e.on("agentTyping",t=>{console.log("Agent Typing:",t)}),e.on("message",async t=>{console.log("Message:",t),await this.acknowledgeMessage({messages:[{messageId:t.messageId,type:fa.READ}]})}),e.on("conversationTerminated",t=>{console.log("Conversation Terminated:",t)}),e.on("error",t=>{console.log("Error:",t)}),this.five9WebSocket=e,e.connect()}async authenticatedFetch(e,t={}){const{sessionToken:i}=this;if(!i)throw new Error("Session not found");e=e.startsWith("/")?e:`/${e}`;const n=i.metadata.dataCenters[0].apiUrls[0].host,r=await fetch(`${Ht.generateBaseUrl(n)}${e}`,{...t,headers:{...t.headers,"Content-Type":"application/json",Accept:"application/json",Authorization:i.tokenId,farmId:i.context.farmId}});return r.status===204?null:r.json()}async getMetadata(){if(!this.sessionToken)throw new Error("Session not created");return this.authenticatedFetch("/auth/metadata",{method:"GET"})}async createConversation(e){if(!this.sessionToken)throw new Error("Session not created");const t=e.contact||{};Object.keys(t).forEach(r=>{const a=r;t[a]||delete t[a]});const i={...e,campaignName:ya,tenantId:this.tenantId,callbackUrl:va};console.log("body",i);const n=await this.authenticatedFetch("/conversations",{method:"POST",body:JSON.stringify(i)});return this.setConversationId(n.id),n}async sendMessage(e){const{conversationId:t,conversationStarted:i}=this;if(!t||!i)throw new Error("Conversation not started");const n={messageType:ms.MessageType.TEXT,message:e};await this.authenticatedFetch(`/conversations/${t}/messages`,{method:"POST",body:JSON.stringify(n)})}async sendTyping(){const{conversationId:e}=this;if(!e)throw new Error("Conversation not started");await this.authenticatedFetch(`/conversations/${e}/messages/typing`,{method:"PUT"})}async acknowledgeMessage(e){const{conversationId:t}=this;if(!t)throw new Error("Conversation not started");await this.authenticatedFetch(`/conversations/${t}/messages/acknowledge`,{method:"PUT",body:JSON.stringify(e)})}async terminateConversation(){const{conversationId:e}=this;if(!e)throw new Error("Conversation not started");await this.authenticatedFetch(`/conversations/${e}/terminate`,{method:"POST"}),this.destroy()}destroy(){this.five9WebSocket&&this.five9WebSocket.destroy(),Ze(this,we,null),Ze(this,Ye,null)}get sessionToken(){return ys(this,we)}get conversationId(){return ys(this,Ye)}get dataCenter(){var e;return(e=this.sessionToken)==null?void 0:e.metadata.dataCenters[0]}get apiUrl(){var e;return(e=this.dataCenter)==null?void 0:e.apiUrls[0].host}get tenantId(){var e;return(e=this.sessionToken)==null?void 0:e.orgId}get tokenId(){var e;return(e=this.sessionToken)==null?void 0:e.tokenId}get farmId(){var e;return(e=this.sessionToken)==null?void 0:e.context.farmId}};we=new WeakMap,Ye=new WeakMap;let fs=Ht;function Ut(s){return`any-${s||"main"}-chatSession`}async function wa({id:s,params:e,chatWindow:t,html:i}){t=t;const n=async()=>{t.removeMessage("transferMessageId"),await t.sendFunctionCallResponse(s,{transfer:"Declined"},!0),t.setInputDisabled(!1)},r=async()=>{t.setInputDisabled(!0),t.removeMessage("transferMessageId"),t.addMessage({role:"system",content:"Please wait while we connect you to a live agent"}),t.chatManager.stopInactivityTimers();const a=new fs;await a.createSession();const{summary:o,subject:c,...l}=e;await a.createConversation({contact:l,attributes:{Question:c,"AI Summary":o}}),localStorage.setItem(Ut(t.cleanOptions.config.historyKey),a.serialize()),qi(t,a)};t.addMessage({id:"transferMessageId",role:"system",contentHtmlTemplate:i`
|
|
396
|
+
`],Mn([V({type:Object})],vt.prototype,"options",2),Mn([V({type:Boolean})],vt.prototype,"isChatWindowOpen",2),Mn([ht()],vt.prototype,"isCtaOpen",2),vt=Mn([_e("iai-chat-open-chat-button")],vt);class Fo{constructor(e){this.widget=null,this.options=xn.parse(e);const t=document.createElement("iai-chat-popup");t.options=this.options;const n=Hs(this.options.config.styles);Object.entries(n).forEach(([s,r])=>{t.style.setProperty(`--iai-chat-${s}`,r)}),document.body.appendChild(t),this.widget=t}get api(){if(!this.widget)throw new Error("Widget has not been initialized");return this.widget}destroy(){var e;(e=this.widget)==null||e.remove(),this.widget=null}}var Vo=Object.defineProperty,qo=Object.getOwnPropertyDescriptor,Rn=(i,e,t,n)=>{for(var s=n>1?void 0:n?qo(e,t):e,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=(n?a(e,t,s):a(s))||s);return n&&s&&Vo(e,t,s),s};let bt=class extends se{constructor(){super(...arguments),this.activeIndex=0,this.items=[]}render(){return z`
|
|
397
|
+
<div>
|
|
398
|
+
<div
|
|
399
|
+
id="carousel"
|
|
400
|
+
class="flex overflow-x-auto snap-x snap-mandatory overflow-scrolling-touch m-0 p-0"
|
|
401
|
+
@scroll="${this.onScroll}"
|
|
402
|
+
>
|
|
403
|
+
<slot @slotchange=${this.onSlotChange}>zzz</slot>
|
|
404
|
+
</div>
|
|
405
|
+
|
|
406
|
+
<div class="flex justify-between items-center">
|
|
407
|
+
<button class="cursor-pointer h-6" @click=${()=>this.scrollCarousel(-1)}>
|
|
408
|
+
|
|
409
|
+
<svg
|
|
410
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
411
|
+
viewBox="0 0 24 24"
|
|
412
|
+
width="100%"
|
|
413
|
+
height="100%"
|
|
414
|
+
fill="currentColor"
|
|
415
|
+
>
|
|
416
|
+
<title>arrow-left</title>
|
|
417
|
+
<path d="M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z" />
|
|
418
|
+
</svg>
|
|
419
|
+
</button>
|
|
420
|
+
|
|
421
|
+
<div class="flex justify-center space-x-2">
|
|
422
|
+
${is(this.items,(i,e)=>e,(i,e)=>z`
|
|
423
|
+
<span
|
|
424
|
+
class="h-2.5 w-2.5 bg-gray-400 rounded-full inline-block ${this.activeIndex===e?"bg-gray-600":""}"
|
|
425
|
+
@click=${()=>this.scrollToIndex(e)}
|
|
426
|
+
/>
|
|
427
|
+
`)}
|
|
428
|
+
</div>
|
|
429
|
+
|
|
430
|
+
<button class="cursor-pointer h-6" @click=${()=>this.scrollCarousel(1)}>
|
|
431
|
+
<svg
|
|
432
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
433
|
+
viewBox="0 0 24 24"
|
|
434
|
+
width="100%"
|
|
435
|
+
height="100%"
|
|
436
|
+
fill="currentColor"
|
|
437
|
+
>
|
|
438
|
+
<title>arrow-right</title>
|
|
439
|
+
<path d="M4,11V13H16L10.5,18.5L11.92,19.92L19.84,12L11.92,4.08L10.5,5.5L16,11H4Z" />
|
|
440
|
+
</svg>
|
|
441
|
+
</button>
|
|
442
|
+
</div>
|
|
443
|
+
</div>
|
|
444
|
+
`}onSlotChange(i){const e=i.target;this.items=(e==null?void 0:e.assignedElements())||[]}onScroll(){const{carousel:i}=this;if(!i)return;let e=0,t=1/0;this.items.forEach((n,s)=>{const r=Math.abs(n.offsetLeft-i.scrollLeft);r<t&&(t=r,e=s)}),this.activeIndex=e}scrollCarousel(i){this.scrollToIndex(this.activeIndex+i)}scrollToIndex(i){i!==this.activeIndex&&(this.activeIndex=Math.max(0,Math.min(i,this.items.length-1)),this.scrollToActiveItem())}scrollToActiveItem(){const{carousel:i,items:e,activeIndex:t}=this;if(!i)return;const n=e[t];n&&i.scrollTo({left:n.offsetLeft-i.clientWidth/2+n.clientWidth/2,behavior:"smooth"})}};bt.styles=[$e,Ue`
|
|
445
|
+
::slotted(div) {
|
|
446
|
+
flex: 0 0 auto;
|
|
447
|
+
scroll-snap-align: start;
|
|
448
|
+
width: 100%;
|
|
449
|
+
padding: 1rem;
|
|
450
|
+
background-color: #f8f9fa;
|
|
451
|
+
border: 1px solid rgba(0, 0, 0, 0.125);
|
|
452
|
+
border-radius: 0.25rem;
|
|
453
|
+
margin-right: 1rem;
|
|
454
|
+
}
|
|
455
|
+
`],Rn([V({type:Number})],bt.prototype,"activeIndex",2),Rn([V({type:Array})],bt.prototype,"items",2),Rn([sn("#carousel")],bt.prototype,"carousel",2),bt=Rn([_e("iai-chat-carousel")],bt);function Ko({html:i,params:e}){return i`
|
|
456
|
+
<div>
|
|
457
|
+
<h2>Unit List</h2>
|
|
458
|
+
|
|
459
|
+
<iai-chat-carousel>
|
|
460
|
+
${e.units.map(t=>i`
|
|
461
|
+
<div>
|
|
462
|
+
<img src=${t.floorPlanImage} alt=${`Floor plan for unit ${t.unitName}`}>
|
|
463
|
+
<h2>Unit ${t.unitName}</h2>
|
|
464
|
+
<ul>
|
|
465
|
+
<li>Bedrooms: ${t.bedroomCount}</li>
|
|
466
|
+
<li>Bathrooms: ${t.bathroomCount}</li>
|
|
467
|
+
<li>SQFT: ${t.squareFeet}</li>
|
|
468
|
+
<li>Rent: $${t.pricing.rent}/mo for a ${t.pricing.term} Month Lease</li>
|
|
469
|
+
</ul>
|
|
470
|
+
</div>
|
|
471
|
+
`)}
|
|
472
|
+
</iai-chat-carousel>
|
|
473
|
+
`}function Jo(i){return async function({id:t,params:n,chatWindow:s}){s.setInputDisabled(!0);const r={...n.guestCardId&&{guestCardId:n.guestCardId},...n.customerFirstName&&{firstName:n.customerFirstName},...n.customerLastName&&{lastName:n.customerLastName},...n.customerEmail&&{email:n.customerEmail},...n.customerPhoneNumber&&{phone:n.customerPhoneNumber},...n.desiredMoveInDate&&{moveInDate:n.desiredMoveInDate}},a=document.createElement("iai-chat-iframe-modal");a.title="Schedule a Tour",a.src=`${i}?${new URLSearchParams(r).toString()}`,a.showHeader=!1;const o=()=>{a.remove(),window.removeEventListener("beforeunload",h),s.setInputDisabled(!1)},l=async({detail:p})=>{if(p.type!=="tourScheduled")return;const{tourType:c,tourDate:f,tourTime:O}=p;o(),s.addMessage({role:"system",content:"Your tour has been scheduled!"}),await s.sendFunctionCallResponse(t,{status:"scheduled",tourType:c,tourDate:f,tourTime:O},!0)},d=async()=>{o(),s.addMessage({role:"system",content:"Tour Scheduler Closed"}),await s.sendFunctionCallResponse(t,{status:"canceled"},!0)},h=async()=>{o(),s.addMessage({role:"system",content:"Tour Scheduler Closed"})};a.addEventListener("message-received",l),a.addEventListener("close",d),window.addEventListener("beforeunload",h),document.body.appendChild(a),s.addMessage({role:"system",content:"Tour Scheduler Opened"})}}function Vs(i){return{all:i=i||new Map,on:function(e,t){var n=i.get(e);n?n.push(t):i.set(e,[t])},off:function(e,t){var n=i.get(e);n&&(t?n.splice(n.indexOf(t)>>>0,1):i.set(e,[]))},emit:function(e,t){var n=i.get(e);n&&n.slice().map(function(s){s(t)}),(n=i.get("*"))&&n.slice().map(function(s){s(e,t)})}}}class Go{constructor(e){this.chatWsUrl=e,this._emitter=Vs(),this.on=this._emitter.on.bind(this._emitter),this.off=this._emitter.off.bind(this._emitter),this.reconnectCodes=new Set([1006]),this.reconnectAttempts=0,this.maxReconnectAttempts=10}connect(){const e=new WebSocket(this.chatWsUrl);e.onopen=async()=>{this.reconnectAttempts=0,e.send(JSON.stringify({type:"ready"}))},e.onmessage=t=>{const n=JSON.parse(t.data);this._emitter.emit(n.type,n.data)},e.onclose=t=>{console.log("Disconnected: ",t.code,t.reason||"No reason provided"),this._emitter.emit("disconnected",t),this.reconnectCodes.has(t.code)&&this.reconnectAttempts<this.maxReconnectAttempts&&(console.log("Reconnecting..."),this._emitter.emit("reconnecting"),this.reconnectAttempts++,setTimeout(()=>this.connect(),this.reconnectAttempts*1e3))},e.onerror=t=>{console.log("Error:",t),this._emitter.emit("error",t)},this.ws=e}reconnect(){this.reconnectAttempts=0,this.connect()}disconnect(){var e;(e=this.ws)==null||e.close()}destroy(){this.disconnect(),this._emitter.all.clear()}}var Pn;(i=>{(e=>{e.TEXT="TEXT"})(i.MessageType||(i.MessageType={})),(e=>{e.DELIVERED="DELIVERED",e.READ="READ",e.FAILED="FAILED"})(i.AcknowledgeType||(i.AcknowledgeType={})),(e=>{e.GENERIC="GENERIC",e.SMS="SMS",e.RCS="RCS",e.FACEBOOK="FACEBOOK",e.TWITTER="TWITTER",e.WHATSAPP="WHATSAPP",e.WECHAT="WECHAT",e.QQMOBILE="QQMOBILE",e.APPLE_BUSINESS_CHAT="APPLE_BUSINESS_CHAT",e.SKYPE="SKYPE",e.SNAPCHAT="SNAPCHAT",e.VIBER="VIBER",e.LINE="LINE",e.TELEGRAM="TELEGRAM",e.KAKAO="KAKAO"})(i.ContentType||(i.ContentType={})),(e=>{e.SYSTEM="SYSTEM",e.USER="USER"})(i.ConversationEventOrigin||(i.ConversationEventOrigin={})),(e=>{e.PENDING="PENDING",e.ACTIVE="ACTIVE",e.TERMINATED="TERMINATED"})(i.ConversationStatus||(i.ConversationStatus={}))})(Pn||(Pn={}));const Qo=Pn.AcknowledgeType,Yo="Anyone Home",Xo="IB Chat Leasing - Development";let el="https://five9.ah.inhabit.work";const tl="https://five9.ah.inhabit.work".replace("http","ws").replace(/\/$/,""),Xt=class Xt{constructor(){Ci(this,Se,void 0);Ci(this,st,void 0);this._emitter=Vs(),this.on=this._emitter.on.bind(this._emitter),this.off=this._emitter.off.bind(this._emitter),De(this,Se,null),De(this,st,null),this.conversationStarted=!1}serialize(){return JSON.stringify({sessionToken:this.sessionToken,conversationId:this.conversationId,conversationStarted:this.conversationStarted})}static deserialize(e){const t=JSON.parse(e),n=new Xt;return t.sessionToken&&n.setSession(t.sessionToken),t.conversationId&&n.setConversationId(t.conversationId),n.conversationStarted=t.conversationStarted||!1,n}static generateBaseUrl(e){return`https://${e}/appsvcs/rs/svc`}async createSession(){const e=await fetch(`${Xt.generateBaseUrl("app-scl.five9.com")}/auth/anon?cookieless=true`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({tenantName:Yo})});return De(this,Se,await e.json()),Dn(this,Se)}setSession(e){De(this,Se,e)}setConversationId(e){De(this,st,e),this.five9WebSocket&&(this.five9WebSocket.destroy(),this.five9WebSocket=void 0,e&&this.connectToWebSocket())}connect(){if(!this.sessionToken)throw new Error("Session not created");if(!this.conversationId)throw new Error("Conversation not started");this.connectToWebSocket()}connectToWebSocket(){if(!this.conversationId)throw new Error("Conversation not started");this.five9WebSocket&&this.five9WebSocket.destroy();const e=new Go(`${tl}/conversations/${this.conversationId}/ws`);e.on("*",(t,n)=>{this._emitter.emit(t,n)}),e.on("conversationCreated",t=>{this.conversationStarted=!0,console.log("Conversation Created:",t)}),e.on("conversationAccepted",t=>{console.log("Conversation Accepted:",t)}),e.on("agentJoined",t=>{console.log("Agent Joined:",t)}),e.on("agentTransferredConversation",t=>{console.log("Agent Transferred Conversation:",t)}),e.on("conversationTransferredToGroup",t=>{console.log("Conversation Transferred To Group:",t)}),e.on("agentLeftConversation",t=>{console.log("Agent Left Conversation:",t)}),e.on("agentTyping",t=>{console.log("Agent Typing:",t)}),e.on("message",async t=>{console.log("Message:",t),await this.acknowledgeMessage({messages:[{messageId:t.messageId,type:Qo.READ}]})}),e.on("conversationTerminated",t=>{console.log("Conversation Terminated:",t)}),e.on("error",t=>{console.log("Error:",t)}),this.five9WebSocket=e,e.connect()}async authenticatedFetch(e,t={}){const{sessionToken:n}=this;if(!n)throw new Error("Session not found");e=e.startsWith("/")?e:`/${e}`;const s=n.metadata.dataCenters[0].apiUrls[0].host,r=await fetch(`${Xt.generateBaseUrl(s)}${e}`,{...t,headers:{...t.headers,"Content-Type":"application/json",Accept:"application/json",Authorization:n.tokenId,farmId:n.context.farmId}});return r.status===204?null:r.json()}async getMetadata(){if(!this.sessionToken)throw new Error("Session not created");return this.authenticatedFetch("/auth/metadata",{method:"GET"})}async createConversation(e){if(!this.sessionToken)throw new Error("Session not created");const t=e.contact||{};Object.keys(t).forEach(r=>{const a=r;t[a]||delete t[a]});const n={...e,campaignName:Xo,tenantId:this.tenantId,callbackUrl:el};console.log("body",n);const s=await this.authenticatedFetch("/conversations",{method:"POST",body:JSON.stringify(n)});return this.setConversationId(s.id),s}async sendMessage(e){const{conversationId:t,conversationStarted:n}=this;if(!t||!n)throw new Error("Conversation not started");const s={messageType:Pn.MessageType.TEXT,message:e};await this.authenticatedFetch(`/conversations/${t}/messages`,{method:"POST",body:JSON.stringify(s)})}async sendTyping(){const{conversationId:e}=this;if(!e)throw new Error("Conversation not started");await this.authenticatedFetch(`/conversations/${e}/messages/typing`,{method:"PUT"})}async acknowledgeMessage(e){const{conversationId:t}=this;if(!t)throw new Error("Conversation not started");await this.authenticatedFetch(`/conversations/${t}/messages/acknowledge`,{method:"PUT",body:JSON.stringify(e)})}async terminateConversation(){const{conversationId:e}=this;if(!e)throw new Error("Conversation not started");await this.authenticatedFetch(`/conversations/${e}/terminate`,{method:"POST"}),this.destroy()}destroy(){this.five9WebSocket&&this.five9WebSocket.destroy(),De(this,Se,null),De(this,st,null)}get sessionToken(){return Dn(this,Se)}get conversationId(){return Dn(this,st)}get dataCenter(){var e;return(e=this.sessionToken)==null?void 0:e.metadata.dataCenters[0]}get apiUrl(){var e;return(e=this.dataCenter)==null?void 0:e.apiUrls[0].host}get tenantId(){var e;return(e=this.sessionToken)==null?void 0:e.orgId}get tokenId(){var e;return(e=this.sessionToken)==null?void 0:e.tokenId}get farmId(){var e;return(e=this.sessionToken)==null?void 0:e.context.farmId}};Se=new WeakMap,st=new WeakMap;let Nn=Xt;function Yt(i){return`any-${i||"main"}-chatSession`}async function nl({id:i,params:e,chatWindow:t,html:n}){t=t;const s=async()=>{t.removeMessage("transferMessageId"),await t.sendFunctionCallResponse(i,{transfer:"Declined"},!0),t.setInputDisabled(!1)},r=async()=>{t.setInputDisabled(!0),t.removeMessage("transferMessageId"),t.addMessage({role:"system",content:"Please wait while we connect you to a live agent"}),t.chatManager.stopInactivityTimers();const a=new Nn;await a.createSession();const{summary:o,subject:l,...d}=e;await a.createConversation({contact:d,attributes:{Question:l,"AI Summary":o}}),localStorage.setItem(Yt(t.cleanOptions.config.historyKey),a.serialize()),qs(t,a)};t.addMessage({id:"transferMessageId",role:"system",contentHtmlTemplate:n`
|
|
376
474
|
<style>
|
|
377
475
|
.btn {
|
|
378
476
|
background-color: #007bff;
|
|
@@ -396,7 +494,7 @@
|
|
|
396
494
|
<strong>Would you like to transfer to an agent?</strong>
|
|
397
495
|
<div>
|
|
398
496
|
<button class="btn" @click=${r}>Yes</button>
|
|
399
|
-
<button class="btn btn-no" @click=${
|
|
497
|
+
<button class="btn btn-no" @click=${s}>No</button>
|
|
400
498
|
</div>
|
|
401
499
|
</div>
|
|
402
|
-
`})}function
|
|
500
|
+
`})}function qs(i,e){e.on("*",(r,a)=>{console.log("event:",r,a)}),e.on("conversationCreated",()=>{i.setInputDisabled(!1),localStorage.setItem(Yt(i.cleanOptions.config.historyKey),e.serialize())}),e.on("conversationAccepted",r=>{i.addMessage({role:"system",content:`${r.displayName} has joined the chat`})}),e.on("agentTyping",()=>{i.setTypingIndicatorVisible(!0)}),e.on("agentJoined",r=>{i.addMessage({role:"system",content:`${r.displayName} has joined the chat`})}),e.on("agentTransferredConversation",r=>{i.addMessage({role:"system",content:`You have been transferred to ${r.toDisplayName}`})}),e.on("conversationTransferredToGroup",r=>{i.addMessage({role:"system",content:`You have been transferred to ${r.groupName}`})}),e.on("agentLeftConversation",r=>{i.addMessage({role:"system",content:`${r.displayName} has left the chat`})}),e.on("conversationTerminated",r=>{i.addMessage({role:"system",content:"The chat has ended"}),i.setInputDisabled(!0),localStorage.removeItem(Yt(i.cleanOptions.config.historyKey))}),e.on("message",r=>{switch(r.from){case"SYSTEM":i.addMessage({role:"system",content:r.text});break;case"USER":i.setTypingIndicatorVisible(!1),i.addMessage({role:"assistant",name:r.displayName,content:r.text});break;default:console.log("unhandled message:",r);break}}),e.connect();const t=async r=>{r.preventDefault(),i.addMessage({role:"user",content:r.detail.message}),await e.sendMessage(r.detail.message)},n=async()=>{console.log("destroyed fired"),e.destroy(),i.removeEventListener("iai-chat-send-user-message",t),i.removeEventListener("iai-chat-reset",s),i.removeEventListener("iai-chat-destroy",n)},s=async()=>{console.log("reset fired"),await e.terminateConversation(),await n(),localStorage.removeItem(Yt(i.cleanOptions.config.historyKey))};i.addEventListener("iai-chat-send-user-message",t),i.addEventListener("iai-chat-reset",s),i.addEventListener("iai-chat-destroy",n)}class il{constructor(e,t){const n=xn.parse({assistantId:"7e59c8c1-a4ff-40f1-9a68-86ea294a4e75",...e});n.handlers.functionCalls.transferToLiveAgent=nl,n.handlers.functionCalls.showScheduleTourWidget=Jo(t.schedulerUrl),n.handlers.enhancedContent.unitList=Ko,this.chatWidget=new Fo(n);const s=localStorage.getItem(Yt(n.config.historyKey));if(s){const r=Nn.deserialize(s);setTimeout(()=>{qs(this.chatWidget.api.chatWindow,r)},0)}}destroy(){this.chatWidget.destroy()}}K.AnyChatWidget=il,Object.defineProperty(K,Symbol.toStringTag,{value:"Module"})});
|