(()=>{class i extends HTMLElement{constructor(){super(),this.hasAttribute("draw")||this.init()}drawComplete(){this.setAttribute("draw",!0)}}document.addEventListener("DOMContentLoaded",()=>{customElements.define("mew-hide",class extends i{init(){var t=$(this),i=t.closest(".main-content");this.options={target:i.attr("data-target"),id:i.attr("data-id")},this.options.target&&this.options.id&&((i=(i=localStorage.getItem(window.encrypt("mew-hide-"+this.options.target)))?JSON.parse(window.decrypt(i)):[]).includes(this.options.id)?(t.before(this.innerHTML),t.remove()):(i=0!==t.find("h1,h2,h3,h4,h5").length,this.setAttribute("hide",window.encrypt(this.innerHTML)),this.innerHTML="",i&&(this.setAttribute("toc",!0),commonContext.initTocAndNotice()),this.onclick=function(){var t=$(`halo-comment[id='${this.options.id}'][type='${this.options.target.substring(0,this.options.target.length-1)}']`);0===t.length||t.is(":hidden")||Utils.animateScroll(t[0],20,(window.innerHeight||document.documentElement.clientHeight)/4)})),this.drawComplete()}}),customElements.define("mew-subtitle",class extends i{init(){this.innerHTML=`${this.innerText||"默认标题"}`,this.drawComplete()}}),customElements.define("mew-music",class i extends HTMLElement{constructor(){super(),this.innerHTML="音乐播放器加载中...",this.options={container:this,theme:this.getAttribute("theme")||"var(--theme)",loop:this.getAttribute("loop")||"all",autoplay:this.hasAttribute("autoplay")&&"false"!==this.getAttribute("autoplay"),lrcType:3},"APlayer"in window?this.render():i.prototype.load?i.prototype.await.push(()=>this.render()):(i.prototype.load=!0,i.prototype.await=[],new Promise(t=>{$("head").append(''),Utils.cachedScript("https://unpkg.com/aplayer@1.10.1/dist/APlayer.min.js").done(()=>t()).fail(()=>t())}).then(()=>{this.render(),i.prototype.await&&i.prototype.await.forEach(t=>t())}))}render(){"APlayer"in window?new Promise(async t=>{if(this.hasAttribute("song"))this.options.audio=await fetch("https://api.i-meto.com/meting/api?server=netease&type=song&id="+this.getAttribute("song")).then(t=>t.json());else if(this.hasAttribute("playlist"))this.options.listFolded=this.getAttribute("fold"),this.options.order=this.getAttribute("order"),this.options.audio=await fetch("https://api.i-meto.com/meting/api?server=netease&type=playlist&id="+this.getAttribute("playlist")).then(t=>t.json());else{if(!this.hasAttribute("url"))return this.innerHTML="未指定播放的音乐!",t();this.options.audio=[{name:this.getAttribute("name")||"音乐",url:this.getAttribute("url"),artist:this.getAttribute("artist")||"未知歌手",cover:this.getAttribute("cover"),lrc:this.getAttribute("lrc")||(this.options.lrcType=void 0)}]}this.aplayer=new APlayer(this.options),t()}):this.innerHTML="未开启音乐播放器!"}disconnectedCallback(){this.aplayer&&this.aplayer.destroy()}}),customElements.define("mew-bilibili",class extends i{init(){this.options={bvid:this.getAttribute("bvid"),width:/^\d{1,3}%$/.test(this.getAttribute("width"))?this.getAttribute("width"):"100%"},this.options.bvid?(this.style.padding=`calc(${this.options.width} * 0.3) 0`,this.innerHTML=``):this.innerHTML="bvid未填写!",this.drawComplete()}}),customElements.define("mew-tabs",class extends i{init(){var t=$(this).children("mew-tab-page");if(0===t.length)this.innerHTML="没有标签页!";else{let s="",o="",n=!1;t.each((t,i)=>{var e=i.getAttribute("title")||"默认标签",t=t+"-"+(new Date).getTime();!n&&i.hasAttribute("active")?(n=!0,s+=`
${e}
`,o+=`
${i.innerHTML}
`):(s+=`
${e}
`,o+=`
${i.innerHTML}
`)}),this.innerHTML=`
${s}
${o}
`,n||$(this).find("div>div:first-child").addClass("active")}this.drawComplete()}connectedCallback(){$(this).find(".tabs-head").on("click","div:not(.active)",function(){var t=$(this).parent().parent();t.find(".active").removeClass("active"),$(this).addClass("active"),t.find($(this).attr("data-id")).addClass("active")})}}),customElements.define("mew-cloud",class extends i{init(){this.options={type:this.getAttribute("type")||"default",title:this.innerText||"资源文件分享",url:this.getAttribute("url"),password:this.getAttribute("password")};var t={default:"网络来源",360:"360云盘",bd:"百度网盘",wy:"微云",ali:"阿里云盘",github:"Github仓库",gitee:"Gitee仓库",lz:"蓝奏云网盘"};this.innerHTML=`
${this.options.title}
来源:${t[this.options.type]||"网络来源"}${this.options.password?" | 提取码:"+this.options.password:""}
`,this.drawComplete()}}),customElements.define("mew-progress",class extends i{init(){this.options={value:/^\d{1,3}%$/.test(this.getAttribute("value"))?this.getAttribute("value"):"50%",color:this.getAttribute("color")||"var(--theme)"},this.innerHTML=`
${this.options.value}
`,this.drawComplete()}}),customElements.define("mew-panel",class extends i{init(){this.options={title:this.getAttribute("title")||"",color:this.getAttribute("color")||"var(--theme)"},this.innerHTML=`
${this.options.title}
${this.innerHTML}
`,this.style.background=this.options.color,this.style.color=this.options.color,this.drawComplete()}}),customElements.define("mew-message",class extends i{init(){this.options={type:/^(success|info|warning|error)$/.test(this.getAttribute("type"))?this.getAttribute("type"):"info",content:this.innerHTML||"消息内容"},this.innerHTML=this.options.content,this.setAttribute("type",this.options.type),this.drawComplete()}}),customElements.define("mew-hr",class extends i{init(){this.startColor=this.getAttribute("startColor")||"#01d0ff",this.endColor=this.getAttribute("endColor")||"#fc3e85",this.style.backgroundImage=`repeating-linear-gradient(-45deg, ${this.startColor} 0,${this.startColor} 20%, transparent 0,transparent 35%, ${this.endColor} 0,${this.endColor} 65%, transparent 0,transparent 80%, ${this.startColor} 0,${this.startColor} 100%)`,this.drawComplete()}}),customElements.define("mew-timeline",class extends i{init(){let t="",i=this.firstChild;for(;i;){var e;"MEW-TIMELINE-TITLE"===i.tagName?t+=`
${i.innerHTML}
`:"MEW-TIMELINE-ITEM"===i.tagName&&(i.getAttribute("type"),e=i.getAttribute("title")?`${i.getAttribute("title")}`:"",t+=`
${e}
${i.innerHTML}
`),i=i.nextElementSibling}this.innerHTML=t,this.drawComplete()}}),customElements.define("mew-btn",class extends i{init(){this.options={color:this.getAttribute("color")||"var(--theme)",href:this.getAttribute("href"),target:this.getAttribute("target")||"_blank",icon:this.getAttribute("icon")},this.innerHTML=`${this.options.icon?``:""}${this.innerHTML}`;var t=this.querySelector("a.mew-btn");this.options.href&&(t.href=this.options.href,t.target=this.options.target),this.drawComplete()}}),customElements.define("mew-quote",class extends i{init(){this.options={avatar:this.getAttribute("avatar"),href:this.getAttribute("href"),name:this.getAttribute("name")};var t=this.options.avatar?``:"",i=this.options.name?`${this.options.name}`:"";this.innerHTML=`
${t}

${this.innerHTML}

${i}
`,this.drawComplete()}}),customElements.define("mew-link",class extends i{async init(){this.options={img:this.getAttribute("img"),href:this.getAttribute("href")||"",title:this.getAttribute("title"),slug:this.getAttribute("slug"),id:this.getAttribute("id"),type:this.getAttribute("type")||"post",desc:this.innerHTML},(this.options.id||this.options.slug)&&await Utils.request({url:this.options.id?`/api/content/${this.options.type}s/`+this.options.id:`/api/content/${this.options.type}s/slug?slug=`+this.options.slug,method:"GET"}).then(t=>{this.options.img=this.options.img||t.thumbnail,this.options.href=this.options.title||t.fullPath,this.options.title=this.options.title||t.title,this.options.desc=this.options.desc||t.summary}).catch(t=>{this.options.desc="Error: "+t});var t=this.options.img?``:"",i=this.options.desc?`${this.options.desc}`:`${this.options.href}`;this.innerHTML=`

${this.options.title||"我分享了一个网站"}

${i}
${t}
`,this.drawComplete()}}),customElements.define("mew-video",class extends i{init(){this.options={src:this.getAttribute("src"),type:this.getAttribute("type"),autoplay:this.hasAttribute("autoplay")&&"false"!==this.getAttribute("autoplay"),controls:"false"!==this.getAttribute("controls"),loop:this.hasAttribute("loop")&&"false"!==this.getAttribute("loop"),muted:this.hasAttribute("muted")&&"false"!==this.getAttribute("muted"),preload:this.hasAttribute("preload")&&"false"!==this.getAttribute("preload"),poster:this.getAttribute("poster"),width:/^\d{1,3}%$/.test(this.getAttribute("width"))?this.getAttribute("width"):"100%"},this.innerHTML=``,this.drawComplete()}}),customElements.define("mew-photos",class t extends i{init(){$.fn.justifiedGallery?this.render():t.prototype.load?t.prototype.await.push(()=>this.render()):(t.prototype.load=!0,t.prototype.await=[],new Promise(t=>{Utils.cachedScript("https://unpkg.com/justifiedGallery@3.8.1/dist/js/jquery.justifiedGallery.min.js").done(()=>t()).fail(()=>t())}).then(()=>{this.render(),t.prototype.await&&t.prototype.await.forEach(t=>t())}))}render(){this.options={captions:this.hasAttribute("captions")&&"false"!==this.getAttribute("captions"),margins:this.getAttribute("margins")||"4"},$(this).find("img").each((t,i)=>{$(i).wrap(`
`)}),$(this).justifiedGallery({captions:this.options.captions,margins:this.options.margins}),this.drawComplete()}}),customElements.define("mew-raw",class extends i{init(){var t=this.innerHTML;this.innerHTML="",this.attachShadow({mode:"closed"}).innerHTML=t,this.drawComplete()}})})})();