diff --git a/dist/assets/index-B240dcNf.css b/dist/assets/index-B240dcNf.css new file mode 100644 index 0000000..560bb9e --- /dev/null +++ b/dist/assets/index-B240dcNf.css @@ -0,0 +1 @@ +layout.post-grid{margin-top:1rem}post-tile{display:block;transition:.3s all ease;position:relative;transition:all .3s ease;border-radius:10px;overflow:hidden;-webkit-tap-highlight-color:transparent;-webkit-user-select:none;user-select:none}@media (hover: hover){post-tile:hover{transform:scale(1.02);z-index:1;box-shadow:0 0 10px color-mix(in srgb,var(--background-color) 50%,transparent)}}post-tile.loading{transition:none}post-tile:active{transform:scale(.95)}post-tile div.video-detail,post-tile div.gif-detail{position:absolute;background-color:var(--background-color-lighter);color:var(--primary-color);bottom:.3rem;right:.3rem;padding:.2em .4em;height:1rem;border-radius:4px;font-size:12px;display:flex;align-items:center;gap:.2rem;z-index:2}post-tile div.video-detail ion-icon,post-tile div.gif-detail ion-icon{font-size:1.4rem}post-tile div.video-detail ion-icon[name=images-outline],post-tile div.gif-detail ion-icon[name=images-outline]{padding:.1rem;font-size:1rem}post-tile div.video-detail span.duration,post-tile div.gif-detail span.duration{text-transform:uppercase;z-index:2}post-tile img{height:100%;width:100%;vertical-align:top;background-color:var(--background-color)}post-tile video{height:100%;width:100%;object-fit:cover;position:absolute;z-index:1}searchbar{display:flex;align-items:center;flex-direction:column;width:100%;z-index:200;position:fixed;height:100%}searchbar div.input-container{margin-top:.4rem;background-color:color-mix(in srgb,var(--background-color-light) 100%,transparent);border-radius:.4rem;font-size:1rem;width:500px;padding:.4rem;max-width:calc(100% - 2rem);box-sizing:border-box;z-index:201;display:flex;align-items:center;border:1px solid var(--secondary-color-dark)}searchbar div.input-container:focus-within{outline:none}searchbar div.input-container tag-input{display:flex;gap:.4rem;width:100%;overflow:hidden;padding-inline:.4rem;box-sizing:border-box;cursor:text}searchbar div.input-container tag-input tag{display:inline-block;padding:.2rem .4rem;background-color:var(--secondary-color-dark);color:var(--secondary-color);border-radius:.4rem;cursor:pointer}searchbar div.input-container ion-icon{font-size:20px;color:var(--secondary-color-dark);cursor:pointer}searchbar div.input-container ion-icon:hover{color:var(--secondary-color)}searchbar div.selection-list-container{overflow:hidden;border-radius:.4rem;background-color:var(--background-color);z-index:201;max-width:calc(100% - 2rem);width:500px}searchbar div.selection-list-container selection-list{display:block;max-height:40vh;overflow-y:scroll;overflow-x:hidden;position:relative}searchbar div.selection-list-container selection-list::-webkit-scrollbar{width:4px}searchbar div.selection-list-container selection-list selection{display:flex;justify-content:space-between;align-items:center;padding:.4rem 1rem;cursor:pointer}searchbar div.selection-list-container selection-list selection:hover{background-color:color-mix(in srgb,var(--background-color-lighter) 50%,transparent)}searchbar div.selection-list-container selection-list selection.active{background-color:var(--background-color-lighter)}searchbar div.selection-list-container selection-list selection .tag-category{padding:.1rem .4rem;border-radius:.4rem;font-size:.9rem;background-color:var(--secondary-color-dark);color:var(--secondary-color)}searchbar div.filter{background-color:var(--background-color);opacity:.5;position:fixed;top:0;height:100%;width:100%;z-index:199}.input-wrapper{color:var(--primary-color);border:1px solid var(--secondary-color);border-radius:.4rem;position:relative;box-sizing:border-box;line-height:1em;font-size:14px;padding:4px 8px;display:inline-block;max-width:100%;text-overflow:ellipsis}.input-wrapper span.sizer{font-family:inherit;white-space:pre;height:1em;display:inline-block;font-size:inherit;line-height:inherit;box-sizing:border-box;position:relative;opacity:0;min-width:2px;-webkit-user-select:none;user-select:none;vertical-align:top}.input-wrapper input{height:100%;text-overflow:ellipsis;font-family:inherit;background:none;color:inherit;top:0;left:0;font-size:inherit;line-height:inherit;padding:inherit;position:absolute;box-sizing:border-box;width:100%;border:none;outline:none}button.icon{display:flex;justify-content:center;align-items:center;gap:.4rem;padding:.4rem;background-color:transparent}button.icon ion-icon{font-size:1.5rem}button.icon:hover{background-color:var(--background-color-light)}button.icon.vertical{flex-direction:column}#post{padding:0;padding-top:var(--nav-height)}#post section{background-color:#2f2f45;border-radius:20px;padding:20px}#post div.viewer{height:calc(100vh - 2rem - var(--nav-height));display:flex;justify-content:center;align-items:center;background-color:#000;border-radius:20px;overflow:hidden;width:calc(100vw - 300px - 4rem);margin:1rem}@media (max-width: 800px){#post div.viewer{width:100%;height:calc(100vh - var(--nav-height));border-radius:0;margin:0}}#post div.viewer img{max-width:100%;max-height:100%}#post div.viewer video{max-width:100%;max-height:100%;-webkit-user-drag:none;transition:all .3s ease}#post div.content{width:calc(100vw - 300px - 2rem);display:flex;flex-direction:column;padding:1rem;box-sizing:border-box}@media (max-width: 800px){#post div.content{width:100%}}#post div.content::-webkit-scrollbar{background-color:#000;width:4px}#post div.content::-webkit-scrollbar-thumb{background-color:#aeaeec;border-radius:2px}#post div.content>h3{padding-left:1rem;margin-block:1rem}#post div.content section.commentary *{text-wrap:wrap;word-break:break-word}#post div.sidebar{--padding: 1rem;position:fixed;top:calc(var(--nav-height) + var(--padding));right:var(--padding);display:flex;flex-direction:column;gap:.4rem;width:300px;overflow:scroll;overflow-x:hidden;height:calc(100vh - 2rem - var(--nav-height));border-radius:20px}@media (max-width: 800px){#post div.sidebar{position:static;width:100%;overflow:visible;height:100%;padding:1rem;box-sizing:border-box}}#post div.sidebar::-webkit-scrollbar{background-color:#000;width:0px}#post div.sidebar::-webkit-scrollbar-thumb{background-color:#aeaeec}#post div.sidebar h3{padding-left:1rem;margin-block:.6rem}#post div.sidebar .post-info{background-color:#2f2f45;border-radius:20px;padding:20px;display:flex;flex-direction:column;gap:.4rem}#post div.sidebar .post-info .buttons{display:grid;grid-template-columns:1fr 1fr 1fr;gap:1rem;margin-top:1rem}#post div.sidebar div.property{display:flex;gap:.6rem;align-items:center}#post div.sidebar div.property div.property-values{display:flex;gap:.4rem}#post div.sidebar div.property div.property-values span.property-value{background-color:var(--secondary-color-dark);color:var(--secondary-color);padding:2px 4px;border-radius:4px}#post div.sidebar div.inline{display:flex;gap:1rem}#post div.sidebar div.post-tags{display:flex;flex-direction:column;gap:.2rem}#post div.sidebar div.post-tags div.tag{align-items:center}#post div.sidebar div.post-tags div.tag a.tag-name{word-break:break-word;color:#d1d1ee;text-decoration:none}#post div.sidebar div.post-tags div.tag span.tag-post-count{background-color:var(--secondary-color-dark);color:var(--secondary-color);padding:0 4px;border-radius:4px;font-size:12px;margin-left:.4rem}page#root layout *{transition:all .3s ease}page#root .loader{text-align:center;padding-block:2rem}:root{--background-color: #1e1e2c;--background-color-lighter: #3b3b66;--background-color-light: #24243b;--primary-color: #d1d1ee;--primary-color-dark: #9696b3;--primary-color-darker: #72728d;--secondary-color: #aeaeec;--secondary-color-dark: #424268;--nav-height: 50px}html{overflow-x:hidden;font-size:14px}html ::-webkit-scrollbar{background-color:var(--background-color);width:8px}html ::-webkit-scrollbar-thumb{background-color:#aeaeec;border-radius:2px}body{overflow-x:hidden;background-color:var(--background-color);color:var(--primary-color);margin:0;font-family:Microsoft Yahei}nav{display:flex;width:100%;height:var(--nav-height);position:fixed;top:0;z-index:100;background-color:color-mix(in srgb,var(--background-color) 70%,transparent);justify-content:space-between;align-items:center;padding-inline:1rem;box-sizing:border-box;-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px)}nav a.title{display:flex;align-items:center;gap:.4rem;text-decoration:none}nav a.title .booru-name{color:var(--secondary-color);margin:0}nav a.title .app{display:flex;align-items:center;border-radius:.4rem;margin:0;gap:.4rem}nav a.title .app .version{color:var(--background-color);background-color:var(--secondary-color);padding:.2em .4em;border-radius:.4rem;font-size:.8rem;font-weight:700}nav a.title .app .app-name{display:none;font-size:1rem;color:var(--secondary-color)}nav div.searchbar{padding:.4rem 10%;max-width:500px;background-color:color-mix(in srgb,var(--background-color-light) 30%,transparent);border:1px solid var(--primary-color-darker);border-radius:.4rem;color:var(--primary-color-dark);transition:.3s all ease;cursor:pointer}nav div.searchbar:hover{color:var(--primary-color)}nav div.buttons{display:flex;align-items:center;gap:1rem}nav div.buttons ion-icon{transition:all .3s ease;border-radius:1rem;padding:.4rem}nav div.buttons ion-icon:hover{background-color:color-mix(in srgb,var(--background-color-lighter) 50%,transparent)}nav div.buttons ion-icon.search{display:none}@media (max-width: 800px){nav div.searchbar{display:none}nav div.buttons ion-icon.search{display:inline-block}}router{display:block;position:relative}router route{display:block;position:relative;padding-inline:10px;padding-top:var(--nav-height)}button{background-color:var(--secondary-color-dark);color:var(--secondary-color);padding:.8rem 1.2rem;border-radius:1rem;border:none;cursor:pointer}ion-icon{font-size:24px;color:var(--primary-color);cursor:pointer}ion-icon:hover{color:var(--secondary-color)} diff --git a/dist/assets/index-BfZu1R1a.js b/dist/assets/index-C21fHnwq.js similarity index 53% rename from dist/assets/index-BfZu1R1a.js rename to dist/assets/index-C21fHnwq.js index 72f1ece..260062e 100644 --- a/dist/assets/index-BfZu1R1a.js +++ b/dist/assets/index-C21fHnwq.js @@ -1 +1 @@ -var Lt=Object.defineProperty;var mt=r=>{throw TypeError(r)};var Mt=(r,t,e)=>t in r?Lt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var c=(r,t,e)=>Mt(r,typeof t!="symbol"?t+"":t,e),ft=(r,t,e)=>t.has(r)||mt("Cannot "+e);var x=(r,t,e)=>(ft(r,t,"read from private field"),e?e.call(r):t.get(r)),B=(r,t,e)=>t.has(r)?mt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),K=(r,t,e,s)=>(ft(r,t,"write to private field"),s?s.call(r,e):t.set(r,e),e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const n of i)if(n.type==="childList")for(const a of n.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&s(a)}).observe(document,{childList:!0,subtree:!0});function e(i){const n={};return i.integrity&&(n.integrity=i.integrity),i.referrerPolicy&&(n.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?n.credentials="include":i.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function s(i){if(i.ep)return;i.ep=!0;const n=e(i);fetch(i.href,n)}})();class U{constructor(){c(this,"__hidden",!1);c(this,"domEvents",{});c(this,"parent");c(this,"events",new et)}on(t,e,s){t=S.orArrayResolve(t);for(const i of t){this.domEvents[i]||(this.domEvents[i]=new Map);const n=a=>{e(a,this)};this.domEvents[i].set(e,n),this.events.on(i,e),this.dom.addEventListener(i,n,s)}return this}off(t,e,s){var n;const i=(n=this.domEvents[t])==null?void 0:n.get(e);return i&&this.dom.removeEventListener(t,i,s),this.events.off(t,e),this}once(t,e,s){const i=n=>{this.dom.removeEventListener(t,i,s),e(n,this)};return this.dom.addEventListener(t,i,s),this.events.once(t,e),this}hide(t,e=!0){return S.fluent(this,arguments,()=>this.__hidden,()=>{var s;if(t!==void 0)return t instanceof I?(this.__hidden=t.value,t.use(this,"hide")):this.__hidden=t,e&&((s=this.parent)==null||s.children.render()),this})}remove(){var t;return(t=this.parent)==null||t.children.remove(this).render(),this}replace(t){var e;return(e=this.parent)==null||e.children.replace(this,t).render(),this}contains(t){return t?t instanceof U?this.dom.contains(t.dom):t instanceof EventTarget?this.dom.contains(S(t).dom):this.dom.contains(t):!1}self(t){return t(this),this}inDOM(){return document.contains(this.dom)}isElement(){return this instanceof P}get element(){return this instanceof P?this:null}}class P extends U{constructor(e,s){super();c(this,"dom");c(this,"static_classes",new Set);this.dom=this.createDom(e,s),this.dom.$=this,this.setOptions(s)}createDom(e,s){return s!=null&&s.dom?s.dom:e==="svg"?document.createElementNS("http://www.w3.org/2000/svg","svg"):document.createElement((s==null?void 0:s.tagname)??e)}setOptions(e){return this.id(e==null?void 0:e.id),e&&e.class&&this.class(...e.class),this}id(e){return $.fluent(this,arguments,()=>this.dom.id,()=>$.set(this.dom,"id",e))}class(...e){return $.fluent(this,arguments,()=>this.dom.classList,()=>{this.dom.classList.forEach(s=>this.static_classes.has(s)??this.dom.classList.remove(s)),this.dom.classList.add(...e.detype())})}addClass(...e){return $.fluent(this,arguments,()=>this,()=>{this.dom.classList.add(...e.detype())})}removeClass(...e){return $.fluent(this,arguments,()=>this,()=>{this.dom.classList.remove(...e.detype())})}staticClass(...e){return $.fluent(this,arguments,()=>this.static_classes,()=>{this.removeClass(...this.static_classes),this.static_classes.clear(),this.addStaticClass(...e)})}addStaticClass(...e){return $.fluent(this,arguments,()=>this,()=>{e.detype().forEach(s=>this.static_classes.add(s)),this.addClass(...e)})}removeStaticClass(...e){return $.fluent(this,arguments,()=>this,()=>{e.detype().forEach(s=>this.static_classes.delete(s)),this.removeClass(...e)})}css(e){return $.fluent(this,arguments,()=>this.dom.style,()=>{Object.assign(this.dom.style,e)})}attribute(e,s){return arguments.length?arguments.length===1?e===void 0?null:this.dom.getAttribute(e):arguments.length===2?e?(s===null?this.dom.removeAttribute(e):s!==void 0&&this.dom.setAttribute(e,`${s}`),this):this:this:null}tabIndex(e){return $.fluent(this,arguments,()=>this.dom.tabIndex,()=>$.set(this.dom,"tabIndex",e))}focus(){return this.dom.focus(),this}blur(){return this.dom.blur(),this}animate(e,s,i){const n=this.dom.animate(e,s);return i&&(n.onfinish=()=>i(n)),n}getAnimations(e){return this.dom.getAnimations(e)}get dataset(){return this.dom.dataset}domRect(e){const s=this.dom.getBoundingClientRect();if(!e)return s;const i=e instanceof P?e.dom.getBoundingClientRect():e;return{...s,top:s.top-i.top,left:s.left-i.left,right:s.right-i.left,bottom:s.bottom-i.top,x:s.x-i.x,y:s.y-i.y}}}class J extends U{constructor(e){super();c(this,"dom");this.dom=e,this.dom.$=this}domRect(e){const s={bottom:innerHeight,height:innerHeight,left:0,right:innerWidth,top:0,width:innerWidth,x:0,y:0};if(!e)return s;const i=e instanceof P?e.dom.getBoundingClientRect():e;return{...s,top:s.top-i.top,left:s.left-i.left,right:s.right-i.left,bottom:s.bottom-i.top,x:s.x-i.x,y:s.y-i.y}}static from(e){return e.$ instanceof J?e.$:new J(e)}}const Pt="modulepreload",At=function(r){return"/"+r},pt={},Ct=function(t,e,s){let i=Promise.resolve();if(e&&e.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));i=Promise.allSettled(e.map(u=>{if(u=At(u),u in pt)return;pt[u]=!0;const h=u.endsWith(".css"),d=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${d}`))return;const m=document.createElement("link");if(m.rel=h?"stylesheet":Pt,h||(m.as="script"),m.crossOrigin="",m.href=u,o&&m.setAttribute("nonce",o),document.head.appendChild(m),h)return new Promise((w,l)=>{m.addEventListener("load",w),m.addEventListener("error",()=>l(new Error(`Unable to preload CSS for ${u}`)))})}))}function n(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return i.then(a=>{for(const o of a||[])o.status==="rejected"&&n(o.reason);return t().catch(n)})};class Rt{constructor(t){c(this,"$container");c(this,"childList",new Set);this.$container=t}add(t,e=-1){if(e===-1||this.childList.size-1===e)this.childList.add(t);else{const s=[...this.childList];s.splice(e,0,t),this.childList.clear(),s.forEach(i=>this.childList.add(i))}t.parent=this.$container}remove(t){return this.childList.has(t)?(this.childList.delete(t),t.parent=void 0,this):this}removeAll(t=!0){this.childList.forEach(e=>this.remove(e)),t&&this.render()}replace(t,e){const s=this.array;return s.splice(s.indexOf(t),1,e),t.remove(),this.childList.clear(),s.forEach(i=>this.childList.add(i)),e.parent=this.$container,this}render(){const[t,e]=[this.array.map(i=>i.dom),Array.from(this.dom.childNodes)],s=[];for(;e.length||t.length;){const[i,n]=[e.at(0),t.at(0)];n?i?n!==i?(n.$.__hidden||(this.dom.insertBefore(n,i),s.push(n)),t.shift()):(n.$.__hidden&&this.dom.removeChild(n),t.shift(),e.shift()):(n.$.__hidden||this.dom.append(n),t.shift()):(i&&!s.includes(i)&&i.remove(),e.shift())}}indexOf(t){return this.array.indexOf(t)}get array(){return[...this.childList.values()]}get dom(){return this.$container.dom}}class I{constructor(t,e){c(this,"_value");c(this,"attributes",new Map);c(this,"linkStates",new Set);c(this,"options",{});this.set(t),e&&(this.options=e)}set(t){this._value=t,t instanceof I&&t.linkStates.add(this),this.update(),this.linkStates.forEach(e=>e.update())}update(){for(const[t,e]of this.attributes.entries())for(const s of e)t[s]instanceof Function?this.options.format?t[s](this.options.format(this.value)):t[s](this.value):s in t&&(t[s]=this.value)}toString(){return this.options.format?this.options.format(this.value):this.value instanceof Object?JSON.stringify(this.toJSON()):`${this.value}`}use(t,e){const s=this.attributes.get(t);s?s.add(e):this.attributes.set(t,new Set().add(e))}toJSON(){return this.value instanceof I?this.value.toJSON():this.value instanceof Object?I.toJSON(this.value):this.toString()}static toJSON(t){const e={};for(let[s,i]of Object.entries(t))i instanceof I?i=i.toJSON():i instanceof Object&&I.toJSON(i),Object.assign(e,{[s]:i});return e}get value(){return this._value instanceof I?this._value.value:this._value}}class z extends U{constructor(e){super();c(this,"dom");this.dom=new Text(e),this.dom.$=this}content(e){return $.fluent(this,arguments,()=>this.dom.textContent,()=>$.set(this.dom,"textContent",e))}}class Q extends P{constructor(t,e){super(t,e)}autocapitalize(t){return $.fluent(this,arguments,()=>this.dom.autocapitalize,()=>$.set(this.dom,"autocapitalize",t))}innerText(t){return $.fluent(this,arguments,()=>this.dom.innerText,()=>$.set(this.dom,"innerText",t))}title(t){return $.fluent(this,arguments,()=>this.dom.title,()=>$.set(this.dom,"title",t))}dir(t){return $.fluent(this,arguments,()=>this.dom.dir,()=>$.set(this.dom,"dir",t))}translate(t){return $.fluent(this,arguments,()=>this.dom.translate,()=>$.set(this.dom,"translate",t))}popover(t){return $.fluent(this,arguments,()=>this.dom.popover,()=>$.set(this.dom,"popover",t))}spellcheck(t){return $.fluent(this,arguments,()=>this.dom.spellcheck,()=>$.set(this.dom,"spellcheck",t))}inert(t){return $.fluent(this,arguments,()=>this.dom.inert,()=>$.set(this.dom,"inert",t))}lang(t){return $.fluent(this,arguments,()=>this.dom.lang,()=>$.set(this.dom,"lang",t))}draggable(t){return $.fluent(this,arguments,()=>this.dom.draggable,()=>$.set(this.dom,"draggable",t))}hidden(t){return $.fluent(this,arguments,()=>this.dom.hidden,()=>$.set(this.dom,"hidden",t))}click(){return this.dom.click(),this}attachInternals(){return this.dom.attachInternals()}hidePopover(){return this.dom.hidePopover(),this}showPopover(){return this.dom.showPopover(),this}togglePopover(){return this.dom.togglePopover(),this}get accessKeyLabel(){return this.dom.accessKeyLabel}get offsetHeight(){return this.dom.offsetHeight}get offsetLeft(){return this.dom.offsetLeft}get offsetParent(){return $(this.dom.offsetParent)}get offsetTop(){return this.dom.offsetTop}get offsetWidth(){return this.dom.offsetWidth}}class f extends Q{constructor(e,s){super(e,s);c(this,"children",new Rt(this));c(this,"__position_cursor",0)}content(e){return $.fluent(this,arguments,()=>this,()=>{this.children.removeAll(!1),this.insert(e)})}insert(e,s=-1){return $.fluent(this,arguments,()=>this,async()=>{if(e instanceof Function){let i=e(this);i instanceof Promise?e=await i:e=i}else e instanceof Promise&&(e=await e);e=$.orArrayResolve(e),this.__position_cursor=s<0?this.children.array.length+s:s;for(const i of e)if(i!=null){if(i instanceof Array)this.insert(i,this.__position_cursor);else if(typeof i=="string")this.children.add(new z(i),s);else if(i instanceof I){const n=new z(i.toString());i.use(n,"content"),this.children.add(n,s)}else if(i instanceof Promise){const n=(await Ct(async()=>{const{$Async:o}=await Promise.resolve().then(()=>Ut);return{$Async:o}},void 0)).$Async,a=new n().await(i);this.children.add(a,s)}else this.children.add(i,s);this.__position_cursor+=1}this.children.render()})}clear(){return this.children.removeAll(),this}$(e){return $(this.dom.querySelector(e))}$all(e){return Array.from(this.dom.querySelectorAll(e)).map(s=>$(s))}get scrollHeight(){return this.dom.scrollHeight}get scrollWidth(){return this.dom.scrollWidth}scrollTop(e){return $.fluent(this,arguments,()=>this.dom.scrollTop,()=>$.set(this.dom,"scrollTop",e))}scrollLeft(e){return $.fluent(this,arguments,()=>this.dom.scrollLeft,()=>$.set(this.dom,"scrollLeft",e))}}class kt extends f{constructor(t){super("a",t),this.dom.addEventListener("click",e=>{$.anchorHandler&&this.href()&&(e.preventDefault(),$.anchorHandler(this,e))})}href(t){return $.fluent(this,arguments,()=>this.dom.href,()=>{t&&(this.dom.href=t)})}target(t){return $.fluent(this,arguments,()=>this.dom.target??void 0,()=>{t&&(this.dom.target=t)})}}class Nt extends P{constructor(t,e){super(t,e)}}var _;(r=>{function t(o,u,h,d){return u.length?(d(),o):h()}r.fluent=t;function e(o){return o instanceof Array?o:[o]}r.orArrayResolve=e;function s(o,u){return e(u).forEach(h=>{Object.getOwnPropertyNames(h.prototype).forEach(d=>{d!=="constructor"&&Object.defineProperty(o.prototype,d,Object.getOwnPropertyDescriptor(h.prototype,d)||Object.create(null))})}),o}r.mixin=s;function i(o,u,h){h!==void 0&&(o[u]=h)}r.set=i;function n(o){return new I(o)}r.state=n;function a(o){if(o.$)return o.$;if(o.nodeName.toLowerCase()==="body")return new f("body",{dom:o});if(o.nodeName.toLowerCase()==="#document")return J.from(o);if(o instanceof HTMLElement){const u=$.TagNameElementMap[o.tagName.toLowerCase()],h=u===f?new u(o.tagName,{dom:o}):new u({dom:o});if(h instanceof f)for(const d of Array.from(h.dom.childNodes))h.children.add($(d));return h}else if(o instanceof Text){const u=new z(o.textContent??"");return u.dom=o,u}else if(o instanceof SVGElement&&o.tagName.toLowerCase()==="svg")return new Nt("svg",{dom:o});throw`$NODE.FROM: NOT SUPPORT TARGET ELEMENT TYPE (${o.nodeName})`}r.from=a})(_||(_={}));class L{static create(...t){const e=class{};return Object.getOwnPropertyNames(L.prototype).forEach(s=>{s!=="constructor"&&t.includes(s)&&Object.defineProperty(e.prototype,s,Object.getOwnPropertyDescriptor(L.prototype,s)||Object.create(null))}),e}disabled(t){return $.fluent(this,arguments,()=>this.dom.disabled,()=>$.set(this.dom,"disabled",t))}checkValidity(){return this.dom.checkValidity()}reportValidity(){return this.dom.reportValidity()}formAction(t){return $.fluent(this,arguments,()=>this.dom.formAction,()=>$.set(this.dom,"formAction",t))}formEnctype(t){return $.fluent(this,arguments,()=>this.dom.formEnctype,()=>$.set(this.dom,"formEnctype",t))}formMethod(t){return $.fluent(this,arguments,()=>this.dom.formMethod,()=>$.set(this.dom,"formMethod",t))}formNoValidate(t){return $.fluent(this,arguments,()=>this.dom.formNoValidate,()=>$.set(this.dom,"formNoValidate",t))}formTarget(t){return $.fluent(this,arguments,()=>this.dom.formTarget,()=>$.set(this.dom,"formTarget",t))}autocomplete(t){return $.fluent(this,arguments,()=>this.dom.autocomplete,()=>$.set(this.dom,"autocomplete",t))}name(t){return $.fluent(this,arguments,()=>this.dom.name,()=>$.set(this.dom,"name",t))}maxLength(t){return $.fluent(this,arguments,()=>this.dom.maxLength,()=>$.set(this.dom,"maxLength",t))}minLength(t){return $.fluent(this,arguments,()=>this.dom.minLength,()=>$.set(this.dom,"minLength",t))}required(t){return $.fluent(this,arguments,()=>this.dom.required,()=>$.set(this.dom,"required",t))}label(t){return $.fluent(this,arguments,()=>this.dom.label,()=>$.set(this.dom,"label",t))}get form(){return this.dom.form?$(this.dom.form):null}get validationMessage(){return this.dom.validationMessage}get validity(){return this.dom.validity}get willValidate(){return this.dom.willValidate}}class $t extends f{constructor(t){super("button",t)}type(t){return $.fluent(this,arguments,()=>this.dom.type,()=>$.set(this.dom,"type",t))}}_.mixin($t,L.create("disabled","checkValidity","formAction","formEnctype","formMethod","formNoValidate","formTarget","reportValidity"));class yt extends f{constructor(t){super("form",t)}action(t){return $.fluent(this,arguments,()=>this.dom.formAction,()=>$.set(this.dom,"formAction",t))}enctype(t){return $.fluent(this,arguments,()=>this.dom.formEnctype,()=>$.set(this.dom,"formEnctype",t))}method(t){return $.fluent(this,arguments,()=>this.dom.formMethod,()=>$.set(this.dom,"formMethod",t))}noValidate(t){return $.fluent(this,arguments,()=>this.dom.formNoValidate,()=>$.set(this.dom,"formNoValidate",t))}acceptCharset(t){return $.fluent(this,arguments,()=>this.dom.acceptCharset,()=>$.set(this.dom,"acceptCharset",t))}target(t){return $.fluent(this,arguments,()=>this.dom.formTarget,()=>$.set(this.dom,"formTarget",t))}requestSubmit(){return this.dom.requestSubmit(),this}reset(){return this.dom.reset(),this}submit(){return this.dom.submit(),this}get length(){return this.dom.length}get elements(){return Array.from(this.dom.elements).map(t=>$(t))}}_.mixin(yt,L.create("checkValidity","reportValidity","autocomplete"));class C extends Q{constructor(t){super("input",t)}value(t){return $.fluent(this,arguments,()=>this.type()==="number"?Number(this.dom.value):this.dom.value,()=>$.set(this.dom,"value",t,e=>{this.on("input",()=>{e.attributes.has(this.dom)!==!1&&(typeof e.value=="string"&&e.set(`${this.value()}`),typeof e.value=="number"&&e.set(Number(this.value())))})}))}type(t){return $.fluent(this,arguments,()=>this.dom.type,()=>$.set(this.dom,"type",t))}capture(t){return $.fluent(this,arguments,()=>this.dom.capture,()=>$.set(this.dom,"capture",t))}alt(t){return $.fluent(this,arguments,()=>this.dom.alt,()=>$.set(this.dom,"alt",t))}height(t){return $.fluent(this,arguments,()=>this.dom.height,()=>$.set(this.dom,"height",t))}width(t){return $.fluent(this,arguments,()=>this.dom.width,()=>$.set(this.dom,"width",t))}defaultValue(t){return $.fluent(this,arguments,()=>this.dom.defaultValue,()=>$.set(this.dom,"defaultValue",t))}dirName(t){return $.fluent(this,arguments,()=>this.dom.dirName,()=>$.set(this.dom,"dirName",t))}pattern(t){return $.fluent(this,arguments,()=>this.dom.pattern,()=>$.set(this.dom,"pattern",t))}placeholder(t){return $.fluent(this,arguments,()=>this.dom.placeholder,()=>$.set(this.dom,"placeholder",t))}readOnly(t){return $.fluent(this,arguments,()=>this.dom.readOnly,()=>$.set(this.dom,"readOnly",t))}selectionDirection(t){return $.fluent(this,arguments,()=>this.dom.selectionDirection,()=>$.set(this.dom,"selectionDirection",t))}selectionEnd(t){return $.fluent(this,arguments,()=>this.dom.selectionEnd,()=>$.set(this.dom,"selectionEnd",t))}selectionStart(t){return $.fluent(this,arguments,()=>this.dom.selectionStart,()=>$.set(this.dom,"selectionStart",t))}size(t){return $.fluent(this,arguments,()=>this.dom.size,()=>$.set(this.dom,"size",t))}src(t){return $.fluent(this,arguments,()=>this.dom.src,()=>$.set(this.dom,"src",t))}inputMode(t){return $.fluent(this,arguments,()=>this.dom.inputMode,()=>$.set(this.dom,"inputMode",t))}valueAsDate(t){return $.fluent(this,arguments,()=>this.dom.valueAsDate,()=>$.set(this.dom,"valueAsDate",t))}valueAsNumber(t){return $.fluent(this,arguments,()=>this.dom.valueAsNumber,()=>$.set(this.dom,"valueAsNumber",t))}webkitdirectory(t){return $.fluent(this,arguments,()=>this.dom.webkitdirectory,()=>$.set(this.dom,"webkitdirectory",t))}select(){return this.dom.select(),this}setCustomValidity(t){return this.dom.setCustomValidity(t),this}setRangeText(t,e,s,i){return typeof e=="number"&&typeof s=="number"&&this.dom.setRangeText(t,e,s,i),this.dom.setRangeText(t),this}setSelectionRange(t,e,s){return this.dom.setSelectionRange(t,e,s),this}showPicker(){return this.dom.showPicker(),this}get files(){return this.dom.files}get webkitEntries(){return this.dom.webkitEntries}get labels(){return Array.from(this.dom.labels??[]).map(t=>$(t))}}_.mixin(C,L.create("checkValidity","reportValidity","autocomplete","name","form","required","validationMessage","validity","willValidate","formAction","formEnctype","formMethod","formNoValidate","formTarget"));class Dt extends C{constructor(t){super(t),this.type("number")}static from(t){return $.mixin(C,this)}stepDown(){return this.dom.stepDown(),this}stepUp(){return this.dom.stepUp(),this}max(t){return $.fluent(this,arguments,()=>this.dom.max===""?null:parseInt(this.dom.min),()=>$.set(this.dom,"max",t==null?void 0:t.toString()))}min(t){return $.fluent(this,arguments,()=>this.dom.min===""?null:parseInt(this.dom.min),()=>$.set(this.dom,"min",t==null?void 0:t.toString()))}step(t){return $.fluent(this,arguments,()=>Number(this.dom.step),()=>$.set(this.dom,"step",t==null?void 0:t.toString()))}}class Ht extends C{constructor(t){super(t),this.type("radio")}static from(t){return $.mixin(C,this)}checked(t){return $.fluent(this,arguments,()=>this.dom.checked,()=>$.set(this.dom,"checked",t))}defaultChecked(t){return $.fluent(this,arguments,()=>this.dom.defaultChecked,()=>$.set(this.dom,"defaultChecked",t))}}class Vt extends C{constructor(t){super(t),this.type("file")}static from(t){return $.mixin(C,this)}multiple(t){return $.fluent(this,arguments,()=>this.dom.multiple,()=>$.set(this.dom,"multiple",t))}accept(...t){return $.fluent(this,arguments,()=>this.dom.accept.split(","),()=>this.dom.accept=t.toString())}}_.mixin(C,[Dt,Ht,Vt]);class vt extends f{constructor(t){super("label",t)}for(t){return $.fluent(this,arguments,()=>this.dom.htmlFor,()=>{$.set(this.dom,"htmlFor",t)})}get control(){return this.dom.control}}_.mixin(vt,L.create("form"));class jt extends Q{constructor(t){super("img",t)}async load(t){return new Promise(e=>{const s=this.once("load",()=>{e(s)});typeof t=="string"?s.src(t):t.then(i=>s.src(i))})}static resize(t,e){return new Promise(s=>{const i=new Image;if(i.addEventListener("load",()=>{const n=document.createElement("canvas"),a=n.getContext("2d");if(!a)throw"$Image.resize: context undefined";const o=i.width/i.height,[u,h,d]=[o>1,o<1,o===1],m=e instanceof Array?e[0]:h?e:e*o,w=e instanceof Array?e[1]:u?e:e/o;n.height=w,n.width=m,a.drawImage(i,0,0,m,w),s(n.toDataURL())},{once:!0}),t instanceof File){const n=new FileReader;n.addEventListener("load",()=>i.src=n.result),n.readAsDataURL(t)}else i.src=t})}alt(t){return $.fluent(this,arguments,()=>this.dom.alt,()=>$.set(this.dom,"alt",t))}crossOrigin(t){return $.fluent(this,arguments,()=>this.dom.crossOrigin,()=>$.set(this.dom,"crossOrigin",t))}decoding(t){return $.fluent(this,arguments,()=>this.dom.decoding,()=>$.set(this.dom,"decoding",t))}height(t){return $.fluent(this,arguments,()=>this.dom.height,()=>$.set(this.dom,"height",t))}isMap(t){return $.fluent(this,arguments,()=>this.dom.isMap,()=>$.set(this.dom,"isMap",t))}loading(t){return $.fluent(this,arguments,()=>this.dom.loading,()=>$.set(this.dom,"loading",t))}referrerPolicy(t){return $.fluent(this,arguments,()=>this.dom.referrerPolicy,()=>$.set(this.dom,"referrerPolicy",t))}sizes(t){return $.fluent(this,arguments,()=>this.dom.sizes,()=>$.set(this.dom,"sizes",t))}src(t){return $.fluent(this,arguments,()=>this.dom.src,()=>$.set(this.dom,"src",t))}srcset(t){return $.fluent(this,arguments,()=>this.dom.srcset,()=>$.set(this.dom,"srcset",t))}useMap(t){return $.fluent(this,arguments,()=>this.dom.useMap,()=>$.set(this.dom,"useMap",t))}width(t){return $.fluent(this,arguments,()=>this.dom.width,()=>$.set(this.dom,"width",t))}decode(){return this.dom.decode()}get complete(){return this.dom.complete}get currentSrc(){return this.dom.currentSrc}get naturalHeight(){return this.dom.naturalHeight}get naturalWidth(){return this.dom.naturalWidth}get x(){return this.dom.x}get y(){return this.dom.y}}class Wt extends f{constructor(t){super("canvas",t)}height(t){return $.fluent(this,arguments,()=>this.dom.height,()=>{$.set(this.dom,"height",t)})}width(t){return $.fluent(this,arguments,()=>this.dom.width,()=>{$.set(this.dom,"width",t)})}captureStream(t){return this.dom.captureStream(t)}getContext(t,e){return this.dom.getContext(t)}toBlob(t,e,s){return this.dom.toBlob(t,e,s),this}toDataURL(t,e){return this.dom.toDataURL(t,e)}transferControlToOffscreen(){return this.dom.transferControlToOffscreen()}}class Ft extends f{constructor(t){super("dialog",t)}open(t){return $.fluent(this,arguments,()=>this.dom.open,()=>$.set(this.dom,"open",t))}returnValue(t){return $.fluent(this,arguments,()=>this.dom.returnValue,()=>$.set(this.dom,"returnValue",t))}close(){return this.dom.close(),this}show(){return this.dom.show(),this}showModal(){return this.dom.showModal(),this}}class wt extends f{constructor(t){super("select")}add(t){return this.insert(t),this}item(t){return $(this.dom.item(t))}namedItem(t){return $(this.dom.namedItem(t))}multiple(t){return $.fluent(this,arguments,()=>this.dom.multiple,()=>$.set(this.dom,"multiple",t))}get length(){return this.dom.length}get size(){return this.dom.size}get options(){return Array.from(this.dom.options).map(t=>$(t))}get selectedIndex(){return this.dom.selectedIndex}get selectedOptions(){return Array.from(this.dom.selectedOptions).map(t=>$(t))}value(t){return $.fluent(this,arguments,()=>this.dom.value,()=>$.set(this.dom,"value",t,e=>{this.on("input",()=>{e.attributes.has(this.dom)!==!1&&(typeof e.value=="string"&&e.set(`${this.value()}`),typeof e.value=="number"&&e.set(Number(this.value())))})}))}get labels(){return Array.from(this.dom.labels??[]).map(t=>$(t))}}_.mixin(wt,L.create("checkValidity","reportValidity","autocomplete","name","form","required","disabled","validationMessage","validity","willValidate"));class bt extends f{constructor(t){super("option",t)}defaultSelected(t){return $.fluent(this,arguments,()=>this.dom.defaultSelected,()=>$.set(this.dom,"defaultSelected",t))}selected(t){return $.fluent(this,arguments,()=>this.dom.selected,()=>$.set(this.dom,"selected",t))}text(t){return $.fluent(this,arguments,()=>this.dom.text,()=>$.set(this.dom,"text",t))}value(t){return $.fluent(this,arguments,()=>this.dom.value,()=>$.set(this.dom,"value",t))}get form(){return this.dom.form?$(this.dom.form):null}get index(){return this.dom.index}}_.mixin(bt,L.create("form","disabled","label"));class St extends f{constructor(t){super("optgroup",t)}disabled(t){return $.fluent(this,arguments,()=>this.dom.disabled,()=>$.set(this.dom,"disabled",t))}}_.mixin(St,L.create("disabled","label"));class Tt extends f{constructor(t){super("textarea",t)}cols(t){return $.fluent(this,arguments,()=>this.dom.cols,()=>$.set(this.dom,"cols",t))}wrap(t){return $.fluent(this,arguments,()=>this.dom.wrap,()=>$.set(this.dom,"wrap",t))}value(t){return $.fluent(this,arguments,()=>this.dom.value,()=>$.set(this.dom,"value",t))}defaultValue(t){return $.fluent(this,arguments,()=>this.dom.defaultValue,()=>$.set(this.dom,"defaultValue",t))}dirName(t){return $.fluent(this,arguments,()=>this.dom.dirName,()=>$.set(this.dom,"dirName",t))}placeholder(t){return $.fluent(this,arguments,()=>this.dom.placeholder,()=>$.set(this.dom,"placeholder",t))}readOnly(t){return $.fluent(this,arguments,()=>this.dom.readOnly,()=>$.set(this.dom,"readOnly",t))}selectionDirection(t){return $.fluent(this,arguments,()=>this.dom.selectionDirection,()=>$.set(this.dom,"selectionDirection",t))}selectionEnd(t){return $.fluent(this,arguments,()=>this.dom.selectionEnd,()=>$.set(this.dom,"selectionEnd",t))}selectionStart(t){return $.fluent(this,arguments,()=>this.dom.selectionStart,()=>$.set(this.dom,"selectionStart",t))}type(t){return $.fluent(this,arguments,()=>this.dom.type,()=>$.set(this.dom,"type",t))}inputMode(t){return $.fluent(this,arguments,()=>this.dom.inputMode,()=>$.set(this.dom,"inputMode",t))}select(){return this.dom.select(),this}setCustomValidity(t){return this.dom.setCustomValidity(t),this}setRangeText(t,e,s,i){return typeof e=="number"&&typeof s=="number"&&this.dom.setRangeText(t,e,s,i),this.dom.setRangeText(t),this}setSelectionRange(t,e,s){return this.dom.setSelectionRange(t,e,s),this}get labels(){return Array.from(this.dom.labels??[]).map(t=>$(t))}}_.mixin(Tt,L.create("checkValidity","reportValidity","autocomplete","name","form","required","disabled","minLength","maxLength","validationMessage","validity","willValidate"));var tt;class It extends f{constructor(e){super("async",e);B(this,tt,!1)}await(e){return e instanceof Function?e(this).then(s=>this._loaded(s)):e.then(s=>this._loaded(s)),this}_loaded(e){if(K(this,tt,!0),typeof e=="string")this.replace(new z(e));else if(e instanceof I){const s=new z(e.toString());e.use(s,"content"),this.replace(s)}else e==null?this.replace(new z(String(e))):this.replace(e);this.dom.dispatchEvent(new Event("load"))}get loaded(){return x(this,tt)}}tt=new WeakMap;const Ut=Object.freeze(Object.defineProperty({__proto__:null,$Async:It},Symbol.toStringTag,{value:"Module"}));class Gt extends P{constructor(t,e){super(t,e)}autoplay(t){return $.fluent(this,arguments,()=>this.dom.autoplay,()=>$.set(this.dom,"autoplay",t))}get buffered(){return this.dom.buffered}controls(t){return $.fluent(this,arguments,()=>this.dom.controls,()=>$.set(this.dom,"controls",t))}crossOrigin(t){return $.fluent(this,arguments,()=>this.dom.crossOrigin,()=>$.set(this.dom,"crossOrigin",t))}get currentSrc(){return this.dom.currentSrc}currentTime(t){return $.fluent(this,arguments,()=>this.dom.currentTime,()=>$.set(this.dom,"currentTime",t))}defaultMuted(t){return $.fluent(this,arguments,()=>this.dom.defaultMuted,()=>$.set(this.dom,"defaultMuted",t))}defaultPlaybackRate(t){return $.fluent(this,arguments,()=>this.dom.defaultPlaybackRate,()=>$.set(this.dom,"defaultPlaybackRate",t))}disableRemotePlayback(t){return $.fluent(this,arguments,()=>this.dom.disableRemotePlayback,()=>$.set(this.dom,"disableRemotePlayback",t))}get duration(){return this.dom.duration}get ended(){return this.dom.ended}get error(){return this.dom.error}loop(t){return $.fluent(this,arguments,()=>this.dom.loop,()=>$.set(this.dom,"loop",t))}mediaKeys(t){return $.fluent(this,arguments,()=>this.dom.mediaKeys,()=>$.set(this.dom,"setMediaKeys",[t]))}muted(t){return $.fluent(this,arguments,()=>this.dom.muted,()=>$.set(this.dom,"muted",t))}get networkState(){return this.dom.networkState}get paused(){return this.dom.paused}playbackRate(t){return $.fluent(this,arguments,()=>this.dom.playbackRate,()=>$.set(this.dom,"playbackRate",t))}get played(){return this.dom.played}preload(t){return $.fluent(this,arguments,()=>this.dom.preload,()=>$.set(this.dom,"preload",t))}preservesPitch(t){return $.fluent(this,arguments,()=>this.dom.preservesPitch,()=>$.set(this.dom,"preservesPitch",t))}get readyState(){return this.dom.readyState}get remote(){return this.dom.remote}get seekable(){return this.dom.seekable}get seeking(){return this.dom.seeking}sinkId(t){return $.fluent(this,arguments,()=>this.dom.sinkId,()=>$.set(this.dom,"setSinkId",[t]))}src(t){return $.fluent(this,arguments,()=>this.dom.src,()=>$.set(this.dom,"src",t))}srcObject(t){return $.fluent(this,arguments,()=>this.dom.srcObject,()=>$.set(this.dom,"srcObject",t))}get textTracks(){return this.dom.textTracks}volume(t){return $.fluent(this,arguments,()=>this.dom.volume,()=>$.set(this.dom,"volume",t))}addTextTrack(t,e,s){return this.dom.addTextTrack(t,e,s)}canPlayType(t){return this.dom.canPlayType(t)}fastSeek(t){return this.dom.fastSeek(t),this}load(){return this.dom.load(),this}pause(){return this.dom.pause(),this}async play(){return await this.dom.play(),this}get isPlaying(){return this.currentTime()>0&&!this.paused&&!this.ended&&this.readyState>2}}class qt extends Gt{constructor(t){super("video",t)}disablePictureInPicture(t){return $.fluent(this,arguments,()=>this.dom.disablePictureInPicture,()=>$.set(this.dom,"disablePictureInPicture",t))}height(t){return $.fluent(this,arguments,()=>this.dom.height,()=>$.set(this.dom,"height",t))}width(t){return $.fluent(this,arguments,()=>this.dom.width,()=>$.set(this.dom,"width",t))}playsInline(t){return $.fluent(this,arguments,()=>this.dom.playsInline,()=>$.set(this.dom,"playsInline",t))}poster(t){return $.fluent(this,arguments,()=>this.dom.poster,()=>$.set(this.dom,"poster",t))}get videoHeight(){return this.dom.videoHeight}get videoWidth(){return this.dom.videoWidth}cancelVideoFrameCallback(t){return this.dom.cancelVideoFrameCallback(t),this}getVideoPlaybackQuality(){return this.dom.getVideoPlaybackQuality()}requestPictureInPicture(){return this.dom.requestPictureInPicture()}requestVideoFrameCallback(t){return this.dom.requestVideoFrameCallback(t)}}function S(r){if(typeof r>"u"||r===null||r instanceof U)return r;if(typeof r=="string"){if(r.startsWith("::"))return Array.from(document.querySelectorAll(r.replace(/^::/,""))).map(t=>S(t));if(r.startsWith(":"))return S(document.querySelector(r.replace(/^:/,"")));if(r in S.TagNameElementMap){const t=S.TagNameElementMap[r];return t===Q?new Q(r):t===f?new f(r):new t}else return new f(r)}if(r instanceof Node)return r.$?r.$:_.from(r);throw`$: NOT SUPPORT TARGET ELEMENT TYPE ('${r}')`}(r=>{r.anchorHandler=null,r.TagNameElementMap={html:f,head:f,document:J,body:f,a:kt,p:f,pre:f,code:f,blockquote:f,strong:f,h1:f,h2:f,h3:f,h4:f,h5:f,h6:f,div:f,ol:f,ul:f,dl:f,li:f,input:C,label:vt,button:$t,form:yt,img:jt,dialog:Ft,canvas:Wt,select:wt,option:bt,optgroup:St,textarea:Tt,video:qt,async:It};function t(l,p,y,T){return p.length?(T(),l):y()}r.fluent=t;function e(l){return l instanceof Array?l:[l]}r.orArrayResolve=e;function s(l,p){return _.mixin(l,p)}r.mixin=s;function i(l,p,y,T){if(y!==void 0){if(y instanceof I){y.use(l,p),l[p]instanceof Function?l[p](...y.value):l[p]=y.value,T&&T(y);return}l[p]instanceof Function?l[p](...y):l[p]=y}}r.set=i;function n(l,p){return new I(l,p)}r.state=n;async function a(l,p){return new Promise(y=>{const T=new FileReader;T.onload=O=>{const b=r("img");if(b.once("load",A=>{const V=r("canvas"),j=V.getContext("2d"),R=b.height()/b.width(),[M,G]=[R>1?p/R:p,R>1?p:p*R];V.height(G).width(M),j==null||j.drawImage(b.dom,0,0,M,G),y(V.toDataURL(l.type))}),!O.target)throw"$.resize(): e.target is null";b.src(O.target.result)},T.readAsDataURL(l)})}r.resize=a;function o(l=1){return parseInt(getComputedStyle(document.documentElement).fontSize)*l}r.rem=o;function u(l){const p=new DOMParser().parseFromString(l,"text/html").body;return Array.from(p.children).map(y=>r(y))}r.html=u;function h(l,p,y){if(typeof p=="number")return Array(p).fill("").map(O=>{const b=T(l)?l[0](...l.slice(1)):r(l);return y&&y(b),b});{const O=[];for(const b of p){const A=l instanceof Function?l(...b):T(l)?l[0](...l.slice(1)):r(l);b instanceof Function?b(A):(b instanceof U||typeof b=="string")&&A.content(b),O.push(A)}return O}function T(O){return O instanceof Array&&O[0]instanceof Function}}r.builder=h;function d(l,p){return Object.assign(r.TagNameElementMap,{[l]:p}),r.TagNameElementMap}r.registerTagName=d;function m(...l){return new et}r.events=m;function w(l){return l()}r.call=w})(S||(S={}));globalThis.$=S;class et{constructor(){c(this,"eventMap",new Map)}fire(t,...e){var s;return(s=this.eventMap.get(t))==null||s.forEach(i=>i(...e)),this}on(t,e){const s=this.eventMap.get(t)??this.eventMap.set(t,new Set).get(t);return s==null||s.add(e),this}off(t,e){var s;return(s=this.eventMap.get(t))==null||s.delete(e),this}once(t,e){const s=(...n)=>{var a;(a=this.eventMap.get(t))==null||a.delete(s),e(...n)},i=this.eventMap.get(t)??this.eventMap.set(t,new Set).get(t);return i==null||i.add(s),this}}Array.prototype.detype=function(...r){return this.filter(t=>{if(r.length)for(const e of r)return typeof t!=typeof e;else return t!==void 0})};Object.defineProperties(Set.prototype,{array:{get:function(){return Array.from(this)}}});Set.prototype.sort=function(r){return this.array.sort(r)};class _t extends f{constructor(e){super("layout",e);c(this,"_property",{ROW_MAX_HEIGHT:200,GAP:0,IS_RENDERING:!1,RENDER_REQUEST:!1,COLUNM:1,TYPE:"justified",ROOT:null,ITEM_PROPERTIES:new Map});this.css({display:"block",position:"relative"}),new ResizeObserver(s=>{this.inDOM()&&(this.render(),this.dom.dispatchEvent(new Event("resize")))}).observe(this.dom),document.addEventListener("scroll",s=>{s.target===this.root().dom&&this.scrollCompute()}),new IntersectionObserver(s=>{this.inDOM()&&this.render()}).observe(this.dom)}type(e){return $.fluent(this,arguments,()=>this._property.TYPE,()=>$.set(this._property,"TYPE",e))}maxHeight(e){return $.fluent(this,arguments,()=>this._property.ROW_MAX_HEIGHT,()=>$.set(this._property,"ROW_MAX_HEIGHT",e))}column(e){return $.fluent(this,arguments,()=>this._property.COLUNM,()=>$.set(this._property,"COLUNM",e))}gap(e){return $.fluent(this,arguments,()=>this._property.GAP,()=>$.set(this._property,"GAP",e))}root(e){return $.fluent(this,arguments,()=>this._property.ROOT??$(document),()=>$.set(this._property,"ROOT",e))}get COL_WIDTH(){return(this.offsetWidth-this._property.GAP*(this._property.COLUNM-1))/this._property.COLUNM}justifiedCompute(){const e=[],s=this.offsetWidth;for(const i of this.children.array){const n=$(i);if(!(n instanceof P))continue;const a=n.attribute("layout-item-ratio"),o=a?parseFloat(a):n.dom.offsetWidth/n.dom.offsetHeight,u={$node:n,ratio:o};let h=e.at(-1);(!h||h.heightd+=l.ratio);const m=d+o,w=(s-this._property.GAP*h.items.length)/m;h.items.push(u),h.ratio=m,h.height=w}return e}waterfallCompute(){const e=[],s=this.COL_WIDTH,i=()=>{if(e.lengthn.height-a.height)[0]};for(const n of this.children.array){const a=$(n);if(!(a instanceof P))continue;const o=a.attribute("layout-item-ratio"),u=o?parseFloat(o):a.dom.offsetWidth/a.dom.offsetHeight,h={$node:a,ratio:u},d=i();let m=0;d.items.forEach(p=>m+=p.ratio);const w=s/(d.height+s/u),l=s/w;d.items.push(h),d.ratio=w,d.height=l}return e}render(){if(!this.inDOM())return this;if(this._property.ITEM_PROPERTIES.clear(),this._property.TYPE==="justified"){const e=this.justifiedCompute();let s=0;for(const i of e){let n=0;i.height>this._property.ROW_MAX_HEIGHT&&(i.height=this._property.ROW_MAX_HEIGHT);for(const a of i.items){const o=a.ratio*i.height;a.$node.css({position:"absolute",height:`${i.height}px`,width:`${o}px`,top:`${s}px`,left:`${n}px`}),a.$node.attribute("layout-item-ratio",a.ratio),this._property.ITEM_PROPERTIES.set(a.$node,{height:i.height,width:o,top:s,left:n,ratio:a.ratio,$node:a.$node}),n+=i.height*a.ratio+this._property.GAP}s+=i.height+this._property.GAP}this.css({height:`${s}px`})}else if(this._property.TYPE="waterfall"){const e=this.waterfallCompute(),s=this.COL_WIDTH;let i=0;for(const n of e){let a=0;for(const o of n.items){const u=s/o.ratio;o.$node.css({position:"absolute",height:`${u}px`,width:`${s}px`,top:`${a}px`,left:`${i}px`}),o.$node.attribute("layout-item-ratio",o.ratio),this._property.ITEM_PROPERTIES.set(o.$node,{height:u,width:s,top:a,left:i,ratio:o.ratio,$node:o.$node}),a+=u+this._property.GAP}i+=s+this._property.GAP}if(e.length){const n=e.sort((a,o)=>o.height-a.height)[0];this.css({height:`${n.height+n.items.length*this._property.GAP}px`})}else this.css({height:""})}return this.scrollCompute(),this}scrollCompute(){if(this.inDOM()===!1)return;const e=document.documentElement.scrollTop-this.dom.offsetTop;this._property.ITEM_PROPERTIES.forEach((s,i)=>{const n=s.top;s.top+s.height>e&&n{this.contentId=e,this.events.fire("rendered",{$view:this,previousContent:i,nextContent:s})},o=()=>{this.events.fire("afterSwitch",{$view:this,previousId:e})};return this.events.fire("beforeSwitch",{$view:this,preventDefault:()=>n=!0,targetId:e,previousContent:i,nextContent:s,switched:o,rendered:a}),n||(this.content(s),a(),o()),this}get currentContent(){if(this.contentId)return this.viewCache.get(this.contentId)}}$.registerTagName("view",Ot);var D;const g=class g extends Ot{constructor(e){super({tagname:"router",...e});B(this,D,"");c(this,"routes",new Map);g.routers.add(this)}base(e){return $.fluent(this,arguments,()=>x(this,D),()=>{K(this,D,e??x(this,D))})}map(e){e=$.orArrayResolve(e);for(const s of e)s instanceof Array?this.map(s):this.routes.set(s.path(),s);return this.resolve(),this}resolve(){return new Promise(e=>{if(!location.pathname.startsWith(x(this,D)))return e(2);const s=location.pathname.replace(x(this,D),"/").replace("//","/"),i=s.split("/").map(p=>`/${p}`),n=location.search,a=new Map(n.replace("?","").split("&").map(p=>p.split("="))),u=(()=>{const p=[];for(const[y,T]of this.routes){const O=$.orArrayResolve(y);for(const b of O){let A=0,V={},j={};const R=b.split("/").map(M=>`/${M}`);if(!(i.lengthObject.assign(j,{[dt]:a.get(dt)})),G.startsWith("/:")){A++,Object.assign(V,{[G.replace("/:","")]:i[M].replace("/","")});continue}else if(b.startsWith("#")&&b===location.hash){A++;continue}else if(G===i[M]){A++;continue}else break}p.push({deep:A,$route:T,params:V,query:j,pathId:Object.keys(j).length!==0?s+n:Object.keys(V).length!==0?s:O[0]})}}}return p.sort((y,T)=>T.deep-y.deep).at(0)})();if(!u)return e(1);const{$route:h,params:d,pathId:m,query:w}=u;if(m===this.contentId)return e(0);this.events.once("rendered",({nextContent:p,previousContent:y})=>{y==null||y.events.fire("afterShift",{$route:y}),p.events.fire("rendered",{$route:p}),e(0)});const l=this.viewCache.get(m)??h.build({params:d,query:w});this.viewCache.has(m)||this.setView(m,l),this.events.once("beforeSwitch",()=>{var p;l.events.fire("beforeShift",{$route:l}),(p=this.currentContent)==null||p.events.fire("beforeShift",{$route:this.currentContent})}),this.events.once("afterSwitch",()=>l.events.fire("afterShift",{$route:l})),this.switchView(m)})}static init(){if(!history.state||!("index"in history.state)){const e={index:g.historyIndex};history.replaceState(e,"")}else g.historyIndex=history.state.index;return g.navigationDirection=0,g.resolve(),window.addEventListener("popstate",()=>g.popstate()),window.addEventListener("scroll",()=>{this.setScrollHistory(this.historyIndex,location.href,document.documentElement.scrollTop)}),history.scrollRestoration="manual",this}static open(e,s){return e===void 0?this:(e=this.urlResolver(e),e.href===this.url.href?this:e.origin!==this.url.origin?(window.open(e,s),this):(g.clearForwardScrollHistory(),g.historyIndex++,history.pushState(g.historyState,"",e),g.stateChange(0),g.resolve(),this))}static back(){return this.historyIndex--,history.back(),this.stateChange(1),this}static replace(e){return e===void 0?this:(e=this.urlResolver(e),console.debug(e.href),history.replaceState(g.historyState,"",e),this.stateChange(2),g.resolve(),this)}static urlResolver(e){return e instanceof URL?e:(e.startsWith("/")&&(e=`${location.origin}${e}`),e.startsWith("#")&&(e=`${location.origin}${location.pathname}${e}`),new URL(e))}static popstate(){const e=history.state.index>g.historyIndex?0:history.state.indexe.resolve())),this.scrollRestoration(),this.setScrollHistory(this.historyIndex,location.href,document.documentElement.scrollTop)}static get historyState(){return{index:g.historyIndex}}static stateChange(e){const s=this.url,i=new URL(location.href);this.url=i,g.events.fire("stateChange",{beforeURL:s,afterURL:i,direction:e}),g.navigationDirection=e}static setScrollHistory(e,s,i){const n=this.getScrollHistory();if(!n)return sessionStorage.setItem(this.scrollHistoryKey,JSON.stringify({[e]:{url:s,value:i}}));n[e]={url:s,value:i},sessionStorage.setItem(this.scrollHistoryKey,JSON.stringify(n))}static getScrollHistory(){const e=sessionStorage.getItem(this.scrollHistoryKey);if(e)return JSON.parse(e)}static clearForwardScrollHistory(){const e=this.getScrollHistory();if(e)for(const s in e)Number(s)>this.historyIndex&&delete e[s],sessionStorage.setItem(this.scrollHistoryKey,JSON.stringify(e))}static scrollRestoration(){const e=this.getScrollHistory();if(e&&e[this.historyIndex])document.documentElement.scrollTop=e[this.historyIndex].value??0;else if(location.hash.length){const s=$(document.body).$(location.hash);s&&(document.documentElement.scrollTop=s.dom.offsetTop)}else document.documentElement.scrollTop=0}};D=new WeakMap,c(g,"routers",new Set),c(g,"events",new et),c(g,"navigationDirection"),c(g,"historyIndex",0),c(g,"url",new URL(location.href)),c(g,"scrollHistoryKey","$ROUTER_SCROLL_HISTORY");let E=g;var W=(r=>(r[r.Forward=0]="Forward",r[r.Back=1]="Back",r[r.Replace=2]="Replace",r))(W||{});E.init();var X,H;const ct=class ct extends f{constructor(e){super("route",e);B(this,X,"");B(this,H);c(this,"rendered",!1)}path(e){return $.fluent(this,arguments,()=>x(this,X),()=>K(this,X,e??x(this,X)))}builder(e){return K(this,H,e),this}render(e){return x(this,H)&&this.content(x(this,H).call(this,{$route:this,params:e.params,query:e.query})),this.rendered=!0,this}build(e){return new ct({dom:this.dom.cloneNode()}).self(s=>{x(this,H)&&s.builder(x(this,H)).render({params:e.params,query:e.query})})}};X=new WeakMap,H=new WeakMap;let ot=ct;$.registerTagName("router",E);$.registerTagName("route",ot);Object.assign($,{open(r,t){return E.open(r,t)},replace(r){return E.replace(r)},back(){return E.back()}});const N=class N{constructor(t){c(this,"posts",new Map);c(this,"tags",new Map);Object.assign(this,t),this.origin.endsWith("/")&&(this.origin=this.origin.slice(0,-1)),N.manager.set(this.name,this)}static set(t){return this.used=t,this.name$.set(t.name),this.storageAPI=t.name,this.events.fire("set"),this}static get storageAPI(){return localStorage.getItem("booru_api")}static set storageAPI(t){t?localStorage.setItem("booru_api",t):localStorage.removeItem("booru_api")}};c(N,"used"),c(N,"events",new et),c(N,"name$",$.state(N.name)),c(N,"manager",new Map);let v=N;const zt=new Intl.NumberFormat("en",{notation:"compact"});class xt{constructor(t,e){c(this,"post_count$",$.state(0,{format:t=>`${zt.format(t)}`}));c(this,"name$",$.state(""));c(this,"booru");this.booru=t,Object.assign(this,e),this.$update()}static async fetch(t,e){var n;const s=await fetch(`${t.origin}/tags/${e}.json`).then(async a=>await a.json()),i=((n=t.tags.get(s.id))==null?void 0:n.update(s))??new this(t,s);return t.tags.set(i.id,i),i}static async fetchMultiple(t,e,s=1e3){let i="";if(e)for(const[u,h]of Object.entries(e))if(h instanceof Array)i+=`&search[${u}]=${h}`;else if(h instanceof Object)for(const[d,m]of Object.entries(h))i+=`&search[${u}${d}]=${m}`;else i+=`&search[${u}]=${h}`;return(await(await fetch(`${t.origin}/tags.json?limit=${s}${i}`)).json()).map(u=>{var d;const h=((d=t.tags.get(u.id))==null?void 0:d.update(u))??new this(t,u);return t.tags.set(h.id,h),h})}update(t){return Object.assign(this,t),this.$update(),this}$update(){this.post_count$.set(this.post_count),this.name$.set(this.name)}}var F=(r=>(r[r.General=0]="General",r[r.Artist=1]="Artist",r[r.Copyright=3]="Copyright",r[r.Character=4]="Character",r[r.Meta=5]="Meta",r))(F||{});class Y{constructor(t){c(this,"name$",$.state("loding..."));Object.assign(this,t),this.update$()}static async fetch(t,e){var n;const s=await fetch(`${t.origin}/users/${e}.json`).then(async a=>await a.json()),i=((n=this.manager.get(s.id))==null?void 0:n.update(s))??new this(s);return this.manager.set(i.id,i),i}static async fetchMultiple(t,e,s=200){let i="";if(e)for(const[u,h]of Object.entries(e))if(h instanceof Array)i+=`&search[${u}]=${h}`;else if(h instanceof Object)for(const[d,m]of Object.entries(h))i+=`&search[${u}${d}]=${m}`;else i+=`&search[${u}]=${h}`;return(await(await fetch(`${t.origin}/users.json?limit=${s}${i}`)).json()).map(u=>{const h=new this(u);return this.manager.set(h.id,h),h})}update(t){return Object.assign(this,t),this.update$(),this}update$(){this.name$.set(this.name)}}c(Y,"manager",new Map);const ht=1e3,it=ht*60,rt=it*60,nt=rt*24,Xt=nt*7,st=new Intl.RelativeTimeFormat("en",{style:"long"});function Bt(r){r=Math.floor(r);const t=r/ht,e=r/it,s=r/rt,i=r/nt,n=r%1e3,a=Math.floor(r%6e4/1e3),o=Math.floor(r%36e5/6e4),u=Math.floor(r%(36e5*24)/36e5),h=a.toString().padStart(2,"0"),d=o.toString().padStart(2,"0"),m=u.toString().padStart(2,"0");return{seconds:t,minutes:e,hours:s,days:i,mil:n,s:a,min:o,h:u,ss:h,mm:d,hh:m}}function Kt(r,t=Date.now()){const e=r-t,s=Math.abs(e);if(sawait s.json());return this.update(e),Y.fetchMultiple(this.booru,{id:[this.uploader_id,this.approver_id].detype(null)}).then(()=>this.update$()),this}static async fetchMultiple(e,s,i=20){let n="";if(s){if(typeof s=="string")n=s;else for(const[d,m]of Object.entries(s))if(m!==void 0){if(d==="tags"){n+=`${m}`;continue}n.at(-1)!=="="&&(n+=" "),n+=`${d}:${m}`}}const o=await(await fetch(`${e.origin}/posts.json?limit=${i}&tags=${n}&_method=get`)).json(),u=o.map(d=>{var w;const m=((w=e.posts.get(d.id))==null?void 0:w.update(d))??new this(e,d.id,d);return e.posts.set(m.id,m),m});if(!u.length)return u;const h=[...new Set(o.map(d=>[d.approver_id,d.uploader_id].detype(null)).flat())];return Y.fetchMultiple(e,{id:h}).then(()=>u.forEach(d=>d.update$())),u}update$(){var e,s,i,n;this.uploader$.set(((e=this.uploader)==null?void 0:e.name$)??((s=this.uploader_id)==null?void 0:s.toString())),this.approver$.set(((i=this.approver)==null?void 0:i.name$)??((n=this.approver_id)==null?void 0:n.toString())??"None"),this.created_date$.set(Kt(+new Date(this.created_at))),this.favorites$.set(this.fav_count),this.score$.set(this.score),this.file_size$.set(Yt(this.file_size)),this.file_ext$.set(this.file_ext),this.dimension$.set(`${this.image_width}x${this.image_height}`),this.createdDate=new Date(this.created_at),this.fire("update")}update(e){return Object.assign(this,e),this.update$(),this}async fetchTags(){return await this.ready,await xt.fetchMultiple(this.booru,{name:{_space:this.tag_string}})}get pathname(){return`/posts/${this.id}`}get uploader(){return Y.manager.get(this.uploader_id)}get approver(){return this.approver_id?Y.manager.get(this.approver_id):null}get isVideo(){return this.file_ext==="mp4"||this.file_ext==="webm"||this.file_ext==="zip"}get isGif(){return this.file_ext==="gif"}get hasSound(){return this.tag_string_meta.includes("sound")}get tags(){const e=this.tag_string.split(" ");return[...this.booru.tags.values()].filter(s=>e.includes(s.name))}get previewURL(){var e;return((e=this.media_asset.variants.find(s=>s.file_ext==="webp"))==null?void 0:e.url)??this.large_file_url}}class Et{constructor(t){Object.assign(this,t)}static async fetch(t,e){const s=await fetch(`${t.origin}/artist_commentaries/${e}.json`);return new this(await s.json())}static async fetchMultiple(t,e,s=200){let i="";if(e)for(const[u,h]of Object.entries(e))if(h instanceof Array)i+=`&search[${u}]=${h}`;else if(h instanceof Object)for(const[d,m]of Object.entries(h))i+=`&search[${u}${d}]=${m}`;else i+=`&search[${u}]=${h}`;return(await(await fetch(`${t.origin}/artist_commentaries.json?limit=${s}${i}`)).json()).map(u=>{const h=new this(u);return this.manager.set(h.id,h),h})}}c(Et,"manager",new Map);const Jt=$("route").path("/posts/:id").id("post").builder(({$route:r,params:t})=>{if(!Number(t.id))return $("h1").content("404: POST NOT FOUND");const e=Z.get(v.used,+t.id);return[$("div").class("viewer").content(async()=>(await e.ready,e.isVideo?$("video").height(e.image_height).width(e.image_width).src(e.file_ext==="zip"?e.large_file_url:e.file_url).controls(!0).autoplay(!0).loop(!0):$("img").src(e.large_file_url))),$("div").class("content").content([$("h3").content("Artist's Commentary"),$("section").class("commentary").content(async s=>{const i=(await Et.fetchMultiple(v.used,{post:{_id:e.id}})).at(0);return[i?[i.original_title?$("h3").content(i.original_title):null,$("pre").content(i.original_description)]:"No commentary"]})]),$("div").class("sidebar").self(s=>{let i=0;addEventListener("scroll",()=>{s.inDOM()&&(i=document.documentElement.scrollTop)}),r.on("beforeShift",()=>{innerWidth>800&&s.css({position:"absolute",top:`calc(${i}px + var(--nav-height) + var(--padding))`})}).on("afterShift",()=>s.css({position:"",top:""}))}).content([$("section").class("post-info").content([new k("id").name("Post").value(`#${t.id}`),new k("uploader").name("Uploader").value(e.uploader$),new k("approver").name("Approver").value(e.approver$),new k("date").name("Date").value(e.created_date$),new k("size").name("Size").value([e.file_size$,e.dimension$]),new k("file").name("File Type").value(e.file_ext$),$("div").class("inline").content([new k("favorites").name("Favorites").value(e.favorites$),new k("score").name("Score").value(e.score$)]),$("button").content("Copy link").on("click",(s,i)=>{s.preventDefault(),navigator.clipboard.writeText(`${v.used.origin}${location.pathname}`),i.content("Copied!"),setTimeout(()=>{i.content("Copy link")},2e3)})]),$("div").class("post-tags").content(async s=>{const i=await e.fetchTags(),[n,a,o,u,h]=[i.filter(m=>m.category===F.Artist),i.filter(m=>m.category===F.Character),i.filter(m=>m.category===F.General),i.filter(m=>m.category===F.Meta),i.filter(m=>m.category===F.Copyright)];return[d("Artist",n),d("Character",a),d("Copyright",h),d("Meta",u),d("General",o)];function d(m,w){return w.length?[$("h3").content(m),$("section").content([w.map(l=>$("div").class("tag").content([$("a").class("tag-name").content(l.name).href(`/posts?tags=${l.name}`),$("span").class("tag-post-count").content(l.post_count$)]))])]:null}})])]});class k extends f{constructor(e){super("div");c(this,"$name",$("span").class("property-name"));c(this,"$values",$("div").class("property-values"));this.staticClass("property").attribute("property-id",e),this.content([this.$name,this.$values])}name(e){return this.$name.content(e),this}value(e){const s=$.orArrayResolve(e);return this.$values.content(s.map(i=>$("span").staticClass("property-value").content(i))),this}}class Qt extends f{constructor(e){super("post-tile");c(this,"post");c(this,"$video");c(this,"duration$",$.state(""));this.post=e,this.$video=this.post.isVideo?$("video").width(this.post.image_width).height(this.post.image_height).disablePictureInPicture(!0).loop(!0).muted(!0).hide(!0).on("mousedown",s=>s.preventDefault()):null,this.attribute("filetype",this.post.file_ext),this.durationUpdate(),this.build()}build(){var s,i;let e;(s=this.$video)==null||s.on("playing",(n,a)=>{e=setInterval(()=>{this.durationUpdate()},500)}),(i=this.$video)==null||i.on("pause",()=>{clearInterval(e),this.durationUpdate()}),this.class("loading").content([this.post.isVideo?$("div").class("video-detail").content([this.post.hasSound?$("ion-icon").name("volume-medium-outline"):null,$("span").class("duration").content(this.duration$)]):null,this.post.isGif?$("div").class("gif-detail").content([$("span").content("GIF")]):null,$("a").href(this.post.pathname).content(()=>[this.$video,$("img").draggable(!1).css({opacity:"0"}).width(this.post.image_width).height(this.post.image_height).src(this.post.previewURL).loading("lazy").on("mousedown",n=>n.preventDefault()).once("load",(n,a)=>{a.src(this.post.previewURL).on(["mouseenter","touchstart"],()=>{this.post.isGif&&a.src(this.post.large_file_url)}).on(["mouseleave","touchend","touchcancel"],()=>{this.post.isGif&&a.src(this.post.previewURL)}).animate({opacity:[0,1]},{duration:300,fill:"both"}),this.removeClass("loading")})]).on(["mouseenter","touchstart"],()=>{var n,a;(n=this.$video)!=null&&n.isPlaying||(a=this.$video)==null||a.src(this.post.large_file_url).hide(!1).play().catch(o=>{})}).on(["mouseleave","touchend","touchcancel"],()=>{var n;(n=this.$video)==null||n.pause().currentTime(0).hide(!0)})])}durationUpdate(){if(!this.$video)return;const e=Bt(this.post.media_asset.duration*1e3-this.$video.currentTime()*1e3);this.duration$.set(Number(e.hh)>0?`${e.hh}:${e.mm}:${e.ss}`:`${e.mm}:${e.ss}`)}}class gt extends _t{constructor(e){super();c(this,"posts",new Set);c(this,"$posts",new Set);c(this,"tags");this.tags=e==null?void 0:e.tags,this.addStaticClass("post-grid"),this.type("waterfall").gap(10),this.init()}async init(){setInterval(()=>{this.inDOM()&&document.documentElement.scrollTop===0&&this.updateNewest()},1e4),v.events.on("set",()=>{this.removeAll()}),this.on("resize",()=>this.resize()),this.loader()}async loader(){if(!this.inDOM())return setTimeout(()=>this.loader(),100);for(;this.inDOM()&&document.documentElement.scrollHeight<=innerHeight*2;)if(await this.getPosts(),!this.posts.size)return;document.documentElement.scrollTop+innerHeight>document.documentElement.scrollHeight-innerHeight*2&&await this.getPosts(),setTimeout(()=>this.loader(),100)}resize(){const e=Math.round(this.dom.clientWidth/300);this.column(e>=2?e:2)}addPost(e){e=$.orArrayResolve(e);for(const i of e){if(!i.file_url||this.posts.has(i))continue;const n=new Qt(i);this.$posts.add(n),this.posts.add(i)}const s=[...this.$posts.values()].sort((i,n)=>+n.post.createdDate-+i.post.createdDate);return this.content(s).render(),this}removeAll(){return this.posts.clear(),this.$posts.clear(),this.animate({opacity:[1,0]},{duration:300,easing:"ease"},()=>this.clear().render()),this}async updateNewest(){const e=this.sortedPosts.at(0),s=await Z.fetchMultiple(v.used,{tags:this.tags,id:e?`>${e.id}`:void 0},100);return this.addPost(s),this}async getPosts(){const e=this.sortedPosts.at(-1),s=await Z.fetchMultiple(v.used,{tags:this.tags,id:e?`<${e.id}`:void 0},100);return this.addPost(s),this}get sortedPosts(){return this.posts.array.sort((e,s)=>+s.createdDate-+e.createdDate)}}class Zt extends f{constructor(){super("searchbar");c(this,"$tagInput",new se(this));c(this,"$selectionList",new te);c(this,"typingTimer",null);c(this,"$filter",$("div").class("filter"));this.build(),window.addEventListener("keyup",e=>{!this.inDOM()&&e.key==="/"&&this.activate(),this.inDOM()&&e.key==="Escape"&&this.inactivate()})}build(){this.content([$("div").class("input-container").content([this.$tagInput.on("input",()=>this.inputHandler()).on("keydown",e=>this.keyHandler(e)),$("ion-icon").name("close-circle-outline").title("Clear Input").on("click",()=>this.$tagInput.clearAll())]).on("click",e=>{e.target===this.$tagInput.dom&&this.$tagInput.addTag().input()}),$("div").class("selection-list-container").content([this.$selectionList]),this.$filter.on("click",()=>{location.hash==="#search"&&$.back()})])}activate(){return this.hide(!1),this.$filter.animate({opacity:[0,.5]},{duration:300,easing:"ease"}),this.$tagInput.input(),this}inactivate(){return this.animate({opacity:[.5,0]},{duration:300,easing:"ease"},()=>this.hide(!0)),this}keyHandler(e){var n,a;const s=()=>{e.preventDefault(),this.$tagInput.addTag().input()},i=o=>{const u=this.$tagInput.children.indexOf(this.$tagInput.$inputor),h=this.$tagInput.children.array.at(u+1);this.$tagInput.addTag(o.value()),h?this.$tagInput.editTag(h):this.$tagInput.input()};switch(e.key){case"ArrowUp":{e.preventDefault(),this.$selectionList.focusPrevSelection(),this.$tagInput.value((n=this.$selectionList.focused)==null?void 0:n.value());break}case"ArrowDown":{e.preventDefault(),this.$selectionList.focusNextSelection(),this.$tagInput.value((a=this.$selectionList.focused)==null?void 0:a.value());break}case" ":s();break;case"Enter":{e.preventDefault(),this.$selectionList.focused?i(this.$selectionList.focused):(this.$tagInput.addTag(),this.search());break}case"Tab":{e.preventDefault();const o=this.$tagInput.children.indexOf(this.$tagInput.$inputor);if(e.shiftKey){this.$tagInput.editTag(this.$tagInput.children.array.at(o-1));break}if(this.$selectionList.focused)i(this.$selectionList.focused);else{const u=this.$tagInput.children.array.at(o+1);u?this.$tagInput.editTag(u):this.$tagInput.addTag().input()}break}case"Backspace":{const o=this.$tagInput.children.indexOf(this.$tagInput.$inputor);o!==0&&!this.$tagInput.$input.value().length&&(e.preventDefault(),this.$tagInput.editTag(this.$tagInput.children.array.at(o-1)));break}}}inputHandler(){this.typingTimer&&(clearTimeout(this.typingTimer),this.typingTimer=null),this.typingTimer=setTimeout(async()=>{this.typingTimer=null,this.getSearchSuggestions()},200)}async getSearchSuggestions(){const e=this.$tagInput.$input.value();if(!e.length)return this.$selectionList.clearSelections();const s=await xt.fetchMultiple(v.used,{fuzzy_name_matches:e,order:"similarity"});this.$selectionList.clearSelections().addSelections(s.map(i=>new ee().value(i.name).content([$("span").class("tag-name").content(i.name),$("span").class("tag-category").content(F[i.category])]).on("click",()=>{this.$tagInput.addTag(i.name).input()}))),this.$tagInput.$input.value().length||this.$selectionList.clearSelections()}search(){return $.replace(`/posts?tags=${this.$tagInput.query}`),this.$tagInput.clearAll(),this.inactivate(),this}checkURL(e,s){e.hash==="#search"&&this.inactivate(),s.hash==="#search"&&this.activate()}}class te extends f{constructor(){super("selection-list");c(this,"focused",null);c(this,"selections",new Set)}addSelections(e){e=$.orArrayResolve(e);for(const s of e)this.selections.add(s);return this.insert(e),this}clearSelections(){return this.focused=null,this.selections.clear(),this.clear(),this}focusSelection(e){return this.blurSelection(),this.focused=e,e.focus(),this}blurSelection(){var e;return(e=this.focused)==null||e.blur(),this.focused=null,this}focusNextSelection(){const e=this.selections.array,s=e.at(0);if(this.focused){const i=e.at(e.indexOf(this.focused)+1);i?this.focusSelection(i):s&&this.focusSelection(s)}else s&&this.focusSelection(s)}focusPrevSelection(){const e=this.selections.array;if(this.focused){const s=e.at(e.indexOf(this.focused)-1);s&&this.focusSelection(s)}else{const s=e.at(0);s&&this.focusSelection(s)}}}class ee extends f{constructor(){super("selection");c(this,"property",{value:""})}value(e){return $.fluent(this,arguments,()=>this.property.value,()=>$.set(this.property,"value",e))}focus(){return this.addClass("active"),this}blur(){return this.removeClass("active"),this}}class se extends f{constructor(e){super("tag-input");c(this,"$input",$("input").type("text"));c(this,"$sizer",$("span").class("sizer"));c(this,"$inputor",$("div").class("input-wrapper").content([this.$sizer,this.$input.on("input",()=>{this.$sizer.content(this.$input.value())})]));c(this,"tags",new Set);c(this,"$seachbar");this.$seachbar=e}input(){return this.insert(this.$inputor),this.$input.focus(),this.$input.value()?this.$seachbar.getSearchSuggestions():this.$seachbar.$selectionList.clearSelections(),this}addTag(e){if(e=e??this.$input.value(),!e.length)return this;const s=new ie(e);return s.on("click",()=>this.editTag(s)),this.tags.add(s),this.value(""),this.$inputor.replace(s),this}editTag(e){return this.addTag(),this.tags.delete(e),e.replace(this.$inputor),this.value(e.name),this.$input.focus(),this.$seachbar.getSearchSuggestions(),this}clearAll(){return this.value(""),this.tags.clear(),this.clear(),this}value(e){return e===void 0?this:(this.$input.value(e),this.$sizer.content(e),this)}get query(){return this.tags.array.map(e=>e.name).toString().replace(",","+")}}class ie extends f{constructor(e){super("tag");c(this,"name");this.name=e,this.build()}build(){this.content(this.name)}}class re extends f{constructor(){super("ion-icon")}name(t){return this.attribute("name",t),this}size(t){return this.attribute("size",t),this}}$.registerTagName("ion-icon",re);$.anchorHandler=r=>{$.open(r.href(),r.target())};const[at,ne]=[new v({origin:"https://danbooru.donmai.us",name:"Danbooru"}),new v({origin:"https://safebooru.donmai.us",name:"Safebooru"}),new v({origin:"https://testbooru.donmai.us",name:"Testbooru"})];v.set(v.manager.get(v.storageAPI??"")??at);const ut=new Zt().hide(!0);location.hash==="#search"&&ut.activate();$(document.body).content([$("nav").content([$("a").class("title").href("/").content([$("h1").class("booru-name").content(v.name$),$("h2").class("app").content([$("span").class("app-name").content("Viewer"),$("span").class("version").content("v0.3.2")])]),$("div").class("searchbar").content(["Search in ",v.name$]).self(r=>E.events.on("stateChange",({beforeURL:t,afterURL:e})=>{t.hash==="#search"&&r.hide(!1),e.hash==="#search"&&r.hide(!0)})).on("click",()=>$.open(location.href+"#search")),$("div").class("buttons").content([$("ion-icon").class("search").name("search-outline").title("Search").self(r=>E.events.on("stateChange",({beforeURL:t,afterURL:e})=>{t.hash==="#search"&&r.hide(!1),e.hash==="#search"&&r.hide(!0)})).on("click",()=>$.open(location.href+"#search")),$("ion-icon").class("switch").name("swap-horizontal").title("Switch Booru").on("click",()=>{v.used===at?v.set(ne):v.set(at)})])]),ut,$("router").base("/").map([$("route").id("posts").path("/").builder(()=>new gt),$("route").id("posts").path("/posts?tags").builder(({query:r})=>new gt({tags:r.tags})),Jt]).on("beforeSwitch",r=>{r.preventDefault();function s(){var a;const n=$.call(()=>{switch(E.navigationDirection){case W.Forward:return["translateX(2%)","translateX(0%)"];case W.Back:return["translateX(-2%)","translateX(0%)"];case W.Replace:return}});r.$view.content(r.nextContent),r.rendered(),(a=r.nextContent.element)==null||a.class("animated").animate({opacity:[0,1],transform:n},{duration:300,easing:"ease"},()=>{var o;r.switched(),(o=r.nextContent.element)==null||o.removeClass("animated")})}function i(){var a,o;const n=$.call(()=>{switch(E.navigationDirection){case W.Forward:return["translateX(0%)","translateX(-2%)"];case W.Back:return["translateX(0%)","translateX(2%)"];case W.Replace:return}});(o=(a=r.previousContent)==null?void 0:a.element)==null||o.class("animated").animate({opacity:[1,0],transform:n},{duration:300,easing:"ease"},()=>{var u,h;(h=(u=r.previousContent)==null?void 0:u.element)==null||h.removeClass("animated"),s()})}r.previousContent?i():s()})]);E.events.on("stateChange",({beforeURL:r,afterURL:t})=>{ut.checkURL(r,t)}); +var Lt=Object.defineProperty;var ft=r=>{throw TypeError(r)};var Pt=(r,t,e)=>t in r?Lt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var u=(r,t,e)=>Pt(r,typeof t!="symbol"?t+"":t,e),pt=(r,t,e)=>t.has(r)||ft("Cannot "+e);var x=(r,t,e)=>(pt(r,t,"read from private field"),e?e.call(r):t.get(r)),B=(r,t,e)=>t.has(r)?ft("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),K=(r,t,e,s)=>(pt(r,t,"write to private field"),s?s.call(r,e):t.set(r,e),e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const n of i)if(n.type==="childList")for(const a of n.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&s(a)}).observe(document,{childList:!0,subtree:!0});function e(i){const n={};return i.integrity&&(n.integrity=i.integrity),i.referrerPolicy&&(n.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?n.credentials="include":i.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function s(i){if(i.ep)return;i.ep=!0;const n=e(i);fetch(i.href,n)}})();class U{constructor(){u(this,"__hidden",!1);u(this,"domEvents",{});u(this,"parent");u(this,"events",new et)}on(t,e,s){t=T.orArrayResolve(t);for(const i of t){this.domEvents[i]||(this.domEvents[i]=new Map);const n=a=>{e(a,this)};this.domEvents[i].set(e,n),this.events.on(i,e),this.dom.addEventListener(i,n,s)}return this}off(t,e,s){var n;const i=(n=this.domEvents[t])==null?void 0:n.get(e);return i&&this.dom.removeEventListener(t,i,s),this.events.off(t,e),this}once(t,e,s){const i=n=>{this.dom.removeEventListener(t,i,s),e(n,this)};return this.dom.addEventListener(t,i,s),this.events.once(t,e),this}hide(t,e=!0){return T.fluent(this,arguments,()=>this.__hidden,()=>{var s;if(t!==void 0)return t instanceof I?(this.__hidden=t.value,t.use(this,"hide")):this.__hidden=t,e&&((s=this.parent)==null||s.children.render()),this})}remove(){var t;return(t=this.parent)==null||t.children.remove(this).render(),this}replace(t){var e;return(e=this.parent)==null||e.children.replace(this,t).render(),this}contains(t){return t?t instanceof U?this.dom.contains(t.dom):t instanceof EventTarget?this.dom.contains(T(t).dom):this.dom.contains(t):!1}self(t){return t(this),this}inDOM(){return document.contains(this.dom)}isElement(){return this instanceof M}get element(){return this instanceof M?this:null}}class M extends U{constructor(e,s){super();u(this,"dom");u(this,"static_classes",new Set);this.dom=this.createDom(e,s),this.dom.$=this,this.setOptions(s)}createDom(e,s){return s!=null&&s.dom?s.dom:e==="svg"?document.createElementNS("http://www.w3.org/2000/svg","svg"):document.createElement((s==null?void 0:s.tagname)??e)}setOptions(e){return this.id(e==null?void 0:e.id),e&&e.class&&this.class(...e.class),this}id(e){return $.fluent(this,arguments,()=>this.dom.id,()=>$.set(this.dom,"id",e))}class(...e){return $.fluent(this,arguments,()=>this.dom.classList,()=>{this.dom.classList.forEach(s=>this.static_classes.has(s)??this.dom.classList.remove(s)),this.dom.classList.add(...e.detype())})}addClass(...e){return $.fluent(this,arguments,()=>this,()=>{this.dom.classList.add(...e.detype())})}removeClass(...e){return $.fluent(this,arguments,()=>this,()=>{this.dom.classList.remove(...e.detype())})}staticClass(...e){return $.fluent(this,arguments,()=>this.static_classes,()=>{this.removeClass(...this.static_classes),this.static_classes.clear(),this.addStaticClass(...e)})}addStaticClass(...e){return $.fluent(this,arguments,()=>this,()=>{e.detype().forEach(s=>this.static_classes.add(s)),this.addClass(...e)})}removeStaticClass(...e){return $.fluent(this,arguments,()=>this,()=>{e.detype().forEach(s=>this.static_classes.delete(s)),this.removeClass(...e)})}css(e){return $.fluent(this,arguments,()=>this.dom.style,()=>{Object.assign(this.dom.style,e)})}attribute(e,s){return arguments.length?arguments.length===1?e===void 0?null:this.dom.getAttribute(e):arguments.length===2?e?(s===null?this.dom.removeAttribute(e):s!==void 0&&this.dom.setAttribute(e,`${s}`),this):this:this:null}tabIndex(e){return $.fluent(this,arguments,()=>this.dom.tabIndex,()=>$.set(this.dom,"tabIndex",e))}focus(){return this.dom.focus(),this}blur(){return this.dom.blur(),this}animate(e,s,i){const n=this.dom.animate(e,s);return i&&(n.onfinish=()=>i(n)),n}getAnimations(e){return this.dom.getAnimations(e)}get dataset(){return this.dom.dataset}domRect(e){const s=this.dom.getBoundingClientRect();if(!e)return s;const i=e instanceof M?e.dom.getBoundingClientRect():e;return{...s,top:s.top-i.top,left:s.left-i.left,right:s.right-i.left,bottom:s.bottom-i.top,x:s.x-i.x,y:s.y-i.y}}}class J extends U{constructor(e){super();u(this,"dom");this.dom=e,this.dom.$=this}domRect(e){const s={bottom:innerHeight,height:innerHeight,left:0,right:innerWidth,top:0,width:innerWidth,x:0,y:0};if(!e)return s;const i=e instanceof M?e.dom.getBoundingClientRect():e;return{...s,top:s.top-i.top,left:s.left-i.left,right:s.right-i.left,bottom:s.bottom-i.top,x:s.x-i.x,y:s.y-i.y}}static from(e){return e.$ instanceof J?e.$:new J(e)}}const Mt="modulepreload",At=function(r){return"/"+r},gt={},Ct=function(t,e,s){let i=Promise.resolve();if(e&&e.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));i=Promise.allSettled(e.map(c=>{if(c=At(c),c in gt)return;gt[c]=!0;const h=c.endsWith(".css"),d=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${d}`))return;const m=document.createElement("link");if(m.rel=h?"stylesheet":Mt,h||(m.as="script"),m.crossOrigin="",m.href=c,o&&m.setAttribute("nonce",o),document.head.appendChild(m),h)return new Promise((w,l)=>{m.addEventListener("load",w),m.addEventListener("error",()=>l(new Error(`Unable to preload CSS for ${c}`)))})}))}function n(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return i.then(a=>{for(const o of a||[])o.status==="rejected"&&n(o.reason);return t().catch(n)})};class Rt{constructor(t){u(this,"$container");u(this,"childList",new Set);this.$container=t}add(t,e=-1){if(e===-1||this.childList.size-1===e)this.childList.add(t);else{const s=[...this.childList];s.splice(e,0,t),this.childList.clear(),s.forEach(i=>this.childList.add(i))}t.parent=this.$container}remove(t){return this.childList.has(t)?(this.childList.delete(t),t.parent=void 0,this):this}removeAll(t=!0){this.childList.forEach(e=>this.remove(e)),t&&this.render()}replace(t,e){const s=this.array;return s.splice(s.indexOf(t),1,e),t.remove(),this.childList.clear(),s.forEach(i=>this.childList.add(i)),e.parent=this.$container,this}render(){const[t,e]=[this.array.map(i=>i.dom),Array.from(this.dom.childNodes)],s=[];for(;e.length||t.length;){const[i,n]=[e.at(0),t.at(0)];n?i?n!==i?(n.$.__hidden||(this.dom.insertBefore(n,i),s.push(n)),t.shift()):(n.$.__hidden&&this.dom.removeChild(n),t.shift(),e.shift()):(n.$.__hidden||this.dom.append(n),t.shift()):(i&&!s.includes(i)&&i.remove(),e.shift())}}indexOf(t){return this.array.indexOf(t)}get array(){return[...this.childList.values()]}get dom(){return this.$container.dom}}class I{constructor(t,e){u(this,"_value");u(this,"attributes",new Map);u(this,"linkStates",new Set);u(this,"options",{});this.set(t),e&&(this.options=e)}set(t){this._value=t,t instanceof I&&t.linkStates.add(this),this.update(),this.linkStates.forEach(e=>e.update())}update(){for(const[t,e]of this.attributes.entries())for(const s of e)t[s]instanceof Function?this.options.format?t[s](this.options.format(this.value)):t[s](this.value):s in t&&(t[s]=this.value)}toString(){return this.options.format?this.options.format(this.value):this.value instanceof Object?JSON.stringify(this.toJSON()):`${this.value}`}use(t,e){const s=this.attributes.get(t);s?s.add(e):this.attributes.set(t,new Set().add(e))}toJSON(){return this.value instanceof I?this.value.toJSON():this.value instanceof Object?I.toJSON(this.value):this.toString()}static toJSON(t){const e={};for(let[s,i]of Object.entries(t))i instanceof I?i=i.toJSON():i instanceof Object&&I.toJSON(i),Object.assign(e,{[s]:i});return e}get value(){return this._value instanceof I?this._value.value:this._value}}class q extends U{constructor(e){super();u(this,"dom");this.dom=new Text(e),this.dom.$=this}content(e){return $.fluent(this,arguments,()=>this.dom.textContent,()=>$.set(this.dom,"textContent",e))}}class Q extends M{constructor(t,e){super(t,e)}autocapitalize(t){return $.fluent(this,arguments,()=>this.dom.autocapitalize,()=>$.set(this.dom,"autocapitalize",t))}innerText(t){return $.fluent(this,arguments,()=>this.dom.innerText,()=>$.set(this.dom,"innerText",t))}title(t){return $.fluent(this,arguments,()=>this.dom.title,()=>$.set(this.dom,"title",t))}dir(t){return $.fluent(this,arguments,()=>this.dom.dir,()=>$.set(this.dom,"dir",t))}translate(t){return $.fluent(this,arguments,()=>this.dom.translate,()=>$.set(this.dom,"translate",t))}popover(t){return $.fluent(this,arguments,()=>this.dom.popover,()=>$.set(this.dom,"popover",t))}spellcheck(t){return $.fluent(this,arguments,()=>this.dom.spellcheck,()=>$.set(this.dom,"spellcheck",t))}inert(t){return $.fluent(this,arguments,()=>this.dom.inert,()=>$.set(this.dom,"inert",t))}lang(t){return $.fluent(this,arguments,()=>this.dom.lang,()=>$.set(this.dom,"lang",t))}draggable(t){return $.fluent(this,arguments,()=>this.dom.draggable,()=>$.set(this.dom,"draggable",t))}hidden(t){return $.fluent(this,arguments,()=>this.dom.hidden,()=>$.set(this.dom,"hidden",t))}click(){return this.dom.click(),this}attachInternals(){return this.dom.attachInternals()}hidePopover(){return this.dom.hidePopover(),this}showPopover(){return this.dom.showPopover(),this}togglePopover(){return this.dom.togglePopover(),this}get accessKeyLabel(){return this.dom.accessKeyLabel}get offsetHeight(){return this.dom.offsetHeight}get offsetLeft(){return this.dom.offsetLeft}get offsetParent(){return $(this.dom.offsetParent)}get offsetTop(){return this.dom.offsetTop}get offsetWidth(){return this.dom.offsetWidth}}class f extends Q{constructor(e,s){super(e,s);u(this,"children",new Rt(this));u(this,"__position_cursor",0)}content(e){return $.fluent(this,arguments,()=>this,()=>{this.children.removeAll(!1),this.insert(e)})}insert(e,s=-1){return $.fluent(this,arguments,()=>this,async()=>{if(e instanceof Function){let i=e(this);i instanceof Promise?e=await i:e=i}else e instanceof Promise&&(e=await e);e=$.orArrayResolve(e),this.__position_cursor=s<0?this.children.array.length+s:s;for(const i of e)if(i!=null){if(i instanceof Array)this.insert(i,this.__position_cursor);else if(typeof i=="string")this.children.add(new q(i),s);else if(i instanceof I){const n=new q(i.toString());i.use(n,"content"),this.children.add(n,s)}else if(i instanceof Promise){const n=(await Ct(async()=>{const{$Async:o}=await Promise.resolve().then(()=>Ut);return{$Async:o}},void 0)).$Async,a=new n().await(i);this.children.add(a,s)}else this.children.add(i,s);this.__position_cursor+=1}this.children.render()})}clear(){return this.children.removeAll(),this}$(e){return $(this.dom.querySelector(e))}$all(e){return Array.from(this.dom.querySelectorAll(e)).map(s=>$(s))}get scrollHeight(){return this.dom.scrollHeight}get scrollWidth(){return this.dom.scrollWidth}scrollTop(e){return $.fluent(this,arguments,()=>this.dom.scrollTop,()=>$.set(this.dom,"scrollTop",e))}scrollLeft(e){return $.fluent(this,arguments,()=>this.dom.scrollLeft,()=>$.set(this.dom,"scrollLeft",e))}}class kt extends f{constructor(t){super("a",t),this.dom.addEventListener("click",e=>{$.anchorHandler&&this.href()&&(e.preventDefault(),$.anchorHandler(this,e))})}href(t){return $.fluent(this,arguments,()=>this.dom.href,()=>{t&&(this.dom.href=t)})}target(t){return $.fluent(this,arguments,()=>this.dom.target??void 0,()=>{t&&(this.dom.target=t)})}}class Nt extends M{constructor(t,e){super(t,e)}}var _;(r=>{function t(o,c,h,d){return c.length?(d(),o):h()}r.fluent=t;function e(o){return o instanceof Array?o:[o]}r.orArrayResolve=e;function s(o,c){return e(c).forEach(h=>{Object.getOwnPropertyNames(h.prototype).forEach(d=>{d!=="constructor"&&Object.defineProperty(o.prototype,d,Object.getOwnPropertyDescriptor(h.prototype,d)||Object.create(null))})}),o}r.mixin=s;function i(o,c,h){h!==void 0&&(o[c]=h)}r.set=i;function n(o){return new I(o)}r.state=n;function a(o){if(o.$)return o.$;if(o.nodeName.toLowerCase()==="body")return new f("body",{dom:o});if(o.nodeName.toLowerCase()==="#document")return J.from(o);if(o instanceof HTMLElement){const c=$.TagNameElementMap[o.tagName.toLowerCase()],h=c===f?new c(o.tagName,{dom:o}):new c({dom:o});if(h instanceof f)for(const d of Array.from(h.dom.childNodes))h.children.add($(d));return h}else if(o instanceof Text){const c=new q(o.textContent??"");return c.dom=o,c}else if(o instanceof SVGElement&&o.tagName.toLowerCase()==="svg")return new Nt("svg",{dom:o});throw`$NODE.FROM: NOT SUPPORT TARGET ELEMENT TYPE (${o.nodeName})`}r.from=a})(_||(_={}));class L{static create(...t){const e=class{};return Object.getOwnPropertyNames(L.prototype).forEach(s=>{s!=="constructor"&&t.includes(s)&&Object.defineProperty(e.prototype,s,Object.getOwnPropertyDescriptor(L.prototype,s)||Object.create(null))}),e}disabled(t){return $.fluent(this,arguments,()=>this.dom.disabled,()=>$.set(this.dom,"disabled",t))}checkValidity(){return this.dom.checkValidity()}reportValidity(){return this.dom.reportValidity()}formAction(t){return $.fluent(this,arguments,()=>this.dom.formAction,()=>$.set(this.dom,"formAction",t))}formEnctype(t){return $.fluent(this,arguments,()=>this.dom.formEnctype,()=>$.set(this.dom,"formEnctype",t))}formMethod(t){return $.fluent(this,arguments,()=>this.dom.formMethod,()=>$.set(this.dom,"formMethod",t))}formNoValidate(t){return $.fluent(this,arguments,()=>this.dom.formNoValidate,()=>$.set(this.dom,"formNoValidate",t))}formTarget(t){return $.fluent(this,arguments,()=>this.dom.formTarget,()=>$.set(this.dom,"formTarget",t))}autocomplete(t){return $.fluent(this,arguments,()=>this.dom.autocomplete,()=>$.set(this.dom,"autocomplete",t))}name(t){return $.fluent(this,arguments,()=>this.dom.name,()=>$.set(this.dom,"name",t))}maxLength(t){return $.fluent(this,arguments,()=>this.dom.maxLength,()=>$.set(this.dom,"maxLength",t))}minLength(t){return $.fluent(this,arguments,()=>this.dom.minLength,()=>$.set(this.dom,"minLength",t))}required(t){return $.fluent(this,arguments,()=>this.dom.required,()=>$.set(this.dom,"required",t))}label(t){return $.fluent(this,arguments,()=>this.dom.label,()=>$.set(this.dom,"label",t))}get form(){return this.dom.form?$(this.dom.form):null}get validationMessage(){return this.dom.validationMessage}get validity(){return this.dom.validity}get willValidate(){return this.dom.willValidate}}class ht extends f{constructor(t){super("button",t)}type(t){return $.fluent(this,arguments,()=>this.dom.type,()=>$.set(this.dom,"type",t))}}_.mixin(ht,L.create("disabled","checkValidity","formAction","formEnctype","formMethod","formNoValidate","formTarget","reportValidity"));class yt extends f{constructor(t){super("form",t)}action(t){return $.fluent(this,arguments,()=>this.dom.formAction,()=>$.set(this.dom,"formAction",t))}enctype(t){return $.fluent(this,arguments,()=>this.dom.formEnctype,()=>$.set(this.dom,"formEnctype",t))}method(t){return $.fluent(this,arguments,()=>this.dom.formMethod,()=>$.set(this.dom,"formMethod",t))}noValidate(t){return $.fluent(this,arguments,()=>this.dom.formNoValidate,()=>$.set(this.dom,"formNoValidate",t))}acceptCharset(t){return $.fluent(this,arguments,()=>this.dom.acceptCharset,()=>$.set(this.dom,"acceptCharset",t))}target(t){return $.fluent(this,arguments,()=>this.dom.formTarget,()=>$.set(this.dom,"formTarget",t))}requestSubmit(){return this.dom.requestSubmit(),this}reset(){return this.dom.reset(),this}submit(){return this.dom.submit(),this}get length(){return this.dom.length}get elements(){return Array.from(this.dom.elements).map(t=>$(t))}}_.mixin(yt,L.create("checkValidity","reportValidity","autocomplete"));class C extends Q{constructor(t){super("input",t)}value(t){return $.fluent(this,arguments,()=>this.type()==="number"?Number(this.dom.value):this.dom.value,()=>$.set(this.dom,"value",t,e=>{this.on("input",()=>{e.attributes.has(this.dom)!==!1&&(typeof e.value=="string"&&e.set(`${this.value()}`),typeof e.value=="number"&&e.set(Number(this.value())))})}))}type(t){return $.fluent(this,arguments,()=>this.dom.type,()=>$.set(this.dom,"type",t))}capture(t){return $.fluent(this,arguments,()=>this.dom.capture,()=>$.set(this.dom,"capture",t))}alt(t){return $.fluent(this,arguments,()=>this.dom.alt,()=>$.set(this.dom,"alt",t))}height(t){return $.fluent(this,arguments,()=>this.dom.height,()=>$.set(this.dom,"height",t))}width(t){return $.fluent(this,arguments,()=>this.dom.width,()=>$.set(this.dom,"width",t))}defaultValue(t){return $.fluent(this,arguments,()=>this.dom.defaultValue,()=>$.set(this.dom,"defaultValue",t))}dirName(t){return $.fluent(this,arguments,()=>this.dom.dirName,()=>$.set(this.dom,"dirName",t))}pattern(t){return $.fluent(this,arguments,()=>this.dom.pattern,()=>$.set(this.dom,"pattern",t))}placeholder(t){return $.fluent(this,arguments,()=>this.dom.placeholder,()=>$.set(this.dom,"placeholder",t))}readOnly(t){return $.fluent(this,arguments,()=>this.dom.readOnly,()=>$.set(this.dom,"readOnly",t))}selectionDirection(t){return $.fluent(this,arguments,()=>this.dom.selectionDirection,()=>$.set(this.dom,"selectionDirection",t))}selectionEnd(t){return $.fluent(this,arguments,()=>this.dom.selectionEnd,()=>$.set(this.dom,"selectionEnd",t))}selectionStart(t){return $.fluent(this,arguments,()=>this.dom.selectionStart,()=>$.set(this.dom,"selectionStart",t))}size(t){return $.fluent(this,arguments,()=>this.dom.size,()=>$.set(this.dom,"size",t))}src(t){return $.fluent(this,arguments,()=>this.dom.src,()=>$.set(this.dom,"src",t))}inputMode(t){return $.fluent(this,arguments,()=>this.dom.inputMode,()=>$.set(this.dom,"inputMode",t))}valueAsDate(t){return $.fluent(this,arguments,()=>this.dom.valueAsDate,()=>$.set(this.dom,"valueAsDate",t))}valueAsNumber(t){return $.fluent(this,arguments,()=>this.dom.valueAsNumber,()=>$.set(this.dom,"valueAsNumber",t))}webkitdirectory(t){return $.fluent(this,arguments,()=>this.dom.webkitdirectory,()=>$.set(this.dom,"webkitdirectory",t))}select(){return this.dom.select(),this}setCustomValidity(t){return this.dom.setCustomValidity(t),this}setRangeText(t,e,s,i){return typeof e=="number"&&typeof s=="number"&&this.dom.setRangeText(t,e,s,i),this.dom.setRangeText(t),this}setSelectionRange(t,e,s){return this.dom.setSelectionRange(t,e,s),this}showPicker(){return this.dom.showPicker(),this}get files(){return this.dom.files}get webkitEntries(){return this.dom.webkitEntries}get labels(){return Array.from(this.dom.labels??[]).map(t=>$(t))}}_.mixin(C,L.create("checkValidity","reportValidity","autocomplete","name","form","required","validationMessage","validity","willValidate","formAction","formEnctype","formMethod","formNoValidate","formTarget"));class Dt extends C{constructor(t){super(t),this.type("number")}static from(t){return $.mixin(C,this)}stepDown(){return this.dom.stepDown(),this}stepUp(){return this.dom.stepUp(),this}max(t){return $.fluent(this,arguments,()=>this.dom.max===""?null:parseInt(this.dom.min),()=>$.set(this.dom,"max",t==null?void 0:t.toString()))}min(t){return $.fluent(this,arguments,()=>this.dom.min===""?null:parseInt(this.dom.min),()=>$.set(this.dom,"min",t==null?void 0:t.toString()))}step(t){return $.fluent(this,arguments,()=>Number(this.dom.step),()=>$.set(this.dom,"step",t==null?void 0:t.toString()))}}class Ht extends C{constructor(t){super(t),this.type("radio")}static from(t){return $.mixin(C,this)}checked(t){return $.fluent(this,arguments,()=>this.dom.checked,()=>$.set(this.dom,"checked",t))}defaultChecked(t){return $.fluent(this,arguments,()=>this.dom.defaultChecked,()=>$.set(this.dom,"defaultChecked",t))}}class Vt extends C{constructor(t){super(t),this.type("file")}static from(t){return $.mixin(C,this)}multiple(t){return $.fluent(this,arguments,()=>this.dom.multiple,()=>$.set(this.dom,"multiple",t))}accept(...t){return $.fluent(this,arguments,()=>this.dom.accept.split(","),()=>this.dom.accept=t.toString())}}_.mixin(C,[Dt,Ht,Vt]);class vt extends f{constructor(t){super("label",t)}for(t){return $.fluent(this,arguments,()=>this.dom.htmlFor,()=>{$.set(this.dom,"htmlFor",t)})}get control(){return this.dom.control}}_.mixin(vt,L.create("form"));class jt extends Q{constructor(t){super("img",t)}async load(t){return new Promise(e=>{const s=this.once("load",()=>{e(s)});typeof t=="string"?s.src(t):t.then(i=>s.src(i))})}static resize(t,e){return new Promise(s=>{const i=new Image;if(i.addEventListener("load",()=>{const n=document.createElement("canvas"),a=n.getContext("2d");if(!a)throw"$Image.resize: context undefined";const o=i.width/i.height,[c,h,d]=[o>1,o<1,o===1],m=e instanceof Array?e[0]:h?e:e*o,w=e instanceof Array?e[1]:c?e:e/o;n.height=w,n.width=m,a.drawImage(i,0,0,m,w),s(n.toDataURL())},{once:!0}),t instanceof File){const n=new FileReader;n.addEventListener("load",()=>i.src=n.result),n.readAsDataURL(t)}else i.src=t})}alt(t){return $.fluent(this,arguments,()=>this.dom.alt,()=>$.set(this.dom,"alt",t))}crossOrigin(t){return $.fluent(this,arguments,()=>this.dom.crossOrigin,()=>$.set(this.dom,"crossOrigin",t))}decoding(t){return $.fluent(this,arguments,()=>this.dom.decoding,()=>$.set(this.dom,"decoding",t))}height(t){return $.fluent(this,arguments,()=>this.dom.height,()=>$.set(this.dom,"height",t))}isMap(t){return $.fluent(this,arguments,()=>this.dom.isMap,()=>$.set(this.dom,"isMap",t))}loading(t){return $.fluent(this,arguments,()=>this.dom.loading,()=>$.set(this.dom,"loading",t))}referrerPolicy(t){return $.fluent(this,arguments,()=>this.dom.referrerPolicy,()=>$.set(this.dom,"referrerPolicy",t))}sizes(t){return $.fluent(this,arguments,()=>this.dom.sizes,()=>$.set(this.dom,"sizes",t))}src(t){return $.fluent(this,arguments,()=>this.dom.src,()=>$.set(this.dom,"src",t))}srcset(t){return $.fluent(this,arguments,()=>this.dom.srcset,()=>$.set(this.dom,"srcset",t))}useMap(t){return $.fluent(this,arguments,()=>this.dom.useMap,()=>$.set(this.dom,"useMap",t))}width(t){return $.fluent(this,arguments,()=>this.dom.width,()=>$.set(this.dom,"width",t))}decode(){return this.dom.decode()}get complete(){return this.dom.complete}get currentSrc(){return this.dom.currentSrc}get naturalHeight(){return this.dom.naturalHeight}get naturalWidth(){return this.dom.naturalWidth}get x(){return this.dom.x}get y(){return this.dom.y}}class Wt extends f{constructor(t){super("canvas",t)}height(t){return $.fluent(this,arguments,()=>this.dom.height,()=>{$.set(this.dom,"height",t)})}width(t){return $.fluent(this,arguments,()=>this.dom.width,()=>{$.set(this.dom,"width",t)})}captureStream(t){return this.dom.captureStream(t)}getContext(t,e){return this.dom.getContext(t)}toBlob(t,e,s){return this.dom.toBlob(t,e,s),this}toDataURL(t,e){return this.dom.toDataURL(t,e)}transferControlToOffscreen(){return this.dom.transferControlToOffscreen()}}class Ft extends f{constructor(t){super("dialog",t)}open(t){return $.fluent(this,arguments,()=>this.dom.open,()=>$.set(this.dom,"open",t))}returnValue(t){return $.fluent(this,arguments,()=>this.dom.returnValue,()=>$.set(this.dom,"returnValue",t))}close(){return this.dom.close(),this}show(){return this.dom.show(),this}showModal(){return this.dom.showModal(),this}}class wt extends f{constructor(t){super("select")}add(t){return this.insert(t),this}item(t){return $(this.dom.item(t))}namedItem(t){return $(this.dom.namedItem(t))}multiple(t){return $.fluent(this,arguments,()=>this.dom.multiple,()=>$.set(this.dom,"multiple",t))}get length(){return this.dom.length}get size(){return this.dom.size}get options(){return Array.from(this.dom.options).map(t=>$(t))}get selectedIndex(){return this.dom.selectedIndex}get selectedOptions(){return Array.from(this.dom.selectedOptions).map(t=>$(t))}value(t){return $.fluent(this,arguments,()=>this.dom.value,()=>$.set(this.dom,"value",t,e=>{this.on("input",()=>{e.attributes.has(this.dom)!==!1&&(typeof e.value=="string"&&e.set(`${this.value()}`),typeof e.value=="number"&&e.set(Number(this.value())))})}))}get labels(){return Array.from(this.dom.labels??[]).map(t=>$(t))}}_.mixin(wt,L.create("checkValidity","reportValidity","autocomplete","name","form","required","disabled","validationMessage","validity","willValidate"));class bt extends f{constructor(t){super("option",t)}defaultSelected(t){return $.fluent(this,arguments,()=>this.dom.defaultSelected,()=>$.set(this.dom,"defaultSelected",t))}selected(t){return $.fluent(this,arguments,()=>this.dom.selected,()=>$.set(this.dom,"selected",t))}text(t){return $.fluent(this,arguments,()=>this.dom.text,()=>$.set(this.dom,"text",t))}value(t){return $.fluent(this,arguments,()=>this.dom.value,()=>$.set(this.dom,"value",t))}get form(){return this.dom.form?$(this.dom.form):null}get index(){return this.dom.index}}_.mixin(bt,L.create("form","disabled","label"));class Tt extends f{constructor(t){super("optgroup",t)}disabled(t){return $.fluent(this,arguments,()=>this.dom.disabled,()=>$.set(this.dom,"disabled",t))}}_.mixin(Tt,L.create("disabled","label"));class St extends f{constructor(t){super("textarea",t)}cols(t){return $.fluent(this,arguments,()=>this.dom.cols,()=>$.set(this.dom,"cols",t))}wrap(t){return $.fluent(this,arguments,()=>this.dom.wrap,()=>$.set(this.dom,"wrap",t))}value(t){return $.fluent(this,arguments,()=>this.dom.value,()=>$.set(this.dom,"value",t))}defaultValue(t){return $.fluent(this,arguments,()=>this.dom.defaultValue,()=>$.set(this.dom,"defaultValue",t))}dirName(t){return $.fluent(this,arguments,()=>this.dom.dirName,()=>$.set(this.dom,"dirName",t))}placeholder(t){return $.fluent(this,arguments,()=>this.dom.placeholder,()=>$.set(this.dom,"placeholder",t))}readOnly(t){return $.fluent(this,arguments,()=>this.dom.readOnly,()=>$.set(this.dom,"readOnly",t))}selectionDirection(t){return $.fluent(this,arguments,()=>this.dom.selectionDirection,()=>$.set(this.dom,"selectionDirection",t))}selectionEnd(t){return $.fluent(this,arguments,()=>this.dom.selectionEnd,()=>$.set(this.dom,"selectionEnd",t))}selectionStart(t){return $.fluent(this,arguments,()=>this.dom.selectionStart,()=>$.set(this.dom,"selectionStart",t))}type(t){return $.fluent(this,arguments,()=>this.dom.type,()=>$.set(this.dom,"type",t))}inputMode(t){return $.fluent(this,arguments,()=>this.dom.inputMode,()=>$.set(this.dom,"inputMode",t))}select(){return this.dom.select(),this}setCustomValidity(t){return this.dom.setCustomValidity(t),this}setRangeText(t,e,s,i){return typeof e=="number"&&typeof s=="number"&&this.dom.setRangeText(t,e,s,i),this.dom.setRangeText(t),this}setSelectionRange(t,e,s){return this.dom.setSelectionRange(t,e,s),this}get labels(){return Array.from(this.dom.labels??[]).map(t=>$(t))}}_.mixin(St,L.create("checkValidity","reportValidity","autocomplete","name","form","required","disabled","minLength","maxLength","validationMessage","validity","willValidate"));var tt;class It extends f{constructor(e){super("async",e);B(this,tt,!1)}await(e){return e instanceof Function?e(this).then(s=>this._loaded(s)):e.then(s=>this._loaded(s)),this}_loaded(e){if(K(this,tt,!0),typeof e=="string")this.replace(new q(e));else if(e instanceof I){const s=new q(e.toString());e.use(s,"content"),this.replace(s)}else e==null?this.replace(new q(String(e))):this.replace(e);this.dom.dispatchEvent(new Event("load"))}get loaded(){return x(this,tt)}}tt=new WeakMap;const Ut=Object.freeze(Object.defineProperty({__proto__:null,$Async:It},Symbol.toStringTag,{value:"Module"}));class Gt extends M{constructor(t,e){super(t,e)}autoplay(t){return $.fluent(this,arguments,()=>this.dom.autoplay,()=>$.set(this.dom,"autoplay",t))}get buffered(){return this.dom.buffered}controls(t){return $.fluent(this,arguments,()=>this.dom.controls,()=>$.set(this.dom,"controls",t))}crossOrigin(t){return $.fluent(this,arguments,()=>this.dom.crossOrigin,()=>$.set(this.dom,"crossOrigin",t))}get currentSrc(){return this.dom.currentSrc}currentTime(t){return $.fluent(this,arguments,()=>this.dom.currentTime,()=>$.set(this.dom,"currentTime",t))}defaultMuted(t){return $.fluent(this,arguments,()=>this.dom.defaultMuted,()=>$.set(this.dom,"defaultMuted",t))}defaultPlaybackRate(t){return $.fluent(this,arguments,()=>this.dom.defaultPlaybackRate,()=>$.set(this.dom,"defaultPlaybackRate",t))}disableRemotePlayback(t){return $.fluent(this,arguments,()=>this.dom.disableRemotePlayback,()=>$.set(this.dom,"disableRemotePlayback",t))}get duration(){return this.dom.duration}get ended(){return this.dom.ended}get error(){return this.dom.error}loop(t){return $.fluent(this,arguments,()=>this.dom.loop,()=>$.set(this.dom,"loop",t))}mediaKeys(t){return $.fluent(this,arguments,()=>this.dom.mediaKeys,()=>$.set(this.dom,"setMediaKeys",[t]))}muted(t){return $.fluent(this,arguments,()=>this.dom.muted,()=>$.set(this.dom,"muted",t))}get networkState(){return this.dom.networkState}get paused(){return this.dom.paused}playbackRate(t){return $.fluent(this,arguments,()=>this.dom.playbackRate,()=>$.set(this.dom,"playbackRate",t))}get played(){return this.dom.played}preload(t){return $.fluent(this,arguments,()=>this.dom.preload,()=>$.set(this.dom,"preload",t))}preservesPitch(t){return $.fluent(this,arguments,()=>this.dom.preservesPitch,()=>$.set(this.dom,"preservesPitch",t))}get readyState(){return this.dom.readyState}get remote(){return this.dom.remote}get seekable(){return this.dom.seekable}get seeking(){return this.dom.seeking}sinkId(t){return $.fluent(this,arguments,()=>this.dom.sinkId,()=>$.set(this.dom,"setSinkId",[t]))}src(t){return $.fluent(this,arguments,()=>this.dom.src,()=>$.set(this.dom,"src",t))}srcObject(t){return $.fluent(this,arguments,()=>this.dom.srcObject,()=>$.set(this.dom,"srcObject",t))}get textTracks(){return this.dom.textTracks}volume(t){return $.fluent(this,arguments,()=>this.dom.volume,()=>$.set(this.dom,"volume",t))}addTextTrack(t,e,s){return this.dom.addTextTrack(t,e,s)}canPlayType(t){return this.dom.canPlayType(t)}fastSeek(t){return this.dom.fastSeek(t),this}load(){return this.dom.load(),this}pause(){return this.dom.pause(),this}async play(){return await this.dom.play(),this}get isPlaying(){return this.currentTime()>0&&!this.paused&&!this.ended&&this.readyState>2}}class zt extends Gt{constructor(t){super("video",t)}disablePictureInPicture(t){return $.fluent(this,arguments,()=>this.dom.disablePictureInPicture,()=>$.set(this.dom,"disablePictureInPicture",t))}height(t){return $.fluent(this,arguments,()=>this.dom.height,()=>$.set(this.dom,"height",t))}width(t){return $.fluent(this,arguments,()=>this.dom.width,()=>$.set(this.dom,"width",t))}playsInline(t){return $.fluent(this,arguments,()=>this.dom.playsInline,()=>$.set(this.dom,"playsInline",t))}poster(t){return $.fluent(this,arguments,()=>this.dom.poster,()=>$.set(this.dom,"poster",t))}get videoHeight(){return this.dom.videoHeight}get videoWidth(){return this.dom.videoWidth}cancelVideoFrameCallback(t){return this.dom.cancelVideoFrameCallback(t),this}getVideoPlaybackQuality(){return this.dom.getVideoPlaybackQuality()}requestPictureInPicture(){return this.dom.requestPictureInPicture()}requestVideoFrameCallback(t){return this.dom.requestVideoFrameCallback(t)}}function T(r){if(typeof r>"u"||r===null||r instanceof U)return r;if(typeof r=="string"){if(r.startsWith("::"))return Array.from(document.querySelectorAll(r.replace(/^::/,""))).map(t=>T(t));if(r.startsWith(":"))return T(document.querySelector(r.replace(/^:/,"")));if(r in T.TagNameElementMap){const t=T.TagNameElementMap[r];return t===Q?new Q(r):t===f?new f(r):new t}else return new f(r)}if(r instanceof Node)return r.$?r.$:_.from(r);throw`$: NOT SUPPORT TARGET ELEMENT TYPE ('${r}')`}(r=>{r.anchorHandler=null,r.TagNameElementMap={html:f,head:f,document:J,body:f,a:kt,p:f,pre:f,code:f,blockquote:f,strong:f,h1:f,h2:f,h3:f,h4:f,h5:f,h6:f,div:f,ol:f,ul:f,dl:f,li:f,input:C,label:vt,button:ht,form:yt,img:jt,dialog:Ft,canvas:Wt,select:wt,option:bt,optgroup:Tt,textarea:St,video:zt,async:It};function t(l,p,y,S){return p.length?(S(),l):y()}r.fluent=t;function e(l){return l instanceof Array?l:[l]}r.orArrayResolve=e;function s(l,p){return _.mixin(l,p)}r.mixin=s;function i(l,p,y,S){if(y!==void 0){if(y instanceof I){y.use(l,p),l[p]instanceof Function?l[p](...y.value):l[p]=y.value,S&&S(y);return}l[p]instanceof Function?l[p](...y):l[p]=y}}r.set=i;function n(l,p){return new I(l,p)}r.state=n;async function a(l,p){return new Promise(y=>{const S=new FileReader;S.onload=O=>{const b=r("img");if(b.once("load",A=>{const V=r("canvas"),j=V.getContext("2d"),R=b.height()/b.width(),[P,G]=[R>1?p/R:p,R>1?p:p*R];V.height(G).width(P),j==null||j.drawImage(b.dom,0,0,P,G),y(V.toDataURL(l.type))}),!O.target)throw"$.resize(): e.target is null";b.src(O.target.result)},S.readAsDataURL(l)})}r.resize=a;function o(l=1){return parseInt(getComputedStyle(document.documentElement).fontSize)*l}r.rem=o;function c(l){const p=new DOMParser().parseFromString(l,"text/html").body;return Array.from(p.children).map(y=>r(y))}r.html=c;function h(l,p,y){if(typeof p=="number")return Array(p).fill("").map(O=>{const b=S(l)?l[0](...l.slice(1)):r(l);return y&&y(b),b});{const O=[];for(const b of p){const A=l instanceof Function?l(...b):S(l)?l[0](...l.slice(1)):r(l);b instanceof Function?b(A):(b instanceof U||typeof b=="string")&&A.content(b),O.push(A)}return O}function S(O){return O instanceof Array&&O[0]instanceof Function}}r.builder=h;function d(l,p){return Object.assign(r.TagNameElementMap,{[l]:p}),r.TagNameElementMap}r.registerTagName=d;function m(...l){return new et}r.events=m;function w(l){return l()}r.call=w})(T||(T={}));globalThis.$=T;class et{constructor(){u(this,"eventMap",new Map)}fire(t,...e){var s;return(s=this.eventMap.get(t))==null||s.forEach(i=>i(...e)),this}on(t,e){const s=this.eventMap.get(t)??this.eventMap.set(t,new Set).get(t);return s==null||s.add(e),this}off(t,e){var s;return(s=this.eventMap.get(t))==null||s.delete(e),this}once(t,e){const s=(...n)=>{var a;(a=this.eventMap.get(t))==null||a.delete(s),e(...n)},i=this.eventMap.get(t)??this.eventMap.set(t,new Set).get(t);return i==null||i.add(s),this}}Array.prototype.detype=function(...r){return this.filter(t=>{if(r.length)for(const e of r)return typeof t!=typeof e;else return t!==void 0})};Object.defineProperties(Set.prototype,{array:{get:function(){return Array.from(this)}}});Set.prototype.sort=function(r){return this.array.sort(r)};class _t extends f{constructor(e){super("layout",e);u(this,"_property",{ROW_MAX_HEIGHT:200,GAP:0,IS_RENDERING:!1,RENDER_REQUEST:!1,COLUNM:1,TYPE:"justified",ROOT:null,ITEM_PROPERTIES:new Map});this.css({display:"block",position:"relative"}),new ResizeObserver(s=>{this.inDOM()&&(this.render(),this.dom.dispatchEvent(new Event("resize")))}).observe(this.dom),document.addEventListener("scroll",s=>{s.target===this.root().dom&&this.scrollCompute()}),new IntersectionObserver(s=>{this.inDOM()&&this.render()}).observe(this.dom)}type(e){return $.fluent(this,arguments,()=>this._property.TYPE,()=>$.set(this._property,"TYPE",e))}maxHeight(e){return $.fluent(this,arguments,()=>this._property.ROW_MAX_HEIGHT,()=>$.set(this._property,"ROW_MAX_HEIGHT",e))}column(e){return $.fluent(this,arguments,()=>this._property.COLUNM,()=>$.set(this._property,"COLUNM",e))}gap(e){return $.fluent(this,arguments,()=>this._property.GAP,()=>$.set(this._property,"GAP",e))}root(e){return $.fluent(this,arguments,()=>this._property.ROOT??$(document),()=>$.set(this._property,"ROOT",e))}get COL_WIDTH(){return(this.offsetWidth-this._property.GAP*(this._property.COLUNM-1))/this._property.COLUNM}justifiedCompute(){const e=[],s=this.offsetWidth;for(const i of this.children.array){const n=$(i);if(!(n instanceof M))continue;const a=n.attribute("layout-item-ratio"),o=a?parseFloat(a):n.dom.offsetWidth/n.dom.offsetHeight,c={$node:n,ratio:o};let h=e.at(-1);(!h||h.heightd+=l.ratio);const m=d+o,w=(s-this._property.GAP*h.items.length)/m;h.items.push(c),h.ratio=m,h.height=w}return e}waterfallCompute(){const e=[],s=this.COL_WIDTH,i=()=>{if(e.lengthn.height-a.height)[0]};for(const n of this.children.array){const a=$(n);if(!(a instanceof M))continue;const o=a.attribute("layout-item-ratio"),c=o?parseFloat(o):a.dom.offsetWidth/a.dom.offsetHeight,h={$node:a,ratio:c},d=i();let m=0;d.items.forEach(p=>m+=p.ratio);const w=s/(d.height+s/c),l=s/w;d.items.push(h),d.ratio=w,d.height=l}return e}render(){if(!this.inDOM())return this;if(this._property.ITEM_PROPERTIES.clear(),this._property.TYPE==="justified"){const e=this.justifiedCompute();let s=0;for(const i of e){let n=0;i.height>this._property.ROW_MAX_HEIGHT&&(i.height=this._property.ROW_MAX_HEIGHT);for(const a of i.items){const o=a.ratio*i.height;a.$node.css({position:"absolute",height:`${i.height}px`,width:`${o}px`,top:`${s}px`,left:`${n}px`}),a.$node.attribute("layout-item-ratio",a.ratio),this._property.ITEM_PROPERTIES.set(a.$node,{height:i.height,width:o,top:s,left:n,ratio:a.ratio,$node:a.$node}),n+=i.height*a.ratio+this._property.GAP}s+=i.height+this._property.GAP}this.css({height:`${s}px`})}else if(this._property.TYPE="waterfall"){const e=this.waterfallCompute(),s=this.COL_WIDTH;let i=0;for(const n of e){let a=0;for(const o of n.items){const c=s/o.ratio;o.$node.css({position:"absolute",height:`${c}px`,width:`${s}px`,top:`${a}px`,left:`${i}px`}),o.$node.attribute("layout-item-ratio",o.ratio),this._property.ITEM_PROPERTIES.set(o.$node,{height:c,width:s,top:a,left:i,ratio:o.ratio,$node:o.$node}),a+=c+this._property.GAP}i+=s+this._property.GAP}if(e.length){const n=e.sort((a,o)=>o.height-a.height)[0];this.css({height:`${n.height+n.items.length*this._property.GAP}px`})}else this.css({height:""})}return this.scrollCompute(),this}scrollCompute(){if(this.inDOM()===!1)return;const e=document.documentElement.scrollTop-this.dom.offsetTop;this._property.ITEM_PROPERTIES.forEach((s,i)=>{const n=s.top;s.top+s.height>e&&n{this.contentId=e,this.events.fire("rendered",{$view:this,previousContent:i,nextContent:s})},o=()=>{this.events.fire("afterSwitch",{$view:this,previousId:e})};return this.events.fire("beforeSwitch",{$view:this,preventDefault:()=>n=!0,targetId:e,previousContent:i,nextContent:s,switched:o,rendered:a}),n||(this.content(s),a(),o()),this}get currentContent(){if(this.contentId)return this.viewCache.get(this.contentId)}}$.registerTagName("view",Ot);var D;const g=class g extends Ot{constructor(e){super({tagname:"router",...e});B(this,D,"");u(this,"routes",new Map);g.routers.add(this)}base(e){return $.fluent(this,arguments,()=>x(this,D),()=>{K(this,D,e??x(this,D))})}map(e){e=$.orArrayResolve(e);for(const s of e)s instanceof Array?this.map(s):this.routes.set(s.path(),s);return this.resolve(),this}resolve(){return new Promise(e=>{if(!location.pathname.startsWith(x(this,D)))return e(2);const s=location.pathname.replace(x(this,D),"/").replace("//","/"),i=s.split("/").map(p=>`/${p}`),n=location.search,a=new Map(n.replace("?","").split("&").map(p=>p.split("="))),c=(()=>{const p=[];for(const[y,S]of this.routes){const O=$.orArrayResolve(y);for(const b of O){let A=0,V={},j={};const R=b.split("/").map(P=>`/${P}`);if(!(i.lengthObject.assign(j,{[mt]:a.get(mt)})),G.startsWith("/:")){A++,Object.assign(V,{[G.replace("/:","")]:i[P].replace("/","")});continue}else if(b.startsWith("#")&&b===location.hash){A++;continue}else if(G===i[P]){A++;continue}else break}p.push({deep:A,$route:S,params:V,query:j,pathId:Object.keys(j).length!==0?s+n:Object.keys(V).length!==0?s:O[0]})}}}return p.sort((y,S)=>S.deep-y.deep).at(0)})();if(!c)return e(1);const{$route:h,params:d,pathId:m,query:w}=c;if(m===this.contentId)return e(0);this.events.once("rendered",({nextContent:p,previousContent:y})=>{y==null||y.events.fire("afterShift",{$route:y}),p.events.fire("rendered",{$route:p}),e(0)});const l=this.viewCache.get(m)??h.build({params:d,query:w});this.viewCache.has(m)||this.setView(m,l),this.events.once("beforeSwitch",()=>{var p;l.events.fire("beforeShift",{$route:l}),(p=this.currentContent)==null||p.events.fire("beforeShift",{$route:this.currentContent})}),this.events.once("afterSwitch",()=>l.events.fire("afterShift",{$route:l})),this.switchView(m)})}static init(){if(!history.state||!("index"in history.state)){const e={index:g.historyIndex};history.replaceState(e,"")}else g.historyIndex=history.state.index;return g.navigationDirection=0,g.resolve(),window.addEventListener("popstate",()=>g.popstate()),window.addEventListener("scroll",()=>{this.setScrollHistory(this.historyIndex,location.href,document.documentElement.scrollTop)}),history.scrollRestoration="manual",this}static open(e,s){return e===void 0?this:(e=this.urlResolver(e),e.href===this.url.href?this:e.origin!==this.url.origin?(window.open(e,s),this):(g.clearForwardScrollHistory(),g.historyIndex++,history.pushState(g.historyState,"",e),g.stateChange(0),g.resolve(),this))}static back(){return this.historyIndex--,history.back(),this.stateChange(1),this}static replace(e){return e===void 0?this:(e=this.urlResolver(e),history.replaceState(g.historyState,"",e),this.stateChange(2),this.setScrollHistory(this.historyIndex,location.href,0),g.resolve(),this)}static urlResolver(e){return e instanceof URL?e:(e.startsWith("/")&&(e=`${location.origin}${e}`),e.startsWith("#")&&(e=`${location.origin}${location.pathname}${e}`),new URL(e))}static popstate(){const e=history.state.index>g.historyIndex?0:history.state.indexe.resolve())),this.scrollRestoration(),this.setScrollHistory(this.historyIndex,location.href,document.documentElement.scrollTop)}static get historyState(){return{index:g.historyIndex}}static stateChange(e){const s=this.url,i=new URL(location.href);this.url=i,g.events.fire("stateChange",{beforeURL:s,afterURL:i,direction:e}),g.navigationDirection=e}static setScrollHistory(e,s,i){const n=this.getScrollHistory();if(!n)return sessionStorage.setItem(this.scrollHistoryKey,JSON.stringify({[e]:{url:s,value:i}}));n[e]={url:s,value:i},sessionStorage.setItem(this.scrollHistoryKey,JSON.stringify(n))}static getScrollHistory(){const e=sessionStorage.getItem(this.scrollHistoryKey);if(e)return JSON.parse(e)}static clearForwardScrollHistory(){const e=this.getScrollHistory();if(e)for(const s in e)Number(s)>this.historyIndex&&delete e[s],sessionStorage.setItem(this.scrollHistoryKey,JSON.stringify(e))}static scrollRestoration(){const e=this.getScrollHistory();if(e&&e[this.historyIndex])document.documentElement.scrollTop=e[this.historyIndex].value??0;else if(location.hash.length){const s=$(document.body).$(location.hash);s&&(document.documentElement.scrollTop=s.dom.offsetTop)}else document.documentElement.scrollTop=0}};D=new WeakMap,u(g,"routers",new Set),u(g,"events",new et),u(g,"navigationDirection"),u(g,"historyIndex",0),u(g,"url",new URL(location.href)),u(g,"scrollHistoryKey","$ROUTER_SCROLL_HISTORY");let E=g;var W=(r=>(r[r.Forward=0]="Forward",r[r.Back=1]="Back",r[r.Replace=2]="Replace",r))(W||{});E.init();var X,H;const lt=class lt extends f{constructor(e){super("route",e);B(this,X,"");B(this,H);u(this,"rendered",!1)}path(e){return $.fluent(this,arguments,()=>x(this,X),()=>K(this,X,e??x(this,X)))}builder(e){return K(this,H,e),this}render(e){return x(this,H)&&this.content(x(this,H).call(this,{$route:this,params:e.params,query:e.query})),this.rendered=!0,this}build(e){return new lt({dom:this.dom.cloneNode()}).self(s=>{x(this,H)&&s.builder(x(this,H)).render({params:e.params,query:e.query})})}};X=new WeakMap,H=new WeakMap;let ot=lt;$.registerTagName("router",E);$.registerTagName("route",ot);Object.assign($,{open(r,t){return E.open(r,t)},replace(r){return E.replace(r)},back(){return E.back()}});const N=class N{constructor(t){u(this,"posts",new Map);u(this,"tags",new Map);Object.assign(this,t),this.origin.endsWith("/")&&(this.origin=this.origin.slice(0,-1)),N.manager.set(this.name,this)}static set(t){return this.used=t,this.name$.set(t.name),this.storageAPI=t.name,this.events.fire("set"),this}static get storageAPI(){return localStorage.getItem("booru_api")}static set storageAPI(t){t?localStorage.setItem("booru_api",t):localStorage.removeItem("booru_api")}};u(N,"used"),u(N,"events",new et),u(N,"name$",$.state(N.name)),u(N,"manager",new Map);let v=N;const qt=new Intl.NumberFormat("en",{notation:"compact"});class xt{constructor(t,e){u(this,"post_count$",$.state(0,{format:t=>`${qt.format(t)}`}));u(this,"name$",$.state(""));u(this,"booru");this.booru=t,Object.assign(this,e),this.$update()}static async fetch(t,e){var n;const s=await fetch(`${t.origin}/tags/${e}.json`).then(async a=>await a.json()),i=((n=t.tags.get(s.id))==null?void 0:n.update(s))??new this(t,s);return t.tags.set(i.id,i),i}static async fetchMultiple(t,e,s=1e3){let i="";if(e)for(const[c,h]of Object.entries(e))if(h instanceof Array)i+=`&search[${c}]=${h}`;else if(h instanceof Object)for(const[d,m]of Object.entries(h))i+=`&search[${c}${d}]=${m}`;else i+=`&search[${c}]=${h}`;return(await(await fetch(`${t.origin}/tags.json?limit=${s}${i}`)).json()).map(c=>{var d;const h=((d=t.tags.get(c.id))==null?void 0:d.update(c))??new this(t,c);return t.tags.set(h.id,h),h})}update(t){return Object.assign(this,t),this.$update(),this}$update(){this.post_count$.set(this.post_count),this.name$.set(this.name)}}var F=(r=>(r[r.General=0]="General",r[r.Artist=1]="Artist",r[r.Copyright=3]="Copyright",r[r.Character=4]="Character",r[r.Meta=5]="Meta",r))(F||{});class Y{constructor(t){u(this,"name$",$.state("loding..."));Object.assign(this,t),this.update$()}static async fetch(t,e){var n;const s=await fetch(`${t.origin}/users/${e}.json`).then(async a=>await a.json()),i=((n=this.manager.get(s.id))==null?void 0:n.update(s))??new this(s);return this.manager.set(i.id,i),i}static async fetchMultiple(t,e,s=200){let i="";if(e)for(const[c,h]of Object.entries(e))if(h instanceof Array)i+=`&search[${c}]=${h}`;else if(h instanceof Object)for(const[d,m]of Object.entries(h))i+=`&search[${c}${d}]=${m}`;else i+=`&search[${c}]=${h}`;return(await(await fetch(`${t.origin}/users.json?limit=${s}${i}`)).json()).map(c=>{const h=new this(c);return this.manager.set(h.id,h),h})}update(t){return Object.assign(this,t),this.update$(),this}update$(){this.name$.set(this.name)}}u(Y,"manager",new Map);const ct=1e3,it=ct*60,rt=it*60,nt=rt*24,Xt=nt*7,st=new Intl.RelativeTimeFormat("en",{style:"long"});function Bt(r){r=Math.floor(r);const t=r/ct,e=r/it,s=r/rt,i=r/nt,n=r%1e3,a=Math.floor(r%6e4/1e3),o=Math.floor(r%36e5/6e4),c=Math.floor(r%(36e5*24)/36e5),h=a.toString().padStart(2,"0"),d=o.toString().padStart(2,"0"),m=c.toString().padStart(2,"0");return{seconds:t,minutes:e,hours:s,days:i,mil:n,s:a,min:o,h:c,ss:h,mm:d,hh:m}}function Kt(r,t=Date.now()){const e=r-t,s=Math.abs(e);if(sawait s.json());return this.update(e),Y.fetchMultiple(this.booru,{id:[this.uploader_id,this.approver_id].detype(null)}).then(()=>this.update$()),this}static async fetchMultiple(e,s,i=20){let n="";if(s){if(typeof s=="string")n=s;else for(const[d,m]of Object.entries(s))if(m!==void 0){if(d==="tags"){n+=`${m}`;continue}n.at(-1)!=="="&&(n+=" "),n+=`${d}:${m}`}}const o=await(await fetch(`${e.origin}/posts.json?limit=${i}&tags=${n}&_method=get`)).json(),c=o.map(d=>{var w;const m=((w=e.posts.get(d.id))==null?void 0:w.update(d))??new this(e,d.id,d);return e.posts.set(m.id,m),m});if(!c.length)return c;const h=[...new Set(o.map(d=>[d.approver_id,d.uploader_id].detype(null)).flat())];return Y.fetchMultiple(e,{id:h}).then(()=>c.forEach(d=>d.update$())),c}update$(){var e,s,i,n;this.uploader$.set(((e=this.uploader)==null?void 0:e.name$)??((s=this.uploader_id)==null?void 0:s.toString())),this.approver$.set(((i=this.approver)==null?void 0:i.name$)??((n=this.approver_id)==null?void 0:n.toString())??"None"),this.created_date$.set(Kt(+new Date(this.created_at))),this.favorites$.set(this.fav_count),this.score$.set(this.score),this.file_size$.set(Yt(this.file_size)),this.file_ext$.set(this.file_ext),this.dimension$.set(`${this.image_width}x${this.image_height}`),this.createdDate=new Date(this.created_at),this.fire("update")}update(e){return Object.assign(this,e),this.update$(),this}async fetchTags(){return await this.ready,await xt.fetchMultiple(this.booru,{name:{_space:this.tag_string}})}get pathname(){return`/posts/${this.id}`}get uploader(){return Y.manager.get(this.uploader_id)}get approver(){return this.approver_id?Y.manager.get(this.approver_id):null}get isVideo(){return this.file_ext==="mp4"||this.file_ext==="webm"||this.file_ext==="zip"}get isGif(){return this.file_ext==="gif"}get isUgoria(){return this.file_ext==="zip"}get hasSound(){return this.tag_string_meta.includes("sound")}get tags(){const e=this.tag_string.split(" ");return[...this.booru.tags.values()].filter(s=>e.includes(s.name))}get previewURL(){var e;return((e=this.media_asset.variants.find(s=>s.file_ext==="webp"))==null?void 0:e.url)??this.large_file_url}}class Et{constructor(t){Object.assign(this,t)}static async fetch(t,e){const s=await fetch(`${t.origin}/artist_commentaries/${e}.json`);return new this(await s.json())}static async fetchMultiple(t,e,s=200){let i="";if(e)for(const[c,h]of Object.entries(e))if(h instanceof Array)i+=`&search[${c}]=${h}`;else if(h instanceof Object)for(const[d,m]of Object.entries(h))i+=`&search[${c}${d}]=${m}`;else i+=`&search[${c}]=${h}`;return(await(await fetch(`${t.origin}/artist_commentaries.json?limit=${s}${i}`)).json()).map(c=>{const h=new this(c);return this.manager.set(h.id,h),h})}}u(Et,"manager",new Map);const Jt=$("route").path("/posts/:id").id("post").builder(({$route:r,params:t})=>{if(!Number(t.id))return $("h1").content("404: POST NOT FOUND");const e=Z.get(v.used,+t.id);return[$("div").class("viewer").content(async()=>(await e.ready,e.isVideo?$("video").height(e.image_height).width(e.image_width).src(e.file_ext==="zip"?e.large_file_url:e.file_url).controls(!0).autoplay(!0).loop(!0).disablePictureInPicture(!0):$("img").src(e.large_file_url))),$("div").class("content").content([$("h3").content("Artist's Commentary"),$("section").class("commentary").content(async s=>{const i=(await Et.fetchMultiple(v.used,{post:{_id:e.id}})).at(0);return[i?[i.original_title?$("h3").content(i.original_title):null,$("pre").content(i.original_description)]:"No commentary"]})]),$("div").class("sidebar").self(s=>{let i=0;addEventListener("scroll",()=>{s.inDOM()&&(i=document.documentElement.scrollTop)}),r.on("beforeShift",()=>{innerWidth>800&&s.css({position:"absolute",top:`calc(${i}px + var(--nav-height) + var(--padding))`})}).on("afterShift",()=>s.css({position:"",top:""}))}).content([$("section").class("post-info").content([new k("id").name("Post").value(`#${t.id}`),new k("uploader").name("Uploader").value(e.uploader$),new k("approver").name("Approver").value(e.approver$),new k("date").name("Date").value(e.created_date$),new k("size").name("Size").value([e.file_size$,e.dimension$]),new k("file").name("File Type").value(e.file_ext$),$("div").class("inline").content([new k("favorites").name("Favorites").value(e.favorites$),new k("score").name("Score").value(e.score$)]),$("div").class("buttons").content([$("icon-button").class("vertical").icon("link-outline").content(v.name$).on("click",(s,i)=>{s.preventDefault(),navigator.clipboard.writeText(`${v.used.origin}${location.pathname}`),i.content("Copied!"),setTimeout(()=>{i.content(v.name$)},2e3)}),$("icon-button").class("vertical").icon("link-outline").content("File").on("click",(s,i)=>{s.preventDefault(),navigator.clipboard.writeText(e.file_url),i.content("Copied!"),setTimeout(()=>{i.content("File")},2e3)}),$("icon-button").class("vertical").icon("link-outline").content("Webm").on("click",(s,i)=>{s.preventDefault(),navigator.clipboard.writeText(e.previewURL),i.content("Copied!"),setTimeout(()=>{i.content("Webm")},2e3)}).hide(!0).self(async s=>{await e.ready,e.file_ext==="zip"&&s.hide(!1)})])]),$("div").class("post-tags").content(async s=>{const i=await e.fetchTags(),[n,a,o,c,h]=[i.filter(m=>m.category===F.Artist),i.filter(m=>m.category===F.Character),i.filter(m=>m.category===F.General),i.filter(m=>m.category===F.Meta),i.filter(m=>m.category===F.Copyright)];return[d("Artist",n),d("Character",a),d("Copyright",h),d("Meta",c),d("General",o)];function d(m,w){return w.length?[$("h3").content(m),$("section").content([w.map(l=>$("div").class("tag").content([$("a").class("tag-name").content(l.name).href(`/posts?tags=${l.name}`),$("span").class("tag-post-count").content(l.post_count$)]))])]:null}})])]});class k extends f{constructor(e){super("div");u(this,"$name",$("span").class("property-name"));u(this,"$values",$("div").class("property-values"));this.staticClass("property").attribute("property-id",e),this.content([this.$name,this.$values])}name(e){return this.$name.content(e),this}value(e){const s=$.orArrayResolve(e);return this.$values.content(s.map(i=>$("span").staticClass("property-value").content(i))),this}}class Qt extends f{constructor(e){super("post-tile");u(this,"post");u(this,"$video");u(this,"duration$",$.state(""));this.post=e,this.$video=this.post.isVideo?$("video").width(this.post.image_width).height(this.post.image_height).disablePictureInPicture(!0).loop(!0).muted(!0).hide(!0).on("mousedown",s=>s.preventDefault()):null,this.attribute("filetype",this.post.file_ext),this.durationUpdate(),this.build()}build(){var s,i;let e;(s=this.$video)==null||s.on("playing",(n,a)=>{e=setInterval(()=>{this.durationUpdate()},500)}),(i=this.$video)==null||i.on("pause",()=>{clearInterval(e),this.durationUpdate()}),this.class("loading").content([this.post.isVideo?$("div").class("video-detail").content([this.post.hasSound?$("ion-icon").name("volume-medium-outline"):null,this.post.isUgoria?$("ion-icon").name("images-outline"):null,$("span").class("duration").content(this.duration$)]):null,this.post.isGif?$("div").class("gif-detail").content([$("span").content("GIF")]):null,$("a").href(this.post.pathname).content(()=>[this.$video,$("img").draggable(!1).css({opacity:"0"}).width(this.post.image_width).height(this.post.image_height).src(this.post.previewURL).loading("lazy").on("mousedown",n=>n.preventDefault()).once("load",(n,a)=>{a.src(this.post.previewURL).on(["mouseenter","touchstart"],()=>{this.post.isGif&&a.src(this.post.large_file_url)}).on(["mouseleave","touchend","touchcancel"],()=>{this.post.isGif&&a.src(this.post.previewURL)}).animate({opacity:[0,1]},{duration:300,fill:"both"}),this.removeClass("loading")})]).on(["mouseenter","touchstart"],()=>{var n,a;(n=this.$video)!=null&&n.isPlaying||(a=this.$video)==null||a.src(this.post.large_file_url).hide(!1).play().catch(o=>{})}).on(["mouseleave","touchend","touchcancel"],()=>{var n;(n=this.$video)==null||n.pause().currentTime(0).hide(!0)})])}durationUpdate(){if(!this.$video)return;const e=Bt(this.post.media_asset.duration*1e3-this.$video.currentTime()*1e3);this.duration$.set(Number(e.hh)>0?`${e.hh}:${e.mm}:${e.ss}`:`${e.mm}:${e.ss}`)}}class $t extends _t{constructor(e){super();u(this,"posts",new Set);u(this,"$posts",new Set);u(this,"tags");this.tags=e==null?void 0:e.tags,this.addStaticClass("post-grid"),this.type("waterfall").gap(10),this.init()}async init(){setInterval(()=>{this.inDOM()&&document.documentElement.scrollTop===0&&this.updateNewest()},1e4),v.events.on("set",()=>{this.removeAll()}),this.on("resize",()=>this.resize()),this.loader()}async loader(){if(!this.inDOM())return setTimeout(()=>this.loader(),100);for(;this.inDOM()&&document.documentElement.scrollHeight<=innerHeight*2;)if(await this.getPosts(),!this.posts.size)return;document.documentElement.scrollTop+innerHeight>document.documentElement.scrollHeight-innerHeight*2&&await this.getPosts(),setTimeout(()=>this.loader(),100)}resize(){const e=Math.round(this.dom.clientWidth/300);this.column(e>=2?e:2)}addPost(e){e=$.orArrayResolve(e);for(const i of e){if(!i.file_url||this.posts.has(i))continue;const n=new Qt(i);this.$posts.add(n),this.posts.add(i)}const s=[...this.$posts.values()].sort((i,n)=>+n.post.createdDate-+i.post.createdDate);return this.content(s).render(),this}removeAll(){return this.posts.clear(),this.$posts.clear(),this.animate({opacity:[1,0]},{duration:300,easing:"ease"},()=>this.clear().render()),this}async updateNewest(){const e=this.sortedPosts.at(0),s=await Z.fetchMultiple(v.used,{tags:this.tags,id:e?`>${e.id}`:void 0},100);return this.addPost(s),this}async getPosts(){const e=this.sortedPosts.at(-1),s=await Z.fetchMultiple(v.used,{tags:this.tags,id:e?`<${e.id}`:void 0},100);return this.addPost(s),this}get sortedPosts(){return this.posts.array.sort((e,s)=>+s.createdDate-+e.createdDate)}}class Zt extends f{constructor(){super("searchbar");u(this,"$tagInput",new se(this));u(this,"$selectionList",new te);u(this,"typingTimer",null);u(this,"$filter",$("div").class("filter"));this.build(),window.addEventListener("keyup",e=>{!this.inDOM()&&e.key==="/"&&this.activate(),this.inDOM()&&e.key==="Escape"&&this.inactivate()})}build(){this.content([$("div").class("input-container").content([this.$tagInput.on("input",()=>this.inputHandler()).on("keydown",e=>this.keyHandler(e)),$("ion-icon").name("close-circle-outline").title("Clear Input").on("click",()=>this.$tagInput.clearAll())]).on("click",e=>{e.target===this.$tagInput.dom&&this.$tagInput.addTag().input()}),$("div").class("selection-list-container").content([this.$selectionList]),this.$filter.on("click",()=>{location.hash==="#search"&&$.back()})])}activate(){return this.hide(!1),this.$filter.animate({opacity:[0,.5]},{duration:300,easing:"ease"}),this.$tagInput.input(),this}inactivate(){return this.animate({opacity:[.5,0]},{duration:300,easing:"ease"},()=>this.hide(!0)),this}keyHandler(e){var n,a;const s=()=>{e.preventDefault(),this.$tagInput.addTag().input()},i=o=>{const c=this.$tagInput.children.indexOf(this.$tagInput.$inputor),h=this.$tagInput.children.array.at(c+1);this.$tagInput.addTag(o.value()),h?this.$tagInput.editTag(h):this.$tagInput.input()};switch(e.key){case"ArrowUp":{e.preventDefault(),this.$selectionList.focusPrevSelection(),this.$tagInput.value((n=this.$selectionList.focused)==null?void 0:n.value());break}case"ArrowDown":{e.preventDefault(),this.$selectionList.focusNextSelection(),this.$tagInput.value((a=this.$selectionList.focused)==null?void 0:a.value());break}case" ":s();break;case"Enter":{e.preventDefault(),this.$selectionList.focused?i(this.$selectionList.focused):(this.$tagInput.addTag(),this.search());break}case"Tab":{e.preventDefault();const o=this.$tagInput.children.indexOf(this.$tagInput.$inputor);if(e.shiftKey){this.$tagInput.editTag(this.$tagInput.children.array.at(o-1));break}if(this.$selectionList.focused)i(this.$selectionList.focused);else{const c=this.$tagInput.children.array.at(o+1);c?this.$tagInput.editTag(c):this.$tagInput.addTag().input()}break}case"Backspace":{const o=this.$tagInput.children.indexOf(this.$tagInput.$inputor);o!==0&&!this.$tagInput.$input.value().length&&(e.preventDefault(),this.$tagInput.editTag(this.$tagInput.children.array.at(o-1)));break}}}inputHandler(){this.typingTimer&&(clearTimeout(this.typingTimer),this.typingTimer=null),this.typingTimer=setTimeout(async()=>{this.typingTimer=null,this.getSearchSuggestions()},200)}async getSearchSuggestions(){const e=this.$tagInput.$input.value();if(!e.length)return this.$selectionList.clearSelections();const s=await xt.fetchMultiple(v.used,{fuzzy_name_matches:e,order:"similarity"});this.$selectionList.clearSelections().addSelections(s.map(i=>new ee().value(i.name).content([$("span").class("tag-name").content(i.name),$("span").class("tag-category").content(F[i.category])]).on("click",()=>{this.$tagInput.addTag(i.name).input()}))),this.$tagInput.$input.value().length||this.$selectionList.clearSelections()}search(){return $.replace(`/posts?tags=${this.$tagInput.query}`),this.$tagInput.clearAll(),this.inactivate(),this}checkURL(e,s){e.hash==="#search"&&this.inactivate(),s.hash==="#search"&&this.activate()}}class te extends f{constructor(){super("selection-list");u(this,"focused",null);u(this,"selections",new Set)}addSelections(e){e=$.orArrayResolve(e);for(const s of e)this.selections.add(s);return this.insert(e),this}clearSelections(){return this.focused=null,this.selections.clear(),this.clear(),this}focusSelection(e){return this.blurSelection(),this.focused=e,e.focus(),this}blurSelection(){var e;return(e=this.focused)==null||e.blur(),this.focused=null,this}focusNextSelection(){const e=this.selections.array,s=e.at(0);if(this.focused){const i=e.at(e.indexOf(this.focused)+1);i?this.focusSelection(i):s&&this.focusSelection(s)}else s&&this.focusSelection(s)}focusPrevSelection(){const e=this.selections.array;if(this.focused){const s=e.at(e.indexOf(this.focused)-1);s&&this.focusSelection(s)}else{const s=e.at(0);s&&this.focusSelection(s)}}}class ee extends f{constructor(){super("selection");u(this,"property",{value:""})}value(e){return $.fluent(this,arguments,()=>this.property.value,()=>$.set(this.property,"value",e))}focus(){return this.addClass("active"),this}blur(){return this.removeClass("active"),this}}class se extends f{constructor(e){super("tag-input");u(this,"$input",$("input").type("text"));u(this,"$sizer",$("span").class("sizer"));u(this,"$inputor",$("div").class("input-wrapper").content([this.$sizer,this.$input.on("input",()=>{this.$sizer.content(this.$input.value())})]));u(this,"tags",new Set);u(this,"$seachbar");this.$seachbar=e}input(){return this.insert(this.$inputor),this.$input.focus(),this.$input.value()?this.$seachbar.getSearchSuggestions():this.$seachbar.$selectionList.clearSelections(),this}addTag(e){if(e=e??this.$input.value(),!e.length)return this;const s=new ie(e);return s.on("click",()=>this.editTag(s)),this.tags.add(s),this.value(""),this.$inputor.replace(s),this}editTag(e){return this.addTag(),this.tags.delete(e),e.replace(this.$inputor),this.value(e.name),this.$input.focus(),this.$seachbar.getSearchSuggestions(),this}clearAll(){return this.value(""),this.tags.clear(),this.clear(),this}value(e){return e===void 0?this:(this.$input.value(e),this.$sizer.content(e),this)}get query(){return this.tags.array.map(e=>e.name).toString().replace(",","+")}}class ie extends f{constructor(e){super("tag");u(this,"name");this.name=e,this.build()}build(){this.content(this.name)}}class re extends f{constructor(){super("ion-icon")}name(t){return this.attribute("name",t),this}size(t){return this.attribute("size",t),this}}class ne extends ht{constructor(){super();u(this,"$icon",$("ion-icon"));u(this,"$label",$("span"));this.addStaticClass("icon"),this.build()}build(){super.content([this.$icon,this.$label])}content(e){return this.$label.content(e),this}icon(e){return this.$icon.name(e),this}}$.registerTagName("ion-icon",re);$.registerTagName("icon-button",ne);$.anchorHandler=r=>{$.open(r.href(),r.target())};const[at,oe]=[new v({origin:"https://danbooru.donmai.us",name:"Danbooru"}),new v({origin:"https://safebooru.donmai.us",name:"Safebooru"}),new v({origin:"https://testbooru.donmai.us",name:"Testbooru"})];v.set(v.manager.get(v.storageAPI??"")??at);const ut=new Zt().hide(!0);location.hash==="#search"&&ut.activate();$(document.body).content([$("nav").content([$("a").class("title").href("/").content([$("h1").class("booru-name").content(v.name$),$("h2").class("app").content([$("span").class("app-name").content("Viewer"),$("span").class("version").content("v0.3.3")])]),$("div").class("searchbar").content(["Search in ",v.name$]).self(r=>E.events.on("stateChange",({beforeURL:t,afterURL:e})=>{t.hash==="#search"&&r.hide(!1),e.hash==="#search"&&r.hide(!0)})).on("click",()=>$.open(location.href+"#search")),$("div").class("buttons").content([$("ion-icon").class("search").name("search-outline").title("Search").self(r=>E.events.on("stateChange",({beforeURL:t,afterURL:e})=>{t.hash==="#search"&&r.hide(!1),e.hash==="#search"&&r.hide(!0)})).on("click",()=>$.open(location.href+"#search")),$("ion-icon").class("switch").name("swap-horizontal").title("Switch Booru").on("click",()=>{v.used===at?v.set(oe):v.set(at)}),$("ion-icon").class("open").name("open-outline").title("Open in Original Site").on("click",()=>$.open(location.href.replace(location.origin,v.used.origin)))])]),ut,$("router").base("/").map([$("route").id("posts").path("/").builder(()=>new $t),$("route").id("posts").path("/posts?tags").builder(({query:r})=>new $t({tags:r.tags})),Jt]).on("beforeSwitch",r=>{r.preventDefault();function s(){var a;const n=$.call(()=>{switch(E.navigationDirection){case W.Forward:return["translateX(2%)","translateX(0%)"];case W.Back:return["translateX(-2%)","translateX(0%)"];case W.Replace:return}});r.$view.content(r.nextContent),r.rendered(),(a=r.nextContent.element)==null||a.class("animated").animate({opacity:[0,1],transform:n},{duration:300,easing:"ease"},()=>{var o;r.switched(),(o=r.nextContent.element)==null||o.removeClass("animated")})}function i(){var a,o;const n=$.call(()=>{switch(E.navigationDirection){case W.Forward:return["translateX(0%)","translateX(-2%)"];case W.Back:return["translateX(0%)","translateX(2%)"];case W.Replace:return}});(o=(a=r.previousContent)==null?void 0:a.element)==null||o.class("animated").animate({opacity:[1,0],transform:n},{duration:300,easing:"ease"},()=>{var c,h;(h=(c=r.previousContent)==null?void 0:c.element)==null||h.removeClass("animated"),s()})}r.previousContent?i():s()})]);E.events.on("stateChange",({beforeURL:r,afterURL:t})=>{ut.checkURL(r,t)}); diff --git a/dist/assets/index-qRel_iFf.css b/dist/assets/index-qRel_iFf.css deleted file mode 100644 index 8200e4d..0000000 --- a/dist/assets/index-qRel_iFf.css +++ /dev/null @@ -1 +0,0 @@ -layout.post-grid{margin-top:1rem}post-tile{display:block;transition:.3s all ease;position:relative;transition:all .3s ease;border-radius:10px;overflow:hidden;-webkit-tap-highlight-color:transparent;-webkit-user-select:none;user-select:none}@media (hover: hover){post-tile:hover{transform:scale(1.02);z-index:1;box-shadow:0 0 10px color-mix(in srgb,var(--background-color) 50%,transparent)}}post-tile.loading{transition:none}post-tile:active{transform:scale(.95)}post-tile div.video-detail,post-tile div.gif-detail{position:absolute;background-color:var(--background-color-lighter);color:var(--primary-color);bottom:.3rem;right:.3rem;padding:2px 4px;border-radius:4px;font-size:12px;display:flex;align-items:center;gap:.2rem;z-index:2}post-tile div.video-detail ion-icon,post-tile div.gif-detail ion-icon{font-size:1.5em}post-tile div.video-detail span.duration,post-tile div.gif-detail span.duration{text-transform:uppercase;z-index:2}post-tile img{height:100%;width:100%;vertical-align:top;background-color:var(--background-color)}post-tile video{height:100%;width:100%;object-fit:cover;position:absolute;z-index:1}searchbar{display:flex;align-items:center;flex-direction:column;width:100%;z-index:200;position:fixed;height:100%}searchbar div.input-container{margin-top:.4rem;background-color:color-mix(in srgb,var(--background-color-light) 70%,transparent);border-radius:.4rem;font-size:1rem;width:500px;padding:.4rem;max-width:calc(100% - 2rem);box-sizing:border-box;z-index:201;display:flex;align-items:center;border:1px solid var(--secondary-color-dark)}searchbar div.input-container:focus-within{outline:none}searchbar div.input-container tag-input{display:flex;gap:.4rem;width:100%;overflow:hidden;padding-inline:.4rem;box-sizing:border-box;cursor:text}searchbar div.input-container tag-input tag{display:inline-block;padding:.2rem .4rem;background-color:var(--secondary-color-dark);color:var(--secondary-color);border-radius:.4rem;cursor:pointer}searchbar div.input-container ion-icon{font-size:20px;color:var(--secondary-color-dark);cursor:pointer}searchbar div.input-container ion-icon:hover{color:var(--secondary-color)}searchbar div.selection-list-container{overflow:hidden;border-radius:.4rem;background-color:var(--background-color);z-index:201;max-width:calc(100% - 2rem);width:500px}searchbar div.selection-list-container selection-list{display:block;max-height:40vh;overflow-y:scroll;overflow-x:hidden;position:relative}searchbar div.selection-list-container selection-list::-webkit-scrollbar{width:4px}searchbar div.selection-list-container selection-list selection{display:flex;justify-content:space-between;align-items:center;padding:.4rem 1rem;cursor:pointer}searchbar div.selection-list-container selection-list selection:hover{background-color:color-mix(in srgb,var(--background-color-lighter) 50%,transparent)}searchbar div.selection-list-container selection-list selection.active{background-color:var(--background-color-lighter)}searchbar div.selection-list-container selection-list selection .tag-category{padding:.1rem .4rem;border-radius:.4rem;font-size:.9rem;background-color:var(--secondary-color-dark);color:var(--secondary-color)}searchbar div.filter{background-color:var(--background-color);opacity:.5;position:fixed;top:0;height:100%;width:100%;z-index:199}.input-wrapper{color:var(--primary-color);border:1px solid var(--secondary-color);border-radius:.4rem;position:relative;box-sizing:border-box;line-height:1em;font-size:14px;padding:4px 8px;display:inline-block;max-width:100%;text-overflow:ellipsis}.input-wrapper span.sizer{font-family:inherit;white-space:pre;height:1em;display:inline-block;font-size:inherit;line-height:inherit;box-sizing:border-box;position:relative;opacity:0;min-width:2px;-webkit-user-select:none;user-select:none;vertical-align:top}.input-wrapper input{height:100%;text-overflow:ellipsis;font-family:inherit;background:none;color:inherit;top:0;left:0;font-size:inherit;line-height:inherit;padding:inherit;position:absolute;box-sizing:border-box;width:100%;border:none;outline:none}#post{padding:0;padding-top:var(--nav-height)}#post section{background-color:#2f2f45;border-radius:20px;padding:20px}#post div.viewer{height:calc(100vh - 2rem - var(--nav-height));display:flex;justify-content:center;align-items:center;background-color:#000;border-radius:20px;overflow:hidden;width:calc(100vw - 300px - 4rem);margin:1rem}@media (max-width: 800px){#post div.viewer{width:100%;height:calc(100vh - var(--nav-height));border-radius:0;margin:0}}#post div.viewer img{max-width:100%;max-height:100%}#post div.viewer video{max-width:100%;max-height:100%;-webkit-user-drag:none;transition:all .3s ease}#post div.content{width:calc(100vw - 300px - 2rem);display:flex;flex-direction:column;padding:1rem;box-sizing:border-box}@media (max-width: 800px){#post div.content{width:100%}}#post div.content::-webkit-scrollbar{background-color:#000;width:4px}#post div.content::-webkit-scrollbar-thumb{background-color:#aeaeec;border-radius:2px}#post div.content>h3{padding-left:1rem;margin-block:1rem}#post div.content section.commentary *{text-wrap:wrap;word-break:break-word}#post div.sidebar{--padding: 1rem;position:fixed;top:calc(var(--nav-height) + var(--padding));right:var(--padding);display:flex;flex-direction:column;gap:.4rem;width:300px;overflow:scroll;overflow-x:hidden;height:calc(100vh - 2rem - var(--nav-height));border-radius:20px}@media (max-width: 800px){#post div.sidebar{position:static;width:100%;overflow:visible;height:100%;padding:1rem;box-sizing:border-box}}#post div.sidebar::-webkit-scrollbar{background-color:#000;width:0px}#post div.sidebar::-webkit-scrollbar-thumb{background-color:#aeaeec}#post div.sidebar h3{padding-left:1rem;margin-block:.6rem}#post div.sidebar .post-info{background-color:#2f2f45;border-radius:20px;padding:20px;display:flex;flex-direction:column;gap:.4rem}#post div.sidebar div.property{display:flex;gap:.6rem;align-items:center}#post div.sidebar div.property div.property-values{display:flex;gap:.4rem}#post div.sidebar div.property div.property-values span.property-value{background-color:var(--secondary-color-dark);color:var(--secondary-color);padding:2px 4px;border-radius:4px}#post div.sidebar div.inline{display:flex;gap:1rem}#post div.sidebar div.post-tags{display:flex;flex-direction:column;gap:.2rem}#post div.sidebar div.post-tags div.tag{align-items:center}#post div.sidebar div.post-tags div.tag a.tag-name{word-break:break-word;color:#d1d1ee;text-decoration:none}#post div.sidebar div.post-tags div.tag span.tag-post-count{background-color:var(--secondary-color-dark);color:var(--secondary-color);padding:0 4px;border-radius:4px;font-size:12px;margin-left:.4rem}page#root layout *{transition:all .3s ease}page#root .loader{text-align:center;padding-block:2rem}:root{--background-color: #1e1e2c;--background-color-lighter: #3b3b66;--background-color-light: #24243b;--primary-color: #d1d1ee;--primary-color-dark: #9696b3;--primary-color-darker: #72728d;--secondary-color: #aeaeec;--secondary-color-dark: #424268;--nav-height: 50px}html{overflow-x:hidden;font-size:14px}html ::-webkit-scrollbar{background-color:var(--background-color);width:8px}html ::-webkit-scrollbar-thumb{background-color:#aeaeec;border-radius:2px}body{overflow-x:hidden;background-color:var(--background-color);color:var(--primary-color);margin:0;font-family:Microsoft Yahei}nav{display:flex;width:100%;height:var(--nav-height);position:fixed;top:0;z-index:100;background-color:color-mix(in srgb,var(--background-color) 70%,transparent);justify-content:space-between;align-items:center;padding-inline:1rem;box-sizing:border-box;-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px)}nav a.title{display:flex;align-items:center;gap:.4rem;text-decoration:none}nav a.title .booru-name{color:var(--secondary-color);margin:0}nav a.title .app{display:flex;align-items:center;border-radius:.4rem;margin:0;gap:.4rem}nav a.title .app .version{color:var(--background-color);background-color:var(--secondary-color);padding:.2em .4em;border-radius:.4rem;font-size:.8rem;font-weight:700}nav a.title .app .app-name{display:none;font-size:1rem;color:var(--secondary-color)}nav div.searchbar{padding:.4rem 10%;max-width:500px;background-color:color-mix(in srgb,var(--background-color-light) 30%,transparent);border:1px solid var(--primary-color-darker);border-radius:.4rem;color:var(--primary-color-dark);transition:.3s all ease;cursor:pointer}nav div.searchbar:hover{color:var(--primary-color)}nav div.buttons{display:flex;align-items:center;gap:1rem}nav div.buttons ion-icon{transition:all .3s ease;border-radius:1rem;padding:.4rem}nav div.buttons ion-icon:hover{background-color:color-mix(in srgb,var(--background-color-lighter) 50%,transparent)}nav div.buttons ion-icon.search{display:none}@media (max-width: 800px){nav div.searchbar{display:none}nav div.buttons ion-icon.search{display:inline-block}}router{display:block;position:relative}router route{display:block;position:relative;padding-inline:10px;padding-top:var(--nav-height)}button{background-color:#aeaeec;padding:2px 4px;border-radius:.4rem;border:none;cursor:pointer}ion-icon{font-size:24px;color:var(--primary-color);cursor:pointer}ion-icon:hover{color:var(--secondary-color)} diff --git a/dist/index.html b/dist/index.html index 7bbca81..9f76f2c 100644 --- a/dist/index.html +++ b/dist/index.html @@ -7,8 +7,8 @@ Danbooru Viewer v0.2.5 - - + + diff --git a/index.scss b/index.scss index 07bcdbf..6bea6ef 100644 --- a/index.scss +++ b/index.scss @@ -1,6 +1,7 @@ @import '/src/component/PostGrid/$PostGrid'; @import '/src/component/PostTile/$PostTile'; @import '/src/component/Searchbar/$Searchbar'; +@import '/src/component/IconButton/$IconButton'; @import '/src/route/post/$post'; @import '/src/route/gallery/$gallery'; @@ -139,9 +140,10 @@ router { } button { - background-color: #aeaeec; - padding: 2px 4px; - border-radius: 0.4rem; + background-color: var(--secondary-color-dark); + color: var(--secondary-color); + padding: 0.8rem 1.2rem; + border-radius: 1rem; border: none; cursor: pointer; } diff --git a/package.json b/package.json index 4967694..aea1169 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "danbooru-viewer", "module": "index.ts", "type": "module", - "version": "0.3.2", + "version": "0.3.3", "devDependencies": { "@types/bun": "latest", "vite": "^5.4.8" diff --git a/src/component/IconButton/$IconButton.ts b/src/component/IconButton/$IconButton.ts new file mode 100644 index 0000000..3a4a93a --- /dev/null +++ b/src/component/IconButton/$IconButton.ts @@ -0,0 +1,28 @@ +import { $Button, type $ContainerContentBuilder } from "elexis"; + +export class $IconButton extends $Button { + $icon = $('ion-icon'); + $label = $('span'); + constructor() { + super(); + this.addStaticClass('icon') + this.build(); + } + + private build() { + super.content([ + this.$icon, + this.$label + ]) + } + + content(children: $ContainerContentBuilder): this { + this.$label.content(children); + return this; + } + + icon(name: string) { + this.$icon.name(name); + return this; + } +} \ No newline at end of file diff --git a/src/component/IconButton/_$IconButton.scss b/src/component/IconButton/_$IconButton.scss new file mode 100644 index 0000000..5f66d60 --- /dev/null +++ b/src/component/IconButton/_$IconButton.scss @@ -0,0 +1,19 @@ +button.icon { + display: flex; + justify-content: center; + align-items: center; + gap: 0.4rem; + padding: 0.4rem; + background-color: transparent; + ion-icon { + font-size: 1.5rem; + } + + &:hover { + background-color: var(--background-color-light); + } + + &.vertical { + flex-direction: column; + } +} \ No newline at end of file diff --git a/src/component/PostTile/$PostTile.ts b/src/component/PostTile/$PostTile.ts index fca4d7c..ff0b484 100644 --- a/src/component/PostTile/$PostTile.ts +++ b/src/component/PostTile/$PostTile.ts @@ -30,6 +30,7 @@ export class $PostTile extends $Container { this.post.isVideo ? $('div').class('video-detail').content([ this.post.hasSound ? $('ion-icon').name('volume-medium-outline') : null, + this.post.isUgoria ? $('ion-icon').name('images-outline') : null, $('span').class('duration').content(this.duration$) ]) : null, // Gif diff --git a/src/component/PostTile/_$PostTile.scss b/src/component/PostTile/_$PostTile.scss index 407867f..c0baf32 100644 --- a/src/component/PostTile/_$PostTile.scss +++ b/src/component/PostTile/_$PostTile.scss @@ -29,7 +29,8 @@ post-tile { color: var(--primary-color); bottom: 0.3rem; right: 0.3rem; - padding: 2px 4px; + padding: 0.2em 0.4em; + height: 1rem; border-radius: 4px; font-size: 12px; display: flex; @@ -39,7 +40,12 @@ post-tile { // text-shadow: 0 0 0.5em var(--background-color); ion-icon { - font-size: 1.5em; + font-size: 1.4rem; + + &[name="images-outline"] { + padding: 0.1rem; + font-size: 1rem; + } } span.duration { diff --git a/src/component/Searchbar/_$Searchbar.scss b/src/component/Searchbar/_$Searchbar.scss index bea98aa..9163deb 100644 --- a/src/component/Searchbar/_$Searchbar.scss +++ b/src/component/Searchbar/_$Searchbar.scss @@ -10,7 +10,7 @@ searchbar { div.input-container { margin-top: 0.4rem; - background-color: color-mix(in srgb, var(--background-color-light) 70%, transparent); + background-color: color-mix(in srgb, var(--background-color-light) 100%, transparent); border-radius: 0.4rem; font-size: 1rem; width: 500px; diff --git a/src/main.ts b/src/main.ts index 007bcc5..8ba76d9 100644 --- a/src/main.ts +++ b/src/main.ts @@ -7,15 +7,18 @@ import { $PostGrid } from './component/PostGrid/$PostGrid'; import { $Router, $RouterNavigationDirection } from '@elexis/router'; import { $Searchbar } from './component/Searchbar/$Searchbar'; import { $IonIcon } from './component/IonIcon/$IonIcon'; +import { $IconButton } from './component/IconButton/$IconButton'; // declare elexis module declare module 'elexis' { export namespace $ { export interface TagNameElementMap { - 'ion-icon': typeof $IonIcon + 'ion-icon': typeof $IonIcon; + 'icon-button': typeof $IconButton; } } } $.registerTagName('ion-icon', $IonIcon) +$.registerTagName('icon-button', $IconButton) $.anchorHandler = ($a) => { $.open($a.href(), $a.target())} // settings export const [danbooru, safebooru]: Booru[] = [ @@ -48,12 +51,15 @@ $(document.body).content([ $('ion-icon').class('search').name('search-outline').title('Search') .self($self => $Router.events.on('stateChange', ({beforeURL, afterURL}) => {if (beforeURL.hash === '#search') $self.hide(false); if (afterURL.hash === '#search') $self.hide(true)})) .on('click', () => $.open(location.href + '#search')), - // Switch Button + // Switch Booru $('ion-icon').class('switch').name('swap-horizontal').title('Switch Booru') .on('click', () => { if (Booru.used === danbooru) Booru.set(safebooru); else Booru.set(danbooru); - }) + }), + // Open Booru + $('ion-icon').class('open').name('open-outline').title('Open in Original Site') + .on('click', () => $.open(location.href.replace(location.origin, Booru.used.origin))), ]) ]), // Searchbar diff --git a/src/route/post/$post.ts b/src/route/post/$post.ts index 2a561aa..949aa78 100644 --- a/src/route/post/$post.ts +++ b/src/route/post/$post.ts @@ -11,7 +11,7 @@ export const post_route = $('route').path('/posts/:id').id('post').builder(({$ro $('div').class('viewer').content(async () => { await post.ready; return post.isVideo - ? $('video').height(post.image_height).width(post.image_width).src(post.file_ext === 'zip' ? post.large_file_url : post.file_url).controls(true).autoplay(true).loop(true) + ? $('video').height(post.image_height).width(post.image_width).src(post.file_ext === 'zip' ? post.large_file_url : post.file_url).controls(true).autoplay(true).loop(true).disablePictureInPicture(true) : $('img').src(post.large_file_url)//.once('load', (e, $img) => { $img.src(post.file_url)}) }), $('div').class('content').content([ @@ -46,14 +46,36 @@ export const post_route = $('route').path('/posts/:id').id('post').builder(({$ro new $Property('favorites').name('Favorites').value(post.favorites$), new $Property('score').name('Score').value(post.score$) ]), - $('button').content('Copy link').on('click', (e, $button) => { - e.preventDefault(); - navigator.clipboard.writeText(`${Booru.used.origin}${location.pathname}`); - $button.content('Copied!'); - setTimeout(() => { - $button.content('Copy link') - }, 2000); - }) + $('div').class('buttons').content([ + $('icon-button').class('vertical').icon('link-outline').content(Booru.name$) + .on('click', (e, $button) => { + e.preventDefault(); + navigator.clipboard.writeText(`${Booru.used.origin}${location.pathname}`); + $button.content('Copied!'); + setTimeout(() => { + $button.content(Booru.name$) + }, 2000); + }), + $('icon-button').class('vertical').icon('link-outline').content(`File`) + .on('click', (e, $button) => { + e.preventDefault(); + navigator.clipboard.writeText(post.file_url); + $button.content('Copied!'); + setTimeout(() => { + $button.content('File') + }, 2000); + }), + $('icon-button').class('vertical').icon('link-outline').content(`Webm`) + .on('click', (e, $button) => { + e.preventDefault(); + navigator.clipboard.writeText(post.previewURL); + $button.content('Copied!'); + setTimeout(() => { + $button.content('Webm') + }, 2000); + }) + .hide(true).self(async ($button) => { await post.ready; if (post.file_ext === 'zip') $button.hide(false) }) + ]), ]), $('div').class('post-tags').content(async $tags => { const tags = await post.fetchTags(); diff --git a/src/route/post/_$post.scss b/src/route/post/_$post.scss index 302cb59..044828c 100644 --- a/src/route/post/_$post.scss +++ b/src/route/post/_$post.scss @@ -116,6 +116,13 @@ display: flex; flex-direction: column; gap: 0.4rem; + + .buttons { + display: grid; + grid-template-columns: 1fr 1fr 1fr; + gap: 1rem; + margin-top: 1rem; + } } div.property { diff --git a/src/structure/Post.ts b/src/structure/Post.ts index 0c1e358..5b3ce3f 100644 --- a/src/structure/Post.ts +++ b/src/structure/Post.ts @@ -96,6 +96,7 @@ export class Post extends $EventManager<{update: []}> { get approver() { if (this.approver_id) return User.manager.get(this.approver_id); else return null } get isVideo() { return this.file_ext === 'mp4' || this.file_ext === 'webm' || this.file_ext === 'zip' } get isGif() { return this.file_ext === 'gif' } + get isUgoria() { return this.file_ext === 'zip' } get hasSound() { return this.tag_string_meta.includes('sound') } get tags() { const tag_list = this.tag_string.split(' ');