diff --git a/dist/ass.esm.js b/dist/ass.esm.js index 55ac889..34f2acd 100644 --- a/dist/ass.esm.js +++ b/dist/ass.esm.js @@ -741,11 +741,30 @@ var DEFAULT_STYLE = { Encoding: '1', }; +/** + * @param {String} color + * @returns {Array} [AA, BBGGRR] + */ function parseStyleColor(color) { - var ref = color.match(/&H(\w\w)?(\w{6})&?/); - var a = ref[1]; - var c = ref[2]; - return [a || '00', c]; + if (/^(&|H|&H)[0-9a-f]{6,}/i.test(color)) { + var ref = color.match(/&?H?([0-9a-f]{2})?([0-9a-f]{6})/i); + var a = ref[1]; + var c = ref[2]; + return [a || '00', c]; + } + var num = parseInt(color, 10); + if (!Number.isNaN(num)) { + var min = -2147483648; + var max = 2147483647; + if (num < min) { + return ['00', '000000']; + } + var aabbggrr = (min <= num && num <= max) + ? ("00000000" + ((num < 0 ? num + 4294967296 : num).toString(16))).slice(-8) + : String(num).slice(0, 8); + return [aabbggrr.slice(0, 2), aabbggrr.slice(2)]; + } + return ['00', '000000']; } function compileStyles(ref) { @@ -1717,26 +1736,24 @@ function renderer(dialogue) { } function framing() { - var this$1 = this; - var vct = this.video.currentTime; for (var i = this._.stagings.length - 1; i >= 0; i--) { - var dia = this$1._.stagings[i]; + var dia = this._.stagings[i]; var end = dia.end; if (dia.effect && /scroll/.test(dia.effect.name)) { var ref = dia.effect; var y1 = ref.y1; var y2 = ref.y2; var delay = ref.delay; - var duration = ((y2 || this$1._.resampledRes.height) - y1) / (1000 / delay); + var duration = ((y2 || this._.resampledRes.height) - y1) / (1000 / delay); end = Math.min(end, dia.start + duration); } if (end < vct) { - this$1._.$stage.removeChild(dia.$div); + this._.$stage.removeChild(dia.$div); if (dia.$clipPath) { - this$1._.$defs.removeChild(dia.$clipPath); + this._.$defs.removeChild(dia.$clipPath); } - this$1._.stagings.splice(i, 1); + this._.stagings.splice(i, 1); } } var dias = this.dialogues; @@ -1744,11 +1761,11 @@ function framing() { this._.index < dias.length && vct >= dias[this._.index].start ) { - if (vct < dias[this$1._.index].end) { - var dia$1 = renderer.call(this$1, dias[this$1._.index]); - this$1._.stagings.push(dia$1); + if (vct < dias[this._.index].end) { + var dia$1 = renderer.call(this, dias[this._.index]); + this._.stagings.push(dia$1); } - ++this$1._.index; + ++this._.index; } } @@ -1772,13 +1789,11 @@ function pause() { } function clear() { - var this$1 = this; - while (this._.$stage.lastChild) { - this$1._.$stage.removeChild(this$1._.$stage.lastChild); + this._.$stage.removeChild(this._.$stage.lastChild); } while (this._.$defs.lastChild) { - this$1._.$defs.removeChild(this$1._.$defs.lastChild); + this._.$defs.removeChild(this._.$defs.lastChild); } this._.stagings = []; this._.space = []; @@ -1959,8 +1974,6 @@ function hide() { } function destroy() { - var this$1 = this; - pause.call(this); clear.call(this); unbindEvents.call(this, this._.listener); @@ -1977,9 +1990,9 @@ function destroy() { styleRoot.removeChild(this._.$animation); // eslint-disable-next-line no-restricted-syntax - for (var key in this$1) { - if (Object.prototype.hasOwnProperty.call(this$1, key)) { - this$1[key] = null; + for (var key in this) { + if (Object.prototype.hasOwnProperty.call(this, key)) { + this[key] = null; } } diff --git a/dist/ass.js b/dist/ass.js index 72cef93..d766640 100644 --- a/dist/ass.js +++ b/dist/ass.js @@ -747,11 +747,30 @@ Encoding: '1', }; + /** + * @param {String} color + * @returns {Array} [AA, BBGGRR] + */ function parseStyleColor(color) { - var ref = color.match(/&H(\w\w)?(\w{6})&?/); - var a = ref[1]; - var c = ref[2]; - return [a || '00', c]; + if (/^(&|H|&H)[0-9a-f]{6,}/i.test(color)) { + var ref = color.match(/&?H?([0-9a-f]{2})?([0-9a-f]{6})/i); + var a = ref[1]; + var c = ref[2]; + return [a || '00', c]; + } + var num = parseInt(color, 10); + if (!Number.isNaN(num)) { + var min = -2147483648; + var max = 2147483647; + if (num < min) { + return ['00', '000000']; + } + var aabbggrr = (min <= num && num <= max) + ? ("00000000" + ((num < 0 ? num + 4294967296 : num).toString(16))).slice(-8) + : String(num).slice(0, 8); + return [aabbggrr.slice(0, 2), aabbggrr.slice(2)]; + } + return ['00', '000000']; } function compileStyles(ref) { @@ -1723,26 +1742,24 @@ } function framing() { - var this$1 = this; - var vct = this.video.currentTime; for (var i = this._.stagings.length - 1; i >= 0; i--) { - var dia = this$1._.stagings[i]; + var dia = this._.stagings[i]; var end = dia.end; if (dia.effect && /scroll/.test(dia.effect.name)) { var ref = dia.effect; var y1 = ref.y1; var y2 = ref.y2; var delay = ref.delay; - var duration = ((y2 || this$1._.resampledRes.height) - y1) / (1000 / delay); + var duration = ((y2 || this._.resampledRes.height) - y1) / (1000 / delay); end = Math.min(end, dia.start + duration); } if (end < vct) { - this$1._.$stage.removeChild(dia.$div); + this._.$stage.removeChild(dia.$div); if (dia.$clipPath) { - this$1._.$defs.removeChild(dia.$clipPath); + this._.$defs.removeChild(dia.$clipPath); } - this$1._.stagings.splice(i, 1); + this._.stagings.splice(i, 1); } } var dias = this.dialogues; @@ -1750,11 +1767,11 @@ this._.index < dias.length && vct >= dias[this._.index].start ) { - if (vct < dias[this$1._.index].end) { - var dia$1 = renderer.call(this$1, dias[this$1._.index]); - this$1._.stagings.push(dia$1); + if (vct < dias[this._.index].end) { + var dia$1 = renderer.call(this, dias[this._.index]); + this._.stagings.push(dia$1); } - ++this$1._.index; + ++this._.index; } } @@ -1778,13 +1795,11 @@ } function clear() { - var this$1 = this; - while (this._.$stage.lastChild) { - this$1._.$stage.removeChild(this$1._.$stage.lastChild); + this._.$stage.removeChild(this._.$stage.lastChild); } while (this._.$defs.lastChild) { - this$1._.$defs.removeChild(this$1._.$defs.lastChild); + this._.$defs.removeChild(this._.$defs.lastChild); } this._.stagings = []; this._.space = []; @@ -1965,8 +1980,6 @@ } function destroy() { - var this$1 = this; - pause.call(this); clear.call(this); unbindEvents.call(this, this._.listener); @@ -1983,9 +1996,9 @@ styleRoot.removeChild(this._.$animation); // eslint-disable-next-line no-restricted-syntax - for (var key in this$1) { - if (Object.prototype.hasOwnProperty.call(this$1, key)) { - this$1[key] = null; + for (var key in this) { + if (Object.prototype.hasOwnProperty.call(this, key)) { + this[key] = null; } } diff --git a/dist/ass.min.js b/dist/ass.min.js index b40cd89..a5b9d2d 100644 --- a/dist/ass.min.js +++ b/dist/ass.min.js @@ -1 +1 @@ -(function(t,e){typeof exports==="object"&&typeof module!=="undefined"?module.exports=e():typeof define==="function"&&define.amd?define(e):t.ASS=e()})(this,function(){"use strict";function l(t){var e=t.toLowerCase().trim().split(/\s*;\s*/);if(e[0]==="banner"){return{name:e[0],delay:e[1]*1||0,leftToRight:e[2]*1||0,fadeAwayWidth:e[3]*1||0}}if(/^scroll\s/.test(e[0])){return{name:e[0],y1:Math.min(e[1]*1,e[2]*1),y2:Math.max(e[1]*1,e[2]*1),delay:e[3]*1||0,fadeAwayHeight:e[4]*1||0}}return null}function y(t){return t.toLowerCase().replace(/([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?)/g," $1 ").replace(/([mnlbspc])/g," $1 ").trim().replace(/\s+/g," ").split(/\s(?=[mnlbspc])/).map(function(t){return t.split(" ").filter(function(t,e){return!(e&&Number.isNaN(t*1))})})}var t=["b","i","u","s","fsp","k","K","kf","ko","kt","fe","q","p","pbo","a","an","fscx","fscy","fax","fay","frx","fry","frz","fr","be","blur","bord","xbord","ybord","shad","xshad","yshad"];var x=t.map(function(t){return{name:t,regex:new RegExp("^"+t+"-?\\d")}});function w(t){var e;var a={};for(var r=0;re.length){var r=a.slice(e.length-1).join();a=a.slice(0,e.length-1);a.push(r)}var i={};for(var n=0;n0)a[r]=arguments[r+1];for(var i=0;i-10?1+s/10:1)*a.fs:s*1}}if(e==="t"){var T=s.t1;var E=s.accel;var F=s.tags;var j=s.t2||(a.end-a.start)*1e3;var L={};F.forEach(function(t){var e=Object.keys(t)[0];if(~O.indexOf(e)&&!(e==="clip"&&!t[e].dots)){P(L,R(t,e,a))}});return{t:{t1:T,t2:j,accel:E,tag:L}}}return n={},n[e]=s,n}var z=[null,1,2,3,null,7,8,9,null,4,5,6];var H=["r","a","an","pos","org","move","fade","fad","clip"];function I(t,e){return{name:t,borderStyle:e[t].style.BorderStyle,tag:e[t].tag,fragments:[]}}function S(t){var e=t.styles;var a=t.name;var r=t.parsed;var i=t.start;var n=t.end;var s;var o;var l;var f;var v;var h;var c=[];var d=I(a,e);var p={};for(var u=0;u=s.End){continue}if(!e[s.Style]){s.Style="Default"}var o=e[s.Style].style;var l=S({styles:e,name:s.Style,parsed:s.Text.parsed,start:s.Start,end:s.End});var f=l.alignment||o.Alignment;r=Math.min(r,s.Layer);i.push(P({layer:s.Layer,start:s.Start,end:s.End,margin:{left:s.MarginL||o.MarginL,right:s.MarginR||o.MarginR,vertical:s.MarginV||o.MarginV},effect:s.Effect},l,{alignment:f}))}for(var v=0;v0?1:-1;var u=l>0?1:-1;o=Math.abs(o);l=Math.abs(l);for(var g=Math.max(i,o-i);g=4&&e<=6){o.y=n+r/2}if(e>=7){o.y=n}}for(var l=s.childNodes.length-1;l>=0;l--){var f=s.childNodes[l];if(f.dataset.hasRotate==="true"){var v=o.x-i-f.offsetLeft;var h=o.y-n-f.offsetTop;f.style.cssText+=M.transform+"transform-origin:"+v+"px "+h+"px;"}}}function W(t,e){return"@"+M.animation+"keyframes "+t+" {"+e+"}\n"}var J=function t(){this.obj={}};J.prototype.set=function t(e,a,r){if(!this.obj[e]){this.obj[e]={}}this.obj[e][a]=r};J.prototype.setT=function t(e){var a=e.t1;var r=e.t2;var i=e.duration;var n=e.prop;var s=e.from;var o=e.to;this.set("0.000%",n,s);if(a/g,">").replace(/\s/g," ").replace(/\\h/g," ").replace(/\\N/g,"
").replace(/\\n/g,e===2?"
":" ")}function at(t){var d=this;var e=document.createElement("div");e.className="ASS-dialogue";var p=document.createDocumentFragment();var a=t.slices;var u=t.start;var g=t.end;a.forEach(function(h){var c=h.borderStyle;h.fragments.forEach(function(i){var t=i.text;var n=i.drawing;var e=i.animationName;var a=P({},h.tag,i.tag);var s="display:inline-block;";var r=d.video.currentTime;if(!n){s+='font-family:"'+a.fn+'",Arial;';s+="font-size:"+d.scale*G(a.fn,a.fs)+"px;";s+="color:"+q(a.a1+a.c1)+";";var o=/Yes/i.test(d.info.ScaledBorderAndShadow)?d.scale:1;if(c===1){s+="text-shadow:"+X(a,o)+";"}if(c===3){s+="background-color:"+q(a.a3+a.c3)+";"+"box-shadow:"+X(a,o)+";"}s+=a.b?"font-weight:"+(a.b===1?"bold":a.b)+";":"";s+=a.i?"font-style:italic;":"";s+=a.u||a.s?"text-decoration:"+(a.u?"underline":"")+" "+(a.s?"line-through":"")+";":"";s+=a.fsp?"letter-spacing:"+a.fsp+"px;":"";if(a.q===1||a.q===0||a.q===3){s+="word-break:break-all;white-space:normal;"}if(a.q===2){s+="word-break:normal;white-space:nowrap;"}}var l=D.some(function(t){return/^fsc[xy]$/.test(t)?a[t]!==100:!!a[t]});if(l){s+=M.transform+"transform:"+V(a)+";";if(!n){s+="transform-style:preserve-3d;word-break:normal;white-space:nowrap;"}}if(e){s+=Q(e,g-u,Math.min(0,u-r))}if(n&&a.pbo){var f=d.scale*-a.pbo*(a.fscy||100)/100;s+="vertical-align:"+f+"px;"}var v=/"fr[xyz]":[^0]/.test(JSON.stringify(a));et(t,a.q).split("
").forEach(function(t,e){var a=document.createElement("span");a.dataset.hasRotate=v;if(n){var r=tt.call(d,i,h.tag);a.style.cssText=r.cssText;a.appendChild(r.$svg)}else{if(e){p.appendChild(document.createElement("br"))}if(!t){return}a.innerHTML=t}a.style.cssText+=s;p.appendChild(a)})})});e.appendChild(p);return e}function rt(t){var e=t.layer;var a=t.margin;var o=t.width;var r=t.height;var i=t.alignment;var n=t.end;var l=this.width-(this.scale*(a.left+a.right)|0);var s=this.height;var f=this.scale*a.vertical|0;var v=this.video.currentTime*100;this._.space[e]=this._.space[e]||{left:{width:new Uint16Array(s+1),end:new Uint16Array(s+1)},center:{width:new Uint16Array(s+1),end:new Uint16Array(s+1)},right:{width:new Uint16Array(s+1),end:new Uint16Array(s+1)}};var h=this._.space[e];var c=["right","left","center"][i%3];var d=function(t){var e=h.left.width[t];var a=h.center.width[t];var r=h.right.width[t];var i=h.left.end[t];var n=h.center.end[t];var s=h.right.end[t];return c==="left"&&(i>v&&e||n>v&&a&&2*o+a>l||s>v&&r&&o+r>l)||c==="center"&&(i>v&&e&&2*e+o>l||n>v&&a||s>v&&r&&2*r+o>l)||c==="right"&&(i>v&&e&&e+o>l||n>v&&a&&2*o+a>l||s>v&&r)};var p=0;var u=0;var g=function(t){p=d(t)?0:p+1;if(p>=r){u=t;return true}return false};if(i<=3){for(var m=s-f-1;m>f;m--){if(g(m)){break}}}else if(i>=7){for(var y=f+1;y>1;x3){u-=r-1}for(var w=u;w=4&&r<=6){f=(this.height-n)/2}if(r>=7){f=s.vertical}l=e.lefttoright?-i:this.width}}else if(t.pos||a){var v=t.pos||{x:0,y:0};if(r%3===1){l=this.scale*v.x}if(r%3===2){l=this.scale*v.x-i/2}if(r%3===0){l=this.scale*v.x-i}if(r<=3){f=this.scale*v.y-n}if(r>=4&&r<=6){f=this.scale*v.y-n/2}if(r>=7){f=this.scale*v.y}}else{if(r%3===1){l=0}if(r%3===2){l=(this.width-i)/2}if(r%3===0){l=this.width-i-this.scale*s.right}var h=o.some(function(t){return t.fragments.some(function(t){var e=t.animationName;return e})});if(h){if(r<=3){f=this.height-n-s.vertical}if(r>=4&&r<=6){f=(this.height-n)/2}if(r>=7){f=s.vertical}}else{f=rt.call(this,t)}}return{x:l,y:f}}function nt(t){var e=t.layer;var a=t.start;var r=t.end;var i=t.alignment;var n=t.effect;var s=t.pos;var o=t.margin;var l=t.animationName;var f=t.width;var v=t.height;var h=t.x;var c=t.y;var d=this.video.currentTime;var p="";if(e){p+="z-index:"+e+";"}if(l){p+=Q(l,r-a,Math.min(0,a-d))}p+="text-align:"+["right","left","center"][i%3]+";";if(!n){var u=this.width-this.scale*(o.left+o.right);p+="max-width:"+u+"px;";if(!s){if(i%3===1){p+="margin-left:"+this.scale*o.left+"px;"}if(i%3===0){p+="margin-right:"+this.scale*o.right+"px;"}if(f>this.width-this.scale*(o.left+o.right)){p+="margin-left:"+this.scale*o.left+"px;";p+="margin-right:"+this.scale*o.right+"px;"}}}p+="width:"+f+"px;height:"+v+"px;left:"+h+"px;top:"+c+"px;";return p}function st(t){var e=at.call(this,t);P(t,{$div:e});this._.$stage.appendChild(e);var a=e.getBoundingClientRect();var r=a.width;var i=a.height;P(t,{width:r,height:i});P(t,it.call(this,t));e.style.cssText=nt.call(this,t);L(t);T.call(this,t);return t}function ot(){var t=this;var e=this.video.currentTime;for(var a=this._.stagings.length-1;a>=0;a--){var r=t._.stagings[a];var i=r.end;if(r.effect&&/scroll/.test(r.effect.name)){var n=r.effect;var s=n.y1;var o=n.y2;var l=n.delay;var f=((o||t._.resampledRes.height)-s)/(1e3/l);i=Math.min(i,r.start+f)}if(i=v[this._.index].start){if(ei[e+t>>1].end){t=e+t>>1}if(!t){return 0}for(var a=t;ar&&r>=i[a].start||a&&i[a-1].ende.length){var i=a.slice(e.length-1).join();a=a.slice(0,e.length-1);a.push(i)}var r={};for(var n=0;n0)a[i]=arguments[i+1];for(var r=0;r-10?1+s/10:1)*a.fs:s*1}}if(e==="t"){var T=s.t1;var E=s.accel;var F=s.tags;var j=s.t2||(a.end-a.start)*1e3;var L={};F.forEach(function(t){var e=Object.keys(t)[0];if(~O.indexOf(e)&&!(e==="clip"&&!t[e].dots)){P(L,R(t,e,a))}});return{t:{t1:T,t2:j,accel:E,tag:L}}}return n={},n[e]=s,n}var z=[null,1,2,3,null,7,8,9,null,4,5,6];var H=["r","a","an","pos","org","move","fade","fad","clip"];function I(t,e){return{name:t,borderStyle:e[t].style.BorderStyle,tag:e[t].tag,fragments:[]}}function S(t){var e=t.styles;var a=t.name;var i=t.parsed;var r=t.start;var n=t.end;var s;var o;var l;var f;var v;var h;var c=[];var d=I(a,e);var p={};for(var u=0;u=s.End){continue}if(!e[s.Style]){s.Style="Default"}var o=e[s.Style].style;var l=S({styles:e,name:s.Style,parsed:s.Text.parsed,start:s.Start,end:s.End});var f=l.alignment||o.Alignment;i=Math.min(i,s.Layer);r.push(P({layer:s.Layer,start:s.Start,end:s.End,margin:{left:s.MarginL||o.MarginL,right:s.MarginR||o.MarginR,vertical:s.MarginV||o.MarginV},effect:s.Effect},l,{alignment:f}))}for(var v=0;v0?1:-1;var u=l>0?1:-1;o=Math.abs(o);l=Math.abs(l);for(var g=Math.max(r,o-r);g=4&&e<=6){o.y=n+i/2}if(e>=7){o.y=n}}for(var l=s.childNodes.length-1;l>=0;l--){var f=s.childNodes[l];if(f.dataset.hasRotate==="true"){var v=o.x-r-f.offsetLeft;var h=o.y-n-f.offsetTop;f.style.cssText+=M.transform+"transform-origin:"+v+"px "+h+"px;"}}}function W(t,e){return"@"+M.animation+"keyframes "+t+" {"+e+"}\n"}var J=function t(){this.obj={}};J.prototype.set=function t(e,a,i){if(!this.obj[e]){this.obj[e]={}}this.obj[e][a]=i};J.prototype.setT=function t(e){var a=e.t1;var i=e.t2;var r=e.duration;var n=e.prop;var s=e.from;var o=e.to;this.set("0.000%",n,s);if(a/g,">").replace(/\s/g," ").replace(/\\h/g," ").replace(/\\N/g,"
").replace(/\\n/g,e===2?"
":" ")}function at(t){var d=this;var e=document.createElement("div");e.className="ASS-dialogue";var p=document.createDocumentFragment();var a=t.slices;var u=t.start;var g=t.end;a.forEach(function(h){var c=h.borderStyle;h.fragments.forEach(function(r){var t=r.text;var n=r.drawing;var e=r.animationName;var a=P({},h.tag,r.tag);var s="display:inline-block;";var i=d.video.currentTime;if(!n){s+='font-family:"'+a.fn+'",Arial;';s+="font-size:"+d.scale*G(a.fn,a.fs)+"px;";s+="color:"+q(a.a1+a.c1)+";";var o=/Yes/i.test(d.info.ScaledBorderAndShadow)?d.scale:1;if(c===1){s+="text-shadow:"+X(a,o)+";"}if(c===3){s+="background-color:"+q(a.a3+a.c3)+";"+"box-shadow:"+X(a,o)+";"}s+=a.b?"font-weight:"+(a.b===1?"bold":a.b)+";":"";s+=a.i?"font-style:italic;":"";s+=a.u||a.s?"text-decoration:"+(a.u?"underline":"")+" "+(a.s?"line-through":"")+";":"";s+=a.fsp?"letter-spacing:"+a.fsp+"px;":"";if(a.q===1||a.q===0||a.q===3){s+="word-break:break-all;white-space:normal;"}if(a.q===2){s+="word-break:normal;white-space:nowrap;"}}var l=D.some(function(t){return/^fsc[xy]$/.test(t)?a[t]!==100:!!a[t]});if(l){s+=M.transform+"transform:"+V(a)+";";if(!n){s+="transform-style:preserve-3d;word-break:normal;white-space:nowrap;"}}if(e){s+=Q(e,g-u,Math.min(0,u-i))}if(n&&a.pbo){var f=d.scale*-a.pbo*(a.fscy||100)/100;s+="vertical-align:"+f+"px;"}var v=/"fr[xyz]":[^0]/.test(JSON.stringify(a));et(t,a.q).split("
").forEach(function(t,e){var a=document.createElement("span");a.dataset.hasRotate=v;if(n){var i=tt.call(d,r,h.tag);a.style.cssText=i.cssText;a.appendChild(i.$svg)}else{if(e){p.appendChild(document.createElement("br"))}if(!t){return}a.innerHTML=t}a.style.cssText+=s;p.appendChild(a)})})});e.appendChild(p);return e}function it(t){var e=t.layer;var a=t.margin;var o=t.width;var i=t.height;var r=t.alignment;var n=t.end;var l=this.width-(this.scale*(a.left+a.right)|0);var s=this.height;var f=this.scale*a.vertical|0;var v=this.video.currentTime*100;this._.space[e]=this._.space[e]||{left:{width:new Uint16Array(s+1),end:new Uint16Array(s+1)},center:{width:new Uint16Array(s+1),end:new Uint16Array(s+1)},right:{width:new Uint16Array(s+1),end:new Uint16Array(s+1)}};var h=this._.space[e];var c=["right","left","center"][r%3];var d=function(t){var e=h.left.width[t];var a=h.center.width[t];var i=h.right.width[t];var r=h.left.end[t];var n=h.center.end[t];var s=h.right.end[t];return c==="left"&&(r>v&&e||n>v&&a&&2*o+a>l||s>v&&i&&o+i>l)||c==="center"&&(r>v&&e&&2*e+o>l||n>v&&a||s>v&&i&&2*i+o>l)||c==="right"&&(r>v&&e&&e+o>l||n>v&&a&&2*o+a>l||s>v&&i)};var p=0;var u=0;var g=function(t){p=d(t)?0:p+1;if(p>=i){u=t;return true}return false};if(r<=3){for(var m=s-f-1;m>f;m--){if(g(m)){break}}}else if(r>=7){for(var y=f+1;y>1;x3){u-=i-1}for(var b=u;b=4&&i<=6){f=(this.height-n)/2}if(i>=7){f=s.vertical}l=e.lefttoright?-r:this.width}}else if(t.pos||a){var v=t.pos||{x:0,y:0};if(i%3===1){l=this.scale*v.x}if(i%3===2){l=this.scale*v.x-r/2}if(i%3===0){l=this.scale*v.x-r}if(i<=3){f=this.scale*v.y-n}if(i>=4&&i<=6){f=this.scale*v.y-n/2}if(i>=7){f=this.scale*v.y}}else{if(i%3===1){l=0}if(i%3===2){l=(this.width-r)/2}if(i%3===0){l=this.width-r-this.scale*s.right}var h=o.some(function(t){return t.fragments.some(function(t){var e=t.animationName;return e})});if(h){if(i<=3){f=this.height-n-s.vertical}if(i>=4&&i<=6){f=(this.height-n)/2}if(i>=7){f=s.vertical}}else{f=it.call(this,t)}}return{x:l,y:f}}function nt(t){var e=t.layer;var a=t.start;var i=t.end;var r=t.alignment;var n=t.effect;var s=t.pos;var o=t.margin;var l=t.animationName;var f=t.width;var v=t.height;var h=t.x;var c=t.y;var d=this.video.currentTime;var p="";if(e){p+="z-index:"+e+";"}if(l){p+=Q(l,i-a,Math.min(0,a-d))}p+="text-align:"+["right","left","center"][r%3]+";";if(!n){var u=this.width-this.scale*(o.left+o.right);p+="max-width:"+u+"px;";if(!s){if(r%3===1){p+="margin-left:"+this.scale*o.left+"px;"}if(r%3===0){p+="margin-right:"+this.scale*o.right+"px;"}if(f>this.width-this.scale*(o.left+o.right)){p+="margin-left:"+this.scale*o.left+"px;";p+="margin-right:"+this.scale*o.right+"px;"}}}p+="width:"+f+"px;height:"+v+"px;left:"+h+"px;top:"+c+"px;";return p}function st(t){var e=at.call(this,t);P(t,{$div:e});this._.$stage.appendChild(e);var a=e.getBoundingClientRect();var i=a.width;var r=a.height;P(t,{width:i,height:r});P(t,rt.call(this,t));e.style.cssText=nt.call(this,t);L(t);T.call(this,t);return t}function ot(){var t=this.video.currentTime;for(var e=this._.stagings.length-1;e>=0;e--){var a=this._.stagings[e];var i=a.end;if(a.effect&&/scroll/.test(a.effect.name)){var r=a.effect;var n=r.y1;var s=r.y2;var o=r.delay;var l=((s||this._.resampledRes.height)-n)/(1e3/o);i=Math.min(i,a.start+l)}if(i=f[this._.index].start){if(tr[e+t>>1].end){t=e+t>>1}if(!t){return 0}for(var a=t;ai&&i>=r[a].start||a&&r[a-1].end