diff --git a/dist/assets/index-D9u7pURH.js b/dist/assets/index-D9u7pURH.js deleted file mode 100644 index c74cd27..0000000 --- a/dist/assets/index-D9u7pURH.js +++ /dev/null @@ -1 +0,0 @@ -var Bt=Object.defineProperty;var xt=r=>{throw TypeError(r)};var Kt=(r,e,t)=>e in r?Bt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var h=(r,e,t)=>Kt(r,typeof e!="symbol"?e+"":e,t),St=(r,e,t)=>e.has(r)||xt("Cannot "+t);var k=(r,e,t)=>(St(r,e,"read from private field"),t?t.call(r):e.get(r)),tt=(r,e,t)=>e.has(r)?xt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),et=(r,e,t,s)=>(St(r,e,"write to private field"),s?s.call(r,t):e.set(r,t),t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.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 t(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=t(i);fetch(i.href,n)}})();class R{constructor(){h(this,"eventMap",new Map)}fire(e,...t){var s;return(s=this.eventMap.get(e))==null||s.forEach(i=>i(...t)),this}on(e,t){const s=this.eventMap.get(e)??this.eventMap.set(e,new Set).get(e);return s==null||s.add(t),this}off(e,t){var s;return(s=this.eventMap.get(e))==null||s.delete(t),this}once(e,t){const s=(...n)=>{var a;(a=this.eventMap.get(e))==null||a.delete(s),t(...n)},i=this.eventMap.get(e)??this.eventMap.set(e,new Set).get(e);return i==null||i.add(s),this}}class Mt{constructor(){h(this,"domEvents",{});h(this,"events",new R)}on(e,t,s){e=$.orArrayResolve(e);for(const i of e){this.domEvents[i]||(this.domEvents[i]=new Map);const n=a=>{t(a,this)};this.domEvents[i].set(t,n),this.events.on(i,t),this.dom.addEventListener(i,n,s)}return this}off(e,t,s){var n;const i=(n=this.domEvents[e])==null?void 0:n.get(t);return i&&this.dom.removeEventListener(e,i,s),this.events.off(e,t),this}once(e,t,s){const i=n=>{this.dom.removeEventListener(e,i,s),t(n,this)};return this.dom.addEventListener(e,i,s),this.events.once(e,t),this}trigger(e){this.dom.dispatchEvent(new Event(e))}}class J extends Mt{constructor(){super(...arguments);h(this,"__$property__",{hidden:!1,coordinate:void 0});h(this,"parent")}hide(t,s=!0){return w.fluent(this,arguments,()=>this.__$property__.hidden,()=>{var i;if(t!==void 0)return t instanceof I?(this.__$property__.hidden=t.value,t.use(this,"hide")):this.__$property__.hidden=t,s&&((i=this.parent)==null||i.children.render()),this})}remove(){var t;return(t=this.parent)==null||t.children.remove(this).render(),this}replace(t){var s;return(s=this.parent)==null||s.children.replace(this,t).render(),this}contains(t){return t?t instanceof J?this.dom.contains(t.dom):t instanceof EventTarget?this.dom.contains(w(t).dom):this.dom.contains(t):!1}coordinate(t){return w.fluent(this,arguments,()=>this.__$property__.coordinate,()=>w.set(this.__$property__,"coordinate",t))}self(t){return w.orArrayResolve(t).forEach(s=>s(this)),this}inDOM(){return document.contains(this.dom)}isElement(){return this instanceof V}get element(){return this instanceof V?this:null}get htmlElement(){return this instanceof K?this:null}}class V extends J{constructor(t,s){super();h(this,"dom");h(this,"static_classes",new Set);this.dom=this.createDom(t,s),this.dom.$=this,this.setOptions(s)}createDom(t,s){return s!=null&&s.dom?s.dom:t==="svg"?document.createElementNS("http://www.w3.org/2000/svg","svg"):document.createElement((s==null?void 0:s.tagname)??t)}setOptions(t){return this.id(t==null?void 0:t.id),t&&t.class&&this.class(...t.class),this}id(t){return $.fluent(this,arguments,()=>this.dom.id,()=>$.set(this.dom,"id",t))}class(...t){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(...t.detype())})}addClass(...t){return $.fluent(this,arguments,()=>this,()=>{this.dom.classList.add(...t.detype())})}removeClass(...t){return $.fluent(this,arguments,()=>this,()=>{this.dom.classList.remove(...t.detype())})}staticClass(...t){return $.fluent(this,arguments,()=>this.static_classes,()=>{this.removeClass(...this.static_classes),this.static_classes.clear(),this.addStaticClass(...t)})}addStaticClass(...t){return $.fluent(this,arguments,()=>this,()=>{t.detype().forEach(s=>this.static_classes.add(s)),this.addClass(...t)})}removeStaticClass(...t){return $.fluent(this,arguments,()=>this,()=>{t.detype().forEach(s=>this.static_classes.delete(s)),this.removeClass(...t)})}css(t){return $.fluent(this,arguments,()=>this.dom.style,()=>{Object.assign(this.dom.style,t)})}attribute(t,s){return arguments.length?arguments.length===1?t===void 0?null:this.dom.getAttribute(t):arguments.length===2?t?(s===null?this.dom.removeAttribute(t):s!==void 0&&this.dom.setAttribute(t,`${s}`),this):this:this:null}tabIndex(t){return $.fluent(this,arguments,()=>this.dom.tabIndex,()=>$.set(this.dom,"tabIndex",t))}focus(t){return this.dom.focus(t),this}blur(){return this.dom.blur(),this}animate(t,s,i){const n=this.dom.animate(t,s);return i&&(n.onfinish=()=>i(n)),n}getAnimations(t){return this.dom.getAnimations(t)}get dataset(){return this.dom.dataset}domRect(t){const s=this.dom.getBoundingClientRect();if(!t)return s;const i=t instanceof V?t.dom.getBoundingClientRect():t;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 it extends J{constructor(t){super();h(this,"dom");this.dom=t,this.dom.$=this}domRect(t){const s={bottom:innerHeight,height:innerHeight,left:0,right:innerWidth,top:0,width:innerWidth,x:0,y:0};if(!t)return s;const i=t instanceof V?t.dom.getBoundingClientRect():t;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(t){return t.$ instanceof it?t.$:new it(t)}}const Xt="modulepreload",qt=function(r){return"/"+r},Ot={},Qt=function(e,t,s){let i=Promise.resolve();if(t&&t.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(t.map(l=>{if(l=qt(l),l in Ot)return;Ot[l]=!0;const u=l.endsWith(".css"),c=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${c}`))return;const d=document.createElement("link");if(d.rel=u?"stylesheet":Xt,u||(d.as="script"),d.crossOrigin="",d.href=l,o&&d.setAttribute("nonce",o),document.head.appendChild(d),u)return new Promise((p,b)=>{d.addEventListener("load",p),d.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${l}`)))})}))}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 e().catch(n)})};class Jt{constructor(e){h(this,"$container");h(this,"childList",new Set);this.$container=e}add(e,t=-1){if(t===-1||this.childList.size-1===t)this.childList.add(e);else{const s=[...this.childList];s.splice(t,0,e),this.childList.clear(),s.forEach(i=>this.childList.add(i))}e.parent=this.$container}remove(e){return this.childList.has(e)?(this.childList.delete(e),e.parent=void 0,this):this}removeAll(e=!0){this.childList.forEach(t=>this.remove(t)),e&&this.render()}replace(e,t){const s=this.array;return s.splice(s.indexOf(e),1,t),e.remove(),this.childList.clear(),s.forEach(i=>this.childList.add(i)),t.parent=this.$container,this}render(){const[e,t]=[this.array.map(i=>i.dom),Array.from(this.dom.childNodes)],s=[];for(;t.length||e.length;){const[i,n]=[t.at(0),e.at(0)];n?i?n!==i?(n.$.hide()||(this.dom.insertBefore(n,i),s.push(n)),e.shift()):(n.$.hide()&&this.dom.removeChild(n),e.shift(),t.shift()):(n.$.hide()||this.dom.append(n),e.shift()):(i&&!s.includes(i)&&i.remove(),t.shift())}}indexOf(e){return this.array.indexOf(e)}get array(){return[...this.childList.values()]}get dom(){return this.$container.dom}}class I extends R{constructor(t,s){super();h(this,"_value");h(this,"_convert");h(this,"attributes",new Map);h(this,"linkStates",new Set);h(this,"options",{});this.set(t),s&&(this.options=s)}set(t){this._value=t,t instanceof I&&t.linkStates.add(this),this.update(),this.linkStates.forEach(s=>s.update())}static toJSON(t){const s={};for(let[i,n]of Object.entries(t))n instanceof I?n=n.toJSON():n instanceof Object&&I.toJSON(n),Object.assign(s,{[i]:n});return s}update(){for(const[t,s]of this.attributes.entries())for(const i of s)t[i]instanceof Function?this.options.format?t[i](this.options.format(this.value)):t[i](this.value):i in t&&(t[i]=this.value);this.fire("update",{state$:this})}use(t,s){const i=this.attributes.get(t);i?i.add(s):this.attributes.set(t,new Set().add(s))}convert(t){const s=new I(this);return s._convert=t,s}get value(){return this._value instanceof I?this._convert?this._convert(this._value.value):this._value.value:this._value}toString(){return this.options.format?`${this.options.format(this.value)}`:this.value instanceof Object?JSON.stringify(this.toJSON()):`${this.value}`}toJSON(){return this.value instanceof I?this.value.toJSON():this.value instanceof Object?I.toJSON(this.value):this.toString()}}class X extends J{constructor(t){super();h(this,"dom");this.dom=new Text(t),this.dom.$=this}content(t){return $.fluent(this,arguments,()=>this.dom.textContent,()=>$.set(this.dom,"textContent",t))}}class K extends V{constructor(e,t){super(e,t)}autocapitalize(e){return $.fluent(this,arguments,()=>this.dom.autocapitalize,()=>$.set(this.dom,"autocapitalize",e))}innerText(e){return $.fluent(this,arguments,()=>this.dom.innerText,()=>$.set(this.dom,"innerText",e))}title(e){return $.fluent(this,arguments,()=>this.dom.title,()=>$.set(this.dom,"title",e))}dir(e){return $.fluent(this,arguments,()=>this.dom.dir,()=>$.set(this.dom,"dir",e))}translate(e){return $.fluent(this,arguments,()=>this.dom.translate,()=>$.set(this.dom,"translate",e))}popover(e){return $.fluent(this,arguments,()=>this.dom.popover,()=>$.set(this.dom,"popover",e))}spellcheck(e){return $.fluent(this,arguments,()=>this.dom.spellcheck,()=>$.set(this.dom,"spellcheck",e))}inert(e){return $.fluent(this,arguments,()=>this.dom.inert,()=>$.set(this.dom,"inert",e))}lang(e){return $.fluent(this,arguments,()=>this.dom.lang,()=>$.set(this.dom,"lang",e))}draggable(e){return $.fluent(this,arguments,()=>this.dom.draggable,()=>$.set(this.dom,"draggable",e))}hidden(e){return $.fluent(this,arguments,()=>this.dom.hidden,()=>$.set(this.dom,"hidden",e))}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 K{constructor(t,s){super(t,s);h(this,"children",new Jt(this));h(this,"__position_cursor",0)}content(t){return $.fluent(this,arguments,()=>this,()=>{this.children.removeAll(!1),this.insert(t)})}insert(t,s=-1){return $.fluent(this,arguments,()=>this,async()=>{if(t instanceof Function){let i=t(this);i instanceof Promise?t=await i:t=i}else t instanceof Promise&&(t=await t);t=$.orArrayResolve(t),this.__position_cursor=s<0?this.children.array.length+s:s;for(const i of t)if(i!=null){if(i instanceof Array)this.insert(i,this.__position_cursor);else if(typeof i=="string")this.children.add(new X(i),s);else if(i instanceof I){const n=new X(i.toString());i.use(n,"content"),this.children.add(n,s)}else if(i instanceof Promise){const n=(await Qt(async()=>{const{$Async:o}=await Promise.resolve().then(()=>ne);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}$(t){if(t.startsWith("::"))return Array.from(document.querySelectorAll(t.replace(/^::/,""))).map(s=>$(s));if(t.startsWith(":"))return $(document.querySelector(t.replace(/^:/,"")))}get scrollHeight(){return this.dom.scrollHeight}get scrollWidth(){return this.dom.scrollWidth}scrollTop(t){return $.fluent(this,arguments,()=>this.dom.scrollTop,()=>$.set(this.dom,"scrollTop",t))}scrollLeft(t){return $.fluent(this,arguments,()=>this.dom.scrollLeft,()=>$.set(this.dom,"scrollLeft",t))}}class Lt extends f{constructor(e){super("a",e),this.dom.addEventListener("click",t=>{$.anchorHandler&&this.href()&&(t.preventDefault(),$.anchorHandler(this,t))})}href(e){return $.fluent(this,arguments,()=>this.dom.href,()=>$.set(this.dom,"href",e))}target(e){return $.fluent(this,arguments,()=>this.dom.target??void 0,()=>{e&&(this.dom.target=e)})}}class Yt extends V{constructor(e,t){super(e,t)}}var x;(r=>{function e(o,l,u,c){return l.length?(c(),o):u()}r.fluent=e;function t(o){return o instanceof Array?o:[o]}r.orArrayResolve=t;function s(o,l){return t(l).forEach(u=>{Object.getOwnPropertyNames(u.prototype).forEach(c=>{c!=="constructor"&&Object.defineProperty(o.prototype,c,Object.getOwnPropertyDescriptor(u.prototype,c)||Object.create(null))})}),o}r.mixin=s;function i(o,l,u){u!==void 0&&(o[l]=u)}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()==="head")return new f("head",{dom:o});if(o.nodeName.toLowerCase()==="#document")return it.from(o);if(o instanceof HTMLElement){const l=$.TagNameElementMap[o.tagName.toLowerCase()],u=l?l===f?new l(o.tagName,{dom:o}):new l({dom:o}):new f(o.tagName,{dom:o});if(u instanceof f)for(const c of Array.from(u.dom.childNodes))u.children.add($(c));return u}else if(o instanceof Text){const l=new X(o.textContent??"");return l.dom=o,l}else if(o instanceof SVGElement&&o.tagName.toLowerCase()==="svg")return new Yt("svg",{dom:o});throw`$NODE.FROM: NOT SUPPORT TARGET ELEMENT TYPE (${o.nodeName})`}r.from=a})(x||(x={}));class P{static create(...e){const t=class{};return Object.getOwnPropertyNames(P.prototype).forEach(s=>{s!=="constructor"&&e.includes(s)&&Object.defineProperty(t.prototype,s,Object.getOwnPropertyDescriptor(P.prototype,s)||Object.create(null))}),t}disabled(e){return $.fluent(this,arguments,()=>this.dom.disabled,()=>$.set(this.dom,"disabled",e))}checkValidity(){return this.dom.checkValidity()}reportValidity(){return this.dom.reportValidity()}formAction(e){return $.fluent(this,arguments,()=>this.dom.formAction,()=>$.set(this.dom,"formAction",e))}formEnctype(e){return $.fluent(this,arguments,()=>this.dom.formEnctype,()=>$.set(this.dom,"formEnctype",e))}formMethod(e){return $.fluent(this,arguments,()=>this.dom.formMethod,()=>$.set(this.dom,"formMethod",e))}formNoValidate(e){return $.fluent(this,arguments,()=>this.dom.formNoValidate,()=>$.set(this.dom,"formNoValidate",e))}formTarget(e){return $.fluent(this,arguments,()=>this.dom.formTarget,()=>$.set(this.dom,"formTarget",e))}autocomplete(e){return $.fluent(this,arguments,()=>this.dom.autocomplete,()=>$.set(this.dom,"autocomplete",e))}name(e){return $.fluent(this,arguments,()=>this.dom.name,()=>$.set(this.dom,"name",e))}maxLength(e){return $.fluent(this,arguments,()=>this.dom.maxLength,()=>$.set(this.dom,"maxLength",e))}minLength(e){return $.fluent(this,arguments,()=>this.dom.minLength,()=>$.set(this.dom,"minLength",e))}required(e){return $.fluent(this,arguments,()=>this.dom.required,()=>$.set(this.dom,"required",e))}label(e){return $.fluent(this,arguments,()=>this.dom.label,()=>$.set(this.dom,"label",e))}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 wt extends f{constructor(e){super("button",e)}type(e){return $.fluent(this,arguments,()=>this.dom.type,()=>$.set(this.dom,"type",e))}}x.mixin(wt,P.create("disabled","checkValidity","formAction","formEnctype","formMethod","formNoValidate","formTarget","reportValidity"));class Pt extends f{constructor(e){super("form",e)}action(e){return $.fluent(this,arguments,()=>this.dom.formAction,()=>$.set(this.dom,"formAction",e))}enctype(e){return $.fluent(this,arguments,()=>this.dom.formEnctype,()=>$.set(this.dom,"formEnctype",e))}method(e){return $.fluent(this,arguments,()=>this.dom.formMethod,()=>$.set(this.dom,"formMethod",e))}noValidate(e){return $.fluent(this,arguments,()=>this.dom.formNoValidate,()=>$.set(this.dom,"formNoValidate",e))}acceptCharset(e){return $.fluent(this,arguments,()=>this.dom.acceptCharset,()=>$.set(this.dom,"acceptCharset",e))}target(e){return $.fluent(this,arguments,()=>this.dom.formTarget,()=>$.set(this.dom,"formTarget",e))}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(e=>$(e))}}x.mixin(Pt,P.create("checkValidity","reportValidity","autocomplete"));class M extends K{constructor(e){super("input",e)}value(e){return $.fluent(this,arguments,()=>this.type()==="number"?Number(this.dom.value):this.dom.value,()=>$.set(this.dom,"value",e,t=>{this.on("input",()=>{t.attributes.has(this.dom)!==!1&&(typeof t.value=="string"&&t.set(`${this.value()}`),typeof t.value=="number"&&t.set(Number(this.value())))})}))}type(e){return $.fluent(this,arguments,()=>this.dom.type,()=>$.set(this.dom,"type",e))}capture(e){return $.fluent(this,arguments,()=>this.dom.capture,()=>$.set(this.dom,"capture",e))}alt(e){return $.fluent(this,arguments,()=>this.dom.alt,()=>$.set(this.dom,"alt",e))}height(e){return $.fluent(this,arguments,()=>this.dom.height,()=>$.set(this.dom,"height",e))}width(e){return $.fluent(this,arguments,()=>this.dom.width,()=>$.set(this.dom,"width",e))}defaultValue(e){return $.fluent(this,arguments,()=>this.dom.defaultValue,()=>$.set(this.dom,"defaultValue",e))}dirName(e){return $.fluent(this,arguments,()=>this.dom.dirName,()=>$.set(this.dom,"dirName",e))}pattern(e){return $.fluent(this,arguments,()=>this.dom.pattern,()=>$.set(this.dom,"pattern",e))}placeholder(e){return $.fluent(this,arguments,()=>this.dom.placeholder,()=>$.set(this.dom,"placeholder",e))}readOnly(e){return $.fluent(this,arguments,()=>this.dom.readOnly,()=>$.set(this.dom,"readOnly",e))}selectionDirection(e){return $.fluent(this,arguments,()=>this.dom.selectionDirection,()=>$.set(this.dom,"selectionDirection",e))}selectionEnd(e){return $.fluent(this,arguments,()=>this.dom.selectionEnd,()=>$.set(this.dom,"selectionEnd",e))}selectionStart(e){return $.fluent(this,arguments,()=>this.dom.selectionStart,()=>$.set(this.dom,"selectionStart",e))}size(e){return $.fluent(this,arguments,()=>this.dom.size,()=>$.set(this.dom,"size",e))}src(e){return $.fluent(this,arguments,()=>this.dom.src,()=>$.set(this.dom,"src",e))}inputMode(e){return $.fluent(this,arguments,()=>this.dom.inputMode,()=>$.set(this.dom,"inputMode",e))}valueAsDate(e){return $.fluent(this,arguments,()=>this.dom.valueAsDate,()=>$.set(this.dom,"valueAsDate",e))}valueAsNumber(e){return $.fluent(this,arguments,()=>this.dom.valueAsNumber,()=>$.set(this.dom,"valueAsNumber",e))}webkitdirectory(e){return $.fluent(this,arguments,()=>this.dom.webkitdirectory,()=>$.set(this.dom,"webkitdirectory",e))}select(){return this.dom.select(),this}setCustomValidity(e){return this.dom.setCustomValidity(e),this}setRangeText(e,t,s,i){return typeof t=="number"&&typeof s=="number"&&this.dom.setRangeText(e,t,s,i),this.dom.setRangeText(e),this}setSelectionRange(e,t,s){return this.dom.setSelectionRange(e,t,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(e=>$(e))}}x.mixin(M,P.create("checkValidity","reportValidity","autocomplete","name","form","required","validationMessage","validity","willValidate","formAction","formEnctype","formMethod","formNoValidate","formTarget"));class Zt extends M{constructor(e){super(e),this.type("number")}static from(e){return $.mixin(M,this)}stepDown(){return this.dom.stepDown(),this}stepUp(){return this.dom.stepUp(),this}max(e){return $.fluent(this,arguments,()=>this.dom.max===""?null:parseInt(this.dom.min),()=>$.set(this.dom,"max",e==null?void 0:e.toString()))}min(e){return $.fluent(this,arguments,()=>this.dom.min===""?null:parseInt(this.dom.min),()=>$.set(this.dom,"min",e==null?void 0:e.toString()))}step(e){return $.fluent(this,arguments,()=>Number(this.dom.step),()=>$.set(this.dom,"step",e==null?void 0:e.toString()))}}class te extends M{constructor(e){super(e),this.type("radio")}static from(e){return $.mixin(M,this)}checked(e){return $.fluent(this,arguments,()=>this.dom.checked,()=>$.set(this.dom,"checked",e))}defaultChecked(e){return $.fluent(this,arguments,()=>this.dom.defaultChecked,()=>$.set(this.dom,"defaultChecked",e))}}class ee extends M{constructor(e){super(e),this.type("file")}static from(e){return $.mixin(M,this)}multiple(e){return $.fluent(this,arguments,()=>this.dom.multiple,()=>$.set(this.dom,"multiple",e))}accept(...e){return $.fluent(this,arguments,()=>this.dom.accept.split(","),()=>this.dom.accept=e.toString())}}x.mixin(M,[Zt,te,ee]);class At extends f{constructor(e){super("label",e)}for(e){return $.fluent(this,arguments,()=>this.dom.htmlFor,()=>{$.set(this.dom,"htmlFor",e)})}get control(){return this.dom.control}}x.mixin(At,P.create("form"));class se extends K{constructor(e){super("img",e)}async load(e){return new Promise(t=>{const s=this.once("load",()=>{t(s)});typeof e=="string"?s.src(e):e.then(i=>s.src(i))})}static resize(e,t){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,[l,u,c]=[o>1,o<1,o===1],d=t instanceof Array?t[0]:u?t:t*o,p=t instanceof Array?t[1]:l?t:t/o;n.height=p,n.width=d,a.drawImage(i,0,0,d,p),s(n.toDataURL())},{once:!0}),e instanceof File){const n=new FileReader;n.addEventListener("load",()=>i.src=n.result),n.readAsDataURL(e)}else i.src=e})}alt(e){return $.fluent(this,arguments,()=>this.dom.alt,()=>$.set(this.dom,"alt",e))}crossOrigin(e){return $.fluent(this,arguments,()=>this.dom.crossOrigin,()=>$.set(this.dom,"crossOrigin",e))}decoding(e){return $.fluent(this,arguments,()=>this.dom.decoding,()=>$.set(this.dom,"decoding",e))}height(e){return $.fluent(this,arguments,()=>this.dom.height,()=>$.set(this.dom,"height",e))}isMap(e){return $.fluent(this,arguments,()=>this.dom.isMap,()=>$.set(this.dom,"isMap",e))}loading(e){return $.fluent(this,arguments,()=>this.dom.loading,()=>$.set(this.dom,"loading",e))}referrerPolicy(e){return $.fluent(this,arguments,()=>this.dom.referrerPolicy,()=>$.set(this.dom,"referrerPolicy",e))}sizes(e){return $.fluent(this,arguments,()=>this.dom.sizes,()=>$.set(this.dom,"sizes",e))}src(e){return $.fluent(this,arguments,()=>this.dom.src,()=>$.set(this.dom,"src",e))}srcset(e){return $.fluent(this,arguments,()=>this.dom.srcset,()=>$.set(this.dom,"srcset",e))}useMap(e){return $.fluent(this,arguments,()=>this.dom.useMap,()=>$.set(this.dom,"useMap",e))}width(e){return $.fluent(this,arguments,()=>this.dom.width,()=>$.set(this.dom,"width",e))}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 ie extends f{constructor(e){super("canvas",e)}height(e){return $.fluent(this,arguments,()=>this.dom.height,()=>{$.set(this.dom,"height",e)})}width(e){return $.fluent(this,arguments,()=>this.dom.width,()=>{$.set(this.dom,"width",e)})}captureStream(e){return this.dom.captureStream(e)}getContext(e,t){return this.dom.getContext(e)}toBlob(e,t,s){return this.dom.toBlob(e,t,s),this}toDataURL(e,t){return this.dom.toDataURL(e,t)}transferControlToOffscreen(){return this.dom.transferControlToOffscreen()}}class re extends f{constructor(e){super("dialog",e)}open(e){return $.fluent(this,arguments,()=>this.dom.open,()=>$.set(this.dom,"open",e))}returnValue(e){return $.fluent(this,arguments,()=>this.dom.returnValue,()=>$.set(this.dom,"returnValue",e))}close(){return this.dom.close(),this}show(){return this.dom.show(),this}showModal(){return this.dom.showModal(),this}}class Ct extends f{constructor(e){super("select")}add(e){return this.insert(e),this}item(e){return $(this.dom.item(e))}namedItem(e){return $(this.dom.namedItem(e))}multiple(e){return $.fluent(this,arguments,()=>this.dom.multiple,()=>$.set(this.dom,"multiple",e))}get length(){return this.dom.length}get size(){return this.dom.size}get options(){return Array.from(this.dom.options).map(e=>$(e))}get selectedIndex(){return this.dom.selectedIndex}get selectedOptions(){return Array.from(this.dom.selectedOptions).map(e=>$(e))}value(e){return $.fluent(this,arguments,()=>this.dom.value,()=>$.set(this.dom,"value",e,t=>{this.on("input",()=>{t.attributes.has(this.dom)!==!1&&(typeof t.value=="string"&&t.set(`${this.value()}`),typeof t.value=="number"&&t.set(Number(this.value())))})}))}get labels(){return Array.from(this.dom.labels??[]).map(e=>$(e))}}x.mixin(Ct,P.create("checkValidity","reportValidity","autocomplete","name","form","required","disabled","validationMessage","validity","willValidate"));class Dt extends f{constructor(e){super("option",e)}defaultSelected(e){return $.fluent(this,arguments,()=>this.dom.defaultSelected,()=>$.set(this.dom,"defaultSelected",e))}selected(e){return $.fluent(this,arguments,()=>this.dom.selected,()=>$.set(this.dom,"selected",e))}text(e){return $.fluent(this,arguments,()=>this.dom.text,()=>$.set(this.dom,"text",e))}value(e){return $.fluent(this,arguments,()=>this.dom.value,()=>$.set(this.dom,"value",e))}get form(){return this.dom.form?$(this.dom.form):null}get index(){return this.dom.index}}x.mixin(Dt,P.create("form","disabled","label"));class Rt extends f{constructor(e){super("optgroup",e)}disabled(e){return $.fluent(this,arguments,()=>this.dom.disabled,()=>$.set(this.dom,"disabled",e))}}x.mixin(Rt,P.create("disabled","label"));class Nt extends f{constructor(e){super("textarea",e)}cols(e){return $.fluent(this,arguments,()=>this.dom.cols,()=>$.set(this.dom,"cols",e))}wrap(e){return $.fluent(this,arguments,()=>this.dom.wrap,()=>$.set(this.dom,"wrap",e))}value(e){return $.fluent(this,arguments,()=>this.dom.value,()=>$.set(this.dom,"value",e))}defaultValue(e){return $.fluent(this,arguments,()=>this.dom.defaultValue,()=>$.set(this.dom,"defaultValue",e))}dirName(e){return $.fluent(this,arguments,()=>this.dom.dirName,()=>$.set(this.dom,"dirName",e))}placeholder(e){return $.fluent(this,arguments,()=>this.dom.placeholder,()=>$.set(this.dom,"placeholder",e))}readOnly(e){return $.fluent(this,arguments,()=>this.dom.readOnly,()=>$.set(this.dom,"readOnly",e))}selectionDirection(e){return $.fluent(this,arguments,()=>this.dom.selectionDirection,()=>$.set(this.dom,"selectionDirection",e))}selectionEnd(e){return $.fluent(this,arguments,()=>this.dom.selectionEnd,()=>$.set(this.dom,"selectionEnd",e))}selectionStart(e){return $.fluent(this,arguments,()=>this.dom.selectionStart,()=>$.set(this.dom,"selectionStart",e))}type(e){return $.fluent(this,arguments,()=>this.dom.type,()=>$.set(this.dom,"type",e))}inputMode(e){return $.fluent(this,arguments,()=>this.dom.inputMode,()=>$.set(this.dom,"inputMode",e))}select(){return this.dom.select(),this}setCustomValidity(e){return this.dom.setCustomValidity(e),this}setRangeText(e,t,s,i){return typeof t=="number"&&typeof s=="number"&&this.dom.setRangeText(e,t,s,i),this.dom.setRangeText(e),this}setSelectionRange(e,t,s){return this.dom.setSelectionRange(e,t,s),this}get labels(){return Array.from(this.dom.labels??[]).map(e=>$(e))}}x.mixin(Nt,P.create("checkValidity","reportValidity","autocomplete","name","form","required","disabled","minLength","maxLength","validationMessage","validity","willValidate"));var rt;class Ht extends f{constructor(t){super("async",t);tt(this,rt,!1)}await(t){return t instanceof Function?t(this).then(s=>this._loaded(s)):t.then(s=>this._loaded(s)),this}_loaded(t){if(et(this,rt,!0),typeof t=="string")this.replace(new X(t));else if(t instanceof I){const s=new X(t.toString());t.use(s,"content"),this.replace(s)}else t==null?this.replace(new X(String(t))):this.replace(t);this.dom.dispatchEvent(new Event("load"))}get loaded(){return k(this,rt)}}rt=new WeakMap;const ne=Object.freeze(Object.defineProperty({__proto__:null,$Async:Ht},Symbol.toStringTag,{value:"Module"}));class oe extends K{constructor(e,t){super(e,t)}autoplay(e){return $.fluent(this,arguments,()=>this.dom.autoplay,()=>$.set(this.dom,"autoplay",e))}get buffered(){return this.dom.buffered}controls(e){return $.fluent(this,arguments,()=>this.dom.controls,()=>$.set(this.dom,"controls",e))}crossOrigin(e){return $.fluent(this,arguments,()=>this.dom.crossOrigin,()=>$.set(this.dom,"crossOrigin",e))}get currentSrc(){return this.dom.currentSrc}currentTime(e){return $.fluent(this,arguments,()=>this.dom.currentTime,()=>$.set(this.dom,"currentTime",e))}defaultMuted(e){return $.fluent(this,arguments,()=>this.dom.defaultMuted,()=>$.set(this.dom,"defaultMuted",e))}defaultPlaybackRate(e){return $.fluent(this,arguments,()=>this.dom.defaultPlaybackRate,()=>$.set(this.dom,"defaultPlaybackRate",e))}disableRemotePlayback(e){return $.fluent(this,arguments,()=>this.dom.disableRemotePlayback,()=>$.set(this.dom,"disableRemotePlayback",e))}get duration(){return this.dom.duration}get ended(){return this.dom.ended}get error(){return this.dom.error}loop(e){return $.fluent(this,arguments,()=>this.dom.loop,()=>$.set(this.dom,"loop",e))}mediaKeys(e){return $.fluent(this,arguments,()=>this.dom.mediaKeys,()=>$.set(this.dom,"setMediaKeys",[e]))}muted(e){return $.fluent(this,arguments,()=>this.dom.muted,()=>$.set(this.dom,"muted",e))}get networkState(){return this.dom.networkState}get paused(){return this.dom.paused}playbackRate(e){return $.fluent(this,arguments,()=>this.dom.playbackRate,()=>$.set(this.dom,"playbackRate",e))}get played(){return this.dom.played}preload(e){return $.fluent(this,arguments,()=>this.dom.preload,()=>$.set(this.dom,"preload",e))}preservesPitch(e){return $.fluent(this,arguments,()=>this.dom.preservesPitch,()=>$.set(this.dom,"preservesPitch",e))}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(e){return $.fluent(this,arguments,()=>this.dom.sinkId,()=>$.set(this.dom,"setSinkId",[e]))}src(e){return $.fluent(this,arguments,()=>this.dom.src,()=>$.set(this.dom,"src",e))}srcObject(e){return $.fluent(this,arguments,()=>this.dom.srcObject,()=>$.set(this.dom,"srcObject",e))}get textTracks(){return this.dom.textTracks}volume(e){return $.fluent(this,arguments,()=>this.dom.volume,()=>$.set(this.dom,"volume",e))}addTextTrack(e,t,s){return this.dom.addTextTrack(e,t,s)}canPlayType(e){return this.dom.canPlayType(e)}fastSeek(e){return this.dom.fastSeek(e),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 ae extends oe{constructor(e){super("video",e)}disablePictureInPicture(e){return $.fluent(this,arguments,()=>this.dom.disablePictureInPicture,()=>$.set(this.dom,"disablePictureInPicture",e))}height(e){return $.fluent(this,arguments,()=>this.dom.height,()=>$.set(this.dom,"height",e))}width(e){return $.fluent(this,arguments,()=>this.dom.width,()=>$.set(this.dom,"width",e))}playsInline(e){return $.fluent(this,arguments,()=>this.dom.playsInline,()=>$.set(this.dom,"playsInline",e))}poster(e){return $.fluent(this,arguments,()=>this.dom.poster,()=>$.set(this.dom,"poster",e))}get videoHeight(){return this.dom.videoHeight}get videoWidth(){return this.dom.videoWidth}cancelVideoFrameCallback(e){return this.dom.cancelVideoFrameCallback(e),this}getVideoPlaybackQuality(){return this.dom.getVideoPlaybackQuality()}requestPictureInPicture(){return this.dom.requestPictureInPicture()}requestVideoFrameCallback(e){return this.dom.requestVideoFrameCallback(e)}}const ut=class ut extends Mt{constructor(){super(...arguments);h(this,"dom",window)}};h(ut,"$",new ut);let ft=ut;class he{constructor(e){h(this,"keyMap",new Map);h(this,"conditional");e.on("keydown",t=>{var s;this.conditional&&!this.conditional(t)||(s=this.keyMap.get(t.key))==null||s.keydown.forEach(i=>i(t))}),e.on("keyup",t=>{var s;this.conditional&&!this.conditional(t)||(s=this.keyMap.get(t.key))==null||s.keyup.forEach(i=>i(t))}),e.on("keypress",t=>{var s;this.conditional&&!this.conditional(t)||(s=this.keyMap.get(t.key))==null||s.keypress.forEach(i=>i(t))})}if(e){return this.conditional=e,this}assigns(e,t,s){e=x.orArrayResolve(e),t=x.orArrayResolve(t);for(const i of e){const n=this.keyMap.get(i)??{keydown:new Set,keypress:new Set,keyup:new Set};for(const a of t)n[a].add(s);this.keyMap.set(i,n)}return this}unassign(e,t,s){e=x.orArrayResolve(e),t=t?x.orArrayResolve(t):["keydown","keypress","keyup"];for(const i of e){const n=this.keyMap.get(i)??{keydown:new Set,keypress:new Set,keyup:new Set};for(const a of t)s?n[a].delete(s):n[a].clear();this.keyMap.set(i,n)}return this}keydown(e,t){return this.assigns(e,"keydown",t),this}keyup(e,t){return this.assigns(e,"keyup",t),this}keypress(e,t){return this.assigns(e,"keypress",t),this}}function w(r){if(typeof r>"u"||r===null||r instanceof J)return r;if(typeof r=="string"){if(r.startsWith("::"))return Array.from(document.querySelectorAll(r.replace(/^::/,""))).map(e=>w(e));if(r.startsWith(":"))return w(document.querySelector(r.replace(/^:/,"")));if(r in w.TagNameElementMap){const e=w.TagNameElementMap[r];return e===K?new K(r):e===f?new f(r):new e}else return new f(r)}if(r instanceof Node)return r.$?r.$:x.from(r);if(r instanceof Window)return ft.$;throw`$: NOT SUPPORT TARGET ELEMENT TYPE ('${r}')`}(r=>{r.anchorHandler=null,r.TagNameElementMap={html:f,head:f,document:it,body:f,a:Lt,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:M,label:At,button:wt,form:Pt,img:se,dialog:re,canvas:ie,select:Ct,option:Dt,optgroup:Rt,textarea:Nt,video:ae,async:Ht};function e(m,y,T,S){return y.length?(S(),m):T()}r.fluent=e;function t(m,y,T,S){if(T!==void 0){if(T instanceof I){T.use(m,y),m[y]instanceof Function?m[y](...T.value):m[y]=T.value,S&&S(T);return}m[y]instanceof Function?m[y](...T):m[y]=T}}r.set=t;function s(m,y){return new I(m,y)}r.state=s;async function i(m,y){return new Promise(T=>{const S=new FileReader;S.onload=A=>{const N=r("img");if(N.once("load",nt=>{const G=r("canvas"),L=G.getContext("2d"),W=N.height()/N.width(),[Y,Z]=[W>1?y/W:y,W>1?y:y*W];G.height(Z).width(Y),L==null||L.drawImage(N.dom,0,0,Y,Z),T(G.toDataURL(m.type))}),!A.target)throw"$.resize(): e.target is null";N.src(A.target.result)},S.readAsDataURL(m)})}r.resize=i;function n(m){const y=new DOMParser().parseFromString(m,"text/html").body;return Array.from(y.children).map(T=>r(T))}r.html=n;function a(m,y){return Object.assign(r.TagNameElementMap,{[m]:y}),r.TagNameElementMap}r.registerTagName=a;function o(m){return m instanceof Array?m:[m]}r.orArrayResolve=o;function l(m,y){return x.mixin(m,y)}r.mixin=l;function u(m=1){return parseInt(getComputedStyle(document.documentElement).fontSize)*m}r.rem=u;function c(m){return m()}r.call=c;function d(){return new R}r.events=d;function p(m){return new ue(m)}r.pointers=p;function b(m){return new he(m)}r.keys=b;function _(){return new le}r.focus=_})(w||(w={}));globalThis.$=w;class le extends R{constructor(){super();h(this,"layerMap",new Map);h(this,"currentLayer");h(this,"historyList",[])}layer(t){const s=this.layerMap.get(t)??new ce(t).on("blur",i=>this.fire("blur",i)).on("focus",i=>this.fire("focus",i));return this.layerMap.set(s.id,s),s}next(){return this.select(0)}prev(){return this.select(1)}up(){return this.select(2)}down(){return this.select(3)}right(){return this.select(4)}left(){return this.select(5)}blur(){var t;return(t=this.currentLayer)==null||t.blur(),this}select(t){var a;if(this.currentLayer=this.currentLayer??[...this.layerMap.values()].at(0),!this.currentLayer)return this;const s=this.currentLayer.currentFocus,i=this.currentLayer.elementSet.array;if(!s){const o=this.currentLayer.beforeBlur??i.at(0);return o?(this.currentLayer.focus(o),this):this}const n=i.indexOf(s);switch(t){case 0:case 1:{let o=t===0?n+1:n-1;(o===i.length&&this.currentLayer.loop()||o===-1&&!this.currentLayer.loop())&&(o=0);const l=i.at(o);if(!l)break;this.currentLayer.focus(l);break}case 3:case 5:case 4:case 2:{const o=s.coordinate();if(!o)break;const l=$.call(()=>{switch(t){case 2:return{y:o.y,x:o.x/2};case 3:return{y:o.y+o.height,x:o.x/2};case 5:return{y:o.y/2,x:o.x};case 4:return{y:o.y/2,x:o.x+o.width}}}),c=(a=i.map(d=>{if(d===s)return;const p=d.coordinate();if(!p)return;const b=$.call(()=>{switch(t){case 2:return{y:p.y+p.height,x:p.x/2};case 3:return{y:p.y,x:p.x/2};case 5:return{y:p.y/2,x:p.x+p.width};case 4:return{y:p.y/2,x:p.x}}});return{$ele:d,elePosition:p,distance:Math.sqrt((b.x-l.x)**2+(b.y-l.y)**2)}}).detype(void 0).filter(({elePosition:d})=>{switch(t){case 2:if(d.y+d.height>=o.y)return!1;break;case 3:if(d.y<=o.y+o.height)return!1;break;case 5:if(d.x+d.width>=o.x)return!1;break;case 4:if(d.x<=o.x+o.width)return!1;break}return!0}).sort((d,p)=>d.distance-p.distance).at(0))==null?void 0:a.$ele;if(!c)break;this.currentLayer.focus(c)}}return this}}class ce extends R{constructor(t){super();h(this,"id");h(this,"elementSet",new Set);h(this,"entrySet",new Set);h(this,"beforeBlur");h(this,"currentFocus");h(this,"focusHandler",(t,s)=>this.focus(s,!0));h(this,"blurHandler",(t,s)=>this.blur(s));h(this,"__$property__",{loop:!0,scrollThreshold:0});this.id=t,this.add=this.add.bind(this),this.entry=this.entry.bind(this)}add(t){return $.orArrayResolve(t).forEach(s=>{this.elementSet.has(s)||(this.elementSet.add(s),s.tabIndex(0))}),this}remove(t){return this.currentFocus===t&&this.blur(),this.beforeBlur===t&&(this.beforeBlur=void 0),this.elementSet.delete(t),this}entry(t){return $.orArrayResolve(t).forEach(this.entrySet.add.bind(this.entrySet)),this}focus(t,s=!1){if(!t)return this;t.hide(!1);const{scrollTop:i,scrollLeft:n}=document.documentElement,a=$.call(()=>{const u=t.domRect();return{left:u.left+n,top:u.top+i,right:u.right+n,bottom:u.bottom+i,height:u.height,width:u.width}}),{scrollThreshold:o}=this.__$property__,l=this.currentFocus;return this.blur(),this.currentFocus=t,(i>a.top-o||i>a.bottom+o)&&document.documentElement.scrollTo({left:a.left-o,top:a.top-o}),(i+innerHeightthis.remove(t)),this}loop(t){return $.fluent(this,arguments,()=>this.__$property__.loop,()=>$.set(this.__$property__,"loop",t))}scrollThreshold(t){return $.fluent(this,arguments,()=>this.__$property__.scrollThreshold,()=>$.set(this.__$property__,"scrollThreshold",t))}}class ue extends R{constructor(t){super();h(this,"$node");h(this,"map",new Map);this.$node=t,this.$node.on("pointerdown",s=>this.down(s)),this.$node.on("pointerup",s=>this.up(s)),this.$node.on("pointermove",s=>this.move(s)),this.$node.on("pointercancel",s=>this.cancel(s))}down(t){const s=new de(this,this.toData(t),$(t.target));this.map.set(s.id,s),this.fire("down",s,t)}up(t){const s=this.map.get(t.pointerId);s&&(this.map.delete(t.pointerId),this.fire("up",s,t))}move(t){const s=this.map.get(t.pointerId);s&&(this.map.set(s.id,s),s.update(this.toData(t)),this.fire("move",s,t))}cancel(t){const s=this.map.get(t.pointerId);s&&(s.update(this.toData(t)),this.map.delete(s.id),this.fire("cancel",s,t))}toData(t){return{id:t.pointerId,type:t.pointerType,width:t.width,height:t.height,x:t.x,y:t.y,movement_x:t.movementX,movement_y:t.movementY}}}class de{constructor(e,t,s){h(this,"initial_x");h(this,"initial_y");h(this,"$target");h(this,"manager");Object.assign(this,t),this.manager=e,this.$target=s,this.initial_x=t.x,this.initial_y=t.y}get move_x(){return this.x-this.initial_x}get move_y(){return this.y-this.initial_y}update(e){return Object.assign(this,e),this}delete(){return this.manager.map.delete(this.id),this}}Array.prototype.detype=function(...r){return this.filter(e=>{if(r.length)for(const t of r)return typeof e!=typeof t;else return e!==void 0})};Object.defineProperties(Set.prototype,{array:{get:function(){return Array.from(this)}}});Set.prototype.sort=function(r){return this.array.sort(r)};class Ft extends f{constructor(t){super("layout",t);h(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()},{passive:!0}),new IntersectionObserver(s=>{this.inDOM()&&this.render()}).observe(this.dom)}type(t){return $.fluent(this,arguments,()=>this._property.TYPE,()=>$.set(this._property,"TYPE",t))}maxHeight(t){return $.fluent(this,arguments,()=>this._property.ROW_MAX_HEIGHT,()=>$.set(this._property,"ROW_MAX_HEIGHT",t))}column(t){return $.fluent(this,arguments,()=>this._property.COLUNM,()=>$.set(this._property,"COLUNM",t))}gap(t){return $.fluent(this,arguments,()=>this._property.GAP,()=>$.set(this._property,"GAP",t))}root(t){return $.fluent(this,arguments,()=>this._property.ROOT??$(document),()=>$.set(this._property,"ROOT",t))}get COL_WIDTH(){return(this.offsetWidth-this._property.GAP*(this._property.COLUNM-1))/this._property.COLUNM}justifiedCompute(){const t=[],s=this.offsetWidth;for(const i of this.children.array){const n=$(i);if(!(n instanceof V))continue;const a=n.attribute("layout-item-ratio"),o=a?parseFloat(a):n.dom.offsetWidth/n.dom.offsetHeight,l={$node:n,ratio:o};let u=t.at(-1);(!u||u.heightc+=b.ratio);const d=c+o,p=(s-this._property.GAP*u.items.length)/d;u.items.push(l),u.ratio=d,u.height=p}return t}waterfallCompute(){const t=[],s=this.COL_WIDTH,i=()=>{if(t.lengthn.height-a.height)[0]};for(const n of this.children.array){const a=$(n);if(!(a instanceof V))continue;const o=a.attribute("layout-item-ratio"),l=o?parseFloat(o):a.dom.offsetWidth/a.dom.offsetHeight,u={$node:a,ratio:l},c=i();let d=0;c.items.forEach(_=>d+=_.ratio);const p=s/(c.height+s/l),b=s/p;c.items.push(u),c.ratio=p,c.height=b}return t}render(){if(!this.inDOM())return this;if(this.events.fire("beforeRender"),this._property.ITEM_PROPERTIES.clear(),this._property.TYPE==="justified"){const t=this.justifiedCompute();let s=0;for(const i of t){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}),a.$node.coordinate({x:n,y:s,height:i.height,width:o}),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 t=this.waterfallCompute(),s=this.COL_WIDTH;let i=0;for(const n of t){let a=0;for(const o of n.items){const l=s/o.ratio;o.$node.css({position:"absolute",height:`${l}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:l,width:s,top:a,left:i,ratio:o.ratio,$node:o.$node}),o.$node.coordinate({x:i,y:a,height:l,width:s}),a+=l+this._property.GAP}i+=s+this._property.GAP}if(t.length){const n=t.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.events.fire("afterRender"),this}scrollCompute(){if(this.inDOM()===!1)return;const t=document.documentElement.scrollTop-this.dom.offsetTop;this._property.ITEM_PROPERTIES.forEach((s,i)=>{const n=s.top,a=s.top+s.height;i.attribute("focus")===""||document.activeElement===i.dom||(a>t&&n{this.contentId=t,this.events.fire("rendered",{$view:this,previousContent:i,nextContent:s})},o=()=>{this.events.fire("afterSwitch",{$view:this,previousId:t})};return this.events.fire("beforeSwitch",{$view:this,preventDefault:()=>n=!0,targetId:t,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",Vt);var j;const v=class v extends Vt{constructor(t){super({tagname:"router",...t});tt(this,j,"");h(this,"routes",new Map);v.routers.add(this)}base(t){return $.fluent(this,arguments,()=>k(this,j),()=>{et(this,j,t??k(this,j))})}map(t){t=$.orArrayResolve(t);for(const s of t)s instanceof Array?this.map(s):this.routes.set(s.path(),s);return this.resolve(),this}resolve(){return new Promise(t=>{if(!location.pathname.startsWith(k(this,j)))return t(2);const s=location.pathname.replace(k(this,j),"/").replace("//","/"),i=s.split("/").map(_=>`/${_}`),n=location.search,a=new Map(n.replace("?","").split("&").map(_=>_.split("="))),l=(()=>{const _=[];for(const[m,y]of this.routes){const T=$.orArrayResolve(m);for(const S of T){let A=0,N={},nt={};const G=S.split("/").map(L=>`/${L}`);if(!(i.length{const Tt=a.get(Z);Tt!==void 0&&A++,Object.assign(nt,{[Z]:Tt})}),W.startsWith("/:")){A++,Object.assign(N,{[W.replace("/:","")]:i[L].replace("/","")});continue}else if(S.startsWith("#")&&S===location.hash){A++;continue}else if(W===i[L]){A++;continue}else break}_.push({deep:A,$route:y,params:N,query:nt,routePath:S,pathId:Object.keys(nt).length!==0?s+n:Object.keys(N).length!==0?s:T[0]})}}}return _.sort((m,y)=>y.deep-m.deep).at(0)})();if(!l)return t(1);const{$route:u,params:c,pathId:d,query:p}=l;if(d===this.contentId)return t(0);this.events.once("rendered",({nextContent:_,previousContent:m})=>{m==null||m.events.fire("afterShift",{$route:m}),_.events.fire("rendered",{$route:_}),t(0)});const b=this.viewCache.get(d)??u.build({params:c,query:p});this.viewCache.has(d)||this.setView(d,b),this.events.once("beforeSwitch",()=>{var _;b.events.fire("beforeShift",{$route:b}),(_=this.currentContent)==null||_.events.fire("beforeShift",{$route:this.currentContent})}),this.events.once("afterSwitch",()=>b.events.fire("afterShift",{$route:b})),this.switchView(d)})}static init(){if(!history.state||!("index"in history.state)){const t={index:v.index};history.replaceState(t,"")}else v.index=history.state.index;return v.navigationDirection=0,v.resolve(),window.addEventListener("popstate",()=>v.popstate()),window.addEventListener("scroll",()=>{this.setScrollHistory(this.index,location.href,document.documentElement.scrollTop)},{passive:!0}),history.scrollRestoration="manual",this}static open(t,s){return t===void 0?this:(t=this.urlResolver(t),t.href===this.url.href?this:t.origin!==this.url.origin?(window.open(t,s),this):(v.clearForwardScrollHistory(),v.forwardIndex=0,v.index++,history.pushState(v.historyState,"",t),v.stateChange(0),v.resolve(),this))}static back(){return history.back(),this}static forward(){return this.forwardIndex===0?this:(history.forward(),this)}static replace(t){return t===void 0?this:(t=this.urlResolver(t),history.replaceState(v.historyState,"",t),this.stateChange(2),this.setScrollHistory(this.index,location.href,0),v.resolve(),this)}static urlResolver(t){return t instanceof URL?t:(t.startsWith("/")&&(t=`${location.origin}${t}`),t.startsWith("#")&&(t=`${location.origin}${location.pathname}${t}`),new URL(t))}static popstate(){const t=history.state.index>v.index?0:history.state.indext.resolve())),this.scrollRestoration(),this.setScrollHistory(this.index,location.href,document.documentElement.scrollTop)}static get historyState(){return{index:v.index}}static stateChange(t){const s=this.url,i=new URL(location.href);this.url=i,v.events.fire("stateChange",{beforeURL:s,afterURL:i,direction:t}),v.navigationDirection=t}static setScrollHistory(t,s,i){const n=this.getScrollHistory();if(!n)return sessionStorage.setItem(this.scrollHistoryKey,JSON.stringify({[t]:{url:s,value:i}}));n[t]={url:s,value:i},sessionStorage.setItem(this.scrollHistoryKey,JSON.stringify(n))}static getScrollHistory(){const t=sessionStorage.getItem(this.scrollHistoryKey);if(t)return JSON.parse(t)}static clearForwardScrollHistory(){const t=this.getScrollHistory();if(t)for(const s in t)Number(s)>this.index&&delete t[s],sessionStorage.setItem(this.scrollHistoryKey,JSON.stringify(t))}static scrollRestoration(){const t=this.getScrollHistory();if(t&&t[this.index])document.documentElement.scrollTop=t[this.index].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}};j=new WeakMap,h(v,"routers",new Set),h(v,"events",new R),h(v,"navigationDirection"),h(v,"index",0),h(v,"forwardIndex",0),h(v,"url",new URL(location.href)),h(v,"scrollHistoryKey","$ROUTER_SCROLL_HISTORY");let O=v;var z=(r=>(r[r.Forward=0]="Forward",r[r.Back=1]="Back",r[r.Replace=2]="Replace",r))(z||{});O.init();var Q,U;const _t=class _t extends f{constructor(t){super("route",t);tt(this,Q,"");tt(this,U);h(this,"rendered",!1)}path(t){return $.fluent(this,arguments,()=>k(this,Q),()=>et(this,Q,t??k(this,Q)))}builder(t){return et(this,U,t),this}render(t){return k(this,U)&&this.content(k(this,U).call(this,{$route:this,params:t.params,query:t.query})),this.rendered=!0,this}build(t){return new _t({dom:this.dom.cloneNode()}).self(s=>{k(this,U)&&s.builder(k(this,U)).render({params:t.params,query:t.query})})}};Q=new WeakMap,U=new WeakMap;let mt=_t;class Wt extends Lt{constructor(e){super(e),Object.assign(this.__$property__,{preventDefault:!1}),this.on("click",t=>{t.preventDefault(),this.__$property__.preventDefault||$.open(this.href(),this.target())})}preventDefault(e){return $.fluent(this,arguments,()=>this.__$property__.preventDefault,()=>$.set(this.__$property__,"preventDefault",e))}}$.registerTagName("router",O);$.registerTagName("route",mt);$.registerTagName("router-a",Wt);Object.assign($,{open(r,e){return O.open(r,e)},replace(r){return O.replace(r)},back(){return O.back()},forward(){return O.forward()}});class fe{constructor(e,t){h(this,"booru");Object.assign(this,t),this.booru=e}static async fetchUserFavorites(e,t,s,i=100,n){return(await e.fetch(`/favorites.json?${s}&${`search[user_id]=${t.id}`}&limit=${i}&page=${n}`)).map(o=>(t.favorites.add(o.post_id),o.post_id))}update(e){return Object.assign(this,e),this}}class pt{constructor(e,t,s=!0){h(this,"name$",$.state("..."));h(this,"post_upload_count$",$.state(0));h(this,"level$",$.state(10));h(this,"level_string$",$.state("..."));h(this,"booru");h(this,"favorites",new Set);this.booru=e,Object.assign(this,t),s&&this.update$()}static async fetch(e,t){var n;let s;if(typeof t=="string"){const a=(await e.fetch(`/users.json?search[name]=${t}`)).at(0);if(!a)throw"User Not Found";return s=a}else s=await e.fetch(`/users/${t}.json`);const i=((n=e.users.get(s.id))==null?void 0:n.update(s))??new this(e,s);return e.users.set(i.id,i),i}static async fetchMultiple(e,t,s=200){let i="";if(t)for(const[o,l]of Object.entries(t))if(l instanceof Array)i+=`&search[${o}]=${l}`;else if(l instanceof Object)for(const[u,c]of Object.entries(l))i+=`&search[${o}${u}]=${c}`;else i+=`&search[${o}]=${l}`;return(await e.fetch(`/users.json?limit=${s}${i}`)).map(o=>{const l=new this(e,o);return e.users.set(l.id,l),l})}update(e){return Object.assign(this,e),this.update$(),this}update$(){this.name$.set(this.name),this.post_upload_count$.set(this.post_upload_count),this.level$.set(this.level),this.level_string$.set(this.level_string)}get booruURL(){return`${this.booru.origin}/users/${this.id}`}get url(){return`/users/${this.id}`}}const dt=class dt extends pt{constructor(t,s,i){super(t,i,!1);h(this,"apiKey");h(this,"favorite_count$",$.state(0));h(this,"forum_post_count$",$.state(0));this.apiKey=s,this.update$()}update$(){var t,s;super.update$(),(t=this.forum_post_count$)==null||t.set(this.forum_post_count),(s=this.favorite_count$)==null||s.set(this.favorite_count)}async init(){await this.fetchFavorites()}async fetchFavorites(){const t=Array.from(this.favorites.keys()).at(-1),s=await fe.fetchUserFavorites(this.booru,this,"",1e3,t?`b${t}`:1);return dt.events.fire("favoriteUpdate",this),s.length>=1e3&&this.fetchFavorites(),s}static get storageUserData(){const t=localStorage.getItem("user_data");return t?JSON.parse(t):null}static set storageUserData(t){localStorage.setItem("user_data",JSON.stringify(t))}};h(dt,"events",new R);let H=dt;const D=class D{constructor(e){h(this,"user");h(this,"posts",new Map);h(this,"tags",new Map);h(this,"users",new Map);h(this,"favorites",new Map);Object.assign(this,e),this.origin.endsWith("/")&&(this.origin=this.origin.slice(0,-1)),D.manager.set(this.name,this)}static set(e){this.used=e,this.name$.set(e.name),this.storageAPI=e.name;const t=H.storageUserData;return t&&e.login(t.username,t.apiKey),this.events.fire("set"),this}static get storageAPI(){return localStorage.getItem("booru_api")}static set storageAPI(e){e?localStorage.setItem("booru_api",e):localStorage.removeItem("booru_api")}async fetch(e,t="GET"){const s=this.user?`${e.includes("?")?"&":"?"}login=${this.user.name}&api_key=${this.user.apiKey}`:"",i=await fetch(`${this.origin}${e}${s}`,{method:t}).then(n=>n.json());if(i.success===!1)throw i.message;return i}async login(e,t){const s=await this.fetch(`/profile.json?login=${e}&api_key=${t}`);return this.user=new H(this,t,s),this.user.init(),D.events.fire("login",this.user),this.user}logout(){return this.user=void 0,H.storageUserData=null,D.events.fire("logout"),this}};h(D,"used"),h(D,"events",new R),h(D,"name$",$.state(D.name)),h(D,"manager",new Map);let g=D;class me{constructor(e,t){h(this,"post_count$",$.state(0));h(this,"name$",$.state(""));h(this,"booru");this.booru=e,Object.assign(this,t),this.$update()}static async fetch(e,t){var n;const s=await e.fetch(`/tags/${t}.json`),i=((n=e.tags.get(s.id))==null?void 0:n.update(s))??new this(e,s);return e.tags.set(i.id,i),i}static async fetchMultiple(e,t,s=1e3){let i="";if(t)for(const[o,l]of Object.entries(t))if(l instanceof Array)i+=`&search[${o}]=${l}`;else if(l instanceof Object)for(const[u,c]of Object.entries(l))i+=`&search[${o}${u}]=${c}`;else i+=`&search[${o}]=${l}`;return(await e.fetch(`/tags.json?limit=${s}${i}`)).map(o=>{var u;const l=((u=e.tags.get(o.id))==null?void 0:u.update(o))??new this(e,o);return e.tags.set(l.id,l),l})}update(e){return Object.assign(this,e),this.$update(),this}$update(){this.post_count$.set(this.post_count),this.name$.set(this.name)}}var B=(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))(B||{});const bt=1e3,ht=bt*60,lt=ht*60,ct=lt*24,pe=ct*7,ot=new Intl.RelativeTimeFormat("en",{style:"long"});function gt(r){r=Math.floor(r);const e=r/bt,t=r/ht,s=r/lt,i=r/ct,n=r%1e3,a=Math.floor(r%6e4/1e3),o=Math.floor(r%36e5/6e4),l=Math.floor(r%(36e5*24)/36e5),u=a.toString().padStart(2,"0"),c=o.toString().padStart(2,"0"),d=l.toString().padStart(2,"0");return{seconds:e,minutes:t,hours:s,days:i,mil:n,s:a,min:o,h:l,ss:u,mm:c,hh:d}}function ge(r,e=Date.now()){const t=r-e,s=Math.abs(t);if(sthis.update$()),this}static async fetchMultiple(t,s,i=20,n){let a="";if(s){if(typeof s=="string")a=s;else for(const[c,d]of Object.entries(s))if(d!==void 0){if(c==="tags"){a+=`${d}`;continue}a.at(-1)!=="="&&(a+=" "),a+=`${c}:${d}`}}const o=await t.fetch(`/posts.json?limit=${i}&tags=${a}${n?`&page=${n}`:""}&_method=get`);if(!(o instanceof Array))return[];const l=o.map(c=>{var p;const d=((p=t.posts.get(c.id))==null?void 0:p.update(c))??new this(t,c.id,c);return t.posts.set(d.id,d),d});if(!l.length)return l;const u=[...new Set(o.map(c=>[c.approver_id,c.uploader_id].detype(null)).flat())];return pt.fetchMultiple(t,{id:u}).then(()=>l.forEach(c=>c.update$())),l}update$(){var t,s,i,n;this.uploader$.set(((t=this.uploader)==null?void 0:t.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(ge(+new Date(this.created_at))),this.favcount$.set(this.fav_count),this.score$.set(this.score),this.file_size$.set($e(this.file_size)),this.file_ext$.set(this.file_ext),this.file_url$.set(this.file_url),this.source$.set(this.source),this.dimension$.set(`${this.image_width}x${this.image_height}`),this.booruUrl$.set(`${this.booruUrl}`),this.isUgoria&&this.webm_url$.set(this.large_file_url),this.createdDate=new Date(this.created_at),this.fire("update")}update(t){return Object.assign(this,t),this.update$(),this}async fetchTags(){return await this.ready,await me.fetchMultiple(this.booru,{name:{_space:this.tag_string}})}async createFavorite(){if(!this.booru.user)return;const t=await this.booru.fetch(`/favorites.json?post_id=${this.id}`,"POST");return this.update(t),this.booru.user.favorites.add(t.id),H.events.fire("favoriteUpdate",this.booru.user),t.id}async deleteFavorite(){!this.booru.user||await fetch(`/api/favorites/${this.id}?login=${this.booru.user.name}&api_key=${this.booru.user.apiKey}&origin=${this.booru.origin}`,{method:"DELETE"}).then(s=>s.json())===!1||(this.fav_count--,this.favcount$.set(this.fav_count),this.booru.user.favorites.delete(this.id),H.events.fire("favoriteUpdate",this.booru.user))}get pathname(){return`/posts/${this.id}`}get uploader(){return this.booru.users.get(this.uploader_id)}get approver(){return this.approver_id?this.booru.users.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 t=this.tag_string.split(" ");return[...this.booru.tags.values()].filter(s=>t.includes(s.name))}get previewURL(){var t,s,i;return((i=(s=(t=this.media_asset)==null?void 0:t.variants)==null?void 0:s.find(n=>n.file_ext==="webp"))==null?void 0:i.url)??this.large_file_url}get booruUrl(){return`${this.booru.origin}/posts/${this.id}`}get url(){return`https://danbooru.defaultkavy.com/posts/${this.id}`}get isFileSource(){return this.source.startsWith("file://")}get isLargeFile(){return this.file_size>5e6}}class jt{constructor(e){Object.assign(this,e)}static async fetch(e,t){const s=await e.fetch(`/artist_commentaries/${t}.json`);return new this(s)}static async fetchMultiple(e,t,s=200){let i="";if(t)for(const[o,l]of Object.entries(t))if(l instanceof Array)i+=`&search[${o}]=${l}`;else if(l instanceof Object)for(const[u,c]of Object.entries(l))i+=`&search[${o}${u}]=${c}`;else i+=`&search[${o}]=${l}`;return(await e.fetch(`/artist_commentaries.json?limit=${s}${i}`)).map(o=>{const l=new this(o);return this.manager.set(l.id,l),l})}}h(jt,"manager",new Map);class ye extends f{constructor(t,s,i){super("video-controller");h(this,"$video");h(this,"$viewer");h(this,"duration$",$.state("00:00"));h(this,"post");this.$video=t,this.$viewer=s,this.post=i,this.build()}build(){const t=$.events();this.$video.on("timeupdate",()=>this.durationUpdate()),this.content([$("div").class("video-details").content([$("div").class("left").content([$("ion-icon").class("play").title("Play").name("play").self(s=>{this.$video.on("play",()=>s.name("pause")).on("pause",()=>s.name("play")),s.on("click",()=>this.$video.isPlaying?this.$video.pause():this.$video.play())}),$("div").class("duration").content([$("span").class("current-time").content(this.duration$),$("span").content("/"),$("span").class("total-time").content("00:00").self(s=>{this.$video.on("loadeddata",()=>{const i=gt(this.$video.duration*1e3);s.content(Number(i.hh)>0?`${i.hh}:${i.mm}:${i.ss}`:`${i.mm}:${i.ss}`)})})])]),$("div").class("right").content([$("ion-icon").class("volume").title("Volume").name("volume-high").disable(!this.post.hasSound).self(s=>{const i=()=>{this.$video.muted()?s.name("volume-mute"):s.name("volume-high")};s.on("click",()=>{this.$video.muted(!this.$video.muted()),i()})}),$("ion-icon").class("full-screen").title("Full-Screen").name("scan").self(s=>{s.on("click",()=>{document.fullscreenElement?document.exitFullscreen():this.$viewer.dom.requestFullscreen()})})])]),$("div").class("progressbar-container").content([$("div").class("progressbar").content([$("div").class("progress").self(s=>{this.$video.on("timeupdate",i=>{s.css({width:`${this.$video.currentTime()/this.$video.duration*100}%`})}),t.on("progressChange",i=>{s.css({width:`${i*100}%`})})})])]).self(s=>{const i=$.pointers($(document.body));let n=!1;i.on("down",(a,o)=>{if(!s.contains(a.$target))return a.delete();o.preventDefault(),this.$video.isPlaying&&(n=!0,this.$video.pause());const l=(a.x-s.domRect().x)/s.offsetWidth;this.$video.currentTime(l*this.$video.duration)}),i.on("move",(a,o)=>{o.preventDefault();const l=(a.x-s.domRect().x)/s.offsetWidth;this.$video.currentTime(l*this.$video.duration),t.fire("progressChange",l)}),i.on("up",(a,o)=>{n&&this.$video.play(),n=!1})})])}durationUpdate(){const t=gt(this.$video.currentTime()*1e3);this.duration$.set(Number(t.hh)>0?`${t.hh}:${t.mm}:${t.ss}`:`${t.mm}:${t.ss}`)}}class Ut extends f{constructor(t){super("detail-panel");h(this,"post",null);h(this,"options");this.options={preview:(t==null?void 0:t.preview)??!1,tagsType:(t==null?void 0:t.tagsType)??"detail"},this.build()}build(){this.post?this.content([this.options.preview?$("div").class("preview").content([$("img").src(this.post.previewURL)]):null,$("div").class("detail").content([$("section").class("post-info").content([new E("id").name("Post").content(`#${this.post.id}`),new E("uploader").name("Uploader").content(this.post.uploader$),new E("approver").name("Approver").content(this.post.approver$),new E("date").name("Date").content(this.post.created_date$),new E("size").name("Size").content([this.post.file_size$,this.post.dimension$]),new E("file-type").name("File Type").content(this.post.file_ext$),$("div").class("inline").content([new E("favorites").name("Favorites").content(this.post.favcount$),new E("score").name("Score").content(this.post.score$)]),new E("file-url").name("File").content([$("a").href(this.post.file_url$).content(this.post.file_url$.convert(t=>t.replace("https://",""))).target("_blank"),$("ion-icon").name("clipboard").on("click",(t,s)=>this.copyButtonHandler(s,this.post.file_url))]),new E("source-url").name("Source").content([$("a").href(this.post.source$).content(this.post.source$.convert(t=>t.replace("https://",""))).target("_blank"),$("ion-icon").name("clipboard").on("click",(t,s)=>this.copyButtonHandler(s,this.post.source))]),new E("booru-url").name(g.name$).content([$("a").href(this.post.booruUrl$).content(this.post.booruUrl$.convert(t=>t.replace("https://",""))).target("_blank"),$("ion-icon").name("clipboard").on("click",(t,s)=>this.copyButtonHandler(s,this.post.booruUrl))]),new E("webm-url").name("Webm").hide(!0).self(async t=>{await this.post.ready,this.post.isUgoria&&t.content($("a").href(this.post.webm_url$).content(this.post.webm_url$.convert(s=>s.replace("https://",""))).target("_blank")).hide(!1)})]),$("div").class("post-tags").content(async t=>{if(this.options.tagsType==="detail"){let s=function(c,d){return d.length?[$("h3").content(c),$("section").content([d.map(p=>$("div").class("tag").content([$("a").class("tag-name").content(p.name).href(`/posts?tags=${p.name}`),$("span").class("tag-post-count").content(p.post_count$.convert(st))]))])]:null};const i=await this.post.fetchTags(),[n,a,o,l,u]=[i.filter(c=>c.category===B.Artist),i.filter(c=>c.category===B.Character),i.filter(c=>c.category===B.General),i.filter(c=>c.category===B.Meta),i.filter(c=>c.category===B.Copyright)];return[s("Artist",n),s("Character",a),s("Copyright",u),s("Meta",l),s("General",o)]}else{let s=function(i,n){var a;return(a=n.at(0))!=null&&a.length?[$("h3").content(i),$("section").class("tag-name-only").content([n.map(o=>$("a").class("tag").content(o).href(`/posts?tags=${o}`))])]:null};return[s("Artist",this.post.tag_string_artist.split(" ")),s("Character",this.post.tag_string_character.split(" ")),s("Copyright",this.post.tag_string_copyright.split(" ")),s("Meta",this.post.tag_string_meta.split(" ")),s("General",this.post.tag_string_general.split(" "))]}})])]):this.content($("span").class("no-content").content("No Selected"))}update(t){return this.post=t,this.build(),this}copyButtonHandler(t,s){t.name("checkmark"),navigator.clipboard.writeText(s),setTimeout(()=>t.name("clipboard"),3e3)}position(t){let s=0;return addEventListener("scroll",()=>{this.inDOM()&&(s=document.documentElement.scrollTop)},{passive:!0}),t.on("beforeShift",()=>{innerWidth>800&&this.css({position:"absolute",top:`calc(${s}px + var(--nav-height) + var(--padding))`})}).on("afterShift",()=>this.css({position:"",top:""})),this}}class E extends f{constructor(t){super("div");h(this,"$name",$("span").class("property-name"));h(this,"$values",$("div").class("property-values"));this.staticClass("property").attribute("property-id",t),super.content([this.$name,this.$values.hide(!0)])}name(t){return this.$name.content(t),this}content(t){this.$values.hide(!1);const s=$.orArrayResolve(t);return this.$values.content(s.map(i=>$("span").staticClass("property-value").content(i))),this}}const we=$("route").path("/posts/:id").id("post").builder(({$route:r,params:e})=>{if(!Number(e.id))return $("h1").content("404: POST NOT FOUND");const t=q.get(g.used,+e.id),s=$("video"),i=$.events();return $.keys($(window)).if(n=>{if(!($(n.target)instanceof M)&&r.inDOM())return!0}).keydown(["f","F"],n=>{var a;(a=g.used.user)!=null&&a.favorites.has(t.id)?t.deleteFavorite():t.createFavorite()}).keydown(" ",n=>{n.preventDefault(),s.isPlaying?s.pause():s.play()}),[$("div").class("viewer").content(async n=>(i.on("video_play_pause",()=>{s.isPlaying?s.pause():s.play()}),await t.ready,n.on("pointermove",a=>{(a.pointerType==="mouse"||a.pointerType==="pen")&&i.fire("viewerPanel_show")}).on("pointerup",a=>{var o;(o=$(":.viewer-panel .panel"))!=null&&o.contains($(a.target))||(a.pointerType==="touch"&&i.fire("viewerPanel_switch"),a.pointerType==="mouse"&&i.fire("video_play_pause"))}).on("mouseleave",()=>{i.fire("viewerPanel_hide")}),[$("div").class("viewer-panel").hide(!1).content([$("div").class("panel").content([t.isVideo?new ye(s,n,t):null,$("div").class("buttons").content([$("ion-icon").title("Favorite").name("heart-outline").self(a=>{var o;H.events.on("favoriteUpdate",l=>{l.favorites.has(t.id)?a.name("heart"):a.name("heart-outline")}),(o=g.used.user)!=null&&o.favorites.has(t.id)&&a.name("heart"),a.on("click",()=>{var l;(l=g.used.user)!=null&&l.favorites.has(t.id)?t.deleteFavorite():t.createFavorite()})}),$("ion-icon").title("Original Size").name("resize-outline").self(a=>{a.on("click",()=>{i.fire("original_size"),a.disable(!0)}),(!t.isLargeFile||t.isVideo)&&a.disable(!0)})])]),$("div").class("overlay")]).self(a=>{i.on("viewerPanel_hide",()=>a.hide(!0)).on("viewerPanel_show",()=>a.hide(!1)).on("viewerPanel_switch",()=>a.hide(!a.hide()))}),t.isVideo?s.height(t.image_height).width(t.image_width).src(t.file_ext==="zip"?t.large_file_url:t.file_url).controls(!1).autoplay(!0).loop(!0).disablePictureInPicture(!0):$("img").src(t.isLargeFile?t.large_file_url:t.file_url).self(a=>{i.on("original_size",()=>a.src(t.file_url))})])),$("div").class("content").content([$("h3").content("Artist's Commentary"),$("section").class("commentary").content(async n=>{const a=(await jt.fetchMultiple(g.used,{post:{_id:t.id}})).at(0);return[a?[a.original_title?$("h3").content(a.original_title):null,$("pre").content(a.original_description)]:"No commentary"]})]),new Ut().position(r).update(t)]});class $t extends f{constructor(t){super("post-tile");h(this,"post");h(this,"$video");h(this,"$img");h(this,"duration$",$.state(""));this.post=t,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.$img=$("img").draggable(!1).css({opacity:"0"}).width(this.post.image_width).height(this.post.image_height).src(this.post.previewURL).loading("lazy"),this.attribute("filetype",this.post.file_ext),this.durationUpdate(),this.build()}build(){var t;(t=this.$video)==null||t.on("timeupdate",(s,i)=>{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).preventDefault(F).content(()=>[this.$video,this.$img.on("mousedown",s=>s.preventDefault()).once("load",(s,i)=>{i.animate({opacity:[0,1]},{duration:300},()=>i.css({opacity:""})),this.removeClass("loading")})])]),this.on(["focus","mouseenter","touchstart"],()=>{var s,i;(s=this.$video)!=null&&s.isPlaying||(i=this.$video)==null||i.src(this.post.large_file_url).hide(!1).play().catch(n=>{}),this.post.isGif&&this.$img.src(this.post.large_file_url)},{passive:!0}).on(["blur","mouseleave","touchend","touchcancel"],()=>{var s;(s=this.$video)==null||s.pause().currentTime(0).hide(!0),this.post.isGif&&this.$img.src(this.post.previewURL)},{passive:!0}).on("click",()=>{if(F.value){if(innerWidth<=800)return $.open(this.post.pathname);$(document.activeElement)===this?$.open(this.post.pathname):this.trigger("$focus")}})}durationUpdate(){if(!this.$video)return;const t=gt(this.post.media_asset.duration*1e3-this.$video.currentTime()*1e3);this.duration$.set(Number(t.hh)>0?`${t.hh}:${t.mm}:${t.ss}`:`${t.mm}:${t.ss}`)}}class be extends Ft{constructor(t){super();h(this,"posts",new Set);h(this,"$posts",new Map);h(this,"orderMap",new Map);h(this,"tags");h(this,"finished",!1);h(this,"limit",100);h(this,"$focus",$.focus());this.tags=t==null?void 0:t.tags,this.addStaticClass("post-grid"),this.type("waterfall").gap(10),this.init()}async init(){setInterval(()=>{this.inDOM()&&document.documentElement.scrollTop===0&&this.getPost("newer")},1e4),g.events.on("set",()=>{this.removeAll(),this.finished&&(this.finished=!1,this.events.fire("startLoad"),this.loader())}),this.on("resize",()=>this.resize()),this.events.fire("startLoad"),this.loader(),this.$focus.layer(100).loop(!1).scrollThreshold($.rem(2)+60),$.keys($(window)).if(t=>{if(!($(t.target)instanceof M)&&this.inDOM())return!0}).keydown(["w","W"],t=>{t.preventDefault(),this.$focus.up()}).keydown(["s","S"],t=>{t.preventDefault(),this.$focus.down()}).keydown(["d","D"],t=>{t.preventDefault(),this.$focus.right()}).keydown(["a","A"],t=>{t.preventDefault(),this.$focus.left()}).keydown([" ","Enter"],t=>{var i;t.preventDefault();const s=(i=this.$focus.currentLayer)==null?void 0:i.currentFocus;s instanceof $t&&$.open(`/posts/${s.post.id}`)}).keydown(["Escape"],t=>{t.preventDefault(),this.$focus.blur()})}async loader(){if(!this.inDOM())return setTimeout(()=>this.loader(),100);for(;this.inDOM()&&document.documentElement.scrollHeight<=innerHeight*2;)if(!(await this.getPost("older")).length)return;document.documentElement.scrollTop+innerHeight>document.documentElement.scrollHeight-innerHeight*2&&!(await this.getPost("older")).length||setTimeout(()=>this.loader(),100)}resize(){const t=Math.round(this.dom.clientWidth/300);this.column(t>=2?t:2)}addPost(t){t=$.orArrayResolve(t);for(const i of t){if(!i.file_url||this.posts.has(i))continue;const n=new $t(i).on("$focus",(a,o)=>this.$focus.layer(100).focus(o));this.$posts.set(i,n),this.posts.add(i)}this.$focus.layer(100).elementSet.clear();const s=[...this.orderMap.values()].map(i=>{var n;return(n=this.$posts.get(i))==null?void 0:n.self(this.$focus.layer(100).add)});return this.content(s).render(),this}removeAll(){return this.posts.clear(),this.$posts.clear(),this.orderMap.clear(),this.$focus.layer(100).removeAll(),this.animate({opacity:[1,0]},{duration:300,easing:"ease"},()=>this.clear().render()),this}async getPost(t){const s=this.tags?decodeURIComponent(this.tags).split("+"):void 0,i=[],n=[];let a=this.limit;if(s)for(const c of s)c.startsWith("ordfav:")||c.startsWith("order:")?n.push(c):c.startsWith("limit:")?a=Number(c.split(":")[1]):i.push(c);if(n.length){if(n.length>1)return this.events.fire("post_error",`Error: These query can't be used together [${n}].`),[];const c=n[0];if(c.startsWith("ordfav:")){const d=c.split(":")[1],p=i.length?`&search[post_tags_match]=${i.toString().replaceAll(",","+")}`:"",b=this.orderKeyList.length?t==="newer"?`&search[id]=>${this.orderKeyList.at(0)}`:`&search[id]=<${this.orderKeyList.at(-1)}`:void 0,_=await g.used.fetch(`/favorites.json?search[user_name]=${d}${b??""}${p}&limit=${a}`),m=await q.fetchMultiple(g.used,{tags:`id:${_.map(T=>T.post_id).toString()}`}),y=new Map;for(const T of _){const S=m.find(A=>A.id===T.post_id);S&&y.set(T.id,S)}return this.orderMap=new Map(t==="newer"?[...y,...this.orderMap]:[...this.orderMap,...y]),this.addPost(m),m}if(c.startsWith("order:")){const d=this.orderKeyList.length?t==="newer"?1:this.orderMap.size/a+1:void 0,p=await q.fetchMultiple(g.used,{tags:this.tags},a,d),b=new Map(p.map(_=>[_.id,_]));return b.forEach((_,m)=>{this.orderMap.has(m)&&b.delete(m)}),this.orderMap=new Map(t==="newer"?[...b,...this.orderMap]:[...this.orderMap,...b]),this.addPost(p),p}}const o=this.orderKeyList.length?t==="newer"?`a${this.orderKeyList.at(0)}`:`b${this.orderKeyList.at(-1)}`:void 0,l=await q.fetchMultiple(g.used,{tags:this.tags},a,o),u=new Map(l.map(c=>[c.id,c]));return this.orderMap=new Map(t==="newer"?[...u,...this.orderMap]:[...this.orderMap,...u]),this.addPost(l),l.length||(this.finished=!0,this.posts.size?this.events.fire("endPost"):this.events.fire("noPost")),l}get orderKeyList(){return[...this.orderMap.keys()]}}class Gt{static async fetch(e,t,s=20){if(!t.length)return this.searchQuery.map(a=>new It(a));const i=await e.fetch(`/autocomplete.json?search[query]=${t}&search[type]=tag_query&version=1&limit=${s}`);return[...t.length?this.searchQuery.filter(a=>a.value.startsWith(t)&&a.value!==t):this.searchQuery,...i].map(a=>new It(a))}}h(Gt,"searchQuery",[{value:"user:",label:"user:"},{value:"approver:",label:"approver:"},{value:"-approver:",label:"-approver:"},{value:"order:",label:"order:"},{value:"ordfav:",label:"ordfav:"},{value:"ordfavgroup:",label:"ordfavgroup:"},{value:"search:",label:"search:"},{value:"favgroup:",label:"favgroup:"},{value:"-favgroup:",label:"-favgroup:"},{value:"favcount:",label:"favcount:"},{value:"id:",label:"id:"},{value:"tagcount:",label:"tagcount:"},{value:"gentags:",label:"gentags:"},{value:"arttags:",label:"arttags:"},{value:"chartags:",label:"chartags:"},{value:"copytags:",label:"copytags:"},{value:"metatags:",label:"metatags:"},{value:"score:",label:"score:"},{value:"upvote:",label:"upvote:"},{value:"downvote:",label:"downvote:"},{value:"disapproved:",label:"disapproved:"},{value:"md5:",label:"md5:"},{value:"width:",label:"width:"},{value:"height:",label:"height:"},{value:"ratio:",label:"ratio:"},{value:"mpixels:",label:"mpixels:"},{value:"filesize:",label:"filesize:"},{value:"duration:",label:"duration:"},{value:"is:",label:"is:"},{value:"has:",label:"has:"},{value:"pool:",label:"pool:"},{value:"-pool:",label:"-pool:"},{value:"ordpool:",label:"ordpool:"},{value:"random:",label:"random:"},{value:"limit:",label:"limit:"},{value:"date:",label:"date:"},{value:"commenter:",label:"commenter:"},{value:"note:",label:"note:"},{value:"noter:",label:"noter:"},{value:"noteupdater:",label:"noteupdater:"},{value:"status:",label:"status:"},{value:"-status:",label:"-status:"},{value:"rating:",label:"rating:"},{value:"-rating:",label:"-rating:"},{value:"source:",label:"source:"},{value:"-source:",label:"-source:"},{value:"pixiv:",label:"pixiv:"},{value:"parent:",label:"parent:"},{value:"child:",label:"child:"},{value:"flagger:",label:"flagger:"},{value:"appealer:",label:"appealer:"},{value:"commentary:",label:"commentary:"},{value:"commentaryupdater:",label:"commentaryupdater:"}].map(e=>({type:"query",...e})));class It{constructor(e){Object.assign(this,e)}isTag(){return this.type==="tag"||this.type==="tag-autocorrect"||this.type==="tag-alias"||this.type==="tag-word"}isTagAutocorrect(){return this.type==="tag-autocorrect"}isTagAntecedent(){return!!this.antecedent}isTagWord(){return this.type==="tag-word"}isUser(){return this.type==="user"}}class _e extends f{constructor(){super("searchbar");h(this,"$tagInput",new Se(this));h(this,"$selectionList",new Te);h(this,"typingTimer",null);h(this,"$filter",$("div").class("filter"));this.build(),window.addEventListener("keyup",t=>{!this.inDOM()&&t.key==="/"&&this.open(),this.inDOM()&&t.key==="Escape"&&this.close()})}build(){this.content([$("div").class("input-container").content([this.$tagInput.on("input",()=>this.inputHandler()).on("keydown",t=>this.keyHandler(t)),$("ion-icon").name("close-circle-outline").title("Clear Input").on("click",()=>this.$tagInput.clearAll())]).on("click",t=>{t.target===this.$tagInput.dom&&this.$tagInput.addTag().input()}),$("div").class("selection-list-container").content([this.$selectionList]),this.$filter.on("click",()=>{location.hash==="#search"&&this.close()})])}open(){return location.hash!=="#search"&&$.open(location.href+"#search"),this}close(){return location.hash==="#search"&&$.back(),this}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(t){var n,a;const s=()=>{t.preventDefault(),this.$tagInput.addTag().input()},i=o=>{const l=this.$tagInput.children.indexOf(this.$tagInput.$inputor);if(this.$tagInput.$input.value().at(-1)===":")return this.getSearchSuggestions();const u=this.$tagInput.children.array.at(l+1);this.$tagInput.addTag(o.value()),u?this.$tagInput.editTag(u):this.$tagInput.input()};switch(t.key){case"ArrowUp":{t.preventDefault(),this.$selectionList.focusPrevSelection(),this.$tagInput.value((n=this.$selectionList.focused)==null?void 0:n.value());break}case"ArrowDown":{t.preventDefault(),this.$selectionList.focusNextSelection(),this.$tagInput.value((a=this.$selectionList.focused)==null?void 0:a.value());break}case" ":s();break;case"Enter":{t.preventDefault(),this.$selectionList.focused?i(this.$selectionList.focused):(this.$tagInput.addTag(),this.search());break}case"Tab":{t.preventDefault();const o=this.$tagInput.children.indexOf(this.$tagInput.$inputor);if(t.shiftKey){o-1>=0&&this.$tagInput.editTag(this.$tagInput.children.array.at(o-1));break}if(this.$selectionList.focused)i(this.$selectionList.focused);else{const l=this.$tagInput.children.array.at(o+1);l?this.$tagInput.editTag(l):this.$tagInput.addTag().input()}break}case"Backspace":{const o=this.$tagInput.children.indexOf(this.$tagInput.$inputor);o!==0&&!this.$tagInput.$input.value().length&&(t.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 t=this.$tagInput.$input.value(),s=await Gt.fetch(g.used,t,20);this.$selectionList.clearSelections().addSelections(s.map(i=>new xe().value(i.value).content([$("div").class("selection-label").content([i.isTagAntecedent()?$("span").class("tag-antecedent").self(n=>n.dom.innerHTML=i.antecedent.replaceAll(t,`${t}`)):null,$("div").class("label-container").content([i.isTagAntecedent()?$("ion-icon").name("arrow-forward-outline"):null,$("span").class("label").self(n=>n.dom.innerHTML=i.label.replaceAll(t,`${t}`))])]),i.isTag()?$("div").class("tag-detail").content([$("span").class("tag-post-count").content(st(i.post_count)),$("span").class("tag-category").content(B[i.category])]):null,i.isUser()?$("span").class("user-level").content(i.level):null]).on("click",()=>{this.$tagInput.addTag(i.value).input()})))}search(){return $.replace(`/posts?tags=${this.$tagInput.query.replace(":","%3A")}`),this.$tagInput.clearAll(),this.inactivate(),this}checkURL(t,s){if((t==null?void 0:t.hash)==="#search"&&this.inactivate(),s.hash==="#search"&&this.activate(),`${t==null?void 0:t.pathname}${t==null?void 0:t.search}`==`${s.pathname}${s.search}`)return;const i=s.searchParams.get("tags");this.$tagInput.clearAll(),i==null||i.split(" ").forEach(n=>this.$tagInput.addTag(n))}}class Te extends f{constructor(){super("selection-list");h(this,"focused",null);h(this,"selections",new Set)}addSelections(t){t=$.orArrayResolve(t);for(const s of t)this.selections.add(s);return this.insert(t),this}clearSelections(){return this.focused=null,this.selections.clear(),this.clear(),this}focusSelection(t){return this.blurSelection(),this.focused=t,t.focus(),t.offsetTopthis.scrollTop()+this.offsetHeight&&this.scrollTop(t.offsetTop+t.offsetHeight-this.offsetHeight),this}blurSelection(){var t;return(t=this.focused)==null||t.blur(),this.focused=null,this}focusNextSelection(){const t=this.selections.array,s=t.at(0);if(this.focused){const i=t.at(t.indexOf(this.focused)+1);i?this.focusSelection(i):s&&this.focusSelection(s)}else s&&this.focusSelection(s)}focusPrevSelection(){const t=this.selections.array;if(this.focused){const s=t.at(t.indexOf(this.focused)-1);s&&this.focusSelection(s)}else{const s=t.at(0);s&&this.focusSelection(s)}}}class xe extends f{constructor(){super("selection");h(this,"property",{value:""})}value(t){return $.fluent(this,arguments,()=>this.property.value,()=>$.set(this.property,"value",t))}focus(){return this.addClass("active"),this}blur(){return this.removeClass("active"),this}}class Se extends f{constructor(t){super("tag-input");h(this,"$input",$("input").type("text"));h(this,"$sizer",$("span").class("sizer"));h(this,"$inputor",$("div").class("input-wrapper").content([this.$sizer,this.$input.on("input",()=>{this.$sizer.content(this.$input.value())})]));h(this,"tags",new Set);h(this,"$seachbar");this.$seachbar=t}input(){return this.insert(this.$inputor),this.$input.focus(),this.$seachbar.$selectionList.clearSelections(),this.$seachbar.getSearchSuggestions(),this}addTag(t){if(t=t??this.$input.value(),!t.length)return this;const s=new Oe(t);return s.on("click",()=>this.editTag(s)),this.tags.add(s),this.value(""),this.$input.inDOM()?this.$inputor.replace(s):this.insert(s),this}editTag(t){return this.addTag(),this.tags.delete(t),t.replace(this.$inputor),this.value(t.name),this.$input.focus(),this.$seachbar.getSearchSuggestions(),this}clearAll(){return this.value(""),this.tags.clear(),this.clear(),this}value(t){return t===void 0?this:(this.$input.value(t),this.$sizer.content(t),this)}focus(){return this.$input.focus(),this}get query(){return this.tags.array.map(t=>t.name).toString().replace(",","+")}}class Oe extends f{constructor(t){super("tag");h(this,"name");this.name=t,this.build()}build(){this.content(this.name)}}class Ie extends f{constructor(){super("ion-icon")}name(e){return this.attribute("name",e),this}size(e){return this.attribute("size",e),this}disable(e){return this.attribute("disable",e),this}link(e,t=!1){return this.on("click",()=>t?$.replace(e):$.open(e)),this}}class ke extends wt{constructor(){super();h(this,"$icon",$("ion-icon"));h(this,"$label",$("span"));this.addStaticClass("icon"),this.build()}build(){super.content([this.$icon.hide(!0),this.$label])}content(t){return this.$label.content(t),this}icon(t){return this.$icon.name(t).hide(!1),this}link(t,s=!1){return this.on("click",()=>s?$.replace(t):$.open(t)),this}}const Ee=$("route").id("login").path("/login").builder(()=>{const[r,e]=[$.state(""),$.state("")];return[$("div").class("login-container").content([$("h1").content("Login"),$("div").class("username","input-container").content([$("label").for("username").content("Username"),$("input").type("text").id("username").value(r)]),$("div").class("api-key","input-container").content([$("label").for("api-key").content("API Key"),$("input").type("password").id("api-key").value(e)]),$("icon-button").content("Login").on("click",async()=>{await g.used.login(r.value,e.value),g.used.user&&(H.storageUserData={apiKey:e.value,username:r.value},r.set(""),e.set(""),$.replace("/"))}),$("icon-button").content("Create Account").icon("open-outline").on("click",()=>$.open("https://danbooru.donmai.us/users/new","_blank"))])]});class Me extends f{constructor(){super("drawer");h(this,"$filter",$("div").class("filter"));h(this,"$container",$("div").class("drawer-container"));h(this,"pointers",$.pointers($(document.body)));h(this,"opened",!1);this.hide(!0),this.build()}build(){this.content([this.$container.content([$("div").class("user-info").hide(!0).self(t=>[g.events.on("login",s=>{t.content([$("div").content([$("h3").class("username").content(s.name$),$("div").class("user-detail").content([$("span").class("userid").content(`ID: ${s.id}`),$("span").class("level").content(["Level: ",s.level_string$])])]),$("div").class("user-nav").content([$("icon-button").title("Uploaded Posts").icon("image").content(s.post_upload_count$.convert(st)).link(`/posts?tags=user:${s.name}`,!0),$("icon-button").title("Favorites").icon("heart").content(s.favorite_count$.convert(st)).link(`/posts?tags=ordfav:${s.name}`,!0),$("icon-button").title("Forum Posts").icon("document-text").content(s.forum_post_count$.convert(st)).hide(!0)])]).hide(!1)}).on("logout",()=>{t.clear().hide(!0)})]),$("div").class("nav").content([$("icon-button").icon("log-in-outline").content("Login").link("/login",!0).self(t=>g.events.on("login",()=>t.hide(!0)).on("logout",()=>t.hide(!1))),$("icon-button").icon("log-in-outline").content("Logout").on("dblclick",()=>g.used.logout()).hide(!0).self(t=>g.events.on("login",()=>t.hide(!1)).on("logout",()=>t.hide(!0))),$("icon-button").icon("swap-horizontal").class("switch").content("Switch Booru").on("click",()=>{g.used===vt?g.set(Le):g.set(vt),this.close()})])]),this.$filter.on("click",()=>$.back())]),this.pointers.on("move",t=>{var s;(s=$(":.viewer"))!=null&&s.contains(t.$target)||(t.$target.parent,!(t.type!=="pen"&&t.type!=="touch")&&(t.move_y>4||t.move_y<-4||(t.move_x<=-7&&(t.delete(),this.open()),t.move_x>=7&&(t.delete(),this.close()))))})}open(){return location.hash!=="#drawer"&&$.open(location.href+"#drawer"),this}close(){return location.hash==="#drawer"&&$.back(),this}activate(){this.opened=!0,this.hide(!1),this.$container.animate({transform:["translateX(100%)","translateX(0%)"]},{fill:"both",duration:300,easing:"ease"}),this.$filter.animate({opacity:[0,1]},{fill:"both",duration:300,easing:"ease"})}inactivate(){this.opened=!1,this.$container.animate({transform:["translateX(0%)","translateX(100%)"]},{fill:"both",duration:300,easing:"ease"},()=>this.hide(!this.opened)),this.$filter.animate({opacity:[1,0]},{fill:"both",duration:300,easing:"ease"})}checkURL(t,s){(t==null?void 0:t.hash)==="#drawer"&&this.inactivate(),s.hash==="#drawer"&&this.activate()}}class kt{static get detailPanelEnabled(){var e;return(e=this.localdata)==null?void 0:e.detailPanelEnabled}static set detailPanelEnabled(e){this.localdata={...this.localdata,detailPanelEnabled:e}}static get localdata(){const e=localStorage.getItem("local_settings_data");return e?JSON.parse(e):null}static set localdata(e){localStorage.setItem("local_settings_data",JSON.stringify(e))}}$.registerTagName("ion-icon",Ie);$.registerTagName("icon-button",ke);$.registerTagName("a",Wt);const[vt,Le]=[new g({origin:"https://danbooru.donmai.us",name:"Danbooru"}),new g({origin:"https://safebooru.donmai.us",name:"Safebooru"}),new g({origin:"https://testbooru.donmai.us",name:"Testbooru"})];g.set(g.manager.get(g.storageAPI??"")??vt);const at=new _e().hide(!0),yt=new Me,F=$.state(kt.detailPanelEnabled??!1).on("update",({state$:r})=>kt.detailPanelEnabled=r.value);$(document.body).content([$("nav").content([$("a").class("title").href("/").content([$("h1").class("booru-name").content(g.name$),$("h2").class("app").content([$("span").class("app-name").content("Viewer"),$("span").class("version").content("v0.10.5")])]),$("div").class("searchbar").content(["Search in ",g.name$]).self(r=>O.events.on("stateChange",({beforeURL:e,afterURL:t})=>{e.hash==="#search"&&r.hide(!1),t.hash==="#search"&&r.hide(!0)})).on("click",()=>at.open()),$("div").class("buttons").content([$("ion-icon").class("search").name("search-outline").title("Search").self(r=>O.events.on("stateChange",({beforeURL:e,afterURL:t})=>{e.hash==="#search"&&r.hide(!1),t.hash==="#search"&&r.hide(!0)})).on("click",()=>at.open()),$("ion-icon").class("detail-panel").name("reader-outline").title("Toggle Detail Panel").on("click",()=>F.set(!F.value)),$("a").content($("ion-icon").class("open").name("open-outline").title("Open in Original Site")).href(location.href.replace(location.origin,g.used.origin)).target("_blank"),$("ion-icon").class("copy").name("link-outline").title("Copy Page Link").hide(!1).on("click",(r,e)=>{navigator.clipboard.writeText(`${location.origin}${location.pathname}${location.search}`),e.name("checkmark-outline"),setTimeout(()=>{e.name("link-outline")},2e3)}),$("ion-icon").class("menu").name("menu-outline").title("Menu").hide(!1).self(r=>{g.events.on("login",()=>r.hide(!0)).on("logout",()=>r.hide(!1))}).on("click",()=>$.open(location.href+"#drawer")),$("div").class("account").hide(!0).title("Menu").self(r=>{g.events.on("login",e=>{r.content(e.name$.convert(t=>{var s;return((s=t.at(0))==null?void 0:s.toUpperCase())??""})).hide(!1)}).on("logout",()=>r.hide(!0))}).on("click",()=>yt.open())])]),at,yt,$("router").base("/").map([$("route").id("posts").path(["/","/posts"]).builder(({$route:r,query:e})=>{const{$postGrid:t,$detail:s}=Et(r,e);return[t,s]}),$("route").id("posts").path("/posts?tags").builder(({$route:r,query:e})=>{const{$postGrid:t,$detail:s}=Et(r,e);return[$("header").content([$("h2").content("Posts"),$("div").class("tags").self(i=>{e.tags.split("+").forEach(n=>{i.insert($("a").class("tag").content(decodeURIComponent(n)).href(`posts?tags=${n}`))})})]),$("div").class("no-post").hide(!0).self(i=>{i.on("startLoad",()=>i.hide(!0)),t.on("noPost",()=>i.hide(!1).content("No Posts")).on("post_error",n=>i.hide(!1).content(n))}),t,s]}),we,Ee]).on("beforeSwitch",r=>{r.preventDefault();function s(){var a;$(document.documentElement).css({scrollBehavior:"auto"});const n=$.call(()=>{switch(O.navigationDirection){case z.Forward:return["translateX(2%)","translateX(0%)"];case z.Back:return["translateX(-2%)","translateX(0%)"];case z.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(),$(document.documentElement).css({scrollBehavior:""}),(o=r.nextContent.element)==null||o.removeClass("animated")})}function i(){var a,o;$(document.documentElement).css({scrollBehavior:"auto"});const n=$.call(()=>{switch(O.navigationDirection){case z.Forward:return["translateX(0%)","translateX(-2%)"];case z.Back:return["translateX(0%)","translateX(2%)"];case z.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 l,u;(u=(l=r.previousContent)==null?void 0:l.element)==null||u.removeClass("animated"),s()})}r.previousContent?i():s()})]);O.events.on("stateChange",({beforeURL:r,afterURL:e})=>zt(r,e));zt(void 0,new URL(location.href));function zt(r,e){at.checkURL(r,e),yt.checkURL(r,e)}function Et(r,e){const t=new be(e),s=new Ut({preview:!0,tagsType:"name_only"}).hide(F.convert(n=>!n)).position(r);i(),F.on("update",i),g.events.on("set",()=>s.update(null));function i(){F.value?t.addClass("detail-panel-enabled"):t.removeClass("detail-panel-enabled")}return t.$focus.on("focus",({$focused:n})=>{n.inDOM()&&n instanceof $t&&s.update(n.post)}).on("blur",()=>s.update(null)),{$postGrid:t,$detail:s}}$.keys($(window)).if(r=>{if(!($(r.target)instanceof M))return!0}).keydown(["q","Q"],r=>{r.preventDefault(),O.index!==0&&$.back()}).keydown(["e","E"],r=>{r.preventDefault(),O.forwardIndex!==0&&$.forward()}).keydown("Tab",r=>{r.preventDefault(),F.set(!F.value)}); diff --git a/dist/assets/index-DAA98Qle.js b/dist/assets/index-DAA98Qle.js new file mode 100644 index 0000000..f344e8c --- /dev/null +++ b/dist/assets/index-DAA98Qle.js @@ -0,0 +1 @@ +var Qt=Object.defineProperty;var kt=r=>{throw TypeError(r)};var Jt=(r,e,t)=>e in r?Qt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var l=(r,e,t)=>Jt(r,typeof e!="symbol"?e+"":e,t),It=(r,e,t)=>e.has(r)||kt("Cannot "+t);var I=(r,e,t)=>(It(r,e,"read from private field"),t?t.call(r):e.get(r)),tt=(r,e,t)=>e.has(r)?kt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),et=(r,e,t,s)=>(It(r,e,"write to private field"),s?s.call(r,t):e.set(r,t),t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.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 h of n.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&s(h)}).observe(document,{childList:!0,subtree:!0});function t(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=t(i);fetch(i.href,n)}})();class C{constructor(){l(this,"eventMap",new Map)}fire(e,...t){var s;return(s=this.eventMap.get(e))==null||s.forEach(i=>i(...t)),this}on(e,t){const s=this.eventMap.get(e)??this.eventMap.set(e,new Set).get(e);return s==null||s.add(t),this}off(e,t){var s;return(s=this.eventMap.get(e))==null||s.delete(t),this}once(e,t){const s=(...n)=>{var h;(h=this.eventMap.get(e))==null||h.delete(s),t(...n)},i=this.eventMap.get(e)??this.eventMap.set(e,new Set).get(e);return i==null||i.add(s),this}}class Ct{constructor(){l(this,"domEvents",{});l(this,"events",new C)}on(e,t,s){e=$.orArrayResolve(e);for(const i of e){this.domEvents[i]||(this.domEvents[i]=new Map);const n=h=>{t(h,this)};this.domEvents[i].set(t,n),this.events.on(i,t),this.dom.addEventListener(i,n,s)}return this}off(e,t,s){var n;const i=(n=this.domEvents[e])==null?void 0:n.get(t);return i&&this.dom.removeEventListener(e,i,s),this.events.off(e,t),this}once(e,t,s){const i=n=>{this.dom.removeEventListener(e,i,s),t(n,this)};return this.dom.addEventListener(e,i,s),this.events.once(e,t),this}trigger(e){this.dom.dispatchEvent(new Event(e))}}class Y extends Ct{constructor(){super(...arguments);l(this,"__$property__",{hidden:!1,coordinate:void 0});l(this,"parent")}hide(t,s=!0){return b.fluent(this,arguments,()=>this.__$property__.hidden,()=>{var i;if(t!==void 0)return t instanceof S?(this.__$property__.hidden=t.value,t.use(this,"hide")):this.__$property__.hidden=t,s&&((i=this.parent)==null||i.children.render()),this})}remove(){var t;return(t=this.parent)==null||t.children.remove(this).render(),this}replace(t){var s;return(s=this.parent)==null||s.children.replace(this,t).render(),this}contains(t){return t?t instanceof Y?this.dom.contains(t.dom):t instanceof EventTarget?this.dom.contains(b(t).dom):this.dom.contains(t):!1}coordinate(t){return b.fluent(this,arguments,()=>this.__$property__.coordinate,()=>b.set(this.__$property__,"coordinate",t))}self(t){return b.orArrayResolve(t).forEach(s=>s(this)),this}inDOM(){return document.contains(this.dom)}isElement(){return this instanceof F}get element(){return this instanceof F?this:null}get htmlElement(){return this instanceof K?this:null}}class F extends Y{constructor(t,s){super();l(this,"dom");l(this,"static_classes",new Set);this.dom=this.createDom(t,s),this.dom.$=this,this.setOptions(s)}createDom(t,s){return s!=null&&s.dom?s.dom:t==="svg"?document.createElementNS("http://www.w3.org/2000/svg","svg"):document.createElement((s==null?void 0:s.tagname)??t)}setOptions(t){return this.id(t==null?void 0:t.id),t&&t.class&&this.class(...t.class),this}id(t){return $.fluent(this,arguments,()=>this.dom.id,()=>$.set(this.dom,"id",t))}class(...t){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(...t.detype())})}addClass(...t){return $.fluent(this,arguments,()=>this,()=>{this.dom.classList.add(...t.detype())})}removeClass(...t){return $.fluent(this,arguments,()=>this,()=>{this.dom.classList.remove(...t.detype())})}staticClass(...t){return $.fluent(this,arguments,()=>this.static_classes,()=>{this.removeClass(...this.static_classes),this.static_classes.clear(),this.addStaticClass(...t)})}addStaticClass(...t){return $.fluent(this,arguments,()=>this,()=>{t.detype().forEach(s=>this.static_classes.add(s)),this.addClass(...t)})}removeStaticClass(...t){return $.fluent(this,arguments,()=>this,()=>{t.detype().forEach(s=>this.static_classes.delete(s)),this.removeClass(...t)})}css(t){return $.fluent(this,arguments,()=>this.dom.style,()=>{Object.assign(this.dom.style,t)})}attribute(t,s){return arguments.length?arguments.length===1?t===void 0?null:this.dom.getAttribute(t):arguments.length===2?t?(s===null?this.dom.removeAttribute(t):s!==void 0&&this.dom.setAttribute(t,`${s}`),this):this:this:null}tabIndex(t){return $.fluent(this,arguments,()=>this.dom.tabIndex,()=>$.set(this.dom,"tabIndex",t))}focus(t){return this.dom.focus(t),this}blur(){return this.dom.blur(),this}animate(t,s,i){const n=this.dom.animate(t,s);return i&&(n.onfinish=()=>i(n)),n}getAnimations(t){return this.dom.getAnimations(t)}get dataset(){return this.dom.dataset}domRect(t){const s=this.dom.getBoundingClientRect();if(!t)return s;const i=t instanceof F?t.dom.getBoundingClientRect():t;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 rt extends Y{constructor(t){super();l(this,"dom");this.dom=t,this.dom.$=this}domRect(t){const s={bottom:innerHeight,height:innerHeight,left:0,right:innerWidth,top:0,width:innerWidth,x:0,y:0};if(!t)return s;const i=t instanceof F?t.dom.getBoundingClientRect():t;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(t){return t.$ instanceof rt?t.$:new rt(t)}}const Yt="modulepreload",Zt=function(r){return"/"+r},Et={},te=function(e,t,s){let i=Promise.resolve();if(t&&t.length>0){document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),o=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));i=Promise.allSettled(t.map(a=>{if(a=Zt(a),a in Et)return;Et[a]=!0;const c=a.endsWith(".css"),d=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${a}"]${d}`))return;const u=document.createElement("link");if(u.rel=c?"stylesheet":Yt,c||(u.as="script"),u.crossOrigin="",u.href=a,o&&u.setAttribute("nonce",o),document.head.appendChild(u),c)return new Promise((m,w)=>{u.addEventListener("load",m),u.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${a}`)))})}))}function n(h){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=h,window.dispatchEvent(o),!o.defaultPrevented)throw h}return i.then(h=>{for(const o of h||[])o.status==="rejected"&&n(o.reason);return e().catch(n)})};class ee{constructor(e){l(this,"$container");l(this,"childList",new Set);this.$container=e}add(e,t=-1){if(t===-1||this.childList.size-1===t)this.childList.add(e);else{const s=[...this.childList];s.splice(t,0,e),this.childList.clear(),s.forEach(i=>this.childList.add(i))}e.parent=this.$container}remove(e){return this.childList.has(e)?(this.childList.delete(e),e.parent=void 0,this):this}removeAll(e=!0){this.childList.forEach(t=>this.remove(t)),e&&this.render()}replace(e,t){const s=this.array;return s.splice(s.indexOf(e),1,t),e.remove(),this.childList.clear(),s.forEach(i=>this.childList.add(i)),t.parent=this.$container,this}render(){const[e,t]=[this.array.map(i=>i.dom),Array.from(this.dom.childNodes)],s=[];for(;t.length||e.length;){const[i,n]=[t.at(0),e.at(0)];n?i?n!==i?(n.$.hide()||(this.dom.insertBefore(n,i),s.push(n)),e.shift()):(n.$.hide()&&this.dom.removeChild(n),e.shift(),t.shift()):(n.$.hide()||this.dom.append(n),e.shift()):(i&&!s.includes(i)&&i.remove(),t.shift())}}indexOf(e){return this.array.indexOf(e)}get array(){return[...this.childList.values()]}get dom(){return this.$container.dom}}class S extends C{constructor(t,s){super();l(this,"_value");l(this,"_convert");l(this,"attributes",new Map);l(this,"linkStates",new Set);l(this,"options",{});this.set(t),s&&(this.options=s)}set(t){this._value=t,t instanceof S&&t.linkStates.add(this),this.update(),this.linkStates.forEach(s=>s.update())}static toJSON(t){const s={};for(let[i,n]of Object.entries(t))n instanceof S?n=n.toJSON():n instanceof Object&&S.toJSON(n),Object.assign(s,{[i]:n});return s}update(){for(const[t,s]of this.attributes.entries())for(const i of s)t[i]instanceof Function?this.options.format?t[i](this.options.format(this.value)):t[i](this.value):i in t&&(t[i]=this.value);this.fire("update",{state$:this})}use(t,s){const i=this.attributes.get(t);i?i.add(s):this.attributes.set(t,new Set().add(s))}convert(t){const s=new S(this);return s._convert=t,s}get value(){return this._value instanceof S?this._convert?this._convert(this._value.value):this._value.value:this._value}toString(){return this.options.format?`${this.options.format(this.value)}`:this.value instanceof Object?JSON.stringify(this.toJSON()):`${this.value}`}toJSON(){return this.value instanceof S?this.value.toJSON():this.value instanceof Object?S.toJSON(this.value):this.toString()}}class X extends Y{constructor(t){super();l(this,"dom");this.dom=new Text(t),this.dom.$=this}content(t){return $.fluent(this,arguments,()=>this.dom.textContent,()=>$.set(this.dom,"textContent",t))}}class K extends F{constructor(e,t){super(e,t)}autocapitalize(e){return $.fluent(this,arguments,()=>this.dom.autocapitalize,()=>$.set(this.dom,"autocapitalize",e))}innerText(e){return $.fluent(this,arguments,()=>this.dom.innerText,()=>$.set(this.dom,"innerText",e))}title(e){return $.fluent(this,arguments,()=>this.dom.title,()=>$.set(this.dom,"title",e))}dir(e){return $.fluent(this,arguments,()=>this.dom.dir,()=>$.set(this.dom,"dir",e))}translate(e){return $.fluent(this,arguments,()=>this.dom.translate,()=>$.set(this.dom,"translate",e))}popover(e){return $.fluent(this,arguments,()=>this.dom.popover,()=>$.set(this.dom,"popover",e))}spellcheck(e){return $.fluent(this,arguments,()=>this.dom.spellcheck,()=>$.set(this.dom,"spellcheck",e))}inert(e){return $.fluent(this,arguments,()=>this.dom.inert,()=>$.set(this.dom,"inert",e))}lang(e){return $.fluent(this,arguments,()=>this.dom.lang,()=>$.set(this.dom,"lang",e))}draggable(e){return $.fluent(this,arguments,()=>this.dom.draggable,()=>$.set(this.dom,"draggable",e))}hidden(e){return $.fluent(this,arguments,()=>this.dom.hidden,()=>$.set(this.dom,"hidden",e))}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 K{constructor(t,s){super(t,s);l(this,"children",new ee(this));l(this,"__position_cursor",0)}content(t){return $.fluent(this,arguments,()=>this,()=>{this.children.removeAll(!1),this.insert(t)})}insert(t,s=-1){return $.fluent(this,arguments,()=>this,async()=>{if(t instanceof Function){let i=t(this);i instanceof Promise?t=await i:t=i}else t instanceof Promise&&(t=await t);t=$.orArrayResolve(t),this.__position_cursor=s<0?this.children.array.length+s:s;for(const i of t)if(i!=null){if(i instanceof Array)this.insert(i,this.__position_cursor);else if(typeof i=="string")this.children.add(new X(i),s);else if(i instanceof S){const n=new X(i.toString());i.use(n,"content"),this.children.add(n,s)}else if(i instanceof Promise){const n=(await te(async()=>{const{$Async:o}=await Promise.resolve().then(()=>le);return{$Async:o}},void 0)).$Async,h=new n().await(i);this.children.add(h,s)}else this.children.add(i,s);this.__position_cursor+=1}this.children.render()})}clear(){return this.children.removeAll(),this}$(t){if(t.startsWith("::"))return Array.from(document.querySelectorAll(t.replace(/^::/,""))).map(s=>$(s));if(t.startsWith(":"))return $(document.querySelector(t.replace(/^:/,"")))}get scrollHeight(){return this.dom.scrollHeight}get scrollWidth(){return this.dom.scrollWidth}scrollTop(t){return $.fluent(this,arguments,()=>this.dom.scrollTop,()=>$.set(this.dom,"scrollTop",t))}scrollLeft(t){return $.fluent(this,arguments,()=>this.dom.scrollLeft,()=>$.set(this.dom,"scrollLeft",t))}}class Dt extends f{constructor(e){super("a",e),this.dom.addEventListener("click",t=>{$.anchorHandler&&this.href()&&(t.preventDefault(),$.anchorHandler(this,t))})}href(e){return $.fluent(this,arguments,()=>this.dom.href,()=>$.set(this.dom,"href",e))}target(e){return $.fluent(this,arguments,()=>this.dom.target??void 0,()=>{e&&(this.dom.target=e)})}}class se extends F{constructor(e,t){super(e,t)}}var x;(r=>{function e(o,a,c,d){return a.length?(d(),o):c()}r.fluent=e;function t(o){return o instanceof Array?o:[o]}r.orArrayResolve=t;function s(o,a){return t(a).forEach(c=>{Object.getOwnPropertyNames(c.prototype).forEach(d=>{d!=="constructor"&&Object.defineProperty(o.prototype,d,Object.getOwnPropertyDescriptor(c.prototype,d)||Object.create(null))})}),o}r.mixin=s;function i(o,a,c){c!==void 0&&(o[a]=c)}r.set=i;function n(o){return new S(o)}r.state=n;function h(o){if(o.$)return o.$;if(o.nodeName.toLowerCase()==="body")return new f("body",{dom:o});if(o.nodeName.toLowerCase()==="head")return new f("head",{dom:o});if(o.nodeName.toLowerCase()==="#document")return rt.from(o);if(o instanceof HTMLElement){const a=$.TagNameElementMap[o.tagName.toLowerCase()],c=a?a===f?new a(o.tagName,{dom:o}):new a({dom:o}):new f(o.tagName,{dom:o});if(c instanceof f)for(const d of Array.from(c.dom.childNodes))c.children.add($(d));return c}else if(o instanceof Text){const a=new X(o.textContent??"");return a.dom=o,a}else if(o instanceof SVGElement&&o.tagName.toLowerCase()==="svg")return new se("svg",{dom:o});throw`$NODE.FROM: NOT SUPPORT TARGET ELEMENT TYPE (${o.nodeName})`}r.from=h})(x||(x={}));class A{static create(...e){const t=class{};return Object.getOwnPropertyNames(A.prototype).forEach(s=>{s!=="constructor"&&e.includes(s)&&Object.defineProperty(t.prototype,s,Object.getOwnPropertyDescriptor(A.prototype,s)||Object.create(null))}),t}disabled(e){return $.fluent(this,arguments,()=>this.dom.disabled,()=>$.set(this.dom,"disabled",e))}checkValidity(){return this.dom.checkValidity()}reportValidity(){return this.dom.reportValidity()}formAction(e){return $.fluent(this,arguments,()=>this.dom.formAction,()=>$.set(this.dom,"formAction",e))}formEnctype(e){return $.fluent(this,arguments,()=>this.dom.formEnctype,()=>$.set(this.dom,"formEnctype",e))}formMethod(e){return $.fluent(this,arguments,()=>this.dom.formMethod,()=>$.set(this.dom,"formMethod",e))}formNoValidate(e){return $.fluent(this,arguments,()=>this.dom.formNoValidate,()=>$.set(this.dom,"formNoValidate",e))}formTarget(e){return $.fluent(this,arguments,()=>this.dom.formTarget,()=>$.set(this.dom,"formTarget",e))}autocomplete(e){return $.fluent(this,arguments,()=>this.dom.autocomplete,()=>$.set(this.dom,"autocomplete",e))}name(e){return $.fluent(this,arguments,()=>this.dom.name,()=>$.set(this.dom,"name",e))}maxLength(e){return $.fluent(this,arguments,()=>this.dom.maxLength,()=>$.set(this.dom,"maxLength",e))}minLength(e){return $.fluent(this,arguments,()=>this.dom.minLength,()=>$.set(this.dom,"minLength",e))}required(e){return $.fluent(this,arguments,()=>this.dom.required,()=>$.set(this.dom,"required",e))}label(e){return $.fluent(this,arguments,()=>this.dom.label,()=>$.set(this.dom,"label",e))}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(e){super("button",e)}type(e){return $.fluent(this,arguments,()=>this.dom.type,()=>$.set(this.dom,"type",e))}}x.mixin(_t,A.create("disabled","checkValidity","formAction","formEnctype","formMethod","formNoValidate","formTarget","reportValidity"));class Rt extends f{constructor(e){super("form",e)}action(e){return $.fluent(this,arguments,()=>this.dom.formAction,()=>$.set(this.dom,"formAction",e))}enctype(e){return $.fluent(this,arguments,()=>this.dom.formEnctype,()=>$.set(this.dom,"formEnctype",e))}method(e){return $.fluent(this,arguments,()=>this.dom.formMethod,()=>$.set(this.dom,"formMethod",e))}noValidate(e){return $.fluent(this,arguments,()=>this.dom.formNoValidate,()=>$.set(this.dom,"formNoValidate",e))}acceptCharset(e){return $.fluent(this,arguments,()=>this.dom.acceptCharset,()=>$.set(this.dom,"acceptCharset",e))}target(e){return $.fluent(this,arguments,()=>this.dom.formTarget,()=>$.set(this.dom,"formTarget",e))}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(e=>$(e))}}x.mixin(Rt,A.create("checkValidity","reportValidity","autocomplete"));class M extends K{constructor(e){super("input",e)}value(e){return $.fluent(this,arguments,()=>this.type()==="number"?Number(this.dom.value):this.dom.value,()=>$.set(this.dom,"value",e,t=>{this.on("input",()=>{t.attributes.has(this.dom)!==!1&&(typeof t.value=="string"&&t.set(`${this.value()}`),typeof t.value=="number"&&t.set(Number(this.value())))})}))}type(e){return $.fluent(this,arguments,()=>this.dom.type,()=>$.set(this.dom,"type",e))}capture(e){return $.fluent(this,arguments,()=>this.dom.capture,()=>$.set(this.dom,"capture",e))}alt(e){return $.fluent(this,arguments,()=>this.dom.alt,()=>$.set(this.dom,"alt",e))}height(e){return $.fluent(this,arguments,()=>this.dom.height,()=>$.set(this.dom,"height",e))}width(e){return $.fluent(this,arguments,()=>this.dom.width,()=>$.set(this.dom,"width",e))}defaultValue(e){return $.fluent(this,arguments,()=>this.dom.defaultValue,()=>$.set(this.dom,"defaultValue",e))}dirName(e){return $.fluent(this,arguments,()=>this.dom.dirName,()=>$.set(this.dom,"dirName",e))}pattern(e){return $.fluent(this,arguments,()=>this.dom.pattern,()=>$.set(this.dom,"pattern",e))}placeholder(e){return $.fluent(this,arguments,()=>this.dom.placeholder,()=>$.set(this.dom,"placeholder",e))}readOnly(e){return $.fluent(this,arguments,()=>this.dom.readOnly,()=>$.set(this.dom,"readOnly",e))}selectionDirection(e){return $.fluent(this,arguments,()=>this.dom.selectionDirection,()=>$.set(this.dom,"selectionDirection",e))}selectionEnd(e){return $.fluent(this,arguments,()=>this.dom.selectionEnd,()=>$.set(this.dom,"selectionEnd",e))}selectionStart(e){return $.fluent(this,arguments,()=>this.dom.selectionStart,()=>$.set(this.dom,"selectionStart",e))}size(e){return $.fluent(this,arguments,()=>this.dom.size,()=>$.set(this.dom,"size",e))}src(e){return $.fluent(this,arguments,()=>this.dom.src,()=>$.set(this.dom,"src",e))}inputMode(e){return $.fluent(this,arguments,()=>this.dom.inputMode,()=>$.set(this.dom,"inputMode",e))}valueAsDate(e){return $.fluent(this,arguments,()=>this.dom.valueAsDate,()=>$.set(this.dom,"valueAsDate",e))}valueAsNumber(e){return $.fluent(this,arguments,()=>this.dom.valueAsNumber,()=>$.set(this.dom,"valueAsNumber",e))}webkitdirectory(e){return $.fluent(this,arguments,()=>this.dom.webkitdirectory,()=>$.set(this.dom,"webkitdirectory",e))}select(){return this.dom.select(),this}setCustomValidity(e){return this.dom.setCustomValidity(e),this}setRangeText(e,t,s,i){return typeof t=="number"&&typeof s=="number"&&this.dom.setRangeText(e,t,s,i),this.dom.setRangeText(e),this}setSelectionRange(e,t,s){return this.dom.setSelectionRange(e,t,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(e=>$(e))}}x.mixin(M,A.create("checkValidity","reportValidity","autocomplete","name","form","required","validationMessage","validity","willValidate","formAction","formEnctype","formMethod","formNoValidate","formTarget"));class ie extends M{constructor(e){super(e),this.type("number")}static from(e){return $.mixin(M,this)}stepDown(){return this.dom.stepDown(),this}stepUp(){return this.dom.stepUp(),this}max(e){return $.fluent(this,arguments,()=>this.dom.max===""?null:parseInt(this.dom.min),()=>$.set(this.dom,"max",e==null?void 0:e.toString()))}min(e){return $.fluent(this,arguments,()=>this.dom.min===""?null:parseInt(this.dom.min),()=>$.set(this.dom,"min",e==null?void 0:e.toString()))}step(e){return $.fluent(this,arguments,()=>Number(this.dom.step),()=>$.set(this.dom,"step",e==null?void 0:e.toString()))}}class re extends M{constructor(e){super(e),this.type("radio")}static from(e){return $.mixin(M,this)}checked(e){return $.fluent(this,arguments,()=>this.dom.checked,()=>$.set(this.dom,"checked",e))}defaultChecked(e){return $.fluent(this,arguments,()=>this.dom.defaultChecked,()=>$.set(this.dom,"defaultChecked",e))}}class ne extends M{constructor(e){super(e),this.type("file")}static from(e){return $.mixin(M,this)}multiple(e){return $.fluent(this,arguments,()=>this.dom.multiple,()=>$.set(this.dom,"multiple",e))}accept(...e){return $.fluent(this,arguments,()=>this.dom.accept.split(","),()=>this.dom.accept=e.toString())}}x.mixin(M,[ie,re,ne]);class Nt extends f{constructor(e){super("label",e)}for(e){return $.fluent(this,arguments,()=>this.dom.htmlFor,()=>{$.set(this.dom,"htmlFor",e)})}get control(){return this.dom.control}}x.mixin(Nt,A.create("form"));class oe extends K{constructor(e){super("img",e)}async load(e){return new Promise(t=>{const s=this.once("load",()=>{t(s)});typeof e=="string"?s.src(e):e.then(i=>s.src(i))})}static resize(e,t){return new Promise(s=>{const i=new Image;if(i.addEventListener("load",()=>{const n=document.createElement("canvas"),h=n.getContext("2d");if(!h)throw"$Image.resize: context undefined";const o=i.width/i.height,[a,c,d]=[o>1,o<1,o===1],u=t instanceof Array?t[0]:c?t:t*o,m=t instanceof Array?t[1]:a?t:t/o;n.height=m,n.width=u,h.drawImage(i,0,0,u,m),s(n.toDataURL())},{once:!0}),e instanceof File){const n=new FileReader;n.addEventListener("load",()=>i.src=n.result),n.readAsDataURL(e)}else i.src=e})}alt(e){return $.fluent(this,arguments,()=>this.dom.alt,()=>$.set(this.dom,"alt",e))}crossOrigin(e){return $.fluent(this,arguments,()=>this.dom.crossOrigin,()=>$.set(this.dom,"crossOrigin",e))}decoding(e){return $.fluent(this,arguments,()=>this.dom.decoding,()=>$.set(this.dom,"decoding",e))}height(e){return $.fluent(this,arguments,()=>this.dom.height,()=>$.set(this.dom,"height",e))}isMap(e){return $.fluent(this,arguments,()=>this.dom.isMap,()=>$.set(this.dom,"isMap",e))}loading(e){return $.fluent(this,arguments,()=>this.dom.loading,()=>$.set(this.dom,"loading",e))}referrerPolicy(e){return $.fluent(this,arguments,()=>this.dom.referrerPolicy,()=>$.set(this.dom,"referrerPolicy",e))}sizes(e){return $.fluent(this,arguments,()=>this.dom.sizes,()=>$.set(this.dom,"sizes",e))}src(e){return $.fluent(this,arguments,()=>this.dom.src,()=>$.set(this.dom,"src",e))}srcset(e){return $.fluent(this,arguments,()=>this.dom.srcset,()=>$.set(this.dom,"srcset",e))}useMap(e){return $.fluent(this,arguments,()=>this.dom.useMap,()=>$.set(this.dom,"useMap",e))}width(e){return $.fluent(this,arguments,()=>this.dom.width,()=>$.set(this.dom,"width",e))}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 ae extends f{constructor(e){super("canvas",e)}height(e){return $.fluent(this,arguments,()=>this.dom.height,()=>{$.set(this.dom,"height",e)})}width(e){return $.fluent(this,arguments,()=>this.dom.width,()=>{$.set(this.dom,"width",e)})}captureStream(e){return this.dom.captureStream(e)}getContext(e,t){return this.dom.getContext(e)}toBlob(e,t,s){return this.dom.toBlob(e,t,s),this}toDataURL(e,t){return this.dom.toDataURL(e,t)}transferControlToOffscreen(){return this.dom.transferControlToOffscreen()}}class he extends f{constructor(e){super("dialog",e)}open(e){return $.fluent(this,arguments,()=>this.dom.open,()=>$.set(this.dom,"open",e))}returnValue(e){return $.fluent(this,arguments,()=>this.dom.returnValue,()=>$.set(this.dom,"returnValue",e))}close(){return this.dom.close(),this}show(){return this.dom.show(),this}showModal(){return this.dom.showModal(),this}}class Ht extends f{constructor(e){super("select")}add(e){return this.insert(e),this}item(e){return $(this.dom.item(e))}namedItem(e){return $(this.dom.namedItem(e))}multiple(e){return $.fluent(this,arguments,()=>this.dom.multiple,()=>$.set(this.dom,"multiple",e))}get length(){return this.dom.length}get size(){return this.dom.size}get options(){return Array.from(this.dom.options).map(e=>$(e))}get selectedIndex(){return this.dom.selectedIndex}get selectedOptions(){return Array.from(this.dom.selectedOptions).map(e=>$(e))}value(e){return $.fluent(this,arguments,()=>this.dom.value,()=>$.set(this.dom,"value",e,t=>{this.on("input",()=>{t.attributes.has(this.dom)!==!1&&(typeof t.value=="string"&&t.set(`${this.value()}`),typeof t.value=="number"&&t.set(Number(this.value())))})}))}get labels(){return Array.from(this.dom.labels??[]).map(e=>$(e))}}x.mixin(Ht,A.create("checkValidity","reportValidity","autocomplete","name","form","required","disabled","validationMessage","validity","willValidate"));class Ft extends f{constructor(e){super("option",e)}defaultSelected(e){return $.fluent(this,arguments,()=>this.dom.defaultSelected,()=>$.set(this.dom,"defaultSelected",e))}selected(e){return $.fluent(this,arguments,()=>this.dom.selected,()=>$.set(this.dom,"selected",e))}text(e){return $.fluent(this,arguments,()=>this.dom.text,()=>$.set(this.dom,"text",e))}value(e){return $.fluent(this,arguments,()=>this.dom.value,()=>$.set(this.dom,"value",e))}get form(){return this.dom.form?$(this.dom.form):null}get index(){return this.dom.index}}x.mixin(Ft,A.create("form","disabled","label"));class Vt extends f{constructor(e){super("optgroup",e)}disabled(e){return $.fluent(this,arguments,()=>this.dom.disabled,()=>$.set(this.dom,"disabled",e))}}x.mixin(Vt,A.create("disabled","label"));class Wt extends f{constructor(e){super("textarea",e)}cols(e){return $.fluent(this,arguments,()=>this.dom.cols,()=>$.set(this.dom,"cols",e))}wrap(e){return $.fluent(this,arguments,()=>this.dom.wrap,()=>$.set(this.dom,"wrap",e))}value(e){return $.fluent(this,arguments,()=>this.dom.value,()=>$.set(this.dom,"value",e))}defaultValue(e){return $.fluent(this,arguments,()=>this.dom.defaultValue,()=>$.set(this.dom,"defaultValue",e))}dirName(e){return $.fluent(this,arguments,()=>this.dom.dirName,()=>$.set(this.dom,"dirName",e))}placeholder(e){return $.fluent(this,arguments,()=>this.dom.placeholder,()=>$.set(this.dom,"placeholder",e))}readOnly(e){return $.fluent(this,arguments,()=>this.dom.readOnly,()=>$.set(this.dom,"readOnly",e))}selectionDirection(e){return $.fluent(this,arguments,()=>this.dom.selectionDirection,()=>$.set(this.dom,"selectionDirection",e))}selectionEnd(e){return $.fluent(this,arguments,()=>this.dom.selectionEnd,()=>$.set(this.dom,"selectionEnd",e))}selectionStart(e){return $.fluent(this,arguments,()=>this.dom.selectionStart,()=>$.set(this.dom,"selectionStart",e))}type(e){return $.fluent(this,arguments,()=>this.dom.type,()=>$.set(this.dom,"type",e))}inputMode(e){return $.fluent(this,arguments,()=>this.dom.inputMode,()=>$.set(this.dom,"inputMode",e))}select(){return this.dom.select(),this}setCustomValidity(e){return this.dom.setCustomValidity(e),this}setRangeText(e,t,s,i){return typeof t=="number"&&typeof s=="number"&&this.dom.setRangeText(e,t,s,i),this.dom.setRangeText(e),this}setSelectionRange(e,t,s){return this.dom.setSelectionRange(e,t,s),this}get labels(){return Array.from(this.dom.labels??[]).map(e=>$(e))}}x.mixin(Wt,A.create("checkValidity","reportValidity","autocomplete","name","form","required","disabled","minLength","maxLength","validationMessage","validity","willValidate"));var nt;class jt extends f{constructor(t){super("async",t);tt(this,nt,!1)}await(t){return t instanceof Function?t(this).then(s=>this._loaded(s)):t.then(s=>this._loaded(s)),this}_loaded(t){if(et(this,nt,!0),typeof t=="string")this.replace(new X(t));else if(t instanceof S){const s=new X(t.toString());t.use(s,"content"),this.replace(s)}else t==null?this.replace(new X(String(t))):this.replace(t);this.dom.dispatchEvent(new Event("load"))}get loaded(){return I(this,nt)}}nt=new WeakMap;const le=Object.freeze(Object.defineProperty({__proto__:null,$Async:jt},Symbol.toStringTag,{value:"Module"}));class ce extends K{constructor(e,t){super(e,t)}autoplay(e){return $.fluent(this,arguments,()=>this.dom.autoplay,()=>$.set(this.dom,"autoplay",e))}get buffered(){return this.dom.buffered}controls(e){return $.fluent(this,arguments,()=>this.dom.controls,()=>$.set(this.dom,"controls",e))}crossOrigin(e){return $.fluent(this,arguments,()=>this.dom.crossOrigin,()=>$.set(this.dom,"crossOrigin",e))}get currentSrc(){return this.dom.currentSrc}currentTime(e){return $.fluent(this,arguments,()=>this.dom.currentTime,()=>$.set(this.dom,"currentTime",e))}defaultMuted(e){return $.fluent(this,arguments,()=>this.dom.defaultMuted,()=>$.set(this.dom,"defaultMuted",e))}defaultPlaybackRate(e){return $.fluent(this,arguments,()=>this.dom.defaultPlaybackRate,()=>$.set(this.dom,"defaultPlaybackRate",e))}disableRemotePlayback(e){return $.fluent(this,arguments,()=>this.dom.disableRemotePlayback,()=>$.set(this.dom,"disableRemotePlayback",e))}get duration(){return this.dom.duration}get ended(){return this.dom.ended}get error(){return this.dom.error}loop(e){return $.fluent(this,arguments,()=>this.dom.loop,()=>$.set(this.dom,"loop",e))}mediaKeys(e){return $.fluent(this,arguments,()=>this.dom.mediaKeys,()=>$.set(this.dom,"setMediaKeys",[e]))}muted(e){return $.fluent(this,arguments,()=>this.dom.muted,()=>$.set(this.dom,"muted",e))}get networkState(){return this.dom.networkState}get paused(){return this.dom.paused}playbackRate(e){return $.fluent(this,arguments,()=>this.dom.playbackRate,()=>$.set(this.dom,"playbackRate",e))}get played(){return this.dom.played}preload(e){return $.fluent(this,arguments,()=>this.dom.preload,()=>$.set(this.dom,"preload",e))}preservesPitch(e){return $.fluent(this,arguments,()=>this.dom.preservesPitch,()=>$.set(this.dom,"preservesPitch",e))}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(e){return $.fluent(this,arguments,()=>this.dom.sinkId,()=>$.set(this.dom,"setSinkId",[e]))}src(e){return $.fluent(this,arguments,()=>this.dom.src,()=>$.set(this.dom,"src",e))}srcObject(e){return $.fluent(this,arguments,()=>this.dom.srcObject,()=>$.set(this.dom,"srcObject",e))}get textTracks(){return this.dom.textTracks}volume(e){return $.fluent(this,arguments,()=>this.dom.volume,()=>$.set(this.dom,"volume",e))}addTextTrack(e,t,s){return this.dom.addTextTrack(e,t,s)}canPlayType(e){return this.dom.canPlayType(e)}fastSeek(e){return this.dom.fastSeek(e),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 ue extends ce{constructor(e){super("video",e)}disablePictureInPicture(e){return $.fluent(this,arguments,()=>this.dom.disablePictureInPicture,()=>$.set(this.dom,"disablePictureInPicture",e))}height(e){return $.fluent(this,arguments,()=>this.dom.height,()=>$.set(this.dom,"height",e))}width(e){return $.fluent(this,arguments,()=>this.dom.width,()=>$.set(this.dom,"width",e))}playsInline(e){return $.fluent(this,arguments,()=>this.dom.playsInline,()=>$.set(this.dom,"playsInline",e))}poster(e){return $.fluent(this,arguments,()=>this.dom.poster,()=>$.set(this.dom,"poster",e))}get videoHeight(){return this.dom.videoHeight}get videoWidth(){return this.dom.videoWidth}cancelVideoFrameCallback(e){return this.dom.cancelVideoFrameCallback(e),this}getVideoPlaybackQuality(){return this.dom.getVideoPlaybackQuality()}requestPictureInPicture(){return this.dom.requestPictureInPicture()}requestVideoFrameCallback(e){return this.dom.requestVideoFrameCallback(e)}}const ft=class ft extends Ct{constructor(){super(...arguments);l(this,"dom",window)}};l(ft,"$",new ft);let pt=ft;class de{constructor(e){l(this,"keyMap",new Map);l(this,"conditional");e.on("keydown",t=>{var s;this.conditional&&!this.conditional(t)||(s=this.keyMap.get(t.key))==null||s.keydown.forEach(i=>i(t))}),e.on("keyup",t=>{var s;this.conditional&&!this.conditional(t)||(s=this.keyMap.get(t.key))==null||s.keyup.forEach(i=>i(t))}),e.on("keypress",t=>{var s;this.conditional&&!this.conditional(t)||(s=this.keyMap.get(t.key))==null||s.keypress.forEach(i=>i(t))})}if(e){return this.conditional=e,this}assigns(e,t,s){e=x.orArrayResolve(e),t=x.orArrayResolve(t);for(const i of e){const n=this.keyMap.get(i)??{keydown:new Set,keypress:new Set,keyup:new Set};for(const h of t)n[h].add(s);this.keyMap.set(i,n)}return this}unassign(e,t,s){e=x.orArrayResolve(e),t=t?x.orArrayResolve(t):["keydown","keypress","keyup"];for(const i of e){const n=this.keyMap.get(i)??{keydown:new Set,keypress:new Set,keyup:new Set};for(const h of t)s?n[h].delete(s):n[h].clear();this.keyMap.set(i,n)}return this}keydown(e,t){return this.assigns(e,"keydown",t),this}keyup(e,t){return this.assigns(e,"keyup",t),this}keypress(e,t){return this.assigns(e,"keypress",t),this}self(e){return e(this),this}}function b(r){if(typeof r>"u"||r===null||r instanceof Y)return r;if(typeof r=="string"){if(r.startsWith("::"))return Array.from(document.querySelectorAll(r.replace(/^::/,""))).map(e=>b(e));if(r.startsWith(":"))return b(document.querySelector(r.replace(/^:/,"")));if(r in b.TagNameElementMap){const e=b.TagNameElementMap[r];return e===K?new K(r):e===f?new f(r):new e}else return new f(r)}if(r instanceof Node)return r.$?r.$:x.from(r);if(r instanceof Window)return pt.$;throw`$: NOT SUPPORT TARGET ELEMENT TYPE ('${r}')`}(r=>{r.anchorHandler=null,r.TagNameElementMap={html:f,head:f,document:rt,body:f,a:Dt,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:M,label:Nt,button:_t,form:Rt,img:oe,dialog:he,canvas:ae,select:Ht,option:Ft,optgroup:Vt,textarea:Wt,video:ue,async:jt};function e(p,y,_,P){return y.length?(P(),p):_()}r.fluent=e;function t(p,y,_,P){if(_!==void 0){if(_ instanceof S){_.use(p,y),p[y]instanceof Function?p[y](..._.value):p[y]=_.value,P&&P(_);return}p[y]instanceof Function?p[y](..._):p[y]=_}}r.set=t;function s(p,y){return new S(p,y)}r.state=s;async function i(p,y){return new Promise(_=>{const P=new FileReader;P.onload=j=>{const L=r("img");if(L.once("load",ot=>{const U=r("canvas"),G=U.getContext("2d"),k=L.height()/L.width(),[q,Z]=[k>1?y/k:y,k>1?y:y*k];U.height(Z).width(q),G==null||G.drawImage(L.dom,0,0,q,Z),_(U.toDataURL(p.type))}),!j.target)throw"$.resize(): e.target is null";L.src(j.target.result)},P.readAsDataURL(p)})}r.resize=i;function n(p){const y=new DOMParser().parseFromString(p,"text/html").body;return Array.from(y.children).map(_=>r(_))}r.html=n;function h(p,y){return Object.assign(r.TagNameElementMap,{[p]:y}),r.TagNameElementMap}r.registerTagName=h;function o(p){return p instanceof Array?p:[p]}r.orArrayResolve=o;function a(p,y){return x.mixin(p,y)}r.mixin=a;function c(p=1){return parseInt(getComputedStyle(document.documentElement).fontSize)*p}r.rem=c;function d(p){return p()}r.call=d;function u(){return new C}r.events=u;function m(p){return new pe(p)}r.pointers=m;function w(p){return new de(p)}r.keys=w;function O(){return new fe}r.focus=O})(b||(b={}));globalThis.$=b;class fe extends C{constructor(){super();l(this,"layerMap",new Map);l(this,"currentLayer");l(this,"historyList",[])}layer(t){const s=this.layerMap.get(t)??new me(t).on("blur",i=>this.fire("blur",i)).on("focus",i=>this.fire("focus",i));return this.layerMap.set(s.id,s),s}next(){return this.select(0)}prev(){return this.select(1)}up(){return this.select(2)}down(){return this.select(3)}right(){return this.select(4)}left(){return this.select(5)}blur(){var t;return(t=this.currentLayer)==null||t.blur(),this}select(t){var h;if(this.currentLayer=this.currentLayer??[...this.layerMap.values()].at(0),!this.currentLayer)return this;const s=this.currentLayer.currentFocus,i=this.currentLayer.elementSet.array;if(!s){const o=this.currentLayer.beforeBlur??i.at(0);return o?(this.currentLayer.focus(o),this):this}const n=i.indexOf(s);switch(t){case 0:case 1:{let o=t===0?n+1:n-1;(o===i.length&&this.currentLayer.loop()||o===-1&&!this.currentLayer.loop())&&(o=0);const a=i.at(o);if(!a)break;this.currentLayer.focus(a);break}case 3:case 5:case 4:case 2:{const o=s.coordinate();if(!o)break;const a=$.call(()=>{switch(t){case 2:return{y:o.y,x:o.x/2};case 3:return{y:o.y+o.height,x:o.x/2};case 5:return{y:o.y/2,x:o.x};case 4:return{y:o.y/2,x:o.x+o.width}}}),d=(h=i.map(u=>{if(u===s)return;const m=u.coordinate();if(!m)return;const w=$.call(()=>{switch(t){case 2:return{y:m.y+m.height,x:m.x/2};case 3:return{y:m.y,x:m.x/2};case 5:return{y:m.y/2,x:m.x+m.width};case 4:return{y:m.y/2,x:m.x}}});return{$ele:u,elePosition:m,distance:Math.sqrt((w.x-a.x)**2+(w.y-a.y)**2)}}).detype(void 0).filter(({elePosition:u})=>{switch(t){case 2:if(u.y+u.height>=o.y)return!1;break;case 3:if(u.y<=o.y+o.height)return!1;break;case 5:if(u.x+u.width>=o.x)return!1;break;case 4:if(u.x<=o.x+o.width)return!1;break}return!0}).sort((u,m)=>u.distance-m.distance).at(0))==null?void 0:h.$ele;if(!d)break;this.currentLayer.focus(d)}}return this}}class me extends C{constructor(t){super();l(this,"id");l(this,"elementSet",new Set);l(this,"entrySet",new Set);l(this,"beforeBlur");l(this,"currentFocus");l(this,"focusHandler",(t,s)=>this.focus(s,!0));l(this,"blurHandler",(t,s)=>this.blur(s));l(this,"__$property__",{loop:!0,scrollThreshold:0});this.id=t,this.add=this.add.bind(this),this.entry=this.entry.bind(this)}add(t){return $.orArrayResolve(t).forEach(s=>{this.elementSet.has(s)||(this.elementSet.add(s),s.tabIndex(0))}),this}remove(t){return this.currentFocus===t&&this.blur(),this.beforeBlur===t&&(this.beforeBlur=void 0),this.elementSet.delete(t),this}entry(t){return $.orArrayResolve(t).forEach(this.entrySet.add.bind(this.entrySet)),this}focus(t,s=!1){if(!t)return this;t.hide(!1);const{scrollTop:i,scrollLeft:n}=document.documentElement,h=$.call(()=>{const c=t.domRect();return{left:c.left+n,top:c.top+i,right:c.right+n,bottom:c.bottom+i,height:c.height,width:c.width}}),{scrollThreshold:o}=this.__$property__,a=this.currentFocus;return this.blur(),this.currentFocus=t,(i>h.top-o||i>h.bottom+o)&&document.documentElement.scrollTo({left:h.left-o,top:h.top-o}),(i+innerHeightthis.remove(t)),this}loop(t){return $.fluent(this,arguments,()=>this.__$property__.loop,()=>$.set(this.__$property__,"loop",t))}scrollThreshold(t){return $.fluent(this,arguments,()=>this.__$property__.scrollThreshold,()=>$.set(this.__$property__,"scrollThreshold",t))}}class pe extends C{constructor(t){super();l(this,"$node");l(this,"map",new Map);this.$node=t,this.$node.on("pointerdown",s=>this.down(s)),this.$node.on("pointerup",s=>this.up(s)),this.$node.on("pointermove",s=>this.move(s)),this.$node.on("pointercancel",s=>this.cancel(s))}down(t){const s=new ge(this,this.toData(t),$(t.target));this.map.set(s.id,s),this.fire("down",s,t)}up(t){const s=this.map.get(t.pointerId);s&&(this.map.delete(t.pointerId),this.fire("up",s,t))}move(t){const s=this.map.get(t.pointerId);s&&(this.map.set(s.id,s),s.update(this.toData(t)),this.fire("move",s,t))}cancel(t){const s=this.map.get(t.pointerId);s&&(s.update(this.toData(t)),this.map.delete(s.id),this.fire("cancel",s,t))}toData(t){return{id:t.pointerId,type:t.pointerType,width:t.width,height:t.height,x:t.x,y:t.y,movement_x:t.movementX,movement_y:t.movementY}}}class ge{constructor(e,t,s){l(this,"initial_x");l(this,"initial_y");l(this,"$target");l(this,"manager");Object.assign(this,t),this.manager=e,this.$target=s,this.initial_x=t.x,this.initial_y=t.y}get move_x(){return this.x-this.initial_x}get move_y(){return this.y-this.initial_y}update(e){return Object.assign(this,e),this}delete(){return this.manager.map.delete(this.id),this}}Array.prototype.detype=function(...r){return this.filter(e=>{if(r.length)for(const t of r)return typeof e!=typeof t;else return e!==void 0})};Object.defineProperties(Set.prototype,{array:{get:function(){return Array.from(this)}}});Set.prototype.sort=function(r){return this.array.sort(r)};class Ut extends f{constructor(t){super("layout",t);l(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()},{passive:!0}),new IntersectionObserver(s=>{this.inDOM()&&this.render()}).observe(this.dom)}type(t){return $.fluent(this,arguments,()=>this._property.TYPE,()=>$.set(this._property,"TYPE",t))}maxHeight(t){return $.fluent(this,arguments,()=>this._property.ROW_MAX_HEIGHT,()=>$.set(this._property,"ROW_MAX_HEIGHT",t))}column(t){return $.fluent(this,arguments,()=>this._property.COLUNM,()=>$.set(this._property,"COLUNM",t))}gap(t){return $.fluent(this,arguments,()=>this._property.GAP,()=>$.set(this._property,"GAP",t))}root(t){return $.fluent(this,arguments,()=>this._property.ROOT??$(document),()=>$.set(this._property,"ROOT",t))}get COL_WIDTH(){return(this.offsetWidth-this._property.GAP*(this._property.COLUNM-1))/this._property.COLUNM}justifiedCompute(){const t=[],s=this.offsetWidth;for(const i of this.children.array){const n=$(i);if(!(n instanceof F))continue;const h=n.attribute("layout-item-ratio"),o=h?parseFloat(h):n.dom.offsetWidth/n.dom.offsetHeight,a={$node:n,ratio:o};let c=t.at(-1);(!c||c.heightd+=w.ratio);const u=d+o,m=(s-this._property.GAP*c.items.length)/u;c.items.push(a),c.ratio=u,c.height=m}return t}waterfallCompute(){const t=[],s=this.COL_WIDTH,i=()=>{if(t.lengthn.height-h.height)[0]};for(const n of this.children.array){const h=$(n);if(!(h instanceof F))continue;const o=h.attribute("layout-item-ratio"),a=o?parseFloat(o):h.dom.offsetWidth/h.dom.offsetHeight,c={$node:h,ratio:a},d=i();let u=0;d.items.forEach(O=>u+=O.ratio);const m=s/(d.height+s/a),w=s/m;d.items.push(c),d.ratio=m,d.height=w}return t}render(){if(!this.inDOM())return this;if(this.events.fire("beforeRender"),this._property.ITEM_PROPERTIES.clear(),this._property.TYPE==="justified"){const t=this.justifiedCompute();let s=0;for(const i of t){let n=0;i.height>this._property.ROW_MAX_HEIGHT&&(i.height=this._property.ROW_MAX_HEIGHT);for(const h of i.items){const o=h.ratio*i.height;h.$node.css({position:"absolute",height:`${i.height}px`,width:`${o}px`,top:`${s}px`,left:`${n}px`}),h.$node.attribute("layout-item-ratio",h.ratio),this._property.ITEM_PROPERTIES.set(h.$node,{height:i.height,width:o,top:s,left:n,ratio:h.ratio,$node:h.$node}),h.$node.coordinate({x:n,y:s,height:i.height,width:o}),n+=i.height*h.ratio+this._property.GAP}s+=i.height+this._property.GAP}this.css({height:`${s}px`})}else if(this._property.TYPE="waterfall"){const t=this.waterfallCompute(),s=this.COL_WIDTH;let i=0;for(const n of t){let h=0;for(const o of n.items){const a=s/o.ratio;o.$node.css({position:"absolute",height:`${a}px`,width:`${s}px`,top:`${h}px`,left:`${i}px`}),o.$node.attribute("layout-item-ratio",o.ratio),this._property.ITEM_PROPERTIES.set(o.$node,{height:a,width:s,top:h,left:i,ratio:o.ratio,$node:o.$node}),o.$node.coordinate({x:i,y:h,height:a,width:s}),h+=a+this._property.GAP}i+=s+this._property.GAP}if(t.length){const n=t.sort((h,o)=>o.height-h.height)[0];this.css({height:`${n.height+n.items.length*this._property.GAP}px`})}else this.css({height:""})}return this.scrollCompute(),this.events.fire("afterRender"),this}scrollCompute(){if(this.inDOM()===!1)return;const t=document.documentElement.scrollTop-this.dom.offsetTop;this._property.ITEM_PROPERTIES.forEach((s,i)=>{const n=s.top,h=s.top+s.height;i.attribute("focus")===""||document.activeElement===i.dom||(h>t&&n{this.contentId=t,this.events.fire("rendered",{$view:this,previousContent:i,nextContent:s})},o=()=>{this.events.fire("afterSwitch",{$view:this,previousId:t})};return this.events.fire("beforeSwitch",{$view:this,preventDefault:()=>n=!0,targetId:t,previousContent:i,nextContent:s,switched:o,rendered:h}),n||(this.content(s),h(),o()),this}get currentContent(){if(this.contentId)return this.viewCache.get(this.contentId)}}$.registerTagName("view",Gt);var V;const v=class v extends Gt{constructor(t){super({tagname:"router",...t});tt(this,V,"");l(this,"routes",new Map);v.routers.add(this)}base(t){return $.fluent(this,arguments,()=>I(this,V),()=>{et(this,V,t??I(this,V))})}map(t){t=$.orArrayResolve(t);for(const s of t)s instanceof Array?this.map(s):this.routes.set(s.path(),s);return this.resolve(),this}resolve(){return new Promise(t=>{var O;if(!location.pathname.startsWith(I(this,V)))return t(2);const s=location.pathname.replace(I(this,V),"/").replace("//","/"),i=s.split("/").map(p=>`/${p}`),n=location.search,h=new Map(n.replace("?","").split("&").map(p=>p.split("="))),a=(()=>{const p=[];for(const[y,_]of this.routes){const P=$.orArrayResolve(y);for(const j of P){let L=0,ot={},U={};const G=j.split("/").map(k=>`/${k}`);if(!(i.length{const Ot=h.get(St);Ot!==void 0&&L++,Object.assign(U,{[St]:Ot})}),q.startsWith("/:")){L++,Object.assign(ot,{[q.replace("/:","")]:i[k].replace("/","")});continue}else if(j.startsWith("#")&&j===location.hash){L++;continue}else if(q===i[k]){L++;continue}else break}p.push({deep:L,$route:_,params:ot,query:U,routePath:j,pathId:_.static()?Object.keys(U).length!==0?s+n:Object.keys(ot).length!==0?s:P[0]:P[0]})}}}return p.sort((y,_)=>_.deep-y.deep).at(0)})();if(!a)return t(1);const{$route:c,params:d,pathId:u,query:m}=a;if(c.static()&&u===this.contentId)return t(0);this.events.once("rendered",({nextContent:p,previousContent:y})=>{y==null||y.events.fire("afterShift",{$route:y}),p.events.fire("rendered",{$route:p,params:d,query:m}),t(0)});const w=this.viewCache.get(u)??c.build({params:d,query:m});this.viewCache.has(u)||this.setView(u,w),this.events.once("beforeSwitch",()=>{var p;w.events.fire("beforeShift",{$route:w}),(p=this.currentContent)==null||p.events.fire("beforeShift",{$route:this.currentContent})}),this.events.once("afterSwitch",()=>w.events.fire("afterShift",{$route:w})),(O=this.currentContent)==null||O.events.fire("close",{$route:this.currentContent}),w.events.fire("open",{$route:w,params:d,query:m}),this.switchView(u)})}static init(){if(!history.state||!("index"in history.state)){const t={index:v.index};history.replaceState(t,"")}else v.index=history.state.index;return v.navigationDirection=0,v.resolve(),window.addEventListener("popstate",()=>v.popstate()),window.addEventListener("scroll",()=>{this.setScrollHistory(this.index,location.href,document.documentElement.scrollTop)},{passive:!0}),history.scrollRestoration="manual",this}static open(t,s){return t===void 0?this:(t=this.urlResolver(t),t.href===this.url.href?this:t.origin!==this.url.origin?(window.open(t,s),this):(v.clearForwardScrollHistory(),v.forwardIndex=0,v.index++,history.pushState(v.historyState,"",t),v.stateChange(0),v.resolve(),this))}static back(){return history.back(),this}static forward(){return this.forwardIndex===0?this:(history.forward(),this)}static replace(t){return t===void 0?this:(t=this.urlResolver(t),history.replaceState(v.historyState,"",t),this.stateChange(2),this.setScrollHistory(this.index,location.href,0),v.resolve(),this)}static urlResolver(t){return t instanceof URL?t:(t.startsWith("/")&&(t=`${location.origin}${t}`),t.startsWith("#")&&(t=`${location.origin}${location.pathname}${t}`),new URL(t))}static popstate(){const t=history.state.index>v.index?0:history.state.indext.resolve())),this.scrollRestoration(),this.setScrollHistory(this.index,location.href,document.documentElement.scrollTop)}static get historyState(){return{index:v.index}}static stateChange(t){const s=this.url,i=new URL(location.href);this.url=i,v.events.fire("stateChange",{beforeURL:s,afterURL:i,direction:t}),v.navigationDirection=t}static setScrollHistory(t,s,i){const n=this.getScrollHistory();if(!n)return sessionStorage.setItem(this.scrollHistoryKey,JSON.stringify({[t]:{url:s,value:i}}));n[t]={url:s,value:i},sessionStorage.setItem(this.scrollHistoryKey,JSON.stringify(n))}static getScrollHistory(){const t=sessionStorage.getItem(this.scrollHistoryKey);if(t)return JSON.parse(t)}static clearForwardScrollHistory(){const t=this.getScrollHistory();if(t)for(const s in t)Number(s)>this.index&&delete t[s],sessionStorage.setItem(this.scrollHistoryKey,JSON.stringify(t))}static scrollRestoration(){const t=this.getScrollHistory();if(t&&t[this.index])document.documentElement.scrollTop=t[this.index].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}};V=new WeakMap,l(v,"routers",new Set),l(v,"events",new C),l(v,"navigationDirection"),l(v,"index",0),l(v,"forwardIndex",0),l(v,"url",new URL(location.href)),l(v,"scrollHistoryKey","$ROUTER_SCROLL_HISTORY");let T=v;var z=(r=>(r[r.Forward=0]="Forward",r[r.Back=1]="Back",r[r.Replace=2]="Replace",r))(z||{});T.init();var J,W;const Tt=class Tt extends f{constructor(t){super("route",t);tt(this,J,"");tt(this,W);l(this,"rendered",!1);this.__$property__.static=!0}path(t){return $.fluent(this,arguments,()=>I(this,J),()=>et(this,J,t??I(this,J)))}static(t){return $.fluent(this,arguments,()=>this.__$property__.static,()=>$.set(this.__$property__,"static",t))}builder(t){return et(this,W,t),this}render(t){return I(this,W)&&this.content(I(this,W).call(this,{$route:this,params:t.params,query:t.query})),this.rendered=!0,this}build(t){return new Tt({dom:this.dom.cloneNode()}).self(s=>{I(this,W)&&s.builder(I(this,W)).render({params:t.params,query:t.query})})}};J=new WeakMap,W=new WeakMap;let gt=Tt;class zt extends Dt{constructor(e){super(e),Object.assign(this.__$property__,{preventDefault:!1}),this.on("click",t=>{t.preventDefault(),this.__$property__.preventDefault||$.open(this.href(),this.target())})}preventDefault(e){return $.fluent(this,arguments,()=>this.__$property__.preventDefault,()=>$.set(this.__$property__,"preventDefault",e))}}$.registerTagName("router",T);$.registerTagName("route",gt);$.registerTagName("router-a",zt);Object.assign($,{open(r,e){return T.open(r,e)},replace(r){return T.replace(r)},back(){return T.back()},forward(){return T.forward()}});class $e{constructor(e,t){l(this,"booru");Object.assign(this,t),this.booru=e}static async fetchUserFavorites(e,t,s,i=100,n){return(await e.fetch(`/favorites.json?${s}&${`search[user_id]=${t.id}`}&limit=${i}&page=${n}`)).map(o=>(t.favorites.add(o.post_id),o.post_id))}update(e){return Object.assign(this,e),this}}class $t{constructor(e,t,s=!0){l(this,"name$",$.state("..."));l(this,"post_upload_count$",$.state(0));l(this,"level$",$.state(10));l(this,"level_string$",$.state("..."));l(this,"booru");l(this,"favorites",new Set);this.booru=e,Object.assign(this,t),s&&this.update$()}static async fetch(e,t){var n;let s;if(typeof t=="string"){const h=(await e.fetch(`/users.json?search[name]=${t}`)).at(0);if(!h)throw"User Not Found";return s=h}else s=await e.fetch(`/users/${t}.json`);const i=((n=e.users.get(s.id))==null?void 0:n.update(s))??new this(e,s);return e.users.set(i.id,i),i}static async fetchMultiple(e,t,s=200){let i="";if(t)for(const[o,a]of Object.entries(t))if(a instanceof Array)i+=`&search[${o}]=${a}`;else if(a instanceof Object)for(const[c,d]of Object.entries(a))i+=`&search[${o}${c}]=${d}`;else i+=`&search[${o}]=${a}`;return(await e.fetch(`/users.json?limit=${s}${i}`)).map(o=>{const a=new this(e,o);return e.users.set(a.id,a),a})}update(e){return Object.assign(this,e),this.update$(),this}update$(){this.name$.set(this.name),this.post_upload_count$.set(this.post_upload_count),this.level$.set(this.level),this.level_string$.set(this.level_string)}get booruURL(){return`${this.booru.origin}/users/${this.id}`}get url(){return`/users/${this.id}`}}const mt=class mt extends $t{constructor(t,s,i){super(t,i,!1);l(this,"apiKey");l(this,"favorite_count$",$.state(0));l(this,"forum_post_count$",$.state(0));this.apiKey=s,this.update$()}update$(){var t,s;super.update$(),(t=this.forum_post_count$)==null||t.set(this.forum_post_count),(s=this.favorite_count$)==null||s.set(this.favorite_count)}async init(){await this.fetchFavorites()}async fetchFavorites(){const t=Array.from(this.favorites.keys()).at(-1),s=await $e.fetchUserFavorites(this.booru,this,"",1e3,t?`b${t}`:1);return mt.events.fire("favoriteUpdate",this),s.length>=1e3&&this.fetchFavorites(),s}static get storageUserData(){const t=localStorage.getItem("user_data");return t?JSON.parse(t):null}static set storageUserData(t){localStorage.setItem("user_data",JSON.stringify(t))}};l(mt,"events",new C);let N=mt;const R=class R{constructor(e){l(this,"user");l(this,"posts",new Map);l(this,"tags",new Map);l(this,"users",new Map);l(this,"favorites",new Map);Object.assign(this,e),this.origin.endsWith("/")&&(this.origin=this.origin.slice(0,-1)),R.manager.set(this.name,this)}static set(e){this.used=e,this.name$.set(e.name),this.storageAPI=e.name;const t=N.storageUserData;return t&&e.login(t.username,t.apiKey),this.events.fire("set"),this}static get storageAPI(){return localStorage.getItem("booru_api")}static set storageAPI(e){e?localStorage.setItem("booru_api",e):localStorage.removeItem("booru_api")}async fetch(e,t="GET"){const s=this.user?`${e.includes("?")?"&":"?"}login=${this.user.name}&api_key=${this.user.apiKey}`:"",i=await fetch(`${this.origin}${e}${s}`,{method:t}).then(n=>n.json());if(i.success===!1)throw i.message;return i}async login(e,t){const s=await this.fetch(`/profile.json?login=${e}&api_key=${t}`);return this.user=new N(this,t,s),this.user.init(),R.events.fire("login",this.user),this.user}logout(){return this.user=void 0,N.storageUserData=null,R.events.fire("logout"),this}};l(R,"used"),l(R,"events",new C),l(R,"name$",$.state(R.name)),l(R,"manager",new Map);let g=R;class Mt{constructor(e,t){l(this,"post_count$",$.state(0));l(this,"name$",$.state(""));l(this,"booru");this.booru=e,Object.assign(this,t),this.$update()}static async fetch(e,t){var n;const s=await e.fetch(`/tags/${t}.json`),i=((n=e.tags.get(s.id))==null?void 0:n.update(s))??new this(e,s);return e.tags.set(i.id,i),i}static async fetchMultiple(e,t,s=1e3){let i="";if(t)for(const[o,a]of Object.entries(t))if(a instanceof Array)i+=`&search[${o}]=${a}`;else if(a instanceof Object)for(const[c,d]of Object.entries(a))i+=`&search[${o}${c}]=${d}`;else i+=`&search[${o}]=${a}`;return(await e.fetch(`/tags.json?limit=${s}${i}`)).map(o=>{var c;const a=((c=e.tags.get(o.id))==null?void 0:c.update(o))??new this(e,o);return e.tags.set(a.id,a),a})}static get(e,t){return[...e.tags.values()].find(s=>s.name===t)}update(e){return Object.assign(this,e),this.$update(),this}$update(){this.post_count$.set(this.post_count),this.name$.set(this.name)}}var B=(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))(B||{});const xt=1e3,lt=xt*60,ct=lt*60,ut=ct*24,ve=ut*7,at=new Intl.RelativeTimeFormat("en",{style:"long"});function vt(r){r=Math.floor(r);const e=r/xt,t=r/lt,s=r/ct,i=r/ut,n=r%1e3,h=Math.floor(r%6e4/1e3),o=Math.floor(r%36e5/6e4),a=Math.floor(r%(36e5*24)/36e5),c=h.toString().padStart(2,"0"),d=o.toString().padStart(2,"0"),u=a.toString().padStart(2,"0");return{seconds:e,minutes:t,hours:s,days:i,mil:n,s:h,min:o,h:a,ss:c,mm:d,hh:u}}function ye(r,e=Date.now()){const t=r-e,s=Math.abs(t);if(sthis.update$()),this}static async fetchMultiple(t,s,i=20,n){let h="";if(s){if(typeof s=="string")h=s;else for(const[u,m]of Object.entries(s))if(m!==void 0){if(u==="tags"){h+=`${m}`;continue}h.at(-1)!=="="&&(h+=" "),h+=`${u}:${m}`}}const o=await t.fetch(`/posts.json?limit=${i}&tags=${h}${n?`&page=${n}`:""}&_method=get`);if(!(o instanceof Array))return[];const a=new Set,c=o.map(u=>{var w;const m=((w=t.posts.get(u.id))==null?void 0:w.update(u))??new this(t,u.id,u);return t.posts.set(m.id,m),m.tag_string.split(" ").forEach(O=>a.add(O)),m});if(!c.length)return c;const d=[...new Set(o.map(u=>[u.approver_id,u.uploader_id].detype(null)).flat())];return $t.fetchMultiple(t,{id:d}).then(()=>c.forEach(u=>u.update$())),c}update$(){var t,s,i,n;this.uploader$.set(((t=this.uploader)==null?void 0:t.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(ye(+new Date(this.created_at))),this.favcount$.set(this.fav_count),this.score$.set(this.score),this.file_size$.set(we(this.file_size)),this.file_ext$.set(this.file_ext),this.file_url$.set(this.file_url),this.source$.set(this.source),this.dimension$.set(`${this.image_width}x${this.image_height}`),this.booruUrl$.set(`${this.booruUrl}`),this.isUgoria&&this.webm_url$.set(this.large_file_url),this.createdDate=new Date(this.created_at),this.fire("update")}update(t){return Object.assign(this,t),this.update$(),this}async fetchTags(){await this.ready;const t=this.tag_string.split(" ").filter(s=>!Mt.get(this.booru,s));return t.length?(await Mt.fetchMultiple(this.booru,{name:{_space:t.toString().replaceAll(","," ")}}),this):this}async createFavorite(){if(!this.booru.user)return;const t=await this.booru.fetch(`/favorites.json?post_id=${this.id}`,"POST");return this.update(t),this.booru.user.favorites.add(t.id),N.events.fire("favoriteUpdate",this.booru.user),t.id}async deleteFavorite(){!this.booru.user||await fetch(`/api/favorites/${this.id}?login=${this.booru.user.name}&api_key=${this.booru.user.apiKey}&origin=${this.booru.origin}`,{method:"DELETE"}).then(s=>s.json())===!1||(this.fav_count--,this.favcount$.set(this.fav_count),this.booru.user.favorites.delete(this.id),N.events.fire("favoriteUpdate",this.booru.user))}get pathname(){return`/posts/${this.id}`}get uploader(){return this.booru.users.get(this.uploader_id)}get approver(){return this.approver_id?this.booru.users.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 t=this.tag_string.split(" ");return[...this.booru.tags.values()].filter(s=>t.includes(s.name))}get previewURL(){var t,s,i;return((i=(s=(t=this.media_asset)==null?void 0:t.variants)==null?void 0:s.find(n=>n.file_ext==="webp"))==null?void 0:i.url)??this.large_file_url}get booruUrl(){return`${this.booru.origin}/posts/${this.id}`}get url(){return`https://danbooru.defaultkavy.com/posts/${this.id}`}get isFileSource(){return this.source.startsWith("file://")}get isLargeFile(){return this.file_size>5e6}}class Bt{constructor(e){Object.assign(this,e)}static async fetch(e,t){const s=await e.fetch(`/artist_commentaries/${t}.json`);return new this(s)}static async fetchMultiple(e,t,s=200){let i="";if(t)for(const[o,a]of Object.entries(t))if(a instanceof Array)i+=`&search[${o}]=${a}`;else if(a instanceof Object)for(const[c,d]of Object.entries(a))i+=`&search[${o}${c}]=${d}`;else i+=`&search[${o}]=${a}`;return(await e.fetch(`/artist_commentaries.json?limit=${s}${i}`)).map(o=>{const a=new this(o);return this.manager.set(a.id,a),a})}}l(Bt,"manager",new Map);class _e extends f{constructor(t,s,i){super("video-controller");l(this,"$video");l(this,"$viewer");l(this,"duration$",$.state("00:00"));l(this,"post");this.$video=t,this.$viewer=s,this.post=i,this.build()}build(){const t=$.events();this.$video.on("timeupdate",()=>this.durationUpdate()),this.content([$("div").class("video-details").content([$("div").class("left").content([$("ion-icon").class("play").title("Play").name("play").self(s=>{this.$video.on("play",()=>s.name("pause")).on("pause",()=>s.name("play")),s.on("click",()=>this.$video.isPlaying?this.$video.pause():this.$video.play())}),$("div").class("duration").content([$("span").class("current-time").content(this.duration$),$("span").content("/"),$("span").class("total-time").content("00:00").self(s=>{this.$video.on("loadeddata",()=>{const i=vt(this.$video.duration*1e3);s.content(Number(i.hh)>0?`${i.hh}:${i.mm}:${i.ss}`:`${i.mm}:${i.ss}`)})})])]),$("div").class("right").content([$("ion-icon").class("volume").title("Volume").name("volume-high").disable(!this.post.hasSound).self(s=>{const i=()=>{this.$video.muted()?s.name("volume-mute"):s.name("volume-high")};s.on("click",()=>{this.$video.muted(!this.$video.muted()),i()})}),$("ion-icon").class("full-screen").title("Full-Screen").name("scan").self(s=>{s.on("click",()=>{document.fullscreenElement?document.exitFullscreen():this.$viewer.dom.requestFullscreen()})})])]),$("div").class("progressbar-container").content([$("div").class("progressbar").content([$("div").class("progress").self(s=>{this.$video.on("timeupdate",i=>{s.css({width:`${this.$video.currentTime()/this.$video.duration*100}%`})}),t.on("progressChange",i=>{s.css({width:`${i*100}%`})})})])]).self(s=>{const i=$.pointers($(document.body));let n=!1;i.on("down",(h,o)=>{if(!s.contains(h.$target))return h.delete();o.preventDefault(),this.$video.isPlaying&&(n=!0,this.$video.pause());const a=(h.x-s.domRect().x)/s.offsetWidth;this.$video.currentTime(a*this.$video.duration)}),i.on("move",(h,o)=>{o.preventDefault();const a=(h.x-s.domRect().x)/s.offsetWidth;this.$video.currentTime(a*this.$video.duration),t.fire("progressChange",a)}),i.on("up",(h,o)=>{n&&this.$video.play(),n=!1})})])}durationUpdate(){const t=vt(this.$video.currentTime()*1e3);this.duration$.set(Number(t.hh)>0?`${t.hh}:${t.mm}:${t.ss}`:`${t.mm}:${t.ss}`)}}class Kt extends f{constructor(t){super("detail-panel");l(this,"post",null);l(this,"options");this.options={preview:(t==null?void 0:t.preview)??!1,tagsType:(t==null?void 0:t.tagsType)??"detail"},this.build()}build(){this.post?this.content([this.options.preview?$("div").class("preview").content([$("img").src(this.post.previewURL)]):null,$("div").class("detail").content([$("section").class("post-info").content([new E("id").name("Post").content(`#${this.post.id}`),new E("uploader").name("Uploader").content(this.post.uploader$),new E("approver").name("Approver").content(this.post.approver$),new E("date").name("Date").content(this.post.created_date$),new E("size").name("Size").content([this.post.file_size$,this.post.dimension$]),new E("file-type").name("File Type").content(this.post.file_ext$),$("div").class("inline").content([new E("favorites").name("Favorites").content(this.post.favcount$),new E("score").name("Score").content(this.post.score$)]),this.post.file_url?new E("file-url").name("File").content([$("a").href(this.post.file_url$).content(this.post.file_url$.convert(t=>t?t.replace("https://",""):"")).target("_blank"),$("ion-icon").name("clipboard").on("click",(t,s)=>this.copyButtonHandler(s,this.post.file_url))]):null,new E("source-url").name("Source").content([$("a").href(this.post.source$).content(this.post.source$.convert(t=>t.replace("https://",""))).target("_blank"),$("ion-icon").name("clipboard").on("click",(t,s)=>this.copyButtonHandler(s,this.post.source))]),new E("booru-url").name(g.name$).content([$("a").href(this.post.booruUrl$).content(this.post.booruUrl$.convert(t=>t.replace("https://",""))).target("_blank"),$("ion-icon").name("clipboard").on("click",(t,s)=>this.copyButtonHandler(s,this.post.booruUrl))]),new E("webm-url").name("Webm").hide(!0).self(async t=>{await this.post.ready,this.post.isUgoria&&t.content($("a").href(this.post.webm_url$).content(this.post.webm_url$.convert(s=>s.replace("https://",""))).target("_blank")).hide(!1)})]),$("div").class("post-tags").content(async t=>{if(this.options.tagsType==="detail"){let s=function(d,u){return u.length?[$("h3").content(d),$("section").content([u.map(m=>$("div").class("tag").content([$("a").class("tag-name").content(m.name).href(`/posts?tags=${m.name}`),$("span").class("tag-post-count").content(m.post_count$.convert(st))]))])]:null};const i=(await this.post.fetchTags()).tags,[n,h,o,a,c]=[i.filter(d=>d.category===B.Artist),i.filter(d=>d.category===B.Character),i.filter(d=>d.category===B.General),i.filter(d=>d.category===B.Meta),i.filter(d=>d.category===B.Copyright)];return[s("Artist",n),s("Character",h),s("Copyright",c),s("Meta",a),s("General",o)]}else{let s=function(i,n){var h;return(h=n.at(0))!=null&&h.length?[$("h3").content(i),$("section").class("tag-name-only").content([n.map(o=>$("a").class("tag").content(o).href(`/posts?tags=${o}`))])]:null};return[s("Artist",this.post.tag_string_artist.split(" ")),s("Character",this.post.tag_string_character.split(" ")),s("Copyright",this.post.tag_string_copyright.split(" ")),s("Meta",this.post.tag_string_meta.split(" ")),s("General",this.post.tag_string_general.split(" "))]}})])]):this.content($("span").class("no-content").content("No Selected"))}update(t){return this.post=t,this.build(),this}copyButtonHandler(t,s){t.name("checkmark"),navigator.clipboard.writeText(s),setTimeout(()=>t.name("clipboard"),3e3)}position(t){let s=0;return addEventListener("scroll",()=>{this.inDOM()&&(s=document.documentElement.scrollTop)},{passive:!0}),t.on("beforeShift",()=>{innerWidth>800&&this.css({position:"absolute",top:`calc(${s}px + var(--nav-height) + var(--padding))`})}).on("afterShift",()=>this.css({position:"",top:""})),this}}class E extends f{constructor(t){super("div");l(this,"$name",$("span").class("property-name"));l(this,"$values",$("div").class("property-values"));this.staticClass("property").attribute("property-id",t),super.content([this.$name,this.$values.hide(!0)])}name(t){return this.$name.content(t),this}content(t){this.$values.hide(!1);const s=$.orArrayResolve(t);return this.$values.content(s.map(i=>$("span").staticClass("property-value").content(i))),this}}const it=class it{constructor(e){l(this,"orderMap",new Map);l(this,"cache",new Set);l(this,"limit",100);l(this,"tags");l(this,"finished",!1);l(this,"events",new C);this.tags=e,it.managers.set(this.tags,this)}static get(e){const t=this.managers.get(e)??new it(e);return this.managers.set(t.tags,t),t}clear(){this.orderMap.clear(),this.cache.clear()}async fetchPosts(e){const t=this.tags?decodeURIComponent(this.tags).split("+"):void 0,s=[],i=[];let n=this.limit,h=[];if(t)for(const o of t)o.startsWith("ordfav:")||o.startsWith("order:")?i.push(o):o.startsWith("limit:")?n=Number(o.split(":")[1]):s.push(o);if(i.length){if(i.length>1)return this.events.fire("post_error",`Error: These query can't be used together [${i}].`),[];const o=i[0];if(o.startsWith("ordfav:")){const a=o.split(":")[1],c=s.length?`&search[post_tags_match]=${s.toString().replaceAll(",","+")}`:"",d=this.orderKeyList.length?e==="newer"?`&search[id]=>${this.orderKeyList.at(0)}`:`&search[id]=<${this.orderKeyList.at(-1)}`:void 0,u=await g.used.fetch(`/favorites.json?search[user_name]=${a}${d??""}${c}&limit=${n}`);h=await Q.fetchMultiple(g.used,{tags:`id:${u.map(w=>w.post_id).toString()}`});const m=new Map;for(const w of u){const O=h.find(p=>p.id===w.post_id);O&&O.file_url&&m.set(w.id,O)}return this.orderMap=new Map(e==="newer"?[...m,...this.orderMap]:[...this.orderMap,...m]),this.events.fire("post_fetch",h),h}if(o.startsWith("order:")){const a=this.orderKeyList.length?e==="newer"?1:this.orderMap.size/n+1:void 0;h=await Q.fetchMultiple(g.used,{tags:this.tags},n,a);const c=new Map(h.filter(d=>d.file_url).map(d=>[d.id,d]));c.forEach((d,u)=>{this.orderMap.has(u)&&c.delete(u)}),this.orderMap=new Map(e==="newer"?[...c,...this.orderMap]:[...this.orderMap,...c]),this.events.fire("post_fetch",h)}}else{const o=this.orderKeyList.length?e==="newer"?`a${this.orderKeyList.at(0)}`:`b${this.orderKeyList.at(-1)}`:void 0;h=await Q.fetchMultiple(g.used,{tags:this.tags},n,o);const a=new Map(h.filter(c=>c.file_url).map(c=>[c.id,c]));this.orderMap=new Map(e==="newer"?[...a,...this.orderMap]:[...this.orderMap,...a])}return h.length||(this.finished=!0,this.cache.size?this.events.fire("endPost"):this.events.fire("noPost")),this.events.fire("post_fetch",h),h}get orderKeyList(){return[...this.orderMap.keys()]}};l(it,"managers",new Map);let dt=it;const xe=$("route").path("/posts/:id?q").id("post").static(!1).builder(({$route:r,params:e})=>{if(!Number(e.id))return $("h1").content("404: POST NOT FOUND");const t=$("video"),s=$.events();let i,n;s.on("video_play_pause",()=>{t.isPlaying?t.pause():t.play()}),$.keys($(window)).self(o=>o.if(a=>{if(!($(a.target)instanceof M)&&r.inDOM())return!0}).keydown(["f","F"],a=>{var c;(c=g.used.user)!=null&&c.favorites.has(i.id)?i.deleteFavorite():i.createFavorite()}).keydown(" ",a=>{a.preventDefault(),t.isPlaying?t.pause():t.play()}).keydown(["a","A"],a=>h("prev")).keydown(["d","D"],a=>{h("next")})),r.on("open",({params:o,query:a})=>{var c;if(n=(c=a.q)!=null&&c.includes("order:")?void 0:dt.get(a.q),i=Q.get(g.used,+o.id),n)if(!n.orderMap.size||!n.cache.has(i))n.cache.add(i),n.orderMap.set(i.id,i),n.fetchPosts("newer"),n.fetchPosts("older");else{const d=[...n.orderMap.values()],u=d.indexOf(i);!n.finished&&u>d.length-n.limit/2?n.fetchPosts("older"):u===0&&n.fetchPosts("newer")}s.fire("post_switch",i)});function h(o){if(!n)return;const a=[...n.orderMap.values()],c=a.indexOf(i);if(o==="prev"&&c===0)return;const d=a.at(o==="next"?c+1:c-1);d&&$.replace(`/posts/${d.id}${n.tags?`?q=${n.tags}`:""}`)}return[$("div").class("viewer").self(async o=>{o.on("pointermove",a=>{(a.pointerType==="mouse"||a.pointerType==="pen")&&s.fire("viewerPanel_show")}).on("pointerup",a=>{var c;(c=$(":.viewer-panel .panel"))!=null&&c.contains($(a.target))||(a.pointerType==="touch"&&s.fire("viewerPanel_switch"),a.pointerType==="mouse"&&s.fire("video_play_pause"))}).on("mouseleave",()=>{s.fire("viewerPanel_hide")}),s.on("post_switch",async a=>{await a.ready,o.content([$("div").class("viewer-panel").hide(!1).content([$("div").class("panel").content([a.isVideo?new _e(t,o,a):null,$("div").class("buttons").content([$("ion-icon").title("Favorite").name("heart-outline").self(c=>{var d;N.events.on("favoriteUpdate",u=>{u.favorites.has(a.id)?c.name("heart"):c.name("heart-outline")}),(d=g.used.user)!=null&&d.favorites.has(a.id)&&c.name("heart"),c.on("click",()=>{var u;(u=g.used.user)!=null&&u.favorites.has(a.id)?a.deleteFavorite():a.createFavorite()})}),$("ion-icon").title("Original Size").name("resize-outline").self(c=>{c.on("click",()=>{s.fire("original_size"),c.disable(!0)}),(!a.isLargeFile||a.isVideo)&&c.disable(!0)})])]),$("div").class("overlay")]).self(c=>{s.on("viewerPanel_hide",()=>c.hide(!0)).on("viewerPanel_show",()=>c.hide(!1)).on("viewerPanel_switch",()=>c.hide(!c.hide()))}),a.isVideo?t.height(a.image_height).width(a.image_width).src(a.file_ext==="zip"?a.large_file_url:a.file_url).controls(!1).autoplay(!0).loop(!0).disablePictureInPicture(!0):$("img").height(a.image_height).width(a.image_width).self(c=>{c.once("load",()=>c.once("load",()=>c.removeClass("loading")).src(a.isLargeFile?a.large_file_url:a.file_url)).src(a.preview_file_url),c.complete||c.class("loading"),s.on("original_size",()=>c.src(a.file_url))})])})}),$("div").class("content").content([$("h3").content("Artist's Commentary"),$("section").class("commentary").self(async o=>{s.on("post_switch",async a=>{const c=(await Bt.fetchMultiple(g.used,{post:{_id:a.id}})).at(0);o.content([c?[c.original_title?$("h3").content(c.original_title):null,$("pre").content(c.original_description)]:"No commentary"])})})]),new Kt().position(r).self(o=>{s.on("post_switch",a=>o.update(a))})]});class yt extends f{constructor(t,s){super("post-tile");l(this,"post");l(this,"$video");l(this,"$img");l(this,"duration$",$.state(""));l(this,"$grid");this.$grid=t,this.post=s,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",i=>i.preventDefault()):null,this.$img=$("img").draggable(!1).css({opacity:"0"}).width(this.post.image_width).height(this.post.image_height).src(this.post.previewURL).loading("lazy"),this.attribute("filetype",this.post.file_ext),this.durationUpdate(),this.build()}build(){var t;(t=this.$video)==null||t.on("timeupdate",(s,i)=>{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.url).preventDefault(H).content(()=>[this.$video,this.$img.on("mousedown",s=>s.preventDefault()).once("load",(s,i)=>{i.animate({opacity:[0,1]},{duration:300},()=>i.css({opacity:""})),this.removeClass("loading")})])]),this.on(["focus","mouseenter","touchstart"],()=>{var s,i;(s=this.$video)!=null&&s.isPlaying||(i=this.$video)==null||i.src(this.post.large_file_url).hide(!1).play().catch(n=>{}),this.post.isGif&&this.$img.src(this.post.large_file_url)},{passive:!0}).on(["blur","mouseleave","touchend","touchcancel"],()=>{var s;(s=this.$video)==null||s.pause().currentTime(0).hide(!0),this.post.isGif&&this.$img.src(this.post.previewURL)},{passive:!0}).on("click",()=>{if(H.value){if(innerWidth<=800)return $.open(this.post.pathname);$(document.activeElement)===this?$.open(this.post.pathname):this.trigger("$focus")}})}durationUpdate(){if(!this.$video)return;const t=vt(this.post.media_asset.duration*1e3-this.$video.currentTime()*1e3);this.duration$.set(Number(t.hh)>0?`${t.hh}:${t.mm}:${t.ss}`:`${t.mm}:${t.ss}`)}get url(){return`${this.post.pathname}${this.$grid.tags?`?q=${this.$grid.tags}`:""}`}}class Te extends Ut{constructor(t){super();l(this,"$posts",new Map);l(this,"tags");l(this,"$focus",$.focus());l(this,"posts");this.tags=t==null?void 0:t.tags,this.posts=dt.get(this.tags),this.addStaticClass("post-grid"),this.type("waterfall").gap(10),this.init()}async init(){this.posts.events.on("post_fetch",t=>{this.addPost(t)}),setInterval(async()=>{this.inDOM()&&document.documentElement.scrollTop===0&&await this.posts.fetchPosts("newer")},1e4),g.events.on("set",()=>{this.removeAll(),this.posts.finished&&(this.posts.finished=!1,this.loader())}),this.on("resize",()=>this.resize()),this.loader(),this.$focus.layer(100).loop(!1).scrollThreshold($.rem(2)+60),$.keys($(window)).if(t=>{if(!($(t.target)instanceof M)&&this.inDOM())return!0}).keydown(["w","W"],t=>{t.preventDefault(),this.$focus.up()}).keydown(["s","S"],t=>{t.preventDefault(),this.$focus.down()}).keydown(["d","D"],t=>{t.preventDefault(),this.$focus.right()}).keydown(["a","A"],t=>{t.preventDefault(),this.$focus.left()}).keydown([" ","Enter"],t=>{var i;t.preventDefault();const s=(i=this.$focus.currentLayer)==null?void 0:i.currentFocus;s instanceof yt&&$.open(s.url)}).keydown(["Escape"],t=>{t.preventDefault(),this.$focus.blur()})}async loader(){if(!this.inDOM())return setTimeout(()=>this.loader(),100);for(;this.inDOM()&&document.documentElement.scrollHeight<=innerHeight*2;)if(!(await this.posts.fetchPosts("older")).length)return;document.documentElement.scrollTop+innerHeight>document.documentElement.scrollHeight-innerHeight*2&&!(await this.posts.fetchPosts("older")).length||setTimeout(()=>this.loader(),100)}resize(){const t=Math.round(this.dom.clientWidth/300);this.column(t>=2?t:2)}addPost(t){t=$.orArrayResolve(t);for(const i of t){if(!i.file_url||this.posts.cache.has(i))continue;const n=new yt(this,i).on("$focus",(h,o)=>this.$focus.layer(100).focus(o));this.$posts.set(i,n),this.posts.cache.add(i)}this.$focus.layer(100).elementSet.clear();const s=[...this.posts.orderMap.values()].map(i=>{var n;return(n=this.$posts.get(i))==null?void 0:n.self(this.$focus.layer(100).add)});return this.content(s).render(),this}removeAll(){return this.posts.clear(),this.$posts.clear(),this.$focus.layer(100).removeAll(),this.animate({opacity:[1,0]},{duration:300,easing:"ease"},()=>this.clear().render()),this}}class qt{static async fetch(e,t,s=20){if(!t.length)return this.searchQuery.map(h=>new Pt(h));const i=await e.fetch(`/autocomplete.json?search[query]=${t}&search[type]=tag_query&version=1&limit=${s}`);return[...t.length?this.searchQuery.filter(h=>h.value.startsWith(t)&&h.value!==t):this.searchQuery,...i].map(h=>new Pt(h))}}l(qt,"searchQuery",[{value:"user:",label:"user:"},{value:"approver:",label:"approver:"},{value:"-approver:",label:"-approver:"},{value:"order:",label:"order:"},{value:"ordfav:",label:"ordfav:"},{value:"ordfavgroup:",label:"ordfavgroup:"},{value:"search:",label:"search:"},{value:"favgroup:",label:"favgroup:"},{value:"-favgroup:",label:"-favgroup:"},{value:"favcount:",label:"favcount:"},{value:"id:",label:"id:"},{value:"tagcount:",label:"tagcount:"},{value:"gentags:",label:"gentags:"},{value:"arttags:",label:"arttags:"},{value:"chartags:",label:"chartags:"},{value:"copytags:",label:"copytags:"},{value:"metatags:",label:"metatags:"},{value:"score:",label:"score:"},{value:"upvote:",label:"upvote:"},{value:"downvote:",label:"downvote:"},{value:"disapproved:",label:"disapproved:"},{value:"md5:",label:"md5:"},{value:"width:",label:"width:"},{value:"height:",label:"height:"},{value:"ratio:",label:"ratio:"},{value:"mpixels:",label:"mpixels:"},{value:"filesize:",label:"filesize:"},{value:"duration:",label:"duration:"},{value:"is:",label:"is:"},{value:"has:",label:"has:"},{value:"pool:",label:"pool:"},{value:"-pool:",label:"-pool:"},{value:"ordpool:",label:"ordpool:"},{value:"random:",label:"random:"},{value:"limit:",label:"limit:"},{value:"date:",label:"date:"},{value:"commenter:",label:"commenter:"},{value:"note:",label:"note:"},{value:"noter:",label:"noter:"},{value:"noteupdater:",label:"noteupdater:"},{value:"status:",label:"status:"},{value:"-status:",label:"-status:"},{value:"rating:",label:"rating:"},{value:"-rating:",label:"-rating:"},{value:"source:",label:"source:"},{value:"-source:",label:"-source:"},{value:"pixiv:",label:"pixiv:"},{value:"parent:",label:"parent:"},{value:"child:",label:"child:"},{value:"flagger:",label:"flagger:"},{value:"appealer:",label:"appealer:"},{value:"commentary:",label:"commentary:"},{value:"commentaryupdater:",label:"commentaryupdater:"}].map(e=>({type:"query",...e})));class Pt{constructor(e){Object.assign(this,e)}isTag(){return this.type==="tag"||this.type==="tag-autocorrect"||this.type==="tag-alias"||this.type==="tag-word"}isTagAutocorrect(){return this.type==="tag-autocorrect"}isTagAntecedent(){return!!this.antecedent}isTagWord(){return this.type==="tag-word"}isUser(){return this.type==="user"}}class Se extends f{constructor(){super("searchbar");l(this,"$tagInput",new Ie(this));l(this,"$selectionList",new Oe);l(this,"typingTimer",null);l(this,"$filter",$("div").class("filter"));this.build(),window.addEventListener("keyup",t=>{!this.inDOM()&&t.key==="/"&&this.open(),this.inDOM()&&t.key==="Escape"&&this.close()})}build(){this.content([$("div").class("input-container").content([this.$tagInput.on("input",()=>this.inputHandler()).on("keydown",t=>this.keyHandler(t)),$("ion-icon").name("close-circle-outline").title("Clear Input").on("click",()=>this.$tagInput.clearAll())]).on("click",t=>{t.target===this.$tagInput.dom&&this.$tagInput.addTag().input()}),$("div").class("selection-list-container").content([this.$selectionList]),this.$filter.on("click",()=>{location.hash==="#search"&&this.close()})])}open(){return location.hash!=="#search"&&$.open(location.href+"#search"),this}close(){return location.hash==="#search"&&$.back(),this}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(t){var n,h;const s=()=>{t.preventDefault(),this.$tagInput.addTag().input()},i=o=>{const a=this.$tagInput.children.indexOf(this.$tagInput.$inputor);if(this.$tagInput.$input.value().at(-1)===":")return this.getSearchSuggestions();const c=this.$tagInput.children.array.at(a+1);this.$tagInput.addTag(o.value()),c?this.$tagInput.editTag(c):this.$tagInput.input()};switch(t.key){case"ArrowUp":{t.preventDefault(),this.$selectionList.focusPrevSelection(),this.$tagInput.value((n=this.$selectionList.focused)==null?void 0:n.value());break}case"ArrowDown":{t.preventDefault(),this.$selectionList.focusNextSelection(),this.$tagInput.value((h=this.$selectionList.focused)==null?void 0:h.value());break}case" ":s();break;case"Enter":{t.preventDefault(),this.$selectionList.focused?i(this.$selectionList.focused):(this.$tagInput.addTag(),this.search());break}case"Tab":{t.preventDefault();const o=this.$tagInput.children.indexOf(this.$tagInput.$inputor);if(t.shiftKey){o-1>=0&&this.$tagInput.editTag(this.$tagInput.children.array.at(o-1));break}if(this.$selectionList.focused)i(this.$selectionList.focused);else{const a=this.$tagInput.children.array.at(o+1);a?this.$tagInput.editTag(a):this.$tagInput.addTag().input()}break}case"Backspace":{const o=this.$tagInput.children.indexOf(this.$tagInput.$inputor);o!==0&&!this.$tagInput.$input.value().length&&(t.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 t=this.$tagInput.$input.value(),s=await qt.fetch(g.used,t,20);this.$selectionList.clearSelections().addSelections(s.map(i=>new ke().value(i.value).content([$("div").class("selection-label").content([i.isTagAntecedent()?$("span").class("tag-antecedent").self(n=>n.dom.innerHTML=i.antecedent.replaceAll(t,`${t}`)):null,$("div").class("label-container").content([i.isTagAntecedent()?$("ion-icon").name("arrow-forward-outline"):null,$("span").class("label").self(n=>n.dom.innerHTML=i.label.replaceAll(t,`${t}`))])]),i.isTag()?$("div").class("tag-detail").content([$("span").class("tag-post-count").content(st(i.post_count)),$("span").class("tag-category").content(B[i.category])]):null,i.isUser()?$("span").class("user-level").content(i.level):null]).on("click",()=>{this.$tagInput.addTag(i.value).input()})))}search(){return $.replace(`/posts?tags=${this.$tagInput.query.replace(":","%3A")}`),this.$tagInput.clearAll(),this.inactivate(),this}checkURL(t,s){if((t==null?void 0:t.hash)==="#search"&&this.inactivate(),s.hash==="#search"&&this.activate(),`${t==null?void 0:t.pathname}${t==null?void 0:t.search}`==`${s.pathname}${s.search}`)return;const i=s.searchParams.get("tags");this.$tagInput.clearAll(),i==null||i.split(" ").forEach(n=>this.$tagInput.addTag(n))}}class Oe extends f{constructor(){super("selection-list");l(this,"focused",null);l(this,"selections",new Set)}addSelections(t){t=$.orArrayResolve(t);for(const s of t)this.selections.add(s);return this.insert(t),this}clearSelections(){return this.focused=null,this.selections.clear(),this.clear(),this}focusSelection(t){return this.blurSelection(),this.focused=t,t.focus(),t.offsetTopthis.scrollTop()+this.offsetHeight&&this.scrollTop(t.offsetTop+t.offsetHeight-this.offsetHeight),this}blurSelection(){var t;return(t=this.focused)==null||t.blur(),this.focused=null,this}focusNextSelection(){const t=this.selections.array,s=t.at(0);if(this.focused){const i=t.at(t.indexOf(this.focused)+1);i?this.focusSelection(i):s&&this.focusSelection(s)}else s&&this.focusSelection(s)}focusPrevSelection(){const t=this.selections.array;if(this.focused){const s=t.at(t.indexOf(this.focused)-1);s&&this.focusSelection(s)}else{const s=t.at(0);s&&this.focusSelection(s)}}}class ke extends f{constructor(){super("selection");l(this,"property",{value:""})}value(t){return $.fluent(this,arguments,()=>this.property.value,()=>$.set(this.property,"value",t))}focus(){return this.addClass("active"),this}blur(){return this.removeClass("active"),this}}class Ie extends f{constructor(t){super("tag-input");l(this,"$input",$("input").type("text"));l(this,"$sizer",$("span").class("sizer"));l(this,"$inputor",$("div").class("input-wrapper").content([this.$sizer,this.$input.on("input",()=>{this.$sizer.content(this.$input.value())})]));l(this,"tags",new Set);l(this,"$seachbar");this.$seachbar=t}input(){return this.insert(this.$inputor),this.$input.focus(),this.$seachbar.$selectionList.clearSelections(),this.$seachbar.getSearchSuggestions(),this}addTag(t){if(t=t??this.$input.value(),!t.length)return this;const s=new Ee(t);return s.on("click",()=>this.editTag(s)),this.tags.add(s),this.value(""),this.$input.inDOM()?this.$inputor.replace(s):this.insert(s),this}editTag(t){return this.addTag(),this.tags.delete(t),t.replace(this.$inputor),this.value(t.name),this.$input.focus(),this.$seachbar.getSearchSuggestions(),this}clearAll(){return this.value(""),this.tags.clear(),this.clear(),this}value(t){return t===void 0?this:(this.$input.value(t),this.$sizer.content(t),this)}focus(){return this.$input.focus(),this}get query(){return this.tags.array.map(t=>t.name).toString().replace(",","+")}}class Ee extends f{constructor(t){super("tag");l(this,"name");this.name=t,this.build()}build(){this.content(this.name)}}class Me extends f{constructor(){super("ion-icon")}name(e){return this.attribute("name",e),this}size(e){return this.attribute("size",e),this}disable(e){return this.attribute("disable",e),this}link(e,t=!1){return this.on("click",()=>t?$.replace(e):$.open(e)),this}}class Pe extends _t{constructor(){super();l(this,"$icon",$("ion-icon"));l(this,"$label",$("span"));this.addStaticClass("icon"),this.build()}build(){super.content([this.$icon.hide(!0),this.$label])}content(t){return this.$label.content(t),this}icon(t){return this.$icon.name(t).hide(!1),this}link(t,s=!1){return this.on("click",()=>s?$.replace(t):$.open(t)),this}}const Le=$("route").id("login").path("/login").builder(()=>{const[r,e]=[$.state(""),$.state("")];return[$("div").class("login-container").content([$("h1").content("Login"),$("div").class("username","input-container").content([$("label").for("username").content("Username"),$("input").type("text").id("username").value(r)]),$("div").class("api-key","input-container").content([$("label").for("api-key").content("API Key"),$("input").type("password").id("api-key").value(e)]),$("icon-button").content("Login").on("click",async()=>{await g.used.login(r.value,e.value),g.used.user&&(N.storageUserData={apiKey:e.value,username:r.value},r.set(""),e.set(""),$.replace("/"))}),$("icon-button").content("Create Account").icon("open-outline").on("click",()=>$.open("https://danbooru.donmai.us/users/new","_blank"))])]});class Ae extends f{constructor(){super("drawer");l(this,"$filter",$("div").class("filter"));l(this,"$container",$("div").class("drawer-container"));l(this,"pointers",$.pointers($(document.body)));l(this,"opened",!1);this.hide(!0),this.build()}build(){this.content([this.$container.content([$("div").class("user-info").hide(!0).self(t=>[g.events.on("login",s=>{t.content([$("div").content([$("h3").class("username").content(s.name$),$("div").class("user-detail").content([$("span").class("userid").content(`ID: ${s.id}`),$("span").class("level").content(["Level: ",s.level_string$])])]),$("div").class("user-nav").content([$("icon-button").title("Uploaded Posts").icon("image").content(s.post_upload_count$.convert(st)).link(`/posts?tags=user:${s.name}`,!0),$("icon-button").title("Favorites").icon("heart").content(s.favorite_count$.convert(st)).link(`/posts?tags=ordfav:${s.name}`,!0),$("icon-button").title("Forum Posts").icon("document-text").content(s.forum_post_count$.convert(st)).hide(!0)])]).hide(!1)}).on("logout",()=>{t.clear().hide(!0)})]),$("div").class("nav").content([$("icon-button").icon("log-in-outline").content("Login").link("/login",!0).self(t=>g.events.on("login",()=>t.hide(!0)).on("logout",()=>t.hide(!1))),$("icon-button").icon("log-in-outline").content("Logout").on("dblclick",()=>g.used.logout()).hide(!0).self(t=>g.events.on("login",()=>t.hide(!1)).on("logout",()=>t.hide(!0))),$("icon-button").icon("swap-horizontal").class("switch").content("Switch Booru").on("click",()=>{g.used===wt?g.set(Ce):g.set(wt),this.close()})])]),this.$filter.on("click",()=>$.back())]),this.pointers.on("move",t=>{var s;(s=$(":.viewer"))!=null&&s.contains(t.$target)||(t.$target.parent,!(t.type!=="pen"&&t.type!=="touch")&&(t.move_y>4||t.move_y<-4||(t.move_x<=-7&&(t.delete(),this.open()),t.move_x>=7&&(t.delete(),this.close()))))})}open(){return location.hash!=="#drawer"&&$.open(location.href+"#drawer"),this}close(){return location.hash==="#drawer"&&$.back(),this}activate(){this.opened=!0,this.hide(!1),this.$container.animate({transform:["translateX(100%)","translateX(0%)"]},{fill:"both",duration:300,easing:"ease"}),this.$filter.animate({opacity:[0,1]},{fill:"both",duration:300,easing:"ease"})}inactivate(){this.opened=!1,this.$container.animate({transform:["translateX(0%)","translateX(100%)"]},{fill:"both",duration:300,easing:"ease"},()=>this.hide(!this.opened)),this.$filter.animate({opacity:[1,0]},{fill:"both",duration:300,easing:"ease"})}checkURL(t,s){(t==null?void 0:t.hash)==="#drawer"&&this.inactivate(),s.hash==="#drawer"&&this.activate()}}class Lt{static get detailPanelEnabled(){var e;return(e=this.localdata)==null?void 0:e.detailPanelEnabled}static set detailPanelEnabled(e){this.localdata={...this.localdata,detailPanelEnabled:e}}static get localdata(){const e=localStorage.getItem("local_settings_data");return e?JSON.parse(e):null}static set localdata(e){localStorage.setItem("local_settings_data",JSON.stringify(e))}}$.registerTagName("ion-icon",Me);$.registerTagName("icon-button",Pe);$.registerTagName("a",zt);const[wt,Ce]=[new g({origin:"https://danbooru.donmai.us",name:"Danbooru"}),new g({origin:"https://safebooru.donmai.us",name:"Safebooru"}),new g({origin:"https://testbooru.donmai.us",name:"Testbooru"})];g.set(g.manager.get(g.storageAPI??"")??wt);const ht=new Se().hide(!0),bt=new Ae,H=$.state(Lt.detailPanelEnabled??!1).on("update",({state$:r})=>Lt.detailPanelEnabled=r.value);$(document.body).content([$("nav").content([$("a").class("title").href("/").content([$("h1").class("booru-name").content(g.name$),$("h2").class("app").content([$("span").class("app-name").content("Viewer"),$("span").class("version").content("v0.11.0")])]),$("div").class("searchbar").content(["Search in ",g.name$]).self(r=>T.events.on("stateChange",({beforeURL:e,afterURL:t})=>{e.hash==="#search"&&r.hide(!1),t.hash==="#search"&&r.hide(!0)})).on("click",()=>ht.open()),$("div").class("buttons").content([$("ion-icon").class("search").name("search-outline").title("Search").self(r=>T.events.on("stateChange",({beforeURL:e,afterURL:t})=>{e.hash==="#search"&&r.hide(!1),t.hash==="#search"&&r.hide(!0)})).on("click",()=>ht.open()),$("ion-icon").class("detail-panel").name("reader-outline").title("Toggle Detail Panel").on("click",()=>H.set(!H.value)),$("a").content($("ion-icon").class("open").name("open-outline").title("Open in Original Site")).href(location.href.replace(location.origin,g.used.origin)).target("_blank"),$("ion-icon").class("copy").name("link-outline").title("Copy Page Link").hide(!1).on("click",(r,e)=>{navigator.clipboard.writeText(`${location.origin}${location.pathname}${location.search}`),e.name("checkmark-outline"),setTimeout(()=>{e.name("link-outline")},2e3)}),$("ion-icon").class("menu").name("menu-outline").title("Menu").hide(!1).self(r=>{g.events.on("login",()=>r.hide(!0)).on("logout",()=>r.hide(!1))}).on("click",()=>$.open(location.href+"#drawer")),$("div").class("account").hide(!0).title("Menu").self(r=>{g.events.on("login",e=>{r.content(e.name$.convert(t=>{var s;return((s=t.at(0))==null?void 0:s.toUpperCase())??""})).hide(!1)}).on("logout",()=>r.hide(!0))}).on("click",()=>bt.open())])]),ht,bt,$("router").base("/").map([$("route").id("posts").path(["/","/posts"]).builder(({$route:r,query:e})=>{const{$postGrid:t,$detail:s}=At(r,e);return[t,s]}),$("route").id("posts").path("/posts?tags").builder(({$route:r,query:e})=>{const{$postGrid:t,$detail:s}=At(r,e);return[$("header").content([$("h2").content("Posts"),$("div").class("tags").self(i=>{e.tags.split("+").forEach(n=>{i.insert($("a").class("tag").content(decodeURIComponent(n)).href(`posts?tags=${n}`))})})]),$("div").class("no-post").hide(!0).self(i=>{i.on("startLoad",()=>i.hide(!0)),t.self(()=>{t.posts.events.on("noPost",()=>i.hide(!1).content("No Posts")).on("post_error",n=>i.hide(!1).content(n))})}),t,s]}),xe,Le]).on("beforeSwitch",r=>{r.preventDefault();function s(){var h;$(document.documentElement).css({scrollBehavior:"auto"});const n=$.call(()=>{switch(T.navigationDirection){case z.Forward:return["translateX(2%)","translateX(0%)"];case z.Back:return["translateX(-2%)","translateX(0%)"];case z.Replace:return""}});r.$view.content(r.nextContent),r.rendered(),(h=r.nextContent.element)==null||h.class("animated").animate({opacity:[0,1],transform:n},{duration:300,easing:"ease"},()=>{var o;r.switched(),$(document.documentElement).css({scrollBehavior:""}),(o=r.nextContent.element)==null||o.removeClass("animated")})}function i(){var h,o;$(document.documentElement).css({scrollBehavior:"auto"});const n=$.call(()=>{switch(T.navigationDirection){case z.Forward:return["translateX(0%)","translateX(-2%)"];case z.Back:return["translateX(0%)","translateX(2%)"];case z.Replace:return""}});(o=(h=r.previousContent)==null?void 0:h.element)==null||o.class("animated").animate({opacity:[1,0],transform:n},{duration:300,easing:"ease"},()=>{var a,c;(c=(a=r.previousContent)==null?void 0:a.element)==null||c.removeClass("animated"),s()})}r.previousContent?i():s()})]);T.events.on("stateChange",({beforeURL:r,afterURL:e})=>Xt(r,e));Xt(void 0,new URL(location.href));function Xt(r,e){ht.checkURL(r,e),bt.checkURL(r,e)}function At(r,e){const t=new Te(e),s=new Kt({preview:!0,tagsType:"name_only"}).hide(H.convert(n=>!n)).position(r);i(),H.on("update",i),g.events.on("set",()=>s.update(null));function i(){H.value?t.addClass("detail-panel-enabled"):t.removeClass("detail-panel-enabled")}return t.$focus.on("focus",({$focused:n})=>{n.inDOM()&&n instanceof yt&&s.update(n.post)}).on("blur",()=>s.update(null)),{$postGrid:t,$detail:s}}$.keys($(window)).if(r=>{if(!($(r.target)instanceof M))return!0}).keydown(["q","Q"],r=>{r.preventDefault(),T.index!==0&&$.back()}).keydown(["e","E"],r=>{r.preventDefault(),T.forwardIndex!==0&&$.forward()}).keydown("Tab",r=>{r.preventDefault(),H.set(!H.value)}); diff --git a/dist/assets/index-BgVVzy-z.css b/dist/assets/index-Plu04C2a.css similarity index 60% rename from dist/assets/index-BgVVzy-z.css rename to dist/assets/index-Plu04C2a.css index 3c0e90a..493a94c 100644 --- a/dist/assets/index-BgVVzy-z.css +++ b/dist/assets/index-Plu04C2a.css @@ -1 +1 @@ -layout.post-grid{margin-block:1rem}layout.post-grid a{transition:.3s all ease}layout.post-grid:has(post-tile[focus]) post-tile:not([focus]) a{opacity:.5}layout.post-grid:has(post-tile[focus]) post-tile:hover a{opacity:1}post-tile{display:block;transition:.3s all ease;position:relative;transition:all .3s ease;border-radius:var(--border-radius-medium);overflow:hidden;-webkit-tap-highlight-color:transparent;-webkit-user-select:none;user-select:none;outline:transparent solid 2px;background-color:var(--secondary-color-1)}post-tile[focus]{outline:var(--secondary-color-9) solid 2px;transform:scale(1.02)}@media (hover: hover){post-tile:hover{transform:scale(1.02);z-index:1;box-shadow:0 0 10px color-mix(in srgb,var(--secondary-color-1) 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(--secondary-color-3);color:var(--primary-color);bottom:.3rem;right:.3rem;padding:.2em .4em;height:1rem;border-radius:var(--border-radius-small);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 a{background-color:transparent;padding:0;border-radius:0}post-tile a img{height:100%;width:100%;vertical-align:top;background-color:var(--secondary-color-1)}post-tile a 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(--secondary-color-2) 100%,transparent);border-radius:var(--border-radius-small);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-4)}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-4);color:var(--secondary-color-9);border-radius:var(--border-radius-small);cursor:pointer}searchbar div.input-container ion-icon{font-size:20px;color:var(--secondary-color-4);cursor:pointer}searchbar div.input-container ion-icon:hover{color:var(--secondary-color-9)}searchbar div.selection-list-container{overflow:hidden;border-radius:var(--border-radius-small);background-color:var(--secondary-color-1);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;gap:1rem}searchbar div.selection-list-container selection-list selection:hover{background-color:color-mix(in srgb,var(--secondary-color-3) 50%,transparent)}searchbar div.selection-list-container selection-list selection.active{background-color:var(--secondary-color-3)}searchbar div.selection-list-container selection-list selection div.selection-label{display:flex;flex-wrap:wrap;gap:.5rem}searchbar div.selection-list-container selection-list selection div.selection-label .label-container{display:flex;gap:.5rem;align-items:center}searchbar div.selection-list-container selection-list selection div.selection-label .label-container ion-icon{font-size:1rem}searchbar div.selection-list-container selection-list selection div.tag-detail{display:flex;align-items:center;gap:.5rem}searchbar div.selection-list-container selection-list selection div.tag-detail .tag-post-count{font-size:.8rem}searchbar div.selection-list-container selection-list selection .tag-category,searchbar div.selection-list-container selection-list selection .user-level{padding:.1rem .4rem;border-radius:var(--border-radius-small);font-size:.9rem;background-color:var(--secondary-color-4);color:var(--secondary-color-9)}searchbar div.filter{background-color:var(--secondary-color-1);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-9);border-radius:var(--border-radius-small);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:.8rem 1.2rem}button.icon ion-icon{font-size:1.4rem;color:inherit}button.icon.vertical{flex-direction:column}ion-icon{font-size:24px;color:var(--primary-color);cursor:pointer}ion-icon:hover{color:var(--secondary-color-9)}ion-icon[disable=true]{color:var(--primary-color-darker);pointer-events:none}drawer{position:fixed;top:0;left:0;display:flex;z-index:300;height:100%;width:100%;box-sizing:border-box;justify-content:end;align-items:center;padding:1rem}drawer div.drawer-container{width:300px;max-width:70%;height:100%;background-color:var(--secondary-color-1);border-radius:var(--border-radius-large);z-index:1;overflow:hidden}drawer div.drawer-container div.user-info{background-color:var(--secondary-color-2);padding:2rem}drawer div.drawer-container div.user-info .username{margin:0;color:var(--secondary-color-9);cursor:pointer}drawer div.drawer-container div.user-info div.user-detail{display:flex;gap:.5rem;margin-top:.2rem}drawer div.drawer-container div.user-info div.user-detail span{font-size:.8rem;color:var(--primary-color-dark);display:block;cursor:pointer}drawer div.drawer-container div.user-info div.user-nav{display:grid;grid-template-columns:1fr 1fr 1fr;gap:1rem;margin-top:1rem}drawer div.drawer-container div.nav{padding:2rem;display:flex;gap:1rem;flex-direction:column}drawer div.drawer-container div.nav button.icon{justify-content:start}drawer div.filter{position:absolute;top:0;left:0;height:100%;width:100%;background:linear-gradient(90deg,color-mix(in srgb,var(--secondary-color-1) 50%,transparent),color-mix(in srgb,var(--secondary-color-0) 70%,transparent))}detail-panel{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;--padding: 1rem;position:fixed;top:calc(var(--nav-height) + var(--padding));right:var(--padding);width:300px;height:calc(100dvh - 2rem - var(--nav-height));background-color:var(--secondary-color-1)}@media (max-width: 800px){detail-panel{position:static;width:100%;overflow:visible;height:100%;padding:1rem;box-sizing:border-box}}detail-panel span.no-content{color:var(--secondary-color-3);font-size:1.6rem;font-weight:900}detail-panel div.preview{overflow:hidden;border-radius:var(--border-radius-large);height:300px;width:300px;background-color:var(--secondary-color-0)}detail-panel div.preview img{height:100%;width:100%;object-fit:contain}detail-panel div.detail{display:flex;flex-direction:column;gap:.4rem;overflow:scroll;overflow-x:hidden;border-radius:var(--border-radius-large);height:100%;width:100%}detail-panel div.detail::-webkit-scrollbar{background-color:#000;width:0px}detail-panel div.detail::-webkit-scrollbar-thumb{background-color:#aeaeec}detail-panel h3{padding-left:1rem;margin-block:.6rem}detail-panel .post-info{background-color:#2f2f45;border-radius:var(--border-radius-large);padding:20px;display:flex;flex-direction:column;gap:.4rem}detail-panel .post-info .buttons{display:grid;grid-template-columns:1fr 1fr 1fr;gap:1rem;margin-top:1rem}detail-panel div.property{display:flex;gap:.6rem;align-items:center;width:100%}detail-panel div.property span.property-name{flex-shrink:0}detail-panel div.property div.property-values{display:flex;gap:.4rem;width:100%;overflow:hidden}detail-panel div.property div.property-values span.property-value{padding:.2rem .4rem;background-color:var(--secondary-color-1);color:var(--primary-color-dark);border-radius:var(--border-radius-small);justify-content:space-between;flex-shrink:1;display:flex;align-items:center;overflow:hidden}detail-panel div.property div.property-values span.property-value:has(ion-icon){flex-shrink:0}detail-panel div.property div.property-values span.property-value *{display:block;overflow:hidden;text-wrap:nowrap;text-overflow:ellipsis;flex-shrink:1}detail-panel div.property div.property-values span.property-value ion-icon{font-size:1rem;padding:4px;box-sizing:border-box}detail-panel div.inline{display:flex;gap:1rem}detail-panel div.post-tags{display:flex;flex-direction:column;gap:.2rem}detail-panel div.post-tags div.tag{align-items:center}detail-panel div.post-tags div.tag a.tag-name{word-break:break-word;text-decoration:none}detail-panel div.post-tags div.tag span.tag-post-count{background-color:var(--secondary-color-3);color:var(--secondary-color-8);padding:0 4px;border-radius:var(--border-radius-small);font-size:12px;margin-left:.4rem}detail-panel div.post-tags section.tag-name-only{display:flex;flex-wrap:wrap;column-gap:.5rem}#post{padding:0;padding-top:var(--nav-height)}#post div.viewer{height:calc(100dvh - 2rem - var(--nav-height));display:flex;justify-content:center;align-items:center;background-color:#000;border-radius:var(--border-radius-large);overflow:hidden;width:calc(100vw - 300px - 4rem);margin:1rem;position:relative;transition:all .3s ease}@media (max-width: 800px){#post div.viewer{width:100%;height:calc(100dvh - 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.viewer div.viewer-panel{position:absolute;bottom:0;width:100%;z-index:1}#post div.viewer div.viewer-panel div.panel{width:100%;display:flex;justify-content:center;flex-direction:column;padding:1rem;gap:1rem;box-sizing:border-box}#post div.viewer div.viewer-panel div.panel video-controller{display:flex;flex-direction:column;gap:1rem;align-items:center;width:100%}#post div.viewer div.viewer-panel div.panel video-controller div.video-details{display:flex;align-items:center;justify-content:space-between;width:100%}#post div.viewer div.viewer-panel div.panel video-controller div.video-details div{display:flex;align-items:center;gap:1rem}#post div.viewer div.viewer-panel div.panel video-controller div.progressbar-container{height:2rem;width:100%;display:flex;touch-action:none;align-items:center;cursor:pointer}#post div.viewer div.viewer-panel div.panel video-controller div.progressbar-container div.progressbar{height:.4rem;width:100%;background-color:var(--secondary-color-1);flex-shrink:1}#post div.viewer div.viewer-panel div.panel video-controller div.progressbar-container div.progressbar div.progress{height:100%;background-color:var(--secondary-color-3);width:100px}#post div.viewer div.viewer-panel div.panel video-controller .play{flex-shrink:0}#post div.viewer div.viewer-panel div.panel div.buttons{width:100%;display:flex;justify-content:center;gap:2rem}#post div.viewer div.viewer-panel div.overlay{position:absolute;bottom:0;width:100%;height:200%;z-index:-1;background:linear-gradient(180deg,color-mix(in srgb,var(--secondary-color-1) 0%,transparent),color-mix(in srgb,var(--secondary-color-0) 70%,transparent))}#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}route#login{display:flex;justify-content:center;align-items:center;margin-top:5rem}route#login .login-container{padding:2rem;border:1px solid var(--secondary-color-9);border-radius:var(--border-radius-large);display:flex;flex-direction:column;justify-content:center;gap:1rem;max-width:400px;width:100%;box-sizing:border-box}route#login .login-container h1{margin:0}route#login .login-container .input-container{display:flex;flex-direction:column;gap:.5rem}route#login .login-container .input-container input{display:block}:root{--primary-color: #d1d1ee;--primary-color-dark: #9696b3;--primary-color-darker: #72728d;--secondary-color-9: #aeaeec;--secondary-color-8: #9a9ad6;--secondary-color-7: #7c7cb8;--secondary-color-6: #646497;--secondary-color-5: #545486;--secondary-color-4: #424268;--secondary-color-3: #3b3b66;--secondary-color-2: #24243b;--secondary-color-1: #1e1e2c;--secondary-color-0: #07070c;--shadow-color: #09090e50;--border-radius-small: .4rem;--border-radius-medium: .8rem;--border-radius-large: 1.2rem;--nav-height: 50px}html{overflow-x:hidden;font-size:14px;scroll-behavior:smooth}html ::-webkit-scrollbar{background-color:var(--secondary-color-1);width:8px}html ::-webkit-scrollbar-thumb{background-color:#aeaeec;border-radius:2px}body{overflow-x:hidden;background-color:var(--secondary-color-1);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(--secondary-color-1) 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-9);margin:0}nav a.title .app{display:flex;align-items:center;border-radius:var(--border-radius-small);margin:0;gap:.4rem}nav a.title .app .version{color:var(--secondary-color-1);background-color:var(--secondary-color-9);padding:.2em .4em;border-radius:var(--border-radius-small);font-size:.8rem;font-weight:700}nav a.title .app .app-name{display:none;font-size:1rem;color:var(--secondary-color-9)}nav div.searchbar{padding:.4rem 10%;max-width:500px;background-color:color-mix(in srgb,var(--secondary-color-2) 30%,transparent);border:1px solid var(--primary-color-darker);border-radius:var(--border-radius-small);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(--secondary-color-3) 50%,transparent)}nav div.buttons ion-icon.search{display:none}nav div.buttons a{display:flex;justify-content:center;align-items:center}nav div.buttons div.account{height:2rem;width:2rem;display:flex;justify-content:center;align-items:center;border-radius:2rem;font-weight:bolder;color:var(--secondary-color-9);background-color:var(--secondary-color-4);-webkit-user-select:none;user-select:none;cursor:pointer}@media (max-width: 800px){nav div.searchbar{display:none}nav div.buttons ion-icon.search{display:inline-block}nav div.buttons ion-icon.detail-panel{display:none}}router{display:block;position:relative}router route{display:block;position:relative;padding-inline:1rem;padding-top:var(--nav-height)}route#posts header{margin-bottom:1rem}route#posts header h2{margin:0}route#posts header div.tags{display:flex;flex-wrap:wrap;gap:.5rem}route#posts .post-grid.detail-panel-enabled{width:calc(100vw - 300px - 4rem)}@media (max-width: 800px){route#posts .post-grid.detail-panel-enabled{width:100%}}@media (max-width: 800px){route#posts detail-panel{display:none}}section{background-color:#2f2f45;border-radius:var(--border-radius-large);padding:20px}button{background-color:var(--secondary-color-4);color:var(--secondary-color-9);padding:.8rem 1.2rem;border-radius:1rem;border:none;cursor:pointer}button:hover{background-color:var(--secondary-color-6);color:var(--primary-color)}a{text-decoration:none;color:var(--secondary-color-9)}input{background-color:var(--secondary-color-2);border-radius:var(--border-radius-small);border:1px solid var(--secondary-color-3);font-size:.9rem;padding:.8rem 1.2rem;color:var(--primary-color);outline:none}input:focus{border-color:var(--secondary-color-9)} +layout.post-grid{margin-block:1rem}layout.post-grid a{transition:.3s all ease}layout.post-grid:has(post-tile[focus]) post-tile:not([focus]) a{opacity:.5}layout.post-grid:has(post-tile[focus]) post-tile:hover a{opacity:1}post-tile{display:block;transition:.3s all ease;position:relative;transition:all .3s ease;border-radius:var(--border-radius-medium);overflow:hidden;-webkit-tap-highlight-color:transparent;-webkit-user-select:none;user-select:none;outline:transparent solid 2px;background-color:var(--secondary-color-1)}post-tile[focus]{outline:var(--secondary-color-9) solid 2px;transform:scale(1.02)}@media (hover: hover){post-tile:hover{transform:scale(1.02);z-index:1;box-shadow:0 0 10px color-mix(in srgb,var(--secondary-color-1) 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(--secondary-color-3);color:var(--primary-color);bottom:.3rem;right:.3rem;padding:.2em .4em;height:1rem;border-radius:var(--border-radius-small);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 a{background-color:transparent;padding:0;border-radius:0}post-tile a img{height:100%;width:100%;vertical-align:top;background-color:var(--secondary-color-1)}post-tile a 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(--secondary-color-2) 100%,transparent);border-radius:var(--border-radius-small);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-4)}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-4);color:var(--secondary-color-9);border-radius:var(--border-radius-small);cursor:pointer}searchbar div.input-container ion-icon{font-size:20px;color:var(--secondary-color-4);cursor:pointer}searchbar div.input-container ion-icon:hover{color:var(--secondary-color-9)}searchbar div.selection-list-container{overflow:hidden;border-radius:var(--border-radius-small);background-color:var(--secondary-color-1);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;gap:1rem}searchbar div.selection-list-container selection-list selection:hover{background-color:color-mix(in srgb,var(--secondary-color-3) 50%,transparent)}searchbar div.selection-list-container selection-list selection.active{background-color:var(--secondary-color-3)}searchbar div.selection-list-container selection-list selection div.selection-label{display:flex;flex-wrap:wrap;gap:.5rem}searchbar div.selection-list-container selection-list selection div.selection-label .label-container{display:flex;gap:.5rem;align-items:center}searchbar div.selection-list-container selection-list selection div.selection-label .label-container ion-icon{font-size:1rem}searchbar div.selection-list-container selection-list selection div.tag-detail{display:flex;align-items:center;gap:.5rem}searchbar div.selection-list-container selection-list selection div.tag-detail .tag-post-count{font-size:.8rem}searchbar div.selection-list-container selection-list selection .tag-category,searchbar div.selection-list-container selection-list selection .user-level{padding:.1rem .4rem;border-radius:var(--border-radius-small);font-size:.9rem;background-color:var(--secondary-color-4);color:var(--secondary-color-9)}searchbar div.filter{background-color:var(--secondary-color-1);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-9);border-radius:var(--border-radius-small);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:.8rem 1.2rem}button.icon ion-icon{font-size:1.4rem;color:inherit}button.icon.vertical{flex-direction:column}ion-icon{font-size:24px;color:var(--primary-color);cursor:pointer}ion-icon:hover{color:var(--secondary-color-9)}ion-icon[disable=true]{color:var(--primary-color-darker);pointer-events:none}drawer{position:fixed;top:0;left:0;display:flex;z-index:300;height:100%;width:100%;box-sizing:border-box;justify-content:end;align-items:center;padding:1rem}drawer div.drawer-container{width:300px;max-width:70%;height:100%;background-color:var(--secondary-color-1);border-radius:var(--border-radius-large);z-index:1;overflow:hidden}drawer div.drawer-container div.user-info{background-color:var(--secondary-color-2);padding:2rem}drawer div.drawer-container div.user-info .username{margin:0;color:var(--secondary-color-9);cursor:pointer}drawer div.drawer-container div.user-info div.user-detail{display:flex;gap:.5rem;margin-top:.2rem}drawer div.drawer-container div.user-info div.user-detail span{font-size:.8rem;color:var(--primary-color-dark);display:block;cursor:pointer}drawer div.drawer-container div.user-info div.user-nav{display:grid;grid-template-columns:1fr 1fr 1fr;gap:1rem;margin-top:1rem}drawer div.drawer-container div.nav{padding:2rem;display:flex;gap:1rem;flex-direction:column}drawer div.drawer-container div.nav button.icon{justify-content:start}drawer div.filter{position:absolute;top:0;left:0;height:100%;width:100%;background:linear-gradient(90deg,color-mix(in srgb,var(--secondary-color-1) 50%,transparent),color-mix(in srgb,var(--secondary-color-0) 70%,transparent))}detail-panel{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1rem;--padding: 1rem;position:fixed;top:calc(var(--nav-height) + var(--padding));right:var(--padding);width:300px;height:calc(100dvh - 2rem - var(--nav-height));background-color:var(--secondary-color-1)}@media (max-width: 800px){detail-panel{position:static;width:100%;overflow:visible;height:100%;padding:1rem;box-sizing:border-box}}detail-panel span.no-content{color:var(--secondary-color-3);font-size:1.6rem;font-weight:900}detail-panel div.preview{overflow:hidden;border-radius:var(--border-radius-large);height:300px;width:300px;background-color:var(--secondary-color-0)}detail-panel div.preview img{height:100%;width:100%;object-fit:contain}detail-panel div.detail{display:flex;flex-direction:column;gap:.4rem;overflow:scroll;overflow-x:hidden;border-radius:var(--border-radius-large);height:100%;width:100%}detail-panel div.detail::-webkit-scrollbar{background-color:#000;width:0px}detail-panel div.detail::-webkit-scrollbar-thumb{background-color:#aeaeec}detail-panel h3{padding-left:1rem;margin-block:.6rem}detail-panel .post-info{background-color:#2f2f45;border-radius:var(--border-radius-large);padding:20px;display:flex;flex-direction:column;gap:.4rem}detail-panel .post-info .buttons{display:grid;grid-template-columns:1fr 1fr 1fr;gap:1rem;margin-top:1rem}detail-panel div.property{display:flex;gap:.6rem;align-items:center;width:100%}detail-panel div.property span.property-name{flex-shrink:0}detail-panel div.property div.property-values{display:flex;gap:.4rem;width:100%;overflow:hidden}detail-panel div.property div.property-values span.property-value{padding:.2rem .4rem;background-color:var(--secondary-color-1);color:var(--primary-color-dark);border-radius:var(--border-radius-small);justify-content:space-between;flex-shrink:1;display:flex;align-items:center;overflow:hidden}detail-panel div.property div.property-values span.property-value:has(ion-icon){flex-shrink:0}detail-panel div.property div.property-values span.property-value *{display:block;overflow:hidden;text-wrap:nowrap;text-overflow:ellipsis;flex-shrink:1}detail-panel div.property div.property-values span.property-value ion-icon{font-size:1rem;padding:4px;box-sizing:border-box}detail-panel div.inline{display:flex;gap:1rem}detail-panel div.post-tags{display:flex;flex-direction:column;gap:.2rem}detail-panel div.post-tags div.tag{align-items:center}detail-panel div.post-tags div.tag a.tag-name{word-break:break-word;text-decoration:none}detail-panel div.post-tags div.tag span.tag-post-count{background-color:var(--secondary-color-3);color:var(--secondary-color-8);padding:0 4px;border-radius:var(--border-radius-small);font-size:12px;margin-left:.4rem}detail-panel div.post-tags section.tag-name-only{display:flex;flex-wrap:wrap;column-gap:.5rem}#post{padding:0;padding-top:var(--nav-height)}#post div.viewer{height:calc(100dvh - 2rem - var(--nav-height));display:flex;justify-content:center;align-items:center;background-color:#000;border-radius:var(--border-radius-large);overflow:hidden;width:calc(100vw - 300px - 4rem);margin:1rem;position:relative;transition:all .3s ease}@media (max-width: 800px){#post div.viewer{width:100%;height:calc(100dvh - var(--nav-height));border-radius:0;margin:0}}#post div.viewer img{max-width:100%;max-height:100%;object-fit:contain;transition:all .3s ease}#post div.viewer img.loading{filter:blur(5px)}#post div.viewer video{max-width:100%;max-height:100%;-webkit-user-drag:none;transition:all .3s ease}#post div.viewer div.viewer-panel{position:absolute;bottom:0;width:100%;z-index:1}#post div.viewer div.viewer-panel div.panel{width:100%;display:flex;justify-content:center;flex-direction:column;padding:1rem;gap:1rem;box-sizing:border-box}#post div.viewer div.viewer-panel div.panel video-controller{display:flex;flex-direction:column;gap:1rem;align-items:center;width:100%}#post div.viewer div.viewer-panel div.panel video-controller div.video-details{display:flex;align-items:center;justify-content:space-between;width:100%}#post div.viewer div.viewer-panel div.panel video-controller div.video-details div{display:flex;align-items:center;gap:1rem}#post div.viewer div.viewer-panel div.panel video-controller div.progressbar-container{height:2rem;width:100%;display:flex;touch-action:none;align-items:center;cursor:pointer}#post div.viewer div.viewer-panel div.panel video-controller div.progressbar-container div.progressbar{height:.4rem;width:100%;background-color:var(--secondary-color-1);flex-shrink:1}#post div.viewer div.viewer-panel div.panel video-controller div.progressbar-container div.progressbar div.progress{height:100%;background-color:var(--secondary-color-3);width:100px}#post div.viewer div.viewer-panel div.panel video-controller .play{flex-shrink:0}#post div.viewer div.viewer-panel div.panel div.buttons{width:100%;display:flex;justify-content:center;gap:2rem}#post div.viewer div.viewer-panel div.overlay{position:absolute;bottom:0;width:100%;height:200%;z-index:-1;background:linear-gradient(180deg,color-mix(in srgb,var(--secondary-color-1) 0%,transparent),color-mix(in srgb,var(--secondary-color-0) 70%,transparent))}#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}route#login{display:flex;justify-content:center;align-items:center;margin-top:5rem}route#login .login-container{padding:2rem;border:1px solid var(--secondary-color-9);border-radius:var(--border-radius-large);display:flex;flex-direction:column;justify-content:center;gap:1rem;max-width:400px;width:100%;box-sizing:border-box}route#login .login-container h1{margin:0}route#login .login-container .input-container{display:flex;flex-direction:column;gap:.5rem}route#login .login-container .input-container input{display:block}:root{--primary-color: #d1d1ee;--primary-color-dark: #9696b3;--primary-color-darker: #72728d;--secondary-color-9: #aeaeec;--secondary-color-8: #9a9ad6;--secondary-color-7: #7c7cb8;--secondary-color-6: #646497;--secondary-color-5: #545486;--secondary-color-4: #424268;--secondary-color-3: #3b3b66;--secondary-color-2: #24243b;--secondary-color-1: #1e1e2c;--secondary-color-0: #07070c;--shadow-color: #09090e50;--border-radius-small: .4rem;--border-radius-medium: .8rem;--border-radius-large: 1.2rem;--nav-height: 50px}html{overflow-x:hidden;font-size:14px;scroll-behavior:smooth}html ::-webkit-scrollbar{background-color:var(--secondary-color-1);width:8px}html ::-webkit-scrollbar-thumb{background-color:#aeaeec;border-radius:2px}body{overflow-x:hidden;background-color:var(--secondary-color-1);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(--secondary-color-1) 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-9);margin:0}nav a.title .app{display:flex;align-items:center;border-radius:var(--border-radius-small);margin:0;gap:.4rem}nav a.title .app .version{color:var(--secondary-color-1);background-color:var(--secondary-color-9);padding:.2em .4em;border-radius:var(--border-radius-small);font-size:.8rem;font-weight:700}nav a.title .app .app-name{display:none;font-size:1rem;color:var(--secondary-color-9)}nav div.searchbar{padding:.4rem 10%;max-width:500px;background-color:color-mix(in srgb,var(--secondary-color-2) 30%,transparent);border:1px solid var(--primary-color-darker);border-radius:var(--border-radius-small);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(--secondary-color-3) 50%,transparent)}nav div.buttons ion-icon.search{display:none}nav div.buttons a{display:flex;justify-content:center;align-items:center}nav div.buttons div.account{height:2rem;width:2rem;display:flex;justify-content:center;align-items:center;border-radius:2rem;font-weight:bolder;color:var(--secondary-color-9);background-color:var(--secondary-color-4);-webkit-user-select:none;user-select:none;cursor:pointer}@media (max-width: 800px){nav div.searchbar{display:none}nav div.buttons ion-icon.search{display:inline-block}nav div.buttons ion-icon.detail-panel{display:none}}router{display:block;position:relative}router route{display:block;position:relative;padding-inline:1rem;padding-top:var(--nav-height)}route#posts header{margin-bottom:1rem}route#posts header h2{margin:0}route#posts header div.tags{display:flex;flex-wrap:wrap;gap:.5rem}route#posts .post-grid.detail-panel-enabled{width:calc(100vw - 300px - 4rem)}@media (max-width: 800px){route#posts .post-grid.detail-panel-enabled{width:100%}}@media (max-width: 800px){route#posts detail-panel{display:none}}section{background-color:#2f2f45;border-radius:var(--border-radius-large);padding:20px}button{background-color:var(--secondary-color-4);color:var(--secondary-color-9);padding:.8rem 1.2rem;border-radius:1rem;border:none;cursor:pointer}button:hover{background-color:var(--secondary-color-6);color:var(--primary-color)}a{text-decoration:none;color:var(--secondary-color-9)}input{background-color:var(--secondary-color-2);border-radius:var(--border-radius-small);border:1px solid var(--secondary-color-3);font-size:.9rem;padding:.8rem 1.2rem;color:var(--primary-color);outline:none}input:focus{border-color:var(--secondary-color-9)} diff --git a/dist/index.html b/dist/index.html index 42676f5..4b47c2b 100644 --- a/dist/index.html +++ b/dist/index.html @@ -16,8 +16,8 @@ gtag('config', 'G-59HBGP98WR'); - - + + diff --git a/package.json b/package.json index 2d37f3c..1822a4a 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "danbooru-viewer", "module": "index.ts", "type": "module", - "version": "0.10.5", + "version": "0.11.0", "scripts": { "dev": "bun x vite", "build": "bun x vite build", diff --git a/src/component/$SlideViewer.ts b/src/component/$SlideViewer.ts new file mode 100644 index 0000000..5306be7 --- /dev/null +++ b/src/component/$SlideViewer.ts @@ -0,0 +1,23 @@ +import { $Container, $Element, $PointerManager } from "elexis"; +import { $View } from "../../../elexis-ext/view"; + +export class $SlideViewer extends $Container { + pointers = new $PointerManager(this); + $container = $('div') + constructor() { + super('slide-viewer') + this.__build__(); + } + + protected __build__() { + this.content([ this.$container ]); + this.pointers.on('move', $pointer => { + const [x, y] = [$pointer.move_x, $pointer.move_y]; + this.$container.css({transform: `translate(${x}, ${y})`}); + }) + } + + addSlide(id: string, $element: $Element) { + return this; + } +} \ No newline at end of file diff --git a/src/component/DetailPanel/$DetailPanel.ts b/src/component/DetailPanel/$DetailPanel.ts index 3a1fd54..56369f9 100644 --- a/src/component/DetailPanel/$DetailPanel.ts +++ b/src/component/DetailPanel/$DetailPanel.ts @@ -37,10 +37,10 @@ export class $DetailPanel extends $Container { new $Property('favorites').name('Favorites').content(this.post.favcount$), new $Property('score').name('Score').content(this.post.score$) ]), - new $Property('file-url').name('File').content([ - $('a').href(this.post.file_url$).content(this.post.file_url$.convert((value) => value.replace('https://', ''))).target('_blank'), - $('ion-icon').name('clipboard').on('click', (e, $ion) => this.copyButtonHandler($ion, this.post!.file_url)) - ]), + this.post.file_url ? new $Property('file-url').name('File').content([ + $('a').href(this.post.file_url$).content(this.post.file_url$.convert((value) => value ? value.replace('https://', '') : '' )).target('_blank'), + $('ion-icon').name('clipboard').on('click', (e, $ion) => this.copyButtonHandler($ion, this.post!.file_url!)) + ]) : null, new $Property('source-url').name('Source').content([ $('a').href(this.post.source$).content(this.post.source$.convert((value) => value.replace('https://', ''))).target('_blank'), $('ion-icon').name('clipboard').on('click', (e, $ion) => this.copyButtonHandler($ion, this.post!.source)) @@ -56,7 +56,7 @@ export class $DetailPanel extends $Container { ]), $('div').class('post-tags').content(async $tags => { if (this.options.tagsType === 'detail') { - const tags = await this.post!.fetchTags(); + const tags = (await this.post!.fetchTags()).tags; const [artist_tags, char_tags, gen_tags, meta_tags, copy_tags] = [ tags.filter(tag => tag.category === TagCategory.Artist), tags.filter(tag => tag.category === TagCategory.Character), diff --git a/src/component/PostGrid/$PostGrid.ts b/src/component/PostGrid/$PostGrid.ts index ebb73fe..2ff7d08 100644 --- a/src/component/PostGrid/$PostGrid.ts +++ b/src/component/PostGrid/$PostGrid.ts @@ -3,33 +3,32 @@ import { Booru } from "../../structure/Booru"; import { Post } from "../../structure/Post"; import { $PostTile } from "../PostTile/$PostTile"; import { $Input } from "elexis/lib/node/$Input"; +import { PostManager } from "../../structure/PostManager"; interface $PostGridOptions { tags?: string } -export class $PostGrid extends $Layout<$PostGridEventMap> { - posts = new Set(); +export class $PostGrid extends $Layout { $posts = new Map(); - orderMap = new Map(); tags?: string; - finished = false; - limit = 100; $focus = $.focus(); + posts: PostManager; constructor(options?: $PostGridOptions) { super(); this.tags = options?.tags; + this.posts = PostManager.get(this.tags); this.addStaticClass('post-grid'); this.type('waterfall').gap(10); this.init(); } protected async init() { - setInterval(() => { if (this.inDOM() && document.documentElement.scrollTop === 0) this.getPost('newer'); }, 10000); + this.posts.events.on('post_fetch', (posts) => { this.addPost(posts) }) + setInterval(async () => { if (this.inDOM() && document.documentElement.scrollTop === 0) await this.posts.fetchPosts('newer'); }, 10000); Booru.events.on('set', () => { this.removeAll(); - if (this.finished) { - this.finished = false; - this.events.fire('startLoad'); + if (this.posts.finished) { + this.posts.finished = false; this.loader(); } }) @@ -37,7 +36,6 @@ export class $PostGrid extends $Layout<$PostGridEventMap> { // this.on('afterRender', () => { // this.$focus.currentLayer?.focus(this.$focus.currentLayer.currentFocus); // }) - this.events.fire('startLoad'); this.loader(); this.$focus.layer(100).loop(false).scrollThreshold($.rem(2) + 60); @@ -59,7 +57,7 @@ export class $PostGrid extends $Layout<$PostGridEventMap> { .keydown([' ', 'Enter'], e => { e.preventDefault(); const focused = this.$focus.currentLayer?.currentFocus; - if (focused instanceof $PostTile) $.open(`/posts/${focused.post.id}`); + if (focused instanceof $PostTile) $.open(focused.url); }) .keydown(['Escape'], e => { e.preventDefault(); this.$focus.blur(); }) } @@ -67,11 +65,11 @@ export class $PostGrid extends $Layout<$PostGridEventMap> { protected async loader() { if (!this.inDOM()) return setTimeout(() => this.loader(), 100);; while (this.inDOM() && document.documentElement.scrollHeight <= innerHeight * 2) { - const posts = await this.getPost('older'); + const posts = await this.posts.fetchPosts('older'); if (!posts.length) return; } if (document.documentElement.scrollTop + innerHeight > document.documentElement.scrollHeight - innerHeight * 2) { - const posts = await this.getPost('older'); + const posts = await this.posts.fetchPosts('older'); if (!posts.length) return; } setTimeout(() => this.loader(), 100); @@ -86,13 +84,13 @@ export class $PostGrid extends $Layout<$PostGridEventMap> { posts = $.orArrayResolve(posts); for (const post of posts) { if (!post.file_url) continue; - if (this.posts.has(post)) continue; - const $post = new $PostTile(post).on('$focus', (e, $post) => this.$focus.layer(100).focus($post)); + if (this.posts.cache.has(post)) continue; + const $post = new $PostTile(this, post).on('$focus', (e, $post) => this.$focus.layer(100).focus($post)); this.$posts.set(post, $post); - this.posts.add(post); + this.posts.cache.add(post); } this.$focus.layer(100).elementSet.clear(); - const $posts = [...this.orderMap.values()].map(post => { + const $posts = [...this.posts.orderMap.values()].map(post => { return this.$posts.get(post)?.self(this.$focus.layer(100).add) }); this.content($posts).render(); @@ -102,85 +100,9 @@ export class $PostGrid extends $Layout<$PostGridEventMap> { removeAll() { this.posts.clear(); this.$posts.clear(); - this.orderMap.clear(); this.$focus.layer(100).removeAll(); this.animate({opacity: [1, 0]}, {duration: 300, easing: 'ease'}, () => this.clear().render()) return this; } - async getPost(direction: 'newer' | 'older'): Promise { - const tags = this.tags ? decodeURIComponent(this.tags).split('+') : undefined; - const generalTags: string[] = []; - const orderTags: string[] = []; - let limit: number = this.limit; - if (tags) for (const tag of tags) { - if (tag.startsWith('ordfav:')) orderTags.push(tag); - else if (tag.startsWith('order:')) orderTags.push(tag); - else if (tag.startsWith('limit:')) limit = Number(tag.split(':')[1]); - else generalTags.push(tag); - } - if (orderTags.length) { - if (orderTags.length > 1) { - this.events.fire('post_error', `Error: These query can't be used together [${orderTags}].`) - return []; - } - const orderTag = orderTags[0]; - if (orderTag.startsWith('ordfav:')) { - const username = orderTag.split(':')[1]; - const match_tags = generalTags.length ? `&search[post_tags_match]=${generalTags.toString().replaceAll(',', '+')}` : ''; - const beforeAfter = this.orderKeyList.length ? direction === 'newer' ? `&search[id]=>${this.orderKeyList.at(0)}` : `&search[id]=<${this.orderKeyList.at(-1)}` : undefined; - const favoritesDataList = await Booru.used.fetch(`/favorites.json?search[user_name]=${username}${beforeAfter ?? ''}${match_tags}&limit=${limit}`); - const posts = await Post.fetchMultiple(Booru.used, {tags: `id:${favoritesDataList.map(data => data.post_id).toString()}`}); - const newPostOrderMap = new Map(); - for (const fav of favoritesDataList) { - const post = posts.find(post => post.id === fav.post_id); - if (!post) continue; - newPostOrderMap.set(fav.id, post); - } - this.orderMap = new Map(direction === 'newer' ? [...newPostOrderMap, ...this.orderMap] : [...this.orderMap, ...newPostOrderMap]); - this.addPost(posts); - return posts; - } - - if (orderTag.startsWith('order:')) { - const page = this.orderKeyList.length ? direction === 'newer' ? 1 : (this.orderMap.size / limit) + 1 : undefined; - const posts = await Post.fetchMultiple(Booru.used, {tags: this.tags}, limit, page); - const newPostOrderMap = new Map(posts.map(post => [post.id, post])); - newPostOrderMap.forEach((post, id) => { if (this.orderMap.has(id)) newPostOrderMap.delete(id) }); - this.orderMap = new Map(direction === 'newer' ? [...newPostOrderMap, ...this.orderMap] : [...this.orderMap, ...newPostOrderMap]) - this.addPost(posts); - return posts - } - } - - const beforeAfter = this.orderKeyList.length ? direction === 'newer' ? `a${this.orderKeyList.at(0)}` : `b${this.orderKeyList.at(-1)}` : undefined; - const posts = await Post.fetchMultiple(Booru.used, {tags: this.tags}, limit, beforeAfter); - const newPostOrderMap = new Map(posts.map(post => [post.id, post])); - this.orderMap = new Map(direction === 'newer' ? [...newPostOrderMap, ...this.orderMap] : [...this.orderMap, ...newPostOrderMap]) - this.addPost(posts); - - if (!posts.length) { - this.finished = true; - if (!this.posts.size) this.events.fire('noPost'); - else this.events.fire('endPost') - } - - return posts - } - - get orderKeyList() { return [...this.orderMap.keys()]} -} - -interface $PostGridEventMap extends $LayoutEventMap { - startLoad: []; - noPost: []; - endPost: []; - post_error: [message: string]; - -} - -interface FavoritesData { - id: id; - post_id: id; - user_id: id; } \ No newline at end of file diff --git a/src/component/PostTile/$PostTile.ts b/src/component/PostTile/$PostTile.ts index 0341a63..2935c07 100644 --- a/src/component/PostTile/$PostTile.ts +++ b/src/component/PostTile/$PostTile.ts @@ -2,13 +2,16 @@ import { $Container, $Image, $State, $Video } from "elexis"; import type { Post } from "../../structure/Post"; import { time } from "../../structure/Util"; import { detailPanelEnable$ } from "../../main"; +import type { $PostGrid } from "../PostGrid/$PostGrid"; export class $PostTile extends $Container { post: Post; $video: $Video | null; $img: $Image; duration$ = $.state(``); - constructor(post: Post) { + $grid: $PostGrid; + constructor($grid: $PostGrid, post: Post) { super('post-tile'); + this.$grid = $grid; this.post = post; this.$video = this.post.isVideo ? $('video').width(this.post.image_width).height(this.post.image_height).disablePictureInPicture(true).loop(true).muted(true).hide(true).on('mousedown', (e) => e.preventDefault()) : null; this.$img = $('img').draggable(false).css({opacity: '0'}).width(this.post.image_width).height(this.post.image_height).src(this.post.previewURL).loading('lazy'); @@ -35,7 +38,7 @@ export class $PostTile extends $Container { $('span').content('GIF') ]) : null, // Tile - $('a').href(this.post.pathname).preventDefault(detailPanelEnable$).content(() => [ + $('a').href(this.url).preventDefault(detailPanelEnable$).content(() => [ this.$video, this.$img.on('mousedown', (e) => e.preventDefault()) .once('load', (e, $img) => { @@ -67,4 +70,6 @@ export class $PostTile extends $Container { const t = time(this.post.media_asset.duration * 1000 - this.$video.currentTime() * 1000) this.duration$.set(Number(t.hh) > 0 ? `${t.hh}:${t.mm}:${t.ss}` : `${t.mm}:${t.ss}`) } + + get url() { return `${this.post.pathname}${this.$grid.tags ? `?q=${this.$grid.tags}` : ''}` } } \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index 5078352..b7fc1dc 100644 --- a/src/main.ts +++ b/src/main.ts @@ -112,9 +112,11 @@ $(document.body).content([ ]), $('div').class('no-post').hide(true).self($div => { $div.on('startLoad', () => $div.hide(true)) - $postGrid - .on('noPost', () => $div.hide(false).content('No Posts')) - .on('post_error', message => $div.hide(false).content(message)) + $postGrid.self(() => { + $postGrid.posts.events + .on('noPost', () => $div.hide(false).content('No Posts')) + .on('post_error', message => $div.hide(false).content(message)) + }) }), $postGrid, $detail diff --git a/src/route/post/$post_route.ts b/src/route/post/$post_route.ts index 375f93b..a9e96f4 100644 --- a/src/route/post/$post_route.ts +++ b/src/route/post/$post_route.ts @@ -5,19 +5,22 @@ import { ClientUser } from "../../structure/ClientUser"; import { $VideoController } from "../../component/VideoController/$VideoController"; import { $Input } from "elexis/lib/node/$Input"; import { $DetailPanel } from "../../component/DetailPanel/$DetailPanel"; +import { PostManager } from "../../structure/PostManager"; -export const post_route = $('route').path('/posts/:id').id('post').builder(({$route, params}) => { +export const post_route = $('route').path('/posts/:id?q').id('post').static(false).builder(({$route, params}) => { if (!Number(params.id)) return $('h1').content('404: POST NOT FOUND'); - const post = Post.get(Booru.used, +params.id); const $video = $('video'); const events = $.events<{ viewerPanel_hide: [], viewerPanel_show: [], viewerPanel_switch: [], original_size: [], - video_play_pause: [] + video_play_pause: [], + post_switch: [Post] }>(); - $.keys($(window)) + let post: Post, posts: PostManager | undefined; + events.on('video_play_pause', () => { if ($video.isPlaying) $video.pause(); else $video.play() }) + $.keys($(window)).self($keys => $keys .if(e => { if ($(e.target) instanceof $Input) return; if (!$route.inDOM()) return; @@ -32,10 +35,44 @@ export const post_route = $('route').path('/posts/:id').id('post').builder(({$ro if ($video.isPlaying) $video.pause(); else $video.play(); }) + .keydown(['a', 'A'], e => navPost('prev') ) + .keydown(['d', 'D'], e => { navPost('next') }) + ) + + $route.on('open', ({params, query}) => { + posts = query.q?.includes('order:') ? undefined : PostManager.get(query.q); + post = Post.get(Booru.used, +params.id); + if (posts) { + if (!posts.orderMap.size || !posts.cache.has(post)) { + posts.cache.add(post); + posts.orderMap.set(post.id, post); + posts.fetchPosts('newer'); + posts.fetchPosts('older'); + } else { + const ordered = [...posts.orderMap.values()]; + const index = ordered.indexOf(post); + if (!posts.finished && index > ordered.length - posts.limit / 2) { + posts.fetchPosts('older'); + } else if (index === 0) { + posts.fetchPosts('newer'); + } + } + } + events.fire('post_switch', post); + }) + + function navPost(dir: 'next' | 'prev') { + if (!posts) return; + const orderList = [...posts.orderMap.values()]; + const index = orderList.indexOf(post); + if (dir === 'prev' && index === 0) return; + const targetPost = orderList.at(dir === 'next' ? index + 1 : index - 1); + if (!targetPost) return; + $.replace(`/posts/${targetPost.id}${posts.tags ? `?q=${posts.tags}` : ''}`) + } + return [ - $('div').class('viewer').content(async ($viewer) => { - events.on('video_play_pause', () => { if ($video.isPlaying) $video.pause(); else $video.play() }) - await post.ready; + $('div').class('viewer').self(async ($viewer) => { $viewer .on('pointermove', (e) => { if (e.pointerType === 'mouse' || e.pointerType === 'pen') events.fire('viewerPanel_show'); @@ -48,55 +85,66 @@ export const post_route = $('route').path('/posts/:id').id('post').builder(({$ro .on('mouseleave', () => { events.fire('viewerPanel_hide'); }) - return [ - $('div').class('viewer-panel').hide(false) - .content([ - $('div').class('panel').content([ - post.isVideo ? new $VideoController($video, $viewer, post) : null, - $('div').class('buttons').content([ - $('ion-icon').title('Favorite').name('heart-outline').self($heart => { - ClientUser.events.on('favoriteUpdate', (user) => { - if (user.favorites.has(post.id)) $heart.name('heart'); - else $heart.name('heart-outline'); + events.on('post_switch', async post => { + await post.ready; + $viewer.content([ + $('div').class('viewer-panel').hide(false) + .content([ + $('div').class('panel').content([ + post.isVideo ? new $VideoController($video, $viewer, post) : null, + $('div').class('buttons').content([ + $('ion-icon').title('Favorite').name('heart-outline').self($heart => { + ClientUser.events.on('favoriteUpdate', (user) => { + if (user.favorites.has(post.id)) $heart.name('heart'); + else $heart.name('heart-outline'); + }) + if (Booru.used.user?.favorites.has(post.id)) $heart.name('heart'); + $heart.on('click', () => { + if (Booru.used.user?.favorites.has(post.id)) post.deleteFavorite(); + else post.createFavorite(); + }) + }), + $('ion-icon').title('Original Size').name('resize-outline').self($original => { + $original.on('click', () => { events.fire('original_size'); $original.disable(true); }) + if (!post.isLargeFile || post.isVideo) $original.disable(true); }) - if (Booru.used.user?.favorites.has(post.id)) $heart.name('heart'); - $heart.on('click', () => { - if (Booru.used.user?.favorites.has(post.id)) post.deleteFavorite(); - else post.createFavorite(); - }) - }), - $('ion-icon').title('Original Size').name('resize-outline').self($original => { - $original.on('click', () => { events.fire('original_size'); $original.disable(true); }) - if (!post.isLargeFile || post.isVideo) $original.disable(true); - }) - ]) - ]), - $('div').class('overlay') - ]) - .self($viewerPanel => { - events.on('viewerPanel_hide', () => $viewerPanel.hide(true)) - .on('viewerPanel_show', () => $viewerPanel.hide(false)) - .on('viewerPanel_switch', () => $viewerPanel.hide(!$viewerPanel.hide())) - }), - post.isVideo - ? $video.height(post.image_height).width(post.image_width).src(post.file_ext === 'zip' ? post.large_file_url : post.file_url).controls(false).autoplay(true).loop(true).disablePictureInPicture(true) - : $('img').src(post.isLargeFile ? post.large_file_url : post.file_url).self($img => { - events.on('original_size', () => $img.src(post.file_url)) - }) - ] + ]) + ]), + $('div').class('overlay') + ]) + .self($viewerPanel => { + events.on('viewerPanel_hide', () => $viewerPanel.hide(true)) + .on('viewerPanel_show', () => $viewerPanel.hide(false)) + .on('viewerPanel_switch', () => $viewerPanel.hide(!$viewerPanel.hide())) + }), + post.isVideo + ? $video.height(post.image_height).width(post.image_width).src(post.file_ext === 'zip' ? post.large_file_url : post.file_url).controls(false).autoplay(true).loop(true).disablePictureInPicture(true) + : $('img').height(post.image_height).width(post.image_width).self($img => { + $img.once('load', () => + $img.once('load', () => $img.removeClass('loading')).src(post.isLargeFile ? post.large_file_url : post.file_url) + ).src(post.preview_file_url) + if (!$img.complete) $img.class('loading') + events.on('original_size', () => $img.src(post.file_url)) + }) + ]) + }) }), $('div').class('content').content([ $('h3').content(`Artist's Commentary`), - $('section').class('commentary').content(async ($comentary) => { - const commentary = (await ArtistCommentary.fetchMultiple(Booru.used, {post: {_id: post.id}})).at(0); - return [ - commentary ? [ - commentary.original_title ? $('h3').content(commentary.original_title) : null, - $('pre').content(commentary.original_description) - ] : 'No commentary' - ] + $('section').class('commentary').self(async ($comentary) => { + events.on('post_switch', async post => { + const commentary = (await ArtistCommentary.fetchMultiple(Booru.used, {post: {_id: post.id}})).at(0); + $comentary.content([ + commentary ? [ + commentary.original_title ? $('h3').content(commentary.original_title) : null, + $('pre').content(commentary.original_description) + ] : 'No commentary' + ]) + }) }) ]), - new $DetailPanel().position($route).update(post) + new $DetailPanel().position($route).self($detail => { + events.on('post_switch', (post) => $detail.update(post)) + }) ] }) \ No newline at end of file diff --git a/src/route/post/_$post_route.scss b/src/route/post/_$post_route.scss index 7cffcea..c0714fc 100644 --- a/src/route/post/_$post_route.scss +++ b/src/route/post/_$post_route.scss @@ -25,7 +25,12 @@ img { max-width: 100%; max-height: 100%; - // transition: all 0.3s ease; + object-fit: contain; + transition: all 0.3s ease; + + &.loading { + filter: blur(5px); + } } video { diff --git a/src/structure/Post.ts b/src/structure/Post.ts index 33f6058..b869e1c 100644 --- a/src/structure/Post.ts +++ b/src/structure/Post.ts @@ -17,7 +17,7 @@ export class Post extends $EventManager<{update: []}> { score$ = $.state(0); file_size$ = $.state(LOADING_STRING); file_ext$ = $.state(LOADING_STRING); - file_url$ = $.state(LOADING_STRING); + file_url$ = $.state(LOADING_STRING); source$ = $.state(LOADING_STRING); dimension$ = $.state(LOADING_STRING); booruUrl$ = $.state(LOADING_STRING); @@ -61,13 +61,16 @@ export class Post extends $EventManager<{update: []}> { } const dataArray = await booru.fetch(`/posts.json?limit=${limit}&tags=${tagsQuery}${page ? `&page=${page}` : ''}&_method=get`); if (dataArray instanceof Array === false) return []; + const tagnameSet = new Set(); const list = dataArray.map(data => { const instance = booru.posts.get(data.id)?.update(data) ?? new this(booru, data.id, data); booru.posts.set(instance.id, instance); + instance.tag_string.split(' ').forEach(tag_name => tagnameSet.add(tag_name)) return instance; }); if (!list.length) return list; const userIds = [...new Set(dataArray.map(data => [data.approver_id, data.uploader_id].detype(null)).flat())]; + // Tag.fetchMultiple(booru, {name: tagnameSet.array.toString().replaceAll(',', ' ')}); User.fetchMultiple(booru, {id: userIds}).then(() => list.forEach(post => post.update$())); return list; } @@ -97,7 +100,10 @@ export class Post extends $EventManager<{update: []}> { async fetchTags() { await this.ready; - return await Tag.fetchMultiple(this.booru, {name: {_space: this.tag_string}}); + const uncached_tags = this.tag_string.split(' ').filter(tag_name => !Tag.get(this.booru, tag_name)); + if (!uncached_tags.length) return this; + await Tag.fetchMultiple(this.booru, {name: {_space: uncached_tags.toString().replaceAll(',', ' ')}}); + return this; } async createFavorite() { @@ -182,7 +188,7 @@ export interface PostData extends PostOptions { "tag_string_copyright": string, "tag_string_artist": string, "tag_string_meta": string, - "file_url": string, + "file_url"?: string, "large_file_url": string, "preview_file_url": string } diff --git a/src/structure/PostManager.ts b/src/structure/PostManager.ts new file mode 100644 index 0000000..c949356 --- /dev/null +++ b/src/structure/PostManager.ts @@ -0,0 +1,105 @@ +import { $EventManager } from "elexis"; +import { Post } from "./Post"; +import { Booru } from "./Booru"; + +export class PostManager { + static managers = new Map(); + orderMap = new Map(); + cache = new Set(); + limit = 100; + tags?: string; + finished = false; + events = new $EventManager(); + constructor(tags?: string) { + this.tags = tags; + PostManager.managers.set(this.tags, this); + } + + static get(tags: string | undefined) { + const manager = this.managers.get(tags) ?? new PostManager(tags); + this.managers.set(manager.tags, manager); + return manager; + } + + clear() { + this.orderMap.clear(); + this.cache.clear(); + } + + async fetchPosts(direction: 'newer' | 'older'): Promise { + const tags = this.tags ? decodeURIComponent(this.tags).split('+') : undefined; + const generalTags: string[] = []; + const orderTags: string[] = []; + let limit: number = this.limit; + let posts: Post[] = []; + if (tags) for (const tag of tags) { + if (tag.startsWith('ordfav:')) orderTags.push(tag); + else if (tag.startsWith('order:')) orderTags.push(tag); + else if (tag.startsWith('limit:')) limit = Number(tag.split(':')[1]); + else generalTags.push(tag); + } + if (orderTags.length) { + if (orderTags.length > 1) { + this.events.fire('post_error', `Error: These query can't be used together [${orderTags}].`) + return []; + } + const orderTag = orderTags[0]; + if (orderTag.startsWith('ordfav:')) { + const username = orderTag.split(':')[1]; + const match_tags = generalTags.length ? `&search[post_tags_match]=${generalTags.toString().replaceAll(',', '+')}` : ''; + const beforeAfter = this.orderKeyList.length ? direction === 'newer' ? `&search[id]=>${this.orderKeyList.at(0)}` : `&search[id]=<${this.orderKeyList.at(-1)}` : undefined; + const favoritesDataList = await Booru.used.fetch(`/favorites.json?search[user_name]=${username}${beforeAfter ?? ''}${match_tags}&limit=${limit}`); + posts = await Post.fetchMultiple(Booru.used, {tags: `id:${favoritesDataList.map(data => data.post_id).toString()}`}); + const newPostOrderMap = new Map(); + for (const fav of favoritesDataList) { + const post = posts.find(post => post.id === fav.post_id); + if (!post) continue; + if (!post.file_url) continue; + newPostOrderMap.set(fav.id, post); + } + this.orderMap = new Map(direction === 'newer' ? [...newPostOrderMap, ...this.orderMap] : [...this.orderMap, ...newPostOrderMap]); + this.events.fire('post_fetch', posts); + return posts; + } + + if (orderTag.startsWith('order:')) { + const page = this.orderKeyList.length ? direction === 'newer' ? 1 : (this.orderMap.size / limit) + 1 : undefined; + posts = await Post.fetchMultiple(Booru.used, {tags: this.tags}, limit, page); + const newPostOrderMap = new Map(posts.filter(post => post.file_url).map(post => [post.id, post])); + newPostOrderMap.forEach((post, id) => { if (this.orderMap.has(id)) newPostOrderMap.delete(id) }); + this.orderMap = new Map(direction === 'newer' ? [...newPostOrderMap, ...this.orderMap] : [...this.orderMap, ...newPostOrderMap]) + this.events.fire('post_fetch', posts); + } + } else { + const beforeAfter = this.orderKeyList.length ? direction === 'newer' ? `a${this.orderKeyList.at(0)}` : `b${this.orderKeyList.at(-1)}` : undefined; + posts = await Post.fetchMultiple(Booru.used, {tags: this.tags}, limit, beforeAfter); + const newPostOrderMap = new Map(posts.filter(post => post.file_url).map(post => [post.id, post])); + this.orderMap = new Map(direction === 'newer' ? [...newPostOrderMap, ...this.orderMap] : [...this.orderMap, ...newPostOrderMap]) + } + + if (!posts.length) { + this.finished = true; + if (!this.cache.size) this.events.fire('noPost'); + else this.events.fire('endPost') + } + + this.events.fire('post_fetch', posts); + return posts + } + + get orderKeyList() { return [...this.orderMap.keys()]} +} + +interface PostManagerEventMap { + startLoad: []; + noPost: []; + endPost: []; + post_error: [message: string]; + post_fetch: [Post[]]; +} + +interface FavoritesData { + id: id; + post_id: id; + user_id: id; +} \ No newline at end of file diff --git a/src/structure/Tag.ts b/src/structure/Tag.ts index f9cfef0..011300f 100644 --- a/src/structure/Tag.ts +++ b/src/structure/Tag.ts @@ -1,4 +1,4 @@ -import type { Booru } from "./Booru"; +import { Booru } from "./Booru"; export interface TagOptions {} export interface Tag extends TagData {} @@ -41,6 +41,10 @@ export class Tag { return list; } + static get(booru: Booru, name: string) { + return [...booru.tags.values()].find(tag => tag.name === name); + } + update(data: TagData) { Object.assign(this, data); this.$update();