signalbird 2.3.2 → 2.4.0

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/README.md CHANGED
@@ -94,7 +94,7 @@ değil, kasıtlı bir duvardır — anahtar bir kez istemciye indiğinde herkesi
94
94
  | Go | `go get github.com/Pariette-Inc/signalbird.sdk` |
95
95
  | .NET, ASP.NET Core | `dotnet add package Signalbird.Sdk` |
96
96
  | Swift (iOS, macOS) | SPM: `https://github.com/Pariette-Inc/signalbird.sdk` |
97
- | Kotlin (Android) | `implementation("io.signalbird:signalbird-sdk:2.3.2")` |
97
+ | Kotlin (Android) | `implementation("io.signalbird:signalbird-sdk:2.4.0")` |
98
98
  | Canlı sohbet widget'ı (herhangi bir site) | `<script async src="https://signalbird.io/sdk/v1/signalbird.js" data-key="sb_public_live_…" data-channel="destek"></script>` |
99
99
 
100
100
  > Hepsi **bu repodan** çıkar ve **aynı sürümü** taşır — ayrı SDK reposu ya da
package/dist/app.d.mts CHANGED
@@ -156,12 +156,33 @@ interface IdentifyInput {
156
156
  phone?: string;
157
157
  attributes?: Record<string, unknown>;
158
158
  }
159
- type MessageSender = 'visitor' | 'agent' | 'system';
159
+ /** `bot` = kanal ajanı (yapay zekâ). Okuyan taraf için ajan gibi ele alınır. */
160
+ type MessageSender = 'visitor' | 'agent' | 'bot' | 'system';
161
+ interface MessageOption {
162
+ label: string;
163
+ value?: string;
164
+ url?: string;
165
+ }
166
+ interface MessageMeta {
167
+ ai?: boolean;
168
+ agent_name?: string | null;
169
+ /** Dokunulabilir seçenekler: `url` varsa aç, yoksa `value ?? label` gönder. */
170
+ options?: MessageOption[];
171
+ [key: string]: unknown;
172
+ }
160
173
  interface Message {
161
174
  id: string;
162
175
  sender_type: MessageSender;
176
+ /** Sunucu kartı: ajan ya da bot (`bot:true`), sistemde null. */
177
+ agent?: {
178
+ id: number | null;
179
+ name: string;
180
+ avatar_url?: string | null;
181
+ bot?: boolean;
182
+ } | null;
163
183
  body?: string | null;
164
184
  attachments?: Attachment[] | null;
185
+ meta?: MessageMeta | null;
165
186
  reply_to_id?: string | null;
166
187
  reactions?: Record<string, string[]> | null;
167
188
  delivered_at?: string | null;
package/dist/app.d.ts CHANGED
@@ -156,12 +156,33 @@ interface IdentifyInput {
156
156
  phone?: string;
157
157
  attributes?: Record<string, unknown>;
158
158
  }
159
- type MessageSender = 'visitor' | 'agent' | 'system';
159
+ /** `bot` = kanal ajanı (yapay zekâ). Okuyan taraf için ajan gibi ele alınır. */
160
+ type MessageSender = 'visitor' | 'agent' | 'bot' | 'system';
161
+ interface MessageOption {
162
+ label: string;
163
+ value?: string;
164
+ url?: string;
165
+ }
166
+ interface MessageMeta {
167
+ ai?: boolean;
168
+ agent_name?: string | null;
169
+ /** Dokunulabilir seçenekler: `url` varsa aç, yoksa `value ?? label` gönder. */
170
+ options?: MessageOption[];
171
+ [key: string]: unknown;
172
+ }
160
173
  interface Message {
161
174
  id: string;
162
175
  sender_type: MessageSender;
176
+ /** Sunucu kartı: ajan ya da bot (`bot:true`), sistemde null. */
177
+ agent?: {
178
+ id: number | null;
179
+ name: string;
180
+ avatar_url?: string | null;
181
+ bot?: boolean;
182
+ } | null;
163
183
  body?: string | null;
164
184
  attachments?: Attachment[] | null;
185
+ meta?: MessageMeta | null;
165
186
  reply_to_id?: string | null;
166
187
  reactions?: Record<string, string[]> | null;
167
188
  delivered_at?: string | null;
@@ -1,4 +1,4 @@
1
- var Signalbird=(function(exports){'use strict';var j=class{constructor(e,t,i,n,r){this.baseUrl=e;this.publicKey=t;this.chatKey=i;this.secret=n;this.log=r;}get(e,t){return this.request("GET",e+Me(t))}post(e,t,i=false){return this.request("POST",e,t,i)}patch(e,t){return this.request("PATCH",e,t)}delete(e){return this.request("DELETE",e)}upload(e,t){let i=new FormData;return i.append("file",t,t.name),this.request("POST",e,i)}async request(e,t,i,n=false){let r={Accept:"application/json","X-Signalbird-Key":this.publicKey,...this.chatKey?{"X-Signalbird-Module-Key":this.chatKey}:{}},o=this.secret();o&&(r["X-Signalbird-Visitor"]=o);let l;i instanceof FormData?l=i:i!==void 0&&(r["Content-Type"]="application/json",l=JSON.stringify(i));let d=0,c=null;try{let p=await fetch(this.baseUrl+t,{method:e,headers:r,body:l,keepalive:n});d=p.status;let h=await p.text();try{c=h?JSON.parse(h):null;}catch(m){c=h;}if(p.ok)return {ok:!0,status:d,data:c}}catch(p){return this.log("network",e,t,p),{ok:false,status:0,code:"NETWORK_ERROR",message:String(p)}}let u=c&&c.code||`HTTP_${d}`,f=c&&c.message||`HTTP ${d}`;return this.log("error",e,t,u,f),{ok:false,status:d,code:u,message:f,data:c}}};function Me(s){if(!s)return "";let e=new URLSearchParams;for(let i in s){let n=s[i];n!=null&&n!==""&&e.set(i,String(n));}let t=e.toString();return t?`?${t}`:""}var q="sb_visitor",N=class{constructor(e){this.publicKey=e;this.visitor=null;this.conversation=null;this.messages=[];this.agent=null;this.agentTyping=false;this.online=false;this.withinHours=true;this.unread=0;this.isOpen=false;this.rated=new Set;this.listeners={};this.visitor=this.readVisitor();}on(e,t){var i;return ((i=this.listeners)[e]||(i[e]=[])).push(t),()=>this.off(e,t)}off(e,t){let i=this.listeners[e];i&&(this.listeners[e]=i.filter(n=>n!==t));}emit(e,t){for(let i of this.listeners[e]||[])try{i(t);}catch(n){}}readVisitor(){try{let e=localStorage.getItem(q);if(!e)return null;let t=JSON.parse(e);return !t||!t.secret||t.publicKey!==this.publicKey?null:t}catch(e){return null}}setVisitor(e){var i,n,r,o,l,d,c;let t=e.secret||((i=this.visitor)==null?void 0:i.secret);if(t){this.visitor={id:e.id,secret:t,publicKey:this.publicKey,name:(o=(r=e.name)!=null?r:(n=this.visitor)==null?void 0:n.name)!=null?o:null,email:(c=(d=e.email)!=null?d:(l=this.visitor)==null?void 0:l.email)!=null?c:null};try{localStorage.setItem(q,JSON.stringify(this.visitor));}catch(u){}}}clearVisitor(){this.visitor=null,this.conversation=null,this.messages=[],this.setUnread(0);try{localStorage.removeItem(q);}catch(e){}this.emit("change");}get secret(){var e,t;return (t=(e=this.visitor)==null?void 0:e.secret)!=null?t:null}setConversation(e){var i;let t=(e==null?void 0:e.id)!==((i=this.conversation)==null?void 0:i.id);this.conversation=e,t&&(this.messages=[]),this.emit("change");}mergeMessages(e,t=false){let i=0,n=new Map,r=new Map;for(let l of this.messages)n.set(l.id,l),l.client_id&&r.set(l.client_id,l);let o=t?this.messages.filter(l=>l._pending||l._failed):[...this.messages];for(let l of e){let d=n.get(l.id)||(l.client_id?r.get(l.client_id):void 0);if(d){let c=o.indexOf(d),u={...d,...l,_pending:false,_failed:false,_files:void 0};c>=0?o[c]=u:o.push(u),n.set(l.id,u);}else o.push(l),n.set(l.id,l),l.sender_type==="agent"&&i++;}return o.sort((l,d)=>ie(l).localeCompare(ie(d))),this.messages=o,this.emit("messages"),i}upsertMessage(e){this.mergeMessages([e]);}removeMessage(e){this.messages=this.messages.filter(t=>t.id!==e),this.emit("messages");}find(e){return e?this.messages.find(t=>t.id===e):void 0}get lastServerMessageId(){for(let e=this.messages.length-1;e>=0;e--){let t=this.messages[e];if(!t._pending&&!t._failed&&!t.id.startsWith("local_"))return t.id}return null}setUnread(e){let t=Math.max(0,e|0);t!==this.unread&&(this.unread=t,this.emit("unread",t));}get dismissed(){return se(this.dismissKey)==="1"}setDismissed(e){try{e?localStorage.setItem(this.dismissKey,"1"):localStorage.removeItem(this.dismissKey);}catch(t){}}get dismissKey(){return `sb_dismissed_${this.publicKey}`}wasRated(e){return this.rated.has(e)||se(`sb_rated_${e}`)==="1"}markRated(e){this.rated.add(e);try{localStorage.setItem(`sb_rated_${e}`,"1");}catch(t){}}};function ie(s){return s.created_at||""}function se(s){try{return localStorage.getItem(s)}catch(e){return null}}var G=[2e4,2e4,2e4,6e4,6e4,18e4],ne=3e3,Ce=45e3,Se=3e5,H=class{constructor(e){this.tick=e;this.timer=null;this.step=0;this.open=false;this.live=false;this.running=false;this.stopped=true;this.onVisible=this.onVisible.bind(this);}start(){this.stopped=false,document.addEventListener("visibilitychange",this.onVisible),window.addEventListener("online",this.onVisible),this.schedule(0);}stop(){this.stopped=true,this.timer&&clearTimeout(this.timer),this.timer=null,document.removeEventListener("visibilitychange",this.onVisible),window.removeEventListener("online",this.onVisible);}setOpen(e){this.open=e,this.step=0,this.schedule(e?0:ne);}poke(e=0){this.step=0,this.schedule(e);}onVisible(){document.hidden||(this.step=0,this.schedule(0));}setLive(e){this.live!==e&&(this.live=e,this.step=0,this.schedule());}interval(){return this.live?this.open?Ce:Se:this.open?ne:G[Math.min(this.step,G.length-1)]}schedule(e=this.interval()){this.stopped||(this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.run();},e));}async run(){if(this.stopped||this.running)return;if(document.hidden||typeof navigator!="undefined"&&navigator.onLine===false){this.schedule();return}this.running=true;let e=false;try{e=await this.tick()===!0;}catch(t){}finally{this.running=false;}e?this.step=0:this.open||(this.step=Math.min(this.step+1,G.length-1)),this.schedule();}};var re=[1e3,2e3,5e3,1e4,3e4],I=class{constructor(e,t,i,n,r=()=>{}){this.config=e;this.auth=t;this.onEvent=i;this.onState=n;this.log=r;this.ws=null;this.sid=null;this.attempt=0;this.closed=false;this.timer=null;this.pending=new Set;this.joined=new Set;}get connected(){var e;return ((e=this.ws)==null?void 0:e.readyState)===WebSocket.OPEN&&this.sid!==null}connect(){if(!this.config.enabled||!this.config.url||typeof WebSocket=="undefined"||this.ws)return;this.closed=false;let t=`${this.config.url.replace(/^http/,"ws").replace(/\/$/,"")}/socket.io/?EIO=4&transport=websocket`;try{this.ws=new WebSocket(t);}catch(i){this.log("socket open failed",i),this.retry();return}this.ws.onmessage=i=>this.handle(String(i.data)),this.ws.onclose=()=>this.retry(),this.ws.onerror=()=>{this.log("socket error");};}subscribe(e){this.joined.has(e)||this.pending.has(e)||(this.pending.add(e),this.connected&&this.flush());}close(){var e;this.closed=true,this.timer&&clearTimeout(this.timer),this.timer=null,this.joined.clear();try{(e=this.ws)==null||e.close();}catch(t){}this.ws=null,this.sid=null;}handle(e){let t=e[0];if(t==="0"){this.send("40");return}if(t==="2"){this.send("3");return}if(t!=="4")return;let i=e[1],n=e.slice(2);if(i==="0"){try{this.sid=String(JSON.parse(n||"{}").sid||"");}catch(r){this.sid="";}this.attempt=0,this.onState(true),this.flush();return}if(i==="2"){let r;try{r=JSON.parse(n);}catch(d){return}if(!Array.isArray(r))return;let[o,l]=r;typeof o=="string"&&o.startsWith("chat.")&&this.onEvent({name:o,data:l!=null?l:{}});}}async flush(){let e=this.sid;if(e)for(let t of Array.from(this.pending))try{let i=await this.auth(e,t);if(!i){this.pending.delete(t);continue}this.emit("subscribe",{channel:t,auth:i.auth,at:i.at}),this.pending.delete(t),this.joined.add(t);}catch(i){this.log("subscribe failed",t,i);}}emit(e,t){this.send(`42${JSON.stringify([e,t])}`);}send(e){var t;if(((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN)try{this.ws.send(e);}catch(i){}}retry(){if(this.ws=null,this.sid=null,this.joined.forEach(t=>this.pending.add(t)),this.joined.clear(),this.onState(false),this.closed)return;let e=re[Math.min(this.attempt,re.length-1)];this.attempt++,this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>this.connect(),e);}};var ae=`
1
+ var Signalbird=(function(exports){'use strict';var H=class{constructor(e,t,i,n,a){this.baseUrl=e;this.publicKey=t;this.chatKey=i;this.secret=n;this.log=a;}get(e,t){return this.request("GET",e+Ce(t))}post(e,t,i=false){return this.request("POST",e,t,i)}patch(e,t){return this.request("PATCH",e,t)}delete(e){return this.request("DELETE",e)}upload(e,t){let i=new FormData;return i.append("file",t,t.name),this.request("POST",e,i)}async request(e,t,i,n=false){let a={Accept:"application/json","X-Signalbird-Key":this.publicKey,...this.chatKey?{"X-Signalbird-Module-Key":this.chatKey}:{}},o=this.secret();o&&(a["X-Signalbird-Visitor"]=o);let l;i instanceof FormData?l=i:i!==void 0&&(a["Content-Type"]="application/json",l=JSON.stringify(i));let d=0,c=null;try{let p=await fetch(this.baseUrl+t,{method:e,headers:a,body:l,keepalive:n});d=p.status;let h=await p.text();try{c=h?JSON.parse(h):null;}catch(m){c=h;}if(p.ok)return {ok:!0,status:d,data:c}}catch(p){return this.log("network",e,t,p),{ok:false,status:0,code:"NETWORK_ERROR",message:String(p)}}let g=c&&c.code||`HTTP_${d}`,f=c&&c.message||`HTTP ${d}`;return this.log("error",e,t,g,f),{ok:false,status:d,code:g,message:f,data:c}}};function Ce(s){if(!s)return "";let e=new URLSearchParams;for(let i in s){let n=s[i];n!=null&&n!==""&&e.set(i,String(n));}let t=e.toString();return t?`?${t}`:""}var W="sb_visitor",I=class{constructor(e){this.publicKey=e;this.visitor=null;this.conversation=null;this.messages=[];this.agent=null;this.agentTyping=false;this.online=false;this.withinHours=true;this.unread=0;this.isOpen=false;this.rated=new Set;this.listeners={};this.visitor=this.readVisitor();}on(e,t){var i;return ((i=this.listeners)[e]||(i[e]=[])).push(t),()=>this.off(e,t)}off(e,t){let i=this.listeners[e];i&&(this.listeners[e]=i.filter(n=>n!==t));}emit(e,t){for(let i of this.listeners[e]||[])try{i(t);}catch(n){}}readVisitor(){try{let e=localStorage.getItem(W);if(!e)return null;let t=JSON.parse(e);return !t||!t.secret||t.publicKey!==this.publicKey?null:t}catch(e){return null}}setVisitor(e){var i,n,a,o,l,d,c;let t=e.secret||((i=this.visitor)==null?void 0:i.secret);if(t){this.visitor={id:e.id,secret:t,publicKey:this.publicKey,name:(o=(a=e.name)!=null?a:(n=this.visitor)==null?void 0:n.name)!=null?o:null,email:(c=(d=e.email)!=null?d:(l=this.visitor)==null?void 0:l.email)!=null?c:null};try{localStorage.setItem(W,JSON.stringify(this.visitor));}catch(g){}}}clearVisitor(){this.visitor=null,this.conversation=null,this.messages=[],this.setUnread(0);try{localStorage.removeItem(W);}catch(e){}this.emit("change");}get secret(){var e,t;return (t=(e=this.visitor)==null?void 0:e.secret)!=null?t:null}setConversation(e){var i;let t=(e==null?void 0:e.id)!==((i=this.conversation)==null?void 0:i.id);this.conversation=e,t&&(this.messages=[]),this.emit("change");}mergeMessages(e,t=false){let i=0,n=new Map,a=new Map;for(let l of this.messages)n.set(l.id,l),l.client_id&&a.set(l.client_id,l);let o=t?this.messages.filter(l=>l._pending||l._failed):[...this.messages];for(let l of e){let d=n.get(l.id)||(l.client_id?a.get(l.client_id):void 0);if(d){let c=o.indexOf(d),g={...d,...l,_pending:false,_failed:false,_files:void 0};c>=0?o[c]=g:o.push(g),n.set(l.id,g);}else o.push(l),n.set(l.id,l),(l.sender_type==="agent"||l.sender_type==="bot")&&i++;}return o.sort((l,d)=>ie(l).localeCompare(ie(d))),this.messages=o,this.emit("messages"),i}upsertMessage(e){this.mergeMessages([e]);}removeMessage(e){this.messages=this.messages.filter(t=>t.id!==e),this.emit("messages");}find(e){return e?this.messages.find(t=>t.id===e):void 0}get lastServerMessageId(){for(let e=this.messages.length-1;e>=0;e--){let t=this.messages[e];if(!t._pending&&!t._failed&&!t.id.startsWith("local_"))return t.id}return null}setUnread(e){let t=Math.max(0,e|0);t!==this.unread&&(this.unread=t,this.emit("unread",t));}get dismissed(){return se(this.dismissKey)==="1"}setDismissed(e){try{e?localStorage.setItem(this.dismissKey,"1"):localStorage.removeItem(this.dismissKey);}catch(t){}}get dismissKey(){return `sb_dismissed_${this.publicKey}`}wasRated(e){return this.rated.has(e)||se(`sb_rated_${e}`)==="1"}markRated(e){this.rated.add(e);try{localStorage.setItem(`sb_rated_${e}`,"1");}catch(t){}}};function ie(s){return s.created_at||""}function se(s){try{return localStorage.getItem(s)}catch(e){return null}}var J=[2e4,2e4,2e4,6e4,6e4,18e4],ne=3e3,Se=45e3,_e=3e5,B=class{constructor(e){this.tick=e;this.timer=null;this.step=0;this.open=false;this.live=false;this.running=false;this.stopped=true;this.onVisible=this.onVisible.bind(this);}start(){this.stopped=false,document.addEventListener("visibilitychange",this.onVisible),window.addEventListener("online",this.onVisible),this.schedule(0);}stop(){this.stopped=true,this.timer&&clearTimeout(this.timer),this.timer=null,document.removeEventListener("visibilitychange",this.onVisible),window.removeEventListener("online",this.onVisible);}setOpen(e){this.open=e,this.step=0,this.schedule(e?0:ne);}poke(e=0){this.step=0,this.schedule(e);}onVisible(){document.hidden||(this.step=0,this.schedule(0));}setLive(e){this.live!==e&&(this.live=e,this.step=0,this.schedule());}interval(){return this.live?this.open?Se:_e:this.open?ne:J[Math.min(this.step,J.length-1)]}schedule(e=this.interval()){this.stopped||(this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.run();},e));}async run(){if(this.stopped||this.running)return;if(document.hidden||typeof navigator!="undefined"&&navigator.onLine===false){this.schedule();return}this.running=true;let e=false;try{e=await this.tick()===!0;}catch(t){}finally{this.running=false;}e?this.step=0:this.open||(this.step=Math.min(this.step+1,J.length-1)),this.schedule();}};var ae=[1e3,2e3,5e3,1e4,3e4],O=class{constructor(e,t,i,n,a=()=>{}){this.config=e;this.auth=t;this.onEvent=i;this.onState=n;this.log=a;this.ws=null;this.sid=null;this.attempt=0;this.closed=false;this.timer=null;this.pending=new Set;this.joined=new Set;}get connected(){var e;return ((e=this.ws)==null?void 0:e.readyState)===WebSocket.OPEN&&this.sid!==null}connect(){if(!this.config.enabled||!this.config.url||typeof WebSocket=="undefined"||this.ws)return;this.closed=false;let t=`${this.config.url.replace(/^http/,"ws").replace(/\/$/,"")}/socket.io/?EIO=4&transport=websocket`;try{this.ws=new WebSocket(t);}catch(i){this.log("socket open failed",i),this.retry();return}this.ws.onmessage=i=>this.handle(String(i.data)),this.ws.onclose=()=>this.retry(),this.ws.onerror=()=>{this.log("socket error");};}subscribe(e){this.joined.has(e)||this.pending.has(e)||(this.pending.add(e),this.connected&&this.flush());}close(){var e;this.closed=true,this.timer&&clearTimeout(this.timer),this.timer=null,this.joined.clear();try{(e=this.ws)==null||e.close();}catch(t){}this.ws=null,this.sid=null;}handle(e){let t=e[0];if(t==="0"){this.send("40");return}if(t==="2"){this.send("3");return}if(t!=="4")return;let i=e[1],n=e.slice(2);if(i==="0"){try{this.sid=String(JSON.parse(n||"{}").sid||"");}catch(a){this.sid="";}this.attempt=0,this.onState(true),this.flush();return}if(i==="2"){let a;try{a=JSON.parse(n);}catch(d){return}if(!Array.isArray(a))return;let[o,l]=a;typeof o=="string"&&o.startsWith("chat.")&&this.onEvent({name:o,data:l!=null?l:{}});}}async flush(){let e=this.sid;if(e)for(let t of Array.from(this.pending))try{let i=await this.auth(e,t);if(!i){this.pending.delete(t);continue}this.emit("subscribe",{channel:t,auth:i.auth,at:i.at}),this.pending.delete(t),this.joined.add(t);}catch(i){this.log("subscribe failed",t,i);}}emit(e,t){this.send(`42${JSON.stringify([e,t])}`);}send(e){var t;if(((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN)try{this.ws.send(e);}catch(i){}}retry(){if(this.ws=null,this.sid=null,this.joined.forEach(t=>this.pending.add(t)),this.joined.clear(),this.onState(false),this.closed)return;let e=ae[Math.min(this.attempt,ae.length-1)];this.attempt++,this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>this.connect(),e);}};var re=`
2
2
  :host{all:initial}
3
3
  *,*::before,*::after{box-sizing:border-box}
4
4
 
@@ -287,6 +287,16 @@ border:1px solid var(--sb-b);color:var(--sb-t);box-shadow:var(--sb-sh-s);
287
287
  transition:transform .2s var(--sb-spring),border-color .15s,background .15s}
288
288
  .qk button:hover{transform:translateY(-2px);border-color:var(--sb-edge);background:var(--sb-tint)}
289
289
 
290
+ /* Kanal ajan\u0131n\u0131n se\xE7enekleri \u2014 baloncu\u011Fun alt\u0131nda dikey liste */
291
+ .opts{display:flex;flex-direction:column;gap:6px;margin-top:6px;max-width:100%}
292
+ .opts a,.opts button{display:flex;align-items:center;justify-content:space-between;gap:8px;text-align:left;
293
+ font-size:13px;font-weight:550;padding:9px 12px;border-radius:12px;background:var(--sb-el);
294
+ border:1px solid var(--sb-b);color:var(--sb-t);box-shadow:var(--sb-sh-s);text-decoration:none;cursor:pointer;
295
+ transition:transform .2s var(--sb-spring),border-color .15s,background .15s}
296
+ .opts a:hover,.opts button:hover:not([disabled]){transform:translateY(-1px);border-color:var(--sb-edge);background:var(--sb-tint)}
297
+ .opts button[disabled]{opacity:.55;cursor:default}
298
+ .opts.past a{opacity:.8}
299
+
290
300
  .day{align-self:center;font-size:11px;font-weight:650;letter-spacing:.02em;color:var(--sb-m);
291
301
  background:var(--sb-s);padding:5px 12px;border-radius:12px;margin:14px 0 10px}
292
302
 
@@ -486,5 +496,5 @@ display:flex;align-items:center;justify-content:center;margin-bottom:8px;animati
486
496
  border:1px solid var(--sb-b);border-radius:14px;text-align:center;display:none}
487
497
  .notice.on{display:block}
488
498
  .notice button{color:var(--sb-c);font-weight:650;margin-left:6px}
489
- `;function a(s,e,...t){let i=document.createElement(s);if(e)for(let n in e){let r=e[n];r==null||r===false||(n==="class"?i.className=String(r):n==="style"?i.setAttribute("style",String(r)):n.startsWith("on")&&typeof r=="function"?i.addEventListener(n.slice(2).toLowerCase(),r):n==="html"?i.innerHTML=String(r):n in i&&n!=="list"&&n!=="form"?i[n]=r:i.setAttribute(n,String(r)));}return _e(i,t),i}function _e(s,e){for(let t of e)t==null||t===false||s.appendChild(typeof t=="object"?t:document.createTextNode(String(t)));}function k(s){for(;s.firstChild;)s.removeChild(s.firstChild);}function y(s,e=18){let t=document.createElementNS("http://www.w3.org/2000/svg","svg");return t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("width",String(e)),t.setAttribute("height",String(e)),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","2"),t.setAttribute("stroke-linecap","round"),t.setAttribute("stroke-linejoin","round"),t.innerHTML=ze[s],t}function W(s=26){let e=document.createElementNS("http://www.w3.org/2000/svg","svg");return e.setAttribute("viewBox","10 2 28 38"),e.setAttribute("width",String(s)),e.setAttribute("height",String(s)),e.setAttribute("fill","none"),e.setAttribute("stroke","currentColor"),e.setAttribute("stroke-width","2"),e.setAttribute("stroke-linejoin","round"),e.setAttribute("aria-hidden","true"),e.innerHTML='<path d="M16 16 L30 16 L33 18 L24 33 L15 18 Z" fill="currentColor" fill-opacity=".18" stroke="none"/><path d="M23 4 L31 9 L23 14 L16 9 Z" fill="currentColor" fill-opacity=".28" stroke="none"/><path d="M30 16 L33 18 L36 27 L34 34 L41 32 L44 38 L31 37 L24 37 L17 35 L13 27 L15 18 L16 16"/><path d="M16 16 L16 9 L23 4 L31 9 L30 16"/><path d="M21.4 12.4 L23.2 18.6 L25 12.4 Z" fill="currentColor" fill-opacity=".35"/><circle cx="28.4" cy="11.4" r="1.6" fill="currentColor" stroke="none"/>',e}var ze={chat:'<path d="M21 11.5a8.4 8.4 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.4 8.4 0 0 1-3.8-.9L3 21l1.9-5.7a8.4 8.4 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.4 8.4 0 0 1 3.8-.9h.5a8.5 8.5 0 0 1 8 8v.5z"/>',close:'<path d="M18 6 6 18M6 6l12 12"/>',send:'<path d="m22 2-7 20-4-9-9-4 20-7z"/><path d="M22 2 11 13"/>',clip:'<path d="m21.4 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"/>',file:'<path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><path d="M14 2v6h6"/>',check:'<path d="M20 6 9 17l-5-5"/>',checks:'<path d="M18 6 7 17l-4-4"/><path d="m22 10-7.5 7.5L13 16"/>',reply:'<path d="M9 17H5a2 2 0 0 1-2-2V9"/><path d="m3 9 4-4"/><path d="m3 9 4 4"/><path d="M9 17h6a6 6 0 0 0 0-12h-2"/>',more:'<circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/>',star:'<path d="m12 2 3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/>',chevron:'<path d="m6 9 6 6 6-6"/>',smile:'<circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><path d="M9 9h.01M15 9h.01"/>',done:'<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><path d="m22 4-10 10-3-3"/>',down:'<path d="M12 5v14"/><path d="m19 12-7 7-7-7"/>',image:'<rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="9" cy="9" r="1.5"/><path d="m21 15-4.5-4.5L9 18"/>',heart:'<path d="M20.8 4.6a5.5 5.5 0 0 0-7.8 0L12 5.7l-1-1.1a5.5 5.5 0 0 0-7.8 7.8l1.1 1L12 21l7.7-7.6 1.1-1a5.5 5.5 0 0 0 0-7.8z"/>'};function B(s){return (s||"?").trim().split(/\s+/).slice(0,2).map(e=>e[0]||"").join("").toUpperCase()}function C(s,e){let t=A(s);return t?a("img",{src:t,alt:"",loading:"lazy"}):document.createTextNode(B(e))}function A(s){return typeof s=="string"&&/^(https:\/\/|data:image\/)/i.test(s)?s:null}function oe(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(0)} KB`:`${(s/1024/1024).toFixed(1)} MB`}function le(){return typeof crypto!="undefined"&&"randomUUID"in crypto?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{let e=Math.random()*16|0;return (s==="x"?e:e&3|8).toString(16)})}var de=["\u{1F44D}","\u2764\uFE0F","\u{1F602}","\u{1F62E}","\u{1F622}","\u{1F64F}"],ge=["\u{1F600}","\u{1F604}","\u{1F60A}","\u{1F642}","\u{1F609}","\u{1F60D}","\u{1F929}","\u{1F60E}","\u{1F914}","\u{1F610}","\u{1F615}","\u{1F641}","\u{1F622}","\u{1F62D}","\u{1F621}","\u{1F92F}","\u{1F44D}","\u{1F44E}","\u{1F44F}","\u{1F64F}","\u{1F4AA}","\u{1F525}","\u2705","\u2764\uFE0F"],Ae=900*1e3,Re=300*1e3;function be(s,e){let t=O(s),i=s.childNodes.length===0,n=Pe(s);if(k(s),e.messages.length===0){s.appendChild(je(e));return}let r="";for(let o=0;o<e.messages.length;o++){let l=e.messages[o],d=J(l.created_at),c=d===r&&e.messages[o-1]||null,u=e.messages[o+1]||null;d!==r&&(s.appendChild(a("div",{class:"day"},$e(l.created_at,e))),r=d),s.appendChild(Ne(l,e,c,He(l,u)?u:null,!i&&!n.has(l.id)));}(t||i)&&z(s);}function O(s,e=60){return s.scrollHeight-s.scrollTop-s.clientHeight<e}function z(s,e=false){if(e&&typeof s.scrollTo=="function"){s.scrollTo({top:s.scrollHeight,behavior:"smooth"});return}s.scrollTop=s.scrollHeight;}function Pe(s){let e=new Set;return s.querySelectorAll("[data-id]").forEach(t=>{let i=t.dataset.id;i&&e.add(i);}),e}function je(s){let e=a("div",{class:"hero"});e.appendChild(a("div",{class:"hv"},a("span",null,C(s.agentAvatar,s.brandName||s.agentName)))),e.appendChild(a("h4",null,s.greeting||s.t.greeting)),s.responseHint&&e.appendChild(a("p",null,s.responseHint));let t=s.quick||[];if(t.length&&s.onQuick){let i=a("div",{class:"qk"});for(let n of t.slice(0,6))i.appendChild(a("button",{type:"button",onclick:()=>s.onQuick(n)},n));e.appendChild(i);}return e}function Ne(s,e,t,i,n){var x;let r=s.sender_type==="visitor"?"v":s.sender_type==="system"?"s":"a",o=!pe(t,s),l=!pe(s,i),d=a("div",{class:`row ${r}`+(o&&t?" gap":"")+(l?"":" mid")+(s._pending?" pend":"")+(s._failed?" fail":"")+(n?" new":""),"data-id":s.id});if(r==="s")return d.appendChild(a("div",{class:"bb"},s.body||"")),d;r==="a"&&d.appendChild(a("div",{class:`av${l?"":" gh"}`},C(e.agentAvatar,s.sender_name||e.agentName)));let c=a("div",{class:"cl"}),u=a("div",{class:`bb${s.deleted_at?" del":""}`});if(s.deleted_at)return u.textContent=e.t.deleted,c.appendChild(u),d.appendChild(c),d;if(s.reply_to_id){let b=e.find(s.reply_to_id),g=b?b.sender_type==="visitor"?e.t.you:b.sender_name||e.agentName:"";u.appendChild(a("span",{class:"q"},g?`${g}: `:"",b?$(b,e.t):"\u2026"));}if(s._files&&s._files.length){let b=a("div",{class:"imgs"});for(let g of s._files)g.type.startsWith("image/")?b.appendChild(a("img",{src:URL.createObjectURL(g),alt:g.name})):u.appendChild(ce({name:g.name,url:"",mime:g.type,size:g.size},e));b.childNodes.length&&u.appendChild(b);}let f=s.attachments||[],p=f.filter(b=>he(b.mime));if(p.length){let b=a("div",{class:"imgs"});for(let g of p)b.appendChild(a("img",{src:g.url,alt:g.name,loading:"lazy",onclick:()=>e.actions.openImage(g.url)}));u.appendChild(b);}for(let b of f.filter(g=>!he(g.mime)))u.appendChild(ce(b,e));let h=(r==="v"?null:(x=s.translation)==null?void 0:x.body)||s.body;h&&u.appendChild(Oe(h)),s._failed&&(u.appendChild(a("div",{style:"font-size:11px;margin-top:5px;font-weight:600"},e.t.failed)),u.addEventListener("click",()=>e.actions.retry(s))),c.appendChild(u);let m=s.reactions&&Object.keys(s.reactions).length?s.reactions:null;if(m){let b=a("div",{class:"rx"});for(let g in m){let L=m[g]||[];if(!L.length)continue;let w=L.includes("visitor");b.appendChild(a("button",{class:w?"me":"",type:"button",onclick:()=>e.actions.react(s,g)},`${g} ${L.length}`));}b.childNodes.length&&c.appendChild(b);}if(l){let b=a("div",{class:"mt"},Ve(s.created_at,e.locale));if(s.edited_at&&b.appendChild(a("span",{class:"ed"},`\xB7 ${e.t.edited}`)),r==="v"&&!s._failed){let g=a("span",{class:`tk${s.read_at?" rd":""}`});g.appendChild(s._pending?y("check",12):s.read_at||s.delivered_at?y("checks",13):y("check",12)),s._pending&&(g.style.opacity=".4"),b.appendChild(g);}c.appendChild(b);}return d.appendChild(c),!s._pending&&!s._failed&&(d.appendChild(Ie(s,e,d)),Be(d)),d}function pe(s,e){if(!s||!e||s.sender_type!==e.sender_type||s.sender_type==="system"||s.sender_id!==e.sender_id)return false;let t=Date.parse(e.created_at)-Date.parse(s.created_at);return t>=0&&t<Re}function He(s,e){return !!e&&J(s.created_at)===J(e.created_at)}function Ie(s,e,t){let i=a("div",{class:"ac"});for(let o of de.slice(0,3))i.appendChild(a("button",{type:"button",title:e.t.react,onclick:()=>e.actions.react(s,o)},o));i.appendChild(a("button",{type:"button",title:e.t.reply,onclick:()=>e.actions.reply(s)},y("reply",15)));let n=a("div",{class:"menu"});for(let o of de.slice(3))n.appendChild(a("button",{type:"button",onclick:()=>{n.classList.remove("show"),e.actions.react(s,o);}},`${o} ${e.t.react}`));return s.sender_type==="visitor"&&Date.now()-Date.parse(s.created_at)<Ae&&(n.appendChild(a("button",{type:"button",onclick:()=>{n.classList.remove("show"),e.actions.edit(s);}},e.t.edit)),n.appendChild(a("button",{type:"button",class:"dg",onclick:()=>{n.classList.remove("show"),e.actions.remove(s);}},e.t.delete))),i.appendChild(a("button",{type:"button",title:e.t.react,onclick:o=>{o.stopPropagation(),n.classList.toggle("show"),n.style.top=`${t.offsetHeight+4}px`;}},y("more",15))),t.appendChild(n),document.addEventListener("click",()=>n.classList.remove("show"),{once:true,capture:true}),i}function Be(s){let e=null,t=()=>{e=setTimeout(()=>{var r;s.classList.add("acts");try{(r=navigator.vibrate)==null||r.call(navigator,8);}catch(o){}let n=o=>{s.contains(o.target)||(s.classList.remove("acts"),document.removeEventListener("touchstart",n,true));};document.addEventListener("touchstart",n,true);},420);},i=()=>e&&clearTimeout(e);s.addEventListener("touchstart",t,{passive:true}),s.addEventListener("touchend",i),s.addEventListener("touchmove",i,{passive:true});}function ce(s,e){return a("a",{class:"fr",href:s.url||void 0,target:"_blank",rel:"noopener"},y("file",18),a("span",{class:"fn"},s.name||e.t.attachment),a("span",{class:"fs"},oe(s.size||0)))}function Oe(s){let e=document.createDocumentFragment(),t=/(https?:\/\/[^\s<]+)/g,i=0,n;for(;n=t.exec(s);){n.index>i&&e.appendChild(document.createTextNode(s.slice(i,n.index)));let r=n[1].replace(/[.,;:!?)]+$/,"");e.appendChild(a("a",{href:r,target:"_blank",rel:"noopener noreferrer nofollow"},r)),i=n.index+r.length;}return i<s.length&&e.appendChild(document.createTextNode(s.slice(i))),e}function $(s,e){var n,r;if(s.deleted_at)return e.deleted;let t=(s.sender_type==="visitor"?null:(n=s.translation)==null?void 0:n.body)||s.body;if(t)return t.length>90?t.slice(0,90)+"\u2026":t;let i=(r=s.attachments)==null?void 0:r[0];return i?`\u{1F4CE} ${i.name}`:"\u2026"}function he(s){return !!s&&s.startsWith("image/")}function J(s){let e=new Date(s);return `${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function $e(s,e){let t=new Date(s),i=new Date,n=Math.round((ue(i)-ue(t))/864e5);if(n===0)return e.t.today;if(n===1)return e.t.yesterday;try{return new Intl.DateTimeFormat(e.locale,{day:"numeric",month:"long",year:t.getFullYear()!==i.getFullYear()?"numeric":void 0}).format(t)}catch(r){return t.toLocaleDateString()}}function ue(s){return new Date(s.getFullYear(),s.getMonth(),s.getDate()).getTime()}function Ve(s,e){let t=new Date(s);try{return new Intl.DateTimeFormat(e,{hour:"2-digit",minute:"2-digit"}).format(t)}catch(i){return t.toLocaleTimeString()}}var De={launcher:"Sohbet",title:"Sohbet",online:"\xC7evrimi\xE7i",offline:"Genelde birka\xE7 dakika i\xE7inde yan\u0131tl\u0131yoruz",greeting:"Merhaba! Size nas\u0131l yard\u0131mc\u0131 olabiliriz?",offlineMessage:"\u015Eu an \xE7evrimd\u0131\u015F\u0131y\u0131z. Mesaj\u0131n\u0131z\u0131 b\u0131rak\u0131n, en k\u0131sa s\xFCrede d\xF6nelim.",prechatTitle:"Ba\u015Flamadan \xF6nce",prechatHint:"Size geri d\xF6nebilmemiz i\xE7in bilgilerinizi b\u0131rak\u0131n.",topicLabel:"Konu",topicPlaceholder:"Konu se\xE7in (iste\u011Fe ba\u011Fl\u0131)",name:"Ad\u0131n\u0131z",email:"E-posta",start:"Sohbete ba\u015Fla",skip:"Atla",placeholder:"Mesaj\u0131n\u0131z\u0131 yaz\u0131n\u2026",send:"G\xF6nder",attach:"Dosya ekle",typing:"yaz\u0131yor\u2026",today:"Bug\xFCn",yesterday:"D\xFCn",reply:"Yan\u0131tla",react:"Tepki ver",edit:"D\xFCzenle",delete:"Sil",deleted:"Bu mesaj silindi",edited:"d\xFCzenlendi",save:"Kaydet",cancel:"Vazge\xE7",you:"Siz",agent:"Destek",system:"Sistem",endChat:"Sohbeti bitir",newChat:"Yeni sohbet",resolved:"Bu sohbet \xE7\xF6z\xFCld\xFC olarak i\u015Faretlendi.",closed:"Bu sohbet kapat\u0131ld\u0131.",rateTitle:"Bu sohbeti nas\u0131l buldunuz?",rateComment:"Eklemek istedi\u011Finiz bir \u015Fey var m\u0131? (iste\u011Fe ba\u011Fl\u0131)",rateSend:"G\xF6nder",rateThanks:"Geri bildiriminiz bize ula\u015Ft\u0131.",rateThanksTitle:"Te\u015Fekk\xFCrler!",rateScale:["Hi\xE7 iyi de\u011Fildi","Bekledi\u011Fim gibi olmad\u0131","\u0130dare eder","\u0130yiydi","Harikayd\u0131"],reviewIntro:"Yard\u0131mc\u0131 olabildiysek bizi yorumlar m\u0131s\u0131n\u0131z?",reviewCta:"De\u011Ferlendir",failed:"G\xF6nderilemedi \u2014 tekrar dene",fileTooLarge:"Dosya \xE7ok b\xFCy\xFCk (en fazla {mb} MB)",fileNotAllowed:"Bu dosya t\xFCr\xFCn\xFC y\xFCkleyemezsiniz",tooLong:"Mesaj en fazla {max} karakter olabilir",unavailable:"Sohbet \u015Fu an kullan\u0131lam\u0131yor. L\xFCtfen daha sonra tekrar deneyin.",close:"Kapat",dismiss:"Sohbet balonunu gizle",minimize:"K\xFC\xE7\xFClt",unreadTitle:"({n}) Yeni mesaj",dropHere:"Dosyay\u0131 buraya b\u0131rak\u0131n",replyingTo:"Yan\u0131tlan\u0131yor",attachment:"Ek",poweredBy:"Signalbird ile",resize:"Boyutland\u0131r",emoji:"Emoji ekle",jump:"En alta in",newMessage:"Yeni mesaj",replyFast:"\u015Eu an buraday\u0131z \u2014 genelde birka\xE7 dakika i\xE7inde yan\u0131tl\u0131yoruz."},Ke={launcher:"Chat",title:"Chat",online:"Online",offline:"We usually reply within a few minutes",greeting:"Hi there! How can we help you?",offlineMessage:"We're offline right now. Leave a message and we'll get back to you.",prechatTitle:"Before we start",prechatHint:"Leave your details so we can get back to you.",topicLabel:"Topic",topicPlaceholder:"Pick a topic (optional)",name:"Your name",email:"Email",start:"Start chat",skip:"Skip",placeholder:"Type your message\u2026",send:"Send",attach:"Attach file",typing:"is typing\u2026",today:"Today",yesterday:"Yesterday",reply:"Reply",react:"React",edit:"Edit",delete:"Delete",deleted:"This message was deleted",edited:"edited",save:"Save",cancel:"Cancel",you:"You",agent:"Support",system:"System",endChat:"End chat",newChat:"New chat",resolved:"This conversation was marked as resolved.",closed:"This conversation was closed.",rateTitle:"How was this conversation?",rateComment:"Anything to add? (optional)",rateSend:"Send",rateThanks:"Your feedback reached us.",rateThanksTitle:"Thank you!",rateScale:["Not good at all","Not what I expected","It was okay","Good","Excellent"],reviewIntro:"If we were helpful, would you leave us a review?",reviewCta:"Leave a review",failed:"Not sent \u2014 tap to retry",fileTooLarge:"File is too large (max {mb} MB)",fileNotAllowed:"That file type cannot be uploaded",tooLong:"A message may be at most {max} characters",unavailable:"Chat is unavailable right now. Please try again later.",close:"Close",dismiss:"Hide the chat bubble",minimize:"Minimize",unreadTitle:"({n}) New message",dropHere:"Drop the file here",replyingTo:"Replying to",attachment:"Attachment",poweredBy:"Powered by Signalbird",resize:"Resize",emoji:"Add emoji",jump:"Jump to latest",newMessage:"New message",replyFast:"We're here right now \u2014 we usually reply within a few minutes."};function X(s,e){let t=n=>n&&n!=="auto"?n.toLowerCase().slice(0,2):null;return (t(e)||t(s)||t(typeof navigator!="undefined"?navigator.language:null)||"en")==="tr"?"tr":"en"}function Z(s){return s==="tr"?De:Ke}function R(s,e){return s.replace(/\{(\w+)\}/g,(t,i)=>{var n;return String((n=e[i])!=null?n:"")})}var Fe=["image/jpeg","image/png","image/gif","image/webp"],Ue=420,Ye=60,qe=11e3,Ge=9e3,me="sb_teaser",fe="sb_seen",K=class{constructor(e){this.o=e;this.list=null;this.typingEl=null;this.typingAvatar=null;this.jumpBtn=null;this.textarea=null;this.sendBtn=null;this.emojiBox=null;this.chips=null;this.replyBar=null;this.notice=null;this.files=[];this.counter=null;this.replyTo=null;this.editing=null;this.view="none";this.agent=null;this.online=false;this.typingTimer=null;this.teaserTimer=null;this.toastTimer=null;this.attnTimer=null;this.wasTyping=false;this.scrollLock=0;this.locked=false;var l;let t=e.t;this.host=a("div",{id:"signalbird-widget"}),this.root=this.host.attachShadow({mode:"open"}),this.root.appendChild(a("style",null,ae));let i=e.settings.position==="left"?"left":"right",n=e.settings.layout==="sidebar"?" sidebar":"";if(this.wrap=a("div",{class:`sb ${i}${n}${Xe(e.settings.theme)?" dark":""}`,style:`--sb-c:${Ze(e.settings.color)}`}),e.settings.theme==="auto"&&typeof matchMedia=="function"){let d=matchMedia("(prefers-color-scheme: dark)");(l=d.addEventListener)==null||l.call(d,"change",c=>this.wrap.classList.toggle("dark",c.matches));}this.badge=a("span",{class:"badge"});let r=e.settings.launcher_text;this.launcher=a("button",{class:`ln${r?"":" icon-only"}`,type:"button","aria-label":r||t.launcher,onclick:()=>this.onLauncher()},a("span",{class:"lm"},this.launcherMark()),r?a("span",{class:"lt"},r):null,a("span",{class:"ln-on"}),a("span",{class:"ln-pulse"}),this.badge),this.dismissBtn=a("button",{class:"dm",type:"button",title:t.dismiss,"aria-label":t.dismiss,onclick:d=>{d.stopPropagation(),e.actions.dismiss();}},y("close",13)),this.teaser=this.buildTeaser(),this.toast=this.buildToast(),this.headerPhoto=a("div",{class:"ph"},this.brandAvatar()),this.headerDot=a("span",{class:"dot"}),this.headerName=a("div",{class:"hn"},e.appName||t.title),this.headerStatus=a("div",{class:"hs"},t.offline),this.endBtn=a("button",{class:"hb hide",type:"button",title:t.endChat,"aria-label":t.endChat,onclick:()=>e.actions.endChat()},y("done",19));let o=a("div",{class:"hd"},a("div",{class:"av"},this.headerPhoto,this.headerDot),a("div",{class:"hi"},this.headerName,this.headerStatus),a("div",{class:"ha"},this.endBtn,a("button",{class:"hb",type:"button",title:t.close,"aria-label":t.close,onclick:()=>e.actions.close()},y("close",20))));this.dragBar=a("div",{class:"drag","aria-hidden":"true"},a("i")),this.banner=a("div",{class:"bn"}),this.body=a("div",{class:"bd"}),this.grip=a("div",{class:"gp",title:t.resize,"aria-hidden":"true"}),this.panel=a("div",{class:"pn",role:"dialog","aria-modal":"false","aria-label":t.title},a("div",{class:"glow","aria-hidden":"true"}),this.dragBar,o,this.banner,this.body,this.grip),e.settings.layout!=="sidebar"&&(this.restoreGeometry(),this.enableMove(o),this.enableResize()),this.enableSwipeClose(),this.wrap.appendChild(this.launcher),this.wrap.appendChild(this.dismissBtn),this.wrap.appendChild(this.teaser),this.wrap.appendChild(this.toast),this.wrap.appendChild(this.panel),this.root.appendChild(this.wrap),this.enableDrop(),this.onKey=this.onKey.bind(this),this.onViewport=this.onViewport.bind(this);}key(e){return `${e}_${this.o.publicKey}`}mount(){this.host.isConnected||document.body.appendChild(this.host),document.addEventListener("keydown",this.onKey),this.scheduleTeaser();}unmount(){var e;this.clearTimers(),this.unlockScroll(),document.removeEventListener("keydown",this.onKey),(e=D())==null||e.removeEventListener("resize",this.onViewport),this.host.remove();}setDismissed(e){this.wrap.classList.toggle("hidden",e),e&&this.hideTeaser(false);}setLauncherHidden(e){this.wrap.classList.toggle("no-ln",e),e&&this.hideTeaser(false);}setOpen(e){var t;this.wrap.classList.toggle("open",e),e?(ye(this.key(fe)),this.hideTeaser(false),this.hideToast(),this.lockScroll(),this.bindViewport(),requestAnimationFrame(()=>{var i;this.list&&z(this.list),S()||(i=this.textarea)==null||i.focus();})):(this.unlockScroll(),(t=D())==null||t.removeEventListener("resize",this.onViewport),this.wrap.style.setProperty("--sb-kb","0px"),this.wrap.classList.remove("kb"),this.hideEmoji());}setUnread(e){this.badge.textContent=e>99?"99+":String(e),this.badge.classList.toggle("on",e>0),this.wrap.classList.toggle("pulse",e>0),e===0&&this.hideToast();}attention(e){let t=this.launcher;t.classList.remove("attn"),t.offsetWidth,t.classList.add("attn"),this.attnTimer&&clearTimeout(this.attnTimer),this.attnTimer=setTimeout(()=>t.classList.remove("attn"),2400),e&&(e.body||e.name)&&this.showToast(e);}setHeader(e,t){var r;let i=this.o.t;this.agent=e,this.online=(r=e==null?void 0:e.online)!=null?r:t;let n=(e==null?void 0:e.name)||this.o.appName||i.title;this.headerName.textContent=n,k(this.headerPhoto),this.headerPhoto.appendChild(e?C(e.avatar,n):this.brandAvatar()),this.headerDot.classList.toggle("on",this.online),this.headerStatus.textContent=this.online?i.online:i.offline,this.wrap.classList.toggle("agent-on",this.online),this.typingAvatar&&(k(this.typingAvatar),this.typingAvatar.appendChild(C(e==null?void 0:e.avatar,n)));}setBanner(e,t=false){k(this.banner),this.banner.className=`bn${t?" err":""}${e?" on":""}`,e&&(this.banner.appendChild(y(t?"close":"chat",15)),this.banner.appendChild(a("span",null,e)));}setEndVisible(e){this.endBtn.classList.toggle("hide",!e);}get currentView(){return this.view}showPrechat(e){let t=this.o.t,i=this.o.settings.prechat||{name:true,email:true,required:false};this.view="prechat",this.list=null,this.textarea=null,k(this.body);let n=ve("text",t.name,e.name||"","name"),r=ve("email",t.email,e.email||"","email"),o=this.o.topics||[],l=o.length?a("select",{"aria-label":t.topicLabel},a("option",{value:""},t.topicPlaceholder),...o.map(f=>a("option",{value:f.slug},f.name))):null,d=l?a("div",{class:"fld"},l,a("label",null,t.topicLabel),a("span",{class:"cv"},y("chevron",16))):null,c=()=>{let f=n.input.value.trim(),p=r.input.value.trim();if(i.required&&(i.name&&!f||i.email&&!p)){let h=i.name&&!f?n:r;h.wrap.classList.add("bad"),h.input.focus();return}if(p&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(p)){r.wrap.classList.add("bad"),r.input.focus();return}this.o.actions.submitPrechat(f,p,(l==null?void 0:l.value)||null);},u=a("form",{class:"fm",onsubmit:f=>{f.preventDefault(),c();}},a("h3",null,t.prechatTitle),a("p",null,this.o.settings.greeting||t.prechatHint),i.name?n.wrap:null,i.email?r.wrap:null,d,a("button",{class:"btn",type:"submit"},t.start),i.required?null:a("button",{class:"btn gh",type:"button",onclick:()=>this.o.actions.skipPrechat((l==null?void 0:l.value)||null)},t.skip));this.body.appendChild(u),S()||setTimeout(()=>(i.name?n.input:r.input).focus(),60);}showChat(){var t,i;if(this.view==="chat"&&this.list)return;let e=this.o.t;this.view="chat",k(this.body),this.list=a("div",{class:"ml"}),this.list.addEventListener("scroll",()=>this.syncJump(),{passive:true}),this.jumpBtn=a("button",{class:"jump",type:"button","aria-label":e.jump,onclick:()=>this.list&&z(this.list,true)},y("down",14),a("span",null,e.jump)),this.typingAvatar=a("div",{class:"av"},C((t=this.agent)==null?void 0:t.avatar,((i=this.agent)==null?void 0:i.name)||this.o.appName)),this.typingEl=a("div",{class:"tp","aria-live":"polite"},this.typingAvatar,a("div",{class:"dots"},a("i"),a("i"),a("i"))),this.notice=a("div",{class:"notice"}),this.body.appendChild(this.list),this.body.appendChild(this.jumpBtn),this.body.appendChild(this.typingEl),this.body.appendChild(this.notice),this.body.appendChild(this.buildComposer()),this.body.appendChild(a("div",{class:"drop"},y("image",26),a("span",null,e.dropHere)));}showRating(){let e=this.o.t;this.view="rating",this.list=null,this.textarea=null,k(this.body);let t=0,i=[],n=a("div",{class:"rl"}),r=()=>{i.forEach((c,u)=>c.classList.toggle("on",u<t)),n.textContent=t?e.rateScale[t-1]:"";},o=a("div",{class:"stars"});for(let c=1;c<=5;c++){let u=a("button",{type:"button","aria-label":String(c),onclick:()=>{t=c,r();}},y("star",32));i.push(u),o.appendChild(u);}let l=a("textarea",{placeholder:e.rateComment,rows:3}),d=a("form",{class:"fm",onsubmit:c=>{c.preventDefault(),this.o.actions.rate(t,l.value.trim());}},a("h3",{style:"text-align:center"},e.rateTitle),o,n,l,a("button",{class:"btn",type:"submit"},e.rateSend),a("button",{class:"btn gh",type:"button",onclick:()=>this.o.actions.rate(0,"")},e.skip));this.body.appendChild(d);}showThanks(e){let t=this.o.t;this.view="none",this.list=null,this.textarea=null,k(this.body);let i=a("div",{class:"ok"},a("div",{class:"ic"},y("done",30)),a("h3",null,t.rateThanksTitle),a("p",null,t.rateThanks));e!=null&&e.url&&(i.appendChild(a("p",{style:"margin-top:16px"},t.reviewIntro)),i.appendChild(a("a",{class:"btn",href:e.url,target:"_blank",rel:"noopener noreferrer"},e.label||t.reviewCta))),i.appendChild(a("button",{class:"btn gh",type:"button",onclick:()=>this.o.actions.newChat()},t.newChat)),this.body.appendChild(i);}render(e){var t,i;this.list&&(be(this.list,{...e,t:this.o.t,locale:this.o.locale,actions:this.o.actions,agentAvatar:((t=this.agent)==null?void 0:t.avatar)||A(this.o.settings.logo_url),brandName:((i=this.agent)==null?void 0:i.name)||this.o.appName,responseHint:this.online?this.o.t.replyFast:this.o.settings.offline_message||this.o.t.offlineMessage,quick:this.quickStarters(),onQuick:n=>this.o.actions.send(n,[],null)}),this.syncJump());}setTyping(e,t){this.typingEl&&(this.typingEl.classList.toggle("on",e),this.typingEl.setAttribute("aria-label",`${t} ${this.o.t.typing}`),e&&this.list&&O(this.list,120)&&z(this.list,true));}setNotice(e,t){this.notice&&(k(this.notice),this.notice.classList.toggle("on",!!e),e&&(this.notice.appendChild(document.createTextNode(e)),t&&this.notice.appendChild(a("button",{type:"button",onclick:t.fn},t.label))));}setReply(e){var i;if(this.replyTo=e,!this.replyBar||(k(this.replyBar),this.replyBar.classList.toggle("on",!!e),!e))return;let t=e.sender_type==="visitor"?this.o.t.you:e.sender_name||this.o.t.agent;this.replyBar.appendChild(y("reply",14)),this.replyBar.appendChild(a("span",{class:"rt"},`${this.o.t.replyingTo} ${t}: ${$(e,this.o.t)}`)),this.replyBar.appendChild(a("button",{type:"button","aria-label":this.o.t.cancel,onclick:()=>this.setReply(null)},y("close",14))),(i=this.textarea)==null||i.focus();}startEdit(e){!this.textarea||!this.replyBar||(this.editing=e,this.setReply(null),this.textarea.value=e.body||"",this.autosize(),this.syncSend(),this.textarea.focus(),k(this.replyBar),this.replyBar.classList.add("on"),this.replyBar.appendChild(a("span",{class:"rt"},`${this.o.t.edit}: ${$(e,this.o.t)}`)),this.replyBar.appendChild(a("button",{type:"button","aria-label":this.o.t.cancel,onclick:()=>this.cancelEdit()},y("close",14))));}buildComposer(){let e=this.o.t;this.replyBar=a("div",{class:"rq"}),this.chips=a("div",{class:"chips"}),this.textarea=a("textarea",{rows:1,placeholder:e.placeholder,"aria-label":e.placeholder,maxLength:this.maxChars,onkeydown:n=>{n.key==="Enter"&&!n.shiftKey&&!n.isComposing?(n.preventDefault(),this.submit()):n.key==="Escape"&&(this.editing?this.cancelEdit():this.replyTo?this.setReply(null):this.hideEmoji());},oninput:()=>{this.autosize(),this.syncSend(),this.notifyTyping();},onpaste:n=>{var o;let r=Array.from(((o=n.clipboardData)==null?void 0:o.files)||[]);r.length&&(n.preventDefault(),this.addFiles(r));}});let t=a("input",{type:"file",multiple:true,style:"display:none",accept:this.allowedMimes.join(","),onchange:()=>{this.addFiles(Array.from(t.files||[])),t.value="";}});return this.emojiBox=a("div",{class:"emj"},...ge.map(n=>a("button",{type:"button",onclick:()=>this.insertEmoji(n)},n))),this.sendBtn=a("button",{class:"cb sd",type:"button",title:e.send,"aria-label":e.send,disabled:true,onclick:()=>this.submit()},y("send",17)),this.counter=a("div",{class:"cnt"}),a("div",{class:"cp"},this.emojiBox,this.replyBar,this.chips,this.counter,a("div",{class:"cr"},a("button",{class:"cb",type:"button",title:e.attach,"aria-label":e.attach,onclick:()=>t.click()},y("clip",19)),this.textarea,a("button",{class:"cb",type:"button",title:e.emoji,"aria-label":e.emoji,onclick:n=>{n.stopPropagation(),this.toggleEmoji();}},y("smile",19)),this.sendBtn),t,a("div",{class:"pw"},a("a",{href:"https://signalbird.io",target:"_blank",rel:"noopener",title:e.poweredBy},a("span",{class:"pk"},W(13)),a("span",{class:"pn2"},"Signalbird"))))}submit(){if(!this.textarea)return;let e=this.textarea.value.trim();if(this.editing){let n=this.editing;this.cancelEdit(),e&&e!==n.body&&this.o.actions.saveEdit(n,e);return}if(!e&&this.files.length===0)return;if(this.textarea.value.length>this.maxChars){this.flash(R(this.o.t.tooLong,{max:this.maxChars}));return}let t=this.files,i=this.replyTo;this.files=[],this.renderChips(),this.setReply(null),this.hideEmoji(),this.textarea.value="",this.autosize(),this.syncSend(),this.stopTyping(),this.o.actions.send(e,t,i),S()||this.textarea.focus();}cancelEdit(){this.editing=null,this.textarea&&(this.textarea.value="",this.autosize(),this.syncSend()),this.replyBar&&(k(this.replyBar),this.replyBar.classList.remove("on"));}addFiles(e){let t=this.o.maxMb*1024*1024;for(let i of e){if(i.size>t){this.flash(R(this.o.t.fileTooLarge,{mb:this.o.maxMb}));continue}if(i.type&&!this.allowedMimes.includes(i.type)){this.flash(this.o.t.fileNotAllowed);continue}if(this.files.length>=5)break;this.files.push(i);}this.renderChips(),this.syncSend();}renderChips(){this.chips&&(k(this.chips),this.chips.classList.toggle("on",this.files.length>0),this.files.forEach((e,t)=>{this.chips.appendChild(a("div",{class:"chip"},e.type.startsWith("image/")?a("img",{src:URL.createObjectURL(e),alt:""}):y("file",16),a("span",null,e.name),a("button",{type:"button","aria-label":this.o.t.delete,onclick:()=>{this.files.splice(t,1),this.renderChips(),this.syncSend();}},y("close",12))));}));}syncSend(){if(!this.sendBtn||!this.textarea)return;let e=!this.textarea.value.trim()&&this.files.length===0;this.sendBtn.disabled=e||this.textarea.value.length>this.maxChars,this.syncCounter();}syncCounter(){if(!this.counter||!this.textarea)return;let e=this.maxChars-this.textarea.value.length,t=e<=Ye;this.counter.classList.toggle("on",t),this.counter.classList.toggle("full",e<=0),this.counter.textContent=t?String(e):"";}toggleEmoji(){if(!this.emojiBox)return;this.emojiBox.classList.toggle("on")&&document.addEventListener("click",()=>this.hideEmoji(),{once:true,capture:true});}hideEmoji(){var e;(e=this.emojiBox)==null||e.classList.remove("on");}insertEmoji(e){var n,r;if(!this.textarea)return;let t=this.textarea,i=(n=t.selectionStart)!=null?n:t.value.length;t.value=t.value.slice(0,i)+e+t.value.slice((r=t.selectionEnd)!=null?r:i),t.selectionStart=t.selectionEnd=i+e.length,this.autosize(),this.syncSend(),t.focus();}autosize(){let e=this.textarea;e&&(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,132)}px`);}notifyTyping(){this.wasTyping||(this.wasTyping=true,this.o.actions.typing(true)),this.typingTimer&&clearTimeout(this.typingTimer),this.typingTimer=setTimeout(()=>this.stopTyping(),2500);}stopTyping(){this.typingTimer&&clearTimeout(this.typingTimer),this.typingTimer=null,this.wasTyping&&(this.wasTyping=false,this.o.actions.typing(false));}syncJump(){!this.jumpBtn||!this.list||this.jumpBtn.classList.toggle("on",!O(this.list,160));}flash(e){this.setBanner(e,true),setTimeout(()=>this.setBanner(null),3200);}buildTeaser(){let e=this.o.t,t=this.o.settings;return a("div",{class:"teaser",role:"button",tabindex:0,onclick:()=>{this.hideTeaser(true),this.o.actions.open();}},a("div",{class:"tv"},this.brandAvatar()),a("div",{class:"tc"},a("div",{class:"tn"},this.o.appName||e.title),a("div",{class:"tb"},t.greeting||e.greeting)),a("button",{class:"tx",type:"button","aria-label":e.close,onclick:i=>{i.stopPropagation(),this.hideTeaser(true);}},y("close",13)))}buildToast(){return a("div",{class:"toast",role:"button",tabindex:0,onclick:()=>{this.hideToast(),this.o.actions.open();}},a("div",{class:"tv"}),a("div",{class:"tc"},a("div",{class:"tn"}),a("div",{class:"tb"})))}scheduleTeaser(){xe(this.key(me))||xe(this.key(fe))||this.o.settings.launcher_mode!=="manual"&&(this.teaserTimer=setTimeout(()=>{this.wrap.classList.contains("open")||this.wrap.classList.contains("hidden")||this.wrap.classList.contains("no-ln")||this.wrap.classList.contains("tst")||this.wrap.classList.add("tz");},qe));}hideTeaser(e){this.teaserTimer&&clearTimeout(this.teaserTimer),this.teaserTimer=null,this.wrap.classList.remove("tz"),e&&ye(this.key(me));}showToast(e){var o,l;let t=e.name||((o=this.agent)==null?void 0:o.name)||this.o.appName||this.o.t.agent,i=this.toast.querySelector(".tv"),n=this.toast.querySelector(".tn"),r=this.toast.querySelector(".tb");k(i),i.appendChild(C(e.avatar||((l=this.agent)==null?void 0:l.avatar),t)),n.textContent=t,r.textContent=e.body||this.o.t.newMessage,this.hideTeaser(false),this.wrap.classList.add("tst"),this.toastTimer&&clearTimeout(this.toastTimer),this.toastTimer=setTimeout(()=>this.hideToast(),Ge);}hideToast(){this.toastTimer&&clearTimeout(this.toastTimer),this.toastTimer=null,this.wrap.classList.remove("tst");}onLauncher(){this.hideTeaser(true),this.hideToast(),this.o.actions.open();}get allowedMimes(){let e=this.o.settings.attachment_mimes;return Array.isArray(e)&&e.length?e:Fe}get maxChars(){let e=Number(this.o.settings.max_message_chars);return Number.isFinite(e)&&e>0?e:Ue}quickStarters(){return (this.o.topics||[]).slice(0,4).map(e=>e.name).filter(Boolean)}bindViewport(){let e=D();e&&(e.addEventListener("resize",this.onViewport),this.onViewport());}onViewport(){let e=D();if(!e||!S())return;let t=Math.max(0,window.innerHeight-e.height-e.offsetTop);this.wrap.style.setProperty("--sb-kb",`${t}px`),this.wrap.classList.toggle("kb",t>40),t>40&&this.list&&requestAnimationFrame(()=>this.list&&z(this.list));}lockScroll(){if(this.locked||!S())return;this.locked=true,this.scrollLock=window.scrollY||0;let e=document.body.style;e.position="fixed",e.top=`-${this.scrollLock}px`,e.left="0",e.right="0",e.width="100%";}unlockScroll(){if(!this.locked)return;this.locked=false;let e=document.body.style;e.position="",e.top="",e.left="",e.right="",e.width="",window.scrollTo(0,this.scrollLock);}enableSwipeClose(){let e=0,t=0,i=false,n=()=>{i&&(i=false,this.wrap.classList.remove("dragging"),this.panel.style.transform="",t>110&&this.o.actions.close(),removeEventListener("pointermove",r),removeEventListener("pointerup",n),removeEventListener("pointercancel",n));},r=o=>{i&&(t=Math.max(0,o.clientY-e),this.panel.style.transform=`translateY(${t}px)`,this.panel.style.opacity=String(Math.max(.5,1-t/420)));};this.dragBar.addEventListener("pointerdown",o=>{S()&&(i=true,e=o.clientY,t=0,this.wrap.classList.add("dragging"),addEventListener("pointermove",r),addEventListener("pointerup",n),addEventListener("pointercancel",n));});}onKey(e){var t;if(e.key==="Escape"){if((t=this.emojiBox)!=null&&t.classList.contains("on")){this.hideEmoji();return}this.wrap.classList.contains("open")&&this.o.actions.close();}}enableDrop(){let e=0;this.body.addEventListener("dragenter",t=>{t.preventDefault(),e++,this.view==="chat"&&this.body.classList.add("dragover");}),this.body.addEventListener("dragover",t=>t.preventDefault()),this.body.addEventListener("dragleave",()=>{--e<=0&&(e=0,this.body.classList.remove("dragover"));}),this.body.addEventListener("drop",t=>{var i;t.preventDefault(),e=0,this.body.classList.remove("dragover"),this.view==="chat"&&((i=t.dataTransfer)!=null&&i.files)&&this.addFiles(Array.from(t.dataTransfer.files));});}clearTimers(){for(let e of [this.typingTimer,this.teaserTimer,this.toastTimer,this.attnTimer])e&&clearTimeout(e);}launcherMark(){let e=this.o.settings,t=A(e.logo_url);return e.launcher_icon==="logo"&&t?a("img",{class:"lg",src:t,alt:""}):e.launcher_icon==="chat"?y("chat",25):W(27)}brandAvatar(){let e=A(this.o.settings.logo_url);return e?a("img",{src:e,alt:""}):document.createTextNode(B(this.o.appName))}restoreGeometry(){let e=We();e&&(e.w&&(this.panel.style.width=`${e.w}px`),e.h&&(this.panel.style.height=`${e.h}px`),this.wrap.style.setProperty("--sb-dx",`${e.dx||0}px`),this.wrap.style.setProperty("--sb-dy",`${e.dy||0}px`));}saveGeometry(){Je({w:this.panel.offsetWidth,h:this.panel.offsetHeight,dx:parseFloat(this.wrap.style.getPropertyValue("--sb-dx"))||0,dy:parseFloat(this.wrap.style.getPropertyValue("--sb-dy"))||0});}enableMove(e){e.addEventListener("pointerdown",t=>{if(t.button!==0||S()||t.target.closest("button"))return;let i=t.clientX,n=t.clientY,r=parseFloat(this.wrap.style.getPropertyValue("--sb-dx"))||0,o=parseFloat(this.wrap.style.getPropertyValue("--sb-dy"))||0,l=this.wrap.classList.contains("left")?-1:1,d=false,c=f=>{let p=f.clientX-i,h=f.clientY-n;if(!d&&Math.abs(p)+Math.abs(h)<4)return;d=true,this.wrap.classList.add("moving");let m=Math.max(0,innerWidth-this.panel.offsetWidth-24),x=Math.max(0,innerHeight-this.panel.offsetHeight-24);this.wrap.style.setProperty("--sb-dx",`${V(r-p*l,0,m)}px`),this.wrap.style.setProperty("--sb-dy",`${V(o-h,0,x)}px`);},u=()=>{removeEventListener("pointermove",c),removeEventListener("pointerup",u),this.wrap.classList.remove("moving"),d&&this.saveGeometry();};addEventListener("pointermove",c),addEventListener("pointerup",u);});}enableResize(){this.grip.addEventListener("pointerdown",e=>{if(e.button!==0||S())return;e.preventDefault();let t=e.clientX,i=e.clientY,n=this.panel.offsetWidth,r=this.panel.offsetHeight,o=this.wrap.classList.contains("left")?-1:1;this.wrap.classList.add("sizing");let l=c=>{this.panel.style.width=`${V(n+(t-c.clientX)*o,340,innerWidth-40)}px`,this.panel.style.height=`${V(r+(i-c.clientY),400,innerHeight-40)}px`;},d=()=>{removeEventListener("pointermove",l),removeEventListener("pointerup",d),this.wrap.classList.remove("sizing"),this.saveGeometry();};addEventListener("pointermove",l),addEventListener("pointerup",d);});}};function ve(s,e,t,i){let n=a("input",{type:s,value:t,autocomplete:i,placeholder:" "});return t&&n.classList.add("has"),n.addEventListener("input",()=>{var r;n.classList.toggle("has",n.value.length>0),(r=n.parentElement)==null||r.classList.remove("bad");}),{wrap:a("div",{class:"fld"},n,a("label",null,e)),input:n}}var we="sb_geometry";function We(){try{let s=localStorage.getItem(we);if(!s)return null;let e=JSON.parse(s);return !e||e.w>innerWidth||e.h>innerHeight?null:e}catch(s){return null}}function Je(s){try{localStorage.setItem(we,JSON.stringify(s));}catch(e){}}function ye(s){try{localStorage.setItem(s,"1");}catch(e){}}function xe(s){try{return localStorage.getItem(s)==="1"}catch(e){return false}}function V(s,e,t){return Math.min(Math.max(s,e),t)}function S(){return innerWidth<=640}function D(){return typeof window!="undefined"&&window.visualViewport||null}function Xe(s){return s==="dark"?true:s!=="auto"||typeof matchMedia!="function"?false:matchMedia("(prefers-color-scheme: dark)").matches}function Ze(s){return s&&/^(#[0-9a-f]{3,8}|rgba?\([\d\s.,%]+\)|hsla?\([\d\s.,%]+\))$/i.test(s)?s:"#4f46e5"}var F=class{constructor(){this.original=null;this.timer=null;this.label="";}update(e,t){e>0&&document.hidden?(this.label=t(e),this.begin()):this.end();}begin(){if(this.timer)return;this.original=document.title;let e=false;this.timer=setInterval(()=>{if(!document.hidden)return this.end();e=!e,document.title=e?this.label:this.original||"";},1200);}end(){this.timer&&clearInterval(this.timer),this.timer=null,this.original!==null&&(document.title=this.original,this.original=null);}};var _=null;function Q(){try{let s=window.AudioContext||window.webkitAudioContext;if(!s)return;_||(_=new s),_.state==="suspended"&&_.resume();let e=_.currentTime,t=_.createGain();t.gain.setValueAtTime(1e-4,e),t.gain.exponentialRampToValueAtTime(.12,e+.02),t.gain.exponentialRampToValueAtTime(1e-4,e+.35),t.connect(_.destination);let i=_.createOscillator();i.type="sine",i.frequency.setValueAtTime(880,e),i.frequency.setValueAtTime(1175,e+.12),i.connect(t),i.start(e),i.stop(e+.36);}catch(s){}}var Qe="https://live.signalbird.io/api",T="/v1/sdk/chat/conversations",U=class{constructor(e){this.opts=e;this.title=new F;this.topic=null;this.ui=null;this.settings=null;this.appName="";this.started=false;this.destroyed=false;this.pendingSends=new Map;this.ratingMode=null;this.autoOpened=false;this.identity=null;this.lastTypingSent=0;this.pollCount=0;this.forceFull=false;this.socket=null;this.onVisibility=()=>{this.syncUnread(),!document.hidden&&this.store.isOpen&&this.store.conversation&&this.markRead();};this.baseUrl=(e.baseUrl||Qe).replace(/\/$/,""),this.store=new N(e.publicKey),this.api=new j(this.baseUrl,e.publicKey,e.chatKey,()=>this.store.secret,(...t)=>this.log(...t)),this.poller=new H(()=>this.tick()),this.identity=e.user&&(e.user.name||e.user.email||e.user.external_id)?e.user:null,this.locale=X(null,e.locale),this.t=Z(this.locale),this.ready=this.start().catch(t=>this.log("start failed",t));}log(...e){this.opts.debug&&console.debug("[signalbird]",...e);}async start(){var f;let e=await this.api.post("/v1/sdk/bootstrap",{page_url:location.href,locale:this.opts.locale});if(!e.ok||!e.data){this.log("bootstrap failed",e);return}let t=(f=e.data.channel)!=null?f:e.data.app;if(!t){this.log("bootstrap failed",e);return}if(this.destroyed)return;let{online:i,within_hours:n,visitor:r,conversation:o,topics:l,realtime:d}=e.data;if(!t.chat_enabled){this.log("chat disabled for app");return}let c=t.chat||{};this.settings=c,this.appName=t.name||"",this.locale=X(c.locale,this.opts.locale),this.t=Z(this.locale),this.store.visitor&&!r&&this.store.clearVisitor(),r&&this.store.setVisitor({id:r.id,name:r.name,email:r.email}),this.store.online=!!i,this.store.withinHours=n!==false,o&&this.store.setConversation(o);let u=Number(c.max_attachment_mb||t.max_attachment_mb||10);this.ui=new K({t:this.t,locale:this.locale,publicKey:this.opts.publicKey,settings:c,appName:this.appName,maxMb:u,topics:l||[],actions:{open:()=>this.open(),close:()=>this.close(),send:(p,h,m)=>{this.send(p,h,m);},typing:p=>{this.typing(p);},submitPrechat:(p,h,m)=>{this.submitPrechat(p,h,m);},skipPrechat:p=>{this.topic=p,this.enterChat();},rate:(p,h)=>{this.rate(p,h);},dismiss:()=>this.dismiss(),endChat:()=>this.endChat(),newChat:()=>this.newChat(),saveEdit:(p,h)=>{this.saveEdit(p,h);},reply:p=>{var h;return (h=this.ui)==null?void 0:h.setReply(p)},react:(p,h)=>{this.react(p,h);},edit:p=>{var h;return (h=this.ui)==null?void 0:h.startEdit(p)},remove:p=>{this.remove(p);},retry:p=>{this.retry(p);},openImage:p=>window.open(p,"_blank","noopener")}}),this.store.on("unread",()=>this.syncUnread()),this.store.on("messages",()=>this.render()),this.store.on("change",()=>this.render()),document.addEventListener("visibilitychange",this.onVisibility),this.ui.mount(),this.ui.setDismissed(this.store.dismissed),this.syncLauncher(),this.ui.setHeader(this.store.agent,this.store.online),this.applyBanner(),this.store.setUnread((r==null?void 0:r.unread)||(o==null?void 0:o.visitor_unread)||0),this.syncUnread(),this.started=true,this.poller.start(),d!=null&&d.enabled&&(this.socket=new I(d,(p,h)=>this.authorizeChannel(p,h),p=>this.onSocketEvent(p),p=>{this.log("socket",p?"connected":"disconnected"),this.poller.setLive(p),p&&this.poller.poke(0);},(...p)=>this.log(...p)),this.socket.connect(),this.subscribeVisitor()),this.opts.user&&this.identify(this.opts.user);}applyBanner(){!this.ui||!this.settings||this.ui.setBanner(this.store.withinHours?null:this.settings.offline_message||this.t.offlineMessage);}syncUnread(){var t;let e=this.store.isOpen&&!document.hidden?0:this.store.unread;(t=this.ui)==null||t.setUnread(this.store.unread),this.title.update(e,i=>R(this.t.unreadTitle,{n:i})),this.store.emit("public:unread",this.store.unread),this.syncLauncher();}syncLauncher(){var i;if(!this.ui)return;if(((i=this.settings)==null?void 0:i.launcher_mode)!=="manual"){this.ui.setLauncherHidden(false);return}let e=this.store.conversation,t=!!e&&e.status!=="closed";this.ui.setLauncherHidden(!(this.store.isOpen||t||this.store.unread>0));}dismiss(){var e;this.store.setDismissed(true),this.close(),(e=this.ui)==null||e.setDismissed(true);}open(){var e,t;this.store.dismissed&&(this.store.setDismissed(false),(e=this.ui)==null||e.setDismissed(false)),!(!this.ui||this.store.isOpen)&&(((t=this.store.conversation)==null?void 0:t.status)==="closed"&&(this.store.setConversation(null),this.ratingMode=null),this.store.isOpen=true,this.ui.setOpen(true),this.syncLauncher(),this.poller.setOpen(true),this.decideView(),this.store.emit("public:open"),this.store.conversation?this.loadConversation():this.store.setUnread(0),this.syncUnread());}close(){if(!this.ui||!this.store.isOpen)return;let e=this.store.conversation;if(e&&e.status==="resolved"&&!this.store.wasRated(e.id)&&this.ui.currentView==="chat"&&this.store.messages.some(t=>t.sender_type==="agent")){this.ratingMode="resolved",this.ui.setEndVisible(false),this.ui.showRating();return}this.store.isOpen=false,this.ui.setOpen(false),this.poller.setOpen(false),this.typing(false),this.store.emit("public:close"),this.syncUnread(),this.syncLauncher();}toggle(){this.store.isOpen?this.close():this.open();}isOpen(){return this.store.isOpen}on(e,t){this.store.on(`public:${e}`,t);}off(e,t){this.store.off(`public:${e}`,t);}async identify(e){var r;if(await this.ready,this.destroyed)return;this.identity={...this.identity||{},...e},((r=this.ui)==null?void 0:r.currentView)==="prechat"&&this.enterChat();let[t,...i]=(e.name||"").trim().split(/\s+/),n={external_id:e.external_id,email:e.email,phone:e.phone,first_name:t||void 0,last_name:i.join(" ")||void 0,attributes:e.attributes};e.external_id&&this.check(await this.api.post("/v1/sdk/identify",n)),await this.session({name:e.name,email:e.email,external_id:e.external_id});}async pushRegister(e){return await this.ready,this.api.post("/v1/sdk/devices",{provider:e.platform==="ios"?"apns":"fcm",locale:ke(),...e})}destroy(){var e,t;this.destroyed=true,(e=this.socket)==null||e.close(),this.socket=null,this.poller.stop(),this.title.end(),document.removeEventListener("visibilitychange",this.onVisibility),(t=this.ui)==null||t.unmount(),this.ui=null;}decideView(){var r,o;if(!this.ui||!this.settings)return;let e=this.settings.prechat,t=this.store.visitor;!!!((r=this.identity)!=null&&r.name||(o=this.identity)!=null&&o.email||t!=null&&t.name||t!=null&&t.email)&&!this.store.conversation&&e&&(e.name||e.email)?this.ui.showPrechat({}):this.enterChat();}enterChat(){var e;this.ui&&(this.ratingMode=null,this.ui.showChat(),this.ui.setEndVisible(((e=this.store.conversation)==null?void 0:e.status)==="open"),this.render());}render(){var t,i;if(!this.ui||this.ui.currentView!=="chat")return;let e=this.store.conversation;this.ui.render({messages:this.store.messages,greeting:((t=this.settings)==null?void 0:t.greeting)||this.t.greeting,agentName:((i=this.store.agent)==null?void 0:i.name)||this.t.agent,find:n=>this.store.find(n)}),this.ui.setEndVisible((e==null?void 0:e.status)==="open"),e&&e.status!=="open"?this.ui.setNotice(e.status==="resolved"?this.t.resolved:this.t.closed,{label:this.t.newChat,fn:()=>this.newChat()}):this.ui.setNotice(null);}async submitPrechat(e,t,i){var r;this.topic=i,await this.session({name:e||void 0,email:t||void 0})?this.enterChat():(r=this.ui)==null||r.setBanner(this.t.unavailable,true);}newChat(){this.ratingMode=null,this.store.setConversation(null),this.enterChat(),this.store.isOpen||this.open();}endChat(){!this.ui||!this.store.conversation||(this.ratingMode="end",this.ui.setEndVisible(false),this.ui.showRating());}async rate(e,t){var r;let i=this.store.conversation,n=this.ratingMode;if(this.ratingMode=null,!(!i||!this.ui)){if(e>0){let o=await this.api.post(`${T}/${i.id}/rate`,{rating:e,comment:t||void 0});this.check(o),this.store.markRated(i.id);}if(n==="end"){let o=await this.api.post(`${T}/${i.id}/close`);this.check(o),((r=this.store.conversation)==null?void 0:r.id)===i.id&&this.store.setConversation({...i,status:"closed"}),this.ui.showThanks(this.reviewFor(e));return}e===0&&this.store.markRated(i.id),this.enterChat(),this.close();}}reviewFor(e){var n,r,o,l;let t=(((n=this.settings)==null?void 0:n.review_url)||"").trim(),i=Number((o=(r=this.settings)==null?void 0:r.review_min_rating)!=null?o:3);return !t||!/^https?:\/\//i.test(t)?null:e>0&&e>=i?{url:t,label:((l=this.settings)==null?void 0:l.review_label)||null}:null}async session(e={}){var n;let t=this.identity?{name:this.identity.name,email:this.identity.email,external_id:this.identity.external_id}:{},i=await this.api.post("/v1/sdk/chat/session",{...t,...e,locale:ke(),page_url:location.href,user_agent:navigator.userAgent});if(i.ok&&((n=i.data)!=null&&n.visitor)){let r=i.data.visitor;return !r.secret&&!this.store.visitor?(this.log("session returned no secret"),false):(this.store.setVisitor(r),this.subscribeVisitor(),true)}return !i.ok&&i.code==="VISITOR_INVALID"&&this.store.visitor?(this.store.clearVisitor(),this.session(e)):(this.check(i),false)}subscribeVisitor(){var t;let e=(t=this.store.visitor)==null?void 0:t.id;this.socket&&e&&this.socket.subscribe(`visitor.${e}`);}async authorizeChannel(e,t){var n;let i=await this.api.post("/v1/sdk/chat/socket/auth",{socket_id:e,channel:t});return i.ok&&((n=i.data)!=null&&n.auth)?{auth:i.data.auth,at:i.data.at}:null}onSocketEvent(e){var t,i;if(e.name==="chat.typing"){e.data.who==="agent"&&(this.store.agentTyping=e.data.active===true,(i=this.ui)==null||i.setTyping(this.store.agentTyping,((t=this.store.agent)==null?void 0:t.name)||this.t.agent));return}e.data.updated===true&&(this.forceFull=true),this.poller.poke(0);}async loadConversation(){let e=this.store.conversation;if(!e)return;let t=await this.api.get(`${T}/${e.id}`,{limit:50});this.applyPayload(t,true)&&this.store.isOpen&&!document.hidden&&this.store.setUnread(0);}applyPayload(e,t){var n,r,o,l;if(!e.ok)return this.check(e),e.status===404&&this.store.setConversation(null),-1;let i=e.data;if(i.conversation){let d=(n=this.store.conversation)==null?void 0:n.status;this.store.conversation=i.conversation,d!==i.conversation.status&&this.store.emit("change");}return i.agent!==void 0&&(this.store.agent=i.agent||null),this.store.agentTyping=!!i.agent_typing,(r=this.ui)==null||r.setHeader(this.store.agent,this.store.online),(l=this.ui)==null||l.setTyping(this.store.agentTyping,((o=this.store.agent)==null?void 0:o.name)||this.t.agent),this.store.mergeMessages(i.messages||[],t)}async tick(){var d,c,u,f,p,h,m,x;if(!this.started||!this.store.visitor)return false;this.pollCount++;let e=this.store.conversation;if(this.store.isOpen&&e){let b=this.pollCount%5===0||this.forceFull;this.forceFull=false;let g=b?void 0:this.store.lastServerMessageId||void 0,L=await this.api.get(`${T}/${e.id}`,g?{after:g}:{limit:50}),w=this.applyPayload(L,!g);return w>0&&(document.hidden?(this.store.setUnread(this.store.unread+w),(d=this.settings)!=null&&d.sound&&Q()):this.markRead()),w>0}if(this.store.isOpen&&!e&&this.pollCount%10!==0)return false;let t=await this.api.get(T);if(!t.ok)return this.check(t),false;let i=t.data,n=Array.isArray(i)?i:(i==null?void 0:i.conversations)||(i==null?void 0:i.data)||[],r=n.find(b=>b.status==="open")||null,o=n.reduce((b,g)=>b+(g.visitor_unread||0),0),l=o>this.store.unread;return r&&r.id!==((c=this.store.conversation)==null?void 0:c.id)&&(this.store.setConversation(r),this.store.isOpen&&this.loadConversation()),(!this.store.isOpen||document.hidden)&&(this.store.setUnread(o),l&&((u=this.settings)!=null&&u.sound&&Q(),(x=this.ui)==null||x.attention({name:((f=r==null?void 0:r.agent)==null?void 0:f.name)||((p=this.store.agent)==null?void 0:p.name)||this.t.agent,avatar:((h=r==null?void 0:r.agent)==null?void 0:h.avatar)||((m=this.store.agent)==null?void 0:m.avatar)||null,body:(r==null?void 0:r.last_message_sender)==="agent"&&(r==null?void 0:r.last_message_preview)||null}),!this.autoOpened&&!document.hidden&&(this.autoOpened=true,this.open()))),l}async markRead(){let e=this.store.conversation,t=this.store.lastServerMessageId;!e||!t||(this.store.setUnread(0),await this.api.post(`${T}/${e.id}/read`,{last_message_id:t},true));}async send(e,t,i,n=le()){var l;let r={id:`local_${n}`,client_id:n,sender_type:"visitor",type:t.length?t[0].type.startsWith("image/")?"image":"file":"text",body:e||null,attachments:null,reply_to_id:(i==null?void 0:i.id)||null,created_at:new Date().toISOString(),_pending:true,_files:t};this.pendingSends.set(n,{text:e,files:t,replyTo:(i==null?void 0:i.id)||null}),this.store.upsertMessage(r);let o=()=>{let d=this.store.find(r.id);d&&this.store.upsertMessage({...d,_pending:false,_failed:true});};try{if(!this.store.visitor&&!await this.session())return o();let d=this.store.conversation,c=!d||d.status!=="open";if(c&&t.length===0){let h=await this.api.post(T,{body:e,page_url:location.href,client_id:n,...this.topic?{topic:this.topic}:{}});if(!h.ok)return this.sendFailed(h,o);this.store.setConversation(h.data.conversation),this.store.mergeMessages(h.data.messages||[]),this.reconcile(r,h.data.messages),this.pendingSends.delete(n),this.poller.poke(3e3);return}if(c){let h=await this.api.post(T,{page_url:location.href,...this.topic?{topic:this.topic}:{}});if(!h.ok)return this.sendFailed(h,o);this.store.setConversation(h.data.conversation),this.store.mergeMessages(h.data.messages||[]),d=h.data.conversation;}if(!d)return o();let u=[];for(let h of t){let m=await this.api.upload(`${T}/${d.id}/attachments`,h);if(!m.ok)return this.sendFailed(m,o);u.push(m.data);}let f=await this.api.post(`${T}/${d.id}/messages`,{body:e||void 0,attachments:u.length?u:void 0,reply_to_id:(i==null?void 0:i.id)||void 0,client_id:n});if(!f.ok)return this.sendFailed(f,o);let p=((l=f.data)==null?void 0:l.message)||f.data;this.reconcile(r,[p]),this.pendingSends.delete(n),this.poller.poke(3e3);}catch(d){this.log("send error",d),o();}}reconcile(e,t){let i=(t||[]).find(n=>n.client_id===e.client_id);i?this.store.mergeMessages([{...i,client_id:e.client_id}]):t&&t.length&&(this.store.removeMessage(e.id),this.store.mergeMessages(t));}sendFailed(e,t){var i;this.check(e),(e.code==="CHAT_UNAVAILABLE"||e.status===503)&&((i=this.ui)==null||i.setBanner(this.t.unavailable,true)),t();}async retry(e){let t=e.client_id?this.pendingSends.get(e.client_id):null;this.store.removeMessage(e.id),!(!t||!e.client_id)&&await this.send(t.text,t.files,this.store.find(t.replyTo)||null,e.client_id);}async typing(e){let t=this.store.conversation;if(!t||t.status!=="open"||!this.store.visitor)return;let i=Date.now();e&&i-this.lastTypingSent<4e3||(this.lastTypingSent=e?i:0,await this.api.post(`${T}/${t.id}/typing`,{is_typing:e},true));}async react(e,t){var c,u,f,p;let i=this.store.conversation;if(!i)return;let n={...e.reactions||{}},r=[...n[t]||[]],o=r.indexOf("visitor");o>=0?r.splice(o,1):r.push("visitor"),n[t]=r,this.store.upsertMessage({...e,reactions:n});let l=await this.api.post(`${T}/${i.id}/messages/${e.id}/reactions`,{emoji:t});if(!l.ok){this.check(l),this.store.upsertMessage({...e});return}let d=(p=(u=(c=l.data)==null?void 0:c.message)==null?void 0:u.reactions)!=null?p:(f=l.data)==null?void 0:f.reactions;d&&this.store.upsertMessage({...e,reactions:d});}async saveEdit(e,t){var o;let i=this.store.conversation;if(!i)return;this.store.upsertMessage({...e,body:t,edited_at:new Date().toISOString()});let n=await this.api.patch(`${T}/${i.id}/messages/${e.id}`,{body:t});if(!n.ok){this.check(n),this.store.upsertMessage({...e});return}let r=((o=n.data)==null?void 0:o.message)||n.data;r&&r.id&&this.store.upsertMessage(r);}async remove(e){let t=this.store.conversation;if(!t)return;this.store.upsertMessage({...e,deleted_at:new Date().toISOString()});let i=await this.api.delete(`${T}/${t.id}/messages/${e.id}`);i.ok||(this.check(i),this.store.upsertMessage({...e}));}check(e){e.ok||(e.code==="VISITOR_INVALID"||e.status===401&&this.store.visitor)&&(this.store.clearVisitor(),this.store.isOpen&&this.decideView());}};function ke(){var s;try{return ((s=navigator.languages)==null?void 0:s[0])||navigator.language||void 0}catch(e){return}}var et={tr:{loading:"Y\xFCkleniyor\u2026",failed:"Ekran y\xFCklenemedi.",expired:"Bu ba\u011Flant\u0131n\u0131n s\xFCresi doldu.",retry:"Yeniden dene"},en:{loading:"Loading\u2026",failed:"The screen could not be loaded.",expired:"This link has expired.",retry:"Try again"}};function tt(s){if(s==="light"||s==="dark")return s;if(typeof document!="undefined"){let e=document.documentElement;if(e.classList.contains("dark")||e.dataset.theme==="dark")return "dark";if(e.classList.contains("light")||e.dataset.theme==="light")return "light"}return typeof window!="undefined"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function it(s){if(typeof s=="string")return s||null;if(s&&typeof s=="object"){let e=s;if(typeof e.url=="string")return e.url;if(e.data&&typeof e.data.url=="string")return e.data.url}return null}function Te(s){var p,h;let e=et[(p=s.language)!=null?p:"tr"],t=new Map,i=null,n=null,r=null,o=(h=s.theme)!=null?h:"auto",l=false,d=(m,x)=>{var b;(b=t.get(m))==null||b.forEach(g=>{try{g(x);}catch(L){console.warn("[signalbird]",L);}});},c=()=>{r&&(window.removeEventListener("message",r),r=null),n=null,i&&(i.textContent="");},u=(m,x)=>{var L;if(!i)return;i.textContent="";let b=document.createElement("div");b.setAttribute("data-signalbird-status",""),b.style.cssText=`display:flex;align-items:center;justify-content:center;gap:12px;min-height:${(L=s.minHeight)!=null?L:220}px;font:13px/1.5 system-ui,-apple-system,sans-serif;color:#6b7280;text-align:center;padding:24px;`;let g=document.createElement("span");if(g.textContent=m,b.appendChild(g),x){let w=document.createElement("button");w.type="button",w.textContent=e.retry,w.style.cssText="border:1px solid currentColor;border-radius:8px;background:transparent;color:inherit;padding:4px 10px;font:inherit;cursor:pointer;",w.addEventListener("click",()=>{f();}),b.appendChild(w);}i.appendChild(b);},f=async()=>{var L;if(!i||l)return;c(),u(e.loading,false);let m=tt(o),x=null;try{s.url?(x=s.url,s={...s,url:void 0}):s.mint&&(x=it(await s.mint({module:s.module,theme:m,locale:s.locale})));}catch(w){d("error",w),u(w instanceof Error?w.message:e.failed,true);return}if(!x){d("error",new Error("EMBED_URL_MISSING")),u(e.expired,!!s.mint);return}let b=x;try{let w=new URL(x);w.searchParams.set("theme",m),s.locale&&w.searchParams.set("locale",s.locale),s.accent&&w.searchParams.set("accent",s.accent.replace(/^#/,"")),b=w.toString();}catch(w){}let g=document.createElement("iframe");g.src=b,g.title="Signalbird",g.style.cssText="width:100%;border:0;display:block;",g.style.height=`${typeof s.height=="number"?s.height:(L=s.minHeight)!=null?L:640}px`,g.setAttribute("allow","clipboard-write; fullscreen; autoplay"),g.setAttribute("sandbox","allow-same-origin allow-scripts allow-forms allow-popups allow-downloads"),g.setAttribute("referrerpolicy","strict-origin-when-cross-origin"),g.setAttribute("loading","lazy"),s.className&&(g.className=s.className),i.textContent="",i.appendChild(g),n=g,r=w=>{var ee,te;if(!n||w.source!==n.contentWindow)return;let M=w.data;if(!(!M||typeof M.type!="string")){if(M.type==="signalbird:ready"){d("ready",M.module);return}if(M.type==="signalbird:height"&&typeof M.px=="number"&&(d("height",M.px),((ee=s.height)!=null?ee:"auto")==="auto")){let Ee=Math.max(M.px,(te=s.minHeight)!=null?te:220);n.style.height=`${Ee}px`;}}},window.addEventListener("message",r);};return {async mount(m){let x=typeof m=="string"?document.querySelector(m):m;if(!(x instanceof HTMLElement))throw new Error("Signalbird: g\xF6mme kab\u0131 bulunamad\u0131 \u2014 "+String(m));i=x,l=false,await f();},refresh:()=>f(),async setTheme(m){o=m,await f();},destroy(){l=true,c(),t.clear(),i=null;},on(m,x){t.has(m)||t.set(m,new Set),t.get(m).add(x);},off(m,x){var b;(b=t.get(m))==null||b.delete(x);}}}var Pt="2.3.2",v=null,Y=[],P=null;function E(s,e){try{return s()}catch(t){try{console.warn("[signalbird]",t);}catch(i){}return e}}function Le(s){s.catch(()=>{});}function st(s){E(()=>{if(!s||!s.publicKey){console.warn("[signalbird] init: publicKey zorunlu");return}if(!(typeof document=="undefined"||typeof window=="undefined")){v&&v.destroy(),v=new U(s);for(let{event:e,fn:t}of Y)v.on(e,t);if(P){let e=P;P=null,Le(v.identify(e));}}},void 0);}function jt(s){E(()=>{if(s){if(!v){P={...P||{},...s};return}Le(v.identify(s));}},void 0);}var Nt={open(){E(()=>v==null?void 0:v.open(),void 0);},close(){E(()=>v==null?void 0:v.close(),void 0);},toggle(){E(()=>v==null?void 0:v.toggle(),void 0);},isOpen(){return E(()=>!!(v!=null&&v.isOpen()),false)},on(s,e){E(()=>{typeof e=="function"&&(Y.push({event:s,fn:e}),v==null||v.on(s,e));},void 0);},off(s,e){E(()=>{let t=Y.findIndex(i=>i.event===s&&i.fn===e);t>=0&&Y.splice(t,1),v==null||v.off(s,e);},void 0);}},Ht={register(s){return E(()=>v?v.pushRegister(s).catch(e=>({ok:!1,status:0,code:"NETWORK_ERROR",message:String(e)})):Promise.resolve({ok:!1,status:0,code:"NOT_INITIALIZED",message:"Signalbird.init \xE7a\u011Fr\u0131lmad\u0131"}),Promise.resolve({ok:false,status:0,code:"WIDGET_ERROR",message:"widget error"}))}},It=Te;function Bt(){E(()=>{v==null||v.destroy(),v=null;},void 0);}E(()=>{if(typeof document=="undefined")return;let s=document.currentScript||document.querySelector('script[data-key][src*="signalbird"]'),e=s==null?void 0:s.dataset;if(!e||!e.key)return;let t=()=>st({publicKey:e.key,chatKey:e.channel||void 0,baseUrl:e.baseUrl||void 0,locale:e.locale||void 0,debug:e.debug==="true"||e.debug==="1"});document.body?t():document.addEventListener("DOMContentLoaded",t,{once:!0});},void 0);
490
- exports.chat=Nt;exports.destroy=Bt;exports.embed=It;exports.identify=jt;exports.init=st;exports.push=Ht;exports.version=Pt;return exports;})({});
499
+ `;function r(s,e,...t){let i=document.createElement(s);if(e)for(let n in e){let a=e[n];a==null||a===false||(n==="class"?i.className=String(a):n==="style"?i.setAttribute("style",String(a)):n.startsWith("on")&&typeof a=="function"?i.addEventListener(n.slice(2).toLowerCase(),a):n==="html"?i.innerHTML=String(a):n in i&&n!=="list"&&n!=="form"?i[n]=a:i.setAttribute(n,String(a)));}return ze(i,t),i}function ze(s,e){for(let t of e)t==null||t===false||s.appendChild(typeof t=="object"?t:document.createTextNode(String(t)));}function T(s){for(;s.firstChild;)s.removeChild(s.firstChild);}function y(s,e=18){let t=document.createElementNS("http://www.w3.org/2000/svg","svg");return t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("width",String(e)),t.setAttribute("height",String(e)),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","2"),t.setAttribute("stroke-linecap","round"),t.setAttribute("stroke-linejoin","round"),t.innerHTML=Ae[s],t}function X(s=26){let e=document.createElementNS("http://www.w3.org/2000/svg","svg");return e.setAttribute("viewBox","10 2 28 38"),e.setAttribute("width",String(s)),e.setAttribute("height",String(s)),e.setAttribute("fill","none"),e.setAttribute("stroke","currentColor"),e.setAttribute("stroke-width","2"),e.setAttribute("stroke-linejoin","round"),e.setAttribute("aria-hidden","true"),e.innerHTML='<path d="M16 16 L30 16 L33 18 L24 33 L15 18 Z" fill="currentColor" fill-opacity=".18" stroke="none"/><path d="M23 4 L31 9 L23 14 L16 9 Z" fill="currentColor" fill-opacity=".28" stroke="none"/><path d="M30 16 L33 18 L36 27 L34 34 L41 32 L44 38 L31 37 L24 37 L17 35 L13 27 L15 18 L16 16"/><path d="M16 16 L16 9 L23 4 L31 9 L30 16"/><path d="M21.4 12.4 L23.2 18.6 L25 12.4 Z" fill="currentColor" fill-opacity=".35"/><circle cx="28.4" cy="11.4" r="1.6" fill="currentColor" stroke="none"/>',e}var Ae={chat:'<path d="M21 11.5a8.4 8.4 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.4 8.4 0 0 1-3.8-.9L3 21l1.9-5.7a8.4 8.4 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.4 8.4 0 0 1 3.8-.9h.5a8.5 8.5 0 0 1 8 8v.5z"/>',close:'<path d="M18 6 6 18M6 6l12 12"/>',send:'<path d="m22 2-7 20-4-9-9-4 20-7z"/><path d="M22 2 11 13"/>',clip:'<path d="m21.4 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"/>',file:'<path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><path d="M14 2v6h6"/>',check:'<path d="M20 6 9 17l-5-5"/>',link:'<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><path d="M15 3h6v6"/><path d="M10 14 21 3"/>',checks:'<path d="M18 6 7 17l-4-4"/><path d="m22 10-7.5 7.5L13 16"/>',reply:'<path d="M9 17H5a2 2 0 0 1-2-2V9"/><path d="m3 9 4-4"/><path d="m3 9 4 4"/><path d="M9 17h6a6 6 0 0 0 0-12h-2"/>',more:'<circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/>',star:'<path d="m12 2 3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/>',chevron:'<path d="m6 9 6 6 6-6"/>',smile:'<circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><path d="M9 9h.01M15 9h.01"/>',done:'<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><path d="m22 4-10 10-3-3"/>',down:'<path d="M12 5v14"/><path d="m19 12-7 7-7-7"/>',image:'<rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="9" cy="9" r="1.5"/><path d="m21 15-4.5-4.5L9 18"/>',heart:'<path d="M20.8 4.6a5.5 5.5 0 0 0-7.8 0L12 5.7l-1-1.1a5.5 5.5 0 0 0-7.8 7.8l1.1 1L12 21l7.7-7.6 1.1-1a5.5 5.5 0 0 0 0-7.8z"/>'};function $(s){return (s||"?").trim().split(/\s+/).slice(0,2).map(e=>e[0]||"").join("").toUpperCase()}function S(s,e){let t=P(s);return t?r("img",{src:t,alt:"",loading:"lazy"}):document.createTextNode($(e))}function P(s){return typeof s=="string"&&/^(https:\/\/|data:image\/)/i.test(s)?s:null}function oe(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(0)} KB`:`${(s/1024/1024).toFixed(1)} MB`}function le(){return typeof crypto!="undefined"&&"randomUUID"in crypto?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{let e=Math.random()*16|0;return (s==="x"?e:e&3|8).toString(16)})}var de=["\u{1F44D}","\u2764\uFE0F","\u{1F602}","\u{1F62E}","\u{1F622}","\u{1F64F}"],be=["\u{1F600}","\u{1F604}","\u{1F60A}","\u{1F642}","\u{1F609}","\u{1F60D}","\u{1F929}","\u{1F60E}","\u{1F914}","\u{1F610}","\u{1F615}","\u{1F641}","\u{1F622}","\u{1F62D}","\u{1F621}","\u{1F92F}","\u{1F44D}","\u{1F44E}","\u{1F44F}","\u{1F64F}","\u{1F4AA}","\u{1F525}","\u2705","\u2764\uFE0F"],Re=900*1e3,Pe=300*1e3;function fe(s,e){let t=V(s),i=s.childNodes.length===0,n=je(s);if(T(s),e.messages.length===0){s.appendChild(Ne(e));return}let a="";for(let o=0;o<e.messages.length;o++){let l=e.messages[o],d=Z(l.created_at),c=d===a&&e.messages[o-1]||null,g=e.messages[o+1]||null;d!==a&&(s.appendChild(r("div",{class:"day"},Ve(l.created_at,e))),a=d),s.appendChild(He(l,e,c,Ie(l,g)?g:null,!i&&!n.has(l.id)));}(t||i)&&R(s);}function V(s,e=60){return s.scrollHeight-s.scrollTop-s.clientHeight<e}function R(s,e=false){if(e&&typeof s.scrollTo=="function"){s.scrollTo({top:s.scrollHeight,behavior:"smooth"});return}s.scrollTop=s.scrollHeight;}function je(s){let e=new Set;return s.querySelectorAll("[data-id]").forEach(t=>{let i=t.dataset.id;i&&e.add(i);}),e}function Ne(s){let e=r("div",{class:"hero"});e.appendChild(r("div",{class:"hv"},r("span",null,S(s.agentAvatar,s.brandName||s.agentName)))),e.appendChild(r("h4",null,s.greeting||s.t.greeting)),s.responseHint&&e.appendChild(r("p",null,s.responseHint));let t=s.quick||[];if(t.length&&s.onQuick){let i=r("div",{class:"qk"});for(let n of t.slice(0,6))i.appendChild(r("button",{type:"button",onclick:()=>s.onQuick(n)},n));e.appendChild(i);}return e}function He(s,e,t,i,n){var k,w,M;let a=s.sender_type==="visitor"?"v":s.sender_type==="system"?"s":"a",o=!ce(t,s),l=!ce(s,i),d=r("div",{class:`row ${a}`+(o&&t?" gap":"")+(l?"":" mid")+(s._pending?" pend":"")+(s._failed?" fail":"")+(n?" new":""),"data-id":s.id});if(a==="s")return d.appendChild(r("div",{class:"bb"},s.body||"")),d;a==="a"&&d.appendChild(r("div",{class:`av${l?"":" gh"}`},S(e.agentAvatar,pe(s)||e.agentName)));let c=r("div",{class:"cl"}),g=r("div",{class:`bb${s.deleted_at?" del":""}`});if(s.deleted_at)return g.textContent=e.t.deleted,c.appendChild(g),d.appendChild(c),d;if(s.reply_to_id){let u=e.find(s.reply_to_id),b=u?u.sender_type==="visitor"?e.t.you:pe(u)||e.agentName:"";g.appendChild(r("span",{class:"q"},b?`${b}: `:"",u?D(u,e.t):"\u2026"));}if(s._files&&s._files.length){let u=r("div",{class:"imgs"});for(let b of s._files)b.type.startsWith("image/")?u.appendChild(r("img",{src:URL.createObjectURL(b),alt:b.name})):g.appendChild(he({name:b.name,url:"",mime:b.type,size:b.size},e));u.childNodes.length&&g.appendChild(u);}let f=s.attachments||[],p=f.filter(u=>ue(u.mime));if(p.length){let u=r("div",{class:"imgs"});for(let b of p)u.appendChild(r("img",{src:b.url,alt:b.name,loading:"lazy",onclick:()=>e.actions.openImage(b.url)}));g.appendChild(u);}for(let u of f.filter(b=>!ue(b.mime)))g.appendChild(he(u,e));let h=(a==="v"?null:(k=s.translation)==null?void 0:k.body)||s.body;h&&g.appendChild($e(h)),s._failed&&(g.appendChild(r("div",{style:"font-size:11px;margin-top:5px;font-weight:600"},e.t.failed)),g.addEventListener("click",()=>e.actions.retry(s))),c.appendChild(g);let m=a==="a"&&((M=(w=s.meta)==null?void 0:w.options)!=null&&M.length)?s.meta.options.slice(0,6):null;if(m){let u=!i||i.sender_type==="system",b=r("div",{class:`opts${u?"":" past"}`});for(let L of m)!L||!L.label||(L.url?b.appendChild(r("a",{href:L.url,target:"_top",rel:"noopener"},L.label,y("link",12))):b.appendChild(r("button",{type:"button",disabled:u?null:"disabled",onclick:()=>{var z;return (z=e.onQuick)==null?void 0:z.call(e,L.value||L.label)}},L.label)));b.childNodes.length&&c.appendChild(b);}let x=s.reactions&&Object.keys(s.reactions).length?s.reactions:null;if(x){let u=r("div",{class:"rx"});for(let b in x){let L=x[b]||[];if(!L.length)continue;let z=L.includes("visitor");u.appendChild(r("button",{class:z?"me":"",type:"button",onclick:()=>e.actions.react(s,b)},`${b} ${L.length}`));}u.childNodes.length&&c.appendChild(u);}if(l){let u=r("div",{class:"mt"},De(s.created_at,e.locale));if(s.edited_at&&u.appendChild(r("span",{class:"ed"},`\xB7 ${e.t.edited}`)),a==="v"&&!s._failed){let b=r("span",{class:`tk${s.read_at?" rd":""}`});b.appendChild(s._pending?y("check",12):s.read_at||s.delivered_at?y("checks",13):y("check",12)),s._pending&&(b.style.opacity=".4"),u.appendChild(b);}c.appendChild(u);}return d.appendChild(c),!s._pending&&!s._failed&&(d.appendChild(Be(s,e,d)),Oe(d)),d}function pe(s){var e,t;return ((e=s.agent)==null?void 0:e.name)||s.sender_name||((t=s.meta)==null?void 0:t.agent_name)||null}function ce(s,e){if(!s||!e||s.sender_type!==e.sender_type||s.sender_type==="system"||s.sender_id!==e.sender_id)return false;let t=Date.parse(e.created_at)-Date.parse(s.created_at);return t>=0&&t<Pe}function Ie(s,e){return !!e&&Z(s.created_at)===Z(e.created_at)}function Be(s,e,t){let i=r("div",{class:"ac"});for(let o of de.slice(0,3))i.appendChild(r("button",{type:"button",title:e.t.react,onclick:()=>e.actions.react(s,o)},o));i.appendChild(r("button",{type:"button",title:e.t.reply,onclick:()=>e.actions.reply(s)},y("reply",15)));let n=r("div",{class:"menu"});for(let o of de.slice(3))n.appendChild(r("button",{type:"button",onclick:()=>{n.classList.remove("show"),e.actions.react(s,o);}},`${o} ${e.t.react}`));return s.sender_type==="visitor"&&Date.now()-Date.parse(s.created_at)<Re&&(n.appendChild(r("button",{type:"button",onclick:()=>{n.classList.remove("show"),e.actions.edit(s);}},e.t.edit)),n.appendChild(r("button",{type:"button",class:"dg",onclick:()=>{n.classList.remove("show"),e.actions.remove(s);}},e.t.delete))),i.appendChild(r("button",{type:"button",title:e.t.react,onclick:o=>{o.stopPropagation(),n.classList.toggle("show"),n.style.top=`${t.offsetHeight+4}px`;}},y("more",15))),t.appendChild(n),document.addEventListener("click",()=>n.classList.remove("show"),{once:true,capture:true}),i}function Oe(s){let e=null,t=()=>{e=setTimeout(()=>{var a;s.classList.add("acts");try{(a=navigator.vibrate)==null||a.call(navigator,8);}catch(o){}let n=o=>{s.contains(o.target)||(s.classList.remove("acts"),document.removeEventListener("touchstart",n,true));};document.addEventListener("touchstart",n,true);},420);},i=()=>e&&clearTimeout(e);s.addEventListener("touchstart",t,{passive:true}),s.addEventListener("touchend",i),s.addEventListener("touchmove",i,{passive:true});}function he(s,e){return r("a",{class:"fr",href:s.url||void 0,target:"_blank",rel:"noopener"},y("file",18),r("span",{class:"fn"},s.name||e.t.attachment),r("span",{class:"fs"},oe(s.size||0)))}function $e(s){let e=document.createDocumentFragment(),t=/(https?:\/\/[^\s<]+)/g,i=0,n;for(;n=t.exec(s);){n.index>i&&e.appendChild(document.createTextNode(s.slice(i,n.index)));let a=n[1].replace(/[.,;:!?)]+$/,"");e.appendChild(r("a",{href:a,target:"_blank",rel:"noopener noreferrer nofollow"},a)),i=n.index+a.length;}return i<s.length&&e.appendChild(document.createTextNode(s.slice(i))),e}function D(s,e){var n,a;if(s.deleted_at)return e.deleted;let t=(s.sender_type==="visitor"?null:(n=s.translation)==null?void 0:n.body)||s.body;if(t)return t.length>90?t.slice(0,90)+"\u2026":t;let i=(a=s.attachments)==null?void 0:a[0];return i?`\u{1F4CE} ${i.name}`:"\u2026"}function ue(s){return !!s&&s.startsWith("image/")}function Z(s){let e=new Date(s);return `${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function Ve(s,e){let t=new Date(s),i=new Date,n=Math.round((ge(i)-ge(t))/864e5);if(n===0)return e.t.today;if(n===1)return e.t.yesterday;try{return new Intl.DateTimeFormat(e.locale,{day:"numeric",month:"long",year:t.getFullYear()!==i.getFullYear()?"numeric":void 0}).format(t)}catch(a){return t.toLocaleDateString()}}function ge(s){return new Date(s.getFullYear(),s.getMonth(),s.getDate()).getTime()}function De(s,e){let t=new Date(s);try{return new Intl.DateTimeFormat(e,{hour:"2-digit",minute:"2-digit"}).format(t)}catch(i){return t.toLocaleTimeString()}}var Ke={launcher:"Sohbet",title:"Sohbet",online:"\xC7evrimi\xE7i",offline:"Genelde birka\xE7 dakika i\xE7inde yan\u0131tl\u0131yoruz",greeting:"Merhaba! Size nas\u0131l yard\u0131mc\u0131 olabiliriz?",offlineMessage:"\u015Eu an \xE7evrimd\u0131\u015F\u0131y\u0131z. Mesaj\u0131n\u0131z\u0131 b\u0131rak\u0131n, en k\u0131sa s\xFCrede d\xF6nelim.",prechatTitle:"Ba\u015Flamadan \xF6nce",prechatHint:"Size geri d\xF6nebilmemiz i\xE7in bilgilerinizi b\u0131rak\u0131n.",topicLabel:"Konu",topicPlaceholder:"Konu se\xE7in (iste\u011Fe ba\u011Fl\u0131)",name:"Ad\u0131n\u0131z",email:"E-posta",start:"Sohbete ba\u015Fla",skip:"Atla",placeholder:"Mesaj\u0131n\u0131z\u0131 yaz\u0131n\u2026",send:"G\xF6nder",attach:"Dosya ekle",typing:"yaz\u0131yor\u2026",today:"Bug\xFCn",yesterday:"D\xFCn",reply:"Yan\u0131tla",react:"Tepki ver",edit:"D\xFCzenle",delete:"Sil",deleted:"Bu mesaj silindi",edited:"d\xFCzenlendi",save:"Kaydet",cancel:"Vazge\xE7",you:"Siz",agent:"Destek",system:"Sistem",endChat:"Sohbeti bitir",newChat:"Yeni sohbet",resolved:"Bu sohbet \xE7\xF6z\xFCld\xFC olarak i\u015Faretlendi.",closed:"Bu sohbet kapat\u0131ld\u0131.",rateTitle:"Bu sohbeti nas\u0131l buldunuz?",rateComment:"Eklemek istedi\u011Finiz bir \u015Fey var m\u0131? (iste\u011Fe ba\u011Fl\u0131)",rateSend:"G\xF6nder",rateThanks:"Geri bildiriminiz bize ula\u015Ft\u0131.",rateThanksTitle:"Te\u015Fekk\xFCrler!",rateScale:["Hi\xE7 iyi de\u011Fildi","Bekledi\u011Fim gibi olmad\u0131","\u0130dare eder","\u0130yiydi","Harikayd\u0131"],reviewIntro:"Yard\u0131mc\u0131 olabildiysek bizi yorumlar m\u0131s\u0131n\u0131z?",reviewCta:"De\u011Ferlendir",failed:"G\xF6nderilemedi \u2014 tekrar dene",fileTooLarge:"Dosya \xE7ok b\xFCy\xFCk (en fazla {mb} MB)",fileNotAllowed:"Bu dosya t\xFCr\xFCn\xFC y\xFCkleyemezsiniz",tooLong:"Mesaj en fazla {max} karakter olabilir",unavailable:"Sohbet \u015Fu an kullan\u0131lam\u0131yor. L\xFCtfen daha sonra tekrar deneyin.",close:"Kapat",dismiss:"Sohbet balonunu gizle",minimize:"K\xFC\xE7\xFClt",unreadTitle:"({n}) Yeni mesaj",dropHere:"Dosyay\u0131 buraya b\u0131rak\u0131n",replyingTo:"Yan\u0131tlan\u0131yor",attachment:"Ek",poweredBy:"Signalbird ile",resize:"Boyutland\u0131r",emoji:"Emoji ekle",jump:"En alta in",newMessage:"Yeni mesaj",replyFast:"\u015Eu an buraday\u0131z \u2014 genelde birka\xE7 dakika i\xE7inde yan\u0131tl\u0131yoruz."},Fe={launcher:"Chat",title:"Chat",online:"Online",offline:"We usually reply within a few minutes",greeting:"Hi there! How can we help you?",offlineMessage:"We're offline right now. Leave a message and we'll get back to you.",prechatTitle:"Before we start",prechatHint:"Leave your details so we can get back to you.",topicLabel:"Topic",topicPlaceholder:"Pick a topic (optional)",name:"Your name",email:"Email",start:"Start chat",skip:"Skip",placeholder:"Type your message\u2026",send:"Send",attach:"Attach file",typing:"is typing\u2026",today:"Today",yesterday:"Yesterday",reply:"Reply",react:"React",edit:"Edit",delete:"Delete",deleted:"This message was deleted",edited:"edited",save:"Save",cancel:"Cancel",you:"You",agent:"Support",system:"System",endChat:"End chat",newChat:"New chat",resolved:"This conversation was marked as resolved.",closed:"This conversation was closed.",rateTitle:"How was this conversation?",rateComment:"Anything to add? (optional)",rateSend:"Send",rateThanks:"Your feedback reached us.",rateThanksTitle:"Thank you!",rateScale:["Not good at all","Not what I expected","It was okay","Good","Excellent"],reviewIntro:"If we were helpful, would you leave us a review?",reviewCta:"Leave a review",failed:"Not sent \u2014 tap to retry",fileTooLarge:"File is too large (max {mb} MB)",fileNotAllowed:"That file type cannot be uploaded",tooLong:"A message may be at most {max} characters",unavailable:"Chat is unavailable right now. Please try again later.",close:"Close",dismiss:"Hide the chat bubble",minimize:"Minimize",unreadTitle:"({n}) New message",dropHere:"Drop the file here",replyingTo:"Replying to",attachment:"Attachment",poweredBy:"Powered by Signalbird",resize:"Resize",emoji:"Add emoji",jump:"Jump to latest",newMessage:"New message",replyFast:"We're here right now \u2014 we usually reply within a few minutes."};function Q(s,e){let t=n=>n&&n!=="auto"?n.toLowerCase().slice(0,2):null;return (t(e)||t(s)||t(typeof navigator!="undefined"?navigator.language:null)||"en")==="tr"?"tr":"en"}function ee(s){return s==="tr"?Ke:Fe}function j(s,e){return s.replace(/\{(\w+)\}/g,(t,i)=>{var n;return String((n=e[i])!=null?n:"")})}var Ue=["image/jpeg","image/png","image/gif","image/webp"],Ye=420,qe=60,Ge=11e3,We=9e3,me="sb_teaser",ve="sb_seen",U=class{constructor(e){this.o=e;this.list=null;this.typingEl=null;this.typingAvatar=null;this.jumpBtn=null;this.textarea=null;this.sendBtn=null;this.emojiBox=null;this.chips=null;this.replyBar=null;this.notice=null;this.files=[];this.counter=null;this.replyTo=null;this.editing=null;this.view="none";this.agent=null;this.online=false;this.typingTimer=null;this.teaserTimer=null;this.toastTimer=null;this.attnTimer=null;this.wasTyping=false;this.scrollLock=0;this.locked=false;var l;let t=e.t;this.host=r("div",{id:"signalbird-widget"}),this.root=this.host.attachShadow({mode:"open"}),this.root.appendChild(r("style",null,re));let i=e.settings.position==="left"?"left":"right",n=e.settings.layout==="sidebar"?" sidebar":"";if(this.wrap=r("div",{class:`sb ${i}${n}${Ze(e.settings.theme)?" dark":""}`,style:`--sb-c:${Qe(e.settings.color)}`}),e.settings.theme==="auto"&&typeof matchMedia=="function"){let d=matchMedia("(prefers-color-scheme: dark)");(l=d.addEventListener)==null||l.call(d,"change",c=>this.wrap.classList.toggle("dark",c.matches));}this.badge=r("span",{class:"badge"});let a=e.settings.launcher_text;this.launcher=r("button",{class:`ln${a?"":" icon-only"}`,type:"button","aria-label":a||t.launcher,onclick:()=>this.onLauncher()},r("span",{class:"lm"},this.launcherMark()),a?r("span",{class:"lt"},a):null,r("span",{class:"ln-on"}),r("span",{class:"ln-pulse"}),this.badge),this.dismissBtn=r("button",{class:"dm",type:"button",title:t.dismiss,"aria-label":t.dismiss,onclick:d=>{d.stopPropagation(),e.actions.dismiss();}},y("close",13)),this.teaser=this.buildTeaser(),this.toast=this.buildToast(),this.headerPhoto=r("div",{class:"ph"},this.brandAvatar()),this.headerDot=r("span",{class:"dot"}),this.headerName=r("div",{class:"hn"},e.appName||t.title),this.headerStatus=r("div",{class:"hs"},t.offline),this.endBtn=r("button",{class:"hb hide",type:"button",title:t.endChat,"aria-label":t.endChat,onclick:()=>e.actions.endChat()},y("done",19));let o=r("div",{class:"hd"},r("div",{class:"av"},this.headerPhoto,this.headerDot),r("div",{class:"hi"},this.headerName,this.headerStatus),r("div",{class:"ha"},this.endBtn,r("button",{class:"hb",type:"button",title:t.close,"aria-label":t.close,onclick:()=>e.actions.close()},y("close",20))));this.dragBar=r("div",{class:"drag","aria-hidden":"true"},r("i")),this.banner=r("div",{class:"bn"}),this.body=r("div",{class:"bd"}),this.grip=r("div",{class:"gp",title:t.resize,"aria-hidden":"true"}),this.panel=r("div",{class:"pn",role:"dialog","aria-modal":"false","aria-label":t.title},r("div",{class:"glow","aria-hidden":"true"}),this.dragBar,o,this.banner,this.body,this.grip),e.settings.layout!=="sidebar"&&(this.restoreGeometry(),this.enableMove(o),this.enableResize()),this.enableSwipeClose(),this.wrap.appendChild(this.launcher),this.wrap.appendChild(this.dismissBtn),this.wrap.appendChild(this.teaser),this.wrap.appendChild(this.toast),this.wrap.appendChild(this.panel),this.root.appendChild(this.wrap),this.enableDrop(),this.onKey=this.onKey.bind(this),this.onViewport=this.onViewport.bind(this);}key(e){return `${e}_${this.o.publicKey}`}mount(){this.host.isConnected||document.body.appendChild(this.host),document.addEventListener("keydown",this.onKey),this.scheduleTeaser();}unmount(){var e;this.clearTimers(),this.unlockScroll(),document.removeEventListener("keydown",this.onKey),(e=F())==null||e.removeEventListener("resize",this.onViewport),this.host.remove();}setDismissed(e){this.wrap.classList.toggle("hidden",e),e&&this.hideTeaser(false);}setLauncherHidden(e){this.wrap.classList.toggle("no-ln",e),e&&this.hideTeaser(false);}setOpen(e){var t;this.wrap.classList.toggle("open",e),e?(xe(this.key(ve)),this.hideTeaser(false),this.hideToast(),this.lockScroll(),this.bindViewport(),requestAnimationFrame(()=>{var i;this.list&&R(this.list),_()||(i=this.textarea)==null||i.focus();})):(this.unlockScroll(),(t=F())==null||t.removeEventListener("resize",this.onViewport),this.wrap.style.setProperty("--sb-kb","0px"),this.wrap.classList.remove("kb"),this.hideEmoji());}setUnread(e){this.badge.textContent=e>99?"99+":String(e),this.badge.classList.toggle("on",e>0),this.wrap.classList.toggle("pulse",e>0),e===0&&this.hideToast();}attention(e){let t=this.launcher;t.classList.remove("attn"),t.offsetWidth,t.classList.add("attn"),this.attnTimer&&clearTimeout(this.attnTimer),this.attnTimer=setTimeout(()=>t.classList.remove("attn"),2400),e&&(e.body||e.name)&&this.showToast(e);}setHeader(e,t){var a;let i=this.o.t;this.agent=e,this.online=(a=e==null?void 0:e.online)!=null?a:t;let n=(e==null?void 0:e.name)||this.o.appName||i.title;this.headerName.textContent=n,T(this.headerPhoto),this.headerPhoto.appendChild(e?S(e.avatar,n):this.brandAvatar()),this.headerDot.classList.toggle("on",this.online),this.headerStatus.textContent=this.online?i.online:i.offline,this.wrap.classList.toggle("agent-on",this.online),this.typingAvatar&&(T(this.typingAvatar),this.typingAvatar.appendChild(S(e==null?void 0:e.avatar,n)));}setBanner(e,t=false){T(this.banner),this.banner.className=`bn${t?" err":""}${e?" on":""}`,e&&(this.banner.appendChild(y(t?"close":"chat",15)),this.banner.appendChild(r("span",null,e)));}setEndVisible(e){this.endBtn.classList.toggle("hide",!e);}get currentView(){return this.view}showPrechat(e){let t=this.o.t,i=this.o.settings.prechat||{name:true,email:true,required:false};this.view="prechat",this.list=null,this.textarea=null,T(this.body);let n=ye("text",t.name,e.name||"","name"),a=ye("email",t.email,e.email||"","email"),o=this.o.topics||[],l=o.length?r("select",{"aria-label":t.topicLabel},r("option",{value:""},t.topicPlaceholder),...o.map(f=>r("option",{value:f.slug},f.name))):null,d=l?r("div",{class:"fld"},l,r("label",null,t.topicLabel),r("span",{class:"cv"},y("chevron",16))):null,c=()=>{let f=n.input.value.trim(),p=a.input.value.trim();if(i.required&&(i.name&&!f||i.email&&!p)){let h=i.name&&!f?n:a;h.wrap.classList.add("bad"),h.input.focus();return}if(p&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(p)){a.wrap.classList.add("bad"),a.input.focus();return}this.o.actions.submitPrechat(f,p,(l==null?void 0:l.value)||null);},g=r("form",{class:"fm",onsubmit:f=>{f.preventDefault(),c();}},r("h3",null,t.prechatTitle),r("p",null,this.o.settings.greeting||t.prechatHint),i.name?n.wrap:null,i.email?a.wrap:null,d,r("button",{class:"btn",type:"submit"},t.start),i.required?null:r("button",{class:"btn gh",type:"button",onclick:()=>this.o.actions.skipPrechat((l==null?void 0:l.value)||null)},t.skip));this.body.appendChild(g),_()||setTimeout(()=>(i.name?n.input:a.input).focus(),60);}showChat(){var t,i;if(this.view==="chat"&&this.list)return;let e=this.o.t;this.view="chat",T(this.body),this.list=r("div",{class:"ml"}),this.list.addEventListener("scroll",()=>this.syncJump(),{passive:true}),this.jumpBtn=r("button",{class:"jump",type:"button","aria-label":e.jump,onclick:()=>this.list&&R(this.list,true)},y("down",14),r("span",null,e.jump)),this.typingAvatar=r("div",{class:"av"},S((t=this.agent)==null?void 0:t.avatar,((i=this.agent)==null?void 0:i.name)||this.o.appName)),this.typingEl=r("div",{class:"tp","aria-live":"polite"},this.typingAvatar,r("div",{class:"dots"},r("i"),r("i"),r("i"))),this.notice=r("div",{class:"notice"}),this.body.appendChild(this.list),this.body.appendChild(this.jumpBtn),this.body.appendChild(this.typingEl),this.body.appendChild(this.notice),this.body.appendChild(this.buildComposer()),this.body.appendChild(r("div",{class:"drop"},y("image",26),r("span",null,e.dropHere)));}showRating(){let e=this.o.t;this.view="rating",this.list=null,this.textarea=null,T(this.body);let t=0,i=[],n=r("div",{class:"rl"}),a=()=>{i.forEach((c,g)=>c.classList.toggle("on",g<t)),n.textContent=t?e.rateScale[t-1]:"";},o=r("div",{class:"stars"});for(let c=1;c<=5;c++){let g=r("button",{type:"button","aria-label":String(c),onclick:()=>{t=c,a();}},y("star",32));i.push(g),o.appendChild(g);}let l=r("textarea",{placeholder:e.rateComment,rows:3}),d=r("form",{class:"fm",onsubmit:c=>{c.preventDefault(),this.o.actions.rate(t,l.value.trim());}},r("h3",{style:"text-align:center"},e.rateTitle),o,n,l,r("button",{class:"btn",type:"submit"},e.rateSend),r("button",{class:"btn gh",type:"button",onclick:()=>this.o.actions.rate(0,"")},e.skip));this.body.appendChild(d);}showThanks(e){let t=this.o.t;this.view="none",this.list=null,this.textarea=null,T(this.body);let i=r("div",{class:"ok"},r("div",{class:"ic"},y("done",30)),r("h3",null,t.rateThanksTitle),r("p",null,t.rateThanks));e!=null&&e.url&&(i.appendChild(r("p",{style:"margin-top:16px"},t.reviewIntro)),i.appendChild(r("a",{class:"btn",href:e.url,target:"_blank",rel:"noopener noreferrer"},e.label||t.reviewCta))),i.appendChild(r("button",{class:"btn gh",type:"button",onclick:()=>this.o.actions.newChat()},t.newChat)),this.body.appendChild(i);}render(e){var t,i;this.list&&(fe(this.list,{...e,t:this.o.t,locale:this.o.locale,actions:this.o.actions,agentAvatar:((t=this.agent)==null?void 0:t.avatar)||P(this.o.settings.logo_url),brandName:((i=this.agent)==null?void 0:i.name)||this.o.appName,responseHint:this.online?this.o.t.replyFast:this.o.settings.offline_message||this.o.t.offlineMessage,quick:this.quickStarters(),onQuick:n=>this.o.actions.send(n,[],null)}),this.syncJump());}setTyping(e,t){this.typingEl&&(this.typingEl.classList.toggle("on",e),this.typingEl.setAttribute("aria-label",`${t} ${this.o.t.typing}`),e&&this.list&&V(this.list,120)&&R(this.list,true));}setNotice(e,t){this.notice&&(T(this.notice),this.notice.classList.toggle("on",!!e),e&&(this.notice.appendChild(document.createTextNode(e)),t&&this.notice.appendChild(r("button",{type:"button",onclick:t.fn},t.label))));}setReply(e){var i,n;if(this.replyTo=e,!this.replyBar||(T(this.replyBar),this.replyBar.classList.toggle("on",!!e),!e))return;let t=e.sender_type==="visitor"?this.o.t.you:((i=e.agent)==null?void 0:i.name)||e.sender_name||this.o.t.agent;this.replyBar.appendChild(y("reply",14)),this.replyBar.appendChild(r("span",{class:"rt"},`${this.o.t.replyingTo} ${t}: ${D(e,this.o.t)}`)),this.replyBar.appendChild(r("button",{type:"button","aria-label":this.o.t.cancel,onclick:()=>this.setReply(null)},y("close",14))),(n=this.textarea)==null||n.focus();}startEdit(e){!this.textarea||!this.replyBar||(this.editing=e,this.setReply(null),this.textarea.value=e.body||"",this.autosize(),this.syncSend(),this.textarea.focus(),T(this.replyBar),this.replyBar.classList.add("on"),this.replyBar.appendChild(r("span",{class:"rt"},`${this.o.t.edit}: ${D(e,this.o.t)}`)),this.replyBar.appendChild(r("button",{type:"button","aria-label":this.o.t.cancel,onclick:()=>this.cancelEdit()},y("close",14))));}buildComposer(){let e=this.o.t;this.replyBar=r("div",{class:"rq"}),this.chips=r("div",{class:"chips"}),this.textarea=r("textarea",{rows:1,placeholder:e.placeholder,"aria-label":e.placeholder,maxLength:this.maxChars,onkeydown:n=>{n.key==="Enter"&&!n.shiftKey&&!n.isComposing?(n.preventDefault(),this.submit()):n.key==="Escape"&&(this.editing?this.cancelEdit():this.replyTo?this.setReply(null):this.hideEmoji());},oninput:()=>{this.autosize(),this.syncSend(),this.notifyTyping();},onpaste:n=>{var o;let a=Array.from(((o=n.clipboardData)==null?void 0:o.files)||[]);a.length&&(n.preventDefault(),this.addFiles(a));}});let t=r("input",{type:"file",multiple:true,style:"display:none",accept:this.allowedMimes.join(","),onchange:()=>{this.addFiles(Array.from(t.files||[])),t.value="";}});return this.emojiBox=r("div",{class:"emj"},...be.map(n=>r("button",{type:"button",onclick:()=>this.insertEmoji(n)},n))),this.sendBtn=r("button",{class:"cb sd",type:"button",title:e.send,"aria-label":e.send,disabled:true,onclick:()=>this.submit()},y("send",17)),this.counter=r("div",{class:"cnt"}),r("div",{class:"cp"},this.emojiBox,this.replyBar,this.chips,this.counter,r("div",{class:"cr"},r("button",{class:"cb",type:"button",title:e.attach,"aria-label":e.attach,onclick:()=>t.click()},y("clip",19)),this.textarea,r("button",{class:"cb",type:"button",title:e.emoji,"aria-label":e.emoji,onclick:n=>{n.stopPropagation(),this.toggleEmoji();}},y("smile",19)),this.sendBtn),t,r("div",{class:"pw"},r("a",{href:"https://signalbird.io",target:"_blank",rel:"noopener",title:e.poweredBy},r("span",{class:"pk"},X(13)),r("span",{class:"pn2"},"Signalbird"))))}submit(){if(!this.textarea)return;let e=this.textarea.value.trim();if(this.editing){let n=this.editing;this.cancelEdit(),e&&e!==n.body&&this.o.actions.saveEdit(n,e);return}if(!e&&this.files.length===0)return;if(this.textarea.value.length>this.maxChars){this.flash(j(this.o.t.tooLong,{max:this.maxChars}));return}let t=this.files,i=this.replyTo;this.files=[],this.renderChips(),this.setReply(null),this.hideEmoji(),this.textarea.value="",this.autosize(),this.syncSend(),this.stopTyping(),this.o.actions.send(e,t,i),_()||this.textarea.focus();}cancelEdit(){this.editing=null,this.textarea&&(this.textarea.value="",this.autosize(),this.syncSend()),this.replyBar&&(T(this.replyBar),this.replyBar.classList.remove("on"));}addFiles(e){let t=this.o.maxMb*1024*1024;for(let i of e){if(i.size>t){this.flash(j(this.o.t.fileTooLarge,{mb:this.o.maxMb}));continue}if(i.type&&!this.allowedMimes.includes(i.type)){this.flash(this.o.t.fileNotAllowed);continue}if(this.files.length>=5)break;this.files.push(i);}this.renderChips(),this.syncSend();}renderChips(){this.chips&&(T(this.chips),this.chips.classList.toggle("on",this.files.length>0),this.files.forEach((e,t)=>{this.chips.appendChild(r("div",{class:"chip"},e.type.startsWith("image/")?r("img",{src:URL.createObjectURL(e),alt:""}):y("file",16),r("span",null,e.name),r("button",{type:"button","aria-label":this.o.t.delete,onclick:()=>{this.files.splice(t,1),this.renderChips(),this.syncSend();}},y("close",12))));}));}syncSend(){if(!this.sendBtn||!this.textarea)return;let e=!this.textarea.value.trim()&&this.files.length===0;this.sendBtn.disabled=e||this.textarea.value.length>this.maxChars,this.syncCounter();}syncCounter(){if(!this.counter||!this.textarea)return;let e=this.maxChars-this.textarea.value.length,t=e<=qe;this.counter.classList.toggle("on",t),this.counter.classList.toggle("full",e<=0),this.counter.textContent=t?String(e):"";}toggleEmoji(){if(!this.emojiBox)return;this.emojiBox.classList.toggle("on")&&document.addEventListener("click",()=>this.hideEmoji(),{once:true,capture:true});}hideEmoji(){var e;(e=this.emojiBox)==null||e.classList.remove("on");}insertEmoji(e){var n,a;if(!this.textarea)return;let t=this.textarea,i=(n=t.selectionStart)!=null?n:t.value.length;t.value=t.value.slice(0,i)+e+t.value.slice((a=t.selectionEnd)!=null?a:i),t.selectionStart=t.selectionEnd=i+e.length,this.autosize(),this.syncSend(),t.focus();}autosize(){let e=this.textarea;e&&(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,132)}px`);}notifyTyping(){this.wasTyping||(this.wasTyping=true,this.o.actions.typing(true)),this.typingTimer&&clearTimeout(this.typingTimer),this.typingTimer=setTimeout(()=>this.stopTyping(),2500);}stopTyping(){this.typingTimer&&clearTimeout(this.typingTimer),this.typingTimer=null,this.wasTyping&&(this.wasTyping=false,this.o.actions.typing(false));}syncJump(){!this.jumpBtn||!this.list||this.jumpBtn.classList.toggle("on",!V(this.list,160));}flash(e){this.setBanner(e,true),setTimeout(()=>this.setBanner(null),3200);}buildTeaser(){let e=this.o.t,t=this.o.settings;return r("div",{class:"teaser",role:"button",tabindex:0,onclick:()=>{this.hideTeaser(true),this.o.actions.open();}},r("div",{class:"tv"},this.brandAvatar()),r("div",{class:"tc"},r("div",{class:"tn"},this.o.appName||e.title),r("div",{class:"tb"},t.greeting||e.greeting)),r("button",{class:"tx",type:"button","aria-label":e.close,onclick:i=>{i.stopPropagation(),this.hideTeaser(true);}},y("close",13)))}buildToast(){return r("div",{class:"toast",role:"button",tabindex:0,onclick:()=>{this.hideToast(),this.o.actions.open();}},r("div",{class:"tv"}),r("div",{class:"tc"},r("div",{class:"tn"}),r("div",{class:"tb"})))}scheduleTeaser(){we(this.key(me))||we(this.key(ve))||this.o.settings.launcher_mode!=="manual"&&(this.teaserTimer=setTimeout(()=>{this.wrap.classList.contains("open")||this.wrap.classList.contains("hidden")||this.wrap.classList.contains("no-ln")||this.wrap.classList.contains("tst")||this.wrap.classList.add("tz");},Ge));}hideTeaser(e){this.teaserTimer&&clearTimeout(this.teaserTimer),this.teaserTimer=null,this.wrap.classList.remove("tz"),e&&xe(this.key(me));}showToast(e){var o,l;let t=e.name||((o=this.agent)==null?void 0:o.name)||this.o.appName||this.o.t.agent,i=this.toast.querySelector(".tv"),n=this.toast.querySelector(".tn"),a=this.toast.querySelector(".tb");T(i),i.appendChild(S(e.avatar||((l=this.agent)==null?void 0:l.avatar),t)),n.textContent=t,a.textContent=e.body||this.o.t.newMessage,this.hideTeaser(false),this.wrap.classList.add("tst"),this.toastTimer&&clearTimeout(this.toastTimer),this.toastTimer=setTimeout(()=>this.hideToast(),We);}hideToast(){this.toastTimer&&clearTimeout(this.toastTimer),this.toastTimer=null,this.wrap.classList.remove("tst");}onLauncher(){this.hideTeaser(true),this.hideToast(),this.o.actions.open();}get allowedMimes(){let e=this.o.settings.attachment_mimes;return Array.isArray(e)&&e.length?e:Ue}get maxChars(){let e=Number(this.o.settings.max_message_chars);return Number.isFinite(e)&&e>0?e:Ye}quickStarters(){return (this.o.topics||[]).slice(0,4).map(e=>e.name).filter(Boolean)}bindViewport(){let e=F();e&&(e.addEventListener("resize",this.onViewport),this.onViewport());}onViewport(){let e=F();if(!e||!_())return;let t=Math.max(0,window.innerHeight-e.height-e.offsetTop);this.wrap.style.setProperty("--sb-kb",`${t}px`),this.wrap.classList.toggle("kb",t>40),t>40&&this.list&&requestAnimationFrame(()=>this.list&&R(this.list));}lockScroll(){if(this.locked||!_())return;this.locked=true,this.scrollLock=window.scrollY||0;let e=document.body.style;e.position="fixed",e.top=`-${this.scrollLock}px`,e.left="0",e.right="0",e.width="100%";}unlockScroll(){if(!this.locked)return;this.locked=false;let e=document.body.style;e.position="",e.top="",e.left="",e.right="",e.width="",window.scrollTo(0,this.scrollLock);}enableSwipeClose(){let e=0,t=0,i=false,n=()=>{i&&(i=false,this.wrap.classList.remove("dragging"),this.panel.style.transform="",t>110&&this.o.actions.close(),removeEventListener("pointermove",a),removeEventListener("pointerup",n),removeEventListener("pointercancel",n));},a=o=>{i&&(t=Math.max(0,o.clientY-e),this.panel.style.transform=`translateY(${t}px)`,this.panel.style.opacity=String(Math.max(.5,1-t/420)));};this.dragBar.addEventListener("pointerdown",o=>{_()&&(i=true,e=o.clientY,t=0,this.wrap.classList.add("dragging"),addEventListener("pointermove",a),addEventListener("pointerup",n),addEventListener("pointercancel",n));});}onKey(e){var t;if(e.key==="Escape"){if((t=this.emojiBox)!=null&&t.classList.contains("on")){this.hideEmoji();return}this.wrap.classList.contains("open")&&this.o.actions.close();}}enableDrop(){let e=0;this.body.addEventListener("dragenter",t=>{t.preventDefault(),e++,this.view==="chat"&&this.body.classList.add("dragover");}),this.body.addEventListener("dragover",t=>t.preventDefault()),this.body.addEventListener("dragleave",()=>{--e<=0&&(e=0,this.body.classList.remove("dragover"));}),this.body.addEventListener("drop",t=>{var i;t.preventDefault(),e=0,this.body.classList.remove("dragover"),this.view==="chat"&&((i=t.dataTransfer)!=null&&i.files)&&this.addFiles(Array.from(t.dataTransfer.files));});}clearTimers(){for(let e of [this.typingTimer,this.teaserTimer,this.toastTimer,this.attnTimer])e&&clearTimeout(e);}launcherMark(){let e=this.o.settings,t=P(e.logo_url);return e.launcher_icon==="logo"&&t?r("img",{class:"lg",src:t,alt:""}):e.launcher_icon==="chat"?y("chat",25):X(27)}brandAvatar(){let e=P(this.o.settings.logo_url);return e?r("img",{src:e,alt:""}):document.createTextNode($(this.o.appName))}restoreGeometry(){let e=Je();e&&(e.w&&(this.panel.style.width=`${e.w}px`),e.h&&(this.panel.style.height=`${e.h}px`),this.wrap.style.setProperty("--sb-dx",`${e.dx||0}px`),this.wrap.style.setProperty("--sb-dy",`${e.dy||0}px`));}saveGeometry(){Xe({w:this.panel.offsetWidth,h:this.panel.offsetHeight,dx:parseFloat(this.wrap.style.getPropertyValue("--sb-dx"))||0,dy:parseFloat(this.wrap.style.getPropertyValue("--sb-dy"))||0});}enableMove(e){e.addEventListener("pointerdown",t=>{if(t.button!==0||_()||t.target.closest("button"))return;let i=t.clientX,n=t.clientY,a=parseFloat(this.wrap.style.getPropertyValue("--sb-dx"))||0,o=parseFloat(this.wrap.style.getPropertyValue("--sb-dy"))||0,l=this.wrap.classList.contains("left")?-1:1,d=false,c=f=>{let p=f.clientX-i,h=f.clientY-n;if(!d&&Math.abs(p)+Math.abs(h)<4)return;d=true,this.wrap.classList.add("moving");let m=Math.max(0,innerWidth-this.panel.offsetWidth-24),x=Math.max(0,innerHeight-this.panel.offsetHeight-24);this.wrap.style.setProperty("--sb-dx",`${K(a-p*l,0,m)}px`),this.wrap.style.setProperty("--sb-dy",`${K(o-h,0,x)}px`);},g=()=>{removeEventListener("pointermove",c),removeEventListener("pointerup",g),this.wrap.classList.remove("moving"),d&&this.saveGeometry();};addEventListener("pointermove",c),addEventListener("pointerup",g);});}enableResize(){this.grip.addEventListener("pointerdown",e=>{if(e.button!==0||_())return;e.preventDefault();let t=e.clientX,i=e.clientY,n=this.panel.offsetWidth,a=this.panel.offsetHeight,o=this.wrap.classList.contains("left")?-1:1;this.wrap.classList.add("sizing");let l=c=>{this.panel.style.width=`${K(n+(t-c.clientX)*o,340,innerWidth-40)}px`,this.panel.style.height=`${K(a+(i-c.clientY),400,innerHeight-40)}px`;},d=()=>{removeEventListener("pointermove",l),removeEventListener("pointerup",d),this.wrap.classList.remove("sizing"),this.saveGeometry();};addEventListener("pointermove",l),addEventListener("pointerup",d);});}};function ye(s,e,t,i){let n=r("input",{type:s,value:t,autocomplete:i,placeholder:" "});return t&&n.classList.add("has"),n.addEventListener("input",()=>{var a;n.classList.toggle("has",n.value.length>0),(a=n.parentElement)==null||a.classList.remove("bad");}),{wrap:r("div",{class:"fld"},n,r("label",null,e)),input:n}}var ke="sb_geometry";function Je(){try{let s=localStorage.getItem(ke);if(!s)return null;let e=JSON.parse(s);return !e||e.w>innerWidth||e.h>innerHeight?null:e}catch(s){return null}}function Xe(s){try{localStorage.setItem(ke,JSON.stringify(s));}catch(e){}}function xe(s){try{localStorage.setItem(s,"1");}catch(e){}}function we(s){try{return localStorage.getItem(s)==="1"}catch(e){return false}}function K(s,e,t){return Math.min(Math.max(s,e),t)}function _(){return innerWidth<=640}function F(){return typeof window!="undefined"&&window.visualViewport||null}function Ze(s){return s==="dark"?true:s!=="auto"||typeof matchMedia!="function"?false:matchMedia("(prefers-color-scheme: dark)").matches}function Qe(s){return s&&/^(#[0-9a-f]{3,8}|rgba?\([\d\s.,%]+\)|hsla?\([\d\s.,%]+\))$/i.test(s)?s:"#4f46e5"}var Y=class{constructor(){this.original=null;this.timer=null;this.label="";}update(e,t){e>0&&document.hidden?(this.label=t(e),this.begin()):this.end();}begin(){if(this.timer)return;this.original=document.title;let e=false;this.timer=setInterval(()=>{if(!document.hidden)return this.end();e=!e,document.title=e?this.label:this.original||"";},1200);}end(){this.timer&&clearInterval(this.timer),this.timer=null,this.original!==null&&(document.title=this.original,this.original=null);}};var A=null;function te(){try{let s=window.AudioContext||window.webkitAudioContext;if(!s)return;A||(A=new s),A.state==="suspended"&&A.resume();let e=A.currentTime,t=A.createGain();t.gain.setValueAtTime(1e-4,e),t.gain.exponentialRampToValueAtTime(.12,e+.02),t.gain.exponentialRampToValueAtTime(1e-4,e+.35),t.connect(A.destination);let i=A.createOscillator();i.type="sine",i.frequency.setValueAtTime(880,e),i.frequency.setValueAtTime(1175,e+.12),i.connect(t),i.start(e),i.stop(e+.36);}catch(s){}}var et="https://live.signalbird.io/api",E="/v1/sdk/chat/conversations",q=class{constructor(e){this.opts=e;this.title=new Y;this.topic=null;this.ui=null;this.settings=null;this.appName="";this.started=false;this.destroyed=false;this.pendingSends=new Map;this.ratingMode=null;this.autoOpened=false;this.identity=null;this.lastTypingSent=0;this.pollCount=0;this.forceFull=false;this.socket=null;this.onVisibility=()=>{this.syncUnread(),!document.hidden&&this.store.isOpen&&this.store.conversation&&this.markRead();};this.baseUrl=(e.baseUrl||et).replace(/\/$/,""),this.store=new I(e.publicKey),this.api=new H(this.baseUrl,e.publicKey,e.chatKey,()=>this.store.secret,(...t)=>this.log(...t)),this.poller=new B(()=>this.tick()),this.identity=e.user&&(e.user.name||e.user.email||e.user.external_id)?e.user:null,this.locale=Q(null,e.locale),this.t=ee(this.locale),this.ready=this.start().catch(t=>this.log("start failed",t));}log(...e){this.opts.debug&&console.debug("[signalbird]",...e);}async start(){var f;let e=await this.api.post("/v1/sdk/bootstrap",{page_url:location.href,locale:this.opts.locale});if(!e.ok||!e.data){this.log("bootstrap failed",e);return}let t=(f=e.data.channel)!=null?f:e.data.app;if(!t){this.log("bootstrap failed",e);return}if(this.destroyed)return;let{online:i,within_hours:n,visitor:a,conversation:o,topics:l,realtime:d}=e.data;if(!t.chat_enabled){this.log("chat disabled for app");return}let c=t.chat||{};this.settings=c,this.appName=t.name||"",this.locale=Q(c.locale,this.opts.locale),this.t=ee(this.locale),this.store.visitor&&!a&&this.store.clearVisitor(),a&&this.store.setVisitor({id:a.id,name:a.name,email:a.email}),this.store.online=!!i,this.store.withinHours=n!==false,o&&this.store.setConversation(o);let g=Number(c.max_attachment_mb||t.max_attachment_mb||10);this.ui=new U({t:this.t,locale:this.locale,publicKey:this.opts.publicKey,settings:c,appName:this.appName,maxMb:g,topics:l||[],actions:{open:()=>this.open(),close:()=>this.close(),send:(p,h,m)=>{this.send(p,h,m);},typing:p=>{this.typing(p);},submitPrechat:(p,h,m)=>{this.submitPrechat(p,h,m);},skipPrechat:p=>{this.topic=p,this.enterChat();},rate:(p,h)=>{this.rate(p,h);},dismiss:()=>this.dismiss(),endChat:()=>this.endChat(),newChat:()=>this.newChat(),saveEdit:(p,h)=>{this.saveEdit(p,h);},reply:p=>{var h;return (h=this.ui)==null?void 0:h.setReply(p)},react:(p,h)=>{this.react(p,h);},edit:p=>{var h;return (h=this.ui)==null?void 0:h.startEdit(p)},remove:p=>{this.remove(p);},retry:p=>{this.retry(p);},openImage:p=>window.open(p,"_blank","noopener")}}),this.store.on("unread",()=>this.syncUnread()),this.store.on("messages",()=>this.render()),this.store.on("change",()=>this.render()),document.addEventListener("visibilitychange",this.onVisibility),this.ui.mount(),this.ui.setDismissed(this.store.dismissed),this.syncLauncher(),this.ui.setHeader(this.store.agent,this.store.online),this.applyBanner(),this.store.setUnread((a==null?void 0:a.unread)||(o==null?void 0:o.visitor_unread)||0),this.syncUnread(),this.started=true,this.poller.start(),d!=null&&d.enabled&&(this.socket=new O(d,(p,h)=>this.authorizeChannel(p,h),p=>this.onSocketEvent(p),p=>{this.log("socket",p?"connected":"disconnected"),this.poller.setLive(p),p&&this.poller.poke(0);},(...p)=>this.log(...p)),this.socket.connect(),this.subscribeVisitor()),this.opts.user&&this.identify(this.opts.user);}applyBanner(){!this.ui||!this.settings||this.ui.setBanner(this.store.withinHours?null:this.settings.offline_message||this.t.offlineMessage);}syncUnread(){var t;let e=this.store.isOpen&&!document.hidden?0:this.store.unread;(t=this.ui)==null||t.setUnread(this.store.unread),this.title.update(e,i=>j(this.t.unreadTitle,{n:i})),this.store.emit("public:unread",this.store.unread),this.syncLauncher();}syncLauncher(){var i;if(!this.ui)return;if(((i=this.settings)==null?void 0:i.launcher_mode)!=="manual"){this.ui.setLauncherHidden(false);return}let e=this.store.conversation,t=!!e&&e.status!=="closed";this.ui.setLauncherHidden(!(this.store.isOpen||t||this.store.unread>0));}dismiss(){var e;this.store.setDismissed(true),this.close(),(e=this.ui)==null||e.setDismissed(true);}open(){var e,t;this.store.dismissed&&(this.store.setDismissed(false),(e=this.ui)==null||e.setDismissed(false)),!(!this.ui||this.store.isOpen)&&(((t=this.store.conversation)==null?void 0:t.status)==="closed"&&(this.store.setConversation(null),this.ratingMode=null),this.store.isOpen=true,this.ui.setOpen(true),this.syncLauncher(),this.poller.setOpen(true),this.decideView(),this.store.emit("public:open"),this.store.conversation?this.loadConversation():this.store.setUnread(0),this.syncUnread());}close(){if(!this.ui||!this.store.isOpen)return;let e=this.store.conversation;if(e&&e.status==="resolved"&&!this.store.wasRated(e.id)&&this.ui.currentView==="chat"&&this.store.messages.some(t=>t.sender_type==="agent"||t.sender_type==="bot")){this.ratingMode="resolved",this.ui.setEndVisible(false),this.ui.showRating();return}this.store.isOpen=false,this.ui.setOpen(false),this.poller.setOpen(false),this.typing(false),this.store.emit("public:close"),this.syncUnread(),this.syncLauncher();}toggle(){this.store.isOpen?this.close():this.open();}isOpen(){return this.store.isOpen}on(e,t){this.store.on(`public:${e}`,t);}off(e,t){this.store.off(`public:${e}`,t);}async identify(e){var a;if(await this.ready,this.destroyed)return;this.identity={...this.identity||{},...e},((a=this.ui)==null?void 0:a.currentView)==="prechat"&&this.enterChat();let[t,...i]=(e.name||"").trim().split(/\s+/),n={external_id:e.external_id,email:e.email,phone:e.phone,first_name:t||void 0,last_name:i.join(" ")||void 0,attributes:e.attributes};e.external_id&&this.check(await this.api.post("/v1/sdk/identify",n)),await this.session({name:e.name,email:e.email,external_id:e.external_id});}async pushRegister(e){return await this.ready,this.api.post("/v1/sdk/devices",{provider:e.platform==="ios"?"apns":"fcm",locale:Te(),...e})}destroy(){var e,t;this.destroyed=true,(e=this.socket)==null||e.close(),this.socket=null,this.poller.stop(),this.title.end(),document.removeEventListener("visibilitychange",this.onVisibility),(t=this.ui)==null||t.unmount(),this.ui=null;}decideView(){var a,o;if(!this.ui||!this.settings)return;let e=this.settings.prechat,t=this.store.visitor;!!!((a=this.identity)!=null&&a.name||(o=this.identity)!=null&&o.email||t!=null&&t.name||t!=null&&t.email)&&!this.store.conversation&&e&&(e.name||e.email)?this.ui.showPrechat({}):this.enterChat();}enterChat(){var e;this.ui&&(this.ratingMode=null,this.ui.showChat(),this.ui.setEndVisible(((e=this.store.conversation)==null?void 0:e.status)==="open"),this.render());}render(){var t,i;if(!this.ui||this.ui.currentView!=="chat")return;let e=this.store.conversation;this.ui.render({messages:this.store.messages,greeting:((t=this.settings)==null?void 0:t.greeting)||this.t.greeting,agentName:((i=this.store.agent)==null?void 0:i.name)||this.t.agent,find:n=>this.store.find(n)}),this.ui.setEndVisible((e==null?void 0:e.status)==="open"),e&&e.status!=="open"?this.ui.setNotice(e.status==="resolved"?this.t.resolved:this.t.closed,{label:this.t.newChat,fn:()=>this.newChat()}):this.ui.setNotice(null);}async submitPrechat(e,t,i){var a;this.topic=i,await this.session({name:e||void 0,email:t||void 0})?this.enterChat():(a=this.ui)==null||a.setBanner(this.t.unavailable,true);}newChat(){this.ratingMode=null,this.store.setConversation(null),this.enterChat(),this.store.isOpen||this.open();}endChat(){!this.ui||!this.store.conversation||(this.ratingMode="end",this.ui.setEndVisible(false),this.ui.showRating());}async rate(e,t){var a;let i=this.store.conversation,n=this.ratingMode;if(this.ratingMode=null,!(!i||!this.ui)){if(e>0){let o=await this.api.post(`${E}/${i.id}/rate`,{rating:e,comment:t||void 0});this.check(o),this.store.markRated(i.id);}if(n==="end"){let o=await this.api.post(`${E}/${i.id}/close`);this.check(o),((a=this.store.conversation)==null?void 0:a.id)===i.id&&this.store.setConversation({...i,status:"closed"}),this.ui.showThanks(this.reviewFor(e));return}e===0&&this.store.markRated(i.id),this.enterChat(),this.close();}}reviewFor(e){var n,a,o,l;let t=(((n=this.settings)==null?void 0:n.review_url)||"").trim(),i=Number((o=(a=this.settings)==null?void 0:a.review_min_rating)!=null?o:3);return !t||!/^https?:\/\//i.test(t)?null:e>0&&e>=i?{url:t,label:((l=this.settings)==null?void 0:l.review_label)||null}:null}async session(e={}){var n;let t=this.identity?{name:this.identity.name,email:this.identity.email,external_id:this.identity.external_id}:{},i=await this.api.post("/v1/sdk/chat/session",{...t,...e,locale:Te(),page_url:location.href,user_agent:navigator.userAgent});if(i.ok&&((n=i.data)!=null&&n.visitor)){let a=i.data.visitor;return !a.secret&&!this.store.visitor?(this.log("session returned no secret"),false):(this.store.setVisitor(a),this.subscribeVisitor(),true)}return !i.ok&&i.code==="VISITOR_INVALID"&&this.store.visitor?(this.store.clearVisitor(),this.session(e)):(this.check(i),false)}subscribeVisitor(){var t;let e=(t=this.store.visitor)==null?void 0:t.id;this.socket&&e&&this.socket.subscribe(`visitor.${e}`);}async authorizeChannel(e,t){var n;let i=await this.api.post("/v1/sdk/chat/socket/auth",{socket_id:e,channel:t});return i.ok&&((n=i.data)!=null&&n.auth)?{auth:i.data.auth,at:i.data.at}:null}onSocketEvent(e){var t,i;if(e.name==="chat.typing"){e.data.who==="agent"&&(this.store.agentTyping=e.data.active===true,(i=this.ui)==null||i.setTyping(this.store.agentTyping,((t=this.store.agent)==null?void 0:t.name)||this.t.agent));return}e.data.updated===true&&(this.forceFull=true),this.poller.poke(0);}async loadConversation(){let e=this.store.conversation;if(!e)return;let t=await this.api.get(`${E}/${e.id}`,{limit:50});this.applyPayload(t,true)&&this.store.isOpen&&!document.hidden&&this.store.setUnread(0);}applyPayload(e,t){var n,a,o,l;if(!e.ok)return this.check(e),e.status===404&&this.store.setConversation(null),-1;let i=e.data;if(i.conversation){let d=(n=this.store.conversation)==null?void 0:n.status;this.store.conversation=i.conversation,d!==i.conversation.status&&this.store.emit("change");}return i.agent!==void 0&&(this.store.agent=i.agent||null),this.store.agentTyping=!!i.agent_typing,(a=this.ui)==null||a.setHeader(this.store.agent,this.store.online),(l=this.ui)==null||l.setTyping(this.store.agentTyping,((o=this.store.agent)==null?void 0:o.name)||this.t.agent),this.store.mergeMessages(i.messages||[],t)}async tick(){var d,c,g,f,p,h,m,x;if(!this.started||!this.store.visitor)return false;this.pollCount++;let e=this.store.conversation;if(this.store.isOpen&&e){let k=this.pollCount%5===0||this.forceFull;this.forceFull=false;let w=k?void 0:this.store.lastServerMessageId||void 0,M=await this.api.get(`${E}/${e.id}`,w?{after:w}:{limit:50}),u=this.applyPayload(M,!w);return u>0&&(document.hidden?(this.store.setUnread(this.store.unread+u),(d=this.settings)!=null&&d.sound&&te()):this.markRead()),u>0}if(this.store.isOpen&&!e&&this.pollCount%10!==0)return false;let t=await this.api.get(E);if(!t.ok)return this.check(t),false;let i=t.data,n=Array.isArray(i)?i:(i==null?void 0:i.conversations)||(i==null?void 0:i.data)||[],a=n.find(k=>k.status==="open")||null,o=n.reduce((k,w)=>k+(w.visitor_unread||0),0),l=o>this.store.unread;return a&&a.id!==((c=this.store.conversation)==null?void 0:c.id)&&(this.store.setConversation(a),this.store.isOpen&&this.loadConversation()),(!this.store.isOpen||document.hidden)&&(this.store.setUnread(o),l&&((g=this.settings)!=null&&g.sound&&te(),(x=this.ui)==null||x.attention({name:((f=a==null?void 0:a.agent)==null?void 0:f.name)||((p=this.store.agent)==null?void 0:p.name)||this.t.agent,avatar:((h=a==null?void 0:a.agent)==null?void 0:h.avatar)||((m=this.store.agent)==null?void 0:m.avatar)||null,body:(a==null?void 0:a.last_message_sender)==="agent"&&(a==null?void 0:a.last_message_preview)||null}),!this.autoOpened&&!document.hidden&&(this.autoOpened=true,this.open()))),l}async markRead(){let e=this.store.conversation,t=this.store.lastServerMessageId;!e||!t||(this.store.setUnread(0),await this.api.post(`${E}/${e.id}/read`,{last_message_id:t},true));}async send(e,t,i,n=le()){var l;let a={id:`local_${n}`,client_id:n,sender_type:"visitor",type:t.length?t[0].type.startsWith("image/")?"image":"file":"text",body:e||null,attachments:null,reply_to_id:(i==null?void 0:i.id)||null,created_at:new Date().toISOString(),_pending:true,_files:t};this.pendingSends.set(n,{text:e,files:t,replyTo:(i==null?void 0:i.id)||null}),this.store.upsertMessage(a);let o=()=>{let d=this.store.find(a.id);d&&this.store.upsertMessage({...d,_pending:false,_failed:true});};try{if(!this.store.visitor&&!await this.session())return o();let d=this.store.conversation,c=!d||d.status!=="open";if(c&&t.length===0){let h=await this.api.post(E,{body:e,page_url:location.href,client_id:n,...this.topic?{topic:this.topic}:{}});if(!h.ok)return this.sendFailed(h,o);this.store.setConversation(h.data.conversation),this.store.mergeMessages(h.data.messages||[]),this.reconcile(a,h.data.messages),this.pendingSends.delete(n),this.poller.poke(3e3);return}if(c){let h=await this.api.post(E,{page_url:location.href,...this.topic?{topic:this.topic}:{}});if(!h.ok)return this.sendFailed(h,o);this.store.setConversation(h.data.conversation),this.store.mergeMessages(h.data.messages||[]),d=h.data.conversation;}if(!d)return o();let g=[];for(let h of t){let m=await this.api.upload(`${E}/${d.id}/attachments`,h);if(!m.ok)return this.sendFailed(m,o);g.push(m.data);}let f=await this.api.post(`${E}/${d.id}/messages`,{body:e||void 0,attachments:g.length?g:void 0,reply_to_id:(i==null?void 0:i.id)||void 0,client_id:n});if(!f.ok)return this.sendFailed(f,o);let p=((l=f.data)==null?void 0:l.message)||f.data;this.reconcile(a,[p]),this.pendingSends.delete(n),this.poller.poke(3e3);}catch(d){this.log("send error",d),o();}}reconcile(e,t){let i=(t||[]).find(n=>n.client_id===e.client_id);i?this.store.mergeMessages([{...i,client_id:e.client_id}]):t&&t.length&&(this.store.removeMessage(e.id),this.store.mergeMessages(t));}sendFailed(e,t){var i;this.check(e),(e.code==="CHAT_UNAVAILABLE"||e.status===503)&&((i=this.ui)==null||i.setBanner(this.t.unavailable,true)),t();}async retry(e){let t=e.client_id?this.pendingSends.get(e.client_id):null;this.store.removeMessage(e.id),!(!t||!e.client_id)&&await this.send(t.text,t.files,this.store.find(t.replyTo)||null,e.client_id);}async typing(e){let t=this.store.conversation;if(!t||t.status!=="open"||!this.store.visitor)return;let i=Date.now();e&&i-this.lastTypingSent<4e3||(this.lastTypingSent=e?i:0,await this.api.post(`${E}/${t.id}/typing`,{is_typing:e},true));}async react(e,t){var c,g,f,p;let i=this.store.conversation;if(!i)return;let n={...e.reactions||{}},a=[...n[t]||[]],o=a.indexOf("visitor");o>=0?a.splice(o,1):a.push("visitor"),n[t]=a,this.store.upsertMessage({...e,reactions:n});let l=await this.api.post(`${E}/${i.id}/messages/${e.id}/reactions`,{emoji:t});if(!l.ok){this.check(l),this.store.upsertMessage({...e});return}let d=(p=(g=(c=l.data)==null?void 0:c.message)==null?void 0:g.reactions)!=null?p:(f=l.data)==null?void 0:f.reactions;d&&this.store.upsertMessage({...e,reactions:d});}async saveEdit(e,t){var o;let i=this.store.conversation;if(!i)return;this.store.upsertMessage({...e,body:t,edited_at:new Date().toISOString()});let n=await this.api.patch(`${E}/${i.id}/messages/${e.id}`,{body:t});if(!n.ok){this.check(n),this.store.upsertMessage({...e});return}let a=((o=n.data)==null?void 0:o.message)||n.data;a&&a.id&&this.store.upsertMessage(a);}async remove(e){let t=this.store.conversation;if(!t)return;this.store.upsertMessage({...e,deleted_at:new Date().toISOString()});let i=await this.api.delete(`${E}/${t.id}/messages/${e.id}`);i.ok||(this.check(i),this.store.upsertMessage({...e}));}check(e){e.ok||(e.code==="VISITOR_INVALID"||e.status===401&&this.store.visitor)&&(this.store.clearVisitor(),this.store.isOpen&&this.decideView());}};function Te(){var s;try{return ((s=navigator.languages)==null?void 0:s[0])||navigator.language||void 0}catch(e){return}}var tt={tr:{loading:"Y\xFCkleniyor\u2026",failed:"Ekran y\xFCklenemedi.",expired:"Bu ba\u011Flant\u0131n\u0131n s\xFCresi doldu.",retry:"Yeniden dene"},en:{loading:"Loading\u2026",failed:"The screen could not be loaded.",expired:"This link has expired.",retry:"Try again"}};function it(s){if(s==="light"||s==="dark")return s;if(typeof document!="undefined"){let e=document.documentElement;if(e.classList.contains("dark")||e.dataset.theme==="dark")return "dark";if(e.classList.contains("light")||e.dataset.theme==="light")return "light"}return typeof window!="undefined"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function st(s){if(typeof s=="string")return s||null;if(s&&typeof s=="object"){let e=s;if(typeof e.url=="string")return e.url;if(e.data&&typeof e.data.url=="string")return e.data.url}return null}function Le(s){var p,h;let e=tt[(p=s.language)!=null?p:"tr"],t=new Map,i=null,n=null,a=null,o=(h=s.theme)!=null?h:"auto",l=false,d=(m,x)=>{var k;(k=t.get(m))==null||k.forEach(w=>{try{w(x);}catch(M){console.warn("[signalbird]",M);}});},c=()=>{a&&(window.removeEventListener("message",a),a=null),n=null,i&&(i.textContent="");},g=(m,x)=>{var M;if(!i)return;i.textContent="";let k=document.createElement("div");k.setAttribute("data-signalbird-status",""),k.style.cssText=`display:flex;align-items:center;justify-content:center;gap:12px;min-height:${(M=s.minHeight)!=null?M:220}px;font:13px/1.5 system-ui,-apple-system,sans-serif;color:#6b7280;text-align:center;padding:24px;`;let w=document.createElement("span");if(w.textContent=m,k.appendChild(w),x){let u=document.createElement("button");u.type="button",u.textContent=e.retry,u.style.cssText="border:1px solid currentColor;border-radius:8px;background:transparent;color:inherit;padding:4px 10px;font:inherit;cursor:pointer;",u.addEventListener("click",()=>{f();}),k.appendChild(u);}i.appendChild(k);},f=async()=>{var M;if(!i||l)return;c(),g(e.loading,false);let m=it(o),x=null;try{s.url?(x=s.url,s={...s,url:void 0}):s.mint&&(x=st(await s.mint({module:s.module,theme:m,locale:s.locale})));}catch(u){d("error",u),g(u instanceof Error?u.message:e.failed,true);return}if(!x){d("error",new Error("EMBED_URL_MISSING")),g(e.expired,!!s.mint);return}let k=x;try{let u=new URL(x);u.searchParams.set("theme",m),s.locale&&u.searchParams.set("locale",s.locale),s.accent&&u.searchParams.set("accent",s.accent.replace(/^#/,"")),k=u.toString();}catch(u){}let w=document.createElement("iframe");w.src=k,w.title="Signalbird",w.style.cssText="width:100%;border:0;display:block;",w.style.height=`${typeof s.height=="number"?s.height:(M=s.minHeight)!=null?M:640}px`,w.setAttribute("allow","clipboard-write; fullscreen; autoplay"),w.setAttribute("sandbox","allow-same-origin allow-scripts allow-forms allow-popups allow-downloads"),w.setAttribute("referrerpolicy","strict-origin-when-cross-origin"),w.setAttribute("loading","lazy"),s.className&&(w.className=s.className),i.textContent="",i.appendChild(w),n=w,a=u=>{var L,z;if(!n||u.source!==n.contentWindow)return;let b=u.data;if(!(!b||typeof b.type!="string")){if(b.type==="signalbird:ready"){d("ready",b.module);return}if(b.type==="signalbird:height"&&typeof b.px=="number"&&(d("height",b.px),((L=s.height)!=null?L:"auto")==="auto")){let Me=Math.max(b.px,(z=s.minHeight)!=null?z:220);n.style.height=`${Me}px`;}}},window.addEventListener("message",a);};return {async mount(m){let x=typeof m=="string"?document.querySelector(m):m;if(!(x instanceof HTMLElement))throw new Error("Signalbird: g\xF6mme kab\u0131 bulunamad\u0131 \u2014 "+String(m));i=x,l=false,await f();},refresh:()=>f(),async setTheme(m){o=m,await f();},destroy(){l=true,c(),t.clear(),i=null;},on(m,x){t.has(m)||t.set(m,new Set),t.get(m).add(x);},off(m,x){var k;(k=t.get(m))==null||k.delete(x);}}}var jt="2.4.0",v=null,G=[],N=null;function C(s,e){try{return s()}catch(t){try{console.warn("[signalbird]",t);}catch(i){}return e}}function Ee(s){s.catch(()=>{});}function nt(s){C(()=>{if(!s||!s.publicKey){console.warn("[signalbird] init: publicKey zorunlu");return}if(!(typeof document=="undefined"||typeof window=="undefined")){v&&v.destroy(),v=new q(s);for(let{event:e,fn:t}of G)v.on(e,t);if(N){let e=N;N=null,Ee(v.identify(e));}}},void 0);}function Nt(s){C(()=>{if(s){if(!v){N={...N||{},...s};return}Ee(v.identify(s));}},void 0);}var Ht={open(){C(()=>v==null?void 0:v.open(),void 0);},close(){C(()=>v==null?void 0:v.close(),void 0);},toggle(){C(()=>v==null?void 0:v.toggle(),void 0);},isOpen(){return C(()=>!!(v!=null&&v.isOpen()),false)},on(s,e){C(()=>{typeof e=="function"&&(G.push({event:s,fn:e}),v==null||v.on(s,e));},void 0);},off(s,e){C(()=>{let t=G.findIndex(i=>i.event===s&&i.fn===e);t>=0&&G.splice(t,1),v==null||v.off(s,e);},void 0);}},It={register(s){return C(()=>v?v.pushRegister(s).catch(e=>({ok:!1,status:0,code:"NETWORK_ERROR",message:String(e)})):Promise.resolve({ok:!1,status:0,code:"NOT_INITIALIZED",message:"Signalbird.init \xE7a\u011Fr\u0131lmad\u0131"}),Promise.resolve({ok:false,status:0,code:"WIDGET_ERROR",message:"widget error"}))}},Bt=Le;function Ot(){C(()=>{v==null||v.destroy(),v=null;},void 0);}C(()=>{if(typeof document=="undefined")return;let s=document.currentScript||document.querySelector('script[data-key][src*="signalbird"]'),e=s==null?void 0:s.dataset;if(!e||!e.key)return;let t=()=>nt({publicKey:e.key,chatKey:e.channel||void 0,baseUrl:e.baseUrl||void 0,locale:e.locale||void 0,debug:e.debug==="true"||e.debug==="1"});document.body?t():document.addEventListener("DOMContentLoaded",t,{once:!0});},void 0);
500
+ exports.chat=Ht;exports.destroy=Ot;exports.embed=Bt;exports.identify=Nt;exports.init=nt;exports.push=It;exports.version=jt;return exports;})({});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "signalbird",
3
- "version": "2.3.2",
3
+ "version": "2.4.0",
4
4
  "description": "Signalbird SDK — Telsiz (Radio), Gönderim (Messaging), Yönetim (Management) ve son kullanıcı sohbet/push istemcisi: sunucu, tarayıcı, mobil",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",