useyuva 0.0.7 → 0.0.8

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/dist/esm/chat.js CHANGED
@@ -1,4 +1,4 @@
1
- import{resolveLocale,directionOf,catalogFor,translatePlain,launcherOf,contrastOn,readStored,writeStored}from"./index-cmr5w646.js";var styles=`
1
+ import{resolveLocale,directionOf,catalogFor,translatePlain,launcherOf,contrastOn,readStored,writeStored}from"./index-e2tek7yk.js";var styles=`
2
2
  :host {
3
3
  --yuva-accent: #2563eb;
4
4
  --yuva-on-accent: #ffffff;
@@ -106,4 +106,4 @@ import{resolveLocale,directionOf,catalogFor,translatePlain,launcherOf,contrastOn
106
106
  block-size: 100%;
107
107
  min-block-size: 320px;
108
108
  }
109
- `,chatIcon='<svg width="26" height="26" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round" aria-hidden="true"><path d="M4 5h16v11H9l-5 4z"/></svg>',closeIcon='<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18"/></svg>',scriptSrc=document.currentScript instanceof HTMLScriptElement?document.currentScript.src:"";class YuvaChatElement extends HTMLElement{static observedAttributes=["channel","server","layout","locale","dir","identity-token","open"];static loadPanel=()=>import(new URL("yuva-chat.js",scriptSrc||location.href).href);#root;#launcher=null;#badge=null;#panel;#controller=null;#messages={};#open=!1;#unread=0;#identity=null;#refused=!1;constructor(){super();this.#root=this.attachShadow({mode:"open"}),this.#panel=document.createElement("section"),this.#panel.className="panel",this.#panel.setAttribute("role","dialog"),this.#panel.hidden=!0,this.#panel.addEventListener("keydown",(event)=>{if(event.key==="Escape"&&this.layout==="launcher")this.close()})}get layout(){return this.getAttribute("layout")==="embedded"?"embedded":"launcher"}get channel(){return this.getAttribute("channel")}get server(){return(this.getAttribute("server")||(scriptSrc?new URL(scriptSrc).origin:location.origin)).replace(/\/+$/,"")}get locale(){return resolveLocale(this.getAttribute("locale"),navigator.language)}get isOpen(){return this.#open}get unread(){return this.#unread}setIdentityToken(source){if(this.#identity=source,this.#controller)this.#controller.then((controller)=>controller.identityChanged())}async signOut(){if(this.#identity=null,this.removeAttribute("identity-token"),this.#controller)await(await this.#controller).signOut()}async rate(conversationId,rating,comment){return(await this.#ensureController()).rate(conversationId,rating,comment)}connectedCallback(){this.#render();let channel=this.channel;if(this.layout==="embedded"||this.hasAttribute("open")||!channel)return;let stored=readStored(channel);if(stored.launcher)this.#applyLauncher(stored.launcher);let idle=()=>{if(!this.isConnected||this.#controller||this.channel!==channel)return;if(stored.session)this.#ensureController();else this.#styleLauncher(channel)};if("requestIdleCallback"in window)requestIdleCallback(idle,{timeout:3000});else setTimeout(idle,1000)}#styleLauncher(channel){fetch(`${this.server}/client/v1/channels/${encodeURIComponent(channel)}`,{credentials:"omit"}).then((response)=>{if(response.status===403||response.status===404)this.#refuse();return response.ok?response.json():null}).then((inbox)=>{if(!inbox||this.channel!==channel||this.#controller)return;let launcher=launcherOf(inbox);this.#applyLauncher(launcher),writeStored(channel,{...readStored(channel),launcher})}).catch(()=>{return})}disconnectedCallback(){let controller=this.#controller;if(this.#controller=null,controller)controller.then((c)=>c.destroy())}attributeChangedCallback(name,previous,value){if(!this.isConnected||previous===value)return;if(name==="open"){value===null?this.close():this.open();return}if(name==="identity-token"){if(this.#controller)this.#controller.then((controller)=>controller.identityChanged());return}if(name==="channel"||name==="server"){this.disconnectedCallback(),this.#refused=!1,this.#render();return}if(this.#render(),this.#controller)this.#controller.then((controller)=>controller.update())}async open(){if(this.#open||this.#refused)return;this.#open=!0,this.toggleAttribute("open-panel",!0),this.#syncLauncher();let controller=await this.#ensureController();if(!this.#open)return;this.#panel.hidden=!1,controller.opened()}close(){if(!this.#open||this.layout==="embedded")return;if(this.#open=!1,this.toggleAttribute("open-panel",!1),this.#panel.hidden=!0,this.#syncLauncher(),this.#launcher?.focus(),this.#controller)this.#controller.then((controller)=>controller.closed())}toggle(){return this.#open?this.close():this.open()}#config(){return{channel:this.channel,server:this.server,layout:this.layout,locale:this.locale}}#ensureController(){return this.#controller??=YuvaChatElement.loadPanel().then(({mount})=>mount({panel:this.#panel,config:()=>this.#config(),identityToken:async()=>this.#identity?await this.#identity()??null:this.getAttribute("identity-token"),isOpen:()=>this.#open,close:()=>this.close(),setUnread:(count)=>{this.#unread=count,this.#syncLauncher(),this.dispatchEvent(new CustomEvent("yuva-unread",{detail:{count}}))},setLauncher:(style)=>this.#applyLauncher(style),refused:()=>this.#refuse()})),this.#controller}#refuse(){if(this.#refused)return;this.#refused=!0,console.warn(`Yuva: channel ${this.channel} is unknown or does not allow ${location.origin}`),this.#open=!1,this.toggleAttribute("open-panel",!1),this.disconnectedCallback(),this.#render()}#applyLauncher(style){if(this.setAttribute("position",style.position==="left"?"left":"right"),style.color&&/^#[0-9a-f]{6}$/i.test(style.color))this.style.setProperty("--yuva-accent",style.color),this.style.setProperty("--yuva-on-accent",contrastOn(style.color))}#render(){let locale=this.locale;this.#messages=catalogFor(locale),this.setAttribute("lang",locale);let style=document.createElement("style");if(style.textContent=styles,this.#panel.dir=this.getAttribute("dir")??directionOf(locale),this.#panel.setAttribute("aria-modal","false"),this.#refused){this.#launcher=null,this.#badge=null,this.#root.replaceChildren();return}if(this.layout==="embedded"){this.#launcher=null,this.#badge=null,this.#root.replaceChildren(style,this.#panel),this.#open=!1,this.open();return}let launcher=document.createElement("button");if(launcher.type="button",launcher.className="launcher",launcher.addEventListener("click",()=>void this.toggle()),this.#launcher=launcher,this.#badge=document.createElement("span"),this.#badge.className="badge",this.#badge.setAttribute("aria-hidden","true"),this.#root.replaceChildren(style,this.#panel,launcher),this.#syncLauncher(),this.hasAttribute("open")&&!this.#open)this.open()}#syncLauncher(){let launcher=this.#launcher,badge=this.#badge;if(!launcher||!badge)return;let count=this.#unread;launcher.setAttribute("aria-expanded",String(this.#open)),launcher.setAttribute("aria-label",this.#open?translatePlain(this.#messages,{id:"pqZJT2"}):count>0?translatePlain(this.#messages,{id:"OkHvGB",values:{count}}):translatePlain(this.#messages,{id:"6I7cJR"})),launcher.innerHTML=this.#open?closeIcon:chatIcon,badge.textContent=count>9?"9+":String(count),badge.hidden=this.#open||count===0,launcher.append(badge)}}function define(){if(!customElements.get("yuva-chat"))customElements.define("yuva-chat",YuvaChatElement)}YuvaChatElement.loadPanel=()=>import("./yuva-chat-acme1k5r.js");define();export{YuvaChatElement,define};
109
+ `,chatIcon='<svg width="26" height="26" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round" aria-hidden="true"><path d="M4 5h16v11H9l-5 4z"/></svg>',closeIcon='<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18"/></svg>',scriptSrc=document.currentScript instanceof HTMLScriptElement?document.currentScript.src:"";class YuvaChatElement extends HTMLElement{static observedAttributes=["channel","server","layout","locale","dir","identity-token","open"];static loadPanel=()=>import(new URL("yuva-chat.js",scriptSrc||location.href).href);#root;#launcher=null;#badge=null;#panel;#controller=null;#messages={};#open=!1;#unread=0;#identity=null;#refused=!1;constructor(){super();this.#root=this.attachShadow({mode:"open"}),this.#panel=document.createElement("section"),this.#panel.className="panel",this.#panel.setAttribute("role","dialog"),this.#panel.hidden=!0,this.#panel.addEventListener("keydown",(event)=>{if(event.key==="Escape"&&this.layout==="launcher")this.close()})}get layout(){return this.getAttribute("layout")==="embedded"?"embedded":"launcher"}get channel(){return this.getAttribute("channel")}get server(){return(this.getAttribute("server")||(scriptSrc?new URL(scriptSrc).origin:location.origin)).replace(/\/+$/,"")}get locale(){return resolveLocale(this.getAttribute("locale"),navigator.language)}get isOpen(){return this.#open}get unread(){return this.#unread}setIdentityToken(source){if(this.#identity=source,this.#controller)this.#controller.then((controller)=>controller.identityChanged())}async signOut(){if(this.#identity=null,this.removeAttribute("identity-token"),this.#controller)await(await this.#controller).signOut()}async rate(conversationId,rating,comment){return(await this.#ensureController()).rate(conversationId,rating,comment)}connectedCallback(){this.#render();let channel=this.channel;if(this.layout==="embedded"||this.hasAttribute("open")||!channel)return;let stored=readStored(channel);if(stored.launcher)this.#applyLauncher(stored.launcher);let idle=()=>{if(!this.isConnected||this.#controller||this.channel!==channel)return;if(stored.session)this.#ensureController();else this.#styleLauncher(channel)};if("requestIdleCallback"in window)requestIdleCallback(idle,{timeout:3000});else setTimeout(idle,1000)}#styleLauncher(channel){fetch(`${this.server}/client/v1/channels/${encodeURIComponent(channel)}`,{credentials:"omit"}).then((response)=>{if(response.status===403||response.status===404)this.#refuse();return response.ok?response.json():null}).then((inbox)=>{if(!inbox||this.channel!==channel||this.#controller)return;let launcher=launcherOf(inbox);this.#applyLauncher(launcher),writeStored(channel,{...readStored(channel),launcher})}).catch(()=>{return})}disconnectedCallback(){let controller=this.#controller;if(this.#controller=null,controller)controller.then((c)=>c.destroy())}attributeChangedCallback(name,previous,value){if(!this.isConnected||previous===value)return;if(name==="open"){value===null?this.close():this.open();return}if(name==="identity-token"){if(this.#controller)this.#controller.then((controller)=>controller.identityChanged());return}if(name==="channel"||name==="server"){this.disconnectedCallback(),this.#refused=!1,this.#render();return}if(this.#render(),this.#controller)this.#controller.then((controller)=>controller.update())}async open(){if(this.#open||this.#refused)return;this.#open=!0,this.toggleAttribute("open-panel",!0),this.#syncLauncher();let controller=await this.#ensureController();if(!this.#open)return;this.#panel.hidden=!1,controller.opened()}close(){if(!this.#open||this.layout==="embedded")return;if(this.#open=!1,this.toggleAttribute("open-panel",!1),this.#panel.hidden=!0,this.#syncLauncher(),this.#launcher?.focus(),this.#controller)this.#controller.then((controller)=>controller.closed())}toggle(){return this.#open?this.close():this.open()}#config(){return{channel:this.channel,server:this.server,layout:this.layout,locale:this.locale}}#ensureController(){return this.#controller??=YuvaChatElement.loadPanel().then(({mount})=>mount({panel:this.#panel,config:()=>this.#config(),identityToken:async()=>this.#identity?await this.#identity()??null:this.getAttribute("identity-token"),isOpen:()=>this.#open,close:()=>this.close(),setUnread:(count)=>{this.#unread=count,this.#syncLauncher(),this.dispatchEvent(new CustomEvent("yuva-unread",{detail:{count}}))},setLauncher:(style)=>this.#applyLauncher(style),refused:()=>this.#refuse()})),this.#controller}#refuse(){if(this.#refused)return;this.#refused=!0,console.warn(`Yuva: channel ${this.channel} is unknown or does not allow ${location.origin}`),this.#open=!1,this.toggleAttribute("open-panel",!1),this.disconnectedCallback(),this.#render()}#applyLauncher(style){if(this.setAttribute("position",style.position==="left"?"left":"right"),style.color&&/^#[0-9a-f]{6}$/i.test(style.color))this.style.setProperty("--yuva-accent",style.color),this.style.setProperty("--yuva-on-accent",contrastOn(style.color))}#render(){let locale=this.locale;this.#messages=catalogFor(locale),this.setAttribute("lang",locale);let style=document.createElement("style");if(style.textContent=styles,this.#panel.dir=this.getAttribute("dir")??directionOf(locale),this.#panel.setAttribute("aria-modal","false"),this.#refused){this.#launcher=null,this.#badge=null,this.#root.replaceChildren();return}if(this.layout==="embedded"){this.#launcher=null,this.#badge=null,this.#root.replaceChildren(style,this.#panel),this.#open=!1,this.open();return}let launcher=document.createElement("button");if(launcher.type="button",launcher.className="launcher",launcher.addEventListener("click",()=>void this.toggle()),this.#launcher=launcher,this.#badge=document.createElement("span"),this.#badge.className="badge",this.#badge.setAttribute("aria-hidden","true"),this.#root.replaceChildren(style,this.#panel,launcher),this.#syncLauncher(),this.hasAttribute("open")&&!this.#open)this.open()}#syncLauncher(){let launcher=this.#launcher,badge=this.#badge;if(!launcher||!badge)return;let count=this.#unread;launcher.setAttribute("aria-expanded",String(this.#open)),launcher.setAttribute("aria-label",this.#open?translatePlain(this.#messages,{id:"pqZJT2"}):count>0?translatePlain(this.#messages,{id:"OkHvGB",values:{count}}):translatePlain(this.#messages,{id:"6I7cJR"})),launcher.innerHTML=this.#open?closeIcon:chatIcon,badge.textContent=count>9?"9+":String(count),badge.hidden=this.#open||count===0,launcher.append(badge)}}function define(){if(!customElements.get("yuva-chat"))customElements.define("yuva-chat",YuvaChatElement)}YuvaChatElement.loadPanel=()=>import("./yuva-chat-86e4mz63.js");define();export{YuvaChatElement,define};
package/dist/esm/docs.js CHANGED
@@ -1,4 +1,4 @@
1
- import{resolveLocale,directionOf,translatePlain,launcherOf,contrastOn,readStored,writeStored}from"./index-cmr5w646.js";import{inlineNodes}from"./index-jdxce2se.js";import{ApiError2,createYuvaClient2}from"./index-dj5dhqc1.js";var messages=JSON.parse(`{"-UxBoG":["Deleted member"],"1UzENP":["No"],"2Hlmdt":["Write a reply…"],"2lF8Zj":["Unanswered"],"3CApMv":["All discussions"],"3PqJQG":["Nothing to preview."],"4-S4QM":["Unmark as answer"],"5lWFkC":["Sign in"],"78dEKp":["Sort discussions"],"7oGBMv":["Discussions"],"8Ekoev":["You can't do that."],"8ntmc1":["Votes: ",["0"]],"8wRl7c":["The opening post was deleted."],"99w-GZ":["Sign in to start a discussion. Your name is shown with your post."],"D9CFV5":["Anonymous"],"E_qvzP":["Enter a valid e-mail address."],"EmiQvf":["Thanks! Anything we could add? (optional)"],"FMWGhb":["Deleted reader"],"F_vGso":["Your reply"],"G2fuEb":["Locked"],"GQVIIl":["You seem to be offline."],"GqCA_t":["Answered"],"HkXOWm":["This reply was deleted."],"Hw3P48":["Replies: ",["0"]],"ImOQa9":["Reply"],"JfAIiv":["This discussion is locked. New replies are closed."],"JlFcis":["Send"],"KDw4GX":["Try again"],"KEjhwb":["This discussion is locked."],"KM6m8p":["Team"],"Kl3TuI":["Get an e-mail when someone replies or an answer is accepted."],"Klsidc":["Delete this reply?"],"LwDe8g":["Sign in to take part in the discussion."],"MDmQKn":["Could not load the discussions."],"MHrjPM":["Title"],"MKEPCY":["Follow"],"NjUiZ4":["Ask a question, share an idea or describe a problem with this page."],"NrGspR":["Thanks! Your discussion will appear for everyone once the team approves it."],"OVijcR":["Remove your vote (",["0"]," votes)"],"PL0621":["Sign in to reply, vote and follow this discussion."],"PN38hZ":["Your question or idea"],"PZ_kxo":["Keep"],"Pwqkdw":["Loading…"],"RqsQKK":["Your first posts are checked by the team before they appear for everyone."],"SOvBw9":["Was this page helpful?"],"Sad2tK":["Sending…"],"Su3Vyp":["Check the title and the text and try again."],"U7H5Fm":["Sorry about that. What was missing or unclear?"],"UbRKMZ":["Pending"],"VGqKyv":["This discussion is no longer available."],"Vwy_nT":["Markdown is supported."],"WWy8TN":["Top"],"XJURKP":["E-mail address"],"YZayoP":["Thanks! Your reply will appear for everyone once the team approves it."],"a_qtPP":["E-mail for a reply (optional)"],"b6Orhy":["Have a question or an idea? Start the first one."],"b_f4xj":["Posts can be edited for 30 minutes after they are written."],"cnGeoo":["Delete"],"d6N994":["Thanks for your feedback."],"dEgA5A":["Cancel"],"dNOvhg":["Upvote (",["0"]," votes)"],"ePK91l":["Edit"],"fMPkxb":["Show more"],"fcWrnU":["Sign out"],"i4_LY_":["Write"],"isRobC":["New"],"j-3eim":["Discussions about this page"],"jhu92n":["Mark as answer"],"k4b5_X":["edited"],"l75CjT":["Yes"],"lWv8id":["Awaiting approval"],"n5vqdp":["Start discussion"],"nLqMRA":["Team member"],"nW3go1":["Your browser blocked the sign-in window. Allow pop-ups for this site and try again."],"pzatAP":["Loading discussions…"],"qzVesX":["Edit your post"],"rAl91-":["Delete this discussion?"],"rdUucN":["Preview"],"rpfOwz":["No discussions about this page yet."],"tA4dAO":["No thanks"],"tAL5wg":["Could not send. Try again."],"tayT8P":["Discussions are turned off for this site."],"tfDRzk":["Save"],"twEQ41":["Every discussion on this page has an answer."],"tzsBOP":["Too many attempts. Wait a moment and try again."],"uuIskV":["Sign in to write to us."],"xOTzt5":["just now"],"y-KXxN":["Accepted answer"],"y6sq5j":["Following"],"z1qf6l":["Start a discussion"],"zmA6sS":["Reader"]}`);var messages2=JSON.parse('{"-UxBoG":["Silinmiş üye"],"1UzENP":["Hayır"],"2Hlmdt":["Bir yanıt yazın…"],"2lF8Zj":["Yanıtsız"],"3CApMv":["Tüm tartışmalar"],"3PqJQG":["Önizlenecek bir şey yok."],"4-S4QM":["Yanıt işaretini kaldır"],"5lWFkC":["Giriş yap"],"78dEKp":["Tartışmaları sırala"],"7oGBMv":["Tartışmalar"],"8Ekoev":["Bunu yapamazsınız."],"8ntmc1":["Oylar: ",["0"]],"8wRl7c":["Açılış gönderisi silindi."],"99w-GZ":["Tartışma başlatmak için giriş yapın. Adınız gönderinizle birlikte gösterilir."],"D9CFV5":["Anonim"],"E_qvzP":["Geçerli bir e-posta adresi girin."],"EmiQvf":["Teşekkürler! Ekleyebileceğimiz bir şey var mı? (isteğe bağlı)"],"FMWGhb":["Silinmiş okuyucu"],"F_vGso":["Yanıtınız"],"G2fuEb":["Kilitli"],"GQVIIl":["Çevrimdışı görünüyorsunuz."],"GqCA_t":["Yanıtlandı"],"HkXOWm":["Bu yanıt silindi."],"Hw3P48":["Yanıtlar: ",["0"]],"ImOQa9":["Yanıtla"],"JfAIiv":["Bu tartışma kilitli. Yeni yanıt yazılamaz."],"JlFcis":["Gönder"],"KDw4GX":["Yeniden dene"],"KEjhwb":["Bu tartışma kilitli."],"KM6m8p":["Ekip"],"Kl3TuI":["Biri yanıt yazdığında ya da bir yanıt kabul edildiğinde e-posta alın."],"Klsidc":["Bu yanıt silinsin mi?"],"LwDe8g":["Tartışmaya katılmak için giriş yapın."],"MDmQKn":["Tartışmalar yüklenemedi."],"MHrjPM":["Başlık"],"MKEPCY":["Takip et"],"NjUiZ4":["Bir soru sorun, bir fikir paylaşın ya da bu sayfadaki bir sorunu anlatın."],"NrGspR":["Teşekkürler! Tartışmanız ekip onayladığında herkese görünecek."],"OVijcR":["Oyunuzu geri alın (",["0"]," oy)"],"PL0621":["Bu tartışmada yanıt yazmak, oy vermek ve takip etmek için giriş yapın."],"PN38hZ":["Sorunuz ya da fikriniz"],"PZ_kxo":["Kalsın"],"Pwqkdw":["Yükleniyor…"],"RqsQKK":["İlk gönderileriniz herkese görünmeden önce ekip tarafından kontrol edilir."],"SOvBw9":["Bu sayfa işinize yaradı mı?"],"Sad2tK":["Gönderiliyor…"],"Su3Vyp":["Başlığı ve metni kontrol edip yeniden deneyin."],"U7H5Fm":["Üzgünüz. Eksik ya da anlaşılmayan ne vardı?"],"UbRKMZ":["Bekliyor"],"VGqKyv":["Bu tartışma artık mevcut değil."],"Vwy_nT":["Markdown desteklenir."],"WWy8TN":["En çok oy alan"],"XJURKP":["E-posta adresi"],"YZayoP":["Teşekkürler! Yanıtınız ekip onayladığında herkese görünecek."],"a_qtPP":["Yanıt için e-posta (isteğe bağlı)"],"b6Orhy":["Bir sorunuz ya da fikriniz mi var? İlk tartışmayı siz başlatın."],"b_f4xj":["Gönderiler yazıldıktan sonra 30 dakika içinde düzenlenebilir."],"cnGeoo":["Sil"],"d6N994":["Geri bildiriminiz için teşekkürler."],"dEgA5A":["Vazgeç"],"dNOvhg":["Oy ver (",["0"]," oy)"],"ePK91l":["Düzenle"],"fMPkxb":["Daha fazla göster"],"fcWrnU":["Çıkış yap"],"i4_LY_":["Yaz"],"isRobC":["Yeni"],"j-3eim":["Bu sayfayla ilgili tartışmalar"],"jhu92n":["Yanıt olarak işaretle"],"k4b5_X":["düzenlendi"],"l75CjT":["Evet"],"lWv8id":["Onay bekliyor"],"n5vqdp":["Tartışmayı başlat"],"nLqMRA":["Ekip üyesi"],"nW3go1":["Tarayıcınız giriş penceresini engelledi. Bu site için açılır pencerelere izin verip yeniden deneyin."],"pzatAP":["Tartışmalar yükleniyor…"],"qzVesX":["Gönderinizi düzenleyin"],"rAl91-":["Bu tartışma silinsin mi?"],"rdUucN":["Önizleme"],"rpfOwz":["Bu sayfayla ilgili henüz bir tartışma yok."],"tA4dAO":["Hayır, teşekkürler"],"tAL5wg":["Gönderilemedi. Yeniden deneyin."],"tayT8P":["Bu sitede tartışmalar kapalı."],"tfDRzk":["Kaydet"],"twEQ41":["Bu sayfadaki her tartışmanın bir yanıtı var."],"tzsBOP":["Çok fazla deneme. Biraz bekleyip tekrar deneyin."],"uuIskV":["Bize yazmak için oturum açın."],"xOTzt5":["az önce"],"y-KXxN":["Kabul edilen yanıt"],"y6sq5j":["Takip ediliyor"],"z1qf6l":["Tartışma başlat"],"zmA6sS":["Okur"]}');var shared=Symbol.for("yuva.navigation");function navigation(){let win=window,target=win[shared];if(target)return target;let created=new EventTarget;target=win[shared]=created;let notify=()=>created.dispatchEvent(new Event("change"));for(let name of["pushState","replaceState"]){let original=history[name];history[name]=function(...args){let result=original.apply(this,args);return notify(),result}}return window.addEventListener("popstate",notify),window.addEventListener("hashchange",notify),target}function pageOf(value){try{let url=new URL(value||location.href,location.href);return url.search="",url.hash="",url.href}catch{return value||location.href}}function followPage(listener){let target=navigation(),scheduled=!1,changed=()=>{if(scheduled)return;scheduled=!0,queueMicrotask(()=>{scheduled=!1,listener()})};return target.addEventListener("change",changed),()=>target.removeEventListener("change",changed)}var catalogs={en:messages,tr:messages2},settings=new Map,Base=typeof HTMLElement>"u"?class{}:HTMLElement,scriptSrc=typeof document<"u"&&document.currentScript instanceof HTMLScriptElement?document.currentScript.src:"",baseStyles=`
1
+ import{resolveLocale,directionOf,translatePlain,launcherOf,contrastOn,readStored,writeStored}from"./index-e2tek7yk.js";import{ApiError2,createYuvaClient2}from"./index-dj5dhqc1.js";import{el}from"./index-rdzxvj2r.js";var messages=JSON.parse(`{"-UxBoG":["Deleted member"],"1UzENP":["No"],"2lF8Zj":["Unanswered"],"5lWFkC":["Sign in"],"78dEKp":["Sort discussions"],"7oGBMv":["Discussions"],"8Ekoev":["You can't do that."],"8ntmc1":["Votes: ",["0"]],"D16wQE":["Could not open the discussion. Try again."],"D9CFV5":["Anonymous"],"E_qvzP":["Enter a valid e-mail address."],"EmiQvf":["Thanks! Anything we could add? (optional)"],"FMWGhb":["Deleted reader"],"G2fuEb":["Locked"],"GQVIIl":["You seem to be offline."],"GqCA_t":["Answered"],"Hw3P48":["Replies: ",["0"]],"JlFcis":["Send"],"KDw4GX":["Try again"],"KEjhwb":["This discussion is locked."],"KM6m8p":["Team"],"LwDe8g":["Sign in to take part in the discussion."],"MDmQKn":["Could not load the discussions."],"Pwqkdw":["Loading…"],"SOvBw9":["Was this page helpful?"],"Sad2tK":["Sending…"],"Su3Vyp":["Check the title and the text and try again."],"U7H5Fm":["Sorry about that. What was missing or unclear?"],"UbRKMZ":["Pending"],"WWy8TN":["Top"],"XJURKP":["E-mail address"],"a_qtPP":["E-mail for a reply (optional)"],"b6Orhy":["Have a question or an idea? Start the first one."],"b_f4xj":["Posts can be edited for 30 minutes after they are written."],"d6N994":["Thanks for your feedback."],"fMPkxb":["Show more"],"fcWrnU":["Sign out"],"isRobC":["New"],"j-3eim":["Discussions about this page"],"l75CjT":["Yes"],"lWv8id":["Awaiting approval"],"nLqMRA":["Team member"],"nW3go1":["Your browser blocked the sign-in window. Allow pop-ups for this site and try again."],"pzatAP":["Loading discussions…"],"rpfOwz":["No discussions about this page yet."],"tA4dAO":["No thanks"],"tAL5wg":["Could not send. Try again."],"tayT8P":["Discussions are turned off for this site."],"twEQ41":["Every discussion on this page has an answer."],"tzsBOP":["Too many attempts. Wait a moment and try again."],"uuIskV":["Sign in to write to us."],"xOTzt5":["just now"],"z1qf6l":["Start a discussion"],"zmA6sS":["Reader"]}`);var messages2=JSON.parse('{"-UxBoG":["Silinmiş üye"],"1UzENP":["Hayır"],"2lF8Zj":["Yanıtsız"],"5lWFkC":["Giriş yap"],"78dEKp":["Tartışmaları sırala"],"7oGBMv":["Tartışmalar"],"8Ekoev":["Bunu yapamazsınız."],"8ntmc1":["Oylar: ",["0"]],"D16wQE":["Tartışma açılamadı. Yeniden deneyin."],"D9CFV5":["Anonim"],"E_qvzP":["Geçerli bir e-posta adresi girin."],"EmiQvf":["Teşekkürler! Ekleyebileceğimiz bir şey var mı? (isteğe bağlı)"],"FMWGhb":["Silinmiş okuyucu"],"G2fuEb":["Kilitli"],"GQVIIl":["Çevrimdışı görünüyorsunuz."],"GqCA_t":["Yanıtlandı"],"Hw3P48":["Yanıtlar: ",["0"]],"JlFcis":["Gönder"],"KDw4GX":["Yeniden dene"],"KEjhwb":["Bu tartışma kilitli."],"KM6m8p":["Ekip"],"LwDe8g":["Tartışmaya katılmak için giriş yapın."],"MDmQKn":["Tartışmalar yüklenemedi."],"Pwqkdw":["Yükleniyor…"],"SOvBw9":["Bu sayfa işinize yaradı mı?"],"Sad2tK":["Gönderiliyor…"],"Su3Vyp":["Başlığı ve metni kontrol edip yeniden deneyin."],"U7H5Fm":["Üzgünüz. Eksik ya da anlaşılmayan ne vardı?"],"UbRKMZ":["Bekliyor"],"WWy8TN":["En çok oy alan"],"XJURKP":["E-posta adresi"],"a_qtPP":["Yanıt için e-posta (isteğe bağlı)"],"b6Orhy":["Bir sorunuz ya da fikriniz mi var? İlk tartışmayı siz başlatın."],"b_f4xj":["Gönderiler yazıldıktan sonra 30 dakika içinde düzenlenebilir."],"d6N994":["Geri bildiriminiz için teşekkürler."],"fMPkxb":["Daha fazla göster"],"fcWrnU":["Çıkış yap"],"isRobC":["Yeni"],"j-3eim":["Bu sayfayla ilgili tartışmalar"],"l75CjT":["Evet"],"lWv8id":["Onay bekliyor"],"nLqMRA":["Ekip üyesi"],"nW3go1":["Tarayıcınız giriş penceresini engelledi. Bu site için açılır pencerelere izin verip yeniden deneyin."],"pzatAP":["Tartışmalar yükleniyor…"],"rpfOwz":["Bu sayfayla ilgili henüz bir tartışma yok."],"tA4dAO":["Hayır, teşekkürler"],"tAL5wg":["Gönderilemedi. Yeniden deneyin."],"tayT8P":["Bu sitede tartışmalar kapalı."],"twEQ41":["Bu sayfadaki her tartışmanın bir yanıtı var."],"tzsBOP":["Çok fazla deneme. Biraz bekleyip tekrar deneyin."],"uuIskV":["Bize yazmak için oturum açın."],"xOTzt5":["az önce"],"z1qf6l":["Tartışma başlat"],"zmA6sS":["Okur"]}');var shared=Symbol.for("yuva.navigation");function navigation(){let win=window,target=win[shared];if(target)return target;let created=new EventTarget;target=win[shared]=created;let notify=()=>created.dispatchEvent(new Event("change"));for(let name of["pushState","replaceState"]){let original=history[name];history[name]=function(...args){let result=original.apply(this,args);return notify(),result}}return window.addEventListener("popstate",notify),window.addEventListener("hashchange",notify),target}function pageOf(value){try{let url=new URL(value||location.href,location.href);return url.search="",url.hash="",url.href}catch{return value||location.href}}function followPage(listener){let target=navigation(),scheduled=!1,changed=()=>{if(scheduled)return;scheduled=!0,queueMicrotask(()=>{scheduled=!1,listener()})};return target.addEventListener("change",changed),()=>target.removeEventListener("change",changed)}var catalogs={en:messages,tr:messages2},settings=new Map,Base=typeof HTMLElement>"u"?class{}:HTMLElement,scriptSrc=typeof document<"u"&&document.currentScript instanceof HTMLScriptElement?document.currentScript.src:"",baseStyles=`
2
2
  :host {
3
3
  --yuva-accent: #2563eb;
4
4
  --yuva-on-accent: #ffffff;
@@ -46,11 +46,7 @@ textarea:focus-visible, input:focus-visible { outline: 2px solid var(--yuva-acce
46
46
  .send:focus-visible, .link:focus-visible { outline: 2px solid var(--yuva-accent); outline-offset: 2px; }
47
47
  .link { padding: 0; border: 0; background: none; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; opacity: 0.8; }
48
48
  @media (max-width: 480px) { textarea, input { font-size: 16px; } }
49
- `;function el(tag,className,text){let element=document.createElement(tag);if(className)element.className=className;if(text!==void 0)element.textContent=text;return element}class YuvaDocsElement extends Base{static observedAttributes=["channel","server","locale","dir","page","page-title","identity-token"];root;inbox=null;pageUrl="";refused=!1;direction="ltr";#messages=messages;#client=null;#identity=null;#unfollow=null;#settingsFor="";#connected=!1;#accentColor="";constructor(){super();this.root=this.attachShadow({mode:"open"})}get channel(){return this.getAttribute("channel")}set channel(value){this.#attribute("channel",value)}get server(){return(this.getAttribute("server")||(scriptSrc?new URL(scriptSrc).origin:location.origin)).replace(/\/+$/,"")}set server(value){this.#attribute("server",value)}get locale(){return resolveLocale(this.getAttribute("locale"),navigator.language)}set locale(value){this.#attribute("locale",value)}get page(){return this.pageUrl||pageOf(this.getAttribute("page"))}set page(value){this.#attribute("page",value)}get pageTitle(){return this.getAttribute("page-title")||document.title}set pageTitle(value){this.#attribute("page-title",value)}#attribute(name,value){if(value===null||value===void 0||value==="")this.removeAttribute(name);else this.setAttribute(name,value)}setIdentityToken(source){if(this.#identity=source,this.#client?.setIdentityToken(()=>this.#identityToken()),this.#connected&&!this.refused)this.render()}connectedCallback(){this.#connected=!0,this.#unfollow??=followPage(()=>this.#syncPage()),this.pageUrl=pageOf(this.getAttribute("page")),this.#applyLocale(),this.#loadSettings(),this.render(),this.pageChanged()}disconnectedCallback(){this.#connected=!1,this.#unfollow?.(),this.#unfollow=null}attributeChangedCallback(name,previous,value){if(!this.#connected||previous===value)return;if(name==="channel"||name==="server"){this.#client?.reset(),this.#client=null,this.refused=!1,this.inbox=null,this.#settingsFor="",this.#loadSettings(),this.reset(),this.render(),this.pageChanged();return}if(name==="page")return this.#syncPage();if(name==="identity-token")this.#client?.setIdentityToken(()=>this.#identityToken());if(name==="locale"||name==="dir")this.#applyLocale();this.render()}t(descriptor){return translatePlain(this.#messages,descriptor,messages)}client(){return this.#client??=createYuvaClient2({server:this.server,channel:this.channel??"",identityToken:()=>this.#identityToken()}),this.#client}get identified(){return!!this.#identity||this.hasAttribute("identity-token")}get canWrite(){return this.identified||this.inbox?.chat.allow_anonymous!==!1}emit(type,detail){this.dispatchEvent(new CustomEvent(type,{detail,bubbles:!0,composed:!0}))}refusal(error,channelRequest=!0){let refused=error instanceof ApiError2&&(error.code==="origin_not_allowed"||error.code==="page_origin"||channelRequest&&error.status===404);if(refused&&!this.refused)this.refused=!0,console.warn(`Yuva: channel ${this.channel} is unknown or does not allow ${this.pageUrl}`),this.root.replaceChildren();return refused}errorText(error){let code=error instanceof ApiError2?error.code:"";if(code==="rate_limited")return this.t({id:"tzsBOP"});if(code==="network")return this.t({id:"GQVIIl"});if(code==="anonymous_not_allowed"||code==="invalid_identity_token")return this.t({id:"uuIskV"});return this.t({id:"tAL5wg"})}frame(css,...children){let style=el("style");style.textContent=baseStyles+css;let wrapper=el("div","frame");if(wrapper.dir=this.direction,wrapper.lang=this.locale,this.#accentColor)wrapper.style.setProperty("--yuva-accent",this.#accentColor),wrapper.style.setProperty("--yuva-on-accent",contrastOn(this.#accentColor));wrapper.append(...children);let focused=null;try{focused=this.root.activeElement}catch{}if(this.root.replaceChildren(style,wrapper),focused instanceof HTMLElement&&focused.isConnected)focused.focus({preventScroll:!0})}async#identityToken(){return this.#identity?await this.#identity()??null:this.getAttribute("identity-token")}#syncPage(){if(!this.#connected)return;let page=pageOf(this.getAttribute("page"));if(page===this.pageUrl)return;this.pageUrl=page,this.reset(),this.render(),this.pageChanged()}#applyLocale(){let locale=this.locale;this.#messages=catalogs[locale]??messages,this.direction=this.getAttribute("dir")==="rtl"?"rtl":this.getAttribute("dir")==="ltr"?"ltr":directionOf(locale)}#loadSettings(){let channel=this.channel,key=`${this.server} ${channel}`;if(!channel||this.#settingsFor===key)return;this.#settingsFor=key;let stored=readStored(channel).launcher;if(stored?.color)this.#accent(stored.color);let request=settings.get(key);if(!request)request=this.client().channelSettings(),settings.set(key,request),request.catch(()=>settings.delete(key));request.then((inbox)=>{if(this.channel!==channel)return;this.inbox=inbox;let launcher=launcherOf(inbox);if(launcher.color)this.#accent(launcher.color);if(writeStored(channel,{...readStored(channel),launcher}),!this.refused)this.render()}).catch((error)=>{if(this.channel===channel)this.refusal(error)})}#accent(color){if(!/^#[0-9a-f]{6}$/i.test(color))return;this.#accentColor=color}}var linkPattern=/\[([^\]\n]+)\]\(([^)\s]+)\)/g;function inline(text){let nodes=[],last=0;for(let match of text.matchAll(linkPattern)){let index=match.index??0;if(index>last)nodes.push(...inlineNodes(text.slice(last,index)));let[whole,label="",href=""]=match,url=null;try{url=new URL(href)}catch{}if(url&&(url.protocol==="http:"||url.protocol==="https:")){let a=document.createElement("a");a.href=url.href,a.target="_blank",a.rel="nofollow ugc noopener",a.append(...inlineNodes(label)),nodes.push(a)}else nodes.push(document.createTextNode(whole));last=index+whole.length}if(last<text.length)nodes.push(...inlineNodes(text.slice(last)));return nodes}function block(tag,lines){let element=document.createElement(tag);return element.append(...inline(lines.join(" "))),element}function preview(markdown){let fragment=document.createDocumentFragment(),lines=markdown.replace(/\r\n?/g,`
50
- `).split(`
51
- `),paragraph=[],list=null,quote=[],flush=()=>{if(paragraph.length)fragment.append(block("p",paragraph));if(quote.length){let element=document.createElement("blockquote");element.append(preview(quote.join(`
52
- `))),fragment.append(element)}paragraph=[],quote=[],list=null};for(let i=0;i<lines.length;i++){let line=lines[i]??"",fence=/^\s*(```|~~~)/.exec(line);if(fence){flush();let code=[];while(++i<lines.length&&!(lines[i]??"").trimStart().startsWith(fence[1]??"```"))code.push(lines[i]??"");let pre=document.createElement("pre");pre.append(Object.assign(document.createElement("code"),{textContent:code.join(`
53
- `)})),fragment.append(pre);continue}if(/^\s*$/.test(line)){flush();continue}let quoted=/^\s*>\s?(.*)$/.exec(line);if(quoted){if(paragraph.length||list)flush();quote.push(quoted[1]??"");continue}let heading=/^\s*(#{1,6})\s+(.*)$/.exec(line);if(heading){flush(),fragment.append(block(`h${Math.min(6,(heading[1]?.length??1)+2)}`,[heading[2]??""]));continue}let item=/^\s*(?:([-*+])|(\d+)[.)])\s+(.*)$/.exec(line);if(item){let tag=item[1]?"ul":"ol";if(paragraph.length||quote.length||list&&list.tagName.toLowerCase()!==tag)flush();if(!list)list=document.createElement(tag),fragment.append(list);list.append(block("li",[item[3]??""]));continue}if(quote.length)flush();if(list&&/^\s{2,}/.test(line)){list.lastElementChild?.append(" ",...inline(line.trim()));continue}list=null,paragraph.push(line.trim())}return flush(),fragment}var hashPrefix="#yuva-discussion-",cacheFor=60000,editWindow=1800000,loads=new Map;function forget(prefix){for(let key of loads.keys())if(key.startsWith(prefix))loads.delete(key)}var svg=(path,size=16)=>`<svg width="${size}" height="${size}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${path}</svg>`,icons={up:svg('<path d="M12 19V5M5 12l7-7 7 7"/>'),comment:svg('<path d="M21 12a8 8 0 01-11.6 7.1L4 20l1-4.6A8 8 0 1121 12z"/>'),check:svg('<path d="M20 6L9 17l-5-5"/>'),checkCircle:svg('<circle cx="12" cy="12" r="9"/><path d="M8 12l3 3 5-6"/>'),lock:svg('<rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V7a4 4 0 018 0v4"/>'),clock:svg('<circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/>'),back:svg('<path d="M19 12H5M12 19l-7-7 7-7"/>'),bell:svg('<path d="M18 8a6 6 0 10-12 0c0 7-3 9-3 9h18s-3-2-3-9M13.7 21a2 2 0 01-3.4 0"/>')},styles=`
49
+ `;class YuvaDocsElement extends Base{static observedAttributes=["channel","server","locale","dir","page","page-title","identity-token"];root;inbox=null;pageUrl="";refused=!1;direction="ltr";#messages=messages;#client=null;#identity=null;#unfollow=null;#settingsFor="";#connected=!1;#accentColor="";constructor(){super();this.root=this.attachShadow({mode:"open"})}get channel(){return this.getAttribute("channel")}set channel(value){this.#attribute("channel",value)}get server(){return(this.getAttribute("server")||(scriptSrc?new URL(scriptSrc).origin:location.origin)).replace(/\/+$/,"")}set server(value){this.#attribute("server",value)}get locale(){return resolveLocale(this.getAttribute("locale"),navigator.language)}set locale(value){this.#attribute("locale",value)}get page(){return this.pageUrl||pageOf(this.getAttribute("page"))}set page(value){this.#attribute("page",value)}get pageTitle(){return this.getAttribute("page-title")||document.title}set pageTitle(value){this.#attribute("page-title",value)}#attribute(name,value){if(value===null||value===void 0||value==="")this.removeAttribute(name);else this.setAttribute(name,value)}setIdentityToken(source){if(this.#identity=source,this.#client?.setIdentityToken(()=>this.#identityToken()),this.#connected&&!this.refused)this.render()}connectedCallback(){this.#connected=!0,this.#unfollow??=followPage(()=>this.#syncPage()),this.pageUrl=pageOf(this.getAttribute("page")),this.#applyLocale(),this.#loadSettings(),this.render(),this.pageChanged()}disconnectedCallback(){this.#connected=!1,this.#unfollow?.(),this.#unfollow=null}attributeChangedCallback(name,previous,value){if(!this.#connected||previous===value)return;if(name==="channel"||name==="server"){this.#client?.reset(),this.#client=null,this.refused=!1,this.inbox=null,this.#settingsFor="",this.#loadSettings(),this.reset(),this.render(),this.pageChanged();return}if(name==="page")return this.#syncPage();if(name==="identity-token")this.#client?.setIdentityToken(()=>this.#identityToken());if(name==="locale"||name==="dir")this.#applyLocale();this.render()}t(descriptor){return translatePlain(this.#messages,descriptor,messages)}client(){return this.#client??=createYuvaClient2({server:this.server,channel:this.channel??"",identityToken:()=>this.#identityToken()}),this.#client}get identified(){return!!this.#identity||this.hasAttribute("identity-token")}get canWrite(){return this.identified||this.inbox?.chat.allow_anonymous!==!1}emit(type,detail){this.dispatchEvent(new CustomEvent(type,{detail,bubbles:!0,composed:!0}))}refusal(error,channelRequest=!0){let refused=error instanceof ApiError2&&(error.code==="origin_not_allowed"||error.code==="page_origin"||channelRequest&&error.status===404);if(refused&&!this.refused)this.refused=!0,console.warn(`Yuva: channel ${this.channel} is unknown or does not allow ${this.pageUrl}`),this.root.replaceChildren();return refused}errorText(error){let code=error instanceof ApiError2?error.code:"";if(code==="rate_limited")return this.t({id:"tzsBOP"});if(code==="network")return this.t({id:"GQVIIl"});if(code==="anonymous_not_allowed"||code==="invalid_identity_token")return this.t({id:"uuIskV"});return this.t({id:"tAL5wg"})}frame(css,...children){let style=el("style");style.textContent=baseStyles+css;let wrapper=el("div","frame");if(wrapper.dir=this.direction,wrapper.lang=this.locale,this.#accentColor)wrapper.style.setProperty("--yuva-accent",this.#accentColor),wrapper.style.setProperty("--yuva-on-accent",contrastOn(this.#accentColor));wrapper.append(...children);let focused=null;try{focused=this.root.activeElement}catch{}if(this.root.replaceChildren(style,wrapper),focused instanceof HTMLElement&&focused.isConnected)focused.focus({preventScroll:!0})}async#identityToken(){return this.#identity?await this.#identity()??null:this.getAttribute("identity-token")}#syncPage(){if(!this.#connected)return;let page=pageOf(this.getAttribute("page"));if(page===this.pageUrl)return;this.pageUrl=page,this.reset(),this.render(),this.pageChanged()}#applyLocale(){let locale=this.locale;this.#messages=catalogs[locale]??messages,this.direction=this.getAttribute("dir")==="rtl"?"rtl":this.getAttribute("dir")==="ltr"?"ltr":directionOf(locale)}#loadSettings(){let channel=this.channel,key=`${this.server} ${channel}`;if(!channel||this.#settingsFor===key)return;this.#settingsFor=key;let stored=readStored(channel).launcher;if(stored?.color)this.#accent(stored.color);let request=settings.get(key);if(!request)request=this.client().channelSettings(),settings.set(key,request),request.catch(()=>settings.delete(key));request.then((inbox)=>{if(this.channel!==channel)return;this.inbox=inbox;let launcher=launcherOf(inbox);if(launcher.color)this.#accent(launcher.color);if(writeStored(channel,{...readStored(channel),launcher}),!this.refused)this.render()}).catch((error)=>{if(this.channel===channel)this.refusal(error)})}#accent(color){if(!/^#[0-9a-f]{6}$/i.test(color))return;this.#accentColor=color}}var hashPrefix="#yuva-discussion-",cacheFor=60000,loads=new Map;function forget(prefix){for(let key of loads.keys())if(key.startsWith(prefix))loads.delete(key)}var svg=(path)=>`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${path}</svg>`,icons={up:svg('<path d="M12 19V5M5 12l7-7 7 7"/>'),comment:svg('<path d="M21 12a8 8 0 01-11.6 7.1L4 20l1-4.6A8 8 0 1121 12z"/>'),check:svg('<path d="M20 6L9 17l-5-5"/>'),lock:svg('<rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V7a4 4 0 018 0v4"/>'),clock:svg('<circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/>')},styles=`
54
50
  .frame { display: flex; flex-direction: column; gap: 16px; }
55
51
  :host { --yuva-success: #1a7f37; --yuva-warn: #9a6700; }
56
52
  @media (prefers-color-scheme: dark) { :host { --yuva-success: #3fb950; --yuva-warn: #d29922; } }
@@ -105,69 +101,16 @@ button { font: inherit; color: inherit; }
105
101
  .badge.locked { opacity: 0.75; }
106
102
  .empty { padding: 28px 16px; text-align: center; border: 1px dashed var(--yuva-border); border-radius: 12px; }
107
103
  .empty p + p { margin-block-start: 4px; }
108
- .thread { display: flex; flex-direction: column; gap: 12px; }
109
- .thread-head { display: flex; flex-direction: column; gap: 8px; }
110
- .post { display: flex; gap: 12px; padding: 14px; border: 1px solid var(--yuva-border); border-radius: 12px; }
111
- .post.accepted { border-color: var(--yuva-success); box-shadow: inset 0 0 0 1px var(--yuva-success); }
112
- .post.pending { border-style: dashed; }
113
- .side { display: flex; flex-direction: column; align-items: center; gap: 6px; }
114
- .vote {
115
- display: inline-flex; flex-direction: column; align-items: center; gap: 0; min-inline-size: 40px; padding: 4px 6px;
116
- border: 1px solid var(--yuva-border); border-radius: 8px; background: none; cursor: pointer; font-size: 0.85em; font-weight: 600;
117
- }
118
- .vote:hover:not(:disabled) { border-color: var(--yuva-accent); }
119
- .vote[aria-pressed="true"] { border-color: var(--yuva-accent); color: var(--yuva-accent); background: var(--yuva-soft); }
120
- .post-body { flex: 1; min-inline-size: 0; display: flex; flex-direction: column; gap: 8px; }
121
- .post-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 0.88em; }
122
- .name { font-weight: 600; }
123
- .answer-label { display: flex; align-items: center; gap: 6px; color: var(--yuva-success); font-weight: 600; font-size: 0.85em; }
124
- .tools { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
125
- .children { display: flex; flex-direction: column; gap: 10px; margin-block-start: 4px; padding-inline-start: 14px; border-inline-start: 2px solid var(--yuva-border); }
126
- .children .post { padding: 10px 0; border: 0; box-shadow: none; }
127
- .children .post + .post { border-block-start: 1px solid var(--yuva-border); border-radius: 0; }
128
- .deleted { font-style: italic; opacity: 0.65; }
129
104
  .notice { padding: 10px 12px; border-radius: 10px; background: var(--yuva-soft); font-size: 0.9em; display: flex; gap: 8px; align-items: flex-start; }
130
105
  .notice svg { flex-shrink: 0; margin-block-start: 3px; }
131
- .signin { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 14px; border: 1px solid var(--yuva-border); border-radius: 12px; }
132
- .composer { display: flex; flex-direction: column; border: 1px solid var(--yuva-border); border-radius: 12px; overflow: hidden; }
133
- .composer:focus-within { border-color: var(--yuva-accent); }
134
- .composer .ctabs { display: flex; gap: 4px; padding: 0 8px; border-block-end: 1px solid var(--yuva-border); }
135
- .composer .ctab { padding: 7px 10px; border: 0; border-block-end: 2px solid transparent; background: none; cursor: pointer; font-size: 0.88em; opacity: 0.75; margin-block-end: -1px; }
136
- .composer .ctab[aria-selected="true"] { border-block-end-color: var(--yuva-accent); font-weight: 600; opacity: 1; }
137
- .composer .ctab:focus-visible { outline: 2px solid var(--yuva-accent); outline-offset: -2px; }
138
- .composer textarea, .composer .preview { border: 0; border-radius: 0; min-block-size: 110px; padding: 10px 12px; }
139
- .composer textarea:focus-visible { outline: none; }
140
- .composer .preview { overflow-wrap: anywhere; }
141
- .composer .foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; padding: 8px 10px; border-block-start: 1px solid var(--yuva-border); }
142
- .composer .hint { font-size: 0.8em; opacity: 0.7; }
143
- .composer .buttons { display: flex; gap: 8px; margin-inline-start: auto; }
144
- .field-title { font-size: 1.05em; font-weight: 600; }
145
- .form { display: flex; flex-direction: column; gap: 10px; }
146
106
  .more { align-self: center; }
147
- .md { overflow-wrap: anywhere; }
148
- .md > :first-child { margin-block-start: 0; }
149
- .md > :last-child { margin-block-end: 0; }
150
- .md p, .md ul, .md ol, .md pre, .md blockquote, .md table { margin: 0 0 0.75em; }
151
- .md h1, .md h2, .md h3, .md h4, .md h5, .md h6 { margin: 0.9em 0 0.4em; font-size: 1em; font-weight: 600; }
152
- .md h1, .md h3 { font-size: 1.1em; }
153
- .md ul, .md ol { padding-inline-start: 1.5em; }
154
- .md a { color: var(--yuva-accent); }
155
- .md code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.88em; padding: 1px 5px; border-radius: 5px; background: var(--yuva-soft); }
156
- .md pre { padding: 10px 12px; border-radius: 8px; background: var(--yuva-soft); overflow-x: auto; }
157
- .md pre code { padding: 0; background: none; }
158
- .md blockquote { padding-inline-start: 12px; border-inline-start: 3px solid var(--yuva-border); opacity: 0.85; }
159
- .md table { border-collapse: collapse; display: block; overflow-x: auto; }
160
- .md th, .md td { border: 1px solid var(--yuva-border); padding: 4px 8px; }
161
- .md img { max-inline-size: 100%; }
162
- .md hr { border: 0; border-block-start: 1px solid var(--yuva-border); }
163
107
  .skeleton { block-size: 64px; border-radius: 12px; background: var(--yuva-soft); }
164
108
  @media (max-width: 560px) {
165
109
  .item { gap: 10px; padding: 12px; }
166
110
  .item .avatar { display: none; }
167
- .post { padding: 12px; gap: 10px; }
168
111
  .bar .send { inline-size: 100%; }
169
112
  }
170
- `;function hue(text){let hash=0;for(let char of text)hash=hash*31+char.charCodeAt(0)|0;return Math.abs(hash)%360}function excerptOf(html){let template=document.createElement("template");return template.innerHTML=html,(template.content.textContent??"").replace(/\s+/g," ").trim().slice(0,240)}class Composer{area=el("textarea");previewing=!1;constructor(rows){this.area.rows=rows,this.area.maxLength=20000,this.area.dir="auto"}get value(){return this.area.value.trim()}clear(){this.area.value="",this.previewing=!1}}class YuvaDiscussionsElement extends YuvaDocsElement{#view={kind:"list"};#sort="new";#items=[];#cursor;#listState="loading";#loadedFor="";#thread=null;#threadState="loading";#writer=null;#reader=null;#offReader=null;#busy=new Set;#notice="";#error="";#confirm="";#reply=new Composer(4);#inline=null;#edit=null;#draft=new Composer(6);#title=el("input");#focus="";constructor(){super();this.#title.maxLength=200,this.#title.dir="auto",this.#title.className="field-title";for(let area of[this.#reply.area,this.#draft.area])area.addEventListener("input",()=>this.#syncSend());this.#title.addEventListener("input",()=>this.#syncSend())}get discussions(){return this.#items}get reader(){return this.#reader}#hashChanged=()=>this.#fromHash();connectedCallback(){super.connectedCallback(),window.addEventListener("hashchange",this.#hashChanged),this.#watchReader()}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("hashchange",this.#hashChanged),this.#offReader?.(),this.#offReader=null}attributeChangedCallback(name,previous,value){if(super.attributeChangedCallback(name,previous,value),previous===value||!this.isConnected)return;if(name==="channel"||name==="server")this.#offReader?.(),this.#offReader=null,this.#watchReader();else if(name==="identity-token")this.#refreshWriter(!0)}setIdentityToken(source){super.setIdentityToken(source),this.#refreshWriter(!0)}#watchReader(){if(!this.channel||this.#offReader)return;let client=this.client();this.#reader=client.reader,this.#offReader=client.on("reader",(reader)=>{this.#reader=reader,this.emit("yuva-reader",reader?reader.reader:null),this.#refreshWriter(!0)}),this.#refreshWriter(!1)}async#refreshWriter(reload){if(!this.channel)return;let writer=await this.client().discussionWriter().catch(()=>null),changed=writer!==this.#writer;if(this.#writer=writer,reload&&changed){if(this.#loadedFor="",this.#load(!1),this.#view.kind==="thread")this.#open(this.#view.id,!1)}this.render()}reset(){this.#view={kind:"list"},this.#items=[],this.#cursor=void 0,this.#listState="loading",this.#loadedFor="",this.#thread=null,this.#notice="",this.#error="",this.#confirm="",this.#inline=null,this.#edit=null,this.#reply.clear()}pageChanged(){this.#load(!1),this.#fromHash()}#linked(){let hash=location.hash;return hash.startsWith(hashPrefix)?decodeURIComponent(hash.slice(hashPrefix.length)):""}#fromHash(){let id=this.#linked();if(!id||!this.channel||this.refused)return;if(this.#view.kind==="thread"&&this.#view.id===id)return;this.#inline=null,this.#edit=null,this.#confirm="",this.#open(id,!0),this.scrollIntoView({block:"start"})}reload(){return this.#load(!0)}open(id){return this.#open(id,!0)}signIn(){return this.#error="",this.client().readerSignIn().then(()=>{return}).catch((error)=>{let code=error instanceof ApiError2?error.code:"";if(code==="sign_in_cancelled")return;this.#error=code==="popup_blocked"?this.t({id:"nW3go1"}):this.#failure(error),this.render()})}signOut(){return this.client().readerSignOut()}get#prefix(){return`${this.server} ${this.channel} ${this.pageUrl} `}async#load(force,more=!1){let page=this.pageUrl;if(!this.channel||!page||this.refused)return;let reader=this.client().reader,auth=reader?reader.token.slice(-12):this.#writer??"-",key=`${this.#prefix}${this.#sort} ${auth}`;if(!force&&!more&&this.#loadedFor===key)return;this.#loadedFor=key;let request;if(more)request=this.client().listDiscussions(page,{sort:this.#sort,cursor:this.#cursor});else{let load=loads.get(key);if(force||!load||Date.now()-load.at>cacheFor){load={at:Date.now(),request:this.client().listDiscussions(page,{sort:this.#sort})},loads.set(key,load);let current=load;load.request.catch(()=>loads.get(key)===current&&loads.delete(key))}if(request=load.request,!this.#items.length)this.#listState="loading"}if(more)this.#busy.add("more");this.render();try{let result=await request;if(this.#loadedFor!==key)return;this.#items=more?[...this.#items,...result.items.filter((d)=>!this.#items.some((i)=>i.id===d.id))]:result.items,this.#cursor=result.next_cursor,this.#listState="ready"}catch(error){if(this.#loadedFor!==key||this.refusal(error))return;if(!more)this.#loadedFor="";if(this.#listState=error instanceof ApiError2&&error.code==="discussions_off"?"off":more?"ready":"error",more)this.#error=this.#failure(error)}finally{this.#busy.delete("more")}this.render()}async#open(id,focus){let page=this.pageUrl,known=this.#thread?.discussion.id===id?this.#thread:null;this.#view={kind:"thread",id};let listed=this.#items.find((d)=>d.id===id);if(this.#thread=known??(listed?{discussion:listed,posts:[]}:null),this.#threadState=known?"ready":"loading",focus)this.#notice=known?this.#notice:"",this.#error="",this.#focus="thread-title";this.render();try{let detail=await this.client().getDiscussion(id);if(this.pageUrl!==page||this.#view.kind!=="thread"||this.#view.id!==id)return;let titled=!!this.#thread;if(this.#thread=detail,this.#threadState="ready",focus&&!titled)this.#focus="thread-title";this.#items=this.#items.map((d)=>d.id===id?detail.discussion:d)}catch(error){if(this.pageUrl!==page||this.#view.kind!=="thread"||this.#view.id!==id)return;if(this.refusal(error,!1))return;this.#threadState=error instanceof ApiError2&&error.status===404?"missing":"error"}this.render()}#toList(){if(this.#linked()){let url=new URL(location.href);url.hash="",history.replaceState(history.state,"",url.href)}this.#view={kind:"list"},this.#inline=null,this.#edit=null,this.#confirm="",this.#error="",this.#focus=this.#thread?`open-${this.#thread.discussion.id}`:"start",this.render(),this.#load(!1)}#failure(error){let code=error instanceof ApiError2?error.code:"";if(code==="sign_in_required")return this.t({id:"LwDe8g"});if(code==="discussion_locked")return this.t({id:"KEjhwb"});if(code==="edit_window_closed")return this.t({id:"b_f4xj"});if(code==="discussions_off")return this.t({id:"tayT8P"});if(code==="forbidden")return this.t({id:"8Ekoev"});if(code==="validation_failed")return this.t({id:"Su3Vyp"});return this.errorText(error)}async#act(key,action){if(this.#busy.has(key))return;this.#busy.add(key),this.#error="",this.render();try{return await action()}catch(error){if(!this.refusal(error,!1))this.#error=this.#failure(error);if(error instanceof ApiError2&&error.code==="sign_in_required")this.#refreshWriter(!1);return}finally{this.#busy.delete(key),this.render()}}async#start(){let title=this.#title.value.trim(),body=this.#draft.value;if(title.length<3||!body)return;let page=this.pageUrl,discussion=await this.#act("start",()=>this.client().startDiscussion({page_url:page,page_title:this.pageTitle||void 0,title,body}));if(!discussion)return;if(forget(this.#prefix),this.emit("yuva-discussion",{page,discussion_id:discussion.id,state:discussion.state}),this.pageUrl!==page)return;this.#title.value="",this.#draft.clear(),this.#items=[discussion,...this.#items.filter((d)=>d.id!==discussion.id)],this.#notice=discussion.state==="pending"?this.t({id:"NrGspR"}):"",this.#thread={discussion,posts:[]},await this.#open(discussion.id,!0)}async#send(composer,parent){let thread=this.#thread,body=composer.value;if(!thread||!body)return;let page=this.pageUrl,id=thread.discussion.id,post=await this.#act(parent?`reply-${parent}`:"reply",()=>this.client().replyToDiscussion(id,{body,parent_post_id:parent}));if(!post)return;if(forget(this.#prefix),this.emit("yuva-post",{page,discussion_id:id,post_id:post.id,state:post.state}),composer.clear(),parent)this.#inline=null;if(this.#notice=post.state==="pending"?this.t({id:"YZayoP"}):"",this.#thread?.discussion.id===id)this.#thread={...this.#thread,posts:[...this.#thread.posts,post]},this.#focus=`post-${post.id}`,this.render(),this.#open(id,!1)}async#vote(post,opening){if(!this.#writer)return void this.signIn();let updated=await this.#act(`vote-${post.id}`,()=>this.client().voteDiscussionPost(post.id,!post.voted));if(!updated||!this.#thread)return;if(forget(this.#prefix),opening){let discussion={...this.#thread.discussion,votes:updated.votes,voted:updated.voted};this.#thread={...this.#thread,discussion},this.#items=this.#items.map((d)=>d.id===discussion.id?discussion:d)}else this.#thread={...this.#thread,posts:this.#thread.posts.map((p)=>p.id===updated.id?{...p,...updated}:p)}}async#follow(){let thread=this.#thread;if(!thread)return;if(!this.#writer)return void this.signIn();let following=!thread.discussion.following;if(await this.#act("follow",()=>this.client().followDiscussion(thread.discussion.id,following).then(()=>!0))&&this.#thread?.discussion.id===thread.discussion.id)this.#thread={...this.#thread,discussion:{...this.#thread.discussion,following}}}async#accept(post){let thread=this.#thread;if(!thread)return;let discussion=await this.#act(`accept-${post?.id??"clear"}`,()=>this.client().acceptDiscussionAnswer(thread.discussion.id,post?.id??null));if(!discussion)return;forget(this.#prefix),this.#focus=post?`post-${post.id}`:"thread-title",await this.#open(discussion.id,!1)}async#saveEdit(){let edit=this.#edit,thread=this.#thread;if(!edit||!thread)return;let body=edit.composer.value,opening=!edit.post,title=edit.title.value.trim();if(!body||opening&&title.length<3)return;let postId=edit.post?.id??thread.discussion.opening_post_id;if(!await this.#act(`edit-${postId}`,()=>this.client().editDiscussionPost(postId,opening?{body,title}:{body})))return;forget(this.#prefix),this.#edit=null,this.#focus=opening?"thread-title":`post-${postId}`,await this.#open(thread.discussion.id,!1)}async#delete(postId,opening){let thread=this.#thread;if(!thread)return;let done=await this.#act(`delete-${postId}`,()=>this.client().deleteDiscussionPost(postId).then(()=>!0));if(this.#confirm="",!done)return;if(forget(this.#prefix),opening)try{await this.client().getDiscussion(thread.discussion.id)}catch{return this.#items=this.#items.filter((d)=>d.id!==thread.discussion.id),this.#thread=null,this.#toList()}await this.#open(thread.discussion.id,!1)}#syncSend(){for(let button of this.root.querySelectorAll("[data-requires]")){let needs=button.dataset.requires,busy=this.#busy.has(button.dataset.busy??""),ok=needs==="start"?this.#title.value.trim().length>=3&&this.#draft.value!=="":needs==="reply"?this.#reply.value!=="":needs==="inline"?!!this.#inline?.composer.value:needs==="edit"?!!this.#edit?.composer.value&&(!!this.#edit.post||this.#edit.title.value.trim().length>=3):!0;button.disabled=busy||!ok}}get#mode(){return this.inbox?.chat.discussions??"moderated"}#button(className,text,key,onClick,html=""){let button=el("button",className);if(button.type="button",html)button.innerHTML=html;return button.append(text),button.dataset.key=key,button.addEventListener("click",onClick),button}#authorName(author){if(author.deleted)return author.kind==="member"?this.t({id:"-UxBoG"}):this.t({id:"FMWGhb"});if(author.kind==="anonymous")return this.t({id:"D9CFV5"});return author.name||(author.kind==="member"?this.t({id:"nLqMRA"}):this.t({id:"zmA6sS"}))}#avatar(author,small=!1){let avatar=el("span",`avatar${small?" small":""}`,author.deleted?"":author.initials||"?");if(avatar.setAttribute("aria-hidden","true"),author.deleted||author.kind==="anonymous")avatar.classList.add("gone");else if(author.kind==="member")avatar.classList.add("team");else avatar.style.setProperty("--avatar",`hsl(${hue(author.name||author.initials)} 45% 42%)`);return avatar}#badge(kind,short=!1){let text=kind==="answered"?this.t({id:"GqCA_t"}):kind==="pending"?short?this.t({id:"UbRKMZ"}):this.t({id:"lWv8id"}):kind==="team"?this.t({id:"KM6m8p"}):this.t({id:"G2fuEb"}),badge=el("span",`badge ${kind}`);if(kind!=="team")badge.innerHTML=kind==="answered"?icons.check:kind==="pending"?icons.clock:icons.lock;return badge.append(text),badge}#time(value){let time=el("time");time.dateTime=value;let date=new Date(value);time.title=date.toLocaleString(this.locale);let seconds=(date.getTime()-Date.now())/1000,steps=[["second",60],["minute",60],["hour",24],["day",30],["month",12],["year",1/0]],amount=seconds;for(let[unit,size]of steps){if(Math.abs(amount)<size){time.textContent=unit==="second"?this.t({id:"xOTzt5"}):new Intl.RelativeTimeFormat(this.locale,{numeric:"auto"}).format(Math.round(amount),unit);break}amount/=size}return time}#md(html){let body=el("div","md");body.dir="auto",body.innerHTML=html;for(let link of body.querySelectorAll("a[href]"))link.setAttribute("target","_blank");return body}#composer(composer,options){let box=el("div","composer"),tabs=el("div","ctabs");tabs.setAttribute("role","tablist"),tabs.setAttribute("aria-label",options.label);let panelId=`p-${options.focusKey}`,write=this.#button("ctab",this.t({id:"i4_LY_"}),`${options.focusKey}-write`,()=>{composer.previewing=!1,this.#focus=options.focusKey,this.render()}),show=this.#button("ctab",this.t({id:"rdUucN"}),`${options.focusKey}-preview`,()=>{composer.previewing=!0,this.render()});for(let[tab,selected]of[[write,!composer.previewing],[show,composer.previewing]])tab.setAttribute("role","tab"),tab.setAttribute("aria-selected",String(selected)),tab.setAttribute("aria-controls",panelId),tab.tabIndex=selected?0:-1,tab.addEventListener("keydown",(event)=>{if(event.key!=="ArrowLeft"&&event.key!=="ArrowRight")return;event.preventDefault(),composer.previewing=!composer.previewing,this.#focus=`${options.focusKey}-${composer.previewing?"preview":"write"}`,this.render()});if(tabs.append(write,show),box.append(tabs),composer.previewing){let panel=el("div","preview md");if(panel.dir="auto",panel.id=panelId,panel.setAttribute("role","tabpanel"),panel.setAttribute("aria-label",this.t({id:"rdUucN"})),composer.value)panel.append(preview(composer.area.value));else panel.append(el("p","muted",this.t({id:"3PqJQG"})));box.append(panel)}else composer.area.id=panelId,composer.area.placeholder=options.placeholder,composer.area.setAttribute("aria-label",options.label),composer.area.dataset.key=options.focusKey,composer.area.disabled=this.#busy.has(options.busy),composer.area.onkeydown=(event)=>{if(event.key==="Enter"&&(event.metaKey||event.ctrlKey))event.preventDefault(),options.onSubmit();else if(event.key==="Escape"&&options.onCancel)options.onCancel()},box.append(composer.area);let foot=el("div","foot");foot.append(el("span","hint",this.t({id:"Vwy_nT"})));let buttons=el("div","buttons");if(options.onCancel)buttons.append(this.#button("ghost",this.t({id:"dEgA5A"}),`${options.focusKey}-cancel`,options.onCancel));let submit=this.#button("send",this.#busy.has(options.busy)?this.t({id:"Sad2tK"}):options.submit,`${options.focusKey}-submit`,options.onSubmit);return submit.dataset.requires=options.requires,submit.dataset.busy=options.busy,buttons.append(submit),foot.append(buttons),box.append(foot),box}#signInBox(text){let box=el("div","signin");return box.append(el("p","",text)),box.append(this.#button("send",this.t({id:"5lWFkC"}),"sign-in-box",()=>void this.signIn())),box}#header(){let head=el("div","head");head.append(el("h2","",this.t({id:"7oGBMv"})));let who=el("div","who"),reader=this.#reader;if(reader){let name=reader.reader.name||this.t({id:"zmA6sS"});who.append(this.#avatar({kind:"reader",name,initials:reader.reader.initials,deleted:!1},!0)),who.append(el("span","",name)),who.append(this.#button("plain",this.t({id:"fcWrnU"}),"sign-out",()=>void this.signOut()))}else if(!this.#writer&&this.#mode!=="off")who.append(this.#button("ghost",this.t({id:"5lWFkC"}),"sign-in",()=>void this.signIn()));return head.append(who),head}#listView(){let nodes=[],bar=el("div","bar"),tabs=el("div","tabs");tabs.setAttribute("role","tablist"),tabs.setAttribute("aria-label",this.t({id:"78dEKp"}));let sorts=[["new",this.t({id:"isRobC"})],["top",this.t({id:"WWy8TN"})],["unanswered",this.t({id:"2lF8Zj"})]];sorts.forEach(([sort,label],index)=>{let tab=this.#button("tab",label,`sort-${sort}`,()=>this.#setSort(sort));tab.setAttribute("role","tab"),tab.setAttribute("aria-selected",String(this.#sort===sort)),tab.setAttribute("aria-controls","yuva-discussion-list"),tab.tabIndex=this.#sort===sort?0:-1,tab.addEventListener("keydown",(event)=>{let step=event.key==="ArrowRight"?1:event.key==="ArrowLeft"?-1:0;if(!step)return;event.preventDefault();let forward=this.direction==="rtl"?-step:step,next=sorts[(index+forward+sorts.length)%sorts.length];if(next)this.#setSort(next[0])}),tabs.append(tab)});let start=this.#button("send",this.t({id:"z1qf6l"}),"start",()=>{this.#view={kind:"new"},this.#error="",this.#notice="",this.#focus="new-title",this.render()});if(bar.append(tabs,start),nodes.push(bar),this.#listState==="loading"&&!this.#items.length){let skeleton=el("div","skeleton");return skeleton.setAttribute("aria-busy","true"),skeleton.setAttribute("aria-label",this.t({id:"pzatAP"})),nodes.push(skeleton),nodes}if(this.#listState==="error"&&!this.#items.length){let box=el("div","empty");box.append(el("p","",this.t({id:"MDmQKn"})));let retry=this.#button("ghost",this.t({id:"KDw4GX"}),"retry",()=>void this.#load(!0));return retry.style.marginBlockStart="8px",box.append(retry),nodes.push(box),nodes}if(!this.#items.length){let box=el("div","empty");if(box.append(el("p","",this.#sort==="unanswered"?this.t({id:"twEQ41"}):this.t({id:"rpfOwz"}))),this.#sort!=="unanswered")box.append(el("p","muted",this.t({id:"b6Orhy"})));return nodes.push(box),nodes}let list=el("ul","list");list.id="yuva-discussion-list",list.setAttribute("aria-label",this.t({id:"j-3eim"})),list.setAttribute("aria-busy",String(this.#listState==="loading"));for(let discussion of this.#items){let item=el("li","item");item.append(this.#avatar(discussion.author));let main=el("div","main"),title=this.#button("title",discussion.title,`open-${discussion.id}`,()=>void this.#open(discussion.id,!0));title.dir="auto",main.append(title);let excerpt=discussion.deleted?"":excerptOf(discussion.body_html);if(excerpt){let text=el("p","excerpt",excerpt);text.dir="auto",main.append(text)}let meta=el("div","meta");if(meta.append(el("span","",this.#authorName(discussion.author)),this.#time(discussion.created_at)),discussion.author.kind==="member"&&!discussion.author.deleted)meta.append(this.#badge("team"));if(discussion.answer_post_id)meta.append(this.#badge("answered"));if(discussion.state==="pending")meta.append(this.#badge("pending"));if(discussion.locked)meta.append(this.#badge("locked"));main.append(meta);let counts=el("div","counts"),votes=el("span","count");votes.innerHTML=icons.up,votes.append(String(discussion.votes)),votes.setAttribute("aria-label",this.t({id:"8ntmc1",values:{0:discussion.votes}})),votes.title=votes.getAttribute("aria-label")??"";let replies=el("span","count");replies.innerHTML=icons.comment,replies.append(String(discussion.reply_count)),replies.setAttribute("aria-label",this.t({id:"Hw3P48",values:{0:discussion.reply_count}})),replies.title=replies.getAttribute("aria-label")??"",counts.append(votes,replies),item.append(main,counts),list.append(item)}if(nodes.push(list),this.#cursor){let more=this.#button("ghost more",this.#busy.has("more")?this.t({id:"Pwqkdw"}):this.t({id:"fMPkxb"}),"more",()=>void this.#load(!1,!0));more.disabled=this.#busy.has("more"),nodes.push(more)}return nodes}#setSort(sort){if(this.#sort===sort)return;this.#sort=sort,this.#items=[],this.#cursor=void 0,this.#listState="loading",this.#focus=`sort-${sort}`,this.#load(!1)}#back(){let back=this.#button("plain",this.t({id:"3CApMv"}),"back",()=>this.#toList(),icons.back);back.style.alignSelf="flex-start",back.style.display="inline-flex",back.style.gap="6px",back.style.alignItems="center";let arrow=back.querySelector("svg");if(arrow&&this.direction==="rtl")arrow.style.transform="scaleX(-1)";return back}#newView(){let form=el("div","form");if(form.append(el("h3","",this.t({id:"z1qf6l"}))),!this.#writer)return form.append(this.#signInBox(this.t({id:"99w-GZ"}))),[this.#back(),form];if(this.#title.placeholder=this.t({id:"MHrjPM"}),this.#title.setAttribute("aria-label",this.t({id:"MHrjPM"})),this.#title.dataset.key="new-title",this.#title.disabled=this.#busy.has("start"),form.append(this.#title),form.append(this.#composer(this.#draft,{label:this.t({id:"PN38hZ"}),placeholder:this.t({id:"NjUiZ4"}),submit:this.t({id:"n5vqdp"}),busy:"start",requires:"start",focusKey:"new-body",onSubmit:()=>void this.#start(),onCancel:()=>this.#toList()})),this.#mode==="moderated"&&this.#reader)form.append(el("p","muted",this.t({id:"RqsQKK"})));return[this.#back(),form]}#editable(post){return!!post.mine&&!this.#thread?.discussion.locked&&Date.now()-Date.parse(post.created_at)<editWindow}#postTools(post,top){let thread=this.#thread;if(!thread)return null;let discussion=thread.discussion,opening=!post,id=post?.id??discussion.opening_post_id,mine=opening?!!discussion.mine:!!post.mine,deleted=opening?!!discussion.deleted:post.deleted,tools=el("div","tools");if(deleted)return null;if(!opening&&top&&!discussion.locked&&this.#writer&&post.state==="published")tools.append(this.#button("plain",this.t({id:"ImOQa9"}),`reply-to-${post.id}`,()=>{this.#inline=this.#inline?.target===top.id?this.#inline:{target:top.id,composer:new Composer(3)},this.#inline.composer.area.oninput=()=>this.#syncSend(),this.#focus=`inline-${top.id}`,this.render()}));if(!opening&&discussion.mine&&!post.parent_post_id&&post.state==="published"&&!discussion.locked){let accepted=discussion.answer_post_id===post.id,accept=this.#button("plain",accepted?this.t({id:"4-S4QM"}):this.t({id:"jhu92n"}),`accept-${post.id}`,()=>void this.#accept(accepted?null:post),accepted?"":icons.checkCircle);accept.style.display="inline-flex",accept.style.gap="4px",accept.style.alignItems="center",accept.disabled=this.#busy.has(`accept-${post.id}`)||this.#busy.has("accept-clear"),tools.append(accept)}if(mine&&this.#editable(opening?discussion:post))tools.append(this.#button("plain",this.t({id:"ePK91l"}),`edit-${id}`,()=>{let composer=new Composer(opening?6:4);composer.area.value=opening?discussion.body:post.body,composer.area.oninput=()=>this.#syncSend();let title=el("input");title.className="field-title",title.maxLength=200,title.dir="auto",title.value=discussion.title,title.oninput=()=>this.#syncSend(),this.#edit={post,composer,title},this.#focus=opening?"edit-title":`edit-body-${id}`,this.render()}));if(mine)if(this.#confirm===id){let yes=this.#button("plain danger",this.t({id:"cnGeoo"}),`delete-yes-${id}`,()=>void this.#delete(id,opening));yes.disabled=this.#busy.has(`delete-${id}`),tools.append(el("span","muted",opening?this.t({id:"rAl91-"}):this.t({id:"Klsidc"})),yes,this.#button("plain",this.t({id:"PZ_kxo"}),`delete-no-${id}`,()=>{this.#confirm="",this.#focus=`delete-${id}`,this.render()}))}else tools.append(this.#button("plain",this.t({id:"cnGeoo"}),`delete-${id}`,()=>{this.#confirm=id,this.#focus=`delete-no-${id}`,this.render()}));return tools.childElementCount?tools:null}#voteButton(target,opening){let vote=this.#button("vote",String(target.votes),`vote-${target.id}`,()=>void this.#vote(target,opening),icons.up);return vote.setAttribute("aria-pressed",String(!!target.voted)),vote.setAttribute("aria-label",target.voted?this.t({id:"OVijcR",values:{0:target.votes}}):this.t({id:"dNOvhg",values:{0:target.votes}})),vote.disabled=!!target.mine||!!this.#thread?.discussion.locked||this.#busy.has(`vote-${target.id}`),vote}#postCard(post,top,children=[]){let accepted=this.#thread.discussion.answer_post_id===post.id,card=el("article",`post${accepted?" accepted":""}${post.state==="pending"?" pending":""}`);card.dataset.key=`post-${post.id}`,card.tabIndex=-1,card.setAttribute("aria-label",this.#authorName(post.author));let side=el("div","side");if(!post.deleted)side.append(this.#voteButton(post,!1));if(!top||top.id===post.id)card.append(side);let body=el("div","post-body");if(accepted){let label=el("div","answer-label");label.innerHTML=icons.checkCircle,label.append(this.t({id:"y-KXxN"})),body.append(label)}if(body.append(this.#postHead(post.author,post.created_at,post.edited_at,post.state,post.deleted)),this.#edit?.post?.id===post.id)body.append(this.#editForm());else if(post.deleted)body.append(el("p","deleted",this.t({id:"HkXOWm"})));else body.append(this.#md(post.body_html));let tools=this.#postTools(post,top);if(tools)body.append(tools);if(children.length||this.#inline?.target===post.id){let nested=el("div","children");for(let child of children)nested.append(this.#postCard(child,post));if(this.#inline?.target===post.id){let inline=this.#inline;nested.append(this.#composer(inline.composer,{label:this.t({id:"F_vGso"}),placeholder:this.t({id:"2Hlmdt"}),submit:this.t({id:"ImOQa9"}),busy:`reply-${post.id}`,requires:"inline",focusKey:`inline-${post.id}`,onSubmit:()=>void this.#send(inline.composer,post.id),onCancel:()=>{this.#inline=null,this.#focus=`reply-to-${post.id}`,this.render()}}))}body.append(nested)}return card.append(body),card}#postHead(author,created,edited,state,deleted){let head=el("div","post-head");if(!deleted){if(head.append(this.#avatar(author,!0),el("span","name",this.#authorName(author))),author.kind==="member"&&!author.deleted)head.append(this.#badge("team"))}if(head.append(this.#time(created)),edited&&!deleted)head.append(el("span","muted",this.t({id:"k4b5_X"})));if(state==="pending")head.append(this.#badge("pending"));return head}#editForm(){let edit=this.#edit,form=el("div","form");if(!edit.post)edit.title.setAttribute("aria-label",this.t({id:"MHrjPM"})),edit.title.dataset.key="edit-title",form.append(edit.title);let id=edit.post?.id??this.#thread.discussion.opening_post_id;return form.append(this.#composer(edit.composer,{label:this.t({id:"qzVesX"}),placeholder:"",submit:this.t({id:"tfDRzk"}),busy:`edit-${id}`,requires:"edit",focusKey:`edit-body-${id}`,onSubmit:()=>void this.#saveEdit(),onCancel:()=>{this.#edit=null,this.#focus=`edit-${id}`,this.render()}})),form}#threadView(){let nodes=[this.#back()],thread=this.#thread;if(!thread||this.#threadState==="missing"){let box=el("div","empty");return box.append(el("p","",this.#threadState==="loading"?this.t({id:"Pwqkdw"}):this.t({id:"VGqKyv"}))),nodes.push(box),nodes}let discussion=thread.discussion,view=el("div","thread"),head=el("div","thread-head");if(this.#edit&&!this.#edit.post)head.append(this.#postHead(discussion.author,discussion.created_at,discussion.edited_at,discussion.state,!1)),head.append(this.#editForm()),view.append(head);else{let title=el("h3","",discussion.title);title.dir="auto",title.tabIndex=-1,title.dataset.key="thread-title",head.append(title);let meta=el("div","meta");if(discussion.answer_post_id)meta.append(this.#badge("answered"));if(discussion.state==="pending")meta.append(this.#badge("pending"));if(discussion.locked)meta.append(this.#badge("locked"));if(meta.childElementCount)head.append(meta);view.append(head);let opening=el("article",`post${discussion.state==="pending"?" pending":""}`),side=el("div","side");if(!discussion.deleted)side.append(this.#voteButton({id:discussion.opening_post_id,votes:discussion.votes,voted:discussion.voted,mine:discussion.mine},!0));let body=el("div","post-body");body.append(this.#postHead(discussion.author,discussion.created_at,discussion.edited_at,discussion.state,!!discussion.deleted)),body.append(discussion.deleted?el("p","deleted",this.t({id:"8wRl7c"})):this.#md(discussion.body_html));let tools=this.#postTools(null,null);if(tools)body.append(tools);opening.append(side,body),view.append(opening)}let actions=el("div","bar"),follow=this.#button("ghost",discussion.following?this.t({id:"y6sq5j"}):this.t({id:"MKEPCY"}),"follow",()=>void this.#follow(),icons.bell);follow.setAttribute("aria-pressed",String(!!discussion.following)),follow.title=this.t({id:"Kl3TuI"}),follow.disabled=this.#busy.has("follow");let count=el("span","muted",this.t({id:"Hw3P48",values:{0:discussion.reply_count}}));if(actions.append(count,follow),view.append(actions),this.#threadState==="loading"&&!thread.posts.length&&discussion.reply_count>0){let skeleton=el("div","skeleton");skeleton.setAttribute("aria-busy","true"),skeleton.setAttribute("aria-label",this.t({id:"Pwqkdw"})),view.append(skeleton)}let tops=thread.posts.filter((p)=>!p.parent_post_id),replies=el("div","thread");for(let top of tops)replies.append(this.#postCard(top,top,thread.posts.filter((p)=>p.parent_post_id===top.id)));if(tops.length)view.append(replies);if(this.#notice)view.append(this.#noticeBox(this.#notice));if(discussion.locked)view.append(this.#noticeBox(this.t({id:"JfAIiv"}),icons.lock));else if(!this.#writer)view.append(this.#signInBox(this.t({id:"PL0621"})));else view.append(this.#composer(this.#reply,{label:this.t({id:"F_vGso"}),placeholder:this.t({id:"2Hlmdt"}),submit:this.t({id:"ImOQa9"}),busy:"reply",requires:"reply",focusKey:"reply",onSubmit:()=>void this.#send(this.#reply)}));return nodes.push(view),nodes}#noticeBox(text,icon=icons.clock){let box=el("div","notice");return box.setAttribute("role","status"),box.innerHTML=icon,box.append(el("p","",text)),box}render(){if(this.refused||!this.channel){this.root.replaceChildren();return}let focused="";try{focused=this.root.activeElement?.dataset?.key??""}catch{}let children=[this.#header()];if(this.#mode==="off"||this.#listState==="off")children.push(el("p","muted",this.t({id:"tayT8P"})));else if(this.#view.kind==="thread")children.push(...this.#threadView());else if(this.#view.kind==="new")children.push(...this.#newView());else{if(this.#notice)children.push(this.#noticeBox(this.#notice));children.push(...this.#listView())}if(this.#error){let error=el("p","error",this.#error);error.setAttribute("role","alert"),children.push(error)}this.frame(styles,...children),this.#syncSend();let wanted=this.#focus;this.#focus="";let key=wanted||focused;if(!key)return;let active=null;try{active=this.root.activeElement}catch{}if(active instanceof HTMLElement&&active.dataset.key===key)return;[...this.root.querySelectorAll("[data-key]")].find((node)=>node.dataset.key===key)?.focus({preventScroll:!wanted})}}var maxRemembered=500,thumb=(down)=>`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"${down?' style="transform:scaleY(-1)"':""}><path d="M7 10v11H3V10zM7 10l4-8a3 3 0 013 3v4h6a2 2 0 012 2.3l-1.4 8A2 2 0 0118.6 21H7"/></svg>`,styles2=`
113
+ `;function hue(text){let hash=0;for(let char of text)hash=hash*31+char.charCodeAt(0)|0;return Math.abs(hash)%360}function excerptOf(html){let template=document.createElement("template");return template.innerHTML=html,(template.content.textContent??"").replace(/\s+/g," ").trim().slice(0,240)}class YuvaDiscussionsElement extends YuvaDocsElement{static loadThread;#s={view:{kind:"list"},items:[],thread:null,threadState:"loading",writer:null,reader:null,busy:new Set,notice:"",error:"",confirm:"",focus:""};#sort="new";#cursor;#listState="loading";#loadedFor="";#offReader=null;#thread=null;#threadLoad=null;#threadStyles="";get discussions(){return this.#s.items}get reader(){return this.#s.reader}#hashChanged=()=>this.#fromHash();connectedCallback(){super.connectedCallback(),window.addEventListener("hashchange",this.#hashChanged),this.#watchReader()}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("hashchange",this.#hashChanged),this.#offReader?.(),this.#offReader=null}attributeChangedCallback(name,previous,value){if(super.attributeChangedCallback(name,previous,value),previous===value||!this.isConnected)return;if(name==="channel"||name==="server")this.#offReader?.(),this.#offReader=null,this.#watchReader();else if(name==="identity-token")this.#refreshWriter(!0)}setIdentityToken(source){super.setIdentityToken(source),this.#refreshWriter(!0)}#watchReader(){if(!this.channel||this.#offReader)return;let client=this.client();this.#s.reader=client.reader,this.#offReader=client.on("reader",(reader)=>{this.#s.reader=reader,this.emit("yuva-reader",reader?reader.reader:null),this.#refreshWriter(!0)}),this.#refreshWriter(!1)}async#refreshWriter(reload){if(!this.channel)return;let writer=await this.client().discussionWriter().catch(()=>null),changed=writer!==this.#s.writer;if(this.#s.writer=writer,reload&&changed){if(this.#loadedFor="",this.#load(!1),this.#s.view.kind==="thread")this.#open(this.#s.view.id,!1)}this.render()}reset(){let s=this.#s;s.view={kind:"list"},s.items=[],this.#cursor=void 0,this.#listState="loading",this.#loadedFor="",s.thread=null,s.notice="",s.error="",s.confirm="",this.#thread?.reset()}pageChanged(){this.#load(!1),this.#fromHash()}#linked(){let hash=location.hash;return hash.startsWith(hashPrefix)?decodeURIComponent(hash.slice(hashPrefix.length)):""}#fromHash(){let id=this.#linked();if(!id||!this.channel||this.refused)return;if(this.#s.view.kind==="thread"&&this.#s.view.id===id)return;this.#thread?.close(),this.#s.confirm="",this.#open(id,!0),this.scrollIntoView({block:"start"})}#prefetchOn(button){let prefetch=()=>void this.#loadThread();button.addEventListener("pointerenter",prefetch,{once:!0}),button.addEventListener("focus",prefetch,{once:!0})}#loadThread(){return this.#threadLoad??=YuvaDiscussionsElement.loadThread().then((module)=>{if(this.#threadStyles=module.styles,this.#thread=module.createThread(this.#host),this.#s.view.kind!=="list")this.render();return this.#thread},()=>{if(this.#threadLoad=null,this.#s.view.kind!=="list")this.#s.view={kind:"list"},this.#s.error=this.t({id:"D16wQE"}),this.render();return null}),this.#threadLoad}#host=this.#makeHost();#makeHost(){return{s:this.#s,icons,root:this.root,locale:()=>this.locale,direction:()=>this.direction,page:()=>this.pageUrl,pageTitle:()=>this.pageTitle,mode:()=>this.#mode,client:()=>this.client(),render:()=>this.render(),emit:(type,detail)=>this.emit(type,detail),act:(key,action)=>this.#act(key,action),signIn:()=>this.signIn(),open:(id,focus)=>this.#open(id,focus),toList:()=>this.#toList(),forget:()=>forget(this.#prefix),button:(className,text,key,onClick,html)=>this.#button(className,text,key,onClick,html),avatar:(author,small)=>this.#avatar(author,small),badge:(kind,short)=>this.#badge(kind,short),time:(value)=>this.#time(value),authorName:(author)=>this.#authorName(author),noticeBox:(text,icon)=>this.#noticeBox(text,icon)}}reload(){return this.#load(!0)}open(id){return this.#open(id,!0)}signIn(){return this.#s.error="",this.client().readerSignIn().then(()=>{return}).catch((error)=>{let code=error instanceof ApiError2?error.code:"";if(code==="sign_in_cancelled")return;this.#s.error=code==="popup_blocked"?this.t({id:"nW3go1"}):this.#failure(error),this.render()})}signOut(){return this.client().readerSignOut()}get#prefix(){return`${this.server} ${this.channel} ${this.pageUrl} `}async#load(force,more=!1){let page=this.pageUrl;if(!this.channel||!page||this.refused)return;let reader=this.client().reader,auth=reader?reader.token.slice(-12):this.#s.writer??"-",key=`${this.#prefix}${this.#sort} ${auth}`;if(!force&&!more&&this.#loadedFor===key)return;this.#loadedFor=key;let request;if(more)request=this.client().listDiscussions(page,{sort:this.#sort,cursor:this.#cursor});else{let load=loads.get(key);if(force||!load||Date.now()-load.at>cacheFor){load={at:Date.now(),request:this.client().listDiscussions(page,{sort:this.#sort})},loads.set(key,load);let current=load;load.request.catch(()=>loads.get(key)===current&&loads.delete(key))}if(request=load.request,!this.#s.items.length)this.#listState="loading"}if(more)this.#s.busy.add("more");this.render();try{let result=await request;if(this.#loadedFor!==key)return;this.#s.items=more?[...this.#s.items,...result.items.filter((d)=>!this.#s.items.some((i)=>i.id===d.id))]:result.items,this.#cursor=result.next_cursor,this.#listState="ready"}catch(error){if(this.#loadedFor!==key||this.refusal(error))return;if(!more)this.#loadedFor="";if(this.#listState=error instanceof ApiError2&&error.code==="discussions_off"?"off":more?"ready":"error",more)this.#s.error=this.#failure(error)}finally{this.#s.busy.delete("more")}this.render()}async#open(id,focus){let s=this.#s,page=this.pageUrl,known=s.thread?.discussion.id===id?s.thread:null;this.#loadThread(),s.view={kind:"thread",id};let listed=s.items.find((d)=>d.id===id);if(s.thread=known??(listed?{discussion:listed,posts:[]}:null),s.threadState=known?"ready":"loading",focus)s.notice=known?s.notice:"",s.error="",s.focus="thread-title";this.render();try{let detail=await this.client().getDiscussion(id);if(this.pageUrl!==page||s.view.kind!=="thread"||s.view.id!==id)return;let titled=!!s.thread;if(s.thread=detail,s.threadState="ready",focus&&!titled)s.focus="thread-title";s.items=s.items.map((d)=>d.id===id?detail.discussion:d)}catch(error){if(this.pageUrl!==page||s.view.kind!=="thread"||s.view.id!==id)return;if(this.refusal(error,!1))return;s.threadState=error instanceof ApiError2&&error.status===404?"missing":"error"}this.render()}#toList(){let s=this.#s;if(this.#linked()){let url=new URL(location.href);url.hash="",history.replaceState(history.state,"",url.href)}s.view={kind:"list"},this.#thread?.close(),s.confirm="",s.error="",s.focus=s.thread?`open-${s.thread.discussion.id}`:"start",this.render(),this.#load(!1)}#failure(error){let code=error instanceof ApiError2?error.code:"";if(code==="sign_in_required")return this.t({id:"LwDe8g"});if(code==="discussion_locked")return this.t({id:"KEjhwb"});if(code==="edit_window_closed")return this.t({id:"b_f4xj"});if(code==="discussions_off")return this.t({id:"tayT8P"});if(code==="forbidden")return this.t({id:"8Ekoev"});if(code==="validation_failed")return this.t({id:"Su3Vyp"});return this.errorText(error)}async#act(key,action){let s=this.#s;if(s.busy.has(key))return;s.busy.add(key),s.error="",this.render();try{return await action()}catch(error){if(!this.refusal(error,!1))s.error=this.#failure(error);if(error instanceof ApiError2&&error.code==="sign_in_required")this.#refreshWriter(!1);return}finally{s.busy.delete(key),this.render()}}get#mode(){return this.inbox?.chat.discussions??"moderated"}#button(className,text,key,onClick,html=""){let button=el("button",className);if(button.type="button",html)button.innerHTML=html;return button.append(text),button.dataset.key=key,button.addEventListener("click",onClick),button}#authorName(author){if(author.deleted)return author.kind==="member"?this.t({id:"-UxBoG"}):this.t({id:"FMWGhb"});if(author.kind==="anonymous")return this.t({id:"D9CFV5"});return author.name||(author.kind==="member"?this.t({id:"nLqMRA"}):this.t({id:"zmA6sS"}))}#avatar(author,small=!1){let avatar=el("span",`avatar${small?" small":""}`,author.deleted?"":author.initials||"?");if(avatar.setAttribute("aria-hidden","true"),author.deleted||author.kind==="anonymous")avatar.classList.add("gone");else if(author.kind==="member")avatar.classList.add("team");else avatar.style.setProperty("--avatar",`hsl(${hue(author.name||author.initials)} 45% 42%)`);return avatar}#badge(kind,short=!1){let text=kind==="answered"?this.t({id:"GqCA_t"}):kind==="pending"?short?this.t({id:"UbRKMZ"}):this.t({id:"lWv8id"}):kind==="team"?this.t({id:"KM6m8p"}):this.t({id:"G2fuEb"}),badge=el("span",`badge ${kind}`);if(kind!=="team")badge.innerHTML=kind==="answered"?icons.check:kind==="pending"?icons.clock:icons.lock;return badge.append(text),badge}#time(value){let time=el("time");time.dateTime=value;let date=new Date(value);time.title=date.toLocaleString(this.locale);let seconds=(date.getTime()-Date.now())/1000,steps=[["second",60],["minute",60],["hour",24],["day",30],["month",12],["year",1/0]],amount=seconds;for(let[unit,size]of steps){if(Math.abs(amount)<size){time.textContent=unit==="second"?this.t({id:"xOTzt5"}):new Intl.RelativeTimeFormat(this.locale,{numeric:"auto"}).format(Math.round(amount),unit);break}amount/=size}return time}#header(){let head=el("div","head");head.append(el("h2","",this.t({id:"7oGBMv"})));let who=el("div","who"),reader=this.#s.reader;if(reader){let name=reader.reader.name||this.t({id:"zmA6sS"});who.append(this.#avatar({kind:"reader",name,initials:reader.reader.initials,deleted:!1},!0)),who.append(el("span","",name)),who.append(this.#button("plain",this.t({id:"fcWrnU"}),"sign-out",()=>void this.signOut()))}else if(!this.#s.writer&&this.#mode!=="off")who.append(this.#button("ghost",this.t({id:"5lWFkC"}),"sign-in",()=>void this.signIn()));return head.append(who),head}#listView(){let nodes=[],bar=el("div","bar"),tabs=el("div","tabs");tabs.setAttribute("role","tablist"),tabs.setAttribute("aria-label",this.t({id:"78dEKp"}));let sorts=[["new",this.t({id:"isRobC"})],["top",this.t({id:"WWy8TN"})],["unanswered",this.t({id:"2lF8Zj"})]];sorts.forEach(([sort,label],index)=>{let tab=this.#button("tab",label,`sort-${sort}`,()=>this.#setSort(sort));tab.setAttribute("role","tab"),tab.setAttribute("aria-selected",String(this.#sort===sort)),tab.setAttribute("aria-controls","yuva-discussion-list"),tab.tabIndex=this.#sort===sort?0:-1,tab.addEventListener("keydown",(event)=>{let step=event.key==="ArrowRight"?1:event.key==="ArrowLeft"?-1:0;if(!step)return;event.preventDefault();let forward=this.direction==="rtl"?-step:step,next=sorts[(index+forward+sorts.length)%sorts.length];if(next)this.#setSort(next[0])}),tabs.append(tab)});let start=this.#button("send",this.t({id:"z1qf6l"}),"start",()=>{this.#loadThread(),this.#s.view={kind:"new"},this.#s.error="",this.#s.notice="",this.#s.focus="new-title",this.render()});if(this.#prefetchOn(start),bar.append(tabs,start),nodes.push(bar),this.#listState==="loading"&&!this.#s.items.length){let skeleton=el("div","skeleton");return skeleton.setAttribute("aria-busy","true"),skeleton.setAttribute("aria-label",this.t({id:"pzatAP"})),nodes.push(skeleton),nodes}if(this.#listState==="error"&&!this.#s.items.length){let box=el("div","empty");box.append(el("p","",this.t({id:"MDmQKn"})));let retry=this.#button("ghost",this.t({id:"KDw4GX"}),"retry",()=>void this.#load(!0));return retry.style.marginBlockStart="8px",box.append(retry),nodes.push(box),nodes}if(!this.#s.items.length){let box=el("div","empty");if(box.append(el("p","",this.#sort==="unanswered"?this.t({id:"twEQ41"}):this.t({id:"rpfOwz"}))),this.#sort!=="unanswered")box.append(el("p","muted",this.t({id:"b6Orhy"})));return nodes.push(box),nodes}let list=el("ul","list");list.id="yuva-discussion-list",list.setAttribute("aria-label",this.t({id:"j-3eim"})),list.setAttribute("aria-busy",String(this.#listState==="loading"));for(let discussion of this.#s.items){let item=el("li","item");item.append(this.#avatar(discussion.author));let main=el("div","main"),title=this.#button("title",discussion.title,`open-${discussion.id}`,()=>void this.#open(discussion.id,!0));title.dir="auto",this.#prefetchOn(title),main.append(title);let excerpt=discussion.deleted?"":excerptOf(discussion.body_html);if(excerpt){let text=el("p","excerpt",excerpt);text.dir="auto",main.append(text)}let meta=el("div","meta");if(meta.append(el("span","",this.#authorName(discussion.author)),this.#time(discussion.created_at)),discussion.author.kind==="member"&&!discussion.author.deleted)meta.append(this.#badge("team"));if(discussion.answer_post_id)meta.append(this.#badge("answered"));if(discussion.state==="pending")meta.append(this.#badge("pending"));if(discussion.locked)meta.append(this.#badge("locked"));main.append(meta);let counts=el("div","counts"),votes=el("span","count");votes.innerHTML=icons.up,votes.append(String(discussion.votes)),votes.setAttribute("aria-label",this.t({id:"8ntmc1",values:{0:discussion.votes}})),votes.title=votes.getAttribute("aria-label")??"";let replies=el("span","count");replies.innerHTML=icons.comment,replies.append(String(discussion.reply_count)),replies.setAttribute("aria-label",this.t({id:"Hw3P48",values:{0:discussion.reply_count}})),replies.title=replies.getAttribute("aria-label")??"",counts.append(votes,replies),item.append(main,counts),list.append(item)}if(nodes.push(list),this.#cursor){let more=this.#button("ghost more",this.#s.busy.has("more")?this.t({id:"Pwqkdw"}):this.t({id:"fMPkxb"}),"more",()=>void this.#load(!1,!0));more.disabled=this.#s.busy.has("more"),nodes.push(more)}return nodes}#setSort(sort){if(this.#sort===sort)return;this.#sort=sort,this.#s.items=[],this.#cursor=void 0,this.#listState="loading",this.#s.focus=`sort-${sort}`,this.#load(!1)}#noticeBox(text,icon=icons.clock){let box=el("div","notice");return box.setAttribute("role","status"),box.innerHTML=icon,box.append(el("p","",text)),box}render(){if(this.refused||!this.channel){this.root.replaceChildren();return}let focused="";try{focused=this.root.activeElement?.dataset?.key??""}catch{}let children=[this.#header()];if(this.#mode==="off"||this.#listState==="off")children.push(el("p","muted",this.t({id:"tayT8P"})));else if(this.#s.view.kind!=="list"){let thread=this.#thread;if(thread)children.push(...this.#s.view.kind==="thread"?thread.threadView():thread.newView());else{let skeleton=el("div","skeleton");skeleton.setAttribute("aria-busy","true"),skeleton.setAttribute("aria-label",this.t({id:"Pwqkdw"})),children.push(skeleton)}}else{if(this.#s.notice)children.push(this.#noticeBox(this.#s.notice));children.push(...this.#listView())}if(this.#s.error){let error=el("p","error",this.#s.error);error.setAttribute("role","alert"),children.push(error)}if(this.frame(styles+this.#threadStyles,...children),this.#s.view.kind!=="list"&&!this.#thread)return;this.#thread?.syncSend();let wanted=this.#s.focus;this.#s.focus="";let key=wanted||focused;if(!key)return;let active=null;try{active=this.root.activeElement}catch{}if(active instanceof HTMLElement&&active.dataset.key===key)return;[...this.root.querySelectorAll("[data-key]")].find((node)=>node.dataset.key===key)?.focus({preventScroll:!wanted})}}var maxRemembered=500,thumb=(down)=>`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"${down?' style="transform:scaleY(-1)"':""}><path d="M7 10v11H3V10zM7 10l4-8a3 3 0 013 3v4h6a2 2 0 012 2.3l-1.4 8A2 2 0 0118.6 21H7"/></svg>`,styles2=`
171
114
  .frame { display: flex; flex-direction: column; gap: 12px; }
172
115
  .ask { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
173
116
  .question { font-weight: 600; }
@@ -188,4 +131,4 @@ button { font: inherit; color: inherit; }
188
131
  .choice[aria-pressed="true"] { background: var(--yuva-soft); }
189
132
  .choice:disabled { cursor: default; }
190
133
  .choice:focus-visible { outline: 2px solid var(--yuva-accent); outline-offset: 2px; }
191
- `;function storageKey(channel){return`yuva:${channel}:page-ratings`}function remembered(channel){try{let raw=localStorage.getItem(storageKey(channel));return raw?JSON.parse(raw):{}}catch{return{}}}function remember(channel,page,rating){try{let ratings=remembered(channel);delete ratings[page],ratings[page]=rating;let pages=Object.keys(ratings);for(let old of pages.slice(0,Math.max(0,pages.length-maxRemembered)))delete ratings[old];localStorage.setItem(storageKey(channel),JSON.stringify(ratings))}catch{}}class YuvaPageFeedbackElement extends YuvaDocsElement{#phase="ask";#rating;#error="";#comment=el("textarea");#email=el("input");constructor(){super();this.#comment.rows=3,this.#comment.maxLength=5000,this.#comment.dir="auto",this.#comment.addEventListener("input",()=>this.#syncSend()),this.#email.type="email",this.#email.autocomplete="email"}get rating(){return this.#rating??null}reset(){this.#phase="ask",this.#error="",this.#comment.value="",this.#rating=this.channel?remembered(this.channel)[this.pageUrl]:void 0}pageChanged(){if(this.#phase==="ask"&&!this.#error)this.#rating=this.channel?remembered(this.channel)[this.pageUrl]:void 0;this.render()}async rate(rating){let channel=this.channel;if(!channel||this.refused||this.#phase==="rating"||this.#phase==="sending")return;let page=this.pageUrl,previous=remembered(channel)[page];if(this.#error="",previous===rating){this.#rating=rating,this.#phase=this.canWrite?"form":"thanks",this.render(),this.#comment.focus({preventScroll:!0});return}this.#phase="rating",this.#rating=rating,this.render();try{await this.client().ratePage({page,title:this.pageTitle||void 0,rating,previous})}catch(error){if(this.pageUrl!==page||this.refusal(error))return;this.#rating=previous,this.#phase="ask",this.#error=this.errorText(error),this.render();return}if(remember(channel,page,rating),this.emit("yuva-rating",{page,rating,previous:previous??null}),this.pageUrl!==page)return;this.#phase=this.canWrite?"form":"thanks",this.render(),this.#comment.focus({preventScroll:!0})}async#send(){let body=this.#comment.value.trim(),email=this.#email.value.trim(),rating=this.#rating;if(!body||this.#phase!=="form")return;if(email&&!this.#email.checkValidity()){this.#error=this.t({id:"E_qvzP"}),this.render();return}let page=this.pageUrl;this.#phase="sending",this.#error="",this.render();try{let{conversation}=await this.client().sendFeedback({page_url:page,page_title:this.pageTitle||void 0,rating,body,locale:this.locale,allow_email:this.identified||!!email,email:!this.identified&&email?email:void 0});if(this.emit("yuva-feedback",{page,rating:rating??null,conversation_id:conversation.id}),this.pageUrl!==page)return;this.#comment.value="",this.#phase="thanks"}catch(error){if(this.pageUrl!==page||this.refusal(error,!1))return;this.#phase="form",this.#error=this.errorText(error)}this.render()}#syncSend(){let send=this.root.querySelector(".send");if(send)send.disabled=this.#phase!=="form"||this.#comment.value.trim()===""}render(){if(this.refused||!this.channel){this.root.replaceChildren();return}let question=this.t({id:"SOvBw9"}),ask=el("div","ask");ask.setAttribute("role","group"),ask.setAttribute("aria-label",question);let choices=el("div","choices");for(let value of["up","down"]){let button=el("button","choice");button.type="button",button.innerHTML=thumb(value==="down"),button.append(el("span","",value==="up"?this.t({id:"l75CjT"}):this.t({id:"1UzENP"}))),button.setAttribute("aria-pressed",String(this.#rating===value)),button.disabled=this.#phase==="rating"||this.#phase==="sending",button.addEventListener("click",()=>void this.rate(value)),choices.append(button)}ask.append(el("p","question",question),choices);let children=[ask];if(this.#phase==="form"||this.#phase==="sending"){let form=el("form");form.noValidate=!0,form.addEventListener("submit",(event)=>{event.preventDefault(),this.#send()});let prompt=this.#rating==="down"?this.t({id:"U7H5Fm"}):this.t({id:"EmiQvf"});if(this.#comment.placeholder=prompt,this.#comment.setAttribute("aria-label",prompt),this.#comment.disabled=this.#phase==="sending",form.append(this.#comment),!this.identified)this.#email.placeholder=this.t({id:"a_qtPP"}),this.#email.setAttribute("aria-label",this.t({id:"XJURKP"})),this.#email.disabled=this.#phase==="sending",form.append(this.#email);let skip=el("button","link",this.t({id:"tA4dAO"}));skip.type="button",skip.disabled=this.#phase==="sending",skip.addEventListener("click",()=>{this.#phase="thanks",this.#error="",this.render()});let send=el("button","send",this.#phase==="sending"?this.t({id:"Sad2tK"}):this.t({id:"JlFcis"}));send.type="submit";let actions=el("div","actions");actions.append(skip,send),form.append(actions),children.push(form)}else if(this.#phase==="thanks"){let thanks=el("p","muted",this.t({id:"d6N994"}));thanks.setAttribute("role","status"),children.push(thanks)}if(this.#error){let error=el("p","error",this.#error);error.setAttribute("role","alert"),children.push(error)}this.frame(styles2,...children),this.#syncSend()}}function defineDocs(){if(typeof customElements>"u")return;if(!customElements.get("yuva-discussions"))customElements.define("yuva-discussions",YuvaDiscussionsElement);if(!customElements.get("yuva-page-feedback"))customElements.define("yuva-page-feedback",YuvaPageFeedbackElement)}defineDocs();export{YuvaDiscussionsElement,YuvaPageFeedbackElement,defineDocs};
134
+ `;function storageKey(channel){return`yuva:${channel}:page-ratings`}function remembered(channel){try{let raw=localStorage.getItem(storageKey(channel));return raw?JSON.parse(raw):{}}catch{return{}}}function remember(channel,page,rating){try{let ratings=remembered(channel);delete ratings[page],ratings[page]=rating;let pages=Object.keys(ratings);for(let old of pages.slice(0,Math.max(0,pages.length-maxRemembered)))delete ratings[old];localStorage.setItem(storageKey(channel),JSON.stringify(ratings))}catch{}}class YuvaPageFeedbackElement extends YuvaDocsElement{#phase="ask";#rating;#error="";#comment=el("textarea");#email=el("input");constructor(){super();this.#comment.rows=3,this.#comment.maxLength=5000,this.#comment.dir="auto",this.#comment.addEventListener("input",()=>this.#syncSend()),this.#email.type="email",this.#email.autocomplete="email"}get rating(){return this.#rating??null}reset(){this.#phase="ask",this.#error="",this.#comment.value="",this.#rating=this.channel?remembered(this.channel)[this.pageUrl]:void 0}pageChanged(){if(this.#phase==="ask"&&!this.#error)this.#rating=this.channel?remembered(this.channel)[this.pageUrl]:void 0;this.render()}async rate(rating){let channel=this.channel;if(!channel||this.refused||this.#phase==="rating"||this.#phase==="sending")return;let page=this.pageUrl,previous=remembered(channel)[page];if(this.#error="",previous===rating){this.#rating=rating,this.#phase=this.canWrite?"form":"thanks",this.render(),this.#comment.focus({preventScroll:!0});return}this.#phase="rating",this.#rating=rating,this.render();try{await this.client().ratePage({page,title:this.pageTitle||void 0,rating,previous})}catch(error){if(this.pageUrl!==page||this.refusal(error))return;this.#rating=previous,this.#phase="ask",this.#error=this.errorText(error),this.render();return}if(remember(channel,page,rating),this.emit("yuva-rating",{page,rating,previous:previous??null}),this.pageUrl!==page)return;this.#phase=this.canWrite?"form":"thanks",this.render(),this.#comment.focus({preventScroll:!0})}async#send(){let body=this.#comment.value.trim(),email=this.#email.value.trim(),rating=this.#rating;if(!body||this.#phase!=="form")return;if(email&&!this.#email.checkValidity()){this.#error=this.t({id:"E_qvzP"}),this.render();return}let page=this.pageUrl;this.#phase="sending",this.#error="",this.render();try{let{conversation}=await this.client().sendFeedback({page_url:page,page_title:this.pageTitle||void 0,rating,body,locale:this.locale,allow_email:this.identified||!!email,email:!this.identified&&email?email:void 0});if(this.emit("yuva-feedback",{page,rating:rating??null,conversation_id:conversation.id}),this.pageUrl!==page)return;this.#comment.value="",this.#phase="thanks"}catch(error){if(this.pageUrl!==page||this.refusal(error,!1))return;this.#phase="form",this.#error=this.errorText(error)}this.render()}#syncSend(){let send=this.root.querySelector(".send");if(send)send.disabled=this.#phase!=="form"||this.#comment.value.trim()===""}render(){if(this.refused||!this.channel){this.root.replaceChildren();return}let question=this.t({id:"SOvBw9"}),ask=el("div","ask");ask.setAttribute("role","group"),ask.setAttribute("aria-label",question);let choices=el("div","choices");for(let value of["up","down"]){let button=el("button","choice");button.type="button",button.innerHTML=thumb(value==="down"),button.append(el("span","",value==="up"?this.t({id:"l75CjT"}):this.t({id:"1UzENP"}))),button.setAttribute("aria-pressed",String(this.#rating===value)),button.disabled=this.#phase==="rating"||this.#phase==="sending",button.addEventListener("click",()=>void this.rate(value)),choices.append(button)}ask.append(el("p","question",question),choices);let children=[ask];if(this.#phase==="form"||this.#phase==="sending"){let form=el("form");form.noValidate=!0,form.addEventListener("submit",(event)=>{event.preventDefault(),this.#send()});let prompt=this.#rating==="down"?this.t({id:"U7H5Fm"}):this.t({id:"EmiQvf"});if(this.#comment.placeholder=prompt,this.#comment.setAttribute("aria-label",prompt),this.#comment.disabled=this.#phase==="sending",form.append(this.#comment),!this.identified)this.#email.placeholder=this.t({id:"a_qtPP"}),this.#email.setAttribute("aria-label",this.t({id:"XJURKP"})),this.#email.disabled=this.#phase==="sending",form.append(this.#email);let skip=el("button","link",this.t({id:"tA4dAO"}));skip.type="button",skip.disabled=this.#phase==="sending",skip.addEventListener("click",()=>{this.#phase="thanks",this.#error="",this.render()});let send=el("button","send",this.#phase==="sending"?this.t({id:"Sad2tK"}):this.t({id:"JlFcis"}));send.type="submit";let actions=el("div","actions");actions.append(skip,send),form.append(actions),children.push(form)}else if(this.#phase==="thanks"){let thanks=el("p","muted",this.t({id:"d6N994"}));thanks.setAttribute("role","status"),children.push(thanks)}if(this.#error){let error=el("p","error",this.#error);error.setAttribute("role","alert"),children.push(error)}this.frame(styles2,...children),this.#syncSend()}}function defineDocs(){if(typeof customElements>"u")return;if(!customElements.get("yuva-discussions"))customElements.define("yuva-discussions",YuvaDiscussionsElement);if(!customElements.get("yuva-page-feedback"))customElements.define("yuva-page-feedback",YuvaPageFeedbackElement)}YuvaDiscussionsElement.loadThread=()=>import("./thread-3ydc3xfc.js");defineDocs();export{YuvaDiscussionsElement,YuvaPageFeedbackElement,defineDocs};
@@ -0,0 +1,2 @@
1
+ var messages=JSON.parse('{"6I7cJR":["Open chat"],"OkHvGB":["Open chat, ",["count"]," unread"],"pqZJT2":["Close chat"]}');var messages2=JSON.parse('{"6I7cJR":["Sohbeti aç"],"OkHvGB":["Sohbeti aç, ",["count"]," okunmamış"],"pqZJT2":["Sohbeti kapat"]}');function translate(messages,descriptor,fallback){let entry=messages[descriptor.id]??fallback[descriptor.id],values=descriptor.values??{};if(typeof entry==="string")return entry;if(Array.isArray(entry))return entry.map((part)=>typeof part==="string"?part:Array.isArray(part)?String(values[part[0]]??""):"").join("");return descriptor.message??descriptor.id}var catalogs={en:messages,tr:messages2},rtlLanguages=new Set(["ar","fa","he","ur"]),sourceLocale="en";function resolveLocale(...candidates){for(let candidate of candidates){if(!candidate)continue;let tag=candidate.toLowerCase();if(catalogs[tag])return tag;let language=tag.split(/[-_]/)[0]??"";if(catalogs[language])return language}return sourceLocale}function directionOf(locale){return rtlLanguages.has(locale.split(/[-_]/)[0]??"")?"rtl":"ltr"}function catalogFor(locale){return catalogs[locale]??messages}function translatePlain(messages2,descriptor,fallback=messages){return translate(messages2,descriptor,fallback)}function launcherOf(inbox){return{position:inbox.chat.launcher_position,color:inbox.chat.launcher_color??inbox.branding.color}}function contrastOn(color){let n=Number.parseInt(color.slice(1),16),[r,g,b]=[n>>16&255,n>>8&255,n&255].map((c)=>{let s=c/255;return s<=0.03928?s/12.92:((s+0.055)/1.055)**2.4});return 0.2126*r+0.7152*g+0.0722*b>0.4?"#111827":"#ffffff"}function storageKey(channel){return`yuva:${channel}`}function readStored(channel){try{let raw=localStorage.getItem(storageKey(channel));return raw?JSON.parse(raw):{}}catch{return{}}}function writeStored(channel,state){try{localStorage.setItem(storageKey(channel),JSON.stringify(state))}catch{}}
2
+ export{translate,resolveLocale,directionOf,catalogFor,translatePlain,launcherOf,contrastOn,readStored,writeStored};
@@ -0,0 +1,2 @@
1
+ function el(tag,className,text){let element=document.createElement(tag);if(className)element.className=className;if(text!==void 0)element.textContent=text;return element}
2
+ export{el};
package/dist/esm/react.js CHANGED
@@ -1 +1 @@
1
- import{createContext,createElement,useCallback,useContext,useEffect,useRef,useState}from"react";var YuvaContext=createContext(null);function YuvaProvider({client,connect=!0,children}){return useEffect(()=>{if(!connect)return;return client.connect().catch(()=>{return}),()=>client.disconnect()},[client,connect]),createElement(YuvaContext.Provider,{value:client},children)}function useYuva(){let client=useContext(YuvaContext);if(!client)throw Error("Yuva: wrap your components in <YuvaProvider client={...}>");return client}var time=(value)=>Date.parse(value),byCreated=(a,b)=>time(a.created_at)-time(b.created_at),byActivity=(a,b)=>time(b.last_message_at??b.created_at)-time(a.last_message_at??a.created_at),initial={items:[],loading:!0,error:null};function useConversations(){let client=useYuva(),[state,setState]=useState(initial),cursor=useRef(void 0),current=useRef(state);current.current=state;let load=useCallback(async(more)=>{setState((s)=>({...s,loading:!0}));try{let page=await client.listConversations({limit:50,cursor:more?cursor.current:void 0});cursor.current=page.next_cursor,setState((s)=>{let items=new Map((more?s.items:[]).map((c)=>[c.id,c]));for(let conversation of page.items)items.set(conversation.id,conversation);return{items:[...items.values()].sort(byActivity),cursor:page.next_cursor,loading:!1,error:null}})}catch(error){setState((s)=>({...s,loading:!1,error}))}},[client]);return useEffect(()=>{load(!1);let offSession=client.on("session",({renewed})=>void(renewed&&load(!1))),offEvent=client.on("event",(message)=>{if(message.type==="resync_required")return void load(!1);if(message.type==="conversation.created")setState((s)=>s.items.some((c)=>c.id===message.data.id)?s:{...s,items:[message.data,...s.items].sort(byActivity)});else if(message.type==="conversation.updated")setState((s)=>({...s,items:s.items.map((c)=>c.id===message.conversation_id?{...c,status:message.data.status}:c)}));else if(message.type==="message.created"){let m=message.data;if(!current.current.items.some((c)=>c.id===m.conversation_id))return void load(!1);setState((s)=>{let items=s.items.map((c)=>c.id===m.conversation_id?{...c,last_message:{id:m.id,author_type:m.author.type,text:m.body.slice(0,140),created_at:m.created_at},last_message_at:m.created_at,unread:c.unread||m.author.type!=="contact"}:c);return{...s,items:items.sort(byActivity)}})}});return()=>{offSession(),offEvent()}},[client,load]),{conversations:state.items,loading:state.loading,error:state.error,hasMore:!!state.cursor,loadMore:()=>load(!0),reload:()=>load(!1)}}function useMessages(conversationId){let client=useYuva(),[state,setState]=useState(initial),cursor=useRef(void 0),upsert=useCallback((message)=>{setState((s)=>{let items=s.items.filter((m)=>m.id!==message.id&&(!message.client_id||m.client_id!==message.client_id));return{...s,items:[...items,message].sort(byCreated)}})},[]),load=useCallback(async(older)=>{if(!conversationId){cursor.current=void 0,setState({items:[],loading:!1,error:null});return}if(older&&!cursor.current)return;setState((s)=>({...s,loading:!0}));try{let page=await client.listMessages(conversationId,{order:"desc",limit:30,cursor:older?cursor.current:void 0});cursor.current=page.next_cursor,setState((s)=>{let items=new Map((older?s.items:[]).map((m)=>[m.id,m]));for(let message of page.items)items.set(message.id,message);return{items:[...items.values()].sort(byCreated),cursor:page.next_cursor,loading:!1,error:null}})}catch(error){setState((s)=>({...s,loading:!1,error}))}},[client,conversationId]);return useEffect(()=>{if(load(!1),!conversationId)return;let offSession=client.on("session",({renewed})=>void(renewed&&load(!1))),offEvent=client.on("event",(message)=>{if(message.type==="resync_required")load(!1);else if((message.type==="message.created"||message.type==="message.updated")&&message.data.conversation_id===conversationId)upsert(message.data)});return()=>{offSession(),offEvent()}},[client,conversationId,load,upsert]),{messages:state.items,loading:state.loading,error:state.error,hasMore:!!state.cursor,loadOlder:()=>load(!0),async send(input){if(!conversationId)throw Error("Yuva: no conversation; start one with client.startConversation()");let message=await client.sendMessage(conversationId,typeof input==="string"?{body:input}:input);return upsert(message),message},async markRead(){if(conversationId)await client.markRead(conversationId)}}}function useDocsElement(tag,props,handlers){let ref=useRef(null),latest=useRef(handlers);latest.current=handlers;let{channel,server,locale,dir,page,pageTitle,identityToken,className,style}=props;useEffect(()=>{import("./docs.js")},[]),useEffect(()=>{let element=ref.current;if(!element)return;let attributes={server,locale,dir,page,"page-title":pageTitle,"identity-token":typeof identityToken==="string"?identityToken:void 0,channel};for(let[name,value]of Object.entries(attributes))if(value)element.setAttribute(name,value);else element.removeAttribute(name)},[channel,server,locale,dir,page,pageTitle,identityToken]),useEffect(()=>{let element=ref.current;if(!element||typeof identityToken!=="function")return;let current=!0;return customElements.whenDefined(tag).then(()=>{if(current)element.setIdentityToken(identityToken)}),()=>{current=!1}},[tag,identityToken]);let events=Object.keys(handlers).join(" ");return useEffect(()=>{let element=ref.current;if(!element)return;let listeners=events.split(" ").map((type)=>{let listener=(event)=>latest.current[type]?.(event.detail);return element.addEventListener(type,listener),()=>element.removeEventListener(type,listener)});return()=>listeners.forEach((off)=>off())},[events]),createElement(tag,{ref,className,style})}function YuvaPageFeedback({onRating,onFeedback,...props}){return useDocsElement("yuva-page-feedback",props,{"yuva-rating":onRating,"yuva-feedback":onFeedback})}function YuvaDiscussions({onDiscussion,onPost,onReader,...props}){return useDocsElement("yuva-discussions",props,{"yuva-discussion":onDiscussion,"yuva-post":onPost,"yuva-reader":onReader})}export{YuvaDiscussions,YuvaPageFeedback,YuvaProvider,useConversations,useMessages,useYuva};
1
+ import{createContext,createElement,useCallback,useContext,useEffect,useRef,useState}from"react";var YuvaContext=createContext(null);function YuvaProvider({client,connect=!0,children}){return useEffect(()=>{if(!connect)return;return client.connect().catch(()=>{return}),()=>client.disconnect()},[client,connect]),createElement(YuvaContext.Provider,{value:client},children)}function useYuva(){let client=useContext(YuvaContext);if(!client)throw Error("Yuva: wrap your components in <YuvaProvider client={...}>");return client}var time=(value)=>Date.parse(value),byCreated=(a,b)=>time(a.created_at)-time(b.created_at),byActivity=(a,b)=>time(b.last_message_at??b.created_at)-time(a.last_message_at??a.created_at),initial={items:[],loading:!0,error:null};function useConversations(){let client=useYuva(),[state,setState]=useState(initial),cursor=useRef(void 0),current=useRef(state);useEffect(()=>{current.current=state});let load=useCallback(async(more)=>{setState((s)=>({...s,loading:!0}));try{let page=await client.listConversations({limit:50,cursor:more?cursor.current:void 0});cursor.current=page.next_cursor,setState((s)=>{let items=new Map((more?s.items:[]).map((c)=>[c.id,c]));for(let conversation of page.items)items.set(conversation.id,conversation);return{items:[...items.values()].sort(byActivity),cursor:page.next_cursor,loading:!1,error:null}})}catch(error){setState((s)=>({...s,loading:!1,error}))}},[client]);return useEffect(()=>{load(!1);let offSession=client.on("session",({renewed})=>void(renewed&&load(!1))),offEvent=client.on("event",(message)=>{if(message.type==="resync_required")return void load(!1);if(message.type==="conversation.created")setState((s)=>s.items.some((c)=>c.id===message.data.id)?s:{...s,items:[message.data,...s.items].sort(byActivity)});else if(message.type==="conversation.updated")setState((s)=>({...s,items:s.items.map((c)=>c.id===message.conversation_id?{...c,status:message.data.status}:c)}));else if(message.type==="message.created"){let m=message.data;if(!current.current.items.some((c)=>c.id===m.conversation_id))return void load(!1);setState((s)=>{let items=s.items.map((c)=>c.id===m.conversation_id?{...c,last_message:{id:m.id,author_type:m.author.type,text:m.body.slice(0,140),created_at:m.created_at},last_message_at:m.created_at,unread:c.unread||m.author.type!=="contact"}:c);return{...s,items:items.sort(byActivity)}})}});return()=>{offSession(),offEvent()}},[client,load]),{conversations:state.items,loading:state.loading,error:state.error,hasMore:!!state.cursor,loadMore:()=>load(!0),reload:()=>load(!1)}}function useMessages(conversationId){let client=useYuva(),[state,setState]=useState(initial),cursor=useRef(void 0),upsert=useCallback((message)=>{setState((s)=>{let items=s.items.filter((m)=>m.id!==message.id&&(!message.client_id||m.client_id!==message.client_id));return{...s,items:[...items,message].sort(byCreated)}})},[]),load=useCallback(async(older)=>{if(!conversationId){cursor.current=void 0,setState({items:[],loading:!1,error:null});return}if(older&&!cursor.current)return;setState((s)=>({...s,loading:!0}));try{let page=await client.listMessages(conversationId,{order:"desc",limit:30,cursor:older?cursor.current:void 0});cursor.current=page.next_cursor,setState((s)=>{let items=new Map((older?s.items:[]).map((m)=>[m.id,m]));for(let message of page.items)items.set(message.id,message);return{items:[...items.values()].sort(byCreated),cursor:page.next_cursor,loading:!1,error:null}})}catch(error){setState((s)=>({...s,loading:!1,error}))}},[client,conversationId]);return useEffect(()=>{if(load(!1),!conversationId)return;let offSession=client.on("session",({renewed})=>void(renewed&&load(!1))),offEvent=client.on("event",(message)=>{if(message.type==="resync_required")load(!1);else if((message.type==="message.created"||message.type==="message.updated")&&message.data.conversation_id===conversationId)upsert(message.data)});return()=>{offSession(),offEvent()}},[client,conversationId,load,upsert]),{messages:state.items,loading:state.loading,error:state.error,hasMore:!!state.cursor,loadOlder:()=>load(!0),async send(input){if(!conversationId)throw Error("Yuva: no conversation; start one with client.startConversation()");let message=await client.sendMessage(conversationId,typeof input==="string"?{body:input}:input);return upsert(message),message},async markRead(){if(conversationId)await client.markRead(conversationId)}}}function useDocsElement(tag,props,handlers){let[element,setElement]=useState(null),latest=useRef(handlers);useEffect(()=>{latest.current=handlers});let{channel,server,locale,dir,page,pageTitle,identityToken,className,style}=props;useEffect(()=>{import("./docs.js")},[]),useEffect(()=>{if(!element)return;let attributes={server,locale,dir,page,"page-title":pageTitle,"identity-token":typeof identityToken==="string"?identityToken:void 0,channel};for(let[name,value]of Object.entries(attributes))if(value)element.setAttribute(name,value);else element.removeAttribute(name)},[element,channel,server,locale,dir,page,pageTitle,identityToken]),useEffect(()=>{if(!element||typeof identityToken!=="function")return;let current=!0;return customElements.whenDefined(tag).then(()=>{if(current)element.setIdentityToken(identityToken)}),()=>{current=!1}},[element,tag,identityToken]);let events=Object.keys(handlers).join(" ");return useEffect(()=>{if(!element)return;let listeners=events.split(" ").map((type)=>{let listener=(event)=>latest.current[type]?.(event.detail);return element.addEventListener(type,listener),()=>element.removeEventListener(type,listener)});return()=>listeners.forEach((off)=>off())},[element,events]),createElement(tag,{ref:setElement,className,style})}function YuvaPageFeedback({onRating,onFeedback,...props}){return useDocsElement("yuva-page-feedback",props,{"yuva-rating":onRating,"yuva-feedback":onFeedback})}function YuvaDiscussions({onDiscussion,onPost,onReader,...props}){return useDocsElement("yuva-discussions",props,{"yuva-discussion":onDiscussion,"yuva-post":onPost,"yuva-reader":onReader})}export{YuvaDiscussions,YuvaPageFeedback,YuvaProvider,useConversations,useMessages,useYuva};
@@ -0,0 +1,61 @@
1
+ import{translate}from"./index-e2tek7yk.js";import{el}from"./index-rdzxvj2r.js";import{inlineNodes}from"./index-jdxce2se.js";var messages=JSON.parse('{"2Hlmdt":["Write a reply…"],"3CApMv":["All discussions"],"3PqJQG":["Nothing to preview."],"4-S4QM":["Unmark as answer"],"5lWFkC":["Sign in"],"8wRl7c":["The opening post was deleted."],"99w-GZ":["Sign in to start a discussion. Your name is shown with your post."],"F_vGso":["Your reply"],"HkXOWm":["This reply was deleted."],"Hw3P48":["Replies: ",["0"]],"ImOQa9":["Reply"],"JfAIiv":["This discussion is locked. New replies are closed."],"Kl3TuI":["Get an e-mail when someone replies or an answer is accepted."],"Klsidc":["Delete this reply?"],"MHrjPM":["Title"],"MKEPCY":["Follow"],"NjUiZ4":["Ask a question, share an idea or describe a problem with this page."],"NrGspR":["Thanks! Your discussion will appear for everyone once the team approves it."],"OVijcR":["Remove your vote (",["0"]," votes)"],"PL0621":["Sign in to reply, vote and follow this discussion."],"PN38hZ":["Your question or idea"],"PZ_kxo":["Keep"],"Pwqkdw":["Loading…"],"RqsQKK":["Your first posts are checked by the team before they appear for everyone."],"Sad2tK":["Sending…"],"VGqKyv":["This discussion is no longer available."],"Vwy_nT":["Markdown is supported."],"YZayoP":["Thanks! Your reply will appear for everyone once the team approves it."],"cnGeoo":["Delete"],"dEgA5A":["Cancel"],"dNOvhg":["Upvote (",["0"]," votes)"],"ePK91l":["Edit"],"i4_LY_":["Write"],"jhu92n":["Mark as answer"],"k4b5_X":["edited"],"n5vqdp":["Start discussion"],"qzVesX":["Edit your post"],"rAl91-":["Delete this discussion?"],"rdUucN":["Preview"],"tfDRzk":["Save"],"y-KXxN":["Accepted answer"],"y6sq5j":["Following"],"z1qf6l":["Start a discussion"]}');var messages2=JSON.parse('{"2Hlmdt":["Bir yanıt yazın…"],"3CApMv":["Tüm tartışmalar"],"3PqJQG":["Önizlenecek bir şey yok."],"4-S4QM":["Yanıt işaretini kaldır"],"5lWFkC":["Giriş yap"],"8wRl7c":["Açılış gönderisi silindi."],"99w-GZ":["Tartışma başlatmak için giriş yapın. Adınız gönderinizle birlikte gösterilir."],"F_vGso":["Yanıtınız"],"HkXOWm":["Bu yanıt silindi."],"Hw3P48":["Yanıtlar: ",["0"]],"ImOQa9":["Yanıtla"],"JfAIiv":["Bu tartışma kilitli. Yeni yanıt yazılamaz."],"Kl3TuI":["Biri yanıt yazdığında ya da bir yanıt kabul edildiğinde e-posta alın."],"Klsidc":["Bu yanıt silinsin mi?"],"MHrjPM":["Başlık"],"MKEPCY":["Takip et"],"NjUiZ4":["Bir soru sorun, bir fikir paylaşın ya da bu sayfadaki bir sorunu anlatın."],"NrGspR":["Teşekkürler! Tartışmanız ekip onayladığında herkese görünecek."],"OVijcR":["Oyunuzu geri alın (",["0"]," oy)"],"PL0621":["Bu tartışmada yanıt yazmak, oy vermek ve takip etmek için giriş yapın."],"PN38hZ":["Sorunuz ya da fikriniz"],"PZ_kxo":["Kalsın"],"Pwqkdw":["Yükleniyor…"],"RqsQKK":["İlk gönderileriniz herkese görünmeden önce ekip tarafından kontrol edilir."],"Sad2tK":["Gönderiliyor…"],"VGqKyv":["Bu tartışma artık mevcut değil."],"Vwy_nT":["Markdown desteklenir."],"YZayoP":["Teşekkürler! Yanıtınız ekip onayladığında herkese görünecek."],"cnGeoo":["Sil"],"dEgA5A":["Vazgeç"],"dNOvhg":["Oy ver (",["0"]," oy)"],"ePK91l":["Düzenle"],"i4_LY_":["Yaz"],"jhu92n":["Yanıt olarak işaretle"],"k4b5_X":["düzenlendi"],"n5vqdp":["Tartışmayı başlat"],"qzVesX":["Gönderinizi düzenleyin"],"rAl91-":["Bu tartışma silinsin mi?"],"rdUucN":["Önizleme"],"tfDRzk":["Kaydet"],"y-KXxN":["Kabul edilen yanıt"],"y6sq5j":["Takip ediliyor"],"z1qf6l":["Tartışma başlat"]}');var linkPattern=/\[([^\]\n]+)\]\(([^)\s]+)\)/g;function inline(text){let nodes=[],last=0;for(let match of text.matchAll(linkPattern)){let index=match.index??0;if(index>last)nodes.push(...inlineNodes(text.slice(last,index)));let[whole,label="",href=""]=match,url=null;try{url=new URL(href)}catch{}if(url&&(url.protocol==="http:"||url.protocol==="https:")){let a=document.createElement("a");a.href=url.href,a.target="_blank",a.rel="nofollow ugc noopener",a.append(...inlineNodes(label)),nodes.push(a)}else nodes.push(document.createTextNode(whole));last=index+whole.length}if(last<text.length)nodes.push(...inlineNodes(text.slice(last)));return nodes}function block(tag,lines){let element=document.createElement(tag);return element.append(...inline(lines.join(" "))),element}function preview(markdown){let fragment=document.createDocumentFragment(),lines=markdown.replace(/\r\n?/g,`
2
+ `).split(`
3
+ `),paragraph=[],list=null,quote=[],flush=()=>{if(paragraph.length)fragment.append(block("p",paragraph));if(quote.length){let element=document.createElement("blockquote");element.append(preview(quote.join(`
4
+ `))),fragment.append(element)}paragraph=[],quote=[],list=null};for(let i=0;i<lines.length;i++){let line=lines[i]??"",fence=/^\s*(```|~~~)/.exec(line);if(fence){flush();let code=[];while(++i<lines.length&&!(lines[i]??"").trimStart().startsWith(fence[1]??"```"))code.push(lines[i]??"");let pre=document.createElement("pre");pre.append(Object.assign(document.createElement("code"),{textContent:code.join(`
5
+ `)})),fragment.append(pre);continue}if(/^\s*$/.test(line)){flush();continue}let quoted=/^\s*>\s?(.*)$/.exec(line);if(quoted){if(paragraph.length||list)flush();quote.push(quoted[1]??"");continue}let heading=/^\s*(#{1,6})\s+(.*)$/.exec(line);if(heading){flush(),fragment.append(block(`h${Math.min(6,(heading[1]?.length??1)+2)}`,[heading[2]??""]));continue}let item=/^\s*(?:([-*+])|(\d+)[.)])\s+(.*)$/.exec(line);if(item){let tag=item[1]?"ul":"ol";if(paragraph.length||quote.length||list&&list.tagName.toLowerCase()!==tag)flush();if(!list)list=document.createElement(tag),fragment.append(list);list.append(block("li",[item[3]??""]));continue}if(quote.length)flush();if(list&&/^\s{2,}/.test(line)){list.lastElementChild?.append(" ",...inline(line.trim()));continue}list=null,paragraph.push(line.trim())}return flush(),fragment}var editWindow=1800000,catalogs={en:messages,tr:messages2},svg=(path)=>`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${path}</svg>`,checkCircle=svg('<circle cx="12" cy="12" r="9"/><path d="M8 12l3 3 5-6"/>'),backIcon=svg('<path d="M19 12H5M12 19l-7-7 7-7"/>'),bell=svg('<path d="M18 8a6 6 0 10-12 0c0 7-3 9-3 9h18s-3-2-3-9M13.7 21a2 2 0 01-3.4 0"/>'),styles=`
6
+ .thread { display: flex; flex-direction: column; gap: 12px; }
7
+ .thread-head { display: flex; flex-direction: column; gap: 8px; }
8
+ .post { display: flex; gap: 12px; padding: 14px; border: 1px solid var(--yuva-border); border-radius: 12px; }
9
+ .post.accepted { border-color: var(--yuva-success); box-shadow: inset 0 0 0 1px var(--yuva-success); }
10
+ .post.pending { border-style: dashed; }
11
+ .side { display: flex; flex-direction: column; align-items: center; gap: 6px; }
12
+ .vote {
13
+ display: inline-flex; flex-direction: column; align-items: center; gap: 0; min-inline-size: 40px; padding: 4px 6px;
14
+ border: 1px solid var(--yuva-border); border-radius: 8px; background: none; cursor: pointer; font-size: 0.85em; font-weight: 600;
15
+ }
16
+ .vote:hover:not(:disabled) { border-color: var(--yuva-accent); }
17
+ .vote[aria-pressed="true"] { border-color: var(--yuva-accent); color: var(--yuva-accent); background: var(--yuva-soft); }
18
+ .post-body { flex: 1; min-inline-size: 0; display: flex; flex-direction: column; gap: 8px; }
19
+ .post-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 0.88em; }
20
+ .name { font-weight: 600; }
21
+ .answer-label { display: flex; align-items: center; gap: 6px; color: var(--yuva-success); font-weight: 600; font-size: 0.85em; }
22
+ .tools { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
23
+ .children { display: flex; flex-direction: column; gap: 10px; margin-block-start: 4px; padding-inline-start: 14px; border-inline-start: 2px solid var(--yuva-border); }
24
+ .children .post { padding: 10px 0; border: 0; box-shadow: none; }
25
+ .children .post + .post { border-block-start: 1px solid var(--yuva-border); border-radius: 0; }
26
+ .deleted { font-style: italic; opacity: 0.65; }
27
+ .signin { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 14px; border: 1px solid var(--yuva-border); border-radius: 12px; }
28
+ .composer { display: flex; flex-direction: column; border: 1px solid var(--yuva-border); border-radius: 12px; overflow: hidden; }
29
+ .composer:focus-within { border-color: var(--yuva-accent); }
30
+ .composer .ctabs { display: flex; gap: 4px; padding: 0 8px; border-block-end: 1px solid var(--yuva-border); }
31
+ .composer .ctab { padding: 7px 10px; border: 0; border-block-end: 2px solid transparent; background: none; cursor: pointer; font-size: 0.88em; opacity: 0.75; margin-block-end: -1px; }
32
+ .composer .ctab[aria-selected="true"] { border-block-end-color: var(--yuva-accent); font-weight: 600; opacity: 1; }
33
+ .composer .ctab:focus-visible { outline: 2px solid var(--yuva-accent); outline-offset: -2px; }
34
+ .composer textarea, .composer .preview { border: 0; border-radius: 0; min-block-size: 110px; padding: 10px 12px; }
35
+ .composer textarea:focus-visible { outline: none; }
36
+ .composer .preview { overflow-wrap: anywhere; }
37
+ .composer .foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; padding: 8px 10px; border-block-start: 1px solid var(--yuva-border); }
38
+ .composer .hint { font-size: 0.8em; opacity: 0.7; }
39
+ .composer .buttons { display: flex; gap: 8px; margin-inline-start: auto; }
40
+ .field-title { font-size: 1.05em; font-weight: 600; }
41
+ .form { display: flex; flex-direction: column; gap: 10px; }
42
+ .md { overflow-wrap: anywhere; }
43
+ .md > :first-child { margin-block-start: 0; }
44
+ .md > :last-child { margin-block-end: 0; }
45
+ .md p, .md ul, .md ol, .md pre, .md blockquote, .md table { margin: 0 0 0.75em; }
46
+ .md h1, .md h2, .md h3, .md h4, .md h5, .md h6 { margin: 0.9em 0 0.4em; font-size: 1em; font-weight: 600; }
47
+ .md h1, .md h3 { font-size: 1.1em; }
48
+ .md ul, .md ol { padding-inline-start: 1.5em; }
49
+ .md a { color: var(--yuva-accent); }
50
+ .md code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.88em; padding: 1px 5px; border-radius: 5px; background: var(--yuva-soft); }
51
+ .md pre { padding: 10px 12px; border-radius: 8px; background: var(--yuva-soft); overflow-x: auto; }
52
+ .md pre code { padding: 0; background: none; }
53
+ .md blockquote { padding-inline-start: 12px; border-inline-start: 3px solid var(--yuva-border); opacity: 0.85; }
54
+ .md table { border-collapse: collapse; display: block; overflow-x: auto; }
55
+ .md th, .md td { border: 1px solid var(--yuva-border); padding: 4px 8px; }
56
+ .md img { max-inline-size: 100%; }
57
+ .md hr { border: 0; border-block-start: 1px solid var(--yuva-border); }
58
+ @media (max-width: 560px) {
59
+ .post { padding: 12px; gap: 10px; }
60
+ }
61
+ `;class Composer{area=el("textarea");previewing=!1;constructor(rows){this.area.rows=rows,this.area.maxLength=20000,this.area.dir="auto"}get value(){return this.area.value.trim()}clear(){this.area.value="",this.previewing=!1}}function createThread(host){let s=host.s,t=(descriptor)=>translate(catalogs[host.locale()]??messages,descriptor,messages),reply=new Composer(4),draft=new Composer(6),title=el("input"),inline=null,edit=null;title.maxLength=200,title.dir="auto",title.className="field-title";for(let area of[reply.area,draft.area])area.addEventListener("input",()=>syncSend());title.addEventListener("input",()=>syncSend());function syncSend(){for(let button of host.root.querySelectorAll("[data-requires]")){let needs=button.dataset.requires,busy=s.busy.has(button.dataset.busy??""),ok=needs==="start"?title.value.trim().length>=3&&draft.value!=="":needs==="reply"?reply.value!=="":needs==="inline"?!!inline?.composer.value:needs==="edit"?!!edit?.composer.value&&(!!edit.post||edit.title.value.trim().length>=3):!0;button.disabled=busy||!ok}}async function start(){let heading=title.value.trim(),body=draft.value;if(heading.length<3||!body)return;let page=host.page(),discussion=await host.act("start",()=>host.client().startDiscussion({page_url:page,page_title:host.pageTitle()||void 0,title:heading,body}));if(!discussion)return;if(host.forget(),host.emit("yuva-discussion",{page,discussion_id:discussion.id,state:discussion.state}),host.page()!==page)return;title.value="",draft.clear(),s.items=[discussion,...s.items.filter((d)=>d.id!==discussion.id)],s.notice=discussion.state==="pending"?t({id:"NrGspR"}):"",s.thread={discussion,posts:[]},await host.open(discussion.id,!0)}async function send(composer,parent){let thread=s.thread,body=composer.value;if(!thread||!body)return;let page=host.page(),id=thread.discussion.id,post=await host.act(parent?`reply-${parent}`:"reply",()=>host.client().replyToDiscussion(id,{body,parent_post_id:parent}));if(!post)return;if(host.forget(),host.emit("yuva-post",{page,discussion_id:id,post_id:post.id,state:post.state}),composer.clear(),parent)inline=null;if(s.notice=post.state==="pending"?t({id:"YZayoP"}):"",s.thread?.discussion.id===id)s.thread={...s.thread,posts:[...s.thread.posts,post]},s.focus=`post-${post.id}`,host.render(),host.open(id,!1)}async function vote(post,opening){if(!s.writer)return void host.signIn();let updated=await host.act(`vote-${post.id}`,()=>host.client().voteDiscussionPost(post.id,!post.voted));if(!updated||!s.thread)return;if(host.forget(),opening){let discussion={...s.thread.discussion,votes:updated.votes,voted:updated.voted};s.thread={...s.thread,discussion},s.items=s.items.map((d)=>d.id===discussion.id?discussion:d)}else s.thread={...s.thread,posts:s.thread.posts.map((p)=>p.id===updated.id?{...p,...updated}:p)}}async function follow(){let thread=s.thread;if(!thread)return;if(!s.writer)return void host.signIn();let following=!thread.discussion.following;if(await host.act("follow",()=>host.client().followDiscussion(thread.discussion.id,following).then(()=>!0))&&s.thread?.discussion.id===thread.discussion.id)s.thread={...s.thread,discussion:{...s.thread.discussion,following}}}async function accept(post){let thread=s.thread;if(!thread)return;let discussion=await host.act(`accept-${post?.id??"clear"}`,()=>host.client().acceptDiscussionAnswer(thread.discussion.id,post?.id??null));if(!discussion)return;host.forget(),s.focus=post?`post-${post.id}`:"thread-title",await host.open(discussion.id,!1)}async function saveEdit(){let current=edit,thread=s.thread;if(!current||!thread)return;let body=current.composer.value,opening=!current.post,heading=current.title.value.trim();if(!body||opening&&heading.length<3)return;let postId=current.post?.id??thread.discussion.opening_post_id;if(!await host.act(`edit-${postId}`,()=>host.client().editDiscussionPost(postId,opening?{body,title:heading}:{body})))return;host.forget(),edit=null,s.focus=opening?"thread-title":`post-${postId}`,await host.open(thread.discussion.id,!1)}async function remove(postId,opening){let thread=s.thread;if(!thread)return;let done=await host.act(`delete-${postId}`,()=>host.client().deleteDiscussionPost(postId).then(()=>!0));if(s.confirm="",!done)return;if(host.forget(),opening)try{await host.client().getDiscussion(thread.discussion.id)}catch{return s.items=s.items.filter((d)=>d.id!==thread.discussion.id),s.thread=null,host.toList()}await host.open(thread.discussion.id,!1)}function md(html){let body=el("div","md");body.dir="auto",body.innerHTML=html;for(let link of body.querySelectorAll("a[href]"))link.setAttribute("target","_blank");return body}function composerBox(composer,options){let box=el("div","composer"),tabs=el("div","ctabs");tabs.setAttribute("role","tablist"),tabs.setAttribute("aria-label",options.label);let panelId=`p-${options.focusKey}`,write=host.button("ctab",t({id:"i4_LY_"}),`${options.focusKey}-write`,()=>{composer.previewing=!1,s.focus=options.focusKey,host.render()}),show=host.button("ctab",t({id:"rdUucN"}),`${options.focusKey}-preview`,()=>{composer.previewing=!0,host.render()});for(let[tab,selected]of[[write,!composer.previewing],[show,composer.previewing]])tab.setAttribute("role","tab"),tab.setAttribute("aria-selected",String(selected)),tab.setAttribute("aria-controls",panelId),tab.tabIndex=selected?0:-1,tab.addEventListener("keydown",(event)=>{if(event.key!=="ArrowLeft"&&event.key!=="ArrowRight")return;event.preventDefault(),composer.previewing=!composer.previewing,s.focus=`${options.focusKey}-${composer.previewing?"preview":"write"}`,host.render()});if(tabs.append(write,show),box.append(tabs),composer.previewing){let panel=el("div","preview md");if(panel.dir="auto",panel.id=panelId,panel.setAttribute("role","tabpanel"),panel.setAttribute("aria-label",t({id:"rdUucN"})),composer.value)panel.append(preview(composer.area.value));else panel.append(el("p","muted",t({id:"3PqJQG"})));box.append(panel)}else composer.area.id=panelId,composer.area.placeholder=options.placeholder,composer.area.setAttribute("aria-label",options.label),composer.area.dataset.key=options.focusKey,composer.area.disabled=s.busy.has(options.busy),composer.area.onkeydown=(event)=>{if(event.key==="Enter"&&(event.metaKey||event.ctrlKey))event.preventDefault(),options.onSubmit();else if(event.key==="Escape"&&options.onCancel)options.onCancel()},box.append(composer.area);let foot=el("div","foot");foot.append(el("span","hint",t({id:"Vwy_nT"})));let buttons=el("div","buttons");if(options.onCancel)buttons.append(host.button("ghost",t({id:"dEgA5A"}),`${options.focusKey}-cancel`,options.onCancel));let submit=host.button("send",s.busy.has(options.busy)?t({id:"Sad2tK"}):options.submit,`${options.focusKey}-submit`,options.onSubmit);return submit.dataset.requires=options.requires,submit.dataset.busy=options.busy,buttons.append(submit),foot.append(buttons),box.append(foot),box}function signInBox(text){let box=el("div","signin");return box.append(el("p","",text)),box.append(host.button("send",t({id:"5lWFkC"}),"sign-in-box",()=>void host.signIn())),box}function back(){let button=host.button("plain",t({id:"3CApMv"}),"back",()=>host.toList(),backIcon);button.style.alignSelf="flex-start",button.style.display="inline-flex",button.style.gap="6px",button.style.alignItems="center";let arrow=button.querySelector("svg");if(arrow&&host.direction()==="rtl")arrow.style.transform="scaleX(-1)";return button}function newView(){let form=el("div","form");if(form.append(el("h3","",t({id:"z1qf6l"}))),!s.writer)return form.append(signInBox(t({id:"99w-GZ"}))),[back(),form];if(title.placeholder=t({id:"MHrjPM"}),title.setAttribute("aria-label",t({id:"MHrjPM"})),title.dataset.key="new-title",title.disabled=s.busy.has("start"),form.append(title),form.append(composerBox(draft,{label:t({id:"PN38hZ"}),placeholder:t({id:"NjUiZ4"}),submit:t({id:"n5vqdp"}),busy:"start",requires:"start",focusKey:"new-body",onSubmit:()=>void start(),onCancel:()=>host.toList()})),host.mode()==="moderated"&&s.reader)form.append(el("p","muted",t({id:"RqsQKK"})));return[back(),form]}function editable(post){return!!post.mine&&!s.thread?.discussion.locked&&Date.now()-Date.parse(post.created_at)<editWindow}function postTools(post,top){let thread=s.thread;if(!thread)return null;let discussion=thread.discussion,opening=!post,id=post?.id??discussion.opening_post_id,mine=opening?!!discussion.mine:!!post.mine,deleted=opening?!!discussion.deleted:post.deleted,tools=el("div","tools");if(deleted)return null;if(!opening&&top&&!discussion.locked&&s.writer&&post.state==="published")tools.append(host.button("plain",t({id:"ImOQa9"}),`reply-to-${post.id}`,()=>{inline=inline?.target===top.id?inline:{target:top.id,composer:new Composer(3)},inline.composer.area.oninput=()=>syncSend(),s.focus=`inline-${top.id}`,host.render()}));if(!opening&&discussion.mine&&!post.parent_post_id&&post.state==="published"&&!discussion.locked){let accepted=discussion.answer_post_id===post.id,button=host.button("plain",accepted?t({id:"4-S4QM"}):t({id:"jhu92n"}),`accept-${post.id}`,()=>void accept(accepted?null:post),accepted?"":checkCircle);button.style.display="inline-flex",button.style.gap="4px",button.style.alignItems="center",button.disabled=s.busy.has(`accept-${post.id}`)||s.busy.has("accept-clear"),tools.append(button)}if(mine&&editable(opening?discussion:post))tools.append(host.button("plain",t({id:"ePK91l"}),`edit-${id}`,()=>{let composer=new Composer(opening?6:4);composer.area.value=opening?discussion.body:post.body,composer.area.oninput=()=>syncSend();let heading=el("input");heading.className="field-title",heading.maxLength=200,heading.dir="auto",heading.value=discussion.title,heading.oninput=()=>syncSend(),edit={post,composer,title:heading},s.focus=opening?"edit-title":`edit-body-${id}`,host.render()}));if(mine)if(s.confirm===id){let yes=host.button("plain danger",t({id:"cnGeoo"}),`delete-yes-${id}`,()=>void remove(id,opening));yes.disabled=s.busy.has(`delete-${id}`),tools.append(el("span","muted",opening?t({id:"rAl91-"}):t({id:"Klsidc"})),yes,host.button("plain",t({id:"PZ_kxo"}),`delete-no-${id}`,()=>{s.confirm="",s.focus=`delete-${id}`,host.render()}))}else tools.append(host.button("plain",t({id:"cnGeoo"}),`delete-${id}`,()=>{s.confirm=id,s.focus=`delete-no-${id}`,host.render()}));return tools.childElementCount?tools:null}function voteButton(target,opening){let button=host.button("vote",String(target.votes),`vote-${target.id}`,()=>void vote(target,opening),host.icons.up);return button.setAttribute("aria-pressed",String(!!target.voted)),button.setAttribute("aria-label",target.voted?t({id:"OVijcR",values:{0:target.votes}}):t({id:"dNOvhg",values:{0:target.votes}})),button.disabled=!!target.mine||!!s.thread?.discussion.locked||s.busy.has(`vote-${target.id}`),button}function postCard(post,top,children=[]){let accepted=s.thread.discussion.answer_post_id===post.id,card=el("article",`post${accepted?" accepted":""}${post.state==="pending"?" pending":""}`);card.dataset.key=`post-${post.id}`,card.tabIndex=-1,card.setAttribute("aria-label",host.authorName(post.author));let side=el("div","side");if(!post.deleted)side.append(voteButton(post,!1));if(!top||top.id===post.id)card.append(side);let body=el("div","post-body");if(accepted){let label=el("div","answer-label");label.innerHTML=checkCircle,label.append(t({id:"y-KXxN"})),body.append(label)}if(body.append(postHead(post.author,post.created_at,post.edited_at,post.state,post.deleted)),edit?.post?.id===post.id)body.append(editForm());else if(post.deleted)body.append(el("p","deleted",t({id:"HkXOWm"})));else body.append(md(post.body_html));let tools=postTools(post,top);if(tools)body.append(tools);if(children.length||inline?.target===post.id){let nested=el("div","children");for(let child of children)nested.append(postCard(child,post));if(inline?.target===post.id){let current=inline;nested.append(composerBox(current.composer,{label:t({id:"F_vGso"}),placeholder:t({id:"2Hlmdt"}),submit:t({id:"ImOQa9"}),busy:`reply-${post.id}`,requires:"inline",focusKey:`inline-${post.id}`,onSubmit:()=>void send(current.composer,post.id),onCancel:()=>{inline=null,s.focus=`reply-to-${post.id}`,host.render()}}))}body.append(nested)}return card.append(body),card}function postHead(author,created,edited,state,deleted){let head=el("div","post-head");if(!deleted){if(head.append(host.avatar(author,!0),el("span","name",host.authorName(author))),author.kind==="member"&&!author.deleted)head.append(host.badge("team"))}if(head.append(host.time(created)),edited&&!deleted)head.append(el("span","muted",t({id:"k4b5_X"})));if(state==="pending")head.append(host.badge("pending"));return head}function editForm(){let current=edit,form=el("div","form");if(!current.post)current.title.setAttribute("aria-label",t({id:"MHrjPM"})),current.title.dataset.key="edit-title",form.append(current.title);let id=current.post?.id??s.thread.discussion.opening_post_id;return form.append(composerBox(current.composer,{label:t({id:"qzVesX"}),placeholder:"",submit:t({id:"tfDRzk"}),busy:`edit-${id}`,requires:"edit",focusKey:`edit-body-${id}`,onSubmit:()=>void saveEdit(),onCancel:()=>{edit=null,s.focus=`edit-${id}`,host.render()}})),form}function threadView(){let nodes=[back()],thread=s.thread;if(!thread||s.threadState==="missing"){let box=el("div","empty");return box.append(el("p","",s.threadState==="loading"?t({id:"Pwqkdw"}):t({id:"VGqKyv"}))),nodes.push(box),nodes}let discussion=thread.discussion,view=el("div","thread"),head=el("div","thread-head");if(edit&&!edit.post)head.append(postHead(discussion.author,discussion.created_at,discussion.edited_at,discussion.state,!1)),head.append(editForm()),view.append(head);else{let heading=el("h3","",discussion.title);heading.dir="auto",heading.tabIndex=-1,heading.dataset.key="thread-title",head.append(heading);let meta=el("div","meta");if(discussion.answer_post_id)meta.append(host.badge("answered"));if(discussion.state==="pending")meta.append(host.badge("pending"));if(discussion.locked)meta.append(host.badge("locked"));if(meta.childElementCount)head.append(meta);view.append(head);let opening=el("article",`post${discussion.state==="pending"?" pending":""}`),side=el("div","side");if(!discussion.deleted)side.append(voteButton({id:discussion.opening_post_id,votes:discussion.votes,voted:discussion.voted,mine:discussion.mine},!0));let body=el("div","post-body");body.append(postHead(discussion.author,discussion.created_at,discussion.edited_at,discussion.state,!!discussion.deleted)),body.append(discussion.deleted?el("p","deleted",t({id:"8wRl7c"})):md(discussion.body_html));let tools=postTools(null,null);if(tools)body.append(tools);opening.append(side,body),view.append(opening)}let actions=el("div","bar"),followButton=host.button("ghost",discussion.following?t({id:"y6sq5j"}):t({id:"MKEPCY"}),"follow",()=>void follow(),bell);followButton.setAttribute("aria-pressed",String(!!discussion.following)),followButton.title=t({id:"Kl3TuI"}),followButton.disabled=s.busy.has("follow");let count=el("span","muted",t({id:"Hw3P48",values:{0:discussion.reply_count}}));if(actions.append(count,followButton),view.append(actions),s.threadState==="loading"&&!thread.posts.length&&discussion.reply_count>0){let skeleton=el("div","skeleton");skeleton.setAttribute("aria-busy","true"),skeleton.setAttribute("aria-label",t({id:"Pwqkdw"})),view.append(skeleton)}let tops=thread.posts.filter((p)=>!p.parent_post_id),replies=el("div","thread");for(let top of tops)replies.append(postCard(top,top,thread.posts.filter((p)=>p.parent_post_id===top.id)));if(tops.length)view.append(replies);if(s.notice)view.append(host.noticeBox(s.notice));if(discussion.locked)view.append(host.noticeBox(t({id:"JfAIiv"}),host.icons.lock));else if(!s.writer)view.append(signInBox(t({id:"PL0621"})));else view.append(composerBox(reply,{label:t({id:"F_vGso"}),placeholder:t({id:"2Hlmdt"}),submit:t({id:"ImOQa9"}),busy:"reply",requires:"reply",focusKey:"reply",onSubmit:()=>void send(reply)}));return nodes.push(view),nodes}return{threadView,newView,syncSend,close(){inline=null,edit=null},reset(){inline=null,edit=null,reply.clear()}}}export{createThread,styles};
@@ -1,4 +1,4 @@
1
- import{launcherOf,readStored,writeStored}from"./index-cmr5w646.js";import{richText}from"./index-jdxce2se.js";import{ApiError2,randomId,createYuvaClient2}from"./index-dj5dhqc1.js";import{setupI18n}from"@lingui/core";var messages=JSON.parse(`{"-HY5kX":["New conversation"],"-f5Tkb":["Bad"],"09Tv5j":["Reconnecting…"],"0XGLbP":["Your sign-in has expired. Reload the page and try again."],"1EICzz":["We're away right now"],"4TqZiz":["Could not send your rating. Try again."],"6Uau97":["Skip"],"6gRgw8":["Retry"],"6lGaum":["Seen"],"ASr-r0":["Show older conversations"],"Amai22":["Chat is not available right now."],"E_qvzP":["Enter a valid e-mail address."],"GQVIIl":["You seem to be offline."],"JkW3Ph":["This file type is not accepted."],"JlFcis":["Send"],"KDw4GX":["Try again"],"M62PBt":["Nobody is available right now. Leave your e-mail and we'll send the reply there too."],"N7m8E-":["Attach files"],"NBdIgR":["Comment"],"OEEQKT":["Good"],"Pwqkdw":["Loading…"],"PxYAul":["Typing…"],"RzWUUK":["Write a message…"],"S63MQu":["All conversations"],"SOk0EB":["Thanks for your feedback"],"Sad2tK":["Sending…"],"SdV5Cn":["Send us a message and we will reply here."],"UY1vmE":["Attachment"],"VggdQJ":["Usually replies in ",["duration"]],"XJURKP":["E-mail address"],"YyNOE7":["Conversation"],"ZxJcgC":["Could not save your e-mail address. Try again."],"axQ1h6":["Anything you'd like to add? (optional)"],"eOu9Px":["The file is too large."],"h69WC6":["Sent"],"iGNUZJ":["Thanks! We'll e-mail you at ",["known"]," if you're gone when we reply."],"meAa31":["No conversations yet"],"nhTADq":["We'll reply as soon as we can"],"njBr8W":["you@example.com"],"oXOSPE":["Online"],"t7TeQU":["Messages"],"tHaDPf":[["name"]," is typing…"],"tfDRzk":["Save"],"tzsBOP":["Too many attempts. Wait a moment and try again."],"uA8iBc":["How did we do?"],"upFvcp":["Not sent."],"w61W3L":["Remove ",["0"]],"xDAtGP":["Message"],"ydzYKJ":["You:"],"yz7wBu":["Close"],"zLzEI3":["Sign in to chat with us."]}`);var messages2=JSON.parse('{"-HY5kX":["Yeni konuşma"],"-f5Tkb":["Kötü"],"09Tv5j":["Yeniden bağlanıyor…"],"0XGLbP":["Oturumunuzun süresi doldu. Sayfayı yenileyip tekrar deneyin."],"1EICzz":["Şu anda uzaktayız"],"4TqZiz":["Değerlendirmeniz gönderilemedi. Tekrar deneyin."],"6Uau97":["Geç"],"6gRgw8":["Tekrar dene"],"6lGaum":["Görüldü"],"ASr-r0":["Eski konuşmaları göster"],"Amai22":["Sohbet şu anda kullanılamıyor."],"E_qvzP":["Geçerli bir e-posta adresi girin."],"GQVIIl":["Çevrimdışı görünüyorsunuz."],"JkW3Ph":["Bu dosya türü kabul edilmiyor."],"JlFcis":["Gönder"],"KDw4GX":["Tekrar dene"],"M62PBt":["Şu anda müsait kimse yok. E-posta adresinizi bırakın, yanıtı oraya da gönderelim."],"N7m8E-":["Dosya ekle"],"NBdIgR":["Yorum"],"OEEQKT":["İyi"],"Pwqkdw":["Yükleniyor…"],"PxYAul":["Yazıyor…"],"RzWUUK":["Bir mesaj yazın…"],"S63MQu":["Tüm konuşmalar"],"SOk0EB":["Geri bildiriminiz için teşekkürler"],"Sad2tK":["Gönderiliyor…"],"SdV5Cn":["Bize bir mesaj gönderin, yanıtımız burada görünecek."],"UY1vmE":["Ek"],"VggdQJ":["Genellikle ",["duration"]," içinde yanıt verir"],"XJURKP":["E-posta adresi"],"YyNOE7":["Konuşma"],"ZxJcgC":["E-posta adresiniz kaydedilemedi. Tekrar deneyin."],"axQ1h6":["Eklemek istediğiniz bir şey var mı? (isteğe bağlı)"],"eOu9Px":["Dosya çok büyük."],"h69WC6":["Gönderildi"],"iGNUZJ":["Teşekkürler! Yanıtladığımızda burada değilseniz ",["known"]," adresine e-posta göndereceğiz."],"meAa31":["Henüz konuşma yok"],"nhTADq":["En kısa sürede yanıt vereceğiz"],"njBr8W":["siz@ornek.com"],"oXOSPE":["Çevrimiçi"],"t7TeQU":["Mesajlar"],"tHaDPf":[["name"]," yazıyor…"],"tfDRzk":["Kaydet"],"tzsBOP":["Çok fazla deneme. Biraz bekleyip tekrar deneyin."],"uA8iBc":["Nasıldık?"],"upFvcp":["Gönderilemedi."],"w61W3L":[["0"]," kaldır"],"xDAtGP":["Mesaj"],"ydzYKJ":["Siz:"],"yz7wBu":["Kapat"],"zLzEI3":["Bizimle sohbet etmek için giriş yapın."]}');var styles=`
1
+ import{launcherOf,readStored,writeStored}from"./index-e2tek7yk.js";import{ApiError2,randomId,createYuvaClient2}from"./index-dj5dhqc1.js";import{richText}from"./index-jdxce2se.js";import{setupI18n}from"@lingui/core";var messages=JSON.parse(`{"-HY5kX":["New conversation"],"-f5Tkb":["Bad"],"09Tv5j":["Reconnecting…"],"0XGLbP":["Your sign-in has expired. Reload the page and try again."],"1EICzz":["We're away right now"],"4TqZiz":["Could not send your rating. Try again."],"6Uau97":["Skip"],"6gRgw8":["Retry"],"6lGaum":["Seen"],"ASr-r0":["Show older conversations"],"Amai22":["Chat is not available right now."],"E_qvzP":["Enter a valid e-mail address."],"GQVIIl":["You seem to be offline."],"JkW3Ph":["This file type is not accepted."],"JlFcis":["Send"],"KDw4GX":["Try again"],"M62PBt":["Nobody is available right now. Leave your e-mail and we'll send the reply there too."],"N7m8E-":["Attach files"],"NBdIgR":["Comment"],"OEEQKT":["Good"],"Pwqkdw":["Loading…"],"PxYAul":["Typing…"],"RzWUUK":["Write a message…"],"S63MQu":["All conversations"],"SOk0EB":["Thanks for your feedback"],"Sad2tK":["Sending…"],"SdV5Cn":["Send us a message and we will reply here."],"UY1vmE":["Attachment"],"VggdQJ":["Usually replies in ",["duration"]],"XJURKP":["E-mail address"],"YyNOE7":["Conversation"],"ZxJcgC":["Could not save your e-mail address. Try again."],"axQ1h6":["Anything you'd like to add? (optional)"],"eOu9Px":["The file is too large."],"h69WC6":["Sent"],"iGNUZJ":["Thanks! We'll e-mail you at ",["known"]," if you're gone when we reply."],"meAa31":["No conversations yet"],"nhTADq":["We'll reply as soon as we can"],"njBr8W":["you@example.com"],"oXOSPE":["Online"],"t7TeQU":["Messages"],"tHaDPf":[["name"]," is typing…"],"tfDRzk":["Save"],"tzsBOP":["Too many attempts. Wait a moment and try again."],"uA8iBc":["How did we do?"],"upFvcp":["Not sent."],"w61W3L":["Remove ",["0"]],"xDAtGP":["Message"],"ydzYKJ":["You:"],"yz7wBu":["Close"],"zLzEI3":["Sign in to chat with us."]}`);var messages2=JSON.parse('{"-HY5kX":["Yeni konuşma"],"-f5Tkb":["Kötü"],"09Tv5j":["Yeniden bağlanıyor…"],"0XGLbP":["Oturumunuzun süresi doldu. Sayfayı yenileyip tekrar deneyin."],"1EICzz":["Şu anda uzaktayız"],"4TqZiz":["Değerlendirmeniz gönderilemedi. Tekrar deneyin."],"6Uau97":["Geç"],"6gRgw8":["Tekrar dene"],"6lGaum":["Görüldü"],"ASr-r0":["Eski konuşmaları göster"],"Amai22":["Sohbet şu anda kullanılamıyor."],"E_qvzP":["Geçerli bir e-posta adresi girin."],"GQVIIl":["Çevrimdışı görünüyorsunuz."],"JkW3Ph":["Bu dosya türü kabul edilmiyor."],"JlFcis":["Gönder"],"KDw4GX":["Tekrar dene"],"M62PBt":["Şu anda müsait kimse yok. E-posta adresinizi bırakın, yanıtı oraya da gönderelim."],"N7m8E-":["Dosya ekle"],"NBdIgR":["Yorum"],"OEEQKT":["İyi"],"Pwqkdw":["Yükleniyor…"],"PxYAul":["Yazıyor…"],"RzWUUK":["Bir mesaj yazın…"],"S63MQu":["Tüm konuşmalar"],"SOk0EB":["Geri bildiriminiz için teşekkürler"],"Sad2tK":["Gönderiliyor…"],"SdV5Cn":["Bize bir mesaj gönderin, yanıtımız burada görünecek."],"UY1vmE":["Ek"],"VggdQJ":["Genellikle ",["duration"]," içinde yanıt verir"],"XJURKP":["E-posta adresi"],"YyNOE7":["Konuşma"],"ZxJcgC":["E-posta adresiniz kaydedilemedi. Tekrar deneyin."],"axQ1h6":["Eklemek istediğiniz bir şey var mı? (isteğe bağlı)"],"eOu9Px":["Dosya çok büyük."],"h69WC6":["Gönderildi"],"iGNUZJ":["Teşekkürler! Yanıtladığımızda burada değilseniz ",["known"]," adresine e-posta göndereceğiz."],"meAa31":["Henüz konuşma yok"],"nhTADq":["En kısa sürede yanıt vereceğiz"],"njBr8W":["siz@ornek.com"],"oXOSPE":["Çevrimiçi"],"t7TeQU":["Mesajlar"],"tHaDPf":[["name"]," yazıyor…"],"tfDRzk":["Kaydet"],"tzsBOP":["Çok fazla deneme. Biraz bekleyip tekrar deneyin."],"uA8iBc":["Nasıldık?"],"upFvcp":["Gönderilemedi."],"w61W3L":[["0"]," kaldır"],"xDAtGP":["Mesaj"],"ydzYKJ":["Siz:"],"yz7wBu":["Kapat"],"zLzEI3":["Bizimle sohbet etmek için giriş yapın."]}');var styles=`
2
2
  [hidden] { display: none !important; }
3
3
  .header {
4
4
  display: flex;