@pillar-ai/sdk 0.1.13 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +46 -44
- package/dist/actions/types.d.ts +39 -3
- package/dist/api/client.d.ts +119 -16
- package/dist/api/mcp-client.d.ts +137 -87
- package/dist/cli/sync.js +72 -13
- package/dist/components/DebugPanel/DebugPanel.d.ts +25 -0
- package/dist/components/DebugPanel/index.d.ts +2 -0
- package/dist/components/DevTools/index.d.ts +5 -0
- package/dist/components/DevTools/styles.d.ts +5 -0
- package/dist/components/PagePilot/PagePilotBanner.d.ts +7 -0
- package/dist/components/PagePilot/PagePilotManager.d.ts +42 -0
- package/dist/components/PagePilot/index.d.ts +7 -0
- package/dist/components/PagePilot/styles.d.ts +6 -0
- package/dist/components/Panel/Header.d.ts +3 -5
- package/dist/components/Panel/HistoryDropdown.d.ts +10 -0
- package/dist/components/Panel/PanelContent.d.ts +1 -2
- package/dist/components/Panel/TaskButton.d.ts +4 -14
- package/dist/components/Panel/UnifiedChatInput.d.ts +5 -1
- package/dist/components/Panel/styles.d.ts +2 -2
- package/dist/components/Plan/InlinePlanView.d.ts +1 -1
- package/dist/components/Plan/PlanDocument.d.ts +18 -0
- package/dist/components/Plan/PlanStepItem.d.ts +1 -1
- package/dist/components/Plan/PlanView.d.ts +1 -1
- package/dist/components/Plan/index.d.ts +1 -0
- package/dist/components/Progress/ProgressGroup.d.ts +20 -0
- package/dist/components/Progress/ProgressRow.d.ts +9 -2
- package/dist/components/Progress/ProgressStack.d.ts +24 -0
- package/dist/components/Progress/ReasoningDisclosure.d.ts +16 -0
- package/dist/components/Progress/index.d.ts +2 -0
- package/dist/components/Views/HomeView.d.ts +3 -0
- package/dist/components/Views/ResumePrompt.d.ts +22 -0
- package/dist/components/Views/index.d.ts +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/shared/icons.d.ts +24 -0
- package/dist/components/shared/index.d.ts +1 -0
- package/dist/core/Pillar.d.ts +325 -70
- package/dist/core/config.d.ts +133 -4
- package/dist/core/events.d.ts +55 -70
- package/dist/core/plan-executor.d.ts +29 -0
- package/dist/core/plan.d.ts +6 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/useDebouncedValue.d.ts +22 -0
- package/dist/hooks/useInlineCard.d.ts +35 -0
- package/dist/hooks/usePillarInstance.d.ts +30 -0
- package/dist/index.d.ts +11 -9
- package/dist/pillar.esm.js +1 -1
- package/dist/store/chat.d.ts +185 -25
- package/dist/store/index.d.ts +2 -0
- package/dist/store/pagePilot.d.ts +56 -0
- package/dist/store/session-persistence.d.ts +62 -0
- package/dist/store/suggestions.d.ts +58 -0
- package/dist/types/dom-scanner.d.ts +50 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/user-context.d.ts +32 -1
- package/dist/utils/debug.d.ts +150 -0
- package/dist/utils/dom-scanner.d.ts +70 -0
- package/dist/utils/markdown-components.d.ts +53 -0
- package/dist/utils/preact-markdown.d.ts +17 -0
- package/dist/utils/route-observer.d.ts +67 -0
- package/package.json +1 -1
- package/src/actions/types.ts +43 -2
- package/dist/utils/markdown.d.ts +0 -9
package/dist/pillar.esm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e={actions:new Map,clientInfo:null};function n(n,t){e.clientInfo={platform:n,version:t}}function t(){return e.clientInfo}function r(n){const t=e.actions.get(n);return t?.handler}function i(n){return e.actions.get(n)}function a(n){return e.actions.has(n)}function l(){return Array.from(e.actions.keys())}function o(n,t,r){const i=[];for(const[n,t]of e.actions){const e={name:n,description:t.description,type:t.type};t.examples?.length&&(e.examples=t.examples),t.path&&(e.path=t.path),t.externalUrl&&(e.external_url=t.externalUrl),t.autoRun&&(e.auto_run=t.autoRun),t.autoComplete&&(e.auto_complete=t.autoComplete),t.returns&&(e.returns_data=t.returns),t.dataSchema&&(e.data_schema=t.dataSchema),t.defaultData&&(e.default_data=t.defaultData),t.requiredContext&&(e.required_context=t.requiredContext),i.push(e)}return{platform:n,version:t,gitSha:r,generatedAt:(new Date).toISOString(),actions:i}}function s(){e.actions.clear(),e.clientInfo=null}function p(){return e.actions.size}class c{constructor(e){this.requestId=0,this.config=e}get baseUrl(){return`${this.config.apiBaseUrl}/mcp/`}get headers(){const e={"Content-Type":"application/json","x-customer-id":this.config.productKey};return"undefined"!=typeof navigator&&(e["Accept-Language"]=navigator.language||navigator.languages?.[0]||"en"),this.config.platform&&(e["X-Pillar-Platform"]=this.config.platform),this.config.version&&(e["X-Pillar-Action-Version"]=this.config.version),e}nextId(){return++this.requestId}async callTool(e,n){const t={jsonrpc:"2.0",id:this.nextId(),method:"tools/call",params:{name:e,arguments:n}},r=await fetch(this.baseUrl,{method:"POST",headers:this.headers,body:JSON.stringify(t)});if(!r.ok){const e=await r.json().catch(()=>({}));throw new Error(e.error?.message||`MCP error: ${r.status}`)}const i=await r.json();if(i.error)throw new Error(i.error.message);return i.result}async callToolStream(e,n,t,r){const i=this.nextId(),a={jsonrpc:"2.0",id:i,method:"tools/call",params:{name:e,arguments:n,stream:!0}},l=await fetch(this.baseUrl,{method:"POST",headers:{...this.headers,Accept:"text/event-stream"},body:JSON.stringify(a),signal:r});if(!l.ok){const e=await l.text();throw new Error(`MCP streaming request failed: ${l.statusText} - ${e}`)}if(!l.body)throw new Error("Response body is null");const o=l.body.getReader(),s=new TextDecoder;let p="",c=[],d=null;try{for(;;){const{done:e,value:n}=await o.read();if(e)break;p+=s.decode(n,{stream:!0});const r=p.split("\n");p=r.pop()||"";for(const e of r)if(e.trim()&&e.startsWith("data: "))try{const n=e.substring(6),r=JSON.parse(n);if("2.0"===r.jsonrpc){if(r.error)throw t.onError?.(r.error.message||"Unknown error"),new Error(r.error.message);if("notifications/progress"===r.method){const e=r.params?.progress;if(e)if("token"===e.kind&&e.token)c.push(e.token),t.onToken?.(e.token);else if("plan_created"===e.kind&&e.plan)t.onPlan?.(e.plan);else{if("cancelled"===e.kind)break;t.onProgress?.({kind:e.kind,message:e.message,progress_id:e.progress_id,metadata:{sources:e.sources||e.metadata?.sources,result_count:e.result_count??e.metadata?.result_count,query:e.query||e.metadata?.query,action_name:e.action_name||e.metadata?.action_name,no_sources_used:e.no_sources_used??e.metadata?.no_sources_used}})}}if(r.result&&r.id===i){d=r.result,d.structuredContent?.sources&&t.onSources?.(d.structuredContent.sources),d.structuredContent?.actions&&t.onActions?.(d.structuredContent.actions),d.structuredContent?.plan&&t.onPlan?.(d.structuredContent.plan);const e=d._meta?.conversation_id,n=d._meta?.query_log_id;t.onComplete?.(e,n)}}}catch(n){console.error("[MCPClient] Failed to parse event:",n,e)}}}catch(e){if("AbortError"===e.name)throw e;throw t.onError?.(e instanceof Error?e.message:"Stream reading failed"),e}finally{o.releaseLock()}return d||(d={content:[{type:"text",text:c.join("")}],isError:!1}),d}async uploadImage(e){const n=`${this.config.apiBaseUrl}/mcp/upload-image/`,t=new FormData;t.append("image",e);const r=await fetch(n,{method:"POST",headers:{"x-customer-id":this.config.productKey},body:t});if(!r.ok){const e=await r.json().catch(()=>({error:"Upload failed"}));throw new Error(e.error||"Upload failed")}return r.json()}async ask(e,n,t){const r={query:e};return t?.articleSlug&&(r.article_slug=t.articleSlug),t?.userContext&&t.userContext.length>0&&(r.user_context=t.userContext),t?.images&&t.images.length>0&&(r.images=t.images),this.callToolStream("ask",r,n,t?.signal)}async continuePlan(e,n,t){return await this.callTool("plans/continue",{plan_id:e,step_id:n,result:t})}async cancelPlan(e){return await this.callTool("plans/cancel",{plan_id:e})}async getPlan(e){return await this.callTool("plans/get",{plan_id:e})}async startPlan(e){return await this.callTool("plans/start",{plan_id:e})}async retryStep(e,n){return await this.callTool("plans/retry-step",{plan_id:e,step_id:n})}async failStep(e,n,t){return await this.callTool("plans/fail-step",{plan_id:e,step_id:n,error_message:t||""})}async skipStep(e,n){return await this.callTool("plans/skip-step",{plan_id:e,step_id:n})}sendActionResult(e,n){const t={jsonrpc:"2.0",id:this.nextId(),method:"action/result",params:{action_name:e,result:n}};fetch(this.baseUrl,{method:"POST",headers:this.headers,body:JSON.stringify(t)}).catch(e=>{console.error("[MCPClient] Failed to send action result:",e)})}}function d(e){return{id:e.id,name:e.name,taskType:e.action_type,data:e.data,autoRun:e.auto_run,autoComplete:e.auto_complete}}class u{constructor(e){this.abortControllers=new Map,this.config=e,this.mcpClient=new c(e)}get baseUrl(){return`${this.config.apiBaseUrl}/api/v1/help-center`}getVisitorId(){if("undefined"==typeof window)return"";const e="pillar_visitor_id";try{let n=localStorage.getItem(e);return n||(n=crypto.randomUUID(),localStorage.setItem(e,n)),n}catch{return""}}getSessionId(){if("undefined"==typeof window)return"";const e="pillar_session_id";try{let n=sessionStorage.getItem(e);return n||(n=crypto.randomUUID(),sessionStorage.setItem(e,n)),n}catch{return""}}getPageUrl(){return"undefined"==typeof window?"":window.location.href}get headers(){const e={"Content-Type":"application/json","x-customer-id":this.config.productKey,"x-visitor-id":this.getVisitorId(),"x-session-id":this.getSessionId(),"x-page-url":this.getPageUrl()};return this.config.platform&&(e["X-Pillar-Platform"]=this.config.platform),this.config.version&&(e["X-Pillar-Action-Version"]=this.config.version),e}async fetch(e,n={},t){if(t){this.abortControllers.get(t)?.abort();const e=new AbortController;this.abortControllers.set(t,e),n.signal=e.signal}const r=`${this.baseUrl}${e}`;try{const e=await fetch(r,{...n,headers:{...this.headers,...n.headers}});if(!e.ok){const n=await e.json().catch(()=>({}));throw new Error(n.detail||n.message||`API error: ${e.status}`)}return e.json()}catch(n){if("AbortError"===n.name)throw n;throw console.error(`[Pillar API] Error fetching ${e}:`,n),n}finally{t&&this.abortControllers.delete(t)}}async fetchEmbedConfig(){try{const e=await fetch(`${this.config.apiBaseUrl}/api/public/products/${this.config.productKey}/embed-config/`,{method:"GET",headers:{"Content-Type":"application/json"}});return e.ok?await e.json():(console.warn("[Pillar] Failed to fetch embed config:",e.status),null)}catch(e){return console.warn("[Pillar] Failed to fetch embed config:",e),null}}async getSuggestedQuestions(){try{const e=await this.mcpClient.callTool("suggest_questions",{}),n=e.structuredContent?.questions;return Array.isArray(n)?n:[]}catch(e){return console.warn("[Pillar] Failed to get suggested questions:",e),[]}}async uploadImage(e){return this.mcpClient.uploadImage(e)}async chat(e,n=[],t,r,i,a,l,o,s,p){let c="",u=[],h=[];try{const n=await this.mcpClient.ask(e,{onToken:e=>{c+=e,t?.(e)},onSources:e=>{u=e},onActions:e=>{h=e.map(d),a?.(h)},onPlan:e=>{l?.(e)},onProgress:e=>{p?.(e)},onError:e=>{console.error("[Pillar API] MCP chat error:",e)}},{articleSlug:r,userContext:o,images:s});c||"text"!==n.content[0]?.type||(c=n.content[0].text||"");const i=n._meta||{};return{message:c,sources:u,actions:h,conversationId:i.conversation_id,messageId:i.query_log_id}}catch(e){throw console.error("[Pillar API] Chat error:",e),e}}async chatLegacy(e,n=[],t,r,i){const a=`${this.baseUrl}/ai/chat/`,l=await fetch(a,{method:"POST",headers:this.headers,body:JSON.stringify({message:e,history:n,...r&&{article_slug:r},...i&&{conversation_id:i}})});if(!l.ok){const e=await l.json().catch(()=>({}));throw new Error(e.detail||e.message||`Chat error: ${l.status}`)}if(t&&l.headers.get("content-type")?.includes("text/event-stream"))return this.handleStreamingChat(l,t);const o=await l.json();return{message:o.answer||o.message,sources:o.sources,workflow:o.workflow||o.structuredContent?.workflow,conversationId:o.conversation_id,messageId:o.message_id}}async handleStreamingChat(e,n){const t=e.body?.getReader();if(!t)throw new Error("No response body");const r=new TextDecoder;let i,a,l,o="",s=[];try{for(;;){const{done:e,value:p}=await t.read();if(e)break;const c=r.decode(p,{stream:!0}).split("\n");for(const e of c)if(e.startsWith("data: ")){const t=e.slice(6);if("[DONE]"===t)continue;try{const e=JSON.parse(t);e.content&&(o+=e.content,n(e.content)),e.sources&&(s=e.sources),e.workflow&&(i=e.workflow),e.structuredContent?.workflow&&(i=e.structuredContent.workflow),e.conversation_id&&(a=e.conversation_id),e.message_id&&(l=e.message_id)}catch{o+=t,n(t)}}}}finally{t.releaseLock()}return{message:o,sources:s,workflow:i,conversationId:a,messageId:l}}async submitFeedback(e,n,t){try{await this.fetch("/ai/feedback/",{method:"POST",body:JSON.stringify({message_id:e,feedback:n,...t&&{comment:t}})})}catch(e){console.warn("[Pillar] Feedback submission failed:",e)}}async confirmTaskExecution(e,n,t){try{const r={status:n,error:t?.error,duration_ms:t?.duration_ms,session_id:t?.session_id,conversation_id:t?.conversation_id,metadata:t};await this.fetch(`/tasks/${e}/confirm/`,{method:"POST",body:JSON.stringify(r)})}catch(e){console.warn("[Pillar] Failed to confirm task execution:",e)}}async getSuggestions(e,n){try{return(await this.fetch("/suggestions/",{method:"POST",body:JSON.stringify({context:e,user_profile:n})})).suggestions||[]}catch(e){return console.warn("[Pillar] Failed to get suggestions:",e),[]}}async chatWithContext(e,n=[],t,r,i,a,l){let o="",s=[],p=[];try{const n=await this.mcpClient.callToolStream("ask",{query:e,context:{product:t,user_profile:r},...a&&{conversation_id:a}},{onToken:e=>{o+=e,i?.(e)},onSources:e=>{s=e},onActions:e=>{p=e.map(d),l?.(p)},onError:e=>{console.error("[Pillar API] MCP chat with context error:",e)}});o||"text"!==n.content[0]?.type||(o=n.content[0].text||"");const c=n._meta||{};return{message:o,sources:s,actions:p,conversationId:c.conversation_id,messageId:c.query_log_id}}catch(e){throw console.error("[Pillar API] Chat with context error:",e),e}}cancelAllRequests(){this.abortControllers.forEach(e=>e.abort()),this.abortControllers.clear()}}var h,g,f,_,m,v,b,x,y,k,w,S,C,P={},$=[],T=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,E=Array.isArray;function z(e,n){for(var t in n)e[t]=n[t];return e}function I(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function M(e,n,t,r,i){var a={type:e,props:n,key:t,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:null==i?++f:i,__i:-1,__u:0};return null==i&&null!=g.vnode&&g.vnode(a),a}function A(e){return e.children}function R(e,n){this.props=e,this.context=n}function j(e,n){if(null==n)return e.__?j(e.__,e.__i+1):null;for(var t;n<e.__k.length;n++)if(null!=(t=e.__k[n])&&null!=t.__e)return t.__e;return"function"==typeof e.type?j(e):null}function L(e){var n,t;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,n=0;n<e.__k.length;n++)if(null!=(t=e.__k[n])&&null!=t.__e){e.__e=e.__c.base=t.__e;break}return L(e)}}function B(e){(!e.__d&&(e.__d=!0)&&m.push(e)&&!H.__r++||v!=g.debounceRendering)&&((v=g.debounceRendering)||b)(H)}function H(){for(var e,n,t,r,i,a,l,o=1;m.length;)m.length>o&&m.sort(x),e=m.shift(),o=m.length,e.__d&&(t=void 0,r=void 0,i=(r=(n=e).__v).__e,a=[],l=[],n.__P&&((t=z({},r)).__v=r.__v+1,g.vnode&&g.vnode(t),W(n.__P,t,r,n.__n,n.__P.namespaceURI,32&r.__u?[i]:null,a,null==i?j(r):i,!!(32&r.__u),l),t.__v=r.__v,t.__.__k[t.__i]=t,K(a,t,l),r.__e=r.__=null,t.__e!=i&&L(t)));H.__r=0}function q(e,n,t,r,i,a,l,o,s,p,c){var d,u,h,g,f,_,m,v=r&&r.__k||$,b=n.length;for(s=function(e,n,t,r,i){var a,l,o,s,p,c=t.length,d=c,u=0;for(e.__k=new Array(i),a=0;a<i;a++)null!=(l=n[a])&&"boolean"!=typeof l&&"function"!=typeof l?("string"==typeof l||"number"==typeof l||"bigint"==typeof l||l.constructor==String?l=e.__k[a]=M(null,l,null,null,null):E(l)?l=e.__k[a]=M(A,{children:l},null,null,null):void 0===l.constructor&&l.__b>0?l=e.__k[a]=M(l.type,l.props,l.key,l.ref?l.ref:null,l.__v):e.__k[a]=l,s=a+u,l.__=e,l.__b=e.__b+1,o=null,-1!=(p=l.__i=D(l,t,s,d))&&(d--,(o=t[p])&&(o.__u|=2)),null==o||null==o.__v?(-1==p&&(i>c?u--:i<c&&u++),"function"!=typeof l.type&&(l.__u|=4)):p!=s&&(p==s-1?u--:p==s+1?u++:(p>s?u--:u++,l.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<c;a++)null!=(o=t[a])&&!(2&o.__u)&&(o.__e==r&&(r=j(o)),Q(o,o));return r}(t,n,v,s,b),d=0;d<b;d++)null!=(h=t.__k[d])&&(u=-1==h.__i?P:v[h.__i]||P,h.__i=d,_=W(e,h,u,i,a,l,o,s,p,c),g=h.__e,h.ref&&u.ref!=h.ref&&(u.ref&&G(u.ref,null,h),c.push(h.ref,h.__c||g,h)),null==f&&null!=g&&(f=g),(m=!!(4&h.__u))||u.__k===h.__k?s=O(h,s,e,m):"function"==typeof h.type&&void 0!==_?s=_:g&&(s=g.nextSibling),h.__u&=-7);return t.__e=f,s}function O(e,n,t,r){var i,a;if("function"==typeof e.type){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,n=O(i[a],n,t,r));return n}e.__e!=n&&(r&&(n&&e.type&&!n.parentNode&&(n=j(e)),t.insertBefore(e.__e,n||null)),n=e.__e);do{n=n&&n.nextSibling}while(null!=n&&8==n.nodeType);return n}function D(e,n,t,r){var i,a,l,o=e.key,s=e.type,p=n[t],c=null!=p&&!(2&p.__u);if(null===p&&null==o||c&&o==p.key&&s==p.type)return t;if(r>(c?1:0))for(i=t-1,a=t+1;i>=0||a<n.length;)if(null!=(p=n[l=i>=0?i--:a++])&&!(2&p.__u)&&o==p.key&&s==p.type)return l;return-1}function N(e,n,t){"-"==n[0]?e.setProperty(n,null==t?"":t):e[n]=null==t?"":"number"!=typeof t||T.test(n)?t:t+"px"}function U(e,n,t,r,i){var a,l;e:if("style"==n)if("string"==typeof t)e.style.cssText=t;else{if("string"==typeof r&&(e.style.cssText=r=""),r)for(n in r)t&&n in t||N(e.style,n,"");if(t)for(n in t)r&&t[n]==r[n]||N(e.style,n,t[n])}else if("o"==n[0]&&"n"==n[1])a=n!=(n=n.replace(y,"$1")),l=n.toLowerCase(),n=l in e||"onFocusOut"==n||"onFocusIn"==n?l.slice(2):n.slice(2),e.l||(e.l={}),e.l[n+a]=t,t?r?t.u=r.u:(t.u=k,e.addEventListener(n,a?S:w,a)):e.removeEventListener(n,a?S:w,a);else{if("http://www.w3.org/2000/svg"==i)n=n.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=n&&"height"!=n&&"href"!=n&&"list"!=n&&"form"!=n&&"tabIndex"!=n&&"download"!=n&&"rowSpan"!=n&&"colSpan"!=n&&"role"!=n&&"popover"!=n&&n in e)try{e[n]=null==t?"":t;break e}catch(e){}"function"==typeof t||(null==t||!1===t&&"-"!=n[4]?e.removeAttribute(n):e.setAttribute(n,"popover"==n&&1==t?"":t))}}function F(e){return function(n){if(this.l){var t=this.l[n.type+e];if(null==n.t)n.t=k++;else if(n.t<t.u)return;return t(g.event?g.event(n):n)}}}function W(e,n,t,r,i,a,l,o,s,p){var c,d,u,f,_,m,v,b,x,y,k,w,S,C,$,T,M,L=n.type;if(void 0!==n.constructor)return null;128&t.__u&&(s=!!(32&t.__u),a=[o=n.__e=t.__e]),(c=g.__b)&&c(n);e:if("function"==typeof L)try{if(b=n.props,x="prototype"in L&&L.prototype.render,y=(c=L.contextType)&&r[c.__c],k=c?y?y.props.value:c.__:r,t.__c?v=(d=n.__c=t.__c).__=d.__E:(x?n.__c=d=new L(b,k):(n.__c=d=new R(b,k),d.constructor=L,d.render=X),y&&y.sub(d),d.state||(d.state={}),d.__n=r,u=d.__d=!0,d.__h=[],d._sb=[]),x&&null==d.__s&&(d.__s=d.state),x&&null!=L.getDerivedStateFromProps&&(d.__s==d.state&&(d.__s=z({},d.__s)),z(d.__s,L.getDerivedStateFromProps(b,d.__s))),f=d.props,_=d.state,d.__v=n,u)x&&null==L.getDerivedStateFromProps&&null!=d.componentWillMount&&d.componentWillMount(),x&&null!=d.componentDidMount&&d.__h.push(d.componentDidMount);else{if(x&&null==L.getDerivedStateFromProps&&b!==f&&null!=d.componentWillReceiveProps&&d.componentWillReceiveProps(b,k),n.__v==t.__v||!d.__e&&null!=d.shouldComponentUpdate&&!1===d.shouldComponentUpdate(b,d.__s,k)){for(n.__v!=t.__v&&(d.props=b,d.state=d.__s,d.__d=!1),n.__e=t.__e,n.__k=t.__k,n.__k.some(function(e){e&&(e.__=n)}),w=0;w<d._sb.length;w++)d.__h.push(d._sb[w]);d._sb=[],d.__h.length&&l.push(d);break e}null!=d.componentWillUpdate&&d.componentWillUpdate(b,d.__s,k),x&&null!=d.componentDidUpdate&&d.__h.push(function(){d.componentDidUpdate(f,_,m)})}if(d.context=k,d.props=b,d.__P=e,d.__e=!1,S=g.__r,C=0,x){for(d.state=d.__s,d.__d=!1,S&&S(n),c=d.render(d.props,d.state,d.context),$=0;$<d._sb.length;$++)d.__h.push(d._sb[$]);d._sb=[]}else do{d.__d=!1,S&&S(n),c=d.render(d.props,d.state,d.context),d.state=d.__s}while(d.__d&&++C<25);d.state=d.__s,null!=d.getChildContext&&(r=z(z({},r),d.getChildContext())),x&&!u&&null!=d.getSnapshotBeforeUpdate&&(m=d.getSnapshotBeforeUpdate(f,_)),T=c,null!=c&&c.type===A&&null==c.key&&(T=Z(c.props.children)),o=q(e,E(T)?T:[T],n,t,r,i,a,l,o,s,p),d.base=n.__e,n.__u&=-161,d.__h.length&&l.push(d),v&&(d.__E=d.__=null)}catch(e){if(n.__v=null,s||null!=a)if(e.then){for(n.__u|=s?160:128;o&&8==o.nodeType&&o.nextSibling;)o=o.nextSibling;a[a.indexOf(o)]=null,n.__e=o}else{for(M=a.length;M--;)I(a[M]);V(n)}else n.__e=t.__e,n.__k=t.__k,e.then||V(n);g.__e(e,n,t)}else null==a&&n.__v==t.__v?(n.__k=t.__k,n.__e=t.__e):o=n.__e=function(e,n,t,r,i,a,l,o,s){var p,c,d,u,f,_,m,v=t.props||P,b=n.props,x=n.type;if("svg"==x?i="http://www.w3.org/2000/svg":"math"==x?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),null!=a)for(p=0;p<a.length;p++)if((f=a[p])&&"setAttribute"in f==!!x&&(x?f.localName==x:3==f.nodeType)){e=f,a[p]=null;break}if(null==e){if(null==x)return document.createTextNode(b);e=document.createElementNS(i,x,b.is&&b),o&&(g.__m&&g.__m(n,a),o=!1),a=null}if(null==x)v===b||o&&e.data==b||(e.data=b);else{if(a=a&&h.call(e.childNodes),!o&&null!=a)for(v={},p=0;p<e.attributes.length;p++)v[(f=e.attributes[p]).name]=f.value;for(p in v)if(f=v[p],"children"==p);else if("dangerouslySetInnerHTML"==p)d=f;else if(!(p in b)){if("value"==p&&"defaultValue"in b||"checked"==p&&"defaultChecked"in b)continue;U(e,p,null,f,i)}for(p in b)f=b[p],"children"==p?u=f:"dangerouslySetInnerHTML"==p?c=f:"value"==p?_=f:"checked"==p?m=f:o&&"function"!=typeof f||v[p]===f||U(e,p,f,v[p],i);if(c)o||d&&(c.__html==d.__html||c.__html==e.innerHTML)||(e.innerHTML=c.__html),n.__k=[];else if(d&&(e.innerHTML=""),q("template"==n.type?e.content:e,E(u)?u:[u],n,t,r,"foreignObject"==x?"http://www.w3.org/1999/xhtml":i,a,l,a?a[0]:t.__k&&j(t,0),o,s),null!=a)for(p=a.length;p--;)I(a[p]);o||(p="value","progress"==x&&null==_?e.removeAttribute("value"):null!=_&&(_!==e[p]||"progress"==x&&!_||"option"==x&&_!=v[p])&&U(e,p,_,v[p],i),p="checked",null!=m&&m!=e[p]&&U(e,p,m,v[p],i))}return e}(t.__e,n,t,r,i,a,l,s,p);return(c=g.diffed)&&c(n),128&n.__u?void 0:o}function V(e){e&&e.__c&&(e.__c.__e=!0),e&&e.__k&&e.__k.forEach(V)}function K(e,n,t){for(var r=0;r<t.length;r++)G(t[r],t[++r],t[++r]);g.__c&&g.__c(n,e),e.some(function(n){try{e=n.__h,n.__h=[],e.some(function(e){e.call(n)})}catch(e){g.__e(e,n.__v)}})}function Z(e){return"object"!=typeof e||null==e||e.__b&&e.__b>0?e:E(e)?e.map(Z):z({},e)}function G(e,n,t){try{if("function"==typeof e){var r="function"==typeof e.__u;r&&e.__u(),r&&null==n||(e.__u=e(n))}else e.current=n}catch(e){g.__e(e,t)}}function Q(e,n,t){var r,i;if(g.unmount&&g.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||G(r,null,n)),null!=(r=e.__c)){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){g.__e(e,n)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&Q(r[i],n,t||"function"!=typeof e.type);t||I(e.__e),e.__c=e.__=e.__e=void 0}function X(e,n,t){return this.constructor(e,t)}function J(e,n,t){var r,i,a;n==document&&(n=document.documentElement),g.__&&g.__(e,n),r=!1?null:n.__k,i=[],a=[],W(n,e=n.__k=function(e,n,t){var r,i,a,l={};for(a in n)"key"==a?r=n[a]:"ref"==a?i=n[a]:l[a]=n[a];if(arguments.length>2&&(l.children=arguments.length>3?h.call(arguments,2):t),"function"==typeof e&&null!=e.defaultProps)for(a in e.defaultProps)void 0===l[a]&&(l[a]=e.defaultProps[a]);return M(e,l,r,i,null)}(A,null,[e]),r||P,P,n.namespaceURI,r?null:n.firstChild?h.call(n.childNodes):null,i,r?r.__e:n.firstChild,false,a),K(i,e,a)}h=$.slice,g={__e:function(e,n,t,r){for(var i,a,l;n=n.__;)if((i=n.__c)&&!i.__)try{if((a=i.constructor)&&null!=a.getDerivedStateFromError&&(i.setState(a.getDerivedStateFromError(e)),l=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(e,r||{}),l=i.__d),l)return i.__E=i}catch(n){e=n}throw e}},f=0,_=function(e){return null!=e&&void 0===e.constructor},R.prototype.setState=function(e,n){var t;t=null!=this.__s&&this.__s!=this.state?this.__s:this.__s=z({},this.state),"function"==typeof e&&(e=e(z({},t),this.props)),e&&z(t,e),null!=e&&this.__v&&(n&&this._sb.push(n),B(this))},R.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),B(this))},R.prototype.render=A,m=[],b="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,x=function(e,n){return e.__v.__b-n.__v.__b},H.__r=0,y=/(PointerCapture)$|Capture$/i,k=0,w=F(!1),S=F(!0),C=0;var Y=0;function ee(e,n,t,r,i,a){n||(n={});var l,o,s=n;if("ref"in s)for(o in s={},n)"ref"==o?l=n[o]:s[o]=n[o];var p={type:e,props:s,key:t,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Y,__i:-1,__u:0,__source:i,__self:a};if("function"==typeof e&&(l=e.defaultProps))for(o in l)void 0===s[o]&&(s[o]=l[o]);return g.vnode&&g.vnode(p),p}var ne,te,re,ie,ae=0,le=[],oe=g,se=oe.__b,pe=oe.__r,ce=oe.diffed,de=oe.__c,ue=oe.unmount,he=oe.__;function ge(e,n){oe.__h&&oe.__h(te,e,ae||n),ae=0;var t=te.__H||(te.__H={__:[],__h:[]});return e>=t.__.length&&t.__.push({}),t.__[e]}function fe(e){return ae=1,function(e,n){var t=ge(ne++,2);if(t.t=e,!t.__c&&(t.__=[Pe(void 0,n),function(e){var n=t.__N?t.__N[0]:t.__[0],r=t.t(n,e);n!==r&&(t.__N=[r,t.__[1]],t.__c.setState({}))}],t.__c=te,!te.__f)){var r=function(e,n,r){if(!t.__c.__H)return!0;var a=t.__c.__H.__.filter(function(e){return!!e.__c});if(a.every(function(e){return!e.__N}))return!i||i.call(this,e,n,r);var l=t.__c.props!==e;return a.forEach(function(e){if(e.__N){var n=e.__[0];e.__=e.__N,e.__N=void 0,n!==e.__[0]&&(l=!0)}}),i&&i.call(this,e,n,r)||l};te.__f=!0;var i=te.shouldComponentUpdate,a=te.componentWillUpdate;te.componentWillUpdate=function(e,n,t){if(this.__e){var l=i;i=void 0,r(e,n,t),i=l}a&&a.call(this,e,n,t)},te.shouldComponentUpdate=r}return t.__N||t.__}(Pe,e)}function _e(e,n){var t=ge(ne++,3);!oe.__s&&Ce(t.__H,n)&&(t.__=e,t.u=n,te.__H.__h.push(t))}function me(e){return ae=5,ve(function(){return{current:e}},[])}function ve(e,n){var t=ge(ne++,7);return Ce(t.__H,n)&&(t.__=e(),t.__H=n,t.__h=e),t.__}function be(e,n){return ae=8,ve(function(){return e},n)}function xe(){for(var e;e=le.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(we),e.__H.__h.forEach(Se),e.__H.__h=[]}catch(n){e.__H.__h=[],oe.__e(n,e.__v)}}oe.__b=function(e){te=null,se&&se(e)},oe.__=function(e,n){e&&n.__k&&n.__k.__m&&(e.__m=n.__k.__m),he&&he(e,n)},oe.__r=function(e){pe&&pe(e),ne=0;var n=(te=e.__c).__H;n&&(re===te?(n.__h=[],te.__h=[],n.__.forEach(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(n.__h.forEach(we),n.__h.forEach(Se),n.__h=[],ne=0)),re=te},oe.diffed=function(e){ce&&ce(e);var n=e.__c;n&&n.__H&&(n.__H.__h.length&&(1!==le.push(n)&&ie===oe.requestAnimationFrame||((ie=oe.requestAnimationFrame)||ke)(xe)),n.__H.__.forEach(function(e){e.u&&(e.__H=e.u),e.u=void 0})),re=te=null},oe.__c=function(e,n){n.some(function(e){try{e.__h.forEach(we),e.__h=e.__h.filter(function(e){return!e.__||Se(e)})}catch(t){n.some(function(e){e.__h&&(e.__h=[])}),n=[],oe.__e(t,e.__v)}}),de&&de(e,n)},oe.unmount=function(e){ue&&ue(e);var n,t=e.__c;t&&t.__H&&(t.__H.__.forEach(function(e){try{we(e)}catch(e){n=e}}),t.__H=void 0,n&&oe.__e(n,t.__v))};var ye="function"==typeof requestAnimationFrame;function ke(e){var n,t=function(){clearTimeout(r),ye&&cancelAnimationFrame(n),setTimeout(e)},r=setTimeout(t,35);ye&&(n=requestAnimationFrame(t))}function we(e){var n=te,t=e.__c;"function"==typeof t&&(e.__c=void 0,t()),te=n}function Se(e){var n=te;e.__c=e.__(),te=n}function Ce(e,n){return!e||e.length!==n.length||n.some(function(n,t){return n!==e[t]})}function Pe(e,n){return"function"==typeof n?n(e):n}var $e=Symbol.for("preact-signals");function Te(){if(Ae>1)Ae--;else{for(var e,n=!1;void 0!==Me;){var t=Me;for(Me=void 0,Re++;void 0!==t;){var r=t.o;if(t.o=void 0,t.f&=-3,!(8&t.f)&&qe(t))try{t.c()}catch(t){n||(e=t,n=!0)}t=r}}if(Re=0,Ae--,n)throw e}}var Ee=void 0;function ze(e){var n=Ee;Ee=void 0;try{return e()}finally{Ee=n}}var Ie,Me=void 0,Ae=0,Re=0,je=0;function Le(e){if(void 0!==Ee){var n=e.n;if(void 0===n||n.t!==Ee)return n={i:0,S:e,p:Ee.s,n:void 0,t:Ee,e:void 0,x:void 0,r:n},void 0!==Ee.s&&(Ee.s.n=n),Ee.s=n,e.n=n,32&Ee.f&&e.S(n),n;if(-1===n.i)return n.i=0,void 0!==n.n&&(n.n.p=n.p,void 0!==n.p&&(n.p.n=n.n),n.p=Ee.s,n.n=void 0,Ee.s.n=n,Ee.s=n),n}}function Be(e,n){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.W=null==n?void 0:n.watched,this.Z=null==n?void 0:n.unwatched,this.name=null==n?void 0:n.name}function He(e,n){return new Be(e,n)}function qe(e){for(var n=e.s;void 0!==n;n=n.n)if(n.S.i!==n.i||!n.S.h()||n.S.i!==n.i)return!0;return!1}function Oe(e){for(var n=e.s;void 0!==n;n=n.n){var t=n.S.n;if(void 0!==t&&(n.r=t),n.S.n=n,n.i=-1,void 0===n.n){e.s=n;break}}}function De(e){for(var n=e.s,t=void 0;void 0!==n;){var r=n.p;-1===n.i?(n.S.U(n),void 0!==r&&(r.n=n.n),void 0!==n.n&&(n.n.p=r)):t=n,n.S.n=n.r,void 0!==n.r&&(n.r=void 0),n=r}e.s=t}function Ne(e,n){Be.call(this,void 0),this.x=e,this.s=void 0,this.g=je-1,this.f=4,this.W=null==n?void 0:n.watched,this.Z=null==n?void 0:n.unwatched,this.name=null==n?void 0:n.name}function Ue(e,n){return new Ne(e,n)}function Fe(e){var n=e.u;if(e.u=void 0,"function"==typeof n){Ae++;var t=Ee;Ee=void 0;try{n()}catch(n){throw e.f&=-2,e.f|=8,We(e),n}finally{Ee=t,Te()}}}function We(e){for(var n=e.s;void 0!==n;n=n.n)n.S.U(n);e.x=void 0,e.s=void 0,Fe(e)}function Ve(e){if(Ee!==this)throw new Error("Out-of-order effect");De(this),Ee=e,this.f&=-2,8&this.f&&We(this),Te()}function Ke(e,n){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==n?void 0:n.name}function Ze(e,n){var t=new Ke(e,n);try{t.c()}catch(e){throw t.d(),e}var r=t.d.bind(t);return r[Symbol.dispose]=r,r}function Ge(e,n){g[e]=n.bind(null,g[e]||function(){})}function Qe(e){Ie&&Ie(),Ie=e&&e.S()}function Xe(e){var n=this,t=e.data,r=function(e){return ve(function(){return He(e)},[])}(t);r.value=t;var i=ve(function(){for(var e=n.__v;e=e.__;)if(e.__c){e.__c.__$f|=4;break}return n.__$u.c=function(){var e,t=n.__$u.S(),r=i.value;t(),_(r)||3!==(null==(e=n.base)?void 0:e.nodeType)?(n.__$f|=1,n.setState({})):n.base.data=r},Ue(function(){var e=r.value.value;return 0===e?0:!0===e?"":e||""})},[]);return i.value}function Je(e,n,t,r){var i=n in e&&void 0===e.ownerSVGElement,a=He(t);return{o:function(e,n){a.value=e,r=n},d:Ze(function(){var t=a.value.value;r[n]!==t&&(r[n]=t,i?e[n]=t:t?e.setAttribute(n,t):e.removeAttribute(n))})}}Be.prototype.brand=$e,Be.prototype.h=function(){return!0},Be.prototype.S=function(e){var n=this,t=this.t;t!==e&&void 0===e.e&&(e.x=t,this.t=e,void 0!==t?t.e=e:ze(function(){var e;null==(e=n.W)||e.call(n)}))},Be.prototype.U=function(e){var n=this;if(void 0!==this.t){var t=e.e,r=e.x;void 0!==t&&(t.x=r,e.e=void 0),void 0!==r&&(r.e=t,e.x=void 0),e===this.t&&(this.t=r,void 0===r&&ze(function(){var e;null==(e=n.Z)||e.call(n)}))}},Be.prototype.subscribe=function(e){var n=this;return Ze(function(){var t=n.value,r=Ee;Ee=void 0;try{e(t)}finally{Ee=r}},{name:"sub"})},Be.prototype.valueOf=function(){return this.value},Be.prototype.toString=function(){return this.value+""},Be.prototype.toJSON=function(){return this.value},Be.prototype.peek=function(){var e=Ee;Ee=void 0;try{return this.value}finally{Ee=e}},Object.defineProperty(Be.prototype,"value",{get:function(){var e=Le(this);return void 0!==e&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Re>100)throw new Error("Cycle detected");this.v=e,this.i++,je++,Ae++;try{for(var n=this.t;void 0!==n;n=n.x)n.t.N()}finally{Te()}}}}),Ne.prototype=new Be,Ne.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===je)return!0;if(this.g=je,this.f|=1,this.i>0&&!qe(this))return this.f&=-2,!0;var e=Ee;try{Oe(this),Ee=this;var n=this.x();(16&this.f||this.v!==n||0===this.i)&&(this.v=n,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return Ee=e,De(this),this.f&=-2,!0},Ne.prototype.S=function(e){if(void 0===this.t){this.f|=36;for(var n=this.s;void 0!==n;n=n.n)n.S.S(n)}Be.prototype.S.call(this,e)},Ne.prototype.U=function(e){if(void 0!==this.t&&(Be.prototype.U.call(this,e),void 0===this.t)){this.f&=-33;for(var n=this.s;void 0!==n;n=n.n)n.S.U(n)}},Ne.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;void 0!==e;e=e.x)e.t.N()}},Object.defineProperty(Ne.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Le(this);if(this.h(),void 0!==e&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),Ke.prototype.c=function(){var e=this.S();try{if(8&this.f)return;if(void 0===this.x)return;var n=this.x();"function"==typeof n&&(this.u=n)}finally{e()}},Ke.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Fe(this),Oe(this),Ae++;var e=Ee;return Ee=this,Ve.bind(this,e)},Ke.prototype.N=function(){2&this.f||(this.f|=2,this.o=Me,Me=this)},Ke.prototype.d=function(){this.f|=8,1&this.f||We(this)},Ke.prototype.dispose=function(){this.d()},Xe.displayName="_st",Object.defineProperties(Be.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:Xe},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}}),Ge("__b",function(e,n){if("string"==typeof n.type){var t,r=n.props;for(var i in r)if("children"!==i){var a=r[i];a instanceof Be&&(t||(n.__np=t={}),t[i]=a,r[i]=a.peek())}}e(n)}),Ge("__r",function(e,n){Qe();var t,r=n.__c;r&&(r.__$f&=-2,void 0===(t=r.__$u)&&(r.__$u=t=function(){var e;return Ze(function(){e=this}),e.c=function(){r.__$f|=1,r.setState({})},e}())),Qe(t),e(n)}),Ge("__e",function(e,n,t,r){Qe(),e(n,t,r)}),Ge("diffed",function(e,n){var t;if(Qe(),"string"==typeof n.type&&(t=n.__e)){var r=n.__np,i=n.props;if(r){var a=t.U;if(a)for(var l in a){var o=a[l];void 0===o||l in r||(o.d(),a[l]=void 0)}else t.U=a={};for(var s in r){var p=a[s],c=r[s];void 0===p?(p=Je(t,s,c,i),a[s]=p):p.o(c,i)}}}e(n)}),Ge("unmount",function(e,n){if("string"==typeof n.type){var t=n.__e;if(t){var r=t.U;if(r)for(var i in t.U=void 0,r){var a=r[i];a&&a.d()}}}else{var l=n.__c;if(l){var o=l.__$u;o&&(l.__$u=void 0,o.d())}}e(n)}),Ge("__h",function(e,n,t,r){(r<3||9===r)&&(n.__$f|=2),e(n,t,r)}),R.prototype.shouldComponentUpdate=function(e,n){var t=this.__$u,r=t&&void 0!==t.s;for(var i in n)return!0;if(this.__f||"boolean"==typeof this.u&&!0===this.u){if(!(r||2&this.__$f||4&this.__$f))return!0;if(1&this.__$f)return!0}else{if(!(r||4&this.__$f))return!0;if(3&this.__$f)return!0}for(var a in e)if("__source"!==a&&e[a]!==this.props[a])return!0;for(var l in this.props)if(!(l in e))return!0;return!1};const Ye=He(!1),en=He("assistant"),nn=He("right"),tn=He("overlay"),rn=He(380),an=He(1200),ln=He(!0),on=He(700),sn=He(500),pn=He("undefined"!=typeof window?window.innerWidth:1920);let cn=null;const dn=Ue(()=>{const e=an.value;return!1!==e&&pn.value<e}),un=Ue(()=>pn.value<on.value),hn=Ue(()=>pn.value<sn.value),gn=Ue(()=>dn.value?"overlay":tn.value);Ue(()=>{const e=["pillar-panel",`pillar-panel--${nn.value}`];return Ye.value&&e.push("pillar-panel--open"),e.join(" ")});const fn=()=>{Ye.value=!1,"overlay"===gn.value&&(document.body.style.overflow="")},_n=()=>{Ye.value=!1,en.value="assistant",document.body.style.overflow=""};function mn(e,n,t){const r=document.createElement("style");return t&&(r.id=t),r.textContent=n,e instanceof Document?e.head.appendChild(r):e.appendChild(r),r}const vn={help:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"></path><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>',support:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 18v-6a9 9 0 0 1 18 0v6"></path><path d="M21 19a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3zM3 19a2 2 0 0 0 2 2h1a2 2 0 0 0 2-2v-3a2 2 0 0 0-2-2H3z"></path></svg>',settings:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"></path><circle cx="12" cy="12" r="3"></circle></svg>',feedback:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path></svg>',chat:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"></path></svg>',calendar:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line></svg>',mail:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path><polyline points="22,6 12,13 2,6"></polyline></svg>'},bn={assistant:vn.help,support:vn.support};function xn({position:e,tabs:n,currentActiveTab:t,onTabClick:r,panelOpen:i,panelWidthPx:a,theme:l}){const o=be(e=>{r(e)},[r]),s=["pillar-edge-sidebar",`pillar-edge-sidebar--${e}`,"pillar-edge-sidebar--mounted",i&&"pillar-edge-sidebar--panel-open","light"===l&&"pillar-edge-sidebar--light","dark"===l&&"pillar-edge-sidebar--dark"].filter(Boolean).join(" "),p={"--pillar-panel-width":`${a}px`},c=n.filter(e=>e.enabled).sort((e,n)=>e.order-n.order);return ee("div",{class:s,style:p,children:c.map(e=>{return ee("button",{class:["pillar-edge-trigger",i&&t===e.id&&"pillar-edge-trigger--active"].filter(Boolean).join(" "),onClick:()=>o(e.id),"aria-label":e.label||"Help",type:"button",children:[ee("span",{class:"pillar-edge-trigger__icon",dangerouslySetInnerHTML:{__html:(n=e.id,r=e.icon,r&&r in vn?vn[r]:bn[n]||vn.help)}}),ee("span",{class:"pillar-edge-trigger__label",children:e.label})]},e.id);var n,r})})}class yn{constructor(e,n,t,r){this.container=null,this.stylesInjected=!1,this.themeStylesInjected=!1,this._isHidden=!1,this.unsubscribeOpen=null,this.unsubscribeWidth=null,this.unsubscribeHoverMode=null,this.unsubscribeMobileMode=null,this.unsubscribeActiveTab=null,this.themeObserver=null,this.currentTheme="light",this.handleTabClick=e=>{if("assistant"!==e){const n=this.config.sidebarTabs.find(n=>n.id===e);return this.events.emit("sidebar:click",{tabId:e,label:n?.label||e}),void("support"===e&&this.events.emit("support:request",{tabId:e}))}(e=>{en.value=e})(e),Ye.value||this.onClick(),this.render()},this.config=e,this.events=n,this.onClick=t,this.rootContainer=r||null}getEdgePosition(){return this.config.panel.position}detectTheme(){const e=document.documentElement;if(e.classList.contains("dark"))return"dark";return"dark"===e.getAttribute("data-theme")||"dark"===e.style.colorScheme?"dark":"light"}init(){if(this.stylesInjected||(mn(document,"\n/* Sidebar container - always visible, shifts when panel opens */\n.pillar-edge-sidebar {\n position: fixed;\n top: 0;\n bottom: 0;\n width: 48px;\n z-index: 100000;\n display: flex;\n flex-direction: column;\n align-items: center;\n background: var(--pillar-bg);\n border-left: 1px solid var(--pillar-border);\n transition: right 0.3s ease, left 0.3s ease;\n}\n\n.pillar-edge-sidebar--right {\n right: 0;\n border-left: 1px solid var(--pillar-border);\n border-right: none;\n}\n\n.pillar-edge-sidebar--left {\n left: 0;\n border-right: 1px solid var(--pillar-border);\n border-left: none;\n}\n\n/* When panel is open, shift the trigger to sit at the panel's outer edge */\n.pillar-edge-sidebar--right.pillar-edge-sidebar--panel-open {\n right: var(--pillar-panel-width, 380px);\n}\n\n.pillar-edge-sidebar--left.pillar-edge-sidebar--panel-open {\n left: var(--pillar-panel-width, 380px);\n}\n\n/* The trigger button - vertical sideways text */\n.pillar-edge-trigger {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 16px 8px;\n margin-top: 8px;\n font-family: var(--pillar-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif);\n font-size: 12px;\n font-weight: 500;\n color: var(--pillar-text-muted);\n background: transparent;\n border: none;\n border-radius: 6px;\n cursor: pointer;\n transition: background 0.15s ease, color 0.15s ease;\n outline: none;\n gap: 8px;\n writing-mode: vertical-rl;\n text-orientation: mixed;\n}\n\n.pillar-edge-trigger:hover {\n background: var(--pillar-bg-secondary);\n color: var(--pillar-primary);\n}\n\n.pillar-edge-trigger--active {\n background: var(--pillar-primary-light, rgba(194, 65, 12, 0.1));\n color: var(--pillar-primary);\n}\n\n.pillar-edge-trigger--active .pillar-edge-trigger__icon {\n opacity: 1;\n color: var(--pillar-primary);\n}\n\n.pillar-edge-trigger:focus-visible {\n background: var(--pillar-bg-secondary);\n box-shadow: 0 0 0 2px var(--pillar-primary);\n}\n\n.pillar-edge-trigger__icon {\n width: 20px;\n height: 20px;\n flex-shrink: 0;\n opacity: 0.8;\n}\n\n.pillar-edge-trigger:hover .pillar-edge-trigger__icon {\n opacity: 1;\n color: var(--pillar-primary);\n}\n\n.pillar-edge-trigger__label {\n white-space: nowrap;\n letter-spacing: 0.5px;\n}\n\n/* Animation on mount */\n@keyframes pillar-sidebar-mount {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n}\n\n.pillar-edge-sidebar--mounted {\n animation: pillar-sidebar-mount 0.2s ease forwards;\n}\n","pillar-edge-trigger-styles"),this.stylesInjected=!0),!this.themeStylesInjected){const e=function(e,n){const t=e=>{const n=[];return e.primary&&n.push(`--pillar-primary: ${e.primary};`),e.primaryHover&&n.push(`--pillar-primary-hover: ${e.primaryHover};`),e.background&&n.push(`--pillar-bg: ${e.background};`),e.backgroundSecondary&&n.push(`--pillar-bg-secondary: ${e.backgroundSecondary};`),e.text&&n.push(`--pillar-text: ${e.text};`),e.textMuted&&n.push(`--pillar-text-muted: ${e.textMuted};`),e.border&&n.push(`--pillar-border: ${e.border};`),e.borderLight&&n.push(`--pillar-border-light: ${e.borderLight};`),n.join("\n ")},r=t(e),i=t(n);let a="";return r&&(a+=`\n.pillar-edge-sidebar,\n.pillar-edge-sidebar--light {\n ${r}\n}\n`),i&&(a+=`\n.pillar-edge-sidebar--dark {\n ${i}\n}\n`),a}(this.config.theme.colors,this.config.theme.darkColors);e&&mn(document,e,"pillar-edge-trigger-theme"),this.themeStylesInjected=!0}this.container=document.createElement("div"),this.container.id="pillar-edge-trigger-container";(this.rootContainer||document.body).appendChild(this.container),this.currentTheme=this.detectTheme(),this.applyLayoutPadding(),this.render(),this.unsubscribeOpen=Ye.subscribe(()=>{this.render(),queueMicrotask(()=>this.applyLayoutPadding())}),this.unsubscribeWidth=rn.subscribe(()=>{this.render(),queueMicrotask(()=>this.applyLayoutPadding())}),this.unsubscribeHoverMode=dn.subscribe(()=>{queueMicrotask(()=>this.applyLayoutPadding())}),this.unsubscribeMobileMode=un.subscribe(e=>{e?this.hide():this.show()}),un.value&&this.hide(),this.unsubscribeActiveTab=en.subscribe(()=>{this.render()}),this.themeObserver=new MutationObserver(()=>{const e=this.detectTheme();e!==this.currentTheme&&(this.currentTheme=e,this.render())}),this.themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme","style"]})}applyLayoutPadding(){if(this._isHidden)return;const e=this.getEdgePosition(),n=rn.value,t=dn.value;let r=48;Ye.value&&!t&&(r=n+48),document.documentElement.style.transition="padding 0.3s ease","right"===e?document.documentElement.style.paddingRight=`${r}px`:document.documentElement.style.paddingLeft=`${r}px`}removeLayoutPadding(){"right"===this.getEdgePosition()?document.documentElement.style.paddingRight="":document.documentElement.style.paddingLeft=""}setOpen(e){this.render()}show(){this._isHidden=!1,this.container&&(this.container.style.display=""),this.applyLayoutPadding(),this.render()}hide(){this._isHidden=!0,this.container&&(this.container.style.display="none"),this.removeLayoutPadding()}setPosition(e){this.removeLayoutPadding(),this.config.panel.position=e,this.applyLayoutPadding(),this.render()}destroy(){this.unsubscribeOpen?.(),this.unsubscribeOpen=null,this.unsubscribeWidth?.(),this.unsubscribeWidth=null,this.unsubscribeHoverMode?.(),this.unsubscribeHoverMode=null,this.unsubscribeMobileMode?.(),this.unsubscribeMobileMode=null,this.unsubscribeActiveTab?.(),this.unsubscribeActiveTab=null,this.themeObserver?.disconnect(),this.themeObserver=null,this.removeLayoutPadding(),this.container&&(J(null,this.container),this.container.remove()),this.container=null,document.getElementById("pillar-edge-trigger-styles")?.remove(),document.getElementById("pillar-edge-trigger-theme")?.remove(),this.stylesInjected=!1,this.themeStylesInjected=!1}render(){if(!this.container||this._isHidden)return;J(ee(xn,{position:this.getEdgePosition(),tabs:this.config.sidebarTabs,currentActiveTab:en.value,onTabClick:this.handleTabClick,panelOpen:Ye.value,panelWidthPx:rn.value,theme:this.currentTheme}),this.container)}}const kn={sparkle:'<svg viewBox="0 0 16 16" fill="currentColor"><path d="M8.8 8.44L9.497 11l.697-2.56c.175-.643.263-.965.435-1.23a2 2 0 0 1 .583-.583c.263-.172.585-.259 1.23-.435l2.56-.697l-2.56-.697c-.643-.175-.964-.263-1.23-.435a2 2 0 0 1-.583-.583c-.172-.263-.259-.585-.435-1.23L9.497-.01L8.8 2.55c-.175.643-.263.965-.435 1.23a2 2 0 0 1-.583.583c-.263.172-.585.259-1.23.435l-2.56.697l2.56.697c.643.175.965.263 1.23.435a2 2 0 0 1 .583.583c.172.263.259.585.435 1.23M2.68 13.7c.169.244.264.542.456 1.14l.362 1.12l.362-1.12c.191-.595.287-.893.456-1.14c.149-.216.34-.4.561-.543c.249-.161.55-.247 1.15-.418l.971-.277l-.971-.277c-.601-.172-.902-.258-1.15-.418a2 2 0 0 1-.561-.543c-.169-.244-.264-.542-.456-1.14l-.362-1.12l-.362 1.12c-.191.595-.287.893-.456 1.14c-.149.216-.34.4-.561.543c-.249.161-.55.247-1.15.418l-.971.277l.971.277c.601.172.902.258 1.15.418a2 2 0 0 1 .561.543"/></svg>',question:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"></path><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>',help:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"></path><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>',chat:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"></path></svg>',support:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 18v-6a9 9 0 0 1 18 0v6"></path><path d="M21 19a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3zM3 19a2 2 0 0 0 2 2h1a2 2 0 0 0 2-2v-3a2 2 0 0 0-2-2H3z"></path></svg>'},wn={small:44,medium:56,large:68};function Sn({position:e,icon:n,backgroundColor:t,iconColor:r,size:i,label:a,offset:l,panelOpen:o,onClick:s}){const p=be(()=>{s()},[s]);return ee("button",{class:["pillar-mobile-trigger",`pillar-mobile-trigger--${e}`,"pillar-mobile-trigger--mounted",o&&"pillar-mobile-trigger--hidden"].filter(Boolean).join(" "),style:{"--pillar-mobile-offset":`${l}px`,"--pillar-mobile-bg":t,width:`${i}px`,height:`${i}px`,backgroundColor:t,color:r},onClick:p,"aria-label":a,title:a,type:"button",children:ee("span",{class:"pillar-mobile-trigger__icon",dangerouslySetInnerHTML:{__html:n}})})}class Cn{constructor(e,n,t,r){this.container=null,this.stylesInjected=!1,this._isEnabled=!0,this.unsubscribeMobileMode=null,this.unsubscribeOpen=null,this.config=e,this.events=n,this.onClick=t,this.rootContainer=r||null,this._isEnabled=e.mobileTrigger.enabled}getSize(){const e=this.config.mobileTrigger.size;return"number"==typeof e?e:wn[e]}getIcon(){const{customIcon:e,icon:n}=this.config.mobileTrigger;return e||kn[n]}getBackgroundColor(){const{backgroundColor:e}=this.config.mobileTrigger;return e||(this.config.theme.colors.primary||"#c2410c")}init(){if(!this._isEnabled)return;this.stylesInjected||(mn(document,"\n/* Mobile trigger floating button */\n.pillar-mobile-trigger {\n position: fixed;\n z-index: 100000;\n display: flex;\n align-items: center;\n justify-content: center;\n border: none;\n border-radius: 50%;\n cursor: pointer;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);\n transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;\n outline: none;\n -webkit-tap-highlight-color: transparent;\n}\n\n.pillar-mobile-trigger:hover {\n transform: scale(1.05);\n box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2), 0 3px 6px rgba(0, 0, 0, 0.12);\n}\n\n.pillar-mobile-trigger:active {\n transform: scale(0.95);\n}\n\n.pillar-mobile-trigger:focus-visible {\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1), 0 0 0 3px rgba(255, 255, 255, 0.5), 0 0 0 5px var(--pillar-mobile-bg, #c2410c);\n}\n\n/* Position variants */\n.pillar-mobile-trigger--bottom-right {\n bottom: var(--pillar-mobile-offset, 24px);\n right: var(--pillar-mobile-offset, 24px);\n}\n\n.pillar-mobile-trigger--bottom-left {\n bottom: var(--pillar-mobile-offset, 24px);\n left: var(--pillar-mobile-offset, 24px);\n}\n\n/* Icon styling */\n.pillar-mobile-trigger__icon {\n width: 55%;\n height: 55%;\n flex-shrink: 0;\n transform: translateY(-1px);\n}\n\n/* Hidden state (when panel is open) */\n.pillar-mobile-trigger--hidden {\n opacity: 0 !important;\n pointer-events: none;\n transform: scale(0.8) !important;\n visibility: hidden;\n}\n\n/* Animation on mount */\n@keyframes pillar-mobile-trigger-mount {\n from {\n opacity: 0;\n transform: scale(0.8);\n }\n to {\n opacity: 1;\n transform: scale(1);\n }\n}\n\n.pillar-mobile-trigger--mounted {\n animation: pillar-mobile-trigger-mount 0.2s ease forwards;\n}\n","pillar-mobile-trigger-styles"),this.stylesInjected=!0),this.container=document.createElement("div"),this.container.id="pillar-mobile-trigger-container";(this.rootContainer||document.body).appendChild(this.container),this.unsubscribeMobileMode=un.subscribe(()=>{this.render()}),this.unsubscribeOpen=Ye.subscribe(()=>{this.render()}),this.render()}show(){this._isEnabled=!0,this.render()}hide(){this._isEnabled=!1,this.render()}get isVisible(){return this._isEnabled&&un.value&&!Ye.value}destroy(){this.unsubscribeMobileMode?.(),this.unsubscribeMobileMode=null,this.unsubscribeOpen?.(),this.unsubscribeOpen=null,this.container&&(J(null,this.container),this.container.remove()),this.container=null,document.getElementById("pillar-mobile-trigger-styles")?.remove(),this.stylesInjected=!1}render(){if(!this.container)return;if(!this._isEnabled||!un.value)return void J(null,this.container);const{position:e,iconColor:n,label:t,offset:r}=this.config.mobileTrigger;J(ee(Sn,{position:e,icon:this.getIcon(),backgroundColor:this.getBackgroundColor(),iconColor:n,size:this.getSize(),label:t,offset:r,panelOpen:Ye.value,onClick:this.onClick}),this.container)}}function Pn(e){return"highlighted_text"===e.type}const $n=He([]),Tn=He(null),En=He(!1),zn=He({kind:null}),In=He([]),Mn=He(!1),An=He([]),Rn=He([]),jn=He(""),Ln=He(null),Bn=He(0),Hn=He(0),qn=He([]),On=He([]),Dn=He([]),Nn=Ue(()=>Dn.value.some(e=>"uploading"===e.status)),Un=(e,n,t,r)=>{Dn.value=Dn.value.map(i=>i.id===e?{...i,status:n,url:t,error:r}:i)},Fn=()=>{Dn.value.forEach(e=>URL.revokeObjectURL(e.preview)),Dn.value=[]},Wn=Ue(()=>$n.value.length>0),Vn=(e,n,t,r)=>{const i=$n.value;if(i.length>0&&"assistant"===i[i.length-1].role){const a=i[i.length-1];$n.value=[...i.slice(0,-1),{role:"assistant",content:void 0!==e?e:a.content,id:n??a.id,actions:t??a.actions,sources:r??a.sources,actionStatus:a.actionStatus}]}},Kn=e=>{En.value=e},Zn=()=>{In.value=[]},Gn=e=>{Ln.value=e},Qn=()=>{Bn.value+=1},Xn=()=>{Hn.value+=1},Jn=e=>{qn.value=qn.value.filter(n=>n.id!==e)},Yn=()=>{$n.value=[],Tn.value=null,En.value=!1,zn.value={kind:null},In.value=[],Mn.value=!1,An.value=[],Rn.value=[],jn.value="",Ln.value=null,Bn.value=0,qn.value=[],On.value=[],Fn()},et=He([]),nt=He({type:"home"}),tt=Ue(()=>et.value.length>0),rt=Ue(()=>"home"===nt.value.type),it=(e,n)=>{et.value=[...et.value,{...nt.value}],nt.value={type:e,params:n}},at=()=>{const e=et.value;if(e.length>0){"chat"===nt.value.type&&Yn();const n=e[e.length-1];nt.value=n,et.value=e.slice(0,-1)}},lt=()=>{"chat"===nt.value.type&&Yn(),et.value=[],nt.value={type:"home"}},ot=()=>{et.value=[],nt.value={type:"home"}},st=()=>{it("chat"),Qn()},pt='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20,6 9,17 4,12"/></svg>',ct='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>';function dt(e){return e.split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function ut(e,n){const t=document.createElement("div");t.className="pillar-confirm-card";const r=dt(e.data?.card_type||e.name),i=e.data||{};let a="idle",l="";const o=()=>{if("success"!==a){if("error"===a)return t.innerHTML=`\n <div class="pillar-confirm-card__content">\n <div class="pillar-confirm-card__header">\n <span class="pillar-confirm-card__title">${r}</span>\n </div>\n <div class="pillar-confirm-card__error">\n <span>${l||"An error occurred"}</span>\n </div>\n <div class="pillar-confirm-card__actions">\n <button type="button" class="pillar-confirm-card__btn pillar-confirm-card__btn--secondary js-cancel">\n ${ct} Dismiss\n </button>\n </div>\n </div>\n `,void t.querySelector(".js-cancel")?.addEventListener("click",n.onCancel);t.innerHTML=`\n <div class="pillar-confirm-card__content">\n <div class="pillar-confirm-card__header">\n <span class="pillar-confirm-card__title">${r}</span>\n </div>\n ${function(e){const n=Object.entries(e).filter(([e])=>"card_type"!==e).slice(0,5);return 0===n.length?"":`\n <div class="pillar-confirm-card__data">\n ${n.map(([e,n])=>{const t=Array.isArray(n)?n.join(", "):String(n);return`\n <div class="pillar-confirm-card__data-row">\n <span class="pillar-confirm-card__data-key">${dt(e)}:</span>\n <span class="pillar-confirm-card__data-value">${t}</span>\n </div>\n `}).join("")}\n </div>\n `}(i)}\n <div class="pillar-confirm-card__actions">\n <button type="button" class="pillar-confirm-card__btn pillar-confirm-card__btn--secondary js-cancel" ${"loading"===a?"disabled":""}>\n ${ct} Cancel\n </button>\n <button type="button" class="pillar-confirm-card__btn pillar-confirm-card__btn--primary js-confirm" ${"loading"===a?"disabled":""}>\n ${"loading"===a?'<span class="pillar-confirm-card__spinner"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="2" x2="12" y2="6"/><line x1="12" y1="18" x2="12" y2="22"/><line x1="4.93" y1="4.93" x2="7.76" y2="7.76"/><line x1="16.24" y1="16.24" x2="19.07" y2="19.07"/><line x1="2" y1="12" x2="6" y2="12"/><line x1="18" y1="12" x2="22" y2="12"/><line x1="4.93" y1="19.07" x2="7.76" y2="16.24"/><line x1="16.24" y1="7.76" x2="19.07" y2="4.93"/></svg></span>':pt} \n ${"loading"===a?"Processing...":"Confirm"}\n </button>\n </div>\n </div>\n `,t.querySelector(".js-cancel")?.addEventListener("click",n.onCancel),t.querySelector(".js-confirm")?.addEventListener("click",()=>{n.onConfirm(i)})}else t.innerHTML=`\n <div class="pillar-confirm-card__success">\n <span class="pillar-confirm-card__success-icon">${pt}</span>\n <span>Completed</span>\n </div>\n `};if(o(),n.onStateChange){const e=n.onStateChange;n.onStateChange=(n,t)=>{"loading"===n?a="loading":"success"===n?a="success":"error"===n&&(a="error",l=t||""),o(),e(n,t)}}return t}const ht="\n/* Confirm Action Card */\n.pillar-confirm-card-wrapper {\n margin-top: 12px;\n}\n\n.pillar-confirm-card {\n background: var(--pillar-bg-secondary, #f9fafb);\n border: 1px solid var(--pillar-border, #e5e7eb);\n border-radius: 12px;\n overflow: hidden;\n}\n\n.pillar-confirm-card__content {\n padding: 16px;\n}\n\n.pillar-confirm-card__header {\n margin-bottom: 12px;\n}\n\n.pillar-confirm-card__title {\n font-size: 14px;\n font-weight: 600;\n color: var(--pillar-text-primary, #111827);\n}\n\n.pillar-confirm-card__data {\n background: var(--pillar-bg-primary, #ffffff);\n border: 1px solid var(--pillar-border, #e5e7eb);\n border-radius: 8px;\n padding: 12px;\n margin-bottom: 12px;\n}\n\n.pillar-confirm-card__data-row {\n display: flex;\n gap: 8px;\n font-size: 13px;\n margin-bottom: 4px;\n}\n\n.pillar-confirm-card__data-row:last-child {\n margin-bottom: 0;\n}\n\n.pillar-confirm-card__data-key {\n color: var(--pillar-text-secondary, #6b7280);\n flex-shrink: 0;\n}\n\n.pillar-confirm-card__data-value {\n color: var(--pillar-text-primary, #111827);\n word-break: break-word;\n}\n\n.pillar-confirm-card__actions {\n display: flex;\n gap: 8px;\n justify-content: flex-end;\n}\n\n.pillar-confirm-card__btn {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 8px 14px;\n font-size: 13px;\n font-weight: 500;\n font-family: inherit;\n border-radius: 8px;\n cursor: pointer;\n transition: all 0.15s ease;\n border: 1px solid transparent;\n}\n\n.pillar-confirm-card__btn:disabled {\n opacity: 0.6;\n cursor: not-allowed;\n}\n\n.pillar-confirm-card__btn svg {\n width: 16px;\n height: 16px;\n}\n\n.pillar-confirm-card__btn--primary {\n background: var(--pillar-primary, #2563eb);\n color: #ffffff;\n border-color: var(--pillar-primary, #2563eb);\n}\n\n.pillar-confirm-card__btn--primary:hover:not(:disabled) {\n background: var(--pillar-primary-hover, #1d4ed8);\n border-color: var(--pillar-primary-hover, #1d4ed8);\n}\n\n.pillar-confirm-card__btn--secondary {\n background: var(--pillar-bg-primary, #ffffff);\n color: var(--pillar-text-secondary, #6b7280);\n border-color: var(--pillar-border, #e5e7eb);\n}\n\n.pillar-confirm-card__btn--secondary:hover:not(:disabled) {\n background: var(--pillar-bg-secondary, #f9fafb);\n}\n\n.pillar-confirm-card__success {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n padding: 16px;\n color: #059669;\n font-weight: 500;\n}\n\n.pillar-confirm-card__success-icon svg {\n width: 20px;\n height: 20px;\n}\n\n.pillar-confirm-card__error {\n background: #fef2f2;\n border: 1px solid #fecaca;\n border-radius: 8px;\n padding: 12px;\n margin-bottom: 12px;\n color: #dc2626;\n font-size: 13px;\n}\n\n.pillar-confirm-card__spinner {\n display: inline-flex;\n animation: pillar-spin 1s linear infinite;\n}\n\n@keyframes pillar-spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n}\n",gt=function(e){function n(e){var t,r;return this.getChildContext||(t=new Set,(r={})[n.__c]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){t=null},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&t.forEach(function(e){e.__e=!0,B(e)})},this.sub=function(e){t.add(e);var n=e.componentWillUnmount;e.componentWillUnmount=function(){t&&t.delete(e),n&&n.call(e)}}),e.children}return n.__c="__cC"+C++,n.__=e,n.Provider=n.__l=(n.Consumer=function(e,n){return e.children(n)}).contextType=n,n}(null);function ft({api:e,events:n,children:t}){return ee(gt.Provider,{value:{api:e,events:n},children:t})}function _t(){const e=function(e){var n=te.context[e.__c],t=ge(ne++,9);return t.c=e,n?(null==t.__&&(t.__=!0,n.sub(te)),n.props.value):e.__}(gt);if(!e)throw new Error("usePillar must be used within a PillarProvider");return e}function mt(){return _t().api}const vt="\n/* Inline Plan Container */\n.pillar-inline-plan {\n display: flex;\n flex-direction: column;\n gap: 6px;\n padding: 8px 0;\n}\n\n/* Steps list */\n.pillar-inline-plan__steps {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n/* Individual step */\n.pillar-inline-plan__step {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 4px 8px;\n border-radius: 6px;\n font-size: 13px;\n background: transparent;\n transition: all 0.15s ease;\n}\n\n.pillar-inline-plan__step-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n color: var(--pillar-text-tertiary, #9ca3af);\n}\n\n.pillar-inline-plan__step-content {\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: 4px;\n min-width: 0;\n}\n\n.pillar-inline-plan__step-text {\n color: var(--pillar-text-primary, #374151);\n line-height: 1.4;\n}\n\n.pillar-inline-plan__step-instruction {\n display: flex;\n align-items: center;\n gap: 6px;\n flex-wrap: wrap;\n}\n\n.pillar-inline-plan__action-badge {\n display: inline-block;\n padding: 1px 5px;\n font-size: 9px;\n font-weight: 600;\n text-transform: uppercase;\n background: var(--pillar-warning, #f59e0b);\n color: white;\n border-radius: 3px;\n flex-shrink: 0;\n}\n\n.pillar-inline-plan__instruction-text {\n font-size: 11px;\n color: var(--pillar-text-secondary, #6b7280);\n}\n\n.pillar-inline-plan__step-actions {\n display: flex;\n gap: 4px;\n}\n\n/* Step states */\n.pillar-inline-plan__step--pending {\n opacity: 0.6;\n}\n\n.pillar-inline-plan__step--ready .pillar-inline-plan__step-icon {\n color: var(--pillar-primary, #2563eb);\n}\n\n.pillar-inline-plan__step--awaiting_confirmation {\n background: var(--pillar-bg-warning-subtle, rgba(251, 191, 36, 0.1));\n}\n\n.pillar-inline-plan__step--awaiting_confirmation .pillar-inline-plan__step-icon {\n color: var(--pillar-warning-dark, #d97706);\n}\n\n.pillar-inline-plan__step--executing .pillar-inline-plan__step-icon,\n.pillar-inline-plan__step--awaiting_result .pillar-inline-plan__step-icon {\n color: var(--pillar-primary, #2563eb);\n}\n\n.pillar-inline-plan__step--completed .pillar-inline-plan__step-icon {\n color: var(--pillar-success, #059669);\n}\n\n.pillar-inline-plan__step--completed .pillar-inline-plan__step-text {\n text-decoration: line-through;\n color: var(--pillar-text-secondary, #6b7280);\n}\n\n.pillar-inline-plan__step--skipped {\n opacity: 0.5;\n}\n\n.pillar-inline-plan__step--skipped .pillar-inline-plan__step-text {\n text-decoration: line-through;\n}\n\n.pillar-inline-plan__step--failed {\n background: var(--pillar-bg-danger-subtle, rgba(220, 38, 38, 0.1));\n}\n\n.pillar-inline-plan__step--failed .pillar-inline-plan__step-icon {\n color: var(--pillar-danger, #dc2626);\n}\n\n/* Guidance step styles */\n.pillar-inline-plan__step--guidance {\n background: var(--pillar-bg-info-subtle, rgba(59, 130, 246, 0.08));\n border-left: 2px solid var(--pillar-info, #3b82f6);\n padding-left: 10px;\n}\n\n.pillar-inline-plan__step--guidance .pillar-inline-plan__step-icon {\n color: var(--pillar-info, #3b82f6);\n}\n\n.pillar-inline-plan__step--guidance.pillar-inline-plan__step--completed {\n background: transparent;\n border-left-color: var(--pillar-success, #059669);\n}\n\n.pillar-inline-plan__guidance-text {\n font-size: 11px;\n color: var(--pillar-text-secondary, #6b7280);\n line-height: 1.4;\n margin-top: 2px;\n}\n\n.pillar-inline-plan__guidance-sources {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n margin-top: 4px;\n}\n\n/* Inline UI Card Container */\n.pillar-inline-plan__inline-card {\n margin-top: 6px;\n}\n\n.pillar-inline-plan__inline-card .pillar-confirm-card {\n margin: 0;\n}\n\n.pillar-inline-plan__source-link {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n padding: 2px 6px;\n font-size: 10px;\n font-weight: 500;\n color: var(--pillar-primary, #2563eb);\n background: var(--pillar-bg-primary-subtle, rgba(37, 99, 235, 0.1));\n border-radius: 3px;\n text-decoration: none;\n transition: all 0.15s ease;\n}\n\n.pillar-inline-plan__source-link:hover {\n background: var(--pillar-bg-primary-subtle-hover, rgba(37, 99, 235, 0.15));\n text-decoration: underline;\n}\n\n/* Buttons */\n.pillar-inline-plan__btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n padding: 3px 8px;\n font-size: 11px;\n font-weight: 500;\n font-family: inherit;\n border-radius: 4px;\n cursor: pointer;\n transition: all 0.15s ease;\n border: none;\n}\n\n.pillar-inline-plan__btn--confirm {\n background: var(--pillar-success, #059669);\n color: #ffffff;\n min-width: 24px;\n}\n\n.pillar-inline-plan__btn--confirm:hover {\n background: var(--pillar-success-hover, #047857);\n}\n\n.pillar-inline-plan__btn--skip {\n background: transparent;\n color: var(--pillar-text-secondary, #6b7280);\n border: 1px solid var(--pillar-border, #d1d5db);\n}\n\n.pillar-inline-plan__btn--skip:hover {\n background: var(--pillar-bg-tertiary, #f3f4f6);\n}\n\n.pillar-inline-plan__btn--retry {\n background: var(--pillar-danger, #dc2626);\n color: #ffffff;\n}\n\n.pillar-inline-plan__btn--retry:hover {\n background: var(--pillar-danger-hover, #b91c1c);\n}\n\n.pillar-inline-plan__btn--done {\n background: var(--pillar-primary, #2563eb);\n color: #ffffff;\n}\n\n.pillar-inline-plan__btn--done:hover {\n background: var(--pillar-primary-hover, #1d4ed8);\n}\n\n.pillar-inline-plan__btn--start {\n background: var(--pillar-primary, #2563eb);\n color: #ffffff;\n}\n\n.pillar-inline-plan__btn--start:hover {\n background: var(--pillar-primary-hover, #1d4ed8);\n}\n\n.pillar-inline-plan__btn--cancel {\n background: transparent;\n color: var(--pillar-text-secondary, #6b7280);\n border: 1px solid var(--pillar-border, #d1d5db);\n}\n\n.pillar-inline-plan__btn--cancel:hover {\n background: var(--pillar-bg-tertiary, #f3f4f6);\n color: var(--pillar-danger, #dc2626);\n border-color: var(--pillar-danger, #dc2626);\n}\n\n/* Footer */\n.pillar-inline-plan__footer {\n display: flex;\n gap: 8px;\n padding-top: 6px;\n}\n\n/* Status messages */\n.pillar-inline-plan__status {\n font-size: 12px;\n font-weight: 500;\n padding: 4px 8px;\n border-radius: 4px;\n}\n\n.pillar-inline-plan__status--success {\n color: var(--pillar-success, #059669);\n background: var(--pillar-bg-success-subtle, rgba(5, 150, 105, 0.1));\n}\n\n.pillar-inline-plan__status--error {\n color: var(--pillar-danger, #dc2626);\n background: var(--pillar-bg-danger-subtle, rgba(220, 38, 38, 0.1));\n}\n\n.pillar-inline-plan__status--cancelled {\n color: var(--pillar-text-tertiary, #9ca3af);\n background: var(--pillar-bg-tertiary, #f3f4f6);\n}\n\n/* Spinner animation */\n@keyframes pillar-inline-plan-spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n}\n\n.pillar-inline-plan__spinner {\n animation: pillar-inline-plan-spin 1s linear infinite;\n}\n",bt={pending:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/></svg>',ready:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><circle cx="12" cy="12" r="4" fill="currentColor"/></svg>',awaiting_confirmation:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>',executing:'<svg class="pillar-plan-step__spinner" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83"/></svg>',awaiting_result:'<svg class="pillar-plan-step__spinner" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83"/></svg>',completed:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><polyline points="9,12 12,15 16,10"/></svg>',skipped:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10" stroke-dasharray="4,2"/><line x1="8" y1="12" x2="16" y2="12"/></svg>',failed:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>'};function xt(e){switch(e){case"pending":default:return bt.pending;case"ready":return bt.ready;case"awaiting_confirmation":return bt.awaiting_confirmation;case"executing":return bt.executing;case"awaiting_result":return bt.awaiting_result;case"completed":return bt.completed;case"skipped":return bt.skipped;case"failed":return bt.failed}}function yt({step:e,onConfirm:n,onSkip:t,onRetry:r,onDone:i,onInlineConfirm:a}){const l=me(null);"ready"===e.status||"executing"===e.status||"awaiting_confirmation"===e.status||e.status;const o="inline_ui"===e.action_type,s=o&&("ready"===e.status||"awaiting_result"===e.status);_e(()=>{if(!s||!l.current)return;l.current.innerHTML="";const n=Vi.getInstance(),r=e.action_data?.card_type||e.action_name||"default",i=n?.getCardRenderer(r),o={id:e.id,name:e.action_name||"action",data:e.action_data||{}},p={onConfirm:t=>{console.log("[PlanStepItem] Inline card confirmed with data:",t),a?a(e.id,t):n&&n.executeTask({id:e.id,name:e.action_name||"action",taskType:"inline_ui",data:t||e.action_data||{}})},onCancel:()=>{console.log("[PlanStepItem] Inline card cancelled"),t(e.id)},onStateChange:(e,n)=>{console.log(`[PlanStepItem] Card state: ${e}${n?` - ${n}`:""}`)}};if(i)try{i(l.current,e.action_data||{},p)}catch(e){console.error("[PlanStepItem] Custom card renderer error:",e)}else{const e=ut(o,p);l.current.appendChild(e)}},[s,e.id,e.action_data,e.action_name]);const p="failed"===e.status&&e.is_retriable&&e.retry_count<e.max_retries;return ee("div",{class:`pillar-plan-step pillar-plan-step--${e.status}`,children:[ee("div",{class:"pillar-plan-step__icon",children:ee("span",{dangerouslySetInnerHTML:{__html:xt(e.status)}})}),ee("div",{class:"pillar-plan-step__content",children:[ee("div",{class:"pillar-plan-step__description",children:e.description}),s&&ee("div",{ref:l,class:"pillar-plan-step__inline-card"}),"awaiting_confirmation"===e.status&&!o&&ee("div",{class:"pillar-plan-step__actions",children:[ee("button",{type:"button",class:"pillar-plan-step__confirm-btn",onClick:()=>{n(e.id)},children:"Confirm"}),ee("button",{type:"button",class:"pillar-plan-step__skip-btn",onClick:()=>{t(e.id)},children:"Skip"})]}),"executing"===e.status&&!o&&ee("div",{class:"pillar-plan-step__status-text",children:"Running..."}),"awaiting_result"===e.status&&!o&&ee("div",{class:"pillar-plan-step__awaiting-container",children:[ee("div",{class:"pillar-plan-step__instruction-row",children:[ee("span",{class:"pillar-plan-step__action-badge",children:"In Progress"}),ee("span",{class:"pillar-plan-step__instruction",children:"Complete this step to continue"})]}),ee("button",{type:"button",class:"pillar-plan-step__done-btn",onClick:()=>{i?.(e.id)},children:"Done"})]}),"failed"===e.status&&ee("div",{class:"pillar-plan-step__error-container",children:[e.error_message&&ee("div",{class:"pillar-plan-step__error",children:e.error_message}),p&&ee("div",{class:"pillar-plan-step__retry-info",children:[ee("span",{class:"pillar-plan-step__retry-count",children:["Attempt ",e.retry_count+1," of ",e.max_retries+1]}),ee("button",{type:"button",class:"pillar-plan-step__retry-btn",onClick:()=>{r?.(e.id)},children:"Retry"})]}),!p&&e.retry_count>=e.max_retries&&ee("div",{class:"pillar-plan-step__retry-exhausted",children:"All retry attempts exhausted"})]})]})]})}const kt="\n/* Individual Step */\n.pillar-plan-step {\n display: flex;\n align-items: flex-start;\n gap: 10px;\n padding: 10px 12px;\n background: var(--pillar-bg-primary, #ffffff);\n border: 1px solid var(--pillar-border, #e5e7eb);\n border-radius: 8px;\n transition: all 0.15s ease;\n}\n\n.pillar-plan-step__icon {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n width: 24px;\n height: 24px;\n color: var(--pillar-text-tertiary, #9ca3af);\n}\n\n.pillar-plan-step__icon svg {\n width: 18px;\n height: 18px;\n}\n\n.pillar-plan-step__content {\n flex: 1;\n min-width: 0;\n display: flex;\n flex-direction: column;\n gap: 6px;\n}\n\n.pillar-plan-step__description {\n font-size: 13px;\n font-weight: 500;\n color: var(--pillar-text-primary, #374151);\n line-height: 1.4;\n}\n\n.pillar-plan-step__status-text {\n font-size: 12px;\n color: var(--pillar-primary, #2563eb);\n font-style: italic;\n}\n\n.pillar-plan-step__error {\n font-size: 12px;\n color: var(--pillar-danger, #dc2626);\n}\n\n.pillar-plan-step__actions {\n display: flex;\n gap: 8px;\n margin-top: 4px;\n}\n\n/* Step States */\n.pillar-plan-step--pending {\n opacity: 0.6;\n}\n\n.pillar-plan-step--ready {\n background: var(--pillar-bg-info-subtle, #eff6ff);\n border-color: var(--pillar-info, #93c5fd);\n}\n\n.pillar-plan-step--ready .pillar-plan-step__icon {\n color: var(--pillar-primary, #2563eb);\n}\n\n.pillar-plan-step--awaiting_confirmation {\n background: var(--pillar-bg-warning-subtle, #fef3c7);\n border-color: var(--pillar-warning, #fcd34d);\n}\n\n.pillar-plan-step--awaiting_confirmation .pillar-plan-step__icon {\n color: var(--pillar-warning-dark, #d97706);\n}\n\n.pillar-plan-step--executing,\n.pillar-plan-step--awaiting_result {\n background: var(--pillar-bg-info-subtle, #eff6ff);\n border-color: var(--pillar-info, #93c5fd);\n}\n\n.pillar-plan-step--executing .pillar-plan-step__icon,\n.pillar-plan-step--awaiting_result .pillar-plan-step__icon {\n color: var(--pillar-primary, #2563eb);\n}\n\n.pillar-plan-step--completed .pillar-plan-step__icon {\n color: var(--pillar-success, #059669);\n}\n\n.pillar-plan-step--completed .pillar-plan-step__description {\n text-decoration: line-through;\n color: var(--pillar-text-secondary, #6b7280);\n}\n\n.pillar-plan-step--skipped {\n opacity: 0.5;\n}\n\n.pillar-plan-step--skipped .pillar-plan-step__icon {\n color: var(--pillar-text-tertiary, #9ca3af);\n}\n\n.pillar-plan-step--skipped .pillar-plan-step__description {\n text-decoration: line-through;\n color: var(--pillar-text-tertiary, #9ca3af);\n}\n\n.pillar-plan-step--failed {\n background: var(--pillar-bg-danger-subtle, #fef2f2);\n border-color: var(--pillar-danger-light, #fca5a5);\n}\n\n.pillar-plan-step--failed .pillar-plan-step__icon {\n color: var(--pillar-danger, #dc2626);\n}\n\n/* Error Container */\n.pillar-plan-step__error-container {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.pillar-plan-step__retry-info {\n display: flex;\n align-items: center;\n gap: 12px;\n margin-top: 2px;\n}\n\n.pillar-plan-step__retry-count {\n font-size: 11px;\n color: var(--pillar-text-tertiary, #9ca3af);\n}\n\n.pillar-plan-step__retry-exhausted {\n font-size: 11px;\n color: var(--pillar-text-tertiary, #9ca3af);\n font-style: italic;\n margin-top: 2px;\n}\n\n/* Retry Button */\n.pillar-plan-step__retry-btn {\n display: inline-flex;\n align-items: center;\n padding: 4px 10px;\n font-size: 11px;\n font-weight: 600;\n font-family: inherit;\n background: var(--pillar-danger, #dc2626);\n color: #ffffff;\n border: none;\n border-radius: 5px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-plan-step__retry-btn:hover {\n background: var(--pillar-danger-hover, #b91c1c);\n}\n\n/* Confirm Button */\n.pillar-plan-step__confirm-btn {\n display: inline-flex;\n align-items: center;\n padding: 6px 12px;\n font-size: 12px;\n font-weight: 600;\n font-family: inherit;\n background: var(--pillar-primary, #2563eb);\n color: #ffffff;\n border: none;\n border-radius: 6px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-plan-step__confirm-btn:hover {\n background: var(--pillar-primary-hover, #1d4ed8);\n}\n\n/* Skip Button */\n.pillar-plan-step__skip-btn {\n display: inline-flex;\n align-items: center;\n padding: 6px 12px;\n font-size: 12px;\n font-weight: 500;\n font-family: inherit;\n background: transparent;\n color: var(--pillar-text-secondary, #6b7280);\n border: 1px solid var(--pillar-border, #d1d5db);\n border-radius: 6px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-plan-step__skip-btn:hover {\n background: var(--pillar-bg-tertiary, #f3f4f6);\n color: var(--pillar-text-primary, #374151);\n}\n\n/* Awaiting Result Container */\n.pillar-plan-step__awaiting-container {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.pillar-plan-step__instruction-row {\n display: flex;\n align-items: center;\n gap: 8px;\n flex-wrap: wrap;\n}\n\n.pillar-plan-step__action-badge {\n display: inline-block;\n padding: 2px 6px;\n font-size: 10px;\n font-weight: 600;\n text-transform: uppercase;\n background: var(--pillar-warning, #f59e0b);\n color: white;\n border-radius: 3px;\n flex-shrink: 0;\n}\n\n.pillar-plan-step__instruction {\n font-size: 12px;\n color: var(--pillar-text-secondary, #6b7280);\n}\n\n/* Done Button */\n.pillar-plan-step__done-btn {\n display: inline-flex;\n align-items: center;\n align-self: flex-start;\n padding: 6px 14px;\n font-size: 12px;\n font-weight: 600;\n font-family: inherit;\n background: var(--pillar-primary, #2563eb);\n color: #ffffff;\n border: none;\n border-radius: 6px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-plan-step__done-btn:hover {\n background: var(--pillar-primary-hover, #1d4ed8);\n}\n\n/* Inline Card Container */\n.pillar-plan-step__inline-card {\n margin-top: 8px;\n}\n\n.pillar-plan-step__inline-card .pillar-confirm-card {\n margin: 0;\n}\n\n/* Spinner Animation for Executing Step */\n@keyframes pillar-plan-spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}\n\n.pillar-plan-step__spinner {\n animation: pillar-plan-spin 1s linear infinite;\n}\n",wt=He(null),St=He([]),Ct=Ue(()=>null!==wt.value);Ue(()=>wt.value&&wt.value.steps.find(e=>"ready"===e.status||"executing"===e.status||"awaiting_confirmation"===e.status)||null),Ue(()=>wt.value?wt.value.steps.filter(e=>"completed"===e.status||"skipped"===e.status).length:0);const Pt=Ue(()=>wt.value&&0!==wt.value.total_steps?wt.value.completed_steps/wt.value.total_steps:0);function $t(e){wt.value&&(St.value=[...St.value,wt.value]),wt.value=e}function Tt(e){wt.value=e}function Et(e,n){if(!wt.value)return;const t=wt.value.steps.map(t=>t.id===e?{...t,...n}:t);let r=wt.value.completed_steps;"completed"===n.status&&(r=t.filter(e=>"completed"===e.status).length),wt.value={...wt.value,steps:t,completed_steps:r}}function zt(e=!0){wt.value&&e&&(St.value=[...St.value,wt.value]),wt.value=null}Ue(()=>"awaiting_start"===wt.value?.status);const It={plan:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 11l3 3L22 4"/><path d="M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11"/></svg>'};function Mt(){const e=wt.value;if(!e)return null;const n="awaiting_start"===e.status,t="executing"===e.status,r=Pt.value,i=Vi.getInstance(),a=(e,n)=>{i?.confirmPlanStep(e,n)},l=e=>{i?.skipPlanStep(e)},o=e=>{i?.retryPlanStep(e)},s=e=>{i?.markPlanStepDone(e)},p=(e,n)=>{i?.confirmInlinePlanStep(e,n)};return ee("div",{class:"pillar-plan",children:[ee("div",{class:"pillar-plan__header",children:[ee("div",{class:"pillar-plan__icon",children:ee("span",{dangerouslySetInnerHTML:{__html:It.plan}})}),ee("div",{class:"pillar-plan__title",children:e.goal}),ee("div",{class:"pillar-plan__progress",children:[e.completed_steps,"/",e.total_steps]})]}),t&&ee("div",{class:"pillar-plan__progress-bar",children:ee("div",{class:"pillar-plan__progress-fill",style:{width:100*r+"%"}})}),ee("div",{class:"pillar-plan__steps",children:e.steps.map(e=>ee(yt,{step:e,onConfirm:a,onSkip:l,onRetry:o,onDone:s,onInlineConfirm:p},e.id))}),ee("div",{class:"pillar-plan__footer",children:[n&&ee("button",{type:"button",class:"pillar-plan__start-btn",onClick:()=>{i?.startPlan()},children:"Start Plan"}),ee("button",{type:"button",class:"pillar-plan__cancel-btn",onClick:()=>{i?.cancelPlan()},children:"Cancel"})]})]})}const At="\n/* Plan Container */\n.pillar-plan {\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding: 16px;\n background: var(--pillar-bg-secondary, #f9fafb);\n border: 1px solid var(--pillar-border, #e5e7eb);\n border-radius: 12px;\n margin: 12px 0;\n}\n\n/* Header */\n.pillar-plan__header {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n\n.pillar-plan__icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: var(--pillar-text-secondary, #6b7280);\n}\n\n.pillar-plan__title {\n flex: 1;\n font-size: 14px;\n font-weight: 600;\n color: var(--pillar-text-primary, #1a1a1a);\n line-height: 1.4;\n}\n\n.pillar-plan__progress {\n font-size: 12px;\n font-weight: 500;\n color: var(--pillar-text-secondary, #6b7280);\n padding: 2px 8px;\n background: var(--pillar-bg-tertiary, #e5e7eb);\n border-radius: 10px;\n}\n\n/* Progress Bar */\n.pillar-plan__progress-bar {\n height: 4px;\n background: var(--pillar-bg-tertiary, #e5e7eb);\n border-radius: 2px;\n overflow: hidden;\n}\n\n.pillar-plan__progress-fill {\n height: 100%;\n background: var(--pillar-primary, #2563eb);\n border-radius: 2px;\n transition: width 0.3s ease;\n}\n\n/* Steps List */\n.pillar-plan__steps {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n/* Footer */\n.pillar-plan__footer {\n display: flex;\n justify-content: flex-end;\n gap: 8px;\n padding-top: 8px;\n border-top: 1px solid var(--pillar-border, #e5e7eb);\n}\n\n/* Start Button */\n.pillar-plan__start-btn {\n display: inline-flex;\n align-items: center;\n padding: 8px 16px;\n font-size: 13px;\n font-weight: 600;\n font-family: inherit;\n background: var(--pillar-primary, #2563eb);\n color: #ffffff;\n border: none;\n border-radius: 6px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-plan__start-btn:hover {\n background: var(--pillar-primary-hover, #1d4ed8);\n}\n\n/* Cancel Button */\n.pillar-plan__cancel-btn {\n display: inline-flex;\n align-items: center;\n padding: 8px 16px;\n font-size: 13px;\n font-weight: 500;\n font-family: inherit;\n background: transparent;\n color: var(--pillar-text-secondary, #6b7280);\n border: 1px solid var(--pillar-border, #d1d5db);\n border-radius: 6px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-plan__cancel-btn:hover {\n background: var(--pillar-bg-tertiary, #f3f4f6);\n color: var(--pillar-danger, #dc2626);\n border-color: var(--pillar-danger, #dc2626);\n}\n",Rt={home:"Assistant",chat:"Assistant"};function jt({currentView:e,customTitle:n,hideNavigation:t=!1}){const r=!t&&tt.value,i=!t&&!rt.value,a="chat"===e&&Wn.value,l=n||Rt[e];return ee("header",{class:"_pillar-header pillar-header",children:[ee("div",{class:"_pillar-header-left pillar-header-left",children:[r&&ee("button",{class:"_pillar-icon-btn pillar-icon-btn pillar-back-btn",onClick:()=>{at()},"aria-label":"Go back",type:"button",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M9.707 16.707a1 1 0 01-1.414 0l-6-6a1 1 0 010-1.414l6-6a1 1 0 011.414 1.414L5.414 9H17a1 1 0 110 2H5.414l4.293 4.293a1 1 0 010 1.414z" clip-rule="evenodd"/></svg>'}}),i&&!a&&ee("button",{class:"_pillar-icon-btn pillar-icon-btn pillar-home-btn",onClick:()=>{lt()},"aria-label":"Go to home",type:"button",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 20 20" fill="currentColor"><path d="M10.707 2.293a1 1 0 00-1.414 0l-7 7a1 1 0 001.414 1.414L4 10.414V17a1 1 0 001 1h2a1 1 0 001-1v-2a1 1 0 011-1h2a1 1 0 011 1v2a1 1 0 001 1h2a1 1 0 001-1v-6.586l.293.293a1 1 0 001.414-1.414l-7-7z"/></svg>'}}),ee("span",{class:"_pillar-header-title pillar-header-title",children:l})]}),ee("div",{class:"_pillar-header-right pillar-header-right",children:[a&&ee("button",{class:"_pillar-icon-btn pillar-icon-btn pillar-new-chat-btn",onClick:()=>{lt()},"aria-label":"New chat",title:"New chat",type:"button",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 20 20" fill="currentColor"><path d="M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z"/></svg>'}}),ee("button",{class:"_pillar-icon-btn pillar-icon-btn pillar-close-btn",onClick:()=>{fn()},"aria-label":"Close assistant panel",type:"button",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd"/></svg>'}})]})]})}const Lt='<svg viewBox="0 0 24 24" fill="currentColor"><path d="M4.583 17.321C3.553 16.227 3 15 3 13.011c0-3.5 2.457-6.637 6.03-8.188l.893 1.378c-3.335 1.804-3.987 4.145-4.247 5.621.537-.278 1.24-.375 1.929-.311 1.804.167 3.226 1.648 3.226 3.489a3.5 3.5 0 01-3.5 3.5c-1.073 0-2.099-.49-2.748-1.179zm10 0C13.553 16.227 13 15 13 13.011c0-3.5 2.457-6.637 6.03-8.188l.893 1.378c-3.335 1.804-3.987 4.145-4.247 5.621.537-.278 1.24-.375 1.929-.311 1.804.167 3.226 1.648 3.226 3.489a3.5 3.5 0 01-3.5 3.5c-1.073 0-2.099-.49-2.748-1.179z"/></svg>';function Bt({context:e,onRemove:n,readOnly:t=!1}){const r="highlighted_text"===(i=e).type?i.text_content.length>40?i.text_content.substring(0,40)+"...":i.text_content:"Context";var i;const a=function(e){return Pn(e),Lt}(e),l=function(e){if(Pn(e)){const n=e.url_origin?`\nFrom: ${e.url_origin}`:"";return`"${e.text_content}"${n}`}return""}(e);return ee("div",{class:"_pillar-context-tag pillar-context-tag",title:l,children:[ee("span",{class:"_pillar-context-tag-icon pillar-context-tag-icon",dangerouslySetInnerHTML:{__html:a}}),ee("span",{class:"_pillar-context-tag-label pillar-context-tag-label",children:r}),!t&&n&&ee("button",{class:"_pillar-context-tag-remove pillar-context-tag-remove",onClick:t=>{t.preventDefault(),t.stopPropagation(),n?.(e.id)},"aria-label":"Remove context",type:"button",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>'}})]})}function Ht({contexts:e,onRemove:n,readOnly:t=!1}){return 0===e.length?null:ee("div",{class:"_pillar-context-tag-list pillar-context-tag-list",children:e.map(e=>ee(Bt,{context:e,onRemove:n,readOnly:t},e.id))})}const qt='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>';function Ot({placeholder:e="Ask anything...",disabled:n=!1,onSubmit:t,showContextTags:r=!0,showImageUpload:i=!0,className:a=""}){const l=mt(),o=me(null),s=me(null),[p,c]=fe(""),[d,u]=fe(!1),h=be(()=>{const e=o.current;if(!e)return;e.style.height="41px";const n=e.scrollHeight;n>146?(e.style.height="146px",e.style.overflowY="auto"):(e.style.height=`${n}px`,e.style.overflowY="hidden")},[]),g=be(async e=>{if(Dn.value.length>=4)return;const n=`img-${Date.now()}-${Math.random().toString(36).slice(2)}`,t=URL.createObjectURL(e);var r;r={id:n,file:e,preview:t,status:"uploading"},Dn.value.length>=4||(Dn.value=[...Dn.value,r]);try{const t=await l.uploadImage(e);Un(n,"ready",t.url)}catch(e){const t=e instanceof Error?e.message:"Upload failed";Un(n,"error",void 0,t)}},[l]),f=be(e=>{const n=Array.from(e).filter(e=>e.type.startsWith("image/")),t=4-Dn.value.length;n.slice(0,t).forEach(g)},[g]),_=be(e=>{const n=e.clipboardData?.items;if(!n)return;const t=[];for(const e of n)if(e.type.startsWith("image/")){const n=e.getAsFile();n&&t.push(n)}t.length>0&&(e.preventDefault(),f(t))},[f]),m=be(e=>{e.preventDefault(),e.stopPropagation(),u(!0)},[]),v=be(e=>{e.preventDefault(),e.stopPropagation(),u(!1)},[]),b=be(e=>{e.preventDefault(),e.stopPropagation(),u(!1);const n=e.dataTransfer?.files;n&&f(n)},[f]),x=be(e=>{const n=e.target;n.files&&(f(n.files),n.value="")},[f]),y=be(()=>{s.current?.click()},[]),k=be(()=>{const e=p.trim(),n=[...qn.value],r=Dn.value.filter(e=>"ready"===e.status&&e.url).map(e=>({url:e.url,detail:"low"})),i=n.length>0,a=r.length>0;var l;(e||i||a)&&(Nn.value||(i&&(qn.value=[]),Fn(),t?t(e,n,r):(i&&(l=n,On.value=l),Gn(e),st()),c(""),o.current&&(o.current.style.height="41px",o.current.style.overflowY="hidden")))},[p,t]),w=Nn.value,S=p.trim()||qn.value.length>0||Dn.value.some(e=>"ready"===e.status);return ee("div",{class:`_pillar-unified-input-wrapper pillar-unified-input-wrapper ${d?"_pillar-unified-input-wrapper--dragging":""} ${a}`.trim(),onDragOver:m,onDragLeave:v,onDrop:b,children:[ee("input",{ref:s,type:"file",accept:"image/*",multiple:!0,onChange:x,style:{display:"none"}}),Dn.value.length>0&&ee("div",{class:"_pillar-chat-images-preview pillar-chat-images-preview",children:Dn.value.map(e=>ee("div",{class:"_pillar-chat-image-thumb pillar-chat-image-thumb",children:[ee("img",{src:e.preview,alt:"Upload preview"}),"uploading"===e.status&&ee("div",{class:"_pillar-chat-image-loading pillar-chat-image-loading",children:ee("div",{class:"_pillar-loading-spinner pillar-loading-spinner",style:{width:"16px",height:"16px"}})}),"error"===e.status&&ee("div",{class:"_pillar-chat-image-error pillar-chat-image-error",title:e.error,children:"!"}),ee("button",{type:"button",class:"_pillar-chat-image-remove pillar-chat-image-remove",onClick:()=>(e=>{const n=Dn.value.find(n=>n.id===e);n&&URL.revokeObjectURL(n.preview),Dn.value=Dn.value.filter(n=>n.id!==e)})(e.id),"aria-label":"Remove image",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>'}})]},e.id))}),r&&ee(Ht,{contexts:qn.value,onRemove:Jn}),ee("textarea",{ref:o,class:"_pillar-unified-input pillar-unified-input",placeholder:d?"Drop image here...":e,value:p,onInput:e=>{const n=e.target;c(n.value),h()},onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),k())},onPaste:_,disabled:n,style:{height:"41px"}}),ee("div",{class:"_pillar-unified-input-row pillar-unified-input-row",children:[i&&ee("button",{type:"button",class:"_pillar-chat-image-btn pillar-chat-image-btn",onClick:y,disabled:n||w||Dn.value.length>=4,"aria-label":"Attach image",title:"Attach image (max 4)",dangerouslySetInnerHTML:{__html:qt}}),ee("button",{type:"button",class:"_pillar-unified-send-btn pillar-unified-send-btn",onClick:k,disabled:n||w||!S,"aria-label":"Send message",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="19" x2="12" y2="5"/><polyline points="5 12 12 5 19 12"/></svg>'}})]}),d&&ee("div",{class:"_pillar-chat-drop-overlay pillar-chat-drop-overlay",children:[ee("span",{dangerouslySetInnerHTML:{__html:qt}}),ee("span",{children:"Drop image here"})]})]})}function Dt({text:e,onClick:n}){return ee("button",{type:"button",class:"_pillar-question-chip pillar-question-chip",onClick:n,children:[ee("span",{class:"_pillar-question-chip-text pillar-question-chip-text",children:e}),ee("span",{class:"_pillar-question-chip-arrow pillar-question-chip-arrow",children:"→"})]})}function Nt(){return ee("div",{class:"_pillar-question-chip-skeleton pillar-question-chip-skeleton",children:ee("div",{class:"_pillar-question-chip-skeleton-bar pillar-question-chip-skeleton-bar"})})}function Ut(){const e=mt(),[n,t]=fe(null),[r,i]=fe(!0);_e(()=>{let n=!0;return(async()=>{try{const r=await e.getSuggestedQuestions();n&&(t(r),i(!1))}catch(e){n&&(console.error("[Pillar] Failed to load suggested questions:",e),t([]),i(!1))}})(),()=>{n=!1}},[e]);return ee("div",{class:"_pillar-home-view pillar-home-view",children:[ee("div",{class:"_pillar-home-view-header pillar-home-view-header",children:[ee("div",{class:"_pillar-home-view-icon",children:"💬"}),ee("h2",{class:"_pillar-home-view-title pillar-home-view-title",children:"How can I help?"})]}),ee("div",{class:"_pillar-home-view-questions pillar-home-view-questions",children:r?ee(A,{children:[ee(Nt,{}),ee(Nt,{}),ee(Nt,{})]}):n&&n.length>0?n.map(e=>ee(Dt,{text:e.text,onClick:()=>(e=>{Gn(e.text),st()})(e)},e.id)):null}),ee("div",{style:{marginTop:"auto"},children:ee(Ot,{placeholder:"Ask anything..."})})]})}function Ft({progress:e,isActive:n=!1}){const[t,r]=fe(!1),[i,a]=fe(!1),l="search_complete"===e.kind,o=e.metadata?.sources&&e.metadata.sources.length>0,s=!0===e.metadata?.no_sources_used,p=l&&o&&!s,c=l&&0===e.metadata?.result_count,d="query_failed"===e.kind,u=p&&(t?i:n),h=me(null),[g,f]=fe(!1);_e(()=>{r(!1)},[n]);const _=()=>{if(h.current){const{scrollTop:e,scrollHeight:n,clientHeight:t}=h.current;f(n>t&&!(e>=n-t-5))}};_e(()=>{_()},[e.metadata?.sources,u]);return ee("div",{class:"_pillar-progress-row pillar-progress-row"+(d?" _pillar-progress-row--error pillar-progress-row--error":""),children:[ee("div",{class:"_pillar-progress-row-header pillar-progress-row-header",onClick:()=>{p&&(r(!0),a(!u))},style:{cursor:p?"pointer":"default"},"data-expanded":u,children:[ee("span",{class:"_pillar-progress-expand-icon pillar-progress-expand-icon",style:{visibility:p?"visible":"hidden",transform:u?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.2s"},children:"▶"}),ee("span",{class:"_pillar-progress-message pillar-progress-message",children:e.message||Wt(e.kind)}),c&&ee("span",{class:"_pillar-progress-no-results pillar-progress-no-results",children:"— no relevant results"})]}),p&&ee("div",{class:"_pillar-progress-content-wrapper pillar-progress-content-wrapper "+(u?"_pillar-progress-content-wrapper--expanded pillar-progress-content-wrapper--expanded":""),children:[ee("div",{ref:h,class:"_pillar-progress-content-container pillar-progress-content-container",onScroll:()=>{_()},children:ee("div",{class:"_pillar-progress-sources pillar-progress-sources",children:e.metadata?.sources?.map((e,n)=>ee("div",{class:"_pillar-progress-source-item pillar-progress-source-item",children:ee("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",class:"_pillar-progress-source-link pillar-progress-source-link",children:ee("span",{class:"_pillar-progress-source-title pillar-progress-source-title",children:e.title})})},n))})}),g&&ee("div",{class:"_pillar-progress-content-gradient pillar-progress-content-gradient"})]})]})}function Wt(e){switch(e){case"processing":return"Processing...";case"search":return"Searching...";case"search_complete":return"Search complete";case"query":return"Executing action...";case"query_complete":return"Action complete";case"query_failed":return"Action failed";case"generating":return"Generating answer...";default:return"Working..."}}function Vt(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Kt={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function Zt(e){Kt=e}var Gt={exec:()=>null};function Qt(e,n=""){let t="string"==typeof e?e:e.source,r={replace:(e,n)=>{let i="string"==typeof n?n:n.source;return i=i.replace(Jt.caret,"$1"),t=t.replace(e,i),r},getRegex:()=>new RegExp(t,n)};return r}var Xt=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Jt={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[\t ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},Yt=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,er=/(?:[*+-]|\d{1,9}[.)])/,nr=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,tr=Qt(nr).replace(/bull/g,er).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),rr=Qt(nr).replace(/bull/g,er).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),ir=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,ar=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,lr=Qt(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",ar).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),or=Qt(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,er).getRegex(),sr="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",pr=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,cr=Qt("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",pr).replace("tag",sr).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),dr=Qt(ir).replace("hr",Yt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",sr).getRegex(),ur={blockquote:Qt(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",dr).getRegex(),code:/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,def:lr,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:Yt,html:cr,lheading:tr,list:or,newline:/^(?:[ \t]*(?:\n|$))+/,paragraph:dr,table:Gt,text:/^[^\n]+/},hr=Qt("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Yt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",sr).getRegex(),gr={...ur,lheading:rr,table:hr,paragraph:Qt(ir).replace("hr",Yt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",hr).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",sr).getRegex()},fr={...ur,html:Qt("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",pr).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Gt,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Qt(ir).replace("hr",Yt).replace("heading"," *#{1,6} *[^\n]").replace("lheading",tr).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},_r=/^( {2,}|\\)\n(?!\s*$)/,mr=/[\p{P}\p{S}]/u,vr=/[\s\p{P}\p{S}]/u,br=/[^\s\p{P}\p{S}]/u,xr=Qt(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,vr).getRegex(),yr=/(?!~)[\p{P}\p{S}]/u,kr=Qt(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Xt?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),wr=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Sr=Qt(wr,"u").replace(/punct/g,mr).getRegex(),Cr=Qt(wr,"u").replace(/punct/g,yr).getRegex(),Pr="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",$r=Qt(Pr,"gu").replace(/notPunctSpace/g,br).replace(/punctSpace/g,vr).replace(/punct/g,mr).getRegex(),Tr=Qt(Pr,"gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|~)/u).replace(/punctSpace/g,/(?!~)[\s\p{P}\p{S}]/u).replace(/punct/g,yr).getRegex(),Er=Qt("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,br).replace(/punctSpace/g,vr).replace(/punct/g,mr).getRegex(),zr=Qt(/\\(punct)/,"gu").replace(/punct/g,mr).getRegex(),Ir=Qt(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Mr=Qt(pr).replace("(?:--\x3e|$)","--\x3e").getRegex(),Ar=Qt("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Mr).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Rr=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,jr=Qt(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Rr).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Lr=Qt(/^!?\[(label)\]\[(ref)\]/).replace("label",Rr).replace("ref",ar).getRegex(),Br=Qt(/^!?\[(ref)\](?:\[\])?/).replace("ref",ar).getRegex(),Hr=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,qr={_backpedal:Gt,anyPunctuation:zr,autolink:Ir,blockSkip:kr,br:_r,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:Gt,emStrongLDelim:Sr,emStrongRDelimAst:$r,emStrongRDelimUnd:Er,escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,link:jr,nolink:Br,punctuation:xr,reflink:Lr,reflinkSearch:Qt("reflink|nolink(?!\\()","g").replace("reflink",Lr).replace("nolink",Br).getRegex(),tag:Ar,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:Gt},Or={...qr,link:Qt(/^!?\[(label)\]\((.*?)\)/).replace("label",Rr).getRegex(),reflink:Qt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Rr).getRegex()},Dr={...qr,emStrongRDelimAst:Tr,emStrongLDelim:Cr,url:Qt(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Hr).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:Qt(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Hr).getRegex()},Nr={...Dr,br:Qt(_r).replace("{2,}","*").getRegex(),text:Qt(Dr.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ur={normal:ur,gfm:gr,pedantic:fr},Fr={normal:qr,gfm:Dr,breaks:Nr,pedantic:Or},Wr={"&":"&","<":"<",">":">",'"':""","'":"'"},Vr=e=>Wr[e];function Kr(e,n){if(n){if(Jt.escapeTest.test(e))return e.replace(Jt.escapeReplace,Vr)}else if(Jt.escapeTestNoEncode.test(e))return e.replace(Jt.escapeReplaceNoEncode,Vr);return e}function Zr(e){try{e=encodeURI(e).replace(Jt.percentDecode,"%")}catch{return null}return e}function Gr(e,n){let t=e.replace(Jt.findPipe,(e,n,t)=>{let r=!1,i=n;for(;--i>=0&&"\\"===t[i];)r=!r;return r?"|":" |"}),r=t.split(Jt.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),n)if(r.length>n)r.splice(n);else for(;r.length<n;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(Jt.slashPipe,"|");return r}function Qr(e,n,t){let r=e.length;if(0===r)return"";let i=0;for(;i<r;){if(e.charAt(r-i-1)!==n)break;i++}return e.slice(0,r-i)}function Xr(e,n,t,r,i){let a=n.href,l=n.title||null,o=e[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let s={type:"!"===e[0].charAt(0)?"image":"link",raw:t,href:a,title:l,text:o,tokens:r.inlineTokens(o)};return r.state.inLink=!1,s}var Jr=class{options;rules;lexer;constructor(e){this.options=e||Kt}space(e){let n=this.rules.block.newline.exec(e);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(e){let n=this.rules.block.code.exec(e);if(n){let e=n[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?e:Qr(e,"\n")}}}fences(e){let n=this.rules.block.fences.exec(e);if(n){let e=n[0],t=function(e,n,t){let r=e.match(t.other.indentCodeCompensation);if(null===r)return n;let i=r[1];return n.split("\n").map(e=>{let n=e.match(t.other.beginningSpace);if(null===n)return e;let[r]=n;return r.length>=i.length?e.slice(i.length):e}).join("\n")}(e,n[3]||"",this.rules);return{type:"code",raw:e,lang:n[2]?n[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):n[2],text:t}}}heading(e){let n=this.rules.block.heading.exec(e);if(n){let e=n[2].trim();if(this.rules.other.endingHash.test(e)){let n=Qr(e,"#");(this.options.pedantic||!n||this.rules.other.endingSpaceChar.test(n))&&(e=n.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let n=this.rules.block.hr.exec(e);if(n)return{type:"hr",raw:Qr(n[0],"\n")}}blockquote(e){let n=this.rules.block.blockquote.exec(e);if(n){let e=Qr(n[0],"\n").split("\n"),t="",r="",i=[];for(;e.length>0;){let n,a=!1,l=[];for(n=0;n<e.length;n++)if(this.rules.other.blockquoteStart.test(e[n]))l.push(e[n]),a=!0;else{if(a)break;l.push(e[n])}e=e.slice(n);let o=l.join("\n"),s=o.replace(this.rules.other.blockquoteSetextReplace,"\n $1").replace(this.rules.other.blockquoteSetextReplace2,"");t=t?`${t}\n${o}`:o,r=r?`${r}\n${s}`:s;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(s,i,!0),this.lexer.state.top=p,0===e.length)break;let c=i.at(-1);if("code"===c?.type)break;if("blockquote"===c?.type){let n=c,a=n.raw+"\n"+e.join("\n"),l=this.blockquote(a);i[i.length-1]=l,t=t.substring(0,t.length-n.raw.length)+l.raw,r=r.substring(0,r.length-n.text.length)+l.text;break}if("list"===c?.type){let n=c,a=n.raw+"\n"+e.join("\n"),l=this.list(a);i[i.length-1]=l,t=t.substring(0,t.length-c.raw.length)+l.raw,r=r.substring(0,r.length-n.raw.length)+l.raw,e=a.substring(i.at(-1).raw.length).split("\n");continue}}return{type:"blockquote",raw:t,tokens:i,text:r}}}list(e){let n=this.rules.block.list.exec(e);if(n){let t=n[1].trim(),r=t.length>1,i={type:"list",raw:"",ordered:r,start:r?+t.slice(0,-1):"",loose:!1,items:[]};t=r?`\\d{1,9}\\${t.slice(-1)}`:`\\${t}`,this.options.pedantic&&(t=r?t:"[*+-]");let a=this.rules.other.listItemRegex(t),l=!1;for(;e;){let t=!1,r="",o="";if(!(n=a.exec(e))||this.rules.block.hr.test(e))break;r=n[0],e=e.substring(r.length);let s=n[2].split("\n",1)[0].replace(this.rules.other.listReplaceTabs,e=>" ".repeat(3*e.length)),p=e.split("\n",1)[0],c=!s.trim(),d=0;if(this.options.pedantic?(d=2,o=s.trimStart()):c?d=n[1].length+1:(d=n[2].search(this.rules.other.nonSpaceChar),d=d>4?1:d,o=s.slice(d),d+=n[1].length),c&&this.rules.other.blankLine.test(p)&&(r+=p+"\n",e=e.substring(p.length+1),t=!0),!t){let n=this.rules.other.nextBulletRegex(d),t=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),a=this.rules.other.headingBeginRegex(d),l=this.rules.other.htmlBeginRegex(d);for(;e;){let u,h=e.split("\n",1)[0];if(p=h,this.options.pedantic?(p=p.replace(this.rules.other.listReplaceNesting," "),u=p):u=p.replace(this.rules.other.tabCharGlobal," "),i.test(p)||a.test(p)||l.test(p)||n.test(p)||t.test(p))break;if(u.search(this.rules.other.nonSpaceChar)>=d||!p.trim())o+="\n"+u.slice(d);else{if(c||s.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||i.test(s)||a.test(s)||t.test(s))break;o+="\n"+p}!c&&!p.trim()&&(c=!0),r+=h+"\n",e=e.substring(h.length+1),s=u.slice(d)}}i.loose||(l?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(l=!0)),i.items.push({type:"list_item",raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(o),loose:!1,text:o,tokens:[]}),i.raw+=r}let o=i.items.at(-1);if(!o)return;o.raw=o.raw.trimEnd(),o.text=o.text.trimEnd(),i.raw=i.raw.trimEnd();for(let e of i.items){if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),e.task){if(e.text=e.text.replace(this.rules.other.listReplaceTask,""),"text"===e.tokens[0]?.type||"paragraph"===e.tokens[0]?.type){e.tokens[0].raw=e.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),e.tokens[0].text=e.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,"");break}}let n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:"checkbox",raw:n[0]+" ",checked:"[ ]"!==n[0]};e.checked=t.checked,i.loose?e.tokens[0]&&["paragraph","text"].includes(e.tokens[0].type)&&"tokens"in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:"paragraph",raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}if(!i.loose){let n=e.tokens.filter(e=>"space"===e.type),t=n.length>0&&n.some(e=>this.rules.other.anyLine.test(e.raw));i.loose=t}}if(i.loose)for(let e of i.items){e.loose=!0;for(let n of e.tokens)"text"===n.type&&(n.type="paragraph")}return i}}html(e){let n=this.rules.block.html.exec(e);if(n)return{type:"html",block:!0,raw:n[0],pre:"pre"===n[1]||"script"===n[1]||"style"===n[1],text:n[0]}}def(e){let n=this.rules.block.def.exec(e);if(n){let e=n[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),t=n[2]?n[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):n[3];return{type:"def",tag:e,raw:n[0],href:t,title:r}}}table(e){let n=this.rules.block.table.exec(e);if(!n||!this.rules.other.tableDelimiter.test(n[2]))return;let t=Gr(n[1]),r=n[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=n[3]?.trim()?n[3].replace(this.rules.other.tableRowBlankLine,"").split("\n"):[],a={type:"table",raw:n[0],header:[],align:[],rows:[]};if(t.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push("right"):this.rules.other.tableAlignCenter.test(e)?a.align.push("center"):this.rules.other.tableAlignLeft.test(e)?a.align.push("left"):a.align.push(null);for(let e=0;e<t.length;e++)a.header.push({text:t[e],tokens:this.lexer.inline(t[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(Gr(e,a.header.length).map((e,n)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[n]})));return a}}lheading(e){let n=this.rules.block.lheading.exec(e);if(n)return{type:"heading",raw:n[0],depth:"="===n[2].charAt(0)?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(e){let n=this.rules.block.paragraph.exec(e);if(n){let e="\n"===n[1].charAt(n[1].length-1)?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let n=this.rules.block.text.exec(e);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(e){let n=this.rules.inline.escape.exec(e);if(n)return{type:"escape",raw:n[0],text:n[1]}}tag(e){let n=this.rules.inline.tag.exec(e);if(n)return!this.lexer.state.inLink&&this.rules.other.startATag.test(n[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:n[0]}}link(e){let n=this.rules.inline.link.exec(e);if(n){let e=n[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let n=Qr(e.slice(0,-1),"\\");if((e.length-n.length)%2==0)return}else{let e=function(e,n){if(-1===e.indexOf(n[1]))return-1;let t=0;for(let r=0;r<e.length;r++)if("\\"===e[r])r++;else if(e[r]===n[0])t++;else if(e[r]===n[1]&&(t--,t<0))return r;return t>0?-2:-1}(n[2],"()");if(-2===e)return;if(e>-1){let t=(0===n[0].indexOf("!")?5:4)+n[1].length+e;n[2]=n[2].substring(0,e),n[0]=n[0].substring(0,t).trim(),n[3]=""}}let t=n[2],r="";if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(t);e&&(t=e[1],r=e[3])}else r=n[3]?n[3].slice(1,-1):"";return t=t.trim(),this.rules.other.startAngleBracket.test(t)&&(t=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?t.slice(1):t.slice(1,-1)),Xr(n,{href:t&&t.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},n[0],this.lexer,this.rules)}}reflink(e,n){let t;if((t=this.rules.inline.reflink.exec(e))||(t=this.rules.inline.nolink.exec(e))){let e=n[(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!e){let e=t[0].charAt(0);return{type:"text",raw:e,text:e}}return Xr(t,e,t[0],this.lexer,this.rules)}}emStrong(e,n,t=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||r[3]&&t.match(this.rules.other.unicodeAlphaNumeric))&&(!r[1]&&!r[2]||!t||this.rules.inline.punctuation.exec(t))){let t,i,a=[...r[0]].length-1,l=a,o=0,s="*"===r[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(s.lastIndex=0,n=n.slice(-1*e.length+a);null!=(r=s.exec(n));){if(t=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!t)continue;if(i=[...t].length,r[3]||r[4]){l+=i;continue}if((r[5]||r[6])&&a%3&&!((a+i)%3)){o+=i;continue}if(l-=i,l>0)continue;i=Math.min(i,i+l+o);let n=[...r[0]][0].length,s=e.slice(0,a+r.index+n+i);if(Math.min(a,i)%2){let e=s.slice(1,-1);return{type:"em",raw:s,text:e,tokens:this.lexer.inlineTokens(e)}}let p=s.slice(2,-2);return{type:"strong",raw:s,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(e){let n=this.rules.inline.code.exec(e);if(n){let e=n[2].replace(this.rules.other.newLineCharGlobal," "),t=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return t&&r&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:n[0],text:e}}}br(e){let n=this.rules.inline.br.exec(e);if(n)return{type:"br",raw:n[0]}}del(e){let n=this.rules.inline.del.exec(e);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(e){let n=this.rules.inline.autolink.exec(e);if(n){let e,t;return"@"===n[2]?(e=n[1],t="mailto:"+e):(e=n[1],t=e),{type:"link",raw:n[0],text:e,href:t,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let n;if(n=this.rules.inline.url.exec(e)){let e,t;if("@"===n[2])e=n[0],t="mailto:"+e;else{let r;do{r=n[0],n[0]=this.rules.inline._backpedal.exec(n[0])?.[0]??""}while(r!==n[0]);e=n[0],t="www."===n[1]?"http://"+n[0]:n[0]}return{type:"link",raw:n[0],text:e,href:t,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){let n=this.rules.inline.text.exec(e);if(n){let e=this.lexer.state.inRawBlock;return{type:"text",raw:n[0],text:n[0],escaped:e}}}},Yr=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Kt,this.options.tokenizer=this.options.tokenizer||new Jr,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:Jt,block:Ur.normal,inline:Fr.normal};this.options.pedantic?(n.block=Ur.pedantic,n.inline=Fr.pedantic):this.options.gfm&&(n.block=Ur.gfm,this.options.breaks?n.inline=Fr.breaks:n.inline=Fr.gfm),this.tokenizer.rules=n}static get rules(){return{block:Ur,inline:Fr}}static lex(n,t){return new e(t).lex(n)}static lexInline(n,t){return new e(t).inlineTokens(n)}lex(e){e=e.replace(Jt.carriageReturn,"\n"),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let n=this.inlineQueue[e];this.inlineTokens(n.src,n.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],t=!1){for(this.options.pedantic&&(e=e.replace(Jt.tabCharGlobal," ").replace(Jt.spaceLine,""));e;){let r;if(this.options.extensions?.block?.some(t=>!!(r=t.call({lexer:this},e,n))&&(e=e.substring(r.raw.length),n.push(r),!0)))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let t=n.at(-1);1===r.raw.length&&void 0!==t?t.raw+="\n":n.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let t=n.at(-1);"paragraph"===t?.type||"text"===t?.type?(t.raw+=(t.raw.endsWith("\n")?"":"\n")+r.raw,t.text+="\n"+r.text,this.inlineQueue.at(-1).src=t.text):n.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let t=n.at(-1);"paragraph"===t?.type||"text"===t?.type?(t.raw+=(t.raw.endsWith("\n")?"":"\n")+r.raw,t.text+="\n"+r.raw,this.inlineQueue.at(-1).src=t.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},n.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),n.push(r);continue}let i=e;if(this.options.extensions?.startBlock){let n,t=1/0,r=e.slice(1);this.options.extensions.startBlock.forEach(e=>{n=e.call({lexer:this},r),"number"==typeof n&&n>=0&&(t=Math.min(t,n))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(this.state.top&&(r=this.tokenizer.paragraph(i))){let a=n.at(-1);t&&"paragraph"===a?.type?(a.raw+=(a.raw.endsWith("\n")?"":"\n")+r.raw,a.text+="\n"+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):n.push(r),t=i.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let t=n.at(-1);"text"===t?.type?(t.raw+=(t.raw.endsWith("\n")?"":"\n")+r.raw,t.text+="\n"+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=t.text):n.push(r);continue}if(e){let n="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(n);break}throw new Error(n)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){let t,r=e,i=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(i=this.tokenizer.rules.inline.reflinkSearch.exec(r));)e.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(i=this.tokenizer.rules.inline.anyPunctuation.exec(r));)r=r.slice(0,i.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;null!=(i=this.tokenizer.rules.inline.blockSkip.exec(r));)t=i[2]?i[2].length:0,r=r.slice(0,i.index+t)+"["+"a".repeat(i[0].length-t-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let a=!1,l="";for(;e;){let t;if(a||(l=""),a=!1,this.options.extensions?.inline?.some(r=>!!(t=r.call({lexer:this},e,n))&&(e=e.substring(t.raw.length),n.push(t),!0)))continue;if(t=this.tokenizer.escape(e)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.tag(e)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.link(e)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(t.raw.length);let r=n.at(-1);"text"===t.type&&"text"===r?.type?(r.raw+=t.raw,r.text+=t.text):n.push(t);continue}if(t=this.tokenizer.emStrong(e,r,l)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.codespan(e)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.br(e)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.del(e)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.autolink(e)){e=e.substring(t.raw.length),n.push(t);continue}if(!this.state.inLink&&(t=this.tokenizer.url(e))){e=e.substring(t.raw.length),n.push(t);continue}let i=e;if(this.options.extensions?.startInline){let n,t=1/0,r=e.slice(1);this.options.extensions.startInline.forEach(e=>{n=e.call({lexer:this},r),"number"==typeof n&&n>=0&&(t=Math.min(t,n))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(t=this.tokenizer.inlineText(i)){e=e.substring(t.raw.length),"_"!==t.raw.slice(-1)&&(l=t.raw.slice(-1)),a=!0;let r=n.at(-1);"text"===r?.type?(r.raw+=t.raw,r.text+=t.text):n.push(t);continue}if(e){let n="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(n);break}throw new Error(n)}}return n}},ei=class{options;parser;constructor(e){this.options=e||Kt}space(e){return""}code({text:e,lang:n,escaped:t}){let r=(n||"").match(Jt.notSpaceStart)?.[0],i=e.replace(Jt.endingNewline,"")+"\n";return r?'<pre><code class="language-'+Kr(r)+'">'+(t?i:Kr(i,!0))+"</code></pre>\n":"<pre><code>"+(t?i:Kr(i,!0))+"</code></pre>\n"}blockquote({tokens:e}){return`<blockquote>\n${this.parser.parse(e)}</blockquote>\n`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:n}){return`<h${n}>${this.parser.parseInline(e)}</h${n}>\n`}hr(e){return"<hr>\n"}list(e){let n=e.ordered,t=e.start,r="";for(let n=0;n<e.items.length;n++){let t=e.items[n];r+=this.listitem(t)}let i=n?"ol":"ul";return"<"+i+(n&&1!==t?' start="'+t+'"':"")+">\n"+r+"</"+i+">\n"}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>\n`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>\n`}table(e){let n="",t="";for(let n=0;n<e.header.length;n++)t+=this.tablecell(e.header[n]);n+=this.tablerow({text:t});let r="";for(let n=0;n<e.rows.length;n++){let i=e.rows[n];t="";for(let e=0;e<i.length;e++)t+=this.tablecell(i[e]);r+=this.tablerow({text:t})}return r&&(r=`<tbody>${r}</tbody>`),"<table>\n<thead>\n"+n+"</thead>\n"+r+"</table>\n"}tablerow({text:e}){return`<tr>\n${e}</tr>\n`}tablecell(e){let n=this.parser.parseInline(e.tokens),t=e.header?"th":"td";return(e.align?`<${t} align="${e.align}">`:`<${t}>`)+n+`</${t}>\n`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Kr(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:n,tokens:t}){let r=this.parser.parseInline(t),i=Zr(e);if(null===i)return r;let a='<a href="'+(e=i)+'"';return n&&(a+=' title="'+Kr(n)+'"'),a+=">"+r+"</a>",a}image({href:e,title:n,text:t,tokens:r}){r&&(t=this.parser.parseInline(r,this.parser.textRenderer));let i=Zr(e);if(null===i)return Kr(t);let a=`<img src="${e=i}" alt="${t}"`;return n&&(a+=` title="${Kr(n)}"`),a+=">",a}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Kr(e.text)}},ni=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},ti=class e{options;renderer;textRenderer;constructor(e){this.options=e||Kt,this.options.renderer=this.options.renderer||new ei,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ni}static parse(n,t){return new e(t).parse(n)}static parseInline(n,t){return new e(t).parseInline(n)}parse(e){let n="";for(let t=0;t<e.length;t++){let r=e[t];if(this.options.extensions?.renderers?.[r.type]){let e=r,t=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==t||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(e.type)){n+=t||"";continue}}let i=r;switch(i.type){case"space":n+=this.renderer.space(i);break;case"hr":n+=this.renderer.hr(i);break;case"heading":n+=this.renderer.heading(i);break;case"code":n+=this.renderer.code(i);break;case"table":n+=this.renderer.table(i);break;case"blockquote":n+=this.renderer.blockquote(i);break;case"list":n+=this.renderer.list(i);break;case"checkbox":n+=this.renderer.checkbox(i);break;case"html":n+=this.renderer.html(i);break;case"def":n+=this.renderer.def(i);break;case"paragraph":n+=this.renderer.paragraph(i);break;case"text":n+=this.renderer.text(i);break;default:{let e='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}parseInline(e,n=this.renderer){let t="";for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){t+=e||"";continue}}let a=i;switch(a.type){case"escape":case"text":t+=n.text(a);break;case"html":t+=n.html(a);break;case"link":t+=n.link(a);break;case"image":t+=n.image(a);break;case"checkbox":t+=n.checkbox(a);break;case"strong":t+=n.strong(a);break;case"em":t+=n.em(a);break;case"codespan":t+=n.codespan(a);break;case"br":t+=n.br(a);break;case"del":t+=n.del(a);break;default:{let e='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return t}},ri=class{options;block;constructor(e){this.options=e||Kt}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?Yr.lex:Yr.lexInline}provideParser(){return this.block?ti.parse:ti.parseInline}},ii=new class{defaults={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=ti;Renderer=ei;TextRenderer=ni;Lexer=Yr;Tokenizer=Jr;Hooks=ri;constructor(...e){this.use(...e)}walkTokens(e,n){let t=[];for(let r of e)switch(t=t.concat(n.call(this,r)),r.type){case"table":{let e=r;for(let r of e.header)t=t.concat(this.walkTokens(r.tokens,n));for(let r of e.rows)for(let e of r)t=t.concat(this.walkTokens(e.tokens,n));break}case"list":{let e=r;t=t.concat(this.walkTokens(e.items,n));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);t=t.concat(this.walkTokens(i,n))}):e.tokens&&(t=t.concat(this.walkTokens(e.tokens,n)))}}return t}use(...e){let n=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let t={...e};if(t.async=this.defaults.async||t.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){let t=n.renderers[e.name];n.renderers[e.name]=t?function(...n){let r=e.renderer.apply(this,n);return!1===r&&(r=t.apply(this,n)),r}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");let t=n[e.level];t?t.unshift(e.tokenizer):n[e.level]=[e.tokenizer],e.start&&("block"===e.level?n.startBlock?n.startBlock.push(e.start):n.startBlock=[e.start]:"inline"===e.level&&(n.startInline?n.startInline.push(e.start):n.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(n.childTokens[e.name]=e.childTokens)}),t.extensions=n),e.renderer){let n=this.defaults.renderer||new ei(this.defaults);for(let t in e.renderer){if(!(t in n))throw new Error(`renderer '${t}' does not exist`);if(["options","parser"].includes(t))continue;let r=t,i=e.renderer[r],a=n[r];n[r]=(...e)=>{let t=i.apply(n,e);return!1===t&&(t=a.apply(n,e)),t||""}}t.renderer=n}if(e.tokenizer){let n=this.defaults.tokenizer||new Jr(this.defaults);for(let t in e.tokenizer){if(!(t in n))throw new Error(`tokenizer '${t}' does not exist`);if(["options","rules","lexer"].includes(t))continue;let r=t,i=e.tokenizer[r],a=n[r];n[r]=(...e)=>{let t=i.apply(n,e);return!1===t&&(t=a.apply(n,e)),t}}t.tokenizer=n}if(e.hooks){let n=this.defaults.hooks||new ri;for(let t in e.hooks){if(!(t in n))throw new Error(`hook '${t}' does not exist`);if(["options","block"].includes(t))continue;let r=t,i=e.hooks[r],a=n[r];ri.passThroughHooks.has(t)?n[r]=e=>{if(this.defaults.async&&ri.passThroughHooksRespectAsync.has(t))return(async()=>{let t=await i.call(n,e);return a.call(n,t)})();let r=i.call(n,e);return a.call(n,r)}:n[r]=(...e)=>{if(this.defaults.async)return(async()=>{let t=await i.apply(n,e);return!1===t&&(t=await a.apply(n,e)),t})();let t=i.apply(n,e);return!1===t&&(t=a.apply(n,e)),t}}t.hooks=n}if(e.walkTokens){let n=this.defaults.walkTokens,r=e.walkTokens;t.walkTokens=function(e){let t=[];return t.push(r.call(this,e)),n&&(t=t.concat(n.call(this,e))),t}}this.defaults={...this.defaults,...t}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,n){return Yr.lex(e,n??this.defaults)}parser(e,n){return ti.parse(e,n??this.defaults)}parseMarkdown(e){return(n,t)=>{let r={...t},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(!0===this.defaults.async&&!1===r.async)return a(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||null===n)return a(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof n)return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let t=i.hooks?await i.hooks.preprocess(n):n,r=await(i.hooks?await i.hooks.provideLexer():e?Yr.lex:Yr.lexInline)(t,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let l=await(i.hooks?await i.hooks.provideParser():e?ti.parse:ti.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(l):l})().catch(a);try{i.hooks&&(n=i.hooks.preprocess(n));let t=(i.hooks?i.hooks.provideLexer():e?Yr.lex:Yr.lexInline)(n,i);i.hooks&&(t=i.hooks.processAllTokens(t)),i.walkTokens&&this.walkTokens(t,i.walkTokens);let r=(i.hooks?i.hooks.provideParser():e?ti.parse:ti.parseInline)(t,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,n){return t=>{if(t.message+="\nPlease report this to https://github.com/markedjs/marked.",e){let e="<p>An error occurred:</p><pre>"+Kr(t.message+"",!0)+"</pre>";return n?Promise.resolve(e):e}if(n)return Promise.reject(t);throw t}}};function ai(e,n){return ii.parse(e,n)}function li(e){try{return ai.parse(e)}catch(n){return console.error("[Pillar] Markdown parsing error:",n),e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/\n/g,"<br>")}}ai.options=ai.setOptions=function(e){return ii.setOptions(e),ai.defaults=ii.defaults,Zt(ai.defaults),ai},ai.getDefaults=Vt,ai.defaults=Kt,ai.use=function(...e){return ii.use(...e),ai.defaults=ii.defaults,Zt(ai.defaults),ai},ai.walkTokens=function(e,n){return ii.walkTokens(e,n)},ai.parseInline=ii.parseInline,ai.Parser=ti,ai.parser=ti.parse,ai.Renderer=ei,ai.TextRenderer=ni,ai.Lexer=Yr,ai.lexer=Yr.lex,ai.Tokenizer=Jr,ai.Hooks=ri,ai.parse=ai,ai.options,ai.setOptions,ai.use,ai.walkTokens,ai.parseInline,ti.parse,Yr.lex,ai.setOptions({gfm:!0,breaks:!0});const oi={navigate:"arrow-right",open_modal:"layout",fill_form:"edit",trigger_action:"zap",copy_text:"copy",external_link:"external-link",start_tutorial:"play-circle"},si={"arrow-right":'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"/><polyline points="12,5 19,12 12,19"/></svg>',"user-plus":'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="8.5" cy="7" r="4"/><line x1="20" y1="8" x2="20" y2="14"/><line x1="23" y1="11" x2="17" y2="11"/></svg>',settings:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"/></svg>',"external-link":'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15,3 21,3 21,9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>',"play-circle":'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><polygon points="10,8 16,12 10,16 10,8"/></svg>',zap:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="13,2 3,14 12,14 11,22 21,10 12,10 13,2"/></svg>',"message-circle":'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"/></svg>',download:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7,10 12,15 17,10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',copy:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>',layout:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="9" y1="21" x2="9" y2="9"/></svg>',edit:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>'};function pi(e){const{task:n,onExecute:t}=e,r=document.createElement("button");r.className=function(e="primary"){return`pillar-task-btn pillar-task-btn--${e}`}(n.buttonVariant||"primary"),r.type="button";const i=n.icon||((a=n.taskType)&&oi[a]||"zap");var a;if(i&&si[i]){const e=document.createElement("span");e.className="pillar-task-btn__icon",e.innerHTML=si[i],r.appendChild(e)}const l=n.label||n.name.split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");const o=document.createElement("span");return o.className="pillar-task-btn__label",o.textContent=l,r.appendChild(o),r.addEventListener("click",()=>{const e=Vi.getInstance();if(e){const t=n.data||{},r=n.path||t.path,i=n.externalUrl||t.url,a={id:n.id,name:n.name,data:t,taskType:n.taskType,path:r,externalUrl:i};e.executeTask(a)}t?.()}),r}const ci="\n/* Task Button Component */\n.pillar-task-btn {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 8px 14px;\n font-size: 13px;\n font-weight: 500;\n font-family: inherit;\n border-radius: 8px;\n cursor: pointer;\n transition: all 0.15s ease;\n border: 1px solid transparent;\n text-decoration: none;\n}\n\n.pillar-task-btn__icon {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n}\n\n.pillar-task-btn__icon svg {\n width: 16px;\n height: 16px;\n}\n\n.pillar-task-btn__label {\n white-space: nowrap;\n}\n\n/* Primary variant (default) */\n.pillar-task-btn--primary {\n background: #2563eb;\n color: #ffffff;\n border-color: #2563eb;\n}\n\n.pillar-task-btn--primary:hover {\n background: #1d4ed8;\n border-color: #1d4ed8;\n}\n\n/* Default variant */\n.pillar-task-btn--default {\n background: #f3f4f6;\n color: #1a1a1a;\n border-color: #e5e7eb;\n}\n\n.pillar-task-btn--default:hover {\n background: #e5e7eb;\n}\n\n/* Secondary variant */\n.pillar-task-btn--secondary {\n background: #eff6ff;\n color: #2563eb;\n border-color: #dbeafe;\n}\n\n.pillar-task-btn--secondary:hover {\n background: #dbeafe;\n}\n\n/* Outline variant */\n.pillar-task-btn--outline {\n background: transparent;\n color: #2563eb;\n border-color: #2563eb;\n}\n\n.pillar-task-btn--outline:hover {\n background: #eff6ff;\n}\n\n/* Ghost variant */\n.pillar-task-btn--ghost {\n background: transparent;\n color: #6b7280;\n border-color: transparent;\n}\n\n.pillar-task-btn--ghost:hover {\n background: #f3f4f6;\n color: #1a1a1a;\n}\n\n/* Task button group */\n.pillar-task-btn-group {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n margin-top: 12px;\n}\n\n/* Task suggestion card in chat */\n.pillar-task-suggestion {\n display: flex;\n flex-direction: column;\n gap: 8px;\n padding: 12px;\n background: #f9fafb;\n border: 1px solid #e5e7eb;\n border-radius: 12px;\n margin-top: 12px;\n}\n\n.pillar-task-suggestion__header {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 11px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n color: #6b7280;\n}\n\n.pillar-task-suggestion__header svg {\n width: 14px;\n height: 14px;\n}\n\n.pillar-task-suggestion__description {\n font-size: 13px;\n color: #374151;\n}\n";function di(){const e=mt(),n=me(null);_e(()=>{const e=Ln.value,n=On.value;e&&(Ln.value=null,On.value=[],i(e,n.length>0?n:void 0))},[Bn.value]),_e(()=>{n.current&&(n.current.scrollTop=n.current.scrollHeight)},[$n.value]),_e(()=>{const e=Vi.getInstance();if(!e)return;const n=e.on("task:complete",({name:e,success:n})=>{((e,n,t)=>{const r=$n.value;for(let i=r.length-1;i>=0;i--){const a=r[i];if(a.actionStatus?.[e]){const l={...a.actionStatus,[e]:{status:n?"success":"failed",completedAt:Date.now(),errorMessage:t}};return void($n.value=[...r.slice(0,i),{...a,actionStatus:l},...r.slice(i+1)])}}})(e,n);const t=function(e,n){const t=e.replace(/_/g," ").toLowerCase();return n?t.startsWith("open ")?`Opened ${t.slice(5)}`:t.startsWith("go to ")?`Navigated to ${t.slice(6)}`:t.startsWith("navigate to ")?`Navigated to ${t.slice(12)}`:"Done!":`Failed to ${t}`}(e,n);((e,n)=>{const t=$n.value;for(let r=t.length-1;r>=0;r--){const i=t[r];if(i.actionStatus?.[e])return void($n.value=[...t.slice(0,r),{...i,content:n},...t.slice(r+1)])}})(e,t)});return n},[]);const t=be(e=>{console.log("[Pillar] Plan received:",e.id,e.goal);const n=Vi.getInstance();n&&n.handlePlanReceived(e);Vn("I'll help you with that. Here's my plan:")},[]),r=be(e=>{const n=Vi.getInstance();console.log("[Pillar] handleActionsReceived called with",e.length,"actions"),console.log("[Pillar] Actions detail:",e.map(e=>({name:e.name,autoRun:e.autoRun})));const t=e.filter(e=>!0===e.autoRun),r=e.filter(e=>!e.autoRun);return console.log("[Pillar] Auto-run actions:",t.length,", Manual actions:",r.length),n&&t.length>0?(console.log("[Pillar] Executing auto-run actions..."),t.forEach(e=>{const t=e.data||{},r=t.path,i=t.url,a=$n.value.length-1;a>=0&&((e,n)=>{const t=$n.value;if(e>=0&&e<t.length){const r=t[e],i={...r.actionStatus||{},[n]:{status:"pending"}};$n.value=[...t.slice(0,e),{...r,actionStatus:i},...t.slice(e+1)]}})(a,e.name),console.log("[Pillar] Executing action:",e.name),n.executeTask({id:e.id,name:e.name,taskType:e.taskType,data:t,path:r,externalUrl:i})}),[]):n?r:(console.warn("[Pillar] No Pillar instance available for auto-run"),e)},[]),i=be(async(n,i,a)=>{var l,o,s;((e,n,t)=>{$n.value=[...$n.value,{role:"user",content:e,userContext:n&&n.length>0?n:void 0,images:t&&t.length>0?t:void 0}]})(n,i,a),Zn(),Kn(!0),l="",$n.value=[...$n.value,{role:"assistant",content:l,id:o}];try{let l="",o=[];const p=$n.value.slice(0,-1),c=await e.chat(n,p,e=>{l+=e,Vn(l)},void 0,Tn.value,e=>{o=r(e)},t,i,a,e=>{var n,t;n=e,In.value=[...In.value,n],t={kind:e.kind,message:e.message},zn.value=t});let d=o;c.actions&&c.actions.length>0&&(d=r(c.actions)),Ct.value&&!c.message?Vn(void 0,c.messageId,d,c.sources):Vn(c.message,c.messageId,d,c.sources),c.conversationId&&(s=c.conversationId,Tn.value=s)}catch(e){console.error("[Pillar] Chat error:",e),Vn("Sorry, I encountered an error. Please try again.")}finally{Kn(!1),zn.value={kind:null},Zn()}},[e,r]),a=be(async(n,t)=>{((e,n)=>{$n.value=$n.value.map(t=>t.id===e?{...t,feedback:n}:t)})(n,t),await e.submitFeedback(n,t)},[e]),l=be((e,n,t)=>{En.value||i(e,n.length>0?n:void 0,t.length>0?t:void 0)},[i]),o=me(new Map);return _e(()=>{const e=Vi.getInstance();$n.value.forEach((n,t)=>{if("assistant"===n.role&&n.actions&&n.actions.length>0){const r=o.current.get(t);if(r&&0===r.children.length){const t=n.actions.filter(e=>"inline_ui"===e.taskType),i=n.actions.filter(e=>"inline_ui"!==e.taskType);if(t.forEach(n=>{const t=function(e,n,t){const r=document.createElement("div");r.className="pillar-confirm-card-wrapper";const i=e.data?.card_type||e.name,a=Vi.getInstance(),l=a?.getCardRenderer(i),o={onConfirm:t=>{n(t||e.data)},onCancel:t,onStateChange:(e,n)=>{console.log(`[Pillar] Card state changed to ${e}${n?`: ${n}`:""}`)}};if(l)try{const n=l(r,e.data||{},o);r._cleanup=n||void 0}catch(e){console.error("[Pillar] Custom card renderer error:",e)}else{const n=ut(e,o);r.appendChild(n)}return r}(n,t=>{e&&e.executeTask({id:n.id,name:n.name,taskType:n.taskType,data:t||n.data||{}})},()=>{console.log("[Pillar] Confirm action cancelled:",n.name)});r.appendChild(t)}),i.length>0){const e=function(e){const n=document.createElement("div");return n.className="pillar-task-btn-group",e.forEach(e=>{const t=pi({task:e});n.appendChild(t)}),n}(i);r.appendChild(e)}}}})},[$n.value]),ee("div",{class:"_pillar-chat-view pillar-chat-view",children:[ee("div",{class:"_pillar-chat-view-messages pillar-chat-view-messages",ref:n,children:[0===$n.value.length&&ee("div",{class:"_pillar-chat-view-welcome pillar-chat-view-welcome",children:[ee("div",{class:"_pillar-chat-view-welcome-icon pillar-chat-view-welcome-icon",children:"💬"}),ee("div",{class:"_pillar-chat-view-welcome-title pillar-chat-view-welcome-title",children:"Ask a question"}),ee("div",{class:"_pillar-chat-view-welcome-text pillar-chat-view-welcome-text",children:"Ask me anything about how to use this product."})]}),$n.value.map((e,n)=>ee("div",{class:`_pillar-chat-view-message pillar-chat-view-message _pillar-chat-view-message--${e.role} pillar-chat-view-message--${e.role}`,children:"user"===e.role?ee("div",{class:"_pillar-message-user pillar-message-user",children:[e.userContext&&e.userContext.length>0&&ee(Ht,{contexts:e.userContext,readOnly:!0}),e.images&&e.images.length>0&&ee("div",{class:"_pillar-message-user-images pillar-message-user-images",children:e.images.map((e,n)=>ee("img",{src:e.url,alt:`Attachment ${n+1}`,class:"_pillar-message-user-image pillar-message-user-image"},n))}),e.content]}):ee("div",{class:"_pillar-message-assistant-wrapper pillar-message-assistant-wrapper",children:[ee("div",{class:"_pillar-message-assistant-content pillar-message-assistant-content",children:[!e.content&&In.value.length>0&&ee("div",{class:"_pillar-progress-events pillar-progress-events",children:In.value.map((n,t)=>ee(Ft,{progress:n,isActive:t===In.value.length-1&&!e.content},n.progress_id||t))}),e.content?ee("div",{class:"_pillar-message-assistant pillar-message-assistant",dangerouslySetInnerHTML:{__html:li(e.content)}}):0===In.value.length&&ee("div",{class:"_pillar-progress-indicator pillar-progress-indicator",children:[ee("div",{class:"_pillar-loading-spinner pillar-loading-spinner"}),ee("span",{class:"_pillar-progress-message pillar-progress-message",children:zn.value.message||"Processing..."})]}),e.actionStatus&&Object.keys(e.actionStatus).length>0&&ee("span",{class:"_pillar-action-status pillar-action-status",children:Object.entries(e.actionStatus).map(([e,n])=>ee("span",{class:`_pillar-action-status-indicator pillar-action-status-indicator _pillar-action-status-indicator--${n.status} pillar-action-status-indicator--${n.status}`,title:"failed"===n.status?n.errorMessage:e,dangerouslySetInnerHTML:{__html:"success"===n.status?'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>':"failed"===n.status?'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>':'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><path d="M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83" opacity="0.3"/><path d="M12 2v4"/></svg>'}},e))})]}),e.id&&e.content&&ee("div",{class:"_pillar-feedback-icons pillar-feedback-icons",children:[ee("button",{class:"_pillar-feedback-btn pillar-feedback-btn "+("up"===e.feedback?"_pillar-feedback-btn--active pillar-feedback-btn--active":""),onClick:()=>a(e.id,"up"),"aria-label":"Helpful",title:"Helpful",type:"button",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"/></svg>'}}),ee("button",{class:"_pillar-feedback-btn pillar-feedback-btn "+("down"===e.feedback?"_pillar-feedback-btn--active pillar-feedback-btn--active":""),onClick:()=>a(e.id,"down"),"aria-label":"Not helpful",title:"Not helpful",type:"button",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17"/></svg>'}})]}),e.sources&&e.sources.length>0&&ee("div",{class:"_pillar-chat-sources pillar-chat-sources",children:[ee("div",{class:"_pillar-chat-sources-title pillar-chat-sources-title",children:"Sources"}),e.sources.map(e=>ee("div",{class:"_pillar-chat-source pillar-chat-source",children:e.title},e.slug))]}),e.actions&&e.actions.length>0&&ee("div",{class:"_pillar-chat-actions pillar-chat-actions",children:[ee("div",{class:"_pillar-chat-actions-title pillar-chat-actions-title",children:"Suggested actions"}),ee("div",{ref:e=>{e&&o.current.set(n,e)},class:"_pillar-chat-actions-buttons pillar-chat-actions-buttons"})]})]})},n)),Ct.value&&ee(Mt,{})]}),ee("div",{class:"_pillar-chat-view-input-area pillar-chat-view-input-area",children:ee(Ot,{placeholder:"Ask a question...",disabled:En.value,onSubmit:l})})]})}function ui(){const e=nt.value,n=en.value,t=(()=>{if("assistant"!==n)return n.charAt(0).toUpperCase()+n.slice(1)})(),r="chat"===e.type,i="home"===e.type;return ee("div","assistant"!==n?{class:"_pillar-panel-ui pillar-panel-ui",children:[ee(jt,{currentView:"home",customTitle:t}),ee("div",{class:"_pillar-content pillar-content",children:"support"===n?ee("div",{style:{padding:"24px",textAlign:"center"},children:[ee("h2",{style:{fontSize:"18px",fontWeight:"600",marginBottom:"8px"},children:"Hello World"}),ee("p",{style:{color:"var(--pillar-text-muted)",fontSize:"14px"},children:"Support tab content goes here."})]}):null})]}:{class:"_pillar-panel-ui pillar-panel-ui",children:[ee(jt,{currentView:e.type,customTitle:t,hideNavigation:r}),ee("div",{class:"_pillar-content pillar-content",children:(()=>{switch(e.type){case"home":default:return ee(Ut,{});case"chat":return ee(di,{})}})()}),!r&&!i&&ee("div",{class:"_pillar-chat-input-area pillar-chat-input-area",children:ee(Ot,{placeholder:"Ask a question..."})})]})}function hi(e,n=""){const t=[];return e.primary&&t.push(`--pillar-primary${n}: ${e.primary};`),e.primaryHover&&t.push(`--pillar-primary-hover${n}: ${e.primaryHover};`),e.background&&t.push(`--pillar-bg${n}: ${e.background};`),e.backgroundSecondary&&t.push(`--pillar-bg-secondary${n}: ${e.backgroundSecondary};`),e.text&&t.push(`--pillar-text${n}: ${e.text};`),e.textMuted&&t.push(`--pillar-text-muted${n}: ${e.textMuted};`),e.border&&t.push(`--pillar-border${n}: ${e.border};`),e.borderLight&&t.push(`--pillar-border-light${n}: ${e.borderLight};`),t.join("\n ")}function gi(e){const n=hi(e.colors),t=hi(e.darkColors);let r="";return n&&(r+=`\n:host {\n ${n}\n}\n`),t&&(r+=`\n@media (prefers-color-scheme: dark) {\n :host:not([data-theme="light"]) {\n ${t}\n }\n}\n:host([data-theme="dark"]) {\n ${t}\n}\n`),r}const fi='\n/* ============================================================================\n CSS Custom Properties (Variables)\n Users can override these to customize colors\n ============================================================================ */\n\n:host {\n /* Core colors - Light mode (default) */\n --pillar-primary: #2563eb;\n --pillar-primary-hover: #1d4ed8;\n --pillar-primary-light: #eff6ff;\n --pillar-primary-light-hover: #dbeafe;\n \n --pillar-bg: #ffffff;\n --pillar-bg-secondary: #f9fafb;\n --pillar-bg-tertiary: #f3f4f6;\n \n --pillar-text: #1a1a1a;\n --pillar-text-secondary: #374151;\n --pillar-text-muted: #6b7280;\n --pillar-text-placeholder: #9ca3af;\n \n --pillar-border: #e5e7eb;\n --pillar-border-light: #f3f4f6;\n \n /* Shadows */\n --pillar-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);\n --pillar-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);\n \n /* Code blocks */\n --pillar-code-bg: #1f2937;\n --pillar-code-text: #e5e7eb;\n \n /* Scrollbar */\n --pillar-scrollbar-track: transparent;\n --pillar-scrollbar-thumb: #d1d5db;\n --pillar-scrollbar-thumb-hover: #9ca3af;\n \n /* Spacing (can be customized) */\n --pillar-panel-width: 380px;\n --pillar-spacing-xs: 4px;\n --pillar-spacing-sm: 8px;\n --pillar-spacing-md: 12px;\n --pillar-spacing-lg: 16px;\n --pillar-spacing-xl: 20px;\n --pillar-spacing-2xl: 24px;\n \n /* Border radius */\n --pillar-radius-sm: 4px;\n --pillar-radius-md: 6px;\n --pillar-radius-lg: 8px;\n --pillar-radius-xl: 10px;\n --pillar-radius-full: 9999px;\n \n /* Typography */\n --pillar-font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, \'Helvetica Neue\', Arial, sans-serif;\n --pillar-font-mono: \'SF Mono\', Consolas, monospace;\n --pillar-font-size-xs: 11px;\n --pillar-font-size-sm: 12px;\n --pillar-font-size-base: 14px;\n --pillar-font-size-md: 15px;\n --pillar-font-size-lg: 16px;\n --pillar-font-size-xl: 18px;\n --pillar-font-size-2xl: 20px;\n \n /* Animation */\n --pillar-transition-fast: 0.15s ease;\n --pillar-transition-normal: 0.3s ease;\n}\n\n/* Dark mode - Auto-detect from system preference */\n@media (prefers-color-scheme: dark) {\n :host:not([data-theme="light"]) {\n --pillar-primary: #3b82f6;\n --pillar-primary-hover: #60a5fa;\n --pillar-primary-light: #1e3a5f;\n --pillar-primary-light-hover: #1e4976;\n \n --pillar-bg: #1a1a1a;\n --pillar-bg-secondary: #262626;\n --pillar-bg-tertiary: #333333;\n \n --pillar-text: #f5f5f5;\n --pillar-text-secondary: #e5e5e5;\n --pillar-text-muted: #a3a3a3;\n --pillar-text-placeholder: #737373;\n \n --pillar-border: #404040;\n --pillar-border-light: #333333;\n \n --pillar-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);\n --pillar-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);\n \n --pillar-code-bg: #0d0d0d;\n --pillar-code-text: #e5e7eb;\n \n --pillar-scrollbar-thumb: #525252;\n --pillar-scrollbar-thumb-hover: #737373;\n }\n}\n\n/* Dark mode - Manual override */\n:host([data-theme="dark"]) {\n --pillar-primary: #3b82f6;\n --pillar-primary-hover: #60a5fa;\n --pillar-primary-light: #1e3a5f;\n --pillar-primary-light-hover: #1e4976;\n \n --pillar-bg: #1a1a1a;\n --pillar-bg-secondary: #262626;\n --pillar-bg-tertiary: #333333;\n \n --pillar-text: #f5f5f5;\n --pillar-text-secondary: #e5e5e5;\n --pillar-text-muted: #a3a3a3;\n --pillar-text-placeholder: #737373;\n \n --pillar-border: #404040;\n --pillar-border-light: #333333;\n \n --pillar-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);\n --pillar-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);\n \n --pillar-code-bg: #0d0d0d;\n --pillar-code-text: #e5e7eb;\n \n --pillar-scrollbar-thumb: #525252;\n --pillar-scrollbar-thumb-hover: #737373;\n}\n\n/* ============================================================================\n Base Styles\n Note: No CSS reset - we rely on explicit styles for SDK components\n and allow custom cards to inherit host app styling (Tailwind, etc.)\n ============================================================================ */\n\n:host {\n font-family: var(--pillar-font-family);\n font-size: var(--pillar-font-size-base);\n line-height: 1.5;\n color: var(--pillar-text);\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\n/* ============================================================================\n Panel Container\n Internal: _pillar-panel | Public: pillar-panel\n ============================================================================ */\n\n._pillar-panel {\n position: fixed;\n top: 0;\n bottom: 0;\n width: var(--pillar-panel-width);\n max-width: 100vw;\n background: var(--pillar-bg);\n border-left: 1px solid var(--pillar-border);\n display: flex;\n flex-direction: column;\n z-index: 99999;\n transform: translateX(100%);\n transition: transform var(--pillar-transition-normal);\n}\n\n._pillar-panel--right {\n right: 0;\n}\n\n._pillar-panel--left {\n left: 0;\n border-left: none;\n border-right: 1px solid var(--pillar-border);\n transform: translateX(-100%);\n}\n\n._pillar-panel--open {\n transform: translateX(0);\n}\n\n._pillar-panel--manual {\n position: static;\n transform: none;\n height: 100%;\n}\n\n._pillar-panel--full-width {\n width: 100vw;\n max-width: 100vw;\n}\n\n._pillar-panel-root {\n display: flex;\n flex-direction: column;\n height: 100%;\n}\n\n._pillar-panel-ui {\n display: flex;\n flex-direction: column;\n height: 100%;\n overflow: hidden;\n}\n\n/* Public override classes - empty by default */\n.pillar-panel {}\n.pillar-panel-root {}\n.pillar-panel-ui {}\n\n/* ============================================================================\n Backdrop\n ============================================================================ */\n\n._pillar-backdrop {\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.3);\n opacity: 0;\n visibility: hidden;\n transition: opacity var(--pillar-transition-normal), visibility var(--pillar-transition-normal);\n z-index: 99998;\n}\n\n._pillar-backdrop--visible {\n opacity: 1;\n visibility: visible;\n}\n\n.pillar-backdrop {}\n\n/* ============================================================================\n Header\n Internal: _pillar-header | Public: pillar-header\n ============================================================================ */\n\n._pillar-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: var(--pillar-spacing-lg) var(--pillar-spacing-xl);\n border-bottom: 1px solid var(--pillar-border);\n flex-shrink: 0;\n background: var(--pillar-bg);\n}\n\n._pillar-header-left {\n display: flex;\n align-items: center;\n gap: var(--pillar-spacing-sm);\n}\n\n._pillar-header-title {\n font-size: var(--pillar-font-size-lg);\n font-weight: 600;\n color: var(--pillar-text);\n}\n\n._pillar-header-right {\n display: flex;\n align-items: center;\n gap: var(--pillar-spacing-xs);\n}\n\n/* Public override classes */\n.pillar-header {}\n.pillar-header-left {}\n.pillar-header-right {}\n.pillar-header-title {}\n.pillar-new-chat-btn {}\n\n/* ============================================================================\n Icon Buttons (back, home, close)\n Internal: _pillar-icon-btn | Public: pillar-icon-btn\n ============================================================================ */\n\n._pillar-icon-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 32px;\n height: 32px;\n padding: 0;\n color: var(--pillar-text-muted);\n background: none;\n border: none;\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n transition: color var(--pillar-transition-fast), background var(--pillar-transition-fast);\n}\n\n._pillar-icon-btn:hover {\n color: var(--pillar-text);\n background: var(--pillar-bg-tertiary);\n}\n\n._pillar-icon-btn svg {\n width: 20px;\n height: 20px;\n}\n\n.pillar-icon-btn {}\n.pillar-back-btn {}\n.pillar-home-btn {}\n.pillar-close-btn {}\n\n/* ============================================================================\n Content Area\n Internal: _pillar-content | Public: pillar-content\n ============================================================================ */\n\n._pillar-content {\n flex: 1;\n overflow-y: auto;\n overflow-x: hidden;\n min-height: 0;\n}\n\n.pillar-content {}\n\n/* ============================================================================\n Search Input\n Internal: _pillar-search | Public: pillar-search\n ============================================================================ */\n\n._pillar-search {\n position: relative;\n padding: var(--pillar-spacing-lg) var(--pillar-spacing-xl);\n}\n\n._pillar-search-input {\n width: 100%;\n padding: 10px 12px 10px 40px;\n font-size: var(--pillar-font-size-base);\n font-family: var(--pillar-font-family);\n color: var(--pillar-text);\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-lg);\n outline: none;\n transition: border-color var(--pillar-transition-fast), box-shadow var(--pillar-transition-fast);\n}\n\n._pillar-search-input:focus {\n border-color: var(--pillar-primary);\n box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);\n}\n\n._pillar-search-input::placeholder {\n color: var(--pillar-text-placeholder);\n}\n\n._pillar-search-icon {\n position: absolute;\n left: 32px;\n top: 50%;\n transform: translateY(-50%);\n width: 18px;\n height: 18px;\n color: var(--pillar-text-placeholder);\n pointer-events: none;\n}\n\n._pillar-search-icon svg {\n width: 18px;\n height: 18px;\n}\n\n.pillar-search {}\n.pillar-search-input {}\n.pillar-search-icon {}\n\n/* ============================================================================\n Chat Input (Persistent Bottom)\n Internal: _pillar-chat-input | Public: pillar-chat-input\n ============================================================================ */\n\n._pillar-chat-input-container {\n flex-shrink: 0;\n border-top: 1px solid var(--pillar-border);\n background: var(--pillar-bg);\n display: flex;\n flex-direction: column;\n max-height: 50%;\n transition: max-height var(--pillar-transition-normal);\n}\n\n._pillar-chat-input-container--expanded {\n max-height: 60%;\n}\n\n._pillar-chat-input-messages {\n flex: 1;\n overflow-y: auto;\n padding: 0;\n max-height: 0;\n transition: max-height var(--pillar-transition-normal), padding var(--pillar-transition-normal);\n}\n\n._pillar-chat-input-container--expanded ._pillar-chat-input-messages {\n max-height: 300px;\n padding: var(--pillar-spacing-lg) var(--pillar-spacing-xl);\n}\n\n._pillar-chat-input-message {\n margin-bottom: var(--pillar-spacing-md);\n}\n\n._pillar-chat-input-message--user {\n text-align: right;\n}\n\n._pillar-chat-input-message-content {\n display: inline-block;\n max-width: 85%;\n padding: 10px 14px;\n border-radius: var(--pillar-spacing-lg);\n font-size: var(--pillar-font-size-base);\n line-height: 1.5;\n}\n\n._pillar-chat-input-message--user ._pillar-chat-input-message-content {\n background: var(--pillar-primary);\n color: #ffffff;\n border-bottom-right-radius: var(--pillar-radius-sm);\n}\n\n._pillar-chat-input-message--assistant ._pillar-chat-input-message-content {\n background: var(--pillar-bg-tertiary);\n color: var(--pillar-text);\n border-bottom-left-radius: var(--pillar-radius-sm);\n}\n\n._pillar-chat-input-sources {\n margin-top: var(--pillar-spacing-sm);\n padding-top: var(--pillar-spacing-sm);\n border-top: 1px solid var(--pillar-border);\n}\n\n._pillar-chat-input-sources-title {\n font-size: var(--pillar-font-size-xs);\n font-weight: 500;\n color: var(--pillar-text-muted);\n margin-bottom: 6px;\n}\n\n._pillar-chat-input-source {\n display: block;\n padding: 6px 10px;\n margin-bottom: var(--pillar-spacing-xs);\n font-size: var(--pillar-font-size-sm);\n color: var(--pillar-primary);\n background: var(--pillar-primary-light);\n border-radius: var(--pillar-radius-md);\n text-decoration: none;\n cursor: pointer;\n}\n\n._pillar-chat-input-source:hover {\n background: var(--pillar-primary-light-hover);\n}\n\n._pillar-chat-input-area {\n padding: var(--pillar-spacing-md) var(--pillar-spacing-lg);\n}\n\n._pillar-chat-input-wrapper {\n display: flex;\n flex-direction: column;\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-xl);\n transition: border-color var(--pillar-transition-fast), box-shadow var(--pillar-transition-fast);\n}\n\n._pillar-chat-input-wrapper:focus-within {\n border-color: var(--pillar-primary);\n box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);\n}\n\n._pillar-chat-input-textarea {\n display: block;\n width: 100%;\n padding: 12px 14px 8px;\n font-size: var(--pillar-font-size-base);\n font-family: var(--pillar-font-family);\n line-height: 1.5;\n color: var(--pillar-text);\n background: transparent;\n border: none;\n outline: none;\n resize: none;\n overflow-y: hidden;\n box-sizing: border-box;\n}\n\n._pillar-chat-input-textarea::placeholder {\n color: var(--pillar-text-placeholder);\n}\n\n.pillar-chat-input-container {}\n.pillar-chat-input-messages {}\n.pillar-chat-input-message {}\n.pillar-chat-input-message-content {}\n.pillar-chat-input-sources {}\n.pillar-chat-input-area {}\n.pillar-chat-input-wrapper {}\n.pillar-chat-input-textarea {}\n\n/* ============================================================================\n Chat Input Footer (contains send button)\n ============================================================================ */\n\n._pillar-chat-input-footer {\n display: flex;\n justify-content: flex-end;\n padding: 8px 10px;\n}\n\n/* ============================================================================\n Send Button - In footer row, right aligned\n Internal: _pillar-send-btn | Public: pillar-send-btn\n ============================================================================ */\n\n._pillar-send-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n padding: 0;\n color: var(--pillar-text-muted);\n background: var(--pillar-bg-tertiary);\n border: none;\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n flex-shrink: 0;\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-send-btn:hover:not(:disabled) {\n color: #ffffff;\n background: var(--pillar-primary);\n}\n\n._pillar-send-btn:disabled {\n color: var(--pillar-text-placeholder);\n background: var(--pillar-bg-tertiary);\n cursor: not-allowed;\n}\n\n._pillar-send-btn svg {\n width: 16px;\n height: 16px;\n}\n\n.pillar-send-btn {}\n.pillar-chat-input-footer {}\n\n/* ============================================================================\n Loading States\n Internal: _pillar-loading | Public: pillar-loading\n ============================================================================ */\n\n._pillar-loading {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 40px var(--pillar-spacing-xl);\n color: var(--pillar-text-muted);\n}\n\n._pillar-loading-spinner {\n width: 24px;\n height: 24px;\n border: 2px solid var(--pillar-border);\n border-top-color: var(--pillar-primary);\n border-radius: 50%;\n animation: pillar-spin 0.8s linear infinite;\n}\n\n@keyframes pillar-spin {\n to { transform: rotate(360deg); }\n}\n\n.pillar-loading {}\n.pillar-loading-spinner {}\n\n/* ============================================================================\n Progress Indicator (AI activity status)\n Internal: _pillar-progress | Public: pillar-progress\n ============================================================================ */\n\n._pillar-progress-indicator {\n display: flex;\n align-items: center;\n gap: var(--pillar-spacing-sm);\n padding: var(--pillar-spacing-sm) 0;\n}\n\n._pillar-progress-indicator ._pillar-loading-spinner {\n width: 16px;\n height: 16px;\n flex-shrink: 0;\n}\n\n._pillar-progress-message {\n font-size: var(--pillar-font-size-sm);\n color: var(--pillar-text-muted);\n font-style: italic;\n}\n\n.pillar-progress-indicator {}\n.pillar-progress-message {}\n\n/* ============================================================================\n Empty States\n Internal: _pillar-empty | Public: pillar-empty\n ============================================================================ */\n\n._pillar-empty {\n padding: 40px var(--pillar-spacing-xl);\n text-align: center;\n color: var(--pillar-text-muted);\n}\n\n._pillar-empty-icon {\n width: 48px;\n height: 48px;\n margin: 0 auto var(--pillar-spacing-lg);\n color: var(--pillar-border);\n}\n\n._pillar-empty-title {\n font-size: var(--pillar-font-size-lg);\n font-weight: 500;\n color: var(--pillar-text);\n margin-bottom: var(--pillar-spacing-xs);\n}\n\n._pillar-empty-description {\n font-size: var(--pillar-font-size-base);\n}\n\n.pillar-empty {}\n.pillar-empty-icon {}\n.pillar-empty-title {}\n.pillar-empty-description {}\n\n/* ============================================================================\n Section Titles\n Internal: _pillar-section-title | Public: pillar-section-title\n ============================================================================ */\n\n._pillar-section-title {\n padding: var(--pillar-spacing-md) var(--pillar-spacing-xl) var(--pillar-spacing-sm);\n font-size: var(--pillar-font-size-xs);\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n color: var(--pillar-text-muted);\n}\n\n.pillar-section-title {}\n\n/* ============================================================================\n Related Articles\n ============================================================================ */\n\n._pillar-related-articles {\n border-top: 1px solid var(--pillar-border);\n margin-top: var(--pillar-spacing-2xl);\n padding-top: var(--pillar-spacing-sm);\n}\n\n.pillar-related-articles {}\n\n/* ============================================================================\n Scrollbar Styling\n ============================================================================ */\n\n._pillar-content::-webkit-scrollbar,\n._pillar-chat-input-messages::-webkit-scrollbar {\n width: 6px;\n}\n\n._pillar-content::-webkit-scrollbar-track,\n._pillar-chat-input-messages::-webkit-scrollbar-track {\n background: var(--pillar-scrollbar-track);\n}\n\n._pillar-content::-webkit-scrollbar-thumb,\n._pillar-chat-input-messages::-webkit-scrollbar-thumb {\n background: var(--pillar-scrollbar-thumb);\n border-radius: 3px;\n}\n\n._pillar-content::-webkit-scrollbar-thumb:hover,\n._pillar-chat-input-messages::-webkit-scrollbar-thumb:hover {\n background: var(--pillar-scrollbar-thumb-hover);\n}\n\n/* ============================================================================\n Home View\n ============================================================================ */\n\n._pillar-home-view {\n display: flex;\n flex-direction: column;\n height: 100%;\n padding: var(--pillar-spacing-xl);\n}\n\n._pillar-home-view-header {\n text-align: center;\n padding: var(--pillar-spacing-2xl) 0;\n}\n\n._pillar-home-view-icon {\n font-size: 40px;\n margin-bottom: var(--pillar-spacing-md);\n}\n\n._pillar-home-view-title {\n font-size: var(--pillar-font-size-xl);\n font-weight: 600;\n color: var(--pillar-text);\n margin: 0;\n}\n\n._pillar-home-view-questions {\n display: flex;\n flex-direction: column;\n gap: var(--pillar-spacing-sm);\n margin-bottom: var(--pillar-spacing-xl);\n}\n\n._pillar-home-view-input-wrapper {\n margin-top: auto;\n display: flex;\n flex-direction: column;\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-xl);\n transition: border-color var(--pillar-transition-fast), box-shadow var(--pillar-transition-fast);\n}\n\n._pillar-home-view-input-wrapper:focus-within {\n border-color: var(--pillar-primary);\n box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);\n}\n\n._pillar-home-view-input {\n display: block;\n width: 100%;\n padding: 12px 14px 8px;\n font-size: var(--pillar-font-size-base);\n font-family: var(--pillar-font-family);\n line-height: 1.5;\n color: var(--pillar-text);\n background: transparent;\n border: none;\n outline: none;\n resize: none;\n overflow-y: hidden;\n box-sizing: border-box;\n}\n\n._pillar-home-view-input::placeholder {\n color: var(--pillar-text-placeholder);\n}\n\n._pillar-home-view-input-row {\n display: flex;\n justify-content: flex-end;\n padding: 8px 10px;\n}\n\n._pillar-home-view-send-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n padding: 0;\n color: var(--pillar-text-muted);\n background: var(--pillar-bg-tertiary);\n border: none;\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n flex-shrink: 0;\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-home-view-send-btn:hover:not(:disabled) {\n color: #ffffff;\n background: var(--pillar-primary);\n}\n\n._pillar-home-view-send-btn:disabled {\n color: var(--pillar-text-placeholder);\n background: var(--pillar-bg-tertiary);\n cursor: not-allowed;\n}\n\n._pillar-home-view-send-btn svg {\n width: 16px;\n height: 16px;\n}\n\n.pillar-home-view {}\n.pillar-home-view-header {}\n.pillar-home-view-title {}\n.pillar-home-view-questions {}\n.pillar-home-view-input-wrapper {}\n.pillar-home-view-input {}\n.pillar-home-view-send-btn {}\n\n/* ============================================================================\n Question Chip\n ============================================================================ */\n\n._pillar-question-chip {\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: 100%;\n padding: var(--pillar-spacing-md) var(--pillar-spacing-lg);\n font-size: var(--pillar-font-size-base);\n font-family: var(--pillar-font-family);\n text-align: left;\n color: var(--pillar-text);\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-lg);\n cursor: pointer;\n transition: background var(--pillar-transition-fast), border-color var(--pillar-transition-fast);\n}\n\n._pillar-question-chip:hover {\n border-color: var(--pillar-primary);\n}\n\n._pillar-question-chip-text {\n flex: 1;\n}\n\n._pillar-question-chip-arrow {\n color: var(--pillar-text-muted);\n margin-left: var(--pillar-spacing-sm);\n transition: color var(--pillar-transition-fast), transform var(--pillar-transition-fast);\n}\n\n._pillar-question-chip:hover ._pillar-question-chip-arrow {\n color: var(--pillar-primary);\n transform: translateX(2px);\n}\n\n._pillar-question-chip-skeleton {\n height: 44px;\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-lg);\n overflow: hidden;\n}\n\n._pillar-question-chip-skeleton-bar {\n width: 60%;\n height: 14px;\n margin: 15px var(--pillar-spacing-lg);\n background: linear-gradient(90deg, var(--pillar-border) 25%, var(--pillar-bg-tertiary) 50%, var(--pillar-border) 75%);\n background-size: 200% 100%;\n animation: pillar-shimmer 1.5s infinite;\n border-radius: var(--pillar-radius-sm);\n}\n\n@keyframes pillar-shimmer {\n 0% { background-position: 200% 0; }\n 100% { background-position: -200% 0; }\n}\n\n.pillar-question-chip {}\n.pillar-question-chip-text {}\n.pillar-question-chip-arrow {}\n.pillar-question-chip-skeleton {}\n.pillar-question-chip-skeleton-bar {}\n\n/* ============================================================================\n Standalone Chat View\n Internal: _pillar-chat-view | Public: pillar-chat-view\n ============================================================================ */\n\n._pillar-chat-view {\n display: flex;\n flex-direction: column;\n height: 100%;\n overflow: hidden;\n}\n\n._pillar-chat-view-messages {\n flex: 1;\n overflow-y: auto;\n padding: var(--pillar-spacing-xl);\n display: flex;\n flex-direction: column;\n}\n\n._pillar-chat-view-welcome {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 40px var(--pillar-spacing-xl);\n text-align: center;\n flex: 1;\n}\n\n._pillar-chat-view-welcome-icon {\n font-size: 48px;\n margin-bottom: var(--pillar-spacing-lg);\n}\n\n._pillar-chat-view-welcome-title {\n font-size: var(--pillar-font-size-xl);\n font-weight: 600;\n color: var(--pillar-text);\n margin-bottom: var(--pillar-spacing-sm);\n}\n\n._pillar-chat-view-welcome-text {\n font-size: var(--pillar-font-size-base);\n color: var(--pillar-text-muted);\n max-width: 280px;\n}\n\n._pillar-chat-view-message {\n margin-bottom: var(--pillar-spacing-lg);\n}\n\n._pillar-chat-view-message--user {\n text-align: right;\n}\n\n._pillar-chat-view-message--assistant {\n text-align: left;\n}\n\n.pillar-chat-view {}\n.pillar-chat-view-messages {}\n.pillar-chat-view-welcome {}\n.pillar-chat-view-message {}\n\n/* ============================================================================\n User Message Bubble\n Internal: _pillar-message-user | Public: pillar-message-user\n ============================================================================ */\n\n._pillar-message-user {\n display: inline-block;\n max-width: 85%;\n padding: 10px 14px;\n border-radius: var(--pillar-spacing-lg);\n border-bottom-right-radius: var(--pillar-radius-sm);\n font-size: var(--pillar-font-size-base);\n line-height: 1.5;\n background: var(--pillar-primary);\n color: #ffffff;\n white-space: pre-wrap;\n word-wrap: break-word;\n}\n\n._pillar-message-user-images {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n margin-bottom: var(--pillar-spacing-sm);\n}\n\n._pillar-message-user-image {\n max-width: 120px;\n max-height: 120px;\n border-radius: var(--pillar-radius-md);\n object-fit: cover;\n}\n\n.pillar-message-user {}\n.pillar-message-user-images {}\n.pillar-message-user-image {}\n\n/* ============================================================================\n AI Response\n Internal: _pillar-message-assistant | Public: pillar-message-assistant\n ============================================================================ */\n\n._pillar-message-assistant {\n font-size: var(--pillar-font-size-base);\n line-height: 1.6;\n color: var(--pillar-text-secondary);\n}\n\n._pillar-message-assistant p {\n margin: 0 0 var(--pillar-spacing-md);\n}\n\n._pillar-message-assistant p:last-child {\n margin-bottom: 0;\n}\n\n._pillar-message-assistant h2 {\n font-size: var(--pillar-font-size-lg);\n font-weight: 600;\n color: var(--pillar-text);\n margin: var(--pillar-spacing-lg) 0 var(--pillar-spacing-sm);\n}\n\n._pillar-message-assistant h3 {\n font-size: var(--pillar-font-size-md);\n font-weight: 600;\n color: var(--pillar-text);\n margin: 14px 0 6px;\n}\n\n._pillar-message-assistant h4 {\n font-size: var(--pillar-font-size-base);\n font-weight: 600;\n color: var(--pillar-text);\n margin: var(--pillar-spacing-md) 0 6px;\n}\n\n._pillar-message-assistant ul,\n._pillar-message-assistant ol {\n margin: 0 0 var(--pillar-spacing-md);\n padding-left: var(--pillar-spacing-2xl);\n list-style-position: outside;\n}\n\n._pillar-message-assistant ul {\n list-style-type: disc;\n}\n\n._pillar-message-assistant ol {\n list-style-type: decimal;\n}\n\n._pillar-message-assistant li {\n margin-bottom: var(--pillar-spacing-xs);\n}\n\n._pillar-message-assistant code {\n padding: 2px 6px;\n font-size: var(--pillar-font-size-sm);\n background: var(--pillar-bg-tertiary);\n border-radius: var(--pillar-radius-sm);\n font-family: var(--pillar-font-mono);\n color: var(--pillar-text);\n}\n\n._pillar-message-assistant pre {\n margin: var(--pillar-spacing-md) 0;\n padding: var(--pillar-spacing-md) 14px;\n background: var(--pillar-code-bg);\n border-radius: var(--pillar-radius-lg);\n overflow-x: auto;\n}\n\n._pillar-message-assistant pre code {\n padding: 0;\n background: none;\n color: var(--pillar-code-text);\n font-size: var(--pillar-font-size-sm);\n line-height: 1.5;\n}\n\n._pillar-message-assistant a {\n color: var(--pillar-primary);\n text-decoration: none;\n}\n\n._pillar-message-assistant a:hover {\n text-decoration: underline;\n}\n\n._pillar-message-assistant strong {\n font-weight: 600;\n color: var(--pillar-text);\n}\n\n._pillar-message-assistant em {\n font-style: italic;\n}\n\n.pillar-message-assistant {}\n\n/* ============================================================================\n Chat Sources\n Internal: _pillar-chat-sources | Public: pillar-chat-sources\n ============================================================================ */\n\n._pillar-chat-sources {\n margin-top: var(--pillar-spacing-md);\n padding-top: var(--pillar-spacing-md);\n border-top: 1px solid var(--pillar-border);\n}\n\n._pillar-chat-sources-title {\n font-size: var(--pillar-font-size-xs);\n font-weight: 500;\n color: var(--pillar-text-muted);\n margin-bottom: var(--pillar-spacing-sm);\n}\n\n._pillar-chat-source {\n display: block;\n padding: var(--pillar-spacing-sm) var(--pillar-spacing-md);\n margin-bottom: 6px;\n font-size: var(--pillar-font-size-sm);\n color: var(--pillar-primary);\n background: var(--pillar-primary-light);\n border-radius: var(--pillar-radius-lg);\n text-decoration: none;\n cursor: pointer;\n transition: background var(--pillar-transition-fast);\n}\n\n._pillar-chat-source:hover {\n background: var(--pillar-primary-light-hover);\n}\n\n.pillar-chat-sources {}\n.pillar-chat-sources-title {}\n.pillar-chat-source {}\n\n/* ============================================================================\n Chat Actions (Suggested action buttons)\n Internal: _pillar-chat-actions | Public: pillar-chat-actions\n ============================================================================ */\n\n._pillar-chat-actions {\n margin-top: var(--pillar-spacing-md);\n padding-top: var(--pillar-spacing-md);\n border-top: 1px solid var(--pillar-border);\n}\n\n._pillar-chat-actions-title {\n font-size: var(--pillar-font-size-xs);\n font-weight: 500;\n color: var(--pillar-text-muted);\n margin-bottom: var(--pillar-spacing-sm);\n}\n\n._pillar-chat-actions-buttons {\n display: flex;\n flex-direction: column;\n gap: var(--pillar-spacing-sm);\n}\n\n/* Task buttons should wrap horizontally */\n._pillar-chat-actions-buttons > ._pillar-task-button-group {\n display: flex;\n flex-wrap: wrap;\n gap: var(--pillar-spacing-sm);\n}\n\n/* Confirm cards take full width */\n._pillar-chat-actions-buttons > .pillar-confirm-card-wrapper {\n width: 100%;\n}\n\n.pillar-chat-actions {}\n.pillar-chat-actions-title {}\n.pillar-chat-actions-buttons {}\n\n/* ============================================================================\n Chat View Input Area - Cursor-style design\n ============================================================================ */\n\n._pillar-chat-view-input-area {\n flex-shrink: 0;\n padding: var(--pillar-spacing-md) var(--pillar-spacing-lg);\n border-top: 1px solid var(--pillar-border);\n background: var(--pillar-bg);\n}\n\n._pillar-chat-view-input-wrapper {\n display: flex;\n flex-direction: column;\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-xl);\n transition: border-color var(--pillar-transition-fast), box-shadow var(--pillar-transition-fast);\n}\n\n._pillar-chat-view-input-wrapper:focus-within {\n border-color: var(--pillar-primary);\n box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);\n}\n\n._pillar-chat-view-input {\n display: block;\n width: 100%;\n padding: 12px 14px 8px;\n font-size: var(--pillar-font-size-base);\n font-family: var(--pillar-font-family);\n line-height: 1.5;\n color: var(--pillar-text);\n background: transparent;\n border: none;\n outline: none;\n resize: none;\n overflow-y: hidden;\n box-sizing: border-box;\n}\n\n._pillar-chat-view-input::placeholder {\n color: var(--pillar-text-placeholder);\n}\n\n._pillar-chat-view-input-row {\n display: flex;\n justify-content: flex-end;\n padding: 8px 10px;\n}\n\n._pillar-chat-view-send-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n padding: 0;\n color: var(--pillar-text-muted);\n background: var(--pillar-bg-tertiary);\n border: none;\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n flex-shrink: 0;\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-chat-view-send-btn:hover:not(:disabled) {\n color: #ffffff;\n background: var(--pillar-primary);\n}\n\n._pillar-chat-view-send-btn:active:not(:disabled) {\n transform: scale(0.95);\n}\n\n._pillar-chat-view-send-btn:disabled {\n color: var(--pillar-text-placeholder);\n background: var(--pillar-bg-tertiary);\n cursor: not-allowed;\n}\n\n._pillar-chat-view-send-btn svg {\n width: 16px;\n height: 16px;\n}\n\n.pillar-chat-view-input-area {}\n.pillar-chat-view-input-wrapper {}\n.pillar-chat-view-input {}\n.pillar-chat-view-send-btn {}\n.pillar-chat-view-input-footer {}\n.pillar-chat-view-new-chat-btn {}\n\n/* New chat button styling */\n._pillar-chat-view-input-footer {\n display: flex;\n justify-content: center;\n margin-top: var(--pillar-spacing-sm);\n}\n\n._pillar-chat-view-new-chat-btn {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 6px 12px;\n font-size: var(--pillar-font-size-sm);\n font-weight: 500;\n font-family: var(--pillar-font-family);\n color: var(--pillar-text-muted);\n background: transparent;\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-lg);\n cursor: pointer;\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-chat-view-new-chat-btn:hover {\n color: var(--pillar-text);\n background: var(--pillar-bg-secondary);\n border-color: var(--pillar-text-muted);\n}\n\n._pillar-chat-view-new-chat-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n._pillar-chat-view-new-chat-icon svg {\n width: 14px;\n height: 14px;\n}\n\n/* Scrollbar for chat view */\n._pillar-chat-view-messages::-webkit-scrollbar {\n width: 6px;\n}\n\n._pillar-chat-view-messages::-webkit-scrollbar-track {\n background: var(--pillar-scrollbar-track);\n}\n\n._pillar-chat-view-messages::-webkit-scrollbar-thumb {\n background: var(--pillar-scrollbar-thumb);\n border-radius: 3px;\n}\n\n._pillar-chat-view-messages::-webkit-scrollbar-thumb:hover {\n background: var(--pillar-scrollbar-thumb-hover);\n}\n\n/* ============================================================================\n Chat Image Upload\n ============================================================================ */\n\n._pillar-chat-view-input-area--dragging {\n position: relative;\n background: rgba(37, 99, 235, 0.05);\n}\n\n._pillar-chat-drop-overlay {\n position: absolute;\n inset: 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 8px;\n background: rgba(37, 99, 235, 0.1);\n border: 2px dashed var(--pillar-primary);\n border-radius: var(--pillar-radius-lg);\n color: var(--pillar-primary);\n font-size: var(--pillar-font-size-sm);\n font-weight: 500;\n z-index: 10;\n pointer-events: none;\n}\n\n._pillar-chat-drop-overlay svg {\n width: 24px;\n height: 24px;\n}\n\n._pillar-chat-images-preview {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n padding: 12px 12px 4px 12px;\n}\n\n._pillar-chat-image-thumb {\n position: relative;\n width: 56px;\n height: 56px;\n border-radius: var(--pillar-radius-md);\n overflow: hidden;\n border: 1px solid var(--pillar-border);\n}\n\n._pillar-chat-image-thumb img {\n width: 100%;\n height: 100%;\n object-fit: cover;\n}\n\n._pillar-chat-image-loading {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n._pillar-chat-image-error {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n background: rgba(239, 68, 68, 0.3);\n color: #dc2626;\n font-weight: bold;\n font-size: 14px;\n}\n\n._pillar-chat-image-remove {\n position: absolute;\n top: 2px;\n right: 2px;\n width: 18px;\n height: 18px;\n padding: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n background: rgba(0, 0, 0, 0.6);\n border: none;\n border-radius: 50%;\n color: white;\n cursor: pointer;\n opacity: 0;\n transition: opacity var(--pillar-transition-fast);\n}\n\n._pillar-chat-image-thumb:hover ._pillar-chat-image-remove {\n opacity: 1;\n}\n\n._pillar-chat-image-remove svg {\n width: 10px;\n height: 10px;\n}\n\n._pillar-chat-image-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 36px;\n height: 36px;\n padding: 0;\n color: var(--pillar-text-muted);\n background: transparent;\n border: none;\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n transition: color var(--pillar-transition-fast);\n}\n\n._pillar-chat-image-btn:hover:not(:disabled) {\n color: var(--pillar-text);\n}\n\n._pillar-chat-image-btn:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n}\n\n._pillar-chat-image-btn svg {\n width: 18px;\n height: 18px;\n}\n\n.pillar-chat-images-preview {}\n.pillar-chat-image-thumb {}\n.pillar-chat-image-remove {}\n.pillar-chat-image-btn {}\n.pillar-chat-drop-overlay {}\n\n/* ============================================================================\n Legacy Class Mappings (for backward compatibility)\n Maps old BEM-style class names to new internal classes\n ============================================================================ */\n\n.pillar-panel { }\n.pillar-panel--right { }\n.pillar-panel--left { }\n.pillar-panel--open { }\n.pillar-panel--manual { }\n.pillar-panel-root { }\n.pillar-panel-ui { }\n.pillar-panel__header { }\n.pillar-panel__header-left { }\n.pillar-panel__back-btn { }\n.pillar-panel__home-btn { }\n.pillar-panel__title { }\n.pillar-panel__close-btn { }\n.pillar-panel__content { }\n.pillar-search { }\n.pillar-search__input { }\n.pillar-search__icon { }\n.pillar-category-card { }\n.pillar-category-card__icon { }\n.pillar-category-card__content { }\n.pillar-category-card__title { }\n.pillar-category-card__description { }\n.pillar-category-card__count { }\n.pillar-article-card { }\n.pillar-article-card__title { }\n.pillar-article-card__excerpt { }\n.pillar-article-card__meta { }\n.pillar-article { }\n.pillar-article__title { }\n.pillar-article__content { }\n.pillar-category-header { }\n.pillar-category-header__title { }\n.pillar-category-header__description { }\n.pillar-chat-input-container { }\n.pillar-chat-input-container--expanded { }\n.pillar-chat-input__messages { }\n.pillar-chat-input__message { }\n.pillar-chat-input__message--user { }\n.pillar-chat-input__message--assistant { }\n.pillar-chat-input__message-content { }\n.pillar-chat-input__sources { }\n.pillar-chat-input__sources-title { }\n.pillar-chat-input__source { }\n.pillar-chat-input__area { }\n.pillar-chat-input__wrapper { }\n.pillar-chat-input__input { }\n.pillar-chat-input__send-btn { }\n.pillar-loading { }\n.pillar-loading__spinner { }\n.pillar-empty { }\n.pillar-empty__icon { }\n.pillar-empty__title { }\n.pillar-empty__description { }\n.pillar-section-title { }\n.pillar-related-articles { }\n.pillar-home-view { }\n.pillar-chat-view { }\n.pillar-chat-view__messages { }\n.pillar-chat-view__welcome { }\n.pillar-chat-view__welcome-icon { }\n.pillar-chat-view__welcome-title { }\n.pillar-chat-view__welcome-text { }\n.pillar-chat-view__message { }\n.pillar-chat-view__message--user { }\n.pillar-chat-view__message--assistant { }\n.pillar-chat-view__user-bubble { }\n.pillar-chat-view__ai-response { }\n.pillar-chat-view__sources { }\n.pillar-chat-view__sources-title { }\n.pillar-chat-view__source { }\n.pillar-chat-view__input-area { }\n.pillar-chat-view__input-wrapper { }\n.pillar-chat-view__input { }\n.pillar-chat-view__send-btn { }\n.pillar-backdrop { }\n.pillar-backdrop--visible { }\n\n/* ============================================================================\n Task Button Component\n ============================================================================ */\n\n.pillar-task-btn {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 8px 14px;\n font-size: 13px;\n font-weight: 500;\n font-family: inherit;\n border-radius: 8px;\n cursor: pointer;\n transition: all 0.15s ease;\n border: 1px solid transparent;\n text-decoration: none;\n}\n\n.pillar-task-btn__icon {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n}\n\n.pillar-task-btn__icon svg {\n width: 16px;\n height: 16px;\n}\n\n.pillar-task-btn__label {\n white-space: nowrap;\n}\n\n/* Primary variant (default) */\n.pillar-task-btn--primary {\n background: #2563eb;\n color: #ffffff;\n border-color: #2563eb;\n}\n\n.pillar-task-btn--primary:hover {\n background: #1d4ed8;\n border-color: #1d4ed8;\n}\n\n/* Default variant */\n.pillar-task-btn--default {\n background: #f3f4f6;\n color: #1a1a1a;\n border-color: #e5e7eb;\n}\n\n.pillar-task-btn--default:hover {\n background: #e5e7eb;\n}\n\n/* Secondary variant */\n.pillar-task-btn--secondary {\n background: #eff6ff;\n color: #2563eb;\n border-color: #dbeafe;\n}\n\n.pillar-task-btn--secondary:hover {\n background: #dbeafe;\n}\n\n/* Outline variant */\n.pillar-task-btn--outline {\n background: transparent;\n color: #2563eb;\n border-color: #2563eb;\n}\n\n.pillar-task-btn--outline:hover {\n background: #eff6ff;\n}\n\n/* Ghost variant */\n.pillar-task-btn--ghost {\n background: transparent;\n color: #6b7280;\n border-color: transparent;\n}\n\n.pillar-task-btn--ghost:hover {\n background: #f3f4f6;\n color: #1a1a1a;\n}\n\n/* Task button group */\n.pillar-task-btn-group {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n margin-top: 12px;\n}\n\n/* Task suggestion card in chat */\n.pillar-task-suggestion {\n display: flex;\n flex-direction: column;\n gap: 8px;\n padding: 12px;\n background: #f9fafb;\n border: 1px solid #e5e7eb;\n border-radius: 12px;\n margin-top: 12px;\n}\n\n.pillar-task-suggestion__header {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 11px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n color: #6b7280;\n}\n\n.pillar-task-suggestion__header svg {\n width: 14px;\n height: 14px;\n}\n\n.pillar-task-suggestion__description {\n font-size: 13px;\n color: #374151;\n}\n\n/* ============================================================================\n Feedback Icons\n Internal: _pillar-feedback | Public: pillar-feedback\n ============================================================================ */\n\n._pillar-message-assistant-wrapper {\n position: relative;\n}\n\n._pillar-feedback-icons {\n display: flex;\n gap: 4px;\n margin-top: var(--pillar-spacing-sm);\n justify-content: flex-end;\n}\n\n._pillar-feedback-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n padding: 0;\n background: transparent;\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n color: var(--pillar-text-placeholder);\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-feedback-btn:hover {\n color: var(--pillar-text-muted);\n background: var(--pillar-bg-secondary);\n border-color: var(--pillar-border);\n}\n\n._pillar-feedback-btn--active {\n color: var(--pillar-primary);\n background: var(--pillar-primary-light);\n border-color: var(--pillar-primary);\n}\n\n._pillar-feedback-btn--active:hover {\n color: var(--pillar-primary);\n background: var(--pillar-primary-light-hover);\n}\n\n._pillar-feedback-btn svg {\n width: 14px;\n height: 14px;\n}\n\n.pillar-feedback-icons {}\n.pillar-feedback-btn {}\n.pillar-message-assistant-wrapper {}\n\n/* ============================================================================\n Action Status Indicators\n Internal: _pillar-action-status | Public: pillar-action-status\n Shows completion status for auto-run actions (checkmark, X, or spinner)\n ============================================================================ */\n\n._pillar-message-assistant-content {\n display: flex;\n align-items: flex-start;\n gap: 8px;\n}\n\n._pillar-action-status {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n flex-shrink: 0;\n margin-top: 2px;\n}\n\n._pillar-action-status-indicator {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 18px;\n height: 18px;\n}\n\n._pillar-action-status-indicator svg {\n width: 16px;\n height: 16px;\n}\n\n._pillar-action-status-indicator--success {\n color: #22c55e;\n}\n\n._pillar-action-status-indicator--failed {\n color: #ef4444;\n}\n\n._pillar-action-status-indicator--pending {\n color: var(--pillar-text-muted);\n animation: pillar-spin 1s linear infinite;\n}\n\n@keyframes pillar-spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n}\n\n.pillar-action-status {}\n.pillar-action-status-indicator {}\n.pillar-message-assistant-content {}\n\n/* ============================================================================\n Context Tags\n Internal: _pillar-context-tag | Public: pillar-context-tag\n Removable chips for user context items (highlighted text, etc.)\n ============================================================================ */\n\n._pillar-context-tag-list {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n padding: 8px 14px 0;\n}\n\n._pillar-context-tag {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n max-width: 200px;\n padding: 4px 6px 4px 8px;\n font-size: var(--pillar-font-size-sm);\n color: var(--pillar-text-secondary);\n background: var(--pillar-bg-tertiary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-md);\n cursor: default;\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-context-tag:hover {\n background: var(--pillar-bg-secondary);\n border-color: var(--pillar-text-muted);\n}\n\n._pillar-context-tag-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 14px;\n height: 14px;\n flex-shrink: 0;\n color: var(--pillar-primary);\n}\n\n._pillar-context-tag-icon svg {\n width: 12px;\n height: 12px;\n}\n\n._pillar-context-tag-label {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n line-height: 1.3;\n}\n\n._pillar-context-tag-remove {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 16px;\n height: 16px;\n padding: 0;\n margin-left: 2px;\n color: var(--pillar-text-placeholder);\n background: transparent;\n border: none;\n border-radius: var(--pillar-radius-sm);\n cursor: pointer;\n flex-shrink: 0;\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-context-tag-remove:hover {\n color: var(--pillar-text);\n background: var(--pillar-border);\n}\n\n._pillar-context-tag-remove svg {\n width: 12px;\n height: 12px;\n}\n\n.pillar-context-tag-list {}\n.pillar-context-tag {}\n.pillar-context-tag-icon {}\n.pillar-context-tag-label {}\n.pillar-context-tag-remove {}\n\n/* Context tags inside user message bubbles need inverted colors */\n._pillar-message-user ._pillar-context-tag-list {\n padding: 0 0 8px 0;\n}\n\n._pillar-message-user ._pillar-context-tag {\n background: rgba(255, 255, 255, 0.2);\n border-color: rgba(255, 255, 255, 0.3);\n color: #ffffff;\n}\n\n._pillar-message-user ._pillar-context-tag:hover {\n background: rgba(255, 255, 255, 0.3);\n border-color: rgba(255, 255, 255, 0.4);\n}\n\n._pillar-message-user ._pillar-context-tag-icon {\n color: #ffffff;\n}\n\n._pillar-message-user ._pillar-context-tag-label {\n color: #ffffff;\n}\n\n/* ============================================================================\n Unified Chat Input\n Internal: _pillar-unified-input | Public: pillar-unified-input\n Reusable input component with context tag support\n ============================================================================ */\n\n._pillar-unified-input-wrapper {\n display: flex;\n flex-direction: column;\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-xl);\n transition: border-color var(--pillar-transition-fast), box-shadow var(--pillar-transition-fast);\n}\n\n._pillar-unified-input-wrapper:focus-within {\n border-color: var(--pillar-primary);\n box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);\n}\n\n._pillar-unified-input {\n display: block;\n width: 100%;\n padding: 12px 14px 8px;\n font-size: var(--pillar-font-size-base);\n font-family: var(--pillar-font-family);\n line-height: 1.5;\n color: var(--pillar-text);\n background: transparent;\n border: none;\n outline: none;\n resize: none;\n overflow-y: hidden;\n box-sizing: border-box;\n}\n\n._pillar-unified-input::placeholder {\n color: var(--pillar-text-placeholder);\n}\n\n._pillar-unified-input:disabled {\n opacity: 0.6;\n cursor: not-allowed;\n}\n\n._pillar-unified-input-row {\n display: flex;\n justify-content: flex-end;\n padding: 8px 10px;\n}\n\n._pillar-unified-send-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n padding: 0;\n color: #ffffff;\n background: var(--pillar-primary);\n border: none;\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n flex-shrink: 0;\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-unified-send-btn:hover:not(:disabled) {\n background: var(--pillar-primary-hover);\n}\n\n._pillar-unified-send-btn:disabled {\n color: var(--pillar-text-placeholder);\n background: var(--pillar-bg-tertiary);\n cursor: not-allowed;\n}\n\n._pillar-unified-send-btn svg {\n width: 16px;\n height: 16px;\n}\n\n.pillar-unified-input-wrapper {}\n.pillar-unified-input {}\n.pillar-unified-input-row {}\n.pillar-unified-send-btn {}\n\n/* ============================================================================\n Progress Row (for search, query, generating events)\n Internal: _pillar-progress-row | Public: pillar-progress-row\n ============================================================================ */\n\n._pillar-progress-events {\n margin: 4px 0;\n}\n\n._pillar-progress-row {\n margin: 1px 0;\n padding: 1px 0;\n font-size: 12px;\n animation: pillar-progress-row-fade-in 0.3s ease-in-out;\n}\n\n._pillar-progress-row--error {\n color: #dc2626;\n}\n\n@keyframes pillar-progress-row-fade-in {\n from { opacity: 0; }\n to { opacity: 1; }\n}\n\n._pillar-progress-row-header {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 2px 0;\n}\n\n._pillar-progress-expand-icon {\n font-size: 10px;\n color: var(--pillar-text-muted);\n transition: transform 0.2s ease;\n flex-shrink: 0;\n}\n\n._pillar-progress-row-header[style*="cursor: pointer"]:hover ._pillar-progress-expand-icon {\n color: var(--pillar-text-secondary);\n}\n\n._pillar-progress-row-header[data-expanded="true"] ._pillar-progress-expand-icon {\n transform: rotate(90deg);\n}\n\n._pillar-progress-message {\n flex: 1;\n color: var(--pillar-text-muted);\n font-size: 12px;\n font-style: italic;\n}\n\n._pillar-progress-no-results {\n color: var(--pillar-text-muted);\n font-size: 11px;\n font-style: italic;\n margin-left: 4px;\n}\n\n._pillar-progress-sources {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n._pillar-progress-source-item {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 2px 0;\n font-size: 11px;\n}\n\n._pillar-progress-source-link {\n flex: 1;\n display: flex;\n flex-direction: column;\n text-decoration: none;\n overflow: hidden;\n color: inherit;\n}\n\n._pillar-progress-source-link:hover ._pillar-progress-source-title {\n text-decoration: underline;\n}\n\n._pillar-progress-source-title {\n font-weight: 400;\n color: var(--pillar-text-muted);\n font-size: 11px;\n}\n\n._pillar-progress-content-wrapper {\n position: relative;\n padding-left: 16px;\n display: grid;\n grid-template-rows: 0fr;\n transition: grid-template-rows 0.2s ease-out;\n}\n\n._pillar-progress-content-wrapper--expanded {\n grid-template-rows: 1fr;\n margin-top: 6px;\n}\n\n._pillar-progress-content-container {\n overflow: hidden;\n min-height: 0;\n scrollbar-width: thin;\n scrollbar-color: var(--pillar-scrollbar-thumb) transparent;\n}\n\n._pillar-progress-content-wrapper--expanded ._pillar-progress-content-container {\n max-height: 100px;\n overflow-y: auto;\n}\n\n._pillar-progress-content-container::-webkit-scrollbar {\n width: 4px;\n}\n\n._pillar-progress-content-container::-webkit-scrollbar-track {\n background: transparent;\n}\n\n._pillar-progress-content-container::-webkit-scrollbar-thumb {\n background-color: var(--pillar-scrollbar-thumb);\n border-radius: 2px;\n}\n\n._pillar-progress-content-gradient {\n position: absolute;\n bottom: 0;\n left: 16px;\n right: 0;\n height: 20px;\n background: linear-gradient(transparent, var(--pillar-bg));\n pointer-events: none;\n}\n\n.pillar-progress-events {}\n.pillar-progress-row {}\n.pillar-progress-row-header {}\n.pillar-progress-expand-icon {}\n.pillar-progress-message {}\n.pillar-progress-no-results {}\n.pillar-progress-sources {}\n.pillar-progress-source-item {}\n.pillar-progress-source-link {}\n.pillar-progress-source-title {}\n.pillar-progress-content-wrapper {}\n.pillar-progress-content-container {}\n.pillar-progress-content-gradient {}\n',_i=He(null),mi=He([]);Ue(()=>null!==_i.value),Ue(()=>_i.value&&_i.value.steps[_i.value.current_step]||null);const vi=Ue(()=>_i.value?_i.value.steps.filter(e=>"completed"===e.status||"skipped"===e.status).length:0);function bi(e,n){if(!_i.value)return;const t=_i.value.steps.map((t,r)=>r===e?{...t,status:n}:t);_i.value={..._i.value,steps:t}}function xi(){if(!_i.value)return null;const e=_i.value.current_step+1;if(e>=_i.value.steps.length)return null;const n=_i.value.steps[e].auto_run?"active":"awaiting_initiation",t=_i.value.steps.map((t,r)=>r===e?{...t,status:n}:t);return _i.value={..._i.value,steps:t,current_step:e},_i.value.steps[e]}function yi(){if(!_i.value)return null;const e=_i.value;return mi.value=[...mi.value,e],_i.value=null,e}Ue(()=>_i.value?vi.value/_i.value.total_steps:0);const ki="\n/* Workflow Checklist Container */\n.pillar-workflow {\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding: 16px;\n background: #f9fafb;\n border: 1px solid #e5e7eb;\n border-radius: 12px;\n margin: 12px 0;\n}\n\n/* Header */\n.pillar-workflow__header {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n\n.pillar-workflow__icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: #6b7280;\n}\n\n.pillar-workflow__title {\n flex: 1;\n font-size: 14px;\n font-weight: 600;\n color: #1a1a1a;\n}\n\n.pillar-workflow__progress {\n font-size: 12px;\n font-weight: 500;\n color: #6b7280;\n padding: 2px 8px;\n background: #e5e7eb;\n border-radius: 10px;\n}\n\n.pillar-workflow__description {\n font-size: 13px;\n color: #6b7280;\n}\n\n/* Steps List */\n.pillar-workflow__steps {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n/* Individual Step */\n.pillar-workflow-step {\n display: flex;\n align-items: flex-start;\n gap: 10px;\n padding: 10px 12px;\n background: #ffffff;\n border: 1px solid #e5e7eb;\n border-radius: 8px;\n transition: all 0.15s ease;\n}\n\n.pillar-workflow-step__icon {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n width: 24px;\n height: 24px;\n color: #9ca3af;\n}\n\n.pillar-workflow-step__icon svg {\n width: 18px;\n height: 18px;\n}\n\n.pillar-workflow-step__content {\n flex: 1;\n min-width: 0;\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n.pillar-workflow-step__label {\n font-size: 13px;\n font-weight: 500;\n color: #374151;\n}\n\n.pillar-workflow-step__note {\n font-size: 12px;\n color: #9ca3af;\n}\n\n.pillar-workflow-step__status-text {\n font-size: 12px;\n color: #2563eb;\n font-style: italic;\n}\n\n.pillar-workflow-step__actions {\n display: flex;\n gap: 8px;\n margin-top: 4px;\n}\n\n/* Step States */\n.pillar-workflow-step--pending {\n opacity: 0.6;\n}\n\n.pillar-workflow-step--awaiting_initiation {\n background: #fef3c7;\n border-color: #fcd34d;\n}\n\n.pillar-workflow-step--awaiting_initiation .pillar-workflow-step__icon {\n color: #d97706;\n}\n\n.pillar-workflow-step--active {\n background: #eff6ff;\n border-color: #93c5fd;\n}\n\n.pillar-workflow-step--active .pillar-workflow-step__icon {\n color: #2563eb;\n}\n\n.pillar-workflow-step--completed .pillar-workflow-step__icon {\n color: #059669;\n}\n\n.pillar-workflow-step--completed .pillar-workflow-step__label {\n text-decoration: line-through;\n color: #6b7280;\n}\n\n.pillar-workflow-step--skipped {\n opacity: 0.5;\n}\n\n.pillar-workflow-step--skipped .pillar-workflow-step__icon {\n color: #9ca3af;\n}\n\n.pillar-workflow-step--skipped .pillar-workflow-step__label {\n text-decoration: line-through;\n color: #9ca3af;\n}\n\n.pillar-workflow-step--failed {\n background: #fef2f2;\n border-color: #fca5a5;\n}\n\n.pillar-workflow-step--failed .pillar-workflow-step__icon {\n color: #dc2626;\n}\n\n/* Start Button */\n.pillar-workflow-step__start-btn {\n display: inline-flex;\n align-items: center;\n padding: 6px 12px;\n font-size: 12px;\n font-weight: 600;\n font-family: inherit;\n background: #2563eb;\n color: #ffffff;\n border: none;\n border-radius: 6px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-workflow-step__start-btn:hover {\n background: #1d4ed8;\n}\n\n/* Skip Button */\n.pillar-workflow-step__skip-btn {\n display: inline-flex;\n align-items: center;\n padding: 6px 12px;\n font-size: 12px;\n font-weight: 500;\n font-family: inherit;\n background: transparent;\n color: #6b7280;\n border: 1px solid #d1d5db;\n border-radius: 6px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-workflow-step__skip-btn:hover {\n background: #f3f4f6;\n color: #374151;\n}\n\n/* Spinner Animation for Active Step */\n@keyframes pillar-spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}\n\n.pillar-workflow-step__spinner {\n animation: pillar-spin 1s linear infinite;\n}\n\n/* Footer */\n.pillar-workflow__footer {\n display: flex;\n justify-content: flex-end;\n padding-top: 8px;\n border-top: 1px solid #e5e7eb;\n}\n\n.pillar-workflow__cancel-btn {\n padding: 6px 12px;\n font-size: 12px;\n font-weight: 500;\n font-family: inherit;\n background: transparent;\n color: #9ca3af;\n border: none;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-workflow__cancel-btn:hover {\n color: #dc2626;\n}\n";class wi{constructor(e,n,t,r){this.host=null,this.shadow=null,this.backdrop=null,this.panelElement=null,this.renderRoot=null,this.unsubscribe=null,this.isManualMount=!1,this.themeObserver=null,this.handleKeyDown=e=>{"Escape"===e.key&&Ye.value&&fn()},this.config=e,this.api=n,this.events=t,this.rootContainer=r||null,this.isManualMount="manual"===e.panel.container}detectThemeFromDOM(){const e=document.documentElement;if(e.classList.contains("dark"))return"dark";return"dark"===e.getAttribute("data-theme")||"dark"===e.style.colorScheme?"dark":"light"}get isOpen(){return Ye.value}async init(){var e,n,t;e=this.config.panel.position,nn.value=e,(e=>{tn.value=e})(this.config.panel.mode),(e=>{rn.value=e})(this.config.panel.width),n=this.config.panel.hoverBreakpoint,an.value=n,t=this.config.panel.hoverBackdrop,ln.value=t,(()=>{if("undefined"==typeof window)return;cn?.();const e=()=>{pn.value=window.innerWidth};pn.value=window.innerWidth,window.addEventListener("resize",e),cn=()=>{window.removeEventListener("resize",e)}})(),this.createHost(),this.isManualMount||this.createBackdrop(),this.createPanel(),this.renderPreact(),this.bindEvents(),this.subscribeToState()}open(e){if(e?.search&&(Gn(e.search),it("chat"),Qn()),Ye.value)return e?.view&&it(e.view),void(e?.focusInput&&Xn());Ye.value=!0,"overlay"===gn.value&&(document.body.style.overflow="hidden"),e?.view&&!e?.search&&it(e.view),e?.focusInput?Xn():this.setupFocusTrap()}close(){Ye.value&&fn()}navigate(e,n){Ye.value?it(e,n):this.open({view:e})}destroy(){this.close(),this.isManualMount||this.removePushModeStyles(),this.unsubscribe?.(),this.unsubscribe=null,cn?.(),cn=null,this.themeObserver?.disconnect(),this.themeObserver=null,this.renderRoot&&J(null,this.renderRoot),this.backdrop?.remove(),this.host?.remove(),document.getElementById("pillar-sdk-styles")?.remove(),document.getElementById("pillar-sdk-theme")?.remove(),document.getElementById("pillar-sdk-custom")?.remove(),this.host=null,this.shadow=null,this.backdrop=null,this.panelElement=null,this.renderRoot=null,document.removeEventListener("keydown",this.handleKeyDown),_n(),ot(),Yn()}subscribeToState(){if(this.isManualMount)return void(this.unsubscribe=Ye.subscribe(e=>{e||this.events.emit("panel:close")}));let e=Ye.value,n=gn.value;const t=()=>{const e=Ye.value,n="push"===gn.value,t=rn.value,r=nn.value,i=dn.value&&ln.value;e?(n?(this.applyPushModeStyles(t,r),this.backdrop?.classList.remove("_pillar-backdrop--visible","pillar-backdrop--visible")):(this.removePushModeStyles(),i?this.backdrop?.classList.add("_pillar-backdrop--visible","pillar-backdrop--visible"):this.backdrop?.classList.remove("_pillar-backdrop--visible","pillar-backdrop--visible")),this.panelElement?.classList.add("_pillar-panel--open","pillar-panel--open")):(this.removePushModeStyles(),this.backdrop?.classList.remove("_pillar-backdrop--visible","pillar-backdrop--visible"),this.panelElement?.classList.remove("_pillar-panel--open","pillar-panel--open"))},r=Ye.subscribe(n=>{n!==e&&(e=n,t(),n||(setTimeout(()=>{Ye.value||(ot(),Yn())},300),this.events.emit("panel:close")))}),i=gn.subscribe(e=>{e!==n&&(n=e,t())}),a=hn.subscribe(e=>{e?this.panelElement?.classList.add("_pillar-panel--full-width","pillar-panel--full-width"):this.panelElement?.classList.remove("_pillar-panel--full-width","pillar-panel--full-width")});this.unsubscribe=()=>{r(),i(),a()}}applyPushModeStyles(e,n){document.documentElement.style.transition="padding 0.3s ease","right"===n?document.documentElement.style.paddingRight=`${e}px`:document.documentElement.style.paddingLeft=`${e}px`}removePushModeStyles(){document.documentElement.style.paddingLeft="",document.documentElement.style.paddingRight="",setTimeout(()=>{Ye.value||(document.documentElement.style.transition="")},300)}get renderContainer(){return this.shadow||this.host}transformStylesForRegularDOM(e){return e.replace(/:host\(([^)]+)\)/g,"[data-pillar-panel]$1").replace(/:host-context\(([^)]+)\)/g,"$1 [data-pillar-panel]").replace(/:host:not\(([^)]+)\)/g,"[data-pillar-panel]:not($1)").replace(/:host/g,"[data-pillar-panel]")}injectStylesIntoHead(){const e="pillar-sdk-styles";if(document.getElementById(e))return;const n=fi+ci+ki+ht+At+kt+vt,t=this.transformStylesForRegularDOM(n),r=document.createElement("style");r.id=e,r.textContent=t,document.head.appendChild(r);const i=gi(this.config.theme);if(i){const e=document.createElement("style");e.id="pillar-sdk-theme",e.textContent=this.transformStylesForRegularDOM(i),document.head.appendChild(e)}if(this.config.customCSS){const e=document.createElement("style");e.id="pillar-sdk-custom",e.textContent=this.transformStylesForRegularDOM(this.config.customCSS),document.head.appendChild(e)}}injectStylesIntoShadow(){if(!this.shadow)return;const e=document.createElement("style");e.textContent=fi+ci+ki+ht+At+kt+vt,this.shadow.appendChild(e);const n=gi(this.config.theme);if(n){const e=document.createElement("style");e.textContent=n,e.setAttribute("data-pillar-theme",""),this.shadow.appendChild(e)}if(this.config.customCSS){const e=document.createElement("style");e.textContent=this.config.customCSS,e.setAttribute("data-pillar-custom",""),this.shadow.appendChild(e)}}createHost(){this.host=document.createElement("div"),this.host.className="pillar-panel-host",this.host.setAttribute("data-pillar-panel",""),this.config.panel.useShadowDOM?(this.shadow=this.host.attachShadow({mode:"open"}),this.injectStylesIntoShadow()):(this.shadow=null,this.injectStylesIntoHead()),this.applyThemeMode(),this.setupThemeObserver();const e=this.config.panel.container;if("manual"===e)return;const n=this.rootContainer||document.body;let t=null;"string"==typeof e?(t=document.querySelector(e),t||(console.warn(`[Pillar] Container element not found: ${e}, falling back to root container`),t=n)):t=e instanceof HTMLElement?e:n,t.appendChild(this.host)}mountTo(e){this.host?(this.host.parentElement&&this.host.parentElement.removeChild(this.host),e.appendChild(this.host)):console.warn("[Pillar] Panel host not created yet")}getHostElement(){return this.host}createBackdrop(){this.backdrop=document.createElement("div"),this.backdrop.className="_pillar-backdrop pillar-backdrop",this.backdrop.style.cssText="\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.3);\n opacity: 0;\n visibility: hidden;\n transition: opacity 0.3s ease, visibility 0.3s ease;\n z-index: 99998;\n ",this.backdrop.addEventListener("click",()=>{fn()}),document.body.appendChild(this.backdrop)}createPanel(){const e=this.renderContainer;if(!e)return;this.panelElement=document.createElement("div");const n=this.isManualMount?" _pillar-panel--manual pillar-panel--manual":"",t=`_pillar-panel--${nn.value} pillar-panel--${nn.value}`;this.panelElement.className=`_pillar-panel pillar-panel ${t}${n}`,this.panelElement.style.setProperty("--pillar-panel-width",`${rn.value}px`),this.panelElement.setAttribute("role","dialog"),this.panelElement.setAttribute("aria-modal","true"),this.panelElement.setAttribute("aria-label","Assistant panel"),this.renderRoot=document.createElement("div"),this.renderRoot.className="_pillar-panel-root pillar-panel-root",this.panelElement.appendChild(this.renderRoot),e.appendChild(this.panelElement)}renderPreact(){this.renderRoot&&J(ee(ft,{api:this.api,events:this.events,children:ee(ui,{})}),this.renderRoot)}bindEvents(){document.addEventListener("keydown",this.handleKeyDown)}setupFocusTrap(){setTimeout(()=>{const e=this.renderContainer,n=e?.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');n?.focus()},100)}applyThemeMode(){if(!this.host)return;const e=this.config.theme.mode;if("light"===e||"dark"===e)this.host.setAttribute("data-theme",e);else{const e=this.detectThemeFromDOM();this.host.setAttribute("data-theme",e)}}setupThemeObserver(){"auto"===this.config.theme.mode&&(this.themeObserver=new MutationObserver(()=>{this.applyThemeMode()}),this.themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme","style"]}))}setTheme(e){this.config={...this.config,theme:{...this.config.theme,...e,colors:{...this.config.theme.colors,...e.colors},darkColors:{...this.config.theme.darkColors,...e.darkColors}}},this.applyThemeMode();const n=gi(this.config.theme);if(this.shadow){const e=this.shadow.querySelector("style[data-pillar-theme]");if(e&&n)e.textContent=n;else if(n&&!e){const e=document.createElement("style");e.textContent=n,e.setAttribute("data-pillar-theme","");const t=this.shadow.querySelector("style");t?.nextSibling?this.shadow.insertBefore(e,t.nextSibling):this.shadow.appendChild(e)}}else{const e=this.transformStylesForRegularDOM(n),t=document.getElementById("pillar-sdk-theme");if(t&&e)t.textContent=e;else if(e&&!t){const n=document.createElement("style");n.id="pillar-sdk-theme",n.textContent=e,document.head.appendChild(n)}}}}function Si({label:e,x:n,y:t,isVisible:r,onClick:i}){const a=me(null),[l,o]=fe({x:n,y:t}),[s,p]=fe(!1),c=be(()=>{if(!a.current||!r)return;const e=a.current.getBoundingClientRect(),i=window.innerWidth;let l=n,s=t,c=!1;l=n-e.width/2,l<10?l=10:l+e.width>i-10&&(l=i-e.width-10),s=t-e.height-10,s<10&&(s=t+10,c=!0),o({x:l,y:s}),p(c)},[n,t,r]);_e(()=>{r&&requestAnimationFrame(c)},[r,c,n,t]);return ee("div",{ref:a,class:`pillar-text-selection-popover${r?" pillar-text-selection-popover--visible":""}${s?" pillar-text-selection-popover--below":""}`,style:{left:`${l.x}px`,top:`${l.y}px`},onClick:e=>{e.preventDefault(),e.stopPropagation(),i()},role:"button",tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),i())},children:[ee("div",{class:"pillar-text-selection-popover__content",children:[ee("span",{class:"pillar-text-selection-popover__icon",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 20 20" fill="currentColor"><path d="M10 2a1 1 0 011 1v1.323l3.954 1.582 1.599-.8a1 1 0 01.894 1.79l-1.233.616 1.738 5.42a1 1 0 01-.285 1.05A3.989 3.989 0 0115 15a3.989 3.989 0 01-2.667-1.019 1 1 0 01-.285-1.05l1.715-5.349L10 6.477l-3.763 1.105 1.715 5.349a1 1 0 01-.285 1.05A3.989 3.989 0 015 15a3.989 3.989 0 01-2.667-1.019 1 1 0 01-.285-1.05l1.738-5.42-1.233-.617a1 1 0 01.894-1.788l1.599.799L9 4.323V3a1 1 0 011-1z"/></svg>'}}),ee("span",{children:e})]}),ee("div",{class:"pillar-text-selection-popover__arrow"})]})}const Ci="pillar-text-selection-styles";class Pi{constructor(e,n,t){this.container=null,this.isVisible=!1,this.currentSelection="",this.stylesInjected=!1,this.handleMouseUp=e=>{setTimeout(()=>{this.checkSelection(e)},10)},this.handleMouseDown=e=>{e.target.closest(".pillar-text-selection-popover")||this.hidePopover()},this.handleKeyDown=e=>{"Escape"===e.key&&this.hidePopover()},this.handleScroll=()=>{this.isVisible&&this.hidePopover()},this.handlePopoverClick=()=>{this.currentSelection&&(this.events.emit("textSelection:click",{text:this.currentSelection}),(e=>{const n={...e,id:`ctx_${Date.now()}_${Math.random().toString(36).substring(2,9)}`};qn.value=[...qn.value,n]})({type:"highlighted_text",url_origin:window.location.href,text_content:this.currentSelection}),this.hidePopover(),window.getSelection()?.removeAllRanges(),this.openPanel())},this.config=e,this.events=n,this.openPanel=t}init(){this.stylesInjected||(mn(document,"\n/* Pillar Text Selection Popover Styles */\n.pillar-text-selection-popover {\n position: absolute;\n z-index: 99999;\n padding: 6px 12px;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n font-size: 13px;\n font-weight: 500;\n line-height: 1;\n color: #ffffff;\n background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3), 0 2px 4px rgba(0, 0, 0, 0.1);\n pointer-events: auto;\n opacity: 0;\n transform: translateY(4px) scale(0.95);\n transition: opacity 0.15s ease, transform 0.15s ease;\n cursor: pointer;\n user-select: none;\n}\n\n.pillar-text-selection-popover.pillar-text-selection-popover--visible {\n opacity: 1;\n transform: translateY(0) scale(1);\n}\n\n.pillar-text-selection-popover:hover {\n background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);\n box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4), 0 2px 4px rgba(0, 0, 0, 0.1);\n}\n\n.pillar-text-selection-popover:active {\n transform: translateY(0) scale(0.98);\n}\n\n.pillar-text-selection-popover__content {\n display: flex;\n align-items: center;\n gap: 6px;\n}\n\n.pillar-text-selection-popover__icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 14px;\n height: 14px;\n}\n\n.pillar-text-selection-popover__icon svg {\n width: 100%;\n height: 100%;\n}\n\n/* Arrow pointing down to selection */\n.pillar-text-selection-popover__arrow {\n position: absolute;\n bottom: -5px;\n left: 50%;\n transform: translateX(-50%) rotate(45deg);\n width: 10px;\n height: 10px;\n background: linear-gradient(135deg, #8b5cf6 0%, #8b5cf6 100%);\n}\n\n.pillar-text-selection-popover--below .pillar-text-selection-popover__arrow {\n bottom: auto;\n top: -5px;\n background: linear-gradient(135deg, #6366f1 0%, #6366f1 100%);\n}\n",Ci),this.stylesInjected=!0),this.container=document.createElement("div"),this.container.id="pillar-text-selection-container",document.body.appendChild(this.container),this.bindEvents()}destroy(){this.unbindEvents(),this.container&&(J(null,this.container),this.container.remove(),this.container=null),document.getElementById(Ci)?.remove(),this.stylesInjected=!1,this.isVisible=!1,this.currentSelection=""}bindEvents(){document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("mousedown",this.handleMouseDown),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("scroll",this.handleScroll,!0)}unbindEvents(){document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("scroll",this.handleScroll,!0)}checkSelection(e){const n=window.getSelection();if(!n||n.isCollapsed)return;const t=n.toString().trim();if(t.length<3)return;const r=n.getRangeAt(0),i=r.commonAncestorContainer,a=i instanceof Element?i:i.parentElement;if(a?.closest("[data-pillar-panel]")||a?.closest(".pillar-panel-host"))return;const l=r.getBoundingClientRect(),o=l.left+l.width/2,s=l.top+window.scrollY;this.currentSelection=t,this.showPopover(o,s)}showPopover(e,n){this.container&&(this.isVisible=!0,J(ee(Si,{label:this.config.textSelection.label,x:e,y:n,isVisible:!0,onClick:this.handlePopoverClick}),this.container),this.events.emit("textSelection:shown",{text:this.currentSelection}))}hidePopover(){this.container&&this.isVisible&&(this.isVisible=!1,J(ee(Si,{label:this.config.textSelection.label,x:0,y:0,isVisible:!1,onClick:()=>{}}),this.container))}}const $i={recentActions:[]},Ti={},Ei=He({...$i}),zi=He({...Ti});Ue(()=>{const e=Ei.value;return!!(e.currentPage||e.currentFeature||e.userRole||e.errorState||e.recentActions&&e.recentActions.length>0)}),Ue(()=>!!Ei.value.errorState);const Ii="pillar-";const Mi=[{id:"assistant",label:"Assistant",enabled:!0,order:0}],Ai="https://help-api.trypillar.com",Ri={enabled:!0,position:"right",mode:"push",width:380,useShadowDOM:!1,hoverBreakpoint:1200,hoverBackdrop:!0,fullWidthBreakpoint:500},ji={enabled:!0},Li={enabled:!0,breakpoint:700,position:"bottom-right",icon:"sparkle",iconColor:"white",size:"medium",label:"Get help",offset:24},Bi={enabled:!0,prefix:"pillar-",clearAfterOpen:!0},Hi={enabled:!0,label:"Ask AI"},qi={mode:"auto"};function Oi(e){if(!e||0===e.length)return Mi;const n=new Map;for(const e of Mi)n.set(e.id,{...e});for(const t of e)n.set(t.id,{...t});const t=n.get("assistant");return t&&(t.enabled=!0),Array.from(n.values()).sort((e,n)=>e.order-n.order)}function Di(e){const n=e.productKey??e.helpCenter;if(!n)throw new Error("[Pillar] productKey is required");return e.helpCenter&&!e.productKey&&console.warn('[Pillar] "helpCenter" is deprecated and will be removed in v1.0. Please use "productKey" instead.'),{productKey:n,apiBaseUrl:e.apiBaseUrl||Ai,platform:e.platform||"web",version:e.version,panel:{...Ri,...e.panel},edgeTrigger:{...ji,...e.edgeTrigger},mobileTrigger:{...Li,...e.mobileTrigger},urlParams:{...Bi,...e.urlParams},textSelection:{...Hi,...e.textSelection},sidebarTabs:Oi(e.sidebarTabs),theme:{mode:e.theme?.mode??qi.mode,colors:{...e.theme?.colors},darkColors:{...e.theme?.darkColors}},customCSS:e.customCSS,onReady:e.onReady,onError:e.onError}}class Ni{constructor(){this.listeners=new Map}on(e,n){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(n),()=>{this.off(e,n)}}off(e,n){const t=this.listeners.get(e);t&&t.delete(n)}emit(e,n){const t=this.listeners.get(e);t&&t.forEach(t=>{try{t(n)}catch(n){console.error(`[Pillar] Error in event handler for "${e}":`,n)}})}removeAllListeners(e){e?this.listeners.delete(e):this.listeners.clear()}}function Ui(e){if(e)try{const n=Fi(e);localStorage.removeItem(n),console.log("[PlanPersistence] Cleared saved plan")}catch(e){console.warn("[PlanPersistence] Failed to clear plan:",e)}}function Fi(e){return`pillar:active_plan:${e}`}class Wi{constructor(e,n,t){this.mcpClient=e,this.events=n,this.siteId=t}async handlePlanReceived(e){console.log(`[PlanExecutor] Received plan: ${e.id}, auto_execute=${e.auto_execute}, status=${e.status}`),$t(e),this.persistPlan(e),e.auto_execute&&"executing"===e.status&&(this.events.emit("plan:start",e),await this.executeNextStep())}async recoverPlan(){const e=function(e){if(!e)return null;try{const n=Fi(e),t=localStorage.getItem(n);if(!t)return null;const r=JSON.parse(t);if(1!==r.version)return console.warn("[PlanPersistence] Stored plan has incompatible version, clearing"),Ui(e),null;if(r.siteId!==e)return console.warn("[PlanPersistence] Stored plan is for different site, clearing"),Ui(e),null;const i=new Date(r.storedAt),a=new Date,l=r.plan.timeout_minutes||30,o=(a.getTime()-i.getTime())/6e4;return o>l?(console.warn(`[PlanPersistence] Stored plan has timed out (${Math.round(o)} minutes old, timeout: ${l} minutes)`),Ui(e),null):(console.log(`[PlanPersistence] Loaded plan ${r.plan.id} from localStorage`),r.plan)}catch(n){return console.warn("[PlanPersistence] Failed to load plan:",n),Ui(e),null}}(this.siteId);if(!e)return console.log("[PlanExecutor] No saved plan found"),null;console.log(`[PlanExecutor] Found saved plan ${e.id}, fetching latest state from server`);try{const n=(await this.mcpClient.getPlan(e.id)).plan;return["planning","ready","executing","awaiting_start","awaiting_input","awaiting_result"].includes(n.status)?($t(n),this.events.emit("plan:updated",n),console.log(`[PlanExecutor] Recovered plan ${n.id} with status ${n.status}`),"executing"===n.status&&await this.executeNextStep(),n):(console.log(`[PlanExecutor] Plan ${n.id} is no longer active (status: ${n.status}), clearing`),Ui(this.siteId),null)}catch(e){return console.error("[PlanExecutor] Failed to recover plan from server:",e),Ui(this.siteId),null}}persistPlan(e){!function(e,n){if(!e||!n)return;if(["planning","ready","executing","awaiting_start","awaiting_input","awaiting_result"].includes(e.status))try{const t={version:1,plan:e,siteId:n,storedAt:(new Date).toISOString()},r=Fi(n);localStorage.setItem(r,JSON.stringify(t)),console.log(`[PlanPersistence] Saved plan ${e.id} to localStorage`)}catch(e){console.warn("[PlanPersistence] Failed to save plan:",e)}else Ui(n)}(e,this.siteId)}async startPlan(){const e=wt.value;if(e)if("awaiting_start"===e.status)try{const n=await this.mcpClient.startPlan(e.id);Tt(n.plan),this.events.emit("plan:start",n.plan),await this.executeNextStep()}catch(n){console.error("[PlanExecutor] Failed to start plan:",n),this.events.emit("plan:error",{plan:e,error:n instanceof Error?n:new Error(String(n))})}else console.warn(`[PlanExecutor] Plan ${e.id} is not in awaiting_start status`);else console.warn("[PlanExecutor] No active plan to start")}async executeNextStep(){const e=wt.value;if(!e)return;let n=e.steps.find(e=>"ready"===e.status);if(n||(n=e.steps.find(e=>"awaiting_confirmation"===e.status&&e.requires_user_confirmation)),!n){const n=e.steps.every(e=>"completed"===e.status||"skipped"===e.status||"failed"===e.status);return void(n&&(console.log(`[PlanExecutor] Plan ${e.id} complete`),Tt({...e,status:"completed"}),this.events.emit("plan:complete",wt.value),Ui(this.siteId)))}if(n.requires_user_confirmation&&"awaiting_confirmation"!==n.status)return Et(n.id,{status:"awaiting_confirmation"}),void this.events.emit("plan:step:confirm",{plan:wt.value,step:n});if("awaiting_confirmation"===n.status)return;if("inline_ui"===n.action_type&&"ready"===n.status)return console.log(`[PlanExecutor] Step ${n.index} is inline_ui - waiting for user card interaction`),void this.events.emit("plan:step:active",{plan:wt.value,step:n});await this.executeStep(n)}async confirmStep(e,n){const t=wt.value;if(!t)return;const r=t.steps.find(n=>n.id===e);if(!r)return void console.warn(`[PlanExecutor] Step ${e} not found`);n&&Et(e,{action_data:{...r.action_data,...n}});const i=wt.value,a=i?.steps.find(n=>n.id===e);a&&await this.executeStep(a)}async confirmInlineStep(e,n){const t=wt.value;if(!t)return void console.warn("[PlanExecutor] No active plan for inline confirmation");const r=t.steps.find(n=>n.id===e);r?(console.log(`[PlanExecutor] Inline step ${r.index} completed with data:`,n),await this.markStepComplete(e,n)):console.warn(`[PlanExecutor] Step ${e} not found`)}async skipStep(e){const n=wt.value;if(!n)return;const t=n.steps.find(n=>n.id===e);if(t)try{const r=await this.mcpClient.skipStep(n.id,e);Tt(r.plan),this.events.emit("plan:step:skip",{plan:r.plan,step:t}),await this.executeNextStep()}catch(n){console.error("[PlanExecutor] Failed to skip step:",n),Et(e,{status:"skipped"});const r=t.index+1,i=wt.value;if(i&&r<i.steps.length){const e=i.steps[r];"pending"===e.status&&Et(e.id,{status:"ready"})}this.events.emit("plan:step:skip",{plan:wt.value,step:t}),await this.executeNextStep()}else console.warn(`[PlanExecutor] Step ${e} not found`)}async retryStep(e){const n=wt.value;if(!n)return;const t=n.steps.find(n=>n.id===e);if(t)if(t.is_retriable)if(t.retry_count>=t.max_retries)console.warn(`[PlanExecutor] Step ${e} has exceeded max retries (${t.retry_count}/${t.max_retries})`);else try{const r=await this.mcpClient.retryStep(n.id,e);Tt(r.plan);const i=r.plan.steps.find(n=>n.id===e);this.events.emit("plan:step:retry",{plan:r.plan,step:i||t,retryCount:i?.retry_count||t.retry_count+1}),await this.executeNextStep()}catch(e){console.error("[PlanExecutor] Failed to retry step:",e),this.events.emit("plan:error",{plan:wt.value,error:e instanceof Error?e:new Error(String(e))})}else console.warn(`[PlanExecutor] Step ${e} is not retriable`);else console.warn(`[PlanExecutor] Step ${e} not found`)}async cancel(){const e=wt.value;if(e)try{const n=await this.mcpClient.cancelPlan(e.id);Tt(n.plan),this.events.emit("plan:cancel",n.plan),zt(!0),Ui(this.siteId)}catch(n){console.error("[PlanExecutor] Failed to cancel plan:",n),this.events.emit("plan:cancel",e),zt(!0),Ui(this.siteId)}else console.warn("[PlanExecutor] No active plan to cancel")}dismissPlan(){const e=wt.value;e?"completed"===e.status||"failed"===e.status?(console.log(`[PlanExecutor] Dismissing completed plan ${e.id}`),this.events.emit("plan:complete",e),zt(!0)):console.warn(`[PlanExecutor] Plan ${e.id} is not completed/failed (status: ${e.status}), use cancel() instead`):console.warn("[PlanExecutor] No active plan to dismiss")}async completeStepByAction(e,n=!0,t){const r=wt.value;if(!r)return;const i=r.steps.find(n=>n.action_name===e&&"awaiting_result"===n.status);i&&(console.log(`[PlanExecutor] Completing step ${i.index} (${e}) via callback`),n?await this.markStepComplete(i.id,t):(Et(i.id,{status:"failed",result:{error:"Action failed by host app"}}),this.events.emit("plan:step:failed",{plan:wt.value,step:wt.value.steps.find(e=>e.id===i.id),error:new Error("Action failed by host app"),canRetry:i.is_retriable})))}async markStepDone(e){const n=wt.value;if(!n)return void console.warn("[PlanExecutor] No active plan");const t=n.steps.find(n=>n.id===e);t?"awaiting_result"===t.status?(console.log(`[PlanExecutor] Marking step ${t.index} as done via UI button`),await this.markStepComplete(e)):console.warn(`[PlanExecutor] Step ${e} is not awaiting result (status: ${t.status})`):console.warn(`[PlanExecutor] Step ${e} not found`)}async markStepComplete(e,n){Et(e,{status:"completed",result:n});const t=wt.value,r=t.steps.find(n=>n.id===e),i=r.index+1;if(i<t.steps.length){const e=t.steps[i];"pending"===e.status&&Et(e.id,{status:"ready"})}this.events.emit("plan:step:complete",{plan:wt.value,step:r,success:!0}),await this.executeNextStep()}async executeStep(e){const n=wt.value;if(!n)return;if("guidance"===e.step_type){console.log(`[PlanExecutor] Guidance step ${e.index}: ${e.description}`),Et(e.id,{status:"completed"});const n=wt.value,t=n.steps.find(n=>n.id===e.id),r=e.index+1;if(r<n.steps.length){const e=n.steps[r];"pending"===e.status&&Et(e.id,{status:"ready"})}return this.events.emit("plan:step:complete",{plan:wt.value,step:t,success:!0}),void await this.executeNextStep()}const t=e.action_name||"unknown";console.log(`[PlanExecutor] Executing step ${e.index}: ${t}`),Et(e.id,{status:"executing"}),this.events.emit("plan:step:active",{plan:wt.value,step:e});try{const r=t&&a(t)?i(t):void 0,l=r?.handler,o=e.action_type;let s;if(l){if(s=await l(e.action_data),r?.returns&&void 0!==s){const{default:e}=await Promise.resolve().then(function(){return Ki}),n=e.getInstance();n&&n.sendActionResult(t,s)}}else{const{default:n}=await Promise.resolve().then(function(){return Ki}),r=n.getInstance();if(!r)throw new Error(`No handler for action: ${t} (Pillar not initialized)`);{const n=e.action_data?.path,i=e.action_data?.url;console.log(`[PlanExecutor] Executing via Pillar.executeTask: ${t}`),r.executeTask({id:e.id,name:t,taskType:o,path:n,externalUrl:i,data:e.action_data||{}}),s={executed:!0,action:t}}}if(e.requires_result_feedback){console.log(`[PlanExecutor] Sending step ${e.index} result to server`);const t=await this.mcpClient.continuePlan(n.id,e.id,s);Tt(t.plan),this.events.emit("plan:updated",t.plan)}else if(e.auto_complete){if(!l&&("navigate"===o||"open_modal"===o))console.log(`[PlanExecutor] Step ${e.index} is wizard action (${o}) - awaiting callback despite auto_complete=true`),Et(e.id,{status:"awaiting_result",result:s}),this.events.emit("plan:step:active",{plan:wt.value,step:e});else{Et(e.id,{status:"completed",result:s});let n=wt.value;const t=n?.steps.find(n=>n.id===e.id),r=e.index+1;if(n&&r<n.steps.length){const e=n.steps[r];"pending"===e.status&&(Et(e.id,{status:"ready"}),n=wt.value)}this.events.emit("plan:step:complete",{plan:n,step:t||e,success:!0}),await this.executeNextStep()}}else console.log(`[PlanExecutor] Step ${e.index} awaiting callback (auto_complete=false)`),Et(e.id,{status:"awaiting_result",result:s}),this.events.emit("plan:step:active",{plan:wt.value,step:e})}catch(t){console.error(`[PlanExecutor] Step ${e.index} failed:`,t);const r=t instanceof Error?t.message:"Unknown error";try{Tt((await this.mcpClient.failStep(n.id,e.id,r)).plan)}catch(n){console.error("[PlanExecutor] Failed to notify server of step failure:",n),Et(e.id,{status:"failed",error_message:r})}const i=wt.value,a=i?.steps.find(n=>n.id===e.id),l=a?a.is_retriable&&a.retry_count<a.max_retries:e.is_retriable&&e.retry_count<e.max_retries;this.events.emit("plan:step:failed",{plan:i,step:a||e,error:t instanceof Error?t:new Error(String(t)),canRetry:l}),this.events.emit("plan:step:complete",{plan:i,step:a||e,success:!1}),l||this.events.emit("plan:error",{plan:i,error:t instanceof Error?t:new Error(String(t))})}}getActivePlan(){return wt.value}}class Vi{constructor(){this._state="uninitialized",this._config=null,this._api=null,this._mcpClient=null,this._planExecutor=null,this._textSelectionManager=null,this._panel=null,this._edgeTrigger=null,this._mobileTrigger=null,this._initPromise=null,this._rootContainer=null,this._unsubscribeHoverMode=null,this._context={...$i},this._userProfile={...Ti},this._taskHandlers=new Map,this._anyTaskHandler=null,this._cardRenderers=new Map,this._events=new Ni}_createRootContainer(){let e=document.getElementById("pillar-root");if(e)return this._subscribeToHoverModeForRoot(e),e;e=document.createElement("div"),e.id="pillar-root";const n=dn.value?"20":"-1";return e.style.cssText=`isolation: isolate; z-index: ${n}; position: relative;`,document.body.appendChild(e),this._subscribeToHoverModeForRoot(e),e}_subscribeToHoverModeForRoot(e){this._unsubscribeHoverMode?.(),this._unsubscribeHoverMode=dn.subscribe(n=>{e.style.zIndex=n?"20":"-1"})}static async init(e){if(!e.productKey&&!e.helpCenter)throw new Error("[Pillar] productKey is required");return Vi.instance||(Vi.instance=new Vi),await Vi.instance._init(e),Vi.instance}static getInstance(){return Vi.instance}static destroy(){Vi.instance&&(Vi.instance._destroy(),Vi.instance=null)}get state(){return this._state}get isReady(){return"ready"===this._state}get isPanelOpen(){return Ye.value}get config(){return this._config}on(e,n){return this._events.on(e,n)}open(e){this._panel&&(this._panel.open(e),this._events.emit("panel:open"))}close(){this._panel&&(this._panel.close(),this._events.emit("panel:close"))}toggle(){this.isPanelOpen?this.close():this.open()}navigate(e,n){this._panel?.navigate(e,n),this._events.emit("panel:navigate",{view:e,params:n})}setContext(e){this._context={...this._context,...e},(e=>{Ei.value={...Ei.value,...e}})(e),this._events.emit("context:change",{context:this._context})}getChatContext(){const e=$n.value,n=Tn.value;return 0===e.length?null:{conversationId:n,messages:e.map(e=>({role:e.role,content:e.content}))}}setTheme(e){this._config&&(this._config.theme={...this._config.theme,...e,mode:e.mode??this._config.theme.mode,colors:{...this._config.theme.colors,...e.colors},darkColors:{...this._config.theme.darkColors,...e.darkColors}},this._panel?.setTheme(this._config.theme),this._events.emit("theme:change",{theme:this._config.theme}))}setTextSelectionEnabled(e){if(!this._config)return;this._config.textSelection.enabled!==e&&(this._config.textSelection.enabled=e,e?this._config.panel.enabled&&!this._textSelectionManager&&(this._textSelectionManager=new Pi(this._config,this._events,()=>this.open()),this._textSelectionManager.init()):this._textSelectionManager&&(this._textSelectionManager.destroy(),this._textSelectionManager=null),this._events.emit("textSelection:change",{enabled:e}))}mountPanelTo(e){this._panel?.mountTo(e)}getPanelHostElement(){return this._panel?.getHostElement()??null}get context(){return{...this._context}}get userProfile(){return{...this._userProfile}}setUserProfile(e){this._userProfile={...e},(e=>{zi.value={...e}})(this._userProfile),this._events.emit("profile:change",{profile:this._userProfile})}reportAction(e,n){const t=[...(this._context.recentActions||[]).slice(-9),e];this._context={...this._context,recentActions:t},(e=>{const n=Ei.value.recentActions||[];Ei.value={...Ei.value,recentActions:[...n.slice(-9),e]}})(e),this._events.emit("action:report",{action:e,metadata:n})}clearErrorState(){if(this._context.errorState){const{errorState:e,...n}=this._context;this._context=n,(()=>{const{errorState:e,...n}=Ei.value;Ei.value=n})(),this._events.emit("context:change",{context:this._context})}}setErrorState(e,n){this._context={...this._context,errorState:{code:e,message:n}},((e,n)=>{Ei.value={...Ei.value,errorState:{code:e,message:n}}})(e,n),this._events.emit("context:change",{context:this._context})}async getSuggestions(){if(!this._api)return console.warn("[Pillar] SDK not initialized, cannot get suggestions"),[];try{return await this._api.getSuggestions(this._context,this._userProfile)}catch(e){return console.error("[Pillar] Failed to get suggestions:",e),[]}}getAssistantContext(){return{product:this._context,user:this._userProfile}}onTask(e,n){return this._taskHandlers.set(e,n),()=>this._taskHandlers.delete(e)}onAnyTask(e){return this._anyTaskHandler=e,()=>{this._anyTaskHandler=null}}offTask(e){this._taskHandlers.delete(e)}executeTask(e){const{name:n,data:t,taskType:r,path:l,externalUrl:o}=e;if(this._events.emit("task:execute",e),this._anyTaskHandler)try{this._anyTaskHandler(n,t)}catch(e){console.error("[Pillar] Error in onAnyTask handler:",e)}const s=a(n)?i(n):void 0,p=s?.handler,c=this._taskHandlers.get(n),d=r?this._taskHandlers.get(r):void 0,u=p||c||d;if(u)try{const e=u("navigate"===r&&l?{...t,path:l}:t);s?.returns&&void 0!==e&&Promise.resolve(e).then(e=>{void 0!==e&&this.sendActionResult(n,e)}).catch(e=>{console.error(`[Pillar] Error in query action "${n}":`,e)}),this._events.emit("task:complete",{name:n,success:!0,data:t})}catch(e){console.error(`[Pillar] Error executing task "${n}":`,e),this._events.emit("task:complete",{name:n,success:!1,data:t})}else switch(r){case"navigate":l&&"undefined"!=typeof window&&(console.warn("[Pillar] No 'navigate' handler registered. Using window.location.href as fallback."),window.location.href=l,this._events.emit("task:complete",{name:n,success:!0,data:t}));break;case"external_link":o&&"undefined"!=typeof window&&(window.open(o,"_blank","noopener,noreferrer"),this._events.emit("task:complete",{name:n,success:!0,data:t}));break;case"copy_text":t.text&&"undefined"!=typeof navigator&&navigator.clipboard&&navigator.clipboard.writeText(String(t.text)).then(()=>{this._events.emit("task:complete",{name:n,success:!0,data:t})}).catch(()=>{this._events.emit("task:complete",{name:n,success:!1,data:t})});break;default:console.warn(`[Pillar] No handler registered for task "${n}". Register one with pillar.onTask('${n}', handler)`),this._events.emit("task:complete",{name:n,success:!1,data:{error:"No handler registered"}})}}completeTask(e,n=!0,t){this._events.emit("task:complete",{name:e,success:n,data:t})}async completeAction(e,n=!0,t){this._events.emit("task:complete",{name:e,success:n,data:t}),this._planExecutor&&await this._planExecutor.completeStepByAction(e,n,t)}confirmTaskExecution(e,n,t){e?this._api?this._api.confirmTaskExecution(e,n,t):console.warn("[Pillar] SDK not initialized, cannot confirm task execution"):console.warn("[Pillar] confirmTaskExecution called without taskId")}registerCard(e,n){return this._cardRenderers.set(e,n),()=>this._cardRenderers.delete(e)}getCardRenderer(e){return this._cardRenderers.get(e)}hasCardRenderer(e){return this._cardRenderers.has(e)}get workflow(){return _i.value}startWorkflow(e){!function(e){_i.value&&(mi.value=[...mi.value,_i.value]);const n=e.steps.map((e,n)=>0===n?{...e,status:e.auto_run?"active":"awaiting_initiation"}:{...e,status:"pending"});_i.value={...e,steps:n,current_step:0}}(e),this._events.emit("workflow:start",_i.value);const n=_i.value.steps[0];n.auto_run&&this._executeWorkflowStep(n)}initiateWorkflowStep(e){const n=_i.value;if(!n)return void console.warn("[Pillar] No active workflow");const t=e??n.current_step,r=n.steps[t];r?"awaiting_initiation"===r.status?this._executeWorkflowStep(r):console.warn(`[Pillar] Step ${t} is not awaiting initiation`):console.warn(`[Pillar] Invalid step index: ${t}`)}confirmWorkflowStep(e,n){const t=_i.value;if(!t)return;const r=n??t.current_step;if(t.steps[r],bi(r,e?"completed":"failed"),this._events.emit("workflow:step:complete",{workflow:_i.value,step:_i.value.steps[r],success:e}),!e)return;const i=xi();if(!i)return this._events.emit("workflow:complete",_i.value),void yi();this._events.emit("workflow:step:active",{workflow:_i.value,step:i}),i.auto_run&&this._executeWorkflowStep(i)}skipWorkflowStep(e){const n=_i.value;if(!n)return;const t=e??n.current_step;n.steps[t],bi(t,"skipped"),this._events.emit("workflow:step:skip",{workflow:_i.value,step:_i.value.steps[t]});const r=xi();if(!r)return this._events.emit("workflow:complete",_i.value),void yi();this._events.emit("workflow:step:active",{workflow:_i.value,step:r}),r.auto_run&&this._executeWorkflowStep(r)}cancelWorkflow(){const e=_i.value;e&&(this._events.emit("workflow:cancel",e),function(){if(!_i.value)return null;const e=_i.value;_i.value=null}())}_executeWorkflowStep(e){bi(e.index,"active"),this.executeTask({id:e.task_id,name:e.task_name,taskType:e.task_type,data:e.data,path:e.data?.path,externalUrl:e.data?.url}),e.auto_complete&&setTimeout(()=>{this.confirmWorkflowStep(!0,e.index)},100)}get activePlan(){return wt.value}handlePlanReceived(e){this._planExecutor?.handlePlanReceived(e)}async startPlan(){await(this._planExecutor?.startPlan())}async confirmPlanStep(e,n){await(this._planExecutor?.confirmStep(e,n))}async confirmInlinePlanStep(e,n){await(this._planExecutor?.confirmInlineStep(e,n))}async skipPlanStep(e){await(this._planExecutor?.skipStep(e))}async retryPlanStep(e){await(this._planExecutor?.retryStep(e))}async cancelPlan(){await(this._planExecutor?.cancel())}async markPlanStepDone(e){await(this._planExecutor?.markStepDone(e))}sendActionResult(e,n){this._mcpClient?(this._mcpClient.sendActionResult(e,n),this._events.emit("action:result",{actionName:e,result:n})):console.warn("[Pillar] SDK not initialized, cannot send action result")}async _init(e){if("initializing"===this._state&&this._initPromise)return console.log("[Pillar] Already initializing, waiting for completion"),void await this._initPromise;"ready"!==this._state?(this._state="initializing",this._initPromise=this._doInit(e),await this._initPromise):console.log("[Pillar] Already initialized")}async _doInit(e){try{await new Promise(e=>{"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>e(),{once:!0}):e()});const r=Di(e),i=new u(r),a=function(e,n){if(!n)return e;const t={...e};return n.panel&&(t.panel={...n.panel,...e.panel}),n.theme?.colors?.primary&&(t.theme={...t.theme,colors:{primary:e.theme?.colors?.primary??n.theme.colors.primary,...e.theme?.colors}}),t}(e,await i.fetchEmbedConfig().catch(e=>(console.warn("[Pillar] Failed to fetch server config, using local config only:",e),null)));this._config=Di(a),this._config.platform&&this._config.version&&n(this._config.platform,this._config.version),this._api=new u(this._config),this._mcpClient=new c(this._config),this._planExecutor=new Wi(this._mcpClient,this._events,this._config.productKey),this._rootContainer=this._createRootContainer(),t=this._config.mobileTrigger.breakpoint,on.value=t,(e=>{sn.value=e})(this._config.panel.fullWidthBreakpoint),this._config.panel.enabled&&(this._panel=new wi(this._config,this._api,this._events,this._rootContainer),await this._panel.init()),this._config.edgeTrigger.enabled&&(this._edgeTrigger=new yn(this._config,this._events,()=>this.toggle(),this._rootContainer),this._edgeTrigger.init()),this._config.mobileTrigger.enabled&&(this._mobileTrigger=new Cn(this._config,this._events,()=>this.toggle(),this._rootContainer),this._mobileTrigger.init()),this._config.textSelection.enabled&&this._config.panel.enabled&&(this._textSelectionManager=new Pi(this._config,this._events,()=>this.open()),this._textSelectionManager.init()),this._state="ready",this._events.emit("ready"),this._config.onReady?.(),console.log("[Pillar] SDK initialized successfully"),await(this._planExecutor?.recoverPlan()),this._config.urlParams.enabled&&await this._handleUrlParams()}catch(e){this._state="error";const n=e instanceof Error?e:new Error(String(e));throw this._events.emit("error",n),this._config?.onError?.(n),console.error("[Pillar] Failed to initialize:",e),e}var t}async _handleUrlParams(){if(!this._config)return;(function(e=Ii){if("undefined"==typeof window||!window.location)return{};const n=new URLSearchParams(window.location.search),t={};n.has(`${e}open`)&&(t.open=!0);const r=n.get(`${e}article`);r&&(t.article=r);const i=n.get(`${e}article-id`);i&&!t.article&&(t.article=i);const a=n.get(`${e}category`);a&&(t.category=a);const l=n.get(`${e}search`);return l&&(t.search=l),t})(this._config.urlParams.prefix).open&&(this.open(),this._config.urlParams.clearAfterOpen&&function(e=Ii){if("undefined"==typeof window||!window.location||!window.history)return;const n=new URL(window.location.href),t=[`${e}open`,`${e}article`,`${e}article-id`,`${e}category`,`${e}search`];let r=!1;for(const e of t)n.searchParams.has(e)&&(n.searchParams.delete(e),r=!0);r&&window.history.replaceState({},"",n.toString())}(this._config.urlParams.prefix))}_destroy(){this._textSelectionManager?.destroy(),this._panel?.destroy(),this._edgeTrigger?.destroy(),this._mobileTrigger?.destroy(),this._api?.cancelAllRequests(),this._events.removeAllListeners(),this._unsubscribeHoverMode?.(),this._unsubscribeHoverMode=null,this._rootContainer?.remove(),this._rootContainer=null,_n(),ot(),Yn(),Ei.value={...$i},zi.value={...Ti},_i.value=null,mi.value=[],wt.value=null,St.value=[],this._context={...$i},this._userProfile={...Ti},this._taskHandlers.clear(),this._anyTaskHandler=null,this._textSelectionManager=null,this._panel=null,this._edgeTrigger=null,this._mobileTrigger=null,this._api=null,this._mcpClient=null,this._planExecutor=null,this._config=null,this._state="uninitialized",console.log("[Pillar] SDK destroyed")}}Vi.instance=null;var Ki=Object.freeze({__proto__:null,Pillar:Vi,default:Vi});if("undefined"!=typeof window){window.Pillar=Vi;const e=()=>{const e=document.currentScript;if(e){const n=e.dataset.productKey??e.dataset.helpCenter;e.dataset.helpCenter&&!e.dataset.productKey&&console.warn("[Pillar] data-help-center is deprecated. Use data-product-key instead."),n&&Vi.init({productKey:n}).catch(console.error)}};if("loading"===document.readyState)document.addEventListener("DOMContentLoaded",e);else{const e=document.querySelectorAll("script[data-product-key], script[data-help-center]");if(e.length>0){const n=e[e.length-1],t=n.dataset.productKey??n.dataset.helpCenter;n.dataset.helpCenter&&!n.dataset.productKey&&console.warn("[Pillar] data-help-center is deprecated. Use data-product-key instead."),t&&Vi.init({productKey:t}).catch(console.error)}}}export{u as APIClient,Mi as DEFAULT_SIDEBAR_TABS,Ni as EventEmitter,Vi as Pillar,s as clearRegistry,Vi as default,p as getActionCount,i as getActionDefinition,l as getActionNames,t as getClientInfo,r as getHandler,o as getManifest,a as hasAction,n as setClientInfo};
|
|
1
|
+
let e=!1;function n(n){e=n,console.log("[Pillar] Debug mode enabled - verbose logging active")}function t(){return e||r()}const r=()=>{if("undefined"!=typeof process&&process.env?.NODE_ENV)return"development"===process.env.NODE_ENV;if("undefined"!=typeof window){const e=window.location?.hostname||"";return"localhost"===e||"127.0.0.1"===e||e.includes(".local")}return!1},i=["[Pillar]","[MCPClient]","[PlanExecutor]"],a=["sdk","handler","network"];class l{constructor(e,n=5e3){this.buffer=[],this.flushTimer=null,this.maxBufferSize=100,this.handleBeforeUnload=()=>{this.flush()},this.mcpClient=e,this.flushIntervalMs=n,this.startFlushTimer(),this.setupUnloadListener()}shouldForward(e){return!!a.includes(e.source)||(!(!e.prefix||!i.some(n=>e.prefix?.startsWith(n)))||"error"===e.level)}bufferEntry(e){const n={level:"info"===e.level?"log":e.level,message:e.prefix?`${e.prefix} ${e.event}`:`[${e.source}] ${e.event}`,data:e.data,timestamp:new Date(e.timestamp).toISOString()};this.buffer.push(n),this.buffer.length>=this.maxBufferSize&&this.flush(),"error"===e.level&&this.flush()}flush(){if(0===this.buffer.length)return;const e=this.buffer.splice(0);this.mcpClient.sendLogBatch(e)}startFlushTimer(){this.flushTimer||(this.flushTimer=setInterval(()=>this.flush(),this.flushIntervalMs))}stopFlushTimer(){this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null)}setupUnloadListener(){"undefined"!=typeof window&&window.addEventListener("beforeunload",this.handleBeforeUnload)}removeUnloadListener(){"undefined"!=typeof window&&window.removeEventListener("beforeunload",this.handleBeforeUnload)}destroy(){this.stopFlushTimer(),this.removeUnloadListener(),this.flush(),this.buffer=[]}}const o=new class{constructor(){this.entries=[],this.maxEntries=500,this.listeners=new Set,this.serverForwarder=null,this.forwarderUnsubscribe=null}add(e){const n={...e,timestamp:Date.now()};this.entries.push(n),this.entries.length>this.maxEntries&&(this.entries=this.entries.slice(-this.maxEntries)),this.listeners.forEach(e=>e(this.entries)),t()&&!e.prefix&&this.logToConsole(n),this.serverForwarder?.shouldForward(n)&&this.serverForwarder.bufferEntry(n)}logToConsole(e){const n=`[${new Date(e.timestamp).toISOString().split("T")[1].slice(0,12)}] [${e.source}]`,t=void 0!==e.data?[n,e.event,e.data]:[n,e.event];"error"===e.level?console.error(...t):"warn"===e.level?console.warn(...t):console.log(...t)}enableServerForwarding(e,n){this.disableServerForwarding(),this.serverForwarder=new l(e,n?.flushIntervalMs)}disableServerForwarding(){this.serverForwarder&&(this.serverForwarder.destroy(),this.serverForwarder=null),this.forwarderUnsubscribe&&(this.forwarderUnsubscribe(),this.forwarderUnsubscribe=null)}flush(){this.serverForwarder?.flush()}getEntries(){return[...this.entries]}clear(){this.entries=[],this.listeners.forEach(e=>e(this.entries))}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}destroy(){this.disableServerForwarding(),this.entries=[],this.listeners.clear()}};function s(e){if(0===e.length)return{event:""};const n=e[0];let t,r,i=[];"string"==typeof n&&n.startsWith("[")&&n.endsWith("]")&&(t=n,e=e.slice(1));for(const n of e)"string"==typeof n?i.push(n):"object"==typeof n&&null!==n&&(r=n);return{prefix:t,event:i.join(" "),data:r}}function c(e){return e?e.includes("MCPClient")?"network":(e.includes("PlanExecutor"),"sdk"):"sdk"}const p={configure:(e,n)=>{!1!==n?.forwardToServer&&o.enableServerForwarding(e,{flushIntervalMs:n?.flushIntervalMs})},flush:()=>{o.flush()},log:(...e)=>{if(!t())return;const{prefix:n,event:r,data:i}=s(e);console.log(...e),o.add({event:r,data:i,source:c(n),level:"info",prefix:n})},warn:(...e)=>{if(!t())return;const{prefix:n,event:r,data:i}=s(e);console.warn(...e),o.add({event:r,data:i,source:c(n),level:"warn",prefix:n})},error:(...e)=>{const{prefix:n,event:t,data:r}=s(e);console.error(...e),o.add({event:t,data:r,source:c(n),level:"error",prefix:n})},destroy:()=>{o.destroy()}};var d=Object.freeze({__proto__:null,debug:p,debugLog:o,isDebugEnabled:t,setDebugMode:n});class u{constructor(){this.listeners=new Map}on(e,n){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(n),()=>{this.off(e,n)}}off(e,n){const t=this.listeners.get(e);t&&t.delete(n)}emit(e,n){const t=this.listeners.get(e);t&&t.forEach(t=>{try{t(n)}catch(n){p.error(`[Pillar] Error in event handler for "${e}":`,n)}})}removeAllListeners(e){e?this.listeners.delete(e):this.listeners.clear()}}const h={actions:new Map,clientInfo:null};function g(e,n){h.clientInfo={platform:e,version:n}}function f(){return h.clientInfo}function m(e){const n=h.actions.get(e);return n?.handler}function b(e){return h.actions.get(e)}function v(e){return h.actions.has(e)}function _(){return Array.from(h.actions.keys())}function x(e,n,t){const r=[];for(const[e,n]of h.actions){const t={name:e,description:n.description,type:n.type};n.examples?.length&&(t.examples=n.examples),n.path&&(t.path=n.path),n.externalUrl&&(t.external_url=n.externalUrl),n.autoRun&&(t.auto_run=n.autoRun),n.autoComplete&&(t.auto_complete=n.autoComplete),n.returns&&(t.returns_data=n.returns),n.dataSchema&&(t.data_schema=n.dataSchema),n.defaultData&&(t.default_data=n.defaultData),n.requiredContext&&(t.required_context=n.requiredContext),r.push(t)}return{platform:e,version:n,gitSha:t,generatedAt:(new Date).toISOString(),actions:r}}function y(){h.actions.clear(),h.clientInfo=null}function w(){return h.actions.size}class k{constructor(e){this.requestId=0,this._externalUserId="",this.config=e}setExternalUserId(e){this._externalUserId=e}getVisitorId(){if("undefined"==typeof window)return"";const e="pillar_visitor_id";try{let n=localStorage.getItem(e);return n||(n=crypto.randomUUID(),localStorage.setItem(e,n)),n}catch{return""}}getSessionId(){if("undefined"==typeof window)return"";const e="pillar_mcp_session_id";try{let n=sessionStorage.getItem(e);return n||(n=crypto.randomUUID(),sessionStorage.setItem(e,n)),n}catch{return""}}getPageUrl(){return"undefined"==typeof window?"":window.location.href}get baseUrl(){return`${this.config.apiBaseUrl}/mcp/`}get headers(){const e={"Content-Type":"application/json","x-customer-id":this.config.productKey,"x-visitor-id":this.getVisitorId(),"x-page-url":this.getPageUrl()},n=this.getSessionId();return n&&(e["Mcp-Session-Id"]=n),this._externalUserId&&(e["x-external-user-id"]=this._externalUserId),"undefined"!=typeof navigator&&(e["Accept-Language"]=navigator.language||navigator.languages?.[0]||"en"),this.config.platform&&(e["X-Pillar-Platform"]=this.config.platform),this.config.version&&(e["X-Pillar-Action-Version"]=this.config.version),e}nextId(){return++this.requestId}async callTool(e,n){const t=performance.now(),r={jsonrpc:"2.0",id:this.nextId(),method:"tools/call",params:{name:e,arguments:n}};o.add({event:"network:request",data:{method:"tools/call",tool:e,url:this.baseUrl},source:"network",level:"info"});const i=await fetch(this.baseUrl,{method:"POST",headers:this.headers,body:JSON.stringify(r)}),a=Math.round(performance.now()-t);if(!i.ok){const e=await i.json().catch(()=>({}));throw o.add({event:"network:response",data:{status:i.status,duration:a,error:e.error?.message},source:"network",level:"error"}),new Error(e.error?.message||`MCP error: ${i.status}`)}const l=await i.json();if(o.add({event:"network:response",data:{status:i.status,duration:a,method:"tools/call",tool:e},source:"network",level:"info"}),l.error)throw new Error(l.error.message);return l.result}async callToolStream(e,n,t,r){const i=performance.now(),a=this.nextId();t.onRequestId?.(a);const l={jsonrpc:"2.0",id:a,method:"tools/call",params:{name:e,arguments:n,stream:!0}};o.add({event:"network:request",data:{method:"tools/call",tool:e,stream:!0,url:this.baseUrl},source:"network",level:"info"});const s=await fetch(this.baseUrl,{method:"POST",headers:{...this.headers,Accept:"text/event-stream"},body:JSON.stringify(l),signal:r}),c=Math.round(performance.now()-i);if(!s.ok){const e=await s.text();throw o.add({event:"network:response",data:{status:s.status,duration:c,error:e},source:"network",level:"error"}),new Error(`MCP streaming request failed: ${s.statusText} - ${e}`)}if(o.add({event:"network:stream:connected",data:{status:s.status,connectionTime:c,tool:e},source:"network",level:"info"}),!s.body)throw new Error("Response body is null");const d=s.body.getReader(),u=new TextDecoder;let h="",g=[],f=null;try{for(;;){const{done:e,value:n}=await d.read();if(e)break;h+=u.decode(n,{stream:!0});const r=h.split("\n");h=r.pop()||"";for(const e of r)if(e.trim()&&e.startsWith("data: "))try{const n=e.substring(6),r=JSON.parse(n);if("2.0"===r.jsonrpc){if(r.error)throw t.onError?.(r.error.message||"Unknown error"),new Error(r.error.message);if("notifications/progress"===r.method){const e=r.params?.progress;if(e){if("debug"===e.type){o.add({event:e.event||"server:event",data:e.data,source:"server",level:"info"});continue}if("progress"===e.type&&e.data){const n=e.data;p.log(`[MCPClient] Progress event (new schema): ${n.kind}`,n),t.onProgress?.({kind:n.kind,id:n.id,label:n.label,status:n.status,text:n.text,children:n.children,metadata:n.metadata});continue}if("token"!==e.kind&&"token"!==e.type&&(console.log(`[MCPClient] Progress event: kind=${e.kind} type=${e.type}`,e),p.log(`[MCPClient] Progress event: ${e.kind}`,e)),"token"===e.kind&&e.token)g.push(e.token),t.onToken?.(e.token);else if("conversation_started"===e.kind)t.onConversationStarted?.(e.conversation_id,e.assistant_message_id);else if("token_usage"===e.kind)t.onTokenUsage?.({prompt_tokens:e.prompt_tokens,completion_tokens:e.completion_tokens,total_prompt_tokens:e.total_prompt_tokens,total_completion_tokens:e.total_completion_tokens,total_used:e.total_used,context_window:e.context_window,occupancy_pct:e.occupancy_pct,model_name:e.model_name,iteration:e.iteration});else{if("cancelled"===e.kind)break;if("action_request"===e.kind||"action_request"===e.type){if(console.log("[MCPClient] *** RECEIVED action_request ***",e.action_name,e.parameters),p.log("[MCPClient] Received action_request:",e.action_name,e.parameters),!e.action_name||"string"!=typeof e.action_name||""===e.action_name.trim()){console.error("[MCPClient] action_request INVALID - missing action_name:",e),p.error("[MCPClient] Received action_request with missing or invalid action_name:",e);continue}if(t.onActionRequest){console.log("[MCPClient] *** CALLING onActionRequest handler ***"),e.tool_call_id||(console.warn("[MCPClient] action_request missing tool_call_id - result correlation may fail"),p.warn("[MCPClient] action_request missing tool_call_id for action:",e.action_name));const n={action_name:e.action_name,parameters:e.parameters||{},action:e.action,tool_call_id:e.tool_call_id};t.onActionRequest(n).catch(e=>{console.error("[MCPClient] Action request handler FAILED:",e),p.error("[MCPClient] Action request handler failed:",e)})}else console.warn("[MCPClient] action_request received but NO HANDLER registered"),p.warn("[MCPClient] Received action_request but no handler registered")}else t.onProgress?.({kind:e.kind,id:e.id,label:e.label,status:e.status,text:e.text||e.content,children:e.children,message:e.message,progress_id:e.progress_id,metadata:{sources:e.sources||e.metadata?.sources,result_count:e.result_count??e.metadata?.result_count,query:e.query||e.metadata?.query,action_name:e.action_name||e.metadata?.action_name,no_sources_used:e.no_sources_used??e.metadata?.no_sources_used}})}}}if(r.result&&r.id===a){f=r.result,f.structuredContent?.sources&&t.onSources?.(f.structuredContent.sources),f.structuredContent?.actions&&t.onActions?.(f.structuredContent.actions),f.structuredContent?.registered_actions&&t.onRegisteredActions?.(f.structuredContent.registered_actions);const e=f._meta?.conversation_id,n=f._meta?.query_log_id;t.onComplete?.(e,n)}}}catch(n){p.error("[MCPClient] Failed to parse event:",n,e)}}}catch(e){if("AbortError"===e.name)throw e;const n=e instanceof Error?e.message:"Stream reading failed";throw t.onProgress?.({kind:"error",id:"stream-error",label:"Connection interrupted",status:"error",text:n,metadata:{error:n}}),t.onError?.(n),e}finally{d.releaseLock();const n=Math.round(performance.now()-i);o.add({event:"network:stream:complete",data:{duration:n,tool:e},source:"network",level:"info"})}return f||(f={content:[{type:"text",text:g.join("")}],isError:!1}),f}async uploadImage(e){const n=`${this.config.apiBaseUrl}/mcp/upload-image/`,t=new FormData;t.append("image",e);const r=await fetch(n,{method:"POST",headers:{"x-customer-id":this.config.productKey},body:t});if(!r.ok){const e=await r.json().catch(()=>({error:"Upload failed"}));throw new Error(e.error||"Upload failed")}return r.json()}async ask(e,n,t){const r={query:e};return t?.conversationId&&(r.conversation_id=t.conversationId),t?.articleSlug&&(r.article_slug=t.articleSlug),t?.userContext&&t.userContext.length>0&&(r.user_context=t.userContext),t?.images&&t.images.length>0&&(r.images=t.images),t?.history&&t.history.length>0&&(r.history=t.history),t?.registeredActions&&t.registeredActions.length>0&&(r.registered_actions=t.registeredActions),this.callToolStream("ask",r,n,t?.signal)}async cancelStream(e){const n={jsonrpc:"2.0",id:this.nextId(),method:"notifications/cancel",params:{request_id:e}};p.log(`[MCPClient] Cancelling stream request_id=${e}`);try{await fetch(this.baseUrl,{method:"POST",headers:this.headers,body:JSON.stringify(n),keepalive:!0})}catch(e){p.warn("[MCPClient] Failed to send cancel request:",e)}}async sendActionResult(e,n,t){const r=performance.now();t||(console.warn(`[MCPClient] sendActionResult called without toolCallId for action "${e}" - server will not be able to correlate result`),p.warn("[MCPClient] Missing toolCallId in sendActionResult for:",e));const i={jsonrpc:"2.0",id:this.nextId(),method:"action/result",params:{action_name:e,result:n,tool_call_id:t}};o.add({event:"network:request",data:{method:"action/result",action:e,tool_call_id:t,url:this.baseUrl},source:"network",level:"info"});try{p.log(`[MCPClient] Sending action result for "${e}"...`),await new Promise(e=>setTimeout(e,0));const n=await fetch(this.baseUrl,{method:"POST",headers:this.headers,body:JSON.stringify(i),keepalive:!0}),t=Math.round(performance.now()-r);if(!n.ok){const r=await n.text().catch(()=>"");throw o.add({event:"network:response",data:{status:n.status,duration:t,action:e,error:r},source:"network",level:"error"}),p.error(`[MCPClient] Action result delivery failed: ${n.status} ${n.statusText}`,r),new Error(`Failed to send action result: ${n.status}`)}o.add({event:"network:response",data:{status:n.status,duration:t,action:e},source:"network",level:"info"}),p.log(`[MCPClient] Action result for "${e}" delivered in ${t}ms`)}catch(n){const t=Math.round(performance.now()-r);throw p.error(`[MCPClient] Failed to send action result for "${e}" after ${t}ms:`,n),n}}async sendLog(e,n,t){const r={jsonrpc:"2.0",id:this.nextId(),method:"client/log",params:{level:e,message:n,data:t,timestamp:(new Date).toISOString()}};try{fetch(this.baseUrl,{method:"POST",headers:this.headers,body:JSON.stringify(r),keepalive:!0}).catch(()=>{})}catch{}}sendLogBatch(e){if(0===e.length)return;const n={jsonrpc:"2.0",id:this.nextId(),method:"client/log-batch",params:{logs:e}};try{fetch(this.baseUrl,{method:"POST",headers:this.headers,body:JSON.stringify(n),keepalive:!0}).catch(()=>{})}catch{}}async getConversationStatus(e){try{const n=await fetch(`${this.baseUrl}conversations/${e}/status/`,{method:"GET",headers:this.headers});if(!n.ok)return p.warn(`[MCPClient] Failed to get conversation status: ${n.status}`),null;return await n.json()}catch(e){return p.warn("[MCPClient] Error getting conversation status:",e),null}}async resumeConversation(e,n,t){try{const r=await fetch(`${this.baseUrl}conversations/${e}/resume/`,{method:"POST",headers:{...this.headers,Accept:"text/event-stream"},body:JSON.stringify({user_context:n})});if(!r.ok)return void t.onError?.(`Failed to resume conversation: ${r.status}`);if(!r.body)return void t.onError?.("No response body for resume stream");const i=r.body.getReader(),a=new TextDecoder;let l="";try{for(;;){const{done:e,value:n}=await i.read();if(e)break;l+=a.decode(n,{stream:!0});const r=l.split("\n");l=r.pop()||"";for(const e of r)if(e.startsWith("data: ")){const n=e.slice(6);if(n.trim())try{const e=JSON.parse(n);this.handleResumeStreamEvent(e,t)}catch{}}}}finally{i.releaseLock()}t.onComplete?.()}catch(e){t.onError?.(`Resume error: ${e}`)}}handleResumeStreamEvent(e,n){if("method"in e&&"notifications/progress"===e.method){const t=e.params?.progress;if(!t)return;const r=t.kind;return void("token"===r?n.onToken?.(t.token):"token_usage"===r?n.onTokenUsage?.({prompt_tokens:t.prompt_tokens,completion_tokens:t.completion_tokens,total_prompt_tokens:t.total_prompt_tokens,total_completion_tokens:t.total_completion_tokens,total_used:t.total_used,context_window:t.context_window,occupancy_pct:t.occupancy_pct,model_name:t.model_name,iteration:t.iteration}):"action_request"===r?n.onActionRequest?.({action_name:t.action_name,parameters:t.parameters,action:t.action,tool_call_id:t.tool_call_id}):n.onProgress?.({kind:r,id:t.id,label:t.label,status:t.status,text:t.text}))}if("result"in e){const t=e.result;t.structuredContent?.registered_actions&&n.onRegisteredActions?.(t.structuredContent.registered_actions),t.structuredContent?.sources&&n.onSources?.(t.structuredContent.sources),t.structuredContent?.actions&&n.onActions?.(t.structuredContent.actions)}"error"in e&&e.error&&n.onError?.(e.error.message)}}function S(e){return{id:e.id,name:e.name,taskType:e.action_type,data:e.data,autoRun:e.auto_run,autoComplete:e.auto_complete}}class C{constructor(e){this.abortControllers=new Map,this._externalUserId=null,this.config=e,this.mcpClient=new k(e)}get mcp(){return this.mcpClient}get baseUrl(){return`${this.config.apiBaseUrl}/api/v1/help-center`}setExternalUserId(e){this._externalUserId=e,this.mcpClient.setExternalUserId(e)}clearExternalUserId(){this._externalUserId=null,this.mcpClient.setExternalUserId("")}getVisitorId(){if("undefined"==typeof window)return"";const e="pillar_visitor_id";try{let n=localStorage.getItem(e);return n||(n=crypto.randomUUID(),localStorage.setItem(e,n)),n}catch{return""}}getSessionId(){if("undefined"==typeof window)return"";const e="pillar_session_id";try{let n=sessionStorage.getItem(e);return n||(n=crypto.randomUUID(),sessionStorage.setItem(e,n)),n}catch{return""}}getPageUrl(){return"undefined"==typeof window?"":window.location.href}get headers(){const e={"Content-Type":"application/json","x-customer-id":this.config.productKey,"x-visitor-id":this.getVisitorId(),"x-session-id":this.getSessionId(),"x-page-url":this.getPageUrl()};return this._externalUserId&&(e["x-external-user-id"]=this._externalUserId),this.config.platform&&(e["X-Pillar-Platform"]=this.config.platform),this.config.version&&(e["X-Pillar-Action-Version"]=this.config.version),e}async fetch(e,n={},t){if(t){this.abortControllers.get(t)?.abort();const e=new AbortController;this.abortControllers.set(t,e),n.signal=e.signal}const r=`${this.baseUrl}${e}`;try{const e=await fetch(r,{...n,headers:{...this.headers,...n.headers}});if(!e.ok){const n=await e.json().catch(()=>({}));throw new Error(n.detail||n.message||`API error: ${e.status}`)}return e.json()}catch(n){if("AbortError"===n.name)throw n;throw p.error(`[Pillar API] Error fetching ${e}:`,n),n}finally{t&&this.abortControllers.delete(t)}}async fetchEmbedConfig(){try{const e=await fetch(`${this.config.apiBaseUrl}/api/public/products/${this.config.productKey}/embed-config/`,{method:"GET",headers:{"Content-Type":"application/json"}});return e.ok?await e.json():(p.warn("[Pillar] Failed to fetch embed config:",e.status),null)}catch(e){return p.warn("[Pillar] Failed to fetch embed config:",e),null}}async getSuggestedQuestions(){try{const e=await this.mcpClient.callTool("suggest_questions",{}),n=e.structuredContent?.questions;return Array.isArray(n)?n:[]}catch(e){return p.warn("[Pillar] Failed to get suggested questions:",e),[]}}async uploadImage(e){return this.mcpClient.uploadImage(e)}async chat(e,n=[],t,r,i,a,l,o,s,c,d,u,h){let g="",f=[],m=[];const{getRegisteredActions:b,setRegisteredActions:v,updateTokenUsage:_}=await Promise.resolve().then(function(){return lr});try{const x=await this.mcpClient.ask(e,{onToken:e=>{g+=e,t?.(e)},onSources:e=>{f=e},onActions:e=>{m=e.map(S),a?.(m)},onProgress:e=>{s?.(e)},onConversationStarted:(e,n)=>{c?.(e,n)},onActionRequest:async e=>{d&&await d(e)},onRegisteredActions:e=>{v(e),p.log("[Pillar API] Stored",e.length,"registered actions for dynamic tool calling")},onRequestId:e=>{h?.(e)},onTokenUsage:e=>{_({promptTokens:e.prompt_tokens,completionTokens:e.completion_tokens,totalPromptTokens:e.total_prompt_tokens,totalCompletionTokens:e.total_completion_tokens,totalUsed:e.total_used,contextWindow:e.context_window,occupancyPct:e.occupancy_pct,modelName:e.model_name,iteration:e.iteration})},onError:e=>{p.error("[Pillar API] MCP chat error:",e)}},{articleSlug:r,userContext:l,images:o,history:n,registeredActions:b(),conversationId:i||void 0,signal:u});g||"text"!==x.content[0]?.type||(g=x.content[0].text||"");const y=x._meta||{};return{message:g,sources:f,actions:m,conversationId:y.conversation_id,messageId:y.query_log_id}}catch(e){throw p.error("[Pillar API] Chat error:",e),e}}async chatLegacy(e,n=[],t,r,i){const a=`${this.baseUrl}/ai/chat/`,l=await fetch(a,{method:"POST",headers:this.headers,body:JSON.stringify({message:e,history:n,...r&&{article_slug:r},...i&&{conversation_id:i}})});if(!l.ok){const e=await l.json().catch(()=>({}));throw new Error(e.detail||e.message||`Chat error: ${l.status}`)}if(t&&l.headers.get("content-type")?.includes("text/event-stream"))return this.handleStreamingChat(l,t);const o=await l.json();return{message:o.answer||o.message,sources:o.sources,workflow:o.workflow||o.structuredContent?.workflow,conversationId:o.conversation_id,messageId:o.message_id}}async handleStreamingChat(e,n){const t=e.body?.getReader();if(!t)throw new Error("No response body");const r=new TextDecoder;let i,a,l,o="",s=[];try{for(;;){const{done:e,value:c}=await t.read();if(e)break;const p=r.decode(c,{stream:!0}).split("\n");for(const e of p)if(e.startsWith("data: ")){const t=e.slice(6);if("[DONE]"===t)continue;try{const e=JSON.parse(t);e.content&&(o+=e.content,n(e.content)),e.sources&&(s=e.sources),e.workflow&&(i=e.workflow),e.structuredContent?.workflow&&(i=e.structuredContent.workflow),e.conversation_id&&(a=e.conversation_id),e.message_id&&(l=e.message_id)}catch{o+=t,n(t)}}}}finally{t.releaseLock()}return{message:o,sources:s,workflow:i,conversationId:a,messageId:l}}async submitFeedback(e,n,t){try{await this.fetch("/ai/feedback/",{method:"POST",body:JSON.stringify({message_id:e,feedback:n,...t&&{comment:t}})})}catch(e){p.warn("[Pillar] Feedback submission failed:",e)}}async confirmTaskExecution(e,n,t){try{const r={status:n,error:t?.error,duration_ms:t?.duration_ms,session_id:t?.session_id,conversation_id:t?.conversation_id,metadata:t};await this.fetch(`/tasks/${e}/confirm/`,{method:"POST",body:JSON.stringify(r)})}catch(e){p.warn("[Pillar] Failed to confirm task execution:",e)}}async getSuggestions(e,n){try{return(await this.fetch("/suggestions/",{method:"POST",body:JSON.stringify({context:e,user_profile:n})})).suggestions||[]}catch(e){return p.warn("[Pillar] Failed to get suggestions:",e),[]}}async chatWithContext(e,n=[],t,r,i,a,l){let o="",s=[],c=[];try{const n=await this.mcpClient.callToolStream("ask",{query:e,context:{product:t,user_profile:r},...a&&{conversation_id:a}},{onToken:e=>{o+=e,i?.(e)},onSources:e=>{s=e},onActions:e=>{c=e.map(S),l?.(c)},onError:e=>{p.error("[Pillar API] MCP chat with context error:",e)}});o||"text"!==n.content[0]?.type||(o=n.content[0].text||"");const d=n._meta||{};return{message:o,sources:s,actions:c,conversationId:d.conversation_id,messageId:d.query_log_id}}catch(e){throw p.error("[Pillar API] Chat with context error:",e),e}}async identify(e,n){const t=`${this.config.apiBaseUrl}/mcp/identify/`,r=await fetch(t,{method:"POST",headers:this.headers,body:JSON.stringify({userId:e,name:n?.name,email:n?.email,metadata:n?.metadata})});if(!r.ok){const e=await r.json().catch(()=>({}));throw new Error(e.error||`Identify failed: ${r.status}`)}}async listConversations(e=20){const n=`${this.config.apiBaseUrl}/mcp/conversations/?limit=${Math.min(e,50)}`;try{const e=await fetch(n,{method:"GET",headers:this.headers});if(!e.ok){const n=await e.json().catch(()=>({}));throw new Error(n.error||`Failed to list conversations: ${e.status}`)}return(await e.json()).conversations||[]}catch(e){return p.warn("[Pillar] Failed to list conversations:",e),[]}}async getConversation(e){const n=`${this.config.apiBaseUrl}/mcp/conversations/${e}/`;try{const e=await fetch(n,{method:"GET",headers:this.headers});if(!e.ok){const n=await e.json().catch(()=>({}));throw new Error(n.error||`Failed to get conversation: ${e.status}`)}return await e.json()}catch(e){return p.warn("[Pillar] Failed to get conversation:",e),null}}cancelAllRequests(){this.abortControllers.forEach(e=>e.abort()),this.abortControllers.clear()}}var P,E,T,I,$,M,A,z,R,L,O,D,H,U={},j=[],q=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,B=Array.isArray;function N(e,n){for(var t in n)e[t]=n[t];return e}function F(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function W(e,n,t){var r,i,a,l={};for(a in n)"key"==a?r=n[a]:"ref"==a?i=n[a]:l[a]=n[a];if(arguments.length>2&&(l.children=arguments.length>3?P.call(arguments,2):t),"function"==typeof e&&null!=e.defaultProps)for(a in e.defaultProps)void 0===l[a]&&(l[a]=e.defaultProps[a]);return K(e,l,r,i,null)}function K(e,n,t,r,i){var a={type:e,props:n,key:t,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:null==i?++T:i,__i:-1,__u:0};return null==i&&null!=E.vnode&&E.vnode(a),a}function V(e){return e.children}function G(e,n){this.props=e,this.context=n}function Z(e,n){if(null==n)return e.__?Z(e.__,e.__i+1):null;for(var t;n<e.__k.length;n++)if(null!=(t=e.__k[n])&&null!=t.__e)return t.__e;return"function"==typeof e.type?Z(e):null}function Q(e){var n,t;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,n=0;n<e.__k.length;n++)if(null!=(t=e.__k[n])&&null!=t.__e){e.__e=e.__c.base=t.__e;break}return Q(e)}}function J(e){(!e.__d&&(e.__d=!0)&&$.push(e)&&!Y.__r++||M!=E.debounceRendering)&&((M=E.debounceRendering)||A)(Y)}function Y(){for(var e,n,t,r,i,a,l,o=1;$.length;)$.length>o&&$.sort(z),e=$.shift(),o=$.length,e.__d&&(t=void 0,r=void 0,i=(r=(n=e).__v).__e,a=[],l=[],n.__P&&((t=N({},r)).__v=r.__v+1,E.vnode&&E.vnode(t),ae(n.__P,t,r,n.__n,n.__P.namespaceURI,32&r.__u?[i]:null,a,null==i?Z(r):i,!!(32&r.__u),l),t.__v=r.__v,t.__.__k[t.__i]=t,oe(a,t,l),r.__e=r.__=null,t.__e!=i&&Q(t)));Y.__r=0}function X(e,n,t,r,i,a,l,o,s,c,p){var d,u,h,g,f,m,b,v=r&&r.__k||j,_=n.length;for(s=function(e,n,t,r,i){var a,l,o,s,c,p=t.length,d=p,u=0;for(e.__k=new Array(i),a=0;a<i;a++)null!=(l=n[a])&&"boolean"!=typeof l&&"function"!=typeof l?("string"==typeof l||"number"==typeof l||"bigint"==typeof l||l.constructor==String?l=e.__k[a]=K(null,l,null,null,null):B(l)?l=e.__k[a]=K(V,{children:l},null,null,null):void 0===l.constructor&&l.__b>0?l=e.__k[a]=K(l.type,l.props,l.key,l.ref?l.ref:null,l.__v):e.__k[a]=l,s=a+u,l.__=e,l.__b=e.__b+1,o=null,-1!=(c=l.__i=ne(l,t,s,d))&&(d--,(o=t[c])&&(o.__u|=2)),null==o||null==o.__v?(-1==c&&(i>p?u--:i<p&&u++),"function"!=typeof l.type&&(l.__u|=4)):c!=s&&(c==s-1?u--:c==s+1?u++:(c>s?u--:u++,l.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<p;a++)null!=(o=t[a])&&!(2&o.__u)&&(o.__e==r&&(r=Z(o)),pe(o,o));return r}(t,n,v,s,_),d=0;d<_;d++)null!=(h=t.__k[d])&&(u=-1==h.__i?U:v[h.__i]||U,h.__i=d,m=ae(e,h,u,i,a,l,o,s,c,p),g=h.__e,h.ref&&u.ref!=h.ref&&(u.ref&&ce(u.ref,null,h),p.push(h.ref,h.__c||g,h)),null==f&&null!=g&&(f=g),(b=!!(4&h.__u))||u.__k===h.__k?s=ee(h,s,e,b):"function"==typeof h.type&&void 0!==m?s=m:g&&(s=g.nextSibling),h.__u&=-7);return t.__e=f,s}function ee(e,n,t,r){var i,a;if("function"==typeof e.type){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,n=ee(i[a],n,t,r));return n}e.__e!=n&&(r&&(n&&e.type&&!n.parentNode&&(n=Z(e)),t.insertBefore(e.__e,n||null)),n=e.__e);do{n=n&&n.nextSibling}while(null!=n&&8==n.nodeType);return n}function ne(e,n,t,r){var i,a,l,o=e.key,s=e.type,c=n[t],p=null!=c&&!(2&c.__u);if(null===c&&null==o||p&&o==c.key&&s==c.type)return t;if(r>(p?1:0))for(i=t-1,a=t+1;i>=0||a<n.length;)if(null!=(c=n[l=i>=0?i--:a++])&&!(2&c.__u)&&o==c.key&&s==c.type)return l;return-1}function te(e,n,t){"-"==n[0]?e.setProperty(n,null==t?"":t):e[n]=null==t?"":"number"!=typeof t||q.test(n)?t:t+"px"}function re(e,n,t,r,i){var a,l;e:if("style"==n)if("string"==typeof t)e.style.cssText=t;else{if("string"==typeof r&&(e.style.cssText=r=""),r)for(n in r)t&&n in t||te(e.style,n,"");if(t)for(n in t)r&&t[n]==r[n]||te(e.style,n,t[n])}else if("o"==n[0]&&"n"==n[1])a=n!=(n=n.replace(R,"$1")),l=n.toLowerCase(),n=l in e||"onFocusOut"==n||"onFocusIn"==n?l.slice(2):n.slice(2),e.l||(e.l={}),e.l[n+a]=t,t?r?t.u=r.u:(t.u=L,e.addEventListener(n,a?D:O,a)):e.removeEventListener(n,a?D:O,a);else{if("http://www.w3.org/2000/svg"==i)n=n.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=n&&"height"!=n&&"href"!=n&&"list"!=n&&"form"!=n&&"tabIndex"!=n&&"download"!=n&&"rowSpan"!=n&&"colSpan"!=n&&"role"!=n&&"popover"!=n&&n in e)try{e[n]=null==t?"":t;break e}catch(e){}"function"==typeof t||(null==t||!1===t&&"-"!=n[4]?e.removeAttribute(n):e.setAttribute(n,"popover"==n&&1==t?"":t))}}function ie(e){return function(n){if(this.l){var t=this.l[n.type+e];if(null==n.t)n.t=L++;else if(n.t<t.u)return;return t(E.event?E.event(n):n)}}}function ae(e,n,t,r,i,a,l,o,s,c){var p,d,u,h,g,f,m,b,v,_,x,y,w,k,S,C,T,I=n.type;if(void 0!==n.constructor)return null;128&t.__u&&(s=!!(32&t.__u),a=[o=n.__e=t.__e]),(p=E.__b)&&p(n);e:if("function"==typeof I)try{if(b=n.props,v="prototype"in I&&I.prototype.render,_=(p=I.contextType)&&r[p.__c],x=p?_?_.props.value:p.__:r,t.__c?m=(d=n.__c=t.__c).__=d.__E:(v?n.__c=d=new I(b,x):(n.__c=d=new G(b,x),d.constructor=I,d.render=de),_&&_.sub(d),d.state||(d.state={}),d.__n=r,u=d.__d=!0,d.__h=[],d._sb=[]),v&&null==d.__s&&(d.__s=d.state),v&&null!=I.getDerivedStateFromProps&&(d.__s==d.state&&(d.__s=N({},d.__s)),N(d.__s,I.getDerivedStateFromProps(b,d.__s))),h=d.props,g=d.state,d.__v=n,u)v&&null==I.getDerivedStateFromProps&&null!=d.componentWillMount&&d.componentWillMount(),v&&null!=d.componentDidMount&&d.__h.push(d.componentDidMount);else{if(v&&null==I.getDerivedStateFromProps&&b!==h&&null!=d.componentWillReceiveProps&&d.componentWillReceiveProps(b,x),n.__v==t.__v||!d.__e&&null!=d.shouldComponentUpdate&&!1===d.shouldComponentUpdate(b,d.__s,x)){for(n.__v!=t.__v&&(d.props=b,d.state=d.__s,d.__d=!1),n.__e=t.__e,n.__k=t.__k,n.__k.some(function(e){e&&(e.__=n)}),y=0;y<d._sb.length;y++)d.__h.push(d._sb[y]);d._sb=[],d.__h.length&&l.push(d);break e}null!=d.componentWillUpdate&&d.componentWillUpdate(b,d.__s,x),v&&null!=d.componentDidUpdate&&d.__h.push(function(){d.componentDidUpdate(h,g,f)})}if(d.context=x,d.props=b,d.__P=e,d.__e=!1,w=E.__r,k=0,v){for(d.state=d.__s,d.__d=!1,w&&w(n),p=d.render(d.props,d.state,d.context),S=0;S<d._sb.length;S++)d.__h.push(d._sb[S]);d._sb=[]}else do{d.__d=!1,w&&w(n),p=d.render(d.props,d.state,d.context),d.state=d.__s}while(d.__d&&++k<25);d.state=d.__s,null!=d.getChildContext&&(r=N(N({},r),d.getChildContext())),v&&!u&&null!=d.getSnapshotBeforeUpdate&&(f=d.getSnapshotBeforeUpdate(h,g)),C=p,null!=p&&p.type===V&&null==p.key&&(C=se(p.props.children)),o=X(e,B(C)?C:[C],n,t,r,i,a,l,o,s,c),d.base=n.__e,n.__u&=-161,d.__h.length&&l.push(d),m&&(d.__E=d.__=null)}catch(e){if(n.__v=null,s||null!=a)if(e.then){for(n.__u|=s?160:128;o&&8==o.nodeType&&o.nextSibling;)o=o.nextSibling;a[a.indexOf(o)]=null,n.__e=o}else{for(T=a.length;T--;)F(a[T]);le(n)}else n.__e=t.__e,n.__k=t.__k,e.then||le(n);E.__e(e,n,t)}else null==a&&n.__v==t.__v?(n.__k=t.__k,n.__e=t.__e):o=n.__e=function(e,n,t,r,i,a,l,o,s){var c,p,d,u,h,g,f,m=t.props||U,b=n.props,v=n.type;if("svg"==v?i="http://www.w3.org/2000/svg":"math"==v?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),null!=a)for(c=0;c<a.length;c++)if((h=a[c])&&"setAttribute"in h==!!v&&(v?h.localName==v:3==h.nodeType)){e=h,a[c]=null;break}if(null==e){if(null==v)return document.createTextNode(b);e=document.createElementNS(i,v,b.is&&b),o&&(E.__m&&E.__m(n,a),o=!1),a=null}if(null==v)m===b||o&&e.data==b||(e.data=b);else{if(a=a&&P.call(e.childNodes),!o&&null!=a)for(m={},c=0;c<e.attributes.length;c++)m[(h=e.attributes[c]).name]=h.value;for(c in m)if(h=m[c],"children"==c);else if("dangerouslySetInnerHTML"==c)d=h;else if(!(c in b)){if("value"==c&&"defaultValue"in b||"checked"==c&&"defaultChecked"in b)continue;re(e,c,null,h,i)}for(c in b)h=b[c],"children"==c?u=h:"dangerouslySetInnerHTML"==c?p=h:"value"==c?g=h:"checked"==c?f=h:o&&"function"!=typeof h||m[c]===h||re(e,c,h,m[c],i);if(p)o||d&&(p.__html==d.__html||p.__html==e.innerHTML)||(e.innerHTML=p.__html),n.__k=[];else if(d&&(e.innerHTML=""),X("template"==n.type?e.content:e,B(u)?u:[u],n,t,r,"foreignObject"==v?"http://www.w3.org/1999/xhtml":i,a,l,a?a[0]:t.__k&&Z(t,0),o,s),null!=a)for(c=a.length;c--;)F(a[c]);o||(c="value","progress"==v&&null==g?e.removeAttribute("value"):null!=g&&(g!==e[c]||"progress"==v&&!g||"option"==v&&g!=m[c])&&re(e,c,g,m[c],i),c="checked",null!=f&&f!=e[c]&&re(e,c,f,m[c],i))}return e}(t.__e,n,t,r,i,a,l,s,c);return(p=E.diffed)&&p(n),128&n.__u?void 0:o}function le(e){e&&e.__c&&(e.__c.__e=!0),e&&e.__k&&e.__k.forEach(le)}function oe(e,n,t){for(var r=0;r<t.length;r++)ce(t[r],t[++r],t[++r]);E.__c&&E.__c(n,e),e.some(function(n){try{e=n.__h,n.__h=[],e.some(function(e){e.call(n)})}catch(e){E.__e(e,n.__v)}})}function se(e){return"object"!=typeof e||null==e||e.__b&&e.__b>0?e:B(e)?e.map(se):N({},e)}function ce(e,n,t){try{if("function"==typeof e){var r="function"==typeof e.__u;r&&e.__u(),r&&null==n||(e.__u=e(n))}else e.current=n}catch(e){E.__e(e,t)}}function pe(e,n,t){var r,i;if(E.unmount&&E.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||ce(r,null,n)),null!=(r=e.__c)){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){E.__e(e,n)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&pe(r[i],n,t||"function"!=typeof e.type);t||F(e.__e),e.__c=e.__=e.__e=void 0}function de(e,n,t){return this.constructor(e,t)}function ue(e,n,t){var r,i,a;n==document&&(n=document.documentElement),E.__&&E.__(e,n),r=!1?null:n.__k,i=[],a=[],ae(n,e=n.__k=W(V,null,[e]),r||U,U,n.namespaceURI,r?null:n.firstChild?P.call(n.childNodes):null,i,r?r.__e:n.firstChild,false,a),oe(i,e,a)}P=j.slice,E={__e:function(e,n,t,r){for(var i,a,l;n=n.__;)if((i=n.__c)&&!i.__)try{if((a=i.constructor)&&null!=a.getDerivedStateFromError&&(i.setState(a.getDerivedStateFromError(e)),l=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(e,r||{}),l=i.__d),l)return i.__E=i}catch(n){e=n}throw e}},T=0,I=function(e){return null!=e&&void 0===e.constructor},G.prototype.setState=function(e,n){var t;t=null!=this.__s&&this.__s!=this.state?this.__s:this.__s=N({},this.state),"function"==typeof e&&(e=e(N({},t),this.props)),e&&N(t,e),null!=e&&this.__v&&(n&&this._sb.push(n),J(this))},G.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),J(this))},G.prototype.render=V,$=[],A="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,z=function(e,n){return e.__v.__b-n.__v.__b},Y.__r=0,R=/(PointerCapture)$|Capture$/i,L=0,O=ie(!1),D=ie(!0),H=0;var he=0;function ge(e,n,t,r,i,a){n||(n={});var l,o,s=n;if("ref"in s)for(o in s={},n)"ref"==o?l=n[o]:s[o]=n[o];var c={type:e,props:s,key:t,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--he,__i:-1,__u:0,__source:i,__self:a};if("function"==typeof e&&(l=e.defaultProps))for(o in l)void 0===s[o]&&(s[o]=l[o]);return E.vnode&&E.vnode(c),c}var fe,me,be,ve,_e=0,xe=[],ye=E,we=ye.__b,ke=ye.__r,Se=ye.diffed,Ce=ye.__c,Pe=ye.unmount,Ee=ye.__;function Te(e,n){ye.__h&&ye.__h(me,e,_e||n),_e=0;var t=me.__H||(me.__H={__:[],__h:[]});return e>=t.__.length&&t.__.push({}),t.__[e]}function Ie(e){return _e=1,function(e,n){var t=Te(fe++,2);if(t.t=e,!t.__c&&(t.__=[je(void 0,n),function(e){var n=t.__N?t.__N[0]:t.__[0],r=t.t(n,e);n!==r&&(t.__N=[r,t.__[1]],t.__c.setState({}))}],t.__c=me,!me.__f)){var r=function(e,n,r){if(!t.__c.__H)return!0;var a=t.__c.__H.__.filter(function(e){return!!e.__c});if(a.every(function(e){return!e.__N}))return!i||i.call(this,e,n,r);var l=t.__c.props!==e;return a.forEach(function(e){if(e.__N){var n=e.__[0];e.__=e.__N,e.__N=void 0,n!==e.__[0]&&(l=!0)}}),i&&i.call(this,e,n,r)||l};me.__f=!0;var i=me.shouldComponentUpdate,a=me.componentWillUpdate;me.componentWillUpdate=function(e,n,t){if(this.__e){var l=i;i=void 0,r(e,n,t),i=l}a&&a.call(this,e,n,t)},me.shouldComponentUpdate=r}return t.__N||t.__}(je,e)}function $e(e,n){var t=Te(fe++,3);!ye.__s&&Ue(t.__H,n)&&(t.__=e,t.u=n,me.__H.__h.push(t))}function Me(e){return _e=5,Ae(function(){return{current:e}},[])}function Ae(e,n){var t=Te(fe++,7);return Ue(t.__H,n)&&(t.__=e(),t.__H=n,t.__h=e),t.__}function ze(e,n){return _e=8,Ae(function(){return e},n)}function Re(){for(var e;e=xe.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(De),e.__H.__h.forEach(He),e.__H.__h=[]}catch(n){e.__H.__h=[],ye.__e(n,e.__v)}}ye.__b=function(e){me=null,we&&we(e)},ye.__=function(e,n){e&&n.__k&&n.__k.__m&&(e.__m=n.__k.__m),Ee&&Ee(e,n)},ye.__r=function(e){ke&&ke(e),fe=0;var n=(me=e.__c).__H;n&&(be===me?(n.__h=[],me.__h=[],n.__.forEach(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(n.__h.forEach(De),n.__h.forEach(He),n.__h=[],fe=0)),be=me},ye.diffed=function(e){Se&&Se(e);var n=e.__c;n&&n.__H&&(n.__H.__h.length&&(1!==xe.push(n)&&ve===ye.requestAnimationFrame||((ve=ye.requestAnimationFrame)||Oe)(Re)),n.__H.__.forEach(function(e){e.u&&(e.__H=e.u),e.u=void 0})),be=me=null},ye.__c=function(e,n){n.some(function(e){try{e.__h.forEach(De),e.__h=e.__h.filter(function(e){return!e.__||He(e)})}catch(t){n.some(function(e){e.__h&&(e.__h=[])}),n=[],ye.__e(t,e.__v)}}),Ce&&Ce(e,n)},ye.unmount=function(e){Pe&&Pe(e);var n,t=e.__c;t&&t.__H&&(t.__H.__.forEach(function(e){try{De(e)}catch(e){n=e}}),t.__H=void 0,n&&ye.__e(n,t.__v))};var Le="function"==typeof requestAnimationFrame;function Oe(e){var n,t=function(){clearTimeout(r),Le&&cancelAnimationFrame(n),setTimeout(e)},r=setTimeout(t,35);Le&&(n=requestAnimationFrame(t))}function De(e){var n=me,t=e.__c;"function"==typeof t&&(e.__c=void 0,t()),me=n}function He(e){var n=me;e.__c=e.__(),me=n}function Ue(e,n){return!e||e.length!==n.length||n.some(function(n,t){return n!==e[t]})}function je(e,n){return"function"==typeof n?n(e):n}var qe=Symbol.for("preact-signals");function Be(){if(Ge>1)Ge--;else{for(var e,n=!1;void 0!==Ve;){var t=Ve;for(Ve=void 0,Ze++;void 0!==t;){var r=t.o;if(t.o=void 0,t.f&=-3,!(8&t.f)&&en(t))try{t.c()}catch(t){n||(e=t,n=!0)}t=r}}if(Ze=0,Ge--,n)throw e}}var Ne=void 0;function Fe(e){var n=Ne;Ne=void 0;try{return e()}finally{Ne=n}}var We,Ke,Ve=void 0,Ge=0,Ze=0,Qe=0;function Je(e){if(void 0!==Ne){var n=e.n;if(void 0===n||n.t!==Ne)return n={i:0,S:e,p:Ne.s,n:void 0,t:Ne,e:void 0,x:void 0,r:n},void 0!==Ne.s&&(Ne.s.n=n),Ne.s=n,e.n=n,32&Ne.f&&e.S(n),n;if(-1===n.i)return n.i=0,void 0!==n.n&&(n.n.p=n.p,void 0!==n.p&&(n.p.n=n.n),n.p=Ne.s,n.n=void 0,Ne.s.n=n,Ne.s=n),n}}function Ye(e,n){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.W=null==n?void 0:n.watched,this.Z=null==n?void 0:n.unwatched,this.name=null==n?void 0:n.name}function Xe(e,n){return new Ye(e,n)}function en(e){for(var n=e.s;void 0!==n;n=n.n)if(n.S.i!==n.i||!n.S.h()||n.S.i!==n.i)return!0;return!1}function nn(e){for(var n=e.s;void 0!==n;n=n.n){var t=n.S.n;if(void 0!==t&&(n.r=t),n.S.n=n,n.i=-1,void 0===n.n){e.s=n;break}}}function tn(e){for(var n=e.s,t=void 0;void 0!==n;){var r=n.p;-1===n.i?(n.S.U(n),void 0!==r&&(r.n=n.n),void 0!==n.n&&(n.n.p=r)):t=n,n.S.n=n.r,void 0!==n.r&&(n.r=void 0),n=r}e.s=t}function rn(e,n){Ye.call(this,void 0),this.x=e,this.s=void 0,this.g=Qe-1,this.f=4,this.W=null==n?void 0:n.watched,this.Z=null==n?void 0:n.unwatched,this.name=null==n?void 0:n.name}function an(e,n){return new rn(e,n)}function ln(e){var n=e.u;if(e.u=void 0,"function"==typeof n){Ge++;var t=Ne;Ne=void 0;try{n()}catch(n){throw e.f&=-2,e.f|=8,on(e),n}finally{Ne=t,Be()}}}function on(e){for(var n=e.s;void 0!==n;n=n.n)n.S.U(n);e.x=void 0,e.s=void 0,ln(e)}function sn(e){if(Ne!==this)throw new Error("Out-of-order effect");tn(this),Ne=e,this.f&=-2,8&this.f&&on(this),Be()}function cn(e,n){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==n?void 0:n.name}function pn(e,n){var t=new cn(e,n);try{t.c()}catch(e){throw t.d(),e}var r=t.d.bind(t);return r[Symbol.dispose]=r,r}function dn(e,n){E[e]=n.bind(null,E[e]||function(){})}function un(e){Ke&&Ke(),Ke=e&&e.S()}function hn(e){var n=this,t=e.data,r=function(e){return Ae(function(){return Xe(e)},[])}(t);r.value=t;var i=Ae(function(){for(var e=n.__v;e=e.__;)if(e.__c){e.__c.__$f|=4;break}return n.__$u.c=function(){var e,t=n.__$u.S(),r=i.value;t(),I(r)||3!==(null==(e=n.base)?void 0:e.nodeType)?(n.__$f|=1,n.setState({})):n.base.data=r},an(function(){var e=r.value.value;return 0===e?0:!0===e?"":e||""})},[]);return i.value}function gn(e,n,t,r){var i=n in e&&void 0===e.ownerSVGElement,a=Xe(t);return{o:function(e,n){a.value=e,r=n},d:pn(function(){var t=a.value.value;r[n]!==t&&(r[n]=t,i?e[n]=t:t?e.setAttribute(n,t):e.removeAttribute(n))})}}function fn(e){var n=Me(e);return n.current=e,We.__$f|=4,Ae(function(){return an(function(){return n.current()})},[])}Ye.prototype.brand=qe,Ye.prototype.h=function(){return!0},Ye.prototype.S=function(e){var n=this,t=this.t;t!==e&&void 0===e.e&&(e.x=t,this.t=e,void 0!==t?t.e=e:Fe(function(){var e;null==(e=n.W)||e.call(n)}))},Ye.prototype.U=function(e){var n=this;if(void 0!==this.t){var t=e.e,r=e.x;void 0!==t&&(t.x=r,e.e=void 0),void 0!==r&&(r.e=t,e.x=void 0),e===this.t&&(this.t=r,void 0===r&&Fe(function(){var e;null==(e=n.Z)||e.call(n)}))}},Ye.prototype.subscribe=function(e){var n=this;return pn(function(){var t=n.value,r=Ne;Ne=void 0;try{e(t)}finally{Ne=r}},{name:"sub"})},Ye.prototype.valueOf=function(){return this.value},Ye.prototype.toString=function(){return this.value+""},Ye.prototype.toJSON=function(){return this.value},Ye.prototype.peek=function(){var e=Ne;Ne=void 0;try{return this.value}finally{Ne=e}},Object.defineProperty(Ye.prototype,"value",{get:function(){var e=Je(this);return void 0!==e&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Ze>100)throw new Error("Cycle detected");this.v=e,this.i++,Qe++,Ge++;try{for(var n=this.t;void 0!==n;n=n.x)n.t.N()}finally{Be()}}}}),rn.prototype=new Ye,rn.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===Qe)return!0;if(this.g=Qe,this.f|=1,this.i>0&&!en(this))return this.f&=-2,!0;var e=Ne;try{nn(this),Ne=this;var n=this.x();(16&this.f||this.v!==n||0===this.i)&&(this.v=n,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return Ne=e,tn(this),this.f&=-2,!0},rn.prototype.S=function(e){if(void 0===this.t){this.f|=36;for(var n=this.s;void 0!==n;n=n.n)n.S.S(n)}Ye.prototype.S.call(this,e)},rn.prototype.U=function(e){if(void 0!==this.t&&(Ye.prototype.U.call(this,e),void 0===this.t)){this.f&=-33;for(var n=this.s;void 0!==n;n=n.n)n.S.U(n)}},rn.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;void 0!==e;e=e.x)e.t.N()}},Object.defineProperty(rn.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Je(this);if(this.h(),void 0!==e&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),cn.prototype.c=function(){var e=this.S();try{if(8&this.f)return;if(void 0===this.x)return;var n=this.x();"function"==typeof n&&(this.u=n)}finally{e()}},cn.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,ln(this),nn(this),Ge++;var e=Ne;return Ne=this,sn.bind(this,e)},cn.prototype.N=function(){2&this.f||(this.f|=2,this.o=Ve,Ve=this)},cn.prototype.d=function(){this.f|=8,1&this.f||on(this)},cn.prototype.dispose=function(){this.d()},hn.displayName="_st",Object.defineProperties(Ye.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:hn},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}}),dn("__b",function(e,n){if("string"==typeof n.type){var t,r=n.props;for(var i in r)if("children"!==i){var a=r[i];a instanceof Ye&&(t||(n.__np=t={}),t[i]=a,r[i]=a.peek())}}e(n)}),dn("__r",function(e,n){un();var t,r=n.__c;r&&(r.__$f&=-2,void 0===(t=r.__$u)&&(r.__$u=t=function(){var e;return pn(function(){e=this}),e.c=function(){r.__$f|=1,r.setState({})},e}())),We=r,un(t),e(n)}),dn("__e",function(e,n,t,r){un(),We=void 0,e(n,t,r)}),dn("diffed",function(e,n){var t;if(un(),We=void 0,"string"==typeof n.type&&(t=n.__e)){var r=n.__np,i=n.props;if(r){var a=t.U;if(a)for(var l in a){var o=a[l];void 0===o||l in r||(o.d(),a[l]=void 0)}else t.U=a={};for(var s in r){var c=a[s],p=r[s];void 0===c?(c=gn(t,s,p,i),a[s]=c):c.o(p,i)}}}e(n)}),dn("unmount",function(e,n){if("string"==typeof n.type){var t=n.__e;if(t){var r=t.U;if(r)for(var i in t.U=void 0,r){var a=r[i];a&&a.d()}}}else{var l=n.__c;if(l){var o=l.__$u;o&&(l.__$u=void 0,o.d())}}e(n)}),dn("__h",function(e,n,t,r){(r<3||9===r)&&(n.__$f|=2),e(n,t,r)}),G.prototype.shouldComponentUpdate=function(e,n){var t=this.__$u,r=t&&void 0!==t.s;for(var i in n)return!0;if(this.__f||"boolean"==typeof this.u&&!0===this.u){if(!(r||2&this.__$f||4&this.__$f))return!0;if(1&this.__$f)return!0}else{if(!(r||4&this.__$f))return!0;if(3&this.__$f)return!0}for(var a in e)if("__source"!==a&&e[a]!==this.props[a])return!0;for(var l in this.props)if(!(l in e))return!0;return!1};const mn="pillar:panel_open";function bn(e){if("undefined"!=typeof window)try{localStorage.setItem(mn,String(e))}catch{}}const vn=Xe(function(){if("undefined"==typeof window)return!1;try{return"true"===localStorage.getItem(mn)}catch{return!1}}()),_n=Xe("assistant"),xn=Xe("right"),yn=Xe("overlay"),wn=Xe(380),kn=Xe(1200),Sn=Xe(!0),Cn=Xe(700),Pn=Xe(500),En=Xe("undefined"!=typeof window?window.innerWidth:1920);let Tn=null;const In=an(()=>{const e=kn.value;return!1!==e&&En.value<e}),$n=an(()=>En.value<Cn.value),Mn=an(()=>En.value<Pn.value),An=an(()=>In.value?"overlay":yn.value);an(()=>{const e=["pillar-panel",`pillar-panel--${xn.value}`];return vn.value&&e.push("pillar-panel--open"),e.join(" ")});const zn=()=>{vn.value=!1,bn(!1),"overlay"===An.value&&(document.body.style.overflow="")},Rn=()=>{vn.value=!1,bn(!1),_n.value="assistant",document.body.style.overflow=""};function Ln(e,n,t){const r=document.createElement("style");return t&&(r.id=t),r.textContent=n,e instanceof Document?e.head.appendChild(r):e.appendChild(r),r}const On={help:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"></path><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>',support:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 18v-6a9 9 0 0 1 18 0v6"></path><path d="M21 19a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3zM3 19a2 2 0 0 0 2 2h1a2 2 0 0 0 2-2v-3a2 2 0 0 0-2-2H3z"></path></svg>',settings:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"></path><circle cx="12" cy="12" r="3"></circle></svg>',feedback:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path></svg>',chat:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"></path></svg>',calendar:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line></svg>',mail:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path><polyline points="22,6 12,13 2,6"></polyline></svg>'},Dn={assistant:On.help,support:On.support};function Hn({position:e,tabs:n,currentActiveTab:t,onTabClick:r,panelOpen:i,panelWidthPx:a,theme:l}){const o=ze(e=>{r(e)},[r]),s=["pillar-edge-sidebar",`pillar-edge-sidebar--${e}`,"pillar-edge-sidebar--mounted",i&&"pillar-edge-sidebar--panel-open","light"===l&&"pillar-edge-sidebar--light","dark"===l&&"pillar-edge-sidebar--dark"].filter(Boolean).join(" "),c={"--pillar-panel-width":`${a}px`},p=n.filter(e=>e.enabled).sort((e,n)=>e.order-n.order);return ge("div",{class:s,style:c,children:p.map(e=>{return ge("button",{class:["pillar-edge-trigger",i&&t===e.id&&"pillar-edge-trigger--active"].filter(Boolean).join(" "),onClick:()=>o(e.id),"aria-label":e.label||"Help",type:"button",children:[ge("span",{class:"pillar-edge-trigger__icon",dangerouslySetInnerHTML:{__html:(n=e.id,r=e.icon,r&&r in On?On[r]:Dn[n]||On.help)}}),ge("span",{class:"pillar-edge-trigger__label",children:e.label})]},e.id);var n,r})})}class Un{constructor(e,n,t,r){this.container=null,this.stylesInjected=!1,this.themeStylesInjected=!1,this._isHidden=!1,this.unsubscribeOpen=null,this.unsubscribeWidth=null,this.unsubscribeHoverMode=null,this.unsubscribeMobileMode=null,this.unsubscribeActiveTab=null,this.themeObserver=null,this.currentTheme="light",this.handleTabClick=e=>{if("assistant"!==e){const n=this.config.sidebarTabs.find(n=>n.id===e);return this.events.emit("sidebar:click",{tabId:e,label:n?.label||e}),void("support"===e&&this.events.emit("support:request",{tabId:e}))}(e=>{_n.value=e})(e),vn.value||this.onClick(),this.render()},this.config=e,this.events=n,this.onClick=t,this.rootContainer=r||null}getEdgePosition(){return this.config.panel.position}detectTheme(){const e=document.documentElement;if(e.classList.contains("dark"))return"dark";return"dark"===e.getAttribute("data-theme")||"dark"===e.style.colorScheme?"dark":"light"}init(){if(this.stylesInjected||(Ln(document,"\n/* Sidebar container - always visible, shifts when panel opens */\n.pillar-edge-sidebar {\n position: fixed;\n top: 0;\n bottom: 0;\n width: 48px;\n z-index: 100000;\n display: flex;\n flex-direction: column;\n align-items: center;\n background: var(--pillar-bg);\n border-left: 1px solid var(--pillar-border);\n transition: right 0.3s ease, left 0.3s ease;\n}\n\n.pillar-edge-sidebar--right {\n right: 0;\n border-left: 1px solid var(--pillar-border);\n border-right: none;\n}\n\n.pillar-edge-sidebar--left {\n left: 0;\n border-right: 1px solid var(--pillar-border);\n border-left: none;\n}\n\n/* When panel is open, shift the trigger to sit at the panel's outer edge */\n.pillar-edge-sidebar--right.pillar-edge-sidebar--panel-open {\n right: var(--pillar-panel-width, 380px);\n}\n\n.pillar-edge-sidebar--left.pillar-edge-sidebar--panel-open {\n left: var(--pillar-panel-width, 380px);\n}\n\n/* The trigger button - vertical sideways text */\n.pillar-edge-trigger {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 16px 8px;\n margin-top: 8px;\n font-family: var(--pillar-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif);\n font-size: 12px;\n font-weight: 500;\n color: var(--pillar-text-muted);\n background: transparent;\n border: none;\n border-radius: 6px;\n cursor: pointer;\n transition: background 0.15s ease, color 0.15s ease;\n outline: none;\n gap: 8px;\n writing-mode: vertical-rl;\n text-orientation: mixed;\n}\n\n.pillar-edge-trigger:hover {\n background: var(--pillar-bg-secondary);\n color: var(--pillar-primary);\n}\n\n.pillar-edge-trigger--active {\n background: var(--pillar-primary-light, rgba(194, 65, 12, 0.1));\n color: var(--pillar-primary);\n}\n\n.pillar-edge-trigger--active .pillar-edge-trigger__icon {\n opacity: 1;\n color: var(--pillar-primary);\n}\n\n.pillar-edge-trigger:focus-visible {\n background: var(--pillar-bg-secondary);\n box-shadow: 0 0 0 2px var(--pillar-primary);\n}\n\n.pillar-edge-trigger__icon {\n width: 20px;\n height: 20px;\n flex-shrink: 0;\n opacity: 0.8;\n}\n\n.pillar-edge-trigger:hover .pillar-edge-trigger__icon {\n opacity: 1;\n color: var(--pillar-primary);\n}\n\n.pillar-edge-trigger__label {\n white-space: nowrap;\n letter-spacing: 0.5px;\n}\n\n/* Animation on mount */\n@keyframes pillar-sidebar-mount {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n}\n\n.pillar-edge-sidebar--mounted {\n animation: pillar-sidebar-mount 0.2s ease forwards;\n}\n","pillar-edge-trigger-styles"),this.stylesInjected=!0),!this.themeStylesInjected){const e=function(e,n){const t=e=>{const n=[];return e.primary&&n.push(`--pillar-primary: ${e.primary};`),e.primaryHover&&n.push(`--pillar-primary-hover: ${e.primaryHover};`),e.background&&n.push(`--pillar-bg: ${e.background};`),e.backgroundSecondary&&n.push(`--pillar-bg-secondary: ${e.backgroundSecondary};`),e.text&&n.push(`--pillar-text: ${e.text};`),e.textMuted&&n.push(`--pillar-text-muted: ${e.textMuted};`),e.border&&n.push(`--pillar-border: ${e.border};`),e.borderLight&&n.push(`--pillar-border-light: ${e.borderLight};`),n.join("\n ")},r=t(e),i=t(n);let a="";return r&&(a+=`\n.pillar-edge-sidebar,\n.pillar-edge-sidebar--light {\n ${r}\n}\n`),i&&(a+=`\n.pillar-edge-sidebar--dark {\n ${i}\n}\n`),a}(this.config.theme.colors,this.config.theme.darkColors);e&&Ln(document,e,"pillar-edge-trigger-theme"),this.themeStylesInjected=!0}this.container=document.createElement("div"),this.container.id="pillar-edge-trigger-container";(this.rootContainer||document.body).appendChild(this.container),this.currentTheme=this.detectTheme(),this.applyLayoutPadding(),this.render(),this.unsubscribeOpen=vn.subscribe(()=>{this.render(),queueMicrotask(()=>this.applyLayoutPadding())}),this.unsubscribeWidth=wn.subscribe(()=>{this.render(),queueMicrotask(()=>this.applyLayoutPadding())}),this.unsubscribeHoverMode=In.subscribe(()=>{queueMicrotask(()=>this.applyLayoutPadding())}),this.unsubscribeMobileMode=$n.subscribe(e=>{e?this.hide():this.show()}),$n.value&&this.hide(),this.unsubscribeActiveTab=_n.subscribe(()=>{this.render()}),this.themeObserver=new MutationObserver(()=>{const e=this.detectTheme();e!==this.currentTheme&&(this.currentTheme=e,this.render())}),this.themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme","style"]})}applyLayoutPadding(){if(this._isHidden)return;const e=this.getEdgePosition(),n=wn.value,t=In.value;let r=48;vn.value&&!t&&(r=n+48),document.documentElement.style.transition="padding 0.3s ease","right"===e?(document.documentElement.style.paddingRight=`${r}px`,document.documentElement.style.setProperty("--pillar-inset-right",`${r}px`),document.documentElement.style.setProperty("--pillar-inset-left","0px")):(document.documentElement.style.paddingLeft=`${r}px`,document.documentElement.style.setProperty("--pillar-inset-left",`${r}px`),document.documentElement.style.setProperty("--pillar-inset-right","0px"))}removeLayoutPadding(){"right"===this.getEdgePosition()?document.documentElement.style.paddingRight="":document.documentElement.style.paddingLeft="",document.documentElement.style.removeProperty("--pillar-inset-right"),document.documentElement.style.removeProperty("--pillar-inset-left")}setOpen(e){this.render()}show(){this._isHidden=!1,this.container&&(this.container.style.display=""),this.applyLayoutPadding(),this.render()}hide(){this._isHidden=!0,this.container&&(this.container.style.display="none"),this.removeLayoutPadding()}setPosition(e){this.removeLayoutPadding(),this.config.panel.position=e,this.applyLayoutPadding(),this.render()}destroy(){this.unsubscribeOpen?.(),this.unsubscribeOpen=null,this.unsubscribeWidth?.(),this.unsubscribeWidth=null,this.unsubscribeHoverMode?.(),this.unsubscribeHoverMode=null,this.unsubscribeMobileMode?.(),this.unsubscribeMobileMode=null,this.unsubscribeActiveTab?.(),this.unsubscribeActiveTab=null,this.themeObserver?.disconnect(),this.themeObserver=null,this.removeLayoutPadding(),this.container&&(ue(null,this.container),this.container.remove()),this.container=null,document.getElementById("pillar-edge-trigger-styles")?.remove(),document.getElementById("pillar-edge-trigger-theme")?.remove(),this.stylesInjected=!1,this.themeStylesInjected=!1}render(){if(!this.container||this._isHidden)return;ue(ge(Hn,{position:this.getEdgePosition(),tabs:this.config.sidebarTabs,currentActiveTab:_n.value,onTabClick:this.handleTabClick,panelOpen:vn.value,panelWidthPx:wn.value,theme:this.currentTheme}),this.container)}}const jn={sparkle:'<svg viewBox="0 0 16 16" fill="currentColor"><path d="M8.8 8.44L9.497 11l.697-2.56c.175-.643.263-.965.435-1.23a2 2 0 0 1 .583-.583c.263-.172.585-.259 1.23-.435l2.56-.697l-2.56-.697c-.643-.175-.964-.263-1.23-.435a2 2 0 0 1-.583-.583c-.172-.263-.259-.585-.435-1.23L9.497-.01L8.8 2.55c-.175.643-.263.965-.435 1.23a2 2 0 0 1-.583.583c-.263.172-.585.259-1.23.435l-2.56.697l2.56.697c.643.175.965.263 1.23.435a2 2 0 0 1 .583.583c.172.263.259.585.435 1.23M2.68 13.7c.169.244.264.542.456 1.14l.362 1.12l.362-1.12c.191-.595.287-.893.456-1.14c.149-.216.34-.4.561-.543c.249-.161.55-.247 1.15-.418l.971-.277l-.971-.277c-.601-.172-.902-.258-1.15-.418a2 2 0 0 1-.561-.543c-.169-.244-.264-.542-.456-1.14l-.362-1.12l-.362 1.12c-.191.595-.287.893-.456 1.14c-.149.216-.34.4-.561.543c-.249.161-.55.247-1.15.418l-.971.277l.971.277c.601.172.902.258 1.15.418a2 2 0 0 1 .561.543"/></svg>',question:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"></path><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>',help:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"></path><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>',chat:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"></path></svg>',support:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 18v-6a9 9 0 0 1 18 0v6"></path><path d="M21 19a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3zM3 19a2 2 0 0 0 2 2h1a2 2 0 0 0 2-2v-3a2 2 0 0 0-2-2H3z"></path></svg>'},qn={small:44,medium:56,large:68};function Bn({position:e,icon:n,backgroundColor:t,iconColor:r,size:i,label:a,offset:l,panelOpen:o,onClick:s}){const c=ze(()=>{s()},[s]);return ge("button",{class:["pillar-mobile-trigger",`pillar-mobile-trigger--${e}`,"pillar-mobile-trigger--mounted",o&&"pillar-mobile-trigger--hidden"].filter(Boolean).join(" "),style:{"--pillar-mobile-offset":`${l}px`,"--pillar-mobile-bg":t,width:`${i}px`,height:`${i}px`,backgroundColor:t,color:r},onClick:c,"aria-label":a,title:a,type:"button",children:ge("span",{class:"pillar-mobile-trigger__icon",dangerouslySetInnerHTML:{__html:n}})})}class Nn{constructor(e,n,t,r){this.container=null,this.stylesInjected=!1,this._isEnabled=!0,this.unsubscribeMobileMode=null,this.unsubscribeOpen=null,this.config=e,this.events=n,this.onClick=t,this.rootContainer=r||null,this._isEnabled=e.mobileTrigger.enabled}getSize(){const e=this.config.mobileTrigger.size;return"number"==typeof e?e:qn[e]}getIcon(){const{customIcon:e,icon:n}=this.config.mobileTrigger;return e||jn[n]}getBackgroundColor(){const{backgroundColor:e}=this.config.mobileTrigger;return e||(this.config.theme.colors.primary||"#c2410c")}init(){if(!this._isEnabled)return;this.stylesInjected||(Ln(document,"\n/* Mobile trigger floating button */\n.pillar-mobile-trigger {\n position: fixed;\n z-index: 100000;\n display: flex;\n align-items: center;\n justify-content: center;\n border: none;\n border-radius: 50%;\n cursor: pointer;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);\n transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;\n outline: none;\n -webkit-tap-highlight-color: transparent;\n}\n\n.pillar-mobile-trigger:hover {\n transform: scale(1.05);\n box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2), 0 3px 6px rgba(0, 0, 0, 0.12);\n}\n\n.pillar-mobile-trigger:active {\n transform: scale(0.95);\n}\n\n.pillar-mobile-trigger:focus-visible {\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1), 0 0 0 3px rgba(255, 255, 255, 0.5), 0 0 0 5px var(--pillar-mobile-bg, #c2410c);\n}\n\n/* Position variants */\n.pillar-mobile-trigger--bottom-right {\n bottom: var(--pillar-mobile-offset, 24px);\n right: var(--pillar-mobile-offset, 24px);\n}\n\n.pillar-mobile-trigger--bottom-left {\n bottom: var(--pillar-mobile-offset, 24px);\n left: var(--pillar-mobile-offset, 24px);\n}\n\n/* Icon styling */\n.pillar-mobile-trigger__icon {\n width: 55%;\n height: 55%;\n flex-shrink: 0;\n transform: translateY(-1px);\n}\n\n/* Hidden state (when panel is open) */\n.pillar-mobile-trigger--hidden {\n opacity: 0 !important;\n pointer-events: none;\n transform: scale(0.8) !important;\n visibility: hidden;\n}\n\n/* Animation on mount */\n@keyframes pillar-mobile-trigger-mount {\n from {\n opacity: 0;\n transform: scale(0.8);\n }\n to {\n opacity: 1;\n transform: scale(1);\n }\n}\n\n.pillar-mobile-trigger--mounted {\n animation: pillar-mobile-trigger-mount 0.2s ease forwards;\n}\n","pillar-mobile-trigger-styles"),this.stylesInjected=!0),this.container=document.createElement("div"),this.container.id="pillar-mobile-trigger-container";(this.rootContainer||document.body).appendChild(this.container),this.unsubscribeMobileMode=$n.subscribe(()=>{this.render()}),this.unsubscribeOpen=vn.subscribe(()=>{this.render()}),this.render()}show(){this._isEnabled=!0,this.render()}hide(){this._isEnabled=!1,this.render()}get isVisible(){return this._isEnabled&&$n.value&&!vn.value}destroy(){this.unsubscribeMobileMode?.(),this.unsubscribeMobileMode=null,this.unsubscribeOpen?.(),this.unsubscribeOpen=null,this.container&&(ue(null,this.container),this.container.remove()),this.container=null,document.getElementById("pillar-mobile-trigger-styles")?.remove(),this.stylesInjected=!1}render(){if(!this.container)return;if(!this._isEnabled||!$n.value)return void ue(null,this.container);const{position:e,iconColor:n,label:t,offset:r}=this.config.mobileTrigger;ue(ge(Bn,{position:e,icon:this.getIcon(),backgroundColor:this.getBackgroundColor(),iconColor:n,size:this.getSize(),label:t,offset:r,panelOpen:vn.value,onClick:this.onClick}),this.container)}}function Fn(){return`ctx_${Date.now()}_${Math.random().toString(36).substring(2,9)}`}function Wn(e){return"highlighted_text"===e.type}function Kn(e){return"dom_snapshot"===e.type}function Vn(e){return Wn(e)?e.text_content.length>40?e.text_content.substring(0,40)+"...":e.text_content:Kn(e)?`Page scan: ${e.interactableCount} elements`:"Context"}const Gn=Xe([]),Zn=Xe(null),Qn=Xe([]),Jn=Xe(0),Yn=Xe([]),Xn="pillar:conversation_id";function et(e){if("undefined"!=typeof window)try{null===e?localStorage.removeItem(Xn):localStorage.setItem(Xn,e)}catch{}}const nt=Xe(!1),tt=Xe(null),rt=e=>{tt.value=e},it=Xe(!1),at=Xe(null),lt=Xe(null),ot=Xe({kind:null}),st=Xe([]),ct=e=>{const n=Gn.value;if(n.length>0&&"assistant"===n[n.length-1].role){const t=n[n.length-1],r=t.progressEvents||[];let i;const a=e.id||e.progress_id;if(a){const n=r.findIndex(e=>(e.id||e.progress_id)===a);if(n>=0){const t=r[n],a="thinking"===t.kind||"step_start"===t.kind,l="active"===t.status,o="done"===e.status||"error"===e.status,s=t.metadata?._startTime,c=a&&l&&o&&s?{_durationSeconds:Math.round((Date.now()-s)/1e3)}:{},p={...t,...e,id:e.id||t.id,progress_id:e.progress_id||t.progress_id,text:t.text&&e.text?t.text+e.text:e.text??t.text,children:e.children||t.children,metadata:{...t.metadata,...e.metadata,...c}};i=[...r.slice(0,n),p,...r.slice(n+1)]}else{const n=Date.now(),t=r.map(e=>{if(!(("thinking"===e.kind||"step_start"===e.kind)&&"active"===e.status))return e;const t=e.metadata?._startTime,r=t?{_durationSeconds:Math.round((n-t)/1e3)}:{};return{...e,status:"done",metadata:{...e.metadata,...r}}});i=[...t,("thinking"===e.kind||"step_start"===e.kind)&&"active"===e.status?{...e,metadata:{...e.metadata,_startTime:n}}:e]}}else{const n=Date.now(),t=r.map(e=>{if(!(("thinking"===e.kind||"step_start"===e.kind)&&"active"===e.status))return e;const t=e.metadata?._startTime,r=t?{_durationSeconds:Math.round((n-t)/1e3)}:{};return{...e,status:"done",metadata:{...e.metadata,...r}}});i=[...t,("thinking"===e.kind||"step_start"===e.kind)&&"active"===e.status?{...e,metadata:{...e.metadata,_startTime:n}}:e]}const l=[...t.segments||[]],o=e.id&&r.some(n=>n.id===e.id);if(o)for(let n=l.length-1;n>=0;n--){const t=l[n];if("progress"!==t.type)continue;const r=t.events.findIndex(n=>n.id===e.id);if(r>=0){const a=i.find(n=>n.id===e.id);if(a){const e=[...t.events];e[r]=a,l[n]={type:"progress",events:e}}break}}else{const n=e.id?i.find(n=>n.id===e.id):i[i.length-1];if(n){const e=l[l.length-1];e&&"progress"===e.type?l[l.length-1]={type:"progress",events:[...e.events,n]}:l.push({type:"progress",events:[n]})}}Gn.value=[...n.slice(0,-1),{...t,progressEvents:i,segments:l}]}},pt=e=>{const n=Gn.value;if(0===n.length||"assistant"!==n[n.length-1].role)return;const t=n[n.length-1],r=[...t.segments||[]],i=r[r.length-1];i&&"text"===i.type?r[r.length-1]={type:"text",content:i.content+e}:r.push({type:"text",content:e}),Gn.value=[...n.slice(0,-1),{...t,segments:r,content:(t.content||"")+e}]},dt=Xe(!1),ut=Xe([]),ht=Xe([]),gt=Xe(""),ft=Xe(null),mt=Xe(0),bt=Xe(0),vt=Xe([]),_t=Xe([]),xt=Xe([]),yt=an(()=>xt.value.some(e=>"uploading"===e.status)),wt=()=>xt.value.filter(e=>"ready"===e.status&&e.url).map(e=>({url:e.url,detail:"low"})),kt=e=>{xt.value.length>=4||(xt.value=[...xt.value,e])},St=(e,n,t,r)=>{xt.value=xt.value.map(i=>i.id===e?{...i,status:n,url:t,error:r}:i)},Ct=e=>{const n=xt.value.find(n=>n.id===e);n&&URL.revokeObjectURL(n.preview),xt.value=xt.value.filter(n=>n.id!==e)},Pt=()=>{xt.value.forEach(e=>URL.revokeObjectURL(e.preview)),xt.value=[]},Et=an(()=>Gn.value.length>0),Tt=(e,n,t)=>{Gn.value=[...Gn.value,{role:"user",content:e,userContext:n&&n.length>0?n:void 0,images:t&&t.length>0?t:void 0}]},It=(e,n)=>{Gn.value=[...Gn.value,{role:"assistant",content:e,id:n,progressEvents:[]}]},$t=(e,n,t,r)=>{const i=Gn.value;if(i.length>0&&"assistant"===i[i.length-1].role){const a=i[i.length-1];Gn.value=[...i.slice(0,-1),{role:"assistant",content:void 0!==e?e:a.content,id:n??a.id,actions:t??a.actions,sources:r??a.sources,actionStatus:a.actionStatus,progressEvents:a.progressEvents,segments:a.segments}]}},Mt=(e,n)=>{const t=Gn.value;if(e>=0&&e<t.length){const r=t[e],i={...r.actionStatus||{},[n]:{status:"pending"}};Gn.value=[...t.slice(0,e),{...r,actionStatus:i},...t.slice(e+1)]}},At=(e,n,t)=>{const r=Gn.value;for(let i=r.length-1;i>=0;i--){const a=r[i];if(a.actionStatus?.[e]){const l={...a.actionStatus,[e]:{status:n?"success":"failed",completedAt:Date.now(),errorMessage:t}};return void(Gn.value=[...r.slice(0,i),{...a,actionStatus:l},...r.slice(i+1)])}}},zt=(e,n)=>{const t=Gn.value;for(let r=t.length-1;r>=0;r--){const i=t[r];if(i.actionStatus?.[e])return void(Gn.value=[...t.slice(0,r),{...i,content:n},...t.slice(r+1)])}},Rt=e=>{Zn.value=e,et(e)},Lt=(e,n)=>{Gn.value=Gn.value.map(t=>t.id===e?{...t,feedback:n}:t)},Ot=e=>{nt.value=e},Dt=()=>{ot.value={kind:null}},Ht=()=>{const e=Gn.value;if(0===e.length)return;const n=e[e.length-1];if("assistant"!==n.role||!n.progressEvents)return;const t=n.progressEvents.some(e=>"active"===e.status);if(!t)return;const r=Date.now(),i=n.progressEvents.map(e=>{if("active"!==e.status)return e;const n=e.metadata?._startTime,t=n?{_durationSeconds:Math.round((r-n)/1e3)}:{};return{...e,status:"done",metadata:{...e.metadata,...t}}});Gn.value=[...e.slice(0,-1),{...n,progressEvents:i}]},Ut=e=>{const n=e.id||e.progress_id;if(n){const t=st.value.findIndex(e=>(e.id||e.progress_id)===n);if(t>=0){const n=st.value[t],r={...n,...e,id:e.id||n.id,progress_id:e.progress_id||n.progress_id,text:"thinking"===e.kind&&n.text&&e.text?n.text+e.text:e.text??n.text};st.value=[...st.value.slice(0,t),r,...st.value.slice(t+1)]}else st.value=[...st.value,e]}else st.value=[...st.value,e];ct(e)},jt=()=>{at.value=null},qt=()=>{const e=Gn.value;if(0===e.length)return;const n=e[e.length-1],t=n.progressEvents&&n.progressEvents.length>0;"assistant"!==n.role||n.content?.trim()||t||(Gn.value=e.slice(0,-1))},Bt=e=>{ft.value=e},Nt=()=>{ft.value=null},Ft=()=>{mt.value+=1},Wt=()=>{bt.value+=1},Kt=e=>{const n={...e,id:Fn()};vt.value=[...vt.value,n]},Vt=e=>{vt.value=vt.value.filter(n=>n.id!==e)},Gt=()=>{vt.value=[]},Zt=e=>{_t.value=e},Qt=()=>{_t.value=[]},Jt=()=>{Gn.value=[],Zn.value=null,et(null),Qn.value=[],nt.value=!1,ot.value={kind:null},st.value=[],lt.value=null,dt.value=!1,ut.value=[],ht.value=[],gt.value="",ft.value=null,mt.value=0,vt.value=[],_t.value=[],Pt()},Yt=()=>{Jt(),it.value=!0};function Xt(e){return"token_summary"===e.step_type||"tool_decision"===e.step_type||"parallel_tool_decision"===e.step_type||"narration"===e.step_type?null:"thinking"===e.step_type?{kind:"thinking",status:"done",text:e.content||"",label:"Thought",metadata:{iteration:e.iteration,timestamp_ms:e.timestamp_ms}}:"tool_result"===e.step_type?{kind:e.kind||"tool_call",status:!1===e.success?"error":"done",label:e.label||e.tool||"Result",text:e.text,children:e.children,metadata:{tool:e.tool,success:e.success,iteration:e.iteration,timestamp_ms:e.timestamp_ms}}:"step_start"===e.step_type?{kind:"step_start",status:"done",label:e.label||"Step",metadata:{iteration:e.iteration,timestamp_ms:e.timestamp_ms}}:{kind:e.step_type,status:"done",label:e.label||e.step_type,text:e.content,metadata:e}}function er(e){if(!e||0===e.length)return[];const n=[];for(const t of e){const e=Xt(t);e&&n.push(e)}return n}function nr(e,n){if(!e||0===e.length)return;const t=[];for(const n of e)if("narration"===n.step_type){const e=n.content||"",r=t[t.length-1];r&&"text"===r.type?r.content+=e:t.push({type:"text",content:e})}else{const e=Xt(n);if(!e)continue;const r=t[t.length-1];r&&"progress"===r.type?r.events.push(e):t.push({type:"progress",events:[e]})}if(n){const r=[...e].reverse().find(e=>"narration"===e.step_type);r?.content?.trim()===n.trim()||t.push({type:"text",content:n})}return t.length>0?t:void 0}const tr=(e,n)=>{Zn.value=e,et(e),Gn.value=n.map(e=>({role:e.role,content:e.content,id:e.id,progressEvents:"assistant"===e.role?er(e.display_trace):void 0,segments:"assistant"===e.role?nr(e.display_trace,e.content):void 0})),dt.value=!0,it.value=!1,Jn.value+=1},rr=()=>{it.value=!1},ir=(e,n)=>{const t=(new Date).toISOString(),r={id:e,title:n,startedAt:t,lastMessageAt:t,messageCount:1};Yn.value=[r,...Yn.value.filter(n=>n.id!==e)],Jn.value+=1},ar=async e=>{const{getApiClient:n}=await Promise.resolve().then(function(){return Kl}),{navigate:t}=await Promise.resolve().then(function(){return mr}),{debug:r}=await Promise.resolve().then(function(){return d}),i=n();if(i){Yt(),t("chat");try{const n=await i.getConversation(e);n&&n.messages.length>0?tr(n.id,n.messages):rr()}catch(e){r.error("[Pillar] Failed to load conversation:",e),rr()}}};var lr=Object.freeze({__proto__:null,activeRequestId:tt,addAssistantMessage:It,addOptimisticConversation:ir,addPendingImage:kt,addProgressEvent:Ut,addProgressEventToLastMessage:ct,addUserContext:Kt,addUserMessage:Tt,appendTokenToSegments:pt,clearInterruptedSession:jt,clearPendingImages:Pt,clearPendingMessage:Nt,clearPendingUserContext:Qt,clearProgressStatus:Dt,clearUserContext:Gt,conversationId:Zn,currentActions:ht,currentSources:ut,finalizeActiveProgressEvents:Ht,focusInputTrigger:bt,getReadyImages:wt,getRegisteredActions:()=>Qn.value,getStoredConversationId:function(){if("undefined"==typeof window)return null;try{return localStorage.getItem(Xn)}catch{return null}},hasMessages:Et,historyInvalidationCounter:Jn,interruptedSession:at,isExpanded:dt,isLoading:nt,isLoadingHistory:it,isUploadingImages:yt,loadConversation:tr,messages:Gn,optimisticConversations:Yn,pendingImages:xt,pendingMessage:ft,pendingUserContext:_t,prefillText:gt,progressEvents:st,progressStatus:ot,registeredActions:Qn,removeLastEmptyAssistantMessage:qt,removePendingImage:Ct,removeUserContext:Vt,resetChat:Jt,selectConversationById:ar,setActionComplete:At,setActionPending:Mt,setActiveRequestId:rt,setConversationId:Rt,setInterruptedSession:e=>{at.value=e},setLoading:Ot,setMessageFeedback:Lt,setPendingMessage:Bt,setPendingUserContext:Zt,setRegisteredActions:e=>{Qn.value=e},startLoadingHistory:Yt,stopLoadingHistory:rr,submitPendingTrigger:mt,tokenUsage:lt,triggerInputFocus:Wt,triggerSubmitPending:Ft,updateActionMessageContent:zt,updateImageStatus:St,updateLastAssistantMessage:$t,updateTokenUsage:e=>{lt.value=e},userContext:vt});const or=Xe([]),sr=Xe({type:"home"}),cr=an(()=>or.value.length>0),pr=an(()=>"home"===sr.value.type),dr=(e,n)=>{or.value=[...or.value,{...sr.value}],sr.value={type:e,params:n}},ur=()=>{const e=or.value;if(e.length>0){"chat"===sr.value.type&&Jt();const n=e[e.length-1];sr.value=n,or.value=e.slice(0,-1)}},hr=()=>{"chat"===sr.value.type&&Jt(),or.value=[],sr.value={type:"home"}},gr=()=>{or.value=[],sr.value={type:"home"}},fr=()=>{dr("chat"),Ft()};var mr=Object.freeze({__proto__:null,canGoBack:cr,currentView:sr,goBack:ur,goHome:hr,isAtHome:pr,navigate:dr,navigateToChat:fr,resetRouter:gr,viewStack:or});const br="\n/* Confirm Action Card */\n.pillar-confirm-card-wrapper {\n margin-top: 12px;\n}\n\n.pillar-confirm-card {\n background: var(--pillar-bg-secondary, #f9fafb);\n border: 1px solid var(--pillar-border, #e5e7eb);\n border-radius: 12px;\n overflow: hidden;\n}\n\n.pillar-confirm-card__content {\n padding: 16px;\n}\n\n.pillar-confirm-card__header {\n margin-bottom: 12px;\n}\n\n.pillar-confirm-card__title {\n font-size: 14px;\n font-weight: 600;\n color: var(--pillar-text-primary, #111827);\n}\n\n.pillar-confirm-card__data {\n background: var(--pillar-bg-primary, #ffffff);\n border: 1px solid var(--pillar-border, #e5e7eb);\n border-radius: 8px;\n padding: 12px;\n margin-bottom: 12px;\n}\n\n.pillar-confirm-card__data-row {\n display: flex;\n gap: 8px;\n font-size: 13px;\n margin-bottom: 4px;\n}\n\n.pillar-confirm-card__data-row:last-child {\n margin-bottom: 0;\n}\n\n.pillar-confirm-card__data-key {\n color: var(--pillar-text-secondary, #6b7280);\n flex-shrink: 0;\n}\n\n.pillar-confirm-card__data-value {\n color: var(--pillar-text-primary, #111827);\n word-break: break-word;\n}\n\n.pillar-confirm-card__actions {\n display: flex;\n gap: 8px;\n justify-content: flex-end;\n}\n\n.pillar-confirm-card__btn {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 8px 14px;\n font-size: 13px;\n font-weight: 500;\n font-family: inherit;\n border-radius: 8px;\n cursor: pointer;\n transition: all 0.15s ease;\n border: 1px solid transparent;\n}\n\n.pillar-confirm-card__btn:disabled {\n opacity: 0.6;\n cursor: not-allowed;\n}\n\n.pillar-confirm-card__btn svg {\n width: 16px;\n height: 16px;\n}\n\n.pillar-confirm-card__btn--primary {\n background: var(--pillar-primary, #2563eb);\n color: #ffffff;\n border-color: var(--pillar-primary, #2563eb);\n}\n\n.pillar-confirm-card__btn--primary:hover:not(:disabled) {\n background: var(--pillar-primary-hover, #1d4ed8);\n border-color: var(--pillar-primary-hover, #1d4ed8);\n}\n\n.pillar-confirm-card__btn--secondary {\n background: var(--pillar-bg-primary, #ffffff);\n color: var(--pillar-text-secondary, #6b7280);\n border-color: var(--pillar-border, #e5e7eb);\n}\n\n.pillar-confirm-card__btn--secondary:hover:not(:disabled) {\n background: var(--pillar-bg-secondary, #f9fafb);\n}\n\n.pillar-confirm-card__success {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n padding: 16px;\n color: #059669;\n font-weight: 500;\n}\n\n.pillar-confirm-card__success-icon svg {\n width: 20px;\n height: 20px;\n}\n\n.pillar-confirm-card__error {\n background: #fef2f2;\n border: 1px solid #fecaca;\n border-radius: 8px;\n padding: 12px;\n margin-bottom: 12px;\n color: #dc2626;\n font-size: 13px;\n}\n\n.pillar-confirm-card__spinner {\n display: inline-flex;\n animation: pillar-spin 1s linear infinite;\n}\n\n@keyframes pillar-spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n}\n",vr=function(e){function n(e){var t,r;return this.getChildContext||(t=new Set,(r={})[n.__c]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){t=null},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&t.forEach(function(e){e.__e=!0,J(e)})},this.sub=function(e){t.add(e);var n=e.componentWillUnmount;e.componentWillUnmount=function(){t&&t.delete(e),n&&n.call(e)}}),e.children}return n.__c="__cC"+H++,n.__=e,n.Provider=n.__l=(n.Consumer=function(e,n){return e.children(n)}).contextType=n,n}(null);function _r({api:e,events:n,children:t}){return ge(vr.Provider,{value:{api:e,events:n},children:t})}function xr(){const e=function(e){var n=me.context[e.__c],t=Te(fe++,9);return t.c=e,n?(null==t.__&&(t.__=!0,n.sub(me)),n.props.value):e.__}(vr);if(!e)throw new Error("usePillar must be used within a PillarProvider");return e}function yr(){return xr().api}const wr=Xe([]),kr=Xe([]),Sr=Xe(!1),Cr=Xe(null),Pr=Xe(null);function Er(e,n,t,r=3){if(0===e.length)return[];const i=function(e,n){const t=e.split("/").filter(Boolean).flatMap(e=>e.split(/[-_]/)),r=n.toLowerCase().split(/\s+/);return[...new Set([...t,...r])].map(e=>e.toLowerCase()).filter(e=>e.length>2)}(n,t),a=e.map(e=>({suggestion:e,score:Tr(e,i)}));return a.sort((e,n)=>n.score-e.score),a.slice(0,r).map(e=>e.suggestion)}function Tr(e,n){if(e.manual)return 1/0;const t=e.text.toLowerCase();let r=0;for(const e of n)t.includes(e)&&(r+=e.length);return r}function Ir(e){Sr.value=e}an(()=>kr.value.length>0),an(()=>wr.value.length>0);const $r='<svg viewBox="0 0 24 24" fill="currentColor"><path d="M4.583 17.321C3.553 16.227 3 15 3 13.011c0-3.5 2.457-6.637 6.03-8.188l.893 1.378c-3.335 1.804-3.987 4.145-4.247 5.621.537-.278 1.24-.375 1.929-.311 1.804.167 3.226 1.648 3.226 3.489a3.5 3.5 0 01-3.5 3.5c-1.073 0-2.099-.49-2.748-1.179zm10 0C13.553 16.227 13 15 13 13.011c0-3.5 2.457-6.637 6.03-8.188l.893 1.378c-3.335 1.804-3.987 4.145-4.247 5.621.537-.278 1.24-.375 1.929-.311 1.804.167 3.226 1.648 3.226 3.489a3.5 3.5 0 01-3.5 3.5c-1.073 0-2.099-.49-2.748-1.179z"/></svg>';function Mr({context:e,onRemove:n,readOnly:t=!1}){const r=Vn(e),i=function(e){return Wn(e),$r}(e),a=function(e){if(Wn(e)){const n=e.url_origin?`\nFrom: ${e.url_origin}`:"";return`"${e.text_content}"${n}`}return""}(e);return ge("div",{class:"_pillar-context-tag pillar-context-tag",title:a,children:[ge("span",{class:"_pillar-context-tag-icon pillar-context-tag-icon",dangerouslySetInnerHTML:{__html:i}}),ge("span",{class:"_pillar-context-tag-label pillar-context-tag-label",children:r}),!t&&n&&ge("button",{class:"_pillar-context-tag-remove pillar-context-tag-remove",onClick:t=>{t.preventDefault(),t.stopPropagation(),n?.(e.id)},"aria-label":"Remove context",type:"button",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>'}})]})}function Ar({contexts:e,onRemove:n,readOnly:t=!1}){const r=e.filter(e=>!Kn(e));return 0===r.length?null:ge("div",{class:"_pillar-context-tag-list pillar-context-tag-list",children:r.map(e=>ge(Mr,{context:e,onRemove:n,readOnly:t},e.id))})}const zr='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>';function Rr({placeholder:e="Ask anything...",disabled:n=!1,onSubmit:t,showContextTags:r=!0,showImageUpload:i=!0,className:a="",isStreaming:l=!1,onStop:o}){const s=yr(),c=Me(null),p=Me(null),[d,u]=Ie(""),[h,g]=Ie(!1),f=ze(()=>{const e=c.current;if(!e)return;e.style.height="41px";const n=e.scrollHeight;n>146?(e.style.height="146px",e.style.overflowY="auto"):(e.style.height=`${n}px`,e.style.overflowY="hidden")},[]),m=ze(async e=>{if(xt.value.length>=4)return;const n=`img-${Date.now()}-${Math.random().toString(36).slice(2)}`,t=URL.createObjectURL(e);kt({id:n,file:e,preview:t,status:"uploading"});try{const t=await s.uploadImage(e);St(n,"ready",t.url)}catch(e){const t=e instanceof Error?e.message:"Upload failed";St(n,"error",void 0,t)}},[s]),b=ze(e=>{const n=Array.from(e).filter(e=>e.type.startsWith("image/")),t=4-xt.value.length;n.slice(0,t).forEach(m)},[m]),v=ze(e=>{const n=e.clipboardData?.items;if(!n)return;const t=[];for(const e of n)if(e.type.startsWith("image/")){const n=e.getAsFile();n&&t.push(n)}t.length>0&&(e.preventDefault(),b(t))},[b]),_=ze(e=>{e.preventDefault(),e.stopPropagation(),g(!0)},[]),x=ze(e=>{e.preventDefault(),e.stopPropagation(),g(!1)},[]),y=ze(e=>{e.preventDefault(),e.stopPropagation(),g(!1);const n=e.dataTransfer?.files;n&&b(n)},[b]),w=ze(e=>{const n=e.target;n.files&&(b(n.files),n.value="")},[b]),k=ze(()=>{p.current?.click()},[]),S=ze(()=>{const e=d.trim(),n=[...vt.value],r=wt(),i=n.length>0,a=r.length>0;(e||i||a)&&(yt.value||(i&&Gt(),Pt(),t?t(e,n,r):(i&&Zt(n),Bt(e),fr()),u(""),c.current&&(c.current.style.height="41px",c.current.style.overflowY="hidden")))},[d,t]),C=yt.value,P=d.trim()||vt.value.length>0||xt.value.some(e=>"ready"===e.status);return ge("div",{class:`_pillar-unified-input-wrapper pillar-unified-input-wrapper ${h?"_pillar-unified-input-wrapper--dragging":""} ${a}`.trim(),onDragOver:_,onDragLeave:x,onDrop:y,children:[ge("input",{ref:p,type:"file",accept:"image/*",multiple:!0,onChange:w,style:{display:"none"}}),xt.value.length>0&&ge("div",{class:"_pillar-chat-images-preview pillar-chat-images-preview",children:xt.value.map(e=>ge("div",{class:"_pillar-chat-image-thumb pillar-chat-image-thumb",children:[ge("img",{src:e.preview,alt:"Upload preview"}),"uploading"===e.status&&ge("div",{class:"_pillar-chat-image-loading pillar-chat-image-loading",children:ge("div",{class:"_pillar-loading-spinner pillar-loading-spinner",style:{width:"16px",height:"16px"}})}),"error"===e.status&&ge("div",{class:"_pillar-chat-image-error pillar-chat-image-error",title:e.error,children:"!"}),ge("button",{type:"button",class:"_pillar-chat-image-remove pillar-chat-image-remove",onClick:()=>Ct(e.id),"aria-label":"Remove image",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>'}})]},e.id))}),r&&ge(Ar,{contexts:vt.value,onRemove:Vt}),ge("textarea",{ref:c,class:"_pillar-unified-input pillar-unified-input",placeholder:h?"Drop image here...":e,value:d,onInput:e=>{const n=e.target;u(n.value),f()},onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),S())},onPaste:v,disabled:n||l,maxLength:32e3,style:{height:"41px"}}),ge("div",{class:"_pillar-unified-input-row pillar-unified-input-row",children:[i&&!l&&ge("button",{type:"button",class:"_pillar-chat-image-btn pillar-chat-image-btn",onClick:k,disabled:n||C||xt.value.length>=4,"aria-label":"Attach image",title:"Attach image (max 4)",dangerouslySetInnerHTML:{__html:zr}}),ge("button",l?{type:"button",class:"_pillar-unified-stop-btn pillar-unified-stop-btn",onClick:o,"aria-label":"Stop generating",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 24 24" fill="currentColor"><rect x="6" y="6" width="12" height="12" rx="2"/></svg>'}}:{type:"button",class:"_pillar-unified-send-btn pillar-unified-send-btn",onClick:S,disabled:n||C||!P,"aria-label":"Send message",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="19" x2="12" y2="5"/><polyline points="5 12 12 5 19 12"/></svg>'}})]}),h&&ge("div",{class:"_pillar-chat-drop-overlay pillar-chat-drop-overlay",children:[ge("span",{dangerouslySetInnerHTML:{__html:zr}}),ge("span",{children:"Drop image here"})]})]})}function Lr({text:e,onClick:n}){return ge("button",{type:"button",class:"_pillar-question-chip pillar-question-chip",onClick:n,children:[ge("span",{class:"_pillar-question-chip-text pillar-question-chip-text",children:e}),ge("span",{class:"_pillar-question-chip-arrow pillar-question-chip-arrow",children:"→"})]})}function Or(){return ge("div",{class:"_pillar-question-chip-skeleton pillar-question-chip-skeleton",children:ge("div",{class:"_pillar-question-chip-skeleton-bar pillar-question-chip-skeleton-bar"})})}function Dr(){const e=fn(()=>kr.value),n=fn(()=>Sr.value);return ge("div",{class:"_pillar-home-view pillar-home-view",children:[ge("div",{class:"_pillar-home-view-questions pillar-home-view-questions",children:n.value?ge(V,{children:[ge(Or,{}),ge(Or,{}),ge(Or,{})]}):e.value&&e.value.length>0?e.value.map(e=>ge(Lr,{text:e.text,onClick:()=>(e=>{Bt(e.text),fr()})(e)},e.id)):null}),ge("div",{style:{marginTop:"auto"},children:ge(Rr,{placeholder:"Ask anything..."})})]})}const Hr=Xe(!1),Ur=Xe(null),jr=Xe(!1),qr=Xe(null);function Br(e,n){Hr.value=!0,Ur.value=e,jr.value=!1,qr.value=n??null}function Nr(){Hr.value=!1,Ur.value=null,qr.value=null}function Fr(){jr.value=!0}function Wr(){jr.value=!1}function Kr(){return jr.value}const Vr=Xe(!1),Gr=Xe(null),Zr=Xe(null);function Qr(e){const n=Zr.value;Vr.value=!1,Gr.value=null,Zr.value=null,n?.(e)}var Jr=Object.freeze({__proto__:null,cancelPiloting:Fr,confirmationLabel:Gr,confirmationResolver:Zr,currentToolCallId:qr,isCancelled:jr,isPiloting:Hr,needsConfirmation:Vr,pilotOperation:Ur,requestConfirmation:function(e){return new Promise(n=>{Gr.value=e,Zr.value=n,Vr.value=!0})},resetCancellation:Wr,resolveConfirmation:Qr,startPiloting:Br,stopPiloting:Nr,wasCancelled:Kr});function Yr(e){if(e)try{const n=Xr(e);localStorage.removeItem(n),p.log("[SessionPersistence] Cleared saved session")}catch(e){p.warn("[SessionPersistence] Failed to clear session:",e)}}function Xr(e){return`pillar:active_session:${e}`}var ei=Object.freeze({__proto__:null,clearActiveSession:Yr,loadActiveSession:function(e){if(!e)return p.warn("[SessionPersistence] loadActiveSession called with empty siteId"),null;try{const n=Xr(e),t=localStorage.getItem(n);if(!t)return p.log(`[SessionPersistence] No session found at key "${n}"`),null;const r=JSON.parse(t);return 1!==r.version?(p.warn("[SessionPersistence] Stored session has incompatible version, clearing"),Yr(e),null):r.siteId!==e?(p.warn("[SessionPersistence] Stored session is for different site, clearing"),Yr(e),null):(p.log(`[SessionPersistence] Loaded session ${r.conversationId.slice(0,8)}... from localStorage`),r)}catch(n){return p.warn("[SessionPersistence] Failed to load session:",n),Yr(e),null}},saveActiveSession:function(e,n){if(e&&n)try{const t={version:1,conversationId:e,siteId:n,streamingStartedAt:(new Date).toISOString()},r=Xr(n);localStorage.setItem(r,JSON.stringify(t)),p.log(`[SessionPersistence] Saved session ${e.slice(0,8)}... to localStorage (key="${r}")`)}catch(e){p.warn("[SessionPersistence] Failed to save session:",e)}}});const ni={maxDepth:20,includeText:!0,visibleOnly:!0,minTextLength:1,maxTextLength:500,maxTotalLength:5e4,maxLabelLength:100,includePositions:!1},ti=new Set(["a","button","input","select","textarea","details","summary","dialog","menu","menuitem"]),ri=new Set(["button","link","checkbox","radio","switch","tab","tabpanel","menuitem","menuitemcheckbox","menuitemradio","option","slider","spinbutton","textbox","combobox","listbox","searchbox","tree","treeitem","grid","gridcell","row","rowheader","columnheader"]),ii=new Set(["script","style","noscript","template","svg","path","iframe","object","embed","head","meta","link","base"]);let ai=0;function li(){document.querySelectorAll("[data-pillar-ref]").forEach(e=>e.removeAttribute("data-pillar-ref")),ai=0}function oi(e){return e instanceof HTMLInputElement&&"password"===e.type.toLowerCase()||null!==e.closest("[data-pillar-redact]")}const si=/\b(delete|remove|destroy|reset|revoke|archive|cancel subscription|deactivate|disable|erase|purge|terminate|unsubscribe|drop)\b/i;function ci(e){if(e.hasAttribute("data-pillar-destructive"))return!0;const n=e.getAttribute("aria-label");if(n&&si.test(n))return!0;const t=e.textContent?.trim().slice(0,200);if(t&&si.test(t))return!0;const r=e.getAttribute("title");if(r&&si.test(r))return!0;if(e instanceof HTMLInputElement||e instanceof HTMLButtonElement){const n=e.type?.toLowerCase();if("reset"===n||"submit"===n){const n=e.closest("form");if(n){const e=n.getAttribute("action")||"";if(si.test(e))return!0}}}return!1}function pi(e){const n=e.tagName.toLowerCase();if(e.hasAttribute("data-pillar-interactable"))return!0;if(ti.has(n))return!0;const t=e.getAttribute("role");if(t&&ri.has(t))return!0;const r=e.getAttribute("tabindex");return null!==r&&"-1"!==r||("true"===e.getAttribute("contenteditable")||!!(e.hasAttribute("onclick")||e.hasAttribute("onkeydown")||e.hasAttribute("onkeyup")))}const di=/^pr-[a-z0-9]+-[a-z0-9]+$/;function ui(e){return di.test(e)}function hi(e){if(!ui(e))throw new Error(`Invalid pillar ref format: "${e}"`);return`[data-pillar-ref="${e}"]`}function gi(e,n){return e.length<=n?e:e.slice(0,n)+"..."}function fi(e,n){const t=function(e){const n=e.getAttribute("aria-label");if(n)return n;const t=e.getAttribute("aria-labelledby");if(t){const e=document.getElementById(t);if(e)return e.textContent?.trim()||void 0}if(e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement){if(e.id){const n=document.querySelector(`label[for="${e.id}"]`);if(n)return n.textContent?.trim()||void 0}const n=e.closest("label");if(n){const e=n.cloneNode(!0);e.querySelectorAll("input, select, textarea").forEach(e=>e.remove());const t=e.textContent?.trim();if(t)return t}}const r=e.getAttribute("title");return r||void 0}(e);if(t)return gi(t,n);if((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.placeholder)return gi(e.placeholder,n);const r=e.textContent?.trim();if(r&&r.length>0)return gi(r,n);const i=e.getAttribute("name");return i?gi(i,n):e.id?gi(e.id,n):e.tagName.toLowerCase()}function mi(e,n,t){if(t>n.maxDepth&&(n.maxDepth=t),t>n.options.maxDepth)return;if(e.nodeType===Node.TEXT_NODE){if(n.options.includeText&&!n.budgetExhausted){const t=e.textContent?.trim();if(t&&t.length>=n.options.minTextLength){const e=t.length>n.options.maxTextLength?t.slice(0,n.options.maxTextLength)+"...":t,r=e.length+1;if(n.totalLength+r>n.options.maxTotalLength)return void(n.budgetExhausted=!0);n.lines.push(e),n.totalLength+=r}}return}if(e.nodeType!==Node.ELEMENT_NODE)return;const r=e,i=r.tagName.toLowerCase();if(!ii.has(i)){if(n.options.excludeSelector)try{if(r.matches(n.options.excludeSelector))return}catch{}if((!n.options.visibleOnly||function(e){if(!e.isConnected)return!1;const n=window.getComputedStyle(e);if("none"===n.display)return!1;if("hidden"===n.visibility)return!1;if("0"===n.opacity)return!1;const t=e.getBoundingClientRect();return(0!==t.width||0!==t.height)&&!e.hasAttribute("hidden")&&"true"!==e.getAttribute("aria-hidden")}(r))&&!r.hasAttribute("data-pillar-redact")){if(pi(r)){if(oi(r))return;const e=function(e){const n=e.tagName.toLowerCase(),t=e.getAttribute("data-pillar-interactable");if(t&&"true"!==t)return t;switch(n){case"input":switch(e.type.toLowerCase()){case"checkbox":case"radio":return"toggle";case"submit":case"button":case"reset":return"click";case"file":return"select";default:return"input"}case"textarea":return"input";case"select":return"select";case"button":return"submit"===e.getAttribute("type")?"submit":"click";case"a":return"click";case"details":case"summary":return"toggle"}const r=e.getAttribute("role");if(r)switch(r){case"button":case"link":case"menuitem":case"tab":default:return"click";case"checkbox":case"radio":case"switch":return"toggle";case"textbox":case"searchbox":case"combobox":case"slider":case"spinbutton":return"input";case"listbox":case"option":return"select"}return"true"===e.getAttribute("contenteditable")?"input":"click"}(r),t=fi(r,n.options.maxLabelLength),i=`pr-${Date.now().toString(36)}-${(ai++).toString(36)}`;r.setAttribute("data-pillar-ref",i);const a=`${e.toUpperCase()}: ${t} [[${i}]]`;n.lines.push(a),n.totalLength+=a.length+1,n.interactableCount++}for(const e of r.childNodes)mi(e,n,t+1)}}}function bi(e){li();const n=e?.root||document.body,t={lines:[],interactableCount:0,totalLength:0,budgetExhausted:!1,maxDepth:0,options:{...ni,...e}};return t.lines.push(`=== PAGE: ${document.title} | ${window.location.pathname} ===`),t.lines.push(""),mi(n,t,0),t.lines.push(""),t.lines.push(`=== ${t.interactableCount} interactable elements ===`),{content:t.lines.join("\n"),interactableCount:t.interactableCount,timestamp:Date.now(),url:window.location.href,title:document.title}}function vi(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var _i={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function xi(e){_i=e}var yi={exec:()=>null};function wi(e,n=""){let t="string"==typeof e?e:e.source,r={replace:(e,n)=>{let i="string"==typeof n?n:n.source;return i=i.replace(Si.caret,"$1"),t=t.replace(e,i),r},getRegex:()=>new RegExp(t,n)};return r}var ki=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Si={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[\t ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},Ci=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Pi=/(?:[*+-]|\d{1,9}[.)])/,Ei=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Ti=wi(Ei).replace(/bull/g,Pi).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Ii=wi(Ei).replace(/bull/g,Pi).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),$i=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Mi=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Ai=wi(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Mi).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),zi=wi(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Pi).getRegex(),Ri="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Li=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Oi=wi("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",Li).replace("tag",Ri).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Di=wi($i).replace("hr",Ci).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ri).getRegex(),Hi={blockquote:wi(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Di).getRegex(),code:/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,def:Ai,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:Ci,html:Oi,lheading:Ti,list:zi,newline:/^(?:[ \t]*(?:\n|$))+/,paragraph:Di,table:yi,text:/^[^\n]+/},Ui=wi("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Ci).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ri).getRegex(),ji={...Hi,lheading:Ii,table:Ui,paragraph:wi($i).replace("hr",Ci).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Ui).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ri).getRegex()},qi={...Hi,html:wi("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",Li).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:yi,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:wi($i).replace("hr",Ci).replace("heading"," *#{1,6} *[^\n]").replace("lheading",Ti).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Bi=/^( {2,}|\\)\n(?!\s*$)/,Ni=/[\p{P}\p{S}]/u,Fi=/[\s\p{P}\p{S}]/u,Wi=/[^\s\p{P}\p{S}]/u,Ki=wi(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Fi).getRegex(),Vi=/(?!~)[\p{P}\p{S}]/u,Gi=wi(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",ki?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Zi=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Qi=wi(Zi,"u").replace(/punct/g,Ni).getRegex(),Ji=wi(Zi,"u").replace(/punct/g,Vi).getRegex(),Yi="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Xi=wi(Yi,"gu").replace(/notPunctSpace/g,Wi).replace(/punctSpace/g,Fi).replace(/punct/g,Ni).getRegex(),ea=wi(Yi,"gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|~)/u).replace(/punctSpace/g,/(?!~)[\s\p{P}\p{S}]/u).replace(/punct/g,Vi).getRegex(),na=wi("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Wi).replace(/punctSpace/g,Fi).replace(/punct/g,Ni).getRegex(),ta=wi(/\\(punct)/,"gu").replace(/punct/g,Ni).getRegex(),ra=wi(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),ia=wi(Li).replace("(?:--\x3e|$)","--\x3e").getRegex(),aa=wi("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",ia).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),la=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,oa=wi(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",la).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),sa=wi(/^!?\[(label)\]\[(ref)\]/).replace("label",la).replace("ref",Mi).getRegex(),ca=wi(/^!?\[(ref)\](?:\[\])?/).replace("ref",Mi).getRegex(),pa=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,da={_backpedal:yi,anyPunctuation:ta,autolink:ra,blockSkip:Gi,br:Bi,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:yi,emStrongLDelim:Qi,emStrongRDelimAst:Xi,emStrongRDelimUnd:na,escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,link:oa,nolink:ca,punctuation:Ki,reflink:sa,reflinkSearch:wi("reflink|nolink(?!\\()","g").replace("reflink",sa).replace("nolink",ca).getRegex(),tag:aa,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:yi},ua={...da,link:wi(/^!?\[(label)\]\((.*?)\)/).replace("label",la).getRegex(),reflink:wi(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",la).getRegex()},ha={...da,emStrongRDelimAst:ea,emStrongLDelim:Ji,url:wi(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",pa).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:wi(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",pa).getRegex()},ga={...ha,br:wi(Bi).replace("{2,}","*").getRegex(),text:wi(ha.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},fa={normal:Hi,gfm:ji,pedantic:qi},ma={normal:da,gfm:ha,breaks:ga,pedantic:ua},ba={"&":"&","<":"<",">":">",'"':""","'":"'"},va=e=>ba[e];function _a(e,n){if(n){if(Si.escapeTest.test(e))return e.replace(Si.escapeReplace,va)}else if(Si.escapeTestNoEncode.test(e))return e.replace(Si.escapeReplaceNoEncode,va);return e}function xa(e){try{e=encodeURI(e).replace(Si.percentDecode,"%")}catch{return null}return e}function ya(e,n){let t=e.replace(Si.findPipe,(e,n,t)=>{let r=!1,i=n;for(;--i>=0&&"\\"===t[i];)r=!r;return r?"|":" |"}),r=t.split(Si.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),n)if(r.length>n)r.splice(n);else for(;r.length<n;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(Si.slashPipe,"|");return r}function wa(e,n,t){let r=e.length;if(0===r)return"";let i=0;for(;i<r;){if(e.charAt(r-i-1)!==n)break;i++}return e.slice(0,r-i)}function ka(e,n,t,r,i){let a=n.href,l=n.title||null,o=e[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let s={type:"!"===e[0].charAt(0)?"image":"link",raw:t,href:a,title:l,text:o,tokens:r.inlineTokens(o)};return r.state.inLink=!1,s}var Sa=class{options;rules;lexer;constructor(e){this.options=e||_i}space(e){let n=this.rules.block.newline.exec(e);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(e){let n=this.rules.block.code.exec(e);if(n){let e=n[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?e:wa(e,"\n")}}}fences(e){let n=this.rules.block.fences.exec(e);if(n){let e=n[0],t=function(e,n,t){let r=e.match(t.other.indentCodeCompensation);if(null===r)return n;let i=r[1];return n.split("\n").map(e=>{let n=e.match(t.other.beginningSpace);if(null===n)return e;let[r]=n;return r.length>=i.length?e.slice(i.length):e}).join("\n")}(e,n[3]||"",this.rules);return{type:"code",raw:e,lang:n[2]?n[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):n[2],text:t}}}heading(e){let n=this.rules.block.heading.exec(e);if(n){let e=n[2].trim();if(this.rules.other.endingHash.test(e)){let n=wa(e,"#");(this.options.pedantic||!n||this.rules.other.endingSpaceChar.test(n))&&(e=n.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let n=this.rules.block.hr.exec(e);if(n)return{type:"hr",raw:wa(n[0],"\n")}}blockquote(e){let n=this.rules.block.blockquote.exec(e);if(n){let e=wa(n[0],"\n").split("\n"),t="",r="",i=[];for(;e.length>0;){let n,a=!1,l=[];for(n=0;n<e.length;n++)if(this.rules.other.blockquoteStart.test(e[n]))l.push(e[n]),a=!0;else{if(a)break;l.push(e[n])}e=e.slice(n);let o=l.join("\n"),s=o.replace(this.rules.other.blockquoteSetextReplace,"\n $1").replace(this.rules.other.blockquoteSetextReplace2,"");t=t?`${t}\n${o}`:o,r=r?`${r}\n${s}`:s;let c=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(s,i,!0),this.lexer.state.top=c,0===e.length)break;let p=i.at(-1);if("code"===p?.type)break;if("blockquote"===p?.type){let n=p,a=n.raw+"\n"+e.join("\n"),l=this.blockquote(a);i[i.length-1]=l,t=t.substring(0,t.length-n.raw.length)+l.raw,r=r.substring(0,r.length-n.text.length)+l.text;break}if("list"===p?.type){let n=p,a=n.raw+"\n"+e.join("\n"),l=this.list(a);i[i.length-1]=l,t=t.substring(0,t.length-p.raw.length)+l.raw,r=r.substring(0,r.length-n.raw.length)+l.raw,e=a.substring(i.at(-1).raw.length).split("\n");continue}}return{type:"blockquote",raw:t,tokens:i,text:r}}}list(e){let n=this.rules.block.list.exec(e);if(n){let t=n[1].trim(),r=t.length>1,i={type:"list",raw:"",ordered:r,start:r?+t.slice(0,-1):"",loose:!1,items:[]};t=r?`\\d{1,9}\\${t.slice(-1)}`:`\\${t}`,this.options.pedantic&&(t=r?t:"[*+-]");let a=this.rules.other.listItemRegex(t),l=!1;for(;e;){let t=!1,r="",o="";if(!(n=a.exec(e))||this.rules.block.hr.test(e))break;r=n[0],e=e.substring(r.length);let s=n[2].split("\n",1)[0].replace(this.rules.other.listReplaceTabs,e=>" ".repeat(3*e.length)),c=e.split("\n",1)[0],p=!s.trim(),d=0;if(this.options.pedantic?(d=2,o=s.trimStart()):p?d=n[1].length+1:(d=n[2].search(this.rules.other.nonSpaceChar),d=d>4?1:d,o=s.slice(d),d+=n[1].length),p&&this.rules.other.blankLine.test(c)&&(r+=c+"\n",e=e.substring(c.length+1),t=!0),!t){let n=this.rules.other.nextBulletRegex(d),t=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),a=this.rules.other.headingBeginRegex(d),l=this.rules.other.htmlBeginRegex(d);for(;e;){let u,h=e.split("\n",1)[0];if(c=h,this.options.pedantic?(c=c.replace(this.rules.other.listReplaceNesting," "),u=c):u=c.replace(this.rules.other.tabCharGlobal," "),i.test(c)||a.test(c)||l.test(c)||n.test(c)||t.test(c))break;if(u.search(this.rules.other.nonSpaceChar)>=d||!c.trim())o+="\n"+u.slice(d);else{if(p||s.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||i.test(s)||a.test(s)||t.test(s))break;o+="\n"+c}!p&&!c.trim()&&(p=!0),r+=h+"\n",e=e.substring(h.length+1),s=u.slice(d)}}i.loose||(l?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(l=!0)),i.items.push({type:"list_item",raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(o),loose:!1,text:o,tokens:[]}),i.raw+=r}let o=i.items.at(-1);if(!o)return;o.raw=o.raw.trimEnd(),o.text=o.text.trimEnd(),i.raw=i.raw.trimEnd();for(let e of i.items){if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),e.task){if(e.text=e.text.replace(this.rules.other.listReplaceTask,""),"text"===e.tokens[0]?.type||"paragraph"===e.tokens[0]?.type){e.tokens[0].raw=e.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),e.tokens[0].text=e.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,"");break}}let n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:"checkbox",raw:n[0]+" ",checked:"[ ]"!==n[0]};e.checked=t.checked,i.loose?e.tokens[0]&&["paragraph","text"].includes(e.tokens[0].type)&&"tokens"in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:"paragraph",raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}if(!i.loose){let n=e.tokens.filter(e=>"space"===e.type),t=n.length>0&&n.some(e=>this.rules.other.anyLine.test(e.raw));i.loose=t}}if(i.loose)for(let e of i.items){e.loose=!0;for(let n of e.tokens)"text"===n.type&&(n.type="paragraph")}return i}}html(e){let n=this.rules.block.html.exec(e);if(n)return{type:"html",block:!0,raw:n[0],pre:"pre"===n[1]||"script"===n[1]||"style"===n[1],text:n[0]}}def(e){let n=this.rules.block.def.exec(e);if(n){let e=n[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),t=n[2]?n[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):n[3];return{type:"def",tag:e,raw:n[0],href:t,title:r}}}table(e){let n=this.rules.block.table.exec(e);if(!n||!this.rules.other.tableDelimiter.test(n[2]))return;let t=ya(n[1]),r=n[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=n[3]?.trim()?n[3].replace(this.rules.other.tableRowBlankLine,"").split("\n"):[],a={type:"table",raw:n[0],header:[],align:[],rows:[]};if(t.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push("right"):this.rules.other.tableAlignCenter.test(e)?a.align.push("center"):this.rules.other.tableAlignLeft.test(e)?a.align.push("left"):a.align.push(null);for(let e=0;e<t.length;e++)a.header.push({text:t[e],tokens:this.lexer.inline(t[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(ya(e,a.header.length).map((e,n)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[n]})));return a}}lheading(e){let n=this.rules.block.lheading.exec(e);if(n)return{type:"heading",raw:n[0],depth:"="===n[2].charAt(0)?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(e){let n=this.rules.block.paragraph.exec(e);if(n){let e="\n"===n[1].charAt(n[1].length-1)?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let n=this.rules.block.text.exec(e);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(e){let n=this.rules.inline.escape.exec(e);if(n)return{type:"escape",raw:n[0],text:n[1]}}tag(e){let n=this.rules.inline.tag.exec(e);if(n)return!this.lexer.state.inLink&&this.rules.other.startATag.test(n[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:n[0]}}link(e){let n=this.rules.inline.link.exec(e);if(n){let e=n[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let n=wa(e.slice(0,-1),"\\");if((e.length-n.length)%2==0)return}else{let e=function(e,n){if(-1===e.indexOf(n[1]))return-1;let t=0;for(let r=0;r<e.length;r++)if("\\"===e[r])r++;else if(e[r]===n[0])t++;else if(e[r]===n[1]&&(t--,t<0))return r;return t>0?-2:-1}(n[2],"()");if(-2===e)return;if(e>-1){let t=(0===n[0].indexOf("!")?5:4)+n[1].length+e;n[2]=n[2].substring(0,e),n[0]=n[0].substring(0,t).trim(),n[3]=""}}let t=n[2],r="";if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(t);e&&(t=e[1],r=e[3])}else r=n[3]?n[3].slice(1,-1):"";return t=t.trim(),this.rules.other.startAngleBracket.test(t)&&(t=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?t.slice(1):t.slice(1,-1)),ka(n,{href:t&&t.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},n[0],this.lexer,this.rules)}}reflink(e,n){let t;if((t=this.rules.inline.reflink.exec(e))||(t=this.rules.inline.nolink.exec(e))){let e=n[(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!e){let e=t[0].charAt(0);return{type:"text",raw:e,text:e}}return ka(t,e,t[0],this.lexer,this.rules)}}emStrong(e,n,t=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||r[3]&&t.match(this.rules.other.unicodeAlphaNumeric))&&(!r[1]&&!r[2]||!t||this.rules.inline.punctuation.exec(t))){let t,i,a=[...r[0]].length-1,l=a,o=0,s="*"===r[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(s.lastIndex=0,n=n.slice(-1*e.length+a);null!=(r=s.exec(n));){if(t=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!t)continue;if(i=[...t].length,r[3]||r[4]){l+=i;continue}if((r[5]||r[6])&&a%3&&!((a+i)%3)){o+=i;continue}if(l-=i,l>0)continue;i=Math.min(i,i+l+o);let n=[...r[0]][0].length,s=e.slice(0,a+r.index+n+i);if(Math.min(a,i)%2){let e=s.slice(1,-1);return{type:"em",raw:s,text:e,tokens:this.lexer.inlineTokens(e)}}let c=s.slice(2,-2);return{type:"strong",raw:s,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){let n=this.rules.inline.code.exec(e);if(n){let e=n[2].replace(this.rules.other.newLineCharGlobal," "),t=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return t&&r&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:n[0],text:e}}}br(e){let n=this.rules.inline.br.exec(e);if(n)return{type:"br",raw:n[0]}}del(e){let n=this.rules.inline.del.exec(e);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(e){let n=this.rules.inline.autolink.exec(e);if(n){let e,t;return"@"===n[2]?(e=n[1],t="mailto:"+e):(e=n[1],t=e),{type:"link",raw:n[0],text:e,href:t,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let n;if(n=this.rules.inline.url.exec(e)){let e,t;if("@"===n[2])e=n[0],t="mailto:"+e;else{let r;do{r=n[0],n[0]=this.rules.inline._backpedal.exec(n[0])?.[0]??""}while(r!==n[0]);e=n[0],t="www."===n[1]?"http://"+n[0]:n[0]}return{type:"link",raw:n[0],text:e,href:t,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){let n=this.rules.inline.text.exec(e);if(n){let e=this.lexer.state.inRawBlock;return{type:"text",raw:n[0],text:n[0],escaped:e}}}},Ca=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||_i,this.options.tokenizer=this.options.tokenizer||new Sa,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:Si,block:fa.normal,inline:ma.normal};this.options.pedantic?(n.block=fa.pedantic,n.inline=ma.pedantic):this.options.gfm&&(n.block=fa.gfm,this.options.breaks?n.inline=ma.breaks:n.inline=ma.gfm),this.tokenizer.rules=n}static get rules(){return{block:fa,inline:ma}}static lex(n,t){return new e(t).lex(n)}static lexInline(n,t){return new e(t).inlineTokens(n)}lex(e){e=e.replace(Si.carriageReturn,"\n"),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let n=this.inlineQueue[e];this.inlineTokens(n.src,n.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],t=!1){for(this.options.pedantic&&(e=e.replace(Si.tabCharGlobal," ").replace(Si.spaceLine,""));e;){let r;if(this.options.extensions?.block?.some(t=>!!(r=t.call({lexer:this},e,n))&&(e=e.substring(r.raw.length),n.push(r),!0)))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let t=n.at(-1);1===r.raw.length&&void 0!==t?t.raw+="\n":n.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let t=n.at(-1);"paragraph"===t?.type||"text"===t?.type?(t.raw+=(t.raw.endsWith("\n")?"":"\n")+r.raw,t.text+="\n"+r.text,this.inlineQueue.at(-1).src=t.text):n.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let t=n.at(-1);"paragraph"===t?.type||"text"===t?.type?(t.raw+=(t.raw.endsWith("\n")?"":"\n")+r.raw,t.text+="\n"+r.raw,this.inlineQueue.at(-1).src=t.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},n.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),n.push(r);continue}let i=e;if(this.options.extensions?.startBlock){let n,t=1/0,r=e.slice(1);this.options.extensions.startBlock.forEach(e=>{n=e.call({lexer:this},r),"number"==typeof n&&n>=0&&(t=Math.min(t,n))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(this.state.top&&(r=this.tokenizer.paragraph(i))){let a=n.at(-1);t&&"paragraph"===a?.type?(a.raw+=(a.raw.endsWith("\n")?"":"\n")+r.raw,a.text+="\n"+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):n.push(r),t=i.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let t=n.at(-1);"text"===t?.type?(t.raw+=(t.raw.endsWith("\n")?"":"\n")+r.raw,t.text+="\n"+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=t.text):n.push(r);continue}if(e){let n="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(n);break}throw new Error(n)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){let t,r=e,i=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(i=this.tokenizer.rules.inline.reflinkSearch.exec(r));)e.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(i=this.tokenizer.rules.inline.anyPunctuation.exec(r));)r=r.slice(0,i.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;null!=(i=this.tokenizer.rules.inline.blockSkip.exec(r));)t=i[2]?i[2].length:0,r=r.slice(0,i.index+t)+"["+"a".repeat(i[0].length-t-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let a=!1,l="";for(;e;){let t;if(a||(l=""),a=!1,this.options.extensions?.inline?.some(r=>!!(t=r.call({lexer:this},e,n))&&(e=e.substring(t.raw.length),n.push(t),!0)))continue;if(t=this.tokenizer.escape(e)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.tag(e)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.link(e)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(t.raw.length);let r=n.at(-1);"text"===t.type&&"text"===r?.type?(r.raw+=t.raw,r.text+=t.text):n.push(t);continue}if(t=this.tokenizer.emStrong(e,r,l)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.codespan(e)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.br(e)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.del(e)){e=e.substring(t.raw.length),n.push(t);continue}if(t=this.tokenizer.autolink(e)){e=e.substring(t.raw.length),n.push(t);continue}if(!this.state.inLink&&(t=this.tokenizer.url(e))){e=e.substring(t.raw.length),n.push(t);continue}let i=e;if(this.options.extensions?.startInline){let n,t=1/0,r=e.slice(1);this.options.extensions.startInline.forEach(e=>{n=e.call({lexer:this},r),"number"==typeof n&&n>=0&&(t=Math.min(t,n))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(t=this.tokenizer.inlineText(i)){e=e.substring(t.raw.length),"_"!==t.raw.slice(-1)&&(l=t.raw.slice(-1)),a=!0;let r=n.at(-1);"text"===r?.type?(r.raw+=t.raw,r.text+=t.text):n.push(t);continue}if(e){let n="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(n);break}throw new Error(n)}}return n}},Pa=class{options;parser;constructor(e){this.options=e||_i}space(e){return""}code({text:e,lang:n,escaped:t}){let r=(n||"").match(Si.notSpaceStart)?.[0],i=e.replace(Si.endingNewline,"")+"\n";return r?'<pre><code class="language-'+_a(r)+'">'+(t?i:_a(i,!0))+"</code></pre>\n":"<pre><code>"+(t?i:_a(i,!0))+"</code></pre>\n"}blockquote({tokens:e}){return`<blockquote>\n${this.parser.parse(e)}</blockquote>\n`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:n}){return`<h${n}>${this.parser.parseInline(e)}</h${n}>\n`}hr(e){return"<hr>\n"}list(e){let n=e.ordered,t=e.start,r="";for(let n=0;n<e.items.length;n++){let t=e.items[n];r+=this.listitem(t)}let i=n?"ol":"ul";return"<"+i+(n&&1!==t?' start="'+t+'"':"")+">\n"+r+"</"+i+">\n"}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>\n`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>\n`}table(e){let n="",t="";for(let n=0;n<e.header.length;n++)t+=this.tablecell(e.header[n]);n+=this.tablerow({text:t});let r="";for(let n=0;n<e.rows.length;n++){let i=e.rows[n];t="";for(let e=0;e<i.length;e++)t+=this.tablecell(i[e]);r+=this.tablerow({text:t})}return r&&(r=`<tbody>${r}</tbody>`),"<table>\n<thead>\n"+n+"</thead>\n"+r+"</table>\n"}tablerow({text:e}){return`<tr>\n${e}</tr>\n`}tablecell(e){let n=this.parser.parseInline(e.tokens),t=e.header?"th":"td";return(e.align?`<${t} align="${e.align}">`:`<${t}>`)+n+`</${t}>\n`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${_a(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:n,tokens:t}){let r=this.parser.parseInline(t),i=xa(e);if(null===i)return r;let a='<a href="'+(e=i)+'"';return n&&(a+=' title="'+_a(n)+'"'),a+=">"+r+"</a>",a}image({href:e,title:n,text:t,tokens:r}){r&&(t=this.parser.parseInline(r,this.parser.textRenderer));let i=xa(e);if(null===i)return _a(t);let a=`<img src="${e=i}" alt="${t}"`;return n&&(a+=` title="${_a(n)}"`),a+=">",a}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:_a(e.text)}},Ea=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},Ta=class e{options;renderer;textRenderer;constructor(e){this.options=e||_i,this.options.renderer=this.options.renderer||new Pa,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ea}static parse(n,t){return new e(t).parse(n)}static parseInline(n,t){return new e(t).parseInline(n)}parse(e){let n="";for(let t=0;t<e.length;t++){let r=e[t];if(this.options.extensions?.renderers?.[r.type]){let e=r,t=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==t||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(e.type)){n+=t||"";continue}}let i=r;switch(i.type){case"space":n+=this.renderer.space(i);break;case"hr":n+=this.renderer.hr(i);break;case"heading":n+=this.renderer.heading(i);break;case"code":n+=this.renderer.code(i);break;case"table":n+=this.renderer.table(i);break;case"blockquote":n+=this.renderer.blockquote(i);break;case"list":n+=this.renderer.list(i);break;case"checkbox":n+=this.renderer.checkbox(i);break;case"html":n+=this.renderer.html(i);break;case"def":n+=this.renderer.def(i);break;case"paragraph":n+=this.renderer.paragraph(i);break;case"text":n+=this.renderer.text(i);break;default:{let e='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}parseInline(e,n=this.renderer){let t="";for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){t+=e||"";continue}}let a=i;switch(a.type){case"escape":case"text":t+=n.text(a);break;case"html":t+=n.html(a);break;case"link":t+=n.link(a);break;case"image":t+=n.image(a);break;case"checkbox":t+=n.checkbox(a);break;case"strong":t+=n.strong(a);break;case"em":t+=n.em(a);break;case"codespan":t+=n.codespan(a);break;case"br":t+=n.br(a);break;case"del":t+=n.del(a);break;default:{let e='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return t}},Ia=class{options;block;constructor(e){this.options=e||_i}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?Ca.lex:Ca.lexInline}provideParser(){return this.block?Ta.parse:Ta.parseInline}},$a=new class{defaults={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Ta;Renderer=Pa;TextRenderer=Ea;Lexer=Ca;Tokenizer=Sa;Hooks=Ia;constructor(...e){this.use(...e)}walkTokens(e,n){let t=[];for(let r of e)switch(t=t.concat(n.call(this,r)),r.type){case"table":{let e=r;for(let r of e.header)t=t.concat(this.walkTokens(r.tokens,n));for(let r of e.rows)for(let e of r)t=t.concat(this.walkTokens(e.tokens,n));break}case"list":{let e=r;t=t.concat(this.walkTokens(e.items,n));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);t=t.concat(this.walkTokens(i,n))}):e.tokens&&(t=t.concat(this.walkTokens(e.tokens,n)))}}return t}use(...e){let n=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let t={...e};if(t.async=this.defaults.async||t.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){let t=n.renderers[e.name];n.renderers[e.name]=t?function(...n){let r=e.renderer.apply(this,n);return!1===r&&(r=t.apply(this,n)),r}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");let t=n[e.level];t?t.unshift(e.tokenizer):n[e.level]=[e.tokenizer],e.start&&("block"===e.level?n.startBlock?n.startBlock.push(e.start):n.startBlock=[e.start]:"inline"===e.level&&(n.startInline?n.startInline.push(e.start):n.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(n.childTokens[e.name]=e.childTokens)}),t.extensions=n),e.renderer){let n=this.defaults.renderer||new Pa(this.defaults);for(let t in e.renderer){if(!(t in n))throw new Error(`renderer '${t}' does not exist`);if(["options","parser"].includes(t))continue;let r=t,i=e.renderer[r],a=n[r];n[r]=(...e)=>{let t=i.apply(n,e);return!1===t&&(t=a.apply(n,e)),t||""}}t.renderer=n}if(e.tokenizer){let n=this.defaults.tokenizer||new Sa(this.defaults);for(let t in e.tokenizer){if(!(t in n))throw new Error(`tokenizer '${t}' does not exist`);if(["options","rules","lexer"].includes(t))continue;let r=t,i=e.tokenizer[r],a=n[r];n[r]=(...e)=>{let t=i.apply(n,e);return!1===t&&(t=a.apply(n,e)),t}}t.tokenizer=n}if(e.hooks){let n=this.defaults.hooks||new Ia;for(let t in e.hooks){if(!(t in n))throw new Error(`hook '${t}' does not exist`);if(["options","block"].includes(t))continue;let r=t,i=e.hooks[r],a=n[r];Ia.passThroughHooks.has(t)?n[r]=e=>{if(this.defaults.async&&Ia.passThroughHooksRespectAsync.has(t))return(async()=>{let t=await i.call(n,e);return a.call(n,t)})();let r=i.call(n,e);return a.call(n,r)}:n[r]=(...e)=>{if(this.defaults.async)return(async()=>{let t=await i.apply(n,e);return!1===t&&(t=await a.apply(n,e)),t})();let t=i.apply(n,e);return!1===t&&(t=a.apply(n,e)),t}}t.hooks=n}if(e.walkTokens){let n=this.defaults.walkTokens,r=e.walkTokens;t.walkTokens=function(e){let t=[];return t.push(r.call(this,e)),n&&(t=t.concat(n.call(this,e))),t}}this.defaults={...this.defaults,...t}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,n){return Ca.lex(e,n??this.defaults)}parser(e,n){return Ta.parse(e,n??this.defaults)}parseMarkdown(e){return(n,t)=>{let r={...t},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(!0===this.defaults.async&&!1===r.async)return a(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||null===n)return a(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof n)return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let t=i.hooks?await i.hooks.preprocess(n):n,r=await(i.hooks?await i.hooks.provideLexer():e?Ca.lex:Ca.lexInline)(t,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let l=await(i.hooks?await i.hooks.provideParser():e?Ta.parse:Ta.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(l):l})().catch(a);try{i.hooks&&(n=i.hooks.preprocess(n));let t=(i.hooks?i.hooks.provideLexer():e?Ca.lex:Ca.lexInline)(n,i);i.hooks&&(t=i.hooks.processAllTokens(t)),i.walkTokens&&this.walkTokens(t,i.walkTokens);let r=(i.hooks?i.hooks.provideParser():e?Ta.parse:Ta.parseInline)(t,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,n){return t=>{if(t.message+="\nPlease report this to https://github.com/markedjs/marked.",e){let e="<p>An error occurred:</p><pre>"+_a(t.message+"",!0)+"</pre>";return n?Promise.resolve(e):e}if(n)return Promise.reject(t);throw t}}};function Ma(e,n){return $a.parse(e,n)}function Aa({title:e,defaultOpen:n=!1,children:t}){const[r,i]=Ie(n),a=Me(null);return ge("div",{class:"_pillar-collapsible pillar-collapsible",children:[ge("button",{type:"button",class:"_pillar-collapsible-header pillar-collapsible-header",onClick:()=>i(!r),children:[ge("span",{class:"_pillar-collapsible-icon pillar-collapsible-icon",style:{transform:r?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.2s ease"},children:"▶"}),ge("span",{class:"_pillar-collapsible-title pillar-collapsible-title",children:e})]}),ge("div",{class:"_pillar-collapsible-content-wrapper pillar-collapsible-content-wrapper "+(r?"_pillar-collapsible-content-wrapper--expanded pillar-collapsible-content-wrapper--expanded":""),children:ge("div",{ref:a,class:"_pillar-collapsible-content pillar-collapsible-content",children:t})})]})}function za({sources:e}){return e&&0!==e.length?ge("div",{class:"_pillar-source-list pillar-source-list",children:e.map((e,n)=>ge("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",class:"_pillar-source-item pillar-source-item",children:ge("span",{class:"_pillar-source-title pillar-source-title",children:e.title})},n))}):ge("span",{})}function Ra({language:e,children:n}){const[t,r]=Ie(!1);return ge("div",{class:"_pillar-code-block pillar-code-block",children:[e&&ge("div",{class:"_pillar-code-header pillar-code-header",children:[ge("span",{class:"_pillar-code-language pillar-code-language",children:e}),ge("button",{type:"button",class:"_pillar-code-copy pillar-code-copy",onClick:async()=>{try{await navigator.clipboard.writeText(n),r(!0),setTimeout(()=>r(!1),2e3)}catch(e){p.error("[Pillar] Failed to copy code:",e)}},children:t?"Copied!":"Copy"})]}),ge("pre",{class:`_pillar-code-pre pillar-code-pre language-${e||"text"}`,children:ge("code",{class:"_pillar-code-content pillar-code-content",children:n})})]})}function La({message:e,isActive:n=!0}){return ge("div",{class:"_pillar-progress-indicator pillar-progress-indicator "+(n?"_pillar-progress-indicator--active pillar-progress-indicator--active":""),children:[n&&ge("div",{class:"_pillar-loading-spinner pillar-loading-spinner"}),ge("span",{class:"_pillar-progress-message pillar-progress-message",children:e})]})}Ma.options=Ma.setOptions=function(e){return $a.setOptions(e),Ma.defaults=$a.defaults,xi(Ma.defaults),Ma},Ma.getDefaults=vi,Ma.defaults=_i,Ma.use=function(...e){return $a.use(...e),Ma.defaults=$a.defaults,xi(Ma.defaults),Ma},Ma.walkTokens=function(e,n){return $a.walkTokens(e,n)},Ma.parseInline=$a.parseInline,Ma.Parser=Ta,Ma.parser=Ta.parse,Ma.Renderer=Pa,Ma.TextRenderer=Ea,Ma.Lexer=Ca,Ma.lexer=Ca.lex,Ma.Tokenizer=Sa,Ma.Hooks=Ia,Ma.parse=Ma,Ma.options,Ma.setOptions,Ma.use,Ma.walkTokens,Ma.parseInline,Ta.parse,Ca.lex;const Oa="\n/* Collapsible Section */\n._pillar-collapsible {\n margin: 2px 0;\n}\n\n._pillar-collapsible-header {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 4px 0;\n background: transparent;\n border: none;\n border-radius: 4px;\n cursor: pointer;\n font-size: 13px;\n font-weight: 500;\n color: var(--pillar-text-secondary, #6b7280);\n font-family: inherit;\n width: 100%;\n text-align: left;\n transition: background-color 0.15s ease;\n}\n\n._pillar-collapsible-header:hover {\n background: var(--pillar-bg-hover, rgba(0, 0, 0, 0.05));\n}\n\n._pillar-collapsible-icon {\n font-size: 10px;\n color: var(--pillar-text-muted, #9ca3af);\n}\n\n._pillar-collapsible-title {\n flex: 1;\n}\n\n._pillar-collapsible-content-wrapper {\n display: grid;\n grid-template-rows: 0fr;\n transition: grid-template-rows 0.2s ease;\n}\n\n._pillar-collapsible-content-wrapper--expanded {\n grid-template-rows: 1fr;\n}\n\n._pillar-collapsible-content {\n overflow: hidden;\n padding-left: 18px;\n font-size: 13px;\n color: var(--pillar-text-secondary, #6b7280);\n line-height: 1.4;\n}\n\n._pillar-collapsible-content-wrapper--expanded ._pillar-collapsible-content {\n padding-top: 2px;\n padding-bottom: 4px;\n}\n\n/* Source List */\n._pillar-source-list {\n display: flex;\n flex-direction: column;\n gap: 4px;\n margin: 4px 0;\n}\n\n._pillar-source-item {\n display: block;\n padding: 4px 8px;\n font-size: 12px;\n color: var(--pillar-primary, #2563eb);\n text-decoration: none;\n border-radius: 4px;\n transition: background-color 0.15s ease;\n}\n\n._pillar-source-item:hover {\n background: var(--pillar-bg-hover, rgba(0, 0, 0, 0.05));\n text-decoration: underline;\n}\n\n/* Task List */\n._pillar-task-list {\n list-style: none;\n padding: 0;\n margin: 8px 0;\n}\n\n._pillar-task-item {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 4px 0;\n font-size: 13px;\n}\n\n._pillar-task-item--completed ._pillar-task-text {\n text-decoration: line-through;\n color: var(--pillar-text-placeholder, #9ca3af);\n}\n\n._pillar-task-checkbox {\n width: 16px;\n height: 16px;\n cursor: pointer;\n}\n\n/* Code Block */\n._pillar-code-block {\n margin: 8px 0;\n border-radius: 8px;\n overflow: hidden;\n background: var(--pillar-bg-code, #1e1e1e);\n}\n\n._pillar-code-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 8px 12px;\n background: var(--pillar-bg-code-header, #2d2d2d);\n border-bottom: 1px solid var(--pillar-border-code, #404040);\n}\n\n._pillar-code-language {\n font-size: 11px;\n font-weight: 500;\n color: var(--pillar-text-code-header, #a0a0a0);\n text-transform: uppercase;\n}\n\n._pillar-code-copy {\n padding: 4px 8px;\n font-size: 11px;\n font-family: inherit;\n background: transparent;\n border: 1px solid var(--pillar-border-code, #404040);\n border-radius: 4px;\n color: var(--pillar-text-code-header, #a0a0a0);\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n._pillar-code-copy:hover {\n background: var(--pillar-bg-code-hover, #404040);\n color: #fff;\n}\n\n._pillar-code-pre {\n margin: 0;\n padding: 12px;\n overflow-x: auto;\n font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;\n font-size: 13px;\n line-height: 1.5;\n}\n\n._pillar-code-content {\n color: var(--pillar-text-code, #e0e0e0);\n}\n\n/* Action Buttons */\n._pillar-action-buttons {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n margin: 8px 0;\n}\n\n._pillar-action-button {\n padding: 8px 16px;\n font-size: 13px;\n font-weight: 500;\n font-family: inherit;\n background: var(--pillar-primary, #2563eb);\n color: #fff;\n border: none;\n border-radius: 6px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n._pillar-action-button:hover {\n background: var(--pillar-primary-hover, #1d4ed8);\n}\n\n/* Progress Indicator */\n._pillar-progress-indicator {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 4px 0;\n font-size: 13px;\n color: var(--pillar-text-secondary, #6b7280);\n}\n\n._pillar-progress-indicator--active ._pillar-loading-spinner {\n display: inline-block;\n}\n\n/* Streaming Thinking Content */\n._pillar-progress-row--streaming {\n margin: 2px 0;\n}\n\n._pillar-thinking-header {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 4px 0;\n font-size: 13px;\n font-weight: 500;\n color: var(--pillar-text-secondary, #6b7280);\n}\n\n._pillar-thinking-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 16px;\n height: 16px;\n}\n\n._pillar-spinner {\n width: 12px;\n height: 12px;\n border: 2px solid var(--pillar-border, #e5e7eb);\n border-top-color: var(--pillar-primary, #2563eb);\n border-radius: 50%;\n animation: pillar-spin 0.8s linear infinite;\n}\n\n@keyframes pillar-spin {\n to { transform: rotate(360deg); }\n}\n\n._pillar-thinking-label {\n flex: 1;\n}\n\n._pillar-thinking-content {\n padding: 6px 10px;\n font-size: 13px;\n line-height: 1.4;\n color: var(--pillar-text-secondary, #6b7280);\n background: var(--pillar-bg-tertiary, #f9fafb);\n border-radius: 4px;\n margin-top: 2px;\n max-height: 150px;\n overflow-y: auto;\n}\n";function Da({content:e,class:n}){if(!e||!e.trim())return ge("span",{});try{return ge("div",{class:`_pillar-markdown pillar-markdown ${n||""}`,children:Ha(Ma.lexer(e))})}catch(t){return p.error("[Pillar] Markdown parsing error:",t),ge("div",{class:`_pillar-markdown pillar-markdown ${n||""}`,children:e})}}function Ha(e){return e.map((e,n)=>function(e,n){switch(e.type){case"heading":return function(e,n){const t=`h${e.depth}`;return ge(t,{class:`_pillar-md-heading _pillar-md-h${e.depth} pillar-md-heading pillar-md-h${e.depth}`,children:ja(e.tokens)},n)}(e,n);case"paragraph":return function(e,n){return ge("p",{class:"_pillar-md-paragraph pillar-md-paragraph",children:ja(e.tokens)},n)}(e,n);case"text":return function(e,n){if(e.tokens&&e.tokens.length>0)return ge(V,{children:ja(e.tokens)},n);return ge(V,{children:e.text},n)}(e,n);case"code":return function(e,n){const t=e.lang||"",r=e.text;if(t.startsWith("collapsible:")){return ge(Aa,{title:t.substring(12),children:ge(Da,{content:r})},n)}if(t.startsWith("collapsible-open:")){return ge(Aa,{title:t.substring(17),defaultOpen:!0,children:ge(Da,{content:r})},n)}if("sources"===t)try{return ge(za,{sources:JSON.parse(r)},n)}catch{p.warn("[Pillar] Failed to parse sources JSON")}if(t.startsWith("progress:")){return ge(La,{message:t.substring(9),isActive:!0},n)}if(t.startsWith("progress-done:")){return ge(La,{message:t.substring(14),isActive:!1},n)}return ge(Ra,{language:t||void 0,children:r},n)}(e,n);case"blockquote":return function(e,n){return ge("blockquote",{class:"_pillar-md-blockquote pillar-md-blockquote",children:Ha(e.tokens)},n)}(e,n);case"list":return function(e,n){const t=e.items.map((e,n)=>Ua(e,n));if(e.ordered)return ge("ol",{start:e.start||1,class:"_pillar-md-list _pillar-md-list--ordered pillar-md-list pillar-md-list--ordered",children:t},n);return ge("ul",{class:"_pillar-md-list _pillar-md-list--unordered pillar-md-list pillar-md-list--unordered",children:t},n)}(e,n);case"list_item":return Ua(e,n);case"table":return function(e,n){return ge("div",{class:"_pillar-md-table-wrapper pillar-md-table-wrapper",children:ge("table",{class:"_pillar-md-table pillar-md-table",children:[ge("thead",{children:ge("tr",{children:e.header.map((n,t)=>ge("th",{style:e.align[t]?{textAlign:e.align[t]}:void 0,class:"_pillar-md-th pillar-md-th",children:ja(n.tokens)},t))})}),ge("tbody",{children:e.rows.map((n,t)=>ge("tr",{children:n.map((n,t)=>ge("td",{style:e.align[t]?{textAlign:e.align[t]}:void 0,class:"_pillar-md-td pillar-md-td",children:ja(n.tokens)},t))},t))})]})},n)}(e,n);case"hr":return ge("hr",{class:"_pillar-md-hr pillar-md-hr"},n);case"space":return null;case"html":return function(e,n){const t=e.raw.match(/<(\w+)\s*([^>]*)\/?\s*>/);if(t){const[,e,r]=t,i=function(e){const n={},t=/(\w+)=["']([^"']*)["']/g;let r;for(;null!==(r=t.exec(e));)n[r[1]]=r[2];return n}(r);switch(e){case"SourceList":if(i.sources)try{return ge(za,{sources:JSON.parse(i.sources)},n)}catch{p.warn("[Pillar] Failed to parse SourceList sources")}break;case"Progress":return ge(La,{message:i.message||"Processing...",isActive:"false"!==i.active},n);case"Collapsible":return ge(Aa,{title:i.title||"Details",defaultOpen:"true"===i.open,children:i.content?ge(Da,{content:i.content}):null},n)}}return ge("span",{dangerouslySetInnerHTML:{__html:e.raw}},n)}(e,n);case"strong":return ge("strong",{children:ja(e.tokens)},n);case"em":return ge("em",{children:ja(e.tokens)},n);case"codespan":return ge("code",{class:"_pillar-md-code-inline pillar-md-code-inline",children:e.text},n);case"link":const t=e;return ge("a",{href:t.href,title:t.title||void 0,target:"_blank",rel:"noopener noreferrer",class:"_pillar-md-link pillar-md-link",children:ja(t.tokens)},n);case"image":const r=e;return ge("img",{src:r.href,alt:r.text,title:r.title||void 0,class:"_pillar-md-image pillar-md-image"},n);case"br":return ge("br",{},n);case"del":return ge("del",{children:ja(e.tokens)},n);default:return"raw"in e&&"string"==typeof e.raw?ge("span",{children:e.raw},n):null}}(e,n)).filter(Boolean)}function Ua(e,n){return e.task?ge("li",{class:"_pillar-md-list-item _pillar-md-task-item pillar-md-list-item pillar-md-task-item",children:[ge("input",{type:"checkbox",checked:e.checked,disabled:!0,class:"_pillar-md-task-checkbox pillar-md-task-checkbox"}),ge("span",{class:e.checked?"_pillar-md-task-text--checked pillar-md-task-text--checked":"",children:Ha(e.tokens)})]},n):ge("li",{class:"_pillar-md-list-item pillar-md-list-item",children:Ha(e.tokens)},n)}function ja(e){return e&&0!==e.length?e.map((e,n)=>{switch(e.type){case"text":case"escape":return e.text;case"strong":return ge("strong",{children:ja(e.tokens)},n);case"em":return ge("em",{children:ja(e.tokens)},n);case"codespan":return ge("code",{class:"_pillar-md-code-inline pillar-md-code-inline",children:e.text},n);case"link":const t=e;return ge("a",{href:t.href,title:t.title||void 0,target:"_blank",rel:"noopener noreferrer",class:"_pillar-md-link pillar-md-link",children:ja(t.tokens)},n);case"image":const r=e;return ge("img",{src:r.href,alt:r.text,title:r.title||void 0,class:"_pillar-md-image pillar-md-image"},n);case"br":return ge("br",{},n);case"del":return ge("del",{children:ja(e.tokens)},n);default:return"raw"in e&&"string"==typeof e.raw?e.raw:null}}):null}const qa="\n/* Base markdown container */\n._pillar-markdown {\n font-size: 14px;\n line-height: 1.6;\n color: var(--pillar-text, #1a1a1a);\n}\n\n/* Headings */\n._pillar-md-heading {\n margin: 16px 0 8px 0;\n font-weight: 600;\n line-height: 1.3;\n}\n\n._pillar-md-h1 { font-size: 1.5em; }\n._pillar-md-h2 { font-size: 1.3em; }\n._pillar-md-h3 { font-size: 1.15em; }\n._pillar-md-h4 { font-size: 1em; }\n._pillar-md-h5 { font-size: 0.95em; }\n._pillar-md-h6 { font-size: 0.9em; }\n\n/* Paragraphs */\n._pillar-md-paragraph {\n margin: 8px 0;\n}\n\n/* Links */\n._pillar-md-link {\n color: var(--pillar-primary, #2563eb);\n text-decoration: none;\n}\n\n._pillar-md-link:hover {\n text-decoration: underline;\n}\n\n/* Inline code */\n._pillar-md-code-inline {\n padding: 2px 6px;\n font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;\n font-size: 0.9em;\n background: var(--pillar-bg-code-inline, #f3f4f6);\n border-radius: 4px;\n}\n\n/* Lists */\n._pillar-md-list {\n margin: 8px 0;\n padding-left: 24px;\n}\n\n._pillar-md-list-item {\n margin: 4px 0;\n}\n\n/* Task list items */\n._pillar-md-task-item {\n display: flex;\n align-items: flex-start;\n gap: 8px;\n list-style: none;\n margin-left: -24px;\n}\n\n._pillar-md-task-checkbox {\n margin-top: 4px;\n}\n\n._pillar-md-task-text--checked {\n text-decoration: line-through;\n color: var(--pillar-text-placeholder, #9ca3af);\n}\n\n/* Blockquote */\n._pillar-md-blockquote {\n margin: 8px 0;\n padding: 8px 16px;\n border-left: 3px solid var(--pillar-border, #e5e7eb);\n color: var(--pillar-text-muted, #6b7280);\n background: var(--pillar-bg-secondary, #f9fafb);\n}\n\n/* Horizontal rule */\n._pillar-md-hr {\n margin: 16px 0;\n border: none;\n border-top: 1px solid var(--pillar-border, #e5e7eb);\n}\n\n/* Tables */\n._pillar-md-table-wrapper {\n overflow-x: auto;\n margin: 8px 0;\n}\n\n._pillar-md-table {\n width: 100%;\n border-collapse: collapse;\n font-size: 13px;\n}\n\n._pillar-md-th,\n._pillar-md-td {\n padding: 8px 12px;\n border: 1px solid var(--pillar-border, #e5e7eb);\n text-align: left;\n}\n\n._pillar-md-th {\n background: var(--pillar-bg-secondary, #f9fafb);\n font-weight: 600;\n}\n\n/* Images */\n._pillar-md-image {\n max-width: 100%;\n height: auto;\n border-radius: 8px;\n margin: 8px 0;\n}\n";function Ba({progress:e,isActive:n=!1,isLast:t=!1,responseStarted:r=!1,nested:i=!1}){const a="active"===e.status||void 0===e.status&&n,l="error"===e.status||"query_failed"===e.kind,o="thinking"===e.kind||"step_start"===e.kind,s=function(e,n=50){const[t,r]=Ie(e);return $e(()=>{const t=setTimeout(()=>{r(e)},n);return()=>{clearTimeout(t)}},[e,n]),t}(e.text,50),[c,p]=Ie(0);$e(()=>{if(!o||!a)return;const n=e.metadata?._startTime||Date.now();p(Math.max(1,Math.round((Date.now()-n)/1e3)));const t=setInterval(()=>{p(Math.round((Date.now()-n)/1e3))},1e3);return()=>clearInterval(t)},[o,a,e.metadata]);const d=Boolean(e.text),u=e.children&&e.children.length>0,h=e.metadata?.sources,g="search_complete"===e.kind&&h&&h.length>0,f=!0===e.metadata?.no_sources_used,m=d||u||g&&!f,b=e.metadata?.result_count,v="search"===e.kind&&0===b,[_,x]=Ie(!1),[y,w]=Ie(!1),k=m&&(_?y:i?a||t:a||t&&!r),S=Me(null),[C,P]=Ie(!1),[E,T]=Ie(!1);$e(()=>{x(!1)},[a]),$e(()=>{T(!1)},[e.id,e.progress_id]),$e(()=>{S.current&&a&&e.text&&!E&&(S.current.scrollTop=S.current.scrollHeight)},[e.text,a,E]);const I=()=>{m&&(x(!0),w(!k))},$=k?"rotate(90deg)":"rotate(0deg)";if(!(e.label||e.message||e.text||u||g||o))return null;const M=(()=>{if(o){if(a)return c>0?`Thought for ${c}s`:"Thinking...";const n=e.metadata?._durationSeconds,t=n||c;return t>0?`Thought for ${t}s`:"Thought"}return e.label||e.message||function(e){switch(e){case"processing":return"Processing...";case"search":return"Searching...";case"search_complete":return"Search complete";case"query":return"Executing action...";case"query_complete":return"Action complete";case"query_failed":return"Action failed";case"generating":return"Generating answer...";case"thinking":case"step_start":return"Thinking...";case"step_complete":return"Done";case"tool_call":return"Running tool...";case"plan":return"Planning...";default:return"Working..."}}(e.kind)})();return ge("div",{class:`_pillar-progress-row pillar-progress-row${l?" _pillar-progress-row--error pillar-progress-row--error":""}${a?" _pillar-progress-row--active pillar-progress-row--active":""}${t?" _pillar-progress-row--last pillar-progress-row--last":""}${i?" _pillar-progress-row--nested pillar-progress-row--nested":""}`,role:"status","aria-live":a?"polite":"off","aria-label":`${M}: ${a?"in progress":l?"error":"complete"}`,children:[ge("div",{class:"_pillar-progress-row-header pillar-progress-row-header",onClick:I,style:{cursor:m?"pointer":"default"},"data-expanded":k,role:m?"button":void 0,"aria-expanded":m?k:void 0,tabIndex:m?0:void 0,onKeyDown:m?e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),I())}:void 0,children:[l&&ge("span",{class:"_pillar-progress-error-icon pillar-progress-error-icon","aria-label":"Error",children:"✗"}),ge("span",{class:"_pillar-progress-message pillar-progress-message",children:M}),v&&ge("span",{class:"_pillar-progress-no-results pillar-progress-no-results",children:"— no relevant results"}),m&&!l&&ge("span",{class:"_pillar-progress-chevron pillar-progress-chevron",style:{transform:$,transition:"transform 0.2s ease, opacity 0.15s ease"},"aria-hidden":"true",children:"▶"})]}),m&&ge("div",{class:"_pillar-progress-content-wrapper pillar-progress-content-wrapper "+(k?"_pillar-progress-content-wrapper--expanded pillar-progress-content-wrapper--expanded":""),children:ge("div",{class:"_pillar-progress-content-container pillar-progress-content-container",children:[d&&ge("div",{class:"_pillar-progress-text-preview-wrapper pillar-progress-text-preview-wrapper",children:[C&&ge("div",{class:"_pillar-progress-text-gradient pillar-progress-text-gradient"}),ge("div",{ref:S,class:"_pillar-progress-text-preview pillar-progress-text-preview",onScroll:()=>{if(S.current){const{scrollTop:e,scrollHeight:n,clientHeight:t}=S.current;T(!(e>=n-t-5)),P(e>0)}},children:ge(Da,{content:s||""})})]}),u?ge("div",{class:"_pillar-progress-children pillar-progress-children",children:e.children.map((e,n)=>ge("div",{class:"_pillar-progress-child-item pillar-progress-child-item",children:e.url?ge("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",class:"_pillar-progress-child-link pillar-progress-child-link",children:e.label}):ge("span",{class:"_pillar-progress-child-label pillar-progress-child-label",children:e.label})},e.id||n))}):g?ge("div",{class:"_pillar-progress-sources pillar-progress-sources",children:h.map((e,n)=>ge("div",{class:"_pillar-progress-source-item pillar-progress-source-item",children:ge("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",class:"_pillar-progress-source-link pillar-progress-source-link",children:ge("span",{class:"_pillar-progress-source-title pillar-progress-source-title",children:e.title})})},n))}):null]})})]})}function Na({events:e,summary:n,isLast:t=!1,responseStarted:r=!1}){const i=e.some(e=>"active"===e.status),[a,l]=Ie(!1),[o,s]=Ie(!1),c=a?o:i||t&&!r;$e(()=>{i&&l(!1)},[i]);const p=()=>{l(!0),s(!c)};return ge("div",{class:`_pillar-progress-group pillar-progress-group${i?" _pillar-progress-group--active pillar-progress-group--active":""}${t?" _pillar-progress-group--last pillar-progress-group--last":""}`,children:[ge("div",{class:"_pillar-progress-group-header pillar-progress-group-header",onClick:p,role:"button","aria-expanded":c,tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),p())},children:[ge("span",{class:"_pillar-progress-group-chevron pillar-progress-group-chevron",style:{transform:c?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.2s ease"},"aria-hidden":"true",children:"▶"}),ge("span",{class:"_pillar-progress-group-summary pillar-progress-group-summary",children:n}),i&&ge("span",{class:"_pillar-progress-group-active-dot pillar-progress-group-active-dot"})]}),ge("div",{class:"_pillar-progress-group-children pillar-progress-group-children "+(c?"_pillar-progress-group-children--expanded pillar-progress-group-children--expanded":""),children:ge("div",{class:"_pillar-progress-group-children-inner pillar-progress-group-children-inner",children:e.map((n,t)=>ge(Ba,{progress:n,isActive:"active"===n.status,isLast:t===e.length-1,responseStarted:r,nested:!0},n.id||n.progress_id||t))})})]})}const Fa=new Set(["search","search_complete","tool_call","plan","generating","query","query_complete","query_failed","step_complete","processing"]);const Wa=new Set(["search_complete","query_complete","step_complete"]);function Ka(e){const n=e.filter(e=>!Wa.has(e.kind));if(1===n.length&&n[0].label)return n[0].label;let t=0,r=0;for(const n of e)switch(n.kind){case"search":case"search_complete":break;case"query":case"query_complete":case"query_failed":case"tool_call":t++;break;default:r++}const i=e.filter(e=>"search_complete"===e.kind).length,a=e.filter(e=>"search"===e.kind).length,l=Math.max(i,a),o=[];return l>0&&o.push(`Searched ${l} ${1===l?"source":"sources"}`),t>0&&o.push(`Ran ${t} ${1===t?"action":"actions"}`),r>0&&0===o.length&&o.push(`${r} ${1===r?"step":"steps"}`),o.length>0?o.join(", "):`${e.length} steps`}function Va({events:e,responseStarted:n=!1}){if(!e||0===e.length)return null;const t=function(e){const n=[];let t=[];const r=()=>{t.length>0&&(n.push({type:"tool_group",events:[...t],summary:Ka(t)}),t=[])};for(const i of e)"thinking"===i.kind||"step_start"===i.kind?(r(),n.push({type:"thinking",event:i})):(Fa.has(i.kind),t.push(i));return r(),n}(e);return ge("div",{class:"_pillar-progress-stack pillar-progress-stack",children:t.flatMap((e,r)=>{if("thinking"===e.type)return[ge(Ba,{progress:e.event,isActive:"active"===e.event.status,isLast:r===t.length-1,responseStarted:n},e.event.id||e.event.progress_id||`thinking-${r}`)];const i=e.events.filter(e=>!Wa.has(e.kind));return i.length<=2?e.events.map((i,a)=>ge(Ba,{progress:i,isActive:"active"===i.status,isLast:r===t.length-1&&a===e.events.length-1,responseStarted:n},i.id||i.progress_id||`flat-${r}-${a}`)):[ge(Na,{events:e.events,summary:e.summary,isLast:r===t.length-1,responseStarted:n},`group-${r}`)]})})}function Ga({session:e,onResume:n,onDiscard:t,isResuming:r=!1}){return ge("div",e.elapsedMs<15e3||r?{class:"_pillar-resume-prompt _pillar-resume-prompt--seamless pillar-resume-prompt",children:[ge("div",{class:"_pillar-resume-prompt-spinner pillar-resume-prompt-spinner"}),ge("span",{class:"_pillar-resume-prompt-text pillar-resume-prompt-text",children:"Resuming conversation..."})]}:{class:"_pillar-resume-prompt pillar-resume-prompt",children:[ge("div",{class:"_pillar-resume-prompt-content pillar-resume-prompt-content",children:[ge("div",{class:"_pillar-resume-prompt-icon pillar-resume-prompt-icon",children:ge("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[ge("circle",{cx:"12",cy:"12",r:"10"}),ge("polyline",{points:"12 6 12 12 16 14"})]})}),ge("div",{class:"_pillar-resume-prompt-body pillar-resume-prompt-body",children:[ge("div",{class:"_pillar-resume-prompt-title pillar-resume-prompt-title",children:"Session Interrupted"}),ge("div",{class:"_pillar-resume-prompt-message pillar-resume-prompt-message",children:[e.userMessage&&ge("span",{class:"_pillar-resume-prompt-user-msg pillar-resume-prompt-user-msg",children:['"',Za(e.userMessage,50),'"']}),e.summary&&ge("span",{class:"_pillar-resume-prompt-summary pillar-resume-prompt-summary",children:e.summary})]})]})]}),ge("div",{class:"_pillar-resume-prompt-actions pillar-resume-prompt-actions",children:[ge("button",{type:"button",class:"_pillar-resume-prompt-btn _pillar-resume-prompt-btn--primary pillar-resume-prompt-btn",onClick:n,children:[ge("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",children:ge("polygon",{points:"5 3 19 12 5 21 5 3"})}),"Resume"]}),ge("button",{type:"button",class:"_pillar-resume-prompt-btn _pillar-resume-prompt-btn--ghost pillar-resume-prompt-btn",onClick:t,children:"Discard"})]})]})}function Za(e,n){return e.length<=n?e:e.slice(0,n)+"..."}function Qa(){const e=yr(),n=Me(null),t=Me(null),[r,i]=Ie(!1),a=ze(async()=>{const n=at.value;if(!n)return;const t=Fl.getInstance(),r=t?.config?.productKey??"",a=t?.isDOMScanningEnabled??!1;let l=[...vt.value];if(a){const e=bi(),n={id:Fn(),type:"dom_snapshot",url:e.url,title:e.title,content:e.content,interactableCount:e.interactableCount,timestamp:e.timestamp};l=[...l,n]}i(!0),Ot(!0),It("");try{let t="";await e.mcp.resumeConversation(n.conversationId,l.length>0?l:void 0,{onToken:e=>{t+=e,pt(e)},onProgress:e=>{Ut(e)},onComplete:()=>{p.log("[Pillar] Resume completed")},onError:e=>{p.error("[Pillar] Resume error:",e),$t("Sorry, failed to resume the conversation. Please try again.")},onRegisteredActions:()=>{}}),jt(),Yr(r)}catch(e){p.error("[Pillar] Resume error:",e),$t("Sorry, failed to resume the conversation. Please try again.")}finally{i(!1),Ot(!1),Dt()}},[e]),l=ze(()=>{const e=Fl.getInstance(),n=e?.config?.productKey??"";jt(),Yr(n)},[]);$e(()=>{const e=at.value;e&&e.elapsedMs<15e3&&a()},[at.value,a]),$e(()=>{n.current&&(n.current.scrollTop=n.current.scrollHeight)},[Gn.value]),$e(()=>{const e=Fl.getInstance();if(!e)return;return e.on("task:complete",({name:e,success:n})=>{At(e,n);const t=function(e,n){const t=e.replace(/_/g," ").toLowerCase();return n?t.startsWith("open ")?`Opened ${t.slice(5)}`:t.startsWith("go to ")?`Navigated to ${t.slice(6)}`:t.startsWith("navigate to ")?`Navigated to ${t.slice(12)}`:"Done!":`Failed to ${t}`}(e,n);zt(e,t)})},[]);const o=ze(e=>{const n=Fl.getInstance();p.log("[Pillar] handleActionsReceived called with",e.length,"actions"),p.log("[Pillar] Actions detail:",e.map(e=>({name:e.name,autoRun:e.autoRun})));const t=e.filter(e=>!0===e.autoRun),r=e.filter(e=>!e.autoRun);return p.log("[Pillar] Auto-run actions:",t.length,", Manual actions:",r.length),n&&t.length>0?(p.log("[Pillar] Executing auto-run actions..."),t.forEach(e=>{const t=e.data||{},r=t.path,i=t.url,a=Gn.value.length-1;a>=0&&Mt(a,e.name),p.log("[Pillar] Executing action:",e.name),n.executeTask({id:e.id,name:e.name,taskType:e.taskType,data:t,path:r,externalUrl:i})}),[]):n?r:(p.warn("[Pillar] No Pillar instance available for auto-run"),e)},[]),s=ze(async(n,r,i)=>{Tt(n,r,i),Ot(!0);const a=new AbortController;t.current=a,It("");try{let t="",l=[];const s=Gn.value.slice(0,-1),c=!Zn.value;c&&Rt(crypto.randomUUID());const d=await e.chat(n,s,e=>{t+=e,pt(e)},void 0,Zn.value,e=>{l=o(e)},r,i,e=>{Ut(e)},()=>{const e=Fl.getInstance(),n=e?.config?.productKey??"",t=Zn.value;n&&t&&Promise.resolve().then(function(){return ei}).then(({saveActiveSession:e})=>{e(t,n)})},async n=>{const t=performance.now(),r=(new Date).toISOString();p.log("[Pillar] Received action_request:",n.action_name,n.parameters,`at ${r}`);const i=Fl.getInstance();if(i)try{if("interact_with_page"===n.action_name){const r=n.parameters;Br(r.operation,n.tool_call_id);try{if(Kr())return await e.mcp.sendActionResult(n.action_name,{success:!1,error:"User cancelled action"},n.tool_call_id),void p.log("[Pillar] Page interaction cancelled by user before execution");const a=await i.handlePageInteraction(r);if(Kr())return await e.mcp.sendActionResult(n.action_name,{success:!1,error:"User cancelled action"},n.tool_call_id),void p.log("[Pillar] Page interaction cancelled by user after execution");let l=null;if(a.success&&i?.isDOMScanningEnabled){await new Promise(e=>setTimeout(e,150));l=bi().content,p.log("[Pillar] DOM rescanned after page interaction")}await e.mcp.sendActionResult(n.action_name,{...a,dom_snapshot:l},n.tool_call_id);const o=Math.round(performance.now()-t);p.log(`[Pillar] Page interaction "${r.operation}" completed in ${o}ms:`,a)}finally{Nr(),Wr()}return}const r=i.getHandler(n.action_name);let a;r?a=await Promise.resolve(r(n.parameters)):await i.executeTask({id:`action-${n.action_name}`,name:n.action_name,data:n.parameters}),await e.mcp.sendActionResult(n.action_name,{success:!0,result:a},n.tool_call_id);const l=Math.round(performance.now()-t);p.log(`[Pillar] Action "${n.action_name}" completed in ${l}ms`)}catch(r){const i=r instanceof Error?r.message:String(r);await e.mcp.sendActionResult(n.action_name,{success:!1,error:i},n.tool_call_id);const a=Math.round(performance.now()-t);p.error(`[Pillar] Action "${n.action_name}" failed after ${a}ms:`,r)}else p.error("[Pillar] SDK not initialized, cannot execute action"),await e.mcp.sendActionResult(n.action_name,{success:!1,error:"SDK not initialized"},n.tool_call_id)},a.signal,e=>rt(e));let u=l;d.actions&&d.actions.length>0&&(u=o(d.actions)),$t(d.message,d.messageId,u,d.sources),d.conversationId&&Rt(d.conversationId),c&&Zn.value&&ir(Zn.value,n)}catch(e){if("AbortError"===e.name)return qt(),void p.log("[Pillar] Chat cancelled by user");p.error("[Pillar] Chat error:",e),$t("Sorry, I encountered an error. Please try again.")}finally{Ot(!1),Dt(),rt(null),t.current=null;const e=Fl.getInstance(),n=e?.config?.productKey??"";n&&Yr(n)}},[e,o]),c=ze(()=>{t.current?.abort(),t.current=null;const n=tt.value;null!==n&&(e.mcp.cancelStream(n),rt(null)),Ot(!1),Dt(),qt(),Ht()},[e]),d=ze(async(n,t)=>{Lt(n,t),await e.submitFeedback(n,t)},[e]),u=ze((e,n,t)=>{if(nt.value)return;const r=Fl.getInstance();if(r?.isDOMScanningEnabled??!1){const r=bi();console.log("[Pillar DOM Scanner] Compact content:\n",r.content);const i={id:Fn(),type:"dom_snapshot",url:r.url,title:r.title,content:r.content,interactableCount:r.interactableCount,timestamp:r.timestamp},a=[...n,i];return void s(e,a.length>0?a:void 0,t.length>0?t:void 0)}s(e,n.length>0?n:void 0,t.length>0?t:void 0)},[s]);return $e(()=>{const e=ft.value,n=_t.value;e&&(Nt(),Qt(),u(e,n,[]))},[mt.value,u]),ge("div",{class:"_pillar-chat-view pillar-chat-view",children:[ge("div",{class:"_pillar-chat-view-messages pillar-chat-view-messages",ref:n,children:[at.value&&at.value.elapsedMs>=15e3&&ge(Ga,{session:at.value,onResume:a,onDiscard:l,isResuming:r}),r&&at.value&&at.value.elapsedMs<15e3&&ge(Ga,{session:at.value,onResume:a,onDiscard:l,isResuming:!0}),it.value&&ge("div",{class:"_pillar-chat-history-loading pillar-chat-history-loading",children:[ge("div",{class:"_pillar-chat-history-loading-message _pillar-chat-history-loading-message--user pillar-chat-history-loading-message--user",children:ge("div",{class:"_pillar-chat-history-loading-bar pillar-chat-history-loading-bar",style:"width: 70%"})}),ge("div",{class:"_pillar-chat-history-loading-message _pillar-chat-history-loading-message--assistant pillar-chat-history-loading-message--assistant",children:[ge("div",{class:"_pillar-chat-history-loading-bar pillar-chat-history-loading-bar",style:"width: 90%"}),ge("div",{class:"_pillar-chat-history-loading-bar pillar-chat-history-loading-bar",style:"width: 85%"}),ge("div",{class:"_pillar-chat-history-loading-bar pillar-chat-history-loading-bar",style:"width: 60%"})]}),ge("div",{class:"_pillar-chat-history-loading-message _pillar-chat-history-loading-message--user pillar-chat-history-loading-message--user",children:ge("div",{class:"_pillar-chat-history-loading-bar pillar-chat-history-loading-bar",style:"width: 55%"})}),ge("div",{class:"_pillar-chat-history-loading-message _pillar-chat-history-loading-message--assistant pillar-chat-history-loading-message--assistant",children:[ge("div",{class:"_pillar-chat-history-loading-bar pillar-chat-history-loading-bar",style:"width: 95%"}),ge("div",{class:"_pillar-chat-history-loading-bar pillar-chat-history-loading-bar",style:"width: 80%"})]})]}),0===Gn.value.length&&!at.value&&!it.value&&ge("div",{class:"_pillar-chat-view-welcome pillar-chat-view-welcome",children:Sr.value?ge("div",{class:"_pillar-home-view-questions pillar-home-view-questions",children:[ge(Or,{}),ge(Or,{}),ge(Or,{})]}):kr.value&&kr.value.length>0?ge("div",{class:"_pillar-home-view-questions pillar-home-view-questions",children:kr.value.map(e=>ge(Lr,{text:e.text,onClick:()=>u(e.text,[],[])},e.id))}):ge(V,{children:[ge("div",{class:"_pillar-chat-view-welcome-icon pillar-chat-view-welcome-icon",children:"💬"}),ge("div",{class:"_pillar-chat-view-welcome-title pillar-chat-view-welcome-title",children:"Ask a question"}),ge("div",{class:"_pillar-chat-view-welcome-text pillar-chat-view-welcome-text",children:"Ask me anything about how to use this product."})]})}),Gn.value.map((e,n)=>ge("div",{class:`_pillar-chat-view-message pillar-chat-view-message _pillar-chat-view-message--${e.role} pillar-chat-view-message--${e.role}`,children:"user"===e.role?ge("div",{class:"_pillar-message-user pillar-message-user",children:[e.userContext&&e.userContext.length>0&&ge(Ar,{contexts:e.userContext,readOnly:!0}),e.images&&e.images.length>0&&ge("div",{class:"_pillar-message-user-images pillar-message-user-images",children:e.images.map((e,n)=>ge("img",{src:e.url,alt:`Attachment ${n+1}`,class:"_pillar-message-user-image pillar-message-user-image"},n))}),e.content]}):ge("div",{class:"_pillar-message-assistant-wrapper pillar-message-assistant-wrapper",children:[ge("div",{class:"_pillar-message-assistant-content pillar-message-assistant-content",children:[e.segments&&e.segments.length>0?e.segments.map((n,t)=>{if("progress"===n.type){const r=e.segments.slice(t+1).some(e=>"text"===e.type);return ge(Va,{events:n.events,responseStarted:r||Boolean(e.content)},`seg-${t}`)}return ge("div",{class:"_pillar-message-assistant pillar-message-assistant",children:ge(Da,{content:n.content})},`seg-${t}`)}):ge(V,{children:[e.progressEvents&&e.progressEvents.length>0&&ge(Va,{events:e.progressEvents,responseStarted:Boolean(e.content)}),e.content?ge("div",{class:"_pillar-message-assistant pillar-message-assistant",children:ge(Da,{content:e.content})}):nt.value&&n===Gn.value.length-1&&(!e.progressEvents||0===e.progressEvents.length)&&ge("div",{class:"_pillar-progress-indicator pillar-progress-indicator",children:[ge("div",{class:"_pillar-loading-spinner pillar-loading-spinner"}),ge("span",{class:"_pillar-progress-message pillar-progress-message",children:"Processing..."})]})]}),e.actionStatus&&Object.keys(e.actionStatus).length>0&&ge("span",{class:"_pillar-action-status pillar-action-status",children:Object.entries(e.actionStatus).map(([e,n])=>ge("span",{class:`_pillar-action-status-indicator pillar-action-status-indicator _pillar-action-status-indicator--${n.status} pillar-action-status-indicator--${n.status}`,title:"failed"===n.status?n.errorMessage:e,dangerouslySetInnerHTML:{__html:"success"===n.status?'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>':"failed"===n.status?'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>':'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><path d="M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83" opacity="0.3"/><path d="M12 2v4"/></svg>'}},e))})]}),e.id&&e.content&&ge("div",{class:"_pillar-feedback-icons pillar-feedback-icons",children:[ge("button",{class:"_pillar-feedback-btn pillar-feedback-btn "+("up"===e.feedback?"_pillar-feedback-btn--active pillar-feedback-btn--active":""),onClick:()=>d(e.id,"up"),"aria-label":"Helpful",title:"Helpful",type:"button",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"/></svg>'}}),ge("button",{class:"_pillar-feedback-btn pillar-feedback-btn "+("down"===e.feedback?"_pillar-feedback-btn--active pillar-feedback-btn--active":""),onClick:()=>d(e.id,"down"),"aria-label":"Not helpful",title:"Not helpful",type:"button",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17"/></svg>'}})]}),e.sources&&e.sources.length>0&&ge("div",{class:"_pillar-chat-sources pillar-chat-sources",children:[ge("div",{class:"_pillar-chat-sources-title pillar-chat-sources-title",children:"Sources"}),e.sources.map(e=>ge("div",{class:"_pillar-chat-source pillar-chat-source",children:e.title},e.slug))]})]})},n))]}),ge("div",{class:"_pillar-chat-view-input-area pillar-chat-view-input-area",children:ge(Rr,{placeholder:"Ask a question...",disabled:it.value,isStreaming:nt.value,onStop:c,onSubmit:u})})]})}function Ja(e){if(!e)return"Unknown";const n=function(e){let n=e;return e.endsWith("Z")&&e.includes("+")&&(n=e.slice(0,-1)),new Date(n)}(e),t=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()),i=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime()-r.getTime(),a=Math.floor(i/864e5);if(0===a)return"Today";if(1===a)return"Yesterday";if(a<7)return`${a}d ago`;if(a<30){const e=Math.floor(a/7);return 1===e?"1 week ago":`${e} weeks ago`}return n.toLocaleDateString(void 0,{month:"short",year:"numeric"})}function Ya({onSelectConversation:e}){const[n,t]=Ie(!1),[r,i]=Ie(!1),[a,l]=Ie([]),[o,s]=Ie(!1),[c,d]=Ie(Jn.value),u=Me(null),h=Ae(()=>function(e){const n=new Map;for(const t of e){const e=Ja(t.lastMessageAt),r=n.get(e)||[];r.push(t),n.set(e,r)}return Array.from(n.entries()).map(([e,n])=>({label:e,conversations:n}))}(a),[a]);$e(()=>Jn.subscribe(e=>{e>c&&(s(!1),d(e))}),[c]),$e(()=>{const e=e=>{u.current&&!u.current.contains(e.target)&&t(!1)};return n&&document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[n]);const g=async()=>{if(!o){i(!0);try{const e=Wl();if(e){const n=await e.listConversations(20);l((e=>{const n=Yn.value;if(0===n.length)return e;const t=new Set(e.map(e=>e.id)),r=n.filter(e=>!t.has(e.id));return[...r,...e]})(n))}}catch(e){p.error("[Pillar] Failed to fetch conversations:",e),Yn.value.length>0&&l(Yn.value)}finally{i(!1),s(!0)}}};return ge("div",{class:"_pillar-history-dropdown pillar-history-dropdown",ref:u,children:[ge("button",{class:"_pillar-icon-btn pillar-icon-btn pillar-history-btn",onClick:()=>{const e=!n;t(e),e&&!o&&g()},"aria-label":"Conversation history","aria-expanded":n,title:"Conversation history",type:"button",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm1-12a1 1 0 10-2 0v4a1 1 0 00.293.707l2.828 2.829a1 1 0 101.415-1.415L11 9.586V6z" clip-rule="evenodd"/></svg>'}}),n&&ge("div",{class:"_pillar-history-menu pillar-history-menu",children:r?ge("div",{class:"_pillar-history-loading pillar-history-loading",children:[ge("div",{class:"_pillar-history-spinner pillar-history-spinner"}),ge("span",{children:"Loading..."})]}):0===a.length?ge("div",{class:"_pillar-history-empty pillar-history-empty",children:"No conversations yet"}):ge("div",{class:"_pillar-history-list pillar-history-list",children:h.map(n=>ge(V,{children:[ge("div",{class:"_pillar-history-group-header pillar-history-group-header",children:n.label}),n.conversations.map(n=>ge("button",{class:"_pillar-history-item pillar-history-item",onClick:()=>(n=>{t(!1),e(n)})(n.id),type:"button",children:ge("span",{class:"_pillar-history-item-title pillar-history-item-title",children:n.title})},n.id))]},n.label))})})]})}function Xa({currentView:e,hideNavigation:n=!1}){const t=!n&&cr.value,r=!n&&!pr.value,i="chat"===e&&Et.value,a=ar;return ge("header",{class:"_pillar-header pillar-header",children:[ge("div",{class:"_pillar-header-left pillar-header-left",children:[t&&ge("button",{class:"_pillar-icon-btn pillar-icon-btn pillar-back-btn",onClick:()=>{ur()},"aria-label":"Go back",type:"button",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M9.707 16.707a1 1 0 01-1.414 0l-6-6a1 1 0 010-1.414l6-6a1 1 0 011.414 1.414L5.414 9H17a1 1 0 110 2H5.414l4.293 4.293a1 1 0 010 1.414z" clip-rule="evenodd"/></svg>'}}),r&&!i&&ge("button",{class:"_pillar-icon-btn pillar-icon-btn pillar-home-btn",onClick:()=>{hr()},"aria-label":"Go to home",type:"button",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 20 20" fill="currentColor"><path d="M10.707 2.293a1 1 0 00-1.414 0l-7 7a1 1 0 001.414 1.414L4 10.414V17a1 1 0 001 1h2a1 1 0 001-1v-2a1 1 0 011-1h2a1 1 0 011 1v2a1 1 0 001 1h2a1 1 0 001-1v-6.586l.293.293a1 1 0 001.414-1.414l-7-7z"/></svg>'}})]}),ge("div",{class:"_pillar-header-right pillar-header-right",children:[i&&ge("button",{class:"_pillar-icon-btn pillar-icon-btn pillar-new-chat-btn",onClick:()=>{hr()},"aria-label":"New chat",title:"New chat",type:"button",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 20 20" fill="currentColor"><path d="M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z"/></svg>'}}),ge(Ya,{onSelectConversation:a}),ge("button",{class:"_pillar-icon-btn pillar-icon-btn pillar-close-btn",onClick:()=>{zn()},"aria-label":"Close assistant panel",type:"button",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd"/></svg>'}})]})]})}function el(){const e=sr.value,n=_n.value,t="chat"===e.type,r="home"===e.type;return ge("div","assistant"!==n?{class:"_pillar-panel-ui pillar-panel-ui",children:[ge(Xa,{currentView:"home"}),ge("div",{class:"_pillar-content pillar-content",children:"support"===n?ge("div",{style:{padding:"24px",textAlign:"center"},children:[ge("h2",{style:{fontSize:"18px",fontWeight:"600",marginBottom:"8px"},children:"Hello World"}),ge("p",{style:{color:"var(--pillar-text-muted)",fontSize:"14px"},children:"Support tab content goes here."})]}):null})]}:{class:"_pillar-panel-ui pillar-panel-ui",children:[ge(Xa,{currentView:e.type,hideNavigation:t}),ge("div",{class:"_pillar-content pillar-content",children:(()=>{switch(e.type){case"home":default:return ge(Dr,{});case"chat":return ge(Qa,{})}})()}),!t&&!r&&ge("div",{class:"_pillar-chat-input-area pillar-chat-input-area",children:ge(Rr,{placeholder:"Ask a question..."})})]})}function nl(e,n=""){const t=[];return e.primary&&t.push(`--pillar-primary${n}: ${e.primary};`),e.primaryHover&&t.push(`--pillar-primary-hover${n}: ${e.primaryHover};`),e.background&&t.push(`--pillar-bg${n}: ${e.background};`),e.backgroundSecondary&&t.push(`--pillar-bg-secondary${n}: ${e.backgroundSecondary};`),e.text&&t.push(`--pillar-text${n}: ${e.text};`),e.textMuted&&t.push(`--pillar-text-muted${n}: ${e.textMuted};`),e.border&&t.push(`--pillar-border${n}: ${e.border};`),e.borderLight&&t.push(`--pillar-border-light${n}: ${e.borderLight};`),t.join("\n ")}function tl(e){const n=nl(e.colors),t=nl(e.darkColors);let r="";return n&&(r+=`\n:host {\n ${n}\n}\n`),t&&(r+=`\n@media (prefers-color-scheme: dark) {\n :host:not([data-theme="light"]) {\n ${t}\n }\n}\n:host([data-theme="dark"]) {\n ${t}\n}\n`),r}const rl='\n/* ============================================================================\n CSS Custom Properties (Variables)\n Users can override these to customize colors\n ============================================================================ */\n\n:host {\n /* Core colors - Light mode (default) */\n --pillar-primary: #2563eb;\n --pillar-primary-hover: #1d4ed8;\n --pillar-primary-light: #eff6ff;\n --pillar-primary-light-hover: #dbeafe;\n \n --pillar-bg: #ffffff;\n --pillar-bg-secondary: #f9fafb;\n --pillar-bg-tertiary: #f3f4f6;\n \n --pillar-text: #1a1a1a;\n --pillar-text-secondary: #374151;\n --pillar-text-muted: #6b7280;\n --pillar-text-placeholder: #9ca3af;\n \n --pillar-border: #e5e7eb;\n --pillar-border-light: #f3f4f6;\n \n /* Shadows */\n --pillar-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);\n --pillar-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);\n \n /* Code blocks */\n --pillar-code-bg: #1f2937;\n --pillar-code-text: #e5e7eb;\n \n /* Scrollbar */\n --pillar-scrollbar-track: transparent;\n --pillar-scrollbar-thumb: #d1d5db;\n --pillar-scrollbar-thumb-hover: #9ca3af;\n \n /* Spacing (can be customized) */\n --pillar-panel-width: 380px;\n --pillar-spacing-xs: 4px;\n --pillar-spacing-sm: 8px;\n --pillar-spacing-md: 12px;\n --pillar-spacing-lg: 16px;\n --pillar-spacing-xl: 20px;\n --pillar-spacing-2xl: 24px;\n \n /* Border radius */\n --pillar-radius-sm: 4px;\n --pillar-radius-md: 6px;\n --pillar-radius-lg: 8px;\n --pillar-radius-xl: 10px;\n --pillar-radius-full: 9999px;\n \n /* Typography */\n --pillar-font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, \'Helvetica Neue\', Arial, sans-serif;\n --pillar-font-mono: \'SF Mono\', Consolas, monospace;\n --pillar-font-size-xs: 11px;\n --pillar-font-size-sm: 12px;\n --pillar-font-size-base: 14px;\n --pillar-font-size-md: 15px;\n --pillar-font-size-lg: 16px;\n --pillar-font-size-xl: 18px;\n --pillar-font-size-2xl: 20px;\n \n /* Animation */\n --pillar-transition-fast: 0.15s ease;\n --pillar-transition-normal: 0.3s ease;\n}\n\n/* Dark mode - Auto-detect from system preference */\n@media (prefers-color-scheme: dark) {\n :host:not([data-theme="light"]) {\n --pillar-primary: #3b82f6;\n --pillar-primary-hover: #60a5fa;\n --pillar-primary-light: #1e3a5f;\n --pillar-primary-light-hover: #1e4976;\n \n --pillar-bg: #1a1a1a;\n --pillar-bg-secondary: #262626;\n --pillar-bg-tertiary: #333333;\n \n --pillar-text: #f5f5f5;\n --pillar-text-secondary: #e5e5e5;\n --pillar-text-muted: #a3a3a3;\n --pillar-text-placeholder: #737373;\n \n --pillar-border: #404040;\n --pillar-border-light: #333333;\n \n --pillar-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);\n --pillar-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);\n \n --pillar-code-bg: #0d0d0d;\n --pillar-code-text: #e5e7eb;\n \n --pillar-scrollbar-thumb: #525252;\n --pillar-scrollbar-thumb-hover: #737373;\n }\n}\n\n/* Dark mode - Manual override */\n:host([data-theme="dark"]) {\n --pillar-primary: #3b82f6;\n --pillar-primary-hover: #60a5fa;\n --pillar-primary-light: #1e3a5f;\n --pillar-primary-light-hover: #1e4976;\n \n --pillar-bg: #1a1a1a;\n --pillar-bg-secondary: #262626;\n --pillar-bg-tertiary: #333333;\n \n --pillar-text: #f5f5f5;\n --pillar-text-secondary: #e5e5e5;\n --pillar-text-muted: #a3a3a3;\n --pillar-text-placeholder: #737373;\n \n --pillar-border: #404040;\n --pillar-border-light: #333333;\n \n --pillar-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);\n --pillar-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);\n \n --pillar-code-bg: #0d0d0d;\n --pillar-code-text: #e5e7eb;\n \n --pillar-scrollbar-thumb: #525252;\n --pillar-scrollbar-thumb-hover: #737373;\n}\n\n/* ============================================================================\n Base Styles\n Note: No CSS reset - we rely on explicit styles for SDK components\n and allow custom cards to inherit host app styling (Tailwind, etc.)\n ============================================================================ */\n\n:host {\n font-family: var(--pillar-font-family);\n font-size: var(--pillar-font-size-base);\n line-height: 1.5;\n color: var(--pillar-text);\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\n/* ============================================================================\n Panel Container\n Internal: _pillar-panel | Public: pillar-panel\n ============================================================================ */\n\n._pillar-panel {\n position: fixed;\n top: 0;\n bottom: 0;\n width: var(--pillar-panel-width);\n max-width: 100vw;\n background: var(--pillar-bg);\n border-left: 1px solid var(--pillar-border);\n display: flex;\n flex-direction: column;\n z-index: 99999;\n transform: translateX(100%);\n transition: transform var(--pillar-transition-normal);\n}\n\n._pillar-panel--right {\n right: 0;\n}\n\n._pillar-panel--left {\n left: 0;\n border-left: none;\n border-right: 1px solid var(--pillar-border);\n transform: translateX(-100%);\n}\n\n._pillar-panel--open {\n transform: translateX(0);\n}\n\n._pillar-panel--manual {\n position: static;\n transform: none;\n height: 100%;\n}\n\n._pillar-panel--full-width {\n width: 100vw;\n max-width: 100vw;\n}\n\n._pillar-panel-root {\n display: flex;\n flex-direction: column;\n height: 100%;\n}\n\n._pillar-panel-ui {\n display: flex;\n flex-direction: column;\n height: 100%;\n overflow: hidden;\n}\n\n/* Public override classes - empty by default */\n.pillar-panel {}\n.pillar-panel-root {}\n.pillar-panel-ui {}\n\n/* ============================================================================\n Backdrop\n ============================================================================ */\n\n._pillar-backdrop {\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.3);\n opacity: 0;\n visibility: hidden;\n transition: opacity var(--pillar-transition-normal), visibility var(--pillar-transition-normal);\n z-index: 99998;\n}\n\n._pillar-backdrop--visible {\n opacity: 1;\n visibility: visible;\n}\n\n.pillar-backdrop {}\n\n/* ============================================================================\n Header\n Internal: _pillar-header | Public: pillar-header\n ============================================================================ */\n\n._pillar-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n height: 32px;\n padding: 0 var(--pillar-spacing-md);\n border-bottom: 1px solid var(--pillar-border);\n flex-shrink: 0;\n background: var(--pillar-bg);\n}\n\n._pillar-header-left {\n display: flex;\n align-items: center;\n gap: var(--pillar-spacing-sm);\n}\n\n._pillar-header-title {\n font-size: var(--pillar-font-size-lg);\n font-weight: 600;\n color: var(--pillar-text);\n}\n\n._pillar-header-right {\n display: flex;\n align-items: center;\n gap: var(--pillar-spacing-xs);\n}\n\n/* Public override classes */\n.pillar-header {}\n.pillar-header-left {}\n.pillar-header-right {}\n.pillar-header-title {}\n.pillar-new-chat-btn {}\n\n/* ============================================================================\n Icon Buttons (back, home, close)\n Internal: _pillar-icon-btn | Public: pillar-icon-btn\n ============================================================================ */\n\n._pillar-icon-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 32px;\n height: 32px;\n padding: 0;\n color: var(--pillar-text-muted);\n background: none;\n border: none;\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n transition: color var(--pillar-transition-fast), background var(--pillar-transition-fast);\n}\n\n._pillar-icon-btn:hover {\n color: var(--pillar-text);\n}\n\n._pillar-icon-btn svg {\n width: 20px;\n height: 20px;\n}\n\n.pillar-icon-btn {}\n.pillar-back-btn {}\n.pillar-home-btn {}\n.pillar-history-btn {}\n\n/* ============================================================================\n History Dropdown\n Internal: _pillar-history-* | Public: pillar-history-*\n ============================================================================ */\n\n._pillar-history-dropdown {\n position: relative;\n}\n\n._pillar-history-menu {\n position: absolute;\n top: 100%;\n right: 0;\n margin-top: var(--pillar-spacing-xs);\n width: 280px;\n max-height: 400px;\n background: var(--pillar-bg);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-lg);\n box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);\n overflow: hidden;\n z-index: 100;\n}\n\n._pillar-history-loading {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: var(--pillar-spacing-sm);\n padding: var(--pillar-spacing-xl);\n color: var(--pillar-text-muted);\n font-size: 13px;\n}\n\n._pillar-history-spinner {\n width: 24px;\n height: 24px;\n border: 2px solid var(--pillar-border);\n border-top-color: var(--pillar-primary);\n border-radius: 50%;\n animation: pillar-spin 0.8s linear infinite;\n}\n\n@keyframes pillar-spin {\n to { transform: rotate(360deg); }\n}\n\n._pillar-history-empty {\n padding: var(--pillar-spacing-xl);\n text-align: center;\n color: var(--pillar-text-muted);\n font-size: 13px;\n}\n\n._pillar-history-list {\n max-height: 360px;\n overflow-y: auto;\n padding: var(--pillar-spacing-xs) 0;\n}\n\n._pillar-history-group-header {\n padding: var(--pillar-spacing-xs) var(--pillar-spacing-md);\n padding-top: var(--pillar-spacing-sm);\n font-size: 10px;\n font-weight: 500;\n color: var(--pillar-text-muted);\n letter-spacing: 0.02em;\n}\n\n._pillar-history-group-header:first-child {\n padding-top: var(--pillar-spacing-xs);\n}\n\n._pillar-history-item {\n display: flex;\n align-items: center;\n width: 100%;\n padding: var(--pillar-spacing-xs) var(--pillar-spacing-md);\n background: none;\n border: none;\n text-align: left;\n cursor: pointer;\n transition: background var(--pillar-transition-fast);\n border-radius: var(--pillar-radius-sm);\n margin: 0 var(--pillar-spacing-xs);\n width: calc(100% - var(--pillar-spacing-sm));\n}\n\n._pillar-history-item:hover {\n background: var(--pillar-bg-secondary);\n}\n\n._pillar-history-item-title {\n font-size: 13px;\n color: var(--pillar-text);\n line-height: 1.4;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n max-width: 100%;\n}\n\n/* Public override classes */\n.pillar-history-dropdown {}\n.pillar-history-menu {}\n.pillar-history-group-header {}\n.pillar-history-list {}\n.pillar-history-item {}\n.pillar-history-item-title {}\n.pillar-close-btn {}\n\n/* ============================================================================\n Content Area\n Internal: _pillar-content | Public: pillar-content\n ============================================================================ */\n\n._pillar-content {\n flex: 1;\n overflow-y: auto;\n overflow-x: hidden;\n min-height: 0;\n}\n\n.pillar-content {}\n\n/* ============================================================================\n Search Input\n Internal: _pillar-search | Public: pillar-search\n ============================================================================ */\n\n._pillar-search {\n position: relative;\n padding: var(--pillar-spacing-lg) var(--pillar-spacing-xl);\n}\n\n._pillar-search-input {\n width: 100%;\n padding: 10px 12px 10px 40px;\n font-size: var(--pillar-font-size-base);\n font-family: var(--pillar-font-family);\n color: var(--pillar-text);\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-lg);\n outline: none;\n transition: border-color var(--pillar-transition-fast), box-shadow var(--pillar-transition-fast);\n}\n\n._pillar-search-input:focus {\n border-color: var(--pillar-primary);\n box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);\n}\n\n._pillar-search-input::placeholder {\n color: var(--pillar-text-placeholder);\n}\n\n._pillar-search-icon {\n position: absolute;\n left: 32px;\n top: 50%;\n transform: translateY(-50%);\n width: 18px;\n height: 18px;\n color: var(--pillar-text-placeholder);\n pointer-events: none;\n}\n\n._pillar-search-icon svg {\n width: 18px;\n height: 18px;\n}\n\n.pillar-search {}\n.pillar-search-input {}\n.pillar-search-icon {}\n\n/* ============================================================================\n Chat Input (Persistent Bottom)\n Internal: _pillar-chat-input | Public: pillar-chat-input\n ============================================================================ */\n\n._pillar-chat-input-container {\n flex-shrink: 0;\n border-top: 1px solid var(--pillar-border);\n background: var(--pillar-bg);\n display: flex;\n flex-direction: column;\n max-height: 50%;\n transition: max-height var(--pillar-transition-normal);\n}\n\n._pillar-chat-input-container--expanded {\n max-height: 60%;\n}\n\n._pillar-chat-input-messages {\n flex: 1;\n overflow-y: auto;\n padding: 0;\n max-height: 0;\n transition: max-height var(--pillar-transition-normal), padding var(--pillar-transition-normal);\n}\n\n._pillar-chat-input-container--expanded ._pillar-chat-input-messages {\n max-height: 300px;\n padding: var(--pillar-spacing-lg) var(--pillar-spacing-xl);\n}\n\n._pillar-chat-input-message {\n margin-bottom: var(--pillar-spacing-md);\n}\n\n._pillar-chat-input-message--user {\n text-align: right;\n}\n\n._pillar-chat-input-message-content {\n display: inline-block;\n max-width: 85%;\n padding: 10px 14px;\n border-radius: var(--pillar-spacing-lg);\n font-size: var(--pillar-font-size-base);\n line-height: 1.5;\n}\n\n._pillar-chat-input-message--user ._pillar-chat-input-message-content {\n background: var(--pillar-primary);\n color: #ffffff;\n border-bottom-right-radius: var(--pillar-radius-sm);\n}\n\n._pillar-chat-input-message--assistant ._pillar-chat-input-message-content {\n background: var(--pillar-bg-tertiary);\n color: var(--pillar-text);\n border-bottom-left-radius: var(--pillar-radius-sm);\n}\n\n._pillar-chat-input-sources {\n margin-top: var(--pillar-spacing-sm);\n padding-top: var(--pillar-spacing-sm);\n border-top: 1px solid var(--pillar-border);\n}\n\n._pillar-chat-input-sources-title {\n font-size: var(--pillar-font-size-xs);\n font-weight: 500;\n color: var(--pillar-text-muted);\n margin-bottom: 6px;\n}\n\n._pillar-chat-input-source {\n display: block;\n padding: 6px 10px;\n margin-bottom: var(--pillar-spacing-xs);\n font-size: var(--pillar-font-size-sm);\n color: var(--pillar-primary);\n background: var(--pillar-primary-light);\n border-radius: var(--pillar-radius-md);\n text-decoration: none;\n cursor: pointer;\n}\n\n._pillar-chat-input-source:hover {\n background: var(--pillar-primary-light-hover);\n}\n\n._pillar-chat-input-area {\n padding: var(--pillar-spacing-md) var(--pillar-spacing-lg);\n}\n\n._pillar-chat-input-wrapper {\n display: flex;\n flex-direction: column;\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-xl);\n transition: border-color var(--pillar-transition-fast), box-shadow var(--pillar-transition-fast);\n}\n\n._pillar-chat-input-wrapper:focus-within {\n border-color: var(--pillar-primary);\n box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);\n}\n\n._pillar-chat-input-textarea {\n display: block;\n width: 100%;\n padding: 12px 14px 8px;\n font-size: var(--pillar-font-size-base);\n font-family: var(--pillar-font-family);\n line-height: 1.5;\n color: var(--pillar-text);\n background: transparent;\n border: none;\n outline: none;\n resize: none;\n overflow-y: hidden;\n box-sizing: border-box;\n}\n\n._pillar-chat-input-textarea::placeholder {\n color: var(--pillar-text-placeholder);\n}\n\n.pillar-chat-input-container {}\n.pillar-chat-input-messages {}\n.pillar-chat-input-message {}\n.pillar-chat-input-message-content {}\n.pillar-chat-input-sources {}\n.pillar-chat-input-area {}\n.pillar-chat-input-wrapper {}\n.pillar-chat-input-textarea {}\n\n/* ============================================================================\n Chat Input Footer (contains send button)\n ============================================================================ */\n\n._pillar-chat-input-footer {\n display: flex;\n justify-content: flex-end;\n padding: 8px 10px;\n}\n\n/* ============================================================================\n Send Button - In footer row, right aligned\n Internal: _pillar-send-btn | Public: pillar-send-btn\n ============================================================================ */\n\n._pillar-send-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n padding: 0;\n color: var(--pillar-text-muted);\n background: var(--pillar-bg-tertiary);\n border: none;\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n flex-shrink: 0;\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-send-btn:hover:not(:disabled) {\n color: #ffffff;\n background: var(--pillar-primary);\n}\n\n._pillar-send-btn:disabled {\n color: var(--pillar-text-placeholder);\n background: var(--pillar-bg-tertiary);\n cursor: not-allowed;\n}\n\n._pillar-send-btn svg {\n width: 16px;\n height: 16px;\n}\n\n.pillar-send-btn {}\n.pillar-chat-input-footer {}\n\n/* ============================================================================\n Loading States\n Internal: _pillar-loading | Public: pillar-loading\n ============================================================================ */\n\n._pillar-loading {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 40px var(--pillar-spacing-xl);\n color: var(--pillar-text-muted);\n}\n\n._pillar-loading-spinner {\n width: 24px;\n height: 24px;\n border: 2px solid var(--pillar-border);\n border-top-color: var(--pillar-primary);\n border-radius: 50%;\n animation: pillar-spin 0.8s linear infinite;\n}\n\n@keyframes pillar-spin {\n to { transform: rotate(360deg); }\n}\n\n.pillar-loading {}\n.pillar-loading-spinner {}\n\n/* ============================================================================\n Progress Indicator (AI activity status)\n Internal: _pillar-progress | Public: pillar-progress\n ============================================================================ */\n\n._pillar-progress-indicator {\n display: flex;\n align-items: center;\n gap: var(--pillar-spacing-sm);\n padding: var(--pillar-spacing-sm) 0;\n}\n\n._pillar-progress-indicator ._pillar-loading-spinner {\n width: 16px;\n height: 16px;\n flex-shrink: 0;\n}\n\n._pillar-progress-message {\n font-size: var(--pillar-font-size-sm);\n color: var(--pillar-text-muted);\n font-style: italic;\n}\n\n.pillar-progress-indicator {}\n.pillar-progress-message {}\n\n/* ============================================================================\n Empty States\n Internal: _pillar-empty | Public: pillar-empty\n ============================================================================ */\n\n._pillar-empty {\n padding: 40px var(--pillar-spacing-xl);\n text-align: center;\n color: var(--pillar-text-muted);\n}\n\n._pillar-empty-icon {\n width: 48px;\n height: 48px;\n margin: 0 auto var(--pillar-spacing-lg);\n color: var(--pillar-border);\n}\n\n._pillar-empty-title {\n font-size: var(--pillar-font-size-lg);\n font-weight: 500;\n color: var(--pillar-text);\n margin-bottom: var(--pillar-spacing-xs);\n}\n\n._pillar-empty-description {\n font-size: var(--pillar-font-size-base);\n}\n\n.pillar-empty {}\n.pillar-empty-icon {}\n.pillar-empty-title {}\n.pillar-empty-description {}\n\n/* ============================================================================\n Section Titles\n Internal: _pillar-section-title | Public: pillar-section-title\n ============================================================================ */\n\n._pillar-section-title {\n padding: var(--pillar-spacing-md) var(--pillar-spacing-xl) var(--pillar-spacing-sm);\n font-size: var(--pillar-font-size-xs);\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n color: var(--pillar-text-muted);\n}\n\n.pillar-section-title {}\n\n/* ============================================================================\n Related Articles\n ============================================================================ */\n\n._pillar-related-articles {\n border-top: 1px solid var(--pillar-border);\n margin-top: var(--pillar-spacing-2xl);\n padding-top: var(--pillar-spacing-sm);\n}\n\n.pillar-related-articles {}\n\n/* ============================================================================\n Scrollbar Styling\n ============================================================================ */\n\n._pillar-content::-webkit-scrollbar,\n._pillar-chat-input-messages::-webkit-scrollbar {\n width: 6px;\n}\n\n._pillar-content::-webkit-scrollbar-track,\n._pillar-chat-input-messages::-webkit-scrollbar-track {\n background: var(--pillar-scrollbar-track);\n}\n\n._pillar-content::-webkit-scrollbar-thumb,\n._pillar-chat-input-messages::-webkit-scrollbar-thumb {\n background: var(--pillar-scrollbar-thumb);\n border-radius: 3px;\n}\n\n._pillar-content::-webkit-scrollbar-thumb:hover,\n._pillar-chat-input-messages::-webkit-scrollbar-thumb:hover {\n background: var(--pillar-scrollbar-thumb-hover);\n}\n\n/* ============================================================================\n Home View\n ============================================================================ */\n\n._pillar-home-view {\n display: flex;\n flex-direction: column;\n height: 100%;\n padding: var(--pillar-spacing-xl);\n}\n\n._pillar-home-view-header {\n text-align: center;\n padding: var(--pillar-spacing-2xl) 0;\n}\n\n._pillar-home-view-icon {\n font-size: 40px;\n margin-bottom: var(--pillar-spacing-md);\n}\n\n._pillar-home-view-title {\n font-size: var(--pillar-font-size-xl);\n font-weight: 600;\n color: var(--pillar-text);\n margin: 0;\n}\n\n._pillar-home-view-questions {\n display: flex;\n flex-direction: column;\n gap: var(--pillar-spacing-sm);\n margin-bottom: var(--pillar-spacing-xl);\n}\n\n._pillar-home-view-input-wrapper {\n margin-top: auto;\n display: flex;\n flex-direction: column;\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-xl);\n transition: border-color var(--pillar-transition-fast), box-shadow var(--pillar-transition-fast);\n}\n\n._pillar-home-view-input-wrapper:focus-within {\n border-color: var(--pillar-primary);\n box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);\n}\n\n._pillar-home-view-input {\n display: block;\n width: 100%;\n padding: 12px 14px 8px;\n font-size: var(--pillar-font-size-base);\n font-family: var(--pillar-font-family);\n line-height: 1.5;\n color: var(--pillar-text);\n background: transparent;\n border: none;\n outline: none;\n resize: none;\n overflow-y: hidden;\n box-sizing: border-box;\n}\n\n._pillar-home-view-input::placeholder {\n color: var(--pillar-text-placeholder);\n}\n\n._pillar-home-view-input-row {\n display: flex;\n justify-content: flex-end;\n padding: 8px 10px;\n}\n\n._pillar-home-view-send-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n padding: 0;\n color: var(--pillar-text-muted);\n background: var(--pillar-bg-tertiary);\n border: none;\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n flex-shrink: 0;\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-home-view-send-btn:hover:not(:disabled) {\n color: #ffffff;\n background: var(--pillar-primary);\n}\n\n._pillar-home-view-send-btn:disabled {\n color: var(--pillar-text-placeholder);\n background: var(--pillar-bg-tertiary);\n cursor: not-allowed;\n}\n\n._pillar-home-view-send-btn svg {\n width: 16px;\n height: 16px;\n}\n\n.pillar-home-view {}\n.pillar-home-view-header {}\n.pillar-home-view-title {}\n.pillar-home-view-questions {}\n.pillar-home-view-input-wrapper {}\n.pillar-home-view-input {}\n.pillar-home-view-send-btn {}\n\n/* ============================================================================\n Question Chip\n ============================================================================ */\n\n._pillar-question-chip {\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: 100%;\n padding: var(--pillar-spacing-md) var(--pillar-spacing-lg);\n font-size: var(--pillar-font-size-base);\n font-family: var(--pillar-font-family);\n text-align: left;\n color: var(--pillar-text);\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-lg);\n cursor: pointer;\n transition: background var(--pillar-transition-fast), border-color var(--pillar-transition-fast);\n}\n\n._pillar-question-chip:hover {\n border-color: var(--pillar-primary);\n}\n\n._pillar-question-chip-text {\n flex: 1;\n}\n\n._pillar-question-chip-arrow {\n color: var(--pillar-text-muted);\n margin-left: var(--pillar-spacing-sm);\n transition: color var(--pillar-transition-fast), transform var(--pillar-transition-fast);\n}\n\n._pillar-question-chip:hover ._pillar-question-chip-arrow {\n color: var(--pillar-primary);\n transform: translateX(2px);\n}\n\n._pillar-question-chip-skeleton {\n height: 44px;\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-lg);\n overflow: hidden;\n}\n\n._pillar-question-chip-skeleton-bar {\n width: 60%;\n height: 14px;\n margin: 15px var(--pillar-spacing-lg);\n background: linear-gradient(90deg, var(--pillar-border) 25%, var(--pillar-bg-tertiary) 50%, var(--pillar-border) 75%);\n background-size: 200% 100%;\n animation: pillar-shimmer 1.5s infinite;\n border-radius: var(--pillar-radius-sm);\n}\n\n@keyframes pillar-shimmer {\n 0% { background-position: 200% 0; }\n 100% { background-position: -200% 0; }\n}\n\n.pillar-question-chip {}\n.pillar-question-chip-text {}\n.pillar-question-chip-arrow {}\n.pillar-question-chip-skeleton {}\n.pillar-question-chip-skeleton-bar {}\n\n/* ============================================================================\n Standalone Chat View\n Internal: _pillar-chat-view | Public: pillar-chat-view\n ============================================================================ */\n\n._pillar-chat-view {\n display: flex;\n flex-direction: column;\n height: 100%;\n overflow: hidden;\n}\n\n._pillar-chat-view-messages {\n flex: 1;\n overflow-y: auto;\n padding: var(--pillar-spacing-xl);\n display: flex;\n flex-direction: column;\n}\n\n._pillar-chat-view-welcome {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: flex-start;\n padding: var(--pillar-spacing-xl);\n text-align: center;\n}\n\n._pillar-chat-view-welcome-icon {\n font-size: 48px;\n margin-bottom: var(--pillar-spacing-lg);\n}\n\n._pillar-chat-view-welcome-title {\n font-size: var(--pillar-font-size-xl);\n font-weight: 600;\n color: var(--pillar-text);\n margin-bottom: var(--pillar-spacing-sm);\n}\n\n._pillar-chat-view-welcome-text {\n font-size: var(--pillar-font-size-base);\n color: var(--pillar-text-muted);\n max-width: 280px;\n}\n\n/* History Loading Skeleton */\n._pillar-chat-history-loading {\n display: flex;\n flex-direction: column;\n gap: var(--pillar-spacing-lg);\n padding: var(--pillar-spacing-md) 0;\n}\n\n._pillar-chat-history-loading-message {\n display: flex;\n flex-direction: column;\n gap: var(--pillar-spacing-xs);\n}\n\n._pillar-chat-history-loading-message--user {\n align-items: flex-end;\n}\n\n._pillar-chat-history-loading-message--assistant {\n align-items: flex-start;\n}\n\n._pillar-chat-history-loading-bar {\n height: 16px;\n border-radius: var(--pillar-radius-md);\n background: linear-gradient(90deg, var(--pillar-bg-secondary) 25%, var(--pillar-border) 50%, var(--pillar-bg-secondary) 75%);\n background-size: 200% 100%;\n animation: pillar-shimmer 1.5s infinite;\n}\n\n._pillar-chat-history-loading-message--user ._pillar-chat-history-loading-bar {\n background: linear-gradient(90deg, var(--pillar-bg-secondary) 25%, var(--pillar-border) 50%, var(--pillar-bg-secondary) 75%);\n background-size: 200% 100%;\n animation: pillar-shimmer 1.5s infinite;\n}\n\n.pillar-chat-history-loading {}\n.pillar-chat-history-loading-message--user {}\n.pillar-chat-history-loading-message--assistant {}\n.pillar-chat-history-loading-bar {}\n\n._pillar-chat-view-message {\n margin-bottom: var(--pillar-spacing-lg);\n}\n\n._pillar-chat-view-message--user {\n text-align: right;\n}\n\n._pillar-chat-view-message--assistant {\n text-align: left;\n}\n\n.pillar-chat-view {}\n.pillar-chat-view-messages {}\n.pillar-chat-view-welcome {}\n.pillar-chat-view-message {}\n\n/* ============================================================================\n User Message Bubble\n Internal: _pillar-message-user | Public: pillar-message-user\n ============================================================================ */\n\n._pillar-message-user {\n display: inline-block;\n max-width: 85%;\n padding: 10px 14px;\n border-radius: var(--pillar-spacing-lg);\n border-bottom-right-radius: var(--pillar-radius-sm);\n font-size: var(--pillar-font-size-base);\n line-height: 1.5;\n background: var(--pillar-primary);\n color: #ffffff;\n white-space: pre-wrap;\n text-align: left;\n word-wrap: break-word;\n}\n\n._pillar-message-user-images {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n margin-bottom: var(--pillar-spacing-sm);\n}\n\n._pillar-message-user-image {\n max-width: 120px;\n max-height: 120px;\n border-radius: var(--pillar-radius-md);\n object-fit: cover;\n}\n\n.pillar-message-user {}\n.pillar-message-user-images {}\n.pillar-message-user-image {}\n\n/* ============================================================================\n AI Response\n Internal: _pillar-message-assistant | Public: pillar-message-assistant\n ============================================================================ */\n\n._pillar-message-assistant {\n font-size: var(--pillar-font-size-base);\n line-height: 1.6;\n color: var(--pillar-text-secondary);\n}\n\n._pillar-message-assistant p {\n margin: 0 0 var(--pillar-spacing-md);\n}\n\n._pillar-message-assistant p:last-child {\n margin-bottom: 0;\n}\n\n._pillar-message-assistant h2 {\n font-size: var(--pillar-font-size-lg);\n font-weight: 600;\n color: var(--pillar-text);\n margin: var(--pillar-spacing-lg) 0 var(--pillar-spacing-sm);\n}\n\n._pillar-message-assistant h3 {\n font-size: var(--pillar-font-size-md);\n font-weight: 600;\n color: var(--pillar-text);\n margin: 14px 0 6px;\n}\n\n._pillar-message-assistant h4 {\n font-size: var(--pillar-font-size-base);\n font-weight: 600;\n color: var(--pillar-text);\n margin: var(--pillar-spacing-md) 0 6px;\n}\n\n._pillar-message-assistant ul,\n._pillar-message-assistant ol {\n margin: 0 0 var(--pillar-spacing-md);\n padding-left: var(--pillar-spacing-2xl);\n list-style-position: outside;\n}\n\n._pillar-message-assistant ul {\n list-style-type: disc;\n}\n\n._pillar-message-assistant ol {\n list-style-type: decimal;\n}\n\n._pillar-message-assistant li {\n margin-bottom: var(--pillar-spacing-xs);\n}\n\n._pillar-message-assistant code {\n padding: 2px 6px;\n font-size: var(--pillar-font-size-sm);\n background: var(--pillar-bg-tertiary);\n border-radius: var(--pillar-radius-sm);\n font-family: var(--pillar-font-mono);\n color: var(--pillar-text);\n}\n\n._pillar-message-assistant pre {\n margin: var(--pillar-spacing-md) 0;\n padding: var(--pillar-spacing-md) 14px;\n background: var(--pillar-code-bg);\n border-radius: var(--pillar-radius-lg);\n overflow-x: auto;\n}\n\n._pillar-message-assistant pre code {\n padding: 0;\n background: none;\n color: var(--pillar-code-text);\n font-size: var(--pillar-font-size-sm);\n line-height: 1.5;\n}\n\n._pillar-message-assistant a {\n color: var(--pillar-primary);\n text-decoration: none;\n}\n\n._pillar-message-assistant a:hover {\n text-decoration: underline;\n}\n\n._pillar-message-assistant strong {\n font-weight: 600;\n color: var(--pillar-text);\n}\n\n._pillar-message-assistant em {\n font-style: italic;\n}\n\n.pillar-message-assistant {}\n\n/* ============================================================================\n Chat Sources\n Internal: _pillar-chat-sources | Public: pillar-chat-sources\n ============================================================================ */\n\n._pillar-chat-sources {\n margin-top: var(--pillar-spacing-md);\n padding-top: var(--pillar-spacing-md);\n border-top: 1px solid var(--pillar-border);\n}\n\n._pillar-chat-sources-title {\n font-size: var(--pillar-font-size-xs);\n font-weight: 500;\n color: var(--pillar-text-muted);\n margin-bottom: var(--pillar-spacing-sm);\n}\n\n._pillar-chat-source {\n display: block;\n padding: var(--pillar-spacing-sm) var(--pillar-spacing-md);\n margin-bottom: 6px;\n font-size: var(--pillar-font-size-sm);\n color: var(--pillar-primary);\n background: var(--pillar-primary-light);\n border-radius: var(--pillar-radius-lg);\n text-decoration: none;\n cursor: pointer;\n transition: background var(--pillar-transition-fast);\n}\n\n._pillar-chat-source:hover {\n background: var(--pillar-primary-light-hover);\n}\n\n.pillar-chat-sources {}\n.pillar-chat-sources-title {}\n.pillar-chat-source {}\n\n/* ============================================================================\n Chat Actions (Suggested action buttons)\n Internal: _pillar-chat-actions | Public: pillar-chat-actions\n ============================================================================ */\n\n._pillar-chat-actions {\n margin-top: var(--pillar-spacing-md);\n padding-top: var(--pillar-spacing-md);\n border-top: 1px solid var(--pillar-border);\n}\n\n._pillar-chat-actions-title {\n font-size: var(--pillar-font-size-xs);\n font-weight: 500;\n color: var(--pillar-text-muted);\n margin-bottom: var(--pillar-spacing-sm);\n}\n\n._pillar-chat-actions-buttons {\n display: flex;\n flex-direction: column;\n gap: var(--pillar-spacing-sm);\n}\n\n/* Task buttons should wrap horizontally */\n._pillar-chat-actions-buttons > ._pillar-task-button-group {\n display: flex;\n flex-wrap: wrap;\n gap: var(--pillar-spacing-sm);\n}\n\n/* Confirm cards take full width */\n._pillar-chat-actions-buttons > .pillar-confirm-card-wrapper {\n width: 100%;\n}\n\n.pillar-chat-actions {}\n.pillar-chat-actions-title {}\n.pillar-chat-actions-buttons {}\n\n/* ============================================================================\n Chat View Input Area - Cursor-style design\n ============================================================================ */\n\n._pillar-chat-view-input-area {\n flex-shrink: 0;\n padding: 0 var(--pillar-spacing-xl) var(--pillar-spacing-xl);\n background: var(--pillar-bg);\n}\n\n._pillar-chat-view-input-wrapper {\n display: flex;\n flex-direction: column;\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-xl);\n transition: border-color var(--pillar-transition-fast), box-shadow var(--pillar-transition-fast);\n}\n\n._pillar-chat-view-input-wrapper:focus-within {\n border-color: var(--pillar-primary);\n box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);\n}\n\n._pillar-chat-view-input {\n display: block;\n width: 100%;\n padding: 12px 14px 8px;\n font-size: var(--pillar-font-size-base);\n font-family: var(--pillar-font-family);\n line-height: 1.5;\n color: var(--pillar-text);\n background: transparent;\n border: none;\n outline: none;\n resize: none;\n overflow-y: hidden;\n box-sizing: border-box;\n}\n\n._pillar-chat-view-input::placeholder {\n color: var(--pillar-text-placeholder);\n}\n\n._pillar-chat-view-input-row {\n display: flex;\n justify-content: flex-end;\n padding: 8px 10px;\n}\n\n._pillar-chat-view-send-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n padding: 0;\n color: var(--pillar-text-muted);\n background: var(--pillar-bg-tertiary);\n border: none;\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n flex-shrink: 0;\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-chat-view-send-btn:hover:not(:disabled) {\n color: #ffffff;\n background: var(--pillar-primary);\n}\n\n._pillar-chat-view-send-btn:active:not(:disabled) {\n transform: scale(0.95);\n}\n\n._pillar-chat-view-send-btn:disabled {\n color: var(--pillar-text-placeholder);\n background: var(--pillar-bg-tertiary);\n cursor: not-allowed;\n}\n\n._pillar-chat-view-send-btn svg {\n width: 16px;\n height: 16px;\n}\n\n.pillar-chat-view-input-area {}\n.pillar-chat-view-input-wrapper {}\n.pillar-chat-view-input {}\n.pillar-chat-view-send-btn {}\n.pillar-chat-view-input-footer {}\n.pillar-chat-view-new-chat-btn {}\n\n/* New chat button styling */\n._pillar-chat-view-input-footer {\n display: flex;\n justify-content: center;\n margin-top: var(--pillar-spacing-sm);\n}\n\n._pillar-chat-view-new-chat-btn {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 6px 12px;\n font-size: var(--pillar-font-size-sm);\n font-weight: 500;\n font-family: var(--pillar-font-family);\n color: var(--pillar-text-muted);\n background: transparent;\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-lg);\n cursor: pointer;\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-chat-view-new-chat-btn:hover {\n color: var(--pillar-text);\n background: var(--pillar-bg-secondary);\n border-color: var(--pillar-text-muted);\n}\n\n._pillar-chat-view-new-chat-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n._pillar-chat-view-new-chat-icon svg {\n width: 14px;\n height: 14px;\n}\n\n/* Scrollbar for chat view */\n._pillar-chat-view-messages::-webkit-scrollbar {\n width: 6px;\n}\n\n._pillar-chat-view-messages::-webkit-scrollbar-track {\n background: var(--pillar-scrollbar-track);\n}\n\n._pillar-chat-view-messages::-webkit-scrollbar-thumb {\n background: var(--pillar-scrollbar-thumb);\n border-radius: 3px;\n}\n\n._pillar-chat-view-messages::-webkit-scrollbar-thumb:hover {\n background: var(--pillar-scrollbar-thumb-hover);\n}\n\n/* ============================================================================\n Chat Image Upload\n ============================================================================ */\n\n._pillar-chat-view-input-area--dragging {\n position: relative;\n background: rgba(37, 99, 235, 0.05);\n}\n\n._pillar-chat-drop-overlay {\n position: absolute;\n inset: 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 8px;\n background: rgba(37, 99, 235, 0.1);\n border: 2px dashed var(--pillar-primary);\n border-radius: var(--pillar-radius-lg);\n color: var(--pillar-primary);\n font-size: var(--pillar-font-size-sm);\n font-weight: 500;\n z-index: 10;\n pointer-events: none;\n}\n\n._pillar-chat-drop-overlay svg {\n width: 24px;\n height: 24px;\n}\n\n._pillar-chat-images-preview {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n padding: 12px 12px 4px 12px;\n}\n\n._pillar-chat-image-thumb {\n position: relative;\n width: 56px;\n height: 56px;\n border-radius: var(--pillar-radius-md);\n overflow: hidden;\n border: 1px solid var(--pillar-border);\n}\n\n._pillar-chat-image-thumb img {\n width: 100%;\n height: 100%;\n object-fit: cover;\n}\n\n._pillar-chat-image-loading {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n._pillar-chat-image-error {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n background: rgba(239, 68, 68, 0.3);\n color: #dc2626;\n font-weight: bold;\n font-size: 14px;\n}\n\n._pillar-chat-image-remove {\n position: absolute;\n top: 2px;\n right: 2px;\n width: 18px;\n height: 18px;\n padding: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n background: rgba(0, 0, 0, 0.6);\n border: none;\n border-radius: 50%;\n color: white;\n cursor: pointer;\n opacity: 0;\n transition: opacity var(--pillar-transition-fast);\n}\n\n._pillar-chat-image-thumb:hover ._pillar-chat-image-remove {\n opacity: 1;\n}\n\n._pillar-chat-image-remove svg {\n width: 10px;\n height: 10px;\n}\n\n._pillar-chat-image-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 36px;\n height: 36px;\n padding: 0;\n color: var(--pillar-text-muted);\n background: transparent;\n border: none;\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n transition: color var(--pillar-transition-fast);\n}\n\n._pillar-chat-image-btn:hover:not(:disabled) {\n color: var(--pillar-text);\n}\n\n._pillar-chat-image-btn:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n}\n\n._pillar-chat-image-btn svg {\n width: 18px;\n height: 18px;\n}\n\n.pillar-chat-images-preview {}\n.pillar-chat-image-thumb {}\n.pillar-chat-image-remove {}\n.pillar-chat-image-btn {}\n.pillar-chat-drop-overlay {}\n\n/* ============================================================================\n Legacy Class Mappings (for backward compatibility)\n Maps old BEM-style class names to new internal classes\n ============================================================================ */\n\n.pillar-panel { }\n.pillar-panel--right { }\n.pillar-panel--left { }\n.pillar-panel--open { }\n.pillar-panel--manual { }\n.pillar-panel-root { }\n.pillar-panel-ui { }\n.pillar-panel__header { }\n.pillar-panel__header-left { }\n.pillar-panel__back-btn { }\n.pillar-panel__home-btn { }\n.pillar-panel__title { }\n.pillar-panel__close-btn { }\n.pillar-panel__content { }\n.pillar-search { }\n.pillar-search__input { }\n.pillar-search__icon { }\n.pillar-category-card { }\n.pillar-category-card__icon { }\n.pillar-category-card__content { }\n.pillar-category-card__title { }\n.pillar-category-card__description { }\n.pillar-category-card__count { }\n.pillar-article-card { }\n.pillar-article-card__title { }\n.pillar-article-card__excerpt { }\n.pillar-article-card__meta { }\n.pillar-article { }\n.pillar-article__title { }\n.pillar-article__content { }\n.pillar-category-header { }\n.pillar-category-header__title { }\n.pillar-category-header__description { }\n.pillar-chat-input-container { }\n.pillar-chat-input-container--expanded { }\n.pillar-chat-input__messages { }\n.pillar-chat-input__message { }\n.pillar-chat-input__message--user { }\n.pillar-chat-input__message--assistant { }\n.pillar-chat-input__message-content { }\n.pillar-chat-input__sources { }\n.pillar-chat-input__sources-title { }\n.pillar-chat-input__source { }\n.pillar-chat-input__area { }\n.pillar-chat-input__wrapper { }\n.pillar-chat-input__input { }\n.pillar-chat-input__send-btn { }\n.pillar-loading { }\n.pillar-loading__spinner { }\n.pillar-empty { }\n.pillar-empty__icon { }\n.pillar-empty__title { }\n.pillar-empty__description { }\n.pillar-section-title { }\n.pillar-related-articles { }\n.pillar-home-view { }\n.pillar-chat-view { }\n.pillar-chat-view__messages { }\n.pillar-chat-view__welcome { }\n.pillar-chat-view__welcome-icon { }\n.pillar-chat-view__welcome-title { }\n.pillar-chat-view__welcome-text { }\n.pillar-chat-view__message { }\n.pillar-chat-view__message--user { }\n.pillar-chat-view__message--assistant { }\n.pillar-chat-view__user-bubble { }\n.pillar-chat-view__ai-response { }\n.pillar-chat-view__sources { }\n.pillar-chat-view__sources-title { }\n.pillar-chat-view__source { }\n.pillar-chat-view__input-area { }\n.pillar-chat-view__input-wrapper { }\n.pillar-chat-view__input { }\n.pillar-chat-view__send-btn { }\n.pillar-backdrop { }\n.pillar-backdrop--visible { }\n\n/* ============================================================================\n Task Button Component\n ============================================================================ */\n\n.pillar-task-btn {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 8px 14px;\n font-size: 13px;\n font-weight: 500;\n font-family: inherit;\n border-radius: 8px;\n cursor: pointer;\n transition: all 0.15s ease;\n border: 1px solid transparent;\n text-decoration: none;\n}\n\n.pillar-task-btn__icon {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n}\n\n.pillar-task-btn__icon svg {\n width: 16px;\n height: 16px;\n}\n\n.pillar-task-btn__label {\n white-space: nowrap;\n}\n\n/* Primary variant (default) */\n.pillar-task-btn--primary {\n background: #2563eb;\n color: #ffffff;\n border-color: #2563eb;\n}\n\n.pillar-task-btn--primary:hover {\n background: #1d4ed8;\n border-color: #1d4ed8;\n}\n\n/* Default variant */\n.pillar-task-btn--default {\n background: #f3f4f6;\n color: #1a1a1a;\n border-color: #e5e7eb;\n}\n\n.pillar-task-btn--default:hover {\n background: #e5e7eb;\n}\n\n/* Secondary variant */\n.pillar-task-btn--secondary {\n background: #eff6ff;\n color: #2563eb;\n border-color: #dbeafe;\n}\n\n.pillar-task-btn--secondary:hover {\n background: #dbeafe;\n}\n\n/* Outline variant */\n.pillar-task-btn--outline {\n background: transparent;\n color: #2563eb;\n border-color: #2563eb;\n}\n\n.pillar-task-btn--outline:hover {\n background: #eff6ff;\n}\n\n/* Ghost variant */\n.pillar-task-btn--ghost {\n background: transparent;\n color: #6b7280;\n border-color: transparent;\n}\n\n.pillar-task-btn--ghost:hover {\n background: #f3f4f6;\n color: #1a1a1a;\n}\n\n/* Task button group */\n.pillar-task-btn-group {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n margin-top: 12px;\n}\n\n/* Task suggestion card in chat */\n.pillar-task-suggestion {\n display: flex;\n flex-direction: column;\n gap: 8px;\n padding: 12px;\n background: #f9fafb;\n border: 1px solid #e5e7eb;\n border-radius: 12px;\n margin-top: 12px;\n}\n\n.pillar-task-suggestion__header {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 11px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n color: #6b7280;\n}\n\n.pillar-task-suggestion__header svg {\n width: 14px;\n height: 14px;\n}\n\n.pillar-task-suggestion__description {\n font-size: 13px;\n color: #374151;\n}\n\n/* ============================================================================\n Feedback Icons\n Internal: _pillar-feedback | Public: pillar-feedback\n ============================================================================ */\n\n._pillar-message-assistant-wrapper {\n position: relative;\n}\n\n._pillar-feedback-icons {\n display: flex;\n gap: 4px;\n margin-top: var(--pillar-spacing-sm);\n justify-content: flex-end;\n}\n\n._pillar-feedback-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n padding: 0;\n background: transparent;\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n color: var(--pillar-text-placeholder);\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-feedback-btn:hover {\n color: var(--pillar-text-muted);\n background: var(--pillar-bg-secondary);\n border-color: var(--pillar-border);\n}\n\n._pillar-feedback-btn--active {\n color: var(--pillar-primary);\n background: var(--pillar-primary-light);\n border-color: var(--pillar-primary);\n}\n\n._pillar-feedback-btn--active:hover {\n color: var(--pillar-primary);\n background: var(--pillar-primary-light-hover);\n}\n\n._pillar-feedback-btn svg {\n width: 14px;\n height: 14px;\n}\n\n.pillar-feedback-icons {}\n.pillar-feedback-btn {}\n.pillar-message-assistant-wrapper {}\n\n/* ============================================================================\n Action Status Indicators\n Internal: _pillar-action-status | Public: pillar-action-status\n Shows completion status for auto-run actions (checkmark, X, or spinner)\n ============================================================================ */\n\n._pillar-message-assistant-content {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: 8px;\n}\n\n._pillar-action-status {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n flex-shrink: 0;\n margin-top: 2px;\n}\n\n._pillar-action-status-indicator {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 18px;\n height: 18px;\n}\n\n._pillar-action-status-indicator svg {\n width: 16px;\n height: 16px;\n}\n\n._pillar-action-status-indicator--success {\n color: #22c55e;\n}\n\n._pillar-action-status-indicator--failed {\n color: #ef4444;\n}\n\n._pillar-action-status-indicator--pending {\n color: var(--pillar-text-muted);\n animation: pillar-spin 1s linear infinite;\n}\n\n@keyframes pillar-spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n}\n\n.pillar-action-status {}\n.pillar-action-status-indicator {}\n.pillar-message-assistant-content {}\n\n/* ============================================================================\n Context Tags\n Internal: _pillar-context-tag | Public: pillar-context-tag\n Removable chips for user context items (highlighted text, etc.)\n ============================================================================ */\n\n._pillar-context-tag-list {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n padding: 8px 14px 0;\n}\n\n._pillar-context-tag {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n max-width: 200px;\n padding: 4px 6px 4px 8px;\n font-size: var(--pillar-font-size-sm);\n color: var(--pillar-text-secondary);\n background: var(--pillar-bg-tertiary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-md);\n cursor: default;\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-context-tag:hover {\n background: var(--pillar-bg-secondary);\n border-color: var(--pillar-text-muted);\n}\n\n._pillar-context-tag-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 14px;\n height: 14px;\n flex-shrink: 0;\n color: var(--pillar-primary);\n}\n\n._pillar-context-tag-icon svg {\n width: 12px;\n height: 12px;\n}\n\n._pillar-context-tag-label {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n line-height: 1.3;\n}\n\n._pillar-context-tag-remove {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 16px;\n height: 16px;\n padding: 0;\n margin-left: 2px;\n color: var(--pillar-text-placeholder);\n background: transparent;\n border: none;\n border-radius: var(--pillar-radius-sm);\n cursor: pointer;\n flex-shrink: 0;\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-context-tag-remove:hover {\n color: var(--pillar-text);\n background: var(--pillar-border);\n}\n\n._pillar-context-tag-remove svg {\n width: 12px;\n height: 12px;\n}\n\n.pillar-context-tag-list {}\n.pillar-context-tag {}\n.pillar-context-tag-icon {}\n.pillar-context-tag-label {}\n.pillar-context-tag-remove {}\n\n/* Context tags inside user message bubbles need inverted colors */\n._pillar-message-user ._pillar-context-tag-list {\n padding: 0 0 8px 0;\n}\n\n._pillar-message-user ._pillar-context-tag {\n background: rgba(255, 255, 255, 0.2);\n border-color: rgba(255, 255, 255, 0.3);\n color: #ffffff;\n}\n\n._pillar-message-user ._pillar-context-tag:hover {\n background: rgba(255, 255, 255, 0.3);\n border-color: rgba(255, 255, 255, 0.4);\n}\n\n._pillar-message-user ._pillar-context-tag-icon {\n color: #ffffff;\n}\n\n._pillar-message-user ._pillar-context-tag-label {\n color: #ffffff;\n}\n\n/* ============================================================================\n Unified Chat Input\n Internal: _pillar-unified-input | Public: pillar-unified-input\n Reusable input component with context tag support\n ============================================================================ */\n\n._pillar-unified-input-wrapper {\n display: flex;\n flex-direction: column;\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-xl);\n transition: border-color var(--pillar-transition-fast), box-shadow var(--pillar-transition-fast);\n}\n\n._pillar-unified-input-wrapper:focus-within {\n border-color: var(--pillar-primary);\n box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);\n}\n\n._pillar-unified-input {\n display: block;\n width: 100%;\n padding: 12px 14px 8px;\n font-size: var(--pillar-font-size-base);\n font-family: var(--pillar-font-family);\n line-height: 1.5;\n color: var(--pillar-text);\n background: transparent;\n border: none;\n outline: none;\n resize: none;\n overflow-y: hidden;\n box-sizing: border-box;\n}\n\n._pillar-unified-input::placeholder {\n color: var(--pillar-text-placeholder);\n}\n\n._pillar-unified-input:disabled {\n opacity: 0.6;\n cursor: not-allowed;\n}\n\n._pillar-unified-input-row {\n display: flex;\n justify-content: flex-end;\n padding: 8px 10px;\n}\n\n._pillar-unified-send-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n padding: 0;\n color: #ffffff;\n background: var(--pillar-primary);\n border: none;\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n flex-shrink: 0;\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-unified-send-btn:hover:not(:disabled) {\n background: var(--pillar-primary-hover);\n}\n\n._pillar-unified-send-btn:disabled {\n color: var(--pillar-text-placeholder);\n background: var(--pillar-bg-tertiary);\n cursor: not-allowed;\n}\n\n._pillar-unified-send-btn svg {\n width: 16px;\n height: 16px;\n}\n\n.pillar-unified-input-wrapper {}\n.pillar-unified-input {}\n.pillar-unified-input-row {}\n.pillar-unified-send-btn {}\n\n._pillar-unified-stop-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n padding: 0;\n color: #ffffff;\n background: var(--pillar-text-secondary);\n border: none;\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n flex-shrink: 0;\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-unified-stop-btn:hover {\n background: var(--pillar-text);\n}\n\n._pillar-unified-stop-btn svg {\n width: 14px;\n height: 14px;\n}\n\n.pillar-unified-stop-btn {}\n\n/* ============================================================================\n Progress Row (for search, query, generating events)\n Internal: _pillar-progress-row | Public: pillar-progress-row\n ============================================================================ */\n\n._pillar-progress-events {\n margin: 4px 0;\n}\n\n._pillar-progress-row {\n margin: 1px 0;\n padding: 1px 0;\n font-size: 12px;\n animation: pillar-progress-row-fade-in 0.3s ease-in-out;\n}\n\n._pillar-progress-row--error {\n color: #dc2626;\n}\n\n@keyframes pillar-progress-row-fade-in {\n from { opacity: 0; }\n to { opacity: 1; }\n}\n\n._pillar-progress-row-header {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 2px 0;\n}\n\n._pillar-progress-expand-icon {\n font-size: 10px;\n color: var(--pillar-text-muted);\n transition: transform 0.2s ease;\n flex-shrink: 0;\n}\n\n._pillar-progress-row-header[style*="cursor: pointer"]:hover ._pillar-progress-expand-icon {\n color: var(--pillar-text-secondary);\n}\n\n._pillar-progress-row-header[data-expanded="true"] ._pillar-progress-expand-icon {\n transform: rotate(90deg);\n}\n\n._pillar-progress-message {\n color: var(--pillar-text-muted);\n font-size: 12px;\n font-style: italic;\n}\n\n._pillar-progress-no-results {\n color: var(--pillar-text-muted);\n font-size: 11px;\n font-style: italic;\n margin-left: 4px;\n}\n\n._pillar-progress-sources {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n._pillar-progress-source-item {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 2px 0;\n font-size: 11px;\n}\n\n._pillar-progress-source-link {\n flex: 1;\n display: flex;\n flex-direction: column;\n text-decoration: none;\n overflow: hidden;\n color: inherit;\n}\n\n._pillar-progress-source-link:hover ._pillar-progress-source-title {\n text-decoration: underline;\n}\n\n._pillar-progress-source-title {\n font-weight: 400;\n color: var(--pillar-text-muted);\n font-size: 11px;\n}\n\n._pillar-progress-details {\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n\n._pillar-progress-detail-item {\n font-size: 11px;\n color: var(--pillar-text-muted);\n padding: 1px 0;\n}\n\n._pillar-progress-detail-action {\n display: flex;\n flex-wrap: wrap;\n align-items: baseline;\n}\n\n._pillar-progress-detail-name {\n font-weight: 500;\n}\n\n._pillar-progress-detail-desc {\n color: var(--pillar-text-muted);\n opacity: 0.8;\n}\n\n._pillar-progress-content-wrapper {\n position: relative;\n display: grid;\n grid-template-rows: 0fr;\n transition: grid-template-rows 0.2s ease-out;\n}\n\n._pillar-progress-content-wrapper--expanded {\n grid-template-rows: 1fr;\n margin-top: 6px;\n}\n\n._pillar-progress-content-container {\n overflow: hidden;\n min-height: 0;\n scrollbar-width: thin;\n scrollbar-color: var(--pillar-scrollbar-thumb) transparent;\n}\n\n._pillar-progress-content-wrapper--expanded ._pillar-progress-content-container {\n max-height: 180px;\n overflow-y: auto;\n}\n\n._pillar-progress-content-container::-webkit-scrollbar {\n width: 4px;\n}\n\n._pillar-progress-content-container::-webkit-scrollbar-track {\n background: transparent;\n}\n\n._pillar-progress-content-container::-webkit-scrollbar-thumb {\n background-color: var(--pillar-scrollbar-thumb);\n border-radius: 2px;\n}\n\n._pillar-progress-content-gradient {\n position: absolute;\n bottom: 0;\n left: 16px;\n right: 0;\n height: 20px;\n background: linear-gradient(transparent, var(--pillar-bg));\n pointer-events: none;\n}\n\n._pillar-progress-text {\n font-size: 11px;\n color: var(--pillar-text-muted);\n line-height: 1.4;\n word-break: break-word;\n}\n\n._pillar-progress-text p {\n margin: 0 0 4px 0;\n}\n\n._pillar-progress-text p:last-child {\n margin-bottom: 0;\n}\n\n._pillar-progress-text ol,\n._pillar-progress-text ul {\n margin: 2px 0;\n padding-left: 16px;\n}\n\n._pillar-progress-text li {\n margin-bottom: 1px;\n}\n\n._pillar-progress-text br {\n display: block;\n content: "";\n margin-top: 2px;\n}\n\n/* Chevron indicator for progress rows - rotates based on expanded state */\n/* Positioned inline next to label, hidden by default, shown on hover */\n._pillar-progress-chevron {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 14px;\n height: 14px;\n flex-shrink: 0;\n font-size: 10px;\n color: var(--pillar-text-muted);\n transition: transform 0.2s ease, opacity 0.15s ease;\n opacity: 0;\n}\n\n._pillar-progress-row:hover ._pillar-progress-chevron {\n opacity: 1;\n}\n\n._pillar-progress-error-icon {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 14px;\n height: 14px;\n flex-shrink: 0;\n font-size: 10px;\n color: var(--pillar-error, #dc2626);\n}\n\n/* Text preview for streaming content */\n._pillar-progress-text-preview-wrapper {\n position: relative;\n margin-top: 4px;\n}\n\n._pillar-progress-text-preview {\n max-height: 180px;\n overflow-y: auto;\n font-size: 11px;\n color: var(--pillar-text-muted);\n line-height: 1.4;\n scroll-behavior: smooth;\n white-space: pre-wrap;\n word-break: break-word;\n scrollbar-width: thin;\n scrollbar-color: var(--pillar-scrollbar-thumb) transparent;\n}\n\n/* All content inside progress text preview should stay muted and small.\n Markdown headers, paragraphs, etc. must not look like answer text. */\n._pillar-progress-text-preview * {\n color: inherit !important;\n font-size: inherit !important;\n font-weight: normal !important;\n line-height: inherit !important;\n margin: 0 !important;\n}\n\n/* Top gradient - fades out older text at the top */\n._pillar-progress-text-gradient {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n height: 20px;\n background: linear-gradient(to bottom, var(--pillar-bg), transparent);\n pointer-events: none;\n z-index: 1;\n}\n\n._pillar-progress-text-preview::-webkit-scrollbar {\n width: 4px;\n}\n\n._pillar-progress-text-preview::-webkit-scrollbar-track {\n background: transparent;\n}\n\n._pillar-progress-text-preview::-webkit-scrollbar-thumb {\n background-color: var(--pillar-scrollbar-thumb);\n border-radius: 2px;\n}\n\n/* Active state indicator */\n._pillar-progress-row--active ._pillar-progress-message {\n font-weight: 500;\n}\n\n/* Long text truncation for labels */\n._pillar-progress-message {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n max-width: 300px;\n}\n\n/* Children/sub-items styling */\n._pillar-progress-children {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n._pillar-progress-child-item {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 2px 0;\n font-size: 11px;\n}\n\n._pillar-progress-child-link {\n color: var(--pillar-text-muted);\n text-decoration: none;\n transition: color 0.15s ease;\n}\n\n._pillar-progress-child-link:hover {\n color: var(--pillar-text-secondary);\n text-decoration: underline;\n}\n\n._pillar-progress-child-label {\n color: var(--pillar-text-muted);\n font-size: 11px;\n}\n\n/* ============================================================================\n Progress Group (collapsible tool event groups)\n Internal: _pillar-progress-group | Public: pillar-progress-group\n ============================================================================ */\n\n._pillar-progress-group {\n margin: 1px 0;\n animation: pillar-progress-row-fade-in 0.3s ease-in-out;\n}\n\n._pillar-progress-group-header {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 3px 0;\n cursor: pointer;\n font-size: 12px;\n color: var(--pillar-text-secondary, #6b7280);\n user-select: none;\n border-radius: 4px;\n transition: color 0.15s ease;\n}\n\n._pillar-progress-group-header:hover {\n color: var(--pillar-text-primary, #374151);\n}\n\n._pillar-progress-group-chevron {\n flex-shrink: 0;\n font-size: 8px;\n line-height: 1;\n color: inherit;\n}\n\n._pillar-progress-group-summary {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n._pillar-progress-group-active-dot {\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: var(--pillar-brand, #3b82f6);\n flex-shrink: 0;\n animation: pillar-progress-group-pulse 1.5s ease-in-out infinite;\n}\n\n@keyframes pillar-progress-group-pulse {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.4; }\n}\n\n._pillar-progress-group-children {\n display: grid;\n grid-template-rows: 0fr;\n transition: grid-template-rows 0.2s ease;\n overflow: hidden;\n}\n\n._pillar-progress-group-children--expanded {\n grid-template-rows: 1fr;\n}\n\n._pillar-progress-group-children-inner {\n min-height: 0;\n padding-left: 14px;\n}\n\n/* Nested rows inside groups have reduced spacing */\n._pillar-progress-row--nested {\n margin: 0;\n padding: 0;\n}\n\n._pillar-progress-row--nested ._pillar-progress-row-header {\n padding: 2px 0;\n}\n\n._pillar-progress-row--nested ._pillar-progress-message {\n font-size: 11px;\n}\n\n.pillar-progress-events {}\n.pillar-progress-chevron {}\n.pillar-progress-error-icon {}\n.pillar-progress-text-preview-wrapper {}\n.pillar-progress-text-preview {}\n.pillar-progress-text-gradient {}\n.pillar-progress-children {}\n.pillar-progress-child-item {}\n.pillar-progress-child-link {}\n.pillar-progress-child-label {}\n.pillar-progress-row {}\n.pillar-progress-row-header {}\n.pillar-progress-expand-icon {}\n.pillar-progress-message {}\n.pillar-progress-no-results {}\n.pillar-progress-sources {}\n.pillar-progress-source-item {}\n.pillar-progress-source-link {}\n.pillar-progress-source-title {}\n.pillar-progress-content-wrapper {}\n.pillar-progress-content-container {}\n.pillar-progress-content-gradient {}\n.pillar-progress-text {}\n.pillar-progress-group {}\n.pillar-progress-group-header {}\n.pillar-progress-group-chevron {}\n.pillar-progress-group-summary {}\n.pillar-progress-group-active-dot {}\n.pillar-progress-group-children {}\n\n/* ============================================================================\n Resume Prompt (Session Resumption)\n Internal: _pillar-resume-prompt | Public: pillar-resume-prompt\n Shows when user reconnects and has an interrupted session to resume\n ============================================================================ */\n\n._pillar-resume-prompt {\n display: flex;\n flex-direction: column;\n gap: var(--pillar-spacing-md);\n padding: var(--pillar-spacing-lg);\n margin: var(--pillar-spacing-md) 0;\n background: var(--pillar-bg-secondary);\n border: 1px solid var(--pillar-border);\n border-radius: var(--pillar-radius-lg);\n}\n\n._pillar-resume-prompt--seamless {\n flex-direction: row;\n align-items: center;\n gap: var(--pillar-spacing-sm);\n padding: var(--pillar-spacing-md) var(--pillar-spacing-lg);\n background: transparent;\n border: none;\n justify-content: center;\n}\n\n._pillar-resume-prompt-spinner {\n width: 16px;\n height: 16px;\n border: 2px solid var(--pillar-border);\n border-top-color: var(--pillar-primary);\n border-radius: 50%;\n animation: pillar-spin 0.8s linear infinite;\n flex-shrink: 0;\n}\n\n._pillar-resume-prompt-text {\n font-size: var(--pillar-font-size-sm);\n color: var(--pillar-text-muted);\n font-style: italic;\n}\n\n._pillar-resume-prompt-content {\n display: flex;\n gap: var(--pillar-spacing-md);\n align-items: flex-start;\n}\n\n._pillar-resume-prompt-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 36px;\n height: 36px;\n flex-shrink: 0;\n color: var(--pillar-primary);\n background: var(--pillar-primary-light);\n border-radius: var(--pillar-radius-md);\n}\n\n._pillar-resume-prompt-body {\n flex: 1;\n min-width: 0;\n}\n\n._pillar-resume-prompt-title {\n font-size: var(--pillar-font-size-base);\n font-weight: 600;\n color: var(--pillar-text);\n margin-bottom: var(--pillar-spacing-xs);\n}\n\n._pillar-resume-prompt-message {\n display: flex;\n flex-direction: column;\n gap: 2px;\n font-size: var(--pillar-font-size-sm);\n color: var(--pillar-text-muted);\n}\n\n._pillar-resume-prompt-user-msg {\n font-style: italic;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n._pillar-resume-prompt-summary {\n font-size: var(--pillar-font-size-xs);\n color: var(--pillar-text-placeholder);\n}\n\n._pillar-resume-prompt-actions {\n display: flex;\n gap: var(--pillar-spacing-sm);\n justify-content: flex-end;\n}\n\n._pillar-resume-prompt-btn {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 8px 14px;\n font-size: var(--pillar-font-size-sm);\n font-weight: 500;\n font-family: var(--pillar-font-family);\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n transition: all var(--pillar-transition-fast);\n border: 1px solid transparent;\n}\n\n._pillar-resume-prompt-btn--primary {\n background: var(--pillar-primary);\n color: #ffffff;\n border-color: var(--pillar-primary);\n}\n\n._pillar-resume-prompt-btn--primary:hover {\n background: var(--pillar-primary-hover);\n border-color: var(--pillar-primary-hover);\n}\n\n._pillar-resume-prompt-btn--ghost {\n background: transparent;\n color: var(--pillar-text-muted);\n border-color: transparent;\n}\n\n._pillar-resume-prompt-btn--ghost:hover {\n background: var(--pillar-bg-tertiary);\n color: var(--pillar-text);\n}\n\n._pillar-resume-prompt-btn svg {\n width: 14px;\n height: 14px;\n flex-shrink: 0;\n}\n\n.pillar-resume-prompt {}\n.pillar-resume-prompt-spinner {}\n.pillar-resume-prompt-text {}\n.pillar-resume-prompt-content {}\n.pillar-resume-prompt-icon {}\n.pillar-resume-prompt-body {}\n.pillar-resume-prompt-title {}\n.pillar-resume-prompt-message {}\n.pillar-resume-prompt-user-msg {}\n.pillar-resume-prompt-summary {}\n.pillar-resume-prompt-actions {}\n.pillar-resume-prompt-btn {}\n',il="\n/* Task Button Component */\n.pillar-task-btn {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 8px 14px;\n font-size: 13px;\n font-weight: 500;\n font-family: inherit;\n border-radius: 8px;\n cursor: pointer;\n transition: all 0.15s ease;\n border: 1px solid transparent;\n text-decoration: none;\n}\n\n.pillar-task-btn__icon {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n}\n\n.pillar-task-btn__icon svg {\n width: 16px;\n height: 16px;\n}\n\n.pillar-task-btn__label {\n white-space: nowrap;\n}\n\n/* Primary variant (default) */\n.pillar-task-btn--primary {\n background: #2563eb;\n color: #ffffff;\n border-color: #2563eb;\n}\n\n.pillar-task-btn--primary:hover {\n background: #1d4ed8;\n border-color: #1d4ed8;\n}\n\n/* Default variant */\n.pillar-task-btn--default {\n background: #f3f4f6;\n color: #1a1a1a;\n border-color: #e5e7eb;\n}\n\n.pillar-task-btn--default:hover {\n background: #e5e7eb;\n}\n\n/* Secondary variant */\n.pillar-task-btn--secondary {\n background: #eff6ff;\n color: #2563eb;\n border-color: #dbeafe;\n}\n\n.pillar-task-btn--secondary:hover {\n background: #dbeafe;\n}\n\n/* Outline variant */\n.pillar-task-btn--outline {\n background: transparent;\n color: #2563eb;\n border-color: #2563eb;\n}\n\n.pillar-task-btn--outline:hover {\n background: #eff6ff;\n}\n\n/* Ghost variant */\n.pillar-task-btn--ghost {\n background: transparent;\n color: #6b7280;\n border-color: transparent;\n}\n\n.pillar-task-btn--ghost:hover {\n background: #f3f4f6;\n color: #1a1a1a;\n}\n\n/* Active state for inline_ui buttons with expanded card */\n.pillar-task-btn--active {\n background: #1d4ed8;\n border-color: #1d4ed8;\n}\n\n/* Task button group */\n.pillar-task-btn-group {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n margin-top: 12px;\n}\n\n/* Inline card container for inline_ui actions */\n.pillar-task-btn-inline-card {\n margin-top: 12px;\n animation: pillar-slide-down 0.15s ease-out;\n}\n\n@keyframes pillar-slide-down {\n from {\n opacity: 0;\n transform: translateY(-8px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n/* Task suggestion card in chat */\n.pillar-task-suggestion {\n display: flex;\n flex-direction: column;\n gap: 8px;\n padding: 12px;\n background: #f9fafb;\n border: 1px solid #e5e7eb;\n border-radius: 12px;\n margin-top: 12px;\n}\n\n.pillar-task-suggestion__header {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 11px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n color: #6b7280;\n}\n\n.pillar-task-suggestion__header svg {\n width: 14px;\n height: 14px;\n}\n\n.pillar-task-suggestion__description {\n font-size: 13px;\n color: #374151;\n}\n",al=Xe(null),ll=Xe([]);an(()=>null!==al.value),an(()=>al.value&&al.value.steps[al.value.current_step]||null);const ol=an(()=>al.value?al.value.steps.filter(e=>"completed"===e.status||"skipped"===e.status).length:0);function sl(e,n){if(!al.value)return;const t=al.value.steps.map((t,r)=>r===e?{...t,status:n}:t);al.value={...al.value,steps:t}}function cl(){if(!al.value)return null;const e=al.value.current_step+1;if(e>=al.value.steps.length)return null;const n=al.value.steps[e].auto_run?"active":"awaiting_initiation",t=al.value.steps.map((t,r)=>r===e?{...t,status:n}:t);return al.value={...al.value,steps:t,current_step:e},al.value.steps[e]}function pl(){if(!al.value)return null;const e=al.value;return ll.value=[...ll.value,e],al.value=null,e}an(()=>al.value?ol.value/al.value.total_steps:0);const dl="\n/* Workflow Checklist Container */\n.pillar-workflow {\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding: 16px;\n background: #f9fafb;\n border: 1px solid #e5e7eb;\n border-radius: 12px;\n margin: 12px 0;\n}\n\n/* Header */\n.pillar-workflow__header {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n\n.pillar-workflow__icon {\n display: flex;\n align-items: center;\n justify-content: center;\n color: #6b7280;\n}\n\n.pillar-workflow__title {\n flex: 1;\n font-size: 14px;\n font-weight: 600;\n color: #1a1a1a;\n}\n\n.pillar-workflow__progress {\n font-size: 12px;\n font-weight: 500;\n color: #6b7280;\n padding: 2px 8px;\n background: #e5e7eb;\n border-radius: 10px;\n}\n\n.pillar-workflow__description {\n font-size: 13px;\n color: #6b7280;\n}\n\n/* Steps List */\n.pillar-workflow__steps {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n/* Individual Step */\n.pillar-workflow-step {\n display: flex;\n align-items: flex-start;\n gap: 10px;\n padding: 10px 12px;\n background: #ffffff;\n border: 1px solid #e5e7eb;\n border-radius: 8px;\n transition: all 0.15s ease;\n}\n\n.pillar-workflow-step__icon {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n width: 24px;\n height: 24px;\n color: #9ca3af;\n}\n\n.pillar-workflow-step__icon svg {\n width: 18px;\n height: 18px;\n}\n\n.pillar-workflow-step__content {\n flex: 1;\n min-width: 0;\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n.pillar-workflow-step__label {\n font-size: 13px;\n font-weight: 500;\n color: #374151;\n}\n\n.pillar-workflow-step__note {\n font-size: 12px;\n color: #9ca3af;\n}\n\n.pillar-workflow-step__status-text {\n font-size: 12px;\n color: #2563eb;\n font-style: italic;\n}\n\n.pillar-workflow-step__actions {\n display: flex;\n gap: 8px;\n margin-top: 4px;\n}\n\n/* Step States */\n.pillar-workflow-step--pending {\n opacity: 0.6;\n}\n\n.pillar-workflow-step--awaiting_initiation {\n background: #fef3c7;\n border-color: #fcd34d;\n}\n\n.pillar-workflow-step--awaiting_initiation .pillar-workflow-step__icon {\n color: #d97706;\n}\n\n.pillar-workflow-step--active {\n background: #eff6ff;\n border-color: #93c5fd;\n}\n\n.pillar-workflow-step--active .pillar-workflow-step__icon {\n color: #2563eb;\n}\n\n.pillar-workflow-step--completed .pillar-workflow-step__icon {\n color: #059669;\n}\n\n.pillar-workflow-step--completed .pillar-workflow-step__label {\n text-decoration: line-through;\n color: #6b7280;\n}\n\n.pillar-workflow-step--skipped {\n opacity: 0.5;\n}\n\n.pillar-workflow-step--skipped .pillar-workflow-step__icon {\n color: #9ca3af;\n}\n\n.pillar-workflow-step--skipped .pillar-workflow-step__label {\n text-decoration: line-through;\n color: #9ca3af;\n}\n\n.pillar-workflow-step--failed {\n background: #fef2f2;\n border-color: #fca5a5;\n}\n\n.pillar-workflow-step--failed .pillar-workflow-step__icon {\n color: #dc2626;\n}\n\n/* Start Button */\n.pillar-workflow-step__start-btn {\n display: inline-flex;\n align-items: center;\n padding: 6px 12px;\n font-size: 12px;\n font-weight: 600;\n font-family: inherit;\n background: #2563eb;\n color: #ffffff;\n border: none;\n border-radius: 6px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-workflow-step__start-btn:hover {\n background: #1d4ed8;\n}\n\n/* Skip Button */\n.pillar-workflow-step__skip-btn {\n display: inline-flex;\n align-items: center;\n padding: 6px 12px;\n font-size: 12px;\n font-weight: 500;\n font-family: inherit;\n background: transparent;\n color: #6b7280;\n border: 1px solid #d1d5db;\n border-radius: 6px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-workflow-step__skip-btn:hover {\n background: #f3f4f6;\n color: #374151;\n}\n\n/* Spinner Animation for Active Step */\n@keyframes pillar-spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}\n\n.pillar-workflow-step__spinner {\n animation: pillar-spin 1s linear infinite;\n}\n\n/* Footer */\n.pillar-workflow__footer {\n display: flex;\n justify-content: flex-end;\n padding-top: 8px;\n border-top: 1px solid #e5e7eb;\n}\n\n.pillar-workflow__cancel-btn {\n padding: 6px 12px;\n font-size: 12px;\n font-weight: 500;\n font-family: inherit;\n background: transparent;\n color: #9ca3af;\n border: none;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.pillar-workflow__cancel-btn:hover {\n color: #dc2626;\n}\n";class ul{constructor(e,n,t,r){this.host=null,this.shadow=null,this.backdrop=null,this.panelElement=null,this.renderRoot=null,this.unsubscribe=null,this.isManualMount=!1,this.themeObserver=null,this.handleKeyDown=e=>{"Escape"===e.key&&vn.value&&zn()},this.config=e,this.api=n,this.events=t,this.rootContainer=r||null,this.isManualMount="manual"===e.panel.container}detectThemeFromDOM(){const e=document.documentElement;if(e.classList.contains("dark"))return"dark";return"dark"===e.getAttribute("data-theme")||"dark"===e.style.colorScheme?"dark":"light"}get isOpen(){return vn.value}async init(){var e,n,t;e=this.config.panel.position,xn.value=e,(e=>{yn.value=e})(this.config.panel.mode),(e=>{wn.value=e})(this.config.panel.width),n=this.config.panel.hoverBreakpoint,kn.value=n,t=this.config.panel.hoverBackdrop,Sn.value=t,(()=>{if("undefined"==typeof window)return;Tn?.();const e=()=>{En.value=window.innerWidth};En.value=window.innerWidth,window.addEventListener("resize",e),Tn=()=>{window.removeEventListener("resize",e)}})(),this.createHost(),this.isManualMount||this.createBackdrop(),this.createPanel(),this.renderPreact(),this.bindEvents(),this.subscribeToState()}open(e){if(e?.search&&(Bt(e.search),dr("chat"),Ft()),vn.value)return e?.view&&dr(e.view),void(e?.focusInput&&Wt());vn.value=!0,bn(!0),"overlay"===An.value&&(document.body.style.overflow="hidden"),e?.view&&!e?.search&&dr(e.view),e?.focusInput?Wt():this.setupFocusTrap()}close(){vn.value&&zn()}navigate(e,n){vn.value?dr(e,n):this.open({view:e})}destroy(){this.close(),this.isManualMount||this.removePushModeStyles(),this.unsubscribe?.(),this.unsubscribe=null,Tn?.(),Tn=null,this.themeObserver?.disconnect(),this.themeObserver=null,this.renderRoot&&ue(null,this.renderRoot),this.backdrop?.remove(),this.host?.remove(),document.getElementById("pillar-sdk-styles")?.remove(),document.getElementById("pillar-sdk-theme")?.remove(),document.getElementById("pillar-sdk-custom")?.remove(),this.host=null,this.shadow=null,this.backdrop=null,this.panelElement=null,this.renderRoot=null,document.removeEventListener("keydown",this.handleKeyDown),Rn(),gr(),Jt()}subscribeToState(){if(this.isManualMount)return void(this.unsubscribe=vn.subscribe(e=>{e||this.events.emit("panel:close")}));let e=vn.value,n=An.value;const t=()=>{const e=vn.value,n="push"===An.value,t=wn.value,r=xn.value,i=In.value&&Sn.value;e?(n?(this.applyPushModeStyles(t,r),this.backdrop?.classList.remove("_pillar-backdrop--visible","pillar-backdrop--visible")):(this.removePushModeStyles(),document.body.style.overflow="hidden",i?this.backdrop?.classList.add("_pillar-backdrop--visible","pillar-backdrop--visible"):this.backdrop?.classList.remove("_pillar-backdrop--visible","pillar-backdrop--visible")),this.panelElement?.classList.add("_pillar-panel--open","pillar-panel--open")):(this.removePushModeStyles(),document.body.style.overflow="",this.backdrop?.classList.remove("_pillar-backdrop--visible","pillar-backdrop--visible"),this.panelElement?.classList.remove("_pillar-panel--open","pillar-panel--open"))};t();const r=vn.subscribe(n=>{n!==e&&(e=n,t(),n||this.events.emit("panel:close"))}),i=An.subscribe(e=>{e!==n&&(n=e,t())}),a=Mn.subscribe(e=>{e?this.panelElement?.classList.add("_pillar-panel--full-width","pillar-panel--full-width"):this.panelElement?.classList.remove("_pillar-panel--full-width","pillar-panel--full-width")});this.unsubscribe=()=>{r(),i(),a()}}applyPushModeStyles(e,n){document.documentElement.style.transition="padding 0.3s ease","right"===n?(document.documentElement.style.paddingRight=`${e}px`,document.documentElement.style.setProperty("--pillar-inset-right",`${e}px`),document.documentElement.style.setProperty("--pillar-inset-left","0px")):(document.documentElement.style.paddingLeft=`${e}px`,document.documentElement.style.setProperty("--pillar-inset-left",`${e}px`),document.documentElement.style.setProperty("--pillar-inset-right","0px"))}removePushModeStyles(){document.documentElement.style.paddingLeft="",document.documentElement.style.paddingRight="",document.documentElement.style.removeProperty("--pillar-inset-right"),document.documentElement.style.removeProperty("--pillar-inset-left"),setTimeout(()=>{vn.value||(document.documentElement.style.transition="")},300)}get renderContainer(){return this.shadow||this.host}transformStylesForRegularDOM(e){return e.replace(/:host\(([^)]+)\)/g,"[data-pillar-panel]$1").replace(/:host-context\(([^)]+)\)/g,"$1 [data-pillar-panel]").replace(/:host:not\(([^)]+)\)/g,"[data-pillar-panel]:not($1)").replace(/:host/g,"[data-pillar-panel]")}injectStylesIntoHead(){const e="pillar-sdk-styles";if(document.getElementById(e))return;const n=rl+il+dl+br+Oa+qa,t=this.transformStylesForRegularDOM(n),r=document.createElement("style");r.id=e,r.textContent=t,document.head.appendChild(r);const i=tl(this.config.theme);if(i){const e=document.createElement("style");e.id="pillar-sdk-theme",e.textContent=this.transformStylesForRegularDOM(i),document.head.appendChild(e)}if(this.config.customCSS){const e=document.createElement("style");e.id="pillar-sdk-custom",e.textContent=this.transformStylesForRegularDOM(this.config.customCSS),document.head.appendChild(e)}}injectStylesIntoShadow(){if(!this.shadow)return;const e=document.createElement("style");e.textContent=rl+il+dl+br+Oa+qa,this.shadow.appendChild(e);const n=tl(this.config.theme);if(n){const e=document.createElement("style");e.textContent=n,e.setAttribute("data-pillar-theme",""),this.shadow.appendChild(e)}if(this.config.customCSS){const e=document.createElement("style");e.textContent=this.config.customCSS,e.setAttribute("data-pillar-custom",""),this.shadow.appendChild(e)}}createHost(){this.host=document.createElement("div"),this.host.className="pillar-panel-host",this.host.setAttribute("data-pillar-panel",""),this.config.panel.useShadowDOM?(this.shadow=this.host.attachShadow({mode:"open"}),this.injectStylesIntoShadow()):(this.shadow=null,this.injectStylesIntoHead()),this.applyThemeMode(),this.setupThemeObserver();const e=this.config.panel.container;if("manual"===e)return;const n=this.rootContainer||document.body;let t=null;"string"==typeof e?(t=document.querySelector(e),t||(p.warn(`[Pillar] Container element not found: ${e}, falling back to root container`),t=n)):t=e instanceof HTMLElement?e:n,t.appendChild(this.host)}mountTo(e){this.host?(this.host.parentElement&&this.host.parentElement.removeChild(this.host),e.appendChild(this.host)):p.warn("[Pillar] Panel host not created yet")}getHostElement(){return this.host}createBackdrop(){this.backdrop=document.createElement("div"),this.backdrop.className="_pillar-backdrop pillar-backdrop",this.backdrop.style.cssText="\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.3);\n opacity: 0;\n visibility: hidden;\n transition: opacity 0.3s ease, visibility 0.3s ease;\n z-index: 99998;\n ",this.backdrop.addEventListener("click",()=>{zn()});(this.rootContainer||document.body).appendChild(this.backdrop)}createPanel(){const e=this.renderContainer;if(!e)return;this.panelElement=document.createElement("div");const n=this.isManualMount?" _pillar-panel--manual pillar-panel--manual":"",t=`_pillar-panel--${xn.value} pillar-panel--${xn.value}`;this.panelElement.className=`_pillar-panel pillar-panel ${t}${n}`,this.panelElement.style.setProperty("--pillar-panel-width",`${wn.value}px`),this.panelElement.setAttribute("role","dialog"),this.panelElement.setAttribute("aria-modal","true"),this.panelElement.setAttribute("aria-label","Assistant panel"),this.renderRoot=document.createElement("div"),this.renderRoot.className="_pillar-panel-root pillar-panel-root",this.panelElement.appendChild(this.renderRoot),e.appendChild(this.panelElement)}renderPreact(){this.renderRoot&&ue(ge(_r,{api:this.api,events:this.events,children:ge(el,{})}),this.renderRoot)}bindEvents(){document.addEventListener("keydown",this.handleKeyDown)}setupFocusTrap(){setTimeout(()=>{const e=this.renderContainer,n=e?.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');n?.focus()},100)}applyThemeMode(){if(!this.host)return;const e=this.config.theme.mode;if("light"===e||"dark"===e)this.host.setAttribute("data-theme",e);else{const e=this.detectThemeFromDOM();this.host.setAttribute("data-theme",e)}}setupThemeObserver(){"auto"===this.config.theme.mode&&(this.themeObserver=new MutationObserver(()=>{this.applyThemeMode()}),this.themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme","style"]}))}setTheme(e){this.config={...this.config,theme:{...this.config.theme,...e,colors:{...this.config.theme.colors,...e.colors},darkColors:{...this.config.theme.darkColors,...e.darkColors}}},this.applyThemeMode();const n=tl(this.config.theme);if(this.shadow){const e=this.shadow.querySelector("style[data-pillar-theme]");if(e&&n)e.textContent=n;else if(n&&!e){const e=document.createElement("style");e.textContent=n,e.setAttribute("data-pillar-theme","");const t=this.shadow.querySelector("style");t?.nextSibling?this.shadow.insertBefore(e,t.nextSibling):this.shadow.appendChild(e)}}else{const e=this.transformStylesForRegularDOM(n),t=document.getElementById("pillar-sdk-theme");if(t&&e)t.textContent=e;else if(e&&!t){const n=document.createElement("style");n.id="pillar-sdk-theme",n.textContent=e,document.head.appendChild(n)}}}}function hl({label:e,x:n,y:t,isVisible:r,onClick:i}){const a=Me(null),[l,o]=Ie({x:n,y:t}),[s,c]=Ie(!1),p=ze(()=>{if(!a.current||!r)return;const e=a.current.getBoundingClientRect(),i=window.innerWidth;let l=n,s=t,p=!1;l=n-e.width/2,l<10?l=10:l+e.width>i-10&&(l=i-e.width-10),s=t-e.height-10,s<10&&(s=t+10,p=!0),o({x:l,y:s}),c(p)},[n,t,r]);$e(()=>{r&&requestAnimationFrame(p)},[r,p,n,t]);return ge("div",{ref:a,class:`pillar-text-selection-popover${r?" pillar-text-selection-popover--visible":""}${s?" pillar-text-selection-popover--below":""}`,style:{left:`${l.x}px`,top:`${l.y}px`},onClick:e=>{e.preventDefault(),e.stopPropagation(),i()},role:"button",tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),i())},children:[ge("div",{class:"pillar-text-selection-popover__content",children:[ge("span",{class:"pillar-text-selection-popover__icon",dangerouslySetInnerHTML:{__html:'<svg viewBox="0 0 20 20" fill="currentColor"><path d="M10 2a1 1 0 011 1v1.323l3.954 1.582 1.599-.8a1 1 0 01.894 1.79l-1.233.616 1.738 5.42a1 1 0 01-.285 1.05A3.989 3.989 0 0115 15a3.989 3.989 0 01-2.667-1.019 1 1 0 01-.285-1.05l1.715-5.349L10 6.477l-3.763 1.105 1.715 5.349a1 1 0 01-.285 1.05A3.989 3.989 0 015 15a3.989 3.989 0 01-2.667-1.019 1 1 0 01-.285-1.05l1.738-5.42-1.233-.617a1 1 0 01.894-1.788l1.599.799L9 4.323V3a1 1 0 011-1z"/></svg>'}}),ge("span",{children:e})]}),ge("div",{class:"pillar-text-selection-popover__arrow"})]})}const gl="pillar-text-selection-styles";class fl{constructor(e,n,t){this.container=null,this.isVisible=!1,this.currentSelection="",this.stylesInjected=!1,this.handleMouseUp=e=>{setTimeout(()=>{this.checkSelection(e)},10)},this.handleMouseDown=e=>{e.target.closest(".pillar-text-selection-popover")||this.hidePopover()},this.handleKeyDown=e=>{"Escape"===e.key&&this.hidePopover()},this.handleScroll=()=>{this.isVisible&&this.hidePopover()},this.handlePopoverClick=()=>{this.currentSelection&&(this.events.emit("textSelection:click",{text:this.currentSelection}),Kt({type:"highlighted_text",url_origin:window.location.href,text_content:this.currentSelection}),this.hidePopover(),window.getSelection()?.removeAllRanges(),this.openPanel())},this.config=e,this.events=n,this.openPanel=t}init(){this.stylesInjected||(Ln(document,"\n/* Pillar Text Selection Popover Styles */\n.pillar-text-selection-popover {\n position: absolute;\n z-index: 99999;\n padding: 6px 12px;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n font-size: 13px;\n font-weight: 500;\n line-height: 1;\n color: #ffffff;\n background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3), 0 2px 4px rgba(0, 0, 0, 0.1);\n pointer-events: auto;\n opacity: 0;\n transform: translateY(4px) scale(0.95);\n transition: opacity 0.15s ease, transform 0.15s ease;\n cursor: pointer;\n user-select: none;\n}\n\n.pillar-text-selection-popover.pillar-text-selection-popover--visible {\n opacity: 1;\n transform: translateY(0) scale(1);\n}\n\n.pillar-text-selection-popover:hover {\n background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);\n box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4), 0 2px 4px rgba(0, 0, 0, 0.1);\n}\n\n.pillar-text-selection-popover:active {\n transform: translateY(0) scale(0.98);\n}\n\n.pillar-text-selection-popover__content {\n display: flex;\n align-items: center;\n gap: 6px;\n}\n\n.pillar-text-selection-popover__icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 14px;\n height: 14px;\n}\n\n.pillar-text-selection-popover__icon svg {\n width: 100%;\n height: 100%;\n}\n\n/* Arrow pointing down to selection */\n.pillar-text-selection-popover__arrow {\n position: absolute;\n bottom: -5px;\n left: 50%;\n transform: translateX(-50%) rotate(45deg);\n width: 10px;\n height: 10px;\n background: linear-gradient(135deg, #8b5cf6 0%, #8b5cf6 100%);\n}\n\n.pillar-text-selection-popover--below .pillar-text-selection-popover__arrow {\n bottom: auto;\n top: -5px;\n background: linear-gradient(135deg, #6366f1 0%, #6366f1 100%);\n}\n",gl),this.stylesInjected=!0),this.container=document.createElement("div"),this.container.id="pillar-text-selection-container",document.body.appendChild(this.container),this.bindEvents()}destroy(){this.unbindEvents(),this.container&&(ue(null,this.container),this.container.remove(),this.container=null),document.getElementById(gl)?.remove(),this.stylesInjected=!1,this.isVisible=!1,this.currentSelection=""}bindEvents(){document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("mousedown",this.handleMouseDown),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("scroll",this.handleScroll,!0)}unbindEvents(){document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("scroll",this.handleScroll,!0)}checkSelection(e){const n=window.getSelection();if(!n||n.isCollapsed)return;const t=n.toString().trim();if(t.length<3)return;const r=n.getRangeAt(0),i=r.commonAncestorContainer,a=i instanceof Element?i:i.parentElement;if(a?.closest("[data-pillar-panel]")||a?.closest(".pillar-panel-host"))return;const l=r.getBoundingClientRect(),o=l.left+l.width/2,s=l.top+window.scrollY;this.currentSelection=t,this.showPopover(o,s)}showPopover(e,n){this.container&&(this.isVisible=!0,ue(ge(hl,{label:this.config.textSelection.label,x:e,y:n,isVisible:!0,onClick:this.handlePopoverClick}),this.container),this.events.emit("textSelection:shown",{text:this.currentSelection}))}hidePopover(){this.container&&this.isVisible&&(this.isVisible=!1,ue(ge(hl,{label:this.config.textSelection.label,x:0,y:0,isVisible:!1,onClick:()=>{}}),this.container))}}function ml(){const e=Hr.value,n=Vr.value;if(!e&&!n)return null;if(n){const e=Gr.value||"Destructive action",n=e=>{e.preventDefault(),e.stopPropagation(),Qr(!0)},t=e=>{e.preventDefault(),e.stopPropagation(),Qr(!1)};return ge("div",{class:"_pillar-page-pilot-banner pillar-page-pilot-banner _pillar-page-pilot-banner--confirm pillar-page-pilot-banner--confirm",children:ge("div",{class:"_pillar-page-pilot-banner__content pillar-page-pilot-banner__content",children:[ge("span",{class:"_pillar-page-pilot-banner__warning-icon pillar-page-pilot-banner__warning-icon",dangerouslySetInnerHTML:{__html:'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>'}}),ge("span",{class:"_pillar-page-pilot-banner__text pillar-page-pilot-banner__text",children:e}),ge("button",{type:"button",class:"_pillar-page-pilot-banner__deny pillar-page-pilot-banner__deny",onClick:t,"aria-label":"Deny destructive action",children:"Deny"}),ge("button",{type:"button",class:"_pillar-page-pilot-banner__allow pillar-page-pilot-banner__allow",onClick:n,"aria-label":"Allow destructive action",children:"Allow"})]})})}return ge("div",{class:"_pillar-page-pilot-banner pillar-page-pilot-banner",children:ge("div",{class:"_pillar-page-pilot-banner__content pillar-page-pilot-banner__content",children:[ge("span",{class:"_pillar-page-pilot-banner__indicator pillar-page-pilot-banner__indicator"}),ge("span",{class:"_pillar-page-pilot-banner__text pillar-page-pilot-banner__text",children:"Page being piloted by Agent"}),ge("button",{type:"button",class:"_pillar-page-pilot-banner__stop pillar-page-pilot-banner__stop",onClick:e=>{e.preventDefault(),e.stopPropagation(),Fr()},"aria-label":"Stop agent action",children:[ge("span",{class:"_pillar-page-pilot-banner__stop-icon pillar-page-pilot-banner__stop-icon",dangerouslySetInnerHTML:{__html:'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/></svg>'}}),ge("span",{children:"Stop"})]})]})})}const bl="pillar-page-pilot-styles";class vl{constructor(){this.container=null,this.stylesInjected=!1,this.unsubscribe=null,this.themeObserver=null}detectThemeFromDOM(){const e=document.documentElement;if(e.classList.contains("dark"))return"dark";const n=e.getAttribute("data-theme");return"dark"===n?"dark":"light"}applyTheme(){if(!this.container)return;const e=this.detectThemeFromDOM();this.container.setAttribute("data-theme",e)}setupThemeObserver(){this.themeObserver=new MutationObserver(()=>{this.applyTheme()}),this.themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme","style"]})}init(e){this.primaryColor=e,this.stylesInjected||(Ln(document,"\n/* Pillar Page Pilot Banner Styles */\n\n/* Define CSS variables at the container level (same as panel) */\n#pillar-page-pilot-container {\n /* Core colors - Light mode (default) */\n --pillar-primary: #2563eb;\n --pillar-primary-hover: #1d4ed8;\n --pillar-bg: #ffffff;\n --pillar-bg-secondary: #f9fafb;\n --pillar-text: #1a1a1a;\n --pillar-text-secondary: #374151;\n --pillar-border: #e5e7eb;\n --pillar-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);\n --pillar-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n --pillar-radius-lg: 8px;\n --pillar-radius-md: 6px;\n --pillar-transition-fast: 0.15s ease;\n}\n\n/* Dark mode - Auto-detect from system preference */\n@media (prefers-color-scheme: dark) {\n #pillar-page-pilot-container:not([data-theme=\"light\"]) {\n --pillar-primary: #3b82f6;\n --pillar-primary-hover: #60a5fa;\n --pillar-bg: #1a1a1a;\n --pillar-bg-secondary: #262626;\n --pillar-text: #f5f5f5;\n --pillar-text-secondary: #e5e5e5;\n --pillar-border: #404040;\n --pillar-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);\n }\n}\n\n/* Dark mode - Manual override via html class or data attribute */\nhtml.dark #pillar-page-pilot-container,\n[data-theme=\"dark\"] #pillar-page-pilot-container,\n#pillar-page-pilot-container[data-theme=\"dark\"] {\n --pillar-primary: #3b82f6;\n --pillar-primary-hover: #60a5fa;\n --pillar-bg: #1a1a1a;\n --pillar-bg-secondary: #262626;\n --pillar-text: #f5f5f5;\n --pillar-text-secondary: #e5e5e5;\n --pillar-border: #404040;\n --pillar-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);\n}\n\n@keyframes pillar-pulse {\n 0%, 100% {\n opacity: 1;\n transform: scale(1);\n }\n 50% {\n opacity: 0.6;\n transform: scale(1.1);\n }\n}\n\n@keyframes pillar-banner-fade-in {\n from {\n opacity: 0;\n transform: translateY(-100%);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n._pillar-page-pilot-banner {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n z-index: 99999;\n font-family: var(--pillar-font-family);\n display: flex;\n justify-content: center;\n pointer-events: none;\n animation: pillar-banner-fade-in 0.2s ease-out;\n}\n\n/* Viewport outline — 3px border on left, right, bottom; top handled by tab shape */\n._pillar-page-pilot-banner::before {\n content: '';\n position: fixed;\n inset: 0;\n border: 3px solid var(--pillar-primary);\n border-top: none;\n pointer-events: none;\n z-index: 99998;\n}\n\n/* Top border segments on either side of the tab */\n._pillar-page-pilot-banner::after {\n content: '';\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n height: 3px;\n background: var(--pillar-primary);\n pointer-events: none;\n z-index: 99997;\n}\n\n._pillar-page-pilot-banner__content {\n position: relative;\n z-index: 99999;\n display: flex;\n align-items: center;\n gap: 12px;\n padding: 6px 20px;\n background: var(--pillar-primary);\n color: #ffffff;\n border-bottom-left-radius: var(--pillar-radius-lg);\n border-bottom-right-radius: var(--pillar-radius-lg);\n pointer-events: auto;\n}\n\n._pillar-page-pilot-banner__indicator {\n width: 8px;\n height: 8px;\n background: #ffffff;\n border-radius: 50%;\n animation: pillar-pulse 1.5s ease-in-out infinite;\n flex-shrink: 0;\n}\n\n._pillar-page-pilot-banner__text {\n font-size: 13px;\n font-weight: 500;\n color: #ffffff;\n white-space: nowrap;\n}\n\n._pillar-page-pilot-banner__stop {\n display: flex;\n align-items: center;\n gap: 4px;\n padding: 5px 10px;\n margin-left: 4px;\n font-family: inherit;\n font-size: 12px;\n font-weight: 500;\n color: #ffffff;\n background: rgba(255, 255, 255, 0.15);\n border: 1px solid rgba(255, 255, 255, 0.3);\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-page-pilot-banner__stop:hover {\n background: rgba(255, 255, 255, 0.25);\n border-color: rgba(255, 255, 255, 0.5);\n}\n\n._pillar-page-pilot-banner__stop:active {\n transform: scale(0.97);\n}\n\n._pillar-page-pilot-banner__stop-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 14px;\n height: 14px;\n}\n\n._pillar-page-pilot-banner__stop-icon svg {\n width: 100%;\n height: 100%;\n}\n\n/* Confirmation variant — amber/warning theme */\n._pillar-page-pilot-banner--confirm ._pillar-page-pilot-banner__content {\n background: #d97706;\n}\n\n._pillar-page-pilot-banner--confirm::before {\n border-color: #d97706;\n}\n\n._pillar-page-pilot-banner--confirm::after {\n background: #d97706;\n}\n\n._pillar-page-pilot-banner__warning-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 14px;\n height: 14px;\n flex-shrink: 0;\n}\n\n._pillar-page-pilot-banner__warning-icon svg {\n width: 100%;\n height: 100%;\n}\n\n._pillar-page-pilot-banner__deny {\n display: flex;\n align-items: center;\n padding: 5px 12px;\n margin-left: 4px;\n font-family: inherit;\n font-size: 12px;\n font-weight: 500;\n color: #ffffff;\n background: rgba(255, 255, 255, 0.15);\n border: 1px solid rgba(255, 255, 255, 0.3);\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-page-pilot-banner__deny:hover {\n background: rgba(255, 255, 255, 0.25);\n border-color: rgba(255, 255, 255, 0.5);\n}\n\n._pillar-page-pilot-banner__deny:active {\n transform: scale(0.97);\n}\n\n._pillar-page-pilot-banner__allow {\n display: flex;\n align-items: center;\n padding: 5px 12px;\n font-family: inherit;\n font-size: 12px;\n font-weight: 600;\n color: #d97706;\n background: #ffffff;\n border: 1px solid rgba(255, 255, 255, 0.8);\n border-radius: var(--pillar-radius-md);\n cursor: pointer;\n transition: all var(--pillar-transition-fast);\n}\n\n._pillar-page-pilot-banner__allow:hover {\n background: #fef3c7;\n}\n\n._pillar-page-pilot-banner__allow:active {\n transform: scale(0.97);\n}\n",bl),this.stylesInjected=!0),this.container=document.createElement("div"),this.container.id="pillar-page-pilot-container",document.body.appendChild(this.container),this.primaryColor&&this.container.style.setProperty("--pillar-primary",this.primaryColor),this.applyTheme(),this.setupThemeObserver(),this.unsubscribe=pn(()=>{Hr.value,this.render()}),this.render()}setPrimaryColor(e){this.primaryColor=e,this.container&&this.container.style.setProperty("--pillar-primary",e)}destroy(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null),this.themeObserver&&(this.themeObserver.disconnect(),this.themeObserver=null),this.container&&(ue(null,this.container),this.container.remove(),this.container=null),document.getElementById(bl)?.remove(),this.stylesInjected=!1}render(){this.container&&ue(ge(ml,{}),this.container)}}const _l={recentActions:[]},xl={},yl=Xe({..._l}),wl=Xe({...xl});an(()=>{const e=yl.value;return!!(e.currentPage||e.currentFeature||e.userRole||e.errorState||e.recentActions&&e.recentActions.length>0)}),an(()=>!!yl.value.errorState);const kl=e=>{wl.value={...e}};class Sl{constructor(e={}){this._callback=null,this._debounceTimer=null,this._lastRoute=null,this._running=!1,this._originalPushState=null,this._originalReplaceState=null,this._handleRouteChange=()=>{this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{const e=this._getCurrentUrl();e!==this._lastRoute&&(this._lastRoute=e,this._callback&&this._callback(this.getCurrentRoute()))},this._debounceMs)},this._debounceMs=e.debounceMs??100}get running(){return this._running}onRouteChange(e){this._callback=e}start(){this._running||"undefined"!=typeof window&&(this._running=!0,this._lastRoute=this._getCurrentUrl(),this._patchHistory(),window.addEventListener("popstate",this._handleRouteChange),window.addEventListener("hashchange",this._handleRouteChange))}stop(){this._running&&(this._running=!1,this._restoreHistory(),window.removeEventListener("popstate",this._handleRouteChange),window.removeEventListener("hashchange",this._handleRouteChange),this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=null))}getCurrentRoute(){return{pathname:window.location.pathname,search:window.location.search,hash:window.location.hash,url:window.location.href,title:document.title}}_patchHistory(){this._originalPushState=history.pushState.bind(history),this._originalReplaceState=history.replaceState.bind(history),history.pushState=(...e)=>{this._originalPushState(...e),this._handleRouteChange()},history.replaceState=(...e)=>{this._originalReplaceState(...e),this._handleRouteChange()}}_restoreHistory(){this._originalPushState&&(history.pushState=this._originalPushState),this._originalReplaceState&&(history.replaceState=this._originalReplaceState),this._originalPushState=null,this._originalReplaceState=null}_getCurrentUrl(){return window.location.pathname+window.location.search+window.location.hash}}function Cl(e){const n=new Date(e);return`${n.getHours().toString().padStart(2,"0")}:${n.getMinutes().toString().padStart(2,"0")}:${n.getSeconds().toString().padStart(2,"0")}.${n.getMilliseconds().toString().padStart(3,"0")}`}function Pl(e){switch(e){case"error":return"#ef4444";case"warn":return"#f59e0b";default:return"#d4d4d4"}}function El(e){switch(e){case"sdk":return"⚡";case"handler":return"🔧";case"network":return"🌐";case"server":return"🧠";default:return"•"}}function Tl(e){switch(e){case"sdk":return"SDK";case"handler":return"Handler";case"network":return"Network";case"server":return"Server";default:return e}}const Il=["sdk","handler","network","server"];function $l({expanded:e=!1,onToggle:n}){const[t,r]=Ie([]),[i,a]=Ie(e),[l,o]=Ie(""),[s,c]=Ie(new Set(Il)),[p,d]=Ie(200),[u,h]=Ie(!1),[g,f]=Ie(new Set),[m,b]=Ie(null),v=Me(null),_=Me("");$e(()=>{const e="pillar-debug-panel-styles";if(!document.getElementById(e)){const n=document.createElement("style");n.id=e,n.textContent="\n.pillar-debug-panel {\n position: fixed;\n bottom: 0;\n left: 0;\n right: 0;\n background-color: #1e1e1e;\n color: #d4d4d4;\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n font-size: 12px;\n z-index: 999999;\n border-top: 1px solid #333;\n}\n.pillar-debug-resize-handle {\n height: 8px;\n background-color: #333;\n cursor: ns-resize;\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n.pillar-debug-resize-handle::after {\n content: '';\n width: 40px;\n height: 3px;\n background-color: #555;\n border-radius: 2px;\n}\n.pillar-debug-resize-handle:hover,\n.pillar-debug-resize-handle.active {\n background-color: #3b82f6;\n}\n.pillar-debug-resize-handle:hover::after,\n.pillar-debug-resize-handle.active::after {\n background-color: #fff;\n}\n.pillar-debug-header {\n display: flex;\n align-items: center;\n padding: 8px 12px;\n background-color: #252526;\n cursor: pointer;\n user-select: none;\n}\n.pillar-debug-header-icon {\n margin-right: 8px;\n font-size: 10px;\n}\n.pillar-debug-header-title {\n font-weight: 600;\n margin-right: 8px;\n}\n.pillar-debug-header-count {\n background-color: #3c3c3c;\n padding: 2px 6px;\n border-radius: 4px;\n font-size: 11px;\n margin-right: auto;\n}\n.pillar-debug-header-actions {\n display: flex;\n gap: 8px;\n}\n.pillar-debug-btn {\n background-color: transparent;\n border: 1px solid #555;\n color: #d4d4d4;\n padding: 2px 8px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 11px;\n}\n.pillar-debug-btn:hover {\n background-color: #333;\n}\n.pillar-debug-btn.copied {\n border-color: #10b981;\n color: #10b981;\n}\n.pillar-debug-content {\n overflow: hidden;\n display: flex;\n flex-direction: column;\n}\n.pillar-debug-toolbar {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 6px 12px;\n background-color: #2d2d2d;\n border-bottom: 1px solid #3c3c3c;\n flex-shrink: 0;\n}\n.pillar-debug-filter-input {\n background-color: #3c3c3c;\n border: none;\n color: #d4d4d4;\n padding: 4px 8px;\n font-size: 12px;\n outline: none;\n border-radius: 4px;\n flex: 1;\n max-width: 200px;\n}\n.pillar-debug-source-filters {\n display: flex;\n gap: 4px;\n}\n.pillar-debug-source-btn {\n background-color: transparent;\n border: 1px solid #444;\n color: #888;\n padding: 2px 8px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 11px;\n display: flex;\n align-items: center;\n gap: 4px;\n}\n.pillar-debug-source-btn.active {\n background-color: #3c3c3c;\n border-color: #666;\n color: #d4d4d4;\n}\n.pillar-debug-source-btn:hover {\n background-color: #333;\n}\n.pillar-debug-source-count {\n background-color: #444;\n padding: 0 4px;\n border-radius: 3px;\n font-size: 10px;\n}\n.pillar-debug-timeline {\n flex: 1;\n overflow-y: auto;\n padding: 4px 0;\n}\n.pillar-debug-empty {\n padding: 12px;\n color: #6b7280;\n text-align: center;\n}\n.pillar-debug-entry {\n padding: 4px 12px;\n border-bottom: 1px solid #2d2d2d;\n}\n.pillar-debug-entry:hover {\n background-color: #252526;\n}\n.pillar-debug-entry.server {\n background-color: rgba(139, 92, 246, 0.1);\n}\n.pillar-debug-entry.server:hover {\n background-color: rgba(139, 92, 246, 0.15);\n}\n.pillar-debug-entry-row {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n.pillar-debug-entry-time {\n color: #6b7280;\n flex-shrink: 0;\n}\n.pillar-debug-entry-source {\n flex-shrink: 0;\n font-size: 10px;\n padding: 1px 4px;\n border-radius: 3px;\n background-color: #333;\n}\n.pillar-debug-entry-source.sdk { background-color: #3b82f6; color: white; }\n.pillar-debug-entry-source.handler { background-color: #10b981; color: white; }\n.pillar-debug-entry-source.network { background-color: #f59e0b; color: black; }\n.pillar-debug-entry-source.server { background-color: #8b5cf6; color: white; }\n.pillar-debug-entry-event {\n font-weight: 500;\n flex-shrink: 0;\n}\n.pillar-debug-entry-data {\n color: #9ca3af;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.pillar-debug-entry.expanded {\n flex-direction: column;\n align-items: stretch;\n}\n.pillar-debug-entry.expanded .pillar-debug-entry-row {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n.pillar-debug-entry.expanded .pillar-debug-entry-data {\n white-space: pre-wrap;\n word-break: break-all;\n overflow: visible;\n margin-top: 8px;\n padding: 8px;\n background-color: #2d2d2d;\n border-radius: 4px;\n font-size: 11px;\n line-height: 1.4;\n}\n.pillar-debug-entry-expand {\n color: #6b7280;\n font-size: 10px;\n flex-shrink: 0;\n margin-left: auto;\n}\n",document.head.appendChild(n)}_.current=document.body.style.paddingBottom||"";const n=Fl.getInstance();if(!n)return;r(n.getDebugLog());const t=n.onDebugLog(e=>{r([...e])});return()=>{t(),document.body.style.paddingBottom=_.current}},[]);const x=Me(null);$e(()=>{const e=x.current;if(!e)return;const n=()=>{document.body.style.paddingBottom=`${e.offsetHeight}px`},t=new ResizeObserver(n);return t.observe(e),n(),()=>{t.disconnect()}},[]),$e(()=>{v.current&&t.length>0&&requestAnimationFrame(()=>{v.current&&(v.current.scrollTop=v.current.scrollHeight)})},[t]);const y=ze(e=>{e.preventDefault(),h(!0);const n=e.clientY,t=p,r=e=>{const r=n-e.clientY,i=Math.min(600,Math.max(100,t+r));d(i)},i=()=>{h(!1),document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",i)};document.addEventListener("mousemove",r),document.addEventListener("mouseup",i)},[p]),w=Ae(()=>{const e={sdk:0,handler:0,network:0,server:0};for(const n of t)e[n.source]=(e[n.source]||0)+1;return e},[t]),k=Ae(()=>t.filter(e=>{if(!s.has(e.source))return!1;if(l){const n=l.toLowerCase(),t=e.event.toLowerCase().includes(n),r=!!e.data&&JSON.stringify(e.data).toLowerCase().includes(n);if(!t&&!r)return!1}return!0}),[t,s,l]),S=(e,n)=>["=== Pillar SDK — Client Logs ===",`Output: ${n}`,`Exported: ${(new Date).toISOString()}`,`Entries: ${e.length}`,""].join("\n")+e.map(e=>{const n=Cl(e.timestamp),t=Tl(e.source).toUpperCase().padEnd(8),r="error"===e.level?" [ERROR]":"warn"===e.level?" [WARN]":"",i=null!=e.data?` ${"object"==typeof e.data?JSON.stringify(e.data):String(e.data)}`:"";return`${n} [${t}]${r} ${e.event}${i}`}).join("\n");return ge("div",{class:"pillar-debug-panel",ref:x,children:[i&&ge("div",{class:"pillar-debug-resize-handle "+(u?"active":""),onMouseDown:y}),ge("div",{class:"pillar-debug-header",onClick:()=>{a(!i),n?.()},children:[ge("span",{class:"pillar-debug-header-icon",children:i?"▼":"▶"}),ge("span",{class:"pillar-debug-header-title",children:"Debug"}),ge("span",{class:"pillar-debug-header-count",children:t.length}),i&&ge("div",{class:"pillar-debug-header-actions",children:[ge("button",{class:"pillar-debug-btn "+("copy"===m?"copied":""),onClick:e=>{e.stopPropagation(),(()=>{const e=Il.filter(e=>s.has(e)).map(Tl).join(", "),n=S(k,l?`${e} (filtered: "${l}")`:e);navigator.clipboard.writeText(n),b("copy"),setTimeout(()=>b(null),1500)})()},children:"copy"===m?"Copied!":"Copy"}),ge("button",{class:"pillar-debug-btn "+("copyAll"===m?"copied":""),onClick:e=>{e.stopPropagation(),(()=>{const e=S(t,"All Sources");navigator.clipboard.writeText(e),b("copyAll"),setTimeout(()=>b(null),1500)})()},children:"copyAll"===m?"Copied!":"Copy All"}),ge("button",{class:"pillar-debug-btn",onClick:e=>{e.stopPropagation(),(()=>{const e=JSON.stringify(t,null,2),n=new Blob([e],{type:"application/json"}),r=URL.createObjectURL(n),i=document.createElement("a");i.href=r,i.download=`pillar-debug-${(new Date).toISOString().slice(0,19).replace(/:/g,"-")}.json`,i.click(),URL.revokeObjectURL(r)})()},children:"Export"}),ge("button",{class:"pillar-debug-btn",onClick:e=>{e.stopPropagation(),(()=>{const e=Fl.getInstance();e?.clearDebugLog()})()},children:"Clear"})]})]}),i&&ge("div",{class:"pillar-debug-content",style:{height:`${p}px`},children:[ge("div",{class:"pillar-debug-toolbar",children:[ge("input",{type:"text",class:"pillar-debug-filter-input",placeholder:"Filter...",value:l,onInput:e=>o(e.target.value),onClick:e=>e.stopPropagation()}),ge("div",{class:"pillar-debug-source-filters",children:Il.map(e=>ge("button",{class:"pillar-debug-source-btn "+(s.has(e)?"active":""),onClick:n=>{n.stopPropagation(),(e=>{c(n=>{const t=new Set(n);return t.has(e)?t.delete(e):t.add(e),t})})(e)},children:[El(e)," ",Tl(e),ge("span",{class:"pillar-debug-source-count",children:w[e]})]},e))})]}),ge("div",{class:"pillar-debug-timeline",ref:v,children:0===k.length?ge("div",{class:"pillar-debug-empty",children:0===t.length?"No events captured yet":"No events match filters"}):k.map((e,n)=>{const t=g.has(n),r=null!==e.data&&void 0!==e.data;return ge("div",{class:`pillar-debug-entry ${e.source} ${t?"expanded":""}`,onClick:()=>r&&(e=>{f(n=>{const t=new Set(n);return t.has(e)?t.delete(e):t.add(e),t})})(n),style:{cursor:r?"pointer":"default"},children:[ge("div",{class:"pillar-debug-entry-row",children:[ge("span",{class:"pillar-debug-entry-time",children:Cl(e.timestamp)}),ge("span",{class:`pillar-debug-entry-source ${e.source}`,children:El(e.source)}),ge("span",{class:"pillar-debug-entry-event",style:{color:Pl(e.level)},children:e.event}),r&&!t&&ge("span",{class:"pillar-debug-entry-data",children:"object"==typeof e.data?JSON.stringify(e.data,null,0).slice(0,100):String(e.data)}),r&&ge("span",{class:"pillar-debug-entry-expand",children:t?"▼":"▶"})]}),r&&t&&ge("span",{class:"pillar-debug-entry-data",children:(i=e.data,null==i?"":"object"==typeof i?JSON.stringify(i,null,2):String(i))})]},n);var i})})]})]})}const Ml="pillar-";const Al=[{id:"assistant",label:"Assistant",enabled:!0,order:0}],zl="https://help-api.trypillar.com",Rl={enabled:!0,position:"right",mode:"push",width:380,useShadowDOM:!1,hoverBreakpoint:1200,hoverBackdrop:!0,fullWidthBreakpoint:500},Ll={enabled:!0},Ol={enabled:!0,breakpoint:700,position:"bottom-right",icon:"sparkle",iconColor:"white",size:"medium",label:"Get help",offset:24},Dl={enabled:!0,prefix:"pillar-",clearAfterOpen:!0},Hl={enabled:!0,label:"Ask AI"},Ul={enabled:!1,includeText:!0,maxDepth:20,visibleOnly:!0,maxTextLength:500,interactionHighlight:{enabled:!0,outlineColor:"#3b82f6",outlineWidth:2,outlineOffset:2,duration:2e3,scrollIntoView:!0,scrollBehavior:"smooth"}},jl={enabled:!0,debounceMs:100,displayLimit:3},ql={mode:"auto"};function Bl(e){if(!e||0===e.length)return Al;const n=new Map;for(const e of Al)n.set(e.id,{...e});for(const t of e)n.set(t.id,{...t});const t=n.get("assistant");return t&&(t.enabled=!0),Array.from(n.values()).sort((e,n)=>e.order-n.order)}function Nl(e){if(!e.productKey)throw new Error("[Pillar] productKey is required");return{productKey:e.productKey,apiBaseUrl:e.apiBaseUrl||zl,platform:e.platform||"web",version:e.version,debug:e.debug??!1,panel:{...Rl,...e.panel},edgeTrigger:{...Ll,...e.edgeTrigger},mobileTrigger:{...Ol,...e.mobileTrigger},urlParams:{...Dl,...e.urlParams},textSelection:{...Hl,...e.textSelection},domScanning:{...Ul,...e.domScanning,interactionHighlight:{...Ul.interactionHighlight,...e.domScanning?.interactionHighlight}},suggestions:{...jl,...e.suggestions},sidebarTabs:Bl(e.sidebarTabs),theme:{mode:e.theme?.mode??ql.mode,colors:{...e.theme?.colors},darkColors:{...e.theme?.darkColors}},customCSS:e.customCSS,onReady:e.onReady,onError:e.onError}}class Fl{_persistExternalUserId(e){if("undefined"!=typeof window)try{null===e?localStorage.removeItem(Fl.EXTERNAL_USER_ID_STORAGE_KEY):localStorage.setItem(Fl.EXTERNAL_USER_ID_STORAGE_KEY,e)}catch{}}_getStoredExternalUserId(){if("undefined"==typeof window)return null;try{return localStorage.getItem(Fl.EXTERNAL_USER_ID_STORAGE_KEY)}catch{return null}}constructor(){this._state="uninitialized",this._config=null,this._api=null,this._textSelectionManager=null,this._pagePilotManager=null,this._panel=null,this._edgeTrigger=null,this._mobileTrigger=null,this._initPromise=null,this._rootContainer=null,this._unsubscribeHoverMode=null,this._context={..._l},this._userProfile={...xl},this._externalUserId=null,this._taskHandlers=new Map,this._anyTaskHandler=null,this._registeredActions=new Map,this._cardRenderers=new Map,this._debugPanelContainer=null,this._routeObserver=null,this._suggestionPool=[],this._highlightedElement=null,this._highlightTimeout=null,this._fadeOutTimeout=null,this._originalStyles=null,this._events=new u}_createRootContainer(){let e=document.getElementById("pillar-root");if(e)return this._subscribeToHoverModeForRoot(e),e;e=document.createElement("div"),e.id="pillar-root";const n=In.value?"9999":"1000";return e.style.cssText=`isolation: isolate; z-index: ${n}; position: relative;`,document.body.appendChild(e),this._subscribeToHoverModeForRoot(e),e}_subscribeToHoverModeForRoot(e){this._unsubscribeHoverMode?.(),this._unsubscribeHoverMode=In.subscribe(n=>{e.style.zIndex=n?"9999":"1000"})}static async init(e){if(!e.productKey)throw new Error("[Pillar] productKey is required");return Fl.instance||(Fl.instance=new Fl),await Fl.instance._init(e),Fl.instance}static getInstance(){return Fl.instance}static destroy(){Fl.instance&&(Fl.instance._destroy(),Fl.instance=null)}get state(){return this._state}get isReady(){return"ready"===this._state}get isPanelOpen(){return vn.value}get config(){return this._config}get isDebugEnabled(){return this._config?.debug??!1}getDebugLog(){return this._config?.debug?o.getEntries():[]}onDebugLog(e){return o.subscribe(e)}clearDebugLog(){o.clear()}on(e,n){return this._events.on(e,n)}open(e){this._panel&&(this._panel.open(e),this._events.emit("panel:open"))}close(){this._panel&&(this._panel.close(),this._events.emit("panel:close"))}toggle(){this.isPanelOpen?this.close():this.open()}navigate(e,n){this._panel?.navigate(e,n),this._events.emit("panel:navigate",{view:e,params:n})}setContext(e){this._context={...this._context,...e},(e=>{yl.value={...yl.value,...e}})(e),this._events.emit("context:change",{context:this._context})}getChatContext(){const e=Gn.value,n=Zn.value;return 0===e.length?null:{conversationId:n,messages:e.map(e=>({role:e.role,content:e.content}))}}setTheme(e){this._config&&(this._config.theme={...this._config.theme,...e,mode:e.mode??this._config.theme.mode,colors:{...this._config.theme.colors,...e.colors},darkColors:{...this._config.theme.darkColors,...e.darkColors}},this._panel?.setTheme(this._config.theme),this._config.theme.colors.primary&&this._pagePilotManager?.setPrimaryColor(this._config.theme.colors.primary),this._events.emit("theme:change",{theme:this._config.theme}))}setTextSelectionEnabled(e){if(!this._config)return;this._config.textSelection.enabled!==e&&(this._config.textSelection.enabled=e,e?this._config.panel.enabled&&!this._textSelectionManager&&(this._textSelectionManager=new fl(this._config,this._events,()=>this.open()),this._textSelectionManager.init()):this._textSelectionManager&&(this._textSelectionManager.destroy(),this._textSelectionManager=null),this._events.emit("textSelection:change",{enabled:e}))}setDOMScanningEnabled(e){this._config&&(this._config.domScanning.enabled=e,this._events.emit("domScanning:change",{enabled:e}))}get isDOMScanningEnabled(){return this._config?.domScanning.enabled??!1}highlightElement(e){const n=this._config?.domScanning.interactionHighlight;if(!n?.enabled)return;this.clearHighlight(!0),n.scrollIntoView&&e.scrollIntoView({behavior:n.scrollBehavior,block:"center",inline:"nearest"}),this._originalStyles={outline:e.style.outline,outlineOffset:e.style.outlineOffset,transition:e.style.transition},this._highlightedElement=e;const t=e.style.transition,r="outline-color 0.3s ease-in-out";e.style.transition=t?`${t}, ${r}`:r,e.style.outline=`${n.outlineWidth}px solid transparent`,e.style.outlineOffset=`${n.outlineOffset}px`,e.offsetHeight,e.style.outline=`${n.outlineWidth}px solid ${n.outlineColor}`,p.log("[Pillar] Element highlighted with fade-in:",e.tagName),n.duration>0&&(this._highlightTimeout=setTimeout(()=>{this.clearHighlight()},n.duration))}clearHighlight(e=!1){if(this._highlightTimeout&&(clearTimeout(this._highlightTimeout),this._highlightTimeout=null),this._fadeOutTimeout&&(clearTimeout(this._fadeOutTimeout),this._fadeOutTimeout=null),this._highlightedElement&&this._originalStyles){const n=this._highlightedElement,t=this._originalStyles;e?(n.style.outline=t.outline,n.style.outlineOffset=t.outlineOffset,n.style.transition=t.transition,p.log("[Pillar] Highlight cleared immediately")):(n.style.outline=n.style.outline.replace(/[^,\s]+$/,"transparent"),this._fadeOutTimeout=setTimeout(()=>{n.style.outline=t.outline,n.style.outlineOffset=t.outlineOffset,n.style.transition=t.transition,p.log("[Pillar] Highlight fade-out complete"),this._fadeOutTimeout=null},300)),this._highlightedElement=null,this._originalStyles=null}}getElement(e){return document.querySelector(e)}clickElement(e){p.log("[Pillar] clickElement called with selector:",e);const n=this.getElement(e);if(p.log("[Pillar] clickElement found element:",n),n instanceof HTMLElement){p.log("[Pillar] clickElement clicking element:",n.tagName,n.textContent?.slice(0,50)),this.highlightElement(n);const e=n.getBoundingClientRect(),t=e.left+e.width/2,r=e.top+e.height/2,i={bubbles:!0,cancelable:!0,view:window,clientX:t,clientY:r,button:0,buttons:1};return n.dispatchEvent(new MouseEvent("mousedown",i)),n.dispatchEvent(new MouseEvent("mouseup",i)),n.dispatchEvent(new MouseEvent("click",i)),p.log("[Pillar] clickElement full mouse sequence executed"),!0}return p.warn("[Pillar] clickElement element not found or not HTMLElement"),!1}typeInElement(e,n){p.log("[Pillar] typeInElement called with selector:",e,"text:",n);const t=this.getElement(e);if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement){p.log("[Pillar] typeInElement found input/textarea:",t.tagName,t.type),this.highlightElement(t),t.focus();const e=t instanceof HTMLInputElement?HTMLInputElement.prototype:HTMLTextAreaElement.prototype,r=Object.getOwnPropertyDescriptor(e,"value")?.set;return r?(r.call(t,n),p.log("[Pillar] typeInElement set value via native setter")):(t.value=n,p.log("[Pillar] typeInElement set value directly (fallback)")),t.dispatchEvent(new InputEvent("beforeinput",{bubbles:!0,cancelable:!0,inputType:"insertText",data:n})),t.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0,inputType:"insertText",data:n})),t.dispatchEvent(new Event("change",{bubbles:!0})),p.log("[Pillar] typeInElement complete - events fired"),!0}return t instanceof HTMLElement&&"true"===t.getAttribute("contenteditable")?(p.log("[Pillar] typeInElement found contenteditable element"),this.highlightElement(t),t.focus(),t.textContent=n,t.dispatchEvent(new InputEvent("beforeinput",{bubbles:!0,cancelable:!0,inputType:"insertText",data:n})),t.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0,inputType:"insertText",data:n})),p.log("[Pillar] typeInElement contenteditable complete"),!0):(p.warn("[Pillar] typeInElement element not found or not an input:",t),!1)}selectOption(e,n){p.log("[Pillar] selectOption called with selector:",e,"value:",n);const t=this.getElement(e);if(t instanceof HTMLSelectElement){p.log("[Pillar] selectOption found select element"),this.highlightElement(t),t.focus();const e=Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype,"value")?.set;return e?(e.call(t,n),p.log("[Pillar] selectOption set value via native setter")):(t.value=n,p.log("[Pillar] selectOption set value directly (fallback)")),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})),p.log("[Pillar] selectOption complete"),!0}return p.warn("[Pillar] selectOption element not found or not a select:",t),!1}focusElement(e){p.log("[Pillar] focusElement called with selector:",e);const n=this.getElement(e);return n instanceof HTMLElement?(p.log("[Pillar] focusElement found element:",n.tagName),this.highlightElement(n),n.focus(),n.dispatchEvent(new FocusEvent("focusin",{bubbles:!0})),p.log("[Pillar] focusElement complete"),!0):(p.warn("[Pillar] focusElement element not found:",n),!1)}toggleElement(e){p.log("[Pillar] toggleElement called with selector:",e);const n=this.getElement(e);if(n instanceof HTMLInputElement&&("checkbox"===n.type||"radio"===n.type)){p.log("[Pillar] toggleElement found checkbox/radio:",n.type,"current checked:",n.checked),this.highlightElement(n),n.focus();const e=n.getBoundingClientRect(),t=e.left+e.width/2,r=e.top+e.height/2,i={bubbles:!0,cancelable:!0,view:window,clientX:t,clientY:r,button:0,buttons:1};return n.dispatchEvent(new MouseEvent("mousedown",i)),n.dispatchEvent(new MouseEvent("mouseup",i)),n.dispatchEvent(new MouseEvent("click",i)),n.dispatchEvent(new Event("input",{bubbles:!0})),p.log("[Pillar] toggleElement complete - new checked:",n.checked),!0}return p.warn("[Pillar] toggleElement element not found or not checkbox/radio:",n),!1}async handlePageInteraction(e){if(p.log("[Pillar] handlePageInteraction called with params:",e),!ui(e.ref))return p.warn("[Pillar] handlePageInteraction rejected invalid ref format:",e.ref),{success:!1,error:"Invalid ref format"};const n=hi(e.ref);p.log("[Pillar] handlePageInteraction built selector:",n);const t=this.getElement(n);if(!t)return p.warn("[Pillar] handlePageInteraction element not found for ref:",e.ref),{success:!1,error:"Element not found"};if(t.getAttribute("data-pillar-ref")!==e.ref)return p.warn("[Pillar] handlePageInteraction ref attribute mismatch"),{success:!1,error:"Ref attribute mismatch"};if(ci(t)){const n=t.textContent?.trim().slice(0,50)||t.getAttribute("aria-label")||e.operation;p.log("[Pillar] handlePageInteraction detected destructive element:",n);const{requestConfirmation:r}=await Promise.resolve().then(function(){return Jr});if(!await r(`Agent wants to ${e.operation} "${n}"`))return p.log("[Pillar] handlePageInteraction destructive action denied by user"),{success:!1,error:"User denied destructive action"};p.log("[Pillar] handlePageInteraction destructive action confirmed by user")}let r;switch(e.operation){case"click":r={success:this.clickElement(n)};break;case"type":if(!e.value){r={success:!1,error:"value required for type operation"};break}r={success:this.typeInElement(n,e.value)};break;case"select":if(!e.value){r={success:!1,error:"value required for select operation"};break}r={success:this.selectOption(n,e.value)};break;case"focus":r={success:this.focusElement(n)};break;case"toggle":r={success:this.toggleElement(n)};break;default:r={success:!1,error:`Unknown operation: ${e.operation}`}}return p.log("[Pillar] handlePageInteraction result:",r),r}mountPanelTo(e){this._panel?.mountTo(e)}getPanelHostElement(){return this._panel?.getHostElement()??null}get context(){return{...this._context}}get userProfile(){return{...this._userProfile}}setUserProfile(e){this._userProfile={...e},kl(this._userProfile),this._events.emit("profile:change",{profile:this._userProfile})}async identify(e,n,t){if(this._api)if(e)if(null===this._externalUserId||String(this._externalUserId)!==String(e))try{await this._api.identify(e,n),this._externalUserId=e,this._persistExternalUserId(e),this._userProfile={...this._userProfile,userId:e,...n?.name&&{name:n.name}},kl(this._userProfile),this._api.setExternalUserId(e),t?.preserveConversation||Jt(),Jn.value+=1,this._events.emit("user:identified",{userId:e,profile:n})}catch(e){throw p.error("[Pillar] Failed to identify user:",e),e}else p.log("[Pillar] Already identified as this user, skipping");else p.warn("[Pillar] userId is required for identify()");else p.warn("[Pillar] SDK not initialized, cannot identify user")}logout(e){this._externalUserId=null,this._persistExternalUserId(null),this._userProfile={...xl},kl(this._userProfile),this._api?.clearExternalUserId(),e?.preserveConversation||Jt(),Jn.value+=1,this._events.emit("user:logout",{})}get externalUserId(){return this._externalUserId}get isIdentified(){return null!==this._externalUserId}reportAction(e,n){const t=[...(this._context.recentActions||[]).slice(-9),e];this._context={...this._context,recentActions:t},(e=>{const n=yl.value.recentActions||[];yl.value={...yl.value,recentActions:[...n.slice(-9),e]}})(e),this._events.emit("action:report",{action:e,metadata:n})}clearErrorState(){if(this._context.errorState){const{errorState:e,...n}=this._context;this._context=n,(()=>{const{errorState:e,...n}=yl.value;yl.value=n})(),this._events.emit("context:change",{context:this._context})}}setErrorState(e,n){this._context={...this._context,errorState:{code:e,message:n}},((e,n)=>{yl.value={...yl.value,errorState:{code:e,message:n}}})(e,n),this._events.emit("context:change",{context:this._context})}async getSuggestions(){if(!this._api)return p.warn("[Pillar] SDK not initialized, cannot get suggestions"),[];try{return await this._api.getSuggestions(this._context,this._userProfile)}catch(e){return p.error("[Pillar] Failed to get suggestions:",e),[]}}getAssistantContext(){return{product:this._context,user:this._userProfile}}onTask(e,n){return this._taskHandlers.set(e,n),()=>this._taskHandlers.delete(e)}registerAction(e){const{name:n,...t}=e;n?(this._registeredActions.set(n,{name:n,...t,returns:t.returnsData||t.returns||!1,autoRun:t.autoRun??t.auto_run??!1,autoComplete:t.autoComplete??t.auto_complete??!0}),p.log(`[Pillar] Registered action: ${n}`)):p.warn("[Pillar] registerAction called without a name")}getRegisteredAction(e){return this._registeredActions.get(e)}getHandler(e){const n=v(e)?b(e):void 0;if(n?.handler)return n.handler;const t=this._taskHandlers.get(e);return t||void 0}onAnyTask(e){return this._anyTaskHandler=e,()=>{this._anyTaskHandler=null}}offTask(e){this._taskHandlers.delete(e)}executeTask(e){const{name:n,data:t,taskType:r,path:i,externalUrl:a}=e;if(this._events.emit("task:execute",e),this._anyTaskHandler)try{this._anyTaskHandler(n,t)}catch(e){p.error("[Pillar] Error in onAnyTask handler:",e)}const l=v(n)?b(n):void 0,s=this._registeredActions.get(n),c=l?.handler,d=this._taskHandlers.get(n),u=r?this._taskHandlers.get(r):void 0,h=c||d||u,g=l?.returns||s?.returns;if(h){const e=performance.now();o.add({event:"handler:execute",data:{action:n,taskType:r,params:t},source:"handler",level:"info"});try{const a=h("navigate"===r&&i?{...t,path:i}:t);if(g&&void 0!==a)Promise.resolve(a).then(async r=>{const i=Math.round(performance.now()-e);if(void 0!==r){await this.sendActionResult(n,r);let e=!0;if(r&&"object"==typeof r&&!Array.isArray(r)){!1===r.success&&(e=!1)}o.add({event:"handler:complete",data:{action:n,duration:i,success:e,returnsData:!0},source:"handler",level:e?"info":"warn"}),this._events.emit("task:complete",{name:n,success:e,data:r})}else o.add({event:"handler:complete",data:{action:n,duration:i,success:!0},source:"handler",level:"info"}),this._events.emit("task:complete",{name:n,success:!0,data:t})}).catch(r=>{const i=Math.round(performance.now()-e);o.add({event:"handler:error",data:{action:n,duration:i,error:r instanceof Error?r.message:String(r)},source:"handler",level:"error"}),p.error(`[Pillar] Error in query action "${n}":`,r),this._events.emit("task:complete",{name:n,success:!1,data:t})});else{const r=Math.round(performance.now()-e);o.add({event:"handler:complete",data:{action:n,duration:r,success:!0},source:"handler",level:"info"}),this._events.emit("task:complete",{name:n,success:!0,data:t})}}catch(r){const i=Math.round(performance.now()-e);o.add({event:"handler:error",data:{action:n,duration:i,error:r instanceof Error?r.message:String(r)},source:"handler",level:"error"}),p.error(`[Pillar] Error executing task "${n}":`,r),this._events.emit("task:complete",{name:n,success:!1,data:t})}}else switch(r){case"navigate":i&&"undefined"!=typeof window&&(p.warn("[Pillar] No 'navigate' handler registered. Using window.location.href as fallback."),window.location.href=i,this._events.emit("task:complete",{name:n,success:!0,data:t}));break;case"external_link":a&&"undefined"!=typeof window&&(window.open(a,"_blank","noopener,noreferrer"),this._events.emit("task:complete",{name:n,success:!0,data:t}));break;case"copy_text":t.text&&"undefined"!=typeof navigator&&navigator.clipboard&&navigator.clipboard.writeText(String(t.text)).then(()=>{this._events.emit("task:complete",{name:n,success:!0,data:t})}).catch(()=>{this._events.emit("task:complete",{name:n,success:!1,data:t})});break;default:p.warn(`[Pillar] No handler registered for task "${n}". Register one with pillar.onTask('${n}', handler)`),this._events.emit("task:complete",{name:n,success:!1,data:{error:"No handler registered"}})}}completeTask(e,n=!0,t){this._events.emit("task:complete",{name:e,success:n,data:t})}async completeAction(e,n=!0,t){this._events.emit("task:complete",{name:e,success:n,data:t})}confirmTaskExecution(e,n,t){e?this._api?this._api.confirmTaskExecution(e,n,t):p.warn("[Pillar] SDK not initialized, cannot confirm task execution"):p.warn("[Pillar] confirmTaskExecution called without taskId")}registerCard(e,n){return this._cardRenderers.set(e,n),()=>this._cardRenderers.delete(e)}getCardRenderer(e){return this._cardRenderers.get(e)}hasCardRenderer(e){return this._cardRenderers.has(e)}get workflow(){return al.value}startWorkflow(e){!function(e){al.value&&(ll.value=[...ll.value,al.value]);const n=e.steps.map((e,n)=>0===n?{...e,status:e.auto_run?"active":"awaiting_initiation"}:{...e,status:"pending"});al.value={...e,steps:n,current_step:0}}(e),this._events.emit("workflow:start",al.value);const n=al.value.steps[0];n.auto_run&&this._executeWorkflowStep(n)}initiateWorkflowStep(e){const n=al.value;if(!n)return void p.warn("[Pillar] No active workflow");const t=e??n.current_step,r=n.steps[t];r?"awaiting_initiation"===r.status?this._executeWorkflowStep(r):p.warn(`[Pillar] Step ${t} is not awaiting initiation`):p.warn(`[Pillar] Invalid step index: ${t}`)}confirmWorkflowStep(e,n){const t=al.value;if(!t)return;const r=n??t.current_step;if(t.steps[r],sl(r,e?"completed":"failed"),this._events.emit("workflow:step:complete",{workflow:al.value,step:al.value.steps[r],success:e}),!e)return;const i=cl();if(!i)return this._events.emit("workflow:complete",al.value),void pl();this._events.emit("workflow:step:active",{workflow:al.value,step:i}),i.auto_run&&this._executeWorkflowStep(i)}skipWorkflowStep(e){const n=al.value;if(!n)return;const t=e??n.current_step;n.steps[t],sl(t,"skipped"),this._events.emit("workflow:step:skip",{workflow:al.value,step:al.value.steps[t]});const r=cl();if(!r)return this._events.emit("workflow:complete",al.value),void pl();this._events.emit("workflow:step:active",{workflow:al.value,step:r}),r.auto_run&&this._executeWorkflowStep(r)}cancelWorkflow(){const e=al.value;e&&(this._events.emit("workflow:cancel",e),function(){if(!al.value)return null;const e=al.value;al.value=null}())}_executeWorkflowStep(e){sl(e.index,"active"),this.executeTask({id:e.task_id,name:e.task_name,taskType:e.task_type,data:e.data,path:e.data?.path,externalUrl:e.data?.url}),e.auto_complete&&setTimeout(()=>{this.confirmWorkflowStep(!0,e.index)},100)}async sendActionResult(e,n,t){this._api?(p.log(`[Pillar] Sending action result for "${e}" (tool_call_id: ${t}):`,n),await this._api.mcp.sendActionResult(e,n,t),this._events.emit("action:result",{actionName:e,result:n,toolCallId:t})):p.warn("[Pillar] SDK not initialized, cannot send action result")}async executeQueryAction(e,n={},t){const r=performance.now();if(!e||"string"!=typeof e||""===e.trim())return void p.error("[Pillar] executeQueryAction called with missing or invalid actionName:",e);if(p.log(`[Pillar] Starting query action "${e}"`,n),t?.properties){const r=this._validateQueryParams(n,t);if(r)return p.error(`[Pillar] Query param validation failed: ${r}`),void await this.sendActionResult(e,{success:!1,error:r})}const i=v(e)?b(e):void 0;this._registeredActions.get(e);const a=i?.handler,l=this._taskHandlers.get(e),s=this._taskHandlers.get("query"),c=a||l||s;if(!c)return p.error(`[Pillar] No handler registered for query action "${e}". Register one with: pillar.onTask('${e}', async (data) => { ... return result; })`),void await this.sendActionResult(e,{error:`No handler registered for action "${e}"`,success:!1});o.add({event:"handler:execute",data:{action:e,type:"query",params:n},source:"handler",level:"info"});try{const t=performance.now(),i=await Promise.resolve(c(n)),a=Math.round(performance.now()-t);if(p.log(`[Pillar] Query action "${e}" handler completed in ${a}ms`,i),void 0!==i){o.add({event:"handler:complete",data:{action:e,duration:a,success:!0,returnsData:!0},source:"handler",level:"info"}),await this.sendActionResult(e,i);const n=Math.round(performance.now()-r);p.log(`[Pillar] Query action "${e}" total time: ${n}ms`)}else o.add({event:"handler:complete",data:{action:e,duration:a,success:!1,error:"returned undefined"},source:"handler",level:"warn"}),p.warn(`[Pillar] Query action "${e}" returned undefined. Make sure your handler returns data for the agent.`),await this.sendActionResult(e,{error:"Handler returned undefined",success:!1})}catch(n){const t=Math.round(performance.now()-r);o.add({event:"handler:error",data:{action:e,duration:t,error:n instanceof Error?n.message:String(n)},source:"handler",level:"error"}),p.error(`[Pillar] Error executing query action "${e}" after ${t}ms:`,n),await this.sendActionResult(e,{error:n instanceof Error?n.message:String(n),success:!1})}}_validateQueryParams(e,n){const t=n.properties||{},r=n.required||[],i=Object.keys(t),a=r.filter(n=>!(n in e));if(a.length>0)return`Missing required parameters: ${a.join(", ")}. Expected: ${i.join(", ")}`;const l=Object.keys(e).filter(e=>!(e in t));return l.length>0?`Unknown parameters: ${l.join(", ")}. Expected: ${i.join(", ")}`:null}async _init(e){if("initializing"===this._state&&this._initPromise)return p.log("[Pillar] Already initializing, waiting for completion"),void await this._initPromise;"ready"!==this._state?(this._state="initializing",this._initPromise=this._doInit(e),await this._initPromise):p.log("[Pillar] Already initialized")}async _doInit(e){try{e.debug&&(n(!0),o.add({event:"sdk:init:start",data:{productKey:e.productKey,debug:!0},source:"sdk",level:"info"})),await new Promise(e=>{"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>e(),{once:!0}):e()});const r=Nl(e),i=new C(r),a=function(e,n){if(!n)return e;const t={...e};return n.panel&&(t.panel={...n.panel,...e.panel}),n.theme?.colors?.primary&&(t.theme={...t.theme,colors:{primary:e.theme?.colors?.primary??n.theme.colors.primary,...e.theme?.colors}}),t}(e,await i.fetchEmbedConfig().catch(e=>(p.warn("[Pillar] Failed to fetch server config, using local config only:",e),null)));this._config=Nl(a),this._config.platform&&this._config.version&&g(this._config.platform,this._config.version),this._api=new C(this._config);const l=this._getStoredExternalUserId();l&&(this._externalUserId=l,this._api.setExternalUserId(l),p.log("[Pillar] Restored external user ID from localStorage")),p.configure(this._api.mcp,{forwardToServer:!0}),this._config.debug&&this._setupDebugEventCapture(),this._rootContainer=this._createRootContainer(),t=this._config.mobileTrigger.breakpoint,Cn.value=t,(e=>{Pn.value=e})(this._config.panel.fullWidthBreakpoint),this._config.panel.enabled&&(this._panel=new ul(this._config,this._api,this._events,this._rootContainer),await this._panel.init()),this._config.edgeTrigger.enabled&&(this._edgeTrigger=new Un(this._config,this._events,()=>this.toggle(),this._rootContainer),this._edgeTrigger.init()),this._config.mobileTrigger.enabled&&(this._mobileTrigger=new Nn(this._config,this._events,()=>this.toggle(),this._rootContainer),this._mobileTrigger.init()),this._config.textSelection.enabled&&this._config.panel.enabled&&(this._textSelectionManager=new fl(this._config,this._events,()=>this.open()),this._textSelectionManager.init()),this._pagePilotManager=new vl,this._pagePilotManager.init(this._config.theme.colors.primary),this._state="ready",this._events.emit("ready"),this._config.onReady?.(),p.log("[Pillar] SDK initialized successfully"),this._config.debug&&this._mountDebugPanel(),this._config.suggestions.enabled&&this._initSuggestions().catch(e=>{p.warn("[Pillar] Background suggestions init failed:",e)}),await this._recoverSession(),this._config.urlParams.enabled&&await this._handleUrlParams(),await this._restoreConversation()}catch(e){this._state="error";const n=e instanceof Error?e:new Error(String(e));throw this._events.emit("error",n),this._config?.onError?.(n),p.error("[Pillar] Failed to initialize:",e),e}var t}async _recoverSession(){if(!this._config||!this._api)return void p.warn("[Pillar] _recoverSession skipped: config or api not available");const e=this._config.productKey;p.log("[Pillar] Checking for saved session hint with siteId:",e);const{loadActiveSession:n,clearActiveSession:t}=await Promise.resolve().then(function(){return ei}),{setInterruptedSession:r,setConversationId:i}=await Promise.resolve().then(function(){return lr}),a=n(e);if(a){p.log("[Pillar] Found saved session hint, checking with server...");try{const n=await this._api.mcp.getConversationStatus(a.conversationId);if(!n||!n.resumable)return p.log("[Pillar] Session is no longer resumable, clearing hint"),void t(e);p.log("[Pillar] Session is resumable, setting up resume state"),i(a.conversationId),r({conversationId:a.conversationId,userMessage:n.user_message??"",partialResponse:n.partial_response??"",summary:n.summary??"",elapsedMs:n.elapsed_ms??0}),p.log("[Pillar] Resume state set up successfully")}catch(n){p.warn("[Pillar] Failed to check session status:",n),t(e)}}else p.log("[Pillar] No saved session found for siteId:",e)}async _restoreConversation(){if(!this._api)return;const{getStoredConversationId:e,messages:n,loadConversation:t,isLoadingHistory:r,interruptedSession:i,setInterruptedSession:a}=await Promise.resolve().then(function(){return lr}),{navigate:l,currentView:o}=await Promise.resolve().then(function(){return mr}),s=e();if(s&&!(n.value.length>0)){p.log("[Pillar] Restoring conversation from localStorage:",s);try{r.value=!0,"chat"!==o.value.type&&l("chat");const e=await this._api.getConversation(s);if(e&&e.messages.length>0){let n=e.messages;const l=n[n.length-1],o="assistant"===l.role&&!l.content?.trim();if(o&&(p.log("[Pillar] Stripped trailing empty assistant message from restored conversation"),n=n.slice(0,-1)),n.length>0?t(e.id,n):r.value=!1,o&&!i.value&&this._api.mcp){p.log("[Pillar] Checking conversation status as fallback for resume...");try{const e=await this._api.mcp.getConversationStatus(s);e&&e.resumable&&(p.log("[Pillar] Fallback: session is resumable, setting up resume state"),a({conversationId:s,userMessage:e.user_message??"",partialResponse:e.partial_response??"",summary:e.summary??"",elapsedMs:e.elapsed_ms??0}))}catch(e){p.warn("[Pillar] Fallback resume check failed:",e)}}}else r.value=!1}catch(e){p.warn("[Pillar] Failed to restore conversation:",e),r.value=!1}}}async _handleUrlParams(){if(!this._config)return;(function(e=Ml){if("undefined"==typeof window||!window.location)return{};const n=new URLSearchParams(window.location.search),t={};n.has(`${e}open`)&&(t.open=!0);const r=n.get(`${e}article`);r&&(t.article=r);const i=n.get(`${e}article-id`);i&&!t.article&&(t.article=i);const a=n.get(`${e}category`);a&&(t.category=a);const l=n.get(`${e}search`);return l&&(t.search=l),t})(this._config.urlParams.prefix).open&&(this.open(),this._config.urlParams.clearAfterOpen&&function(e=Ml){if("undefined"==typeof window||!window.location||!window.history)return;const n=new URL(window.location.href),t=[`${e}open`,`${e}article`,`${e}article-id`,`${e}category`,`${e}search`];let r=!1;for(const e of t)n.searchParams.has(e)&&(n.searchParams.delete(e),r=!0);r&&window.history.replaceState({},"",n.toString())}(this._config.urlParams.prefix))}_mountDebugPanel(){this._debugPanelContainer=document.createElement("div"),this._debugPanelContainer.id="pillar-debug-panel-root",document.body.appendChild(this._debugPanelContainer),ue(W($l,null),this._debugPanelContainer),o.add({event:"debug:panel:mounted",source:"sdk",level:"info"})}_setupDebugEventCapture(){this._events.on("task:execute",e=>{o.add({event:"task:execute",data:{name:e.name,taskType:e.taskType},source:"sdk",level:"info"})}),this._events.on("task:complete",e=>{o.add({event:"task:complete",data:{name:e.name,success:e.success},source:"sdk",level:e.success?"info":"error"})}),this._events.on("action:result",e=>{o.add({event:"action:result",data:{actionName:e.actionName,hasResult:!!e.result},source:"sdk",level:"info"})}),this._events.on("ready",()=>{o.add({event:"sdk:ready",source:"sdk",level:"info"})}),this._events.on("error",e=>{o.add({event:"sdk:error",data:{message:e.message},source:"sdk",level:"error"})}),p.log("[Pillar] Debug event capture enabled")}async _initSuggestions(){if(this._api&&this._config){p.log("[Pillar] Initializing page-aware suggestions"),Ir(!0);try{const e=await this._api.getSuggestedQuestions();p.log(`[Pillar] Fetched ${e.length} suggestions for pool`),this._suggestionPool=e,function(e){wr.value=e}(e),this._routeObserver=new Sl({debounceMs:this._config.suggestions.debounceMs}),this._routeObserver.onRouteChange(e=>{this._handleRouteChange(e)}),this._routeObserver.start();const n=this._routeObserver.getCurrentRoute();this._handleRouteChange(n),Ir(!1)}catch(e){p.error("[Pillar] Failed to initialize suggestions:",e),function(e){Cr.value=e,Sr.value=!1}(e instanceof Error?e.message:String(e)),Ir(!1)}}}_handleRouteChange(e){if(!this._config)return;const{pathname:n,title:t}=e,r=this._config.suggestions.displayLimit;p.log(`[Pillar] Route changed to: ${n}, sorting suggestions`);const i=Er(this._suggestionPool,n,t,r);!function(e,n){kr.value=e,Pr.value=n}(i,n),this._events.emit("suggestions:updated",{suggestions:i.map(e=>({id:e.id,text:e.text})),route:n}),p.log(`[Pillar] Sorted ${i.length} suggestions for page`)}_destroy(){this._routeObserver?.stop(),this._routeObserver=null,this._suggestionPool=[],wr.value=[],kr.value=[],Sr.value=!1,Cr.value=null,Pr.value=null,this._textSelectionManager?.destroy(),this._pagePilotManager?.destroy(),this._panel?.destroy(),this._edgeTrigger?.destroy(),this._mobileTrigger?.destroy(),this._api?.cancelAllRequests(),this._events.removeAllListeners(),this._unsubscribeHoverMode?.(),this._unsubscribeHoverMode=null,this._rootContainer?.remove(),this._rootContainer=null,this._debugPanelContainer&&(ue(null,this._debugPanelContainer),this._debugPanelContainer.remove(),this._debugPanelContainer=null),Rn(),gr(),Jt(),yl.value={..._l},wl.value={...xl},al.value=null,ll.value=[],this._context={..._l},this._userProfile={...xl},this._taskHandlers.clear(),this._anyTaskHandler=null,this._textSelectionManager=null,this._pagePilotManager=null,this._panel=null,this._edgeTrigger=null,this._mobileTrigger=null,this._api=null,this._config=null,this._state="uninitialized",p.log("[Pillar] SDK destroyed")}}function Wl(){return Fl.getInstance()?._api??null}Fl.instance=null,Fl.EXTERNAL_USER_ID_STORAGE_KEY="pillar:external_user_id";var Kl=Object.freeze({__proto__:null,Pillar:Fl,default:Fl,getApiClient:Wl});if("undefined"!=typeof window){window.Pillar=Fl;const e=()=>{const e=document.currentScript;e?.dataset.productKey&&Fl.init({productKey:e.dataset.productKey}).catch(p.error)};if("loading"===document.readyState)document.addEventListener("DOMContentLoaded",e);else{const e=document.querySelectorAll("script[data-product-key]");if(e.length>0){const n=e[e.length-1];n.dataset.productKey&&Fl.init({productKey:n.dataset.productKey}).catch(p.error)}}}export{C as APIClient,ni as DEFAULT_SCAN_OPTIONS,Al as DEFAULT_SIDEBAR_TABS,u as EventEmitter,ri as INTERACTABLE_ROLES,ti as INTERACTABLE_TAGS,Fl as Pillar,ii as SKIP_TAGS,hi as buildSelectorFromRef,li as clearPillarRefs,y as clearRegistry,Fl as default,Fn as generateContextId,w as getActionCount,b as getActionDefinition,_ as getActionNames,f as getClientInfo,Vn as getContextDisplayLabel,m as getHandler,x as getManifest,v as hasAction,Kn as isDOMSnapshotContext,ci as isDestructiveElement,Wn as isHighlightedTextContext,pi as isInteractable,oi as isRedacted,ui as isValidPillarRef,bi as scanPageDirect,g as setClientInfo};
|
|
2
2
|
//# sourceMappingURL=pillar.esm.js.map
|