/*! * artplayer-plugin-danmuku.js v5.2.0 * Github: https://github.com/zhw2590582/ArtPlayer * (c) 2017-2026 Harvey Zack * Released under the MIT License. */ !function(t,e,i,a,n,o,s,r){var l="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:"u">typeof global?global:{},d="function"==typeof l[a]&&l[a],p=d.i||{},u=d.cache||{},h="u">typeof module&&"function"==typeof module.require&&module.require.bind(module);function m(e,i){if(!u[e]){if(!t[e]){if(n[e])return n[e];var o="function"==typeof l[a]&&l[a];if(!i&&o)return o(e,!0);if(d)return d(e,!0);if(h&&"string"==typeof e)return h(e);var s=Error("Cannot find module '"+e+"'");throw s.code="MODULE_NOT_FOUND",s}p.resolve=function(i){var a=t[e][1][i];return null!=a?a:i},p.cache={};var r=u[e]=new m.Module(e);t[e][0].call(r.exports,p,r,r.exports,l)}return u[e].exports;function p(t){var e=p.resolve(t);if(!1===e)return{};if(Array.isArray(e)){var i={__esModule:!0};return e.forEach(function(t){var e=t[0],a=t[1],n=t[2]||t[0],o=m(a);"*"===e?Object.keys(o).forEach(function(t){"default"===t||"__esModule"===t||Object.prototype.hasOwnProperty.call(i,t)||Object.defineProperty(i,t,{enumerable:!0,get:function(){return o[t]}})}):"*"===n?Object.defineProperty(i,e,{enumerable:!0,value:o}):Object.defineProperty(i,e,{enumerable:!0,get:function(){return"default"===n?o.__esModule?o.default:o:o[n]}})}),i}return m(e)}}m.isParcelRequire=!0,m.Module=function(t){this.id=t,this.bundle=m,this.require=h,this.exports={}},m.modules=t,m.cache=u,m.parent=d,m.distDir=void 0,m.publicUrl=void 0,m.devServer=void 0,m.i=p,m.register=function(e,i){t[e]=[function(t,e){e.exports=i},{}]},Object.defineProperty(m,"root",{get:function(){return l[a]}}),l[a]=m;for(var c=0;ctypeof module?module.exports=f:"function"==typeof define&&define.amd&&define(function(){return f})}}({"666Ok":[function(t,e,i,a){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(i),n.export(i,"default",()=>u);var o=t("./danmuku"),s=n.interopDefault(o),r=t("./heatmap"),l=n.interopDefault(r),d=t("./setting"),p=n.interopDefault(d);function u(t){return e=>{let i=new(0,s.default)(e,t),a=new(0,p.default)(e,i);return i.option.heatmap&&(0,l.default)(e,i,i.option.heatmap),{name:"artplayerPluginDanmuku",emit:i.emit.bind(i),load:i.load.bind(i),config:i.config.bind(i),hide:i.hide.bind(i),show:i.show.bind(i),reset:i.reset.bind(i),mount:a.mount.bind(a),get option(){return i.option},get isHide(){return i.isHide},get isStop(){return i.isStop}}}}u.icons=p.default.icons,"u">typeof window&&(window.artplayerPluginDanmuku=u)},{"./danmuku":"g81Wu","./heatmap":"hjtgU","./setting":"ho690","@parcel/transformer-js/src/esmodule-helpers.js":"6ykb1"}],g81Wu:[function(t,e,i,a){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(i);var o=t("bundle-text:./worker"),s=n.interopDefault(o),r=t("./bilibili");class l{constructor(t,e){const{constructor:i,template:a}=t;this.utils=i.utils,this.validator=i.validator,this.$danmuku=a.$danmuku,this.$player=a.$player,this.art=t,this.queue=[],this.$refs=[],this.isStop=!1,this.isHide=!1,this.timer=null,this.index=0,this.option=l.option,this.states={wait:[],ready:[],emit:[],stop:[]},this.config(e,!0);const n=new Blob([s.default.replace("export{e as default};","")],{type:"application/javascript"});this.worker=new Worker(URL.createObjectURL(n)),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this.reset=this.reset.bind(this),this.resize=this.resize.bind(this),this.destroy=this.destroy.bind(this),t.on("video:play",this.start),t.on("video:playing",this.start),t.on("video:pause",this.stop),t.on("video:waiting",this.stop),t.on("destroy",this.destroy),t.on("resize",this.resize),this.load()}static get option(){return{danmuku:[],speed:5,margin:[10,"25%"],opacity:1,color:"#FFFFFF",mode:0,modes:[0,1,2],fontSize:25,antiOverlap:!0,synchronousPlayback:!1,mount:void 0,heatmap:!1,width:512,points:[],filter:()=>!0,beforeEmit:()=>!0,beforeVisible:()=>!0,visible:!0,emitter:!0,maxLength:200,lockTime:5,theme:"dark",OPACITY:{},FONT_SIZE:{},MARGIN:{},SPEED:{},COLOR:[]}}static get scheme(){return{danmuku:"array|function|string",speed:"number",margin:"array",opacity:"number",color:"string",mode:"number",modes:"array",fontSize:"number|string",antiOverlap:"boolean",synchronousPlayback:"boolean",mount:"?htmldivelement|string",heatmap:"object|boolean",width:"number",points:"array",filter:"function",beforeEmit:"function",beforeVisible:"function",visible:"boolean",emitter:"boolean",maxLength:"number",lockTime:"number",theme:"string",OPACITY:"object",FONT_SIZE:"object",MARGIN:"object",SPEED:"object",COLOR:"array"}}static get cssText(){return` user-select: none; position: absolute; white-space: pre; pointer-events: none; perspective: 500px; display: inline-block; will-change: transform; font-weight: normal; line-height: 1.125; visibility: hidden; font-family: SimHei, "Microsoft JhengHei", Arial, Helvetica, sans-serif; text-shadow: rgb(0, 0, 0) 1px 0px 1px, rgb(0, 0, 0) 0px 1px 1px, rgb(0, 0, 0) 0px -1px 1px, rgb(0, 0, 0) -1px 0px 1px; `}get isRotate(){return this.art.plugins?.autoOrientation?.state}get marginTop(){let{clamp:t}=this.utils,e=this.option.margin[0],{clientHeight:i}=this.$player;return"number"==typeof e?t(e,0,i):"string"==typeof e&&e.endsWith("%")?t(i*(Number.parseFloat(e)/100),0,i):l.option.margin[0]}get marginBottom(){let{clamp:t}=this.utils,e=this.option.margin[1],{clientHeight:i}=this.$player;return"number"==typeof e?t(e,0,i):"string"==typeof e&&e.endsWith("%")?t(i*(Number.parseFloat(e)/100),0,i):l.option.margin[1]}get fontSize(){let{clamp:t}=this.utils,{clientHeight:e}=this.$player,i=this.option.fontSize;return"number"==typeof i?Math.round(t(i,12,e)):"string"==typeof i&&i.endsWith("%")?Math.round(t(e*(Number.parseFloat(i)/100),12,e)):l.option.fontSize}get $ref(){let t=this.$refs.pop()||document.createElement("div");return t.style.cssText=l.cssText,t.dataset.mode="",t.dataset.id="",t.className="",t}get readys(){let{currentTime:t}=this.art,e=[];return this.filter("ready",t=>e.push(t)),this.filter("wait",i=>{t+.1>=i.time&&i.time>=t-.1&&e.push(i)}),e}get visibles(){let t=[],{clientWidth:e}=this.$player,i=this.getLeft(this.$player);return this.filter("emit",a=>{let n=a.$ref.offsetTop,o=this.getLeft(a.$ref)-i,s=a.$ref.clientHeight,r=a.$ref.clientWidth,l=o+r,d=l/a.$restTime,p={};p.top=n,p.left=o,p.height=s,p.width=r,p.right=e-l,p.speed=d,p.distance=l,p.time=a.$restTime,p.mode=a.mode,t.push(p)}),t}get speed(){return this.option.synchronousPlayback&&this.art.playbackRate?this.option.speed/Number(this.art.playbackRate):this.option.speed}async load(t){let{errorHandle:e}=this.utils,i=[],a=t||this.option.danmuku;try{"function"==typeof a?i=await a():a instanceof Promise?i=await a:"string"==typeof a?i=await (0,r.bilibiliDanmuParseFromUrl)(a):Array.isArray(a)&&(i=a),e(Array.isArray(i),"Danmuku need return an array as result"),void 0===t&&(this.reset(),this.queue=[],this.states={wait:[],ready:[],emit:[],stop:[]},this.$refs=[],this.$danmuku.textContent="");for(let t=0;tJSON.stringify(this.option[e])!==JSON.stringify(t[e]))||e)&&(this.option=Object.assign({},l.option,this.option,t),this.validator(this.option,l.scheme),this.option.mode=i(this.option.mode,0,2),this.option.speed=i(this.option.speed,1,10),this.option.opacity=i(this.option.opacity,0,1),this.option.lockTime=i(this.option.lockTime,1,60),this.option.maxLength=i(this.option.maxLength,1,1e3),this.option.mount=this.option.mount||a,t.fontSize&&this.reset(),this.option.visible?this.show():this.hide(),this.art.emit("artplayerPluginDanmuku:config",this.option)),this}getLeft(t){let e=t.getBoundingClientRect();return this.isRotate?e.top:e.left}postMessage(t={}){return new Promise(e=>{t.id=Date.now(),this.worker.postMessage(t),this.worker.onmessage=i=>{let{data:a}=i;a.id===t.id&&e(a)}})}filter(t,e){let i=this.states[t]||[];for(let t=0;te!==t),t.$state=e,t.$ref&&(t.$ref.dataset.state=e),this.states[e].push(t)}makeWait(t){this.setState(t,"wait"),t.$ref&&(t.$ref.style.cssText=l.cssText,t.$ref.style.visibility="hidden",t.$ref.style.marginLeft="0px",t.$ref.style.transform="translateX(0px)",t.$ref.style.transition="transform 0s linear 0s",this.$refs.push(t.$ref),t.$ref=null)}update(){let{setStyles:t}=this.utils;return this.timer=window.requestAnimationFrame(async()=>{if(this.art.playing&&!this.isHide){this.filter("emit",t=>{let e=(Date.now()-t.$lastStartTime)/1e3;t.$restTime-=e,t.$lastStartTime=Date.now(),t.$restTime<=0&&this.makeWait(t)});let e=this.readys;for(let i=0;i{0===e.mode&&(e.$ref.style.left=`${t}px`)}),this.filter("emit",e=>{if(e.$lastStartTime=Date.now(),0===e.mode){let i=t+e.$ref.clientWidth;e.$ref.style.left=`${t}px`,e.$ref.style.transform=`translateX(${-i}px)`,e.$ref.style.transition=`transform ${e.$restTime}s linear 0s`}})}continue(){let{clientWidth:t}=this.$player;return this.filter("stop",e=>{if(this.setState(e,"emit"),e.$lastStartTime=Date.now(),0===e.mode){let i=t+e.$ref.clientWidth;e.$ref.style.transform=`translateX(${-i}px)`,e.$ref.style.transition=`transform ${e.$restTime}s linear 0s`}}),this}suspend(){let{clientWidth:t}=this.$player;return this.filter("emit",e=>{if(this.setState(e,"stop"),0===e.mode){let i=t-(this.getLeft(e.$ref)-this.getLeft(this.$player));e.$ref.style.transform=`translateX(${-i}px)`,e.$ref.style.transition="transform 0s linear 0s"}}),this}stop(){return this.isStop=!0,this.suspend(),window.cancelAnimationFrame(this.timer),this.art.emit("artplayerPluginDanmuku:stop"),this}start(){return this.isStop=!1,this.continue(),this.update(),this.art.emit("artplayerPluginDanmuku:start"),this}reset(){return this.queue.forEach(t=>this.makeWait(t)),this.art.emit("artplayerPluginDanmuku:reset"),this}show(){return this.isHide=!1,this.$danmuku.style.opacity=1,this.option.visible=!0,this.art.emit("artplayerPluginDanmuku:show"),this}hide(){return this.isHide=!0,this.$danmuku.style.opacity=0,this.option.visible=!1,this.art.emit("artplayerPluginDanmuku:hide"),this}destroy(){this.stop(),this.worker.terminate(),this.art.off("video:play",this.start),this.art.off("video:playing",this.start),this.art.off("video:pause",this.stop),this.art.off("video:waiting",this.stop),this.art.off("resize",this.reset),this.art.off("destroy",this.destroy),this.art.emit("artplayerPluginDanmuku:destroy")}}i.default=l},{"bundle-text:./worker":"f8uCH","./bilibili":"jICn4","@parcel/transformer-js/src/esmodule-helpers.js":"6ykb1"}],f8uCH:[function(t,e,i,a){e.exports='!function(e,t,r,o,i,n,u,l){var f="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:"u">typeof global?global:{},p="function"==typeof f[o]&&f[o],s=p.i||{},d=p.cache||{},h="u">typeof module&&"function"==typeof module.require&&module.require.bind(module);function a(t,r){if(!d[t]){if(!e[t]){if(i[t])return i[t];var n="function"==typeof f[o]&&f[o];if(!r&&n)return n(t,!0);if(p)return p(t,!0);if(h&&"string"==typeof t)return h(t);var u=Error("Cannot find module \'"+t+"\'");throw u.code="MODULE_NOT_FOUND",u}s.resolve=function(r){var o=e[t][1][r];return null!=o?o:r},s.cache={};var l=d[t]=new a.Module(t);e[t][0].call(l.exports,s,l,l.exports,f)}return d[t].exports;function s(e){var t=s.resolve(e);if(!1===t)return{};if(Array.isArray(t)){var r={__esModule:!0};return t.forEach(function(e){var t=e[0],o=e[1],i=e[2]||e[0],n=a(o);"*"===t?Object.keys(n).forEach(function(e){"default"===e||"__esModule"===e||Object.prototype.hasOwnProperty.call(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:function(){return n[e]}})}):"*"===i?Object.defineProperty(r,t,{enumerable:!0,value:n}):Object.defineProperty(r,t,{enumerable:!0,get:function(){return"default"===i?n.__esModule?n.default:n:n[i]}})}),r}return a(t)}}a.isParcelRequire=!0,a.Module=function(e){this.id=e,this.bundle=a,this.require=h,this.exports={}},a.modules=e,a.cache=d,a.parent=p,a.distDir=void 0,a.publicUrl=void 0,a.devServer=void 0,a.i=s,a.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(a,"root",{get:function(){return f[o]}}),f[o]=a;for(var c=0;ctypeof module?module.exports=g:"function"==typeof define&&define.amd&&define(function(){return g})}}({fpBtQ:[function(e,t,r,o){function i({target:e,visibles:t,clientWidth:r,clientHeight:o,marginBottom:i,marginTop:n,antiOverlap:u}){let l=o-i,f=t.filter(t=>t.mode===e.mode&&t.top<=l).sort((e,t)=>e.top-t.top);if(0===f.length)if(2===e.mode)return l-e.height;else return n;if(f.unshift({type:"top",top:0,left:0,right:0,height:n,width:r,speed:0,distance:r}),f.push({type:"bottom",top:l,left:0,right:0,height:i,width:r,speed:0,distance:r}),2===e.mode)for(let t=f.length-2;t>=0;t-=1){let r=f[t],o=f[t+1],i=r.top+r.height;if(o.top-i>=e.height)return o.top-e.height}else for(let t=1;t=e.height)return i}let p=[];for(let e=1;et.every(t=>!(rt.time))));return t&&t[0]?t[0].top:void 0}case 1:case 2:return}else{switch(e.mode){case 0:p.sort((e,t)=>{let r=Math.min(...t.map(e=>e.right)),o=Math.min(...e.map(e=>e.right));return r*t.length-o*e.length});break;case 1:case 2:p.sort((e,t)=>{let r=Math.max(...t.map(e=>e.width));return Math.max(...e.map(e=>e.width))*e.length-r*t.length})}return p[0][0].top}}onmessage=e=>{let{data:t}=e;t.id&&t.type&&globalThis.postMessage({result:(0,({getDanmuTop:i})[t.type])(t),id:t.id})}},{}]},["fpBtQ"],"fpBtQ","parcelRequire4dc0",{});'},{}],jICn4:[function(t,e,i,a){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");function o(t){switch(t){case 1:case 2:case 3:default:return 0;case 4:return 2;case 5:return 1}}function s(t){return"string"!=typeof t?[]:Array.from(t.matchAll(/]*?p="(?

[^"]+)"[^>]*>(?.*?)<\/d>/gs)).map(t=>{let e=t.groups.p.split(",");return e.length>=8?{text:t.groups.text.trim().replaceAll(""",'"').replaceAll("'","'").replaceAll("<","<").replaceAll(">",">").replaceAll("&","&"),time:Number(e[0]),mode:o(Number(e[1])),fontSize:Number(e[2]),color:`#${Number(e[3]).toString(16)}`,timestamp:Number(e[4]),pool:Number(e[5]),userID:e[6],rowID:Number(e[7])}:null}).filter(Boolean)}function r({data:t}){let{xml:e,id:i}=t;i&&e&&globalThis.postMessage({danmus:s(e),id:i})}function l(t){return new Promise(async e=>{let i=await fetch(t),a=await i.text();try{let t,i=(t=new Blob([` ${o.toString()} ${s.toString()} onmessage = ${r.toString()} `],{type:"application/javascript"}),new Worker(URL.createObjectURL(t)));i.onmessage=t=>{let{danmus:a,id:n}=t.data;n&&a&&(e(a),i.terminate())},i.postMessage({xml:a,id:Date.now()})}catch(t){console.error("Error parsing Bilibili Danmu:",t),e(s(a))}})}n.defineInteropFlag(i),n.export(i,"bilibiliDanmuParseFromUrl",()=>l)},{"@parcel/transformer-js/src/esmodule-helpers.js":"6ykb1"}],"6ykb1":[function(t,e,i,a){i.interopDefault=function(t){return t&&t.__esModule?t:{default:t}},i.defineInteropFlag=function(t){Object.defineProperty(t,"__esModule",{value:!0})},i.exportAll=function(t,e){return Object.keys(t).forEach(function(i){"default"===i||"__esModule"===i||Object.prototype.hasOwnProperty.call(e,i)||Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[i]}})}),e},i.export=function(t,e,i){Object.defineProperty(t,e,{enumerable:!0,get:i})}},{}],hjtgU:[function(t,e,i,a){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(i),n.export(i,"default",()=>s);let o={map:(t,e,i,a,n)=>(t-e)*(n-a)/(i-e)+a,range(t,e,i){let a=Math.round(t/i)*i;return Array.from({length:Math.floor((e-t)/i)},(t,e)=>e*i+a)}};function s(t,e,i){let{query:a}=t.constructor.utils;t.controls.add({name:"heatmap",position:"top",html:"",style:{position:"absolute",top:"-100px",left:"0px",right:"0px",height:"100px",width:"100%",pointerEvents:"none"},mounted(n){let s=null,r=null;function l(d=[]){if(s=null,r=null,n.innerHTML="",!t.duration||t.option.isLive)return;let p={w:n.offsetWidth,h:n.offsetHeight},u={xMin:0,xMax:p.w,yMin:0,yMax:128,scale:.25,opacity:.2,minHeight:Math.floor(.05*p.h),sampling:Math.floor(p.w/100),smoothing:.2,flattening:.2};"object"==typeof i&&Object.assign(u,i);let h=[];if(Array.isArray(d)&&d.length)h=[...d];else{let i=t.duration/p.w;for(let t=0;t<=p.w;t+=u.sampling){let a=e.queue.filter(({time:e})=>e>t*i&&e<=(t+u.sampling)*i).length;h.push([t,a])}}if(0===h.length)return;let m=h[h.length-1],c=m[0],f=m[1];c!==p.w&&h.push([p.w,f]);let g=h.map(t=>t[1]),y=(Math.min(...g)+Math.max(...g))/2;for(let t=0;ty?1+u.scale:1-u.scale)+u.minHeight}let v=(t,e,i,a)=>{let n,s,r=e||t,l=i||t,d=(n=l[0]-r[0],{length:Math.sqrt(n**2+(s=l[1]-r[1])**2),angle:Math.atan2(s,n)}),p=o.map(Math.cos(d.angle)*u.flattening,0,1,1,0),h=d.angle*p+(a?Math.PI:0),m=d.length*u.smoothing;return[t[0]+Math.cos(h)*m,t[1]+Math.sin(h)*m]},x=h.map(t=>[o.map(t[0],u.xMin,u.xMax,0,p.w),o.map(t[1],u.yMin,u.yMax,p.h,0)]).reduce((t,e,i,a)=>{let n,o,s;return 0===i?`M ${a[a.length-1][0]},${p.h} L ${e[0]},${p.h} L ${e[0]},${e[1]}`:`${t} ${n=v(a[i-1],a[i-2],e),o=v(e,a[i-1],a[i+1],!0),s=i===a.length-1?" z":"",`C ${n[0]},${n[1]} ${o[0]},${o[1]} ${e[0]},${e[1]}${s}`}`},"");n.innerHTML=``,s=a("#heatmap-start",n),r=a("#heatmap-stop",n),s.setAttribute("offset",`${100*t.played}%`),r.setAttribute("offset",`${100*t.played}%`)}t.on("video:timeupdate",()=>{s&&r&&(s.setAttribute("offset",`${100*t.played}%`),r.setAttribute("offset",`${100*t.played}%`))}),t.on("setBar",(t,e)=>{s&&r&&"played"===t&&(s.setAttribute("offset",`${100*e}%`),r.setAttribute("offset",`${100*e}%`))}),t.on("ready",()=>l()),t.on("resize",()=>l()),t.on("artplayerPluginDanmuku:loaded",()=>l()),t.on("artplayerPluginDanmuku:points",t=>l(t))}})}},{"@parcel/transformer-js/src/esmodule-helpers.js":"6ykb1"}],ho690:[function(t,e,i,a){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(i);var o=t("bundle-text:./img/check_off.svg"),s=n.interopDefault(o),r=t("bundle-text:./img/check_on.svg"),l=n.interopDefault(r),d=t("bundle-text:./img/config.svg"),p=n.interopDefault(d),u=t("bundle-text:./img/mode_0_off.svg"),h=n.interopDefault(u),m=t("bundle-text:./img/mode_0_on.svg"),c=n.interopDefault(m),f=t("bundle-text:./img/mode_1_off.svg"),g=n.interopDefault(f),y=t("bundle-text:./img/mode_1_on.svg"),v=n.interopDefault(y),x=t("bundle-text:./img/mode_2_off.svg"),k=n.interopDefault(x),b=t("bundle-text:./img/mode_2_on.svg"),$=n.interopDefault(b),w=t("bundle-text:./img/off.svg"),M=n.interopDefault(w),D=t("bundle-text:./img/on.svg"),S=n.interopDefault(D),E=t("bundle-text:./img/style.svg"),A=n.interopDefault(E),O=t("bundle-text:./style.less"),j=n.interopDefault(O);if(i.default=class{constructor(t,e){this.art=t,this.danmuku=e,this.utils=t.constructor.utils;const{setStyle:i}=this.utils,{$controlsCenter:a}=t.template;i(a,"display","flex"),this.template={$controlsCenter:a,$mount:a,$danmuku:null,$toggle:null,$config:null,$configPanel:null,$configModes:null,$style:null,$stylePanel:null,$styleModes:null,$colors:null,$opacitySlider:null,$opacityValue:null,$marginSlider:null,$marginValue:null,$fontSizeSlider:null,$fontSizeValue:null,$speedSlider:null,$speedValue:null,$input:null,$send:null},this.slider={opacity:null,margin:null,fontSize:null,speed:null},this.emitting=!1,this.isLock=!1,this.timer=null,this.createTemplate(),this.createSliders(),this.createEvents(),this.mount(this.option.mount),t.on("resize",()=>this.resize()),t.on("fullscreen",t=>this.onFullscreen(t)),t.on("fullscreenWeb",t=>this.onFullscreen(t)),t.proxy(this.template.$config,"mouseenter",()=>{this.onMouseEnter({$control:this.template.$config,$panel:this.template.$configPanel})}),t.proxy(this.template.$style,"mouseenter",()=>{this.onMouseEnter({$control:this.template.$style,$panel:this.template.$stylePanel})})}static get icons(){return{$on:S.default,$off:M.default,$config:p.default,$style:A.default,$mode_0_off:h.default,$mode_0_on:c.default,$mode_1_off:g.default,$mode_1_on:v.default,$mode_2_off:k.default,$mode_2_on:$.default,$check_on:l.default,$check_off:s.default}}get option(){return this.danmuku.option}get outside(){return this.template.$mount!==this.template.$controlsCenter}get TEMPLATE(){let{option:t}=this;return`

${S.default}${M.default}
${p.default}
\u{6309}\u{7C7B}\u{578B}\u{5C4F}\u{853D}
${h.default}${c.default}
\u{6EDA}\u{52A8}
${g.default}${v.default}
\u{9876}\u{90E8}
${k.default}${$.default}
\u{5E95}\u{90E8}
${l.default}${s.default} \u{9632}\u{6B62}\u{5F39}\u{5E55}\u{91CD}\u{53E0}
${l.default}${s.default} \u{540C}\u{6B65}\u{89C6}\u{9891}\u{901F}\u{5EA6}
\u{4E0D}\u{900F}\u{660E}\u{5EA6}
\u{672A}\u{77E5}
\u{663E}\u{793A}\u{533A}\u{57DF}
\u{672A}\u{77E5}
\u{5F39}\u{5E55}\u{5B57}\u{53F7}
\u{672A}\u{77E5}
\u{5F39}\u{5E55}\u{901F}\u{5EA6}
\u{672A}\u{77E5}
${A.default}
\u{6A21}\u{5F0F}
${c.default}
\u{6EDA}\u{52A8}
${v.default}
\u{9876}\u{90E8}
${$.default}
\u{5E95}\u{90E8}
\u{989C}\u{8272}
${this.COLOR.map(t=>`
`).join("")}
\u{53D1}\u{9001}
`}get OPACITY(){return{min:0,max:100,steps:[],...this.option.OPACITY}}get FONT_SIZE(){return{min:12,max:120,steps:[],...this.option.FONT_SIZE}}get MARGIN(){return{min:0,max:3,steps:[{name:"1/4",value:[10,"75%"]},{name:"半屏",value:[10,"50%"]},{name:"3/4",value:[10,"25%"]},{name:"满屏",value:[10,10]}],...this.option.MARGIN}}get SPEED(){return{min:0,max:4,steps:[{name:"极慢",value:10},{name:"较慢",value:7.5,hide:!0},{name:"适中",value:5},{name:"较快",value:2.5,hide:!0},{name:"极快",value:1}],...this.option.SPEED}}get COLOR(){return this.option.COLOR.length?this.option.COLOR:["#FE0302","#FF7204","#FFAA02","#FFD302","#FFFF00","#A0EE00","#00CD00","#019899","#4266BE","#89D5FF","#CC0273","#222222","#9B9B9B","#FFFFFF"]}query(t){let{query:e}=this.utils,{$danmuku:i}=this.template;return e(t,i)}append(t,e){let{append:i}=this.utils;[...t.children].includes(e)||i(t,e)}setData(t,e){let{$player:i}=this.art.template,{$mount:a}=this.template;i.dataset[t]=e,this.outside&&(a.dataset[t]=e)}createTemplate(){let{createElement:t,tooltip:e}=this.utils,i=t("div");i.className="artplayer-plugin-danmuku",i.innerHTML=this.TEMPLATE,this.template.$danmuku=i,this.template.$toggle=this.query(".apd-toggle"),this.template.$config=this.query(".apd-config"),this.template.$configPanel=this.query(".apd-config-panel"),this.template.$configModes=this.query(".apd-config-mode .apd-modes"),this.template.$style=this.query(".apd-style"),this.template.$stylePanel=this.query(".apd-style-panel"),this.template.$styleModes=this.query(".apd-style-mode .apd-modes"),this.template.$colors=this.query(".apd-colors"),this.template.$antiOverlap=this.query(".apd-anti-overlap"),this.template.$syncVideo=this.query(".apd-sync-video"),this.template.$opacitySlider=this.query(".apd-config-opacity .apd-slider"),this.template.$opacityValue=this.query(".apd-config-opacity .apd-value"),this.template.$marginSlider=this.query(".apd-config-margin .apd-slider"),this.template.$marginValue=this.query(".apd-config-margin .apd-value"),this.template.$fontSizeSlider=this.query(".apd-config-fontSize .apd-slider"),this.template.$fontSizeValue=this.query(".apd-config-fontSize .apd-value"),this.template.$speedSlider=this.query(".apd-config-speed .apd-slider"),this.template.$speedValue=this.query(".apd-config-speed .apd-value"),this.template.$input=this.query(".apd-input"),this.template.$send=this.query(".apd-send");let{$toggle:a}=this.template;this.art.on("artplayerPluginDanmuku:show",()=>{e(a,"关闭弹幕")}),this.art.on("artplayerPluginDanmuku:hide",()=>{e(a,"打开弹幕")})}createEvents(){let{$toggle:t,$configModes:e,$styleModes:i,$colors:a,$antiOverlap:n,$syncVideo:o,$send:s,$input:r}=this.template;this.art.proxy(t,"click",()=>{this.danmuku.config({visible:!this.option.visible}),this.reset()}),this.art.proxy(e,"click",t=>{let e=t.target.closest(".apd-mode");if(!e)return;let i=Number(e.dataset.mode);this.option.modes.includes(i)?this.danmuku.config({modes:this.option.modes.filter(t=>t!==i)}):this.danmuku.config({modes:[...this.option.modes,i]}),this.reset()}),this.art.proxy(n,"click",()=>{this.danmuku.config({antiOverlap:!this.option.antiOverlap}),this.reset()}),this.art.proxy(o,"click",()=>{this.danmuku.config({synchronousPlayback:!this.option.synchronousPlayback}),this.reset()}),this.art.proxy(i,"click",t=>{let e=t.target.closest(".apd-mode");if(!e)return;let i=Number(e.dataset.mode);this.danmuku.config({mode:i}),this.reset()}),this.art.proxy(a,"click",t=>{let e=t.target.closest(".apd-color");e&&(this.danmuku.config({color:e.dataset.color}),this.reset())}),this.art.proxy(s,"click",()=>this.emit()),this.art.proxy(r,"keypress",t=>{"Enter"===t.key&&(t.preventDefault(),this.emit())})}createSliders(){this.slider.opacity=this.createSlider({...this.OPACITY,container:this.template.$opacitySlider,findIndex:()=>Math.round(100*this.option.opacity),onChange:t=>{let{$opacityValue:e}=this.template;e.textContent=`${t}%`,this.danmuku.config({opacity:t/100})}}),this.slider.margin=this.createSlider({...this.MARGIN,container:this.template.$marginSlider,findIndex:()=>this.MARGIN.steps.findIndex(t=>t.value[0]===this.option.margin[0]&&t.value[1]===this.option.margin[1]),onChange:t=>{let e=this.MARGIN.steps[t];if(!e)return;let{$marginValue:i}=this.template;i.textContent=e.name,this.danmuku.config({margin:e.value})}}),this.slider.fontSize=this.createSlider({...this.FONT_SIZE,container:this.template.$fontSizeSlider,findIndex:()=>this.danmuku.fontSize,onChange:t=>{let{$fontSizeValue:e}=this.template;e.textContent=`${t}px`,t!==this.danmuku.fontSize&&this.danmuku.config({fontSize:t})}}),this.slider.speed=this.createSlider({...this.SPEED,container:this.template.$speedSlider,findIndex:()=>this.SPEED.steps.findIndex(t=>t.value===this.option.speed),onChange:t=>{let e=this.SPEED.steps[t];if(!e)return;let{$speedValue:i}=this.template;i.textContent=e.name,this.danmuku.config({speed:e.value})}})}createSlider({min:t,max:e,container:i,findIndex:a,onChange:n,steps:o=[]}){let{query:s,clamp:r,setStyle:l}=this.utils;l(i,"touch-action","none"),i.innerHTML=`
${o.map(()=>'
').join("")}
${o.map(t=>t.hide?"":`
${t.name}
`).join("")}
`;let d=s(".apd-slider-dot",i),p=s(".apd-slider-progress",i),u=!1;function h(i=a()){if(ie)return;let s=(i-t)/(e-t);d.style.left=`${100*s}%`,0===o.length&&(p.style.width=d.style.left),n(i)}function m(a){let{top:n,height:o,left:s,width:l}=i.getBoundingClientRect();this.art.isRotate?h(Math.round(r(a.clientY-n,0,o)/o*(e-t)+t)):h(Math.round(r(a.clientX-s,0,l)/l*(e-t)+t))}return this.art.proxy(i,"click",t=>{m.call(this,t)}),this.art.proxy(i,"pointerdown",t=>{u=0===t.button}),this.art.on("document:pointermove",t=>{u&&m.call(this,t)}),this.art.on("document:pointerup",t=>{u&&(u=!1,m.call(this,t))}),{reset:h}}onFullscreen(t){let{$danmuku:e,$controlsCenter:i,$mount:a}=this.template;this.outside?t?this.append(i,e):this.append(a,e):this.append(i,e)}onMouseEnter({$control:t,$panel:e}){let{$player:i}=this.art.template,a=t.getBoundingClientRect(),n=e.getBoundingClientRect(),o=i.getBoundingClientRect(),s=n.width/2-a.width/2,r=o.left-(a.left-s),l=a.right+s-o.right;r>0?e.style.left=`${-s+r}px`:l>0?e.style.left=`${-s-l}px`:e.style.left=`${-s}px`}async emit(){let{$input:t}=this.template,e=t.value.trim();if(!e.length||this.isLock||this.emitting)return;let i={text:e,mode:this.option.mode,color:this.option.color,time:this.art.currentTime};try{this.emitting=!0;let e=await this.option.beforeEmit(i);if(this.emitting=!1,!0!==e)return;i.border=!0,delete i.time,this.danmuku.emit(i),t.value="",this.lock()}catch(t){console.error("Error emitting danmuku:",t),this.emitting=!1}}lock(){let{addClass:t}=this.utils,{$send:e}=this.template;this.isLock=!0;let i=this.option.lockTime;e.textContent=i,t(e,"apd-lock");let a=()=>{this.timer=setTimeout(()=>{0===i?this.unlock():(e.textContent=i-=1,a())},1e3)};a()}unlock(){let{removeClass:t}=this.utils,{$send:e}=this.template;clearTimeout(this.timer),this.isLock=!1,e.textContent="发送",t(e,"apd-lock")}resize(){if(this.outside||this.art.fullscreen||this.art.fullscreenWeb)return;let{$player:t,$controlsCenter:e}=this.art.template,{$danmuku:i}=this.template;this.art.widtht.dataset.color===this.option.color.toUpperCase());n&&t(n,"apd-active"),e(i,this.option.visible?"关闭弹幕":"打开弹幕"),this.resize()}mount(t){let{errorHandle:e}=this.utils,i="string"==typeof t?document.querySelector(t):t;e(i,`Can not find the mount point: ${t}`),this.append(i,this.template.$danmuku),this.template.$mount=i,this.reset()}},"u">typeof document){let t="artplayer-plugin-danmuku",e=document.getElementById(t);e||((e=document.createElement("style")).id=t,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{document.head.appendChild(e)}):(document.head||document.documentElement).appendChild(e)),e.textContent=j.default}},{"bundle-text:./img/check_off.svg":"2pPC1","bundle-text:./img/check_on.svg":"47UDb","bundle-text:./img/config.svg":"kCi8g","bundle-text:./img/mode_0_off.svg":"7HQlG","bundle-text:./img/mode_0_on.svg":"t7s2B","bundle-text:./img/mode_1_off.svg":"lkKl2","bundle-text:./img/mode_1_on.svg":"8f8zW","bundle-text:./img/mode_2_off.svg":"emrpJ","bundle-text:./img/mode_2_on.svg":"1fmjY","bundle-text:./img/off.svg":"8Ug2A","bundle-text:./img/on.svg":"1BQ1c","bundle-text:./img/style.svg":"b24KT","bundle-text:./style.less":"k8RGI","@parcel/transformer-js/src/esmodule-helpers.js":"6ykb1"}],"2pPC1":[function(t,e,i,a){e.exports=''},{}],"47UDb":[function(t,e,i,a){e.exports=''},{}],kCi8g:[function(t,e,i,a){e.exports=''},{}],"7HQlG":[function(t,e,i,a){e.exports=''},{}],t7s2B:[function(t,e,i,a){e.exports=''},{}],lkKl2:[function(t,e,i,a){e.exports=''},{}],"8f8zW":[function(t,e,i,a){e.exports=''},{}],emrpJ:[function(t,e,i,a){e.exports=''},{}],"1fmjY":[function(t,e,i,a){e.exports=''},{}],"8Ug2A":[function(t,e,i,a){e.exports=''},{}],"1BQ1c":[function(t,e,i,a){e.exports=''},{}],b24KT:[function(t,e,i,a){e.exports=''},{}],k8RGI:[function(t,e,i,a){e.exports='.artplayer-plugin-danmuku{z-index:99;color:#fff;flex-shrink:0;justify-content:center;align-items:center;gap:10px;width:100%;height:32px;font-size:12px;font-weight:300;display:flex;position:relative}.artplayer-plugin-danmuku .apd-icon{cursor:pointer;opacity:.75;fill:#fff;transition:all .2s}.artplayer-plugin-danmuku .apd-icon:hover{opacity:1}.artplayer-plugin-danmuku .apd-config{display:flex;position:relative}.artplayer-plugin-danmuku .apd-config .apd-config-panel{opacity:0;pointer-events:none;width:320px;padding:10px;position:absolute;bottom:24px;left:0}.artplayer-plugin-danmuku .apd-config .apd-config-panel .apd-config-panel-inner{background-color:#000000d9;border-radius:3px;width:100%;padding:10px}.artplayer-plugin-danmuku .apd-config:hover .apd-config-panel{opacity:100;pointer-events:all}.artplayer-plugin-danmuku .apd-config-mode,.artplayer-plugin-danmuku .apd-config-slider,.artplayer-plugin-danmuku .apd-config-other,.artplayer-plugin-danmuku .apd-style-mode{margin-bottom:15px}.artplayer-plugin-danmuku .apd-modes{align-items:center;gap:20px;margin-top:5px;display:flex}.artplayer-plugin-danmuku .apd-modes .apd-mode{cursor:pointer;text-align:center}.artplayer-plugin-danmuku .apd-modes .apd-mode:hover{color:#00a1d6}.artplayer-plugin-danmuku .apd-config-slider{align-items:center;gap:12px;display:flex}.artplayer-plugin-danmuku .apd-config-slider .apd-value{text-align:right;width:32px}.artplayer-plugin-danmuku .apd-slider{cursor:pointer;flex:1;justify-content:center;align-items:center;height:20px;display:flex;position:relative}.artplayer-plugin-danmuku .apd-slider .apd-slider-line{background-color:#ffffff40;border-radius:3px;width:100%;height:2px;position:relative;overflow:hidden}.artplayer-plugin-danmuku .apd-slider .apd-slider-points{justify-content:space-between;align-items:center;display:flex;position:absolute;inset:0}.artplayer-plugin-danmuku .apd-slider .apd-slider-points .apd-slider-point{background-color:#ffffff80;border-radius:50%;width:2px;height:2px}.artplayer-plugin-danmuku .apd-slider .apd-slider-progress{background-color:#00a1d6;width:0%;height:100%}.artplayer-plugin-danmuku .apd-slider .apd-slider-dot{background-color:#00a1d6;border-radius:50%;width:12px;height:12px;position:absolute;left:0%;transform:translate(-6px)}.artplayer-plugin-danmuku .apd-slider .apd-slider-steps{color:#777;justify-content:space-between;align-items:center;width:calc(100% + 32px);display:flex;position:absolute;bottom:-12px}.artplayer-plugin-danmuku .apd-slider .apd-slider-steps .apd-slider-step{text-align:center;flex-shrink:0;width:36px;scale:.95}.artplayer-plugin-danmuku .apd-config-other{align-items:center;gap:20px;display:flex}.artplayer-plugin-danmuku .apd-config-other .apd-check-off,.artplayer-plugin-danmuku .apd-config-other .apd-check-on{width:16px;height:16px}.artplayer-plugin-danmuku .apd-config-other .apd-other{cursor:pointer;align-items:center;gap:2px;display:flex}.artplayer-plugin-danmuku .apd-config-other .apd-other:hover{color:#00a1d6}.artplayer-plugin-danmuku .apd-emitter{background-color:#ffffff40;border-radius:5px;flex:1;align-items:center;height:100%;display:flex}.artplayer-plugin-danmuku .apd-style{justify-content:center;align-items:center;display:flex;position:relative}.artplayer-plugin-danmuku .apd-style .apd-style-panel{opacity:0;pointer-events:none;width:200px;padding:10px;position:absolute;bottom:24px;left:0}.artplayer-plugin-danmuku .apd-style .apd-style-panel .apd-style-panel-inner{background-color:#000000d9;border-radius:3px;width:100%;padding:10px}.artplayer-plugin-danmuku .apd-style:hover .apd-style-panel{opacity:100;pointer-events:all}.artplayer-plugin-danmuku .apd-colors{flex-wrap:wrap;gap:8px;margin-top:5px;display:flex}.artplayer-plugin-danmuku .apd-colors .apd-color{cursor:pointer;border-radius:2px;width:16px;height:16px}.artplayer-plugin-danmuku .apd-colors .apd-color.apd-active{border:1px solid #000;box-shadow:0 0 0 1px #fff}.artplayer-plugin-danmuku .apd-input{color:#fff;background-color:#0000;border:none;outline:none;flex:1;width:auto;min-width:0;height:100%;line-height:1}.artplayer-plugin-danmuku .apd-input::placeholder{color:#ffffff80}.artplayer-plugin-danmuku .apd-send{cursor:pointer;width:60px;height:100%;text-shadow:none;background-color:#00a1d6;border-top-right-radius:5px;border-bottom-right-radius:5px;flex-shrink:0;justify-content:center;align-items:center;display:flex}.artplayer-plugin-danmuku .apd-send.apd-lock{cursor:not-allowed;color:#666;background-color:#e7e7e7}.art-controls-center .apd-emitter{flex:none;width:260px}.art-fullscreen .artplayer-plugin-danmuku,.art-fullscreen-web .artplayer-plugin-danmuku{gap:16px;height:38px}.art-fullscreen .artplayer-plugin-danmuku .apd-config-icon,.art-fullscreen-web .artplayer-plugin-danmuku .apd-config-icon,.art-fullscreen .artplayer-plugin-danmuku .apd-toggle-off,.art-fullscreen-web .artplayer-plugin-danmuku .apd-toggle-off,.art-fullscreen .artplayer-plugin-danmuku .apd-toggle-on,.art-fullscreen-web .artplayer-plugin-danmuku .apd-toggle-on{width:28px;height:28px}.art-fullscreen .artplayer-plugin-danmuku .apd-emitter,.art-fullscreen-web .artplayer-plugin-danmuku .apd-emitter{flex:none;width:400px}.art-video-player>.artplayer-plugin-danmuku{padding:0 10px;position:absolute;bottom:-40px;left:0;right:0}.art-video-player:has(>.artplayer-plugin-danmuku){margin-bottom:40px}[data-danmuku-emitter=false] .apd-emitter{display:none!important}[data-danmuku-emitter=false] .art-controls-center .artplayer-plugin-danmuku{justify-content:flex-end;gap:18px}[data-danmuku-emitter=false].art-fullscreen .art-controls-center .artplayer-plugin-danmuku,[data-danmuku-emitter=false].art-fullscreen-web .art-controls-center .artplayer-plugin-danmuku{gap:24px}[data-danmuku-theme=light]>.artplayer-plugin-danmuku .apd-icon{fill:#333}[data-danmuku-theme=light]>.artplayer-plugin-danmuku .apd-emitter{background-color:#f1f2f3}[data-danmuku-theme=light]>.artplayer-plugin-danmuku .apd-input{color:#000}[data-danmuku-theme=light]>.artplayer-plugin-danmuku .apd-input::placeholder{color:#0000004d}[data-danmuku-visible=false] .apd-toggle-off{display:block}[data-danmuku-visible=false] .apd-toggle-on,[data-danmuku-visible=true] .apd-toggle-off{display:none}[data-danmuku-visible=true] .apd-toggle-on{display:block}[data-danmuku-anti-overlap=false] .apd-anti-overlap .apd-check-on{display:none}[data-danmuku-anti-overlap=false] .apd-anti-overlap .apd-check-off,[data-danmuku-anti-overlap=true] .apd-anti-overlap .apd-check-on{display:block}[data-danmuku-anti-overlap=true] .apd-anti-overlap .apd-check-off,[data-danmuku-sync-video=false] .apd-sync-video .apd-check-on{display:none}[data-danmuku-sync-video=false] .apd-sync-video .apd-check-off,[data-danmuku-sync-video=true] .apd-sync-video .apd-check-on{display:block}[data-danmuku-sync-video=true] .apd-sync-video .apd-check-off{display:none}[data-danmuku-mode0=false] .apd-config-mode .apd-mode-0-off{display:block}[data-danmuku-mode0=false] .apd-config-mode .apd-mode-0-on{display:none}[data-danmuku-mode0=false] .art-danmuku [data-mode="0"]{opacity:0!important}[data-danmuku-mode0=true] .apd-config-mode .apd-mode-0-off{display:none}[data-danmuku-mode0=true] .apd-config-mode .apd-mode-0-on{display:block}[data-danmuku-mode="0"] .apd-style-mode [data-mode="0"]{color:#00a1d6}[data-danmuku-mode="0"] .apd-style-mode [data-mode="0"] path{fill:#00a1d6}[data-danmuku-mode1=false] .apd-config-mode .apd-mode-1-off{display:block}[data-danmuku-mode1=false] .apd-config-mode .apd-mode-1-on{display:none}[data-danmuku-mode1=false] .art-danmuku [data-mode="1"]{opacity:0!important}[data-danmuku-mode1=true] .apd-config-mode .apd-mode-1-off{display:none}[data-danmuku-mode1=true] .apd-config-mode .apd-mode-1-on{display:block}[data-danmuku-mode="1"] .apd-style-mode [data-mode="1"]{color:#00a1d6}[data-danmuku-mode="1"] .apd-style-mode [data-mode="1"] path{fill:#00a1d6}[data-danmuku-mode2=false] .apd-config-mode .apd-mode-2-off{display:block}[data-danmuku-mode2=false] .apd-config-mode .apd-mode-2-on{display:none}[data-danmuku-mode2=false] .art-danmuku [data-mode="2"]{opacity:0!important}[data-danmuku-mode2=true] .apd-config-mode .apd-mode-2-off{display:none}[data-danmuku-mode2=true] .apd-config-mode .apd-mode-2-on{display:block}[data-danmuku-mode="2"] .apd-style-mode [data-mode="2"]{color:#00a1d6}[data-danmuku-mode="2"] .apd-style-mode [data-mode="2"] path{fill:#00a1d6}'},{}]},["666Ok"],"666Ok","parcelRequire4dc0",{});