import{F as H,_ as X,p as A,s as $,a as ne,b as He,x as Je,u as De,c as e,k as E,d as we,g as dt,y as kt,e as Ni,f as Et,h as Nt,i as ft,q as ge,j as et,l as As,L as Ae,m as rn,A as ut,n as Ui,o as zc,r as Fi,t as Oi,v as Rs,C as Es,w as Xe,z as _s,B as ot,T as Ls,D as Ms,P as Ds,E as _n,G as St,H as qe,I as zi,J as Ps,K as qt,M as Ns,N as Us,O as Zn,Q as Jn,R as Fs,S as Qn,U as Ln,V as Fe,W as Os,X as zs}from"./useTitle-KMkGka9H.js";import{u as Mn,s as se,a as _e,o as ei,b as Bs,I as v,M as Re,A as st,N as _t,c as Ze,d as pe,e as ze,f as tt,L as re,g as Bi,l as Hs,t as ti,R as It,h as Ge,p as Ut,i as Qe,j as Ee,k as Hi,m as Sn,E as qi,n as je,q as rt,r as qs,S as cn,v as ni,T as Vi,w as it,x as Dn,y as Be,z as ht,B as ii,C as Vs,D as Gs,F as Pn,G as Gi,H as js,J as Ys,K as Ws,O as ji,P as Vt,Q as Ks,U as Xs,V as Yi,W as Zs,X as wt,Y as Nn,Z as Js,_ as Wi,$ as Qs,a0 as Ki,a1 as eo,a2 as to,a3 as no,a4 as si,a5 as io,a6 as Kt}from"./fuse-GSnTzOyH.js";import"./tinyld-light-PxOyhYWY.js";import"./index-dbOm7oTI.js";var Xi=so;function so(t,n,s){var i=null,o=null,r=function(){i&&(clearTimeout(i),o=null,i=null)},f=function(){var a=o;r(),a&&a()},u=function(){if(!n)return t.apply(this,arguments);var a=this,d=arguments,p=s&&!i;if(r(),o=function(){t.apply(a,d)},i=setTimeout(function(){if(i=null,!p){var c=o;return o=null,c()}},n),p)return o()};return u.cancel=r,u.flush=f,u}/*! * swiped-events.js - v@version@ * Pure JavaScript swipe events * https://github.com/john-doherty/swiped-events * @inspiration https://stackoverflow.com/questions/16348031/disable-scrolling-when-touch-moving-certain-element * @author John Doherty * @license MIT */(function(t,n){"use strict";typeof t.CustomEvent!="function"&&(t.CustomEvent=function(l,b){b=b||{bubbles:!1,cancelable:!1,detail:void 0};var m=n.createEvent("CustomEvent");return m.initCustomEvent(l,b.bubbles,b.cancelable,b.detail),m},t.CustomEvent.prototype=t.Event.prototype),n.addEventListener("touchstart",p,!1),n.addEventListener("touchmove",c,!1),n.addEventListener("touchend",d,!1);var s=null,i=null,o=null,r=null,f=null,u=null,a=0;function d(l){if(u===l.target){var b=parseInt(h(u,"data-swipe-threshold","20"),10),m=h(u,"data-swipe-unit","px"),k=parseInt(h(u,"data-swipe-timeout","500"),10),g=Date.now()-f,y="",T=l.changedTouches||l.touches||[];if(m==="vh"&&(b=Math.round(b/100*n.documentElement.clientHeight)),m==="vw"&&(b=Math.round(b/100*n.documentElement.clientWidth)),Math.abs(o)>Math.abs(r)?Math.abs(o)>b&&g0?y="swiped-left":y="swiped-right"):Math.abs(r)>b&&g0?y="swiped-up":y="swiped-down"),y!==""){var w={dir:y.replace(/swiped-/,""),touchType:(T[0]||{}).touchType||"direct",fingers:a,xStart:parseInt(s,10),xEnd:parseInt((T[0]||{}).clientX||-1,10),yStart:parseInt(i,10),yEnd:parseInt((T[0]||{}).clientY||-1,10)};u.dispatchEvent(new CustomEvent("swiped",{bubbles:!0,cancelable:!0,detail:w})),u.dispatchEvent(new CustomEvent(y,{bubbles:!0,cancelable:!0,detail:w}))}s=null,i=null,f=null}}function p(l){l.target.getAttribute("data-swipe-ignore")!=="true"&&(u=l.target,f=Date.now(),s=l.touches[0].clientX,i=l.touches[0].clientY,o=0,r=0,a=l.touches.length)}function c(l){if(!(!s||!i)){var b=l.touches[0].clientX,m=l.touches[0].clientY;o=s-b,r=i-m}}function h(l,b,m){for(;l&&l!==n.documentElement;){var k=l.getAttribute(b);if(k)return k;l=l.parentNode}return m}})(window,document);function Lt(t=()=>{},n=[]){const s=H(t);X(()=>{s.current=t},[n]),X(()=>{const i=()=>{const o=document.hidden||document.visibilityState==="hidden";s.current(!o)};return document.addEventListener("visibilitychange",i),()=>document.removeEventListener("visibilitychange",i)},[])}const oo=1e3*3,ao=15e3,ro=Je(function({isLoggedIn:n}){const[s,i]=A(!0);Lt(i);const o=async(u,a,d)=>{var p;if($.notificationsLast){const c=u.v1.notifications.list({limit:1,sinceId:$.notificationsLast.id}),{value:h}=await c.next();if(h!=null&&h.length)if(d)$.notificationsShowNew=!0;else{let l;try{const b=await u.v1.markers.fetch({timeline:"notifications"});l=(p=b==null?void 0:b.notifications)==null?void 0:p.lastReadId}catch{}l?$.notificationsShowNew=h[0].id!==l:$.notificationsShowNew=!0}}};X(()=>{let u,a;if(n&&s){const{masto:d,streaming:p,instance:c}=ne();(async()=>{await o(d,c);let h=!1;p&&(a=setTimeout(()=>{(async()=>{try{h=!0,u=p.user.notification.subscribe();for await(const l of u){if(!u||!s)break;l.event==="notification"&&He(l.payload,c,{skipThreading:!0}),$.notificationsShowNew=!0}}catch{h=!1}h||(a=setInterval(()=>{o(d,c,!0)},ao))})()},oo))})()}return()=>{var d;(d=u==null?void 0:u.unsubscribe)==null||d.call(u),u=null,clearTimeout(a),clearInterval(a)}},[s,n]);const r=H(),f=()=>{r.current=Date.now(),fetch("./version.json").then(u=>u.json()).then(u=>{u&&($.appVersion=u)}).catch(u=>{})};return Mn(f,s&&1e3*60*30),Lt(u=>{u&&(r.current?Date.now()-r.current>1e3*60*60&&f():f())}),_e("shift+alt+k",()=>{const u=$.settings.cloakMode;$.settings.cloakMode=!u,se({text:`Cloak mode ${u?"disabled":"enabled"}`})}),null});function co(){const t=De($);function n(s){if(t.composerState.minimized){$.composerState.minimized=!1,ei();return}s.shiftKey?Bs()||($.showCompose=!0):(ei(),$.showCompose=!0)}return _e("c, shift+c",n,{ignoreEventWhen:s=>!!document.querySelector("#modal-container > *")}),e("button",{type:"button",id:"compose-button",onClick:n,class:`${t.composerState.minimized?"min":""} ${t.composerState.publishing?"loading":""} ${t.composerState.publishingError?"error":""}`,children:e(v,{icon:"quill",size:"xl",alt:"Compose"})})}const lo=Je(function(){const n=De($);function s(){$.showKeyboardShortcutsHelp=!1}return _e("?, shift+?, shift+slash",i=>{$.showKeyboardShortcutsHelp=!0},{ignoreEventWhen:i=>!!document.querySelector("#modal-container > *")}),!!n.showKeyboardShortcutsHelp&&e(Re,{onClose:s,children:e("div",{id:"keyboard-shortcuts-help-container",class:"sheet",tabindex:"-1",children:[e("button",{type:"button",class:"sheet-close",onClick:s,children:e(v,{icon:"x"})}),e("header",{children:e("h2",{children:"Keyboard shortcuts"})}),e("main",{children:e("table",{children:[{action:"Keyboard shortcuts help",keys:e("kbd",{children:"?"})},{action:"Next post",keys:e("kbd",{children:"j"})},{action:"Previous post",keys:e("kbd",{children:"k"})},{action:"Skip carousel to next post",keys:e(E,{children:[e("kbd",{children:"Shift"})," + ",e("kbd",{children:"j"})]})},{action:"Skip carousel to previous post",keys:e(E,{children:[e("kbd",{children:"Shift"})," + ",e("kbd",{children:"k"})]})},{action:"Load new posts",keys:e("kbd",{children:"."})},{action:"Open post details",keys:e(E,{children:[e("kbd",{children:"Enter"})," or ",e("kbd",{children:"o"})]})},{action:e(E,{children:["Expand content warning or",e("br",{}),"toggle expanded/collapsed thread"]}),keys:e("kbd",{children:"x"})},{action:"Close post or dialogs",keys:e(E,{children:[e("kbd",{children:"Esc"})," or ",e("kbd",{children:"Backspace"})]})},{action:"Focus column in multi-column mode",keys:e(E,{children:[e("kbd",{children:"1"})," to ",e("kbd",{children:"9"})]})},{action:"Compose new post",keys:e("kbd",{children:"c"})},{action:"Compose new post (new window)",className:"insignificant",keys:e(E,{children:[e("kbd",{children:"Shift"})," + ",e("kbd",{children:"c"})]})},{action:"Send post",keys:e(E,{children:[e("kbd",{children:"Ctrl"})," + ",e("kbd",{children:"Enter"})," or ",e("kbd",{children:"⌘"})," +"," ",e("kbd",{children:"Enter"})]})},{action:"Search",keys:e("kbd",{children:"/"})},{action:"Reply",keys:e("kbd",{children:"r"})},{action:"Reply (new window)",className:"insignificant",keys:e(E,{children:[e("kbd",{children:"Shift"})," + ",e("kbd",{children:"r"})]})},{action:"Like (favourite)",keys:e(E,{children:[e("kbd",{children:"l"})," or ",e("kbd",{children:"f"})]})},{action:"Boost",keys:e(E,{children:[e("kbd",{children:"Shift"})," + ",e("kbd",{children:"b"})]})},{action:"Bookmark",keys:e("kbd",{children:"d"})},{action:"Toggle Cloak mode",keys:e(E,{children:[e("kbd",{children:"Shift"})," + ",e("kbd",{children:"Alt"})," + ",e("kbd",{children:"k"})]})}].map(({action:i,className:o,keys:r})=>e("tr",{children:[e("th",{class:o,children:i}),e("td",{children:r})]},i))})})]})})}),Zi=new Set,We=new WeakMap,Mt=new WeakMap,vt=new WeakMap,In=new WeakMap,uo=new WeakMap,Dt=new WeakMap,ln=new WeakMap,Bt=new WeakSet;let gt,Un=0,Fn=0;const ct="__aa_tgt",Gt="__aa_del",dn="__aa_new",ho=t=>{const n=yo(t);n&&n.forEach(s=>wo(s))},fo=t=>{t.forEach(n=>{n.target===gt&&mo(),We.has(n.target)&&Ct(n.target)})};function po(t){const n=In.get(t);n==null||n.disconnect();let s=We.get(t),i=0;const o=5;s||(s=Pt(t),We.set(t,s));const{offsetWidth:r,offsetHeight:f}=gt,a=[s.top-o,r-(s.left+o+s.width),f-(s.top+o+s.height),s.left-o].map(p=>`${-1*Math.floor(p)}px`).join(" "),d=new IntersectionObserver(()=>{++i>1&&Ct(t)},{root:gt,threshold:1,rootMargin:a});d.observe(t),In.set(t,d)}function Ct(t){clearTimeout(ln.get(t));const n=fn(t),s=jt(n)?500:n.duration;ln.set(t,setTimeout(async()=>{const i=vt.get(t);try{await(i==null?void 0:i.finished),We.set(t,Pt(t)),po(t)}catch{}},s))}function mo(){clearTimeout(ln.get(gt)),ln.set(gt,setTimeout(()=>{Zi.forEach(t=>ts(t,n=>Ji(()=>Ct(n))))},100))}function go(t){setTimeout(()=>{uo.set(t,setInterval(()=>Ji(Ct.bind(null,t)),2e3))},Math.round(2e3*Math.random()))}function Ji(t){typeof requestIdleCallback=="function"?requestIdleCallback(()=>t()):requestAnimationFrame(()=>t())}let Cn,Rt;const bo=typeof window<"u"&&"ResizeObserver"in window;bo&&(gt=document.documentElement,Cn=new MutationObserver(ho),Rt=new ResizeObserver(fo),window.addEventListener("scroll",()=>{Fn=window.scrollY,Un=window.scrollX}),Rt.observe(gt));function yo(t){return t.reduce((i,o)=>[...i,...Array.from(o.addedNodes),...Array.from(o.removedNodes)],[]).every(i=>i.nodeName==="#comment")?!1:t.reduce((i,o)=>{if(i===!1)return!1;if(o.target instanceof Element){if(gn(o.target),!i.has(o.target)){i.add(o.target);for(let r=0;rs(t,Dt.has(t)));for(let s=0;so(i,Dt.has(i)))}}function zn(t){return Array.isArray(t)?t:[t]}function jt(t){return typeof t=="function"}function ko(t){const n=We.get(t),s=Pt(t);if(!On(t))return We.set(t,s);let i;if(!n)return;const o=fn(t);if(typeof o!="function"){const r=n.left-s.left,f=n.top-s.top,[u,a,d,p]=Qi(t,n,s),c={transform:`translate(${r}px, ${f}px)`},h={transform:"translate(0, 0)"};u!==a&&(c.width=`${u}px`,h.width=`${a}px`),d!==p&&(c.height=`${d}px`,h.height=`${p}px`),i=t.animate([c,h],{duration:o.duration,easing:o.easing})}else{const[r]=zn(o(t,"remain",n,s));i=new Animation(r),i.play()}vt.set(t,i),We.set(t,s),i.addEventListener("finish",Ct.bind(null,t))}function oi(t){dn in t&&delete t[dn];const n=Pt(t);We.set(t,n);const s=fn(t);if(!On(t))return;let i;if(typeof s!="function")i=t.animate([{transform:"scale(.98)",opacity:0},{transform:"scale(0.98)",opacity:0,offset:.5},{transform:"scale(1)",opacity:1}],{duration:s.duration*1.5,easing:"ease-in"});else{const[o]=zn(s(t,"add",n));i=new Animation(o),i.play()}vt.set(t,i),i.addEventListener("finish",Ct.bind(null,t))}function ai(t,n){var s;t.remove(),We.delete(t),Mt.delete(t),vt.delete(t),(s=In.get(t))===null||s===void 0||s.disconnect(),setTimeout(()=>{if(Gt in t&&delete t[Gt],Object.defineProperty(t,dn,{value:!0,configurable:!0}),n&&t instanceof HTMLElement)for(const i in n)t.style[i]=""},0)}function So(t){var n;if(!Mt.has(t)||!We.has(t))return;const[s,i]=Mt.get(t);Object.defineProperty(t,Gt,{value:!0,configurable:!0});const o=window.scrollX,r=window.scrollY;if(i&&i.parentNode&&i.parentNode instanceof Element?i.parentNode.insertBefore(t,i):s&&s.parentNode?s.parentNode.appendChild(t):(n=es(t))===null||n===void 0||n.appendChild(t),!On(t))return ai(t);const[f,u,a,d]=Co(t),p=fn(t),c=We.get(t);(o!==Un||r!==Fn)&&Io(t,o,r,p);let h,l={position:"absolute",top:`${f}px`,left:`${u}px`,width:`${a}px`,height:`${d}px`,margin:"0",pointerEvents:"none",transformOrigin:"center",zIndex:"100"};if(!jt(p))Object.assign(t.style,l),h=t.animate([{transform:"scale(1)",opacity:1},{transform:"scale(.98)",opacity:0}],{duration:p.duration,easing:"ease-out"});else{const[b,m]=zn(p(t,"remove",c));(m==null?void 0:m.styleReset)!==!1&&(l=(m==null?void 0:m.styleReset)||l,Object.assign(t.style,l)),h=new Animation(b),h.play()}vt.set(t,h),h.addEventListener("finish",ai.bind(null,t,l))}function Io(t,n,s,i){const o=Un-n,r=Fn-s,f=document.documentElement.style.scrollBehavior;if(getComputedStyle(gt).scrollBehavior==="smooth"&&(document.documentElement.style.scrollBehavior="auto"),window.scrollTo(window.scrollX+o,window.scrollY+r),!t.parentElement)return;const a=t.parentElement;let d=a.clientHeight,p=a.clientWidth;const c=performance.now();function h(){requestAnimationFrame(()=>{if(!jt(i)){const l=d-a.clientHeight,b=p-a.clientWidth;c+i.duration>performance.now()?(window.scrollTo({left:window.scrollX-b,top:window.scrollY-l}),d=a.clientHeight,p=a.clientWidth,h()):document.documentElement.style.scrollBehavior=f}})}h()}function Co(t){const n=We.get(t),[s,,i]=Qi(t,n,Pt(t));let o=t.parentElement;for(;o&&(getComputedStyle(o).position==="static"||o instanceof HTMLBodyElement);)o=o.parentElement;o||(o=document.body);const r=getComputedStyle(o),f=We.get(o)||Pt(o),u=Math.round(n.top-f.top)-at(r.borderTopWidth),a=Math.round(n.left-f.left)-at(r.borderLeftWidth);return[u,a,s,i]}function ns(t,n={}){return Cn&&Rt&&(window.matchMedia("(prefers-reduced-motion: reduce)").matches&&!jt(n)&&!n.disrespectUserMotionPreference||(Bt.add(t),getComputedStyle(t).position==="static"&&Object.assign(t.style,{position:"relative"}),ts(t,Ct,go,o=>Rt==null?void 0:Rt.observe(o)),jt(n)?Dt.set(t,n):Dt.set(t,{duration:250,easing:"ease-in-out",...n}),Cn.observe(t,{childList:!0}),Zi.add(t))),Object.freeze({parent:t,enable:()=>{Bt.add(t)},disable:()=>{Bt.delete(t)},isEnabled:()=>Bt.has(t)})}function Bn(t){const n=H(null),[s,i]=A(),o=r=>{s&&(r?s.enable():s.disable())};return X(()=>{n.current instanceof HTMLElement&&i(ns(n.current,t||{}))},[]),[n,o]}function To({onClose:t}){const{masto:n}=ne(),s=we.local.getJSON("accounts"),i=dt(),o=s.length>1,[r,f]=kt(a=>a+1,0),[u]=Bn();return e("div",{id:"accounts-container",class:"sheet",tabIndex:"-1",children:[!!t&&e("button",{type:"button",class:"sheet-close",onClick:t,children:e(v,{icon:"x"})}),e("header",{class:"header-grid",children:e("h2",{children:"Accounts"})}),e("main",{children:e("section",{children:[e("ul",{class:"accounts-list",ref:u,children:s.map((a,d)=>{const p=a.info.id===i,c=d===0;return e("li",{children:[e("div",{children:[o&&e("span",{class:`current ${p?"is-current":""}`,children:e(v,{icon:"check-circle",alt:"Current"})}),e(st,{url:a.info.avatarStatic,size:"xxl",onDblClick:async()=>{if(p)try{const h=await n.v1.accounts.$select(a.info.id).fetch();a.info=h,we.local.setJSON("accounts",s),f()}catch{}}}),e(_t,{account:o?{...a.info,acct:/@/.test(a.info.acct)?a.info.acct:`${a.info.acct}@${a.instanceURL}`}:a.info,showAcct:!0,onClick:()=>{p?$.showAccount=`${a.info.username}@${a.instanceURL}`:(Ni(a.info.id),location.reload())}})]}),e("div",{class:"actions",children:[c&&o&&e(E,{children:[e("span",{class:"tag",children:"Default"})," "]}),e(Ze,{align:"end",menuButton:e("button",{type:"button",title:"More",class:"plain more-button",children:e(v,{icon:"more",size:"l",alt:"More"})}),children:[e(pe,{onClick:()=>{$.showAccount=`${a.info.username}@${a.instanceURL}`},children:[e(v,{icon:"user"}),e("span",{children:"View profile…"})]}),e(ze,{}),o&&e(pe,{disabled:c,onClick:()=>{s.splice(d,1),s.unshift(a),we.local.setJSON("accounts",s),f()},children:[e(v,{icon:"check-circle"}),e("span",{children:"Set as default"})]}),e(tt,{subMenu:!0,confirmLabel:e(E,{children:[e(v,{icon:"exit"}),e("span",{children:["Log out @",a.info.acct,"?"]})]}),disabled:!p,menuItemClassName:"danger",onClick:()=>{s.splice(d,1),we.local.setJSON("accounts",s),location.href=location.pathname||"/"},children:[e(v,{icon:"exit"}),e("span",{children:"Log out…"})]})]})]})]},a.info.id)})}),e("p",{children:e(re,{to:"/login",class:"button plain2",onClick:t,children:[e(v,{icon:"plus"})," ",e("span",{children:"Add an existing account"})]})}),o&&e("p",{children:e("small",{children:["Note: ",e("i",{children:"Default"})," account will always be used for first load. Switched accounts will persist during the session."]})})]})})]})}const Hn="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xml:space='preserve'%20fill-rule='evenodd'%20stroke-linejoin='round'%20stroke-miterlimit='2'%20clip-rule='evenodd'%20viewBox='0%200%2064%2064'%3e%3cpath%20fill='none'%20d='M0%200h63.994v63.994H0z'/%3e%3cpath%20fill='%23a4bff7'%20d='M37.774%2011.471c14.639%203.752%2019.034%2016.557%2015.889%2031.304-.696%203.261-2.563%206.661-6.356%208.693-3.204%201.717-8.07%202.537-15.338.55l-9.634-2.404C11.651%2046.992%208.378%2038.733%2010.027%2031.823c3.627-15.201%2015.543-23.48%2027.747-20.352Z'/%3e%3cpath%20fill='%23d8e7fe'%20d='M36.76%2015.429c12.289%203.15%2015.547%2014.114%2012.907%2026.493-.947%204.44-4.937%209.365-16.664%206.143l-9.684-2.417c-7.854-1.923-10.53-7.8-9.318-12.877%203.016-12.639%2012.611-19.943%2022.759-17.342Z'/%3e%3cpath%20fill='%236081e6'%20d='M27.471%2024.991c-1.457-.698-7.229%203.213-7.663%208.926-.182%202.39%204.55%203.237%205.071-.169.725-4.743%203.715-8.218%202.592-8.757Zm10.746%202.005c-2.083.327-.382%205.901-.595%2010.727-.123%202.8%204.388%203.464%204.703%202.011%201.098-5.073-2.066-13.058-4.108-12.738Z'/%3e%3c/svg%3e";function ri(t){const{masto:n}=ne();return n.v1.push.subscription.create(t)}function xo(){const{masto:t}=ne();return t.v1.push.subscription.fetch()}function $o(t){const{masto:n}=ne();return n.v1.push.subscription.update(t)}function Ao(){const{masto:t}=ne();return t.v1.push.subscription.remove()}function pn(){return"serviceWorker"in navigator&&"PushManager"in window}function Ro(){return navigator.serviceWorker.getRegistration()}async function qn(){const t=await Ro(),n=t?await t.pushManager.getSubscription():void 0;return{registration:t,subscription:n}}function is(t){const n="=".repeat((4-t.length%4)%4),s=`${t}${n}`.replace(/-/g,"+").replace(/_/g,"/"),i=window.atob(s),o=new Uint8Array(i.length);for(let r=0;r{l.preventDefault();const m=new FormData(i.current).get("theme"),k=document.documentElement;if(m==="auto"){k.classList.remove("is-light","is-dark");const g=document.querySelector('meta[data-theme-setting="manual"]');g&&(g.name=""),document.querySelectorAll('meta[data-theme-setting="auto"]').forEach(T=>{T.name="theme-color"})}else{k.classList.toggle("is-light",m==="light"),k.classList.toggle("is-dark",m==="dark");const g=document.querySelector('meta[data-theme-setting="manual"]');g&&(g.name="theme-color",g.content=m==="light"?g.dataset.themeLightColor:g.dataset.themeDarkColor),document.querySelectorAll('meta[data-theme-setting="auto"]').forEach(T=>{T.name=""})}document.querySelector('meta[name="color-scheme"]').setAttribute("content",m==="auto"?"dark light":m),m==="auto"?we.local.del("theme"):we.local.set("theme",m)},children:e("div",{class:"radio-group",children:[e("label",{children:[e("input",{type:"radio",name:"theme",value:"light",defaultChecked:s==="light"}),e("span",{children:"Light"})]}),e("label",{children:[e("input",{type:"radio",name:"theme",value:"dark",defaultChecked:s==="dark"}),e("span",{children:"Dark"})]}),e("label",{children:[e("input",{type:"radio",name:"theme",value:"auto",defaultChecked:s!=="light"&&s!=="dark"}),e("span",{children:"Auto"})]})]})})})]}),e("li",{children:[e("div",{children:e("label",{children:"Text size"})}),e("div",{class:"range-group",children:[e("span",{style:{fontSize:yt[0]},children:"A"})," ",e("input",{type:"range",min:yt[0],max:yt[yt.length-1],step:"1",value:u,list:"sizes",onChange:l=>{const b=parseInt(l.target.value,10);document.documentElement.style.setProperty("--text-size",`${b}px`),b===di?we.local.del("textSize"):we.local.set("textSize",l.target.value)}})," ",e("span",{style:{fontSize:yt[yt.length-1]},children:"A"}),e("datalist",{id:"sizes",children:yt.map(l=>e("option",{value:l}))})]})]})]})}),c&&e(E,{children:[e("h3",{children:"Posting"}),e("section",{children:e("ul",{children:e("li",{children:[e("div",{children:e("label",{for:"posting-privacy-field",children:["Default visibility"," ",e(v,{icon:"cloud",alt:"Synced",class:"synced-icon"})]})}),e("div",{children:e("select",{id:"posting-privacy-field",value:a["posting:default:visibility"]||"public",onChange:l=>{const{value:b}=l.target;(async()=>{try{await p.v1.accounts.updateCredentials({source:{privacy:b}}),d({...a,"posting:default:visibility":b}),we.account.set("preferences",{...a,"posting:default:visibility":b})}catch{alert("Failed to update posting privacy")}})()},children:[e("option",{value:"public",children:"Public"}),e("option",{value:"unlisted",children:"Unlisted"}),e("option",{value:"private",children:"Followers only"})]})})]})})}),e("p",{class:"section-postnote",children:[e(v,{icon:"cloud",alt:"Synced",class:"synced-icon"})," ",e("small",{children:["Synced to your instance server's settings."," ",e("a",{href:`https://${h}/`,target:"_blank",rel:"noopener noreferrer",children:["Go to your instance (",h,") for more settings."]})]})]})]}),e("h3",{children:"Experiments"}),e("section",{children:e("ul",{children:[e("li",{children:e("label",{children:[e("input",{type:"checkbox",checked:n.settings.autoRefresh,onChange:l=>{$.settings.autoRefresh=l.target.checked}})," ","Auto refresh timeline posts"]})}),e("li",{children:e("label",{children:[e("input",{type:"checkbox",checked:n.settings.boostsCarousel,onChange:l=>{$.settings.boostsCarousel=l.target.checked}})," ","Boosts carousel"]})}),e("li",{children:[e("label",{children:[e("input",{type:"checkbox",checked:n.settings.contentTranslation,onChange:l=>{const{checked:b}=l.target;$.settings.contentTranslation=b,b||($.settings.contentTranslationTargetLanguage=null)}})," ","Post translation"]}),e("div",{class:`sub-section ${n.settings.contentTranslation?"":"more-insignificant"}`,children:[e("div",{children:e("label",{children:["Translate to"," ",e("select",{value:o||"",disabled:!n.settings.contentTranslation,onChange:l=>{$.settings.contentTranslationTargetLanguage=l.target.value||null},children:[e("option",{value:"",children:["System language (",f,")"]}),e("option",{disabled:!0,children:"──────────"}),ti.map(l=>e("option",{value:l.code,children:l.name}))]})]})}),e("hr",{}),e("p",{class:"checkbox-fieldset",children:['Hide "Translate" button for',n.settings.contentTranslationHideLanguages.length>0&&e(E,{children:[" ","(",n.settings.contentTranslationHideLanguages.length,")"]}),":",e("div",{class:"checkbox-fields",children:ti.map(l=>e("label",{children:[e("input",{type:"checkbox",checked:n.settings.contentTranslationHideLanguages.includes(l.code),onChange:b=>{const{checked:m}=b.target;m?$.settings.contentTranslationHideLanguages.push(l.code):$.settings.contentTranslationHideLanguages=n.settings.contentTranslationHideLanguages.filter(k=>k!==l.code)}})," ",l.name]}))})]}),e("p",{class:"insignificant",children:e("small",{children:["Note: This feature uses external translation services, powered by"," ",e("a",{href:"https://github.com/cheeaun/lingva-api",target:"_blank",rel:"noopener noreferrer",children:"Lingva API"})," ","&"," ",e("a",{href:"https://github.com/thedaviddelta/lingva-translate",target:"_blank",rel:"noopener noreferrer",children:"Lingva Translate"}),"."]})}),e("hr",{}),e("div",{children:[e("label",{children:[e("input",{type:"checkbox",checked:n.settings.contentTranslationAutoInline,disabled:!n.settings.contentTranslation,onChange:l=>{$.settings.contentTranslationAutoInline=l.target.checked}})," ","Auto inline translation"]}),e("p",{class:"insignificant",children:e("small",{children:["Automatically show translation for posts in timeline. Only works for ",e("b",{children:"short"})," posts without content warning, media and poll."]})})]})]})]}),!!Do&&c&&e("li",{children:[e("label",{children:[e("input",{type:"checkbox",checked:n.settings.composerGIFPicker,onChange:l=>{$.settings.composerGIFPicker=l.target.checked}})," ","GIF Picker for composer"]}),e("div",{class:"sub-section insignificant",children:e("small",{children:["Note: This feature uses external GIF search service, powered by"," ",e("a",{href:"https://developers.giphy.com/",target:"_blank",rel:"noopener noreferrer",children:"GIPHY"}),". G-rated (suitable for viewing by all ages), tracking parameters are stripped, referrer information is omitted from requests, but search queries and IP address information will still reach their servers."]})})]}),!!Mo&&c&&e("li",{children:[e("label",{children:[e("input",{type:"checkbox",checked:n.settings.mediaAltGenerator,onChange:l=>{$.settings.mediaAltGenerator=l.target.checked}})," ","Image description generator"," ",e(v,{icon:"sparkles2",class:"more-insignificant"})]}),e("div",{class:"sub-section insignificant",children:e("small",{children:"Only for new images while composing new posts."})}),e("div",{class:"sub-section insignificant",children:e("small",{children:["Note: This feature uses external AI service, powered by"," ",e("a",{href:"https://github.com/cheeaun/img-alt-api",target:"_blank",rel:"noopener noreferrer",children:"img-alt-api"}),". May not work well. Only for images and in English."]})})]}),c&&e("li",{children:[e("label",{children:[e("input",{type:"checkbox",checked:n.settings.shortcutSettingsCloudImportExport,onChange:l=>{$.settings.shortcutSettingsCloudImportExport=l.target.checked}})," ",'"Cloud" import/export for shortcuts settings'," ",e(v,{icon:"cloud",class:"more-insignificant"})]}),e("div",{class:"sub-section insignificant",children:e("small",{children:["⚠️⚠️⚠️ Very experimental.",e("br",{}),"Stored in your own profile’s notes. Profile (private) notes are mainly used for other profiles, and hidden for own profile."]})}),e("div",{class:"sub-section insignificant",children:e("small",{children:"Note: This feature uses currently-logged-in instance server API."})})]}),e("li",{children:[e("label",{children:[e("input",{type:"checkbox",checked:n.settings.cloakMode,onChange:l=>{$.settings.cloakMode=l.target.checked}})," ","Cloak mode"," ",e("span",{class:"insignificant",children:["(",e("samp",{children:"Text"})," → ",e("samp",{children:"████"}),")"]})]}),e("div",{class:"sub-section insignificant",children:e("small",{children:"Replace text as blocks, useful when taking screenshots, for privacy reasons."})})]}),c&&e("li",{children:e("button",{type:"button",class:"light",onClick:()=>{$.showDrafts=!0,$.showSettings=!1},children:"Unsent drafts"})})]})}),c&&e(No,{onClose:t}),e("h3",{children:"About"}),e("section",{children:[e("div",{style:{display:"flex",flexWrap:"wrap",gap:8,lineHeight:1.25,alignItems:"center",marginTop:8},children:[e("img",{src:Hn,alt:"",width:"64",height:"64",style:{aspectRatio:"1/1",verticalAlign:"middle",background:"#b7cdf9",borderRadius:12}}),e("div",{children:[e("b",{children:"Phanpy"})," ",e("a",{href:"https://hachyderm.io/@phanpy",rel:"noopener noreferrer",onClick:l=>{l.preventDefault(),$.showAccount="phanpy@hachyderm.io"},children:"@phanpy"}),e("br",{}),e("a",{href:"https://github.com/cheeaun/phanpy",target:"_blank",rel:"noopener noreferrer",children:"Built"})," ","by"," ",e("a",{href:"https://mastodon.social/@cheeaun",rel:"noopener noreferrer",onClick:l=>{l.preventDefault(),$.showAccount="cheeaun@mastodon.social"},children:"@cheeaun"})]})]}),e("p",{children:[e("a",{href:"https://github.com/sponsors/cheeaun",target:"_blank",rel:"noopener noreferrer",children:"Sponsor"})," ","·"," ",e("a",{href:"https://www.buymeacoffee.com/cheeaun",target:"_blank",rel:"noopener noreferrer",children:"Donate"})," ","·"," ",e("a",{href:Lo,target:"_blank",rel:"noopener noreferrer",children:"Privacy Policy"})]}),e("p",{children:[ui&&e(E,{children:[e("span",{class:"insignificant",children:"Site:"})," ",ui.replace(/https?:\/\//g,"").replace(/\/$/,""),e("br",{})]}),e("span",{class:"insignificant",children:"Version:"})," ",e("input",{type:"text",class:"version-string",readOnly:!0,size:"18",value:`${"2024-07-01T05:23:17.415Z".slice(0,10).replace(/-/g,".")}.5e9165b`,onClick:l=>{l.target.select();try{navigator.clipboard.writeText(l.target.value),se("Version string copied")}catch{se("Unable to copy version string")}}})," ",e("span",{class:"ib insignificant",children:["(",e("a",{href:"https://github.com/cheeaun/phanpy/commit/5e9165b",target:"_blank",rel:"noopener noreferrer",children:e(It,{datetime:new Date("2024-07-01T05:23:17.415Z")})}),")"]})]})]})]})]})}function No({onClose:t}){if(!pn())return null;const{instance:n}=ne(),[s,i]=A("default"),o=H(),[r,f]=A(!1),[u,a]=A(!1),d=H();X(()=>{(async()=>{i("loading");try{const{subscription:c,backendSubscription:h}=await Eo();if(h!=null&&h.policy&&h.policy!=="none"){f(!0);const{alerts:l,policy:b}=h;d.current=b;const{elements:m}=o.current,k=m.namedItem("policy");k&&(k.value=b),Object.keys(l).forEach(g=>{const y=m.namedItem(g);(y==null?void 0:y.type)==="checkbox"&&(y.checked=!0)})}i("default")}catch(c){/outside.*authorized/i.test(c.message)?a(!0):alert((c==null?void 0:c.message)||c),i("error")}})()},[]);const p=s==="loading";return e("form",{ref:o,onChange:()=>{setTimeout(()=>{const c=Object.fromEntries(new FormData(o.current)),h=!!c["policy-allow"],l={data:{policy:c.policy,alerts:{mention:!!c.mention,favourite:!!c.favourite,reblog:!!c.reblog,follow:!!c.follow,follow_request:!!c.followRequest,poll:!!c.poll,update:!!c.update,status:!!c.status}}};let b=0;Object.keys(l.data.alerts).forEach(k=>{l.data.alerts[k]?b++:delete l.data.alerts[k]});const m=d.current!==l.data.policy;h&&b>0?m?li().then(()=>{ci(l)}).catch(k=>{alert("Failed to update subscription. Please try again.")}):ci(l).catch(k=>{alert("Failed to update subscription. Please try again.")}):li().catch(k=>{alert("Failed to remove subscription. Please try again.")})},100)},children:[e("h3",{children:"Push Notifications (beta)"}),e("section",{children:e("ul",{children:e("li",{children:[e("label",{children:[e("input",{type:"checkbox",disabled:p||u,name:"policy-allow",checked:r,onChange:async c=>{const{checked:h}=c.target;if(h){const l=await Notification.requestPermission();l==="granted"?f(!0):(f(!1),l==="denied"&&alert("Push notifications are blocked. Please enable them in your browser settings."))}else f(!1)}})," ","Allow from"," ",e("select",{name:"policy",disabled:p||u||!r,children:[{value:"all",label:"anyone"},{value:"followed",label:"people I follow"},{value:"follower",label:"followers"}].map(c=>e("option",{value:c.value,children:c.label}))})]}),e("div",{class:"shazam-container no-animation",style:{width:"100%"},hidden:!r,children:e("div",{class:"shazam-container-inner",children:e("div",{class:"sub-section",children:e("ul",{children:[{value:"mention",label:"Mentions"},{value:"favourite",label:"Likes"},{value:"reblog",label:"Boosts"},{value:"follow",label:"Follows"},{value:"followRequest",label:"Follow requests"},{value:"poll",label:"Polls"},{value:"update",label:"Post edits"},{value:"status",label:"New posts"}].map(c=>e("li",{children:e("label",{children:[e("input",{type:"checkbox",name:c.value})," ",c.label]})}))})})})}),u&&e("div",{class:"sub-section",children:e("p",{children:["Push permission was not granted since your last login. You'll need to"," ",e(re,{to:`/login?instance=${n}`,onClick:t,children:[e("b",{children:"log in"})," again to grant push permission"]}),"."]})})]})})}),e("p",{class:"section-postnote",children:e("small",{children:["NOTE: Push notifications only work for ",e("b",{children:"one account"}),"."]})})]})}const Tn=()=>{let t=setTimeout(()=>{if(!document.getElementById("columns")){const s=document.querySelectorAll("#modal-container > *");if(s!=null&&s.length){const f=s[s.length-1],u=f.querySelector('[tabindex="-1"]')||f;if(u){u.focus();return}}if(document.querySelector(".deck-backdrop"))return;const o=document.querySelectorAll(".deck-container"),r=o[o.length-1];r&&r.tabIndex===-1&&r.focus()}},100);return()=>clearTimeout(t)};function ss(t){if(!t)return;const n=Nt(),s=H(n.pathname);X(()=>{s.current&&n.pathname!==s.current&&(t==null||t())},[n.pathname,t])}const os=1e3*60,Uo=24*60*60*1e3,xn=ft(async()=>{const{masto:t}=ne(),n=await t.v1.lists.list();return n.sort((s,i)=>s.title.localeCompare(i.title)),n.length&&setTimeout(()=>{we.account.set("lists",{lists:n,updatedAt:Date.now()})},1),n},{maxAge:os});async function Yt(){try{const{lists:t,updatedAt:n}=we.account.get("lists")||{};return t!=null&&t.length?(Date.now()-n>Uo&&xn(),t):await xn()}catch{return[]}}const Fo=ft(t=>{const{masto:n}=ne();return n.v1.lists.$select(t).fetch()},{maxAge:os});async function as(t){const{lists:n}=we.account.get("lists")||{};if(n!=null&&n.length){const s=n.find(i=>i.id===t);if(s)return s}try{return Fo(t)}catch{return null}}async function Oo(t){const n=await as(t);return(n==null?void 0:n.title)||""}function zo(t){const{lists:n}=we.account.get("lists")||{};n!=null&&n.length&&(n.push(t),n.sort((s,i)=>s.title.localeCompare(i.title)),we.account.set("lists",{lists:n,updatedAt:Date.now()}))}function Bo(t){const{lists:n}=we.account.get("lists")||{};if(n!=null&&n.length){const s=n.findIndex(i=>i.id===t.id);s!==-1&&(n[s]=t,n.sort((i,o)=>i.title.localeCompare(o.title)),we.account.set("lists",{lists:n,updatedAt:Date.now()}))}}function Ho(t){const{lists:n}=we.account.get("lists")||{};if(n!=null&&n.length){const s=n.findIndex(i=>i.id===t);s!==-1&&(n.splice(s,1),we.account.set("lists",{lists:n,updatedAt:Date.now()}))}}function Vn({list:t,onClose:n}){const{masto:s}=ne(),[i,o]=A("default"),r=!!t,f=H(),u=H(),a=H();X(()=>{r&&(f.current.value=t.title,u.current.value=t.repliesPolicy,a.current&&(a.current.checked=t.exclusive))},[r]);const d=Ge("@mastodon/list-exclusive");return e("div",{class:"sheet",children:[!!n&&e("button",{type:"button",class:"sheet-close",onClick:n,children:e(v,{icon:"x"})})," ",e("header",{children:e("h2",{children:r?"Edit list":"New list"})}),e("main",{children:e("form",{class:"list-form",onSubmit:p=>{p.preventDefault();const c=new FormData(p.target),h=c.get("title"),l=c.get("replies_policy"),b=c.get("exclusive")==="on";o("loading"),(async()=>{try{let m;r?m=await s.v1.lists.$select(t.id).update({title:h,replies_policy:l,exclusive:b}):m=await s.v1.lists.create({title:h,replies_policy:l,exclusive:b}),o("default"),n==null||n({state:"success",list:m}),setTimeout(()=>{r?Bo(m):zo(m)},1)}catch{o("error"),alert(r?"Unable to edit list.":"Unable to create list.")}})()},children:[e("div",{class:"list-form-row",children:e("label",{for:"list-title",children:["Name"," ",e("input",{ref:f,type:"text",id:"list-title",name:"title",required:!0,disabled:i==="loading",dir:"auto"})]})}),e("div",{class:"list-form-row",children:e("select",{ref:u,name:"replies_policy",required:!0,disabled:i==="loading",children:[e("option",{value:"list",children:"Show replies to list members"}),e("option",{value:"followed",children:"Show replies to people I follow"}),e("option",{value:"none",children:"Don't show replies"})]})}),d&&e("div",{class:"list-form-row",children:e("label",{class:"label-block",children:[e("input",{ref:a,type:"checkbox",name:"exclusive",disabled:i==="loading"})," ","Hide posts on this list from Home/Following"]})}),e("div",{class:"list-form-footer",children:[e("button",{type:"submit",disabled:i==="loading",children:r?"Save":"Create"}),r&&e(tt,{disabled:i==="loading",align:"end",menuItemClassName:"danger",confirmLabel:"Delete this list?",onClick:()=>{o("loading"),(async()=>{try{await s.v1.lists.$select(t.id).remove(),o("default"),n==null||n({state:"deleted"}),setTimeout(()=>{Ho(t.id)},1)}catch{o("error"),alert("Unable to delete list.")}})()},children:e("button",{type:"button",class:"light danger",disabled:i==="loading",children:"Delete…"})})]})]})})]})}const qo=[60*5,60*30,60*60,60*60*6,60*60*24,60*60*24*3,60*60*24*7,0],hi={0:"Forever",300:"5 minutes",1800:"30 minutes",3600:"1 hour",21600:"6 hours",86400:"1 day",259200:"3 days",604800:"1 week"},fi=80,rs=1e3*60*10;function Vo(t,n){return n.v1.accounts.familiarFollowers.fetch({id:[t]})}const Go=ft(Vo,{maxAge:rs});async function jo(t,n){const s=n.v1.accounts.$select(t).statuses.list({limit:20}).next(),{value:i}=await s,o={total:i.length,originals:0,replies:0,boosts:0};return i.forEach(r=>{r.reblog?o.boosts++:r.inReplyToId&&r.inReplyToAccountId!==r.account.id?o.replies++:o.originals++}),i.length&&(o.daysSinceLastPost=Math.ceil((Date.now()-new Date(i[i.length-1].createdAt))/864e5)),o}const Yo=ft(jo,{maxAge:rs});function cs({account:t,fetchAccount:n=()=>{},standalone:s,instance:i,authenticated:o}){const{masto:r}=ne({instance:i}),{masto:f,instance:u}=ne(),[a,d]=A("default"),p=typeof t=="string",[c,h]=A(p?null:t),l=ge(()=>i===u,[i,u]);X(()=>{if(!p){h(t);return}d("loading"),(async()=>{try{const C=await n();$.accounts[`${C.id}@${i}`]=C,h(C),d("default")}catch{h(null),d("error")}})()},[p,t,n]);const{acct:b,avatar:m,avatarStatic:k,bot:g,createdAt:y,displayName:T,emojis:w,fields:S,followersCount:I,followingCount:x,group:G,id:D,lastStatusAt:M,locked:ee,note:J,statusesCount:L,url:N,username:_,memorial:U,moved:j,roles:ce,hideCollections:O}=c||{};let ie=!1,{header:V,headerStatic:de}=c||{};(!V||/missing\.png$/.test(V))&&m&&!/missing\.png$/.test(m)&&(V=m,ie=!0,k&&!/missing\.png$/.test(k)&&(de=k));const he=ge(()=>D===dt(),[D]);X(()=>{const C=!!(c!=null&&c.id&&(c!=null&&c.username)&&(c!=null&&c.acct)&&(c!=null&&c.avatar)&&(c!=null&&c.avatarStatic)&&(c!=null&&c.displayName)&&(c!=null&&c.url));if(he&&i&&C){const F=we.local.getJSON("accounts");let W=!1;F.forEach(B=>{B.info.id===c.id&&B.instanceURL===i&&(B.info=c,W=!0)}),W&&we.local.setJSON("accounts",F)}},[he,c,i]);const oe=ge(()=>N?Ut.toUnicode(URL.parse(N).hostname):null,[N]),[be,Ce]=A([]),Ie=H(),Le=H([]);async function Pe(C){var Q;(C||!Ie.current)&&(Ie.current=r.v1.accounts.$select(D).followers.list({limit:fi}));const F=await Ie.current.next();if(he||!l)return F;const{value:W}=F;let B=[];if(C){let ye=[];try{ye=await r.v1.accounts.familiarFollowers.fetch({id:[D]})}catch{}Le.current=((Q=ye==null?void 0:ye[0])==null?void 0:Q.accounts)||[],B=[...Le.current,...W.filter(fe=>!Le.current.some(ae=>ae.id===fe.id))]}else W!=null&&W.length&&(B=W.filter(ye=>!Le.current.some(fe=>fe.id===ye.id)));return{...F,value:B}}const $e=H();async function Se(C){return(C||!$e.current)&&($e.current=r.v1.accounts.$select(D).following.list({limit:fi})),await $e.current.next()}const Te=s?"div":re,ve=i?`/${i}/a/${D}`:`/a/${D}`,[te,me]=A([]),[z,le]=A(),[P,Y]=A("default"),R=!!(z!=null&&z.total),q=async C=>{try{const F=await Go(C,f);me(F[0].accounts.slice(0,Wo))}catch{}},Z=async()=>{if(D){Y("loading");try{const C=await Yo(D,r);le(C),Y("default")}catch{Y("error")}}},ue=et(({relationship:C,currentID:F})=>{C.following||(q(F),!s&&L>0&&Z())},[s,D,L]),Ne=et(C=>{C.id===D&&(h(C),$.accounts[`${C.id}@${i}`]=C)},[D,i]);return e("div",{tabIndex:"-1",class:`account-container ${a==="loading"?"skeleton":""}`,style:{"--header-color-1":be[0],"--header-color-2":be[1],"--header-color-3":be[2],"--header-color-4":be[3]},children:[a==="error"&&e("div",{class:"ui-state",children:[e("p",{children:"Unable to load account."}),e("p",{children:e("a",{href:p?t:N,target:"_blank",rel:"noopener noreferrer",children:["Go to account page ",e(v,{icon:"external"})]})})]}),a==="loading"?e(E,{children:[e("header",{children:e(Qe,{avatarSize:"xxxl",skeleton:!0})}),e("main",{children:[e("div",{class:"note",children:[e("p",{children:"███████ ████ ████"}),e("p",{children:"████ ████████ ██████ █████████ ████ ██"})]}),e("div",{class:"account-metadata-box",children:[e("div",{class:"profile-metadata",children:[e("div",{class:"profile-field",children:[e("b",{class:"more-insignificant",children:"███"}),e("p",{children:"██████"})]}),e("div",{class:"profile-field",children:[e("b",{class:"more-insignificant",children:"████"}),e("p",{children:"███████████"})]})]}),e("div",{class:"stats",children:[e("div",{children:[e("span",{children:"██"})," Followers"]}),e("div",{children:[e("span",{children:"██"})," Following"]}),e("div",{children:[e("span",{children:"██"})," Posts"]})]})]}),e("div",{class:"actions",children:[e("span",{}),e("span",{class:"buttons",children:e("button",{type:"button",title:"More",class:"plain",disabled:!0,children:e(v,{icon:"more",size:"l",alt:"More"})})})]})]})]}):c&&e(E,{children:[!!j&&e("div",{class:"account-moved",children:[e("p",{children:[e("b",{children:T})," has indicated that their new account is now:"]}),e(Qe,{account:j,instance:i,onClick:C=>{C.stopPropagation(),$.showAccount=j}})]}),!!V&&!/missing\.png$/.test(V)&&e("img",{src:V,alt:"",class:`header-banner ${ie?"header-is-avatar":""}`,onError:C=>{C.target.crossOrigin?C.target.src!==de?C.target.src=de:(C.target.removeAttribute("crossorigin"),C.target.src=V):C.target.src!==de?C.target.src=de:C.target.remove()},crossOrigin:"anonymous",onLoad:C=>{C.target.classList.add("loaded");try{const F=window.OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas"),W=F.getContext("2d",{willReadFrequently:!0});F.width=C.target.width,F.height=C.target.height,W.imageSmoothingEnabled=!1,W.drawImage(C.target,0,0);const B=10,ye=[W.getImageData(0,0,B,B).data,W.getImageData(C.target.width-B,0,B,B).data,W.getImageData(0,C.target.height-B,B,B).data,W.getImageData(C.target.width-B,C.target.height-B,B,B).data].map(fe=>{let ae=0,xe=0,Ue=0,Oe=0;for(let Ve=0;Ve{const[ae,xe,Ue,Oe]=Xo(fe);return`rgba(${ae}, ${xe}, ${Ue}, ${Oe})`});Ce(ye)}catch{}}}),e("header",{children:s?e(Ze,{shift:window.matchMedia("(min-width: calc(40em))").matches?114:64,menuButton:e("div",{children:e(Qe,{account:c,instance:i,avatarSize:"xxxl",onClick:()=>{}})}),children:[e("div",{class:"szh-menu__header",children:e(ia,{acct:b,instance:i})}),e(pe,{onClick:()=>{const C=`@${b}`;try{navigator.clipboard.writeText(C),se("Handle copied")}catch{se("Unable to copy handle")}},children:[e(v,{icon:"link"}),e("span",{children:"Copy handle"})]}),e(pe,{href:N,target:"_blank",children:[e(v,{icon:"external"}),e("span",{children:"Go to original profile page"})]}),e(ze,{}),e(Ee,{href:c.avatar,target:"_blank",children:[e(v,{icon:"user"}),e("span",{children:"View profile image"})]}),e(Ee,{href:c.header,target:"_blank",children:[e(v,{icon:"media"}),e("span",{children:"View profile header"})]})]}):e(Qe,{account:c,instance:i,avatarSize:"xxxl",internal:!0})}),e("div",{class:"faux-header-bg","aria-hidden":"true"}),e("main",{children:[!!U&&e("span",{class:"tag",children:"In Memoriam"}),!!g&&e("span",{class:"tag",children:[e(v,{icon:"bot"})," Automated"]}),!!G&&e("span",{class:"tag",children:[e(v,{icon:"group"})," Group"]}),ce==null?void 0:ce.map(C=>e("span",{class:"tag",children:[C.name,!!oe&&e(E,{children:[" ",e("span",{class:"more-insignificant",children:oe})]})]})),e("div",{class:"note",dir:"auto",onClick:Hi({instance:u}),dangerouslySetInnerHTML:{__html:Sn(J,{emojis:w})}}),e("div",{class:"account-metadata-box",children:[(S==null?void 0:S.length)>0&&e("div",{class:"profile-metadata",children:S.map(({name:C,value:F,verifiedAt:W},B)=>e("div",{class:`profile-field ${W?"profile-verified":""}`,dir:"auto",children:[e("b",{children:[e(qi,{text:C,emojis:w})," ",!!W&&e(v,{icon:"check-circle",size:"s"})]}),e("p",{dangerouslySetInnerHTML:{__html:Sn(F,{emojis:w})}})]},C+B))}),e("div",{class:"stats",children:[e(Te,{tabIndex:0,to:ve,onClick:()=>{setTimeout(()=>{$.showGenericAccounts={id:"followers",heading:"Followers",fetchAccounts:Pe,instance:i,excludeRelationshipAttrs:he?["followedBy"]:[],blankCopy:O?"This user has chosen to not make this information available.":void 0}},0)},children:[!!te.length&&e("span",{class:"shazam-container-horizontal",children:e("span",{class:"shazam-container-inner stats-avatars-bunch",children:te.map(C=>e(st,{url:C.avatarStatic,size:"s",alt:`${C.displayName} @${C.acct}`,squircle:C==null?void 0:C.bot}))})}),e("span",{title:I,children:je(I)})," ","Followers"]}),e(Te,{class:"insignificant",tabIndex:0,to:ve,onClick:()=>{setTimeout(()=>{$.showGenericAccounts={heading:"Following",fetchAccounts:Se,instance:i,excludeRelationshipAttrs:he?["following"]:[],blankCopy:O?"This user has chosen to not make this information available.":void 0}},0)},children:[e("span",{title:x,children:je(x)})," ","Following",e("br",{})]}),e(Te,{class:"insignificant",to:ve,children:[e("span",{title:L,children:je(L)})," ","Posts"]}),!!y&&e("div",{class:"insignificant",children:["Joined"," ",e("time",{datetime:y,children:rt(y,{hideTime:!0})})]})]})]}),!!z&&e(Te,{to:ve,class:"account-metadata-box",children:e("div",{class:"shazam-container",children:e("div",{class:"shazam-container-inner",children:R?e("div",{class:"posting-stats",title:`${Math.round(z.originals/z.total*100)}% original posts, ${Math.round(z.replies/z.total*100)}% replies, ${Math.round(z.boosts/z.total*100)}% boosts`,children:[e("div",{children:z.daysSinceLastPost<365?`Last ${z.total} post${z.total>1?"s":""} in the past ${z.daysSinceLastPost} day${z.daysSinceLastPost>1?"s":""}`:` Last ${z.total} posts in the past year(s) `}),e("div",{class:"posting-stats-bar",style:{"--originals-percentage":`${z.originals/z.total*100}%`,"--replies-percentage":`${(z.originals+z.replies)/z.total*100}%`}}),e("div",{class:"posting-stats-legends",children:[e("span",{class:"ib",children:[e("span",{class:"posting-stats-legend-item posting-stats-legend-item-originals"})," ","Original"]})," ",e("span",{class:"ib",children:[e("span",{class:"posting-stats-legend-item posting-stats-legend-item-replies"})," ","Replies"]})," ",e("span",{class:"ib",children:[e("span",{class:"posting-stats-legend-item posting-stats-legend-item-boosts"})," ","Boosts"]})]})]}):e("div",{class:"posting-stats",children:"Post stats unavailable."})})})}),!j&&e("div",{class:"account-metadata-box",children:e("div",{class:"shazam-container no-animation",hidden:!!z,children:e("div",{class:"shazam-container-inner",children:e("button",{type:"button",class:"posting-stats-button",disabled:P==="loading",onClick:()=>{Z()},children:[e("div",{class:`posting-stats-bar posting-stats-icon ${P==="loading"?"loading":""}`,style:{"--originals-percentage":"33%","--replies-percentage":"66%"}}),"View post stats"," "]})})})})]}),e("footer",{children:e(Ko,{info:c,instance:i,standalone:s,authenticated:o,onRelationshipChange:ue,onProfileUpdate:Ne})})]})]})}const Wo=3;function Ko({info:t,instance:n,standalone:s,authenticated:i,onRelationshipChange:o=()=>{},onProfileUpdate:r=()=>{}}){var me;if(!t)return null;const{masto:f,instance:u,authenticated:a}=ne(),d=n===u,[p,c]=A("default"),[h,l]=A(null),{id:b,acct:m,url:k,username:g,locked:y,lastStatusAt:T,note:w,fields:S,moved:I}=t,x=H(b),{following:G,showingReblogs:D,notifying:M,followedBy:ee,blocking:J,blockedBy:L,muting:N,mutingNotifications:_,requested:U,domainBlocking:j,endorsed:ce,note:O}=h||{},[ie,V]=A(null),[de,he]=A(!1);X(()=>{if(t){const z=dt();let le;(async()=>{if(d&&i)le=b;else if(!d&&a){const Y=t.acct.includes("@");try{const R=await f.v2.search.fetch({q:Y?t.acct:`${t.username}@${n}`,type:"accounts",limit:1,resolve:!0});R.accounts.length&&(le=R.accounts[0].id,V(R.accounts[0]))}catch{}}if(!le)return;if(z===le){he(!0);return}x.current=le,c("loading");const P=f.v1.accounts.relationships.fetch({id:[le]});try{const Y=await P;if(c("default"),Y.length){const R=Y[0];l(R),o({relationship:R,currentID:le})}}catch{c("error")}})()}},[t,i]),X(()=>{t&&de&&As(t)},[t,de]);const oe=p==="loading",[be,Ce]=A(!1),[Ie,Le]=A(!1),[Pe,$e]=A(!1),[Se,Te]=A(!1),[ve,te]=A([]);return e(E,{children:[e("div",{class:"actions",children:[e("span",{children:[ee?e("span",{class:"tag",children:"Follows you"}):T?e("small",{class:"insignificant",children:["Last post:"," ",e("span",{class:"ib",children:rt(T,{hideTime:!0})})]}):e("span",{}),N&&e("span",{class:"tag danger",children:"Muted"}),J&&e("span",{class:"tag danger",children:"Blocked"})]})," ",e("span",{class:"buttons",children:[!!O&&e("button",{type:"button",class:"private-note-tag",title:"Private note",onClick:()=>{$e(!0)},dir:"auto",children:e("span",{children:O})}),e(Ze,{portal:{target:document.body},containerProps:{style:{zIndex:1001}},align:"center",position:"anchor",overflow:"auto",menuButton:e("button",{type:"button",title:"More",class:"plain",disabled:oe,children:e(v,{icon:"more",size:"l",alt:"More"})}),onMenuChange:z=>{G&&z.open&&(async()=>{try{const le=await f.v1.accounts.$select(x.current).lists.list();te(le)}catch{}})()},children:[a&&!de&&e(E,{children:[e(pe,{onClick:()=>{qs({draftStatus:{status:`@${(ie==null?void 0:ie.acct)||m} `}})},children:[e(v,{icon:"at"}),e("span",{children:["Mention @",g]})]}),e(pe,{onClick:()=>{Ce(!0)},children:[e(v,{icon:"translate"}),e("span",{children:"Translate bio"})]}),Ge("@mastodon/profile-private-note")&&e(pe,{onClick:()=>{$e(!0)},children:[e(v,{icon:"pencil"}),e("span",{children:O?"Edit private note":"Add private note"})]}),G&&!!h&&e(E,{children:[e(pe,{onClick:()=>{c("loading"),(async()=>{try{const z=await f.v1.accounts.$select(x.current).follow({notify:!M});z&&l(z),c("default"),se(z.notifying?`Notifications enabled for @${g}'s posts.`:` Notifications disabled for @${g}'s posts.`)}catch(z){alert(z),c("error")}})()},children:[e(v,{icon:"notification"}),e("span",{children:M?"Disable notifications":"Enable notifications"})]}),e(pe,{onClick:()=>{c("loading"),(async()=>{try{const z=await f.v1.accounts.$select(x.current).follow({reblogs:!D});z&&l(z),c("default"),se(z.showingReblogs?`Boosts from @${g} enabled.`:`Boosts from @${g} disabled.`)}catch(z){alert(z),c("error")}})()},children:[e(v,{icon:"rocket"}),e("span",{children:D?"Disable boosts":"Enable boosts"})]})]}),G&&e(pe,{onClick:()=>{Le(!0)},children:[e(v,{icon:"list"}),ve.length?e(E,{children:[e("small",{class:"menu-grow",children:["Add/Remove from Lists",e("br",{}),e("span",{class:"more-insignificant",children:ve.map(z=>z.title).join(", ")})]}),e("small",{class:"more-insignificant",children:ve.length})]}):e("span",{children:"Add/Remove from Lists"})]}),e(ze,{})]}),e(pe,{onClick:()=>{const z=`@${(ie==null?void 0:ie.acct)||m}`;try{navigator.clipboard.writeText(z),se("Handle copied")}catch{se("Unable to copy handle")}},children:[e(v,{icon:"copy"}),e("small",{children:["Copy handle",e("br",{}),e("span",{class:"more-insignificant",children:["@",(ie==null?void 0:ie.acct)||m]})]})]}),e(pe,{href:k,target:"_blank",children:[e(v,{icon:"external"}),e("small",{class:"menu-double-lines",children:Zo(k)})]}),e("div",{class:"menu-horizontal",children:[e(pe,{onClick:()=>{try{navigator.clipboard.writeText(k),se("Link copied")}catch{se("Unable to copy link")}},children:[e(v,{icon:"link"}),e("span",{children:"Copy"})]}),(navigator==null?void 0:navigator.share)&&((me=navigator==null?void 0:navigator.canShare)==null?void 0:me.call(navigator,{url:k}))&&e(pe,{onClick:()=>{try{navigator.share({url:k})}catch{alert("Sharing doesn't seem to work.")}},children:[e(v,{icon:"share"}),e("span",{children:"Share…"})]})]}),!!h&&e(E,{children:[e(ze,{}),N?e(pe,{onClick:()=>{c("loading"),(async()=>{try{const z=await f.v1.accounts.$select((ie==null?void 0:ie.id)||b).unmute();l(z),c("default"),se(`Unmuted @${g}`),$.reloadGenericAccounts.id="mute",$.reloadGenericAccounts.counter++}catch{c("error")}})()},children:[e(v,{icon:"unmute"}),e("span",{children:["Unmute @",g]})]}):e(cn,{menuClassName:"menu-blur",openTrigger:"clickOnly",direction:"bottom",overflow:"auto",shift:16,label:e(E,{children:[e(v,{icon:"mute"}),e("span",{class:"menu-grow",children:["Mute @",g,"…"]}),e("span",{style:{textOverflow:"clip"},children:[e(v,{icon:"time"}),e(v,{icon:"chevron-right"})]})]}),children:e("div",{class:"menu-wrap",children:qo.map(z=>e(pe,{onClick:()=>{c("loading"),(async()=>{try{const le=await f.v1.accounts.$select((ie==null?void 0:ie.id)||b).mute({duration:z});l(le),c("default"),se(`Muted @${g} for ${hi[z]}`),$.reloadGenericAccounts.id="mute",$.reloadGenericAccounts.counter++}catch{c("error"),se(`Unable to mute @${g}`)}})()},children:hi[z]}))})}),ee&&e(tt,{subMenu:!0,menuItemClassName:"danger",confirmLabel:e(E,{children:[e(v,{icon:"user-x"}),e("span",{children:["Remove @",g," from followers?"]})]}),onClick:()=>{c("loading"),(async()=>{try{const z=await f.v1.accounts.$select((ie==null?void 0:ie.id)||b).removeFromFollowers();l(z),c("default"),se(`@${g} removed from followers`),$.reloadGenericAccounts.id="followers",$.reloadGenericAccounts.counter++}catch{c("error")}})()},children:[e(v,{icon:"user-x"}),e("span",{children:"Remove follower…"})]}),e(tt,{subMenu:!0,confirm:!J,confirmLabel:e(E,{children:[e(v,{icon:"block"}),e("span",{children:["Block @",g,"?"]})]}),menuItemClassName:"danger",onClick:()=>{c("loading"),(async()=>{try{if(J){const z=await f.v1.accounts.$select((ie==null?void 0:ie.id)||b).unblock();l(z),c("default"),se(`Unblocked @${g}`)}else{const z=await f.v1.accounts.$select((ie==null?void 0:ie.id)||b).block();l(z),c("default"),se(`Blocked @${g}`)}$.reloadGenericAccounts.id="block",$.reloadGenericAccounts.counter++}catch{c("error"),J?se(`Unable to unblock @${g}`):se(`Unable to block @${g}`)}})()},children:J?e(E,{children:[e(v,{icon:"unblock"}),e("span",{children:["Unblock @",g]})]}):e(E,{children:[e(v,{icon:"block"}),e("span",{children:["Block @",g,"…"]})]})}),e(pe,{className:"danger",onClick:()=>{$.showReportModal={account:ie||t}},children:[e(v,{icon:"flag"}),e("span",{children:["Report @",g,"…"]})]})]}),a&&de&&s&&Ge("@mastodon/profile-edit")&&e(E,{children:[e(ze,{}),e(pe,{onClick:()=>{Te(!0)},children:[e(v,{icon:"pencil"}),e("span",{children:"Edit profile"})]})]}),!1]}),!h&&p==="loading"&&e(Ae,{abrupt:!0}),!!h&&!I&&e(tt,{confirm:G||U,confirmLabel:e("span",{children:U?"Withdraw follow request?":`Unfollow @${t.acct||t.username}?`}),menuItemClassName:"danger",align:"end",disabled:oe,onClick:()=>{c("loading"),(async()=>{try{let z;G||U?z=await f.v1.accounts.$select(x.current).unfollow():z=await f.v1.accounts.$select(x.current).follow(),z&&l(z),c("default")}catch(z){alert(z),c("error")}})()},children:e("button",{type:"button",class:`${G||U?"light swap":""}`,"data-swap-state":G||U?"danger":"",disabled:oe,children:G?e(E,{children:[e("span",{children:"Following"}),e("span",{children:"Unfollow…"})]}):U?e(E,{children:[e("span",{children:"Requested"}),e("span",{children:"Withdraw…"})]}):y?e(E,{children:[e(v,{icon:"lock"})," ",e("span",{children:"Follow"})]}):"Follow"})})]})]}),!!be&&e(Re,{onClose:()=>{Ce(!1)},children:e(Jo,{note:w,fields:S,onClose:()=>Ce(!1)})}),!!Ie&&e(Re,{onClose:()=>{Le(!1)},children:e(Qo,{accountID:x.current,onClose:()=>Le(!1)})}),!!Pe&&e(Re,{onClose:()=>{$e(!1)},children:e(ea,{account:t,note:O,onRelationshipChange:z=>{l(z)},onClose:()=>$e(!1)})}),!!Se&&e(Re,{onClose:()=>{Te(!1)},children:e(ta,{onClose:({state:z,account:le}={})=>{Te(!1),z==="success"&&le&&r(le)}})})]})}function Xo([t,n,s]){const i=.2126*t+.7152*n+.0722*s;let o;return i>=220?o=1:i<=50?o=.1:o=i/255,o=Math.min(1,o),[t,n,s,o]}function Zo(t){if(!t)return;const n=URL.parse(t),{host:s,pathname:i}=n,o=i.replace(/\/$/,"").replace(/^\//,"");return e(E,{children:[e("span",{class:"more-insignificant",children:[Ut.toUnicode(s),"/"]}),e("wbr",{}),e("span",{children:o})]})}function Jo({note:t,fields:n,onClose:s}){const i=(n==null?void 0:n.map(({name:r,value:f})=>`${r} ${ni(f)}`).join(` `))||"",o=ni(t)+(i?` ${i}`:"");return e("div",{class:"sheet",children:[!!s&&e("button",{type:"button",class:"sheet-close",onClick:s,children:e(v,{icon:"x"})}),e("header",{children:e("h2",{children:"Translated Bio"})}),e("main",{children:[e("p",{style:{whiteSpace:"pre-wrap"},children:o}),e(Vi,{forceTranslate:!0,text:o})]})]})}function Qo({accountID:t,onClose:n}){const{masto:s}=ne(),[i,o]=A("default"),[r,f]=A([]),[u,a]=A([]),[d,p]=kt(l=>l+1,0);X(()=>{o("loading"),(async()=>{try{const l=await Yt();f(l);const b=await s.v1.accounts.$select(t).lists.list();a(b),o("default")}catch{o("error")}})()},[d]);const[c,h]=A(!1);return e("div",{class:"sheet",id:"list-add-remove-container",children:[!!n&&e("button",{type:"button",class:"sheet-close",onClick:n,children:e(v,{icon:"x"})}),e("header",{children:e("h2",{children:"Add/Remove from Lists"})}),e("main",{children:[r.length>0?e("ul",{class:"list-add-remove",children:r.map(l=>{const b=u.some(m=>m.id===l.id);return e("li",{children:e("button",{type:"button",class:`light ${b?"checked":""}`,disabled:i==="loading",onClick:()=>{o("loading"),(async()=>{try{b?await s.v1.lists.$select(l.id).accounts.remove({accountIds:[t]}):await s.v1.lists.$select(l.id).accounts.create({accountIds:[t]}),p()}catch{o("error"),alert(b?"Unable to remove from list.":"Unable to add to list.")}})()},children:[e(v,{icon:"check-circle"}),e("span",{children:l.title})]})})})}):i==="loading"?e("p",{class:"ui-state",children:e(Ae,{abrupt:!0})}):i==="error"?e("p",{class:"ui-state",children:"Unable to load lists."}):e("p",{class:"ui-state",children:"No lists."}),e("button",{type:"button",class:"plain2",onClick:()=>h(!0),disabled:i!=="default",children:[e(v,{icon:"plus",size:"l"})," ",e("span",{children:"New list"})]})]}),c&&e(Re,{onClick:l=>{l.target===l.currentTarget&&h(!1)},children:e(Vn,{list:c==null?void 0:c.list,onClose:l=>{l.state==="success"&&p(),h(!1)}})})]})}function ea({account:t,note:n,onRelationshipChange:s=()=>{},onClose:i=()=>{}}){const{masto:o}=ne(),[r,f]=A("default"),u=H(null);return X(()=>{let a;return u.current&&!n&&(a=setTimeout(()=>{var d,p;(p=(d=u.current).focus)==null||p.call(d)},100)),()=>{clearTimeout(a)}},[]),e("div",{class:"sheet",id:"private-note-container",children:[!!i&&e("button",{type:"button",class:"sheet-close",onClick:i,children:e(v,{icon:"x"})}),e("header",{children:e("b",{children:["Private note about @",(t==null?void 0:t.username)||(t==null?void 0:t.acct)]})}),e("main",{children:e("form",{onSubmit:a=>{a.preventDefault();const p=new FormData(a.target).get("note");(p==null?void 0:p.trim())!==(n==null?void 0:n.trim())&&(f("loading"),(async()=>{try{const c=await o.v1.accounts.$select(t==null?void 0:t.id).note.create({comment:p});f("default"),s(c),i()}catch(c){f("error"),alert((c==null?void 0:c.message)||"Unable to update private note.")}})())},children:[e("textarea",{ref:u,name:"note",disabled:r==="loading",children:n}),e("footer",{children:[e("button",{type:"button",class:"light",disabled:r==="loading",onClick:()=>{i==null||i()},children:"Cancel"}),e("span",{children:[e(Ae,{abrupt:!0,hidden:r!=="loading"}),e("button",{disabled:r==="loading",type:"submit",children:"Save & close"})]})]})]})})]})}function ta({onClose:t=()=>{}}){const{masto:n}=ne(),[s,i]=A("loading"),[o,r]=A(null);X(()=>{(async()=>{try{const c=await n.v1.accounts.verifyCredentials();r(c),i("default")}catch{i("error")}})()},[]);const{displayName:f,source:u}=o||{},{note:a,fields:d}=u||{},p=H(null);return e("div",{class:"sheet",id:"edit-profile-container",children:[!!t&&e("button",{type:"button",class:"sheet-close",onClick:t,children:e(v,{icon:"x"})}),e("header",{children:e("b",{children:"Edit profile"})}),e("main",{children:s==="loading"?e("p",{class:"ui-state",children:e(Ae,{abrupt:!0})}):e("form",{onSubmit:c=>{c.preventDefault();const h=new FormData(c.target),l=h.get("display_name"),b=h.get("note"),m=p.current.querySelectorAll('input[name^="fields_attributes"]'),k=[];m.forEach(g=>{const y=g.name,[T,w,S]=y.match(/fields_attributes\[(\d+)\]\[(.+)\]/)||[],I=g.value?g.value.trim():"";w&&S&&I&&(k[w]||(k[w]={}),k[w][S]=I)}),k.forEach(g=>{g.name&&!g.value&&(g.value="")}),(async()=>{try{const g=await n.v1.accounts.updateCredentials({displayName:l,note:b,fieldsAttributes:k});t==null||t({state:"success",account:g})}catch(g){alert((g==null?void 0:g.message)||"Unable to update profile.")}})()},children:[e("p",{children:e("label",{children:["Name"," ",e("input",{type:"text",name:"display_name",defaultValue:f,maxLength:30,disabled:s==="loading"})]})}),e("p",{children:e("label",{children:["Bio",e("textarea",{defaultValue:a,name:"note",maxLength:500,rows:"5",disabled:s==="loading"})]})}),e("p",{children:"Extra fields"}),e("table",{ref:p,children:[e("thead",{children:e("tr",{children:[e("th",{children:"Label"}),e("th",{children:"Content"})]})}),e("tbody",{children:Array.from({length:Math.max(4,d.length)}).map((c,h)=>{const{name:l="",value:b=""}=d[h]||{};return e(na,{name:l,value:b,index:h,disabled:s==="loading"},h)})})]}),e("footer",{children:[e("button",{type:"button",class:"light",disabled:s==="loading",onClick:()=>{t==null||t()},children:"Cancel"}),e("button",{type:"submit",disabled:s==="loading",children:"Save"})]})]})})]})}function na({name:t,value:n,disabled:s,index:i}){const[o,r]=A(!!n);return e("tr",{children:[e("td",{children:e("input",{type:"text",name:`fields_attributes[${i}][name]`,defaultValue:t,disabled:s,maxLength:255,required:o})}),e("td",{children:e("input",{type:"text",name:`fields_attributes[${i}][value]`,defaultValue:n,disabled:s,maxLength:255,onChange:f=>r(!!f.currentTarget.value)})})]})}function ia({acct:t,instance:n}){let[s,i]=t.split("@");return i||(i=n),e("div",{class:"handle-info",children:[e("span",{class:"handle-handle",children:[e("b",{class:"handle-username",children:s}),e("span",{class:"handle-at",children:"@"}),e("b",{class:"handle-server",children:i})]}),e("div",{class:"handle-legend",children:[e("span",{class:"ib",children:[e("span",{class:"handle-legend-icon username"})," username"]})," ",e("span",{class:"ib",children:[e("span",{class:"handle-legend-icon server"})," server domain name"]})]})]})}function sa({account:t,instance:n,onClose:s}){const{masto:i,instance:o,authenticated:r}=ne({instance:n}),f=typeof t=="string";return X(()=>{f||($.accounts[`${t.id}@${o}`]=t)},[t]),ss(s),e("div",{class:"sheet",children:[!!s&&e("button",{type:"button",class:"sheet-close outer",onClick:s,children:e(v,{icon:"x"})}),e(cs,{instance:o,authenticated:r,account:t,fetchAccount:async()=>{if(f)try{return await i.v1.accounts.lookup({acct:t,skip_webfinger:!1})}catch{const a=await i.v2.search.fetch({q:t,type:"accounts",limit:1,resolve:r});if(a.accounts.length)return a.accounts[0];if(/https?:\/\/[^/]+\/@/.test(t)){const d=URL.parse(t),{hostname:p,pathname:c}=d,h=c.replace(/^\//,"").replace(/\/$/,"")+"@"+p,l=await i.v2.search.fetch({q:h,type:"accounts",limit:1,resolve:r});if(l.accounts.length)return l.accounts[0]}}else return t}})]})}function oa({onClose:t}){const{masto:n}=ne(),[s,i]=A("default"),[o,r]=A([]),[f,u]=kt(d=>d+1,0);X(()=>{i("loading"),(async()=>{try{const d=await it.drafts.keys();if(d.length){const p=rn(),c=d.filter(h=>h.startsWith(p));if(c.length){const h=await it.drafts.getMany(c);h.sort((l,b)=>new Date(b.updatedAt).getTime()-new Date(l.updatedAt).getTime()),r(h)}else r([])}else r([]);i("default")}catch{i("error")}})()},[f]);const a=(o==null?void 0:o.length)>0;return e("div",{class:"sheet",children:[!!t&&e("button",{type:"button",class:"sheet-close",onClick:t,children:e(v,{icon:"x"})}),e("header",{children:[e("h2",{children:["Unsent drafts ",e(Ae,{abrupt:!0,hidden:s!=="loading"})]}),a&&e("div",{class:"insignificant",children:"Looks like you have unsent drafts. Let's continue where you left off."})]}),e("main",{children:a?e(E,{children:[e("ul",{class:"drafts-list",children:o.map(d=>{const{updatedAt:p,key:c,draftStatus:h,replyTo:l}=d,b=new Date(p);return e("li",{children:[e("div",{class:"mini-draft-meta",children:[e("b",{children:[e(v,{icon:l?"reply":"quill",size:"s"})," ",e("time",{children:[!!l&&e(E,{children:["@",l.account.acct,e("br",{})]}),rt(b)]})]}),e(tt,{confirmLabel:e("span",{children:"Delete this draft?"}),menuItemClassName:"danger",align:"end",disabled:s==="loading",onClick:()=>{(async()=>{try{await it.drafts.del(c),u()}catch{alert("Error deleting draft! Please try again.")}})()},children:e("button",{type:"button",class:"small light",disabled:s==="loading",children:"Delete…"})})]}),e("button",{type:"button",disabled:s==="loading",class:"draft-item",onClick:async()=>{let m;if(l){i("loading");try{m=await n.v1.statuses.$select(l.id).fetch()}catch{alert("Error fetching reply-to status!"),i("default");return}i("default")}window.__COMPOSE__={draftStatus:h,replyToStatus:m},$.showCompose=!0,$.showDrafts=!1},children:e(aa,{draft:d})})]},p)})}),o.length>1&&e("p",{children:e(tt,{confirmLabel:e("span",{children:"Delete all drafts?"}),menuItemClassName:"danger",disabled:s==="loading",onClick:()=>{(async()=>{i("loading");try{await it.drafts.delMany(o.map(d=>d.key)),i("default"),u()}catch{alert("Error deleting drafts! Please try again."),i("error")}})()},children:e("button",{type:"button",class:"light danger",disabled:s==="loading",children:"Delete all…"})})})]}):e("p",{children:"No drafts found."})})]})}function aa({draft:t}){var c;const{draftStatus:n,replyTo:s}=t,{status:i,spoilerText:o,poll:r,mediaAttachments:f}=n,u=((c=r==null?void 0:r.options)==null?void 0:c.length)>0,a=(f==null?void 0:f.length)>0,d=u||a,p=ge(()=>{if(!a)return;const h=f.find(m=>/image/.test(m.type));if(!h)return;const{file:l}=h;return URL.createObjectURL(l)},[a,f]);return e(E,{children:e("div",{class:"mini-draft",children:[d&&e("div",{class:`mini-draft-aside ${p?"has-image":""}`,style:p?{"--bg-image":`url(${p})`}:{},children:[u&&e(v,{icon:"poll"}),a&&e("span",{children:[e(v,{icon:"attachment"})," ",e("small",{children:f==null?void 0:f.length})]})]}),e("div",{class:"mini-draft-main",children:[!!o&&e("div",{class:"mini-draft-spoiler",children:o}),!!i&&e("div",{class:"mini-draft-status",children:i})]})]})})}function ra({html:t,url:n,width:s,height:i,onClose:o=()=>{}}){return e("div",{class:"embed-modal-container",children:[e("div",{class:"top-controls",children:[e("button",{type:"button",class:"light",onClick:()=>o(),children:e(v,{icon:"x"})}),n&&e("a",{href:n,target:"_blank",rel:"noopener noreferrer",class:"button plain",children:[e("span",{children:"Open link"})," ",e(v,{icon:"external"})]})]}),e("div",{class:"embed-content",dangerouslySetInnerHTML:{__html:t},style:{"--width":s+"px","--height":i+"px","--aspect-ratio":`${s}/${i}`}})]})}function ca({instance:t,excludeRelationshipAttrs:n=[],postID:s,onClose:i=()=>{},blankCopy:o="Nothing to show"}){const{masto:r,instance:f}=ne(),u=t?t===f:!0,a=De($),[d,p]=A("default"),[c,h]=A([]),[l,b]=A(!1);if(ss(i),!a.showGenericAccounts)return null;const{id:m,heading:k,fetchAccounts:g,accounts:y,showReactions:T}=a.showGenericAccounts,[w,S]=A({}),I=async M=>{if(!(M!=null&&M.length)||!u)return;const ee=await Dn(M,w);ee&&S({...w,...ee})},x=M=>{g&&(M&&h([]),p("loading"),(async()=>{try{const{done:ee,value:J}=await g(M);if(Array.isArray(J)){if(M){const L=[];for(let N=0;Nj.id===_.id&&N!==ce);U?U._types.push(..._._types):L.push({_types:[],..._})}h(L)}else h(L=>{const N=L;for(const _ of J){const U=N.find(j=>j.id===_.id);U?U._types.push(..._._types):N.push(_)}return N});b(!ee),I(J)}else b(!1);p("default")}catch{p("error")}})())},G=H(!0);X(()=>{(y==null?void 0:y.length)>0?(h(y),I(y)):(x(!0),G.current=!1)},[y,g]),X(()=>{var M;G.current||((M=a.reloadGenericAccounts)==null?void 0:M.id)===m&&x(!0)},[a.reloadGenericAccounts.counter]);const D=$.statuses[s];return e("div",{id:"generic-accounts-container",class:"sheet",tabindex:"-1",children:[e("button",{type:"button",class:"sheet-close",onClick:i,children:e(v,{icon:"x"})}),e("header",{children:e("h2",{children:k||"Accounts"})}),e("main",{children:[D&&e(re,{to:`/${t||f}/s/${D.id}`,class:"post-preview",children:e(Be,{status:D,size:"s",readOnly:!0})}),c.length>0?e(E,{children:[e("ul",{class:"accounts-list",children:c.map(M=>{var L,N;const ee=w[M.id],J=`${M.id}-${((L=M._types)==null?void 0:L.length)||""}`;return e("li",{children:[T&&((N=M._types)==null?void 0:N.length)>0&&e("div",{class:"reactions-block",children:M._types.map(_=>e(v,{icon:{reblog:"rocket",favourite:"heart"}[_],class:`${_}-icon`}))}),e("div",{class:"account-relationships",children:e(Qe,{account:M,showStats:!0,relationship:ee,excludeRelationshipAttrs:n})})]},J)})}),d==="default"?l?e(ht,{onChange:M=>{M&&x()},children:e("button",{type:"button",class:"plain block",onClick:()=>x(),children:"Show more…"})}):e("p",{class:"ui-state insignificant",children:"The end."}):d==="loading"&&e("p",{class:"ui-state",children:e(Ae,{abrupt:!0})})]}):d==="loading"?e("p",{class:"ui-state",children:e(Ae,{abrupt:!0})}):d==="error"?e("p",{class:"ui-state",children:"Error loading accounts"}):e("p",{class:"ui-state insignificant",children:o})]})]})}function la({alt:t,lang:n,onClose:s}){const i=De($),[o,r]=A(!1),f=Bi(!0),u=i.settings.contentTranslationHideLanguages||[],a=!!n&&n!==f&&!ii([n],[f])&&!u.find(d=>n===d||ii([n],[d]));return e("div",{class:"sheet",tabindex:"-1",children:[!!s&&e("button",{type:"button",class:"sheet-close outer",onClick:s,children:e(v,{icon:"x"})}),e("header",{class:"header-grid",children:[e("h2",{children:"Media description"}),e("div",{class:"header-side",children:e(Ze,{align:"end",menuButton:e("button",{type:"button",class:"plain4",children:e(v,{icon:"more",alt:"More",size:"xl"})}),children:[e(pe,{disabled:o,onClick:()=>{r(!0)},children:[e(v,{icon:"translate"}),e("span",{children:"Translate"})]}),Vs&&e(pe,{onClick:()=>{Gs(t,n)},children:[e(v,{icon:"speak"}),e("span",{children:"Speak"})]})]})})]}),e("main",{lang:n,dir:"auto",children:[e("p",{style:{whiteSpace:"pre-wrap",textWrap:"pretty"},children:t}),(a||o)&&e(Vi,{forceTranslate:o,sourceLanguage:n,text:t})]})]})}function bn(t,n,s){return Math.max(Math.min(t,s),n)}const yn=t=>t>=.04045?Math.pow((t+.055)/1.055,2.4):t/12.92,wn=t=>t>=.0031308?1.055*Math.pow(t,1/2.4)-.055:12.92*t;function Gn([t,n,s]){t=yn(t/255),n=yn(n/255),s=yn(s/255);var i=.4122214708*t+.5363325363*n+.0514459929*s,o=.2119034982*t+.6806995451*n+.1073969566*s,r=.0883024619*t+.2817188376*n+.6299787005*s;return i=Math.cbrt(i),o=Math.cbrt(o),r=Math.cbrt(r),[i*.2104542553+o*.793617785+r*-.0040720468,i*1.9779984951+o*-2.428592205+r*.4505937099,i*.0259040371+o*.7827717662+r*-.808675766]}function jn([t,n,a]){var i=t+n*.3963377774+a*.2158037573,o=t+n*-.1055613458+a*-.0638541728,r=t+n*-.0894841775+a*-1.291485548;i=i**3,o=o**3,r=r**3;var f=i*4.0767416621+o*-3.3077115913+r*.2309699292,u=i*-1.2684380046+o*2.6097574011+r*-.3413193965,a=i*-.0041960863+o*-.7034186147+r*1.707614701;return f=255*wn(f),u=255*wn(u),a=255*wn(a),f=bn(f,0,255),u=bn(u,0,255),a=bn(a,0,255),f=Math.round(f),u=Math.round(u),a=Math.round(a),[f,u,a]}var da={PHANPY_CLIENT_NAME:"Phanpy",PHANPY_WEBSITE:"https://phanpy.social",PHANPY_LINGVA_INSTANCES:"lingva.phanpy.social lingva.lunar.icu lingva.garudalinux.org translate.plausibility.cloud",PHANPY_PRIVACY_POLICY_URL:"https://github.com/cheeaun/phanpy/blob/main/PRIVACY.MD",VITE_APP_ENV:"production",BASE_URL:"./",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const{PHANPY_IMG_ALT_API_URL:Vc}=da;function ls({mediaAttachments:t,statusID:n,instance:s,lang:i,index:o=0,onClose:r=()=>{}}){var y,T;const[f,u]=A("default"),a=H(null),[d,p]=A(o),c=H(null);ut(()=>{var w;(w=c.current)==null||w.scrollIntoView()},[]);const h=H(n);X(()=>{const w=o*a.current.clientWidth,S=h.current!==n;S&&(h.current=n),a.current.scrollTo({left:w,behavior:S?"auto":"smooth"}),a.current.focus()},[o,n]);const[l,b]=A(!0);X(()=>{let w=()=>{r()};return a.current&&a.current.addEventListener("swiped-down",w),()=>{a.current&&a.current.removeEventListener("swiped-down",w)}},[]),_e("esc",r,{ignoreEventWhen:w=>!!document.querySelector("#modal-container > *")},[r]),X(()=>{let w=()=>{const{clientWidth:S,scrollLeft:I}=a.current,x=Math.round(I/S);p(x)};return a.current&&a.current.addEventListener("scroll",w,{passive:!0}),()=>{a.current&&a.current.removeEventListener("scroll",w)}},[]),X(()=>{let w=setTimeout(()=>{var S,I;(I=(S=a.current)==null?void 0:S.focus)==null||I.call(S)},100);return()=>clearTimeout(w)},[]);const m=ge(()=>t==null?void 0:t.map(w=>{const{blurhash:S}=w;if(S){const I=Pn(S),x=Gn(I);return jn([.6,x[1],x[2]])}return null}),[t]),k=ge(()=>{var I;const S=100/m.length;return((I=m==null?void 0:m.map((x,G)=>{const D=G*S+5,M=(G+1)*S-5;return x?` rgba(${x==null?void 0:x.join(",")}, 0.4) ${D}%, rgba(${x==null?void 0:x.join(",")}, 0.4) ${M}% `:` transparent ${D}%, transparent ${M}% `}))==null?void 0:I.join(", "))||"transparent"},[m]);let g=H(null);return X(()=>()=>{var w,S;(S=(w=g.current)==null?void 0:w.hideToast)==null||S.call(w)},[]),e("div",{class:`media-modal-container media-modal-count-${t==null?void 0:t.length}`,children:[e("div",{ref:a,tabIndex:"0","data-swipe-threshold":"44",class:"carousel",onClick:w=>{(w.target.classList.contains("carousel-item")||w.target.classList.contains("media")||w.target.classList.contains("media-zoom"))&&r()},style:t.length>1?{backgroundAttachment:"local",backgroundImage:`linear-gradient( to right, ${k})`}:{},children:t==null?void 0:t.map((w,S)=>{const I=t.length===1?m[S]:null;return e("div",{class:"carousel-item",style:I?{"--accent-color":`rgb(${I==null?void 0:I.join(",")})`,"--accent-alpha-color":`rgba(${I==null?void 0:I.join(",")}, 0.4)`}:{},tabindex:"0",ref:S===d?c:null,onClick:x=>{x.target.classList.contains("media")||b(!l)},children:[!!w.description&&e("button",{type:"button",class:"media-alt",hidden:!l,onClick:()=>{$.showMediaAlt={alt:w.description,lang:i}},children:[e("span",{class:"alt-badge",children:"ALT"}),e("span",{class:"media-alt-desc",lang:i,dir:"auto",children:w.description})]}),e(Gi,{media:w,showOriginal:!0,lang:i})]},w.id)})}),e("div",{class:"carousel-top-controls",hidden:!l,children:[e("span",{children:e("button",{type:"button",class:"carousel-button",onClick:()=>r(),children:e(v,{icon:"x"})})}),(t==null?void 0:t.length)>1?e("span",{class:"carousel-dots",children:t==null?void 0:t.map((w,S)=>e("button",{type:"button",disabled:S===d,class:`carousel-dot ${S===d?"active":""}`,onClick:I=>{I.preventDefault(),I.stopPropagation(),a.current.scrollTo({left:a.current.clientWidth*S,behavior:"smooth"}),a.current.focus()},children:e(v,{icon:"round",size:"s"})},w.id))}):e("span",{}),e("span",{children:[e(Ze,{overflow:"auto",align:"end",position:"anchor",gap:4,menuClassName:"glass-menu",menuButton:e("button",{type:"button",class:"carousel-button",children:e(v,{icon:"more",alt:"More"})}),children:[e(Ee,{href:((y=t[d])==null?void 0:y.remoteUrl)||((T=t[d])==null?void 0:T.url),class:"carousel-button",target:"_blank",title:"Open original media in new window",children:[e(v,{icon:"popout"}),e("span",{children:"Open original media"})]}),!1]})," ",e(re,{to:`${s?`/${s}`:""}/s/${n}${window.matchMedia("(min-width: calc(40em + 350px))").matches?`?media=${d+1}`:""}`,class:"button carousel-button media-post-link",children:[e("span",{class:"button-label",children:"View post "}),"»"]})]})]}),(t==null?void 0:t.length)>1&&e("div",{class:"carousel-controls",hidden:!l,children:[e("button",{type:"button",class:"carousel-button",hidden:d===0,onClick:w=>{w.preventDefault(),w.stopPropagation(),a.current.focus(),a.current.scrollTo({left:a.current.clientWidth*(d-1),behavior:"smooth"})},children:e(v,{icon:"arrow-left"})}),e("button",{type:"button",class:"carousel-button",hidden:d===t.length-1,onClick:w=>{w.preventDefault(),w.stopPropagation(),a.current.focus(),a.current.scrollTo({left:a.current.clientWidth*(d+1),behavior:"smooth"})},children:e(v,{icon:"arrow-right"})})]})]})}const ua=[,"spam","legal","violation","other"],Ft={spam:{label:"Spam",description:"Malicious links, fake engagement, or repetitive replies"},legal:{label:"Illegal",description:"Violates the law of your or the server's country"},violation:{label:"Server rule violation",description:"Breaks specific server rules",stampLabel:"Violation"},other:{label:"Other",description:"Issue doesn't fit other categories",excludeStamp:!0}};function ha({account:t,post:n,onClose:s}){const{masto:i}=ne(),[o,r]=A("default"),[f,u]=t.acct.split("@"),[a,d]=ge(()=>{const{rules:g,domain:y}=Ui();return[g||[],y]}),[p,c]=A(null),[h,l]=A(!1),b=H(null),[m,k]=A(!1);return e("div",{class:"report-modal-container",children:[e("div",{class:"top-controls",children:[e("h1",{children:n?"Report Post":`Report @${f}`}),e("button",{type:"button",class:"plain4 small",disabled:o==="loading",onClick:()=>s(),children:e(v,{icon:"x",size:"xl"})})]}),e("main",{children:[e("div",{class:"report-preview",children:n?e(Be,{status:n,size:"s",previewMode:!0}):e(Qe,{account:t,avatarSize:"xxl",useAvatarStatic:!0,showStats:!0,showActivity:!0})}),!!p&&!Ft[p].excludeStamp&&e("span",{class:"rubber-stamp","aria-hidden":"true",children:[Ft[p].stampLabel||Ft[p].label,e("small",{children:"Pending review"})]},p),e("form",{onSubmit:g=>{g.preventDefault();const y=new FormData(g.target),T=Object.fromEntries(y.entries());let{category:w,comment:S,forward:I}=T;S||(S=void 0),I==="on"&&(I=!0);const x=w==="violation"?Object.entries(T).filter(([D])=>D.startsWith("rule_ids")).map(([D,M])=>M):void 0,G={category:w,comment:S,forward:I,ruleIds:x};r("loading"),(async()=>{try{await i.v1.reports.create({accountId:t.id,statusIds:n!=null&&n.id?[n.id]:void 0,category:w,comment:S,ruleIds:x,forward:I}),r("success"),se(n?"Post reported":"Profile reported"),s()}catch(D){r("error"),se((D==null?void 0:D.message)||(n?"Unable to report post":"Unable to report profile"))}})()},children:[e("p",{children:n?"What's the issue with this post?":"What's the issue with this profile?"}),e("section",{class:"report-categories",children:ua.map(g=>g==="violation"&&!(a!=null&&a.length)?null:e(E,{children:[e("label",{class:"report-category",children:[e("input",{type:"radio",name:"category",value:g,required:!0,disabled:o==="loading",onChange:y=>{c(y.target.value),l(y.target.value==="violation")}}),e("span",{children:[Ft[g].label,"  ",e("small",{class:"ib insignificant",children:Ft[g].description})]})]}),g==="violation"&&!!(a!=null&&a.length)&&e("div",{class:"shazam-container no-animation",hidden:!h,children:e("div",{class:"shazam-container-inner",children:e("div",{class:"report-rules",ref:b,children:a.map((y,T)=>e("label",{class:"report-rule",children:[e("input",{type:"checkbox",name:`rule_ids[${T}]`,value:y.id,required:h&&!m,disabled:o==="loading",onChange:w=>{const{checked:S}=w.target;S?k(!0):b.current.querySelectorAll("input:checked").length||k(!1)}}),e("span",{children:y.text})]},y.id))})})})]},g))}),e("section",{class:"report-comment",children:[e("p",{children:e("label",{for:"report-comment",children:"Additional info"})}),e("textarea",{maxlength:"1000",rows:"1",name:"comment",id:"report-comment",disabled:o==="loading"})]}),!!u&&u!==d&&e("section",{children:e("p",{children:e("label",{children:[e("input",{type:"checkbox",switch:!0,name:"forward",disabled:o==="loading"})," ",e("span",{children:["Forward to ",e("i",{children:u})]})]})})}),e("footer",{children:[e("button",{type:"submit",disabled:o==="loading",children:"Send Report"})," ",e("button",{type:"submit",class:"plain2",disabled:o==="loading",onClick:async()=>{try{await i.v1.accounts.$select(t.id).mute(),se(`Muted ${f}`)}catch{se(`Unable to mute ${f}`)}},children:["Send Report ",e("small",{class:"ib",children:"+ Mute profile"})]})," ",e("button",{type:"submit",class:"plain2",disabled:o==="loading",onClick:async()=>{try{await i.v1.accounts.$select(t.id).block(),se(`Blocked ${f}`)}catch{se(`Unable to block ${f}`)}},children:["Send Report ",e("small",{class:"ib",children:"+ Block profile"})]}),e(Ae,{hidden:o!=="loading"})]})]})]})]})}var Yn={exports:{}},Gc=Yn.exports;(function(t){var n=function(){var s=String.fromCharCode,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",r={};function f(a,d){if(!r[a]){r[a]={};for(var p=0;p>>8,p[c*2+1]=l%256}return p},decompressFromUint8Array:function(a){if(a==null)return u.decompress(a);for(var d=new Array(a.length/2),p=0,c=d.length;p>1}else{for(h=1,c=0;c>1}y--,y==0&&(y=Math.pow(2,w),w++),delete b[g]}else for(h=l[g],c=0;c>1;y--,y==0&&(y=Math.pow(2,w),w++),l[k]=T++,g=String(m)}if(g!==""){if(Object.prototype.hasOwnProperty.call(b,g)){if(g.charCodeAt(0)<256){for(c=0;c>1}else{for(h=1,c=0;c>1}y--,y==0&&(y=Math.pow(2,w),w++),delete b[g]}else for(h=l[g],c=0;c>1;y--,y==0&&(y=Math.pow(2,w),w++)}for(h=2,c=0;c>1;for(;;)if(I=I<<1,x==d-1){S.push(p(I));break}else x++;return S.join("")},decompress:function(a){return a==null?"":a==""?null:u._decompress(a.length,32768,function(d){return a.charCodeAt(d)})},_decompress:function(a,d,p){var c=[],h,l=4,b=4,m=3,k="",g=[],y,T,w,S,I,x,G,D={val:p(0),position:d,index:1};for(y=0;y<3;y+=1)c[y]=y;for(w=0,I=Math.pow(2,2),x=1;x!=I;)S=D.val&D.position,D.position>>=1,D.position==0&&(D.position=d,D.val=p(D.index++)),w|=(S>0?1:0)*x,x<<=1;switch(h=w){case 0:for(w=0,I=Math.pow(2,8),x=1;x!=I;)S=D.val&D.position,D.position>>=1,D.position==0&&(D.position=d,D.val=p(D.index++)),w|=(S>0?1:0)*x,x<<=1;G=s(w);break;case 1:for(w=0,I=Math.pow(2,16),x=1;x!=I;)S=D.val&D.position,D.position>>=1,D.position==0&&(D.position=d,D.val=p(D.index++)),w|=(S>0?1:0)*x,x<<=1;G=s(w);break;case 2:return""}for(c[3]=G,T=G,g.push(G);;){if(D.index>a)return"";for(w=0,I=Math.pow(2,m),x=1;x!=I;)S=D.val&D.position,D.position>>=1,D.position==0&&(D.position=d,D.val=p(D.index++)),w|=(S>0?1:0)*x,x<<=1;switch(G=w){case 0:for(w=0,I=Math.pow(2,8),x=1;x!=I;)S=D.val&D.position,D.position>>=1,D.position==0&&(D.position=d,D.val=p(D.index++)),w|=(S>0?1:0)*x,x<<=1;c[b++]=s(w),G=b-1,l--;break;case 1:for(w=0,I=Math.pow(2,16),x=1;x!=I;)S=D.val&D.position,D.position>>=1,D.position==0&&(D.position=d,D.val=p(D.index++)),w|=(S>0?1:0)*x,x<<=1;c[b++]=s(w),G=b-1,l--;break;case 2:return g.join("")}if(l==0&&(l=Math.pow(2,m),m++),c[G])k=c[G];else if(G===b)k=T+T.charAt(0);else return null;g.push(k),c[b++]=T+k.charAt(0),l--,T=k,l==0&&(l=Math.pow(2,m),m++)}}};return u}();t!=null?t.exports=n:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return n})})(Yn);var pi=Yn.exports;const fa="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20fill='none'%20viewBox='0%200%2084%2062'%3e%3crect%20width='64'%20height='48'%20x='18'%20y='2'%20fill='%23fff'%20stroke='%23999'%20stroke-width='3'%20rx='4'/%3e%3crect%20width='32'%20height='48'%20x='2'%20y='12'%20fill='%23fff'%20stroke='%23999'%20stroke-width='3'%20rx='4'/%3e%3cpath%20fill='%234169E1'%20d='M14%2052a4%204%200%201%201-8%200%204%204%200%200%201%208%200Zm64-42a4%204%200%201%201-8%200%204%204%200%200%201%208%200Z'/%3e%3c/svg%3e",pa="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20fill='none'%20viewBox='0%200%2082%2062'%3e%3crect%20width='78'%20height='58'%20x='2'%20y='2'%20fill='%23999'%20fill-opacity='.3'%20stroke='%23999'%20stroke-width='3'%20rx='4'/%3e%3crect%20width='18'%20height='46'%20x='8'%20y='8'%20fill='%23fff'%20stroke='%23999'%20stroke-width='2'%20rx='1'/%3e%3crect%20width='18'%20height='46'%20x='32'%20y='8'%20fill='%23fff'%20stroke='%23999'%20stroke-width='2'%20rx='1'/%3e%3crect%20width='18'%20height='46'%20x='56'%20y='8'%20fill='%23fff'%20stroke='%23999'%20stroke-width='2'%20rx='1'/%3e%3c/svg%3e",ma="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20fill='none'%20viewBox='0%200%2084%2062'%3e%3crect%20width='64'%20height='48'%20x='18'%20y='2'%20fill='%23fff'%20stroke='%23999'%20stroke-width='3'%20rx='4'/%3e%3cpath%20fill='%23999'%20fill-opacity='.3'%20d='M19%203h62v10H19z'/%3e%3cpath%20stroke='%234169E1'%20stroke-width='2'%20d='M43%208a2%202%200%201%201-4%200%202%202%200%200%201%204%200Z'/%3e%3cpath%20stroke='%23999'%20stroke-width='2'%20d='M52%208a2%202%200%201%201-4%200%202%202%200%200%201%204%200Zm9%200a2%202%200%201%201-4%200%202%202%200%200%201%204%200Z'/%3e%3crect%20width='32'%20height='48'%20x='2'%20y='12'%20fill='%23fff'%20stroke='%23999'%20stroke-width='3'%20rx='4'/%3e%3cpath%20fill='%23999'%20fill-opacity='.3'%20d='M3%2049h30v10H3z'/%3e%3cpath%20stroke='%234169E1'%20stroke-width='2'%20d='M11%2054a2%202%200%201%201-4%200%202%202%200%200%201%204%200Z'/%3e%3cpath%20stroke='%23999'%20stroke-width='2'%20d='M20%2054a2%202%200%201%201-4%200%202%202%200%200%201%204%200Zm9%200a2%202%200%201%201-4%200%202%202%200%200%201%204%200Z'/%3e%3c/svg%3e",ga=200,ba=10;async function un(){const{masto:t}=ne(),n=t.v1.followedTags.list({limit:ga}),s=[];let i=0;do{const{value:o,done:r}=await n.next();if(r||(o==null?void 0:o.length)===0)break;s.push(...o),i++}while(io.name.localeCompare(r.name)),s.length&&setTimeout(()=>{we.account.set("followedTags",{tags:s,updatedAt:Date.now()})},1),s}const ya=24*60*60*1e3;async function wa(){try{const{tags:t,updatedAt:n}=we.account.get("followedTags")||{};return t!=null&&t.length?(Date.now()-n>ya&&un(),t):await un()}catch{return[]}}const mi=document.createElement("div"),va=t=>{if(!t)return[];if(t.indexOf("#")===-1)return[];mi.innerHTML=t;const n=mi.querySelectorAll("a.hashtag");return n.length?Array.from(n).map(s=>s.innerText.trim().replace(/^[^#]*#+/,"")):[]};function tn({children:t}){if(typeof t=="string")return t;const[n,s]=A("");return X(()=>{Promise.resolve(t).then(s)},[t]),n}const lt=9,ka=["following","mentions","notifications","list","public","trending","search","hashtag","bookmarks","favourites"],ds={following:"Home / Following",notifications:"Notifications",list:"Lists",public:"Public (Local / Federated)",search:"Search","account-statuses":"Account",bookmarks:"Bookmarks",favourites:"Likes",hashtag:"Hashtag",trending:"Trending",mentions:"Mentions"},nn={list:[{text:"List ID",name:"id",notRequired:!0}],public:[{text:"Local only",name:"local",type:"checkbox"},{text:"Instance",name:"instance",type:"text",placeholder:"Optional, e.g. mastodon.social",notRequired:!0}],trending:[{text:"Instance",name:"instance",type:"text",placeholder:"Optional, e.g. mastodon.social",notRequired:!0}],search:[{text:"Search term",name:"query",type:"text",placeholder:"Optional, unless for multi-column mode",notRequired:!0}],"account-statuses":[{text:"@",name:"id",type:"text",placeholder:"cheeaun@mastodon.social"}],hashtag:[{text:"#",name:"hashtag",type:"text",placeholder:"e.g. PixelArt (Max 5, space-separated)",pattern:"[^#]+"},{text:"Media only",name:"media",type:"checkbox"},{text:"Instance",name:"instance",type:"text",placeholder:"Optional, e.g. mastodon.social",notRequired:!0}]},Sa=ft(async({id:t})=>{const n=await ne().masto.v1.accounts.$select(t).fetch();return n.username||n.acct||n.displayName}),hn={following:{id:"home",title:(t,n)=>n===0?"Home":"Following",path:"/",icon:"home"},mentions:{id:"mentions",title:"Mentions",path:"/mentions",icon:"at"},notifications:{id:"notifications",title:"Notifications",path:"/notifications",icon:"notification"},list:{id:({id:t})=>t?"list":"lists",title:({id:t})=>t?Oo(t):"Lists",path:({id:t})=>t?`/l/${t}`:"/l",icon:"list",excludeViewMode:({id:t})=>t?[]:["multi-column"]},public:{id:"public",title:({local:t})=>t?"Local":"Federated",subtitle:({instance:t})=>t||ne().instance,path:({local:t,instance:n})=>`/${n}/p${t?"/l":""}`,icon:({local:t})=>t?"building":"earth"},trending:{id:"trending",title:"Trending",subtitle:({instance:t})=>t||ne().instance,path:({instance:t})=>`/${t}/trending`,icon:"chart"},search:{id:"search",title:({query:t})=>t?`“${t}”`:"Search",path:({query:t})=>t?`/search?q=${encodeURIComponent(t)}&type=statuses`:"/search",icon:"search",excludeViewMode:({query:t})=>t?[]:["multi-column"]},"account-statuses":{id:"account-statuses",title:Sa,path:({id:t})=>`/a/${t}`,icon:"user"},bookmarks:{id:"bookmarks",title:"Bookmarks",path:"/b",icon:"bookmark"},favourites:{id:"favourites",title:"Likes",path:"/f",icon:"heart"},hashtag:{id:"hashtag",title:({hashtag:t})=>t,subtitle:({instance:t})=>t||ne().instance,path:({hashtag:t,instance:n,media:s})=>`${n?`/${n}`:""}/t/${t.split(/\s+/).join("+")}${s?"?media=1":""}`,icon:"hashtag"}};function Ia({onClose:t}){const n=De($),{shortcuts:s}=n,[i,o]=A(!1),[r,f]=A(!1),[u]=Bn();return e("div",{id:"shortcuts-settings-container",class:"sheet",tabindex:"-1",children:[!!t&&e("button",{type:"button",class:"sheet-close",onClick:t,children:e(v,{icon:"x"})}),e("header",{children:e("h2",{children:[e(v,{icon:"shortcut"})," Shortcuts"," ",e("sup",{style:{fontSize:12,opacity:.5,textTransform:"uppercase"},children:"beta"})]})}),e("main",{children:[e("p",{children:"Specify a list of shortcuts that'll appear as:"}),e("div",{class:"shortcuts-view-mode",children:[{value:"float-button",label:"Floating button",imgURL:fa},{value:"tab-menu-bar",label:"Tab/Menu bar",imgURL:ma},{value:"multi-column",label:"Multi-column",imgURL:pa}].map(({value:a,label:d,imgURL:p})=>{const c=n.settings.shortcutsViewMode===a||a==="float-button"&&!n.settings.shortcutsViewMode;return e("label",{class:c?"checked":"",children:[e("input",{type:"radio",name:"shortcuts-view-mode",value:a,checked:c,onChange:h=>{$.settings.shortcutsViewMode=h.target.value}})," ",e("img",{src:p,alt:"",width:"80",height:"58"})," ",e("span",{children:d})]},a)})}),s.length>0?e(E,{children:[e("ol",{class:"shortcuts-list",ref:u,children:s.filter(Boolean).map((a,d)=>{const p=Object.values(a).join("-"),{type:c}=a;if(!hn[c])return null;let{icon:h,title:l,subtitle:b,excludeViewMode:m}=hn[c];typeof l=="function"&&(l=l(a,d)),typeof b=="function"&&(b=b(a,d)),typeof h=="function"&&(h=h(a,d)),typeof m=="function"&&(m=m(a,d));const k=m==null?void 0:m.includes(n.settings.shortcutsViewMode);return e("li",{children:[e(v,{icon:h}),e("span",{class:"shortcut-text",children:[e(tn,{children:l}),b&&e(E,{children:[" ",e("small",{class:"ib insignificant",children:b})]}),k&&e("span",{class:"tag",children:"Not available in current view mode"})]}),e("span",{class:"shortcut-actions",children:[e("button",{type:"button",class:"plain small",disabled:d===0,onClick:()=>{const g=Array.from($.shortcuts);if(d>0){const y=$.shortcuts[d-1];g[d-1]=a,g[d]=y,$.shortcuts=g}},children:e(v,{icon:"arrow-up",alt:"Move up"})}),e("button",{type:"button",class:"plain small",disabled:d===s.length-1,onClick:()=>{const g=Array.from($.shortcuts);if(d<$.shortcuts.length-1){const y=$.shortcuts[d+1];g[d+1]=a,g[d]=y,$.shortcuts=g}},children:e(v,{icon:"arrow-down",alt:"Move down"})}),e("button",{type:"button",class:"plain small",onClick:()=>{o({shortcut:a,shortcutIndex:d})},children:e(v,{icon:"pencil",alt:"Edit"})})]})]},p)})}),s.length===1&&n.settings.shortcutsViewMode!=="float-button"&&e("div",{class:"ui-state insignificant",children:[e(v,{icon:"info"})," ",e("small",{children:"Add more than one shortcut/column to make this work."})]})]}):e("div",{class:"ui-state insignificant",children:[e("p",{children:n.settings.shortcutsViewMode==="multi-column"?"No columns yet. Tap on the Add column button.":"No shortcuts yet. Tap on the Add shortcut button."}),e("p",{children:["Not sure what to add?",e("br",{}),"Try adding"," ",e("a",{href:"#",onClick:a=>{a.preventDefault(),$.shortcuts=[{type:"following"},{type:"notifications"}]},children:"Home / Following and Notifications"})," ","first."]})]}),e("p",{class:"insignificant",children:s.length>=lt&&(n.settings.shortcutsViewMode==="multi-column"?`Max ${lt} columns`:`Max ${lt} shortcuts`)}),e("p",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e("button",{type:"button",class:"light",onClick:()=>f(!0),children:"Import/export"}),e("button",{type:"button",disabled:s.length>=lt,onClick:()=>o(!0),children:[e(v,{icon:"plus"})," ",e("span",{children:n.settings.shortcutsViewMode==="multi-column"?"Add column…":"Add shortcut…"})]})]})]}),i&&e(Re,{onClick:a=>{a.target===a.currentTarget&&o(!1)},children:e(Ca,{shortcut:i.shortcut,shortcutIndex:i.shortcutIndex,onSubmit:({result:a,mode:d})=>{d==="edit"?$.shortcuts[i.shortcutIndex]=a:$.shortcuts.push(a)},onClose:()=>o(!1)})}),r&&e(Re,{onClick:a=>{a.target===a.currentTarget&&f(!1)},children:e(Ta,{shortcuts:s,onClose:()=>f(!1)})})]})}const gi={list:"Specific list is optional. For multi-column mode, list is required, else the column will not be shown.",search:"For multi-column mode, search term is required, else the column will not be shown.",hashtag:"Multiple hashtags are supported. Space-separated."};function Ca({onSubmit:t,disabled:n,shortcut:s,shortcutIndex:i,onClose:o}){var k,g;const r=!!s,[f,u]=A((s==null?void 0:s.type)||null),{masto:a}=ne(),[d,p]=A("default"),[c,h]=A([]),[l,b]=A([]);X(()=>{(async()=>{if(f==="list")try{p("loading");const y=await Yt();h(y),p("default")}catch{p("error")}})(),(async()=>{if(f==="hashtag")try{const y=await un();b(y)}catch{}})()},[f]);const m=H();return X(()=>{if(r&&f&&nn[f]){const y=m.current;nn[f].forEach(({name:T,type:w})=>{const S=y.querySelector(`[name="${T}"]`);S&&s[T]&&(w==="checkbox"?S.checked=s[T]==="on":S.value=s[T])})}},[r,f]),e("div",{id:"shortcut-settings-form",class:"sheet",children:[!!o&&e("button",{type:"button",class:"sheet-close",onClick:o,children:e(v,{icon:"x"})}),e("header",{children:e("h2",{children:[r?"Edit":"Add"," shortcut"]})}),e("main",{tabindex:"-1",children:e("form",{ref:m,onSubmit:y=>{y.preventDefault();const T=new FormData(y.target),w={};T.forEach((S,I)=>{w[I]=S==null?void 0:S.trim(),I==="instance"&&(w[I]=w[I].replace(/^https?:\/\//,"").replace(/\/+$/,""),w[I]=w[I].replace(/^@?[^@]+@/,""))}),w.type&&(t({result:w,mode:r?"edit":"add"}),y.target.reset(),u(null),o==null||o())},children:[e("p",{children:e("label",{children:[e("span",{children:"Timeline"}),e("select",{required:!0,disabled:n,onChange:y=>{u(y.target.value)},defaultValue:r?s.type:void 0,name:"type",children:[e("option",{}),ka.map(y=>e("option",{value:y,children:ds[y]}))]})]})}),(g=(k=nn[f])==null?void 0:k.map)==null?void 0:g.call(k,({text:y,name:T,type:w,placeholder:S,pattern:I,notRequired:x})=>f==="list"?e("p",{children:e("label",{children:[e("span",{children:"List"}),e("select",{name:"id",required:!x,disabled:n||d==="loading",defaultValue:r?s.id:void 0,children:[e("option",{value:""}),c.map(G=>e("option",{value:G.id,children:G.title}))]})]})}):e("p",{children:e("label",{children:[e("span",{children:y})," ",e("input",{type:w,switch:w==="checkbox"||void 0,name:T,placeholder:S,required:w==="text"&&!x,disabled:n,list:f==="hashtag"?"followed-hashtags-datalist":null,autocorrect:"off",autocapitalize:"off",spellCheck:!1,pattern:I}),f==="hashtag"&&l.length>0&&e("datalist",{id:"followed-hashtags-datalist",children:l.map(G=>e("option",{value:G.name}))})]})})),!!gi[f]&&e("p",{class:"form-note insignificant",children:[e(v,{icon:"info"}),gi[f]]}),e("footer",{children:[e("button",{type:"submit",class:"block",disabled:n||d==="loading",children:r?"Save":"Add"}),r&&e("button",{type:"button",class:"light danger",onClick:()=>{$.shortcuts.splice(i,1),o==null||o()},children:"Remove"})]})]})})]})}function Ta({shortcuts:t,onClose:n}){var c;const{masto:s}=ne(),i=ge(()=>!t||!t.filter(Boolean).length?"":pi.compressToEncodedURIComponent(JSON.stringify(t.filter(Boolean))),[t]),[o,r]=A(""),[f,u]=A("default"),a=ge(()=>{if(!o)return u("default"),null;try{const h=JSON.parse(pi.decompressFromEncodedURIComponent(o));if(!Array.isArray(h))throw new Error("Not an array");return u("default"),h}catch{try{const l=JSON.parse(o);if(!Array.isArray(l))throw new Error("Not an array");return u("default"),l}catch{return u("error"),null}}},[o]),d=$.shortcuts.length>0,p=H();return e("div",{id:"import-export-container",class:"sheet",children:[!!n&&e("button",{type:"button",class:"sheet-close",onClick:n,children:e(v,{icon:"x"})}),e("header",{children:e("h2",{children:["Import/Export ",e("small",{class:"ib insignificant",children:"Shortcuts"})]})}),e("main",{tabindex:"-1",children:[e("section",{children:[e("h3",{children:[e(v,{icon:"arrow-down-circle",size:"l",class:"insignificant"})," ",e("span",{children:"Import"})]}),e("p",{class:"field-button",children:[e("input",{ref:p,type:"text",name:"import",placeholder:"Paste shortcuts here",class:"block",onInput:h=>{r(h.target.value)}}),$.settings.shortcutSettingsCloudImportExport&&e("button",{type:"button",class:"plain2 small",disabled:f==="cloud-downloading",onClick:async()=>{u("cloud-downloading");const h=dt();se("Downloading saved shortcuts from instance server…");try{const b=(await s.v1.accounts.relationships.fetch({id:[h]}))[0];if(b){const{note:m=""}=b;if(/(.*)<\/phanpy-shortcuts-settings>/.test(m)){const k=m.match(/(.*)<\/phanpy-shortcuts-settings>/)[1],{v:g,dt:y,data:T}=JSON.parse(k);p.current.value=T,p.current.dispatchEvent(new Event("input"))}}u("default")}catch{u("error"),se("Unable to download shortcuts")}},title:"Download shortcuts from instance server",children:[e(v,{icon:"cloud"}),e(v,{icon:"arrow-down"})]})]}),!!a&&Array.isArray(a)&&e(E,{children:[e("p",{children:[e("b",{children:a.length})," shortcut",a.length>1?"s":""," ",e("small",{class:"insignificant",children:["(",o.length," characters)"]})]}),e("ol",{class:"import-settings-list",children:a.map(h=>{var l,b;return e("li",{children:[e("span",{style:{opacity:t.some(m=>Object.keys(m).every(k=>m[k]===h[k]))?1:0},children:"*"}),e("span",{children:[ds[h.type],h.type==="list"&&" ⚠️"," ",(b=(l=nn[h.type])==null?void 0:l.map)==null?void 0:b.call(l,({text:m,name:k,type:g})=>h[k]?e(E,{children:[e("span",{class:"tag collapsed insignificant",children:[m,":"," ",g==="checkbox"?h[k]==="on"?"✅":"❌":h[k]]})," "]}):null)]})]})})}),e("p",{children:[e("small",{children:"* Exists in current shortcuts"}),e("br",{}),e("small",{children:"⚠️ List may not work if it's from a different account."})]})]}),f==="error"&&e("p",{class:"error",children:e("small",{children:"⚠️ Invalid settings format"})}),e("p",{children:[d&&e(E,{children:[e(tt,{confirmLabel:"Append to current shortcuts?",menuFooter:e("div",{class:"footer",children:"Only shortcuts that don’t exist in current shortcuts will be appended."}),onClick:()=>{const h=a.filter(m=>!$.shortcuts.some(k=>Object.keys(k).every(g=>k[g]===m[g])));if(!h.length){se("No new shortcuts to import");return}let l=[...$.shortcuts,...h];const b=l.length>lt;b&&(l=l.slice(0,lt)),$.shortcuts=l,se(b?`Shortcuts imported. Exceeded max ${lt}, so the rest are not imported.`:"Shortcuts imported"),n==null||n()},children:e("button",{type:"button",class:"plain2",disabled:!a,children:"Import & append…"})})," "]}),e(tt,{confirmLabel:d?"Override current shortcuts?":"Import shortcuts?",menuItemClassName:d?"danger":void 0,onClick:()=>{$.shortcuts=a,se("Shortcuts imported"),n==null||n()},children:e("button",{type:"button",class:"plain2",disabled:!a,children:d?"or override…":"Import…"})})]})]}),e("section",{children:[e("h3",{children:[e(v,{icon:"arrow-up-circle",size:"l",class:"insignificant"})," ",e("span",{children:"Export"})]}),e("p",{children:e("input",{style:{width:"100%"},type:"text",value:i,readOnly:!0,onClick:h=>{if(h.target.value){h.target.select();try{navigator.clipboard.writeText(h.target.value),se("Shortcuts copied")}catch{se("Unable to copy shortcuts")}}}})}),e("p",{children:[e("button",{type:"button",class:"plain2",disabled:!i,onClick:()=>{try{navigator.clipboard.writeText(i),se("Shortcut settings copied")}catch{se("Unable to copy shortcut settings")}},children:[e(v,{icon:"clipboard"})," ",e("span",{children:"Copy"})]})," ",(navigator==null?void 0:navigator.share)&&((c=navigator==null?void 0:navigator.canShare)==null?void 0:c.call(navigator,{text:i}))&&e("button",{type:"button",class:"plain2",disabled:!i,onClick:()=>{try{navigator.share({text:i})}catch{alert("Sharing doesn't seem to work.")}},children:[e(v,{icon:"share"})," ",e("span",{children:"Share"})]})," ",$.settings.shortcutSettingsCloudImportExport&&e("button",{type:"button",class:"plain2",disabled:f==="cloud-uploading",onClick:async()=>{u("cloud-uploading");const h=dt();try{const b=(await s.v1.accounts.relationships.fetch({id:[h]}))[0];if(b){const{note:m=""}=b;let k="";if(/(.*)<\/phanpy-shortcuts-settings>/.test(m)){const g=JSON.stringify({v:"1",dt:Date.now(),data:i});k=m.replace(/(.*)<\/phanpy-shortcuts-settings>/,`${g}`)}else k=`${m} ${settingsJSON}`;se("Saving shortcuts to instance server…"),await s.v1.accounts.$select(h).note.create({comment:k}),u("default"),se("Shortcuts saved")}}catch{u("error"),se("Unable to save shortcuts")}},title:"Sync to instance server",children:[e(v,{icon:"cloud"}),e(v,{icon:"arrow-up"})]})," ",i.length>0&&e("small",{class:"insignificant ib",children:[i.length," characters"]})]}),!!i&&e("details",{children:[e("summary",{class:"insignificant",children:e("small",{children:"Raw Shortcuts JSON"})}),e("textarea",{style:{width:"100%"},rows:10,readOnly:!0,children:JSON.stringify(t.filter(Boolean),null,2)})]})]}),$.settings.shortcutSettingsCloudImportExport&&e("footer",{children:e("p",{children:[e(v,{icon:"cloud"})," Import/export settings from/to instance server (Very experimental)"]})})]})]})}Fi($,t=>{for(const[n,s,i,o]of t)/^show/i.test(s)&&!i&&Tn()});function xa(){var i,o,r,f,u,a,d,p;const t=De($),n=Oi(),s=Nt();return X(()=>{setTimeout(Rs,1e3)},[]),e(E,{children:[!!t.showCompose&&e(Re,{class:`solid ${t.composerState.minimized?"min":""}`,minimized:!!t.composerState.minimized,children:e(Es,{replyToStatus:typeof t.showCompose!="boolean"?t.showCompose.replyToStatus:((i=window.__COMPOSE__)==null?void 0:i.replyToStatus)||null,editStatus:((o=$.showCompose)==null?void 0:o.editStatus)||((r=window.__COMPOSE__)==null?void 0:r.editStatus)||null,draftStatus:((f=$.showCompose)==null?void 0:f.draftStatus)||((u=window.__COMPOSE__)==null?void 0:u.draftStatus)||null,onClose:c=>{const{newStatus:h,instance:l,type:b}=c||{};$.showCompose=!1,window.__COMPOSE__=null,h&&($.reloadStatusPage++,se({text:{post:"Post published. Check it out.",reply:"Reply posted. Check it out.",edit:"Post updated. Check it out."}[b||"post"],delay:1e3,duration:1e4,onClick:m=>{m.hideToast(),$.prevLocation=s,n(l?`/${l}/s/${h.id}`:`/s/${h.id}`)}}))}})}),!!t.showSettings&&e(Re,{onClose:()=>{$.showSettings=!1},children:e(Po,{onClose:()=>{$.showSettings=!1}})}),!!t.showAccounts&&e(Re,{onClose:()=>{$.showAccounts=!1},children:e(To,{onClose:()=>{$.showAccounts=!1}})}),!!t.showAccount&&e(Re,{onClose:()=>{$.showAccount=!1},children:e(sa,{account:((a=t.showAccount)==null?void 0:a.account)||t.showAccount,instance:(d=t.showAccount)==null?void 0:d.instance,onClose:({destination:c}={})=>{$.showAccount=!1}})}),!!t.showDrafts&&e(Re,{onClose:()=>{$.showDrafts=!1},children:e(oa,{onClose:()=>$.showDrafts=!1})}),!!t.showMediaModal&&e(Re,{onClick:c=>{(c.target===c.currentTarget||c.target.classList.contains("media"))&&($.showMediaModal=!1)},children:e(ls,{mediaAttachments:t.showMediaModal.mediaAttachments,instance:t.showMediaModal.instance,index:t.showMediaModal.index,statusID:t.showMediaModal.statusID,onClose:()=>{$.showMediaModal=!1}})}),!!t.showShortcutsSettings&&e(Re,{onClose:()=>{$.showShortcutsSettings=!1},children:e(Ia,{onClose:()=>$.showShortcutsSettings=!1})}),!!t.showGenericAccounts&&e(Re,{onClose:()=>{$.showGenericAccounts=!1},children:e(ca,{instance:t.showGenericAccounts.instance,excludeRelationshipAttrs:t.showGenericAccounts.excludeRelationshipAttrs,postID:t.showGenericAccounts.postID,onClose:()=>$.showGenericAccounts=!1,blankCopy:t.showGenericAccounts.blankCopy})}),!!t.showMediaAlt&&e(Re,{onClose:c=>{$.showMediaAlt=!1},children:e(la,{alt:t.showMediaAlt.alt||t.showMediaAlt,lang:(p=t.showMediaAlt)==null?void 0:p.lang,onClose:()=>{$.showMediaAlt=!1}})}),!!t.showEmbedModal&&e(Re,{class:"solid",onClose:()=>{$.showEmbedModal=!1},children:e(ra,{html:t.showEmbedModal.html,url:t.showEmbedModal.url,width:t.showEmbedModal.width,height:t.showEmbedModal.height,onClose:()=>{$.showEmbedModal=!1}})}),!!t.showReportModal&&e(Re,{onClose:()=>{$.showReportModal=!1},children:e(ha,{account:t.showReportModal.account,post:t.showReportModal.post,onClose:()=>{$.showReportModal=!1}})})]})}function $n({accountID:t,onChange:n}){const{masto:s}=ne(),[i,o]=A("default"),[r,f]=A(null),[u,a]=A(null),d=u!==null;return e("p",{class:"follow-request-buttons",children:[e("button",{type:"button",disabled:i==="loading"||d,onClick:()=>{o("loading"),f("accept"),(async()=>{try{const p=await s.v1.followRequests.$select(t).authorize();if(!(p!=null&&p.followedBy))throw new Error("Follow request not accepted");a(p),n()}catch{}o("default")})()},children:"Accept"})," ",e("button",{type:"button",disabled:i==="loading"||d,class:"light danger",onClick:()=>{o("loading"),f("reject"),(async()=>{try{const p=await s.v1.followRequests.$select(t).reject();if(p!=null&&p.followedBy)throw new Error("Follow request not rejected");a(p),n()}catch{o("default")}})()},children:"Reject"}),e("span",{class:"follow-request-states",children:d&&r?r==="accept"?e(v,{icon:"check-circle",alt:"Accepted",class:"follow-accepted"}):e(v,{icon:"x-circle",alt:"Rejected",class:"follow-rejected"}):e(Ae,{hidden:i!=="loading"})})]})}const bi={mention:"comment",status:"notification",reblog:"rocket",follow:"follow",follow_request:"follow-add",favourite:"heart",poll:"poll",update:"pencil","admin.signup":"account-edit","admin.report":"account-warning",severed_relationships:"heart-break",moderation_warning:"alert",emoji_reaction:"emoji2","pleroma:emoji_reaction":"emoji2"};function yi(t,n){let s,i;return typeof n=="string"?s=n:(s=n==null?void 0:n.url,i=n==null?void 0:n.staticUrl),s?e(E,{children:["reacted to your post with"," ",e(js,{url:s,staticUrl:i,alt:t})]}):`reacted to your post with ${t}.`}const $t={mention:"mentioned you in their post.",status:"published a post.",reblog:"boosted your post.","reblog+account":t=>`boosted ${t} of your posts.`,reblog_reply:"boosted your reply.",follow:"followed you.",follow_request:"requested to follow you.",favourite:"liked your post.","favourite+account":t=>`liked ${t} of your posts.`,favourite_reply:"liked your reply.",poll:"A poll you have voted in or created has ended.","poll-self":"A poll you have created has ended.","poll-voted":"A poll you have voted in has ended.",update:"A post you interacted with has been edited.","favourite+reblog":"boosted & liked your post.","favourite+reblog+account":t=>`boosted & liked ${t} of your posts.`,"favourite+reblog_reply":"boosted & liked your reply.","admin.sign_up":"signed up.","admin.report":t=>e(E,{children:["reported ",t]}),severed_relationships:t=>e(E,{children:["Lost connections with ",e("i",{children:t}),"."]}),moderation_warning:e("b",{children:"Moderation warning"}),emoji_reaction:yi,"pleroma:emoji_reaction":yi},$a={account_suspension:({from:t,targetName:n})=>e(E,{children:["An admin from ",e("i",{children:t})," has suspended ",e("i",{children:n}),", which means you can no longer receive updates from them or interact with them."]}),domain_block:({from:t,targetName:n,followersCount:s,followingCount:i})=>e(E,{children:["An admin from ",e("i",{children:t})," has blocked ",e("i",{children:n}),". Affected followers: ",s,", followings: ",i,"."]}),user_domain_block:({targetName:t,followersCount:n,followingCount:s})=>e(E,{children:["You have blocked ",e("i",{children:t}),". Removed followers: ",n,", followings: ",s,"."]})},Aa={none:"Your account has received a moderation warning.",disable:"Your account has been disabled.",mark_statuses_as_sensitive:"Some of your posts have been marked as sensitive.",delete_statuses:"Some of your posts have been deleted.",sensitive:"Your posts will be marked as sensitive from now on.",silence:"Your account has been limited.",suspend:"Your account has been suspended."},vn=30;function Ra({notification:t,instance:n,isStatic:s,disableContextMenu:i}){var D,M,ee,J,L,N;const{id:o,status:r,account:f,report:u,event:a,moderation_warning:d,_accounts:p,_statuses:c}=t;let{type:h}=t;const l=(r==null?void 0:r.reblog)||r,b=l==null?void 0:l.id,m=dt(),k=m===(f==null?void 0:f.id),g=(D=r==null?void 0:r.poll)==null?void 0:D.voted,y=!!(r!=null&&r.inReplyToAccountId)&&(r==null?void 0:r.inReplyToAccountId)!==m&&((M=r==null?void 0:r.account)==null?void 0:M.id)===m;let T=0,w=0;if(h==="favourite+reblog"){for(const _ of p)(ee=_._types)!=null&&ee.includes("favourite")&&T++,(J=_._types)!=null&&J.includes("reblog")&&w++;!w&&T&&(h="favourite"),!T&&w&&(h="reblog")}let S;if(h==="poll"?S=$t[k?"poll-self":g?"poll-voted":"poll"]:h==="reblog"||h==="favourite"||h==="favourite+reblog"?(c==null?void 0:c.length)>1?S=$t[`${h}+account`]:y?S=$t[`${h}_reply`]:S=$t[h]:$t[h]?S=$t[h]:S=`[Unknown notification type: ${h}]`,typeof S=="function"){const _=(c==null?void 0:c.length)||(p==null?void 0:p.length);if(h==="admin.report"){const U=u==null?void 0:u.targetAccount;U&&(S=S(e(_t,{account:U,showAvatar:!0})))}else if(h==="severed_relationships"){const U=a==null?void 0:a.targetName;U&&(S=S(U))}else if((h==="emoji_reaction"||h==="pleroma:emoji_reaction")&&t.emoji){const U=t.emoji_url||((N=(L=r==null?void 0:r.emojis)==null?void 0:L.find)==null?void 0:N.call(L,j=>(j==null?void 0:j.shortcode)===t.emoji.replace(/^:/,"").replace(/:$/,"")));S=S(t.emoji,U)}else _&&(S=S(_))}if(h==="mention"&&!r)return null;const I=t.createdAt&&new Date(t.createdAt).toLocaleString(),x={"favourite+reblog":"Boosted/Liked by…",favourite:"Liked by…",reblog:"Boosted by…",follow:"Followed by…"}[h]||"Accounts",G=()=>{$.showGenericAccounts={heading:x,accounts:p,showReactions:h==="favourite+reblog",excludeRelationshipAttrs:h==="follow"?["followedBy"]:[],postID:Xe(b,n)}};return e("div",{class:`notification notification-${h}`,"data-notification-id":o,tabIndex:"0",children:[e("div",{class:`notification-type notification-${h}`,title:I,children:h==="favourite+reblog"?e(E,{children:[e(v,{icon:"rocket",size:"xl",alt:h,class:"reblog-icon"}),e(v,{icon:"heart",size:"xl",alt:h,class:"favourite-icon"})]}):e(v,{icon:bi[h]||"notification",size:"xl",alt:h})}),e("div",{class:"notification-content",children:[h!=="mention"&&e(E,{children:[e("p",{children:[!/poll|update|severed_relationships/i.test(h)&&e(E,{children:(p==null?void 0:p.length)>1?e(E,{children:[e("b",{tabIndex:"0",onClick:G,children:[e("span",{title:p.length,children:je(p.length)})," ","people"]})," "]}):f&&e(E,{children:[e(_t,{account:f,showAvatar:!0})," "]})}),S,h==="mention"&&e("span",{class:"insignificant",children:[" ","•"," ",e(It,{datetime:t.createdAt,format:"micro"})]})]}),h==="follow_request"&&e($n,{accountID:f.id}),h==="severed_relationships"&&e("div",{children:[$a[a.type]({from:n,...a}),e("br",{}),e("a",{href:`https://${n}/severed_relationships`,target:"_blank",rel:"noopener noreferrer",children:["Learn more ",e(v,{icon:"external",size:"s"})]}),"."]}),h==="moderation_warning"&&!!d&&e("div",{children:[Aa[d.action],e("br",{}),e("a",{href:`/disputes/strikes/${d.id}`,target:"_blank",rel:"noopener noreferrer",children:["Learn more ",e(v,{icon:"external",size:"s"})]}),"."]})]}),(p==null?void 0:p.length)>1&&e("p",{class:"avatars-stack",children:[p.slice(0,vn).map(_=>e(E,{children:[e("a",{href:_.url,rel:"noopener noreferrer",class:"account-avatar-stack",onClick:U=>{U.preventDefault(),$.showAccount=_},children:[e(st,{url:_.avatarStatic,size:p.length<=10?"xxl":p.length<20?"xl":"l",alt:`${_.displayName} @${_.acct}`,squircle:_==null?void 0:_.bot},_.id),h==="favourite+reblog"&&e("div",{class:"account-sub-icons",children:_._types.map(U=>e(v,{icon:bi[U],size:"s",class:`${U}-icon`}))})]},_.id)," "]},_.id)),e("button",{type:"button",class:"small plain",onClick:G,children:[p.length>vn&&`+${p.length-vn}`,e(v,{icon:"chevron-down"})]})]}),(c==null?void 0:c.length)>1&&e("ul",{class:"notification-group-statuses",children:c.map(_=>e("li",{children:e(wi,{class:`status-link status-type-${h}`,to:n?`/${n}/s/${_.id}`:`/s/${_.id}`,children:e(Be,{status:_,size:"s",previewMode:!0,allowContextMenu:!0})})},_.id))}),r&&(!(c!=null&&c.length)||(c==null?void 0:c.length)<=1)&&e(wi,{class:`status-link status-type-${h}`,to:n?`/${n}/s/${b}`:`/s/${b}`,onContextMenu:i?void 0:_=>{const U=_.target.querySelector(".status");if(U){if(_.metaKey)return;_.preventDefault(),U.dispatchEvent(new MouseEvent("contextmenu",{clientX:_.clientX,clientY:_.clientY}))}},children:s?e(Be,{status:l,size:"s",readOnly:!0,allowContextMenu:!0}):e(Be,{statusID:b,size:"s",readOnly:!0,allowContextMenu:!0})})]})]})}function wi(t){const n=Ys();return e(re,{...t,"data-read-more":"Read more →",ref:n})}const mn=Je(Ra,(t,n)=>{var s,i;return((s=t.notification)==null?void 0:s.id)===((i=n.notification)==null?void 0:i.id)});"serviceWorker"in navigator&&navigator.serviceWorker.addEventListener("message",t=>{const{type:n,id:s,accessToken:i}=(t==null?void 0:t.data)||{};n==="notification"&&($.routeNotification={id:s,accessToken:i})});const Ea=Je(function(){if(!("serviceWorker"in navigator))return null;const n=De($),{routeNotification:s}=n,{id:i,accessToken:o}=s||{},[r,f]=A(!1);ut(()=>{if(!i||!o)return;const{instance:a}=ne(),{masto:d,instance:p}=ne({accessToken:o}),c=a===p,h=o?_s(o):Et();(async()=>{const l=await d.v1.notifications.$select(i).fetch();if(l&&h){const b=h.instanceURL,{type:m,status:k,account:g}=l,y=!!document.querySelector("#modal-container > *"),T=m==="follow"&&!!(g!=null&&g.id),w=!!(g!=null&&g.id),S=!!(k!=null&&k.id);T&&c?$.showAccount={account:g,instance:b}:y||!c||w&&S?f({id:i,account:h,notification:l,sameInstance:c}):S?location.hash=`/${a}/s/${k.id}`:T?location.hash=`/${a}/a/${g.id}`:location.hash="/notifications"}})()},[i,o]),ut(()=>{navigator!=null&&navigator.clearAppBadge&&navigator.clearAppBadge()},[]),Lt(a=>{a&&(navigator!=null&&navigator.clearAppBadge)&&navigator.clearAppBadge()});const u=()=>{f(!1),$.routeNotification=null,/\/notifications\?id=/i.test(location.hash)&&(location.hash="/notifications")};if(r){const{id:a,account:d,notification:p,sameInstance:c}=r;return e(Re,{onClick:h=>{h.target===h.currentTarget&&u()},children:e("div",{class:"sheet",tabIndex:"-1",children:[e("button",{type:"button",class:"sheet-close",onClick:u,children:e(v,{icon:"x"})}),e("header",{children:e("b",{children:"Notification"})}),e("main",{children:[!c&&e("p",{children:"This notification is from your other account."}),e("div",{class:"notification-peek",onClick:h=>{const{target:l}=h;(h.target.tagName==="BUTTON"||h.target.tagName==="A")&&u()},children:e(mn,{instance:d.instanceURL,notification:p,isStatic:!0})}),e("div",{style:{textAlign:"end"},children:e(re,{to:"/notifications",class:"button light",onClick:u,children:[e("span",{children:"View all notifications"})," ",e(v,{icon:"arrow-right"})]})})]})]})})}return null}),us=Ms((t,n)=>{const{instance:s}=ne(),[i,o]=ot(),[r,f]=A(!1),[u,a]=A(i.get("q")||""),d=i.get("type"),p=H(null),c=H(null);return Ls(n,()=>({setValue:h=>{a(h)},focus:()=>{c.current.focus()},select:()=>{c.current.select()},blur:()=>{c.current.blur()}})),e("form",{ref:p,class:"search-popover-container",onSubmit:h=>{var b;if(h.preventDefault(),/\/search/.test(location.hash))if(u){const m={q:u};d&&(m.type=d),o(m)}else o({});else u?location.hash=`/search?q=${encodeURIComponent(u)}${d?`&type=${d}`:""}`:location.hash="/search";(b=t==null?void 0:t.onSubmit)==null||b.call(t,h)},children:[e("input",{ref:c,value:u,name:"q",type:"search",placeholder:"Search",dir:"auto",autocomplete:"off",autocorrect:"off",autocapitalize:"off",spellCheck:"false",onSearch:h=>{h.target.value||o({})},onInput:h=>{a(h.target.value),f(!0)},onFocus:()=>{var h,l;f(!0),(l=(h=p.current)==null?void 0:h.querySelector(".search-popover-item"))==null||l.classList.add("focus")},onBlur:()=>{var h,l;setTimeout(()=>{f(!1)},100),(l=(h=p.current)==null?void 0:h.querySelector(".search-popover-item.focus"))==null||l.classList.remove("focus")},onKeyDown:h=>{var b;const{key:l}=h;switch(l){case"Escape":f(!1);break;case"Down":case"ArrowDown":if(h.preventDefault(),r){const m=p.current.querySelector(".search-popover-item.focus");if(m){let k=m.nextElementSibling;for(;k&&k.hidden;)k=k.nextElementSibling;k&&(k.classList.add("focus"),Array.from(k.parentElement.children).filter(y=>y!==k).forEach(y=>{y.classList.remove("focus")}))}else{const k=p.current.querySelector(".search-popover-item");k&&k.classList.add("focus")}}break;case"Up":case"ArrowUp":if(h.preventDefault(),r){const m=document.querySelector(".search-popover-item.focus");if(m){let k=m.previousElementSibling;for(;k&&k.hidden;)k=k.previousElementSibling;k&&(k.classList.add("focus"),Array.from(k.parentElement.children).filter(y=>y!==k).forEach(y=>{y.classList.remove("focus")}))}else{const k=document.querySelector(".search-popover-item:last-child");k&&k.classList.add("focus")}}break;case"Enter":if(r){const m=document.querySelector(".search-popover-item.focus");m&&(h.preventDefault(),m.click()),f(!1),(b=t==null?void 0:t.onSubmit)==null||b.call(t,h)}break}}}),e("div",{class:"search-popover",hidden:!r||!u,children:!!u&&[{label:e(E,{children:[u," ",e("small",{class:"insignificant",children:"‒ accounts, hashtags & posts"})]}),to:`/search?q=${encodeURIComponent(u)}`,top:!d&&!/\s/.test(u),hidden:!!d},{label:e(E,{children:["Posts with ",e("q",{children:u})]}),to:`/search?q=${encodeURIComponent(u)}&type=statuses`,hidden:/^https?:/.test(u),top:/\s/.test(u),icon:"document",queryType:"statuses"},{label:e(E,{children:["Posts tagged with ",e("mark",{children:["#",u.replace(/^#/,"")]})]}),to:`/${s}/t/${u.replace(/^#/,"")}`,hidden:/^@/.test(u)||/^https?:/.test(u)||/\s/.test(u),top:/^#/.test(u),type:"link",icon:"hashtag",queryType:"hashtags"},{label:e(E,{children:["Look up ",e("mark",{children:u})]}),to:`/${u}`,hidden:!/^https?:/.test(u),top:/^https?:/.test(u),type:"link"},{label:e(E,{children:["Accounts with ",e("q",{children:u})]}),to:`/search?q=${encodeURIComponent(u)}&type=accounts`,icon:"group",queryType:"accounts"}].sort((h,l)=>{if(d){if(h.queryType===d)return-1;if(l.queryType===d)return 1}return h.top&&!l.top?-1:!h.top&&l.top?1:0}).filter(({hidden:h})=>!h).map(({label:h,to:l,icon:b,type:m},k)=>e(re,{to:l,class:`search-popover-item ${k===0?"focus":""}`,onClick:g=>{var y;(y=t==null?void 0:t.onSubmit)==null||y.call(t,g)},children:[e(v,{icon:b||(m==="link"?"arrow-right":"search"),class:"more-insignificant"}),e("span",{children:h})," "]}))})]})}),_a=Je(function({onClose:n=()=>{}}){const[s,i]=A(!1),o=H(null);_e(["Slash","/"],f=>{i(!0),setTimeout(()=>{var u,a,d,p;(a=(u=o.current)==null?void 0:u.focus)==null||a.call(u),(p=(d=o.current)==null?void 0:d.select)==null||p.call(d)},0)},{preventDefault:!0,ignoreEventWhen:f=>{const u=/\/search/.test(location.hash),a=!!document.querySelector("#modal-container > *");return u||a}});const r=()=>{i(!1),n()};return _e("esc",f=>{var u,a;(a=(u=o.current)==null?void 0:u.blur)==null||a.call(u),r()},{enabled:s,enableOnFormTags:!0,preventDefault:!0}),e("div",{id:"search-command-container",hidden:!s,onClick:f=>{f.target===f.currentTarget&&r()},children:e(us,{ref:o,onSubmit:()=>{r()}})})});function La(){const{instance:t}=ne(),n=De($),{shortcuts:s,settings:i}=n;if(!s.length||i.shortcutsViewMode==="multi-column"||!i.shortcutsViewMode&&i.shortcutsColumnsMode)return null;const o=H(),r=H(!1),f=s.map((p,c)=>{const{type:h,...l}=p;if(!hn[h])return null;let{id:b,path:m,title:k,subtitle:g,icon:y}=hn[h];return typeof b=="function"&&(b=b(l,c)),typeof m=="function"&&(m=m({...l,instance:l.instance||t},c)),typeof k=="function"&&(k=k(l,c)),typeof g=="function"&&(g=g(l,c)),typeof y=="function"&&(y=y(l,c)),b==="lists"&&(r.current=!0),{id:b,path:m,title:k,subtitle:g,icon:y}}).filter(Boolean),u=Oi();_e(["1","2","3","4","5","6","7","8","9"],(p,c)=>{var l,b;const h=parseInt(c.keys[0],10)-1;if(h{p.preventDefault(),$.showShortcutsSettings=!0},children:e("ul",{children:f.map(({id:p,path:c,title:h,subtitle:l,icon:b},m)=>e("li",{children:e(re,{class:l?"has-subtitle":"",to:c,onClick:k=>{if(k.target.classList.contains("is-active")){k.preventDefault();const g=document.getElementById(`${p}-page`);if(g){g.scrollTop=0;const y=g.querySelector(".updates-button");y&&y.click()}}},children:[e(v,{icon:b,size:"xl",alt:h}),e("span",{children:[e(tn,{children:h}),l&&e(E,{children:[e("br",{}),e("small",{children:l})]})]})]})},`${m}-${p}-${h}-${l}-${c}`))})}):e(Ze,{instanceRef:o,overflow:"auto",viewScroll:"close",menuClassName:"glass-menu shortcuts-menu",gap:8,position:"anchor",onMenuChange:p=>{p.open&&r.current&&Yt().then(d)},menuButton:e("button",{type:"button",id:"shortcuts-button",class:"plain",onContextMenu:p=>{p.preventDefault(),$.showShortcutsSettings=!0},onTransitionStart:p=>{var c,h;try{const{target:l}=p;getComputedStyle(l).pointerEvents==="none"&&((h=(c=o.current)==null?void 0:c.closeMenu)==null||h.call(c))}catch{}},children:e(v,{icon:"shortcut",size:"xl",alt:"Shortcuts"})}),children:f.map(({id:p,path:c,title:h,subtitle:l,icon:b},m)=>p==="lists"?e(cn,{menuClassName:"glass-menu",overflow:"auto",gap:-8,label:e(E,{children:[e(v,{icon:b,size:"l"}),e("span",{class:"menu-grow",children:e(tn,{children:h})}),e(v,{icon:"chevron-right"})]}),children:[e(Ee,{to:"/l",children:e("span",{children:"All Lists"})}),e(ze,{}),a==null?void 0:a.map(k=>e(Ee,{to:`/l/${k.id}`,children:e("span",{children:k.title})},k.id))]}):e(Ee,{to:c,class:"glass-menu-item",children:[e(v,{icon:b,size:"l"})," ",e("span",{class:"menu-grow",children:[e("span",{children:e(tn,{children:h})}),l&&e(E,{children:[" ",e("small",{class:"more-insignificant",children:l})]})]}),e("span",{class:"menu-shortcut hide-until-focus-visible",children:m+1})]},`${m}-${p}-${h}-${l}-${c}`))})})}const Ma=Je(La);function Da(t){var o;let n=[],s=[],i=0;for(let r=0;r10&&(s.length>t.length/4||i>=3)){const r=s.map(f=>f.id);if(s.length>t.length*3/4)n=[...n,{id:r,items:s,type:"boosts"}];else{const f=Math.floor(n.length/2);n=[...n.slice(0,f),{id:r,items:s,type:"boosts"},...n.slice(f)]}return n}else return t}function vi(t,n){const s=we.account.get("boostedStatusIDs")||{},i=t.filter(r=>{if(!r.reblog)return!0;const f=`${n}-${r.reblog.id}`,u=s[f];return u&&u!==r.id?!1:(s[f]=r.id,!0)}),o=Object.keys(s);return o.length>50&&o.slice(0,o.length-50).forEach(r=>{delete s[r]}),we.account.set("boostedStatusIDs",s),i}function Pa(t,n){const s=[];let i=0;t.forEach(u=>{for(let d=0;dp.id===u.id))return;if(s[d].find(p=>p.id===u.inReplyToId)||s[d].find(p=>p.inReplyToId===u.id)){s[d].push(u);return}}const a=t.find(d=>d.id===u.inReplyToId);a&&(s[i++]=[u,a])});for(let u=0;us[a].includes(p))&&(s[u]=[...s[u],...s[a]],s[u]=s[u].filter((p,c,h)=>h.findIndex(l=>l.id===p.id)===c),s.splice(a,1),a--);s.forEach(u=>{u.sort((a,d)=>!a.inReplyToId&&!d.inReplyToId?new Date(a.createdAt)-new Date(d.createdAt):a.inReplyToId===d.id?1:d.inReplyToId===a.id||!a.inReplyToId?-1:d.inReplyToId?new Date(a.createdAt)-new Date(d.createdAt):1)}),s.forEach(u=>{const a=u[0].account.id;u.forEach(d=>{d.account.id!==a&&(d._differentAuthor=!0)})}),s.length;const o=[],r=[],f=[];return t.forEach(u=>{if(u.reblog){o.push(u);return}for(let a=0;ad.id===u.id)){if(r.includes(a))return;const d=s[a];d.sort((c,h)=>{const l=new Date(c.createdAt),b=new Date(h.createdAt);return l-b});const p=d[0].account.id;o.push({id:d.map(c=>c.id),items:d,type:d.every(c=>c.account.id===p)?"thread":"conversation"}),r.push(a);return}if(u.inReplyToId&&u.inReplyToAccountId!==u.account.id){const a=Xe(u.id,n);$.statusReply[a]||f.push({sKey:a,inReplyToId:u.inReplyToId})}o.push(u)}),f!=null&&f.length&&queueMicrotask(()=>{const{masto:u}=ne({instance:n});async function a(){for(let d=0;dsetTimeout(l,1e3))}catch{}}}if(Ge("@mastodon/fetch-multiple-statuses")){const d=f.map(({inReplyToId:p})=>p);(async()=>{var p;try{const c=await u.v1.statuses.list({id:d});if(c!=null&&c.length)for(const h of c){He(h,n,{skipThreading:!0});const l=(p=f.find(({inReplyToId:b})=>b===h.id))==null?void 0:p.sKey;l&&($.statusReply[l]={id:h.id,instance:n})}else a()}catch{a()}})()}else a()}),o}const Na=ft((t,n)=>n.v1.statuses.$select(t).fetch());async function hs(t,n){const s=await wa();if(!s.length)return;const{statusFollowedTags:i}=$,o=[];if(t.forEach(r=>{var h;if(r.reblog)return;const{id:f,content:u,tags:a=[]}=r,d=Xe(f,n);if((h=i[d])!=null&&h.length)return;const p=va(u);if(!p.length&&!a.length)return;const c=s.reduce((l,b)=>((p.some(m=>m.toLowerCase()===b.name.toLowerCase())||a.some(m=>m.name.toLowerCase()===b.name.toLowerCase()))&&l.push(b.name),l),[]);c.length&&o.push({item:r,sKey:d,followedTags:c})}),o.length){const r=o.map(u=>u.item.account),f=await Dn(r);if(!f)return;o.forEach(u=>{const{item:a,sKey:d,followedTags:p}=u,c=f[a.account.id];c&&!c.following&&(i[d]=p)})}}function Ua(){$.statusFollowedTags={}}function Fa({scrollableRef:t,distanceFromStart:n=1,distanceFromEnd:s=1,scrollThresholdStart:i=10,scrollThresholdEnd:o=10,direction:r="vertical",distanceFromStartPx:f,distanceFromEndPx:u}={}){const[a,d]=A(null),[p,c]=A(!1),[h,l]=A(!1),[b,m]=A(!1),[k,g]=A(!1),y=r==="vertical";return ut(()=>{const T=t.current;if(!T)return{};let w=y?T.scrollTop:T.scrollLeft;function S(){const{scrollTop:I,scrollLeft:x,scrollHeight:G,scrollWidth:D,clientHeight:M,clientWidth:ee}=T,J=y?I:x,L=y?G:D,N=y?M:ee,_=Math.abs(J-w),U=f||Math.min(N*n,L,J),j=u||Math.min(N*s,L,L-J-N);_>=(w=L),m(J<=U),g(J+N>=L-j)}return T.addEventListener("scroll",S,{passive:!0}),()=>T.removeEventListener("scroll",S)},[n,s,i,o]),{scrollDirection:a,reachStart:p,reachEnd:h,nearReachStart:b,nearReachEnd:k,init:()=>{t.current&&t.current.dispatchEvent(new Event("scroll"))}}}function Oa({scrollableRef:t,distanceFromStart:n=1,distanceFromEnd:s=1,scrollThresholdStart:i=10,scrollThresholdEnd:o=10,direction:r="vertical",distanceFromStartPx:f,distanceFromEndPx:u,init:a}={},d,p){if(!d)return;const c=r==="vertical",h=H(null),l=H(null),b=Ws(()=>{let m=!1,k=!1,g=!1,y=!1;const T=t.current,{scrollTop:w,scrollLeft:S,scrollHeight:I,scrollWidth:x,clientHeight:G,clientWidth:D}=T,M=c?w:S,ee=c?I:x,J=c?G:D,L=Math.abs(M-h.current),N=f||Math.min(J*n,ee,M),_=u||Math.min(J*s,ee,ee-M-J);L>=(h.current=ee,g=M<=N,y=M+J>=ee-_,d({scrollDirection:l.current,reachStart:m,reachEnd:k,nearReachStart:g,nearReachEnd:y})},500);ut(()=>{const m=t.current;return m?(h.current=m[c?"scrollTop":"scrollLeft"],m.addEventListener("scroll",b,{passive:!0}),()=>m.removeEventListener("scroll",b)):{}},[n,s,i,o,...p]),X(()=>{a&&t.current&&queueMicrotask(()=>{t.current.dispatchEvent(new Event("scroll"))})},[a])}function za({class:t,statusID:n,status:s,instance:i,parent:o,onMediaClick:r}){let f=Xe(n,i);const u=De($);if(s||(s=u.statuses[f]||u.statuses[n],f=Xe(s==null?void 0:s.id,i)),!s)return null;const{account:{acct:a,avatar:d,avatarStatic:p,id:c,url:h,displayName:l,username:b,emojis:m,bot:k,group:g},id:y,repliesCount:T,reblogged:w,reblogsCount:S,favourited:I,favouritesCount:x,bookmarked:G,poll:D,muted:M,sensitive:ee,spoilerText:J,visibility:L,language:N,editedAt:_,filtered:U,card:j,createdAt:ce,inReplyToId:O,inReplyToAccountId:ie,content:V,mentions:de,mediaAttachments:he,reblog:oe,uri:be,url:Ce,emojis:Ie,_deleted:Le,_pinned:Pe}=s;if(!(he!=null&&he.length))return null;const $e=Y=>{Y.shiftKey},Se=ge(()=>dt(),[]),Te=ge(()=>Se&&Se===c,[c,Se]),ve=Ds(ji),te=!Te&&Vt(U,ve);if((te==null?void 0:te.action)==="hide")return null;const me=ee,le=ge(()=>(we.account.get("preferences")||{})["reading:expand:media"]||"default",[])==="show_all",P=o||"div";return he.map((Y,R)=>{const q=`${f}-${Y.id}`,Z=te==null?void 0:te.titlesStr;return e(P,{"data-state-post-id":f,onMouseEnter:$e,"data-spoiler-text":J||(ee?"Sensitive media":void 0),"data-filtered-text":te?`Filtered${Z?`: ${Z}`:""}`:void 0,class:` media-post ${te?"filtered":""} ${me?"has-spoiler":""} ${le?"show-media":""} `,children:e(Gi,{class:t,media:Y,lang:N,to:`/${i}/s/${y}?media-only=${R+1}`,onClick:r?ue=>r(ue,R,Y,s):void 0})},q)})}const ki=Je(za);function Ba(t){var S,I,x,G,D;const n=De($),{masto:s,instance:i,authenticated:o}=ne(),[r,f]=ge(()=>{const M=we.local.getJSON("accounts")||[];return[M.find(J=>J.info.id===dt())||M[0],M.length>1]},[]),u=(n.settings.shortcutsViewMode==="multi-column"||!n.settings.shortcutsViewMode&&n.settings.shortcutsColumnsMode)&&!n.shortcuts.find(M=>M.type==="following"),a=Ks(()=>{$.showAccounts=!0},{threshold:600,detect:"touch",cancelOnMovement:!0}),d=H(),[p,c]=A(void 0),h=Xs([0,0,n.settings.shortcutsViewMode==="tab-menu-bar"?50:0,0]),l=H();async function b(M){return(M||!l.current)&&(l.current=s.v1.mutes.list({limit:80})),await l.current.next()}const m=H();async function k(M){return(M||!m.current)&&(m.current=s.v1.blocks.list({limit:80})),await m.current.next()}const g=Ge("@mastodon/lists"),[y,T]=A([]);X(()=>{g&&p==="open"&&Yt().then(T)},[p==="open"]);const w=H();return e(E,{children:[e("button",{ref:d,type:"button",class:`button plain nav-menu-button ${f?"with-avatar":""} ${p==="open"?"active":""}`,style:{position:"relative"},onClick:()=>{w.current=Date.now(),c(M=>M?void 0:"open")},onContextMenu:M=>{M.preventDefault(),$.showAccounts=!0},...a(),children:[f&&e(st,{url:((S=r==null?void 0:r.info)==null?void 0:S.avatar)||((I=r==null?void 0:r.info)==null?void 0:I.avatarStatic),size:"l",squircle:(x=r==null?void 0:r.info)==null?void 0:x.bot}),e(v,{icon:"menu",size:f?"s":"l"})]}),e(Yi,{menuClassName:"nav-menu",state:p,anchorRef:d,onClose:()=>{c(void 0)},containerProps:{style:{zIndex:10},onClick:()=>{Date.now()-w.current<300}},portal:{target:document.body},...t,overflow:"auto",viewScroll:"close",position:"anchor",align:"center",boundingBoxPadding:h,unmountOnClose:!0,children:[!!((G=n.appVersion)!=null&&G.commitHash)&&n.appVersion.commitHash!=="5e9165b"&&e("div",{class:"top-menu",children:[e(pe,{onClick:()=>{confirm("Reload page now to update?")&&(async()=>{try{location.reload()}catch{}})()},children:[e(v,{icon:"sparkles",class:"sparkle-icon",size:"l"})," ",e("span",{children:"New update available…"})]}),e(ze,{})]}),e("section",{children:[e(Ee,{to:"/",children:[e(v,{icon:"home",size:"l"})," ",e("span",{children:"Home"})]}),o?e(E,{children:[u&&e(Ee,{to:"/following",children:[e(v,{icon:"following",size:"l"})," ",e("span",{children:"Following"})]}),e(Ee,{to:"/catchup",children:[e(v,{icon:"history2",size:"l"}),e("span",{children:"Catch-up"})]}),Ge("@mastodon/mentions")&&e(Ee,{to:"/mentions",children:[e(v,{icon:"at",size:"l"})," ",e("span",{children:"Mentions"})]}),e(Ee,{to:"/notifications",children:[e(v,{icon:"notification",size:"l"})," ",e("span",{children:"Notifications"}),n.notificationsShowNew&&e("sup",{title:"New",style:{opacity:.5},children:[" ","•"]})]}),e(ze,{}),((D=r==null?void 0:r.info)==null?void 0:D.id)&&e(Ee,{to:`/${i}/a/${r.info.id}`,children:[e(v,{icon:"user",size:"l"})," ",e("span",{children:"Profile"})]}),(y==null?void 0:y.length)>0?e(cn,{menuClassName:"nav-submenu",overflow:"auto",gap:-8,label:e(E,{children:[e(v,{icon:"list",size:"l"}),e("span",{class:"menu-grow",children:"Lists"}),e(v,{icon:"chevron-right"})]}),children:[e(Ee,{to:"/l",children:e("span",{children:"All Lists"})}),(y==null?void 0:y.length)>0&&e(E,{children:[e(ze,{}),y.map(M=>e(Ee,{to:`/l/${M.id}`,children:e("span",{children:M.title})},M.id))]})]}):g&&e(Ee,{to:"/l",children:[e(v,{icon:"list",size:"l"}),e("span",{children:"Lists"})]}),e(Ee,{to:"/b",children:[e(v,{icon:"bookmark",size:"l"})," ",e("span",{children:"Bookmarks"})]}),e(cn,{menuClassName:"nav-submenu",overflow:"auto",gap:-8,label:e(E,{children:[e(v,{icon:"more",size:"l"}),e("span",{class:"menu-grow",children:"More…"}),e(v,{icon:"chevron-right"})]}),children:[e(Ee,{to:"/f",children:[e(v,{icon:"heart",size:"l"})," ",e("span",{children:"Likes"})]}),e(Ee,{to:"/fh",children:[e(v,{icon:"hashtag",size:"l"})," ",e("span",{children:"Followed Hashtags"})]}),e(ze,{}),Ge("@mastodon/filters")&&e(Ee,{to:"/ft",children:[e(v,{icon:"filters",size:"l"}),"Filters"]}),e(pe,{onClick:()=>{$.showGenericAccounts={id:"mute",heading:"Muted users",fetchAccounts:b,excludeRelationshipAttrs:["muting"]}},children:[e(v,{icon:"mute",size:"l"})," Muted users…"]}),e(pe,{onClick:()=>{$.showGenericAccounts={id:"block",heading:"Blocked users",fetchAccounts:k,excludeRelationshipAttrs:["blocking"]}},children:[e(v,{icon:"block",size:"l"}),"Blocked users…"]})," "]}),e(ze,{}),e(pe,{onClick:()=>{$.showAccounts=!0},children:[e(v,{icon:"group",size:"l"})," ",e("span",{children:"Accounts…"})]})]}):e(E,{children:[e(ze,{}),e(Ee,{to:"/login",children:[e(v,{icon:"user",size:"l"})," ",e("span",{children:"Log in"})]})]})]}),e("section",{children:[e(ze,{}),e(Ee,{to:"/search",children:[e(v,{icon:"search",size:"l"})," ",e("span",{children:"Search"})]}),e(Ee,{to:`/${i}/trending`,children:[e(v,{icon:"chart",size:"l"})," ",e("span",{children:"Trending"})]}),e(Ee,{to:`/${i}/p/l`,children:[e(v,{icon:"building",size:"l"})," ",e("span",{children:"Local"})]}),e(Ee,{to:`/${i}/p`,children:[e(v,{icon:"earth",size:"l"})," ",e("span",{children:"Federated"})]}),o?e(E,{children:[e(ze,{className:"divider-grow"}),e(pe,{onClick:()=>{$.showKeyboardShortcutsHelp=!0},children:[e(v,{icon:"keyboard",size:"l"})," ",e("span",{children:"Keyboard shortcuts"})]}),e(pe,{onClick:()=>{$.showShortcutsSettings=!0},children:[e(v,{icon:"shortcut",size:"l"})," ",e("span",{children:"Shortcuts / Columns…"})]}),e(pe,{onClick:()=>{$.showSettings=!0},children:[e(v,{icon:"gear",size:"l"})," ",e("span",{children:"Settings…"})]})]}):e(E,{children:[e(ze,{}),e(pe,{onClick:()=>{$.showSettings=!0},children:[e(v,{icon:"gear",size:"l"})," ",e("span",{children:"Settings…"})]})]})]})]})]})}const Tt=Je(Ba),Xt={block:"nearest",inline:"center",behavior:"smooth"};function pt({title:t,titleComponent:n,id:s,instance:i,emptyText:o,errorText:r,useItemID:f,boostsCarousel:u,fetchItems:a=()=>{},checkForUpdates:d=()=>{},checkForUpdatesInterval:p=15e3,headerStart:c,headerEnd:h,timelineStart:l,refresh:b,view:m,filterContext:k,showFollowedTags:g,showReplyParent:y,clearWhenRefresh:T}){const w=De($),[S,I]=A([]),[x,G]=A("start"),[D,M]=A(!1),[ee,J]=A(!1),[L,N]=A(!0),_=H(),U=ge(()=>_n(),[]),j=m!=="media",ce=H(0),O=Zs(te=>{J(!1),G("loading"),(async()=>{try{const me=ce.current=Date.now();let{done:z,value:le}=await a(te);if(me!==ce.current)return;if(Array.isArray(le)){const[P,Y]=le.reduce((R,q)=>(q._pinned?R[0].push(q):R[1].push(q),R),[[],[]]);le=Y,j&&(u&&(le=Da(le)),le=Pa(le,i)),P.length&&(le=P.concat(le)),I(te?le:R=>[...R,...le]),le.length||(z=!0),M(!z)}else M(!1);G("default")}catch{G("error")}finally{O.cancel()}})()},1e3,{leading:!0}),ie=".timeline-item, .timeline-item-alt",V=_e("j, shift+j",(te,me)=>{const z=document.activeElement.closest(ie),le=z==null?void 0:z.getBoundingClientRect(),P=Array.from(_.current.querySelectorAll(ie));if(z&&le.top<_.current.clientHeight&&le.bottom>0){const Y=P.indexOf(z);let R=P[Y+1];me.shift&&(R=P.find((q,Z)=>Z>Y&&!q.classList.contains("timeline-item-alt"))),R&&(R.focus(),R.scrollIntoView(Xt))}else{const Y=P.find(R=>{const q=R.getBoundingClientRect();return q.top>=44&&q.left>=0});Y&&(Y.focus(),Y.scrollIntoView(Xt))}}),de=_e("k, shift+k",(te,me)=>{const z=document.activeElement.closest(ie),le=z==null?void 0:z.getBoundingClientRect(),P=Array.from(_.current.querySelectorAll(ie));if(z&&le.top<_.current.clientHeight&&le.bottom>0){const Y=P.indexOf(z);let R=P[Y-1];me.shift&&(R=P.findLast((q,Z)=>Z{const q=R.getBoundingClientRect();return q.top>=44&&q.left>=0});Y&&(Y.focus(),Y.scrollIntoView(Xt))}}),he=_e(["enter","o"],()=>{const te=document.activeElement;te!=null&&te.matches(ie)&&te.click()}),oe=S.length>0&&x!=="loading"&&ee,be=et(()=>{var te;oe&&O(!0),(te=_.current)==null||te.scrollTo({top:0,behavior:"smooth"})},[O,oe]),Ce=_e(".",be),Ie=H(),[Le,Pe]=A(!1);Oa({scrollableRef:_,distanceFromEnd:2,scrollThresholdStart:44},({scrollDirection:te,nearReachStart:me,reachStart:z})=>{if(Ie.current){const le=te==="end"&&!me;Ie.current.hidden=le}Pe(me),z&&O(!0)},[]),X(()=>{var te;(te=_.current)==null||te.scrollTo({top:0}),O(!0)},[]);const $e=H(!0);X(()=>{var te;if($e.current){$e.current=!1;return}T&&(S!=null&&S.length)&&((te=O.cancel)==null||te.call(O),I([])),O(!0)},[T,b]);const Se=H(m);X(()=>{Se.current!==m&&(Se.current=m,I([]))},[m]);const Te=et(async({disableIdleCheck:te=!1}={})=>{const me=_.current?getComputedStyle(_.current).pointerEvents==="none":!1;w.settings.autoRefresh&&_.current.scrollTop<16&&(te||window.__IDLE__)&&!Ga()&&!me?O(!0):await d()&&J(!0)},[s,O,d,w.settings.autoRefresh]),ve=H();return Lt(te=>{if(te){const me=Date.now()-ve.current;(!ve.current||me>1e3*3)&&Te({disableIdleCheck:!0})}else ve.current=Date.now();N(te)},[d,Te,w.settings.autoRefresh]),Mn(Te,L&&!ee?p*(Le?1:2):null),e(ji.Provider,{value:k,children:e("div",{id:`${s}-page`,class:`deck-container ${U?"deck-container-media-first":""}`,ref:te=>{_.current=te,V.current=te,de.current=te,he.current=te,Ce.current=te},tabIndex:"-1",children:e("div",{class:"timeline-deck deck",children:[e("header",{ref:Ie,onClick:te=>{var me;te.target.closest("a, button")||(me=_.current)==null||me.scrollTo({top:0,behavior:"smooth"})},onDblClick:te=>{te.target.closest("a, button")||O(!0)},class:x==="loading"?"loading":"",children:[e("div",{class:"header-grid",children:[e("div",{class:"header-side",children:[e(Tt,{}),c??e(re,{to:"/",class:"button plain home-button",children:e(v,{icon:"home",size:"l"})})]}),t&&(n||e("h1",{children:t})),e("div",{class:"header-side",children:!!h&&h})]}),oe&&e("button",{class:"updates-button shiny-pill",type:"button",onClick:be,children:[e(v,{icon:"arrow-up"})," New posts"]})]}),!!l&&e("div",{class:`timeline-start ${x==="loading"?"loading":""}`,children:l}),S.length?e(E,{children:[e("ul",{class:`timeline ${m?`timeline-${m}`:""}`,children:[S.map(te=>e(Ha,{status:te,instance:i,useItemID:f,filterContext:k,view:m,showFollowedTags:g,showReplyParent:y,mediaFirst:U},te.id+(te==null?void 0:te._pinned)+m)),D&&x==="loading"&&(m==="media"?null:e(E,{children:[e("li",{style:{height:"20vh"},children:e(Be,{skeleton:!0,mediaFirst:U})}),e("li",{style:{height:"25vh"},children:e(Be,{skeleton:!0,mediaFirst:U})})]}))]}),x==="default"&&(D?e(ht,{root:_.current,rootMargin:`0px 0px ${screen.height*1.5}px 0px`,onChange:te=>{te&&O()},children:e("button",{type:"button",class:"plain block",onClick:()=>O(),style:{marginBlockEnd:"6em"},children:"Show more…"})}):e("p",{class:"ui-state insignificant",children:"The end."}))]}):x==="loading"?e("ul",{class:"timeline",children:Array.from({length:5}).map((te,me)=>m==="media"?e("div",{style:{height:"50vh"}}):e("li",{children:e(Be,{skeleton:!0,mediaFirst:U})},me))}):x!=="error"&&x!=="start"&&e("p",{class:"ui-state",children:o}),x==="error"&&e("p",{class:"ui-state",children:[r,e("br",{}),e("br",{}),e("button",{type:"button",onClick:()=>O(!S.length),children:"Try again"})]})]})})})}const Ha=Je(({status:t,instance:n,useItemID:s,filterContext:i,view:o,showFollowedTags:r,showReplyParent:f,mediaFirst:u})=>{const{id:a,reblog:d,items:p,type:c,_pinned:h}=t;h&&(s=!1);const l=(d==null?void 0:d.id)||a,b=n?`/${n}/s/${l}`:`/s/${l}`;if(p){const k=wt(p,i);let g="";if(c==="boosts"?g=`${k.length} Boosts`:c==="pinned"&&(g="Pinned posts"),c==="boosts"||c==="pinned")return k.sort((w,S)=>{const I=Vt(w.filtered,i),x=Vt(S.filtered,i);return I&&!x?1:!I&&x?-1:0}),e("li",{class:"timeline-item-carousel",children:e(qa,{title:g,class:`${c}-carousel`,children:k.map(w=>{const{id:S,reblog:I,_pinned:x}=w,G=(I==null?void 0:I.id)||S,D=n?`/${n}/s/${G}`:`/s/${G}`;return x&&(s=!1),e("li",{children:e(re,{class:"status-carousel-link timeline-item-alt",to:D,children:s?e(Be,{statusID:S,instance:n,size:"s",contentTextWeight:!0,enableCommentHint:!0,mediaFirst:u}):e(Be,{status:w,instance:n,size:"s",contentTextWeight:!0,enableCommentHint:!0,mediaFirst:u})})},S)})})},`timeline-${a}`);const T=k.length>3;return k.map((w,S)=>{const{id:I,_differentAuthor:x}=w,G=n?`/${n}/s/${I}`:`/s/${I}`,D=S>0&&S0||T&&D&&(c==="thread"||c==="conversation"&&!x&&!k[S-1]._differentAuthor&&!k[S+1]._differentAuthor),J=S===0,L=S===k.length-1;return e("li",{class:`timeline-item-container timeline-item-container-type-${c} timeline-item-container-${J?"start":L?"end":"middle"} ${x?"timeline-item-diff-author":""}`,children:e(re,{class:"status-link timeline-item",to:G,children:ee?e(Va,{status:w,instance:n,filterContext:i}):s?e(Be,{statusID:I,instance:n,enableCommentHint:L,showFollowedTags:r}):e(Be,{status:w,instance:n,enableCommentHint:L,showFollowedTags:r})})},`timeline-${I}`)})}const m=`timeline-${a+h}`;return o==="media"?s?e(ki,{class:"timeline-item",parent:"li",statusID:a,instance:n},m):e(ki,{class:"timeline-item",parent:"li",status:t,instance:n},m):e("li",{children:e(re,{class:"status-link timeline-item",to:b,children:s?e(Be,{statusID:a,instance:n,enableCommentHint:!0,showFollowedTags:r,showReplyParent:f,mediaFirst:u}):e(Be,{status:t,instance:n,enableCommentHint:!0,showFollowedTags:r,showReplyParent:f,mediaFirst:u})})},m)},(t,n)=>{var o,r;const s=(((o=t.status)==null?void 0:o.id)||"").toString(),i=(((r=n.status)==null?void 0:r.id)||"").toString();return s===i&&t.instance===n.instance&&t.view===n.view});function qa({title:t,class:n,children:s}){const i=H(),o=H(),r=H(),[f,u]=A(!1);return X(()=>{setTimeout(()=>{u(!0)},1)},[]),e("div",{class:`status-carousel ${n}`,children:[e("header",{children:[e("h3",{children:t}),e("span",{children:[e("button",{ref:o,type:"button",class:"small plain2",onClick:()=>{var a,d;(d=i.current)==null||d.scrollBy({left:-Math.min(320,(a=i.current)==null?void 0:a.offsetWidth),behavior:"smooth"})},children:e(v,{icon:"chevron-left"})})," ",e("button",{ref:r,type:"button",class:"small plain2",onClick:()=>{var a,d;(d=i.current)==null||d.scrollBy({left:Math.min(320,(a=i.current)==null?void 0:a.offsetWidth),behavior:"smooth"})},children:e(v,{icon:"chevron-right"})})]})]}),e("ul",{ref:i,children:[e(ht,{class:"status-carousel-beacon",onChange:a=>{o.current&&(o.current.disabled=a)}}),s[0],f&&s.slice(1),e(ht,{class:"status-carousel-beacon",onChange:a=>{r.current&&(r.current.disabled=a)}})]})]})}function Va({status:t,instance:n,filterContext:s}){const i=De($),{id:o,visibility:r,language:f}=t,u=Nn(t),a=Xe(o,n),d=Vt(t.filtered,s);return e("article",{class:`status compact-thread ${r==="direct"?"visibility-direct":""}`,tabindex:"-1",children:[i.statusThreadNumber[a]?e("div",{class:"status-thread-badge",children:[e(v,{icon:"thread",size:"s"}),i.statusThreadNumber[a]?` ${i.statusThreadNumber[a]}/X`:""]}):e("div",{class:"status-thread-badge",children:e(v,{icon:"thread",size:"s"})}),e("div",{class:"content-compact",title:u,lang:f,dir:"auto",children:d?e("b",{class:"status-filtered-badge badge-meta horizontal",title:(d==null?void 0:d.titlesStr)||"",children:[e("span",{children:"Filtered"}),": ",e("span",{children:(d==null?void 0:d.titlesStr)||""})]}):e(E,{children:[u,t.sensitive&&t.spoilerText&&e(E,{children:[" ",e("span",{class:"spoiler-badge",children:e(v,{icon:"eye-close",size:"s"})})]})]})})]})}function Ga(){return!!document.querySelector(".deck-backdrop, #modal-container > *")}const At=20,Wn=1983,Si=`${Wn}-01`,ja=(()=>{try{const t=document.createElement("input");return t.setAttribute("type","month"),t.type==="month"}catch{return!1}})();async function Ya(t){var i;const{masto:n}=ne({instance:t}),s=await n.v2.search.fetch({q:"from:me",type:"statuses",limit:1});return!!((i=s==null?void 0:s.statuses)!=null&&i.length)}const Wa=ft(Ya);function Ka(){const t=De($),{id:n,...s}=St(),[i,o]=ot(),r=i.get("month"),f=!i.get("replies"),u=!!i.get("boosts"),a=i.get("tagged"),d=!!i.get("media"),{masto:p,instance:c,authenticated:h}=ne({instance:s.instance}),{masto:l,instance:b}=ne(),m=H(),k=[r,f,u,a,d],[g,y]=A(),T=H(0);X(()=>{T.current=0},k);const w=ge(()=>_n(),[]),S=ge(()=>c===b,[c,b]),[I,x]=A(!1);X(()=>{S&&g!=null&&g.acct&&(async()=>{const V=await Wa(c);x(V)})()},[c,S,g==null?void 0:g.acct]);async function G(V){var Ie,Le,Pe,$e;const de=/^\d{4}-[01]\d$/.test(r),he=((Le=(Ie=r==null?void 0:r.split)==null?void 0:Ie.call(r,"-"))==null?void 0:Le[0])>=Wn;if(de&&he){if(!g)return{value:[],done:!0};const[Se,Te]=r.split("-"),ve=parseInt(Te,10)-1,te=new Date(Se,ve,0),me=`${te.getFullYear()}-${(te.getMonth()+1).toString().padStart(2,"0")}-${te.getDate().toString().padStart(2,"0")}`,z=new Date(Se,ve+1,1),le=`${z.getFullYear()}-${(z.getMonth()+1).toString().padStart(2,"0")}-${z.getDate().toString().padStart(2,"0")}`;let P;V?(P=At+1,T.current=0):(P=At+T.current+1,T.current+=At);const Y=await p.v2.search.fetch({q:`from:${g.acct} after:${me} before:${le}`,type:"statuses",limit:P,offset:T.current});if((Pe=Y==null?void 0:Y.statuses)!=null&&Pe.length){const R=Y.statuses.slice(0,At);R.forEach(Z=>{He(Z,c)});const q=Y.statuses.length<=At;return{value:R,done:q}}else return{value:[],done:!0}}let oe=[];if(V){const{value:Se}=await p.v1.accounts.$select(n).statuses.list({pinned:!0}).next();if(Se!=null&&Se.length&&!a&&!d){const Te=Se.map(ve=>(He(ve,c),{...ve,_pinned:!0}));if(Te.length>=3){const ve=Te.map(te=>te.id);oe.push({id:ve,items:Te,type:"pinned"})}else oe.push(...Te)}}(V||!m.current)&&(m.current=p.v1.accounts.$select(n).statuses.list({limit:At,exclude_replies:f,exclude_reblogs:u,only_media:d||void 0,tagged:a}));const{value:be,done:Ce}=await m.current.next();if(be!=null&&be.length){if(oe.length){let Se=[];(($e=oe[0])==null?void 0:$e.type)==="pinned"?Se=oe[0].id:Se=oe.filter(ve=>ve._pinned).map(ve=>ve.id),Se.every(ve=>be.some(te=>te.id===ve))&&(oe=[])}oe.push(...be),be.forEach(Se=>{He(Se,c)})}return{value:oe,done:Ce}}const[D,M]=A([]);qe(g!=null&&g.acct?`${g!=null&&g.displayName?`${g.displayName} (${/@/.test(g.acct)?"":"@"}${g.acct})`:`${/@/.test(g.acct)?"":"@"}${g.acct}`}${f?u?" (- Boosts)":a?` (#${a})`:d?" (Media)":r?` (${new Date(r).toLocaleString("default",{month:"long",year:"numeric"})})`:"":" (+ Replies)"}`:"Account posts","/:instance?/a/:id");const ee=H(),J=et(()=>{const V=ee.current||p.v1.accounts.$select(n).fetch();return ee.current=V,V},[n,p]);X(()=>{(async()=>{try{const V=await J();y(V)}catch{}if(!w)try{const V=await p.v1.accounts.$select(n).featuredTags.list();M(V)}catch{}})()},[n,w]);const{displayName:L,acct:N,emojis:_}=g||{},U=H(),j=ge(()=>{const V=!f||u||a||d||!!r,de=t.accounts[`${n}@${c}`];return e(E,{children:[e(cs,{instance:c,account:de||n,fetchAccount:J,authenticated:h,standalone:!0}),!w&&e("div",{class:"filter-bar",ref:U,style:{position:"relative"},children:[V?e(re,{to:`/${c}/a/${n}`,class:"insignificant filter-clear",title:"Clear filters",children:e(v,{icon:"x",size:"l"})},"clear-filters"):e(v,{icon:"filter",class:"insignificant",size:"l"}),e(re,{to:`/${c}/a/${n}${f?"?replies=1":""}`,onClick:()=>{f&&se("Showing post with replies")},class:f?"":"is-active",children:"+ Replies"}),e(re,{to:`/${c}/a/${n}${u?"":"?boosts=0"}`,onClick:()=>{u||se("Showing posts without boosts")},class:u?"is-active":"",children:"- Boosts"}),e(re,{to:`/${c}/a/${n}${d?"":"?media=1"}`,onClick:()=>{d||se("Showing posts with media")},class:d?"is-active":"",children:"Media"}),D.map(he=>e(re,{to:`/${c}/a/${n}${a===he.name?"":`?tagged=${encodeURIComponent(he.name)}`}`,onClick:()=>{a!==he.name&&se(`Showing posts tagged with #${he.name}`)},class:a===he.name?"is-active":"",children:e("span",{children:[e("span",{class:"more-insignificant",children:"#"}),he.name]})},he.id)),I&&(ja?e("label",{class:`filter-field ${r?"is-active":""}`,children:[e(v,{icon:"month",size:"l"}),e("input",{type:"month",disabled:!(g!=null&&g.acct),value:r||"",min:Si,max:new Date().toISOString().slice(0,7),onInput:he=>{const{value:oe,validity:be}=he.currentTarget;if(!be.valid)return;o(oe?{month:oe}:{});const[Ce,Ie]=oe.split("-"),Le=parseInt(Ie,10)-1,Pe=new Date(Ce,Le);se(`Showing posts in ${Pe.toLocaleString("default",{month:"long",year:"numeric"})}`)}})]}):e(Xa,{class:`filter-field ${r?"is-active":""}`,disabled:!(g!=null&&g.acct),value:r||"",min:Si,max:new Date().toISOString().slice(0,7),onInput:he=>{const{value:oe,validity:be}=he;be.valid&&o(oe?{month:oe}:{})}}))]})]})},[n,c,h,D,J,I,...k]);X(()=>{var de;const V=(de=U.current)==null?void 0:de.querySelector(".is-active");V&&U.current.scrollTo({behavior:"smooth",left:V.offsetLeft-(U.current.offsetWidth-V.offsetWidth)/2})},[D,I,...k]);const ce=ge(()=>g!=null&&g.url?URL.parse(g.url).hostname:null,[g]),ie=!!g&&!(c===ce);return e(pt,{title:`${g!=null&&g.acct?"@"+g.acct:"Posts"}`,titleComponent:e("h1",{class:"header-double-lines header-account",children:[e("b",{children:e(qi,{text:L,emojis:_})}),e("div",{children:e("span",{children:["@",N]})})]}),id:"account-statuses",instance:c,emptyText:"Nothing to see here yet.",errorText:"Unable to load posts",fetchItems:G,useItemID:!0,view:d||w?"media":void 0,boostsCarousel:t.settings.boostsCarousel,timelineStart:j,refresh:[f,u,a,d,r+(g==null?void 0:g.acct)].toString(),headerEnd:e(Ze,{portal:!0,overflow:"auto",viewScroll:"close",position:"anchor",menuButton:e("button",{type:"button",class:"plain",children:e(v,{icon:"more",size:"l"})}),children:[e(pe,{disabled:!ie,onClick:()=>{(async()=>{try{const{masto:V}=ne({instance:ce}),de=await V.v1.accounts.lookup({acct:g.acct}),{id:he}=de;location.hash=`/${ce}/a/${he}`}catch{alert("Unable to fetch account info")}})()},children:[e(v,{icon:"transfer"})," ",e("small",{class:"menu-double-lines",children:["Switch to account's instance"," ",ce?e(E,{children:[" ","(",e("b",{children:Ut.toUnicode(ce)}),")"]}):null]})]}),!S&&e(pe,{onClick:()=>{(async()=>{try{const V=await l.v1.accounts.lookup({acct:g.acct+"@"+c}),{id:de}=V;location.hash=`/${b}/a/${de}`}catch{alert("Unable to fetch account info")}})()},children:[e(v,{icon:"transfer"})," ",e("small",{class:"menu-double-lines",children:["Switch to my instance (",e("b",{children:b}),")"]})]})]})},n)}function Xa(t){const{class:n,disabled:s,value:i,min:o,max:r,onInput:f=()=>{}}=t,[u,a]=(i==null?void 0:i.split("-"))||[],d=H(),p=H(),c=(h,l)=>{const[b,m]=(o==null?void 0:o.split("-"))||[],[k,g]=(r==null?void 0:r.split("-"))||[];return!(lk||l===b&&hg)};return e("div",{class:n,children:[e(v,{icon:"month",size:"l"}),e("select",{ref:d,disabled:s,value:a||"",onInput:h=>{const{value:l}=h.currentTarget,b=p.current.value;if(!c(l,b))return{value:"",validity:{valid:!1}};f({value:l?`${b}-${l}`:"",validity:{valid:!0}})},children:[e("option",{value:"",children:"Month"}),e("option",{disabled:!0,children:"-----"}),Array.from({length:12},(h,l)=>e("option",{value:(l+1).toString().padStart(2,"0"),children:new Date(0,l).toLocaleString("default",{month:"long"})},l))]})," ",e("input",{ref:p,type:"number",disabled:s,value:u||new Date().getFullYear(),min:(o==null?void 0:o.slice(0,4))||Wn,max:(r==null?void 0:r.slice(0,4))||new Date().getFullYear(),onInput:h=>{const{value:l,validity:b}=h.currentTarget,m=d.current.value;if(!b.valid||!c(m,l))return{value:"",validity:{valid:!1}};f({value:l?`${l}-${m}`:"",validity:{valid:!0}})},style:{width:"4.5em"}})]})}const Za=20;function fs(){qe("Bookmarks","/b");const{masto:t,instance:n}=ne(),s=H();async function i(o){return(o||!s.current)&&(s.current=t.v1.bookmarks.list({limit:Za})),await s.current.next()}return e(pt,{title:"Bookmarks",id:"bookmarks",emptyText:"No bookmarks yet. Go bookmark something!",errorText:"Unable to load bookmarks",instance:n,fetchItems:i})}const Ja=""+new URL("catch-up-DuauQu-W.png",import.meta.url).href,Qa="home",Ke=[{label:"last 1 hour",value:1},{label:"last 2 hours",value:2},{label:"last 3 hours",value:3},{label:"last 4 hours",value:4},{label:"last 5 hours",value:5},{label:"last 6 hours",value:6},{label:"last 7 hours",value:7},{label:"last 8 hours",value:8},{label:"last 9 hours",value:9},{label:"last 10 hours",value:10},{label:"last 11 hours",value:11},{label:"last 12 hours",value:12},{label:"beyond 12 hours",value:13}],er=["Original","Replies","Boosts","Followed tags","Groups","Filtered"],tr=["createdAt","repliesCount","favouritesCount","reblogsCount","density"],nr=[null,"account"],Ii={Filtered:"filtered",Groups:"group",Boosts:"boost",Replies:"reply","Followed tags":"followedTags",Original:"original"},ir={Filtered:"filtered posts",Groups:"group posts",Boosts:"boosts",Replies:"replies","Followed tags":"followed-tag posts",Original:"original posts"},sr={createdAt:["oldest","latest"],repliesCount:["fewest replies","most replies"],favouritesCount:["fewest likes","most likes"],reblogsCount:["fewest boosts","most boosts"],density:["least dense","most dense"]};function or(){qe("Catch-up","/catchup");const{masto:t,instance:n}=ne(),[s,i]=ot(),o=s.get("id"),[r,f]=A("start"),[u,a]=A(!1),d=ge(()=>dt(),[]),p=C=>C===d,c=Ge("@pixelfed/home-include-reblogs");async function h({maxCreatedAt:C}){var Q,ye,fe;const F=C?new Date(C):null,W=[],B=t.v1.timelines.home.list({limit:40});e:for(;;)try{c&&B.nextParams&&(typeof B.nextParams=="string"?B.nextParams+="&include_reblogs=true":B.nextParams.include_reblogs=!0);const ae=await B.next(),{value:xe}=ae;if(xe!=null&&xe.length){await hs(xe,n);let Ue=!1;for(let Oe=0;Oe=F){const ke=!p(((ye=(Q=Me.reblog)==null?void 0:Q.account)==null?void 0:ye.id)||Me.account.id)&&Vt(((fe=Me.reblog)==null?void 0:fe.filtered)||Me.filtered,Qa);if((ke==null?void 0:ke.action)==="hide")continue;Me._filtered=ke;const nt=Xe(Me.id,n);Me._followedTags=$.statusFollowedTags[nt]?[...$.statusFollowedTags[nt]]:[],W.push(Me),Ue=!0}if(!Ue)break e}}else break e;await new Promise(Ue=>setTimeout(Ue,1e3))}catch{break e}return W.forEach(ae=>{if(ae!=null&&ae.inReplyToId){const xe=W.find(Ue=>Ue.id===ae.inReplyToId);xe&&!xe.inReplyToId&&(xe._thread=!0)}}),W}const[l,b]=A([]),m=H(),k=H(),g=ge(()=>rn(),[]),y=et(async({duration:C}={})=>{const F=Date.now(),W=C?F-C:null;f("loading");const B=await h({maxCreatedAt:W}),Q=`${g}-${Js()}`;try{await it.catchup.set(Q,{id:Q,posts:B,count:B.length,startAt:W,endAt:F}),i({id:Q})}catch{}},[]);X(()=>{o?(async()=>{const C=await it.catchup.get(o);C&&(C.posts.sort((F,W)=>F.createdAt>W.createdAt?1:-1),b(C.posts),f("results"))})():r==="results"&&(b([]),f("start"))},[o]);const[T,w]=kt(C=>C+1,0),[S,I]=A(null),[x,G]=A([]);X(()=>{(async()=>{try{const C=await it.catchup.keys();if(C.length){const F=rn(),W=C.filter(B=>B.startsWith(`${F}-`));if(W.length){let B=await it.catchup.getMany(W);B.sort((ae,xe)=>xe.endAt-ae.endAt);let Q=B.slice(0,3),ye=B.slice(3);const fe=Q.map(ae=>{const{id:xe,count:Ue,startAt:Oe,endAt:Me}=ae;return{id:xe,count:Ue,startAt:Oe,endAt:Me}});G(fe),I(Q[0].endAt),B=null,Q=null,queueMicrotask(()=>{ye.length&&it.catchup.delMany(ye.map(ae=>ae.id)).then(()=>{ye=null}).catch(ae=>{})});return}}}catch{}G([])})()},[T]),X(()=>{r==="start"&&w()},[r==="start"]);const[D,M]=ge(()=>{var xe,Ue,Oe,Me,Ve;let C=0,F=0,W=0,B=0,Q=0,ye=0;const fe={};for(const K of l){K._filtered?(C++,K.__FILTER="filtered"):K.group?(F++,K.__FILTER="group"):K.reblog?(W++,K.__FILTER="boost"):(xe=K._followedTags)!=null&&xe.length?(Q++,K.__FILTER="followedTags"):K.inReplyToId&&K.inReplyToAccountId!==((Ue=K.account)==null?void 0:Ue.id)?(B++,K.__FILTER="reply"):(ye++,K.__FILTER="original");const ke=K.reblog||K;if(K.__FILTER!=="filtered"&&((Oe=ke.card)!=null&&Oe.url)&&((Me=ke.card)!=null&&Me.image)&&((Ve=ke.card)==null?void 0:Ve.type)==="link"){const{card:nt,favouritesCount:Wt,reblogsCount:bt}=ke;let{url:Ye}=nt;if(Ye=Ye.replace(/\/$/,""),!fe[Ye])fe[Ye]={postID:ke.id,card:nt,shared:1,sharers:[K.account],likes:Wt,boosts:bt};else{if(fe[Ye].sharers.find(xt=>xt.id===K.account.id))continue;fe[Ye].shared++,fe[Ye].sharers.push(K.account),fe[Ye].postID!==ke.id&&(fe[Ye].likes+=Wt,fe[Ye].boosts+=bt)}}}let ae=[];for(const K in fe)ae.push({url:K,...fe[K]});if(ae.sort((K,ke)=>K.shared>ke.shared?-1:K.sharedke.boosts?-1:K.boostske.likes?-1:K.likes10)e:for(let K=10;K{const C={},F=new Map;let W=l.filter(Q=>{const ye=ee==="All"||Q.__FILTER===Ii[ee];return ye&&(C[Q.account.id]=Q.account,F.set(Q.account.id,(F.get(Q.account.id)||0)+1)),ye});const B={};return W.forEach(Q=>{Q.reblog&&(B[Q.reblog.id]?(B[Q.reblog.id].__BOOSTERS?B[Q.reblog.id].__BOOSTERS.add(Q.account):B[Q.reblog.id].__BOOSTERS=new Set([Q.account]),Q.__HIDDEN=!0):B[Q.reblog.id]=Q)}),L&&F.has(L)&&(W=W.filter(Q=>Q.account.id===L||[...Q.__BOOSTERS||[]].find(ye=>ye.id===L))),[W,C,Object.fromEntries(F)]},[ee,L,l]),Ce=ge(()=>{const C={};return he.forEach(F=>{C[F.id]=F}),C},[he]),Ie=ge(()=>Object.keys(be).sort((C,F)=>be[F]-be[C]),[be]),Le=ge(()=>{const C={};return Ie.forEach((F,W)=>{C[F]=W}),he.filter(F=>!F.__HIDDEN).sort((F,W)=>{if(V==="account"){const B=F.account.id,Q=W.account.id,ye=C[B],fe=C[Q],ae=ye-fe;if(ae!==0)return ae}if(j!=="createdAt"&&(F=F.reblog||F,W=W.reblog||W,j!=="density"&&F[j]===W[j]))return F.createdAt>W.createdAt?1:-1;if(j==="density"){const B=Ci(F),Q=Ci(W);return O==="asc"?B>Q?1:-1:Q>B?1:-1}return O==="asc"?F[j]>W[j]?1:-1:W[j]>F[j]?1:-1})},[he,j,O,V,Ie]),Pe=H(null),$e=H(null),Se=H(!1);X(()=>{l.length>100||Se.current||$e.current&&(ns($e.current,{duration:200}),Se.current=!0)},[l,$e]);const Te=l.length>160?"3d":"2d",ve=ge(()=>Te!=="2d"?null:l.map(C=>{const F=Ce[C.id];return e("span",{class:`post-dot ${F?"post-dot-highlight":""}`},C.id)}),[Ce]),te=ge(()=>Te!=="3d"||!(l!=null&&l.length)?null:fr(l,"createdAt",320).map((F,W)=>e("div",{class:"posts-bin",children:F.map(B=>{const Q=Ce[B.id];return e("span",{class:`post-dot ${Q?"post-dot-highlight":""}`},B.id)})},W)),[Ce]),me=H(null),z=ge(()=>S?(Date.now()-S)/1e3/60/60:null,[S,_]);X(()=>{if(r!=="results")return;const C=L&&oe[L]?oe[L].username:"",F=O==="asc"?0:1,W={account:"authors"};let B=se({duration:5e3,text:`Showing ${ir[ee]||"all posts"}${C?` by @${C}`:""}, ${sr[j][F]} first${V?`, grouped by ${V==="account"?W[V]:""}`:""}`});return()=>{var Q;(Q=B==null?void 0:B.hideToast)==null||Q.call(B)}},[r,ee,L,j,O,V,oe]),X(()=>{var C;if(L&&oe[L]){const F=$e.current.querySelector(`[data-author="${L}"]`),W=(C=$e.current)==null?void 0:C.getBoundingClientRect(),B=F==null?void 0:F.getBoundingClientRect();B.leftW.right?F.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"}):B.top<0&&F.scrollIntoView({block:"nearest",inline:"nearest",behavior:"smooth"})}},[L,oe]);const[le,P]=A(!1),Y=".catchup-list > li > a",R=_e("j",()=>{const C=document.activeElement.closest(Y),F=C==null?void 0:C.getBoundingClientRect(),W=Array.from(me.current.querySelectorAll(Y));if(C&&F.top0){const B=W.indexOf(C),Q=W[B+1];Q&&(Q.focus(),Q.scrollIntoView({block:"center",inline:"center",behavior:"smooth"}))}else{const B=W.find(Q=>Q.getBoundingClientRect().top>=0);B&&(B.focus(),B.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"}))}},{preventDefault:!0,ignoreModifiers:!0}),q=_e("k",()=>{const C=document.activeElement.closest(Y),F=C==null?void 0:C.getBoundingClientRect(),W=Array.from(me.current.querySelectorAll(Y));if(C&&F.top0){const B=W.indexOf(C);let Q=W[B-1];Q&&(Q.focus(),Q.scrollIntoView({block:"center",inline:"center",behavior:"smooth"}))}else{const B=W.find(Q=>{const ye=Q.getBoundingClientRect();return ye.top>=44&&ye.left>=0});B&&(B.focus(),B.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"}))}},{preventDefault:!0,ignoreModifiers:!0}),Z=_e("h, l",(C,F)=>{var B,Q,ye;const W=F.keys[0];if(L){const fe=Ie.indexOf(L);W==="h"?fe>0&&fe=0&&(N(Ie[fe+1]),(Q=me.current)==null||Q.focus())}else W==="l"&&(N(Ie[0]),(ye=me.current)==null||ye.focus())},{preventDefault:!0,ignoreModifiers:!0,enableOnFormTags:["input"]}),ue=_e("esc",()=>{var C;N(null),(C=me.current)==null||C.focus()},{preventDefault:!0,ignoreModifiers:!0,enableOnFormTags:["input"]}),Ne=_e(".",()=>{var C;(C=me.current)==null||C.scrollTo({top:0,behavior:"smooth"})},{preventDefault:!0,ignoreModifiers:!0,enableOnFormTags:["input"]});return e("div",{ref:C=>{me.current=C,R.current=C,q.current=C,Z.current=C,ue.current=C},id:"catchup-page",class:"deck-container",tabIndex:"-1",children:[e("div",{class:"timeline-deck deck wide",children:[e("header",{class:`${r==="loading"?"loading":""}`,onClick:C=>{var F;C.target.closest("a, button")||(F=me.current)==null||F.scrollTo({top:0,behavior:"smooth"})},children:e("div",{class:"header-grid",children:[e("div",{class:"header-side",children:[e(Tt,{}),r==="results"&&e(re,{to:"/catchup",class:"button plain",children:e(v,{icon:"history2",size:"l"})}),r==="start"&&e(re,{to:"/",class:"button plain",children:e(v,{icon:"home",size:"l"})})]}),e("h1",{children:r!=="start"&&e(E,{children:["Catch-up ",e("sup",{children:"beta"})]})}),e("div",{class:"header-side",children:r!=="start"&&r!=="loading"&&e("button",{type:"button",class:"plain",onClick:()=>{P(!0)},children:"Help"})})]})}),e("main",{children:[r==="start"&&e("div",{class:"catchup-start",children:[e("h1",{children:["Catch-up ",e("sup",{children:"beta"})]}),e("details",{children:[e("summary",{children:"What is this?"}),e("p",{children:"Catch-up is a separate timeline for your followings, offering a high-level view at a glance, with a simple, email-inspired interface to effortlessly sort and filter through posts."}),e("img",{src:Ja,width:"1200",height:"900",alt:"Preview of Catch-up UI"}),e("p",{children:e("button",{type:"button",onClick:C=>{C.target.closest("details").open=!1},children:"Let's catch up"})})]}),e("p",{children:"Let's catch up on the posts from your followings."}),e("p",{children:e("b",{children:"Show me all posts from…"})}),e("div",{class:"catchup-form",children:[e("input",{ref:m,type:"range",value:_,min:Ke[0].value,max:Ke[Ke.length-1].value,step:"1",list:"catchup-ranges",onChange:C=>U(+C.target.value)})," ",e("span",{style:{width:"8em"},children:[Ke[_-1].label,e("br",{}),e("small",{class:"insignificant",children:_==Ke[Ke.length-1].value?"until the max":rt(new Date(Date.now()-_*60*60*1e3))})]}),e("datalist",{id:"catchup-ranges",children:Ke.map(({label:C,value:F})=>e("option",{value:F,label:C}))})," ",e("button",{type:"button",onClick:()=>{var C;if(_z?e("p",{class:"catchup-info",children:[e(v,{icon:"info"})," Overlaps with your last catch-up"]}):_===Ke[Ke.length-1].value&&S?e("p",{class:"catchup-info",children:e("label",{children:[e("input",{type:"checkbox",switch:!0,checked:!0,ref:k})," ","Until the last catch-up (",Zt.format(new Date(S)),")"]})}):null,e("p",{class:"insignificant",children:e("small",{children:"Note: your instance might only show a maximum of 800 posts in the Home timeline regardless of the time range. Could be less or more."})}),!!(x!=null&&x.length)&&e("div",{class:"catchup-prev",children:[e("p",{children:"Previously…"}),e("ul",{children:x.map(C=>e("li",{children:[e(re,{to:`/catchup?id=${C.id}`,children:[e(v,{icon:"history2"})," ",e("span",{children:C.startAt?Zt.formatRange(new Date(C.startAt),new Date(C.endAt)):`… – ${Zt.format(new Date(C.endAt))}`})]})," ",e("span",{children:[e("small",{class:"ib insignificant",children:[C.count," posts"]})," ",e("button",{type:"button",class:"light danger small",onClick:async()=>{var W;if(confirm("Remove this catch-up?")){let B=se(`Removing Catch-up ${C.id}`);await it.catchup.del(C.id),(W=B==null?void 0:B.hideToast)==null||W.call(B),se(`Catch-up ${C.id} removed`),w()}},children:e(v,{icon:"x"})})]})]},C.id))}),x.length>=3&&e("p",{children:e("small",{children:"Note: Only max 3 will be stored. The rest will be automatically removed."})})]})]}),r==="loading"&&e("div",{class:"ui-state catchup-start",children:[e(Ae,{abrupt:!0}),e("p",{class:"insignificant",children:"Fetching posts…"}),e("p",{class:"insignificant",children:"This might take a while."})]}),r==="results"&&e(E,{children:[e("div",{class:"catchup-header",children:[l.length>0&&e("p",{children:e("b",{class:"ib",children:Zt.formatRange(new Date(l[0].createdAt),new Date(l[l.length-1].createdAt))})}),e("aside",{children:[e("button",{hidden:ee==="All"&&!L&&j==="createdAt"&&O==="asc",type:"button",class:"plain4 small",onClick:()=>{J("All"),N(null),ce("createdAt"),de(null),ie("asc")},children:"Reset filters"}),(M==null?void 0:M.length)>0&&e("button",{type:"button",class:"plain small",onClick:()=>a(!u),children:["Top links"," ",e(v,{icon:"chevron-down",style:{transform:u?"rotate(180deg)":"rotate(0deg)"}})]})]})]}),e("div",{class:"shazam-container no-animation",hidden:!u,children:e("div",{class:"shazam-container-inner",children:e("div",{class:"catchup-top-links links-bar",children:M.map(C=>{const{card:F,shared:W,sharers:B,likes:Q,boosts:ye}=C,{blurhash:fe,title:ae,description:xe,url:Ue,image:Oe,imageDescription:Me,language:Ve,width:K,height:ke,publishedAt:nt}=F,Wt=Ut.toUnicode(URL.parse(Ue).hostname.replace(/^www\./,"").replace(/\/$/,""));let bt;if(fe){const Ye=Pn(fe),xt=Gn(Ye);bt=jn([.6,xt[1],xt[2]])}return e("a",{href:Ue,target:"_blank",rel:"noopener noreferrer",style:bt?{"--accent-color":`rgb(${bt.join(",")})`,"--accent-alpha-color":`rgba(${bt.join(",")}, 0.4)`}:{},children:e("article",{children:[e("figure",{children:e("img",{src:Oe,alt:Me,width:K,height:ke,loading:"lazy"})}),e("div",{class:"article-body",children:[e("header",{children:[e("div",{class:"article-meta",children:[e("span",{class:"domain",children:Wt})," ",!!nt&&e(E,{children:"· "}),!!nt&&e(E,{children:e(It,{datetime:nt,format:"micro"})})]}),!!ae&&e("h1",{class:"title",lang:Ve,dir:"auto",title:ae,children:ae})]}),!!xe&&e("p",{class:"description",lang:Ve,dir:"auto",title:xe,children:xe}),e("hr",{}),e("p",{style:{whiteSpace:"nowrap"},children:["Shared by"," ",B.map(Ye=>{const{avatarStatic:xt,displayName:$s}=Ye;return e(st,{url:xt,size:"s",alt:$s})})]})]})]})},Ue)})})})}),l.length>=5&&(Te==="3d"?e("div",{class:"catchup-posts-viz-time-bar",children:te}):e("div",{class:"catchup-posts-viz-bar",children:ve})),l.length>=2&&e("div",{class:"catchup-filters",children:[e("label",{class:"filter-cat",children:[e("input",{type:"radio",name:"filter-cat",checked:ee.toLowerCase()==="all",onChange:()=>{J("All")}}),"All ",e("span",{class:"count",children:l.length})]}),er.map(C=>!!D[C]&&e("label",{class:"filter-cat",title:(D[C]/l.length*100).toFixed(2)+"%",children:[e("input",{type:"radio",name:"filter-cat",checked:ee.toLowerCase()===C.toLowerCase(),onChange:()=>{J(C)}}),C," ",e("span",{class:"count",children:D[C]})]},C))]}),l.length>=2&&!!be&&e("div",{class:"catchup-filters authors-filters",ref:$e,children:[Ie.map(C=>e("label",{class:"filter-author","data-author":C,children:[e("input",{type:"radio",name:"filter-author",checked:L===C,onChange:()=>{N(C)},onClick:()=>{L===C&&N(null)}}),e(st,{url:oe[C].avatarStatic||oe[C].avatar,size:"xxl",alt:`${oe[C].displayName} (@${oe[C].acct})`})," ",e("span",{class:"count",children:be[C]}),e("span",{class:"username",children:oe[C].username})]},`${C}-${be[C]}`)),Ie.length>5&&e("small",{style:{whiteSpace:"nowrap",paddingInline:"1em",opacity:.33},children:[Ie.length," authors"]},"authors-count")]}),l.length>=2&&e("div",{class:"catchup-filters",children:[e("span",{class:"filter-label",children:"Sort"})," ",e("fieldset",{class:"radio-field-group",children:tr.map(C=>e("label",{class:"filter-sort",onClick:F=>{j===C&&(F.preventDefault(),F.stopPropagation(),ie(O==="asc"?"desc":"asc"))},children:[e("input",{type:"radio",name:"filter-sort-cat",checked:j===C,onChange:()=>{ce(C);const F=/(replies|favourites|reblogs)/.test(C)?"desc":"asc";ie(F)}}),{createdAt:"Date",repliesCount:"Replies",favouritesCount:"Likes",reblogsCount:"Boosts",density:"Density"}[C],j===C&&(O==="asc"?" ↑":" ↓")]},C))}),e("span",{class:"filter-label",children:"Group"})," ",e("fieldset",{class:"radio-field-group",children:nr.map(C=>e("label",{class:"filter-group",children:[e("input",{type:"radio",name:"filter-group",checked:V===C,onChange:()=>{de(C)},disabled:C==="account"&&L}),{account:"Authors"}[C]||"None"]},C||"none"))}),L&&Ie.length>1?e("button",{type:"button",class:"plain6 small",onClick:()=>{N(null)},style:{whiteSpace:"nowrap"},children:"Show all authors"}):null]}),e("ul",{class:`catchup-list catchup-filter-${Ii[ee]||""} ${j?`catchup-sort-${j}`:""} ${L&&oe[L]?"catchup-selected-author":""} ${V?`catchup-group-${V}`:""}`,children:Le.map((C,F)=>{var Q;const W=((Q=C.reblog)==null?void 0:Q.id)||C.id;let B=!1;return V==="account"&&(Pe.current&&C.account.id!==Pe.current&&F>0&&(B=!0),Pe.current=C.account.id),e(E,{children:[B&&e("li",{class:"separator"}),e(rr,{to:`/${n}/s/${W}`,post:C,root:me.current})]},`${C.id}-${B}`)})}),e("footer",{children:he.length>5&&e("p",{children:[ee==="Boosts"?"You don't have to read everything.":"That's all."," ",e("button",{type:"button",class:"textual",onClick:()=>{me.current.scrollTop=0},children:"Back to top"}),"."]})})]})]})]}),le&&e(Re,{onClose:()=>P(!1),children:e("div",{class:"sheet",id:"catchup-help-sheet",children:[e("button",{type:"button",class:"sheet-close",onClick:()=>P(!1),children:e(v,{icon:"x"})}),e("header",{children:e("h2",{children:"Help"})}),e("main",{children:e("dl",{children:[e("dt",{children:"Top links"}),e("dd",{children:"Links shared by followings, sorted by shared counts, boosts and likes."}),e("dt",{children:"Sort: Density"}),e("dd",{children:'Posts are sorted by information density or depth. Shorter posts are "lighter" while longer posts are "heavier". Posts with photos are "heavier" than posts without photos.'}),e("dt",{children:"Group: Authors"}),e("dd",{children:"Posts are grouped by authors, sorted by posts count per author."}),e("dt",{children:"Keyboard shortcuts"}),e("dd",{children:[e("kbd",{children:"j"}),": Next post"]}),e("dd",{children:[e("kbd",{children:"k"}),": Previous post"]}),e("dd",{children:[e("kbd",{children:"l"}),": Next author"]}),e("dd",{children:[e("kbd",{children:"h"}),": Previous author"]}),e("dd",{children:[e("kbd",{children:"Enter"}),": Open post details"]}),e("dd",{children:[e("kbd",{children:"."}),": Scroll to top"]})]})})]})})]})}const ar=Je(function({post:t}){const{id:n,account:s,group:i,reblog:o,inReplyToId:r,inReplyToAccountId:f,_followedTags:u,_filtered:a,visibility:d,__BOOSTERS:p}=t,c=r&&f!==s.id,h=!!a,l=b=>{b.shiftKey};return e("article",{class:`post-line ${i?"group":o?"reblog":u!=null&&u.length?"followed-tags":""} ${c?"reply-to":""} ${h?"filtered":""} visibility-${d}`,onMouseEnter:l,children:[e("span",{class:"post-author",children:o?e("span",{class:"post-reblog-avatar",children:[e(st,{url:s.avatarStatic||s.avatar,squircle:s.bot}),(p==null?void 0:p.size)>0?[...p].map(b=>e(st,{url:b.avatarStatic||b.avatar,squircle:b.bot})):""," ",e(v,{icon:"rocket"})," ",e(_t,{account:o.account,showAvatar:!0})]}):e(_t,{account:s,showAvatar:!0})}),e(dr,{post:o||t,filterInfo:a}),e("span",{class:"post-meta",children:[e(ur,{post:o||t})," ",e(It,{datetime:new Date((o==null?void 0:o.createdAt)||t.createdAt),format:"micro"})]})]})},(t,n)=>{var s,i;return((s=t==null?void 0:t.post)==null?void 0:s.id)===((i=n==null?void 0:n.post)==null?void 0:i.id)}),rr=({root:t,to:n,...s})=>{const i=H(),[o,r]=A(!1);return X(()=>{const f=new IntersectionObserver(u=>{u[0].isIntersecting&&(queueMicrotask(()=>r(!0)),f.unobserve(i.current))},{root:t,rootMargin:`${Math.max(320,screen.height*.75)}px`});return i.current&&f.observe(i.current),()=>{i.current&&f.unobserve(i.current)}},[]),o?e("li",{children:e(re,{to:n,children:e(ar,{...s})})}):e("li",{ref:i,style:{height:"4em"}})},cr=8,lr=8;function Ci(t){var a;const{spoilerText:n,content:s,poll:i,mediaAttachments:o,card:r}=t,f=(a=i==null?void 0:i.options)!=null&&a.length?i.options.reduce((d,p)=>d+p.title,""):"";return(n.length+Wi(s)+f.length)/140+(o!=null&&o.length?cr*o.length:r!=null&&r.image?lr:0)}const mt=48;function dr({post:t,filterInfo:n}){var y;const{spoilerText:s,sensitive:i,content:o,emojis:r,poll:f,mediaAttachments:u,card:a,inReplyToId:d,inReplyToAccountId:p,account:c,_thread:h}=t,l=d&&p===c.id||!!h,b=ge(()=>!!(we.account.get("preferences")||{})["reading:expand:spoilers"],[]),m=b||!s&&!i,k=o?Nn(t):"",g=!s||b;return e("div",{class:"post-peek",title:s?"":k,children:[e("span",{class:"post-peek-content",children:[l&&!g&&e(E,{children:[e("span",{class:"post-peek-tag post-peek-thread",children:"Thread"})," "]}),n?e("span",{class:"post-peek-filtered",children:["Filtered",n!=null&&n.titlesStr?`: ${n.titlesStr}`:""]}):e(E,{children:[!!s&&e("span",{class:"post-peek-spoiler",children:[e(v,{icon:`${b?"eye-open":"eye-close"}`})," ",s]}),g&&e("div",{class:"post-peek-html",children:[l&&e(E,{children:[e("span",{class:"post-peek-tag post-peek-thread",children:"Thread"})," "]}),!!o&&e("div",{dangerouslySetInnerHTML:{__html:Qs(o,r)}}),!!((y=f==null?void 0:f.options)!=null&&y.length)&&f.options.map(T=>e("div",{children:[f.multiple?"▪️":"•"," ",T.title]})),!o&&(u==null?void 0:u.length)===1&&u[0].description&&e(E,{children:[e("span",{class:"post-peek-tag post-peek-alt",children:"ALT"})," ",e("div",{children:u[0].description})]})]})]})]}),!n&&e("span",{class:"post-peek-post-content",children:[!!f&&e("span",{class:"post-peek-tag post-peek-poll",children:[e(v,{icon:"poll",size:"s"}),"Poll"]}),u!=null&&u.length?u.map(T=>{var G,D,M,ee,J,L,N,_,U,j;const w=T.previewUrl||T.url,S=T.previewRemoteUrl||T.remoteUrl,I=(G=T.meta)!=null&&G.original?T.meta.original.width:((M=(D=T.meta)==null?void 0:D.small)==null?void 0:M.width)||((J=(ee=T.meta)==null?void 0:ee.original)==null?void 0:J.width),x=(L=T.meta)!=null&&L.original?T.meta.original.height:((_=(N=T.meta)==null?void 0:N.small)==null?void 0:_.height)||((j=(U=T.meta)==null?void 0:U.original)==null?void 0:j.height);return e("span",{class:"post-peek-media",children:{image:(w||S)&&m?e("img",{src:w,width:mt,height:mt,alt:T.description,loading:"lazy",onError:ce=>{const{src:O}=ce.target;O===w&&(ce.target.src=S)},style:{"--anim-duration":`${Math.min(Math.max(Math.max(I,x)/100,5),120)}s`}}):e("span",{class:"post-peek-faux-media",children:"🖼"}),gifv:(w||S)&&m?e("img",{src:w,width:mt,height:mt,alt:T.description,loading:"lazy",onError:ce=>{const{src:O}=ce.target;O===w&&(ce.target.src=S)}}):e("span",{class:"post-peek-faux-media",children:"🎞️"}),video:(w||S)&&m?e("img",{src:w,width:mt,height:mt,alt:T.description,loading:"lazy",onError:ce=>{const{src:O}=ce.target;O===w&&(ce.target.src=S)}}):e("span",{class:"post-peek-faux-media",children:"📹"}),audio:e("span",{class:"post-peek-faux-media",children:"🎵"})}[T.type]||null},T.id)}):!!a&&a.image&&m&&e("span",{class:`post-peek-media post-peek-card card-${a.type||""}`,children:a.image?e("img",{src:a.image,width:mt,height:mt,alt:a.title||a.description||a.imageDescription,loading:"lazy",style:{"--anim-duration":a.width&&a.height&&`${Math.min(Math.max(Math.max(a.width,a.height)/100,5),120)}s`}}):e("span",{class:"post-peek-faux-media",children:"🔗"})})]})]})}function ur({post:t}){const{reblogsCount:n,repliesCount:s,favouritesCount:i}=t;return e("span",{class:"post-stats",children:[s>0&&e("span",{class:"post-stat-replies",children:[e(v,{icon:"comment2",size:"s"})," ",je(s)]}),i>0&&e("span",{class:"post-stat-likes",children:[e(v,{icon:"heart",size:"s"})," ",je(i)]}),n>0&&e("span",{class:"post-stat-boosts",children:[e(v,{icon:"rocket",size:"s"})," ",je(n)]})]})}const{locale:hr}=new Intl.DateTimeFormat().resolvedOptions(),Zt=new Intl.DateTimeFormat(hr,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric"});function fr(t,n,s){const i=t.map(a=>new Date(a[n])),o=i.reduce((a,d)=>dd>a?d:a,i[0]).getTime()-o.getTime(),u=Array.from({length:s},()=>[]);return t.forEach(a=>{const p=(new Date(a[n]).getTime()-o.getTime())/f,c=Math.floor(p*(s-1));u[c].push(a)}),u}const pr=20;function ps(){qe("Likes","/f");const{masto:t,instance:n}=ne(),s=H();async function i(o){return(o||!s.current)&&(s.current=t.v1.favourites.list({limit:pr})),await s.current.next()}return e(pt,{title:"Likes",id:"favourites",emptyText:"No likes yet. Go like something!",errorText:"Unable to load likes",instance:n,fetchItems:i})}const mr=["home","public","notifications","thread","account"],Ti=["notifications","thread","account"],gr={home:"Home and lists",notifications:"Notifications",public:"Public timelines",thread:"Conversations",account:"Profiles"},br=[0,30*60,60*60,6*60*60,12*60*60,60*60*24,60*60*24*7,60*60*24*30],yr={0:"Never",1800:"30 minutes",3600:"1 hour",21600:"6 hours",43200:"12 hours",86400:"24 hours",604800:"7 days",2592e3:"30 days"};function wr(){const{masto:t}=ne();qe("Filters","/ft");const[n,s]=A("default"),[i,o]=A(!1),[r,f]=kt(d=>d+1,0),[u,a]=A([]);return X(()=>{s("loading"),(async()=>{try{const d=await t.v2.filters.list();d.sort((p,c)=>p.title.localeCompare(c.title)),d.forEach(p=>{var c;(c=p.keywords)!=null&&c.length&&p.keywords.sort((h,l)=>h.id-l.id)}),a(d),s("default")}catch{s("error")}})()},[r]),e("div",{id:"filters-page",class:"deck-container",tabIndex:"-1",children:[e("div",{class:"timeline-deck deck",children:[e("header",{children:e("div",{class:"header-grid",children:[e("div",{class:"header-side",children:[e(Tt,{}),e(re,{to:"/",class:"button plain",children:e(v,{icon:"home",size:"l"})})]}),e("h1",{children:"Filters"}),e("div",{class:"header-side",children:e("button",{type:"button",class:"plain",onClick:()=>{o(!0)},children:e(v,{icon:"plus",size:"l",alt:"New filter"})})})]})}),e("main",{children:u.length>0?e(E,{children:[e("ul",{class:"filters-list",children:u.map(d=>{const{id:p,title:c,expiresAt:h,keywords:l}=d;return e("li",{children:[e("div",{children:[e("h2",{children:c}),(l==null?void 0:l.length)>0&&e("div",{children:l.map(b=>e(E,{children:[e("span",{class:"tag collapsed insignificant",children:b.wholeWord?`“${b.keyword}”`:b.keyword})," "]}))}),e("small",{class:"insignificant",children:e(ms,{expiresAt:h})})]}),e("button",{type:"button",class:"plain",onClick:()=>{o({filter:d})},children:e(v,{icon:"pencil",size:"l",alt:"Edit filter"})})]},p)})}),u.length>1&&e("footer",{class:"ui-state",children:e("small",{class:"insignificant",children:[u.length," filter",u.length===1?"":"s"]})})]}):n==="loading"?e("p",{class:"ui-state",children:e(Ae,{})}):n==="error"?e("p",{class:"ui-state",children:"Unable to load filters."}):e("p",{class:"ui-state",children:"No filters yet."})})]}),!!i&&e(Re,{title:"Add filter",onClose:()=>{o(!1)},children:e(Sr,{filter:i==null?void 0:i.filter,onClose:d=>{d.state==="success"&&f(),o(!1)}})})]})}let vr=1;const kr=()=>vr++;function Sr({filter:t,onClose:n}){const{masto:s}=ne(),[i,o]=A("default"),r=!!t,{context:f,expiresAt:u,id:a,keywords:d,title:p,filterAction:c}=t||{},h=!!u,l=h&&new Date(u),[b,m]=A(d||[]),k=H(),[g,y]=A([]),[T,w]=A([]),S=b.filter(I=>!g.includes(I.id)&&!T.includes(I._id));return e("div",{class:"sheet",id:"filters-add-edit-modal",children:[!!n&&e("button",{type:"button",class:"sheet-close",onClick:n,children:e(v,{icon:"x"})}),e("header",{children:e("h2",{children:r?"Edit filter":"New filter"})}),e("main",{children:e("form",{onSubmit:I=>{I.preventDefault();const x=new FormData(I.target),G=x.get("title"),D=x.getAll("keyword_attributes[][id]"),M=x.getAll("keyword_attributes[][keyword]"),ee=[...k.current.querySelectorAll('input[name="keyword_attributes[][whole_word]"]')].map(U=>U.checked),J=M.map((U,j)=>({id:D[j]||void 0,keyword:U,wholeWord:ee[j]}));r&&(g!=null&&g.length)&&g.forEach(U=>{J.push({id:U,_destroy:!0})});const L=x.getAll("context");let N=x.get("expires_in");const _=x.get("filter_action");!G||!(L!=null&&L.length)||(o("loading"),(async()=>{try{let U;r?(N===""||N===null?h?N=Math.floor((l-new Date)/1e3):N=null:N==="0"||N===0?N=null:N=+N,U=await s.v2.filters.$select(a).update({title:G,context:L,expiresIn:N,keywordsAttributes:J,filterAction:_})):(N=+N||null,U=await s.v2.filters.create({title:G,context:L,expiresIn:N,keywordsAttributes:J,filterAction:_})),o("default"),n==null||n({state:"success",filter:U})}catch{o("error"),alert(r?"Unable to edit filter":"Unable to create filter")}})())},children:[e("div",{class:"filter-form-row",children:e("label",{children:[e("b",{children:"Title"}),e("input",{type:"text",name:"title",defaultValue:p,disabled:i==="loading",dir:"auto",required:!0})]})}),e("div",{class:"filter-form-keywords",ref:k,children:[S.length?e("ul",{class:"filter-keywords",children:S.map(I=>{const{id:x,keyword:G,wholeWord:D,_id:M}=I;return e("li",{children:[e("input",{type:"hidden",name:"keyword_attributes[][id]",value:x}),e("input",{name:"keyword_attributes[][keyword]",type:"text",defaultValue:G,disabled:i==="loading",required:!0}),e("div",{class:"filter-keyword-actions",children:[e("label",{children:[e("input",{name:"keyword_attributes[][whole_word]",type:"checkbox",value:x,defaultChecked:D,disabled:i==="loading"})," ","Whole word"]}),e("button",{type:"button",class:"light danger small",disabled:i==="loading",onClick:()=>{x?(g.push(x),y([...g])):M&&(T.push(M),w([...T]))},children:e(v,{icon:"x"})})]})]},`${x}-${M}`)})}):e("div",{class:"filter-keywords",children:e("div",{class:"insignificant",children:"No keywords. Add one."})}),e("footer",{class:"filter-keywords-footer",children:[e("button",{type:"button",class:"light",onClick:()=>{m([...b,{_id:kr(),keyword:"",wholeWord:!0}]),setTimeout(()=>{var x,G;const I=k.current.querySelectorAll('input[type="text"]');(G=(x=I[I.length-1])==null?void 0:x.focus)==null||G.call(x)},10)},children:"Add keyword"})," ",(S==null?void 0:S.length)>1&&e("small",{class:"insignificant",children:[S.length," keyword",S.length===1?"":"s"]})]})]}),e("div",{class:"filter-form-cols",children:[e("div",{class:"filter-form-col",children:[e("div",{children:e("b",{children:"Filter from…"})}),mr.map(I=>e("div",{children:[e("label",{class:Ti.includes(I)?"insignificant":"",children:[e("input",{type:"checkbox",name:"context",value:I,defaultChecked:f?f.includes(I):!0,disabled:i==="loading"})," ",gr[I],Ti.includes(I)?"*":""]})," "]})),e("p",{children:e("small",{class:"insignificant",children:"* Not implemented yet"})})]}),e("div",{class:"filter-form-col",children:[r&&e(E,{children:["Status:"," ",e("b",{children:e(ms,{expiresAt:u,showNeverExpires:!0})})]}),e("div",{children:[e("label",{for:"filters-expires_in",children:r?"Change expiry":"Expiry"}),e("select",{id:"filters-expires_in",name:"expires_in",disabled:i==="loading",defaultValue:r?void 0:0,children:[r&&e("option",{}),br.map(I=>e("option",{value:I,children:yr[I]}))]})]}),e("p",{children:["Filtered post will be…",e("br",{}),e("label",{class:"ib",children:[e("input",{type:"radio",name:"filter_action",value:"warn",defaultChecked:c==="warn"||!r,disabled:i==="loading"})," ","minimized"]})," ",e("label",{class:"ib",children:[e("input",{type:"radio",name:"filter_action",value:"hide",defaultChecked:c==="hide",disabled:i==="loading"})," ","hidden"]})]})]})]}),e("footer",{class:"filter-form-footer",children:[e("span",{children:[e("button",{type:"submit",disabled:i==="loading",children:r?"Save":"Create"})," ",e(Ae,{abrupt:!0,hidden:i!=="loading"})]}),r&&e(tt,{disabled:i==="loading",align:"end",menuItemClassName:"danger",confirmLabel:"Delete this filter?",onClick:()=>{o("loading"),(async()=>{try{await s.v2.filters.$select(a).remove(),o("default"),n==null||n({state:"success"})}catch{o("error"),alert("Unable to delete filter.")}})()},children:e("button",{type:"button",class:"light danger",onClick:()=>{},disabled:i==="loading",children:"Delete…"})})]})]})})]})}function ms({expiresAt:t,showNeverExpires:n}){const s=!!t,i=s&&new Date(t),o=s&&i<=new Date,[r,f]=kt(u=>u+1,0);return Mn(f,o||3e4),o?"Expired":s?e(E,{children:["Expiring ",e(It,{datetime:i})]}):n&&"Never expires"}function Ir(){const{masto:t,instance:n}=ne();qe("Followed Hashtags","/fh");const[s,i]=A("default"),[o,r]=A([]);return X(()=>{i("loading"),(async()=>{try{const f=await un();r(f),i("default")}catch{i("error")}})()},[]),e("div",{id:"followed-hashtags-page",class:"deck-container",tabIndex:"-1",children:e("div",{class:"timeline-deck deck",children:[e("header",{children:e("div",{class:"header-grid",children:[e("div",{class:"header-side",children:[e(Tt,{}),e(re,{to:"/",class:"button plain",children:e(v,{icon:"home",size:"l"})})]}),e("h1",{children:"Followed Hashtags"}),e("div",{class:"header-side"})]})}),e("main",{children:o.length>0?e(E,{children:[e("ul",{class:"link-list",children:o.map(f=>e("li",{children:e(re,{to:n?`/${n}/t/${f.name}`:`/t/${f.name}`,children:[e(v,{icon:"hashtag"})," ",e("span",{children:f.name})]})}))}),o.length>1&&e("footer",{class:"ui-state",children:e("small",{class:"insignificant",children:[o.length," hashtag",o.length===1?"":"s"]})})]}):s==="loading"?e("p",{class:"ui-state",children:e(Ae,{abrupt:!0})}):s==="error"?e("p",{class:"ui-state",children:"Unable to load followed hashtags."}):e("p",{class:"ui-state",children:"No hashtags followed yet."})})]})})}const Cr=20;function Kn({title:t,path:n,id:s,...i}){qe(t||"Following",n||"/following");const{masto:o,streaming:r,instance:f}=ne(),u=De($),a=H(),d=H(),p=Ge("@pixelfed/home-include-reblogs");async function c(l){var k;(l||!a.current)&&(a.current=o.v1.timelines.home.list({limit:Cr})),p&&((k=a.current)!=null&&k.nextParams)&&(typeof a.current.nextParams=="string"?a.current.nextParams+="&include_reblogs=true":a.current.nextParams.include_reblogs=!0);const b=await a.current.next();let{value:m}=b;if(m!=null&&m.length){let g=!1;l&&(m[0].id!==d.current&&(g=!0),d.current=m[0].id),m.forEach(y=>{He(y,f)}),m=vi(m,f),l&&g&&Ua(),hs(m,f),m.sort((y,T)=>{const w=new Date(y.createdAt);return new Date(T.createdAt)-w})}return{...b,value:m}}async function h(){var l;try{const b={limit:5,since_id:d.current};Ge("@pixelfed/home-include-reblogs")&&(b.include_reblogs=!0);const m=await o.v1.timelines.home.list(b).next();let{value:k}=m;const g=((l=k[0])==null?void 0:l.id)===d.current;return!!(k!=null&&k.length&&!g&&(d.current=k[0].id,k=vi(k,f),k=wt(k,"home"),k.some(y=>!y.reblog)))}catch{return!1}}return X(()=>{let l;return(async()=>{if(r){l=r.user.subscribe();for await(const b of l){if(!l)break;if(b.event==="status.update"){const m=b.payload;He(m,f)}else if(b.event==="delete"){const m=b.payload,k=zi(m,f);k&&(k._deleted=!0)}}}})(),()=>{var b;(b=l==null?void 0:l.unsubscribe)==null||b.call(l),l=null}},[r]),e(pt,{title:t||"Following",id:s||"following",emptyText:"Nothing to see here.",errorText:"Unable to load posts.",instance:f,fetchItems:c,checkForUpdates:h,useItemID:!0,boostsCarousel:u.settings.boostsCarousel,...i,filterContext:"home",showFollowedTags:!0,showReplyParent:!0})}const Tr=20,xr=4,xi=xr+1;function gs({media:t,columnMode:n,...s}){let{hashtag:i,...o}=n?{}:St();s.hashtag&&(i=s.hashtag);let r=i.trim().split(/[\s+]+/);r.sort(),i=r[0];const[f,u]=ot(),a=t||!!f.get("media"),d=a?"?media=1":"",{masto:p,instance:c,authenticated:h}=ne({instance:(s==null?void 0:s.instance)||o.instance}),{masto:l,instance:b,authenticated:m}=ne(),k=r.map(O=>`#${O}`).join(" "),g=a?" (Media only)":"",y=c?`${k}${g} on ${c}`:`${k}${g}`;qe(y,"/:instance?/t/:hashtag");const T=H(),w=ge(()=>_n(),[]),S=H(void 0);async function I(O){const ie=await p.v1.timelines.tag.$select(i).list({limit:Tr,any:r.slice(1),maxId:O?void 0:S.current,onlyMedia:a?!0:void 0}).next();let{value:V}=ie;return V!=null&&V.length&&(O&&(T.current=V[0].id),V.forEach(de=>{He(de,c,{skipThreading:a||w})}),S.current=V[V.length-1].id),{...ie,value:V}}async function x(){var O;try{const ie=await p.v1.timelines.tag.$select(i).list({limit:1,any:r.slice(1),since_id:T.current,onlyMedia:a}).next();let{value:V}=ie;const de=((O=V[0])==null?void 0:O.id)===T.current;return V!=null&&V.length&&!de?(V=wt(V,"public"),!0):!1}catch{return!1}}const[G,D]=A("default"),[M,ee]=A();X(()=>{(async()=>{try{const O=await p.v1.tags.$select(i).fetch();ee(O)}catch{}})()},[i]);const J=r.length>=xi,[L,N]=A("default"),[_,U]=A([]),[j,ce]=A(!1);return X(()=>{h&&(async()=>{try{const O=await p.v1.featuredTags.list();U(O),ce(O.some(ie=>ie.name.toLowerCase()===i.toLowerCase()))}catch{}})()},[]),e(pt,{title:y,titleComponent:!!c&&e("h1",{class:"header-double-lines",children:[e("b",{children:k}),e("div",{children:c})]}),id:"hashtag",instance:c,emptyText:"No one has posted anything with this tag yet.",errorText:"Unable to load posts with this tag",fetchItems:I,checkForUpdates:x,useItemID:!0,view:a||w?"media":void 0,refresh:a,filterContext:"public",headerEnd:e(Ze,{portal:!0,setDownOverflow:!0,overflow:"auto",position:"anchor",menuButton:e("button",{type:"button",class:"plain",children:e(v,{icon:"more",size:"l"})}),children:[!!M&&r.length===1&&e(E,{children:[e(tt,{subMenu:!0,confirm:M.following,confirmLabel:`Unfollow #${i}?`,disabled:G==="loading"||!h,onClick:()=>{D("loading"),M.following?p.v1.tags.$select(i).unfollow().then(()=>{ee({...M,following:!1}),se(`Unfollowed #${i}`)}).catch(O=>{alert(O)}).finally(()=>{D("default")}):p.v1.tags.$select(i).follow().then(()=>{ee({...M,following:!0}),se(`Followed #${i}`)}).catch(O=>{alert(O)}).finally(()=>{D("default")})},children:M.following?e(E,{children:[e(v,{icon:"check-circle"})," ",e("span",{children:"Following…"})]}):e(E,{children:[e(v,{icon:"plus"})," ",e("span",{children:"Follow"})]})}),e(pe,{type:"checkbox",checked:j,disabled:L==="loading"||!h,onClick:()=>{if(N("loading"),j){const O=_.find(ie=>ie.name.toLowerCase()===i.toLowerCase()).id;O?p.v1.featuredTags.$select(O).remove().then(()=>{ce(!1),se("Unfeatured on profile"),U(_.filter(ie=>ie.id!==O))}).catch(ie=>{}).finally(()=>{N("default")}):se("Unable to unfeature on profile")}else p.v1.featuredTags.create({name:i}).then(O=>{ce(!0),se("Featured on profile"),U(_.concat(O))}).catch(O=>{}).finally(()=>{N("default")})},children:j?e(E,{children:[e(v,{icon:"check-circle"}),e("span",{children:"Featured on profile"})]}):e(E,{children:[e(v,{icon:"check-circle"}),e("span",{children:"Feature on profile"})]})}),e(ze,{})]}),!w&&e(E,{children:[e(Ki,{className:"plain",children:"Filters"}),e(pe,{type:"checkbox",checked:!!a,onClick:()=>{a?f.delete("media"):f.set("media","1"),u(f)},children:[e(v,{icon:"check-circle"})," ",e("span",{class:"menu-grow",children:"Media only"})]}),e(ze,{})]}),e(eo,{className:"menu-field",disabled:J,children:({ref:O})=>e("form",{onSubmit:ie=>{var de,he;ie.preventDefault();const V=(he=(de=ie.target[0].value)==null?void 0:de.trim)==null?void 0:he.call(de);V&&!r.some(oe=>oe.toLowerCase()===V.toLowerCase())&&(r.push(V),r.sort(),location.hash=c?`/${c}/t/${r.join("+")}`:`/t/${r.join("+")}${d}`)},children:[e(v,{icon:"hashtag"}),e("input",{ref:O,type:"text",placeholder:J?`Max ${xi} tags`:"Add hashtag",required:!0,autocorrect:"off",autocapitalize:"off",spellCheck:!1,pattern:"[^#][^\\s#]+[^#]",disabled:J})]})}),e(to,{takeOverflow:!0,children:r.map((O,ie)=>e(pe,{disabled:r.length===1,onClick:V=>{r.splice(ie,1),r.sort(),location.hash=c?`/${c}/t/${r.join("+")}${d}`:`/t/${r.join("+")}${d}`},children:[e(v,{icon:"x",alt:"Remove hashtag",class:"danger-icon"}),e("span",{children:[e("span",{class:"more-insignificant",children:"#"}),O]})]},O))}),e(ze,{}),e(pe,{disabled:!m,onClick:()=>{if($.shortcuts.length>=lt){alert(`Max ${lt} shortcuts reached. Unable to add shortcut.`);return}const O={type:"hashtag",hashtag:r.join(" "),instance:c,media:a?"on":void 0};$.shortcuts.some(V=>V.type===O.type&&V.hashtag.split(/[\s+]+/).sort().join(" ")===O.hashtag.split(/[\s+]+/).sort().join(" ")&&(V.instance?V.instance===O.instance:!0)&&(V.media?!!V.media==!!O.media:!0))?alert("This shortcut already exists"):($.shortcuts.push(O),se("Hashtag shortcut added"))},children:[e(v,{icon:"shortcut"})," ",e("span",{children:"Add to Shortcuts"})]}),e(pe,{onClick:()=>{let O=prompt('Enter a new instance e.g. "mastodon.social"');if(!/\./.test(O)){O&&alert("Invalid instance");return}O&&(O=O.toLowerCase().trim(),location.hash=`/${O}/t/${r.join("+")}${d}`)},children:[e(v,{icon:"bus"})," ",e("span",{children:"Go to another instance…"})]}),b!==c&&e(pe,{onClick:()=>{location.hash=`/${b}/t/${r.join("+")}${d}`},children:[e(v,{icon:"bus"})," ",e("small",{class:"menu-double-lines",children:["Go to my instance (",e("b",{children:b}),")"]})]})]})},c+k)}const $r=20;function bs(t){var g;const n=De($),{masto:s,instance:i}=ne(),o=(t==null?void 0:t.id)||((g=St())==null?void 0:g.id),r=H(),f=H();async function u(y){(y||!f.current)&&(f.current=s.v1.timelines.list.$select(o).list({limit:$r}));const T=await f.current.next();let{value:w}=T;return w!=null&&w.length&&(y&&(r.current=w[0].id),w.forEach(S=>{He(S,i)})),{...T,value:w}}async function a(){var y;try{const T=await s.v1.timelines.list.$select(o).list({limit:1,since_id:r.current});let{value:w}=T;const S=((y=w[0])==null?void 0:y.id)===r.current;return w!=null&&w.length&&!S?(w=wt(w,"home"),!0):!1}catch{return!1}}const[d,p]=A([]);X(()=>{Yt().then(p)},[]);const[c,h]=A({title:"List"});qe(c.title,"/l/:id"),X(()=>{(async()=>{try{const y=await as(o);h(y)}catch{}})()},[o]);const[l,b]=A(!1),[m,k]=A(!1);return e(E,{children:[e(pt,{title:c.title,id:"list",emptyText:"Nothing yet.",errorText:"Unable to load posts.",instance:i,fetchItems:u,checkForUpdates:a,useItemID:!0,boostsCarousel:n.settings.boostsCarousel,filterContext:"home",showReplyParent:!0,headerStart:e(Ze,{overflow:"auto",menuButton:e("button",{type:"button",class:"plain",children:[e(v,{icon:"list",size:"l",alt:"Lists"}),e(v,{icon:"chevron-down",size:"s"})]}),children:[e(Ee,{to:"/l",children:e("span",{children:"All Lists"})}),(d==null?void 0:d.length)>0&&e(E,{children:[e(ze,{}),d.map(y=>e(Ee,{to:`/l/${y.id}`,children:e("span",{children:y.title})},y.id))]})]}),headerEnd:e(Ze,{portal:!0,setDownOverflow:!0,overflow:"auto",viewScroll:"close",position:"anchor",menuButton:e("button",{type:"button",class:"plain",children:e(v,{icon:"more",size:"l"})}),children:[e(pe,{onClick:()=>b({list:c}),children:[e(v,{icon:"pencil",size:"l"}),e("span",{children:"Edit"})]}),e(pe,{onClick:()=>k(!0),children:[e(v,{icon:"group",size:"l"}),e("span",{children:"Manage members"})]})]})},o),l&&e(Re,{onClick:y=>{y.target===y.currentTarget&&b(!1)},children:e(Vn,{list:l==null?void 0:l.list,onClose:y=>{y.state==="success"&&y.list?h(y.list):y.state==="deleted"&&(location.hash="/l"),b(!1)}})}),m&&e(Re,{onClick:y=>{y.target===y.currentTarget&&k(!1)},children:e(Rr,{listID:o,onClose:()=>k(!1)})})]})}const Ar=40;function Rr({listID:t,onClose:n}){const{masto:s,instance:i}=ne(),[o,r]=A([]),[f,u]=A("default"),[a,d]=A(!1),p=H();async function c(h){d(!1),u("loading"),(async()=>{try{(h||!p.current)&&(p.current=s.v1.lists.$select(t).accounts.list({limit:Ar}));const l=await p.current.next();let{done:b,value:m}=l;m!=null&&m.length?(r(h?m:o.concat(m)),d(!b)):d(!1),u("default")}catch{u("error")}})()}return X(()=>{c(!0)},[]),e("div",{class:"sheet",id:"list-manage-members-container",children:[!!n&&e("button",{type:"button",class:"sheet-close",onClick:n,children:e(v,{icon:"x"})}),e("header",{children:e("h2",{children:"Manage members"})}),e("main",{children:e("ul",{children:[o.map(h=>e("li",{children:[e(Qe,{account:h,instance:i}),e(Er,{account:h,listID:t})]},h.id)),a&&f==="default"&&e(ht,{as:"li",onChange:h=>h&&c(),children:e("button",{type:"button",class:"light block",onClick:c,children:"Show more…"})})]})})]})}function Er({account:t,listID:n}){const{masto:s}=ne(),[i,o]=A("default"),[r,f]=A(!1);return e(tt,{confirm:!r,confirmLabel:e("span",{children:["Remove @",t.username," from list?"]}),align:"end",menuItemClassName:"danger",onClick:()=>{r?(o("loading"),(async()=>{try{await s.v1.lists.$select(n).accounts.create({accountIds:[t.id]}),o("default"),f(!1)}catch{o("error")}})()):(o("loading"),(async()=>{try{await s.v1.lists.$select(n).accounts.remove({accountIds:[t.id]}),o("default"),f(!0)}catch{o("error")}})())},children:e("button",{type:"button",class:`light ${r?"":"danger"}`,disabled:i==="loading",children:r?"Add":"Remove…"})})}const _r={mention:["account","status"],status:["account","status"],reblog:["account","status"],follow:["account"],follow_request:["account"],favourite:["account","status"],poll:["status"],update:["status"]};function ys(t){return t.filter(n=>{const{type:s,id:i,createdAt:o}=n;if(!s)return!1;const r=_r[s];return r!=null&&r.length?r.every(f=>!!n[f]):!0})}function ws(t){t=ys(t);const n={},s=[];for(let r=0,f=0;ry.id===p.id);g?(g._types.push(c),g._types.sort().reverse(),k.id+=`-${a}`):(p._types=[c],k._accounts.push(p),k.id+=`-${a}`)}else{p&&(p._types=[c]);let g=n[m]={...u,type:b,_accounts:p?[p]:[]};s[f++]=g}}const i={},o=[];for(let r=0,f=0;r{He(w,i)})),{...y,value:T==null?void 0:T.map(w=>w.status)}}const c=H(),h=H();async function l(g){(g||!c.current)&&(c.current=s.v1.conversations.list({limit:$i}));const y=await c.current.next();let{value:T}=y;return T=T==null?void 0:T.filter(w=>w.lastStatus),T!=null&&T.length&&(g&&(h.current=T[0].lastStatus.id),T.forEach(({lastStatus:w})=>{He(w,i)})),{...y,value:T==null?void 0:T.map(w=>w.lastStatus)}}function b(...g){return u==="private"?l(...g):p(...g)}async function m(){var g;if(u==="private")try{const y=await s.v1.conversations.list({limit:1,since_id:h.current}).next();let{value:T}=y;const w=((g=T[0])==null?void 0:g.id)===h.current;return T!=null&&T.length&&!w?(h.current=T[0].lastStatus.id,!0):!1}catch{return!1}else try{const y=await s.v1.notifications.list({limit:1,types:["mention"],since_id:d.current}).next();let{value:T}=y;return T!=null&&T.length?(d.current=T[0].id,!0):!1}catch{return!1}}const k=ge(()=>e("div",{class:"filter-bar centered",children:[e(re,{to:"/mentions",class:u?"":"is-active",onClick:g=>{t&&(g.preventDefault(),f(null))},children:"All"}),e(re,{to:"/mentions?type=private",class:u==="private"?"is-active":"",onClick:g=>{t&&(g.preventDefault(),f("private"))},children:"Private"})]}),[u]);return e(pt,{title:"Mentions",id:"mentions",emptyText:"No one mentioned you :(",errorText:"Unable to load mentions.",instance:i,fetchItems:b,checkForUpdates:m,useItemID:!0,timelineStart:k,refresh:u})}const Mr=80,Dr=new URLSearchParams,Jt={block:"center",inline:"center",behavior:"smooth"};function Pr({columnMode:t}){var le;qe("Notifications","/notifications");const{masto:n,instance:s}=ne(),i=De($),[o,r]=A("default"),[f]=t?[Dr]:ot(),u=f.get("id"),a=f.get("access_token"),[d,p]=A(!1),[c,h]=A(!1),l=H(),{nearReachEnd:b,scrollDirection:m,reachStart:k,nearReachStart:g}=Fa({scrollableRef:l}),y=m==="end"&&!g,[T,w]=A([]),[S,I]=A([]),x=H();async function G(P){var q;if((P||!x.current)&&(x.current=n.v1.notifications.list({limit:Mr,excludeTypes:["follow_request"]})),/max_id=($|&)/i.test((q=x.current)==null?void 0:q.nextParams))return{done:!0};const Y=await x.current.next(),R=Y.value;if(R!=null&&R.length){R.forEach(ue=>{He(ue.status,s,{skipThreading:!0})});const Z=ws(R);P?($.notificationsLast=R[0],$.notifications=Z,n.v1.markers.create({notifications:{lastReadId:R[0].id}}).catch(()=>{})):$.notifications.push(...Z)}return $.notificationsShowNew=!1,$.notificationsLastFetchTime=Date.now(),Y}async function D(){try{return await n.v1.followRequests.list({limit:80})}catch{return[]}}const M=()=>{r("loading"),(async()=>{try{const P=await D();w(P),r("default")}catch{r("error")}})()};async function ee(){try{return await n.v1.announcements.list()}catch{return[]}}const J=Ge("@mastodon/filtered-notifications"),[L,N]=A(!1),[_,U]=A({});function j(){return n.v1.notifications.policy.fetch().catch(()=>{})}function ce(){j().then(P=>{U(P)}).catch(()=>{})}const[O,ie]=A(null);function V(){return n.v1.notifications.requests.list()}const de=P=>{oe(!1),r("loading"),(async()=>{try{const Y=G(P);P&&(ee().then(q=>{q.sort((Z,ue)=>{const Ne=new Date(Z.updatedAt||Z.createdAt);return new Date(ue.updatedAt||ue.createdAt)-Ne}),I(q)}).catch(()=>{}),D().then(q=>{w(q)}).catch(()=>{}),J&&ce());const{done:R}=await Y;p(!R),r("default")}catch{r("error")}})()};X(()=>{de(!0)},[]),X(()=>{k&&de(!0)},[k]);const[he,oe]=A(!1),be=et(({disableIdleCheck:P=!1}={})=>{var Y;o!=="loading"&&i.settings.autoRefresh&&((Y=l.current)==null?void 0:Y.scrollTop)<16&&(P||window.__IDLE__)&&!Nr()&&de(!0)},[i.notificationsShowNew,i.settings.autoRefresh,o]),Ce=H();Lt(P=>{if(P){const Y=Date.now()-Ce.current;!Ce.current||Y>1e3*3?be({disableIdleCheck:!0}):Ce.current=Date.now()}});const Ie=H(!0);X(()=>{let P=Ps($,"notificationsShowNew",Y=>{if(Ie.current){Ie.current=!1;return}o!=="loading"&&(Y&&be(),oe(Y))});return()=>P==null?void 0:P()},[]);const Le=new Date,Pe=new Date(Le-24*60*60*1e3);let $e=new Date;const Se=!i.notifications.some(P=>new Date(P.createdAt).toDateString()===Le.toDateString()),Te=H();X(()=>{u&&($.routeNotification={id:u,accessToken:atob(a)})},[u,a]);const ve=".notification",te=_e("j",()=>{const P=document.activeElement.closest(ve),Y=P==null?void 0:P.getBoundingClientRect(),R=Array.from(l.current.querySelectorAll(ve));if(P&&Y.top0){const q=R.indexOf(P);let Z=R[q+1];Z&&(Z.focus(),Z.scrollIntoView(Jt))}else{const q=R.find(Z=>{const ue=Z.getBoundingClientRect();return ue.top>=44&&ue.left>=0});q&&(q.focus(),q.scrollIntoView(Jt))}}),me=_e("k",()=>{const P=document.activeElement.closest(ve),Y=P==null?void 0:P.getBoundingClientRect(),R=Array.from(l.current.querySelectorAll(ve));if(P&&Y.top0){const q=R.indexOf(P);let Z=R[q-1];Z&&(Z.focus(),Z.scrollIntoView(Jt))}else{const q=R.find(Z=>{const ue=Z.getBoundingClientRect();return ue.top>=44&&ue.left>=0});q&&(q.focus(),q.scrollIntoView(Jt))}}),z=_e(["enter","o"],()=>{const P=document.activeElement.closest(ve),Y=P==null?void 0:P.querySelector(".status-link");Y&&Y.click()});return e("div",{id:"notifications-page",class:"deck-container",ref:P=>{l.current=P,te.current=P,me.current=P,z.current=P},tabIndex:"-1",children:[e("div",{class:`timeline-deck deck ${c?"only-mentions":""}`,children:[e("header",{hidden:y,onClick:P=>{var Y;P.target.closest("a, button")||(Y=l.current)==null||Y.scrollTo({top:0,behavior:"smooth"})},onDblClick:P=>{P.target.closest("a, button")||de(!0)},class:o==="loading"?"loading":"",children:[e("div",{class:"header-grid",children:[e("div",{class:"header-side",children:[e(Tt,{}),e(re,{to:"/",class:"button plain",children:e(v,{icon:"home",size:"l",alt:"Home"})})]}),e("h1",{children:"Notifications"}),e("div",{class:"header-side",children:J&&e("button",{type:"button",class:"button plain4",onClick:()=>{N(!0)},children:e(v,{icon:"settings",size:"l",alt:"Notifications settings"})})})]}),he&&o!=="loading"&&e("button",{class:"updates-button shiny-pill",type:"button",onClick:()=>{var P;de(!0),(P=l.current)==null||P.scrollTo({top:0,behavior:"smooth"})},children:[e(v,{icon:"arrow-up"})," New notifications"]})]}),S.length>0&&e("div",{class:"shazam-container",children:e("div",{class:"shazam-container-inner",children:e("details",{class:"announcements",children:[e("summary",{children:[e("span",{children:[e(v,{icon:"announce",class:"announcement-icon",size:"l"})," ",e("b",{children:["Announcement",S.length>1?"s":""]})," ",e("small",{class:"insignificant",children:s})]}),S.length>1&&e("span",{class:"announcements-nav-buttons",children:S.map((P,Y)=>e("button",{type:"button",class:"plain2 small",onClick:()=>{var R;(R=Te.current)==null||R.children[Y].scrollIntoView({behavior:"smooth",block:"nearest"})},children:Y+1}))})]}),e("ul",{class:`announcements-list-${S.length>1?"multiple":"single"}`,ref:Te,children:S.map(P=>e("li",{children:e(Ur,{announcement:P})}))})]})})}),T.length>0&&e("div",{class:"follow-requests",children:[e("h2",{class:"timeline-header",children:"Follow requests"}),T.length>5?e("details",{children:[e("summary",{children:[T.length," follow requests"]}),e("ul",{children:T.map(P=>e("li",{children:[e(Qe,{account:P}),e($n,{accountID:P.id,onChange:()=>{}})]},P.id))})]}):e("ul",{children:T.map(P=>e("li",{children:[e(Qe,{account:P}),e($n,{accountID:P.id,onChange:()=>{}})]},P.id))})]}),J&&((le=_==null?void 0:_.summary)==null?void 0:le.pendingRequestsCount)>0&&e("div",{class:"shazam-container",children:e("div",{class:"shazam-container-inner",children:e("div",{class:"filtered-notifications",children:e("details",{onToggle:async P=>{const{open:Y}=P.target;if(Y){const R=await V();ie(R)}},children:[e("summary",{children:["Filtered notifications from"," ",_.summary.pendingRequestsCount," people"]}),O?(O==null?void 0:O.length)>0&&e("ul",{children:O.map(P=>{var Y,R;return e("li",{children:[e("div",{class:"request-notifcations",children:[!((Y=P.lastStatus)!=null&&Y.id)&&e(Qe,{useAvatarStatic:!0,showStats:!0,account:P.account}),((R=P.lastStatus)==null?void 0:R.id)&&e("div",{class:"last-post",children:e(re,{class:"status-link",to:`/${s}/s/${P.lastStatus.id}`,children:e(Be,{status:P.lastStatus,size:"s",readOnly:!0})})}),e(Or,{request:P})]}),e(zr,{request:P,onChange:()=>{de(!0)}})]},P.id)})}):e("p",{class:"ui-state",children:e(Ae,{abrupt:!0})})]})})})}),e("div",{id:"mentions-option",children:e("label",{children:[e("input",{type:"checkbox",checked:c,onChange:P=>{h(P.target.checked)}})," ","Only mentions"]})}),e("h2",{class:"timeline-header",children:"Today"}),Se&&e("p",{class:"ui-state insignificant",children:o==="default"?"You're all caught up.":e(E,{children:"…"})}),i.notifications.length?e(E,{children:i.notifications.filter(P=>P.type!=="follow_request").map(P=>{if(c&&P.type!=="mention")return null;const Y=new Date(P.createdAt),R=Y.toDateString()!==$e.toDateString();R&&($e=Y);const q=Y.toDateString()===Pe.toDateString()?"Yesterday":rt($e,{hideTime:!0});return e(E,{children:[R&&e("h2",{class:"timeline-header",children:q}),e(mn,{instance:s,notification:P},P.id)]},P.id)})}):e(E,{children:[o==="loading"&&e(E,{children:e("ul",{class:"timeline flat",children:Array.from({length:5}).map((P,Y)=>e("li",{class:"notification skeleton",children:[e("div",{class:"notification-type",children:e(v,{icon:"notification",size:"xl"})}),e("div",{class:"notification-content",children:e("p",{children:"███████████ ████"})})]}))})}),o==="error"&&e("p",{class:"ui-state",children:["Unable to load notifications",e("br",{}),e("br",{}),e("button",{type:"button",onClick:()=>de(!0),children:"Try again"})]})]}),d&&e(ht,{onChange:P=>{P&&de()},children:e("button",{type:"button",class:"plain block",disabled:o==="loading",onClick:()=>de(),style:{marginBlockEnd:"6em"},children:o==="loading"?e(Ae,{abrupt:!0}):e(E,{children:"Show more…"})})})]}),J&&L&&e(Re,{onClick:P=>{P.target===P.currentTarget&&N(!1)},children:e("div",{class:"sheet",id:"notifications-settings",tabIndex:"-1",children:[e("button",{type:"button",class:"sheet-close",onClick:()=>N(!1),children:e(v,{icon:"x"})}),e("header",{children:e("h2",{children:"Notifications settings"})}),e("main",{children:e("form",{onSubmit:P=>{P.preventDefault();const{filterNotFollowing:Y,filterNotFollowers:R,filterNewAccounts:q,filterPrivateMentions:Z}=P.target,ue={filterNotFollowing:Y.checked,filterNotFollowers:R.checked,filterNewAccounts:q.checked,filterPrivateMentions:Z.checked};U({..._,...ue}),N(!1),(async()=>{try{await n.v1.notifications.policy.update(ue),se("Notifications settings updated")}catch{}})()},children:[e("p",{children:"Filter out notifications from people:"}),e("p",{children:e("label",{children:[e("input",{type:"checkbox",switch:!0,defaultChecked:_.filterNotFollowing,name:"filterNotFollowing"})," ","You don't follow"]})}),e("p",{children:e("label",{children:[e("input",{type:"checkbox",switch:!0,defaultChecked:_.filterNotFollowers,name:"filterNotFollowers"})," ","Who don't follow you"]})}),e("p",{children:e("label",{children:[e("input",{type:"checkbox",switch:!0,defaultChecked:_.filterNewAccounts,name:"filterNewAccounts"})," ","With a new account"]})}),e("p",{children:e("label",{children:[e("input",{type:"checkbox",switch:!0,defaultChecked:_.filterPrivateMentions,name:"filterPrivateMentions"})," ","Who unsolicitedly private mention you"]})}),e("p",{children:e("button",{type:"submit",children:"Save"})})]})})]})})]})}function Nr(){return!!document.querySelector(".deck-backdrop, #modal-container > *")}function Ur({announcement:t}){const{instance:n}=ne(),{contact:s}=Ui(),i=s==null?void 0:s.account,{id:o,content:r,startsAt:f,endsAt:u,published:a,allDay:d,publishedAt:p,updatedAt:c,read:h,mentions:l,statuses:b,tags:m,emojis:k,reactions:g}=t,y=new Date(p),T=rt(y),w=new Date(c),S=rt(w);return e("div",{class:"announcement-block",children:[e(Qe,{account:i}),e("div",{class:"announcement-content",onClick:Hi({mentions:l,instance:n}),dangerouslySetInnerHTML:{__html:Sn(r,{emojis:k})}}),e("p",{class:"insignificant",children:[e("time",{datetime:y.toISOString(),children:rt(y)}),c&&S!==T&&e(E,{children:[" ","•"," ",e("span",{class:"ib",children:["Updated"," ",e("time",{datetime:w.toISOString(),children:rt(w)})]})]})]}),e("div",{class:"announcement-reactions",hidden:!0,children:g.map(I=>{const{name:x,count:G,me:D,staticUrl:M,url:ee}=I;return e("button",{type:"button",class:`plain4 small ${D?"reacted":""}`,children:[ee||M?e("img",{src:ee||M,alt:x,width:"16",height:"16"}):e("span",{children:x})," ",e("span",{class:"count",children:je(G)})]})})})]})}function Fr(t){const{masto:n}=ne();return n.v1.notifications.list({accountID:t})}function Or({request:t}){var c;const{instance:n}=ne(),[s,i]=A("loading"),{account:o,lastStatus:r}=t,[f,u]=A(!1),[a,d]=A([]);function p(){u(!1)}return X(()=>{var h;(h=t==null?void 0:t.account)!=null&&h.id&&f&&(i("loading"),(async()=>{const l=await Fr(t.account.id);d(l||[]),i("default")})())},[f,(c=t==null?void 0:t.account)==null?void 0:c.id]),e(E,{children:[e("button",{type:"button",class:"plain4 request-notifications-account",onClick:()=>{u(!0)},children:[e(v,{icon:"notification",class:"more-insignificant"})," ",e("small",{children:["View notifications from @",o.username]})," ",e(v,{icon:"chevron-down"})]}),f&&e(Re,{onClick:h=>{h.target===h.currentTarget&&p()},children:e("div",{class:"sheet",tabIndex:"-1",children:[e("button",{type:"button",class:"sheet-close",onClick:p,children:e(v,{icon:"x"})}),e("header",{children:e("b",{children:["Notifications from @",o.username]})}),e("main",{children:s==="loading"?e("p",{class:"ui-state",children:e(Ae,{abrupt:!0})}):a.map(h=>e("div",{class:"notification-peek",onClick:l=>{const{target:b}=l;(l.target.tagName==="BUTTON"||l.target.tagName==="A")&&p()},children:e(mn,{instance:n,notification:h,isStatic:!0})}))})]})})]})}function zr({request:t,onChange:n}){const{masto:s}=ne(),[i,o]=A("default"),[r,f]=A(null),u=r!==null;return e("p",{class:"notification-request-buttons",children:[e("button",{type:"button",disabled:i==="loading"||u,onClick:()=>{o("loading"),(async()=>{try{await s.v1.notifications.requests.$select(t.id).accept(),f("accept"),o("default"),n({request:t,state:"accept"}),se(`Notifications from @${t.account.username} will not be filtered from now on.`)}catch{o("error"),se("Unable to accept notification request")}})()},children:"Allow"})," ",e("button",{type:"button",disabled:i==="loading"||u,class:"light danger",onClick:()=>{o("loading"),(async()=>{try{await s.v1.notifications.requests.$select(t.id).dismiss(),f("dismiss"),o("default"),n({request:t,state:"dismiss"}),se(`Notifications from @${t.account.username} will not show up in Filtered notifications from now on.`)}catch{o("error"),se("Unable to dismiss notification request")}})()},children:"Dismiss"}),e("span",{class:"notification-request-states",children:i==="loading"?e(Ae,{abrupt:!0}):r==="accept"?e(v,{icon:"check-circle",alt:"Accepted",class:"notification-accepted"}):r==="dismiss"&&e(v,{icon:"x-circle",alt:"Dismissed",class:"notification-dismissed"})})]})}const ks=Je(Pr),Br=20;function An({local:t,columnMode:n,...s}){const i=De($),o=!!t,r=n?{}:St(),{masto:f,instance:u}=ne({instance:(s==null?void 0:s.instance)||r.instance}),{masto:a,instance:d}=ne(),p=`${o?"Local":"Federated"} timeline (${u})`;qe(p,o?"/:instance?/p/l":"/:instance?/p");const c=H(),h=H();async function l(m){if(m||!h.current){const y={limit:Br,local:o||void 0};!o&&Ge("@pixelfed/global-feed")&&(y.remote=!0),h.current=f.v1.timelines.public.list(y)}const k=await h.current.next();let{value:g}=k;return g!=null&&g.length&&(m&&(c.current=g[0].id),g.forEach(y=>{He(y,u)})),{...k,value:g}}async function b(){var m;try{const k=await f.v1.timelines.public.list({limit:1,local:o,since_id:c.current}).next();let{value:g}=k;const y=((m=g[0])==null?void 0:m.id)===c.current;return g!=null&&g.length&&!y?(g=wt(g,"public"),!0):!1}catch{return!1}}return e(pt,{title:p,titleComponent:e("h1",{class:"header-double-lines",children:[e("b",{children:o?"Local timeline":"Federated timeline"}),e("div",{children:u})]}),id:"public",instance:u,emptyText:"No one has posted anything yet.",errorText:"Unable to load posts",fetchItems:l,checkForUpdates:b,useItemID:!0,headerStart:e(E,{}),boostsCarousel:i.settings.boostsCarousel,filterContext:"public",headerEnd:e(Ze,{portal:!0,overflow:"auto",viewScroll:"close",position:"anchor",menuButton:e("button",{type:"button",class:"plain",children:e(v,{icon:"more",size:"l"})}),children:[e(pe,{href:o?`/#/${u}/p`:`/#/${u}/p/l`,children:o?e(E,{children:[e(v,{icon:"transfer"})," ",e("span",{children:"Switch to Federated"})]}):e(E,{children:[e(v,{icon:"transfer"})," ",e("span",{children:"Switch to Local"})]})}),e(ze,{}),e(pe,{onClick:()=>{let m=prompt('Enter a new instance e.g. "mastodon.social"');if(!/\./.test(m)){m&&alert("Invalid instance");return}m&&(m=m.toLowerCase().trim(),location.hash=o?`/${m}/p/l`:`/${m}/p`)},children:[e(v,{icon:"bus"})," ",e("span",{children:"Go to another instance…"})]}),d!==u&&e(pe,{onClick:()=>{location.hash=o?`/${d}/p/l`:`/${d}/p`},children:[e(v,{icon:"bus"})," ",e("small",{class:"menu-double-lines",children:["Go to my instance (",e("b",{children:d}),")"]})]})]})},u+o)}const Qt=5,kn=40,Hr=new URLSearchParams;function Ss({columnMode:t,...n}){const s=t?{}:St(),{masto:i,instance:o,authenticated:r}=ne({instance:s.instance}),[f,u]=A("default"),[a]=t?[Hr]:ot(),d=H(),p=(n==null?void 0:n.query)||a.get("q"),c=t?"statuses":(n==null?void 0:n.type)||a.get("type");qe(p?`Search: ${p}${c?` (${{statuses:"Posts",accounts:"Accounts",hashtags:"Hashtags"}[c]})`:""}`:"Search","/search");const[h,l]=A(!1),b=H(0);X(()=>{b.current=0},[p,c]);const m=H();ut(()=>{var L,N;(N=(L=m.current)==null?void 0:L.scrollTo)==null||N.call(L,0,0)},[p,c]);const[k,g]=A([]),[y,T]=A([]),[w,S]=A([]);X(()=>{g([]),T([]),S([])},[p]);const I={statuses:g,accounts:T,hashtags:S},[x,G]=A({}),D=async L=>{if(!(L!=null&&L.length))return;const N=await Dn(L,x);N&&G({...x,...N})};function M(L){L&&(b.current=0),!(!L&&!r)&&(u("loading"),L&&!c&&(g(k.slice(0,Qt)),T(y.slice(0,Qt)),S(w.slice(0,Qt))),(async()=>{var _,U;const N={q:p,resolve:r,limit:Qt};c&&(N.limit=kn,N.type=c,r&&(N.offset=b.current));try{const j=await i.v2.search.fetch(N);if(c)if(L){I[c](j[c]);const ce=(_=j[c])==null?void 0:_.length;b.current=kn,l(!!ce)}else{I[c](O=>[...O,...j[c]]);const ce=(U=j[c])==null?void 0:U.length;b.current=b.current+kn,l(!!ce)}else g(j.statuses||[]),T(j.accounts||[]),S(j.hashtags||[]),b.current=0,l(!1);D(j.accounts),u("default")}catch{u("error")}})())}const ee=H();Lt(L=>{var _;const N=((_=m.current)==null?void 0:_.scrollTop)===0;if(L&&N){const U=Date.now()-ee.current;!ee.current||U>1e3*3?M(!0):ee.current=Date.now()}}),X(()=>{var L,N,_,U;(N=(L=d.current)==null?void 0:L.setValue)==null||N.call(L,p||""),p?M(!0):(U=(_=d.current)==null?void 0:_.focus)==null||U.call(_)},[p,c,o]),_e(["/","Slash"],L=>{var N,_,U,j;(_=(N=d.current)==null?void 0:N.focus)==null||_.call(N),(j=(U=d.current)==null?void 0:U.select)==null||j.call(U)},{preventDefault:!0});const[J]=Bn();return e("div",{id:"search-page",class:"deck-container",ref:m,children:e("div",{class:"timeline-deck deck",children:[e("header",{class:f==="loading"?"loading":"",children:e("div",{class:"header-grid",children:[e("div",{class:"header-side",children:e(Tt,{})}),e(us,{ref:d}),e("div",{class:"header-side",children:e("button",{type:"button",class:"plain",onClick:()=>{M(!0)},disabled:f==="loading",children:e(v,{icon:"search",size:"l"})})})]})}),e("main",{children:[!!p&&!t&&e("div",{ref:J,class:`filter-bar ${f==="loading"?"loading":""}`,children:[!!c&&e(re,{to:`/search${p?`?q=${encodeURIComponent(p)}`:""}`,children:"‹ All"}),[{label:"Accounts",type:"accounts",to:`/search?q=${encodeURIComponent(p)}&type=accounts`},{label:"Hashtags",type:"hashtags",to:`/search?q=${encodeURIComponent(p)}&type=hashtags`},{label:"Posts",type:"statuses",to:`/search?q=${encodeURIComponent(p)}&type=statuses`}].sort((L,N)=>L.type===c?-1:N.type===c?1:0).map(L=>e(re,{to:L.to,children:L.label},L.type))]}),p?e(E,{children:[(!c||c==="accounts")&&e(E,{children:[c!=="accounts"&&e("h2",{class:"timeline-header",children:["Accounts"," ",e(re,{to:`/search?q=${encodeURIComponent(p)}&type=accounts`,children:e(v,{icon:"arrow-right",size:"l"})})]}),y.length>0?e(E,{children:[e("ul",{class:"timeline flat accounts-list",children:y.map(L=>e("li",{children:e(Qe,{account:L,instance:o,showStats:!0,relationship:x[L.id]})},L.id))}),c!=="accounts"&&e("div",{class:"ui-state",children:e(re,{class:"plain button",to:`/search?q=${encodeURIComponent(p)}&type=accounts`,children:["See more accounts ",e(v,{icon:"arrow-right"})]})})]}):!c&&(f==="loading"?e("p",{class:"ui-state",children:e(Ae,{abrupt:!0})}):e("p",{class:"ui-state",children:"No accounts found."}))]}),(!c||c==="hashtags")&&e(E,{children:[c!=="hashtags"&&e("h2",{class:"timeline-header",children:["Hashtags"," ",e(re,{to:`/search?q=${encodeURIComponent(p)}&type=hashtags`,children:e(v,{icon:"arrow-right",size:"l"})})]}),w.length>0?e(E,{children:[e("ul",{class:"link-list hashtag-list",children:w.map(L=>{var j;const{name:N,history:_}=L,U=(j=_==null?void 0:_.reduce)==null?void 0:j.call(_,(ce,O)=>ce+ +O.uses,0);return e("li",{children:e(re,{to:o?`/${o}/t/${N}`:`/t/${N}`,children:[e(v,{icon:"hashtag"}),e("span",{children:N}),!!U&&e("span",{class:"count",children:je(U)})]})},`${N}-${U}`)})}),c!=="hashtags"&&e("div",{class:"ui-state",children:e(re,{class:"plain button",to:`/search?q=${encodeURIComponent(p)}&type=hashtags`,children:["See more hashtags ",e(v,{icon:"arrow-right"})]})})]}):!c&&(f==="loading"?e("p",{class:"ui-state",children:e(Ae,{abrupt:!0})}):e("p",{class:"ui-state",children:"No hashtags found."}))]}),(!c||c==="statuses")&&e(E,{children:[c!=="statuses"&&e("h2",{class:"timeline-header",children:["Posts"," ",e(re,{to:`/search?q=${encodeURIComponent(p)}&type=statuses`,children:e(v,{icon:"arrow-right",size:"l"})})]}),k.length>0?e(E,{children:[e("ul",{class:"timeline",children:k.map(L=>e("li",{children:e(re,{class:"status-link",to:o?`/${o}/s/${L.id}`:`/s/${L.id}`,children:e(Be,{status:L})})},L.id))}),c!=="statuses"&&e("div",{class:"ui-state",children:e(re,{class:"plain button",to:`/search?q=${encodeURIComponent(p)}&type=statuses`,children:["See more posts ",e(v,{icon:"arrow-right"})]})})]}):!c&&(f==="loading"?e("p",{class:"ui-state",children:e(Ae,{abrupt:!0})}):e("p",{class:"ui-state",children:"No posts found."}))]}),!!c&&(f==="default"?h?e(ht,{onChange:L=>{L&&M()},children:e("button",{type:"button",class:"plain block",onClick:()=>M(),style:{marginBlockEnd:"6em"},children:"Show more…"})}):e("p",{class:"ui-state insignificant",children:"The end."}):f==="loading"&&e("p",{class:"ui-state",children:e(Ae,{abrupt:!0})}))]}):f==="loading"?e("p",{class:"ui-state",children:e(Ae,{abrupt:!0})}):e("p",{class:"ui-state",children:"Enter your search term or paste a URL above to get started."})]})]})})}const qr=20,Is=10*60*1e3,Vr=ft(t=>t.v1.trends.links.list().next(),{maxAge:Is}),Gr=ft(t=>t.v1.trends.tags.list().next(),{maxAge:Is});function jr(t){return Ge("@pixelfed/trending")?t.pixelfed.v2.discover.posts.trending.list({range:"daily"}):t.v1.trends.statuses.list({limit:qr})}function Yr(t,n){return t.v1.timelines.link.list(n)}function Cs({columnMode:t,...n}){const s=De($),i=t?{}:St(),{masto:o,instance:r}=ne({instance:(n==null?void 0:n.instance)||i.instance}),{masto:f,instance:u}=ne(),a=`Trending (${r})`;qe(a,"/:instance?/trending");const d=H(),p=r===u,[c,h]=A([]),[l,b]=A([]),m=H();async function k(L){var U;if(L||!m.current){if(m.current=jr(o),Ge("@mastodon/trending-hashtags"))try{const{value:j}=await Gr(o);j!=null&&j.length&&h(j)}catch{}if(Ge("@mastodon/trending-links"))try{const{value:j}=await Vr(o,r),ce=(U=j==null?void 0:j.filter)==null?void 0:U.call(j,O=>O.type==="link");ce!=null&&ce.length&&b(ce)}catch{}}const N=await m.current.next();let{value:_}=N;return _!=null&&_.length&&(L&&(d.current=_[0].id),_.forEach(j=>{He(j,r)})),{...N,value:_}}const[g,y]=A(!1),T=H(),[w,S]=A(null),I=!!w,x=H(),G=p&&Ge("@mastodon/trending-hashtags");X(()=>{w&&x.current&&x.current.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})},[w]);const D=H();async function M(L){(L||!T.current)&&(y(!0),T.current=Yr(o,{url:w})),D.current=w;const N=await T.current.next();let{value:_}=N;return _!=null&&_.length&&(_=wt(_,"public"),_.forEach(U=>{He(U,r)})),D.current===w&&y(!1),{...N,value:_}}async function ee(){try{const L=await o.v1.trends.statuses.list({limit:1}).next();let{value:N}=L;return N=wt(N,"public"),N!=null&&N.length&&N[0].id!==d.current?(d.current=N[0].id,!0):!1}catch{return!1}}const J=ge(()=>e(E,{children:[!!c.length&&e("div",{class:"filter-bar expandable",children:[e(v,{icon:"chart",class:"insignificant",size:"l"}),c.map((L,N)=>{const{name:_,history:U}=L,j=U.reduce((ce,O)=>ce+ +O.uses,0);return e(re,{to:`/${r}/t/${_}`,children:[e("span",{children:[e("span",{class:"more-insignificant",children:"#"}),_]}),e("span",{class:"filter-count",children:je(j)})]},_)})]}),!!l.length&&e("div",{class:"links-bar",children:[e("header",{children:e("h3",{children:"Trending News"})}),l.map(L=>{const{authorName:N,authorUrl:_,blurhash:U,description:j,height:ce,image:O,imageDescription:ie,language:V,providerName:de,providerUrl:he,publishedAt:oe,title:be,url:Ce,width:Ie}=L,Le=Ut.toUnicode(URL.parse(Ce).hostname.replace(/^www\./,"").replace(/\/$/,""));let Pe;if(U){const $e=Pn(U),Se=Gn($e);Pe=jn([.6,Se[1],Se[2]])}return e("div",{children:[e("a",{ref:w===Ce?x:null,href:Ce,target:"_blank",rel:"noopener noreferrer",class:I?w===Ce?"active":"inactive":"",style:Pe?{"--accent-color":`rgb(${Pe.join(",")})`,"--accent-alpha-color":`rgba(${Pe.join(",")}, 0.4)`}:{},children:e("article",{children:[e("figure",{children:e("img",{src:O,alt:ie,width:Ie,height:ce,loading:"lazy"})}),e("div",{class:"article-body",children:[e("header",{children:[e("div",{class:"article-meta",children:[e("span",{class:"domain",children:Le})," ",!!oe&&e(E,{children:"· "}),!!oe&&e(E,{children:e(It,{datetime:oe,format:"micro"})})]}),!!be&&e("h1",{class:"title",lang:V,dir:"auto",title:be,children:be})]}),!!j&&e("p",{class:"description",lang:V,dir:"auto",title:j,children:j})]})]})}),G&&e("button",{type:"button",class:"small plain4 block",onClick:()=>{S(Ce)},disabled:Ce===w,children:[e(v,{icon:"comment2"})," ",e("span",{children:"Mentions"})," ",e(v,{icon:"chevron-down"})]})]},Ce)})]}),G&&!!l.length&&e("div",{class:`timeline-header-block ${I?"blended":""}`,children:I?e(E,{children:[e("div",{style:{width:50,flexShrink:0,textAlign:"center"},children:g?e(Ae,{abrupt:!0}):e("button",{type:"button",class:"light",onClick:()=>{S(null)},children:e(v,{icon:"x"})})}),e("p",{children:["Showing posts mentioning"," ",e("span",{class:"link-text",children:w.replace(/^https?:\/\/(www\.)?/i,"").replace(/\/$/,"")})]})]}):e("p",{class:"insignificant",children:"Trending posts"})})]}),[c,l,w,g]);return e(pt,{title:a,titleComponent:e("h1",{class:"header-double-lines",children:[e("b",{children:"Trending"}),e("div",{children:r})]}),id:"trending",instance:r,emptyText:"No trending posts.",errorText:"Unable to load posts",fetchItems:I?M:k,checkForUpdates:I?void 0:ee,checkForUpdatesInterval:5*60*1e3,useItemID:!0,headerStart:e(E,{}),boostsCarousel:s.settings.boostsCarousel,filterContext:"public",timelineStart:J,refresh:w,clearWhenRefresh:!0,view:I?"link-mentions":void 0,headerEnd:e(Ze,{portal:!0,overflow:"auto",viewScroll:"close",position:"anchor",menuButton:e("button",{type:"button",class:"plain",children:e(v,{icon:"more",size:"l"})}),children:[e(pe,{onClick:()=>{let L=prompt('Enter a new instance e.g. "mastodon.social"');if(!/\./.test(L)){L&&alert("Invalid instance");return}L&&(L=L.toLowerCase().trim(),location.hash=`/${L}/trending`)},children:[e(v,{icon:"bus"})," ",e("span",{children:"Go to another instance…"})]}),u!==r&&e(pe,{onClick:()=>{location.hash=`/${u}/trending`},children:[e(v,{icon:"bus"})," ",e("small",{class:"menu-double-lines",children:["Go to my instance (",e("b",{children:u}),")"]})]})]})},r)}function Wr(){qe("Home","/");const t=De($),{shortcuts:n}=t,s=n.map(i=>{if(!i)return null;const{type:o,...r}=i,f={following:Kn,notifications:ks,list:bs,public:An,bookmarks:fs,favourites:ps,hashtag:gs,mentions:vs,trending:Cs,search:Ss}[o];return!f||o==="search"&&!r.query||o==="list"&&!r.id?null:e(f,{...r,columnMode:!0},o+JSON.stringify(r))});return _e(["1","2","3","4","5","6","7","8","9"],(i,o)=>{try{const r=parseInt(o.keys[0],10)-1;document.querySelectorAll("#columns > *")[r].focus()}catch{}}),e("div",{id:"columns",onContextMenu:i=>{i.target.closest(".deck > header")&&!i.target.closest("a")&&!i.target.closest("button")&&(i.preventDefault(),$.showShortcutsSettings=!0)},children:s})}function Kr(){var n;const t=De($);return X(()=>{(async()=>{const s=await it.drafts.keys();if(s.length){const i=rn();s.filter(r=>r.startsWith(i)).length&&($.showDrafts=!0)}})()},[]),e(E,{children:(t.settings.shortcutsViewMode==="multi-column"||!t.settings.shortcutsViewMode&&t.settings.shortcutsColumnsMode)&&((n=t.shortcuts)!=null&&n.length)?e(Wr,{}):e(Kn,{title:"Home",path:"/",id:"home",headerStart:!1,headerEnd:e(Xr,{})})})}function Xr(){const t=De($),n=H(),[s,i]=A(void 0);return e(E,{children:[e(re,{ref:n,to:"/notifications",class:`button plain notifications-button ${t.notificationsShowNew?"has-badge":""} ${s||""}`,onClick:o=>{o.stopPropagation(),window.matchMedia("(min-width: calc(40em))").matches&&(o.preventDefault(),i(r=>r?void 0:"open"))},children:e(v,{icon:"notification",size:"l",alt:"Notifications"})}),e(Qr,{state:s,anchorRef:n,onClose:()=>i(void 0)})]})}const Zr=80,Jr=5;function Qr({anchorRef:t,state:n,onClose:s}){const{masto:i,instance:o}=ne(),r=De($),[f,u]=A("default"),a=i.v1.notifications.list({limit:Zr});async function d(){const b=await a.next(),m=b.value;if(m!=null&&m.length){m.forEach(g=>{He(g.status,o,{skipThreading:!0})});const k=ws(m);$.notificationsLast=m[0],$.notifications=k,i.v1.markers.create({notifications:{lastReadId:m[0].id}}).catch(()=>{})}return $.notificationsShowNew=!1,$.notificationsLastFetchTime=Date.now(),b}const[p,c]=A(!1);function h(){return i.v1.followRequests.list({limit:1})}function l(){u("loading"),(async()=>{try{await d();const b=await h();c(!!(b!=null&&b.length)),u("default")}catch{u("error")}})()}return X(()=>{n==="open"&&l()},[n]),e(Yi,{menuClassName:"notifications-menu",state:n,anchorRef:t,onClose:s,portal:{target:document.body},overflow:"auto",viewScroll:"close",position:"anchor",align:"center",boundingBoxPadding:"8 8 8 8",children:[e("header",{children:e("h2",{children:"Notifications"})}),e("main",{children:r.notifications.length?e(E,{children:r.notifications.slice(0,Jr).map(b=>e(mn,{instance:o,notification:b,disableContextMenu:!0},b.id))}):f==="loading"?e("div",{class:"ui-state",children:e(Ae,{abrupt:!0})}):f==="error"&&e("div",{class:"ui-state",children:[e("p",{children:"Unable to fetch notifications."}),e("p",{children:e("button",{type:"button",onClick:l,children:"Try again"})})]})}),e("footer",{children:[e(re,{to:"/mentions",class:"button plain",children:[e(v,{icon:"at"})," ",e("span",{children:"Mentions"})]}),e(re,{to:"/notifications",class:"button plain2",children:[p?e(E,{children:[e("span",{class:"tag collapsed",children:"New"})," ",e("span",{children:"Follow Requests"})]}):e("b",{children:"See all"})," ",e(v,{icon:"arrow-right"})]})]})]})}const ec=Je(Kr),tc=[/^\/@[^@\/]+\/(?:statuses|posts)\/([^\/]+)/i,/\/notes\/([^\/]+)/i,/^\/(?:notice|objects)\/([a-z0-9-]+)/i,/\/@[^@\/]+@?[^\/]+?\/([^\/]+)/i,/^\/p\/[^\/]+\/([^\/]+)/i];function Ts(t){const{hostname:n,pathname:s}=URL.parse(t);for(const i of tc){const[,o]=s.match(i)||[];if(o)return{instance:n,id:o}}return{}}function nc(t){const{instance:n,id:s}=Ts(t);return n&&s?`/${n}/s/${s}`:null}function ic(){const n=Nt().pathname.replace(/^\//,""),s=Ts(n),i=s!=null&&s.instance?`/${s.instance}/s/${s.id}`:null,[o,r]=A("loading");return ut(()=>{r("loading"),(async()=>{try{const{instance:f,id:u}=s,{masto:a}=ne({instance:f});if(await a.v1.statuses.$select(u).fetch()){window.location.hash=i+"?view=full";return}}catch{}{const{masto:f,instance:u}=ne(),a=await f.v2.search.fetch({q:n,limit:1,resolve:!0});if(a.statuses.length){const d=a.statuses[0];window.location.hash=`/${u}/s/${d.id}?view=full`}else if(a.accounts.length){const d=a.accounts[0];window.location.hash=`/${u}/a/${d.id}`}else i?window.location.hash=i+"?view=full":r("error")}})()},[i]),e("div",{class:"ui-state",tabIndex:"-1",children:[o==="loading"?e(E,{children:[e(Ae,{abrupt:!0}),e("h2",{children:"Resolving…"}),e("p",{children:e("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:n})})]}):e(E,{children:[e("h2",{children:"Unable to resolve URL"}),e("p",{children:e("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:n})})]}),e("hr",{}),e("p",{children:e(re,{to:"/",children:"Go home"})})]})}function sc(){qe("Lists","/l");const[t,n]=A("default"),[s,i]=kt(a=>a+1,0),[o,r]=A([]);X(()=>{n("loading"),(async()=>{try{const a=await xn();r(a),n("default")}catch{n("error")}})()},[s]);const[f,u]=A(!1);return e("div",{id:"lists-page",class:"deck-container",tabIndex:"-1",children:[e("div",{class:"timeline-deck deck",children:[e("header",{children:e("div",{class:"header-grid",children:[e("div",{class:"header-side",children:[e(Tt,{}),e(re,{to:"/",class:"button plain",children:e(v,{icon:"home",size:"l"})})]}),e("h1",{children:"Lists"}),e("div",{class:"header-side",children:e("button",{type:"button",class:"plain",onClick:()=>u(!0),children:e(v,{icon:"plus",size:"l",alt:"New list"})})})]})}),e("main",{children:o.length>0?e(E,{children:[e("ul",{class:"link-list",children:o.map(a=>e("li",{children:e(re,{to:`/l/${a.id}`,children:e("span",{children:[e(v,{icon:"list"})," ",e("span",{children:a.title})]})})}))}),o.length>1&&e("footer",{class:"ui-state",children:e("small",{class:"insignificant",children:[o.length," list",o.length===1?"":"s"]})})]}):t==="loading"?e("p",{class:"ui-state",children:e(Ae,{})}):t==="error"?e("p",{class:"ui-state",children:"Unable to load lists."}):e("p",{class:"ui-state",children:"No lists yet."})})]}),f&&e(Re,{onClick:a=>{a.target===a.currentTarget&&u(!1)},children:e(Vn,{list:f==null?void 0:f.list,onClose:a=>{a.state==="success"&&i(),u(!1)}})})]})}const oc=""+new URL("instances-MzK7fGXv.json",import.meta.url).href;var ac={PHANPY_CLIENT_NAME:"Phanpy",PHANPY_WEBSITE:"https://phanpy.social",PHANPY_LINGVA_INSTANCES:"lingva.phanpy.social lingva.lunar.icu lingva.garudalinux.org translate.plausibility.cloud",PHANPY_PRIVACY_POLICY_URL:"https://github.com/cheeaun/phanpy/blob/main/PRIVACY.MD",VITE_APP_ENV:"production",BASE_URL:"./",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const{PHANPY_CLIENT_NAME:rc,PHANPY_WEBSITE:cc}=ac,Xn="read write follow push";async function lc({instanceURL:t}){const n=new URLSearchParams({client_name:rc,redirect_uris:location.origin+location.pathname,scopes:Xn,website:cc});return await(await fetch(`https://${t}/api/v1/apps`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:n.toString()})).json()}async function dc({instanceURL:t,client_id:n}){const s=new URLSearchParams({client_id:n,scope:Xn,redirect_uri:location.origin+location.pathname,response_type:"code"});return`https://${t}/oauth/authorize?${s.toString()}`}async function uc({instanceURL:t,client_id:n,client_secret:s,code:i}){const o=new URLSearchParams({client_id:n,client_secret:s,redirect_uri:location.origin+location.pathname,grant_type:"authorization_code",code:i,scope:Xn});return await(await fetch(`https://${t}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:o.toString()})).json()}var hc={PHANPY_CLIENT_NAME:"Phanpy",PHANPY_WEBSITE:"https://phanpy.social",PHANPY_LINGVA_INSTANCES:"lingva.phanpy.social lingva.lunar.icu lingva.garudalinux.org translate.plausibility.cloud",PHANPY_PRIVACY_POLICY_URL:"https://github.com/cheeaun/phanpy/blob/main/PRIVACY.MD",VITE_APP_ENV:"production",BASE_URL:"./",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const{PHANPY_DEFAULT_INSTANCE:fc}=hc;function pc(){var y,T;qe("Log in");const t=H(),n=we.local.get("instanceURL"),[s,i]=A("default"),[o]=ot(),r=o.get("instance"),f=o.get("submit"),[u,a]=A(r||(n==null?void 0:n.toLowerCase())||""),[d,p]=A([]),c=H();X(()=>{(async()=>{try{const S=await(await fetch(oc)).json();p(S),c.current=new no(S)}catch{}})()},[]);const h=w=>{w&&(we.local.set("instanceURL",w),(async()=>{i("loading");try{const{client_id:S,client_secret:I,vapid_key:x}=await lc({instanceURL:w});S&&I?(we.session.set("clientID",S),we.session.set("clientSecret",I),we.session.set("vapidKey",x),location.href=await dc({instanceURL:w,client_id:S})):alert("Failed to register application"),i("default")}catch{i("error")}})())},l=u?u.replace(/^https?:\/\//,"").replace(/\/+$/,"").replace(/^@?[^@]+@/,"").trim():null,b=/[^\s\r\n\t\/\\]+\.[^\s\r\n\t\/\\]+/.test(l)&&!/[\s\/\\@]/.test(l),m=l?(T=(y=c.current)==null?void 0:y.search(l,{limit:10}))==null?void 0:T.map(w=>w.item):[],k=b?l:m!=null&&m.length?m[0]:u?d.find(w=>w.includes(u)):null,g=w=>{w.preventDefault(),h(k)};return f&&X(()=>{h(r||k)},[]),e("main",{id:"login",style:{textAlign:"center"},children:e("form",{onSubmit:g,children:[e("h1",{children:[e("img",{src:Hn,alt:"",width:"80",height:"80"}),e("br",{}),"Log in"]}),e("label",{children:[e("p",{children:"Instance"}),e("input",{value:u,required:!0,type:"text",class:"large",id:"instanceURL",ref:t,disabled:s==="loading",autocorrect:"off",autocapitalize:"off",autocomplete:"off",spellCheck:!1,placeholder:"instance domain",onInput:w=>{a(w.target.value)}}),(m==null?void 0:m.length)>0?e("ul",{id:"instances-suggestions",children:m.map((w,S)=>e("li",{children:e("button",{type:"button",class:"plain5",onClick:()=>{h(w)},children:w})}))}):e("div",{id:"instances-eg",children:"e.g. “mastodon.social”"})]}),s==="error"&&e("p",{class:"error",children:"Failed to log in. Please try again or another instance."}),e("div",{children:[e("button",{disabled:s==="loading"||!u||!k,children:k?`Continue with ${k}`:"Continue"})," "]}),e(Ae,{hidden:s!=="loading"}),e("hr",{}),!fc&&e("p",{children:e("a",{href:"https://joinmastodon.org/servers",target:"_blank",children:"Don't have an account? Create one!"})}),e("p",{children:e(re,{to:"/",children:"Go home"})})]})})}const en=40,mc=10,gc=5;let Rn={},sn={},on={};function an(t){delete sn[t],delete on[t]}const Ot={block:"nearest",inline:"center",behavior:"smooth"},Ai=".status-link:not(details:not([open]) > summary ~ *, details:not([open]) > summary ~ * *), .status-focus:not(details:not([open]) > summary ~ *, details:not([open]) > summary ~ * *)",Ri=/\/s\//i;function bc(t){var w;const{id:n}=t,{masto:s,instance:i}=ne({instance:t.instance}),o=De($),[r,f]=ot(),u=r.get("media"),a=r.get("media-only"),d=parseInt(u||a,10);let p=d>0;const c=r.get("mediaStatusID"),h=zi(c,i);c&&!h&&(p=!1);const l=p&&!!a,b=Xe(n,i),[m,k]=A($.statuses[b]);X(()=>{$.statuses[b]&&k($.statuses[b])},[b]);const g=ge(()=>{const{prevLocation:S}=$,I=((S==null?void 0:S.pathname)||"")+((S==null?void 0:S.search)||""),x=qt("/:instance/s/:id",I)||qt("/s/:id",I);return!I||x?"/":I},[]);X(()=>{!m&&p&&(async()=>{try{const S=await s.v1.statuses.$select(n).fetch();He(S,i),k(S)}catch{alert("Unable to load post."),location.hash=g}})()},[p]);const y=c?(w=o.statuses[Xe(c,i)])==null?void 0:w.mediaAttachments:m==null?void 0:m.mediaAttachments,T=et(()=>{!window.matchMedia("(min-width: calc(40em + 350px))").matches&&o.prevLocation?history.back():l?location.hash=g:(r.delete("media"),r.delete("mediaStatusID"),f(r))},[l,g,o.prevLocation]);return X(()=>{let S=setTimeout(()=>{const I=document.querySelector(".carousel");I&&I.focus()},100);return()=>clearTimeout(S)},[l]),X(()=>{const S=document.querySelectorAll(".deck-container");return S.forEach(I=>{I.setAttribute("inert","")}),()=>{S.forEach(I=>{I.removeAttribute("inert")})}},[]),e("div",{class:"deck-backdrop",children:[p?y!=null&&y.length?e(ls,{mediaAttachments:y,statusID:c||n,instance:i,lang:m==null?void 0:m.language,index:d-1,onClose:T}):e("div",{class:"media-modal-container loading",children:e(Ae,{abrupt:!0})}):e(re,{to:g}),!l&&e(wc,{id:n,instance:t.instance,closeLink:g})]})}function yc(t){const{linkable:n,to:s,onClick:i,...o}=t;return n?e(re,{class:"status-link",to:s,onClick:i,...o}):e("div",{class:"status-focus",tabIndex:0,...o})}function wc({id:t,closeLink:n="/",instance:s}){var P,Y;const[i,o]=ot(),r=i.get("media"),f=i.get("mediaStatusID"),u=parseInt(r,10)>0,a=H(!$.prevLocation&&(history.length===1||"navigation"in window&&((Y=(P=navigation==null?void 0:navigation.entries)==null?void 0:P.call(navigation))==null?void 0:Y.length)===1)),[d,p]=A(i.get("view")||a.current?"full":null),c=!!parseInt(i.get("translate")),{masto:h,instance:l}=ne({instance:s}),{masto:b,instance:m,authenticated:k}=ne(),g=l===m,y=De($),[T,w]=A([]),[S,I]=A("default"),x=H(),G=Xe(t,l),D=H(0),M=H();X(()=>{var R;(R=M.current)==null||R.focus()},[]),X(()=>{var q;const R=Xi(()=>{if(!M.current)return;const{scrollTop:Z}=M.current;S!=="loading"&&(on[t]=Z)},50);return(q=M.current)==null||q.addEventListener("scroll",R,{passive:!0}),R(),()=>{var Z;R.cancel(),(Z=M.current)==null||Z.removeEventListener("scroll",R)}},[t,S!=="loading"]);const ee=H(),J=H(),L=({reloadHero:R}={})=>{I("loading");let q;const Z=sn[t];if(Z){const ue=Z.filter(Ne=>$.statuses[G]);w(ue)}else w([{id:t}]);return(async()=>{var W,B;const ue=()=>si(()=>h.v1.statuses.$select(t).fetch(),{retries:4}),Ne=si(()=>h.v1.statuses.$select(t).context.fetch(),{retries:8}),C=!!y.statuses[G];let F=y.statuses[G];if(!(C&&!R))try{F=await ue(),He(F,l),await new Promise(Q=>{setTimeout(Q,100)})}catch{I("error");return}try{let Q=function(K){return K==null?void 0:K.map(ke=>({id:ke.id,account:ke.account,repliesCount:ke.repliesCount,content:ke.content,weight:Ht(ke),replies:Q(ke.__replies)}))};const ye=await Ne,{ancestors:fe,descendants:ae}=ye;D.current=(ae==null?void 0:ae.length)||0;const xe=new Set;fe.forEach(K=>{He(K,l,{skipThreading:!0}),K.inReplyToId&&!fe.find(ke=>ke.id===K.inReplyToId)&&xe.add(K.inReplyToId)});const Ue=fe.every(K=>K.account.id===F.account.id),Oe=[];ae.forEach(K=>{if(He(K,l,{skipThreading:!0}),K.inReplyToId&&!ae.find(ke=>ke.id===K.inReplyToId)&&K.inReplyToId!==F.id&&xe.add(K.inReplyToId),K.inReplyToAccountId===K.account.id)Oe.push(K);else if(K.inReplyToId===F.id)Oe.push(K);else if(!K.inReplyToAccountId&&Oe.find(ke=>ke.id===K.inReplyToId)&&K.account.id===F.account.id)Oe.push(K);else{const ke=ae.find(nt=>nt.id===K.inReplyToId);ke&&(ke.__replies||(ke.__replies=[]),ke.__replies.push(K))}}),xe.size;const Me=[...fe.map(K=>({id:K.id,ancestor:!0,isThread:Ue,accountID:K.account.id,account:K.account,repliesCount:K.repliesCount,weight:Ht(K)})),{id:t,accountID:F.account.id,weight:Ht(F)},...Oe.map(K=>({id:K.id,account:K.account,accountID:K.account.id,descendant:!0,thread:K.account.id===F.account.id,weight:Ht(K),replies:Q(K.__replies)}))];I("default"),ee.current={offsetTop:(W=x.current)==null?void 0:W.offsetTop,scrollTop:(B=M.current)==null?void 0:B.scrollTop};const Ve=Me.findIndex(K=>K.id===t);Ve>=V&&de(Ve+1),w(Me),sn[t]=Me,Ns(F,l)}catch{I("error")}})(),J.current=Date.now(),()=>{clearTimeout(q)}};X(L,[t,h]);const[N,_]=A(!1);X(()=>{let R=setInterval(()=>{const q=Date.now();J.current&&q-J.current>=6e4&&_(!0)},6e4);return()=>{clearInterval(R)}},[]),ut(()=>{var q,Z;if(!T.length)return;const R=on[t];if(R)M.current.scrollTop=R;else if(ee.current){const ue={offsetTop:(q=x.current)==null?void 0:q.offsetTop,scrollTop:(Z=M.current)==null?void 0:Z.scrollTop},Ne=ue.offsetTop-ee.current.offsetTop+ue.scrollTop;M.current.scrollTop=Ne}else T.length===1&&(M.current.scrollTop=0);ee.current=null},[T]),X(()=>{y.reloadStatusPage<=0||(async()=>{try{const{instanceURL:R}=Et(),q=`https://${R}/api/v1/statuses/${t}/context`;return await(await caches.open("api")).delete(q,{ignoreVary:!0}),L({reloadHero:!0})}catch{}})()},[y.reloadStatusPage]),X(()=>()=>{on={},$.reloadStatusPage=0,sn={},Rn={},En.clear()},[]);const U=y.statuses[G]||y.statuses[t],j=ge(()=>{if(!U)return"";const{account:R}=U,q=document.createElement("div");return q.innerHTML=R.displayName,q.innerText.trim()},[U]),ce=ge(()=>{if(!U)return"";let R=Nn(U);return R.length>64&&(R=R.slice(0,64)+"…"),R},[U]);qe(j&&ce?`${j}: "${ce}"`:"Status","/:instance?/s/:id");const O=ge(()=>{if(!U)return;const{url:R}=U;if(R)return URL.parse(R).hostname},[U]),ie=ge(()=>{if(O)return O===l},[O,l]),[V,de]=A(en),he=ge(()=>T.length-V,[T.length,V]),oe=T.some(R=>R.descendant),be=T.filter(R=>R.ancestor),[Ce,Ie]=A(!0),Le=ge(()=>{if(!x.current||Ce)return null;const{top:R}=x.current.getBoundingClientRect();return R>0?"down":"up"},[Ce]);_e("esc",()=>{location.hash=n},{enabled:!u,ignoreEventWhen:R=>!!document.querySelector("#modal-container > *")}),_e("backspace",()=>{location.hash=n}),_e("j",()=>{const R=document.activeElement.closest(".status-link, .status-focus"),q=R==null?void 0:R.getBoundingClientRect(),Z=Array.from(M.current.querySelectorAll(Ai));if(R&&q.top0){const ue=Z.indexOf(R);let Ne=Z[ue+1];Ne&&(Ne.focus(),Ne.scrollIntoView(Ot))}else{const ue=Z.find(Ne=>{const C=Ne.getBoundingClientRect();return C.top>=44&&C.left>=0});ue&&(ue.focus(),ue.scrollIntoView(Ot))}}),_e("k",()=>{const R=document.activeElement.closest(".status-link, .status-focus"),q=R==null?void 0:R.getBoundingClientRect(),Z=Array.from(M.current.querySelectorAll(Ai));if(R&&q.top0){const ue=Z.indexOf(R);let Ne=Z[ue-1];Ne&&(Ne.focus(),Ne.scrollIntoView(Ot))}else{const ue=Z.find(Ne=>{const C=Ne.getBoundingClientRect();return C.top>=44&&C.left>=0});ue&&(ue.focus(),ue.scrollIntoView(Ot))}}),_e("x",()=>{const R=document.activeElement.closest(".status-link, .status-focus");if(R){const q=R.nextElementSibling;q&&q.tagName.toLowerCase()==="details"&&(q.open=!q.open)}});const[Pe,$e]=A(!1),Se=H(u?"media+status":"status"),Te=et((R,q,Z,ue)=>{R.preventDefault(),R.stopPropagation(),o({media:q+1,mediaStatusID:ue.id})},[t]),ve=et((R,q)=>{an(q.id)},[]);X(()=>{let R;return f&&u&&(R=setTimeout(()=>{var Z;const q=(Z=M.current)==null?void 0:Z.querySelector(`.status-link[href*="/${f}"]`);q&&q.scrollIntoView(Ot)},400)),()=>{clearTimeout(R)}},[f,u]);const te=et((R,q)=>{const{id:Z,ancestor:ue,isThread:Ne,descendant:C,thread:F,replies:W,repliesCount:B,weight:Q}=R,ye=Z===t;return e("li",{ref:ye?x:null,class:`${ue?"ancestor":""} ${C?"descendant":""} ${F?"thread":""} ${ye?"hero":""}`,children:[ye?e(E,{children:[e(ht,{threshold:.1,onChange:ae=>{queueMicrotask(()=>{requestAnimationFrame(()=>{Ie(ae)})})},class:"status-focus",tabIndex:0,children:e(Be,{statusID:Z,instance:l,withinContext:!0,size:"l",enableTranslate:!0,forceTranslate:c})}),S!=="loading"&&!k?e("div",{class:"post-status-banner",children:[e("p",{children:"You're not logged in. Interactions (reply, boost, etc) are not possible."}),e(re,{to:"/login",class:"button",children:"Log in"})]}):!g&&e("div",{class:"post-status-banner",children:[e("p",{children:["This post is from another instance (",e("b",{children:l}),"). Interactions (reply, boost, etc) are not possible."]}),e("button",{type:"button",disabled:S==="loading",onClick:()=>{I("loading"),(async()=>{try{const ae=await b.v2.search.fetch({q:U.url,type:"statuses",resolve:!0,limit:1});if(ae.statuses.length){const xe=ae.statuses[0];location.hash=m?`/${m}/s/${xe.id}`:`/s/${xe.id}`}else throw new Error("No results")}catch(ae){I("default"),alert("Error: "+ae)}})()},children:[e(v,{icon:"transfer"})," Switch to my instance to enable interactions"]})]})]}):e(yc,{linkable:Ne||ue,to:l?`/${l}/s/${Z}`:`/s/${Z}`,onClick:()=>{an(Z)},children:[q===0&&ue?e(ht,{threshold:.5,onChange:ae=>{queueMicrotask(()=>{requestAnimationFrame(()=>{$e(ae)})})},children:e(Be,{statusID:Z,instance:l,withinContext:!0,size:F||ue?"m":"s",enableTranslate:!0,onMediaClick:Te,onStatusLinkClick:ve})}):e(Be,{statusID:Z,instance:l,withinContext:!0,size:F||ue?"m":"s",enableTranslate:!0,onMediaClick:Te,onStatusLinkClick:ve,showActionsBar:!!C}),ue&&B>1&&e("div",{class:"replies-link",children:[e(v,{icon:"comment2"})," ",e("span",{title:B,children:je(B)})]})," "]}),C&&(W==null?void 0:W.length)>0&&e(xs,{instance:l,replies:W,hasParentThread:F,level:1,accWeight:Q,openAll:D.currentan(Z)}}),S==="loading"&&ye&&!!(U!=null&&U.repliesCount)&&!oe&&e("div",{class:"status-loading",children:e(Ae,{abrupt:U.repliesCount>=3})}),S==="error"&&ye&&!!(U!=null&&U.repliesCount)&&!oe&&e("div",{class:"status-error",children:["Unable to load replies.",e("br",{}),e("button",{type:"button",class:"plain",onClick:()=>{$.reloadStatusPage++},children:"Try again"})]})]},Z)},[t,l,S,k,g,c,Te,ve,oe]),me=ge(()=>{var R;if("navigation"in window&&(navigation!=null&&navigation.entries)){const q=navigation.entries()[navigation.currentEntry.index-1];if(q!=null&&q.url)return Ri.test(q.url)}return Ri.test((R=$.prevLocation)==null?void 0:R.pathname)},[G]),z=ge(()=>{if(!he)return[];const R=[];function q(Z){R.push(Z.id),Z.replies&&Z.replies.forEach(q)}return T.slice(V).forEach(q),R.map(Z=>Xe(Z,l))},[he,T,V,l]),le=ge(()=>T.slice(0,V).map(te),[T,V,te]);return X(()=>{let R=setTimeout(()=>{if(!x.current)return;const q=x.current.querySelector(".spoiler-button:not(.spoiling), .spoiler-media-button:not(.spoiling)");q&&q.click()},1e3);return()=>clearTimeout(R)},[t]),e("div",{tabIndex:"-1",ref:M,class:`status-deck deck contained ${T.length>1?"padded-bottom":""} ${Se.current==="status"&&!a.current?"slide-in":""} ${d?`deck-view-${d}`:""}`,onAnimationEnd:R=>{Se.current==="status"&&(Se.current=null)},children:[e("header",{class:`${S==="loading"?"loading":""}`,onDblClick:R=>{$.reloadStatusPage++},children:e("div",{class:"header-grid header-grid-2",children:[e("h1",{children:[me&&e("button",{type:"button",class:"plain deck-back",onClick:()=>{history.back()},children:e(v,{icon:"chevron-left",size:"xl"})}),!Ce&&U&&S!=="loading"?e(E,{children:[e("span",{class:"hero-heading",children:[e(_t,{account:U.account,instance:l,showAvatar:!0,short:!0})," ",e("span",{class:"insignificant",children:["•"," ",e(It,{datetime:U.createdAt,format:"micro"})]})]})," ",e("button",{type:"button",class:"ancestors-indicator light small",onClick:R=>{R.preventDefault(),R.stopPropagation(),x.current.scrollIntoView({behavior:"smooth",block:"start"})},title:"Go to main post",children:e(v,{icon:Le==="down"?"arrow-down":"arrow-up"})})]}):e(E,{children:["Post"," ",e("button",{type:"button",class:"ancestors-indicator light small",onClick:R=>{R.preventDefault(),R.stopPropagation(),M.current.scrollTo({top:0,behavior:"smooth"})},hidden:!be.length||Pe,title:`${be.length} posts above ‒ Go to top`,children:[e(v,{icon:"arrow-up"}),be.filter((R,q,Z)=>Z.findIndex(ue=>ue.accountID===R.accountID)===q).slice(0,3).map(R=>e(st,{url:R.account.avatar,alt:R.account.displayName},R.account.id)),be.length>3&&e(E,{children:[" ",e("span",{class:"insignificant",children:je(be.length)})]})]})]})]}),e("div",{class:"header-side",children:[e("button",{type:"button",class:"plain4 button-switch-view",style:{display:d==="full"?"":"none"},onClick:()=>{p(null),i.delete("media"),i.delete("media-only"),i.delete("view"),o(i)},title:"Switch to Side Peek view",children:e(v,{icon:"layout4",size:"l"})}),N&&e("button",{type:"button",class:"plain button-refresh",onClick:()=>{$.reloadStatusPage++,_(!1)},children:e(v,{icon:"refresh",size:"l"})}),e(Ze,{align:"end",portal:{target:M.current},menuButton:e("button",{type:"button",class:"button plain4",children:e(v,{icon:"more",alt:"Actions",size:"xl"})}),children:[e(pe,{disabled:S==="loading",onClick:()=>{$.reloadStatusPage++},children:[e(v,{icon:"refresh"}),e("span",{children:"Refresh"})]}),e(pe,{className:"menu-switch-view",onClick:()=>{p(d==="full"?null:"full"),i.delete("media"),i.delete("media-only"),d==="full"?i.delete("view"):i.set("view","full"),o(i)},children:[e(v,{icon:{"":"layout5",full:"layout4"}[d||""]}),e("span",{children:["Switch to ",d==="full"?"Side Peek":"Full"," view"]})]}),e(pe,{onClick:()=>{Array.from(M.current.querySelectorAll(".spoiler-button:not(.spoiling), .spoiler-media-button:not(.spoiling)")).forEach(q=>{q.click()})},children:[e(v,{icon:"eye-open"})," ",e("span",{children:"Show all sensitive content"})]}),e(ze,{}),e(Ki,{className:"plain",children:"Experimental"}),e(pe,{disabled:!O||ie,onClick:()=>{const R=nc(U.url);R?location.hash=R:alert("Unable to switch")},children:[e(v,{icon:"transfer"}),e("small",{class:"menu-double-lines",children:["Switch to post's instance",O?e(E,{children:[" ","(",e("b",{children:Ut.toUnicode(O)}),")"]}):""]})]})]}),e(re,{class:"button plain deck-close",to:n,children:e(v,{icon:"x",size:"xl"})})]})]})}),T.length&&U?e("ul",{class:`timeline flat contextual grow ${S==="loading"?"loading":""}`,children:[le,he>0&&e("li",{children:e("button",{type:"button",class:"plain block show-more",disabled:S==="loading",onClick:()=>de(R=>R+en),style:{marginBlockEnd:"6em"},"data-state-post-ids":z.join(" "),children:[e("div",{class:"ib avatars-bunch",children:T.slice(V,V+5).map(R=>e(st,{url:R.account.avatarStatic},R.id))})," ",e("div",{class:"ib",children:["Show more…"," ",e("span",{class:"tag",children:he>en?`${en}+`:he})]})]})})]}):e(E,{children:[S==="loading"&&e("ul",{class:"timeline flat contextual grow loading",children:e("li",{children:e(Be,{skeleton:!0,size:"l"})})}),S==="error"&&e("p",{class:"ui-state",children:["Unable to load post",e("br",{}),e("br",{}),e("button",{type:"button",onClick:()=>{$.reloadStatusPage++},children:"Try again"})]})]})]})}function xs({replies:t,instance:n,hasParentThread:s,level:i,accWeight:o,openAll:r,parentLink:f}){const[u,a]=ot(),d=y=>y.reduce((T,w)=>{const{repliesCount:S,replies:I}=w,x=(I==null?void 0:I.length)||S;return T+x+d(I||[])},0),p=t.length+d(t),c=t.length===p,h=t.map(y=>y.account).filter((y,T,w)=>w.findIndex(S=>S.id===y.id)===T).slice(0,3),l=ge(()=>t==null?void 0:t.reduce((y,T)=>y+(T==null?void 0:T.weight),o),[o,t==null?void 0:t.length]);let b=!1;(r||l<=gc||!s&&p===1&&Ht(t[0])<2)&&(b=!0);const m=Rn[t[0].id],k=et((y,T,w,S)=>{y.preventDefault(),y.stopPropagation(),a({media:T+1,mediaStatusID:S.id})},[]),g=H();return ut(()=>{var T;function y(w){w.target.dataset.scrollLeft=w.target.scrollLeft}return(T=g.current)==null||T.addEventListener("scroll",y,{passive:!0}),()=>{var w;(w=g.current)==null||w.removeEventListener("scroll",y)}},[]),e("details",{ref:g,class:"replies",open:m||b,onToggle:y=>{const{open:T}=y.target;Rn[t[0].id]=T},style:{"--comments-level":i},"data-comments-level":i,"data-comments-level-overflow":i>4,children:[e("summary",{class:"replies-summary",hidden:b,children:[e("span",{class:"avatars",children:h.map(y=>e(st,{url:y.avatarStatic,title:`${y.displayName} @${y.username}`,squircle:y==null?void 0:y.bot},y.id))}),e("span",{class:"replies-counts",children:[e("b",{children:[e("span",{title:t.length,children:je(t.length)})," ","repl",t.length===1?"y":"ies"]}),!c&&p>1&&e(E,{children:[" ","·"," ",e("span",{children:[e("span",{title:p,children:je(p)})," ","comment",p===1?"":"s"]})]})]}),e(v,{icon:"chevron-down",class:"replies-summary-chevron"}),!!f&&e(re,{class:"replies-parent-link",to:f.to,onClick:f.onClick,title:"View post with its replies",children:"»"})]}),e("ul",{children:t.map(y=>{var T,w;return e("li",{children:[e("div",{class:"status-focus",tabIndex:0,children:[e(Be,{statusID:y.id,instance:n,withinContext:!0,size:"s",enableTranslate:!0,onMediaClick:k,showActionsBar:!0}),!((T=y.replies)!=null&&T.length)&&y.repliesCount>0&&e("div",{class:"replies-link",children:[e(v,{icon:"comment2"})," ",e("span",{title:y.repliesCount,children:je(y.repliesCount)})]})]}),((w=y.replies)==null?void 0:w.length)&&e(xs,{instance:n,replies:y.replies,level:i+1,accWeight:b?l:y.weight,openAll:r,parentLink:{to:n?`/${n}/s/${y.id}`:`/s/${y.id}`,onClick:()=>{an(y.id)}}})]},y.id)})})]})}const vc=140,kc=35,Sc=70,Ic=140,En=new Map;function Ht(t){var l,b;const n=En.get(t.id);if(n)return n;const{spoilerText:s,content:i,mediaAttachments:o,poll:r,card:f}=t,u=Wi(s+i),a=o!=null&&o.length?vc:0,d=(((l=r==null?void 0:r.options)==null?void 0:l.length)||0)*kc,p=f&&(o!=null&&o.length||(b=r==null?void 0:r.options)!=null&&b.length)?0:Sc,h=(u+a+d+p)/Ic;return En.set(t.id,h),h}const Cc=Je(bc);function Tc(){const t=St(),{id:n,instance:s}=t;return e(Cc,{id:n,instance:s})}const xc=""+new URL("boosts-carousel-YjmjXTE6.jpg",import.meta.url).href,$c=""+new URL("grouped-notifications-xYMFVY91.jpg",import.meta.url).href,Ac=""+new URL("multi-column-ETnJNDVb.jpg",import.meta.url).href,Rc=""+new URL("multi-hashtag-timeline-x-SDVR4g.jpg",import.meta.url).href,Ec=""+new URL("nested-comments-thread-Ib-fZGS3.jpg",import.meta.url).href,_c="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xml:space='preserve'%20fill-rule='evenodd'%20stroke-linejoin='round'%20stroke-miterlimit='2'%20clip-rule='evenodd'%20viewBox='0%200%20102%2028'%3e%3cpath%20fill='none'%20d='M0%200h101.5v27.5H0z'/%3e%3cg%20fill-rule='nonzero'%3e%3cpath%20fill='url(%23a)'%20d='M2.32%2021.85c1.4%200%202.21-.85%202.21-2.3v-4.64H8.5c4.45%200%207.54-2.9%207.54-7.24%200-4.35-2.98-7.24-7.32-7.24h-6.4C.93.43.11%201.28.11%202.73v16.82c0%201.45.82%202.3%202.21%202.3Zm2.21-10.4V3.94h3c2.54%200%204%201.34%204%203.75s-1.47%203.76-4%203.76h-3Z'/%3e%3cpath%20fill='url(%23b)'%20d='M20.52%2021.88c1.25%200%202.13-.76%202.13-2.23v-7.04c0-2.07%201.2-3.49%203.21-3.49%201.95%200%202.95%201.23%202.95%203.25v7.28c0%201.47.89%202.23%202.13%202.23%201.26%200%202.14-.76%202.14-2.23v-8.18c0-3.64-1.99-5.9-5.48-5.9-2.38%200-4.1%201.12-4.93%203.1h-.09V2.3c0-1.38-.78-2.2-2.1-2.2-1.31%200-2.1.82-2.1%202.2v17.34c0%201.47.9%202.23%202.14%202.23Z'/%3e%3cpath%20fill='url(%23c)'%20d='M40.45%2021.82c1.96%200%203.93-.98%204.8-2.65h.1v.8c.08%201.27.89%201.91%202.05%201.91%201.21%200%202.08-.73%202.08-2.15v-8.95c0-3.17-2.63-5.25-6.65-5.25-3.26%200-5.78%201.16-6.5%203.04-.15.32-.23.63-.23.96%200%20.97.75%201.64%201.79%201.64.69%200%201.23-.26%201.7-.79.95-1.23%201.74-1.65%203.04-1.65%201.62%200%202.64.85%202.64%202.31v1.04l-3.95.24c-3.93.23-6.13%201.88-6.13%204.74%200%202.83%202.27%204.76%205.26%204.76Zm1.4-3.09c-1.43%200-2.4-.73-2.4-1.9%200-1.12.91-1.83%202.51-1.95l3.31-.2v1.14c0%201.7-1.54%202.91-3.41%202.91Z'/%3e%3cpath%20fill='url(%23d)'%20d='M54.37%2021.88c1.26%200%202.14-.76%202.14-2.23v-7.09c0-2.03%201.21-3.44%203.13-3.44s2.89%201.17%202.89%203.22v7.31c0%201.47.88%202.23%202.14%202.23%201.24%200%202.13-.76%202.13-2.23v-8.2c0-3.68-1.96-5.87-5.45-5.87-2.41%200-4%201.07-4.83%203.01h-.09v-.87c0-1.35-.85-2.17-2.14-2.17-1.28%200-2.06.82-2.06%202.15v11.95c0%201.47.9%202.23%202.14%202.23Z'/%3e%3cpath%20fill='url(%23e)'%20d='M71.65%2027.17c1.26%200%202.14-.76%202.14-2.23v-6h.09a5.15%205.15%200%200%200%204.88%202.88c3.92%200%206.35-3.05%206.35-8.1%200-5.07-2.44-8.1-6.43-8.1a5.12%205.12%200%200%200-4.86%202.99h-.09v-.85c0-1.45-.88-2.21-2.1-2.21-1.24%200-2.11.76-2.11%202.2v17.2c0%201.46.89%202.22%202.13%202.22Zm5.6-8.8c-2.1%200-3.47-1.8-3.47-4.65%200-2.81%201.37-4.67%203.47-4.67%202.14%200%203.49%201.83%203.49%204.67%200%202.86-1.35%204.66-3.5%204.66Z'/%3e%3cpath%20fill='url(%23f)'%20d='M89.61%2027.39c3.44%200%205.26-1.5%206.73-5.55l4.81-13.1a4%204%200%200%200%20.24-1.26c0-1.13-.85-1.93-2.08-1.93-1.1%200-1.71.51-2.07%201.7l-3.4%2010.9h-.08L90.35%207.28c-.36-1.25-.94-1.73-2.07-1.73-1.26%200-2.21.83-2.21%201.99%200%20.35.09.82.25%201.26l5%2013.21-.21.56c-.52%201.1-1.32%201.42-2.07%201.42l-.75-.01c-.96%200-1.56.54-1.56%201.4%200%201.29%201%202%202.88%202Z'/%3e%3c/g%3e%3cdefs%3e%3cradialGradient%20id='a'%20cx='0'%20cy='0'%20r='1'%20gradientTransform='rotate(28.51%20.06%20.22)%20scale(57.6252)'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%23a4bff7'/%3e%3cstop%20offset='1'%20stop-color='%236081e6'/%3e%3c/radialGradient%3e%3cradialGradient%20id='b'%20cx='0'%20cy='0'%20r='1'%20gradientTransform='rotate(28.51%20.06%20.22)%20scale(57.6252)'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%23a4bff7'/%3e%3cstop%20offset='1'%20stop-color='%236081e6'/%3e%3c/radialGradient%3e%3cradialGradient%20id='c'%20cx='0'%20cy='0'%20r='1'%20gradientTransform='rotate(28.51%20.06%20.22)%20scale(57.6252)'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%23a4bff7'/%3e%3cstop%20offset='1'%20stop-color='%236081e6'/%3e%3c/radialGradient%3e%3cradialGradient%20id='d'%20cx='0'%20cy='0'%20r='1'%20gradientTransform='rotate(28.51%20.06%20.22)%20scale(57.6252)'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%23a4bff7'/%3e%3cstop%20offset='1'%20stop-color='%236081e6'/%3e%3c/radialGradient%3e%3cradialGradient%20id='e'%20cx='0'%20cy='0'%20r='1'%20gradientTransform='rotate(28.51%20.06%20.22)%20scale(57.6252)'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%23a4bff7'/%3e%3cstop%20offset='1'%20stop-color='%236081e6'/%3e%3c/radialGradient%3e%3cradialGradient%20id='f'%20cx='0'%20cy='0'%20r='1'%20gradientTransform='rotate(28.51%20.06%20.22)%20scale(57.6252)'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%23a4bff7'/%3e%3cstop%20offset='1'%20stop-color='%236081e6'/%3e%3c/radialGradient%3e%3c/defs%3e%3c/svg%3e";var Lc={PHANPY_CLIENT_NAME:"Phanpy",PHANPY_WEBSITE:"https://phanpy.social",PHANPY_LINGVA_INSTANCES:"lingva.phanpy.social lingva.lunar.icu lingva.garudalinux.org translate.plausibility.cloud",PHANPY_PRIVACY_POLICY_URL:"https://github.com/cheeaun/phanpy/blob/main/PRIVACY.MD",VITE_APP_ENV:"production",BASE_URL:"./",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const{PHANPY_DEFAULT_INSTANCE:zt,PHANPY_WEBSITE:Ei,PHANPY_PRIVACY_POLICY_URL:Mc,PHANPY_DEFAULT_INSTANCE_REGISTRATION_URL:_i}=Lc,Li=Ei?Ei.replace(/https?:\/\//g,"").replace(/\/$/,""):null,Mi=`${"2024-07-01T05:23:17.415Z".slice(0,10).replace(/-/g,".")}.5e9165b`;function Di(){return qe(null,["/","/welcome"]),e("main",{id:"welcome",children:[e("div",{class:"hero-container",children:[e("div",{class:"hero-content",children:[e("h1",{children:[e("img",{src:Hn,alt:"",width:"160",height:"160",style:{aspectRatio:"1/1",marginBlockEnd:-16}}),e("img",{src:_c,alt:"Phanpy",width:"200"})]}),e("p",{class:"desc",children:"A minimalistic opinionated Mastodon web client."}),e("p",{children:e(re,{to:zt?`/login?instance=${zt}&submit=1`:"/login",class:"button",children:zt?"Log in":"Log in with Mastodon"})}),zt&&_i&&e("p",{children:e("a",{href:_i,class:"button plain5",children:"Sign up"})}),!zt&&e("p",{class:"insignificant",children:e("small",{children:["Connect your existing Mastodon/Fediverse account.",e("br",{}),"Your credentials are not stored on this server."]})})]}),(Li||Mi)&&e("p",{class:"app-site-version",children:e("small",{children:[Li," ",Mi]})}),e("p",{children:[e("a",{href:"https://github.com/cheeaun/phanpy",target:"_blank",children:"Built"})," ","by"," ",e("a",{href:"https://mastodon.social/@cheeaun",target:"_blank",onClick:t=>{t.preventDefault(),$.showAccount="cheeaun@mastodon.social"},children:"@cheeaun"}),"."," ",e("a",{href:Mc,target:"_blank",children:"Privacy Policy"}),"."]})]}),e("div",{id:"why-container",children:e("div",{class:"sections",children:[e("section",{children:[e("img",{src:xc,alt:"Screenshot of Boosts Carousel",loading:"lazy"}),e("h4",{children:"Boosts Carousel"}),e("p",{children:"Visually separate original posts and re-shared posts (boosted posts)."})]}),e("section",{children:[e("img",{src:Ec,alt:"Screenshot of nested comments thread",loading:"lazy"}),e("h4",{children:"Nested comments thread"}),e("p",{children:"Effortlessly follow conversations. Semi-collapsible replies."})]}),e("section",{children:[e("img",{src:$c,alt:"Screenshot of grouped notifications",loading:"lazy"}),e("h4",{children:"Grouped notifications"}),e("p",{children:"Similar notifications are grouped and collapsed to reduce clutter."})]}),e("section",{children:[e("img",{src:Ac,alt:"Screenshot of multi-column UI",loading:"lazy"}),e("h4",{children:"Single or multi-column"}),e("p",{children:"By default, single column for zen-mode seekers. Configurable multi-column for power users."})]}),e("section",{children:[e("img",{src:Rc,alt:"Screenshot of multi-hashtag timeline with a form to add more hashtags",loading:"lazy"}),e("h4",{children:"Multi-hashtag timeline"}),e("p",{children:"Up to 5 hashtags combined into a single timeline."})]})]})})]})}const Dc=window.alert;window.__nativeAlert||(window.__nativeAlert=Dc);window.alert=function(t){t instanceof Error&&(t!=null&&t.message)&&(t=t.message),typeof t!="string"&&(t=JSON.stringify(t));const n=io({text:t,className:"alert",gravity:"top",position:"center",duration:1e4,offset:{y:48},onClick:()=>{n.hideToast()}});n.showToast()};window.__STATES__=$;window.__STATES_STATS__=()=>{const t=["statuses","accounts","spoilers","unfurledLinks","statusQuotes"],n={};t.forEach(o=>{n[o]=Object.keys($[o]).length});const{statuses:s}=$,i=[];for(const o in s)document.querySelector(`[data-state-post-id~="${o}"], [data-state-post-ids~="${o}"]`)||i.push(o)};setInterval(()=>{if(!window.__IDLE__)return;const{statuses:t,unfurledLinks:n,notifications:s}=$;let i=0;const{instance:o}=ne();for(const r in t){if(!window.__IDLE__)break;try{const f=document.querySelector(`[data-state-post-id~="${r}"], [data-state-post-ids~="${r}"]`),u=s.some(a=>{var d;return r===Xe((d=a.status)==null?void 0:d.id,o)});if(!f&&!u){delete $.statuses[r],delete $.statusQuotes[r];for(const a in n){const d=n[a];if(Xe(d.id,d.instance)===r){delete $.unfurledLinks[a];break}}i++}}catch{}}},15*60*1e3);setTimeout(()=>{for(const t in Kt)setTimeout(()=>{var n,s,i,o;Array.isArray(Kt[t])?(s=(n=Kt[t])[0])==null||s.call(n):(o=(i=Kt)[t])==null||o.call(i)},1)},5e3);(()=>{window.__IDLE__=!0;const t=["mousemove","mousedown","resize","keydown","touchstart","pointerdown","pointermove","wheel"],n=()=>{window.__IDLE__=!0},i=Xi(n,3e3),o=()=>{window.__IDLE__=!1,i()};t.forEach(r=>{window.addEventListener(r,o,{passive:!0,capture:!0})}),window.addEventListener("blur",n,{passive:!0}),document.documentElement.addEventListener("mouseleave",r=>{!r.relatedTarget&&!r.toElement&&n()},{passive:!0})})();const Pc=/iPad|iPhone|iPod/.test(navigator.userAgent);Pc&&document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="visible"){const t=we.local.get("theme");let n;if(t){if(n=document.querySelector('meta[name="theme-color"][data-theme-setting="manual"]'),n){const s=n.content,i=t==="light"?n.dataset.themeLightColorTemp:n.dataset.themeDarkColorTemp;n.content=i||"",setTimeout(()=>{n.content=s},10)}}else{const s=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";if(n=document.querySelector(`meta[name="theme-color"][media*="${s}"]`),n){const i=n.dataset.content,o=n.dataset.contentTemp;n.content=o||"",setTimeout(()=>{n.content=i},10)}}}});{const t=we.local.get("theme");if(t){document.documentElement.classList.add(`is-${t}`),document.querySelector('meta[name="color-scheme"]').setAttribute("content",t||"dark light");const s=document.querySelector('meta[data-theme-setting="manual"]');s&&(s.name="theme-color",s.content=t==="light"?s.dataset.themeLightColor:s.dataset.themeDarkColor),document.querySelectorAll('meta[data-theme-setting="auto"]').forEach(o=>{o.name=""})}const n=we.local.get("textSize");n&&document.documentElement.style.setProperty("--text-size",`${n}px`)}Fi($,t=>{var n;for(const[s,i,o,r]of t){if(i.join(".")==="settings.shortcutsViewMode"){const f=document.getElementById("app");f&&(f.dataset.shortcutsViewMode=(n=$.shortcuts)!=null&&n.length?o:"")}i.join(".")==="settings.cloakMode"&&document.body.classList.toggle("cloak",o)}});function Nc(){const[t,n]=A(!1),[s,i]=A("loading");X(()=>{const r=we.local.get("instanceURL"),f=decodeURIComponent((window.location.search.match(/code=([^&]+)/)||[,""])[1]);if(f){window.history.replaceState({},document.title,window.location.pathname||"/");const u=we.session.get("clientID"),a=we.session.get("clientSecret"),d=we.session.get("vapidKey");(async()=>{i("loading");const{access_token:p}=await uc({instanceURL:r,client_id:u,client_secret:a,code:f}),c=Us({instance:r,accessToken:p});await Promise.allSettled([Zn(c),Jn(c,r),Fs(c,r,p,d)]),Qn(),n(!0),i("default")})()}else{window.__IGNORE_GET_ACCOUNT_ERROR__=!0;const u=Et();if(u){Ni(u.info.id);const{client:a}=ne({account:u}),{instance:d}=a;Qn(),i("loading"),(async()=>{try{await Zn(a),await Jn(a,d)}catch{}finally{n(!0),i("default")}})()}else i("default")}},[]);let o=Nt();return $.currentLocation=o.pathname,X(Tn,[o,t]),/\/https?:/.test(o.pathname)?e(ic,{}):e(E,{children:[e(Uc,{isLoggedIn:t,loading:s==="loading"}),e(Fc,{isLoggedIn:t}),s==="default"&&e(Ln,{children:e(Fe,{path:"/:instance?/s/:id",element:e(Tc,{})})}),t&&e(co,{}),t&&e(Ma,{}),e(xa,{}),t&&e(Ea,{}),e(ro,{isLoggedIn:t}),s!=="loading"&&e(_a,{onClose:Tn}),e(lo,{})]})}function Uc({isLoggedIn:t,loading:n}){const s=Nt(),i=ge(()=>{const{pathname:o}=s;return!/^\/(login|welcome)/i.test(o)},[s]);return e(Ln,{location:i||s,children:[e(Fe,{path:"/",element:t?e(ec,{}):n?e(Ae,{id:"loader-root"}):e(Di,{})}),e(Fe,{path:"/login",element:e(pc,{})}),e(Fe,{path:"/welcome",element:e(Di,{})})]})}function Pi(){return $.prevLocation||null}function Fc({isLoggedIn:t}){const n=Nt(),s=H(Pi());return ge(()=>qt("/:instance/s/:id",n.pathname)||qt("/s/:id",n.pathname),[n.pathname,qt])?s.current||(s.current=Pi()):s.current=null,e(Ln,{location:s.current||n,children:[t&&e(E,{children:[e(Fe,{path:"/notifications",element:e(ks,{})}),e(Fe,{path:"/mentions",element:e(vs,{})}),e(Fe,{path:"/following",element:e(Kn,{})}),e(Fe,{path:"/b",element:e(fs,{})}),e(Fe,{path:"/f",element:e(ps,{})}),e(Fe,{path:"/l",children:[e(Fe,{index:!0,element:e(sc,{})}),e(Fe,{path:":id",element:e(bs,{})})]}),e(Fe,{path:"/fh",element:e(Ir,{})}),e(Fe,{path:"/ft",element:e(wr,{})}),e(Fe,{path:"/catchup",element:e(or,{})})]}),e(Fe,{path:"/:instance?/t/:hashtag",element:e(gs,{})}),e(Fe,{path:"/:instance?/a/:id",element:e(Ka,{})}),e(Fe,{path:"/:instance?/p",children:[e(Fe,{index:!0,element:e(An,{})}),e(Fe,{path:"l",element:e(An,{local:!0})})]}),e(Fe,{path:"/:instance?/trending",element:e(Cs,{})}),e(Fe,{path:"/:instance?/search",element:e(Ss,{})})]})}zs(e(Os,{children:e(Nc,{})}),document.getElementById("app"));setTimeout(()=>{try{Object.keys(localStorage).forEach(t=>{t.startsWith("iconify")&&localStorage.removeItem(t)}),Object.keys(sessionStorage).forEach(t=>{t.startsWith("iconify")&&sessionStorage.removeItem(t)}),localStorage.removeItem("settings:boostsCarousel")}catch{}},5e3);window.__CLOAK__=()=>{document.body.classList.toggle("cloak")}; //# sourceMappingURL=main-ztohNzti.js.map