index.js 52 KB

12
  1. window.DanmuJs=function(t){var e={};function n(o){if(e[o])return e[o].exports;var i=e[o]={i:o,l:!1,exports:{}};return t[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(o,i,function(e){return t[e]}.bind(null,i));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=4)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o,i=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),r=n(26),a=(o=r)&&o.__esModule?o:{default:o};var s=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return i(t,[{key:"setLogger",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.logger=new a.default(t+".js")}}]),t}();e.default=s,t.exports=e.default},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o={createDom:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"div",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=document.createElement(t);return i.className=o,i.innerHTML=e,Object.keys(n).forEach((function(e){var o=e,r=n[e];"video"===t||"audio"===t?r&&i.setAttribute(o,r):i.setAttribute(o,r)})),i},hasClass:function(t,e){return t.classList?Array.prototype.some.call(t.classList,(function(t){return t===e})):!!t.className.match(new RegExp("(\\s|^)"+e+"(\\s|$)"))},addClass:function(t,e){t.classList?e.replace(/(^\s+|\s+$)/g,"").split(/\s+/g).forEach((function(e){e&&t.classList.add(e)})):o.hasClass(t,e)||(t.className+=" "+e)},removeClass:function(t,e){t.classList?e.split(/\s+/g).forEach((function(e){t.classList.remove(e)})):o.hasClass(t,e)&&e.split(/\s+/g).forEach((function(e){var n=new RegExp("(\\s|^)"+e+"(\\s|$)");t.className=t.className.replace(n," ")}))},toggleClass:function(t,e){e.split(/\s+/g).forEach((function(e){o.hasClass(t,e)?o.removeClass(t,e):o.addClass(t,e)}))},findDom:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,e=arguments[1],n=void 0;try{n=t.querySelector(e)}catch(o){e.startsWith("#")&&(n=t.getElementById(e.slice(1)))}return n},deepCopy:function(t,e){if("Object"===o.typeOf(e)&&"Object"===o.typeOf(t))return Object.keys(e).forEach((function(n){"Object"!==o.typeOf(e[n])||e[n]instanceof Node?"Array"===o.typeOf(e[n])?t[n]="Array"===o.typeOf(t[n])?t[n].concat(e[n]):e[n]:t[n]=e[n]:t[n]?o.deepCopy(t[n],e[n]):t[n]=e[n]})),t},typeOf:function(t){return Object.prototype.toString.call(t).match(/([^\s.*]+)(?=]$)/g)[0]},copyDom:function(t){if(t&&1===t.nodeType){var e=document.createElement(t.tagName);return Array.prototype.forEach.call(t.attributes,(function(t){e.setAttribute(t.name,t.value)})),t.innerHTML&&(e.innerHTML=t.innerHTML),e}return""},formatTime:function(t){var e=Math.floor(t);return 1e3*e+(t-e)},offInDestroy:function(t,e,n,o){t.once(o,(function i(){t.off(e,n),t.off(o,i)}))},on:function(t,e,n,i){if(i)t.on(e,n),o.offInDestroy(t,e,n,i);else{t.on(e,(function o(i){n(i),t.off(e,o)}))}}};e.default=o,t.exports=e.default},function(t,e,n){"use strict";var o=n(19)();t.exports=function(t){return t!==o&&null!==t}},function(t,e,n){"use strict";t.exports=function(t){return null!=t}},function(t,e,n){t.exports=n(5)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o,i=n(6),r=(o=i)&&o.__esModule?o:{default:o};n(33),e.default=r.default,t.exports=e.default},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),i=c(n(7)),r=c(n(0)),a=c(n(27)),s=c(n(31)),u=c(n(1)),l=n(32);function c(t){return t&&t.__esModule?t:{default:t}}function f(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}var h=function(t){function e(t){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);var n=f(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));n.setLogger("danmu"),n.logger.info("danmu.js version: "+l.version);var o=n;if(o.config=u.default.deepCopy({overlap:!1,area:{start:0,end:1},live:!1,comments:[],direction:"r2l"},t),o.hideArr=[],o.domObj=new s.default,(0,i.default)(o),o.config.comments.forEach((function(t){t.duration=t.duration?t.duration:5e3,t.mode||(t.mode="scroll")})),!o.config.container||1!==o.config.container.nodeType)return o.emit("error","container id can't be empty"),!1,f(n,!1);if(o.container=o.config.container,o.config.containerStyle){var r=o.config.containerStyle;Object.keys(r).forEach((function(t){o.container.style[t]=r[t]}))}return o.live=o.config.live,o.player=o.config.player,o.direction=o.config.direction,u.default.addClass(o.container,"danmu"),o.bulletBtn=new a.default(o),o.emit("ready"),n.logger.info("ready"),n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),o(e,[{key:"start",value:function(){this.logger.info("start"),this.bulletBtn.main.start()}},{key:"pause",value:function(){this.logger.info("pause"),this.bulletBtn.main.pause()}},{key:"play",value:function(){this.logger.info("play"),this.bulletBtn.main.play()}},{key:"stop",value:function(){this.logger.info("stop"),this.bulletBtn.main.stop()}},{key:"destroy",value:function(){for(var t in this.logger.info("destroy"),this.stop(),this.bulletBtn.destroy(),this.domObj.destroy(),this)delete this[t];this.emit("destroy")}},{key:"sendComment",value:function(t){this.logger.info("sendComment: "+(t.txt||"[DOM Element]")),t.duration||(t.duration=15e3),t&&t.id&&t.duration&&(t.el||t.txt)&&(t.duration=t.duration?t.duration:5e3,t.style&&(this.opacity&&this.opacity!==t.style.opacity&&(t.style.opacity=this.opacity),this.fontSize&&this.fontSize!==t.style.fontSize&&(t.style.fontSize=this.fontSize),this.like&&(t.like=t.like?t.like:this.like)),t.prior||t.realTime?(this.bulletBtn.main.data.unshift(t),t.realTime&&(this.bulletBtn.main.readData(),this.bulletBtn.main.dataHandle())):this.bulletBtn.main.data.push(t))}},{key:"setCommentID",value:function(t,e){var n=this;this.logger.info("setCommentID: oldID "+t+" newID "+e);var o=this.container.getBoundingClientRect();t&&e&&(this.bulletBtn.main.data.some((function(n){return n.id===t&&(n.id=e,!0)})),this.bulletBtn.main.queue.some((function(i){return i.id===t&&(i.id=e,i.pauseMove(o),"paused"!==n.bulletBtn.main.status&&i.startMove(o),!0)})))}},{key:"setCommentDuration",value:function(t,e){var n=this;this.logger.info("setCommentDuration: id "+t+" duration "+e);var o=this.container.getBoundingClientRect();t&&e&&(e=e||5e3,this.bulletBtn.main.data.some((function(n){return n.id===t&&(n.duration=e,!0)})),this.bulletBtn.main.queue.some((function(i){return i.id===t&&(i.duration=e,i.pauseMove(o),"paused"!==n.bulletBtn.main.status&&i.startMove(o),!0)})))}},{key:"setCommentLike",value:function(t,e){this.logger.info("setCommentLike: id "+t+" like "+e);var n=this.container.getBoundingClientRect();this.like=e,t&&e&&(this.bulletBtn.main.data.some((function(n){return n.id===t&&(n.like=e,!0)})),this.bulletBtn.main.queue.some((function(o){return o.id===t&&(o.pauseMove(n),o.setLikeDom(e.el,e.style),"paused"!==o.danmu.bulletBtn.main.status&&o.startMove(n),!0)})))}},{key:"restartComment",value:function(t){this.logger.info("restartComment: id "+t),this.mouseControl=!1;var e=this.container.getBoundingClientRect();t&&this.bulletBtn.main.queue.some((function(n){return n.id===t&&("paused"!==n.danmu.bulletBtn.main.status?n.startMove(e,!0):n.status="paused",!0)}))}},{key:"freezeComment",value:function(t){this.logger.info("freezeComment: id "+t),this.mouseControl=!0;var e=this.container.getBoundingClientRect();t&&this.bulletBtn.main.queue.some((function(n){return n.id===t&&(n.status="forcedPause",n.pauseMove(e),n.el&&n.el.style&&(n.el.style.zIndex=10),!0)}))}},{key:"removeComment",value:function(t){this.logger.info("removeComment: id "+t),t&&(this.bulletBtn.main.queue.some((function(e){return e.id===t&&(e.remove(),!0)})),this.bulletBtn.main.data=this.bulletBtn.main.data.filter((function(e){return e.id!==t})))}},{key:"setAllDuration",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"scroll",e=arguments[1],n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];this.logger.info("setAllDuration: mode "+t+" duration "+e+" force "+n);var o=this.container.getBoundingClientRect();e&&(e=e||5e3,n&&(this.bulletBtn.main.forceDuration=e),this.bulletBtn.main.data.forEach((function(n){t===n.mode&&(n.duration=e)})),this.bulletBtn.main.queue.forEach((function(n){t===n.mode&&(n.duration=e,n.pauseMove(o),"paused"!==n.danmu.bulletBtn.main.status&&n.startMove(o))})))}},{key:"setOpacity",value:function(t){this.logger.info("setOpacity: opacity "+t),this.container.style.opacity=t}},{key:"setFontSize",value:function(t,e){var n=this;this.logger.info("setFontSize: size "+t+" channelSize "+e),this.fontSize=t+"px",t&&(this.bulletBtn.main.data.forEach((function(t){t.style&&(t.style.fontSize=n.fontSize)})),this.bulletBtn.main.queue.forEach((function(t){t.options.style||(t.options.style={}),t.options.style.fontSize=n.fontSize,t.setFontSize(n.fontSize),e&&(t.top=t.channel_id[0]*e,t.topInit())}))),e&&(this.config.channelSize=e,this.bulletBtn.main.channel.resize(!0))}},{key:"setArea",value:function(t){this.logger.info("setArea: area "+t),this.config.area=t,this.bulletBtn.main.channel.resize(!0)}},{key:"hide",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"scroll";this.logger.info("hide: mode "+t),this.hideArr.indexOf(t)<0&&this.hideArr.push(t);var e=this.bulletBtn.main.queue.filter((function(e){return t===e.mode||"color"===t&&e.color}));e.forEach((function(t){return t.remove()}))}},{key:"show",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"scroll";this.logger.info("show: mode "+t);var e=this.hideArr.indexOf(t);e>-1&&this.hideArr.splice(e,1)}},{key:"setDirection",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"r2l";this.logger.info("setDirection: direction "+t),this.emit("changeDirection",t)}},{key:"resize",value:function(){this.logger.info("resize"),this.emit("channel_resize")}}]),e}(r.default);e.default=h,t.exports=e.default},function(t,e,n){"use strict";var o,i,r,a,s,u,l,c=n(8),f=n(25),h=Function.prototype.apply,d=Function.prototype.call,p=Object.create,m=Object.defineProperty,g=Object.defineProperties,v=Object.prototype.hasOwnProperty,b={configurable:!0,enumerable:!1,writable:!0};i=function(t,e){var n,i;return f(e),i=this,o.call(this,t,n=function(){r.call(i,t,n),h.call(e,this,arguments)}),n.__eeOnceListener__=e,this},s={on:o=function(t,e){var n;return f(e),v.call(this,"__ee__")?n=this.__ee__:(n=b.value=p(null),m(this,"__ee__",b),b.value=null),n[t]?"object"==typeof n[t]?n[t].push(e):n[t]=[n[t],e]:n[t]=e,this},once:i,off:r=function(t,e){var n,o,i,r;if(f(e),!v.call(this,"__ee__"))return this;if(!(n=this.__ee__)[t])return this;if("object"==typeof(o=n[t]))for(r=0;i=o[r];++r)i!==e&&i.__eeOnceListener__!==e||(2===o.length?n[t]=o[r?0:1]:o.splice(r,1));else o!==e&&o.__eeOnceListener__!==e||delete n[t];return this},emit:a=function(t){var e,n,o,i,r;if(v.call(this,"__ee__")&&(i=this.__ee__[t]))if("object"==typeof i){for(n=arguments.length,r=new Array(n-1),e=1;e<n;++e)r[e-1]=arguments[e];for(i=i.slice(),e=0;o=i[e];++e)h.call(o,this,r)}else switch(arguments.length){case 1:d.call(i,this);break;case 2:d.call(i,this,arguments[1]);break;case 3:d.call(i,this,arguments[1],arguments[2]);break;default:for(n=arguments.length,r=new Array(n-1),e=1;e<n;++e)r[e-1]=arguments[e];h.call(i,this,r)}}},u={on:c(o),once:c(i),off:c(r),emit:c(a)},l=g({},u),t.exports=e=function(t){return null==t?p(l):g(Object(t),u)},e.methods=s},function(t,e,n){"use strict";var o=n(3),i=n(9),r=n(13),a=n(21),s=n(22);(t.exports=function(t,e){var n,i,u,l,c;return arguments.length<2||"string"!=typeof t?(l=e,e=t,t=null):l=arguments[2],o(t)?(n=s.call(t,"c"),i=s.call(t,"e"),u=s.call(t,"w")):(n=u=!0,i=!1),c={value:e,configurable:n,enumerable:i,writable:u},l?r(a(l),c):c}).gs=function(t,e,n){var u,l,c,f;return"string"!=typeof t?(c=n,n=e,e=t,t=null):c=arguments[3],o(e)?i(e)?o(n)?i(n)||(c=n,n=void 0):n=void 0:(c=e,e=n=void 0):e=void 0,o(t)?(u=s.call(t,"c"),l=s.call(t,"e")):(u=!0,l=!1),f={get:e,set:n,configurable:u,enumerable:l},c?r(a(c),f):f}},function(t,e,n){"use strict";var o=n(10),i=/^\s*class[\s{/}]/,r=Function.prototype.toString;t.exports=function(t){return!!o(t)&&!i.test(r.call(t))}},function(t,e,n){"use strict";var o=n(11);t.exports=function(t){if("function"!=typeof t)return!1;if(!hasOwnProperty.call(t,"length"))return!1;try{if("number"!=typeof t.length)return!1;if("function"!=typeof t.call)return!1;if("function"!=typeof t.apply)return!1}catch(t){return!1}return!o(t)}},function(t,e,n){"use strict";var o=n(12);t.exports=function(t){if(!o(t))return!1;try{return!!t.constructor&&t.constructor.prototype===t}catch(t){return!1}}},function(t,e,n){"use strict";var o=n(3),i={object:!0,function:!0,undefined:!0};t.exports=function(t){return!!o(t)&&hasOwnProperty.call(i,typeof t)}},function(t,e,n){"use strict";t.exports=n(14)()?Object.assign:n(15)},function(t,e,n){"use strict";t.exports=function(){var t,e=Object.assign;return"function"==typeof e&&(e(t={foo:"raz"},{bar:"dwa"},{trzy:"trzy"}),t.foo+t.bar+t.trzy==="razdwatrzy")}},function(t,e,n){"use strict";var o=n(16),i=n(20),r=Math.max;t.exports=function(t,e){var n,a,s,u=r(arguments.length,2);for(t=Object(i(t)),s=function(o){try{t[o]=e[o]}catch(t){n||(n=t)}},a=1;a<u;++a)o(e=arguments[a]).forEach(s);if(void 0!==n)throw n;return t}},function(t,e,n){"use strict";t.exports=n(17)()?Object.keys:n(18)},function(t,e,n){"use strict";t.exports=function(){try{return Object.keys("primitive"),!0}catch(t){return!1}}},function(t,e,n){"use strict";var o=n(2),i=Object.keys;t.exports=function(t){return i(o(t)?Object(t):t)}},function(t,e,n){"use strict";t.exports=function(){}},function(t,e,n){"use strict";var o=n(2);t.exports=function(t){if(!o(t))throw new TypeError("Cannot use null or undefined");return t}},function(t,e,n){"use strict";var o=n(2),i=Array.prototype.forEach,r=Object.create,a=function(t,e){var n;for(n in t)e[n]=t[n]};t.exports=function(t){var e=r(null);return i.call(arguments,(function(t){o(t)&&a(Object(t),e)})),e}},function(t,e,n){"use strict";t.exports=n(23)()?String.prototype.contains:n(24)},function(t,e,n){"use strict";var o="razdwatrzy";t.exports=function(){return"function"==typeof o.contains&&(!0===o.contains("dwa")&&!1===o.contains("foo"))}},function(t,e,n){"use strict";var o=String.prototype.indexOf;t.exports=function(t){return o.call(this,t,arguments[1])>-1}},function(t,e,n){"use strict";t.exports=function(t){if("function"!=typeof t)throw new TypeError(t+" is not a function");return t}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}();var i=window.location.href.indexOf("danmu-debug")>-1,r=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.constructorName=e||""}return o(t,[{key:"info",value:function(t){for(var e,n=arguments.length,o=Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];i&&(e=console).log.apply(e,["[Danmu Log]["+this.constructorName+"]",t].concat(o))}}]),t}();e.default=r,t.exports=e.default},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),i=s(n(0)),r=s(n(1)),a=s(n(28));function s(t){return t&&t.__esModule?t:{default:t}}var u=function(t){function e(t){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);var n=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return n.setLogger("control"),n.danmu=t,n.main=new a.default(t),t.config.defaultOff||n.main.start(),n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),o(e,[{key:"createSwitch",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.logger.info("createSwitch"),this.switchBtn=r.default.createDom("dk-switch",'<span class="txt">弹</span>',{},"danmu-switch "+(t?"danmu-switch-active":"")),this.switchBtn}},{key:"destroy",value:function(){for(var t in this.logger.info("destroy"),this.main.destroy(),this)delete this[t]}}]),e}(i.default);e.default=u,t.exports=e.default},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),i=u(n(0)),r=u(n(29)),a=u(n(30)),s=u(n(1));function u(t){return t&&t.__esModule?t:{default:t}}var l=function(t){function e(t){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);var n=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));n.setLogger("main"),n.danmu=t,n.container=t.container,n.channel=new r.default(t),n.data=[].concat(t.config.comments),n.playedData=[],n.queue=[],n.timer=null,n.retryTimer=null,n.retryStatus="normal",n.interval=t.config.interval||2e3,n.status="idle",s.default.on(t,"bullet_remove",n.updateQueue.bind(n),"destroy");var o=n;return s.default.on(n.danmu,"changeDirection",(function(t){o.danmu.direction=t}),"destroy"),n.nums=0,n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),o(e,[{key:"destroy",value:function(){for(var t in this.logger.info("destroy"),clearTimeout(this.dataHandleTimer),this.channel.destroy(),this.data=[],this)delete this[t]}},{key:"updateQueue",value:function(t){this.logger.info("updateQueue");var e=this;e.queue.some((function(n,o){return n.id===t.bullet.id&&(e.queue.splice(o,1),!0)}))}},{key:"init",value:function(t,e){e.logger.info("init"),e||(e=this),e.retryStatus="normal",e.data.sort((function(t,e){return t.start-e.start}));e.retryTimer||function t(){"closed"===e.status&&"stop"===e.retryStatus||("playing"===e.status&&(e.readData(),e.dataHandle()),"stop"===e.retryStatus&&"paused"!==this.status||(e.dataHandleTimer=setTimeout((function(){t()}),e.interval-1e3)))}()}},{key:"start",value:function(){this.logger.info("start");this.status="playing",this.queue=[],this.container.innerHTML="",this.channel.resetWithCb(this.init,this)}},{key:"stop",value:function(){this.logger.info("stop");this.status="closed",this.retryTimer=null,this.retryStatus="stop",this.channel.reset(),this.queue=[],this.container.innerHTML=""}},{key:"play",value:function(){var t=this;this.logger.info("play"),this.status="playing";var e=this.channel.channels,n=this.danmu.container.getBoundingClientRect();e&&e.length>0&&["scroll","top","bottom"].forEach((function(o){t.queue.forEach((function(t){t.startMove(n),t.resized=!0}));for(var i=0;i<e.length;i++)e[i].queue[o].forEach((function(t){t.resized=!1}))}))}},{key:"pause",value:function(){this.logger.info("pause"),this.status="paused";var t=this.channel.channels,e=this.danmu.container.getBoundingClientRect();t&&t.length>0&&this.queue.forEach((function(t){t.pauseMove(e)}))}},{key:"dataHandle",value:function(){var t=this;"paused"!==this.status&&"closed"!==this.status&&t.queue.length&&t.queue.forEach((function(e){"waiting"===e.status&&e.startMove(t.channel.containerPos)}))}},{key:"readData",value:function(){var t=this,e=this.danmu,n=0;e.player&&e.player.currentTime&&(n=s.default.formatTime(e.player.currentTime));var o=void 0,i=t.interval,r=t.channel,u=void 0;e.player?(u=t.data.filter((function(e){return!e.start&&t.danmu.hideArr.indexOf(e.mode)<0&&(!e.color||t.danmu.hideArr.indexOf("color")<0)&&(e.start=n),t.danmu.hideArr.indexOf(e.mode)<0&&(!e.color||t.danmu.hideArr.indexOf("color")<0)&&e.start-i<=n&&n<=e.start+i})),e.live&&(t.data=t.data.filter((function(t){return t.start||(t.start=n),t.start>n-3*i})))):0===(u=t.data.splice(0,1)).length&&(u=t.playedData.splice(0,1)),u.length>0&&u.forEach((function(n){t.forceDuration&&t.forceDuration!=n.duration&&(n.duration=t.forceDuration),o=new a.default(e,n),n.hasAttached||(o.attach(),n.hasAttached=!0,r.addBullet(o).result?(t.queue.push(o),t.nums++,o.topInit()):(o.detach(),n.hasAttached=!1,n.noDiscard&&(n.prior?t.data.unshift(n):t.data.push(n))))}))}}]),e}(i.default);e.default=l,t.exports=e.default},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),i=a(n(0)),r=a(n(1));function a(t){return t&&t.__esModule?t:{default:t}}var s=function(t){function e(t){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);var n=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));n.setLogger("channel"),n.danmu=t,n.reset();var o=n;return r.default.on(n.danmu,"bullet_remove",(function(t){o.removeBullet(t.bullet)}),"destroy"),n.direction=t.direction,r.default.on(n.danmu,"changeDirection",(function(t){o.direction=t}),"destroy"),n.containerPos=n.danmu.container.getBoundingClientRect(),n.containerWidth=n.containerPos.width,n.containerHeight=n.containerPos.height,n.containerLeft=n.containerPos.left,n.containerRight=n.containerPos.right,r.default.on(n.danmu,"channel_resize",(function(){o.containerPos=o.danmu.container.getBoundingClientRect(),o.resizing||(o.containerWidth=o.containerPos.width,o.containerHeight=o.containerPos.height,o.containerLeft=o.containerPos.left,o.containerRight=o.containerPos.right,o.resize(!0))}),"destroy"),n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),o(e,[{key:"destroy",value:function(){for(var t in this.logger.info("destroy"),clearTimeout(this.resizeTimer),clearTimeout(this.resetTimer),this.channels=[],this)delete this[t]}},{key:"resize",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.logger.info("resize");var e=this.danmu.container,n=this;n.resizing||(n.resizing=!0,this.resizeTimer=setTimeout((function(){n.danmu.bulletBtn.main.status;n.danmu.bulletBtn.main.data&&n.danmu.bulletBtn.main.data.forEach((function(t){t.bookChannelId&&(delete t.bookChannelId,n.logger.info("resize导致"+t.id+"号优先弹幕预定取消"))})),n.logger.info("resize导致所有轨道恢复正常使用");var o=e.getBoundingClientRect();n.width=o.width,n.height=o.height,n.danmu.config.area&&n.danmu.config.area.start>=0&&n.danmu.config.area.end>=n.danmu.config.area.start&&("b2t"===n.direction?n.width=n.width*(n.danmu.config.area.end-n.danmu.config.area.start):n.height=n.height*(n.danmu.config.area.end-n.danmu.config.area.start)),n.container=e;var i=n.danmu.config.channelSize||(/mobile/gi.test(navigator.userAgent)?10:12),r=void 0;r="b2t"===n.direction?Math.floor(n.width/i):Math.floor(n.height/i);for(var a=[],s=0;s<r;s++)a[s]={id:s,queue:{scroll:[],top:[],bottom:[]},operating:{scroll:!1,top:!1,bottom:!1},bookId:{}};if(n.channels&&n.channels.length<=a.length){for(var u=function(e){a[e]={id:e,queue:{scroll:[],top:[],bottom:[]},operating:{scroll:!1,top:!1,bottom:!1},bookId:{}},["scroll","top"].forEach((function(o){n.channels[e].queue[o].forEach((function(i){i.el&&(a[e].queue[o].push(i),i.resized||(i.pauseMove(n.containerPos,t),"paused"!==i.danmu.bulletBtn.main.status&&i.startMove(n.containerPos),i.resized=!0))}))})),n.channels[e].queue.bottom.forEach((function(o){if(o.el){if(a[e+a.length-n.channels.length].queue.bottom.push(o),o.channel_id[0]+o.channel_id[1]-1===e){var r=[].concat(o.channel_id);o.channel_id=[r[0]-n.channels.length+a.length,r[1]],o.top=o.channel_id[0]*i,n.danmu.config.area&&n.danmu.config.area.start&&(o.top+=n.containerHeight*n.danmu.config.area.start),o.topInit()}o.resized||(o.pauseMove(n.containerPos,t),"paused"!==o.danmu.bulletBtn.main.status&&o.startMove(n.containerPos),o.resized=!0)}}))},l=0;l<n.channels.length;l++)u(l);for(var c=function(t){["scroll","top","bottom"].forEach((function(e){a[t].queue[e].forEach((function(t){t.resized=!1}))}))},f=0;f<a.length;f++)c(f);n.channels=a,"b2t"===n.direction?n.channelWidth=i:n.channelHeight=i}else if(n.channels&&n.channels.length>a.length){for(var h=function(e){a[e]={id:e,queue:{scroll:[],top:[],bottom:[]},operating:{scroll:!1,top:!1,bottom:!1},bookId:{}},["scroll","top","bottom"].forEach((function(o){if("top"===o&&e>Math.floor(a.length/2));else if("bottom"===o&&e<=Math.floor(a.length/2));else{var r="bottom"===o?e-a.length+n.channels.length:e;n.channels[r].queue[o].forEach((function(s,u){if(s.el){if(a[e].queue[o].push(s),"bottom"===o&&s.channel_id[0]+s.channel_id[1]-1===r){var l=[].concat(s.channel_id);s.channel_id=[l[0]-n.channels.length+a.length,l[1]],s.top=s.channel_id[0]*i,n.danmu.config.area&&n.danmu.config.area.start&&(s.top+=n.containerHeight*n.danmu.config.area.start),s.topInit()}s.pauseMove(n.containerPos,t),"paused"!==s.danmu.bulletBtn.main.status&&s.startMove(n.containerPos),s.resized||(s.resized=!0)}n.channels[r].queue[o].splice(u,1)}))}}))},d=0;d<a.length;d++)h(d);for(var p=function(t){["scroll","top","bottom"].forEach((function(e){a[t].queue[e].forEach((function(t){t.resized=!1}))}))},m=0;m<a.length;m++)p(m);n.channels=a,"b2t"===n.direction?n.channelWidth=i:n.channelHeight=i}n.resizing=!1}),10))}},{key:"addBullet",value:function(t){var e=this,n=this.danmu,o=this.channels,i=void 0,r=void 0,a=void 0;if("b2t"===e.direction?(r=this.channelWidth,a=Math.ceil(t.width/r)):(i=this.channelHeight,a=Math.ceil(t.height/i)),a>o.length)return{result:!1,message:"exceed channels.length, occupy="+a+",channelsSize="+o.length};for(var s=!0,u=void 0,l=-1,c=0,f=o.length;c<f;c++)if(o[c].queue[t.mode].some((function(e){return e.id===t.id})))return{result:!1,message:"exsited, channelOrder="+c+",danmu_id="+t.id};if("scroll"===t.mode)for(var h=0,d=o.length-a;h<=d;h++){s=!0;for(var p=h;p<h+a;p++){if((u=o[p]).operating.scroll){s=!1;break}if((u.bookId.scroll||t.prior)&&u.bookId.scroll!==t.id){s=!1;break}u.operating.scroll=!0;var m=u.queue.scroll[0];if(m){var g=m.el.getBoundingClientRect();if("b2t"===e.direction){if(g.bottom>e.containerPos.bottom){s=!1,u.operating.scroll=!1;break}}else if(g.right>e.containerPos.right){s=!1,u.operating.scroll=!1;break}var v,b=void 0,y=void 0,w=void 0,_=void 0;if("b2t"===e.direction?(y=(g.top-e.containerPos.top+g.height)/(b=(e.containerPos.height+g.height)/m.duration),w=e.containerPos.height,_=(e.containerPos.height+t.height)/t.duration):(y=(g.left-e.containerPos.left+g.width)/(b=(e.containerPos.width+g.width)/m.duration),w=e.containerPos.width,_=(e.containerPos.width+t.width)/t.duration),v=w/_,n.config.bOffset||(n.config.bOffset=0),b<_&&y+n.config.bOffset>v){s=!1,u.operating.scroll=!1;break}}u.operating.scroll=!1}if(s){l=h;break}}else if("top"===t.mode)for(var k=0,O=o.length-a;k<=O;k++){s=!0;for(var x=k;x<k+a;x++){if(x>Math.floor(o.length/2)){s=!1;break}if((u=o[x]).operating[t.mode]){s=!1;break}if((u.bookId[t.mode]||t.prior)&&u.bookId[t.mode]!==t.id){s=!1;break}if(u.operating[t.mode]=!0,u.queue[t.mode].length>0){s=!1,u.operating[t.mode]=!1;break}u.operating[t.mode]=!1}if(s){l=k;break}}else if("bottom"===t.mode)for(var M=o.length-a;M>=0;M--){s=!0;for(var C=M;C<M+a;C++){if(C<=Math.floor(o.length/2)){s=!1;break}if((u=o[C]).operating[t.mode]){s=!1;break}if((u.bookId[t.mode]||t.prior)&&u.bookId[t.mode]!==t.id){s=!1;break}if(u.operating[t.mode]=!0,u.queue[t.mode].length>0){s=!1,u.operating[t.mode]=!1;break}u.operating[t.mode]=!1}if(s){l=M;break}}if(-1!==l){for(var j=l,P=l+a;j<P;j++)(u=o[j]).operating[t.mode]=!0,u.queue[t.mode].unshift(t),t.prior&&(delete u.bookId[t.mode],e.logger.info(j+"号轨道恢复正常使用")),u.operating[t.mode]=!1;if(t.prior)if(e.logger.info(t.id+"号优先弹幕运行完毕"),delete t.bookChannelId,n.player)n.bulletBtn.main.data.some((function(e){return e.id===t.id&&(delete e.bookChannelId,!0)}));return t.channel_id=[l,a],"b2t"===e.direction?(t.top=l*r,e.danmu.config.area&&e.danmu.config.area.start&&(t.top+=e.containerWidth*e.danmu.config.area.start)):(t.top=l*i,e.danmu.config.area&&e.danmu.config.area.start&&(t.top+=e.containerHeight*e.danmu.config.area.start)),{result:t,message:"success"}}if(t.options.realTime){var T=0,B=null;if(e.danmu.bulletBtn.main.queue.forEach((function(t,n){t.el&&t.el.getBoundingClientRect().right>e.containerPos.right&&t.start>=T&&(T=t.start,n,B=t)})),B){t.channel_id=B.channel_id;for(var E=B.channel_id[0],z=B.channel_id[0]+B.channel_id[1];E<z;E++)(u=o[E]).operating[t.mode]=!0,u.queue[t.mode].unshift(t),t.prior&&delete u.bookId[t.mode],u.operating[t.mode]=!1;return t.top=B.top,e.danmu.config.area&&e.danmu.config.area.start&&(t.top+=e.containerHeight*e.danmu.config.area.start),{result:t,message:"success"}}}if(t.prior)if(t.bookChannelId){if(n.player)n.bulletBtn.main.data.some((function(n){return n.id===t.id&&(e.logger.info(t.id+"号优先弹幕将于2秒后再次请求注册"),n.start+=2e3,!0)}))}else{l=-1;for(var L=0,S=o.length-a;L<=S;L++){s=!0;for(var D=L;D<L+a;D++)if(o[D].bookId[t.mode]){s=!1;break}if(s){l=L;break}}if(-1!==l){for(var q=l;q<l+a;q++)o[q].bookId[t.mode]=t.id,e.logger.info(q+"号轨道被"+t.id+"号优先弹幕预定");if(n.player)n.bulletBtn.main.data.some((function(n){return n.id===t.id&&(e.logger.info(t.id+"号优先弹幕将于2秒后再次请求注册"),n.start+=2e3,n.bookChannelId=[l,a],e.logger.info(t.id+"号优先弹幕预定了"+l+"~"+(l+a-1)+"号轨道"),!0)}))}}return{result:!1,message:"no surplus will right"}}},{key:"removeBullet",value:function(t){this.logger.info("removeBullet "+(t.options.txt||"[DOM Element]"));for(var e=this.channels,n=t.channel_id,o=void 0,i=n[0],r=n[0]+n[1];i<r;i++)if(o=e[i]){o.operating[t.mode]=!0;var a=-1;o.queue[t.mode].some((function(e,n){return e.id===t.id&&(a=n,!0)})),a>-1&&o.queue[t.mode].splice(a,1),o.operating[t.mode]=!1}t.options.loop&&this.danmu.bulletBtn.main.playedData.push(t.options)}},{key:"resetArea",value:function(){this.logger.info("resetArea");var t=this.danmu.container,e=this,n=t.getBoundingClientRect();e.width=n.width,e.height=n.height,e.danmu.config.area&&e.danmu.config.area.start>=0&&e.danmu.config.area.end>=e.danmu.config.area.start&&("b2t"===e.direction?e.width=e.width*(e.danmu.config.area.end-e.danmu.config.area.start):e.height=e.height*(e.danmu.config.area.end-e.danmu.config.area.start)),e.container=t;var o=e.danmu.config.channelSize||(/mobile/gi.test(navigator.userAgent)?10:12),i=void 0;i="b2t"===e.direction?Math.floor(e.width/o):Math.floor(e.height/o);for(var r=[],a=0;a<i;a++)r[a]={id:a,queue:{scroll:[],top:[],bottom:[]},operating:{scroll:!1,top:!1,bottom:!1},bookId:{}};if(e.channels&&e.channels.length<=r.length){for(var s=function(t){r[t]={id:t,queue:{scroll:[],top:[],bottom:[]},operating:{scroll:!1,top:!1,bottom:!1},bookId:{}},["scroll","top"].forEach((function(n){e.channels[t].queue[n].forEach((function(o){o.el&&(r[t].queue[n].push(o),o.resized||(o.pauseMove(e.containerPos,!1),o.startMove(e.containerPos),o.resized=!0))}))})),e.channels[t].queue.bottom.forEach((function(n){if(n.el){if(r[t+r.length-e.channels.length].queue.bottom.push(n),n.channel_id[0]+n.channel_id[1]-1===t){var i=[].concat(n.channel_id);n.channel_id=[i[0]-e.channels.length+r.length,i[1]],n.top=n.channel_id[0]*o,e.danmu.config.area&&e.danmu.config.area.start&&(n.top+=e.containerHeight*e.danmu.config.area.start),n.topInit()}n.resized||(n.pauseMove(e.containerPos,!1),n.startMove(e.containerPos),n.resized=!0)}}))},u=0;u<e.channels.length;u++)s(u);for(var l=function(t){["scroll","top","bottom"].forEach((function(e){r[t].queue[e].forEach((function(t){t.resized=!1}))}))},c=0;c<r.length;c++)l(c);e.channels=r,"b2t"===e.direction?e.channelWidth=o:e.channelHeight=o}else if(e.channels&&e.channels.length>r.length){for(var f=function(t){r[t]={id:t,queue:{scroll:[],top:[],bottom:[]},operating:{scroll:!1,top:!1,bottom:!1},bookId:{}},["scroll","top","bottom"].forEach((function(n){if("top"===n&&t>Math.floor(r.length/2));else if("bottom"===n&&t<=Math.floor(r.length/2));else{var i="bottom"===n?t-r.length+e.channels.length:t;e.channels[i].queue[n].forEach((function(a,s){if(a.el){if(r[t].queue[n].push(a),"bottom"===n&&a.channel_id[0]+a.channel_id[1]-1===i){var u=[].concat(a.channel_id);a.channel_id=[u[0]-e.channels.length+r.length,u[1]],a.top=a.channel_id[0]*o,e.danmu.config.area&&e.danmu.config.area.start&&(a.top+=e.containerHeight*e.danmu.config.area.start),a.topInit()}a.resized||(a.pauseMove(e.containerPos,!1),a.startMove(e.containerPos),a.resized=!0)}e.channels[i].queue[n].splice(s,1)}))}}))},h=0;h<r.length;h++)f(h);for(var d=function(t){["scroll","top","bottom"].forEach((function(e){r[t].queue[e].forEach((function(t){t.resized=!1}))}))},p=0;p<r.length;p++)d(p);e.channels=r,"b2t"===e.direction?e.channelWidth=o:e.channelHeight=o}}},{key:"reset",value:function(){this.logger.info("reset");var t=this.danmu.container,e=this;e.danmu.bulletBtn&&e.danmu.bulletBtn.main&&e.danmu.bulletBtn.main.queue.forEach((function(t){t.pauseMove(e.containerPos),t.remove()})),e.channels&&e.channels.length>0&&["scroll","top","bottom"].forEach((function(t){for(var n=0;n<e.channels.length;n++)e.channels[n].queue[t].forEach((function(t){t.pauseMove(e.containerPos),t.remove()}))})),this.resetTimer=setTimeout((function(){var n=t.getBoundingClientRect();e.width=n.width,e.height=n.height,e.danmu.config.area&&e.danmu.config.area.start>=0&&e.danmu.config.area.end>=e.danmu.config.area.start&&("b2t"===e.direction?e.width=e.width*(e.danmu.config.area.end-e.danmu.config.area.start):e.height=e.height*(e.danmu.config.area.end-e.danmu.config.area.start)),e.container=t;var o=e.danmu.config.channelSize||(/mobile/gi.test(navigator.userAgent)?10:12),i=void 0;i="b2t"===e.direction?Math.floor(e.width/o):Math.floor(e.height/o);for(var r=[],a=0;a<i;a++)r[a]={id:a,queue:{scroll:[],top:[],bottom:[]},operating:{scroll:!1,top:!1,bottom:!1},bookId:{}};e.channels=r,"b2t"===e.direction?e.channelWidth=o:e.channelHeight=o}),200)}},{key:"resetWithCb",value:function(t,e){this.logger.info("resetWithCb");var n=this.danmu.container,o=this;o.channels&&o.channels.length>0&&["scroll","top","bottom"].forEach((function(t){for(var e=0;e<o.channels.length;e++)o.channels[e].queue[t].forEach((function(t){t.pauseMove(o.containerPos),t.remove()}))}));var i=n.getBoundingClientRect();o.width=i.width,o.height=i.height,o.danmu.config.area&&o.danmu.config.area.start>=0&&o.danmu.config.area.end>=o.danmu.config.area.start&&("b2t"===o.direction?o.width=o.width*(o.danmu.config.area.end-o.danmu.config.area.start):o.height=o.height*(o.danmu.config.area.end-o.danmu.config.area.start)),o.container=n;var r=o.danmu.config.channelSize||(/mobile/gi.test(navigator.userAgent)?10:12),a=void 0;a="b2t"===o.direction?Math.floor(o.width/r):Math.floor(o.height/r);for(var s=[],u=0;u<a;u++)s[u]={id:u,queue:{scroll:[],top:[],bottom:[]},operating:{scroll:!1,top:!1,bottom:!1},bookId:{}};o.channels=s,o.channelHeight=r,t&&t(!0,e)}}]),e}(i.default);e.default=s,t.exports=e.default},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),i=a(n(0)),r=a(n(1));function a(t){return t&&t.__esModule?t:{default:t}}var s=function(t){function e(t,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);var o=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));o.setLogger("bullet"),o.danmu=t,o.options=n,o.duration=n.duration,o.moveV=n.moveV,o.id=n.id,o.container=t.container,o.start=n.start,o.prior=n.prior,o.color=n.color,o.bookChannelId=n.bookChannelId,o.direction=t.direction;var i=o;o.onChangeDirection=function(t){i.direction=t},o.danmu.on("changeDirection",o.onChangeDirection);var a=void 0;if(o.domObj=t.domObj,n.el&&1===n.el.nodeType)(a=o.domObj.use()).appendChild(r.default.copyDom(n.el));else if((a=o.domObj.use()).textContent=n.txt,n.style){var s=n.style;Object.keys(s).forEach((function(t){a.style[t]=s[t]}))}"top"===n.mode||"bottom"===n.mode?o.mode=n.mode:o.mode="scroll",o.el=a,n.like&&n.like.el&&o.setLikeDom(n.like.el,n.like.style),o.status="waiting";var u=o.container.getBoundingClientRect(),l=Math.floor(Math.random()*(u.width/10>100?200:u.width/10));return n.realTime&&(l=0),o.el.style.left=u.width+l+"px",o.containerPos=u,o}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),o(e,[{key:"attach",value:function(){if(this.container.appendChild(this.el),this.elPos=this.el.getBoundingClientRect(),"b2t"===this.direction?(this.width=this.elPos.height,this.height=this.elPos.width):(this.width=this.elPos.width,this.height=this.elPos.height),this.moveV){var t=this.containerPos;this.duration=(t.width+this.width)/this.moveV*1e3}this.danmu.config.mouseControl&&this.el.addEventListener("mouseover",this.mouseoverFun.bind(this))}},{key:"mouseoverFun",value:function(t){this.danmu.mouseControl&&this.danmu.config.mouseControlPause||"waiting"===this.status||"end"===this.status||this.danmu.emit("bullet_hover",{bullet:this,event:t})}},{key:"detach",value:function(){this.container&&this.el&&this.domObj.unuse(this.el),this.danmu.off("changeDirection",this.onChangeDirection)}},{key:"topInit",value:function(){if(this.logger.info("topInit #"+(this.options.txt||"[DOM Element]")+"#"),"b2t"===this.direction){var t=this.containerPos;this.el.style.transformOrigin="left top",this.el.style.transform="translateX(-"+this.top+"px) translateY("+t.height+"px) translateZ(0px) rotate(90deg)",this.el.style.transition="transform 0s linear 0s"}else this.el.style.top=this.top+"px"}},{key:"pauseMove",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.logger.info("pauseMove #"+(this.options.txt||"[DOM Element]")+"#");var n=this;if("paused"!==this.status&&("forcedPause"!==n.status&&(this.status="paused"),clearTimeout(n.removeTimer),this.el))if(this.el.style.willChange="auto","scroll"===this.mode){if(e){var o=((new Date).getTime()-n.moveTime)/1e3,i=o*this.moveV,r=0;r=n.moveMoreS-i>=0?"b2t"===this.direction?(n.moveMoreS-i)/n.moveContainerHeight*t.height:(n.moveMoreS-i)/n.moveContainerWidth*t.width:n.moveMoreS-i,"b2t"===this.direction?this.el.style.transform="translateX(-"+this.top+"px) translateY("+r+"px) translateZ(0px) rotate(90deg)":this.el.style.left=r+"px"}else"b2t"===this.direction?this.el.style.transform="translateX(-"+this.top+"px) translateY("+(this.el.getBoundingClientRect().top-t.top)+"px) translateZ(0px) rotate(90deg)":this.el.style.left=this.el.getBoundingClientRect().left-t.left+"px";"b2t"===this.direction||(this.el.style.transform="translateX(0px) translateY(0px) translateZ(0px)"),this.el.style.transition="transform 0s linear 0s"}else this.pastDuration&&this.startTime?this.pastDuration=this.pastDuration+(new Date).getTime()-this.startTime:this.pastDuration=1}},{key:"startMove",value:function(t,e){this.logger.info("startMove #"+(this.options.txt||"[DOM Element]")+"#");var n=this;if(n.hasMove||(n.danmu.emit("bullet_start",n),n.hasMove=!0),("forcedPause"!==n.status||e)&&this.el&&"start"!==this.status)if(this.status="start",this.el.style.willChange="transform","scroll"===this.mode)if("b2t"===this.direction){this.moveV=(t.height+this.height)/this.duration*1e3;var o=(n.el.getBoundingClientRect().bottom-t.top)/this.moveV;this.el.style.transition="transform "+o+"s linear 0s",this.startMoveTimer=setTimeout((function(){n.el&&(n.el.style.transform="translateX(-"+n.top+"px) translateY(-"+n.height+"px) translateZ(0px) rotate(90deg)",n.moveTime=(new Date).getTime(),n.moveMoreS=n.el.getBoundingClientRect().top-t.top,n.moveContainerHeight=t.height,n.removeTimer=setTimeout(a,1e3*o))}),20)}else{this.moveV=(t.width+this.width)/this.duration*1e3;var i=(n.el.getBoundingClientRect().right-t.left)/this.moveV;this.el.style.transition="transform "+i+"s linear 0s",this.startMoveTimer=setTimeout((function(){n.el&&(n.el.style.transform="translateX(-"+(n.el.getBoundingClientRect().right-t.left)+"px) translateY(0px) translateZ(0px)",n.moveTime=(new Date).getTime(),n.moveMoreS=n.el.getBoundingClientRect().left-t.left,n.moveContainerWidth=t.width,n.removeTimer=setTimeout(a,1e3*i))}),20)}else{this.el.style.left="50%",this.el.style.margin="0 0 0 -"+this.width/2+"px",this.pastDuration||(this.pastDuration=1);var r=this.duration>=this.pastDuration?this.duration-this.pastDuration:0;this.removeTimer=setTimeout(a,r),this.startTime=(new Date).getTime()}function a(){if(n.el)if("scroll"===n.mode){var t=n.containerPos,e=n.el.getBoundingClientRect();"b2t"===n.direction?e&&e.bottom<=t.top+100?(n.status="end",n.remove()):(n.pauseMove(t),"paused"!==n.danmu.bulletBtn.main.status&&n.startMove(t)):e&&e.right<=t.left+100?(n.status="end",n.remove()):(n.pauseMove(t),"paused"!==n.danmu.bulletBtn.main.status&&n.startMove(t))}else n.status="end",n.remove()}}},{key:"remove",value:function(){this.logger.info("remove #"+(this.options.txt||"[DOM Element]")+"#");(this.removeTimer&&clearTimeout(this.removeTimer),this.startMoveTimer&&clearTimeout(this.startMoveTimer),this.el&&this.el.parentNode)&&(this.el.style.willChange="auto",this.danmu.off("changeDirection",this.onChangeDirection),this.domObj.unuse(this.el),this.el.parentNode.removeChild(this.el),this.el=null,this.danmu.emit("bullet_remove",{bullet:this}))}},{key:"setFontSize",value:function(t){this.el&&(this.el.style.fontSize=t)}},{key:"setLikeDom",value:function(t,e){if(t){Object.keys(e).forEach((function(n){t.style[n]=e[n]}));if(t.className="danmu-like",this.el){var n=this.el.querySelector(".danmu-like");n&&this.el.removeChild(n),this.el.innerHTML=""+this.el.innerHTML+t.outerHTML}}return t}}]),e}(i.default);e.default=s,t.exports=e.default},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}();var i=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),e={initDOM:function(){return document.createElement("div")},initSize:10},this.init(e)}return o(t,[{key:"init",value:function(t){this.idleList=[],this.usingList=[],this._id=0,this.options=t,this._expand(t.initSize)}},{key:"use",value:function(){this.idleList.length||this._expand(1);var t=this.idleList.shift();return this.usingList.push(t),t}},{key:"unuse",value:function(t){var e=this.usingList.indexOf(t);e<0||(this.usingList.splice(e,1),t.innerHTML="",t.textcontent="",t.style="",this.idleList.push(t))}},{key:"_expand",value:function(t){for(var e=0;e<t;e++)this.idleList.push(this.options.initDOM(this._id++))}},{key:"destroy",value:function(){for(var t=0;t<this.idleList.length;t++)this.idleList[t].innerHTML="",this.idleList[t].textcontent="",this.idleList[t].style="";for(var e=0;e<this.usingList.length;e++)this.usingList[e].innerHTML="",this.usingList[e].textcontent="",this.usingList[e].style="";for(var n in this)delete this[n]}}]),t}();e.default=i,t.exports=e.default},function(t){t.exports=JSON.parse('{"version":"0.2.23"}')},function(t,e,n){var o=n(34);"string"==typeof o&&(o=[[t.i,o,""]]);var i={hmr:!0,transform:void 0,insertInto:void 0};n(36)(o,i);o.locals&&(t.exports=o.locals)},function(t,e,n){(t.exports=n(35)(!1)).push([t.i,".danmu{overflow:hidden;-webkit-user-select:none;-moz-user-select:none;user-select:none;-ms-user-select:none}.danmu>*{position:absolute;white-space:nowrap}.danmu-switch{width:32px;height:20px;border-radius:100px;background-color:#ccc;-webkit-box-sizing:border-box;box-sizing:border-box;outline:none;cursor:pointer;position:relative;text-align:center;margin:10px auto}.danmu-switch.danmu-switch-active{padding-left:12px;background-color:#f85959}.danmu-switch span.txt{width:20px;height:20px;line-height:20px;text-align:center;display:block;border-radius:100px;background-color:#ffffff;-webkit-box-shadow:-2px 0 0 0 rgba(0, 0, 0, .04);box-shadow:-2px 0 0 0 rgba(0, 0, 0, .04);font-family:PingFangSC;font-size:10px;font-weight:500;color:#f44336}\n",""])},function(t,e){t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n=function(t,e){var n=t[1]||"",o=t[3];if(!o)return n;if(e&&"function"==typeof btoa){var i=(a=o,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(a))))+" */"),r=o.sources.map((function(t){return"/*# sourceURL="+o.sourceRoot+t+" */"}));return[n].concat(r).concat([i]).join("\n")}var a;return[n].join("\n")}(e,t);return e[2]?"@media "+e[2]+"{"+n+"}":n})).join("")},e.i=function(t,n){"string"==typeof t&&(t=[[null,t,""]]);for(var o={},i=0;i<this.length;i++){var r=this[i][0];"number"==typeof r&&(o[r]=!0)}for(i=0;i<t.length;i++){var a=t[i];"number"==typeof a[0]&&o[a[0]]||(n&&!a[2]?a[2]=n:n&&(a[2]="("+a[2]+") and ("+n+")"),e.push(a))}},e}},function(t,e,n){var o,i,r={},a=(o=function(){return window&&document&&document.all&&!window.atob},function(){return void 0===i&&(i=o.apply(this,arguments)),i}),s=function(t){return document.querySelector(t)},u=function(t){var e={};return function(t){if("function"==typeof t)return t();if(void 0===e[t]){var n=s.call(this,t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}}(),l=null,c=0,f=[],h=n(37);function d(t,e){for(var n=0;n<t.length;n++){var o=t[n],i=r[o.id];if(i){i.refs++;for(var a=0;a<i.parts.length;a++)i.parts[a](o.parts[a]);for(;a<o.parts.length;a++)i.parts.push(y(o.parts[a],e))}else{var s=[];for(a=0;a<o.parts.length;a++)s.push(y(o.parts[a],e));r[o.id]={id:o.id,refs:1,parts:s}}}}function p(t,e){for(var n=[],o={},i=0;i<t.length;i++){var r=t[i],a=e.base?r[0]+e.base:r[0],s={css:r[1],media:r[2],sourceMap:r[3]};o[a]?o[a].parts.push(s):n.push(o[a]={id:a,parts:[s]})}return n}function m(t,e){var n=u(t.insertInto);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");var o=f[f.length-1];if("top"===t.insertAt)o?o.nextSibling?n.insertBefore(e,o.nextSibling):n.appendChild(e):n.insertBefore(e,n.firstChild),f.push(e);else if("bottom"===t.insertAt)n.appendChild(e);else{if("object"!=typeof t.insertAt||!t.insertAt.before)throw new Error("[Style Loader]\n\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\n Must be 'top', 'bottom', or Object.\n (https://github.com/webpack-contrib/style-loader#insertat)\n");var i=u(t.insertInto+" "+t.insertAt.before);n.insertBefore(e,i)}}function g(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t);var e=f.indexOf(t);e>=0&&f.splice(e,1)}function v(t){var e=document.createElement("style");return void 0===t.attrs.type&&(t.attrs.type="text/css"),b(e,t.attrs),m(t,e),e}function b(t,e){Object.keys(e).forEach((function(n){t.setAttribute(n,e[n])}))}function y(t,e){var n,o,i,r;if(e.transform&&t.css){if(!(r=e.transform(t.css)))return function(){};t.css=r}if(e.singleton){var a=c++;n=l||(l=v(e)),o=k.bind(null,n,a,!1),i=k.bind(null,n,a,!0)}else t.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=function(t){var e=document.createElement("link");return void 0===t.attrs.type&&(t.attrs.type="text/css"),t.attrs.rel="stylesheet",b(e,t.attrs),m(t,e),e}(e),o=x.bind(null,n,e),i=function(){g(n),n.href&&URL.revokeObjectURL(n.href)}):(n=v(e),o=O.bind(null,n),i=function(){g(n)});return o(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap)return;o(t=e)}else i()}}t.exports=function(t,e){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(e=e||{}).attrs="object"==typeof e.attrs?e.attrs:{},e.singleton||"boolean"==typeof e.singleton||(e.singleton=a()),e.insertInto||(e.insertInto="head"),e.insertAt||(e.insertAt="bottom");var n=p(t,e);return d(n,e),function(t){for(var o=[],i=0;i<n.length;i++){var a=n[i];(s=r[a.id]).refs--,o.push(s)}t&&d(p(t,e),e);for(i=0;i<o.length;i++){var s;if(0===(s=o[i]).refs){for(var u=0;u<s.parts.length;u++)s.parts[u]();delete r[s.id]}}}};var w,_=(w=[],function(t,e){return w[t]=e,w.filter(Boolean).join("\n")});function k(t,e,n,o){var i=n?"":o.css;if(t.styleSheet)t.styleSheet.cssText=_(e,i);else{var r=document.createTextNode(i),a=t.childNodes;a[e]&&t.removeChild(a[e]),a.length?t.insertBefore(r,a[e]):t.appendChild(r)}}function O(t,e){var n=e.css,o=e.media;if(o&&t.setAttribute("media",o),t.styleSheet)t.styleSheet.cssText=n;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(n))}}function x(t,e,n){var o=n.css,i=n.sourceMap,r=void 0===e.convertToAbsoluteUrls&&i;(e.convertToAbsoluteUrls||r)&&(o=h(o)),i&&(o+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(i))))+" */");var a=new Blob([o],{type:"text/css"}),s=t.href;t.href=URL.createObjectURL(a),s&&URL.revokeObjectURL(s)}},function(t,e){t.exports=function(t){var e="undefined"!=typeof window&&window.location;if(!e)throw new Error("fixUrls requires window.location");if(!t||"string"!=typeof t)return t;var n=e.protocol+"//"+e.host,o=n+e.pathname.replace(/\/[^\/]*$/,"/");return t.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,(function(t,e){var i,r=e.trim().replace(/^"(.*)"$/,(function(t,e){return e})).replace(/^'(.*)'$/,(function(t,e){return e}));return/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(r)?t:(i=0===r.indexOf("//")?r:0===r.indexOf("/")?n+r:o+r.replace(/^\.\//,""),"url("+JSON.stringify(i)+")")}))}}]);
  2. //# sourceMappingURL=index.js.map