@copilotkit/vue 1.62.0 → 1.62.2-canary.1783457132

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.
Files changed (53) hide show
  1. package/PARITY.md +7 -7
  2. package/dist/index-By5nIKxT.js +1632 -0
  3. package/dist/index-By5nIKxT.js.map +1 -0
  4. package/dist/index-LFxZI63k.cjs +748 -0
  5. package/dist/index-LFxZI63k.cjs.map +1 -0
  6. package/dist/index.cjs +1 -1
  7. package/dist/index.mjs +70 -69
  8. package/dist/styles.css +1 -1
  9. package/dist/{use-render-activity-message-Bzh3Bckz.js → use-render-activity-message-DbGuwvBd.js} +3363 -3064
  10. package/dist/use-render-activity-message-DbGuwvBd.js.map +1 -0
  11. package/dist/use-render-activity-message-hlNcbV9l.cjs +85 -0
  12. package/dist/use-render-activity-message-hlNcbV9l.cjs.map +1 -0
  13. package/dist/v2/components/chat/CopilotChat.vue.d.ts.map +1 -1
  14. package/dist/v2/components/chat/CopilotModalHeader.vue.d.ts.map +1 -1
  15. package/dist/v2/components/chat/CopilotThreadsDrawer.vue.d.ts +42 -0
  16. package/dist/v2/components/chat/CopilotThreadsDrawer.vue.d.ts.map +1 -0
  17. package/dist/v2/components/chat/index.d.ts +1 -0
  18. package/dist/v2/components/chat/index.d.ts.map +1 -1
  19. package/dist/v2/components/icons/index.d.ts +1 -1
  20. package/dist/v2/components/icons/index.d.ts.map +1 -1
  21. package/dist/v2/hooks/use-agent.d.ts.map +1 -1
  22. package/dist/v2/hooks/use-threads.d.ts +12 -0
  23. package/dist/v2/hooks/use-threads.d.ts.map +1 -1
  24. package/dist/v2/index.cjs +1 -1
  25. package/dist/v2/index.mjs +44 -43
  26. package/dist/v2/lib/is-mobile-viewport.d.ts +15 -0
  27. package/dist/v2/lib/is-mobile-viewport.d.ts.map +1 -0
  28. package/dist/v2/providers/CopilotChatConfigurationProvider.vue.d.ts.map +1 -1
  29. package/dist/v2/providers/types.d.ts +24 -0
  30. package/dist/v2/providers/types.d.ts.map +1 -1
  31. package/package.json +7 -6
  32. package/src/v2/components/chat/CopilotChat.vue +22 -4
  33. package/src/v2/components/chat/CopilotModalHeader.vue +61 -2
  34. package/src/v2/components/chat/CopilotThreadsDrawer.vue +285 -0
  35. package/src/v2/components/chat/__tests__/CopilotChat.clearOnFresh.test.ts +160 -0
  36. package/src/v2/components/chat/__tests__/CopilotModalHeader.drawerLauncher.test.ts +125 -0
  37. package/src/v2/components/chat/__tests__/CopilotThreadsDrawer.ssr.test.ts +25 -0
  38. package/src/v2/components/chat/__tests__/CopilotThreadsDrawer.test.ts +835 -0
  39. package/src/v2/components/chat/index.ts +1 -0
  40. package/src/v2/components/icons/index.ts +1 -0
  41. package/src/v2/hooks/__tests__/use-agent.test.ts +60 -1
  42. package/src/v2/hooks/__tests__/use-human-in-the-loop.e2e.test.ts +4 -4
  43. package/src/v2/hooks/__tests__/use-threads.test.ts +303 -6
  44. package/src/v2/hooks/use-agent.ts +4 -1
  45. package/src/v2/hooks/use-threads.ts +137 -8
  46. package/src/v2/lib/__tests__/is-mobile-viewport.test.ts +48 -0
  47. package/src/v2/lib/is-mobile-viewport.ts +23 -0
  48. package/src/v2/providers/CopilotChatConfigurationProvider.vue +120 -4
  49. package/src/v2/providers/__tests__/CopilotChatConfigurationProvider.test.ts +105 -1
  50. package/src/v2/providers/types.ts +25 -0
  51. package/dist/use-render-activity-message-Bzh3Bckz.js.map +0 -1
  52. package/dist/use-render-activity-message-CW3vipBB.cjs +0 -85
  53. package/dist/use-render-activity-message-CW3vipBB.cjs.map +0 -1
@@ -0,0 +1,748 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const fe={bg:"oklch(1 0 0)",fg:"oklch(0.145 0 0)",surface:"oklch(1 0 0)","surface-fg":"oklch(0.145 0 0)",muted:"oklch(0.97 0 0)","muted-fg":"oklch(0.556 0 0)",accent:"oklch(0.97 0 0)","accent-fg":"oklch(0.205 0 0)",primary:"oklch(0.205 0 0)","primary-fg":"oklch(0.985 0 0)",danger:"oklch(0.577 0.245 27.325)",border:"oklch(0.922 0 0)",ring:"oklch(0.708 0 0)",radius:"0.625rem"};const I=globalThis,Q=I.ShadowRoot&&(I.ShadyCSS===void 0||I.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Y=Symbol(),ee=new WeakMap;let me=class{constructor(e,t,r){if(this._$cssResult$=!0,r!==Y)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(Q&&e===void 0){const r=t!==void 0&&t.length===1;r&&(e=ee.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&ee.set(t,e))}return e}toString(){return this.cssText}};const _e=s=>new me(typeof s=="string"?s:s+"",void 0,Y),Se=(s,...e)=>{const t=s.length===1?s[0]:e.reduce((r,i,o)=>r+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+s[o+1],s[0]);return new me(t,s,Y)},Me=(s,e)=>{if(Q)s.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const t of e){const r=document.createElement("style"),i=I.litNonce;i!==void 0&&r.setAttribute("nonce",i),r.textContent=t.cssText,s.appendChild(r)}},te=Q?s=>s:s=>s instanceof CSSStyleSheet?(e=>{let t="";for(const r of e.cssRules)t+=r.cssText;return _e(t)})(s):s;const{is:Ce,defineProperty:Te,getOwnPropertyDescriptor:Ne,getOwnPropertyNames:Oe,getOwnPropertySymbols:Pe,getPrototypeOf:Re}=Object,H=globalThis,re=H.trustedTypes,De=re?re.emptyScript:"",Ue=H.reactiveElementPolyfillSupport,O=(s,e)=>s,q={toAttribute(s,e){switch(e){case Boolean:s=s?De:null;break;case Object:case Array:s=s==null?s:JSON.stringify(s)}return s},fromAttribute(s,e){let t=s;switch(e){case Boolean:t=s!==null;break;case Number:t=s===null?null:Number(s);break;case Object:case Array:try{t=JSON.parse(s)}catch{t=null}}return t}},ge=(s,e)=>!Ce(s,e),ie={attribute:!0,type:String,converter:q,reflect:!1,useDefault:!1,hasChanged:ge};Symbol.metadata??=Symbol("metadata"),H.litPropertyMetadata??=new WeakMap;let S=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=ie){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){const r=Symbol(),i=this.getPropertyDescriptor(e,r,t);i!==void 0&&Te(this.prototype,e,i)}}static getPropertyDescriptor(e,t,r){const{get:i,set:o}=Ne(this.prototype,e)??{get(){return this[t]},set(n){this[t]=n}};return{get:i,set(n){const d=i?.call(this);o?.call(this,n),this.requestUpdate(e,d,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??ie}static _$Ei(){if(this.hasOwnProperty(O("elementProperties")))return;const e=Re(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(O("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(O("properties"))){const t=this.properties,r=[...Oe(t),...Pe(t)];for(const i of r)this.createProperty(i,t[i])}const e=this[Symbol.metadata];if(e!==null){const t=litPropertyMetadata.get(e);if(t!==void 0)for(const[r,i]of t)this.elementProperties.set(r,i)}this._$Eh=new Map;for(const[t,r]of this.elementProperties){const i=this._$Eu(t,r);i!==void 0&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const r=new Set(e.flat(1/0).reverse());for(const i of r)t.unshift(te(i))}else e!==void 0&&t.push(te(e));return t}static _$Eu(e,t){const r=t.attribute;return r===!1?void 0:typeof r=="string"?r: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(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const r of t.keys())this.hasOwnProperty(r)&&(e.set(r,this[r]),delete this[r]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Me(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,r){this._$AK(e,r)}_$ET(e,t){const r=this.constructor.elementProperties.get(e),i=this.constructor._$Eu(e,r);if(i!==void 0&&r.reflect===!0){const o=(r.converter?.toAttribute!==void 0?r.converter:q).toAttribute(t,r.type);this._$Em=e,o==null?this.removeAttribute(i):this.setAttribute(i,o),this._$Em=null}}_$AK(e,t){const r=this.constructor,i=r._$Eh.get(e);if(i!==void 0&&this._$Em!==i){const o=r.getPropertyOptions(i),n=typeof o.converter=="function"?{fromAttribute:o.converter}:o.converter?.fromAttribute!==void 0?o.converter:q;this._$Em=i;const d=n.fromAttribute(t,o.type);this[i]=d??this._$Ej?.get(i)??d,this._$Em=null}}requestUpdate(e,t,r,i=!1,o){if(e!==void 0){const n=this.constructor;if(i===!1&&(o=this[e]),r??=n.getPropertyOptions(e),!((r.hasChanged??ge)(o,t)||r.useDefault&&r.reflect&&o===this._$Ej?.get(e)&&!this.hasAttribute(n._$Eu(e,r))))return;this.C(e,t,r)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,t,{useDefault:r,reflect:i,wrapped:o},n){r&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,n??t??this[e]),o!==!0||n!==void 0)||(this._$AL.has(e)||(this.hasUpdated||r||(t=void 0),this._$AL.set(e,t)),i===!0&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){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(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[i,o]of this._$Ep)this[i]=o;this._$Ep=void 0}const r=this.constructor.elementProperties;if(r.size>0)for(const[i,o]of r){const{wrapped:n}=o,d=this[i];n!==!0||this._$AL.has(i)||d===void 0||this.C(i,void 0,o,d)}}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach(r=>r.hostUpdate?.()),this.update(t)):this._$EM()}catch(r){throw e=!1,this._$EM(),r}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(e){}firstUpdated(e){}};S.elementStyles=[],S.shadowRootOptions={mode:"open"},S[O("elementProperties")]=new Map,S[O("finalized")]=new Map,Ue?.({ReactiveElement:S}),(H.reactiveElementVersions??=[]).push("2.1.2");const G=globalThis,se=s=>s,L=G.trustedTypes,oe=L?L.createPolicy("lit-html",{createHTML:s=>s}):void 0,ve="$lit$",$=`lit$${Math.random().toFixed(9).slice(2)}$`,be="?"+$,Ie=`<${be}>`,E=document,R=()=>E.createComment(""),D=s=>s===null||typeof s!="object"&&typeof s!="function",Z=Array.isArray,Le=s=>Z(s)||typeof s?.[Symbol.iterator]=="function",j=`[
2
+ \f\r]`,T=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ne=/-->/g,ae=/>/g,y=RegExp(`>|${j}(?:([^\\s"'>=/]+)(${j}*=${j}*(?:[^
3
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),le=/'/g,de=/"/g,$e=/^(?:script|style|textarea|title)$/i,He=s=>(e,...t)=>({_$litType$:s,strings:e,values:t}),u=He(1),w=Symbol.for("lit-noChange"),f=Symbol.for("lit-nothing"),ce=new WeakMap,A=E.createTreeWalker(E,129);function we(s,e){if(!Z(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return oe!==void 0?oe.createHTML(e):e}const Be=(s,e)=>{const t=s.length-1,r=[];let i,o=e===2?"<svg>":e===3?"<math>":"",n=T;for(let d=0;d<t;d++){const a=s[d];let c,m,l=-1,p=0;for(;p<a.length&&(n.lastIndex=p,m=n.exec(a),m!==null);)p=n.lastIndex,n===T?m[1]==="!--"?n=ne:m[1]!==void 0?n=ae:m[2]!==void 0?($e.test(m[2])&&(i=RegExp("</"+m[2],"g")),n=y):m[3]!==void 0&&(n=y):n===y?m[0]===">"?(n=i??T,l=-1):m[1]===void 0?l=-2:(l=n.lastIndex-m[2].length,c=m[1],n=m[3]===void 0?y:m[3]==='"'?de:le):n===de||n===le?n=y:n===ne||n===ae?n=T:(n=y,i=void 0);const h=n===y&&s[d+1].startsWith("/>")?" ":"";o+=n===T?a+Ie:l>=0?(r.push(c),a.slice(0,l)+ve+a.slice(l)+$+h):a+$+(l===-2?d:h)}return[we(s,o+(s[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),r]};class U{constructor({strings:e,_$litType$:t},r){let i;this.parts=[];let o=0,n=0;const d=e.length-1,a=this.parts,[c,m]=Be(e,t);if(this.el=U.createElement(c,r),A.currentNode=this.el.content,t===2||t===3){const l=this.el.content.firstChild;l.replaceWith(...l.childNodes)}for(;(i=A.nextNode())!==null&&a.length<d;){if(i.nodeType===1){if(i.hasAttributes())for(const l of i.getAttributeNames())if(l.endsWith(ve)){const p=m[n++],h=i.getAttribute(l).split($),_=/([.?@])?(.*)/.exec(p);a.push({type:1,index:o,name:_[2],strings:h,ctor:_[1]==="."?je:_[1]==="?"?Fe:_[1]==="@"?Ke:B}),i.removeAttribute(l)}else l.startsWith($)&&(a.push({type:6,index:o}),i.removeAttribute(l));if($e.test(i.tagName)){const l=i.textContent.split($),p=l.length-1;if(p>0){i.textContent=L?L.emptyScript:"";for(let h=0;h<p;h++)i.append(l[h],R()),A.nextNode(),a.push({type:2,index:++o});i.append(l[p],R())}}}else if(i.nodeType===8)if(i.data===be)a.push({type:2,index:o});else{let l=-1;for(;(l=i.data.indexOf($,l+1))!==-1;)a.push({type:7,index:o}),l+=$.length-1}o++}}static createElement(e,t){const r=E.createElement("template");return r.innerHTML=e,r}}function M(s,e,t=s,r){if(e===w)return e;let i=r!==void 0?t._$Co?.[r]:t._$Cl;const o=D(e)?void 0:e._$litDirective$;return i?.constructor!==o&&(i?._$AO?.(!1),o===void 0?i=void 0:(i=new o(s),i._$AT(s,t,r)),r!==void 0?(t._$Co??=[])[r]=i:t._$Cl=i),i!==void 0&&(e=M(s,i._$AS(s,e.values),i,r)),e}class ze{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:r}=this._$AD,i=(e?.creationScope??E).importNode(t,!0);A.currentNode=i;let o=A.nextNode(),n=0,d=0,a=r[0];for(;a!==void 0;){if(n===a.index){let c;a.type===2?c=new C(o,o.nextSibling,this,e):a.type===1?c=new a.ctor(o,a.name,a.strings,this,e):a.type===6&&(c=new We(o,this,e)),this._$AV.push(c),a=r[++d]}n!==a?.index&&(o=A.nextNode(),n++)}return A.currentNode=E,i}p(e){let t=0;for(const r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,t),t+=r.strings.length-2):r._$AI(e[t])),t++}}class C{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,r,i){this.type=2,this._$AH=f,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=r,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return t!==void 0&&e?.nodeType===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=M(this,e,t),D(e)?e===f||e==null||e===""?(this._$AH!==f&&this._$AR(),this._$AH=f):e!==this._$AH&&e!==w&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):Le(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==f&&D(this._$AH)?this._$AA.nextSibling.data=e:this.T(E.createTextNode(e)),this._$AH=e}$(e){const{values:t,_$litType$:r}=e,i=typeof r=="number"?this._$AC(e):(r.el===void 0&&(r.el=U.createElement(we(r.h,r.h[0]),this.options)),r);if(this._$AH?._$AD===i)this._$AH.p(t);else{const o=new ze(i,this),n=o.u(this.options);o.p(t),this.T(n),this._$AH=o}}_$AC(e){let t=ce.get(e.strings);return t===void 0&&ce.set(e.strings,t=new U(e)),t}k(e){Z(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let r,i=0;for(const o of e)i===t.length?t.push(r=new C(this.O(R()),this.O(R()),this,this.options)):r=t[i],r._$AI(o),i++;i<t.length&&(this._$AR(r&&r._$AB.nextSibling,i),t.length=i)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){const r=se(e).nextSibling;se(e).remove(),e=r}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}}class B{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,r,i,o){this.type=1,this._$AH=f,this._$AN=void 0,this.element=e,this.name=t,this._$AM=i,this.options=o,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=f}_$AI(e,t=this,r,i){const o=this.strings;let n=!1;if(o===void 0)e=M(this,e,t,0),n=!D(e)||e!==this._$AH&&e!==w,n&&(this._$AH=e);else{const d=e;let a,c;for(e=o[0],a=0;a<o.length-1;a++)c=M(this,d[r+a],t,a),c===w&&(c=this._$AH[a]),n||=!D(c)||c!==this._$AH[a],c===f?e=f:e!==f&&(e+=(c??"")+o[a+1]),this._$AH[a]=c}n&&!i&&this.j(e)}j(e){e===f?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class je extends B{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===f?void 0:e}}class Fe extends B{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==f)}}class Ke extends B{constructor(e,t,r,i,o){super(e,t,r,i,o),this.type=5}_$AI(e,t=this){if((e=M(this,e,t,0)??f)===w)return;const r=this._$AH,i=e===f&&r!==f||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,o=e!==f&&(r===f||i);i&&this.element.removeEventListener(this.name,this,r),o&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}}class We{constructor(e,t,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){M(this,e)}}const qe={I:C},Ve=G.litHtmlPolyfillSupport;Ve?.(U,C),(G.litHtmlVersions??=[]).push("3.3.2");const Qe=(s,e,t)=>{const r=t?.renderBefore??e;let i=r._$litPart$;if(i===void 0){const o=t?.renderBefore??null;r._$litPart$=i=new C(e.insertBefore(R(),o),o,void 0,t??{})}return i._$AI(s),i};const J=globalThis;let P=class extends S{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=Qe(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return w}};P._$litElement$=!0,P.finalized=!0,J.litElementHydrateSupport?.({LitElement:P});const Ye=J.litElementPolyfillSupport;Ye?.({LitElement:P});(J.litElementVersions??=[]).push("4.2.2");const g=s=>_e(s),v=fe,ye=Se`
4
+ :host {
5
+ /* Re-pin inheritable properties to close inheritance leaks from hostile
6
+ host CSS. These are the only properties that cross the shadow boundary
7
+ via inheritance, so we hard-set them at the root. */
8
+ all: initial;
9
+ display: block;
10
+ height: 100%;
11
+ box-sizing: border-box;
12
+ font-family:
13
+ var(--cpk-drawer-font-family, ui-sans-serif, system-ui, sans-serif);
14
+ font-size: var(--cpk-drawer-font-size, 14px);
15
+ line-height: var(--cpk-drawer-line-height, 1.4);
16
+ color: var(--cpk-drawer-fg, var(--foreground, ${g(v.fg)}));
17
+
18
+ /* Three-level token resolution, highest priority first:
19
+ 1. explicit per-token override (--cpk-drawer-*),
20
+ 2. the host app's theme variable (--background/--card/… — the standard
21
+ react-core/shadcn names), so the drawer follows the host's light/dark
22
+ theme by inheritance (custom properties are NOT reset by all:initial),
23
+ 3. the built-in light default derived from react-core at build time, so a
24
+ host with no theme still renders correctly (self-contained). */
25
+ --_bg: var(--cpk-drawer-bg, var(--background, ${g(v.bg)}));
26
+ --_surface: var(--cpk-drawer-surface, var(--card, ${g(v.surface)}));
27
+ --_surface-fg: var(
28
+ --cpk-drawer-surface-fg,
29
+ var(--card-foreground, ${g(v["surface-fg"])})
30
+ );
31
+ --_muted: var(--cpk-drawer-muted, var(--muted, ${g(v.muted)}));
32
+ --_muted-fg: var(
33
+ --cpk-drawer-muted-fg,
34
+ var(--muted-foreground, ${g(v["muted-fg"])})
35
+ );
36
+ --_accent: var(--cpk-drawer-accent, var(--accent, ${g(v.accent)}));
37
+ --_accent-fg: var(
38
+ --cpk-drawer-accent-fg,
39
+ var(--accent-foreground, ${g(v["accent-fg"])})
40
+ );
41
+ --_primary: var(--cpk-drawer-primary, var(--primary, ${g(v.primary)}));
42
+ --_primary-fg: var(
43
+ --cpk-drawer-primary-fg,
44
+ var(--primary-foreground, ${g(v["primary-fg"])})
45
+ );
46
+ --_danger: var(--cpk-drawer-danger, var(--destructive, ${g(v.danger)}));
47
+ --_border: var(--cpk-drawer-border, var(--border, ${g(v.border)}));
48
+ --_ring: var(--cpk-drawer-ring, var(--ring, ${g(v.ring)}));
49
+ --_radius: var(--cpk-drawer-radius, var(--radius, ${g(v.radius)}));
50
+ --_width: var(--cpk-drawer-width, 320px);
51
+ --_rail-width: var(--cpk-drawer-rail-width, 56px);
52
+ }
53
+
54
+ :host([hidden]) {
55
+ display: none;
56
+ }
57
+
58
+ * {
59
+ box-sizing: border-box;
60
+ }
61
+
62
+ .root {
63
+ display: flex;
64
+ flex-direction: column;
65
+ height: 100%;
66
+ width: var(--_width);
67
+ background: var(--_bg);
68
+ border-right: 1px solid var(--_border);
69
+ overflow: hidden;
70
+ transition: width 0.2s ease;
71
+ /* Positioning context for the confirm-delete dialog's absolutely-positioned
72
+ backdrop (see .dialog-backdrop). Without this the backdrop's inset:0
73
+ resolves against the initial containing block (the viewport) and its
74
+ low z-index competes in the light-DOM root stacking context, so on
75
+ desktop the dialog escapes the drawer column and paints UNDER the chat
76
+ input (which sits in a sibling column). Anchoring here confines the
77
+ modal to the drawer, where its z-index only needs to beat the rows.
78
+ The mobile path already establishes its own context via position:fixed. */
79
+ position: relative;
80
+ }
81
+
82
+ .root.collapsed {
83
+ width: var(--_rail-width);
84
+ }
85
+
86
+ /* Mobile: off-canvas overlay (modal pattern). */
87
+ .root.mobile {
88
+ position: fixed;
89
+ inset: 0 auto 0 0;
90
+ z-index: 1000;
91
+ width: min(var(--_width), 85vw);
92
+ transform: translateX(-100%);
93
+ transition: transform 0.2s ease;
94
+ box-shadow: 0 0 0 100vmax transparent;
95
+ }
96
+
97
+ .root.mobile.open {
98
+ transform: translateX(0);
99
+ }
100
+
101
+ .backdrop {
102
+ position: fixed;
103
+ inset: 0;
104
+ z-index: 999;
105
+ background: rgba(0, 0, 0, 0.4);
106
+ border: 0;
107
+ padding: 0;
108
+ margin: 0;
109
+ cursor: pointer;
110
+ }
111
+
112
+ /* Mobile-only floating affordance to OPEN the off-canvas drawer. Rendered by
113
+ the element itself so phones always have a way in with no host wiring. */
114
+ .launcher {
115
+ position: fixed;
116
+ z-index: 998;
117
+ /* Position is themeable so a host can line the launcher up with its own
118
+ header controls (e.g. vertically centering it on a toggle group). */
119
+ top: var(--cpk-drawer-launcher-top, 12px);
120
+ left: var(--cpk-drawer-launcher-left, 12px);
121
+ display: inline-flex;
122
+ align-items: center;
123
+ justify-content: center;
124
+ width: 40px;
125
+ height: 40px;
126
+ border-radius: 999px;
127
+ border: 1px solid var(--_border);
128
+ background: var(--_surface);
129
+ color: var(--_surface-fg);
130
+ cursor: pointer;
131
+ box-shadow: 0 2px 8px rgb(0 0 0 / 0.12);
132
+ }
133
+
134
+ .launcher-icon {
135
+ width: 18px;
136
+ height: 18px;
137
+ display: block;
138
+ }
139
+
140
+ .header {
141
+ display: flex;
142
+ align-items: center;
143
+ justify-content: space-between;
144
+ gap: 8px;
145
+ padding: 12px;
146
+ border-bottom: 1px solid var(--_border);
147
+ }
148
+
149
+ .filters {
150
+ display: flex;
151
+ gap: 4px;
152
+ padding: 8px 12px;
153
+ }
154
+
155
+ .filter-btn {
156
+ flex: 1;
157
+ padding: 6px 10px;
158
+ border: 1px solid var(--_border);
159
+ border-radius: var(--_radius);
160
+ background: var(--_bg);
161
+ color: var(--_muted-fg);
162
+ cursor: pointer;
163
+ font: inherit;
164
+ }
165
+
166
+ .filter-btn[aria-pressed="true"] {
167
+ background: var(--_accent);
168
+ color: var(--_accent-fg);
169
+ border-color: var(--_ring);
170
+ }
171
+
172
+ .list {
173
+ flex: 1;
174
+ min-height: 0;
175
+ overflow-y: auto;
176
+ padding: 8px 12px;
177
+ margin: 0;
178
+ list-style: none;
179
+ display: flex;
180
+ flex-direction: column;
181
+ gap: 4px;
182
+ }
183
+
184
+ .row {
185
+ display: flex;
186
+ align-items: center;
187
+ gap: 8px;
188
+ padding: 8px 10px;
189
+ border-radius: var(--_radius);
190
+ cursor: pointer;
191
+ background: transparent;
192
+ color: inherit;
193
+ border: 1px solid transparent;
194
+ opacity: 0;
195
+ transform: translateY(4px);
196
+ animation: cpk-drawer-row-in 0.18s ease forwards;
197
+ /* Positioned so the hovered row can be lifted above later rows (below). */
198
+ position: relative;
199
+ }
200
+
201
+ /* The entry animation leaves each row with a (non-none) transform, making it
202
+ its own stacking context — which would paint the name tooltip UNDER the
203
+ following rows (their text bled through the bubble). Lifting the hovered
204
+ row's z-index re-floats its tooltip above the rows beneath it. */
205
+ .row.name-clipped:hover {
206
+ z-index: 2;
207
+ }
208
+
209
+ @keyframes cpk-drawer-row-in {
210
+ to {
211
+ opacity: 1;
212
+ transform: translateY(0);
213
+ }
214
+ }
215
+
216
+ .row.active {
217
+ background: var(--_accent);
218
+ color: var(--_accent-fg);
219
+ border-color: var(--_ring);
220
+ }
221
+
222
+ .row.archived .row-name {
223
+ color: var(--_muted-fg);
224
+ }
225
+
226
+ .row-name {
227
+ /* The outer name element owns NO overflow clip so it can host the name
228
+ tooltip pseudo-element; the inner .row-name-text does the ellipsis. */
229
+ flex: 1;
230
+ min-width: 0;
231
+ position: relative;
232
+ }
233
+
234
+ .row-name-text {
235
+ display: block;
236
+ overflow: hidden;
237
+ text-overflow: ellipsis;
238
+ white-space: nowrap;
239
+ }
240
+
241
+ /* Name tooltip: matches the row-action tooltip (instant primary bubble with
242
+ an arrow), shown ONLY when the name is clipped. Positioned below the name,
243
+ wrapping within the drawer width (a long name can't fit one line). */
244
+ .row-name.name-clipped[data-tooltip]:hover::after {
245
+ content: attr(data-tooltip);
246
+ position: absolute;
247
+ left: 0;
248
+ top: calc(100% + 6px);
249
+ white-space: normal;
250
+ max-width: 240px;
251
+ background: var(--_primary);
252
+ color: var(--_primary-fg);
253
+ border-radius: 6px;
254
+ padding: 4px 8px;
255
+ font-size: 12px;
256
+ line-height: 1.4;
257
+ box-shadow: 0 4px 12px rgb(0 0 0 / 0.18);
258
+ pointer-events: none;
259
+ z-index: 20;
260
+ }
261
+
262
+ .row-name.name-clipped[data-tooltip]:hover::before {
263
+ content: "";
264
+ position: absolute;
265
+ left: 10px;
266
+ top: calc(100% + 1.5px);
267
+ transform: rotate(45deg);
268
+ width: 7px;
269
+ height: 7px;
270
+ background: var(--_primary);
271
+ border-radius: 1px;
272
+ pointer-events: none;
273
+ z-index: 21;
274
+ }
275
+
276
+ .row-name.placeholder {
277
+ color: var(--_muted-fg);
278
+ font-style: italic;
279
+ }
280
+
281
+ .row-name.revealed {
282
+ animation: cpk-drawer-name-reveal 0.3s ease;
283
+ }
284
+
285
+ @keyframes cpk-drawer-name-reveal {
286
+ from {
287
+ opacity: 0.4;
288
+ }
289
+ to {
290
+ opacity: 1;
291
+ }
292
+ }
293
+
294
+ .row-action {
295
+ position: relative;
296
+ display: inline-flex;
297
+ align-items: center;
298
+ justify-content: center;
299
+ flex: none;
300
+ border: 0;
301
+ background: transparent;
302
+ color: var(--_muted-fg);
303
+ cursor: pointer;
304
+ font: inherit;
305
+ padding: 5px;
306
+ border-radius: 6px;
307
+ }
308
+
309
+ /* Instant tooltip (matches the react components' delayDuration:0) styled to
310
+ match the CPK standard tooltip: a solid primary-colored bubble with
311
+ primary-foreground text, rounded corners, no border, and a small arrow —
312
+ NOT a surface/bordered box (which reads as a button). Rendered to the LEFT
313
+ of the action so the list's vertical overflow never clips it; the native
314
+ \`title\` tooltip is avoided because its show-delay is browser-fixed (~1.5s)
315
+ and cannot be tuned. */
316
+ .row-action[data-tooltip]:hover::after,
317
+ .row-action[data-tooltip]:focus-visible::after {
318
+ content: attr(data-tooltip);
319
+ position: absolute;
320
+ right: calc(100% + 8px);
321
+ top: 50%;
322
+ transform: translateY(-50%);
323
+ white-space: nowrap;
324
+ background: var(--_primary);
325
+ color: var(--_primary-fg);
326
+ border-radius: 6px;
327
+ padding: 4px 8px;
328
+ font-size: 12px;
329
+ line-height: 1.4;
330
+ box-shadow: 0 4px 12px rgb(0 0 0 / 0.18);
331
+ pointer-events: none;
332
+ z-index: 20;
333
+ }
334
+
335
+ /* Arrow: a small rotated square at the bubble's right edge, pointing at the
336
+ action — same primary fill as the bubble. */
337
+ .row-action[data-tooltip]:hover::before,
338
+ .row-action[data-tooltip]:focus-visible::before {
339
+ content: "";
340
+ position: absolute;
341
+ right: calc(100% + 4.5px);
342
+ top: 50%;
343
+ transform: translateY(-50%) rotate(45deg);
344
+ width: 7px;
345
+ height: 7px;
346
+ background: var(--_primary);
347
+ border-radius: 1px;
348
+ pointer-events: none;
349
+ z-index: 21;
350
+ }
351
+
352
+ /* While the delete-confirmation dialog is open, suppress row-action tooltips:
353
+ the clicked trash button keeps :focus-visible (and may stay hovered), which
354
+ would otherwise leave its "Delete" tooltip floating over the dialog. */
355
+ .root.confirming .row-action[data-tooltip]:hover::after,
356
+ .root.confirming .row-action[data-tooltip]:focus-visible::after,
357
+ .root.confirming .row-action[data-tooltip]:hover::before,
358
+ .root.confirming .row-action[data-tooltip]:focus-visible::before {
359
+ content: none;
360
+ display: none;
361
+ }
362
+
363
+ .row-action:hover,
364
+ .row-action:focus-visible {
365
+ background: var(--_muted);
366
+ color: inherit;
367
+ }
368
+
369
+ .row-action.danger:hover,
370
+ .row-action.danger:focus-visible {
371
+ color: var(--_danger);
372
+ }
373
+
374
+ .row-action-icon {
375
+ width: 15px;
376
+ height: 15px;
377
+ display: block;
378
+ }
379
+
380
+ button.primary {
381
+ background: var(--_primary);
382
+ color: var(--_primary-fg);
383
+ border: 0;
384
+ border-radius: var(--_radius);
385
+ padding: 8px 12px;
386
+ cursor: pointer;
387
+ font: inherit;
388
+ }
389
+
390
+ .state {
391
+ padding: 24px 16px;
392
+ text-align: center;
393
+ color: var(--_muted-fg);
394
+ }
395
+
396
+ .state.error {
397
+ color: var(--_danger);
398
+ }
399
+
400
+ .fetch-more-error {
401
+ padding: 8px 12px;
402
+ text-align: center;
403
+ color: var(--_danger);
404
+ font-size: 0.9em;
405
+ }
406
+
407
+ .load-more {
408
+ display: block;
409
+ width: 100%;
410
+ padding: 8px 12px;
411
+ background: none;
412
+ border: none;
413
+ color: var(--_muted-fg);
414
+ font: inherit;
415
+ font-size: 0.9em;
416
+ cursor: pointer;
417
+ }
418
+
419
+ .load-more:hover,
420
+ .load-more:focus-visible {
421
+ color: var(--_surface-fg);
422
+ background: var(--_muted);
423
+ }
424
+
425
+ .licensed {
426
+ padding: 24px 16px;
427
+ text-align: center;
428
+ display: flex;
429
+ flex-direction: column;
430
+ gap: 12px;
431
+ }
432
+
433
+ .memories {
434
+ border-top: 1px solid var(--_border);
435
+ padding: 8px 12px;
436
+ }
437
+
438
+ .memories[hidden] {
439
+ display: none;
440
+ }
441
+
442
+ .dialog-backdrop {
443
+ position: absolute;
444
+ inset: 0;
445
+ background: rgba(0, 0, 0, 0.3);
446
+ display: flex;
447
+ align-items: center;
448
+ justify-content: center;
449
+ z-index: 10;
450
+ }
451
+
452
+ .dialog {
453
+ background: var(--_surface);
454
+ color: var(--_surface-fg);
455
+ border-radius: var(--_radius);
456
+ padding: 16px;
457
+ max-width: 80%;
458
+ display: flex;
459
+ flex-direction: column;
460
+ gap: 12px;
461
+ }
462
+
463
+ .dialog-actions {
464
+ display: flex;
465
+ justify-content: flex-end;
466
+ gap: 8px;
467
+ }
468
+
469
+ .footer {
470
+ border-top: 1px solid var(--_border);
471
+ padding: 12px;
472
+ }
473
+
474
+ .footer[hidden] {
475
+ display: none;
476
+ }
477
+ `;const xe={ATTRIBUTE:1,CHILD:2},Ae=s=>(...e)=>({_$litDirective$:s,values:e});let ke=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,r){this._$Ct=e,this._$AM=t,this._$Ci=r}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}};const{I:Ge}=qe,he=s=>s,pe=()=>document.createComment(""),N=(s,e,t)=>{const r=s._$AA.parentNode,i=e===void 0?s._$AB:e._$AA;if(t===void 0){const o=r.insertBefore(pe(),i),n=r.insertBefore(pe(),i);t=new Ge(o,n,s,s.options)}else{const o=t._$AB.nextSibling,n=t._$AM,d=n!==s;if(d){let a;t._$AQ?.(s),t._$AM=s,t._$AP!==void 0&&(a=s._$AU)!==n._$AU&&t._$AP(a)}if(o!==i||d){let a=t._$AA;for(;a!==o;){const c=he(a).nextSibling;he(r).insertBefore(a,i),a=c}}}return t},x=(s,e,t=s)=>(s._$AI(e,t),s),Ze={},Je=(s,e=Ze)=>s._$AH=e,Xe=s=>s._$AH,F=s=>{s._$AR(),s._$AA.remove()};const ue=(s,e,t)=>{const r=new Map;for(let i=e;i<=t;i++)r.set(s[i],i);return r},et=Ae(class extends ke{constructor(s){if(super(s),s.type!==xe.CHILD)throw Error("repeat() can only be used in text expressions")}dt(s,e,t){let r;t===void 0?t=e:e!==void 0&&(r=e);const i=[],o=[];let n=0;for(const d of s)i[n]=r?r(d,n):n,o[n]=t(d,n),n++;return{values:o,keys:i}}render(s,e,t){return this.dt(s,e,t).values}update(s,[e,t,r]){const i=Xe(s),{values:o,keys:n}=this.dt(e,t,r);if(!Array.isArray(i))return this.ut=n,o;const d=this.ut??=[],a=[];let c,m,l=0,p=i.length-1,h=0,_=o.length-1;for(;l<=p&&h<=_;)if(i[l]===null)l++;else if(i[p]===null)p--;else if(d[l]===n[h])a[h]=x(i[l],o[h]),l++,h++;else if(d[p]===n[_])a[_]=x(i[p],o[_]),p--,_--;else if(d[l]===n[_])a[_]=x(i[l],o[_]),N(s,a[_+1],i[l]),l++,_--;else if(d[p]===n[h])a[h]=x(i[p],o[h]),N(s,i[l],i[p]),p--,h++;else if(c===void 0&&(c=ue(n,h,_),m=ue(d,l,p)),c.has(d[l]))if(c.has(d[p])){const b=m.get(n[h]),z=b!==void 0?i[b]:null;if(z===null){const X=N(s,i[l]);x(X,o[h]),a[h]=X}else a[h]=x(z,o[h]),N(s,i[l],z),i[b]=null;h++}else F(i[p]),p--;else F(i[l]),l++;for(;h<=_;){const b=N(s,a[_+1]);x(b,o[h]),a[h++]=b}for(;l<=p;){const b=i[l++];b!==null&&F(b)}return this.ut=n,Je(s,a),w}});const K=Ae(class extends ke{constructor(s){if(super(s),s.type!==xe.ATTRIBUTE||s.name!=="class"||s.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(s){return" "+Object.keys(s).filter(e=>s[e]).join(" ")+" "}update(s,[e]){if(this.st===void 0){this.st=new Set,s.strings!==void 0&&(this.nt=new Set(s.strings.join(" ").split(/\s/).filter(r=>r!=="")));for(const r in e)e[r]&&!this.nt?.has(r)&&this.st.add(r);return this.render(e)}const t=s.element.classList;for(const r of this.st)r in e||(t.remove(r),this.st.delete(r));for(const r in e){const i=!!e[r];i===this.st.has(r)||this.nt?.has(r)||(i?(t.add(r),this.st.add(r)):(t.remove(r),this.st.delete(r)))}return w}}),V="copilotkit-threads-drawer",tt=768;function W(s){return s!==null&&s.trim().length>0}function rt(s){return s.length===0||/[\s"'<>=]/.test(s)?null:`row:${s}`}const it=u`
478
+ <svg
479
+ class="row-action-icon"
480
+ viewBox="0 0 24 24"
481
+ fill="none"
482
+ stroke="currentColor"
483
+ stroke-width="2"
484
+ stroke-linecap="round"
485
+ stroke-linejoin="round"
486
+ aria-hidden="true"
487
+ >
488
+ <rect width="20" height="5" x="2" y="3" rx="1" />
489
+ <path d="M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8" />
490
+ <path d="M10 12h4" />
491
+ </svg>
492
+ `,st=u`
493
+ <svg
494
+ class="row-action-icon"
495
+ viewBox="0 0 24 24"
496
+ fill="none"
497
+ stroke="currentColor"
498
+ stroke-width="2"
499
+ stroke-linecap="round"
500
+ stroke-linejoin="round"
501
+ aria-hidden="true"
502
+ >
503
+ <rect width="20" height="5" x="2" y="3" rx="1" />
504
+ <path d="M4 8v11a2 2 0 0 0 2 2h2" />
505
+ <path d="M20 8v11a2 2 0 0 1-2 2h-2" />
506
+ <path d="m9 15 3-3 3 3" />
507
+ <path d="M12 12v9" />
508
+ </svg>
509
+ `,ot=u`
510
+ <svg
511
+ class="row-action-icon"
512
+ viewBox="0 0 24 24"
513
+ fill="none"
514
+ stroke="currentColor"
515
+ stroke-width="2"
516
+ stroke-linecap="round"
517
+ stroke-linejoin="round"
518
+ aria-hidden="true"
519
+ >
520
+ <path d="M3 6h18" />
521
+ <path
522
+ d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"
523
+ />
524
+ <line x1="10" x2="10" y1="11" y2="17" />
525
+ <line x1="14" x2="14" y1="11" y2="17" />
526
+ </svg>
527
+ `,nt=u`
528
+ <svg
529
+ class="launcher-icon"
530
+ viewBox="0 0 24 24"
531
+ fill="none"
532
+ stroke="currentColor"
533
+ stroke-width="2"
534
+ stroke-linecap="round"
535
+ stroke-linejoin="round"
536
+ aria-hidden="true"
537
+ >
538
+ <rect width="18" height="18" x="3" y="3" rx="2" />
539
+ <path d="M9 3v18" />
540
+ <path d="m14 9 3 3-3 3" />
541
+ </svg>
542
+ `;var k,Ee=(k=class extends P{constructor(...e){super(...e),this.label="Threads",this.threads=[],this.loading=!1,this.error=null,this.activeThreadId=null,this.licensed=!0,this.licenseUrl="https://docs.copilotkit.ai/intelligence",this.hasMore=!1,this.fetchingMore=!1,this.fetchMoreError=null,this.open=!0,this.collapsed=!1,this._filter="active",this._confirmingDeleteId=null,this._viewportIsMobile=!1,this._hasMemories=!1,this._hasFooter=!1,this._mediaQuery=null,this._onMediaChange=t=>{this._viewportIsMobile=t.matches},this._onKeyDown=t=>{if(t.key==="Escape"){if(this._confirmingDeleteId!==null){this._confirmingDeleteId=null,t.stopPropagation();return}this._viewportIsMobile&&this.open&&(this._setOpen(!1),t.stopPropagation());return}t.key==="Tab"&&this._trapTab(t)},this._seenNamed=new Set,this._justRevealed=new Set,this._scrollLocked=!1,this._prevBodyOverflow="",this._trapTab=t=>{if(t.key!=="Tab"||!this._isMobileModalOpen())return;const r=this._composedFocusable();if(r.length===0)return;const i=r[0],o=r[r.length-1],n=this.renderRoot.activeElement??document.activeElement;t.shiftKey&&n===i?(o.focus(),t.preventDefault()):!t.shiftKey&&n===o&&(i.focus(),t.preventDefault())}}connectedCallback(){super.connectedCallback(),typeof window<"u"&&window.matchMedia&&(this._mediaQuery=window.matchMedia(`(max-width: ${tt}px)`),this._viewportIsMobile=this._mediaQuery.matches,this._mediaQuery.addEventListener("change",this._onMediaChange)),this.addEventListener("keydown",this._onKeyDown)}disconnectedCallback(){super.disconnectedCallback(),this._mediaQuery?.removeEventListener("change",this._onMediaChange),this.removeEventListener("keydown",this._onKeyDown),this._releaseScrollLock()}willUpdate(e){if(e.has("threads")){const t=new Set,r=new Set;for(const i of this.threads){t.add(i.id);const o=i.name!==null&&i.name!=="";o&&!this._seenNamed.has(i.id)&&r.add(i.id),o&&this._seenNamed.add(i.id)}for(const i of this._seenNamed)t.has(i)||this._seenNamed.delete(i);this._justRevealed=r,this._confirmingDeleteId!==null&&(this._visibleThreads().some(i=>i.id===this._confirmingDeleteId)||(this._confirmingDeleteId=null))}}updated(e){(e.has("open")||e.has("_viewportIsMobile"))&&(this._isMobileModalOpen()?(this._applyScrollLock(),this._focusFirstFocusable()):this._releaseScrollLock()),this._justRevealed.size>0&&(this._justRevealed=new Set),this._syncNameClipping()}_syncNameClipping(){this.renderRoot.querySelectorAll(".row-name").forEach(e=>{const t=e.querySelector(".row-name-text"),r=!!t&&t.scrollWidth>t.clientWidth;e.classList.toggle("name-clipped",r),e.closest(".row")?.classList.toggle("name-clipped",r)})}_isMobileModalOpen(){return this._viewportIsMobile&&this.open}_setOpen(e){this.open!==e&&(this.open=e,this._emit("open-change",{open:e}))}_setFilter(e){this._filter!==e&&(this._filter=e,this._emit("filter-change",{filter:e}))}_visibleThreads(){const e=this._filter==="active"?this.threads.filter(r=>!r.archived):this.threads,t=r=>{const i=r.lastRunAt??r.updatedAt??r.createdAt,o=Date.parse(i);return Number.isNaN(o)?null:o};return[...e].map((r,i)=>({thread:r,index:i,ts:t(r)})).sort((r,i)=>r.ts===null&&i.ts===null?r.index-i.index:r.ts===null?1:i.ts===null?-1:r.ts!==i.ts?i.ts-r.ts:r.index-i.index).map(r=>r.thread)}_emit(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}_applyScrollLock(){this._scrollLocked||typeof document>"u"||(this._prevBodyOverflow=document.body.style.overflow,document.body.style.overflow="hidden",this._scrollLocked=!0)}_releaseScrollLock(){!this._scrollLocked||typeof document>"u"||(document.body.style.overflow=this._prevBodyOverflow,this._scrollLocked=!1)}_composedFocusable(){const e='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',t=[],r=this.renderRoot.querySelector(".backdrop");r&&t.push(r);const i=this.renderRoot.querySelector(".root");if(!i)return t;const o=n=>{n.querySelectorAll(e).forEach(d=>t.push(d))};return o(i),i.querySelectorAll("slot").forEach(n=>{n.assignedElements({flatten:!0}).forEach(d=>{d.matches(e)&&t.push(d),o(d)})}),t}_focusFirstFocusable(){queueMicrotask(()=>{const e=this._composedFocusable(),t=this.renderRoot.querySelector(".backdrop");(e.find(r=>r!==t)??e[0])?.focus()})}render(){const e={root:!0,collapsed:this.collapsed&&!this._viewportIsMobile,mobile:this._viewportIsMobile,open:this.open,confirming:this._confirmingDeleteId!==null};return u`
543
+ ${this._viewportIsMobile&&!this.open?u`<button
544
+ class="launcher"
545
+ part="launcher"
546
+ aria-label="Open threads"
547
+ @click=${()=>this._setOpen(!0)}
548
+ >
549
+ <slot name="launcher-icon">${nt}</slot>
550
+ </button>`:f}
551
+ ${this._isMobileModalOpen()?u`<button
552
+ class="backdrop"
553
+ part="backdrop"
554
+ aria-label="Close threads drawer"
555
+ @click=${()=>this._setOpen(!1)}
556
+ ></button>`:f}
557
+ <div
558
+ class=${K(e)}
559
+ part="root"
560
+ role=${this._isMobileModalOpen()?"dialog":"region"}
561
+ aria-modal=${this._isMobileModalOpen()?"true":f}
562
+ aria-label=${this.label}
563
+ >
564
+ ${this._renderHeader()} ${this._renderBody()} ${this._renderMemories()}
565
+ ${this._renderFooter()} ${this._renderConfirmDialog()}
566
+ </div>
567
+ `}_renderHeader(){return u`
568
+ <div class="header" part="header">
569
+ <slot name="header"><span>${this.label}</span></slot>
570
+ <button
571
+ class="primary"
572
+ part="new-thread-button"
573
+ aria-label="New thread"
574
+ @click=${()=>this._emit("new-thread",{})}
575
+ >
576
+ + New
577
+ </button>
578
+ </div>
579
+ ${this.licensed&&(!W(this.error)||this.threads.length>0)?u`
580
+ <div class="filters" part="filters" role="group" aria-label="Filter threads">
581
+ <button
582
+ class="filter-btn"
583
+ part="filter-active"
584
+ aria-pressed=${this._filter==="active"}
585
+ @click=${()=>this._setFilter("active")}
586
+ >
587
+ Active
588
+ </button>
589
+ <button
590
+ class="filter-btn"
591
+ part="filter-all"
592
+ aria-pressed=${this._filter==="all"}
593
+ @click=${()=>this._setFilter("all")}
594
+ >
595
+ All
596
+ </button>
597
+ </div>
598
+ `:f}
599
+ `}_renderBody(){return this.licensed?W(this.error)&&this.threads.length===0?this._renderError():this.loading&&this.threads.length===0?this._renderLoading():this._renderList():this._renderLicensed()}_onLicensedCta(){this.dispatchEvent(new CustomEvent("licensed",{detail:{licenseUrl:this.licenseUrl},bubbles:!0,composed:!0,cancelable:!0}))&&this.licenseUrl&&typeof window<"u"&&window.open(this.licenseUrl,"_blank","noopener,noreferrer")}_renderLicensed(){return u`
600
+ <div class="licensed" part="licensed" data-testid="drawer-licensed">
601
+ <slot name="licensed">
602
+ <p>Threads are a CopilotKit Intelligence feature.</p>
603
+ <button
604
+ class="primary"
605
+ part="licensed-cta"
606
+ @click=${()=>this._onLicensedCta()}
607
+ >
608
+ Upgrade
609
+ </button>
610
+ </slot>
611
+ </div>
612
+ `}_renderError(){return u`
613
+ <div class="state error" part="error" role="alert" data-testid="drawer-error">
614
+ <p>${this.error}</p>
615
+ <button
616
+ class="primary"
617
+ part="retry-button"
618
+ @click=${()=>this._emit("retry",{scope:"initial"})}
619
+ >
620
+ Retry
621
+ </button>
622
+ </div>
623
+ `}_renderLoading(){return u`
624
+ <div class="state" part="loading" data-testid="drawer-loading" aria-busy="true">
625
+ Loading threads…
626
+ </div>
627
+ `}_renderList(){const e=this._visibleThreads();return e.length===0?u`
628
+ <div class="state" part="empty" data-testid="drawer-empty">
629
+ <slot name="empty">No threads yet.</slot>
630
+ </div>
631
+ `:u`
632
+ <ul class="list" part="list" role="listbox" aria-label=${this.label}>
633
+ ${et(e,t=>t.id,t=>this._renderRow(t))}
634
+ </ul>
635
+ ${this._renderFetchMore()}
636
+ `}_renderRow(e){const t=e.id===this.activeThreadId,r=e.name!==null&&e.name!=="",i=this._justRevealed.has(e.id),o={row:!0,active:t,archived:e.archived},n={"row-name":!0,placeholder:!r,revealed:i},d=rt(e.id),a=u`<span
637
+ class=${K(n)}
638
+ part="row-name"
639
+ data-tooltip=${r?e.name:f}
640
+ >
641
+ <span class="row-name-text"
642
+ >${r?e.name:"New thread"}</span
643
+ >
644
+ </span>`;return u`
645
+ <li
646
+ class=${K(o)}
647
+ part=${t?"row row-active":"row"}
648
+ role="option"
649
+ aria-selected=${t?"true":"false"}
650
+ tabindex="0"
651
+ data-thread-id=${e.id}
652
+ @click=${()=>this._emit("thread-selected",{threadId:e.id})}
653
+ @keydown=${c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),this._emit("thread-selected",{threadId:e.id}))}}
654
+ >
655
+ ${d!==null?u`<slot name=${d}>${a}</slot>`:a}
656
+ ${e.archived?u`<button
657
+ class="row-action"
658
+ part="row-unarchive"
659
+ data-tooltip="Unarchive"
660
+ aria-label=${`Unarchive thread ${e.name??"New thread"}`}
661
+ @click=${c=>{c.stopPropagation(),this._emit("unarchive",{threadId:e.id})}}
662
+ >
663
+ ${st}
664
+ </button>`:u`<button
665
+ class="row-action"
666
+ part="row-archive"
667
+ data-tooltip="Archive"
668
+ aria-label=${`Archive thread ${e.name??"New thread"}`}
669
+ @click=${c=>{c.stopPropagation(),this._emit("archive",{threadId:e.id})}}
670
+ >
671
+ ${it}
672
+ </button>`}
673
+ <button
674
+ class="row-action danger"
675
+ part="row-delete"
676
+ data-tooltip="Delete"
677
+ aria-label=${`Delete thread ${e.name??"New thread"}`}
678
+ @click=${c=>{c.stopPropagation(),this._confirmingDeleteId=e.id}}
679
+ >
680
+ ${ot}
681
+ </button>
682
+ </li>
683
+ `}_renderFetchMore(){return W(this.fetchMoreError)?u`
684
+ <div class="fetch-more-error" part="fetch-more-error" role="alert">
685
+ Couldn't load more —
686
+ <button
687
+ class="row-action"
688
+ part="fetch-more-retry"
689
+ @click=${()=>this._emit("retry",{scope:"fetch-more"})}
690
+ >
691
+ retry
692
+ </button>
693
+ </div>
694
+ `:this.fetchingMore?u`
695
+ <div class="state" part="fetching-more" aria-busy="true">Loading more…</div>
696
+ `:this.hasMore?u`
697
+ <button
698
+ class="load-more"
699
+ part="load-more"
700
+ @click=${()=>this._emit("load-more",{})}
701
+ >
702
+ Load more
703
+ </button>
704
+ `:f}_renderMemories(){return u`
705
+ <div class="memories" part="memories" ?hidden=${!this._hasMemories}>
706
+ <slot
707
+ name="memories"
708
+ @slotchange=${e=>{this._hasMemories=e.target.assignedElements().length>0}}
709
+ ></slot>
710
+ </div>
711
+ `}_renderFooter(){return u`
712
+ <div class="footer" part="footer" ?hidden=${!this._hasFooter}>
713
+ <slot
714
+ name="footer"
715
+ @slotchange=${e=>{this._hasFooter=e.target.assignedElements().length>0}}
716
+ ></slot>
717
+ </div>
718
+ `}_renderConfirmDialog(){if(this._confirmingDeleteId===null)return f;const e=this._confirmingDeleteId;return u`
719
+ <div class="dialog-backdrop" part="dialog-backdrop">
720
+ <div
721
+ class="dialog"
722
+ part="confirm-dialog"
723
+ role="alertdialog"
724
+ aria-modal="true"
725
+ aria-label="Confirm delete"
726
+ data-testid="drawer-confirm-delete"
727
+ >
728
+ <p>Delete this thread? This cannot be undone.</p>
729
+ <div class="dialog-actions">
730
+ <button
731
+ class="row-action"
732
+ part="confirm-cancel"
733
+ @click=${()=>this._confirmingDeleteId=null}
734
+ >
735
+ Cancel
736
+ </button>
737
+ <button
738
+ class="primary"
739
+ part="confirm-delete"
740
+ @click=${()=>{this._confirmingDeleteId=null,this._emit("delete",{threadId:e})}}
741
+ >
742
+ Delete
743
+ </button>
744
+ </div>
745
+ </div>
746
+ </div>
747
+ `}},k.styles=ye,k.properties={threads:{attribute:!1},loading:{type:Boolean},error:{type:String},activeThreadId:{attribute:"active-thread-id",type:String},licensed:{type:Boolean},licenseUrl:{attribute:"license-url",type:String},hasMore:{attribute:"has-more",type:Boolean},fetchingMore:{attribute:"fetching-more",type:Boolean},fetchMoreError:{attribute:"fetch-more-error",type:String},label:{type:String},open:{type:Boolean,reflect:!0},collapsed:{type:Boolean,reflect:!0},_filter:{state:!0},_confirmingDeleteId:{state:!0},_viewportIsMobile:{state:!0},_hasMemories:{state:!0},_hasFooter:{state:!0}},k);function at(){typeof customElements<"u"&&!customElements.get(V)&&customElements.define(V,Ee)}exports.COPILOTKIT_THREADS_DRAWER_TAG=V;exports.CopilotKitThreadsDrawer=Ee;exports.GENERATED_DRAWER_TOKEN_DEFAULTS=fe;exports.defineCopilotKitThreadsDrawer=at;exports.drawerStyles=ye;
748
+ //# sourceMappingURL=index-LFxZI63k.cjs.map