text: var t=function(){for(var t=["oTransform","msTransform","mozTransform","webkitTransform","transform"],i=document.createElement("div").style,e=0;e<t.length;e++)if(t[e]in i)return t[e];return"transform"}();function i(t){var i=document.createElement("div");if(i.style.cssText="position:absolute;","function"==typeof t.render){var e=t.render();if(e instanceof HTMLElement)return i.appendChild(e),i}if(i.textContent=t.text,t.style)for(var n in t.style)i.style[n]=t.style[n];return i}var e={name:"dom",init:function(){var t=document.createElement("div");return t.style.cssText="overflow:hidden;white-space:nowrap;transform:translateZ(0);",t},clear:function(t){for(var i=t.lastChild;i;)t.removeChild(i),i=t.lastChild},resize:function(t){t.style.width=t.width+"px",t.style.height=t.height+"px"},framing:function(){},setup:function(t,e){var n=document.createDocumentFragment(),s=0,h=null;for(s=0;s<e.length;s++)(h=e[s]).node=h.node||i(h),n.appendChild(h.node);for(e.length&&t.appendChild(n),s=0;s<e.length;s++)(h=e[s]).width=h.width||h.node.offsetWidth,h.height=h.height||h.node.offsetHeight},render:function(i,e){e.node.style[t]="translate("+e.x+"px,"+e.y+"px)"},remove:function(t,i){t.removeChild(i.node),this.media||(i.node=null)}};function n(t){var i=this,e=this.media?this.media.currentTime:Date.now()/1e3,n=this.media?this.media.playbackRate:1;function s(t,s){if("top"===s.mode||"bottom"===s.mode)return e-t.time<i._.duration;var h=(i._.stage.width+t.width)*(e-t.time)*n/i._.duration;if(t.width>h)return!0;var r=i._.duration+t.time-e,a=i._.stage.width+s.width,o=i.media?s.time:s._utc,d=a*(e-o)*n/i._.duration,m=i._.stage.width-d;return r>i._.duration*m/(i._.stage.width+s.width)}for(var h=this._.space[t.mode],r=0,a=0,o=1;o<h.length;o++){var d=h[o],m=t.height;if("top"!==t.mode&&"bottom"!==t.mode||(m+=d.height),d.range-d.height-h[r].range>=m){a=o;break}s(d,t)&&(r=o)}var u=h[r].range,l={range:u+t.height,time:this.media?t.time:t._utc,width:t.width,height:t.height};return h.splice(r+1,a-r-1,l),"bottom"===t.mode?this._.stage.height-t.height-u%this._.stage.height:u%(this._.stage.height-t.height)}var s=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||function(t){return setTimeout(t,50/3)},h=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||clearTimeout;function r(t,i,e){for(var n=0,s=0,h=t.length;s<h-1;)e>=t[n=s+h>>1][i]?s=n:h=n;return t[s]&&e<t[s][i]?s:h}function a(t){return/^(ltr|top|bottom)$/i.test(t)?t.toLowerCase():"rtl"}function o(){var t=9007199254740991;return[{range:0,time:-t,width:t,height:0},{range:t,time:t,width:0,height:0}]}function d(t){t.ltr=o(),t.rtl=o(),t.top=o(),t.bottom=o()}function m(){if(!this._.visible||!this._.paused)return this;if(this._.paused=!1,this.media)for(var t=0;t<this._.runningList.length;t++){var i=this._.runningList[t];i._utc=Date.now()/1e3-(this.media.currentTime-i.time)}var e=this,h=function(t,i,e,s){return function(){t(this._.stage);var h=Date.now()/1e3,r=this.media?this.media.currentTime:h,a=this.media?this.media.playbackRate:1,o=null,d=0,m=0;for(m=this._.runningList.length-1;m>=0;m--)o=this._.runningList[m],r-(d=this.media?o.time:o._utc)>this._.duration&&(s(this._.stage,o),this._.runningList.splice(m,1));for(var u=[];this._.position<this.comments.length&&(o=this.comments[this._.position],!((d=this.media?o.time:o._utc)>=r));)r-d>this._.duration||(this.media&&(o._utc=h-(this.media.currentTime-o.time)),u.push(o)),++this._.position;for(i(this._.stage,u),m=0;m<u.length;m++)(o=u[m]).y=n.call(this,o),"top"!==o.mode&&"bottom"!==o.mode||(o.x=this._.stage.width-o.width>>1),this._.runningList.push(o);for(m=0;m<this._.runningList.length;m++){o=this._.runningList[m];var l=(this._.stage.width+o.width)*(h-o._utc)*a/this._.duration;"ltr"===o.mode&&(o.x=l-o.width+.5|0),"rtl"===o.mode&&(o.x=this._.stage.width-l+.5|0),e(this._.stage,o)}}}(this._.engine.framing.bind(this),this._.engine.setup.bind(this),this._.engine.render.bind(this),this._.engine.remove.bind(this));return this._.requestID=s((function t(){h.call(e),e._.requestID=s(t)})),this}function u(){return!this._.visible||this._.paused||(this._.paused=!0,h(this._.requestID),this._.requestID=0),this}function l(){if(!this.media)return this;this.clear(),d(this._.space);var t=r(this.comments,"time",this.media.currentTime);return this._.position=Math.max(0,t-1),this}function c(t){t.play=m.bind(this),t.pause=u.bind(this),t.seeking=l.bind(this),this.media.addEventListener("play",t.play),this.media.addEventListener("pause",t.pause),this.media.addEventListener("playing",t.play),this.media.addEventListener("waiting",t.pause),this.media.addEventListener("seeking",t.seeking)}function _(t){this.media.removeEventListener("play",t.play),this.media.removeEventListener("pause",t.pause),this.media.removeEventListener("playing",t.play),this.media.removeEventListener("waiting",t.pause),this.media.removeEventListener("seeking",t.seeking),t.play=null,t.pause=null,t.seeking=null}function g(t){this._={},this.container=t.container||document.createElement("div"),this.media=t.media,this._.visible=!0,this.engine="dom",this._.engine=e,this._.requestID=0,this._.speed=Math.max(0,t.speed)||144,this._.duration=4,this.comments=t.comments||[],this.comments.sort((function(t,i){return t.time-i.time}));for(var i=0;i<this.comments.length;i++)this.comments[i].mode=a(this.comments[i].mode);return this._.runningList=[],this._.position=0,this._.paused=!0,this.media&&(this._.listener={},c.call(this,this._.listener)),this._.stage=this._.engine.init(this.container),this._.stage.style.cssText+="position:relative;pointer-events:none;",this.resize(),this.container.appendChild(this._.stage),this._.space={},d(this._.space),this.media&&this.media.paused||(l.call(this),m.call(this)),this}function p(){if(!this.container)return this;for(var t in u.call(this),this.clear(),this.container.removeChild(this._.stage),this.media&&_.call(this,this._.listener),this)Object.prototype.hasOwnProperty.call(this,t)&&(this[t]=null);return this}var f=["mode","time","text","render","style"];function v(t){if(!t||"[object Object]"!==Object.prototype.toString.call(t))return this;for(var i={},e=0;e<f.length;e++)void 0!==t[f[e]]&&(i[f[e]]=t[f[e]]);if(i.text=(i.text||"").toString(),i.mode=a(i.mode),i._utc=Date.now()/1e3,this.media){var n=0;void 0===i.time?(i.time=this.media.currentTime,n=this._.position):(n=r(this.comments,"time",i.time))<this._.position&&(this._.position+=1),this.comments.splice(n,0,i)}else this.comments.push(i);return this}function w(){return this._.visible?this:(this._.visible=!0,this.media&&this.media.paused||(l.call(this),m.call(this)),this)}function y(){return this._.visible?(u.call(this),this.clear(),this._.visible=!1,this):this}function b(){return this._.engine.clear(this._.stage,this._.runningList),this._.runningList=[],this}function L(){return this._.stage.width=this.container.offsetWidth,this._.stage.height=this.container.offsetHeight,this._.engine.resize(this._.stage),this._.duration=this._.stage.width/this._.speed,this}var x={get:function(){return this._.speed},set:function(t){return"number"!=typeof t||isNaN(t)||!isFinite(t)||t<=0?this._.speed:(this._.speed=t,this._.stage.width&&(this._.duration=this._.stage.width/t),t)}};function T(t){t&&g.call(this,t)}T.prototype.destroy=function(){return p.call(this)},T.prototype.emit=function(t){return v.call(this,t)},T.prototype.show=function(){return w.call(this)},T.prototype.hide=function(){return y.call(this)},T.prototype.clear=function(){return b.call(this)},T.prototype.resize=function(){return L.call(this)},Object.defineProperty(T.prototype,"speed",x);export{T as default};
  