Liquid Tags

Overview

Liquid tags offer tremendous flexibility and personalization for your messages. You can create a 'write once use multiple times' message and add multiple variations to it. You can use Liquid tags with the following engagement channels:

  • Email
  • Mobile Push
  • SMS
  • Webhooks
  • App Inbox
  • In-App
  • Native Display
  • WhatsApp

Here is a simple example of personalization with a liquid tag:

{% if Profile.Language == "Spanish" %} 
Hola!
{% elsif Profile.Language == "English" %}
Hello!
{% endif %}

If the user's preferred language is Spanish, the greeting will appear in Spanish.

Hola!

If the user's preferred language is English, the greeting will appear in English.

Hello!

Liquid tags also support nested object personalization, allowing you to access structured profile and event data (for example, subscription.plan.name) for deeper personalization. For more information, refer to Liquid Personalization with Nested Objects.

Getting Started

You can personalize your messages for Events and User Profiles. For example, a user whose language is English (Profile property), or someone who has purchased (Event property) a new shirt.

Let us create a Liquid tag in an email campaign. To create a tag, select the "New email with rich media" template when you create an email campaign. You can use Liquid Tags within this template.

2878

Select a Rich Media Template

The Liquid Tags work within the email editor. However, you can also combine the power of HTML with Liquid Tags. You can paste your HTML code directly in the HTML editor by clicking the Source button and then personalize it with Liquid Tags. For more information, see Liquid Tags with HTML

The liquid terms are adapted from shopify's documentation to CleverTap. We support only the terms identified in our documentation for a seamless experience.

Using Tags

You can start creating your message by declaring tags in the campaign editor. You can declare the tags in the following ways:

  • For creating message conditions - Conditional tags can help you vary the message for each condition. For example, if your users make a purchase, then send them a coupon with an additional discount for their next purchase. You can create a conditional tag by enclosing the condition within curly braces and a % sign. Start by entering {% in the email editor. The closing tag is completed automatically. The syntax for these tags is: {% if %} {% endif %}
  • For displaying output from a variable - Output tags display the output of a variable. For example, if customer_type is a variable, display all the types of customers such as Platinum, Gold, and Silver. Start by entering {{ in the email editor. The closing tag is completed automatically. The syntax for these tags is: {{customer_type}}

You can use any of the Profile and Event properties within tags. Just enter Profile. or Event. in the editor and we will list all the corresponding properties automatically.

📘

Note

When selecting properties, the "P" in profile and the "E" in Events must be capitalized and followed with a period ".". Profile properties are available for all segments. Liquid tags for Event properties are only available for live user segments. The "@" personalization is supported only outside the tags.

Conditional Tags

You can use conditional tags for creating simple or complex conditional statements. For example, If condition A, then send message 1, else send message 2, else-if message 3. If we were to express this in tags, we can use the user's preferred language as an example.

The following are the conditional tags:

  • if
  • else
  • else-if
  • unless
  • switch case
  • for
  • break
  • split
  • continue
  • abort
  • limit
  • offset
  • tablerow
  • now

If

{% if Profile.Language  == "French"%} 

Bonjour !

{% endif %}

Else/Elseif

You can send messages conditionally to each recipient.

{% if Profile.Language  == "French"%} 

Bonjour !

{% elsif  Profile.Language == "Spanish"%} 

Hola!

{% else %}

Hello!

{% endif %}

If the user's preferred language is French, the greeting will appear in French. If the user's preferred language is Spanish, the greeting will appear in Spanish. However, if the preferred language is not French or Spanish, the greeting will appear in English.

Hello!

You can display different messages based on the value of an Event Property (for example, Requested Product). Here is an example demonstrating the syntax for using Event Properties in Liquid Tags:

{% if Event["Requested Product"] == "Personal Loan" %}
You selected **Personal Loan**. Here's what you need to know about it.
  
{% elsif Event["Requested Product"] == "Car Title Loan" %}
You selected **Car Title Loan**. Let's get started with your application.
  
{% else %}
It seems like we couldn't determine your requested product. Please try again.
{% endif %}

Unless

You can use this tag if a condition is not true. For example, if a user's language is "not" French, then greet with "Hello" in English.

{% unless Profile.Language  == "French"%} 

Hello!

{% endunless %}

The message display will be as follows:

Hello!

Switch case

You can switch a statement when a variable changes in value. The when statements define the various conditions.
For example, you have three types of customers, namely "Gold", "Silver" and everyone else. They are represented by the profile property "customer_type". You can change the displayed message based on the type of customers.

{% case Profile.customer_type %}
  {% when "Gold" %}
     You are eligible for free lounge access!
  {% when "Silver" %}
     You are eligible for lounge access at only 50% of the cost!
  {% else %}
     Upgrade your membership now for free lounge access!
{% endcase %}
Upgrade your membership now for free lounge access!

for

You can repeat execution in liquid script with the for a loop.

{% for item in hiking.items %}
  {{ item.names | default: "NA"}}
{% endfor %}
flashlight  backpack boots

break

You can stop execution in the liquid script by adding break in a loop.

{% for i in (1..10) %}
  {% if i == 7 %}
    {% break %}
  {% else %}
    {{ i | default: "NA" }}
  {% endif %}
{% endfor %}
1 2 3 4 5 6

split

You can divide a string into an array using the argument as a separator. It converts comma-separated values from a string format to an array.

{% assign premium = " Customer 1, Customer 2, Customer 3, Customer 4" | split: ", " %}
{% for member in premium %}
  {{ member }}
{% endfor %}

split displays the following output:

Customer 1

Customer 2

Customer 3

Customer 4

continue

You can skip the current iteration in a loop with the continue tag.

{% for i in (1..10) %}
  {% if i == 7 %}
    {% continue %}
  {% else %}
    {{ i | default: "NA"}}
  {% endif %}
{% endfor %}
1 2 3 4 5 6   8 9 10

abort

This is a CleverTap Tag within Liquid. You can abort sending a message with the abort tag. If a condition is not fulfilled for a user, it is displayed in the campaign reports as LiquidLogicAborted.

{% if Event.price > 100%}
Thank you for your purchase. Here is a coupon code for you. 
COUPON
{% else %}
{% abort %}
{% endif %}
Thank you for your purchase. Here is a coupon code for you. 
COUPON

limit

You can specify the limit of the for loop with this tag.

<!-- if array = [1,2,3,4,5,6] -->
{% for item in array limit:2 %}
  {{ item | default: "NA" }}
{% endfor %}
1 2

offset

You can begin the loop at a specified index.

<!-- if array = [1,2,3,4,5,6] -->
{% for item in array offset:2 %}
  {{ item | default: "NA" }}
{% endfor %}
3 4 5 6

tablerow

You can generate an HTML table with this tag. It must be wrapped in opening <table> and closing </table> HTML tags.

<table>
{% tablerow product in Profile.multi %}
{{ product | default: "def" }}
{% endtablerow %}
</table>
<table>
  <tr class="row1">
    <td class="col1">
      Cool Shirt
    </td>
    <td class="col2">
      Alien Poster
    </td>
    <td class="col3">
      Batman Poster
    </td>
    <td class="col4">
      Bullseye Shirt
    </td>
    <td class="col5">
      Another Classic Vinyl
    </td>
    <td class="col6">
      Awesome Jeans
    </td>
  </tr>
</table>

now

Using this tag, you can insert the current date and time in the specified format. Results are returned in IST (Indian Standard Time, UTC+5:30) by default.

{{ "now" | date: "%Y-%m-%d %H:%M" }}

date_tz

Using this tag you can format the current timestamp in a specified IANA timezone. Use this filter when your messages need to display time in the recipient's local timezone or a specific regional timezone, regardless of the server timezone.

Syntax

{{ "now" | date_tz: "<format>", "<timezone>" }}

Parameters

format: A string format for time (same as the standard date filter).

timezone: An IANA timezone string (for example, Asia/Singapore, America/Los_Angeles).

📘

Note

Daylight saving time adjustments are handled automatically for time zones that observe Daylight Saving Time (DST).

The date_tz filter is supported across all channels: Email, Mobile Push, SMS, Webhooks, App Inbox, In-App, and WhatsApp.

For example, you can use multiple date_tz calls within a single message to display time across different timezones simultaneously:

Singapore: {{ "now" | date_tz: "%Y-%m-%d %H:%M:%S", "Asia/Singapore" }}
London:    {{ "now" | date_tz: "%Y-%m-%d %H:%M:%S", "Europe/London" }}
New York:  {{ "now" | date_tz: "%H:%M", "America/New_York" }}
Sydney: {{ "now" | date_tz: "%Y-%m-%d %H:%M:%S", "Australia/Sydney" }}
Auckland: {{ "now" | date_tz:"%Y-%m-%d %H:%M:%S", "Pacific/Auckland" }}

Variable Tags

Assign

You can use the assign tag to assign value to a variable. The value of this variable can change based on the defined condition or a range. You can then reuse this variable across your message.

For example, you want to greet a user in French. You create a variable called LANG. Now, you can use this variable for all available languages. If the value of the LANG variable is French, the greeting is "Bonjour!". The greeting is "Hello!" for all other languages.

{% assign LANG = PROFILE.Language %}
{% if LANG == "FRENCH" %}
Bonjour!
{% else %}
Hello!
{% endif %}

Theme Tags

Raw

You can use the raw tag to display characters used by the tag syntax.

{% raw %}{{ 5 | plus: 6 }}{% endraw %} equals 11.
{{ 5 | plus: 6 }} equals 11.

Comment

You can comment on your code with this tag. It can be notes or description that you want to add to make your code more understandable.

{% if Profile.Language  == "French"%} 

{% comment %} This condition is fulfilled only if the value is 
French {% endcomment %}

Bonjour !

{% endif %}
Bonjour!

Operators

You can use the following operators to evaluate conditions in your tags.

OperatorDescription
==equals
!=does not equal
>greater than
<less than
>=greater than or equal to
<=less than or equal to
orlogical or. Choose between condition 1 or condition 2.
andlogical and. Choose conditions 1 and condition 2
containscheck for a string within a string

Liquid Personalization with Nested Objects

You can personalize campaign messages using nested objects within profile-based and event-based personalization for deeper data granularity in your campaigns. To use nested personalization, ensure that Nested Object Personalization is enabled for your account.

Syntax

Nested profile and event personalization are supported up to 3 levels. Use the following syntax to configure personalization placeholders:

  • Nested Profile Personalization: {{ Profile.<property_name>.<level_1>.<level_2>.<level_3> | default: "Default" }}
  • Nested Event Personalization: {{ Event.<property_name>.<level_1>.<level_2>.<level_3> | default: "Default" }}

When using nested personalization, you must use the Preview & Test option to validate your message before publishing the campaign.

📘

Supported Channels

You can use Nested Personalization with the following channels: Email, Mobile Push, SMS, Webhooks, and WhatsApp.

Example

Nested personalization is especially useful when your profile or event data is stored in structured objects such as subscription details, order information, travel bookings, or product metadata.

For example, suppose your profile stores subscription information in the following structure:
subscription > plan > name

You can reference the plan name using{{ Profile.subscription.plan.name | default: "your current plan" }}

Sample Campaign

Thanks for being a {{ Profile.subscription.plan.name | default: "valued" }} member! Unlock your exclusive benefits today.

In this case, the campaign dynamically inserts the exact plan name (for example, Gold or Premium), making the message more contextual and relevant. If the value is unavailable, the default value ensures the message remains natural.

Liquid Tags with HTML

This section applies only to the email channel.

You can combine your HTML code with Liquid Tags to create beautiful and personalized messages for your users. To do so:

  1. Open the message editor and paste your HTML code.
  2. Click the Image icon and add your Liquid Tags.
2876

Add Liquid Tags

Linked Content and Liquid Tags in Drag and Drop Editor

Linked Content and Liquid tags are available for the drag-and-drop email editor. This functionality allows customers to design emails and personalize them using dynamic content when they create an email campaign.

Perform the following steps to personalize drag and drop editor templates with liquid tags.

  1. Select a template.
2878

Select Media Template

  1. Click the Row item in Preview.
1047

Select the Row Tab

  1. Click More dropdown and select Customize with Liquid Tags. The Personalize messages with Liquid tags and Linked Content popup displays.
2862

Customize with Liquid Tags

  1. Add the liquid script inside the popup.
2856

Add Liquid Script

  1. Click Add.

Validate Liquid Tags

When creating a campaign message with Liquid tags, errors appear in real time if the syntax is incorrect. Errors also surface when clicking Done on the campaign creation page if the message contains invalid Liquid Tag syntax. You can also use Preview & Test in the message editor to validate your message and send test campaigns with personalized values.

Here is an example of how to add Liquid Tags in the message editor:

Add Liquid Tags

Message Editor

Here is an example of how CleverTap validates the Liquid Tag syntax from the campaign creation page:

Validating the Liquid Tag Syntax

Validating the Liquid Tag Syntax

Video Tutorial

You can watch the following video to learn more about Liquid Tags personalization.


CleverTap Ask AI Widget (CSP-Safe) ");const I1=O?O.createHTML(p):p;if(pe===h1)try{V=new g().parseFromString(I1,a2)}catch{}if(!V||!V.documentElement){V=I.createDocument(pe,"template",null);try{V.documentElement.innerHTML=w5?U:I1}catch{}}const te=V.body||V.documentElement;return p&&J&&te.insertBefore(n.createTextNode(J),te.childNodes[0]||null),pe===h1?r1.call(V,V1?"html":"body")[0]:V1?V.documentElement:te},w8=function(p){return F.call(p.ownerDocument||p,p,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},c7=function(p){return p instanceof d&&(typeof p.nodeName!="string"||typeof p.textContent!="string"||typeof p.removeChild!="function"||!(p.attributes instanceof u)||typeof p.removeAttribute!="function"||typeof p.setAttribute!="function"||typeof p.namespaceURI!="string"||typeof p.insertBefore!="function"||typeof p.hasChildNodes!="function")},b8=function(p){return typeof a=="function"&&p instanceof a};function at(i1,p,V){u3(i1,J=>{J.call(e,p,V,b5)})}const _8=function(p){let V=null;if(at(a1.beforeSanitizeElements,p,null),c7(p))return Ye(p),!0;const J=K1(p.nodeName);if(at(a1.uponSanitizeElement,p,{tagName:J,allowedTags:N}),L1&&p.hasChildNodes()&&!b8(p.firstElementChild)&&se(/<[/\w!]/g,p.innerHTML)&&se(/<[/\w!]/g,p.textContent)||p.nodeType===i2.progressingInstruction||L1&&p.nodeType===i2.comment&&se(/<[/\w]/g,p.data))return Ye(p),!0;if(!N[J]||b1[J]){if(!b1[J]&&y8(J)&&(t1.tagNameCheck instanceof RegExp&&se(t1.tagNameCheck,J)||t1.tagNameCheck instanceof Function&&t1.tagNameCheck(J)))return!1;if(Ce&&!R[J]){const I1=P(p)||p.parentNode,te=$(p)||p.childNodes;if(te&&I1){const G1=te.length;for(let be=G1-1;be>=0;--be){const lt=A(te[be],!0);lt.__removalCount=(p.__removalCount||0)+1,I1.insertBefore(lt,Z(p))}}}return Ye(p),!0}return p instanceof l&&!W_(p)||(J==="noscript"||J==="noembed"||J==="noframes")&&se(/<\/no(script|embed|frames)/i,p.innerHTML)?(Ye(p),!0):(ue&&p.nodeType===i2.text&&(V=p.textContent,u3([m,h,E],I1=>{V=t2(V,I1," ")}),p.textContent!==V&&(e2(e.removed,{element:p.cloneNode()}),p.textContent=V)),at(a1.afterSanitizeElements,p,null),!1)},E8=function(p,V,J){if(de&&(V==="id"||V==="name")&&(J in n||J in G_))return!1;if(!(A1&&!D1[V]&&se(D,V))){if(!(O1&&se(z,V))){if(!X[V]||D1[V]){if(!(y8(p)&&(t1.tagNameCheck instanceof RegExp&&se(t1.tagNameCheck,p)||t1.tagNameCheck instanceof Function&&t1.tagNameCheck(p))&&(t1.attributeNameCheck instanceof RegExp&&se(t1.attributeNameCheck,V)||t1.attributeNameCheck instanceof Function&&t1.attributeNameCheck(V))||V==="is"&&t1.allowCustomizedBuiltInElements&&(t1.tagNameCheck instanceof RegExp&&se(t1.tagNameCheck,J)||t1.tagNameCheck instanceof Function&&t1.tagNameCheck(J))))return!1}else if(!W[V]){if(!se(B,t2(J,x,""))){if(!((V==="src"||V==="xlink:href"||V==="href")&&p!=="script"&&y_(J,"data:")===0&&T[p])){if(!(ze&&!se(b,t2(J,x,"")))){if(J)return!1}}}}}}return!0},y8=function(p){return p!=="annotation-xml"&&Y9(p,H)},x8=function(p){at(a1.beforeSanitizeAttributes,p,null);const{attributes:V}=p;if(!V||c7(p))return;const J={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:X,forceKeepAttr:void 0};let I1=V.length;for(;I1--;){const te=V[I1],{name:G1,namespaceURI:be,value:lt}=te,l2=K1(G1),u7=lt;let ne=G1==="value"?u7:x_(u7);if(J.attrName=l2,J.attrValue=ne,J.keepAttr=!0,J.forceKeepAttr=void 0,at(a1.uponSanitizeAttribute,p,J),ne=J.attrValue,M1&&(l2==="id"||l2==="name")&&(_5(G1,p),ne=E1+ne),L1&&se(/((--!?|])>)|<\/(style|title)/i,ne)){_5(G1,p);continue}if(J.forceKeepAttr)continue;if(!J.keepAttr){_5(G1,p);continue}if(!ce&&se(/\/>/i,ne)){_5(G1,p);continue}ue&&u3([m,h,E],S8=>{ne=t2(ne,S8," ")});const M8=K1(p.nodeName);if(!E8(M8,l2,ne)){_5(G1,p);continue}if(O&&typeof C=="object"&&typeof C.getAttributeType=="function"&&!be)switch(C.getAttributeType(M8,l2)){case"TrustedHTML":{ne=O.createHTML(ne);break}case"TrustedScriptURL":{ne=O.createScriptURL(ne);break}}if(ne!==u7)try{be?p.setAttributeNS(be,G1,ne):p.setAttribute(G1,ne),c7(p)?Ye(p):q9(e.removed)}catch{_5(G1,p)}}at(a1.afterSanitizeAttributes,p,null)},j_=function i1(p){let V=null;const J=w8(p);for(at(a1.beforeSanitizeShadowDOM,p,null);V=J.nextNode();)at(a1.uponSanitizeShadowNode,V,null),_8(V),x8(V),V.content instanceof o&&i1(V.content);at(a1.afterSanitizeShadowDOM,p,null)};return e.sanitize=function(i1){let p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},V=null,J=null,I1=null,te=null;if(w5=!i1,w5&&(i1="<\x21--\x3e"),typeof i1!="string"&&!b8(i1))if(typeof i1.toString=="function"){if(i1=i1.toString(),typeof i1!="string")throw n2("dirty is not a string, aborting")}else throw n2("toString is not a function");if(!e.isSupported)return i1;if(ee||l7(p),e.removed=[],typeof i1=="string"&&(L=!1),L){if(i1.nodeName){const lt=K1(i1.nodeName);if(!N[lt]||b1[lt])throw n2("root node is forbidden and cannot be sanitized in-place")}}else if(i1 instanceof a)V=L8("<\x21----\x3e"),J=V.ownerDocument.importNode(i1,!0),J.nodeType===i2.element&&J.nodeName==="BODY"||J.nodeName==="HTML"?V=J:V.appendChild(J);else{if(!Ae&&!ue&&!V1&&i1.indexOf("<")===-1)return O&&o1?O.createHTML(i1):i1;if(V=L8(i1),!V)return Ae?null:o1?U:""}V&&P1&&Ye(V.firstChild);const G1=w8(L?i1:V);for(;I1=G1.nextNode();)_8(I1),x8(I1),I1.content instanceof o&&j_(I1.content);if(L)return i1;if(Ae){if(Ve)for(te=Q.call(V.ownerDocument);V.firstChild;)te.appendChild(V.firstChild);else te=V;return(X.shadowroot||X.shadowrootmode)&&(te=v1.call(r,te,!0)),te}let be=V1?V.outerHTML:V.innerHTML;return V1&&N["!doctype"]&&V.ownerDocument&&V.ownerDocument.doctype&&V.ownerDocument.doctype.name&&se(n8,V.ownerDocument.doctype.name)&&(be=" `+be),ue&&u3([m,h,E],lt=>{be=t2(be,lt," ")}),O&&o1?O.createHTML(be):be},e.setConfig=function(){let i1=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};l7(i1),ee=!0},e.clearConfig=function(){b5=null,ee=!1},e.isValidAttribute=function(i1,p,V){b5||l7({});const J=K1(i1),I1=K1(p);return E8(J,I1,V)},e.addHook=function(i1,p){typeof p=="function"&&e2(a1[i1],p)},e.removeHook=function(i1,p){if(p!==void 0){const V=__(a1[i1],p);return V===-1?void 0:E_(a1[i1],V,1)[0]}return q9(a1[i1])},e.removeHooks=function(i1){a1[i1]=[]},e.removeAllHooks=function(){a1=i8()},e}var s8=o8();const a8={USE_PROFILES:{html:!0},ALLOWED_TAGS:["p","div","span","br","strong","em","u","a","ul","ol","li","code","pre","h1","h2","h3","h4","h5","h6","blockquote","hr","table","thead","tbody","tr","th","td","img","button","svg","rect","path"],ALLOWED_ATTR:["href","target","class","id","src","alt","width","height","rel","title","data-code","data-language","loading","viewBox","fill","stroke","stroke-width","d","x","y","rx","ry","xmlns","fill-rule","clip-rule"]},l8=(t,e)=>{t.innerHTML=s8.sanitize(e.value||"",a8)},$_={bind:l8,update:l8},c8=t=>s8.sanitize(t,a8);var xt;let Se=xt=class extends l1{constructor(){super(...arguments),Object.defineProperty(this,"message",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"enableVoice",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isSpeaking",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"feedbackGiven",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"codeBlockInstances",{enumerable:!0,configurable:!0,writable:!0,value:[]})}get isUser(){return this.message.role==="user"}get isAssistant(){return this.message.role==="assistant"}get showLoadingIndicator(){return this.message.isStreaming===!0&&this.message.content.trim()===""}get isStreamingWithContent(){return this.message.isStreaming===!0&&this.message.content.trim().length>0}get sanitizedUserContent(){return c8(U1.escapeHtml(this.message.content))}get renderedAssistantContent(){const e=J5.renderStreaming(this.message.id,this.message.content,this.message.isStreaming??!1);return c8(e)}mounted(){this.$nextTick(()=>this.mountCodeBlocks())}updated(){this.$nextTick(()=>this.mountCodeBlocks())}beforeDestroy(){this.destroyCodeBlocks(),J5.clearStreamingCache(this.message.id)}render(){return this.isUser?this.renderUserMessage():this.renderAssistantMessage()}renderUserMessage(){const e=this.$createElement;return e("div",{class:"ct-user-message"},[e("div",{class:"ct-user-query",directives:[{name:"safe-html",value:this.sanitizedUserContent}],on:{click:this.handleLinkClick}})])}renderAssistantMessage(){const e=this.$createElement,n=this.message.content.trim().length>0;return e("div",{class:"ct-ai-message-container"},[e("div",{class:"ct-ai-message-content"},[(n||this.showLoadingIndicator)&&e("div",{class:"ct-ai-message-final"},[e("div",{class:"ct-ai-message-icon-container"},[e(j,{attrs:{type:j.Type.ASK_AI,size:xt.AVATAR_ICON_SIZE},class:"ct-ask-logo"})]),e("div",{class:"ct-ai-message-body"},[this.showLoadingIndicator&&e("i",{class:"ct-status-line"},["Thinking..."]),n&&e("div",{class:["ct-ai-message",{"ct-streaming":this.isStreamingWithContent}],directives:[{name:"safe-html",value:this.renderedAssistantContent}],on:{click:this.handleLinkClick}}),this.isStreamingWithContent&&e("span",{class:"ct-streaming-cursor"})])]),!this.message.isStreaming&&n&&this.renderMessageActions()])])}renderMessageActions(){const e=this.$createElement;return e("div",{class:"ct-message-actions"},[e("div",{class:"ct-actions-primary"},[e(Ft,{class:"ct-action-btn",attrs:{text:this.message.content,tooltipText:"Copy",tooltipTextCopied:"Copied!"}})]),e("div",{class:"ct-actions-feedback"},[e(q1,{class:["ct-fb-btn",{"ct-active-good":this.feedbackGiven==="good"}],attrs:{tooltip:"Good Answer",stopPropagation:!0,iconSize:xt.ACTION_ICON_SIZE,icon:j.Type.THUMBS_UP,color:this.feedbackGiven==="good"?K.Color.SUCCESS:K.Color.LIGHT,disabled:!!this.feedbackGiven},on:{click:()=>this.handleFeedback("good")}}),e(q1,{class:["ct-fb-btn",{"ct-active-bad":this.feedbackGiven==="bad"}],attrs:{tooltip:"Bad Answer",stopPropagation:!0,iconSize:xt.ACTION_ICON_SIZE,icon:j.Type.THUMBS_DOWN,color:this.feedbackGiven==="bad"?K.Color.DANGER:K.Color.LIGHT,disabled:!!this.feedbackGiven},on:{click:()=>this.handleFeedback("bad")}})])])}onContentChange(){this.message.isStreaming||this.$nextTick(()=>this.mountCodeBlocks())}onStreamingChange(e){e||this.$nextTick(()=>this.mountCodeBlocks())}handleSpeak(){this.$emit(xt.Event.SPEAK,this.message.content)}handleFeedback(e){this.feedbackGiven=e,this.$emit(xt.Event.FEEDBACK,e,this.message.content,this.message.id)}handleLinkClick(e){const r=e.target.closest("a");r?.href&&!r.closest(".ct-message-actions")&&(e.preventDefault(),window.open(r.href,"_blank","noopener,noreferrer"),He.linkClicked(r.href,r.textContent?.trim()||r.href))}mountCodeBlocks(){if(!this.$el||this.isUser||this.message.isStreaming)return;const e=this.$el.querySelector(".ct-ai-message");if(!e)return;const n=e.querySelectorAll(".ct-code-placeholder");if(n.length===0)return;this.destroyCodeBlocks();const r=Array.from(n).map(i=>i.getAttribute("data-language")||"text").filter((i,o,s)=>s.indexOf(i)===o);v_(r),n.forEach(i=>{const o=i.getAttribute("data-code"),s=i.getAttribute("data-language")||"text";if(o)try{const a=J5.decodeBase64Unicode(o);if(!a)return;const l=document.createElement("div");l.className="ct-code-block-wrapper",i.parentNode?.replaceChild(l,i);const c=l1.extend(Ie),u=new c({propsData:{text:a,language:s,showCopyButton:!0,tooltipText:"Copy",tooltipTextCopied:"Copied!"}});u.$mount(),l.appendChild(u.$el),this.codeBlockInstances.push(u)}catch(a){console.error("[ChatMessage] Failed to mount code block:",a)}})}destroyCodeBlocks(){this.codeBlockInstances.forEach(e=>{e.$destroy()}),this.codeBlockInstances=[]}};Object.defineProperty(Se,"AVATAR_ICON_SIZE",{enumerable:!0,configurable:!0,writable:!0,value:20}),Object.defineProperty(Se,"ACTION_ICON_SIZE",{enumerable:!0,configurable:!0,writable:!0,value:16}),v([y({type:Object,required:!0,validator:t=>!!t&&["user","assistant"].includes(t.role)}),f("design:type",Object)],Se.prototype,"message",void 0),v([y({type:Boolean,default:!1}),f("design:type",Boolean)],Se.prototype,"enableVoice",void 0),v([y({type:Boolean,default:!1}),f("design:type",Boolean)],Se.prototype,"isSpeaking",void 0),v([ge("message.content"),f("design:type",Function),f("design:paramtypes",[]),f("design:returntype",void 0)],Se.prototype,"onContentChange",null),v([ge("message.isStreaming"),f("design:type",Function),f("design:paramtypes",[Boolean]),f("design:returntype",void 0)],Se.prototype,"onStreamingChange",null),Se=xt=v([Z1({name:"ChatMessage",directives:{"safe-html":$_}})],Se),function(t){(function(e){e.COPY="copy",e.SPEAK="speak",e.FEEDBACK="feedback",e.LINK_CLICK="link-click"})(t.Event||(t.Event={}))}(Se||(Se={}));var ot,u8;let $1=ot=class extends l1{constructor(){super(...arguments),Object.defineProperty(this,"projectName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sendMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"stopRun",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isStreaming",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"disabled",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"enableVoice",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isListening",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"hasMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"startingText",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"textareaRef",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"text",{enumerable:!0,configurable:!0,writable:!0,value:""})}get placeholder(){return this.isListening?"Listening...":this.isStreaming?"AI is thinking...":"Search or ask a question..."}get textValue(){return this.text||this.startingText}onTextChange(){this.$nextTick(()=>this.adjustTextareaHeight())}onStartingTextChange(e){this.$nextTick(()=>{e&&(this.focus(),this.adjustTextareaHeight())})}mounted(){this.adjustTextareaHeight()}focus(){this.textareaRef?.focus()}render(){const e=arguments[0];return e("div",{class:"ct-composer-footer drag-cancel"},[e("div",{class:"ct-composer-container"},[e(K,{class:"ct-action-btn ct-clear-btn",attrs:{tooltip:"Clear conversation",size:ot.DELETE_BUTTON_SIZE,iconSize:ot.DELETE_ICON_SIZE,icon:j.Type.DELETE,color:K.Color.LIGHT,disabled:this.isStreaming||!this.hasMessages},on:{click:this.handleClear}}),e("div",{class:"ct-input-wrapper"},[e("textarea",{ref:"textarea",class:"ct-input",attrs:{autocomplete:"none",placeholder:this.placeholder,disabled:this.disabled||this.isStreaming,rows:1},domProps:{value:this.textValue},on:{input:n=>{this.text=n.target.value},keydown:this.handleKeyDown}}),e("div",{class:"ct-input-actions"},[this.enableVoice&&e(q1,{class:["ct-action-btn ct-voice-btn",{"ct-listening":this.isListening}],attrs:{tooltip:"Voice input",iconSize:ot.DEFAULT_ICON_SIZE,icon:j.Type.MIC,color:this.isListening?K.Color.DANGER:K.Color.PRIMARY,appearance:this.isListening?K.Appearance.OUTLINE:K.Appearance.LIGHTEN},on:{click:this.handleVoice}}),this.isStreaming?e("button",{class:"ct-submit-btn",on:{click:this.handleStop}},[e(j,{attrs:{type:j.Type.ASK_AI_LOADING,size:24},class:"ct-ask-ai-icon"})]):e("button",{class:"ct-submit-btn",attrs:{disabled:this.disabled||!this.text.trim()},on:{click:this.handleSend}},[this.disabled?e(j,{attrs:{type:j.Type.ASK_AI_LOADING,size:24},class:"ct-ask-ai-icon"}):e(j,{attrs:{type:j.Type.ASK_AI,size:24},class:"ct-ask-ai-icon"})])])])]),e("div",{class:"ct-disclaimer"},["Powered by CleverAI. Responses may have inaccuracies. Please verify important info."])])}adjustTextareaHeight(){const e=this.textareaRef;e&&(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,200)}px`)}handleKeyDown(e){e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),this.handleSend())}handleSend(){const e=this.text.trim();e&&!this.disabled&&!this.isStreaming&&(this.sendMessage&&this.sendMessage(e),this.$emit(ot.Event.SEND,e),this.text="",this.$nextTick(()=>{this.adjustTextareaHeight()}))}handleStop(){this.stopRun&&this.stopRun(),this.$emit(ot.Event.STOP)}handleClear(){this.isStreaming||this.$emit(ot.Event.CLEAR)}handleVoice(){this.$emit(ot.Event.VOICE)}};Object.defineProperty($1,"DEFAULT_ICON_SIZE",{enumerable:!0,configurable:!0,writable:!0,value:16}),Object.defineProperty($1,"DELETE_BUTTON_SIZE",{enumerable:!0,configurable:!0,writable:!0,value:"48px"}),Object.defineProperty($1,"DELETE_ICON_SIZE",{enumerable:!0,configurable:!0,writable:!0,value:20}),v([y({type:String,required:!0}),f("design:type",String)],$1.prototype,"projectName",void 0),v([y({type:Function,required:!1}),f("design:type",Function)],$1.prototype,"sendMessage",void 0),v([y({type:Function,required:!1}),f("design:type",Function)],$1.prototype,"stopRun",void 0),v([y({type:Boolean,default:!1}),f("design:type",Boolean)],$1.prototype,"isStreaming",void 0),v([y({type:Boolean,default:!1}),f("design:type",Boolean)],$1.prototype,"disabled",void 0),v([y({type:Boolean,default:!1}),f("design:type",Boolean)],$1.prototype,"enableVoice",void 0),v([y({type:Boolean,default:!1}),f("design:type",Boolean)],$1.prototype,"isListening",void 0),v([y({type:Boolean,default:!1}),f("design:type",Boolean)],$1.prototype,"hasMessages",void 0),v([y({default:""}),f("design:type",String)],$1.prototype,"startingText",void 0),v([hn("textarea"),f("design:type",typeof(u8=typeof HTMLTextAreaElement<"u"&&HTMLTextAreaElement)=="function"?u8:Object)],$1.prototype,"textareaRef",void 0),v([ge("text"),f("design:type",Function),f("design:paramtypes",[]),f("design:returntype",void 0)],$1.prototype,"onTextChange",null),v([ge("startingText",{immediate:!0}),f("design:type",Function),f("design:paramtypes",[String]),f("design:returntype",void 0)],$1.prototype,"onStartingTextChange",null),$1=ot=v([Z1({name:"ChatComposer"})],$1),function(t){(function(e){e.SEND="send",e.STOP="stop",e.CLEAR="clear",e.VOICE="voice"})(t.Event||(t.Event={}))}($1||($1={}));var o7;let Kt=o7=class extends l1{constructor(){super(...arguments),Object.defineProperty(this,"question",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}render(){const e=arguments[0];return e("button",{class:"ct-query-pill",on:{click:this.handleClick}},[this.question])}handleClick(){this.$emit(o7.Event.SELECT,this.question)}};v([y({type:String,required:!0}),f("design:type",String)],Kt.prototype,"question",void 0),Kt=o7=v([Z1({name:"QueryPill"})],Kt),function(t){(function(e){e.SELECT="select"})(t.Event||(t.Event={}))}(Kt||(Kt={}));var o2,d8,C8,p8;let Y1=o2=class extends l1{constructor(){super(...arguments),Object.defineProperty(this,"messageContainerRef",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"widgetRuntime",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"projectName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"enableVoice",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isAtBottom",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"isAtTop",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"messages",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"isStreaming",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"isListening",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"isSpeaking",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"randomQuestions",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"currentQuestionIndex",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"hasScrollableContent",{enumerable:!0,configurable:!0,writable:!0,value:!1})}get isEmpty(){return this.messages.length===0}checkScrollableContent(){const e=this.messageContainerRef;e?this.hasScrollableContent=e.scrollHeight>e.clientHeight:this.hasScrollableContent=!1}get questionIndices(){return this.messages.map((e,n)=>({message:e,index:n})).filter(({message:e})=>e.role==="user").map(({index:e})=>e)}onIsStreamingChange(e){this.isStreaming=e}onMessagesChange(e){e&&(this.messages=e),this.$nextTick(()=>{this.checkScrollableContent(),(this.isAtBottom||this.isStreaming)&&this.scrollToBottom()})}onThreadChange(){this.isAtBottom=!0,this.currentQuestionIndex=null,this.$nextTick(()=>{this.scrollToBottom()})}onRandomQuestionsChange(e){e&&(this.randomQuestions=e)}mounted(){this.randomQuestions=this.widgetRuntime.randomQuestions||[],this.$nextTick(()=>{this.checkScrollableContent(),this.scrollToBottom()})}render(){const e=arguments[0];return e("div",{class:"ct-thread"},[e("div",{class:"ct-message-area"},[e("div",{class:"ct-message-container",ref:"messageContainer",on:{scroll:this.handleScroll}},[this.isEmpty?this.renderEmptyState():this.renderMessages()]),!this.isEmpty&&this.renderScrollButton()]),e($1,{attrs:{projectName:this.projectName,isStreaming:this.isStreaming,hasMessages:!this.isEmpty,enableVoice:this.enableVoice,isListening:this.isListening},on:{send:this.handleSendMessage,stop:this.handleStopRun,clear:this.handleClear,voice:this.handleVoice}})])}renderEmptyState(){const e=this.$createElement;return e("div",{class:"ct-empty-state"},[e("div",{class:"ct-intro-header"},[e("div",{class:"ct-intro-icon-wrapper"},[e(j,{class:"ct-intro-icon",attrs:{type:j.Type.ASK_AI_BLUE,size:52}})]),e("div",{class:"ct-intro-heading"},["What do you want to ask?"])]),this.$slots.suggestions||e("div",{class:"ct-intro-queries"},[e("span",{class:"ct-intro-queries-label"},["Example queries"]),e("div",{class:"ct-intro-queries-list"},[this.randomQuestions.map(n=>e(Kt,{key:n,attrs:{question:n},on:{select:this.handleQueryPillSelect}}))])])])}renderMessages(){const e=this.$createElement;return e("div",{class:"ct-message-list"},[this.messages.map((n,r)=>e("div",{key:`${n.id}-${r}`,class:"ct-message-wrapper",ref:`message-${r}`,attrs:{"data-message-index":r,"data-is-question":n.role==="user"}},[e(Se,{attrs:{message:n,enableVoice:this.enableVoice,isSpeaking:this.isSpeaking},on:{copy:this.handleCopy,speak:this.handleSpeak,feedback:this.handleFeedback,linkClick:this.handleLinkClick}})]))])}renderScrollButton(){const e=this.$createElement;if(!this.hasScrollableContent)return null;const n=this.questionIndices,r=this.isAtTop&&n.length>0&&n[0]===0,i=this.currentQuestionIndex!==null&&n.length>0&&this.currentQuestionIndex===n[0];return this.isAtBottom?e("button",{class:"ct-scroll-button",on:{click:this.scrollToMostRecentQuestion},attrs:{"aria-label":"Scroll to most recent question"}},[e(j,{attrs:{type:j.Type.ARROW_UP,size:16}})]):r||i?e("button",{class:"ct-scroll-button",on:{click:this.scrollToBottom},attrs:{"aria-label":"Scroll to bottom"}},[e(j,{attrs:{type:j.Type.ARROW_DOWN,size:16}})]):this.currentQuestionIndex!==null?e("button",{class:"ct-scroll-button",on:{click:this.scrollToMostRecentQuestion},attrs:{"aria-label":"Scroll to previous question"}},[e(j,{attrs:{type:j.Type.ARROW_UP,size:16}})]):e("button",{class:"ct-scroll-button",on:{click:this.scrollToBottom},attrs:{"aria-label":"Scroll to bottom"}},[e(j,{attrs:{type:j.Type.ARROW_DOWN,size:16}})])}handleScroll(){const e=this.messageContainerRef;if(e){const{scrollTop:n,scrollHeight:r,clientHeight:i}=e;this.isAtTop=n0)r=n[i-1];else{this.scrollToTop(),this.currentQuestionIndex=null;return}}r!==null&&this.$nextTick(()=>{const i=e.querySelectorAll("[data-message-index]"),o=Array.from(i).find(s=>Number(s.dataset.messageIndex)===r);if(o){const s=o.offsetTop,a=parseInt(getComputedStyle(e).paddingTop,10)||0;e.scrollTo({top:s-a,behavior:"smooth"}),this.currentQuestionIndex=r,this.$nextTick(()=>{this.checkScrollableContent(),this.handleScroll()})}else this.scrollToTop(),this.currentQuestionIndex=null})}scrollToTop(){const e=this.messageContainerRef;e&&(e.scrollTo({top:0,behavior:"smooth"}),this.isAtTop=!0,this.currentQuestionIndex=null,this.$nextTick(()=>{this.checkScrollableContent(),this.isAtBottom=!this.hasScrollableContent}))}scrollToBottom(){const e=this.messageContainerRef;e&&(e.scrollTo({top:e.scrollHeight,behavior:"smooth"}),this.isAtBottom=!0,this.currentQuestionIndex=null,this.$nextTick(()=>{this.checkScrollableContent(),this.isAtTop=!this.hasScrollableContent}))}async handleSendMessage(e){await this.widgetRuntime.sendMessage(this.widgetRuntime.currentThreadId,e)}handleStopRun(){this.widgetRuntime.cancelStreaming?.()}handleClear(){this.widgetRuntime.clearThreadMessages?.(this.widgetRuntime.currentThreadId)}handleVoice(){this.widgetRuntime.startListening?.()}handleCopy(){this.$emit(o2.Event.COPY)}handleSpeak(e){this.widgetRuntime.speak?.(e)}handleFeedback(e,n,r){this.widgetRuntime.handleFeedback?.(e,n,r)}handleLinkClick(e,n){this.widgetRuntime.handleLinkClick?.(e,n)}handleQueryPillSelect(e){this.handleSendMessage(e)}setVoiceState(e,n){e==="listening"?this.isListening=n:e==="speaking"&&(this.isSpeaking=n)}};Object.defineProperty(Y1,"SCROLL_THRESHOLD",{enumerable:!0,configurable:!0,writable:!0,value:100}),v([hn("messageContainer"),f("design:type",typeof(d8=typeof HTMLDivElement<"u"&&HTMLDivElement)=="function"?d8:Object)],Y1.prototype,"messageContainerRef",void 0),v([r6("widgetRuntime"),f("design:type",Object)],Y1.prototype,"widgetRuntime",void 0),v([y({type:String,required:!0}),f("design:type",String)],Y1.prototype,"projectName",void 0),v([y({type:Boolean,default:!1}),f("design:type",Boolean)],Y1.prototype,"enableVoice",void 0),v([ge("widgetRuntime.isCurrentThreadStreaming",{immediate:!0,deep:!0}),f("design:type",Function),f("design:paramtypes",[Boolean]),f("design:returntype",void 0)],Y1.prototype,"onIsStreamingChange",null),v([ge("widgetRuntime.currentMessages",{immediate:!0,deep:!0}),f("design:type",Function),f("design:paramtypes",[typeof(C8=typeof Array<"u"&&Array)=="function"?C8:Object]),f("design:returntype",void 0)],Y1.prototype,"onMessagesChange",null),v([ge("widgetRuntime.currentThreadId",{immediate:!0,deep:!0}),f("design:type",Function),f("design:paramtypes",[]),f("design:returntype",void 0)],Y1.prototype,"onThreadChange",null),v([ge("widgetRuntime.randomQuestions",{immediate:!0}),f("design:type",Function),f("design:paramtypes",[typeof(p8=typeof Array<"u"&&Array)=="function"?p8:Object]),f("design:returntype",void 0)],Y1.prototype,"onRandomQuestionsChange",null),Y1=o2=v([Z1({name:"ChatThread",components:{ChatMessage:Se,ChatComposer:$1,QueryPill:Kt}})],Y1),function(t){(function(e){e.COPY="copy",e.MESSAGE_CLICK="message-click"})(t.Event||(t.Event={}))}(Y1||(Y1={}));let Mt=class extends l1{constructor(){super(...arguments),Object.defineProperty(this,"height",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"width",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"runtime",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}get widgetRuntime(){return this.runtime}render(){const e=arguments[0];return e("div",{class:"ct-runtime-container",style:{height:this.height,width:this.width}},[this.$slots.header,e("div",{class:"ct-runtime-body"},[this.$slots.default])])}};v([y({default:"100%"}),f("design:type",String)],Mt.prototype,"height",void 0),v([y({default:"100%"}),f("design:type",String)],Mt.prototype,"width",void 0),v([y({required:!0}),f("design:type",Object)],Mt.prototype,"runtime",void 0),v([us("widgetRuntime"),f("design:type",Object),f("design:paramtypes",[])],Mt.prototype,"widgetRuntime",null),Mt=v([Z1({name:"ChatRuntimeProvider"})],Mt);var qt,st;(function(t){t.SUCCESS="success",t.WARNING="warning",t.DANGER="danger",t.INFO="info"})(st||(st={}));let le=qt=class extends l1{render(){const e=arguments[0],{className:n,iconType:r}=qt.TYPE_METADATA[this.type];return e("div",{class:j1(`lp-info-panel ${n}`,{inline:this.inline,emphasize:this.emphasize})},[this.title&&e("div",{class:"flex-row"},[e(j,{class:"lp-info-panel-icon",attrs:{size:qt.ICON_SIZE,type:r}}),e("div",{class:"flex-column"},[e("p",{class:"lp-info-panel__title"},[this.title]),this.renderMessage(),this.$slots.default])]),!this.title&&e("div",{class:j1(`flex-row ${this.contentPosition||""}`)},[e(j,{class:"lp-info-panel-icon",attrs:{size:qt.ICON_SIZE,type:r}}),this.renderMessage(),this.$slots.default,this.renderCloseIcon()])])}renderMessage(){const e=this.$createElement;return e("div",[this.text&&e("p",{class:j1("lp-info-panel-text")},[this.text])])}renderCloseIcon(){const e=this.$createElement;return this.showClose?e("span",{class:"flex-row-left"},[e(j,{class:"lp-info-panel-close-icon",attrs:{type:j.Type.CLOSE,size:this.isToast?qt.ICON_SIZE:20},on:{click:this.onClose}})]):null}onClose(){this.$emit(qt.EVENT_CLOSE)}};le.ICON_SIZE=16,le.TYPE_METADATA={[st.SUCCESS]:{className:"lp-success",iconType:j.Type.CHECK_MEDIUM},[st.WARNING]:{className:"lp-warning",iconType:j.Type.EXCLAMATION_MEDIUM},[st.DANGER]:{className:"lp-danger",iconType:j.Type.EXCLAMATION_MEDIUM},[st.INFO]:{className:"lp-info",iconType:j.Type.EXCLAMATION_MEDIUM}},v([y({type:String,required:!1,default:null}),f("design:type",Object)],le.prototype,"title",void 0),v([y({type:String,default:"",required:!1}),f("design:type",String)],le.prototype,"text",void 0),v([y({type:Boolean,default:!1,required:!1}),f("design:type",Boolean)],le.prototype,"inline",void 0),v([y({type:Boolean,default:!0,required:!1}),f("design:type",Boolean)],le.prototype,"emphasize",void 0),v([y({type:Boolean,default:!1,required:!1}),f("design:type",Boolean)],le.prototype,"showClose",void 0),v([y({type:Boolean,default:!1,required:!1}),f("design:type",Boolean)],le.prototype,"isToast",void 0),v([y({type:String,default:"",required:!1}),f("design:type",String)],le.prototype,"contentPosition",void 0),v([y({type:String,default:st.SUCCESS,validator:t=>ye(st).indexOf(t)!==-1}),f("design:type",String)],le.prototype,"type",void 0),le=qt=v([Z1({name:"InfoPanel"})],le),function(t){t.EVENT_CLOSE="close",t.Type=st,function(e){e.RIGHT="right",e.BOTTOM="bottom"}(t.ContentPosition||(t.ContentPosition={}))}(le||(le={}));var L5;let N1=L5=class extends l1{constructor(){super(...arguments),this.hasScrolled=!1,this.hasScrolledToEnd=!0}static get hasOpenedModals(){return nt.openedInstances.filter(e=>e.$parent instanceof L5).length>0}mounted(){document.documentElement&&document.documentElement.classList.add("modal-open")}beforeDestroy(){document.documentElement&&document.documentElement.classList.remove("modal-open")}render(){const e=arguments[0];return e(nt,{on:{bodyKeyDown:this.onBodyKeyDown}},[e("transition",{attrs:{appear:!0},on:{appear:this.computeScrollState}},[e("div",{attrs:{"data-testid":this.dataTestId},class:j1("lp-modal",this.className,{"full-screen":this.fullScreen,"transparent-bg":this.noFade,"not-like-modal":this.allowBackgroundInteraction},this.position),on:{click:this.onOverlayClick}},[e("div",{class:j1("wrapper",{"not-like-modal":this.allowBackgroundInteraction})},[this.simple?this.$slots.default:this.renderContent()])])])])}renderContent(){const e=this.$createElement;return e("div",{attrs:{"data-testid":`${this.dataTestId}-content`},class:j1("content",this.spinnerClass),style:this.sizingStyles,on:{click:Wu,scroll:this.computeScrollState},ref:"content"},[this.hasHeader&&e("div",{class:j1("header",{scrolled:this.hasScrolled})},[e("div",{class:"header-container"},[e("div",{class:j1("title",{big:this.bigTitle})},[this.title]),e("div",{class:"header-slot-container"},[this.$slots.header])]),this.closeButton&&e(j,{class:"cross",attrs:{size:32,type:j.Type.CLEAR},on:{click:this.onClickCross}})]),e("div",{class:"body"},[this.$slots.default]),this.hasSpinner&&e("div",{class:"spinner-container",attrs:{"data-testid":"modal-spinner"}},[e("div",{class:"spinner"})]),this.hasFooter()?e("div",{class:j1("footer",{scrolled:!this.hasScrolledToEnd})},[this.$slots.footer]):e("div",{class:"footer-accommodation"})])}get hasHeader(){return this.closeButton||!!this.title}hasFooter(){return!u5(this.$slots.footer)}get sizingStyles(){const e={minWidth:this.width,width:this.width};return this.minHeight!==null&&(e.minHeight=this.minHeight),e}get hasSpinner(){return this.hasOverlaySpinner||this.hasContentReplacingSpinner}get spinnerClass(){return j1({"overlay-spinner":this.hasOverlaySpinner,"content-replacing-spinner":this.hasContentReplacingSpinner})}get hasOverlaySpinner(){return this.spinner===L5.Spinner.OVERLAY}get hasContentReplacingSpinner(){return this.spinner===L5.Spinner.REPLACE_CONTENT}onOverlayClick(){this.fadeClose&&this.emitClose()}onClickCross(){this.closeButton&&this.emitClose()}onBodyKeyDown(e){this.escClose&&e.key===U5.ESC_KEY&&(e.stopImmediatePropagation(),this.emitClose())}emitClose(){this.hasSpinner||this.$emit(L5.EVENT_CLOSE)}computeScrollState(){const e=this.$refs.content;e&&(this.hasScrolled=e.scrollTop>0,this.hasScrolledToEnd=e.scrollTop+e.clientHeight===e.scrollHeight)}};N1.SLOT_HEADER="header",N1.SLOT_FOOTER="footer",v([y({type:Boolean,required:!1,default:!1}),f("design:type",Boolean)],N1.prototype,"simple",void 0),v([y({type:String,required:!1,default:null}),f("design:type",Object)],N1.prototype,"title",void 0),v([y({type:String,required:!1,default:"480px"}),f("design:type",String)],N1.prototype,"width",void 0),v([y({type:String,required:!1,default:""}),f("design:type",String)],N1.prototype,"className",void 0),v([y({type:String,required:!1,default:"120px"}),f("design:type",String)],N1.prototype,"minHeight",void 0),v([y({type:Boolean,required:!1,default:!0}),f("design:type",Boolean)],N1.prototype,"fadeClose",void 0),v([y({type:Boolean,required:!1,default:!1}),f("design:type",Boolean)],N1.prototype,"escClose",void 0),v([y({type:Boolean,required:!1,default:!1}),f("design:type",Boolean)],N1.prototype,"closeButton",void 0),v([y({type:String,required:!1,default:"hidden"}),f("design:type",String)],N1.prototype,"spinner",void 0),v([y({type:Boolean,required:!1,default:!1}),f("design:type",Boolean)],N1.prototype,"fullScreen",void 0),v([y({type:Boolean,required:!1,default:!1}),f("design:type",Boolean)],N1.prototype,"bigTitle",void 0),v([y({type:Boolean,required:!1,default:!1}),f("design:type",Boolean)],N1.prototype,"noFade",void 0),v([y({type:String,required:!1,default:()=>N1.Position.AUTO}),f("design:type",String)],N1.prototype,"position",void 0),v([y({type:Boolean,default:!1}),f("design:type",Boolean)],N1.prototype,"allowBackgroundInteraction",void 0),v([y({type:String,default:"modal"}),f("design:type",String)],N1.prototype,"dataTestId",void 0),v([zu(100),f("design:type",Function),f("design:paramtypes",[]),f("design:returntype",void 0)],N1.prototype,"computeScrollState",null),N1=L5=v([Z1({name:"Modal"})],N1),function(t){t.EVENT_CLOSE="close",function(e){e.HIDDEN="hidden",e.OVERLAY="overlay",e.REPLACE_CONTENT="replace-content"}(t.Spinner||(t.Spinner={})),function(e){e.AUTO="auto",e.TOP="top",e.BOTTOM="bottom"}(t.Position||(t.Position={}))}(N1||(N1={}));var s7,s2;(function(t){t.SUCCESS="success",t.WARNING="warning",t.DANGER="danger",t.INFO="info"})(s2||(s2={}));let X1=s7=class extends l1{created(){(!this.showClose||this.hasTimeoutAndClose)&&(this.timeoutInternal=window.setTimeout(this.close,this.timeout))}beforeDestroy(){clearTimeout(this.timeoutInternal)}render(){const e=arguments[0];return e(N1,{attrs:{simple:!0,alignTop:!0,escClose:!0,noFade:!0,fadeClose:this.fadeClose,position:this.position,className:this.className},on:{close:this.close}},[e(le,{class:"lp-toast",attrs:{type:this.type,text:this.text,showClose:this.showClose,isToast:!0},on:{close:this.handleInfoClose}},[this.$slots.default])])}close(){this.$emit(s7.EVENT_CLOSE)}handleInfoClose(){this.close()}};v([y({type:String,required:!1,default:""}),f("design:type",String)],X1.prototype,"text",void 0),v([y({type:String,required:!1,default:s2.SUCCESS,validator:t=>ye(s2).indexOf(t)!==-1}),f("design:type",String)],X1.prototype,"type",void 0),v([y({type:Boolean,required:!1,default:!1}),f("design:type",Boolean)],X1.prototype,"showClose",void 0),v([y({type:String,required:!1,default:()=>X1.Position.TOP}),f("design:type",String)],X1.prototype,"position",void 0),v([y({type:String,default:""}),f("design:type",String)],X1.prototype,"className",void 0),v([y({type:Number,default:()=>X1.ToastOpenedTimeout}),f("design:type",Number)],X1.prototype,"timeout",void 0),v([y({type:Boolean,default:!0}),f("design:type",Boolean)],X1.prototype,"fadeClose",void 0),v([y({type:Boolean,default:!1}),f("design:type",Boolean)],X1.prototype,"hasTimeoutAndClose",void 0),X1=s7=v([Z1({name:"Toast"})],X1),function(t){t.EVENT_CLOSE="close",t.Type=s2,t.ToastOpenedTimeout=5e3,function(e){e.AUTO="auto",e.TOP="top",e.BOTTOM="bottom"}(t.Position||(t.Position={}))}(X1||(X1={}));let p3=class extends l1{render(){const e=arguments[0];return e(C0,{class:"lp-portal-target",attrs:{name:this.name||W2.TARGET_A,multiple:!0}})}};v([y({type:String,required:!1,default:""}),f("design:type",String)],p3.prototype,"name",void 0),p3=v([Z1({name:"StargateTarget"})],p3);var Yt;let De=Yt=class extends l1{constructor(){super(...arguments),Object.defineProperty(this,"title",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"windowState",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"allowMinimize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"allowMaximize",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}render(){const e=arguments[0];return e("div",{class:"ct-widget-header",on:{click:this.handleHeaderClick}},[e("div",{class:"ct-header-logo"},[e(q1,{class:"ct-logo-button",attrs:{iconSize:20,icon:j.Type.ASK_AI,appearance:K.Appearance.LIGHTEN,color:K.Color.PRIMARY}})]),e("div",{class:"ct-header-title"},[this.title]),e("div",{class:"ct-window-controls"},[this.allowMaximize&&this.renderMaximizeButton(),this.renderCloseButton()])])}renderMaximizeButton(){const e=this.$createElement;return e(j,{class:"ct-win-btn ct-maximize-btn",attrs:{type:this.windowState==="maximized"?j.Type.MINIMIZE:j.Type.MAXIMIZE,size:Yt.MAXIMIZE_ICON_SIZE,clickable:!0,stopPropagation:!0},on:{click:this.handleMaximize}})}renderCloseButton(){const e=this.$createElement;return e(j,{class:"ct-win-btn ct-close-btn",attrs:{clickable:!0,stopPropagation:!0,type:j.Type.CLOSE,size:Yt.CLOSE_ICON_SIZE},on:{click:this.handleClose}})}handleHeaderClick(){this.$emit(Yt.Event.HEADER_CLICK)}handleMaximize(){this.$emit(Yt.Event.MAXIMIZE)}handleClose(){this.$emit(Yt.Event.CLOSE)}};Object.defineProperty(De,"CLOSE_ICON_SIZE",{enumerable:!0,configurable:!0,writable:!0,value:20}),Object.defineProperty(De,"MAXIMIZE_ICON_SIZE",{enumerable:!0,configurable:!0,writable:!0,value:14}),v([y({type:String,required:!0}),f("design:type",String)],De.prototype,"title",void 0),v([y({type:String,default:"normal"}),f("design:type",Object)],De.prototype,"windowState",void 0),v([y({type:Boolean,default:!0}),f("design:type",Boolean)],De.prototype,"allowMinimize",void 0),v([y({type:Boolean,default:!0}),f("design:type",Boolean)],De.prototype,"allowMaximize",void 0),De=Yt=v([Z1({name:"WidgetHeader"})],De),function(t){(function(e){e.MINIMIZE="minimize",e.MAXIMIZE="maximize",e.CLOSE="close",e.HEADER_CLICK="headerClick"})(t.Event||(t.Event={}))}(De||(De={}));var f8;F1.Widget=class extends l1{constructor(){super(...arguments),Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"debug",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"chatThreadRef",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"widgetRuntime",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"isOpen",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"windowState",{enumerable:!0,configurable:!0,writable:!0,value:"normal"}),Object.defineProperty(this,"isInitializing",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"initializationError",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"toastMessage",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"showToast",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"scrollPosition",{enumerable:!0,configurable:!0,writable:!0,value:0})}get runtime(){return this.widgetRuntime}get positionClass(){return`ct-pos-${this.config.position}`}logDebug(e,n,r="log"){(this.debug||r==="error"||r==="warn")&&console[r](`[Widget] ${e}`,n!==void 0?n:"")}async created(){try{if(this.logDebug("Initializing Widget"),this.widgetRuntime=new m_(this.config),this.setupRuntimeCallbacks(),!await this.widgetRuntime.initialize())throw new Error("Failed to initialize widget runtime");this.isInitializing=!1,this.logDebug("Widget initialized successfully")}catch(e){this.isInitializing=!1,this.initializationError=`Error initializing widget: ${e.message||"Unknown error"}`,this.logDebug("Failed to initialize Widget:",e,"error")}}mounted(){document.documentElement.style.setProperty("--ct-primary",this.config.color),document.documentElement.style.setProperty("--ct-primary-hover",this.config.colorHover),document.addEventListener("keydown",this.handleKeyDown)}beforeDestroy(){document.removeEventListener("keydown",this.handleKeyDown),this.isOpen&&this.unlockBodyScroll(),this.widgetRuntime?.destroy?.()}render(){const e=arguments[0];return e("div",{class:"ct-widget-container"},[this.renderLauncher(),this.renderModal(),this.renderToast(),e(p3)])}renderLauncher(){const e=this.$createElement;return e(K,{attrs:{id:"ct-launcher",text:"Ask",iconSize:20,prefixIcon:j.Type.ASK_AI,appearance:K.Appearance.LIGHTEN,color:K.Color.PRIMARY},class:"ct-widget-launcher",on:{click:this.open}})}renderModal(){const e=this.$createElement,n=["ct-widget-root",this.positionClass,{"ct-visible":this.isOpen,"ct-maximized":this.windowState==="maximized","ct-minimized":this.windowState==="minimized"}];return e("div",{class:n,attrs:{"aria-hidden":this.isOpen?"false":"true"}},[e("div",{class:"ct-widget-overlay",on:{click:this.handleOverlayClick}}),e("div",{class:"ct-widget-modal"},[this.renderModalContent()])])}renderModalContent(){return this.isInitializing?this.renderLoadingState():this.initializationError?this.renderErrorState():this.renderChatInterface()}renderLoadingState(){const e=this.$createElement;return e("div",{class:"ct-widget-loading"},[e(j,{attrs:{type:j.Type.ASK_AI,size:40}}),e("span",{class:"ct-loading-text"},["Initializing..."])])}renderErrorState(){const e=this.$createElement;return e("div",{class:"ct-widget-error"},[e(j,{attrs:{type:j.Type.ALERT,size:40}}),e("span",{class:"ct-error-text"},[this.initializationError]),e(K,{attrs:{text:"Retry",appearance:K.Appearance.OUTLINE,color:K.Color.PRIMARY},on:{click:this.retryInitialization}})])}renderChatInterface(){const e=this.$createElement;return this.widgetRuntime?e(Mt,{attrs:{runtime:this.widgetRuntime,height:"100%",width:"100%"}},[e("template",{slot:"header"},[e(De,{attrs:{title:this.config.name,windowState:this.windowState,allowMinimize:this.config.allowMinimize,allowMaximize:this.config.allowMaximize},on:{minimize:this.minimize,maximize:this.maximize,close:this.close,headerClick:this.handleHeaderClick}})]),e("div",{class:"ct-chat-interface"},[e(Y1,{ref:"chatThread",attrs:{projectName:this.config.name,enableVoice:this.config.enableVoice},on:{copy:this.handleCopy}})])]):this.renderLoadingState()}renderToast(){const e=this.$createElement;return this.showToast?e(X1,{attrs:{text:this.toastMessage,type:X1.Type.DANGER,position:X1.Position.TOP,showClose:!0},on:{close:this.handleToastClose}}):null}onRuntimeChange(){this.widgetRuntime&&this.setupRuntimeCallbacks()}handleKeyDown(e){e.key==="Escape"&&this.isOpen&&this.close()}open(){if(this.isOpen)return;this.isOpen=!0,He.widgetOpened(),this.lockBodyScroll()}close(){if(!this.isOpen)return;this.isOpen=!1,He.widgetClosed(),this.windowState="normal",this.unlockBodyScroll(),this.widgetRuntime?.stopListening?.(),this.widgetRuntime?.stopSpeaking?.()}lockBodyScroll(){this.scrollPosition=window.pageYOffset||document.documentElement.scrollTop,document.body.classList.add("ct-widget-open"),document.body.style.top=`-${this.scrollPosition}px`}unlockBodyScroll(){document.body.classList.remove("ct-widget-open"),document.body.style.top="",window.scrollTo(0,this.scrollPosition)}minimize(){this.windowState=this.windowState==="minimized"?"normal":"minimized"}maximize(){this.windowState=this.windowState==="maximized"?"normal":"maximized"}restore(){this.windowState="normal"}async retryInitialization(){this.isInitializing=!0,this.initializationError=null;try{if(this.widgetRuntime&&!await this.widgetRuntime.initialize())throw new Error("Failed to initialize widget runtime");this.isInitializing=!1}catch(e){this.isInitializing=!1,this.initializationError=`Error initializing widget: ${e.message||"Unknown error"}`}}handleCopy(){this.logDebug("Copy action triggered")}handleOverlayClick(){this.close()}handleHeaderClick(){this.windowState==="minimized"&&this.restore()}displayToast(e){this.toastMessage=e,this.showToast=!0}handleToastClose(){this.showToast=!1,this.toastMessage=""}setupRuntimeCallbacks(){this.widgetRuntime&&(this.widgetRuntime.setOnStateChange(e=>{this.logDebug("Runtime state changed:",e),this.$forceUpdate()}),this.widgetRuntime.setOnVoiceState((e,n)=>{this.chatThreadRef?.setVoiceState(e,n)}),this.widgetRuntime.setOnError(e=>{this.logDebug("Runtime error:",e,"error"),this.displayToast(e)}),this.widgetRuntime.setOnStreaming(e=>{this.logDebug("Streaming event:",e)}))}},v([y({type:Object,required:!0}),f("design:type",Object)],F1.Widget.prototype,"config",void 0),v([y({type:Boolean,default:!1}),f("design:type",Boolean)],F1.Widget.prototype,"debug",void 0),v([hn("chatThread"),f("design:type",typeof(f8=typeof Y1<"u"&&Y1)=="function"?f8:Object)],F1.Widget.prototype,"chatThreadRef",void 0),v([ds("widgetRuntime"),f("design:type",Object),f("design:paramtypes",[])],F1.Widget.prototype,"runtime",null),v([ge("widgetRuntime",{immediate:!0}),f("design:type",Function),f("design:paramtypes",[]),f("design:returntype",void 0)],F1.Widget.prototype,"onRuntimeChange",null),F1.Widget=v([Z1({name:"Widget",components:{ChatThread:Y1,ChatRuntimeProvider:Mt,WidgetHeader:De}})],F1.Widget);function h8(){try{const t=new Fn,e=document.createElement("div");e.id="ask-ai-root",document.body.appendChild(e),new l1({render:n=>n(F1.Widget,{props:{config:t}})}).$mount("#ask-ai-root")}catch{}}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",h8):h8(),window.AskAIWidget={Widget:F1.Widget,WidgetConfig:Fn},F1.WidgetConfig=Fn,Object.defineProperty(F1,Symbol.toStringTag,{value:"Module"}),F1}({});