System.register(["./@page-chat-B0e1__P_.js"],function(e){"use strict";var t,s,a;return{setters:[function(e){t=e.P,s=e.a,a=e.b}],execute:function(){var n,r,i,h,c,o,g,l,m=Object.defineProperty,d=e=>{throw TypeError(e)},p=(e,t)=>m(e,"name",{value:t,configurable:!0}),v=(e,t,s)=>((e,t,s)=>t in e?m(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s),u=(e,t,s)=>t.has(e)||d("Cannot "+s),f=(e,t,s)=>(u(e,t,"read from private field"),s?s.call(e):t.get(e)),w=(e,t,s)=>t.has(e)?d("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),E=(e,t,s,a)=>(u(e,t,"write to private field"),t.set(e,s),s);const y="page-chat:history:v1",S=class extends EventTarget{constructor(e){super(),w(this,o),v(this,"panel"),v(this,"core"),v(this,"config"),w(this,n,p(()=>this.dispatchEvent(new Event("messagechange")),"#onMessageChange")),w(this,r,p(()=>this.dispatchEvent(new Event("statuschange")),"#onStatusChange")),w(this,i,p(()=>this.dispatchEvent(new Event("attachmentchange")),"#onAttachmentChange")),w(this,h,p(()=>this.dispatchEvent(new Event("screenshotchange")),"#onScreenshotChange")),w(this,c,null),w(this,l,p(()=>{try{localStorage.setItem(y,JSON.stringify({messages:this.core.messages}))}catch(e){console.warn("[page-chat] Failed to persist history:",e)}},"#onPersistMessages"));const m=new t;var d,E,S;this.core=new s({...e,pageController:m}),this.config=this.core.config,this.config.persist&&(d=this,E=o,S=g,u(d,E,"access private method"),S).call(this),this.core.addEventListener("messagechange",f(this,n)),this.core.addEventListener("statuschange",f(this,r)),this.core.addEventListener("attachmentchange",f(this,i)),this.core.addEventListener("screenshotchange",f(this,h)),this.config.persist&&this.core.addEventListener("messagechange",f(this,l)),this.panel=new a(this,{language:e.language,title:e.title}),this.refreshPage().catch(e=>{console.warn("[page-chat] Initial page scan failed:",e)})}get messages(){return this.core.messages}get attachments(){return this.core.attachments}get pageScreenshot(){return this.core.pageScreenshot}get status(){return this.core.status}sendMessage(e,t){const s=new AbortController;return E(this,c,s),t&&t.addEventListener("abort",()=>s.abort(),{once:!0}),this.core.sendMessage(e,s.signal)}async refreshPage(){await this.core.refreshPage()}async takeScreenshot(){return this.core.takeScreenshot()}async addAttachment(e){return this.core.addAttachment(e)}async addFile(e){return this.addAttachment(e)}removeAttachment(e){this.core.removeAttachment(e)}stop(){f(this,c)?.abort(),E(this,c,null)}clear(){this.core.clear(),this.config.persist&&localStorage.removeItem(y)}dispose(){this.stop(),this.panel.dispose(),this.core.removeEventListener("messagechange",f(this,n)),this.core.removeEventListener("statuschange",f(this,r)),this.core.removeEventListener("attachmentchange",f(this,i)),this.core.removeEventListener("screenshotchange",f(this,h)),this.core.dispose()}};n=new WeakMap,r=new WeakMap,i=new WeakMap,h=new WeakMap,c=new WeakMap,o=new WeakSet,g=p(function(){try{const e=localStorage.getItem(y);if(e){const t=JSON.parse(e);t.messages&&Array.isArray(t.messages)&&(this.core.messages=t.messages,this.core.dispatchEvent(new Event("messagechange")))}}catch(e){console.warn("[page-chat] Failed to restore history:",e)}},"#loadFromStorage"),l=new WeakMap,p(S,"PageChat");e("P",S)}}});
