From 44f4e083a9518619b519484f3c75137b11fad55e Mon Sep 17 00:00:00 2001 From: Harvey Zhao Date: Fri, 11 Sep 2026 02:34:26 +0800 Subject: [PATCH] refactor(core): CORE-09 isolate source operations and settle cancelled switches --- docs/compiled/artplayer.js | 2 +- docs/compiled/artplayer.legacy.js | 2 +- docs/compiled/artplayer.mjs | 313 +- package.json | 2 +- packages/artplayer/ARCHITECTURE.md | 28 + packages/artplayer/dist/artplayer.js | 2 +- packages/artplayer/dist/artplayer.legacy.js | 2 +- packages/artplayer/dist/artplayer.mjs | 313 +- packages/artplayer/src/player/playMix.ts | 13 +- packages/artplayer/src/player/switchMix.js | 63 - packages/artplayer/src/player/switchMix.ts | 10 + packages/artplayer/src/player/urlMix.js | 48 - packages/artplayer/src/player/urlMix.ts | 87 + packages/artplayer/src/source/listen.ts | 21 + packages/artplayer/src/source/operation.ts | 79 + packages/artplayer/src/source/switch.ts | 121 + packages/artplayer/src/source/types.ts | 44 + .../source-operations-validation.json | 2959 +++++++++++++++++ .../2026-09-11-CORE-09-source-operations.md | 49 + refactor/plan.md | 5 +- refactor/progress.md | 4 + refactor/risk-table.md | 6 +- refactor/risks.json | 36 +- refactor/tasks.json | 7 +- test/browser/source.spec.js | 146 + test/helpers/playback.js | 3 +- test/playback.test.js | 2 + test/source.test.js | 364 ++ test/types/source.ts | 36 + 29 files changed, 4512 insertions(+), 255 deletions(-) delete mode 100644 packages/artplayer/src/player/switchMix.js create mode 100644 packages/artplayer/src/player/switchMix.ts delete mode 100644 packages/artplayer/src/player/urlMix.js create mode 100644 packages/artplayer/src/player/urlMix.ts create mode 100644 packages/artplayer/src/source/listen.ts create mode 100644 packages/artplayer/src/source/operation.ts create mode 100644 packages/artplayer/src/source/switch.ts create mode 100644 packages/artplayer/src/source/types.ts create mode 100644 refactor/baselines/source-operations-validation.json create mode 100644 refactor/changes/2026-09-11-CORE-09-source-operations.md create mode 100644 test/browser/source.spec.js create mode 100644 test/source.test.js create mode 100644 test/types/source.ts diff --git a/docs/compiled/artplayer.js b/docs/compiled/artplayer.js index eae162ffd..844e216bd 100644 --- a/docs/compiled/artplayer.js +++ b/docs/compiled/artplayer.js @@ -4,4 +4,4 @@ * (c) 2017-2026 Harvey Zhao * Released under the MIT License. */ -!function(t,e){"object"===typeof exports&&"undefined"!==typeof module?module.exports=e():"function"==typeof define&&define.amd?(t.Artplayer=e(),define(function(){return t.Artplayer})):(t="undefined"!==typeof globalThis?globalThis:t||self).Artplayer=e()}(this,function(){"use strict";function t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var e,r={exports:{}};var o=(e||(e=1,r.exports=function(){function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}var e=Object.prototype.toString,r=function(r){if(void 0===r)return"undefined";if(null===r)return"null";var a=t(r);if("boolean"===a)return"boolean";if("string"===a)return"string";if("number"===a)return"number";if("symbol"===a)return"symbol";if("function"===a)return"GeneratorFunction"===o(r)?"generatorfunction":"function";if(function(t){return Array.isArray?Array.isArray(t):t instanceof Array}(r))return"array";if(function(t){return!(!t.constructor||"function"!=typeof t.constructor.isBuffer)&&t.constructor.isBuffer(t)}(r))return"buffer";if(function(t){try{if("number"==typeof t.length&&"function"==typeof t.callee)return!0}catch(e){if(-1!==e.message.indexOf("callee"))return!0}return!1}(r))return"arguments";if(function(t){return t instanceof Date||"function"==typeof t.toDateString&&"function"==typeof t.getDate&&"function"==typeof t.setDate}(r))return"date";if(function(t){return t instanceof Error||"string"==typeof t.message&&t.constructor&&"number"==typeof t.constructor.stackTraceLimit}(r))return"error";if(function(t){return t instanceof RegExp||"string"==typeof t.flags&&"boolean"==typeof t.ignoreCase&&"boolean"==typeof t.multiline&&"boolean"==typeof t.global}(r))return"regexp";switch(o(r)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(function(t){return"function"==typeof t.throw&&"function"==typeof t.return&&"function"==typeof t.next}(r))return"generator";switch(a=e.call(r)){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return a.slice(8,-1).toLowerCase().replace(/\s/g,"")};function o(t){return t.constructor?t.constructor.name:null}function a(t,e){var o=2=1,p=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(s)||d,h="undefined"!==typeof window&&"undefined"!==typeof document;function u(t,e=document){return e.querySelector(t)}function m(t,e=document){return Array.from(e.querySelectorAll(t))}function f(t,e){return t.classList.add(e)}function g(t,e){return t.classList.remove(e)}function v(t,e){return t.classList.contains(e)}function y(t,e){return e instanceof Element?t.appendChild(e):t.insertAdjacentHTML("beforeend",String(e)),t.lastElementChild||t.lastChild}function b(t){return t.parentNode.removeChild(t)}function w(t,e,r){return t.style[e]=r,t}function x(t,e){for(const r in e)w(t,r,e[r]);return t}function k(t){return Array.from(t.parentElement.children).filter(e=>e!==t)}function $(t,e){k(t).forEach(t=>g(t,e)),f(t,e)}function E(t,e,r="top"){p||(t.setAttribute("aria-label",e),f(t,"hint--rounded"),f(t,`hint--${r}`))}function T(t,e=0){const r=t.getBoundingClientRect(),o=window.innerHeight||document.documentElement.clientHeight,a=window.innerWidth||document.documentElement.clientWidth,n=r.top-e<=o&&r.top+r.height+e>=0,i=r.left-e<=a+e&&r.left+r.width+e>=0;return n&&i}function C(t,e){return R(t).includes(e)}function z(t,e){return e.parentNode.replaceChild(t,e),t}function L(t){return document.createElement(t)}function S(t="",e=""){const r=L("i");return f(r,"art-icon"),f(r,`art-icon-${t}`),y(r,e),r}function M(t,e){let r=document.getElementById(t);r||(r=document.createElement("style"),r.id=t,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{document.head.appendChild(r)}):(document.head||document.documentElement).appendChild(r)),r.textContent=e}function A(){const t=document.createElement("div");return t.style.display="flex","flex"===t.style.display}function P(t){return t.getBoundingClientRect()}function I(t,e){return new Promise((r,o)=>{const a=new Image;a.onload=function(){if(e&&1!==e){const n=document.createElement("canvas"),i=n.getContext("2d");n.width=a.width*e,n.height=a.height*e,i.drawImage(a,0,0,n.width,n.height),n.toBlob(e=>{const a=URL.createObjectURL(e),n=new Image;n.onload=function(){r(n)},n.onerror=function(){URL.revokeObjectURL(a),o(new Error(`Image load failed: ${t}`))},n.src=a})}else r(a)},a.onerror=function(){o(new Error(`Image load failed: ${t}`))},a.src=t})}function R(t){if(t.composedPath)return t.composedPath();const e=[];let r=t.target;for(;r;)e.push(r),r=r.parentNode;return e.includes(window)||void 0===window||e.push(window),e}function O(){const t=document.createElement("div");t.style.cssText="position:fixed;top:env(safe-area-inset-top,0px);right:env(safe-area-inset-right,0px);bottom:env(safe-area-inset-bottom,0px);left:env(safe-area-inset-left,0px);pointer-events:none;visibility:hidden;",document.body.appendChild(t);const e=getComputedStyle(t),r={top:Number.parseFloat(e.top)||0,right:Number.parseFloat(e.right)||0,bottom:Number.parseFloat(e.bottom)||0,left:Number.parseFloat(e.left)||0};return t.remove(),r}class _ extends Error{constructor(t,e){super(t),"captureStackTrace"in Error&&"function"===typeof Error.captureStackTrace&&Error.captureStackTrace(this,e||this.constructor),this.name="ArtPlayerError"}}function V(t,e){if(!t)throw new _(e);return t}function Y(t){const e=t;return e&&"function"===typeof e.catch?e.catch(()=>{}):t}function N(t){const e=t.search(/[?#]/),r=(e<0?t:t.slice(0,e)).trim().toLowerCase();return r.slice(r.lastIndexOf(".")+1)}function D(t,e){const r=document.createElement("a");r.style.display="none",r.href=t,r.download=e,document.body.appendChild(r);try{r.click()}finally{r.remove()}}function F(t,e,r){return Math.max(Math.min(t,Math.max(e,r)),Math.min(e,r))}function H(t){return t.charAt(0).toUpperCase()+t.slice(1)}function B(t){if(!t)return"00:00";const e=Math.floor(t/3600),r=Math.floor((t-3600*e)/60),o=Math.floor(t-3600*e-60*r);return(e>0?[e,r,o]:[r,o]).map(t=>t<10?`0${t}`:String(t)).join(":")}const W={"&":"&","<":"<",">":">","'":"'",'"':"""},j={"&":"&","<":"<",">":">","'":"'",""":'"'},U=/(&|<|>|'|")/g;function q(t){return t.replace(/[&<>'"]/g,t=>W[t]||t)}const X=Object.defineProperty,{hasOwnProperty:G}=Object.prototype;function K(t,e){return G.call(t,e)}function Z(t,e){return Object.getOwnPropertyDescriptor(t,e)}function J(...t){const e=t=>!!t&&"object"===typeof t&&!Array.isArray(t);return t.reduce((t,r)=>(Object.keys(r).forEach(o=>{const a=t[o],n=r[o];let i;i=Array.isArray(a)&&Array.isArray(n)?a.concat(...n):e(a)&&e(n)?J(a,n):n,X(t,o,{value:i,enumerable:!0,configurable:!0,writable:!0})}),t),{})}function Q(t){return"WEBVTT \r\n\r\n".concat((e=t,e.replace(/(\d\d:\d\d:\d\d)[,.](\d+)/g,(t,e,r)=>{let o=r.slice(0,3);return 1===r.length&&(o=`${r}00`),2===r.length&&(o=`${r}0`),`${e},${o}`})).replace(/\{\\([ibu])\}/g,"").replace(/\{\\([ibu])1\}/g,"<$1>").replace(/\{([ibu])\}/g,"<$1>").replace(/\{\/([ibu])\}/g,"").replace(/(\d\d:\d\d:\d\d),(\d\d\d)/g,"$1.$2").replace(/\{[\s\S]*?\}/g,"").concat("\r\n\r\n"));var e}function tt(t){return URL.createObjectURL(new Blob([t],{type:"text/vtt"}))}function et(t){const e=new RegExp("Dialogue:\\s\\d,(\\d+:\\d\\d:\\d\\d.\\d\\d),(\\d+:\\d\\d:\\d\\d.\\d\\d),([^,]*),([^,]*),(?:[^,]*,){4}([\\s\\S]*)$","i");function r(t=""){return t.split(/[:.]/).map((t,e,r)=>{if(e===r.length-1){if(1===t.length)return`.${t}00`;if(2===t.length)return`.${t}0`}else if(1===t.length)return(0===e?"0":":0")+t;return 0===e?t:e===r.length-1?`.${t}`:`:${t}`}).join("")}return`WEBVTT\n\n${t.split(/\r?\n/).map(t=>{const o=t.match(e);if(!o)return null;const[,a="",n="",,,i=""]=o;return{start:r(a.trim()),end:r(n.trim()),text:i.replace(/\{[\s\S]*?\}/g,"").replace(/(\\N)/g,"\n").trim().split(/\r?\n/).map(t=>t.trim()).join("\n")}}).filter(t=>t).map((t,e)=>t?`${e+1}\n${t.start} --\x3e ${t.end}\n${t.text}`:"").filter(t=>t.trim()).join("\n\n")}`}function rt(t,e){let r=!1;return function(...o){r||(t.apply(this,o),r=!0,setTimeout(()=>{r=!1},e))}}const ot=Object.freeze(Object.defineProperty({__proto__:null,ArtPlayerError:_,addClass:f,append:y,assToVtt:et,capitalize:H,clamp:F,createElement:L,debounce:function(t,e){let r;return function(...o){clearTimeout(r),r=setTimeout(()=>(r=void 0,t.apply(this,o)),e)}},def:X,download:D,errorHandle:V,escape:q,get:Z,getComposedPath:R,getExt:N,getIcon:S,getRect:P,getSafeAreaInsets:O,getStyle:function(t,e,r=!0){const o=window.getComputedStyle(t,null).getPropertyValue(e);return r?Number.parseFloat(o):o},has:K,hasClass:v,includeFromEvent:C,inverseClass:$,isBrowser:h,isIOS:c,isIOS13:d,isInViewport:T,isMobile:p,isSafari:l,loadImg:I,mergeDeep:J,query:u,queryAll:m,remove:b,removeClass:g,replaceElement:z,secondToTime:B,setStyle:w,setStyleText:M,setStyles:x,siblings:k,silencePromise:Y,sleep:function(t=0){return new Promise(e=>setTimeout(e,t))},srtToVtt:Q,supportsFlex:A,throttle:rt,tooltip:E,unescape:function(t){return t.replace(U,t=>j[t]||t)},userAgent:s,vttToBlob:tt},Symbol.toStringTag,{value:"Module"})),at="array",nt="boolean",it="string",st="number",lt="object",ct="function";function dt(t,e,r){return V(e===it||e===st||t instanceof Element,`${r.join(".")} require '${it}' or 'Element' type`)}const pt={html:dt,disable:`?${nt}`,name:`?${it}`,index:`?${st}`,style:`?${lt}`,click:`?${ct}`,mounted:`?${ct}`,tooltip:`?${it}|${st}`,width:`?${st}`,selector:`?${at}`,onSelect:`?${ct}`,switch:`?${nt}`,onSwitch:`?${ct}`,range:`?${at}`,onRange:`?${ct}`,onChange:`?${ct}`},ht={id:it,container:dt,url:it,poster:it,type:it,theme:it,lang:it,volume:st,isLive:nt,muted:nt,autoplay:nt,autoSize:nt,autoMini:nt,loop:nt,flip:nt,playbackRate:nt,aspectRatio:nt,screenshot:nt,setting:nt,hotkey:nt,pip:nt,mutex:nt,backdrop:nt,fullscreen:nt,fullscreenWeb:nt,subtitleOffset:nt,miniProgressBar:nt,useSSR:nt,playsInline:nt,lock:nt,gesture:nt,fastForward:nt,autoPlayback:nt,autoOrientation:nt,airplay:nt,proxy:`?${ct}`,plugins:[ct],layers:[pt],contextmenu:[pt],settings:[pt],controls:[{...pt,position:(t,e,r)=>{const o=["top","left","right"];return V("string"===typeof t&&o.includes(t),`${r.join(".")} only accept ${o.toString()} as parameters`)}}],quality:[{default:`?${nt}`,html:it,url:it}],highlight:[{time:st,text:it}],thumbnails:{url:it,number:st,column:st,width:st,height:st,scale:st},subtitle:{url:it,name:it,type:it,style:lt,escape:nt,encoding:it,onVttLoad:ct},moreVideoAttr:lt,i18n:lt,icons:lt,cssVar:lt,customType:lt};class ut{constructor(t){this.id=0,this.art=t,this.cache=new Map,this.add=this.add.bind(this),this.remove=this.remove.bind(this),this.update=this.update.bind(this)}get show(){return v(this.art.template.$player,`art-${this.name}-show`)}set show(t){const{$player:e}=this.art.template,r=`art-${this.name}-show`;t?f(e,r):g(e,r),this.art.emit(this.name,t)}toggle(){this.show=!this.show}add(t){const e="function"===typeof t?t(this.art):t;if(e.html=e.html||"",a(e,pt),!this.$parent||!this.name||e.disable)return;const r=e.name||`${this.name}${this.id}`;V(!this.cache.has(r),`Can't add an existing [${r}] to the [${this.name}]`),this.id+=1;const o=L("div");f(o,`art-${this.name}`),f(o,`art-${this.name}-${r}`);const n=Array.from(this.$parent.children);o.dataset.index=e.index||this.id;const i=n.find(t=>Number(t.dataset.index)>=Number(o.dataset.index));i?i.insertAdjacentElement("beforebegin",o):y(this.$parent,o),e.html&&y(o,e.html),e.style&&x(o,e.style),e.tooltip&&E(o,e.tooltip);const s=[];if(e.click){const t=this.art.events.proxy(o,"click",t=>{t.preventDefault(),e.click.call(this.art,this,t)});s.push(t)}return e.selector&&["left","right"].includes(e.position)&&this.selector(e,o,s),this[r]=o,this.cache.set(r,{$ref:o,events:s,option:e}),e.mounted&&e.mounted.call(this.art,o),o}remove(t){V(this.cache.has(t),`Can't find [${t}] from the [${this.name}]`);const e=this.cache.get(t);e.option.beforeUnmount&&e.option.beforeUnmount.call(this.art,e.$ref);for(const r of e.events)this.art.events.remove(r);this.cache.delete(t),delete this[t],b(e.$ref)}update(t){if(this.cache.has(t.name)){const e=this.cache.get(t.name);t=Object.assign(e.option,t),this.remove(t.name)}return this.add(t)}}class mt extends ut{constructor(t){super(t),this.name="contextmenu",this.$parent=t.template.$contextmenu,p||this.init()}init(){const{option:t,proxy:e,template:{$player:r,$contextmenu:o}}=this.art;t.playbackRate&&this.add(function(t){return e=>{const{i18n:r,constructor:{PLAYBACK_RATE:o}}=e,a=o.map(t=>`${1===t?r.get("Normal"):t.toFixed(1)}`).join("");return{...t,html:`${r.get("Play Speed")}: ${a}`,click:(t,r)=>{const{value:o}=r.target.dataset;o&&(e.playbackRate=Number(o),t.show=!1)},mounted:t=>{const r=u('[data-value="1"]',t);r&&$(r,"art-current"),e.on("video:ratechange",()=>{const r=m("span",t).find(t=>Number(t.dataset.value)===e.playbackRate);r&&$(r,"art-current")})}}}}({name:"playbackRate",index:10})),t.aspectRatio&&this.add(function(t){return e=>{const{i18n:r,constructor:{ASPECT_RATIO:o}}=e,a=o.map(t=>`${"default"===t?r.get("Default"):t}`).join("");return{...t,html:`${r.get("Aspect Ratio")}: ${a}`,click:(t,r)=>{const{value:o}=r.target.dataset;o&&(e.aspectRatio=o,t.show=!1)},mounted:t=>{const r=u('[data-value="default"]',t);r&&$(r,"art-current"),e.on("aspectRatio",e=>{const r=m("span",t).find(t=>t.dataset.value===e);r&&$(r,"art-current")})}}}}({name:"aspectRatio",index:20})),t.flip&&this.add(function(t){return e=>{const{i18n:r,constructor:{FLIP:o}}=e,a=o.map(t=>`${r.get(H(t))}`).join("");return{...t,html:`${r.get("Video Flip")}: ${a}`,click:(t,r)=>{const{value:o}=r.target.dataset;o&&(e.flip=o.toLowerCase(),t.show=!1)},mounted:t=>{const r=u('[data-value="normal"]',t);r&&$(r,"art-current"),e.on("flip",e=>{const r=m("span",t).find(t=>t.dataset.value===e);r&&$(r,"art-current")})}}}}({name:"flip",index:30})),this.add(function(t){return e=>({...t,html:e.i18n.get("Video Info"),click:t=>{e.info.show=!0,t.show=!1}})}({name:"info",index:40})),this.add(function(t){return{...t,html:`ArtPlayer ${n}`}}({name:"version",index:50})),this.add(function(t){return e=>({...t,html:e.i18n.get("Close"),click:t=>{t.show=!1}})}({name:"close",index:60}));for(let a=0;a{if(!this.art.constructor.CONTEXTMENU)return;t.preventDefault(),this.show=!0;const e=t.clientX,a=t.clientY,{height:n,width:i,left:s,top:l}=P(r),{height:c,width:d}=P(o);let p=e-s,h=a-l;e+d>s+i&&(p=i-d),a+c>l+n&&(h=n-c),x(o,{top:`${h}px`,left:`${p}px`})}),e(r,"click",t=>{C(t,o)||(this.show=!1)}),this.art.on("blur",()=>{this.show=!1})}}class ft extends Error{constructor(t){super("Failed to release ArtPlayer resources"),this.errors=t,this.name="ResourceCleanupError"}}class gt{constructor(){this.cleanups=new Set,this.disposed=!1}get closed(){return this.disposed}add(t){let e=!0;const r=()=>{e&&(e=!1,this.cleanups.delete(r),t())};return this.closed?r():this.cleanups.add(r),r}child(){const t=new gt,e=this.add(()=>{t.dispose()});return t.add(()=>{e()}),t}dispose(){if(this.closed)return;this.disposed=!0;const t=[];for(const r of Array.from(this.cleanups).reverse())try{r()}catch(e){e instanceof ft?t.push(...e.errors):t.push(e)}if(t.length)throw new ft(t)}}const vt=new WeakMap,yt=new WeakMap;function bt(t){const e=vt.get(t);if(!e)throw new Error("ArtPlayer lifecycle has not been initialized");return e}function wt(t){return bt(t).scope}function xt(t){const e=bt(t);return e.destroying||e.scope.closed}function kt(t,e,r,o,a=!1){const n=bt(t);if(n.destroying||n.scope.closed)return;n.destroying=!0;const i=[],s=t=>{try{t()}catch(e){i.push(...e instanceof ft?e.errors:[e])}};o&&t.template?.$video&&s(()=>t.reset()),s(()=>n.scope.dispose()),s(()=>t.template?.destroy(r));const l=e.indexOf(t);-1!==l&&e.splice(l,1),t.isDestroy=!0,a||(n.releaseContainer?.(),n.releaseContainer=void 0),s(()=>t.emit("destroy")),a&&n.rollback&&s(n.rollback),n.rollback=void 0,n.releaseContainer?.(),n.releaseContainer=void 0;for(const c of i.slice(1))console.warn("Additional ArtPlayer cleanup failure:",c);if(i.length)throw i[0]}function $t(t,e,r){if(t.closed)return()=>{};let o=!0,a=()=>{};const n=setTimeout(()=>{o&&(a(),t.closed||e())},r);return a=t.add(()=>{o=!1,clearTimeout(n)}),a}function Et(t,e=0){return t.closed?Promise.resolve(!1):new Promise(r=>{let o=!1,a=()=>{};const n=setTimeout(()=>{o=!0,a(),r(!0)},e);a=t.add(()=>{clearTimeout(n),o||r(!1)})})}function Tt(t,e){const{$progress:r}=t.template,{left:o}=P(r),a=F((p?e.touches[0].clientX:e.clientX)-o,0,r.clientWidth),n=a/r.clientWidth*t.duration;return{second:n,time:B(n),width:a,percentage:F(a/r.clientWidth,0,1)}}function Ct(t,e){if(t.isRotate){const r=(e.touches[0].clientY-t.top)/t.height,o=r*t.duration;t.emit("setBar","played",r,e),t.seek=o}else{const{second:r,percentage:o}=Tt(t,e);t.emit("setBar","played",o,e),t.seek=r}}function zt(t){return e=>{const{icons:r,option:o,proxy:a}=e,{$player:n,$progress:i}=e.template;return{...t,html:'\n
\n
\n
\n
\n
\n
\n
00:00
\n
\n ',mounted:t=>{let s=null,l=!1;const c=u(".art-progress-hover",t),d=u(".art-progress-loaded",t),h=u(".art-progress-played",t),m=u(".art-progress-highlight",t),v=u(".art-progress-indicator",t),b=u(".art-progress-tip",t);function x(r,o){const{width:a,time:n}=o||Tt(e,r);b.textContent=n||"00:00";const i=b.clientWidth;a<=i/2?w(b,"left",0):a>t.clientWidth-i/2?w(b,"left",t.clientWidth-i+"px"):w(b,"left",a-i/2+"px")}r.indicator?y(v,r.indicator):w(v,"backgroundColor","var(--art-theme)"),e.on("setBar",function(r,o,a){const i="played"===r&&a&&p;if("loaded"===r&&w(d,"width",100*o+"%"),"hover"===r&&(w(c,"width",100*o+"%"),C(a,m)?function(r){const{width:o}=Tt(e,r),{text:a}=r.target.dataset;b.textContent=a;const n=b.clientWidth;o<=n/2?w(b,"left",0):o>t.clientWidth-n/2?w(b,"left",t.clientWidth-n+"px"):w(b,"left",o-n/2+"px")}(a):x(a),0===o?g(n,"art-progress-hover"):f(n,"art-progress-hover")),"played"===r&&(w(h,"width",100*o+"%"),w(v,"left",100*o+"%")),i){f(n,"art-progress-hover");x(a,{width:t.clientWidth*o,time:B(o*e.duration)}),clearTimeout(s),s=setTimeout(()=>{g(n,"art-progress-hover")},500)}}),e.on("video:loadedmetadata",function(){m.textContent="";for(let t=0;t`;y(m,n)}}),e.constructor.USE_RAF?e.on("raf",()=>{e.emit("setBar","played",e.played),e.emit("setBar","loaded",e.loaded)}):(e.on("video:timeupdate",()=>{e.emit("setBar","played",e.played)}),e.on("video:progress",()=>{e.emit("setBar","loaded",e.loaded)}),e.on("video:ended",()=>{e.emit("setBar","played",1)})),e.emit("setBar","loaded",e.loaded||0),p||(a(i,"click",t=>{t.target!==v&&Ct(e,t)}),a(i,"mousemove",t=>{const{percentage:r}=Tt(e,t);e.emit("setBar","hover",r,t)}),a(i,"mouseleave",t=>{e.emit("setBar","hover",0,t)}),a(i,"mousedown",t=>{l=0===t.button}),e.on("document:mousemove",t=>{if(l){const{second:r,percentage:o}=Tt(e,t);e.emit("setBar","played",o,t),e.seek=r}}),e.on("document:mouseup",()=>{l&&(l=!1)}))}}}}class Lt extends ut{constructor(t){super(t),this.isHover=!1,this.name="control",this.timer=Date.now();const{constructor:e}=t,{$player:r,$bottom:o}=this.art.template;t.on("mousemove",()=>{p||(this.show=!0)}),t.on("click",()=>{p?this.toggle():this.show=!0}),t.on("document:mousemove",t=>{this.isHover=C(t,o)}),t.on("video:timeupdate",()=>{!t.setting.show&&!this.isHover&&!t.isInput&&t.playing&&this.show&&Date.now()-this.timer>=e.CONTROL_HIDE_TIME&&(this.show=!1)}),t.on("control",t=>{t?(g(r,"art-hide-cursor"),f(r,"art-hover"),this.timer=Date.now()):(f(r,"art-hide-cursor"),g(r,"art-hover"))}),this.init()}init(){const{option:t}=this.art;t.isLive||this.add(zt({name:"progress",position:"top",index:10})),this.add({name:"thumbnails",position:"top",index:20}),this.add(function(t){return e=>({...t,mounted:t=>{const{proxy:r,icons:o,i18n:a}=e,n=y(t,o.play),i=y(t,o.pause);function s(){w(n,"display","flex"),w(i,"display","none")}function l(){w(n,"display","none"),w(i,"display","flex")}E(n,a.get("Play")),E(i,a.get("Pause")),r(n,"click",()=>{Y(e.play())}),r(i,"click",()=>{e.pause()}),e.playing?l():s(),e.on("video:playing",()=>{l()}),e.on("video:pause",()=>{s()})}})}({name:"playAndPause",position:"left",index:10})),this.add(function(t){return e=>({...t,mounted:t=>{const{proxy:r,icons:o}=e,a=y(t,o.volume),n=y(t,o.volumeClose),i=y(t,'
'),s=y(i,'
'),l=y(s,'
'),c=y(s,'
'),d=y(c,'
'),h=y(d,'
'),u=y(c,'
');function m(t){const{top:e,height:r}=P(c);return 1-(t.clientY-e)/r}function f(){if(e.muted||0===e.volume)w(a,"display","none"),w(n,"display","flex"),w(u,"top","100%"),w(h,"top","100%"),l.textContent=0;else{const t=100*e.volume;w(a,"display","flex"),w(n,"display","none"),w(u,"top",100-t+"%"),w(h,"top",100-t+"%"),l.textContent=Math.floor(t)}}if(f(),e.on("video:volumechange",f),r(a,"click",()=>{e.muted=!0}),r(n,"click",()=>{e.muted=!1}),p)w(i,"display","none");else{let t=!1;r(c,"mousedown",r=>{t=0===r.button,e.volume=m(r)}),e.on("document:mousemove",r=>{t&&(e.muted=!1,e.volume=m(r))}),e.on("document:mouseup",()=>{t&&(t=!1)})}}})}({name:"volume",position:"left",index:20})),t.isLive||this.add(function(t){return e=>({...t,style:p?{fontSize:"12px",padding:"0 5px"}:{cursor:"auto",padding:"0 10px"},mounted:t=>{function r(){const r=`${B(e.currentTime)} / ${B(e.duration)}`;r!==t.textContent&&(t.textContent=r)}r();const o=["video:loadedmetadata","video:timeupdate","video:progress"];for(let a=0;a{e&&!wt(this.art).closed&&(this.art.quality=t.quality)}),t.screenshot&&!p&&this.add(function(t){return e=>({...t,tooltip:e.i18n.get("Screenshot"),mounted:t=>{const{proxy:r,icons:o}=e;y(t,o.screenshot),r(t,"click",()=>{e.screenshot()})}})}({name:"screenshot",position:"right",index:20})),t.setting&&this.add(function(t){return e=>({...t,tooltip:e.i18n.get("Show Setting"),mounted:t=>{const{proxy:r,icons:o,i18n:a}=e;y(t,o.setting),r(t,"click",()=>{e.setting.toggle(),e.setting.resize()}),e.on("setting",e=>{E(t,a.get(e?"Hide Setting":"Show Setting"))})}})}({name:"setting",position:"right",index:30})),t.pip&&this.add(function(t){return e=>({...t,tooltip:e.i18n.get("PIP Mode"),mounted:t=>{const{proxy:r,icons:o,i18n:a}=e;y(t,o.pip),r(t,"click",()=>{e.pip=!e.pip}),e.on("pip",e=>{E(t,a.get(e?"Exit PIP Mode":"PIP Mode"))})}})}({name:"pip",position:"right",index:40})),t.airplay&&window.WebKitPlaybackTargetAvailabilityEvent&&this.add(function(t){return e=>({...t,tooltip:e.i18n.get("AirPlay"),mounted:t=>{const{proxy:r,icons:o}=e;y(t,o.airplay),r(t,"click",()=>e.airplay())}})}({name:"airplay",position:"right",index:50})),t.fullscreenWeb&&this.add(function(t){return e=>({...t,tooltip:e.i18n.get("Web Fullscreen"),mounted:t=>{const{proxy:r,icons:o,i18n:a}=e,n=y(t,o.fullscreenWebOn),i=y(t,o.fullscreenWebOff);w(i,"display","none"),r(t,"click",()=>{e.fullscreenWeb=!e.fullscreenWeb}),e.on("fullscreenWeb",e=>{e?(E(t,a.get("Exit Web Fullscreen")),w(n,"display","none"),w(i,"display","inline-flex")):(E(t,a.get("Web Fullscreen")),w(n,"display","inline-flex"),w(i,"display","none"))})}})}({name:"fullscreenWeb",position:"right",index:60})),t.fullscreen&&this.add(function(t){return e=>({...t,tooltip:e.i18n.get("Fullscreen"),mounted:t=>{const{proxy:r,icons:o,i18n:a}=e,n=y(t,o.fullscreenOn),i=y(t,o.fullscreenOff);w(i,"display","none"),r(t,"click",()=>{e.fullscreen=!e.fullscreen}),e.on("fullscreen",e=>{e?(E(t,a.get("Exit Fullscreen")),w(n,"display","none"),w(i,"display","inline-flex")):(E(t,a.get("Fullscreen")),w(n,"display","inline-flex"),w(i,"display","none"))})}})}({name:"fullscreen",position:"right",index:70}));for(let e=0;et.selector}),X(e,"$control_item",{get:()=>r}),X(e,"$control_value",{get:()=>a})}const i=o(n,"click",async e=>{const r=R(e),o=t.selector.find(t=>t.$control_item===r.find(e=>t.$control_item===e));this.check(o),t.onSelect&&(a.innerHTML=await t.onSelect.call(this.art,o,o.$control_item,e))});r.push(i)}}function St(t,e,r,o){const a=e-o,n=r-t;let i=0;if(Math.abs(n)<2&&Math.abs(a)<2)return i;const s=function(t,e){return 180*Math.atan2(e,t)/Math.PI}(n,a);return s>=-45&&s<45?i=4:s>=45&&s<135?i=1:s>=-135&&s<-45?i=2:(s>=135&&s<=180||s>=-180&&s<-135)&&(i=3),i}function Mt(t){if(t.constructor.USE_RAF){const e=wt(t);let r=()=>{};!function o(){t.playing&&t.emit("raf"),t.isDestroy||(r=function(t,e){if(t.closed)return()=>{};let r=!0,o=()=>{};const a=requestAnimationFrame(a=>{r&&(o(),t.closed||e(a))});return o=t.add(()=>{r=!1,cancelAnimationFrame(a)}),o}(e,o))}(),t.on("destroy",()=>{r()})}}const At=new WeakMap;class Pt{constructor(t){this.destroyEvents=new Set;const e=wt(t);At.set(this,e),e.add(()=>this.destroy()),this.proxy=this.proxy.bind(this),this.hover=this.hover.bind(this),function(t,e){const{constructor:r,template:{$player:o,$video:a}}=t;function n(e){C(e,o)?(t.isInput="INPUT"===e.target.tagName,t.isFocus=!0,t.emit("focus",e)):(t.isInput=!1,t.isFocus=!1,t.emit("blur",e))}t.on("document:click",n),t.on("document:contextmenu",n);let i=[];e.proxy(a,"click",e=>{const o=Date.now();i.push(o);const{MOBILE_CLICK_PLAY:a,DBCLICK_TIME:n,MOBILE_DBCLICK_PLAY:s,DBCLICK_FULLSCREEN:l}=r,c=i.filter(t=>o-t<=n);switch(c.length){case 1:t.emit("click",e),p?!t.isLock&&a&&Y(t.toggle()):Y(t.toggle()),i=c;break;case 2:t.emit("dblclick",e),p?!t.isLock&&s&&Y(t.toggle()):l&&(t.fullscreen=!t.fullscreen),i=[];break;default:i=[]}})}(t,this),function(t,e){const{$player:r}=t.template;e.hover(r,e=>{f(r,"art-hover"),t.emit("hover",!0,e)},e=>{g(r,"art-hover"),t.emit("hover",!1,e)})}(t,this),function(t,e){const{$player:r}=t.template;e.proxy(r,"mousemove",e=>{t.emit("mousemove",e)})}(t,this),function(t,e){const{option:r,constructor:o}=t;t.on("resize",()=>{const{aspectRatio:e,notice:o}=t;"standard"===t.state&&r.autoSize&&t.autoSize(),t.aspectRatio=e,o.show=""});const a=wt(t);let n=()=>{};const i=()=>{n(),n=$t(a,()=>t.emit("resize"),o.RESIZE_TIME)};t.on("window:orientationchange",()=>i()),t.on("window:resize",()=>i()),screen&&screen.orientation&&screen.orientation.onchange&&e.proxy(screen.orientation,"change",()=>i())}(t,this),function(t,e){if(p&&!t.option.isLive){const{$video:r,$progress:o}=t.template;let a=null,n=!1,i=0,s=0,l=0;const c=e=>{if(1===e.touches.length&&!t.isLock){a===o&&Ct(t,e),n=!0;const{pageX:r,pageY:c}=e.touches[0];i=r,s=c,l=t.currentTime}},d=e=>{if(1===e.touches.length&&n&&t.duration){const{pageX:o,pageY:n}=e.touches[0],c=St(i,s,o,n),d=[3,4].includes(c),p=[1,2].includes(c);if(d&&!t.isRotate||p&&t.isRotate){const c=F((o-i)/t.width,-1,1),d=F((n-s)/t.height,-1,1),p=t.isRotate?d:c,h=a===r?t.constructor.TOUCH_MOVE_RATIO:1,u=F(l+t.duration*p*h,0,t.duration);t.seek=u,t.emit("setBar","played",F(u/t.duration,0,1),e),t.notice.show=`${B(u)} / ${B(t.duration)}`}}},p=()=>{n&&(i=0,s=0,l=0,n=!1,a=null)};t.option.gesture&&(e.proxy(r,"touchstart",t=>{a=r,c(t)}),e.proxy(r,"touchmove",d)),e.proxy(o,"touchstart",t=>{a=o,c(t)}),e.proxy(o,"touchmove",d),t.on("document:touchend",p)}}(t,this),function(t){const{option:e,constructor:r,template:{$container:o}}=t,a=rt(()=>{t.emit("view",T(o,r.SCROLL_GAP))},r.SCROLL_TIME);t.on("window:scroll",()=>a()),t.on("view",r=>{e.autoMini&&(t.mini=!r)})}(t),function(t,e){const r=["click","mouseup","keydown","touchend","touchmove","mousemove","pointerup","contextmenu","pointermove","visibilitychange","webkitfullscreenchange"],o=["resize","scroll","orientationchange"],a=[];function n(n={}){for(let t=0;t{const o=n.document||i.ownerDocument||document,s=e.proxy(o,r,e=>{t.emit(`document:${r}`,e)});a.push(s)}),o.forEach(r=>{const o=n.window||i.ownerDocument?.defaultView||window,s=e.proxy(o,r,e=>{t.emit(`window:${r}`,e)});a.push(s)})}n(),e.bindGlobalEvents=n}(t,this),Mt(t)}proxy(t,e,r,o={}){if(Array.isArray(e))return e.map(e=>this.proxy(t,e,r,o));if(At.get(this).closed)return()=>{};t.addEventListener(e,r,o);const a=()=>t.removeEventListener(e,r,o);return this.destroyEvents.add(a),a}hover(t,e,r){e&&this.proxy(t,"mouseenter",e),r&&this.proxy(t,"mouseleave",r)}remove(t){if(this.destroyEvents.has(t))try{t()}catch(e){console.warn("Failed to remove event listener:",e)}finally{this.destroyEvents.delete(t)}}destroy(){for(const e of this.destroyEvents)try{e()}catch(t){console.warn("Failed to destroy event listener:",t)}this.destroyEvents.clear()}}class It{constructor(t){this.art=t,this.keys={},p||this.init()}init(){const{constructor:t}=this.art;this.art.option.hotkey&&(this.add("Escape",()=>{this.art.fullscreenWeb&&(this.art.fullscreenWeb=!1)}),this.add("Space",()=>{Y(this.art.toggle())}),this.add("ArrowLeft",()=>{this.art.backward=t.SEEK_STEP}),this.add("ArrowUp",()=>{this.art.volume+=t.VOLUME_STEP}),this.add("ArrowRight",()=>{this.art.forward=t.SEEK_STEP}),this.add("ArrowDown",()=>{this.art.volume-=t.VOLUME_STEP})),this.art.on("document:keydown",t=>{if(this.art.isFocus){const e=document.activeElement.tagName.toUpperCase(),r=document.activeElement.getAttribute("contenteditable");if("INPUT"!==e&&"TEXTAREA"!==e&&""!==r&&"true"!==r&&!t.altKey&&!t.ctrlKey&&!t.metaKey&&!t.shiftKey){const e=this.keys[t.code];if(e){t.preventDefault();for(let r=0;r\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n',state:'\r\n\r\n\r\n',play:'\r\n \r\n',pause:'\r\n \r\n',check:'\r\n\r\n',volume:'\r\n \r\n \r\n',volumeClose:'\r\n \r\n \r\n',screenshot:'\r\n\t\r\n\r\n',setting:'\r\n \r\n \r\n',pip:'\r\n\r\n',arrowLeft:'\r\n \r\n',arrowRight:'\r\n \r\n',playbackRate:'',aspectRatio:'',config:'',lock:'\r\n\r\n\r\n\r\n\r\n',flip:'\r\n\r\n\r\n\r\n\r\n\r\n',unlock:'\r\n\r\n\r\n',fullscreenOff:'\r\n\r\n\r\n\r\n\r\n',fullscreenOn:'\r\n\r\n\r\n\r\n\r\n',fullscreenWebOff:'\r\n\r\n\r\n\r\n\r\n',fullscreenWebOn:'\r\n\r\n\r\n\r\n\r\n',switchOn:'\r\n\r\n\r\n \r\n',switchOff:'\r\n\r\n\r\n \r\n\r\n',error:'\r\n\r\n\r\n\r\n\r\n',close:'\r\n\r\n\r\n\r\n\r\n',airplay:'\r\n \r\n \r\n \r\n \r\n\r\n',...t.option.icons};for(const r in e)X(this,r,{get:()=>S(r,e[r])})}}class Vt extends ut{constructor(t){super(t),this.name="info",p||this.init()}init(){const{proxy:t,constructor:e,template:{$infoPanel:r,$infoClose:o,$video:a}}=this.art;t(o,"click",()=>{this.show=!1});let n=()=>{};const i=m("[data-video]",r)||[];this.art.on("destroy",()=>n());const s=wt(this.art);!function t(){for(let e=0;e{w(a,"display","none"),w(n,"display",null)}),o.proxy(e.$state,"click",()=>Y(t.play()))}}class Ft{constructor(t){this.art=t,this.timer=null,wt(t).add(()=>this.destroy()),t.on("destroy",()=>this.destroy())}destroy(){this.timer&&(clearTimeout(this.timer),this.timer=null)}set show(t){if(wt(this.art).closed)return;const{constructor:e,template:{$player:r,$noticeInner:o}}=this.art;t?(o.textContent=t instanceof Error?t.message.trim():t,f(r,"art-notice-show"),clearTimeout(this.timer),this.timer=setTimeout(()=>{o.textContent="",g(r,"art-notice-show")},e.NOTICE_TIME)):g(r,"art-notice-show")}get show(){const{template:{$player:t}}=this.art;return t.classList.contains("art-notice-show")}}const Ht=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],Bt=(()=>{if("undefined"===typeof document)return!1;const t=Ht[0],e={};for(const r of Ht){if(r[1]in document){for(const[o,a]of r.entries())e[t[o]]=a;return e}}return!1})(),Wt={change:Bt.fullscreenchange,error:Bt.fullscreenerror},jt={request:(t=document.documentElement,e)=>new Promise((r,o)=>{const a=()=>{jt.off("change",a),r()};jt.on("change",a);const n=t[Bt.requestFullscreen](e);n instanceof Promise&&n.then(a).catch(o)}),exit:()=>new Promise((t,e)=>{if(!jt.isFullscreen)return void t();const r=()=>{jt.off("change",r),t()};jt.on("change",r);const o=document[Bt.exitFullscreen]();o instanceof Promise&&o.then(r).catch(e)}),toggle:(t,e)=>jt.isFullscreen?jt.exit():jt.request(t,e),onchange(t){jt.on("change",t)},onerror(t){jt.on("error",t)},on(t,e){const r=Wt[t];r&&document.addEventListener(r,e,!1)},off(t,e){const r=Wt[t];r&&document.removeEventListener(r,e,!1)},raw:Bt};function Ut(t){const{i18n:e,notice:r,template:{$video:o,$player:a}}=t;t.once("video:loadedmetadata",()=>{var n;jt.isEnabled?(n=t,jt.on("change",()=>{n.emit("fullscreen",jt.isFullscreen),jt.isFullscreen?(n.state="fullscreen",f(a,"art-fullscreen")):g(a,"art-fullscreen"),n.emit("resize")}),jt.on("error",t=>{n.emit("fullscreenError",t)}),X(n,"fullscreen",{get:()=>jt.isFullscreen,async set(t){t?await jt.request(a):await jt.exit()}})):o.webkitSupportsFullscreen?(t=>{t.on("document:webkitfullscreenchange",()=>{t.emit("fullscreen",t.fullscreen),t.emit("resize")}),X(t,"fullscreen",{get:()=>document.fullscreenElement===o,set(e){e?(t.state="fullscreen",o.webkitEnterFullscreen()):o.webkitExitFullscreen()}})})(t):X(t,"fullscreen",{get:()=>!1,set(){r.show=e.get("Fullscreen Not Supported")}}),X(t,"fullscreen",Z(t,"fullscreen"))})}function qt(t){const{icons:e,proxy:r,storage:o,template:{$player:a,$video:n}}=t;let i=!1,s=0,l=0;function c(){const{$mini:e}=t.template;e&&(g(a,"art-mini"),w(e,"display","none"),a.prepend(n),t.emit("mini",!1))}function d(e,r){t.playing?(w(e,"display","none"),w(r,"display","flex")):(w(e,"display","flex"),w(r,"display","none"))}function p(){const{$mini:e}=t.template,r=P(e),a=window.innerHeight-r.height-50,n=window.innerWidth-r.width-50;o.set("top",a),o.set("left",n),w(e,"top",`${a}px`),w(e,"left",`${n}px`)}X(t,"mini",{get:()=>v(a,"art-mini"),set(h){if(h){t.state="mini",f(a,"art-mini");const h=function(){const{$mini:a}=t.template;if(a)return y(a,n),w(a,"display","flex");{const a=L("div");f(a,"art-mini-popup"),y(document.body,a),t.template.$mini=a,y(a,n);const p=y(a,'
');y(p,e.close),r(p,"click",c);const h=y(a,'
'),u=y(h,e.play),m=y(h,e.pause);return r(u,"click",()=>Y(t.play())),r(m,"click",()=>t.pause()),d(u,m),t.on("video:playing",()=>d(u,m)),t.on("video:pause",()=>d(u,m)),t.on("video:timeupdate",()=>d(u,m)),r(a,"mousedown",t=>{i=0===t.button,s=t.pageX,l=t.pageY}),t.on("document:mousemove",t=>{if(i){f(a,"art-mini-dragging");const e=t.pageX-s,r=t.pageY-l;w(a,"transform",`translate(${e}px, ${r}px)`)}}),t.on("document:mouseup",()=>{if(i){i=!1,g(a,"art-mini-dragging");const t=P(a);o.set("left",t.left),o.set("top",t.top),w(a,"left",`${t.left}px`),w(a,"top",`${t.top}px`),w(a,"transform",null)}}),a}}(),u=o.get("top"),m=o.get("left");"number"===typeof u&&"number"===typeof m?(w(h,"top",`${u}px`),w(h,"left",`${m}px`),T(h)||p()):p(),t.emit("mini",!0)}else c()}})}function Xt(t){const{i18n:e,notice:r,template:{$video:o}}=t;document.pictureInPictureEnabled?function(t){const{template:{$video:e},proxy:r,notice:o}=t;e.disablePictureInPicture=!1,X(t,"pip",{get:()=>document.pictureInPictureElement,set(r){r?(t.state="pip",e.requestPictureInPicture().catch(t=>{throw o.show=t,t})):document.exitPictureInPicture().catch(t=>{throw o.show=t,t})}}),r(e,"enterpictureinpicture",()=>{t.emit("pip",!0)}),r(e,"leavepictureinpicture",()=>{t.emit("pip",!1)})}(t):o.webkitSupportsPresentationMode?function(t){const{$video:e}=t.template;e.webkitSetPresentationMode("inline"),X(t,"pip",{get:()=>"picture-in-picture"===e.webkitPresentationMode,set(r){r?(t.state="pip",e.webkitSetPresentationMode("picture-in-picture"),t.emit("pip",!0)):(e.webkitSetPresentationMode("inline"),t.emit("pip",!1))}})}(t):X(t,"pip",{get:()=>!1,set(){r.show=e.get("PIP Not Supported")}})}function Gt(t){const{option:e,template:{$progress:r,$video:o}}=t;let a=null,n=!1,i=null;t.on("setBar",async(a,s,l)=>{const c=t.controls?.thumbnails,{url:d,scale:h}=e.thumbnails;if(!c||!d)return;if("hover"===a||"played"===a&&l&&p){if(i||n||(n=!0,i=await I(d,h),n=!1),!i)return;const a=r.clientWidth*s;a>0&&ar.clientWidth-h/2?w(n,"left",r.clientWidth-h+"px"):w(n,"left",a-h/2+"px")}(a)}}),X(t,"thumbnails",{get:()=>t.option.thumbnails,set(e){e.url&&!t.option.isLive&&(t.option.thumbnails=e,clearTimeout(a),a=null,n=!1,i=null)}})}Object.defineProperties(jt,{isFullscreen:{get:()=>Boolean(document[Bt.fullscreenElement])},element:{enumerable:!0,get:()=>document[Bt.fullscreenElement]},isEnabled:{enumerable:!0,get:()=>Boolean(document[Bt.fullscreenEnabled])}});class Kt{constructor(t){!function(t){const{option:e,template:{$video:r}}=t;X(t,"url",{get:()=>r.src,async set(o){if(o){const a=t.url,n=e.type||N(o),i=e.customType[n];if(n&&i){if(!(await Et(wt(t)))||wt(t).closed)return;t.loading.show=!0,i.call(t,r,o,t)}else URL.revokeObjectURL(a),r.src=o;a!==t.url&&(t.option.url=o,t.isReady&&a&&t.once("video:canplay",()=>{t.emit("restart",o)}))}else{if(!(await Et(wt(t)))||wt(t).closed)return;t.loading.show=!0}}})}(t),function(t){const{template:{$video:e}}=t;X(t,"attr",{value(t,r){if(void 0===r)return e[t];e[t]=r}})}(t),function(t){const{i18n:e,notice:r,option:o,constructor:{instances:a},template:{$video:n}}=t;X(t,"play",{async value(){const i=await n.play();if(r.show=e.get("Play"),t.emit("play"),o.mutex)for(let e=0;et.playing?t.pause():t.play()})}(t),function(t){const{notice:e}=t;X(t,"seek",{set(r){t.currentTime=r,t.duration&&(e.show=`${B(t.currentTime)} / ${B(t.duration)}`),t.emit("seek",t.currentTime,r)}}),X(t,"forward",{set(e){t.seek=t.currentTime+e}}),X(t,"backward",{set(e){t.seek=t.currentTime-e}})}(t),function(t){const{template:{$video:e},i18n:r,notice:o,storage:a}=t;X(t,"volume",{get:()=>e.volume||0,set:t=>{e.volume=F(t,0,1),o.show=`${r.get("Volume")}: ${Number.parseInt(100*e.volume,10)}`,0!==e.volume&&a.set("volume",e.volume)}}),X(t,"muted",{get:()=>e.muted,set:r=>{e.muted=r,t.emit("muted",r)}})}(t),function(t){const{$video:e}=t.template;X(t,"currentTime",{get:()=>e.currentTime||0,set:r=>{r=Number.parseFloat(r),Number.isNaN(r)||(e.currentTime=F(r,0,t.duration))}})}(t),function(t){X(t,"duration",{get:()=>{const{duration:e}=t.template.$video;return e===1/0?0:e||0}})}(t),function(t){function e(e,r){return new Promise((o,a)=>{if(e===t.url)return void o();const{playing:n,aspectRatio:i,playbackRate:s}=t;t.pause(),t.url=e,t.notice.show="";const l={error:e=>{t.off("video:canplay",l.canplay),t.off("video:loadedmetadata",l.metadata),a(e)},metadata:()=>{t.currentTime=r},canplay:async()=>{t.off("video:error",l.error),t.playbackRate=s,t.aspectRatio=i,n&&await Y(t.play()),t.notice.show="",o()}};t.once("video:error",l.error),t.once("video:loadedmetadata",l.metadata),t.once("video:canplay",l.canplay)})}X(t,"switchQuality",{value:r=>e(r,t.currentTime)}),X(t,"switchUrl",{value:t=>e(t,0)}),X(t,"switch",{set:t.switchUrl})}(t),function(t){const{template:{$video:e},i18n:r,notice:o}=t;X(t,"playbackRate",{get:()=>e.playbackRate,set(a){if(a){if(a===e.playbackRate)return;e.playbackRate=a,o.show=`${r.get("Rate")}: ${1===a?r.get("Normal"):`${a}x`}`}else t.playbackRate=1}})}(t),function(t){const{i18n:e,notice:r,template:{$video:o,$player:a}}=t;X(t,"aspectRatio",{get:()=>a.dataset.aspectRatio||"default",set(n){if(n||(n="default"),"default"===n)w(o,"width",null),w(o,"height",null),w(o,"margin",null),delete a.dataset.aspectRatio;else{const t=n.split(":").map(Number),{clientWidth:e,clientHeight:r}=a,i=e/r,s=t[0]/t[1];i>s?(w(o,"width",s*r+"px"),w(o,"height","100%"),w(o,"margin","0 auto")):(w(o,"width","100%"),w(o,"height",e/s+"px"),w(o,"margin","auto 0")),a.dataset.aspectRatio=n}r.show=`${e.get("Aspect Ratio")}: ${"default"===n?e.get("Default"):n}`,t.emit("aspectRatio",n)}})}(t),function(t){const{notice:e,template:{$video:r}}=t,o=L("canvas");X(t,"getDataURL",{value:()=>new Promise((t,a)=>{try{o.width=r.videoWidth,o.height=r.videoHeight,o.getContext("2d").drawImage(r,0,0),t(o.toDataURL("image/png"))}catch(n){e.show=n,a(n)}})}),X(t,"getBlobUrl",{value:()=>new Promise((t,a)=>{try{o.width=r.videoWidth,o.height=r.videoHeight,o.getContext("2d").drawImage(r,0,0),o.toBlob(e=>{t(URL.createObjectURL(e))})}catch(n){e.show=n,a(n)}})}),X(t,"screenshot",{value:async e=>{const o=await t.getDataURL();return D(o,`${e||`artplayer_${B(r.currentTime)}`}.png`),t.emit("screenshot",o),o}})}(t),Ut(t),function(t){const{constructor:e,template:{$container:r,$player:o}}=t;let a="";X(t,"fullscreenWeb",{get:()=>v(o,"art-fullscreen-web"),set(n){n?(a=o.style.cssText,e.FULLSCREEN_WEB_IN_BODY&&y(document.body,o),t.state="fullscreenWeb",w(o,"width","100%"),w(o,"height","100%"),f(o,"art-fullscreen-web"),t.emit("fullscreenWeb",!0)):(e.FULLSCREEN_WEB_IN_BODY&&y(r,o),a&&(o.style.cssText=a,a=""),g(o,"art-fullscreen-web"),t.emit("fullscreenWeb",!1)),t.emit("resize")}})}(t),Xt(t),function(t){const{$video:e}=t.template;X(t,"loaded",{get:()=>t.loadedTime/e.duration}),X(t,"loadedTime",{get:()=>e.buffered.length?e.buffered.end(e.buffered.length-1):0})}(t),function(t){X(t,"played",{get:()=>t.currentTime/t.duration})}(t),function(t){const{$video:e}=t.template;X(t,"playing",{get:()=>"boolean"===typeof e.playing?e.playing:!!(e.currentTime>0&&!e.paused&&!e.ended&&e.readyState>2)})}(t),function(t){const{$container:e,$player:r,$video:o}=t.template;X(t,"autoSize",{value(){const{videoWidth:a,videoHeight:n}=o,{width:i,height:s}=P(e),l=a/n;if(i/s>l)w(r,"width",s*l/i*100+"%"),w(r,"height","100%");else{const t=i/l/s*100;w(r,"width","100%"),w(r,"height",`${t}%`)}t.emit("autoSize",{width:t.width,height:t.height})}})}(t),function(t){const e=t;X(t,"rect",{get:()=>P(t.template.$player)});const r=["bottom","height","left","right","top","width"];for(let o=0;oe.rect[a]})}X(t,"x",{get:()=>e.left+window.pageXOffset}),X(t,"y",{get:()=>e.top+window.pageYOffset})}(t),function(t){const{template:{$player:e},i18n:r,notice:o}=t;X(t,"flip",{get:()=>e.dataset.flip||"normal",set(a){a||(a="normal"),"normal"===a?delete e.dataset.flip:e.dataset.flip=a,o.show=`${r.get("Video Flip")}: ${r.get(H(a))}`,t.emit("flip",a)}})}(t),qt(t),function(t){const{template:{$poster:e}}=t;X(t,"poster",{get:()=>{try{return e.style.backgroundImage.match(/"(.*)"/)[1]}catch{return""}},set(t){w(e,"backgroundImage",`url(${t})`)}})}(t),function(t){const{template:{$container:e,$video:r}}=t;X(t,"autoHeight",{value(){const{clientWidth:o}=e,{videoHeight:a,videoWidth:n}=r,i=a*(o/n);w(e,"height",`${i}px`),t.emit("autoHeight",i)}})}(t),function(t){const{$player:e}=t.template;X(t,"cssVar",{value:(t,r)=>r?e.style.setProperty(t,r):getComputedStyle(e).getPropertyValue(t)})}(t),function(t){X(t,"theme",{get:()=>t.cssVar("--art-theme"),set(e){t.cssVar("--art-theme",e)}})}(t),function(t){X(t,"type",{get:()=>t.option.type,set(e){t.option.type=e}})}(t),function(t){const e=["mini","pip","fullscreen","fullscreenWeb"];X(t,"state",{get:()=>e.find(e=>t[e])||"standard",set(r){for(let o=0;oo.$track?.offset||0,set(a){const{cues:n}=t.subtitle;if(!o.$track||0===n.length)return;const i=F(a,-10,10);o.$track.offset=i;for(let e=0;e{switch(t.availability){case"available":n=!0;break;case"not-available":n=!1}}):n=!1,X(t,"airplay",{value(){n?(a.webkitShowPlaybackTargetPicker(),t.emit("airplay")):r.show=e.get("AirPlay Not Available")}})}(t),function(t){X(t,"quality",{set(e){const{controls:r,notice:o,i18n:a}=t,n=e.find(t=>t.default)||e[0];r.update({name:"quality",position:"right",index:10,style:{marginRight:"10px"},html:n?.html||"",selector:e,onSelect:async e=>(await t.switchQuality(e.url),o.show=`${a.get("Switch Video")}: ${e.html}`,e.html)})}})}(t),Gt(t),function(t){const{i18n:e,notice:r,option:o,constructor:a,proxy:n,template:{$player:s,$video:l,$poster:c}}=t;let d=0;for(let p=0;p{t.emit(`video:${e.type}`,e)});t.on("video:canplay",()=>{d=0,t.loading.show=!1}),t.once("video:canplay",()=>{t.loading.show=!1,t.controls.show=!0,t.mask.show=!0,t.isReady=!0,t.emit("ready")}),t.on("video:ended",()=>{o.loop?(t.seek=0,Y(t.play()),t.controls.show=!1,t.mask.show=!1):(t.controls.show=!0,t.mask.show=!0)}),t.on("video:error",async n=>{if(d{t.emit("resize"),p&&(t.loading.show=!1,t.controls.show=!0,t.mask.show=!0)}),t.on("video:loadstart",()=>{t.loading.show=!0,t.mask.show=!1,t.controls.show=!0}),t.on("video:pause",()=>{t.controls.show=!0,t.mask.show=!0}),t.on("video:play",()=>{t.mask.show=!1,w(c,"display","none")}),t.on("video:playing",()=>{t.mask.show=!1}),t.on("video:progress",()=>{t.playing&&(t.loading.show=!1)}),t.on("video:seeked",()=>{t.loading.show=!1,t.mask.show=!0}),t.on("video:seeking",()=>{t.loading.show=!0,t.mask.show=!1}),t.on("video:timeupdate",()=>{t.mask.show=!1}),t.on("video:waiting",()=>{t.loading.show=!0,t.mask.show=!1})}(t),function(t){const{option:e,storage:r,template:{$video:o,$poster:a}}=t;for(const i in e.moreVideoAttr)t.attr(i,e.moreVideoAttr[i]);e.muted&&(t.muted=e.muted),e.volume&&(o.volume=F(e.volume,0,1));const n=r.get("volume");"number"===typeof n&&(o.volume=F(n,0,1)),e.poster&&w(a,"backgroundImage",`url(${e.poster})`),e.autoplay&&(o.autoplay=e.autoplay),e.playsInline&&(o.playsInline=!0,o["webkit-playsinline"]=!0),e.theme&&(e.cssVar["--art-theme"]=e.theme);for(const i in e.cssVar)t.cssVar(i,e.cssVar[i]);t.url=e.url}(t)}}function Zt(t){const{notice:e,constructor:r,template:{$player:o,$video:a}}=t,n="art-auto-orientation",i="art-auto-orientation-fullscreen";let s=!1;function l(){const{videoWidth:t,videoHeight:e}=a,r=document.documentElement.clientWidth,o=document.documentElement.clientHeight;return t>e&&ro}return t.on("fullscreenWeb",e=>{if(e){if(l()){const e=Number(r.AUTO_ORIENTATION_TIME??0);setTimeout(()=>{t.fullscreenWeb&&!v(o,n)&&function(){const e=O(),r=document.documentElement.clientWidth,a=document.documentElement.clientHeight-e.top-e.bottom,i=r-e.left-e.right;w(o,"width",`${a}px`),w(o,"height",`${i}px`),w(o,"transform-origin","0 0"),w(o,"transform",`rotate(90deg) translate(${e.top}px, -${r-e.right}px)`),f(o,n),t.isRotate=!0,t.emit("resize")}()},e)}}else v(o,n)&&(w(o,"width",""),w(o,"height",""),w(o,"transform-origin",""),w(o,"transform",""),g(o,n),t.isRotate=!1,t.emit("resize"))}),t.on("fullscreen",async t=>{const r=!!screen?.orientation?.lock;if(t){if(r&&l())try{const t=screen.orientation.type.startsWith("portrait")?"landscape":"portrait";await screen.orientation.lock(t),s=!0,f(o,i)}catch(a){s=!1,e.show=a}}else if(v(o,i)&&g(o,i),r&&s){try{screen.orientation.unlock()}catch{}s=!1}}),{name:"autoOrientation",get state(){return v(o,n)}}}function Jt(t){const{i18n:e,icons:r,storage:o,constructor:a,proxy:n,template:{$poster:i}}=t,s=t.layers.add({name:"auto-playback",html:'\n
\n
\n
\n '}),l=u(".art-auto-playback-last",s),c=u(".art-auto-playback-jump",s),d=u(".art-auto-playback-close",s);y(d,r.close);let p=null;function h(){const r=(o.get("times")||{})[t.option.id||t.option.url];clearTimeout(p),w(s,"display","none"),r&&r>=a.AUTO_PLAYBACK_MIN&&(w(s,"display","flex"),l.textContent=`${e.get("Last Seen")} ${B(r)}`,c.textContent=e.get("Jump Play"),n(d,"click",()=>{w(s,"display","none")}),n(c,"click",()=>{t.seek=r,Y(t.play()),w(i,"display","none"),w(s,"display","none")}),t.once("video:timeupdate",()=>{p=setTimeout(()=>{w(s,"display","none")},a.AUTO_PLAYBACK_TIMEOUT)}))}return t.on("video:timeupdate",()=>{if(t.playing){const e=o.get("times")||{},r=Object.keys(e);r.length>a.AUTO_PLAYBACK_MAX&&delete e[r[0]],e[t.option.id||t.option.url]=t.currentTime,o.set("times",e)}}),t.on("ready",h),t.on("restart",h),{name:"auto-playback",get times(){return o.get("times")||{}},clear:()=>o.del("times"),delete(t){const e=o.get("times")||{};return delete e[t],o.set("times",e),e}}}function Qt(t){const{constructor:e,proxy:r,template:{$player:o,$video:a}}=t;let n=null,i=!1,s=1;const l=()=>{clearTimeout(n),i&&(i=!1,t.playbackRate=s,g(o,"art-fast-forward"))};return r(a,"touchstart",r=>{1===r.touches.length&&t.playing&&!t.isLock&&(n=setTimeout(()=>{i=!0,s=t.playbackRate,t.playbackRate=e.FAST_FORWARD_VALUE,f(o,"art-fast-forward")},e.FAST_FORWARD_TIME))}),t.on("document:touchmove",l),t.on("document:touchend",l),{name:"fastForward",get state(){return v(o,"art-fast-forward")}}}function te(t){const{layers:e,icons:r,template:{$player:o}}=t;function a(){return v(o,"art-lock")}function n(){f(o,"art-lock"),t.isLock=!0,t.emit("lock",!0)}function i(){g(o,"art-lock"),t.isLock=!1,t.emit("lock",!1)}return e.add({name:"lock",mounted(e){const o=y(e,r.lock),a=y(e,r.unlock);w(o,"display","none"),t.on("lock",t=>{t?(w(o,"display","inline-flex"),w(a,"display","none")):(w(o,"display","none"),w(a,"display","inline-flex"))})},click(){a()?i():n()}}),{name:"lock",get state(){return a()},set state(t){t?n():i()}}}function ee(t){return t.on("control",e=>{e?g(t.template.$player,"art-mini-progress-bar"):f(t.template.$player,"art-mini-progress-bar")}),{name:"mini-progress-bar"}}class re{constructor(t){this.art=t,this.id=0;const{option:e}=t;!function(t,e){xt(t.art)||!e.miniProgressBar||e.isLive||t.add(ee),!xt(t.art)&&e.lock&&p&&t.add(te),xt(t.art)||!e.autoPlayback||e.isLive||t.add(Jt),!xt(t.art)&&e.autoOrientation&&p&&t.add(Zt),!xt(t.art)&&e.fastForward&&p&&!e.isLive&&t.add(Qt)}(this,e);for(let r=0;rconsole.warn("Failed to initialize ArtPlayer plugin:",t))}}add(t){V(!xt(this.art),"Cannot add a plugin after ArtPlayer is destroyed"),this.id+=1;const e=t.call(this.art,this.art);return e instanceof Promise?e.then(e=>this.next(t,e)):this.next(t,e)}next(t,e){return function(t,e,r){if(xt(t.art))return t;const o=r&&r.name||e.name||`plugin${t.id}`;if(xt(t.art))return t;let a=o;const n=K(t,a);if(xt(t.art))return t;const i=`Cannot add a plugin that already has the same name: ${o}`;return xt(t.art)||(V(!n,i),("object"===typeof o&&null!==o||"function"===typeof o)&&(a=Reflect.ownKeys({[a]:void 0})[0]),xt(t.art)||X(t,a,{value:r})),t}(this,t,e)}}class oe extends ut{constructor(t){super(t);const{option:e,controls:r,template:{$setting:o}}=t;this.name="setting",this.$parent=o,this.id=0,this.active=null,this.cache=new Map,this.option=[...this.builtin,...e.settings],e.setting&&(this.format(),this.render(),t.on("blur",()=>{this.show&&(this.show=!1,this.render())}),t.on("focus",t=>{const e=C(t,r.setting),o=C(t,this.$parent);!this.show||e||o||(this.show=!1,this.render())}),t.on("resize",()=>this.resize()))}get builtin(){const t=[],{option:e}=this.art;return e.playbackRate&&t.push(function(t){const{i18n:e,icons:r,constructor:{SETTING_ITEM_WIDTH:o,PLAYBACK_RATE:a}}=t;function n(t){return 1===t?e.get("Normal"):t.toFixed(1)}function i(){const e=t.setting.find(`playback-rate-${t.playbackRate}`);t.setting.check(e)}return{width:o,name:"playback-rate",html:e.get("Play Speed"),tooltip:n(t.playbackRate),icon:r.playbackRate,selector:a.map(e=>({value:e,name:`playback-rate-${e}`,default:e===t.playbackRate,html:n(e)})),onSelect:e=>(t.playbackRate=e.value,e.html),mounted:()=>{i(),t.on("video:ratechange",()=>i())}}}(this.art)),e.aspectRatio&&t.push(function(t){const{i18n:e,icons:r,constructor:{SETTING_ITEM_WIDTH:o,ASPECT_RATIO:a}}=t;function n(t){return"default"===t?e.get("Default"):t}function i(){const e=t.setting.find(`aspect-ratio-${t.aspectRatio}`);t.setting.check(e)}return{width:o,name:"aspect-ratio",html:e.get("Aspect Ratio"),icon:r.aspectRatio,tooltip:n(t.aspectRatio),selector:a.map(e=>({value:e,name:`aspect-ratio-${e}`,default:e===t.aspectRatio,html:n(e)})),onSelect:e=>(t.aspectRatio=e.value,e.html),mounted:()=>{i(),t.on("aspectRatio",()=>i())}}}(this.art)),e.flip&&t.push(function(t){const{i18n:e,icons:r,constructor:{SETTING_ITEM_WIDTH:o,FLIP:a}}=t;function n(t){return e.get(H(t))}function i(){const e=t.setting.find(`flip-${t.flip}`);t.setting.check(e)}return{width:o,name:"flip",html:e.get("Video Flip"),tooltip:n(t.flip),icon:r.flip,selector:a.map(e=>({value:e,name:`flip-${e}`,default:e===t.flip,html:n(e)})),onSelect:e=>(t.flip=e.value,e.html),mounted:()=>{i(),t.on("flip",()=>i())}}}(this.art)),e.subtitleOffset&&t.push(function(t){const{i18n:e,icons:r,constructor:o}=t;return{width:o.SETTING_ITEM_WIDTH,name:"subtitle-offset",html:e.get("Subtitle Offset"),icon:r.subtitle,tooltip:"0s",range:[0,-10,10,.1],onChange:e=>(t.subtitleOffset=e.range[0],`${e.range[0]}s`),mounted:(e,r)=>{t.on("subtitleOffset",t=>{r.$range.value=t,r.tooltip=`${t}s`})}}}(this.art)),t}traverse(t,e=this.option){for(let r=0;r{e.default=e===t,e.default&&e.$item&&$(e.$item,"art-current")},t.$option),this.render(t.$parents))}format(t=this.option,e,r,o=[]){for(let a=0;ae}),X(n,"$parents",{get:()=>r}),X(n,"$option",{get:()=>t});const o=[];X(n,"$events",{get:()=>o}),X(n,"$formatted",{get:()=>!0})}this.format(n.selector||[],n,t,o)}this.option=t}find(t=""){let e=null;return this.traverse(r=>{r.name===t&&(e=r)}),e}resize(){const{controls:t,constructor:{SETTING_WIDTH:e,SETTING_ITEM_HEIGHT:r},template:{$player:o,$setting:a}}=this.art;if(t.setting&&this.show){const n=this.active[0]?.$parent?.width||e,{left:i,width:s}=P(t.setting),{left:l,width:c}=P(o),d=i-l+s/2-n/2;if(w(a,"height",`${this.active===this.option?this.active.length*r:(this.active.length+1)*r}px`),w(a,"width",`${n}px`),this.art.isRotate||p)return;d+n>c?(w(a,"left",null),w(a,"right",null)):(w(a,"left",`${d}px`),w(a,"right","auto"))}}inactivate(t){for(let e=0;e'),s=L("div");f(s,"art-setting-item-left-icon"),y(s,o),y(i,s),y(i,t.$parent.html);const l=r(n,"click",()=>this.render(t.$parents));t.$parent.$events.push(l),y(e,n)}createItem(t,e=!1){if(!this.cache.has(t.$option))return;const r=this.cache.get(t.$option),o=t.$item;let a="selector";K(t,"switch")&&(a="switch"),K(t,"range")&&(a="range"),K(t,"onClick")&&(a="button");const{icons:n,proxy:i,constructor:s}=this.art,l=L("div");f(l,"art-setting-item"),w(l,"height",`${s.SETTING_ITEM_HEIGHT}px`),l.dataset.name=t.name||"",l.dataset.value=t.value||"";const c=y(l,'
'),d=y(l,'
'),p=L("div");switch(f(p,"art-setting-item-left-icon"),a){case"button":case"switch":case"range":y(p,t.icon||n.config);break;case"selector":t.selector?.length?y(p,t.icon||n.config):y(p,n.check)}y(c,p),X(t,"$icon",{configurable:!0,get:()=>p}),X(t,"icon",{configurable:!0,get:()=>p.innerHTML,set(t){p.innerHTML="",y(p,t)}});const h=L("div");f(h,"art-setting-item-left-text"),y(h,t.html||""),y(c,h),X(t,"$html",{configurable:!0,get:()=>h}),X(t,"html",{configurable:!0,get:()=>h.innerHTML,set(t){h.innerHTML="",y(h,t)}});const u=L("div");switch(f(u,"art-setting-item-right-tooltip"),y(u,t.tooltip||""),y(d,u),X(t,"$tooltip",{configurable:!0,get:()=>u}),X(t,"tooltip",{configurable:!0,get:()=>u.innerHTML,set(t){u.innerHTML="",y(u,t)}}),a){case"switch":{const e=L("div");f(e,"art-setting-item-right-icon");const r=y(e,n.switchOn),o=y(e,n.switchOff);w(t.switch?o:r,"display","none"),y(d,e),X(t,"$switch",{configurable:!0,get:()=>e});let a=t.switch;X(t,"switch",{configurable:!0,get:()=>a,set(t){a=t,t?(w(o,"display","none"),w(r,"display",null)):(w(o,"display",null),w(r,"display","none"))}});break}case"range":{const e=L("div");f(e,"art-setting-item-right-icon");const r=y(e,'');r.value=t.range[0],r.min=t.range[1],r.max=t.range[2],r.step=t.range[3],f(r,"art-setting-range"),y(d,e),X(t,"$range",{configurable:!0,get:()=>r});let o=[...t.range];X(t,"range",{configurable:!0,get:()=>o,set(t){o=[...t],r.value=t[0],r.min=t[1],r.max=t[2],r.step=t[3]}})}break;case"selector":if(t.selector?.length){const t=L("div");f(t,"art-setting-item-right-icon"),y(t,n.arrowRight),y(d,t)}}switch(a){case"switch":if(t.onSwitch){const e=i(l,"click",async e=>{t.switch=await t.onSwitch.call(this.art,t,l,e)});t.$events.push(e)}break;case"range":if(t.$range){if(t.onRange){const e=i(t.$range,"change",async e=>{t.range[0]=t.$range.valueAsNumber,t.tooltip=await t.onRange.call(this.art,t,l,e)});t.$events.push(e)}if(t.onChange){const e=i(t.$range,"input",async e=>{t.range[0]=t.$range.valueAsNumber,t.tooltip=await t.onChange.call(this.art,t,l,e)});t.$events.push(e)}}break;case"selector":{const e=i(l,"click",async e=>{t.selector?.length?this.render(t.selector):(this.check(t),t.$parent.onSelect&&(t.$parent.tooltip=await t.$parent.onSelect.call(this.art,t,l,e)))});t.$events.push(e),t.default&&f(l,"art-current")}break;case"button":if(t.onClick){const e=i(l,"click",async e=>{t.tooltip=await t.onClick.call(this.art,t,l,e)});t.$events.push(e)}}X(t,"$item",{configurable:!0,get:()=>l}),e?z(l,o):y(r,l),t.mounted&&$t(wt(this.art),()=>t.mounted.call(this.art,t.$item,t),0)}render(t=this.option){if(this.active=t,this.cache.has(t)){$(this.cache.get(t),"art-current")}else{const e=L("div");this.cache.set(t,e),f(e,"art-setting-panel"),y(this.$parent,e),$(e,"art-current"),t[0]?.$parent&&this.createHeader(t[0]);for(let r=0;rnull,this.init(t.option.subtitle);let e=!1;t.on("video:timeupdate",()=>{if(!this.url)return;const t=this.art.template.$video.webkitDisplayingFullscreen;"boolean"===typeof t&&t!==e&&(e=t,this.createTrack(t?"subtitles":"metadata",this.url))})}get url(){return this.art.template.$track.src}set url(t){this.switch(t)}get textTrack(){return this.art.template.$video?.textTracks?.[0]}get activeCues(){return this.textTrack?Array.from(this.textTrack.activeCues):[]}get cues(){return this.textTrack?Array.from(this.textTrack.cues):[]}style(t,e){const{$subtitle:r}=this.art.template;return"object"===typeof t?x(r,t):w(r,t,e)}update(){const{option:{subtitle:t},template:{$subtitle:e}}=this.art;e.innerHTML="",this.activeCues.length&&(this.art.emit("subtitleBeforeUpdate",this.activeCues),e.innerHTML=this.activeCues.map((e,r)=>e.text.split(/\r?\n/).filter(t=>t.trim()).map(e=>`
\n ${t.escape?q(e):e}\n
`).join("")).join(""),this.art.emit("subtitleAfterUpdate",this.activeCues))}async switch(t,e={}){const{i18n:r,notice:o,option:a}=this.art,n={...a.subtitle,...e,url:t},i=await this.init(n);return e.name&&(o.show=`${r.get("Switch Subtitle")}: ${e.name}`),i}createTrack(t,e){const{template:r,proxy:o,option:a}=this.art,{$video:n,$track:i}=r,s=L("track");s.default=!0,s.kind=t,s.src=e,s.label=a.subtitle.name||"Artplayer",s.track.mode="hidden",s.onload=()=>{this.art.emit("subtitleLoad",this.cues,this.option)},this.art.events.remove(this.destroyEvent),i.onload=null,b(i),y(n,s),r.$track=s,this.destroyEvent=o(this.textTrack,"cuechange",()=>this.update())}async init(t){const{notice:e,template:{$subtitle:r}}=this.art;return this.textTrack?(a(t,ht.subtitle),t.url?(this.option=t,this.style(t.style),fetch(t.url).then(t=>t.arrayBuffer()).then(e=>{const r=new TextDecoder(t.encoding).decode(e);switch(t.type||N(t.url)){case"srt":{const e=Q(r);return tt(t.onVttLoad(e))}case"ass":{const e=et(r);return tt(t.onVttLoad(e))}case"vtt":return tt(t.onVttLoad(r));default:return t.url}}).then(t=>(r.innerHTML="",this.url===t||(URL.revokeObjectURL(this.url),this.createTrack("metadata",t)),t)).catch(t=>{throw r.innerHTML="",e.show=t,t})):void 0):null}}class se{constructor(t){this.art=t;const{option:e,constructor:r}=t;e.container instanceof Element?this.$container=e.container:(this.$container=u(e.container),V(this.$container,`No container element found by ${e.container}`)),V(A(),"The current browser does not support flex layout");const o=this.$container.tagName.toLowerCase();V("div"===o,`Unsupported container element type, only support 'div' but got '${o}'`),V(r.instances.every(t=>t.template.$container!==this.$container),"Cannot mount multiple instances on the same dom element"),this.query=this.query.bind(this),function(t,e,r){const o=yt.get(e);if(o&&o!==t)throw new Error("Cannot mount multiple instances on the same dom element");const a=bt(t);a.rollback=r,yt.set(e,t),a.releaseContainer=()=>{yt.get(e)===t&&yt.delete(e)}}(t,this.$container,function(t){const e=[];return function t(r){const o=Array.from(r.childNodes);e.push({node:r,children:o,attributes:1===r.nodeType?Array.from(r.attributes,t=>[t.name,t.value]):void 0,value:r.nodeValue}),o.forEach(t)}(t),()=>{for(const{node:t,children:r,attributes:o,value:a}of e){for(;t.firstChild;)t.removeChild(t.firstChild);for(const e of r)t.appendChild(e);if(o){const e=t;for(const t of Array.from(e.attributes))e.removeAttribute(t.name);for(const[t,r]of o)e.setAttribute(t,r)}else t.nodeValue=a}}}(this.$container)),this.$container.dataset.artId=t.id,this.init()}static get html(){return`\n
\n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
Player version:
\n
${n}
\n
\n
\n
Video url:
\n
\n
\n
\n
Video volume:
\n
\n
\n
\n
Video time:
\n
\n
\n
\n
Video duration:
\n
\n
\n
\n
Video resolution:
\n
\n x \n
\n
\n
\n
[x]
\n
\n
\n
\n `}query(t){return u(t,this.$container)}init(){const{option:t}=this.art;if(t.useSSR||(this.$container.innerHTML=se.html),this.$player=this.query(".art-video-player"),this.$video=this.query(".art-video"),this.$track=this.query("track"),this.$poster=this.query(".art-poster"),this.$subtitle=this.query(".art-subtitle"),this.$danmuku=this.query(".art-danmuku"),this.$bottom=this.query(".art-bottom"),this.$progress=this.query(".art-progress"),this.$controls=this.query(".art-controls"),this.$controlsLeft=this.query(".art-controls-left"),this.$controlsCenter=this.query(".art-controls-center"),this.$controlsRight=this.query(".art-controls-right"),this.$layer=this.query(".art-layers"),this.$loading=this.query(".art-loading"),this.$notice=this.query(".art-notice"),this.$noticeInner=this.query(".art-notice-inner"),this.$mask=this.query(".art-mask"),this.$state=this.query(".art-state"),this.$setting=this.query(".art-settings"),this.$info=this.query(".art-info"),this.$infoPanel=this.query(".art-info-panel"),this.$infoClose=this.query(".art-info-close"),this.$contextmenu=this.query(".art-contextmenus"),t.proxy){const e=t.proxy.call(this.art,this.art);V(e instanceof HTMLVideoElement||e instanceof HTMLCanvasElement,"Function 'option.proxy' needs to return 'HTMLVideoElement' or 'HTMLCanvasElement'"),z(e,this.$video),e.className="art-video",this.$video=e}t.backdrop&&f(this.$player,"art-backdrop"),p&&f(this.$player,"art-mobile")}destroy(t){t?this.$container.innerHTML="":f(this.$player,"art-destroy")}}const le=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);class ce{on(t,e,r){const o=this.e||(this.e={});let a=le(o,t)?o[t]:void 0;return a||(a=[],Object.defineProperty(o,t,{value:a,enumerable:!0,configurable:!0,writable:!0})),a.push({fn:e,ctx:r}),this}once(t,e,r){const o=this,a=e;let n=!1;function i(...e){n||(n=!0,o.off(t,i),a.apply(r,e))}return i._=e,this.on(t,i,r)}emit(t,...e){const r=this.e||(this.e={}),o=(le(r,t)&&r[t]||[]).slice();for(const a of o)a.fn.apply(a.ctx,e);return this}off(t,e){const r=this.e||(this.e={}),o=le(r,t)?r[t]:void 0,a=[];if(o&&e)for(let n=0,i=o.length;ne.call(this,this)),he.DEBUG){const t=t=>console.log(`[ART.${this.id}] -> ${t}`);t(`Version@${he.version}`);for(let e=0;et(`Event@${e.type}`))}(function(t){const e=bt(t);return e.rollback=void 0,!e.scope.closed})(this)&&pe.push(this)}catch(o){try{kt(this,pe,!0,he.REMOVE_SRC_WHEN_DESTROY,!0)}catch(n){console.warn("Failed to clean up ArtPlayer initialization:",n)}throw o}}static get instances(){return pe}static get version(){return n}static get config(){return i}static get utils(){return ot}static get scheme(){return ht}static get Emitter(){return ce}static get validator(){return a}static get kindOf(){return a.kindOf}static get html(){return se.html}static get option(){return{id:"",container:"#artplayer",url:"",poster:"",type:"",theme:"#f00",volume:.7,isLive:!1,muted:!1,autoplay:!1,autoSize:!1,autoMini:!1,loop:!1,flip:!1,playbackRate:!1,aspectRatio:!1,screenshot:!1,setting:!1,hotkey:!0,pip:!1,mutex:!0,backdrop:!0,fullscreen:!1,fullscreenWeb:!1,subtitleOffset:!1,miniProgressBar:!1,useSSR:!1,playsInline:!0,lock:!1,gesture:!0,fastForward:!1,autoPlayback:!1,autoOrientation:!1,airplay:!1,proxy:void 0,layers:[],contextmenu:[],controls:[],settings:[],quality:[],highlight:[],plugins:[],thumbnails:{url:"",number:60,column:10,width:0,height:0,scale:1},subtitle:{url:"",type:"",style:{},name:"",escape:!0,encoding:"utf-8",onVttLoad:t=>t},moreVideoAttr:{controls:!1,preload:l?"auto":"metadata"},i18n:{},icons:{},cssVar:{},customType:{},lang:navigator?.language.toLowerCase()}}get proxy(){return this.events.proxy}get query(){return this.template.query}get video(){return this.template.$video}reset(){this.video.removeAttribute("src"),this.video.load()}destroy(t=!0){kt(this,pe,t,he.REMOVE_SRC_WHEN_DESTROY)}}return he.STYLE=ne,he.DEBUG=!1,he.CONTEXTMENU=!0,he.NOTICE_TIME=2e3,he.SETTING_WIDTH=250,he.SETTING_ITEM_WIDTH=200,he.SETTING_ITEM_HEIGHT=35,he.RESIZE_TIME=200,he.SCROLL_TIME=200,he.SCROLL_GAP=50,he.AUTO_PLAYBACK_MAX=10,he.AUTO_PLAYBACK_MIN=5,he.AUTO_PLAYBACK_TIMEOUT=3e3,he.RECONNECT_TIME_MAX=5,he.RECONNECT_SLEEP_TIME=1e3,he.CONTROL_HIDE_TIME=3e3,he.DBCLICK_TIME=300,he.DBCLICK_FULLSCREEN=!0,he.MOBILE_DBCLICK_PLAY=!0,he.MOBILE_CLICK_PLAY=!1,he.AUTO_ORIENTATION_TIME=200,he.INFO_LOOP_TIME=1e3,he.FAST_FORWARD_VALUE=3,he.FAST_FORWARD_TIME=1e3,he.TOUCH_MOVE_RATIO=.5,he.VOLUME_STEP=.1,he.SEEK_STEP=5,he.PLAYBACK_RATE=[.5,.75,1,1.25,1.5,2],he.ASPECT_RATIO=["default","4:3","16:9"],he.FLIP=["normal","horizontal","vertical"],he.FULLSCREEN_WEB_IN_BODY=!0,he.LOG_VERSION=!0,he.USE_RAF=!1,he.REMOVE_SRC_WHEN_DESTROY=!0,h&&(window.Artplayer=he,M("artplayer-style",ne),setTimeout(()=>{he.LOG_VERSION&&console.log(`%c ArtPlayer %c ${he.version} %c https://artplayer.org`,"color: #fff; background: #5f5f5f","color: #fff; background: #4bc729","")},100)),he}); +!function(t,e){"object"===typeof exports&&"undefined"!==typeof module?module.exports=e():"function"==typeof define&&define.amd?(t.Artplayer=e(),define(function(){return t.Artplayer})):(t="undefined"!==typeof globalThis?globalThis:t||self).Artplayer=e()}(this,function(){"use strict";function t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var e,r={exports:{}};var o=(e||(e=1,r.exports=function(){function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}var e=Object.prototype.toString,r=function(r){if(void 0===r)return"undefined";if(null===r)return"null";var a=t(r);if("boolean"===a)return"boolean";if("string"===a)return"string";if("number"===a)return"number";if("symbol"===a)return"symbol";if("function"===a)return"GeneratorFunction"===o(r)?"generatorfunction":"function";if(function(t){return Array.isArray?Array.isArray(t):t instanceof Array}(r))return"array";if(function(t){return!(!t.constructor||"function"!=typeof t.constructor.isBuffer)&&t.constructor.isBuffer(t)}(r))return"buffer";if(function(t){try{if("number"==typeof t.length&&"function"==typeof t.callee)return!0}catch(e){if(-1!==e.message.indexOf("callee"))return!0}return!1}(r))return"arguments";if(function(t){return t instanceof Date||"function"==typeof t.toDateString&&"function"==typeof t.getDate&&"function"==typeof t.setDate}(r))return"date";if(function(t){return t instanceof Error||"string"==typeof t.message&&t.constructor&&"number"==typeof t.constructor.stackTraceLimit}(r))return"error";if(function(t){return t instanceof RegExp||"string"==typeof t.flags&&"boolean"==typeof t.ignoreCase&&"boolean"==typeof t.multiline&&"boolean"==typeof t.global}(r))return"regexp";switch(o(r)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(function(t){return"function"==typeof t.throw&&"function"==typeof t.return&&"function"==typeof t.next}(r))return"generator";switch(a=e.call(r)){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return a.slice(8,-1).toLowerCase().replace(/\s/g,"")};function o(t){return t.constructor?t.constructor.name:null}function a(t,e){var o=2=1,p=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(s)||d,h="undefined"!==typeof window&&"undefined"!==typeof document;function u(t,e=document){return e.querySelector(t)}function m(t,e=document){return Array.from(e.querySelectorAll(t))}function f(t,e){return t.classList.add(e)}function g(t,e){return t.classList.remove(e)}function v(t,e){return t.classList.contains(e)}function y(t,e){return e instanceof Element?t.appendChild(e):t.insertAdjacentHTML("beforeend",String(e)),t.lastElementChild||t.lastChild}function b(t){return t.parentNode.removeChild(t)}function w(t,e,r){return t.style[e]=r,t}function x(t,e){for(const r in e)w(t,r,e[r]);return t}function k(t){return Array.from(t.parentElement.children).filter(e=>e!==t)}function $(t,e){k(t).forEach(t=>g(t,e)),f(t,e)}function E(t,e,r="top"){p||(t.setAttribute("aria-label",e),f(t,"hint--rounded"),f(t,`hint--${r}`))}function T(t,e=0){const r=t.getBoundingClientRect(),o=window.innerHeight||document.documentElement.clientHeight,a=window.innerWidth||document.documentElement.clientWidth,n=r.top-e<=o&&r.top+r.height+e>=0,i=r.left-e<=a+e&&r.left+r.width+e>=0;return n&&i}function C(t,e){return R(t).includes(e)}function z(t,e){return e.parentNode.replaceChild(t,e),t}function L(t){return document.createElement(t)}function S(t="",e=""){const r=L("i");return f(r,"art-icon"),f(r,`art-icon-${t}`),y(r,e),r}function M(t,e){let r=document.getElementById(t);r||(r=document.createElement("style"),r.id=t,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{document.head.appendChild(r)}):(document.head||document.documentElement).appendChild(r)),r.textContent=e}function A(){const t=document.createElement("div");return t.style.display="flex","flex"===t.style.display}function P(t){return t.getBoundingClientRect()}function I(t,e){return new Promise((r,o)=>{const a=new Image;a.onload=function(){if(e&&1!==e){const n=document.createElement("canvas"),i=n.getContext("2d");n.width=a.width*e,n.height=a.height*e,i.drawImage(a,0,0,n.width,n.height),n.toBlob(e=>{const a=URL.createObjectURL(e),n=new Image;n.onload=function(){r(n)},n.onerror=function(){URL.revokeObjectURL(a),o(new Error(`Image load failed: ${t}`))},n.src=a})}else r(a)},a.onerror=function(){o(new Error(`Image load failed: ${t}`))},a.src=t})}function R(t){if(t.composedPath)return t.composedPath();const e=[];let r=t.target;for(;r;)e.push(r),r=r.parentNode;return e.includes(window)||void 0===window||e.push(window),e}function O(){const t=document.createElement("div");t.style.cssText="position:fixed;top:env(safe-area-inset-top,0px);right:env(safe-area-inset-right,0px);bottom:env(safe-area-inset-bottom,0px);left:env(safe-area-inset-left,0px);pointer-events:none;visibility:hidden;",document.body.appendChild(t);const e=getComputedStyle(t),r={top:Number.parseFloat(e.top)||0,right:Number.parseFloat(e.right)||0,bottom:Number.parseFloat(e.bottom)||0,left:Number.parseFloat(e.left)||0};return t.remove(),r}class _ extends Error{constructor(t,e){super(t),"captureStackTrace"in Error&&"function"===typeof Error.captureStackTrace&&Error.captureStackTrace(this,e||this.constructor),this.name="ArtPlayerError"}}function V(t,e){if(!t)throw new _(e);return t}function Y(t){const e=t;return e&&"function"===typeof e.catch?e.catch(()=>{}):t}function N(t){const e=t.search(/[?#]/),r=(e<0?t:t.slice(0,e)).trim().toLowerCase();return r.slice(r.lastIndexOf(".")+1)}function D(t,e){const r=document.createElement("a");r.style.display="none",r.href=t,r.download=e,document.body.appendChild(r);try{r.click()}finally{r.remove()}}function F(t,e,r){return Math.max(Math.min(t,Math.max(e,r)),Math.min(e,r))}function H(t){return t.charAt(0).toUpperCase()+t.slice(1)}function B(t){if(!t)return"00:00";const e=Math.floor(t/3600),r=Math.floor((t-3600*e)/60),o=Math.floor(t-3600*e-60*r);return(e>0?[e,r,o]:[r,o]).map(t=>t<10?`0${t}`:String(t)).join(":")}const W={"&":"&","<":"<",">":">","'":"'",'"':"""},j={"&":"&","<":"<",">":">","'":"'",""":'"'},U=/(&|<|>|'|")/g;function q(t){return t.replace(/[&<>'"]/g,t=>W[t]||t)}const X=Object.defineProperty,{hasOwnProperty:G}=Object.prototype;function K(t,e){return G.call(t,e)}function Z(t,e){return Object.getOwnPropertyDescriptor(t,e)}function J(...t){const e=t=>!!t&&"object"===typeof t&&!Array.isArray(t);return t.reduce((t,r)=>(Object.keys(r).forEach(o=>{const a=t[o],n=r[o];let i;i=Array.isArray(a)&&Array.isArray(n)?a.concat(...n):e(a)&&e(n)?J(a,n):n,X(t,o,{value:i,enumerable:!0,configurable:!0,writable:!0})}),t),{})}function Q(t){return"WEBVTT \r\n\r\n".concat((e=t,e.replace(/(\d\d:\d\d:\d\d)[,.](\d+)/g,(t,e,r)=>{let o=r.slice(0,3);return 1===r.length&&(o=`${r}00`),2===r.length&&(o=`${r}0`),`${e},${o}`})).replace(/\{\\([ibu])\}/g,"").replace(/\{\\([ibu])1\}/g,"<$1>").replace(/\{([ibu])\}/g,"<$1>").replace(/\{\/([ibu])\}/g,"").replace(/(\d\d:\d\d:\d\d),(\d\d\d)/g,"$1.$2").replace(/\{[\s\S]*?\}/g,"").concat("\r\n\r\n"));var e}function tt(t){return URL.createObjectURL(new Blob([t],{type:"text/vtt"}))}function et(t){const e=new RegExp("Dialogue:\\s\\d,(\\d+:\\d\\d:\\d\\d.\\d\\d),(\\d+:\\d\\d:\\d\\d.\\d\\d),([^,]*),([^,]*),(?:[^,]*,){4}([\\s\\S]*)$","i");function r(t=""){return t.split(/[:.]/).map((t,e,r)=>{if(e===r.length-1){if(1===t.length)return`.${t}00`;if(2===t.length)return`.${t}0`}else if(1===t.length)return(0===e?"0":":0")+t;return 0===e?t:e===r.length-1?`.${t}`:`:${t}`}).join("")}return`WEBVTT\n\n${t.split(/\r?\n/).map(t=>{const o=t.match(e);if(!o)return null;const[,a="",n="",,,i=""]=o;return{start:r(a.trim()),end:r(n.trim()),text:i.replace(/\{[\s\S]*?\}/g,"").replace(/(\\N)/g,"\n").trim().split(/\r?\n/).map(t=>t.trim()).join("\n")}}).filter(t=>t).map((t,e)=>t?`${e+1}\n${t.start} --\x3e ${t.end}\n${t.text}`:"").filter(t=>t.trim()).join("\n\n")}`}function rt(t,e){let r=!1;return function(...o){r||(t.apply(this,o),r=!0,setTimeout(()=>{r=!1},e))}}const ot=Object.freeze(Object.defineProperty({__proto__:null,ArtPlayerError:_,addClass:f,append:y,assToVtt:et,capitalize:H,clamp:F,createElement:L,debounce:function(t,e){let r;return function(...o){clearTimeout(r),r=setTimeout(()=>(r=void 0,t.apply(this,o)),e)}},def:X,download:D,errorHandle:V,escape:q,get:Z,getComposedPath:R,getExt:N,getIcon:S,getRect:P,getSafeAreaInsets:O,getStyle:function(t,e,r=!0){const o=window.getComputedStyle(t,null).getPropertyValue(e);return r?Number.parseFloat(o):o},has:K,hasClass:v,includeFromEvent:C,inverseClass:$,isBrowser:h,isIOS:c,isIOS13:d,isInViewport:T,isMobile:p,isSafari:l,loadImg:I,mergeDeep:J,query:u,queryAll:m,remove:b,removeClass:g,replaceElement:z,secondToTime:B,setStyle:w,setStyleText:M,setStyles:x,siblings:k,silencePromise:Y,sleep:function(t=0){return new Promise(e=>setTimeout(e,t))},srtToVtt:Q,supportsFlex:A,throttle:rt,tooltip:E,unescape:function(t){return t.replace(U,t=>j[t]||t)},userAgent:s,vttToBlob:tt},Symbol.toStringTag,{value:"Module"})),at="array",nt="boolean",it="string",st="number",lt="object",ct="function";function dt(t,e,r){return V(e===it||e===st||t instanceof Element,`${r.join(".")} require '${it}' or 'Element' type`)}const pt={html:dt,disable:`?${nt}`,name:`?${it}`,index:`?${st}`,style:`?${lt}`,click:`?${ct}`,mounted:`?${ct}`,tooltip:`?${it}|${st}`,width:`?${st}`,selector:`?${at}`,onSelect:`?${ct}`,switch:`?${nt}`,onSwitch:`?${ct}`,range:`?${at}`,onRange:`?${ct}`,onChange:`?${ct}`},ht={id:it,container:dt,url:it,poster:it,type:it,theme:it,lang:it,volume:st,isLive:nt,muted:nt,autoplay:nt,autoSize:nt,autoMini:nt,loop:nt,flip:nt,playbackRate:nt,aspectRatio:nt,screenshot:nt,setting:nt,hotkey:nt,pip:nt,mutex:nt,backdrop:nt,fullscreen:nt,fullscreenWeb:nt,subtitleOffset:nt,miniProgressBar:nt,useSSR:nt,playsInline:nt,lock:nt,gesture:nt,fastForward:nt,autoPlayback:nt,autoOrientation:nt,airplay:nt,proxy:`?${ct}`,plugins:[ct],layers:[pt],contextmenu:[pt],settings:[pt],controls:[{...pt,position:(t,e,r)=>{const o=["top","left","right"];return V("string"===typeof t&&o.includes(t),`${r.join(".")} only accept ${o.toString()} as parameters`)}}],quality:[{default:`?${nt}`,html:it,url:it}],highlight:[{time:st,text:it}],thumbnails:{url:it,number:st,column:st,width:st,height:st,scale:st},subtitle:{url:it,name:it,type:it,style:lt,escape:nt,encoding:it,onVttLoad:ct},moreVideoAttr:lt,i18n:lt,icons:lt,cssVar:lt,customType:lt};class ut{constructor(t){this.id=0,this.art=t,this.cache=new Map,this.add=this.add.bind(this),this.remove=this.remove.bind(this),this.update=this.update.bind(this)}get show(){return v(this.art.template.$player,`art-${this.name}-show`)}set show(t){const{$player:e}=this.art.template,r=`art-${this.name}-show`;t?f(e,r):g(e,r),this.art.emit(this.name,t)}toggle(){this.show=!this.show}add(t){const e="function"===typeof t?t(this.art):t;if(e.html=e.html||"",a(e,pt),!this.$parent||!this.name||e.disable)return;const r=e.name||`${this.name}${this.id}`;V(!this.cache.has(r),`Can't add an existing [${r}] to the [${this.name}]`),this.id+=1;const o=L("div");f(o,`art-${this.name}`),f(o,`art-${this.name}-${r}`);const n=Array.from(this.$parent.children);o.dataset.index=e.index||this.id;const i=n.find(t=>Number(t.dataset.index)>=Number(o.dataset.index));i?i.insertAdjacentElement("beforebegin",o):y(this.$parent,o),e.html&&y(o,e.html),e.style&&x(o,e.style),e.tooltip&&E(o,e.tooltip);const s=[];if(e.click){const t=this.art.events.proxy(o,"click",t=>{t.preventDefault(),e.click.call(this.art,this,t)});s.push(t)}return e.selector&&["left","right"].includes(e.position)&&this.selector(e,o,s),this[r]=o,this.cache.set(r,{$ref:o,events:s,option:e}),e.mounted&&e.mounted.call(this.art,o),o}remove(t){V(this.cache.has(t),`Can't find [${t}] from the [${this.name}]`);const e=this.cache.get(t);e.option.beforeUnmount&&e.option.beforeUnmount.call(this.art,e.$ref);for(const r of e.events)this.art.events.remove(r);this.cache.delete(t),delete this[t],b(e.$ref)}update(t){if(this.cache.has(t.name)){const e=this.cache.get(t.name);t=Object.assign(e.option,t),this.remove(t.name)}return this.add(t)}}class mt extends ut{constructor(t){super(t),this.name="contextmenu",this.$parent=t.template.$contextmenu,p||this.init()}init(){const{option:t,proxy:e,template:{$player:r,$contextmenu:o}}=this.art;t.playbackRate&&this.add(function(t){return e=>{const{i18n:r,constructor:{PLAYBACK_RATE:o}}=e,a=o.map(t=>`${1===t?r.get("Normal"):t.toFixed(1)}`).join("");return{...t,html:`${r.get("Play Speed")}: ${a}`,click:(t,r)=>{const{value:o}=r.target.dataset;o&&(e.playbackRate=Number(o),t.show=!1)},mounted:t=>{const r=u('[data-value="1"]',t);r&&$(r,"art-current"),e.on("video:ratechange",()=>{const r=m("span",t).find(t=>Number(t.dataset.value)===e.playbackRate);r&&$(r,"art-current")})}}}}({name:"playbackRate",index:10})),t.aspectRatio&&this.add(function(t){return e=>{const{i18n:r,constructor:{ASPECT_RATIO:o}}=e,a=o.map(t=>`${"default"===t?r.get("Default"):t}`).join("");return{...t,html:`${r.get("Aspect Ratio")}: ${a}`,click:(t,r)=>{const{value:o}=r.target.dataset;o&&(e.aspectRatio=o,t.show=!1)},mounted:t=>{const r=u('[data-value="default"]',t);r&&$(r,"art-current"),e.on("aspectRatio",e=>{const r=m("span",t).find(t=>t.dataset.value===e);r&&$(r,"art-current")})}}}}({name:"aspectRatio",index:20})),t.flip&&this.add(function(t){return e=>{const{i18n:r,constructor:{FLIP:o}}=e,a=o.map(t=>`${r.get(H(t))}`).join("");return{...t,html:`${r.get("Video Flip")}: ${a}`,click:(t,r)=>{const{value:o}=r.target.dataset;o&&(e.flip=o.toLowerCase(),t.show=!1)},mounted:t=>{const r=u('[data-value="normal"]',t);r&&$(r,"art-current"),e.on("flip",e=>{const r=m("span",t).find(t=>t.dataset.value===e);r&&$(r,"art-current")})}}}}({name:"flip",index:30})),this.add(function(t){return e=>({...t,html:e.i18n.get("Video Info"),click:t=>{e.info.show=!0,t.show=!1}})}({name:"info",index:40})),this.add(function(t){return{...t,html:`ArtPlayer ${n}`}}({name:"version",index:50})),this.add(function(t){return e=>({...t,html:e.i18n.get("Close"),click:t=>{t.show=!1}})}({name:"close",index:60}));for(let a=0;a{if(!this.art.constructor.CONTEXTMENU)return;t.preventDefault(),this.show=!0;const e=t.clientX,a=t.clientY,{height:n,width:i,left:s,top:l}=P(r),{height:c,width:d}=P(o);let p=e-s,h=a-l;e+d>s+i&&(p=i-d),a+c>l+n&&(h=n-c),x(o,{top:`${h}px`,left:`${p}px`})}),e(r,"click",t=>{C(t,o)||(this.show=!1)}),this.art.on("blur",()=>{this.show=!1})}}class ft extends Error{constructor(t){super("Failed to release ArtPlayer resources"),this.errors=t,this.name="ResourceCleanupError"}}class gt{constructor(){this.cleanups=new Set,this.disposed=!1}get closed(){return this.disposed}add(t){let e=!0;const r=()=>{e&&(e=!1,this.cleanups.delete(r),t())};return this.closed?r():this.cleanups.add(r),r}child(){const t=new gt,e=this.add(()=>{t.dispose()});return t.add(()=>{e()}),t}dispose(){if(this.closed)return;this.disposed=!0;const t=[];for(const r of Array.from(this.cleanups).reverse())try{r()}catch(e){e instanceof ft?t.push(...e.errors):t.push(e)}if(t.length)throw new ft(t)}}const vt=new WeakMap,yt=new WeakMap;function bt(t){const e=vt.get(t);if(!e)throw new Error("ArtPlayer lifecycle has not been initialized");return e}function wt(t){return bt(t).scope}function xt(t){const e=bt(t);return e.destroying||e.scope.closed}function kt(t,e,r,o,a=!1){const n=bt(t);if(n.destroying||n.scope.closed)return;n.destroying=!0;const i=[],s=t=>{try{t()}catch(e){i.push(...e instanceof ft?e.errors:[e])}};o&&t.template?.$video&&s(()=>t.reset()),s(()=>n.scope.dispose()),s(()=>t.template?.destroy(r));const l=e.indexOf(t);-1!==l&&e.splice(l,1),t.isDestroy=!0,a||(n.releaseContainer?.(),n.releaseContainer=void 0),s(()=>t.emit("destroy")),a&&n.rollback&&s(n.rollback),n.rollback=void 0,n.releaseContainer?.(),n.releaseContainer=void 0;for(const c of i.slice(1))console.warn("Additional ArtPlayer cleanup failure:",c);if(i.length)throw i[0]}function $t(t,e,r){if(t.closed)return()=>{};let o=!0,a=()=>{};const n=setTimeout(()=>{o&&(a(),t.closed||e())},r);return a=t.add(()=>{o=!1,clearTimeout(n)}),a}function Et(t,e=0){return t.closed?Promise.resolve(!1):new Promise(r=>{let o=!1,a=()=>{};const n=setTimeout(()=>{o=!0,a(),r(!0)},e);a=t.add(()=>{clearTimeout(n),o||r(!1)})})}function Tt(t,e){const{$progress:r}=t.template,{left:o}=P(r),a=F((p?e.touches[0].clientX:e.clientX)-o,0,r.clientWidth),n=a/r.clientWidth*t.duration;return{second:n,time:B(n),width:a,percentage:F(a/r.clientWidth,0,1)}}function Ct(t,e){if(t.isRotate){const r=(e.touches[0].clientY-t.top)/t.height,o=r*t.duration;t.emit("setBar","played",r,e),t.seek=o}else{const{second:r,percentage:o}=Tt(t,e);t.emit("setBar","played",o,e),t.seek=r}}function zt(t){return e=>{const{icons:r,option:o,proxy:a}=e,{$player:n,$progress:i}=e.template;return{...t,html:'\n
\n
\n
\n
\n
\n
\n
00:00
\n
\n ',mounted:t=>{let s=null,l=!1;const c=u(".art-progress-hover",t),d=u(".art-progress-loaded",t),h=u(".art-progress-played",t),m=u(".art-progress-highlight",t),v=u(".art-progress-indicator",t),b=u(".art-progress-tip",t);function x(r,o){const{width:a,time:n}=o||Tt(e,r);b.textContent=n||"00:00";const i=b.clientWidth;a<=i/2?w(b,"left",0):a>t.clientWidth-i/2?w(b,"left",t.clientWidth-i+"px"):w(b,"left",a-i/2+"px")}r.indicator?y(v,r.indicator):w(v,"backgroundColor","var(--art-theme)"),e.on("setBar",function(r,o,a){const i="played"===r&&a&&p;if("loaded"===r&&w(d,"width",100*o+"%"),"hover"===r&&(w(c,"width",100*o+"%"),C(a,m)?function(r){const{width:o}=Tt(e,r),{text:a}=r.target.dataset;b.textContent=a;const n=b.clientWidth;o<=n/2?w(b,"left",0):o>t.clientWidth-n/2?w(b,"left",t.clientWidth-n+"px"):w(b,"left",o-n/2+"px")}(a):x(a),0===o?g(n,"art-progress-hover"):f(n,"art-progress-hover")),"played"===r&&(w(h,"width",100*o+"%"),w(v,"left",100*o+"%")),i){f(n,"art-progress-hover");x(a,{width:t.clientWidth*o,time:B(o*e.duration)}),clearTimeout(s),s=setTimeout(()=>{g(n,"art-progress-hover")},500)}}),e.on("video:loadedmetadata",function(){m.textContent="";for(let t=0;t`;y(m,n)}}),e.constructor.USE_RAF?e.on("raf",()=>{e.emit("setBar","played",e.played),e.emit("setBar","loaded",e.loaded)}):(e.on("video:timeupdate",()=>{e.emit("setBar","played",e.played)}),e.on("video:progress",()=>{e.emit("setBar","loaded",e.loaded)}),e.on("video:ended",()=>{e.emit("setBar","played",1)})),e.emit("setBar","loaded",e.loaded||0),p||(a(i,"click",t=>{t.target!==v&&Ct(e,t)}),a(i,"mousemove",t=>{const{percentage:r}=Tt(e,t);e.emit("setBar","hover",r,t)}),a(i,"mouseleave",t=>{e.emit("setBar","hover",0,t)}),a(i,"mousedown",t=>{l=0===t.button}),e.on("document:mousemove",t=>{if(l){const{second:r,percentage:o}=Tt(e,t);e.emit("setBar","played",o,t),e.seek=r}}),e.on("document:mouseup",()=>{l&&(l=!1)}))}}}}class Lt extends ut{constructor(t){super(t),this.isHover=!1,this.name="control",this.timer=Date.now();const{constructor:e}=t,{$player:r,$bottom:o}=this.art.template;t.on("mousemove",()=>{p||(this.show=!0)}),t.on("click",()=>{p?this.toggle():this.show=!0}),t.on("document:mousemove",t=>{this.isHover=C(t,o)}),t.on("video:timeupdate",()=>{!t.setting.show&&!this.isHover&&!t.isInput&&t.playing&&this.show&&Date.now()-this.timer>=e.CONTROL_HIDE_TIME&&(this.show=!1)}),t.on("control",t=>{t?(g(r,"art-hide-cursor"),f(r,"art-hover"),this.timer=Date.now()):(f(r,"art-hide-cursor"),g(r,"art-hover"))}),this.init()}init(){const{option:t}=this.art;t.isLive||this.add(zt({name:"progress",position:"top",index:10})),this.add({name:"thumbnails",position:"top",index:20}),this.add(function(t){return e=>({...t,mounted:t=>{const{proxy:r,icons:o,i18n:a}=e,n=y(t,o.play),i=y(t,o.pause);function s(){w(n,"display","flex"),w(i,"display","none")}function l(){w(n,"display","none"),w(i,"display","flex")}E(n,a.get("Play")),E(i,a.get("Pause")),r(n,"click",()=>{Y(e.play())}),r(i,"click",()=>{e.pause()}),e.playing?l():s(),e.on("video:playing",()=>{l()}),e.on("video:pause",()=>{s()})}})}({name:"playAndPause",position:"left",index:10})),this.add(function(t){return e=>({...t,mounted:t=>{const{proxy:r,icons:o}=e,a=y(t,o.volume),n=y(t,o.volumeClose),i=y(t,'
'),s=y(i,'
'),l=y(s,'
'),c=y(s,'
'),d=y(c,'
'),h=y(d,'
'),u=y(c,'
');function m(t){const{top:e,height:r}=P(c);return 1-(t.clientY-e)/r}function f(){if(e.muted||0===e.volume)w(a,"display","none"),w(n,"display","flex"),w(u,"top","100%"),w(h,"top","100%"),l.textContent=0;else{const t=100*e.volume;w(a,"display","flex"),w(n,"display","none"),w(u,"top",100-t+"%"),w(h,"top",100-t+"%"),l.textContent=Math.floor(t)}}if(f(),e.on("video:volumechange",f),r(a,"click",()=>{e.muted=!0}),r(n,"click",()=>{e.muted=!1}),p)w(i,"display","none");else{let t=!1;r(c,"mousedown",r=>{t=0===r.button,e.volume=m(r)}),e.on("document:mousemove",r=>{t&&(e.muted=!1,e.volume=m(r))}),e.on("document:mouseup",()=>{t&&(t=!1)})}}})}({name:"volume",position:"left",index:20})),t.isLive||this.add(function(t){return e=>({...t,style:p?{fontSize:"12px",padding:"0 5px"}:{cursor:"auto",padding:"0 10px"},mounted:t=>{function r(){const r=`${B(e.currentTime)} / ${B(e.duration)}`;r!==t.textContent&&(t.textContent=r)}r();const o=["video:loadedmetadata","video:timeupdate","video:progress"];for(let a=0;a{e&&!wt(this.art).closed&&(this.art.quality=t.quality)}),t.screenshot&&!p&&this.add(function(t){return e=>({...t,tooltip:e.i18n.get("Screenshot"),mounted:t=>{const{proxy:r,icons:o}=e;y(t,o.screenshot),r(t,"click",()=>{e.screenshot()})}})}({name:"screenshot",position:"right",index:20})),t.setting&&this.add(function(t){return e=>({...t,tooltip:e.i18n.get("Show Setting"),mounted:t=>{const{proxy:r,icons:o,i18n:a}=e;y(t,o.setting),r(t,"click",()=>{e.setting.toggle(),e.setting.resize()}),e.on("setting",e=>{E(t,a.get(e?"Hide Setting":"Show Setting"))})}})}({name:"setting",position:"right",index:30})),t.pip&&this.add(function(t){return e=>({...t,tooltip:e.i18n.get("PIP Mode"),mounted:t=>{const{proxy:r,icons:o,i18n:a}=e;y(t,o.pip),r(t,"click",()=>{e.pip=!e.pip}),e.on("pip",e=>{E(t,a.get(e?"Exit PIP Mode":"PIP Mode"))})}})}({name:"pip",position:"right",index:40})),t.airplay&&window.WebKitPlaybackTargetAvailabilityEvent&&this.add(function(t){return e=>({...t,tooltip:e.i18n.get("AirPlay"),mounted:t=>{const{proxy:r,icons:o}=e;y(t,o.airplay),r(t,"click",()=>e.airplay())}})}({name:"airplay",position:"right",index:50})),t.fullscreenWeb&&this.add(function(t){return e=>({...t,tooltip:e.i18n.get("Web Fullscreen"),mounted:t=>{const{proxy:r,icons:o,i18n:a}=e,n=y(t,o.fullscreenWebOn),i=y(t,o.fullscreenWebOff);w(i,"display","none"),r(t,"click",()=>{e.fullscreenWeb=!e.fullscreenWeb}),e.on("fullscreenWeb",e=>{e?(E(t,a.get("Exit Web Fullscreen")),w(n,"display","none"),w(i,"display","inline-flex")):(E(t,a.get("Web Fullscreen")),w(n,"display","inline-flex"),w(i,"display","none"))})}})}({name:"fullscreenWeb",position:"right",index:60})),t.fullscreen&&this.add(function(t){return e=>({...t,tooltip:e.i18n.get("Fullscreen"),mounted:t=>{const{proxy:r,icons:o,i18n:a}=e,n=y(t,o.fullscreenOn),i=y(t,o.fullscreenOff);w(i,"display","none"),r(t,"click",()=>{e.fullscreen=!e.fullscreen}),e.on("fullscreen",e=>{e?(E(t,a.get("Exit Fullscreen")),w(n,"display","none"),w(i,"display","inline-flex")):(E(t,a.get("Fullscreen")),w(n,"display","inline-flex"),w(i,"display","none"))})}})}({name:"fullscreen",position:"right",index:70}));for(let e=0;et.selector}),X(e,"$control_item",{get:()=>r}),X(e,"$control_value",{get:()=>a})}const i=o(n,"click",async e=>{const r=R(e),o=t.selector.find(t=>t.$control_item===r.find(e=>t.$control_item===e));this.check(o),t.onSelect&&(a.innerHTML=await t.onSelect.call(this.art,o,o.$control_item,e))});r.push(i)}}function St(t,e,r,o){const a=e-o,n=r-t;let i=0;if(Math.abs(n)<2&&Math.abs(a)<2)return i;const s=function(t,e){return 180*Math.atan2(e,t)/Math.PI}(n,a);return s>=-45&&s<45?i=4:s>=45&&s<135?i=1:s>=-135&&s<-45?i=2:(s>=135&&s<=180||s>=-180&&s<-135)&&(i=3),i}function Mt(t){if(t.constructor.USE_RAF){const e=wt(t);let r=()=>{};!function o(){t.playing&&t.emit("raf"),t.isDestroy||(r=function(t,e){if(t.closed)return()=>{};let r=!0,o=()=>{};const a=requestAnimationFrame(a=>{r&&(o(),t.closed||e(a))});return o=t.add(()=>{r=!1,cancelAnimationFrame(a)}),o}(e,o))}(),t.on("destroy",()=>{r()})}}const At=new WeakMap;class Pt{constructor(t){this.destroyEvents=new Set;const e=wt(t);At.set(this,e),e.add(()=>this.destroy()),this.proxy=this.proxy.bind(this),this.hover=this.hover.bind(this),function(t,e){const{constructor:r,template:{$player:o,$video:a}}=t;function n(e){C(e,o)?(t.isInput="INPUT"===e.target.tagName,t.isFocus=!0,t.emit("focus",e)):(t.isInput=!1,t.isFocus=!1,t.emit("blur",e))}t.on("document:click",n),t.on("document:contextmenu",n);let i=[];e.proxy(a,"click",e=>{const o=Date.now();i.push(o);const{MOBILE_CLICK_PLAY:a,DBCLICK_TIME:n,MOBILE_DBCLICK_PLAY:s,DBCLICK_FULLSCREEN:l}=r,c=i.filter(t=>o-t<=n);switch(c.length){case 1:t.emit("click",e),p?!t.isLock&&a&&Y(t.toggle()):Y(t.toggle()),i=c;break;case 2:t.emit("dblclick",e),p?!t.isLock&&s&&Y(t.toggle()):l&&(t.fullscreen=!t.fullscreen),i=[];break;default:i=[]}})}(t,this),function(t,e){const{$player:r}=t.template;e.hover(r,e=>{f(r,"art-hover"),t.emit("hover",!0,e)},e=>{g(r,"art-hover"),t.emit("hover",!1,e)})}(t,this),function(t,e){const{$player:r}=t.template;e.proxy(r,"mousemove",e=>{t.emit("mousemove",e)})}(t,this),function(t,e){const{option:r,constructor:o}=t;t.on("resize",()=>{const{aspectRatio:e,notice:o}=t;"standard"===t.state&&r.autoSize&&t.autoSize(),t.aspectRatio=e,o.show=""});const a=wt(t);let n=()=>{};const i=()=>{n(),n=$t(a,()=>t.emit("resize"),o.RESIZE_TIME)};t.on("window:orientationchange",()=>i()),t.on("window:resize",()=>i()),screen&&screen.orientation&&screen.orientation.onchange&&e.proxy(screen.orientation,"change",()=>i())}(t,this),function(t,e){if(p&&!t.option.isLive){const{$video:r,$progress:o}=t.template;let a=null,n=!1,i=0,s=0,l=0;const c=e=>{if(1===e.touches.length&&!t.isLock){a===o&&Ct(t,e),n=!0;const{pageX:r,pageY:c}=e.touches[0];i=r,s=c,l=t.currentTime}},d=e=>{if(1===e.touches.length&&n&&t.duration){const{pageX:o,pageY:n}=e.touches[0],c=St(i,s,o,n),d=[3,4].includes(c),p=[1,2].includes(c);if(d&&!t.isRotate||p&&t.isRotate){const c=F((o-i)/t.width,-1,1),d=F((n-s)/t.height,-1,1),p=t.isRotate?d:c,h=a===r?t.constructor.TOUCH_MOVE_RATIO:1,u=F(l+t.duration*p*h,0,t.duration);t.seek=u,t.emit("setBar","played",F(u/t.duration,0,1),e),t.notice.show=`${B(u)} / ${B(t.duration)}`}}},p=()=>{n&&(i=0,s=0,l=0,n=!1,a=null)};t.option.gesture&&(e.proxy(r,"touchstart",t=>{a=r,c(t)}),e.proxy(r,"touchmove",d)),e.proxy(o,"touchstart",t=>{a=o,c(t)}),e.proxy(o,"touchmove",d),t.on("document:touchend",p)}}(t,this),function(t){const{option:e,constructor:r,template:{$container:o}}=t,a=rt(()=>{t.emit("view",T(o,r.SCROLL_GAP))},r.SCROLL_TIME);t.on("window:scroll",()=>a()),t.on("view",r=>{e.autoMini&&(t.mini=!r)})}(t),function(t,e){const r=["click","mouseup","keydown","touchend","touchmove","mousemove","pointerup","contextmenu","pointermove","visibilitychange","webkitfullscreenchange"],o=["resize","scroll","orientationchange"],a=[];function n(n={}){for(let t=0;t{const o=n.document||i.ownerDocument||document,s=e.proxy(o,r,e=>{t.emit(`document:${r}`,e)});a.push(s)}),o.forEach(r=>{const o=n.window||i.ownerDocument?.defaultView||window,s=e.proxy(o,r,e=>{t.emit(`window:${r}`,e)});a.push(s)})}n(),e.bindGlobalEvents=n}(t,this),Mt(t)}proxy(t,e,r,o={}){if(Array.isArray(e))return e.map(e=>this.proxy(t,e,r,o));if(At.get(this).closed)return()=>{};t.addEventListener(e,r,o);const a=()=>t.removeEventListener(e,r,o);return this.destroyEvents.add(a),a}hover(t,e,r){e&&this.proxy(t,"mouseenter",e),r&&this.proxy(t,"mouseleave",r)}remove(t){if(this.destroyEvents.has(t))try{t()}catch(e){console.warn("Failed to remove event listener:",e)}finally{this.destroyEvents.delete(t)}}destroy(){for(const e of this.destroyEvents)try{e()}catch(t){console.warn("Failed to destroy event listener:",t)}this.destroyEvents.clear()}}class It{constructor(t){this.art=t,this.keys={},p||this.init()}init(){const{constructor:t}=this.art;this.art.option.hotkey&&(this.add("Escape",()=>{this.art.fullscreenWeb&&(this.art.fullscreenWeb=!1)}),this.add("Space",()=>{Y(this.art.toggle())}),this.add("ArrowLeft",()=>{this.art.backward=t.SEEK_STEP}),this.add("ArrowUp",()=>{this.art.volume+=t.VOLUME_STEP}),this.add("ArrowRight",()=>{this.art.forward=t.SEEK_STEP}),this.add("ArrowDown",()=>{this.art.volume-=t.VOLUME_STEP})),this.art.on("document:keydown",t=>{if(this.art.isFocus){const e=document.activeElement.tagName.toUpperCase(),r=document.activeElement.getAttribute("contenteditable");if("INPUT"!==e&&"TEXTAREA"!==e&&""!==r&&"true"!==r&&!t.altKey&&!t.ctrlKey&&!t.metaKey&&!t.shiftKey){const e=this.keys[t.code];if(e){t.preventDefault();for(let r=0;r\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n',state:'\r\n\r\n\r\n',play:'\r\n \r\n',pause:'\r\n \r\n',check:'\r\n\r\n',volume:'\r\n \r\n \r\n',volumeClose:'\r\n \r\n \r\n',screenshot:'\r\n\t\r\n\r\n',setting:'\r\n \r\n \r\n',pip:'\r\n\r\n',arrowLeft:'\r\n \r\n',arrowRight:'\r\n \r\n',playbackRate:'',aspectRatio:'',config:'',lock:'\r\n\r\n\r\n\r\n\r\n',flip:'\r\n\r\n\r\n\r\n\r\n\r\n',unlock:'\r\n\r\n\r\n',fullscreenOff:'\r\n\r\n\r\n\r\n\r\n',fullscreenOn:'\r\n\r\n\r\n\r\n\r\n',fullscreenWebOff:'\r\n\r\n\r\n\r\n\r\n',fullscreenWebOn:'\r\n\r\n\r\n\r\n\r\n',switchOn:'\r\n\r\n\r\n \r\n',switchOff:'\r\n\r\n\r\n \r\n\r\n',error:'\r\n\r\n\r\n\r\n\r\n',close:'\r\n\r\n\r\n\r\n\r\n',airplay:'\r\n \r\n \r\n \r\n \r\n\r\n',...t.option.icons};for(const r in e)X(this,r,{get:()=>S(r,e[r])})}}class Vt extends ut{constructor(t){super(t),this.name="info",p||this.init()}init(){const{proxy:t,constructor:e,template:{$infoPanel:r,$infoClose:o,$video:a}}=this.art;t(o,"click",()=>{this.show=!1});let n=()=>{};const i=m("[data-video]",r)||[];this.art.on("destroy",()=>n());const s=wt(this.art);!function t(){for(let e=0;e{w(a,"display","none"),w(n,"display",null)}),o.proxy(e.$state,"click",()=>Y(t.play()))}}class Ft{constructor(t){this.art=t,this.timer=null,wt(t).add(()=>this.destroy()),t.on("destroy",()=>this.destroy())}destroy(){this.timer&&(clearTimeout(this.timer),this.timer=null)}set show(t){if(wt(this.art).closed)return;const{constructor:e,template:{$player:r,$noticeInner:o}}=this.art;t?(o.textContent=t instanceof Error?t.message.trim():t,f(r,"art-notice-show"),clearTimeout(this.timer),this.timer=setTimeout(()=>{o.textContent="",g(r,"art-notice-show")},e.NOTICE_TIME)):g(r,"art-notice-show")}get show(){const{template:{$player:t}}=this.art;return t.classList.contains("art-notice-show")}}const Ht=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],Bt=(()=>{if("undefined"===typeof document)return!1;const t=Ht[0],e={};for(const r of Ht){if(r[1]in document){for(const[o,a]of r.entries())e[t[o]]=a;return e}}return!1})(),Wt={change:Bt.fullscreenchange,error:Bt.fullscreenerror},jt={request:(t=document.documentElement,e)=>new Promise((r,o)=>{const a=()=>{jt.off("change",a),r()};jt.on("change",a);const n=t[Bt.requestFullscreen](e);n instanceof Promise&&n.then(a).catch(o)}),exit:()=>new Promise((t,e)=>{if(!jt.isFullscreen)return void t();const r=()=>{jt.off("change",r),t()};jt.on("change",r);const o=document[Bt.exitFullscreen]();o instanceof Promise&&o.then(r).catch(e)}),toggle:(t,e)=>jt.isFullscreen?jt.exit():jt.request(t,e),onchange(t){jt.on("change",t)},onerror(t){jt.on("error",t)},on(t,e){const r=Wt[t];r&&document.addEventListener(r,e,!1)},off(t,e){const r=Wt[t];r&&document.removeEventListener(r,e,!1)},raw:Bt};function Ut(t){const{i18n:e,notice:r,template:{$video:o,$player:a}}=t;t.once("video:loadedmetadata",()=>{var n;jt.isEnabled?(n=t,jt.on("change",()=>{n.emit("fullscreen",jt.isFullscreen),jt.isFullscreen?(n.state="fullscreen",f(a,"art-fullscreen")):g(a,"art-fullscreen"),n.emit("resize")}),jt.on("error",t=>{n.emit("fullscreenError",t)}),X(n,"fullscreen",{get:()=>jt.isFullscreen,async set(t){t?await jt.request(a):await jt.exit()}})):o.webkitSupportsFullscreen?(t=>{t.on("document:webkitfullscreenchange",()=>{t.emit("fullscreen",t.fullscreen),t.emit("resize")}),X(t,"fullscreen",{get:()=>document.fullscreenElement===o,set(e){e?(t.state="fullscreen",o.webkitEnterFullscreen()):o.webkitExitFullscreen()}})})(t):X(t,"fullscreen",{get:()=>!1,set(){r.show=e.get("Fullscreen Not Supported")}}),X(t,"fullscreen",Z(t,"fullscreen"))})}function qt(t){const{icons:e,proxy:r,storage:o,template:{$player:a,$video:n}}=t;let i=!1,s=0,l=0;function c(){const{$mini:e}=t.template;e&&(g(a,"art-mini"),w(e,"display","none"),a.prepend(n),t.emit("mini",!1))}function d(e,r){t.playing?(w(e,"display","none"),w(r,"display","flex")):(w(e,"display","flex"),w(r,"display","none"))}function p(){const{$mini:e}=t.template,r=P(e),a=window.innerHeight-r.height-50,n=window.innerWidth-r.width-50;o.set("top",a),o.set("left",n),w(e,"top",`${a}px`),w(e,"left",`${n}px`)}X(t,"mini",{get:()=>v(a,"art-mini"),set(h){if(h){t.state="mini",f(a,"art-mini");const h=function(){const{$mini:a}=t.template;if(a)return y(a,n),w(a,"display","flex");{const a=L("div");f(a,"art-mini-popup"),y(document.body,a),t.template.$mini=a,y(a,n);const p=y(a,'
');y(p,e.close),r(p,"click",c);const h=y(a,'
'),u=y(h,e.play),m=y(h,e.pause);return r(u,"click",()=>Y(t.play())),r(m,"click",()=>t.pause()),d(u,m),t.on("video:playing",()=>d(u,m)),t.on("video:pause",()=>d(u,m)),t.on("video:timeupdate",()=>d(u,m)),r(a,"mousedown",t=>{i=0===t.button,s=t.pageX,l=t.pageY}),t.on("document:mousemove",t=>{if(i){f(a,"art-mini-dragging");const e=t.pageX-s,r=t.pageY-l;w(a,"transform",`translate(${e}px, ${r}px)`)}}),t.on("document:mouseup",()=>{if(i){i=!1,g(a,"art-mini-dragging");const t=P(a);o.set("left",t.left),o.set("top",t.top),w(a,"left",`${t.left}px`),w(a,"top",`${t.top}px`),w(a,"transform",null)}}),a}}(),u=o.get("top"),m=o.get("left");"number"===typeof u&&"number"===typeof m?(w(h,"top",`${u}px`),w(h,"left",`${m}px`),T(h)||p()):p(),t.emit("mini",!0)}else c()}})}function Xt(t){const{i18n:e,notice:r,template:{$video:o}}=t;document.pictureInPictureEnabled?function(t){const{template:{$video:e},proxy:r,notice:o}=t;e.disablePictureInPicture=!1,X(t,"pip",{get:()=>document.pictureInPictureElement,set(r){r?(t.state="pip",e.requestPictureInPicture().catch(t=>{throw o.show=t,t})):document.exitPictureInPicture().catch(t=>{throw o.show=t,t})}}),r(e,"enterpictureinpicture",()=>{t.emit("pip",!0)}),r(e,"leavepictureinpicture",()=>{t.emit("pip",!1)})}(t):o.webkitSupportsPresentationMode?function(t){const{$video:e}=t.template;e.webkitSetPresentationMode("inline"),X(t,"pip",{get:()=>"picture-in-picture"===e.webkitPresentationMode,set(r){r?(t.state="pip",e.webkitSetPresentationMode("picture-in-picture"),t.emit("pip",!0)):(e.webkitSetPresentationMode("inline"),t.emit("pip",!1))}})}(t):X(t,"pip",{get:()=>!1,set(){r.show=e.get("PIP Not Supported")}})}Object.defineProperties(jt,{isFullscreen:{get:()=>Boolean(document[Bt.fullscreenElement])},element:{enumerable:!0,get:()=>document[Bt.fullscreenElement]},isEnabled:{enumerable:!0,get:()=>Boolean(document[Bt.fullscreenEnabled])}});const Gt=new WeakMap,Kt=new WeakMap;function Zt(t){const e=Gt.get(t),r=wt(t).child(),o={scope:r,assigned:!1,acceptingEvents:!1,active:()=>!xt(t)&&!r.closed&&Gt.get(t)===o};return Gt.set(t,o),r.add(()=>{Gt.get(t)===o&&Gt.delete(t),o.onAssigned=void 0,o.onError=void 0}),e?.scope.dispose(),o}function Jt(t){t.assigned=!0;const e=t.onAssigned;t.onAssigned=void 0,t.active()&&e?.()}function Qt(t,e){t.active()&&(t.onError?t.onError(e):console.warn("Failed to initialize ArtPlayer source:",e),t.scope.dispose())}function te(t){const{i18n:e,notice:r,option:o,constructor:{instances:a},template:{$video:n}}=t;X(t,"play",{async value(){const i=function(t){const e=Gt.get(t);return()=>Gt.get(t)===e&&(!e||e.active())}(t),s=await n.play();if(!i())return s;const l=e.get("Play");if(!i())return s;if(r.show=l,!i())return s;if(t.emit("play"),o.mutex)for(let e=0;e{t.closed||i||(a&&(i=!0,n()),o(e))};return e[a?"once":"on"](r,s),n=t.add(()=>{e.off(r,s)}),s}function re(t,e,r){return new Promise((o,a)=>{if(xt(t)||e===t.url)return void o();const n=Zt(t),i=n.scope.child();let s=!1;const l=(t=!1,e)=>{s||(s=!0,n.onError=void 0,n.onAssigned=void 0,i.dispose(),t?a(e):o(),t&&n.scope.dispose())};i.add(()=>{l()});const c=()=>!s&&n.active(),d=t=>l(!0,t);n.onError=d;try{const{playing:o,aspectRatio:a,playbackRate:s}=t;if(t.pause(),!c())return;const p=i.child(),h={"video:error":d,"video:loadedmetadata":()=>{if(c())try{t.currentTime=r}catch(e){d(e)}},"video:canplay":()=>{if(!c())return;p.dispose();(async()=>{if(t.playbackRate=s,c()&&(t.aspectRatio=a,c())){if(o)try{await t.play()}catch{}c()&&(t.notice.show="",l())}})().catch(d)}},u=i.child(),m=[],f=Object.keys(h);for(const e of f)ee(u,t,e,t=>{n.acceptingEvents&&m.push([e,t])},!1);if(function(t,e,r){Kt.set(t,e),e.acceptingEvents=!0;try{t.url=r}finally{Kt.get(t)===e&&(Kt.delete(t),Jt(e))}}(t,n,e),!c())return;if(t.notice.show="",!c())return;const g=()=>{if(u.dispose(),!e)return void l();const r={};for(const e of f)r[e]=ee(p,t,e,h[e]);for(const[t,e]of m){if(!c()||p.closed)break;r[t](e)}m.length=0};n.assigned?g():n.onAssigned=g}catch(p){d(p)}})}function oe(t){const{option:e,template:{$progress:r,$video:o}}=t;let a=null,n=!1,i=null;t.on("setBar",async(a,s,l)=>{const c=t.controls?.thumbnails,{url:d,scale:h}=e.thumbnails;if(!c||!d)return;if("hover"===a||"played"===a&&l&&p){if(i||n||(n=!0,i=await I(d,h),n=!1),!i)return;const a=r.clientWidth*s;a>0&&ar.clientWidth-h/2?w(n,"left",r.clientWidth-h+"px"):w(n,"left",a-h/2+"px")}(a)}}),X(t,"thumbnails",{get:()=>t.option.thumbnails,set(e){e.url&&!t.option.isLive&&(t.option.thumbnails=e,clearTimeout(a),a=null,n=!1,i=null)}})}function ae(t){const{option:e,template:{$video:r}}=t;X(t,"url",{get:()=>r.src,async set(o){if(xt(t))return;const a=function(t){const e=Kt.get(t);return Kt.delete(t),e||Zt(t)}(t);a.acceptingEvents=!1;try{if(!o)return void(await Et(a.scope)&&a.active()&&(t.loading.show=!0));const n=t.url,i=e.type||N(o),s=e.customType[i];if(i&&s){if(!(await Et(a.scope))||!a.active())return;t.loading.show=!0}if(!a.active())return;const l=a.scope.child();let c=!1,d=!1;ee(l,t,"video:canplay",()=>{c=!d}),ee(l,t,"video:error",()=>{d=!0});try{if(a.acceptingEvents=!0,i&&s){const e=s.call(t,r,o,t);Promise.resolve(e).catch(t=>Qt(a,t))}else{if(n&&URL.revokeObjectURL(n),!a.active())return;r.src=o}}finally{l.dispose()}if(!a.active())return;if(n!==t.url&&(t.option.url=o,a.active()&&t.isReady&&n)){const e=()=>{a.active()&&t.emit("restart",o)};c?e():d||ee(a.scope,t,"video:canplay",e)}}catch(n){Qt(a,n)}finally{Jt(a)}}})}class ne{constructor(t){ae(t),function(t){const{template:{$video:e}}=t;X(t,"attr",{value(t,r){if(void 0===r)return e[t];e[t]=r}})}(t),te(t),function(t){const{template:{$video:e},i18n:r,notice:o}=t;X(t,"pause",{value(){const a=e.pause();return o.show=r.get("Pause"),t.emit("pause"),a}})}(t),function(t){X(t,"toggle",{value:()=>t.playing?t.pause():t.play()})}(t),function(t){const{notice:e}=t;X(t,"seek",{set(r){t.currentTime=r,t.duration&&(e.show=`${B(t.currentTime)} / ${B(t.duration)}`),t.emit("seek",t.currentTime,r)}}),X(t,"forward",{set(e){t.seek=t.currentTime+e}}),X(t,"backward",{set(e){t.seek=t.currentTime-e}})}(t),function(t){const{template:{$video:e},i18n:r,notice:o,storage:a}=t;X(t,"volume",{get:()=>e.volume||0,set:t=>{e.volume=F(t,0,1),o.show=`${r.get("Volume")}: ${Number.parseInt(100*e.volume,10)}`,0!==e.volume&&a.set("volume",e.volume)}}),X(t,"muted",{get:()=>e.muted,set:r=>{e.muted=r,t.emit("muted",r)}})}(t),function(t){const{$video:e}=t.template;X(t,"currentTime",{get:()=>e.currentTime||0,set:r=>{r=Number.parseFloat(r),Number.isNaN(r)||(e.currentTime=F(r,0,t.duration))}})}(t),function(t){X(t,"duration",{get:()=>{const{duration:e}=t.template.$video;return e===1/0?0:e||0}})}(t),function(t){const e=e=>re(t,e,0);X(t,"switchQuality",{value:e=>re(t,e,t.currentTime)}),X(t,"switchUrl",{value:e}),X(t,"switch",{set:e})}(t),function(t){const{template:{$video:e},i18n:r,notice:o}=t;X(t,"playbackRate",{get:()=>e.playbackRate,set(a){if(a){if(a===e.playbackRate)return;e.playbackRate=a,o.show=`${r.get("Rate")}: ${1===a?r.get("Normal"):`${a}x`}`}else t.playbackRate=1}})}(t),function(t){const{i18n:e,notice:r,template:{$video:o,$player:a}}=t;X(t,"aspectRatio",{get:()=>a.dataset.aspectRatio||"default",set(n){if(n||(n="default"),"default"===n)w(o,"width",null),w(o,"height",null),w(o,"margin",null),delete a.dataset.aspectRatio;else{const t=n.split(":").map(Number),{clientWidth:e,clientHeight:r}=a,i=e/r,s=t[0]/t[1];i>s?(w(o,"width",s*r+"px"),w(o,"height","100%"),w(o,"margin","0 auto")):(w(o,"width","100%"),w(o,"height",e/s+"px"),w(o,"margin","auto 0")),a.dataset.aspectRatio=n}r.show=`${e.get("Aspect Ratio")}: ${"default"===n?e.get("Default"):n}`,t.emit("aspectRatio",n)}})}(t),function(t){const{notice:e,template:{$video:r}}=t,o=L("canvas");X(t,"getDataURL",{value:()=>new Promise((t,a)=>{try{o.width=r.videoWidth,o.height=r.videoHeight,o.getContext("2d").drawImage(r,0,0),t(o.toDataURL("image/png"))}catch(n){e.show=n,a(n)}})}),X(t,"getBlobUrl",{value:()=>new Promise((t,a)=>{try{o.width=r.videoWidth,o.height=r.videoHeight,o.getContext("2d").drawImage(r,0,0),o.toBlob(e=>{t(URL.createObjectURL(e))})}catch(n){e.show=n,a(n)}})}),X(t,"screenshot",{value:async e=>{const o=await t.getDataURL();return D(o,`${e||`artplayer_${B(r.currentTime)}`}.png`),t.emit("screenshot",o),o}})}(t),Ut(t),function(t){const{constructor:e,template:{$container:r,$player:o}}=t;let a="";X(t,"fullscreenWeb",{get:()=>v(o,"art-fullscreen-web"),set(n){n?(a=o.style.cssText,e.FULLSCREEN_WEB_IN_BODY&&y(document.body,o),t.state="fullscreenWeb",w(o,"width","100%"),w(o,"height","100%"),f(o,"art-fullscreen-web"),t.emit("fullscreenWeb",!0)):(e.FULLSCREEN_WEB_IN_BODY&&y(r,o),a&&(o.style.cssText=a,a=""),g(o,"art-fullscreen-web"),t.emit("fullscreenWeb",!1)),t.emit("resize")}})}(t),Xt(t),function(t){const{$video:e}=t.template;X(t,"loaded",{get:()=>t.loadedTime/e.duration}),X(t,"loadedTime",{get:()=>e.buffered.length?e.buffered.end(e.buffered.length-1):0})}(t),function(t){X(t,"played",{get:()=>t.currentTime/t.duration})}(t),function(t){const{$video:e}=t.template;X(t,"playing",{get:()=>"boolean"===typeof e.playing?e.playing:!!(e.currentTime>0&&!e.paused&&!e.ended&&e.readyState>2)})}(t),function(t){const{$container:e,$player:r,$video:o}=t.template;X(t,"autoSize",{value(){const{videoWidth:a,videoHeight:n}=o,{width:i,height:s}=P(e),l=a/n;if(i/s>l)w(r,"width",s*l/i*100+"%"),w(r,"height","100%");else{const t=i/l/s*100;w(r,"width","100%"),w(r,"height",`${t}%`)}t.emit("autoSize",{width:t.width,height:t.height})}})}(t),function(t){const e=t;X(t,"rect",{get:()=>P(t.template.$player)});const r=["bottom","height","left","right","top","width"];for(let o=0;oe.rect[a]})}X(t,"x",{get:()=>e.left+window.pageXOffset}),X(t,"y",{get:()=>e.top+window.pageYOffset})}(t),function(t){const{template:{$player:e},i18n:r,notice:o}=t;X(t,"flip",{get:()=>e.dataset.flip||"normal",set(a){a||(a="normal"),"normal"===a?delete e.dataset.flip:e.dataset.flip=a,o.show=`${r.get("Video Flip")}: ${r.get(H(a))}`,t.emit("flip",a)}})}(t),qt(t),function(t){const{template:{$poster:e}}=t;X(t,"poster",{get:()=>{try{return e.style.backgroundImage.match(/"(.*)"/)[1]}catch{return""}},set(t){w(e,"backgroundImage",`url(${t})`)}})}(t),function(t){const{template:{$container:e,$video:r}}=t;X(t,"autoHeight",{value(){const{clientWidth:o}=e,{videoHeight:a,videoWidth:n}=r,i=a*(o/n);w(e,"height",`${i}px`),t.emit("autoHeight",i)}})}(t),function(t){const{$player:e}=t.template;X(t,"cssVar",{value:(t,r)=>r?e.style.setProperty(t,r):getComputedStyle(e).getPropertyValue(t)})}(t),function(t){X(t,"theme",{get:()=>t.cssVar("--art-theme"),set(e){t.cssVar("--art-theme",e)}})}(t),function(t){X(t,"type",{get:()=>t.option.type,set(e){t.option.type=e}})}(t),function(t){const e=["mini","pip","fullscreen","fullscreenWeb"];X(t,"state",{get:()=>e.find(e=>t[e])||"standard",set(r){for(let o=0;oo.$track?.offset||0,set(a){const{cues:n}=t.subtitle;if(!o.$track||0===n.length)return;const i=F(a,-10,10);o.$track.offset=i;for(let e=0;e{switch(t.availability){case"available":n=!0;break;case"not-available":n=!1}}):n=!1,X(t,"airplay",{value(){n?(a.webkitShowPlaybackTargetPicker(),t.emit("airplay")):r.show=e.get("AirPlay Not Available")}})}(t),function(t){X(t,"quality",{set(e){const{controls:r,notice:o,i18n:a}=t,n=e.find(t=>t.default)||e[0];r.update({name:"quality",position:"right",index:10,style:{marginRight:"10px"},html:n?.html||"",selector:e,onSelect:async e=>(await t.switchQuality(e.url),o.show=`${a.get("Switch Video")}: ${e.html}`,e.html)})}})}(t),oe(t),function(t){const{i18n:e,notice:r,option:o,constructor:a,proxy:n,template:{$player:s,$video:l,$poster:c}}=t;let d=0;for(let p=0;p{t.emit(`video:${e.type}`,e)});t.on("video:canplay",()=>{d=0,t.loading.show=!1}),t.once("video:canplay",()=>{t.loading.show=!1,t.controls.show=!0,t.mask.show=!0,t.isReady=!0,t.emit("ready")}),t.on("video:ended",()=>{o.loop?(t.seek=0,Y(t.play()),t.controls.show=!1,t.mask.show=!1):(t.controls.show=!0,t.mask.show=!0)}),t.on("video:error",async n=>{if(d{t.emit("resize"),p&&(t.loading.show=!1,t.controls.show=!0,t.mask.show=!0)}),t.on("video:loadstart",()=>{t.loading.show=!0,t.mask.show=!1,t.controls.show=!0}),t.on("video:pause",()=>{t.controls.show=!0,t.mask.show=!0}),t.on("video:play",()=>{t.mask.show=!1,w(c,"display","none")}),t.on("video:playing",()=>{t.mask.show=!1}),t.on("video:progress",()=>{t.playing&&(t.loading.show=!1)}),t.on("video:seeked",()=>{t.loading.show=!1,t.mask.show=!0}),t.on("video:seeking",()=>{t.loading.show=!0,t.mask.show=!1}),t.on("video:timeupdate",()=>{t.mask.show=!1}),t.on("video:waiting",()=>{t.loading.show=!0,t.mask.show=!1})}(t),function(t){const{option:e,storage:r,template:{$video:o,$poster:a}}=t;for(const i in e.moreVideoAttr)t.attr(i,e.moreVideoAttr[i]);e.muted&&(t.muted=e.muted),e.volume&&(o.volume=F(e.volume,0,1));const n=r.get("volume");"number"===typeof n&&(o.volume=F(n,0,1)),e.poster&&w(a,"backgroundImage",`url(${e.poster})`),e.autoplay&&(o.autoplay=e.autoplay),e.playsInline&&(o.playsInline=!0,o["webkit-playsinline"]=!0),e.theme&&(e.cssVar["--art-theme"]=e.theme);for(const i in e.cssVar)t.cssVar(i,e.cssVar[i]);t.url=e.url}(t)}}function ie(t){const{notice:e,constructor:r,template:{$player:o,$video:a}}=t,n="art-auto-orientation",i="art-auto-orientation-fullscreen";let s=!1;function l(){const{videoWidth:t,videoHeight:e}=a,r=document.documentElement.clientWidth,o=document.documentElement.clientHeight;return t>e&&ro}return t.on("fullscreenWeb",e=>{if(e){if(l()){const e=Number(r.AUTO_ORIENTATION_TIME??0);setTimeout(()=>{t.fullscreenWeb&&!v(o,n)&&function(){const e=O(),r=document.documentElement.clientWidth,a=document.documentElement.clientHeight-e.top-e.bottom,i=r-e.left-e.right;w(o,"width",`${a}px`),w(o,"height",`${i}px`),w(o,"transform-origin","0 0"),w(o,"transform",`rotate(90deg) translate(${e.top}px, -${r-e.right}px)`),f(o,n),t.isRotate=!0,t.emit("resize")}()},e)}}else v(o,n)&&(w(o,"width",""),w(o,"height",""),w(o,"transform-origin",""),w(o,"transform",""),g(o,n),t.isRotate=!1,t.emit("resize"))}),t.on("fullscreen",async t=>{const r=!!screen?.orientation?.lock;if(t){if(r&&l())try{const t=screen.orientation.type.startsWith("portrait")?"landscape":"portrait";await screen.orientation.lock(t),s=!0,f(o,i)}catch(a){s=!1,e.show=a}}else if(v(o,i)&&g(o,i),r&&s){try{screen.orientation.unlock()}catch{}s=!1}}),{name:"autoOrientation",get state(){return v(o,n)}}}function se(t){const{i18n:e,icons:r,storage:o,constructor:a,proxy:n,template:{$poster:i}}=t,s=t.layers.add({name:"auto-playback",html:'\n
\n
\n
\n '}),l=u(".art-auto-playback-last",s),c=u(".art-auto-playback-jump",s),d=u(".art-auto-playback-close",s);y(d,r.close);let p=null;function h(){const r=(o.get("times")||{})[t.option.id||t.option.url];clearTimeout(p),w(s,"display","none"),r&&r>=a.AUTO_PLAYBACK_MIN&&(w(s,"display","flex"),l.textContent=`${e.get("Last Seen")} ${B(r)}`,c.textContent=e.get("Jump Play"),n(d,"click",()=>{w(s,"display","none")}),n(c,"click",()=>{t.seek=r,Y(t.play()),w(i,"display","none"),w(s,"display","none")}),t.once("video:timeupdate",()=>{p=setTimeout(()=>{w(s,"display","none")},a.AUTO_PLAYBACK_TIMEOUT)}))}return t.on("video:timeupdate",()=>{if(t.playing){const e=o.get("times")||{},r=Object.keys(e);r.length>a.AUTO_PLAYBACK_MAX&&delete e[r[0]],e[t.option.id||t.option.url]=t.currentTime,o.set("times",e)}}),t.on("ready",h),t.on("restart",h),{name:"auto-playback",get times(){return o.get("times")||{}},clear:()=>o.del("times"),delete(t){const e=o.get("times")||{};return delete e[t],o.set("times",e),e}}}function le(t){const{constructor:e,proxy:r,template:{$player:o,$video:a}}=t;let n=null,i=!1,s=1;const l=()=>{clearTimeout(n),i&&(i=!1,t.playbackRate=s,g(o,"art-fast-forward"))};return r(a,"touchstart",r=>{1===r.touches.length&&t.playing&&!t.isLock&&(n=setTimeout(()=>{i=!0,s=t.playbackRate,t.playbackRate=e.FAST_FORWARD_VALUE,f(o,"art-fast-forward")},e.FAST_FORWARD_TIME))}),t.on("document:touchmove",l),t.on("document:touchend",l),{name:"fastForward",get state(){return v(o,"art-fast-forward")}}}function ce(t){const{layers:e,icons:r,template:{$player:o}}=t;function a(){return v(o,"art-lock")}function n(){f(o,"art-lock"),t.isLock=!0,t.emit("lock",!0)}function i(){g(o,"art-lock"),t.isLock=!1,t.emit("lock",!1)}return e.add({name:"lock",mounted(e){const o=y(e,r.lock),a=y(e,r.unlock);w(o,"display","none"),t.on("lock",t=>{t?(w(o,"display","inline-flex"),w(a,"display","none")):(w(o,"display","none"),w(a,"display","inline-flex"))})},click(){a()?i():n()}}),{name:"lock",get state(){return a()},set state(t){t?n():i()}}}function de(t){return t.on("control",e=>{e?g(t.template.$player,"art-mini-progress-bar"):f(t.template.$player,"art-mini-progress-bar")}),{name:"mini-progress-bar"}}class pe{constructor(t){this.art=t,this.id=0;const{option:e}=t;!function(t,e){xt(t.art)||!e.miniProgressBar||e.isLive||t.add(de),!xt(t.art)&&e.lock&&p&&t.add(ce),xt(t.art)||!e.autoPlayback||e.isLive||t.add(se),!xt(t.art)&&e.autoOrientation&&p&&t.add(ie),!xt(t.art)&&e.fastForward&&p&&!e.isLive&&t.add(le)}(this,e);for(let r=0;rconsole.warn("Failed to initialize ArtPlayer plugin:",t))}}add(t){V(!xt(this.art),"Cannot add a plugin after ArtPlayer is destroyed"),this.id+=1;const e=t.call(this.art,this.art);return e instanceof Promise?e.then(e=>this.next(t,e)):this.next(t,e)}next(t,e){return function(t,e,r){if(xt(t.art))return t;const o=r&&r.name||e.name||`plugin${t.id}`;if(xt(t.art))return t;let a=o;const n=K(t,a);if(xt(t.art))return t;const i=`Cannot add a plugin that already has the same name: ${o}`;return xt(t.art)||(V(!n,i),("object"===typeof o&&null!==o||"function"===typeof o)&&(a=Reflect.ownKeys({[a]:void 0})[0]),xt(t.art)||X(t,a,{value:r})),t}(this,t,e)}}class he extends ut{constructor(t){super(t);const{option:e,controls:r,template:{$setting:o}}=t;this.name="setting",this.$parent=o,this.id=0,this.active=null,this.cache=new Map,this.option=[...this.builtin,...e.settings],e.setting&&(this.format(),this.render(),t.on("blur",()=>{this.show&&(this.show=!1,this.render())}),t.on("focus",t=>{const e=C(t,r.setting),o=C(t,this.$parent);!this.show||e||o||(this.show=!1,this.render())}),t.on("resize",()=>this.resize()))}get builtin(){const t=[],{option:e}=this.art;return e.playbackRate&&t.push(function(t){const{i18n:e,icons:r,constructor:{SETTING_ITEM_WIDTH:o,PLAYBACK_RATE:a}}=t;function n(t){return 1===t?e.get("Normal"):t.toFixed(1)}function i(){const e=t.setting.find(`playback-rate-${t.playbackRate}`);t.setting.check(e)}return{width:o,name:"playback-rate",html:e.get("Play Speed"),tooltip:n(t.playbackRate),icon:r.playbackRate,selector:a.map(e=>({value:e,name:`playback-rate-${e}`,default:e===t.playbackRate,html:n(e)})),onSelect:e=>(t.playbackRate=e.value,e.html),mounted:()=>{i(),t.on("video:ratechange",()=>i())}}}(this.art)),e.aspectRatio&&t.push(function(t){const{i18n:e,icons:r,constructor:{SETTING_ITEM_WIDTH:o,ASPECT_RATIO:a}}=t;function n(t){return"default"===t?e.get("Default"):t}function i(){const e=t.setting.find(`aspect-ratio-${t.aspectRatio}`);t.setting.check(e)}return{width:o,name:"aspect-ratio",html:e.get("Aspect Ratio"),icon:r.aspectRatio,tooltip:n(t.aspectRatio),selector:a.map(e=>({value:e,name:`aspect-ratio-${e}`,default:e===t.aspectRatio,html:n(e)})),onSelect:e=>(t.aspectRatio=e.value,e.html),mounted:()=>{i(),t.on("aspectRatio",()=>i())}}}(this.art)),e.flip&&t.push(function(t){const{i18n:e,icons:r,constructor:{SETTING_ITEM_WIDTH:o,FLIP:a}}=t;function n(t){return e.get(H(t))}function i(){const e=t.setting.find(`flip-${t.flip}`);t.setting.check(e)}return{width:o,name:"flip",html:e.get("Video Flip"),tooltip:n(t.flip),icon:r.flip,selector:a.map(e=>({value:e,name:`flip-${e}`,default:e===t.flip,html:n(e)})),onSelect:e=>(t.flip=e.value,e.html),mounted:()=>{i(),t.on("flip",()=>i())}}}(this.art)),e.subtitleOffset&&t.push(function(t){const{i18n:e,icons:r,constructor:o}=t;return{width:o.SETTING_ITEM_WIDTH,name:"subtitle-offset",html:e.get("Subtitle Offset"),icon:r.subtitle,tooltip:"0s",range:[0,-10,10,.1],onChange:e=>(t.subtitleOffset=e.range[0],`${e.range[0]}s`),mounted:(e,r)=>{t.on("subtitleOffset",t=>{r.$range.value=t,r.tooltip=`${t}s`})}}}(this.art)),t}traverse(t,e=this.option){for(let r=0;r{e.default=e===t,e.default&&e.$item&&$(e.$item,"art-current")},t.$option),this.render(t.$parents))}format(t=this.option,e,r,o=[]){for(let a=0;ae}),X(n,"$parents",{get:()=>r}),X(n,"$option",{get:()=>t});const o=[];X(n,"$events",{get:()=>o}),X(n,"$formatted",{get:()=>!0})}this.format(n.selector||[],n,t,o)}this.option=t}find(t=""){let e=null;return this.traverse(r=>{r.name===t&&(e=r)}),e}resize(){const{controls:t,constructor:{SETTING_WIDTH:e,SETTING_ITEM_HEIGHT:r},template:{$player:o,$setting:a}}=this.art;if(t.setting&&this.show){const n=this.active[0]?.$parent?.width||e,{left:i,width:s}=P(t.setting),{left:l,width:c}=P(o),d=i-l+s/2-n/2;if(w(a,"height",`${this.active===this.option?this.active.length*r:(this.active.length+1)*r}px`),w(a,"width",`${n}px`),this.art.isRotate||p)return;d+n>c?(w(a,"left",null),w(a,"right",null)):(w(a,"left",`${d}px`),w(a,"right","auto"))}}inactivate(t){for(let e=0;e'),s=L("div");f(s,"art-setting-item-left-icon"),y(s,o),y(i,s),y(i,t.$parent.html);const l=r(n,"click",()=>this.render(t.$parents));t.$parent.$events.push(l),y(e,n)}createItem(t,e=!1){if(!this.cache.has(t.$option))return;const r=this.cache.get(t.$option),o=t.$item;let a="selector";K(t,"switch")&&(a="switch"),K(t,"range")&&(a="range"),K(t,"onClick")&&(a="button");const{icons:n,proxy:i,constructor:s}=this.art,l=L("div");f(l,"art-setting-item"),w(l,"height",`${s.SETTING_ITEM_HEIGHT}px`),l.dataset.name=t.name||"",l.dataset.value=t.value||"";const c=y(l,'
'),d=y(l,'
'),p=L("div");switch(f(p,"art-setting-item-left-icon"),a){case"button":case"switch":case"range":y(p,t.icon||n.config);break;case"selector":t.selector?.length?y(p,t.icon||n.config):y(p,n.check)}y(c,p),X(t,"$icon",{configurable:!0,get:()=>p}),X(t,"icon",{configurable:!0,get:()=>p.innerHTML,set(t){p.innerHTML="",y(p,t)}});const h=L("div");f(h,"art-setting-item-left-text"),y(h,t.html||""),y(c,h),X(t,"$html",{configurable:!0,get:()=>h}),X(t,"html",{configurable:!0,get:()=>h.innerHTML,set(t){h.innerHTML="",y(h,t)}});const u=L("div");switch(f(u,"art-setting-item-right-tooltip"),y(u,t.tooltip||""),y(d,u),X(t,"$tooltip",{configurable:!0,get:()=>u}),X(t,"tooltip",{configurable:!0,get:()=>u.innerHTML,set(t){u.innerHTML="",y(u,t)}}),a){case"switch":{const e=L("div");f(e,"art-setting-item-right-icon");const r=y(e,n.switchOn),o=y(e,n.switchOff);w(t.switch?o:r,"display","none"),y(d,e),X(t,"$switch",{configurable:!0,get:()=>e});let a=t.switch;X(t,"switch",{configurable:!0,get:()=>a,set(t){a=t,t?(w(o,"display","none"),w(r,"display",null)):(w(o,"display",null),w(r,"display","none"))}});break}case"range":{const e=L("div");f(e,"art-setting-item-right-icon");const r=y(e,'');r.value=t.range[0],r.min=t.range[1],r.max=t.range[2],r.step=t.range[3],f(r,"art-setting-range"),y(d,e),X(t,"$range",{configurable:!0,get:()=>r});let o=[...t.range];X(t,"range",{configurable:!0,get:()=>o,set(t){o=[...t],r.value=t[0],r.min=t[1],r.max=t[2],r.step=t[3]}})}break;case"selector":if(t.selector?.length){const t=L("div");f(t,"art-setting-item-right-icon"),y(t,n.arrowRight),y(d,t)}}switch(a){case"switch":if(t.onSwitch){const e=i(l,"click",async e=>{t.switch=await t.onSwitch.call(this.art,t,l,e)});t.$events.push(e)}break;case"range":if(t.$range){if(t.onRange){const e=i(t.$range,"change",async e=>{t.range[0]=t.$range.valueAsNumber,t.tooltip=await t.onRange.call(this.art,t,l,e)});t.$events.push(e)}if(t.onChange){const e=i(t.$range,"input",async e=>{t.range[0]=t.$range.valueAsNumber,t.tooltip=await t.onChange.call(this.art,t,l,e)});t.$events.push(e)}}break;case"selector":{const e=i(l,"click",async e=>{t.selector?.length?this.render(t.selector):(this.check(t),t.$parent.onSelect&&(t.$parent.tooltip=await t.$parent.onSelect.call(this.art,t,l,e)))});t.$events.push(e),t.default&&f(l,"art-current")}break;case"button":if(t.onClick){const e=i(l,"click",async e=>{t.tooltip=await t.onClick.call(this.art,t,l,e)});t.$events.push(e)}}X(t,"$item",{configurable:!0,get:()=>l}),e?z(l,o):y(r,l),t.mounted&&$t(wt(this.art),()=>t.mounted.call(this.art,t.$item,t),0)}render(t=this.option){if(this.active=t,this.cache.has(t)){$(this.cache.get(t),"art-current")}else{const e=L("div");this.cache.set(t,e),f(e,"art-setting-panel"),y(this.$parent,e),$(e,"art-current"),t[0]?.$parent&&this.createHeader(t[0]);for(let r=0;rnull,this.init(t.option.subtitle);let e=!1;t.on("video:timeupdate",()=>{if(!this.url)return;const t=this.art.template.$video.webkitDisplayingFullscreen;"boolean"===typeof t&&t!==e&&(e=t,this.createTrack(t?"subtitles":"metadata",this.url))})}get url(){return this.art.template.$track.src}set url(t){this.switch(t)}get textTrack(){return this.art.template.$video?.textTracks?.[0]}get activeCues(){return this.textTrack?Array.from(this.textTrack.activeCues):[]}get cues(){return this.textTrack?Array.from(this.textTrack.cues):[]}style(t,e){const{$subtitle:r}=this.art.template;return"object"===typeof t?x(r,t):w(r,t,e)}update(){const{option:{subtitle:t},template:{$subtitle:e}}=this.art;e.innerHTML="",this.activeCues.length&&(this.art.emit("subtitleBeforeUpdate",this.activeCues),e.innerHTML=this.activeCues.map((e,r)=>e.text.split(/\r?\n/).filter(t=>t.trim()).map(e=>`
\n ${t.escape?q(e):e}\n
`).join("")).join(""),this.art.emit("subtitleAfterUpdate",this.activeCues))}async switch(t,e={}){const{i18n:r,notice:o,option:a}=this.art,n={...a.subtitle,...e,url:t},i=await this.init(n);return e.name&&(o.show=`${r.get("Switch Subtitle")}: ${e.name}`),i}createTrack(t,e){const{template:r,proxy:o,option:a}=this.art,{$video:n,$track:i}=r,s=L("track");s.default=!0,s.kind=t,s.src=e,s.label=a.subtitle.name||"Artplayer",s.track.mode="hidden",s.onload=()=>{this.art.emit("subtitleLoad",this.cues,this.option)},this.art.events.remove(this.destroyEvent),i.onload=null,b(i),y(n,s),r.$track=s,this.destroyEvent=o(this.textTrack,"cuechange",()=>this.update())}async init(t){const{notice:e,template:{$subtitle:r}}=this.art;return this.textTrack?(a(t,ht.subtitle),t.url?(this.option=t,this.style(t.style),fetch(t.url).then(t=>t.arrayBuffer()).then(e=>{const r=new TextDecoder(t.encoding).decode(e);switch(t.type||N(t.url)){case"srt":{const e=Q(r);return tt(t.onVttLoad(e))}case"ass":{const e=et(r);return tt(t.onVttLoad(e))}case"vtt":return tt(t.onVttLoad(r));default:return t.url}}).then(t=>(r.innerHTML="",this.url===t||(URL.revokeObjectURL(this.url),this.createTrack("metadata",t)),t)).catch(t=>{throw r.innerHTML="",e.show=t,t})):void 0):null}}class ge{constructor(t){this.art=t;const{option:e,constructor:r}=t;e.container instanceof Element?this.$container=e.container:(this.$container=u(e.container),V(this.$container,`No container element found by ${e.container}`)),V(A(),"The current browser does not support flex layout");const o=this.$container.tagName.toLowerCase();V("div"===o,`Unsupported container element type, only support 'div' but got '${o}'`),V(r.instances.every(t=>t.template.$container!==this.$container),"Cannot mount multiple instances on the same dom element"),this.query=this.query.bind(this),function(t,e,r){const o=yt.get(e);if(o&&o!==t)throw new Error("Cannot mount multiple instances on the same dom element");const a=bt(t);a.rollback=r,yt.set(e,t),a.releaseContainer=()=>{yt.get(e)===t&&yt.delete(e)}}(t,this.$container,function(t){const e=[];return function t(r){const o=Array.from(r.childNodes);e.push({node:r,children:o,attributes:1===r.nodeType?Array.from(r.attributes,t=>[t.name,t.value]):void 0,value:r.nodeValue}),o.forEach(t)}(t),()=>{for(const{node:t,children:r,attributes:o,value:a}of e){for(;t.firstChild;)t.removeChild(t.firstChild);for(const e of r)t.appendChild(e);if(o){const e=t;for(const t of Array.from(e.attributes))e.removeAttribute(t.name);for(const[t,r]of o)e.setAttribute(t,r)}else t.nodeValue=a}}}(this.$container)),this.$container.dataset.artId=t.id,this.init()}static get html(){return`\n
\n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
Player version:
\n
${n}
\n
\n
\n
Video url:
\n
\n
\n
\n
Video volume:
\n
\n
\n
\n
Video time:
\n
\n
\n
\n
Video duration:
\n
\n
\n
\n
Video resolution:
\n
\n x \n
\n
\n
\n
[x]
\n
\n
\n
\n `}query(t){return u(t,this.$container)}init(){const{option:t}=this.art;if(t.useSSR||(this.$container.innerHTML=ge.html),this.$player=this.query(".art-video-player"),this.$video=this.query(".art-video"),this.$track=this.query("track"),this.$poster=this.query(".art-poster"),this.$subtitle=this.query(".art-subtitle"),this.$danmuku=this.query(".art-danmuku"),this.$bottom=this.query(".art-bottom"),this.$progress=this.query(".art-progress"),this.$controls=this.query(".art-controls"),this.$controlsLeft=this.query(".art-controls-left"),this.$controlsCenter=this.query(".art-controls-center"),this.$controlsRight=this.query(".art-controls-right"),this.$layer=this.query(".art-layers"),this.$loading=this.query(".art-loading"),this.$notice=this.query(".art-notice"),this.$noticeInner=this.query(".art-notice-inner"),this.$mask=this.query(".art-mask"),this.$state=this.query(".art-state"),this.$setting=this.query(".art-settings"),this.$info=this.query(".art-info"),this.$infoPanel=this.query(".art-info-panel"),this.$infoClose=this.query(".art-info-close"),this.$contextmenu=this.query(".art-contextmenus"),t.proxy){const e=t.proxy.call(this.art,this.art);V(e instanceof HTMLVideoElement||e instanceof HTMLCanvasElement,"Function 'option.proxy' needs to return 'HTMLVideoElement' or 'HTMLCanvasElement'"),z(e,this.$video),e.className="art-video",this.$video=e}t.backdrop&&f(this.$player,"art-backdrop"),p&&f(this.$player,"art-mobile")}destroy(t){t?this.$container.innerHTML="":f(this.$player,"art-destroy")}}const ve=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);class ye{on(t,e,r){const o=this.e||(this.e={});let a=ve(o,t)?o[t]:void 0;return a||(a=[],Object.defineProperty(o,t,{value:a,enumerable:!0,configurable:!0,writable:!0})),a.push({fn:e,ctx:r}),this}once(t,e,r){const o=this,a=e;let n=!1;function i(...e){n||(n=!0,o.off(t,i),a.apply(r,e))}return i._=e,this.on(t,i,r)}emit(t,...e){const r=this.e||(this.e={}),o=(ve(r,t)&&r[t]||[]).slice();for(const a of o)a.fn.apply(a.ctx,e);return this}off(t,e){const r=this.e||(this.e={}),o=ve(r,t)?r[t]:void 0,a=[];if(o&&e)for(let n=0,i=o.length;ne.call(this,this)),xe.DEBUG){const t=t=>console.log(`[ART.${this.id}] -> ${t}`);t(`Version@${xe.version}`);for(let e=0;et(`Event@${e.type}`))}(function(t){const e=bt(t);return e.rollback=void 0,!e.scope.closed})(this)&&we.push(this)}catch(o){try{kt(this,we,!0,xe.REMOVE_SRC_WHEN_DESTROY,!0)}catch(n){console.warn("Failed to clean up ArtPlayer initialization:",n)}throw o}}static get instances(){return we}static get version(){return n}static get config(){return i}static get utils(){return ot}static get scheme(){return ht}static get Emitter(){return ye}static get validator(){return a}static get kindOf(){return a.kindOf}static get html(){return ge.html}static get option(){return{id:"",container:"#artplayer",url:"",poster:"",type:"",theme:"#f00",volume:.7,isLive:!1,muted:!1,autoplay:!1,autoSize:!1,autoMini:!1,loop:!1,flip:!1,playbackRate:!1,aspectRatio:!1,screenshot:!1,setting:!1,hotkey:!0,pip:!1,mutex:!0,backdrop:!0,fullscreen:!1,fullscreenWeb:!1,subtitleOffset:!1,miniProgressBar:!1,useSSR:!1,playsInline:!0,lock:!1,gesture:!0,fastForward:!1,autoPlayback:!1,autoOrientation:!1,airplay:!1,proxy:void 0,layers:[],contextmenu:[],controls:[],settings:[],quality:[],highlight:[],plugins:[],thumbnails:{url:"",number:60,column:10,width:0,height:0,scale:1},subtitle:{url:"",type:"",style:{},name:"",escape:!0,encoding:"utf-8",onVttLoad:t=>t},moreVideoAttr:{controls:!1,preload:l?"auto":"metadata"},i18n:{},icons:{},cssVar:{},customType:{},lang:navigator?.language.toLowerCase()}}get proxy(){return this.events.proxy}get query(){return this.template.query}get video(){return this.template.$video}reset(){this.video.removeAttribute("src"),this.video.load()}destroy(t=!0){kt(this,we,t,xe.REMOVE_SRC_WHEN_DESTROY)}}return xe.STYLE=me,xe.DEBUG=!1,xe.CONTEXTMENU=!0,xe.NOTICE_TIME=2e3,xe.SETTING_WIDTH=250,xe.SETTING_ITEM_WIDTH=200,xe.SETTING_ITEM_HEIGHT=35,xe.RESIZE_TIME=200,xe.SCROLL_TIME=200,xe.SCROLL_GAP=50,xe.AUTO_PLAYBACK_MAX=10,xe.AUTO_PLAYBACK_MIN=5,xe.AUTO_PLAYBACK_TIMEOUT=3e3,xe.RECONNECT_TIME_MAX=5,xe.RECONNECT_SLEEP_TIME=1e3,xe.CONTROL_HIDE_TIME=3e3,xe.DBCLICK_TIME=300,xe.DBCLICK_FULLSCREEN=!0,xe.MOBILE_DBCLICK_PLAY=!0,xe.MOBILE_CLICK_PLAY=!1,xe.AUTO_ORIENTATION_TIME=200,xe.INFO_LOOP_TIME=1e3,xe.FAST_FORWARD_VALUE=3,xe.FAST_FORWARD_TIME=1e3,xe.TOUCH_MOVE_RATIO=.5,xe.VOLUME_STEP=.1,xe.SEEK_STEP=5,xe.PLAYBACK_RATE=[.5,.75,1,1.25,1.5,2],xe.ASPECT_RATIO=["default","4:3","16:9"],xe.FLIP=["normal","horizontal","vertical"],xe.FULLSCREEN_WEB_IN_BODY=!0,xe.LOG_VERSION=!0,xe.USE_RAF=!1,xe.REMOVE_SRC_WHEN_DESTROY=!0,h&&(window.Artplayer=xe,M("artplayer-style",me),setTimeout(()=>{xe.LOG_VERSION&&console.log(`%c ArtPlayer %c ${xe.version} %c https://artplayer.org`,"color: #fff; background: #5f5f5f","color: #fff; background: #4bc729","")},100)),xe}); diff --git a/docs/compiled/artplayer.legacy.js b/docs/compiled/artplayer.legacy.js index 478e8e41a..4b83c7396 100644 --- a/docs/compiled/artplayer.legacy.js +++ b/docs/compiled/artplayer.legacy.js @@ -4,4 +4,4 @@ * (c) 2017-2026 Harvey Zhao * Released under the MIT License. */ -!function(t,e){"object"===typeof exports&&"undefined"!==typeof module?module.exports=e():"function"==typeof define&&define.amd?(t.Artplayer=e(),define(function(){return t.Artplayer})):(t="undefined"!==typeof globalThis?globalThis:t||self).Artplayer=e()}(this,function(){"use strict";var t,e=Object.defineProperty,r=Object.defineProperties,o=Object.getOwnPropertyDescriptors,a=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,s=(t,r,o)=>r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o,l=(t,e)=>{for(var r in e||(e={}))n.call(e,r)&&s(t,r,e[r]);if(a)for(var r of a(e))i.call(e,r)&&s(t,r,e[r]);return t},c=(t,e)=>r(t,o(e)),d=(t,e,r)=>new Promise((o,a)=>{var n=t=>{try{s(r.next(t))}catch(e){a(e)}},i=t=>{try{s(r.throw(t))}catch(e){a(e)}},s=t=>t.done?o(t.value):Promise.resolve(t.value).then(n,i);s((r=r.apply(t,e)).next())});function p(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var h,u={exports:{}};var m=(h||(h=1,u.exports=function(){function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}var e=Object.prototype.toString,r=function(r){if(void 0===r)return"undefined";if(null===r)return"null";var a=t(r);if("boolean"===a)return"boolean";if("string"===a)return"string";if("number"===a)return"number";if("symbol"===a)return"symbol";if("function"===a)return"GeneratorFunction"===o(r)?"generatorfunction":"function";if(function(t){return Array.isArray?Array.isArray(t):t instanceof Array}(r))return"array";if(function(t){return!(!t.constructor||"function"!=typeof t.constructor.isBuffer)&&t.constructor.isBuffer(t)}(r))return"buffer";if(function(t){try{if("number"==typeof t.length&&"function"==typeof t.callee)return!0}catch(e){if(-1!==e.message.indexOf("callee"))return!0}return!1}(r))return"arguments";if(function(t){return t instanceof Date||"function"==typeof t.toDateString&&"function"==typeof t.getDate&&"function"==typeof t.setDate}(r))return"date";if(function(t){return t instanceof Error||"string"==typeof t.message&&t.constructor&&"number"==typeof t.constructor.stackTraceLimit}(r))return"error";if(function(t){return t instanceof RegExp||"string"==typeof t.flags&&"boolean"==typeof t.ignoreCase&&"boolean"==typeof t.multiline&&"boolean"==typeof t.global}(r))return"regexp";switch(o(r)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(function(t){return"function"==typeof t.throw&&"function"==typeof t.return&&"function"==typeof t.next}(r))return"generator";switch(a=e.call(r)){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return a.slice(8,-1).toLowerCase().replace(/\s/g,"")};function o(t){return t.constructor?t.constructor.name:null}function a(t,e){var o=2=1,k=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(y)||x,$="undefined"!==typeof window&&"undefined"!==typeof document;function E(t,e=document){return e.querySelector(t)}function T(t,e=document){return Array.from(e.querySelectorAll(t))}function C(t,e){return t.classList.add(e)}function z(t,e){return t.classList.remove(e)}function L(t,e){return t.classList.contains(e)}function S(t,e){return e instanceof Element?t.appendChild(e):t.insertAdjacentHTML("beforeend",String(e)),t.lastElementChild||t.lastChild}function M(t){return t.parentNode.removeChild(t)}function P(t,e,r){return t.style[e]=r,t}function A(t,e){for(const r in e)P(t,r,e[r]);return t}function I(t){return Array.from(t.parentElement.children).filter(e=>e!==t)}function O(t,e){I(t).forEach(t=>z(t,e)),C(t,e)}function R(t,e,r="top"){k||(t.setAttribute("aria-label",e),C(t,"hint--rounded"),C(t,`hint--${r}`))}function _(t,e=0){const r=t.getBoundingClientRect(),o=window.innerHeight||document.documentElement.clientHeight,a=window.innerWidth||document.documentElement.clientWidth,n=r.top-e<=o&&r.top+r.height+e>=0,i=r.left-e<=a+e&&r.left+r.width+e>=0;return n&&i}function V(t,e){return j(t).includes(e)}function Y(t,e){return e.parentNode.replaceChild(t,e),t}function N(t){return document.createElement(t)}function D(t="",e=""){const r=N("i");return C(r,"art-icon"),C(r,`art-icon-${t}`),S(r,e),r}function F(t,e){let r=document.getElementById(t);r||(r=document.createElement("style"),r.id=t,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{document.head.appendChild(r)}):(document.head||document.documentElement).appendChild(r)),r.textContent=e}function H(){const t=document.createElement("div");return t.style.display="flex","flex"===t.style.display}function B(t){return t.getBoundingClientRect()}function W(t,e){return new Promise((r,o)=>{const a=new Image;a.onload=function(){if(e&&1!==e){const n=document.createElement("canvas"),i=n.getContext("2d");n.width=a.width*e,n.height=a.height*e,i.drawImage(a,0,0,n.width,n.height),n.toBlob(e=>{const a=URL.createObjectURL(e),n=new Image;n.onload=function(){r(n)},n.onerror=function(){URL.revokeObjectURL(a),o(new Error(`Image load failed: ${t}`))},n.src=a})}else r(a)},a.onerror=function(){o(new Error(`Image load failed: ${t}`))},a.src=t})}function j(t){if(t.composedPath)return t.composedPath();const e=[];let r=t.target;for(;r;)e.push(r),r=r.parentNode;return e.includes(window)||void 0===window||e.push(window),e}function U(){const t=document.createElement("div");t.style.cssText="position:fixed;top:env(safe-area-inset-top,0px);right:env(safe-area-inset-right,0px);bottom:env(safe-area-inset-bottom,0px);left:env(safe-area-inset-left,0px);pointer-events:none;visibility:hidden;",document.body.appendChild(t);const e=getComputedStyle(t),r={top:Number.parseFloat(e.top)||0,right:Number.parseFloat(e.right)||0,bottom:Number.parseFloat(e.bottom)||0,left:Number.parseFloat(e.left)||0};return t.remove(),r}class q extends Error{constructor(t,e){super(t),"captureStackTrace"in Error&&"function"===typeof Error.captureStackTrace&&Error.captureStackTrace(this,e||this.constructor),this.name="ArtPlayerError"}}function X(t,e){if(!t)throw new q(e);return t}function G(t){const e=t;return e&&"function"===typeof e.catch?e.catch(()=>{}):t}function K(t){const e=t.search(/[?#]/),r=(e<0?t:t.slice(0,e)).trim().toLowerCase();return r.slice(r.lastIndexOf(".")+1)}function Z(t,e){const r=document.createElement("a");r.style.display="none",r.href=t,r.download=e,document.body.appendChild(r);try{r.click()}finally{r.remove()}}function J(t,e,r){return Math.max(Math.min(t,Math.max(e,r)),Math.min(e,r))}function Q(t){return t.charAt(0).toUpperCase()+t.slice(1)}function tt(t){if(!t)return"00:00";const e=Math.floor(t/3600),r=Math.floor((t-3600*e)/60),o=Math.floor(t-3600*e-60*r);return(e>0?[e,r,o]:[r,o]).map(t=>t<10?`0${t}`:String(t)).join(":")}const et={"&":"&","<":"<",">":">","'":"'",'"':"""},rt={"&":"&","<":"<",">":">","'":"'",""":'"'},ot=/(&|<|>|'|")/g;function at(t){return t.replace(/[&<>'"]/g,t=>et[t]||t)}const nt=Object.defineProperty,{hasOwnProperty:it}=Object.prototype;function st(t,e){return it.call(t,e)}function lt(t,e){return Object.getOwnPropertyDescriptor(t,e)}function ct(...t){const e=t=>!!t&&"object"===typeof t&&!Array.isArray(t);return t.reduce((t,r)=>(Object.keys(r).forEach(o=>{const a=t[o],n=r[o];let i;i=Array.isArray(a)&&Array.isArray(n)?a.concat(...n):e(a)&&e(n)?ct(a,n):n,nt(t,o,{value:i,enumerable:!0,configurable:!0,writable:!0})}),t),{})}function dt(t){return"WEBVTT \r\n\r\n".concat((e=t,e.replace(/(\d\d:\d\d:\d\d)[,.](\d+)/g,(t,e,r)=>{let o=r.slice(0,3);return 1===r.length&&(o=`${r}00`),2===r.length&&(o=`${r}0`),`${e},${o}`})).replace(/\{\\([ibu])\}/g,"").replace(/\{\\([ibu])1\}/g,"<$1>").replace(/\{([ibu])\}/g,"<$1>").replace(/\{\/([ibu])\}/g,"").replace(/(\d\d:\d\d:\d\d),(\d\d\d)/g,"$1.$2").replace(/\{[\s\S]*?\}/g,"").concat("\r\n\r\n"));var e}function pt(t){return URL.createObjectURL(new Blob([t],{type:"text/vtt"}))}function ht(t){const e=new RegExp("Dialogue:\\s\\d,(\\d+:\\d\\d:\\d\\d.\\d\\d),(\\d+:\\d\\d:\\d\\d.\\d\\d),([^,]*),([^,]*),(?:[^,]*,){4}([\\s\\S]*)$","i");function r(t=""){return t.split(/[:.]/).map((t,e,r)=>{if(e===r.length-1){if(1===t.length)return`.${t}00`;if(2===t.length)return`.${t}0`}else if(1===t.length)return(0===e?"0":":0")+t;return 0===e?t:e===r.length-1?`.${t}`:`:${t}`}).join("")}return`WEBVTT\n\n${t.split(/\r?\n/).map(t=>{const o=t.match(e);if(!o)return null;const[,a="",n="",,,i=""]=o;return{start:r(a.trim()),end:r(n.trim()),text:i.replace(/\{[\s\S]*?\}/g,"").replace(/(\\N)/g,"\n").trim().split(/\r?\n/).map(t=>t.trim()).join("\n")}}).filter(t=>t).map((t,e)=>t?`${e+1}\n${t.start} --\x3e ${t.end}\n${t.text}`:"").filter(t=>t.trim()).join("\n\n")}`}function ut(t,e){let r=!1;return function(...o){r||(t.apply(this,o),r=!0,setTimeout(()=>{r=!1},e))}}const mt=Object.freeze(Object.defineProperty({__proto__:null,ArtPlayerError:q,addClass:C,append:S,assToVtt:ht,capitalize:Q,clamp:J,createElement:N,debounce:function(t,e){let r;return function(...o){clearTimeout(r),r=setTimeout(()=>(r=void 0,t.apply(this,o)),e)}},def:nt,download:Z,errorHandle:X,escape:at,get:lt,getComposedPath:j,getExt:K,getIcon:D,getRect:B,getSafeAreaInsets:U,getStyle:function(t,e,r=!0){const o=window.getComputedStyle(t,null).getPropertyValue(e);return r?Number.parseFloat(o):o},has:st,hasClass:L,includeFromEvent:V,inverseClass:O,isBrowser:$,isIOS:w,isIOS13:x,isInViewport:_,isMobile:k,isSafari:b,loadImg:W,mergeDeep:ct,query:E,queryAll:T,remove:M,removeClass:z,replaceElement:Y,secondToTime:tt,setStyle:P,setStyleText:F,setStyles:A,siblings:I,silencePromise:G,sleep:function(t=0){return new Promise(e=>setTimeout(e,t))},srtToVtt:dt,supportsFlex:H,throttle:ut,tooltip:R,unescape:function(t){return t.replace(ot,t=>rt[t]||t)},userAgent:y,vttToBlob:pt},Symbol.toStringTag,{value:"Module"})),ft="array",gt="boolean",vt="string",yt="number",bt="object",wt="function";function xt(t,e,r){return X(e===vt||e===yt||t instanceof Element,`${r.join(".")} require '${vt}' or 'Element' type`)}const kt={html:xt,disable:`?${gt}`,name:`?${vt}`,index:`?${yt}`,style:`?${bt}`,click:`?${wt}`,mounted:`?${wt}`,tooltip:`?${vt}|${yt}`,width:`?${yt}`,selector:`?${ft}`,onSelect:`?${wt}`,switch:`?${gt}`,onSwitch:`?${wt}`,range:`?${ft}`,onRange:`?${wt}`,onChange:`?${wt}`},$t={id:vt,container:xt,url:vt,poster:vt,type:vt,theme:vt,lang:vt,volume:yt,isLive:gt,muted:gt,autoplay:gt,autoSize:gt,autoMini:gt,loop:gt,flip:gt,playbackRate:gt,aspectRatio:gt,screenshot:gt,setting:gt,hotkey:gt,pip:gt,mutex:gt,backdrop:gt,fullscreen:gt,fullscreenWeb:gt,subtitleOffset:gt,miniProgressBar:gt,useSSR:gt,playsInline:gt,lock:gt,gesture:gt,fastForward:gt,autoPlayback:gt,autoOrientation:gt,airplay:gt,proxy:`?${wt}`,plugins:[wt],layers:[kt],contextmenu:[kt],settings:[kt],controls:[c(l({},kt),{position:(t,e,r)=>{const o=["top","left","right"];return X("string"===typeof t&&o.includes(t),`${r.join(".")} only accept ${o.toString()} as parameters`)}})],quality:[{default:`?${gt}`,html:vt,url:vt}],highlight:[{time:yt,text:vt}],thumbnails:{url:vt,number:yt,column:yt,width:yt,height:yt,scale:yt},subtitle:{url:vt,name:vt,type:vt,style:bt,escape:gt,encoding:vt,onVttLoad:wt},moreVideoAttr:bt,i18n:bt,icons:bt,cssVar:bt,customType:bt};class Et{constructor(t){this.id=0,this.art=t,this.cache=new Map,this.add=this.add.bind(this),this.remove=this.remove.bind(this),this.update=this.update.bind(this)}get show(){return L(this.art.template.$player,`art-${this.name}-show`)}set show(t){const{$player:e}=this.art.template,r=`art-${this.name}-show`;t?C(e,r):z(e,r),this.art.emit(this.name,t)}toggle(){this.show=!this.show}add(t){const e="function"===typeof t?t(this.art):t;if(e.html=e.html||"",f(e,kt),!this.$parent||!this.name||e.disable)return;const r=e.name||`${this.name}${this.id}`;X(!this.cache.has(r),`Can't add an existing [${r}] to the [${this.name}]`),this.id+=1;const o=N("div");C(o,`art-${this.name}`),C(o,`art-${this.name}-${r}`);const a=Array.from(this.$parent.children);o.dataset.index=e.index||this.id;const n=a.find(t=>Number(t.dataset.index)>=Number(o.dataset.index));n?n.insertAdjacentElement("beforebegin",o):S(this.$parent,o),e.html&&S(o,e.html),e.style&&A(o,e.style),e.tooltip&&R(o,e.tooltip);const i=[];if(e.click){const t=this.art.events.proxy(o,"click",t=>{t.preventDefault(),e.click.call(this.art,this,t)});i.push(t)}return e.selector&&["left","right"].includes(e.position)&&this.selector(e,o,i),this[r]=o,this.cache.set(r,{$ref:o,events:i,option:e}),e.mounted&&e.mounted.call(this.art,o),o}remove(t){X(this.cache.has(t),`Can't find [${t}] from the [${this.name}]`);const e=this.cache.get(t);e.option.beforeUnmount&&e.option.beforeUnmount.call(this.art,e.$ref);for(const r of e.events)this.art.events.remove(r);this.cache.delete(t),delete this[t],M(e.$ref)}update(t){if(this.cache.has(t.name)){const e=this.cache.get(t.name);t=Object.assign(e.option,t),this.remove(t.name)}return this.add(t)}}class Tt extends Et{constructor(t){super(t),this.name="contextmenu",this.$parent=t.template.$contextmenu,k||this.init()}init(){const{option:t,proxy:e,template:{$player:r,$contextmenu:o}}=this.art;t.playbackRate&&this.add(function(t){return e=>{const{i18n:r,constructor:{PLAYBACK_RATE:o}}=e,a=o.map(t=>`${1===t?r.get("Normal"):t.toFixed(1)}`).join("");return c(l({},t),{html:`${r.get("Play Speed")}: ${a}`,click:(t,r)=>{const{value:o}=r.target.dataset;o&&(e.playbackRate=Number(o),t.show=!1)},mounted:t=>{const r=E('[data-value="1"]',t);r&&O(r,"art-current"),e.on("video:ratechange",()=>{const r=T("span",t).find(t=>Number(t.dataset.value)===e.playbackRate);r&&O(r,"art-current")})}})}}({name:"playbackRate",index:10})),t.aspectRatio&&this.add(function(t){return e=>{const{i18n:r,constructor:{ASPECT_RATIO:o}}=e,a=o.map(t=>`${"default"===t?r.get("Default"):t}`).join("");return c(l({},t),{html:`${r.get("Aspect Ratio")}: ${a}`,click:(t,r)=>{const{value:o}=r.target.dataset;o&&(e.aspectRatio=o,t.show=!1)},mounted:t=>{const r=E('[data-value="default"]',t);r&&O(r,"art-current"),e.on("aspectRatio",e=>{const r=T("span",t).find(t=>t.dataset.value===e);r&&O(r,"art-current")})}})}}({name:"aspectRatio",index:20})),t.flip&&this.add(function(t){return e=>{const{i18n:r,constructor:{FLIP:o}}=e,a=o.map(t=>`${r.get(Q(t))}`).join("");return c(l({},t),{html:`${r.get("Video Flip")}: ${a}`,click:(t,r)=>{const{value:o}=r.target.dataset;o&&(e.flip=o.toLowerCase(),t.show=!1)},mounted:t=>{const r=E('[data-value="normal"]',t);r&&O(r,"art-current"),e.on("flip",e=>{const r=T("span",t).find(t=>t.dataset.value===e);r&&O(r,"art-current")})}})}}({name:"flip",index:30})),this.add(function(t){return e=>c(l({},t),{html:e.i18n.get("Video Info"),click:t=>{e.info.show=!0,t.show=!1}})}({name:"info",index:40})),this.add(function(t){return c(l({},t),{html:`ArtPlayer ${g}`})}({name:"version",index:50})),this.add(function(t){return e=>c(l({},t),{html:e.i18n.get("Close"),click:t=>{t.show=!1}})}({name:"close",index:60}));for(let a=0;a{if(!this.art.constructor.CONTEXTMENU)return;t.preventDefault(),this.show=!0;const e=t.clientX,a=t.clientY,{height:n,width:i,left:s,top:l}=B(r),{height:c,width:d}=B(o);let p=e-s,h=a-l;e+d>s+i&&(p=i-d),a+c>l+n&&(h=n-c),A(o,{top:`${h}px`,left:`${p}px`})}),e(r,"click",t=>{V(t,o)||(this.show=!1)}),this.art.on("blur",()=>{this.show=!1})}}class Ct extends Error{constructor(t){super("Failed to release ArtPlayer resources"),this.errors=t,this.name="ResourceCleanupError"}}class zt{constructor(){this.cleanups=new Set,this.disposed=!1}get closed(){return this.disposed}add(t){let e=!0;const r=()=>{e&&(e=!1,this.cleanups.delete(r),t())};return this.closed?r():this.cleanups.add(r),r}child(){const t=new zt,e=this.add(()=>{t.dispose()});return t.add(()=>{e()}),t}dispose(){if(this.closed)return;this.disposed=!0;const t=[];for(const r of Array.from(this.cleanups).reverse())try{r()}catch(e){e instanceof Ct?t.push(...e.errors):t.push(e)}if(t.length)throw new Ct(t)}}const Lt=new WeakMap,St=new WeakMap;function Mt(t){const e=Lt.get(t);if(!e)throw new Error("ArtPlayer lifecycle has not been initialized");return e}function Pt(t){return Mt(t).scope}function At(t){const e=Mt(t);return e.destroying||e.scope.closed}function It(t,e,r,o,a=!1){var n,i,s;const l=Mt(t);if(l.destroying||l.scope.closed)return;l.destroying=!0;const c=[],d=t=>{try{t()}catch(e){c.push(...e instanceof Ct?e.errors:[e])}};o&&(null==(n=t.template)?void 0:n.$video)&&d(()=>t.reset()),d(()=>l.scope.dispose()),d(()=>{var e;return null==(e=t.template)?void 0:e.destroy(r)});const p=e.indexOf(t);-1!==p&&e.splice(p,1),t.isDestroy=!0,a||(null==(i=l.releaseContainer)||i.call(l),l.releaseContainer=void 0),d(()=>t.emit("destroy")),a&&l.rollback&&d(l.rollback),l.rollback=void 0,null==(s=l.releaseContainer)||s.call(l),l.releaseContainer=void 0;for(const h of c.slice(1))console.warn("Additional ArtPlayer cleanup failure:",h);if(c.length)throw c[0]}function Ot(t,e,r){if(t.closed)return()=>{};let o=!0,a=()=>{};const n=setTimeout(()=>{o&&(a(),t.closed||e())},r);return a=t.add(()=>{o=!1,clearTimeout(n)}),a}function Rt(t,e=0){return t.closed?Promise.resolve(!1):new Promise(r=>{let o=!1,a=()=>{};const n=setTimeout(()=>{o=!0,a(),r(!0)},e);a=t.add(()=>{clearTimeout(n),o||r(!1)})})}function _t(t,e){const{$progress:r}=t.template,{left:o}=B(r),a=J((k?e.touches[0].clientX:e.clientX)-o,0,r.clientWidth),n=a/r.clientWidth*t.duration;return{second:n,time:tt(n),width:a,percentage:J(a/r.clientWidth,0,1)}}function Vt(t,e){if(t.isRotate){const r=(e.touches[0].clientY-t.top)/t.height,o=r*t.duration;t.emit("setBar","played",r,e),t.seek=o}else{const{second:r,percentage:o}=_t(t,e);t.emit("setBar","played",o,e),t.seek=r}}function Yt(t){return e=>{const{icons:r,option:o,proxy:a}=e,{$player:n,$progress:i}=e.template;return c(l({},t),{html:'\n
\n
\n
\n
\n
\n
\n
00:00
\n
\n ',mounted:t=>{let s=null,l=!1;const c=E(".art-progress-hover",t),d=E(".art-progress-loaded",t),p=E(".art-progress-played",t),h=E(".art-progress-highlight",t),u=E(".art-progress-indicator",t),m=E(".art-progress-tip",t);function f(r,o){const{width:a,time:n}=o||_t(e,r);m.textContent=n||"00:00";const i=m.clientWidth;a<=i/2?P(m,"left",0):a>t.clientWidth-i/2?P(m,"left",t.clientWidth-i+"px"):P(m,"left",a-i/2+"px")}r.indicator?S(u,r.indicator):P(u,"backgroundColor","var(--art-theme)"),e.on("setBar",function(r,o,a){const i="played"===r&&a&&k;if("loaded"===r&&P(d,"width",100*o+"%"),"hover"===r&&(P(c,"width",100*o+"%"),V(a,h)?function(r){const{width:o}=_t(e,r),{text:a}=r.target.dataset;m.textContent=a;const n=m.clientWidth;o<=n/2?P(m,"left",0):o>t.clientWidth-n/2?P(m,"left",t.clientWidth-n+"px"):P(m,"left",o-n/2+"px")}(a):f(a),0===o?z(n,"art-progress-hover"):C(n,"art-progress-hover")),"played"===r&&(P(p,"width",100*o+"%"),P(u,"left",100*o+"%")),i){C(n,"art-progress-hover");f(a,{width:t.clientWidth*o,time:tt(o*e.duration)}),clearTimeout(s),s=setTimeout(()=>{z(n,"art-progress-hover")},500)}}),e.on("video:loadedmetadata",function(){h.textContent="";for(let t=0;t`;S(h,n)}}),e.constructor.USE_RAF?e.on("raf",()=>{e.emit("setBar","played",e.played),e.emit("setBar","loaded",e.loaded)}):(e.on("video:timeupdate",()=>{e.emit("setBar","played",e.played)}),e.on("video:progress",()=>{e.emit("setBar","loaded",e.loaded)}),e.on("video:ended",()=>{e.emit("setBar","played",1)})),e.emit("setBar","loaded",e.loaded||0),k||(a(i,"click",t=>{t.target!==u&&Vt(e,t)}),a(i,"mousemove",t=>{const{percentage:r}=_t(e,t);e.emit("setBar","hover",r,t)}),a(i,"mouseleave",t=>{e.emit("setBar","hover",0,t)}),a(i,"mousedown",t=>{l=0===t.button}),e.on("document:mousemove",t=>{if(l){const{second:r,percentage:o}=_t(e,t);e.emit("setBar","played",o,t),e.seek=r}}),e.on("document:mouseup",()=>{l&&(l=!1)}))}})}}class Nt extends Et{constructor(t){super(t),this.isHover=!1,this.name="control",this.timer=Date.now();const{constructor:e}=t,{$player:r,$bottom:o}=this.art.template;t.on("mousemove",()=>{k||(this.show=!0)}),t.on("click",()=>{k?this.toggle():this.show=!0}),t.on("document:mousemove",t=>{this.isHover=V(t,o)}),t.on("video:timeupdate",()=>{!t.setting.show&&!this.isHover&&!t.isInput&&t.playing&&this.show&&Date.now()-this.timer>=e.CONTROL_HIDE_TIME&&(this.show=!1)}),t.on("control",t=>{t?(z(r,"art-hide-cursor"),C(r,"art-hover"),this.timer=Date.now()):(C(r,"art-hide-cursor"),z(r,"art-hover"))}),this.init()}init(){const{option:t}=this.art;t.isLive||this.add(Yt({name:"progress",position:"top",index:10})),this.add({name:"thumbnails",position:"top",index:20}),this.add(function(t){return e=>c(l({},t),{mounted:t=>{const{proxy:r,icons:o,i18n:a}=e,n=S(t,o.play),i=S(t,o.pause);function s(){P(n,"display","flex"),P(i,"display","none")}function l(){P(n,"display","none"),P(i,"display","flex")}R(n,a.get("Play")),R(i,a.get("Pause")),r(n,"click",()=>{G(e.play())}),r(i,"click",()=>{e.pause()}),e.playing?l():s(),e.on("video:playing",()=>{l()}),e.on("video:pause",()=>{s()})}})}({name:"playAndPause",position:"left",index:10})),this.add(function(t){return e=>c(l({},t),{mounted:t=>{const{proxy:r,icons:o}=e,a=S(t,o.volume),n=S(t,o.volumeClose),i=S(t,'
'),s=S(i,'
'),l=S(s,'
'),c=S(s,'
'),d=S(c,'
'),p=S(d,'
'),h=S(c,'
');function u(t){const{top:e,height:r}=B(c);return 1-(t.clientY-e)/r}function m(){if(e.muted||0===e.volume)P(a,"display","none"),P(n,"display","flex"),P(h,"top","100%"),P(p,"top","100%"),l.textContent=0;else{const t=100*e.volume;P(a,"display","flex"),P(n,"display","none"),P(h,"top",100-t+"%"),P(p,"top",100-t+"%"),l.textContent=Math.floor(t)}}if(m(),e.on("video:volumechange",m),r(a,"click",()=>{e.muted=!0}),r(n,"click",()=>{e.muted=!1}),k)P(i,"display","none");else{let t=!1;r(c,"mousedown",r=>{t=0===r.button,e.volume=u(r)}),e.on("document:mousemove",r=>{t&&(e.muted=!1,e.volume=u(r))}),e.on("document:mouseup",()=>{t&&(t=!1)})}}})}({name:"volume",position:"left",index:20})),t.isLive||this.add(function(t){return e=>c(l({},t),{style:k?{fontSize:"12px",padding:"0 5px"}:{cursor:"auto",padding:"0 10px"},mounted:t=>{function r(){const r=`${tt(e.currentTime)} / ${tt(e.duration)}`;r!==t.textContent&&(t.textContent=r)}r();const o=["video:loadedmetadata","video:timeupdate","video:progress"];for(let a=0;a{e&&!Pt(this.art).closed&&(this.art.quality=t.quality)}),t.screenshot&&!k&&this.add(function(t){return e=>c(l({},t),{tooltip:e.i18n.get("Screenshot"),mounted:t=>{const{proxy:r,icons:o}=e;S(t,o.screenshot),r(t,"click",()=>{e.screenshot()})}})}({name:"screenshot",position:"right",index:20})),t.setting&&this.add(function(t){return e=>c(l({},t),{tooltip:e.i18n.get("Show Setting"),mounted:t=>{const{proxy:r,icons:o,i18n:a}=e;S(t,o.setting),r(t,"click",()=>{e.setting.toggle(),e.setting.resize()}),e.on("setting",e=>{R(t,a.get(e?"Hide Setting":"Show Setting"))})}})}({name:"setting",position:"right",index:30})),t.pip&&this.add(function(t){return e=>c(l({},t),{tooltip:e.i18n.get("PIP Mode"),mounted:t=>{const{proxy:r,icons:o,i18n:a}=e;S(t,o.pip),r(t,"click",()=>{e.pip=!e.pip}),e.on("pip",e=>{R(t,a.get(e?"Exit PIP Mode":"PIP Mode"))})}})}({name:"pip",position:"right",index:40})),t.airplay&&window.WebKitPlaybackTargetAvailabilityEvent&&this.add(function(t){return e=>c(l({},t),{tooltip:e.i18n.get("AirPlay"),mounted:t=>{const{proxy:r,icons:o}=e;S(t,o.airplay),r(t,"click",()=>e.airplay())}})}({name:"airplay",position:"right",index:50})),t.fullscreenWeb&&this.add(function(t){return e=>c(l({},t),{tooltip:e.i18n.get("Web Fullscreen"),mounted:t=>{const{proxy:r,icons:o,i18n:a}=e,n=S(t,o.fullscreenWebOn),i=S(t,o.fullscreenWebOff);P(i,"display","none"),r(t,"click",()=>{e.fullscreenWeb=!e.fullscreenWeb}),e.on("fullscreenWeb",e=>{e?(R(t,a.get("Exit Web Fullscreen")),P(n,"display","none"),P(i,"display","inline-flex")):(R(t,a.get("Web Fullscreen")),P(n,"display","inline-flex"),P(i,"display","none"))})}})}({name:"fullscreenWeb",position:"right",index:60})),t.fullscreen&&this.add(function(t){return e=>c(l({},t),{tooltip:e.i18n.get("Fullscreen"),mounted:t=>{const{proxy:r,icons:o,i18n:a}=e,n=S(t,o.fullscreenOn),i=S(t,o.fullscreenOff);P(i,"display","none"),r(t,"click",()=>{e.fullscreen=!e.fullscreen}),e.on("fullscreen",e=>{e?(R(t,a.get("Exit Fullscreen")),P(n,"display","none"),P(i,"display","inline-flex")):(R(t,a.get("Fullscreen")),P(n,"display","inline-flex"),P(i,"display","none"))})}})}({name:"fullscreen",position:"right",index:70}));for(let e=0;et.selector}),nt(e,"$control_item",{get:()=>r}),nt(e,"$control_value",{get:()=>a})}const i=o(n,"click",e=>d(this,null,function*(){const r=j(e),o=t.selector.find(t=>t.$control_item===r.find(e=>t.$control_item===e));this.check(o),t.onSelect&&(a.innerHTML=yield t.onSelect.call(this.art,o,o.$control_item,e))}));r.push(i)}}function Dt(t,e,r,o){const a=e-o,n=r-t;let i=0;if(Math.abs(n)<2&&Math.abs(a)<2)return i;const s=function(t,e){return 180*Math.atan2(e,t)/Math.PI}(n,a);return s>=-45&&s<45?i=4:s>=45&&s<135?i=1:s>=-135&&s<-45?i=2:(s>=135&&s<=180||s>=-180&&s<-135)&&(i=3),i}function Ft(t){if(t.constructor.USE_RAF){const e=Pt(t);let r=()=>{};!function o(){t.playing&&t.emit("raf"),t.isDestroy||(r=function(t,e){if(t.closed)return()=>{};let r=!0,o=()=>{};const a=requestAnimationFrame(a=>{r&&(o(),t.closed||e(a))});return o=t.add(()=>{r=!1,cancelAnimationFrame(a)}),o}(e,o))}(),t.on("destroy",()=>{r()})}}const Ht=new WeakMap;class Bt{constructor(t){this.destroyEvents=new Set;const e=Pt(t);Ht.set(this,e),e.add(()=>this.destroy()),this.proxy=this.proxy.bind(this),this.hover=this.hover.bind(this),function(t,e){const{constructor:r,template:{$player:o,$video:a}}=t;function n(e){V(e,o)?(t.isInput="INPUT"===e.target.tagName,t.isFocus=!0,t.emit("focus",e)):(t.isInput=!1,t.isFocus=!1,t.emit("blur",e))}t.on("document:click",n),t.on("document:contextmenu",n);let i=[];e.proxy(a,"click",e=>{const o=Date.now();i.push(o);const{MOBILE_CLICK_PLAY:a,DBCLICK_TIME:n,MOBILE_DBCLICK_PLAY:s,DBCLICK_FULLSCREEN:l}=r,c=i.filter(t=>o-t<=n);switch(c.length){case 1:t.emit("click",e),k?!t.isLock&&a&&G(t.toggle()):G(t.toggle()),i=c;break;case 2:t.emit("dblclick",e),k?!t.isLock&&s&&G(t.toggle()):l&&(t.fullscreen=!t.fullscreen),i=[];break;default:i=[]}})}(t,this),function(t,e){const{$player:r}=t.template;e.hover(r,e=>{C(r,"art-hover"),t.emit("hover",!0,e)},e=>{z(r,"art-hover"),t.emit("hover",!1,e)})}(t,this),function(t,e){const{$player:r}=t.template;e.proxy(r,"mousemove",e=>{t.emit("mousemove",e)})}(t,this),function(t,e){const{option:r,constructor:o}=t;t.on("resize",()=>{const{aspectRatio:e,notice:o}=t;"standard"===t.state&&r.autoSize&&t.autoSize(),t.aspectRatio=e,o.show=""});const a=Pt(t);let n=()=>{};const i=()=>{n(),n=Ot(a,()=>t.emit("resize"),o.RESIZE_TIME)};t.on("window:orientationchange",()=>i()),t.on("window:resize",()=>i()),screen&&screen.orientation&&screen.orientation.onchange&&e.proxy(screen.orientation,"change",()=>i())}(t,this),function(t,e){if(k&&!t.option.isLive){const{$video:r,$progress:o}=t.template;let a=null,n=!1,i=0,s=0,l=0;const c=e=>{if(1===e.touches.length&&!t.isLock){a===o&&Vt(t,e),n=!0;const{pageX:r,pageY:c}=e.touches[0];i=r,s=c,l=t.currentTime}},d=e=>{if(1===e.touches.length&&n&&t.duration){const{pageX:o,pageY:n}=e.touches[0],c=Dt(i,s,o,n),d=[3,4].includes(c),p=[1,2].includes(c);if(d&&!t.isRotate||p&&t.isRotate){const c=J((o-i)/t.width,-1,1),d=J((n-s)/t.height,-1,1),p=t.isRotate?d:c,h=a===r?t.constructor.TOUCH_MOVE_RATIO:1,u=J(l+t.duration*p*h,0,t.duration);t.seek=u,t.emit("setBar","played",J(u/t.duration,0,1),e),t.notice.show=`${tt(u)} / ${tt(t.duration)}`}}},p=()=>{n&&(i=0,s=0,l=0,n=!1,a=null)};t.option.gesture&&(e.proxy(r,"touchstart",t=>{a=r,c(t)}),e.proxy(r,"touchmove",d)),e.proxy(o,"touchstart",t=>{a=o,c(t)}),e.proxy(o,"touchmove",d),t.on("document:touchend",p)}}(t,this),function(t){const{option:e,constructor:r,template:{$container:o}}=t,a=ut(()=>{t.emit("view",_(o,r.SCROLL_GAP))},r.SCROLL_TIME);t.on("window:scroll",()=>a()),t.on("view",r=>{e.autoMini&&(t.mini=!r)})}(t),function(t,e){const r=["click","mouseup","keydown","touchend","touchmove","mousemove","pointerup","contextmenu","pointermove","visibilitychange","webkitfullscreenchange"],o=["resize","scroll","orientationchange"],a=[];function n(n={}){for(let t=0;t{const o=n.document||i.ownerDocument||document,s=e.proxy(o,r,e=>{t.emit(`document:${r}`,e)});a.push(s)}),o.forEach(r=>{var o;const s=n.window||(null==(o=i.ownerDocument)?void 0:o.defaultView)||window,l=e.proxy(s,r,e=>{t.emit(`window:${r}`,e)});a.push(l)})}n(),e.bindGlobalEvents=n}(t,this),Ft(t)}proxy(t,e,r,o={}){if(Array.isArray(e))return e.map(e=>this.proxy(t,e,r,o));if(Ht.get(this).closed)return()=>{};t.addEventListener(e,r,o);const a=()=>t.removeEventListener(e,r,o);return this.destroyEvents.add(a),a}hover(t,e,r){e&&this.proxy(t,"mouseenter",e),r&&this.proxy(t,"mouseleave",r)}remove(t){if(this.destroyEvents.has(t))try{t()}catch(e){console.warn("Failed to remove event listener:",e)}finally{this.destroyEvents.delete(t)}}destroy(){for(const e of this.destroyEvents)try{e()}catch(t){console.warn("Failed to destroy event listener:",t)}this.destroyEvents.clear()}}class Wt{constructor(t){this.art=t,this.keys={},k||this.init()}init(){const{constructor:t}=this.art;this.art.option.hotkey&&(this.add("Escape",()=>{this.art.fullscreenWeb&&(this.art.fullscreenWeb=!1)}),this.add("Space",()=>{G(this.art.toggle())}),this.add("ArrowLeft",()=>{this.art.backward=t.SEEK_STEP}),this.add("ArrowUp",()=>{this.art.volume+=t.VOLUME_STEP}),this.add("ArrowRight",()=>{this.art.forward=t.SEEK_STEP}),this.add("ArrowDown",()=>{this.art.volume-=t.VOLUME_STEP})),this.art.on("document:keydown",t=>{if(this.art.isFocus){const e=document.activeElement.tagName.toUpperCase(),r=document.activeElement.getAttribute("contenteditable");if("INPUT"!==e&&"TEXTAREA"!==e&&""!==r&&"true"!==r&&!t.altKey&&!t.ctrlKey&&!t.metaKey&&!t.shiftKey){const e=this.keys[t.code];if(e){t.preventDefault();for(let r=0;r\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n',state:'\r\n\r\n\r\n',play:'\r\n \r\n',pause:'\r\n \r\n',check:'\r\n\r\n',volume:'\r\n \r\n \r\n',volumeClose:'\r\n \r\n \r\n',screenshot:'\r\n\t\r\n\r\n',setting:'\r\n \r\n \r\n',pip:'\r\n\r\n',arrowLeft:'\r\n \r\n',arrowRight:'\r\n \r\n',playbackRate:'',aspectRatio:'',config:'',lock:'\r\n\r\n\r\n\r\n\r\n',flip:'\r\n\r\n\r\n\r\n\r\n\r\n',unlock:'\r\n\r\n\r\n',fullscreenOff:'\r\n\r\n\r\n\r\n\r\n',fullscreenOn:'\r\n\r\n\r\n\r\n\r\n',fullscreenWebOff:'\r\n\r\n\r\n\r\n\r\n',fullscreenWebOn:'\r\n\r\n\r\n\r\n\r\n',switchOn:'\r\n\r\n\r\n \r\n',switchOff:'\r\n\r\n\r\n \r\n\r\n',error:'\r\n\r\n\r\n\r\n\r\n',close:'\r\n\r\n\r\n\r\n\r\n',airplay:'\r\n \r\n \r\n \r\n \r\n\r\n'},t.option.icons);for(const r in e)nt(this,r,{get:()=>D(r,e[r])})}}class Xt extends Et{constructor(t){super(t),this.name="info",k||this.init()}init(){const{proxy:t,constructor:e,template:{$infoPanel:r,$infoClose:o,$video:a}}=this.art;t(o,"click",()=>{this.show=!1});let n=()=>{};const i=T("[data-video]",r)||[];this.art.on("destroy",()=>n());const s=Pt(this.art);!function t(){for(let e=0;e{P(a,"display","none"),P(n,"display",null)}),o.proxy(e.$state,"click",()=>G(t.play()))}}class Jt{constructor(t){this.art=t,this.timer=null,Pt(t).add(()=>this.destroy()),t.on("destroy",()=>this.destroy())}destroy(){this.timer&&(clearTimeout(this.timer),this.timer=null)}set show(t){if(Pt(this.art).closed)return;const{constructor:e,template:{$player:r,$noticeInner:o}}=this.art;t?(o.textContent=t instanceof Error?t.message.trim():t,C(r,"art-notice-show"),clearTimeout(this.timer),this.timer=setTimeout(()=>{o.textContent="",z(r,"art-notice-show")},e.NOTICE_TIME)):z(r,"art-notice-show")}get show(){const{template:{$player:t}}=this.art;return t.classList.contains("art-notice-show")}}const Qt=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],te=(()=>{if("undefined"===typeof document)return!1;const t=Qt[0],e={};for(const r of Qt){if(r[1]in document){for(const[o,a]of r.entries())e[t[o]]=a;return e}}return!1})(),ee={change:te.fullscreenchange,error:te.fullscreenerror},re={request:(t=document.documentElement,e)=>new Promise((r,o)=>{const a=()=>{re.off("change",a),r()};re.on("change",a);const n=t[te.requestFullscreen](e);n instanceof Promise&&n.then(a).catch(o)}),exit:()=>new Promise((t,e)=>{if(!re.isFullscreen)return void t();const r=()=>{re.off("change",r),t()};re.on("change",r);const o=document[te.exitFullscreen]();o instanceof Promise&&o.then(r).catch(e)}),toggle:(t,e)=>re.isFullscreen?re.exit():re.request(t,e),onchange(t){re.on("change",t)},onerror(t){re.on("error",t)},on(t,e){const r=ee[t];r&&document.addEventListener(r,e,!1)},off(t,e){const r=ee[t];r&&document.removeEventListener(r,e,!1)},raw:te};function oe(t){const{i18n:e,notice:r,template:{$video:o,$player:a}}=t,n=t=>{re.on("change",()=>{t.emit("fullscreen",re.isFullscreen),re.isFullscreen?(t.state="fullscreen",C(a,"art-fullscreen")):z(a,"art-fullscreen"),t.emit("resize")}),re.on("error",e=>{t.emit("fullscreenError",e)}),nt(t,"fullscreen",{get:()=>re.isFullscreen,set(t){return d(this,null,function*(){t?yield re.request(a):yield re.exit()})}})};t.once("video:loadedmetadata",()=>{var a;re.isEnabled?n(t):o.webkitSupportsFullscreen?((a=t).on("document:webkitfullscreenchange",()=>{a.emit("fullscreen",a.fullscreen),a.emit("resize")}),nt(a,"fullscreen",{get:()=>document.fullscreenElement===o,set(t){t?(a.state="fullscreen",o.webkitEnterFullscreen()):o.webkitExitFullscreen()}})):nt(t,"fullscreen",{get:()=>!1,set(){r.show=e.get("Fullscreen Not Supported")}}),nt(t,"fullscreen",lt(t,"fullscreen"))})}function ae(t){const{icons:e,proxy:r,storage:o,template:{$player:a,$video:n}}=t;let i=!1,s=0,l=0;function c(){const{$mini:e}=t.template;e&&(z(a,"art-mini"),P(e,"display","none"),a.prepend(n),t.emit("mini",!1))}function d(e,r){t.playing?(P(e,"display","none"),P(r,"display","flex")):(P(e,"display","flex"),P(r,"display","none"))}function p(){const{$mini:e}=t.template,r=B(e),a=window.innerHeight-r.height-50,n=window.innerWidth-r.width-50;o.set("top",a),o.set("left",n),P(e,"top",`${a}px`),P(e,"left",`${n}px`)}nt(t,"mini",{get:()=>L(a,"art-mini"),set(h){if(h){t.state="mini",C(a,"art-mini");const h=function(){const{$mini:a}=t.template;if(a)return S(a,n),P(a,"display","flex");{const a=N("div");C(a,"art-mini-popup"),S(document.body,a),t.template.$mini=a,S(a,n);const p=S(a,'
');S(p,e.close),r(p,"click",c);const h=S(a,'
'),u=S(h,e.play),m=S(h,e.pause);return r(u,"click",()=>G(t.play())),r(m,"click",()=>t.pause()),d(u,m),t.on("video:playing",()=>d(u,m)),t.on("video:pause",()=>d(u,m)),t.on("video:timeupdate",()=>d(u,m)),r(a,"mousedown",t=>{i=0===t.button,s=t.pageX,l=t.pageY}),t.on("document:mousemove",t=>{if(i){C(a,"art-mini-dragging");const e=t.pageX-s,r=t.pageY-l;P(a,"transform",`translate(${e}px, ${r}px)`)}}),t.on("document:mouseup",()=>{if(i){i=!1,z(a,"art-mini-dragging");const t=B(a);o.set("left",t.left),o.set("top",t.top),P(a,"left",`${t.left}px`),P(a,"top",`${t.top}px`),P(a,"transform",null)}}),a}}(),u=o.get("top"),m=o.get("left");"number"===typeof u&&"number"===typeof m?(P(h,"top",`${u}px`),P(h,"left",`${m}px`),_(h)||p()):p(),t.emit("mini",!0)}else c()}})}function ne(t){const{i18n:e,notice:r,template:{$video:o}}=t;document.pictureInPictureEnabled?function(t){const{template:{$video:e},proxy:r,notice:o}=t;e.disablePictureInPicture=!1,nt(t,"pip",{get:()=>document.pictureInPictureElement,set(r){r?(t.state="pip",e.requestPictureInPicture().catch(t=>{throw o.show=t,t})):document.exitPictureInPicture().catch(t=>{throw o.show=t,t})}}),r(e,"enterpictureinpicture",()=>{t.emit("pip",!0)}),r(e,"leavepictureinpicture",()=>{t.emit("pip",!1)})}(t):o.webkitSupportsPresentationMode?function(t){const{$video:e}=t.template;e.webkitSetPresentationMode("inline"),nt(t,"pip",{get:()=>"picture-in-picture"===e.webkitPresentationMode,set(r){r?(t.state="pip",e.webkitSetPresentationMode("picture-in-picture"),t.emit("pip",!0)):(e.webkitSetPresentationMode("inline"),t.emit("pip",!1))}})}(t):nt(t,"pip",{get:()=>!1,set(){r.show=e.get("PIP Not Supported")}})}function ie(t){const{option:e,template:{$progress:r,$video:o}}=t;let a=null,n=!1,i=null;t.on("setBar",(a,s,l)=>d(null,null,function*(){var c;const d=null==(c=t.controls)?void 0:c.thumbnails,{url:p,scale:h}=e.thumbnails;if(!d||!p)return;if("hover"===a||"played"===a&&l&&k){if(i||n||(n=!0,i=yield W(p,h),n=!1),!i)return;const a=r.clientWidth*s;a>0&&ar.clientWidth-u/2?P(s,"left",r.clientWidth-u+"px"):P(s,"left",a-u/2+"px")}(a)}})),nt(t,"thumbnails",{get:()=>t.option.thumbnails,set(e){e.url&&!t.option.isLive&&(t.option.thumbnails=e,clearTimeout(a),a=null,n=!1,i=null)}})}Object.defineProperties(re,{isFullscreen:{get:()=>Boolean(document[te.fullscreenElement])},element:{enumerable:!0,get:()=>document[te.fullscreenElement]},isEnabled:{enumerable:!0,get:()=>Boolean(document[te.fullscreenEnabled])}});class se{constructor(t){!function(t){const{option:e,template:{$video:r}}=t;nt(t,"url",{get:()=>r.src,set(o){return d(this,null,function*(){if(o){const a=t.url,n=e.type||K(o),i=e.customType[n];if(n&&i){if(!(yield Rt(Pt(t)))||Pt(t).closed)return;t.loading.show=!0,i.call(t,r,o,t)}else URL.revokeObjectURL(a),r.src=o;a!==t.url&&(t.option.url=o,t.isReady&&a&&t.once("video:canplay",()=>{t.emit("restart",o)}))}else{if(!(yield Rt(Pt(t)))||Pt(t).closed)return;t.loading.show=!0}})}})}(t),function(t){const{template:{$video:e}}=t;nt(t,"attr",{value(t,r){if(void 0===r)return e[t];e[t]=r}})}(t),function(t){const{i18n:e,notice:r,option:o,constructor:{instances:a},template:{$video:n}}=t;nt(t,"play",{value(){return d(this,null,function*(){const i=yield n.play();if(r.show=e.get("Play"),t.emit("play"),o.mutex)for(let e=0;et.playing?t.pause():t.play()})}(t),function(t){const{notice:e}=t;nt(t,"seek",{set(r){t.currentTime=r,t.duration&&(e.show=`${tt(t.currentTime)} / ${tt(t.duration)}`),t.emit("seek",t.currentTime,r)}}),nt(t,"forward",{set(e){t.seek=t.currentTime+e}}),nt(t,"backward",{set(e){t.seek=t.currentTime-e}})}(t),function(t){const{template:{$video:e},i18n:r,notice:o,storage:a}=t;nt(t,"volume",{get:()=>e.volume||0,set:t=>{e.volume=J(t,0,1),o.show=`${r.get("Volume")}: ${Number.parseInt(100*e.volume,10)}`,0!==e.volume&&a.set("volume",e.volume)}}),nt(t,"muted",{get:()=>e.muted,set:r=>{e.muted=r,t.emit("muted",r)}})}(t),function(t){const{$video:e}=t.template;nt(t,"currentTime",{get:()=>e.currentTime||0,set:r=>{r=Number.parseFloat(r),Number.isNaN(r)||(e.currentTime=J(r,0,t.duration))}})}(t),function(t){nt(t,"duration",{get:()=>{const{duration:e}=t.template.$video;return e===1/0?0:e||0}})}(t),function(t){function e(e,r){return new Promise((o,a)=>{if(e===t.url)return void o();const{playing:n,aspectRatio:i,playbackRate:s}=t;t.pause(),t.url=e,t.notice.show="";const l={error:e=>{t.off("video:canplay",l.canplay),t.off("video:loadedmetadata",l.metadata),a(e)},metadata:()=>{t.currentTime=r},canplay:()=>d(null,null,function*(){t.off("video:error",l.error),t.playbackRate=s,t.aspectRatio=i,n&&(yield G(t.play())),t.notice.show="",o()})};t.once("video:error",l.error),t.once("video:loadedmetadata",l.metadata),t.once("video:canplay",l.canplay)})}nt(t,"switchQuality",{value:r=>e(r,t.currentTime)}),nt(t,"switchUrl",{value:t=>e(t,0)}),nt(t,"switch",{set:t.switchUrl})}(t),function(t){const{template:{$video:e},i18n:r,notice:o}=t;nt(t,"playbackRate",{get:()=>e.playbackRate,set(a){if(a){if(a===e.playbackRate)return;e.playbackRate=a,o.show=`${r.get("Rate")}: ${1===a?r.get("Normal"):`${a}x`}`}else t.playbackRate=1}})}(t),function(t){const{i18n:e,notice:r,template:{$video:o,$player:a}}=t;nt(t,"aspectRatio",{get:()=>a.dataset.aspectRatio||"default",set(n){if(n||(n="default"),"default"===n)P(o,"width",null),P(o,"height",null),P(o,"margin",null),delete a.dataset.aspectRatio;else{const t=n.split(":").map(Number),{clientWidth:e,clientHeight:r}=a,i=e/r,s=t[0]/t[1];i>s?(P(o,"width",s*r+"px"),P(o,"height","100%"),P(o,"margin","0 auto")):(P(o,"width","100%"),P(o,"height",e/s+"px"),P(o,"margin","auto 0")),a.dataset.aspectRatio=n}r.show=`${e.get("Aspect Ratio")}: ${"default"===n?e.get("Default"):n}`,t.emit("aspectRatio",n)}})}(t),function(t){const{notice:e,template:{$video:r}}=t,o=N("canvas");nt(t,"getDataURL",{value:()=>new Promise((t,a)=>{try{o.width=r.videoWidth,o.height=r.videoHeight,o.getContext("2d").drawImage(r,0,0),t(o.toDataURL("image/png"))}catch(n){e.show=n,a(n)}})}),nt(t,"getBlobUrl",{value:()=>new Promise((t,a)=>{try{o.width=r.videoWidth,o.height=r.videoHeight,o.getContext("2d").drawImage(r,0,0),o.toBlob(e=>{t(URL.createObjectURL(e))})}catch(n){e.show=n,a(n)}})}),nt(t,"screenshot",{value:e=>d(null,null,function*(){const o=yield t.getDataURL();return Z(o,`${e||`artplayer_${tt(r.currentTime)}`}.png`),t.emit("screenshot",o),o})})}(t),oe(t),function(t){const{constructor:e,template:{$container:r,$player:o}}=t;let a="";nt(t,"fullscreenWeb",{get:()=>L(o,"art-fullscreen-web"),set(n){n?(a=o.style.cssText,e.FULLSCREEN_WEB_IN_BODY&&S(document.body,o),t.state="fullscreenWeb",P(o,"width","100%"),P(o,"height","100%"),C(o,"art-fullscreen-web"),t.emit("fullscreenWeb",!0)):(e.FULLSCREEN_WEB_IN_BODY&&S(r,o),a&&(o.style.cssText=a,a=""),z(o,"art-fullscreen-web"),t.emit("fullscreenWeb",!1)),t.emit("resize")}})}(t),ne(t),function(t){const{$video:e}=t.template;nt(t,"loaded",{get:()=>t.loadedTime/e.duration}),nt(t,"loadedTime",{get:()=>e.buffered.length?e.buffered.end(e.buffered.length-1):0})}(t),function(t){nt(t,"played",{get:()=>t.currentTime/t.duration})}(t),function(t){const{$video:e}=t.template;nt(t,"playing",{get:()=>"boolean"===typeof e.playing?e.playing:!!(e.currentTime>0&&!e.paused&&!e.ended&&e.readyState>2)})}(t),function(t){const{$container:e,$player:r,$video:o}=t.template;nt(t,"autoSize",{value(){const{videoWidth:a,videoHeight:n}=o,{width:i,height:s}=B(e),l=a/n;if(i/s>l)P(r,"width",s*l/i*100+"%"),P(r,"height","100%");else{const t=i/l/s*100;P(r,"width","100%"),P(r,"height",`${t}%`)}t.emit("autoSize",{width:t.width,height:t.height})}})}(t),function(t){const e=t;nt(t,"rect",{get:()=>B(t.template.$player)});const r=["bottom","height","left","right","top","width"];for(let o=0;oe.rect[a]})}nt(t,"x",{get:()=>e.left+window.pageXOffset}),nt(t,"y",{get:()=>e.top+window.pageYOffset})}(t),function(t){const{template:{$player:e},i18n:r,notice:o}=t;nt(t,"flip",{get:()=>e.dataset.flip||"normal",set(a){a||(a="normal"),"normal"===a?delete e.dataset.flip:e.dataset.flip=a,o.show=`${r.get("Video Flip")}: ${r.get(Q(a))}`,t.emit("flip",a)}})}(t),ae(t),function(t){const{template:{$poster:e}}=t;nt(t,"poster",{get:()=>{try{return e.style.backgroundImage.match(/"(.*)"/)[1]}catch(t){return""}},set(t){P(e,"backgroundImage",`url(${t})`)}})}(t),function(t){const{template:{$container:e,$video:r}}=t;nt(t,"autoHeight",{value(){const{clientWidth:o}=e,{videoHeight:a,videoWidth:n}=r,i=a*(o/n);P(e,"height",`${i}px`),t.emit("autoHeight",i)}})}(t),function(t){const{$player:e}=t.template;nt(t,"cssVar",{value:(t,r)=>r?e.style.setProperty(t,r):getComputedStyle(e).getPropertyValue(t)})}(t),function(t){nt(t,"theme",{get:()=>t.cssVar("--art-theme"),set(e){t.cssVar("--art-theme",e)}})}(t),function(t){nt(t,"type",{get:()=>t.option.type,set(e){t.option.type=e}})}(t),function(t){const e=["mini","pip","fullscreen","fullscreenWeb"];nt(t,"state",{get:()=>e.find(e=>t[e])||"standard",set(r){for(let o=0;o{switch(t.availability){case"available":n=!0;break;case"not-available":n=!1}}):n=!1,nt(t,"airplay",{value(){n?(a.webkitShowPlaybackTargetPicker(),t.emit("airplay")):r.show=e.get("AirPlay Not Available")}})}(t),function(t){nt(t,"quality",{set(e){const{controls:r,notice:o,i18n:a}=t,n=e.find(t=>t.default)||e[0];r.update({name:"quality",position:"right",index:10,style:{marginRight:"10px"},html:(null==n?void 0:n.html)||"",selector:e,onSelect(e){return d(this,null,function*(){return yield t.switchQuality(e.url),o.show=`${a.get("Switch Video")}: ${e.html}`,e.html})}})}})}(t),ie(t),function(t){const{i18n:e,notice:r,option:o,constructor:a,proxy:n,template:{$player:i,$video:s,$poster:l}}=t;let c=0;for(let d=0;d{t.emit(`video:${e.type}`,e)});t.on("video:canplay",()=>{c=0,t.loading.show=!1}),t.once("video:canplay",()=>{t.loading.show=!1,t.controls.show=!0,t.mask.show=!0,t.isReady=!0,t.emit("ready")}),t.on("video:ended",()=>{o.loop?(t.seek=0,G(t.play()),t.controls.show=!1,t.mask.show=!1):(t.controls.show=!0,t.mask.show=!0)}),t.on("video:error",n=>d(null,null,function*(){if(c{t.emit("resize"),k&&(t.loading.show=!1,t.controls.show=!0,t.mask.show=!0)}),t.on("video:loadstart",()=>{t.loading.show=!0,t.mask.show=!1,t.controls.show=!0}),t.on("video:pause",()=>{t.controls.show=!0,t.mask.show=!0}),t.on("video:play",()=>{t.mask.show=!1,P(l,"display","none")}),t.on("video:playing",()=>{t.mask.show=!1}),t.on("video:progress",()=>{t.playing&&(t.loading.show=!1)}),t.on("video:seeked",()=>{t.loading.show=!1,t.mask.show=!0}),t.on("video:seeking",()=>{t.loading.show=!0,t.mask.show=!1}),t.on("video:timeupdate",()=>{t.mask.show=!1}),t.on("video:waiting",()=>{t.loading.show=!0,t.mask.show=!1})}(t),function(t){const{option:e,storage:r,template:{$video:o,$poster:a}}=t;for(const i in e.moreVideoAttr)t.attr(i,e.moreVideoAttr[i]);e.muted&&(t.muted=e.muted),e.volume&&(o.volume=J(e.volume,0,1));const n=r.get("volume");"number"===typeof n&&(o.volume=J(n,0,1)),e.poster&&P(a,"backgroundImage",`url(${e.poster})`),e.autoplay&&(o.autoplay=e.autoplay),e.playsInline&&(o.playsInline=!0,o["webkit-playsinline"]=!0),e.theme&&(e.cssVar["--art-theme"]=e.theme);for(const i in e.cssVar)t.cssVar(i,e.cssVar[i]);t.url=e.url}(t)}}function le(t){const{notice:e,constructor:r,template:{$player:o,$video:a}}=t,n="art-auto-orientation",i="art-auto-orientation-fullscreen";let s=!1;function l(){const{videoWidth:t,videoHeight:e}=a,r=document.documentElement.clientWidth,o=document.documentElement.clientHeight;return t>e&&ro}return t.on("fullscreenWeb",e=>{var a;if(e){if(l()){const e=Number(null!=(a=r.AUTO_ORIENTATION_TIME)?a:0);setTimeout(()=>{t.fullscreenWeb&&!L(o,n)&&function(){const e=U(),r=document.documentElement.clientWidth,a=document.documentElement.clientHeight-e.top-e.bottom,i=r-e.left-e.right;P(o,"width",`${a}px`),P(o,"height",`${i}px`),P(o,"transform-origin","0 0"),P(o,"transform",`rotate(90deg) translate(${e.top}px, -${r-e.right}px)`),C(o,n),t.isRotate=!0,t.emit("resize")}()},e)}}else L(o,n)&&(P(o,"width",""),P(o,"height",""),P(o,"transform-origin",""),P(o,"transform",""),z(o,n),t.isRotate=!1,t.emit("resize"))}),t.on("fullscreen",t=>d(null,null,function*(){var r;const a=!!(null==(r=null==screen?void 0:screen.orientation)?void 0:r.lock);if(t){if(a&&l())try{const t=screen.orientation.type.startsWith("portrait")?"landscape":"portrait";yield screen.orientation.lock(t),s=!0,C(o,i)}catch(n){s=!1,e.show=n}}else if(L(o,i)&&z(o,i),a&&s){try{screen.orientation.unlock()}catch(c){}s=!1}})),{name:"autoOrientation",get state(){return L(o,n)}}}function ce(t){const{i18n:e,icons:r,storage:o,constructor:a,proxy:n,template:{$poster:i}}=t,s=t.layers.add({name:"auto-playback",html:'\n
\n
\n
\n '}),l=E(".art-auto-playback-last",s),c=E(".art-auto-playback-jump",s),d=E(".art-auto-playback-close",s);S(d,r.close);let p=null;function h(){const r=(o.get("times")||{})[t.option.id||t.option.url];clearTimeout(p),P(s,"display","none"),r&&r>=a.AUTO_PLAYBACK_MIN&&(P(s,"display","flex"),l.textContent=`${e.get("Last Seen")} ${tt(r)}`,c.textContent=e.get("Jump Play"),n(d,"click",()=>{P(s,"display","none")}),n(c,"click",()=>{t.seek=r,G(t.play()),P(i,"display","none"),P(s,"display","none")}),t.once("video:timeupdate",()=>{p=setTimeout(()=>{P(s,"display","none")},a.AUTO_PLAYBACK_TIMEOUT)}))}return t.on("video:timeupdate",()=>{if(t.playing){const e=o.get("times")||{},r=Object.keys(e);r.length>a.AUTO_PLAYBACK_MAX&&delete e[r[0]],e[t.option.id||t.option.url]=t.currentTime,o.set("times",e)}}),t.on("ready",h),t.on("restart",h),{name:"auto-playback",get times(){return o.get("times")||{}},clear:()=>o.del("times"),delete(t){const e=o.get("times")||{};return delete e[t],o.set("times",e),e}}}function de(t){const{constructor:e,proxy:r,template:{$player:o,$video:a}}=t;let n=null,i=!1,s=1;const l=()=>{clearTimeout(n),i&&(i=!1,t.playbackRate=s,z(o,"art-fast-forward"))};return r(a,"touchstart",r=>{1===r.touches.length&&t.playing&&!t.isLock&&(n=setTimeout(()=>{i=!0,s=t.playbackRate,t.playbackRate=e.FAST_FORWARD_VALUE,C(o,"art-fast-forward")},e.FAST_FORWARD_TIME))}),t.on("document:touchmove",l),t.on("document:touchend",l),{name:"fastForward",get state(){return L(o,"art-fast-forward")}}}function pe(t){const{layers:e,icons:r,template:{$player:o}}=t;function a(){return L(o,"art-lock")}function n(){C(o,"art-lock"),t.isLock=!0,t.emit("lock",!0)}function i(){z(o,"art-lock"),t.isLock=!1,t.emit("lock",!1)}return e.add({name:"lock",mounted(e){const o=S(e,r.lock),a=S(e,r.unlock);P(o,"display","none"),t.on("lock",t=>{t?(P(o,"display","inline-flex"),P(a,"display","none")):(P(o,"display","none"),P(a,"display","inline-flex"))})},click(){a()?i():n()}}),{name:"lock",get state(){return a()},set state(t){t?n():i()}}}function he(t){return t.on("control",e=>{e?z(t.template.$player,"art-mini-progress-bar"):C(t.template.$player,"art-mini-progress-bar")}),{name:"mini-progress-bar"}}class ue{constructor(t){this.art=t,this.id=0;const{option:e}=t;!function(t,e){At(t.art)||!e.miniProgressBar||e.isLive||t.add(he),!At(t.art)&&e.lock&&k&&t.add(pe),At(t.art)||!e.autoPlayback||e.isLive||t.add(ce),!At(t.art)&&e.autoOrientation&&k&&t.add(le),!At(t.art)&&e.fastForward&&k&&!e.isLive&&t.add(de)}(this,e);for(let r=0;rconsole.warn("Failed to initialize ArtPlayer plugin:",t))}}add(t){X(!At(this.art),"Cannot add a plugin after ArtPlayer is destroyed"),this.id+=1;const e=t.call(this.art,this.art);return e instanceof Promise?e.then(e=>this.next(t,e)):this.next(t,e)}next(t,e){return function(t,e,r){if(At(t.art))return t;const o=r&&r.name||e.name||`plugin${t.id}`;if(At(t.art))return t;let a=o;const n=st(t,a);if(At(t.art))return t;const i=`Cannot add a plugin that already has the same name: ${o}`;return At(t.art)||(X(!n,i),("object"===typeof o&&null!==o||"function"===typeof o)&&(a=Reflect.ownKeys({[a]:void 0})[0]),At(t.art)||nt(t,a,{value:r})),t}(this,t,e)}}class me extends Et{constructor(t){super(t);const{option:e,controls:r,template:{$setting:o}}=t;this.name="setting",this.$parent=o,this.id=0,this.active=null,this.cache=new Map,this.option=[...this.builtin,...e.settings],e.setting&&(this.format(),this.render(),t.on("blur",()=>{this.show&&(this.show=!1,this.render())}),t.on("focus",t=>{const e=V(t,r.setting),o=V(t,this.$parent);!this.show||e||o||(this.show=!1,this.render())}),t.on("resize",()=>this.resize()))}get builtin(){const t=[],{option:e}=this.art;return e.playbackRate&&t.push(function(t){const{i18n:e,icons:r,constructor:{SETTING_ITEM_WIDTH:o,PLAYBACK_RATE:a}}=t;function n(t){return 1===t?e.get("Normal"):t.toFixed(1)}function i(){const e=t.setting.find(`playback-rate-${t.playbackRate}`);t.setting.check(e)}return{width:o,name:"playback-rate",html:e.get("Play Speed"),tooltip:n(t.playbackRate),icon:r.playbackRate,selector:a.map(e=>({value:e,name:`playback-rate-${e}`,default:e===t.playbackRate,html:n(e)})),onSelect:e=>(t.playbackRate=e.value,e.html),mounted:()=>{i(),t.on("video:ratechange",()=>i())}}}(this.art)),e.aspectRatio&&t.push(function(t){const{i18n:e,icons:r,constructor:{SETTING_ITEM_WIDTH:o,ASPECT_RATIO:a}}=t;function n(t){return"default"===t?e.get("Default"):t}function i(){const e=t.setting.find(`aspect-ratio-${t.aspectRatio}`);t.setting.check(e)}return{width:o,name:"aspect-ratio",html:e.get("Aspect Ratio"),icon:r.aspectRatio,tooltip:n(t.aspectRatio),selector:a.map(e=>({value:e,name:`aspect-ratio-${e}`,default:e===t.aspectRatio,html:n(e)})),onSelect:e=>(t.aspectRatio=e.value,e.html),mounted:()=>{i(),t.on("aspectRatio",()=>i())}}}(this.art)),e.flip&&t.push(function(t){const{i18n:e,icons:r,constructor:{SETTING_ITEM_WIDTH:o,FLIP:a}}=t;function n(t){return e.get(Q(t))}function i(){const e=t.setting.find(`flip-${t.flip}`);t.setting.check(e)}return{width:o,name:"flip",html:e.get("Video Flip"),tooltip:n(t.flip),icon:r.flip,selector:a.map(e=>({value:e,name:`flip-${e}`,default:e===t.flip,html:n(e)})),onSelect:e=>(t.flip=e.value,e.html),mounted:()=>{i(),t.on("flip",()=>i())}}}(this.art)),e.subtitleOffset&&t.push(function(t){const{i18n:e,icons:r,constructor:o}=t;return{width:o.SETTING_ITEM_WIDTH,name:"subtitle-offset",html:e.get("Subtitle Offset"),icon:r.subtitle,tooltip:"0s",range:[0,-10,10,.1],onChange:e=>(t.subtitleOffset=e.range[0],`${e.range[0]}s`),mounted:(e,r)=>{t.on("subtitleOffset",t=>{r.$range.value=t,r.tooltip=`${t}s`})}}}(this.art)),t}traverse(t,e=this.option){var r;for(let o=0;o{e.default=e===t,e.default&&e.$item&&O(e.$item,"art-current")},t.$option),this.render(t.$parents))}format(t=this.option,e,r,o=[]){for(let a=0;ae}),nt(n,"$parents",{get:()=>r}),nt(n,"$option",{get:()=>t});const o=[];nt(n,"$events",{get:()=>o}),nt(n,"$formatted",{get:()=>!0})}this.format(n.selector||[],n,t,o)}this.option=t}find(t=""){let e=null;return this.traverse(r=>{r.name===t&&(e=r)}),e}resize(){var t,e;const{controls:r,constructor:{SETTING_WIDTH:o,SETTING_ITEM_HEIGHT:a},template:{$player:n,$setting:i}}=this.art;if(r.setting&&this.show){const s=(null==(e=null==(t=this.active[0])?void 0:t.$parent)?void 0:e.width)||o,{left:l,width:c}=B(r.setting),{left:d,width:p}=B(n),h=l-d+c/2-s/2;if(P(i,"height",`${this.active===this.option?this.active.length*a:(this.active.length+1)*a}px`),P(i,"width",`${s}px`),this.art.isRotate||k)return;h+s>p?(P(i,"left",null),P(i,"right",null)):(P(i,"left",`${h}px`),P(i,"right","auto"))}}inactivate(t){for(let e=0;e'),s=N("div");C(s,"art-setting-item-left-icon"),S(s,o),S(i,s),S(i,t.$parent.html);const l=r(n,"click",()=>this.render(t.$parents));t.$parent.$events.push(l),S(e,n)}createItem(t,e=!1){var r,o;if(!this.cache.has(t.$option))return;const a=this.cache.get(t.$option),n=t.$item;let i="selector";st(t,"switch")&&(i="switch"),st(t,"range")&&(i="range"),st(t,"onClick")&&(i="button");const{icons:s,proxy:l,constructor:c}=this.art,p=N("div");C(p,"art-setting-item"),P(p,"height",`${c.SETTING_ITEM_HEIGHT}px`),p.dataset.name=t.name||"",p.dataset.value=t.value||"";const h=S(p,'
'),u=S(p,'
'),m=N("div");switch(C(m,"art-setting-item-left-icon"),i){case"button":case"switch":case"range":S(m,t.icon||s.config);break;case"selector":(null==(r=t.selector)?void 0:r.length)?S(m,t.icon||s.config):S(m,s.check)}S(h,m),nt(t,"$icon",{configurable:!0,get:()=>m}),nt(t,"icon",{configurable:!0,get:()=>m.innerHTML,set(t){m.innerHTML="",S(m,t)}});const f=N("div");C(f,"art-setting-item-left-text"),S(f,t.html||""),S(h,f),nt(t,"$html",{configurable:!0,get:()=>f}),nt(t,"html",{configurable:!0,get:()=>f.innerHTML,set(t){f.innerHTML="",S(f,t)}});const g=N("div");switch(C(g,"art-setting-item-right-tooltip"),S(g,t.tooltip||""),S(u,g),nt(t,"$tooltip",{configurable:!0,get:()=>g}),nt(t,"tooltip",{configurable:!0,get:()=>g.innerHTML,set(t){g.innerHTML="",S(g,t)}}),i){case"switch":{const e=N("div");C(e,"art-setting-item-right-icon");const r=S(e,s.switchOn),o=S(e,s.switchOff);P(t.switch?o:r,"display","none"),S(u,e),nt(t,"$switch",{configurable:!0,get:()=>e});let a=t.switch;nt(t,"switch",{configurable:!0,get:()=>a,set(t){a=t,t?(P(o,"display","none"),P(r,"display",null)):(P(o,"display",null),P(r,"display","none"))}});break}case"range":{const e=N("div");C(e,"art-setting-item-right-icon");const r=S(e,'');r.value=t.range[0],r.min=t.range[1],r.max=t.range[2],r.step=t.range[3],C(r,"art-setting-range"),S(u,e),nt(t,"$range",{configurable:!0,get:()=>r});let o=[...t.range];nt(t,"range",{configurable:!0,get:()=>o,set(t){o=[...t],r.value=t[0],r.min=t[1],r.max=t[2],r.step=t[3]}})}break;case"selector":if(null==(o=t.selector)?void 0:o.length){const t=N("div");C(t,"art-setting-item-right-icon"),S(t,s.arrowRight),S(u,t)}}switch(i){case"switch":if(t.onSwitch){const e=l(p,"click",e=>d(this,null,function*(){t.switch=yield t.onSwitch.call(this.art,t,p,e)}));t.$events.push(e)}break;case"range":if(t.$range){if(t.onRange){const e=l(t.$range,"change",e=>d(this,null,function*(){t.range[0]=t.$range.valueAsNumber,t.tooltip=yield t.onRange.call(this.art,t,p,e)}));t.$events.push(e)}if(t.onChange){const e=l(t.$range,"input",e=>d(this,null,function*(){t.range[0]=t.$range.valueAsNumber,t.tooltip=yield t.onChange.call(this.art,t,p,e)}));t.$events.push(e)}}break;case"selector":{const e=l(p,"click",e=>d(this,null,function*(){var r;(null==(r=t.selector)?void 0:r.length)?this.render(t.selector):(this.check(t),t.$parent.onSelect&&(t.$parent.tooltip=yield t.$parent.onSelect.call(this.art,t,p,e)))}));t.$events.push(e),t.default&&C(p,"art-current")}break;case"button":if(t.onClick){const e=l(p,"click",e=>d(this,null,function*(){t.tooltip=yield t.onClick.call(this.art,t,p,e)}));t.$events.push(e)}}nt(t,"$item",{configurable:!0,get:()=>p}),e?Y(p,n):S(a,p),t.mounted&&Ot(Pt(this.art),()=>t.mounted.call(this.art,t.$item,t),0)}render(t=this.option){var e;if(this.active=t,this.cache.has(t)){O(this.cache.get(t),"art-current")}else{const r=N("div");this.cache.set(t,r),C(r,"art-setting-panel"),S(this.$parent,r),O(r,"art-current"),(null==(e=t[0])?void 0:e.$parent)&&this.createHeader(t[0]);for(let e=0;enull,this.init(t.option.subtitle);let e=!1;t.on("video:timeupdate",()=>{if(!this.url)return;const t=this.art.template.$video.webkitDisplayingFullscreen;"boolean"===typeof t&&t!==e&&(e=t,this.createTrack(t?"subtitles":"metadata",this.url))})}get url(){return this.art.template.$track.src}set url(t){this.switch(t)}get textTrack(){var t,e;return null==(e=null==(t=this.art.template.$video)?void 0:t.textTracks)?void 0:e[0]}get activeCues(){return this.textTrack?Array.from(this.textTrack.activeCues):[]}get cues(){return this.textTrack?Array.from(this.textTrack.cues):[]}style(t,e){const{$subtitle:r}=this.art.template;return"object"===typeof t?A(r,t):P(r,t,e)}update(){const{option:{subtitle:t},template:{$subtitle:e}}=this.art;e.innerHTML="",this.activeCues.length&&(this.art.emit("subtitleBeforeUpdate",this.activeCues),e.innerHTML=this.activeCues.map((e,r)=>e.text.split(/\r?\n/).filter(t=>t.trim()).map(e=>`
\n ${t.escape?at(e):e}\n
`).join("")).join(""),this.art.emit("subtitleAfterUpdate",this.activeCues))}switch(t){return d(this,arguments,function*(t,e={}){const{i18n:r,notice:o,option:a}=this.art,n=c(l(l({},a.subtitle),e),{url:t}),i=yield this.init(n);return e.name&&(o.show=`${r.get("Switch Subtitle")}: ${e.name}`),i})}createTrack(t,e){const{template:r,proxy:o,option:a}=this.art,{$video:n,$track:i}=r,s=N("track");s.default=!0,s.kind=t,s.src=e,s.label=a.subtitle.name||"Artplayer",s.track.mode="hidden",s.onload=()=>{this.art.emit("subtitleLoad",this.cues,this.option)},this.art.events.remove(this.destroyEvent),i.onload=null,M(i),S(n,s),r.$track=s,this.destroyEvent=o(this.textTrack,"cuechange",()=>this.update())}init(t){return d(this,null,function*(){const{notice:e,template:{$subtitle:r}}=this.art;return this.textTrack?(f(t,$t.subtitle),t.url?(this.option=t,this.style(t.style),fetch(t.url).then(t=>t.arrayBuffer()).then(e=>{const r=new TextDecoder(t.encoding).decode(e);switch(t.type||K(t.url)){case"srt":{const e=dt(r);return pt(t.onVttLoad(e))}case"ass":{const e=ht(r);return pt(t.onVttLoad(e))}case"vtt":return pt(t.onVttLoad(r));default:return t.url}}).then(t=>(r.innerHTML="",this.url===t||(URL.revokeObjectURL(this.url),this.createTrack("metadata",t)),t)).catch(t=>{throw r.innerHTML="",e.show=t,t})):void 0):null})}}class ye{constructor(t){this.art=t;const{option:e,constructor:r}=t;e.container instanceof Element?this.$container=e.container:(this.$container=E(e.container),X(this.$container,`No container element found by ${e.container}`)),X(H(),"The current browser does not support flex layout");const o=this.$container.tagName.toLowerCase();X("div"===o,`Unsupported container element type, only support 'div' but got '${o}'`),X(r.instances.every(t=>t.template.$container!==this.$container),"Cannot mount multiple instances on the same dom element"),this.query=this.query.bind(this),function(t,e,r){const o=St.get(e);if(o&&o!==t)throw new Error("Cannot mount multiple instances on the same dom element");const a=Mt(t);a.rollback=r,St.set(e,t),a.releaseContainer=()=>{St.get(e)===t&&St.delete(e)}}(t,this.$container,function(t){const e=[];return function t(r){const o=Array.from(r.childNodes);e.push({node:r,children:o,attributes:1===r.nodeType?Array.from(r.attributes,t=>[t.name,t.value]):void 0,value:r.nodeValue}),o.forEach(t)}(t),()=>{for(const{node:t,children:r,attributes:o,value:a}of e){for(;t.firstChild;)t.removeChild(t.firstChild);for(const e of r)t.appendChild(e);if(o){const e=t;for(const t of Array.from(e.attributes))e.removeAttribute(t.name);for(const[t,r]of o)e.setAttribute(t,r)}else t.nodeValue=a}}}(this.$container)),this.$container.dataset.artId=t.id,this.init()}static get html(){return`\n
\n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
Player version:
\n
${g}
\n
\n
\n
Video url:
\n
\n
\n
\n
Video volume:
\n
\n
\n
\n
Video time:
\n
\n
\n
\n
Video duration:
\n
\n
\n
\n
Video resolution:
\n
\n x \n
\n
\n
\n
[x]
\n
\n
\n
\n `}query(t){return E(t,this.$container)}init(){const{option:t}=this.art;if(t.useSSR||(this.$container.innerHTML=ye.html),this.$player=this.query(".art-video-player"),this.$video=this.query(".art-video"),this.$track=this.query("track"),this.$poster=this.query(".art-poster"),this.$subtitle=this.query(".art-subtitle"),this.$danmuku=this.query(".art-danmuku"),this.$bottom=this.query(".art-bottom"),this.$progress=this.query(".art-progress"),this.$controls=this.query(".art-controls"),this.$controlsLeft=this.query(".art-controls-left"),this.$controlsCenter=this.query(".art-controls-center"),this.$controlsRight=this.query(".art-controls-right"),this.$layer=this.query(".art-layers"),this.$loading=this.query(".art-loading"),this.$notice=this.query(".art-notice"),this.$noticeInner=this.query(".art-notice-inner"),this.$mask=this.query(".art-mask"),this.$state=this.query(".art-state"),this.$setting=this.query(".art-settings"),this.$info=this.query(".art-info"),this.$infoPanel=this.query(".art-info-panel"),this.$infoClose=this.query(".art-info-close"),this.$contextmenu=this.query(".art-contextmenus"),t.proxy){const e=t.proxy.call(this.art,this.art);X(e instanceof HTMLVideoElement||e instanceof HTMLCanvasElement,"Function 'option.proxy' needs to return 'HTMLVideoElement' or 'HTMLCanvasElement'"),Y(e,this.$video),e.className="art-video",this.$video=e}t.backdrop&&C(this.$player,"art-backdrop"),k&&C(this.$player,"art-mobile")}destroy(t){t?this.$container.innerHTML="":C(this.$player,"art-destroy")}}const be=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);class we{on(t,e,r){const o=this.e||(this.e={});let a=be(o,t)?o[t]:void 0;return a||(a=[],Object.defineProperty(o,t,{value:a,enumerable:!0,configurable:!0,writable:!0})),a.push({fn:e,ctx:r}),this}once(t,e,r){const o=this,a=e;let n=!1;function i(...e){n||(n=!0,o.off(t,i),a.apply(r,e))}return i._=e,this.on(t,i,r)}emit(t,...e){const r=this.e||(this.e={}),o=(be(r,t)&&r[t]||[]).slice();for(const a of o)a.fn.apply(a.ctx,e);return this}off(t,e){const r=this.e||(this.e={}),o=be(r,t)?r[t]:void 0,a=[];if(o&&e)for(let n=0,i=o.length;ne.call(this,this)),$e.DEBUG){const t=t=>console.log(`[ART.${this.id}] -> ${t}`);t(`Version@${$e.version}`);for(let e=0;et(`Event@${e.type}`))}(function(t){const e=Mt(t);return e.rollback=void 0,!e.scope.closed})(this)&&ke.push(this)}catch(o){try{It(this,ke,!0,$e.REMOVE_SRC_WHEN_DESTROY,!0)}catch(a){console.warn("Failed to clean up ArtPlayer initialization:",a)}throw o}}static get instances(){return ke}static get version(){return g}static get config(){return v}static get utils(){return mt}static get scheme(){return $t}static get Emitter(){return we}static get validator(){return f}static get kindOf(){return f.kindOf}static get html(){return ye.html}static get option(){return{id:"",container:"#artplayer",url:"",poster:"",type:"",theme:"#f00",volume:.7,isLive:!1,muted:!1,autoplay:!1,autoSize:!1,autoMini:!1,loop:!1,flip:!1,playbackRate:!1,aspectRatio:!1,screenshot:!1,setting:!1,hotkey:!0,pip:!1,mutex:!0,backdrop:!0,fullscreen:!1,fullscreenWeb:!1,subtitleOffset:!1,miniProgressBar:!1,useSSR:!1,playsInline:!0,lock:!1,gesture:!0,fastForward:!1,autoPlayback:!1,autoOrientation:!1,airplay:!1,proxy:void 0,layers:[],contextmenu:[],controls:[],settings:[],quality:[],highlight:[],plugins:[],thumbnails:{url:"",number:60,column:10,width:0,height:0,scale:1},subtitle:{url:"",type:"",style:{},name:"",escape:!0,encoding:"utf-8",onVttLoad:t=>t},moreVideoAttr:{controls:!1,preload:b?"auto":"metadata"},i18n:{},icons:{},cssVar:{},customType:{},lang:null==navigator?void 0:navigator.language.toLowerCase()}}get proxy(){return this.events.proxy}get query(){return this.template.query}get video(){return this.template.$video}reset(){this.video.removeAttribute("src"),this.video.load()}destroy(t=!0){It(this,ke,t,$e.REMOVE_SRC_WHEN_DESTROY)}}return $e.STYLE=ge,$e.DEBUG=!1,$e.CONTEXTMENU=!0,$e.NOTICE_TIME=2e3,$e.SETTING_WIDTH=250,$e.SETTING_ITEM_WIDTH=200,$e.SETTING_ITEM_HEIGHT=35,$e.RESIZE_TIME=200,$e.SCROLL_TIME=200,$e.SCROLL_GAP=50,$e.AUTO_PLAYBACK_MAX=10,$e.AUTO_PLAYBACK_MIN=5,$e.AUTO_PLAYBACK_TIMEOUT=3e3,$e.RECONNECT_TIME_MAX=5,$e.RECONNECT_SLEEP_TIME=1e3,$e.CONTROL_HIDE_TIME=3e3,$e.DBCLICK_TIME=300,$e.DBCLICK_FULLSCREEN=!0,$e.MOBILE_DBCLICK_PLAY=!0,$e.MOBILE_CLICK_PLAY=!1,$e.AUTO_ORIENTATION_TIME=200,$e.INFO_LOOP_TIME=1e3,$e.FAST_FORWARD_VALUE=3,$e.FAST_FORWARD_TIME=1e3,$e.TOUCH_MOVE_RATIO=.5,$e.VOLUME_STEP=.1,$e.SEEK_STEP=5,$e.PLAYBACK_RATE=[.5,.75,1,1.25,1.5,2],$e.ASPECT_RATIO=["default","4:3","16:9"],$e.FLIP=["normal","horizontal","vertical"],$e.FULLSCREEN_WEB_IN_BODY=!0,$e.LOG_VERSION=!0,$e.USE_RAF=!1,$e.REMOVE_SRC_WHEN_DESTROY=!0,$&&(window.Artplayer=$e,F("artplayer-style",ge),setTimeout(()=>{$e.LOG_VERSION&&console.log(`%c ArtPlayer %c ${$e.version} %c https://artplayer.org`,"color: #fff; background: #5f5f5f","color: #fff; background: #4bc729","")},100)),$e}); +!function(t,e){"object"===typeof exports&&"undefined"!==typeof module?module.exports=e():"function"==typeof define&&define.amd?(t.Artplayer=e(),define(function(){return t.Artplayer})):(t="undefined"!==typeof globalThis?globalThis:t||self).Artplayer=e()}(this,function(){"use strict";var t,e=Object.defineProperty,r=Object.defineProperties,o=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,s=(t,r,o)=>r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o,l=(t,e)=>{for(var r in e||(e={}))a.call(e,r)&&s(t,r,e[r]);if(n)for(var r of n(e))i.call(e,r)&&s(t,r,e[r]);return t},c=(t,e)=>r(t,o(e)),d=(t,e,r)=>new Promise((o,n)=>{var a=t=>{try{s(r.next(t))}catch(e){n(e)}},i=t=>{try{s(r.throw(t))}catch(e){n(e)}},s=t=>t.done?o(t.value):Promise.resolve(t.value).then(a,i);s((r=r.apply(t,e)).next())});function p(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var h,u={exports:{}};var m=(h||(h=1,u.exports=function(){function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}var e=Object.prototype.toString,r=function(r){if(void 0===r)return"undefined";if(null===r)return"null";var n=t(r);if("boolean"===n)return"boolean";if("string"===n)return"string";if("number"===n)return"number";if("symbol"===n)return"symbol";if("function"===n)return"GeneratorFunction"===o(r)?"generatorfunction":"function";if(function(t){return Array.isArray?Array.isArray(t):t instanceof Array}(r))return"array";if(function(t){return!(!t.constructor||"function"!=typeof t.constructor.isBuffer)&&t.constructor.isBuffer(t)}(r))return"buffer";if(function(t){try{if("number"==typeof t.length&&"function"==typeof t.callee)return!0}catch(e){if(-1!==e.message.indexOf("callee"))return!0}return!1}(r))return"arguments";if(function(t){return t instanceof Date||"function"==typeof t.toDateString&&"function"==typeof t.getDate&&"function"==typeof t.setDate}(r))return"date";if(function(t){return t instanceof Error||"string"==typeof t.message&&t.constructor&&"number"==typeof t.constructor.stackTraceLimit}(r))return"error";if(function(t){return t instanceof RegExp||"string"==typeof t.flags&&"boolean"==typeof t.ignoreCase&&"boolean"==typeof t.multiline&&"boolean"==typeof t.global}(r))return"regexp";switch(o(r)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(function(t){return"function"==typeof t.throw&&"function"==typeof t.return&&"function"==typeof t.next}(r))return"generator";switch(n=e.call(r)){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return n.slice(8,-1).toLowerCase().replace(/\s/g,"")};function o(t){return t.constructor?t.constructor.name:null}function n(t,e){var o=2=1,k=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(y)||x,$="undefined"!==typeof window&&"undefined"!==typeof document;function E(t,e=document){return e.querySelector(t)}function T(t,e=document){return Array.from(e.querySelectorAll(t))}function C(t,e){return t.classList.add(e)}function z(t,e){return t.classList.remove(e)}function L(t,e){return t.classList.contains(e)}function S(t,e){return e instanceof Element?t.appendChild(e):t.insertAdjacentHTML("beforeend",String(e)),t.lastElementChild||t.lastChild}function M(t){return t.parentNode.removeChild(t)}function P(t,e,r){return t.style[e]=r,t}function A(t,e){for(const r in e)P(t,r,e[r]);return t}function I(t){return Array.from(t.parentElement.children).filter(e=>e!==t)}function O(t,e){I(t).forEach(t=>z(t,e)),C(t,e)}function R(t,e,r="top"){k||(t.setAttribute("aria-label",e),C(t,"hint--rounded"),C(t,`hint--${r}`))}function _(t,e=0){const r=t.getBoundingClientRect(),o=window.innerHeight||document.documentElement.clientHeight,n=window.innerWidth||document.documentElement.clientWidth,a=r.top-e<=o&&r.top+r.height+e>=0,i=r.left-e<=n+e&&r.left+r.width+e>=0;return a&&i}function V(t,e){return j(t).includes(e)}function Y(t,e){return e.parentNode.replaceChild(t,e),t}function N(t){return document.createElement(t)}function D(t="",e=""){const r=N("i");return C(r,"art-icon"),C(r,`art-icon-${t}`),S(r,e),r}function F(t,e){let r=document.getElementById(t);r||(r=document.createElement("style"),r.id=t,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{document.head.appendChild(r)}):(document.head||document.documentElement).appendChild(r)),r.textContent=e}function H(){const t=document.createElement("div");return t.style.display="flex","flex"===t.style.display}function B(t){return t.getBoundingClientRect()}function W(t,e){return new Promise((r,o)=>{const n=new Image;n.onload=function(){if(e&&1!==e){const a=document.createElement("canvas"),i=a.getContext("2d");a.width=n.width*e,a.height=n.height*e,i.drawImage(n,0,0,a.width,a.height),a.toBlob(e=>{const n=URL.createObjectURL(e),a=new Image;a.onload=function(){r(a)},a.onerror=function(){URL.revokeObjectURL(n),o(new Error(`Image load failed: ${t}`))},a.src=n})}else r(n)},n.onerror=function(){o(new Error(`Image load failed: ${t}`))},n.src=t})}function j(t){if(t.composedPath)return t.composedPath();const e=[];let r=t.target;for(;r;)e.push(r),r=r.parentNode;return e.includes(window)||void 0===window||e.push(window),e}function U(){const t=document.createElement("div");t.style.cssText="position:fixed;top:env(safe-area-inset-top,0px);right:env(safe-area-inset-right,0px);bottom:env(safe-area-inset-bottom,0px);left:env(safe-area-inset-left,0px);pointer-events:none;visibility:hidden;",document.body.appendChild(t);const e=getComputedStyle(t),r={top:Number.parseFloat(e.top)||0,right:Number.parseFloat(e.right)||0,bottom:Number.parseFloat(e.bottom)||0,left:Number.parseFloat(e.left)||0};return t.remove(),r}class q extends Error{constructor(t,e){super(t),"captureStackTrace"in Error&&"function"===typeof Error.captureStackTrace&&Error.captureStackTrace(this,e||this.constructor),this.name="ArtPlayerError"}}function X(t,e){if(!t)throw new q(e);return t}function G(t){const e=t;return e&&"function"===typeof e.catch?e.catch(()=>{}):t}function K(t){const e=t.search(/[?#]/),r=(e<0?t:t.slice(0,e)).trim().toLowerCase();return r.slice(r.lastIndexOf(".")+1)}function Z(t,e){const r=document.createElement("a");r.style.display="none",r.href=t,r.download=e,document.body.appendChild(r);try{r.click()}finally{r.remove()}}function J(t,e,r){return Math.max(Math.min(t,Math.max(e,r)),Math.min(e,r))}function Q(t){return t.charAt(0).toUpperCase()+t.slice(1)}function tt(t){if(!t)return"00:00";const e=Math.floor(t/3600),r=Math.floor((t-3600*e)/60),o=Math.floor(t-3600*e-60*r);return(e>0?[e,r,o]:[r,o]).map(t=>t<10?`0${t}`:String(t)).join(":")}const et={"&":"&","<":"<",">":">","'":"'",'"':"""},rt={"&":"&","<":"<",">":">","'":"'",""":'"'},ot=/(&|<|>|'|")/g;function nt(t){return t.replace(/[&<>'"]/g,t=>et[t]||t)}const at=Object.defineProperty,{hasOwnProperty:it}=Object.prototype;function st(t,e){return it.call(t,e)}function lt(t,e){return Object.getOwnPropertyDescriptor(t,e)}function ct(...t){const e=t=>!!t&&"object"===typeof t&&!Array.isArray(t);return t.reduce((t,r)=>(Object.keys(r).forEach(o=>{const n=t[o],a=r[o];let i;i=Array.isArray(n)&&Array.isArray(a)?n.concat(...a):e(n)&&e(a)?ct(n,a):a,at(t,o,{value:i,enumerable:!0,configurable:!0,writable:!0})}),t),{})}function dt(t){return"WEBVTT \r\n\r\n".concat((e=t,e.replace(/(\d\d:\d\d:\d\d)[,.](\d+)/g,(t,e,r)=>{let o=r.slice(0,3);return 1===r.length&&(o=`${r}00`),2===r.length&&(o=`${r}0`),`${e},${o}`})).replace(/\{\\([ibu])\}/g,"").replace(/\{\\([ibu])1\}/g,"<$1>").replace(/\{([ibu])\}/g,"<$1>").replace(/\{\/([ibu])\}/g,"").replace(/(\d\d:\d\d:\d\d),(\d\d\d)/g,"$1.$2").replace(/\{[\s\S]*?\}/g,"").concat("\r\n\r\n"));var e}function pt(t){return URL.createObjectURL(new Blob([t],{type:"text/vtt"}))}function ht(t){const e=new RegExp("Dialogue:\\s\\d,(\\d+:\\d\\d:\\d\\d.\\d\\d),(\\d+:\\d\\d:\\d\\d.\\d\\d),([^,]*),([^,]*),(?:[^,]*,){4}([\\s\\S]*)$","i");function r(t=""){return t.split(/[:.]/).map((t,e,r)=>{if(e===r.length-1){if(1===t.length)return`.${t}00`;if(2===t.length)return`.${t}0`}else if(1===t.length)return(0===e?"0":":0")+t;return 0===e?t:e===r.length-1?`.${t}`:`:${t}`}).join("")}return`WEBVTT\n\n${t.split(/\r?\n/).map(t=>{const o=t.match(e);if(!o)return null;const[,n="",a="",,,i=""]=o;return{start:r(n.trim()),end:r(a.trim()),text:i.replace(/\{[\s\S]*?\}/g,"").replace(/(\\N)/g,"\n").trim().split(/\r?\n/).map(t=>t.trim()).join("\n")}}).filter(t=>t).map((t,e)=>t?`${e+1}\n${t.start} --\x3e ${t.end}\n${t.text}`:"").filter(t=>t.trim()).join("\n\n")}`}function ut(t,e){let r=!1;return function(...o){r||(t.apply(this,o),r=!0,setTimeout(()=>{r=!1},e))}}const mt=Object.freeze(Object.defineProperty({__proto__:null,ArtPlayerError:q,addClass:C,append:S,assToVtt:ht,capitalize:Q,clamp:J,createElement:N,debounce:function(t,e){let r;return function(...o){clearTimeout(r),r=setTimeout(()=>(r=void 0,t.apply(this,o)),e)}},def:at,download:Z,errorHandle:X,escape:nt,get:lt,getComposedPath:j,getExt:K,getIcon:D,getRect:B,getSafeAreaInsets:U,getStyle:function(t,e,r=!0){const o=window.getComputedStyle(t,null).getPropertyValue(e);return r?Number.parseFloat(o):o},has:st,hasClass:L,includeFromEvent:V,inverseClass:O,isBrowser:$,isIOS:w,isIOS13:x,isInViewport:_,isMobile:k,isSafari:b,loadImg:W,mergeDeep:ct,query:E,queryAll:T,remove:M,removeClass:z,replaceElement:Y,secondToTime:tt,setStyle:P,setStyleText:F,setStyles:A,siblings:I,silencePromise:G,sleep:function(t=0){return new Promise(e=>setTimeout(e,t))},srtToVtt:dt,supportsFlex:H,throttle:ut,tooltip:R,unescape:function(t){return t.replace(ot,t=>rt[t]||t)},userAgent:y,vttToBlob:pt},Symbol.toStringTag,{value:"Module"})),ft="array",gt="boolean",vt="string",yt="number",bt="object",wt="function";function xt(t,e,r){return X(e===vt||e===yt||t instanceof Element,`${r.join(".")} require '${vt}' or 'Element' type`)}const kt={html:xt,disable:`?${gt}`,name:`?${vt}`,index:`?${yt}`,style:`?${bt}`,click:`?${wt}`,mounted:`?${wt}`,tooltip:`?${vt}|${yt}`,width:`?${yt}`,selector:`?${ft}`,onSelect:`?${wt}`,switch:`?${gt}`,onSwitch:`?${wt}`,range:`?${ft}`,onRange:`?${wt}`,onChange:`?${wt}`},$t={id:vt,container:xt,url:vt,poster:vt,type:vt,theme:vt,lang:vt,volume:yt,isLive:gt,muted:gt,autoplay:gt,autoSize:gt,autoMini:gt,loop:gt,flip:gt,playbackRate:gt,aspectRatio:gt,screenshot:gt,setting:gt,hotkey:gt,pip:gt,mutex:gt,backdrop:gt,fullscreen:gt,fullscreenWeb:gt,subtitleOffset:gt,miniProgressBar:gt,useSSR:gt,playsInline:gt,lock:gt,gesture:gt,fastForward:gt,autoPlayback:gt,autoOrientation:gt,airplay:gt,proxy:`?${wt}`,plugins:[wt],layers:[kt],contextmenu:[kt],settings:[kt],controls:[c(l({},kt),{position:(t,e,r)=>{const o=["top","left","right"];return X("string"===typeof t&&o.includes(t),`${r.join(".")} only accept ${o.toString()} as parameters`)}})],quality:[{default:`?${gt}`,html:vt,url:vt}],highlight:[{time:yt,text:vt}],thumbnails:{url:vt,number:yt,column:yt,width:yt,height:yt,scale:yt},subtitle:{url:vt,name:vt,type:vt,style:bt,escape:gt,encoding:vt,onVttLoad:wt},moreVideoAttr:bt,i18n:bt,icons:bt,cssVar:bt,customType:bt};class Et{constructor(t){this.id=0,this.art=t,this.cache=new Map,this.add=this.add.bind(this),this.remove=this.remove.bind(this),this.update=this.update.bind(this)}get show(){return L(this.art.template.$player,`art-${this.name}-show`)}set show(t){const{$player:e}=this.art.template,r=`art-${this.name}-show`;t?C(e,r):z(e,r),this.art.emit(this.name,t)}toggle(){this.show=!this.show}add(t){const e="function"===typeof t?t(this.art):t;if(e.html=e.html||"",f(e,kt),!this.$parent||!this.name||e.disable)return;const r=e.name||`${this.name}${this.id}`;X(!this.cache.has(r),`Can't add an existing [${r}] to the [${this.name}]`),this.id+=1;const o=N("div");C(o,`art-${this.name}`),C(o,`art-${this.name}-${r}`);const n=Array.from(this.$parent.children);o.dataset.index=e.index||this.id;const a=n.find(t=>Number(t.dataset.index)>=Number(o.dataset.index));a?a.insertAdjacentElement("beforebegin",o):S(this.$parent,o),e.html&&S(o,e.html),e.style&&A(o,e.style),e.tooltip&&R(o,e.tooltip);const i=[];if(e.click){const t=this.art.events.proxy(o,"click",t=>{t.preventDefault(),e.click.call(this.art,this,t)});i.push(t)}return e.selector&&["left","right"].includes(e.position)&&this.selector(e,o,i),this[r]=o,this.cache.set(r,{$ref:o,events:i,option:e}),e.mounted&&e.mounted.call(this.art,o),o}remove(t){X(this.cache.has(t),`Can't find [${t}] from the [${this.name}]`);const e=this.cache.get(t);e.option.beforeUnmount&&e.option.beforeUnmount.call(this.art,e.$ref);for(const r of e.events)this.art.events.remove(r);this.cache.delete(t),delete this[t],M(e.$ref)}update(t){if(this.cache.has(t.name)){const e=this.cache.get(t.name);t=Object.assign(e.option,t),this.remove(t.name)}return this.add(t)}}class Tt extends Et{constructor(t){super(t),this.name="contextmenu",this.$parent=t.template.$contextmenu,k||this.init()}init(){const{option:t,proxy:e,template:{$player:r,$contextmenu:o}}=this.art;t.playbackRate&&this.add(function(t){return e=>{const{i18n:r,constructor:{PLAYBACK_RATE:o}}=e,n=o.map(t=>`${1===t?r.get("Normal"):t.toFixed(1)}`).join("");return c(l({},t),{html:`${r.get("Play Speed")}: ${n}`,click:(t,r)=>{const{value:o}=r.target.dataset;o&&(e.playbackRate=Number(o),t.show=!1)},mounted:t=>{const r=E('[data-value="1"]',t);r&&O(r,"art-current"),e.on("video:ratechange",()=>{const r=T("span",t).find(t=>Number(t.dataset.value)===e.playbackRate);r&&O(r,"art-current")})}})}}({name:"playbackRate",index:10})),t.aspectRatio&&this.add(function(t){return e=>{const{i18n:r,constructor:{ASPECT_RATIO:o}}=e,n=o.map(t=>`${"default"===t?r.get("Default"):t}`).join("");return c(l({},t),{html:`${r.get("Aspect Ratio")}: ${n}`,click:(t,r)=>{const{value:o}=r.target.dataset;o&&(e.aspectRatio=o,t.show=!1)},mounted:t=>{const r=E('[data-value="default"]',t);r&&O(r,"art-current"),e.on("aspectRatio",e=>{const r=T("span",t).find(t=>t.dataset.value===e);r&&O(r,"art-current")})}})}}({name:"aspectRatio",index:20})),t.flip&&this.add(function(t){return e=>{const{i18n:r,constructor:{FLIP:o}}=e,n=o.map(t=>`${r.get(Q(t))}`).join("");return c(l({},t),{html:`${r.get("Video Flip")}: ${n}`,click:(t,r)=>{const{value:o}=r.target.dataset;o&&(e.flip=o.toLowerCase(),t.show=!1)},mounted:t=>{const r=E('[data-value="normal"]',t);r&&O(r,"art-current"),e.on("flip",e=>{const r=T("span",t).find(t=>t.dataset.value===e);r&&O(r,"art-current")})}})}}({name:"flip",index:30})),this.add(function(t){return e=>c(l({},t),{html:e.i18n.get("Video Info"),click:t=>{e.info.show=!0,t.show=!1}})}({name:"info",index:40})),this.add(function(t){return c(l({},t),{html:`ArtPlayer ${g}`})}({name:"version",index:50})),this.add(function(t){return e=>c(l({},t),{html:e.i18n.get("Close"),click:t=>{t.show=!1}})}({name:"close",index:60}));for(let n=0;n{if(!this.art.constructor.CONTEXTMENU)return;t.preventDefault(),this.show=!0;const e=t.clientX,n=t.clientY,{height:a,width:i,left:s,top:l}=B(r),{height:c,width:d}=B(o);let p=e-s,h=n-l;e+d>s+i&&(p=i-d),n+c>l+a&&(h=a-c),A(o,{top:`${h}px`,left:`${p}px`})}),e(r,"click",t=>{V(t,o)||(this.show=!1)}),this.art.on("blur",()=>{this.show=!1})}}class Ct extends Error{constructor(t){super("Failed to release ArtPlayer resources"),this.errors=t,this.name="ResourceCleanupError"}}class zt{constructor(){this.cleanups=new Set,this.disposed=!1}get closed(){return this.disposed}add(t){let e=!0;const r=()=>{e&&(e=!1,this.cleanups.delete(r),t())};return this.closed?r():this.cleanups.add(r),r}child(){const t=new zt,e=this.add(()=>{t.dispose()});return t.add(()=>{e()}),t}dispose(){if(this.closed)return;this.disposed=!0;const t=[];for(const r of Array.from(this.cleanups).reverse())try{r()}catch(e){e instanceof Ct?t.push(...e.errors):t.push(e)}if(t.length)throw new Ct(t)}}const Lt=new WeakMap,St=new WeakMap;function Mt(t){const e=Lt.get(t);if(!e)throw new Error("ArtPlayer lifecycle has not been initialized");return e}function Pt(t){return Mt(t).scope}function At(t){const e=Mt(t);return e.destroying||e.scope.closed}function It(t,e,r,o,n=!1){var a,i,s;const l=Mt(t);if(l.destroying||l.scope.closed)return;l.destroying=!0;const c=[],d=t=>{try{t()}catch(e){c.push(...e instanceof Ct?e.errors:[e])}};o&&(null==(a=t.template)?void 0:a.$video)&&d(()=>t.reset()),d(()=>l.scope.dispose()),d(()=>{var e;return null==(e=t.template)?void 0:e.destroy(r)});const p=e.indexOf(t);-1!==p&&e.splice(p,1),t.isDestroy=!0,n||(null==(i=l.releaseContainer)||i.call(l),l.releaseContainer=void 0),d(()=>t.emit("destroy")),n&&l.rollback&&d(l.rollback),l.rollback=void 0,null==(s=l.releaseContainer)||s.call(l),l.releaseContainer=void 0;for(const h of c.slice(1))console.warn("Additional ArtPlayer cleanup failure:",h);if(c.length)throw c[0]}function Ot(t,e,r){if(t.closed)return()=>{};let o=!0,n=()=>{};const a=setTimeout(()=>{o&&(n(),t.closed||e())},r);return n=t.add(()=>{o=!1,clearTimeout(a)}),n}function Rt(t,e=0){return t.closed?Promise.resolve(!1):new Promise(r=>{let o=!1,n=()=>{};const a=setTimeout(()=>{o=!0,n(),r(!0)},e);n=t.add(()=>{clearTimeout(a),o||r(!1)})})}function _t(t,e){const{$progress:r}=t.template,{left:o}=B(r),n=J((k?e.touches[0].clientX:e.clientX)-o,0,r.clientWidth),a=n/r.clientWidth*t.duration;return{second:a,time:tt(a),width:n,percentage:J(n/r.clientWidth,0,1)}}function Vt(t,e){if(t.isRotate){const r=(e.touches[0].clientY-t.top)/t.height,o=r*t.duration;t.emit("setBar","played",r,e),t.seek=o}else{const{second:r,percentage:o}=_t(t,e);t.emit("setBar","played",o,e),t.seek=r}}function Yt(t){return e=>{const{icons:r,option:o,proxy:n}=e,{$player:a,$progress:i}=e.template;return c(l({},t),{html:'\n
\n
\n
\n
\n
\n
\n
00:00
\n
\n ',mounted:t=>{let s=null,l=!1;const c=E(".art-progress-hover",t),d=E(".art-progress-loaded",t),p=E(".art-progress-played",t),h=E(".art-progress-highlight",t),u=E(".art-progress-indicator",t),m=E(".art-progress-tip",t);function f(r,o){const{width:n,time:a}=o||_t(e,r);m.textContent=a||"00:00";const i=m.clientWidth;n<=i/2?P(m,"left",0):n>t.clientWidth-i/2?P(m,"left",t.clientWidth-i+"px"):P(m,"left",n-i/2+"px")}r.indicator?S(u,r.indicator):P(u,"backgroundColor","var(--art-theme)"),e.on("setBar",function(r,o,n){const i="played"===r&&n&&k;if("loaded"===r&&P(d,"width",100*o+"%"),"hover"===r&&(P(c,"width",100*o+"%"),V(n,h)?function(r){const{width:o}=_t(e,r),{text:n}=r.target.dataset;m.textContent=n;const a=m.clientWidth;o<=a/2?P(m,"left",0):o>t.clientWidth-a/2?P(m,"left",t.clientWidth-a+"px"):P(m,"left",o-a/2+"px")}(n):f(n),0===o?z(a,"art-progress-hover"):C(a,"art-progress-hover")),"played"===r&&(P(p,"width",100*o+"%"),P(u,"left",100*o+"%")),i){C(a,"art-progress-hover");f(n,{width:t.clientWidth*o,time:tt(o*e.duration)}),clearTimeout(s),s=setTimeout(()=>{z(a,"art-progress-hover")},500)}}),e.on("video:loadedmetadata",function(){h.textContent="";for(let t=0;t`;S(h,a)}}),e.constructor.USE_RAF?e.on("raf",()=>{e.emit("setBar","played",e.played),e.emit("setBar","loaded",e.loaded)}):(e.on("video:timeupdate",()=>{e.emit("setBar","played",e.played)}),e.on("video:progress",()=>{e.emit("setBar","loaded",e.loaded)}),e.on("video:ended",()=>{e.emit("setBar","played",1)})),e.emit("setBar","loaded",e.loaded||0),k||(n(i,"click",t=>{t.target!==u&&Vt(e,t)}),n(i,"mousemove",t=>{const{percentage:r}=_t(e,t);e.emit("setBar","hover",r,t)}),n(i,"mouseleave",t=>{e.emit("setBar","hover",0,t)}),n(i,"mousedown",t=>{l=0===t.button}),e.on("document:mousemove",t=>{if(l){const{second:r,percentage:o}=_t(e,t);e.emit("setBar","played",o,t),e.seek=r}}),e.on("document:mouseup",()=>{l&&(l=!1)}))}})}}class Nt extends Et{constructor(t){super(t),this.isHover=!1,this.name="control",this.timer=Date.now();const{constructor:e}=t,{$player:r,$bottom:o}=this.art.template;t.on("mousemove",()=>{k||(this.show=!0)}),t.on("click",()=>{k?this.toggle():this.show=!0}),t.on("document:mousemove",t=>{this.isHover=V(t,o)}),t.on("video:timeupdate",()=>{!t.setting.show&&!this.isHover&&!t.isInput&&t.playing&&this.show&&Date.now()-this.timer>=e.CONTROL_HIDE_TIME&&(this.show=!1)}),t.on("control",t=>{t?(z(r,"art-hide-cursor"),C(r,"art-hover"),this.timer=Date.now()):(C(r,"art-hide-cursor"),z(r,"art-hover"))}),this.init()}init(){const{option:t}=this.art;t.isLive||this.add(Yt({name:"progress",position:"top",index:10})),this.add({name:"thumbnails",position:"top",index:20}),this.add(function(t){return e=>c(l({},t),{mounted:t=>{const{proxy:r,icons:o,i18n:n}=e,a=S(t,o.play),i=S(t,o.pause);function s(){P(a,"display","flex"),P(i,"display","none")}function l(){P(a,"display","none"),P(i,"display","flex")}R(a,n.get("Play")),R(i,n.get("Pause")),r(a,"click",()=>{G(e.play())}),r(i,"click",()=>{e.pause()}),e.playing?l():s(),e.on("video:playing",()=>{l()}),e.on("video:pause",()=>{s()})}})}({name:"playAndPause",position:"left",index:10})),this.add(function(t){return e=>c(l({},t),{mounted:t=>{const{proxy:r,icons:o}=e,n=S(t,o.volume),a=S(t,o.volumeClose),i=S(t,'
'),s=S(i,'
'),l=S(s,'
'),c=S(s,'
'),d=S(c,'
'),p=S(d,'
'),h=S(c,'
');function u(t){const{top:e,height:r}=B(c);return 1-(t.clientY-e)/r}function m(){if(e.muted||0===e.volume)P(n,"display","none"),P(a,"display","flex"),P(h,"top","100%"),P(p,"top","100%"),l.textContent=0;else{const t=100*e.volume;P(n,"display","flex"),P(a,"display","none"),P(h,"top",100-t+"%"),P(p,"top",100-t+"%"),l.textContent=Math.floor(t)}}if(m(),e.on("video:volumechange",m),r(n,"click",()=>{e.muted=!0}),r(a,"click",()=>{e.muted=!1}),k)P(i,"display","none");else{let t=!1;r(c,"mousedown",r=>{t=0===r.button,e.volume=u(r)}),e.on("document:mousemove",r=>{t&&(e.muted=!1,e.volume=u(r))}),e.on("document:mouseup",()=>{t&&(t=!1)})}}})}({name:"volume",position:"left",index:20})),t.isLive||this.add(function(t){return e=>c(l({},t),{style:k?{fontSize:"12px",padding:"0 5px"}:{cursor:"auto",padding:"0 10px"},mounted:t=>{function r(){const r=`${tt(e.currentTime)} / ${tt(e.duration)}`;r!==t.textContent&&(t.textContent=r)}r();const o=["video:loadedmetadata","video:timeupdate","video:progress"];for(let n=0;n{e&&!Pt(this.art).closed&&(this.art.quality=t.quality)}),t.screenshot&&!k&&this.add(function(t){return e=>c(l({},t),{tooltip:e.i18n.get("Screenshot"),mounted:t=>{const{proxy:r,icons:o}=e;S(t,o.screenshot),r(t,"click",()=>{e.screenshot()})}})}({name:"screenshot",position:"right",index:20})),t.setting&&this.add(function(t){return e=>c(l({},t),{tooltip:e.i18n.get("Show Setting"),mounted:t=>{const{proxy:r,icons:o,i18n:n}=e;S(t,o.setting),r(t,"click",()=>{e.setting.toggle(),e.setting.resize()}),e.on("setting",e=>{R(t,n.get(e?"Hide Setting":"Show Setting"))})}})}({name:"setting",position:"right",index:30})),t.pip&&this.add(function(t){return e=>c(l({},t),{tooltip:e.i18n.get("PIP Mode"),mounted:t=>{const{proxy:r,icons:o,i18n:n}=e;S(t,o.pip),r(t,"click",()=>{e.pip=!e.pip}),e.on("pip",e=>{R(t,n.get(e?"Exit PIP Mode":"PIP Mode"))})}})}({name:"pip",position:"right",index:40})),t.airplay&&window.WebKitPlaybackTargetAvailabilityEvent&&this.add(function(t){return e=>c(l({},t),{tooltip:e.i18n.get("AirPlay"),mounted:t=>{const{proxy:r,icons:o}=e;S(t,o.airplay),r(t,"click",()=>e.airplay())}})}({name:"airplay",position:"right",index:50})),t.fullscreenWeb&&this.add(function(t){return e=>c(l({},t),{tooltip:e.i18n.get("Web Fullscreen"),mounted:t=>{const{proxy:r,icons:o,i18n:n}=e,a=S(t,o.fullscreenWebOn),i=S(t,o.fullscreenWebOff);P(i,"display","none"),r(t,"click",()=>{e.fullscreenWeb=!e.fullscreenWeb}),e.on("fullscreenWeb",e=>{e?(R(t,n.get("Exit Web Fullscreen")),P(a,"display","none"),P(i,"display","inline-flex")):(R(t,n.get("Web Fullscreen")),P(a,"display","inline-flex"),P(i,"display","none"))})}})}({name:"fullscreenWeb",position:"right",index:60})),t.fullscreen&&this.add(function(t){return e=>c(l({},t),{tooltip:e.i18n.get("Fullscreen"),mounted:t=>{const{proxy:r,icons:o,i18n:n}=e,a=S(t,o.fullscreenOn),i=S(t,o.fullscreenOff);P(i,"display","none"),r(t,"click",()=>{e.fullscreen=!e.fullscreen}),e.on("fullscreen",e=>{e?(R(t,n.get("Exit Fullscreen")),P(a,"display","none"),P(i,"display","inline-flex")):(R(t,n.get("Fullscreen")),P(a,"display","inline-flex"),P(i,"display","none"))})}})}({name:"fullscreen",position:"right",index:70}));for(let e=0;et.selector}),at(e,"$control_item",{get:()=>r}),at(e,"$control_value",{get:()=>n})}const i=o(a,"click",e=>d(this,null,function*(){const r=j(e),o=t.selector.find(t=>t.$control_item===r.find(e=>t.$control_item===e));this.check(o),t.onSelect&&(n.innerHTML=yield t.onSelect.call(this.art,o,o.$control_item,e))}));r.push(i)}}function Dt(t,e,r,o){const n=e-o,a=r-t;let i=0;if(Math.abs(a)<2&&Math.abs(n)<2)return i;const s=function(t,e){return 180*Math.atan2(e,t)/Math.PI}(a,n);return s>=-45&&s<45?i=4:s>=45&&s<135?i=1:s>=-135&&s<-45?i=2:(s>=135&&s<=180||s>=-180&&s<-135)&&(i=3),i}function Ft(t){if(t.constructor.USE_RAF){const e=Pt(t);let r=()=>{};!function o(){t.playing&&t.emit("raf"),t.isDestroy||(r=function(t,e){if(t.closed)return()=>{};let r=!0,o=()=>{};const n=requestAnimationFrame(n=>{r&&(o(),t.closed||e(n))});return o=t.add(()=>{r=!1,cancelAnimationFrame(n)}),o}(e,o))}(),t.on("destroy",()=>{r()})}}const Ht=new WeakMap;class Bt{constructor(t){this.destroyEvents=new Set;const e=Pt(t);Ht.set(this,e),e.add(()=>this.destroy()),this.proxy=this.proxy.bind(this),this.hover=this.hover.bind(this),function(t,e){const{constructor:r,template:{$player:o,$video:n}}=t;function a(e){V(e,o)?(t.isInput="INPUT"===e.target.tagName,t.isFocus=!0,t.emit("focus",e)):(t.isInput=!1,t.isFocus=!1,t.emit("blur",e))}t.on("document:click",a),t.on("document:contextmenu",a);let i=[];e.proxy(n,"click",e=>{const o=Date.now();i.push(o);const{MOBILE_CLICK_PLAY:n,DBCLICK_TIME:a,MOBILE_DBCLICK_PLAY:s,DBCLICK_FULLSCREEN:l}=r,c=i.filter(t=>o-t<=a);switch(c.length){case 1:t.emit("click",e),k?!t.isLock&&n&&G(t.toggle()):G(t.toggle()),i=c;break;case 2:t.emit("dblclick",e),k?!t.isLock&&s&&G(t.toggle()):l&&(t.fullscreen=!t.fullscreen),i=[];break;default:i=[]}})}(t,this),function(t,e){const{$player:r}=t.template;e.hover(r,e=>{C(r,"art-hover"),t.emit("hover",!0,e)},e=>{z(r,"art-hover"),t.emit("hover",!1,e)})}(t,this),function(t,e){const{$player:r}=t.template;e.proxy(r,"mousemove",e=>{t.emit("mousemove",e)})}(t,this),function(t,e){const{option:r,constructor:o}=t;t.on("resize",()=>{const{aspectRatio:e,notice:o}=t;"standard"===t.state&&r.autoSize&&t.autoSize(),t.aspectRatio=e,o.show=""});const n=Pt(t);let a=()=>{};const i=()=>{a(),a=Ot(n,()=>t.emit("resize"),o.RESIZE_TIME)};t.on("window:orientationchange",()=>i()),t.on("window:resize",()=>i()),screen&&screen.orientation&&screen.orientation.onchange&&e.proxy(screen.orientation,"change",()=>i())}(t,this),function(t,e){if(k&&!t.option.isLive){const{$video:r,$progress:o}=t.template;let n=null,a=!1,i=0,s=0,l=0;const c=e=>{if(1===e.touches.length&&!t.isLock){n===o&&Vt(t,e),a=!0;const{pageX:r,pageY:c}=e.touches[0];i=r,s=c,l=t.currentTime}},d=e=>{if(1===e.touches.length&&a&&t.duration){const{pageX:o,pageY:a}=e.touches[0],c=Dt(i,s,o,a),d=[3,4].includes(c),p=[1,2].includes(c);if(d&&!t.isRotate||p&&t.isRotate){const c=J((o-i)/t.width,-1,1),d=J((a-s)/t.height,-1,1),p=t.isRotate?d:c,h=n===r?t.constructor.TOUCH_MOVE_RATIO:1,u=J(l+t.duration*p*h,0,t.duration);t.seek=u,t.emit("setBar","played",J(u/t.duration,0,1),e),t.notice.show=`${tt(u)} / ${tt(t.duration)}`}}},p=()=>{a&&(i=0,s=0,l=0,a=!1,n=null)};t.option.gesture&&(e.proxy(r,"touchstart",t=>{n=r,c(t)}),e.proxy(r,"touchmove",d)),e.proxy(o,"touchstart",t=>{n=o,c(t)}),e.proxy(o,"touchmove",d),t.on("document:touchend",p)}}(t,this),function(t){const{option:e,constructor:r,template:{$container:o}}=t,n=ut(()=>{t.emit("view",_(o,r.SCROLL_GAP))},r.SCROLL_TIME);t.on("window:scroll",()=>n()),t.on("view",r=>{e.autoMini&&(t.mini=!r)})}(t),function(t,e){const r=["click","mouseup","keydown","touchend","touchmove","mousemove","pointerup","contextmenu","pointermove","visibilitychange","webkitfullscreenchange"],o=["resize","scroll","orientationchange"],n=[];function a(a={}){for(let t=0;t{const o=a.document||i.ownerDocument||document,s=e.proxy(o,r,e=>{t.emit(`document:${r}`,e)});n.push(s)}),o.forEach(r=>{var o;const s=a.window||(null==(o=i.ownerDocument)?void 0:o.defaultView)||window,l=e.proxy(s,r,e=>{t.emit(`window:${r}`,e)});n.push(l)})}a(),e.bindGlobalEvents=a}(t,this),Ft(t)}proxy(t,e,r,o={}){if(Array.isArray(e))return e.map(e=>this.proxy(t,e,r,o));if(Ht.get(this).closed)return()=>{};t.addEventListener(e,r,o);const n=()=>t.removeEventListener(e,r,o);return this.destroyEvents.add(n),n}hover(t,e,r){e&&this.proxy(t,"mouseenter",e),r&&this.proxy(t,"mouseleave",r)}remove(t){if(this.destroyEvents.has(t))try{t()}catch(e){console.warn("Failed to remove event listener:",e)}finally{this.destroyEvents.delete(t)}}destroy(){for(const e of this.destroyEvents)try{e()}catch(t){console.warn("Failed to destroy event listener:",t)}this.destroyEvents.clear()}}class Wt{constructor(t){this.art=t,this.keys={},k||this.init()}init(){const{constructor:t}=this.art;this.art.option.hotkey&&(this.add("Escape",()=>{this.art.fullscreenWeb&&(this.art.fullscreenWeb=!1)}),this.add("Space",()=>{G(this.art.toggle())}),this.add("ArrowLeft",()=>{this.art.backward=t.SEEK_STEP}),this.add("ArrowUp",()=>{this.art.volume+=t.VOLUME_STEP}),this.add("ArrowRight",()=>{this.art.forward=t.SEEK_STEP}),this.add("ArrowDown",()=>{this.art.volume-=t.VOLUME_STEP})),this.art.on("document:keydown",t=>{if(this.art.isFocus){const e=document.activeElement.tagName.toUpperCase(),r=document.activeElement.getAttribute("contenteditable");if("INPUT"!==e&&"TEXTAREA"!==e&&""!==r&&"true"!==r&&!t.altKey&&!t.ctrlKey&&!t.metaKey&&!t.shiftKey){const e=this.keys[t.code];if(e){t.preventDefault();for(let r=0;r\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n',state:'\r\n\r\n\r\n',play:'\r\n \r\n',pause:'\r\n \r\n',check:'\r\n\r\n',volume:'\r\n \r\n \r\n',volumeClose:'\r\n \r\n \r\n',screenshot:'\r\n\t\r\n\r\n',setting:'\r\n \r\n \r\n',pip:'\r\n\r\n',arrowLeft:'\r\n \r\n',arrowRight:'\r\n \r\n',playbackRate:'',aspectRatio:'',config:'',lock:'\r\n\r\n\r\n\r\n\r\n',flip:'\r\n\r\n\r\n\r\n\r\n\r\n',unlock:'\r\n\r\n\r\n',fullscreenOff:'\r\n\r\n\r\n\r\n\r\n',fullscreenOn:'\r\n\r\n\r\n\r\n\r\n',fullscreenWebOff:'\r\n\r\n\r\n\r\n\r\n',fullscreenWebOn:'\r\n\r\n\r\n\r\n\r\n',switchOn:'\r\n\r\n\r\n \r\n',switchOff:'\r\n\r\n\r\n \r\n\r\n',error:'\r\n\r\n\r\n\r\n\r\n',close:'\r\n\r\n\r\n\r\n\r\n',airplay:'\r\n \r\n \r\n \r\n \r\n\r\n'},t.option.icons);for(const r in e)at(this,r,{get:()=>D(r,e[r])})}}class Xt extends Et{constructor(t){super(t),this.name="info",k||this.init()}init(){const{proxy:t,constructor:e,template:{$infoPanel:r,$infoClose:o,$video:n}}=this.art;t(o,"click",()=>{this.show=!1});let a=()=>{};const i=T("[data-video]",r)||[];this.art.on("destroy",()=>a());const s=Pt(this.art);!function t(){for(let e=0;e{P(n,"display","none"),P(a,"display",null)}),o.proxy(e.$state,"click",()=>G(t.play()))}}class Jt{constructor(t){this.art=t,this.timer=null,Pt(t).add(()=>this.destroy()),t.on("destroy",()=>this.destroy())}destroy(){this.timer&&(clearTimeout(this.timer),this.timer=null)}set show(t){if(Pt(this.art).closed)return;const{constructor:e,template:{$player:r,$noticeInner:o}}=this.art;t?(o.textContent=t instanceof Error?t.message.trim():t,C(r,"art-notice-show"),clearTimeout(this.timer),this.timer=setTimeout(()=>{o.textContent="",z(r,"art-notice-show")},e.NOTICE_TIME)):z(r,"art-notice-show")}get show(){const{template:{$player:t}}=this.art;return t.classList.contains("art-notice-show")}}const Qt=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],te=(()=>{if("undefined"===typeof document)return!1;const t=Qt[0],e={};for(const r of Qt){if(r[1]in document){for(const[o,n]of r.entries())e[t[o]]=n;return e}}return!1})(),ee={change:te.fullscreenchange,error:te.fullscreenerror},re={request:(t=document.documentElement,e)=>new Promise((r,o)=>{const n=()=>{re.off("change",n),r()};re.on("change",n);const a=t[te.requestFullscreen](e);a instanceof Promise&&a.then(n).catch(o)}),exit:()=>new Promise((t,e)=>{if(!re.isFullscreen)return void t();const r=()=>{re.off("change",r),t()};re.on("change",r);const o=document[te.exitFullscreen]();o instanceof Promise&&o.then(r).catch(e)}),toggle:(t,e)=>re.isFullscreen?re.exit():re.request(t,e),onchange(t){re.on("change",t)},onerror(t){re.on("error",t)},on(t,e){const r=ee[t];r&&document.addEventListener(r,e,!1)},off(t,e){const r=ee[t];r&&document.removeEventListener(r,e,!1)},raw:te};function oe(t){const{i18n:e,notice:r,template:{$video:o,$player:n}}=t,a=t=>{re.on("change",()=>{t.emit("fullscreen",re.isFullscreen),re.isFullscreen?(t.state="fullscreen",C(n,"art-fullscreen")):z(n,"art-fullscreen"),t.emit("resize")}),re.on("error",e=>{t.emit("fullscreenError",e)}),at(t,"fullscreen",{get:()=>re.isFullscreen,set(t){return d(this,null,function*(){t?yield re.request(n):yield re.exit()})}})};t.once("video:loadedmetadata",()=>{var n;re.isEnabled?a(t):o.webkitSupportsFullscreen?((n=t).on("document:webkitfullscreenchange",()=>{n.emit("fullscreen",n.fullscreen),n.emit("resize")}),at(n,"fullscreen",{get:()=>document.fullscreenElement===o,set(t){t?(n.state="fullscreen",o.webkitEnterFullscreen()):o.webkitExitFullscreen()}})):at(t,"fullscreen",{get:()=>!1,set(){r.show=e.get("Fullscreen Not Supported")}}),at(t,"fullscreen",lt(t,"fullscreen"))})}function ne(t){const{icons:e,proxy:r,storage:o,template:{$player:n,$video:a}}=t;let i=!1,s=0,l=0;function c(){const{$mini:e}=t.template;e&&(z(n,"art-mini"),P(e,"display","none"),n.prepend(a),t.emit("mini",!1))}function d(e,r){t.playing?(P(e,"display","none"),P(r,"display","flex")):(P(e,"display","flex"),P(r,"display","none"))}function p(){const{$mini:e}=t.template,r=B(e),n=window.innerHeight-r.height-50,a=window.innerWidth-r.width-50;o.set("top",n),o.set("left",a),P(e,"top",`${n}px`),P(e,"left",`${a}px`)}at(t,"mini",{get:()=>L(n,"art-mini"),set(h){if(h){t.state="mini",C(n,"art-mini");const h=function(){const{$mini:n}=t.template;if(n)return S(n,a),P(n,"display","flex");{const n=N("div");C(n,"art-mini-popup"),S(document.body,n),t.template.$mini=n,S(n,a);const p=S(n,'
');S(p,e.close),r(p,"click",c);const h=S(n,'
'),u=S(h,e.play),m=S(h,e.pause);return r(u,"click",()=>G(t.play())),r(m,"click",()=>t.pause()),d(u,m),t.on("video:playing",()=>d(u,m)),t.on("video:pause",()=>d(u,m)),t.on("video:timeupdate",()=>d(u,m)),r(n,"mousedown",t=>{i=0===t.button,s=t.pageX,l=t.pageY}),t.on("document:mousemove",t=>{if(i){C(n,"art-mini-dragging");const e=t.pageX-s,r=t.pageY-l;P(n,"transform",`translate(${e}px, ${r}px)`)}}),t.on("document:mouseup",()=>{if(i){i=!1,z(n,"art-mini-dragging");const t=B(n);o.set("left",t.left),o.set("top",t.top),P(n,"left",`${t.left}px`),P(n,"top",`${t.top}px`),P(n,"transform",null)}}),n}}(),u=o.get("top"),m=o.get("left");"number"===typeof u&&"number"===typeof m?(P(h,"top",`${u}px`),P(h,"left",`${m}px`),_(h)||p()):p(),t.emit("mini",!0)}else c()}})}function ae(t){const{i18n:e,notice:r,template:{$video:o}}=t;document.pictureInPictureEnabled?function(t){const{template:{$video:e},proxy:r,notice:o}=t;e.disablePictureInPicture=!1,at(t,"pip",{get:()=>document.pictureInPictureElement,set(r){r?(t.state="pip",e.requestPictureInPicture().catch(t=>{throw o.show=t,t})):document.exitPictureInPicture().catch(t=>{throw o.show=t,t})}}),r(e,"enterpictureinpicture",()=>{t.emit("pip",!0)}),r(e,"leavepictureinpicture",()=>{t.emit("pip",!1)})}(t):o.webkitSupportsPresentationMode?function(t){const{$video:e}=t.template;e.webkitSetPresentationMode("inline"),at(t,"pip",{get:()=>"picture-in-picture"===e.webkitPresentationMode,set(r){r?(t.state="pip",e.webkitSetPresentationMode("picture-in-picture"),t.emit("pip",!0)):(e.webkitSetPresentationMode("inline"),t.emit("pip",!1))}})}(t):at(t,"pip",{get:()=>!1,set(){r.show=e.get("PIP Not Supported")}})}Object.defineProperties(re,{isFullscreen:{get:()=>Boolean(document[te.fullscreenElement])},element:{enumerable:!0,get:()=>document[te.fullscreenElement]},isEnabled:{enumerable:!0,get:()=>Boolean(document[te.fullscreenEnabled])}});const ie=new WeakMap,se=new WeakMap;function le(t){const e=ie.get(t),r=Pt(t).child(),o={scope:r,assigned:!1,acceptingEvents:!1,active:()=>!At(t)&&!r.closed&&ie.get(t)===o};return ie.set(t,o),r.add(()=>{ie.get(t)===o&&ie.delete(t),o.onAssigned=void 0,o.onError=void 0}),null==e||e.scope.dispose(),o}function ce(t){t.assigned=!0;const e=t.onAssigned;t.onAssigned=void 0,t.active()&&(null==e||e())}function de(t,e){t.active()&&(t.onError?t.onError(e):console.warn("Failed to initialize ArtPlayer source:",e),t.scope.dispose())}function pe(t){const{i18n:e,notice:r,option:o,constructor:{instances:n},template:{$video:a}}=t;at(t,"play",{value(){return d(this,null,function*(){const i=function(t){const e=ie.get(t);return()=>ie.get(t)===e&&(!e||e.active())}(t),s=yield a.play();if(!i())return s;const l=e.get("Play");if(!i())return s;if(r.show=l,!i())return s;if(t.emit("play"),o.mutex)for(let e=0;e{t.closed||i||(n&&(i=!0,a()),o(e))};return e[n?"once":"on"](r,s),a=t.add(()=>{e.off(r,s)}),s}function ue(t,e,r){return new Promise((o,n)=>{if(At(t)||e===t.url)return void o();const a=le(t),i=a.scope.child();let s=!1;const l=(t=!1,e)=>{s||(s=!0,a.onError=void 0,a.onAssigned=void 0,i.dispose(),t?n(e):o(),t&&a.scope.dispose())};i.add(()=>{l()});const c=()=>!s&&a.active(),p=t=>l(!0,t);a.onError=p;try{const{playing:o,aspectRatio:n,playbackRate:s}=t;if(t.pause(),!c())return;const h=i.child(),u={"video:error":p,"video:loadedmetadata":()=>{if(c())try{t.currentTime=r}catch(e){p(e)}},"video:canplay":()=>{if(!c())return;h.dispose();d(null,null,function*(){if(t.playbackRate=s,c()&&(t.aspectRatio=n,c())){if(o)try{yield t.play()}catch(e){}c()&&(t.notice.show="",l())}}).catch(p)}},m=i.child(),f=[],g=Object.keys(u);for(const e of g)he(m,t,e,t=>{a.acceptingEvents&&f.push([e,t])},!1);if(function(t,e,r){se.set(t,e),e.acceptingEvents=!0;try{t.url=r}finally{se.get(t)===e&&(se.delete(t),ce(e))}}(t,a,e),!c())return;if(t.notice.show="",!c())return;const v=()=>{if(m.dispose(),!e)return void l();const r={};for(const e of g)r[e]=he(h,t,e,u[e]);for(const[t,e]of f){if(!c()||h.closed)break;r[t](e)}f.length=0};a.assigned?v():a.onAssigned=v}catch(h){p(h)}})}function me(t){const{option:e,template:{$progress:r,$video:o}}=t;let n=null,a=!1,i=null;t.on("setBar",(n,s,l)=>d(null,null,function*(){var c;const d=null==(c=t.controls)?void 0:c.thumbnails,{url:p,scale:h}=e.thumbnails;if(!d||!p)return;if("hover"===n||"played"===n&&l&&k){if(i||a||(a=!0,i=yield W(p,h),a=!1),!i)return;const n=r.clientWidth*s;n>0&&nr.clientWidth-u/2?P(s,"left",r.clientWidth-u+"px"):P(s,"left",n-u/2+"px")}(n)}})),at(t,"thumbnails",{get:()=>t.option.thumbnails,set(e){e.url&&!t.option.isLive&&(t.option.thumbnails=e,clearTimeout(n),n=null,a=!1,i=null)}})}function fe(t){const{option:e,template:{$video:r}}=t;at(t,"url",{get:()=>r.src,set(o){return d(this,null,function*(){if(At(t))return;const n=function(t){const e=se.get(t);return se.delete(t),e||le(t)}(t);n.acceptingEvents=!1;try{if(!o)return void((yield Rt(n.scope))&&n.active()&&(t.loading.show=!0));const a=t.url,i=e.type||K(o),s=e.customType[i];if(i&&s){if(!(yield Rt(n.scope))||!n.active())return;t.loading.show=!0}if(!n.active())return;const l=n.scope.child();let c=!1,d=!1;he(l,t,"video:canplay",()=>{c=!d}),he(l,t,"video:error",()=>{d=!0});try{if(n.acceptingEvents=!0,i&&s){const e=s.call(t,r,o,t);Promise.resolve(e).catch(t=>de(n,t))}else{if(a&&URL.revokeObjectURL(a),!n.active())return;r.src=o}}finally{l.dispose()}if(!n.active())return;if(a!==t.url&&(t.option.url=o,n.active()&&t.isReady&&a)){const e=()=>{n.active()&&t.emit("restart",o)};c?e():d||he(n.scope,t,"video:canplay",e)}}catch(a){de(n,a)}finally{ce(n)}})}})}class ge{constructor(t){fe(t),function(t){const{template:{$video:e}}=t;at(t,"attr",{value(t,r){if(void 0===r)return e[t];e[t]=r}})}(t),pe(t),function(t){const{template:{$video:e},i18n:r,notice:o}=t;at(t,"pause",{value(){const n=e.pause();return o.show=r.get("Pause"),t.emit("pause"),n}})}(t),function(t){at(t,"toggle",{value:()=>t.playing?t.pause():t.play()})}(t),function(t){const{notice:e}=t;at(t,"seek",{set(r){t.currentTime=r,t.duration&&(e.show=`${tt(t.currentTime)} / ${tt(t.duration)}`),t.emit("seek",t.currentTime,r)}}),at(t,"forward",{set(e){t.seek=t.currentTime+e}}),at(t,"backward",{set(e){t.seek=t.currentTime-e}})}(t),function(t){const{template:{$video:e},i18n:r,notice:o,storage:n}=t;at(t,"volume",{get:()=>e.volume||0,set:t=>{e.volume=J(t,0,1),o.show=`${r.get("Volume")}: ${Number.parseInt(100*e.volume,10)}`,0!==e.volume&&n.set("volume",e.volume)}}),at(t,"muted",{get:()=>e.muted,set:r=>{e.muted=r,t.emit("muted",r)}})}(t),function(t){const{$video:e}=t.template;at(t,"currentTime",{get:()=>e.currentTime||0,set:r=>{r=Number.parseFloat(r),Number.isNaN(r)||(e.currentTime=J(r,0,t.duration))}})}(t),function(t){at(t,"duration",{get:()=>{const{duration:e}=t.template.$video;return e===1/0?0:e||0}})}(t),function(t){const e=e=>ue(t,e,0);at(t,"switchQuality",{value:e=>ue(t,e,t.currentTime)}),at(t,"switchUrl",{value:e}),at(t,"switch",{set:e})}(t),function(t){const{template:{$video:e},i18n:r,notice:o}=t;at(t,"playbackRate",{get:()=>e.playbackRate,set(n){if(n){if(n===e.playbackRate)return;e.playbackRate=n,o.show=`${r.get("Rate")}: ${1===n?r.get("Normal"):`${n}x`}`}else t.playbackRate=1}})}(t),function(t){const{i18n:e,notice:r,template:{$video:o,$player:n}}=t;at(t,"aspectRatio",{get:()=>n.dataset.aspectRatio||"default",set(a){if(a||(a="default"),"default"===a)P(o,"width",null),P(o,"height",null),P(o,"margin",null),delete n.dataset.aspectRatio;else{const t=a.split(":").map(Number),{clientWidth:e,clientHeight:r}=n,i=e/r,s=t[0]/t[1];i>s?(P(o,"width",s*r+"px"),P(o,"height","100%"),P(o,"margin","0 auto")):(P(o,"width","100%"),P(o,"height",e/s+"px"),P(o,"margin","auto 0")),n.dataset.aspectRatio=a}r.show=`${e.get("Aspect Ratio")}: ${"default"===a?e.get("Default"):a}`,t.emit("aspectRatio",a)}})}(t),function(t){const{notice:e,template:{$video:r}}=t,o=N("canvas");at(t,"getDataURL",{value:()=>new Promise((t,n)=>{try{o.width=r.videoWidth,o.height=r.videoHeight,o.getContext("2d").drawImage(r,0,0),t(o.toDataURL("image/png"))}catch(a){e.show=a,n(a)}})}),at(t,"getBlobUrl",{value:()=>new Promise((t,n)=>{try{o.width=r.videoWidth,o.height=r.videoHeight,o.getContext("2d").drawImage(r,0,0),o.toBlob(e=>{t(URL.createObjectURL(e))})}catch(a){e.show=a,n(a)}})}),at(t,"screenshot",{value:e=>d(null,null,function*(){const o=yield t.getDataURL();return Z(o,`${e||`artplayer_${tt(r.currentTime)}`}.png`),t.emit("screenshot",o),o})})}(t),oe(t),function(t){const{constructor:e,template:{$container:r,$player:o}}=t;let n="";at(t,"fullscreenWeb",{get:()=>L(o,"art-fullscreen-web"),set(a){a?(n=o.style.cssText,e.FULLSCREEN_WEB_IN_BODY&&S(document.body,o),t.state="fullscreenWeb",P(o,"width","100%"),P(o,"height","100%"),C(o,"art-fullscreen-web"),t.emit("fullscreenWeb",!0)):(e.FULLSCREEN_WEB_IN_BODY&&S(r,o),n&&(o.style.cssText=n,n=""),z(o,"art-fullscreen-web"),t.emit("fullscreenWeb",!1)),t.emit("resize")}})}(t),ae(t),function(t){const{$video:e}=t.template;at(t,"loaded",{get:()=>t.loadedTime/e.duration}),at(t,"loadedTime",{get:()=>e.buffered.length?e.buffered.end(e.buffered.length-1):0})}(t),function(t){at(t,"played",{get:()=>t.currentTime/t.duration})}(t),function(t){const{$video:e}=t.template;at(t,"playing",{get:()=>"boolean"===typeof e.playing?e.playing:!!(e.currentTime>0&&!e.paused&&!e.ended&&e.readyState>2)})}(t),function(t){const{$container:e,$player:r,$video:o}=t.template;at(t,"autoSize",{value(){const{videoWidth:n,videoHeight:a}=o,{width:i,height:s}=B(e),l=n/a;if(i/s>l)P(r,"width",s*l/i*100+"%"),P(r,"height","100%");else{const t=i/l/s*100;P(r,"width","100%"),P(r,"height",`${t}%`)}t.emit("autoSize",{width:t.width,height:t.height})}})}(t),function(t){const e=t;at(t,"rect",{get:()=>B(t.template.$player)});const r=["bottom","height","left","right","top","width"];for(let o=0;oe.rect[n]})}at(t,"x",{get:()=>e.left+window.pageXOffset}),at(t,"y",{get:()=>e.top+window.pageYOffset})}(t),function(t){const{template:{$player:e},i18n:r,notice:o}=t;at(t,"flip",{get:()=>e.dataset.flip||"normal",set(n){n||(n="normal"),"normal"===n?delete e.dataset.flip:e.dataset.flip=n,o.show=`${r.get("Video Flip")}: ${r.get(Q(n))}`,t.emit("flip",n)}})}(t),ne(t),function(t){const{template:{$poster:e}}=t;at(t,"poster",{get:()=>{try{return e.style.backgroundImage.match(/"(.*)"/)[1]}catch(t){return""}},set(t){P(e,"backgroundImage",`url(${t})`)}})}(t),function(t){const{template:{$container:e,$video:r}}=t;at(t,"autoHeight",{value(){const{clientWidth:o}=e,{videoHeight:n,videoWidth:a}=r,i=n*(o/a);P(e,"height",`${i}px`),t.emit("autoHeight",i)}})}(t),function(t){const{$player:e}=t.template;at(t,"cssVar",{value:(t,r)=>r?e.style.setProperty(t,r):getComputedStyle(e).getPropertyValue(t)})}(t),function(t){at(t,"theme",{get:()=>t.cssVar("--art-theme"),set(e){t.cssVar("--art-theme",e)}})}(t),function(t){at(t,"type",{get:()=>t.option.type,set(e){t.option.type=e}})}(t),function(t){const e=["mini","pip","fullscreen","fullscreenWeb"];at(t,"state",{get:()=>e.find(e=>t[e])||"standard",set(r){for(let o=0;o{switch(t.availability){case"available":a=!0;break;case"not-available":a=!1}}):a=!1,at(t,"airplay",{value(){a?(n.webkitShowPlaybackTargetPicker(),t.emit("airplay")):r.show=e.get("AirPlay Not Available")}})}(t),function(t){at(t,"quality",{set(e){const{controls:r,notice:o,i18n:n}=t,a=e.find(t=>t.default)||e[0];r.update({name:"quality",position:"right",index:10,style:{marginRight:"10px"},html:(null==a?void 0:a.html)||"",selector:e,onSelect(e){return d(this,null,function*(){return yield t.switchQuality(e.url),o.show=`${n.get("Switch Video")}: ${e.html}`,e.html})}})}})}(t),me(t),function(t){const{i18n:e,notice:r,option:o,constructor:n,proxy:a,template:{$player:i,$video:s,$poster:l}}=t;let c=0;for(let d=0;d{t.emit(`video:${e.type}`,e)});t.on("video:canplay",()=>{c=0,t.loading.show=!1}),t.once("video:canplay",()=>{t.loading.show=!1,t.controls.show=!0,t.mask.show=!0,t.isReady=!0,t.emit("ready")}),t.on("video:ended",()=>{o.loop?(t.seek=0,G(t.play()),t.controls.show=!1,t.mask.show=!1):(t.controls.show=!0,t.mask.show=!0)}),t.on("video:error",a=>d(null,null,function*(){if(c{t.emit("resize"),k&&(t.loading.show=!1,t.controls.show=!0,t.mask.show=!0)}),t.on("video:loadstart",()=>{t.loading.show=!0,t.mask.show=!1,t.controls.show=!0}),t.on("video:pause",()=>{t.controls.show=!0,t.mask.show=!0}),t.on("video:play",()=>{t.mask.show=!1,P(l,"display","none")}),t.on("video:playing",()=>{t.mask.show=!1}),t.on("video:progress",()=>{t.playing&&(t.loading.show=!1)}),t.on("video:seeked",()=>{t.loading.show=!1,t.mask.show=!0}),t.on("video:seeking",()=>{t.loading.show=!0,t.mask.show=!1}),t.on("video:timeupdate",()=>{t.mask.show=!1}),t.on("video:waiting",()=>{t.loading.show=!0,t.mask.show=!1})}(t),function(t){const{option:e,storage:r,template:{$video:o,$poster:n}}=t;for(const i in e.moreVideoAttr)t.attr(i,e.moreVideoAttr[i]);e.muted&&(t.muted=e.muted),e.volume&&(o.volume=J(e.volume,0,1));const a=r.get("volume");"number"===typeof a&&(o.volume=J(a,0,1)),e.poster&&P(n,"backgroundImage",`url(${e.poster})`),e.autoplay&&(o.autoplay=e.autoplay),e.playsInline&&(o.playsInline=!0,o["webkit-playsinline"]=!0),e.theme&&(e.cssVar["--art-theme"]=e.theme);for(const i in e.cssVar)t.cssVar(i,e.cssVar[i]);t.url=e.url}(t)}}function ve(t){const{notice:e,constructor:r,template:{$player:o,$video:n}}=t,a="art-auto-orientation",i="art-auto-orientation-fullscreen";let s=!1;function l(){const{videoWidth:t,videoHeight:e}=n,r=document.documentElement.clientWidth,o=document.documentElement.clientHeight;return t>e&&ro}return t.on("fullscreenWeb",e=>{var n;if(e){if(l()){const e=Number(null!=(n=r.AUTO_ORIENTATION_TIME)?n:0);setTimeout(()=>{t.fullscreenWeb&&!L(o,a)&&function(){const e=U(),r=document.documentElement.clientWidth,n=document.documentElement.clientHeight-e.top-e.bottom,i=r-e.left-e.right;P(o,"width",`${n}px`),P(o,"height",`${i}px`),P(o,"transform-origin","0 0"),P(o,"transform",`rotate(90deg) translate(${e.top}px, -${r-e.right}px)`),C(o,a),t.isRotate=!0,t.emit("resize")}()},e)}}else L(o,a)&&(P(o,"width",""),P(o,"height",""),P(o,"transform-origin",""),P(o,"transform",""),z(o,a),t.isRotate=!1,t.emit("resize"))}),t.on("fullscreen",t=>d(null,null,function*(){var r;const n=!!(null==(r=null==screen?void 0:screen.orientation)?void 0:r.lock);if(t){if(n&&l())try{const t=screen.orientation.type.startsWith("portrait")?"landscape":"portrait";yield screen.orientation.lock(t),s=!0,C(o,i)}catch(a){s=!1,e.show=a}}else if(L(o,i)&&z(o,i),n&&s){try{screen.orientation.unlock()}catch(c){}s=!1}})),{name:"autoOrientation",get state(){return L(o,a)}}}function ye(t){const{i18n:e,icons:r,storage:o,constructor:n,proxy:a,template:{$poster:i}}=t,s=t.layers.add({name:"auto-playback",html:'\n
\n
\n
\n '}),l=E(".art-auto-playback-last",s),c=E(".art-auto-playback-jump",s),d=E(".art-auto-playback-close",s);S(d,r.close);let p=null;function h(){const r=(o.get("times")||{})[t.option.id||t.option.url];clearTimeout(p),P(s,"display","none"),r&&r>=n.AUTO_PLAYBACK_MIN&&(P(s,"display","flex"),l.textContent=`${e.get("Last Seen")} ${tt(r)}`,c.textContent=e.get("Jump Play"),a(d,"click",()=>{P(s,"display","none")}),a(c,"click",()=>{t.seek=r,G(t.play()),P(i,"display","none"),P(s,"display","none")}),t.once("video:timeupdate",()=>{p=setTimeout(()=>{P(s,"display","none")},n.AUTO_PLAYBACK_TIMEOUT)}))}return t.on("video:timeupdate",()=>{if(t.playing){const e=o.get("times")||{},r=Object.keys(e);r.length>n.AUTO_PLAYBACK_MAX&&delete e[r[0]],e[t.option.id||t.option.url]=t.currentTime,o.set("times",e)}}),t.on("ready",h),t.on("restart",h),{name:"auto-playback",get times(){return o.get("times")||{}},clear:()=>o.del("times"),delete(t){const e=o.get("times")||{};return delete e[t],o.set("times",e),e}}}function be(t){const{constructor:e,proxy:r,template:{$player:o,$video:n}}=t;let a=null,i=!1,s=1;const l=()=>{clearTimeout(a),i&&(i=!1,t.playbackRate=s,z(o,"art-fast-forward"))};return r(n,"touchstart",r=>{1===r.touches.length&&t.playing&&!t.isLock&&(a=setTimeout(()=>{i=!0,s=t.playbackRate,t.playbackRate=e.FAST_FORWARD_VALUE,C(o,"art-fast-forward")},e.FAST_FORWARD_TIME))}),t.on("document:touchmove",l),t.on("document:touchend",l),{name:"fastForward",get state(){return L(o,"art-fast-forward")}}}function we(t){const{layers:e,icons:r,template:{$player:o}}=t;function n(){return L(o,"art-lock")}function a(){C(o,"art-lock"),t.isLock=!0,t.emit("lock",!0)}function i(){z(o,"art-lock"),t.isLock=!1,t.emit("lock",!1)}return e.add({name:"lock",mounted(e){const o=S(e,r.lock),n=S(e,r.unlock);P(o,"display","none"),t.on("lock",t=>{t?(P(o,"display","inline-flex"),P(n,"display","none")):(P(o,"display","none"),P(n,"display","inline-flex"))})},click(){n()?i():a()}}),{name:"lock",get state(){return n()},set state(t){t?a():i()}}}function xe(t){return t.on("control",e=>{e?z(t.template.$player,"art-mini-progress-bar"):C(t.template.$player,"art-mini-progress-bar")}),{name:"mini-progress-bar"}}class ke{constructor(t){this.art=t,this.id=0;const{option:e}=t;!function(t,e){At(t.art)||!e.miniProgressBar||e.isLive||t.add(xe),!At(t.art)&&e.lock&&k&&t.add(we),At(t.art)||!e.autoPlayback||e.isLive||t.add(ye),!At(t.art)&&e.autoOrientation&&k&&t.add(ve),!At(t.art)&&e.fastForward&&k&&!e.isLive&&t.add(be)}(this,e);for(let r=0;rconsole.warn("Failed to initialize ArtPlayer plugin:",t))}}add(t){X(!At(this.art),"Cannot add a plugin after ArtPlayer is destroyed"),this.id+=1;const e=t.call(this.art,this.art);return e instanceof Promise?e.then(e=>this.next(t,e)):this.next(t,e)}next(t,e){return function(t,e,r){if(At(t.art))return t;const o=r&&r.name||e.name||`plugin${t.id}`;if(At(t.art))return t;let n=o;const a=st(t,n);if(At(t.art))return t;const i=`Cannot add a plugin that already has the same name: ${o}`;return At(t.art)||(X(!a,i),("object"===typeof o&&null!==o||"function"===typeof o)&&(n=Reflect.ownKeys({[n]:void 0})[0]),At(t.art)||at(t,n,{value:r})),t}(this,t,e)}}class $e extends Et{constructor(t){super(t);const{option:e,controls:r,template:{$setting:o}}=t;this.name="setting",this.$parent=o,this.id=0,this.active=null,this.cache=new Map,this.option=[...this.builtin,...e.settings],e.setting&&(this.format(),this.render(),t.on("blur",()=>{this.show&&(this.show=!1,this.render())}),t.on("focus",t=>{const e=V(t,r.setting),o=V(t,this.$parent);!this.show||e||o||(this.show=!1,this.render())}),t.on("resize",()=>this.resize()))}get builtin(){const t=[],{option:e}=this.art;return e.playbackRate&&t.push(function(t){const{i18n:e,icons:r,constructor:{SETTING_ITEM_WIDTH:o,PLAYBACK_RATE:n}}=t;function a(t){return 1===t?e.get("Normal"):t.toFixed(1)}function i(){const e=t.setting.find(`playback-rate-${t.playbackRate}`);t.setting.check(e)}return{width:o,name:"playback-rate",html:e.get("Play Speed"),tooltip:a(t.playbackRate),icon:r.playbackRate,selector:n.map(e=>({value:e,name:`playback-rate-${e}`,default:e===t.playbackRate,html:a(e)})),onSelect:e=>(t.playbackRate=e.value,e.html),mounted:()=>{i(),t.on("video:ratechange",()=>i())}}}(this.art)),e.aspectRatio&&t.push(function(t){const{i18n:e,icons:r,constructor:{SETTING_ITEM_WIDTH:o,ASPECT_RATIO:n}}=t;function a(t){return"default"===t?e.get("Default"):t}function i(){const e=t.setting.find(`aspect-ratio-${t.aspectRatio}`);t.setting.check(e)}return{width:o,name:"aspect-ratio",html:e.get("Aspect Ratio"),icon:r.aspectRatio,tooltip:a(t.aspectRatio),selector:n.map(e=>({value:e,name:`aspect-ratio-${e}`,default:e===t.aspectRatio,html:a(e)})),onSelect:e=>(t.aspectRatio=e.value,e.html),mounted:()=>{i(),t.on("aspectRatio",()=>i())}}}(this.art)),e.flip&&t.push(function(t){const{i18n:e,icons:r,constructor:{SETTING_ITEM_WIDTH:o,FLIP:n}}=t;function a(t){return e.get(Q(t))}function i(){const e=t.setting.find(`flip-${t.flip}`);t.setting.check(e)}return{width:o,name:"flip",html:e.get("Video Flip"),tooltip:a(t.flip),icon:r.flip,selector:n.map(e=>({value:e,name:`flip-${e}`,default:e===t.flip,html:a(e)})),onSelect:e=>(t.flip=e.value,e.html),mounted:()=>{i(),t.on("flip",()=>i())}}}(this.art)),e.subtitleOffset&&t.push(function(t){const{i18n:e,icons:r,constructor:o}=t;return{width:o.SETTING_ITEM_WIDTH,name:"subtitle-offset",html:e.get("Subtitle Offset"),icon:r.subtitle,tooltip:"0s",range:[0,-10,10,.1],onChange:e=>(t.subtitleOffset=e.range[0],`${e.range[0]}s`),mounted:(e,r)=>{t.on("subtitleOffset",t=>{r.$range.value=t,r.tooltip=`${t}s`})}}}(this.art)),t}traverse(t,e=this.option){var r;for(let o=0;o{e.default=e===t,e.default&&e.$item&&O(e.$item,"art-current")},t.$option),this.render(t.$parents))}format(t=this.option,e,r,o=[]){for(let n=0;ne}),at(a,"$parents",{get:()=>r}),at(a,"$option",{get:()=>t});const o=[];at(a,"$events",{get:()=>o}),at(a,"$formatted",{get:()=>!0})}this.format(a.selector||[],a,t,o)}this.option=t}find(t=""){let e=null;return this.traverse(r=>{r.name===t&&(e=r)}),e}resize(){var t,e;const{controls:r,constructor:{SETTING_WIDTH:o,SETTING_ITEM_HEIGHT:n},template:{$player:a,$setting:i}}=this.art;if(r.setting&&this.show){const s=(null==(e=null==(t=this.active[0])?void 0:t.$parent)?void 0:e.width)||o,{left:l,width:c}=B(r.setting),{left:d,width:p}=B(a),h=l-d+c/2-s/2;if(P(i,"height",`${this.active===this.option?this.active.length*n:(this.active.length+1)*n}px`),P(i,"width",`${s}px`),this.art.isRotate||k)return;h+s>p?(P(i,"left",null),P(i,"right",null)):(P(i,"left",`${h}px`),P(i,"right","auto"))}}inactivate(t){for(let e=0;e'),s=N("div");C(s,"art-setting-item-left-icon"),S(s,o),S(i,s),S(i,t.$parent.html);const l=r(a,"click",()=>this.render(t.$parents));t.$parent.$events.push(l),S(e,a)}createItem(t,e=!1){var r,o;if(!this.cache.has(t.$option))return;const n=this.cache.get(t.$option),a=t.$item;let i="selector";st(t,"switch")&&(i="switch"),st(t,"range")&&(i="range"),st(t,"onClick")&&(i="button");const{icons:s,proxy:l,constructor:c}=this.art,p=N("div");C(p,"art-setting-item"),P(p,"height",`${c.SETTING_ITEM_HEIGHT}px`),p.dataset.name=t.name||"",p.dataset.value=t.value||"";const h=S(p,'
'),u=S(p,'
'),m=N("div");switch(C(m,"art-setting-item-left-icon"),i){case"button":case"switch":case"range":S(m,t.icon||s.config);break;case"selector":(null==(r=t.selector)?void 0:r.length)?S(m,t.icon||s.config):S(m,s.check)}S(h,m),at(t,"$icon",{configurable:!0,get:()=>m}),at(t,"icon",{configurable:!0,get:()=>m.innerHTML,set(t){m.innerHTML="",S(m,t)}});const f=N("div");C(f,"art-setting-item-left-text"),S(f,t.html||""),S(h,f),at(t,"$html",{configurable:!0,get:()=>f}),at(t,"html",{configurable:!0,get:()=>f.innerHTML,set(t){f.innerHTML="",S(f,t)}});const g=N("div");switch(C(g,"art-setting-item-right-tooltip"),S(g,t.tooltip||""),S(u,g),at(t,"$tooltip",{configurable:!0,get:()=>g}),at(t,"tooltip",{configurable:!0,get:()=>g.innerHTML,set(t){g.innerHTML="",S(g,t)}}),i){case"switch":{const e=N("div");C(e,"art-setting-item-right-icon");const r=S(e,s.switchOn),o=S(e,s.switchOff);P(t.switch?o:r,"display","none"),S(u,e),at(t,"$switch",{configurable:!0,get:()=>e});let n=t.switch;at(t,"switch",{configurable:!0,get:()=>n,set(t){n=t,t?(P(o,"display","none"),P(r,"display",null)):(P(o,"display",null),P(r,"display","none"))}});break}case"range":{const e=N("div");C(e,"art-setting-item-right-icon");const r=S(e,'');r.value=t.range[0],r.min=t.range[1],r.max=t.range[2],r.step=t.range[3],C(r,"art-setting-range"),S(u,e),at(t,"$range",{configurable:!0,get:()=>r});let o=[...t.range];at(t,"range",{configurable:!0,get:()=>o,set(t){o=[...t],r.value=t[0],r.min=t[1],r.max=t[2],r.step=t[3]}})}break;case"selector":if(null==(o=t.selector)?void 0:o.length){const t=N("div");C(t,"art-setting-item-right-icon"),S(t,s.arrowRight),S(u,t)}}switch(i){case"switch":if(t.onSwitch){const e=l(p,"click",e=>d(this,null,function*(){t.switch=yield t.onSwitch.call(this.art,t,p,e)}));t.$events.push(e)}break;case"range":if(t.$range){if(t.onRange){const e=l(t.$range,"change",e=>d(this,null,function*(){t.range[0]=t.$range.valueAsNumber,t.tooltip=yield t.onRange.call(this.art,t,p,e)}));t.$events.push(e)}if(t.onChange){const e=l(t.$range,"input",e=>d(this,null,function*(){t.range[0]=t.$range.valueAsNumber,t.tooltip=yield t.onChange.call(this.art,t,p,e)}));t.$events.push(e)}}break;case"selector":{const e=l(p,"click",e=>d(this,null,function*(){var r;(null==(r=t.selector)?void 0:r.length)?this.render(t.selector):(this.check(t),t.$parent.onSelect&&(t.$parent.tooltip=yield t.$parent.onSelect.call(this.art,t,p,e)))}));t.$events.push(e),t.default&&C(p,"art-current")}break;case"button":if(t.onClick){const e=l(p,"click",e=>d(this,null,function*(){t.tooltip=yield t.onClick.call(this.art,t,p,e)}));t.$events.push(e)}}at(t,"$item",{configurable:!0,get:()=>p}),e?Y(p,a):S(n,p),t.mounted&&Ot(Pt(this.art),()=>t.mounted.call(this.art,t.$item,t),0)}render(t=this.option){var e;if(this.active=t,this.cache.has(t)){O(this.cache.get(t),"art-current")}else{const r=N("div");this.cache.set(t,r),C(r,"art-setting-panel"),S(this.$parent,r),O(r,"art-current"),(null==(e=t[0])?void 0:e.$parent)&&this.createHeader(t[0]);for(let e=0;enull,this.init(t.option.subtitle);let e=!1;t.on("video:timeupdate",()=>{if(!this.url)return;const t=this.art.template.$video.webkitDisplayingFullscreen;"boolean"===typeof t&&t!==e&&(e=t,this.createTrack(t?"subtitles":"metadata",this.url))})}get url(){return this.art.template.$track.src}set url(t){this.switch(t)}get textTrack(){var t,e;return null==(e=null==(t=this.art.template.$video)?void 0:t.textTracks)?void 0:e[0]}get activeCues(){return this.textTrack?Array.from(this.textTrack.activeCues):[]}get cues(){return this.textTrack?Array.from(this.textTrack.cues):[]}style(t,e){const{$subtitle:r}=this.art.template;return"object"===typeof t?A(r,t):P(r,t,e)}update(){const{option:{subtitle:t},template:{$subtitle:e}}=this.art;e.innerHTML="",this.activeCues.length&&(this.art.emit("subtitleBeforeUpdate",this.activeCues),e.innerHTML=this.activeCues.map((e,r)=>e.text.split(/\r?\n/).filter(t=>t.trim()).map(e=>`
\n ${t.escape?nt(e):e}\n
`).join("")).join(""),this.art.emit("subtitleAfterUpdate",this.activeCues))}switch(t){return d(this,arguments,function*(t,e={}){const{i18n:r,notice:o,option:n}=this.art,a=c(l(l({},n.subtitle),e),{url:t}),i=yield this.init(a);return e.name&&(o.show=`${r.get("Switch Subtitle")}: ${e.name}`),i})}createTrack(t,e){const{template:r,proxy:o,option:n}=this.art,{$video:a,$track:i}=r,s=N("track");s.default=!0,s.kind=t,s.src=e,s.label=n.subtitle.name||"Artplayer",s.track.mode="hidden",s.onload=()=>{this.art.emit("subtitleLoad",this.cues,this.option)},this.art.events.remove(this.destroyEvent),i.onload=null,M(i),S(a,s),r.$track=s,this.destroyEvent=o(this.textTrack,"cuechange",()=>this.update())}init(t){return d(this,null,function*(){const{notice:e,template:{$subtitle:r}}=this.art;return this.textTrack?(f(t,$t.subtitle),t.url?(this.option=t,this.style(t.style),fetch(t.url).then(t=>t.arrayBuffer()).then(e=>{const r=new TextDecoder(t.encoding).decode(e);switch(t.type||K(t.url)){case"srt":{const e=dt(r);return pt(t.onVttLoad(e))}case"ass":{const e=ht(r);return pt(t.onVttLoad(e))}case"vtt":return pt(t.onVttLoad(r));default:return t.url}}).then(t=>(r.innerHTML="",this.url===t||(URL.revokeObjectURL(this.url),this.createTrack("metadata",t)),t)).catch(t=>{throw r.innerHTML="",e.show=t,t})):void 0):null})}}class ze{constructor(t){this.art=t;const{option:e,constructor:r}=t;e.container instanceof Element?this.$container=e.container:(this.$container=E(e.container),X(this.$container,`No container element found by ${e.container}`)),X(H(),"The current browser does not support flex layout");const o=this.$container.tagName.toLowerCase();X("div"===o,`Unsupported container element type, only support 'div' but got '${o}'`),X(r.instances.every(t=>t.template.$container!==this.$container),"Cannot mount multiple instances on the same dom element"),this.query=this.query.bind(this),function(t,e,r){const o=St.get(e);if(o&&o!==t)throw new Error("Cannot mount multiple instances on the same dom element");const n=Mt(t);n.rollback=r,St.set(e,t),n.releaseContainer=()=>{St.get(e)===t&&St.delete(e)}}(t,this.$container,function(t){const e=[];return function t(r){const o=Array.from(r.childNodes);e.push({node:r,children:o,attributes:1===r.nodeType?Array.from(r.attributes,t=>[t.name,t.value]):void 0,value:r.nodeValue}),o.forEach(t)}(t),()=>{for(const{node:t,children:r,attributes:o,value:n}of e){for(;t.firstChild;)t.removeChild(t.firstChild);for(const e of r)t.appendChild(e);if(o){const e=t;for(const t of Array.from(e.attributes))e.removeAttribute(t.name);for(const[t,r]of o)e.setAttribute(t,r)}else t.nodeValue=n}}}(this.$container)),this.$container.dataset.artId=t.id,this.init()}static get html(){return`\n
\n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
Player version:
\n
${g}
\n
\n
\n
Video url:
\n
\n
\n
\n
Video volume:
\n
\n
\n
\n
Video time:
\n
\n
\n
\n
Video duration:
\n
\n
\n
\n
Video resolution:
\n
\n x \n
\n
\n
\n
[x]
\n
\n
\n
\n `}query(t){return E(t,this.$container)}init(){const{option:t}=this.art;if(t.useSSR||(this.$container.innerHTML=ze.html),this.$player=this.query(".art-video-player"),this.$video=this.query(".art-video"),this.$track=this.query("track"),this.$poster=this.query(".art-poster"),this.$subtitle=this.query(".art-subtitle"),this.$danmuku=this.query(".art-danmuku"),this.$bottom=this.query(".art-bottom"),this.$progress=this.query(".art-progress"),this.$controls=this.query(".art-controls"),this.$controlsLeft=this.query(".art-controls-left"),this.$controlsCenter=this.query(".art-controls-center"),this.$controlsRight=this.query(".art-controls-right"),this.$layer=this.query(".art-layers"),this.$loading=this.query(".art-loading"),this.$notice=this.query(".art-notice"),this.$noticeInner=this.query(".art-notice-inner"),this.$mask=this.query(".art-mask"),this.$state=this.query(".art-state"),this.$setting=this.query(".art-settings"),this.$info=this.query(".art-info"),this.$infoPanel=this.query(".art-info-panel"),this.$infoClose=this.query(".art-info-close"),this.$contextmenu=this.query(".art-contextmenus"),t.proxy){const e=t.proxy.call(this.art,this.art);X(e instanceof HTMLVideoElement||e instanceof HTMLCanvasElement,"Function 'option.proxy' needs to return 'HTMLVideoElement' or 'HTMLCanvasElement'"),Y(e,this.$video),e.className="art-video",this.$video=e}t.backdrop&&C(this.$player,"art-backdrop"),k&&C(this.$player,"art-mobile")}destroy(t){t?this.$container.innerHTML="":C(this.$player,"art-destroy")}}const Le=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);class Se{on(t,e,r){const o=this.e||(this.e={});let n=Le(o,t)?o[t]:void 0;return n||(n=[],Object.defineProperty(o,t,{value:n,enumerable:!0,configurable:!0,writable:!0})),n.push({fn:e,ctx:r}),this}once(t,e,r){const o=this,n=e;let a=!1;function i(...e){a||(a=!0,o.off(t,i),n.apply(r,e))}return i._=e,this.on(t,i,r)}emit(t,...e){const r=this.e||(this.e={}),o=(Le(r,t)&&r[t]||[]).slice();for(const n of o)n.fn.apply(n.ctx,e);return this}off(t,e){const r=this.e||(this.e={}),o=Le(r,t)?r[t]:void 0,n=[];if(o&&e)for(let a=0,i=o.length;ae.call(this,this)),Ae.DEBUG){const t=t=>console.log(`[ART.${this.id}] -> ${t}`);t(`Version@${Ae.version}`);for(let e=0;et(`Event@${e.type}`))}(function(t){const e=Mt(t);return e.rollback=void 0,!e.scope.closed})(this)&&Pe.push(this)}catch(o){try{It(this,Pe,!0,Ae.REMOVE_SRC_WHEN_DESTROY,!0)}catch(n){console.warn("Failed to clean up ArtPlayer initialization:",n)}throw o}}static get instances(){return Pe}static get version(){return g}static get config(){return v}static get utils(){return mt}static get scheme(){return $t}static get Emitter(){return Se}static get validator(){return f}static get kindOf(){return f.kindOf}static get html(){return ze.html}static get option(){return{id:"",container:"#artplayer",url:"",poster:"",type:"",theme:"#f00",volume:.7,isLive:!1,muted:!1,autoplay:!1,autoSize:!1,autoMini:!1,loop:!1,flip:!1,playbackRate:!1,aspectRatio:!1,screenshot:!1,setting:!1,hotkey:!0,pip:!1,mutex:!0,backdrop:!0,fullscreen:!1,fullscreenWeb:!1,subtitleOffset:!1,miniProgressBar:!1,useSSR:!1,playsInline:!0,lock:!1,gesture:!0,fastForward:!1,autoPlayback:!1,autoOrientation:!1,airplay:!1,proxy:void 0,layers:[],contextmenu:[],controls:[],settings:[],quality:[],highlight:[],plugins:[],thumbnails:{url:"",number:60,column:10,width:0,height:0,scale:1},subtitle:{url:"",type:"",style:{},name:"",escape:!0,encoding:"utf-8",onVttLoad:t=>t},moreVideoAttr:{controls:!1,preload:b?"auto":"metadata"},i18n:{},icons:{},cssVar:{},customType:{},lang:null==navigator?void 0:navigator.language.toLowerCase()}}get proxy(){return this.events.proxy}get query(){return this.template.query}get video(){return this.template.$video}reset(){this.video.removeAttribute("src"),this.video.load()}destroy(t=!0){It(this,Pe,t,Ae.REMOVE_SRC_WHEN_DESTROY)}}return Ae.STYLE=Te,Ae.DEBUG=!1,Ae.CONTEXTMENU=!0,Ae.NOTICE_TIME=2e3,Ae.SETTING_WIDTH=250,Ae.SETTING_ITEM_WIDTH=200,Ae.SETTING_ITEM_HEIGHT=35,Ae.RESIZE_TIME=200,Ae.SCROLL_TIME=200,Ae.SCROLL_GAP=50,Ae.AUTO_PLAYBACK_MAX=10,Ae.AUTO_PLAYBACK_MIN=5,Ae.AUTO_PLAYBACK_TIMEOUT=3e3,Ae.RECONNECT_TIME_MAX=5,Ae.RECONNECT_SLEEP_TIME=1e3,Ae.CONTROL_HIDE_TIME=3e3,Ae.DBCLICK_TIME=300,Ae.DBCLICK_FULLSCREEN=!0,Ae.MOBILE_DBCLICK_PLAY=!0,Ae.MOBILE_CLICK_PLAY=!1,Ae.AUTO_ORIENTATION_TIME=200,Ae.INFO_LOOP_TIME=1e3,Ae.FAST_FORWARD_VALUE=3,Ae.FAST_FORWARD_TIME=1e3,Ae.TOUCH_MOVE_RATIO=.5,Ae.VOLUME_STEP=.1,Ae.SEEK_STEP=5,Ae.PLAYBACK_RATE=[.5,.75,1,1.25,1.5,2],Ae.ASPECT_RATIO=["default","4:3","16:9"],Ae.FLIP=["normal","horizontal","vertical"],Ae.FULLSCREEN_WEB_IN_BODY=!0,Ae.LOG_VERSION=!0,Ae.USE_RAF=!1,Ae.REMOVE_SRC_WHEN_DESTROY=!0,$&&(window.Artplayer=Ae,F("artplayer-style",Te),setTimeout(()=>{Ae.LOG_VERSION&&console.log(`%c ArtPlayer %c ${Ae.version} %c https://artplayer.org`,"color: #fff; background: #5f5f5f","color: #fff; background: #4bc729","")},100)),Ae}); diff --git a/docs/compiled/artplayer.mjs b/docs/compiled/artplayer.mjs index f5c1b90c0..099fdf3f9 100644 --- a/docs/compiled/artplayer.mjs +++ b/docs/compiled/artplayer.mjs @@ -1167,8 +1167,8 @@ function isClosing(owner) { return state2.destroying || state2.scope.closed; } function ownContainer(owner, container, rollback) { - const current = containers.get(container); - if (current && current !== owner) + const current2 = containers.get(container); + if (current2 && current2 !== owner) throw new Error("Cannot mount multiple instances on the same dom element"); const state2 = stateOf(owner); state2.rollback = rollback; @@ -3420,6 +3420,64 @@ function playingMix(art) { } }); } +const current = /* @__PURE__ */ new WeakMap(); +const assignments = /* @__PURE__ */ new WeakMap(); +function captureSource(owner) { + const operation = current.get(owner); + return () => current.get(owner) === operation && (!operation || operation.active()); +} +function beginSource(owner) { + const previous = current.get(owner); + const scope = getScope(owner).child(); + const operation = { + scope, + assigned: false, + acceptingEvents: false, + active: () => !isClosing(owner) && !scope.closed && current.get(owner) === operation + }; + current.set(owner, operation); + scope.add(() => { + if (current.get(owner) === operation) + current.delete(owner); + operation.onAssigned = void 0; + operation.onError = void 0; + }); + previous?.scope.dispose(); + return operation; +} +function takeAssignment(owner) { + const operation = assignments.get(owner); + assignments.delete(owner); + return operation || beginSource(owner); +} +function finishAssignment(operation) { + operation.assigned = true; + const callback = operation.onAssigned; + operation.onAssigned = void 0; + if (operation.active()) + callback?.(); +} +function assignUrl(owner, operation, url) { + assignments.set(owner, operation); + operation.acceptingEvents = true; + try { + owner.url = url; + } finally { + if (assignments.get(owner) === operation) { + assignments.delete(owner); + finishAssignment(operation); + } + } +} +function failSource(operation, error2) { + if (!operation.active()) + return; + if (operation.onError) + operation.onError(error2); + else + console.warn("Failed to initialize ArtPlayer source:", error2); + operation.scope.dispose(); +} function playMix(art) { const { i18n, @@ -3430,11 +3488,21 @@ function playMix(art) { } = art; def(art, "play", { async value() { + const active = captureSource(art); const result = await $video.play(); - notice.show = i18n.get("Play"); + if (!active()) + return result; + const message = i18n.get("Play"); + if (!active()) + return result; + notice.show = message; + if (!active()) + return result; art.emit("play"); if (option.mutex) { for (let index = 0; index < instances2.length; index++) { + if (!active()) + break; const instance = instances2[index]; if (instance !== art) { instance.pause(); @@ -3617,54 +3685,140 @@ function subtitleOffsetMix(art) { } }); } -function switchMix(art) { - function switchUrl(url, currentTime) { - return new Promise((resolve, reject) => { - if (url === art.url) { - resolve(); +function listenSource(scope, art, name, callback, once = true) { + let fired = false; + let release; + const guarded = (event) => { + if (scope.closed || fired) + return; + if (once) { + fired = true; + release(); + } + callback(event); + }; + art[once ? "once" : "on"](name, guarded); + release = scope.add(() => { + art.off(name, guarded); + }); + return guarded; +} +function switchSource(art, url, currentTime) { + return new Promise((resolve, reject) => { + if (isClosing(art) || url === art.url) { + resolve(); + return; + } + const operation = beginSource(art); + const scope = operation.scope.child(); + let settled = false; + const settle = (failed = false, error2) => { + if (settled) return; - } + settled = true; + operation.onError = void 0; + operation.onAssigned = void 0; + scope.dispose(); + if (failed) + reject(error2); + else + resolve(); + if (failed) + operation.scope.dispose(); + }; + scope.add(() => { + settle(); + }); + const active = () => !settled && operation.active(); + const fail = (error2) => settle(true, error2); + operation.onError = fail; + try { const { playing, aspectRatio: aspectRatio2, playbackRate: playbackRate2 } = art; art.pause(); - art.url = url; - art.notice.show = ""; - const handlers = {}; - handlers.error = (error2) => { - art.off("video:canplay", handlers.canplay); - art.off("video:loadedmetadata", handlers.metadata); - reject(error2); - }; - handlers.metadata = () => { - art.currentTime = currentTime; - }; - handlers.canplay = async () => { - art.off("video:error", handlers.error); - art.playbackRate = playbackRate2; - art.aspectRatio = aspectRatio2; - if (playing) { - await silencePromise(art.play()); + if (!active()) + return; + const readiness = scope.child(); + const handlers = { + "video:error": fail, + "video:loadedmetadata": () => { + if (!active()) + return; + try { + art.currentTime = currentTime; + } catch (error2) { + fail(error2); + } + }, + "video:canplay": () => { + if (!active()) + return; + readiness.dispose(); + const resume = async () => { + art.playbackRate = playbackRate2; + if (!active()) + return; + art.aspectRatio = aspectRatio2; + if (!active()) + return; + if (playing) { + try { + await art.play(); + } catch { + } + } + if (!active()) + return; + art.notice.show = ""; + settle(); + }; + void resume().catch(fail); } - art.notice.show = ""; - resolve(); }; - art.once("video:error", handlers.error); - art.once("video:loadedmetadata", handlers.metadata); - art.once("video:canplay", handlers.canplay); - }); - } - def(art, "switchQuality", { - value: (url) => { - return switchUrl(url, art.currentTime); + const capture = scope.child(); + const queued = []; + const names = Object.keys(handlers); + for (const name of names) { + listenSource(capture, art, name, (event) => { + if (operation.acceptingEvents) + queued.push([name, event]); + }, false); + } + assignUrl(art, operation, url); + if (!active()) + return; + art.notice.show = ""; + if (!active()) + return; + const activate = () => { + capture.dispose(); + if (!url) { + settle(); + return; + } + const dispatch = {}; + for (const name of names) + dispatch[name] = listenSource(readiness, art, name, handlers[name]); + for (const [name, event] of queued) { + if (!active() || readiness.closed) + break; + dispatch[name](event); + } + queued.length = 0; + }; + if (operation.assigned) + activate(); + else + operation.onAssigned = activate; + } catch (error2) { + fail(error2); } }); - def(art, "switchUrl", { - value: (url) => { - return switchUrl(url, 0); - } - }); - def(art, "switch", { - set: art.switchUrl - }); +} +function switchMix(art) { + const switchUrl = (url) => switchSource(art, url, 0); + def(art, "switchQuality", { value: (url) => switchSource(art, url, art.currentTime) }); + def(art, "switchUrl", { value: switchUrl }); + def(art, "switch", { set: switchUrl }); } function themeMix(art) { def(art, "theme", { @@ -3767,40 +3921,75 @@ function typeMix(art) { }); } function urlMix(art) { - const { - option, - template: { $video } - } = art; + const { option, template: { $video } } = art; def(art, "url", { get() { return $video.src; }, async set(newUrl) { - if (newUrl) { + if (isClosing(art)) + return; + const operation = takeAssignment(art); + operation.acceptingEvents = false; + try { + if (!newUrl) { + if (await wait(operation.scope) && operation.active()) + art.loading.show = true; + return; + } const oldUrl = art.url; const typeName = option.type || getExt(newUrl); const typeCallback = option.customType[typeName]; if (typeName && typeCallback) { - if (!await wait(getScope(art)) || getScope(art).closed) + if (!await wait(operation.scope) || !operation.active()) return; art.loading.show = true; - typeCallback.call(art, $video, newUrl, art); - } else { - URL.revokeObjectURL(oldUrl); - $video.src = newUrl; } + if (!operation.active()) + return; + const capture = operation.scope.child(); + let ready = false; + let failed = false; + listenSource(capture, art, "video:canplay", () => { + ready = !failed; + }); + listenSource(capture, art, "video:error", () => { + failed = true; + }); + try { + operation.acceptingEvents = true; + if (typeName && typeCallback) { + const result = typeCallback.call(art, $video, newUrl, art); + void Promise.resolve(result).catch((error2) => failSource(operation, error2)); + } else { + if (oldUrl) + URL.revokeObjectURL(oldUrl); + if (!operation.active()) + return; + $video.src = newUrl; + } + } finally { + capture.dispose(); + } + if (!operation.active()) + return; if (oldUrl !== art.url) { art.option.url = newUrl; - if (art.isReady && oldUrl) { - art.once("video:canplay", () => { - art.emit("restart", newUrl); - }); + if (operation.active() && art.isReady && oldUrl) { + const restart = () => { + if (operation.active()) + art.emit("restart", newUrl); + }; + if (ready) + restart(); + else if (!failed) + listenSource(operation.scope, art, "video:canplay", restart); } } - } else { - if (!await wait(getScope(art)) || getScope(art).closed) - return; - art.loading.show = true; + } catch (error2) { + failSource(operation, error2); + } finally { + finishAssignment(operation); } } }); diff --git a/package.json b/package.json index e18d275d5..756458814 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "ci:build": "yarn build all && yarn build:i18n && yarn build:ts && yarn build:docs && yarn test:imports", "test:imports": "node --test test/esm.test.js test/i18n.test.js test/ssr.test.js", "typecheck": "node scripts/typecheck.mjs", - "test:unit": "node --test test/playback.test.js test/dash-control.test.js test/public-behavior.test.js test/helpers.test.js test/chapter.test.js test/utils.test.js test/resource-scope.test.js test/instance-lifecycle.test.js test/options.test.js test/media-hosts.test.js test/plugins.test.js", + "test:unit": "node --test test/playback.test.js test/dash-control.test.js test/public-behavior.test.js test/helpers.test.js test/chapter.test.js test/utils.test.js test/resource-scope.test.js test/instance-lifecycle.test.js test/options.test.js test/media-hosts.test.js test/plugins.test.js test/source.test.js", "test": "yarn test:node && yarn test:baseline", "test:browser": "playwright test", "test:browser:install": "playwright install chromium firefox webkit", diff --git a/packages/artplayer/ARCHITECTURE.md b/packages/artplayer/ARCHITECTURE.md index 24d47ca3d..7209a9d25 100644 --- a/packages/artplayer/ARCHITECTURE.md +++ b/packages/artplayer/ARCHITECTURE.md @@ -318,6 +318,34 @@ finding, not a claim that a standalone debounce can know when its owner is destr ## Verification and maintenance +### Source operations (CORE-09) + +`player/urlMix.ts` and `player/switchMix.ts` preserve the public descriptors. +`source/types.ts` defines minimal structural media/host capabilities; +`source/operation.ts` owns a current generation and its resource scope; +`source/listen.ts` owns individual media subscriptions; `source/switch.ts` +coordinates assignment, readiness, state restoration and Promise settlement. + +A new URL assignment supersedes the prior operation, including direct `art.url` +writes. Superseded/destroyed switches fulfill with undefined; actual source errors +reject with their original value. Fulfillment does not prove the source became +active. Same-string URL calls remain no-ops. Internal resume rejection stays +handled while public play retains rejection. Synchronous proxy events are buffered +until assignment finishes, and operation cleanup does not remove user listeners. + +customType still receives the real media object and player. Its arbitrary external +SDK work cannot be cancelled generically: adapters must own that cleanup. The core +guards deferred invocation, ignores obsolete returned failures, and cancels its own +continuations. Direct assignment failures are reported with console.warn; switch +callers receive the original rejection. `playMix.ts` captures the current source: +its native result/rejection is preserved, while obsolete notice/event/mutex effects +are suppressed. Object URL ownership, other playback migration and reconnect +generations remain CORE-19/10/11 work. + +`test/source.test.js` checks cancellation, reentry, synchronous events and cleanup; +`test/browser/source.spec.js` compares published/candidate real-media switching and +destruction and verifies candidate customType and resume-failure behavior. + Run `yarn test:unit` for shared published/workspace utility contracts and controlled timers. `test/utils.test.js` also accepts `ARTPLAYER_TEST_CORE` to test an actual UMD, legacy or ESM file. `test/types/utils-source.ts` checks source inference, receiver diff --git a/packages/artplayer/dist/artplayer.js b/packages/artplayer/dist/artplayer.js index eae162ffd..844e216bd 100644 --- a/packages/artplayer/dist/artplayer.js +++ b/packages/artplayer/dist/artplayer.js @@ -4,4 +4,4 @@ * (c) 2017-2026 Harvey Zhao * Released under the MIT License. */ -!function(t,e){"object"===typeof exports&&"undefined"!==typeof module?module.exports=e():"function"==typeof define&&define.amd?(t.Artplayer=e(),define(function(){return t.Artplayer})):(t="undefined"!==typeof globalThis?globalThis:t||self).Artplayer=e()}(this,function(){"use strict";function t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var e,r={exports:{}};var o=(e||(e=1,r.exports=function(){function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}var e=Object.prototype.toString,r=function(r){if(void 0===r)return"undefined";if(null===r)return"null";var a=t(r);if("boolean"===a)return"boolean";if("string"===a)return"string";if("number"===a)return"number";if("symbol"===a)return"symbol";if("function"===a)return"GeneratorFunction"===o(r)?"generatorfunction":"function";if(function(t){return Array.isArray?Array.isArray(t):t instanceof Array}(r))return"array";if(function(t){return!(!t.constructor||"function"!=typeof t.constructor.isBuffer)&&t.constructor.isBuffer(t)}(r))return"buffer";if(function(t){try{if("number"==typeof t.length&&"function"==typeof t.callee)return!0}catch(e){if(-1!==e.message.indexOf("callee"))return!0}return!1}(r))return"arguments";if(function(t){return t instanceof Date||"function"==typeof t.toDateString&&"function"==typeof t.getDate&&"function"==typeof t.setDate}(r))return"date";if(function(t){return t instanceof Error||"string"==typeof t.message&&t.constructor&&"number"==typeof t.constructor.stackTraceLimit}(r))return"error";if(function(t){return t instanceof RegExp||"string"==typeof t.flags&&"boolean"==typeof t.ignoreCase&&"boolean"==typeof t.multiline&&"boolean"==typeof t.global}(r))return"regexp";switch(o(r)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(function(t){return"function"==typeof t.throw&&"function"==typeof t.return&&"function"==typeof t.next}(r))return"generator";switch(a=e.call(r)){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return a.slice(8,-1).toLowerCase().replace(/\s/g,"")};function o(t){return t.constructor?t.constructor.name:null}function a(t,e){var o=2=1,p=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(s)||d,h="undefined"!==typeof window&&"undefined"!==typeof document;function u(t,e=document){return e.querySelector(t)}function m(t,e=document){return Array.from(e.querySelectorAll(t))}function f(t,e){return t.classList.add(e)}function g(t,e){return t.classList.remove(e)}function v(t,e){return t.classList.contains(e)}function y(t,e){return e instanceof Element?t.appendChild(e):t.insertAdjacentHTML("beforeend",String(e)),t.lastElementChild||t.lastChild}function b(t){return t.parentNode.removeChild(t)}function w(t,e,r){return t.style[e]=r,t}function x(t,e){for(const r in e)w(t,r,e[r]);return t}function k(t){return Array.from(t.parentElement.children).filter(e=>e!==t)}function $(t,e){k(t).forEach(t=>g(t,e)),f(t,e)}function E(t,e,r="top"){p||(t.setAttribute("aria-label",e),f(t,"hint--rounded"),f(t,`hint--${r}`))}function T(t,e=0){const r=t.getBoundingClientRect(),o=window.innerHeight||document.documentElement.clientHeight,a=window.innerWidth||document.documentElement.clientWidth,n=r.top-e<=o&&r.top+r.height+e>=0,i=r.left-e<=a+e&&r.left+r.width+e>=0;return n&&i}function C(t,e){return R(t).includes(e)}function z(t,e){return e.parentNode.replaceChild(t,e),t}function L(t){return document.createElement(t)}function S(t="",e=""){const r=L("i");return f(r,"art-icon"),f(r,`art-icon-${t}`),y(r,e),r}function M(t,e){let r=document.getElementById(t);r||(r=document.createElement("style"),r.id=t,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{document.head.appendChild(r)}):(document.head||document.documentElement).appendChild(r)),r.textContent=e}function A(){const t=document.createElement("div");return t.style.display="flex","flex"===t.style.display}function P(t){return t.getBoundingClientRect()}function I(t,e){return new Promise((r,o)=>{const a=new Image;a.onload=function(){if(e&&1!==e){const n=document.createElement("canvas"),i=n.getContext("2d");n.width=a.width*e,n.height=a.height*e,i.drawImage(a,0,0,n.width,n.height),n.toBlob(e=>{const a=URL.createObjectURL(e),n=new Image;n.onload=function(){r(n)},n.onerror=function(){URL.revokeObjectURL(a),o(new Error(`Image load failed: ${t}`))},n.src=a})}else r(a)},a.onerror=function(){o(new Error(`Image load failed: ${t}`))},a.src=t})}function R(t){if(t.composedPath)return t.composedPath();const e=[];let r=t.target;for(;r;)e.push(r),r=r.parentNode;return e.includes(window)||void 0===window||e.push(window),e}function O(){const t=document.createElement("div");t.style.cssText="position:fixed;top:env(safe-area-inset-top,0px);right:env(safe-area-inset-right,0px);bottom:env(safe-area-inset-bottom,0px);left:env(safe-area-inset-left,0px);pointer-events:none;visibility:hidden;",document.body.appendChild(t);const e=getComputedStyle(t),r={top:Number.parseFloat(e.top)||0,right:Number.parseFloat(e.right)||0,bottom:Number.parseFloat(e.bottom)||0,left:Number.parseFloat(e.left)||0};return t.remove(),r}class _ extends Error{constructor(t,e){super(t),"captureStackTrace"in Error&&"function"===typeof Error.captureStackTrace&&Error.captureStackTrace(this,e||this.constructor),this.name="ArtPlayerError"}}function V(t,e){if(!t)throw new _(e);return t}function Y(t){const e=t;return e&&"function"===typeof e.catch?e.catch(()=>{}):t}function N(t){const e=t.search(/[?#]/),r=(e<0?t:t.slice(0,e)).trim().toLowerCase();return r.slice(r.lastIndexOf(".")+1)}function D(t,e){const r=document.createElement("a");r.style.display="none",r.href=t,r.download=e,document.body.appendChild(r);try{r.click()}finally{r.remove()}}function F(t,e,r){return Math.max(Math.min(t,Math.max(e,r)),Math.min(e,r))}function H(t){return t.charAt(0).toUpperCase()+t.slice(1)}function B(t){if(!t)return"00:00";const e=Math.floor(t/3600),r=Math.floor((t-3600*e)/60),o=Math.floor(t-3600*e-60*r);return(e>0?[e,r,o]:[r,o]).map(t=>t<10?`0${t}`:String(t)).join(":")}const W={"&":"&","<":"<",">":">","'":"'",'"':"""},j={"&":"&","<":"<",">":">","'":"'",""":'"'},U=/(&|<|>|'|")/g;function q(t){return t.replace(/[&<>'"]/g,t=>W[t]||t)}const X=Object.defineProperty,{hasOwnProperty:G}=Object.prototype;function K(t,e){return G.call(t,e)}function Z(t,e){return Object.getOwnPropertyDescriptor(t,e)}function J(...t){const e=t=>!!t&&"object"===typeof t&&!Array.isArray(t);return t.reduce((t,r)=>(Object.keys(r).forEach(o=>{const a=t[o],n=r[o];let i;i=Array.isArray(a)&&Array.isArray(n)?a.concat(...n):e(a)&&e(n)?J(a,n):n,X(t,o,{value:i,enumerable:!0,configurable:!0,writable:!0})}),t),{})}function Q(t){return"WEBVTT \r\n\r\n".concat((e=t,e.replace(/(\d\d:\d\d:\d\d)[,.](\d+)/g,(t,e,r)=>{let o=r.slice(0,3);return 1===r.length&&(o=`${r}00`),2===r.length&&(o=`${r}0`),`${e},${o}`})).replace(/\{\\([ibu])\}/g,"").replace(/\{\\([ibu])1\}/g,"<$1>").replace(/\{([ibu])\}/g,"<$1>").replace(/\{\/([ibu])\}/g,"").replace(/(\d\d:\d\d:\d\d),(\d\d\d)/g,"$1.$2").replace(/\{[\s\S]*?\}/g,"").concat("\r\n\r\n"));var e}function tt(t){return URL.createObjectURL(new Blob([t],{type:"text/vtt"}))}function et(t){const e=new RegExp("Dialogue:\\s\\d,(\\d+:\\d\\d:\\d\\d.\\d\\d),(\\d+:\\d\\d:\\d\\d.\\d\\d),([^,]*),([^,]*),(?:[^,]*,){4}([\\s\\S]*)$","i");function r(t=""){return t.split(/[:.]/).map((t,e,r)=>{if(e===r.length-1){if(1===t.length)return`.${t}00`;if(2===t.length)return`.${t}0`}else if(1===t.length)return(0===e?"0":":0")+t;return 0===e?t:e===r.length-1?`.${t}`:`:${t}`}).join("")}return`WEBVTT\n\n${t.split(/\r?\n/).map(t=>{const o=t.match(e);if(!o)return null;const[,a="",n="",,,i=""]=o;return{start:r(a.trim()),end:r(n.trim()),text:i.replace(/\{[\s\S]*?\}/g,"").replace(/(\\N)/g,"\n").trim().split(/\r?\n/).map(t=>t.trim()).join("\n")}}).filter(t=>t).map((t,e)=>t?`${e+1}\n${t.start} --\x3e ${t.end}\n${t.text}`:"").filter(t=>t.trim()).join("\n\n")}`}function rt(t,e){let r=!1;return function(...o){r||(t.apply(this,o),r=!0,setTimeout(()=>{r=!1},e))}}const ot=Object.freeze(Object.defineProperty({__proto__:null,ArtPlayerError:_,addClass:f,append:y,assToVtt:et,capitalize:H,clamp:F,createElement:L,debounce:function(t,e){let r;return function(...o){clearTimeout(r),r=setTimeout(()=>(r=void 0,t.apply(this,o)),e)}},def:X,download:D,errorHandle:V,escape:q,get:Z,getComposedPath:R,getExt:N,getIcon:S,getRect:P,getSafeAreaInsets:O,getStyle:function(t,e,r=!0){const o=window.getComputedStyle(t,null).getPropertyValue(e);return r?Number.parseFloat(o):o},has:K,hasClass:v,includeFromEvent:C,inverseClass:$,isBrowser:h,isIOS:c,isIOS13:d,isInViewport:T,isMobile:p,isSafari:l,loadImg:I,mergeDeep:J,query:u,queryAll:m,remove:b,removeClass:g,replaceElement:z,secondToTime:B,setStyle:w,setStyleText:M,setStyles:x,siblings:k,silencePromise:Y,sleep:function(t=0){return new Promise(e=>setTimeout(e,t))},srtToVtt:Q,supportsFlex:A,throttle:rt,tooltip:E,unescape:function(t){return t.replace(U,t=>j[t]||t)},userAgent:s,vttToBlob:tt},Symbol.toStringTag,{value:"Module"})),at="array",nt="boolean",it="string",st="number",lt="object",ct="function";function dt(t,e,r){return V(e===it||e===st||t instanceof Element,`${r.join(".")} require '${it}' or 'Element' type`)}const pt={html:dt,disable:`?${nt}`,name:`?${it}`,index:`?${st}`,style:`?${lt}`,click:`?${ct}`,mounted:`?${ct}`,tooltip:`?${it}|${st}`,width:`?${st}`,selector:`?${at}`,onSelect:`?${ct}`,switch:`?${nt}`,onSwitch:`?${ct}`,range:`?${at}`,onRange:`?${ct}`,onChange:`?${ct}`},ht={id:it,container:dt,url:it,poster:it,type:it,theme:it,lang:it,volume:st,isLive:nt,muted:nt,autoplay:nt,autoSize:nt,autoMini:nt,loop:nt,flip:nt,playbackRate:nt,aspectRatio:nt,screenshot:nt,setting:nt,hotkey:nt,pip:nt,mutex:nt,backdrop:nt,fullscreen:nt,fullscreenWeb:nt,subtitleOffset:nt,miniProgressBar:nt,useSSR:nt,playsInline:nt,lock:nt,gesture:nt,fastForward:nt,autoPlayback:nt,autoOrientation:nt,airplay:nt,proxy:`?${ct}`,plugins:[ct],layers:[pt],contextmenu:[pt],settings:[pt],controls:[{...pt,position:(t,e,r)=>{const o=["top","left","right"];return V("string"===typeof t&&o.includes(t),`${r.join(".")} only accept ${o.toString()} as parameters`)}}],quality:[{default:`?${nt}`,html:it,url:it}],highlight:[{time:st,text:it}],thumbnails:{url:it,number:st,column:st,width:st,height:st,scale:st},subtitle:{url:it,name:it,type:it,style:lt,escape:nt,encoding:it,onVttLoad:ct},moreVideoAttr:lt,i18n:lt,icons:lt,cssVar:lt,customType:lt};class ut{constructor(t){this.id=0,this.art=t,this.cache=new Map,this.add=this.add.bind(this),this.remove=this.remove.bind(this),this.update=this.update.bind(this)}get show(){return v(this.art.template.$player,`art-${this.name}-show`)}set show(t){const{$player:e}=this.art.template,r=`art-${this.name}-show`;t?f(e,r):g(e,r),this.art.emit(this.name,t)}toggle(){this.show=!this.show}add(t){const e="function"===typeof t?t(this.art):t;if(e.html=e.html||"",a(e,pt),!this.$parent||!this.name||e.disable)return;const r=e.name||`${this.name}${this.id}`;V(!this.cache.has(r),`Can't add an existing [${r}] to the [${this.name}]`),this.id+=1;const o=L("div");f(o,`art-${this.name}`),f(o,`art-${this.name}-${r}`);const n=Array.from(this.$parent.children);o.dataset.index=e.index||this.id;const i=n.find(t=>Number(t.dataset.index)>=Number(o.dataset.index));i?i.insertAdjacentElement("beforebegin",o):y(this.$parent,o),e.html&&y(o,e.html),e.style&&x(o,e.style),e.tooltip&&E(o,e.tooltip);const s=[];if(e.click){const t=this.art.events.proxy(o,"click",t=>{t.preventDefault(),e.click.call(this.art,this,t)});s.push(t)}return e.selector&&["left","right"].includes(e.position)&&this.selector(e,o,s),this[r]=o,this.cache.set(r,{$ref:o,events:s,option:e}),e.mounted&&e.mounted.call(this.art,o),o}remove(t){V(this.cache.has(t),`Can't find [${t}] from the [${this.name}]`);const e=this.cache.get(t);e.option.beforeUnmount&&e.option.beforeUnmount.call(this.art,e.$ref);for(const r of e.events)this.art.events.remove(r);this.cache.delete(t),delete this[t],b(e.$ref)}update(t){if(this.cache.has(t.name)){const e=this.cache.get(t.name);t=Object.assign(e.option,t),this.remove(t.name)}return this.add(t)}}class mt extends ut{constructor(t){super(t),this.name="contextmenu",this.$parent=t.template.$contextmenu,p||this.init()}init(){const{option:t,proxy:e,template:{$player:r,$contextmenu:o}}=this.art;t.playbackRate&&this.add(function(t){return e=>{const{i18n:r,constructor:{PLAYBACK_RATE:o}}=e,a=o.map(t=>`${1===t?r.get("Normal"):t.toFixed(1)}`).join("");return{...t,html:`${r.get("Play Speed")}: ${a}`,click:(t,r)=>{const{value:o}=r.target.dataset;o&&(e.playbackRate=Number(o),t.show=!1)},mounted:t=>{const r=u('[data-value="1"]',t);r&&$(r,"art-current"),e.on("video:ratechange",()=>{const r=m("span",t).find(t=>Number(t.dataset.value)===e.playbackRate);r&&$(r,"art-current")})}}}}({name:"playbackRate",index:10})),t.aspectRatio&&this.add(function(t){return e=>{const{i18n:r,constructor:{ASPECT_RATIO:o}}=e,a=o.map(t=>`${"default"===t?r.get("Default"):t}`).join("");return{...t,html:`${r.get("Aspect Ratio")}: ${a}`,click:(t,r)=>{const{value:o}=r.target.dataset;o&&(e.aspectRatio=o,t.show=!1)},mounted:t=>{const r=u('[data-value="default"]',t);r&&$(r,"art-current"),e.on("aspectRatio",e=>{const r=m("span",t).find(t=>t.dataset.value===e);r&&$(r,"art-current")})}}}}({name:"aspectRatio",index:20})),t.flip&&this.add(function(t){return e=>{const{i18n:r,constructor:{FLIP:o}}=e,a=o.map(t=>`${r.get(H(t))}`).join("");return{...t,html:`${r.get("Video Flip")}: ${a}`,click:(t,r)=>{const{value:o}=r.target.dataset;o&&(e.flip=o.toLowerCase(),t.show=!1)},mounted:t=>{const r=u('[data-value="normal"]',t);r&&$(r,"art-current"),e.on("flip",e=>{const r=m("span",t).find(t=>t.dataset.value===e);r&&$(r,"art-current")})}}}}({name:"flip",index:30})),this.add(function(t){return e=>({...t,html:e.i18n.get("Video Info"),click:t=>{e.info.show=!0,t.show=!1}})}({name:"info",index:40})),this.add(function(t){return{...t,html:`ArtPlayer ${n}`}}({name:"version",index:50})),this.add(function(t){return e=>({...t,html:e.i18n.get("Close"),click:t=>{t.show=!1}})}({name:"close",index:60}));for(let a=0;a{if(!this.art.constructor.CONTEXTMENU)return;t.preventDefault(),this.show=!0;const e=t.clientX,a=t.clientY,{height:n,width:i,left:s,top:l}=P(r),{height:c,width:d}=P(o);let p=e-s,h=a-l;e+d>s+i&&(p=i-d),a+c>l+n&&(h=n-c),x(o,{top:`${h}px`,left:`${p}px`})}),e(r,"click",t=>{C(t,o)||(this.show=!1)}),this.art.on("blur",()=>{this.show=!1})}}class ft extends Error{constructor(t){super("Failed to release ArtPlayer resources"),this.errors=t,this.name="ResourceCleanupError"}}class gt{constructor(){this.cleanups=new Set,this.disposed=!1}get closed(){return this.disposed}add(t){let e=!0;const r=()=>{e&&(e=!1,this.cleanups.delete(r),t())};return this.closed?r():this.cleanups.add(r),r}child(){const t=new gt,e=this.add(()=>{t.dispose()});return t.add(()=>{e()}),t}dispose(){if(this.closed)return;this.disposed=!0;const t=[];for(const r of Array.from(this.cleanups).reverse())try{r()}catch(e){e instanceof ft?t.push(...e.errors):t.push(e)}if(t.length)throw new ft(t)}}const vt=new WeakMap,yt=new WeakMap;function bt(t){const e=vt.get(t);if(!e)throw new Error("ArtPlayer lifecycle has not been initialized");return e}function wt(t){return bt(t).scope}function xt(t){const e=bt(t);return e.destroying||e.scope.closed}function kt(t,e,r,o,a=!1){const n=bt(t);if(n.destroying||n.scope.closed)return;n.destroying=!0;const i=[],s=t=>{try{t()}catch(e){i.push(...e instanceof ft?e.errors:[e])}};o&&t.template?.$video&&s(()=>t.reset()),s(()=>n.scope.dispose()),s(()=>t.template?.destroy(r));const l=e.indexOf(t);-1!==l&&e.splice(l,1),t.isDestroy=!0,a||(n.releaseContainer?.(),n.releaseContainer=void 0),s(()=>t.emit("destroy")),a&&n.rollback&&s(n.rollback),n.rollback=void 0,n.releaseContainer?.(),n.releaseContainer=void 0;for(const c of i.slice(1))console.warn("Additional ArtPlayer cleanup failure:",c);if(i.length)throw i[0]}function $t(t,e,r){if(t.closed)return()=>{};let o=!0,a=()=>{};const n=setTimeout(()=>{o&&(a(),t.closed||e())},r);return a=t.add(()=>{o=!1,clearTimeout(n)}),a}function Et(t,e=0){return t.closed?Promise.resolve(!1):new Promise(r=>{let o=!1,a=()=>{};const n=setTimeout(()=>{o=!0,a(),r(!0)},e);a=t.add(()=>{clearTimeout(n),o||r(!1)})})}function Tt(t,e){const{$progress:r}=t.template,{left:o}=P(r),a=F((p?e.touches[0].clientX:e.clientX)-o,0,r.clientWidth),n=a/r.clientWidth*t.duration;return{second:n,time:B(n),width:a,percentage:F(a/r.clientWidth,0,1)}}function Ct(t,e){if(t.isRotate){const r=(e.touches[0].clientY-t.top)/t.height,o=r*t.duration;t.emit("setBar","played",r,e),t.seek=o}else{const{second:r,percentage:o}=Tt(t,e);t.emit("setBar","played",o,e),t.seek=r}}function zt(t){return e=>{const{icons:r,option:o,proxy:a}=e,{$player:n,$progress:i}=e.template;return{...t,html:'\n
\n
\n
\n
\n
\n
\n
00:00
\n
\n ',mounted:t=>{let s=null,l=!1;const c=u(".art-progress-hover",t),d=u(".art-progress-loaded",t),h=u(".art-progress-played",t),m=u(".art-progress-highlight",t),v=u(".art-progress-indicator",t),b=u(".art-progress-tip",t);function x(r,o){const{width:a,time:n}=o||Tt(e,r);b.textContent=n||"00:00";const i=b.clientWidth;a<=i/2?w(b,"left",0):a>t.clientWidth-i/2?w(b,"left",t.clientWidth-i+"px"):w(b,"left",a-i/2+"px")}r.indicator?y(v,r.indicator):w(v,"backgroundColor","var(--art-theme)"),e.on("setBar",function(r,o,a){const i="played"===r&&a&&p;if("loaded"===r&&w(d,"width",100*o+"%"),"hover"===r&&(w(c,"width",100*o+"%"),C(a,m)?function(r){const{width:o}=Tt(e,r),{text:a}=r.target.dataset;b.textContent=a;const n=b.clientWidth;o<=n/2?w(b,"left",0):o>t.clientWidth-n/2?w(b,"left",t.clientWidth-n+"px"):w(b,"left",o-n/2+"px")}(a):x(a),0===o?g(n,"art-progress-hover"):f(n,"art-progress-hover")),"played"===r&&(w(h,"width",100*o+"%"),w(v,"left",100*o+"%")),i){f(n,"art-progress-hover");x(a,{width:t.clientWidth*o,time:B(o*e.duration)}),clearTimeout(s),s=setTimeout(()=>{g(n,"art-progress-hover")},500)}}),e.on("video:loadedmetadata",function(){m.textContent="";for(let t=0;t`;y(m,n)}}),e.constructor.USE_RAF?e.on("raf",()=>{e.emit("setBar","played",e.played),e.emit("setBar","loaded",e.loaded)}):(e.on("video:timeupdate",()=>{e.emit("setBar","played",e.played)}),e.on("video:progress",()=>{e.emit("setBar","loaded",e.loaded)}),e.on("video:ended",()=>{e.emit("setBar","played",1)})),e.emit("setBar","loaded",e.loaded||0),p||(a(i,"click",t=>{t.target!==v&&Ct(e,t)}),a(i,"mousemove",t=>{const{percentage:r}=Tt(e,t);e.emit("setBar","hover",r,t)}),a(i,"mouseleave",t=>{e.emit("setBar","hover",0,t)}),a(i,"mousedown",t=>{l=0===t.button}),e.on("document:mousemove",t=>{if(l){const{second:r,percentage:o}=Tt(e,t);e.emit("setBar","played",o,t),e.seek=r}}),e.on("document:mouseup",()=>{l&&(l=!1)}))}}}}class Lt extends ut{constructor(t){super(t),this.isHover=!1,this.name="control",this.timer=Date.now();const{constructor:e}=t,{$player:r,$bottom:o}=this.art.template;t.on("mousemove",()=>{p||(this.show=!0)}),t.on("click",()=>{p?this.toggle():this.show=!0}),t.on("document:mousemove",t=>{this.isHover=C(t,o)}),t.on("video:timeupdate",()=>{!t.setting.show&&!this.isHover&&!t.isInput&&t.playing&&this.show&&Date.now()-this.timer>=e.CONTROL_HIDE_TIME&&(this.show=!1)}),t.on("control",t=>{t?(g(r,"art-hide-cursor"),f(r,"art-hover"),this.timer=Date.now()):(f(r,"art-hide-cursor"),g(r,"art-hover"))}),this.init()}init(){const{option:t}=this.art;t.isLive||this.add(zt({name:"progress",position:"top",index:10})),this.add({name:"thumbnails",position:"top",index:20}),this.add(function(t){return e=>({...t,mounted:t=>{const{proxy:r,icons:o,i18n:a}=e,n=y(t,o.play),i=y(t,o.pause);function s(){w(n,"display","flex"),w(i,"display","none")}function l(){w(n,"display","none"),w(i,"display","flex")}E(n,a.get("Play")),E(i,a.get("Pause")),r(n,"click",()=>{Y(e.play())}),r(i,"click",()=>{e.pause()}),e.playing?l():s(),e.on("video:playing",()=>{l()}),e.on("video:pause",()=>{s()})}})}({name:"playAndPause",position:"left",index:10})),this.add(function(t){return e=>({...t,mounted:t=>{const{proxy:r,icons:o}=e,a=y(t,o.volume),n=y(t,o.volumeClose),i=y(t,'
'),s=y(i,'
'),l=y(s,'
'),c=y(s,'
'),d=y(c,'
'),h=y(d,'
'),u=y(c,'
');function m(t){const{top:e,height:r}=P(c);return 1-(t.clientY-e)/r}function f(){if(e.muted||0===e.volume)w(a,"display","none"),w(n,"display","flex"),w(u,"top","100%"),w(h,"top","100%"),l.textContent=0;else{const t=100*e.volume;w(a,"display","flex"),w(n,"display","none"),w(u,"top",100-t+"%"),w(h,"top",100-t+"%"),l.textContent=Math.floor(t)}}if(f(),e.on("video:volumechange",f),r(a,"click",()=>{e.muted=!0}),r(n,"click",()=>{e.muted=!1}),p)w(i,"display","none");else{let t=!1;r(c,"mousedown",r=>{t=0===r.button,e.volume=m(r)}),e.on("document:mousemove",r=>{t&&(e.muted=!1,e.volume=m(r))}),e.on("document:mouseup",()=>{t&&(t=!1)})}}})}({name:"volume",position:"left",index:20})),t.isLive||this.add(function(t){return e=>({...t,style:p?{fontSize:"12px",padding:"0 5px"}:{cursor:"auto",padding:"0 10px"},mounted:t=>{function r(){const r=`${B(e.currentTime)} / ${B(e.duration)}`;r!==t.textContent&&(t.textContent=r)}r();const o=["video:loadedmetadata","video:timeupdate","video:progress"];for(let a=0;a{e&&!wt(this.art).closed&&(this.art.quality=t.quality)}),t.screenshot&&!p&&this.add(function(t){return e=>({...t,tooltip:e.i18n.get("Screenshot"),mounted:t=>{const{proxy:r,icons:o}=e;y(t,o.screenshot),r(t,"click",()=>{e.screenshot()})}})}({name:"screenshot",position:"right",index:20})),t.setting&&this.add(function(t){return e=>({...t,tooltip:e.i18n.get("Show Setting"),mounted:t=>{const{proxy:r,icons:o,i18n:a}=e;y(t,o.setting),r(t,"click",()=>{e.setting.toggle(),e.setting.resize()}),e.on("setting",e=>{E(t,a.get(e?"Hide Setting":"Show Setting"))})}})}({name:"setting",position:"right",index:30})),t.pip&&this.add(function(t){return e=>({...t,tooltip:e.i18n.get("PIP Mode"),mounted:t=>{const{proxy:r,icons:o,i18n:a}=e;y(t,o.pip),r(t,"click",()=>{e.pip=!e.pip}),e.on("pip",e=>{E(t,a.get(e?"Exit PIP Mode":"PIP Mode"))})}})}({name:"pip",position:"right",index:40})),t.airplay&&window.WebKitPlaybackTargetAvailabilityEvent&&this.add(function(t){return e=>({...t,tooltip:e.i18n.get("AirPlay"),mounted:t=>{const{proxy:r,icons:o}=e;y(t,o.airplay),r(t,"click",()=>e.airplay())}})}({name:"airplay",position:"right",index:50})),t.fullscreenWeb&&this.add(function(t){return e=>({...t,tooltip:e.i18n.get("Web Fullscreen"),mounted:t=>{const{proxy:r,icons:o,i18n:a}=e,n=y(t,o.fullscreenWebOn),i=y(t,o.fullscreenWebOff);w(i,"display","none"),r(t,"click",()=>{e.fullscreenWeb=!e.fullscreenWeb}),e.on("fullscreenWeb",e=>{e?(E(t,a.get("Exit Web Fullscreen")),w(n,"display","none"),w(i,"display","inline-flex")):(E(t,a.get("Web Fullscreen")),w(n,"display","inline-flex"),w(i,"display","none"))})}})}({name:"fullscreenWeb",position:"right",index:60})),t.fullscreen&&this.add(function(t){return e=>({...t,tooltip:e.i18n.get("Fullscreen"),mounted:t=>{const{proxy:r,icons:o,i18n:a}=e,n=y(t,o.fullscreenOn),i=y(t,o.fullscreenOff);w(i,"display","none"),r(t,"click",()=>{e.fullscreen=!e.fullscreen}),e.on("fullscreen",e=>{e?(E(t,a.get("Exit Fullscreen")),w(n,"display","none"),w(i,"display","inline-flex")):(E(t,a.get("Fullscreen")),w(n,"display","inline-flex"),w(i,"display","none"))})}})}({name:"fullscreen",position:"right",index:70}));for(let e=0;et.selector}),X(e,"$control_item",{get:()=>r}),X(e,"$control_value",{get:()=>a})}const i=o(n,"click",async e=>{const r=R(e),o=t.selector.find(t=>t.$control_item===r.find(e=>t.$control_item===e));this.check(o),t.onSelect&&(a.innerHTML=await t.onSelect.call(this.art,o,o.$control_item,e))});r.push(i)}}function St(t,e,r,o){const a=e-o,n=r-t;let i=0;if(Math.abs(n)<2&&Math.abs(a)<2)return i;const s=function(t,e){return 180*Math.atan2(e,t)/Math.PI}(n,a);return s>=-45&&s<45?i=4:s>=45&&s<135?i=1:s>=-135&&s<-45?i=2:(s>=135&&s<=180||s>=-180&&s<-135)&&(i=3),i}function Mt(t){if(t.constructor.USE_RAF){const e=wt(t);let r=()=>{};!function o(){t.playing&&t.emit("raf"),t.isDestroy||(r=function(t,e){if(t.closed)return()=>{};let r=!0,o=()=>{};const a=requestAnimationFrame(a=>{r&&(o(),t.closed||e(a))});return o=t.add(()=>{r=!1,cancelAnimationFrame(a)}),o}(e,o))}(),t.on("destroy",()=>{r()})}}const At=new WeakMap;class Pt{constructor(t){this.destroyEvents=new Set;const e=wt(t);At.set(this,e),e.add(()=>this.destroy()),this.proxy=this.proxy.bind(this),this.hover=this.hover.bind(this),function(t,e){const{constructor:r,template:{$player:o,$video:a}}=t;function n(e){C(e,o)?(t.isInput="INPUT"===e.target.tagName,t.isFocus=!0,t.emit("focus",e)):(t.isInput=!1,t.isFocus=!1,t.emit("blur",e))}t.on("document:click",n),t.on("document:contextmenu",n);let i=[];e.proxy(a,"click",e=>{const o=Date.now();i.push(o);const{MOBILE_CLICK_PLAY:a,DBCLICK_TIME:n,MOBILE_DBCLICK_PLAY:s,DBCLICK_FULLSCREEN:l}=r,c=i.filter(t=>o-t<=n);switch(c.length){case 1:t.emit("click",e),p?!t.isLock&&a&&Y(t.toggle()):Y(t.toggle()),i=c;break;case 2:t.emit("dblclick",e),p?!t.isLock&&s&&Y(t.toggle()):l&&(t.fullscreen=!t.fullscreen),i=[];break;default:i=[]}})}(t,this),function(t,e){const{$player:r}=t.template;e.hover(r,e=>{f(r,"art-hover"),t.emit("hover",!0,e)},e=>{g(r,"art-hover"),t.emit("hover",!1,e)})}(t,this),function(t,e){const{$player:r}=t.template;e.proxy(r,"mousemove",e=>{t.emit("mousemove",e)})}(t,this),function(t,e){const{option:r,constructor:o}=t;t.on("resize",()=>{const{aspectRatio:e,notice:o}=t;"standard"===t.state&&r.autoSize&&t.autoSize(),t.aspectRatio=e,o.show=""});const a=wt(t);let n=()=>{};const i=()=>{n(),n=$t(a,()=>t.emit("resize"),o.RESIZE_TIME)};t.on("window:orientationchange",()=>i()),t.on("window:resize",()=>i()),screen&&screen.orientation&&screen.orientation.onchange&&e.proxy(screen.orientation,"change",()=>i())}(t,this),function(t,e){if(p&&!t.option.isLive){const{$video:r,$progress:o}=t.template;let a=null,n=!1,i=0,s=0,l=0;const c=e=>{if(1===e.touches.length&&!t.isLock){a===o&&Ct(t,e),n=!0;const{pageX:r,pageY:c}=e.touches[0];i=r,s=c,l=t.currentTime}},d=e=>{if(1===e.touches.length&&n&&t.duration){const{pageX:o,pageY:n}=e.touches[0],c=St(i,s,o,n),d=[3,4].includes(c),p=[1,2].includes(c);if(d&&!t.isRotate||p&&t.isRotate){const c=F((o-i)/t.width,-1,1),d=F((n-s)/t.height,-1,1),p=t.isRotate?d:c,h=a===r?t.constructor.TOUCH_MOVE_RATIO:1,u=F(l+t.duration*p*h,0,t.duration);t.seek=u,t.emit("setBar","played",F(u/t.duration,0,1),e),t.notice.show=`${B(u)} / ${B(t.duration)}`}}},p=()=>{n&&(i=0,s=0,l=0,n=!1,a=null)};t.option.gesture&&(e.proxy(r,"touchstart",t=>{a=r,c(t)}),e.proxy(r,"touchmove",d)),e.proxy(o,"touchstart",t=>{a=o,c(t)}),e.proxy(o,"touchmove",d),t.on("document:touchend",p)}}(t,this),function(t){const{option:e,constructor:r,template:{$container:o}}=t,a=rt(()=>{t.emit("view",T(o,r.SCROLL_GAP))},r.SCROLL_TIME);t.on("window:scroll",()=>a()),t.on("view",r=>{e.autoMini&&(t.mini=!r)})}(t),function(t,e){const r=["click","mouseup","keydown","touchend","touchmove","mousemove","pointerup","contextmenu","pointermove","visibilitychange","webkitfullscreenchange"],o=["resize","scroll","orientationchange"],a=[];function n(n={}){for(let t=0;t{const o=n.document||i.ownerDocument||document,s=e.proxy(o,r,e=>{t.emit(`document:${r}`,e)});a.push(s)}),o.forEach(r=>{const o=n.window||i.ownerDocument?.defaultView||window,s=e.proxy(o,r,e=>{t.emit(`window:${r}`,e)});a.push(s)})}n(),e.bindGlobalEvents=n}(t,this),Mt(t)}proxy(t,e,r,o={}){if(Array.isArray(e))return e.map(e=>this.proxy(t,e,r,o));if(At.get(this).closed)return()=>{};t.addEventListener(e,r,o);const a=()=>t.removeEventListener(e,r,o);return this.destroyEvents.add(a),a}hover(t,e,r){e&&this.proxy(t,"mouseenter",e),r&&this.proxy(t,"mouseleave",r)}remove(t){if(this.destroyEvents.has(t))try{t()}catch(e){console.warn("Failed to remove event listener:",e)}finally{this.destroyEvents.delete(t)}}destroy(){for(const e of this.destroyEvents)try{e()}catch(t){console.warn("Failed to destroy event listener:",t)}this.destroyEvents.clear()}}class It{constructor(t){this.art=t,this.keys={},p||this.init()}init(){const{constructor:t}=this.art;this.art.option.hotkey&&(this.add("Escape",()=>{this.art.fullscreenWeb&&(this.art.fullscreenWeb=!1)}),this.add("Space",()=>{Y(this.art.toggle())}),this.add("ArrowLeft",()=>{this.art.backward=t.SEEK_STEP}),this.add("ArrowUp",()=>{this.art.volume+=t.VOLUME_STEP}),this.add("ArrowRight",()=>{this.art.forward=t.SEEK_STEP}),this.add("ArrowDown",()=>{this.art.volume-=t.VOLUME_STEP})),this.art.on("document:keydown",t=>{if(this.art.isFocus){const e=document.activeElement.tagName.toUpperCase(),r=document.activeElement.getAttribute("contenteditable");if("INPUT"!==e&&"TEXTAREA"!==e&&""!==r&&"true"!==r&&!t.altKey&&!t.ctrlKey&&!t.metaKey&&!t.shiftKey){const e=this.keys[t.code];if(e){t.preventDefault();for(let r=0;r\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n',state:'\r\n\r\n\r\n',play:'\r\n \r\n',pause:'\r\n \r\n',check:'\r\n\r\n',volume:'\r\n \r\n \r\n',volumeClose:'\r\n \r\n \r\n',screenshot:'\r\n\t\r\n\r\n',setting:'\r\n \r\n \r\n',pip:'\r\n\r\n',arrowLeft:'\r\n \r\n',arrowRight:'\r\n \r\n',playbackRate:'',aspectRatio:'',config:'',lock:'\r\n\r\n\r\n\r\n\r\n',flip:'\r\n\r\n\r\n\r\n\r\n\r\n',unlock:'\r\n\r\n\r\n',fullscreenOff:'\r\n\r\n\r\n\r\n\r\n',fullscreenOn:'\r\n\r\n\r\n\r\n\r\n',fullscreenWebOff:'\r\n\r\n\r\n\r\n\r\n',fullscreenWebOn:'\r\n\r\n\r\n\r\n\r\n',switchOn:'\r\n\r\n\r\n \r\n',switchOff:'\r\n\r\n\r\n \r\n\r\n',error:'\r\n\r\n\r\n\r\n\r\n',close:'\r\n\r\n\r\n\r\n\r\n',airplay:'\r\n \r\n \r\n \r\n \r\n\r\n',...t.option.icons};for(const r in e)X(this,r,{get:()=>S(r,e[r])})}}class Vt extends ut{constructor(t){super(t),this.name="info",p||this.init()}init(){const{proxy:t,constructor:e,template:{$infoPanel:r,$infoClose:o,$video:a}}=this.art;t(o,"click",()=>{this.show=!1});let n=()=>{};const i=m("[data-video]",r)||[];this.art.on("destroy",()=>n());const s=wt(this.art);!function t(){for(let e=0;e{w(a,"display","none"),w(n,"display",null)}),o.proxy(e.$state,"click",()=>Y(t.play()))}}class Ft{constructor(t){this.art=t,this.timer=null,wt(t).add(()=>this.destroy()),t.on("destroy",()=>this.destroy())}destroy(){this.timer&&(clearTimeout(this.timer),this.timer=null)}set show(t){if(wt(this.art).closed)return;const{constructor:e,template:{$player:r,$noticeInner:o}}=this.art;t?(o.textContent=t instanceof Error?t.message.trim():t,f(r,"art-notice-show"),clearTimeout(this.timer),this.timer=setTimeout(()=>{o.textContent="",g(r,"art-notice-show")},e.NOTICE_TIME)):g(r,"art-notice-show")}get show(){const{template:{$player:t}}=this.art;return t.classList.contains("art-notice-show")}}const Ht=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],Bt=(()=>{if("undefined"===typeof document)return!1;const t=Ht[0],e={};for(const r of Ht){if(r[1]in document){for(const[o,a]of r.entries())e[t[o]]=a;return e}}return!1})(),Wt={change:Bt.fullscreenchange,error:Bt.fullscreenerror},jt={request:(t=document.documentElement,e)=>new Promise((r,o)=>{const a=()=>{jt.off("change",a),r()};jt.on("change",a);const n=t[Bt.requestFullscreen](e);n instanceof Promise&&n.then(a).catch(o)}),exit:()=>new Promise((t,e)=>{if(!jt.isFullscreen)return void t();const r=()=>{jt.off("change",r),t()};jt.on("change",r);const o=document[Bt.exitFullscreen]();o instanceof Promise&&o.then(r).catch(e)}),toggle:(t,e)=>jt.isFullscreen?jt.exit():jt.request(t,e),onchange(t){jt.on("change",t)},onerror(t){jt.on("error",t)},on(t,e){const r=Wt[t];r&&document.addEventListener(r,e,!1)},off(t,e){const r=Wt[t];r&&document.removeEventListener(r,e,!1)},raw:Bt};function Ut(t){const{i18n:e,notice:r,template:{$video:o,$player:a}}=t;t.once("video:loadedmetadata",()=>{var n;jt.isEnabled?(n=t,jt.on("change",()=>{n.emit("fullscreen",jt.isFullscreen),jt.isFullscreen?(n.state="fullscreen",f(a,"art-fullscreen")):g(a,"art-fullscreen"),n.emit("resize")}),jt.on("error",t=>{n.emit("fullscreenError",t)}),X(n,"fullscreen",{get:()=>jt.isFullscreen,async set(t){t?await jt.request(a):await jt.exit()}})):o.webkitSupportsFullscreen?(t=>{t.on("document:webkitfullscreenchange",()=>{t.emit("fullscreen",t.fullscreen),t.emit("resize")}),X(t,"fullscreen",{get:()=>document.fullscreenElement===o,set(e){e?(t.state="fullscreen",o.webkitEnterFullscreen()):o.webkitExitFullscreen()}})})(t):X(t,"fullscreen",{get:()=>!1,set(){r.show=e.get("Fullscreen Not Supported")}}),X(t,"fullscreen",Z(t,"fullscreen"))})}function qt(t){const{icons:e,proxy:r,storage:o,template:{$player:a,$video:n}}=t;let i=!1,s=0,l=0;function c(){const{$mini:e}=t.template;e&&(g(a,"art-mini"),w(e,"display","none"),a.prepend(n),t.emit("mini",!1))}function d(e,r){t.playing?(w(e,"display","none"),w(r,"display","flex")):(w(e,"display","flex"),w(r,"display","none"))}function p(){const{$mini:e}=t.template,r=P(e),a=window.innerHeight-r.height-50,n=window.innerWidth-r.width-50;o.set("top",a),o.set("left",n),w(e,"top",`${a}px`),w(e,"left",`${n}px`)}X(t,"mini",{get:()=>v(a,"art-mini"),set(h){if(h){t.state="mini",f(a,"art-mini");const h=function(){const{$mini:a}=t.template;if(a)return y(a,n),w(a,"display","flex");{const a=L("div");f(a,"art-mini-popup"),y(document.body,a),t.template.$mini=a,y(a,n);const p=y(a,'
');y(p,e.close),r(p,"click",c);const h=y(a,'
'),u=y(h,e.play),m=y(h,e.pause);return r(u,"click",()=>Y(t.play())),r(m,"click",()=>t.pause()),d(u,m),t.on("video:playing",()=>d(u,m)),t.on("video:pause",()=>d(u,m)),t.on("video:timeupdate",()=>d(u,m)),r(a,"mousedown",t=>{i=0===t.button,s=t.pageX,l=t.pageY}),t.on("document:mousemove",t=>{if(i){f(a,"art-mini-dragging");const e=t.pageX-s,r=t.pageY-l;w(a,"transform",`translate(${e}px, ${r}px)`)}}),t.on("document:mouseup",()=>{if(i){i=!1,g(a,"art-mini-dragging");const t=P(a);o.set("left",t.left),o.set("top",t.top),w(a,"left",`${t.left}px`),w(a,"top",`${t.top}px`),w(a,"transform",null)}}),a}}(),u=o.get("top"),m=o.get("left");"number"===typeof u&&"number"===typeof m?(w(h,"top",`${u}px`),w(h,"left",`${m}px`),T(h)||p()):p(),t.emit("mini",!0)}else c()}})}function Xt(t){const{i18n:e,notice:r,template:{$video:o}}=t;document.pictureInPictureEnabled?function(t){const{template:{$video:e},proxy:r,notice:o}=t;e.disablePictureInPicture=!1,X(t,"pip",{get:()=>document.pictureInPictureElement,set(r){r?(t.state="pip",e.requestPictureInPicture().catch(t=>{throw o.show=t,t})):document.exitPictureInPicture().catch(t=>{throw o.show=t,t})}}),r(e,"enterpictureinpicture",()=>{t.emit("pip",!0)}),r(e,"leavepictureinpicture",()=>{t.emit("pip",!1)})}(t):o.webkitSupportsPresentationMode?function(t){const{$video:e}=t.template;e.webkitSetPresentationMode("inline"),X(t,"pip",{get:()=>"picture-in-picture"===e.webkitPresentationMode,set(r){r?(t.state="pip",e.webkitSetPresentationMode("picture-in-picture"),t.emit("pip",!0)):(e.webkitSetPresentationMode("inline"),t.emit("pip",!1))}})}(t):X(t,"pip",{get:()=>!1,set(){r.show=e.get("PIP Not Supported")}})}function Gt(t){const{option:e,template:{$progress:r,$video:o}}=t;let a=null,n=!1,i=null;t.on("setBar",async(a,s,l)=>{const c=t.controls?.thumbnails,{url:d,scale:h}=e.thumbnails;if(!c||!d)return;if("hover"===a||"played"===a&&l&&p){if(i||n||(n=!0,i=await I(d,h),n=!1),!i)return;const a=r.clientWidth*s;a>0&&ar.clientWidth-h/2?w(n,"left",r.clientWidth-h+"px"):w(n,"left",a-h/2+"px")}(a)}}),X(t,"thumbnails",{get:()=>t.option.thumbnails,set(e){e.url&&!t.option.isLive&&(t.option.thumbnails=e,clearTimeout(a),a=null,n=!1,i=null)}})}Object.defineProperties(jt,{isFullscreen:{get:()=>Boolean(document[Bt.fullscreenElement])},element:{enumerable:!0,get:()=>document[Bt.fullscreenElement]},isEnabled:{enumerable:!0,get:()=>Boolean(document[Bt.fullscreenEnabled])}});class Kt{constructor(t){!function(t){const{option:e,template:{$video:r}}=t;X(t,"url",{get:()=>r.src,async set(o){if(o){const a=t.url,n=e.type||N(o),i=e.customType[n];if(n&&i){if(!(await Et(wt(t)))||wt(t).closed)return;t.loading.show=!0,i.call(t,r,o,t)}else URL.revokeObjectURL(a),r.src=o;a!==t.url&&(t.option.url=o,t.isReady&&a&&t.once("video:canplay",()=>{t.emit("restart",o)}))}else{if(!(await Et(wt(t)))||wt(t).closed)return;t.loading.show=!0}}})}(t),function(t){const{template:{$video:e}}=t;X(t,"attr",{value(t,r){if(void 0===r)return e[t];e[t]=r}})}(t),function(t){const{i18n:e,notice:r,option:o,constructor:{instances:a},template:{$video:n}}=t;X(t,"play",{async value(){const i=await n.play();if(r.show=e.get("Play"),t.emit("play"),o.mutex)for(let e=0;et.playing?t.pause():t.play()})}(t),function(t){const{notice:e}=t;X(t,"seek",{set(r){t.currentTime=r,t.duration&&(e.show=`${B(t.currentTime)} / ${B(t.duration)}`),t.emit("seek",t.currentTime,r)}}),X(t,"forward",{set(e){t.seek=t.currentTime+e}}),X(t,"backward",{set(e){t.seek=t.currentTime-e}})}(t),function(t){const{template:{$video:e},i18n:r,notice:o,storage:a}=t;X(t,"volume",{get:()=>e.volume||0,set:t=>{e.volume=F(t,0,1),o.show=`${r.get("Volume")}: ${Number.parseInt(100*e.volume,10)}`,0!==e.volume&&a.set("volume",e.volume)}}),X(t,"muted",{get:()=>e.muted,set:r=>{e.muted=r,t.emit("muted",r)}})}(t),function(t){const{$video:e}=t.template;X(t,"currentTime",{get:()=>e.currentTime||0,set:r=>{r=Number.parseFloat(r),Number.isNaN(r)||(e.currentTime=F(r,0,t.duration))}})}(t),function(t){X(t,"duration",{get:()=>{const{duration:e}=t.template.$video;return e===1/0?0:e||0}})}(t),function(t){function e(e,r){return new Promise((o,a)=>{if(e===t.url)return void o();const{playing:n,aspectRatio:i,playbackRate:s}=t;t.pause(),t.url=e,t.notice.show="";const l={error:e=>{t.off("video:canplay",l.canplay),t.off("video:loadedmetadata",l.metadata),a(e)},metadata:()=>{t.currentTime=r},canplay:async()=>{t.off("video:error",l.error),t.playbackRate=s,t.aspectRatio=i,n&&await Y(t.play()),t.notice.show="",o()}};t.once("video:error",l.error),t.once("video:loadedmetadata",l.metadata),t.once("video:canplay",l.canplay)})}X(t,"switchQuality",{value:r=>e(r,t.currentTime)}),X(t,"switchUrl",{value:t=>e(t,0)}),X(t,"switch",{set:t.switchUrl})}(t),function(t){const{template:{$video:e},i18n:r,notice:o}=t;X(t,"playbackRate",{get:()=>e.playbackRate,set(a){if(a){if(a===e.playbackRate)return;e.playbackRate=a,o.show=`${r.get("Rate")}: ${1===a?r.get("Normal"):`${a}x`}`}else t.playbackRate=1}})}(t),function(t){const{i18n:e,notice:r,template:{$video:o,$player:a}}=t;X(t,"aspectRatio",{get:()=>a.dataset.aspectRatio||"default",set(n){if(n||(n="default"),"default"===n)w(o,"width",null),w(o,"height",null),w(o,"margin",null),delete a.dataset.aspectRatio;else{const t=n.split(":").map(Number),{clientWidth:e,clientHeight:r}=a,i=e/r,s=t[0]/t[1];i>s?(w(o,"width",s*r+"px"),w(o,"height","100%"),w(o,"margin","0 auto")):(w(o,"width","100%"),w(o,"height",e/s+"px"),w(o,"margin","auto 0")),a.dataset.aspectRatio=n}r.show=`${e.get("Aspect Ratio")}: ${"default"===n?e.get("Default"):n}`,t.emit("aspectRatio",n)}})}(t),function(t){const{notice:e,template:{$video:r}}=t,o=L("canvas");X(t,"getDataURL",{value:()=>new Promise((t,a)=>{try{o.width=r.videoWidth,o.height=r.videoHeight,o.getContext("2d").drawImage(r,0,0),t(o.toDataURL("image/png"))}catch(n){e.show=n,a(n)}})}),X(t,"getBlobUrl",{value:()=>new Promise((t,a)=>{try{o.width=r.videoWidth,o.height=r.videoHeight,o.getContext("2d").drawImage(r,0,0),o.toBlob(e=>{t(URL.createObjectURL(e))})}catch(n){e.show=n,a(n)}})}),X(t,"screenshot",{value:async e=>{const o=await t.getDataURL();return D(o,`${e||`artplayer_${B(r.currentTime)}`}.png`),t.emit("screenshot",o),o}})}(t),Ut(t),function(t){const{constructor:e,template:{$container:r,$player:o}}=t;let a="";X(t,"fullscreenWeb",{get:()=>v(o,"art-fullscreen-web"),set(n){n?(a=o.style.cssText,e.FULLSCREEN_WEB_IN_BODY&&y(document.body,o),t.state="fullscreenWeb",w(o,"width","100%"),w(o,"height","100%"),f(o,"art-fullscreen-web"),t.emit("fullscreenWeb",!0)):(e.FULLSCREEN_WEB_IN_BODY&&y(r,o),a&&(o.style.cssText=a,a=""),g(o,"art-fullscreen-web"),t.emit("fullscreenWeb",!1)),t.emit("resize")}})}(t),Xt(t),function(t){const{$video:e}=t.template;X(t,"loaded",{get:()=>t.loadedTime/e.duration}),X(t,"loadedTime",{get:()=>e.buffered.length?e.buffered.end(e.buffered.length-1):0})}(t),function(t){X(t,"played",{get:()=>t.currentTime/t.duration})}(t),function(t){const{$video:e}=t.template;X(t,"playing",{get:()=>"boolean"===typeof e.playing?e.playing:!!(e.currentTime>0&&!e.paused&&!e.ended&&e.readyState>2)})}(t),function(t){const{$container:e,$player:r,$video:o}=t.template;X(t,"autoSize",{value(){const{videoWidth:a,videoHeight:n}=o,{width:i,height:s}=P(e),l=a/n;if(i/s>l)w(r,"width",s*l/i*100+"%"),w(r,"height","100%");else{const t=i/l/s*100;w(r,"width","100%"),w(r,"height",`${t}%`)}t.emit("autoSize",{width:t.width,height:t.height})}})}(t),function(t){const e=t;X(t,"rect",{get:()=>P(t.template.$player)});const r=["bottom","height","left","right","top","width"];for(let o=0;oe.rect[a]})}X(t,"x",{get:()=>e.left+window.pageXOffset}),X(t,"y",{get:()=>e.top+window.pageYOffset})}(t),function(t){const{template:{$player:e},i18n:r,notice:o}=t;X(t,"flip",{get:()=>e.dataset.flip||"normal",set(a){a||(a="normal"),"normal"===a?delete e.dataset.flip:e.dataset.flip=a,o.show=`${r.get("Video Flip")}: ${r.get(H(a))}`,t.emit("flip",a)}})}(t),qt(t),function(t){const{template:{$poster:e}}=t;X(t,"poster",{get:()=>{try{return e.style.backgroundImage.match(/"(.*)"/)[1]}catch{return""}},set(t){w(e,"backgroundImage",`url(${t})`)}})}(t),function(t){const{template:{$container:e,$video:r}}=t;X(t,"autoHeight",{value(){const{clientWidth:o}=e,{videoHeight:a,videoWidth:n}=r,i=a*(o/n);w(e,"height",`${i}px`),t.emit("autoHeight",i)}})}(t),function(t){const{$player:e}=t.template;X(t,"cssVar",{value:(t,r)=>r?e.style.setProperty(t,r):getComputedStyle(e).getPropertyValue(t)})}(t),function(t){X(t,"theme",{get:()=>t.cssVar("--art-theme"),set(e){t.cssVar("--art-theme",e)}})}(t),function(t){X(t,"type",{get:()=>t.option.type,set(e){t.option.type=e}})}(t),function(t){const e=["mini","pip","fullscreen","fullscreenWeb"];X(t,"state",{get:()=>e.find(e=>t[e])||"standard",set(r){for(let o=0;oo.$track?.offset||0,set(a){const{cues:n}=t.subtitle;if(!o.$track||0===n.length)return;const i=F(a,-10,10);o.$track.offset=i;for(let e=0;e{switch(t.availability){case"available":n=!0;break;case"not-available":n=!1}}):n=!1,X(t,"airplay",{value(){n?(a.webkitShowPlaybackTargetPicker(),t.emit("airplay")):r.show=e.get("AirPlay Not Available")}})}(t),function(t){X(t,"quality",{set(e){const{controls:r,notice:o,i18n:a}=t,n=e.find(t=>t.default)||e[0];r.update({name:"quality",position:"right",index:10,style:{marginRight:"10px"},html:n?.html||"",selector:e,onSelect:async e=>(await t.switchQuality(e.url),o.show=`${a.get("Switch Video")}: ${e.html}`,e.html)})}})}(t),Gt(t),function(t){const{i18n:e,notice:r,option:o,constructor:a,proxy:n,template:{$player:s,$video:l,$poster:c}}=t;let d=0;for(let p=0;p{t.emit(`video:${e.type}`,e)});t.on("video:canplay",()=>{d=0,t.loading.show=!1}),t.once("video:canplay",()=>{t.loading.show=!1,t.controls.show=!0,t.mask.show=!0,t.isReady=!0,t.emit("ready")}),t.on("video:ended",()=>{o.loop?(t.seek=0,Y(t.play()),t.controls.show=!1,t.mask.show=!1):(t.controls.show=!0,t.mask.show=!0)}),t.on("video:error",async n=>{if(d{t.emit("resize"),p&&(t.loading.show=!1,t.controls.show=!0,t.mask.show=!0)}),t.on("video:loadstart",()=>{t.loading.show=!0,t.mask.show=!1,t.controls.show=!0}),t.on("video:pause",()=>{t.controls.show=!0,t.mask.show=!0}),t.on("video:play",()=>{t.mask.show=!1,w(c,"display","none")}),t.on("video:playing",()=>{t.mask.show=!1}),t.on("video:progress",()=>{t.playing&&(t.loading.show=!1)}),t.on("video:seeked",()=>{t.loading.show=!1,t.mask.show=!0}),t.on("video:seeking",()=>{t.loading.show=!0,t.mask.show=!1}),t.on("video:timeupdate",()=>{t.mask.show=!1}),t.on("video:waiting",()=>{t.loading.show=!0,t.mask.show=!1})}(t),function(t){const{option:e,storage:r,template:{$video:o,$poster:a}}=t;for(const i in e.moreVideoAttr)t.attr(i,e.moreVideoAttr[i]);e.muted&&(t.muted=e.muted),e.volume&&(o.volume=F(e.volume,0,1));const n=r.get("volume");"number"===typeof n&&(o.volume=F(n,0,1)),e.poster&&w(a,"backgroundImage",`url(${e.poster})`),e.autoplay&&(o.autoplay=e.autoplay),e.playsInline&&(o.playsInline=!0,o["webkit-playsinline"]=!0),e.theme&&(e.cssVar["--art-theme"]=e.theme);for(const i in e.cssVar)t.cssVar(i,e.cssVar[i]);t.url=e.url}(t)}}function Zt(t){const{notice:e,constructor:r,template:{$player:o,$video:a}}=t,n="art-auto-orientation",i="art-auto-orientation-fullscreen";let s=!1;function l(){const{videoWidth:t,videoHeight:e}=a,r=document.documentElement.clientWidth,o=document.documentElement.clientHeight;return t>e&&ro}return t.on("fullscreenWeb",e=>{if(e){if(l()){const e=Number(r.AUTO_ORIENTATION_TIME??0);setTimeout(()=>{t.fullscreenWeb&&!v(o,n)&&function(){const e=O(),r=document.documentElement.clientWidth,a=document.documentElement.clientHeight-e.top-e.bottom,i=r-e.left-e.right;w(o,"width",`${a}px`),w(o,"height",`${i}px`),w(o,"transform-origin","0 0"),w(o,"transform",`rotate(90deg) translate(${e.top}px, -${r-e.right}px)`),f(o,n),t.isRotate=!0,t.emit("resize")}()},e)}}else v(o,n)&&(w(o,"width",""),w(o,"height",""),w(o,"transform-origin",""),w(o,"transform",""),g(o,n),t.isRotate=!1,t.emit("resize"))}),t.on("fullscreen",async t=>{const r=!!screen?.orientation?.lock;if(t){if(r&&l())try{const t=screen.orientation.type.startsWith("portrait")?"landscape":"portrait";await screen.orientation.lock(t),s=!0,f(o,i)}catch(a){s=!1,e.show=a}}else if(v(o,i)&&g(o,i),r&&s){try{screen.orientation.unlock()}catch{}s=!1}}),{name:"autoOrientation",get state(){return v(o,n)}}}function Jt(t){const{i18n:e,icons:r,storage:o,constructor:a,proxy:n,template:{$poster:i}}=t,s=t.layers.add({name:"auto-playback",html:'\n
\n
\n
\n '}),l=u(".art-auto-playback-last",s),c=u(".art-auto-playback-jump",s),d=u(".art-auto-playback-close",s);y(d,r.close);let p=null;function h(){const r=(o.get("times")||{})[t.option.id||t.option.url];clearTimeout(p),w(s,"display","none"),r&&r>=a.AUTO_PLAYBACK_MIN&&(w(s,"display","flex"),l.textContent=`${e.get("Last Seen")} ${B(r)}`,c.textContent=e.get("Jump Play"),n(d,"click",()=>{w(s,"display","none")}),n(c,"click",()=>{t.seek=r,Y(t.play()),w(i,"display","none"),w(s,"display","none")}),t.once("video:timeupdate",()=>{p=setTimeout(()=>{w(s,"display","none")},a.AUTO_PLAYBACK_TIMEOUT)}))}return t.on("video:timeupdate",()=>{if(t.playing){const e=o.get("times")||{},r=Object.keys(e);r.length>a.AUTO_PLAYBACK_MAX&&delete e[r[0]],e[t.option.id||t.option.url]=t.currentTime,o.set("times",e)}}),t.on("ready",h),t.on("restart",h),{name:"auto-playback",get times(){return o.get("times")||{}},clear:()=>o.del("times"),delete(t){const e=o.get("times")||{};return delete e[t],o.set("times",e),e}}}function Qt(t){const{constructor:e,proxy:r,template:{$player:o,$video:a}}=t;let n=null,i=!1,s=1;const l=()=>{clearTimeout(n),i&&(i=!1,t.playbackRate=s,g(o,"art-fast-forward"))};return r(a,"touchstart",r=>{1===r.touches.length&&t.playing&&!t.isLock&&(n=setTimeout(()=>{i=!0,s=t.playbackRate,t.playbackRate=e.FAST_FORWARD_VALUE,f(o,"art-fast-forward")},e.FAST_FORWARD_TIME))}),t.on("document:touchmove",l),t.on("document:touchend",l),{name:"fastForward",get state(){return v(o,"art-fast-forward")}}}function te(t){const{layers:e,icons:r,template:{$player:o}}=t;function a(){return v(o,"art-lock")}function n(){f(o,"art-lock"),t.isLock=!0,t.emit("lock",!0)}function i(){g(o,"art-lock"),t.isLock=!1,t.emit("lock",!1)}return e.add({name:"lock",mounted(e){const o=y(e,r.lock),a=y(e,r.unlock);w(o,"display","none"),t.on("lock",t=>{t?(w(o,"display","inline-flex"),w(a,"display","none")):(w(o,"display","none"),w(a,"display","inline-flex"))})},click(){a()?i():n()}}),{name:"lock",get state(){return a()},set state(t){t?n():i()}}}function ee(t){return t.on("control",e=>{e?g(t.template.$player,"art-mini-progress-bar"):f(t.template.$player,"art-mini-progress-bar")}),{name:"mini-progress-bar"}}class re{constructor(t){this.art=t,this.id=0;const{option:e}=t;!function(t,e){xt(t.art)||!e.miniProgressBar||e.isLive||t.add(ee),!xt(t.art)&&e.lock&&p&&t.add(te),xt(t.art)||!e.autoPlayback||e.isLive||t.add(Jt),!xt(t.art)&&e.autoOrientation&&p&&t.add(Zt),!xt(t.art)&&e.fastForward&&p&&!e.isLive&&t.add(Qt)}(this,e);for(let r=0;rconsole.warn("Failed to initialize ArtPlayer plugin:",t))}}add(t){V(!xt(this.art),"Cannot add a plugin after ArtPlayer is destroyed"),this.id+=1;const e=t.call(this.art,this.art);return e instanceof Promise?e.then(e=>this.next(t,e)):this.next(t,e)}next(t,e){return function(t,e,r){if(xt(t.art))return t;const o=r&&r.name||e.name||`plugin${t.id}`;if(xt(t.art))return t;let a=o;const n=K(t,a);if(xt(t.art))return t;const i=`Cannot add a plugin that already has the same name: ${o}`;return xt(t.art)||(V(!n,i),("object"===typeof o&&null!==o||"function"===typeof o)&&(a=Reflect.ownKeys({[a]:void 0})[0]),xt(t.art)||X(t,a,{value:r})),t}(this,t,e)}}class oe extends ut{constructor(t){super(t);const{option:e,controls:r,template:{$setting:o}}=t;this.name="setting",this.$parent=o,this.id=0,this.active=null,this.cache=new Map,this.option=[...this.builtin,...e.settings],e.setting&&(this.format(),this.render(),t.on("blur",()=>{this.show&&(this.show=!1,this.render())}),t.on("focus",t=>{const e=C(t,r.setting),o=C(t,this.$parent);!this.show||e||o||(this.show=!1,this.render())}),t.on("resize",()=>this.resize()))}get builtin(){const t=[],{option:e}=this.art;return e.playbackRate&&t.push(function(t){const{i18n:e,icons:r,constructor:{SETTING_ITEM_WIDTH:o,PLAYBACK_RATE:a}}=t;function n(t){return 1===t?e.get("Normal"):t.toFixed(1)}function i(){const e=t.setting.find(`playback-rate-${t.playbackRate}`);t.setting.check(e)}return{width:o,name:"playback-rate",html:e.get("Play Speed"),tooltip:n(t.playbackRate),icon:r.playbackRate,selector:a.map(e=>({value:e,name:`playback-rate-${e}`,default:e===t.playbackRate,html:n(e)})),onSelect:e=>(t.playbackRate=e.value,e.html),mounted:()=>{i(),t.on("video:ratechange",()=>i())}}}(this.art)),e.aspectRatio&&t.push(function(t){const{i18n:e,icons:r,constructor:{SETTING_ITEM_WIDTH:o,ASPECT_RATIO:a}}=t;function n(t){return"default"===t?e.get("Default"):t}function i(){const e=t.setting.find(`aspect-ratio-${t.aspectRatio}`);t.setting.check(e)}return{width:o,name:"aspect-ratio",html:e.get("Aspect Ratio"),icon:r.aspectRatio,tooltip:n(t.aspectRatio),selector:a.map(e=>({value:e,name:`aspect-ratio-${e}`,default:e===t.aspectRatio,html:n(e)})),onSelect:e=>(t.aspectRatio=e.value,e.html),mounted:()=>{i(),t.on("aspectRatio",()=>i())}}}(this.art)),e.flip&&t.push(function(t){const{i18n:e,icons:r,constructor:{SETTING_ITEM_WIDTH:o,FLIP:a}}=t;function n(t){return e.get(H(t))}function i(){const e=t.setting.find(`flip-${t.flip}`);t.setting.check(e)}return{width:o,name:"flip",html:e.get("Video Flip"),tooltip:n(t.flip),icon:r.flip,selector:a.map(e=>({value:e,name:`flip-${e}`,default:e===t.flip,html:n(e)})),onSelect:e=>(t.flip=e.value,e.html),mounted:()=>{i(),t.on("flip",()=>i())}}}(this.art)),e.subtitleOffset&&t.push(function(t){const{i18n:e,icons:r,constructor:o}=t;return{width:o.SETTING_ITEM_WIDTH,name:"subtitle-offset",html:e.get("Subtitle Offset"),icon:r.subtitle,tooltip:"0s",range:[0,-10,10,.1],onChange:e=>(t.subtitleOffset=e.range[0],`${e.range[0]}s`),mounted:(e,r)=>{t.on("subtitleOffset",t=>{r.$range.value=t,r.tooltip=`${t}s`})}}}(this.art)),t}traverse(t,e=this.option){for(let r=0;r{e.default=e===t,e.default&&e.$item&&$(e.$item,"art-current")},t.$option),this.render(t.$parents))}format(t=this.option,e,r,o=[]){for(let a=0;ae}),X(n,"$parents",{get:()=>r}),X(n,"$option",{get:()=>t});const o=[];X(n,"$events",{get:()=>o}),X(n,"$formatted",{get:()=>!0})}this.format(n.selector||[],n,t,o)}this.option=t}find(t=""){let e=null;return this.traverse(r=>{r.name===t&&(e=r)}),e}resize(){const{controls:t,constructor:{SETTING_WIDTH:e,SETTING_ITEM_HEIGHT:r},template:{$player:o,$setting:a}}=this.art;if(t.setting&&this.show){const n=this.active[0]?.$parent?.width||e,{left:i,width:s}=P(t.setting),{left:l,width:c}=P(o),d=i-l+s/2-n/2;if(w(a,"height",`${this.active===this.option?this.active.length*r:(this.active.length+1)*r}px`),w(a,"width",`${n}px`),this.art.isRotate||p)return;d+n>c?(w(a,"left",null),w(a,"right",null)):(w(a,"left",`${d}px`),w(a,"right","auto"))}}inactivate(t){for(let e=0;e'),s=L("div");f(s,"art-setting-item-left-icon"),y(s,o),y(i,s),y(i,t.$parent.html);const l=r(n,"click",()=>this.render(t.$parents));t.$parent.$events.push(l),y(e,n)}createItem(t,e=!1){if(!this.cache.has(t.$option))return;const r=this.cache.get(t.$option),o=t.$item;let a="selector";K(t,"switch")&&(a="switch"),K(t,"range")&&(a="range"),K(t,"onClick")&&(a="button");const{icons:n,proxy:i,constructor:s}=this.art,l=L("div");f(l,"art-setting-item"),w(l,"height",`${s.SETTING_ITEM_HEIGHT}px`),l.dataset.name=t.name||"",l.dataset.value=t.value||"";const c=y(l,'
'),d=y(l,'
'),p=L("div");switch(f(p,"art-setting-item-left-icon"),a){case"button":case"switch":case"range":y(p,t.icon||n.config);break;case"selector":t.selector?.length?y(p,t.icon||n.config):y(p,n.check)}y(c,p),X(t,"$icon",{configurable:!0,get:()=>p}),X(t,"icon",{configurable:!0,get:()=>p.innerHTML,set(t){p.innerHTML="",y(p,t)}});const h=L("div");f(h,"art-setting-item-left-text"),y(h,t.html||""),y(c,h),X(t,"$html",{configurable:!0,get:()=>h}),X(t,"html",{configurable:!0,get:()=>h.innerHTML,set(t){h.innerHTML="",y(h,t)}});const u=L("div");switch(f(u,"art-setting-item-right-tooltip"),y(u,t.tooltip||""),y(d,u),X(t,"$tooltip",{configurable:!0,get:()=>u}),X(t,"tooltip",{configurable:!0,get:()=>u.innerHTML,set(t){u.innerHTML="",y(u,t)}}),a){case"switch":{const e=L("div");f(e,"art-setting-item-right-icon");const r=y(e,n.switchOn),o=y(e,n.switchOff);w(t.switch?o:r,"display","none"),y(d,e),X(t,"$switch",{configurable:!0,get:()=>e});let a=t.switch;X(t,"switch",{configurable:!0,get:()=>a,set(t){a=t,t?(w(o,"display","none"),w(r,"display",null)):(w(o,"display",null),w(r,"display","none"))}});break}case"range":{const e=L("div");f(e,"art-setting-item-right-icon");const r=y(e,'');r.value=t.range[0],r.min=t.range[1],r.max=t.range[2],r.step=t.range[3],f(r,"art-setting-range"),y(d,e),X(t,"$range",{configurable:!0,get:()=>r});let o=[...t.range];X(t,"range",{configurable:!0,get:()=>o,set(t){o=[...t],r.value=t[0],r.min=t[1],r.max=t[2],r.step=t[3]}})}break;case"selector":if(t.selector?.length){const t=L("div");f(t,"art-setting-item-right-icon"),y(t,n.arrowRight),y(d,t)}}switch(a){case"switch":if(t.onSwitch){const e=i(l,"click",async e=>{t.switch=await t.onSwitch.call(this.art,t,l,e)});t.$events.push(e)}break;case"range":if(t.$range){if(t.onRange){const e=i(t.$range,"change",async e=>{t.range[0]=t.$range.valueAsNumber,t.tooltip=await t.onRange.call(this.art,t,l,e)});t.$events.push(e)}if(t.onChange){const e=i(t.$range,"input",async e=>{t.range[0]=t.$range.valueAsNumber,t.tooltip=await t.onChange.call(this.art,t,l,e)});t.$events.push(e)}}break;case"selector":{const e=i(l,"click",async e=>{t.selector?.length?this.render(t.selector):(this.check(t),t.$parent.onSelect&&(t.$parent.tooltip=await t.$parent.onSelect.call(this.art,t,l,e)))});t.$events.push(e),t.default&&f(l,"art-current")}break;case"button":if(t.onClick){const e=i(l,"click",async e=>{t.tooltip=await t.onClick.call(this.art,t,l,e)});t.$events.push(e)}}X(t,"$item",{configurable:!0,get:()=>l}),e?z(l,o):y(r,l),t.mounted&&$t(wt(this.art),()=>t.mounted.call(this.art,t.$item,t),0)}render(t=this.option){if(this.active=t,this.cache.has(t)){$(this.cache.get(t),"art-current")}else{const e=L("div");this.cache.set(t,e),f(e,"art-setting-panel"),y(this.$parent,e),$(e,"art-current"),t[0]?.$parent&&this.createHeader(t[0]);for(let r=0;rnull,this.init(t.option.subtitle);let e=!1;t.on("video:timeupdate",()=>{if(!this.url)return;const t=this.art.template.$video.webkitDisplayingFullscreen;"boolean"===typeof t&&t!==e&&(e=t,this.createTrack(t?"subtitles":"metadata",this.url))})}get url(){return this.art.template.$track.src}set url(t){this.switch(t)}get textTrack(){return this.art.template.$video?.textTracks?.[0]}get activeCues(){return this.textTrack?Array.from(this.textTrack.activeCues):[]}get cues(){return this.textTrack?Array.from(this.textTrack.cues):[]}style(t,e){const{$subtitle:r}=this.art.template;return"object"===typeof t?x(r,t):w(r,t,e)}update(){const{option:{subtitle:t},template:{$subtitle:e}}=this.art;e.innerHTML="",this.activeCues.length&&(this.art.emit("subtitleBeforeUpdate",this.activeCues),e.innerHTML=this.activeCues.map((e,r)=>e.text.split(/\r?\n/).filter(t=>t.trim()).map(e=>`
\n ${t.escape?q(e):e}\n
`).join("")).join(""),this.art.emit("subtitleAfterUpdate",this.activeCues))}async switch(t,e={}){const{i18n:r,notice:o,option:a}=this.art,n={...a.subtitle,...e,url:t},i=await this.init(n);return e.name&&(o.show=`${r.get("Switch Subtitle")}: ${e.name}`),i}createTrack(t,e){const{template:r,proxy:o,option:a}=this.art,{$video:n,$track:i}=r,s=L("track");s.default=!0,s.kind=t,s.src=e,s.label=a.subtitle.name||"Artplayer",s.track.mode="hidden",s.onload=()=>{this.art.emit("subtitleLoad",this.cues,this.option)},this.art.events.remove(this.destroyEvent),i.onload=null,b(i),y(n,s),r.$track=s,this.destroyEvent=o(this.textTrack,"cuechange",()=>this.update())}async init(t){const{notice:e,template:{$subtitle:r}}=this.art;return this.textTrack?(a(t,ht.subtitle),t.url?(this.option=t,this.style(t.style),fetch(t.url).then(t=>t.arrayBuffer()).then(e=>{const r=new TextDecoder(t.encoding).decode(e);switch(t.type||N(t.url)){case"srt":{const e=Q(r);return tt(t.onVttLoad(e))}case"ass":{const e=et(r);return tt(t.onVttLoad(e))}case"vtt":return tt(t.onVttLoad(r));default:return t.url}}).then(t=>(r.innerHTML="",this.url===t||(URL.revokeObjectURL(this.url),this.createTrack("metadata",t)),t)).catch(t=>{throw r.innerHTML="",e.show=t,t})):void 0):null}}class se{constructor(t){this.art=t;const{option:e,constructor:r}=t;e.container instanceof Element?this.$container=e.container:(this.$container=u(e.container),V(this.$container,`No container element found by ${e.container}`)),V(A(),"The current browser does not support flex layout");const o=this.$container.tagName.toLowerCase();V("div"===o,`Unsupported container element type, only support 'div' but got '${o}'`),V(r.instances.every(t=>t.template.$container!==this.$container),"Cannot mount multiple instances on the same dom element"),this.query=this.query.bind(this),function(t,e,r){const o=yt.get(e);if(o&&o!==t)throw new Error("Cannot mount multiple instances on the same dom element");const a=bt(t);a.rollback=r,yt.set(e,t),a.releaseContainer=()=>{yt.get(e)===t&&yt.delete(e)}}(t,this.$container,function(t){const e=[];return function t(r){const o=Array.from(r.childNodes);e.push({node:r,children:o,attributes:1===r.nodeType?Array.from(r.attributes,t=>[t.name,t.value]):void 0,value:r.nodeValue}),o.forEach(t)}(t),()=>{for(const{node:t,children:r,attributes:o,value:a}of e){for(;t.firstChild;)t.removeChild(t.firstChild);for(const e of r)t.appendChild(e);if(o){const e=t;for(const t of Array.from(e.attributes))e.removeAttribute(t.name);for(const[t,r]of o)e.setAttribute(t,r)}else t.nodeValue=a}}}(this.$container)),this.$container.dataset.artId=t.id,this.init()}static get html(){return`\n
\n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
Player version:
\n
${n}
\n
\n
\n
Video url:
\n
\n
\n
\n
Video volume:
\n
\n
\n
\n
Video time:
\n
\n
\n
\n
Video duration:
\n
\n
\n
\n
Video resolution:
\n
\n x \n
\n
\n
\n
[x]
\n
\n
\n
\n `}query(t){return u(t,this.$container)}init(){const{option:t}=this.art;if(t.useSSR||(this.$container.innerHTML=se.html),this.$player=this.query(".art-video-player"),this.$video=this.query(".art-video"),this.$track=this.query("track"),this.$poster=this.query(".art-poster"),this.$subtitle=this.query(".art-subtitle"),this.$danmuku=this.query(".art-danmuku"),this.$bottom=this.query(".art-bottom"),this.$progress=this.query(".art-progress"),this.$controls=this.query(".art-controls"),this.$controlsLeft=this.query(".art-controls-left"),this.$controlsCenter=this.query(".art-controls-center"),this.$controlsRight=this.query(".art-controls-right"),this.$layer=this.query(".art-layers"),this.$loading=this.query(".art-loading"),this.$notice=this.query(".art-notice"),this.$noticeInner=this.query(".art-notice-inner"),this.$mask=this.query(".art-mask"),this.$state=this.query(".art-state"),this.$setting=this.query(".art-settings"),this.$info=this.query(".art-info"),this.$infoPanel=this.query(".art-info-panel"),this.$infoClose=this.query(".art-info-close"),this.$contextmenu=this.query(".art-contextmenus"),t.proxy){const e=t.proxy.call(this.art,this.art);V(e instanceof HTMLVideoElement||e instanceof HTMLCanvasElement,"Function 'option.proxy' needs to return 'HTMLVideoElement' or 'HTMLCanvasElement'"),z(e,this.$video),e.className="art-video",this.$video=e}t.backdrop&&f(this.$player,"art-backdrop"),p&&f(this.$player,"art-mobile")}destroy(t){t?this.$container.innerHTML="":f(this.$player,"art-destroy")}}const le=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);class ce{on(t,e,r){const o=this.e||(this.e={});let a=le(o,t)?o[t]:void 0;return a||(a=[],Object.defineProperty(o,t,{value:a,enumerable:!0,configurable:!0,writable:!0})),a.push({fn:e,ctx:r}),this}once(t,e,r){const o=this,a=e;let n=!1;function i(...e){n||(n=!0,o.off(t,i),a.apply(r,e))}return i._=e,this.on(t,i,r)}emit(t,...e){const r=this.e||(this.e={}),o=(le(r,t)&&r[t]||[]).slice();for(const a of o)a.fn.apply(a.ctx,e);return this}off(t,e){const r=this.e||(this.e={}),o=le(r,t)?r[t]:void 0,a=[];if(o&&e)for(let n=0,i=o.length;ne.call(this,this)),he.DEBUG){const t=t=>console.log(`[ART.${this.id}] -> ${t}`);t(`Version@${he.version}`);for(let e=0;et(`Event@${e.type}`))}(function(t){const e=bt(t);return e.rollback=void 0,!e.scope.closed})(this)&&pe.push(this)}catch(o){try{kt(this,pe,!0,he.REMOVE_SRC_WHEN_DESTROY,!0)}catch(n){console.warn("Failed to clean up ArtPlayer initialization:",n)}throw o}}static get instances(){return pe}static get version(){return n}static get config(){return i}static get utils(){return ot}static get scheme(){return ht}static get Emitter(){return ce}static get validator(){return a}static get kindOf(){return a.kindOf}static get html(){return se.html}static get option(){return{id:"",container:"#artplayer",url:"",poster:"",type:"",theme:"#f00",volume:.7,isLive:!1,muted:!1,autoplay:!1,autoSize:!1,autoMini:!1,loop:!1,flip:!1,playbackRate:!1,aspectRatio:!1,screenshot:!1,setting:!1,hotkey:!0,pip:!1,mutex:!0,backdrop:!0,fullscreen:!1,fullscreenWeb:!1,subtitleOffset:!1,miniProgressBar:!1,useSSR:!1,playsInline:!0,lock:!1,gesture:!0,fastForward:!1,autoPlayback:!1,autoOrientation:!1,airplay:!1,proxy:void 0,layers:[],contextmenu:[],controls:[],settings:[],quality:[],highlight:[],plugins:[],thumbnails:{url:"",number:60,column:10,width:0,height:0,scale:1},subtitle:{url:"",type:"",style:{},name:"",escape:!0,encoding:"utf-8",onVttLoad:t=>t},moreVideoAttr:{controls:!1,preload:l?"auto":"metadata"},i18n:{},icons:{},cssVar:{},customType:{},lang:navigator?.language.toLowerCase()}}get proxy(){return this.events.proxy}get query(){return this.template.query}get video(){return this.template.$video}reset(){this.video.removeAttribute("src"),this.video.load()}destroy(t=!0){kt(this,pe,t,he.REMOVE_SRC_WHEN_DESTROY)}}return he.STYLE=ne,he.DEBUG=!1,he.CONTEXTMENU=!0,he.NOTICE_TIME=2e3,he.SETTING_WIDTH=250,he.SETTING_ITEM_WIDTH=200,he.SETTING_ITEM_HEIGHT=35,he.RESIZE_TIME=200,he.SCROLL_TIME=200,he.SCROLL_GAP=50,he.AUTO_PLAYBACK_MAX=10,he.AUTO_PLAYBACK_MIN=5,he.AUTO_PLAYBACK_TIMEOUT=3e3,he.RECONNECT_TIME_MAX=5,he.RECONNECT_SLEEP_TIME=1e3,he.CONTROL_HIDE_TIME=3e3,he.DBCLICK_TIME=300,he.DBCLICK_FULLSCREEN=!0,he.MOBILE_DBCLICK_PLAY=!0,he.MOBILE_CLICK_PLAY=!1,he.AUTO_ORIENTATION_TIME=200,he.INFO_LOOP_TIME=1e3,he.FAST_FORWARD_VALUE=3,he.FAST_FORWARD_TIME=1e3,he.TOUCH_MOVE_RATIO=.5,he.VOLUME_STEP=.1,he.SEEK_STEP=5,he.PLAYBACK_RATE=[.5,.75,1,1.25,1.5,2],he.ASPECT_RATIO=["default","4:3","16:9"],he.FLIP=["normal","horizontal","vertical"],he.FULLSCREEN_WEB_IN_BODY=!0,he.LOG_VERSION=!0,he.USE_RAF=!1,he.REMOVE_SRC_WHEN_DESTROY=!0,h&&(window.Artplayer=he,M("artplayer-style",ne),setTimeout(()=>{he.LOG_VERSION&&console.log(`%c ArtPlayer %c ${he.version} %c https://artplayer.org`,"color: #fff; background: #5f5f5f","color: #fff; background: #4bc729","")},100)),he}); +!function(t,e){"object"===typeof exports&&"undefined"!==typeof module?module.exports=e():"function"==typeof define&&define.amd?(t.Artplayer=e(),define(function(){return t.Artplayer})):(t="undefined"!==typeof globalThis?globalThis:t||self).Artplayer=e()}(this,function(){"use strict";function t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var e,r={exports:{}};var o=(e||(e=1,r.exports=function(){function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}var e=Object.prototype.toString,r=function(r){if(void 0===r)return"undefined";if(null===r)return"null";var a=t(r);if("boolean"===a)return"boolean";if("string"===a)return"string";if("number"===a)return"number";if("symbol"===a)return"symbol";if("function"===a)return"GeneratorFunction"===o(r)?"generatorfunction":"function";if(function(t){return Array.isArray?Array.isArray(t):t instanceof Array}(r))return"array";if(function(t){return!(!t.constructor||"function"!=typeof t.constructor.isBuffer)&&t.constructor.isBuffer(t)}(r))return"buffer";if(function(t){try{if("number"==typeof t.length&&"function"==typeof t.callee)return!0}catch(e){if(-1!==e.message.indexOf("callee"))return!0}return!1}(r))return"arguments";if(function(t){return t instanceof Date||"function"==typeof t.toDateString&&"function"==typeof t.getDate&&"function"==typeof t.setDate}(r))return"date";if(function(t){return t instanceof Error||"string"==typeof t.message&&t.constructor&&"number"==typeof t.constructor.stackTraceLimit}(r))return"error";if(function(t){return t instanceof RegExp||"string"==typeof t.flags&&"boolean"==typeof t.ignoreCase&&"boolean"==typeof t.multiline&&"boolean"==typeof t.global}(r))return"regexp";switch(o(r)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(function(t){return"function"==typeof t.throw&&"function"==typeof t.return&&"function"==typeof t.next}(r))return"generator";switch(a=e.call(r)){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return a.slice(8,-1).toLowerCase().replace(/\s/g,"")};function o(t){return t.constructor?t.constructor.name:null}function a(t,e){var o=2=1,p=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(s)||d,h="undefined"!==typeof window&&"undefined"!==typeof document;function u(t,e=document){return e.querySelector(t)}function m(t,e=document){return Array.from(e.querySelectorAll(t))}function f(t,e){return t.classList.add(e)}function g(t,e){return t.classList.remove(e)}function v(t,e){return t.classList.contains(e)}function y(t,e){return e instanceof Element?t.appendChild(e):t.insertAdjacentHTML("beforeend",String(e)),t.lastElementChild||t.lastChild}function b(t){return t.parentNode.removeChild(t)}function w(t,e,r){return t.style[e]=r,t}function x(t,e){for(const r in e)w(t,r,e[r]);return t}function k(t){return Array.from(t.parentElement.children).filter(e=>e!==t)}function $(t,e){k(t).forEach(t=>g(t,e)),f(t,e)}function E(t,e,r="top"){p||(t.setAttribute("aria-label",e),f(t,"hint--rounded"),f(t,`hint--${r}`))}function T(t,e=0){const r=t.getBoundingClientRect(),o=window.innerHeight||document.documentElement.clientHeight,a=window.innerWidth||document.documentElement.clientWidth,n=r.top-e<=o&&r.top+r.height+e>=0,i=r.left-e<=a+e&&r.left+r.width+e>=0;return n&&i}function C(t,e){return R(t).includes(e)}function z(t,e){return e.parentNode.replaceChild(t,e),t}function L(t){return document.createElement(t)}function S(t="",e=""){const r=L("i");return f(r,"art-icon"),f(r,`art-icon-${t}`),y(r,e),r}function M(t,e){let r=document.getElementById(t);r||(r=document.createElement("style"),r.id=t,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{document.head.appendChild(r)}):(document.head||document.documentElement).appendChild(r)),r.textContent=e}function A(){const t=document.createElement("div");return t.style.display="flex","flex"===t.style.display}function P(t){return t.getBoundingClientRect()}function I(t,e){return new Promise((r,o)=>{const a=new Image;a.onload=function(){if(e&&1!==e){const n=document.createElement("canvas"),i=n.getContext("2d");n.width=a.width*e,n.height=a.height*e,i.drawImage(a,0,0,n.width,n.height),n.toBlob(e=>{const a=URL.createObjectURL(e),n=new Image;n.onload=function(){r(n)},n.onerror=function(){URL.revokeObjectURL(a),o(new Error(`Image load failed: ${t}`))},n.src=a})}else r(a)},a.onerror=function(){o(new Error(`Image load failed: ${t}`))},a.src=t})}function R(t){if(t.composedPath)return t.composedPath();const e=[];let r=t.target;for(;r;)e.push(r),r=r.parentNode;return e.includes(window)||void 0===window||e.push(window),e}function O(){const t=document.createElement("div");t.style.cssText="position:fixed;top:env(safe-area-inset-top,0px);right:env(safe-area-inset-right,0px);bottom:env(safe-area-inset-bottom,0px);left:env(safe-area-inset-left,0px);pointer-events:none;visibility:hidden;",document.body.appendChild(t);const e=getComputedStyle(t),r={top:Number.parseFloat(e.top)||0,right:Number.parseFloat(e.right)||0,bottom:Number.parseFloat(e.bottom)||0,left:Number.parseFloat(e.left)||0};return t.remove(),r}class _ extends Error{constructor(t,e){super(t),"captureStackTrace"in Error&&"function"===typeof Error.captureStackTrace&&Error.captureStackTrace(this,e||this.constructor),this.name="ArtPlayerError"}}function V(t,e){if(!t)throw new _(e);return t}function Y(t){const e=t;return e&&"function"===typeof e.catch?e.catch(()=>{}):t}function N(t){const e=t.search(/[?#]/),r=(e<0?t:t.slice(0,e)).trim().toLowerCase();return r.slice(r.lastIndexOf(".")+1)}function D(t,e){const r=document.createElement("a");r.style.display="none",r.href=t,r.download=e,document.body.appendChild(r);try{r.click()}finally{r.remove()}}function F(t,e,r){return Math.max(Math.min(t,Math.max(e,r)),Math.min(e,r))}function H(t){return t.charAt(0).toUpperCase()+t.slice(1)}function B(t){if(!t)return"00:00";const e=Math.floor(t/3600),r=Math.floor((t-3600*e)/60),o=Math.floor(t-3600*e-60*r);return(e>0?[e,r,o]:[r,o]).map(t=>t<10?`0${t}`:String(t)).join(":")}const W={"&":"&","<":"<",">":">","'":"'",'"':"""},j={"&":"&","<":"<",">":">","'":"'",""":'"'},U=/(&|<|>|'|")/g;function q(t){return t.replace(/[&<>'"]/g,t=>W[t]||t)}const X=Object.defineProperty,{hasOwnProperty:G}=Object.prototype;function K(t,e){return G.call(t,e)}function Z(t,e){return Object.getOwnPropertyDescriptor(t,e)}function J(...t){const e=t=>!!t&&"object"===typeof t&&!Array.isArray(t);return t.reduce((t,r)=>(Object.keys(r).forEach(o=>{const a=t[o],n=r[o];let i;i=Array.isArray(a)&&Array.isArray(n)?a.concat(...n):e(a)&&e(n)?J(a,n):n,X(t,o,{value:i,enumerable:!0,configurable:!0,writable:!0})}),t),{})}function Q(t){return"WEBVTT \r\n\r\n".concat((e=t,e.replace(/(\d\d:\d\d:\d\d)[,.](\d+)/g,(t,e,r)=>{let o=r.slice(0,3);return 1===r.length&&(o=`${r}00`),2===r.length&&(o=`${r}0`),`${e},${o}`})).replace(/\{\\([ibu])\}/g,"").replace(/\{\\([ibu])1\}/g,"<$1>").replace(/\{([ibu])\}/g,"<$1>").replace(/\{\/([ibu])\}/g,"").replace(/(\d\d:\d\d:\d\d),(\d\d\d)/g,"$1.$2").replace(/\{[\s\S]*?\}/g,"").concat("\r\n\r\n"));var e}function tt(t){return URL.createObjectURL(new Blob([t],{type:"text/vtt"}))}function et(t){const e=new RegExp("Dialogue:\\s\\d,(\\d+:\\d\\d:\\d\\d.\\d\\d),(\\d+:\\d\\d:\\d\\d.\\d\\d),([^,]*),([^,]*),(?:[^,]*,){4}([\\s\\S]*)$","i");function r(t=""){return t.split(/[:.]/).map((t,e,r)=>{if(e===r.length-1){if(1===t.length)return`.${t}00`;if(2===t.length)return`.${t}0`}else if(1===t.length)return(0===e?"0":":0")+t;return 0===e?t:e===r.length-1?`.${t}`:`:${t}`}).join("")}return`WEBVTT\n\n${t.split(/\r?\n/).map(t=>{const o=t.match(e);if(!o)return null;const[,a="",n="",,,i=""]=o;return{start:r(a.trim()),end:r(n.trim()),text:i.replace(/\{[\s\S]*?\}/g,"").replace(/(\\N)/g,"\n").trim().split(/\r?\n/).map(t=>t.trim()).join("\n")}}).filter(t=>t).map((t,e)=>t?`${e+1}\n${t.start} --\x3e ${t.end}\n${t.text}`:"").filter(t=>t.trim()).join("\n\n")}`}function rt(t,e){let r=!1;return function(...o){r||(t.apply(this,o),r=!0,setTimeout(()=>{r=!1},e))}}const ot=Object.freeze(Object.defineProperty({__proto__:null,ArtPlayerError:_,addClass:f,append:y,assToVtt:et,capitalize:H,clamp:F,createElement:L,debounce:function(t,e){let r;return function(...o){clearTimeout(r),r=setTimeout(()=>(r=void 0,t.apply(this,o)),e)}},def:X,download:D,errorHandle:V,escape:q,get:Z,getComposedPath:R,getExt:N,getIcon:S,getRect:P,getSafeAreaInsets:O,getStyle:function(t,e,r=!0){const o=window.getComputedStyle(t,null).getPropertyValue(e);return r?Number.parseFloat(o):o},has:K,hasClass:v,includeFromEvent:C,inverseClass:$,isBrowser:h,isIOS:c,isIOS13:d,isInViewport:T,isMobile:p,isSafari:l,loadImg:I,mergeDeep:J,query:u,queryAll:m,remove:b,removeClass:g,replaceElement:z,secondToTime:B,setStyle:w,setStyleText:M,setStyles:x,siblings:k,silencePromise:Y,sleep:function(t=0){return new Promise(e=>setTimeout(e,t))},srtToVtt:Q,supportsFlex:A,throttle:rt,tooltip:E,unescape:function(t){return t.replace(U,t=>j[t]||t)},userAgent:s,vttToBlob:tt},Symbol.toStringTag,{value:"Module"})),at="array",nt="boolean",it="string",st="number",lt="object",ct="function";function dt(t,e,r){return V(e===it||e===st||t instanceof Element,`${r.join(".")} require '${it}' or 'Element' type`)}const pt={html:dt,disable:`?${nt}`,name:`?${it}`,index:`?${st}`,style:`?${lt}`,click:`?${ct}`,mounted:`?${ct}`,tooltip:`?${it}|${st}`,width:`?${st}`,selector:`?${at}`,onSelect:`?${ct}`,switch:`?${nt}`,onSwitch:`?${ct}`,range:`?${at}`,onRange:`?${ct}`,onChange:`?${ct}`},ht={id:it,container:dt,url:it,poster:it,type:it,theme:it,lang:it,volume:st,isLive:nt,muted:nt,autoplay:nt,autoSize:nt,autoMini:nt,loop:nt,flip:nt,playbackRate:nt,aspectRatio:nt,screenshot:nt,setting:nt,hotkey:nt,pip:nt,mutex:nt,backdrop:nt,fullscreen:nt,fullscreenWeb:nt,subtitleOffset:nt,miniProgressBar:nt,useSSR:nt,playsInline:nt,lock:nt,gesture:nt,fastForward:nt,autoPlayback:nt,autoOrientation:nt,airplay:nt,proxy:`?${ct}`,plugins:[ct],layers:[pt],contextmenu:[pt],settings:[pt],controls:[{...pt,position:(t,e,r)=>{const o=["top","left","right"];return V("string"===typeof t&&o.includes(t),`${r.join(".")} only accept ${o.toString()} as parameters`)}}],quality:[{default:`?${nt}`,html:it,url:it}],highlight:[{time:st,text:it}],thumbnails:{url:it,number:st,column:st,width:st,height:st,scale:st},subtitle:{url:it,name:it,type:it,style:lt,escape:nt,encoding:it,onVttLoad:ct},moreVideoAttr:lt,i18n:lt,icons:lt,cssVar:lt,customType:lt};class ut{constructor(t){this.id=0,this.art=t,this.cache=new Map,this.add=this.add.bind(this),this.remove=this.remove.bind(this),this.update=this.update.bind(this)}get show(){return v(this.art.template.$player,`art-${this.name}-show`)}set show(t){const{$player:e}=this.art.template,r=`art-${this.name}-show`;t?f(e,r):g(e,r),this.art.emit(this.name,t)}toggle(){this.show=!this.show}add(t){const e="function"===typeof t?t(this.art):t;if(e.html=e.html||"",a(e,pt),!this.$parent||!this.name||e.disable)return;const r=e.name||`${this.name}${this.id}`;V(!this.cache.has(r),`Can't add an existing [${r}] to the [${this.name}]`),this.id+=1;const o=L("div");f(o,`art-${this.name}`),f(o,`art-${this.name}-${r}`);const n=Array.from(this.$parent.children);o.dataset.index=e.index||this.id;const i=n.find(t=>Number(t.dataset.index)>=Number(o.dataset.index));i?i.insertAdjacentElement("beforebegin",o):y(this.$parent,o),e.html&&y(o,e.html),e.style&&x(o,e.style),e.tooltip&&E(o,e.tooltip);const s=[];if(e.click){const t=this.art.events.proxy(o,"click",t=>{t.preventDefault(),e.click.call(this.art,this,t)});s.push(t)}return e.selector&&["left","right"].includes(e.position)&&this.selector(e,o,s),this[r]=o,this.cache.set(r,{$ref:o,events:s,option:e}),e.mounted&&e.mounted.call(this.art,o),o}remove(t){V(this.cache.has(t),`Can't find [${t}] from the [${this.name}]`);const e=this.cache.get(t);e.option.beforeUnmount&&e.option.beforeUnmount.call(this.art,e.$ref);for(const r of e.events)this.art.events.remove(r);this.cache.delete(t),delete this[t],b(e.$ref)}update(t){if(this.cache.has(t.name)){const e=this.cache.get(t.name);t=Object.assign(e.option,t),this.remove(t.name)}return this.add(t)}}class mt extends ut{constructor(t){super(t),this.name="contextmenu",this.$parent=t.template.$contextmenu,p||this.init()}init(){const{option:t,proxy:e,template:{$player:r,$contextmenu:o}}=this.art;t.playbackRate&&this.add(function(t){return e=>{const{i18n:r,constructor:{PLAYBACK_RATE:o}}=e,a=o.map(t=>`${1===t?r.get("Normal"):t.toFixed(1)}`).join("");return{...t,html:`${r.get("Play Speed")}: ${a}`,click:(t,r)=>{const{value:o}=r.target.dataset;o&&(e.playbackRate=Number(o),t.show=!1)},mounted:t=>{const r=u('[data-value="1"]',t);r&&$(r,"art-current"),e.on("video:ratechange",()=>{const r=m("span",t).find(t=>Number(t.dataset.value)===e.playbackRate);r&&$(r,"art-current")})}}}}({name:"playbackRate",index:10})),t.aspectRatio&&this.add(function(t){return e=>{const{i18n:r,constructor:{ASPECT_RATIO:o}}=e,a=o.map(t=>`${"default"===t?r.get("Default"):t}`).join("");return{...t,html:`${r.get("Aspect Ratio")}: ${a}`,click:(t,r)=>{const{value:o}=r.target.dataset;o&&(e.aspectRatio=o,t.show=!1)},mounted:t=>{const r=u('[data-value="default"]',t);r&&$(r,"art-current"),e.on("aspectRatio",e=>{const r=m("span",t).find(t=>t.dataset.value===e);r&&$(r,"art-current")})}}}}({name:"aspectRatio",index:20})),t.flip&&this.add(function(t){return e=>{const{i18n:r,constructor:{FLIP:o}}=e,a=o.map(t=>`${r.get(H(t))}`).join("");return{...t,html:`${r.get("Video Flip")}: ${a}`,click:(t,r)=>{const{value:o}=r.target.dataset;o&&(e.flip=o.toLowerCase(),t.show=!1)},mounted:t=>{const r=u('[data-value="normal"]',t);r&&$(r,"art-current"),e.on("flip",e=>{const r=m("span",t).find(t=>t.dataset.value===e);r&&$(r,"art-current")})}}}}({name:"flip",index:30})),this.add(function(t){return e=>({...t,html:e.i18n.get("Video Info"),click:t=>{e.info.show=!0,t.show=!1}})}({name:"info",index:40})),this.add(function(t){return{...t,html:`ArtPlayer ${n}`}}({name:"version",index:50})),this.add(function(t){return e=>({...t,html:e.i18n.get("Close"),click:t=>{t.show=!1}})}({name:"close",index:60}));for(let a=0;a{if(!this.art.constructor.CONTEXTMENU)return;t.preventDefault(),this.show=!0;const e=t.clientX,a=t.clientY,{height:n,width:i,left:s,top:l}=P(r),{height:c,width:d}=P(o);let p=e-s,h=a-l;e+d>s+i&&(p=i-d),a+c>l+n&&(h=n-c),x(o,{top:`${h}px`,left:`${p}px`})}),e(r,"click",t=>{C(t,o)||(this.show=!1)}),this.art.on("blur",()=>{this.show=!1})}}class ft extends Error{constructor(t){super("Failed to release ArtPlayer resources"),this.errors=t,this.name="ResourceCleanupError"}}class gt{constructor(){this.cleanups=new Set,this.disposed=!1}get closed(){return this.disposed}add(t){let e=!0;const r=()=>{e&&(e=!1,this.cleanups.delete(r),t())};return this.closed?r():this.cleanups.add(r),r}child(){const t=new gt,e=this.add(()=>{t.dispose()});return t.add(()=>{e()}),t}dispose(){if(this.closed)return;this.disposed=!0;const t=[];for(const r of Array.from(this.cleanups).reverse())try{r()}catch(e){e instanceof ft?t.push(...e.errors):t.push(e)}if(t.length)throw new ft(t)}}const vt=new WeakMap,yt=new WeakMap;function bt(t){const e=vt.get(t);if(!e)throw new Error("ArtPlayer lifecycle has not been initialized");return e}function wt(t){return bt(t).scope}function xt(t){const e=bt(t);return e.destroying||e.scope.closed}function kt(t,e,r,o,a=!1){const n=bt(t);if(n.destroying||n.scope.closed)return;n.destroying=!0;const i=[],s=t=>{try{t()}catch(e){i.push(...e instanceof ft?e.errors:[e])}};o&&t.template?.$video&&s(()=>t.reset()),s(()=>n.scope.dispose()),s(()=>t.template?.destroy(r));const l=e.indexOf(t);-1!==l&&e.splice(l,1),t.isDestroy=!0,a||(n.releaseContainer?.(),n.releaseContainer=void 0),s(()=>t.emit("destroy")),a&&n.rollback&&s(n.rollback),n.rollback=void 0,n.releaseContainer?.(),n.releaseContainer=void 0;for(const c of i.slice(1))console.warn("Additional ArtPlayer cleanup failure:",c);if(i.length)throw i[0]}function $t(t,e,r){if(t.closed)return()=>{};let o=!0,a=()=>{};const n=setTimeout(()=>{o&&(a(),t.closed||e())},r);return a=t.add(()=>{o=!1,clearTimeout(n)}),a}function Et(t,e=0){return t.closed?Promise.resolve(!1):new Promise(r=>{let o=!1,a=()=>{};const n=setTimeout(()=>{o=!0,a(),r(!0)},e);a=t.add(()=>{clearTimeout(n),o||r(!1)})})}function Tt(t,e){const{$progress:r}=t.template,{left:o}=P(r),a=F((p?e.touches[0].clientX:e.clientX)-o,0,r.clientWidth),n=a/r.clientWidth*t.duration;return{second:n,time:B(n),width:a,percentage:F(a/r.clientWidth,0,1)}}function Ct(t,e){if(t.isRotate){const r=(e.touches[0].clientY-t.top)/t.height,o=r*t.duration;t.emit("setBar","played",r,e),t.seek=o}else{const{second:r,percentage:o}=Tt(t,e);t.emit("setBar","played",o,e),t.seek=r}}function zt(t){return e=>{const{icons:r,option:o,proxy:a}=e,{$player:n,$progress:i}=e.template;return{...t,html:'\n
\n
\n
\n
\n
\n
\n
00:00
\n
\n ',mounted:t=>{let s=null,l=!1;const c=u(".art-progress-hover",t),d=u(".art-progress-loaded",t),h=u(".art-progress-played",t),m=u(".art-progress-highlight",t),v=u(".art-progress-indicator",t),b=u(".art-progress-tip",t);function x(r,o){const{width:a,time:n}=o||Tt(e,r);b.textContent=n||"00:00";const i=b.clientWidth;a<=i/2?w(b,"left",0):a>t.clientWidth-i/2?w(b,"left",t.clientWidth-i+"px"):w(b,"left",a-i/2+"px")}r.indicator?y(v,r.indicator):w(v,"backgroundColor","var(--art-theme)"),e.on("setBar",function(r,o,a){const i="played"===r&&a&&p;if("loaded"===r&&w(d,"width",100*o+"%"),"hover"===r&&(w(c,"width",100*o+"%"),C(a,m)?function(r){const{width:o}=Tt(e,r),{text:a}=r.target.dataset;b.textContent=a;const n=b.clientWidth;o<=n/2?w(b,"left",0):o>t.clientWidth-n/2?w(b,"left",t.clientWidth-n+"px"):w(b,"left",o-n/2+"px")}(a):x(a),0===o?g(n,"art-progress-hover"):f(n,"art-progress-hover")),"played"===r&&(w(h,"width",100*o+"%"),w(v,"left",100*o+"%")),i){f(n,"art-progress-hover");x(a,{width:t.clientWidth*o,time:B(o*e.duration)}),clearTimeout(s),s=setTimeout(()=>{g(n,"art-progress-hover")},500)}}),e.on("video:loadedmetadata",function(){m.textContent="";for(let t=0;t`;y(m,n)}}),e.constructor.USE_RAF?e.on("raf",()=>{e.emit("setBar","played",e.played),e.emit("setBar","loaded",e.loaded)}):(e.on("video:timeupdate",()=>{e.emit("setBar","played",e.played)}),e.on("video:progress",()=>{e.emit("setBar","loaded",e.loaded)}),e.on("video:ended",()=>{e.emit("setBar","played",1)})),e.emit("setBar","loaded",e.loaded||0),p||(a(i,"click",t=>{t.target!==v&&Ct(e,t)}),a(i,"mousemove",t=>{const{percentage:r}=Tt(e,t);e.emit("setBar","hover",r,t)}),a(i,"mouseleave",t=>{e.emit("setBar","hover",0,t)}),a(i,"mousedown",t=>{l=0===t.button}),e.on("document:mousemove",t=>{if(l){const{second:r,percentage:o}=Tt(e,t);e.emit("setBar","played",o,t),e.seek=r}}),e.on("document:mouseup",()=>{l&&(l=!1)}))}}}}class Lt extends ut{constructor(t){super(t),this.isHover=!1,this.name="control",this.timer=Date.now();const{constructor:e}=t,{$player:r,$bottom:o}=this.art.template;t.on("mousemove",()=>{p||(this.show=!0)}),t.on("click",()=>{p?this.toggle():this.show=!0}),t.on("document:mousemove",t=>{this.isHover=C(t,o)}),t.on("video:timeupdate",()=>{!t.setting.show&&!this.isHover&&!t.isInput&&t.playing&&this.show&&Date.now()-this.timer>=e.CONTROL_HIDE_TIME&&(this.show=!1)}),t.on("control",t=>{t?(g(r,"art-hide-cursor"),f(r,"art-hover"),this.timer=Date.now()):(f(r,"art-hide-cursor"),g(r,"art-hover"))}),this.init()}init(){const{option:t}=this.art;t.isLive||this.add(zt({name:"progress",position:"top",index:10})),this.add({name:"thumbnails",position:"top",index:20}),this.add(function(t){return e=>({...t,mounted:t=>{const{proxy:r,icons:o,i18n:a}=e,n=y(t,o.play),i=y(t,o.pause);function s(){w(n,"display","flex"),w(i,"display","none")}function l(){w(n,"display","none"),w(i,"display","flex")}E(n,a.get("Play")),E(i,a.get("Pause")),r(n,"click",()=>{Y(e.play())}),r(i,"click",()=>{e.pause()}),e.playing?l():s(),e.on("video:playing",()=>{l()}),e.on("video:pause",()=>{s()})}})}({name:"playAndPause",position:"left",index:10})),this.add(function(t){return e=>({...t,mounted:t=>{const{proxy:r,icons:o}=e,a=y(t,o.volume),n=y(t,o.volumeClose),i=y(t,'
'),s=y(i,'
'),l=y(s,'
'),c=y(s,'
'),d=y(c,'
'),h=y(d,'
'),u=y(c,'
');function m(t){const{top:e,height:r}=P(c);return 1-(t.clientY-e)/r}function f(){if(e.muted||0===e.volume)w(a,"display","none"),w(n,"display","flex"),w(u,"top","100%"),w(h,"top","100%"),l.textContent=0;else{const t=100*e.volume;w(a,"display","flex"),w(n,"display","none"),w(u,"top",100-t+"%"),w(h,"top",100-t+"%"),l.textContent=Math.floor(t)}}if(f(),e.on("video:volumechange",f),r(a,"click",()=>{e.muted=!0}),r(n,"click",()=>{e.muted=!1}),p)w(i,"display","none");else{let t=!1;r(c,"mousedown",r=>{t=0===r.button,e.volume=m(r)}),e.on("document:mousemove",r=>{t&&(e.muted=!1,e.volume=m(r))}),e.on("document:mouseup",()=>{t&&(t=!1)})}}})}({name:"volume",position:"left",index:20})),t.isLive||this.add(function(t){return e=>({...t,style:p?{fontSize:"12px",padding:"0 5px"}:{cursor:"auto",padding:"0 10px"},mounted:t=>{function r(){const r=`${B(e.currentTime)} / ${B(e.duration)}`;r!==t.textContent&&(t.textContent=r)}r();const o=["video:loadedmetadata","video:timeupdate","video:progress"];for(let a=0;a{e&&!wt(this.art).closed&&(this.art.quality=t.quality)}),t.screenshot&&!p&&this.add(function(t){return e=>({...t,tooltip:e.i18n.get("Screenshot"),mounted:t=>{const{proxy:r,icons:o}=e;y(t,o.screenshot),r(t,"click",()=>{e.screenshot()})}})}({name:"screenshot",position:"right",index:20})),t.setting&&this.add(function(t){return e=>({...t,tooltip:e.i18n.get("Show Setting"),mounted:t=>{const{proxy:r,icons:o,i18n:a}=e;y(t,o.setting),r(t,"click",()=>{e.setting.toggle(),e.setting.resize()}),e.on("setting",e=>{E(t,a.get(e?"Hide Setting":"Show Setting"))})}})}({name:"setting",position:"right",index:30})),t.pip&&this.add(function(t){return e=>({...t,tooltip:e.i18n.get("PIP Mode"),mounted:t=>{const{proxy:r,icons:o,i18n:a}=e;y(t,o.pip),r(t,"click",()=>{e.pip=!e.pip}),e.on("pip",e=>{E(t,a.get(e?"Exit PIP Mode":"PIP Mode"))})}})}({name:"pip",position:"right",index:40})),t.airplay&&window.WebKitPlaybackTargetAvailabilityEvent&&this.add(function(t){return e=>({...t,tooltip:e.i18n.get("AirPlay"),mounted:t=>{const{proxy:r,icons:o}=e;y(t,o.airplay),r(t,"click",()=>e.airplay())}})}({name:"airplay",position:"right",index:50})),t.fullscreenWeb&&this.add(function(t){return e=>({...t,tooltip:e.i18n.get("Web Fullscreen"),mounted:t=>{const{proxy:r,icons:o,i18n:a}=e,n=y(t,o.fullscreenWebOn),i=y(t,o.fullscreenWebOff);w(i,"display","none"),r(t,"click",()=>{e.fullscreenWeb=!e.fullscreenWeb}),e.on("fullscreenWeb",e=>{e?(E(t,a.get("Exit Web Fullscreen")),w(n,"display","none"),w(i,"display","inline-flex")):(E(t,a.get("Web Fullscreen")),w(n,"display","inline-flex"),w(i,"display","none"))})}})}({name:"fullscreenWeb",position:"right",index:60})),t.fullscreen&&this.add(function(t){return e=>({...t,tooltip:e.i18n.get("Fullscreen"),mounted:t=>{const{proxy:r,icons:o,i18n:a}=e,n=y(t,o.fullscreenOn),i=y(t,o.fullscreenOff);w(i,"display","none"),r(t,"click",()=>{e.fullscreen=!e.fullscreen}),e.on("fullscreen",e=>{e?(E(t,a.get("Exit Fullscreen")),w(n,"display","none"),w(i,"display","inline-flex")):(E(t,a.get("Fullscreen")),w(n,"display","inline-flex"),w(i,"display","none"))})}})}({name:"fullscreen",position:"right",index:70}));for(let e=0;et.selector}),X(e,"$control_item",{get:()=>r}),X(e,"$control_value",{get:()=>a})}const i=o(n,"click",async e=>{const r=R(e),o=t.selector.find(t=>t.$control_item===r.find(e=>t.$control_item===e));this.check(o),t.onSelect&&(a.innerHTML=await t.onSelect.call(this.art,o,o.$control_item,e))});r.push(i)}}function St(t,e,r,o){const a=e-o,n=r-t;let i=0;if(Math.abs(n)<2&&Math.abs(a)<2)return i;const s=function(t,e){return 180*Math.atan2(e,t)/Math.PI}(n,a);return s>=-45&&s<45?i=4:s>=45&&s<135?i=1:s>=-135&&s<-45?i=2:(s>=135&&s<=180||s>=-180&&s<-135)&&(i=3),i}function Mt(t){if(t.constructor.USE_RAF){const e=wt(t);let r=()=>{};!function o(){t.playing&&t.emit("raf"),t.isDestroy||(r=function(t,e){if(t.closed)return()=>{};let r=!0,o=()=>{};const a=requestAnimationFrame(a=>{r&&(o(),t.closed||e(a))});return o=t.add(()=>{r=!1,cancelAnimationFrame(a)}),o}(e,o))}(),t.on("destroy",()=>{r()})}}const At=new WeakMap;class Pt{constructor(t){this.destroyEvents=new Set;const e=wt(t);At.set(this,e),e.add(()=>this.destroy()),this.proxy=this.proxy.bind(this),this.hover=this.hover.bind(this),function(t,e){const{constructor:r,template:{$player:o,$video:a}}=t;function n(e){C(e,o)?(t.isInput="INPUT"===e.target.tagName,t.isFocus=!0,t.emit("focus",e)):(t.isInput=!1,t.isFocus=!1,t.emit("blur",e))}t.on("document:click",n),t.on("document:contextmenu",n);let i=[];e.proxy(a,"click",e=>{const o=Date.now();i.push(o);const{MOBILE_CLICK_PLAY:a,DBCLICK_TIME:n,MOBILE_DBCLICK_PLAY:s,DBCLICK_FULLSCREEN:l}=r,c=i.filter(t=>o-t<=n);switch(c.length){case 1:t.emit("click",e),p?!t.isLock&&a&&Y(t.toggle()):Y(t.toggle()),i=c;break;case 2:t.emit("dblclick",e),p?!t.isLock&&s&&Y(t.toggle()):l&&(t.fullscreen=!t.fullscreen),i=[];break;default:i=[]}})}(t,this),function(t,e){const{$player:r}=t.template;e.hover(r,e=>{f(r,"art-hover"),t.emit("hover",!0,e)},e=>{g(r,"art-hover"),t.emit("hover",!1,e)})}(t,this),function(t,e){const{$player:r}=t.template;e.proxy(r,"mousemove",e=>{t.emit("mousemove",e)})}(t,this),function(t,e){const{option:r,constructor:o}=t;t.on("resize",()=>{const{aspectRatio:e,notice:o}=t;"standard"===t.state&&r.autoSize&&t.autoSize(),t.aspectRatio=e,o.show=""});const a=wt(t);let n=()=>{};const i=()=>{n(),n=$t(a,()=>t.emit("resize"),o.RESIZE_TIME)};t.on("window:orientationchange",()=>i()),t.on("window:resize",()=>i()),screen&&screen.orientation&&screen.orientation.onchange&&e.proxy(screen.orientation,"change",()=>i())}(t,this),function(t,e){if(p&&!t.option.isLive){const{$video:r,$progress:o}=t.template;let a=null,n=!1,i=0,s=0,l=0;const c=e=>{if(1===e.touches.length&&!t.isLock){a===o&&Ct(t,e),n=!0;const{pageX:r,pageY:c}=e.touches[0];i=r,s=c,l=t.currentTime}},d=e=>{if(1===e.touches.length&&n&&t.duration){const{pageX:o,pageY:n}=e.touches[0],c=St(i,s,o,n),d=[3,4].includes(c),p=[1,2].includes(c);if(d&&!t.isRotate||p&&t.isRotate){const c=F((o-i)/t.width,-1,1),d=F((n-s)/t.height,-1,1),p=t.isRotate?d:c,h=a===r?t.constructor.TOUCH_MOVE_RATIO:1,u=F(l+t.duration*p*h,0,t.duration);t.seek=u,t.emit("setBar","played",F(u/t.duration,0,1),e),t.notice.show=`${B(u)} / ${B(t.duration)}`}}},p=()=>{n&&(i=0,s=0,l=0,n=!1,a=null)};t.option.gesture&&(e.proxy(r,"touchstart",t=>{a=r,c(t)}),e.proxy(r,"touchmove",d)),e.proxy(o,"touchstart",t=>{a=o,c(t)}),e.proxy(o,"touchmove",d),t.on("document:touchend",p)}}(t,this),function(t){const{option:e,constructor:r,template:{$container:o}}=t,a=rt(()=>{t.emit("view",T(o,r.SCROLL_GAP))},r.SCROLL_TIME);t.on("window:scroll",()=>a()),t.on("view",r=>{e.autoMini&&(t.mini=!r)})}(t),function(t,e){const r=["click","mouseup","keydown","touchend","touchmove","mousemove","pointerup","contextmenu","pointermove","visibilitychange","webkitfullscreenchange"],o=["resize","scroll","orientationchange"],a=[];function n(n={}){for(let t=0;t{const o=n.document||i.ownerDocument||document,s=e.proxy(o,r,e=>{t.emit(`document:${r}`,e)});a.push(s)}),o.forEach(r=>{const o=n.window||i.ownerDocument?.defaultView||window,s=e.proxy(o,r,e=>{t.emit(`window:${r}`,e)});a.push(s)})}n(),e.bindGlobalEvents=n}(t,this),Mt(t)}proxy(t,e,r,o={}){if(Array.isArray(e))return e.map(e=>this.proxy(t,e,r,o));if(At.get(this).closed)return()=>{};t.addEventListener(e,r,o);const a=()=>t.removeEventListener(e,r,o);return this.destroyEvents.add(a),a}hover(t,e,r){e&&this.proxy(t,"mouseenter",e),r&&this.proxy(t,"mouseleave",r)}remove(t){if(this.destroyEvents.has(t))try{t()}catch(e){console.warn("Failed to remove event listener:",e)}finally{this.destroyEvents.delete(t)}}destroy(){for(const e of this.destroyEvents)try{e()}catch(t){console.warn("Failed to destroy event listener:",t)}this.destroyEvents.clear()}}class It{constructor(t){this.art=t,this.keys={},p||this.init()}init(){const{constructor:t}=this.art;this.art.option.hotkey&&(this.add("Escape",()=>{this.art.fullscreenWeb&&(this.art.fullscreenWeb=!1)}),this.add("Space",()=>{Y(this.art.toggle())}),this.add("ArrowLeft",()=>{this.art.backward=t.SEEK_STEP}),this.add("ArrowUp",()=>{this.art.volume+=t.VOLUME_STEP}),this.add("ArrowRight",()=>{this.art.forward=t.SEEK_STEP}),this.add("ArrowDown",()=>{this.art.volume-=t.VOLUME_STEP})),this.art.on("document:keydown",t=>{if(this.art.isFocus){const e=document.activeElement.tagName.toUpperCase(),r=document.activeElement.getAttribute("contenteditable");if("INPUT"!==e&&"TEXTAREA"!==e&&""!==r&&"true"!==r&&!t.altKey&&!t.ctrlKey&&!t.metaKey&&!t.shiftKey){const e=this.keys[t.code];if(e){t.preventDefault();for(let r=0;r\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n',state:'\r\n\r\n\r\n',play:'\r\n \r\n',pause:'\r\n \r\n',check:'\r\n\r\n',volume:'\r\n \r\n \r\n',volumeClose:'\r\n \r\n \r\n',screenshot:'\r\n\t\r\n\r\n',setting:'\r\n \r\n \r\n',pip:'\r\n\r\n',arrowLeft:'\r\n \r\n',arrowRight:'\r\n \r\n',playbackRate:'',aspectRatio:'',config:'',lock:'\r\n\r\n\r\n\r\n\r\n',flip:'\r\n\r\n\r\n\r\n\r\n\r\n',unlock:'\r\n\r\n\r\n',fullscreenOff:'\r\n\r\n\r\n\r\n\r\n',fullscreenOn:'\r\n\r\n\r\n\r\n\r\n',fullscreenWebOff:'\r\n\r\n\r\n\r\n\r\n',fullscreenWebOn:'\r\n\r\n\r\n\r\n\r\n',switchOn:'\r\n\r\n\r\n \r\n',switchOff:'\r\n\r\n\r\n \r\n\r\n',error:'\r\n\r\n\r\n\r\n\r\n',close:'\r\n\r\n\r\n\r\n\r\n',airplay:'\r\n \r\n \r\n \r\n \r\n\r\n',...t.option.icons};for(const r in e)X(this,r,{get:()=>S(r,e[r])})}}class Vt extends ut{constructor(t){super(t),this.name="info",p||this.init()}init(){const{proxy:t,constructor:e,template:{$infoPanel:r,$infoClose:o,$video:a}}=this.art;t(o,"click",()=>{this.show=!1});let n=()=>{};const i=m("[data-video]",r)||[];this.art.on("destroy",()=>n());const s=wt(this.art);!function t(){for(let e=0;e{w(a,"display","none"),w(n,"display",null)}),o.proxy(e.$state,"click",()=>Y(t.play()))}}class Ft{constructor(t){this.art=t,this.timer=null,wt(t).add(()=>this.destroy()),t.on("destroy",()=>this.destroy())}destroy(){this.timer&&(clearTimeout(this.timer),this.timer=null)}set show(t){if(wt(this.art).closed)return;const{constructor:e,template:{$player:r,$noticeInner:o}}=this.art;t?(o.textContent=t instanceof Error?t.message.trim():t,f(r,"art-notice-show"),clearTimeout(this.timer),this.timer=setTimeout(()=>{o.textContent="",g(r,"art-notice-show")},e.NOTICE_TIME)):g(r,"art-notice-show")}get show(){const{template:{$player:t}}=this.art;return t.classList.contains("art-notice-show")}}const Ht=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],Bt=(()=>{if("undefined"===typeof document)return!1;const t=Ht[0],e={};for(const r of Ht){if(r[1]in document){for(const[o,a]of r.entries())e[t[o]]=a;return e}}return!1})(),Wt={change:Bt.fullscreenchange,error:Bt.fullscreenerror},jt={request:(t=document.documentElement,e)=>new Promise((r,o)=>{const a=()=>{jt.off("change",a),r()};jt.on("change",a);const n=t[Bt.requestFullscreen](e);n instanceof Promise&&n.then(a).catch(o)}),exit:()=>new Promise((t,e)=>{if(!jt.isFullscreen)return void t();const r=()=>{jt.off("change",r),t()};jt.on("change",r);const o=document[Bt.exitFullscreen]();o instanceof Promise&&o.then(r).catch(e)}),toggle:(t,e)=>jt.isFullscreen?jt.exit():jt.request(t,e),onchange(t){jt.on("change",t)},onerror(t){jt.on("error",t)},on(t,e){const r=Wt[t];r&&document.addEventListener(r,e,!1)},off(t,e){const r=Wt[t];r&&document.removeEventListener(r,e,!1)},raw:Bt};function Ut(t){const{i18n:e,notice:r,template:{$video:o,$player:a}}=t;t.once("video:loadedmetadata",()=>{var n;jt.isEnabled?(n=t,jt.on("change",()=>{n.emit("fullscreen",jt.isFullscreen),jt.isFullscreen?(n.state="fullscreen",f(a,"art-fullscreen")):g(a,"art-fullscreen"),n.emit("resize")}),jt.on("error",t=>{n.emit("fullscreenError",t)}),X(n,"fullscreen",{get:()=>jt.isFullscreen,async set(t){t?await jt.request(a):await jt.exit()}})):o.webkitSupportsFullscreen?(t=>{t.on("document:webkitfullscreenchange",()=>{t.emit("fullscreen",t.fullscreen),t.emit("resize")}),X(t,"fullscreen",{get:()=>document.fullscreenElement===o,set(e){e?(t.state="fullscreen",o.webkitEnterFullscreen()):o.webkitExitFullscreen()}})})(t):X(t,"fullscreen",{get:()=>!1,set(){r.show=e.get("Fullscreen Not Supported")}}),X(t,"fullscreen",Z(t,"fullscreen"))})}function qt(t){const{icons:e,proxy:r,storage:o,template:{$player:a,$video:n}}=t;let i=!1,s=0,l=0;function c(){const{$mini:e}=t.template;e&&(g(a,"art-mini"),w(e,"display","none"),a.prepend(n),t.emit("mini",!1))}function d(e,r){t.playing?(w(e,"display","none"),w(r,"display","flex")):(w(e,"display","flex"),w(r,"display","none"))}function p(){const{$mini:e}=t.template,r=P(e),a=window.innerHeight-r.height-50,n=window.innerWidth-r.width-50;o.set("top",a),o.set("left",n),w(e,"top",`${a}px`),w(e,"left",`${n}px`)}X(t,"mini",{get:()=>v(a,"art-mini"),set(h){if(h){t.state="mini",f(a,"art-mini");const h=function(){const{$mini:a}=t.template;if(a)return y(a,n),w(a,"display","flex");{const a=L("div");f(a,"art-mini-popup"),y(document.body,a),t.template.$mini=a,y(a,n);const p=y(a,'
');y(p,e.close),r(p,"click",c);const h=y(a,'
'),u=y(h,e.play),m=y(h,e.pause);return r(u,"click",()=>Y(t.play())),r(m,"click",()=>t.pause()),d(u,m),t.on("video:playing",()=>d(u,m)),t.on("video:pause",()=>d(u,m)),t.on("video:timeupdate",()=>d(u,m)),r(a,"mousedown",t=>{i=0===t.button,s=t.pageX,l=t.pageY}),t.on("document:mousemove",t=>{if(i){f(a,"art-mini-dragging");const e=t.pageX-s,r=t.pageY-l;w(a,"transform",`translate(${e}px, ${r}px)`)}}),t.on("document:mouseup",()=>{if(i){i=!1,g(a,"art-mini-dragging");const t=P(a);o.set("left",t.left),o.set("top",t.top),w(a,"left",`${t.left}px`),w(a,"top",`${t.top}px`),w(a,"transform",null)}}),a}}(),u=o.get("top"),m=o.get("left");"number"===typeof u&&"number"===typeof m?(w(h,"top",`${u}px`),w(h,"left",`${m}px`),T(h)||p()):p(),t.emit("mini",!0)}else c()}})}function Xt(t){const{i18n:e,notice:r,template:{$video:o}}=t;document.pictureInPictureEnabled?function(t){const{template:{$video:e},proxy:r,notice:o}=t;e.disablePictureInPicture=!1,X(t,"pip",{get:()=>document.pictureInPictureElement,set(r){r?(t.state="pip",e.requestPictureInPicture().catch(t=>{throw o.show=t,t})):document.exitPictureInPicture().catch(t=>{throw o.show=t,t})}}),r(e,"enterpictureinpicture",()=>{t.emit("pip",!0)}),r(e,"leavepictureinpicture",()=>{t.emit("pip",!1)})}(t):o.webkitSupportsPresentationMode?function(t){const{$video:e}=t.template;e.webkitSetPresentationMode("inline"),X(t,"pip",{get:()=>"picture-in-picture"===e.webkitPresentationMode,set(r){r?(t.state="pip",e.webkitSetPresentationMode("picture-in-picture"),t.emit("pip",!0)):(e.webkitSetPresentationMode("inline"),t.emit("pip",!1))}})}(t):X(t,"pip",{get:()=>!1,set(){r.show=e.get("PIP Not Supported")}})}Object.defineProperties(jt,{isFullscreen:{get:()=>Boolean(document[Bt.fullscreenElement])},element:{enumerable:!0,get:()=>document[Bt.fullscreenElement]},isEnabled:{enumerable:!0,get:()=>Boolean(document[Bt.fullscreenEnabled])}});const Gt=new WeakMap,Kt=new WeakMap;function Zt(t){const e=Gt.get(t),r=wt(t).child(),o={scope:r,assigned:!1,acceptingEvents:!1,active:()=>!xt(t)&&!r.closed&&Gt.get(t)===o};return Gt.set(t,o),r.add(()=>{Gt.get(t)===o&&Gt.delete(t),o.onAssigned=void 0,o.onError=void 0}),e?.scope.dispose(),o}function Jt(t){t.assigned=!0;const e=t.onAssigned;t.onAssigned=void 0,t.active()&&e?.()}function Qt(t,e){t.active()&&(t.onError?t.onError(e):console.warn("Failed to initialize ArtPlayer source:",e),t.scope.dispose())}function te(t){const{i18n:e,notice:r,option:o,constructor:{instances:a},template:{$video:n}}=t;X(t,"play",{async value(){const i=function(t){const e=Gt.get(t);return()=>Gt.get(t)===e&&(!e||e.active())}(t),s=await n.play();if(!i())return s;const l=e.get("Play");if(!i())return s;if(r.show=l,!i())return s;if(t.emit("play"),o.mutex)for(let e=0;e{t.closed||i||(a&&(i=!0,n()),o(e))};return e[a?"once":"on"](r,s),n=t.add(()=>{e.off(r,s)}),s}function re(t,e,r){return new Promise((o,a)=>{if(xt(t)||e===t.url)return void o();const n=Zt(t),i=n.scope.child();let s=!1;const l=(t=!1,e)=>{s||(s=!0,n.onError=void 0,n.onAssigned=void 0,i.dispose(),t?a(e):o(),t&&n.scope.dispose())};i.add(()=>{l()});const c=()=>!s&&n.active(),d=t=>l(!0,t);n.onError=d;try{const{playing:o,aspectRatio:a,playbackRate:s}=t;if(t.pause(),!c())return;const p=i.child(),h={"video:error":d,"video:loadedmetadata":()=>{if(c())try{t.currentTime=r}catch(e){d(e)}},"video:canplay":()=>{if(!c())return;p.dispose();(async()=>{if(t.playbackRate=s,c()&&(t.aspectRatio=a,c())){if(o)try{await t.play()}catch{}c()&&(t.notice.show="",l())}})().catch(d)}},u=i.child(),m=[],f=Object.keys(h);for(const e of f)ee(u,t,e,t=>{n.acceptingEvents&&m.push([e,t])},!1);if(function(t,e,r){Kt.set(t,e),e.acceptingEvents=!0;try{t.url=r}finally{Kt.get(t)===e&&(Kt.delete(t),Jt(e))}}(t,n,e),!c())return;if(t.notice.show="",!c())return;const g=()=>{if(u.dispose(),!e)return void l();const r={};for(const e of f)r[e]=ee(p,t,e,h[e]);for(const[t,e]of m){if(!c()||p.closed)break;r[t](e)}m.length=0};n.assigned?g():n.onAssigned=g}catch(p){d(p)}})}function oe(t){const{option:e,template:{$progress:r,$video:o}}=t;let a=null,n=!1,i=null;t.on("setBar",async(a,s,l)=>{const c=t.controls?.thumbnails,{url:d,scale:h}=e.thumbnails;if(!c||!d)return;if("hover"===a||"played"===a&&l&&p){if(i||n||(n=!0,i=await I(d,h),n=!1),!i)return;const a=r.clientWidth*s;a>0&&ar.clientWidth-h/2?w(n,"left",r.clientWidth-h+"px"):w(n,"left",a-h/2+"px")}(a)}}),X(t,"thumbnails",{get:()=>t.option.thumbnails,set(e){e.url&&!t.option.isLive&&(t.option.thumbnails=e,clearTimeout(a),a=null,n=!1,i=null)}})}function ae(t){const{option:e,template:{$video:r}}=t;X(t,"url",{get:()=>r.src,async set(o){if(xt(t))return;const a=function(t){const e=Kt.get(t);return Kt.delete(t),e||Zt(t)}(t);a.acceptingEvents=!1;try{if(!o)return void(await Et(a.scope)&&a.active()&&(t.loading.show=!0));const n=t.url,i=e.type||N(o),s=e.customType[i];if(i&&s){if(!(await Et(a.scope))||!a.active())return;t.loading.show=!0}if(!a.active())return;const l=a.scope.child();let c=!1,d=!1;ee(l,t,"video:canplay",()=>{c=!d}),ee(l,t,"video:error",()=>{d=!0});try{if(a.acceptingEvents=!0,i&&s){const e=s.call(t,r,o,t);Promise.resolve(e).catch(t=>Qt(a,t))}else{if(n&&URL.revokeObjectURL(n),!a.active())return;r.src=o}}finally{l.dispose()}if(!a.active())return;if(n!==t.url&&(t.option.url=o,a.active()&&t.isReady&&n)){const e=()=>{a.active()&&t.emit("restart",o)};c?e():d||ee(a.scope,t,"video:canplay",e)}}catch(n){Qt(a,n)}finally{Jt(a)}}})}class ne{constructor(t){ae(t),function(t){const{template:{$video:e}}=t;X(t,"attr",{value(t,r){if(void 0===r)return e[t];e[t]=r}})}(t),te(t),function(t){const{template:{$video:e},i18n:r,notice:o}=t;X(t,"pause",{value(){const a=e.pause();return o.show=r.get("Pause"),t.emit("pause"),a}})}(t),function(t){X(t,"toggle",{value:()=>t.playing?t.pause():t.play()})}(t),function(t){const{notice:e}=t;X(t,"seek",{set(r){t.currentTime=r,t.duration&&(e.show=`${B(t.currentTime)} / ${B(t.duration)}`),t.emit("seek",t.currentTime,r)}}),X(t,"forward",{set(e){t.seek=t.currentTime+e}}),X(t,"backward",{set(e){t.seek=t.currentTime-e}})}(t),function(t){const{template:{$video:e},i18n:r,notice:o,storage:a}=t;X(t,"volume",{get:()=>e.volume||0,set:t=>{e.volume=F(t,0,1),o.show=`${r.get("Volume")}: ${Number.parseInt(100*e.volume,10)}`,0!==e.volume&&a.set("volume",e.volume)}}),X(t,"muted",{get:()=>e.muted,set:r=>{e.muted=r,t.emit("muted",r)}})}(t),function(t){const{$video:e}=t.template;X(t,"currentTime",{get:()=>e.currentTime||0,set:r=>{r=Number.parseFloat(r),Number.isNaN(r)||(e.currentTime=F(r,0,t.duration))}})}(t),function(t){X(t,"duration",{get:()=>{const{duration:e}=t.template.$video;return e===1/0?0:e||0}})}(t),function(t){const e=e=>re(t,e,0);X(t,"switchQuality",{value:e=>re(t,e,t.currentTime)}),X(t,"switchUrl",{value:e}),X(t,"switch",{set:e})}(t),function(t){const{template:{$video:e},i18n:r,notice:o}=t;X(t,"playbackRate",{get:()=>e.playbackRate,set(a){if(a){if(a===e.playbackRate)return;e.playbackRate=a,o.show=`${r.get("Rate")}: ${1===a?r.get("Normal"):`${a}x`}`}else t.playbackRate=1}})}(t),function(t){const{i18n:e,notice:r,template:{$video:o,$player:a}}=t;X(t,"aspectRatio",{get:()=>a.dataset.aspectRatio||"default",set(n){if(n||(n="default"),"default"===n)w(o,"width",null),w(o,"height",null),w(o,"margin",null),delete a.dataset.aspectRatio;else{const t=n.split(":").map(Number),{clientWidth:e,clientHeight:r}=a,i=e/r,s=t[0]/t[1];i>s?(w(o,"width",s*r+"px"),w(o,"height","100%"),w(o,"margin","0 auto")):(w(o,"width","100%"),w(o,"height",e/s+"px"),w(o,"margin","auto 0")),a.dataset.aspectRatio=n}r.show=`${e.get("Aspect Ratio")}: ${"default"===n?e.get("Default"):n}`,t.emit("aspectRatio",n)}})}(t),function(t){const{notice:e,template:{$video:r}}=t,o=L("canvas");X(t,"getDataURL",{value:()=>new Promise((t,a)=>{try{o.width=r.videoWidth,o.height=r.videoHeight,o.getContext("2d").drawImage(r,0,0),t(o.toDataURL("image/png"))}catch(n){e.show=n,a(n)}})}),X(t,"getBlobUrl",{value:()=>new Promise((t,a)=>{try{o.width=r.videoWidth,o.height=r.videoHeight,o.getContext("2d").drawImage(r,0,0),o.toBlob(e=>{t(URL.createObjectURL(e))})}catch(n){e.show=n,a(n)}})}),X(t,"screenshot",{value:async e=>{const o=await t.getDataURL();return D(o,`${e||`artplayer_${B(r.currentTime)}`}.png`),t.emit("screenshot",o),o}})}(t),Ut(t),function(t){const{constructor:e,template:{$container:r,$player:o}}=t;let a="";X(t,"fullscreenWeb",{get:()=>v(o,"art-fullscreen-web"),set(n){n?(a=o.style.cssText,e.FULLSCREEN_WEB_IN_BODY&&y(document.body,o),t.state="fullscreenWeb",w(o,"width","100%"),w(o,"height","100%"),f(o,"art-fullscreen-web"),t.emit("fullscreenWeb",!0)):(e.FULLSCREEN_WEB_IN_BODY&&y(r,o),a&&(o.style.cssText=a,a=""),g(o,"art-fullscreen-web"),t.emit("fullscreenWeb",!1)),t.emit("resize")}})}(t),Xt(t),function(t){const{$video:e}=t.template;X(t,"loaded",{get:()=>t.loadedTime/e.duration}),X(t,"loadedTime",{get:()=>e.buffered.length?e.buffered.end(e.buffered.length-1):0})}(t),function(t){X(t,"played",{get:()=>t.currentTime/t.duration})}(t),function(t){const{$video:e}=t.template;X(t,"playing",{get:()=>"boolean"===typeof e.playing?e.playing:!!(e.currentTime>0&&!e.paused&&!e.ended&&e.readyState>2)})}(t),function(t){const{$container:e,$player:r,$video:o}=t.template;X(t,"autoSize",{value(){const{videoWidth:a,videoHeight:n}=o,{width:i,height:s}=P(e),l=a/n;if(i/s>l)w(r,"width",s*l/i*100+"%"),w(r,"height","100%");else{const t=i/l/s*100;w(r,"width","100%"),w(r,"height",`${t}%`)}t.emit("autoSize",{width:t.width,height:t.height})}})}(t),function(t){const e=t;X(t,"rect",{get:()=>P(t.template.$player)});const r=["bottom","height","left","right","top","width"];for(let o=0;oe.rect[a]})}X(t,"x",{get:()=>e.left+window.pageXOffset}),X(t,"y",{get:()=>e.top+window.pageYOffset})}(t),function(t){const{template:{$player:e},i18n:r,notice:o}=t;X(t,"flip",{get:()=>e.dataset.flip||"normal",set(a){a||(a="normal"),"normal"===a?delete e.dataset.flip:e.dataset.flip=a,o.show=`${r.get("Video Flip")}: ${r.get(H(a))}`,t.emit("flip",a)}})}(t),qt(t),function(t){const{template:{$poster:e}}=t;X(t,"poster",{get:()=>{try{return e.style.backgroundImage.match(/"(.*)"/)[1]}catch{return""}},set(t){w(e,"backgroundImage",`url(${t})`)}})}(t),function(t){const{template:{$container:e,$video:r}}=t;X(t,"autoHeight",{value(){const{clientWidth:o}=e,{videoHeight:a,videoWidth:n}=r,i=a*(o/n);w(e,"height",`${i}px`),t.emit("autoHeight",i)}})}(t),function(t){const{$player:e}=t.template;X(t,"cssVar",{value:(t,r)=>r?e.style.setProperty(t,r):getComputedStyle(e).getPropertyValue(t)})}(t),function(t){X(t,"theme",{get:()=>t.cssVar("--art-theme"),set(e){t.cssVar("--art-theme",e)}})}(t),function(t){X(t,"type",{get:()=>t.option.type,set(e){t.option.type=e}})}(t),function(t){const e=["mini","pip","fullscreen","fullscreenWeb"];X(t,"state",{get:()=>e.find(e=>t[e])||"standard",set(r){for(let o=0;oo.$track?.offset||0,set(a){const{cues:n}=t.subtitle;if(!o.$track||0===n.length)return;const i=F(a,-10,10);o.$track.offset=i;for(let e=0;e{switch(t.availability){case"available":n=!0;break;case"not-available":n=!1}}):n=!1,X(t,"airplay",{value(){n?(a.webkitShowPlaybackTargetPicker(),t.emit("airplay")):r.show=e.get("AirPlay Not Available")}})}(t),function(t){X(t,"quality",{set(e){const{controls:r,notice:o,i18n:a}=t,n=e.find(t=>t.default)||e[0];r.update({name:"quality",position:"right",index:10,style:{marginRight:"10px"},html:n?.html||"",selector:e,onSelect:async e=>(await t.switchQuality(e.url),o.show=`${a.get("Switch Video")}: ${e.html}`,e.html)})}})}(t),oe(t),function(t){const{i18n:e,notice:r,option:o,constructor:a,proxy:n,template:{$player:s,$video:l,$poster:c}}=t;let d=0;for(let p=0;p{t.emit(`video:${e.type}`,e)});t.on("video:canplay",()=>{d=0,t.loading.show=!1}),t.once("video:canplay",()=>{t.loading.show=!1,t.controls.show=!0,t.mask.show=!0,t.isReady=!0,t.emit("ready")}),t.on("video:ended",()=>{o.loop?(t.seek=0,Y(t.play()),t.controls.show=!1,t.mask.show=!1):(t.controls.show=!0,t.mask.show=!0)}),t.on("video:error",async n=>{if(d{t.emit("resize"),p&&(t.loading.show=!1,t.controls.show=!0,t.mask.show=!0)}),t.on("video:loadstart",()=>{t.loading.show=!0,t.mask.show=!1,t.controls.show=!0}),t.on("video:pause",()=>{t.controls.show=!0,t.mask.show=!0}),t.on("video:play",()=>{t.mask.show=!1,w(c,"display","none")}),t.on("video:playing",()=>{t.mask.show=!1}),t.on("video:progress",()=>{t.playing&&(t.loading.show=!1)}),t.on("video:seeked",()=>{t.loading.show=!1,t.mask.show=!0}),t.on("video:seeking",()=>{t.loading.show=!0,t.mask.show=!1}),t.on("video:timeupdate",()=>{t.mask.show=!1}),t.on("video:waiting",()=>{t.loading.show=!0,t.mask.show=!1})}(t),function(t){const{option:e,storage:r,template:{$video:o,$poster:a}}=t;for(const i in e.moreVideoAttr)t.attr(i,e.moreVideoAttr[i]);e.muted&&(t.muted=e.muted),e.volume&&(o.volume=F(e.volume,0,1));const n=r.get("volume");"number"===typeof n&&(o.volume=F(n,0,1)),e.poster&&w(a,"backgroundImage",`url(${e.poster})`),e.autoplay&&(o.autoplay=e.autoplay),e.playsInline&&(o.playsInline=!0,o["webkit-playsinline"]=!0),e.theme&&(e.cssVar["--art-theme"]=e.theme);for(const i in e.cssVar)t.cssVar(i,e.cssVar[i]);t.url=e.url}(t)}}function ie(t){const{notice:e,constructor:r,template:{$player:o,$video:a}}=t,n="art-auto-orientation",i="art-auto-orientation-fullscreen";let s=!1;function l(){const{videoWidth:t,videoHeight:e}=a,r=document.documentElement.clientWidth,o=document.documentElement.clientHeight;return t>e&&ro}return t.on("fullscreenWeb",e=>{if(e){if(l()){const e=Number(r.AUTO_ORIENTATION_TIME??0);setTimeout(()=>{t.fullscreenWeb&&!v(o,n)&&function(){const e=O(),r=document.documentElement.clientWidth,a=document.documentElement.clientHeight-e.top-e.bottom,i=r-e.left-e.right;w(o,"width",`${a}px`),w(o,"height",`${i}px`),w(o,"transform-origin","0 0"),w(o,"transform",`rotate(90deg) translate(${e.top}px, -${r-e.right}px)`),f(o,n),t.isRotate=!0,t.emit("resize")}()},e)}}else v(o,n)&&(w(o,"width",""),w(o,"height",""),w(o,"transform-origin",""),w(o,"transform",""),g(o,n),t.isRotate=!1,t.emit("resize"))}),t.on("fullscreen",async t=>{const r=!!screen?.orientation?.lock;if(t){if(r&&l())try{const t=screen.orientation.type.startsWith("portrait")?"landscape":"portrait";await screen.orientation.lock(t),s=!0,f(o,i)}catch(a){s=!1,e.show=a}}else if(v(o,i)&&g(o,i),r&&s){try{screen.orientation.unlock()}catch{}s=!1}}),{name:"autoOrientation",get state(){return v(o,n)}}}function se(t){const{i18n:e,icons:r,storage:o,constructor:a,proxy:n,template:{$poster:i}}=t,s=t.layers.add({name:"auto-playback",html:'\n
\n
\n
\n '}),l=u(".art-auto-playback-last",s),c=u(".art-auto-playback-jump",s),d=u(".art-auto-playback-close",s);y(d,r.close);let p=null;function h(){const r=(o.get("times")||{})[t.option.id||t.option.url];clearTimeout(p),w(s,"display","none"),r&&r>=a.AUTO_PLAYBACK_MIN&&(w(s,"display","flex"),l.textContent=`${e.get("Last Seen")} ${B(r)}`,c.textContent=e.get("Jump Play"),n(d,"click",()=>{w(s,"display","none")}),n(c,"click",()=>{t.seek=r,Y(t.play()),w(i,"display","none"),w(s,"display","none")}),t.once("video:timeupdate",()=>{p=setTimeout(()=>{w(s,"display","none")},a.AUTO_PLAYBACK_TIMEOUT)}))}return t.on("video:timeupdate",()=>{if(t.playing){const e=o.get("times")||{},r=Object.keys(e);r.length>a.AUTO_PLAYBACK_MAX&&delete e[r[0]],e[t.option.id||t.option.url]=t.currentTime,o.set("times",e)}}),t.on("ready",h),t.on("restart",h),{name:"auto-playback",get times(){return o.get("times")||{}},clear:()=>o.del("times"),delete(t){const e=o.get("times")||{};return delete e[t],o.set("times",e),e}}}function le(t){const{constructor:e,proxy:r,template:{$player:o,$video:a}}=t;let n=null,i=!1,s=1;const l=()=>{clearTimeout(n),i&&(i=!1,t.playbackRate=s,g(o,"art-fast-forward"))};return r(a,"touchstart",r=>{1===r.touches.length&&t.playing&&!t.isLock&&(n=setTimeout(()=>{i=!0,s=t.playbackRate,t.playbackRate=e.FAST_FORWARD_VALUE,f(o,"art-fast-forward")},e.FAST_FORWARD_TIME))}),t.on("document:touchmove",l),t.on("document:touchend",l),{name:"fastForward",get state(){return v(o,"art-fast-forward")}}}function ce(t){const{layers:e,icons:r,template:{$player:o}}=t;function a(){return v(o,"art-lock")}function n(){f(o,"art-lock"),t.isLock=!0,t.emit("lock",!0)}function i(){g(o,"art-lock"),t.isLock=!1,t.emit("lock",!1)}return e.add({name:"lock",mounted(e){const o=y(e,r.lock),a=y(e,r.unlock);w(o,"display","none"),t.on("lock",t=>{t?(w(o,"display","inline-flex"),w(a,"display","none")):(w(o,"display","none"),w(a,"display","inline-flex"))})},click(){a()?i():n()}}),{name:"lock",get state(){return a()},set state(t){t?n():i()}}}function de(t){return t.on("control",e=>{e?g(t.template.$player,"art-mini-progress-bar"):f(t.template.$player,"art-mini-progress-bar")}),{name:"mini-progress-bar"}}class pe{constructor(t){this.art=t,this.id=0;const{option:e}=t;!function(t,e){xt(t.art)||!e.miniProgressBar||e.isLive||t.add(de),!xt(t.art)&&e.lock&&p&&t.add(ce),xt(t.art)||!e.autoPlayback||e.isLive||t.add(se),!xt(t.art)&&e.autoOrientation&&p&&t.add(ie),!xt(t.art)&&e.fastForward&&p&&!e.isLive&&t.add(le)}(this,e);for(let r=0;rconsole.warn("Failed to initialize ArtPlayer plugin:",t))}}add(t){V(!xt(this.art),"Cannot add a plugin after ArtPlayer is destroyed"),this.id+=1;const e=t.call(this.art,this.art);return e instanceof Promise?e.then(e=>this.next(t,e)):this.next(t,e)}next(t,e){return function(t,e,r){if(xt(t.art))return t;const o=r&&r.name||e.name||`plugin${t.id}`;if(xt(t.art))return t;let a=o;const n=K(t,a);if(xt(t.art))return t;const i=`Cannot add a plugin that already has the same name: ${o}`;return xt(t.art)||(V(!n,i),("object"===typeof o&&null!==o||"function"===typeof o)&&(a=Reflect.ownKeys({[a]:void 0})[0]),xt(t.art)||X(t,a,{value:r})),t}(this,t,e)}}class he extends ut{constructor(t){super(t);const{option:e,controls:r,template:{$setting:o}}=t;this.name="setting",this.$parent=o,this.id=0,this.active=null,this.cache=new Map,this.option=[...this.builtin,...e.settings],e.setting&&(this.format(),this.render(),t.on("blur",()=>{this.show&&(this.show=!1,this.render())}),t.on("focus",t=>{const e=C(t,r.setting),o=C(t,this.$parent);!this.show||e||o||(this.show=!1,this.render())}),t.on("resize",()=>this.resize()))}get builtin(){const t=[],{option:e}=this.art;return e.playbackRate&&t.push(function(t){const{i18n:e,icons:r,constructor:{SETTING_ITEM_WIDTH:o,PLAYBACK_RATE:a}}=t;function n(t){return 1===t?e.get("Normal"):t.toFixed(1)}function i(){const e=t.setting.find(`playback-rate-${t.playbackRate}`);t.setting.check(e)}return{width:o,name:"playback-rate",html:e.get("Play Speed"),tooltip:n(t.playbackRate),icon:r.playbackRate,selector:a.map(e=>({value:e,name:`playback-rate-${e}`,default:e===t.playbackRate,html:n(e)})),onSelect:e=>(t.playbackRate=e.value,e.html),mounted:()=>{i(),t.on("video:ratechange",()=>i())}}}(this.art)),e.aspectRatio&&t.push(function(t){const{i18n:e,icons:r,constructor:{SETTING_ITEM_WIDTH:o,ASPECT_RATIO:a}}=t;function n(t){return"default"===t?e.get("Default"):t}function i(){const e=t.setting.find(`aspect-ratio-${t.aspectRatio}`);t.setting.check(e)}return{width:o,name:"aspect-ratio",html:e.get("Aspect Ratio"),icon:r.aspectRatio,tooltip:n(t.aspectRatio),selector:a.map(e=>({value:e,name:`aspect-ratio-${e}`,default:e===t.aspectRatio,html:n(e)})),onSelect:e=>(t.aspectRatio=e.value,e.html),mounted:()=>{i(),t.on("aspectRatio",()=>i())}}}(this.art)),e.flip&&t.push(function(t){const{i18n:e,icons:r,constructor:{SETTING_ITEM_WIDTH:o,FLIP:a}}=t;function n(t){return e.get(H(t))}function i(){const e=t.setting.find(`flip-${t.flip}`);t.setting.check(e)}return{width:o,name:"flip",html:e.get("Video Flip"),tooltip:n(t.flip),icon:r.flip,selector:a.map(e=>({value:e,name:`flip-${e}`,default:e===t.flip,html:n(e)})),onSelect:e=>(t.flip=e.value,e.html),mounted:()=>{i(),t.on("flip",()=>i())}}}(this.art)),e.subtitleOffset&&t.push(function(t){const{i18n:e,icons:r,constructor:o}=t;return{width:o.SETTING_ITEM_WIDTH,name:"subtitle-offset",html:e.get("Subtitle Offset"),icon:r.subtitle,tooltip:"0s",range:[0,-10,10,.1],onChange:e=>(t.subtitleOffset=e.range[0],`${e.range[0]}s`),mounted:(e,r)=>{t.on("subtitleOffset",t=>{r.$range.value=t,r.tooltip=`${t}s`})}}}(this.art)),t}traverse(t,e=this.option){for(let r=0;r{e.default=e===t,e.default&&e.$item&&$(e.$item,"art-current")},t.$option),this.render(t.$parents))}format(t=this.option,e,r,o=[]){for(let a=0;ae}),X(n,"$parents",{get:()=>r}),X(n,"$option",{get:()=>t});const o=[];X(n,"$events",{get:()=>o}),X(n,"$formatted",{get:()=>!0})}this.format(n.selector||[],n,t,o)}this.option=t}find(t=""){let e=null;return this.traverse(r=>{r.name===t&&(e=r)}),e}resize(){const{controls:t,constructor:{SETTING_WIDTH:e,SETTING_ITEM_HEIGHT:r},template:{$player:o,$setting:a}}=this.art;if(t.setting&&this.show){const n=this.active[0]?.$parent?.width||e,{left:i,width:s}=P(t.setting),{left:l,width:c}=P(o),d=i-l+s/2-n/2;if(w(a,"height",`${this.active===this.option?this.active.length*r:(this.active.length+1)*r}px`),w(a,"width",`${n}px`),this.art.isRotate||p)return;d+n>c?(w(a,"left",null),w(a,"right",null)):(w(a,"left",`${d}px`),w(a,"right","auto"))}}inactivate(t){for(let e=0;e'),s=L("div");f(s,"art-setting-item-left-icon"),y(s,o),y(i,s),y(i,t.$parent.html);const l=r(n,"click",()=>this.render(t.$parents));t.$parent.$events.push(l),y(e,n)}createItem(t,e=!1){if(!this.cache.has(t.$option))return;const r=this.cache.get(t.$option),o=t.$item;let a="selector";K(t,"switch")&&(a="switch"),K(t,"range")&&(a="range"),K(t,"onClick")&&(a="button");const{icons:n,proxy:i,constructor:s}=this.art,l=L("div");f(l,"art-setting-item"),w(l,"height",`${s.SETTING_ITEM_HEIGHT}px`),l.dataset.name=t.name||"",l.dataset.value=t.value||"";const c=y(l,'
'),d=y(l,'
'),p=L("div");switch(f(p,"art-setting-item-left-icon"),a){case"button":case"switch":case"range":y(p,t.icon||n.config);break;case"selector":t.selector?.length?y(p,t.icon||n.config):y(p,n.check)}y(c,p),X(t,"$icon",{configurable:!0,get:()=>p}),X(t,"icon",{configurable:!0,get:()=>p.innerHTML,set(t){p.innerHTML="",y(p,t)}});const h=L("div");f(h,"art-setting-item-left-text"),y(h,t.html||""),y(c,h),X(t,"$html",{configurable:!0,get:()=>h}),X(t,"html",{configurable:!0,get:()=>h.innerHTML,set(t){h.innerHTML="",y(h,t)}});const u=L("div");switch(f(u,"art-setting-item-right-tooltip"),y(u,t.tooltip||""),y(d,u),X(t,"$tooltip",{configurable:!0,get:()=>u}),X(t,"tooltip",{configurable:!0,get:()=>u.innerHTML,set(t){u.innerHTML="",y(u,t)}}),a){case"switch":{const e=L("div");f(e,"art-setting-item-right-icon");const r=y(e,n.switchOn),o=y(e,n.switchOff);w(t.switch?o:r,"display","none"),y(d,e),X(t,"$switch",{configurable:!0,get:()=>e});let a=t.switch;X(t,"switch",{configurable:!0,get:()=>a,set(t){a=t,t?(w(o,"display","none"),w(r,"display",null)):(w(o,"display",null),w(r,"display","none"))}});break}case"range":{const e=L("div");f(e,"art-setting-item-right-icon");const r=y(e,'');r.value=t.range[0],r.min=t.range[1],r.max=t.range[2],r.step=t.range[3],f(r,"art-setting-range"),y(d,e),X(t,"$range",{configurable:!0,get:()=>r});let o=[...t.range];X(t,"range",{configurable:!0,get:()=>o,set(t){o=[...t],r.value=t[0],r.min=t[1],r.max=t[2],r.step=t[3]}})}break;case"selector":if(t.selector?.length){const t=L("div");f(t,"art-setting-item-right-icon"),y(t,n.arrowRight),y(d,t)}}switch(a){case"switch":if(t.onSwitch){const e=i(l,"click",async e=>{t.switch=await t.onSwitch.call(this.art,t,l,e)});t.$events.push(e)}break;case"range":if(t.$range){if(t.onRange){const e=i(t.$range,"change",async e=>{t.range[0]=t.$range.valueAsNumber,t.tooltip=await t.onRange.call(this.art,t,l,e)});t.$events.push(e)}if(t.onChange){const e=i(t.$range,"input",async e=>{t.range[0]=t.$range.valueAsNumber,t.tooltip=await t.onChange.call(this.art,t,l,e)});t.$events.push(e)}}break;case"selector":{const e=i(l,"click",async e=>{t.selector?.length?this.render(t.selector):(this.check(t),t.$parent.onSelect&&(t.$parent.tooltip=await t.$parent.onSelect.call(this.art,t,l,e)))});t.$events.push(e),t.default&&f(l,"art-current")}break;case"button":if(t.onClick){const e=i(l,"click",async e=>{t.tooltip=await t.onClick.call(this.art,t,l,e)});t.$events.push(e)}}X(t,"$item",{configurable:!0,get:()=>l}),e?z(l,o):y(r,l),t.mounted&&$t(wt(this.art),()=>t.mounted.call(this.art,t.$item,t),0)}render(t=this.option){if(this.active=t,this.cache.has(t)){$(this.cache.get(t),"art-current")}else{const e=L("div");this.cache.set(t,e),f(e,"art-setting-panel"),y(this.$parent,e),$(e,"art-current"),t[0]?.$parent&&this.createHeader(t[0]);for(let r=0;rnull,this.init(t.option.subtitle);let e=!1;t.on("video:timeupdate",()=>{if(!this.url)return;const t=this.art.template.$video.webkitDisplayingFullscreen;"boolean"===typeof t&&t!==e&&(e=t,this.createTrack(t?"subtitles":"metadata",this.url))})}get url(){return this.art.template.$track.src}set url(t){this.switch(t)}get textTrack(){return this.art.template.$video?.textTracks?.[0]}get activeCues(){return this.textTrack?Array.from(this.textTrack.activeCues):[]}get cues(){return this.textTrack?Array.from(this.textTrack.cues):[]}style(t,e){const{$subtitle:r}=this.art.template;return"object"===typeof t?x(r,t):w(r,t,e)}update(){const{option:{subtitle:t},template:{$subtitle:e}}=this.art;e.innerHTML="",this.activeCues.length&&(this.art.emit("subtitleBeforeUpdate",this.activeCues),e.innerHTML=this.activeCues.map((e,r)=>e.text.split(/\r?\n/).filter(t=>t.trim()).map(e=>`
\n ${t.escape?q(e):e}\n
`).join("")).join(""),this.art.emit("subtitleAfterUpdate",this.activeCues))}async switch(t,e={}){const{i18n:r,notice:o,option:a}=this.art,n={...a.subtitle,...e,url:t},i=await this.init(n);return e.name&&(o.show=`${r.get("Switch Subtitle")}: ${e.name}`),i}createTrack(t,e){const{template:r,proxy:o,option:a}=this.art,{$video:n,$track:i}=r,s=L("track");s.default=!0,s.kind=t,s.src=e,s.label=a.subtitle.name||"Artplayer",s.track.mode="hidden",s.onload=()=>{this.art.emit("subtitleLoad",this.cues,this.option)},this.art.events.remove(this.destroyEvent),i.onload=null,b(i),y(n,s),r.$track=s,this.destroyEvent=o(this.textTrack,"cuechange",()=>this.update())}async init(t){const{notice:e,template:{$subtitle:r}}=this.art;return this.textTrack?(a(t,ht.subtitle),t.url?(this.option=t,this.style(t.style),fetch(t.url).then(t=>t.arrayBuffer()).then(e=>{const r=new TextDecoder(t.encoding).decode(e);switch(t.type||N(t.url)){case"srt":{const e=Q(r);return tt(t.onVttLoad(e))}case"ass":{const e=et(r);return tt(t.onVttLoad(e))}case"vtt":return tt(t.onVttLoad(r));default:return t.url}}).then(t=>(r.innerHTML="",this.url===t||(URL.revokeObjectURL(this.url),this.createTrack("metadata",t)),t)).catch(t=>{throw r.innerHTML="",e.show=t,t})):void 0):null}}class ge{constructor(t){this.art=t;const{option:e,constructor:r}=t;e.container instanceof Element?this.$container=e.container:(this.$container=u(e.container),V(this.$container,`No container element found by ${e.container}`)),V(A(),"The current browser does not support flex layout");const o=this.$container.tagName.toLowerCase();V("div"===o,`Unsupported container element type, only support 'div' but got '${o}'`),V(r.instances.every(t=>t.template.$container!==this.$container),"Cannot mount multiple instances on the same dom element"),this.query=this.query.bind(this),function(t,e,r){const o=yt.get(e);if(o&&o!==t)throw new Error("Cannot mount multiple instances on the same dom element");const a=bt(t);a.rollback=r,yt.set(e,t),a.releaseContainer=()=>{yt.get(e)===t&&yt.delete(e)}}(t,this.$container,function(t){const e=[];return function t(r){const o=Array.from(r.childNodes);e.push({node:r,children:o,attributes:1===r.nodeType?Array.from(r.attributes,t=>[t.name,t.value]):void 0,value:r.nodeValue}),o.forEach(t)}(t),()=>{for(const{node:t,children:r,attributes:o,value:a}of e){for(;t.firstChild;)t.removeChild(t.firstChild);for(const e of r)t.appendChild(e);if(o){const e=t;for(const t of Array.from(e.attributes))e.removeAttribute(t.name);for(const[t,r]of o)e.setAttribute(t,r)}else t.nodeValue=a}}}(this.$container)),this.$container.dataset.artId=t.id,this.init()}static get html(){return`\n
\n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
Player version:
\n
${n}
\n
\n
\n
Video url:
\n
\n
\n
\n
Video volume:
\n
\n
\n
\n
Video time:
\n
\n
\n
\n
Video duration:
\n
\n
\n
\n
Video resolution:
\n
\n x \n
\n
\n
\n
[x]
\n
\n
\n
\n `}query(t){return u(t,this.$container)}init(){const{option:t}=this.art;if(t.useSSR||(this.$container.innerHTML=ge.html),this.$player=this.query(".art-video-player"),this.$video=this.query(".art-video"),this.$track=this.query("track"),this.$poster=this.query(".art-poster"),this.$subtitle=this.query(".art-subtitle"),this.$danmuku=this.query(".art-danmuku"),this.$bottom=this.query(".art-bottom"),this.$progress=this.query(".art-progress"),this.$controls=this.query(".art-controls"),this.$controlsLeft=this.query(".art-controls-left"),this.$controlsCenter=this.query(".art-controls-center"),this.$controlsRight=this.query(".art-controls-right"),this.$layer=this.query(".art-layers"),this.$loading=this.query(".art-loading"),this.$notice=this.query(".art-notice"),this.$noticeInner=this.query(".art-notice-inner"),this.$mask=this.query(".art-mask"),this.$state=this.query(".art-state"),this.$setting=this.query(".art-settings"),this.$info=this.query(".art-info"),this.$infoPanel=this.query(".art-info-panel"),this.$infoClose=this.query(".art-info-close"),this.$contextmenu=this.query(".art-contextmenus"),t.proxy){const e=t.proxy.call(this.art,this.art);V(e instanceof HTMLVideoElement||e instanceof HTMLCanvasElement,"Function 'option.proxy' needs to return 'HTMLVideoElement' or 'HTMLCanvasElement'"),z(e,this.$video),e.className="art-video",this.$video=e}t.backdrop&&f(this.$player,"art-backdrop"),p&&f(this.$player,"art-mobile")}destroy(t){t?this.$container.innerHTML="":f(this.$player,"art-destroy")}}const ve=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);class ye{on(t,e,r){const o=this.e||(this.e={});let a=ve(o,t)?o[t]:void 0;return a||(a=[],Object.defineProperty(o,t,{value:a,enumerable:!0,configurable:!0,writable:!0})),a.push({fn:e,ctx:r}),this}once(t,e,r){const o=this,a=e;let n=!1;function i(...e){n||(n=!0,o.off(t,i),a.apply(r,e))}return i._=e,this.on(t,i,r)}emit(t,...e){const r=this.e||(this.e={}),o=(ve(r,t)&&r[t]||[]).slice();for(const a of o)a.fn.apply(a.ctx,e);return this}off(t,e){const r=this.e||(this.e={}),o=ve(r,t)?r[t]:void 0,a=[];if(o&&e)for(let n=0,i=o.length;ne.call(this,this)),xe.DEBUG){const t=t=>console.log(`[ART.${this.id}] -> ${t}`);t(`Version@${xe.version}`);for(let e=0;et(`Event@${e.type}`))}(function(t){const e=bt(t);return e.rollback=void 0,!e.scope.closed})(this)&&we.push(this)}catch(o){try{kt(this,we,!0,xe.REMOVE_SRC_WHEN_DESTROY,!0)}catch(n){console.warn("Failed to clean up ArtPlayer initialization:",n)}throw o}}static get instances(){return we}static get version(){return n}static get config(){return i}static get utils(){return ot}static get scheme(){return ht}static get Emitter(){return ye}static get validator(){return a}static get kindOf(){return a.kindOf}static get html(){return ge.html}static get option(){return{id:"",container:"#artplayer",url:"",poster:"",type:"",theme:"#f00",volume:.7,isLive:!1,muted:!1,autoplay:!1,autoSize:!1,autoMini:!1,loop:!1,flip:!1,playbackRate:!1,aspectRatio:!1,screenshot:!1,setting:!1,hotkey:!0,pip:!1,mutex:!0,backdrop:!0,fullscreen:!1,fullscreenWeb:!1,subtitleOffset:!1,miniProgressBar:!1,useSSR:!1,playsInline:!0,lock:!1,gesture:!0,fastForward:!1,autoPlayback:!1,autoOrientation:!1,airplay:!1,proxy:void 0,layers:[],contextmenu:[],controls:[],settings:[],quality:[],highlight:[],plugins:[],thumbnails:{url:"",number:60,column:10,width:0,height:0,scale:1},subtitle:{url:"",type:"",style:{},name:"",escape:!0,encoding:"utf-8",onVttLoad:t=>t},moreVideoAttr:{controls:!1,preload:l?"auto":"metadata"},i18n:{},icons:{},cssVar:{},customType:{},lang:navigator?.language.toLowerCase()}}get proxy(){return this.events.proxy}get query(){return this.template.query}get video(){return this.template.$video}reset(){this.video.removeAttribute("src"),this.video.load()}destroy(t=!0){kt(this,we,t,xe.REMOVE_SRC_WHEN_DESTROY)}}return xe.STYLE=me,xe.DEBUG=!1,xe.CONTEXTMENU=!0,xe.NOTICE_TIME=2e3,xe.SETTING_WIDTH=250,xe.SETTING_ITEM_WIDTH=200,xe.SETTING_ITEM_HEIGHT=35,xe.RESIZE_TIME=200,xe.SCROLL_TIME=200,xe.SCROLL_GAP=50,xe.AUTO_PLAYBACK_MAX=10,xe.AUTO_PLAYBACK_MIN=5,xe.AUTO_PLAYBACK_TIMEOUT=3e3,xe.RECONNECT_TIME_MAX=5,xe.RECONNECT_SLEEP_TIME=1e3,xe.CONTROL_HIDE_TIME=3e3,xe.DBCLICK_TIME=300,xe.DBCLICK_FULLSCREEN=!0,xe.MOBILE_DBCLICK_PLAY=!0,xe.MOBILE_CLICK_PLAY=!1,xe.AUTO_ORIENTATION_TIME=200,xe.INFO_LOOP_TIME=1e3,xe.FAST_FORWARD_VALUE=3,xe.FAST_FORWARD_TIME=1e3,xe.TOUCH_MOVE_RATIO=.5,xe.VOLUME_STEP=.1,xe.SEEK_STEP=5,xe.PLAYBACK_RATE=[.5,.75,1,1.25,1.5,2],xe.ASPECT_RATIO=["default","4:3","16:9"],xe.FLIP=["normal","horizontal","vertical"],xe.FULLSCREEN_WEB_IN_BODY=!0,xe.LOG_VERSION=!0,xe.USE_RAF=!1,xe.REMOVE_SRC_WHEN_DESTROY=!0,h&&(window.Artplayer=xe,M("artplayer-style",me),setTimeout(()=>{xe.LOG_VERSION&&console.log(`%c ArtPlayer %c ${xe.version} %c https://artplayer.org`,"color: #fff; background: #5f5f5f","color: #fff; background: #4bc729","")},100)),xe}); diff --git a/packages/artplayer/dist/artplayer.legacy.js b/packages/artplayer/dist/artplayer.legacy.js index 478e8e41a..4b83c7396 100644 --- a/packages/artplayer/dist/artplayer.legacy.js +++ b/packages/artplayer/dist/artplayer.legacy.js @@ -4,4 +4,4 @@ * (c) 2017-2026 Harvey Zhao * Released under the MIT License. */ -!function(t,e){"object"===typeof exports&&"undefined"!==typeof module?module.exports=e():"function"==typeof define&&define.amd?(t.Artplayer=e(),define(function(){return t.Artplayer})):(t="undefined"!==typeof globalThis?globalThis:t||self).Artplayer=e()}(this,function(){"use strict";var t,e=Object.defineProperty,r=Object.defineProperties,o=Object.getOwnPropertyDescriptors,a=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,s=(t,r,o)=>r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o,l=(t,e)=>{for(var r in e||(e={}))n.call(e,r)&&s(t,r,e[r]);if(a)for(var r of a(e))i.call(e,r)&&s(t,r,e[r]);return t},c=(t,e)=>r(t,o(e)),d=(t,e,r)=>new Promise((o,a)=>{var n=t=>{try{s(r.next(t))}catch(e){a(e)}},i=t=>{try{s(r.throw(t))}catch(e){a(e)}},s=t=>t.done?o(t.value):Promise.resolve(t.value).then(n,i);s((r=r.apply(t,e)).next())});function p(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var h,u={exports:{}};var m=(h||(h=1,u.exports=function(){function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}var e=Object.prototype.toString,r=function(r){if(void 0===r)return"undefined";if(null===r)return"null";var a=t(r);if("boolean"===a)return"boolean";if("string"===a)return"string";if("number"===a)return"number";if("symbol"===a)return"symbol";if("function"===a)return"GeneratorFunction"===o(r)?"generatorfunction":"function";if(function(t){return Array.isArray?Array.isArray(t):t instanceof Array}(r))return"array";if(function(t){return!(!t.constructor||"function"!=typeof t.constructor.isBuffer)&&t.constructor.isBuffer(t)}(r))return"buffer";if(function(t){try{if("number"==typeof t.length&&"function"==typeof t.callee)return!0}catch(e){if(-1!==e.message.indexOf("callee"))return!0}return!1}(r))return"arguments";if(function(t){return t instanceof Date||"function"==typeof t.toDateString&&"function"==typeof t.getDate&&"function"==typeof t.setDate}(r))return"date";if(function(t){return t instanceof Error||"string"==typeof t.message&&t.constructor&&"number"==typeof t.constructor.stackTraceLimit}(r))return"error";if(function(t){return t instanceof RegExp||"string"==typeof t.flags&&"boolean"==typeof t.ignoreCase&&"boolean"==typeof t.multiline&&"boolean"==typeof t.global}(r))return"regexp";switch(o(r)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(function(t){return"function"==typeof t.throw&&"function"==typeof t.return&&"function"==typeof t.next}(r))return"generator";switch(a=e.call(r)){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return a.slice(8,-1).toLowerCase().replace(/\s/g,"")};function o(t){return t.constructor?t.constructor.name:null}function a(t,e){var o=2=1,k=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(y)||x,$="undefined"!==typeof window&&"undefined"!==typeof document;function E(t,e=document){return e.querySelector(t)}function T(t,e=document){return Array.from(e.querySelectorAll(t))}function C(t,e){return t.classList.add(e)}function z(t,e){return t.classList.remove(e)}function L(t,e){return t.classList.contains(e)}function S(t,e){return e instanceof Element?t.appendChild(e):t.insertAdjacentHTML("beforeend",String(e)),t.lastElementChild||t.lastChild}function M(t){return t.parentNode.removeChild(t)}function P(t,e,r){return t.style[e]=r,t}function A(t,e){for(const r in e)P(t,r,e[r]);return t}function I(t){return Array.from(t.parentElement.children).filter(e=>e!==t)}function O(t,e){I(t).forEach(t=>z(t,e)),C(t,e)}function R(t,e,r="top"){k||(t.setAttribute("aria-label",e),C(t,"hint--rounded"),C(t,`hint--${r}`))}function _(t,e=0){const r=t.getBoundingClientRect(),o=window.innerHeight||document.documentElement.clientHeight,a=window.innerWidth||document.documentElement.clientWidth,n=r.top-e<=o&&r.top+r.height+e>=0,i=r.left-e<=a+e&&r.left+r.width+e>=0;return n&&i}function V(t,e){return j(t).includes(e)}function Y(t,e){return e.parentNode.replaceChild(t,e),t}function N(t){return document.createElement(t)}function D(t="",e=""){const r=N("i");return C(r,"art-icon"),C(r,`art-icon-${t}`),S(r,e),r}function F(t,e){let r=document.getElementById(t);r||(r=document.createElement("style"),r.id=t,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{document.head.appendChild(r)}):(document.head||document.documentElement).appendChild(r)),r.textContent=e}function H(){const t=document.createElement("div");return t.style.display="flex","flex"===t.style.display}function B(t){return t.getBoundingClientRect()}function W(t,e){return new Promise((r,o)=>{const a=new Image;a.onload=function(){if(e&&1!==e){const n=document.createElement("canvas"),i=n.getContext("2d");n.width=a.width*e,n.height=a.height*e,i.drawImage(a,0,0,n.width,n.height),n.toBlob(e=>{const a=URL.createObjectURL(e),n=new Image;n.onload=function(){r(n)},n.onerror=function(){URL.revokeObjectURL(a),o(new Error(`Image load failed: ${t}`))},n.src=a})}else r(a)},a.onerror=function(){o(new Error(`Image load failed: ${t}`))},a.src=t})}function j(t){if(t.composedPath)return t.composedPath();const e=[];let r=t.target;for(;r;)e.push(r),r=r.parentNode;return e.includes(window)||void 0===window||e.push(window),e}function U(){const t=document.createElement("div");t.style.cssText="position:fixed;top:env(safe-area-inset-top,0px);right:env(safe-area-inset-right,0px);bottom:env(safe-area-inset-bottom,0px);left:env(safe-area-inset-left,0px);pointer-events:none;visibility:hidden;",document.body.appendChild(t);const e=getComputedStyle(t),r={top:Number.parseFloat(e.top)||0,right:Number.parseFloat(e.right)||0,bottom:Number.parseFloat(e.bottom)||0,left:Number.parseFloat(e.left)||0};return t.remove(),r}class q extends Error{constructor(t,e){super(t),"captureStackTrace"in Error&&"function"===typeof Error.captureStackTrace&&Error.captureStackTrace(this,e||this.constructor),this.name="ArtPlayerError"}}function X(t,e){if(!t)throw new q(e);return t}function G(t){const e=t;return e&&"function"===typeof e.catch?e.catch(()=>{}):t}function K(t){const e=t.search(/[?#]/),r=(e<0?t:t.slice(0,e)).trim().toLowerCase();return r.slice(r.lastIndexOf(".")+1)}function Z(t,e){const r=document.createElement("a");r.style.display="none",r.href=t,r.download=e,document.body.appendChild(r);try{r.click()}finally{r.remove()}}function J(t,e,r){return Math.max(Math.min(t,Math.max(e,r)),Math.min(e,r))}function Q(t){return t.charAt(0).toUpperCase()+t.slice(1)}function tt(t){if(!t)return"00:00";const e=Math.floor(t/3600),r=Math.floor((t-3600*e)/60),o=Math.floor(t-3600*e-60*r);return(e>0?[e,r,o]:[r,o]).map(t=>t<10?`0${t}`:String(t)).join(":")}const et={"&":"&","<":"<",">":">","'":"'",'"':"""},rt={"&":"&","<":"<",">":">","'":"'",""":'"'},ot=/(&|<|>|'|")/g;function at(t){return t.replace(/[&<>'"]/g,t=>et[t]||t)}const nt=Object.defineProperty,{hasOwnProperty:it}=Object.prototype;function st(t,e){return it.call(t,e)}function lt(t,e){return Object.getOwnPropertyDescriptor(t,e)}function ct(...t){const e=t=>!!t&&"object"===typeof t&&!Array.isArray(t);return t.reduce((t,r)=>(Object.keys(r).forEach(o=>{const a=t[o],n=r[o];let i;i=Array.isArray(a)&&Array.isArray(n)?a.concat(...n):e(a)&&e(n)?ct(a,n):n,nt(t,o,{value:i,enumerable:!0,configurable:!0,writable:!0})}),t),{})}function dt(t){return"WEBVTT \r\n\r\n".concat((e=t,e.replace(/(\d\d:\d\d:\d\d)[,.](\d+)/g,(t,e,r)=>{let o=r.slice(0,3);return 1===r.length&&(o=`${r}00`),2===r.length&&(o=`${r}0`),`${e},${o}`})).replace(/\{\\([ibu])\}/g,"").replace(/\{\\([ibu])1\}/g,"<$1>").replace(/\{([ibu])\}/g,"<$1>").replace(/\{\/([ibu])\}/g,"").replace(/(\d\d:\d\d:\d\d),(\d\d\d)/g,"$1.$2").replace(/\{[\s\S]*?\}/g,"").concat("\r\n\r\n"));var e}function pt(t){return URL.createObjectURL(new Blob([t],{type:"text/vtt"}))}function ht(t){const e=new RegExp("Dialogue:\\s\\d,(\\d+:\\d\\d:\\d\\d.\\d\\d),(\\d+:\\d\\d:\\d\\d.\\d\\d),([^,]*),([^,]*),(?:[^,]*,){4}([\\s\\S]*)$","i");function r(t=""){return t.split(/[:.]/).map((t,e,r)=>{if(e===r.length-1){if(1===t.length)return`.${t}00`;if(2===t.length)return`.${t}0`}else if(1===t.length)return(0===e?"0":":0")+t;return 0===e?t:e===r.length-1?`.${t}`:`:${t}`}).join("")}return`WEBVTT\n\n${t.split(/\r?\n/).map(t=>{const o=t.match(e);if(!o)return null;const[,a="",n="",,,i=""]=o;return{start:r(a.trim()),end:r(n.trim()),text:i.replace(/\{[\s\S]*?\}/g,"").replace(/(\\N)/g,"\n").trim().split(/\r?\n/).map(t=>t.trim()).join("\n")}}).filter(t=>t).map((t,e)=>t?`${e+1}\n${t.start} --\x3e ${t.end}\n${t.text}`:"").filter(t=>t.trim()).join("\n\n")}`}function ut(t,e){let r=!1;return function(...o){r||(t.apply(this,o),r=!0,setTimeout(()=>{r=!1},e))}}const mt=Object.freeze(Object.defineProperty({__proto__:null,ArtPlayerError:q,addClass:C,append:S,assToVtt:ht,capitalize:Q,clamp:J,createElement:N,debounce:function(t,e){let r;return function(...o){clearTimeout(r),r=setTimeout(()=>(r=void 0,t.apply(this,o)),e)}},def:nt,download:Z,errorHandle:X,escape:at,get:lt,getComposedPath:j,getExt:K,getIcon:D,getRect:B,getSafeAreaInsets:U,getStyle:function(t,e,r=!0){const o=window.getComputedStyle(t,null).getPropertyValue(e);return r?Number.parseFloat(o):o},has:st,hasClass:L,includeFromEvent:V,inverseClass:O,isBrowser:$,isIOS:w,isIOS13:x,isInViewport:_,isMobile:k,isSafari:b,loadImg:W,mergeDeep:ct,query:E,queryAll:T,remove:M,removeClass:z,replaceElement:Y,secondToTime:tt,setStyle:P,setStyleText:F,setStyles:A,siblings:I,silencePromise:G,sleep:function(t=0){return new Promise(e=>setTimeout(e,t))},srtToVtt:dt,supportsFlex:H,throttle:ut,tooltip:R,unescape:function(t){return t.replace(ot,t=>rt[t]||t)},userAgent:y,vttToBlob:pt},Symbol.toStringTag,{value:"Module"})),ft="array",gt="boolean",vt="string",yt="number",bt="object",wt="function";function xt(t,e,r){return X(e===vt||e===yt||t instanceof Element,`${r.join(".")} require '${vt}' or 'Element' type`)}const kt={html:xt,disable:`?${gt}`,name:`?${vt}`,index:`?${yt}`,style:`?${bt}`,click:`?${wt}`,mounted:`?${wt}`,tooltip:`?${vt}|${yt}`,width:`?${yt}`,selector:`?${ft}`,onSelect:`?${wt}`,switch:`?${gt}`,onSwitch:`?${wt}`,range:`?${ft}`,onRange:`?${wt}`,onChange:`?${wt}`},$t={id:vt,container:xt,url:vt,poster:vt,type:vt,theme:vt,lang:vt,volume:yt,isLive:gt,muted:gt,autoplay:gt,autoSize:gt,autoMini:gt,loop:gt,flip:gt,playbackRate:gt,aspectRatio:gt,screenshot:gt,setting:gt,hotkey:gt,pip:gt,mutex:gt,backdrop:gt,fullscreen:gt,fullscreenWeb:gt,subtitleOffset:gt,miniProgressBar:gt,useSSR:gt,playsInline:gt,lock:gt,gesture:gt,fastForward:gt,autoPlayback:gt,autoOrientation:gt,airplay:gt,proxy:`?${wt}`,plugins:[wt],layers:[kt],contextmenu:[kt],settings:[kt],controls:[c(l({},kt),{position:(t,e,r)=>{const o=["top","left","right"];return X("string"===typeof t&&o.includes(t),`${r.join(".")} only accept ${o.toString()} as parameters`)}})],quality:[{default:`?${gt}`,html:vt,url:vt}],highlight:[{time:yt,text:vt}],thumbnails:{url:vt,number:yt,column:yt,width:yt,height:yt,scale:yt},subtitle:{url:vt,name:vt,type:vt,style:bt,escape:gt,encoding:vt,onVttLoad:wt},moreVideoAttr:bt,i18n:bt,icons:bt,cssVar:bt,customType:bt};class Et{constructor(t){this.id=0,this.art=t,this.cache=new Map,this.add=this.add.bind(this),this.remove=this.remove.bind(this),this.update=this.update.bind(this)}get show(){return L(this.art.template.$player,`art-${this.name}-show`)}set show(t){const{$player:e}=this.art.template,r=`art-${this.name}-show`;t?C(e,r):z(e,r),this.art.emit(this.name,t)}toggle(){this.show=!this.show}add(t){const e="function"===typeof t?t(this.art):t;if(e.html=e.html||"",f(e,kt),!this.$parent||!this.name||e.disable)return;const r=e.name||`${this.name}${this.id}`;X(!this.cache.has(r),`Can't add an existing [${r}] to the [${this.name}]`),this.id+=1;const o=N("div");C(o,`art-${this.name}`),C(o,`art-${this.name}-${r}`);const a=Array.from(this.$parent.children);o.dataset.index=e.index||this.id;const n=a.find(t=>Number(t.dataset.index)>=Number(o.dataset.index));n?n.insertAdjacentElement("beforebegin",o):S(this.$parent,o),e.html&&S(o,e.html),e.style&&A(o,e.style),e.tooltip&&R(o,e.tooltip);const i=[];if(e.click){const t=this.art.events.proxy(o,"click",t=>{t.preventDefault(),e.click.call(this.art,this,t)});i.push(t)}return e.selector&&["left","right"].includes(e.position)&&this.selector(e,o,i),this[r]=o,this.cache.set(r,{$ref:o,events:i,option:e}),e.mounted&&e.mounted.call(this.art,o),o}remove(t){X(this.cache.has(t),`Can't find [${t}] from the [${this.name}]`);const e=this.cache.get(t);e.option.beforeUnmount&&e.option.beforeUnmount.call(this.art,e.$ref);for(const r of e.events)this.art.events.remove(r);this.cache.delete(t),delete this[t],M(e.$ref)}update(t){if(this.cache.has(t.name)){const e=this.cache.get(t.name);t=Object.assign(e.option,t),this.remove(t.name)}return this.add(t)}}class Tt extends Et{constructor(t){super(t),this.name="contextmenu",this.$parent=t.template.$contextmenu,k||this.init()}init(){const{option:t,proxy:e,template:{$player:r,$contextmenu:o}}=this.art;t.playbackRate&&this.add(function(t){return e=>{const{i18n:r,constructor:{PLAYBACK_RATE:o}}=e,a=o.map(t=>`${1===t?r.get("Normal"):t.toFixed(1)}`).join("");return c(l({},t),{html:`${r.get("Play Speed")}: ${a}`,click:(t,r)=>{const{value:o}=r.target.dataset;o&&(e.playbackRate=Number(o),t.show=!1)},mounted:t=>{const r=E('[data-value="1"]',t);r&&O(r,"art-current"),e.on("video:ratechange",()=>{const r=T("span",t).find(t=>Number(t.dataset.value)===e.playbackRate);r&&O(r,"art-current")})}})}}({name:"playbackRate",index:10})),t.aspectRatio&&this.add(function(t){return e=>{const{i18n:r,constructor:{ASPECT_RATIO:o}}=e,a=o.map(t=>`${"default"===t?r.get("Default"):t}`).join("");return c(l({},t),{html:`${r.get("Aspect Ratio")}: ${a}`,click:(t,r)=>{const{value:o}=r.target.dataset;o&&(e.aspectRatio=o,t.show=!1)},mounted:t=>{const r=E('[data-value="default"]',t);r&&O(r,"art-current"),e.on("aspectRatio",e=>{const r=T("span",t).find(t=>t.dataset.value===e);r&&O(r,"art-current")})}})}}({name:"aspectRatio",index:20})),t.flip&&this.add(function(t){return e=>{const{i18n:r,constructor:{FLIP:o}}=e,a=o.map(t=>`${r.get(Q(t))}`).join("");return c(l({},t),{html:`${r.get("Video Flip")}: ${a}`,click:(t,r)=>{const{value:o}=r.target.dataset;o&&(e.flip=o.toLowerCase(),t.show=!1)},mounted:t=>{const r=E('[data-value="normal"]',t);r&&O(r,"art-current"),e.on("flip",e=>{const r=T("span",t).find(t=>t.dataset.value===e);r&&O(r,"art-current")})}})}}({name:"flip",index:30})),this.add(function(t){return e=>c(l({},t),{html:e.i18n.get("Video Info"),click:t=>{e.info.show=!0,t.show=!1}})}({name:"info",index:40})),this.add(function(t){return c(l({},t),{html:`ArtPlayer ${g}`})}({name:"version",index:50})),this.add(function(t){return e=>c(l({},t),{html:e.i18n.get("Close"),click:t=>{t.show=!1}})}({name:"close",index:60}));for(let a=0;a{if(!this.art.constructor.CONTEXTMENU)return;t.preventDefault(),this.show=!0;const e=t.clientX,a=t.clientY,{height:n,width:i,left:s,top:l}=B(r),{height:c,width:d}=B(o);let p=e-s,h=a-l;e+d>s+i&&(p=i-d),a+c>l+n&&(h=n-c),A(o,{top:`${h}px`,left:`${p}px`})}),e(r,"click",t=>{V(t,o)||(this.show=!1)}),this.art.on("blur",()=>{this.show=!1})}}class Ct extends Error{constructor(t){super("Failed to release ArtPlayer resources"),this.errors=t,this.name="ResourceCleanupError"}}class zt{constructor(){this.cleanups=new Set,this.disposed=!1}get closed(){return this.disposed}add(t){let e=!0;const r=()=>{e&&(e=!1,this.cleanups.delete(r),t())};return this.closed?r():this.cleanups.add(r),r}child(){const t=new zt,e=this.add(()=>{t.dispose()});return t.add(()=>{e()}),t}dispose(){if(this.closed)return;this.disposed=!0;const t=[];for(const r of Array.from(this.cleanups).reverse())try{r()}catch(e){e instanceof Ct?t.push(...e.errors):t.push(e)}if(t.length)throw new Ct(t)}}const Lt=new WeakMap,St=new WeakMap;function Mt(t){const e=Lt.get(t);if(!e)throw new Error("ArtPlayer lifecycle has not been initialized");return e}function Pt(t){return Mt(t).scope}function At(t){const e=Mt(t);return e.destroying||e.scope.closed}function It(t,e,r,o,a=!1){var n,i,s;const l=Mt(t);if(l.destroying||l.scope.closed)return;l.destroying=!0;const c=[],d=t=>{try{t()}catch(e){c.push(...e instanceof Ct?e.errors:[e])}};o&&(null==(n=t.template)?void 0:n.$video)&&d(()=>t.reset()),d(()=>l.scope.dispose()),d(()=>{var e;return null==(e=t.template)?void 0:e.destroy(r)});const p=e.indexOf(t);-1!==p&&e.splice(p,1),t.isDestroy=!0,a||(null==(i=l.releaseContainer)||i.call(l),l.releaseContainer=void 0),d(()=>t.emit("destroy")),a&&l.rollback&&d(l.rollback),l.rollback=void 0,null==(s=l.releaseContainer)||s.call(l),l.releaseContainer=void 0;for(const h of c.slice(1))console.warn("Additional ArtPlayer cleanup failure:",h);if(c.length)throw c[0]}function Ot(t,e,r){if(t.closed)return()=>{};let o=!0,a=()=>{};const n=setTimeout(()=>{o&&(a(),t.closed||e())},r);return a=t.add(()=>{o=!1,clearTimeout(n)}),a}function Rt(t,e=0){return t.closed?Promise.resolve(!1):new Promise(r=>{let o=!1,a=()=>{};const n=setTimeout(()=>{o=!0,a(),r(!0)},e);a=t.add(()=>{clearTimeout(n),o||r(!1)})})}function _t(t,e){const{$progress:r}=t.template,{left:o}=B(r),a=J((k?e.touches[0].clientX:e.clientX)-o,0,r.clientWidth),n=a/r.clientWidth*t.duration;return{second:n,time:tt(n),width:a,percentage:J(a/r.clientWidth,0,1)}}function Vt(t,e){if(t.isRotate){const r=(e.touches[0].clientY-t.top)/t.height,o=r*t.duration;t.emit("setBar","played",r,e),t.seek=o}else{const{second:r,percentage:o}=_t(t,e);t.emit("setBar","played",o,e),t.seek=r}}function Yt(t){return e=>{const{icons:r,option:o,proxy:a}=e,{$player:n,$progress:i}=e.template;return c(l({},t),{html:'\n
\n
\n
\n
\n
\n
\n
00:00
\n
\n ',mounted:t=>{let s=null,l=!1;const c=E(".art-progress-hover",t),d=E(".art-progress-loaded",t),p=E(".art-progress-played",t),h=E(".art-progress-highlight",t),u=E(".art-progress-indicator",t),m=E(".art-progress-tip",t);function f(r,o){const{width:a,time:n}=o||_t(e,r);m.textContent=n||"00:00";const i=m.clientWidth;a<=i/2?P(m,"left",0):a>t.clientWidth-i/2?P(m,"left",t.clientWidth-i+"px"):P(m,"left",a-i/2+"px")}r.indicator?S(u,r.indicator):P(u,"backgroundColor","var(--art-theme)"),e.on("setBar",function(r,o,a){const i="played"===r&&a&&k;if("loaded"===r&&P(d,"width",100*o+"%"),"hover"===r&&(P(c,"width",100*o+"%"),V(a,h)?function(r){const{width:o}=_t(e,r),{text:a}=r.target.dataset;m.textContent=a;const n=m.clientWidth;o<=n/2?P(m,"left",0):o>t.clientWidth-n/2?P(m,"left",t.clientWidth-n+"px"):P(m,"left",o-n/2+"px")}(a):f(a),0===o?z(n,"art-progress-hover"):C(n,"art-progress-hover")),"played"===r&&(P(p,"width",100*o+"%"),P(u,"left",100*o+"%")),i){C(n,"art-progress-hover");f(a,{width:t.clientWidth*o,time:tt(o*e.duration)}),clearTimeout(s),s=setTimeout(()=>{z(n,"art-progress-hover")},500)}}),e.on("video:loadedmetadata",function(){h.textContent="";for(let t=0;t`;S(h,n)}}),e.constructor.USE_RAF?e.on("raf",()=>{e.emit("setBar","played",e.played),e.emit("setBar","loaded",e.loaded)}):(e.on("video:timeupdate",()=>{e.emit("setBar","played",e.played)}),e.on("video:progress",()=>{e.emit("setBar","loaded",e.loaded)}),e.on("video:ended",()=>{e.emit("setBar","played",1)})),e.emit("setBar","loaded",e.loaded||0),k||(a(i,"click",t=>{t.target!==u&&Vt(e,t)}),a(i,"mousemove",t=>{const{percentage:r}=_t(e,t);e.emit("setBar","hover",r,t)}),a(i,"mouseleave",t=>{e.emit("setBar","hover",0,t)}),a(i,"mousedown",t=>{l=0===t.button}),e.on("document:mousemove",t=>{if(l){const{second:r,percentage:o}=_t(e,t);e.emit("setBar","played",o,t),e.seek=r}}),e.on("document:mouseup",()=>{l&&(l=!1)}))}})}}class Nt extends Et{constructor(t){super(t),this.isHover=!1,this.name="control",this.timer=Date.now();const{constructor:e}=t,{$player:r,$bottom:o}=this.art.template;t.on("mousemove",()=>{k||(this.show=!0)}),t.on("click",()=>{k?this.toggle():this.show=!0}),t.on("document:mousemove",t=>{this.isHover=V(t,o)}),t.on("video:timeupdate",()=>{!t.setting.show&&!this.isHover&&!t.isInput&&t.playing&&this.show&&Date.now()-this.timer>=e.CONTROL_HIDE_TIME&&(this.show=!1)}),t.on("control",t=>{t?(z(r,"art-hide-cursor"),C(r,"art-hover"),this.timer=Date.now()):(C(r,"art-hide-cursor"),z(r,"art-hover"))}),this.init()}init(){const{option:t}=this.art;t.isLive||this.add(Yt({name:"progress",position:"top",index:10})),this.add({name:"thumbnails",position:"top",index:20}),this.add(function(t){return e=>c(l({},t),{mounted:t=>{const{proxy:r,icons:o,i18n:a}=e,n=S(t,o.play),i=S(t,o.pause);function s(){P(n,"display","flex"),P(i,"display","none")}function l(){P(n,"display","none"),P(i,"display","flex")}R(n,a.get("Play")),R(i,a.get("Pause")),r(n,"click",()=>{G(e.play())}),r(i,"click",()=>{e.pause()}),e.playing?l():s(),e.on("video:playing",()=>{l()}),e.on("video:pause",()=>{s()})}})}({name:"playAndPause",position:"left",index:10})),this.add(function(t){return e=>c(l({},t),{mounted:t=>{const{proxy:r,icons:o}=e,a=S(t,o.volume),n=S(t,o.volumeClose),i=S(t,'
'),s=S(i,'
'),l=S(s,'
'),c=S(s,'
'),d=S(c,'
'),p=S(d,'
'),h=S(c,'
');function u(t){const{top:e,height:r}=B(c);return 1-(t.clientY-e)/r}function m(){if(e.muted||0===e.volume)P(a,"display","none"),P(n,"display","flex"),P(h,"top","100%"),P(p,"top","100%"),l.textContent=0;else{const t=100*e.volume;P(a,"display","flex"),P(n,"display","none"),P(h,"top",100-t+"%"),P(p,"top",100-t+"%"),l.textContent=Math.floor(t)}}if(m(),e.on("video:volumechange",m),r(a,"click",()=>{e.muted=!0}),r(n,"click",()=>{e.muted=!1}),k)P(i,"display","none");else{let t=!1;r(c,"mousedown",r=>{t=0===r.button,e.volume=u(r)}),e.on("document:mousemove",r=>{t&&(e.muted=!1,e.volume=u(r))}),e.on("document:mouseup",()=>{t&&(t=!1)})}}})}({name:"volume",position:"left",index:20})),t.isLive||this.add(function(t){return e=>c(l({},t),{style:k?{fontSize:"12px",padding:"0 5px"}:{cursor:"auto",padding:"0 10px"},mounted:t=>{function r(){const r=`${tt(e.currentTime)} / ${tt(e.duration)}`;r!==t.textContent&&(t.textContent=r)}r();const o=["video:loadedmetadata","video:timeupdate","video:progress"];for(let a=0;a{e&&!Pt(this.art).closed&&(this.art.quality=t.quality)}),t.screenshot&&!k&&this.add(function(t){return e=>c(l({},t),{tooltip:e.i18n.get("Screenshot"),mounted:t=>{const{proxy:r,icons:o}=e;S(t,o.screenshot),r(t,"click",()=>{e.screenshot()})}})}({name:"screenshot",position:"right",index:20})),t.setting&&this.add(function(t){return e=>c(l({},t),{tooltip:e.i18n.get("Show Setting"),mounted:t=>{const{proxy:r,icons:o,i18n:a}=e;S(t,o.setting),r(t,"click",()=>{e.setting.toggle(),e.setting.resize()}),e.on("setting",e=>{R(t,a.get(e?"Hide Setting":"Show Setting"))})}})}({name:"setting",position:"right",index:30})),t.pip&&this.add(function(t){return e=>c(l({},t),{tooltip:e.i18n.get("PIP Mode"),mounted:t=>{const{proxy:r,icons:o,i18n:a}=e;S(t,o.pip),r(t,"click",()=>{e.pip=!e.pip}),e.on("pip",e=>{R(t,a.get(e?"Exit PIP Mode":"PIP Mode"))})}})}({name:"pip",position:"right",index:40})),t.airplay&&window.WebKitPlaybackTargetAvailabilityEvent&&this.add(function(t){return e=>c(l({},t),{tooltip:e.i18n.get("AirPlay"),mounted:t=>{const{proxy:r,icons:o}=e;S(t,o.airplay),r(t,"click",()=>e.airplay())}})}({name:"airplay",position:"right",index:50})),t.fullscreenWeb&&this.add(function(t){return e=>c(l({},t),{tooltip:e.i18n.get("Web Fullscreen"),mounted:t=>{const{proxy:r,icons:o,i18n:a}=e,n=S(t,o.fullscreenWebOn),i=S(t,o.fullscreenWebOff);P(i,"display","none"),r(t,"click",()=>{e.fullscreenWeb=!e.fullscreenWeb}),e.on("fullscreenWeb",e=>{e?(R(t,a.get("Exit Web Fullscreen")),P(n,"display","none"),P(i,"display","inline-flex")):(R(t,a.get("Web Fullscreen")),P(n,"display","inline-flex"),P(i,"display","none"))})}})}({name:"fullscreenWeb",position:"right",index:60})),t.fullscreen&&this.add(function(t){return e=>c(l({},t),{tooltip:e.i18n.get("Fullscreen"),mounted:t=>{const{proxy:r,icons:o,i18n:a}=e,n=S(t,o.fullscreenOn),i=S(t,o.fullscreenOff);P(i,"display","none"),r(t,"click",()=>{e.fullscreen=!e.fullscreen}),e.on("fullscreen",e=>{e?(R(t,a.get("Exit Fullscreen")),P(n,"display","none"),P(i,"display","inline-flex")):(R(t,a.get("Fullscreen")),P(n,"display","inline-flex"),P(i,"display","none"))})}})}({name:"fullscreen",position:"right",index:70}));for(let e=0;et.selector}),nt(e,"$control_item",{get:()=>r}),nt(e,"$control_value",{get:()=>a})}const i=o(n,"click",e=>d(this,null,function*(){const r=j(e),o=t.selector.find(t=>t.$control_item===r.find(e=>t.$control_item===e));this.check(o),t.onSelect&&(a.innerHTML=yield t.onSelect.call(this.art,o,o.$control_item,e))}));r.push(i)}}function Dt(t,e,r,o){const a=e-o,n=r-t;let i=0;if(Math.abs(n)<2&&Math.abs(a)<2)return i;const s=function(t,e){return 180*Math.atan2(e,t)/Math.PI}(n,a);return s>=-45&&s<45?i=4:s>=45&&s<135?i=1:s>=-135&&s<-45?i=2:(s>=135&&s<=180||s>=-180&&s<-135)&&(i=3),i}function Ft(t){if(t.constructor.USE_RAF){const e=Pt(t);let r=()=>{};!function o(){t.playing&&t.emit("raf"),t.isDestroy||(r=function(t,e){if(t.closed)return()=>{};let r=!0,o=()=>{};const a=requestAnimationFrame(a=>{r&&(o(),t.closed||e(a))});return o=t.add(()=>{r=!1,cancelAnimationFrame(a)}),o}(e,o))}(),t.on("destroy",()=>{r()})}}const Ht=new WeakMap;class Bt{constructor(t){this.destroyEvents=new Set;const e=Pt(t);Ht.set(this,e),e.add(()=>this.destroy()),this.proxy=this.proxy.bind(this),this.hover=this.hover.bind(this),function(t,e){const{constructor:r,template:{$player:o,$video:a}}=t;function n(e){V(e,o)?(t.isInput="INPUT"===e.target.tagName,t.isFocus=!0,t.emit("focus",e)):(t.isInput=!1,t.isFocus=!1,t.emit("blur",e))}t.on("document:click",n),t.on("document:contextmenu",n);let i=[];e.proxy(a,"click",e=>{const o=Date.now();i.push(o);const{MOBILE_CLICK_PLAY:a,DBCLICK_TIME:n,MOBILE_DBCLICK_PLAY:s,DBCLICK_FULLSCREEN:l}=r,c=i.filter(t=>o-t<=n);switch(c.length){case 1:t.emit("click",e),k?!t.isLock&&a&&G(t.toggle()):G(t.toggle()),i=c;break;case 2:t.emit("dblclick",e),k?!t.isLock&&s&&G(t.toggle()):l&&(t.fullscreen=!t.fullscreen),i=[];break;default:i=[]}})}(t,this),function(t,e){const{$player:r}=t.template;e.hover(r,e=>{C(r,"art-hover"),t.emit("hover",!0,e)},e=>{z(r,"art-hover"),t.emit("hover",!1,e)})}(t,this),function(t,e){const{$player:r}=t.template;e.proxy(r,"mousemove",e=>{t.emit("mousemove",e)})}(t,this),function(t,e){const{option:r,constructor:o}=t;t.on("resize",()=>{const{aspectRatio:e,notice:o}=t;"standard"===t.state&&r.autoSize&&t.autoSize(),t.aspectRatio=e,o.show=""});const a=Pt(t);let n=()=>{};const i=()=>{n(),n=Ot(a,()=>t.emit("resize"),o.RESIZE_TIME)};t.on("window:orientationchange",()=>i()),t.on("window:resize",()=>i()),screen&&screen.orientation&&screen.orientation.onchange&&e.proxy(screen.orientation,"change",()=>i())}(t,this),function(t,e){if(k&&!t.option.isLive){const{$video:r,$progress:o}=t.template;let a=null,n=!1,i=0,s=0,l=0;const c=e=>{if(1===e.touches.length&&!t.isLock){a===o&&Vt(t,e),n=!0;const{pageX:r,pageY:c}=e.touches[0];i=r,s=c,l=t.currentTime}},d=e=>{if(1===e.touches.length&&n&&t.duration){const{pageX:o,pageY:n}=e.touches[0],c=Dt(i,s,o,n),d=[3,4].includes(c),p=[1,2].includes(c);if(d&&!t.isRotate||p&&t.isRotate){const c=J((o-i)/t.width,-1,1),d=J((n-s)/t.height,-1,1),p=t.isRotate?d:c,h=a===r?t.constructor.TOUCH_MOVE_RATIO:1,u=J(l+t.duration*p*h,0,t.duration);t.seek=u,t.emit("setBar","played",J(u/t.duration,0,1),e),t.notice.show=`${tt(u)} / ${tt(t.duration)}`}}},p=()=>{n&&(i=0,s=0,l=0,n=!1,a=null)};t.option.gesture&&(e.proxy(r,"touchstart",t=>{a=r,c(t)}),e.proxy(r,"touchmove",d)),e.proxy(o,"touchstart",t=>{a=o,c(t)}),e.proxy(o,"touchmove",d),t.on("document:touchend",p)}}(t,this),function(t){const{option:e,constructor:r,template:{$container:o}}=t,a=ut(()=>{t.emit("view",_(o,r.SCROLL_GAP))},r.SCROLL_TIME);t.on("window:scroll",()=>a()),t.on("view",r=>{e.autoMini&&(t.mini=!r)})}(t),function(t,e){const r=["click","mouseup","keydown","touchend","touchmove","mousemove","pointerup","contextmenu","pointermove","visibilitychange","webkitfullscreenchange"],o=["resize","scroll","orientationchange"],a=[];function n(n={}){for(let t=0;t{const o=n.document||i.ownerDocument||document,s=e.proxy(o,r,e=>{t.emit(`document:${r}`,e)});a.push(s)}),o.forEach(r=>{var o;const s=n.window||(null==(o=i.ownerDocument)?void 0:o.defaultView)||window,l=e.proxy(s,r,e=>{t.emit(`window:${r}`,e)});a.push(l)})}n(),e.bindGlobalEvents=n}(t,this),Ft(t)}proxy(t,e,r,o={}){if(Array.isArray(e))return e.map(e=>this.proxy(t,e,r,o));if(Ht.get(this).closed)return()=>{};t.addEventListener(e,r,o);const a=()=>t.removeEventListener(e,r,o);return this.destroyEvents.add(a),a}hover(t,e,r){e&&this.proxy(t,"mouseenter",e),r&&this.proxy(t,"mouseleave",r)}remove(t){if(this.destroyEvents.has(t))try{t()}catch(e){console.warn("Failed to remove event listener:",e)}finally{this.destroyEvents.delete(t)}}destroy(){for(const e of this.destroyEvents)try{e()}catch(t){console.warn("Failed to destroy event listener:",t)}this.destroyEvents.clear()}}class Wt{constructor(t){this.art=t,this.keys={},k||this.init()}init(){const{constructor:t}=this.art;this.art.option.hotkey&&(this.add("Escape",()=>{this.art.fullscreenWeb&&(this.art.fullscreenWeb=!1)}),this.add("Space",()=>{G(this.art.toggle())}),this.add("ArrowLeft",()=>{this.art.backward=t.SEEK_STEP}),this.add("ArrowUp",()=>{this.art.volume+=t.VOLUME_STEP}),this.add("ArrowRight",()=>{this.art.forward=t.SEEK_STEP}),this.add("ArrowDown",()=>{this.art.volume-=t.VOLUME_STEP})),this.art.on("document:keydown",t=>{if(this.art.isFocus){const e=document.activeElement.tagName.toUpperCase(),r=document.activeElement.getAttribute("contenteditable");if("INPUT"!==e&&"TEXTAREA"!==e&&""!==r&&"true"!==r&&!t.altKey&&!t.ctrlKey&&!t.metaKey&&!t.shiftKey){const e=this.keys[t.code];if(e){t.preventDefault();for(let r=0;r\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n',state:'\r\n\r\n\r\n',play:'\r\n \r\n',pause:'\r\n \r\n',check:'\r\n\r\n',volume:'\r\n \r\n \r\n',volumeClose:'\r\n \r\n \r\n',screenshot:'\r\n\t\r\n\r\n',setting:'\r\n \r\n \r\n',pip:'\r\n\r\n',arrowLeft:'\r\n \r\n',arrowRight:'\r\n \r\n',playbackRate:'',aspectRatio:'',config:'',lock:'\r\n\r\n\r\n\r\n\r\n',flip:'\r\n\r\n\r\n\r\n\r\n\r\n',unlock:'\r\n\r\n\r\n',fullscreenOff:'\r\n\r\n\r\n\r\n\r\n',fullscreenOn:'\r\n\r\n\r\n\r\n\r\n',fullscreenWebOff:'\r\n\r\n\r\n\r\n\r\n',fullscreenWebOn:'\r\n\r\n\r\n\r\n\r\n',switchOn:'\r\n\r\n\r\n \r\n',switchOff:'\r\n\r\n\r\n \r\n\r\n',error:'\r\n\r\n\r\n\r\n\r\n',close:'\r\n\r\n\r\n\r\n\r\n',airplay:'\r\n \r\n \r\n \r\n \r\n\r\n'},t.option.icons);for(const r in e)nt(this,r,{get:()=>D(r,e[r])})}}class Xt extends Et{constructor(t){super(t),this.name="info",k||this.init()}init(){const{proxy:t,constructor:e,template:{$infoPanel:r,$infoClose:o,$video:a}}=this.art;t(o,"click",()=>{this.show=!1});let n=()=>{};const i=T("[data-video]",r)||[];this.art.on("destroy",()=>n());const s=Pt(this.art);!function t(){for(let e=0;e{P(a,"display","none"),P(n,"display",null)}),o.proxy(e.$state,"click",()=>G(t.play()))}}class Jt{constructor(t){this.art=t,this.timer=null,Pt(t).add(()=>this.destroy()),t.on("destroy",()=>this.destroy())}destroy(){this.timer&&(clearTimeout(this.timer),this.timer=null)}set show(t){if(Pt(this.art).closed)return;const{constructor:e,template:{$player:r,$noticeInner:o}}=this.art;t?(o.textContent=t instanceof Error?t.message.trim():t,C(r,"art-notice-show"),clearTimeout(this.timer),this.timer=setTimeout(()=>{o.textContent="",z(r,"art-notice-show")},e.NOTICE_TIME)):z(r,"art-notice-show")}get show(){const{template:{$player:t}}=this.art;return t.classList.contains("art-notice-show")}}const Qt=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],te=(()=>{if("undefined"===typeof document)return!1;const t=Qt[0],e={};for(const r of Qt){if(r[1]in document){for(const[o,a]of r.entries())e[t[o]]=a;return e}}return!1})(),ee={change:te.fullscreenchange,error:te.fullscreenerror},re={request:(t=document.documentElement,e)=>new Promise((r,o)=>{const a=()=>{re.off("change",a),r()};re.on("change",a);const n=t[te.requestFullscreen](e);n instanceof Promise&&n.then(a).catch(o)}),exit:()=>new Promise((t,e)=>{if(!re.isFullscreen)return void t();const r=()=>{re.off("change",r),t()};re.on("change",r);const o=document[te.exitFullscreen]();o instanceof Promise&&o.then(r).catch(e)}),toggle:(t,e)=>re.isFullscreen?re.exit():re.request(t,e),onchange(t){re.on("change",t)},onerror(t){re.on("error",t)},on(t,e){const r=ee[t];r&&document.addEventListener(r,e,!1)},off(t,e){const r=ee[t];r&&document.removeEventListener(r,e,!1)},raw:te};function oe(t){const{i18n:e,notice:r,template:{$video:o,$player:a}}=t,n=t=>{re.on("change",()=>{t.emit("fullscreen",re.isFullscreen),re.isFullscreen?(t.state="fullscreen",C(a,"art-fullscreen")):z(a,"art-fullscreen"),t.emit("resize")}),re.on("error",e=>{t.emit("fullscreenError",e)}),nt(t,"fullscreen",{get:()=>re.isFullscreen,set(t){return d(this,null,function*(){t?yield re.request(a):yield re.exit()})}})};t.once("video:loadedmetadata",()=>{var a;re.isEnabled?n(t):o.webkitSupportsFullscreen?((a=t).on("document:webkitfullscreenchange",()=>{a.emit("fullscreen",a.fullscreen),a.emit("resize")}),nt(a,"fullscreen",{get:()=>document.fullscreenElement===o,set(t){t?(a.state="fullscreen",o.webkitEnterFullscreen()):o.webkitExitFullscreen()}})):nt(t,"fullscreen",{get:()=>!1,set(){r.show=e.get("Fullscreen Not Supported")}}),nt(t,"fullscreen",lt(t,"fullscreen"))})}function ae(t){const{icons:e,proxy:r,storage:o,template:{$player:a,$video:n}}=t;let i=!1,s=0,l=0;function c(){const{$mini:e}=t.template;e&&(z(a,"art-mini"),P(e,"display","none"),a.prepend(n),t.emit("mini",!1))}function d(e,r){t.playing?(P(e,"display","none"),P(r,"display","flex")):(P(e,"display","flex"),P(r,"display","none"))}function p(){const{$mini:e}=t.template,r=B(e),a=window.innerHeight-r.height-50,n=window.innerWidth-r.width-50;o.set("top",a),o.set("left",n),P(e,"top",`${a}px`),P(e,"left",`${n}px`)}nt(t,"mini",{get:()=>L(a,"art-mini"),set(h){if(h){t.state="mini",C(a,"art-mini");const h=function(){const{$mini:a}=t.template;if(a)return S(a,n),P(a,"display","flex");{const a=N("div");C(a,"art-mini-popup"),S(document.body,a),t.template.$mini=a,S(a,n);const p=S(a,'
');S(p,e.close),r(p,"click",c);const h=S(a,'
'),u=S(h,e.play),m=S(h,e.pause);return r(u,"click",()=>G(t.play())),r(m,"click",()=>t.pause()),d(u,m),t.on("video:playing",()=>d(u,m)),t.on("video:pause",()=>d(u,m)),t.on("video:timeupdate",()=>d(u,m)),r(a,"mousedown",t=>{i=0===t.button,s=t.pageX,l=t.pageY}),t.on("document:mousemove",t=>{if(i){C(a,"art-mini-dragging");const e=t.pageX-s,r=t.pageY-l;P(a,"transform",`translate(${e}px, ${r}px)`)}}),t.on("document:mouseup",()=>{if(i){i=!1,z(a,"art-mini-dragging");const t=B(a);o.set("left",t.left),o.set("top",t.top),P(a,"left",`${t.left}px`),P(a,"top",`${t.top}px`),P(a,"transform",null)}}),a}}(),u=o.get("top"),m=o.get("left");"number"===typeof u&&"number"===typeof m?(P(h,"top",`${u}px`),P(h,"left",`${m}px`),_(h)||p()):p(),t.emit("mini",!0)}else c()}})}function ne(t){const{i18n:e,notice:r,template:{$video:o}}=t;document.pictureInPictureEnabled?function(t){const{template:{$video:e},proxy:r,notice:o}=t;e.disablePictureInPicture=!1,nt(t,"pip",{get:()=>document.pictureInPictureElement,set(r){r?(t.state="pip",e.requestPictureInPicture().catch(t=>{throw o.show=t,t})):document.exitPictureInPicture().catch(t=>{throw o.show=t,t})}}),r(e,"enterpictureinpicture",()=>{t.emit("pip",!0)}),r(e,"leavepictureinpicture",()=>{t.emit("pip",!1)})}(t):o.webkitSupportsPresentationMode?function(t){const{$video:e}=t.template;e.webkitSetPresentationMode("inline"),nt(t,"pip",{get:()=>"picture-in-picture"===e.webkitPresentationMode,set(r){r?(t.state="pip",e.webkitSetPresentationMode("picture-in-picture"),t.emit("pip",!0)):(e.webkitSetPresentationMode("inline"),t.emit("pip",!1))}})}(t):nt(t,"pip",{get:()=>!1,set(){r.show=e.get("PIP Not Supported")}})}function ie(t){const{option:e,template:{$progress:r,$video:o}}=t;let a=null,n=!1,i=null;t.on("setBar",(a,s,l)=>d(null,null,function*(){var c;const d=null==(c=t.controls)?void 0:c.thumbnails,{url:p,scale:h}=e.thumbnails;if(!d||!p)return;if("hover"===a||"played"===a&&l&&k){if(i||n||(n=!0,i=yield W(p,h),n=!1),!i)return;const a=r.clientWidth*s;a>0&&ar.clientWidth-u/2?P(s,"left",r.clientWidth-u+"px"):P(s,"left",a-u/2+"px")}(a)}})),nt(t,"thumbnails",{get:()=>t.option.thumbnails,set(e){e.url&&!t.option.isLive&&(t.option.thumbnails=e,clearTimeout(a),a=null,n=!1,i=null)}})}Object.defineProperties(re,{isFullscreen:{get:()=>Boolean(document[te.fullscreenElement])},element:{enumerable:!0,get:()=>document[te.fullscreenElement]},isEnabled:{enumerable:!0,get:()=>Boolean(document[te.fullscreenEnabled])}});class se{constructor(t){!function(t){const{option:e,template:{$video:r}}=t;nt(t,"url",{get:()=>r.src,set(o){return d(this,null,function*(){if(o){const a=t.url,n=e.type||K(o),i=e.customType[n];if(n&&i){if(!(yield Rt(Pt(t)))||Pt(t).closed)return;t.loading.show=!0,i.call(t,r,o,t)}else URL.revokeObjectURL(a),r.src=o;a!==t.url&&(t.option.url=o,t.isReady&&a&&t.once("video:canplay",()=>{t.emit("restart",o)}))}else{if(!(yield Rt(Pt(t)))||Pt(t).closed)return;t.loading.show=!0}})}})}(t),function(t){const{template:{$video:e}}=t;nt(t,"attr",{value(t,r){if(void 0===r)return e[t];e[t]=r}})}(t),function(t){const{i18n:e,notice:r,option:o,constructor:{instances:a},template:{$video:n}}=t;nt(t,"play",{value(){return d(this,null,function*(){const i=yield n.play();if(r.show=e.get("Play"),t.emit("play"),o.mutex)for(let e=0;et.playing?t.pause():t.play()})}(t),function(t){const{notice:e}=t;nt(t,"seek",{set(r){t.currentTime=r,t.duration&&(e.show=`${tt(t.currentTime)} / ${tt(t.duration)}`),t.emit("seek",t.currentTime,r)}}),nt(t,"forward",{set(e){t.seek=t.currentTime+e}}),nt(t,"backward",{set(e){t.seek=t.currentTime-e}})}(t),function(t){const{template:{$video:e},i18n:r,notice:o,storage:a}=t;nt(t,"volume",{get:()=>e.volume||0,set:t=>{e.volume=J(t,0,1),o.show=`${r.get("Volume")}: ${Number.parseInt(100*e.volume,10)}`,0!==e.volume&&a.set("volume",e.volume)}}),nt(t,"muted",{get:()=>e.muted,set:r=>{e.muted=r,t.emit("muted",r)}})}(t),function(t){const{$video:e}=t.template;nt(t,"currentTime",{get:()=>e.currentTime||0,set:r=>{r=Number.parseFloat(r),Number.isNaN(r)||(e.currentTime=J(r,0,t.duration))}})}(t),function(t){nt(t,"duration",{get:()=>{const{duration:e}=t.template.$video;return e===1/0?0:e||0}})}(t),function(t){function e(e,r){return new Promise((o,a)=>{if(e===t.url)return void o();const{playing:n,aspectRatio:i,playbackRate:s}=t;t.pause(),t.url=e,t.notice.show="";const l={error:e=>{t.off("video:canplay",l.canplay),t.off("video:loadedmetadata",l.metadata),a(e)},metadata:()=>{t.currentTime=r},canplay:()=>d(null,null,function*(){t.off("video:error",l.error),t.playbackRate=s,t.aspectRatio=i,n&&(yield G(t.play())),t.notice.show="",o()})};t.once("video:error",l.error),t.once("video:loadedmetadata",l.metadata),t.once("video:canplay",l.canplay)})}nt(t,"switchQuality",{value:r=>e(r,t.currentTime)}),nt(t,"switchUrl",{value:t=>e(t,0)}),nt(t,"switch",{set:t.switchUrl})}(t),function(t){const{template:{$video:e},i18n:r,notice:o}=t;nt(t,"playbackRate",{get:()=>e.playbackRate,set(a){if(a){if(a===e.playbackRate)return;e.playbackRate=a,o.show=`${r.get("Rate")}: ${1===a?r.get("Normal"):`${a}x`}`}else t.playbackRate=1}})}(t),function(t){const{i18n:e,notice:r,template:{$video:o,$player:a}}=t;nt(t,"aspectRatio",{get:()=>a.dataset.aspectRatio||"default",set(n){if(n||(n="default"),"default"===n)P(o,"width",null),P(o,"height",null),P(o,"margin",null),delete a.dataset.aspectRatio;else{const t=n.split(":").map(Number),{clientWidth:e,clientHeight:r}=a,i=e/r,s=t[0]/t[1];i>s?(P(o,"width",s*r+"px"),P(o,"height","100%"),P(o,"margin","0 auto")):(P(o,"width","100%"),P(o,"height",e/s+"px"),P(o,"margin","auto 0")),a.dataset.aspectRatio=n}r.show=`${e.get("Aspect Ratio")}: ${"default"===n?e.get("Default"):n}`,t.emit("aspectRatio",n)}})}(t),function(t){const{notice:e,template:{$video:r}}=t,o=N("canvas");nt(t,"getDataURL",{value:()=>new Promise((t,a)=>{try{o.width=r.videoWidth,o.height=r.videoHeight,o.getContext("2d").drawImage(r,0,0),t(o.toDataURL("image/png"))}catch(n){e.show=n,a(n)}})}),nt(t,"getBlobUrl",{value:()=>new Promise((t,a)=>{try{o.width=r.videoWidth,o.height=r.videoHeight,o.getContext("2d").drawImage(r,0,0),o.toBlob(e=>{t(URL.createObjectURL(e))})}catch(n){e.show=n,a(n)}})}),nt(t,"screenshot",{value:e=>d(null,null,function*(){const o=yield t.getDataURL();return Z(o,`${e||`artplayer_${tt(r.currentTime)}`}.png`),t.emit("screenshot",o),o})})}(t),oe(t),function(t){const{constructor:e,template:{$container:r,$player:o}}=t;let a="";nt(t,"fullscreenWeb",{get:()=>L(o,"art-fullscreen-web"),set(n){n?(a=o.style.cssText,e.FULLSCREEN_WEB_IN_BODY&&S(document.body,o),t.state="fullscreenWeb",P(o,"width","100%"),P(o,"height","100%"),C(o,"art-fullscreen-web"),t.emit("fullscreenWeb",!0)):(e.FULLSCREEN_WEB_IN_BODY&&S(r,o),a&&(o.style.cssText=a,a=""),z(o,"art-fullscreen-web"),t.emit("fullscreenWeb",!1)),t.emit("resize")}})}(t),ne(t),function(t){const{$video:e}=t.template;nt(t,"loaded",{get:()=>t.loadedTime/e.duration}),nt(t,"loadedTime",{get:()=>e.buffered.length?e.buffered.end(e.buffered.length-1):0})}(t),function(t){nt(t,"played",{get:()=>t.currentTime/t.duration})}(t),function(t){const{$video:e}=t.template;nt(t,"playing",{get:()=>"boolean"===typeof e.playing?e.playing:!!(e.currentTime>0&&!e.paused&&!e.ended&&e.readyState>2)})}(t),function(t){const{$container:e,$player:r,$video:o}=t.template;nt(t,"autoSize",{value(){const{videoWidth:a,videoHeight:n}=o,{width:i,height:s}=B(e),l=a/n;if(i/s>l)P(r,"width",s*l/i*100+"%"),P(r,"height","100%");else{const t=i/l/s*100;P(r,"width","100%"),P(r,"height",`${t}%`)}t.emit("autoSize",{width:t.width,height:t.height})}})}(t),function(t){const e=t;nt(t,"rect",{get:()=>B(t.template.$player)});const r=["bottom","height","left","right","top","width"];for(let o=0;oe.rect[a]})}nt(t,"x",{get:()=>e.left+window.pageXOffset}),nt(t,"y",{get:()=>e.top+window.pageYOffset})}(t),function(t){const{template:{$player:e},i18n:r,notice:o}=t;nt(t,"flip",{get:()=>e.dataset.flip||"normal",set(a){a||(a="normal"),"normal"===a?delete e.dataset.flip:e.dataset.flip=a,o.show=`${r.get("Video Flip")}: ${r.get(Q(a))}`,t.emit("flip",a)}})}(t),ae(t),function(t){const{template:{$poster:e}}=t;nt(t,"poster",{get:()=>{try{return e.style.backgroundImage.match(/"(.*)"/)[1]}catch(t){return""}},set(t){P(e,"backgroundImage",`url(${t})`)}})}(t),function(t){const{template:{$container:e,$video:r}}=t;nt(t,"autoHeight",{value(){const{clientWidth:o}=e,{videoHeight:a,videoWidth:n}=r,i=a*(o/n);P(e,"height",`${i}px`),t.emit("autoHeight",i)}})}(t),function(t){const{$player:e}=t.template;nt(t,"cssVar",{value:(t,r)=>r?e.style.setProperty(t,r):getComputedStyle(e).getPropertyValue(t)})}(t),function(t){nt(t,"theme",{get:()=>t.cssVar("--art-theme"),set(e){t.cssVar("--art-theme",e)}})}(t),function(t){nt(t,"type",{get:()=>t.option.type,set(e){t.option.type=e}})}(t),function(t){const e=["mini","pip","fullscreen","fullscreenWeb"];nt(t,"state",{get:()=>e.find(e=>t[e])||"standard",set(r){for(let o=0;o{switch(t.availability){case"available":n=!0;break;case"not-available":n=!1}}):n=!1,nt(t,"airplay",{value(){n?(a.webkitShowPlaybackTargetPicker(),t.emit("airplay")):r.show=e.get("AirPlay Not Available")}})}(t),function(t){nt(t,"quality",{set(e){const{controls:r,notice:o,i18n:a}=t,n=e.find(t=>t.default)||e[0];r.update({name:"quality",position:"right",index:10,style:{marginRight:"10px"},html:(null==n?void 0:n.html)||"",selector:e,onSelect(e){return d(this,null,function*(){return yield t.switchQuality(e.url),o.show=`${a.get("Switch Video")}: ${e.html}`,e.html})}})}})}(t),ie(t),function(t){const{i18n:e,notice:r,option:o,constructor:a,proxy:n,template:{$player:i,$video:s,$poster:l}}=t;let c=0;for(let d=0;d{t.emit(`video:${e.type}`,e)});t.on("video:canplay",()=>{c=0,t.loading.show=!1}),t.once("video:canplay",()=>{t.loading.show=!1,t.controls.show=!0,t.mask.show=!0,t.isReady=!0,t.emit("ready")}),t.on("video:ended",()=>{o.loop?(t.seek=0,G(t.play()),t.controls.show=!1,t.mask.show=!1):(t.controls.show=!0,t.mask.show=!0)}),t.on("video:error",n=>d(null,null,function*(){if(c{t.emit("resize"),k&&(t.loading.show=!1,t.controls.show=!0,t.mask.show=!0)}),t.on("video:loadstart",()=>{t.loading.show=!0,t.mask.show=!1,t.controls.show=!0}),t.on("video:pause",()=>{t.controls.show=!0,t.mask.show=!0}),t.on("video:play",()=>{t.mask.show=!1,P(l,"display","none")}),t.on("video:playing",()=>{t.mask.show=!1}),t.on("video:progress",()=>{t.playing&&(t.loading.show=!1)}),t.on("video:seeked",()=>{t.loading.show=!1,t.mask.show=!0}),t.on("video:seeking",()=>{t.loading.show=!0,t.mask.show=!1}),t.on("video:timeupdate",()=>{t.mask.show=!1}),t.on("video:waiting",()=>{t.loading.show=!0,t.mask.show=!1})}(t),function(t){const{option:e,storage:r,template:{$video:o,$poster:a}}=t;for(const i in e.moreVideoAttr)t.attr(i,e.moreVideoAttr[i]);e.muted&&(t.muted=e.muted),e.volume&&(o.volume=J(e.volume,0,1));const n=r.get("volume");"number"===typeof n&&(o.volume=J(n,0,1)),e.poster&&P(a,"backgroundImage",`url(${e.poster})`),e.autoplay&&(o.autoplay=e.autoplay),e.playsInline&&(o.playsInline=!0,o["webkit-playsinline"]=!0),e.theme&&(e.cssVar["--art-theme"]=e.theme);for(const i in e.cssVar)t.cssVar(i,e.cssVar[i]);t.url=e.url}(t)}}function le(t){const{notice:e,constructor:r,template:{$player:o,$video:a}}=t,n="art-auto-orientation",i="art-auto-orientation-fullscreen";let s=!1;function l(){const{videoWidth:t,videoHeight:e}=a,r=document.documentElement.clientWidth,o=document.documentElement.clientHeight;return t>e&&ro}return t.on("fullscreenWeb",e=>{var a;if(e){if(l()){const e=Number(null!=(a=r.AUTO_ORIENTATION_TIME)?a:0);setTimeout(()=>{t.fullscreenWeb&&!L(o,n)&&function(){const e=U(),r=document.documentElement.clientWidth,a=document.documentElement.clientHeight-e.top-e.bottom,i=r-e.left-e.right;P(o,"width",`${a}px`),P(o,"height",`${i}px`),P(o,"transform-origin","0 0"),P(o,"transform",`rotate(90deg) translate(${e.top}px, -${r-e.right}px)`),C(o,n),t.isRotate=!0,t.emit("resize")}()},e)}}else L(o,n)&&(P(o,"width",""),P(o,"height",""),P(o,"transform-origin",""),P(o,"transform",""),z(o,n),t.isRotate=!1,t.emit("resize"))}),t.on("fullscreen",t=>d(null,null,function*(){var r;const a=!!(null==(r=null==screen?void 0:screen.orientation)?void 0:r.lock);if(t){if(a&&l())try{const t=screen.orientation.type.startsWith("portrait")?"landscape":"portrait";yield screen.orientation.lock(t),s=!0,C(o,i)}catch(n){s=!1,e.show=n}}else if(L(o,i)&&z(o,i),a&&s){try{screen.orientation.unlock()}catch(c){}s=!1}})),{name:"autoOrientation",get state(){return L(o,n)}}}function ce(t){const{i18n:e,icons:r,storage:o,constructor:a,proxy:n,template:{$poster:i}}=t,s=t.layers.add({name:"auto-playback",html:'\n
\n
\n
\n '}),l=E(".art-auto-playback-last",s),c=E(".art-auto-playback-jump",s),d=E(".art-auto-playback-close",s);S(d,r.close);let p=null;function h(){const r=(o.get("times")||{})[t.option.id||t.option.url];clearTimeout(p),P(s,"display","none"),r&&r>=a.AUTO_PLAYBACK_MIN&&(P(s,"display","flex"),l.textContent=`${e.get("Last Seen")} ${tt(r)}`,c.textContent=e.get("Jump Play"),n(d,"click",()=>{P(s,"display","none")}),n(c,"click",()=>{t.seek=r,G(t.play()),P(i,"display","none"),P(s,"display","none")}),t.once("video:timeupdate",()=>{p=setTimeout(()=>{P(s,"display","none")},a.AUTO_PLAYBACK_TIMEOUT)}))}return t.on("video:timeupdate",()=>{if(t.playing){const e=o.get("times")||{},r=Object.keys(e);r.length>a.AUTO_PLAYBACK_MAX&&delete e[r[0]],e[t.option.id||t.option.url]=t.currentTime,o.set("times",e)}}),t.on("ready",h),t.on("restart",h),{name:"auto-playback",get times(){return o.get("times")||{}},clear:()=>o.del("times"),delete(t){const e=o.get("times")||{};return delete e[t],o.set("times",e),e}}}function de(t){const{constructor:e,proxy:r,template:{$player:o,$video:a}}=t;let n=null,i=!1,s=1;const l=()=>{clearTimeout(n),i&&(i=!1,t.playbackRate=s,z(o,"art-fast-forward"))};return r(a,"touchstart",r=>{1===r.touches.length&&t.playing&&!t.isLock&&(n=setTimeout(()=>{i=!0,s=t.playbackRate,t.playbackRate=e.FAST_FORWARD_VALUE,C(o,"art-fast-forward")},e.FAST_FORWARD_TIME))}),t.on("document:touchmove",l),t.on("document:touchend",l),{name:"fastForward",get state(){return L(o,"art-fast-forward")}}}function pe(t){const{layers:e,icons:r,template:{$player:o}}=t;function a(){return L(o,"art-lock")}function n(){C(o,"art-lock"),t.isLock=!0,t.emit("lock",!0)}function i(){z(o,"art-lock"),t.isLock=!1,t.emit("lock",!1)}return e.add({name:"lock",mounted(e){const o=S(e,r.lock),a=S(e,r.unlock);P(o,"display","none"),t.on("lock",t=>{t?(P(o,"display","inline-flex"),P(a,"display","none")):(P(o,"display","none"),P(a,"display","inline-flex"))})},click(){a()?i():n()}}),{name:"lock",get state(){return a()},set state(t){t?n():i()}}}function he(t){return t.on("control",e=>{e?z(t.template.$player,"art-mini-progress-bar"):C(t.template.$player,"art-mini-progress-bar")}),{name:"mini-progress-bar"}}class ue{constructor(t){this.art=t,this.id=0;const{option:e}=t;!function(t,e){At(t.art)||!e.miniProgressBar||e.isLive||t.add(he),!At(t.art)&&e.lock&&k&&t.add(pe),At(t.art)||!e.autoPlayback||e.isLive||t.add(ce),!At(t.art)&&e.autoOrientation&&k&&t.add(le),!At(t.art)&&e.fastForward&&k&&!e.isLive&&t.add(de)}(this,e);for(let r=0;rconsole.warn("Failed to initialize ArtPlayer plugin:",t))}}add(t){X(!At(this.art),"Cannot add a plugin after ArtPlayer is destroyed"),this.id+=1;const e=t.call(this.art,this.art);return e instanceof Promise?e.then(e=>this.next(t,e)):this.next(t,e)}next(t,e){return function(t,e,r){if(At(t.art))return t;const o=r&&r.name||e.name||`plugin${t.id}`;if(At(t.art))return t;let a=o;const n=st(t,a);if(At(t.art))return t;const i=`Cannot add a plugin that already has the same name: ${o}`;return At(t.art)||(X(!n,i),("object"===typeof o&&null!==o||"function"===typeof o)&&(a=Reflect.ownKeys({[a]:void 0})[0]),At(t.art)||nt(t,a,{value:r})),t}(this,t,e)}}class me extends Et{constructor(t){super(t);const{option:e,controls:r,template:{$setting:o}}=t;this.name="setting",this.$parent=o,this.id=0,this.active=null,this.cache=new Map,this.option=[...this.builtin,...e.settings],e.setting&&(this.format(),this.render(),t.on("blur",()=>{this.show&&(this.show=!1,this.render())}),t.on("focus",t=>{const e=V(t,r.setting),o=V(t,this.$parent);!this.show||e||o||(this.show=!1,this.render())}),t.on("resize",()=>this.resize()))}get builtin(){const t=[],{option:e}=this.art;return e.playbackRate&&t.push(function(t){const{i18n:e,icons:r,constructor:{SETTING_ITEM_WIDTH:o,PLAYBACK_RATE:a}}=t;function n(t){return 1===t?e.get("Normal"):t.toFixed(1)}function i(){const e=t.setting.find(`playback-rate-${t.playbackRate}`);t.setting.check(e)}return{width:o,name:"playback-rate",html:e.get("Play Speed"),tooltip:n(t.playbackRate),icon:r.playbackRate,selector:a.map(e=>({value:e,name:`playback-rate-${e}`,default:e===t.playbackRate,html:n(e)})),onSelect:e=>(t.playbackRate=e.value,e.html),mounted:()=>{i(),t.on("video:ratechange",()=>i())}}}(this.art)),e.aspectRatio&&t.push(function(t){const{i18n:e,icons:r,constructor:{SETTING_ITEM_WIDTH:o,ASPECT_RATIO:a}}=t;function n(t){return"default"===t?e.get("Default"):t}function i(){const e=t.setting.find(`aspect-ratio-${t.aspectRatio}`);t.setting.check(e)}return{width:o,name:"aspect-ratio",html:e.get("Aspect Ratio"),icon:r.aspectRatio,tooltip:n(t.aspectRatio),selector:a.map(e=>({value:e,name:`aspect-ratio-${e}`,default:e===t.aspectRatio,html:n(e)})),onSelect:e=>(t.aspectRatio=e.value,e.html),mounted:()=>{i(),t.on("aspectRatio",()=>i())}}}(this.art)),e.flip&&t.push(function(t){const{i18n:e,icons:r,constructor:{SETTING_ITEM_WIDTH:o,FLIP:a}}=t;function n(t){return e.get(Q(t))}function i(){const e=t.setting.find(`flip-${t.flip}`);t.setting.check(e)}return{width:o,name:"flip",html:e.get("Video Flip"),tooltip:n(t.flip),icon:r.flip,selector:a.map(e=>({value:e,name:`flip-${e}`,default:e===t.flip,html:n(e)})),onSelect:e=>(t.flip=e.value,e.html),mounted:()=>{i(),t.on("flip",()=>i())}}}(this.art)),e.subtitleOffset&&t.push(function(t){const{i18n:e,icons:r,constructor:o}=t;return{width:o.SETTING_ITEM_WIDTH,name:"subtitle-offset",html:e.get("Subtitle Offset"),icon:r.subtitle,tooltip:"0s",range:[0,-10,10,.1],onChange:e=>(t.subtitleOffset=e.range[0],`${e.range[0]}s`),mounted:(e,r)=>{t.on("subtitleOffset",t=>{r.$range.value=t,r.tooltip=`${t}s`})}}}(this.art)),t}traverse(t,e=this.option){var r;for(let o=0;o{e.default=e===t,e.default&&e.$item&&O(e.$item,"art-current")},t.$option),this.render(t.$parents))}format(t=this.option,e,r,o=[]){for(let a=0;ae}),nt(n,"$parents",{get:()=>r}),nt(n,"$option",{get:()=>t});const o=[];nt(n,"$events",{get:()=>o}),nt(n,"$formatted",{get:()=>!0})}this.format(n.selector||[],n,t,o)}this.option=t}find(t=""){let e=null;return this.traverse(r=>{r.name===t&&(e=r)}),e}resize(){var t,e;const{controls:r,constructor:{SETTING_WIDTH:o,SETTING_ITEM_HEIGHT:a},template:{$player:n,$setting:i}}=this.art;if(r.setting&&this.show){const s=(null==(e=null==(t=this.active[0])?void 0:t.$parent)?void 0:e.width)||o,{left:l,width:c}=B(r.setting),{left:d,width:p}=B(n),h=l-d+c/2-s/2;if(P(i,"height",`${this.active===this.option?this.active.length*a:(this.active.length+1)*a}px`),P(i,"width",`${s}px`),this.art.isRotate||k)return;h+s>p?(P(i,"left",null),P(i,"right",null)):(P(i,"left",`${h}px`),P(i,"right","auto"))}}inactivate(t){for(let e=0;e'),s=N("div");C(s,"art-setting-item-left-icon"),S(s,o),S(i,s),S(i,t.$parent.html);const l=r(n,"click",()=>this.render(t.$parents));t.$parent.$events.push(l),S(e,n)}createItem(t,e=!1){var r,o;if(!this.cache.has(t.$option))return;const a=this.cache.get(t.$option),n=t.$item;let i="selector";st(t,"switch")&&(i="switch"),st(t,"range")&&(i="range"),st(t,"onClick")&&(i="button");const{icons:s,proxy:l,constructor:c}=this.art,p=N("div");C(p,"art-setting-item"),P(p,"height",`${c.SETTING_ITEM_HEIGHT}px`),p.dataset.name=t.name||"",p.dataset.value=t.value||"";const h=S(p,'
'),u=S(p,'
'),m=N("div");switch(C(m,"art-setting-item-left-icon"),i){case"button":case"switch":case"range":S(m,t.icon||s.config);break;case"selector":(null==(r=t.selector)?void 0:r.length)?S(m,t.icon||s.config):S(m,s.check)}S(h,m),nt(t,"$icon",{configurable:!0,get:()=>m}),nt(t,"icon",{configurable:!0,get:()=>m.innerHTML,set(t){m.innerHTML="",S(m,t)}});const f=N("div");C(f,"art-setting-item-left-text"),S(f,t.html||""),S(h,f),nt(t,"$html",{configurable:!0,get:()=>f}),nt(t,"html",{configurable:!0,get:()=>f.innerHTML,set(t){f.innerHTML="",S(f,t)}});const g=N("div");switch(C(g,"art-setting-item-right-tooltip"),S(g,t.tooltip||""),S(u,g),nt(t,"$tooltip",{configurable:!0,get:()=>g}),nt(t,"tooltip",{configurable:!0,get:()=>g.innerHTML,set(t){g.innerHTML="",S(g,t)}}),i){case"switch":{const e=N("div");C(e,"art-setting-item-right-icon");const r=S(e,s.switchOn),o=S(e,s.switchOff);P(t.switch?o:r,"display","none"),S(u,e),nt(t,"$switch",{configurable:!0,get:()=>e});let a=t.switch;nt(t,"switch",{configurable:!0,get:()=>a,set(t){a=t,t?(P(o,"display","none"),P(r,"display",null)):(P(o,"display",null),P(r,"display","none"))}});break}case"range":{const e=N("div");C(e,"art-setting-item-right-icon");const r=S(e,'');r.value=t.range[0],r.min=t.range[1],r.max=t.range[2],r.step=t.range[3],C(r,"art-setting-range"),S(u,e),nt(t,"$range",{configurable:!0,get:()=>r});let o=[...t.range];nt(t,"range",{configurable:!0,get:()=>o,set(t){o=[...t],r.value=t[0],r.min=t[1],r.max=t[2],r.step=t[3]}})}break;case"selector":if(null==(o=t.selector)?void 0:o.length){const t=N("div");C(t,"art-setting-item-right-icon"),S(t,s.arrowRight),S(u,t)}}switch(i){case"switch":if(t.onSwitch){const e=l(p,"click",e=>d(this,null,function*(){t.switch=yield t.onSwitch.call(this.art,t,p,e)}));t.$events.push(e)}break;case"range":if(t.$range){if(t.onRange){const e=l(t.$range,"change",e=>d(this,null,function*(){t.range[0]=t.$range.valueAsNumber,t.tooltip=yield t.onRange.call(this.art,t,p,e)}));t.$events.push(e)}if(t.onChange){const e=l(t.$range,"input",e=>d(this,null,function*(){t.range[0]=t.$range.valueAsNumber,t.tooltip=yield t.onChange.call(this.art,t,p,e)}));t.$events.push(e)}}break;case"selector":{const e=l(p,"click",e=>d(this,null,function*(){var r;(null==(r=t.selector)?void 0:r.length)?this.render(t.selector):(this.check(t),t.$parent.onSelect&&(t.$parent.tooltip=yield t.$parent.onSelect.call(this.art,t,p,e)))}));t.$events.push(e),t.default&&C(p,"art-current")}break;case"button":if(t.onClick){const e=l(p,"click",e=>d(this,null,function*(){t.tooltip=yield t.onClick.call(this.art,t,p,e)}));t.$events.push(e)}}nt(t,"$item",{configurable:!0,get:()=>p}),e?Y(p,n):S(a,p),t.mounted&&Ot(Pt(this.art),()=>t.mounted.call(this.art,t.$item,t),0)}render(t=this.option){var e;if(this.active=t,this.cache.has(t)){O(this.cache.get(t),"art-current")}else{const r=N("div");this.cache.set(t,r),C(r,"art-setting-panel"),S(this.$parent,r),O(r,"art-current"),(null==(e=t[0])?void 0:e.$parent)&&this.createHeader(t[0]);for(let e=0;enull,this.init(t.option.subtitle);let e=!1;t.on("video:timeupdate",()=>{if(!this.url)return;const t=this.art.template.$video.webkitDisplayingFullscreen;"boolean"===typeof t&&t!==e&&(e=t,this.createTrack(t?"subtitles":"metadata",this.url))})}get url(){return this.art.template.$track.src}set url(t){this.switch(t)}get textTrack(){var t,e;return null==(e=null==(t=this.art.template.$video)?void 0:t.textTracks)?void 0:e[0]}get activeCues(){return this.textTrack?Array.from(this.textTrack.activeCues):[]}get cues(){return this.textTrack?Array.from(this.textTrack.cues):[]}style(t,e){const{$subtitle:r}=this.art.template;return"object"===typeof t?A(r,t):P(r,t,e)}update(){const{option:{subtitle:t},template:{$subtitle:e}}=this.art;e.innerHTML="",this.activeCues.length&&(this.art.emit("subtitleBeforeUpdate",this.activeCues),e.innerHTML=this.activeCues.map((e,r)=>e.text.split(/\r?\n/).filter(t=>t.trim()).map(e=>`
\n ${t.escape?at(e):e}\n
`).join("")).join(""),this.art.emit("subtitleAfterUpdate",this.activeCues))}switch(t){return d(this,arguments,function*(t,e={}){const{i18n:r,notice:o,option:a}=this.art,n=c(l(l({},a.subtitle),e),{url:t}),i=yield this.init(n);return e.name&&(o.show=`${r.get("Switch Subtitle")}: ${e.name}`),i})}createTrack(t,e){const{template:r,proxy:o,option:a}=this.art,{$video:n,$track:i}=r,s=N("track");s.default=!0,s.kind=t,s.src=e,s.label=a.subtitle.name||"Artplayer",s.track.mode="hidden",s.onload=()=>{this.art.emit("subtitleLoad",this.cues,this.option)},this.art.events.remove(this.destroyEvent),i.onload=null,M(i),S(n,s),r.$track=s,this.destroyEvent=o(this.textTrack,"cuechange",()=>this.update())}init(t){return d(this,null,function*(){const{notice:e,template:{$subtitle:r}}=this.art;return this.textTrack?(f(t,$t.subtitle),t.url?(this.option=t,this.style(t.style),fetch(t.url).then(t=>t.arrayBuffer()).then(e=>{const r=new TextDecoder(t.encoding).decode(e);switch(t.type||K(t.url)){case"srt":{const e=dt(r);return pt(t.onVttLoad(e))}case"ass":{const e=ht(r);return pt(t.onVttLoad(e))}case"vtt":return pt(t.onVttLoad(r));default:return t.url}}).then(t=>(r.innerHTML="",this.url===t||(URL.revokeObjectURL(this.url),this.createTrack("metadata",t)),t)).catch(t=>{throw r.innerHTML="",e.show=t,t})):void 0):null})}}class ye{constructor(t){this.art=t;const{option:e,constructor:r}=t;e.container instanceof Element?this.$container=e.container:(this.$container=E(e.container),X(this.$container,`No container element found by ${e.container}`)),X(H(),"The current browser does not support flex layout");const o=this.$container.tagName.toLowerCase();X("div"===o,`Unsupported container element type, only support 'div' but got '${o}'`),X(r.instances.every(t=>t.template.$container!==this.$container),"Cannot mount multiple instances on the same dom element"),this.query=this.query.bind(this),function(t,e,r){const o=St.get(e);if(o&&o!==t)throw new Error("Cannot mount multiple instances on the same dom element");const a=Mt(t);a.rollback=r,St.set(e,t),a.releaseContainer=()=>{St.get(e)===t&&St.delete(e)}}(t,this.$container,function(t){const e=[];return function t(r){const o=Array.from(r.childNodes);e.push({node:r,children:o,attributes:1===r.nodeType?Array.from(r.attributes,t=>[t.name,t.value]):void 0,value:r.nodeValue}),o.forEach(t)}(t),()=>{for(const{node:t,children:r,attributes:o,value:a}of e){for(;t.firstChild;)t.removeChild(t.firstChild);for(const e of r)t.appendChild(e);if(o){const e=t;for(const t of Array.from(e.attributes))e.removeAttribute(t.name);for(const[t,r]of o)e.setAttribute(t,r)}else t.nodeValue=a}}}(this.$container)),this.$container.dataset.artId=t.id,this.init()}static get html(){return`\n
\n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
Player version:
\n
${g}
\n
\n
\n
Video url:
\n
\n
\n
\n
Video volume:
\n
\n
\n
\n
Video time:
\n
\n
\n
\n
Video duration:
\n
\n
\n
\n
Video resolution:
\n
\n x \n
\n
\n
\n
[x]
\n
\n
\n
\n `}query(t){return E(t,this.$container)}init(){const{option:t}=this.art;if(t.useSSR||(this.$container.innerHTML=ye.html),this.$player=this.query(".art-video-player"),this.$video=this.query(".art-video"),this.$track=this.query("track"),this.$poster=this.query(".art-poster"),this.$subtitle=this.query(".art-subtitle"),this.$danmuku=this.query(".art-danmuku"),this.$bottom=this.query(".art-bottom"),this.$progress=this.query(".art-progress"),this.$controls=this.query(".art-controls"),this.$controlsLeft=this.query(".art-controls-left"),this.$controlsCenter=this.query(".art-controls-center"),this.$controlsRight=this.query(".art-controls-right"),this.$layer=this.query(".art-layers"),this.$loading=this.query(".art-loading"),this.$notice=this.query(".art-notice"),this.$noticeInner=this.query(".art-notice-inner"),this.$mask=this.query(".art-mask"),this.$state=this.query(".art-state"),this.$setting=this.query(".art-settings"),this.$info=this.query(".art-info"),this.$infoPanel=this.query(".art-info-panel"),this.$infoClose=this.query(".art-info-close"),this.$contextmenu=this.query(".art-contextmenus"),t.proxy){const e=t.proxy.call(this.art,this.art);X(e instanceof HTMLVideoElement||e instanceof HTMLCanvasElement,"Function 'option.proxy' needs to return 'HTMLVideoElement' or 'HTMLCanvasElement'"),Y(e,this.$video),e.className="art-video",this.$video=e}t.backdrop&&C(this.$player,"art-backdrop"),k&&C(this.$player,"art-mobile")}destroy(t){t?this.$container.innerHTML="":C(this.$player,"art-destroy")}}const be=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);class we{on(t,e,r){const o=this.e||(this.e={});let a=be(o,t)?o[t]:void 0;return a||(a=[],Object.defineProperty(o,t,{value:a,enumerable:!0,configurable:!0,writable:!0})),a.push({fn:e,ctx:r}),this}once(t,e,r){const o=this,a=e;let n=!1;function i(...e){n||(n=!0,o.off(t,i),a.apply(r,e))}return i._=e,this.on(t,i,r)}emit(t,...e){const r=this.e||(this.e={}),o=(be(r,t)&&r[t]||[]).slice();for(const a of o)a.fn.apply(a.ctx,e);return this}off(t,e){const r=this.e||(this.e={}),o=be(r,t)?r[t]:void 0,a=[];if(o&&e)for(let n=0,i=o.length;ne.call(this,this)),$e.DEBUG){const t=t=>console.log(`[ART.${this.id}] -> ${t}`);t(`Version@${$e.version}`);for(let e=0;et(`Event@${e.type}`))}(function(t){const e=Mt(t);return e.rollback=void 0,!e.scope.closed})(this)&&ke.push(this)}catch(o){try{It(this,ke,!0,$e.REMOVE_SRC_WHEN_DESTROY,!0)}catch(a){console.warn("Failed to clean up ArtPlayer initialization:",a)}throw o}}static get instances(){return ke}static get version(){return g}static get config(){return v}static get utils(){return mt}static get scheme(){return $t}static get Emitter(){return we}static get validator(){return f}static get kindOf(){return f.kindOf}static get html(){return ye.html}static get option(){return{id:"",container:"#artplayer",url:"",poster:"",type:"",theme:"#f00",volume:.7,isLive:!1,muted:!1,autoplay:!1,autoSize:!1,autoMini:!1,loop:!1,flip:!1,playbackRate:!1,aspectRatio:!1,screenshot:!1,setting:!1,hotkey:!0,pip:!1,mutex:!0,backdrop:!0,fullscreen:!1,fullscreenWeb:!1,subtitleOffset:!1,miniProgressBar:!1,useSSR:!1,playsInline:!0,lock:!1,gesture:!0,fastForward:!1,autoPlayback:!1,autoOrientation:!1,airplay:!1,proxy:void 0,layers:[],contextmenu:[],controls:[],settings:[],quality:[],highlight:[],plugins:[],thumbnails:{url:"",number:60,column:10,width:0,height:0,scale:1},subtitle:{url:"",type:"",style:{},name:"",escape:!0,encoding:"utf-8",onVttLoad:t=>t},moreVideoAttr:{controls:!1,preload:b?"auto":"metadata"},i18n:{},icons:{},cssVar:{},customType:{},lang:null==navigator?void 0:navigator.language.toLowerCase()}}get proxy(){return this.events.proxy}get query(){return this.template.query}get video(){return this.template.$video}reset(){this.video.removeAttribute("src"),this.video.load()}destroy(t=!0){It(this,ke,t,$e.REMOVE_SRC_WHEN_DESTROY)}}return $e.STYLE=ge,$e.DEBUG=!1,$e.CONTEXTMENU=!0,$e.NOTICE_TIME=2e3,$e.SETTING_WIDTH=250,$e.SETTING_ITEM_WIDTH=200,$e.SETTING_ITEM_HEIGHT=35,$e.RESIZE_TIME=200,$e.SCROLL_TIME=200,$e.SCROLL_GAP=50,$e.AUTO_PLAYBACK_MAX=10,$e.AUTO_PLAYBACK_MIN=5,$e.AUTO_PLAYBACK_TIMEOUT=3e3,$e.RECONNECT_TIME_MAX=5,$e.RECONNECT_SLEEP_TIME=1e3,$e.CONTROL_HIDE_TIME=3e3,$e.DBCLICK_TIME=300,$e.DBCLICK_FULLSCREEN=!0,$e.MOBILE_DBCLICK_PLAY=!0,$e.MOBILE_CLICK_PLAY=!1,$e.AUTO_ORIENTATION_TIME=200,$e.INFO_LOOP_TIME=1e3,$e.FAST_FORWARD_VALUE=3,$e.FAST_FORWARD_TIME=1e3,$e.TOUCH_MOVE_RATIO=.5,$e.VOLUME_STEP=.1,$e.SEEK_STEP=5,$e.PLAYBACK_RATE=[.5,.75,1,1.25,1.5,2],$e.ASPECT_RATIO=["default","4:3","16:9"],$e.FLIP=["normal","horizontal","vertical"],$e.FULLSCREEN_WEB_IN_BODY=!0,$e.LOG_VERSION=!0,$e.USE_RAF=!1,$e.REMOVE_SRC_WHEN_DESTROY=!0,$&&(window.Artplayer=$e,F("artplayer-style",ge),setTimeout(()=>{$e.LOG_VERSION&&console.log(`%c ArtPlayer %c ${$e.version} %c https://artplayer.org`,"color: #fff; background: #5f5f5f","color: #fff; background: #4bc729","")},100)),$e}); +!function(t,e){"object"===typeof exports&&"undefined"!==typeof module?module.exports=e():"function"==typeof define&&define.amd?(t.Artplayer=e(),define(function(){return t.Artplayer})):(t="undefined"!==typeof globalThis?globalThis:t||self).Artplayer=e()}(this,function(){"use strict";var t,e=Object.defineProperty,r=Object.defineProperties,o=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,s=(t,r,o)=>r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o,l=(t,e)=>{for(var r in e||(e={}))a.call(e,r)&&s(t,r,e[r]);if(n)for(var r of n(e))i.call(e,r)&&s(t,r,e[r]);return t},c=(t,e)=>r(t,o(e)),d=(t,e,r)=>new Promise((o,n)=>{var a=t=>{try{s(r.next(t))}catch(e){n(e)}},i=t=>{try{s(r.throw(t))}catch(e){n(e)}},s=t=>t.done?o(t.value):Promise.resolve(t.value).then(a,i);s((r=r.apply(t,e)).next())});function p(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var h,u={exports:{}};var m=(h||(h=1,u.exports=function(){function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}var e=Object.prototype.toString,r=function(r){if(void 0===r)return"undefined";if(null===r)return"null";var n=t(r);if("boolean"===n)return"boolean";if("string"===n)return"string";if("number"===n)return"number";if("symbol"===n)return"symbol";if("function"===n)return"GeneratorFunction"===o(r)?"generatorfunction":"function";if(function(t){return Array.isArray?Array.isArray(t):t instanceof Array}(r))return"array";if(function(t){return!(!t.constructor||"function"!=typeof t.constructor.isBuffer)&&t.constructor.isBuffer(t)}(r))return"buffer";if(function(t){try{if("number"==typeof t.length&&"function"==typeof t.callee)return!0}catch(e){if(-1!==e.message.indexOf("callee"))return!0}return!1}(r))return"arguments";if(function(t){return t instanceof Date||"function"==typeof t.toDateString&&"function"==typeof t.getDate&&"function"==typeof t.setDate}(r))return"date";if(function(t){return t instanceof Error||"string"==typeof t.message&&t.constructor&&"number"==typeof t.constructor.stackTraceLimit}(r))return"error";if(function(t){return t instanceof RegExp||"string"==typeof t.flags&&"boolean"==typeof t.ignoreCase&&"boolean"==typeof t.multiline&&"boolean"==typeof t.global}(r))return"regexp";switch(o(r)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(function(t){return"function"==typeof t.throw&&"function"==typeof t.return&&"function"==typeof t.next}(r))return"generator";switch(n=e.call(r)){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return n.slice(8,-1).toLowerCase().replace(/\s/g,"")};function o(t){return t.constructor?t.constructor.name:null}function n(t,e){var o=2=1,k=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(y)||x,$="undefined"!==typeof window&&"undefined"!==typeof document;function E(t,e=document){return e.querySelector(t)}function T(t,e=document){return Array.from(e.querySelectorAll(t))}function C(t,e){return t.classList.add(e)}function z(t,e){return t.classList.remove(e)}function L(t,e){return t.classList.contains(e)}function S(t,e){return e instanceof Element?t.appendChild(e):t.insertAdjacentHTML("beforeend",String(e)),t.lastElementChild||t.lastChild}function M(t){return t.parentNode.removeChild(t)}function P(t,e,r){return t.style[e]=r,t}function A(t,e){for(const r in e)P(t,r,e[r]);return t}function I(t){return Array.from(t.parentElement.children).filter(e=>e!==t)}function O(t,e){I(t).forEach(t=>z(t,e)),C(t,e)}function R(t,e,r="top"){k||(t.setAttribute("aria-label",e),C(t,"hint--rounded"),C(t,`hint--${r}`))}function _(t,e=0){const r=t.getBoundingClientRect(),o=window.innerHeight||document.documentElement.clientHeight,n=window.innerWidth||document.documentElement.clientWidth,a=r.top-e<=o&&r.top+r.height+e>=0,i=r.left-e<=n+e&&r.left+r.width+e>=0;return a&&i}function V(t,e){return j(t).includes(e)}function Y(t,e){return e.parentNode.replaceChild(t,e),t}function N(t){return document.createElement(t)}function D(t="",e=""){const r=N("i");return C(r,"art-icon"),C(r,`art-icon-${t}`),S(r,e),r}function F(t,e){let r=document.getElementById(t);r||(r=document.createElement("style"),r.id=t,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{document.head.appendChild(r)}):(document.head||document.documentElement).appendChild(r)),r.textContent=e}function H(){const t=document.createElement("div");return t.style.display="flex","flex"===t.style.display}function B(t){return t.getBoundingClientRect()}function W(t,e){return new Promise((r,o)=>{const n=new Image;n.onload=function(){if(e&&1!==e){const a=document.createElement("canvas"),i=a.getContext("2d");a.width=n.width*e,a.height=n.height*e,i.drawImage(n,0,0,a.width,a.height),a.toBlob(e=>{const n=URL.createObjectURL(e),a=new Image;a.onload=function(){r(a)},a.onerror=function(){URL.revokeObjectURL(n),o(new Error(`Image load failed: ${t}`))},a.src=n})}else r(n)},n.onerror=function(){o(new Error(`Image load failed: ${t}`))},n.src=t})}function j(t){if(t.composedPath)return t.composedPath();const e=[];let r=t.target;for(;r;)e.push(r),r=r.parentNode;return e.includes(window)||void 0===window||e.push(window),e}function U(){const t=document.createElement("div");t.style.cssText="position:fixed;top:env(safe-area-inset-top,0px);right:env(safe-area-inset-right,0px);bottom:env(safe-area-inset-bottom,0px);left:env(safe-area-inset-left,0px);pointer-events:none;visibility:hidden;",document.body.appendChild(t);const e=getComputedStyle(t),r={top:Number.parseFloat(e.top)||0,right:Number.parseFloat(e.right)||0,bottom:Number.parseFloat(e.bottom)||0,left:Number.parseFloat(e.left)||0};return t.remove(),r}class q extends Error{constructor(t,e){super(t),"captureStackTrace"in Error&&"function"===typeof Error.captureStackTrace&&Error.captureStackTrace(this,e||this.constructor),this.name="ArtPlayerError"}}function X(t,e){if(!t)throw new q(e);return t}function G(t){const e=t;return e&&"function"===typeof e.catch?e.catch(()=>{}):t}function K(t){const e=t.search(/[?#]/),r=(e<0?t:t.slice(0,e)).trim().toLowerCase();return r.slice(r.lastIndexOf(".")+1)}function Z(t,e){const r=document.createElement("a");r.style.display="none",r.href=t,r.download=e,document.body.appendChild(r);try{r.click()}finally{r.remove()}}function J(t,e,r){return Math.max(Math.min(t,Math.max(e,r)),Math.min(e,r))}function Q(t){return t.charAt(0).toUpperCase()+t.slice(1)}function tt(t){if(!t)return"00:00";const e=Math.floor(t/3600),r=Math.floor((t-3600*e)/60),o=Math.floor(t-3600*e-60*r);return(e>0?[e,r,o]:[r,o]).map(t=>t<10?`0${t}`:String(t)).join(":")}const et={"&":"&","<":"<",">":">","'":"'",'"':"""},rt={"&":"&","<":"<",">":">","'":"'",""":'"'},ot=/(&|<|>|'|")/g;function nt(t){return t.replace(/[&<>'"]/g,t=>et[t]||t)}const at=Object.defineProperty,{hasOwnProperty:it}=Object.prototype;function st(t,e){return it.call(t,e)}function lt(t,e){return Object.getOwnPropertyDescriptor(t,e)}function ct(...t){const e=t=>!!t&&"object"===typeof t&&!Array.isArray(t);return t.reduce((t,r)=>(Object.keys(r).forEach(o=>{const n=t[o],a=r[o];let i;i=Array.isArray(n)&&Array.isArray(a)?n.concat(...a):e(n)&&e(a)?ct(n,a):a,at(t,o,{value:i,enumerable:!0,configurable:!0,writable:!0})}),t),{})}function dt(t){return"WEBVTT \r\n\r\n".concat((e=t,e.replace(/(\d\d:\d\d:\d\d)[,.](\d+)/g,(t,e,r)=>{let o=r.slice(0,3);return 1===r.length&&(o=`${r}00`),2===r.length&&(o=`${r}0`),`${e},${o}`})).replace(/\{\\([ibu])\}/g,"").replace(/\{\\([ibu])1\}/g,"<$1>").replace(/\{([ibu])\}/g,"<$1>").replace(/\{\/([ibu])\}/g,"").replace(/(\d\d:\d\d:\d\d),(\d\d\d)/g,"$1.$2").replace(/\{[\s\S]*?\}/g,"").concat("\r\n\r\n"));var e}function pt(t){return URL.createObjectURL(new Blob([t],{type:"text/vtt"}))}function ht(t){const e=new RegExp("Dialogue:\\s\\d,(\\d+:\\d\\d:\\d\\d.\\d\\d),(\\d+:\\d\\d:\\d\\d.\\d\\d),([^,]*),([^,]*),(?:[^,]*,){4}([\\s\\S]*)$","i");function r(t=""){return t.split(/[:.]/).map((t,e,r)=>{if(e===r.length-1){if(1===t.length)return`.${t}00`;if(2===t.length)return`.${t}0`}else if(1===t.length)return(0===e?"0":":0")+t;return 0===e?t:e===r.length-1?`.${t}`:`:${t}`}).join("")}return`WEBVTT\n\n${t.split(/\r?\n/).map(t=>{const o=t.match(e);if(!o)return null;const[,n="",a="",,,i=""]=o;return{start:r(n.trim()),end:r(a.trim()),text:i.replace(/\{[\s\S]*?\}/g,"").replace(/(\\N)/g,"\n").trim().split(/\r?\n/).map(t=>t.trim()).join("\n")}}).filter(t=>t).map((t,e)=>t?`${e+1}\n${t.start} --\x3e ${t.end}\n${t.text}`:"").filter(t=>t.trim()).join("\n\n")}`}function ut(t,e){let r=!1;return function(...o){r||(t.apply(this,o),r=!0,setTimeout(()=>{r=!1},e))}}const mt=Object.freeze(Object.defineProperty({__proto__:null,ArtPlayerError:q,addClass:C,append:S,assToVtt:ht,capitalize:Q,clamp:J,createElement:N,debounce:function(t,e){let r;return function(...o){clearTimeout(r),r=setTimeout(()=>(r=void 0,t.apply(this,o)),e)}},def:at,download:Z,errorHandle:X,escape:nt,get:lt,getComposedPath:j,getExt:K,getIcon:D,getRect:B,getSafeAreaInsets:U,getStyle:function(t,e,r=!0){const o=window.getComputedStyle(t,null).getPropertyValue(e);return r?Number.parseFloat(o):o},has:st,hasClass:L,includeFromEvent:V,inverseClass:O,isBrowser:$,isIOS:w,isIOS13:x,isInViewport:_,isMobile:k,isSafari:b,loadImg:W,mergeDeep:ct,query:E,queryAll:T,remove:M,removeClass:z,replaceElement:Y,secondToTime:tt,setStyle:P,setStyleText:F,setStyles:A,siblings:I,silencePromise:G,sleep:function(t=0){return new Promise(e=>setTimeout(e,t))},srtToVtt:dt,supportsFlex:H,throttle:ut,tooltip:R,unescape:function(t){return t.replace(ot,t=>rt[t]||t)},userAgent:y,vttToBlob:pt},Symbol.toStringTag,{value:"Module"})),ft="array",gt="boolean",vt="string",yt="number",bt="object",wt="function";function xt(t,e,r){return X(e===vt||e===yt||t instanceof Element,`${r.join(".")} require '${vt}' or 'Element' type`)}const kt={html:xt,disable:`?${gt}`,name:`?${vt}`,index:`?${yt}`,style:`?${bt}`,click:`?${wt}`,mounted:`?${wt}`,tooltip:`?${vt}|${yt}`,width:`?${yt}`,selector:`?${ft}`,onSelect:`?${wt}`,switch:`?${gt}`,onSwitch:`?${wt}`,range:`?${ft}`,onRange:`?${wt}`,onChange:`?${wt}`},$t={id:vt,container:xt,url:vt,poster:vt,type:vt,theme:vt,lang:vt,volume:yt,isLive:gt,muted:gt,autoplay:gt,autoSize:gt,autoMini:gt,loop:gt,flip:gt,playbackRate:gt,aspectRatio:gt,screenshot:gt,setting:gt,hotkey:gt,pip:gt,mutex:gt,backdrop:gt,fullscreen:gt,fullscreenWeb:gt,subtitleOffset:gt,miniProgressBar:gt,useSSR:gt,playsInline:gt,lock:gt,gesture:gt,fastForward:gt,autoPlayback:gt,autoOrientation:gt,airplay:gt,proxy:`?${wt}`,plugins:[wt],layers:[kt],contextmenu:[kt],settings:[kt],controls:[c(l({},kt),{position:(t,e,r)=>{const o=["top","left","right"];return X("string"===typeof t&&o.includes(t),`${r.join(".")} only accept ${o.toString()} as parameters`)}})],quality:[{default:`?${gt}`,html:vt,url:vt}],highlight:[{time:yt,text:vt}],thumbnails:{url:vt,number:yt,column:yt,width:yt,height:yt,scale:yt},subtitle:{url:vt,name:vt,type:vt,style:bt,escape:gt,encoding:vt,onVttLoad:wt},moreVideoAttr:bt,i18n:bt,icons:bt,cssVar:bt,customType:bt};class Et{constructor(t){this.id=0,this.art=t,this.cache=new Map,this.add=this.add.bind(this),this.remove=this.remove.bind(this),this.update=this.update.bind(this)}get show(){return L(this.art.template.$player,`art-${this.name}-show`)}set show(t){const{$player:e}=this.art.template,r=`art-${this.name}-show`;t?C(e,r):z(e,r),this.art.emit(this.name,t)}toggle(){this.show=!this.show}add(t){const e="function"===typeof t?t(this.art):t;if(e.html=e.html||"",f(e,kt),!this.$parent||!this.name||e.disable)return;const r=e.name||`${this.name}${this.id}`;X(!this.cache.has(r),`Can't add an existing [${r}] to the [${this.name}]`),this.id+=1;const o=N("div");C(o,`art-${this.name}`),C(o,`art-${this.name}-${r}`);const n=Array.from(this.$parent.children);o.dataset.index=e.index||this.id;const a=n.find(t=>Number(t.dataset.index)>=Number(o.dataset.index));a?a.insertAdjacentElement("beforebegin",o):S(this.$parent,o),e.html&&S(o,e.html),e.style&&A(o,e.style),e.tooltip&&R(o,e.tooltip);const i=[];if(e.click){const t=this.art.events.proxy(o,"click",t=>{t.preventDefault(),e.click.call(this.art,this,t)});i.push(t)}return e.selector&&["left","right"].includes(e.position)&&this.selector(e,o,i),this[r]=o,this.cache.set(r,{$ref:o,events:i,option:e}),e.mounted&&e.mounted.call(this.art,o),o}remove(t){X(this.cache.has(t),`Can't find [${t}] from the [${this.name}]`);const e=this.cache.get(t);e.option.beforeUnmount&&e.option.beforeUnmount.call(this.art,e.$ref);for(const r of e.events)this.art.events.remove(r);this.cache.delete(t),delete this[t],M(e.$ref)}update(t){if(this.cache.has(t.name)){const e=this.cache.get(t.name);t=Object.assign(e.option,t),this.remove(t.name)}return this.add(t)}}class Tt extends Et{constructor(t){super(t),this.name="contextmenu",this.$parent=t.template.$contextmenu,k||this.init()}init(){const{option:t,proxy:e,template:{$player:r,$contextmenu:o}}=this.art;t.playbackRate&&this.add(function(t){return e=>{const{i18n:r,constructor:{PLAYBACK_RATE:o}}=e,n=o.map(t=>`${1===t?r.get("Normal"):t.toFixed(1)}`).join("");return c(l({},t),{html:`${r.get("Play Speed")}: ${n}`,click:(t,r)=>{const{value:o}=r.target.dataset;o&&(e.playbackRate=Number(o),t.show=!1)},mounted:t=>{const r=E('[data-value="1"]',t);r&&O(r,"art-current"),e.on("video:ratechange",()=>{const r=T("span",t).find(t=>Number(t.dataset.value)===e.playbackRate);r&&O(r,"art-current")})}})}}({name:"playbackRate",index:10})),t.aspectRatio&&this.add(function(t){return e=>{const{i18n:r,constructor:{ASPECT_RATIO:o}}=e,n=o.map(t=>`${"default"===t?r.get("Default"):t}`).join("");return c(l({},t),{html:`${r.get("Aspect Ratio")}: ${n}`,click:(t,r)=>{const{value:o}=r.target.dataset;o&&(e.aspectRatio=o,t.show=!1)},mounted:t=>{const r=E('[data-value="default"]',t);r&&O(r,"art-current"),e.on("aspectRatio",e=>{const r=T("span",t).find(t=>t.dataset.value===e);r&&O(r,"art-current")})}})}}({name:"aspectRatio",index:20})),t.flip&&this.add(function(t){return e=>{const{i18n:r,constructor:{FLIP:o}}=e,n=o.map(t=>`${r.get(Q(t))}`).join("");return c(l({},t),{html:`${r.get("Video Flip")}: ${n}`,click:(t,r)=>{const{value:o}=r.target.dataset;o&&(e.flip=o.toLowerCase(),t.show=!1)},mounted:t=>{const r=E('[data-value="normal"]',t);r&&O(r,"art-current"),e.on("flip",e=>{const r=T("span",t).find(t=>t.dataset.value===e);r&&O(r,"art-current")})}})}}({name:"flip",index:30})),this.add(function(t){return e=>c(l({},t),{html:e.i18n.get("Video Info"),click:t=>{e.info.show=!0,t.show=!1}})}({name:"info",index:40})),this.add(function(t){return c(l({},t),{html:`ArtPlayer ${g}`})}({name:"version",index:50})),this.add(function(t){return e=>c(l({},t),{html:e.i18n.get("Close"),click:t=>{t.show=!1}})}({name:"close",index:60}));for(let n=0;n{if(!this.art.constructor.CONTEXTMENU)return;t.preventDefault(),this.show=!0;const e=t.clientX,n=t.clientY,{height:a,width:i,left:s,top:l}=B(r),{height:c,width:d}=B(o);let p=e-s,h=n-l;e+d>s+i&&(p=i-d),n+c>l+a&&(h=a-c),A(o,{top:`${h}px`,left:`${p}px`})}),e(r,"click",t=>{V(t,o)||(this.show=!1)}),this.art.on("blur",()=>{this.show=!1})}}class Ct extends Error{constructor(t){super("Failed to release ArtPlayer resources"),this.errors=t,this.name="ResourceCleanupError"}}class zt{constructor(){this.cleanups=new Set,this.disposed=!1}get closed(){return this.disposed}add(t){let e=!0;const r=()=>{e&&(e=!1,this.cleanups.delete(r),t())};return this.closed?r():this.cleanups.add(r),r}child(){const t=new zt,e=this.add(()=>{t.dispose()});return t.add(()=>{e()}),t}dispose(){if(this.closed)return;this.disposed=!0;const t=[];for(const r of Array.from(this.cleanups).reverse())try{r()}catch(e){e instanceof Ct?t.push(...e.errors):t.push(e)}if(t.length)throw new Ct(t)}}const Lt=new WeakMap,St=new WeakMap;function Mt(t){const e=Lt.get(t);if(!e)throw new Error("ArtPlayer lifecycle has not been initialized");return e}function Pt(t){return Mt(t).scope}function At(t){const e=Mt(t);return e.destroying||e.scope.closed}function It(t,e,r,o,n=!1){var a,i,s;const l=Mt(t);if(l.destroying||l.scope.closed)return;l.destroying=!0;const c=[],d=t=>{try{t()}catch(e){c.push(...e instanceof Ct?e.errors:[e])}};o&&(null==(a=t.template)?void 0:a.$video)&&d(()=>t.reset()),d(()=>l.scope.dispose()),d(()=>{var e;return null==(e=t.template)?void 0:e.destroy(r)});const p=e.indexOf(t);-1!==p&&e.splice(p,1),t.isDestroy=!0,n||(null==(i=l.releaseContainer)||i.call(l),l.releaseContainer=void 0),d(()=>t.emit("destroy")),n&&l.rollback&&d(l.rollback),l.rollback=void 0,null==(s=l.releaseContainer)||s.call(l),l.releaseContainer=void 0;for(const h of c.slice(1))console.warn("Additional ArtPlayer cleanup failure:",h);if(c.length)throw c[0]}function Ot(t,e,r){if(t.closed)return()=>{};let o=!0,n=()=>{};const a=setTimeout(()=>{o&&(n(),t.closed||e())},r);return n=t.add(()=>{o=!1,clearTimeout(a)}),n}function Rt(t,e=0){return t.closed?Promise.resolve(!1):new Promise(r=>{let o=!1,n=()=>{};const a=setTimeout(()=>{o=!0,n(),r(!0)},e);n=t.add(()=>{clearTimeout(a),o||r(!1)})})}function _t(t,e){const{$progress:r}=t.template,{left:o}=B(r),n=J((k?e.touches[0].clientX:e.clientX)-o,0,r.clientWidth),a=n/r.clientWidth*t.duration;return{second:a,time:tt(a),width:n,percentage:J(n/r.clientWidth,0,1)}}function Vt(t,e){if(t.isRotate){const r=(e.touches[0].clientY-t.top)/t.height,o=r*t.duration;t.emit("setBar","played",r,e),t.seek=o}else{const{second:r,percentage:o}=_t(t,e);t.emit("setBar","played",o,e),t.seek=r}}function Yt(t){return e=>{const{icons:r,option:o,proxy:n}=e,{$player:a,$progress:i}=e.template;return c(l({},t),{html:'\n
\n
\n
\n
\n
\n
\n
00:00
\n
\n ',mounted:t=>{let s=null,l=!1;const c=E(".art-progress-hover",t),d=E(".art-progress-loaded",t),p=E(".art-progress-played",t),h=E(".art-progress-highlight",t),u=E(".art-progress-indicator",t),m=E(".art-progress-tip",t);function f(r,o){const{width:n,time:a}=o||_t(e,r);m.textContent=a||"00:00";const i=m.clientWidth;n<=i/2?P(m,"left",0):n>t.clientWidth-i/2?P(m,"left",t.clientWidth-i+"px"):P(m,"left",n-i/2+"px")}r.indicator?S(u,r.indicator):P(u,"backgroundColor","var(--art-theme)"),e.on("setBar",function(r,o,n){const i="played"===r&&n&&k;if("loaded"===r&&P(d,"width",100*o+"%"),"hover"===r&&(P(c,"width",100*o+"%"),V(n,h)?function(r){const{width:o}=_t(e,r),{text:n}=r.target.dataset;m.textContent=n;const a=m.clientWidth;o<=a/2?P(m,"left",0):o>t.clientWidth-a/2?P(m,"left",t.clientWidth-a+"px"):P(m,"left",o-a/2+"px")}(n):f(n),0===o?z(a,"art-progress-hover"):C(a,"art-progress-hover")),"played"===r&&(P(p,"width",100*o+"%"),P(u,"left",100*o+"%")),i){C(a,"art-progress-hover");f(n,{width:t.clientWidth*o,time:tt(o*e.duration)}),clearTimeout(s),s=setTimeout(()=>{z(a,"art-progress-hover")},500)}}),e.on("video:loadedmetadata",function(){h.textContent="";for(let t=0;t`;S(h,a)}}),e.constructor.USE_RAF?e.on("raf",()=>{e.emit("setBar","played",e.played),e.emit("setBar","loaded",e.loaded)}):(e.on("video:timeupdate",()=>{e.emit("setBar","played",e.played)}),e.on("video:progress",()=>{e.emit("setBar","loaded",e.loaded)}),e.on("video:ended",()=>{e.emit("setBar","played",1)})),e.emit("setBar","loaded",e.loaded||0),k||(n(i,"click",t=>{t.target!==u&&Vt(e,t)}),n(i,"mousemove",t=>{const{percentage:r}=_t(e,t);e.emit("setBar","hover",r,t)}),n(i,"mouseleave",t=>{e.emit("setBar","hover",0,t)}),n(i,"mousedown",t=>{l=0===t.button}),e.on("document:mousemove",t=>{if(l){const{second:r,percentage:o}=_t(e,t);e.emit("setBar","played",o,t),e.seek=r}}),e.on("document:mouseup",()=>{l&&(l=!1)}))}})}}class Nt extends Et{constructor(t){super(t),this.isHover=!1,this.name="control",this.timer=Date.now();const{constructor:e}=t,{$player:r,$bottom:o}=this.art.template;t.on("mousemove",()=>{k||(this.show=!0)}),t.on("click",()=>{k?this.toggle():this.show=!0}),t.on("document:mousemove",t=>{this.isHover=V(t,o)}),t.on("video:timeupdate",()=>{!t.setting.show&&!this.isHover&&!t.isInput&&t.playing&&this.show&&Date.now()-this.timer>=e.CONTROL_HIDE_TIME&&(this.show=!1)}),t.on("control",t=>{t?(z(r,"art-hide-cursor"),C(r,"art-hover"),this.timer=Date.now()):(C(r,"art-hide-cursor"),z(r,"art-hover"))}),this.init()}init(){const{option:t}=this.art;t.isLive||this.add(Yt({name:"progress",position:"top",index:10})),this.add({name:"thumbnails",position:"top",index:20}),this.add(function(t){return e=>c(l({},t),{mounted:t=>{const{proxy:r,icons:o,i18n:n}=e,a=S(t,o.play),i=S(t,o.pause);function s(){P(a,"display","flex"),P(i,"display","none")}function l(){P(a,"display","none"),P(i,"display","flex")}R(a,n.get("Play")),R(i,n.get("Pause")),r(a,"click",()=>{G(e.play())}),r(i,"click",()=>{e.pause()}),e.playing?l():s(),e.on("video:playing",()=>{l()}),e.on("video:pause",()=>{s()})}})}({name:"playAndPause",position:"left",index:10})),this.add(function(t){return e=>c(l({},t),{mounted:t=>{const{proxy:r,icons:o}=e,n=S(t,o.volume),a=S(t,o.volumeClose),i=S(t,'
'),s=S(i,'
'),l=S(s,'
'),c=S(s,'
'),d=S(c,'
'),p=S(d,'
'),h=S(c,'
');function u(t){const{top:e,height:r}=B(c);return 1-(t.clientY-e)/r}function m(){if(e.muted||0===e.volume)P(n,"display","none"),P(a,"display","flex"),P(h,"top","100%"),P(p,"top","100%"),l.textContent=0;else{const t=100*e.volume;P(n,"display","flex"),P(a,"display","none"),P(h,"top",100-t+"%"),P(p,"top",100-t+"%"),l.textContent=Math.floor(t)}}if(m(),e.on("video:volumechange",m),r(n,"click",()=>{e.muted=!0}),r(a,"click",()=>{e.muted=!1}),k)P(i,"display","none");else{let t=!1;r(c,"mousedown",r=>{t=0===r.button,e.volume=u(r)}),e.on("document:mousemove",r=>{t&&(e.muted=!1,e.volume=u(r))}),e.on("document:mouseup",()=>{t&&(t=!1)})}}})}({name:"volume",position:"left",index:20})),t.isLive||this.add(function(t){return e=>c(l({},t),{style:k?{fontSize:"12px",padding:"0 5px"}:{cursor:"auto",padding:"0 10px"},mounted:t=>{function r(){const r=`${tt(e.currentTime)} / ${tt(e.duration)}`;r!==t.textContent&&(t.textContent=r)}r();const o=["video:loadedmetadata","video:timeupdate","video:progress"];for(let n=0;n{e&&!Pt(this.art).closed&&(this.art.quality=t.quality)}),t.screenshot&&!k&&this.add(function(t){return e=>c(l({},t),{tooltip:e.i18n.get("Screenshot"),mounted:t=>{const{proxy:r,icons:o}=e;S(t,o.screenshot),r(t,"click",()=>{e.screenshot()})}})}({name:"screenshot",position:"right",index:20})),t.setting&&this.add(function(t){return e=>c(l({},t),{tooltip:e.i18n.get("Show Setting"),mounted:t=>{const{proxy:r,icons:o,i18n:n}=e;S(t,o.setting),r(t,"click",()=>{e.setting.toggle(),e.setting.resize()}),e.on("setting",e=>{R(t,n.get(e?"Hide Setting":"Show Setting"))})}})}({name:"setting",position:"right",index:30})),t.pip&&this.add(function(t){return e=>c(l({},t),{tooltip:e.i18n.get("PIP Mode"),mounted:t=>{const{proxy:r,icons:o,i18n:n}=e;S(t,o.pip),r(t,"click",()=>{e.pip=!e.pip}),e.on("pip",e=>{R(t,n.get(e?"Exit PIP Mode":"PIP Mode"))})}})}({name:"pip",position:"right",index:40})),t.airplay&&window.WebKitPlaybackTargetAvailabilityEvent&&this.add(function(t){return e=>c(l({},t),{tooltip:e.i18n.get("AirPlay"),mounted:t=>{const{proxy:r,icons:o}=e;S(t,o.airplay),r(t,"click",()=>e.airplay())}})}({name:"airplay",position:"right",index:50})),t.fullscreenWeb&&this.add(function(t){return e=>c(l({},t),{tooltip:e.i18n.get("Web Fullscreen"),mounted:t=>{const{proxy:r,icons:o,i18n:n}=e,a=S(t,o.fullscreenWebOn),i=S(t,o.fullscreenWebOff);P(i,"display","none"),r(t,"click",()=>{e.fullscreenWeb=!e.fullscreenWeb}),e.on("fullscreenWeb",e=>{e?(R(t,n.get("Exit Web Fullscreen")),P(a,"display","none"),P(i,"display","inline-flex")):(R(t,n.get("Web Fullscreen")),P(a,"display","inline-flex"),P(i,"display","none"))})}})}({name:"fullscreenWeb",position:"right",index:60})),t.fullscreen&&this.add(function(t){return e=>c(l({},t),{tooltip:e.i18n.get("Fullscreen"),mounted:t=>{const{proxy:r,icons:o,i18n:n}=e,a=S(t,o.fullscreenOn),i=S(t,o.fullscreenOff);P(i,"display","none"),r(t,"click",()=>{e.fullscreen=!e.fullscreen}),e.on("fullscreen",e=>{e?(R(t,n.get("Exit Fullscreen")),P(a,"display","none"),P(i,"display","inline-flex")):(R(t,n.get("Fullscreen")),P(a,"display","inline-flex"),P(i,"display","none"))})}})}({name:"fullscreen",position:"right",index:70}));for(let e=0;et.selector}),at(e,"$control_item",{get:()=>r}),at(e,"$control_value",{get:()=>n})}const i=o(a,"click",e=>d(this,null,function*(){const r=j(e),o=t.selector.find(t=>t.$control_item===r.find(e=>t.$control_item===e));this.check(o),t.onSelect&&(n.innerHTML=yield t.onSelect.call(this.art,o,o.$control_item,e))}));r.push(i)}}function Dt(t,e,r,o){const n=e-o,a=r-t;let i=0;if(Math.abs(a)<2&&Math.abs(n)<2)return i;const s=function(t,e){return 180*Math.atan2(e,t)/Math.PI}(a,n);return s>=-45&&s<45?i=4:s>=45&&s<135?i=1:s>=-135&&s<-45?i=2:(s>=135&&s<=180||s>=-180&&s<-135)&&(i=3),i}function Ft(t){if(t.constructor.USE_RAF){const e=Pt(t);let r=()=>{};!function o(){t.playing&&t.emit("raf"),t.isDestroy||(r=function(t,e){if(t.closed)return()=>{};let r=!0,o=()=>{};const n=requestAnimationFrame(n=>{r&&(o(),t.closed||e(n))});return o=t.add(()=>{r=!1,cancelAnimationFrame(n)}),o}(e,o))}(),t.on("destroy",()=>{r()})}}const Ht=new WeakMap;class Bt{constructor(t){this.destroyEvents=new Set;const e=Pt(t);Ht.set(this,e),e.add(()=>this.destroy()),this.proxy=this.proxy.bind(this),this.hover=this.hover.bind(this),function(t,e){const{constructor:r,template:{$player:o,$video:n}}=t;function a(e){V(e,o)?(t.isInput="INPUT"===e.target.tagName,t.isFocus=!0,t.emit("focus",e)):(t.isInput=!1,t.isFocus=!1,t.emit("blur",e))}t.on("document:click",a),t.on("document:contextmenu",a);let i=[];e.proxy(n,"click",e=>{const o=Date.now();i.push(o);const{MOBILE_CLICK_PLAY:n,DBCLICK_TIME:a,MOBILE_DBCLICK_PLAY:s,DBCLICK_FULLSCREEN:l}=r,c=i.filter(t=>o-t<=a);switch(c.length){case 1:t.emit("click",e),k?!t.isLock&&n&&G(t.toggle()):G(t.toggle()),i=c;break;case 2:t.emit("dblclick",e),k?!t.isLock&&s&&G(t.toggle()):l&&(t.fullscreen=!t.fullscreen),i=[];break;default:i=[]}})}(t,this),function(t,e){const{$player:r}=t.template;e.hover(r,e=>{C(r,"art-hover"),t.emit("hover",!0,e)},e=>{z(r,"art-hover"),t.emit("hover",!1,e)})}(t,this),function(t,e){const{$player:r}=t.template;e.proxy(r,"mousemove",e=>{t.emit("mousemove",e)})}(t,this),function(t,e){const{option:r,constructor:o}=t;t.on("resize",()=>{const{aspectRatio:e,notice:o}=t;"standard"===t.state&&r.autoSize&&t.autoSize(),t.aspectRatio=e,o.show=""});const n=Pt(t);let a=()=>{};const i=()=>{a(),a=Ot(n,()=>t.emit("resize"),o.RESIZE_TIME)};t.on("window:orientationchange",()=>i()),t.on("window:resize",()=>i()),screen&&screen.orientation&&screen.orientation.onchange&&e.proxy(screen.orientation,"change",()=>i())}(t,this),function(t,e){if(k&&!t.option.isLive){const{$video:r,$progress:o}=t.template;let n=null,a=!1,i=0,s=0,l=0;const c=e=>{if(1===e.touches.length&&!t.isLock){n===o&&Vt(t,e),a=!0;const{pageX:r,pageY:c}=e.touches[0];i=r,s=c,l=t.currentTime}},d=e=>{if(1===e.touches.length&&a&&t.duration){const{pageX:o,pageY:a}=e.touches[0],c=Dt(i,s,o,a),d=[3,4].includes(c),p=[1,2].includes(c);if(d&&!t.isRotate||p&&t.isRotate){const c=J((o-i)/t.width,-1,1),d=J((a-s)/t.height,-1,1),p=t.isRotate?d:c,h=n===r?t.constructor.TOUCH_MOVE_RATIO:1,u=J(l+t.duration*p*h,0,t.duration);t.seek=u,t.emit("setBar","played",J(u/t.duration,0,1),e),t.notice.show=`${tt(u)} / ${tt(t.duration)}`}}},p=()=>{a&&(i=0,s=0,l=0,a=!1,n=null)};t.option.gesture&&(e.proxy(r,"touchstart",t=>{n=r,c(t)}),e.proxy(r,"touchmove",d)),e.proxy(o,"touchstart",t=>{n=o,c(t)}),e.proxy(o,"touchmove",d),t.on("document:touchend",p)}}(t,this),function(t){const{option:e,constructor:r,template:{$container:o}}=t,n=ut(()=>{t.emit("view",_(o,r.SCROLL_GAP))},r.SCROLL_TIME);t.on("window:scroll",()=>n()),t.on("view",r=>{e.autoMini&&(t.mini=!r)})}(t),function(t,e){const r=["click","mouseup","keydown","touchend","touchmove","mousemove","pointerup","contextmenu","pointermove","visibilitychange","webkitfullscreenchange"],o=["resize","scroll","orientationchange"],n=[];function a(a={}){for(let t=0;t{const o=a.document||i.ownerDocument||document,s=e.proxy(o,r,e=>{t.emit(`document:${r}`,e)});n.push(s)}),o.forEach(r=>{var o;const s=a.window||(null==(o=i.ownerDocument)?void 0:o.defaultView)||window,l=e.proxy(s,r,e=>{t.emit(`window:${r}`,e)});n.push(l)})}a(),e.bindGlobalEvents=a}(t,this),Ft(t)}proxy(t,e,r,o={}){if(Array.isArray(e))return e.map(e=>this.proxy(t,e,r,o));if(Ht.get(this).closed)return()=>{};t.addEventListener(e,r,o);const n=()=>t.removeEventListener(e,r,o);return this.destroyEvents.add(n),n}hover(t,e,r){e&&this.proxy(t,"mouseenter",e),r&&this.proxy(t,"mouseleave",r)}remove(t){if(this.destroyEvents.has(t))try{t()}catch(e){console.warn("Failed to remove event listener:",e)}finally{this.destroyEvents.delete(t)}}destroy(){for(const e of this.destroyEvents)try{e()}catch(t){console.warn("Failed to destroy event listener:",t)}this.destroyEvents.clear()}}class Wt{constructor(t){this.art=t,this.keys={},k||this.init()}init(){const{constructor:t}=this.art;this.art.option.hotkey&&(this.add("Escape",()=>{this.art.fullscreenWeb&&(this.art.fullscreenWeb=!1)}),this.add("Space",()=>{G(this.art.toggle())}),this.add("ArrowLeft",()=>{this.art.backward=t.SEEK_STEP}),this.add("ArrowUp",()=>{this.art.volume+=t.VOLUME_STEP}),this.add("ArrowRight",()=>{this.art.forward=t.SEEK_STEP}),this.add("ArrowDown",()=>{this.art.volume-=t.VOLUME_STEP})),this.art.on("document:keydown",t=>{if(this.art.isFocus){const e=document.activeElement.tagName.toUpperCase(),r=document.activeElement.getAttribute("contenteditable");if("INPUT"!==e&&"TEXTAREA"!==e&&""!==r&&"true"!==r&&!t.altKey&&!t.ctrlKey&&!t.metaKey&&!t.shiftKey){const e=this.keys[t.code];if(e){t.preventDefault();for(let r=0;r\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n',state:'\r\n\r\n\r\n',play:'\r\n \r\n',pause:'\r\n \r\n',check:'\r\n\r\n',volume:'\r\n \r\n \r\n',volumeClose:'\r\n \r\n \r\n',screenshot:'\r\n\t\r\n\r\n',setting:'\r\n \r\n \r\n',pip:'\r\n\r\n',arrowLeft:'\r\n \r\n',arrowRight:'\r\n \r\n',playbackRate:'',aspectRatio:'',config:'',lock:'\r\n\r\n\r\n\r\n\r\n',flip:'\r\n\r\n\r\n\r\n\r\n\r\n',unlock:'\r\n\r\n\r\n',fullscreenOff:'\r\n\r\n\r\n\r\n\r\n',fullscreenOn:'\r\n\r\n\r\n\r\n\r\n',fullscreenWebOff:'\r\n\r\n\r\n\r\n\r\n',fullscreenWebOn:'\r\n\r\n\r\n\r\n\r\n',switchOn:'\r\n\r\n\r\n \r\n',switchOff:'\r\n\r\n\r\n \r\n\r\n',error:'\r\n\r\n\r\n\r\n\r\n',close:'\r\n\r\n\r\n\r\n\r\n',airplay:'\r\n \r\n \r\n \r\n \r\n\r\n'},t.option.icons);for(const r in e)at(this,r,{get:()=>D(r,e[r])})}}class Xt extends Et{constructor(t){super(t),this.name="info",k||this.init()}init(){const{proxy:t,constructor:e,template:{$infoPanel:r,$infoClose:o,$video:n}}=this.art;t(o,"click",()=>{this.show=!1});let a=()=>{};const i=T("[data-video]",r)||[];this.art.on("destroy",()=>a());const s=Pt(this.art);!function t(){for(let e=0;e{P(n,"display","none"),P(a,"display",null)}),o.proxy(e.$state,"click",()=>G(t.play()))}}class Jt{constructor(t){this.art=t,this.timer=null,Pt(t).add(()=>this.destroy()),t.on("destroy",()=>this.destroy())}destroy(){this.timer&&(clearTimeout(this.timer),this.timer=null)}set show(t){if(Pt(this.art).closed)return;const{constructor:e,template:{$player:r,$noticeInner:o}}=this.art;t?(o.textContent=t instanceof Error?t.message.trim():t,C(r,"art-notice-show"),clearTimeout(this.timer),this.timer=setTimeout(()=>{o.textContent="",z(r,"art-notice-show")},e.NOTICE_TIME)):z(r,"art-notice-show")}get show(){const{template:{$player:t}}=this.art;return t.classList.contains("art-notice-show")}}const Qt=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],te=(()=>{if("undefined"===typeof document)return!1;const t=Qt[0],e={};for(const r of Qt){if(r[1]in document){for(const[o,n]of r.entries())e[t[o]]=n;return e}}return!1})(),ee={change:te.fullscreenchange,error:te.fullscreenerror},re={request:(t=document.documentElement,e)=>new Promise((r,o)=>{const n=()=>{re.off("change",n),r()};re.on("change",n);const a=t[te.requestFullscreen](e);a instanceof Promise&&a.then(n).catch(o)}),exit:()=>new Promise((t,e)=>{if(!re.isFullscreen)return void t();const r=()=>{re.off("change",r),t()};re.on("change",r);const o=document[te.exitFullscreen]();o instanceof Promise&&o.then(r).catch(e)}),toggle:(t,e)=>re.isFullscreen?re.exit():re.request(t,e),onchange(t){re.on("change",t)},onerror(t){re.on("error",t)},on(t,e){const r=ee[t];r&&document.addEventListener(r,e,!1)},off(t,e){const r=ee[t];r&&document.removeEventListener(r,e,!1)},raw:te};function oe(t){const{i18n:e,notice:r,template:{$video:o,$player:n}}=t,a=t=>{re.on("change",()=>{t.emit("fullscreen",re.isFullscreen),re.isFullscreen?(t.state="fullscreen",C(n,"art-fullscreen")):z(n,"art-fullscreen"),t.emit("resize")}),re.on("error",e=>{t.emit("fullscreenError",e)}),at(t,"fullscreen",{get:()=>re.isFullscreen,set(t){return d(this,null,function*(){t?yield re.request(n):yield re.exit()})}})};t.once("video:loadedmetadata",()=>{var n;re.isEnabled?a(t):o.webkitSupportsFullscreen?((n=t).on("document:webkitfullscreenchange",()=>{n.emit("fullscreen",n.fullscreen),n.emit("resize")}),at(n,"fullscreen",{get:()=>document.fullscreenElement===o,set(t){t?(n.state="fullscreen",o.webkitEnterFullscreen()):o.webkitExitFullscreen()}})):at(t,"fullscreen",{get:()=>!1,set(){r.show=e.get("Fullscreen Not Supported")}}),at(t,"fullscreen",lt(t,"fullscreen"))})}function ne(t){const{icons:e,proxy:r,storage:o,template:{$player:n,$video:a}}=t;let i=!1,s=0,l=0;function c(){const{$mini:e}=t.template;e&&(z(n,"art-mini"),P(e,"display","none"),n.prepend(a),t.emit("mini",!1))}function d(e,r){t.playing?(P(e,"display","none"),P(r,"display","flex")):(P(e,"display","flex"),P(r,"display","none"))}function p(){const{$mini:e}=t.template,r=B(e),n=window.innerHeight-r.height-50,a=window.innerWidth-r.width-50;o.set("top",n),o.set("left",a),P(e,"top",`${n}px`),P(e,"left",`${a}px`)}at(t,"mini",{get:()=>L(n,"art-mini"),set(h){if(h){t.state="mini",C(n,"art-mini");const h=function(){const{$mini:n}=t.template;if(n)return S(n,a),P(n,"display","flex");{const n=N("div");C(n,"art-mini-popup"),S(document.body,n),t.template.$mini=n,S(n,a);const p=S(n,'
');S(p,e.close),r(p,"click",c);const h=S(n,'
'),u=S(h,e.play),m=S(h,e.pause);return r(u,"click",()=>G(t.play())),r(m,"click",()=>t.pause()),d(u,m),t.on("video:playing",()=>d(u,m)),t.on("video:pause",()=>d(u,m)),t.on("video:timeupdate",()=>d(u,m)),r(n,"mousedown",t=>{i=0===t.button,s=t.pageX,l=t.pageY}),t.on("document:mousemove",t=>{if(i){C(n,"art-mini-dragging");const e=t.pageX-s,r=t.pageY-l;P(n,"transform",`translate(${e}px, ${r}px)`)}}),t.on("document:mouseup",()=>{if(i){i=!1,z(n,"art-mini-dragging");const t=B(n);o.set("left",t.left),o.set("top",t.top),P(n,"left",`${t.left}px`),P(n,"top",`${t.top}px`),P(n,"transform",null)}}),n}}(),u=o.get("top"),m=o.get("left");"number"===typeof u&&"number"===typeof m?(P(h,"top",`${u}px`),P(h,"left",`${m}px`),_(h)||p()):p(),t.emit("mini",!0)}else c()}})}function ae(t){const{i18n:e,notice:r,template:{$video:o}}=t;document.pictureInPictureEnabled?function(t){const{template:{$video:e},proxy:r,notice:o}=t;e.disablePictureInPicture=!1,at(t,"pip",{get:()=>document.pictureInPictureElement,set(r){r?(t.state="pip",e.requestPictureInPicture().catch(t=>{throw o.show=t,t})):document.exitPictureInPicture().catch(t=>{throw o.show=t,t})}}),r(e,"enterpictureinpicture",()=>{t.emit("pip",!0)}),r(e,"leavepictureinpicture",()=>{t.emit("pip",!1)})}(t):o.webkitSupportsPresentationMode?function(t){const{$video:e}=t.template;e.webkitSetPresentationMode("inline"),at(t,"pip",{get:()=>"picture-in-picture"===e.webkitPresentationMode,set(r){r?(t.state="pip",e.webkitSetPresentationMode("picture-in-picture"),t.emit("pip",!0)):(e.webkitSetPresentationMode("inline"),t.emit("pip",!1))}})}(t):at(t,"pip",{get:()=>!1,set(){r.show=e.get("PIP Not Supported")}})}Object.defineProperties(re,{isFullscreen:{get:()=>Boolean(document[te.fullscreenElement])},element:{enumerable:!0,get:()=>document[te.fullscreenElement]},isEnabled:{enumerable:!0,get:()=>Boolean(document[te.fullscreenEnabled])}});const ie=new WeakMap,se=new WeakMap;function le(t){const e=ie.get(t),r=Pt(t).child(),o={scope:r,assigned:!1,acceptingEvents:!1,active:()=>!At(t)&&!r.closed&&ie.get(t)===o};return ie.set(t,o),r.add(()=>{ie.get(t)===o&&ie.delete(t),o.onAssigned=void 0,o.onError=void 0}),null==e||e.scope.dispose(),o}function ce(t){t.assigned=!0;const e=t.onAssigned;t.onAssigned=void 0,t.active()&&(null==e||e())}function de(t,e){t.active()&&(t.onError?t.onError(e):console.warn("Failed to initialize ArtPlayer source:",e),t.scope.dispose())}function pe(t){const{i18n:e,notice:r,option:o,constructor:{instances:n},template:{$video:a}}=t;at(t,"play",{value(){return d(this,null,function*(){const i=function(t){const e=ie.get(t);return()=>ie.get(t)===e&&(!e||e.active())}(t),s=yield a.play();if(!i())return s;const l=e.get("Play");if(!i())return s;if(r.show=l,!i())return s;if(t.emit("play"),o.mutex)for(let e=0;e{t.closed||i||(n&&(i=!0,a()),o(e))};return e[n?"once":"on"](r,s),a=t.add(()=>{e.off(r,s)}),s}function ue(t,e,r){return new Promise((o,n)=>{if(At(t)||e===t.url)return void o();const a=le(t),i=a.scope.child();let s=!1;const l=(t=!1,e)=>{s||(s=!0,a.onError=void 0,a.onAssigned=void 0,i.dispose(),t?n(e):o(),t&&a.scope.dispose())};i.add(()=>{l()});const c=()=>!s&&a.active(),p=t=>l(!0,t);a.onError=p;try{const{playing:o,aspectRatio:n,playbackRate:s}=t;if(t.pause(),!c())return;const h=i.child(),u={"video:error":p,"video:loadedmetadata":()=>{if(c())try{t.currentTime=r}catch(e){p(e)}},"video:canplay":()=>{if(!c())return;h.dispose();d(null,null,function*(){if(t.playbackRate=s,c()&&(t.aspectRatio=n,c())){if(o)try{yield t.play()}catch(e){}c()&&(t.notice.show="",l())}}).catch(p)}},m=i.child(),f=[],g=Object.keys(u);for(const e of g)he(m,t,e,t=>{a.acceptingEvents&&f.push([e,t])},!1);if(function(t,e,r){se.set(t,e),e.acceptingEvents=!0;try{t.url=r}finally{se.get(t)===e&&(se.delete(t),ce(e))}}(t,a,e),!c())return;if(t.notice.show="",!c())return;const v=()=>{if(m.dispose(),!e)return void l();const r={};for(const e of g)r[e]=he(h,t,e,u[e]);for(const[t,e]of f){if(!c()||h.closed)break;r[t](e)}f.length=0};a.assigned?v():a.onAssigned=v}catch(h){p(h)}})}function me(t){const{option:e,template:{$progress:r,$video:o}}=t;let n=null,a=!1,i=null;t.on("setBar",(n,s,l)=>d(null,null,function*(){var c;const d=null==(c=t.controls)?void 0:c.thumbnails,{url:p,scale:h}=e.thumbnails;if(!d||!p)return;if("hover"===n||"played"===n&&l&&k){if(i||a||(a=!0,i=yield W(p,h),a=!1),!i)return;const n=r.clientWidth*s;n>0&&nr.clientWidth-u/2?P(s,"left",r.clientWidth-u+"px"):P(s,"left",n-u/2+"px")}(n)}})),at(t,"thumbnails",{get:()=>t.option.thumbnails,set(e){e.url&&!t.option.isLive&&(t.option.thumbnails=e,clearTimeout(n),n=null,a=!1,i=null)}})}function fe(t){const{option:e,template:{$video:r}}=t;at(t,"url",{get:()=>r.src,set(o){return d(this,null,function*(){if(At(t))return;const n=function(t){const e=se.get(t);return se.delete(t),e||le(t)}(t);n.acceptingEvents=!1;try{if(!o)return void((yield Rt(n.scope))&&n.active()&&(t.loading.show=!0));const a=t.url,i=e.type||K(o),s=e.customType[i];if(i&&s){if(!(yield Rt(n.scope))||!n.active())return;t.loading.show=!0}if(!n.active())return;const l=n.scope.child();let c=!1,d=!1;he(l,t,"video:canplay",()=>{c=!d}),he(l,t,"video:error",()=>{d=!0});try{if(n.acceptingEvents=!0,i&&s){const e=s.call(t,r,o,t);Promise.resolve(e).catch(t=>de(n,t))}else{if(a&&URL.revokeObjectURL(a),!n.active())return;r.src=o}}finally{l.dispose()}if(!n.active())return;if(a!==t.url&&(t.option.url=o,n.active()&&t.isReady&&a)){const e=()=>{n.active()&&t.emit("restart",o)};c?e():d||he(n.scope,t,"video:canplay",e)}}catch(a){de(n,a)}finally{ce(n)}})}})}class ge{constructor(t){fe(t),function(t){const{template:{$video:e}}=t;at(t,"attr",{value(t,r){if(void 0===r)return e[t];e[t]=r}})}(t),pe(t),function(t){const{template:{$video:e},i18n:r,notice:o}=t;at(t,"pause",{value(){const n=e.pause();return o.show=r.get("Pause"),t.emit("pause"),n}})}(t),function(t){at(t,"toggle",{value:()=>t.playing?t.pause():t.play()})}(t),function(t){const{notice:e}=t;at(t,"seek",{set(r){t.currentTime=r,t.duration&&(e.show=`${tt(t.currentTime)} / ${tt(t.duration)}`),t.emit("seek",t.currentTime,r)}}),at(t,"forward",{set(e){t.seek=t.currentTime+e}}),at(t,"backward",{set(e){t.seek=t.currentTime-e}})}(t),function(t){const{template:{$video:e},i18n:r,notice:o,storage:n}=t;at(t,"volume",{get:()=>e.volume||0,set:t=>{e.volume=J(t,0,1),o.show=`${r.get("Volume")}: ${Number.parseInt(100*e.volume,10)}`,0!==e.volume&&n.set("volume",e.volume)}}),at(t,"muted",{get:()=>e.muted,set:r=>{e.muted=r,t.emit("muted",r)}})}(t),function(t){const{$video:e}=t.template;at(t,"currentTime",{get:()=>e.currentTime||0,set:r=>{r=Number.parseFloat(r),Number.isNaN(r)||(e.currentTime=J(r,0,t.duration))}})}(t),function(t){at(t,"duration",{get:()=>{const{duration:e}=t.template.$video;return e===1/0?0:e||0}})}(t),function(t){const e=e=>ue(t,e,0);at(t,"switchQuality",{value:e=>ue(t,e,t.currentTime)}),at(t,"switchUrl",{value:e}),at(t,"switch",{set:e})}(t),function(t){const{template:{$video:e},i18n:r,notice:o}=t;at(t,"playbackRate",{get:()=>e.playbackRate,set(n){if(n){if(n===e.playbackRate)return;e.playbackRate=n,o.show=`${r.get("Rate")}: ${1===n?r.get("Normal"):`${n}x`}`}else t.playbackRate=1}})}(t),function(t){const{i18n:e,notice:r,template:{$video:o,$player:n}}=t;at(t,"aspectRatio",{get:()=>n.dataset.aspectRatio||"default",set(a){if(a||(a="default"),"default"===a)P(o,"width",null),P(o,"height",null),P(o,"margin",null),delete n.dataset.aspectRatio;else{const t=a.split(":").map(Number),{clientWidth:e,clientHeight:r}=n,i=e/r,s=t[0]/t[1];i>s?(P(o,"width",s*r+"px"),P(o,"height","100%"),P(o,"margin","0 auto")):(P(o,"width","100%"),P(o,"height",e/s+"px"),P(o,"margin","auto 0")),n.dataset.aspectRatio=a}r.show=`${e.get("Aspect Ratio")}: ${"default"===a?e.get("Default"):a}`,t.emit("aspectRatio",a)}})}(t),function(t){const{notice:e,template:{$video:r}}=t,o=N("canvas");at(t,"getDataURL",{value:()=>new Promise((t,n)=>{try{o.width=r.videoWidth,o.height=r.videoHeight,o.getContext("2d").drawImage(r,0,0),t(o.toDataURL("image/png"))}catch(a){e.show=a,n(a)}})}),at(t,"getBlobUrl",{value:()=>new Promise((t,n)=>{try{o.width=r.videoWidth,o.height=r.videoHeight,o.getContext("2d").drawImage(r,0,0),o.toBlob(e=>{t(URL.createObjectURL(e))})}catch(a){e.show=a,n(a)}})}),at(t,"screenshot",{value:e=>d(null,null,function*(){const o=yield t.getDataURL();return Z(o,`${e||`artplayer_${tt(r.currentTime)}`}.png`),t.emit("screenshot",o),o})})}(t),oe(t),function(t){const{constructor:e,template:{$container:r,$player:o}}=t;let n="";at(t,"fullscreenWeb",{get:()=>L(o,"art-fullscreen-web"),set(a){a?(n=o.style.cssText,e.FULLSCREEN_WEB_IN_BODY&&S(document.body,o),t.state="fullscreenWeb",P(o,"width","100%"),P(o,"height","100%"),C(o,"art-fullscreen-web"),t.emit("fullscreenWeb",!0)):(e.FULLSCREEN_WEB_IN_BODY&&S(r,o),n&&(o.style.cssText=n,n=""),z(o,"art-fullscreen-web"),t.emit("fullscreenWeb",!1)),t.emit("resize")}})}(t),ae(t),function(t){const{$video:e}=t.template;at(t,"loaded",{get:()=>t.loadedTime/e.duration}),at(t,"loadedTime",{get:()=>e.buffered.length?e.buffered.end(e.buffered.length-1):0})}(t),function(t){at(t,"played",{get:()=>t.currentTime/t.duration})}(t),function(t){const{$video:e}=t.template;at(t,"playing",{get:()=>"boolean"===typeof e.playing?e.playing:!!(e.currentTime>0&&!e.paused&&!e.ended&&e.readyState>2)})}(t),function(t){const{$container:e,$player:r,$video:o}=t.template;at(t,"autoSize",{value(){const{videoWidth:n,videoHeight:a}=o,{width:i,height:s}=B(e),l=n/a;if(i/s>l)P(r,"width",s*l/i*100+"%"),P(r,"height","100%");else{const t=i/l/s*100;P(r,"width","100%"),P(r,"height",`${t}%`)}t.emit("autoSize",{width:t.width,height:t.height})}})}(t),function(t){const e=t;at(t,"rect",{get:()=>B(t.template.$player)});const r=["bottom","height","left","right","top","width"];for(let o=0;oe.rect[n]})}at(t,"x",{get:()=>e.left+window.pageXOffset}),at(t,"y",{get:()=>e.top+window.pageYOffset})}(t),function(t){const{template:{$player:e},i18n:r,notice:o}=t;at(t,"flip",{get:()=>e.dataset.flip||"normal",set(n){n||(n="normal"),"normal"===n?delete e.dataset.flip:e.dataset.flip=n,o.show=`${r.get("Video Flip")}: ${r.get(Q(n))}`,t.emit("flip",n)}})}(t),ne(t),function(t){const{template:{$poster:e}}=t;at(t,"poster",{get:()=>{try{return e.style.backgroundImage.match(/"(.*)"/)[1]}catch(t){return""}},set(t){P(e,"backgroundImage",`url(${t})`)}})}(t),function(t){const{template:{$container:e,$video:r}}=t;at(t,"autoHeight",{value(){const{clientWidth:o}=e,{videoHeight:n,videoWidth:a}=r,i=n*(o/a);P(e,"height",`${i}px`),t.emit("autoHeight",i)}})}(t),function(t){const{$player:e}=t.template;at(t,"cssVar",{value:(t,r)=>r?e.style.setProperty(t,r):getComputedStyle(e).getPropertyValue(t)})}(t),function(t){at(t,"theme",{get:()=>t.cssVar("--art-theme"),set(e){t.cssVar("--art-theme",e)}})}(t),function(t){at(t,"type",{get:()=>t.option.type,set(e){t.option.type=e}})}(t),function(t){const e=["mini","pip","fullscreen","fullscreenWeb"];at(t,"state",{get:()=>e.find(e=>t[e])||"standard",set(r){for(let o=0;o{switch(t.availability){case"available":a=!0;break;case"not-available":a=!1}}):a=!1,at(t,"airplay",{value(){a?(n.webkitShowPlaybackTargetPicker(),t.emit("airplay")):r.show=e.get("AirPlay Not Available")}})}(t),function(t){at(t,"quality",{set(e){const{controls:r,notice:o,i18n:n}=t,a=e.find(t=>t.default)||e[0];r.update({name:"quality",position:"right",index:10,style:{marginRight:"10px"},html:(null==a?void 0:a.html)||"",selector:e,onSelect(e){return d(this,null,function*(){return yield t.switchQuality(e.url),o.show=`${n.get("Switch Video")}: ${e.html}`,e.html})}})}})}(t),me(t),function(t){const{i18n:e,notice:r,option:o,constructor:n,proxy:a,template:{$player:i,$video:s,$poster:l}}=t;let c=0;for(let d=0;d{t.emit(`video:${e.type}`,e)});t.on("video:canplay",()=>{c=0,t.loading.show=!1}),t.once("video:canplay",()=>{t.loading.show=!1,t.controls.show=!0,t.mask.show=!0,t.isReady=!0,t.emit("ready")}),t.on("video:ended",()=>{o.loop?(t.seek=0,G(t.play()),t.controls.show=!1,t.mask.show=!1):(t.controls.show=!0,t.mask.show=!0)}),t.on("video:error",a=>d(null,null,function*(){if(c{t.emit("resize"),k&&(t.loading.show=!1,t.controls.show=!0,t.mask.show=!0)}),t.on("video:loadstart",()=>{t.loading.show=!0,t.mask.show=!1,t.controls.show=!0}),t.on("video:pause",()=>{t.controls.show=!0,t.mask.show=!0}),t.on("video:play",()=>{t.mask.show=!1,P(l,"display","none")}),t.on("video:playing",()=>{t.mask.show=!1}),t.on("video:progress",()=>{t.playing&&(t.loading.show=!1)}),t.on("video:seeked",()=>{t.loading.show=!1,t.mask.show=!0}),t.on("video:seeking",()=>{t.loading.show=!0,t.mask.show=!1}),t.on("video:timeupdate",()=>{t.mask.show=!1}),t.on("video:waiting",()=>{t.loading.show=!0,t.mask.show=!1})}(t),function(t){const{option:e,storage:r,template:{$video:o,$poster:n}}=t;for(const i in e.moreVideoAttr)t.attr(i,e.moreVideoAttr[i]);e.muted&&(t.muted=e.muted),e.volume&&(o.volume=J(e.volume,0,1));const a=r.get("volume");"number"===typeof a&&(o.volume=J(a,0,1)),e.poster&&P(n,"backgroundImage",`url(${e.poster})`),e.autoplay&&(o.autoplay=e.autoplay),e.playsInline&&(o.playsInline=!0,o["webkit-playsinline"]=!0),e.theme&&(e.cssVar["--art-theme"]=e.theme);for(const i in e.cssVar)t.cssVar(i,e.cssVar[i]);t.url=e.url}(t)}}function ve(t){const{notice:e,constructor:r,template:{$player:o,$video:n}}=t,a="art-auto-orientation",i="art-auto-orientation-fullscreen";let s=!1;function l(){const{videoWidth:t,videoHeight:e}=n,r=document.documentElement.clientWidth,o=document.documentElement.clientHeight;return t>e&&ro}return t.on("fullscreenWeb",e=>{var n;if(e){if(l()){const e=Number(null!=(n=r.AUTO_ORIENTATION_TIME)?n:0);setTimeout(()=>{t.fullscreenWeb&&!L(o,a)&&function(){const e=U(),r=document.documentElement.clientWidth,n=document.documentElement.clientHeight-e.top-e.bottom,i=r-e.left-e.right;P(o,"width",`${n}px`),P(o,"height",`${i}px`),P(o,"transform-origin","0 0"),P(o,"transform",`rotate(90deg) translate(${e.top}px, -${r-e.right}px)`),C(o,a),t.isRotate=!0,t.emit("resize")}()},e)}}else L(o,a)&&(P(o,"width",""),P(o,"height",""),P(o,"transform-origin",""),P(o,"transform",""),z(o,a),t.isRotate=!1,t.emit("resize"))}),t.on("fullscreen",t=>d(null,null,function*(){var r;const n=!!(null==(r=null==screen?void 0:screen.orientation)?void 0:r.lock);if(t){if(n&&l())try{const t=screen.orientation.type.startsWith("portrait")?"landscape":"portrait";yield screen.orientation.lock(t),s=!0,C(o,i)}catch(a){s=!1,e.show=a}}else if(L(o,i)&&z(o,i),n&&s){try{screen.orientation.unlock()}catch(c){}s=!1}})),{name:"autoOrientation",get state(){return L(o,a)}}}function ye(t){const{i18n:e,icons:r,storage:o,constructor:n,proxy:a,template:{$poster:i}}=t,s=t.layers.add({name:"auto-playback",html:'\n
\n
\n
\n '}),l=E(".art-auto-playback-last",s),c=E(".art-auto-playback-jump",s),d=E(".art-auto-playback-close",s);S(d,r.close);let p=null;function h(){const r=(o.get("times")||{})[t.option.id||t.option.url];clearTimeout(p),P(s,"display","none"),r&&r>=n.AUTO_PLAYBACK_MIN&&(P(s,"display","flex"),l.textContent=`${e.get("Last Seen")} ${tt(r)}`,c.textContent=e.get("Jump Play"),a(d,"click",()=>{P(s,"display","none")}),a(c,"click",()=>{t.seek=r,G(t.play()),P(i,"display","none"),P(s,"display","none")}),t.once("video:timeupdate",()=>{p=setTimeout(()=>{P(s,"display","none")},n.AUTO_PLAYBACK_TIMEOUT)}))}return t.on("video:timeupdate",()=>{if(t.playing){const e=o.get("times")||{},r=Object.keys(e);r.length>n.AUTO_PLAYBACK_MAX&&delete e[r[0]],e[t.option.id||t.option.url]=t.currentTime,o.set("times",e)}}),t.on("ready",h),t.on("restart",h),{name:"auto-playback",get times(){return o.get("times")||{}},clear:()=>o.del("times"),delete(t){const e=o.get("times")||{};return delete e[t],o.set("times",e),e}}}function be(t){const{constructor:e,proxy:r,template:{$player:o,$video:n}}=t;let a=null,i=!1,s=1;const l=()=>{clearTimeout(a),i&&(i=!1,t.playbackRate=s,z(o,"art-fast-forward"))};return r(n,"touchstart",r=>{1===r.touches.length&&t.playing&&!t.isLock&&(a=setTimeout(()=>{i=!0,s=t.playbackRate,t.playbackRate=e.FAST_FORWARD_VALUE,C(o,"art-fast-forward")},e.FAST_FORWARD_TIME))}),t.on("document:touchmove",l),t.on("document:touchend",l),{name:"fastForward",get state(){return L(o,"art-fast-forward")}}}function we(t){const{layers:e,icons:r,template:{$player:o}}=t;function n(){return L(o,"art-lock")}function a(){C(o,"art-lock"),t.isLock=!0,t.emit("lock",!0)}function i(){z(o,"art-lock"),t.isLock=!1,t.emit("lock",!1)}return e.add({name:"lock",mounted(e){const o=S(e,r.lock),n=S(e,r.unlock);P(o,"display","none"),t.on("lock",t=>{t?(P(o,"display","inline-flex"),P(n,"display","none")):(P(o,"display","none"),P(n,"display","inline-flex"))})},click(){n()?i():a()}}),{name:"lock",get state(){return n()},set state(t){t?a():i()}}}function xe(t){return t.on("control",e=>{e?z(t.template.$player,"art-mini-progress-bar"):C(t.template.$player,"art-mini-progress-bar")}),{name:"mini-progress-bar"}}class ke{constructor(t){this.art=t,this.id=0;const{option:e}=t;!function(t,e){At(t.art)||!e.miniProgressBar||e.isLive||t.add(xe),!At(t.art)&&e.lock&&k&&t.add(we),At(t.art)||!e.autoPlayback||e.isLive||t.add(ye),!At(t.art)&&e.autoOrientation&&k&&t.add(ve),!At(t.art)&&e.fastForward&&k&&!e.isLive&&t.add(be)}(this,e);for(let r=0;rconsole.warn("Failed to initialize ArtPlayer plugin:",t))}}add(t){X(!At(this.art),"Cannot add a plugin after ArtPlayer is destroyed"),this.id+=1;const e=t.call(this.art,this.art);return e instanceof Promise?e.then(e=>this.next(t,e)):this.next(t,e)}next(t,e){return function(t,e,r){if(At(t.art))return t;const o=r&&r.name||e.name||`plugin${t.id}`;if(At(t.art))return t;let n=o;const a=st(t,n);if(At(t.art))return t;const i=`Cannot add a plugin that already has the same name: ${o}`;return At(t.art)||(X(!a,i),("object"===typeof o&&null!==o||"function"===typeof o)&&(n=Reflect.ownKeys({[n]:void 0})[0]),At(t.art)||at(t,n,{value:r})),t}(this,t,e)}}class $e extends Et{constructor(t){super(t);const{option:e,controls:r,template:{$setting:o}}=t;this.name="setting",this.$parent=o,this.id=0,this.active=null,this.cache=new Map,this.option=[...this.builtin,...e.settings],e.setting&&(this.format(),this.render(),t.on("blur",()=>{this.show&&(this.show=!1,this.render())}),t.on("focus",t=>{const e=V(t,r.setting),o=V(t,this.$parent);!this.show||e||o||(this.show=!1,this.render())}),t.on("resize",()=>this.resize()))}get builtin(){const t=[],{option:e}=this.art;return e.playbackRate&&t.push(function(t){const{i18n:e,icons:r,constructor:{SETTING_ITEM_WIDTH:o,PLAYBACK_RATE:n}}=t;function a(t){return 1===t?e.get("Normal"):t.toFixed(1)}function i(){const e=t.setting.find(`playback-rate-${t.playbackRate}`);t.setting.check(e)}return{width:o,name:"playback-rate",html:e.get("Play Speed"),tooltip:a(t.playbackRate),icon:r.playbackRate,selector:n.map(e=>({value:e,name:`playback-rate-${e}`,default:e===t.playbackRate,html:a(e)})),onSelect:e=>(t.playbackRate=e.value,e.html),mounted:()=>{i(),t.on("video:ratechange",()=>i())}}}(this.art)),e.aspectRatio&&t.push(function(t){const{i18n:e,icons:r,constructor:{SETTING_ITEM_WIDTH:o,ASPECT_RATIO:n}}=t;function a(t){return"default"===t?e.get("Default"):t}function i(){const e=t.setting.find(`aspect-ratio-${t.aspectRatio}`);t.setting.check(e)}return{width:o,name:"aspect-ratio",html:e.get("Aspect Ratio"),icon:r.aspectRatio,tooltip:a(t.aspectRatio),selector:n.map(e=>({value:e,name:`aspect-ratio-${e}`,default:e===t.aspectRatio,html:a(e)})),onSelect:e=>(t.aspectRatio=e.value,e.html),mounted:()=>{i(),t.on("aspectRatio",()=>i())}}}(this.art)),e.flip&&t.push(function(t){const{i18n:e,icons:r,constructor:{SETTING_ITEM_WIDTH:o,FLIP:n}}=t;function a(t){return e.get(Q(t))}function i(){const e=t.setting.find(`flip-${t.flip}`);t.setting.check(e)}return{width:o,name:"flip",html:e.get("Video Flip"),tooltip:a(t.flip),icon:r.flip,selector:n.map(e=>({value:e,name:`flip-${e}`,default:e===t.flip,html:a(e)})),onSelect:e=>(t.flip=e.value,e.html),mounted:()=>{i(),t.on("flip",()=>i())}}}(this.art)),e.subtitleOffset&&t.push(function(t){const{i18n:e,icons:r,constructor:o}=t;return{width:o.SETTING_ITEM_WIDTH,name:"subtitle-offset",html:e.get("Subtitle Offset"),icon:r.subtitle,tooltip:"0s",range:[0,-10,10,.1],onChange:e=>(t.subtitleOffset=e.range[0],`${e.range[0]}s`),mounted:(e,r)=>{t.on("subtitleOffset",t=>{r.$range.value=t,r.tooltip=`${t}s`})}}}(this.art)),t}traverse(t,e=this.option){var r;for(let o=0;o{e.default=e===t,e.default&&e.$item&&O(e.$item,"art-current")},t.$option),this.render(t.$parents))}format(t=this.option,e,r,o=[]){for(let n=0;ne}),at(a,"$parents",{get:()=>r}),at(a,"$option",{get:()=>t});const o=[];at(a,"$events",{get:()=>o}),at(a,"$formatted",{get:()=>!0})}this.format(a.selector||[],a,t,o)}this.option=t}find(t=""){let e=null;return this.traverse(r=>{r.name===t&&(e=r)}),e}resize(){var t,e;const{controls:r,constructor:{SETTING_WIDTH:o,SETTING_ITEM_HEIGHT:n},template:{$player:a,$setting:i}}=this.art;if(r.setting&&this.show){const s=(null==(e=null==(t=this.active[0])?void 0:t.$parent)?void 0:e.width)||o,{left:l,width:c}=B(r.setting),{left:d,width:p}=B(a),h=l-d+c/2-s/2;if(P(i,"height",`${this.active===this.option?this.active.length*n:(this.active.length+1)*n}px`),P(i,"width",`${s}px`),this.art.isRotate||k)return;h+s>p?(P(i,"left",null),P(i,"right",null)):(P(i,"left",`${h}px`),P(i,"right","auto"))}}inactivate(t){for(let e=0;e'),s=N("div");C(s,"art-setting-item-left-icon"),S(s,o),S(i,s),S(i,t.$parent.html);const l=r(a,"click",()=>this.render(t.$parents));t.$parent.$events.push(l),S(e,a)}createItem(t,e=!1){var r,o;if(!this.cache.has(t.$option))return;const n=this.cache.get(t.$option),a=t.$item;let i="selector";st(t,"switch")&&(i="switch"),st(t,"range")&&(i="range"),st(t,"onClick")&&(i="button");const{icons:s,proxy:l,constructor:c}=this.art,p=N("div");C(p,"art-setting-item"),P(p,"height",`${c.SETTING_ITEM_HEIGHT}px`),p.dataset.name=t.name||"",p.dataset.value=t.value||"";const h=S(p,'
'),u=S(p,'
'),m=N("div");switch(C(m,"art-setting-item-left-icon"),i){case"button":case"switch":case"range":S(m,t.icon||s.config);break;case"selector":(null==(r=t.selector)?void 0:r.length)?S(m,t.icon||s.config):S(m,s.check)}S(h,m),at(t,"$icon",{configurable:!0,get:()=>m}),at(t,"icon",{configurable:!0,get:()=>m.innerHTML,set(t){m.innerHTML="",S(m,t)}});const f=N("div");C(f,"art-setting-item-left-text"),S(f,t.html||""),S(h,f),at(t,"$html",{configurable:!0,get:()=>f}),at(t,"html",{configurable:!0,get:()=>f.innerHTML,set(t){f.innerHTML="",S(f,t)}});const g=N("div");switch(C(g,"art-setting-item-right-tooltip"),S(g,t.tooltip||""),S(u,g),at(t,"$tooltip",{configurable:!0,get:()=>g}),at(t,"tooltip",{configurable:!0,get:()=>g.innerHTML,set(t){g.innerHTML="",S(g,t)}}),i){case"switch":{const e=N("div");C(e,"art-setting-item-right-icon");const r=S(e,s.switchOn),o=S(e,s.switchOff);P(t.switch?o:r,"display","none"),S(u,e),at(t,"$switch",{configurable:!0,get:()=>e});let n=t.switch;at(t,"switch",{configurable:!0,get:()=>n,set(t){n=t,t?(P(o,"display","none"),P(r,"display",null)):(P(o,"display",null),P(r,"display","none"))}});break}case"range":{const e=N("div");C(e,"art-setting-item-right-icon");const r=S(e,'');r.value=t.range[0],r.min=t.range[1],r.max=t.range[2],r.step=t.range[3],C(r,"art-setting-range"),S(u,e),at(t,"$range",{configurable:!0,get:()=>r});let o=[...t.range];at(t,"range",{configurable:!0,get:()=>o,set(t){o=[...t],r.value=t[0],r.min=t[1],r.max=t[2],r.step=t[3]}})}break;case"selector":if(null==(o=t.selector)?void 0:o.length){const t=N("div");C(t,"art-setting-item-right-icon"),S(t,s.arrowRight),S(u,t)}}switch(i){case"switch":if(t.onSwitch){const e=l(p,"click",e=>d(this,null,function*(){t.switch=yield t.onSwitch.call(this.art,t,p,e)}));t.$events.push(e)}break;case"range":if(t.$range){if(t.onRange){const e=l(t.$range,"change",e=>d(this,null,function*(){t.range[0]=t.$range.valueAsNumber,t.tooltip=yield t.onRange.call(this.art,t,p,e)}));t.$events.push(e)}if(t.onChange){const e=l(t.$range,"input",e=>d(this,null,function*(){t.range[0]=t.$range.valueAsNumber,t.tooltip=yield t.onChange.call(this.art,t,p,e)}));t.$events.push(e)}}break;case"selector":{const e=l(p,"click",e=>d(this,null,function*(){var r;(null==(r=t.selector)?void 0:r.length)?this.render(t.selector):(this.check(t),t.$parent.onSelect&&(t.$parent.tooltip=yield t.$parent.onSelect.call(this.art,t,p,e)))}));t.$events.push(e),t.default&&C(p,"art-current")}break;case"button":if(t.onClick){const e=l(p,"click",e=>d(this,null,function*(){t.tooltip=yield t.onClick.call(this.art,t,p,e)}));t.$events.push(e)}}at(t,"$item",{configurable:!0,get:()=>p}),e?Y(p,a):S(n,p),t.mounted&&Ot(Pt(this.art),()=>t.mounted.call(this.art,t.$item,t),0)}render(t=this.option){var e;if(this.active=t,this.cache.has(t)){O(this.cache.get(t),"art-current")}else{const r=N("div");this.cache.set(t,r),C(r,"art-setting-panel"),S(this.$parent,r),O(r,"art-current"),(null==(e=t[0])?void 0:e.$parent)&&this.createHeader(t[0]);for(let e=0;enull,this.init(t.option.subtitle);let e=!1;t.on("video:timeupdate",()=>{if(!this.url)return;const t=this.art.template.$video.webkitDisplayingFullscreen;"boolean"===typeof t&&t!==e&&(e=t,this.createTrack(t?"subtitles":"metadata",this.url))})}get url(){return this.art.template.$track.src}set url(t){this.switch(t)}get textTrack(){var t,e;return null==(e=null==(t=this.art.template.$video)?void 0:t.textTracks)?void 0:e[0]}get activeCues(){return this.textTrack?Array.from(this.textTrack.activeCues):[]}get cues(){return this.textTrack?Array.from(this.textTrack.cues):[]}style(t,e){const{$subtitle:r}=this.art.template;return"object"===typeof t?A(r,t):P(r,t,e)}update(){const{option:{subtitle:t},template:{$subtitle:e}}=this.art;e.innerHTML="",this.activeCues.length&&(this.art.emit("subtitleBeforeUpdate",this.activeCues),e.innerHTML=this.activeCues.map((e,r)=>e.text.split(/\r?\n/).filter(t=>t.trim()).map(e=>`
\n ${t.escape?nt(e):e}\n
`).join("")).join(""),this.art.emit("subtitleAfterUpdate",this.activeCues))}switch(t){return d(this,arguments,function*(t,e={}){const{i18n:r,notice:o,option:n}=this.art,a=c(l(l({},n.subtitle),e),{url:t}),i=yield this.init(a);return e.name&&(o.show=`${r.get("Switch Subtitle")}: ${e.name}`),i})}createTrack(t,e){const{template:r,proxy:o,option:n}=this.art,{$video:a,$track:i}=r,s=N("track");s.default=!0,s.kind=t,s.src=e,s.label=n.subtitle.name||"Artplayer",s.track.mode="hidden",s.onload=()=>{this.art.emit("subtitleLoad",this.cues,this.option)},this.art.events.remove(this.destroyEvent),i.onload=null,M(i),S(a,s),r.$track=s,this.destroyEvent=o(this.textTrack,"cuechange",()=>this.update())}init(t){return d(this,null,function*(){const{notice:e,template:{$subtitle:r}}=this.art;return this.textTrack?(f(t,$t.subtitle),t.url?(this.option=t,this.style(t.style),fetch(t.url).then(t=>t.arrayBuffer()).then(e=>{const r=new TextDecoder(t.encoding).decode(e);switch(t.type||K(t.url)){case"srt":{const e=dt(r);return pt(t.onVttLoad(e))}case"ass":{const e=ht(r);return pt(t.onVttLoad(e))}case"vtt":return pt(t.onVttLoad(r));default:return t.url}}).then(t=>(r.innerHTML="",this.url===t||(URL.revokeObjectURL(this.url),this.createTrack("metadata",t)),t)).catch(t=>{throw r.innerHTML="",e.show=t,t})):void 0):null})}}class ze{constructor(t){this.art=t;const{option:e,constructor:r}=t;e.container instanceof Element?this.$container=e.container:(this.$container=E(e.container),X(this.$container,`No container element found by ${e.container}`)),X(H(),"The current browser does not support flex layout");const o=this.$container.tagName.toLowerCase();X("div"===o,`Unsupported container element type, only support 'div' but got '${o}'`),X(r.instances.every(t=>t.template.$container!==this.$container),"Cannot mount multiple instances on the same dom element"),this.query=this.query.bind(this),function(t,e,r){const o=St.get(e);if(o&&o!==t)throw new Error("Cannot mount multiple instances on the same dom element");const n=Mt(t);n.rollback=r,St.set(e,t),n.releaseContainer=()=>{St.get(e)===t&&St.delete(e)}}(t,this.$container,function(t){const e=[];return function t(r){const o=Array.from(r.childNodes);e.push({node:r,children:o,attributes:1===r.nodeType?Array.from(r.attributes,t=>[t.name,t.value]):void 0,value:r.nodeValue}),o.forEach(t)}(t),()=>{for(const{node:t,children:r,attributes:o,value:n}of e){for(;t.firstChild;)t.removeChild(t.firstChild);for(const e of r)t.appendChild(e);if(o){const e=t;for(const t of Array.from(e.attributes))e.removeAttribute(t.name);for(const[t,r]of o)e.setAttribute(t,r)}else t.nodeValue=n}}}(this.$container)),this.$container.dataset.artId=t.id,this.init()}static get html(){return`\n
\n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
Player version:
\n
${g}
\n
\n
\n
Video url:
\n
\n
\n
\n
Video volume:
\n
\n
\n
\n
Video time:
\n
\n
\n
\n
Video duration:
\n
\n
\n
\n
Video resolution:
\n
\n x \n
\n
\n
\n
[x]
\n
\n
\n
\n `}query(t){return E(t,this.$container)}init(){const{option:t}=this.art;if(t.useSSR||(this.$container.innerHTML=ze.html),this.$player=this.query(".art-video-player"),this.$video=this.query(".art-video"),this.$track=this.query("track"),this.$poster=this.query(".art-poster"),this.$subtitle=this.query(".art-subtitle"),this.$danmuku=this.query(".art-danmuku"),this.$bottom=this.query(".art-bottom"),this.$progress=this.query(".art-progress"),this.$controls=this.query(".art-controls"),this.$controlsLeft=this.query(".art-controls-left"),this.$controlsCenter=this.query(".art-controls-center"),this.$controlsRight=this.query(".art-controls-right"),this.$layer=this.query(".art-layers"),this.$loading=this.query(".art-loading"),this.$notice=this.query(".art-notice"),this.$noticeInner=this.query(".art-notice-inner"),this.$mask=this.query(".art-mask"),this.$state=this.query(".art-state"),this.$setting=this.query(".art-settings"),this.$info=this.query(".art-info"),this.$infoPanel=this.query(".art-info-panel"),this.$infoClose=this.query(".art-info-close"),this.$contextmenu=this.query(".art-contextmenus"),t.proxy){const e=t.proxy.call(this.art,this.art);X(e instanceof HTMLVideoElement||e instanceof HTMLCanvasElement,"Function 'option.proxy' needs to return 'HTMLVideoElement' or 'HTMLCanvasElement'"),Y(e,this.$video),e.className="art-video",this.$video=e}t.backdrop&&C(this.$player,"art-backdrop"),k&&C(this.$player,"art-mobile")}destroy(t){t?this.$container.innerHTML="":C(this.$player,"art-destroy")}}const Le=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);class Se{on(t,e,r){const o=this.e||(this.e={});let n=Le(o,t)?o[t]:void 0;return n||(n=[],Object.defineProperty(o,t,{value:n,enumerable:!0,configurable:!0,writable:!0})),n.push({fn:e,ctx:r}),this}once(t,e,r){const o=this,n=e;let a=!1;function i(...e){a||(a=!0,o.off(t,i),n.apply(r,e))}return i._=e,this.on(t,i,r)}emit(t,...e){const r=this.e||(this.e={}),o=(Le(r,t)&&r[t]||[]).slice();for(const n of o)n.fn.apply(n.ctx,e);return this}off(t,e){const r=this.e||(this.e={}),o=Le(r,t)?r[t]:void 0,n=[];if(o&&e)for(let a=0,i=o.length;ae.call(this,this)),Ae.DEBUG){const t=t=>console.log(`[ART.${this.id}] -> ${t}`);t(`Version@${Ae.version}`);for(let e=0;et(`Event@${e.type}`))}(function(t){const e=Mt(t);return e.rollback=void 0,!e.scope.closed})(this)&&Pe.push(this)}catch(o){try{It(this,Pe,!0,Ae.REMOVE_SRC_WHEN_DESTROY,!0)}catch(n){console.warn("Failed to clean up ArtPlayer initialization:",n)}throw o}}static get instances(){return Pe}static get version(){return g}static get config(){return v}static get utils(){return mt}static get scheme(){return $t}static get Emitter(){return Se}static get validator(){return f}static get kindOf(){return f.kindOf}static get html(){return ze.html}static get option(){return{id:"",container:"#artplayer",url:"",poster:"",type:"",theme:"#f00",volume:.7,isLive:!1,muted:!1,autoplay:!1,autoSize:!1,autoMini:!1,loop:!1,flip:!1,playbackRate:!1,aspectRatio:!1,screenshot:!1,setting:!1,hotkey:!0,pip:!1,mutex:!0,backdrop:!0,fullscreen:!1,fullscreenWeb:!1,subtitleOffset:!1,miniProgressBar:!1,useSSR:!1,playsInline:!0,lock:!1,gesture:!0,fastForward:!1,autoPlayback:!1,autoOrientation:!1,airplay:!1,proxy:void 0,layers:[],contextmenu:[],controls:[],settings:[],quality:[],highlight:[],plugins:[],thumbnails:{url:"",number:60,column:10,width:0,height:0,scale:1},subtitle:{url:"",type:"",style:{},name:"",escape:!0,encoding:"utf-8",onVttLoad:t=>t},moreVideoAttr:{controls:!1,preload:b?"auto":"metadata"},i18n:{},icons:{},cssVar:{},customType:{},lang:null==navigator?void 0:navigator.language.toLowerCase()}}get proxy(){return this.events.proxy}get query(){return this.template.query}get video(){return this.template.$video}reset(){this.video.removeAttribute("src"),this.video.load()}destroy(t=!0){It(this,Pe,t,Ae.REMOVE_SRC_WHEN_DESTROY)}}return Ae.STYLE=Te,Ae.DEBUG=!1,Ae.CONTEXTMENU=!0,Ae.NOTICE_TIME=2e3,Ae.SETTING_WIDTH=250,Ae.SETTING_ITEM_WIDTH=200,Ae.SETTING_ITEM_HEIGHT=35,Ae.RESIZE_TIME=200,Ae.SCROLL_TIME=200,Ae.SCROLL_GAP=50,Ae.AUTO_PLAYBACK_MAX=10,Ae.AUTO_PLAYBACK_MIN=5,Ae.AUTO_PLAYBACK_TIMEOUT=3e3,Ae.RECONNECT_TIME_MAX=5,Ae.RECONNECT_SLEEP_TIME=1e3,Ae.CONTROL_HIDE_TIME=3e3,Ae.DBCLICK_TIME=300,Ae.DBCLICK_FULLSCREEN=!0,Ae.MOBILE_DBCLICK_PLAY=!0,Ae.MOBILE_CLICK_PLAY=!1,Ae.AUTO_ORIENTATION_TIME=200,Ae.INFO_LOOP_TIME=1e3,Ae.FAST_FORWARD_VALUE=3,Ae.FAST_FORWARD_TIME=1e3,Ae.TOUCH_MOVE_RATIO=.5,Ae.VOLUME_STEP=.1,Ae.SEEK_STEP=5,Ae.PLAYBACK_RATE=[.5,.75,1,1.25,1.5,2],Ae.ASPECT_RATIO=["default","4:3","16:9"],Ae.FLIP=["normal","horizontal","vertical"],Ae.FULLSCREEN_WEB_IN_BODY=!0,Ae.LOG_VERSION=!0,Ae.USE_RAF=!1,Ae.REMOVE_SRC_WHEN_DESTROY=!0,$&&(window.Artplayer=Ae,F("artplayer-style",Te),setTimeout(()=>{Ae.LOG_VERSION&&console.log(`%c ArtPlayer %c ${Ae.version} %c https://artplayer.org`,"color: #fff; background: #5f5f5f","color: #fff; background: #4bc729","")},100)),Ae}); diff --git a/packages/artplayer/dist/artplayer.mjs b/packages/artplayer/dist/artplayer.mjs index f5c1b90c0..099fdf3f9 100644 --- a/packages/artplayer/dist/artplayer.mjs +++ b/packages/artplayer/dist/artplayer.mjs @@ -1167,8 +1167,8 @@ function isClosing(owner) { return state2.destroying || state2.scope.closed; } function ownContainer(owner, container, rollback) { - const current = containers.get(container); - if (current && current !== owner) + const current2 = containers.get(container); + if (current2 && current2 !== owner) throw new Error("Cannot mount multiple instances on the same dom element"); const state2 = stateOf(owner); state2.rollback = rollback; @@ -3420,6 +3420,64 @@ function playingMix(art) { } }); } +const current = /* @__PURE__ */ new WeakMap(); +const assignments = /* @__PURE__ */ new WeakMap(); +function captureSource(owner) { + const operation = current.get(owner); + return () => current.get(owner) === operation && (!operation || operation.active()); +} +function beginSource(owner) { + const previous = current.get(owner); + const scope = getScope(owner).child(); + const operation = { + scope, + assigned: false, + acceptingEvents: false, + active: () => !isClosing(owner) && !scope.closed && current.get(owner) === operation + }; + current.set(owner, operation); + scope.add(() => { + if (current.get(owner) === operation) + current.delete(owner); + operation.onAssigned = void 0; + operation.onError = void 0; + }); + previous?.scope.dispose(); + return operation; +} +function takeAssignment(owner) { + const operation = assignments.get(owner); + assignments.delete(owner); + return operation || beginSource(owner); +} +function finishAssignment(operation) { + operation.assigned = true; + const callback = operation.onAssigned; + operation.onAssigned = void 0; + if (operation.active()) + callback?.(); +} +function assignUrl(owner, operation, url) { + assignments.set(owner, operation); + operation.acceptingEvents = true; + try { + owner.url = url; + } finally { + if (assignments.get(owner) === operation) { + assignments.delete(owner); + finishAssignment(operation); + } + } +} +function failSource(operation, error2) { + if (!operation.active()) + return; + if (operation.onError) + operation.onError(error2); + else + console.warn("Failed to initialize ArtPlayer source:", error2); + operation.scope.dispose(); +} function playMix(art) { const { i18n, @@ -3430,11 +3488,21 @@ function playMix(art) { } = art; def(art, "play", { async value() { + const active = captureSource(art); const result = await $video.play(); - notice.show = i18n.get("Play"); + if (!active()) + return result; + const message = i18n.get("Play"); + if (!active()) + return result; + notice.show = message; + if (!active()) + return result; art.emit("play"); if (option.mutex) { for (let index = 0; index < instances2.length; index++) { + if (!active()) + break; const instance = instances2[index]; if (instance !== art) { instance.pause(); @@ -3617,54 +3685,140 @@ function subtitleOffsetMix(art) { } }); } -function switchMix(art) { - function switchUrl(url, currentTime) { - return new Promise((resolve, reject) => { - if (url === art.url) { - resolve(); +function listenSource(scope, art, name, callback, once = true) { + let fired = false; + let release; + const guarded = (event) => { + if (scope.closed || fired) + return; + if (once) { + fired = true; + release(); + } + callback(event); + }; + art[once ? "once" : "on"](name, guarded); + release = scope.add(() => { + art.off(name, guarded); + }); + return guarded; +} +function switchSource(art, url, currentTime) { + return new Promise((resolve, reject) => { + if (isClosing(art) || url === art.url) { + resolve(); + return; + } + const operation = beginSource(art); + const scope = operation.scope.child(); + let settled = false; + const settle = (failed = false, error2) => { + if (settled) return; - } + settled = true; + operation.onError = void 0; + operation.onAssigned = void 0; + scope.dispose(); + if (failed) + reject(error2); + else + resolve(); + if (failed) + operation.scope.dispose(); + }; + scope.add(() => { + settle(); + }); + const active = () => !settled && operation.active(); + const fail = (error2) => settle(true, error2); + operation.onError = fail; + try { const { playing, aspectRatio: aspectRatio2, playbackRate: playbackRate2 } = art; art.pause(); - art.url = url; - art.notice.show = ""; - const handlers = {}; - handlers.error = (error2) => { - art.off("video:canplay", handlers.canplay); - art.off("video:loadedmetadata", handlers.metadata); - reject(error2); - }; - handlers.metadata = () => { - art.currentTime = currentTime; - }; - handlers.canplay = async () => { - art.off("video:error", handlers.error); - art.playbackRate = playbackRate2; - art.aspectRatio = aspectRatio2; - if (playing) { - await silencePromise(art.play()); + if (!active()) + return; + const readiness = scope.child(); + const handlers = { + "video:error": fail, + "video:loadedmetadata": () => { + if (!active()) + return; + try { + art.currentTime = currentTime; + } catch (error2) { + fail(error2); + } + }, + "video:canplay": () => { + if (!active()) + return; + readiness.dispose(); + const resume = async () => { + art.playbackRate = playbackRate2; + if (!active()) + return; + art.aspectRatio = aspectRatio2; + if (!active()) + return; + if (playing) { + try { + await art.play(); + } catch { + } + } + if (!active()) + return; + art.notice.show = ""; + settle(); + }; + void resume().catch(fail); } - art.notice.show = ""; - resolve(); }; - art.once("video:error", handlers.error); - art.once("video:loadedmetadata", handlers.metadata); - art.once("video:canplay", handlers.canplay); - }); - } - def(art, "switchQuality", { - value: (url) => { - return switchUrl(url, art.currentTime); + const capture = scope.child(); + const queued = []; + const names = Object.keys(handlers); + for (const name of names) { + listenSource(capture, art, name, (event) => { + if (operation.acceptingEvents) + queued.push([name, event]); + }, false); + } + assignUrl(art, operation, url); + if (!active()) + return; + art.notice.show = ""; + if (!active()) + return; + const activate = () => { + capture.dispose(); + if (!url) { + settle(); + return; + } + const dispatch = {}; + for (const name of names) + dispatch[name] = listenSource(readiness, art, name, handlers[name]); + for (const [name, event] of queued) { + if (!active() || readiness.closed) + break; + dispatch[name](event); + } + queued.length = 0; + }; + if (operation.assigned) + activate(); + else + operation.onAssigned = activate; + } catch (error2) { + fail(error2); } }); - def(art, "switchUrl", { - value: (url) => { - return switchUrl(url, 0); - } - }); - def(art, "switch", { - set: art.switchUrl - }); +} +function switchMix(art) { + const switchUrl = (url) => switchSource(art, url, 0); + def(art, "switchQuality", { value: (url) => switchSource(art, url, art.currentTime) }); + def(art, "switchUrl", { value: switchUrl }); + def(art, "switch", { set: switchUrl }); } function themeMix(art) { def(art, "theme", { @@ -3767,40 +3921,75 @@ function typeMix(art) { }); } function urlMix(art) { - const { - option, - template: { $video } - } = art; + const { option, template: { $video } } = art; def(art, "url", { get() { return $video.src; }, async set(newUrl) { - if (newUrl) { + if (isClosing(art)) + return; + const operation = takeAssignment(art); + operation.acceptingEvents = false; + try { + if (!newUrl) { + if (await wait(operation.scope) && operation.active()) + art.loading.show = true; + return; + } const oldUrl = art.url; const typeName = option.type || getExt(newUrl); const typeCallback = option.customType[typeName]; if (typeName && typeCallback) { - if (!await wait(getScope(art)) || getScope(art).closed) + if (!await wait(operation.scope) || !operation.active()) return; art.loading.show = true; - typeCallback.call(art, $video, newUrl, art); - } else { - URL.revokeObjectURL(oldUrl); - $video.src = newUrl; } + if (!operation.active()) + return; + const capture = operation.scope.child(); + let ready = false; + let failed = false; + listenSource(capture, art, "video:canplay", () => { + ready = !failed; + }); + listenSource(capture, art, "video:error", () => { + failed = true; + }); + try { + operation.acceptingEvents = true; + if (typeName && typeCallback) { + const result = typeCallback.call(art, $video, newUrl, art); + void Promise.resolve(result).catch((error2) => failSource(operation, error2)); + } else { + if (oldUrl) + URL.revokeObjectURL(oldUrl); + if (!operation.active()) + return; + $video.src = newUrl; + } + } finally { + capture.dispose(); + } + if (!operation.active()) + return; if (oldUrl !== art.url) { art.option.url = newUrl; - if (art.isReady && oldUrl) { - art.once("video:canplay", () => { - art.emit("restart", newUrl); - }); + if (operation.active() && art.isReady && oldUrl) { + const restart = () => { + if (operation.active()) + art.emit("restart", newUrl); + }; + if (ready) + restart(); + else if (!failed) + listenSource(operation.scope, art, "video:canplay", restart); } } - } else { - if (!await wait(getScope(art)) || getScope(art).closed) - return; - art.loading.show = true; + } catch (error2) { + failSource(operation, error2); + } finally { + finishAssignment(operation); } } }); diff --git a/packages/artplayer/src/player/playMix.ts b/packages/artplayer/src/player/playMix.ts index 2c21063c3..09e5e625b 100644 --- a/packages/artplayer/src/player/playMix.ts +++ b/packages/artplayer/src/player/playMix.ts @@ -1,5 +1,6 @@ import type { PlayHost } from '../media/hosts' import type { PlaybackMethods } from '../media/types' +import { captureSource } from '../source/operation' import { def } from '../utils' export default function playMix>(art: PlayHost): asserts art is PlayHost & { play: () => Promise>> } { @@ -13,12 +14,22 @@ export default function playMix>(art def(art, 'play', { async value() { + const active = captureSource(art) const result = await $video.play() - notice.show = i18n.get('Play') + if (!active()) + return result + const message = i18n.get('Play') + if (!active()) + return result + notice.show = message + if (!active()) + return result art.emit('play') if (option.mutex) { for (let index = 0; index < instances.length; index++) { + if (!active()) + break const instance = instances[index]! if (instance !== art) { instance.pause() diff --git a/packages/artplayer/src/player/switchMix.js b/packages/artplayer/src/player/switchMix.js deleted file mode 100644 index f8913f981..000000000 --- a/packages/artplayer/src/player/switchMix.js +++ /dev/null @@ -1,63 +0,0 @@ -import { def, silencePromise } from '../utils' - -export default function switchMix(art) { - function switchUrl(url, currentTime) { - return new Promise((resolve, reject) => { - if (url === art.url) { - resolve() - return - } - const { playing, aspectRatio, playbackRate } = art - - art.pause() - art.url = url - art.notice.show = '' - - const handlers = {} - - handlers.error = (error) => { - art.off('video:canplay', handlers.canplay) - art.off('video:loadedmetadata', handlers.metadata) - reject(error) - } - - handlers.metadata = () => { - art.currentTime = currentTime - } - - handlers.canplay = async () => { - art.off('video:error', handlers.error) - art.playbackRate = playbackRate - art.aspectRatio = aspectRatio - - if (playing) { - await silencePromise(art.play()) - } - - art.notice.show = '' - - resolve() - } - - art.once('video:error', handlers.error) - art.once('video:loadedmetadata', handlers.metadata) - art.once('video:canplay', handlers.canplay) - }) - } - - def(art, 'switchQuality', { - value: (url) => { - return switchUrl(url, art.currentTime) - }, - }) - - def(art, 'switchUrl', { - value: (url) => { - return switchUrl(url, 0) - }, - }) - - def(art, 'switch', { - set: art.switchUrl, - }) -} diff --git a/packages/artplayer/src/player/switchMix.ts b/packages/artplayer/src/player/switchMix.ts new file mode 100644 index 000000000..fc2814730 --- /dev/null +++ b/packages/artplayer/src/player/switchMix.ts @@ -0,0 +1,10 @@ +import type { SwitchHost, SwitchMethods } from '../source/types' +import { switchSource } from '../source/switch' +import { def } from '../utils' + +export default function switchMix(art: SwitchHost): asserts art is SwitchHost & SwitchMethods { + const switchUrl = (url: string) => switchSource(art, url, 0) + def(art, 'switchQuality', { value: (url: string) => switchSource(art, url, art.currentTime) }) + def(art, 'switchUrl', { value: switchUrl }) + def(art, 'switch', { set: switchUrl }) +} diff --git a/packages/artplayer/src/player/urlMix.js b/packages/artplayer/src/player/urlMix.js deleted file mode 100644 index bd14d4bda..000000000 --- a/packages/artplayer/src/player/urlMix.js +++ /dev/null @@ -1,48 +0,0 @@ -import { getScope } from '../lifecycle/instance' -import { wait } from '../lifecycle/resources' -import { def, getExt } from '../utils' - -export default function urlMix(art) { - const { - option, - template: { $video }, - } = art - - def(art, 'url', { - get() { - return $video.src - }, - async set(newUrl) { - if (newUrl) { - const oldUrl = art.url - const typeName = option.type || getExt(newUrl) - const typeCallback = option.customType[typeName] - - if (typeName && typeCallback) { - if (!await wait(getScope(art)) || getScope(art).closed) - return - art.loading.show = true - typeCallback.call(art, $video, newUrl, art) - } - else { - URL.revokeObjectURL(oldUrl) - $video.src = newUrl - } - - if (oldUrl !== art.url) { - art.option.url = newUrl - if (art.isReady && oldUrl) { - art.once('video:canplay', () => { - art.emit('restart', newUrl) - }) - } - } - } - else { - if (!await wait(getScope(art)) || getScope(art).closed) - return - art.loading.show = true - } - }, - }) -} diff --git a/packages/artplayer/src/player/urlMix.ts b/packages/artplayer/src/player/urlMix.ts new file mode 100644 index 000000000..dfee86292 --- /dev/null +++ b/packages/artplayer/src/player/urlMix.ts @@ -0,0 +1,87 @@ +import type { SourceMedia, UrlHost } from '../source/types' +import { isClosing } from '../lifecycle/instance' +import { wait } from '../lifecycle/resources' +import { listenSource } from '../source/listen' +import { failSource, finishAssignment, takeAssignment } from '../source/operation' +import { def, getExt } from '../utils' + +export default function urlMix>(art: Host): void { + const { option, template: { $video } } = art + def(art, 'url', { + get() { + return $video.src + }, + async set(newUrl: string) { + if (isClosing(art)) + return + const operation = takeAssignment(art) + operation.acceptingEvents = false + try { + if (!newUrl) { + if (await wait(operation.scope) && operation.active()) + art.loading.show = true + return + } + const oldUrl = art.url + const typeName = option.type || getExt(newUrl) + const typeCallback = option.customType[typeName] + if (typeName && typeCallback) { + if (!await wait(operation.scope) || !operation.active()) + return + art.loading.show = true + } + if (!operation.active()) + return + // Proxies can synchronously dispatch readiness from their src setter. + const capture = operation.scope.child() + let ready = false + let failed = false + listenSource(capture, art, 'video:canplay', () => { + ready = !failed + }) + listenSource(capture, art, 'video:error', () => { + failed = true + }) + try { + operation.acceptingEvents = true + if (typeName && typeCallback) { + const result = typeCallback.call(art, $video, newUrl, art) + // Preserve immediate customType invocation semantics while owning rejections. + void Promise.resolve(result).catch(error => failSource(operation, error)) + } + else { + if (oldUrl) + URL.revokeObjectURL(oldUrl) + if (!operation.active()) + return + $video.src = newUrl + } + } + finally { + capture.dispose() + } + if (!operation.active()) + return + if (oldUrl !== art.url) { + art.option.url = newUrl + if (operation.active() && art.isReady && oldUrl) { + const restart = () => { + if (operation.active()) + art.emit('restart', newUrl) + } + if (ready) + restart() + else if (!failed) + listenSource(operation.scope, art, 'video:canplay', restart) + } + } + } + catch (error) { + failSource(operation, error) + } + finally { + finishAssignment(operation) + } + }, + }) +} diff --git a/packages/artplayer/src/source/listen.ts b/packages/artplayer/src/source/listen.ts new file mode 100644 index 000000000..44d4e43ff --- /dev/null +++ b/packages/artplayer/src/source/listen.ts @@ -0,0 +1,21 @@ +import type ResourceScope from '../lifecycle/scope' +import type { SourceEvent, SourceEvents, SourceListener } from './types' + +export function listenSource(scope: ResourceScope, art: SourceEvents, name: SourceEvent, callback: SourceListener, once = true): SourceListener { + let fired = false + let release: () => void + const guarded: SourceListener = (event) => { + if (scope.closed || fired) + return + if (once) { + fired = true + release() + } + callback(event) + } + art[once ? 'once' : 'on'](name, guarded) + release = scope.add(() => { + art.off(name, guarded) + }) + return guarded +} diff --git a/packages/artplayer/src/source/operation.ts b/packages/artplayer/src/source/operation.ts new file mode 100644 index 000000000..9e6fe9f15 --- /dev/null +++ b/packages/artplayer/src/source/operation.ts @@ -0,0 +1,79 @@ +import type ResourceScope from '../lifecycle/scope' +import type { UrlTarget } from './types' +import { getScope, isClosing } from '../lifecycle/instance' + +export interface SourceOperation { + scope: ResourceScope + assigned: boolean + acceptingEvents: boolean + onAssigned?: () => void + onError?: (error: unknown) => void + active: () => boolean +} + +const current = new WeakMap() +const assignments = new WeakMap() + +export function captureSource(owner: object): () => boolean { + const operation = current.get(owner) + return () => current.get(owner) === operation && (!operation || operation.active()) +} + +export function beginSource(owner: object): SourceOperation { + const previous = current.get(owner) + const scope = getScope(owner).child() + const operation: SourceOperation = { + scope, + assigned: false, + acceptingEvents: false, + active: () => !isClosing(owner) && !scope.closed && current.get(owner) === operation, + } + current.set(owner, operation) + scope.add(() => { + if (current.get(owner) === operation) + current.delete(owner) + operation.onAssigned = undefined + operation.onError = undefined + }) + previous?.scope.dispose() + return operation +} + +export function takeAssignment(owner: object): SourceOperation { + const operation = assignments.get(owner) + assignments.delete(owner) + return operation || beginSource(owner) +} + +export function finishAssignment(operation: SourceOperation): void { + operation.assigned = true + const callback = operation.onAssigned + operation.onAssigned = undefined + if (operation.active()) + callback?.() +} + +export function assignUrl(owner: UrlTarget, operation: SourceOperation, url: string): void { + assignments.set(owner, operation) + operation.acceptingEvents = true + try { + owner.url = url + } + finally { + // Also support a host-provided URL setter without a core URL mixin. + if (assignments.get(owner) === operation) { + assignments.delete(owner) + finishAssignment(operation) + } + } +} + +export function failSource(operation: SourceOperation, error: unknown): void { + if (!operation.active()) + return + if (operation.onError) + operation.onError(error) + else + console.warn('Failed to initialize ArtPlayer source:', error) + operation.scope.dispose() +} diff --git a/packages/artplayer/src/source/switch.ts b/packages/artplayer/src/source/switch.ts new file mode 100644 index 000000000..26b223ad0 --- /dev/null +++ b/packages/artplayer/src/source/switch.ts @@ -0,0 +1,121 @@ +import type { SourceEvent, SourceListener, SwitchHost } from './types' +import { isClosing } from '../lifecycle/instance' +import { listenSource } from './listen' +import { assignUrl, beginSource } from './operation' + +export function switchSource(art: SwitchHost, url: string, currentTime: number): Promise { + return new Promise((resolve, reject) => { + if (isClosing(art) || url === art.url) { + resolve() + return + } + const operation = beginSource(art) + const scope = operation.scope.child() + let settled = false + const settle = (failed = false, error?: unknown) => { + if (settled) + return + settled = true + operation.onError = undefined + operation.onAssigned = undefined + scope.dispose() + if (failed) + reject(error) + else + resolve() + if (failed) + operation.scope.dispose() + } + scope.add(() => { + settle() + }) + const active = () => !settled && operation.active() + const fail = (error: unknown) => settle(true, error) + operation.onError = fail + try { + const { playing, aspectRatio, playbackRate } = art + art.pause() + if (!active()) + return + + const readiness = scope.child() + const handlers = { + 'video:error': fail, + 'video:loadedmetadata': () => { + if (!active()) + return + try { + art.currentTime = currentTime + } + catch (error) { + fail(error) + } + }, + 'video:canplay': () => { + if (!active()) + return + // Detach readiness handlers before awaiting a possibly pending play. + readiness.dispose() + const resume = async () => { + art.playbackRate = playbackRate + if (!active()) + return + art.aspectRatio = aspectRatio + if (!active()) + return + if (playing) { + // The public play promise still rejects; this internal resume is best effort. + try { + await art.play() + } + catch {} + } + if (!active()) + return + art.notice.show = '' + settle() + } + void resume().catch(fail) + }, + } + const capture = scope.child() + const queued: [SourceEvent, unknown][] = [] + const names = Object.keys(handlers) as SourceEvent[] + for (const name of names) { + listenSource(capture, art, name, (event) => { + if (operation.acceptingEvents) + queued.push([name, event]) + }, false) + } + assignUrl(art, operation, url) + if (!active()) + return + art.notice.show = '' + if (!active()) + return + const activate = () => { + capture.dispose() + if (!url) { + settle() + return + } + const dispatch = {} as Record + for (const name of names) + dispatch[name] = listenSource(readiness, art, name, handlers[name]) + for (const [name, event] of queued) { + if (!active() || readiness.closed) + break + dispatch[name](event) + } + queued.length = 0 + } + if (operation.assigned) + activate() + else + operation.onAssigned = activate + } + catch (error) { + fail(error) + } + }) +} diff --git a/packages/artplayer/src/source/types.ts b/packages/artplayer/src/source/types.ts new file mode 100644 index 000000000..da5f1cc2d --- /dev/null +++ b/packages/artplayer/src/source/types.ts @@ -0,0 +1,44 @@ +export type SourceEvent = 'video:error' | 'video:loadedmetadata' | 'video:canplay' +export type SourceListener = (event?: unknown) => void + +export interface SourceEvents { + on: (name: SourceEvent, callback: SourceListener) => unknown + once: (name: SourceEvent, callback: SourceListener) => unknown + off: (name: SourceEvent, callback: SourceListener) => unknown +} + +export interface SourceMedia { + src: string | null +} + +export interface UrlTarget { + url: string | null +} + +export interface UrlHost extends UrlTarget, SourceEvents { + template: { $video: Media } + option: { + url: string + type: string + customType: Record unknown) | undefined> + } + loading: { set show(value: boolean) } + isReady: boolean + emit: (name: 'restart', url: string) => unknown +} + +export interface SwitchHost extends UrlTarget, SourceEvents { + currentTime: number + readonly playing: boolean + aspectRatio: string + playbackRate: number + pause: () => unknown + play: () => unknown + notice: { set show(value: string) } +} + +export interface SwitchMethods { + switchUrl: (url: string) => Promise + switchQuality: (url: string) => Promise + set switch(url: string) +} diff --git a/refactor/baselines/source-operations-validation.json b/refactor/baselines/source-operations-validation.json new file mode 100644 index 000000000..77434e05c --- /dev/null +++ b/refactor/baselines/source-operations-validation.json @@ -0,0 +1,2959 @@ +{ + "task": "CORE-09", + "date": "2026-09-11", + "status": "validated", + "node": "v24.21.0", + "parentCommit": "874dac9f229acded285d413a87b96a0619311ac1", + "source": { + "packages/artplayer/src/config/index.js": "d6d2bd612daaf6c5c6e982158acbdf724b16d3c35bb5f1a5c923284665a8de79", + "packages/artplayer/src/contextmenu/aspectRatio.js": "bac04419497c2949d0bed8417930e2b6d2c2fc40d31a853a736f4fa81409fb34", + "packages/artplayer/src/contextmenu/close.js": "3aaaf06927882b76e88460aa79ae5b6e075d5fab5c40e4995c0a82dc5dbbdcd0", + "packages/artplayer/src/contextmenu/flip.js": "93221aacd5bfa9fa4b0ba7641cd4c2496f1e54eb12a004eff6e1e16c35519847", + "packages/artplayer/src/contextmenu/index.js": "d9691244110920060c2418c2c50d74efdd486e96a4fa316f84b848d35076793f", + "packages/artplayer/src/contextmenu/info.js": "7d2d23a63aa7fa319896f3ea8adb4739604d60696d3e8f0519a36ba241d30e85", + "packages/artplayer/src/contextmenu/playbackRate.js": "c2b15147d2f0f62f1a490f84ca2f8ecd23fcc37113806c364ab7ce128765fcfe", + "packages/artplayer/src/contextmenu/version.js": "b35e652e3b55628ec3ad2cd3a874009a03e277835e91ff5f291f286003d1726c", + "packages/artplayer/src/control/airplay.js": "1f4d6d793b73ff4b814161ded1f59a8aff5a13bf04c7fffc328ea29b69536e4c", + "packages/artplayer/src/control/fullscreen.js": "31a4cf1079e6c9e44d76252b791d8a51bd99c9cb64e39e897c61e820abe69728", + "packages/artplayer/src/control/fullscreenWeb.js": "8c69c403ed80d911dc7389c05894ed41827c4aac9cf53e12a41a43a9cb9148ce", + "packages/artplayer/src/control/index.js": "4114a06ddce38fdc2738868d9a9dd0fe2141d1ca905fdf4663f350d44504c9cb", + "packages/artplayer/src/control/pip.js": "bd8a1187214f6fce5599db9d4ca93141cde82d51f0db372e54e0c7ba199a1031", + "packages/artplayer/src/control/playAndPause.js": "0020d1bfac5609fdd5a8d3900646622dbf48d74ff3d60fc34c180b10ef117e3b", + "packages/artplayer/src/control/progress.js": "2064d0766b7f40a4ce812f92333a3dd728ba71b5b920e3fa3cbc67dd2bc38e2e", + "packages/artplayer/src/control/screenshot.js": "07044ef4d0c8c172447391cd2b5e5c4fcb98ee813a71d3270e0f2cfbaa3db900", + "packages/artplayer/src/control/setting.js": "2e5c4a6d3f463d7dd7a81698929acaf45d1f3966f86b9a226011da9f46e3ded7", + "packages/artplayer/src/control/time.js": "c39fb755a848ad77b1681adb3bad35fdc6ec9458ee57efa99ad31bd4d963d9b7", + "packages/artplayer/src/control/volume.js": "3572668f5c56b9b5f76b4e002a545e7e6dab199eb47686c8385a7751426ad118", + "packages/artplayer/src/events/clickInit.js": "bc680c921a958c25705962577513677d5d97de94e4eff6a04ba20d2f60e6a1be", + "packages/artplayer/src/events/gestureInit.js": "a5dcdb4216c8e3544fc85a1b4d3ebd929ec6f7d51ab17f2cee713030ae7ad464", + "packages/artplayer/src/events/globalInit.js": "5d8c3147f17755b0d35504cfc69cf8cbff510b66b2a52686d8f2a235a6c5b9df", + "packages/artplayer/src/events/hoverInit.js": "7ed5666e01972dc0955d1c1b4006001c99dd55ed133ca026f685b71d6b4d01c6", + "packages/artplayer/src/events/index.js": "94ddb9ad5ceb21901fbbc974d983fec60c488314474c89138e4ab2b40e205d5a", + "packages/artplayer/src/events/moveInit.js": "782d627260c9fdf46c0766876138f05836860bc9c2fa2c519d22b43f3d24de15", + "packages/artplayer/src/events/resizeInit.js": "26fc9628490e6c45ef741e7bc7c1353097b21da1dc83aae65dc80783226e36bc", + "packages/artplayer/src/events/updateInit.js": "1b4ef85c819ae68eb0de1791241b2c3d4e22bb108746518fa67f7c322591e55a", + "packages/artplayer/src/events/viewInit.js": "2b4ce508812b8f03cf5801a5e3a7eaa4a5a8b05d6be500d217aeb6231fb93a51", + "packages/artplayer/src/hotkey.js": "689fb87b2ed8a424cbc2880c8f70610b3695dc5b0346c9a5833699996682c0d6", + "packages/artplayer/src/i18n/ar.js": "61294854675d72444a370f06a16c8d84bcdc782e88010b3c5a59326a98d3af56", + "packages/artplayer/src/i18n/cs.js": "f44e651be5d24dfce25122ebae03c76bedb83b145aadec134f0438e85c08e17c", + "packages/artplayer/src/i18n/es.js": "93785fd99ecbc906abd396d525f6ae715cddcce4a7b9d556838b98e927abc693", + "packages/artplayer/src/i18n/fa.js": "0a6b8f61ff7d5ec1e2839caa5f790c8681462a553c64d38ca7ec1988309e02f1", + "packages/artplayer/src/i18n/fr.js": "90421a72e6f8e82503a067d6c28cbc8ab91331de1342d367c3bd86e0fb62f621", + "packages/artplayer/src/i18n/id.js": "1a48adf6c940ef24870faa9cf1025fb6de45a63dc13ad54fe1d18222be0f481c", + "packages/artplayer/src/i18n/index.js": "35a07de6ed556f88637b129a9affe4f1ae1168cac7dce1171c197e023e714bfd", + "packages/artplayer/src/i18n/pl.js": "7f2c358f4aca1acbfc5e9edacc6619512fffcd81081c49830b276ed7f7e5e22c", + "packages/artplayer/src/i18n/ru.js": "26ca6dd2468847d656d283cc817dd8b78fe332f39a7eee9e630c72078ccc3459", + "packages/artplayer/src/i18n/tr.js": "c85a257270df2ce213d722a33bf342098b140defa321c0f197356fea419f6624", + "packages/artplayer/src/i18n/vi.js": "0c957375d7b0f4804d7bcc46b766a0e2c2a2d8d72616f9d20da69bd83b93533d", + "packages/artplayer/src/i18n/zh-cn.js": "cd58122e0e38846741775bf10bb71e2529a45f1157f8eb1083116ae3d4e1c897", + "packages/artplayer/src/i18n/zh-tw.js": "cbf6d2d14d5242f32c32e13e346c741fc074c10c164e78a2dd5f65cfff68c9aa", + "packages/artplayer/src/icons/airplay.svg": "8c75a40f1bfacee2be2a425e132ff51f3712eba60679010f7b1349d4a04374bc", + "packages/artplayer/src/icons/arrow-left.svg": "8b9d544b7bd728d01747005fc7a2d63f822eed3b605393e2435b6733861b585f", + "packages/artplayer/src/icons/arrow-right.svg": "68c63d6d5810173ec9192c9e96ee7b6aefdc3b79d3c1329fb4d6c750f859fe10", + "packages/artplayer/src/icons/aspect-ratio.svg": "987752a87701523057d8dfa7c45a6a139c4542b96fdcfaf8665722bbeb41f3b2", + "packages/artplayer/src/icons/check.svg": "963ce0aee2337fdee951aa6c917cc75ee0b4e75158887ccc16baebfd3925942b", + "packages/artplayer/src/icons/close.svg": "ebabfe8044f48d5df4d13f4f906a163fd55a4d6f1dedb3b5ba95601209bc8888", + "packages/artplayer/src/icons/config.svg": "e1884d5411296b5cd1bfec7803b558b0afa5ab64478393977b07a662e2e0f15c", + "packages/artplayer/src/icons/error.svg": "b40c01e511a599c9dd369aeb9a3b2a0d1a76ef3c5ede8124cbbc23f8e4e7248c", + "packages/artplayer/src/icons/fast-forward.svg": "abef6fe4d75ffa74d3a84683373b4702a4eda2a5b4045952f969ee62cc68b0be", + "packages/artplayer/src/icons/flip.svg": "474a9d53a97add71e3fb7bc6530a68580ce63a1d83f9b75d1c2908a7cf494152", + "packages/artplayer/src/icons/fullscreen-off.svg": "71125ac56586897e2c0e52035a4d65cff34cf52043a95b45d186e0d268671399", + "packages/artplayer/src/icons/fullscreen-on.svg": "d46cdf265cac729c9b7382722ebe7a4c76d71ad4e5a27c2d5ed8323fd595ebf5", + "packages/artplayer/src/icons/fullscreen-web-off.svg": "52a6862ecd7cba12ab7042de5064c498bc2e9f86b430358c912401fafe4f4a98", + "packages/artplayer/src/icons/fullscreen-web-on.svg": "5cfaae62b61456251e771bff01356fad8376ebedb10a4b8819740f60e6e5a073", + "packages/artplayer/src/icons/index.js": "2f258d42bf8dceb7a1b60fd8b3d20e9c338d06db8ce6bc5a7f80e84e935c275d", + "packages/artplayer/src/icons/loading.svg": "485472153890eff3ed49963f7bf7d841f66ca2f40894c01d6e8bcf1bf4ad1c58", + "packages/artplayer/src/icons/lock.svg": "431e9a25fae051016be0efa286387ec3e5f7651c3ecf569bf0ece9842f57156c", + "packages/artplayer/src/icons/pause.svg": "57405dba81dd3d9f329d957fdc704101cbb6f6654325eb0083c03324c4453a68", + "packages/artplayer/src/icons/pip.svg": "1e922140e0941e5b9ef53dc0b4776813e1c470ea229fe3ec786fd148148c3352", + "packages/artplayer/src/icons/play.svg": "41a961c629a55cb25a813e115a25204e492d4e935a0879177e65d6e1ddfd6796", + "packages/artplayer/src/icons/playback-rate.svg": "872deecac0365ab04aeb5ccb1cdd9a0c88589a1442709fdac7c0ed12a241ff2b", + "packages/artplayer/src/icons/screenshot.svg": "538b5cd0c6b20afb98bd850e15019072d652d191075c2869f2fc0f28b597b131", + "packages/artplayer/src/icons/setting.svg": "2976b00d1f03e78f28d0e55ebcb01d5a0746ec1a6ff8de97a5e8294bacdd1fad", + "packages/artplayer/src/icons/state.svg": "620a127f74bb5e249993bd7008c027373263eacb4a44af8adeaa0d7523346887", + "packages/artplayer/src/icons/switch-off.svg": "95a8d81a4a3bfcf7c016d5f71d46a72be73c5e94790c55fd1d31023416ef5deb", + "packages/artplayer/src/icons/switch-on.svg": "cccd0f9c1e54d9ac50c323360da944d8ff44633a82ff17889914b6bc8b1652ae", + "packages/artplayer/src/icons/unlock.svg": "fc058db3d99a475fb9ffbbbb6248978a95990a9c532b83d0955ac28eaa626c60", + "packages/artplayer/src/icons/volume-close.svg": "f7e100fd9e9f3f6e06afe5bc994d5d9305ee4d1ee23fae37e4108cf286dab379", + "packages/artplayer/src/icons/volume.svg": "3a78f40d8b48595e8f15d9189e4d767e0c7abbf0338d3f2db1ac810049dd3942", + "packages/artplayer/src/index.js": "1d7df75d280a43e25b4e2277445a2e6b6de3c5e95eb22eabd17c4a3b9af66c17", + "packages/artplayer/src/info.js": "6dcdb4457d63ddb74fb6268df64522722420d6c0eb7b1654d6fb7703466d3b8c", + "packages/artplayer/src/layer.js": "e96173ca177e0446738205dd753e267aa433d595f719d9a5bcd747dea3d32f66", + "packages/artplayer/src/libs/screenfull.js": "2332b50c0c6364d5c99080be0f5739255e4b9e465d2cca40f761adce9a1908f8", + "packages/artplayer/src/lifecycle/instance.ts": "19a89de4ae22cb57eea7302265ce07422d12d1aea5acb99deb44fd0dba351a13", + "packages/artplayer/src/lifecycle/resources.ts": "399ea5e84545c973f8967e8ffd7326dad7b3168ca6f96f77286995a5b62ee389", + "packages/artplayer/src/lifecycle/scope.ts": "e2188e8544b27cf8c7ac149e7146af628a2d6166c82b719a247adef5d85be5db", + "packages/artplayer/src/lifecycle/template-rollback.ts": "7a83da6739bcec1587b02f8157934988910d7f9103fe489a0d6f4f65290c3d77", + "packages/artplayer/src/loading.js": "4b08a8f9fa69f71d054cdf1508bbb9e92c075c8df1eda0fa8a79efbf08eb8c40", + "packages/artplayer/src/mask.js": "094162e28ec76c81f73bb7bfe276bf5832080ffb7aa9d9dc9dc013479659c2e5", + "packages/artplayer/src/media/hosts.ts": "7129cb93290a250e932464b71a4e4abce8a98e83935d4fd6c36a59fc6357b6af", + "packages/artplayer/src/media/types.ts": "96d4a7f066cbb6fb9138165dd736b4ca500cb19c827bd7702134d61c44cc0e87", + "packages/artplayer/src/notice.js": "72e97833e0499993d8d133111e32f32f031b911426117397be2003e824023664", + "packages/artplayer/src/option/defaults.ts": "f357ef80cf32085fcbc3409d92dfa27b31c13fbcf823f576052c0347911c0cca", + "packages/artplayer/src/option/resolve.ts": "53a73627cd540e3f21349c0a43beda35ea5195647a31e3f5b30ac292390b4b1b", + "packages/artplayer/src/option/types.ts": "f2ce01c01acf45fac6cbb34685b8e6c321bcad6b0da2526f3f189eb5962ea0e5", + "packages/artplayer/src/player/airplayMix.js": "b9ce49489e75045b6a1df4d8ed28f123c1b105ac4c04fefaabcffe4353ad004d", + "packages/artplayer/src/player/aspectRatioMix.js": "c0a4cbd84bd0d70f078d87fc2ed082ee81fd33eed12b6265fa2d6f043b8f0f97", + "packages/artplayer/src/player/attrMix.js": "c873d587ff71e024cfda5b5464d0c70a09a6a319da3f18fbaa7451a16c9ae055", + "packages/artplayer/src/player/autoHeightMix.js": "e7400a46eeb01416d5ac7c6b787295cd9b9f90b38ce640a737ef5a34a8affd6d", + "packages/artplayer/src/player/autoSizeMix.js": "341e8c6a6a1b451c43f758a7774d1cd6cdf9e1f9e818692e03eb58c2fbda4525", + "packages/artplayer/src/player/cssVarMix.js": "93e641dd760e8f844a643a0b7d8af92b73a7f205e55087d9501934d218701bd2", + "packages/artplayer/src/player/currentTimeMix.js": "4733317778fefe6155f9d5ef46652b4267178d0c08003467eeaff6bc9955b41d", + "packages/artplayer/src/player/durationMix.ts": "60a9d665cf302dcb6b3e37e2f057e31720935e5e588fd7709231f691f6014191", + "packages/artplayer/src/player/eventInit.js": "faee770b0cbe5a6f9dd3259518ba91f00c2df290348ed3829c809f3875aa6338", + "packages/artplayer/src/player/flipMix.js": "f5abb8d079d0a9c4f9eaa31c4940723bf407ba422ac713dc73443dfa6cb6ac4f", + "packages/artplayer/src/player/fullscreenMix.js": "fe28104d9b3ab5f197204b69950b14c274d17b7a918dc9c45f749884f2e41cb8", + "packages/artplayer/src/player/fullscreenWebMix.js": "85f8800b4ed9027cdfdf79387b2dc95ed130fb03de267b85ac37badc15967661", + "packages/artplayer/src/player/index.js": "c3eaeab0aa5015a51dfeeb4de6f25b02b8cd66e1f8471940367d628b5fd0bdec", + "packages/artplayer/src/player/loadedMix.js": "08dda96239d054848a34063479da94af98834ef334276d7d22fe49be1e94f62b", + "packages/artplayer/src/player/miniMix.js": "7355a66a23de47be91ab08dd28e8d54116aa2a603bd47b687014e4ab4736094e", + "packages/artplayer/src/player/optionInit.js": "9d1d9d276da2403a580498c62f947373e000d9cd6e4bef5831d272c3055b5592", + "packages/artplayer/src/player/pauseMix.ts": "5bbb68eab7dcf2170c944cabb8d4b82be4e6d7623e37ad6ea464b81c1028bc0b", + "packages/artplayer/src/player/pipMix.js": "15322751e235a70e6f9dc4d5e2b6b0ee6a8b93080370c6a90cd96268e101a8ab", + "packages/artplayer/src/player/playbackRateMix.js": "531f25b5a9d86a5d0a884dac1b812a9ebfb588d3be785a0459e52f181c1de2a0", + "packages/artplayer/src/player/playedMix.js": "a5e664643666c3692c4e473d0d6c1c8ed72d6126346b9630cc3e0cce1b9344c8", + "packages/artplayer/src/player/playingMix.ts": "968c9f6e6d23c233c77d62a593db64adcc6d1a2411f5f1c61a35c6996d6a54d9", + "packages/artplayer/src/player/playMix.ts": "60249fcacdc5b1bc6f33bcd806e8a4f5472cea21d40550b042794a75027fe34a", + "packages/artplayer/src/player/posterMix.js": "a96b0a9f5817919e373a5a55b43fe7ea94af357051c01ddd6ce9c68bc932ecba", + "packages/artplayer/src/player/qualityMix.js": "53d28d000bd0417e757e585d5c3460c5198d6d5067e7ea3d797244abd45b2832", + "packages/artplayer/src/player/rectMix.ts": "a741ee09fa3271df84363c5d73eac1b2e5adb39491f95f8112af81f1219ffed4", + "packages/artplayer/src/player/screenshotMix.js": "c64871270b224233ea67ff31c3fbc0c2e2eb35635da5e4d5a263b930fb96e6e7", + "packages/artplayer/src/player/seekMix.js": "6d3779a19220358523c846275971f43157e11e1dd172049ac9de6c7b4fdeea8a", + "packages/artplayer/src/player/stateMix.js": "06968c1697487670e02af73045caaa676a01088e76d047cc87802d3df80f7251", + "packages/artplayer/src/player/subtitleOffsetMix.js": "c0ebf552e025dc5ede6ff3e5c2a82ff3382610268130941e5f56746568ac5baf", + "packages/artplayer/src/player/switchMix.ts": "b47e174ef0edb2b96ff29f2ddd3c9f2dd2a38713db2a81002b18c89ce71994e9", + "packages/artplayer/src/player/themeMix.js": "382acfaf113fbd1ee77c63dba72953d984ea715f2d99748a12b9eae70c081d49", + "packages/artplayer/src/player/thumbnailsMix.js": "43bdbd9b62a803f4966103c6718305a9ef665d25df26f735d3e34558ddf339bf", + "packages/artplayer/src/player/toggleMix.js": "d29c407906c8407975756bf26090e0550f8cc38f0c6389836163161cf99a299c", + "packages/artplayer/src/player/typeMix.js": "70920c8f785dca6d4bd66d82b996c37f1b69265190d7747ae8de298afae3604e", + "packages/artplayer/src/player/urlMix.ts": "23ee05577af66e3608f9c6d63f060bd3de68a99b1992e4e35e45f16a08a8c14f", + "packages/artplayer/src/player/volumeMix.js": "38b9dd4a11cff3287769cace6fc161579eefb75af74c410b470083db6aba3251", + "packages/artplayer/src/plugins/autoOrientation.js": "6ceb81bb3a778323f88ecaa78ef5646b642dad3f7d3176031c4ce53815a8d153", + "packages/artplayer/src/plugins/autoPlayback.js": "26f4a21691a2b2f767304b7d2fe40a35c599575651b9ace0c55a709a2be279b8", + "packages/artplayer/src/plugins/builtins.ts": "4b9f83959ebaea9991636ee670c3344a5ede5990d1631177ca470ecc156ddc67", + "packages/artplayer/src/plugins/fastForward.js": "d1f396efb22a279f9450fd02f85dc2245d274dbf0d36c99e87a5e5f895cc0029", + "packages/artplayer/src/plugins/index.ts": "28d13abc95cbedafadae0fdb682bf86fda9b705191c51843943a5dadddbd0a53", + "packages/artplayer/src/plugins/lock.js": "843caf8c7981463e8dadf1510cd028e7e70049f5a10038bd66dfccbc63bb7886", + "packages/artplayer/src/plugins/miniProgressBar.js": "3bf48d30c209105a0144c17062d6ea4e2bdd351b1bc928df73ea1680b78462e2", + "packages/artplayer/src/plugins/registration.ts": "9891686c32aeaa33c48ca500cf30ab24ffbb0835c6248769b4c645a5ff20129b", + "packages/artplayer/src/plugins/types.ts": "6823098d5ec1bf053f60ddfdd36bfcd3f06f3b528cc5dd30fd676a1318dac590", + "packages/artplayer/src/scheme/index.ts": "dc4a3b5e08478cf72b46b0b59c023359ad5f79b891ea8a6a119ce24a5251821a", + "packages/artplayer/src/setting/aspectRatio.js": "c07e382eb4a2dd29d6bbf5c697274809777bd72091239e108ddc3ca15b60fa64", + "packages/artplayer/src/setting/flip.js": "d9972868640ec6ad1e6600aa97ed8cf75702552ecaafed49f16002939fd8f832", + "packages/artplayer/src/setting/index.js": "9c16ee2161e100e0223d2878ffc40dd6b410afa35acd5b1908d18242049f9675", + "packages/artplayer/src/setting/playbackRate.js": "063e196324bd6f0e0cd841292b70f469593949073b60c9999b250addf1208e81", + "packages/artplayer/src/setting/subtitleOffset.js": "d1a18118c34e6121dd030e464bfe9047330ea7a60a83045aa762272d0b4b455f", + "packages/artplayer/src/source/listen.ts": "c0596b98258c1544c8e4b762509646428450e56588da36908cb8583b8b716c37", + "packages/artplayer/src/source/operation.ts": "412898e91ad42c64d8fcf405b4d8047eedbed125178690af4eef6325cba0c5ed", + "packages/artplayer/src/source/switch.ts": "697ab56a765f957e3ce1da076c69cfc11dbf0901efecae0199cd94c729e0b236", + "packages/artplayer/src/source/types.ts": "1c27ee38826c0974f0afe0e36d1c0560e26263b21f202632fc85ed92585fb645", + "packages/artplayer/src/storage.js": "92067265b7f1104c4680e27e35726cf033811c6551e7c38d66028f2dd5300491", + "packages/artplayer/src/style/artplayer.less": "4e8513138d5d10c05b66986977d24ed17f1de3c0df3816dec6d90db7a97b5da3", + "packages/artplayer/src/style/aspectRatio.less": "091931a0cdc83e65a669332811ef3276b85bca9e55f7fff42aa46893d728c1ef", + "packages/artplayer/src/style/backdrop.less": "6c2cd0fa200d1f3525df98c3c56dbdc553445724aece3feb0386949245813343", + "packages/artplayer/src/style/bottom.less": "6fb307d8449fd04b804d5e72ea0f175f8aa9c9dd2bf1efbf756f800b39ac97ab", + "packages/artplayer/src/style/contextmenu.less": "70f6c7e26dc96652b659c7bf6fdad92737ed477dea69d253c57dc7266c76586d", + "packages/artplayer/src/style/controls.less": "4ff79f7bdb166f4e65455726c1879d003deb504cc175ea0d371ca6753ef0f155", + "packages/artplayer/src/style/danmuku.less": "e4215ee9fa2f1d0599e7311a2415cc975138265b7c6af0448d27d21b6c9e3511", + "packages/artplayer/src/style/flip.less": "5d3c7a81df9be455c2f683ebf48f39597d218dc2144addacb72ee1736bac3b7f", + "packages/artplayer/src/style/fullscreen.less": "dd350d3a0fc556d59b622a53c786b8c2a583e8fb28176e4b9e91baff90479496", + "packages/artplayer/src/style/fullscreenWeb.less": "d74e785c2fbbb2976e131620e751326f622f2916eceff9f2333059ca3296cdc9", + "packages/artplayer/src/style/hideCursor.less": "09a4607c8b0005dc199828172aa8dda395f861e407769b9696d793476c4a7823", + "packages/artplayer/src/style/hint.less": "ae9f3115dfdb1e2d7b8249497c080e6a25f9667f915f6e89820338d67bbc2d85", + "packages/artplayer/src/style/icon.less": "52d8f75c1d193e6160f57ca6997c3f9135adad8eb2338ed60c1eb8e5fe443be5", + "packages/artplayer/src/style/index.less": "ec67999b458d5545a4f17eeda922872823d655da012fa69113902629ad847548", + "packages/artplayer/src/style/info.less": "fa56d1b8c8936218e581b2426026e4ba85cd5fea20d045c4f69aca96be4059be", + "packages/artplayer/src/style/layers.less": "9653c581190bb22d60a706109819cd010908898740701c9526957b5682991c5f", + "packages/artplayer/src/style/loading.less": "185b0f05274196ba71fdb1d088b55af568f3342a495490c99c3f0e058a40659e", + "packages/artplayer/src/style/mask.less": "d1239a171b71ea6184cb4aee6660d74d6ffc0c48f7c47c3cf5fbe52d2e93ac92", + "packages/artplayer/src/style/mini.less": "a352e7a63f9529f18e6e389202fc277c500bc70acb38c7aa6eea9d7dba831c0f", + "packages/artplayer/src/style/mixins.less": "c6be95aa682f266749fe37cb89796fbec6488abc537174f817da79bdac6e00b5", + "packages/artplayer/src/style/mobile.less": "ff3f64fca5d2dd7ddd50385d88d9b2fa1a645909488ab7a0978ba4f1670b7c0e", + "packages/artplayer/src/style/notice.less": "72a935c0effc557a9d7ab3baccb2c3b77fc3a1783450b4e3178a40a5325fe369", + "packages/artplayer/src/style/plugins.less": "a59d0fedb13eb79ea5c0251273e6d603363922e389faf43d051cb03c590a6788", + "packages/artplayer/src/style/poster.less": "36b38fe138f8c9537ff4e93f7ec4f2dbdba1ec41d243d741ddf1da7c6581e546", + "packages/artplayer/src/style/progress.less": "59b9d95d49dbcb1be40752d7086239b6de5925b0574da231199d999e22ff4990", + "packages/artplayer/src/style/selector.less": "295012ba379a7e957a24476616a0c3623d6a06e82ebbdaa45b916dd6412d7f4f", + "packages/artplayer/src/style/setting.less": "409dbdc3dae8b7b9e16c2e41f53b2801514545fc07af0bef752221cbd8b4e35e", + "packages/artplayer/src/style/subtitle.less": "43b72a07292a01cef45adffbd94ee9d9419e2997e0295d38e230fea2c1c0e0ca", + "packages/artplayer/src/style/variables.less": "703739b2bdfc77bfde063d8788ef6b6a55b8730764baae8e7d755b7c54d8ecc7", + "packages/artplayer/src/style/video.less": "b89c6f6e27592d49825c68c9ab98d46e81cb1e5add855863f89d19637f98e35f", + "packages/artplayer/src/style/volume.less": "a3954794a9478d3872202b90d349c873cbb51639dcd7d1e3d73a55ce635fcd99", + "packages/artplayer/src/subtitle.js": "7f926d99cc581f38804a9400bfe7159d0c4ef4c15c887811f9443bbb5ae7dd20", + "packages/artplayer/src/template.js": "ef60334f381f419cffb4628ee460ae0d0159de1ed0a3296a43863ff49b44d263", + "packages/artplayer/src/utils/compatibility.js": "51290838ef62be8e4251f4db8ecdd45a626cecd8c732e4e53a1c55df8d454a13", + "packages/artplayer/src/utils/component.js": "b9b190d31e9275d357396f6617a3dae87530227a6c8ef22b5ffe7c541246b546", + "packages/artplayer/src/utils/dom.js": "d72f934f55db3cd91db93eb388fc958a653c959a5ef776fb146c114bf523b21e", + "packages/artplayer/src/utils/emitter.ts": "26a93d3ff35b53e71a5f3bb22c252a854559d8151ede50a66a28d9eefae6c008", + "packages/artplayer/src/utils/error.ts": "ba303c7d4e4228919088f9d608fa364596f5853ee646eda2008deee354866f38", + "packages/artplayer/src/utils/file.ts": "ea71d7fc0e818d473bf5a596211ba9d571e4febdf1878014eadefa8d0a98d4cc", + "packages/artplayer/src/utils/format.ts": "891df5b7542b713aef46bf2b93924f42e68eee574afd802db3e6c62ff2655ede", + "packages/artplayer/src/utils/index.ts": "5211af833dddb2937d25dcc772740d62f9d5c5039ce5505bffff0796d4afd756", + "packages/artplayer/src/utils/property.ts": "c737d4582a4382f4038d12dafdf8b43418e508c9b8b859b2f0cc17c20f370343", + "packages/artplayer/src/utils/subtitle.ts": "f058851d11a418e321a8a498472b67fa535fec2c7b5d3df739b6b4f263d00337", + "packages/artplayer/src/utils/time.ts": "b8ce3d50865f6c343e8e3ce9f5c87de565a87b4e9fbcbccbe7030e30e80b93fe" + }, + "tests": { + "test/source.test.js": "25d7466ce68ae81c65a7f7759189c80c357a5253ecba0197cecd1f7c101be3b9", + "test/playback.test.js": "af40485704227e0a9ec50cf4ea1ddbd2ff964288aabac31f55575c17cf726b86", + "test/helpers/playback.js": "04cc009a6231295d0ff1c4fde347df8878dc355cf2e74efe48582d359d2e2fd6", + "test/types/source.ts": "0cd6c84c3a7a107c8ece4b2594a192b8a25ef2190dfb21f732c2f6704446e708", + "test/browser/source.spec.js": "c43b32001b6ee69c23211df2e94b2a4194128c121197a78dbd21c83818c50215", + "package.json": "a41794a6d2b00130a0ce194c63431a957f9a996441d2bcd8565b09fd2d019ac0" + }, + "ci": { + "command": "yarn ci:check", + "passed": 137, + "unit": 108, + "engineering": 4, + "baseline": 25, + "strictSourceFiles": 38, + "logSha256": "96c01203d77f79f13fb6711054a562afef5a4d749f9fcf483fedb4807389ea48" + }, + "packages": [ + { + "name": "artplayer", + "version": "5.4.1", + "archive": "artplayer.tgz", + "sha256": "1ef88b09d19be7d5e3d7c609beaba4bec2d6f3357bac665ff88204b91ecbbeeb", + "files": { + "package/ARCHITECTURE.md": "dfc01bc1784a10f3f55701103ab55440dc60d210db1e249a36a8d384b693532c", + "package/README.md": "1e185e65f67fc2081b4182bbc6c4558ea05b6e3fa3acc5dd0c3ac7df1d542b09", + "package/dist/artplayer.js": "abf32b0a5d59904e09bbd04da4e09f76c324c22a8be0e5e26dd27f559b31c622", + "package/dist/artplayer.legacy.js": "7d2c5371576d9f076f34b5093852aafa66f3c0f6485c434365d13b7e6d45b4e3", + "package/dist/artplayer.mjs": "c20ba22e737781c6ad0e7cb1cfeb962daba352b310b623481d5985719b3f9e8c", + "package/dist/i18n/ar.js": "61c43469ee95a00dc624583f418653e3dcbf48b24ae6a4c203ad986234852365", + "package/dist/i18n/ar.mjs": "68922fdc9f80d3321ea0654c8ff8f5875b6715103d2b14ffcf17f93738b39cf9", + "package/dist/i18n/cs.js": "ad7bbf8853204a6955ef84bfbd932cab3f141a7e73a8145f28ba7a5b2b83b7c0", + "package/dist/i18n/cs.mjs": "29a489be767fda9d46b59c9adbaad323f17a5e67daf7f7aa78b7ce8fb5b4d63c", + "package/dist/i18n/es.js": "aaa95cc9645b734c58fba06fdbcdda962c4cb3a0e7eb6206f06d6168208cd86b", + "package/dist/i18n/es.mjs": "331d2ef74da2eec8f3304fec0b5340c795d9c1eec24e08167c9a7b66bf30973b", + "package/dist/i18n/fa.js": "c998467261cbdfd2c3fb16c0ae4b2c48c409f42f41aea35ed94766f1e12819d5", + "package/dist/i18n/fa.mjs": "b4c98894b46975cebf5ea9088bcf0b5bdfd408bc3c82f4e2e9128133c7de2d4d", + "package/dist/i18n/fr.js": "6b06e16b1fb01c8695fb5c10b32a00421399180de5dc5d845ce17010f2fd3e66", + "package/dist/i18n/fr.mjs": "abe8e3548fa7304f302e2c74818a6176edee8c3b65e33cb6f62e96d130749ee5", + "package/dist/i18n/id.js": "a5832c4bfc03c7f16418bf4b324d9773895541dc823ece9114741794737aad74", + "package/dist/i18n/id.mjs": "a40a433be6ca1ac1ee1810fe805ee60784d349e59b9ad82ea80201d660db4e68", + "package/dist/i18n/pl.js": "2491487062bdfc91d60f17c6e9a83ee196c991216d15f525fe3536b98873da2c", + "package/dist/i18n/pl.mjs": "ad8ea2c03785edbfe1f35761bec21b8a04213f9fa88a794d850bb3973564930f", + "package/dist/i18n/ru.js": "2d3a9ee6533cb6fa961f0a24a25ce63cc76992fca17e1769b6fa75104f8a1529", + "package/dist/i18n/ru.mjs": "a89b8c36cfd7c181c2b31aa823deda3d7c37b56b2b81746338c52ea1c1d93352", + "package/dist/i18n/tr.js": "438b06a4c3f479a2901b0085eaa7bdba8eaef87bdb07ff3faa559c85403fe433", + "package/dist/i18n/tr.mjs": "cc96f9cbb9c1587d5cd8f25b0b9800678ad76e93de089ae42c38dee16e6fe8fa", + "package/dist/i18n/vi.js": "1ffbd62843a902ea2967eab46432d3fc548f5633e53eed104314b523cacc46a8", + "package/dist/i18n/vi.mjs": "7872ded84622bcda20e8c1d70c597c2ba071b50701900efa47cc4683ee17f1a2", + "package/dist/i18n/zh-tw.js": "2d43577f98456488196921e1ec721695a95e1b8c827077286b02ce3fb987e8ff", + "package/dist/i18n/zh-tw.mjs": "7ec638b4babe59d3ab1d3e64abdd74a96fefb260a50e2cd7240f8d50a1340925", + "package/package.json": "38fa5a41fe142c34ba52ce4ecd7cc81f25a7aba5adbe9e8fab843caedbddc15c", + "package/types/COMPATIBILITY.md": "926ac48955ff3d7e48ed92897a6725f518637daa07de7d56b51338914c3e33e2", + "package/types/README.md": "7d41215995614d1bc7285f027bdd89dc2b9bf47c5d8fe4e86222c6a92f6d347c", + "package/types/artplayer.d.cts": "6f6e2418c66681bf369fac5a63d599e0bd1a592717474e50afcaa87420d0145a", + "package/types/artplayer.d.mts": "7857c8f54354c1aafff446fc46b991eecd93c04f226ab8ebd009a39a78f9ed32", + "package/types/artplayer.d.ts": "9f3e90bfd735e4bcac414e53a60340321852ec5b96b003f9a6f9fc450e4078fb", + "package/types/component.d.ts": "aa1c43be67322781b4b355b143bc69d9f29d22e578e4974d6a13e957a7c0334f", + "package/types/config.d.ts": "c4fd8681bf32b10c743e3e561c532520c8f32e43fd765524850b15e55cb91c72", + "package/types/cssVar.d.ts": "e027d82fb4f01c9ce7559cf679b2d5ee1962d3f7e5b4dd64ca21f472b933efb6", + "package/types/emitter.d.ts": "9c62551cdcc6dd3966bed8a7a85dd477435db977c91a294d2ac8f162f9592537", + "package/types/events.d.ts": "53ace64a29cbef8e0c30e124d09c71e1dfa3ba6cdeecde8c7f928161b54084ef", + "package/types/i18n.d.ts": "3e14759caf71f97f01650839248c8737c42d2c2979dabc43ad92b724da648708", + "package/types/icons.d.ts": "0d8e8e52e52130dd4a29bab551dd7a2a954797e42e92a6e068c85d583e23e6a4", + "package/types/language.d.cts": "1c9e0c47fae3c2d68c3e144d95a55071318a03bb31554dd049109efd3d0f95a4", + "package/types/language.d.mts": "c391e863012c77769e661afbf8fa949e9373aa88d17f58cbba7f5696edb8077f", + "package/types/legacy/language.d.ts": "c452ffd764ff9b29b819b3475c42395d2ea7a33560d8c186ef5df3844b9524c3", + "package/types/option.d.ts": "850e5264219b8b438c80694402225b690b131786677a5da0d22739ec2352d263", + "package/types/player.d.ts": "f1e50257df2ea592d0a0e1f36078dda77eaf2cf3b3d795307501396562d99f28", + "package/types/plugin.d.ts": "2a57e148fda00ee687da5036b890b0f611cb94bb403a1ed52602179060259d35", + "package/types/quality.d.ts": "7ed6ed78cea52991b2f6ddd2bd3b7bd8c5146fdfff7486fe8b814c3e632f1567", + "package/types/setting.d.ts": "d12a75b656fff70cbb30be4bffec46d9c4273636e8722bce971a4d2b188712a1", + "package/types/subtitle.d.ts": "d25b470e47d6a9bd696d9c1ad8adb58e56a208f05695186d513bc8c43c2e8acf", + "package/types/template.d.ts": "68aed9e97d006d6be4fabb8504ca84dafab770b0925f4d6e7319e67c82f21b0d", + "package/types/utils.d.ts": "494ec447ab467a07ddd7a2c2abf778b3fce69fd28a09aaa8ced9759f8de2e3f6" + } + }, + { + "name": "artplayer-plugin-chapter", + "version": "1.1.0", + "archive": "artplayer-plugin-chapter.tgz", + "sha256": "2abb2aa419b7cdd0d0f118905f7f202e57f5a7bf43b2c6691da3cc46f28bb3c5", + "files": { + "package/ARCHITECTURE.md": "20743bad87a174b0450e0d876b6aa6b2a9f47df296d479511ce7cc9298fdb57c", + "package/README.md": "b95400ff3d525621a15268bb56a2d353aacaaadefde7e735d7abd91a34edd96f", + "package/dist/artplayer-plugin-chapter.js": "6ac3dfe28f46084ac7caedd571b1a97dcee3cf9d708112f1b8bbd6566e1dc5c5", + "package/dist/artplayer-plugin-chapter.legacy.js": "6d9bff885412169e701670961aa00c2e46c4b42c9b9647ff4e6d198777d2a359", + "package/dist/artplayer-plugin-chapter.mjs": "26415cecab2c0198c566cef0232e20123413782d5bad7534a32939b3298617af", + "package/package.json": "24eec6907b3218439189adab6af3f932c1497c47c2d41209311c01042b07fd4f", + "package/types/artplayer-plugin-chapter.d.cts": "4f07514b37453cd6cea8e5aa28fa018ff31738e0d423c11a3b5eccd50ed30bcc", + "package/types/artplayer-plugin-chapter.d.mts": "610179754db36276e161a07bccf4eaba8b4480f053e716a2bcc5a1574871a171", + "package/types/artplayer-plugin-chapter.d.ts": "581aa2862e709601c87a23585f54a969ebd350be56a7469a31ff53f1311b578d" + } + } + ], + "runtime": [ + "DIST.cjs", + "DIST.cjs-legacy", + "DIST.esm", + "DIST.esm-default-only", + "DIST.esm-legacy", + "DIST.global-core", + "DIST.amd-core", + "DIST.global-core-legacy", + "DIST.amd-core-legacy", + "DIST.global-chapter", + "DIST.amd-chapter", + "DIST.global-chapter-legacy", + "DIST.amd-chapter-legacy", + "SSR.import-template", + "SSR.constructor-browser-only", + "DIST.i18n-cjs-esm-global", + "DIST.exports-boundary", + "DIST.direct-esm-file", + "EVENT.lazy-registry", + "EVENT.symbol-number-channels", + "EVENT.context-removal", + "EVENT.once-throw-consumed", + "EVENT.chain-context-arguments", + "EVENT.once-reentry", + "EVENT.dispatch-snapshot", + "EVENT.off-original-once", + "EVENT.throw-propagation" + ], + "types": [ + { + "compiler": "5.9.3", + "mode": "node10-commonjs", + "diagnostics": [] + }, + { + "compiler": "5.9.3", + "mode": "nodenext-cjs", + "diagnostics": [] + }, + { + "compiler": "5.9.3", + "mode": "bundler-esm", + "diagnostics": [] + }, + { + "compiler": "4.3.5", + "mode": "node10-commonjs", + "diagnostics": [] + }, + { + "compiler": "5.9.3", + "mode": "nodenext-esm", + "diagnostics": [] + } + ], + "browser": { + "stats": { + "startTime": "2026-09-10T18:30:45.013Z", + "duration": 47754.426999999996, + "expected": 183, + "skipped": 0, + "unexpected": 0, + "flaky": 0 + }, + "candidateMember": "artplayer.js", + "candidateSha256": "abf32b0a5d59904e09bbd04da4e09f76c324c22a8be0e5e26dd27f559b31c622", + "versions": { + "chromium": "153.0.8010.12", + "firefox": "155.0", + "webkit": "26.6" + }, + "cases": [ + { + "file": "chapter.spec.js", + "title": "published-only observations: blank title, NaN and once-only metadata are historical defects", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "candidate clears titles on blank chapters, zero hover and replacement", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "candidate rejects NaN and can recover after an invalid update", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "candidate releases only its listeners and DOM across multiple instances and early destruction", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "candidate ignores pending metadata initialization after immediate destroy", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "candidate deduplicates stylesheet injection while the document is loading", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "published-only observations: blank title, NaN and once-only metadata are historical defects", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "candidate clears titles on blank chapters, zero hover and replacement", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "candidate rejects NaN and can recover after an invalid update", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "candidate releases only its listeners and DOM across multiple instances and early destruction", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "candidate ignores pending metadata initialization after immediate destroy", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "candidate deduplicates stylesheet injection while the document is loading", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "published-only observations: blank title, NaN and once-only metadata are historical defects", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "candidate clears titles on blank chapters, zero hover and replacement", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "candidate rejects NaN and can recover after an invalid update", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "candidate releases only its listeners and DOM across multiple instances and early destruction", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "candidate ignores pending metadata initialization after immediate destroy", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "candidate deduplicates stylesheet injection while the document is loading", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "factory, registration, input normalization and safe title text", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "progress bars, real hover, title edges and boundary seek", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "sync update, Infinity, object identity, empty lists and invalid data", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "explicit source update and core-owned destruction", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "factory, registration, input normalization and safe title text", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "progress bars, real hover, title edges and boundary seek", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "sync update, Infinity, object identity, empty lists and invalid data", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "explicit source update and core-owned destruction", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "factory, registration, input normalization and safe title text", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "progress bars, real hover, title edges and boundary seek", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "sync update, Infinity, object identity, empty lists and invalid data", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "explicit source update and core-owned destruction", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "factory, registration, input normalization and safe title text", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "progress bars, real hover, title edges and boundary seek", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "sync update, Infinity, object identity, empty lists and invalid data", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "explicit source update and core-owned destruction", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "factory, registration, input normalization and safe title text", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "progress bars, real hover, title edges and boundary seek", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "sync update, Infinity, object identity, empty lists and invalid data", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "explicit source update and core-owned destruction", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "factory, registration, input normalization and safe title text", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "progress bars, real hover, title edges and boundary seek", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "sync update, Infinity, object identity, empty lists and invalid data", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "explicit source update and core-owned destruction", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "declarations.spec.js", + "title": "published: plugin, toggle, setting and static runtime return contracts", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "declarations.spec.js", + "title": "published: native subtitle update events carry cue arrays", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "declarations.spec.js", + "title": "candidate: plugin, toggle, setting and static runtime return contracts", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "declarations.spec.js", + "title": "candidate: native subtitle update events carry cue arrays", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "declarations.spec.js", + "title": "published: plugin, toggle, setting and static runtime return contracts", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "declarations.spec.js", + "title": "published: native subtitle update events carry cue arrays", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "declarations.spec.js", + "title": "candidate: plugin, toggle, setting and static runtime return contracts", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "declarations.spec.js", + "title": "candidate: native subtitle update events carry cue arrays", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "declarations.spec.js", + "title": "published: plugin, toggle, setting and static runtime return contracts", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "declarations.spec.js", + "title": "published: native subtitle update events carry cue arrays", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "declarations.spec.js", + "title": "candidate: plugin, toggle, setting and static runtime return contracts", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "declarations.spec.js", + "title": "candidate: native subtitle update events carry cue arrays", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "emitter.spec.js", + "title": "published: emitter event names and once across nested dispatch", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "emitter.spec.js", + "title": "candidate: emitter event names and once across nested dispatch", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "emitter.spec.js", + "title": "published: emitter event names and once across nested dispatch", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "emitter.spec.js", + "title": "candidate: emitter event names and once across nested dispatch", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "emitter.spec.js", + "title": "published: emitter event names and once across nested dispatch", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "emitter.spec.js", + "title": "candidate: emitter event names and once across nested dispatch", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "published: repeated destroy preserves other live instances", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: repeated destroy preserves other live instances", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: constructor plugin failure restores original DOM and clears resources", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: early proxy failure restores SSR nodes, attributes and text", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: reentrant destroy keeps sequence and does not repeat callbacks", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: destroying cancels queued resize, notice, RAF, reconnect and mounted work", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: constructor can synchronously destroy without entering the registry", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: partial Events initialization releases listeners before its property is assigned", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: live resize still coalesces and destroy cancels the next burst", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: a container is reserved during reentrant initialization", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "published: repeated destroy preserves other live instances", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: repeated destroy preserves other live instances", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: constructor plugin failure restores original DOM and clears resources", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: early proxy failure restores SSR nodes, attributes and text", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: reentrant destroy keeps sequence and does not repeat callbacks", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: destroying cancels queued resize, notice, RAF, reconnect and mounted work", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: constructor can synchronously destroy without entering the registry", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: partial Events initialization releases listeners before its property is assigned", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: live resize still coalesces and destroy cancels the next burst", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: a container is reserved during reentrant initialization", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "published: repeated destroy preserves other live instances", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: repeated destroy preserves other live instances", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: constructor plugin failure restores original DOM and clears resources", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: early proxy failure restores SSR nodes, attributes and text", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: reentrant destroy keeps sequence and does not repeat callbacks", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: destroying cancels queued resize, notice, RAF, reconnect and mounted work", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: constructor can synchronously destroy without entering the registry", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: partial Events initialization releases listeners before its property is assigned", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: live resize still coalesces and destroy cancels the next burst", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: a container is reserved during reentrant initialization", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "media-hosts.spec.js", + "title": "published: existing canvas proxy keeps media identity, playback and layout", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "media-hosts.spec.js", + "title": "candidate: existing canvas proxy keeps media identity, playback and layout", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "media-hosts.spec.js", + "title": "published: existing canvas proxy keeps media identity, playback and layout", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "media-hosts.spec.js", + "title": "candidate: existing canvas proxy keeps media identity, playback and layout", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "media-hosts.spec.js", + "title": "published: existing canvas proxy keeps media identity, playback and layout", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "media-hosts.spec.js", + "title": "candidate: existing canvas proxy keeps media identity, playback and layout", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "published: expanded option input preserves historical JS forms", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "published: configuration errors occur before mounting and preserve allocation timing", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "published: container identity, partial defaults, custom fields and normal callbacks", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "candidate: expanded option input preserves historical JS forms", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "candidate: configuration errors occur before mounting and preserve allocation timing", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "candidate: container identity, partial defaults, custom fields and normal callbacks", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "published: expanded option input preserves historical JS forms", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "published: configuration errors occur before mounting and preserve allocation timing", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "published: container identity, partial defaults, custom fields and normal callbacks", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "candidate: expanded option input preserves historical JS forms", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "candidate: configuration errors occur before mounting and preserve allocation timing", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "candidate: container identity, partial defaults, custom fields and normal callbacks", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "published: expanded option input preserves historical JS forms", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "published: configuration errors occur before mounting and preserve allocation timing", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "published: container identity, partial defaults, custom fields and normal callbacks", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "candidate: expanded option input preserves historical JS forms", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "candidate: configuration errors occur before mounting and preserve allocation timing", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "candidate: container identity, partial defaults, custom fields and normal callbacks", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "playback.spec.js", + "title": "published: real playback, pause, seek, switch and destroy", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "playback.spec.js", + "title": "candidate: real playback, pause, seek, switch and destroy", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "playback.spec.js", + "title": "controlled HTTP media failure emits a real video error", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "playback.spec.js", + "title": "Range, media identity and docs candidate routes", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "playback.spec.js", + "title": "published: real playback, pause, seek, switch and destroy", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "playback.spec.js", + "title": "candidate: real playback, pause, seek, switch and destroy", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "playback.spec.js", + "title": "controlled HTTP media failure emits a real video error", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "playback.spec.js", + "title": "Range, media identity and docs candidate routes", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "playback.spec.js", + "title": "published: real playback, pause, seek, switch and destroy", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "playback.spec.js", + "title": "candidate: real playback, pause, seek, switch and destroy", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "playback.spec.js", + "title": "controlled HTTP media failure emits a real video error", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "playback.spec.js", + "title": "Range, media identity and docs candidate routes", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "published: late plugin registration preserves fulfillment without reviving a closed candidate", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "candidate: late plugin registration preserves fulfillment without reviving a closed candidate", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "candidate: a plugin that closes construction prevents subsequent factories", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "candidate: constructor-owned rejection is reported once without an unhandled rejection", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "published: late plugin registration preserves fulfillment without reviving a closed candidate", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "candidate: late plugin registration preserves fulfillment without reviving a closed candidate", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "candidate: a plugin that closes construction prevents subsequent factories", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "candidate: constructor-owned rejection is reported once without an unhandled rejection", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "published: late plugin registration preserves fulfillment without reviving a closed candidate", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "candidate: late plugin registration preserves fulfillment without reviving a closed candidate", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "candidate: a plugin that closes construction prevents subsequent factories", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "candidate: constructor-owned rejection is reported once without an unhandled rejection", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "published: builtin order and live exclusions precede user plugins", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "candidate: builtin order and live exclusions precede user plugins", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "published: builtin order and live exclusions precede user plugins", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "candidate: builtin order and live exclusions precede user plugins", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "published: builtin order and live exclusions precede user plugins", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "candidate: builtin order and live exclusions precede user plugins", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "resource-scope.spec.js", + "title": "internal resource scope: native DOM, RAF, timer, fetch abort and URL release", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "resource-scope.spec.js", + "title": "internal resource scope: native DOM, RAF, timer, fetch abort and URL release", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "resource-scope.spec.js", + "title": "internal resource scope: native DOM, RAF, timer, fetch abort and URL release", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "published: rapid real-media switches identify the last restart and settle superseded work", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "published: destroy settles the candidate switch without waiting for detached media", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "candidate: rapid real-media switches identify the last restart and settle superseded work", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "candidate: destroy settles the candidate switch without waiting for detached media", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "candidate: quality switch restores position/rate and preserves real customType identities", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "candidate: real switch settles when the controlled native resume rejects", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "candidate: late native play completion cannot publish stale player effects", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "published: rapid real-media switches identify the last restart and settle superseded work", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "published: destroy settles the candidate switch without waiting for detached media", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "candidate: rapid real-media switches identify the last restart and settle superseded work", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "candidate: destroy settles the candidate switch without waiting for detached media", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "candidate: quality switch restores position/rate and preserves real customType identities", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "candidate: real switch settles when the controlled native resume rejects", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "candidate: late native play completion cannot publish stale player effects", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "published: rapid real-media switches identify the last restart and settle superseded work", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "published: destroy settles the candidate switch without waiting for detached media", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "candidate: rapid real-media switches identify the last restart and settle superseded work", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "candidate: destroy settles the candidate switch without waiting for detached media", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "candidate: quality switch restores position/rate and preserves real customType identities", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "candidate: real switch settles when the controlled native resume rejects", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "candidate: late native play completion cannot publish stale player effects", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "utils.spec.js", + "title": "published: subtitle object URL contains real VTT data", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "utils.spec.js", + "title": "published: download starts and removes its temporary anchor", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "utils.spec.js", + "title": "candidate: subtitle object URL contains real VTT data", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "utils.spec.js", + "title": "candidate: download starts and removes its temporary anchor", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "utils.spec.js", + "title": "candidate download releases the anchor even when click fails", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "utils.spec.js", + "title": "published: subtitle object URL contains real VTT data", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "utils.spec.js", + "title": "published: download starts and removes its temporary anchor", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "utils.spec.js", + "title": "candidate: subtitle object URL contains real VTT data", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "utils.spec.js", + "title": "candidate: download starts and removes its temporary anchor", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "utils.spec.js", + "title": "candidate download releases the anchor even when click fails", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "utils.spec.js", + "title": "published: subtitle object URL contains real VTT data", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "utils.spec.js", + "title": "published: download starts and removes its temporary anchor", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "utils.spec.js", + "title": "candidate: subtitle object URL contains real VTT data", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "utils.spec.js", + "title": "candidate: download starts and removes its temporary anchor", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "utils.spec.js", + "title": "candidate download releases the anchor even when click fails", + "engine": "webkit", + "status": "passed", + "retry": 0 + } + ] + }, + "legacyBrowser": { + "stats": { + "startTime": "2026-09-10T18:32:11.484Z", + "duration": 48578.331, + "expected": 183, + "skipped": 0, + "unexpected": 0, + "flaky": 0 + }, + "candidateMember": "artplayer.legacy.js", + "candidateSha256": "7d2c5371576d9f076f34b5093852aafa66f3c0f6485c434365d13b7e6d45b4e3", + "versions": { + "chromium": "153.0.8010.12", + "firefox": "155.0", + "webkit": "26.6" + }, + "cases": [ + { + "file": "chapter.spec.js", + "title": "published-only observations: blank title, NaN and once-only metadata are historical defects", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "candidate clears titles on blank chapters, zero hover and replacement", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "candidate rejects NaN and can recover after an invalid update", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "candidate releases only its listeners and DOM across multiple instances and early destruction", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "candidate ignores pending metadata initialization after immediate destroy", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "candidate deduplicates stylesheet injection while the document is loading", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "published-only observations: blank title, NaN and once-only metadata are historical defects", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "candidate clears titles on blank chapters, zero hover and replacement", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "candidate rejects NaN and can recover after an invalid update", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "candidate releases only its listeners and DOM across multiple instances and early destruction", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "candidate ignores pending metadata initialization after immediate destroy", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "candidate deduplicates stylesheet injection while the document is loading", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "published-only observations: blank title, NaN and once-only metadata are historical defects", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "candidate clears titles on blank chapters, zero hover and replacement", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "candidate rejects NaN and can recover after an invalid update", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "candidate releases only its listeners and DOM across multiple instances and early destruction", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "candidate ignores pending metadata initialization after immediate destroy", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "candidate deduplicates stylesheet injection while the document is loading", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "factory, registration, input normalization and safe title text", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "progress bars, real hover, title edges and boundary seek", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "sync update, Infinity, object identity, empty lists and invalid data", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "explicit source update and core-owned destruction", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "factory, registration, input normalization and safe title text", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "progress bars, real hover, title edges and boundary seek", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "sync update, Infinity, object identity, empty lists and invalid data", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "explicit source update and core-owned destruction", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "factory, registration, input normalization and safe title text", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "progress bars, real hover, title edges and boundary seek", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "sync update, Infinity, object identity, empty lists and invalid data", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "explicit source update and core-owned destruction", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "factory, registration, input normalization and safe title text", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "progress bars, real hover, title edges and boundary seek", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "sync update, Infinity, object identity, empty lists and invalid data", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "explicit source update and core-owned destruction", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "factory, registration, input normalization and safe title text", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "progress bars, real hover, title edges and boundary seek", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "sync update, Infinity, object identity, empty lists and invalid data", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "explicit source update and core-owned destruction", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "factory, registration, input normalization and safe title text", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "progress bars, real hover, title edges and boundary seek", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "sync update, Infinity, object identity, empty lists and invalid data", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "chapter.spec.js", + "title": "explicit source update and core-owned destruction", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "declarations.spec.js", + "title": "published: plugin, toggle, setting and static runtime return contracts", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "declarations.spec.js", + "title": "published: native subtitle update events carry cue arrays", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "declarations.spec.js", + "title": "candidate: plugin, toggle, setting and static runtime return contracts", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "declarations.spec.js", + "title": "candidate: native subtitle update events carry cue arrays", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "declarations.spec.js", + "title": "published: plugin, toggle, setting and static runtime return contracts", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "declarations.spec.js", + "title": "published: native subtitle update events carry cue arrays", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "declarations.spec.js", + "title": "candidate: plugin, toggle, setting and static runtime return contracts", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "declarations.spec.js", + "title": "candidate: native subtitle update events carry cue arrays", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "declarations.spec.js", + "title": "published: plugin, toggle, setting and static runtime return contracts", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "declarations.spec.js", + "title": "published: native subtitle update events carry cue arrays", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "declarations.spec.js", + "title": "candidate: plugin, toggle, setting and static runtime return contracts", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "declarations.spec.js", + "title": "candidate: native subtitle update events carry cue arrays", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "emitter.spec.js", + "title": "published: emitter event names and once across nested dispatch", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "emitter.spec.js", + "title": "candidate: emitter event names and once across nested dispatch", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "emitter.spec.js", + "title": "published: emitter event names and once across nested dispatch", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "emitter.spec.js", + "title": "candidate: emitter event names and once across nested dispatch", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "emitter.spec.js", + "title": "published: emitter event names and once across nested dispatch", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "emitter.spec.js", + "title": "candidate: emitter event names and once across nested dispatch", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "published: repeated destroy preserves other live instances", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: repeated destroy preserves other live instances", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: constructor plugin failure restores original DOM and clears resources", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: early proxy failure restores SSR nodes, attributes and text", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: reentrant destroy keeps sequence and does not repeat callbacks", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: destroying cancels queued resize, notice, RAF, reconnect and mounted work", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: constructor can synchronously destroy without entering the registry", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: partial Events initialization releases listeners before its property is assigned", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: live resize still coalesces and destroy cancels the next burst", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: a container is reserved during reentrant initialization", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "published: repeated destroy preserves other live instances", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: repeated destroy preserves other live instances", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: constructor plugin failure restores original DOM and clears resources", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: early proxy failure restores SSR nodes, attributes and text", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: reentrant destroy keeps sequence and does not repeat callbacks", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: destroying cancels queued resize, notice, RAF, reconnect and mounted work", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: constructor can synchronously destroy without entering the registry", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: partial Events initialization releases listeners before its property is assigned", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: live resize still coalesces and destroy cancels the next burst", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: a container is reserved during reentrant initialization", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "published: repeated destroy preserves other live instances", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: repeated destroy preserves other live instances", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: constructor plugin failure restores original DOM and clears resources", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: early proxy failure restores SSR nodes, attributes and text", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: reentrant destroy keeps sequence and does not repeat callbacks", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: destroying cancels queued resize, notice, RAF, reconnect and mounted work", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: constructor can synchronously destroy without entering the registry", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: partial Events initialization releases listeners before its property is assigned", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: live resize still coalesces and destroy cancels the next burst", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "lifecycle.spec.js", + "title": "candidate: a container is reserved during reentrant initialization", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "media-hosts.spec.js", + "title": "published: existing canvas proxy keeps media identity, playback and layout", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "media-hosts.spec.js", + "title": "candidate: existing canvas proxy keeps media identity, playback and layout", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "media-hosts.spec.js", + "title": "published: existing canvas proxy keeps media identity, playback and layout", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "media-hosts.spec.js", + "title": "candidate: existing canvas proxy keeps media identity, playback and layout", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "media-hosts.spec.js", + "title": "published: existing canvas proxy keeps media identity, playback and layout", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "media-hosts.spec.js", + "title": "candidate: existing canvas proxy keeps media identity, playback and layout", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "published: expanded option input preserves historical JS forms", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "published: configuration errors occur before mounting and preserve allocation timing", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "published: container identity, partial defaults, custom fields and normal callbacks", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "candidate: expanded option input preserves historical JS forms", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "candidate: configuration errors occur before mounting and preserve allocation timing", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "candidate: container identity, partial defaults, custom fields and normal callbacks", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "published: expanded option input preserves historical JS forms", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "published: configuration errors occur before mounting and preserve allocation timing", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "published: container identity, partial defaults, custom fields and normal callbacks", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "candidate: expanded option input preserves historical JS forms", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "candidate: configuration errors occur before mounting and preserve allocation timing", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "candidate: container identity, partial defaults, custom fields and normal callbacks", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "published: expanded option input preserves historical JS forms", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "published: configuration errors occur before mounting and preserve allocation timing", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "published: container identity, partial defaults, custom fields and normal callbacks", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "candidate: expanded option input preserves historical JS forms", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "candidate: configuration errors occur before mounting and preserve allocation timing", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "options.spec.js", + "title": "candidate: container identity, partial defaults, custom fields and normal callbacks", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "playback.spec.js", + "title": "published: real playback, pause, seek, switch and destroy", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "playback.spec.js", + "title": "candidate: real playback, pause, seek, switch and destroy", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "playback.spec.js", + "title": "controlled HTTP media failure emits a real video error", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "playback.spec.js", + "title": "Range, media identity and docs candidate routes", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "playback.spec.js", + "title": "published: real playback, pause, seek, switch and destroy", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "playback.spec.js", + "title": "candidate: real playback, pause, seek, switch and destroy", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "playback.spec.js", + "title": "controlled HTTP media failure emits a real video error", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "playback.spec.js", + "title": "Range, media identity and docs candidate routes", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "playback.spec.js", + "title": "published: real playback, pause, seek, switch and destroy", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "playback.spec.js", + "title": "candidate: real playback, pause, seek, switch and destroy", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "playback.spec.js", + "title": "controlled HTTP media failure emits a real video error", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "playback.spec.js", + "title": "Range, media identity and docs candidate routes", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "published: late plugin registration preserves fulfillment without reviving a closed candidate", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "candidate: late plugin registration preserves fulfillment without reviving a closed candidate", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "candidate: a plugin that closes construction prevents subsequent factories", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "candidate: constructor-owned rejection is reported once without an unhandled rejection", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "published: late plugin registration preserves fulfillment without reviving a closed candidate", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "candidate: late plugin registration preserves fulfillment without reviving a closed candidate", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "candidate: a plugin that closes construction prevents subsequent factories", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "candidate: constructor-owned rejection is reported once without an unhandled rejection", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "published: late plugin registration preserves fulfillment without reviving a closed candidate", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "candidate: late plugin registration preserves fulfillment without reviving a closed candidate", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "candidate: a plugin that closes construction prevents subsequent factories", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "candidate: constructor-owned rejection is reported once without an unhandled rejection", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "published: builtin order and live exclusions precede user plugins", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "candidate: builtin order and live exclusions precede user plugins", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "published: builtin order and live exclusions precede user plugins", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "candidate: builtin order and live exclusions precede user plugins", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "published: builtin order and live exclusions precede user plugins", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "plugins.spec.js", + "title": "candidate: builtin order and live exclusions precede user plugins", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "resource-scope.spec.js", + "title": "internal resource scope: native DOM, RAF, timer, fetch abort and URL release", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "resource-scope.spec.js", + "title": "internal resource scope: native DOM, RAF, timer, fetch abort and URL release", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "resource-scope.spec.js", + "title": "internal resource scope: native DOM, RAF, timer, fetch abort and URL release", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "published: rapid real-media switches identify the last restart and settle superseded work", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "published: destroy settles the candidate switch without waiting for detached media", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "candidate: rapid real-media switches identify the last restart and settle superseded work", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "candidate: destroy settles the candidate switch without waiting for detached media", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "candidate: quality switch restores position/rate and preserves real customType identities", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "candidate: real switch settles when the controlled native resume rejects", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "candidate: late native play completion cannot publish stale player effects", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "published: rapid real-media switches identify the last restart and settle superseded work", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "published: destroy settles the candidate switch without waiting for detached media", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "candidate: rapid real-media switches identify the last restart and settle superseded work", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "candidate: destroy settles the candidate switch without waiting for detached media", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "candidate: quality switch restores position/rate and preserves real customType identities", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "candidate: real switch settles when the controlled native resume rejects", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "candidate: late native play completion cannot publish stale player effects", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "published: rapid real-media switches identify the last restart and settle superseded work", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "published: destroy settles the candidate switch without waiting for detached media", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "candidate: rapid real-media switches identify the last restart and settle superseded work", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "candidate: destroy settles the candidate switch without waiting for detached media", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "candidate: quality switch restores position/rate and preserves real customType identities", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "candidate: real switch settles when the controlled native resume rejects", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "source.spec.js", + "title": "candidate: late native play completion cannot publish stale player effects", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "utils.spec.js", + "title": "published: subtitle object URL contains real VTT data", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "utils.spec.js", + "title": "published: download starts and removes its temporary anchor", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "utils.spec.js", + "title": "candidate: subtitle object URL contains real VTT data", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "utils.spec.js", + "title": "candidate: download starts and removes its temporary anchor", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "utils.spec.js", + "title": "candidate download releases the anchor even when click fails", + "engine": "chromium", + "status": "passed", + "retry": 0 + }, + { + "file": "utils.spec.js", + "title": "published: subtitle object URL contains real VTT data", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "utils.spec.js", + "title": "published: download starts and removes its temporary anchor", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "utils.spec.js", + "title": "candidate: subtitle object URL contains real VTT data", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "utils.spec.js", + "title": "candidate: download starts and removes its temporary anchor", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "utils.spec.js", + "title": "candidate download releases the anchor even when click fails", + "engine": "firefox", + "status": "passed", + "retry": 0 + }, + { + "file": "utils.spec.js", + "title": "published: subtitle object URL contains real VTT data", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "utils.spec.js", + "title": "published: download starts and removes its temporary anchor", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "utils.spec.js", + "title": "candidate: subtitle object URL contains real VTT data", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "utils.spec.js", + "title": "candidate: download starts and removes its temporary anchor", + "engine": "webkit", + "status": "passed", + "retry": 0 + }, + { + "file": "utils.spec.js", + "title": "candidate download releases the anchor even when click fails", + "engine": "webkit", + "status": "passed", + "retry": 0 + } + ] + }, + "limits": [ + "No remote CI or physical device run", + "Controlled native play replacement proves rejection/late-completion handling, not autoplay permission or codec support", + "Cancellation fulfills with undefined, which signals settlement and does not prove source activation", + "customType keeps the original video and player; already-started external SDK work remains adapter-owned", + "Old URL revocation policy remains for CORE-19; reconnect generation remains CORE-11" + ], + "discovery": { + "issue": "Actual playMix could overwrite a replacement source notice after a late native play resolution", + "reproduction": "test/source.test.js real play mixin regression failed with actual Play versus expected latest notice before captureSource was added", + "resolution": "Capture source identity in playMix, preserve native fulfillment/rejection, suppress obsolete notice/event/mutex effects" + } +} diff --git a/refactor/changes/2026-09-11-CORE-09-source-operations.md b/refactor/changes/2026-09-11-CORE-09-source-operations.md new file mode 100644 index 000000000..a48a572f8 --- /dev/null +++ b/refactor/changes/2026-09-11-CORE-09-source-operations.md @@ -0,0 +1,49 @@ +# CORE-09 URL 与切源操作 + +状态:完成;源码、生成产物、安装消费与本地三浏览器检查通过。全项目发布验收仍待后续任务。 + +## 行为决策 + +涉及 API-02/03/04/05/07/12。旧 switchUrl/switchQuality 返回 Promise,无取消结果类型。保持方法名、描述符、绑定行为、switch setter 与 switchUrl 的函数身份;保持严格字符串同 URL 快速返回。 + +每次真实 URL 赋值创建内部操作作用域。新的 switch 或直接 art.url 赋值使旧操作失效,销毁清理所有操作。被替代/销毁的 Promise 以 undefined 正常兑现,不新增 AbortError 拒绝;兑现仅表示该调用已结束,不能证明资源曾成功激活。需要确认当前源的应用仍通过 art.url、媒体事件及当前状态判断。实际媒体错误与 customType 抛出/拒绝保留原错误值;内部恢复播放失败仍正常结束切换,公开 play() 的拒绝不改变。 + +连续切源时只允许最新操作恢复位置、速率、比例、清理通知和发出 restart。普通原生事件注册顺序保持;源 setter 或 customType 同步发出媒体事件时,暂存到赋值完成后处理,防止先前遗漏。仅清除本操作监听器,不清空用户 Emitter 订阅。空 URL 保持旧 loading 行为且不替换媒体源;对应 switch 调用结束,不无限等待一个没有启动的加载。 + +## 模块 + +- player/urlMix.ts:公开 URL 描述符、customType 调用及 restart。 +- player/switchMix.ts:公开切源方法门面。 +- source/types.ts:最小媒体、宿主、事件和方法类型。 +- source/operation.ts:当前操作、URL 赋值令牌、失效与失败。 +- source/listen.ts:操作拥有的事件订阅与单次调用。 +- source/switch.ts:切源、事件暂存、状态恢复和 Promise 结算。 + +## 兼容边界与责任 + +customType 保留真实 video、art、this 和三个参数,不用代理对象替换。其内部已启动的 SDK、请求或用户 Promise 可以继续访问真实对象;核心只能取消尚未调用的回调、忽略过期返回/拒绝并清理自身订阅,不能声称取消任意外部代码。直接 URL 赋值没有可消费的 Promise,当前回调错误通过带原错误值的 console.warn 报告;switch 调用通过自身 Promise 拒绝报告。 + +媒体事件本身没有操作 ID;customType/proxy 仍负责让自己的事件与当前资源一致。核心的操作身份检查不能鉴别第三方继续向真实 video 或 art 发送的伪装成当前事件的过期回调。 + +补测真实 playMix 曾复现旧恢复把新通知覆盖成 Play;因此 playMix 也捕获当前源身份,晚到结果仍按原值兑现或拒绝,但不再写通知、发 play 或触发互斥暂停。同步正常路径及公开返回值保持。测试既使用受控覆盖函数,也使用实际 playMix,不能用前者代替后者。 + +旧 URL 的 revokeObjectURL 行为暂保留;对象 URL 的完整归属审计归 CORE-19。播放模块其余迁移归 CORE-10;过期重连归 CORE-11。不要把本任务的操作监听隔离当作这些模块也已全部处理。 + +## 验证与交付 + +证据见 [source-operations-validation.json](../baselines/source-operations-validation.json),记录完整源码/测试/包文件 SHA、安装检查、浏览器版本与逐项结果。 + +| 验证 | 结果 | +| --- | --- | +| yarn ci:check | 137 项:108 单元、4 工程、25 基线;严格编译 38 个生产 TS 文件 | +| 切源专项 Node | 新增 17 项,覆盖过期、销毁、同 URL、重入、同步事件、错误身份、真实 playMix 和回调身份 | +| 安装包类型 | TS 5.9.3 四组消费模式、TS 4.3.5 一组,均零诊断 | +| 安装包运行时 | 实际 tarball 仓库外安装,27 项通过;范围为核心及 chapter | +| 安装 UMD | Chromium/Firefox/WebKit 共 183 项,通过,无跳过/重试 | +| 安装 legacy | 同一套三浏览器共 183 项,通过,无跳过/重试 | + +测试入口:test/source.test.js、test/playback.test.js、test/types/source.ts、test/browser/source.spec.js。BASE-LIFE-01/02/06 已关闭,旧发布基线原样保留。原生 play 的受控拒绝/延迟用于验证 Promise 处理,不作为真实自动播放授权或 codec 支持证明。playMix 补充身份检查前的 180 项 UMD 通过只是阶段证据;最终以包含该修复的 183 项报告及匹配包指纹为准。 + +未执行远端 GitHub Actions、实体设备或全部生态包发布验收;这些不计为本任务已完成。 + +不升级版本、不改变依赖和锁文件。本任务完成后单独本地提交。回退按该任务完整提交回退源码、生成产物和文档,不能只恢复 JS 文件而保留调用方的 TS 逻辑。 diff --git a/refactor/plan.md b/refactor/plan.md index 131783ff8..4dccb05f7 100644 --- a/refactor/plan.md +++ b/refactor/plan.md @@ -4,7 +4,7 @@ 基线:`40fcda6a37d0049d42e49c1e64e70d4fd9ba5f7f`。总任务 214 项,范围 22 个包及工作区/示例。 -状态:todo 170 / doing 0 / blocked 0 / done 44 / deferred 0。风险 L/M/H 表示兼容风险,不表示工期。 +状态:todo 169 / doing 0 / blocked 0 / done 45 / deferred 0。风险 L/M/H 表示兼容风险,不表示工期。 前置依赖是启动条件;验收是完成条件。任务可以继续拆分,但不能复用或悄悄删除旧 ID。 @@ -112,7 +112,7 @@ | CORE-06 | artplayer
建立内部媒体与宿主类型 | CORE-05 | 原生 video、canvas shim、UI host 类型 | 不更改公开 art.video 用法,不以 HTMLVideoElement 断言掩盖 shim | M | done | | CORE-07 | artplayer
逐项协调公开声明差异 | CORE-02, CORE-06, BASE-07 | plugins/toggle/cue/setting/static 的旧新类型对照 | 每项有兼容重载/扩展或待决结论,不能删除旧类型样例;处理 BASE-TYPE-01/04,分别保留旧合法声明消费并验证真实返回;协调 BASE-TYPE-05 的 Utils 导出、descriptor 和 timer 旧声明差异 | H | done | | CORE-08 | artplayer
整理插件管理器与扩展类型 | CORE-03, CORE-07 | 注册流程、同步/异步结果、插件/事件扩展接口 | 旧插件同步可见性、重名与命名、销毁中异步插件保持明确语义;处理 baselines/lifecycle-coverage.md 的 BASE-LIFE-03 并增加候选正向回归;接续 CORE-07 / BASE-TYPE-04 的同步/异步注册返回声明冲突,内部返回类型精确,保留历史消费者 | H | done | -| CORE-09 | artplayer
整理 URL 与切源操作 | CORE-04, CORE-06, CORE-08 | url/switch/customType 的操作身份及取消方案 | 并发切源、错误、同 URL、销毁和 Promise 结算有契约;处理 baselines/lifecycle-coverage.md 的 BASE-LIFE-01/02/06 并增加候选正向回归 | H | todo | +| CORE-09 | artplayer
整理 URL 与切源操作 | CORE-04, CORE-06, CORE-08 | url/switch/customType 的操作身份及取消方案 | 并发切源、错误、同 URL、销毁和 Promise 结算有契约;处理 baselines/lifecycle-coverage.md 的 BASE-LIFE-01/02/06 并增加候选正向回归 | H | done | | CORE-10 | artplayer
迁移播放与时间/状态属性 | CORE-09 | play/pause/toggle/seek/volume/rate/duration 等模块 | 旧返回值、拒绝、mutex、位置恢复、属性描述符与事件通过;接续 CORE-07 / BASE-TYPE-04 的 toggle void 与实际 Promise 分支冲突,不吞拒绝 | H | todo | | CORE-11 | artplayer
整理媒体事件、ready 与重连 | CORE-10 | 媒体转发、重连、UI 响应职责分离 | readiness 次数/顺序、过期重连、原错误参数有回归 | H | todo | | CORE-12 | artplayer
迁移模板及公开资源入口 | CORE-06, CORE-04, BASE-04 | template/icons/i18n/style、SSR 与 proxy 挂载 | DOM/CSS/global/样式注入、i18n 子路径及 SSR import 保持;不把 SSR import/useSSR 保持扩大为服务端构造播放器;复跑 BASE-05 的 SSR import/模板、浏览器 useSSR 节点复用和非浏览器构造错误;接续 VENDOR-01/02,核对 screenfull/hint 复制版本、修改与分发通知,保留 DOM/CSS/fullscreen 行为 | H | todo | @@ -443,6 +443,7 @@ - CORE-06: [记录](changes/2026-09-11-CORE-06-media-hosts.md) [记录](baselines/media-hosts-validation.json) - CORE-07: [记录](changes/2026-09-11-CORE-07-declarations.md) [记录](baselines/declarations-validation.json) - CORE-08: [记录](changes/2026-09-11-CORE-08-plugin-manager.md) [记录](baselines/plugins-validation.json) +- CORE-09: [记录](changes/2026-09-11-CORE-09-source-operations.md) [记录](baselines/source-operations-validation.json) - PKG-CHAPTER-01: [记录](changes/2026-09-10-PKG-CHAPTER-01-contract.md) [记录](baselines/chapter-contract.md) - PKG-CHAPTER-02: [记录](changes/2026-09-10-PKG-CHAPTER-02-tests.md) [记录](baselines/chapter-validation.json) - PKG-CHAPTER-03: [记录](changes/2026-09-10-PKG-CHAPTER-03-typescript-modules.md) [记录](baselines/chapter-migration-validation.json) diff --git a/refactor/progress.md b/refactor/progress.md index d175c2a41..c6d7eb5c9 100644 --- a/refactor/progress.md +++ b/refactor/progress.md @@ -1,5 +1,9 @@ # 进度与证据 +## 当前实施:CORE-09 URL 与切源操作完成 + +URL/switch 门面迁移 TS,新增四个 source 模块,统一切源取消、事件清理、同步代理事件和 Promise 结算;真实 playMix 同步接入源身份,避免晚到播放覆盖新状态。137 项 Node/基线、安装 UMD 与 legacy 各 183 项三浏览器检查、打包 27 项运行时和五组类型检查通过。见 [交付](changes/2026-09-11-CORE-09-source-operations.md)。关闭 BASE-LIFE-01/02/06;customType 外部 SDK 清理、对象 URL 归属和过期重连仍由对应后续任务处理。当前 214 项,45 完成、169 待办;核心 33 个 TS 文件、chapter 5 个。下一项 CORE-10 播放与时间/状态属性。 + ## 当前实施:CORE-08 插件管理器 TS 完成 插件注册、内置装配、命名与内部类型拆成四个 TS 模块;修复销毁后晚到注册,保持 Promise 结算与同步可见性,新增共享类型扩展入口。120 项 Node/基线、安装 UMD 三浏览器 162 项及 legacy 插件/章节/生命周期 90 项通过;严格打包 27 项运行时、五组类型零诊断。见 [交付](changes/2026-09-11-CORE-08-plugin-manager.md)。关闭 BASE-LIFE-03;公开返回声明和各插件自有资源清理仍有后续责任。当前 214 项,44 完成、170 待办;核心 27 个 TS 文件、chapter 5 个。下一项 CORE-09 URL/切源操作。 diff --git a/refactor/risk-table.md b/refactor/risk-table.md index 6b34a26dd..aebe6221d 100644 --- a/refactor/risk-table.md +++ b/refactor/risk-table.md @@ -4,9 +4,9 @@ | ID | 状态 / 证据等级 | 条目 | 后续任务 | | --- | --- | --- | --- | -| BASE-LIFE-06 | open / 已复现 | Published switch leaves an unhandled rejection and an unsettled promise when resume fails | CORE-09 | -| BASE-LIFE-01 | open / 已复现 | Superseded switch resolves along with the latest source | CORE-09 | -| BASE-LIFE-02 | open / 已复现 | Switch remains unsettled during the bounded observation after destroy | CORE-09 | +| BASE-LIFE-06 | resolved / 已复现 | Published switch leaves an unhandled rejection and an unsettled promise when resume fails | CORE-09 | +| BASE-LIFE-01 | resolved / 已复现 | Superseded switch resolves along with the latest source | CORE-09 | +| BASE-LIFE-02 | resolved / 已复现 | Switch remains unsettled during the bounded observation after destroy | CORE-09 | | BASE-LIFE-03 | resolved / 已复现 | Async plugin registers its result after destroy | CORE-08 | | BASE-LIFE-04 | resolved / 已复现 | Destroying an instance twice unregisters a different live instance | CORE-04 | | BASE-LIFE-05 | resolved / 已复现 | Failed constructor leaves initialized markup/listeners until explicit probe cleanup | CORE-04 | diff --git a/refactor/risks.json b/refactor/risks.json index feee3296a..2522242ea 100644 --- a/refactor/risks.json +++ b/refactor/risks.json @@ -9,7 +9,7 @@ "id": "BASE-LIFE-06", "title": "Published switch leaves an unhandled rejection and an unsettled promise when resume fails", "confirmation": "reproduced", - "status": "open", + "status": "resolved", "owners": [ "CORE-09" ], @@ -20,13 +20,21 @@ ], "compatibleResolution": "按对应 CORE 任务修复,保持合法旧调用;异步取消需明确结算策略,不把 pending 或重复销毁当正常兼容要求。", "closureCriteria": "候选正向回归和旧新差异记录通过;有界观察问题不得仅靠延长等待隐藏。", - "workspaceState": "Current switchMix uses silencePromise and test/playback.test.js covers resume rejection. Published baseline still reproduces the old failure; preserve the existing workspace mitigation during migration." + "workspaceState": "Current switchMix uses silencePromise and test/playback.test.js covers resume rejection. Published baseline still reproduces the old failure; preserve the existing workspace mitigation during migration.", + "resolutionEvidence": [ + "refactor/changes/2026-09-11-CORE-09-source-operations.md", + "refactor/baselines/source-operations-validation.json", + "test/source.test.js", + "test/playback.test.js", + "test/browser/source.spec.js" + ], + "resolutionRationale": "Owned source generations settle superseded/destroyed calls with undefined, prevent stale restart/restoration and actual playMix effects, retain original load failures and best-effort resume settlement. Published baselines remain unchanged; real-media comparisons and controlled native-play tests cover the candidate." }, { "id": "BASE-LIFE-01", "title": "Superseded switch resolves along with the latest source", "confirmation": "reproduced", - "status": "open", + "status": "resolved", "owners": [ "CORE-09" ], @@ -35,13 +43,21 @@ "refactor/baselines/lifecycle-coverage.md" ], "compatibleResolution": "按对应 CORE 任务修复,保持合法旧调用;异步取消需明确结算策略,不把 pending 或重复销毁当正常兼容要求。", - "closureCriteria": "候选正向回归和旧新差异记录通过;有界观察问题不得仅靠延长等待隐藏。" + "closureCriteria": "候选正向回归和旧新差异记录通过;有界观察问题不得仅靠延长等待隐藏。", + "resolutionEvidence": [ + "refactor/changes/2026-09-11-CORE-09-source-operations.md", + "refactor/baselines/source-operations-validation.json", + "test/source.test.js", + "test/playback.test.js", + "test/browser/source.spec.js" + ], + "resolutionRationale": "Owned source generations settle superseded/destroyed calls with undefined, prevent stale restart/restoration and actual playMix effects, retain original load failures and best-effort resume settlement. Published baselines remain unchanged; real-media comparisons and controlled native-play tests cover the candidate." }, { "id": "BASE-LIFE-02", "title": "Switch remains unsettled during the bounded observation after destroy", "confirmation": "reproduced", - "status": "open", + "status": "resolved", "owners": [ "CORE-09" ], @@ -50,7 +66,15 @@ "refactor/baselines/lifecycle-coverage.md" ], "compatibleResolution": "按对应 CORE 任务修复,保持合法旧调用;异步取消需明确结算策略,不把 pending 或重复销毁当正常兼容要求。", - "closureCriteria": "候选正向回归和旧新差异记录通过;有界观察问题不得仅靠延长等待隐藏。" + "closureCriteria": "候选正向回归和旧新差异记录通过;有界观察问题不得仅靠延长等待隐藏。", + "resolutionEvidence": [ + "refactor/changes/2026-09-11-CORE-09-source-operations.md", + "refactor/baselines/source-operations-validation.json", + "test/source.test.js", + "test/playback.test.js", + "test/browser/source.spec.js" + ], + "resolutionRationale": "Owned source generations settle superseded/destroyed calls with undefined, prevent stale restart/restoration and actual playMix effects, retain original load failures and best-effort resume settlement. Published baselines remain unchanged; real-media comparisons and controlled native-play tests cover the candidate." }, { "id": "BASE-LIFE-03", diff --git a/refactor/tasks.json b/refactor/tasks.json index cfc274bdd..1ed7d019d 100644 --- a/refactor/tasks.json +++ b/refactor/tasks.json @@ -911,11 +911,14 @@ "CORE-06", "CORE-08" ], - "status": "todo", + "status": "done", "risk": "H", "deliverable": "url/switch/customType 的操作身份及取消方案", "acceptance": "并发切源、错误、同 URL、销毁和 Promise 结算有契约;处理 baselines/lifecycle-coverage.md 的 BASE-LIFE-01/02/06 并增加候选正向回归", - "evidence": [] + "evidence": [ + "changes/2026-09-11-CORE-09-source-operations.md", + "baselines/source-operations-validation.json" + ] }, { "id": "CORE-10", diff --git a/test/browser/source.spec.js b/test/browser/source.spec.js new file mode 100644 index 000000000..99e193cf5 --- /dev/null +++ b/test/browser/source.spec.js @@ -0,0 +1,146 @@ +import { expect, test } from './fixtures.js' + +for (const core of ['published', 'candidate']) { + test(`${core}: rapid real-media switches identify the last restart and settle superseded work`, async ({ page }) => { + await page.goto(`/test/player.html?core=${core}&chapter=published`) + await page.evaluate(() => window.createPlayer('/test/pattern.mp4?source=initial')) + await expect.poll(() => page.evaluate(() => window.art.isReady)).toBe(true) + const result = await page.evaluate(async () => { + const { art } = window + const restarts = [] + const order = [] + art.on('restart', url => restarts.push(url)) + art.on('video:canplay', () => order.push('canplay')) + art.on('restart', () => order.push('restart')) + let firstSettled = false + const first = art.switchUrl('/test/pattern.mp4?source=first').then(() => { + firstSettled = true + }) + const second = art.switchUrl('/test/pattern.mp4?source=second') + await Promise.resolve() + const early = firstSettled + await Promise.all([first, second]) + const result = { early, restarts, order, current: new URL(art.video.currentSrc).search, error: art.video.error?.code || 0, time: art.currentTime } + art.destroy() + return result + }) + expect(result.early).toBe(core === 'candidate') + expect(result.restarts).toEqual(core === 'candidate' + ? ['/test/pattern.mp4?source=second'] + : ['/test/pattern.mp4?source=first', '/test/pattern.mp4?source=second']) + expect(result.order[0]).toBe('canplay') + expect(result.current).toBe('?source=second') + expect(result.error).toBe(0) + expect(result.time).toBeCloseTo(0, 1) + }) + + test(`${core}: destroy settles the candidate switch without waiting for detached media`, async ({ page }) => { + await page.goto(`/test/player.html?core=${core}&chapter=published`) + await page.evaluate(() => window.createPlayer('/test/pattern.mp4?destroy=initial')) + await expect.poll(() => page.evaluate(() => window.art.isReady)).toBe(true) + const result = await page.evaluate(async () => { + const { art } = window + let settled = false + let rejected = false + art.switchUrl('/test/pattern.mp4?destroy=pending').then(() => { + settled = true + }, () => { + rejected = true + }) + art.destroy() + // Retain the published baseline's bounded pending observation, not an infinite-pending claim. + await new Promise(resolve => setTimeout(resolve, 250)) + return { settled, rejected, destroyed: art.isDestroy, instances: window.Artplayer.instances.length } + }) + expect(result).toEqual({ settled: core === 'candidate', rejected: false, destroyed: true, instances: 0 }) + }) +} + +test('candidate: quality switch restores position/rate and preserves real customType identities', async ({ page }) => { + await page.goto('/test/player.html?core=candidate&chapter=published') + await page.evaluate(() => window.createPlayer('/test/pattern.mp4?custom=initial')) + await expect.poll(() => page.evaluate(() => window.art.isReady)).toBe(true) + await page.evaluate(() => { + window.art.currentTime = 3 + }) + await expect.poll(() => page.evaluate(() => window.art.video.seeking)).toBe(false) + const result = await page.evaluate(async () => { + const { art } = window + const calls = [] + art.option.type = 'controlled' + art.option.customType.controlled = function (video, url, owner) { + calls.push({ thisIdentity: this === art, ownerIdentity: owner === art, videoIdentity: video === art.video, count: arguments.length, url }) + video.src = url + } + art.playbackRate = 1.5 + art.aspectRatio = '16:9' + const restart = [] + art.on('restart', url => restart.push(url)) + await art.switchQuality('/test/pattern.mp4?custom=next') + const result = { calls, restart, time: art.currentTime, rate: art.playbackRate, ratio: art.aspectRatio, paused: art.video.paused, error: art.video.error?.code || 0 } + art.destroy() + return result + }) + expect(result.calls).toEqual([{ thisIdentity: true, ownerIdentity: true, videoIdentity: true, count: 3, url: '/test/pattern.mp4?custom=next' }]) + expect(result.restart).toEqual(['/test/pattern.mp4?custom=next']) + expect(result.time).toBeCloseTo(3, 1) + expect(result.rate).toBe(1.5) + expect(result.ratio).toBe('16:9') + expect(result.paused).toBe(true) + expect(result.error).toBe(0) +}) + +test('candidate: real switch settles when the controlled native resume rejects', async ({ page }) => { + await page.goto('/test/player.html?core=candidate&chapter=published') + await page.evaluate(() => window.createPlayer('/test/pattern.mp4?resume=initial')) + await expect.poll(() => page.evaluate(() => window.art.isReady)).toBe(true) + await page.locator('#play').click() + await expect.poll(() => page.evaluate(() => window.art.playing)).toBe(true) + const result = await page.evaluate(async () => { + const { art } = window + const error = new DOMException('controlled resume rejection', 'NotAllowedError') + let calls = 0 + Object.defineProperty(art.video, 'play', { configurable: true, value() { + calls++ + return Promise.reject(error) + } }) + const value = await art.switchUrl('/test/pattern.mp4?resume=next') + const result = { settledUndefined: value === undefined, calls, source: new URL(art.video.currentSrc).search, paused: art.video.paused } + delete art.video.play + art.destroy() + return result + }) + expect(result).toEqual({ settledUndefined: true, calls: 1, source: '?resume=next', paused: true }) +}) + +test('candidate: late native play completion cannot publish stale player effects', async ({ page }) => { + await page.goto('/test/player.html?core=candidate&chapter=published') + await page.evaluate(() => window.createPlayer('/test/pattern.mp4?late=initial')) + await expect.poll(() => page.evaluate(() => window.art.isReady)).toBe(true) + await page.locator('#play').click() + await expect.poll(() => page.evaluate(() => window.art.playing)).toBe(true) + const result = await page.evaluate(async () => { + const { art } = window + const plays = [] + art.on('play', () => plays.push('play')) + let resolveNative + let started + const invoked = new Promise(resolve => started = resolve) + Object.defineProperty(art.video, 'play', { configurable: true, value() { + started() + return new Promise(resolve => resolveNative = resolve) + } }) + const switching = art.switchUrl('/test/pattern.mp4?late=resume') + await invoked + art.url = '/test/pattern.mp4?late=latest' + await switching + art.notice.show = 'Latest source notice' + resolveNative(42) + await new Promise(resolve => setTimeout(resolve, 0)) + const result = { plays, notice: art.template.$noticeInner.textContent } + delete art.video.play + art.destroy() + return result + }) + expect(result).toEqual({ plays: [], notice: 'Latest source notice' }) +}) diff --git a/test/helpers/playback.js b/test/helpers/playback.js index 9319c7133..880fa8715 100644 --- a/test/helpers/playback.js +++ b/test/helpers/playback.js @@ -1,6 +1,6 @@ import { mock } from 'node:test' -export function playbackFactory({ Emitter, playMix, pauseMix, toggleMix, switchMix }) { +export function playbackFactory({ Emitter, playMix, pauseMix, toggleMix, switchMix, beginLifecycle }) { return function createArt(play = () => Promise.resolve(), playing = false) { const art = Object.assign(new Emitter(), { url: 'old.mp4', @@ -19,6 +19,7 @@ export function playbackFactory({ Emitter, playMix, pauseMix, toggleMix, switchM }, }, }) + beginLifecycle(art) Object.defineProperty(art, 'playing', { get: () => !art.template.$video.paused }) for (const mix of [playMix, pauseMix, toggleMix, switchMix]) mix(art) diff --git a/test/playback.test.js b/test/playback.test.js index 16271b8be..519e601bc 100644 --- a/test/playback.test.js +++ b/test/playback.test.js @@ -13,6 +13,8 @@ const modules = await loadModules({ pauseMix: 'packages/artplayer/src/player/pauseMix', toggleMix: 'packages/artplayer/src/player/toggleMix', switchMix: 'packages/artplayer/src/player/switchMix', + beginLifecycle: { file: 'packages/artplayer/src/lifecycle/instance', name: 'beginLifecycle' }, + getScope: { file: 'packages/artplayer/src/lifecycle/instance', name: 'getScope' }, }) const { silencePromise, Hotkey } = modules const createArt = playbackFactory(modules) diff --git a/test/source.test.js b/test/source.test.js new file mode 100644 index 000000000..c8b19b517 --- /dev/null +++ b/test/source.test.js @@ -0,0 +1,364 @@ +import assert from 'node:assert/strict' +// eslint-disable-next-line test/no-import-node-test -- Use the repository Node test runner. +import { mock, test } from 'node:test' +import { setImmediate } from 'node:timers/promises' +import { loadModules } from './helpers/load.js' + +const { Emitter, urlMix, switchMix, playMix, beginLifecycle, getScope } = await loadModules({ + Emitter: 'packages/artplayer/src/utils/emitter', + urlMix: 'packages/artplayer/src/player/urlMix', + switchMix: 'packages/artplayer/src/player/switchMix', + playMix: 'packages/artplayer/src/player/playMix', + beginLifecycle: { file: 'packages/artplayer/src/lifecycle/instance', name: 'beginLifecycle' }, + getScope: { file: 'packages/artplayer/src/lifecycle/instance', name: 'getScope' }, +}) + +function createArt(customType) { + const art = Object.assign(new Emitter(), { + template: { $video: { src: 'old.mp4' } }, + option: { url: 'old.mp4', type: customType ? 'custom' : '', customType: { custom: customType } }, + isReady: true, + playing: false, + currentTime: 37, + playbackRate: 1.5, + aspectRatio: '16:9', + loading: { show: false }, + notice: { show: '' }, + pause: mock.fn(), + play: mock.fn(() => Promise.resolve()), + }) + beginLifecycle(art) + urlMix(art) + switchMix(art) + return art +} + +test('superseded switches settle before readiness and only the latest restores state/restarts', async () => { + const art = createArt() + const restarts = [] + art.on('restart', url => restarts.push(url)) + const first = art.switchQuality('first.mp4') + art.currentTime = 9 + const second = art.switchQuality('second.mp4') + assert.equal(await first, undefined) + art.currentTime = 0 + art.emit('video:loadedmetadata') + assert.equal(art.currentTime, 9) + art.emit('video:canplay') + assert.equal(await second, undefined) + assert.deepEqual(restarts, ['second.mp4']) + assert.deepEqual(Object.keys(art.e), ['restart']) +}) + +test('direct URL assignment cancels an outstanding switch and stale restart listeners', async () => { + const art = createArt() + const restarts = [] + art.on('restart', url => restarts.push(url)) + const switching = art.switchQuality('switch.mp4') + art.url = 'direct.mp4' + await switching + art.currentTime = 4 + art.emit('video:loadedmetadata') + art.emit('video:canplay') + assert.equal(art.currentTime, 4) + assert.deepEqual(restarts, ['direct.mp4']) +}) + +test('scope disposal settles a pending switch and prevents post-destroy work', async () => { + const art = createArt() + const switching = art.switchUrl('pending.mp4') + getScope(art).dispose() + assert.equal(await switching, undefined) + assert.deepEqual(Object.keys(art.e), []) + art.url = 'closed.mp4' + await art.switchUrl('also-closed.mp4') + assert.equal(art.url, 'pending.mp4') + assert.equal(art.pause.mock.callCount(), 1) +}) + +test('same URL remains a no-op and switch setter retains the public function identity', async () => { + const art = createArt() + art.notice.show = 'keep' + assert.equal(await art.switchUrl('old.mp4'), undefined) + assert.equal(art.pause.mock.callCount(), 0) + assert.equal(art.notice.show, 'keep') + assert.equal(Object.getOwnPropertyDescriptor(art, 'switch').set, art.switchUrl) + for (const name of ['url', 'switch', 'switchUrl', 'switchQuality']) { + const descriptor = Object.getOwnPropertyDescriptor(art, name) + assert.equal(descriptor.enumerable, false) + assert.equal(descriptor.configurable, false) + } +}) + +test('a reentrant pause cannot make its superseded switch overwrite the latest URL', async () => { + const art = createArt() + art.pause = () => { + art.url = 'reentrant.mp4' + } + await art.switchUrl('stale.mp4') + assert.equal(art.url, 'reentrant.mp4') +}) + +test('synchronous media setters cannot lose metadata, readiness or original errors', async () => { + for (const fails of [false, true]) { + const art = createArt() + const error = new Error('synchronous source failure') + let src = 'old.mp4' + Object.defineProperty(art.template.$video, 'src', { + get: () => src, + set(value) { + src = value + if (fails) { + art.emit('video:error', error) + } + else { + art.currentTime = 0 + art.emit('video:loadedmetadata') + art.emit('video:canplay') + } + }, + }) + const switching = art.switchQuality('sync.mp4') + if (fails) { + await assert.rejects(switching, actual => actual === error) + } + else { + await switching + assert.equal(art.currentTime, 37) + } + assert.deepEqual(Object.keys(art.e), []) + } +}) + +test('late resume fulfillment or rejection cannot clear a newer operation notice', async () => { + for (const rejects of [false, true]) { + const art = createArt() + art.playing = true + let finish + art.play = () => new Promise((resolve, reject) => { + finish = rejects ? reject : resolve + }) + const first = art.switchUrl('first.mp4') + art.emit('video:canplay') + art.playing = false + const second = art.switchUrl('second.mp4') + await first + art.notice.show = 'new source notice' + finish(new Error('late play')) + await setImmediate() + assert.equal(art.notice.show, 'new source notice') + art.emit('video:canplay') + await second + assert.deepEqual(Object.keys(art.e), []) + } +}) + +test('state restoration errors reject without leaking handlers or unhandled promises', async () => { + for (const property of ['currentTime', 'playbackRate', 'aspectRatio']) { + const art = createArt() + const error = new Error(property) + const switching = art.switchQuality('new.mp4') + const previous = art[property] + Object.defineProperty(art, property, { + get: () => previous, + set() { + throw error + }, + }) + const rejected = assert.rejects(switching, actual => actual === error) + art.emit(property === 'currentTime' ? 'video:loadedmetadata' : 'video:canplay') + await rejected + assert.deepEqual(Object.keys(art.e), []) + } +}) + +test('customType deferral ignores the old resource and preserves callback identities', async () => { + let called + const art = createArt(function (video, url, owner) { + called = [this, video, url, owner, arguments.length] + video.src = url + owner.emit('video:loadedmetadata') + owner.emit('video:canplay') + }) + const switching = art.switchQuality('custom.mp4') + art.currentTime = 0 + art.emit('video:canplay') + assert.equal(called, undefined) + await switching + assert.deepEqual(called, [art, art.template.$video, 'custom.mp4', art, 3]) + assert.equal(art.currentTime, 37) + assert.equal(art.option.url, 'custom.mp4') +}) + +test('customType failures reject switches with the original thrown/rejected value', async () => { + for (const asynchronous of [false, true]) { + const error = new Error('customType failed') + const art = createArt(() => { + if (asynchronous) + return Promise.reject(error) + throw error + }) + await assert.rejects(art.switchUrl('failed.mp4'), actual => actual === error) + assert.deepEqual(Object.keys(art.e), []) + } +}) + +test('superseded customType callbacks never start and empty URL switches settle', async () => { + const callback = mock.fn((video, url, art) => { + video.src = url + art.emit('video:canplay') + }) + const art = createArt(callback) + const first = art.switchUrl('first.mp4') + const second = art.switchUrl('second.mp4') + await Promise.all([first, second]) + assert.equal(callback.mock.callCount(), 1) + assert.equal(callback.mock.calls[0].arguments[1], 'second.mp4') + await art.switchUrl('') + assert.equal(art.loading.show, true) + assert.equal(art.url, 'second.mp4') +}) + +test('reentrant media listeners and property setters cannot restore stale state', async () => { + for (const boundary of ['metadata', 'rate']) { + const art = createArt() + if (boundary === 'metadata') { + art.once('video:loadedmetadata', () => { + art.url = 'reentrant.mp4' + art.currentTime = 6 + }) + } + const switching = art.switchQuality('stale.mp4') + art.currentTime = 0 + art.aspectRatio = 'default' + if (boundary === 'rate') { + Object.defineProperty(art, 'playbackRate', { + get: () => 1, + set() { + art.url = 'reentrant.mp4' + }, + }) + } + art.emit(boundary === 'metadata' ? 'video:loadedmetadata' : 'video:canplay') + await switching + assert.equal(art.url, 'reentrant.mp4') + assert.equal(art.aspectRatio, 'default') + if (boundary === 'metadata') + assert.equal(art.currentTime, 6) + getScope(art).dispose() + assert.deepEqual(Object.keys(art.e), []) + } +}) + +test('direct customType rejection is reported once; obsolete returned failures are ignored', async (t) => { + const warning = t.mock.method(console, 'warn', () => {}) + const error = new Error('direct custom source') + let rejectLate + let started + const invoked = new Promise(resolve => started = resolve) + const art = createArt(() => new Promise((resolve, reject) => { + rejectLate = reject + started() + })) + art.url = 'late.mp4' + await invoked + art.option.type = '' + art.url = 'current.mp4' + rejectLate(error) + await setImmediate() + assert.equal(warning.mock.callCount(), 0) + art.option.type = 'custom' + art.option.customType.custom = () => Promise.reject(error) + await Object.getOwnPropertyDescriptor(art, 'url').set.call(art, 'failed.mp4') + await setImmediate() + assert.equal(warning.mock.callCount(), 1) + assert.deepEqual(warning.mock.calls[0].arguments, ['Failed to initialize ArtPlayer source:', error]) + assert.deepEqual(Object.keys(art.e), []) +}) + +test('same-URL calls do not cancel the still-loading original operation', async () => { + const art = createArt() + let firstSettled = false + const first = art.switchQuality('pending.mp4').then(() => firstSettled = true) + await art.switchUrl('pending.mp4') + assert.equal(firstSettled, false) + art.currentTime = 0 + art.emit('video:loadedmetadata') + art.emit('video:canplay') + await first + assert.equal(art.currentTime, 37) + assert.equal(art.pause.mock.callCount(), 1) +}) + +test('synchronous readiness replay consumes metadata once and emits restart once', async () => { + const art = createArt() + const restarts = [] + art.on('restart', url => restarts.push(url)) + let src = 'old.mp4' + Object.defineProperty(art.template.$video, 'src', { + get: () => src, + set(value) { + src = value + art.emit('video:loadedmetadata') + art.emit('video:loadedmetadata') + }, + }) + const switching = art.switchQuality('sync.mp4') + assert.equal(art.currentTime, 37) + art.currentTime = 4 + art.emit('video:loadedmetadata') + assert.equal(art.currentTime, 4) + art.emit('video:canplay') + art.emit('video:canplay') + await switching + assert.deepEqual(restarts, ['sync.mp4']) + assert.deepEqual(Object.keys(art.e), ['restart']) +}) + +test('the real play mixin cannot publish stale resume effects after source replacement', async () => { + const art = createArt() + art.i18n = { get: key => key } + art.constructor = { instances: [] } + let resolveNative + art.template.$video.play = () => new Promise(resolve => resolveNative = resolve) + playMix(art) + art.playing = true + const plays = [] + art.on('play', () => plays.push('play')) + const switching = art.switchUrl('pending-resume.mp4') + art.emit('video:canplay') + art.url = 'latest.mp4' + await switching + art.notice.show = 'latest notice' + resolveNative(42) + await setImmediate() + assert.equal(art.notice.show, 'latest notice') + assert.deepEqual(plays, []) +}) + +test('public pending play preserves its result while obsolete notification/event/mutex work stops', async () => { + for (const destroy of [false, true]) { + const art = createArt() + art.i18n = { get: key => key } + const other = { pause: mock.fn() } + art.constructor = { instances: [other] } + art.option.mutex = true + art.url = 'initial.mp4' + let resolveNative + art.template.$video.play = () => new Promise(resolve => resolveNative = resolve) + playMix(art) + const plays = mock.fn() + art.on('play', plays) + const playing = art.play() + if (destroy) + getScope(art).dispose() + else + art.url = 'replacement.mp4' + art.notice.show = 'preserve' + resolveNative(42) + assert.equal(await playing, 42) + assert.equal(art.notice.show, 'preserve') + assert.equal(plays.mock.callCount(), 0) + assert.equal(other.pause.mock.callCount(), 0) + } +}) diff --git a/test/types/source.ts b/test/types/source.ts new file mode 100644 index 000000000..dddbbc512 --- /dev/null +++ b/test/types/source.ts @@ -0,0 +1,36 @@ +import type { CanvasMedia, NativeMedia } from '../../packages/artplayer/src/media/types' +import type { SourceMedia, SwitchHost, UrlHost } from '../../packages/artplayer/src/source/types' +import switchMix from '../../packages/artplayer/src/player/switchMix' +import urlMix from '../../packages/artplayer/src/player/urlMix' + +declare const native: NativeMedia +declare const canvas: CanvasMedia +const sourceMedia: SourceMedia[] = [native, canvas] +void sourceMedia + +declare const switching: SwitchHost +switchMix(switching) +const pending: Promise = switching.switchQuality('movie.mp4') +void pending +switching.switch = 'movie.mp4' +// @ts-expect-error Source URLs remain strings. +switching.switchUrl(42) +// @ts-expect-error Switching does not resolve with a media element or success boolean. +const wrong: Promise = switching.switchUrl('movie.mp4') +void wrong + +interface CustomHost extends UrlHost { + extension: number +} +declare const custom: CustomHost +custom.option.customType.canvas = function (video, url, art) { + this satisfies CustomHost + const owner: CustomHost = art + const surface: HTMLCanvasElement = video + const source: string = url + void [owner, surface, source] + // @ts-expect-error A canvas proxy is not a native video element. + const wrongMedia: HTMLVideoElement = video + void wrongMedia +} +urlMix(custom)