/* THIS IS A GENERATED/BUNDLED FILE BY ESBUILD if you want to view the source visit the plugins github repository */ "use strict";var aO=Object.create;var cc=Object.defineProperty;var lO=Object.getOwnPropertyDescriptor;var cO=Object.getOwnPropertyNames;var uO=Object.getPrototypeOf,dO=Object.prototype.hasOwnProperty;var pO=(t,e,n)=>e in t?cc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var at=(t,e)=>()=>(t&&(e=t(t=0)),e);var Lt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),zt=(t,e)=>{for(var n in e)cc(t,n,{get:e[n],enumerable:!0})},lE=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of cO(e))!dO.call(t,r)&&r!==n&&cc(t,r,{get:()=>e[r],enumerable:!(i=lO(e,r))||i.enumerable});return t};var A=(t,e,n)=>(n=t!=null?aO(uO(t)):{},lE(e||!t||!t.__esModule?cc(n,"default",{value:t,enumerable:!0}):n,t)),hO=t=>lE(cc({},"__esModule",{value:!0}),t);var E=(t,e,n)=>(pO(t,typeof e!="symbol"?e+"":e,n),n),kv=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)};var C=(t,e,n)=>(kv(t,e,"read from private field"),n?n.call(t):e.get(t)),Y=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},Le=(t,e,n,i)=>(kv(t,e,"write to private field"),i?i.call(t,n):e.set(t,n),n);var F=(t,e,n)=>(kv(t,e,"access private method"),n);var Ap=Lt(Lp=>{"use strict";Object.defineProperty(Lp,"__esModule",{value:!0});function wE(t,e){if(e)return t;throw new Error("Unhandled discriminated union member: "+JSON.stringify(t))}Lp.assertNever=wE;Lp.default=wE});var MS=Lt(ge=>{"use strict";var xc=Symbol.for("react.element"),cF=Symbol.for("react.portal"),uF=Symbol.for("react.fragment"),dF=Symbol.for("react.strict_mode"),pF=Symbol.for("react.profiler"),hF=Symbol.for("react.provider"),fF=Symbol.for("react.context"),mF=Symbol.for("react.forward_ref"),gF=Symbol.for("react.suspense"),yF=Symbol.for("react.memo"),vF=Symbol.for("react.lazy"),wS=Symbol.iterator;function wF(t){return t===null||typeof t!="object"?null:(t=wS&&t[wS]||t["@@iterator"],typeof t=="function"?t:null)}var xS={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},kS=Object.assign,TS={};function wa(t,e,n){this.props=t,this.context=e,this.refs=TS,this.updater=n||xS}wa.prototype.isReactComponent={};wa.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};wa.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function ES(){}ES.prototype=wa.prototype;function Fv(t,e,n){this.props=t,this.context=e,this.refs=TS,this.updater=n||xS}var Vv=Fv.prototype=new ES;Vv.constructor=Fv;kS(Vv,wa.prototype);Vv.isPureReactComponent=!0;var _S=Array.isArray,SS=Object.prototype.hasOwnProperty,zv={current:null},PS={key:!0,ref:!0,__self:!0,__source:!0};function CS(t,e,n){var i,r={},s=null,o=null;if(e!=null)for(i in e.ref!==void 0&&(o=e.ref),e.key!==void 0&&(s=""+e.key),e)SS.call(e,i)&&!PS.hasOwnProperty(i)&&(r[i]=e[i]);var a=arguments.length-2;if(a===1)r.children=n;else if(1{"use strict";$S.exports=MS()});var zS=Lt(Ae=>{"use strict";function qv(t,e){var n=t.length;t.push(e);e:for(;0>>1,r=t[i];if(0>>1;ish(a,n))lsh(c,a)?(t[i]=c,t[l]=n,i=l):(t[i]=a,t[o]=n,i=o);else if(lsh(c,n))t[i]=c,t[l]=n,i=l;else break e}}return e}function sh(t,e){var n=t.sortIndex-e.sortIndex;return n!==0?n:t.id-e.id}typeof performance=="object"&&typeof performance.now=="function"?(RS=performance,Ae.unstable_now=function(){return RS.now()}):(jv=Date,IS=jv.now(),Ae.unstable_now=function(){return jv.now()-IS});var RS,jv,IS,Wi=[],Zr=[],TF=1,ti=null,Ut=3,lh=!1,Zs=!1,Tc=!1,DS=typeof setTimeout=="function"?setTimeout:null,NS=typeof clearTimeout=="function"?clearTimeout:null,LS=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function Wv(t){for(var e=Ti(Zr);e!==null;){if(e.callback===null)ah(Zr);else if(e.startTime<=t)ah(Zr),e.sortIndex=e.expirationTime,qv(Wi,e);else break;e=Ti(Zr)}}function Kv(t){if(Tc=!1,Wv(t),!Zs)if(Ti(Wi)!==null)Zs=!0,Yv(Gv);else{var e=Ti(Zr);e!==null&&Qv(Kv,e.startTime-t)}}function Gv(t,e){Zs=!1,Tc&&(Tc=!1,NS(Ec),Ec=-1),lh=!0;var n=Ut;try{for(Wv(e),ti=Ti(Wi);ti!==null&&(!(ti.expirationTime>e)||t&&!VS());){var i=ti.callback;if(typeof i=="function"){ti.callback=null,Ut=ti.priorityLevel;var r=i(ti.expirationTime<=e);e=Ae.unstable_now(),typeof r=="function"?ti.callback=r:ti===Ti(Wi)&&ah(Wi),Wv(e)}else ah(Wi);ti=Ti(Wi)}if(ti!==null)var s=!0;else{var o=Ti(Zr);o!==null&&Qv(Kv,o.startTime-e),s=!1}return s}finally{ti=null,Ut=n,lh=!1}}var ch=!1,oh=null,Ec=-1,OS=5,FS=-1;function VS(){return!(Ae.unstable_now()-FSt||125i?(t.sortIndex=n,qv(Zr,t),Ti(Wi)===null&&t===Ti(Zr)&&(Tc?(NS(Ec),Ec=-1):Tc=!0,Qv(Kv,n-i))):(t.sortIndex=r,qv(Wi,t),Zs||lh||(Zs=!0,Yv(Gv))),t};Ae.unstable_shouldYield=VS;Ae.unstable_wrapCallback=function(t){var e=Ut;return function(){var n=Ut;Ut=e;try{return t.apply(this,arguments)}finally{Ut=n}}}});var jS=Lt((XK,US)=>{"use strict";US.exports=zS()});var GC=Lt(On=>{"use strict";var Y1=X(),Dn=jS();function D(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ww=Object.prototype.hasOwnProperty,EF=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,BS={},HS={};function SF(t){return ww.call(HS,t)?!0:ww.call(BS,t)?!1:EF.test(t)?HS[t]=!0:(BS[t]=!0,!1)}function PF(t,e,n,i){if(n!==null&&n.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return i?!1:n!==null?!n.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function CF(t,e,n,i){if(e===null||typeof e>"u"||PF(t,e,n,i))return!0;if(i)return!1;if(n!==null)switch(n.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function tn(t,e,n,i,r,s,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=i,this.attributeNamespace=r,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=s,this.removeEmptyString=o}var Nt={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){Nt[t]=new tn(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];Nt[e]=new tn(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){Nt[t]=new tn(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){Nt[t]=new tn(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){Nt[t]=new tn(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){Nt[t]=new tn(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){Nt[t]=new tn(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){Nt[t]=new tn(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){Nt[t]=new tn(t,5,!1,t.toLowerCase(),null,!1,!1)});var d_=/[\-:]([a-z])/g;function p_(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(d_,p_);Nt[e]=new tn(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(d_,p_);Nt[e]=new tn(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(d_,p_);Nt[e]=new tn(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){Nt[t]=new tn(t,1,!1,t.toLowerCase(),null,!1,!1)});Nt.xlinkHref=new tn("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){Nt[t]=new tn(t,1,!1,t.toLowerCase(),null,!0,!0)});function h_(t,e,n,i){var r=Nt.hasOwnProperty(e)?Nt[e]:null;(r!==null?r.type!==0:i||!(2a||r[o]!==s[a]){var l=` `+r[o].replace(" at new "," at ");return t.displayName&&l.includes("")&&(l=l.replace("",t.displayName)),l}while(1<=o&&0<=a);break}}}finally{Zv=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?Ac(t):""}function MF(t){switch(t.tag){case 5:return Ac(t.type);case 16:return Ac("Lazy");case 13:return Ac("Suspense");case 19:return Ac("SuspenseList");case 0:case 2:case 15:return t=Jv(t.type,!1),t;case 11:return t=Jv(t.type.render,!1),t;case 1:return t=Jv(t.type,!0),t;default:return""}}function kw(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case ka:return"Fragment";case xa:return"Portal";case _w:return"Profiler";case f_:return"StrictMode";case bw:return"Suspense";case xw:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case Z1:return(t.displayName||"Context")+".Consumer";case X1:return(t._context.displayName||"Context")+".Provider";case m_:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case g_:return e=t.displayName||null,e!==null?e:kw(t.type)||"Memo";case es:e=t._payload,t=t._init;try{return kw(t(e))}catch{}}return null}function $F(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return kw(e);case 8:return e===f_?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function fs(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function eP(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function RF(t){var e=eP(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),i=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var r=n.get,s=n.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return r.call(this)},set:function(o){i=""+o,s.call(this,o)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return i},setValue:function(o){i=""+o},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function dh(t){t._valueTracker||(t._valueTracker=RF(t))}function tP(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),i="";return t&&(i=eP(t)?t.checked?"true":"false":t.value),t=i,t!==n?(e.setValue(t),!0):!1}function Vh(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Tw(t,e){var n=e.checked;return Ye({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function WS(t,e){var n=e.defaultValue==null?"":e.defaultValue,i=e.checked!=null?e.checked:e.defaultChecked;n=fs(e.value!=null?e.value:n),t._wrapperState={initialChecked:i,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function nP(t,e){e=e.checked,e!=null&&h_(t,"checked",e,!1)}function Ew(t,e){nP(t,e);var n=fs(e.value),i=e.type;if(n!=null)i==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(i==="submit"||i==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?Sw(t,e.type,n):e.hasOwnProperty("defaultValue")&&Sw(t,e.type,fs(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function KS(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var i=e.type;if(!(i!=="submit"&&i!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function Sw(t,e,n){(e!=="number"||Vh(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var Dc=Array.isArray;function Aa(t,e,n,i){if(t=t.options,e){e={};for(var r=0;r"+e.valueOf().toString()+"",e=ph.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function Gc(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var Fc={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},IF=["Webkit","ms","Moz","O"];Object.keys(Fc).forEach(function(t){IF.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),Fc[e]=Fc[t]})});function oP(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||Fc.hasOwnProperty(t)&&Fc[t]?(""+e).trim():e+"px"}function aP(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var i=n.indexOf("--")===0,r=oP(n,e[n],i);n==="float"&&(n="cssFloat"),i?t.setProperty(n,r):t[n]=r}}var LF=Ye({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Mw(t,e){if(e){if(LF[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(D(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(D(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(D(61))}if(e.style!=null&&typeof e.style!="object")throw Error(D(62))}}function $w(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Rw=null;function y_(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Iw=null,Da=null,Na=null;function QS(t){if(t=pu(t)){if(typeof Iw!="function")throw Error(D(280));var e=t.stateNode;e&&(e=ff(e),Iw(t.stateNode,t.type,e))}}function lP(t){Da?Na?Na.push(t):Na=[t]:Da=t}function cP(){if(Da){var t=Da,e=Na;if(Na=Da=null,QS(t),e)for(t=0;t>>=0,t===0?32:31-(HF(t)/qF|0)|0}var hh=64,fh=4194304;function Nc(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function Bh(t,e){var n=t.pendingLanes;if(n===0)return 0;var i=0,r=t.suspendedLanes,s=t.pingedLanes,o=n&268435455;if(o!==0){var a=o&~r;a!==0?i=Nc(a):(s&=o,s!==0&&(i=Nc(s)))}else o=n&~r,o!==0?i=Nc(o):s!==0&&(i=Nc(s));if(i===0)return 0;if(e!==0&&e!==i&&!(e&r)&&(r=i&-i,s=e&-e,r>=s||r===16&&(s&4194240)!==0))return e;if(i&4&&(i|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=i;0n;n++)e.push(t);return e}function uu(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-Mi(e),t[e]=n}function YF(t,e){var n=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var i=t.eventTimes;for(t=t.expirationTimes;0=zc),s1=" ",o1=!1;function MP(t,e){switch(t){case"keyup":return k3.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function $P(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Ta=!1;function E3(t,e){switch(t){case"compositionend":return $P(e);case"keypress":return e.which!==32?null:(o1=!0,s1);case"textInput":return t=e.data,t===s1&&o1?null:t;default:return null}}function S3(t,e){if(Ta)return t==="compositionend"||!E_&&MP(t,e)?(t=PP(),$h=x_=rs=null,Ta=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:n,offset:e-t};t=i}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=c1(n)}}function AP(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?AP(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function DP(){for(var t=window,e=Vh();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=Vh(t.document)}return e}function S_(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function D3(t){var e=DP(),n=t.focusedElem,i=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&AP(n.ownerDocument.documentElement,n)){if(i!==null&&S_(n)){if(e=i.start,t=i.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var r=n.textContent.length,s=Math.min(i.start,r);i=i.end===void 0?s:Math.min(i.end,r),!t.extend&&s>i&&(r=i,i=s,s=r),r=u1(n,s);var o=u1(n,i);r&&o&&(t.rangeCount!==1||t.anchorNode!==r.node||t.anchorOffset!==r.offset||t.focusNode!==o.node||t.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(r.node,r.offset),t.removeAllRanges(),s>i?(t.addRange(e),t.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,Ea=null,Fw=null,jc=null,Vw=!1;function d1(t,e,n){var i=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Vw||Ea==null||Ea!==Vh(i)||(i=Ea,"selectionStart"in i&&S_(i)?i={start:i.selectionStart,end:i.selectionEnd}:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection(),i={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}),jc&&eu(jc,i)||(jc=i,i=Wh(Fw,"onSelect"),0Ca||(t.current=qw[Ca],qw[Ca]=null,Ca--)}function De(t,e){Ca++,qw[Ca]=t.current,t.current=e}var ms={},qt=ys(ms),wn=ys(!1),oo=ms;function Ua(t,e){var n=t.type.contextTypes;if(!n)return ms;var i=t.stateNode;if(i&&i.__reactInternalMemoizedUnmaskedChildContext===e)return i.__reactInternalMemoizedMaskedChildContext;var r={},s;for(s in n)r[s]=e[s];return i&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=r),r}function _n(t){return t=t.childContextTypes,t!=null}function Gh(){Ue(wn),Ue(qt)}function _1(t,e,n){if(qt.current!==ms)throw Error(D(168));De(qt,e),De(wn,n)}function HP(t,e,n){var i=t.stateNode;if(e=e.childContextTypes,typeof i.getChildContext!="function")return n;i=i.getChildContext();for(var r in i)if(!(r in e))throw Error(D(108,$F(t)||"Unknown",r));return Ye({},n,i)}function Yh(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||ms,oo=qt.current,De(qt,t),De(wn,wn.current),!0}function b1(t,e,n){var i=t.stateNode;if(!i)throw Error(D(169));n?(t=HP(t,e,oo),i.__reactInternalMemoizedMergedChildContext=t,Ue(wn),Ue(qt),De(qt,t)):Ue(wn),De(wn,n)}var wr=null,mf=!1,uw=!1;function qP(t){wr===null?wr=[t]:wr.push(t)}function q3(t){mf=!0,qP(t)}function vs(){if(!uw&&wr!==null){uw=!0;var t=0,e=Ce;try{var n=wr;for(Ce=1;t>=o,r-=o,_r=1<<32-Mi(e)+r|n<I?(O=M,M=null):O=M.sibling;var b=p(f,M,y[I],T);if(b===null){M===null&&(M=O);break}t&&M&&b.alternate===null&&e(f,M),g=s(b,g,I),k===null?P=b:k.sibling=b,k=b,M=O}if(I===y.length)return n(f,M),qe&&Js(f,I),P;if(M===null){for(;II?(O=M,M=null):O=M.sibling;var ee=p(f,M,b.value,T);if(ee===null){M===null&&(M=O);break}t&&M&&ee.alternate===null&&e(f,M),g=s(ee,g,I),k===null?P=ee:k.sibling=ee,k=ee,M=O}if(b.done)return n(f,M),qe&&Js(f,I),P;if(M===null){for(;!b.done;I++,b=y.next())b=d(f,b.value,T),b!==null&&(g=s(b,g,I),k===null?P=b:k.sibling=b,k=b);return qe&&Js(f,I),P}for(M=i(f,M);!b.done;I++,b=y.next())b=h(M,f,I,b.value,T),b!==null&&(t&&b.alternate!==null&&M.delete(b.key===null?I:b.key),g=s(b,g,I),k===null?P=b:k.sibling=b,k=b);return t&&M.forEach(function(U){return e(f,U)}),qe&&Js(f,I),P}function w(f,g,y,T){if(typeof y=="object"&&y!==null&&y.type===ka&&y.key===null&&(y=y.props.children),typeof y=="object"&&y!==null){switch(y.$$typeof){case uh:e:{for(var P=y.key,k=g;k!==null;){if(k.key===P){if(P=y.type,P===ka){if(k.tag===7){n(f,k.sibling),g=r(k,y.props.children),g.return=f,f=g;break e}}else if(k.elementType===P||typeof P=="object"&&P!==null&&P.$$typeof===es&&C1(P)===k.type){n(f,k.sibling),g=r(k,y.props),g.ref=$c(f,k,y),g.return=f,f=g;break e}n(f,k);break}else e(f,k);k=k.sibling}y.type===ka?(g=so(y.props.children,f.mode,T,y.key),g.return=f,f=g):(T=Fh(y.type,y.key,y.props,null,f.mode,T),T.ref=$c(f,g,y),T.return=f,f=T)}return o(f);case xa:e:{for(k=y.key;g!==null;){if(g.key===k)if(g.tag===4&&g.stateNode.containerInfo===y.containerInfo&&g.stateNode.implementation===y.implementation){n(f,g.sibling),g=r(g,y.children||[]),g.return=f,f=g;break e}else{n(f,g);break}else e(f,g);g=g.sibling}g=vw(y,f.mode,T),g.return=f,f=g}return o(f);case es:return k=y._init,w(f,g,k(y._payload),T)}if(Dc(y))return m(f,g,y,T);if(Sc(y))return v(f,g,y,T);Eh(f,y)}return typeof y=="string"&&y!==""||typeof y=="number"?(y=""+y,g!==null&&g.tag===6?(n(f,g.sibling),g=r(g,y),g.return=f,f=g):(n(f,g),g=yw(y,f.mode,T),g.return=f,f=g),o(f)):n(f,g)}return w}var Ba=JP(!0),eC=JP(!1),hu={},Xi=ys(hu),ru=ys(hu),su=ys(hu);function io(t){if(t===hu)throw Error(D(174));return t}function D_(t,e){switch(De(su,e),De(ru,t),De(Xi,hu),t=e.nodeType,t){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:Cw(null,"");break;default:t=t===8?e.parentNode:e,e=t.namespaceURI||null,t=t.tagName,e=Cw(e,t)}Ue(Xi),De(Xi,e)}function Ha(){Ue(Xi),Ue(ru),Ue(su)}function tC(t){io(su.current);var e=io(Xi.current),n=Cw(e,t.type);e!==n&&(De(ru,t),De(Xi,n))}function N_(t){ru.current===t&&(Ue(Xi),Ue(ru))}var Ke=ys(0);function tf(t){for(var e=t;e!==null;){if(e.tag===13){var n=e.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return e}else if(e.tag===19&&e.memoizedProps.revealOrder!==void 0){if(e.flags&128)return e}else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break;for(;e.sibling===null;){if(e.return===null||e.return===t)return null;e=e.return}e.sibling.return=e.return,e=e.sibling}return null}var dw=[];function O_(){for(var t=0;tn?n:4,t(!0);var i=pw.transition;pw.transition={};try{t(!1),e()}finally{Ce=n,pw.transition=i}}function yC(){return ai().memoizedState}function Y3(t,e,n){var i=ps(t);if(n={lane:i,action:n,hasEagerState:!1,eagerState:null,next:null},vC(t))wC(e,n);else if(n=YP(t,e,n,i),n!==null){var r=en();$i(n,t,i,r),_C(n,e,i)}}function Q3(t,e,n){var i=ps(t),r={lane:i,action:n,hasEagerState:!1,eagerState:null,next:null};if(vC(t))wC(e,r);else{var s=t.alternate;if(t.lanes===0&&(s===null||s.lanes===0)&&(s=e.lastRenderedReducer,s!==null))try{var o=e.lastRenderedState,a=s(o,n);if(r.hasEagerState=!0,r.eagerState=a,Ri(a,o)){var l=e.interleaved;l===null?(r.next=r,L_(e)):(r.next=l.next,l.next=r),e.interleaved=r;return}}catch{}finally{}n=YP(t,e,r,i),n!==null&&(r=en(),$i(n,t,i,r),_C(n,e,i))}}function vC(t){var e=t.alternate;return t===Ge||e!==null&&e===Ge}function wC(t,e){Bc=nf=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function _C(t,e,n){if(n&4194240){var i=e.lanes;i&=t.pendingLanes,n|=i,e.lanes=n,w_(t,n)}}var rf={readContext:oi,useCallback:jt,useContext:jt,useEffect:jt,useImperativeHandle:jt,useInsertionEffect:jt,useLayoutEffect:jt,useMemo:jt,useReducer:jt,useRef:jt,useState:jt,useDebugValue:jt,useDeferredValue:jt,useTransition:jt,useMutableSource:jt,useSyncExternalStore:jt,useId:jt,unstable_isNewReconciler:!1},X3={readContext:oi,useCallback:function(t,e){return Gi().memoizedState=[t,e===void 0?null:e],t},useContext:oi,useEffect:$1,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,Ah(4194308,4,pC.bind(null,e,t),n)},useLayoutEffect:function(t,e){return Ah(4194308,4,t,e)},useInsertionEffect:function(t,e){return Ah(4,2,t,e)},useMemo:function(t,e){var n=Gi();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var i=Gi();return e=n!==void 0?n(e):e,i.memoizedState=i.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},i.queue=t,t=t.dispatch=Y3.bind(null,Ge,t),[i.memoizedState,t]},useRef:function(t){var e=Gi();return t={current:t},e.memoizedState=t},useState:M1,useDebugValue:j_,useDeferredValue:function(t){return Gi().memoizedState=t},useTransition:function(){var t=M1(!1),e=t[0];return t=G3.bind(null,t[1]),Gi().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var i=Ge,r=Gi();if(qe){if(n===void 0)throw Error(D(407));n=n()}else{if(n=e(),Pt===null)throw Error(D(349));lo&30||rC(i,e,n)}r.memoizedState=n;var s={value:n,getSnapshot:e};return r.queue=s,$1(oC.bind(null,i,s,t),[t]),i.flags|=2048,lu(9,sC.bind(null,i,s,n,e),void 0,null),n},useId:function(){var t=Gi(),e=Pt.identifierPrefix;if(qe){var n=br,i=_r;n=(i&~(1<<32-Mi(i)-1)).toString(32)+n,e=":"+e+"R"+n,n=ou++,0<\/script>",t=t.removeChild(t.firstChild)):typeof i.is=="string"?t=o.createElement(n,{is:i.is}):(t=o.createElement(n),n==="select"&&(o=t,i.multiple?o.multiple=!0:i.size&&(o.size=i.size))):t=o.createElementNS(t,n),t[Yi]=e,t[iu]=i,MC(t,e,!1,!1),e.stateNode=t;e:{switch(o=$w(n,i),n){case"dialog":ze("cancel",t),ze("close",t),r=i;break;case"iframe":case"object":case"embed":ze("load",t),r=i;break;case"video":case"audio":for(r=0;rWa&&(e.flags|=128,i=!0,Rc(s,!1),e.lanes=4194304)}else{if(!i)if(t=tf(o),t!==null){if(e.flags|=128,i=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),Rc(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!qe)return Bt(e),null}else 2*rt()-s.renderingStartTime>Wa&&n!==1073741824&&(e.flags|=128,i=!0,Rc(s,!1),e.lanes=4194304);s.isBackwards?(o.sibling=e.child,e.child=o):(n=s.last,n!==null?n.sibling=o:e.child=o,s.last=o)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=rt(),e.sibling=null,n=Ke.current,De(Ke,i?n&1|2:n&1),e):(Bt(e),null);case 22:case 23:return G_(),i=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==i&&(e.flags|=8192),i&&e.mode&1?In&1073741824&&(Bt(e),e.subtreeFlags&6&&(e.flags|=8192)):Bt(e),null;case 24:return null;case 25:return null}throw Error(D(156,e.tag))}function sV(t,e){switch(C_(e),e.tag){case 1:return _n(e.type)&&Gh(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Ha(),Ue(wn),Ue(qt),O_(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return N_(e),null;case 13:if(Ue(Ke),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(D(340));ja()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return Ue(Ke),null;case 4:return Ha(),null;case 10:return I_(e.type._context),null;case 22:case 23:return G_(),null;case 24:return null;default:return null}}var Ph=!1,Ht=!1,oV=typeof WeakSet=="function"?WeakSet:Set,j=null;function Ia(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(i){nt(t,e,i)}else n.current=null}function i_(t,e,n){try{n()}catch(i){nt(t,e,i)}}var V1=!1;function aV(t,e){if(zw=Hh,t=DP(),S_(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var i=n.getSelection&&n.getSelection();if(i&&i.rangeCount!==0){n=i.anchorNode;var r=i.anchorOffset,s=i.focusNode;i=i.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var o=0,a=-1,l=-1,c=0,u=0,d=t,p=null;t:for(;;){for(var h;d!==n||r!==0&&d.nodeType!==3||(a=o+r),d!==s||i!==0&&d.nodeType!==3||(l=o+i),d.nodeType===3&&(o+=d.nodeValue.length),(h=d.firstChild)!==null;)p=d,d=h;for(;;){if(d===t)break t;if(p===n&&++c===r&&(a=o),p===s&&++u===i&&(l=o),(h=d.nextSibling)!==null)break;d=p,p=d.parentNode}d=h}n=a===-1||l===-1?null:{start:a,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for(Uw={focusedElem:t,selectionRange:n},Hh=!1,j=e;j!==null;)if(e=j,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,j=t;else for(;j!==null;){e=j;try{var m=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(m!==null){var v=m.memoizedProps,w=m.memoizedState,f=e.stateNode,g=f.getSnapshotBeforeUpdate(e.elementType===e.type?v:Si(e.type,v),w);f.__reactInternalSnapshotBeforeUpdate=g}break;case 3:var y=e.stateNode.containerInfo;y.nodeType===1?y.textContent="":y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(D(163))}}catch(T){nt(e,e.return,T)}if(t=e.sibling,t!==null){t.return=e.return,j=t;break}j=e.return}return m=V1,V1=!1,m}function Hc(t,e,n){var i=e.updateQueue;if(i=i!==null?i.lastEffect:null,i!==null){var r=i=i.next;do{if((r.tag&t)===t){var s=r.destroy;r.destroy=void 0,s!==void 0&&i_(e,n,s)}r=r.next}while(r!==i)}}function vf(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var i=n.create;n.destroy=i()}n=n.next}while(n!==e)}}function r_(t){var e=t.ref;if(e!==null){var n=t.stateNode;switch(t.tag){case 5:t=n;break;default:t=n}typeof e=="function"?e(t):e.current=t}}function IC(t){var e=t.alternate;e!==null&&(t.alternate=null,IC(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[Yi],delete e[iu],delete e[Hw],delete e[B3],delete e[H3])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function LC(t){return t.tag===5||t.tag===3||t.tag===4}function z1(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||LC(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function s_(t,e,n){var i=t.tag;if(i===5||i===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=Kh));else if(i!==4&&(t=t.child,t!==null))for(s_(t,e,n),t=t.sibling;t!==null;)s_(t,e,n),t=t.sibling}function o_(t,e,n){var i=t.tag;if(i===5||i===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(i!==4&&(t=t.child,t!==null))for(o_(t,e,n),t=t.sibling;t!==null;)o_(t,e,n),t=t.sibling}var At=null,Pi=!1;function Jr(t,e,n){for(n=n.child;n!==null;)AC(t,e,n),n=n.sibling}function AC(t,e,n){if(Qi&&typeof Qi.onCommitFiberUnmount=="function")try{Qi.onCommitFiberUnmount(uf,n)}catch{}switch(n.tag){case 5:Ht||Ia(n,e);case 6:var i=At,r=Pi;At=null,Jr(t,e,n),At=i,Pi=r,At!==null&&(Pi?(t=At,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):At.removeChild(n.stateNode));break;case 18:At!==null&&(Pi?(t=At,n=n.stateNode,t.nodeType===8?cw(t.parentNode,n):t.nodeType===1&&cw(t,n),Zc(t)):cw(At,n.stateNode));break;case 4:i=At,r=Pi,At=n.stateNode.containerInfo,Pi=!0,Jr(t,e,n),At=i,Pi=r;break;case 0:case 11:case 14:case 15:if(!Ht&&(i=n.updateQueue,i!==null&&(i=i.lastEffect,i!==null))){r=i=i.next;do{var s=r,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&i_(n,e,o),r=r.next}while(r!==i)}Jr(t,e,n);break;case 1:if(!Ht&&(Ia(n,e),i=n.stateNode,typeof i.componentWillUnmount=="function"))try{i.props=n.memoizedProps,i.state=n.memoizedState,i.componentWillUnmount()}catch(a){nt(n,e,a)}Jr(t,e,n);break;case 21:Jr(t,e,n);break;case 22:n.mode&1?(Ht=(i=Ht)||n.memoizedState!==null,Jr(t,e,n),Ht=i):Jr(t,e,n);break;default:Jr(t,e,n)}}function U1(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new oV),e.forEach(function(i){var r=gV.bind(null,t,i);n.has(i)||(n.add(i),i.then(r,r))})}}function Ei(t,e){var n=e.deletions;if(n!==null)for(var i=0;ir&&(r=o),i&=~s}if(i=r,i=rt()-i,i=(120>i?120:480>i?480:1080>i?1080:1920>i?1920:3e3>i?3e3:4320>i?4320:1960*cV(i/1960))-i,10t?16:t,ss===null)var i=!1;else{if(t=ss,ss=null,af=0,we&6)throw Error(D(331));var r=we;for(we|=4,j=t.current;j!==null;){var s=j,o=s.child;if(j.flags&16){var a=s.deletions;if(a!==null){for(var l=0;lrt()-W_?ro(t,0):q_|=n),bn(t,e)}function jC(t,e){e===0&&(t.mode&1?(e=fh,fh<<=1,!(fh&130023424)&&(fh=4194304)):e=1);var n=en();t=Er(t,e),t!==null&&(uu(t,e,n),bn(t,n))}function mV(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),jC(t,n)}function gV(t,e){var n=0;switch(t.tag){case 13:var i=t.stateNode,r=t.memoizedState;r!==null&&(n=r.retryLane);break;case 19:i=t.stateNode;break;default:throw Error(D(314))}i!==null&&i.delete(e),jC(t,n)}var BC;BC=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||wn.current)vn=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return vn=!1,iV(t,e,n);vn=!!(t.flags&131072)}else vn=!1,qe&&e.flags&1048576&&WP(e,Xh,e.index);switch(e.lanes=0,e.tag){case 2:var i=e.type;Dh(t,e),t=e.pendingProps;var r=Ua(e,qt.current);Fa(e,n),r=V_(null,e,i,t,r,n);var s=z_();return e.flags|=1,typeof r=="object"&&r!==null&&typeof r.render=="function"&&r.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,_n(i)?(s=!0,Yh(e)):s=!1,e.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,A_(e),r.updater=gf,e.stateNode=r,r._reactInternals=e,Qw(e,i,t,n),e=Jw(null,e,i,!0,s,n)):(e.tag=0,qe&&s&&P_(e),Jt(null,e,r,n),e=e.child),e;case 16:i=e.elementType;e:{switch(Dh(t,e),t=e.pendingProps,r=i._init,i=r(i._payload),e.type=i,r=e.tag=vV(i),t=Si(i,t),r){case 0:e=Zw(null,e,i,t,n);break e;case 1:e=N1(null,e,i,t,n);break e;case 11:e=A1(null,e,i,t,n);break e;case 14:e=D1(null,e,i,Si(i.type,t),n);break e}throw Error(D(306,i,""))}return e;case 0:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:Si(i,r),Zw(t,e,i,r,n);case 1:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:Si(i,r),N1(t,e,i,r,n);case 3:e:{if(SC(e),t===null)throw Error(D(387));i=e.pendingProps,s=e.memoizedState,r=s.element,QP(t,e),ef(e,i,null,n);var o=e.memoizedState;if(i=o.element,s.isDehydrated)if(s={element:i,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},e.updateQueue.baseState=s,e.memoizedState=s,e.flags&256){r=qa(Error(D(423)),e),e=O1(t,e,i,n,r);break e}else if(i!==r){r=qa(Error(D(424)),e),e=O1(t,e,i,n,r);break e}else for(Ln=cs(e.stateNode.containerInfo.firstChild),An=e,qe=!0,Ci=null,n=eC(e,null,i,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(ja(),i===r){e=Sr(t,e,n);break e}Jt(t,e,i,n)}e=e.child}return e;case 5:return tC(e),t===null&&Kw(e),i=e.type,r=e.pendingProps,s=t!==null?t.memoizedProps:null,o=r.children,jw(i,r)?o=null:s!==null&&jw(i,s)&&(e.flags|=32),EC(t,e),Jt(t,e,o,n),e.child;case 6:return t===null&&Kw(e),null;case 13:return PC(t,e,n);case 4:return D_(e,e.stateNode.containerInfo),i=e.pendingProps,t===null?e.child=Ba(e,null,i,n):Jt(t,e,i,n),e.child;case 11:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:Si(i,r),A1(t,e,i,r,n);case 7:return Jt(t,e,e.pendingProps,n),e.child;case 8:return Jt(t,e,e.pendingProps.children,n),e.child;case 12:return Jt(t,e,e.pendingProps.children,n),e.child;case 10:e:{if(i=e.type._context,r=e.pendingProps,s=e.memoizedProps,o=r.value,De(Zh,i._currentValue),i._currentValue=o,s!==null)if(Ri(s.value,o)){if(s.children===r.children&&!wn.current){e=Sr(t,e,n);break e}}else for(s=e.child,s!==null&&(s.return=e);s!==null;){var a=s.dependencies;if(a!==null){o=s.child;for(var l=a.firstContext;l!==null;){if(l.context===i){if(s.tag===1){l=xr(-1,n&-n),l.tag=2;var c=s.updateQueue;if(c!==null){c=c.shared;var u=c.pending;u===null?l.next=l:(l.next=u.next,u.next=l),c.pending=l}}s.lanes|=n,l=s.alternate,l!==null&&(l.lanes|=n),Gw(s.return,n,e),a.lanes|=n;break}l=l.next}}else if(s.tag===10)o=s.type===e.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(D(341));o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),Gw(o,n,e),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===e){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}Jt(t,e,r.children,n),e=e.child}return e;case 9:return r=e.type,i=e.pendingProps.children,Fa(e,n),r=oi(r),i=i(r),e.flags|=1,Jt(t,e,i,n),e.child;case 14:return i=e.type,r=Si(i,e.pendingProps),r=Si(i.type,r),D1(t,e,i,r,n);case 15:return kC(t,e,e.type,e.pendingProps,n);case 17:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:Si(i,r),Dh(t,e),e.tag=1,_n(i)?(t=!0,Yh(e)):t=!1,Fa(e,n),ZP(e,i,r),Qw(e,i,r,n),Jw(null,e,i,!0,t,n);case 19:return CC(t,e,n);case 22:return TC(t,e,n)}throw Error(D(156,e.tag))};function HC(t,e){return gP(t,e)}function yV(t,e,n,i){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=i,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ri(t,e,n,i){return new yV(t,e,n,i)}function Q_(t){return t=t.prototype,!(!t||!t.isReactComponent)}function vV(t){if(typeof t=="function")return Q_(t)?1:0;if(t!=null){if(t=t.$$typeof,t===m_)return 11;if(t===g_)return 14}return 2}function hs(t,e){var n=t.alternate;return n===null?(n=ri(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function Fh(t,e,n,i,r,s){var o=2;if(i=t,typeof t=="function")Q_(t)&&(o=1);else if(typeof t=="string")o=5;else e:switch(t){case ka:return so(n.children,r,s,e);case f_:o=8,r|=8;break;case _w:return t=ri(12,n,e,r|2),t.elementType=_w,t.lanes=s,t;case bw:return t=ri(13,n,e,r),t.elementType=bw,t.lanes=s,t;case xw:return t=ri(19,n,e,r),t.elementType=xw,t.lanes=s,t;case J1:return _f(n,r,s,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case X1:o=10;break e;case Z1:o=9;break e;case m_:o=11;break e;case g_:o=14;break e;case es:o=16,i=null;break e}throw Error(D(130,t==null?t:typeof t,""))}return e=ri(o,n,e,r),e.elementType=t,e.type=i,e.lanes=s,e}function so(t,e,n,i){return t=ri(7,t,i,e),t.lanes=n,t}function _f(t,e,n,i){return t=ri(22,t,i,e),t.elementType=J1,t.lanes=n,t.stateNode={isHidden:!1},t}function yw(t,e,n){return t=ri(6,t,null,e),t.lanes=n,t}function vw(t,e,n){return e=ri(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function wV(t,e,n,i,r){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=tw(0),this.expirationTimes=tw(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=tw(0),this.identifierPrefix=i,this.onRecoverableError=r,this.mutableSourceEagerHydrationData=null}function X_(t,e,n,i,r,s,o,a,l){return t=new wV(t,e,n,a,l),e===1?(e=1,s===!0&&(e|=8)):e=0,s=ri(3,null,null,e),t.current=s,s.stateNode=t,s.memoizedState={element:i,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},A_(s),t}function _V(t,e,n){var i=3{"use strict";function YC(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(YC)}catch(t){console.error(t)}}YC(),QC.exports=GC()});var mu=Lt(tb=>{"use strict";var XC=fu();tb.createRoot=XC.createRoot,tb.hydrateRoot=XC.hydrateRoot;var eG});var tM=Lt(eM=>{"use strict";var Ya=X();function EV(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var SV=typeof Object.is=="function"?Object.is:EV,PV=Ya.useState,CV=Ya.useEffect,MV=Ya.useLayoutEffect,$V=Ya.useDebugValue;function RV(t,e){var n=e(),i=PV({inst:{value:n,getSnapshot:e}}),r=i[0].inst,s=i[1];return MV(function(){r.value=n,r.getSnapshot=e,nb(r)&&s({inst:r})},[t,n,e]),CV(function(){return nb(r)&&s({inst:r}),t(function(){nb(r)&&s({inst:r})})},[t]),$V(n),n}function nb(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!SV(t,n)}catch{return!0}}function IV(t,e){return e()}var LV=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?IV:RV;eM.useSyncExternalStore=Ya.useSyncExternalStore!==void 0?Ya.useSyncExternalStore:LV});var iM=Lt((rG,nM)=>{"use strict";nM.exports=tM()});var sM=Lt(rM=>{"use strict";var Sf=X(),AV=iM();function DV(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var NV=typeof Object.is=="function"?Object.is:DV,OV=AV.useSyncExternalStore,FV=Sf.useRef,VV=Sf.useEffect,zV=Sf.useMemo,UV=Sf.useDebugValue;rM.useSyncExternalStoreWithSelector=function(t,e,n,i,r){var s=FV(null);if(s.current===null){var o={hasValue:!1,value:null};s.current=o}else o=s.current;s=zV(function(){function l(h){if(!c){if(c=!0,u=h,h=i(h),r!==void 0&&o.hasValue){var m=o.value;if(r(m,h))return d=m}return d=h}if(m=d,NV(u,h))return m;var v=i(h);return r!==void 0&&r(m,v)?m:(u=h,d=v)}var c=!1,u,d,p=n===void 0?null:n;return[function(){return l(e())},p===null?void 0:function(){return l(p())}]},[e,n,i,r]);var a=OV(t,s[0],s[1]);return VV(function(){o.hasValue=!0,o.value=a},[a]),UV(a),a}});var aM=Lt((oG,oM)=>{"use strict";oM.exports=sM()});function YV(){Lf=!0,queueMicrotask(EM)}function EM(){if(!Qa.length){Lf=!1;return}lb=!0;for(let t=0;t=0;n--)bb(e[n])}function SM(t){let e=rn();return bu(e,t.length?t.bind(null,_u.bind(e)):t,null)}function N(t){return bu(nn,t,null)}function el(t){return bu(null,t,null)}function Li(){lb||EM()}function wu(){return nn}function Ct(t,e){try{return bu(e,t,null)}catch(n){gb(e,n);return}}function mb(t,e=nn){return e?.$cx[t]}function XV(t,e,n=nn){n&&(n.$cx={...n.$cx,[t]:e})}function ZV(t){nn&&(nn.$eh=nn.$eh?[t,...nn.$eh]:[t])}function ae(t){if(!t||!nn)return t||GV;let e=nn;return e.$d?Array.isArray(e.$d)?e.$d.push(t):e.$d=[e.$d,t]:e.$d=t,function(){e.$st!==Nf&&(t.call(null),Of(e.$d)?e.$d=null:Array.isArray(e.$d)&&e.$d.splice(e.$d.indexOf(t),1))}}function _u(t=!0){if(this.$st===Nf)return;let e=t?this.$ps||this[Vn]:this,n=this.$ns,i=null;for(;n&&n[Vn]===this;)_u.call(n,!0),vM(n),i=n.$ns,n.$ns=null,n=i;t&&vM(this),n&&(n.$ps=t?this.$ps:this),e&&(e.$ns=n)}function vM(t){t.$st=Nf,t.$d&&PM(t),t.$s&&Rf(t,0),t.$ps&&(t.$ps.$ns=null),t[Vn]=null,t.$s=null,t.$o=null,t.$ps=null,t.$cx=fb,t.$eh=null}function PM(t){try{if(Array.isArray(t.$d))for(let e=t.$d.length-1;e>=0;e--){let n=t.$d[e];n.call(n)}else t.$d.call(t.$d);t.$d=null}catch(e){gb(t,e)}}function bu(t,e,n){let i=nn,r=Xa;nn=t,Xa=n;try{return e.call(t)}finally{nn=i,Xa=r}}function gb(t,e){if(!t||!t.$eh)throw e;let n=0,i=t.$eh.length,r=wM(e);for(n=0;n0){t.$s.length=Fn+li.length;for(let s=0;s=e)&&(t.$e&&t.$st===Ja&&(Qa.push(t),Lf||YV()),t.$st=e,t.$o))for(let n=0;nt();return e[Vn]=!0,e}function xb(t){return IM(t)&&"set"in t}function kn(...t){}function Ji(t){return t===null}function Qe(t){return typeof t>"u"}function kb(t){return Ji(t)||Qe(t)}function xu(t){return t?.constructor===Object}function dt(t){return typeof t=="number"&&!Number.isNaN(t)}function Z(t){return typeof t=="string"}function Tb(t){return typeof t=="boolean"}function Wt(t){return typeof t=="function"}function ut(t){return Array.isArray(t)}function t5(t){return Z(t)?new RegExp(t):t}function n5(t){return xn?!1:t===window}function i5(t,e){return typeof process<"u",kn}function Ff(t){return!!t?.[DM]}function s5(t){return t.originEvent}function NM(t,e){if(Ff(t))return t.triggers.walk(e)}function Eb(t,e){return Ff(t)?t.triggers.findType(e):void 0}function OM(t,e){return!!Eb(t,e)}function FM(t,e){e&&t.triggers.add(e)}function L(t,e,n,i){return xn?kn:(t.addEventListener(e,n,i),ae(()=>t.removeEventListener(e,n,i)))}function ku(t){return!!t?.type.startsWith("pointer")}function tl(t){return!!t?.type.startsWith("touch")}function Sb(t){return/^(click|mouse)/.test(t?.type??"")}function Mr(t){return!!t?.type.startsWith("key")}function o5(t){return Mr(t)&&t.key==="Enter"}function a5(t){return Mr(t)&&t.key==="Escape"}function Tu(t){return Mr(t)&&(t.key==="Enter"||t.key===" ")}function Pb(t){return t instanceof Node}function l5(t){return Pb(t)&&t.nodeType===1}function c5(t){return Pb(t)&&t.nodeType===11}function u5(){return document.createDocumentFragment()}function d5(t){return xn?t:document.createComment(t)}function pe(t,e,n){if(t)if(!n&&n!==""&&n!==0)t.removeAttribute(e);else{let i=n===!0?"":n+"";t.getAttribute(e)!==i&&t.setAttribute(e,i)}else return}function Ot(t,e,n){if(t)!n&&n!==0?t.style.removeProperty(e):t.style.setProperty(e,n+"");else return}function p5(t,e,n){t.classList[n?"add":"remove"](e)}function h5(t,e){let n=e?`slot[name="${e}"]`:"slot:not([name])",r=t.shadowRoot?.querySelector(n)?.assignedNodes({flatten:!0})??[];return Array.prototype.filter.call(r,s=>s.nodeType==1)}function f5(t){let e=t.firstChild,n=e.getAttribute("shadowroot");e.parentNode.attachShadow({mode:n}).appendChild(e.content),e.remove()}function m5(t){return Wt(t)?t():t}function cb(t){let e=t;for(;typeof e=="function";)e=e.call(this);return e}function er(t){return{id:Symbol(),provide:t}}function on(t,e,n=wu()){let i=!Qe(e);XV(t.id,i?e:t.provide?.(),n)}function Xe(t){return mb(t.id)}function ci(t){return!Qe(mb(t.id))}function g5(t){let e={};for(let n of Object.keys(t)){let i=t[n];e[n]=K(i,i)}return e}function Cb(t,e){return SM(()=>{yu.$$=new Df(t,wu(),e);let n=new t;return yu.$$.e=n,yu.$$=null,n})}function he(t,e,n){t[sb]||(t[sb]=new Set),t[sb].add(e)}function Ze(t,e,n){t[ob]||(t[ob]=new Set),t[ob].add(e)}function mo(t){return Xe(t)}function nl(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function y5(t){return Eu(t.replace(/([A-Z])/g," $1"))}function zf(t){return t.replace(/-./g,e=>e[1].toUpperCase())}function zM(t){return UM(t).replace(/\s/g,"")}function UM(t){return Eu(t.replace(/-./g,e=>" "+e[1].toUpperCase()))}function Eu(t){return t.charAt(0).toUpperCase()+t.slice(1)}function v5(t){return t.charAt(0).toLowerCase()+t.slice(1)}function _5(t){return t.replace(w5,"")}function Uf(t,...e){return Pe.createElement(go.Provider,{value:t},...e)}function jf(){return Pe.useContext(go).current}function Bf(t){let e=jf();return Pe.useMemo(()=>mb(t.id,e),[e])}function b5(){return BM}function x5(t,e){var n;return n=class extends BM{},n.F=t,n.T=e,n}function Mb(t,e){typeof t=="function"?t(e):t&&(t.current=e)}function ye(...t){return e=>t.forEach(n=>Mb(n,e))}function k5(t,e){let n=Pe.forwardRef((i,r)=>{let s=Pe.useContext(go),o=Pe.useRef(null),a=Pe.useRef();if(!a.current){let w=E5(),f=kM(t,w,i,s.current);w.e=f,a.current=w,o.current=f.scope}function l(){let w=a.current,f=s.current;if(window.cancelAnimationFrame(w.ea),w.ea=-1,w.e.$$.o){let g=kM(t,w,i,f);w.e=g,w.Q=!1,w.da=!1,o.current=g.scope}return w.a&&xM(w,w.a),w.da||(Mb(r,w.e),w.da=!0),()=>If(w)}function c(w){let f=a.current;if(!f.da){f.a=w;return}window.cancelAnimationFrame(f.K),f.K=window.requestAnimationFrame(()=>{let g=a.current;g.K=-1,g.a!==w&&(If(g),w&&xM(g,w),g.a=w)})}Pe.useEffect(()=>{let w=a.current;return window.cancelAnimationFrame(w.ea),w.ea=-1,function(){Wt(i.children)&&(window.cancelAnimationFrame(w.K),w.K=-1,window.cancelAnimationFrame(w.E),w.E=-1,window.cancelAnimationFrame(w.ea),w.ea=window.requestAnimationFrame(()=>{w.ea=-1,If(w),w.e.$$.p(),w.e.$$[Vf]=null,w.J={},w._={},o.current=null}))}},[]),Pe.useEffect(Li);let u=a.current,{children:d,...p}=i,h={},m=u.aa,v=Object.keys(p);u.J={};for(let w of[...m,...v])if(e.props.has(w))u.e.$props[w].set(v.includes(w)?p[w]:t.props?.[w]);else if(e.events?.has(w)||e.eventsRE?.test(w))u.J[w]=p[w];else if(e.domEvents?.has(w)||e.domEventsRE?.test(w)){let f=nl(w.slice(2));u._[f]=p[w],v.includes(w)?u.a&&!u.ca?.has(f)&&(u.ca||(u.ca=new Set),u.ca.add(f),u.a.addEventListener(f,u.ba)):(u.a?.removeEventListener(f,u.ba),u.ca?.delete(f))}else h[w]=p[w];return u.aa=v,Uf(o,Pe.createElement(T5,{effect:l}),Wt(d)?d?.({...h,suppressHydrationWarning:!0,ref:c},u.e):d)});return n.displayName=t.name+"Bridge",n}function T5({effect:t}){return Pe.useEffect(t,[]),null}function E5(){let t={a:null,aa:[],J:{},_:{},K:-1,E:-1,ea:-1,Q:!1,da:!1,ca:null,ba(e){let n=Qe(e.detail)?[e]:[e.detail,e];t._[e.type]?.(...n)}};return t}function xM(t,e){if(!(t.a===e&&t.Q)){if(t.Q&&If(t),t._){t.ca||(t.ca=new Set);for(let n of Object.keys(t._))t.ca.has(n)||(e.addEventListener(n,t.ba),t.ca.add(n))}t.e.$$.x(e),t.E=window.requestAnimationFrame(()=>{t.e.$$.y(),t.E=-1}),t.Q=!0}}function If(t){if(t.Q&&(window.cancelAnimationFrame(t.E),t.E=-1,t.e.$$.s(),t.Q=!1,t.a&&t.ca)){for(let e of t.ca)t.a.removeEventListener(e,t.ba);t.ca.clear()}}function S5(t){let e=bM.get(t.type),n=Qe(t.detail)?[t]:[t.detail,t];e||bM.set(t.type,e=`on${zM(t.type)}`),this.J[e]?.(...n)}function kM(t,e,n,i){let r=Cb(t,{props:n,scope:i});return r.$$[Vf]=S5.bind(e),r.$$.w(),r}function HM(t,e=!1){let n=typeof t;if(n!=="string")return!e&&n==="function"?HM(t()):e&&n==="boolean"?t+"":t;let i=e?'"':"<",r=e?""":"<",s=t.indexOf(i),o=t.indexOf("&");if(s<0&&o<0)return t;let a=0,l="";for(;s>=0&&o>=0;)s=0)do a=0);else for(;o>=0;)a(o.destroy(),null)))}return n.displayName=t.name+"Bridge",n}function ws(t){return Bf(t)}function Me(t,e){let[,n]=Pe.useState();return Pe.useEffect(()=>LM(()=>{t(),n({})}),[e??t]),t()}function il(t){return t?"true":"false"}function qM(t){let e=[];for(let n=0;n!e.includes(n)))}function $r(){let t,e;return{promise:new Promise((i,r)=>{t=i,e=r}),resolve:t,reject:e}}function V5(t,e,n){let i=new Promise((r,s)=>{let o=setTimeout(()=>{clearTimeout(o),s(n)},e)});return Promise.race([t,i])}function Rb(t){return new Promise(e=>setTimeout(e,t))}function z5(t){return xn?Promise.resolve():new Promise(e=>{window.requestAnimationFrame(n=>{t?.(n),e()})})}function _s(t){if(xn)return kn;let e=-1,n;function i(...r){n=r,!(e>=0)&&(e=window.requestAnimationFrame(()=>{t.apply(this,n),e=-1,n=void 0}))}return i}function Ib(t,e){return xn?Promise.resolve():new Promise(n=>{U5(i=>{t?.(i),n()},e)})}function Lb(t){let[,e]=Pe.useState(),n=Pe.useRef(null);return n.current==null&&(n.current={state:{},$update:K({}),props:new Set}),Pe.useEffect(()=>{let{state:i,$update:r,props:s}=n.current;return S(()=>{for(let o of s){let a=t[o]();i[o]=ut(a)?[...a]:a}r(),e({})})},[t]),Pe.useMemo(()=>{let{state:i,$update:r,props:s}=n.current,o=!1;return s.clear(),new Proxy(i,{get(a,l){if(!s.has(l)&&l in t){s.add(l);let c=t[l]();i[l]=ut(c)?[...c]:c,o||(r.set({}),o=!0,queueMicrotask(()=>o=!1))}return i[l]},set(a,l,c){return l in t||(i[l]=c),!0}})},[t])}function de(t,e){return xn?A5(t,{props:new Set(Object.keys(t.props||{}))}):k5(t,{props:new Set(Object.keys(t.props||{})),events:new Set(e?.events),eventsRE:e?.eventsRegex,domEvents:e?.domEvents,domEventsRE:e?.domEventsRegex})}var Pe,xn,Vn,Lf,lb,nn,Xa,li,Fn,Qa,fb,GV,Ja,TM,vu,Nf,vb,fo,MM,wb,S,AM,r5,DM,ne,Af,Za,sb,ob,Vf,VM,ab,Df,yu,sn,ie,Ii,w5,go,jM,BM,bM,P5,C5,$5,R5,ub,db,pb,hb,L5,U5,bs,an=at(()=>{"use strict";"use client";Pe=A(X(),1),xn=typeof document>"u",Vn=Symbol(0),Lf=!1,lb=!1,nn=null,Xa=null,li=null,Fn=0,Qa=[],fb={},GV=()=>{},Ja=0,TM=1,vu=2,Nf=3;vb=function(){this[Vn]=null,this.$ns=null,this.$ps=null,nn&&nn.append(this)},fo=vb.prototype;fo.$cx=fb;fo.$eh=null;fo.$c=null;fo.$d=null;fo.append=function(t){if(t[Vn]=this,t.$ps=this,this.$ns)if(t.$ns){let e=t.$ns;for(;e.$ns;)e=e.$ns;e.$ns=this.$ns,this.$ns.$ps=e}else t.$ns=this.$ns,this.$ns.$ps=t;this.$ns=t,t.$cx=t.$cx===fb?this.$cx:{...this.$cx,...t.$cx},this.$eh&&(t.$eh=t.$eh?[...t.$eh,...this.$eh]:this.$eh)};fo.dispose=function(){_u.call(this)};MM=function(e,n,i){vb.call(this),this.$st=n?vu:Ja,this.$i=!1,this.$e=!1,this.$s=null,this.$o=null,this.$v=e,n&&(this.$c=n),i&&i.dirty&&(this.$ch=i.dirty)},wb=MM.prototype;Object.setPrototypeOf(wb,fo);wb.$ch=JV;wb.call=yb;S=xn?i5:LM;r5=xn?class{}:Event,DM=Symbol("DOM_EVENT"),ne=class extends r5{constructor(e,...n){super(e,n[0]),this[AM]=!0,this.triggers=new Af,this.detail=n[0]?.detail;let i=n[0]?.trigger;i&&this.triggers.add(i)}get trigger(){return this.triggers.source}get originEvent(){return this.triggers.origin}get isOriginTrusted(){return this.triggers.origin?.isTrusted??!1}};AM=DM;Af=class{constructor(){this.chain=[]}get source(){return this.chain[0]}get origin(){return this.chain[this.chain.length-1]}add(e){this.chain.push(e),Ff(e)&&this.chain.push(...e.triggers)}remove(e){return this.chain.splice(this.chain.indexOf(e),1)[0]}has(e){return this.chain.some(n=>n===e)}hasType(e){return!!this.findType(e)}findType(e){return this.chain.find(n=>n.type===e)}walk(e){for(let n of this.chain){let i=e(n);if(i)return[n,i]}}[Symbol.iterator](){return this.chain.values()}};Za=class extends EventTarget{addEventListener(e,n,i){return super.addEventListener(e,n,i)}removeEventListener(e,n,i){return super.removeEventListener(e,n,i)}};sb=Symbol(0),ob=Symbol(0),Vf=Symbol(0),ab={},Df=class{constructor(e,n,i){this[VM]=null,this.$el=K(null),this.a=null,this.d=null,this.f=null,this.g=null,this.e=null,this.o=!1,this.i=ab,this.b=null,this.c=null,this.l=[],this.m=[],this.j=[],this.n=[],this.d=n,i?.scope&&i.scope.append(n);let r=e.state,s=e.props;if(r&&(this.h=r.create(),this.k=new Proxy(this.h,{get:(o,a)=>this.h[a]()}),on(r,this.h)),s&&(this.i=g5(s),i?.props))for(let o of Object.keys(i.props))this.i[o]?.set(i.props[o]);ae(this.p.bind(this))}w(){Ct(()=>{for(let e of this.l)e()},this.d)}x(e){this.a||(this.a=e,this.$el.set(e),Ct(()=>{this.f=rn(),Ct(()=>{for(let n of this.m)n(this.a);this.q(),this.r()},this.f)},this.d),e.dispatchEvent(new Event("attached")))}s(){this.f?.dispose(),this.f=null,this.g=null,this.a=null,this.$el.set(null)}y(){!this.a||!this.f||!this.j.length||Ct(()=>{this.g=rn(),Ct(()=>{for(let e of this.j)e(this.a)},this.g)},this.f)}z(){this.g?.dispose(),this.g=null}p(){if(this.o)return;this.o=!0,Ct(()=>{for(let n of this.n)n(this.a)},this.d);let e=this.a;this.s(),this.d.dispose(),this.l.length=0,this.m.length=0,this.j.length=0,this.n.length=0,this.e=null,this.b=null,this.c=null,this.i=ab,this.d=null,this.k=ab,this.h=null,e&&delete e.$}t(e){e.onSetup&&this.l.push(e.onSetup.bind(e)),e.onAttach&&this.m.push(e.onAttach.bind(e)),e.onConnect&&this.j.push(e.onConnect.bind(e)),e.onDestroy&&this.n.push(e.onDestroy.bind(e))}q(){if(this.b)for(let e of Object.keys(this.b))xn?pe(this.a,e,cb.call(this.e,this.b[e])):Wt(this.b[e])?S(this.u.bind(this,e)):pe(this.a,e,this.b[e])}r(){if(this.c)for(let e of Object.keys(this.c))xn?Ot(this.a,e,cb.call(this.e,this.c[e])):Wt(this.c[e])?S(this.v.bind(this,e)):Ot(this.a,e,this.c[e])}u(e){pe(this.a,e,this.b[e].call(this.e))}v(e){Ot(this.a,e,this.c[e].call(this.e))}};VM=Vf;yu={$$:null};sn=class extends EventTarget{constructor(){super(),yu.$$&&this.attach(yu)}get el(){return this.$$.a}get $el(){return this.$$.$el()}get scope(){return this.$$.d}get attachScope(){return this.$$.f}get connectScope(){return this.$$.g}get $props(){return this.$$.i}get $state(){return this.$$.h}get state(){return this.$$.k}attach({$$:e}){return this.$$=e,e.t(this),this}addEventListener(e,n,i){this.listen(e,n,i)}removeEventListener(e,n,i){this.el?.removeEventListener(e,n,i)}setAttributes(e){this.$$.b||(this.$$.b={}),Object.assign(this.$$.b,e)}setStyles(e){this.$$.c||(this.$$.c={}),Object.assign(this.$$.c,e)}setCSSVars(e){this.setStyles(e)}createEvent(e,...n){return new ne(e,n[0])}dispatch(e,...n){if(xn||!this.el)return!1;let i=e instanceof Event?e:new ne(e,n[0]);return Object.defineProperty(i,"target",{get:()=>this.$$.e}),el(()=>(this.$$[Vf]?.(i),this.el.dispatchEvent(i)))}dispatchEvent(e){return this.dispatch(e)}listen(e,n,i){return xn||!this.el?kn:L(this.el,e,n,i)}},ie=class extends sn{subscribe(e){return Ct(()=>S(()=>e(this.state)),this.$$.d)}destroy(){this.$$.p()}};Ii=class{constructor(e){this.id=Symbol(0),this.record=e,this.A=Object.getOwnPropertyDescriptors(e)}create(){let e={},n=new Proxy(e,{get:(i,r)=>e[r]()});for(let i of Object.keys(this.record)){let r=this.A[i].get;e[i]=r?Zi(r.bind(n)):K(this.record[i])}return e}reset(e,n){for(let i of Object.keys(e))!this.A[i].get&&(!n||n(i))&&e[i].set(this.record[i])}};w5=/;\s*$/;go=Pe.createContext({current:null});go.displayName="Scope";jM=class extends Pe.Component{constructor(e,n){super(e),this.d={current:rn()},n&&n.append(this.d.current);let i=this.constructor;i.F&&on(i.F,i.T?.(),this.d.current)}render(){return Uf(this.d,this.props?.children)}};jM.contextType=go;BM=jM;bM=new Map;P5=Symbol(0),C5=/\s+/;$5=/\s*:\s*/,R5=/\s*;\s*/;ub=class{constructor(e){this.keepAlive=!1,this.forwardKeepAlive=!0,this.attributes=new db,this.style=new pb,this.classList=new hb,this.$=e}get $props(){return this.$.$$.i}get $state(){return this.$.$$.h}get state(){return this.$.state}setup(){let e=this.$.$$;Ct(()=>{this.hasAttribute("class")&&M5(this.classList.tokens,this.getAttribute("class")),this.hasAttribute("style")&&I5(this.style.tokens,this.getAttribute("style")),e.w(),e.x(this),this.classList.length>0&&this.setAttribute("class",this.classList.toString()),this.style.length>0&&this.setAttribute("style",this.style.toString()),this.keepAlive&&this.setAttribute("keep-alive","")},e.d)}getAttribute(e){return this.attributes.getAttribute(e)}setAttribute(e,n){this.attributes.setAttribute(e,n)}hasAttribute(e){return this.attributes.hasAttribute(e)}removeAttribute(e){return this.attributes.removeAttribute(e)}[P5](){}addEventListener(){}removeEventListener(){}dispatchEvent(){return!1}subscribe(){return kn}destroy(){this.$.destroy()}},db=class{constructor(){this.Z=new Map}get length(){return this.Z.size}get tokens(){return this.Z}getAttribute(e){return this.Z.get(e)??null}hasAttribute(e){return this.Z.has(e)}setAttribute(e,n){this.Z.set(e,n+"")}removeAttribute(e){this.Z.delete(e)}toString(){if(this.Z.size===0)return"";let e="";for(let[n,i]of this.Z)e+=` ${n}="${HM(i,!0)}"`;return e}},pb=class{constructor(){this.Z=new Map}get length(){return this.Z.size}get tokens(){return this.Z}getPropertyValue(e){return this.Z.get(e)??""}setProperty(e,n){this.Z.set(e,n??"")}removeProperty(e){let n=this.Z.get(e);return this.Z.delete(e),n??""}toString(){if(this.Z.size===0)return"";let e="";for(let[n,i]of this.Z)e+=`${n}: ${i};`;return e}},hb=class{constructor(){this.Z=new Set}get length(){return this.Z.size}get tokens(){return this.Z}add(...e){for(let n of e)this.Z.add(n)}contains(e){return this.Z.has(e)}remove(e){this.Z.delete(e)}replace(e,n){return this.Z.has(e)?(this.Z.delete(e),this.Z.add(n),!0):!1}toggle(e,n){return n!==!0&&(this.Z.has(e)||n===!1)?(this.Z.delete(e),!1):(this.Z.add(e),!0)}toString(){return Array.from(this.Z).join(" ")}},L5={acceptcharset:"acceptCharset","accept-charset":"acceptCharset",accesskey:"accessKey",allowfullscreen:"allowFullScreen",autocapitalize:"autoCapitalize",autocomplete:"autoComplete",autocorrect:"autoCorrect",autofocus:"autoFocus",autoplay:"autoPlay",autosave:"autoSave",cellpadding:"cellPadding",cellspacing:"cellSpacing",charset:"charSet",class:"className",classid:"classID",classname:"className",colspan:"colSpan",contenteditable:"contentEditable",contextmenu:"contextMenu",controlslist:"controlsList",crossorigin:"crossOrigin",dangerouslysetinnerhtml:"dangerouslySetInnerHTML",datetime:"dateTime",defaultchecked:"defaultChecked",defaultvalue:"defaultValue",disablepictureinpicture:"disablePictureInPicture",disableremoteplayback:"disableRemotePlayback",enctype:"encType",enterkeyhint:"enterKeyHint",fetchpriority:"fetchPriority",for:"htmlFor",formmethod:"formMethod",formaction:"formAction",formenctype:"formEncType",formnovalidate:"formNoValidate",formtarget:"formTarget",frameborder:"frameBorder",hreflang:"hrefLang",htmlfor:"htmlFor",httpequiv:"httpEquiv","http-equiv":"httpEquiv",imagesizes:"imageSizes",imagesrcset:"imageSrcSet",innerhtml:"innerHTML",inputmode:"inputMode",itemid:"itemID",itemprop:"itemProp",itemref:"itemRef",itemscope:"itemScope",itemtype:"itemType",keyparams:"keyParams",keytype:"keyType",marginwidth:"marginWidth",marginheight:"marginHeight",maxlength:"maxLength",mediagroup:"mediaGroup",minlength:"minLength",nomodule:"noModule",novalidate:"noValidate",playsinline:"playsInline",radiogroup:"radioGroup",readonly:"readOnly",referrerpolicy:"referrerPolicy",rowspan:"rowSpan",spellcheck:"spellCheck",srcdoc:"srcDoc",srclang:"srcLang",srcset:"srcSet",tabindex:"tabIndex",usemap:"useMap"};U5=xn?kn:typeof window<"u"?"requestIdleCallback"in window?window.requestIdleCallback:t=>window.setTimeout(t,1):kn;bs=Object.freeze({__proto__:null,Component:ie,DOMEvent:ne,EventTriggers:Af,EventsTarget:Za,Instance:Df,ReactScopeContext:go,State:Ii,ViewController:sn,WithScope:Uf,animationFrameThrottle:_s,appendTriggerEvent:FM,ariaBool:il,attachDeclarativeShadowDOM:f5,camelToKebabCase:nl,camelToTitleCase:y5,composeRefs:ye,computed:Zi,createComment:d5,createComponent:Cb,createContext:er,createDisposalBin:Su,createFragment:u5,createReactComponent:de,createReactContextProvider:x5,createReactScopeProvider:b5,createRegex:t5,createScope:rn,deferredPromise:$r,effect:S,findTriggerEvent:Eb,flattenArray:qM,getOriginEvent:s5,getScope:wu,getSlottedChildren:h5,hasProvidedContext:ci,hasTriggerEvent:OM,isArray:ut,isBoolean:Tb,isDOMElement:l5,isDOMEvent:Ff,isDOMFragment:c5,isDOMNode:Pb,isFunction:Wt,isKeyboardClick:Tu,isKeyboardEvent:Mr,isMouseEvent:Sb,isNil:kb,isNull:Ji,isNumber:dt,isObject:xu,isPointerEvent:ku,isReadSignal:IM,isString:Z,isTouchEvent:tl,isUndefined:Qe,isWindow:n5,isWriteSignal:xb,kebabToCamelCase:zf,kebabToPascalCase:zM,kebabToTitleCase:UM,keysOf:Pu,listenEvent:L,lowercaseFirstLetter:v5,mergeProperties:O5,method:Ze,noop:kn,omit:F5,onDispose:ae,onError:ZV,peek:N,pick:WM,prop:he,provideContext:on,readonly:e5,root:SM,run:D5,runAll:N5,scoped:Ct,setAttribute:pe,setRef:Mb,setStyle:Ot,signal:K,tick:Li,timedPromise:V5,toggleClass:p5,trimTrailingSemicolon:_5,untrack:el,unwrap:m5,unwrapDeep:cb,uppercaseFirstChar:Eu,useContext:Xe,useDisposalBin:$b,useReactContext:Bf,useReactScope:jf,useSignal:Me,useSignalRecord:Lb,useState:mo,useStateContext:ws,waitAnimationFrame:z5,waitIdlePeriod:Ib,waitTimeout:Rb,walkTriggerEventChain:NM,wasEnterKeyPressed:o5,wasEscapeKeyPressed:a5})});var KM={};zt(KM,{SRTParser:()=>Hf,default:()=>H5});function H5(){return new Hf}var j5,B5,Hf,GM=at(()=>{"use strict";Cu();j5=/,/g,B5="-->",Hf=class extends sl{parse(e,n){if(e==="")this.a&&(this.j.push(this.a),this.f.onCue?.(this.a),this.a=null),this.c=rl.None;else if(this.c===rl.Cue)this.a.text+=(this.a.text?` `:"")+e;else if(e.includes(B5)){let i=this.o(e,n);i&&(this.a=new Rr(i[0],i[1],i[2].join(" ")),this.a.id=this.l,this.c=rl.Cue)}this.l=e}o(e,n){return super.o(e.replace(j5,"."),n)}}});var Ab={};zt(Ab,{ParseErrorBuilder:()=>q5});var q5,Db=at(()=>{"use strict";Cu();q5={p(){return new Tn({code:ui.BadSignature,reason:"missing WEBVTT file header",line:1})},q(t,e){return new Tn({code:ui.BadTimestamp,reason:`cue start timestamp \`${t}\` is invalid on line ${e}`,line:e})},r(t,e){return new Tn({code:ui.BadTimestamp,reason:`cue end timestamp \`${t}\` is invalid on line ${e}`,line:e})},s(t,e,n){return new Tn({code:ui.BadTimestamp,reason:`cue end timestamp \`${e}\` is greater than start \`${t}\` on line ${n}`,line:n})},w(t,e,n){return new Tn({code:ui.BadSettingValue,reason:`invalid value for cue setting \`${t}\` on line ${n} (value: ${e})`,line:n})},v(t,e,n){return new Tn({code:ui.UnknownSetting,reason:`unknown cue setting \`${t}\` on line ${n} (value: ${e})`,line:n})},u(t,e,n){return new Tn({code:ui.BadSettingValue,reason:`invalid value for region setting \`${t}\` on line ${n} (value: ${e})`,line:n})},t(t,e,n){return new Tn({code:ui.UnknownSetting,reason:`unknown region setting \`${t}\` on line ${n} (value: ${e})`,line:n})},T(t,e){return new Tn({code:ui.BadFormat,reason:`format missing for \`${t}\` block on line ${e}`,line:e})}}});var e$={};zt(e$,{SSAParser:()=>Kf,default:()=>W5});function Ob(t){let e=parseInt(t.replace("&H",""),16);if(e>=0){let i=(e>>24&255^255)/255,r=e>>16&255,s=e>>8&255;return"rgba("+[e&255,s,r,i].join(",")+")"}return null}function Fb(t,e,n){let i=Math.ceil(2*Math.PI*t),r="";for(let s=0;s{"use strict";Cu();qf=/^Format:[\s\t]*/,YM=/^Style:[\s\t]*/,QM=/^Dialogue:[\s\t]*/,Wf=/[\s\t]*,[\s\t]*/,XM=/\{[^}]+\}/g,ZM=/\\N/g,JM=/^\[(.*)[\s\t]?Styles\]$/,Nb=/^\[(.*)[\s\t]?Events\]$/,Kf=class{constructor(){E(this,"f");E(this,"O",0);E(this,"a",null);E(this,"j",[]);E(this,"k",[]);E(this,"N",null);E(this,"d");E(this,"P",{})}async init(e){this.f=e,e.errors&&(this.d=(await Promise.resolve().then(()=>(Db(),Ab))).ParseErrorBuilder)}parse(e,n){if(this.O)switch(this.O){case 1:if(e==="")this.O=0;else if(YM.test(e))if(this.N){let i=e.replace(YM,"").split(Wf);this.S(i)}else this.e(this.d?.T("Style",n));else qf.test(e)?this.N=e.replace(qf,"").split(Wf):Nb.test(e)&&(this.N=null,this.O=2);break;case 2:if(e==="")this.Q();else if(QM.test(e))if(this.Q(),this.N){let i=e.replace(QM,"").split(Wf),r=this.U(i,n);r&&(this.a=r)}else this.e(this.d?.T("Dialogue",n));else this.a?this.a.text+=` `+e.replace(XM,"").replace(ZM,` `):qf.test(e)?this.N=e.replace(qf,"").split(Wf):JM.test(e)?(this.N=null,this.O=1):Nb.test(e)&&(this.N=null)}else e===""||(JM.test(e)?(this.N=null,this.O=1):Nb.test(e)&&(this.N=null,this.O=2))}done(){return{metadata:{},cues:this.j,regions:[],errors:this.k}}Q(){this.a&&(this.j.push(this.a),this.f.onCue?.(this.a),this.a=null)}S(e){let n="Default",i={},r,s="center",o="bottom",a,l=1.2,c,u,d=3,p=[];for(let h=0;h=4&&(o=g>=7?"top":"center"),g%3){case 1:s="start";break;case 2:s="center";break;case 3:s="end";break}}}if(i.R=o,i["--cue-white-space"]="normal",i["--cue-line-height"]="normal",i["--cue-text-align"]=s,o==="center"?(i["--cue-top"]="50%",p.push("translateY(-50%)")):i[`--cue-${o}`]=(a||0)+"px",d===1&&(i["--cue-padding-y"]="0"),(d===1||u)&&(i["--cue-bg-color"]=d===1?"none":u),d===3&&c&&(i["--cue-outline"]=`${r}px solid ${c}`),d===1&&typeof r=="number"){let h=u??"#000";i["--cue-text-shadow"]=[c&&Fb(r*1.2,l*1.2,c),c?Fb(r*(r/2),l*(r/2),h):Fb(r,l,h)].filter(Boolean).join(", ")}p.length&&(i["--cue-transform"]=p.join(" ")),this.P[n]=i}U(e,n){let i=this.V(e),r=this.o(i.Start,i.End,n);if(!r)return;let s=new Rr(r[0],r[1],""),o={...this.P[i.Style]||{}},a=i.Name?``:"",l=o.R,c=i.MarginL&&parseFloat(i.MarginL),u=i.MarginR&&parseFloat(i.MarginR),d=i.MarginV&&parseFloat(i.MarginV);return c&&(o["--cue-width"]="auto",o["--cue-left"]=c+"px"),u&&(o["--cue-width"]="auto",o["--cue-right"]=u+"px"),d&&l!=="center"&&(o[`--cue-${l}`]=d+"px"),s.text=a+e.slice(this.N.length-1).join(", ").replace(XM,"").replace(ZM,` `),delete o.R,Object.keys(o).length&&(s.style=o),s}V(e){let n={};for(let i=0;ir)return[r,s];r===null&&this.e(this.d?.q(e,i)),s===null&&this.e(this.d?.r(n,i)),r!=null&&s!==null&&s>r&&this.e(this.d?.s(r,s,i))}e(e){if(e){if(this.k.push(e),this.f.strict)throw this.f.cancel(),e;this.f.onError?.(e)}}}});async function a$(t,e){let n=new ReadableStream({start(i){let r=t.split(o$);for(let s of r)i.enqueue(s);i.close()}});return Xf(n,e)}async function Xf(t,e){let n=e?.type??"vtt",i;if(typeof n=="string")switch(n){case"srt":i=(await Promise.resolve().then(()=>(GM(),KM))).default;break;case"ssa":case"ass":i=(await Promise.resolve().then(()=>(t$(),e$))).default;break;default:i=(await Promise.resolve().then(function(){return uz})).default}else i=n;let r,s=t.getReader(),o=i(),a=!!e?.strict||!!e?.errors;await o.init({strict:!1,...e,errors:a,type:n,cancel(){s.cancel(),r=o.done(!0)}});let l=1;for(;;){let{value:c,done:u}=await s.read();if(u){o.parse("",l),r=o.done(!1);break}o.parse(c,l),l++}return r}async function l$(t,e){let n=await t;if(!n.ok||!n.body)return{metadata:{},cues:[],regions:[],errors:[void 0]};let i=n.headers.get("content-type")||"",r=i.match(/text\/(.*?)(?:;|$)/)?.[1],s=i.match(/charset=(.*?)(?:;|$)/)?.[1];return jb(n.body,{type:r,encoding:s,...e})}async function jb(t,{encoding:e="utf-8",...n}={}){let i=t.pipeThrough(new zb(e));return Xf(i,n)}function Y5(t){let e=parseInt(t,10);return Number.isNaN(e)?null:e}function $u(t){let e=parseInt(t.replace(G5,""),10);return!Number.isNaN(e)&&e>=0&&e<=100?e:null}function i$(t){if(!t.includes(n$))return null;let[e,n]=t.split(n$).map($u);return e!==null&&n!==null?[e,n]:null}function Q5(t){let e=parseFloat(t);return Number.isNaN(e)?null:e}function Ir(t){let e=t.match(lz);if(!e)return null;let n=e[1]?parseInt(e[1],10):0,i=parseInt(e[2],10),r=parseInt(e[3],10),s=e[4]?parseInt(e[4].padEnd(3,"0"),10):0,o=n*3600+i*60+r+s/1e3;return n<0||i<0||r<0||s<0||i>59||r>59?null:o}function cz(){return new sl}function Hb(t){let e="",n=1,i=[],r=[],s;for(let c=0;c":o(),n=1;break;default:!e&&dz.test(u)&&(n=6),e+=u;break}break;case 3:switch(u){case" ":case" ":case` `:a(),s&&s.class?.trim(),n=4;break;case".":a();break;case">":a(),s&&s.class?.trim(),n=1;break;default:e+=u}break;case 4:u===">"?(e=e.replace(pz," "),s?.type==="v"?s.voice=Vb(e):s?.type==="lang"&&(s.lang=Vb(e)),e="",n=1):e+=u;break;case 5:u===">"&&(e="",s=r.pop(),n=1);break;case 6:if(u===">"){let d=Ir(e);d!==null&&d>=t.startTime&&d<=t.endTime&&(e="timestamp",o(),s.time=d),e="",n=1}else e+=u;break}}function o(){if(gz.has(e)){let c=s;s=yz(e),c?(r[r.length-1]!==c&&r.push(c),c.children.push(s)):i.push(s)}e="",n=1}function a(){if(s&&e){let c=e.replace("bg_","");mz.has(c)?s[e.startsWith("bg_")?"bgColor":"color"]=c:s.class=s.class?s.class+" "+e:e}e=""}function l(){if(!e)return;let c={type:"text",data:Vb(e)};s?s.children.push(c):i.push(c),e=""}return n===1&&l(),i}function yz(t){return{tagName:c$[t],type:t,children:[]}}function Vb(t){return t.replace(fz,e=>hz[e]||"'")}function ln(t,e,n){t.style.setProperty(`--${e}`,n+"")}function xs(t,e,n=!0){t.setAttribute(`data-${e}`,n===!0?"":n+"")}function Gf(t,e){t.setAttribute("data-part",e)}function vz(t){return parseFloat(getComputedStyle(t).lineHeight)||0}function u$(t){if(Bb)throw Error("[media-captions] called `createVTTCueTemplate` on the server - use `renderVTTCueString`");let e=document.createElement("template");return e.innerHTML=Zf(t),{cue:t,content:e.content}}function Zf(t,e=0){return Jf(Hb(t),e)}function Jf(t,e=0){let n,i="";for(let r of t)if(r.type==="text")i+=r.data;else{let s=r.type==="timestamp";n={},n.class=r.class,n.title=r.type==="v"&&r.voice,n.lang=r.type==="lang"&&r.lang,n["data-part"]=r.type==="v"&&"voice",s&&(n["data-part"]="timed",n["data-time"]=r.time,n["data-future"]=r.time>e,n["data-past"]=r.timea[1]).map(a=>`${a[0]}="${a[1]===!0?"":a[1]}"`).join(" ");i+=`<${r.tagName}${o?" "+o:""}>${Jf(r.children)}`}return i}function qb(t,e){if(!Bb)for(let n of t.querySelectorAll('[data-part="timed"]')){let i=Number(n.getAttribute("data-time"));Number.isNaN(i)||(i>e?xs(n,"future"):n.removeAttribute("data-future"),i=e.left&&t.top<=e.bottom&&t.bottom>=e.top}function bz(t,e){for(let n=0;n=0&&e.bottom<=t.height&&e.left>=0&&e.right<=t.width}function xz(t,e,n){switch(n){case"+x":return e.left<0;case"-x":return e.right>t.width;case"+y":return e.top<0;case"-y":return e.bottom>t.height}}function kz(t,e){let n=Math.max(0,Math.min(t.width,e.right)-Math.max(0,e.left)),i=Math.max(0,Math.min(t.height,e.bottom)-Math.max(0,e.top));return n*i/(t.height*t.width)}function Kb(t,e){return{top:e.top/t.height,left:e.left/t.width,right:(t.width-e.right)/t.width,bottom:(t.height-e.bottom)/t.height}}function d$(t,e){return e.top=e.top*t.height,e.left=e.left*t.width,e.right=t.width-e.right*t.width,e.bottom=t.height-e.bottom*t.height,e}function h$(t,e,n,i){let r=Kb(e,n);for(let s of p$)ln(t,`${i}-${s}`,r[s]*100+"%")}function f$(t,e,n,i){let r=1,s,o={...e};for(let a=0;al&&(s={...e},r=l),e={...o}}return s||o}function Tz(t,e,n,i){let r=n.firstElementChild,s=Pz(e),o,a=[];if(n[ks]||(n[ks]=Ez(t,n)),o=d$(t,{...n[ks]}),n[Ru])a=[n[Ru]==="top"?"+y":"-y","+x","-x"];else if(e.snapToLines){let l;switch(e.vertical){case"":a=["+y","-y"],l="height";break;case"rl":a=["+x","-x"],l="width";break;case"lr":a=["-x","+x"],l="width";break}let c=vz(r),u=c*Math.round(s),d=t[l]+c,p=a[0];Math.abs(u)>d&&(u=u<0?-1:1,u*=Math.ceil(d/c)*c),s<0&&(u+=e.vertical===""?t.height:t.width,a=a.reverse()),Yf(o,p,u)}else{let l=e.vertical==="",c=l?"+y":"+x",u=l?o.height:o.width;Yf(o,c,(l?t.height:t.width)*s/100),Yf(o,c,e.lineAlign==="center"?u/2:e.lineAlign==="end"?u:0),a=l?["-y","+y","-x","+x"]:["-x","+x","-y","+y"]}return o=f$(t,o,i,a),h$(n,t,o,"cue"),o}function Ez(t,e){let n=Wb(e),i=Sz(e);if(e[Ru]=!1,i.top&&(n.top=i.top,n.bottom=i.top+n.height,e[Ru]="top"),i.bottom){let r=t.height-i.bottom;n.top=r-n.height,n.bottom=r,e[Ru]="bottom"}return i.left&&(n.left=i.left),i.right&&(n.right=t.width-i.right),Kb(t,n)}function Sz(t){let e={};for(let n of p$)e[n]=parseFloat(t.style.getPropertyValue(`--cue-${n}`));return e}function Pz(t){return t.line==="auto"?t.snapToLines?-1:100:t.line}function Cz(t){if(t.position==="auto")switch(t.align){case"start":case"left":return 0;case"right":case"end":return 100;default:return 50}return t.position}function Mz(t,e){if(t.positionAlign==="auto")switch(t.align){case"start":return e==="ltr"?"line-left":"line-right";case"end":return e==="ltr"?"line-right":"line-left";case"center":return"center";default:return`line-${t.align}`}return t.positionAlign}function Rz(t,e,n,i){let r=Array.from(n.querySelectorAll('[data-part="cue-display"]')),s=0,o=Math.max(0,r.length-e.lines);for(let l=r.length-1;l>=o;l--)s+=r[l].offsetHeight;ln(n,"region-height",s+"px"),n[ks]||(n[ks]=Kb(t,Wb(n)));let a={...n[ks]};return a=d$(t,a),a.width=n.clientWidth,a.height=s,a.right=a.left+a.width,a.bottom=a.top+s,a=f$(t,a,i,$z),h$(n,t,a,"region"),a}var ui,Tn,o$,zb,Ub,Iu,Bb,K5,Rr,Lu,n$,G5,X5,r$,Z5,ol,J5,ez,tz,nz,Mu,iz,rz,sz,oz,az,lz,rl,sl,uz,dz,pz,c$,hz,fz,mz,gz,ks,p$,Ru,$z,Qf,Cu=at(()=>{"use strict";ui={LoadFail:0,BadSignature:1,BadTimestamp:2,BadSettingValue:3,BadFormat:4,UnknownSetting:5},Tn=class extends Error{constructor(n){super(n.reason);E(this,"code");E(this,"line");this.code=n.code,this.line=n.line}},o$=/\r?\n|\r/gm,zb=class{constructor(e){E(this,"writable");E(this,"readable");let n=new Ub(e);this.writable=new WritableStream({write(i){n.transform(i)},close(){n.close()}}),this.readable=new ReadableStream({start(i){n.onLine=r=>i.enqueue(r),n.onClose=()=>i.close()}})}},Ub=class{constructor(e){E(this,"x","");E(this,"y");E(this,"onLine");E(this,"onClose");this.y=new TextDecoder(e)}transform(e){this.x+=this.y.decode(e,{stream:!0});let n=this.x.split(o$);this.x=n.pop()||"";for(let i=0;i"u",K5=Bb?Iu:window.VTTCue,Rr=class extends K5{constructor(){super(...arguments);E(this,"region",null);E(this,"vertical","");E(this,"snapToLines",!0);E(this,"line","auto");E(this,"lineAlign","start");E(this,"position","auto");E(this,"positionAlign","auto");E(this,"size",100);E(this,"align","center");E(this,"style")}},Lu=class{constructor(){E(this,"id","");E(this,"width",100);E(this,"lines",3);E(this,"regionAnchorX",0);E(this,"regionAnchorY",100);E(this,"viewportAnchorX",0);E(this,"viewportAnchorY",100);E(this,"scroll","")}},n$=",",G5="%";X5="WEBVTT",r$=",",Z5="%",ol=/[:=]/,J5=/^[\s\t]*(region|vertical|line|position|size|align)[:=]/,ez="NOTE",tz="REGION",nz=/^REGION:?[\s\t]+/,Mu=/[\s\t]+/,iz="-->",rz=/[\s\t]*-->[\s\t]+/,sz=/start|center|end|left|right/,oz=/start|center|end/,az=/line-(?:left|right)|center|auto/,lz=/^(?:(\d{1,2}):)?(\d{2}):(\d{2})(?:\.(\d{1,3}))?$/,rl=(t=>(t[t.None=0]="None",t[t.Header=1]="Header",t[t.Cue=2]="Cue",t[t.Region=3]="Region",t[t.Note=4]="Note",t))(rl||{}),sl=class{constructor(){E(this,"f");E(this,"c",0);E(this,"g",{});E(this,"h",{});E(this,"j",[]);E(this,"a",null);E(this,"b",null);E(this,"k",[]);E(this,"d");E(this,"l","")}async init(e){this.f=e,e.strict&&(this.c=1),e.errors&&(this.d=(await Promise.resolve().then(()=>(Db(),Ab))).ParseErrorBuilder)}parse(e,n){if(e==="")this.a?(this.j.push(this.a),this.f.onCue?.(this.a),this.a=null):this.b?(this.h[this.b.id]=this.b,this.f.onRegion?.(this.b),this.b=null):this.c===1&&(this.i(e,n),this.f.onHeaderMetadata?.(this.g)),this.c=0;else if(this.c)switch(this.c){case 1:this.i(e,n);break;case 2:if(this.a){let i=this.a.text.length>0;!i&&J5.test(e)?this.m(e.split(Mu),n):this.a.text+=(i?` `:"")+e}break;case 3:this.n(e.split(Mu),n);break}else if(e.startsWith(ez))this.c=4;else if(e.startsWith(tz))this.c=3,this.b=new Lu,this.n(e.replace(nz,"").split(Mu),n);else if(e.includes(iz)){let i=this.o(e,n);i&&(this.a=new Rr(i[0],i[1],""),this.a.id=this.l,this.m(i[2],n)),this.c=2}else n===1&&this.i(e,n);this.l=e}done(){return{metadata:this.g,cues:this.j,regions:Object.values(this.h),errors:this.k}}i(e,n){if(n>1){if(ol.test(e)){let[i,r]=e.split(ol);i&&(this.g[i]=(r||"").replace(Mu,""))}}else e.startsWith(X5)?this.c=1:this.e(this.d?.p())}o(e,n){let[i,r=""]=e.split(rz),[s,...o]=r.split(Mu),a=Ir(i),l=Ir(s);if(a!==null&&l!==null&&l>a)return[a,l,o];a===null&&this.e(this.d?.q(i,n)),l===null&&this.e(this.d?.r(s,n)),a!=null&&l!==null&&l>a&&this.e(this.d?.s(a,l,n))}n(e,n){let i;for(let r=0;r",""":'"',"'":"'"," ":"\xA0","‎":"\u200E","‏":"\u200F"},fz=/&(?:amp|lt|gt|quot|#(0+)?39|nbsp|lrm|rlm);/g,mz=new Set(["white","lime","cyan","red","yellow","magenta","blue","black"]),gz=new Set(Object.keys(c$));ks=Symbol(0);p$=["top","left","right","bottom"];Ru=Symbol(0);$z=["-y","+y","-x","+x"];Qf=class{constructor(e,n){E(this,"overlay");E(this,"z");E(this,"A",0);E(this,"C","ltr");E(this,"B",[]);E(this,"D",!1);E(this,"E");E(this,"h",new Map);E(this,"j",new Map);E(this,"K",wz(()=>{this.D=!1,this.G();for(let e of this.h.values())e[ks]=null;for(let e of this.j.values())e&&(e[ks]=null);this.H(!0)},50));this.overlay=e,this.dir=n?.dir??"ltr",e.setAttribute("translate","yes"),e.setAttribute("aria-live","off"),e.setAttribute("aria-atomic","true"),Gf(e,"captions"),this.G(),this.E=new ResizeObserver(this.I.bind(this)),this.E.observe(e)}get dir(){return this.C}set dir(e){this.C=e,xs(this.overlay,"dir",e)}get currentTime(){return this.A}set currentTime(e){this.A=e,this.update()}changeTrack({regions:e,cues:n}){this.reset(),this.J(e);for(let i of n)this.j.set(i,null);this.update()}addCue(e){this.j.set(e,null),this.update()}removeCue(e){this.j.delete(e),this.update()}update(e=!1){this.H(e)}reset(){this.j.clear(),this.h.clear(),this.B=[],this.overlay.textContent=""}destroy(){this.reset(),this.E.disconnect()}I(){this.D=!0,this.K()}G(){this.z=Wb(this.overlay),ln(this.overlay,"overlay-width",this.z.width+"px"),ln(this.overlay,"overlay-height",this.z.height+"px")}H(e=!1){if(!this.j.size||this.D)return;let n,i=[...this.j.keys()].filter(s=>this.A>=s.startTime&&this.A<=s.endTime).sort((s,o)=>s.startTime!==o.startTime?s.startTime-o.startTime:s.endTime-o.endTime),r=i.map(s=>s.region);for(let s=0;sxs(a,"active")),e=!0),o.isConnected||((a||this.overlay).append(o),e=!0)}if(e){let s=[],o=new Set;for(let a=i.length-1;a>=0;a--){if(n=i[a],o.has(n.region||n))continue;let l=this.F(n),c=l?this.h.get(n.region.id):this.j.get(n);l?s.push(Rz(this.z,n.region,c,s)):s.push(Tz(this.z,n,c,s)),o.add(l?n.region:n)}}qb(this.overlay,this.A),this.B=i}J(e){if(e)for(let n of e){let i=this.M(n);this.h.set(n.id,i),this.overlay.append(i)}}M(e){let n=document.createElement("div");return Gf(n,"region"),xs(n,"id",e.id),xs(n,"scroll",e.scroll),ln(n,"region-width",e.width+"%"),ln(n,"region-anchor-x",e.regionAnchorX),ln(n,"region-anchor-y",e.regionAnchorY),ln(n,"region-viewport-anchor-x",e.viewportAnchorX),ln(n,"region-viewport-anchor-y",e.viewportAnchorY),ln(n,"region-lines",e.lines),n}L(e){let n=document.createElement("div"),i=Cz(e),r=Mz(e,this.C);if(Gf(n,"cue-display"),e.vertical!==""&&xs(n,"vertical"),ln(n,"cue-text-align",e.align),e.style)for(let o of Object.keys(e.style))n.style.setProperty(o,e.style[o]);if(this.F(e))ln(n,"cue-offset",`${i-(r==="line-right"?100:r==="center"?50:0)}%`);else if(ln(n,"cue-writing-mode",e.vertical===""?"horizontal-tb":e.vertical==="lr"?"vertical-lr":"vertical-rl"),!e.style?.["--cue-width"]){let o=i;r==="line-left"?o=100-i:r==="center"&&i<=50?o=i*2:r==="center"&&i>50&&(o=(100-i)*2);let a=e.sizeQf,ParseError:()=>Tn,ParseErrorCode:()=>ui,TextCue:()=>Iu,VTTCue:()=>Rr,VTTRegion:()=>Lu,createVTTCueTemplate:()=>u$,parseByteStream:()=>jb,parseResponse:()=>l$,parseText:()=>a$,parseTextStream:()=>Xf,parseVTTTimestamp:()=>Ir,renderVTTCueString:()=>Zf,renderVTTTokensString:()=>Jf,tokenizeVTTCue:()=>Hb,updateTimedVTTCueNodes:()=>qb});var Du=at(()=>{"use strict";Cu()});var tr,Nu=at(()=>{"use strict";"use client";an();tr=class{constructor(e){this._callback=e}_start(){Qe(this._id)&&this._loop()}_stop(){dt(this._id)&&window.cancelAnimationFrame(this._id),this._id=void 0}_loop(){this._id=window.requestAnimationFrame(()=>{Qe(this._id)||(this._callback(),this._loop())})}}});var Gb,Yb,al,Qb=at(()=>{"use strict";"use client";an();En();Nu();Gb=class{constructor(e,n){this._provider=e,this._ctx=n,this._disposal=$b(),this._waiting=!1,this._attachedLoadStart=!1,this._attachedCanPlay=!1,this._timeRAF=new tr(this._onAnimationFrame.bind(this)),this._handlers=void 0,this._handleDevEvent=void 0,this._attachInitialListeners(),S(this._attachTimeUpdate.bind(this)),ae(this._onDispose.bind(this))}get _media(){return this._provider.media}get _notify(){return this._ctx.delegate._notify}_onDispose(){this._attachedLoadStart=!1,this._attachedCanPlay=!1,this._timeRAF._stop(),this._disposal.empty()}_onAnimationFrame(){let e=this._media.currentTime;this._ctx.$state.realCurrentTime()!==e&&this._updateCurrentTime(e)}_attachInitialListeners(){this._attachEventListener("loadstart",this._onLoadStart),this._attachEventListener("abort",this._onAbort),this._attachEventListener("emptied",this._onEmptied),this._attachEventListener("error",this._onError),this._attachEventListener("volumechange",this._onVolumeChange)}_attachLoadStartListeners(){this._attachedLoadStart||(this._disposal.add(this._attachEventListener("loadeddata",this._onLoadedData),this._attachEventListener("loadedmetadata",this._onLoadedMetadata),this._attachEventListener("canplay",this._onCanPlay),this._attachEventListener("canplaythrough",this._onCanPlayThrough),this._attachEventListener("durationchange",this._onDurationChange),this._attachEventListener("play",this._onPlay),this._attachEventListener("progress",this._onProgress),this._attachEventListener("stalled",this._onStalled),this._attachEventListener("suspend",this._onSuspend)),this._attachedLoadStart=!0)}_attachCanPlayListeners(){this._attachedCanPlay||(this._disposal.add(this._attachEventListener("pause",this._onPause),this._attachEventListener("playing",this._onPlaying),this._attachEventListener("ratechange",this._onRateChange),this._attachEventListener("seeked",this._onSeeked),this._attachEventListener("seeking",this._onSeeking),this._attachEventListener("ended",this._onEnded),this._attachEventListener("waiting",this._onWaiting)),this._attachedCanPlay=!0)}_attachEventListener(e,n){return L(this._media,e,n.bind(this))}_onDevEvent(e){}_updateCurrentTime(e,n){let i={currentTime:Math.min(e,this._ctx.$state.seekableEnd()),played:this._media.played};this._notify("time-update",i,n)}_onLoadStart(e){if(this._media.networkState===3){this._onAbort(e);return}this._attachLoadStartListeners(),this._notify("load-start",void 0,e)}_onAbort(e){this._notify("abort",void 0,e)}_onEmptied(){this._notify("emptied",void 0,event)}_onLoadedData(e){this._notify("loaded-data",void 0,e)}_onLoadedMetadata(e){this._attachCanPlayListeners(),this._notify("loaded-metadata",void 0,e),Xb&&yo(this._ctx.$state.source())&&this._ctx.delegate._ready(this._getCanPlayDetail(),e)}_getCanPlayDetail(){return{provider:N(this._ctx.$provider),duration:this._media.duration,buffered:this._media.buffered,seekable:this._media.seekable}}_onPlay(e){this._ctx.$state.canPlay&&this._notify("play",void 0,e)}_onPause(e){this._media.readyState===1&&!this._waiting||(this._waiting=!1,this._timeRAF._stop(),this._notify("pause",void 0,e))}_onCanPlay(e){this._ctx.delegate._ready(this._getCanPlayDetail(),e)}_onCanPlayThrough(e){this._ctx.$state.started()||this._notify("can-play-through",this._getCanPlayDetail(),e)}_onPlaying(e){this._waiting=!1,this._notify("playing",void 0,e),this._timeRAF._start()}_onStalled(e){this._notify("stalled",void 0,e),this._media.readyState<3&&(this._waiting=!0,this._notify("waiting",void 0,e))}_onWaiting(e){this._media.readyState<3&&(this._waiting=!0,this._notify("waiting",void 0,e))}_onEnded(e){this._timeRAF._stop(),this._updateCurrentTime(this._media.duration,e),this._notify("end",void 0,e),this._ctx.$state.loop()&&kb(this._media.controls)&&(this._media.controls=!1)}_attachTimeUpdate(){this._ctx.$state.paused()&&L(this._media,"timeupdate",this._onTimeUpdate.bind(this))}_onTimeUpdate(e){this._updateCurrentTime(this._media.currentTime,e)}_onDurationChange(e){this._ctx.$state.ended()&&this._updateCurrentTime(this._media.duration,e),this._notify("duration-change",this._media.duration,e)}_onVolumeChange(e){let n={volume:this._media.volume,muted:this._media.muted};this._notify("volume-change",n,e)}_onSeeked(e){this._updateCurrentTime(this._media.currentTime,e),this._notify("seeked",this._media.currentTime,e),Math.trunc(this._media.currentTime)===Math.trunc(this._media.duration)&&em(this._media.duration)>em(this._media.currentTime)&&(this._updateCurrentTime(this._media.duration,e),this._media.ended||this._ctx.player.dispatch(new ne("media-play-request",{trigger:e})))}_onSeeking(e){this._notify("seeking",this._media.currentTime,e)}_onProgress(e){let n={buffered:this._media.buffered,seekable:this._media.seekable};this._notify("progress",n,e)}_onSuspend(e){this._notify("suspend",void 0,e)}_onRateChange(e){this._notify("rate-change",this._media.playbackRate,e)}_onError(e){let n=this._media.error;if(!n)return;let i={message:n.message,code:n.code,mediaError:n};this._notify("error",i,e)}},Yb=class{constructor(e,n){this._provider=e,this._ctx=n,this._nativeTracks.onaddtrack=this._onAddNativeTrack.bind(this),this._nativeTracks.onremovetrack=this._onRemoveNativeTrack.bind(this),this._nativeTracks.onchange=this._onChangeNativeTrack.bind(this),L(this._ctx.audioTracks,"change",this._onChangeTrack.bind(this))}get _nativeTracks(){return this._provider.media.audioTracks}_onAddNativeTrack(e){let n=e.track;if(n.label==="")return;let i={id:n.id.toString(),label:n.label,language:n.language,kind:n.kind,selected:!1};this._ctx.audioTracks[le._add](i,e),n.enabled&&(i.selected=!0)}_onRemoveNativeTrack(e){let n=this._ctx.audioTracks.getById(e.track.id);n&&this._ctx.audioTracks[le._remove](n,e)}_onChangeNativeTrack(e){let n=this._getEnabledNativeTrack();if(!n)return;let i=this._ctx.audioTracks.getById(n.id);i&&this._ctx.audioTracks[le._select](i,!0,e)}_getEnabledNativeTrack(){return Array.from(this._nativeTracks).find(e=>e.enabled)}_onChangeTrack(e){let{current:n}=e.detail;if(!n)return;let i=this._nativeTracks.getTrackById(n.id);if(i){let r=this._getEnabledNativeTrack();r&&(r.enabled=!1),i.enabled=!0}}},al=class{constructor(e,n){this._media=e,this._ctx=n,this.scope=rn(),this._currentSrc=null}setup(){new Gb(this,this._ctx),"audioTracks"in this.media&&new Yb(this,this._ctx),ae(()=>{this._media.setAttribute("src",""),this._media.load()})}get type(){return""}get media(){return this._media}get currentSrc(){return this._currentSrc}setPlaybackRate(e){this._media.playbackRate=e}async play(){return this._media.play()}async pause(){return this._media.pause()}setMuted(e){this._media.muted=e}setVolume(e){this._media.volume=e}setCurrentTime(e){this._media.currentTime=e}setPlaysInline(e){pe(this._media,"playsinline",e)}async loadSource({src:e,type:n},i){this._media.preload=i||"",Zb(e)?this._media.srcObject=e:(this._media.srcObject=null,this._media.src=Z(e)?this._appendMediaFragment(e):window.URL.createObjectURL(e)),this._media.load(),this._currentSrc={src:e,type:n}}_appendMediaFragment(e){let{clipStartTime:n,clipEndTime:i}=this._ctx.$state,r=n(),s=i();return r>0&&s>0?`${e}#t=${r},${s}`:r>0?`${e}#t=${r}`:s>0?`${e}#t=0,${s}`:e}}});var m$={};zt(m$,{AudioProvider:()=>Jb});var FG,Jb,g$=at(()=>{"use strict";"use client";Qb();FG=A(X(),1),Jb=class extends al{constructor(){super(...arguments),this.$$PROVIDER_TYPE="AUDIO"}get type(){return"audio"}setup(){super.setup(),this.type==="audio"&&this._ctx.delegate._notify("provider-setup",this)}get audio(){return this._media}}});var y$={};zt(y$,{VideoProvider:()=>Ou});function Iz(t,e){return Array.from(t.children).find(n=>n.track===e)}var jG,ex,tx,nx,ix,rx,sx,ox,Ou,ax=at(()=>{"use strict";"use client";an();En();Qb();jG=A(X(),1),ex=class{constructor(e,n){this._video=e,this._ctx=n,e.textTracks.onaddtrack=this._onAddTrack.bind(this),ae(this._onDispose.bind(this))}_onAddTrack(e){let n=e.track;if(!n||Iz(this._video,n))return;let i=new zn({id:n.id,kind:n.kind,label:n.label,language:n.language,type:"vtt"});i[se._native]={track:n},i[se._readyState]=2,i[se._nativeHLS]=!0;let r=0,s=o=>{if(n.cues)for(let a=r;a{this._media.delegate._notify("picture-in-picture-change",i,r)},L(this._video,"enterpictureinpicture",this._onEnter.bind(this)),L(this._video,"leavepictureinpicture",this._onExit.bind(this))}get active(){return document.pictureInPictureElement===this._video}get supported(){return nm(this._video)}async enter(){return this._video.requestPictureInPicture()}exit(){return document.exitPictureInPicture()}_onEnter(e){this._onChange(!0,e)}_onExit(e){this._onChange(!1,e)}},nx=class{constructor(e,n){this._video=e,this._media=n,this._mode="inline",L(this._video,"webkitpresentationmodechanged",this._onModeChange.bind(this))}get _supported(){return im(this._video)}async _setPresentationMode(e){this._mode!==e&&this._video.webkitSetPresentationMode(e)}_onModeChange(e){let n=this._mode;this._mode=this._video.webkitPresentationMode,this._media.player?.dispatch(new ne("video-presentation-change",{detail:this._mode,trigger:e})),["fullscreen","picture-in-picture"].forEach(i=>{(this._mode===i||n===i)&&this._media.delegate._notify(`${i}-change`,this._mode===i,e)})}},ix=class{constructor(e){this._presentation=e}get active(){return this._presentation._mode==="fullscreen"}get supported(){return this._presentation._supported}async enter(){this._presentation._setPresentationMode("fullscreen")}async exit(){this._presentation._setPresentationMode("inline")}},rx=class{constructor(e){this._presentation=e}get active(){return this._presentation._mode==="picture-in-picture"}get supported(){return this._presentation._supported}async enter(){this._presentation._setPresentationMode("picture-in-picture")}async exit(){this._presentation._setPresentationMode("inline")}},sx=class{constructor(e,n){this._video=e,this._ctx=n,this._supported=K(!1),this._setup()}get supported(){return this._supported()}_setup(){B||!this._video.remote||!this._canPrompt||(this._video.remote.watchAvailability(e=>{this._supported.set(e)}).catch(()=>{this._supported.set(!1)}),S(this._watchSupported.bind(this)))}_watchSupported(){if(!this._supported())return;let e=["connecting","connect","disconnect"],n=this._onStateChange.bind(this);n(),L(this._video,"playing",n);for(let i of e)L(this._video.remote,i,n)}async prompt(){if(!this.supported)throw Error("Not supported on this platform.");return this._video.remote.prompt()}_onStateChange(e){let n=this._video.remote.state;if(n===this._state)return;let i={type:this._type,state:n};this._ctx.delegate._notify("remote-playback-change",i,e),this._state=n}},ox=class extends sx{constructor(){super(...arguments),this._type="airplay"}get _canPrompt(){return"WebKitPlaybackTargetAvailabilityEvent"in window}},Ou=class extends al{constructor(e,n){super(e,n),this.$$PROVIDER_TYPE="VIDEO",Ct(()=>{if(this.airPlay=new ox(e,n),im(e)){let i=new nx(e,n);this.fullscreen=new ix(i),this.pictureInPicture=new rx(i)}else nm(e)&&(this.pictureInPicture=new tx(e,n))},this.scope)}get type(){return"video"}setup(){super.setup(),tm(this.video)&&new ex(this.video,this._ctx),this._ctx.textRenderers._attachVideo(this.video),ae(()=>{this._ctx.textRenderers._attachVideo(null)}),this.type==="video"&&this._ctx.delegate._notify("provider-setup",this)}get video(){return this._media}}});var v$={};zt(v$,{HLSProvider:()=>rm});async function Az(t,e={}){if(!Qe(t)){if(e.onLoadStart?.(),t.prototype&&t.prototype!==Function)return e.onLoaded?.(t),t;try{let n=(await t())?.default;if(n&&n.isSupported)e.onLoaded?.(n);else throw Error("");return n}catch(n){e.onLoadError?.(n)}}}async function Dz(t,e={}){if(Z(t)){e.onLoadStart?.();try{if(await om(t),!Wt(window.Hls))throw Error("");let n=window.Hls;return e.onLoaded?.(n),n}catch(n){e.onLoadError?.(n)}}}var KG,Lz,lx,cx,Nz,rm,w$=at(()=>{"use strict";"use client";an();En();ax();Nu();KG=A(X(),1),Lz=t=>nl(t),lx=class{constructor(e,n){this._video=e,this._ctx=n,this._instance=null,this._stopLiveSync=null,this._config={},this._callbacks=new Set,this._retryLoadingTimer=-1}get instance(){return this._instance}setup(e){let{streamType:n}=this._ctx.$state,i=N(n).includes("live"),r=N(n).includes("ll-");this._instance=new e({lowLatencyMode:r,backBufferLength:r?4:i?8:void 0,renderTextTracksNatively:!1,...this._config});let s=this._dispatchHLSEvent.bind(this);for(let o of Object.values(e.Events))this._instance.on(o,s);this._instance.on(e.Events.ERROR,this._onError.bind(this));for(let o of this._callbacks)o(this._instance);this._ctx.player.dispatch("hls-instance",{detail:this._instance}),this._instance.attachMedia(this._video),this._instance.on(e.Events.FRAG_LOADING,this._onFragLoading.bind(this)),this._instance.on(e.Events.AUDIO_TRACK_SWITCHED,this._onAudioSwitch.bind(this)),this._instance.on(e.Events.LEVEL_SWITCHED,this._onLevelSwitched.bind(this)),this._instance.on(e.Events.LEVEL_LOADED,this._onLevelLoaded.bind(this)),this._instance.on(e.Events.NON_NATIVE_TEXT_TRACKS_FOUND,this._onTracksFound.bind(this)),this._instance.on(e.Events.CUES_PARSED,this._onCuesParsed.bind(this)),this._ctx.qualities[Un._enableAuto]=this._enableAutoQuality.bind(this),L(this._ctx.qualities,"change",this._onQualityChange.bind(this)),L(this._ctx.audioTracks,"change",this._onAudioChange.bind(this)),this._stopLiveSync=S(this._liveSync.bind(this))}_liveSync(){if(!this._ctx.$state.live())return;let e=new tr(this._liveSyncPosition.bind(this));return e._start(),e._stop.bind(e)}_liveSyncPosition(){this._ctx.$state.liveSyncPosition.set(this._instance?.liveSyncPosition??1/0)}_dispatchHLSEvent(e,n){this._ctx.player?.dispatch(new ne(Lz(e),{detail:n}))}_onTracksFound(e,n){let i=new ne(e,{detail:n}),r=-1;for(let s=0;s{l.mode==="showing"?(this._instance.subtitleTrack=s,r=s):r===s&&(this._instance.subtitleTrack=-1,r=-1)},this._ctx.textTracks.add(l,i)}}_onCuesParsed(e,n){let i=this._ctx.textTracks.getById(`hls-${n.track}`);if(!i)return;let r=new ne(e,{detail:n});for(let s of n.cues)s.positionAlign="auto",i.addCue(s,r)}_onAudioSwitch(e,n){let i=this._ctx.audioTracks[n.id];if(i){let r=new ne(e,{detail:n});this._ctx.audioTracks[le._select](i,!0,r)}}_onLevelSwitched(e,n){let i=this._ctx.qualities[n.level];if(i){let r=new ne(e,{detail:n});this._ctx.qualities[le._select](i,!0,r)}}_onLevelLoaded(e,n){if(this._ctx.$state.canPlay())return;let{type:i,live:r,totalduration:s,targetduration:o}=n.details,a=new ne(e,{detail:n});this._ctx.delegate._notify("stream-type-change",r?i==="EVENT"&&Number.isFinite(s)&&o>=10?"live:dvr":"live":"on-demand",a),this._ctx.delegate._notify("duration-change",s,a);let l=this._instance.media;this._instance.currentLevel===-1&&this._ctx.qualities[Un._setAuto](!0,a);for(let c of this._instance.audioTracks){let u={id:c.id.toString(),label:c.name,language:c.lang||"",kind:"main"};this._ctx.audioTracks[le._add](u,a)}for(let c of this._instance.levels){let u={id:c.id?.toString()??c.height+"p",width:c.width,height:c.height,codec:c.codecSet,bitrate:c.bitrate};this._ctx.qualities[le._add](u,a)}l.dispatchEvent(new ne("canplay",{trigger:a}))}_onError(e,n){if(n.fatal)switch(n.type){case"networkError":this._onNetworkError(n.error);break;case"mediaError":this._instance?.recoverMediaError();break;default:this._onFatalError(n.error);break}}_onFragLoading(){this._retryLoadingTimer>=0&&this._clearRetryTimer()}_onNetworkError(e){this._clearRetryTimer(),this._instance?.startLoad(),this._retryLoadingTimer=window.setTimeout(()=>{this._retryLoadingTimer=-1,this._onFatalError(e)},5e3)}_clearRetryTimer(){clearTimeout(this._retryLoadingTimer),this._retryLoadingTimer=-1}_onFatalError(e){this._instance?.destroy(),this._instance=null,this._ctx.delegate._notify("error",{message:e.message,code:1,error:e})}_enableAutoQuality(){this._instance&&(this._instance.currentLevel=-1)}_onQualityChange(){let{qualities:e}=this._ctx;!this._instance||e.auto||(this._instance[e.switch+"Level"]=e.selectedIndex,Fu&&(this._video.currentTime=this._video.currentTime))}_onAudioChange(){let{audioTracks:e}=this._ctx;this._instance&&this._instance.audioTrack!==e.selectedIndex&&(this._instance.audioTrack=e.selectedIndex)}_loadSource(e){Z(e.src)&&(this._clearRetryTimer(),this._instance?.loadSource(e.src))}_destroy(){this._clearRetryTimer(),this._ctx&&(this._ctx.qualities[Un._enableAuto]=void 0),this._instance?.destroy(),this._instance=null,this._stopLiveSync?.(),this._stopLiveSync=null}},cx=class{constructor(e,n,i){this._lib=e,this._ctx=n,this._callback=i,this._startLoading()}async _startLoading(){let e={onLoadStart:this._onLoadStart.bind(this),onLoaded:this._onLoaded.bind(this),onLoadError:this._onLoadError.bind(this)},n=await Dz(this._lib,e);if(Qe(n)&&!Z(this._lib)&&(n=await Az(this._lib,e)),!n)return null;if(!n.isSupported()){let i="[vidstack] `hls.js` is not supported in this environment";return this._ctx.player.dispatch(new ne("hls-unsupported")),this._ctx.delegate._notify("error",{message:i,code:4}),null}return n}_onLoadStart(){this._ctx.player.dispatch(new ne("hls-lib-load-start"))}_onLoaded(e){this._ctx.player.dispatch(new ne("hls-lib-loaded",{detail:e})),this._callback(e)}_onLoadError(e){let n=nr(e);this._ctx.player.dispatch(new ne("hls-lib-load-error",{detail:n})),this._ctx.delegate._notify("error",{message:n.message,code:4,error:n})}};Nz="https://cdn.jsdelivr.net",rm=class extends Ou{constructor(){super(...arguments),this.$$PROVIDER_TYPE="HLS",this._ctor=null,this._controller=new lx(this.video,this._ctx),this._library=`${Nz}/npm/hls.js@^1.5.0/dist/hls.min.js`}get ctor(){return this._ctor}get instance(){return this._controller.instance}get type(){return"hls"}get canLiveSync(){return!0}get config(){return this._controller._config}set config(e){this._controller._config=e}get library(){return this._library}set library(e){this._library=e}preconnect(){Z(this._library)&&Ai(this._library)}setup(){super.setup(),new cx(this._library,this._ctx,e=>{this._ctor=e,this._controller.setup(e),this._ctx.delegate._notify("provider-setup",this);let n=N(this._ctx.$state.source);n&&this.loadSource(n)})}async loadSource(e,n){Z(e.src)&&(this._media.preload=n||"",this._controller._loadSource(e),this._currentSrc=e)}onInstance(e){let n=this._controller.instance;return n&&e(n),this._controller._callbacks.add(e),()=>this._controller._callbacks.delete(e)}destroy(){this._controller._destroy()}};rm.supported=sm()});function cl(t,e=3e3){let n=$r();return setTimeout(()=>{let i=t();i&&n.reject(i)},e),n}var ll,ux=at(()=>{"use strict";"use client";an();En();ll=class{constructor(e){this._iframe=e,this._src=K(""),this.referrerPolicy=null,e.setAttribute("frameBorder","0"),e.setAttribute("aria-hidden","true"),e.setAttribute("allow","autoplay; fullscreen; encrypted-media; picture-in-picture; accelerometer; gyroscope"),this.referrerPolicy!==null&&e.setAttribute("referrerpolicy",this.referrerPolicy)}get iframe(){return this._iframe}setup(){L(window,"message",this._onWindowMessage.bind(this)),L(this._iframe,"load",this._onLoad.bind(this)),S(this._watchSrc.bind(this))}_watchSrc(){let e=this._src();if(!e.length){this._iframe.setAttribute("src","");return}let n=N(()=>this._buildParams());this._iframe.setAttribute("src",_$(e,n))}_postMessage(e,n){B||this._iframe.contentWindow?.postMessage(JSON.stringify(e),n??"*")}_onWindowMessage(e){let n=this._getOrigin();if((e.source===null||e.source===this._iframe?.contentWindow)&&(!Z(n)||n===e.origin)){try{let r=JSON.parse(e.data);r&&this._onMessage(r,e);return}catch{}e.data&&this._onMessage(e.data,e)}}}});var b$={};zt(b$,{getVimeoVideoInfo:()=>hx,resolveVimeoVideoId:()=>px});function px(t){let e=t.match(Oz);return{videoId:e?.[1],hash:e?.[2]}}async function hx(t,e){if(dx.has(t))return dx.get(t);if(am.has(t))return am.get(t);let n=`https://vimeo.com/api/oembed.json?url=https://player.vimeo.com/video/${t}`,i=window.fetch(n,{mode:"cors",signal:e.signal}).then(r=>r.json()).then(r=>{let s=/vimeocdn.com\/video\/(.*)?_/,o=r?.thumbnail_url?.match(s)?.[1],a=o?`https://i.vimeocdn.com/video/${o}_1920x1080.webp`:"",l={title:r?.title??"",duration:r?.duration??0,poster:a,pro:r.account_type!=="basic"};return dx.set(t,l),l}).finally(()=>am.delete(t));return am.set(t,i),i}var Oz,dx,am,fx=at(()=>{"use strict";"use client";Oz=/(?:https:\/\/)?(?:player\.)?vimeo(?:\.com)?\/(?:video\/)?(\d+)(?:\?hash=(.*))?/,dx=new Map,am=new Map});var x$={};zt(x$,{VimeoProvider:()=>mx});var nY,Fz,mx,k$=at(()=>{"use strict";"use client";an();En();Nu();ux();fx();nY=A(X(),1),Fz=["bufferend","bufferstart","durationchange","ended","enterpictureinpicture","error","fullscreenchange","leavepictureinpicture","loaded","playProgress","loadProgress","pause","play","playbackratechange","qualitychange","seeked","seeking","timeupdate","volumechange","waiting"],mx=class extends ll{constructor(e,n){super(e),this._ctx=n,this.$$PROVIDER_TYPE="VIMEO",this.scope=rn(),this._played=0,this._playedRange=new Te(0,0),this._seekableRange=new Te(0,0),this._playPromise=null,this._pausePromise=null,this._videoInfoPromise=null,this._videoId=K(""),this._pro=K(!1),this._hash=null,this._currentSrc=null,this._currentCue=null,this._timeRAF=new tr(this._onAnimationFrame.bind(this)),this._chaptersTrack=null,this.cookies=!1,this.title=!0,this.byline=!0,this.portrait=!0,this.color="00ADEF",this._skipTimeUpdates=!1}get _notify(){return this._ctx.delegate._notify}get type(){return"vimeo"}get currentSrc(){return this._currentSrc}get videoId(){return this._videoId()}get hash(){return this._hash}get isPro(){return this._pro()}preconnect(){Ai(this._getOrigin())}setup(){super.setup(),S(this._watchVideoId.bind(this)),S(this._watchVideoInfo.bind(this)),S(this._watchPro.bind(this)),this._notify("provider-setup",this)}destroy(){this._reset(),this._remote("destroy")}async play(){let{paused:e}=this._ctx.$state;return this._playPromise||(this._playPromise=cl(()=>{if(this._playPromise=null,e())return"Timed out."}),this._remote("play")),this._playPromise.promise}async pause(){let{paused:e}=this._ctx.$state;return this._pausePromise||(this._pausePromise=cl(()=>{if(this._pausePromise=null,!e())return"Timed out."}),this._remote("pause")),this._pausePromise.promise}setMuted(e){this._remote("setMuted",e)}setCurrentTime(e){this._remote("seekTo",e),this._notify("seeking",e)}setVolume(e){this._remote("setVolume",e),this._remote("setMuted",N(this._ctx.$state.muted))}setPlaybackRate(e){this._remote("setPlaybackRate",e)}async loadSource(e){if(!Z(e.src)){this._currentSrc=null,this._hash=null,this._videoId.set("");return}let{videoId:n,hash:i}=px(e.src);this._videoId.set(n??""),this._hash=i??null,this._currentSrc=e}_watchVideoId(){this._reset();let e=this._videoId();if(!e){this._src.set("");return}this._src.set(`${this._getOrigin()}/video/${e}`),this._notify("load-start")}_watchVideoInfo(){let e=this._videoId();if(!e)return;let n=$r(),i=new AbortController;return this._videoInfoPromise=n,hx(e,i).then(r=>{n.resolve(r)}).catch(r=>{n.reject(),this._notify("error",{message:`Failed to fetch vimeo video info for id \`${e}\`.`,code:1,error:nr(r)})}),()=>{n.reject(),i.abort()}}_watchPro(){let e=this._pro(),{$state:n,qualities:i}=this._ctx;if(n.canSetPlaybackRate.set(e),i[le._setReadonly](!e),e)return L(i,"change",()=>{if(i.auto)return;let r=i.selected?.id;r&&this._remote("setQuality",r)})}_getOrigin(){return"https://player.vimeo.com"}_buildParams(){let{$iosControls:e}=this._ctx,{keyDisabled:n}=this._ctx.$props,{controls:i,playsInline:r}=this._ctx.$state,s=i()||e();return{title:this.title,byline:this.byline,color:this.color,portrait:this.portrait,controls:s,h:this.hash,keyboard:s&&!n(),transparent:!0,playsinline:r(),dnt:!this.cookies}}_onAnimationFrame(){this._remote("getCurrentTime")}_onTimeUpdate(e,n){if(this._skipTimeUpdates&&e===0)return;let{realCurrentTime:i,realDuration:r,paused:s,bufferedEnd:o}=this._ctx.$state;if(i()===e)return;let a=i(),l={currentTime:e,played:this._getPlayedRange(e)};this._notify("time-update",l,n),Math.abs(a-e)>1.5&&(this._notify("seeking",e,n),!s()&&o(){this._skipTimeUpdates=!1},500))}_getPlayedRange(e){return this._played>=e?this._playedRange:this._playedRange=new Te(0,this._played=e)}_onSeeked(e,n){this._notify("seeked",e,n)}_onReady(e){let n=this._videoId();this._videoInfoPromise?.promise.then(i=>{if(!i)return;let{title:r,poster:s,duration:o,pro:a}=i,{$iosControls:l}=this._ctx,{controls:c}=this._ctx.$state,u=c()||l();this._pro.set(a),this._seekableRange=new Te(0,o),this._notify("title-change",r,e),this._notify("poster-change",s,e),this._notify("duration-change",o,e);let d={buffered:new Te(0,0),seekable:this._seekableRange,duration:o};this._ctx.delegate._ready(d,e),u||this._remote("_hideOverlay"),this._remote("getQualities"),this._remote("getChapters")}).catch(i=>{n===this._videoId()&&this._notify("error",{message:"Failed to fetch oembed data",code:2,error:nr(i)})})}_onMethod(e,n,i){switch(e){case"getCurrentTime":this._onTimeUpdate(n,i);break;case"getBuffered":ut(n)&&n.length&&this._onLoadProgress(n[n.length-1][1],i);break;case"setMuted":this._onVolumeChange(N(this._ctx.$state.volume),n,i);break;case"getChapters":this._onChaptersChange(n);break;case"getQualities":this._onQualitiesChange(n,i);break}}_attachListeners(){for(let e of Fz)this._remote("addEventListener",e)}_onPause(e){this._timeRAF._stop(),this._notify("pause",void 0,e),this._pausePromise?.resolve(),this._pausePromise=null}_onPlay(e){this._timeRAF._start(),this._notify("play",void 0,e),this._playPromise?.resolve(),this._playPromise=null}_onPlayProgress(e){let{paused:n}=this._ctx.$state;n()||this._notify("playing",void 0,e)}_onLoadProgress(e,n){let i={buffered:new Te(0,e),seekable:this._seekableRange};this._notify("progress",i,n)}_onBufferStart(e){this._notify("waiting",void 0,e)}_onBufferEnd(e){let{paused:n}=this._ctx.$state;n()||this._notify("playing",void 0,e)}_onWaiting(e){let{paused:n}=this._ctx.$state;n()&&this._notify("play",void 0,e),this._notify("waiting",void 0,e)}_onVolumeChange(e,n,i){let r={volume:e,muted:n};this._notify("volume-change",r,i)}_onChaptersChange(e){if(this._removeChapters(),!e.length)return;let n=new zn({kind:"chapters",default:!0}),{realDuration:i}=this._ctx.$state;for(let r=0;ri.id==="auto")?()=>{this._remote("setQuality","auto")}:void 0;for(let i of e){if(i.id==="auto")continue;let r=+i.id.slice(0,-1);isNaN(r)||this._ctx.qualities[le._add]({id:i.id,width:r*(16/9),height:r,codec:"avc1,h.264",bitrate:-1},n)}this._onQualityChange(e.find(i=>i.active),n)}_onQualityChange({id:e}={},n){if(!e)return;let i=e==="auto",r=this._ctx.qualities.toArray().find(s=>s.id===e);i?(this._ctx.qualities[Un._setAuto](i,n),this._ctx.qualities[le._select](void 0,!0,n)):this._ctx.qualities[le._select](r,!0,n)}_onEvent(e,n,i){switch(e){case"ready":this._attachListeners();break;case"loaded":this._onReady(i);break;case"play":this._onPlay(i);break;case"playProgress":this._onPlayProgress(i);break;case"pause":this._onPause(i);break;case"loadProgress":this._onLoadProgress(n.seconds,i);break;case"waiting":this._onWaiting(i);break;case"bufferstart":this._onBufferStart(i);break;case"bufferend":this._onBufferEnd(i);break;case"volumechange":this._onVolumeChange(n.volume,N(this._ctx.$state.muted),i);break;case"durationchange":this._seekableRange=new Te(0,n.duration),this._notify("duration-change",n.duration,i);break;case"playbackratechange":this._notify("rate-change",n.playbackRate,i);break;case"qualitychange":this._onQualityChange(n,i);break;case"fullscreenchange":this._notify("fullscreen-change",n.fullscreen,i);break;case"enterpictureinpicture":this._notify("picture-in-picture-change",!0,i);break;case"leavepictureinpicture":this._notify("picture-in-picture-change",!1,i);break;case"ended":this._notify("end",void 0,i);break;case"error":this._onError(n,i);break;case"seek":case"seeked":this._onSeeked(n.seconds,i);break}}_onError(e,n){if(e.method==="setPlaybackRate"&&this._pro.set(!1),e.method==="play"){this._playPromise?.reject(e.message);return}}_onMessage(e,n){e.event?this._onEvent(e.event,e.data,n):e.method&&this._onMethod(e.method,e.value,n)}_onLoad(){}_remote(e,n){return this._postMessage({method:e,value:n})}_reset(){this._timeRAF._stop(),this._played=0,this._playedRange=new Te(0,0),this._seekableRange=new Te(0,0),this._playPromise=null,this._pausePromise=null,this._videoInfoPromise=null,this._currentCue=null,this._pro.set(!1),this._removeChapters()}}});var T$={};zt(T$,{findYouTubePoster:()=>zz,resolveYouTubeVideoId:()=>yx});function yx(t){return t.match(Vz)?.[1]}async function zz(t,e){if(gx.has(t))return gx.get(t);if(lm.has(t))return lm.get(t);let n=new Promise(async i=>{let r=["maxresdefault","sddefault","hqdefault"];for(let s of r)for(let o of[!0,!1]){let a=Uz(t,s,o);if((await fetch(a,{mode:"no-cors",signal:e.signal})).status<400){gx.set(t,a),i(a);return}}}).catch(()=>"").finally(()=>lm.delete(t));return lm.set(t,n),n}function Uz(t,e,n){return`https://i.ytimg.com/${n?"vi_webp":"vi"}/${t}/${e}.${n?"webp":"jpg"}`}var Vz,gx,lm,vx=at(()=>{"use strict";"use client";Vz=/(?:youtu\.be|youtube|youtube\.com|youtube-nocookie\.com)\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=|)((?:\w|-){11})/,gx=new Map,lm=new Map});var E$={};zt(E$,{YouTubeProvider:()=>wx});var aY,vo,wx,S$=at(()=>{"use strict";"use client";an();En();ux();vx();aY=A(X(),1),vo={_Unstarted:-1,_Ended:0,_Playing:1,_Paused:2,_Buffering:3,_Cued:5},wx=class extends ll{constructor(e,n){super(e),this._ctx=n,this.$$PROVIDER_TYPE="YOUTUBE",this.scope=rn(),this._videoId=K(""),this._state=-1,this._seekingTimer=-1,this._pausedSeeking=!1,this._played=0,this._playedRange=new Te(0,0),this._currentSrc=null,this._playPromise=null,this._pausePromise=null,this.language="en",this.color="red",this.cookies=!1}get _notify(){return this._ctx.delegate._notify}get currentSrc(){return this._currentSrc}get type(){return"youtube"}get videoId(){return this._videoId()}preconnect(){Ai(this._getOrigin())}setup(){super.setup(),S(this._watchVideoId.bind(this)),this._notify("provider-setup",this)}async play(){let{paused:e}=this._ctx.$state;return this._playPromise||(this._playPromise=cl(()=>{if(this._playPromise=null,e())return"Timed out."}),this._remote("playVideo")),this._playPromise.promise}async pause(){let{paused:e}=this._ctx.$state;return this._pausePromise||(this._pausePromise=cl(()=>{this._pausePromise=null,e()}),this._remote("pauseVideo")),this._pausePromise.promise}setMuted(e){e?this._remote("mute"):this._remote("unMute")}setCurrentTime(e){this._pausedSeeking=this._ctx.$state.paused(),this._remote("seekTo",e),this._notify("seeking",e)}setVolume(e){this._remote("setVolume",e*100)}setPlaybackRate(e){this._remote("setPlaybackRate",e)}async loadSource(e){if(!Z(e.src)){this._currentSrc=null,this._videoId.set("");return}let n=yx(e.src);this._videoId.set(n??""),this._currentSrc=e}_getOrigin(){return this.cookies?"https://www.youtube.com":"https://www.youtube-nocookie.com"}_watchVideoId(){this._reset();let e=this._videoId();if(!e){this._src.set("");return}this._src.set(`${this._getOrigin()}/embed/${e}`),this._notify("load-start")}_buildParams(){let{keyDisabled:e}=this._ctx.$props,{$iosControls:n}=this._ctx,{controls:i,muted:r,playsInline:s}=this._ctx.$state,o=i()||n();return{autoplay:0,cc_lang_pref:this.language,cc_load_policy:o?1:void 0,color:this.color,controls:o?1:0,disablekb:!o||e()?1:0,enablejsapi:1,fs:1,hl:this.language,iv_load_policy:o?1:3,mute:r()?1:0,playsinline:s()?1:0}}_remote(e,n){this._postMessage({event:"command",func:e,args:n?[n]:void 0})}_onLoad(){window.setTimeout(()=>this._postMessage({event:"listening"}),100)}_onReady(e){this._notify("loaded-metadata"),this._notify("loaded-data"),this._ctx.delegate._ready(void 0,e)}_onPause(e){this._pausePromise?.resolve(),this._pausePromise=null,this._notify("pause",void 0,e)}_onTimeUpdate(e,n){let{duration:i,realCurrentTime:r}=this._ctx.$state,s=this._state===vo._Ended,o=s?i():e,a={currentTime:o,played:this._getPlayedRange(o)};this._notify("time-update",a,n),!s&&Math.abs(o-r())>1&&this._notify("seeking",o,n)}_getPlayedRange(e){return this._played>=e?this._playedRange:this._playedRange=new Te(0,this._played=e)}_onProgress(e,n,i){let r={buffered:new Te(0,e),seekable:n};this._notify("progress",r,i);let{seeking:s,realCurrentTime:o}=this._ctx.$state;s()&&e>o()&&this._onSeeked(i)}_onSeeked(e){let{paused:n,realCurrentTime:i}=this._ctx.$state;window.clearTimeout(this._seekingTimer),this._seekingTimer=window.setTimeout(()=>{this._notify("seeked",i(),e),this._seekingTimer=-1},n()?100:0),this._pausedSeeking=!1}_onEnded(e){let{seeking:n}=this._ctx.$state;n()&&this._onSeeked(e),this._notify("end",void 0,e)}_onStateChange(e,n){let{started:i,paused:r,seeking:s}=this._ctx.$state,o=e===vo._Playing,a=e===vo._Buffering,l=(r()||this._playPromise)&&(a||o);if(a&&this._notify("waiting",void 0,n),s()&&o&&this._onSeeked(n),!i()&&l&&this._pausedSeeking){this._playPromise?.reject("invalid internal play operation"),this._playPromise=null,o&&(this.pause(),this._pausedSeeking=!1);return}switch(l&&(this._playPromise?.resolve(),this._playPromise=null,this._notify("play",void 0,n)),e){case vo._Cued:this._onReady(n);break;case vo._Playing:this._notify("playing",void 0,n);break;case vo._Paused:this._onPause(n);break;case vo._Ended:this._onEnded(n);break}this._state=e}_onMessage({info:e},n){if(!e)return;let{title:i,intrinsicDuration:r,playbackRate:s}=this._ctx.$state;if(xu(e.videoData)&&e.videoData.title!==i()&&this._notify("title-change",e.videoData.title,n),dt(e.duration)&&e.duration!==r()){if(dt(e.videoLoadedFraction)){let o=e.progressState?.loaded??e.videoLoadedFraction*e.duration,a=new Te(0,e.duration);this._onProgress(o,a,n)}this._notify("duration-change",e.duration,n)}if(dt(e.playbackRate)&&e.playbackRate!==s()&&this._notify("rate-change",e.playbackRate,n),e.progressState){let{current:o,seekableStart:a,seekableEnd:l,loaded:c,duration:u}=e.progressState;this._onTimeUpdate(o,n),this._onProgress(c,new Te(a,l),n),u!==r()&&this._notify("duration-change",u,n)}if(dt(e.volume)&&Tb(e.muted)){let o={muted:e.muted,volume:e.volume/100};this._notify("volume-change",o,n)}dt(e.playerState)&&e.playerState!==this._state&&this._onStateChange(e.playerState,n)}_reset(){this._state=-1,this._seekingTimer=-1,this._played=0,this._playedRange=new Te(0,0),this._playPromise=null,this._pausePromise=null,this._pausedSeeking=!1}}});var C$={};zt(C$,{GoogleCastProvider:()=>kx});var pY,bx,_x,P$,xx,kx,M$=at(()=>{"use strict";"use client";an();En();Nu();Ex();pY=A(X(),1),bx=class{constructor(e){this._info=new chrome.cast.media.MediaInfo(e.src,e.type)}build(){return this._info}_setStreamType(e){return e.includes("live")?this._info.streamType=chrome.cast.media.StreamType.LIVE:this._info.streamType=chrome.cast.media.StreamType.BUFFERED,this}_setTracks(e){return this._info.tracks=e.map(this._buildCastTrack),this}_setMetadata(e,n){return this._info.metadata=new chrome.cast.media.GenericMediaMetadata,this._info.metadata.title=e,this._info.metadata.images=[{url:n}],this}_buildCastTrack(e,n){let i=new chrome.cast.media.Track(n,chrome.cast.media.TrackType.TEXT);return i.name=e.label,i.trackContentId=e.src,i.trackContentType="text/vtt",i.language=e.language,i.subtype=e.kind.toUpperCase(),i}},_x=chrome.cast.media.TrackType.TEXT,P$=chrome.cast.media.TrackType.AUDIO,xx=class{constructor(e,n,i){this._cast=e,this._ctx=n,this._onNewLocalTracks=i}_setup(){let e=this._syncRemoteActiveIds.bind(this);L(this._ctx.audioTracks,"change",e),L(this._ctx.textTracks,"mode-change",e),S(this._syncLocalTracks.bind(this))}_getLocalTextTracks(){return this._ctx.$state.textTracks().filter(e=>e.src&&e.type==="vtt")}_getLocalAudioTracks(){return this._ctx.$state.audioTracks()}_getRemoteTracks(e){let n=this._cast.mediaInfo?.tracks??[];return e?n.filter(i=>i.type===e):n}_getRemoteActiveIds(){let e=[],n=this._getLocalAudioTracks().find(r=>r.selected),i=this._getLocalTextTracks().filter(r=>r.mode==="showing");if(n){let r=this._getRemoteTracks(P$),s=this._findRemoteTrack(r,n);s&&e.push(s.trackId)}if(i?.length){let r=this._getRemoteTracks(_x);if(r.length)for(let s of i){let o=this._findRemoteTrack(r,s);o&&e.push(o.trackId)}}return e}_syncLocalTracks(){let e=this._getLocalTextTracks();if(!this._cast.isMediaLoaded)return;let n=this._getRemoteTracks(_x);for(let i of e)if(!this._findRemoteTrack(n,i)){el(()=>this._onNewLocalTracks?.());break}}_syncRemoteTracks(e){if(!this._cast.isMediaLoaded)return;let n=this._getLocalAudioTracks(),i=this._getLocalTextTracks(),r=this._getRemoteTracks(P$),s=this._getRemoteTracks(_x);for(let o of r){if(this._findLocalTrack(n,o))continue;let l={id:o.trackId.toString(),label:o.name,language:o.language,kind:o.subtype??"main",selected:!1};this._ctx.audioTracks[le._add](l,e)}for(let o of s){if(this._findLocalTrack(i,o))continue;let l={id:o.trackId.toString(),src:o.trackContentId,label:o.name,language:o.language,kind:o.subtype.toLowerCase()};this._ctx.textTracks.add(l,e)}}_syncRemoteActiveIds(e){if(!this._cast.isMediaLoaded)return;let n=this._getRemoteActiveIds(),i=new chrome.cast.media.EditTracksInfoRequest(n);this._editTracksInfo(i).catch(r=>{})}_editTracksInfo(e){let n=zu();return new Promise((i,r)=>n?.editTracksInfo(e,i,r))}_findLocalTrack(e,n){return e.find(i=>this._isMatch(i,n))}_findRemoteTrack(e,n){return e.find(i=>this._isMatch(n,i))}_isMatch(e,n){return n.name===e.label&&n.language===e.language&&n.subtype.toLowerCase()===e.kind.toLowerCase()}},kx=class{constructor(e,n){this._player=e,this._ctx=n,this.$$PROVIDER_TYPE="GOOGLE_CAST",this.scope=rn(),this._currentSrc=null,this._state="disconnected",this._currentTime=0,this._played=0,this._playedRange=new Te(0,0),this._seekableRange=new Te(0,0),this._timeRAF=new tr(this._onAnimationFrame.bind(this)),this._reloadInfo=null,this._isIdle=!1,this._tracks=new xx(this._player,this._ctx,this._onNewLocalTracks.bind(this))}get _notify(){return this._ctx.delegate._notify}get type(){return"google-cast"}get currentSrc(){return this._currentSrc}get player(){return this._player}get cast(){return wo()}get session(){return Vu()}get media(){return zu()}get hasActiveSession(){return cm(this._currentSrc)}setup(){this._attachCastContextEventListeners(),this._attachCastPlayerEventListeners(),this._tracks._setup(),this._notify("provider-setup",this)}_attachCastContextEventListeners(){Tx(cast.framework.CastContextEventType.CAST_STATE_CHANGED,this._onCastStateChange.bind(this))}_attachCastPlayerEventListeners(){let e=cast.framework.RemotePlayerEventType,n={[e.IS_CONNECTED_CHANGED]:this._onCastStateChange,[e.IS_MEDIA_LOADED_CHANGED]:this._onMediaLoadedChange,[e.CAN_CONTROL_VOLUME_CHANGED]:this._onCanControlVolumeChange,[e.CAN_SEEK_CHANGED]:this._onCanSeekChange,[e.DURATION_CHANGED]:this._onDurationChange,[e.IS_MUTED_CHANGED]:this._onVolumeChange,[e.VOLUME_LEVEL_CHANGED]:this._onVolumeChange,[e.IS_PAUSED_CHANGED]:this._onPausedChange,[e.LIVE_SEEKABLE_RANGE_CHANGED]:this._onProgress,[e.PLAYER_STATE_CHANGED]:this._onPlayerStateChange};this._playerEventHandlers=n;let i=this._onRemotePlayerEvent.bind(this);for(let r of Pu(n))this._player.controller.addEventListener(r,i);ae(()=>{for(let r of Pu(n))this._player.controller.removeEventListener(r,i)})}async play(){if(!(!this._player.isPaused&&!this._isIdle)){if(this._isIdle){await this._reload(!1,0);return}this._player.controller?.playOrPause()}}async pause(){this._player.isPaused||this._player.controller?.playOrPause()}getMediaStatus(e){return new Promise((n,i)=>{this.media?.getStatus(e,n,i)})}setMuted(e){(e&&!this._player.isMuted||!e&&this._player.isMuted)&&this._player.controller?.muteOrUnmute()}setCurrentTime(e){this._player.currentTime=e,this._notify("seeking",e),this._player.controller?.seek()}setVolume(e){this._player.volumeLevel=e,this._player.controller?.setVolumeLevel()}async loadSource(e){if(this._reloadInfo?.src!==e&&(this._reloadInfo=null),cm(e)){this._resumeSession(),this._currentSrc=e;return}this._notify("load-start");let n=this._buildLoadRequest(e),i=await this.session.loadMedia(n);if(i){this._currentSrc=null,this._notify("error",Error(um(i)));return}this._currentSrc=e}destroy(){this._reset(),this._endSession()}_reset(){this._reloadInfo||(this._played=0,this._playedRange=new Te(0,0),this._seekableRange=new Te(0,0)),this._timeRAF._stop(),this._currentTime=0,this._reloadInfo=null}_resumeSession(){let e=new ne("resume-session",{detail:this.session});this._onMediaLoadedChange(e);let{muted:n,volume:i,remotePlaybackInfo:r}=this._ctx.$state,s=r();this.setCurrentTime(Math.max(this._player.currentTime,s?.savedState?.currentTime??0)),this.setMuted(n()),this.setVolume(i()),s?.savedState?.paused===!1&&this.play()}_endSession(){this.cast.endCurrentSession(!0);let{remotePlaybackLoader:e}=this._ctx.$state;e.set(null)}_disconnectFromReceiver(){this._ctx.$state.remotePlaybackInfo.set({savedState:{paused:this._player.isPaused,currentTime:this._player.currentTime}}),this._endSession()}_onAnimationFrame(){this._onCurrentTimeChange()}_onRemotePlayerEvent(e){this._playerEventHandlers[e.type].call(this,e)}_onCastStateChange(e){let n=this.cast.getCastState(),i=n===cast.framework.CastState.CONNECTED?"connected":n===cast.framework.CastState.CONNECTING?"connecting":"disconnected";if(this._state===i)return;let r={type:"google-cast",state:i},s=this._createEvent(e);this._state=i,this._notify("remote-playback-change",r,s),i==="disconnected"&&this._disconnectFromReceiver()}_onMediaLoadedChange(e){if(!!!this._player.isMediaLoaded)return;let i=N(this._ctx.$state.source);Promise.resolve().then(()=>{if(i!==N(this._ctx.$state.source)||!this._player.isMediaLoaded)return;this._reset();let r=this._player.duration;this._seekableRange=new Te(0,r);let s={provider:this,duration:r,buffered:this._playedRange,seekable:this._getSeekableRange()},o=this._createEvent(e);this._notify("loaded-metadata",void 0,o),this._notify("loaded-data",void 0,o),this._notify("can-play",s,o),this._onCanControlVolumeChange(),this._onCanSeekChange(e);let{volume:a,muted:l}=this._ctx.$state;this.setVolume(a()),this.setMuted(l()),this._timeRAF._start(),this._tracks._syncRemoteTracks(o),this._tracks._syncRemoteActiveIds(o)})}_onCanControlVolumeChange(){this._ctx.$state.canSetVolume.set(this._player.canControlVolume)}_onCanSeekChange(e){let n=this._createEvent(e);this._notify("stream-type-change",this._getStreamType(),n)}_getStreamType(){return this._player.mediaInfo?.streamType===chrome.cast.media.StreamType.LIVE?this._player.canSeek?"live:dvr":"live":"on-demand"}_onCurrentTimeChange(){if(this._reloadInfo)return;let e=this._player.currentTime;if(e===this._currentTime)return;let n=this._played,i=this._getPlayedRange(e),r={currentTime:e,played:i};this._notify("time-update",r),e>n&&this._onProgress(),this._ctx.$state.seeking()&&this._notify("seeked",e),this._currentTime=e}_getPlayedRange(e){return this._played>=e?this._playedRange:this._playedRange=new Te(0,this._played=e)}_onDurationChange(e){if(!this._player.isMediaLoaded||this._reloadInfo)return;let n=this._player.duration,i=this._createEvent(e);this._seekableRange=new Te(0,n),this._notify("duration-change",n,i)}_onVolumeChange(e){if(!this._player.isMediaLoaded)return;let n={muted:this._player.isMuted,volume:this._player.volumeLevel},i=this._createEvent(e);this._notify("volume-change",n,i)}_onPausedChange(e){let n=this._createEvent(e);this._player.isPaused?this._notify("pause",void 0,n):this._notify("play",void 0,n)}_onProgress(e){let n={seekable:this._getSeekableRange(),buffered:this._playedRange},i=e?this._createEvent(e):void 0;this._notify("progress",n,i)}_onPlayerStateChange(e){let n=this._player.playerState,i=chrome.cast.media.PlayerState;if(this._isIdle=n===i.IDLE,n===i.PAUSED)return;let r=this._createEvent(e);switch(n){case i.PLAYING:this._notify("playing",void 0,r);break;case i.BUFFERING:this._notify("waiting",void 0,r);break;case i.IDLE:this._timeRAF._stop(),this._notify("pause"),this._notify("end");break}}_getSeekableRange(){return this._player.liveSeekableRange?new Te(this._player.liveSeekableRange.start,this._player.liveSeekableRange.end):this._seekableRange}_createEvent(e){return e instanceof Event?e:new ne(e.type,{detail:e})}_buildMediaInfo(e){let{streamType:n,title:i,poster:r}=this._ctx.$state;return new bx(e)._setMetadata(i(),r())._setStreamType(n())._setTracks(this._tracks._getLocalTextTracks()).build()}_buildLoadRequest(e){let n=this._buildMediaInfo(e),i=new chrome.cast.media.LoadRequest(n),r=this._ctx.$state.remotePlaybackInfo();return i.autoplay=(this._reloadInfo?.paused??r?.savedState?.paused)===!1,i.currentTime=this._reloadInfo?.time??r?.savedState?.currentTime??0,i}async _reload(e,n){let i=N(this._ctx.$state.source);this._reloadInfo={src:i,paused:e,time:n},await this.loadSource(i)}_onNewLocalTracks(){this._reload(this._player.isPaused,this._player.currentTime).catch(e=>{})}}});var R$={};zt(R$,{a:()=>wo,b:()=>Vu,c:()=>um,d:()=>Wz,g:()=>zu,h:()=>cm,l:()=>Tx});function jz(){return"https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"}function Bz(){return!!window.cast?.framework}function Hz(){return!!window.chrome?.cast?.isAvailable}function $$(){return wo().getCastState()===cast.framework.CastState.CONNECTED}function wo(){return window.cast.framework.CastContext.getInstance()}function Vu(){return wo().getCurrentSession()}function zu(){return Vu()?.getSessionObj().media[0]}function cm(t){return zu()?.media.contentId===t?.src}function qz(){return{language:"en-US",autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,resumeSavedSession:!0,androidReceiverCompatible:!0}}function um(t){return`Google Cast Error Code: ${t}`}function Tx(t,e){return I$(wo(),t,e)}var Sx,Wz,Ex=at(()=>{"use strict";"use client";En();an();Sx=class{constructor(){this.name="google-cast"}get cast(){return wo()}mediaType(){return"video"}canPlay(e){return Fu&&!dm&&pm(e)}async prompt(e){let n;try{let i=await this._loadCastFramework(e);this._player||(this._player=new cast.framework.RemotePlayer,new cast.framework.RemotePlayerController(this._player)),n=e.player.createEvent("google-cast-prompt-open",{trigger:i}),e.player.dispatchEvent(n),this._notifyRemoteStateChange(e,"connecting",n),await this._showPrompt(N(e.$props.googleCast)),e.$state.remotePlaybackInfo.set({deviceName:Vu()?.getCastDevice().friendlyName}),$$()&&this._notifyRemoteStateChange(e,"connected",n)}catch(i){let r=nr(i);throw this._notifyRemoteStateChange(e,$$()?"connected":"disconnected",new ne("google-cast-prompt-error",{detail:r})),r}finally{e.player.dispatch("google-cast-prompt-close",{trigger:n})}}async load(e){if(B)throw Error("[vidstack] can not load google cast provider server-side");if(!this._player)throw Error("[vidstack] google cast player was not initialized");return new(await Promise.resolve().then(()=>(M$(),C$))).GoogleCastProvider(this._player,e)}async _loadCastFramework(e){if(Bz())return;let n=e.player.createEvent("google-cast-load-start");e.player.dispatch(n),await om(jz()),await customElements.whenDefined("google-cast-launcher");let i=e.player.createEvent("google-cast-loaded",{trigger:n});if(e.player.dispatch(i),!Hz())throw Error("Cast not available.");return i}async _showPrompt(e){this._setOptions(e);let n=await this.cast.requestSession();if(n)throw Error(um(n))}_setOptions(e){this.cast?.setOptions({...qz(),...e})}_notifyRemoteStateChange(e,n,i){let r={type:"google-cast",state:n};e.delegate._notify("remote-playback-change",r,i)}},Wz=Object.freeze({__proto__:null,GoogleCastLoader:Sx})});function nR(){return vm}function Px(t){if(_o.fullscreenElement===t)return!0;try{return t.matches(_o.fullscreenPseudoClass)}catch{return!1}}function O$(){if(!vm)throw Error("[vidstack] no fullscreen API")}function Xx(){return iR()&&Wt(screen.orientation.unlock)}function iR(){return!B&&!Qe(window.screen.orientation)&&!Qe(window.screen.orientation.lock)}function s4(t,e){return B?!1:(t||(t=document.createElement("audio")),t.canPlayType(e).length>0)}function o4(t,e){return B?!1:(t||(t=document.createElement("video")),t.canPlayType(e).length>0)}function tm(t){return B?!1:(t||(t=document.createElement("video")),t.canPlayType("application/vnd.apple.mpegurl").length>0)}function nm(t){return B?!1:!!document.pictureInPictureEnabled&&!t?.disablePictureInPicture}function im(t){return B?!1:Wt(t?.webkitSupportsPresentationMode)&&Wt(t?.webkitSetPresentationMode)}async function rR(){let t=document.createElement("video");return t.volume=.5,await Rb(0),t.volume===.5}function a4(){return B?void 0:window?.ManagedMediaSource??window?.MediaSource??window?.WebKitMediaSource}function l4(){return B?void 0:window?.SourceBuffer??window?.WebKitSourceBuffer}function sm(){if(B)return!1;let t=a4();if(Qe(t))return!1;let e=t&&Wt(t.isTypeSupported)&&t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),n=l4(),i=Qe(n)||!Qe(n.prototype)&&Wt(n.prototype.appendBuffer)&&Wt(n.prototype.remove);return!!e&&!!i}function Rx(t){if(!t.length)return null;let e=t.start(0);for(let n=1;ne&&(e=i)}return e}function _$(t,e){let n=new URLSearchParams;for(let i of Object.keys(e))n.set(i,e[i]+"");return t+"?"+n.toString()}function Ai(t,e="preconnect"){if(B)return!1;let n=document.querySelector(`link[href="${t}"]`);if(!Ji(n))return!0;let i=document.createElement("link");return i.rel=e,i.href=t,i.crossOrigin="true",document.head.append(i),!0}function om(t){if(hm[t])return hm[t].promise;let e=$r(),n=document.querySelector(`script[src="${t}"]`);if(!Ji(n))return e.resolve(),e.promise;let i=document.createElement("script");return i.src=t,i.onload=()=>{e.resolve(),delete hm[t]},i.onerror=()=>{e.reject(),delete hm[t]},setTimeout(()=>document.head.append(i),0),e.promise}function _m(t){return t==="use-credentials"?"include":Z(t)?"same-origin":void 0}function bm(t,e){return e>=t.startTime&&es.includes(a.kind)&&a.mode==="showing");if(o!==i){if(!o){n(null),i=null;return}o.readyState==2?n(o):(n(null),o.addEventListener("load",()=>n(o),{once:!0})),i=o}}return r(),L(t,"mode-change",r)}function pt(t){return g4.test(t.kind)}function aR(t,e,n){let i=Z(t)?JSON.parse(t):t,r=[],s=[];return i.regions&&n&&(r=i.regions.map(o=>Object.assign(new n,o))),(i.cues||ut(i))&&(s=(ut(i)?i:i.cues).filter(o=>dt(o.startTime)&&dt(o.endTime)).map(o=>Object.assign(new e(0,0,""),o))),{regions:r,cues:s}}function lR(t){$o.reset(t,e=>y4.has(e)),Li()}function Ee(){return Xe(Id)}function cR(t){return t.split("-")[0]}function v4(t){return t.split("-")[1]}function w4(t){return t==="x"?"y":"x"}function _4(t){return t==="y"?"height":"width"}function uR(t){return["top","bottom"].includes(cR(t))?"y":"x"}function b4(t){return w4(uR(t))}function dR(t){return{...t,top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height}}function j$(t,e,n){let{reference:i,floating:r}=t,s=uR(e),o=b4(e),a=_4(o),l=cR(e),c=s==="y",u=i.x+i.width/2-r.width/2,d=i.y+i.height/2-r.height/2,p=i[a]/2-r[a]/2,h;switch(l){case"top":h={x:u,y:i.y-r.height};break;case"bottom":h={x:u,y:i.y+i.height};break;case"right":h={x:i.x+i.width,y:d};break;case"left":h={x:i.x-r.width,y:d};break;default:h={x:i.x,y:i.y}}switch(v4(e)){case"start":h[o]-=p*(n&&c?-1:1);break;case"end":h[o]+=p*(n&&c?-1:1);break}return h}function Es(t){return pR(t)?(t.nodeName||"").toLowerCase():"#document"}function Bn(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function zr(t){var e;return(e=(pR(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function pR(t){return t instanceof Node||t instanceof Bn(t).Node}function Dr(t){return t instanceof Element||t instanceof Bn(t).Element}function ir(t){return t instanceof HTMLElement||t instanceof Bn(t).HTMLElement}function B$(t){return typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Bn(t).ShadowRoot}function Ld(t){let{overflow:e,overflowX:n,overflowY:i,display:r}=pi(t);return/auto|scroll|overlay|hidden|clip/.test(e+i+n)&&!["inline","contents"].includes(r)}function k4(t){return["table","td","th"].includes(Es(t))}function Jx(t){let e=ek(),n=pi(t);return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(i=>(n.willChange||"").includes(i))||["paint","layout","strict","content"].some(i=>(n.contain||"").includes(i))}function hR(t){let e=fl(t);for(;ir(e)&&!ag(e);){if(Jx(e))return e;e=fl(e)}return null}function ek(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function ag(t){return["html","body","#document"].includes(Es(t))}function pi(t){return Bn(t).getComputedStyle(t)}function lg(t){return Dr(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function fl(t){if(Es(t)==="html")return t;let e=t.assignedSlot||t.parentNode||B$(t)&&t.host||zr(t);return B$(e)?e.host:e}function fR(t){let e=fl(t);return ag(e)?t.ownerDocument?t.ownerDocument.body:t.body:ir(e)&&Ld(e)?e:fR(e)}function Hu(t,e,n){var i;e===void 0&&(e=[]),n===void 0&&(n=!0);let r=fR(t),s=r===((i=t.ownerDocument)==null?void 0:i.body),o=Bn(r);return s?e.concat(o,o.visualViewport||[],Ld(r)?r:[],o.frameElement&&n?Hu(o.frameElement):[]):e.concat(r,Hu(r,[],n))}function mR(t){let e=pi(t),n=parseFloat(e.width)||0,i=parseFloat(e.height)||0,r=ir(t),s=r?t.offsetWidth:n,o=r?t.offsetHeight:i,a=xm(n)!==s||xm(i)!==o;return a&&(n=s,i=o),{width:n,height:i,$:a}}function tk(t){return Dr(t)?t:t.contextElement}function dl(t){let e=tk(t);if(!ir(e))return Ts(1);let n=e.getBoundingClientRect(),{width:i,height:r,$:s}=mR(e),o=(s?xm(n.width):n.width)/i,a=(s?xm(n.height):n.height)/r;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}function gR(t){let e=Bn(t);return!ek()||!e.visualViewport?T4:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function E4(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Bn(t)?!1:e}function bo(t,e,n,i){e===void 0&&(e=!1),n===void 0&&(n=!1);let r=t.getBoundingClientRect(),s=tk(t),o=Ts(1);e&&(i?Dr(i)&&(o=dl(i)):o=dl(t));let a=E4(s,n,i)?gR(s):Ts(0),l=(r.left+a.x)/o.x,c=(r.top+a.y)/o.y,u=r.width/o.x,d=r.height/o.y;if(s){let p=Bn(s),h=i&&Dr(i)?Bn(i):i,m=p.frameElement;for(;m&&i&&h!==p;){let v=dl(m),w=m.getBoundingClientRect(),f=pi(m),g=w.left+(m.clientLeft+parseFloat(f.paddingLeft))*v.x,y=w.top+(m.clientTop+parseFloat(f.paddingTop))*v.y;l*=v.x,c*=v.y,u*=v.x,d*=v.y,l+=g,c+=y,m=Bn(m).frameElement}}return dR({width:u,height:d,x:l,y:c})}function yR(t){let e=!1,n=0,i=0;function r(o){try{e=e||t.matches(o)}catch{}}S4.forEach(o=>{r(o)});let s=hR(t);if(e&&s){let o=s.getBoundingClientRect();n=o.x,i=o.y}return[e,n,i]}function P4(t){let{elements:e,rect:n,offsetParent:i,strategy:r}=t,s=zr(i),[o]=e?yR(e.floating):[!1];if(i===s||o)return n;let a={scrollLeft:0,scrollTop:0},l=Ts(1),c=Ts(0),u=ir(i);if((u||!u&&r!=="fixed")&&((Es(i)!=="body"||Ld(s))&&(a=lg(i)),ir(i))){let d=bo(i);l=dl(i),c.x=d.x+i.clientLeft,c.y=d.y+i.clientTop}return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-a.scrollLeft*l.x+c.x,y:n.y*l.y-a.scrollTop*l.y+c.y}}function C4(t){return Array.from(t.getClientRects())}function vR(t){return bo(zr(t)).left+lg(t).scrollLeft}function M4(t){let e=zr(t),n=lg(t),i=t.ownerDocument.body,r=ul(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),s=ul(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight),o=-n.scrollLeft+vR(t),a=-n.scrollTop;return pi(i).direction==="rtl"&&(o+=ul(e.clientWidth,i.clientWidth)-r),{width:r,height:s,x:o,y:a}}function $4(t,e){let n=Bn(t),i=zr(t),r=n.visualViewport,s=i.clientWidth,o=i.clientHeight,a=0,l=0;if(r){s=r.width,o=r.height;let c=ek();(!c||c&&e==="fixed")&&(a=r.offsetLeft,l=r.offsetTop)}return{width:s,height:o,x:a,y:l}}function R4(t,e){let n=bo(t,!0,e==="fixed"),i=n.top+t.clientTop,r=n.left+t.clientLeft,s=ir(t)?dl(t):Ts(1),o=t.clientWidth*s.x,a=t.clientHeight*s.y,l=r*s.x,c=i*s.y;return{width:o,height:a,x:l,y:c}}function H$(t,e,n){let i;if(e==="viewport")i=$4(t,n);else if(e==="document")i=M4(zr(t));else if(Dr(e))i=R4(e,n);else{let r=gR(t);i={...e,x:e.x-r.x,y:e.y-r.y}}return dR(i)}function wR(t,e){let n=fl(t);return n===e||!Dr(n)||ag(n)?!1:pi(n).position==="fixed"||wR(n,e)}function I4(t,e){let n=e.get(t);if(n)return n;let i=Hu(t,[],!1).filter(a=>Dr(a)&&Es(a)!=="body"),r=null,s=pi(t).position==="fixed",o=s?fl(t):t;for(;Dr(o)&&!ag(o);){let a=pi(o),l=Jx(o);!l&&a.position==="fixed"&&(r=null),(s?!l&&!r:!l&&a.position==="static"&&!!r&&["absolute","fixed"].includes(r.position)||Ld(o)&&!l&&wR(t,o))?i=i.filter(u=>u!==o):r=a,o=fl(o)}return e.set(t,i),i}function L4(t){let{element:e,boundary:n,rootBoundary:i,strategy:r}=t,o=[...n==="clippingAncestors"?I4(e,this._c):[].concat(n),i],a=o[0],l=o.reduce((c,u)=>{let d=H$(e,u,r);return c.top=ul(d.top,c.top),c.right=Lx(d.right,c.right),c.bottom=Lx(d.bottom,c.bottom),c.left=ul(d.left,c.left),c},H$(e,a,r));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function A4(t){let{width:e,height:n}=mR(t);return{width:e,height:n}}function D4(t,e,n,i){let r=ir(e),s=zr(e),o=n==="fixed",a=bo(t,!0,o,e),l={scrollLeft:0,scrollTop:0},c=Ts(0);if(r||!r&&!o)if((Es(e)!=="body"||Ld(s))&&(l=lg(e)),r){let v=bo(e,!0,o,e);c.x=v.x+e.clientLeft,c.y=v.y+e.clientTop}else s&&(c.x=vR(s));let u=a.left+l.scrollLeft-c.x,d=a.top+l.scrollTop-c.y,[p,h,m]=yR(i);return p&&(u+=h,d+=m,r&&(u+=e.clientLeft,d+=e.clientTop)),{x:u,y:d,width:a.width,height:a.height}}function q$(t,e){return!ir(t)||pi(t).position==="fixed"?null:e?e(t):t.offsetParent}function _R(t,e){let n=Bn(t);if(!ir(t))return n;let i=q$(t,e);for(;i&&k4(i)&&pi(i).position==="static";)i=q$(i,e);return i&&(Es(i)==="html"||Es(i)==="body"&&pi(i).position==="static"&&!Jx(i))?n:i||hR(t)||n}function O4(t){return pi(t).direction==="rtl"}function V4(t,e){let n=null,i,r=zr(t);function s(){var a;clearTimeout(i),(a=n)==null||a.disconnect(),n=null}function o(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();let{left:c,top:u,width:d,height:p}=t.getBoundingClientRect();if(a||e(),!d||!p)return;let h=fm(u),m=fm(r.clientWidth-(c+d)),v=fm(r.clientHeight-(u+p)),w=fm(c),g={rootMargin:-h+"px "+-m+"px "+-v+"px "+-w+"px",threshold:ul(0,Lx(1,l))||1},y=!0;function T(P){let k=P[0].intersectionRatio;if(k!==l){if(!y)return o();k?o(!1,k):i=setTimeout(()=>{o(!1,1e-7)},100)}y=!1}try{n=new IntersectionObserver(T,{...g,root:r.ownerDocument})}catch{n=new IntersectionObserver(T,g)}n.observe(t)}return o(!0),s}function z4(t,e,n,i){i===void 0&&(i={});let{ancestorScroll:r=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=i,c=tk(t),u=r||s?[...c?Hu(c):[],...Hu(e)]:[];u.forEach(f=>{r&&f.addEventListener("scroll",n,{passive:!0}),s&&f.addEventListener("resize",n)});let d=c&&a?V4(c,n):null,p=-1,h=null;o&&(h=new ResizeObserver(f=>{let[g]=f;g&&g.target===c&&h&&(h.unobserve(e),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var y;(y=h)==null||y.observe(e)})),n()}),c&&!l&&h.observe(c),h.observe(e));let m,v=l?bo(t):null;l&&w();function w(){let f=bo(t);v&&(f.x!==v.x||f.y!==v.y||f.width!==v.width||f.height!==v.height)&&n(),v=f,m=requestAnimationFrame(w)}return n(),()=>{var f;u.forEach(g=>{r&&g.removeEventListener("scroll",n),s&&g.removeEventListener("resize",n)}),d?.(),(f=h)==null||f.disconnect(),h=null,l&&cancelAnimationFrame(m)}}function I$(t,e,n){if(t)return L(t,e,n)}function Ne(t,e,n){t.hasAttribute(e)||t.setAttribute(e,n)}function Cs(t,e){if(t.hasAttribute("aria-label")||t.hasAttribute("data-no-label"))return;function n(){pe(t,"aria-label",e())}B?n():S(n)}function bR(t,e,n){for(;e;){if(e===t)return!0;if(n?.(e))break;e=e.parentElement}return!1}function Ss(t,e){L(t,"pointerup",n=>{n.button===0&&e(n)}),L(t,"keydown",n=>{Tu(n)&&e(n)})}function nk(t){return tl(t)&&(t.touches.length>1||t.changedTouches.length>1)}function km(t){if(B)return t();let e=wu(),n=window.requestAnimationFrame(()=>{Ct(t,e),n=-1});return()=>void window.cancelAnimationFrame(n)}function xR(t,e,n,{offsetVarName:i,xOffset:r,yOffset:s,...o}){if(!t)return;let a=n.replace(" ","-").replace("-center","");if(Ot(t,"visibility",e?null:"hidden"),!e)return;let l=u=>n.includes("left")?`calc(-1 * ${u})`:u,c=u=>n.includes("top")?`calc(-1 * ${u})`:u;return z4(e,t,()=>{U4(e,t,{placement:a,...o}).then(({x:u,y:d})=>{Object.assign(t.style,{top:`calc(${d+"px"} + ${c(s?s+"px":`var(--${i}-y-offset, 0px)`)})`,left:`calc(${u+"px"} + ${l(r?r+"px":`var(--${i}-x-offset, 0px)`)})`})})})}function j4(t){return getComputedStyle(t).animationName!=="none"}function B4(t,e,n){var i=null,r=null,s=n&&n.leading,o=n&&n.trailing;s==null&&(s=!0),o==null&&(o=!s),s==!0&&(o=!1);var a=function(){i&&(clearTimeout(i),i=null)},l=function(){var u=r;a(),u&&u()},c=function(){var u=s&&!i,d=this,p=arguments;if(r=function(){return t.apply(d,p)},i||(i=setTimeout(function(){if(i=null,o)return r()},e)),u)return u=!1,r()};return c.cancel=a,c.flush=l,c}function H4(t,e,n){var i=null,r=null,s=function(){i&&(clearTimeout(i),r=null,i=null)},o=function(){var l=r;s(),l&&l()},a=function(){if(!e)return t.apply(this,arguments);var l=this,c=arguments,u=n&&!i;if(s(),r=function(){t.apply(l,c)},i=setTimeout(function(){if(i=null,!u){var d=r;return r=null,d()}},e),u)return r()};return a.cancel=s,a.flush=o,a}function kl(t){return t?.$$PROVIDER_TYPE==="VIDEO"}function kR(t){return!B&&t instanceof HTMLAudioElement}function TR(t){return!B&&t instanceof HTMLVideoElement}function ER(t){return kR(t)||TR(t)}function Y4(t){return t.replace(/Shift\+(\d)/g,(e,n)=>G4[n-1])}function rk({src:t,type:e}){return Z(t)?PR.test(t)||CR.has(e)||t.startsWith("blob:")&&e==="audio/object":e==="audio/object"}function sk(t){return Z(t.src)?MR.test(t.src)||$R.has(t.type)||t.src.startsWith("blob:")&&t.type==="video/object"||yo(t)&&(B||tm()):t.type==="video/object"}function yo({src:t,type:e}){return Z(t)&&RR.test(t)||IR.has(e)}function pm(t){return Z(t.src)&&(rk(t)||sk(t)||yo(t))}function Zb(t){return!B&&typeof window.MediaStream<"u"&&t instanceof window.MediaStream}function nr(t){return t instanceof Error?t:Error(JSON.stringify(t))}function Lr(t,e){if(!t)throw Error(e||"Assertion failed.")}function Mx(t,e){if(!(t&&e))throw Error("[vidstack] media not ready")}function G$(t,e){if(!e?.supported)throw Error("[vidstack] no fullscreen support")}function cn(t,e=2){return Number(t.toFixed(e))}function em(t){return String(t).split(".")[1]?.length??0}function ok(t,e,n){return Math.max(t,Math.min(n,e))}function mm(t,e){pe(t,"data-focus",e),pe(t,"data-hocus",e)}function Y$(t,e){pe(t,"data-hocus",e),pe(t,"data-hover",e)}function NR(t,e){return fetch(t,e).then(n=>n.text()).then(n=>{let i=i6(n);if(i)return NR(/^https?:/.test(i)?i:new URL(i,t).href,e);let r=/EXT-X-PLAYLIST-TYPE:\s*VOD/.test(n)?"on-demand":"live";return r==="live"&&r6(n)>=10&&(/#EXT-X-DVR-ENABLED:\s*true/.test(n)||n.includes("#EXT-X-DISCONTINUITY"))?"live:dvr":r})}function i6(t){let e=t.match(/#EXT-X-STREAM-INF:[^\n]+(\n[^\n]+)*/g);return e?e[0].split(` `)[1].trim():null}function r6(t){let e=t.split(` `);for(let n of e)if(n.startsWith("#EXT-X-TARGETDURATION")){let i=parseFloat(n.split(":")[1]);if(!isNaN(i))return i}return-1}function Q$(t){return(ut(t)?t:[!Z(t)&&"src"in t?t:{src:t}]).map(({src:e,type:n,...i})=>({src:e,type:n??(Z(e)?OR.get(e):null)??(!Z(e)||e.startsWith("blob:")?"video/object":e.includes("youtube")?"video/youtube":e.includes("vimeo")?"video/vimeo":"?"),...i})).sort(e=>e.type==="?"?1:-1)}function X$(t,e){return t?.src===e?.src&&t?.type===e?.type}function p6(t){return t?"true":"false"}function Pn(t){return()=>p6(t())}function Z$(t,e,n){let i=e-t,r=n-t;return i>0?r/i:0}function h6(t,e,n,i){return ok(t,cn(n,em(i)),e)}function f6(t,e,n,i){let r=ok(0,n,1),s=e-t,o=s*r,a=o/i,l=i*a;return t+l}function $x(t,e){let n=String(t),i=n.length;if(i=3600?$x(s,2):s,c=$x(o,2);return r>0||i?`${a}:${l}:${c}`:`${l}:${c}`}function Yu(t){let e=[],{hours:n,minutes:i,seconds:r}=FR(t);return n>0&&e.push(`${n} hour`),i>0&&e.push(`${i} min`),(r>0||e.length===0)&&e.push(`${r} sec`),e.join(" ")}function ak(t,{clamp:e,offset:n,orientation:i}){let r=getComputedStyle(t),s=parseFloat(r.width),o=parseFloat(r.height),a={top:null,right:null,bottom:null,left:null};if(a[i==="horizontal"?"bottom":"left"]=`calc(100% + var(--media-slider-preview-offset, ${n}px))`,i==="horizontal"){let l=s/2;if(!e)a.left=`calc(var(--slider-pointer) - ${l}px)`;else{let c=`max(0px, calc(var(--slider-pointer) - ${l}px))`,u=`calc(100% - ${s}px)`;a.left=`min(${c}, ${u})`}}else{let l=o/2;if(!e)a.bottom=`calc(var(--slider-pointer) - ${l}px)`;else{let c=`max(${l}px, calc(var(--slider-pointer) - ${l}px))`,u=`calc(100% - ${o}px)`;a.bottom=`min(${c}, ${u})`}}Object.assign(t.style,a)}function G6(t){return je.isValidElement(t)&&t.type===K6}function Y6(t,e){let n={...e};for(let i in e){let r=t[i],s=e[i];/^on[A-Z]/.test(i)?r&&s?n[i]=(...a)=>{s(...a),r(...a)}:r&&(n[i]=r):i==="style"?n[i]={...r,...s}:i==="className"&&(n[i]=[r,s].filter(Boolean).join(" "))}return{...t,...n}}function UR(t){return t?.$$PROVIDER_TYPE==="REMOTION"}function Oe(t,e){let n=ws($o);return Me((e?.current?.$state||n||X6)[t])}var je,Kz,Gz,Yz,Qz,Xz,Zz,Jz,e4,t4,n4,i4,le,L$,Bu,jn,A$,D$,N$,Sn,di,_o,vm,wm,B,r4,dm,F$,Fu,Xb,sR,Zx,Te,hm,c4,u4,d4,p4,h4,f4,m4,se,V$,z$,U$,zn,g4,$o,y4,Id,hl,Lx,ul,xm,fm,Ts,x4,T4,S4,N4,F4,U4,Nr,Tm,Ad,Em,Ax,Sm,ik,Pm,Uu,Cm,Mm,q4,W4,Un,$m,SR,W$,K4,K$,Dx,G4,Rm,PR,CR,MR,$R,RR,IR,Im,qu,LR,DR,Lm,Am,Cx,Q4,X4,Dm,Nx,Ox,Nm,Fx,Vx,Z4,zx,Ux,J4,Om,Hn,e6,t6,Be,Re,n6,OR,Bx,Hx,s6,o6,a6,ml,Fm,Vm,zm,pl,l6,Um,jm,Wu,Mt,c6,u6,d6,Ku,Bm,Hm,qm,Wm,Km,Gm,Ym,Qm,Xm,cg,J$,qx,Gu,ug,rr,Or,Ar,gm,Zm,gl,Jm,m6,g6,y6,xo,v6,w6,_6,yl,Qu,Xu,vl,b6,x6,dg,Fr,Ft,k6,eR,Wx,T6,E6,Dd,S6,Vr,P6,C6,M6,ko,eg,tg,ju,Zu,Kx,Ps,$6,R6,VR,wl,I6,L6,A6,_l,D6,N6,lk,To,O6,F6,ck,Eo,V6,z6,uk,So,U6,j6,dk,Po,B6,H6,pk,Co,ng,Gx,ig,Ju,ed,q6,W6,Yx,Mo,rg,td,nd,sg,id,rd,sd,od,ad,ld,cd,ud,dd,pd,hd,fd,md,gd,yd,vd,wd,_d,bd,xd,kd,Td,Ed,Sd,Pd,Cd,Md,$d,og,bl,Rd,zR,Qx,K6,Q6,te,tR,X6,En=at(()=>{"use strict";"use client";je=A(X(),1);an();Gz=Symbol(0);Kz=Gz;Yz=Symbol(0),Qz=Symbol(0),Xz=Symbol(0),Zz=Symbol(0),Jz=Symbol(0),e4=Symbol(0),t4=Symbol(0),n4=Symbol(0),i4=Symbol(0),le={_add:Yz,_remove:Qz,_reset:Xz,_select:Zz,_readonly:Jz,_setReadonly:e4,_onReset:t4,_onRemove:n4,_onUserSelect:i4},Bu=class extends Za{constructor(){super(...arguments),this._items=[],this[L$]=!1}get length(){return this._items.length}get readonly(){return this[le._readonly]}toArray(){return[...this._items]}[(L$=le._readonly,Symbol.iterator)](){return this._items.values()}[le._add](e,n){let i=this._items.length;""+i in this||Object.defineProperty(this,i,{get(){return this._items[i]}}),!this._items.includes(e)&&(this._items.push(e),this.dispatchEvent(new ne("add",{detail:e,trigger:n})))}[le._remove](e,n){let i=this._items.indexOf(e);i>=0&&(this[le._onRemove]?.(e,n),this._items.splice(i,1),this.dispatchEvent(new ne("remove",{detail:e,trigger:n})))}[le._reset](e){for(let n of[...this._items])this[le._remove](n,e);this._items=[],this[le._setReadonly](!1,e),this[le._onReset]?.()}[le._setReadonly](e,n){this[le._readonly]!==e&&(this[le._readonly]=e,this.dispatchEvent(new ne("readonly-change",{detail:e,trigger:n})))}},jn={fullscreenEnabled:0,fullscreenElement:1,requestFullscreen:2,exitFullscreen:3,fullscreenchange:4,fullscreenerror:5,fullscreen:6},A$=["webkitFullscreenEnabled","webkitFullscreenElement","webkitRequestFullscreen","webkitExitFullscreen","webkitfullscreenchange","webkitfullscreenerror","-webkit-full-screen"],D$=["mozFullScreenEnabled","mozFullScreenElement","mozRequestFullScreen","mozCancelFullScreen","mozfullscreenchange","mozfullscreenerror","-moz-full-screen"],N$=["msFullscreenEnabled","msFullscreenElement","msRequestFullscreen","msExitFullscreen","MSFullscreenChange","MSFullscreenError","-ms-fullscreen"],Sn=typeof window<"u"&&typeof window.document<"u"?window.document:{},di="fullscreenEnabled"in Sn&&Object.keys(jn)||A$[0]in Sn&&A$||D$[0]in Sn&&D$||N$[0]in Sn&&N$||[],_o={requestFullscreen:function(t){return t[di[jn.requestFullscreen]]()},requestFullscreenFunction:function(t){return t[di[jn.requestFullscreen]]},get exitFullscreen(){return Sn[di[jn.exitFullscreen]].bind(Sn)},get fullscreenPseudoClass(){return":"+di[jn.fullscreen]},addEventListener:function(t,e,n){return Sn.addEventListener(di[jn[t]],e,n)},removeEventListener:function(t,e,n){return Sn.removeEventListener(di[jn[t]],e,n)},get fullscreenEnabled(){return!!Sn[di[jn.fullscreenEnabled]]},set fullscreenEnabled(t){},get fullscreenElement(){return Sn[di[jn.fullscreenElement]]},set fullscreenElement(t){},get onfullscreenchange(){return Sn[("on"+di[jn.fullscreenchange]).toLowerCase()]},set onfullscreenchange(t){return Sn[("on"+di[jn.fullscreenchange]).toLowerCase()]=t},get onfullscreenerror(){return Sn[("on"+di[jn.fullscreenerror]).toLowerCase()]},set onfullscreenerror(t){return Sn[("on"+di[jn.fullscreenerror]).toLowerCase()]=t}},vm=_o.fullscreenEnabled,wm=class extends sn{constructor(){super(...arguments),this._listening=!1,this._active=!1}get active(){return this._active}get supported(){return vm}onConnect(){L(_o,"fullscreenchange",this._onFullscreenChange.bind(this)),L(_o,"fullscreenerror",this._onFullscreenError.bind(this)),ae(this._onDisconnect.bind(this))}async _onDisconnect(){vm&&await this.exit()}_onFullscreenChange(e){let n=Px(this.el);n!==this._active&&(n||(this._listening=!1),this._active=n,this.dispatch("fullscreen-change",{detail:n,trigger:e}))}_onFullscreenError(e){this._listening&&(this.dispatch("fullscreen-error",{detail:null,trigger:e}),this._listening=!1)}async enter(){try{return this._listening=!0,!this.el||Px(this.el)?void 0:(O$(),_o.requestFullscreen(this.el))}catch(e){throw this._listening=!1,e}}async exit(){if(!(!this.el||!Px(this.el)))return O$(),_o.exitFullscreen()}};B=typeof document>"u",r4=B?"":navigator?.userAgent.toLowerCase()||"",dm=!B&&/iphone|ipad|ipod|ios|crios|fxios/i.test(r4),F$=!B&&/(iphone|ipod)/gi.test(navigator?.platform||""),Fu=!B&&!!window.chrome,Xb=!B&&(!!window.safari||dm);sR=class oR extends sn{constructor(){super(...arguments),this._type=K(this._getScreenOrientation()),this._locked=K(!1)}get type(){return this._type()}get locked(){return this._locked()}get portrait(){return this._type().startsWith("portrait")}get landscape(){return this._type().startsWith("landscape")}get supported(){return oR.supported}onConnect(){if(this.supported)L(screen.orientation,"change",this._onOrientationChange.bind(this));else{let e=window.matchMedia("(orientation: landscape)");e.onchange=this._onOrientationChange.bind(this),ae(()=>e.onchange=null)}ae(this._onDisconnect.bind(this))}async _onDisconnect(){this.supported&&this._locked()&&await this.unlock()}_onOrientationChange(e){this._type.set(this._getScreenOrientation()),this.dispatch("orientation-change",{detail:{orientation:N(this._type),lock:this._currentLock},trigger:e})}async lock(e){N(this._locked)||this._currentLock===e||(this._assertScreenOrientationAPI(),await screen.orientation.lock(e),this._locked.set(!0),this._currentLock=e)}async unlock(){N(this._locked)&&(this._assertScreenOrientationAPI(),this._currentLock=void 0,await screen.orientation.unlock(),this._locked.set(!1))}_assertScreenOrientationAPI(){if(!this.supported)throw Error("[vidstack] no orientation API")}_getScreenOrientation(){return B?"portrait-primary":this.supported?window.screen.orientation.type:window.innerWidth>=window.innerHeight?"landscape-primary":"portrait-primary"}};sR.supported=Xx();Zx=sR,Te=class{get length(){return this._ranges.length}constructor(e,n){ut(e)?this._ranges=e:!Qe(e)&&!Qe(n)?this._ranges=[[e,n]]:this._ranges=[]}start(e){return this._ranges[e][0]??1/0}end(e){return this._ranges[e][1]??1/0}};hm={};c4=Symbol(0),u4=Symbol(0),d4=Symbol(0),p4=Symbol(0),h4=Symbol(0),f4=Symbol(0),m4=Symbol(0),se={_crossOrigin:c4,_readyState:u4,_updateActiveCues:d4,_canLoad:p4,_onModeChange:h4,_native:f4,_nativeHLS:m4};zn=class extends Za{constructor(e){super(),this.id="",this.label="",this.language="",this.default=!1,this._canLoad=!1,this._currentTime=0,this._mode="disabled",this._metadata={},this._regions=[],this._cues=[],this._activeCues=[],this[V$]=0,this[z$]=null,this[U$]=null;for(let n of Object.keys(e))this[n]=e[n];this.type||(this.type="vtt"),!B&&e.content?Promise.resolve().then(()=>(Du(),Au)).then(({parseText:n,VTTCue:i,VTTRegion:r})=>{!Z(e.content)||e.type==="json"?(this._parseJSON(e.content,i,r),this.readyState!==3&&this._readyState()):n(e.content,{type:e.type}).then(({cues:s,regions:o})=>{this._cues=s,this._regions=o,this._readyState()})}):e.src||(this[se._readyState]=2)}static createId(e){return`id::${e.type}-${e.kind}-${e.src??e.label}`}get metadata(){return this._metadata}get regions(){return this._regions}get cues(){return this._cues}get activeCues(){return this._activeCues}get readyState(){return this[se._readyState]}get mode(){return this._mode}set mode(e){this.setMode(e)}addCue(e,n){let i=0,r=this._cues.length;for(i=0;i=0){let r=this._activeCues.includes(e);this._cues.splice(i,1),this[se._native]?.track.removeCue(e),this.dispatchEvent(new ne("remove-cue",{detail:e,trigger:n})),r&&this[se._updateActiveCues](this._currentTime,n)}}setMode(e,n){this._mode!==e&&(this._mode=e,e==="disabled"?(this._activeCues=[],this._activeCuesChanged()):this.readyState===2?this[se._updateActiveCues](this._currentTime,n):this._load(),this.dispatchEvent(new ne("mode-change",{detail:this,trigger:n})),this[se._onModeChange]?.())}[(V$=se._readyState,z$=se._onModeChange,U$=se._native,se._updateActiveCues)](e,n){if(this._currentTime=e,this.mode==="disabled"||!this._cues.length)return;let i=[];for(let s=0,o=this._cues.length;s0)){this[se._readyState]=1,this.dispatchEvent(new ne("load-start"));try{let{parseResponse:e,VTTCue:n,VTTRegion:i}=await Promise.resolve().then(()=>(Du(),Au)),r=this[se._crossOrigin]?.(),s=fetch(this.src,{headers:this.type==="json"?{"Content-Type":"application/json"}:void 0,credentials:_m(r)});if(this.type==="json")this._parseJSON(await(await s).text(),n,i);else{let{errors:o,metadata:a,regions:l,cues:c}=await e(s,{type:this.type,encoding:this.encoding});if(o[0]?.code===0)throw o[0];this._metadata=a,this._regions=l,this._cues=c}this._readyState()}catch(e){this._errorState(e)}}}_readyState(){if(this[se._readyState]=2,!this.src||this.type!=="vtt"){let n=this[se._native]?.track;if(n)for(let i of this._cues)n.addCue(i)}let e=new ne("load");this[se._updateActiveCues](this._currentTime,e),this.dispatchEvent(e)}_errorState(e){this[se._readyState]=3,this.dispatchEvent(new ne("error",{detail:e}))}_parseJSON(e,n,i){try{let{regions:r,cues:s}=aR(e,n,i);this._regions=r,this._cues=s}catch(r){this._errorState(r)}}_activeCuesChanged(e){this.dispatchEvent(new ne("cue-change",{trigger:e}))}},g4=/captions|subtitles/;$o=new Ii({artist:"",audioTrack:null,audioTracks:[],autoPlay:!1,autoPlayError:null,buffered:new Te,canLoad:!1,canLoadPoster:!1,canFullscreen:!1,canOrientScreen:Xx(),canPictureInPicture:!1,canPlay:!1,clipStartTime:0,clipEndTime:0,controls:!1,controlsVisible:!1,crossOrigin:null,ended:!1,error:null,fullscreen:!1,loop:!1,logLevel:"silent",mediaType:"unknown",muted:!1,paused:!0,played:new Te,playing:!1,playsInline:!1,pictureInPicture:!1,preload:"metadata",playbackRate:1,qualities:[],quality:null,autoQuality:!1,canSetQuality:!0,canSetPlaybackRate:!0,canSetVolume:!1,seekable:new Te,seeking:!1,source:{src:"",type:""},sources:[],started:!1,textTracks:[],textTrack:null,get hasCaptions(){return this.textTracks.filter(pt).length>0},volume:1,waiting:!1,realCurrentTime:0,get currentTime(){return this.clipStartTime>0?Math.max(0,Math.min(this.realCurrentTime-this.clipStartTime,this.duration)):this.realCurrentTime},providedDuration:-1,intrinsicDuration:0,get realDuration(){return this.providedDuration>0?this.providedDuration:this.intrinsicDuration},get duration(){return this.clipEndTime>0?this.clipEndTime-this.clipStartTime:Math.max(0,this.realDuration-this.clipStartTime)},get title(){return this.providedTitle||this.inferredTitle},get poster(){return this.providedPoster||this.inferredPoster},get viewType(){return this.providedViewType!=="unknown"?this.providedViewType:this.inferredViewType},get streamType(){return this.providedStreamType!=="unknown"?this.providedStreamType:this.inferredStreamType},get currentSrc(){return this.source},get bufferedStart(){let t=Rx(this.buffered)??0;return Math.max(0,t-this.clipStartTime)},get bufferedEnd(){let t=Ix(this.buffered)??0;return Math.min(this.duration,Math.max(0,t-this.clipStartTime))},get seekableStart(){let t=Rx(this.seekable)??0;return Math.max(0,t-this.clipStartTime)},get seekableEnd(){let t=this.canPlay?Ix(this.seekable)??1/0:0;return this.clipEndTime>0?Math.min(this.clipEndTime,Math.max(0,t-this.clipStartTime)):t},get seekableWindow(){return Math.max(0,this.seekableEnd-this.seekableStart)},canAirPlay:!1,canGoogleCast:!1,remotePlaybackState:"disconnected",remotePlaybackType:"none",remotePlaybackLoader:null,remotePlaybackInfo:null,get isAirPlayConnected(){return this.remotePlaybackType==="airplay"&&this.remotePlaybackState==="connected"},get isGoogleCastConnected(){return this.remotePlaybackType==="google-cast"&&this.remotePlaybackState==="connected"},pointer:"fine",orientation:"landscape",width:0,height:0,mediaWidth:0,mediaHeight:0,lastKeyboardAction:null,userBehindLiveEdge:!1,liveEdgeTolerance:10,minLiveDVRWindow:60,get canSeek(){return/unknown|on-demand|:dvr/.test(this.streamType)&&Number.isFinite(this.seekableWindow)&&(!this.live||/:dvr/.test(this.streamType)&&this.seekableWindow>=this.minLiveDVRWindow)},get live(){return this.streamType.includes("live")||!Number.isFinite(this.realDuration)},get liveEdgeStart(){return this.live&&Number.isFinite(this.seekableEnd)?Math.max(0,(this.liveSyncPosition??this.seekableEnd)-this.liveEdgeTolerance):0},get liveEdge(){return this.live&&(!this.canSeek||!this.userBehindLiveEdge&&this.currentTime>=this.liveEdgeStart)},get liveEdgeWindow(){return this.live&&Number.isFinite(this.seekableEnd)?this.seekableEnd-this.liveEdgeStart:0},autoPlaying:!1,providedTitle:"",inferredTitle:"",providedPoster:"",inferredPoster:"",inferredViewType:"unknown",providedViewType:"unknown",providedStreamType:"unknown",inferredStreamType:"unknown",liveSyncPosition:null}),y4=new Set(["audioTrack","audioTracks","autoPlayError","autoPlaying","autoQuality","buffered","canPlay","ended","error","inferredPoster","inferredStreamType","inferredTitle","intrinsicDuration","liveSyncPosition","paused","played","playing","qualities","quality","realCurrentTime","seekable","seeking","started","userBehindLiveEdge","waiting"]);Id=er();hl=class{constructor(e=void 0){this._logger=e,this._target=null,this._player=null,this._prevTrackIndex=-1}setTarget(e){this._target=e}getPlayer(e){return this._player?this._player:((e??this._target)?.dispatchEvent(new ne("find-media-player",{detail:n=>void(this._player=n),bubbles:!0,composed:!0})),this._player)}setPlayer(e){this._player=e}startLoading(e){this._dispatchRequest("media-start-loading",e)}startLoadingPoster(e){this._dispatchRequest("media-poster-start-loading",e)}requestAirPlay(e){this._dispatchRequest("media-airplay-request",e)}requestGoogleCast(e){this._dispatchRequest("media-google-cast-request",e)}play(e){this._dispatchRequest("media-play-request",e)}pause(e){this._dispatchRequest("media-pause-request",e)}mute(e){this._dispatchRequest("media-mute-request",e)}unmute(e){this._dispatchRequest("media-unmute-request",e)}enterFullscreen(e,n){this._dispatchRequest("media-enter-fullscreen-request",n,e)}exitFullscreen(e,n){this._dispatchRequest("media-exit-fullscreen-request",n,e)}lockScreenOrientation(e,n){this._dispatchRequest("media-orientation-lock-request",n,e)}unlockScreenOrientation(e){this._dispatchRequest("media-orientation-unlock-request",e)}enterPictureInPicture(e){this._dispatchRequest("media-enter-pip-request",e)}exitPictureInPicture(e){this._dispatchRequest("media-exit-pip-request",e)}seeking(e,n){this._dispatchRequest("media-seeking-request",n,e)}seek(e,n){this._dispatchRequest("media-seek-request",n,e)}seekToLiveEdge(e){this._dispatchRequest("media-live-edge-request",e)}changeVolume(e,n){this._dispatchRequest("media-volume-change-request",n,Math.max(0,Math.min(1,e)))}changeAudioTrack(e,n){this._dispatchRequest("media-audio-track-change-request",n,e)}changeQuality(e,n){this._dispatchRequest("media-quality-change-request",n,e)}requestAutoQuality(e){this.changeQuality(-1,e)}changeTextTrackMode(e,n,i){this._dispatchRequest("media-text-track-change-request",i,{index:e,mode:n})}changePlaybackRate(e,n){this._dispatchRequest("media-rate-change-request",n,e)}resumeControls(e){this._dispatchRequest("media-resume-controls-request",e)}pauseControls(e){this._dispatchRequest("media-pause-controls-request",e)}togglePaused(e){let n=this.getPlayer(e?.target);n&&(n.state.paused?this.play(e):this.pause(e))}toggleControls(e){let n=this.getPlayer(e?.target);n&&(n.controls.showing?n.controls.hide(0,e):n.controls.show(0,e))}toggleMuted(e){let n=this.getPlayer(e?.target);n&&(n.state.muted?this.unmute(e):this.mute(e))}toggleFullscreen(e,n){let i=this.getPlayer(n?.target);i&&(i.state.fullscreen?this.exitFullscreen(e,n):this.enterFullscreen(e,n))}togglePictureInPicture(e){let n=this.getPlayer(e?.target);n&&(n.state.pictureInPicture?this.exitPictureInPicture(e):this.enterPictureInPicture(e))}disableCaptions(e){let n=this.getPlayer(e?.target);if(!n)return;let i=n.state.textTracks,r=n.state.textTrack;if(r){let s=i.indexOf(r);this.changeTextTrackMode(s,"disabled",e)}}toggleCaptions(e){let n=this.getPlayer(e?.target);if(!n)return;let i=n.state.textTracks,r=n.state.textTrack;if(r){let s=i.indexOf(r);this.changeTextTrackMode(s,"disabled",e),this._prevTrackIndex=s}else{let s=this._prevTrackIndex;(!i[s]||!pt(i[s]))&&(s=-1),s===-1&&(s=i.findIndex(o=>pt(o)&&o.default)),s===-1&&(s=i.findIndex(o=>pt(o))),s>=0&&this.changeTextTrackMode(s,"showing",e),this._prevTrackIndex=-1}}_dispatchRequest(e,n,i){let r=new ne(e,{bubbles:!0,composed:!0,cancelable:!0,detail:i,trigger:n}),s=n?.target||null;s&&s instanceof ie&&(s=s.el),s=!s||s===document||s===window||s===document.body||this._player?.el&&s instanceof Node&&!this._player.el.contains(s)?this._target??this.getPlayer()?.el:s??this._target,this._player?e==="media-play-request"&&!this._player.state.canLoad?s?.dispatchEvent(r):this._player.canPlayQueue._enqueue(e,()=>s?.dispatchEvent(r)):s?.dispatchEvent(r)}_noPlayerWarning(e){}},Lx=Math.min,ul=Math.max,xm=Math.round,fm=Math.floor,Ts=t=>({x:t,y:t});x4=async(t,e,n)=>{let{placement:i="bottom",strategy:r="absolute",middleware:s=[],platform:o}=n,a=s.filter(Boolean),l=await(o.isRTL==null?void 0:o.isRTL(e)),c=await o.getElementRects({reference:t,floating:e,strategy:r}),{x:u,y:d}=j$(c,i,l),p=i,h={},m=0;for(let v=0;v{let i=new Map,r={platform:F4,...n},s={...r.platform,_c:i};return x4(t,e,{...r,platform:s})};Nr=class extends sn{},Tm=class extends Nr{constructor(){super(...arguments),this._idleTimer=-2,this._pausedTracking=!1,this._hideOnMouseLeave=K(!1),this._isMouseOutside=K(!1),this._focusedItem=null,this.defaultDelay=2e3}get hideOnMouseLeave(){let{hideControlsOnMouseLeave:e}=this.$props;return this._hideOnMouseLeave()||e()}set hideOnMouseLeave(e){this._hideOnMouseLeave.set(e)}get showing(){return this.$state.controlsVisible()}show(e=0,n){this._clearIdleTimer(),this._pausedTracking||this._changeVisibility(!0,e,n)}hide(e=this.defaultDelay,n){this._clearIdleTimer(),this._pausedTracking||this._changeVisibility(!1,e,n)}pause(e){this._pausedTracking=!0,this._clearIdleTimer(),this._changeVisibility(!0,0,e)}resume(e){this._pausedTracking=!1,!this.$state.paused()&&this._changeVisibility(!1,this.defaultDelay,e)}onConnect(){S(this._watchMouse.bind(this)),S(this._watchPaused.bind(this));let e=this._onPlay.bind(this),n=this._onPause.bind(this);this.listen("can-play",i=>this.show(0,i)),this.listen("play",e),this.listen("pause",n),this.listen("auto-play-fail",n)}_watchMouse(){let{started:e,pointer:n,paused:i}=this.$state;if(!e()||n()!=="fine")return;let r=this.hideOnMouseLeave;(!r||!this._isMouseOutside())&&S(()=>{i()||this.listen("pointermove",this._onStopIdle.bind(this))}),r&&(this.listen("mouseenter",this._onMouseEnter.bind(this)),this.listen("mouseleave",this._onMouseLeave.bind(this)))}_watchPaused(){let{paused:e,started:n,autoPlayError:i}=this.$state;if(e()||i()&&!n())return;let r=this._onStopIdle.bind(this);S(()=>{let s=this.$state.pointer(),o=s==="coarse",a=[o?"touchend":"pointerup","keydown"];for(let l of a)this.listen(l,r,{passive:!1})})}_onPlay(e){this.show(0,e),this.hide(void 0,e)}_onPause(e){this.show(0,e)}_onMouseEnter(e){this._isMouseOutside.set(!1),this.show(0,e),this.hide(void 0,e)}_onMouseLeave(e){this._isMouseOutside.set(!0),this.hide(0,e)}_clearIdleTimer(){window.clearTimeout(this._idleTimer),this._idleTimer=-1}_onStopIdle(e){e.MEDIA_GESTURE||this._pausedTracking||nk(e)||(Mr(e)&&(e.key==="Escape"?(this.el?.focus(),this._focusedItem=null):this._focusedItem&&(e.preventDefault(),requestAnimationFrame(()=>{this._focusedItem?.focus(),this._focusedItem=null}))),this.show(0,e),this.hide(this.defaultDelay,e))}_changeVisibility(e,n,i){if(n===0){this._onChange(e,i);return}this._idleTimer=window.setTimeout(()=>{this.scope&&this._onChange(e&&!this._pausedTracking,i)},n)}_onChange(e,n){this.$state.controlsVisible()!==e&&(this.$state.controlsVisible.set(e),!e&&document.activeElement&&this.el?.contains(document.activeElement)&&(this._focusedItem=document.activeElement,requestAnimationFrame(()=>this.el?.focus())),this.dispatch("controls-change",{detail:e,trigger:n}))}},Ad=B4;Em=class{constructor(){this.playerId="vds-player",this.mediaId=null,this._data={volume:null,muted:null,time:null,lang:null,captions:null,rate:null},this.saveTime=Ad(()=>{if(B||!this.mediaId)return;let e=(this._data.time??0).toString();localStorage.setItem(this.mediaId,e)},1e3)}async getVolume(){return this._data.volume}async setVolume(e){this._data.volume=e,this.save()}async getMuted(){return this._data.muted}async setMuted(e){this._data.muted=e,this.save()}async getTime(){return this._data.time}async setTime(e){this._data.time=e,this.saveTime()}async getLang(){return this._data.lang}async setLang(e){this._data.lang=e,this.save()}async getCaptions(){return this._data.captions}async setCaptions(e){this._data.captions=e,this.save()}async getPlaybackRate(){return this._data.rate}async setPlaybackRate(e){this._data.rate=e,this.save()}onChange(e,n,i="vds-player"){let r=i?localStorage.getItem(i):null,s=n?localStorage.getItem(n):null;this.playerId=i,this.mediaId=n,this._data={volume:null,muted:null,lang:null,captions:null,...r?JSON.parse(r):{},time:s?+s:null}}save(){if(B||!this.playerId)return;let e=JSON.stringify({...this._data,time:void 0});localStorage.setItem(this.playerId,e)}},Ax=class{constructor(){this.priority=0,this._display=!0,this._video=null,this._track=null,this._tracks=new Set}canRender(e,n){return!!n}attach(e){this._video=e,e&&(e.textTracks.onchange=this._onChange.bind(this))}addTrack(e){this._tracks.add(e),this._attachTrack(e)}removeTrack(e){e[se._native]?.remove?.(),e[se._native]=null,this._tracks.delete(e)}changeTrack(e){let n=e?.[se._native];n&&n.track.mode!=="showing"&&(n.track.mode="showing"),this._track=e}setDisplay(e){this._display=e,this._onChange()}detach(){this._video&&(this._video.textTracks.onchange=null);for(let e of this._tracks)this.removeTrack(e);this._tracks.clear(),this._video=null,this._track=null}_attachTrack(e){var i;if(!this._video)return;let n=e[i=se._native]??(e[i]=this._createTrackElement(e));n instanceof HTMLElement&&(this._video.append(n),n.track.mode=n.default?"showing":"hidden")}_createTrackElement(e){let n=document.createElement("track"),i=e.default||e.mode==="showing",r=e.src&&e.type==="vtt";if(n.id=e.id,r)n.src=e.src;else{let s=function(){URL.revokeObjectURL(this.src),this.removeEventListener("load",s),this.removeEventListener("error",s)},o=new Blob([`WEBVTT `],{type:"text/vtt"});n.src=URL.createObjectURL(o),n.addEventListener("load",s),n.addEventListener("error",s)}return n.label=e.label,n.kind=e.kind,n.default=i,e.language&&(n.srclang=e.language),i&&!r&&this._copyCues(e,n.track),n}_copyCues(e,n){if(!(e.src&&e.type==="vtt"||n.cues?.length))for(let i of e.cues)n.addCue(i)}_onChange(e){for(let n of this._tracks){let i=n[se._native]?.track;if(!i)continue;if(!this._display){i.mode="disabled";continue}let r=i.mode==="showing";r&&this._copyCues(n,i),n.setMode(r?"showing":"disabled",e)}}},Sm=class{constructor(e){this._media=e,this._video=null,this._renderers=[],this._nativeDisplay=!1,this._nativeRenderer=null,this._customRenderer=null;let n=e.textTracks;this._textTracks=n,S(this._watchControls.bind(this)),ae(this._detach.bind(this)),L(n,"add",this._onAddTrack.bind(this)),L(n,"remove",this._onRemoveTrack.bind(this)),L(n,"mode-change",this._update.bind(this))}_watchControls(){let{$state:e,$iosControls:n}=this._media;this._nativeDisplay=e.controls()||n(),this._update()}add(e){this._renderers.push(e),this._update()}remove(e){e.detach(),this._renderers.splice(this._renderers.indexOf(e),1),this._update()}_attachVideo(e){requestAnimationFrame(()=>{if(this._video=e,e){this._nativeRenderer=new Ax,this._nativeRenderer.attach(e);for(let n of this._textTracks)this._addNativeTrack(n)}this._update()})}_addNativeTrack(e){pt(e)&&this._nativeRenderer?.addTrack(e)}_removeNativeTrack(e){pt(e)&&this._nativeRenderer?.removeTrack(e)}_onAddTrack(e){this._addNativeTrack(e.detail)}_onRemoveTrack(e){this._removeNativeTrack(e.detail)}_update(){let e=this._textTracks.selected;if(this._video&&(this._nativeDisplay||e?.[se._nativeHLS])){this._customRenderer?.changeTrack(null),this._nativeRenderer?.setDisplay(!0),this._nativeRenderer?.changeTrack(e);return}if(this._nativeRenderer?.setDisplay(!1),this._nativeRenderer?.changeTrack(null),!e){this._customRenderer?.changeTrack(null);return}let n=this._renderers.sort((i,r)=>i.priority-r.priority).find(i=>i.canRender(e,this._video));this._customRenderer!==n&&(this._customRenderer?.detach(),n?.attach(this._video),this._customRenderer=n??null),n?.changeTrack(e)}_detach(){this._nativeRenderer?.detach(),this._nativeRenderer=null,this._customRenderer?.detach(),this._customRenderer=null}},ik=H4;Pm=class extends Bu{constructor(){super(),this._canLoad=!1,this._defaults={},this._storage=null,this._preferredLang=null,this._selectCaptions=ik(async()=>{if(!this._canLoad||this.selected||await this._storage?.getCaptions()===!1)return;!this._preferredLang&&this._storage&&(this._preferredLang=await this._storage.getLang());let e=this._preferredLang&&this._items.find(i=>pt(i)&&i.language===this._preferredLang),n=this._defaults.captions;e?e.mode="showing":n&&n&&(n.mode="showing"),this._storage?.setLang?.(this._preferredLang??n?.language??null)},300),this._onTrackModeChangeBind=this._onTrackModeChange.bind(this)}get selected(){return this._items.find(n=>n.mode==="showing"&&pt(n))??null}get preferredLang(){return this._preferredLang}set preferredLang(e){this._preferredLang=e}add(e,n){let i=e instanceof zn,r=i?e:new zn(e),s=e.kind==="captions"||e.kind==="subtitles"?"captions":e.kind;return this._defaults[s]&&e.default&&delete e.default,r.addEventListener("mode-change",this._onTrackModeChangeBind),this[le._add](r,n),r[se._crossOrigin]=this[se._crossOrigin],this._canLoad&&r[se._canLoad](),e.default&&(this._defaults[s]=r,s!=="captions"?r.mode="showing":this._selectCaptions()),this}remove(e,n){if(this._items.includes(e))return e===this._defaults[e.kind]&&delete this._defaults[e.kind],e.mode="disabled",e[se._onModeChange]=null,e.removeEventListener("mode-change",this._onTrackModeChangeBind),this[le._remove](e,n),this}clear(e){for(let n of[...this._items])this.remove(n,e);return this}getById(e){return this._items.find(n=>n.id===e)??null}getByKind(e){let n=Array.isArray(e)?e:[e];return this._items.filter(i=>n.includes(i.kind))}[se._canLoad](){if(!this._canLoad){for(let e of this._items)e[se._canLoad]();this._canLoad=!0,this._selectCaptions()}}_onTrackModeChange(e){let n=e.detail;if(this._storage&&pt(n)&&(this._storage.setCaptions?.(n.mode==="showing"),this._storage?.setLang?.(this._preferredLang??n?.language??null)),n.mode==="showing"){let i=pt(n)?["captions","subtitles"]:[n.kind];for(let r of this._items)r.mode==="showing"&&r!=n&&i.includes(r.kind)&&(r.mode="disabled")}this.dispatchEvent(new ne("mode-change",{detail:e.detail,trigger:e}))}setStorage(e){this._storage=e}},Uu=Symbol(0),Cm=class extends Bu{get selected(){return this._items.find(e=>e.selected)??null}get selectedIndex(){return this._items.findIndex(e=>e.selected)}[le._onRemove](e,n){this[le._select](e,!1,n)}[le._add](e,n){e[Uu]=!1,Object.defineProperty(e,"selected",{get(){return this[Uu]},set:i=>{this.readonly||(this[le._onUserSelect]?.(),this[le._select](e,i))}}),super[le._add](e,n)}[le._select](e,n,i){if(n===e?.[Uu])return;let r=this.selected;e&&(e[Uu]=n),(n?r!==e:r===e)&&(r&&(r[Uu]=!1),this.dispatchEvent(new ne("change",{detail:{prev:r,current:this.selected},trigger:i})))}},Mm=class extends Cm{getById(e){return e===""?null:this._items.find(n=>n.id===e)??null}},q4=Symbol(0),W4=Symbol(0),Un={_setAuto:q4,_enableAuto:W4},$m=class extends Cm{constructor(){super(...arguments),this._auto=!1,this.switch="current"}get auto(){return this._auto||this.readonly}[le._onUserSelect](){this[Un._setAuto](!1)}[le._onReset](e){this[Un._setAuto](!1,e)}autoSelect(e){this.readonly||this._auto||!this[Un._enableAuto]||(this[Un._enableAuto]?.(),this[Un._setAuto](!0,e))}[Un._setAuto](e,n){this._auto!==e&&(this._auto=e,this.dispatchEvent(new ne("auto-change",{detail:e,trigger:n})))}};SR={togglePaused:"k Space",toggleMuted:"m",toggleFullscreen:"f",togglePictureInPicture:"i",toggleCaptions:"c",seekBackward:"j J ArrowLeft",seekForward:"l L ArrowRight",volumeUp:"ArrowUp",volumeDown:"ArrowDown",speedUp:">",slowDown:"<"},W$=new Set(["Shift","Alt","Meta","Control"]),K4='button, [role="button"]',K$='input, textarea, select, [contenteditable], [role^="menuitem"], [role="timer"]',Dx=class extends Nr{constructor(e){super(),this._media=e,this._timeSlider=null}onConnect(){S(this._onTargetChange.bind(this))}_onTargetChange(){let{keyDisabled:e,keyTarget:n}=this.$props;if(e())return;let i=n()==="player"?this.el:document,r=K(!1);i===this.el?(this.listen("focusin",()=>r.set(!0)),this.listen("focusout",s=>{this.el.contains(s.target)||r.set(!1)})):(N(r)||r.set(document.querySelector("[data-media-player]")===this.el),L(document,"focusin",s=>{let o=s.composedPath().find(a=>a instanceof Element&&a.localName==="media-player");o!==void 0&&r.set(this.el===o)})),S(()=>{r()&&(L(i,"keyup",this._onKeyUp.bind(this)),L(i,"keydown",this._onKeyDown.bind(this)),L(i,"keydown",this._onPreventVideoKeys.bind(this),{capture:!0}))})}_onKeyUp(e){let n=document.activeElement;if(!e.key||!this.$state.canSeek()||n?.matches(K$))return;let{method:i,value:r}=this._getMatchingMethod(e);if(!Z(r)&&!ut(r)){r?.callback(e);return}i?.startsWith("seek")&&(e.preventDefault(),e.stopPropagation(),this._timeSlider?(this._forwardTimeKeyboardEvent(e,i==="seekForward"),this._timeSlider=null):(this._media.remote.seek(this._seekTotal,e),this._seekTotal=void 0)),i?.startsWith("volume")&&this.el.querySelector("[data-media-volume-slider]")?.dispatchEvent(new KeyboardEvent("keyup",{key:i==="volumeUp"?"Up":"Down",shiftKey:e.shiftKey,trigger:e}))}_onKeyDown(e){if(!e.key||W$.has(e.key))return;let n=document.activeElement;if(n?.matches(K$)||Tu(e)&&n?.matches(K4))return;let{method:i,value:r}=this._getMatchingMethod(e);if(!Z(r)&&!ut(r)){r?.callback(e);return}if(!i&&!e.metaKey&&/[0-9]/.test(e.key)){e.preventDefault(),e.stopPropagation(),this._media.remote.seek(this.$state.duration()/10*Number(e.key),e);return}if(i){switch(e.preventDefault(),e.stopPropagation(),i){case"seekForward":case"seekBackward":this._seeking(e,i,i==="seekForward");break;case"volumeUp":case"volumeDown":let s=this.el.querySelector("[data-media-volume-slider]");if(s)s.dispatchEvent(new KeyboardEvent("keydown",{key:i==="volumeUp"?"Up":"Down",shiftKey:e.shiftKey,trigger:e}));else{let a=e.shiftKey?.1:.05;this._media.remote.changeVolume(this.$state.volume()+(i==="volumeUp"?+a:-a),e)}break;case"toggleFullscreen":this._media.remote.toggleFullscreen("prefer-media",e);break;case"speedUp":case"slowDown":let o=this.$state.playbackRate();this._media.remote.changePlaybackRate(Math.max(.25,Math.min(2,o+(i==="speedUp"?.25:-.25))),e);break;default:this._media.remote[i]?.(e)}this.$state.lastKeyboardAction.set({action:i,event:e})}}_onPreventVideoKeys(e){ER(e.target)&&this._getMatchingMethod(e).method&&e.preventDefault()}_getMatchingMethod(e){let n={...this.$props.keyShortcuts(),...this._media.ariaKeys},i=Object.keys(n).find(r=>{let s=n[r],o=ut(s)?s.join(" "):Z(s)?s:s?.keys;return(ut(o)?o:o?.split(" "))?.some(a=>Y4(a).replace(/Control/g,"Ctrl").split("+").every(l=>W$.has(l)?e[l.toLowerCase()+"Key"]:e.key===l.replace("Space"," ")))});return{method:i,value:i?n[i]:null}}_calcSeekAmount(e,n){let i=e.shiftKey?10:5;return this._seekTotal=Math.max(0,Math.min((this._seekTotal??this.$state.currentTime())+(n==="seekForward"?+i:-i),this.$state.duration()))}_forwardTimeKeyboardEvent(e,n){this._timeSlider?.dispatchEvent(new KeyboardEvent(e.type,{key:n?"Right":"Left",shiftKey:e.shiftKey,trigger:e}))}_seeking(e,n,i){this.$state.canSeek()&&(this._timeSlider||(this._timeSlider=this.el.querySelector("[data-media-time-slider]")),this._timeSlider?this._forwardTimeKeyboardEvent(e,i):this._media.remote.seeking(this._calcSeekAmount(e,n),e))}},G4=["!","@","#","$","%","^","&","*","(",")"];Rm=class extends sn{constructor(e){super(),this._shortcut=e}onAttach(e){let{$props:n,ariaKeys:i}=Ee(),r=e.getAttribute("aria-keyshortcuts");if(r){i[this._shortcut]=r,B||ae(()=>{delete i[this._shortcut]});return}let s=n.keyShortcuts()[this._shortcut];if(s){let o=ut(s)?s.join(" "):Z(s)?s:s?.keys;e.setAttribute("aria-keyshortcuts",ut(o)?o.join(" "):o)}}},PR=/\.(m4a|m4b|mp4a|mpga|mp2|mp2a|mp3|m2a|m3a|wav|weba|aac|oga|spx)($|\?)/i,CR=new Set(["audio/mpeg","audio/ogg","audio/3gp","audio/mp4","audio/webm","audio/flac"]),MR=/\.(mp4|og[gv]|webm|mov|m4v)(#t=[,\d+]+)?($|\?)/i,$R=new Set(["video/mp4","video/webm","video/3gp","video/ogg","video/avi","video/mpeg"]),RR=/\.(m3u8)($|\?)/i,IR=new Set(["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"]);Im=class{constructor(){this.name="audio"}canPlay(e){return rk(e)?B||e.type==="?"||s4(this.target,e.type):!1}mediaType(){return"audio"}async load(e){if(B)throw Error("[vidstack] can not load audio provider server-side");return new(await Promise.resolve().then(()=>(g$(),m$))).AudioProvider(this.target,e)}},qu=class{constructor(){this.name="video"}canPlay(e){return sk(e)?B||e.type==="?"||o4(this.target,e.type):!1}mediaType(){return"video"}async load(e){if(B)throw Error("[vidstack] can not load video provider server-side");return new(await Promise.resolve().then(()=>(ax(),y$))).VideoProvider(this.target,e)}},LR=class AR extends qu{constructor(){super(...arguments),this.name="hls"}canPlay(e){return AR.supported&&yo(e)}async load(e){if(B)throw Error("[vidstack] can not load hls provider server-side");return new(await Promise.resolve().then(()=>(w$(),v$))).HLSProvider(this.target,e)}};LR.supported=sm();DR=LR,Lm=class{constructor(){this.name="vimeo"}preconnect(){let e=["https://i.vimeocdn.com","https://f.vimeocdn.com","https://fresnel.vimeocdn.com"];for(let n of e)Ai(n)}canPlay(e){return Z(e.src)&&e.type==="video/vimeo"}mediaType(){return"video"}async load(e){if(B)throw Error("[vidstack] can not load vimeo provider server-side");return new(await Promise.resolve().then(()=>(k$(),x$))).VimeoProvider(this.target,e)}async loadPoster(e,n,i){let{resolveVimeoVideoId:r,getVimeoVideoInfo:s}=await Promise.resolve().then(()=>(fx(),b$));if(!Z(e.src))return null;let{videoId:o}=r(e.src);return o?s(o,i).then(a=>a?a.poster:null):null}},Am=class{constructor(){this.name="youtube"}preconnect(){let e=["https://www.google.com","https://i.ytimg.com","https://googleads.g.doubleclick.net","https://static.doubleclick.net"];for(let n of e)Ai(n)}canPlay(e){return Z(e.src)&&e.type==="video/youtube"}mediaType(){return"video"}async load(e){if(B)throw Error("[vidstack] can not load youtube provider server-side");return new(await Promise.resolve().then(()=>(S$(),E$))).YouTubeProvider(this.target,e)}async loadPoster(e,n,i){let{findYouTubePoster:r,resolveYouTubeVideoId:s}=await Promise.resolve().then(()=>(vx(),T$)),o=Z(e.src)&&s(e.src);return o?r(o,i):null}},Cx=Symbol(0),Q4=["autoPlay","canAirPlay","canFullscreen","canGoogleCast","canLoad","canLoadPoster","canPictureInPicture","canPlay","canSeek","ended","fullscreen","isAirPlayConnected","isGoogleCastConnected","live","liveEdge","loop","mediaType","muted","paused","pictureInPicture","playing","playsInline","remotePlaybackState","remotePlaybackType","seeking","started","streamType","viewType","waiting"],X4={artist:"",autoplay:!1,autoPlay:!1,clipStartTime:0,clipEndTime:0,controls:!1,currentTime:0,crossorigin:null,crossOrigin:null,duration:-1,fullscreenOrientation:"landscape",googleCast:{},load:"visible",posterLoad:"visible",logLevel:"silent",loop:!1,muted:!1,paused:!0,playsinline:!1,playsInline:!1,playbackRate:1,poster:"",preload:"metadata",preferNativeHLS:!1,src:"",title:"",controlsDelay:2e3,hideControlsOnMouseLeave:!1,viewType:"unknown",streamType:"unknown",volume:1,liveEdgeTolerance:10,minLiveDVRWindow:60,keyDisabled:!1,keyTarget:"player",keyShortcuts:SR,storage:null},Dm=class extends Nr{constructor(e,n){super(),this._type=e,this._callback=n}async onAttach(e){if(B)return;let n=this.$props[this._type]();if(n==="eager")requestAnimationFrame(this._callback);else if(n==="idle")Ib(this._callback);else if(n==="visible"){let i,r=new IntersectionObserver(s=>{this.scope&&s[0].isIntersecting&&(i?.(),i=void 0,this._callback())});r.observe(e),i=ae(()=>r.disconnect())}}},Nx=class{constructor(e,n){this._handle=e,this._media=n,this._notify=(i,...r)=>{B||this._handle(new ne(i,{detail:r?.[0],trigger:r?.[1]}))}}async _ready(e,n){if(!B)return el(async()=>{this._media;let{autoPlay:i,canPlay:r,started:s,duration:o,seekable:a,buffered:l,remotePlaybackInfo:c,playsInline:u}=this._media.$state;if(r())return;let d={duration:e?.duration??o(),seekable:e?.seekable??a(),buffered:e?.buffered??l(),provider:this._media.$provider()};this._notify("can-play",d,n),Li();let p=this._media.$provider(),{storage:h}=this._media,{muted:m,volume:v,clipStartTime:w,playbackRate:f}=this._media.$props,g=c()?.savedState?.currentTime,y=c()?.savedState?.paused===!1,T=g??await h?.getTime()??w(),P=y||i();p&&(p.setVolume(await h?.getVolume()??v()),p.setMuted(await h?.getMuted()??m()),p.setPlaybackRate?.(await h?.getPlaybackRate()??f()),p.setPlaysInline?.(u()),T>0&&p.setCurrentTime(T)),r()&&P&&!s()&&await this._attemptAutoplay(n),c.set(null)})}async _attemptAutoplay(e){let{player:n,$state:{autoPlaying:i,muted:r}}=this._media;i.set(!0);let s=new ne("auto-play-attempt",{trigger:e});try{await n.play(s)}catch{}}},Ox=class{constructor(){this._queue=new Map}_enqueue(e,n){this._queue.set(e,n)}_serve(e){let n=this._peek(e);return this._queue.delete(e),n}_peek(e){return this._queue.get(e)}_delete(e){this._queue.delete(e)}_clear(){this._queue.clear()}},Nm=class{constructor(){this._serving=!1,this._pending=$r(),this._queue=new Map}get _size(){return this._queue.size}get _isServing(){return this._serving}async _waitForFlush(){this._serving||await this._pending.promise}_enqueue(e,n){if(this._serving){n();return}this._queue.delete(e),this._queue.set(e,n)}_serve(e){this._queue.get(e)?.(),this._queue.delete(e)}_start(){this._flush(),this._serving=!0,this._queue.size>0&&this._flush()}_stop(){this._serving=!1}_reset(){this._stop(),this._queue.clear(),this._release()}_flush(){for(let e of this._queue.keys())this._serve(e);this._release()}_release(){this._pending.resolve(),this._pending=$r()}};Fx=class extends Nr{constructor(e,n,i){super(),this._stateMgr=e,this._request=n,this._media=i,this._providerQueue=new Nm,this._wasPIPActive=!1,this._$provider=i.$provider,this._controls=new Tm,this._fullscreen=new wm,this._orientation=new Zx}onAttach(){this.listen("fullscreen-change",this._onFullscreenChange.bind(this))}onConnect(){let e=Object.getOwnPropertyNames(Object.getPrototypeOf(this)),n=this._handleRequest.bind(this);for(let i of e)i.startsWith("media-")&&this.listen(i,n);this._attachLoadPlayListener(),S(this._watchProvider.bind(this)),S(this._onControlsDelayChange.bind(this)),S(this._onAirPlaySupportChange.bind(this)),S(this._onGoogleCastSupportChange.bind(this)),S(this._onFullscreenSupportChange.bind(this)),S(this._onPiPSupportChange.bind(this))}onDestroy(){this._providerQueue._reset()}_attachLoadPlayListener(){let{load:e}=this.$props,{canLoad:n}=this.$state;if(e()!=="play"||n())return;let i=this.listen("media-play-request",r=>{this._handleLoadPlayStrategy(r),i()})}_watchProvider(){let e=this._$provider(),n=this.$state.canPlay();return e&&n&&this._providerQueue._start(),()=>{this._providerQueue._stop()}}_handleRequest(e){e.stopPropagation(),!e.defaultPrevented&&this[e.type]&&(N(this._$provider)?this[e.type](e):this._providerQueue._enqueue(e.type,()=>{N(this._$provider)&&this[e.type](e)}))}async _play(e){if(B)return;let{canPlay:n,paused:i,autoPlaying:r}=this.$state;if(!this._handleLoadPlayStrategy(e)&&!(!N(i)&&!this._request._looping)){e&&this._request._queue._enqueue("media-play-request",e);try{let s=N(this._$provider);return Mx(s,N(n)),await s.play()}catch(s){let o=this.createEvent("play-fail",{detail:nr(s),trigger:e});throw o.autoPlay=r(),this._stateMgr._handle(o),s}}}_handleLoadPlayStrategy(e){let{load:n}=this.$props,{canLoad:i}=this.$state;if(n()==="play"&&!i()){let r=this.createEvent("media-start-loading",{trigger:e});return this.dispatchEvent(r),this._providerQueue._enqueue("media-play-request",async()=>{try{await this._play(r)}catch{}}),!0}return!1}async _pause(e){if(B)return;let{canPlay:n,paused:i}=this.$state;if(!N(i)){e&&this._request._queue._enqueue("media-pause-request",e);try{let r=N(this._$provider);return Mx(r,N(n)),await r.pause()}catch(r){throw this._request._queue._delete("media-pause-request"),r}}}_seekToLiveEdge(e){if(B)return;let{canPlay:n,live:i,liveEdge:r,canSeek:s,liveSyncPosition:o,seekableEnd:a,userBehindLiveEdge:l}=this.$state;if(l.set(!1),N(()=>!i()||r()||!s()))return;let c=N(this._$provider);Mx(c,N(n)),e&&this._request._queue._enqueue("media-seek-request",e);let u=a()-2;c.setCurrentTime(Math.min(u,o()??u))}async _enterFullscreen(e="prefer-media",n){if(B)return;let i=this._getFullscreenAdapter(e);if(G$(e,i),!i.active)return N(this.$state.pictureInPicture)&&(this._wasPIPActive=!0,await this._exitPictureInPicture(n)),n&&this._request._queue._enqueue("media-enter-fullscreen-request",n),i.enter()}async _exitFullscreen(e="prefer-media",n){if(B)return;let i=this._getFullscreenAdapter(e);if(G$(e,i),!!i.active){n&&this._request._queue._enqueue("media-exit-fullscreen-request",n);try{let r=await i.exit();return this._wasPIPActive&&N(this.$state.canPictureInPicture)&&await this._enterPictureInPicture(),r}finally{this._wasPIPActive=!1}}}_getFullscreenAdapter(e){let n=N(this._$provider);return e==="prefer-media"&&this._fullscreen.supported||e==="media"?this._fullscreen:n?.fullscreen}async _enterPictureInPicture(e){if(!B&&(this._throwIfPIPNotSupported(),!this.$state.pictureInPicture()))return e&&this._request._queue._enqueue("media-enter-pip-request",e),await this._$provider().pictureInPicture.enter()}async _exitPictureInPicture(e){if(!B&&(this._throwIfPIPNotSupported(),!!this.$state.pictureInPicture()))return e&&this._request._queue._enqueue("media-exit-pip-request",e),await this._$provider().pictureInPicture.exit()}_throwIfPIPNotSupported(){if(!this.$state.canPictureInPicture())throw Error("[vidstack] no pip support")}_onControlsDelayChange(){this._controls.defaultDelay=this.$props.controlsDelay()}_onAirPlaySupportChange(){let{canAirPlay:e}=this.$state,n=!!this._$provider()?.airPlay?.supported;e.set(n)}_onGoogleCastSupportChange(){let{canGoogleCast:e,source:n}=this.$state,i=Fu&&!dm&&pm(n());e.set(i)}_onFullscreenSupportChange(){let{canFullscreen:e}=this.$state,n=this._fullscreen.supported||!!this._$provider()?.fullscreen?.supported;e.set(n)}_onPiPSupportChange(){let{canPictureInPicture:e}=this.$state,n=!!this._$provider()?.pictureInPicture?.supported;e.set(n)}async"media-airplay-request"(e){try{await this._requestAirPlay(e)}catch{}}async _requestAirPlay(e){try{let n=this._$provider()?.airPlay;if(!n?.supported)throw Error("No AirPlay adapter.");return e&&this._request._queue._enqueue("media-airplay-request",e),await n.prompt()}catch(n){throw this._request._queue._delete("media-airplay-request"),n}}async"media-google-cast-request"(e){try{await this._requestGoogleCast(e)}catch{}}async _requestGoogleCast(e){try{let{canGoogleCast:n}=this.$state;if(!N(n))throw new Error("Cast not available.");if(Ai("https://www.gstatic.com"),!this._googleCastLoader){let r=await Promise.resolve().then(()=>(Ex(),R$)).then(function(s){return s.d});this._googleCastLoader=new r.GoogleCastLoader}await this._googleCastLoader.prompt(this._media),e&&this._request._queue._enqueue("media-google-cast-request",e);let i=N(this.$state.remotePlaybackState)!=="disconnected";i&&this.$state.remotePlaybackInfo.set(r=>({...r,savedState:{paused:N(this.$state.paused),currentTime:N(this.$state.currentTime)}})),this.$state.remotePlaybackLoader.set(i?this._googleCastLoader:null)}catch(n){throw this._request._queue._delete("media-google-cast-request"),n}}"media-audio-track-change-request"(e){if(this._media.audioTracks.readonly)return;let n=e.detail,i=this._media.audioTracks[n];if(i){let r=e.type;this._request._queue._enqueue(r,e),i.selected=!0}}async"media-enter-fullscreen-request"(e){try{await this._enterFullscreen(e.detail,e)}catch(n){this._onFullscreenError(n,e)}}async"media-exit-fullscreen-request"(e){try{await this._exitFullscreen(e.detail,e)}catch(n){this._onFullscreenError(n,e)}}async _onFullscreenChange(e){let n=N(this.$props.fullscreenOrientation),i=e.detail;if(!(Qe(n)||!this._orientation.supported))if(i){if(this._orientation.locked)return;this.dispatch("media-orientation-lock-request",{detail:n,trigger:e})}else this._orientation.locked&&this.dispatch("media-orientation-unlock-request",{trigger:e})}_onFullscreenError(e,n){this._stateMgr._handle(this.createEvent("fullscreen-error",{detail:nr(e)}))}async"media-orientation-lock-request"(e){let n=e.type;try{this._request._queue._enqueue(n,e),await this._orientation.lock(e.detail)}catch{this._request._queue._delete(n)}}async"media-orientation-unlock-request"(e){let n=e.type;try{this._request._queue._enqueue(n,e),await this._orientation.unlock()}catch{this._request._queue._delete(n)}}async"media-enter-pip-request"(e){try{await this._enterPictureInPicture(e)}catch(n){this._onPictureInPictureError(n,e)}}async"media-exit-pip-request"(e){try{await this._exitPictureInPicture(e)}catch(n){this._onPictureInPictureError(n,e)}}_onPictureInPictureError(e,n){this._stateMgr._handle(this.createEvent("picture-in-picture-error",{detail:nr(e)}))}"media-live-edge-request"(e){let{live:n,liveEdge:i,canSeek:r}=this.$state;if(!(!n()||i()||!r())){this._request._queue._enqueue("media-seek-request",e);try{this._seekToLiveEdge()}catch{this._request._queue._delete("media-seek-request")}}}async"media-loop-request"(e){try{this._request._looping=!0,this._request._replaying=!0,await this._play(e)}catch{this._request._looping=!1}}async"media-pause-request"(e){if(!this.$state.paused())try{await this._pause(e)}catch{}}async"media-play-request"(e){if(this.$state.paused())try{await this._play(e)}catch{}}"media-rate-change-request"(e){let{playbackRate:n,canSetPlaybackRate:i}=this.$state;if(n()===e.detail||!i())return;let r=this._$provider();r?.setPlaybackRate&&(this._request._queue._enqueue("media-rate-change-request",e),r.setPlaybackRate(e.detail))}"media-quality-change-request"(e){if(this._media.qualities.readonly)return;this._request._queue._enqueue("media-quality-change-request",e);let n=e.detail;if(n<0)this._media.qualities.autoSelect(e);else{let i=this._media.qualities[n];i&&(i.selected=!0)}}"media-pause-controls-request"(e){let n=e.type;this._request._queue._enqueue(n,e),this._controls.pause(e)}"media-resume-controls-request"(e){let n=e.type;this._request._queue._enqueue(n,e),this._controls.resume(e)}"media-seek-request"(e){let{seekableStart:n,seekableEnd:i,ended:r,canSeek:s,live:o,userBehindLiveEdge:a,clipStartTime:l}=this.$state;r()&&(this._request._replaying=!0);let c=e.type;this._request._seeking=!1,this._request._queue._delete(c);let u=Math.min(Math.max(n()+.1,e.detail+l()),i()-.1);!Number.isFinite(u)||!s()||(this._request._queue._enqueue(c,e),this._$provider().setCurrentTime(u),o()&&e.isOriginTrusted&&Math.abs(i()-u)>=2&&a.set(!0))}"media-seeking-request"(e){let n=e.type;this._request._queue._enqueue(n,e),this.$state.seeking.set(!0),this._request._seeking=!0}"media-start-loading"(e){if(this.$state.canLoad())return;let n=e.type;this._request._queue._enqueue(n,e),this._stateMgr._handle(this.createEvent("can-load"))}"media-poster-start-loading"(e){if(this.$state.canLoadPoster())return;let n=e.type;this._request._queue._enqueue(n,e),this._stateMgr._handle(this.createEvent("can-load-poster"))}"media-text-track-change-request"(e){let{index:n,mode:i}=e.detail,r=this._media.textTracks[n];if(r){let s=e.type;this._request._queue._enqueue(s,e),r.setMode(i,e)}}"media-mute-request"(e){if(this.$state.muted())return;let n=e.type;this._request._queue._enqueue(n,e),this._$provider().setMuted(!0)}"media-unmute-request"(e){let{muted:n,volume:i}=this.$state;if(!n())return;let r=e.type;this._request._queue._enqueue(r,e),this._media.$provider().setMuted(!1),i()===0&&(this._request._queue._enqueue(r,e),this._$provider().setVolume(.25))}"media-volume-change-request"(e){let{muted:n,volume:i}=this.$state,r=e.detail;if(i()===r)return;let s=e.type;this._request._queue._enqueue(s,e),this._$provider().setVolume(r),r>0&&n()&&(this._request._queue._enqueue(s,e),this._$provider().setMuted(!1))}_logError(e,n,i){}};Vx=class{constructor(){this._seeking=!1,this._looping=!1,this._replaying=!1,this._queue=new Ox}},Z4=new Set(["auto-play","auto-play-fail","can-load","sources-change","source-change","load-start","abort","error","loaded-metadata","loaded-data","can-play","play","play-fail","pause","playing","seeking","seeked","waiting"]),zx=class extends Nr{constructor(e,n){super(),this._request=e,this._media=n,this._trackedEvents=new Map,this._clipEnded=!1,this._firingWaiting=!1,this._isPlayingOnDisconnect=!1,this.seeking=Ad(i=>{let{seeking:r,realCurrentTime:s,paused:o}=this.$state;r.set(!0),s.set(i.detail),this._satisfyRequest("media-seeking-request",i),o()&&(this._waitingTrigger=i,this._fireWaiting())},150,{leading:!0}),this._fireWaiting=ik(()=>{if(!this._waitingTrigger)return;this._firingWaiting=!0;let{waiting:i,playing:r}=this.$state;i.set(!0),r.set(!1);let s=this.createEvent("waiting",{trigger:this._waitingTrigger});this._trackedEvents.set("waiting",s),this.dispatch(s),this._waitingTrigger=void 0,this._firingWaiting=!1},300)}onAttach(e){e.setAttribute("aria-busy","true"),this.listen("fullscreen-change",this["fullscreen-change"].bind(this)),this.listen("fullscreen-error",this["fullscreen-error"].bind(this)),this.listen("orientation-change",this["orientation-change"].bind(this))}onConnect(e){S(this._watchCanSetVolume.bind(this)),this._addTextTrackListeners(),this._addQualityListeners(),this._addAudioTrackListeners(),this._resumePlaybackOnConnect(),ae(this._pausePlaybackOnDisconnect.bind(this))}_handle(e){if(!this.scope)return;let n=e.type;this[e.type]?.(e),B||(Z4.has(n)&&this._trackedEvents.set(n,e),this.dispatch(e))}_resumePlaybackOnConnect(){this._isPlayingOnDisconnect&&(requestAnimationFrame(()=>{this.scope&&this._media.remote.play(new ne("dom-connect"))}),this._isPlayingOnDisconnect=!1)}_pausePlaybackOnDisconnect(){this._isPlayingOnDisconnect||(this._isPlayingOnDisconnect=!this._media.$state.paused(),this._media.$provider()?.pause())}_resetTracking(){this._stopWaiting(),this._clipEnded=!1,this._request._replaying=!1,this._request._looping=!1,this._firingWaiting=!1,this._waitingTrigger=void 0,this._trackedEvents.clear()}_satisfyRequest(e,n){let i=this._request._queue._serve(e);i&&(n.request=i,n.triggers.add(i))}_addTextTrackListeners(){this._onTextTracksChange(),this._onTextTrackModeChange();let e=this._media.textTracks;L(e,"add",this._onTextTracksChange.bind(this)),L(e,"remove",this._onTextTracksChange.bind(this)),L(e,"mode-change",this._onTextTrackModeChange.bind(this))}_addQualityListeners(){let e=this._media.qualities;L(e,"add",this._onQualitiesChange.bind(this)),L(e,"remove",this._onQualitiesChange.bind(this)),L(e,"change",this._onQualityChange.bind(this)),L(e,"auto-change",this._onAutoQualityChange.bind(this)),L(e,"readonly-change",this._onCanSetQualityChange.bind(this))}_addAudioTrackListeners(){let e=this._media.audioTracks;L(e,"add",this._onAudioTracksChange.bind(this)),L(e,"remove",this._onAudioTracksChange.bind(this)),L(e,"change",this._onAudioTrackChange.bind(this))}_onTextTracksChange(e){let{textTracks:n}=this.$state;n.set(this._media.textTracks.toArray()),this.dispatch("text-tracks-change",{detail:n(),trigger:e})}_onTextTrackModeChange(e){e&&this._satisfyRequest("media-text-track-change-request",e);let n=this._media.textTracks.selected,{textTrack:i}=this.$state;i()!==n&&(i.set(n),this.dispatch("text-track-change",{detail:n,trigger:e}))}_onAudioTracksChange(e){let{audioTracks:n}=this.$state;n.set(this._media.audioTracks.toArray()),this.dispatch("audio-tracks-change",{detail:n(),trigger:e})}_onAudioTrackChange(e){let{audioTrack:n}=this.$state;n.set(this._media.audioTracks.selected),e&&this._satisfyRequest("media-audio-track-change-request",e),this.dispatch("audio-track-change",{detail:n(),trigger:e})}_onQualitiesChange(e){let{qualities:n}=this.$state;n.set(this._media.qualities.toArray()),this.dispatch("qualities-change",{detail:n(),trigger:e})}_onQualityChange(e){let{quality:n}=this.$state;n.set(this._media.qualities.selected),e&&this._satisfyRequest("media-quality-change-request",e),this.dispatch("quality-change",{detail:n(),trigger:e})}_onAutoQualityChange(){this.$state.autoQuality.set(this._media.qualities.auto)}_onCanSetQualityChange(){this.$state.canSetQuality.set(!this._media.qualities.readonly)}_watchCanSetVolume(){let{canSetVolume:e,isGoogleCastConnected:n}=this.$state;if(n()){e.set(!1);return}rR().then(e.set)}"provider-change"(e){let n=this._media.$provider(),i=e.detail;n?.type!==i?.type&&(n?.destroy?.(),n?.scope?.dispose(),this._media.$provider.set(e.detail),n&&e.detail===null&&this._resetMediaState(e))}"provider-loader-change"(e){}"auto-play"(e){this.$state.autoPlayError.set(null)}"auto-play-fail"(e){this.$state.autoPlayError.set(e.detail),this._resetTracking()}"can-load"(e){this.$state.canLoad.set(!0),this._trackedEvents.set("can-load",e),this._media.textTracks[se._canLoad](),this._satisfyRequest("media-start-loading",e)}"can-load-poster"(e){this.$state.canLoadPoster.set(!0),this._trackedEvents.set("can-load-poster",e),this._satisfyRequest("media-poster-start-loading",e)}"media-type-change"(e){let n=this._trackedEvents.get("source-change");n&&e.triggers.add(n);let i=this.$state.viewType();this.$state.mediaType.set(e.detail);let r=this.$state.providedViewType(),s=r==="unknown"?e.detail:r;i!==s&&(B?this.$state.inferredViewType.set(s):setTimeout(()=>{requestAnimationFrame(()=>{this.scope&&(this.$state.inferredViewType.set(e.detail),this.dispatch("view-type-change",{detail:s,trigger:e}))})},0))}"stream-type-change"(e){let n=this._trackedEvents.get("source-change");n&&e.triggers.add(n);let{streamType:i,inferredStreamType:r}=this.$state;r.set(e.detail),e.detail=i()}"rate-change"(e){let{storage:n}=this._media,{canPlay:i}=this.$state;this.$state.playbackRate.set(e.detail),this._satisfyRequest("media-rate-change-request",e),i()&&n?.setPlaybackRate?.(e.detail)}"remote-playback-change"(e){let{remotePlaybackState:n,remotePlaybackType:i}=this.$state,{type:r,state:s}=e.detail,o=s==="connected";i.set(r),n.set(s);let a=r==="airplay"?"media-airplay-request":"media-google-cast-request";if(o)this._satisfyRequest(a,e);else{let l=this._request._queue._peek(a);l&&(e.request=l,e.triggers.add(l))}}"sources-change"(e){this.$state.sources.set(e.detail)}"source-change"(e){let n=this._trackedEvents.get("sources-change");n&&e.triggers.add(n),this._resetMediaState(e),this._trackedEvents.set(e.type,e),this.$state.source.set(e.detail),this.el?.setAttribute("aria-busy","true")}_resetMediaState(e){this._media.audioTracks[le._reset](e),this._media.qualities[le._reset](e),this._resetTracking(),lR(this._media.$state)}abort(e){let n=this._trackedEvents.get("source-change");n&&e.triggers.add(n);let i=this._trackedEvents.get("can-load");i&&!e.triggers.hasType("can-load")&&e.triggers.add(i)}"load-start"(e){let n=this._trackedEvents.get("source-change");n&&e.triggers.add(n)}error(e){this.$state.error.set(e.detail);let n=this._trackedEvents.get("abort");n&&e.triggers.add(n)}"loaded-metadata"(e){let n=this._trackedEvents.get("load-start");n&&e.triggers.add(n)}"loaded-data"(e){let n=this._trackedEvents.get("load-start");n&&e.triggers.add(n)}"can-play"(e){let n=this._trackedEvents.get("loaded-metadata");n&&e.triggers.add(n),this._onCanPlayDetail(e.detail),this.el?.setAttribute("aria-busy","false")}"can-play-through"(e){this._onCanPlayDetail(e.detail);let n=this._trackedEvents.get("can-play");n&&e.triggers.add(n)}_onCanPlayDetail(e){let{seekable:n,seekableEnd:i,buffered:r,intrinsicDuration:s,canPlay:o}=this.$state;o.set(!0),r.set(e.buffered),n.set(e.seekable),s.set(i())}"duration-change"(e){let{live:n,intrinsicDuration:i}=this.$state,r=e.detail;n()||i.set(Number.isNaN(r)?0:r)}progress(e){let{buffered:n,seekable:i,live:r,intrinsicDuration:s,seekableEnd:o}=this.$state,a=e.detail;n.set(a.buffered),i.set(a.seekable),r()&&(s.set(o),this.dispatch("duration-change",{detail:o(),trigger:e}))}play(e){let{paused:n,autoPlayError:i,ended:r,autoPlaying:s,playsInline:o,pointer:a,muted:l,viewType:c}=this.$state;if(this._resetPlaybackIfNeeded(),!n()&&!this._request._looping){e.stopImmediatePropagation();return}e.autoPlay=s();let u=this._trackedEvents.get("waiting");u&&e.triggers.add(u),this._satisfyRequest("media-play-request",e),this._trackedEvents.set("play",e),n.set(!1),i.set(null),e.autoPlay&&(this._handle(this.createEvent("auto-play",{detail:{muted:l()},trigger:e})),s.set(!1)),(r()||this._request._replaying)&&(this._request._replaying=!1,r.set(!1),this._handle(this.createEvent("replay",{trigger:e}))),!o()&&c()==="video"&&a()==="coarse"&&this._media.remote.enterFullscreen("prefer-media",e),this._request._looping&&e.stopImmediatePropagation()}_resetPlaybackIfNeeded(e){if(!N(this._media.$provider))return;let{ended:i,seekableStart:r,clipStartTime:s,clipEndTime:o,realCurrentTime:a,duration:l}=this.$state,c=a()0&&a()>=o()||Math.abs(a()-l())<.1||i();return c&&this.dispatch("media-seek-request",{detail:(s()>0?0:r())+.1,trigger:e}),c}"play-fail"(e){let{muted:n,autoPlaying:i}=this.$state,r=this._trackedEvents.get("play");r&&e.triggers.add(r),this._satisfyRequest("media-play-request",e);let{paused:s,playing:o}=this.$state;s.set(!0),o.set(!1),this._resetTracking(),this._trackedEvents.set("play-fail",e),e.autoPlay&&(this._handle(this.createEvent("auto-play-fail",{detail:{muted:n(),error:e.detail},trigger:e})),i.set(!1))}playing(e){let n=this._trackedEvents.get("play"),i=this._trackedEvents.get("seeked");n?e.triggers.add(n):i&&e.triggers.add(i),setTimeout(()=>this._resetTracking(),0);let{paused:r,playing:s,live:o,liveSyncPosition:a,seekableEnd:l,started:c,currentTime:u,seeking:d,ended:p}=this.$state;if(r.set(!1),s.set(!0),d.set(!1),p.set(!1),this._request._looping){e.stopImmediatePropagation(),this._request._looping=!1;return}if(o()&&!c()&&u()===0){let h=a()??l()-2;Number.isFinite(h)&&this._media.$provider().setCurrentTime(h)}this.started(e)}started(e){let{started:n}=this.$state;n()||(n.set(!0),this._handle(this.createEvent("started",{trigger:e})))}pause(e){this.el?.isConnected||(this._isPlayingOnDisconnect=!0),this._satisfyRequest("media-pause-request",e);let n=this._trackedEvents.get("seeked");if(n&&e.triggers.add(n),this._clipEnded){e.stopImmediatePropagation(),this._handle(this.createEvent("end",{trigger:e})),this._clipEnded=!1;return}if(this._request._looping){e.stopImmediatePropagation();return}this._resetTracking();let{paused:i,playing:r}=this.$state;i.set(!0),r.set(!1)}"time-update"(e){if(this._request._looping){e.stopImmediatePropagation();return}let{realCurrentTime:n,played:i,waiting:r,clipEndTime:s,loop:o}=this.$state,a=s(),l=e.detail;n.set(l.currentTime),i.set(l.played),r.set(!1);for(let c of this._media.textTracks)c[se._updateActiveCues](l.currentTime,e);a>0&&l.currentTime>=a&&(o()&&(this._request._looping=!0),this._clipEnded=!0,this.dispatch("media-pause-request",{trigger:e})),this._saveTime()}_saveTime(){let{storage:e}=this._media,{canPlay:n,realCurrentTime:i}=this.$state;n()&&e?.setTime?.(i())}"volume-change"(e){let{storage:n}=this._media,{volume:i,muted:r,canPlay:s}=this.$state,o=e.detail;i.set(o.volume),r.set(o.muted||o.volume===0),this._satisfyRequest("media-volume-change-request",e),this._satisfyRequest(o.muted?"media-mute-request":"media-unmute-request",e),s()&&(n?.setVolume?.(i()),n?.setMuted?.(r()))}seeked(e){let{seeking:n,realCurrentTime:i,paused:r,duration:s,ended:o}=this.$state;if(this._request._seeking)n.set(!0),e.stopImmediatePropagation();else if(n()){let a=this._trackedEvents.get("waiting");a&&e.triggers.add(a);let l=this._trackedEvents.get("seeking");l&&!e.triggers.has(l)&&e.triggers.add(l),r()&&this._stopWaiting(),n.set(!1),e.detail!==s()&&o.set(!1),i.set(e.detail),this._satisfyRequest("media-seek-request",e);let c=e?.originEvent;c?.isTrusted&&!/seek/.test(c.type)&&this.started(e)}}waiting(e){this._firingWaiting||this._request._seeking||(e.stopImmediatePropagation(),this._waitingTrigger=e,this._fireWaiting())}end(e){let{loop:n}=this.$state;if(n()){setTimeout(()=>{requestAnimationFrame(()=>{this.dispatch("media-loop-request",{trigger:e})})},10);return}this._onEnded(e)}_onEnded(e){let{paused:n,seeking:i,ended:r,duration:s}=this.$state;n()||this.dispatch("pause",{trigger:e}),i()&&this.dispatch("seeked",{detail:s(),trigger:e}),r.set(!0),this._resetTracking(),this.dispatch("ended",{trigger:e})}_stopWaiting(){this._fireWaiting.cancel(),this.$state.waiting.set(!1)}"fullscreen-change"(e){let n=e.detail;this.$state.fullscreen.set(n),this._satisfyRequest(n?"media-enter-fullscreen-request":"media-exit-fullscreen-request",e)}"fullscreen-error"(e){this._satisfyRequest("media-enter-fullscreen-request",e),this._satisfyRequest("media-exit-fullscreen-request",e)}"orientation-change"(e){let n=e.detail.lock;this._satisfyRequest(n?"media-orientation-lock-request":"media-orientation-unlock-request",e)}"picture-in-picture-change"(e){let n=e.detail;this.$state.pictureInPicture.set(n),this._satisfyRequest(n?"media-enter-pip-request":"media-exit-pip-request",e)}"picture-in-picture-error"(e){this._satisfyRequest("media-enter-pip-request",e),this._satisfyRequest("media-exit-pip-request",e)}"title-change"(e){e.trigger&&(e.stopImmediatePropagation(),this.$state.inferredTitle.set(e.detail))}"poster-change"(e){e.trigger&&(e.stopImmediatePropagation(),this.$state.inferredPoster.set(e.detail))}},Ux=class extends Nr{onSetup(){this._init(),!B&&(S(this._watchArtist.bind(this)),S(this._watchAutoplay.bind(this)),S(this._watchClipTimes.bind(this)),S(this._watchControls.bind(this)),S(this._watchCrossOrigin.bind(this)),S(this._watchDuration.bind(this)),S(this._watchLive.bind(this)),S(this._watchLiveEdge.bind(this)),S(this._watchLiveTolerance.bind(this)),S(this._watchLoop.bind(this)),S(this._watchPlaysInline.bind(this)),S(this._watchPoster.bind(this)),S(this._watchProvidedTypes.bind(this)),S(this._watchTitle.bind(this)))}_init(){let e={duration:"providedDuration",poster:"providedPoster",streamType:"providedStreamType",title:"providedTitle",viewType:"providedViewType"},n=new Set(["currentTime","paused","playbackRate","volume"]);for(let i of Object.keys(this.$props))n.has(i)||this.$state[e[i]??i]?.set(this.$props[i]());this.$state.muted.set(this.$props.muted()||this.$props.volume()===0)}_watchProvidedTypes(){let{viewType:e,streamType:n,title:i,poster:r}=this.$props;this.$state.providedPoster.set(r()),this.$state.providedStreamType.set(n()),this.$state.providedViewType.set(e()),this.$state.providedTitle.set(i())}_watchLogLevel(){}_watchArtist(){let{artist:e}=this.$props;this.$state.artist.set(e())}_watchTitle(){let{title:e}=this.$state;this.dispatch("title-change",{detail:e()})}_watchAutoplay(){let e=this.$props.autoPlay()||this.$props.autoplay();this.$state.autoPlay.set(e),this.dispatch("auto-play-change",{detail:e})}_watchLoop(){let e=this.$props.loop();this.$state.loop.set(e),this.dispatch("loop-change",{detail:e})}_watchControls(){let e=this.$props.controls();this.$state.controls.set(e)}_watchPoster(){let{poster:e}=this.$state;this.dispatch("poster-change",{detail:e()})}_watchCrossOrigin(){let e=this.$props.crossOrigin()??this.$props.crossorigin(),n=e===!0?"":e;this.$state.crossOrigin.set(n)}_watchDuration(){let{providedDuration:e}=this.$state;e.set(this.$props.duration())}_watchPlaysInline(){let e=this.$props.playsInline()||this.$props.playsinline();this.$state.playsInline.set(e),this.dispatch("plays-inline-change",{detail:e})}_watchClipTimes(){let{clipStartTime:e,clipEndTime:n}=this.$props;this.$state.clipStartTime.set(e()),this.$state.clipEndTime.set(n())}_watchLive(){this.dispatch("live-change",{detail:this.$state.live()})}_watchLiveTolerance(){this.$state.liveEdgeTolerance.set(this.$props.liveEdgeTolerance()),this.$state.minLiveDVRWindow.set(this.$props.minLiveDVRWindow())}_watchLiveEdge(){this.dispatch("live-edge-change",{detail:this.$state.liveEdge()})}},J4=class jx extends Nr{constructor(){super()}onConnect(){S(this._onMetadataChange.bind(this)),S(this._onPlaybackStateChange.bind(this));let e=this._handleAction.bind(this);for(let n of jx._actions)navigator.mediaSession.setActionHandler(n,e);ae(this._onDisconnect.bind(this))}_onDisconnect(){for(let e of jx._actions)navigator.mediaSession.setActionHandler(e,null)}_onMetadataChange(){let{title:e,artist:n,poster:i}=this.$state;navigator.mediaSession.metadata=new MediaMetadata({title:e(),artist:n(),artwork:[{src:i()}]})}_onPlaybackStateChange(){let{canPlay:e,paused:n}=this.$state;navigator.mediaSession.playbackState=e()?n()?"paused":"playing":"none"}_handleAction(e){let n=new ne("media-session-action",{detail:e});switch(e.action){case"play":this.dispatch("media-play-request",{trigger:n});break;case"pause":this.dispatch("media-pause-request",{trigger:n});break;case"seekto":case"seekforward":case"seekbackward":this.dispatch("media-seek-request",{detail:dt(e.seekTime)?e.seekTime:this.$state.currentTime()+(e.seekOffset??10),trigger:n});break}}};J4._actions=["play","pause","seekforward","seekbackward","seekto"];Om=K(!1);B||(L(document,"pointerdown",()=>{Om.set(!1)}),L(document,"keydown",t=>{t.metaKey||t.altKey||t.ctrlKey||Om.set(!0)}));Hn=class extends sn{constructor(){super(...arguments),this._focused=K(!1)}onConnect(e){S(()=>{if(!Om()){this._focused.set(!1),mm(e,!1),this.listen("pointerenter",this._onPointerEnter.bind(this)),this.listen("pointerleave",this._onPointerLeave.bind(this));return}let n=document.activeElement===e;this._focused.set(n),mm(e,n),this.listen("focus",this._onFocus.bind(this)),this.listen("blur",this._onBlur.bind(this))})}focused(){return this._focused()}_onFocus(){this._focused.set(!0),mm(this.el,!0)}_onBlur(){this._focused.set(!1),mm(this.el,!1)}_onPointerEnter(){Y$(this.el,!0)}_onPointerLeave(){Y$(this.el,!1)}};e6=Object.defineProperty,t6=Object.getOwnPropertyDescriptor,Be=(t,e,n,i)=>{for(var r=i>1?void 0:i?t6(e,n):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(r=(i?o(e,n,r):o(r))||r);return i&&r&&e6(e,n,r),r},Re=class ym extends ie{constructor(){super(),this.canPlayQueue=new Nm,this._skipTitleUpdate=!1,new Ux;let e={player:this,qualities:new $m,audioTracks:new Mm,storage:null,$provider:K(null),$providerSetup:K(!1),$props:this.$props,$state:this.$state};e.remote=new hl(void 0),e.remote.setPlayer(this),e.$iosControls=Zi(this._isIOSControls.bind(this)),e.textTracks=new Pm,e.textTracks[se._crossOrigin]=this.$state.crossOrigin,e.textRenderers=new Sm(e),e.ariaKeys={},this._media=e,on(Id,e),this.orientation=new Zx,new Hn,new Dx(e);let n=new Vx;this._stateMgr=new zx(n,e),this._requestMgr=new Fx(this._stateMgr,n,e),e.delegate=new Nx(this._stateMgr._handle.bind(this._stateMgr),e),new Dm("load",this.startLoading.bind(this)),new Dm("posterLoad",this.startLoadingPoster.bind(this))}get _provider(){return this._media.$provider()}onSetup(){this._setupMediaAttributes(),S(this._watchCanPlay.bind(this)),S(this._watchMuted.bind(this)),S(this._watchPaused.bind(this)),S(this._watchVolume.bind(this)),S(this._watchCurrentTime.bind(this)),S(this._watchPlaysInline.bind(this)),S(this._watchPlaybackRate.bind(this))}onAttach(e){e.setAttribute("data-media-player",""),Ne(e,"tabindex","0"),Ne(e,"role","region"),S(this._watchStorage.bind(this)),B?this._watchTitle():S(this._watchTitle.bind(this)),B?this._watchOrientation():S(this._watchOrientation.bind(this)),L(e,"find-media-player",this._onFindPlayer.bind(this))}onConnect(e){F$&&pe(e,"data-iphone","");let n=window.matchMedia("(pointer: coarse)");this._onPointerChange(n),n.onchange=this._onPointerChange.bind(this);let i=new ResizeObserver(_s(this._onResize.bind(this)));i.observe(e),S(this._onResize.bind(this)),this.dispatch("media-player-connect",{detail:this,bubbles:!0,composed:!0}),ae(()=>{i.disconnect(),n.onchange=null})}onDestroy(){this._media.player=null,this.canPlayQueue._reset()}_watchTitle(){let e=this.$el,{title:n,live:i,viewType:r,providedTitle:s}=this.$state,o=i(),a=Eu(r()),l=a!=="Unknown"?`${o?"Live ":""}${a}`:o?"Live":"Media",c=n();pe(this.el,"aria-label",c?`${l} - ${c}`:l+" Player"),!B&&e?.hasAttribute("title")&&(this._skipTitleUpdate=!0,e?.removeAttribute("title"))}_watchOrientation(){let e=this.orientation.landscape?"landscape":"portrait";this.$state.orientation.set(e),pe(this.el,"data-orientation",e),this._onResize()}_watchCanPlay(){this.$state.canPlay()&&this._provider?this.canPlayQueue._start():this.canPlayQueue._stop()}_setupMediaAttributes(){if(ym[Cx]){this.setAttributes(ym[Cx]);return}let e={"data-load":function(){return this.$props.load()},"data-captions":function(){let i=this.$state.textTrack();return!!i&&pt(i)},"data-ios-controls":function(){return this._media.$iosControls()},"data-controls":function(){return this.controls.showing},"data-buffering":function(){let{canLoad:i,canPlay:r,waiting:s}=this.$state;return i()&&(!r()||s())},"data-error":function(){let{error:i}=this.$state;return!!i()},"data-autoplay-error":function(){let{autoPlayError:i}=this.$state;return!!i()}},n={autoPlay:"autoplay",canAirPlay:"can-airplay",canPictureInPicture:"can-pip",pictureInPicture:"pip",playsInline:"playsinline",remotePlaybackState:"remote-state",remotePlaybackType:"remote-type",isAirPlayConnected:"airplay",isGoogleCastConnected:"google-cast"};for(let i of Q4){let r="data-"+(n[i]??nl(i));e[r]=function(){return this.$state[i]()}}delete e.title,ym[Cx]=e,this.setAttributes(e)}_onFindPlayer(e){e.detail(this)}_onResize(){if(B||!this.el)return;let e=this.el.clientWidth,n=this.el.clientHeight;this.$state.width.set(e),this.$state.height.set(n),Ot(this.el,"--player-width",e+"px"),Ot(this.el,"--player-height",n+"px")}_onPointerChange(e){if(B)return;let n=e.matches?"coarse":"fine";pe(this.el,"data-pointer",n),this.$state.pointer.set(n),this._onResize()}_isIOSControls(){let{playsInline:e,fullscreen:n}=this.$state;return F$&&!nR()&&this.$state.mediaType()==="video"&&(!e()||n())}get provider(){return this._provider}get controls(){return this._requestMgr._controls}get title(){return N(this.$state.providedTitle)}set title(e){if(this._skipTitleUpdate){this._skipTitleUpdate=!1;return}this.$state.providedTitle.set(e)}get qualities(){return this._media.qualities}get audioTracks(){return this._media.audioTracks}get textTracks(){return this._media.textTracks}get textRenderers(){return this._media.textRenderers}get paused(){return N(this.$state.paused)}set paused(e){this._queuePausedUpdate(e)}_watchPaused(){this._queuePausedUpdate(this.$props.paused())}_queuePausedUpdate(e){e?this.canPlayQueue._enqueue("paused",()=>this._requestMgr._pause()):this.canPlayQueue._enqueue("paused",()=>this._requestMgr._play())}get muted(){return N(this.$state.muted)}set muted(e){this.$props.muted.set(e)}_watchMuted(){this._queueMutedUpdate(this.$props.muted())}_queueMutedUpdate(e){this.canPlayQueue._enqueue("muted",()=>{this._provider&&this._provider.setMuted(e)})}get currentTime(){return N(this.$state.currentTime)}set currentTime(e){this._queueCurrentTimeUpdate(e)}_watchCurrentTime(){this._queueCurrentTimeUpdate(this.$props.currentTime())}_queueCurrentTimeUpdate(e){this.canPlayQueue._enqueue("currentTime",()=>{let{currentTime:n,clipStartTime:i,seekableStart:r,seekableEnd:s}=this.$state;e!==N(n)&&N(()=>{if(!this._provider)return;let o=Math.min(Math.max(r()+.1,e+i()),s()-.1);Number.isFinite(o)&&this._provider.setCurrentTime(o)})})}get volume(){return N(this.$state.volume)}set volume(e){this.$props.volume.set(e)}_watchVolume(){this._queueVolumeUpdate(this.$props.volume())}_queueVolumeUpdate(e){let n=ok(0,e,1);this.canPlayQueue._enqueue("volume",()=>{this._provider&&this._provider.setVolume(n)})}get playbackRate(){return N(this.$state.playbackRate)}set playbackRate(e){this._queuePlaybackRateUpdate(e)}_watchPlaybackRate(){this._queuePlaybackRateUpdate(this.$props.playbackRate())}_queuePlaybackRateUpdate(e){this.canPlayQueue._enqueue("rate",()=>{this._provider&&this._provider.setPlaybackRate?.(e)})}_watchPlaysInline(){this._queuePlaysInlineUpdate(this.$props.playsInline())}_queuePlaysInlineUpdate(e){this.canPlayQueue._enqueue("playsinline",()=>{this._provider&&this._provider.setPlaysInline?.(e)})}_watchStorage(){let e=this.$props.storage(),n=Z(e)?new Em:e;if(n?.onChange){let{source:i}=this.$state,r=Z(e)?e:this.el?.id,s=Zi(this._computeMediaId.bind(this));S(()=>n.onChange(i(),s(),r))}this._media.storage=n,this._media.textTracks.setStorage(n),ae(()=>{n?.onDestroy?.(),this._media.storage=null,this._media.textTracks.setStorage(null)})}_computeMediaId(){let{clipStartTime:e,clipEndTime:n}=this.$props,{source:i}=this.$state,r=i();return r.src?`${r.src}:${e()}:${n()}`:null}async play(e){return this._requestMgr._play(e)}async pause(e){return this._requestMgr._pause(e)}async enterFullscreen(e,n){return this._requestMgr._enterFullscreen(e,n)}async exitFullscreen(e,n){return this._requestMgr._exitFullscreen(e,n)}enterPictureInPicture(e){return this._requestMgr._enterPictureInPicture(e)}exitPictureInPicture(e){return this._requestMgr._exitPictureInPicture(e)}seekToLiveEdge(e){this._requestMgr._seekToLiveEdge(e)}startLoading(e){this._media.delegate._notify("can-load",void 0,e)}startLoadingPoster(e){this._media.delegate._notify("can-load-poster",void 0,e)}requestAirPlay(e){return this._requestMgr._requestAirPlay(e)}requestGoogleCast(e){return this._requestMgr._requestGoogleCast(e)}destroy(){this._media.remote.setPlayer(null),this.dispatch("destroy")}};Re.props=X4;Re.state=$o;Be([he],Re.prototype,"canPlayQueue",2);Be([he],Re.prototype,"provider",1);Be([he],Re.prototype,"controls",1);Be([he],Re.prototype,"orientation",2);Be([he],Re.prototype,"title",1);Be([he],Re.prototype,"qualities",1);Be([he],Re.prototype,"audioTracks",1);Be([he],Re.prototype,"textTracks",1);Be([he],Re.prototype,"textRenderers",1);Be([he],Re.prototype,"paused",1);Be([he],Re.prototype,"muted",1);Be([he],Re.prototype,"currentTime",1);Be([he],Re.prototype,"volume",1);Be([he],Re.prototype,"playbackRate",1);Be([Ze],Re.prototype,"play",1);Be([Ze],Re.prototype,"pause",1);Be([Ze],Re.prototype,"enterFullscreen",1);Be([Ze],Re.prototype,"exitFullscreen",1);Be([Ze],Re.prototype,"enterPictureInPicture",1);Be([Ze],Re.prototype,"exitPictureInPicture",1);Be([Ze],Re.prototype,"seekToLiveEdge",1);Be([Ze],Re.prototype,"startLoading",1);Be([Ze],Re.prototype,"startLoadingPoster",1);Be([Ze],Re.prototype,"requestAirPlay",1);Be([Ze],Re.prototype,"requestGoogleCast",1);n6=Re;OR=new Map,Bx=class{constructor(e,n,i,r=[]){this._domSources=e,this._media=n,this._loader=i,this._initialize=!1;let s=new DR,o=new qu,a=new Im,l=new Am,c=new Lm,u=[l,c];this._loaders=Zi(()=>{let p=n.$state.remotePlaybackLoader(),h=n.$props.preferNativeHLS()?[...r,o,a,s,...u]:[...r,s,o,a,...u];return p?[p,...h]:h});let{$state:d}=n;d.sources.set(Q$(n.$props.src()));for(let p of d.sources()){let h=this._loaders().find(v=>v.canPlay(p));if(!h)continue;let m=h.mediaType(p);this._media.$state.source.set(p),this._media.$state.mediaType.set(m),this._media.$state.inferredViewType.set(m),this._loader.set(h),this._initialize=!0}}get _notify(){return this._media.delegate._notify}connect(){let e=this._loader();this._initialize&&(this._notifySourceChange(this._media.$state.source(),e),this._notifyLoaderChange(e),this._initialize=!1),S(this._onSourcesChange.bind(this)),S(this._onSourceChange.bind(this)),S(this._onSetup.bind(this)),S(this._onLoadSource.bind(this)),S(this._onLoadPoster.bind(this))}_onSourcesChange(){this._notify("sources-change",[...Q$(this._media.$props.src()),...this._domSources()])}_onSourceChange(){let{$state:e}=this._media,n=e.sources(),i=N(e.source),r=this._findNewSource(i,n);if(n[0]?.src&&!r.src&&!r.type){let{crossOrigin:o}=e,a=_m(o()),l=new AbortController;return Promise.all(n.map(c=>Z(c.src)&&c.type==="?"?fetch(c.src,{method:"HEAD",credentials:a,signal:l.signal}).then(u=>(c.type=u.headers.get("content-type")||"??",OR.set(c.src,c.type),c)).catch(()=>c):c)).then(c=>{l.signal.aborted||(this._findNewSource(N(e.source),c),Li())}),()=>l.abort()}Li()}_findNewSource(e,n){let i={src:"",type:""},r=null,s=this._loaders();for(let o of n){let a=s.find(l=>l.canPlay(o));if(a){i=o,r=a;break}}return X$(e,i)||this._notifySourceChange(i,r),r!==N(this._loader)&&this._notifyLoaderChange(r),i}_notifySourceChange(e,n){this._notify("source-change",e),this._notify("media-type-change",n?.mediaType(e)||"unknown")}_notifyLoaderChange(e){this._media.$providerSetup.set(!1),this._notify("provider-change",null),e&&N(()=>e.preconnect?.(this._media)),this._loader.set(e),this._notify("provider-loader-change",e)}_onSetup(){let e=this._media.$provider();if(!(!e||N(this._media.$providerSetup))){if(this._media.$state.canLoad()){Ct(()=>e.setup(),e.scope),this._media.$providerSetup.set(!0);return}N(()=>e.preconnect?.())}}_onLoadSource(){if(!this._media.$providerSetup())return;let e=this._media.$provider(),n=this._media.$state.source(),i=N(this._media.$state.crossOrigin);if(!X$(e?.currentSrc,n)){if(this._media.$state.canLoad()){let r=new AbortController;return yo(n)?sm()||NR(n.src,{credentials:_m(i),signal:r.signal}).then(s=>{this._notify("stream-type-change",s)}).catch(kn):this._notify("stream-type-change","on-demand"),N(()=>{let s=N(this._media.$state.preload);return e?.loadSource(n,s).catch(o=>{})}),()=>r.abort()}try{Z(n.src)&&Ai(new URL(n.src).origin)}catch{}}}_onLoadPoster(){let e=this._loader(),{source:n,canLoadPoster:i}=this._media.$state;if(!e||!e.loadPoster||!n()||!i())return;let r=new AbortController,s=new ne("source-change",{detail:n});return e.loadPoster(n(),this._media,r).then(o=>{this._notify("poster-change",o||"",s)}).catch(()=>{this._notify("poster-change","",s)}),()=>{r.abort()}}};Hx=class{constructor(e,n){this._domTracks=e,this._media=n,this._prevTracks=[],S(this._onTracksChange.bind(this))}_onTracksChange(){let e=this._domTracks();for(let n of this._prevTracks)if(!e.some(i=>i.id===n.id)){let i=n.id&&this._media.textTracks.getById(n.id);i&&this._media.textTracks.remove(i)}for(let n of e){let i=n.id||zn.createId(n);this._media.textTracks.getById(i)||(n.id=i,this._media.textTracks.add(n))}this._prevTracks=e}},s6=Object.defineProperty,o6=Object.getOwnPropertyDescriptor,a6=(t,e,n,i)=>{for(var r=i>1?void 0:i?o6(e,n):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(r=(i?o(e,n,r):o(r))||r);return i&&r&&s6(e,n,r),r},ml=class extends ie{constructor(){super(...arguments),this._domSources=K([]),this._domTracks=K([]),this._loader=null,this._loadRafId=-1}onSetup(){this._media=Ee(),this._sources=new Bx(this._domSources,this._media,this.$state.loader,this.$props.loaders())}onAttach(e){e.setAttribute("data-media-provider","")}onConnect(e){this._sources.connect(),new Hx(this._domTracks,this._media);let n=new ResizeObserver(_s(this._onResize.bind(this)));n.observe(e);let i=new MutationObserver(this._onMutation.bind(this));i.observe(e,{attributes:!0,childList:!0}),this._onResize(),this._onMutation(),ae(()=>{n.disconnect(),i.disconnect()})}load(e){window.cancelAnimationFrame(this._loadRafId),this._loadRafId=requestAnimationFrame(()=>this._runLoader(e)),ae(()=>{window.cancelAnimationFrame(this._loadRafId)})}_runLoader(e){if(!this.scope)return;let n=this.$state.loader(),{$provider:i}=this._media;this._loader===n&&n?.target===e&&N(i)||(this._destroyProvider(),this._loader=n,n&&(n.target=e||null),!(!n||!e)&&n.load(this._media).then(r=>{this.scope&&N(this.$state.loader)===n&&this._media.delegate._notify("provider-change",r)}))}onDestroy(){this._loader=null,this._destroyProvider()}_destroyProvider(){this._media.delegate._notify("provider-change",null)}_onResize(){if(!this.el)return;let e=this._media.player,n=this.el.offsetWidth,i=this.el.offsetHeight;e&&(e.$state.mediaWidth.set(n),e.$state.mediaHeight.set(i),e.el&&(Ot(e.el,"--media-width",n+"px"),Ot(e.el,"--media-height",i+"px")))}_onMutation(){let e=[],n=[],i=this.el.children;for(let r of i)r instanceof HTMLSourceElement?e.push({src:r.src,type:r.type}):r instanceof HTMLTrackElement&&n.push({id:r.id,src:r.src,kind:r.track.kind,language:r.srclang,label:r.label,default:r.default,type:r.getAttribute("data-type")});this._domSources.set(e),this._domTracks.set(n),Li()}};ml.props={loaders:[]};ml.state=new Ii({loader:null});a6([Ze],ml.prototype,"load",1);Fm=class extends ie{onSetup(){this._media=Ee(),S(this._watchProps.bind(this))}onAttach(e){let{pictureInPicture:n,fullscreen:i}=this._media.$state;Ot(e,"pointer-events","none"),Ne(e,"role","group"),this.setAttributes({"data-visible":this._isShowing.bind(this),"data-fullscreen":i,"data-pip":n}),S(()=>{this.dispatch("change",{detail:this._isShowing()})}),S(this._hideControls.bind(this)),S(()=>{let r=i();for(let s of["top","right","bottom","left"])Ot(e,`padding-${s}`,r&&`env(safe-area-inset-${s})`)})}_hideControls(){if(!this.el)return;let{$iosControls:e}=this._media,{controls:n}=this._media.$state,i=n()||e();pe(this.el,"aria-hidden",i?"true":null),Ot(this.el,"display",i?"none":null)}_watchProps(){let{controls:e}=this._media.player,{hideDelay:n,hideOnMouseLeave:i}=this.$props;e.defaultDelay=n()===2e3?this._media.$props.controlsDelay():n(),e.hideOnMouseLeave=i()}_isShowing(){let{controlsVisible:e}=this._media.$state;return e()}};Fm.props={hideDelay:2e3,hideOnMouseLeave:!1};Vm=class extends ie{onAttach(e){Ot(e,"pointer-events","auto")}},zm=class extends sn{constructor(e){super(),this._delegate=e,this._showTimerId=-1,this._hideRafId=-1,this._stopAnimationEndListener=null,S(this._watchTrigger.bind(this))}onDestroy(){this._stopAnimationEndListener?.(),this._stopAnimationEndListener=null}_watchTrigger(){let e=this._delegate._trigger();if(!e){this.hide();return}let n=this.show.bind(this),i=this.hide.bind(this);this._delegate._listen(e,n,i)}show(e){this._cancelShowing(),window.cancelAnimationFrame(this._hideRafId),this._hideRafId=-1,this._stopAnimationEndListener?.(),this._stopAnimationEndListener=null,this._showTimerId=window.setTimeout(()=>{this._showTimerId=-1;let n=this._delegate._content();n&&n.style.removeProperty("display"),N(()=>this._delegate._onChange(!0,e))},this._delegate._showDelay?.()??0)}hide(e){this._cancelShowing(),N(()=>this._delegate._onChange(!1,e)),this._hideRafId=requestAnimationFrame(()=>{this._cancelShowing(),this._hideRafId=-1;let n=this._delegate._content();if(n){let i=()=>{n.style.display="none",this._stopAnimationEndListener=null};if(j4(n)){this._stopAnimationEndListener?.();let s=L(n,"animationend",i,{once:!0});this._stopAnimationEndListener=s}else i()}})}_cancelShowing(){window.clearTimeout(this._showTimerId),this._showTimerId=-1}},pl=er(),l6=0,Um=class extends ie{constructor(){super(),this._id=`media-tooltip-${++l6}`,this._trigger=K(null),this._content=K(null),new Hn;let{showDelay:e}=this.$props;new zm({_trigger:this._trigger,_content:this._content,_showDelay:e,_listen(n,i,r){L(n,"touchstart",s=>s.preventDefault(),{passive:!1}),S(()=>{Om()&&L(n,"focus",i),L(n,"blur",r)}),L(n,"mouseenter",i),L(n,"mouseleave",r)},_onChange:this._onShowingChange.bind(this)})}onAttach(e){e.style.setProperty("display","contents")}onSetup(){on(pl,{_trigger:this._trigger,_content:this._content,_attachTrigger:this._attachTrigger.bind(this),_detachTrigger:this._detachTrigger.bind(this),_attachContent:this._attachContent.bind(this),_detachContent:this._detachContent.bind(this)})}_attachTrigger(e){this._trigger.set(e);let n=e.getAttribute("data-media-tooltip");n&&this.el?.setAttribute(`data-media-${n}-tooltip`,""),pe(e,"data-describedby",this._id)}_detachTrigger(e){e.removeAttribute("data-describedby"),e.removeAttribute("aria-describedby"),this._trigger.set(null)}_attachContent(e){e.setAttribute("id",this._id),e.style.display="none",Ne(e,"role","tooltip"),this._content.set(e)}_detachContent(e){e.removeAttribute("id"),e.removeAttribute("role"),this._content.set(null)}_onShowingChange(e){let n=this._trigger(),i=this._content();n&&pe(n,"aria-describedby",e?this._id:null);for(let r of[this.el,n,i])r&&pe(r,"data-visible",e)}};Um.props={showDelay:700};jm=class extends ie{constructor(){super(),new Hn}onConnect(e){ae(km(()=>{if(!this.connectScope)return;this._attach();let n=Xe(pl);ae(()=>{let i=this._getButton();i&&n._detachTrigger(i)})}))}_attach(){let e=this._getButton(),n=Xe(pl);e&&n._attachTrigger(e)}_getButton(){let e=this.el.firstElementChild;return e?.localName==="button"||e?.getAttribute("role")==="button"?e:this.el}},Wu=class extends ie{constructor(){super(),new Hn;let{placement:e}=this.$props;this.setAttributes({"data-placement":e})}onAttach(e){this._attach(e),Object.assign(e.style,{position:"absolute",top:0,left:0,width:"max-content"})}onConnect(e){this._attach(e);let n=Xe(pl);ae(()=>n._detachContent(e)),ae(km(()=>{this.connectScope&&S(this._watchPlacement.bind(this))}))}_attach(e){Xe(pl)._attachContent(e)}_watchPlacement(){let{placement:e,offset:n,alignOffset:i}=this.$props;return xR(this.el,this._getTrigger(),e(),{offsetVarName:"media-tooltip",xOffset:i(),yOffset:n()})}_getTrigger(){return Xe(pl)._trigger()}};Wu.props={placement:"top center",offset:0,alignOffset:0};Mt=class extends sn{constructor(e){super(),this._delegate=e,new Hn,e._keyShortcut&&new Rm(e._keyShortcut)}onSetup(){let{disabled:e}=this.$props;this.setAttributes({"data-pressed":this._delegate._isPressed,"aria-pressed":this._isARIAPressed.bind(this),"aria-disabled":()=>e()?"true":null})}onAttach(e){Ne(e,"tabindex","0"),Ne(e,"role","button"),Ne(e,"type","button")}onConnect(e){Ss(e,this._onMaybePress.bind(this));for(let n of["click","touchstart"])this.listen(n,this._onInteraction.bind(this))}_isARIAPressed(){return il(this._delegate._isPressed())}_onPressed(e){xb(this._delegate._isPressed)&&this._delegate._isPressed.set(n=>!n)}_onMaybePress(e){if(this.$props.disabled()||this.el.hasAttribute("data-disabled")){e.preventDefault(),e.stopImmediatePropagation();return}e.preventDefault(),(this._delegate._onPress??this._onPressed).call(this,e)}_onInteraction(e){this.$props.disabled()&&(e.preventDefault(),e.stopImmediatePropagation())}};Mt.props={disabled:!1};c6=Object.defineProperty,u6=Object.getOwnPropertyDescriptor,d6=(t,e,n,i)=>{for(var r=i>1?void 0:i?u6(e,n):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(r=(i?o(e,n,r):o(r))||r);return i&&r&&c6(e,n,r),r},Ku=class extends ie{constructor(){super(),this._pressed=K(!1),new Mt({_isPressed:this._pressed})}get pressed(){return this._pressed()}};Ku.props={disabled:!1,defaultPressed:!1};d6([he],Ku.prototype,"pressed",1);Bm=class extends ie{constructor(){super(),new Mt({_isPressed:this._isPressed.bind(this),_onPress:this._onPress.bind(this)})}onSetup(){this._media=Ee();let{canAirPlay:e,isAirPlayConnected:n}=this._media.$state;this.setAttributes({"data-active":n,"data-supported":e,"data-state":this._getState.bind(this),"aria-hidden":Pn(()=>!e())})}onAttach(e){e.setAttribute("data-media-tooltip","airplay"),Cs(e,this._getDefaultLabel.bind(this))}_onPress(e){this._media.remote.requestAirPlay(e)}_isPressed(){let{remotePlaybackType:e,remotePlaybackState:n}=this._media.$state;return e()==="airplay"&&n()!=="disconnected"}_getState(){let{remotePlaybackType:e,remotePlaybackState:n}=this._media.$state;return e()==="airplay"&&n()}_getDefaultLabel(){let{remotePlaybackState:e}=this._media.$state;return`AirPlay ${e()}`}};Bm.props=Mt.props;Hm=class extends ie{constructor(){super(),new Mt({_isPressed:this._isPressed.bind(this),_onPress:this._onPress.bind(this)})}onSetup(){this._media=Ee();let{canGoogleCast:e,isGoogleCastConnected:n}=this._media.$state;this.setAttributes({"data-active":n,"data-supported":e,"data-state":this._getState.bind(this),"aria-hidden":Pn(()=>!e())})}onAttach(e){e.setAttribute("data-media-tooltip","google-cast"),Cs(e,this._getDefaultLabel.bind(this))}_onPress(e){this._media.remote.requestGoogleCast(e)}_isPressed(){let{remotePlaybackType:e,remotePlaybackState:n}=this._media.$state;return e()==="google-cast"&&n()!=="disconnected"}_getState(){let{remotePlaybackType:e,remotePlaybackState:n}=this._media.$state;return e()==="google-cast"&&n()}_getDefaultLabel(){let{remotePlaybackState:e}=this._media.$state;return`Google Cast ${e()}`}};Hm.props=Mt.props;qm=class extends ie{constructor(){super(),new Mt({_isPressed:this._isPressed.bind(this),_keyShortcut:"togglePaused",_onPress:this._onPress.bind(this)})}onSetup(){this._media=Ee();let{paused:e,ended:n}=this._media.$state;this.setAttributes({"data-paused":e,"data-ended":n})}onAttach(e){e.setAttribute("data-media-tooltip","play"),Cs(e,this._getDefaultLabel.bind(this))}_onPress(e){let n=this._media.remote;this._isPressed()?n.pause(e):n.play(e)}_isPressed(){let{paused:e}=this._media.$state;return!e()}_getDefaultLabel(){let{paused:e}=this._media.$state;return e()?"Play":"Pause"}};qm.props=Mt.props;Wm=class extends ie{constructor(){super(),new Mt({_isPressed:this._isPressed.bind(this),_keyShortcut:"toggleCaptions",_onPress:this._onPress.bind(this)})}onSetup(){this._media=Ee(),this.setAttributes({"data-active":this._isPressed.bind(this),"data-supported":()=>!this._isHidden(),"aria-hidden":Pn(this._isHidden.bind(this))})}onAttach(e){e.setAttribute("data-media-tooltip","caption"),Cs(e,this._getDefaultLabel.bind(this))}_onPress(e){this._media.remote.toggleCaptions(e)}_isPressed(){let{textTrack:e}=this._media.$state,n=e();return!!n&&pt(n)}_isHidden(){let{hasCaptions:e}=this._media.$state;return!e()}_getDefaultLabel(){let{textTrack:e}=this._media.$state;return e()?"Closed-Captions Off":"Closed-Captions On"}};Wm.props=Mt.props;Km=class extends ie{constructor(){super(),new Mt({_isPressed:this._isPressed.bind(this),_keyShortcut:"toggleFullscreen",_onPress:this._onPress.bind(this)})}onSetup(){this._media=Ee();let{fullscreen:e}=this._media.$state,n=this._isSupported.bind(this);this.setAttributes({"data-active":e,"data-supported":n,"aria-hidden":Pn(()=>!n())})}onAttach(e){e.setAttribute("data-media-tooltip","fullscreen"),Cs(e,this._getDefaultLabel.bind(this))}_onPress(e){let n=this._media.remote,i=this.$props.target();this._isPressed()?n.exitFullscreen(i,e):n.enterFullscreen(i,e)}_isPressed(){let{fullscreen:e}=this._media.$state;return e()}_isSupported(){let{canFullscreen:e}=this._media.$state;return e()}_getDefaultLabel(){let{fullscreen:e}=this._media.$state;return e()?"Exit Fullscreen":"Enter Fullscreen"}};Km.props={...Mt.props,target:"prefer-media"};Gm=class extends ie{constructor(){super(),new Mt({_isPressed:this._isPressed.bind(this),_keyShortcut:"toggleMuted",_onPress:this._onPress.bind(this)})}onSetup(){this._media=Ee(),this.setAttributes({"data-muted":this._isPressed.bind(this),"data-state":this._getState.bind(this)})}onAttach(e){e.setAttribute("data-media-mute-button",""),e.setAttribute("data-media-tooltip","mute"),Cs(e,this._getDefaultLabel.bind(this))}_onPress(e){let n=this._media.remote;this._isPressed()?n.unmute(e):n.mute(e)}_isPressed(){let{muted:e,volume:n}=this._media.$state;return e()||n()===0}_getDefaultLabel(){return this._isPressed()?"Unmute":"Mute"}_getState(){let{muted:e,volume:n}=this._media.$state,i=n();if(e()||i===0)return"muted";if(i>=.5)return"high";if(i<.5)return"low"}};Gm.props=Mt.props;Ym=class extends ie{constructor(){super(),new Mt({_isPressed:this._isPressed.bind(this),_keyShortcut:"togglePictureInPicture",_onPress:this._onPress.bind(this)})}onSetup(){this._media=Ee();let{pictureInPicture:e}=this._media.$state,n=this._isSupported.bind(this);this.setAttributes({"data-active":e,"data-supported":n,"aria-hidden":Pn(()=>!n())})}onAttach(e){e.setAttribute("data-media-tooltip","pip"),Cs(e,this._getDefaultLabel.bind(this))}_onPress(e){let n=this._media.remote;this._isPressed()?n.exitPictureInPicture(e):n.enterPictureInPicture(e)}_isPressed(){let{pictureInPicture:e}=this._media.$state;return e()}_isSupported(){let{canPictureInPicture:e}=this._media.$state;return e()}_getDefaultLabel(){let{pictureInPicture:e}=this._media.$state;return e()?"Exit Picture In Picture":"Enter Picture In Picture"}};Ym.props=Mt.props;Qm=class extends ie{constructor(){super(),new Hn}onSetup(){this._media=Ee();let{seeking:e}=this._media.$state,{seconds:n}=this.$props,i=this._isSupported.bind(this);this.setAttributes({seconds:n,"data-seeking":e,"data-supported":i,"aria-hidden":Pn(()=>!i())})}onAttach(e){Ne(e,"tabindex","0"),Ne(e,"role","button"),Ne(e,"type","button"),e.setAttribute("data-media-tooltip","seek"),Cs(e,this._getDefaultLabel.bind(this))}onConnect(e){Ss(e,this._onPress.bind(this))}_isSupported(){let{canSeek:e}=this._media.$state;return e()}_getDefaultLabel(){let{seconds:e}=this.$props;return`Seek ${e()>0?"forward":"backward"} ${e()} seconds`}_onPress(e){let{seconds:n,disabled:i}=this.$props;if(i())return;let{currentTime:r}=this._media.$state,s=r()+n();this._media.remote.seek(s,e)}};Qm.props={disabled:!1,seconds:30};Xm=class extends ie{constructor(){super(),new Hn}onSetup(){this._media=Ee();let{disabled:e}=this.$props,{live:n,liveEdge:i}=this._media.$state,r=()=>!n();this.setAttributes({"data-edge":i,"data-hidden":r,"aria-disabled":Pn(()=>e()||i()),"aria-hidden":Pn(r)})}onAttach(e){Ne(e,"tabindex","0"),Ne(e,"role","button"),Ne(e,"type","button"),e.setAttribute("data-media-tooltip","live")}onConnect(e){Ss(e,this._onPress.bind(this))}_onPress(e){let{disabled:n}=this.$props,{liveEdge:i}=this._media.$state;n()||i()||this._media.remote.seekToLiveEdge(e)}};Xm.props={disabled:!1};cg=new Ii({min:0,max:100,value:0,pointerValue:0,focused:!1,dragging:!1,pointing:!1,get active(){return this.dragging||this.focused||this.pointing},get fillRate(){return Z$(this.min,this.max,this.value)},get fillPercent(){return this.fillRate*100},get pointerRate(){return Z$(this.min,this.max,this.pointerValue)},get pointerPercent(){return this.pointerRate*100}});J$={Left:-1,ArrowLeft:-1,Up:1,ArrowUp:1,Right:1,ArrowRight:1,Down:-1,ArrowDown:-1},qx=class extends sn{constructor(e,n){super(),this._delegate=e,this._media=n,this._provider=null,this._touch=null,this._touchStartValue=null,this._onDocumentPointerMove=Ad(i=>{this._updatePointerValue(this._getPointerValue(i),i)},20,{leading:!0})}onConnect(){if(S(this._attachEventListeners.bind(this)),S(this._attachPointerListeners.bind(this)),this._delegate._swipeGesture){let e=this._media.player.el?.querySelector("media-provider,[data-media-provider]");e&&(this._provider=e,L(e,"touchstart",this._onTouchStart.bind(this),{passive:!0}),L(e,"touchmove",this._onTouchMove.bind(this),{passive:!1}))}}_onTouchStart(e){this._touch=e.touches[0]}_onTouchMove(e){if(Ji(this._touch)||nk(e))return;let n=e.touches[0],i=n.clientX-this._touch.clientX,r=n.clientY-this._touch.clientY,s=this.$state.dragging();!s&&Math.abs(r)>20||s||Math.abs(i)>20&&(this._touch=n,this._touchStartValue=this.$state.value(),this._onStartDragging(this._touchStartValue,e))}_attachEventListeners(){this._delegate._isDisabled()||(this.listen("focus",this._onFocus.bind(this)),this.listen("pointerenter",this._onPointerEnter.bind(this)),this.listen("pointermove",this._onPointerMove.bind(this)),this.listen("pointerleave",this._onPointerLeave.bind(this)),this.listen("pointerdown",this._onPointerDown.bind(this)),this.listen("keydown",this._onKeyDown.bind(this)),this.listen("keyup",this._onKeyUp.bind(this)))}_attachPointerListeners(){this._delegate._isDisabled()||!this.$state.dragging()||(L(document,"pointerup",this._onDocumentPointerUp.bind(this)),L(document,"pointermove",this._onDocumentPointerMove.bind(this)),Xb&&L(document,"touchmove",this._onDocumentTouchMove.bind(this),{passive:!1}))}_onFocus(){this._updatePointerValue(this.$state.value())}_updateValue(e,n){let{value:i,min:r,max:s,dragging:o}=this.$state,a=Math.max(r(),Math.min(e,s()));i.set(a);let l=this.createEvent("value-change",{detail:a,trigger:n});if(this.dispatch(l),this._delegate._onValueChange?.(l),o()){let c=this.createEvent("drag-value-change",{detail:a,trigger:n});this.dispatch(c),this._delegate._onDragValueChange?.(c)}}_updatePointerValue(e,n){let{pointerValue:i,dragging:r}=this.$state;i.set(e),this.dispatch("pointer-value-change",{detail:e,trigger:n}),r()&&this._updateValue(e,n)}_getPointerValue(e){let n,i=this.el.getBoundingClientRect(),{min:r,max:s}=this.$state;if(this.$props.orientation()==="vertical"){let{bottom:o,height:a}=i;n=(o-e.clientY)/a}else if(this._touch&&dt(this._touchStartValue)){let{width:o}=this._provider.getBoundingClientRect(),a=(e.clientX-this._touch.clientX)/o,l=s()-r(),c=l*Math.abs(a);n=(a<0?this._touchStartValue-c:this._touchStartValue+c)/l}else{let{left:o,width:a}=i;n=(e.clientX-o)/a}return Math.max(r(),Math.min(s(),this._delegate._roundValue(f6(r(),s(),n,this._delegate._getStep()))))}_onPointerEnter(e){this.$state.pointing.set(!0)}_onPointerMove(e){let{dragging:n}=this.$state;n()||this._updatePointerValue(this._getPointerValue(e),e)}_onPointerLeave(e){this.$state.pointing.set(!1)}_onPointerDown(e){if(e.button!==0)return;let n=this._getPointerValue(e);this._onStartDragging(n,e),this._updatePointerValue(n,e)}_onStartDragging(e,n){let{dragging:i}=this.$state;if(i())return;i.set(!0),this._media.remote.pauseControls(n);let r=this.createEvent("drag-start",{detail:e,trigger:n});this.dispatch(r),this._delegate._onDragStart?.(r)}_onStopDragging(e,n){let{dragging:i}=this.$state;if(!i())return;i.set(!1),this._media.remote.resumeControls(n);let r=this.createEvent("drag-end",{detail:e,trigger:n});this.dispatch(r),this._delegate._onDragEnd?.(r),this._touch=null,this._touchStartValue=null}_onKeyDown(e){let{key:n}=e,{min:i,max:r}=this.$state,s;if(n==="Home"||n==="PageUp"?s=i():n==="End"||n==="PageDown"?s=r():!e.metaKey&&/[0-9]/.test(n)&&(s=(r()-i())/10*Number(n)),!Qe(s)){this._updatePointerValue(s,e),this._updateValue(s,e);return}let o=this._getKeyValue(e);if(Qe(o))return;let a=n===this._lastDownKey;!this.$state.dragging()&&a&&this._onStartDragging(o,e),this._updatePointerValue(o,e),a||this._updateValue(o,e),this._lastDownKey=n}_onKeyUp(e){this._lastDownKey="";let{dragging:n,value:i}=this.$state;if(!n())return;let r=this._getKeyValue(e)??i();this._updatePointerValue(r),this._onStopDragging(r,e)}_getKeyValue(e){let{key:n,shiftKey:i}=e;if(!Object.keys(J$).includes(n))return;e.preventDefault(),e.stopPropagation();let{shiftKeyMultiplier:s}=this.$props,{value:o,min:a,max:l}=this.$state,c=this._delegate._getStep(),u=this._delegate._getKeyStep(),d=i?u*s():u,p=Number(J$[n]),h=d*p,m=(o()+h)/c;return Math.max(a(),Math.min(l(),Number((c*m).toFixed(3))))}_onDocumentPointerUp(e){if(e.button!==0)return;let n=this._getPointerValue(e);this._updatePointerValue(n,e),this._onStopDragging(n,e)}_onDocumentTouchMove(e){e.preventDefault()}},Gu=er(()=>({})),ug=er(),rr=class extends sn{constructor(e){super(),this._delegate=e,this._updateSliderVars=_s((n,i)=>{this.el?.style.setProperty("--slider-fill",n+"%"),this.el?.style.setProperty("--slider-pointer",i+"%")})}onSetup(){this._media=Ee();let e=new Hn;e.attach(this),this.$state.focused=e.focused.bind(e),ci(Gu)||on(Gu,{default:"value"}),on(ug,{_orientation:this.$props.orientation,_disabled:this._delegate._isDisabled,_preview:K(null)}),S(this._watchValue.bind(this)),S(this._watchDisabled.bind(this)),this._setupAttrs(),new qx(this._delegate,this._media).attach(this)}onAttach(e){Ne(e,"role","slider"),Ne(e,"tabindex","0"),Ne(e,"autocomplete","off"),B?this._watchCSSVars():S(this._watchCSSVars.bind(this))}_watchValue(){let{dragging:e,value:n,min:i,max:r}=this.$state;N(e)||n.set(h6(i(),r(),n(),this._delegate._getStep()))}_watchDisabled(){if(!this._delegate._isDisabled())return;let{dragging:e,pointing:n}=this.$state;e.set(!1),n.set(!1)}_getARIADisabled(){return il(this._delegate._isDisabled())}_setupAttrs(){let{orientation:e}=this.$props,{dragging:n,active:i,pointing:r}=this.$state;this.setAttributes({"data-dragging":n,"data-pointing":r,"data-active":i,"aria-disabled":this._getARIADisabled.bind(this),"aria-valuemin":this.$state.min,"aria-valuemax":this.$state.max,"aria-valuenow":this._delegate._getARIAValueNow,"aria-valuetext":this._delegate._getARIAValueText,"aria-orientation":e})}_watchCSSVars(){let{fillPercent:e,pointerPercent:n}=this.$state;this._updateSliderVars(cn(e(),3),cn(n(),3))}};rr.props={disabled:!1,step:1,keyStep:1,orientation:"horizontal",shiftKeyMultiplier:5};Or=class extends ie{constructor(){super(),new rr({_getStep:this.$props.step,_getKeyStep:this.$props.keyStep,_roundValue:Math.round,_isDisabled:this.$props.disabled,_getARIAValueNow:this._getARIAValueNow.bind(this),_getARIAValueText:this._getARIAValueText.bind(this)})}onSetup(){S(this._watchValue.bind(this)),S(this._watchMinMax.bind(this))}_getARIAValueNow(){let{value:e}=this.$state;return Math.round(e())}_getARIAValueText(){let{value:e,max:n}=this.$state;return cn(e()/n()*100,2)+"%"}_watchValue(){let{value:e}=this.$props;this.$state.value.set(e())}_watchMinMax(){let{min:e,max:n}=this.$props;this.$state.min.set(e()),this.$state.max.set(n())}};Or.props={...rr.props,min:0,max:100,value:0};Or.state=cg;Ar=new Map,gm=new Map,Zm=class t{constructor(e,n,i){this.$src=e,this.$crossOrigin=n,this._media=i,this.$images=K([]),S(this._onLoadCues.bind(this))}static create(e,n){let i=Ee();return new t(e,n,i)}_onLoadCues(){let{canLoad:e}=this._media.$state;if(!e())return;let n=this.$src(),i=new AbortController;if(n){if(Z(n)&&Ar.has(n)){let r=Ar.get(n);if(Ar.delete(n),Ar.set(n,r),Ar.size>30){let s=Ar.keys().next().value;Ar.delete(s)}this.$images.set(Ar.get(n))}else if(Z(n)){let r=this.$crossOrigin(),s=n+"::"+r;if(!gm.has(s)){let o=new Promise(async(a,l)=>{try{let c=await fetch(n,{signal:i.signal,credentials:_m(r)});if(c.headers.get("content-type")==="application/json"){let d=await c.json();if(ut(d))if(d[0]&&"text"in d)a(this._processVTTCues(d));else{for(let p=0;p(Du(),Au)).then(async({parseResponse:d})=>{try{let{cues:p}=await d(c);a(this._processVTTCues(p))}catch(p){l(p)}})}catch(c){l(c)}}).then(a=>(i.signal.aborted||Ar.set(s,a),a)).catch(a=>{i.signal.aborted||this._onError(n,a)}).finally(()=>{Z(s)&&gm.delete(s)});gm.set(s,o)}gm.get(s)?.then(o=>{i.signal.aborted||this.$images.set(o||[])})}else if(ut(n))try{this.$images.set(this._processImages(n))}catch(r){this._onError(n,r)}else try{this.$images.set(this._processStoryboard(n))}catch(r){this._onError(n,r)}return()=>{i.abort(),this.$images.set([])}}}_processImages(e){let n=this._resolveBaseUrl();return e.map((i,r)=>(Lr(i.url&&Z(i.url),!1),Lr("startTime"in i&&dt(i.startTime),!1),{...i,url:Z(i.url)?this._resolveURL(i.url,n):i.url}))}_processStoryboard(e){Lr(Z(e.url),!1),Lr(ut(e.tiles)&&e.tiles?.length,!1);let n=new URL(e.url),i=[],r="tile_width"in e?e.tile_width:e.tileWidth,s="tile_height"in e?e.tile_height:e.tileHeight;for(let o of e.tiles)i.push({url:n,startTime:"start"in o?o.start:o.startTime,width:r,height:s,coords:{x:o.x,y:o.y}});return i}_processVTTCues(e){for(let r=0;r{this._resetStyles(),n.set(!1),i.set(null)}}_onLoaded(){let{loading:e,error:n}=this.$state;e.set(!1),n.set(null)}_onError(e){let{loading:n,error:i}=this.$state;n.set(!1),i.set(e)}_isLoading(){let{loading:e,hidden:n}=this.$state;return!n()&&e()}_hasError(){let{error:e}=this.$state;return!Ji(e())}_watchHidden(){let{hidden:e}=this.$state,{duration:n}=this._media.$state,i=this._loader.$images();e.set(this._hasError()||!Number.isFinite(n())||i.length===0)}_getTime(){return this.$props.time()}_onFindActiveThumbnail(){let e=this._getTime(),{src:n,activeThumbnail:i}=this.$state,r=this._loader.$images(),s=-1,o=null;for(let a=r.length-1;a>=0;a--){let l=r[a];if(e>=l.startTime&&(!l.endTime||e1?h:1;this._style(e,"--thumbnail-width",`${s*v}px`),this._style(e,"--thumbnail-height",`${o*v}px`),this._style(n,"width",`${n.naturalWidth*v}px`),this._style(n,"height",`${n.naturalHeight*v}px`),this._style(n,"transform",r.coords?`translate(-${r.coords.x*v}px, -${r.coords.y*v}px)`:""),this._style(n,"max-width","none")}_style(e,n,i){e.style.setProperty(n,i),this._styleResets.push(()=>e.style.removeProperty(n))}_resetStyles(){for(let e of this._styleResets)e();this._styleResets=[]}};gl.props={src:null,time:0,crossOrigin:null};gl.state=new Ii({src:"",img:null,thumbnails:[],activeThumbnail:null,crossOrigin:null,loading:!1,error:null,hidden:!1});Jm=class extends gl{onAttach(e){this._slider=mo(Or.state)}_getTime(){let{duration:e,clipStartTime:n}=this._media.$state;return n()+this._slider.pointerRate()*e()}},m6=Object.defineProperty,g6=Object.getOwnPropertyDescriptor,y6=(t,e,n,i)=>{for(var r=i>1?void 0:i?g6(e,n):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(r=(i?o(e,n,r):o(r))||r);return i&&r&&m6(e,n,r),r},xo=class extends ie{get video(){return this.$state.video()}onSetup(){this._media=Ee(),this._slider=mo(Or.state),this._watchCrossOrigin(),this.setAttributes({"data-loading":this._isLoading.bind(this),"data-hidden":this.$state.hidden,"data-error":this._hasError.bind(this),"aria-hidden":Pn(this.$state.hidden)})}onAttach(e){S(this._watchVideo.bind(this)),S(this._watchSrc.bind(this)),S(this._watchCrossOrigin.bind(this)),S(this._watchHidden.bind(this)),S(this._onSrcChange.bind(this)),S(this._onUpdateTime.bind(this))}_watchVideo(){let e=this.$state.video();e&&(e.readyState>=2&&this._onCanPlay(),L(e,"canplay",this._onCanPlay.bind(this)),L(e,"error",this._onError.bind(this)))}_watchSrc(){let{src:e}=this.$state,{canLoad:n}=this._media.$state;e.set(n()?this.$props.src():null)}_watchCrossOrigin(){let{crossOrigin:e}=this.$props,{crossOrigin:n}=this.$state,{crossOrigin:i}=this._media.$state,r=e()!==null?e():i();n.set(r===!0?"anonymous":r)}_isLoading(){let{canPlay:e,hidden:n}=this.$state;return!e()&&!n()}_hasError(){let{error:e}=this.$state;return!Ji(e)}_watchHidden(){let{src:e,hidden:n}=this.$state,{canLoad:i,duration:r}=this._media.$state;n.set(i()&&(!e()||this._hasError()||!Number.isFinite(r())))}_onSrcChange(){let{src:e,canPlay:n,error:i}=this.$state;e(),n.set(!1),i.set(null)}_onCanPlay(e){let{canPlay:n,error:i}=this.$state;n.set(!0),i.set(null),this.dispatch("can-play",{trigger:e})}_onError(e){let{canPlay:n,error:i}=this.$state;n.set(!1),i.set(e),this.dispatch("error",{trigger:e})}_onUpdateTime(){let{video:e,canPlay:n}=this.$state,{duration:i}=this._media.$state,{pointerRate:r}=this._slider,s=e();n()&&s&&Number.isFinite(i())&&Number.isFinite(r())&&(s.currentTime=r()*i())}};xo.props={src:null,crossOrigin:null};xo.state=new Ii({video:null,src:null,crossOrigin:null,canPlay:!1,error:null,hidden:!1});y6([he],xo.prototype,"video",1);v6=Object.defineProperty,w6=Object.getOwnPropertyDescriptor,_6=(t,e,n,i)=>{for(var r=i>1?void 0:i?w6(e,n):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(r=(i?o(e,n,r):o(r))||r);return i&&r&&v6(e,n,r),r},yl=class extends ie{onSetup(){this._slider=mo(Or.state),this._format=Xe(Gu),this._text=Zi(this.getValueText.bind(this))}getValueText(){let{type:e,format:n,decimalPlaces:i,padHours:r,padMinutes:s,showHours:o}=this.$props,{value:a,pointerValue:l,min:c,max:u}=this._slider,d=n()??this._format.default,p=e()==="current"?a():l();if(d==="percent"){let h=u()-c(),m=p/h*100;return(this._format.percent??cn)(m,i())+"\uFE6A"}else return d==="time"?(this._format.time??Ms)(p,r(),s(),o()):this._format.value?.(p)??p.toFixed(2)}};yl.props={type:"pointer",format:null,showHours:!1,padHours:null,padMinutes:null,decimalPlaces:2};_6([Ze],yl.prototype,"getValueText",1);Qu=class extends ie{constructor(){super(...arguments),this._updatePlacement=_s(()=>{let{_disabled:e,_orientation:n}=this._slider;if(e())return;let i=this.el,{offset:r,noClamp:s}=this.$props;ak(i,{clamp:!s(),offset:r(),orientation:n()})})}onSetup(){this._slider=Xe(ug);let{active:e}=mo(Or.state);this.setAttributes({"data-visible":e})}onAttach(e){Object.assign(e.style,{position:"absolute",top:0,left:0,width:"max-content"})}onConnect(e){let{_preview:n}=this._slider;n.set(e),ae(()=>n.set(null)),S(this._updatePlacement.bind(this));let i=new ResizeObserver(this._updatePlacement.bind(this));i.observe(e),ae(()=>i.disconnect())}};Qu.props={offset:0,noClamp:!1};Xu=class extends ie{constructor(){super(...arguments),this._throttleVolumeChange=Ad(this._onVolumeChange.bind(this),25)}onSetup(){this._media=Ee(),on(Gu,{default:"percent"}),new rr({_getStep:this.$props.step,_getKeyStep:this.$props.keyStep,_isDisabled:this.$props.disabled,_roundValue:Math.round,_getARIAValueNow:this._getARIAValueNow.bind(this),_getARIAValueText:this._getARIAValueText.bind(this),_onDragValueChange:this._onDragValueChange.bind(this),_onValueChange:this._onValueChange.bind(this)}).attach(this),S(this._watchVolume.bind(this))}onAttach(e){e.setAttribute("data-media-volume-slider",""),Ne(e,"aria-label","Volume");let{canSetVolume:n}=this._media.$state;this.setAttributes({"data-supported":n,"aria-hidden":Pn(()=>!n())})}_getARIAValueNow(){let{value:e}=this.$state;return Math.round(e())}_getARIAValueText(){let{value:e,max:n}=this.$state;return cn(e()/n()*100,2)+"%"}_watchVolume(){let{muted:e,volume:n}=this._media.$state,i=e()?0:n()*100;this.$state.value.set(i),this.dispatch("value-change",{detail:i})}_onVolumeChange(e){if(!e.trigger)return;let n=cn(e.detail/100,3);this._media.remote.changeVolume(n,e)}_onValueChange(e){this._throttleVolumeChange(e)}_onDragValueChange(e){this._throttleVolumeChange(e)}};Xu.props={...rr.props,keyStep:5,shiftKeyMultiplier:2};Xu.state=cg;vl=class extends ie{constructor(){super(),this._chapter=K(null),this._playingBeforeDragStart=!1,new rr({_swipeGesture:!0,_getStep:this._getStep.bind(this),_getKeyStep:this._getKeyStep.bind(this),_isDisabled:this._isDisabled.bind(this),_roundValue:this._roundValue,_getARIAValueNow:this._getARIAValueNow.bind(this),_getARIAValueText:this._getARIAValueText.bind(this),_onDragStart:this._onDragStart.bind(this),_onDragValueChange:this._onDragValueChange.bind(this),_onDragEnd:this._onDragEnd.bind(this),_onValueChange:this._onValueChange.bind(this)})}onSetup(){this._media=Ee(),on(Gu,{default:"time",value:this._formatValue.bind(this),time:this._formatTime.bind(this)}),this.setAttributes({"data-chapters":this._hasChapters.bind(this)}),this.setStyles({"--slider-progress":this._calcBufferedPercent.bind(this)}),S(this._watchCurrentTime.bind(this)),S(this._watchSeekingThrottle.bind(this))}onAttach(e){e.setAttribute("data-media-time-slider",""),Ne(e,"aria-label","Seek")}onConnect(e){S(this._watchPreviewing.bind(this)),xl(this._media.textTracks,"chapters",this._chapter.set)}_calcBufferedPercent(){let{bufferedEnd:e,duration:n}=this._media.$state;return cn(Math.min(e()/Math.max(n(),1),1)*100,3)+"%"}_hasChapters(){let{duration:e}=this._media.$state;return this._chapter()?.cues.length&&Number.isFinite(e())&&e()>0}_watchSeekingThrottle(){this._dispatchSeeking=Ad(this._seeking.bind(this),this.$props.seekingRequestThrottle())}_watchCurrentTime(){let{currentTime:e}=this._media.$state,{value:n,dragging:i}=this.$state,r=this._timeToPercent(e());N(i)||(n.set(r),this.dispatch("value-change",{detail:r}))}_watchPreviewing(){let e=this._media.player.el,{_preview:n}=Xe(ug);e&&n()&&pe(e,"data-preview",this.$state.active())}_seeking(e,n){this._media.remote.seeking(e,n)}_seek(e,n,i){this._dispatchSeeking.cancel();let{live:r}=this._media.$state;if(r()&&n>=99){this._media.remote.seekToLiveEdge(i);return}this._media.remote.seek(e,i)}_onDragStart(e){let{pauseWhileDragging:n}=this.$props;if(n()){let{paused:i}=this._media.$state;this._playingBeforeDragStart=!i(),this._media.remote.pause(e)}}_onDragValueChange(e){this._dispatchSeeking(this._percentToTime(e.detail),e)}_onDragEnd(e){let n=e.detail;this._seek(this._percentToTime(n),n,e);let{pauseWhileDragging:i}=this.$props;i()&&this._playingBeforeDragStart&&(this._media.remote.play(e),this._playingBeforeDragStart=!1)}_onValueChange(e){let{dragging:n}=this.$state;n()||!e.trigger||this._onDragEnd(e)}_getStep(){let e=this.$props.step()/this._media.$state.duration()*100;return Number.isFinite(e)?e:1}_getKeyStep(){let e=this.$props.keyStep()/this._media.$state.duration()*100;return Number.isFinite(e)?e:1}_roundValue(e){return cn(e,3)}_isDisabled(){let{canSeek:e}=this._media.$state;return this.$props.disabled()||!e()}_getARIAValueNow(){let{value:e}=this.$state;return Math.round(e())}_getARIAValueText(){let e=this._percentToTime(this.$state.value()),{duration:n}=this._media.$state;return Number.isFinite(e)?`${Yu(e)} out of ${Yu(n())}`:"live"}_percentToTime(e){let{duration:n}=this._media.$state;return cn(e/100*n(),5)}_timeToPercent(e){let{liveEdge:n,duration:i}=this._media.$state,r=Math.max(0,Math.min(1,n()?1:Math.min(e,i())/i()));return Number.isNaN(r)?0:Number.isFinite(r)?r*100:100}_formatValue(e){let n=this._percentToTime(e),{live:i,duration:r}=this._media.$state;return Number.isFinite(n)?(i()?n-r():n).toFixed(0):"LIVE"}_formatTime(e,n,i,r){let s=this._percentToTime(e),{live:o,duration:a}=this._media.$state,l=o()?s-a():s;return Number.isFinite(s)?`${l<0?"-":""}${Ms(Math.abs(l),n,i,r)}`:"LIVE"}};vl.props={...rr.props,step:.1,keyStep:5,shiftKeyMultiplier:2,pauseWhileDragging:!1,seekingRequestThrottle:100};vl.state=cg;b6=Object.defineProperty,x6=Object.getOwnPropertyDescriptor,dg=(t,e,n,i)=>{for(var r=i>1?void 0:i?x6(e,n):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(r=(i?o(e,n,r):o(r))||r);return i&&r&&b6(e,n,r),r},Fr=class extends ie{constructor(){super(...arguments),this._titleRef=null,this._refs=[],this._$track=K(null),this._$cues=K([]),this._activeIndex=K(-1),this._activePointerIndex=K(-1),this._bufferedIndex=0,this._updateBufferedPercent=_s(e=>{let n,i=this._$cues(),{clipStartTime:r}=this._media.$state,s=r(),o=this._getEndTime(i);for(let a=this._bufferedIndex;a{let e=N(this._$track);!this.scope||!e||!e.cues.length||(this._$cues.set(this._fillGaps(e.cues)),this._activeIndex.set(0),this._bufferedIndex=0)},150,!0)}get cues(){return this._$cues()}get activeCue(){return this._$cues()[this._activeIndex()]||null}get activePointerCue(){return this._$cues()[this._activePointerIndex()]||null}onSetup(){this._media=Ee(),this._sliderState=mo(vl.state)}onAttach(e){xl(this._media.textTracks,"chapters",this._setTrack.bind(this)),S(this._onTrackChange.bind(this))}onConnect(){ae(()=>this._reset.bind(this))}onDestroy(){this._setTrack(null)}setRefs(e){if(this._refs=e,this._updateScope?.dispose(),this._refs.length===1){let n=this._refs[0];n.style.width="100%",n.style.setProperty("--chapter-fill","var(--slider-fill)"),n.style.setProperty("--chapter-progress","var(--slider-progress)")}else this._refs.length>0&&Ct(()=>this._watch(),this._updateScope=rn())}_setTrack(e){N(this._$track)!==e&&(this._reset(),this._$track.set(e))}_reset(){this._refs=[],this._$cues.set([]),this._activeIndex.set(-1),this._activePointerIndex.set(-1),this._bufferedIndex=0,this._updateScope?.dispose()}_watch(){this._refs.length&&(S(this._watchContainerWidths.bind(this)),S(this._watchFillPercent.bind(this)),S(this._watchPointerPercent.bind(this)),S(this._watchBufferedPercent.bind(this)))}_watchContainerWidths(){let e=this._$cues();if(!e.length)return;let n,{clipStartTime:i,clipEndTime:r}=this._media.$state,s=i(),o=r()||e[e.length-1].endTime,a=o-s,l=100;for(let c=0;cc?this._updateFillPercents(c,d,"100%"):d=0&&i<100)return l;return 0}_watchBufferedPercent(){this._updateBufferedPercent(this._bufferedPercent())}_calcMediaBufferedPercent(){let{bufferedEnd:e,duration:n}=this._media.$state;return cn(Math.min(e()/Math.max(n(),1),1),3)*100}_getEndTime(e){let{clipEndTime:n}=this._media.$state,i=n();return i>0?i:e[e.length-1]?.endTime||0}_calcPercent(e,n,i,r){if(this._$cues().length===0)return 0;let o=r-i,a=Math.max(0,e.startTime-i),l=Math.min(r,e.endTime)-i,c=a/o,u=c*100,d=Math.min(1,c+(l-a)/o)*100;return Math.max(0,cn(n>=d?100:(n-u)/(d-u)*100,3))}_fillGaps(e){let n=[],{clipStartTime:i,clipEndTime:r,duration:s}=this._media.$state,o=i(),a=r()||1/0;e=e.filter(u=>u.startTime<=a&&u.endTime>=o);let l=e[0];l&&l.startTime>o&&n.push(new window.VTTCue(o,l.startTime,""));for(let u=0;u0&&n.push(new window.VTTCue(d.endTime,d.endTime+h,""))}}let c=e[e.length-1];return c&&(n.push(c),s()>=0&&(a===0||a!==1/0&&c.endTime1&&n.push(new window.VTTCue(c.endTime,s(),""))),n}_onTrackChange(){if(!this.scope)return;let{disabled:e}=this.$props;if(e()){this._$cues.set([]),this._activeIndex.set(0),this._bufferedIndex=0;return}let n=this._$track();if(n){let i=this._onCuesChange.bind(this);i(),ae(L(n,"add-cue",i)),ae(L(n,"remove-cue",i)),S(this._watchMediaDuration.bind(this))}return this._titleRef=this._findChapterTitleRef(),this._titleRef&&S(this._onChapterTitleChange.bind(this)),()=>{this._titleRef&&(this._titleRef.textContent="",this._titleRef=null)}}_watchMediaDuration(){this._media.$state.duration(),this._onCuesChange()}_onChapterTitleChange(){let e=this.activePointerCue||this.activeCue;this._titleRef&&(this._titleRef.textContent=e?.text||"")}_findParentSlider(){let e=this.el;for(;e&&e.getAttribute("role")!=="slider";)e=e.parentElement;return e}_findChapterTitleRef(){let e=this._findParentSlider();return e?e.querySelector('[data-part="chapter-title"]'):null}};Fr.props={disabled:!1};dg([he],Fr.prototype,"cues",1);dg([he],Fr.prototype,"activeCue",1);dg([he],Fr.prototype,"activePointerCue",1);dg([Ze],Fr.prototype,"setRefs",1);Ft=er(),k6=["a[href]","[tabindex]","input","select","button"].map(t=>`${t}:not([aria-hidden='true'])`).join(","),eR=new Set(["Escape","Tab","ArrowUp","ArrowDown","Home","PageUp","End","PageDown","Enter"," "]),Wx=class{constructor(e){this._delegate=e,this._index=0,this._el=null,this._elements=[]}get _items(){return this._elements}_attachMenu(e){return L(e,"focus",this._onFocus.bind(this)),this._el=e,ae(()=>{this._el=null}),this}_listen(){this._el&&(this._update(),L(this._el,"keyup",this._onKeyUp.bind(this)),L(this._el,"keydown",this._onKeyDown.bind(this)),ae(()=>{this._index=0,this._elements=[]}))}_update(){this._index=0,this._elements=this._getFocusableElements()}_scroll(e=this._findActiveIndex()){let n=this._elements[e],i=this._delegate._getScrollContainer();n&&i&&requestAnimationFrame(()=>{i.scrollTop=n.offsetTop-i.offsetHeight/2+n.offsetHeight/2})}_focusAt(e){this._index=e,this._elements[e]?.focus(),this._scroll(e)}_findActiveIndex(){return this._elements.findIndex(e=>e.getAttribute("aria-checked")==="true")}_onFocus(){this._update(),setTimeout(()=>{let e=this._findActiveIndex();this._focusAt(e>=0?e:0)},100)}_onKeyUp(e){eR.has(e.key)&&(e.stopPropagation(),e.preventDefault())}_onKeyDown(e){if(eR.has(e.key))switch(e.stopPropagation(),e.preventDefault(),e.key){case"Escape":this._delegate._closeMenu(e);break;case"Tab":this._focusAt(this._nextIndex(e.shiftKey?-1:1));break;case"ArrowUp":this._focusAt(this._nextIndex(-1));break;case"ArrowDown":this._focusAt(this._nextIndex(1));break;case"Home":case"PageUp":this._focusAt(0);break;case"End":case"PageDown":this._focusAt(this._elements.length-1);break}}_nextIndex(e){let n=this._index;do n=(n+e+this._elements.length)%this._elements.length;while(this._elements[n]?.offsetParent===null);return n}_getFocusableElements(){if(!this._el)return[];let e=this._el.querySelectorAll(k6),n=[],i=r=>r.getAttribute("role")==="menu";for(let r of e)r instanceof HTMLElement&&r.offsetParent!==null&&bR(this._el,r,i)&&n.push(r);return n}},T6=Object.defineProperty,E6=Object.getOwnPropertyDescriptor,Dd=(t,e,n,i)=>{for(var r=i>1?void 0:i?E6(e,n):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(r=(i?o(e,n,r):o(r))||r);return i&&r&&T6(e,n,r),r},S6=0,Vr=class extends ie{constructor(){super(),this._expanded=K(!1),this._disabled=K(!1),this._trigger=K(null),this._content=K(null),this._isTriggerDisabled=K(!1),this._submenus=new Set,this._menuObserver=null,this._removeSubmenuBind=this._removeSubmenu.bind(this),this._onSubmenuOpenBind=this._onSubmenuOpen.bind(this),this._onSubmenuCloseBind=this._onSubmenuClose.bind(this),this._onResize=_s(()=>{let n=N(this._content);if(!n||B)return;let i=0,r=getComputedStyle(n),s=[...n.children];for(let o of["paddingTop","paddingBottom","borderTopWidth","borderBottomWidth"])i+=parseFloat(r[o])||0;for(let o of s)if(o instanceof HTMLElement&&o.style.display==="contents")s.push(...o.children);else if(o.nodeType===3)i+=parseFloat(getComputedStyle(o).fontSize);else if(o instanceof HTMLElement){let a=getComputedStyle(o);if(a.display==="none")continue;i+=o.offsetHeight+(parseFloat(a.marginTop)||0)+(parseFloat(a.marginBottom)||0)}requestAnimationFrame(()=>{Ot(n,"--menu-height",i+"px")})});let{showDelay:e}=this.$props;this._popper=new zm({_trigger:this._trigger,_content:this._content,_showDelay:e,_listen:(n,i,r)=>{Ss(n,o=>{this._expanded()?r(o):i(o)});let s=this._getCloseTarget();s&&Ss(s,o=>{o.stopPropagation(),r(o)})},_onChange:this._onExpandedChange.bind(this)})}get triggerElement(){return this._trigger()}get contentElement(){return this._content()}get isSubmenu(){return!!this._parentMenu}onSetup(){this._media=Ee();let e=++S6;this._menuId=`media-menu-${e}`,this._menuButtonId=`media-menu-button-${e}`,this._focus=new Wx({_getScrollContainer:this._findScrollContainer.bind(this),_closeMenu:this.close.bind(this)}),ci(Ft)&&(this._parentMenu=Xe(Ft)),this.setAttributes({"data-open":this._expanded,"data-submenu":this.isSubmenu,"data-disabled":this._isDisabled.bind(this)}),on(Ft,{_button:this._trigger,_expanded:this._expanded,_hint:K(""),_disable:this._disable.bind(this),_attachMenuButton:this._attachMenuButton.bind(this),_attachMenuItems:this._attachMenuItems.bind(this),_attachObserver:this._attachObserver.bind(this),_disableMenuButton:this._disableMenuButton.bind(this),_addSubmenu:this._addSubmenu.bind(this)})}onAttach(e){e.style.setProperty("display","contents"),this._focus._attachMenu(e)}onConnect(e){S(this._watchExpanded.bind(this)),this.isSubmenu&&this._parentMenu?._addSubmenu(this)}onDestroy(){this._trigger.set(null),this._content.set(null),this._menuObserver=null}_watchExpanded(){let e=this._isExpanded();this.isSubmenu||this._onResize(),this._updateMenuItemsHidden(e),e&&(S(()=>{let{height:n}=this._media.$state,i=this._content();i&&Ot(i,"--player-height",n()+"px")}),this._focus._listen(),this.listen("pointerup",this._onPointerUp.bind(this)),L(window,"pointerup",this._onWindowPointerUp.bind(this)))}_attachMenuButton(e){let n=e.el,i=this.isSubmenu,r=Pn(this._isDisabled.bind(this));Ne(n,"tabindex",i?"-1":"0"),Ne(n,"role",i?"menuitem":"button"),pe(n,"id",this._menuButtonId),pe(n,"aria-haspopup","menu"),pe(n,"aria-expanded","false"),pe(n,"data-submenu",this.isSubmenu),this.isSubmenu||this._stopClickPropagation(n);let s=()=>{pe(n,"data-open",this._expanded()),pe(n,"aria-disabled",r())};B?s():S(s),this._trigger.set(n),ae(()=>{this._trigger.set(null)})}_attachMenuItems(e){let n=e.el;n.style.setProperty("display","none"),pe(n,"id",this._menuId),Ne(n,"role","menu"),Ne(n,"tabindex","-1"),pe(n,"data-submenu",this.isSubmenu),this._content.set(n),ae(()=>this._content.set(null));let i=()=>pe(n,"data-open",this._expanded());if(B?i():S(i),this._focus._attachMenu(n),this._updateMenuItemsHidden(!1),!this.isSubmenu){let r=this._onResizeTransition.bind(this);e.listen("transitionstart",r),e.listen("transitionend",r),e.listen("vds-menu-resize",this._onResize)}}_attachObserver(e){this._menuObserver=e}_stopClickPropagation(e){L(e,"click",n=>n.stopPropagation()),L(e,"pointerup",n=>n.stopPropagation())}_updateMenuItemsHidden(e){let n=N(this._content);n&&pe(n,"aria-hidden",il(!e))}_disableMenuButton(e){this._isTriggerDisabled.set(e)}_onExpandedChange(e,n){if(n?.stopPropagation(),this._expanded()===e)return;if(this._isDisabled()){e&&this._popper.hide(n);return}this.el?.dispatchEvent(new Event("vds-menu-resize",{bubbles:!0,composed:!0}));let i=this._trigger(),r=this._content();if(i&&(pe(i,"aria-controls",e&&this._menuId),pe(i,"aria-expanded",il(e))),r&&pe(r,"aria-labelledby",e&&this._menuButtonId),this._expanded.set(e),this._toggleMediaControls(n),Li(),Mr(n)){e?r?.focus():i?.focus();for(let s of[this.el,r])s&&s.setAttribute("data-keyboard","")}else for(let s of[this.el,r])s&&s.removeAttribute("data-keyboard");this.dispatch(e?"open":"close",{trigger:n}),e?(!this.isSubmenu&&this._media.activeMenu!==this&&(this._media.activeMenu?.close(n),this._media.activeMenu=this),this._menuObserver?._onOpen?.(n)):(this.isSubmenu?setTimeout(()=>{for(let s of this._submenus)s.close(n)},300):this._media.activeMenu=null,this._menuObserver?._onClose?.(n)),e&&!Mr(n)&&requestAnimationFrame(()=>{this._focus._update(),setTimeout(()=>{this._focus._scroll()},100)})}_isExpanded(){return!this._isDisabled()&&this._expanded()}_isDisabled(){return this._disabled()||this._isTriggerDisabled()}_disable(e){this._disabled.set(e)}_onPointerUp(e){e.stopPropagation()}_onWindowPointerUp(e){if(!(!(e.target instanceof Node)||this._content()?.contains(e.target))){if(this.isSubmenu)return setTimeout(this.close.bind(this,e),800);this.close(e)}}_getCloseTarget(){let e=this.el?.querySelector('[data-part="close-target"]');return this.el&&e&&bR(this.el,e,n=>n.getAttribute("role")==="menu")?e:null}_findScrollContainer(){if(this.isSubmenu){let e=this.el;for(;e&&e.tagName!=="media-menu"&&e.hasAttribute("data-submenu");)e=e.parentNode;return e}else return N(this._content)||null}_toggleMediaControls(e){this.isSubmenu||(this._expanded()?this._media.remote.pauseControls(e):this._media.remote.resumeControls(e))}_addSubmenu(e){this._submenus.add(e),L(e,"open",this._onSubmenuOpenBind),L(e,"close",this._onSubmenuCloseBind),ae(this._removeSubmenuBind)}_removeSubmenu(e){this._submenus.delete(e)}_onSubmenuOpen(e){this.isSubmenu&&this.triggerElement?.setAttribute("aria-hidden","true");for(let n of this._submenus)if(n!==e.target)for(let i of[n.el,n.triggerElement])i?.setAttribute("aria-hidden","true")}_onSubmenuClose(){this.isSubmenu&&this.triggerElement?.setAttribute("aria-hidden","false");for(let e of this._submenus)for(let n of[e.el,e.triggerElement])n?.setAttribute("aria-hidden","false")}_onResizeTransition(e){let n=this._content();if(n&&e.propertyName==="height"){let i=e.type==="transitionstart";pe(n,"data-resizing",i)}}open(e){N(this._expanded)||(this._popper.show(e),Li())}close(e){N(this._expanded)&&(this._popper.hide(e),Li())}};Vr.props={showDelay:0};Dd([he],Vr.prototype,"triggerElement",1);Dd([he],Vr.prototype,"contentElement",1);Dd([he],Vr.prototype,"isSubmenu",1);Dd([Ze],Vr.prototype,"open",1);Dd([Ze],Vr.prototype,"close",1);P6=Object.defineProperty,C6=Object.getOwnPropertyDescriptor,M6=(t,e,n,i)=>{for(var r=i>1?void 0:i?C6(e,n):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(r=(i?o(e,n,r):o(r))||r);return i&&r&&P6(e,n,r),r},ko=class extends ie{get expanded(){return this._menu?._expanded()??!1}constructor(){super(),new Hn}onSetup(){this._menu=Xe(Ft)}onAttach(e){this._menu._attachMenuButton(this),S(this._watchDisabled.bind(this)),Ne(e,"type","button")}onConnect(e){let n=Array.from(e.querySelectorAll('[data-part="hint"]')).pop();n&&S(()=>{let i=this._menu._hint();i&&(n.textContent=i)}),Ss(e,i=>{this.dispatch("select",{trigger:i})})}_watchDisabled(){this._menu._disableMenuButton(this.$props.disabled())}};ko.props={disabled:!1};M6([he],ko.prototype,"expanded",1);eg=class extends ko{},tg=class extends ie{constructor(){super(...arguments),this._target=null}onSetup(){this._media=Ee(),on(ju,{_attach:this._attachElement.bind(this)})}onAttach(e){e.style.setProperty("display","contents")}onConnect(e){}onDestroy(){this._target?.remove(),this._target=null}_attachElement(e){this._portal(!1),this._target=e,km(()=>{km(()=>{this.connectScope&&S(this._watchDisabled.bind(this))})})}_watchDisabled(){let{fullscreen:e}=this._media.$state,{disabled:n}=this.$props,i=n();this._portal(i==="fullscreen"?!e():!i)}_portal(e){if(!this._target)return;let n=this._getContainer(this.$props.container());if(!n)return;let i=this._target.parentElement===n;pe(this._target,"data-portal",e),e?i||(this._target.remove(),n.append(this._target)):i&&this._target.parentElement===n&&(this._target.remove(),this.el?.append(this._target))}_getContainer(e){return e instanceof HTMLElement?e:e?document.querySelector(e):document.body}};tg.props={container:null,disabled:!1};ju=er(),Zu=class extends ie{constructor(){super(),new Hn;let{placement:e}=this.$props;this.setAttributes({"data-placement":e})}onAttach(e){if(this._menu=Xe(Ft),this._menu._attachMenuItems(this),ci(ju)){let n=Xe(ju);n&&(on(ju,null),n._attach(e),ae(()=>n._attach(null)))}}onConnect(e){S(this._watchPlacement.bind(this))}_watchPlacement(){if(!this.el)return;let e=this.$props.placement();if(e){Object.assign(this.el.style,{position:"absolute",top:0,left:0,width:"max-content"});let{offset:n,alignOffset:i}=this.$props;return xR(this.el,this._getButton(),e,{offsetVarName:"media-menu",xOffset:i(),yOffset:n()})}else this.el.removeAttribute("style"),this.el.style.display="none"}_getButton(){return this._menu._button()}};Zu.props={placement:null,offset:0,alignOffset:0};Kx=er(),Ps=class extends sn{constructor(){super(...arguments),this._group=new Set,this._value=K(""),this._controller=null,this._onChangeBind=this._onChange.bind(this)}get _values(){return Array.from(this._group).map(e=>e._value())}get value(){return this._value()}set value(e){this._onChange(e)}onSetup(){on(Kx,{add:this._addRadio.bind(this),remove:this._removeRadio.bind(this)})}onAttach(e){ci(Ft)||Ne(e,"role","radiogroup"),this.setAttributes({value:this._value})}onDestroy(){this._group.clear()}_addRadio(e){this._group.has(e)||(this._group.add(e),e._onCheck=this._onChangeBind,e._check(e._value()===this._value()))}_removeRadio(e){e._onCheck=null,this._group.delete(e)}_onChange(e,n){let i=N(this._value);if(!e||e===i)return;let r=this._findRadio(i),s=this._findRadio(e);r?._check(!1,n),s?._check(!0,n),this._value.set(e),this._onValueChange?.(e,n)}_findRadio(e){for(let n of this._group)if(e===N(n._value))return n;return null}},$6=Object.defineProperty,R6=Object.getOwnPropertyDescriptor,VR=(t,e,n,i)=>{for(var r=i>1?void 0:i?R6(e,n):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(r=(i?o(e,n,r):o(r))||r);return i&&r&&$6(e,n,r),r},wl=class extends ie{get values(){return this._controller._values}get value(){return this._controller.value}set value(e){this._controller.value=e}constructor(){super(),this._controller=new Ps,this._controller._onValueChange=this._onValueChange.bind(this)}onSetup(){B?this._watchValue():S(this._watchValue.bind(this))}_watchValue(){this._controller.value=this.$props.value()}_onValueChange(e,n){let i=this.createEvent("change",{detail:e,trigger:n});this.dispatch(i)}};wl.props={value:""};VR([he],wl.prototype,"values",1);VR([he],wl.prototype,"value",1);I6=Object.defineProperty,L6=Object.getOwnPropertyDescriptor,A6=(t,e,n,i)=>{for(var r=i>1?void 0:i?L6(e,n):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(r=(i?o(e,n,r):o(r))||r);return i&&r&&I6(e,n,r),r},_l=class extends ie{constructor(){super(),this._checked=K(!1),this._controller={_value:this.$props.value,_check:this._check.bind(this),_onCheck:null},new Hn}get checked(){return this._checked()}onSetup(){this.setAttributes({value:this.$props.value,"data-checked":this._checked,"aria-checked":Pn(this._checked)})}onAttach(e){let n=ci(Ft);Ne(e,"tabindex",n?"-1":"0"),Ne(e,"role",n?"menuitemradio":"radio"),S(this._watchValue.bind(this))}onConnect(e){this._addToGroup(),Ss(e,this._onPress.bind(this)),ae(this._onDisconnect.bind(this))}_onDisconnect(){Ct(()=>{Xe(Kx).remove(this._controller)},this.connectScope)}_addToGroup(){Xe(Kx).add(this._controller)}_watchValue(){let{value:e}=this.$props,n=e();N(this._checked)&&this._controller._onCheck?.(n)}_onPress(e){N(this._checked)||(this._onChange(!0,e),this._onSelect(e),this._controller._onCheck?.(N(this.$props.value),e))}_check(e,n){N(this._checked)!==e&&this._onChange(e,n)}_onChange(e,n){this._checked.set(e),this.dispatch("change",{detail:e,trigger:n})}_onSelect(e){this.dispatch("select",{trigger:e})}};_l.props={value:""};A6([he],_l.prototype,"checked",1);D6=Object.defineProperty,N6=Object.getOwnPropertyDescriptor,lk=(t,e,n,i)=>{for(var r=i>1?void 0:i?N6(e,n):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(r=(i?o(e,n,r):o(r))||r);return i&&r&&D6(e,n,r),r},To=class extends ie{constructor(){super(),this._index=K(0),this._track=K(null),this._cues=K([]),this._controller=new Ps,this._controller._onValueChange=this._onValueChange.bind(this)}get value(){return this._controller.value}get disabled(){return!this._cues()?.length}onSetup(){this._media=Ee(),ci(Ft)&&(this._menu=Xe(Ft));let{thumbnails:e}=this.$props;this.setAttributes({"data-thumbnails":()=>!!e()})}onAttach(e){this._menu?._attachObserver({_onOpen:this._onOpen.bind(this)})}getOptions(){let{clipStartTime:e,clipEndTime:n}=this._media.$state,i=e(),r=n()||1/0;return this._cues().map((s,o)=>({cue:s,value:o.toString(),label:s.text,startTime:Ms(Math.max(0,s.startTime-i),!1),duration:Yu(Math.min(r,s.endTime)-Math.max(i,s.startTime))}))}_onOpen(){N(()=>this._watchCurrentTime())}onConnect(e){S(this._watchValue.bind(this)),S(this._watchCurrentTime.bind(this)),S(this._watchControllerDisabled.bind(this)),S(this._watchTrack.bind(this)),xl(this._media.textTracks,"chapters",this._track.set)}_watchTrack(){let e=this._track();if(!e)return;let n=this._onCuesChange.bind(this,e);return n(),L(e,"add-cue",n),L(e,"remove-cue",n),()=>{this._cues.set([])}}_onCuesChange(e){let{clipStartTime:n,clipEndTime:i}=this._media.$state,r=n(),s=i()||1/0;this._cues.set([...e.cues].filter(o=>o.startTime<=s&&o.endTime>=r))}_watchValue(){this._controller.value=this._getValue()}_watchCurrentTime(){if(!this._menu?._expanded())return;if(!this._track()){this._index.set(-1);return}let{realCurrentTime:n,clipStartTime:i,clipEndTime:r}=this._media.$state,s=i(),o=r()||1/0,a=n(),l=this._cues().findIndex(c=>bm(c,a));if(this._index.set(l),l>=0){let c=this._cues()[l],u=this.el.querySelector("[aria-checked='true']"),d=Math.max(s,c.startTime),p=Math.min(o,c.endTime)-d,h=Math.max(0,a-d)/p*100;u&&Ot(u,"--progress",cn(h,3)+"%")}}_watchControllerDisabled(){this._menu?._disable(this.disabled)}_getValue(){return this._index().toString()}_onValueChange(e,n){if(this.disabled||!n)return;let i=+e,r=this._cues(),{clipStartTime:s}=this._media.$state;dt(i)&&r?.[i]&&(this._index.set(i),this._media.remote.seek(r[i].startTime-s(),n),this.dispatch("change",{detail:r[i],trigger:n}))}};To.props={thumbnails:null};lk([he],To.prototype,"value",1);lk([he],To.prototype,"disabled",1);lk([Ze],To.prototype,"getOptions",1);O6=Object.defineProperty,F6=Object.getOwnPropertyDescriptor,ck=(t,e,n,i)=>{for(var r=i>1?void 0:i?F6(e,n):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(r=(i?o(e,n,r):o(r))||r);return i&&r&&O6(e,n,r),r},Eo=class extends ie{get value(){return this._controller.value}get disabled(){let{audioTracks:e}=this._media.$state;return e().length===0}constructor(){super(),this._controller=new Ps,this._controller._onValueChange=this._onValueChange.bind(this)}onSetup(){this._media=Ee(),ci(Ft)&&(this._menu=Xe(Ft))}onConnect(e){S(this._watchValue.bind(this)),S(this._watchControllerDisabled.bind(this)),S(this._watchHintText.bind(this))}getOptions(){let{audioTracks:e}=this._media.$state;return e().map(n=>({track:n,label:n.label,value:n.label.toLowerCase()}))}_watchValue(){this._controller.value=this._getValue()}_watchHintText(){let{emptyLabel:e}=this.$props,{audioTrack:n}=this._media.$state,i=n();this._menu?._hint.set(i?.label??e())}_watchControllerDisabled(){this._menu?._disable(this.disabled)}_getValue(){let{audioTrack:e}=this._media.$state,n=e();return n?n.label.toLowerCase():""}_onValueChange(e,n){if(this.disabled)return;let i=this._media.audioTracks.toArray().findIndex(r=>r.label.toLowerCase()===e);if(i>=0){let r=this._media.audioTracks[i];this._media.remote.changeAudioTrack(i,n),this.dispatch("change",{detail:r,trigger:n})}}};Eo.props={emptyLabel:"Default"};ck([he],Eo.prototype,"value",1);ck([he],Eo.prototype,"disabled",1);ck([Ze],Eo.prototype,"getOptions",1);V6=Object.defineProperty,z6=Object.getOwnPropertyDescriptor,uk=(t,e,n,i)=>{for(var r=i>1?void 0:i?z6(e,n):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(r=(i?o(e,n,r):o(r))||r);return i&&r&&V6(e,n,r),r},So=class extends ie{get value(){return this._controller.value}get disabled(){let{hasCaptions:e}=this._media.$state;return!e()}constructor(){super(),this._controller=new Ps,this._controller._onValueChange=this._onValueChange.bind(this)}onSetup(){this._media=Ee(),ci(Ft)&&(this._menu=Xe(Ft))}onConnect(e){super.onConnect?.(e),S(this._watchValue.bind(this)),S(this._watchControllerDisabled.bind(this)),S(this._watchHintText.bind(this))}getOptions(){let{offLabel:e}=this.$props,{textTracks:n}=this._media.$state;return[{value:"off",label:e},...n().filter(pt).map(i=>({track:i,label:i.label,value:this._getTrackValue(i)}))]}_watchValue(){this._controller.value=this._getValue()}_watchHintText(){let{offLabel:e}=this.$props,{textTrack:n}=this._media.$state,i=n();this._menu?._hint.set(i&&pt(i)&&i.mode==="showing"?i.label:e())}_watchControllerDisabled(){this._menu?._disable(this.disabled)}_getValue(){let{textTrack:e}=this._media.$state,n=e();return n&&pt(n)&&n.mode==="showing"?this._getTrackValue(n):"off"}_onValueChange(e,n){if(this.disabled)return;if(e==="off"){let r=this._media.textTracks.selected;if(r){let s=this._media.textTracks.toArray().indexOf(r);this._media.remote.changeTextTrackMode(s,"disabled",n),this.dispatch("change",{detail:null,trigger:n})}return}let i=this._media.textTracks.toArray().findIndex(r=>this._getTrackValue(r)===e);if(i>=0){let r=this._media.textTracks[i];this._media.remote.changeTextTrackMode(i,"showing",n),this.dispatch("change",{detail:r,trigger:n})}}_getTrackValue(e){return e.id+":"+e.kind+"-"+e.label.toLowerCase()}};So.props={offLabel:"Off"};uk([he],So.prototype,"value",1);uk([he],So.prototype,"disabled",1);uk([Ze],So.prototype,"getOptions",1);U6=Object.defineProperty,j6=Object.getOwnPropertyDescriptor,dk=(t,e,n,i)=>{for(var r=i>1?void 0:i?j6(e,n):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(r=(i?o(e,n,r):o(r))||r);return i&&r&&U6(e,n,r),r},Po=class extends ie{get value(){return this._controller.value}get disabled(){let{rates:e}=this.$props,{canSetPlaybackRate:n}=this._media.$state;return!n()||e().length===0}constructor(){super(),this._controller=new Ps,this._controller._onValueChange=this._onValueChange.bind(this)}onSetup(){this._media=Ee(),ci(Ft)&&(this._menu=Xe(Ft))}onConnect(e){S(this._watchValue.bind(this)),S(this._watchHintText.bind(this)),S(this._watchControllerDisabled.bind(this))}getOptions(){let{rates:e,normalLabel:n}=this.$props;return e().map(i=>({label:i===1?n:i+"\xD7",value:i.toString()}))}_watchValue(){this._controller.value=this._getValue()}_watchHintText(){let{normalLabel:e}=this.$props,{playbackRate:n}=this._media.$state,i=n();this._menu?._hint.set(i===1?e():i+"\xD7")}_watchControllerDisabled(){this._menu?._disable(this.disabled)}_getValue(){let{playbackRate:e}=this._media.$state;return e().toString()}_onValueChange(e,n){if(this.disabled)return;let i=+e;this._media.remote.changePlaybackRate(i,n),this.dispatch("change",{detail:i,trigger:n})}};Po.props={normalLabel:"Normal",rates:[.25,.5,.75,1,1.25,1.5,1.75,2]};dk([he],Po.prototype,"value",1);dk([he],Po.prototype,"disabled",1);dk([Ze],Po.prototype,"getOptions",1);B6=Object.defineProperty,H6=Object.getOwnPropertyDescriptor,pk=(t,e,n,i)=>{for(var r=i>1?void 0:i?H6(e,n):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(r=(i?o(e,n,r):o(r))||r);return i&&r&&B6(e,n,r),r},Co=class extends ie{constructor(){super(),this._sortedQualities=Zi(()=>{let{qualities:e}=this._media.$state;return[...e()].sort((n,i)=>i.height===n.height?i.bitrate-n.bitrate:i.height-n.height)}),this._controller=new Ps,this._controller._onValueChange=this._onValueChange.bind(this)}get value(){return this._controller.value}get disabled(){let{canSetQuality:e,qualities:n}=this._media.$state;return!e()||n().length===0}onSetup(){this._media=Ee(),ci(Ft)&&(this._menu=Xe(Ft))}onConnect(e){S(this._watchValue.bind(this)),S(this._watchControllerDisabled.bind(this)),S(this._watchHintText.bind(this))}getOptions(){let{autoLabel:e,hideBitrate:n}=this.$props;return[{value:"auto",label:e},...this._sortedQualities().map(i=>{let r=i.bitrate>=0?`${cn(i.bitrate/1e6,2)} Mbps`:null;return{quality:i,label:i.height+"p",value:this._getQualityId(i),bitrate:()=>n()?null:r}})]}_watchValue(){this._controller.value=this._getValue()}_watchHintText(){let{autoLabel:e}=this.$props,{autoQuality:n,quality:i}=this._media.$state,r=i()?i().height+"p":"";this._menu?._hint.set(n()?e()+(r?` (${r})`:""):r)}_watchControllerDisabled(){this._menu?._disable(this.disabled)}_onValueChange(e,n){if(this.disabled)return;if(e==="auto"){this._media.remote.changeQuality(-1,n),this.dispatch("change",{detail:"auto",trigger:n});return}let{qualities:i}=this._media.$state,r=N(i).findIndex(s=>this._getQualityId(s)===e);if(r>=0){let s=N(i)[r];this._media.remote.changeQuality(r,n),this.dispatch("change",{detail:s,trigger:n})}}_getValue(){let{quality:e,autoQuality:n}=this._media.$state;if(n())return"auto";let i=e();return i?this._getQualityId(i):"auto"}_getQualityId(e){return e.height+"_"+e.bitrate}};Co.props={autoLabel:"Auto",hideBitrate:!1};pk([he],Co.prototype,"value",1);pk([he],Co.prototype,"disabled",1);pk([Ze],Co.prototype,"getOptions",1);ng=class extends ie{constructor(){super(...arguments),this._provider=null,this._presses=0,this._pressTimerId=-1}onSetup(){this._media=Ee();let{event:e,action:n}=this.$props;this.setAttributes({event:e,action:n})}onAttach(e){e.setAttribute("data-media-gesture",""),e.style.setProperty("pointer-events","none")}onConnect(e){this._provider=this._media.player.el?.querySelector("[data-media-provider]"),S(this._attachListener.bind(this))}_attachListener(){let e=this.$props.event(),n=this.$props.disabled();!this._provider||!e||n||(/^dbl/.test(e)&&(e=e.split(/^dbl/)[1]),(e==="pointerup"||e==="pointerdown")&&this._media.$state.pointer()==="coarse"&&(e=e==="pointerup"?"touchend":"touchstart"),L(this._provider,e,this._acceptEvent.bind(this),{passive:!1}))}_acceptEvent(e){if(this.$props.disabled()||ku(e)&&(e.button!==0||this._media.activeMenu)||tl(e)&&this._media.activeMenu||nk(e)||!this._inBounds(e))return;if(e.MEDIA_GESTURE=!0,e.preventDefault(),!N(this.$props.event)?.startsWith("dbl"))this._presses===0&&setTimeout(()=>{this._presses===1&&this._handleEvent(e)},250);else if(this._presses===1){queueMicrotask(()=>this._handleEvent(e)),clearTimeout(this._pressTimerId),this._presses=0;return}this._presses===0&&(this._pressTimerId=window.setTimeout(()=>{this._presses=0},275)),this._presses++}_handleEvent(e){this.el.setAttribute("data-triggered",""),requestAnimationFrame(()=>{this._isTopLayer()&&this._performAction(N(this.$props.action),e),requestAnimationFrame(()=>{this.el.removeAttribute("data-triggered")})})}_inBounds(e){if(!this.el)return!1;if(ku(e)||Sb(e)||tl(e)){let n=tl(e)?e.changedTouches[0]??e.touches[0]:void 0,i=n?.clientX??e.clientX,r=n?.clientY??e.clientY,s=this.el.getBoundingClientRect(),o=r>=s.top&&r<=s.bottom&&i>=s.left&&i<=s.right;return e.type.includes("leave")?!o:o}return!0}_isTopLayer(){let e=this._media.player.el.querySelectorAll("[data-media-gesture][data-triggered]");return Array.from(e).sort((n,i)=>+getComputedStyle(i).zIndex-+getComputedStyle(n).zIndex)[0]===this.el}_performAction(e,n){if(!e)return;let i=new ne("will-trigger",{detail:e,cancelable:!0,trigger:n});if(this.dispatchEvent(i),i.defaultPrevented)return;let[r,s]=e.replace(/:([a-z])/,"-$1").split(":");e.includes(":fullscreen")?this._media.remote.toggleFullscreen("prefer-media",n):e.includes("seek:")?this._media.remote.seek(N(this._media.$state.currentTime)+(+s||0),n):this._media.remote[zf(r)](n),this.dispatch("trigger",{detail:e,trigger:n})}};ng.props={disabled:!1,event:void 0,action:void 0};Gx=class{constructor(e){this._renderer=e,this.priority=10,this._track=null,this._disposal=Su()}attach(){}canRender(){return!0}detach(){this._disposal.empty(),this._renderer.reset(),this._track=null}changeTrack(e){!e||this._track===e||(this._disposal.empty(),e.readyState<2?(this._renderer.reset(),this._disposal.add(L(e,"load",()=>this._changeTrack(e),{once:!0}))):this._changeTrack(e),this._disposal.add(L(e,"add-cue",n=>{this._renderer.addCue(n.detail)}),L(e,"remove-cue",n=>{this._renderer.removeCue(n.detail)})),this._track=e)}_changeTrack(e){this._renderer.changeTrack({cues:[...e.cues],regions:[...e.regions]})}},ig=class extends ie{onSetup(){this._media=Ee(),this.setAttributes({"aria-hidden":Pn(this._isHidden.bind(this))})}onAttach(e){e.style.setProperty("pointer-events","none")}onConnect(e){if(this._renderer){S(this._watchViewType.bind(this));return}Promise.resolve().then(()=>(Du(),Au)).then(n=>{this.connectScope&&Ct(()=>{this._lib=n;let{CaptionsRenderer:i}=this._lib;this._renderer=new i(e),this._textRenderer=new Gx(this._renderer),S(this._watchViewType.bind(this))},this.connectScope)})}onDestroy(){this._textRenderer&&(this._textRenderer.detach(),this._media.textRenderers.remove(this._textRenderer)),this._renderer?.destroy()}_isHidden(){let{textTrack:e,remotePlaybackState:n}=this._media.$state,i=e();return this._media.$iosControls()||n()==="connected"||!i||!pt(i)}_watchViewType(){let{viewType:e}=this._media.$state;return e()==="audio"?this._setupAudioView():this._setupVideoView()}_setupAudioView(){return S(this._onTrackChange.bind(this)),()=>{this.el.textContent=""}}_onTrackChange(){if(this._isHidden())return;let{textTrack:e}=this._media.$state;this._onCueChange(),L(e(),"cue-change",this._onCueChange.bind(this)),S(this._onUpdateTimedNodes.bind(this))}_onCueChange(){this.el.textContent="";let{realCurrentTime:e,textTrack:n}=this._media.$state,i=N(e),r=N(n).activeCues,{renderVTTCueString:s}=this._lib;for(let o of r){let a=document.createElement("div");a.setAttribute("data-part","cue"),a.innerHTML=s(o,i),this.el.append(a)}}_onUpdateTimedNodes(){let{realCurrentTime:e}=this._media.$state,{updateTimedVTTCueNodes:n}=this._lib;n(this.el,e())}_setupVideoView(){return S(this._watchTextDirection.bind(this)),S(this._watchMediaTime.bind(this)),this._media.textRenderers.add(this._textRenderer),()=>{this.el.textContent="",this._textRenderer.detach(),this._media.textRenderers.remove(this._textRenderer)}}_watchTextDirection(){this._renderer.dir=this.$props.textDir()}_watchMediaTime(){if(this._isHidden())return;let{realCurrentTime:e}=this._media.$state;this._renderer.currentTime=e()}};ig.props={textDir:"ltr"};Ju=class extends ie{onSetup(){this._media=Ee(),this._watchSrc(),this._watchAlt(),this._watchCrossOrigin(),this._watchHidden()}onAttach(e){e.style.setProperty("pointer-events","none"),S(this._watchImg.bind(this)),S(this._watchSrc.bind(this)),S(this._watchAlt.bind(this)),S(this._watchCrossOrigin.bind(this)),S(this._watchHidden.bind(this));let{started:n}=this._media.$state;this.setAttributes({"data-visible":()=>!n()&&!this.$state.hidden(),"data-loading":this._isLoading.bind(this),"data-error":this._hasError.bind(this),"data-hidden":this.$state.hidden})}onConnect(e){S(this._onPreconnect.bind(this)),S(this._onLoadStart.bind(this))}_hasError(){let{error:e}=this.$state;return!Ji(e())}_onPreconnect(){let{canLoadPoster:e,poster:n}=this._media.$state;!e()&&n()&&Ai(n(),"preconnect")}_watchHidden(){let{src:e}=this.$props,{$iosControls:n}=this._media,{poster:i}=this._media.$state;this.el&&pe(this.el,"display",n()?"none":null),this.$state.hidden.set(this._hasError()||!(e()||i())||n())}_isLoading(){let{loading:e,hidden:n}=this.$state;return!n()&&e()}_watchImg(){let e=this.$state.img();e&&(L(e,"load",this._onLoad.bind(this)),L(e,"error",this._onError.bind(this)))}_watchSrc(){let{canLoadPoster:e,poster:n}=this._media.$state,i=this.$props.src(),r=i||n();i&&n()!==i&&this._media.$state.providedPoster.set(i),this.$state.src.set(e()&&r.length?r:null)}_watchAlt(){let{src:e}=this.$props,{alt:n}=this.$state,{poster:i}=this._media.$state;n.set(e()||i()?this.$props.alt():null)}_watchCrossOrigin(){let{crossOrigin:e}=this.$props,{crossOrigin:n}=this.$state,{crossOrigin:i,poster:r}=this._media.$state,s=e()!==null?e():i();n.set(/ytimg\.com|vimeo/.test(r()||"")?null:s===!0?"anonymous":s)}_onLoadStart(){let{loading:e,error:n}=this.$state,{canLoadPoster:i,poster:r}=this._media.$state;e.set(i()&&!!r()),n.set(null)}_onLoad(){let{loading:e,error:n}=this.$state;e.set(!1),n.set(null)}_onError(e){let{loading:n,error:i}=this.$state;n.set(!1),i.set(e)}};Ju.props={src:null,alt:null,crossOrigin:null};Ju.state=new Ii({img:null,src:null,alt:null,crossOrigin:null,loading:!0,error:null,hidden:!1});ed=class extends ie{constructor(){super(...arguments),this._invert=K(null)}onSetup(){this._media=Ee(),this._watchTime();let{type:e}=this.$props;this.setAttributes({"data-type":e,"data-remainder":this._shouldInvert.bind(this)})}onAttach(e){e.hasAttribute("role")||S(this._watchRole.bind(this)),S(this._watchTime.bind(this))}onConnect(e){S(()=>{if(!this.$props.toggle()){this._invert.set(null);return}Ss(e,this._onToggle.bind(this))})}_watchTime(){let{type:e,padHours:n,padMinutes:i,showHours:r}=this.$props,s=this._getSeconds(e()),o=this._media.$state.duration(),a=this._shouldInvert();if(!Number.isFinite(s+o)){this.$state.timeText.set("LIVE");return}let l=a?Math.max(0,o-s):s,c=Ms(l,n(),i(),r());this.$state.timeText.set((a?"-":"")+c)}_watchRole(){if(!this.el)return;let{toggle:e}=this.$props;pe(this.el,"role",e()?"timer":null),pe(this.el,"tabindex",e()?0:null)}_getSeconds(e){let{bufferedEnd:n,duration:i,currentTime:r}=this._media.$state;switch(e){case"buffered":return n();case"duration":return i();default:return r()}}_shouldInvert(){return this.$props.remainder()&&this._invert()!==!1}_onToggle(e){if(e.preventDefault(),this._invert()===null){this._invert.set(!this.$props.remainder());return}this._invert.set(n=>!n)}};ed.props={type:"current",showHours:!1,padHours:null,padMinutes:null,remainder:!1,toggle:!1};ed.state=new Ii({timeText:""});q6=er(),W6={clickToPlay:!0,clickToFullscreen:!0,controls:["play-large","play","progress","current-time","mute+volume","captions","settings","pip","airplay","fullscreen"],customIcons:!1,displayDuration:!1,download:null,markers:null,invertTime:!0,thumbnails:null,toggleTime:!0,translations:null,seekTime:10,speed:[.5,.75,1,1.25,1.5,1.75,2,4]},Yx=class extends ie{onSetup(){this._media=Ee(),on(q6,{...this.$props,previewTime:K(0)})}};Yx.props=W6;Mo=class extends n6{},rg=class extends ml{},td=class extends Fm{},nd=class extends Vm{},sg=class extends Ku{},id=class extends Wm{},rd=class extends Km{},sd=class extends Xm{},od=class extends Gm{},ad=class extends Ym{},ld=class extends qm{},cd=class extends Bm{},ud=class extends Hm{},dd=class extends Qm{},pd=class extends Um{},hd=class extends jm{},fd=class extends Wu{},md=class extends Or{},gd=class extends vl{},yd=class extends Xu{},vd=class extends Jm{},wd=class extends yl{},_d=class extends xo{},bd=class extends Qu{},xd=class extends Fr{},kd=class extends Vr{},Td=class extends ko{},Ed=class extends Zu{},Sd=class extends eg{},Pd=class extends wl{},Cd=class extends _l{},Md=class extends ig{},$d=class extends ng{},og=class extends Ju{},bl=class extends gl{},Rd=class extends ed{},zR=je.forwardRef((t,e)=>{let{children:n,...i}=t,r=je.Children.toArray(n),s=r.find(G6);if(s){let o=s.props.children,a=r.map(l=>l===s?je.Children.count(o)>1?je.Children.only(null):je.isValidElement(o)?o.props.children:null:l);return je.createElement(Qx,{...i,ref:e},je.isValidElement(o)?je.cloneElement(o,void 0,a):null)}return je.createElement(Qx,{...i,ref:e},n)});zR.displayName="Slot";Qx=je.forwardRef((t,e)=>{let{children:n,...i}=t;return je.isValidElement(n)?je.cloneElement(n,{...Y6(i,n.props),ref:e?ye(e,n.ref):n.ref}):je.Children.count(n)>1?je.Children.only(null):null});Qx.displayName="SlotClone";K6=({children:t})=>je.createElement(je.Fragment,null,t);Q6=["button","div","span","img","video","audio"],te=Q6.reduce((t,e)=>{let n=je.forwardRef((i,r)=>{let{asChild:s,...o}=i;return je.createElement(s?zR:e,{...o,ref:r})});return n.displayName=`Primitive.${e}`,{...t,[e]:n}},{});tR=Mo.state.record,X6=Object.keys(tR).reduce((t,e)=>({...t,[e](){return tR[e]}}),{})});var rI={};zt(rI,{default:()=>nj});var nj,sI=at(()=>{"use strict";"use client";nj=' '});var jI=Lt((UX,UI)=>{"use strict";var Nj={aa:{name:"Afar",nativeName:"Afaraf"},ab:{name:"Abkhaz",nativeName:"\u0430\u04A7\u0441\u0443\u0430 \u0431\u044B\u0437\u0448\u04D9\u0430"},ae:{name:"Avestan",nativeName:"avesta"},af:{name:"Afrikaans",nativeName:"Afrikaans"},ak:{name:"Akan",nativeName:"Akan"},am:{name:"Amharic",nativeName:"\u12A0\u121B\u122D\u129B"},an:{name:"Aragonese",nativeName:"aragon\xE9s"},ar:{name:"Arabic",nativeName:"\u0627\u064E\u0644\u0652\u0639\u064E\u0631\u064E\u0628\u0650\u064A\u064E\u0651\u0629\u064F"},as:{name:"Assamese",nativeName:"\u0985\u09B8\u09AE\u09C0\u09AF\u09BC\u09BE"},av:{name:"Avaric",nativeName:"\u0430\u0432\u0430\u0440 \u043C\u0430\u0446\u04C0"},ay:{name:"Aymara",nativeName:"aymar aru"},az:{name:"Azerbaijani",nativeName:"az\u0259rbaycan dili"},ba:{name:"Bashkir",nativeName:"\u0431\u0430\u0448\u04A1\u043E\u0440\u0442 \u0442\u0435\u043B\u0435"},be:{name:"Belarusian",nativeName:"\u0431\u0435\u043B\u0430\u0440\u0443\u0441\u043A\u0430\u044F \u043C\u043E\u0432\u0430"},bg:{name:"Bulgarian",nativeName:"\u0431\u044A\u043B\u0433\u0430\u0440\u0441\u043A\u0438 \u0435\u0437\u0438\u043A"},bi:{name:"Bislama",nativeName:"Bislama"},bm:{name:"Bambara",nativeName:"bamanankan"},bn:{name:"Bengali",nativeName:"\u09AC\u09BE\u0982\u09B2\u09BE"},bo:{name:"Tibetan",nativeName:"\u0F56\u0F7C\u0F51\u0F0B\u0F61\u0F72\u0F42"},br:{name:"Breton",nativeName:"brezhoneg"},bs:{name:"Bosnian",nativeName:"bosanski jezik"},ca:{name:"Catalan",nativeName:"Catal\xE0"},ce:{name:"Chechen",nativeName:"\u043D\u043E\u0445\u0447\u0438\u0439\u043D \u043C\u043E\u0442\u0442"},ch:{name:"Chamorro",nativeName:"Chamoru"},co:{name:"Corsican",nativeName:"corsu"},cr:{name:"Cree",nativeName:"\u14C0\u1426\u1403\u152D\u140D\u140F\u1423"},cs:{name:"Czech",nativeName:"\u010De\u0161tina"},cu:{name:"Old Church Slavonic",nativeName:"\u0469\u0437\u044B\u043A\u044A \u0441\u043B\u043E\u0432\u0463\u043D\u044C\u0441\u043A\u044A"},cv:{name:"Chuvash",nativeName:"\u0447\u04D1\u0432\u0430\u0448 \u0447\u04D7\u043B\u0445\u0438"},cy:{name:"Welsh",nativeName:"Cymraeg"},da:{name:"Danish",nativeName:"dansk"},de:{name:"German",nativeName:"Deutsch"},dv:{name:"Divehi",nativeName:"\u078B\u07A8\u0788\u07AC\u0780\u07A8"},dz:{name:"Dzongkha",nativeName:"\u0F62\u0FAB\u0F7C\u0F44\u0F0B\u0F41"},ee:{name:"Ewe",nativeName:"E\u028Begbe"},el:{name:"Greek",nativeName:"\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC"},en:{name:"English",nativeName:"English"},eo:{name:"Esperanto",nativeName:"Esperanto"},es:{name:"Spanish",nativeName:"Espa\xF1ol"},et:{name:"Estonian",nativeName:"eesti"},eu:{name:"Basque",nativeName:"euskara"},fa:{name:"Persian",nativeName:"\u0641\u0627\u0631\u0633\u06CC"},ff:{name:"Fula",nativeName:"Fulfulde"},fi:{name:"Finnish",nativeName:"suomi"},fj:{name:"Fijian",nativeName:"vosa Vakaviti"},fo:{name:"Faroese",nativeName:"f\xF8royskt"},fr:{name:"French",nativeName:"Fran\xE7ais"},fy:{name:"Western Frisian",nativeName:"Frysk"},ga:{name:"Irish",nativeName:"Gaeilge"},gd:{name:"Scottish Gaelic",nativeName:"G\xE0idhlig"},gl:{name:"Galician",nativeName:"galego"},gn:{name:"Guaran\xED",nativeName:"Ava\xF1e'\u1EBD"},gu:{name:"Gujarati",nativeName:"\u0A97\u0AC1\u0A9C\u0AB0\u0ABE\u0AA4\u0AC0"},gv:{name:"Manx",nativeName:"Gaelg"},ha:{name:"Hausa",nativeName:"\u0647\u064E\u0648\u064F\u0633\u064E"},he:{name:"Hebrew",nativeName:"\u05E2\u05D1\u05E8\u05D9\u05EA"},hi:{name:"Hindi",nativeName:"\u0939\u093F\u0928\u094D\u0926\u0940"},ho:{name:"Hiri Motu",nativeName:"Hiri Motu"},hr:{name:"Croatian",nativeName:"Hrvatski"},ht:{name:"Haitian",nativeName:"Krey\xF2l ayisyen"},hu:{name:"Hungarian",nativeName:"magyar"},hy:{name:"Armenian",nativeName:"\u0540\u0561\u0575\u0565\u0580\u0565\u0576"},hz:{name:"Herero",nativeName:"Otjiherero"},ia:{name:"Interlingua",nativeName:"Interlingua"},id:{name:"Indonesian",nativeName:"Bahasa Indonesia"},ie:{name:"Interlingue",nativeName:"Interlingue"},ig:{name:"Igbo",nativeName:"As\u1EE5s\u1EE5 Igbo"},ii:{name:"Nuosu",nativeName:"\uA188\uA320\uA4BF Nuosuhxop"},ik:{name:"Inupiaq",nativeName:"I\xF1upiaq"},io:{name:"Ido",nativeName:"Ido"},is:{name:"Icelandic",nativeName:"\xCDslenska"},it:{name:"Italian",nativeName:"Italiano"},iu:{name:"Inuktitut",nativeName:"\u1403\u14C4\u1483\u144E\u1450\u1466"},ja:{name:"Japanese",nativeName:"\u65E5\u672C\u8A9E"},jv:{name:"Javanese",nativeName:"basa Jawa"},ka:{name:"Georgian",nativeName:"\u10E5\u10D0\u10E0\u10D7\u10E3\u10DA\u10D8"},kg:{name:"Kongo",nativeName:"Kikongo"},ki:{name:"Kikuyu",nativeName:"G\u0129k\u0169y\u0169"},kj:{name:"Kwanyama",nativeName:"Kuanyama"},kk:{name:"Kazakh",nativeName:"\u049B\u0430\u0437\u0430\u049B \u0442\u0456\u043B\u0456"},kl:{name:"Kalaallisut",nativeName:"kalaallisut"},km:{name:"Khmer",nativeName:"\u1781\u17C1\u1798\u179A\u1797\u17B6\u179F\u17B6"},kn:{name:"Kannada",nativeName:"\u0C95\u0CA8\u0CCD\u0CA8\u0CA1"},ko:{name:"Korean",nativeName:"\uD55C\uAD6D\uC5B4"},kr:{name:"Kanuri",nativeName:"Kanuri"},ks:{name:"Kashmiri",nativeName:"\u0915\u0936\u094D\u092E\u0940\u0930\u0940"},ku:{name:"Kurdish",nativeName:"Kurd\xEE"},kv:{name:"Komi",nativeName:"\u043A\u043E\u043C\u0438 \u043A\u044B\u0432"},kw:{name:"Cornish",nativeName:"Kernewek"},ky:{name:"Kyrgyz",nativeName:"\u041A\u044B\u0440\u0433\u044B\u0437\u0447\u0430"},la:{name:"Latin",nativeName:"latine"},lb:{name:"Luxembourgish",nativeName:"L\xEBtzebuergesch"},lg:{name:"Ganda",nativeName:"Luganda"},li:{name:"Limburgish",nativeName:"Limburgs"},ln:{name:"Lingala",nativeName:"Ling\xE1la"},lo:{name:"Lao",nativeName:"\u0E9E\u0EB2\u0EAA\u0EB2\u0EA5\u0EB2\u0EA7"},lt:{name:"Lithuanian",nativeName:"lietuvi\u0173 kalba"},lu:{name:"Luba-Katanga",nativeName:"Kiluba"},lv:{name:"Latvian",nativeName:"latvie\u0161u valoda"},mg:{name:"Malagasy",nativeName:"fiteny malagasy"},mh:{name:"Marshallese",nativeName:"Kajin M\u0327aje\u013C"},mi:{name:"M\u0101ori",nativeName:"te reo M\u0101ori"},mk:{name:"Macedonian",nativeName:"\u043C\u0430\u043A\u0435\u0434\u043E\u043D\u0441\u043A\u0438 \u0458\u0430\u0437\u0438\u043A"},ml:{name:"Malayalam",nativeName:"\u0D2E\u0D32\u0D2F\u0D3E\u0D33\u0D02"},mn:{name:"Mongolian",nativeName:"\u041C\u043E\u043D\u0433\u043E\u043B \u0445\u044D\u043B"},mr:{name:"Marathi",nativeName:"\u092E\u0930\u093E\u0920\u0940"},ms:{name:"Malay",nativeName:"Bahasa Melayu"},mt:{name:"Maltese",nativeName:"Malti"},my:{name:"Burmese",nativeName:"\u1017\u1019\u102C\u1005\u102C"},na:{name:"Nauru",nativeName:"Dorerin Naoero"},nb:{name:"Norwegian Bokm\xE5l",nativeName:"Norsk bokm\xE5l"},nd:{name:"Northern Ndebele",nativeName:"isiNdebele"},ne:{name:"Nepali",nativeName:"\u0928\u0947\u092A\u093E\u0932\u0940"},ng:{name:"Ndonga",nativeName:"Owambo"},nl:{name:"Dutch",nativeName:"Nederlands"},nn:{name:"Norwegian Nynorsk",nativeName:"Norsk nynorsk"},no:{name:"Norwegian",nativeName:"Norsk"},nr:{name:"Southern Ndebele",nativeName:"isiNdebele"},nv:{name:"Navajo",nativeName:"Din\xE9 bizaad"},ny:{name:"Chichewa",nativeName:"chiChe\u0175a"},oc:{name:"Occitan",nativeName:"occitan"},oj:{name:"Ojibwe",nativeName:"\u140A\u14C2\u1511\u14C8\u142F\u14A7\u140E\u14D0"},om:{name:"Oromo",nativeName:"Afaan Oromoo"},or:{name:"Oriya",nativeName:"\u0B13\u0B21\u0B3C\u0B3F\u0B06"},os:{name:"Ossetian",nativeName:"\u0438\u0440\u043E\u043D \xE6\u0432\u0437\u0430\u0433"},pa:{name:"Panjabi",nativeName:"\u0A2A\u0A70\u0A1C\u0A3E\u0A2C\u0A40"},pi:{name:"P\u0101li",nativeName:"\u092A\u093E\u0934\u093F"},pl:{name:"Polish",nativeName:"Polski"},ps:{name:"Pashto",nativeName:"\u067E\u069A\u062A\u0648"},pt:{name:"Portuguese",nativeName:"Portugu\xEAs"},qu:{name:"Quechua",nativeName:"Runa Simi"},rm:{name:"Romansh",nativeName:"rumantsch grischun"},rn:{name:"Kirundi",nativeName:"Ikirundi"},ro:{name:"Romanian",nativeName:"Rom\xE2n\u0103"},ru:{name:"Russian",nativeName:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439"},rw:{name:"Kinyarwanda",nativeName:"Ikinyarwanda"},sa:{name:"Sanskrit",nativeName:"\u0938\u0902\u0938\u094D\u0915\u0943\u0924\u092E\u094D"},sc:{name:"Sardinian",nativeName:"sardu"},sd:{name:"Sindhi",nativeName:"\u0938\u093F\u0928\u094D\u0927\u0940"},se:{name:"Northern Sami",nativeName:"Davvis\xE1megiella"},sg:{name:"Sango",nativeName:"y\xE2ng\xE2 t\xEE s\xE4ng\xF6"},si:{name:"Sinhala",nativeName:"\u0DC3\u0DD2\u0D82\u0DC4\u0DBD"},sk:{name:"Slovak",nativeName:"sloven\u010Dina"},sl:{name:"Slovenian",nativeName:"sloven\u0161\u010Dina"},sm:{name:"Samoan",nativeName:"gagana fa'a Samoa"},sn:{name:"Shona",nativeName:"chiShona"},so:{name:"Somali",nativeName:"Soomaaliga"},sq:{name:"Albanian",nativeName:"Shqip"},sr:{name:"Serbian",nativeName:"\u0441\u0440\u043F\u0441\u043A\u0438 \u0458\u0435\u0437\u0438\u043A"},ss:{name:"Swati",nativeName:"SiSwati"},st:{name:"Southern Sotho",nativeName:"Sesotho"},su:{name:"Sundanese",nativeName:"Basa Sunda"},sv:{name:"Swedish",nativeName:"Svenska"},sw:{name:"Swahili",nativeName:"Kiswahili"},ta:{name:"Tamil",nativeName:"\u0BA4\u0BAE\u0BBF\u0BB4\u0BCD"},te:{name:"Telugu",nativeName:"\u0C24\u0C46\u0C32\u0C41\u0C17\u0C41"},tg:{name:"Tajik",nativeName:"\u0442\u043E\u04B7\u0438\u043A\u04E3"},th:{name:"Thai",nativeName:"\u0E44\u0E17\u0E22"},ti:{name:"Tigrinya",nativeName:"\u1275\u130D\u122D\u129B"},tk:{name:"Turkmen",nativeName:"T\xFCrkmen\xE7e"},tl:{name:"Tagalog",nativeName:"Wikang Tagalog"},tn:{name:"Tswana",nativeName:"Setswana"},to:{name:"Tonga",nativeName:"faka Tonga"},tr:{name:"Turkish",nativeName:"T\xFCrk\xE7e"},ts:{name:"Tsonga",nativeName:"Xitsonga"},tt:{name:"Tatar",nativeName:"\u0442\u0430\u0442\u0430\u0440 \u0442\u0435\u043B\u0435"},tw:{name:"Twi",nativeName:"Twi"},ty:{name:"Tahitian",nativeName:"Reo Tahiti"},ug:{name:"Uyghur",nativeName:"\u0626\u06C7\u064A\u063A\u06C7\u0631\u0686\u06D5\u200E"},uk:{name:"Ukrainian",nativeName:"\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430"},ur:{name:"Urdu",nativeName:"\u0627\u0631\u062F\u0648"},uz:{name:"Uzbek",nativeName:"\u040E\u0437\u0431\u0435\u043A"},ve:{name:"Venda",nativeName:"Tshiven\u1E13a"},vi:{name:"Vietnamese",nativeName:"Ti\u1EBFng Vi\u1EC7t"},vo:{name:"Volap\xFCk",nativeName:"Volap\xFCk"},wa:{name:"Walloon",nativeName:"walon"},wo:{name:"Wolof",nativeName:"Wollof"},xh:{name:"Xhosa",nativeName:"isiXhosa"},yi:{name:"Yiddish",nativeName:"\u05D9\u05D9\u05B4\u05D3\u05D9\u05E9"},yo:{name:"Yoruba",nativeName:"Yor\xF9b\xE1"},za:{name:"Zhuang",nativeName:"Sa\u026F cue\u014B\u0185"},zh:{name:"Chinese",nativeName:"\u4E2D\u6587"},zu:{name:"Zulu",nativeName:"isiZulu"}};UI.exports=Nj});var Pk=Lt((jX,KI)=>{"use strict";var jd=jI(),BI={},Ig={},HI=[],qI=[],WI=[];for(let t in jd){let{name:e,nativeName:n}=jd[t];BI[t]=Ig[e.toLowerCase()]=Ig[n.toLowerCase()]={code:t,name:e,nativeName:n},HI.push(t),qI.push(e),WI.push(n)}KI.exports=class Rg{static getLanguages(e=[]){return e.map(n=>Rg.validate(n)?Object.assign({},BI[n]):{code:n,name:"",nativeName:""})}static getName(e){return Rg.validate(e)?jd[e].name:""}static getAllNames(){return qI.slice()}static getNativeName(e){return Rg.validate(e)?jd[e].nativeName:""}static getAllNativeNames(){return WI.slice()}static getCode(e){return e=e.toLowerCase(),Ig.hasOwnProperty(e)?Ig[e].code:""}static getAllCodes(){return HI.slice()}static validate(e){return jd.hasOwnProperty(e)}}});var jL=Lt(Xg=>{"use strict";var N9=X(),O9=Symbol.for("react.element"),F9=Symbol.for("react.fragment"),V9=Object.prototype.hasOwnProperty,z9=N9.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,U9={key:!0,ref:!0,__self:!0,__source:!0};function UL(t,e,n){var i,r={},s=null,o=null;n!==void 0&&(s=""+n),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(o=e.ref);for(i in e)V9.call(e,i)&&!U9.hasOwnProperty(i)&&(r[i]=e[i]);if(t&&t.defaultProps)for(i in e=t.defaultProps,e)r[i]===void 0&&(r[i]=e[i]);return{$$typeof:O9,type:t,key:s,ref:o,props:r,_owner:z9.current}}Xg.Fragment=F9;Xg.jsx=UL;Xg.jsxs=UL});var _e=Lt((ree,BL)=>{"use strict";BL.exports=jL()});var FD=Lt((Sue,OD)=>{"use strict";var nv=Object.prototype.hasOwnProperty,ND=Object.prototype.toString,$D=Object.defineProperty,RD=Object.getOwnPropertyDescriptor,ID=function(e){return typeof Array.isArray=="function"?Array.isArray(e):ND.call(e)==="[object Array]"},LD=function(e){if(!e||ND.call(e)!=="[object Object]")return!1;var n=nv.call(e,"constructor"),i=e.constructor&&e.constructor.prototype&&nv.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!n&&!i)return!1;var r;for(r in e);return typeof r>"u"||nv.call(e,r)},AD=function(e,n){$D&&n.name==="__proto__"?$D(e,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):e[n.name]=n.newValue},DD=function(e,n){if(n==="__proto__")if(nv.call(e,n)){if(RD)return RD(e,n).value}else return;return e[n]};OD.exports=function t(){var e,n,i,r,s,o,a=arguments[0],l=1,c=arguments.length,u=!1;for(typeof a=="boolean"&&(u=a,a=arguments[1]||{},l=2),(a==null||typeof a!="object"&&typeof a!="function")&&(a={});lwv});module.exports=hO(Lq);var uE=require("obsidian");function Tv(t,e){let n={};for(let i of e)i in t&&(n[i]=t[i]);return n}function Cp(t,e){let n={...t};for(let i of e)delete n[i];return n}var Ev={bilibili:"https://www.bilibili.com",youtube:"https://www.youtube.com",vimeo:"https://www.vimeo.com",coursera:"https://www.coursera.org"},Mp={bilibili:"bilibili",youtube:"YouTube",generic:"Website",vimeo:"Vimeo",coursera:"Coursera"},cE=t=>Cp(t,["generic"]);var fO={bilibili:'',vimeo:'',coursera:'',youtube:null};Object.entries(fO).forEach(([t,e])=>{e&&(0,uE.addIcon)(t,e)});var _v=require("obsidian");function vt(t,e){let n=Object.keys(e).map(i=>mO(t,i,e[i]));return n.length===1?n[0]:function(){n.forEach(i=>i())}}function mO(t,e,n){let i=t[e],r=t.hasOwnProperty(e),s=n(i);return i&&Object.setPrototypeOf(s,i),Object.setPrototypeOf(o,s),t[e]=o,a;function o(...l){return s===i&&t[e]===o&&a(),s.apply(this,l)}function a(){t[e]===o&&(r?t[e]=i:delete t[e]),s!==i&&(s=i,Object.setPrototypeOf(o,i||Function))}}var Yn=require("obsidian");var dE=require("obsidian");var Yt={video:["mp4","webm","ogv","mov","mkv"],audio:["mp3","wav","m4a","3gp","flac","ogg","oga","opus"]};function hn(t){t=t.replace(/^\./,"").toLowerCase();for(let e of Object.keys(Yt))if(Yt[e].includes(t))return e;return null}var Wq=[...Yt.video,...Yt.audio];function ke(t){return t?.file instanceof dE.TFile}function Ui(t,e){if(!t)return null;let n=hn(t.extension);return n?{type:n,file:t,hash:e}:null}var vE=require("obsidian");function pE(t,e){let n=e.getCursor("to");console.debug("insert to cursor [to]",n.ch,n.line),e.replaceRange(t,n,n),e.setCursor(e.offsetToPos(e.posToOffset(n)+t.length))}function hE(t,e){let n=e.getCursor("from");console.debug("insert before cursor [from]",n.ch,n.line),e.replaceRange(t,n,n)}var dc=require("obsidian");var uc={main:/^(?[\w:.]*)(?:,(?[\w:.]+))?$/,npt_sec:/^\d+(?:\.\d+)?$/,npt_mmss:/^(?[0-5]\d):(?[0-5]\d(?:\.\d+)?)$/,npt_hhmmss:/^(?\d+):(?[0-5]\d):(?[0-5]\d(?:\.\d+)?)$/,npt_time:/^(?:npt:)?([\d.:]+)$/},Gn=({start:t,end:e})=>t>=0&&e<0;function fn(t){if(!t)return null;let n=new URLSearchParams(t.replace(/^#+/,"")).get("t");if(!n)return null;let i=n.match(uc.main);if(!i)return null;let{start:r,end:s}=i.groups;return gO(r,s)}var gO=(t,e)=>{let n=t||null,i=e??null,r,s;if(n&&i)r=$p(n),s=i==="e"?1/0:$p(i);else if(n)r=$p(n),s=-1;else if(i)r=-1,s=$p(i);else throw console.error("Missing startTime and endTime",t,e),new Error("Missing startTime and endTime");return r===null||s===null?null:{start:r,end:s}};function $p(t){let e=t.match(uc.npt_time);if(!e)return null;let n=e[1],i=n.match(uc.npt_sec);if(i)return Number(i[0]);let r=n.match(uc.npt_mmss);if(r){let{mm:o,ss:a}=r.groups;return Number(o)*60+Number(a)}let s=n.match(uc.npt_hhmmss);if(s){let{hh:o,mm:a,ss:l}=s.groups;return Number(o)*60*60+Number(a)*60+Number(l)}return null}function Rp(t){return t===0?"00:00:00":dc.moment.utc(dc.moment.duration({seconds:t}).as("milliseconds")).format("HH:mm:ss")}function gE(t){return t===0?"DT0S":dc.moment.duration(t,"seconds").toISOString()}var fE=(t,e=2)=>{let n,i;return Number.isInteger(t)?n=t.toString():[n,i]=t.toFixed(e).split("."),n.length===1&&(n="0"+n),i?n+"."+i:n};function pc(t){return t.replace(/t=[^&]+/,"")}function Sv(t,e){if(t=pc(t.trim().replace(/^#/,"")),!e)return t;let n=Pv(e);return t?`${t}&${n}`:n??""}function yE(t,e){let n=Number.isNaN(t)?-1:t,i=Number.isNaN(e)?-1:e;return{start:n,end:i}}function Pv(t){let{start:e,end:n}=t,i={get start(){return mE(e)},get end(){return mE(n)}};return Gn(t)?`t=${i.start}`:e<0&&n>0?Number.isFinite(n)?`t=,${i.end}`:null:e>0&&n>0?`t=${i.start},${i.end}`:null}function mE(t){if(Number.isNaN(t)||t<0)throw new Error("durationInSecond must be positive");if(t===1/0)return"e";let e=dc.moment.duration(t,"seconds"),n=e.hours(),i=e.minutes(),r=e.seconds()+e.milliseconds()/1e3;if(n>0)return[n,...[i,r].map(s=>fE(s))].join(":");if(i>0)return[i,r].map(s=>fE(s)).join(":");if(r>0)return r.toFixed(2);throw new Error("durationInSecond must be positive")}function yO(t,e){if(e?.title)return e.title;if(t.isFileUrl){let n=t.pathname.split("/").pop()?.split(".");n?.pop();let i=n?.join(".");if(i)return i}return t.type!=="generic"&&t.id?`${t.type}: ${t.id}`:t.source.hostname+decodeURI(t.source.pathname).replaceAll("/","_")}function ea(t,{state:e}={}){return ke(t)?t.file.basename:yO(t,e)}function ta({timestamp:t,screenshot:e},{template:n,editor:i,insertBefore:r}){console.debug("insert timestamp",{timestamp:t,screenshot:e,template:n});let s=n.replace("{{TIMESTAMP}}",t);e&&(s=s.replace("{{SCREENSHOT}}",e)),console.debug("content to insert",s);try{console.debug(`inserting timestamp ${r?"before":"after"} cursor`),r?hE(s,i):pE(s,i)}catch(o){new vE.Notice("Failed to insert timestamp, see console for details"),console.error("Failed to insert timestamp",o)}}function na(t,e){let{metadataCache:n}=e.plugin.app,i=e.store.getState().player;if(!i)throw new Error("Player not initialized");let r=ea(t,{state:i.state});if(ke(t)){let s=hn(t.file.extension),o=t.file;return e.plugin.leafOpener.openNote(t,{title:r,fm:a=>({[s]:`[[${n.fileToLinktext(o,a)}]]`}),sourcePath:o.path})}else{let s=t.inferredType??"media";return e.plugin.leafOpener.openNote(t,{title:r,fm:()=>({[s]:t.jsonState.source})})}}function ia(t,e,{app:{fileManager:n},settings:{timestampOffset:i},duration:r=1/0}){t+=i,t<0?t=0:t>r&&(t=r);let s=Rp(t),o=t>0?{start:t,end:-1}:void 0,a=o?`#${Pv(o)}`:"";if(ke(e)){let{file:l}=e;return c=>n.generateMarkdownLink(l,c,a,s).replace(/^!/,"")}else{let l=e.print(o);return()=>`[${s}](${l}${a})`}}var Ip=class extends Yn.Component{constructor(n){super();this.plugin=n;E(this,"_recording",null);E(this,"_recordedEditors",new Map)}onload(){this.rec||console.info("recorder not found, skip patching for recorder note"),this.patch(),this.addCommand()}get app(){return this.plugin.app}get rec(){return this.app.internalPlugins.plugins["audio-recorder"]}get settings(){return this.plugin.settings.getState()}onunload(){this._recordedEditors.clear()}async onRecordingSaved(n){if(!this._recording)return;let{start:i}=this._recording;this._recording=null;let r=Ui(n,"");if(!r){new Yn.Notice("Failed to get media info from the saved file: "+n.path);return}for(let s of this._recordedEditors){let o=s[0],a=()=>{},l=s[1];if(!o.containerEl.isConnected){if(!l){new Yn.Notice("One of the note with timestamp is closed, the timestamp will not be updated");continue}if(o=_O(l,this.app),!o){let c=this.app.workspace.getLeaf("tab");if(await c.openFile(l,{state:{mode:"source"}}),!(c.view instanceof Yn.MarkdownView)){new Yn.Notice("Failed to open note for timestamp update: "+l.path);continue}o=c.view.editor,a=()=>c.detach()}}try{let c=o.getValue().replaceAll(vO(i),(u,d)=>{let p=parseInt(d,10);return ia(p/1e3,r,{app:this.app,settings:this.plugin.settings.getState()})(l?.path??"")});o.setValue(c)}catch(c){console.error("failed to insert timestamp",c)}finally{a()}}this._recordedEditors.clear()}patch(){if(!this.rec.instance)return;let n=this.rec.instance,i=this,{vault:r,workspace:s}=this.app;this.register(vt(n,{saveRecording(o){return function(...a){s.getLeaf("split").setViewState({type:"empty",active:!0});let l=o.apply(this,a),c=()=>r.off("create",d),u=window.setTimeout(c,3e5),d=p=>{p instanceof Yn.TFile?i.onRecordingSaved(p):console.error("unexpected folder"),c(),window.clearTimeout(u)};return r.on("create",d),l}},startRecording(o){return function(...a){let l=o.apply(this,a),c=this.recorder;if(i._recording={start:Date.now()},console.debug("recording start called",i._recording.start),c&&c instanceof MediaRecorder){c.addEventListener("start",()=>{i._recording={start:Date.now()},console.debug("recording started in MediaRecorder",i._recording.start)},{once:!0});let u=()=>{i._recording&&(i._recording.end=Date.now(),console.debug("recording stopped in MediaRecorder",i._recording.end)),c.removeEventListener("stop",u),c.removeEventListener("error",u)};c.addEventListener("stop",u,{once:!0}),c.addEventListener("error",u,{once:!0})}return l}}}))}addCommand(){this.plugin.addCommand({id:"take-rec-timestamp",name:"Take timestamp on current recording",editorCheckCallback:(n,i,r)=>{if(!this._recording)return!1;if(n)return!0;let{start:s,notified:o}=this._recording;!o&&!r.file&&(new Yn.Notice("You've taken a timestamp for the recording, probably in canvas node, keep editor in foreground and in live preview mode. Otherwise, the dummy timestamp cannot be updated when recording is saved."),this._recording.notified=!0);let a=wO(s,Date.now()-s);ta({timestamp:a},{editor:i,template:this.settings.timestampTemplate,insertBefore:this.settings.insertBefore}),this._recordedEditors.set(i,r.file)}})}};function vO(t){return new RegExp(`%%REC_${t}_(?\\d+)%%`,"g")}function wO(t,e){return`%%REC_${t}_${e}%%`}function _O(t,e){let n=null;return e.workspace.iterateAllLeaves(i=>{i.view instanceof Yn.MarkdownView&&t.path===i.view.file?.path&&i.view.getMode()==="source"&&(n=i.view)}),n?.editor}var uS=A(Ap()),Qp=require("obsidian");var gc=class{constructor(t,e,n,i,r,s){E(this,"type",3);E(this,"name","");E(this,"prefix","");E(this,"value","");E(this,"suffix","");E(this,"modifier",3);this.type=t,this.name=e,this.prefix=n,this.value=i,this.suffix=r,this.modifier=s}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},bO=/[$_\p{ID_Start}]/u,xO=/[$_\u200C\u200D\p{ID_Continue}]/u,Mv=".*";function kO(t,e){return(e?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(t)}function TE(t,e=!1){let n=[],i=0;for(;i{if(oc("OTHER_MODIFIER")??c("ASTERISK"),d=y=>{let T=c(y);if(T!==void 0)return T;let{type:P,index:k}=n[o];throw new TypeError(`Unexpected ${P} at ${k}, expected ${y}`)},p=()=>{let y="",T;for(;T=c("CHAR")??c("ESCAPED_CHAR");)y+=T;return y},h=y=>y,m=e.encodePart||h,v="",w=y=>{v+=y},f=()=>{v.length&&(r.push(new gc(3,"","",m(v),"",3)),v="")},g=(y,T,P,k,M)=>{let I=3;switch(M){case"?":I=1;break;case"*":I=0;break;case"+":I=2;break}if(!T&&!P&&I===3){w(y);return}if(f(),!T&&!P){if(!y)return;r.push(new gc(3,"","",m(y),"",I));return}let O;P?P==="*"?O=Mv:O=P:O=i;let b=2;O===i?(b=1,O=""):O===Mv&&(b=0,O="");let ee;if(T?ee=T:P&&(ee=s++),l.has(ee))throw new TypeError(`Duplicate name '${ee}'.`);l.add(ee),r.push(new gc(b,ee,m(y),O,m(k),I))};for(;o-1)}return o||(i+=`(?=${s}|${r})`),new RegExp(i,_E(n))}var Kr={delimiter:"",prefixes:"",sensitive:!0,strict:!0},EO={delimiter:".",prefixes:"",sensitive:!0,strict:!0},SO={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function PO(t,e){return t.length?t[0]==="/"?!0:!e||t.length<2?!1:(t[0]=="\\"||t[0]=="{")&&t[1]=="/":!1}function PE(t,e){return t.startsWith(e)?t.substring(e.length,t.length):t}function CO(t,e){return t.endsWith(e)?t.substr(0,t.length-e.length):t}function CE(t){return!t||t.length<2?!1:t[0]==="["||(t[0]==="\\"||t[0]==="{")&&t[1]==="["}var ME=["ftp","file","http","https","ws","wss"];function $E(t){if(!t)return!0;for(let e of ME)if(t.test(e))return!0;return!1}function MO(t,e){if(t=PE(t,"#"),e||t==="")return t;let n=new URL("https://example.com");return n.hash=t,n.hash?n.hash.substring(1,n.hash.length):""}function $O(t,e){if(t=PE(t,"?"),e||t==="")return t;let n=new URL("https://example.com");return n.search=t,n.search?n.search.substring(1,n.search.length):""}function RO(t,e){return e||t===""?t:CE(t)?LE(t):IE(t)}function IO(t,e){if(e||t==="")return t;let n=new URL("https://example.com");return n.password=t,n.password}function LO(t,e){if(e||t==="")return t;let n=new URL("https://example.com");return n.username=t,n.username}function AO(t,e,n){if(n||t==="")return t;if(e&&!ME.includes(e))return new URL(`${e}:${t}`).pathname;let i=t[0]=="/";return t=new URL(i?t:"/-"+t,"https://example.com").pathname,i||(t=t.substring(2,t.length)),t}function DO(t,e,n){return RE(e)===t&&(t=""),n||t===""?t:AE(t)}function NO(t,e){return t=CO(t,":"),e||t===""?t:Iv(t)}function RE(t){switch(t){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}function Iv(t){if(t==="")return t;if(/^[-+.A-Za-z0-9]*$/.test(t))return t.toLowerCase();throw new TypeError(`Invalid protocol '${t}'.`)}function OO(t){if(t==="")return t;let e=new URL("https://example.com");return e.username=t,e.username}function FO(t){if(t==="")return t;let e=new URL("https://example.com");return e.password=t,e.password}function IE(t){if(t==="")return t;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(t))throw new TypeError(`Invalid hostname '${t}'`);let e=new URL("https://example.com");return e.hostname=t,e.hostname}function LE(t){if(t==="")return t;if(/[^0-9a-fA-F[\]:]/g.test(t))throw new TypeError(`Invalid IPv6 hostname '${t}'`);return t.toLowerCase()}function AE(t){if(t===""||/^[0-9]*$/.test(t)&&parseInt(t)<=65535)return t;throw new TypeError(`Invalid port '${t}'.`)}function VO(t){if(t==="")return t;let e=new URL("https://example.com");return e.pathname=t[0]!=="/"?"/-"+t:t,t[0]!=="/"?e.pathname.substring(2,e.pathname.length):e.pathname}function zO(t){return t===""?t:new URL(`data:${t}`).pathname}function UO(t){if(t==="")return t;let e=new URL("https://example.com");return e.search=t,e.search.substring(1,e.search.length)}function jO(t){if(t==="")return t;let e=new URL("https://example.com");return e.hash=t,e.hash.substring(1,e.hash.length)}var oa,Qt,Tt,Ve,Gs,aa,$n,la,ca,ua,it,wt,Fp,DE,yc,$v,Ys,fc,da,Dp,mn,Xn,vc,Rv,Vp,NE,pa,Np,zp,OE,Up,FE,ha,Op,Gr,ra,yr,Ks,jp,VE,Bp,zE,Hp,UE,qp,jE,Zn,ji,Wp,BE,xE,BO=(xE=class{constructor(t){Y(this,it);Y(this,Fp);Y(this,yc);Y(this,Ys);Y(this,da);Y(this,mn);Y(this,vc);Y(this,Vp);Y(this,pa);Y(this,zp);Y(this,Up);Y(this,ha);Y(this,Gr);Y(this,yr);Y(this,jp);Y(this,Bp);Y(this,Hp);Y(this,qp);Y(this,Zn);Y(this,Wp);Y(this,oa,void 0);Y(this,Qt,[]);Y(this,Tt,{});Y(this,Ve,0);Y(this,Gs,1);Y(this,aa,0);Y(this,$n,0);Y(this,la,0);Y(this,ca,0);Y(this,ua,!1);Le(this,oa,t)}get result(){return C(this,Tt)}parse(){for(Le(this,Qt,TE(C(this,oa),!0));C(this,Ve)0)if(F(this,Bp,zE).call(this))Le(this,la,C(this,la)-1);else continue;if(F(this,jp,VE).call(this)){Le(this,la,C(this,la)+1);continue}switch(C(this,$n)){case 0:F(this,vc,Rv).call(this)&&F(this,Ys,fc).call(this,1);break;case 1:if(F(this,vc,Rv).call(this)){F(this,Wp,BE).call(this);let t=7,e=1;F(this,Vp,NE).call(this)?(t=2,e=3):C(this,ua)&&(t=2),F(this,it,wt).call(this,t,e)}break;case 2:F(this,pa,Np).call(this)?F(this,Ys,fc).call(this,3):(F(this,ha,Op).call(this)||F(this,Gr,ra).call(this)||F(this,yr,Ks).call(this))&&F(this,Ys,fc).call(this,5);break;case 3:F(this,zp,OE).call(this)?F(this,it,wt).call(this,4,1):F(this,pa,Np).call(this)&&F(this,it,wt).call(this,5,1);break;case 4:F(this,pa,Np).call(this)&&F(this,it,wt).call(this,5,1);break;case 5:F(this,Hp,UE).call(this)?Le(this,ca,C(this,ca)+1):F(this,qp,jE).call(this)&&Le(this,ca,C(this,ca)-1),F(this,Up,FE).call(this)&&!C(this,ca)?F(this,it,wt).call(this,6,1):F(this,ha,Op).call(this)?F(this,it,wt).call(this,7,0):F(this,Gr,ra).call(this)?F(this,it,wt).call(this,8,1):F(this,yr,Ks).call(this)&&F(this,it,wt).call(this,9,1);break;case 6:F(this,ha,Op).call(this)?F(this,it,wt).call(this,7,0):F(this,Gr,ra).call(this)?F(this,it,wt).call(this,8,1):F(this,yr,Ks).call(this)&&F(this,it,wt).call(this,9,1);break;case 7:F(this,Gr,ra).call(this)?F(this,it,wt).call(this,8,1):F(this,yr,Ks).call(this)&&F(this,it,wt).call(this,9,1);break;case 8:F(this,yr,Ks).call(this)&&F(this,it,wt).call(this,9,1);break;case 9:break;case 10:break}}C(this,Tt).hostname!==void 0&&C(this,Tt).port===void 0&&(C(this,Tt).port="")}},oa=new WeakMap,Qt=new WeakMap,Tt=new WeakMap,Ve=new WeakMap,Gs=new WeakMap,aa=new WeakMap,$n=new WeakMap,la=new WeakMap,ca=new WeakMap,ua=new WeakMap,it=new WeakSet,wt=function(t,e){var n,i,r;switch(C(this,$n)){case 0:break;case 1:C(this,Tt).protocol=F(this,Zn,ji).call(this);break;case 2:break;case 3:C(this,Tt).username=F(this,Zn,ji).call(this);break;case 4:C(this,Tt).password=F(this,Zn,ji).call(this);break;case 5:C(this,Tt).hostname=F(this,Zn,ji).call(this);break;case 6:C(this,Tt).port=F(this,Zn,ji).call(this);break;case 7:C(this,Tt).pathname=F(this,Zn,ji).call(this);break;case 8:C(this,Tt).search=F(this,Zn,ji).call(this);break;case 9:C(this,Tt).hash=F(this,Zn,ji).call(this);break;case 10:break}C(this,$n)!==0&&t!==10&&([1,2,3,4].includes(C(this,$n))&&[6,7,8,9].includes(t)&&((n=C(this,Tt)).hostname??(n.hostname="")),[1,2,3,4,5,6].includes(C(this,$n))&&[8,9].includes(t)&&((i=C(this,Tt)).pathname??(i.pathname=C(this,ua)?"/":"")),[1,2,3,4,5,6,7].includes(C(this,$n))&&t===9&&((r=C(this,Tt)).search??(r.search=""))),F(this,Fp,DE).call(this,t,e)},Fp=new WeakSet,DE=function(t,e){Le(this,$n,t),Le(this,aa,C(this,Ve)+e),Le(this,Ve,C(this,Ve)+e),Le(this,Gs,0)},yc=new WeakSet,$v=function(){Le(this,Ve,C(this,aa)),Le(this,Gs,0)},Ys=new WeakSet,fc=function(t){F(this,yc,$v).call(this),Le(this,$n,t)},da=new WeakSet,Dp=function(t){return t<0&&(t=C(this,Qt).length-t),t=0&&(t.pathname=gr(i.pathname.substring(0,r+1),n)+t.pathname)}t.pathname=AO(t.pathname,t.protocol,n)}return typeof e.search=="string"&&(t.search=$O(e.search,n)),typeof e.hash=="string"&&(t.hash=MO(e.hash,n)),t}function mc(t){return t.replace(/([+*?:{}()\\])/g,"\\$1")}function HO(t){return t.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}function qO(t,e){e.delimiter??(e.delimiter="/#?"),e.prefixes??(e.prefixes="./"),e.sensitive??(e.sensitive=!1),e.strict??(e.strict=!1),e.end??(e.end=!0),e.start??(e.start=!0),e.endsWith="";let n=".*",i=`[^${HO(e.delimiter)}]+?`,r=/[$_\u200C\u200D\p{ID_Continue}]/u,s="";for(let o=0;o0?t[o-1]:null,d=o0?d.value[0]:"";c=r.test(p)}else c=!d.hasCustomName();if(!c&&!a.prefix.length&&u&&u.type===3){let p=u.value[u.value.length-1];c=e.prefixes.includes(p)}c&&(s+="{"),s+=mc(a.prefix),l&&(s+=`:${a.name}`),a.type===2?s+=`(${a.value})`:a.type===1?l||(s+=`(${i})`):a.type===0&&(!l&&(!u||u.type===3||u.modifier!==3||c||a.prefix!=="")?s+="*":s+=`(${n})`),a.type===1&&l&&a.suffix.length&&r.test(a.suffix[0])&&(s+="\\"),s+=mc(a.suffix),c&&(s+="}"),a.modifier!==3&&(s+=sa(a.modifier))}return s}var Bi,Qs,fa,Et,_i,ma,kE,Kp=(kE=class{constructor(t={},e,n){Y(this,Bi,void 0);Y(this,Qs,{});Y(this,fa,{});Y(this,Et,{});Y(this,_i,{});Y(this,ma,!1);try{let i;if(typeof e=="string"?i=e:n=e,typeof t=="string"){let a=new BO(t);if(a.parse(),t=a.result,i===void 0&&typeof t.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");t.baseURL=i}else{if(!t||typeof t!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(i)throw new TypeError("parameter 1 is not of type 'string'.")}typeof n>"u"&&(n={ignoreCase:!1});let r={ignoreCase:n.ignoreCase===!0};Le(this,Bi,hc({pathname:Wr,protocol:Wr,username:Wr,password:Wr,hostname:Wr,port:Wr,search:Wr,hash:Wr},t,!0)),RE(C(this,Bi).protocol)===C(this,Bi).port&&(C(this,Bi).port="");let o;for(o of Cv){if(!(o in C(this,Bi)))continue;let a={},l=C(this,Bi)[o];switch(C(this,fa)[o]=[],o){case"protocol":Object.assign(a,Kr),a.encodePart=Iv;break;case"username":Object.assign(a,Kr),a.encodePart=OO;break;case"password":Object.assign(a,Kr),a.encodePart=FO;break;case"hostname":Object.assign(a,EO),CE(l)?a.encodePart=LE:a.encodePart=IE;break;case"port":Object.assign(a,Kr),a.encodePart=AE;break;case"pathname":$E(C(this,Qs).protocol)?(Object.assign(a,SO,r),a.encodePart=VO):(Object.assign(a,Kr,r),a.encodePart=zO);break;case"search":Object.assign(a,Kr,r),a.encodePart=UO;break;case"hash":Object.assign(a,Kr,r),a.encodePart=jO;break}try{C(this,_i)[o]=EE(l,a),C(this,Qs)[o]=SE(C(this,_i)[o],C(this,fa)[o],a),C(this,Et)[o]=qO(C(this,_i)[o],a),Le(this,ma,C(this,ma)||C(this,_i)[o].some(c=>c.type===2))}catch{throw new TypeError(`invalid ${o} pattern '${C(this,Bi)[o]}'.`)}}}catch(i){throw new TypeError(`Failed to construct 'URLPattern': ${i.message}`)}}test(t={},e){let n={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof t!="string"&&e)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof t>"u")return!1;try{typeof t=="object"?n=hc(n,t,!1):n=hc(n,bE(t,e),!1)}catch{return!1}let i;for(i of Cv)if(!C(this,Qs)[i].exec(n[i]))return!1;return!0}exec(t={},e){let n={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof t!="string"&&e)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof t>"u")return;try{typeof t=="object"?n=hc(n,t,!1):n=hc(n,bE(t,e),!1)}catch{return null}let i={};e?i.inputs=[t,e]:i.inputs=[t];let r;for(r of Cv){let s=C(this,Qs)[r].exec(n[r]);if(!s)return null;let o={};for(let[a,l]of C(this,fa)[r].entries())if(typeof l=="string"||typeof l=="number"){let c=s[a+1];o[l]=c}i[r]={input:n[r]??"",groups:o}}return i}static compareComponent(t,e,n){let i=(a,l)=>{for(let c of["type","modifier","prefix","value","suffix"]){if(a[c]{let c=0;for(;cKE(t)===null?null:"bilibili",YE=t=>{let e=KE(t);if(e===null)throw new Error("Invalid bilibili url");let n=fn(t.hash),i=ZO(t),r=xi(t);r.hostname==="bilibili.com"&&(r.hostname="www.bilibili.com"),r.searchParams.forEach((a,l,c)=>{l==="p"&&a!=="1"||c.delete(l)}),r.searchParams.sort();let s=r.searchParams.get("p")??"1",o=new URL(r);return!n&&i>0&&(n={start:i,end:-1}),n&&Gn(n)&&(o=WE(o,n)),o=Hi(o),{source:o,cleaned:r,tempFrag:n,print:a=>WE(o,a).href,id:`${s}@${e}`||void 0}};function WE(t,e){let n=new URL(t.href);return n.searchParams.set("t",String(e.start)),n}function ZO(t){let e=t.searchParams.get("t"),n=e?Number(e):NaN;return Number.isNaN(n)?NaN:n}var QE=t=>t.hostname==="www.coursera.org"?"coursera":null,XE=t=>{let e=xi(t);e.search="";let n=new URL(t);return{cleaned:e,source:Hi(n),tempFrag:fn(t.hash)}};var ZE=require("obsidian");var JE=t=>({type:"generic",cleaned:xi(t),source:Hi(t.protocol==="file:"?JO(t):t),tempFrag:fn(t.hash)});function JO(t){let e=new URL(ZE.Platform.resourcePathPrefix+t.href.substring(8));return e.search=Date.now().toString(),e}var eS=t=>t.hostname!=="vimeo.com"||!t.pathname.substring(1).match(/^\d+$/)?null:"vimeo",tS=t=>{let e=t.pathname.substring(1);if(!e.match(/^\d+$/))throw new Error("Invalid vimeo url");let n=xi(t);n.search="";let i=new URL(t);return{cleaned:n,source:Hi(i),tempFrag:fn(t.hash),id:e}};function rS(t){let e=t.pathname.split("/");if(t.hostname==="youtu.be"&&e.length===2)return e[1];if(t.hostname==="www.youtube.com"||t.hostname==="youtube.com"){if(e.length===2&&e[1]==="watch")return t.searchParams.get("v");let n=["shorts","embed","v"];if(e.length===3&&n.includes(e[1]))return e[2]}return null}var sS=t=>rS(t)?"youtube":null,oS=t=>{let e=fn(t.hash),n=Av(t.searchParams.get("t")),i=Av(t.searchParams.get("start")),r=Av(t.searchParams.get("end")),s=rS(t);if(!s)throw new Error("Invalid youtube url");let o=xi("https://www.youtube.com/watch");o.search=new URLSearchParams({v:s}).toString();let a=new URL(o);return t.searchParams.has("list")&&a.searchParams.set("list",t.searchParams.get("list")),e||(i>0&&r>0?e=yE(i,r):i>0?e={start:i,end:1/0}:r>0?e={start:0,end:r}:n>0&&(e={start:n,end:-1})),e&&(a=nS(a,e)),a=Hi(a),{source:a,cleaned:o,tempFrag:e,print:l=>nS(a,l).href,id:s}};function nS(t,e){let n=new URL(t),i=iS(e.start),r=iS(e.end);return Gn(e)||e.start>0&&e.end>0&&i===r?n.searchParams.set("t",i):(e.start>0&&n.searchParams.set("start",i),e.end>0&&n.searchParams.set("end",r)),n}function iS(t){return t.toFixed(0)}function Av(t){if(!t)return NaN;let e=Number(t);if(!Number.isNaN(e))return e;let n=/^(?:(?\d+)h)?(?:(?\d+)m)?(?:(?\d+)s)?$/,i=t.match(n);if(!i)return NaN;let{h:r,m:s,s:o}=i.groups,a=r?Number(r):0,l=s?Number(s):0,c=o?Number(o):0;return a*3600+l*60+c}function aS(t){let e=eF.reduce((i,r)=>i??r(t),null)??"generic",n=tF[e](t);return{type:e,resolved:n}}var eF=[GE,sS,eS,QE],tF={bilibili:YE,youtube:oS,vimeo:tS,coursera:XE,generic:JE};function lS(t,{getUrlMapping:e},n){if(!t)return null;if(t.protocol!=="mx:")return s(t);let[,,i]=t.pathname.split("/"),r=e(i);if(!r)return null;return s(t.href.replace(`mx://${i}/`,r.replace(/\/*$/,"/")),t);function s(o,a){let l=Rn.create(o,a);if(!l)return null;if(!l.isFileUrl)return l;let c=l.getVaultFile(n.vault);return c?hn(c.extension)===null?null:Ui(c,l.hash):l.inferredType===null?null:l}}var nF=new Set(["https:","http:","file:"]),qi,wc=class wc extends URL{constructor(n,i){super(n);Y(this,qi,void 0);E(this,"type");E(this,"mxUrl");if(this.mxUrl=i?new URL(i):null,!nF.has(this.protocol))throw new Error("Unsupported protocol: "+this.protocol);let{type:r,resolved:s}=aS(this);Le(this,qi,s),this.type=r}static create(n,i){if(n instanceof wc)return n.clone();try{return new wc(n,i)}catch{return null}}get inferredType(){let n=this.pathname.split(".").pop();return n?hn(n):null}get isFileUrl(){return this.protocol==="file:"}get filePath(){if(this.isFileUrl)try{return(0,cS.fileURLToPath)(this)}catch(n){return console.error("Failed to convert file url to path",n,this.href),null}return null}getVaultFile(n){if(!(n.adapter instanceof Gp.FileSystemAdapter))return null;let i=this.filePath,r=n.adapter.getBasePath();if(!i)return null;let s=bi.relative(r,i);if(/^\.\.[/\\]/.test(s)||bi.isAbsolute(s))return null;let o=(0,Gp.normalizePath)(s);return n.getFileByPath(o)}compare(n){return!!n&&this.jsonState.source===n.jsonState.source}print(n){return this.mxUrl?ga(this.mxUrl.href):n?C(this,qi).print?C(this,qi).print(n):this.jsonState.source:this.jsonState.source}get tempFrag(){return fn(this.hash)}setTempFrag(n){let i=this.clone(),r=pc(this.hash);return n?i.hash=Sv(r,n):i.hash=r,i}clone(){return new wc(this,this.mxUrl??void 0)}get readableHref(){return decodeURI(this.href)}get source(){return C(this,qi).source}get cleaned(){return C(this,qi).cleaned}get id(){return C(this,qi).id}get jsonState(){return{source:ga(this.mxUrl??this.cleaned),hash:Sv(this.hash,C(this,qi).tempFrag)}}};qi=new WeakMap;var Rn=wc;var _c,Dv,Yp=class extends Qp.Component{constructor(n){super();this.plugin=n;Y(this,_c);E(this,"matcher");F(this,_c,Dv).call(this)}onload(){let n=(0,Qp.debounce)(()=>F(this,_c,Dv).call(this),500,!0);this.register(this.plugin.settings.subscribe((i,r)=>{i.linkHandler!==r.linkHandler&&n()}))}getPreferred(n,i){let r=this.getSupported(n),s=null;for(let o of r)for(let a of this.matcher.get(o)){if(!a.test(n))continue;let l=iF(a);(!s||l>s.specifity)&&(s={type:o,specifity:l})}return s?.type??(i?null:r[0])}setPreferred(n,i){this.plugin.settings.getState().setLinkHandler(n,i)}getSupported(n){if(!(n instanceof Rn))return[gn[n.type]];if(n.type==="generic")switch(n.inferredType){case"video":return[Xt.video,Jn];case"audio":return[Xt.audio,Jn];default:return[Jn,Xt.video,Xt.audio]}switch(n.type){case"youtube":case"vimeo":return[Jn,Xs];case"bilibili":case"coursera":return[Jn];default:(0,uS.assertNever)(n.type)}}};_c=new WeakSet,Dv=function(){this.matcher=new Map(Object.entries(this.plugin.settings.getState().linkHandler).map(([n,i])=>[n,i.map(r=>new Kp(r))]))};function iF(t){return["protocol","username","password","hostname","port","pathname","search","hash"].reduce((e,n)=>{let i=t[n];return e+(i!=="*"?1:0)},0)}var lt=require("obsidian");function ya(t,e){let n="target"in t?t.target:t;if(!n.instanceOf?.(HTMLElement))return;let i=n.getBoundingClientRect();return e.setParentElement(n).showAtPosition({x:i.x,y:i.bottom,width:i.width,overlap:!0,left:!0},n.doc)}var dS="mx-port";var Yr=t=>`persist:mx-player-${t}`;var pS=require("obsidian");function bc(t){let e=require("@electron/remote"),n=Yr(t);return n?e.session.fromPartition(n):(console.log("No partition, skip modifying session"),null)}function hS(){return pS.Platform.isDesktopApp?require("fs/promises"):null}function fS(t){return require("@electron/remote").webContents.fromId(t)}function Xp(){return require("@electron/remote").dialog}var Qr=class extends lt.Modal{constructor(n){super(n);E(this,"navEl",this.contentEl.insertAdjacentElement("beforebegin",createDiv({cls:"mx-login-nav"})));E(this,"webview",createEl("webview",{attr:{partition:this.partition,allowpopups:""}}));E(this,"backButton",new lt.ButtonComponent(this.navEl).setIcon("arrow-left").setTooltip("Back").setClass("mx-login-back").setDisabled(!0).onClick(()=>{try{this.webview.goBack()}catch(n){new lt.Notice("Failed to go back, see console for details"),console.error("err go back",n)}}));E(this,"forwardButton",new lt.ButtonComponent(this.navEl).setIcon("arrow-right").setTooltip("Forward").setClass("mx-login-forward").setDisabled(!0).onClick(()=>{try{this.webview.goForward()}catch(n){new lt.Notice("Failed to go forward, see console for details"),console.error("err go forward",n)}}));E(this,"refreshButton",new lt.ButtonComponent(this.navEl).setIcon("rotate-ccw").setTooltip("Refresh").setClass("mx-login-refresh").setDisabled(!0).onClick(()=>{try{this.webview.reload()}catch(n){new lt.Notice("Failed to refresh, see console for details"),console.error("err refresh",n)}}));E(this,"addressBarForm",this.navEl.createEl("form"));E(this,"addressBar",new lt.TextComponent(this.addressBarForm).then(n=>{n.inputEl.type="url",n.inputEl.placeholder="https://example.com",n.inputEl.classList.add("mx-login-address")}));E(this,"addressSubmit",new lt.ButtonComponent(this.addressBarForm).setIcon("arrow-right-circle").then(n=>n.buttonEl.type="submit"));E(this,"moreOptionsButton",new lt.ButtonComponent(this.navEl).setIcon("more-horizontal").setTooltip("More options").setClass("mx-login-more").onClick(n=>{let i=new lt.Menu;this.onMoreOptions(i),ya(n,i)}));E(this,"callbacks",[]);E(this,"handledWebcontents",new Set);this.containerEl.addClasses(["mx-login-modal"]),this.titleEl.style.display="none",this.buildWelcome()}get partition(){return Yr(this.app.appId)}buildWelcome(){this.contentEl.empty(),this.contentEl.createEl("h1").setText("Login");let n=this.contentEl.createEl("main");n.createEl("p").setText("You can login to sites, change preferences and more, just as you would in a browser."),n.createEl("p").setText("To open a website, you can:");let i=n.createEl("ul");i.createEl("li").setText("Enter the site address in the address bar");let r=i.createEl("li");r.setText("Select from a list of "),new lt.DropdownComponent(r).addOptions({...cE(Mp),".":"supported websites..."}).setValue(".").onChange(s=>{s in Ev&&this.setUrl(Ev[s])})}getSession(){return bc(this.app.appId)}onMoreOptions(n){n.addItem(i=>i.setTitle("Clear cache").setSection("clear").setIcon("trash").onClick(async()=>{if(window.confirm("Are you sure you want to clear the website cache? All login sessions and preferences will be lost."))try{await this.getSession()?.clearCache(),new lt.Notice("Cache cleared")}catch(s){new lt.Notice("Failed to clear cache, see console for details"),console.error("err clear cache",s)}}))}setUrl(n){this.initWebview(),this.webview.src=n,this.addressBar.setValue(n)}register(n){this.callbacks.push(n)}registerWebviewEvent(n,i){this.webview.addEventListener(n,i),this.register(()=>this.webview.removeEventListener(n,i))}onClose(){for(let n of this.callbacks)n();this.containerEl.empty()}initWebview(){this.webview.isConnected||(this.registerWebviewEvent("will-navigate",()=>{this.addressBar.setValue(this.webview.getURL())}),this.contentEl.empty(),this.contentEl.appendChild(this.webview),this.backButton.setDisabled(!1),this.forwardButton.setDisabled(!1),this.refreshButton.setDisabled(!1),this.registerWebviewEvent("dom-ready",()=>{if(this.handledWebcontents.has(this.webview.getWebContentsId()))return;let n=this.webview.getWebContentsId();this.handledWebcontents.add(n),fS(n)?.setWindowOpenHandler(({url:r,disposition:s})=>((s==="new-window"||s==="foreground-tab"||s==="default")&&this.setUrl(r),{action:"deny"}))}))}onOpen(){this.addressBarForm.onsubmit=n=>{n.preventDefault();let i=this.addressBar.getValue();i&&this.setUrl(i)}}};function mS(){this.addCommand({id:"login",name:"Login website",callback:()=>{new Qr(this.app).open()}})}var o2=require("obsidian");var Hl=require("obsidian");var Zp=require("obsidian"),va=class t extends Zp.Modal{constructor(n,i,r){super(n);this.onSubmit=i;this.onExit=r;this.containerEl.addClass("mx-playback-prompt"),this.onSubmit=i}static run(){return new Promise(n=>{new t(app,r=>n(Number(r)),()=>n(null)).open()})}onOpen(){let{contentEl:n,titleEl:i}=this;i.setText("Playback Speed");let r=n.createEl("form",{},s=>{s.createEl("input",{type:"number",placeholder:"Enter a number between 0 and 10",attr:{min:.1,max:10,step:.1,width:100,required:!0,name:"playback-speed"}}),s.createEl("button",{attr:{type:"submit"},text:"Submit"})});r.oninvalid=s=>{s.preventDefault(),new Zp.Notice("Invalid playback rate")},r.onsubmit=s=>{s.preventDefault();let o=new FormData(r);this.onSubmit(o.get("playback-speed").toString()),this.close()}}onClose(){let{contentEl:n}=this;n.empty(),this.onExit()}};var ei=[.25,.5,.75,1,1.25,1.5,2,3,5,10];function gS(t,e){let n=e.state.playbackRate,i=!ei.includes(n),r=t.setTitle(rF(n)).setIcon("gauge").setSection("mx-player").setSubmenu();ei.forEach(s=>r.addItem(o=>o.setTitle(`${s}x`).setChecked(s===n).onClick(()=>{e.playbackRate=s}))),r.addItem(s=>s.setTitle(sF(n)).setChecked(i).onClick(async()=>{let o=await va.run();o&&(e.playbackRate=o)}))}function rF(t){let e=new DocumentFragment;return e.appendText("Speed "),e.createEl("code",{text:`(${t}x)`}),e}function sF(t){let e=new DocumentFragment;return e.appendText("Custom"),ei.includes(t)?e.appendText("..."):(e.appendText(" "),e.createEl("code",{text:`(${t}x)`})),e}var Ry=require("obsidian");var Bl=require("obsidian");function Jp(){return/[<>:"/\\|?*\u0000-\u001F]/g}function yS(){return/^(con|prn|aux|nul|com\d|lpt\d)$/i}var oF=100,aF=/^\.+(\\|\/)|^\.+$/,lF=/\.+$/;function Nv(t,e={}){let n=/[\u0000-\u001F\u0080-\u009F]/g,i=/([<>:"/\\|?*\u0000-\u001F]){2,}/g;if(typeof t!="string")throw new TypeError("Expected a string");let r=e.replacement===void 0?"!":e.replacement;if(Jp().test(r)&&n.test(r))throw new Error("Replacement string cannot contain reserved filename characters");r.length>0&&(t=t.replace(i,"$1")),t=t.normalize("NFD"),t=t.replace(aF,r),t=t.replace(Jp(),r),t=t.replace(n,r),t=t.replace(lF,""),r.length>0&&(!(t[0]===".")&&t[0]==="."&&(t=r+t),t[t.length-1]==="."&&(t+=r)),t=yS().test(t)?t+r:t;let s=typeof e.maxLength=="number"?e.maxLength:oF;if(t.length>s){let o=t.lastIndexOf(".");if(o===-1)t=t.slice(0,s);else{let a=t.slice(0,o),l=t.slice(o);t=a.slice(0,Math.max(1,s-l.length))+l}}return t}function eh(t){return Nv(t,{replacement:"_"}).replaceAll(/[[\]#^|]/g,"_")}var vS=require("obsidian");function th(t){let e=vS.Keymap.isModEvent(t);return Xr(e)}function Xr(t){return t===!0?"tab":t}var xy=require("obsidian"),YA=A(mu());var yi=A(X());var JC={},ZC=t=>{let e,n=new Set,i=(u,d)=>{let p=typeof u=="function"?u(e):u;if(!Object.is(p,e)){let h=e;e=d??(typeof p!="object"||p===null)?p:Object.assign({},e,p),n.forEach(m=>m(e,h))}},r=()=>e,l={setState:i,getState:r,getInitialState:()=>c,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(JC.env?JC.env.MODE:void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},c=e=t(i,r,l);return l},Ef=t=>t?ZC(t):ZC;var uM=A(X(),1),dM=A(aM(),1),cM={},{useDebugValue:jV}=uM.default,{useSyncExternalStoreWithSelector:BV}=dM.default,lM=!1,HV=t=>t;function ib(t,e=HV,n){(cM.env?cM.env.MODE:void 0)!=="production"&&n&&!lM&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),lM=!0);let i=BV(t.subscribe,t.getState,t.getServerState||t.getInitialState,e,n);return jV(i),i}function Pf(t){let e=new URLSearchParams(t.replace(/^#+/,"")),n=!e.has("noctrl")&&!e.has("controls")?void 0:e.has("controls");return{loop:e.has("loop")?!0:void 0,muted:e.has("mute")?!0:void 0,autoplay:e.has("play")?!0:void 0,controls:n,volume:qV(e.get("vol")),tempFragment:fn(t)}}function qV(t){if(!t)return;let e=parseInt(t,10);if(!isNaN(e)&&e>=0&&e<=100)return e/100}var pM=()=>({emit(t,...e){for(let n=0,i=this.events[t]||[],r=i.length;n{this.events[t]=this.events[t]?.filter(i=>e!==i)}}});function Cf(){let t=pM();return t.once=function(n,i){let r=this.on(n,(...s)=>{r(),i(...s)});return r},t}function hM(t){let e=t;return typeof e.id=="string"&&typeof e.invoke=="string"}function fM(t,...e){return{id:WV(),invoke:t,args:e}}function mM(t){return typeof t.id=="string"}function gM(t){return typeof t.send=="string"}function yM(t,e){return{send:t,payload:e}}function WV(){return Math.random().toString(36).substring(2,9)}var Mf=class extends Error{constructor(e){super(`no handler for ${e}`)}},rb="mx-port-ready";var $f=class{constructor(){E(this,"port",null);E(this,"actions",Object.create(null));E(this,"emitter",Cf());E(this,"methods",new Proxy({},{get:(e,n)=>{if(typeof n=="symbol")throw new Error("Remote invoke does not support symbol property");return e[n]??(e[n]=(...i)=>this.invoke(n.toString(),i))}}))}load(e){this.port&&this.port.close(),this.port=e;let n=({data:i})=>{this.onMessage(i)};e.addEventListener("message",n),e.start(),e.postMessage(rb)}unload(){this.port?.close(),this.emitter.events={}}onMessage(e){e===rb?this.emitter.emit("ready"):hM(e)?this.response(e):mM(e)?this.emitter.emit("resp",e.id,e.payload,e.error):gM(e)&&this.emitter.emit(`send:${e.send}`,{type:e.send,payload:e.payload})}invoke(e,n,{transfer:i,timeout:r=1e3}={}){if(!this.port)throw new Error("port not loaded");let s=fM(e,...n);return this.port.postMessage(s,{transfer:i}),new Promise((o,a)=>{let l=-1,c=this.emitter.on("resp",(u,d,p)=>{if(u===s.id)if(c(),window.clearTimeout(l),p){let{message:h,stack:m}=p,v=new Error(h);v.stack=m,a(v)}else o(d)});r>0&&r<1/0&&(l=window.setTimeout(()=>{c(),console.error(`${e} timeout after ${r}ms`),a(new Cr(r))},r))})}handle(e,n){this.actions[e]=n}send(e,n,i){if(!this.port)throw new Error("port not loaded");let r=yM(e,n);this.port.postMessage(r,{transfer:i})}on(e,n){return this.emitter.on(`send:${e}`,n)}once(e,n){return this.emitter.once(`send:${e}`,n)}onReady(e,{once:n=!1}={}){return n?this.emitter.once("ready",e):this.emitter.on("ready",e)}async response({id:e,invoke:n,args:i=[]}){if(!this.port)throw new Error("port not loaded");let r={id:e,payload:null};try{let s=this.actions[n];if(!s)throw new Mf(n);let o=await s(...i);o===void 0?this.port.postMessage(r):(r.payload=await o.value,this.port.postMessage(r,{transfer:o.transfer}))}catch(s){console.error("port messaging error",s),s instanceof Error?r.error={message:s.message,stack:s.stack}:r.error={message:String(s)},this.port.postMessage(r)}}},Cr=class extends Error{constructor(e){super(`timeout after ${e}ms`)}};var KV=()=>{},gu=KV;an();an();En();En();var Q=A(X(),1);var $=A(X(),1);an();En();var BR=A(fu(),1);function sr(){return Bf(Id)}var Z6=de(cd,{domEventsRegex:/^onMedia/}),HR=$.forwardRef(({children:t,...e},n)=>$.createElement(Z6,{...e},i=>$.createElement(te.button,{...i,ref:ye(i.ref,n)},t)));HR.displayName="AirPlayButton";var J6=de(ld,{domEventsRegex:/^onMedia/}),pg=$.forwardRef(({children:t,...e},n)=>$.createElement(J6,{...e},i=>$.createElement(te.button,{...i,ref:ye(i.ref,n)},t)));pg.displayName="PlayButton";var eU=de(id,{domEventsRegex:/^onMedia/}),hk=$.forwardRef(({children:t,...e},n)=>$.createElement(eU,{...e},i=>$.createElement(te.button,{...i,ref:ye(i.ref,n)},t)));hk.displayName="CaptionButton";var tU=de(rd,{domEventsRegex:/^onMedia/}),hg=$.forwardRef(({children:t,...e},n)=>$.createElement(tU,{...e},i=>$.createElement(te.button,{...i,ref:ye(i.ref,n)},t)));hg.displayName="FullscreenButton";var nU=de(od,{domEventsRegex:/^onMedia/}),fg=$.forwardRef(({children:t,...e},n)=>$.createElement(nU,{...e},i=>$.createElement(te.button,{...i,ref:ye(i.ref,n)},t)));fg.displayName="MuteButton";var iU=de(ad,{domEventsRegex:/^onMedia/}),fk=$.forwardRef(({children:t,...e},n)=>$.createElement(iU,{...e},i=>$.createElement(te.button,{...i,ref:ye(i.ref,n)},t)));fk.displayName="PIPButton";var rU=de(dd,{domEventsRegex:/^onMedia/}),Nd=$.forwardRef(({children:t,...e},n)=>$.createElement(rU,{...e},i=>$.createElement(te.button,{...i,ref:ye(i.ref,n)},t)));Nd.displayName="SeekButton";var sU=de(sd,{domEventsRegex:/^onMedia/}),qR=$.forwardRef(({children:t,...e},n)=>$.createElement(sU,{...e},i=>$.createElement(te.button,{...i,ref:ye(i.ref,n)},t)));qR.displayName="LiveButton";var mk=de(wd),oU=de(md,{events:["onDragStart","onDragEnd","onDragValueChange","onValueChange","onPointerValueChange"]}),aU=$.forwardRef(({children:t,...e},n)=>$.createElement(oU,{...e,ref:n},i=>$.createElement(te.div,{...i},t)));aU.displayName="Slider";var lU=$.forwardRef((t,e)=>$.createElement(te.div,{...t,ref:e}));lU.displayName="SliderThumb";var cU=$.forwardRef((t,e)=>$.createElement(te.div,{...t,ref:e}));cU.displayName="SliderTrack";var uU=$.forwardRef((t,e)=>$.createElement(te.div,{...t,ref:e}));uU.displayName="SliderTrackFill";var dU=de(bd),pU=$.forwardRef(({children:t,...e},n)=>$.createElement(dU,{...e},i=>$.createElement(te.div,{...i,ref:ye(i.ref,n)},t)));pU.displayName="SliderPreview";var hU=$.forwardRef(({children:t,...e},n)=>$.createElement(mk,{...e},(i,r)=>{let s=Me(()=>r.getValueText(),r);return $.createElement(te.div,{...i,ref:n},s,t)}));hU.displayName="SliderValue";var fU=de(yd,{domEventsRegex:/^onMedia/}),mU=$.forwardRef(({children:t,...e},n)=>$.createElement(fU,{...e,ref:n},i=>$.createElement(te.div,{...i},t)));mU.displayName="VolumeSlider";var gU=$.forwardRef(({children:t,...e},n)=>$.createElement(mk,{...e},(i,r)=>{let s=Me(()=>r.getValueText(),r);return $.createElement(te.div,{...i,ref:ye(i.ref,n)},s,t)}));gU.displayName="SliderValue";function yU(t=0,e=0,n=""){return B?{startTime:t,endTime:e,text:n,addEventListener:kn,removeEventListener:kn,dispatchEvent:kn}:new window.VTTCue(t,e,n)}var vU=de(bl),WR=$.forwardRef(({children:t,...e},n)=>$.createElement(vU,{...e},i=>$.createElement(te.div,{...i,ref:ye(i.ref,n)},t)));WR.displayName="Thumbnail";var KR=$.forwardRef(({children:t,...e},n)=>{let{src:i,img:r,crossOrigin:s}=ws(bl.state),o=Me(i),a=Me(s);return $.createElement(te.img,{crossOrigin:a,...e,src:o,ref:ye(r.set,n)},t)});KR.displayName="ThumbnailImg";var mg=Object.freeze({__proto__:null,Img:KR,Root:WR}),gg=$.createContext({$chapters:K(null)});gg.displayName="TimeSliderContext";var wU=de(gd,{domEventsRegex:/^onMedia/}),_U=$.forwardRef(({children:t,...e},n)=>{let i=$.useMemo(()=>K(null),[]);return $.createElement(gg.Provider,{value:{$chapters:i}},$.createElement(wU,{...e,ref:n},r=>$.createElement(te.div,{...r},t)))});_U.displayName="TimeSlider";var bU=de(xd),xU=$.forwardRef(({children:t,...e},n)=>$.createElement(bU,{...e},(i,r)=>$.createElement(te.div,{...i,ref:ye(i.ref,n)},$.createElement(GR,{instance:r},t))));xU.displayName="SliderChapters";function GR({instance:t,children:e}){let n=Me(()=>t.cues,t),i=$.useRef([]),r=$.useRef(),{$chapters:s}=$.useContext(gg);return r.current||(r.current=yU()),$.useEffect(()=>(s.set(t),()=>void s.set(null)),[t]),$.useEffect(()=>{t.setRefs(i.current)},[n]),e(n.length?n:[r.current],o=>{if(!o){i.current.length=0;return}i.current.push(o)})}GR.displayName="SliderChapterTracks";var kU=$.forwardRef(({children:t,...e},n)=>{let{$chapters:i}=$.useContext(gg),[r,s]=$.useState();return $.useEffect(()=>S(()=>{let o=i(),a=o?.activePointerCue||o?.activeCue;s(a?.text||"")}),[]),$.createElement(te.div,{...e,ref:n},r,t)});kU.displayName="SliderChapterTitle";var TU=$.forwardRef(({children:t,...e},n)=>$.createElement(mk,{...e},(i,r)=>{let s=Me(()=>r.getValueText(),r);return $.createElement(te.div,{...i,ref:ye(i.ref,n)},s,t)}));TU.displayName="SliderValue";var EU=$.forwardRef((t,e)=>$.createElement(te.div,{...t,ref:e}));EU.displayName="SliderProgress";var SU=de(vd),PU=$.forwardRef(({children:t,...e},n)=>$.createElement(SU,{...e},i=>$.createElement(te.div,{...i,ref:ye(i.ref,n)},t)));PU.displayName="SliderThumbnail";var CU=de(_d,{events:["onCanPlay","onError"]}),MU=$.forwardRef(({children:t,...e},n)=>$.createElement(CU,{...e},(i,r)=>$.createElement(YR,{...i,instance:r,ref:ye(i.ref,n)},t)));MU.displayName="SliderVideo";var YR=$.forwardRef(({instance:t,children:e,...n},i)=>{let{canLoad:r}=ws($o),{src:s,video:o,crossOrigin:a}=t.$state,l=Me(s),c=Me(r),u=Me(a);return $.createElement(te.video,{style:{maxWidth:"unset"},...n,src:l||void 0,muted:!0,playsInline:!0,preload:c?"auto":"none",crossOrigin:u||void 0,ref:ye(o.set,i)},e)});YR.displayName="SliderVideoProvider";var $U=de(Pd,{events:["onChange"]}),RU=$.forwardRef(({children:t,...e},n)=>$.createElement($U,{...e,ref:n},i=>$.createElement(te.div,{...i},t)));RU.displayName="RadioGroup";var IU=de(Cd,{events:["onChange","onSelect"]}),LU=$.forwardRef(({children:t,...e},n)=>$.createElement(IU,{...e},i=>$.createElement(te.div,{...i,ref:ye(i.ref,n)},t)));LU.displayName="RadioItem";var AU=typeof document>"u",DU=de(kd,{events:["onOpen","onClose"],domEventsRegex:/^onMedia/}),NU=$.forwardRef(({children:t,...e},n)=>$.createElement(DU,{...e,ref:n},(i,r)=>$.createElement(te.div,{...i,style:{display:r.isSubmenu?void 0:"contents",...i.style}},t)));NU.displayName="Menu";var OU=de(Td,{events:["onSelect"]}),FU=$.forwardRef(({children:t,...e},n)=>$.createElement(OU,{...e},i=>$.createElement(te.button,{...i,ref:ye(i.ref,n)},t)));FU.displayName="MenuButton";var VU=$.forwardRef(({disabled:t=!1,children:e,...n},i)=>{let r=Oe("fullscreen");return AU||!(t==="fullscreen"?!r:!t)?e:(0,BR.createPortal)($.createElement(te.div,{...n,style:{display:"contents",...n.style},ref:i},e),document.body)});VU.displayName="MenuPortal";var zU=de(Ed),UU=$.forwardRef(({children:t,...e},n)=>$.createElement(zU,{...e},i=>$.createElement(te.div,{...i,ref:ye(i.ref,n)},t)));UU.displayName="MenuItems";var jU=de(Sd),BU=$.forwardRef(({children:t,...e},n)=>$.createElement(jU,{...e},i=>$.createElement(te.div,{...i,ref:ye(i.ref,n)},t)));BU.displayName="MenuItem";var HU=de($d,{events:["onWillTrigger","onTrigger"]}),hi=$.forwardRef(({children:t,...e},n)=>$.createElement(HU,{...e,ref:n},i=>$.createElement(te.div,{...i},t)));hi.displayName="Gesture";var qU=de(Rd),Od=$.forwardRef(({children:t,...e},n)=>$.createElement(qU,{...e},(i,r)=>$.createElement(QR,{...i,instance:r,ref:ye(i.ref,n)},t)));Od.displayName="Time";var QR=$.forwardRef(({instance:t,children:e,...n},i)=>{let{timeText:r}=t.$state,s=Me(r);return $.createElement(te.div,{...n,ref:i},s,e)});QR.displayName="TimeText";function or(){return sr()?.player||null}function gk({off:t=!0}={}){let e=sr(),{textTracks:n,textTrack:i}=e.$state,r=Me(n);return Me(i),$.useMemo(()=>{let s=r.filter(pt),o=s.map(a=>({track:a,label:a.label,value:jR(a),get selected(){return i()===a},select(l){let c=n().indexOf(a);c>=0&&e.remote.changeTextTrackMode(c,"showing",l)}}));return t&&o.unshift({track:null,label:Z(t)?t:"Off",value:"off",get selected(){return!i()},select(a){e.remote.toggleCaptions(a)}}),Object.defineProperty(o,"disabled",{get(){return!s.length}}),Object.defineProperty(o,"selectedTrack",{get(){return i()}}),Object.defineProperty(o,"selectedValue",{get(){let a=i();return a?jR(a):"off"}}),o},[r])}function jR(t){return t.id+":"+t.kind+"-"+t.label.toLowerCase()}var yg=A(X(),1),yk=yg.forwardRef((t,e)=>{let{width:n,height:i,size:r=null,paths:s,...o}=t;return yg.createElement("svg",{viewBox:"0 0 32 32",...o,width:n??r,height:i??r,fill:"none","aria-hidden":"true",focusable:"false",xmlns:"http://www.w3.org/2000/svg",ref:e,dangerouslySetInnerHTML:{__html:s}})});yk.displayName="VidstackIcon";var fe=A(X(),1);an();En();var WU=de(td),XR=fe.forwardRef(({children:t,...e},n)=>fe.createElement(WU,{...e},i=>fe.createElement(te.div,{...i,ref:ye(i.ref,n)},t)));XR.displayName="Controls";var KU=de(nd),ZR=fe.forwardRef(({children:t,...e},n)=>fe.createElement(KU,{...e},i=>fe.createElement(te.div,{...i,ref:ye(i.ref,n)},t)));ZR.displayName="ControlsGroup";var Ur=Object.freeze({__proto__:null,Group:ZR,Root:XR}),GU=de(pd);function YU({children:t,...e}){return fe.createElement(GU,{...e},t)}YU.displayName="Tooltip";var QU=de(hd),XU=fe.forwardRef(({children:t,...e},n)=>fe.createElement(QU,{...e},i=>fe.createElement(te.button,{...i,ref:ye(i.ref,n)},t)));XU.displayName="TooltipTrigger";var ZU=de(fd),JU=fe.forwardRef(({children:t,...e},n)=>fe.createElement(ZU,{...e},i=>fe.createElement(te.div,{...i,ref:ye(i.ref,n)},t)));JU.displayName="TooltipContent";var ej=de(ud,{domEventsRegex:/^onMedia/}),JR=fe.forwardRef(({children:t,...e},n)=>fe.createElement(ej,{...e},i=>fe.createElement(te.button,{...i,ref:ye(i.ref,n)},t)));JR.displayName="GoogleCastButton";var eI=fe.forwardRef(({children:t,...e},n)=>{let i=Oe("title");return fe.createElement(te.span,{...e,ref:n},i,t)});eI.displayName="Title";function tI(t){let[e,n]=fe.useState([]);return fe.useEffect(()=>{if(!t){n([]);return}function i(){n(t.activeCues)}return i(),L(t,"cue-change",i)},[t]),e}function nI(t){let e=sr(),[n,i]=fe.useState(null);return fe.useEffect(()=>xl(e.textTracks,t,i),[t]),n}function vg(){let t=nI("chapters");return tI(t)[0]?.text||""}var iI=fe.forwardRef(({children:t,...e},n)=>{let i=vg();return fe.createElement(te.span,{...e,ref:n},i,t)});iI.displayName="ChapterTitle";var tj=de(Md),wg=fe.forwardRef(({children:t,...e},n)=>fe.createElement(tj,{...e,ref:n},i=>fe.createElement(te.div,{...i},t)));wg.displayName="Captions";var TY=fe.forwardRef(({size:t=96,children:e,...n},i)=>fe.createElement("svg",{width:t,height:t,fill:"none",viewBox:"0 0 120 120","aria-hidden":"true","data-part":"root",...n,ref:i},e)),EY=fe.forwardRef(({width:t=8,children:e,...n},i)=>fe.createElement("circle",{cx:"60",cy:"60",r:"54",stroke:"currentColor",strokeWidth:t,"data-part":"track",...n,ref:i},e)),SY=fe.forwardRef(({width:t=8,fillPercent:e=50,children:n,...i},r)=>fe.createElement("circle",{cx:"60",cy:"60",r:"54",stroke:"currentColor",pathLength:"100",strokeWidth:t,strokeDasharray:100,strokeDashoffset:100-e,"data-part":"track-fill",...i,ref:r},n));var _g=A(X(),1);En();function bg(t){let e=sr(),n=_g.useRef();return n.current||(n.current=new hl),_g.useEffect(()=>{let i=t&&"current"in t?t.current:t,r=i instanceof Mo,s=r?i:e?.player;n.current.setPlayer(s??null),n.current.setTarget(i??null)},[e,t&&"current"in t?t.current:t]),n.current}var sQ=A(fu(),1);var ij=["onAbort","onAudioTrackChange","onAudioTracksChange","onAutoPlay","onAutoPlayChange","onAutoPlayFail","onCanLoad","onCanPlay","onCanPlayThrough","onControlsChange","onDestroy","onDurationChange","onEmptied","onEnd","onEnded","onError","onFindMediaPlayer","onFullscreenChange","onFullscreenError","onLiveChange","onLiveEdgeChange","onLoadedData","onLoadedMetadata","onLoadStart","onLoopChange","onOrientationChange","onPause","onPictureInPictureChange","onPictureInPictureError","onPlay","onPlayFail","onPlaying","onPlaysInlineChange","onPosterChange","onProgress","onProviderChange","onProviderLoaderChange","onProviderSetup","onQualitiesChange","onQualityChange","onRateChange","onReplay","onSeeked","onSeeking","onSourceChange","onSourceChange","onStalled","onStarted","onStreamTypeChange","onSuspend","onTextTrackChange","onTextTracksChange","onTimeUpdate","onTitleChange","onVdsLog","onVideoPresentationChange","onVolumeChange","onWaiting"],rj=de(Mo,{events:ij,eventsRegex:/^onHls/,domEventsRegex:/^onMedia/}),vk=Q.forwardRef(({aspectRatio:t,children:e,...n},i)=>Q.createElement(rj,{...n,src:n.src,ref:i,style:{aspectRatio:t,...n.style}},r=>Q.createElement(te.div,{...r},e)));vk.displayName="MediaPlayer";var sj=de(rg),wk=Q.forwardRef(({loaders:t=[],children:e,mediaProps:n,buildMediaEl:i,...r},s)=>{let o=Q.useMemo(()=>t.map(a=>new a),t);return Q.createElement(sj,{...r,loaders:o,ref:s},(a,l)=>Q.createElement("div",{...a},Q.createElement(oI,{...n,provider:l,buildMediaEl:i}),e))});wk.displayName="MediaProvider";function oI({provider:t,buildMediaEl:e,...n}){let{controls:i,crossOrigin:r,poster:s,remotePlaybackInfo:o}=ws($o),{loader:a}=t.$state,{$iosControls:l,$provider:c,$providerSetup:u}=sr(),d=Me(i),p=Me(l),h=d||p,m=Me(r),v=Me(s),w=Me(a),f=Me(c),g=Me(u),y=Me(o),T=w?.mediaType(),P=w?.name==="youtube",k=w?.name==="vimeo",M=P||k,I=w?.name==="remotion",O=w?.name==="google-cast",[b,ee]=Q.useState("");return Q.useEffect(()=>{!O||b||Promise.resolve().then(()=>(sI(),rI)).then(U=>{ee(U.default)})},[O]),O?Q.createElement("div",{className:"vds-google-cast",ref:U=>{t.load(U)}},Q.createElement(yk,{paths:b}),y?.deviceName?Q.createElement("span",{className:"vds-google-cast-info"},"Google Cast on"," ",Q.createElement("span",{className:"vds-google-cast-device-name"},y.deviceName)):null):I?Q.createElement("div",{"data-remotion-canvas":!0},Q.createElement("div",{"data-remotion-container":!0,ref:U=>{t.load(U)}},UR(f)&&g?Q.createElement(f.render):null)):e?.(w,t)??(M?Q.createElement(Q.Fragment,null,Q.createElement("iframe",{className:P?"vds-youtube":"vds-vimeo",suppressHydrationWarning:!0,tabIndex:h?void 0:-1,"aria-hidden":"true","data-no-controls":h?void 0:"",ref(U){t.load(U)}}),h?null:Q.createElement("div",{className:"vds-blocker"})):T?Q.createElement(T==="audio"?"audio":"video",{...n,controls:h?"true":null,crossOrigin:typeof m=="boolean"?"":m,poster:T==="video"&&h&&v?v:null,preload:"none","aria-hidden":"true",suppressHydrationWarning:!0,ref(U){t.load(U)}}):null)}oI.displayName="MediaOutlet";function oj(t){let e=sr(),n=Q.useMemo(()=>new zn(t),Object.values(t));return Q.useEffect(()=>(e.textTracks.add(n),()=>void e.textTracks.remove(n)),[n]),n}function _k({lang:t,...e}){return oj({language:t,...e}),null}_k.displayName="Track";var aj=de(sg),lj=Q.forwardRef(({children:t,...e},n)=>Q.createElement(aj,{...e},i=>Q.createElement(te.button,{...i,ref:ye(i.ref,n)},t)));lj.displayName="ToggleButton";var cj=de(og),uj=Q.forwardRef(({children:t,...e},n)=>Q.createElement(cj,{...e},(i,r)=>Q.createElement(aI,{...i,instance:r,ref:ye(i.ref,n)},t)));uj.displayName="Poster";var aI=Q.forwardRef(({instance:t,children:e,...n},i)=>{let{src:r,img:s,alt:o,crossOrigin:a}=t.$state,l=Me(r),c=Me(o),u=Me(a);return Q.createElement(te.img,{...n,src:l||"",alt:c||void 0,crossOrigin:u||void 0,ref:ye(s.set,i)},e)});aI.displayName="PosterImg";var dj=Q.forwardRef(({children:t,...e},n)=>Q.createElement(te.div,{translate:"yes","aria-live":"off","aria-atomic":"true",...e,ref:n},t));dj.displayName="Caption";var pj=Q.forwardRef((t,e)=>{let n=Oe("textTrack"),[i,r]=Q.useState();return Q.useEffect(()=>{if(!n)return;function s(){r(n?.activeCues[0])}return n.addEventListener("cue-change",s),()=>{n.removeEventListener("cue-change",s),r(void 0)}},[n]),Q.createElement(te.span,{...t,"data-part":"cue",dangerouslySetInnerHTML:{__html:i?.text||""},ref:e})});pj.displayName="CaptionText";function lI(){let[t,e]=Q.useState(null),n=sr();return Q.useEffect(()=>{if(n)return S(()=>{e(n.$provider())})},[]),t}function cI({clamp:t=!1,offset:e=0,orientation:n="horizontal"}={}){let[i,r]=Q.useState(null),[s,o]=Q.useState(null),[a,l]=Q.useState(0),[c,u]=Q.useState(!1);return Q.useEffect(()=>{if(!i)return;let d=K(!1);function p(h){i&&l(hj(i,h,n))}return S(()=>{if(!d()){L(i,"pointerenter",()=>{u(!0),s?.setAttribute("data-visible","")}),L(i,"pointerdown",h=>{d.set(!0),p(h)}),L(i,"pointerleave",()=>{u(!1),s?.removeAttribute("data-visible")}),L(i,"pointermove",h=>{p(h)});return}s?.setAttribute("data-dragging",""),L(document,"pointerup",h=>{d.set(!1),s?.removeAttribute("data-dragging"),p(h)}),L(document,"pointermove",h=>{p(h)}),L(document,"touchmove",h=>h.preventDefault(),{passive:!1})})},[i]),Q.useEffect(()=>{s&&s.style.setProperty("--slider-pointer",a+"%")},[s,a]),Q.useEffect(()=>{if(!s)return;let d=()=>{ak(s,{offset:e,clamp:t,orientation:n})};d();let p=new ResizeObserver(d);return p.observe(s),()=>p.disconnect()},[s,t,e,n]),{previewRootRef:r,previewRef:o,previewValue:a,isPreviewVisible:c}}function hj(t,e,n){let i,r=t.getBoundingClientRect();if(n==="vertical"){let{bottom:s,height:o}=r;i=(s-e.clientY)/o}else{let{left:s,width:o}=r;i=(e.clientX-s)/o}return fj(Math.max(0,Math.min(100,100*i)))}function fj(t){return Number(t.toFixed(3))}var uI='"use strict";var X=()=>({emit(e,...t){for(let n=0,r=this.events[e]||[],i=r.length;n{this.events[e]=this.events[e]?.filter(n=>t!==n)}}});function Z(){let e=X();return e.once=function(n,r){let i=this.on(n,(...s)=>{i(),r(...s)});return i},e}function ee(e){let t=e;return typeof t.id=="string"&&typeof t.invoke=="string"}function te(e,...t){return{id:Ce(),invoke:e,args:t}}function ne(e){return typeof e.id=="string"}function re(e){return typeof e.send=="string"}function ie(e,t){return{send:e,payload:t}}function Ce(){return Math.random().toString(36).substring(2,9)}var k=class extends Error{constructor(t){super(`no handler for ${t}`)}},N="mx-port-ready";var R=class{port=null;load(t){this.port&&this.port.close(),this.port=t;let n=({data:r})=>{this.onMessage(r)};t.addEventListener("message",n),t.start(),t.postMessage(N)}unload(){this.port?.close(),this.emitter.events={}}actions=Object.create(null);emitter=Z();onMessage(t){t===N?this.emitter.emit("ready"):ee(t)?this.response(t):ne(t)?this.emitter.emit("resp",t.id,t.payload,t.error):re(t)&&this.emitter.emit(`send:${t.send}`,{type:t.send,payload:t.payload})}methods=new Proxy({},{get:(t,n)=>{if(typeof n=="symbol")throw new Error("Remote invoke does not support symbol property");return t[n]??=(...r)=>this.invoke(n.toString(),r)}});invoke(t,n,{transfer:r,timeout:i=1e3}={}){if(!this.port)throw new Error("port not loaded");let s=te(t,...n);return this.port.postMessage(s,{transfer:r}),new Promise((o,a)=>{let l=-1,u=this.emitter.on("resp",(c,p,y)=>{if(c===s.id)if(u(),window.clearTimeout(l),y){let{message:K,stack:z}=y,S=new Error(K);S.stack=z,a(S)}else o(p)});i>0&&i<1/0&&(l=window.setTimeout(()=>{u(),a(new M(i))},i))})}handle(t,n){this.actions[t]=n}send(t,n,r){if(!this.port)throw new Error("port not loaded");let i=ie(t,n);this.port.postMessage(i,{transfer:r})}on(t,n){return this.emitter.on(`send:${t}`,n)}once(t,n){return this.emitter.once(`send:${t}`,n)}onReady(t,{once:n=!1}={}){return n?this.emitter.once("ready",t):this.emitter.on("ready",t)}async response({id:t,invoke:n,args:r=[]}){if(!this.port)throw new Error("port not loaded");let i={id:t,payload:null};try{let s=this.actions[n];if(!s)throw new k(n);let o=await s(...r);o===void 0?this.port.postMessage(i):(i.payload=await o.value,this.port.postMessage(i,{transfer:o.transfer}))}catch(s){s instanceof Error?i.error={message:s.message,stack:s.stack}:i.error={message:String(s)},this.port.postMessage(i)}}},M=class extends Error{constructor(t){super(`timeout after ${t}ms`)}};var se="mx-port";async function q(){let e=await new Promise((n,r)=>{function i({data:o,ports:a}){o===se&&(n(a[0]),window.removeEventListener("message",i),window.clearTimeout(s))}window.addEventListener("message",i);let s=setTimeout(()=>{r("failed to get port: timeout "+5e3),window.removeEventListener("message",i)},5e3)}),t=new R;return t.load(e),t}var A=class{#e=[];#t=!1;async load(){if(!this.#t){this.#t=!0,await this.onload();for(let t of this.#n)await t.load()}}async onload(){}async unload(){if(!this.#t)return;this.#t=!1;let t;for(;t=this.#e.pop();)await t();let n;for(;n=this.#n.pop();)await n.unload();await this.onunload()}async onunload(){}register(t){this.#e.push(t)}registerInterval(t,n){let r=setInterval(t,n);this.register(()=>clearInterval(r))}registerDomEvent(t,n,r,i){t.addEventListener(n,r,i),this.register(()=>t.removeEventListener(n,r,i))}#n=[];async addChild(t){return this.#n.push(t),this.#t&&await t.load(),t}async removeChild(t){let n=this.#n.indexOf(t);return n!==-1&&(this.#n.splice(n,1),t.unload()),t}};function d(e){let t=[];for(let n=0;nn.send("enterpictureinpicture",void 0)),e.registerDomEvent(t,"leavepictureinpicture",()=>n.send("leavepictureinpicture",void 0)));function r(){n.send("abort",void 0)}function i(){n.send("emptied",void 0)}function s(){t.error&&n.send("error",{code:t.error.code,message:t.error.message})}function o(){n.send("volumechange",{muted:t.muted,volume:t.volume})}function a(){n.send("durationchange",{played:d(t.played),duration:t.duration})}function l(){n.send("progress",{buffered:d(t.buffered),seekable:d(t.seekable)})}function u(){n.send("stalled",{readyState:t.readyState})}function c(){n.send("suspend",void 0)}function p(){n.send("ratechange",{rate:t.playbackRate})}function y(){n.send("seeked",{current:t.currentTime,played:d(t.played),duration:t.duration,ended:t.ended})}function K(){n.send("seeking",{current:t.currentTime})}function z(){n.send("ended",{controls:t.controls,current:t.currentTime,played:d(t.played),duration:t.duration,ended:t.ended})}function S(){n.send("waiting",{readyState:t.readyState})}}var U=class{value;next;constructor(t){this.value=t}},T=class{#e;#t;#n;constructor(){this.clear()}enqueue(t){let n=new U(t);this.#e?(this.#t.next=n,this.#t=n):(this.#e=n,this.#t=n),this.#n++}dequeue(){let t=this.#e;if(t)return this.#e=this.#e.next,this.#n--,t.value}clear(){this.#e=void 0,this.#t=void 0,this.#n=0}get size(){return this.#n}*[Symbol.iterator](){let t=this.#e;for(;t;)yield t.value,t=t.next}};var le={bind(e,t,n){return e.bind(n)}};function F(e){if(!((Number.isInteger(e)||e===Number.POSITIVE_INFINITY)&&e>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");let t=new T,n=0,r=()=>{n--,t.size>0&&t.dequeue()()},i=async(a,l,u)=>{n++;let c=(async()=>a(...u))();l(c);try{await c}catch{}r()},s=(a,l,u)=>{t.enqueue(le.bind(i.bind(void 0,a,l,u))),(async()=>(await Promise.resolve(),n0&&t.dequeue()()))()},o=(a,...l)=>new Promise(u=>{s(a,u,l)});return Object.defineProperties(o,{activeCount:{get:()=>n},pendingCount:{get:()=>t.size},clearQueue:{value(){t.clear()}}}),o}async function ue(e,t,n){let r=document.createElement("canvas"),{videoWidth:i,videoHeight:s}=e;if(!i||!s)throw new Error("Cannot screenshot video without width or height");Object.assign(r,{width:i,height:s});let o=r.getContext("2d",{alpha:!1});if(!o)throw new Error("Canvas context creation failed");o.drawImage(e,0,0,i,s);let a=await new Promise((u,c)=>{try{r.toBlob(p=>{p?u(p):c(new Error("Canvas to blob failed"))},t,n)}catch(p){c(p)}}),l=await a.arrayBuffer();return{time:e.currentTime,blob:{arrayBuffer:l,type:a.type}}}var de=["currentTime","playbackRate","volume","muted"],ce=["paused","played","networkState","duration","buffered","seekable","readyState","ended","autoplay","error"],me=["play","pause"],fe="mx-mounted";function x(e){return e[0].toUpperCase()+e.slice(1)}function W(e){return e instanceof TimeRanges?d(e):e}function pe(){let e=this.media,t=this.controller,n=this.stateRef;ce.forEach(i=>{t.handle(`get${x(i)}`,()=>({value:W(e[i])}))}),t.handle("pictureInPictureEnabled",()=>({value:document.pictureInPictureElement===e})),t.handle("requestPictureInPicture",()=>{e instanceof HTMLVideoElement&&e.requestPictureInPicture()}),t.handle("exitPictureInPicture",()=>{document.exitPictureInPicture()}),de.forEach(i=>{t.handle(`get${x(i)}`,()=>({value:W(e[i])})),i==="currentTime"?t.handle(`set${x(i)}`,s=>{n.prevSeek={value:e.currentTime,time:Date.now()},e[i]=s}):t.handle(`set${x(i)}`,s=>{e[i]=s})}),me.forEach(i=>{t.handle(i,async(...s)=>({value:await e[i](...s)}))}),t.handle("screenshot",async(i,s)=>{if(!(e instanceof HTMLVideoElement))throw new Error("Cannot take screenshot of non-video element");let o=await ue(e,i,s);return{value:o,transfer:[o.blob.arrayBuffer]}});let r=F(4);return t.handle("fetch",async(i,{gzip:s=!1,...o}={})=>{let a=await r(()=>window.fetch(i,o)),l=await a.blob(),u={type:l.type,respHeaders:Object.fromEntries(a.headers)};if(!s){let y=await l.arrayBuffer();return{value:{ab:y,gzip:!1,...u},transfer:[y]}}let c=l.stream(),p=await De(c.pipeThrough(new CompressionStream("gzip")));return{value:{ab:p,gzip:!0,...u},transfer:[p]}}),n}async function De(e){let t=e.getReader(),n=[];for(;;){let{done:s,value:o}=await t.read();if(s)break;n.push(o)}let r=n.reduce((s,o)=>s+o.byteLength,0),i=new Uint8Array(r);for(let s=0,o=0;s=0&&o(),t.readyState>=1&&a(),t.readyState>=2&&l(),t.readyState>=3&&u(),t.readyState>=4&&c(),e.registerDomEvent(t,"play",s),e.registerDomEvent(t,"pause",r),e.registerDomEvent(t,"playing",i),t.readyState>=3&&!t.paused?(s(),i()):r();function r(){n.send("pause",{readyState:t.readyState})}function i(){n.send("playing",void 0)}function s(){n.send("play",void 0)}function o(){n.send("loadstart",{networkState:t.networkState})}function a(){n.send("loadedmetadata",void 0)}function l(){n.send("loadeddata",void 0)}function u(){n.send("canplay",{buffered:d(t.buffered),seekable:d(t.seekable),duration:t.duration})}function c(){n.send("canplaythrough",{buffered:d(t.buffered),seekable:d(t.seekable),duration:t.duration})}}var g=Symbol(0),C=!1,he=!1,$=null,b=null,f=null,m=0,E=[],j={};var w=0,we=1,P=2,B=3;function Ie(){C=!0,queueMicrotask(Oe)}function Oe(){if(!E.length){C=!1;return}he=!0;for(let e=0;e=0;n--)J(t[n])}function G(e=!0){if(this.$st===B)return;let t=e?this.$ps||this[g]:this,n=this.$ns,r=null;for(;n&&n[g]===this;)G.call(n,!0),ye(n),r=n.$ns,n.$ns=null,n=r;e&&ye(this),n&&(n.$ps=e?this.$ps:this),t&&(t.$ns=n)}function ye(e){e.$st=B,e.$d&&Me(e),e.$s&&L(e,0),e.$ps&&(e.$ps.$ns=null),e[g]=null,e.$s=null,e.$o=null,e.$ps=null,e.$cx=j,e.$eh=null}function Me(e){try{if(Array.isArray(e.$d))for(let t=e.$d.length-1;t>=0;t--){let n=e.$d[t];n.call(n)}else e.$d.call(e.$d);e.$d=null}catch(t){Te(e,t)}}function _e(e,t,n){let r=$,i=b;$=e,b=n;try{return t.call(e)}finally{$=r,b=i}}function Te(e,t){if(!e||!e.$eh)throw t;let n=0,r=e.$eh.length,i=ve(t);for(n=0;n0){e.$s.length=m+f.length;for(let s=0;s=t)&&(e.$e&&e.$st===w&&(E.push(e),C||Ie()),e.$st=t,e.$o))for(let n=0;n"u"}function Q(e){return typeof e=="number"&&!Number.isNaN(e)}var be,We=Event,Se=Symbol("DOM_EVENT"),V=class extends We{constructor(t,...n){super(t,n[0]),this[be]=!0,this.triggers=new D,this.detail=n[0]?.detail;let r=n[0]?.trigger;r&&this.triggers.add(r)}static{be=Se}get trigger(){return this.triggers.source}get originEvent(){return this.triggers.origin}get isOriginTrusted(){return this.triggers.origin?.isTrusted??!1}},D=class{constructor(){this.chain=[]}get source(){return this.chain[0]}get origin(){return this.chain[this.chain.length-1]}add(t){this.chain.push(t),ke(t)&&this.chain.push(...t.triggers)}remove(t){return this.chain.splice(this.chain.indexOf(t),1)[0]}has(t){return this.chain.some(n=>n===t)}hasType(t){return!!this.findType(t)}findType(t){return this.chain.find(n=>n.type===t)}walk(t){for(let n of this.chain){let r=t(n);if(r)return[n,r]}}[Symbol.iterator](){return this.chain.values()}};function ke(e){return!!e?.[Se]}var dn=typeof window<"u"?"requestIdleCallback"in window?window.requestIdleCallback:e=>window.setTimeout(e,1):Pe;var O=class{constructor(t){this._callback=t}_id;_start(){I(this._id)&&this._loop()}_stop(){Q(this._id)&&window.cancelAnimationFrame(this._id),this._id=void 0}_loop(){this._id=window.requestAnimationFrame(()=>{I(this._id)||(this._callback(),this._loop())})}};function Re(e){let t=e.media,n=e.controller,r=new O(a);e.register(()=>r._stop());let i,s=t.currentTime;function o(){i!==t.paused&&(i=t.paused,t.paused?t.addEventListener("timeupdate",a):t.removeEventListener("timeupdate",a))}o(),t.addEventListener("ended",()=>{r._stop(),o()}),t.addEventListener("pause",()=>{r._stop(),o()}),t.addEventListener("playing",()=>{r._start(),o()});function a(){s!==t.currentTime&&(s=t.currentTime,n.send("timeupdate",{current:s,played:d(t.played)}))}}function H(e,t=document.body,n=1e4){return new Promise((r,i)=>{let s=t.querySelector(e);if(s){r(s);return}let o=new MutationObserver(()=>{let l=t.querySelector(e);l&&(o.disconnect(),r(l),window.clearTimeout(a))}),a=window.setTimeout(()=>{o.disconnect(),i(new Error(`timeout waiting for ${e}`))},n);o.observe(t,{childList:!0,subtree:!0})})}var Ve=[".dplayer",".video-js",".jwplayer","[data-player]"],h=class extends A{constructor(n){super();this.controller=n;this.register(()=>n.unload())}getStyle(){return Ge}#e=null;stateRef={prevSeek:null};findMedia(){return H("video, audio")}async load(){let n=this.getStyle();n&&this.injectStyle(n),await super.load();let r=this.media.controls===!0;r&&(this.media.controls=!1),this.register(this.controller.on("mx-toggle-controls",({payload:i})=>{document.body.classList.toggle("mx-show-controls",i)})),r&&this.register(this.controller.on("mx-toggle-controls",({payload:i})=>{this.media.controls=i})),this.register(this.controller.on("mx-toggle-webfs",({payload:i})=>{document.body.classList.toggle("mx-fs-enable",i)})),document.body.classList.add("mx-play-ready"),this.controller.send("mx-play-ready",void 0)}get media(){if(!this.#e)throw new Error("Get media before load");return this.#e}async onload(){this.#e=await this.findMedia(),await Promise.all([this.enterWebFullscreen(),this.hookMediaEl()])}enterWebFullscreen(){document.body.classList.add("mx-fs-enable");let n=this.media.closest(Ve.join(", "))??this.media;n.classList.add("mx-player"),this.assignParentClass(n),window.dispatchEvent(new Event("resize"))}assignParentClass(n){for(let r of je(n))r.classList.add("mx-parent"),getComputedStyle(r).position=="fixed"&&r.classList.add("mx-absolute")}injectStyle(n){let r=document.createElement("style");r.textContent=n,document.head.appendChild(r),this.register(()=>r.remove())}async untilMediaReady(n="canplay",r=5e3){if(this.media.readyState>=Be[n])return;let i=-1;await new Promise((s,o)=>{this.registerDomEvent(this.media,n,s,{once:!0}),i=window.setTimeout(()=>{o(new M(r))},r)}),window.clearTimeout(i)}rehookMediaEl(n){this.#e=n,this.hookMediaEl()}async hookMediaEl(){ge(this),Re(this),ae(this),pe.call(this),this.controller.send(fe,void 0)}};function*je(e,t=!1){for(t&&(yield e);e.parentElement&&e.parentElement!==document.body;)e=e.parentElement,yield e}var Be={loadedmetadata:HTMLMediaElement.HAVE_METADATA,loadeddata:HTMLMediaElement.HAVE_CURRENT_DATA,canplay:HTMLMediaElement.HAVE_FUTURE_DATA,canplaythrough:HTMLMediaElement.HAVE_ENOUGH_DATA},Ge=`\nbody.mx-fs-enable .mx-player {\n position: fixed !important;\n top: 0 !important;\n left: 0 !important;\n width: 100vw !important;\n height: 100vh !important;\n max-width: none !important;\n max-height: none !important;\n min-width: 0 !important;\n min-height: 0 !important;\n margin: 0 !important;\n padding: 0 !important;\n z-index: 2147483647 !important; /* Ensure it\'s on top of other elements */\n background-color: #000 !important;\n transform: none !important;\n}\nbody.mx-fs-enable .mx-parent {\n overflow: visible !important;\n z-index: auto !important;\n transform: none !important;\n -webkit-transform-style: flat !important;\n transition: none !important;\n contain: none !important;\n}\nbody.mx-fs-enable .mx-absolute {\n position: absolute !important;\n}\nbody.mx-fs-enable {\n overflow: hidden !important;\n zoom: 100% !important;\n}\nbody.mx-fs-enable .mx-parent video {\n object-fit: contain !important;\n}\n`.trim();var Ye={waitForSelector:H,MediaPlugin:h},Ae=(e=>function(n){if(n in e)return e[n];throw new Error(`Module not found: ${n.toString()}`)})({"media-extended":Ye});async function Le(e,t){if(!e)return new h(t);let n=window.eval(`(function anonymous(require,module,exports){${e}\n})`),r={},i={exports:r};n(Ae,i,r),r=i.exports||r;let s=r.default||i.exports;if(!s)throw new Error("Failed to load plugin. No exports detected.");let o=new s(t);if(!(o instanceof h))throw new Error("Failed to load plugin. plugin not extends MediaPlugin");return o}var _;q().then(e=>{e.handle("loadPlugin",async t=>{_&&_.unload(),_=await Le(t,e),_.load()})});\n';var jr=Symbol(0),kg=!1,dI=!1,Ro=null,El=null,fi=null,qn=0,Tl=[],xk={},gj=()=>{},Sl=0,gI=1,Fd=2,Eg=3;function yj(){kg=!0,queueMicrotask(vj)}function vj(){if(!Tl.length){kg=!1;return}dI=!0;for(let t=0;t=0;n--)Ek(e[n])}function yI(t){if(!t||!Ro)return t||gj;let e=Ro;return e.$d?Array.isArray(e.$d)?e.$d.push(t):e.$d=[e.$d,t]:e.$d=t,function(){e.$st!==Eg&&(t.call(null),bI(e.$d)?e.$d=null:Array.isArray(e.$d)&&e.$d.splice(e.$d.indexOf(t),1))}}function kk(t=!0){if(this.$st===Eg)return;let e=t?this.$ps||this[jr]:this,n=this.$ns,i=null;for(;n&&n[jr]===this;)kk.call(n,!0),pI(n),i=n.$ns,n.$ns=null,n=i;t&&pI(this),n&&(n.$ps=t?this.$ps:this),e&&(e.$ns=n)}function pI(t){t.$st=Eg,t.$d&&vI(t),t.$s&&xg(t,0),t.$ps&&(t.$ps.$ns=null),t[jr]=null,t.$s=null,t.$o=null,t.$ps=null,t.$cx=xk,t.$eh=null}function vI(t){try{if(Array.isArray(t.$d))for(let e=t.$d.length-1;e>=0;e--){let n=t.$d[e];n.call(n)}else t.$d.call(t.$d);t.$d=null}catch(e){wI(t,e)}}function _j(t,e,n){let i=Ro,r=El;Ro=t,El=n;try{return e.call(t)}finally{Ro=i,El=r}}function wI(t,e){if(!t||!t.$eh)throw e;let n=0,i=t.$eh.length,r=hI(e);for(n=0;n0){t.$s.length=qn+fi.length;for(let s=0;s=e)&&(t.$e&&t.$st===Sl&&(Tl.push(t),kg||yj()),t.$st=e,t.$o))for(let n=0;nn===e)}hasType(e){return!!this.findType(e)}findType(e){return this.chain.find(n=>n.type===e)}walk(e){for(let n of this.chain){let i=e(n);if(i)return[n,i]}}[Symbol.iterator](){return this.chain.values()}};function EI(t){return!!t?.[TI]}function Pj(){let t=new Set;return{add(...e){for(let n of e)t.add(n)},empty(){for(let e of t)e();t.clear()}}}function SI(){let t=Pj();return yI(t.empty),t}var YQ=typeof window<"u"?"requestIdleCallback"in window?window.requestIdleCallback:t=>window.setTimeout(t,1):kI;var $s=require("obsidian");var PI=`"use strict";var s=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var y=(r,e)=>{for(var t in e)s(r,t,{get:e[t],enumerable:!0})},b=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of p(e))!m.call(r,n)&&n!==t&&s(r,n,{get:()=>e[n],enumerable:!(i=d(e,n))||i.enumerable});return r};var f=r=>b(s({},"__esModule",{value:!0}),r);var k={};y(k,{default:()=>o});module.exports=f(k);var c=()=>require("media-extended");var{waitForSelector:l,MediaPlugin:h}=c(),w=\` #bilibili-player .bpx-player-control-wrap { opacity: 0 !important; } .mx-show-controls #bilibili-player .bpx-player-control-wrap { opacity: 100 !important; } \`,o=class extends h{findMedia(){return l("#bilibili-player video")}getStyle(){return w}async onload(){this.controller.handle("bili_getManifest",()=>({value:window.player.getManifest()})),localStorage.setItem("recommend_auto_play","close"),localStorage.setItem("bpx_player_profile",JSON.stringify({media:{autoplay:!1}})),await super.onload(),this.revertAutoSeek(),Promise.all([this.toggleDanmaku(!1)]),await this.untilWebFullscreen()}get player(){return this.media.closest("#bilibili-player")}async toggleDanmaku(e){if(window.player){e===void 0&&(e=!window.player.danmaku.isOpen()),e?window.player.danmaku.open():window.player.danmaku.close();return}let t=await l(".bui-danmaku-switch",this.player);if(!t)return;let i=t.querySelector("input.bui-danmaku-switch-input");if(i){if(e===void 0){i.click();return}e!==this.isDanmakuOn(t)&&i.click()}}isDanmakuOn(e){return e.querySelector(".bui-danmaku-switch-off")?.offsetHeight===0}isWebFullscreen(){return this.player.classList.contains("mode-webscreen")}enterWebFullscreen(){this.isWebFullscreen()||l(".bpx-player-ctrl-web",this.player).then(e=>{e.click()})}revertAutoSeek(){let t=this.player.querySelector(".bpx-player-toast-auto");if(!t)return;let i=()=>{this.stateRef.prevSeek&&this.stateRef.prevSeek.time>Date.now()-5e3?this.media.currentTime=this.stateRef.prevSeek.value:this.media.currentTime=0},n=new MutationObserver(u=>{u.find(a=>a.type==="childList"&&a.addedNodes.length>0)?.addedNodes.forEach(a=>{a.textContent?.includes("\\u5DF2\\u4E3A\\u60A8\\u5B9A\\u4F4D\\u81F3")&&(a.style.opacity="0",i())})});n.observe(t,{childList:!0,subtree:!0}),this.register(()=>n.disconnect())}async untilWebFullscreen(){let e=this.player;this.isWebFullscreen()||await new Promise(t=>{let i=new MutationObserver(n=>{n.find(a=>a.type==="attributes"&&a.attributeName==="class"&&e?.classList.contains("mode-webscreen"))&&(i.disconnect(),t(void 0))});i.observe(e,{attributes:!0}),setTimeout(()=>{i.disconnect(),t(void 0)},6e3)})}}; `;var CI=`"use strict";var a=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var u=(r,e)=>{for(var o in e)a(r,o,{get:e[o],enumerable:!0})},m=(r,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of p(e))!d.call(r,t)&&t!==o&&a(r,t,{get:()=>e[t],enumerable:!(s=l(e,t))||s.enumerable});return r};var c=r=>m(a({},"__esModule",{value:!0}),r);var b={};u(b,{default:()=>i});module.exports=c(b);var n=()=>require("media-extended");var y=\` body:not(.mx-show-controls) .vp-player-ui-overlays { opacity: 0 !important; } \`,{waitForSelector:x,MediaPlugin:M}=n(),i=class extends M{findMedia(){return x("#main [data-player] .vp-video video")}getStyle(){return super.getStyle()+\` \`+y}}; `;var MI=`"use strict";var d=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var y=(o,t)=>{for(var e in t)d(o,e,{get:t[e],enumerable:!0})},b=(o,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of u(t))!h.call(o,i)&&i!==e&&d(o,i,{get:()=>t[i],enumerable:!(n=p(t,i))||n.enumerable});return o};var g=o=>b(d({},"__esModule",{value:!0}),o);var x={};y(x,{default:()=>l});module.exports=g(x);var a=()=>require("media-extended");var v=\` body:not(.mx-player-ready) #movie_player, ytd-watch-flexy[theater] #movie_player { position: fixed !important; top: 0 !important; left: 0 !important; width: 100vw !important; height: 100vh !important; max-width: none !important; max-height: none !important; min-width: 0 !important; min-height: 0 !important; margin: 0 !important; padding: 0 !important; z-index: 2147483647 !important; /* Ensure it's on top of other elements */ background-color: #000 !important; transform: none !important; } .mx-parent { overflow: visible !important; z-index: auto !important; transform: none !important; -webkit-transform-style: flat !important; transition: none !important; contain: none !important; } .mx-absolute { position: absolute !important; } html, body { overflow: hidden !important; zoom: 100% !important; } .mx-parent video { object-fit: contain !important; } ytd-app .html5-endscreen { opacity: 0 !important; } body:not(.mx-show-controls) ytd-app .ytp-chrome-bottom { opacity: 0 !important; } \`.trim(),w=\` /* \\u9996\\u9875\\u9876\\u90E8\\u6A2A\\u5E45\\u5E7F\\u544A */ #masthead-ad, /* \\u9996\\u9875\\u89C6\\u9891\\u6392\\u7248\\u5E7F\\u544A */ ytd-rich-item-renderer.style-scope.ytd-rich-grid-row #content:has(.ytd-display-ad-renderer), /* \\u64AD\\u653E\\u5668\\u5E95\\u90E8\\u5E7F\\u544A */ .video-ads.ytp-ad-module, /* \\u64AD\\u653E\\u9875\\u4F1A\\u5458\\u4FC3\\u9500\\u5E7F\\u544A */ tp-yt-paper-dialog:has(yt-mealbar-promo-renderer), /* \\u64AD\\u653E\\u9875\\u53F3\\u4E0A\\u65B9\\u63A8\\u8350\\u5E7F\\u544A */ ytd-engagement-panel-section-list-renderer[target-id="engagement-panel-ads"], /* \\u64AD\\u653E\\u9875\\u8BC4\\u8BBA\\u533A\\u53F3\\u4FA7\\u63A8\\u5E7F\\u5E7F\\u544A */ #related #player-ads, /* \\u64AD\\u653E\\u9875\\u8BC4\\u8BBA\\u533A\\u53F3\\u4FA7\\u89C6\\u9891\\u6392\\u7248\\u5E7F\\u544A */ #related ytd-ad-slot-renderer, /* \\u641C\\u7D22\\u9875\\u5E7F\\u544A */ ytd-ad-slot-renderer, /* \\u64AD\\u653E\\u9875\\u4F1A\\u5458\\u63A8\\u8350\\u5E7F\\u544A */ yt-mealbar-promo-renderer, /* M\\u64AD\\u653E\\u9875\\u7B2C\\u4E09\\u65B9\\u63A8\\u8350\\u5E7F */ ad-slot-renderer, /* M\\u53EF\\u8DF3\\u8FC7\\u7684\\u89C6\\u9891\\u5E7F\\u544A\\u94FE\\u63A5 */ ytm-companion-ad-renderer { opacity: 0 !important; } \`.trim(),{waitForSelector:s,MediaPlugin:f}=a(),r=class extends f{async findMedia(){let t=await s("ytd-app #movie_player video");if(this.app=t.closest("ytd-app"),this.moviePlayer=t.closest("#movie_player"),!this.app||!this.moviePlayer)throw new Error("Failed to find media");return this.watchIfDetached(),t}watchIfDetached(){let t=this.moviePlayer,e=new MutationObserver(async()=>{if(this.media.isConnected)return;let n=await this.findMedia();n&&this.rehookMediaEl(n)});e.observe(t,{childList:!0,subtree:!0}),this.register(()=>e.disconnect())}getStyle(){return v+\` \`+w}async onload(){await super.onload(),this.disableAutoPlay(),s("ytd-consent-bump-v2-lightbox",this.app).then(()=>{this.controller.send("mx-open-browser",{message:"Seems like YouTube is showing a consent popup that block playback. To continue playback, you should handle it in dedicated login browser. ",url:"https://youtube.com"})})}app;moviePlayer;async disableAutoPlay(){let e=await s('button.ytp-button[data-tooltip-target-id="ytp-autonav-toggle-button"]',this.app);if(!e)throw new Error("Autoplay button not found");let n=e.querySelector(".ytp-autonav-toggle-button");if(!n)throw new Error("Autoplay button label not found");let i=()=>n.getAttribute("aria-checked")==="true";i()&&(e.click(),await new Promise(m=>{let c=new MutationObserver(()=>{i()||(c.disconnect(),m())});c.observe(n,{attributes:!0})}))}enterWebFullscreen(){this.assignParentClass(this.moviePlayer),(async()=>{let t=await s("#movie_player .ytp-size-button"),e=()=>!!this.app.querySelector("ytd-watch-flexy[theater]");if(!e())do t.click(),await E(200);while(!e());window.dispatchEvent(new Event("resize"))})()}};function E(o){return new Promise(t=>setTimeout(t,o))}var{waitForSelector:M}=a(),l=class extends r{async onload(){await super.onload(),M(".video-ads.ytp-ad-module",this.app).then(t=>this.removePlayerAD(t))}removePlayerAD(t){let e=new MutationObserver(()=>this.skipAd());this.registerInterval(()=>this.skipAd(),500),e.observe(t,{childList:!0,subtree:!0})}skipAd(){let t=this.media,e=this.moviePlayer.querySelector(".ytp-ad-skip-button")||this.moviePlayer.querySelector(".ytp-ad-skip-button-modern"),n=this.moviePlayer.querySelector(".video-ads.ytp-ad-module .ytp-ad-player-overlay");if(t)if(e){if(window.location.href.indexOf("https://m.youtube.com/")===-1&&(t.muted=!0),t.currentTime>.5){t.currentTime=t.duration;return}e.click(),T.call(e)}else n&&(t.currentTime=t.duration)}};function T(){let o=new Touch({identifier:Date.now(),target:this,clientX:12,clientY:34,radiusX:56,radiusY:78,rotationAngle:0,force:1}),t=new TouchEvent("touchstart",{bubbles:!0,cancelable:!0,view:window,touches:[o],targetTouches:[o],changedTouches:[o]});this.dispatchEvent(t);let e=new TouchEvent("touchend",{bubbles:!0,cancelable:!0,view:window,touches:[],targetTouches:[],changedTouches:[o]});this.dispatchEvent(e)} `;var $I={bilibili:PI,youtube:MI,vimeo:CI,coursera:void 0,generic:void 0};var RI={generic:t=>t,bilibili:t=>t.replaceAll(/[-_]哔哩哔哩.+$|[-_]bilibili.+$|-(?:番剧|电影|纪录片|国创|电视剧|综艺)-.+/g,""),youtube:t=>t.replace(/^\(\d+\) /,"").replace(/ - YouTube$/,""),vimeo:t=>t.replace(/ on Vimeo$/,""),coursera:t=>t.replace(/ \| Coursera$/,"")};function II(t){return`webpage::${btoa(t)}`}function LI(t){return atob(t.replace(/^webpage::/,""))}function AI(t){return typeof t=="string"&&t.startsWith("webpage::")}function DI(t){return t.type==="TimeRanges"}var Sg=class{constructor(e){this.ranges=e}get length(){return this.ranges.length}start(e){return this.ranges[e][0]}end(e){return this.ranges[e][1]}};function Di(t){return DI(t)?new Sg(t.value):t}var{onDispose:Sk,peek:Rj}=bs,Pg=class{constructor(e,n){this._provider=e;this._ctx=n;E(this,"_disposal",SI());E(this,"_waiting",!1);E(this,"_attachedLoadStart",!1);E(this,"_attachedCanPlay",!1);E(this,"_handlers");E(this,"_handleDevEvent");this._attachInitialListeners(),Sk(this._media.on("timeupdate",this._onTimeUpdate.bind(this))),Sk(this._onDispose.bind(this))}get _webview(){return this._provider.webview}get _media(){return this._provider.media}get _notify(){return this._ctx.delegate._notify}_onDispose(){this._attachedLoadStart=!1,this._attachedCanPlay=!1,this._disposal.empty()}_attachInitialListeners(){this._attachEventListener("loadstart",this._onLoadStart),this._attachEventListener("abort",this._onAbort),this._attachEventListener("emptied",this._onEmptied),this._attachEventListener("error",this._onError),this._attachEventListener("volumechange",this._onVolumeChange)}_attachLoadStartListeners(){this._attachedLoadStart||(this._disposal.add(this._attachEventListener("loadeddata",this._onLoadedData),this._attachEventListener("loadedmetadata",this._onLoadedMetadata),this._attachEventListener("canplay",this._onCanPlay),this._attachEventListener("canplaythrough",this._onCanPlayThrough),this._attachEventListener("durationchange",this._onDurationChange),this._attachEventListener("play",this._onPlay),this._attachEventListener("progress",this._onProgress),this._attachEventListener("stalled",this._onStalled),this._attachEventListener("suspend",this._onSuspend)),this._attachedLoadStart=!0)}_attachCanPlayListeners(){this._attachedCanPlay||(this._disposal.add(this._attachEventListener("pause",this._onPause),this._attachEventListener("playing",this._onPlaying),this._attachEventListener("ratechange",this._onRateChange),this._attachEventListener("seeked",this._onSeeked),this._attachEventListener("seeking",this._onSeeking),this._attachEventListener("ended",this._onEnded),this._attachEventListener("waiting",this._onWaiting)),this._attachedCanPlay=!0)}_attachEventListener(e,n){let i=n.bind(this),r=this._media.on(e,i);return Sk(r)}_onDevEvent(e){}_updateCurrentTime(e,n,i){let r={currentTime:Math.min(e,this._ctx.$state.seekableEnd()),played:n};this._notify("time-update",r,i&&new Event(i.type))}_onLoadStart(e){if(e.payload.networkState===3){this._onAbort(e);return}this._attachLoadStartListeners(),this._notify("load-start",void 0,new Event(e.type))}_onAbort(e){this._notify("abort",void 0,new Event(e.type))}_onEmptied({type:e}){this._notify("emptied",void 0,new Event(e))}_onLoadedData(e){this._notify("loaded-data",void 0,new Event(e.type))}_onLoadedMetadata(e){this._attachCanPlayListeners(),this._notify("loaded-metadata",void 0,new Event(e.type))}_getCanPlayDetail({duration:e,buffered:n,seekable:i}){return{provider:Rj(this._ctx.$provider),duration:e,buffered:n,seekable:i}}_onPlay(e){this._ctx.$state.canPlay()&&this._notify("play",void 0,new Event(e.type))}_onPause({type:e,payload:n}){n.readyState===1&&!this._waiting||(this._waiting=!1,this._notify("pause",void 0,new Event(e)))}_onCanPlay({type:e,payload:n}){let i=Di(n.buffered),r=Di(n.seekable);this._ctx.delegate._ready(this._getCanPlayDetail({duration:n.duration,buffered:i,seekable:r}),new Event(e))}_onCanPlayThrough({type:e,payload:n}){if(this._ctx.$state.started())return;let i=Di(n.buffered),r=Di(n.seekable);this._notify("can-play-through",this._getCanPlayDetail({duration:n.duration,buffered:i,seekable:r}),new Event(e))}_onPlaying({type:e}){this._waiting=!1,this._notify("playing",void 0,new Event(e))}_onStalled({type:e,payload:n}){this._notify("stalled",void 0,new Event(e)),n.readyState<3&&(this._waiting=!0,this._notify("waiting",void 0,new Event(e)))}_onWaiting({type:e,payload:n}){n.readyState<3&&(this._waiting=!0,this._notify("waiting",void 0,new Event(e)))}_onEnded(e){let{payload:n}=e,i=Di(n.played);this._updateCurrentTime(n.duration,i,e),this._notify("end",void 0,new Event(e.type))}_onTimeUpdate(e){let{payload:n}=e,i=Di(n.played);this._updateCurrentTime(n.current,i,e)}_onDurationChange(e){let{payload:n}=e,i=Di(n.played);this._ctx.$state.ended()&&this._updateCurrentTime(n.duration,i,e),this._notify("duration-change",n.duration,new Event(e.type))}_onVolumeChange({type:e,payload:n}){let i={volume:n.volume,muted:n.muted};this._notify("volume-change",i,new Event(e))}_onSeeked(e){let{payload:n}=e,i=Di(n.played);this._updateCurrentTime(n.current,i,e),this._notify("seeked",n.current,new Event(e.type))}_onSeeking({type:e,payload:n}){this._notify("seeking",n.current,new Event(e))}_onProgress({type:e,payload:n}){let i={buffered:Di(n.buffered),seekable:Di(n.seekable)};this._notify("progress",i,new Event(e))}_onSuspend({type:e}){this._notify("suspend",void 0,new Event(e))}_onRateChange({type:e,payload:n}){this._notify("rate-change",n.rate,new Event(e))}_onError({type:e,payload:n}){let i={message:n.message,code:n.code};this._notify("error",i,new ErrorEvent(e,{error:n}))}};async function NI(t,e){return await e.executeJavaScript(`(async function(){${t}})()`)}function OI(t){switch(t.code){case-202:return"SSL certificate isn't trusted by the browser. If the website is self-hosted, double check the SSL certificate and test it with a browser. ";default:return t.message}}var zd=class extends Error{constructor(n){super(`${n.errorCode}: ${n.errorDescription}`);E(this,"code");E(this,"description");E(this,"url");this.code=n.errorCode,this.url=n.validatedURL,this.description=n.errorDescription}};var{onDispose:FI}=bs,Ud,Cg=class{constructor(e,n,i){this._video=e;this._media=n;this.userGesture=i;Y(this,Ud,!1);E(this,"_onChange",(e,n)=>{this._media.delegate._notify("picture-in-picture-change",e,n)});FI(e.on("enterpictureinpicture",r=>this._onChange(!0,new Event(r.type)))),FI(e.on("leavepictureinpicture",r=>this._onChange(!1,new Event(r.type))))}async updateActive(){let e=await this._video.methods.pictureInPictureEnabled();return Le(this,Ud,e),e}get active(){return this.updateActive(),C(this,Ud)}get supported(){return!!document.pictureInPictureEnabled}async enter(){await this.userGesture(),await this._video.methods.requestPictureInPicture()}async exit(){await this._video.methods.exitPictureInPicture()}};Ud=new WeakMap;var{createScope:Ij,onDispose:Mg,scoped:Lj}=bs,Lo,mi=class{constructor(e,n){this._webview=e;this._ctx=n;E(this,"scope",Ij());E(this,"$$PROVIDER_TYPE","WEBVIEW");E(this,"_currentSrc",null);E(this,"_port",new $f);E(this,"pictureInPicture");Y(this,Lo,null);E(this,"onDomReady",async e=>{let n=this._webview;new Pg(this,this._ctx),bs.effect(()=>{this._ctx.$state.autoPlay()&&this.userGesture()}),this._updateTitle(e),await NI(uI,n),await this.loadPlugin(this.currentWebHost)});Lj(()=>{this.pictureInPicture=new Cg(this._port,n,()=>this.userGesture(!0))},this.scope)}setup(){Mg(()=>{this._webview.src=""}),Aj(),this.type==="webview"&&this._ctx.delegate._notify("provider-setup",this),this.registerTitleChange(),Mg(()=>{this._webview.removeEventListener("dom-ready",this.onDomReady)}),Mg(this._port.on("mx-open-browser",({payload:{url:e,message:n=""}})=>{zI({message:n+`Open ${e} in login browser?`,cancelText:"No",onConfirm:()=>{let i=new Qr(app);i.open(),i.setUrl(e)}})}))}get type(){return"webview"}get webview(){return this._webview}get media(){return this._port}get currentSrc(){return this._currentSrc}get currentWebHost(){return this._currentSrc?.host??"generic"}setPlaybackRate(e){this._port.methods.setPlaybackRate(e)}async userGesture(e=!1){if(!e&&C(this,Lo)){await C(this,Lo);return}await Le(this,Lo,this.webview.executeJavaScript("1",!0).finally(()=>{Le(this,Lo,null)}))}async play(){this.webview.isConnected&&(await this.userGesture(),await this._port.methods.play())}async pause(){this.webview.isConnected&&(await this.userGesture(),await this._port.methods.pause())}setMuted(e){this._port.methods.setMuted(e)}setVolume(e){this._port.methods.setVolume(e)}setCurrentTime(e){this._port.methods.setCurrentTime(e)}get _notify(){return this._ctx.delegate._notify}async _updateTitle(e,n){let i=e=typeof e=="string"?new Event(e):e,r=n??this._webview.getTitle(),s=RI[this.currentWebHost](r),o=this._ctx.$state.title();s!==o&&this._notify("title-change",s,i)}loadPlugin(e){return new Promise((n,i)=>{let r=this._webview,s=this.media.onReady(async()=>{window.clearTimeout(o),await this.media.methods.loadPlugin($I[e]),n()},{once:!0}),o=setTimeout(()=>{s(),i(new Cr(5e3))},5e3),{port1:a,port2:l}=new MessageChannel;this._port.load(a),r.contentWindow.postMessage(dS,"*",[l])})}handlePlayReady(){let e=new Promise((o,a)=>{let l=()=>{this.webview.removeEventListener("did-stop-loading",c),this.webview.removeEventListener("did-finish-load",c),this.webview.removeEventListener("did-fail-load",u)},c=()=>{o(),l()},u=d=>{a(new zd(d)),l()};this.webview.addEventListener("did-stop-loading",c),this.webview.addEventListener("did-finish-load",c),this.webview.addEventListener("did-fail-load",u)}),n,i=o=>new Promise((a,l)=>{n=window.setTimeout(()=>l(new Cr(o)),o)}),r=new Promise(o=>{this._port.once("mx-play-ready",()=>{o(),window.clearTimeout(n)})}),s=1e4;e.then(()=>Promise.race([r,i(s)])).then(()=>{this.togglePlayReady(!0)}).catch(o=>{if(o instanceof Cr)Dj(s);else if(o instanceof zd){let a=OI(o);new $s.Notice(createFragment(l=>{l.appendText(`Failed to load webpage: ${a}`),l.createEl("p",{text:"Click to copy "},c=>c.createEl("a",{href:o.url,text:o.url.length>50?`${o.url.substring(0,50)}...`:o.url},u=>{u.addEventListener("click",d=>{d.preventDefault(),navigator.clipboard.writeText(o.url),new $s.Notice("URL copied to clipboard.")})}))}))}else throw o}).finally(()=>{this.togglePlayReady(!0)})}registerTitleChange(){let e=this._webview,n=i=>{this._updateTitle(i,i.title)};e.addEventListener("page-title-updated",n),Mg(()=>{e.removeEventListener("page-title-updated",n)})}togglePlayReady(e){typeof e>"u"&&(e=!("playReady"in this._webview.dataset)),e?this._webview.dataset.playReady="":delete this._webview.dataset.playReady}untilPluginReady(){let e=this._webview;return this.togglePlayReady(!1),e.removeEventListener("dom-ready",this.onDomReady),this.handlePlayReady(),new Promise((n,i)=>{let r=s=>{this.onDomReady(s).then(n).catch(i),e.removeEventListener("dom-ready",r),e.addEventListener("dom-ready",this.onDomReady)};e.addEventListener("dom-ready",r)})}async loadSource({src:e,type:n}){if(!Vd(e))throw new Error("Webview provider only supports string src.");let i=Rn.create(LI(e)),r=this._webview;if(this._currentSrc={src:i?.source.href??"",type:n,host:i?.type??"generic"},!i){r.src="";return}let s=!r.src||ga(i.source)!==ga(r.src);r.src=i.href,s&&await this.untilPluginReady()}};Lo=new WeakMap;function Aj(){let t="mx:webview-login-notified";localStorage.getItem(t)||(new $s.Notice(createFragment(n=>{n.appendText("You're using a webpage media player."),n.createEl("p",{text:"If you are requested to login, you can open a browser to login from:"},i=>{i.createEl("br"),i.appendText('- the "Login" command'),i.createEl("br"),i.appendText("- the entry in settings tab")}),n.appendText("Click to dismiss this notice.")}),0),localStorage.setItem(t,"1"))}function Dj(t){let e="mx:webview-timeout-ignore";if(localStorage.getItem(e))return;let i=(t/1e3).toFixed(1);zI({message:`Webpage not fully loaded within ${i}s. You can still try to play.`,onCancel(){console.log("ignore webview timeout notice"),localStorage.setItem(e,"1")},cancelText:"Don't show again",timeout:5e3})}function zI({message:t,cancelText:e="Ignore",confirmText:n="OK",onConfirm:i,onCancel:r,timeout:s}){let o=new $s.Notice(createFragment(a=>{a.createDiv({text:t}),a.createDiv({},l=>{l.style.display="flex",l.style.justifyContent="flex-end",l.style.gap="1em",l.style.marginTop="1em";let c=new $s.ButtonComponent(l).setButtonText(n);i&&c.onClick(async()=>{await i(),o.hide()});let u=new $s.ButtonComponent(l).setButtonText(e);r&&u.onClick(async()=>{await r(),o.hide()})})}),s);return o}var Ag=require("fs/promises"),Bd=require("obsidian");function $g(t,e){let n=new Map;for(let i of t){let r=e(i),s=n.get(r);s?s.push(i):n.set(r,[i])}return n}var Lg=A(Pk());var Ck={"de-AT":"\xD6sterreichisches Deutsch","de-CH":"Schweizer Hochdeutsch","en-AU":"Australian English","en-CA":"Canadian English","en-GB":"British English","en-US":"American English","es-ES":"espa\xF1ol de Espa\xF1a","es-MX":"espa\xF1ol de M\xE9xico","fr-CA":"fran\xE7ais canadien","fr-CH":"fran\xE7ais suisse","nl-BE":"Vlaams","pt-BR":"portugu\xEAs do Brasil","pt-PT":"portugu\xEAs europeu","ro-MD":"moldoveneasc\u0103","zh-Hans":"\u7B80\u4F53\u4E2D\u6587","zh-Hant":"\u7E41\u9AD4\u4E2D\u6587"},YI=()=>$g(Object.entries(Ck),([t])=>t.split("-")[0]),GI={"zh-Hans":["CN","SG","MY"],"zh-Hant":["TW","HK","MO"]};function QI(t){let e=t.split("-"),n=e[0].toLowerCase();if(e.length===1)return Lg.default.getNativeName(n);let i=e.slice(0,2).join("-");return Ck[i]||`${Lg.default.getNativeName(e[0])} (${t})`}function Oj(t){return t.toLowerCase()==="hans"||GI["zh-Hans"].includes(t.toUpperCase())?"zh-Hans":t.toLowerCase()==="hant"||GI["zh-Hant"].includes(t.toUpperCase())?"zh-Hant":"zh"}function Mk(t){if(!t)return!1;let e=t.split("-")[0].toLowerCase();return Lg.default.validate(e)}function XI(t){if(!Mk(t))return null;let e=t.split("-"),n=e[0].toLowerCase();if(e.length===1)return n;let i=e[1];return n==="zh"?Oj(i):Ck[`${n}-${i.toUpperCase()}`]??`${n}-${e.slice(1).join("-")}`}var ZI=["vtt","ass","ssa","srt"];function Fj(t){return ZI.includes(t.extension)}function JI(t,e,n){console.debug("Search subtitles for media",{basename:t.basename,path:t.path,defaultLangCode:n}),console.debug(`${e.length} siblings`,e);let i=e.filter(Fj).flatMap(l=>{let c=Vj(l,t.basename);return c?[c]:[]});if(i.length===0)return console.debug("No subtitles found"),i;console.debug(`Found ${i.length} subtitles: `,i.map(l=>l.src.path)),console.debug("Subtitles details: ",i);let r=$g(i,l=>l.language),s=[...r.keys()],o=n?s.find(l=>{if(l)return l===n})??s.find(l=>{if(!l)return;let c=l.split("-")[0],u=n.split("-")[0];return c===u}):s.filter(l=>!!l)[0],a=[];return r.forEach((l,c)=>{for(let u of ZI){let d=l.find(p=>p.type===u);if(d){a.push({...d,default:!!o&&c===o});return}}}),console.debug(`Final tracks: ${a.length}`,a.map(l=>l.src.path)),console.debug("Final tracks details",a),a.length===0||(console.debug(`Final default lang: ${o??a[0].id}`),o||(a[0].default=!0)),a}async function Dg(t,e){let n=t.filePath;if(!n||!t.inferredType)return[];let i=bi.basename(n),r=i.split(".").slice(0,-1).join("."),s=bi.dirname(n),o=(await(0,Ag.readdir)(s,{encoding:"utf-8",withFileTypes:!0}).catch(l=>{let c=l;return c.code!=="ENOENT"&&new Bd.Notice(`Failed to read directory ${s}: ${c.message}`),[]})).filter(l=>l.name!==i&&(l.isFile()||l.isSymbolicLink())).map(l=>{let c=l.name.split(".");return c.length===1?{extension:"",basename:l.name,path:bi.join(s,l.name)}:{extension:c.at(-1),basename:c.slice(0,-1).join("."),path:bi.join(s,l.name)}}),a=JI({basename:r,path:n},o,e);return(await Promise.all(a.map(async({src:l,...c})=>{let u=await(0,Ag.readFile)(l.path,"utf-8").catch(d=>{let p=d;return p.code!=="ENOENT"&&new Bd.Notice(`Failed to read subtitle file ${l.path}: ${p.message}`),""});return u?{...c,content:u}:null}))).filter(l=>!!l)}async function eL(t,e,n){if(!t.parent)return[];let i=JI(t,t.parent.children.filter(r=>r instanceof Bd.TFile),n);return await Promise.all(i.map(async({src:r,...s})=>({...s,content:await e.cachedRead(r)})))}function Vj(t,e){if(!t.basename.startsWith(e))return null;let n=t.basename.substring(e.length),i;if(!n)i=null;else if(i=XI(n.replace(/^\./,"")),!i)return null;let r=i?QI(i):"Unknown";return{kind:"subtitles",language:i??void 0,id:`${t.basename}.${t.extension}.${i??"unknown"}`,src:t,type:t.extension,label:`${r} (${t.extension})`,default:!1}}var tL={"application/prs.cww":["cww"],"application/prs.xsf+xml":["xsf"],"application/vnd.1000minds.decision-model+xml":["1km"],"application/vnd.3gpp.pic-bw-large":["plb"],"application/vnd.3gpp.pic-bw-small":["psb"],"application/vnd.3gpp.pic-bw-var":["pvb"],"application/vnd.3gpp2.tcap":["tcap"],"application/vnd.3m.post-it-notes":["pwn"],"application/vnd.accpac.simply.aso":["aso"],"application/vnd.accpac.simply.imp":["imp"],"application/vnd.acucobol":["acu"],"application/vnd.acucorp":["atc","acutc"],"application/vnd.adobe.air-application-installer-package+zip":["air"],"application/vnd.adobe.formscentral.fcdt":["fcdt"],"application/vnd.adobe.fxp":["fxp","fxpl"],"application/vnd.adobe.xdp+xml":["xdp"],"application/vnd.adobe.xfdf":["*xfdf"],"application/vnd.age":["age"],"application/vnd.ahead.space":["ahead"],"application/vnd.airzip.filesecure.azf":["azf"],"application/vnd.airzip.filesecure.azs":["azs"],"application/vnd.amazon.ebook":["azw"],"application/vnd.americandynamics.acc":["acc"],"application/vnd.amiga.ami":["ami"],"application/vnd.android.package-archive":["apk"],"application/vnd.anser-web-certificate-issue-initiation":["cii"],"application/vnd.anser-web-funds-transfer-initiation":["fti"],"application/vnd.antix.game-component":["atx"],"application/vnd.apple.installer+xml":["mpkg"],"application/vnd.apple.keynote":["key"],"application/vnd.apple.mpegurl":["m3u8"],"application/vnd.apple.numbers":["numbers"],"application/vnd.apple.pages":["pages"],"application/vnd.apple.pkpass":["pkpass"],"application/vnd.aristanetworks.swi":["swi"],"application/vnd.astraea-software.iota":["iota"],"application/vnd.audiograph":["aep"],"application/vnd.balsamiq.bmml+xml":["bmml"],"application/vnd.blueice.multipass":["mpm"],"application/vnd.bmi":["bmi"],"application/vnd.businessobjects":["rep"],"application/vnd.chemdraw+xml":["cdxml"],"application/vnd.chipnuts.karaoke-mmd":["mmd"],"application/vnd.cinderella":["cdy"],"application/vnd.citationstyles.style+xml":["csl"],"application/vnd.claymore":["cla"],"application/vnd.cloanto.rp9":["rp9"],"application/vnd.clonk.c4group":["c4g","c4d","c4f","c4p","c4u"],"application/vnd.cluetrust.cartomobile-config":["c11amc"],"application/vnd.cluetrust.cartomobile-config-pkg":["c11amz"],"application/vnd.commonspace":["csp"],"application/vnd.contact.cmsg":["cdbcmsg"],"application/vnd.cosmocaller":["cmc"],"application/vnd.crick.clicker":["clkx"],"application/vnd.crick.clicker.keyboard":["clkk"],"application/vnd.crick.clicker.palette":["clkp"],"application/vnd.crick.clicker.template":["clkt"],"application/vnd.crick.clicker.wordbank":["clkw"],"application/vnd.criticaltools.wbs+xml":["wbs"],"application/vnd.ctc-posml":["pml"],"application/vnd.cups-ppd":["ppd"],"application/vnd.curl.car":["car"],"application/vnd.curl.pcurl":["pcurl"],"application/vnd.dart":["dart"],"application/vnd.data-vision.rdz":["rdz"],"application/vnd.dbf":["dbf"],"application/vnd.dece.data":["uvf","uvvf","uvd","uvvd"],"application/vnd.dece.ttml+xml":["uvt","uvvt"],"application/vnd.dece.unspecified":["uvx","uvvx"],"application/vnd.dece.zip":["uvz","uvvz"],"application/vnd.denovo.fcselayout-link":["fe_launch"],"application/vnd.dna":["dna"],"application/vnd.dolby.mlp":["mlp"],"application/vnd.dpgraph":["dpg"],"application/vnd.dreamfactory":["dfac"],"application/vnd.ds-keypoint":["kpxx"],"application/vnd.dvb.ait":["ait"],"application/vnd.dvb.service":["svc"],"application/vnd.dynageo":["geo"],"application/vnd.ecowin.chart":["mag"],"application/vnd.enliven":["nml"],"application/vnd.epson.esf":["esf"],"application/vnd.epson.msf":["msf"],"application/vnd.epson.quickanime":["qam"],"application/vnd.epson.salt":["slt"],"application/vnd.epson.ssf":["ssf"],"application/vnd.eszigno3+xml":["es3","et3"],"application/vnd.ezpix-album":["ez2"],"application/vnd.ezpix-package":["ez3"],"application/vnd.fdf":["*fdf"],"application/vnd.fdsn.mseed":["mseed"],"application/vnd.fdsn.seed":["seed","dataless"],"application/vnd.flographit":["gph"],"application/vnd.fluxtime.clip":["ftc"],"application/vnd.framemaker":["fm","frame","maker","book"],"application/vnd.frogans.fnc":["fnc"],"application/vnd.frogans.ltf":["ltf"],"application/vnd.fsc.weblaunch":["fsc"],"application/vnd.fujitsu.oasys":["oas"],"application/vnd.fujitsu.oasys2":["oa2"],"application/vnd.fujitsu.oasys3":["oa3"],"application/vnd.fujitsu.oasysgp":["fg5"],"application/vnd.fujitsu.oasysprs":["bh2"],"application/vnd.fujixerox.ddd":["ddd"],"application/vnd.fujixerox.docuworks":["xdw"],"application/vnd.fujixerox.docuworks.binder":["xbd"],"application/vnd.fuzzysheet":["fzs"],"application/vnd.genomatix.tuxedo":["txd"],"application/vnd.geogebra.file":["ggb"],"application/vnd.geogebra.tool":["ggt"],"application/vnd.geometry-explorer":["gex","gre"],"application/vnd.geonext":["gxt"],"application/vnd.geoplan":["g2w"],"application/vnd.geospace":["g3w"],"application/vnd.gmx":["gmx"],"application/vnd.google-apps.document":["gdoc"],"application/vnd.google-apps.presentation":["gslides"],"application/vnd.google-apps.spreadsheet":["gsheet"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/vnd.grafeq":["gqf","gqs"],"application/vnd.groove-account":["gac"],"application/vnd.groove-help":["ghf"],"application/vnd.groove-identity-message":["gim"],"application/vnd.groove-injector":["grv"],"application/vnd.groove-tool-message":["gtm"],"application/vnd.groove-tool-template":["tpl"],"application/vnd.groove-vcard":["vcg"],"application/vnd.hal+xml":["hal"],"application/vnd.handheld-entertainment+xml":["zmm"],"application/vnd.hbci":["hbci"],"application/vnd.hhe.lesson-player":["les"],"application/vnd.hp-hpgl":["hpgl"],"application/vnd.hp-hpid":["hpid"],"application/vnd.hp-hps":["hps"],"application/vnd.hp-jlyt":["jlt"],"application/vnd.hp-pcl":["pcl"],"application/vnd.hp-pclxl":["pclxl"],"application/vnd.hydrostatix.sof-data":["sfd-hdstx"],"application/vnd.ibm.minipay":["mpy"],"application/vnd.ibm.modcap":["afp","listafp","list3820"],"application/vnd.ibm.rights-management":["irm"],"application/vnd.ibm.secure-container":["sc"],"application/vnd.iccprofile":["icc","icm"],"application/vnd.igloader":["igl"],"application/vnd.immervision-ivp":["ivp"],"application/vnd.immervision-ivu":["ivu"],"application/vnd.insors.igm":["igm"],"application/vnd.intercon.formnet":["xpw","xpx"],"application/vnd.intergeo":["i2g"],"application/vnd.intu.qbo":["qbo"],"application/vnd.intu.qfx":["qfx"],"application/vnd.ipunplugged.rcprofile":["rcprofile"],"application/vnd.irepository.package+xml":["irp"],"application/vnd.is-xpr":["xpr"],"application/vnd.isac.fcs":["fcs"],"application/vnd.jam":["jam"],"application/vnd.jcp.javame.midlet-rms":["rms"],"application/vnd.jisp":["jisp"],"application/vnd.joost.joda-archive":["joda"],"application/vnd.kahootz":["ktz","ktr"],"application/vnd.kde.karbon":["karbon"],"application/vnd.kde.kchart":["chrt"],"application/vnd.kde.kformula":["kfo"],"application/vnd.kde.kivio":["flw"],"application/vnd.kde.kontour":["kon"],"application/vnd.kde.kpresenter":["kpr","kpt"],"application/vnd.kde.kspread":["ksp"],"application/vnd.kde.kword":["kwd","kwt"],"application/vnd.kenameaapp":["htke"],"application/vnd.kidspiration":["kia"],"application/vnd.kinar":["kne","knp"],"application/vnd.koan":["skp","skd","skt","skm"],"application/vnd.kodak-descriptor":["sse"],"application/vnd.las.las+xml":["lasxml"],"application/vnd.llamagraphics.life-balance.desktop":["lbd"],"application/vnd.llamagraphics.life-balance.exchange+xml":["lbe"],"application/vnd.lotus-1-2-3":["123"],"application/vnd.lotus-approach":["apr"],"application/vnd.lotus-freelance":["pre"],"application/vnd.lotus-notes":["nsf"],"application/vnd.lotus-organizer":["org"],"application/vnd.lotus-screencam":["scm"],"application/vnd.lotus-wordpro":["lwp"],"application/vnd.macports.portpkg":["portpkg"],"application/vnd.mapbox-vector-tile":["mvt"],"application/vnd.mcd":["mcd"],"application/vnd.medcalcdata":["mc1"],"application/vnd.mediastation.cdkey":["cdkey"],"application/vnd.mfer":["mwf"],"application/vnd.mfmp":["mfm"],"application/vnd.micrografx.flo":["flo"],"application/vnd.micrografx.igx":["igx"],"application/vnd.mif":["mif"],"application/vnd.mobius.daf":["daf"],"application/vnd.mobius.dis":["dis"],"application/vnd.mobius.mbk":["mbk"],"application/vnd.mobius.mqy":["mqy"],"application/vnd.mobius.msl":["msl"],"application/vnd.mobius.plc":["plc"],"application/vnd.mobius.txf":["txf"],"application/vnd.mophun.application":["mpn"],"application/vnd.mophun.certificate":["mpc"],"application/vnd.mozilla.xul+xml":["xul"],"application/vnd.ms-artgalry":["cil"],"application/vnd.ms-cab-compressed":["cab"],"application/vnd.ms-excel":["xls","xlm","xla","xlc","xlt","xlw"],"application/vnd.ms-excel.addin.macroenabled.12":["xlam"],"application/vnd.ms-excel.sheet.binary.macroenabled.12":["xlsb"],"application/vnd.ms-excel.sheet.macroenabled.12":["xlsm"],"application/vnd.ms-excel.template.macroenabled.12":["xltm"],"application/vnd.ms-fontobject":["eot"],"application/vnd.ms-htmlhelp":["chm"],"application/vnd.ms-ims":["ims"],"application/vnd.ms-lrm":["lrm"],"application/vnd.ms-officetheme":["thmx"],"application/vnd.ms-outlook":["msg"],"application/vnd.ms-pki.seccat":["cat"],"application/vnd.ms-pki.stl":["*stl"],"application/vnd.ms-powerpoint":["ppt","pps","pot"],"application/vnd.ms-powerpoint.addin.macroenabled.12":["ppam"],"application/vnd.ms-powerpoint.presentation.macroenabled.12":["pptm"],"application/vnd.ms-powerpoint.slide.macroenabled.12":["sldm"],"application/vnd.ms-powerpoint.slideshow.macroenabled.12":["ppsm"],"application/vnd.ms-powerpoint.template.macroenabled.12":["potm"],"application/vnd.ms-project":["*mpp","mpt"],"application/vnd.ms-word.document.macroenabled.12":["docm"],"application/vnd.ms-word.template.macroenabled.12":["dotm"],"application/vnd.ms-works":["wps","wks","wcm","wdb"],"application/vnd.ms-wpl":["wpl"],"application/vnd.ms-xpsdocument":["xps"],"application/vnd.mseq":["mseq"],"application/vnd.musician":["mus"],"application/vnd.muvee.style":["msty"],"application/vnd.mynfc":["taglet"],"application/vnd.neurolanguage.nlu":["nlu"],"application/vnd.nitf":["ntf","nitf"],"application/vnd.noblenet-directory":["nnd"],"application/vnd.noblenet-sealer":["nns"],"application/vnd.noblenet-web":["nnw"],"application/vnd.nokia.n-gage.ac+xml":["*ac"],"application/vnd.nokia.n-gage.data":["ngdat"],"application/vnd.nokia.n-gage.symbian.install":["n-gage"],"application/vnd.nokia.radio-preset":["rpst"],"application/vnd.nokia.radio-presets":["rpss"],"application/vnd.novadigm.edm":["edm"],"application/vnd.novadigm.edx":["edx"],"application/vnd.novadigm.ext":["ext"],"application/vnd.oasis.opendocument.chart":["odc"],"application/vnd.oasis.opendocument.chart-template":["otc"],"application/vnd.oasis.opendocument.database":["odb"],"application/vnd.oasis.opendocument.formula":["odf"],"application/vnd.oasis.opendocument.formula-template":["odft"],"application/vnd.oasis.opendocument.graphics":["odg"],"application/vnd.oasis.opendocument.graphics-template":["otg"],"application/vnd.oasis.opendocument.image":["odi"],"application/vnd.oasis.opendocument.image-template":["oti"],"application/vnd.oasis.opendocument.presentation":["odp"],"application/vnd.oasis.opendocument.presentation-template":["otp"],"application/vnd.oasis.opendocument.spreadsheet":["ods"],"application/vnd.oasis.opendocument.spreadsheet-template":["ots"],"application/vnd.oasis.opendocument.text":["odt"],"application/vnd.oasis.opendocument.text-master":["odm"],"application/vnd.oasis.opendocument.text-template":["ott"],"application/vnd.oasis.opendocument.text-web":["oth"],"application/vnd.olpc-sugar":["xo"],"application/vnd.oma.dd2+xml":["dd2"],"application/vnd.openblox.game+xml":["obgx"],"application/vnd.openofficeorg.extension":["oxt"],"application/vnd.openstreetmap.data+xml":["osm"],"application/vnd.openxmlformats-officedocument.presentationml.presentation":["pptx"],"application/vnd.openxmlformats-officedocument.presentationml.slide":["sldx"],"application/vnd.openxmlformats-officedocument.presentationml.slideshow":["ppsx"],"application/vnd.openxmlformats-officedocument.presentationml.template":["potx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":["xlsx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.template":["xltx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":["docx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.template":["dotx"],"application/vnd.osgeo.mapguide.package":["mgp"],"application/vnd.osgi.dp":["dp"],"application/vnd.osgi.subsystem":["esa"],"application/vnd.palm":["pdb","pqa","oprc"],"application/vnd.pawaafile":["paw"],"application/vnd.pg.format":["str"],"application/vnd.pg.osasli":["ei6"],"application/vnd.picsel":["efif"],"application/vnd.pmi.widget":["wg"],"application/vnd.pocketlearn":["plf"],"application/vnd.powerbuilder6":["pbd"],"application/vnd.previewsystems.box":["box"],"application/vnd.proteus.magazine":["mgz"],"application/vnd.publishare-delta-tree":["qps"],"application/vnd.pvi.ptid1":["ptid"],"application/vnd.pwg-xhtml-print+xml":["xhtm"],"application/vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"application/vnd.rar":["rar"],"application/vnd.realvnc.bed":["bed"],"application/vnd.recordare.musicxml":["mxl"],"application/vnd.recordare.musicxml+xml":["musicxml"],"application/vnd.rig.cryptonote":["cryptonote"],"application/vnd.rim.cod":["cod"],"application/vnd.rn-realmedia":["rm"],"application/vnd.rn-realmedia-vbr":["rmvb"],"application/vnd.route66.link66+xml":["link66"],"application/vnd.sailingtracker.track":["st"],"application/vnd.seemail":["see"],"application/vnd.sema":["sema"],"application/vnd.semd":["semd"],"application/vnd.semf":["semf"],"application/vnd.shana.informed.formdata":["ifm"],"application/vnd.shana.informed.formtemplate":["itp"],"application/vnd.shana.informed.interchange":["iif"],"application/vnd.shana.informed.package":["ipk"],"application/vnd.simtech-mindmapper":["twd","twds"],"application/vnd.smaf":["mmf"],"application/vnd.smart.teacher":["teacher"],"application/vnd.software602.filler.form+xml":["fo"],"application/vnd.solent.sdkm+xml":["sdkm","sdkd"],"application/vnd.spotfire.dxp":["dxp"],"application/vnd.spotfire.sfs":["sfs"],"application/vnd.stardivision.calc":["sdc"],"application/vnd.stardivision.draw":["sda"],"application/vnd.stardivision.impress":["sdd"],"application/vnd.stardivision.math":["smf"],"application/vnd.stardivision.writer":["sdw","vor"],"application/vnd.stardivision.writer-global":["sgl"],"application/vnd.stepmania.package":["smzip"],"application/vnd.stepmania.stepchart":["sm"],"application/vnd.sun.wadl+xml":["wadl"],"application/vnd.sun.xml.calc":["sxc"],"application/vnd.sun.xml.calc.template":["stc"],"application/vnd.sun.xml.draw":["sxd"],"application/vnd.sun.xml.draw.template":["std"],"application/vnd.sun.xml.impress":["sxi"],"application/vnd.sun.xml.impress.template":["sti"],"application/vnd.sun.xml.math":["sxm"],"application/vnd.sun.xml.writer":["sxw"],"application/vnd.sun.xml.writer.global":["sxg"],"application/vnd.sun.xml.writer.template":["stw"],"application/vnd.sus-calendar":["sus","susp"],"application/vnd.svd":["svd"],"application/vnd.symbian.install":["sis","sisx"],"application/vnd.syncml+xml":["xsm"],"application/vnd.syncml.dm+wbxml":["bdm"],"application/vnd.syncml.dm+xml":["xdm"],"application/vnd.syncml.dmddf+xml":["ddf"],"application/vnd.tao.intent-module-archive":["tao"],"application/vnd.tcpdump.pcap":["pcap","cap","dmp"],"application/vnd.tmobile-livetv":["tmo"],"application/vnd.trid.tpt":["tpt"],"application/vnd.triscape.mxs":["mxs"],"application/vnd.trueapp":["tra"],"application/vnd.ufdl":["ufd","ufdl"],"application/vnd.uiq.theme":["utz"],"application/vnd.umajin":["umj"],"application/vnd.unity":["unityweb"],"application/vnd.uoml+xml":["uoml","uo"],"application/vnd.vcx":["vcx"],"application/vnd.visio":["vsd","vst","vss","vsw"],"application/vnd.visionary":["vis"],"application/vnd.vsf":["vsf"],"application/vnd.wap.wbxml":["wbxml"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.wap.wmlscriptc":["wmlsc"],"application/vnd.webturbo":["wtb"],"application/vnd.wolfram.player":["nbp"],"application/vnd.wordperfect":["wpd"],"application/vnd.wqd":["wqd"],"application/vnd.wt.stf":["stf"],"application/vnd.xara":["xar"],"application/vnd.xfdl":["xfdl"],"application/vnd.yamaha.hv-dic":["hvd"],"application/vnd.yamaha.hv-script":["hvs"],"application/vnd.yamaha.hv-voice":["hvp"],"application/vnd.yamaha.openscoreformat":["osf"],"application/vnd.yamaha.openscoreformat.osfpvg+xml":["osfpvg"],"application/vnd.yamaha.smaf-audio":["saf"],"application/vnd.yamaha.smaf-phrase":["spf"],"application/vnd.yellowriver-custom-menu":["cmp"],"application/vnd.zul":["zir","zirz"],"application/vnd.zzazz.deck+xml":["zaz"],"application/x-7z-compressed":["7z"],"application/x-abiword":["abw"],"application/x-ace-compressed":["ace"],"application/x-apple-diskimage":["*dmg"],"application/x-arj":["arj"],"application/x-authorware-bin":["aab","x32","u32","vox"],"application/x-authorware-map":["aam"],"application/x-authorware-seg":["aas"],"application/x-bcpio":["bcpio"],"application/x-bdoc":["*bdoc"],"application/x-bittorrent":["torrent"],"application/x-blorb":["blb","blorb"],"application/x-bzip":["bz"],"application/x-bzip2":["bz2","boz"],"application/x-cbr":["cbr","cba","cbt","cbz","cb7"],"application/x-cdlink":["vcd"],"application/x-cfs-compressed":["cfs"],"application/x-chat":["chat"],"application/x-chess-pgn":["pgn"],"application/x-chrome-extension":["crx"],"application/x-cocoa":["cco"],"application/x-conference":["nsc"],"application/x-cpio":["cpio"],"application/x-csh":["csh"],"application/x-debian-package":["*deb","udeb"],"application/x-dgc-compressed":["dgc"],"application/x-director":["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"],"application/x-doom":["wad"],"application/x-dtbncx+xml":["ncx"],"application/x-dtbook+xml":["dtb"],"application/x-dtbresource+xml":["res"],"application/x-dvi":["dvi"],"application/x-envoy":["evy"],"application/x-eva":["eva"],"application/x-font-bdf":["bdf"],"application/x-font-ghostscript":["gsf"],"application/x-font-linux-psf":["psf"],"application/x-font-pcf":["pcf"],"application/x-font-snf":["snf"],"application/x-font-type1":["pfa","pfb","pfm","afm"],"application/x-freearc":["arc"],"application/x-futuresplash":["spl"],"application/x-gca-compressed":["gca"],"application/x-glulx":["ulx"],"application/x-gnumeric":["gnumeric"],"application/x-gramps-xml":["gramps"],"application/x-gtar":["gtar"],"application/x-hdf":["hdf"],"application/x-httpd-php":["php"],"application/x-install-instructions":["install"],"application/x-iso9660-image":["*iso"],"application/x-iwork-keynote-sffkey":["*key"],"application/x-iwork-numbers-sffnumbers":["*numbers"],"application/x-iwork-pages-sffpages":["*pages"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-keepass2":["kdbx"],"application/x-latex":["latex"],"application/x-lua-bytecode":["luac"],"application/x-lzh-compressed":["lzh","lha"],"application/x-makeself":["run"],"application/x-mie":["mie"],"application/x-mobipocket-ebook":["*prc","mobi"],"application/x-ms-application":["application"],"application/x-ms-shortcut":["lnk"],"application/x-ms-wmd":["wmd"],"application/x-ms-wmz":["wmz"],"application/x-ms-xbap":["xbap"],"application/x-msaccess":["mdb"],"application/x-msbinder":["obd"],"application/x-mscardfile":["crd"],"application/x-msclip":["clp"],"application/x-msdos-program":["*exe"],"application/x-msdownload":["*exe","*dll","com","bat","*msi"],"application/x-msmediaview":["mvb","m13","m14"],"application/x-msmetafile":["*wmf","*wmz","*emf","emz"],"application/x-msmoney":["mny"],"application/x-mspublisher":["pub"],"application/x-msschedule":["scd"],"application/x-msterminal":["trm"],"application/x-mswrite":["wri"],"application/x-netcdf":["nc","cdf"],"application/x-ns-proxy-autoconfig":["pac"],"application/x-nzb":["nzb"],"application/x-perl":["pl","pm"],"application/x-pilot":["*prc","*pdb"],"application/x-pkcs12":["p12","pfx"],"application/x-pkcs7-certificates":["p7b","spc"],"application/x-pkcs7-certreqresp":["p7r"],"application/x-rar-compressed":["*rar"],"application/x-redhat-package-manager":["rpm"],"application/x-research-info-systems":["ris"],"application/x-sea":["sea"],"application/x-sh":["sh"],"application/x-shar":["shar"],"application/x-shockwave-flash":["swf"],"application/x-silverlight-app":["xap"],"application/x-sql":["*sql"],"application/x-stuffit":["sit"],"application/x-stuffitx":["sitx"],"application/x-subrip":["srt"],"application/x-sv4cpio":["sv4cpio"],"application/x-sv4crc":["sv4crc"],"application/x-t3vm-image":["t3"],"application/x-tads":["gam"],"application/x-tar":["tar"],"application/x-tcl":["tcl","tk"],"application/x-tex":["tex"],"application/x-tex-tfm":["tfm"],"application/x-texinfo":["texinfo","texi"],"application/x-tgif":["*obj"],"application/x-ustar":["ustar"],"application/x-virtualbox-hdd":["hdd"],"application/x-virtualbox-ova":["ova"],"application/x-virtualbox-ovf":["ovf"],"application/x-virtualbox-vbox":["vbox"],"application/x-virtualbox-vbox-extpack":["vbox-extpack"],"application/x-virtualbox-vdi":["vdi"],"application/x-virtualbox-vhd":["vhd"],"application/x-virtualbox-vmdk":["vmdk"],"application/x-wais-source":["src"],"application/x-web-app-manifest+json":["webapp"],"application/x-x509-ca-cert":["der","crt","pem"],"application/x-xfig":["fig"],"application/x-xliff+xml":["*xlf"],"application/x-xpinstall":["xpi"],"application/x-xz":["xz"],"application/x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"audio/vnd.dece.audio":["uva","uvva"],"audio/vnd.digital-winds":["eol"],"audio/vnd.dra":["dra"],"audio/vnd.dts":["dts"],"audio/vnd.dts.hd":["dtshd"],"audio/vnd.lucent.voice":["lvp"],"audio/vnd.ms-playready.media.pya":["pya"],"audio/vnd.nuera.ecelp4800":["ecelp4800"],"audio/vnd.nuera.ecelp7470":["ecelp7470"],"audio/vnd.nuera.ecelp9600":["ecelp9600"],"audio/vnd.rip":["rip"],"audio/x-aac":["*aac"],"audio/x-aiff":["aif","aiff","aifc"],"audio/x-caf":["caf"],"audio/x-flac":["flac"],"audio/x-m4a":["*m4a"],"audio/x-matroska":["mka"],"audio/x-mpegurl":["m3u"],"audio/x-ms-wax":["wax"],"audio/x-ms-wma":["wma"],"audio/x-pn-realaudio":["ram","ra"],"audio/x-pn-realaudio-plugin":["rmp"],"audio/x-realaudio":["*ra"],"audio/x-wav":["*wav"],"chemical/x-cdx":["cdx"],"chemical/x-cif":["cif"],"chemical/x-cmdf":["cmdf"],"chemical/x-cml":["cml"],"chemical/x-csml":["csml"],"chemical/x-xyz":["xyz"],"image/prs.btif":["btif","btf"],"image/prs.pti":["pti"],"image/vnd.adobe.photoshop":["psd"],"image/vnd.airzip.accelerator.azv":["azv"],"image/vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"image/vnd.djvu":["djvu","djv"],"image/vnd.dvb.subtitle":["*sub"],"image/vnd.dwg":["dwg"],"image/vnd.dxf":["dxf"],"image/vnd.fastbidsheet":["fbs"],"image/vnd.fpx":["fpx"],"image/vnd.fst":["fst"],"image/vnd.fujixerox.edmics-mmr":["mmr"],"image/vnd.fujixerox.edmics-rlc":["rlc"],"image/vnd.microsoft.icon":["ico"],"image/vnd.ms-dds":["dds"],"image/vnd.ms-modi":["mdi"],"image/vnd.ms-photo":["wdp"],"image/vnd.net-fpx":["npx"],"image/vnd.pco.b16":["b16"],"image/vnd.tencent.tap":["tap"],"image/vnd.valve.source.texture":["vtf"],"image/vnd.wap.wbmp":["wbmp"],"image/vnd.xiff":["xif"],"image/vnd.zbrush.pcx":["pcx"],"image/x-3ds":["3ds"],"image/x-cmu-raster":["ras"],"image/x-cmx":["cmx"],"image/x-freehand":["fh","fhc","fh4","fh5","fh7"],"image/x-icon":["*ico"],"image/x-jng":["jng"],"image/x-mrsid-image":["sid"],"image/x-ms-bmp":["*bmp"],"image/x-pcx":["*pcx"],"image/x-pict":["pic","pct"],"image/x-portable-anymap":["pnm"],"image/x-portable-bitmap":["pbm"],"image/x-portable-graymap":["pgm"],"image/x-portable-pixmap":["ppm"],"image/x-rgb":["rgb"],"image/x-tga":["tga"],"image/x-xbitmap":["xbm"],"image/x-xpixmap":["xpm"],"image/x-xwindowdump":["xwd"],"message/vnd.wfa.wsc":["wsc"],"model/vnd.cld":["cld"],"model/vnd.collada+xml":["dae"],"model/vnd.dwf":["dwf"],"model/vnd.gdl":["gdl"],"model/vnd.gtw":["gtw"],"model/vnd.mts":["mts"],"model/vnd.opengex":["ogex"],"model/vnd.parasolid.transmit.binary":["x_b"],"model/vnd.parasolid.transmit.text":["x_t"],"model/vnd.pytha.pyox":["pyo","pyox"],"model/vnd.sap.vds":["vds"],"model/vnd.usda":["usda"],"model/vnd.usdz+zip":["usdz"],"model/vnd.valve.source.compiled-map":["bsp"],"model/vnd.vtu":["vtu"],"text/prs.lines.tag":["dsc"],"text/vnd.curl":["curl"],"text/vnd.curl.dcurl":["dcurl"],"text/vnd.curl.mcurl":["mcurl"],"text/vnd.curl.scurl":["scurl"],"text/vnd.dvb.subtitle":["sub"],"text/vnd.familysearch.gedcom":["ged"],"text/vnd.fly":["fly"],"text/vnd.fmi.flexstor":["flx"],"text/vnd.graphviz":["gv"],"text/vnd.in3d.3dml":["3dml"],"text/vnd.in3d.spot":["spot"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/vnd.wap.wmlscript":["wmls"],"text/x-asm":["s","asm"],"text/x-c":["c","cc","cxx","cpp","h","hh","dic"],"text/x-component":["htc"],"text/x-fortran":["f","for","f77","f90"],"text/x-handlebars-template":["hbs"],"text/x-java-source":["java"],"text/x-lua":["lua"],"text/x-markdown":["mkd"],"text/x-nfo":["nfo"],"text/x-opml":["opml"],"text/x-org":["*org"],"text/x-pascal":["p","pas"],"text/x-processing":["pde"],"text/x-sass":["sass"],"text/x-scss":["scss"],"text/x-setext":["etx"],"text/x-sfv":["sfv"],"text/x-suse-ymp":["ymp"],"text/x-uuencode":["uu"],"text/x-vcalendar":["vcs"],"text/x-vcard":["vcf"],"video/vnd.dece.hd":["uvh","uvvh"],"video/vnd.dece.mobile":["uvm","uvvm"],"video/vnd.dece.pd":["uvp","uvvp"],"video/vnd.dece.sd":["uvs","uvvs"],"video/vnd.dece.video":["uvv","uvvv"],"video/vnd.dvb.file":["dvb"],"video/vnd.fvt":["fvt"],"video/vnd.mpegurl":["mxu","m4u"],"video/vnd.ms-playready.media.pyv":["pyv"],"video/vnd.uvvu.mp4":["uvu","uvvu"],"video/vnd.vivo":["viv"],"video/x-f4v":["f4v"],"video/x-fli":["fli"],"video/x-flv":["flv"],"video/x-m4v":["m4v"],"video/x-matroska":["mkv","mk3d","mks"],"video/x-mng":["mng"],"video/x-ms-asf":["asf","asx"],"video/x-ms-vob":["vob"],"video/x-ms-wm":["wm"],"video/x-ms-wmv":["wmv"],"video/x-ms-wmx":["wmx"],"video/x-ms-wvx":["wvx"],"video/x-msvideo":["avi"],"video/x-sgi-movie":["movie"],"video/x-smv":["smv"],"x-conference/x-cooltalk":["ice"]};Object.freeze(tL);var nL=tL;var iL={"application/andrew-inset":["ez"],"application/appinstaller":["appinstaller"],"application/applixware":["aw"],"application/appx":["appx"],"application/appxbundle":["appxbundle"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/automationml-aml+xml":["aml"],"application/automationml-amlx+zip":["amlx"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cpl+xml":["cpl"],"application/cu-seeme":["cu"],"application/cwl":["cwl"],"application/dash+xml":["mpd"],"application/dash-patch+xml":["mpp"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/express":["exp"],"application/fdf":["fdf"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["*js"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/media-policy-dataset+xml":["mpf"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["*mp4","*mpg4","mp4s","m4p"],"application/msix":["msix"],"application/msixbundle":["msixbundle"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-keys":["asc"],"application/pgp-signature":["sig","*asc"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/sql":["sql"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/trig":["trig"],"application/ttml+xml":["ttml"],"application/ubjson":["ubj"],"application/urc-ressheet+xml":["rsheet"],"application/urc-targetdesc+xml":["td"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/watcherinfo+xml":["wif"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xfdf":["xfdf"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["*xsl","xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":["*3gpp"],"audio/aac":["adts","aac"],"audio/adpcm":["adp"],"audio/amr":["amr"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mobile-xmf":["mxmf"],"audio/mp3":["*mp3"],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx","opus"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/wav":["wav"],"audio/wave":["*wav"],"audio/webm":["weba"],"audio/xm":["xm"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/aces":["exr"],"image/apng":["apng"],"image/avci":["avci"],"image/avcs":["avcs"],"image/avif":["avif"],"image/bmp":["bmp","dib"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/dpx":["dpx"],"image/emf":["emf"],"image/fits":["fits"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heic-sequence":["heics"],"image/heif":["heif"],"image/heif-sequence":["heifs"],"image/hej2k":["hej2"],"image/hsj2":["hsj2"],"image/ief":["ief"],"image/jls":["jls"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jph":["jph"],"image/jphc":["jhc"],"image/jpm":["jpm","jpgm"],"image/jpx":["jpx","jpf"],"image/jxr":["jxr"],"image/jxra":["jxra"],"image/jxrs":["jxrs"],"image/jxs":["jxs"],"image/jxsc":["jxsc"],"image/jxsi":["jxsi"],"image/jxss":["jxss"],"image/ktx":["ktx"],"image/ktx2":["ktx2"],"image/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/jt":["jt"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/prc":["prc"],"model/step+xml":["stpx"],"model/step+zip":["stpz"],"model/step-xml+zip":["stpxz"],"model/stl":["stl"],"model/u3d":["u3d"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/javascript":["js","mjs"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["md","markdown"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/spdx":["spdx"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vtt":["vtt"],"text/wgsl":["wgsl"],"text/xml":["*xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/iso.segment":["m4s"],"video/jpeg":["jpgv"],"video/jpm":["*jpm","*jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/webm":["webm"]};Object.freeze(iL);var rL=iL;var gi=function(t,e,n,i){if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?i:n==="a"?i.call(t):i?i.value:e.get(t)},Pl,Hd,Ao,$k=class{constructor(...e){Pl.set(this,new Map),Hd.set(this,new Map),Ao.set(this,new Map);for(let n of e)this.define(n)}define(e,n=!1){for(let[i,r]of Object.entries(e)){i=i.toLowerCase(),r=r.map(a=>a.toLowerCase()),gi(this,Ao,"f").has(i)||gi(this,Ao,"f").set(i,new Set);let s=gi(this,Ao,"f").get(i),o=!0;for(let a of r){let l=a.startsWith("*");if(a=l?a.slice(1):a,s?.add(a),o&&gi(this,Hd,"f").set(i,a),o=!1,l)continue;let c=gi(this,Pl,"f").get(a);if(c&&c!=i&&!n)throw new Error(`"${i} -> ${a}" conflicts with "${c} -> ${a}". Pass \`force=true\` to override this definition.`);gi(this,Pl,"f").set(a,i)}}return this}getType(e){if(typeof e!="string")return null;let n=e.replace(/^.*[/\\]/,"").toLowerCase(),i=n.replace(/^.*\./,"").toLowerCase(),r=n.length{throw new Error("define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances")},Object.freeze(this);for(let e of gi(this,Ao,"f").values())Object.freeze(e);return this}_getTestState(){return{types:gi(this,Pl,"f"),extensions:gi(this,Hd,"f")}}};Pl=new WeakMap,Hd=new WeakMap,Ao=new WeakMap;var Rk=$k;var Ik=new Rk(rL,nL)._freeze();var ht=require("obsidian");var qd=require("obsidian");async function sL(t,e,n){let i=document.createElement("canvas"),{videoWidth:r,videoHeight:s}=t;if(!r||!s)throw new Error("Cannot screenshot video without width or height");Object.assign(i,{width:r,height:s});let o=i.getContext("2d",{alpha:!1});if(!o)throw new Error("Canvas context creation failed");o.drawImage(t,0,0,r,s);let a=await new Promise((c,u)=>{try{i.toBlob(d=>{d?c(d):u(new Error("Canvas to blob failed"))},e,n)}catch(d){u(d)}}),l=await a.arrayBuffer();return{time:t.currentTime,blob:{arrayBuffer:l,type:a.type}}}function Do(t){return kl(t)||t instanceof mi}async function Wd(t,e,n){let i=qd.Platform.isSafari&&e==="image/webp"?"image/jpeg":e;try{if(kl(t))return await sL(t.video,i,n);if(t instanceof mi)return await t.media.methods.screenshot(i,n);throw new Error("Unsupported provider for screenshot")}catch(r){throw r instanceof DOMException&&r.name==="SecurityError"?new qd.Notice("Cannot take screenshot due to CORS restriction, you can try open media as webpage to bypass this"):new qd.Notice("Cannot take screenshot: "+(r instanceof Error?r.message:String(r))),r}}function Ng(t){let e=t.store.getState().player;if(!e)return new ht.Notice("Player not initialized"),!1;let n=t.getMediaInfo();return n?!e?.provider||!Do(e.provider)?(new ht.Notice("Screenshot is not supported for this media"),!1):{media:n,provider:e.provider,state:e.state,app:t.plugin.app,settings:t.plugin.settings.getState()}:(new ht.Notice("No media is opened"),!1)}async function Kd(t,{file:e,editor:n}){let i=Ng(t);if(!i)return!1;let{provider:r,state:s,media:o,app:{fileManager:a,vault:l},settings:{insertBefore:c,screenshotTemplate:u,screenshotEmbedTemplate:d,screenshotQuality:p,screenshotFormat:h,screenshotFolderPath:m}}=i,{blob:v,time:w}=await Wd(r,h,p),f=ia(w,o,i),g=Ik.getExtension(v.type);if(!g)return new ht.Notice("Unknown mime type: "+v.type),!1;let y=ea(o,{state:s}),T=eh(y)+gE(w),P=w>0?` - ${Rp(w)}`:"",k,M=`${T}.${g}`;if(m===void 0){let b=`${Date.now()}.${Math.random().toString(36).substring(2)}.${g}`,ee=(await a.getAvailablePathForAttachment(b,e.path)).replace(b,"");k=(0,ht.normalizePath)(`${ee}/${M}`)}else{let b=l.getAbstractFileByPath(m);if(b===null)b=await l.createFolder(m).catch(ee=>{throw new ht.Notice(`Failed to create screenshot folder ${m}: ${ee instanceof Error?ee.message:ee}`),ee});else if(!(b instanceof ht.TFolder))return new ht.Notice(`Screenshot folder occupied, check your preferences: ${b.path}`),!1;k=`${b.path}/${M}`}let I=!1,O=l.getAbstractFileByPath(k);if(O instanceof ht.TFile)await l.modifyBinary(O,v.arrayBuffer).catch(b=>{throw new ht.Notice(`Failed to save screenshot to ${O}: ${b instanceof Error?b.message:b}`),b});else if(O===null)I=!0,O=await l.createBinary(k,v.arrayBuffer).catch(b=>{throw new ht.Notice(`Failed to create screenshot in ${O}: ${b instanceof Error?b.message:b}`),b});else return new ht.Notice(`Screenshot file occupied by a folder: ${O.path}`),!1;new ht.Notice(`Screenshot ${I?"created in":"save to"} ${O.path}`);try{return ta({timestamp:f(e.path),screenshot:a.generateMarkdownLink(O,e.path,"",d.replaceAll("{{TITLE}}",y).replaceAll("{{DURATION}}",P)).replace(/^!/,"")},{editor:n,template:u,insertBefore:c}),!0}catch(b){return new ht.Notice("Failed to insert screenshot, see console for details"),console.error("Failed to insert screenshot",b),!1}}async function Gd(t){let{provider:e}=t,{blob:{arrayBuffer:n,type:i}}=await Wd(e,"image/png",void 0),r;try{r=new ClipboardItem({[i]:new Blob([n],{type:i})})}catch(s){return new ht.Notice("Failed to copy screenshot, see console for details"),console.error("Failed to copy screenshot",s),!1}await navigator.clipboard.write([r]),new ht.Notice("Screenshot copied to clipboard")}var Yd=require("obsidian");async function Qd(t,{file:e,editor:n}){let i=t.store.getState().player;if(!i)return new Yd.Notice("Player not initialized"),!1;let r=t.getMediaInfo();if(!r)return new Yd.Notice("No media is opened"),!1;let s=i.currentTime,o=ia(s,r,{app:t.plugin.app,settings:t.plugin.settings.getState(),duration:i.state.duration});if(s<=0)return new Yd.Notice("Playback not started yet"),!1;let{insertBefore:a,timestampTemplate:l}=t.plugin.settings.getState();try{return ta({timestamp:o(e.path)},{editor:n,template:l,insertBefore:a}),!0}catch(c){return new Yd.Notice("Failed to insert timestamp, see console for details"),console.error("Failed to insert timestamp",c),!1}}var oL=require("obsidian");function Lk(t){let e="mx:media-notetaking-notified";localStorage.getItem(e)||(new oL.Notice(createFragment(i=>{i.appendText(`You are taking ${t} from media player. By default, they will only be saved in the media note. `),i.createEl("p",{text:`To take ${t} or control playback from abritrary note, use command when focused on the note`}),i.createEl("p",{text:"PS: you can assign a hotkey to each command in the settings"}),i.appendText("Click to dismiss this notice.")}),0),localStorage.setItem(e,"1"))}function Og(t){let e=ki(t);if(!e)return"";let{pathname:n}=e;if(!n)return"";let i=n.split("/").pop();return i?decodeURI(i.split(".").slice(0,-1).join(".")):""}function Fg(t){t.addAction("star","Take timestamp in media note",()=>{let n=t.getMediaInfo();n&&(Lk("timestamp"),na(n,t).then(i=>{Qd(t,i)}))});let e=t.getViewType();HE.has(e)&&t.addAction("camera","Take screenshot in media",()=>{let n=t.getMediaInfo();n&&(Lk("screenshot"),na(n,t).then(i=>Kd(t,i)))})}function Vg(t,e,n){let{player:i,source:r,toggleControls:s,controls:o,setTransform:a,transform:l,toggleWebFullscreen:c,disableWebFullscreen:u}=t.store.getState();!i||!r||t.plugin.app.workspace.trigger("mx-media-menu",e,{source:r.url,viewType:r.viewType,player:i,toggleControls:s,controls:o,setTransform:a,transform:l,plugin:t.plugin,disableWebFullscreen:u,toggleWebFullscreen:c,reload:()=>t.render()},n,t.leaf)}var Xd={generic:"media",video:"video",audio:"audio"},aL=Object.values(Xd);function un(t){return ke(t)?`file:${t.file.path}`:`url:${t.jsonState.source}`}function ar(t,e){if(!t||!e)return!1;let n=un(t),i=un(e);return n===i}var Ak=new WeakSet;function lL(t){t.subscribe((e,n)=>{e.player!==n.player&&Zd(e)}),t.subscribe((e,n)=>{let i=e.player;if(!i)return;let r=e.source,s=n.source;if(r===s)return;let o=r?.url,a=s?.url;o!==a&&(!o&&a!==void 0||o!==void 0&&!ar(a,o))&&Ak.delete(i)})}async function Zd({player:t,hash:{tempFragment:e}}){if(!t||!e)return;let n=!Ak.has(t);Ak.add(t);let i=null,r=.25;if(Gn(e)||t.currentTimee.end&&(i=e.end),i!==null){let s=i;t.currentTime=s,!t.state.canPlay&&["video/youtube"].includes(t.state.source.type)&&!t.state.autoPlay&&(await zj(t,"seeked"),await t.pause())}Gn(e)&&t.state.canPlay&&!n&&await t.play(new Event("hashchange"))}function zj(t,e){return new Promise(n=>{let i=window.setTimeout(()=>{n(),r()},5e3),r=t.listen(e,()=>{n(),window.clearTimeout(i),r()})})}function Rs(){let t=Ef((e,n,i)=>({player:null,playerRef:r=>e({player:r}),source:void 0,hash:{autoplay:void 0,controls:void 0,loop:void 0,muted:void 0,tempFragment:null,volume:void 0},async getPlayer(r=1e4){let{player:s}=n();return s||new Promise((o,a)=>{let l=i.subscribe(({player:u})=>{u&&(l(),o(u),window.clearTimeout(c))}),c=window.setTimeout(()=>{l(),a(new Cr(r))},r)})},setSource(r,{hash:s,viewType:o,title:a,textTracks:l}){e(c=>({source:{...c.source,viewType:o,url:r},textTracks:l??c.textTracks,hash:{...c.hash,...Pf(s||r.hash)},title:(a===!0?Og(r.source.href):a)??c.title})),Zd(n())},setHash(r){e(s=>({hash:{...s.hash,...Pf(r)}})),Zd(n())},async loadFile(r,{vault:s,subpath:o,defaultLang:a}){let l=await eL(r,s,a),c=Ui(r,o??"");if(!c)throw new Error("Invalid media file: "+r.path);e(({source:u,hash:d})=>({source:{...u,url:c,viewType:gn[c.type]},textTracks:l,title:r.name,hash:o?{...d,...Pf(o)}:d})),await Zd(n())},title:"",transform:null,setTransform:r=>{e(r?s=>{let o={transform:{...s.transform,...r}};return o.transform.flipHorizontal&&o.transform.flipVertical&&o.transform.rotate==="180"&&(o.transform={...o.transform,flipHorizontal:!1,flipVertical:!1,rotate:void 0}),o}:{transform:null})},toggleControls(r){let{player:s}=n();e({controls:r}),s&&s.provider instanceof mi&&s.provider.media.send("mx-toggle-controls",!r)},toggleWebFullscreen(r){let{player:s}=n();e({disableWebFullscreen:!r}),s&&s.provider instanceof mi&&s.provider.media.send("mx-toggle-webfs",r)},textTracks:[],updateWebHost:r=>e({webHost:r==="generic"?void 0:r})}));return lL(t),t}var Vt=(0,yi.createContext)(null);function ft(t){let{store:e}=(0,yi.useContext)(Vt);return ib(e,t)}function No(t){let{plugin:{settings:e}}=(0,yi.useContext)(Vt);return ib(e,t)}function zg(){let{store:t}=(0,yi.useContext)(Vt);return t}function cL(){return(0,yi.useContext)(Vt).reload}function Oo(t){let e=(0,yi.useContext)(Vt).plugin.app;return t?t(e):e}function Ug(){return(0,yi.useContext)(Vt).plugin}function uL(){return(0,yi.useContext)(Vt).onScreenshot}function jg(){return(0,yi.useContext)(Vt).onPlaylistChange}var Cl=()=>(0,yi.useContext)(Vt).embed;function Jd(t,e){let n=gu,i=[()=>n(),t.subscribe((r,s)=>{if(r.player===s.player||(n(),!r.player))return;let o=e(r.player);o?Array.isArray(o)?n=()=>o.forEach(a=>a()):n=o:n=gu})];return()=>i.forEach(r=>r())}var e0=require("obsidian"),vy=A(X());var mL=A(X());var ep=A(X());var dL=function(t){return typeof t=="function"};var Uj=!1,pL=Uj;function jj(t){pL&&(dL(t)||console.error("useMemoizedFn expected parameter is a function, got ".concat(typeof t)));var e=(0,ep.useRef)(t);e.current=(0,ep.useMemo)(function(){return t},[t]);var n=(0,ep.useRef)();return n.current||(n.current=function(){for(var i=[],r=0;r":"video","^":"audio",_:"subtitle","#":"generic","/":"chapter"};function hL(t){return!!t&&t in Dk}function Ml(t){return!!t.media}function fL(t,e,{fromIndex:n,reverse:i=!1}={}){if(i)for(let r=n??t.length-1;r>=0;r--){let s=t[r];if(s&&Ml(s)&&e(s,r,t))return s}else for(let r=n??0;rr.source?.url),e=Ug(),[n,i]=(0,$l.useState)(()=>e.playlist.get(t));return(0,$l.useEffect)(()=>{function r(){i(e.playlist.get(t))}return r(),e.app.metadataCache.on("mx-playlist-change",r),()=>{e.app.metadataCache.off("mx-playlist-change",r)}},[t,e.playlist,e.app.metadataCache]),n.sort((r,s)=>r.file.stat.mtime-s.file.stat.mtime).last()}function qg(){let{target:t,action:e}=Wg("next"),n=Hg()?.autoplay;return{onEnded:Bg(()=>{!n||!t||e()})}}function Wg(t){let e=jg(),n=Hg(),i=(0,$l.useMemo)(()=>{if(!n)return;let s=n.list[n.active];if(!(s&&Ml(s)))return;let o=fL(n.list,a=>!ar(s.media,a.media),{fromIndex:t==="next"?n.active+1:n.active-1,reverse:t==="previous"});if(o)return o},[n,t]),r=Bg(()=>{!i||!n||!e||e(i,n)});return{target:i,action:r}}function gL(){let t=or(),e=zg(),{onEnded:n}=qg();(0,mL.useEffect)(()=>{if(t)return Bj(t,e,n)},[t,e,n])}function Bj(t,e,n){let i={currentTime:t.state.currentTime,paused:t.state.paused,loop:t.state.loop},r=!1,s=[t.subscribe(({currentTime:o,paused:a,loop:l})=>{let c=Hj(e.getState().hash.tempFragment,t.state.duration);if(!c||Gn(c))return;let{start:u,end:d}=c;if(i.paused!==a&&!a)o>d&&!l&&n?.(),(o>d||od)if(l)t.currentTime=u,a&&t.play();else{if(n?.(),r){r=!1;return}a||t.pause()}}Object.assign(i,{currentTime:o,paused:a,loop:l})})];return()=>s.forEach(o=>o())}function Hj(t,e){if(!t)return null;if(Gn(t))return t;let{start:n,end:i}=t;return e&&eo(s))?.classGroupId}var wL=/^\[(.+)\]$/;function Wj(t){if(wL.test(t)){let e=wL.exec(t)[1],n=e?.substring(0,e.indexOf(":"));if(n)return"arbitrary.."+n}}function Kj(t){let{theme:e,prefix:n}=t,i={nextPart:new Map,validators:[]};return Yj(Object.entries(t.classGroups),n).forEach(([s,o])=>{Ok(o,i,s,e)}),i}function Ok(t,e,n,i){t.forEach(r=>{if(typeof r=="string"){let s=r===""?e:_L(e,r);s.classGroupId=n;return}if(typeof r=="function"){if(Gj(r)){Ok(r(i),e,n,i);return}e.validators.push({validator:r,classGroupId:n});return}Object.entries(r).forEach(([s,o])=>{Ok(o,_L(e,s),n,i)})})}function _L(t,e){let n=t;return e.split(Fk).forEach(i=>{n.nextPart.has(i)||n.nextPart.set(i,{nextPart:new Map,validators:[]}),n=n.nextPart.get(i)}),n}function Gj(t){return t.isThemeGetter}function Yj(t,e){return e?t.map(([n,i])=>{let r=i.map(s=>typeof s=="string"?e+s:typeof s=="object"?Object.fromEntries(Object.entries(s).map(([o,a])=>[e+o,a])):s);return[n,r]}):t}function Qj(t){if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=new Map,i=new Map;function r(s,o){n.set(s,o),e++,e>t&&(e=0,i=n,n=new Map)}return{get(s){let o=n.get(s);if(o!==void 0)return o;if((o=i.get(s))!==void 0)return r(s,o),o},set(s,o){n.has(s)?n.set(s,o):r(s,o)}}}var xL="!";function Xj(t){let e=t.separator,n=e.length===1,i=e[0],r=e.length;return function(o){let a=[],l=0,c=0,u;for(let v=0;vc?u-c:void 0;return{modifiers:a,hasImportantModifier:p,baseClassName:h,maybePostfixModifierPosition:m}}}function Zj(t){if(t.length<=1)return t;let e=[],n=[];return t.forEach(i=>{i[0]==="["?(e.push(...n.sort(),i),n=[]):n.push(i)}),e.push(...n.sort()),e}function Jj(t){return{cache:Qj(t.cacheSize),splitModifiers:Xj(t),...qj(t)}}var e9=/\s+/;function t9(t,e){let{splitModifiers:n,getClassGroupId:i,getConflictingClassGroupIds:r}=e,s=new Set;return t.trim().split(e9).map(o=>{let{modifiers:a,hasImportantModifier:l,baseClassName:c,maybePostfixModifierPosition:u}=n(o),d=i(u?c.substring(0,u):c),p=!!u;if(!d){if(!u)return{isTailwindClass:!1,originalClassName:o};if(d=i(c),!d)return{isTailwindClass:!1,originalClassName:o};p=!1}let h=Zj(a).join(":");return{isTailwindClass:!0,modifierId:l?h+xL:h,classGroupId:d,originalClassName:o,hasPostfixModifier:p}}).reverse().filter(o=>{if(!o.isTailwindClass)return!0;let{modifierId:a,classGroupId:l,hasPostfixModifier:c}=o,u=a+l;return s.has(u)?!1:(s.add(u),r(l,c).forEach(d=>s.add(a+d)),!0)}).reverse().map(o=>o.originalClassName).join(" ")}function n9(){let t=0,e,n,i="";for(;td(u),t());return n=Jj(c),i=n.cache.get,r=n.cache.set,s=a,a(l)}function a(l){let c=i(l);if(c)return c;let u=t9(l,n);return r(l,u),u}return function(){return s(n9.apply(null,arguments))}}function He(t){let e=n=>n[t]||[];return e.isThemeGetter=!0,e}var TL=/^\[(?:([a-z-]+):)?(.+)\]$/i,r9=/^\d+\/\d+$/,s9=new Set(["px","full","screen"]),o9=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,a9=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,l9=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,c9=/^-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,u9=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/;function Br(t){return Fo(t)||s9.has(t)||r9.test(t)}function Is(t){return Rl(t,"length",v9)}function Fo(t){return!!t&&!Number.isNaN(Number(t))}function Kg(t){return Rl(t,"number",Fo)}function tp(t){return!!t&&Number.isInteger(Number(t))}function d9(t){return t.endsWith("%")&&Fo(t.slice(0,-1))}function ce(t){return TL.test(t)}function Ls(t){return o9.test(t)}var p9=new Set(["length","size","percentage"]);function h9(t){return Rl(t,p9,EL)}function f9(t){return Rl(t,"position",EL)}var m9=new Set(["image","url"]);function g9(t){return Rl(t,m9,_9)}function y9(t){return Rl(t,"",w9)}function np(){return!0}function Rl(t,e,n){let i=TL.exec(t);return i?i[1]?typeof e=="string"?i[1]===e:e.has(i[1]):n(i[2]):!1}function v9(t){return a9.test(t)&&!l9.test(t)}function EL(){return!1}function w9(t){return c9.test(t)}function _9(t){return u9.test(t)}function b9(){let t=He("colors"),e=He("spacing"),n=He("blur"),i=He("brightness"),r=He("borderColor"),s=He("borderRadius"),o=He("borderSpacing"),a=He("borderWidth"),l=He("contrast"),c=He("grayscale"),u=He("hueRotate"),d=He("invert"),p=He("gap"),h=He("gradientColorStops"),m=He("gradientColorStopPositions"),v=He("inset"),w=He("margin"),f=He("opacity"),g=He("padding"),y=He("saturate"),T=He("scale"),P=He("sepia"),k=He("skew"),M=He("space"),I=He("translate"),O=()=>["auto","contain","none"],b=()=>["auto","hidden","clip","visible","scroll"],ee=()=>["auto",ce,e],U=()=>[ce,e],H=()=>["",Br,Is],q=()=>["auto",Fo,ce],W=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],xe=()=>["solid","dashed","dotted","double","none"],Fe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","plus-lighter"],yt=()=>["start","end","center","between","around","evenly","stretch"],tt=()=>["","0",ce],_=()=>["auto","avoid","all","avoid-page","page","left","right","column"],Ie=()=>[Fo,Kg],Rt=()=>[Fo,ce];return{cacheSize:500,separator:":",theme:{colors:[np],spacing:[Br,Is],blur:["none","",Ls,ce],brightness:Ie(),borderColor:[t],borderRadius:["none","","full",Ls,ce],borderSpacing:U(),borderWidth:H(),contrast:Ie(),grayscale:tt(),hueRotate:Rt(),invert:tt(),gap:U(),gradientColorStops:[t],gradientColorStopPositions:[d9,Is],inset:ee(),margin:ee(),opacity:Ie(),padding:U(),saturate:Ie(),scale:Ie(),sepia:tt(),skew:Rt(),space:U(),translate:U()},classGroups:{aspect:[{aspect:["auto","square","video",ce]}],container:["container"],columns:[{columns:[Ls]}],"break-after":[{"break-after":_()}],"break-before":[{"break-before":_()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...W(),ce]}],overflow:[{overflow:b()}],"overflow-x":[{"overflow-x":b()}],"overflow-y":[{"overflow-y":b()}],overscroll:[{overscroll:O()}],"overscroll-x":[{"overscroll-x":O()}],"overscroll-y":[{"overscroll-y":O()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[v]}],"inset-x":[{"inset-x":[v]}],"inset-y":[{"inset-y":[v]}],start:[{start:[v]}],end:[{end:[v]}],top:[{top:[v]}],right:[{right:[v]}],bottom:[{bottom:[v]}],left:[{left:[v]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",tp,ce]}],basis:[{basis:ee()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",ce]}],grow:[{grow:tt()}],shrink:[{shrink:tt()}],order:[{order:["first","last","none",tp,ce]}],"grid-cols":[{"grid-cols":[np]}],"col-start-end":[{col:["auto",{span:["full",tp,ce]},ce]}],"col-start":[{"col-start":q()}],"col-end":[{"col-end":q()}],"grid-rows":[{"grid-rows":[np]}],"row-start-end":[{row:["auto",{span:[tp,ce]},ce]}],"row-start":[{"row-start":q()}],"row-end":[{"row-end":q()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",ce]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",ce]}],gap:[{gap:[p]}],"gap-x":[{"gap-x":[p]}],"gap-y":[{"gap-y":[p]}],"justify-content":[{justify:["normal",...yt()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...yt(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...yt(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[g]}],px:[{px:[g]}],py:[{py:[g]}],ps:[{ps:[g]}],pe:[{pe:[g]}],pt:[{pt:[g]}],pr:[{pr:[g]}],pb:[{pb:[g]}],pl:[{pl:[g]}],m:[{m:[w]}],mx:[{mx:[w]}],my:[{my:[w]}],ms:[{ms:[w]}],me:[{me:[w]}],mt:[{mt:[w]}],mr:[{mr:[w]}],mb:[{mb:[w]}],ml:[{ml:[w]}],"space-x":[{"space-x":[M]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[M]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",ce,e]}],"min-w":[{"min-w":[ce,e,"min","max","fit"]}],"max-w":[{"max-w":[ce,e,"none","full","min","max","fit","prose",{screen:[Ls]},Ls]}],h:[{h:[ce,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[ce,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[ce,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[ce,e,"auto","min","max","fit"]}],"font-size":[{text:["base",Ls,Is]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Kg]}],"font-family":[{font:[np]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractons"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",ce]}],"line-clamp":[{"line-clamp":["none",Fo,Kg]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Br,ce]}],"list-image":[{"list-image":["none",ce]}],"list-style-type":[{list:["none","disc","decimal",ce]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[f]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[f]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...xe(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Br,Is]}],"underline-offset":[{"underline-offset":["auto",Br,ce]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:U()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ce]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ce]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[f]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...W(),f9]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",h9]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},g9]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[m]}],"gradient-via-pos":[{via:[m]}],"gradient-to-pos":[{to:[m]}],"gradient-from":[{from:[h]}],"gradient-via":[{via:[h]}],"gradient-to":[{to:[h]}],rounded:[{rounded:[s]}],"rounded-s":[{"rounded-s":[s]}],"rounded-e":[{"rounded-e":[s]}],"rounded-t":[{"rounded-t":[s]}],"rounded-r":[{"rounded-r":[s]}],"rounded-b":[{"rounded-b":[s]}],"rounded-l":[{"rounded-l":[s]}],"rounded-ss":[{"rounded-ss":[s]}],"rounded-se":[{"rounded-se":[s]}],"rounded-ee":[{"rounded-ee":[s]}],"rounded-es":[{"rounded-es":[s]}],"rounded-tl":[{"rounded-tl":[s]}],"rounded-tr":[{"rounded-tr":[s]}],"rounded-br":[{"rounded-br":[s]}],"rounded-bl":[{"rounded-bl":[s]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[f]}],"border-style":[{border:[...xe(),"hidden"]}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[f]}],"divide-style":[{divide:xe()}],"border-color":[{border:[r]}],"border-color-x":[{"border-x":[r]}],"border-color-y":[{"border-y":[r]}],"border-color-t":[{"border-t":[r]}],"border-color-r":[{"border-r":[r]}],"border-color-b":[{"border-b":[r]}],"border-color-l":[{"border-l":[r]}],"divide-color":[{divide:[r]}],"outline-style":[{outline:["",...xe()]}],"outline-offset":[{"outline-offset":[Br,ce]}],"outline-w":[{outline:[Br,Is]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:H()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[f]}],"ring-offset-w":[{"ring-offset":[Br,Is]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Ls,y9]}],"shadow-color":[{shadow:[np]}],opacity:[{opacity:[f]}],"mix-blend":[{"mix-blend":Fe()}],"bg-blend":[{"bg-blend":Fe()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[i]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",Ls,ce]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[d]}],saturate:[{saturate:[y]}],sepia:[{sepia:[P]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[i]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[d]}],"backdrop-opacity":[{"backdrop-opacity":[f]}],"backdrop-saturate":[{"backdrop-saturate":[y]}],"backdrop-sepia":[{"backdrop-sepia":[P]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",ce]}],duration:[{duration:Rt()}],ease:[{ease:["linear","in","out","in-out",ce]}],delay:[{delay:Rt()}],animate:[{animate:["none","spin","ping","pulse","bounce",ce]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[T]}],"scale-x":[{"scale-x":[T]}],"scale-y":[{"scale-y":[T]}],rotate:[{rotate:[tp,ce]}],"translate-x":[{"translate-x":[I]}],"translate-y":[{"translate-y":[I]}],"skew-x":[{"skew-x":[k]}],"skew-y":[{"skew-y":[k]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",ce]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",ce]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":U()}],"scroll-mx":[{"scroll-mx":U()}],"scroll-my":[{"scroll-my":U()}],"scroll-ms":[{"scroll-ms":U()}],"scroll-me":[{"scroll-me":U()}],"scroll-mt":[{"scroll-mt":U()}],"scroll-mr":[{"scroll-mr":U()}],"scroll-mb":[{"scroll-mb":U()}],"scroll-ml":[{"scroll-ml":U()}],"scroll-p":[{"scroll-p":U()}],"scroll-px":[{"scroll-px":U()}],"scroll-py":[{"scroll-py":U()}],"scroll-ps":[{"scroll-ps":U()}],"scroll-pe":[{"scroll-pe":U()}],"scroll-pt":[{"scroll-pt":U()}],"scroll-pr":[{"scroll-pr":U()}],"scroll-pb":[{"scroll-pb":U()}],"scroll-pl":[{"scroll-pl":U()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ce]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[Br,Is,Kg]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}}var SL=i9(b9);function vi(...t){return SL(vL(t))}var PL=A(X());function CL(t){let e=or();(0,PL.useEffect)(()=>{if(e)return e.listen("loaded-metadata",n=>{let i=n.target;if(!kl(i.provider)){t("unknown");return}let{videoHeight:r,videoWidth:s}=i.provider.video;t(r===0||s===0?"audio":"unknown")})},[e])}var ML=require("obsidian"),ip=A(X());function Gg(){let{controls:t}=Vk(),e=ft(r=>r.controls);return e===void 0&&t===void 0?!0:e||t}function Vk(){let{volume:t,tempFragment:e,...n}=ft(i=>i.hash);return n}function $L(){let t=or(),{volume:e}=ft(o=>o.hash),n=No(o=>o.defaultVolume/100),i=e??n,r=(0,ip.useRef)(i);r.current=i;let s=(0,ip.useRef)(!1);(0,ip.useEffect)(()=>{let o=(0,ML.debounce)(()=>{s.current=!1},1e3,!0),a=c=>{c.target.provider?.setVolume(r.current),s.current=!0,o()};if(!t)return;let l=[t.listen("can-play-through",a),t.listen("can-play",a),t.listen("loaded-data",a),t.listen("loaded-metadata",a),t.subscribe(({volume:c})=>{!s.current||c===r.current||t.provider?.setVolume(r.current)})];return()=>l.forEach(c=>c())},[t])}function mt(){return mt=Object.assign?Object.assign.bind():function(t){for(var e=1;et.forEach(n=>x9(n,e))}function lr(...t){return(0,RL.useCallback)(zk(...t),t)}var Ni=A(X(),1);function As(t,e=[]){let n=[];function i(s,o){let a=(0,Ni.createContext)(o),l=n.length;n=[...n,o];function c(d){let{scope:p,children:h,...m}=d,v=p?.[t][l]||a,w=(0,Ni.useMemo)(()=>m,Object.values(m));return(0,Ni.createElement)(v.Provider,{value:w},h)}function u(d,p){let h=p?.[t][l]||a,m=(0,Ni.useContext)(h);if(m)return m;if(o!==void 0)return o;throw new Error(`\`${d}\` must be used within \`${s}\``)}return c.displayName=s+"Provider",[c,u]}let r=()=>{let s=n.map(o=>(0,Ni.createContext)(o));return function(a){let l=a?.[t]||s;return(0,Ni.useMemo)(()=>({[`__scope${t}`]:{...a,[t]:l}}),[a,l])}};return r.scopeName=t,[i,k9(r,...e)]}function k9(...t){let e=t[0];if(t.length===1)return e;let n=()=>{let i=t.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(s){let o=i.reduce((a,{useScope:l,scopeName:c})=>{let d=l(s)[`__scope${c}`];return{...a,...d}},{});return(0,Ni.useMemo)(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}var Ll=A(X(),1),P9=A(fu(),1);var Je=A(X(),1);var Il=(0,Je.forwardRef)((t,e)=>{let{children:n,...i}=t,r=Je.Children.toArray(n),s=r.find(E9);if(s){let o=s.props.children,a=r.map(l=>l===s?Je.Children.count(o)>1?Je.Children.only(null):(0,Je.isValidElement)(o)?o.props.children:null:l);return(0,Je.createElement)(Uk,mt({},i,{ref:e}),(0,Je.isValidElement)(o)?(0,Je.cloneElement)(o,void 0,a):null)}return(0,Je.createElement)(Uk,mt({},i,{ref:e}),n)});Il.displayName="Slot";var Uk=(0,Je.forwardRef)((t,e)=>{let{children:n,...i}=t;return(0,Je.isValidElement)(n)?(0,Je.cloneElement)(n,{...S9(i,n.props),ref:e?zk(e,n.ref):n.ref}):Je.Children.count(n)>1?Je.Children.only(null):null});Uk.displayName="SlotClone";var T9=({children:t})=>(0,Je.createElement)(Je.Fragment,null,t);function E9(t){return(0,Je.isValidElement)(t)&&t.type===T9}function S9(t,e){let n={...e};for(let i in e){let r=t[i],s=e[i];/^on[A-Z]/.test(i)?r&&s?n[i]=(...a)=>{s(...a),r(...a)}:r&&(n[i]=r):i==="style"?n[i]={...r,...s}:i==="className"&&(n[i]=[r,s].filter(Boolean).join(" "))}return{...t,...n}}var C9=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],rp=C9.reduce((t,e)=>{let n=(0,Ll.forwardRef)((i,r)=>{let{asChild:s,...o}=i,a=s?Il:e;return(0,Ll.useEffect)(()=>{window[Symbol.for("radix-ui")]=!0},[]),(0,Ll.createElement)(a,mt({},o,{ref:r}))});return n.displayName=`Primitive.${e}`,{...t,[e]:n}},{});var Al=A(X(),1);function jk(t){let e=(0,Al.useRef)(t);return(0,Al.useEffect)(()=>{e.current=t}),(0,Al.useMemo)(()=>(...n)=>{var i;return(i=e.current)===null||i===void 0?void 0:i.call(e,...n)},[])}var IL=A(X(),1),LL=globalThis?.document?IL.useLayoutEffect:()=>{};var sp=A(X(),1);var AL=A(X(),1);function DL(t){let[e,n]=(0,AL.useState)(void 0);return LL(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});let i=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;let s=r[0],o,a;if("borderBoxSize"in s){let l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;o=c.inlineSize,a=c.blockSize}else o=t.offsetWidth,a=t.offsetHeight;n({width:o,height:a})});return i.observe(t,{box:"border-box"}),()=>i.unobserve(t)}else n(void 0)},[t]),e}var NL="Popper",[OL,Bk]=As(NL),[RJ,IJ]=OL(NL);var M9="PopperContent",[LJ,AJ]=OL(M9);var Ds=A(X(),1);function FL({prop:t,defaultProp:e,onChange:n=()=>{}}){let[i,r]=$9({defaultProp:e,onChange:n}),s=t!==void 0,o=s?t:i,a=jk(n),l=(0,Ds.useCallback)(c=>{if(s){let d=typeof c=="function"?c(t):c;d!==t&&a(d)}else r(c)},[s,t,r,a]);return[o,l]}function $9({defaultProp:t,onChange:e}){let n=(0,Ds.useState)(t),[i]=n,r=(0,Ds.useRef)(i),s=jk(e);return(0,Ds.useEffect)(()=>{r.current!==i&&(s(i),r.current=i)},[i,r,s]),n}var[Yg,qJ]=As("Tooltip",[Bk]),WJ=Bk(),R9="TooltipProvider",I9=700;var[L9,KJ]=Yg(R9),A9=t=>{let{__scopeTooltip:e,delayDuration:n=I9,skipDelayDuration:i=300,disableHoverableContent:r=!1,children:s}=t,[o,a]=(0,dn.useState)(!0),l=(0,dn.useRef)(!1),c=(0,dn.useRef)(0);return(0,dn.useEffect)(()=>{let u=c.current;return()=>window.clearTimeout(u)},[]),(0,dn.createElement)(L9,{scope:e,isOpenDelayed:o,delayDuration:n,onOpen:(0,dn.useCallback)(()=>{window.clearTimeout(c.current),a(!1)},[]),onClose:(0,dn.useCallback)(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>a(!0),i)},[i]),isPointerInTransitRef:l,onPointerInTransitChange:(0,dn.useCallback)(u=>{l.current=u},[]),disableHoverableContent:r},s)},VL="Tooltip",[GJ,YJ]=Yg(VL);var D9="TooltipPortal",[QJ,XJ]=Yg(D9,{forceMount:void 0});var[ZJ,JJ]=Yg(VL,{isInside:!1});var Qg=A9;var Jg=A(X());var HL=require("obsidian"),Zg=A(X()),oA=A(_e());function j9(t){let e=(0,Zg.useRef)(null);return[(0,Zg.useCallback)(i=>{e.current&&e.current.empty(),i&&(0,HL.setIcon)(i,t),e.current=i},[t])]}function We(t){return function(n){let[i]=j9(t);return(0,oA.jsx)("div",{ref:i,...n})}}var qL=We("play"),WL=We("pause"),see=We("volume"),KL=We("volume-1"),GL=We("volume-2"),YL=We("volume-x"),QL=We("maximize"),XL=We("minimize"),B9=We("picture-in-picture-2"),H9=We("picture-in-picture"),Hk=We("subtitles"),oee=We("check-circle"),aee=We("circle"),ZL=We("fast-forward"),JL=We("rewind"),eA=We("edit"),tA=We("image-down"),q9=We("pin"),nA=We("more-horizontal"),lee=We("plus"),cee=We("trash"),iA=We("list-video"),rA=We("skip-forward"),sA=We("skip-back");var et=A(_e()),op="group ring-mod-border-focus relative inline-flex h-10 w-10 cursor-pointer items-center justify-center rounded-md outline-none ring-inset hover:bg-white/20 focus-visible:ring-2 aria-disabled:hidden";function ey(){let t=Oe("paused");return(0,et.jsx)(pg,{className:op,"aria-label":t?"Play":"Pause",children:t?(0,et.jsx)(qL,{className:"w-7 h-7 translate-x-px"}):(0,et.jsx)(WL,{className:"w-7 h-7"})})}function aA({seconds:t}){return(0,et.jsx)(Nd,{className:op,seconds:t,"aria-label":`Fast forward ${t}s`,children:(0,et.jsx)(ZL,{className:"w-7 h-7"})})}function lA({seconds:t}){return(0,et.jsx)(Nd,{className:op,seconds:-t,"aria-label":`Rewind ${t}s`,children:(0,et.jsx)(JL,{className:"w-7 h-7"})})}function ty(){let t=Oe("volume"),e=Oe("muted");return(0,et.jsx)(fg,{className:op,"aria-label":e?"Unmute":"Mute",children:e||t==0?(0,et.jsx)(YL,{className:"w-7 h-7"}):t<.5?(0,et.jsx)(KL,{className:"w-7 h-7"}):(0,et.jsx)(GL,{className:"w-7 h-7"})})}function cA(){let t=Oe("fullscreen");return(0,et.jsx)(hg,{className:op,"aria-label":t?"Exit fullscreen":"Enter fullscreen",children:t?(0,et.jsx)(XL,{className:"w-7 h-7"}):(0,et.jsx)(QL,{className:"w-7 h-7"})})}function ny(){return Cl()?(0,et.jsx)("button",{className:vi("mx-lp-edit","group ring-mod-border-focus relative inline-flex h-10 w-10 cursor-pointer items-center justify-center rounded-md outline-none ring-inset hover:bg-white/20 focus-visible:ring-2 aria-disabled:hidden"),onClick:()=>{},[Hr]:!0,"aria-label":"Edit in editor",children:(0,et.jsx)(eA,{className:"w-7 h-7"})}):null}function W9(){let t=lI(),[e,n]=(0,Jg.useState)(()=>Do(t)),i=uL(),r=No(o=>o.screenshotFormat),s=No(o=>o.screenshotQuality);return(0,Jg.useEffect)(()=>{n(Do(t))},[t]),!e||!i||!t?null:async()=>{i(await Wd(t,r,s))}}function uA(){let t=W9();return t?(0,et.jsx)("button",{className:"group ring-mod-border-focus relative inline-flex h-10 w-10 cursor-pointer items-center justify-center rounded-md outline-none ring-inset hover:bg-white/20 focus-visible:ring-2 aria-disabled:hidden",onClick:t,"aria-label":"Capture screenshot",children:(0,et.jsx)(tA,{className:"w-7 h-7"})}):null}function iy(){let{target:t,action:e}=Wg("next");return t?(0,et.jsx)("button",{className:"group ring-mod-border-focus relative inline-flex h-10 w-10 cursor-pointer items-center justify-center rounded-md outline-none ring-inset hover:bg-white/20 focus-visible:ring-2 aria-disabled:hidden",onClick:e,"aria-label":`Next: ${t.title}`,children:(0,et.jsx)(rA,{className:"w-7 h-7"})}):null}function ry(){let{target:t,action:e}=Wg("previous");if(t)return(0,et.jsx)("button",{className:"group ring-mod-border-focus relative inline-flex h-10 w-10 cursor-pointer items-center justify-center rounded-md outline-none ring-inset hover:bg-white/20 focus-visible:ring-2 aria-disabled:hidden",onClick:e,"aria-label":`Prev: ${t.title}`,children:(0,et.jsx)(sA,{className:"w-7 h-7"})})}var Hr="data-lp-pass-through";var fA=require("obsidian"),mA=A(X());function pA(t,e,n){let i=K9(e);hA(t,i,n,new Map)}function hA(t,e,n,i){e.forEach(r=>{let s=n(t,r,i);if(s&&r.children.length>0){i.set(r.index,s);let o=s.setSubmenu();hA(o,r.children,n,i)}})}function K9(t){let e=[],n=t.map((i,r)=>({...i,index:r,children:[]}));return n.forEach(i=>{i.parent>=0?n[i.parent]?.children.push(i):e.push(i)}),e}var zo=A(_e());function qk(t){let e=(0,mA.useRef)(null);return n=>{e.current?.close(),e.current=null;let i=new fA.Menu;t(i)?(ya(n.nativeEvent,i),n.nativeEvent.stopImmediatePropagation(),vt(i,{close:r=>function(...s){return e.current===this&&(e.current=null),r.call(this,...s)}}),e.current=i):i.close()}}function sy(){let t=Hg(),e=jg(),n=ft(s=>s.source?.url),i=Oo(),r=qk(s=>!e||!n||!t?!1:(s.addItem(o=>o.setTitle(t.title).setIcon("list-video").onClick(()=>{i.workspace.openLinkText(t.file.path,"","tab")})).addSeparator(),pA(s,t.list,(o,a,l)=>{if(a.type==="subtitle")return null;let c=null;if(Ml(a)){let u=a.children.length>0;o.addItem(d=>{if(d.setTitle(a.title).onClick(()=>{e(a,t)}),ar(n,a.media)){d.setChecked(!0);let p=h=>{if(h.parent<0)return;l.get(h.parent)?.setChecked(!0);let m=t.list[h.parent];m&&p(m)};p(a)}u||(c=d)}),u&&o.addItem(d=>{d.setTitle(" \u21B3"),c=d})}else o.addItem(u=>{u.setTitle(a.title).setIcon("hash"),c=u});return c}),!0));return!e||!n||!t?null:(0,zo.jsx)("button",{className:"group ring-mod-border-focus relative inline-flex h-10 w-10 cursor-pointer items-center justify-center rounded-md outline-none ring-inset hover:bg-white/20 focus-visible:ring-2 aria-disabled:hidden",[Hr]:!0,onClick:r,"aria-label":"Select Playlist",children:(0,zo.jsx)(iA,{className:"w-7 h-7"})})}function gA(){let t=gk(),e=Oe("textTracks"),n=qk(i=>(t.forEach(({label:r,select:s,selected:o},a,l)=>{i.addItem(c=>{l.length===2&&r==="Unknown"&&(r="On"),c.setTitle(r).setChecked(o).onClick(s)})}),!0));return e.length===0?null:(0,zo.jsx)("button",{className:"group ring-mod-border-focus relative inline-flex h-10 w-10 cursor-pointer items-center justify-center rounded-md outline-none ring-inset hover:bg-white/20 focus-visible:ring-2 aria-disabled:hidden",[Hr]:!0,onClick:n,"aria-label":"Select Caption",children:(0,zo.jsx)(Hk,{className:"w-7 h-7"})})}function oy(){let t=or(),e=Oo(l=>l.workspace),n=Ug(),i=Cl(),r=cL(),s=ft(l=>l.source),o=zg(),a=qk(l=>{if(!t||!s)return!1;let{toggleControls:c,controls:u,setTransform:d,transform:p,disableWebFullscreen:h,toggleWebFullscreen:m}=o.getState();return e.trigger("mx-media-menu",l,{player:t,reload:r,source:s.url,viewType:s.viewType,toggleControls:c,controls:u,setTransform:d,transform:p,plugin:n,disableWebFullscreen:h,toggleWebFullscreen:m},i?"player-menu-embed":"player-menu-view"),!0});return!t||!s?null:(0,zo.jsx)("button",{className:"group ring-mod-border-focus relative inline-flex h-10 w-10 cursor-pointer items-center justify-center rounded-md outline-none ring-inset hover:bg-white/20 focus-visible:ring-2 aria-disabled:hidden",[Hr]:!0,onClick:a,"aria-label":"More options",children:(0,zo.jsx)(nA,{className:"w-7 h-7"})})}var uy=A(X());var re=A(X(),1);function Wk(t,[e,n]){return Math.min(n,Math.max(e,t))}var ap=A(X(),1),G9=(0,ap.createContext)(void 0);function vA(t){let e=(0,ap.useContext)(G9);return t||e||"ltr"}var ay=A(X(),1);function wA(t){let e=(0,ay.useRef)({value:t,previous:t});return(0,ay.useMemo)(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}var Oi=A(X(),1);function _A(t){let e=t+"CollectionProvider",[n,i]=As(e),[r,s]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=h=>{let{scope:m,children:v}=h,w=Oi.default.useRef(null),f=Oi.default.useRef(new Map).current;return Oi.default.createElement(r,{scope:m,itemMap:f,collectionRef:w},v)},a=t+"CollectionSlot",l=Oi.default.forwardRef((h,m)=>{let{scope:v,children:w}=h,f=s(a,v),g=lr(m,f.collectionRef);return Oi.default.createElement(Il,{ref:g},w)}),c=t+"CollectionItemSlot",u="data-radix-collection-item",d=Oi.default.forwardRef((h,m)=>{let{scope:v,children:w,...f}=h,g=Oi.default.useRef(null),y=lr(m,g),T=s(c,v);return Oi.default.useEffect(()=>(T.itemMap.set(g,{ref:g,...f}),()=>void T.itemMap.delete(g))),Oi.default.createElement(Il,{[u]:"",ref:y},w)});function p(h){let m=s(t+"CollectionConsumer",h);return Oi.default.useCallback(()=>{let w=m.collectionRef.current;if(!w)return[];let f=Array.from(w.querySelectorAll(`[${u}]`));return Array.from(m.itemMap.values()).sort((T,P)=>f.indexOf(T.ref.current)-f.indexOf(P.ref.current))},[m.collectionRef,m.itemMap])}return[{Provider:o,Slot:l,ItemSlot:d},p,i]}var kA=["PageUp","PageDown"],TA=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],EA={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},lp="Slider",[Kk,Y9,Q9]=_A(lp),[SA,Zee]=As(lp,[Q9]),[X9,ly]=SA(lp),Z9=(0,re.forwardRef)((t,e)=>{let{name:n,min:i=0,max:r=100,step:s=1,orientation:o="horizontal",disabled:a=!1,minStepsBetweenThumbs:l=0,defaultValue:c=[i],value:u,onValueChange:d=()=>{},onValueCommit:p=()=>{},inverted:h=!1,...m}=t,[v,w]=(0,re.useState)(null),f=lr(e,q=>w(q)),g=(0,re.useRef)(new Set),y=(0,re.useRef)(0),T=o==="horizontal",P=v?!!v.closest("form"):!0,k=T?J9:eB,[M=[],I]=FL({prop:u,defaultProp:c,onChange:q=>{var W;(W=[...g.current][y.current])===null||W===void 0||W.focus(),d(q)}}),O=(0,re.useRef)(M);function b(q){let W=cB(M,q);H(q,W)}function ee(q){H(q,y.current)}function U(){let q=O.current[y.current];M[y.current]!==q&&p(M)}function H(q,W,{commit:xe}={commit:!1}){let Fe=hB(s),yt=fB(Math.round((q-i)/s)*s+i,Fe),tt=Wk(yt,[i,r]);I((_=[])=>{let Ie=aB(_,tt,W);if(pB(Ie,l*s)){y.current=Ie.indexOf(tt);let Rt=String(Ie)!==String(_);return Rt&&xe&&p(Ie),Rt?Ie:_}else return _})}return(0,re.createElement)(X9,{scope:t.__scopeSlider,disabled:a,min:i,max:r,valueIndexToChangeRef:y,thumbs:g.current,values:M,orientation:o},(0,re.createElement)(Kk.Provider,{scope:t.__scopeSlider},(0,re.createElement)(Kk.Slot,{scope:t.__scopeSlider},(0,re.createElement)(k,mt({"aria-disabled":a,"data-disabled":a?"":void 0},m,{ref:f,onPointerDown:Vo(m.onPointerDown,()=>{a||(O.current=M)}),min:i,max:r,inverted:h,onSlideStart:a?void 0:b,onSlideMove:a?void 0:ee,onSlideEnd:a?void 0:U,onHomeKeyDown:()=>!a&&H(i,0,{commit:!0}),onEndKeyDown:()=>!a&&H(r,M.length-1,{commit:!0}),onStepKeyDown:({event:q,direction:W})=>{if(!a){let yt=kA.includes(q.key)||q.shiftKey&&TA.includes(q.key)?10:1,tt=y.current,_=M[tt],Ie=s*yt*W;H(_+Ie,tt,{commit:!0})}}})))),P&&M.map((q,W)=>(0,re.createElement)(oB,{key:W,name:n?n+(M.length>1?"[]":""):void 0,value:q})))}),[PA,CA]=SA(lp,{startEdge:"left",endEdge:"right",size:"width",direction:1}),J9=(0,re.forwardRef)((t,e)=>{let{min:n,max:i,dir:r,inverted:s,onSlideStart:o,onSlideMove:a,onSlideEnd:l,onStepKeyDown:c,...u}=t,[d,p]=(0,re.useState)(null),h=lr(e,y=>p(y)),m=(0,re.useRef)(),v=vA(r),w=v==="ltr",f=w&&!s||!w&&s;function g(y){let T=m.current||d.getBoundingClientRect(),P=[0,T.width],M=Gk(P,f?[n,i]:[i,n]);return m.current=T,M(y-T.left)}return(0,re.createElement)(PA,{scope:t.__scopeSlider,startEdge:f?"left":"right",endEdge:f?"right":"left",direction:f?1:-1,size:"width"},(0,re.createElement)(MA,mt({dir:v,"data-orientation":"horizontal"},u,{ref:h,style:{...u.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:y=>{let T=g(y.clientX);o?.(T)},onSlideMove:y=>{let T=g(y.clientX);a?.(T)},onSlideEnd:()=>{m.current=void 0,l?.()},onStepKeyDown:y=>{let P=EA[f?"from-left":"from-right"].includes(y.key);c?.({event:y,direction:P?-1:1})}})))}),eB=(0,re.forwardRef)((t,e)=>{let{min:n,max:i,inverted:r,onSlideStart:s,onSlideMove:o,onSlideEnd:a,onStepKeyDown:l,...c}=t,u=(0,re.useRef)(null),d=lr(e,u),p=(0,re.useRef)(),h=!r;function m(v){let w=p.current||u.current.getBoundingClientRect(),f=[0,w.height],y=Gk(f,h?[i,n]:[n,i]);return p.current=w,y(v-w.top)}return(0,re.createElement)(PA,{scope:t.__scopeSlider,startEdge:h?"bottom":"top",endEdge:h?"top":"bottom",size:"height",direction:h?1:-1},(0,re.createElement)(MA,mt({"data-orientation":"vertical"},c,{ref:d,style:{...c.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:v=>{let w=m(v.clientY);s?.(w)},onSlideMove:v=>{let w=m(v.clientY);o?.(w)},onSlideEnd:()=>{p.current=void 0,a?.()},onStepKeyDown:v=>{let f=EA[h?"from-bottom":"from-top"].includes(v.key);l?.({event:v,direction:f?-1:1})}})))}),MA=(0,re.forwardRef)((t,e)=>{let{__scopeSlider:n,onSlideStart:i,onSlideMove:r,onSlideEnd:s,onHomeKeyDown:o,onEndKeyDown:a,onStepKeyDown:l,...c}=t,u=ly(lp,n);return(0,re.createElement)(rp.span,mt({},c,{ref:e,onKeyDown:Vo(t.onKeyDown,d=>{d.key==="Home"?(o(d),d.preventDefault()):d.key==="End"?(a(d),d.preventDefault()):kA.concat(TA).includes(d.key)&&(l(d),d.preventDefault())}),onPointerDown:Vo(t.onPointerDown,d=>{let p=d.target;p.setPointerCapture(d.pointerId),d.preventDefault(),u.thumbs.has(p)?p.focus():i(d)}),onPointerMove:Vo(t.onPointerMove,d=>{d.target.hasPointerCapture(d.pointerId)&&r(d)}),onPointerUp:Vo(t.onPointerUp,d=>{let p=d.target;p.hasPointerCapture(d.pointerId)&&(p.releasePointerCapture(d.pointerId),s(d))})}))}),tB="SliderTrack",nB=(0,re.forwardRef)((t,e)=>{let{__scopeSlider:n,...i}=t,r=ly(tB,n);return(0,re.createElement)(rp.span,mt({"data-disabled":r.disabled?"":void 0,"data-orientation":r.orientation},i,{ref:e}))}),bA="SliderRange",iB=(0,re.forwardRef)((t,e)=>{let{__scopeSlider:n,...i}=t,r=ly(bA,n),s=CA(bA,n),o=(0,re.useRef)(null),a=lr(e,o),l=r.values.length,c=r.values.map(p=>$A(p,r.min,r.max)),u=l>1?Math.min(...c):0,d=100-Math.max(...c);return(0,re.createElement)(rp.span,mt({"data-orientation":r.orientation,"data-disabled":r.disabled?"":void 0},i,{ref:a,style:{...t.style,[s.startEdge]:u+"%",[s.endEdge]:d+"%"}}))}),xA="SliderThumb",rB=(0,re.forwardRef)((t,e)=>{let n=Y9(t.__scopeSlider),[i,r]=(0,re.useState)(null),s=lr(e,a=>r(a)),o=(0,re.useMemo)(()=>i?n().findIndex(a=>a.ref.current===i):-1,[n,i]);return(0,re.createElement)(sB,mt({},t,{ref:s,index:o}))}),sB=(0,re.forwardRef)((t,e)=>{let{__scopeSlider:n,index:i,...r}=t,s=ly(xA,n),o=CA(xA,n),[a,l]=(0,re.useState)(null),c=lr(e,w=>l(w)),u=DL(a),d=s.values[i],p=d===void 0?0:$A(d,s.min,s.max),h=lB(i,s.values.length),m=u?.[o.size],v=m?uB(m,p,o.direction):0;return(0,re.useEffect)(()=>{if(a)return s.thumbs.add(a),()=>{s.thumbs.delete(a)}},[a,s.thumbs]),(0,re.createElement)("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[o.startEdge]:`calc(${p}% + ${v}px)`}},(0,re.createElement)(Kk.ItemSlot,{scope:t.__scopeSlider},(0,re.createElement)(rp.span,mt({role:"slider","aria-label":t["aria-label"]||h,"aria-valuemin":s.min,"aria-valuenow":d,"aria-valuemax":s.max,"aria-orientation":s.orientation,"data-orientation":s.orientation,"data-disabled":s.disabled?"":void 0,tabIndex:s.disabled?void 0:0},r,{ref:c,style:d===void 0?{display:"none"}:t.style,onFocus:Vo(t.onFocus,()=>{s.valueIndexToChangeRef.current=i})}))))}),oB=t=>{let{value:e,...n}=t,i=(0,re.useRef)(null),r=wA(e);return(0,re.useEffect)(()=>{let s=i.current,o=window.HTMLInputElement.prototype,l=Object.getOwnPropertyDescriptor(o,"value").set;if(r!==e&&l){let c=new Event("input",{bubbles:!0});l.call(s,e),s.dispatchEvent(c)}},[r,e]),(0,re.createElement)("input",mt({style:{display:"none"}},n,{ref:i,defaultValue:e}))};function aB(t=[],e,n){let i=[...t];return i[n]=e,i.sort((r,s)=>r-s)}function $A(t,e,n){let s=100/(n-e)*(t-e);return Wk(s,[0,100])}function lB(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}function cB(t,e){if(t.length===1)return 0;let n=t.map(r=>Math.abs(r-e)),i=Math.min(...n);return n.indexOf(i)}function uB(t,e,n){let i=t/2,s=Gk([0,50],[0,i]);return(i-s(e)*n)*n}function dB(t){return t.slice(0,-1).map((e,n)=>t[n+1]-e)}function pB(t,e){if(e>0){let n=dB(t);return Math.min(...n)>=e}return!0}function Gk(t,e){return n=>{if(t[0]===t[1]||e[0]===e[1])return e[0];let i=(e[1]-e[0])/(t[1]-t[0]);return e[0]+i*(n-t[0])}}function hB(t){return(String(t).split(".")[1]||"").length}function fB(t,e){let n=Math.pow(10,e);return Math.round(t*n)/n}var Yk=Z9,RA=nB,IA=iB,LA=rB;var AA=A(X());var Dl=A(_e()),cy=AA.forwardRef(({className:t,variant:e="regular",autoHidden:n,children:i,...r},s)=>(0,Dl.jsxs)(Yk,{ref:s,className:vi("group relative flex w-full touch-none select-none items-center",t),...r,children:[(0,Dl.jsx)(RA,{className:"relative h-slider-track w-full grow overflow-hidden rounded-sm bg-slider-track",children:(0,Dl.jsx)(IA,{className:"absolute h-full bg-ia-accent rounded-sm will-change-[width]"})}),(0,Dl.jsx)(LA,{className:vi("block rounded-slider-thumb border-width-slider-thumb border-slider-thumb bg-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mod-border-focus disabled:pointer-events-none disabled:opacity-50 transition-opacity will-change-[left]",e==="regular"?"h-slider-thumb w-slider-thumb":"h-slider-thumb-sm w-slider-thumb-sm",n&&"opacity-0 group-hocus:opacity-100 focus:opacity-100")}),i]}));cy.displayName=Yk.displayName;var Ns=A(_e());function dy(){let t=Oe("volume"),e=Oe("canSetVolume"),n=bg();return e?(0,Ns.jsx)(cy,{className:"group relative inline-flex h-10 w-full max-w-[80px] cursor-pointer touch-none select-none items-center outline-none",value:[t*100],onValueChange:([i])=>{n.changeVolume(i/100)},"aria-label":"Volume",autoHidden:!0}):null}function py({thumbnails:t}){let e=Oe("currentTime"),n=Oe("canSeek"),i=Oe("duration"),r=Oe("seeking"),s=bg(),o=1/i*100,[a,l]=(0,uy.useState)(0),{previewRootRef:c,previewRef:u,previewValue:d}=cI({clamp:!0,offset:6,orientation:"horizontal"}),p=d/100*i;return(0,uy.useEffect)(()=>{r||l(e/i*100)},[e,i,r]),(0,Ns.jsx)(cy,{className:"group relative inline-flex h-9 w-full cursor-pointer touch-none select-none items-center outline-none",value:[a],disabled:!n,step:Number.isFinite(o)?o:1,ref:c,onValueChange:([h])=>{l(h),s.seeking(h/100*i)},onValueCommit:([h])=>{s.seek(h/100*i)},autoHidden:!0,"aria-label":"Current Time",children:(0,Ns.jsxs)("div",{className:"flex flex-col items-center absolute opacity-0 data-[visible]:opacity-100 transition-opacity duration-200 will-change-[left] pointer-events-none",ref:u,children:[t?(0,Ns.jsx)(mg.Root,{src:t,time:p,className:"block mb-2 h-[var(--thumbnail-height)] max-h-[160px] min-h-[80px] w-[var(--thumbnail-width)] min-w-[120px] max-w-[180px] overflow-hidden border border-white bg-black",children:(0,Ns.jsx)(mg.Img,{})}):null,(0,Ns.jsx)("span",{className:"text-[13px]",children:Ms(p)})]})})}var Nl=A(_e());function hy(){return(0,Nl.jsxs)("div",{className:"ml-2.5 flex items-center text-sm font-medium",children:[(0,Nl.jsx)(Od,{className:"time",type:"current"}),(0,Nl.jsx)("div",{className:"mx-1 text-white/80",children:"/"}),(0,Nl.jsx)(Od,{className:"time",type:"duration"})]})}var cp=A(_e());function fy(){let t=Oe("title").trim(),e=vg().trim();return!t&&!e?null:(0,cp.jsxs)("span",{className:"inline-block flex-1 overflow-hidden text-ellipsis whitespace-nowrap px-2 text-sm font-medium text-white/70",children:[(0,cp.jsx)("span",{className:"mr-1",children:"|"}),(0,cp.jsx)("span",{children:e||t})]})}var Se=A(_e());function NA({thumbnails:t}){return(0,Se.jsxs)(Se.Fragment,{children:[(0,Se.jsx)(gB,{}),(0,Se.jsx)(Ur.Root,{className:"opacity-100 absolute inset-0 z-10 flex h-full w-full flex-col bg-gradient-to-t from-black/10 to-transparent",children:(0,Se.jsxs)(Qg,{children:[(0,Se.jsx)("div",{className:"flex-1"}),(0,Se.jsx)(Ur.Group,{className:"flex w-full items-center px-2",children:(0,Se.jsx)(py,{thumbnails:t})}),(0,Se.jsxs)(Ur.Group,{className:"-mt-0.5 flex w-full items-center px-2 pb-2",children:[(0,Se.jsx)(lA,{seconds:30}),(0,Se.jsx)(ey,{}),(0,Se.jsx)(aA,{seconds:30}),(0,Se.jsx)(ry,{}),(0,Se.jsx)(iy,{}),(0,Se.jsx)(ty,{}),(0,Se.jsx)(dy,{}),(0,Se.jsx)(hy,{}),(0,Se.jsx)(fy,{}),(0,Se.jsx)("div",{className:"flex-1"}),(0,Se.jsx)(ny,{}),(0,Se.jsx)(sy,{}),(0,Se.jsx)(oy,{})]})]})})]})}function gB(){return(0,Se.jsxs)(Se.Fragment,{children:[(0,Se.jsx)(hi,{className:"absolute inset-0 z-0 block h-full w-full",event:"pointerup",action:"toggle:paused"}),(0,Se.jsx)(hi,{className:"absolute inset-0 z-0 block h-full w-full",event:"dblpointerup",action:"toggle:fullscreen"}),(0,Se.jsx)(hi,{className:"absolute left-0 top-0 z-10 block h-full w-1/5",event:"dblpointerup",action:"seek:-10"}),(0,Se.jsx)(hi,{className:"absolute right-0 top-0 z-10 block h-full w-1/5",event:"dblpointerup",action:"seek:10"})]})}var be=A(_e());function OA({thumbnails:t}){return(0,be.jsxs)(be.Fragment,{children:[(0,be.jsx)(yB,{}),(0,be.jsx)(wg,{className:"mx-captions media-preview:opacity-0 media-controls:bottom-[85px] media-captions:opacity-100 absolute inset-0 bottom-2 z-10 select-none break-words opacity-0 transition-[opacity,bottom] duration-300"}),(0,be.jsx)(Ur.Root,{className:"media-controls:opacity-100 not-media-can-load:opacity-100 absolute inset-0 z-10 flex h-full w-full flex-col bg-gradient-to-t from-black/10 to-transparent opacity-0 transition-opacity",children:(0,be.jsxs)(Qg,{children:[(0,be.jsx)("div",{className:"flex-1"}),(0,be.jsx)(Ur.Group,{className:"flex w-full items-center px-2",children:(0,be.jsx)(py,{thumbnails:t})}),(0,be.jsxs)(Ur.Group,{className:"-mt-0.5 flex w-full items-center px-2 pb-2",children:[(0,be.jsx)(ey,{}),(0,be.jsx)(ry,{}),(0,be.jsx)(iy,{}),(0,be.jsx)(ty,{}),(0,be.jsx)(dy,{}),(0,be.jsx)(hy,{}),(0,be.jsx)(fy,{}),(0,be.jsx)("div",{className:"flex-1"}),(0,be.jsx)(gA,{}),(0,be.jsx)(sy,{}),(0,be.jsx)(uA,{}),(0,be.jsx)(cA,{}),(0,be.jsx)(ny,{}),(0,be.jsx)(oy,{})]})]})})]})}function yB(){return(0,be.jsxs)(be.Fragment,{children:[(0,be.jsx)(hi,{className:"absolute inset-0 z-0 block h-full w-full",event:"pointerup",action:"toggle:paused"}),(0,be.jsx)(hi,{className:"absolute inset-0 z-0 block h-full w-full",event:"dblpointerup",action:"toggle:fullscreen"}),(0,be.jsx)(hi,{className:"absolute left-0 top-0 z-10 block h-full w-1/5",event:"dblpointerup",action:"seek:-10"}),(0,be.jsx)(hi,{className:"absolute right-0 top-0 z-10 block h-full w-1/5",event:"dblpointerup",action:"seek:10"})]})}var WA=A(X());var up=class{constructor(){E(this,"name","webview");E(this,"target")}canPlay({src:e}){return Vd(e)&&AI(e)}mediaType(){return"video"}async load(e){return new mi(this.target,e)}};var Wn=A(X());function my(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}var FA=A(X());function VA(t,e){var n=(0,FA.useState)(function(){return{value:t,callback:e,facade:{get current(){return n.value},set current(i){var r=n.value;r!==i&&(n.value=i,n.callback(i,r))}}}})[0];return n.callback=e,n.facade}var UA=A(X());var zA=new WeakMap;function Qk(t,e){var n=VA(e||null,function(i){return t.forEach(function(r){return my(r,i)})});return UA.useLayoutEffect(function(){var i=zA.get(n);if(i){var r=new Set(i),s=new Set(t),o=n.current;r.forEach(function(a){s.has(a)||my(a,null)}),s.forEach(function(a){r.has(a)||my(a,o)})}zA.set(n,t)},[t]),n}var yy=require("obsidian"),gy={mac:"Mozilla/5.0 (Macintosh; Intel Mac OS X 12.1; rv:95.0) Gecko/20100101 Firefox/95.0",windows:"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:95.0) Gecko/20100101 Firefox/95.0",linux:"Mozilla/5.0 (Linux x86_64; rv:95.0) Gecko/20100101 Firefox/95.0"};function Xk(t){return yy.Platform.isWin?gy.windows:yy.Platform.isMacOS?gy.mac:yy.Platform.isLinux?gy.linux:gy.windows}var jA=A(X()),Zk={onLoadCommit:"load-commit",onDidFinishLoad:"did-finish-load",onDidFailLoad:"did-fail-load",onDidFrameFinishLoad:"did-frame-finish-load",onDidStartLoading:"did-start-loading",onDidStopLoading:"did-stop-loading",onDidAttach:"did-attach",onDomReady:"dom-ready",onPageTitleUpdated:"page-title-updated",onPageFaviconUpdated:"page-favicon-updated",onEnterHtmlFullScreen:"enter-html-full-screen",onLeaveHtmlFullScreen:"leave-html-full-screen",onConsoleMessage:"console-message",onFoundInPage:"found-in-page",onWillNavigate:"will-navigate",onDidStartNavigation:"did-start-navigation",onDidRedirectNavigation:"did-redirect-navigation",onDidNavigate:"did-navigate",onDidFrameNavigate:"did-frame-navigate",onDidNavigateInPage:"did-navigate-in-page",onClose:"close",onIpcMessage:"ipc-message",onCrashed:"crashed",onPluginCrashed:"plugin-crashed",onDestroyed:"destroyed",onMediaStartedPlaying:"media-started-playing",onMediaPaused:"media-paused",onDidChangeThemeColor:"did-change-theme-color",onUpdateTargetUrl:"update-target-url",onDevtoolsOpened:"devtools-opened",onDevtoolsClosed:"devtools-closed",onDevtoolsFocused:"devtools-focused",onContextMenu:"context-menu"};function vB(t){return Object.entries(t).reduce((e,[n,i])=>(n in Zk?e.event[n]=i:e.rest[n]=i,e),{event:{},rest:{}})}function BA(t,e){let{event:n,rest:i}=vB(t);for(let r of Object.keys(Zk)){let s=r,o=Zk[s],a=n[s];(0,jA.useEffect)(()=>{if(!e.current||!a)return;let l=e.current;return l.addEventListener(o,a),()=>{l.removeEventListener(o,a)}},[o,a,e])}return i}var qA=A(_e()),HA=(0,Wn.forwardRef)(function({devtools:e=!1,muted:n=!1,className:i,useragent:r,...s},o){let a=(0,Wn.useRef)(null),[l,c]=(0,Wn.useState)(!1),u=BA(s,a);_B(n,a,l);let d=wB(r??navigator.userAgent,a,l);return(0,Wn.useEffect)(()=>{if(!a.current)return;let p=a.current;return p.addEventListener("dom-ready",h),p.addEventListener("will-navigate",m),()=>{p.removeEventListener("dom-ready",h),p.removeEventListener("will-navigate",m)};function h(){c(!0)}function m(){c(!1)}},[]),(0,qA.jsx)("webview",{ref:Qk([a,o]),className:vi("h-full w-full",i),useragent:d,...u})});function wB(t,e,n){let i=(0,Wn.useMemo)(()=>{let r=t??navigator.userAgent;return Xk(r)},[t]);return(0,Wn.useEffect)(()=>{!e.current||!n||i===e.current.useragent||e.current.setUserAgent(i)},[i,n,e]),i}function _B(t,e,n){(0,Wn.useEffect)(()=>{!e.current||!n||t===e.current.isAudioMuted()||e.current.setAudioMuted(t)},[t,n,e])}var Jk=A(_e());function KA({loaders:t,...e}){let n=Oo(l=>l.appId),i=Oe("viewType"),r=ft(l=>!!l.transform?.flipHorizontal),s=ft(l=>!!l.transform?.flipVertical),o=ft(l=>{if(l.transform?.rotate)switch(l.transform.rotate){case"90":return"rotate-90";case"180":return"rotate-180";case"270":return"rotate-[270deg]";default:return}}),a=Gg();return(0,Jk.jsx)(wk,{className:vi(i==="video"&&r&&"-scale-x-100",i==="video"&&s&&"-scale-y-100",i==="video"&&o),loaders:[up,...t??[]],buildMediaEl:(0,WA.useCallback)((l,c)=>l instanceof up?(0,Jk.jsx)(HA,{"aria-hidden":!0,className:vi("data-[play-ready]:blur-none blur-lg transition-opacity",a&&"pointer-events-none"),webpreferences:"autoplayPolicy=user-gesture-required",partition:Yr(n),ref:u=>{c.load(u)}}):null,[n,a]),...e})}var Fi=A(_e()),GA=A(X());function bB({onViewTypeChange:t}){return CL(t),gL(),$L(),(0,Fi.jsx)(Fi.Fragment,{})}function xB(){let t=Oe("viewType"),e=Gg();return t==="audio"?(0,Fi.jsx)(NA,{}):e?(0,Fi.jsx)(OA,{}):null}function kB(){let t=ft(s=>s.source?.url),{vault:e}=Oo(),n=t?un(t):null,i=(0,vy.useMemo)(()=>{if(t)return ke(t)?e.getResourcePath(t.file):t.source.href},[n]),r=ft(s=>{let o=s.source?.viewType;if(o){if(o==="mx-webpage")return"webpage";if(o?.endsWith("video"))return"video/mp4";if(o?.endsWith("audio"))return"audio/mp3"}});if(i)return r==="webpage"?{src:II(i)}:{src:i,type:r}}function Os(){let t=ft(p=>p.playerRef),{onEnded:e}=qg(),n=kB(),i=ft(({source:p})=>{if(p)return ke(p.url)?p.url.file.extension==="webm":p.url.source.pathname.endsWith(".webm")}),r=ft(({textTracks:p})=>p),s=No(p=>p.loadStrategy),o=Cl(),[a,l]=(0,vy.useState)("unknown"),c=ft(p=>p.title),{controls:u,...d}=Vk();return n?(0,Fi.jsxs)(vk,{className:vi("w-full bg-slate-900 text-white font-sans overflow-hidden rounded-md ring-mod-border-focus data-[focus]:ring-2","data-[view-type=video]:aspect-video data-[view-type=audio]:h-20 data-[view-type=audio]:aspect-auto"),load:o?s:"eager",src:n,playsInline:!0,title:c,viewType:a,ref:t,onEnded:e,onError:p=>{new e0.Notice(createFragment(h=>{switch(h.appendText(`Failed to load media for ${n.src}: `),h.createEl("br"),p.code){case 1:h.appendText("The media playback was aborted");break;case 2:h.appendText("A network error caused the media playback to fail");break;case 3:h.appendText("The media playback was aborted due to a corruption problem or because the media encoding is not supported");break;case 4:h.appendText("The media is not supported to open as regular video or audio, try open as webpage");break;default:h.appendText(p.message||"Unknown error, check console for more details"),console.error("Failed to load media",n.src,p);break}}))},...d,children:[(0,Fi.jsx)(KA,{children:r.map(p=>(0,GA.createElement)(_k,{...p,key:p.id}))}),(0,Fi.jsx)(bB,{onViewTypeChange:p=>{l(p),!i&&p==="audio"&&new e0.Notice("Unable to show video content due to a potentially unsupported codec by Obsidian. For verification, please disable this plugin, add the video to the vault, and check if video playback resumes normally.")}}),(0,Fi.jsx)(xB,{})]}):null}function wy(t,e){let n=new WeakMap,i;t.register(Jd(t.store,r=>[r.subscribe(({currentTime:s,paused:o,playbackRate:a})=>{s!==0&&r.el&&n.set(t.leaf.parent,{currentTime:s,paused:o,playbackRate:a})}),r.listen("can-play",()=>{if(!i)return;let s=n.get(i);if(!s){i=void 0;return}let{currentTime:o,paused:a,playbackRate:l}=s;if(!a)r.play(new Event("recover-state")).then(()=>{r.currentTime=o,r.playbackRate=l,i&&(n.delete(i),i=void 0)}).catch(c=>console.error("recov err play",c));else try{r.currentTime=o,r.playbackRate=l,i&&(n.delete(i),i=void 0)}catch(c){console.error("recov err paused",c)}})])),t.register(EB(t,(r,s)=>{e(),n.has(s)?i=s:i=void 0})),t.register(()=>{i=void 0})}function _y(t,e){let n=new WeakMap,i;t.register(Jd(t.store,r=>[r.subscribe(({currentTime:s,paused:o,playbackRate:a})=>{s!==0&&r.el&&n.set(r.el.win,{currentTime:s,paused:o,playbackRate:a})}),r.listen("can-play",()=>{if(!i)return;let s=n.get(i);if(!s){i=void 0;return}let{currentTime:o,paused:a,playbackRate:l}=s;if(!a)r.play(new Event("recover-state")).then(()=>{r.currentTime=o,r.playbackRate=l,i&&(n.delete(i),i=void 0)}).catch(c=>console.error("recov err play",c));else try{r.currentTime=o,r.playbackRate=l,i&&(n.delete(i),i=void 0)}catch(c){console.error("recov err paused",c)}})])),t.register(TB(t.containerEl,(r,s)=>{e(),n.has(s)?i=s:i=void 0})),t.register(()=>{i=void 0})}function TB(t,e){let n=t.win;return t.onNodeInserted(()=>{let i=t.win;i!==n&&(e(i,n),n=i)})}function EB(t,e){let n=t.containerEl.win,i=t.leaf.parent;return t.containerEl.onNodeInserted(()=>{let r=t.containerEl.win,s=t.leaf.parent;r===n?s!==i&&(e(s,i),i=s):n=r})}var t0=A(_e()),by=class extends xy.EditableFileView{constructor(n,i){super(n);this.plugin=i;E(this,"allowNoFile",!1);E(this,"store");E(this,"scope");E(this,"root",null);this.store=Rs(),this.scope=new xy.Scope(this.app.scope),this.contentEl.addClasses(["mx","custom"]),Fg(this)}onload(){_y(this,()=>this.render())}async onLoadFile(n){await this.store.getState().loadFile(n,{vault:this.app.vault,defaultLang:this.plugin.settings.getState().getDefaultLang()})}onPaneMenu(n,i){super.onPaneMenu(n,i),Vg(this,n,i)}setEphemeralState(n){if("subpath"in n){let{subpath:i}=n;this.store.getState().setHash(i)}super.setEphemeralState(n)}async onOpen(){await super.onOpen(),this.render()}render(){this.root?.unmount(),this.root=YA.default.createRoot(this.contentEl),this.root.render((0,t0.jsx)(Vt.Provider,{value:{plugin:this.plugin,store:this.store,reload:()=>this.render(),onPlaylistChange:n=>{this.plugin.leafOpener.openMediaIn(this.leaf,n.media)},embed:!1},children:(0,t0.jsx)(Os,{})}))}async onClose(){return this.root?.unmount(),this.root=null,super.onClose()}},Ol=class extends by{getIcon(){return"file-video"}getMediaInfo(){return this.file?{type:"video",file:this.file,hash:this.getEphemeralState().subpath}:null}getViewType(){return gn.video}canAcceptExtension(e){return Yt.video.includes(e)}},Fl=class extends by{getIcon(){return"file-audio"}getViewType(){return gn.audio}getMediaInfo(){return this.file?{type:"audio",file:this.file,hash:this.getEphemeralState().subpath}:null}canAcceptExtension(e){return Yt.audio.includes(e)}};var ky=require("obsidian"),QA=A(mu());var n0=A(_e()),Fs=class extends ky.ItemView{constructor(n,i){super(n);this.plugin=i;E(this,"store");E(this,"scope");E(this,"root",null);E(this,"navigation",!0);this.store=Rs(),this.scope=new ky.Scope(this.app.scope),this.contentEl.addClasses(["mx","custom"]),Fg(this)}setSource(n){this.store.getState().setSource(n,{viewType:this.getViewType()})}getMediaInfo(){return this.store.getState().source?.url??null}get sourceType(){return this.store.getState().player?.state.source.type??""}get playerTitle(){return this.store.getState().player?.state.title??""}onload(){let n=this;super.onload(),this.register(vt(this.leaf,{detach:i=>function(...r){return n.root?.unmount(),n.root=null,i.call(this,...r)}})),_y(this,()=>this.render())}registerRemoteTitleChange(){this.register(Jd(this.store,n=>n.subscribe(({title:i})=>{this.updateTitle()})))}onPaneMenu(n,i){super.onPaneMenu(n,i),Vg(this,n,i)}getState(){let n=super.getState(),i=this.store.getState().source?.url;if(ke(i))throw new Error("Remote view don't handle file media");return{...n,source:i?i.jsonState.source:n.source}}async setState(n,i){if(await super.setState(n,i),!("source"in n))return;let r=this.plugin.resolveUrl(n.source);if(!r)console.warn("Invalid URL",n.source);else if(ke(r))console.warn("Open in-vault media in remote view",r);else{let s=this.store.getState().source?.url;ar(r,s)||(await this.setSource(r),this.render())}}setEphemeralState(n){if("subpath"in n){let{subpath:i}=n;this.store.getState().setHash(i)}super.setEphemeralState(n)}async onOpen(){await super.onOpen(),this.render()}updateTitle(){let n=this.getDisplayText();this.titleEl.setText(n),this.app.workspace.activeLeaf===this.leaf&&this.app.workspace.requestActiveLeafEvents()&&this.leaf.updateHeader()}render(){this.root&&this.root.unmount(),this.root=QA.default.createRoot(this.contentEl),this.root.render((0,n0.jsx)(Vt.Provider,{value:{plugin:this.plugin,store:this.store,reload:()=>this.render(),onPlaylistChange:n=>{n.media.hash+="&play",this.plugin.leafOpener.openMediaIn(this.leaf,n.media)},embed:!1},children:(0,n0.jsx)(Os,{})}))}close(){return this.root?.unmount(),this.root=null,super.close()}async onClose(){return this.root?.unmount(),this.root=null,super.onClose()}};var SB={"video/vimeo":"Vimeo","video/youtube":"YouTube"},Vl=class extends Fs{onload(){super.onload(),this.registerRemoteTitleChange(),wy(this,()=>this.render())}getDisplayText(){let e=SB[this.sourceType]??"Embed";return this.playerTitle?`${this.playerTitle} - ${e}`:e}getIcon(){switch(this.sourceType){case"video/youtube":return"youtube";case"video/vimeo":return"vimeo";default:return"video"}}getViewType(){return Xs}};var Ty=class extends Fs{},zl=class extends Ty{getIcon(){return"file-video"}getViewType(){return Xt.video}getDisplayText(){return this.playerTitle||"Video"}async setSource(e){let n=this.plugin.settings.getState().getDefaultLang(),i=await Dg(e,n).catch(r=>(console.error("Failed to get text tracks",r,e.href,n),[]));this.store.getState().setSource(e,{title:!0,textTracks:i,viewType:this.getViewType()})}},Ul=class extends Ty{getIcon(){return"file-audio"}getDisplayText(){return this.playerTitle||"Audio"}getViewType(){return Xt.audio}async setSource(e){this.store.getState().setSource(e,{title:!0,viewType:this.getViewType()})}};var jl=class extends Fs{onload(){super.onload(),this.registerRemoteTitleChange(),wy(this,()=>this.render())}getViewType(){return Jn}getIcon(){let e=this.getHost();return e==="generic"?"globe":e}getHost(){let{source:e}=this.store.getState();if(ke(e?.url))throw new Error("Cannot get host for file");return e?.url?e.url.type:"generic"}getDisplayText(){return this.playerTitle?`${this.playerTitle} - ${Mp[this.getHost()]}`:"Webpage"}};function XA(t,e){if(!(t.view instanceof Ol||t.view instanceof Fl))return!1;let{file:n}=t.view.getState();return n===e.file.path}function ZA(t,e){if(!(t.view instanceof Vl||t.view instanceof jl||t.view instanceof zl||t.view instanceof Ul))return!1;let{source:n}=t.view.store.getState();return ar(n?.url,e)}function i0(t,e){let n=t.stat.mtime,i=e.stat.mtime;return!n||!i?0:i-n}var Ey="mx-media-active",Py,e2,Cy,t2,My,n2,Sy=class extends Bl.Component{constructor(n){super();this.plugin=n;Y(this,Py);Y(this,Cy);Y(this,My);E(this,"app");E(this,"activeMediaLeaf",null);E(this,"onLeafUpdate",(0,Bl.debounce)(n=>{n=n??this.workspace.activeLeaf,this.onActiveLeafChange(n)},200));this.app=n.app}onload(){let n=this.app.workspace;n.onLayoutReady(()=>{this.onLeafUpdate()}),this.registerEvent(n.on("active-leaf-change",i=>{this.onLeafUpdate(i)})),this.registerEvent(n.on("layout-change",()=>{this.onLeafUpdate()}))}onunload(){this.applyActiveMediaLeaf(null)}get workspace(){return this.app.workspace}onActiveLeafChange(n){let i=this.detectActiveMediaLeaf(n);this.activeMediaLeaf!==i&&this.applyActiveMediaLeaf(i)}applyActiveMediaLeaf(n){this.activeMediaLeaf?.tabHeaderEl.removeClass(Ey),this.activeMediaLeaf?.containerEl.removeClass(Ey),n?.tabHeaderEl.addClass(Ey),n?.containerEl.addClass(Ey),this.activeMediaLeaf=n}detectActiveMediaLeaf(n){let i=()=>{let r=this.findPinnedPlayer();if(r)return r;let s=JA(this.workspace),{activeTabGroup:o}=this.workspace;return(!n||!o?s:s.filter(l=>!o.children.includes(l))).at(0)??null};if(!n)return i();if(r0(n))return n;if(n.view instanceof Bl.MarkdownView&&n.view.file){let{mediaNote:r}=this.plugin,s=r.findMedia(n.view.file);if(s)return this.findPlayerWithSameMedia(s)}return i()}findPlayerWithSameMedia(n){for(let i of this.plugin.urlViewType.getSupported(n)){let r=PB(n,i,this.workspace);if(r.length>0)return r[0]}return null}findPinnedPlayer(){return JA(this.workspace).filter(n=>n.pinned)[0]??null}get settings(){return this.plugin.settings.getState()}getSplitBehavior(n,i){if(!i)return Xr(n)??!1;n=Xr(n);let{defaultMxLinkClick:{click:r,alt:s}}=this.settings;return r===null?n??!1:n===void 0||n===!1?r:s!==null&&n===r?s:n}async openMedia(n,i,{direction:r,viewType:s,fromUser:o=!1}={}){let{workspace:a}=this.app;if(!i){let u=await F(this,Py,e2).call(this,n,s);if(u)return u}let l=this.getSplitBehavior(i,o),c;return l==="split-horizontal"?c=a.getLeaf("split",r??"horizontal"):c=a.getLeaf(l,r),this.openMediaIn(c,n,s)}async openMediaIn(n,i,r){if(ke(i))await n.openFile(i.file,{eState:{subpath:i.hash},active:!0});else{let{hash:s,source:o}=i.jsonState,a={source:o};r??(r=this.plugin.urlViewType.getPreferred(i)),await n.setViewState({type:r,state:a,active:!0},{subpath:s})}return n}async openNote(n,i,r="split",s="vertical"){let o=this.plugin.mediaNote.findNotes(n),a=F(this,Cy,t2).call(this,o);if(a)return a.getMode()!=="source"&&await a.setState({mode:"source"},{history:!1}),a;let l;if(o.length===0){let d=`Media Note - ${eh(i.title)}`;l=await F(this,My,n2).call(this,d,i.fm,i.sourcePath??"")}else l=o.sort(i0).at(0);let c=this.app.workspace.getLeaf(r,s);return await c.openFile(l,{state:{mode:"source"}}),{file:l,editor:c.view.editor}}};Py=new WeakSet,e2=async function(n,i){let r=this.findPinnedPlayer();if(r)return await this.openMediaIn(r,n,i);let s=this.findPlayerWithSameMedia(n);return s?(CB(n.hash,s),s):null},Cy=new WeakSet,t2=function(n){let{workspace:i}=this.app,r=i.getLeavesOfType("markdown").filter(o=>{let a=o.view.file?.path;return!!a&&n.some(l=>l.path===a)});return r.length===0?null:(r.find(o=>o===i.activeLeaf)??r.sort((o,a)=>i0(o.view.file,a.view.file)).at(0)).view},My=new WeakSet,n2=async function(n,i,r=""){let{fileManager:s}=this.app,o=s.getNewFileParent(r,n),a=await s.createNewFile(o,n,"md",`--- --- `);return await s.processFrontMatter(a,l=>{Object.assign(l,i(a.path))}),a};function JA(t){let e=[];return t.iterateAllLeaves(n=>{Lv(n.view.getViewType())&&e.push(n)}),e.sort($y),e}function PB(t,e,n){let i=n.getLeavesOfType(e).filter(r=>ke(t)?XA(r,t):ZA(r,t));return i.sort($y),i}function r0(t){return!!t&&Lv(t.view.getViewType())}function $y(t,e){return e.activeTime-t.activeTime}function CB(t,e){e.setEphemeralState({subpath:t})}function MB(t,e,n){return i=>{let r=n.workspace.activeEditor;if(!r)return t?t(i):void 0;if(e&&r.getMode()!=="preview")return r instanceof Ry.MarkdownView&&r.inlineTitleEl.isActiveElement()?void 0:e(i,r.editor,r)}}function Vs({playerCheckCallback:t,noteCheckCallback:e,...n},i){let{app:r}=i,s=i.addCommand({...n,checkCallback:MB(t&&(o=>!t||!r0(r.workspace.activeLeaf)?!1:o?!0:t(o,r.workspace.activeLeaf.view)),e&&((o,a,l)=>{if(!l.file)return!1;let c=i.mediaNote.findMedia(l.file),u=i.leafOpener.detectActiveMediaLeaf(r.workspace.activeLeaf);return e(o,u?.view,{isMediaNote:c,file:l.file,editor:a})}),r)});return!e||!n.menu||i.registerEvent(i.app.workspace.on("editor-menu",(o,a,l)=>{if(!l.file)return!1;let c=i.mediaNote.findMedia(l.file),u=i.leafOpener.detectActiveMediaLeaf(r.workspace.activeLeaf);if(!e(!0,u?.view,{isMediaNote:c,file:l.file,editor:a}))return;let d=l.file;o.addItem(p=>{n.icon&&p.setIcon(n.icon),n.name&&p.setTitle(n.name),n.section&&p.setSection(n.section),p.onClick(()=>{e(!1,u?.view,{isMediaNote:c,file:d,editor:a})})})})),s}function i2(t,{onKeyDown:e,onTrigger:n,onKeyUp:i}){let r=null,s=new Set;return t.register(()=>{s.forEach(o=>{window.removeEventListener("keyup",o,{capture:!0})})}),t.registerDomEvent(window,"keydown",o=>{if(!r)return;let a=o.target;if(a.instanceOf(HTMLElement)&&a.matches("input.prompt-input"))return;let l=o;if(e(o,...r),i){let c=r,u=d=>{let p=$B(l);(d.code===l.code&&p.every(h=>Ry.Keymap.isModifier(d,h))||p.some(h=>d.key===h))&&(i(d,...c),window.removeEventListener("keyup",u,{capture:!0}),s.delete(u))};s.add(u),window.addEventListener("keyup",u,{passive:!0,capture:!0})}r=null},!0),{callback:(...o)=>{r=o,setTimeout(()=>{r===null||(n?.(...o),r=null)},0)}}}function $B(t){let e=[];return t.ctrlKey&&e.push("Ctrl"),t.altKey&&e.push("Alt"),t.shiftKey&&e.push("Shift"),t.metaKey&&e.push("Meta"),e}var RB=t=>[{id:"toggle-play",label:"Play/pause",icon:"play",action:e=>{e.paused=!e.paused}},...[.5,1,2,5,10,30,60].flatMap(e=>[{id:`forward-${e}s`,label:`Forward ${e}s`,icon:"forward",action:n=>{n.currentTime+=e},repeat:!0},{id:`rewind-${e}s`,label:`Rewind ${e}s`,icon:"rewind",action:n=>{n.currentTime-=e},repeat:!0}]),{id:"toggle-mute",label:"Mute/unmute",icon:"volume-x",action:e=>{e.muted=!e.muted}},{id:"toggle-fullscreen",label:"Enter/exit fullscreen",icon:"expand",check:e=>e.state.canFullscreen,action:e=>{e.state.fullscreen?e.exitFullscreen():e.enterFullscreen()}},...IB(t)];function IB(t){let e=null,n=(0,Hl.debounce)(()=>e?.hide(),2e3,!0);function i(o){!e||e.noticeEl.isConnected===!1?e=new Hl.Notice(o,0):e.setMessage(o),n()}function r(o){!e||e.noticeEl.isConnected===!1?e=new Hl.Notice(o,0):e.setMessage(o)}function s(o){new Hl.Notice(o,2e3)}return[...ei.filter(o=>o>1).map(o=>{let a=!1,{callback:l}=i2(t,{onKeyDown(c,u){c.repeat&&(a=!0,u.playbackRate=o,r(`Fast forwarding at ${o}x`))},onKeyUp(c,u){a&&(u.playbackRate=1,e?.hide())}});return{id:`fast-forward-${o}x`,label:`Fast forward at ${o}x by holding hotkey`,icon:"forward",action:l,repeat:!0}}),...ei.map(o=>({id:`set-speed-${o}x`,label:`Set playback speed to ${o}x`,icon:"gauge",action:async a=>{a.playbackRate=o,i(`Speed set to ${o}x`)}})),{id:"reset-speed",label:"Reset playback speed",icon:"reset",check:o=>o.state.playbackRate!==1,action:o=>{o.playbackRate=1,s("Speed reset to 1x")}},{id:"increase-speed",label:"Increase playback speed",icon:"arrow-up",action:o=>{let a=o.playbackRate;if(a>=ei.last()){s("Cannot increase speed further");return}let l=ei.find(c=>c>a);o.playbackRate=l,i(`Speed increased to ${l}x`)}},{id:"decrease-speed",label:"Decrease playback speed",icon:"arrow-down",action:o=>{let a=o.playbackRate;if(a<=ei.first()){s("Cannot decrease speed further");return}let l=ei.slice().reverse().find(c=>c{let a=await va.run();a&&(o.playbackRate=a,i(`Speed set to ${a}x`))}},{id:"increase-speed-granular",label:"Increase playback speed slightly",icon:"arrow-up",action:o=>{let a=o.playbackRate;if(a>=ei.last()){s("Cannot increase speed further");return}let l=t.settings.getState().speedStep,c=Math.round((a+l)*100)/100;o.playbackRate=c,i(`Speed increased to ${c}x`)}},{id:"decrease-speed-granular",label:"Decrease playback speed by 0.1x",icon:"arrow-down",action:o=>{let a=o.playbackRate;if(a<=ei.first()){s("Cannot decrease speed further");return}let l=t.settings.getState().speedStep,c=Math.round((a-l)*100)/100;o.playbackRate=c,i(`Speed decreased to ${c}x`)}}]}function r2(t){RB(t).forEach(({id:e,label:n,icon:i,action:r,repeat:s,check:o})=>{Vs({id:e,name:n,icon:i,repeatable:s,playerCheckCallback:(a,l)=>{if(!l)return!1;let c=l.store.getState().player;if(!c||o&&!o(c))return!1;if(a)return!0;r(c)},noteCheckCallback(a,l){if(!l)return!1;let c=l.store.getState().player;if(!c||o&&!o(c))return!1;if(a)return!0;if(c.el?.doc){let u=window.activeDocument;window.activeDocument=c.el.doc,r(c),window.activeDocument=u}else r(c)}},t)})}var Iy=require("obsidian");function s2(t){let e=null;Vs({id:"copy-screenshot",name:"Copy screenshot",icon:"focus",playerCheckCallback(i,r){if(i)return!0;let s=Ng(r);s&&Gd(s)},noteCheckCallback:n(i=>{let r=Ng(i);r&&Gd(r)}).noteCheckCallback},t),Vs({id:"take-timestamp",name:"Take timestamp",icon:"star",menu:!0,section:"selection-link",...n(async(i,r)=>{let s=e;e=r.file,await Qd(i,r)&&r.from==="player"&&s!==r.file&&new Iy.Notice(`Timestamp taken in "${r.file.basename}"`)})},t),Vs({id:"save-screenshot",name:"Save screenshot",icon:"camera",section:"selection-link",menu:!0,...n(async(i,r)=>{let s=e;e=r.file,await Kd(i,r)&&r.from==="player"&&s!==r.file&&new Iy.Notice(`Taking screenshot in "${r.file.basename}"`)})},t),Vs({id:"take-timestamp-media-note",name:"Take timestamp in media note",icon:"star",menu:!0,section:"selection-link",playerCheckCallback(i,r){let s=r.getMediaInfo();if(!s)return!1;if(i)return!0;na(s,r).then(o=>Qd(r,o))}},t),Vs({id:"save-screenshot-media-note",name:"Save screenshot in media note",icon:"camera",section:"selection-link",menu:!0,playerCheckCallback(i,r){let s=r.getMediaInfo();if(!s)return!1;if(i)return!0;na(s,r).then(o=>Kd(r,o))}},t);function n(i){return{playerCheckCallback:(r,s)=>{let o=LB(t.app);if(!o){if(r)return!1;new Iy.Notice("No active note can be edited");return}if(r)return!0;(async()=>{let a=window.activeDocument;window.activeDocument=o.containerEl.doc,await i(s,{file:o.view.file,editor:o.view.editor,from:"player"}),window.activeDocument=a})()},noteCheckCallback:(r,s,{isMediaNote:o,...a})=>{let l;if(s){if(r)return!0;t.app.workspace.revealLeaf(s.leaf),l=Promise.resolve(s)}else{if(!o)return!1;if(r)return!0;l=t.leafOpener.openMedia(o,void 0,{fromUser:!0}).then(c=>c.view)}l.then(async c=>{await i(c,{...a,from:"note"})})}}}}function LB(t){return t.workspace.getLeavesOfType("markdown").filter(n=>{let i=n.view;return i.file&&i.getMode()==="source"}).sort($y)[0]??null}function a2(){this.registerEvent(this.app.workspace.on("file-menu",(t,e,n,i)=>{if(!(e instanceof o2.TFile))return;let r=this.mediaNote.findMedia(e);r&&t.addItem(s=>s.setSection("view").setIcon("play").setTitle("Open linked media").onClick(()=>this.leafOpener.openMedia(r,void 0,{fromUser:!0})))})),s2(this),r2(this)}var cr=require("obsidian");var ql=require("obsidian");function Ly(t,e){if(ql.Platform.isDesktopApp&&t.isFileUrl&&t.filePath){let n=t.filePath;e.addItem(i=>i.setIcon("folder").setTitle(ql.Platform.isMacOS?"Reveal in Finder":"Show in system explorer").setSection("view").onClick(()=>{l2(n).catch(r=>{new ql.Notice(`Failed to open file in file explorer: ${r.message}`),console.error("Failed to open file in file explorer",r)})})).addItem(i=>i.setIcon("arrow-up-right").setTitle("Open in default player").setSection("view").onClick(()=>{c2(n).catch(r=>{new ql.Notice(`Failed to open file in system player: ${r.message}`),console.error("Failed to open file in system player",r)})}))}}var u2={"mx-embed":{label:"iframe",icon:"code"},"mx-url-audio":{label:"regular audio",icon:"headphones"},"mx-url-video":{label:"regular video",icon:"film"},"mx-webpage":{label:"webpage",icon:"globe"}};function s0(t,e,n=!1){let i=u2[e].label;return t.setTitle(n?i:`Open as ${i}`).setIcon(u2[e].icon)}function dp(t,{mode:e,plugin:n,targetViewTypes:i,open:r=!0,url:s}){let{protocol:o,hostname:a,pathname:l,host:c,port:u}=s;i.length!==0&&(e==="once"&&i.forEach(d=>{if(!r)throw new Error("openAsMenu: cannot set 'open' to false in 'open once' mode");t.addItem(p=>s0(p,d).setSection("mx-link").onClick(async()=>{await n.leafOpener.openMedia(s,void 0,{viewType:d,fromUser:!0})}))}),e==="always"&&(t.addItem(d=>{let p=d.setTitle("Always open this url as").setIcon("external-link").setSection("mx-link").setSubmenu();i.forEach(h=>{p.addItem(m=>s0(m,h,!0).setSection("mx-link").onClick(async()=>{n.urlViewType.setPreferred({protocol:o,hostname:a,pathname:l,port:u},h),r&&await n.leafOpener.openMedia(s,void 0,{viewType:h,fromUser:!0})}))})}),a&&t.addItem(d=>{let p=d.setTitle(`Always open ${c} as`).setIcon("external-link").setSection("mx-link").setSubmenu();i.forEach(h=>{p.addItem(m=>s0(m,h,!0).setSection("mx-link").onClick(async()=>{n.urlViewType.setPreferred({protocol:o,hostname:a,port:u},h),r&&await n.leafOpener.openMedia(s,void 0,{viewType:h,fromUser:!0})}))})})))}function Wl(t,e){return!!(t.type!=="generic"||t.inferredType||t.tempFrag||e.mediaNote.findNotes(t).length>0||e.urlViewType.getPreferred(t,!0))}var o0=async function(t,e,n){let i=this.resolveUrl(t);if(ke(i)){new cr.Notice("For in-vault media, use internal link instead"),n();return}if(!i||!Wl(i,this)){n();return}await this.leafOpener.openMedia(i,e,{fromUser:!0})};async function l2(t){if(!cr.Platform.isDesktopApp)return;let e=window.electron;if(!e)return;await(cr.Platform.isMacOS?e.remote.shell:e.shell).showItemInFolder(t)}async function c2(t){if(!cr.Platform.isDesktopApp)return;let e=window.electron;if(!e)return;let i=await(cr.Platform.isMacOS?e.remote.shell:e.shell).openPath(t);if(i)throw new Error(i)}function d2(t){t.registerEvent(t.app.workspace.on("url-menu",(e,n)=>{let i=t.resolveUrl(n);if(!i)return;if(ke(i)){new cr.Notice("For in-vault media, use internal link instead");return}Ly(i,e);let r=t.urlViewType.getSupported(i),s=t.urlViewType.getPreferred(i),o=Wl(i,t)?r.filter(a=>a!==s):r;dp(e,{targetViewTypes:o,url:i,mode:"once",plugin:t}),dp(e,{targetViewTypes:o,url:i,mode:"always",plugin:t})}))}var p2=async function(t,e,n,i){let{metadataCache:r}=this.app,{path:s,subpath:o}=(0,cr.parseLinktext)(t),a=r.getFirstLinkpathDest(s,e),l;if(!a||!(l=hn(a.extension))){i();return}let c={file:a,hash:o,type:l,viewType:gn[l]};await this.leafOpener.openMedia(c,n,{fromUser:!0})};var f2=require("obsidian");var Ay=require("obsidian");function*pp(t){for(let e of t.children)e instanceof Ay.TFolder?yield*pp(e):e instanceof Ay.TFile&&(yield e)}function Dy(t,e){return t.initialized?Promise.resolve():new Promise(n=>{let i=t.on("initialized",()=>{t.offref(i),n()});e?.registerEvent(i)})}var h2=require("obsidian");function l0(t,{metadataCache:e,plugin:n}){let i=e.getFileCache(t);if(!i)return null;let r={metadataCache:e,sourcePath:t.path,plugin:n};return a0(Xd.video,i,r)??a0(Xd.audio,i,r)??a0(Xd.generic,i,r)}function a0(t,e,n){let{frontmatter:i,frontmatterLinks:r}=e;if(!i||!(t in i))return null;let s=r?.find(a=>a.key===t);if(s){let{path:a,subpath:l}=(0,h2.parseLinktext)(s.link),c=n.metadataCache.getFirstLinkpathDest(a,n.sourcePath);if(!c)return null;let u=hn(c.extension);return u?{type:u,file:c,hash:l}:null}let o=i[t];return typeof o!="string"?null:n.plugin.resolveUrl(o)}var Ny=class extends f2.Component{constructor(n){super();this.plugin=n;E(this,"app");E(this,"noteToMediaIndex",new Map);E(this,"mediaToNoteIndex",new Map);this.app=n.app}findNotes(n){let i=this.mediaToNoteIndex.get(un(n));return i?[...i]:[]}findMedia(n){return this.noteToMediaIndex.get(n.path)}onResolve(){this.noteToMediaIndex.clear(),this.mediaToNoteIndex.clear();let n={metadataCache:this.app.metadataCache,vault:this.app.vault,plugin:this.plugin};for(let{file:i,mediaInfo:r}of AB(n))this.addMediaNote(r,i);this.registerEvent(this.app.metadataCache.on("changed",i=>{let r=l0(i,n);r&&this.addMediaNote(r,i)})),this.registerEvent(this.app.metadataCache.on("deleted",i=>{this.removeMediaNote(i)})),this.registerEvent(this.app.vault.on("rename",(i,r)=>{if(!this.noteToMediaIndex.has(r))return;let s=this.noteToMediaIndex.get(r);this.noteToMediaIndex.delete(r),this.noteToMediaIndex.set(i.path,s)}))}removeMediaNote(n){let i=this.noteToMediaIndex.get(n.path);if(!i)return;this.noteToMediaIndex.delete(n.path);let r=un(i),s=this.mediaToNoteIndex.get(r);s&&(s.delete(n),s.size===0&&this.mediaToNoteIndex.delete(r))}addMediaNote(n,i){this.noteToMediaIndex.set(i.path,n);let r=un(n),s=this.mediaToNoteIndex.get(r);s?s.add(i):this.mediaToNoteIndex.set(r,new Set([i]))}onload(){Dy(this.app.metadataCache,this).then(()=>{this.onResolve()})}};function*AB(t){for(let e of pp(t.vault.getRoot())){if(e.extension!=="md")continue;let n=l0(e,t);n&&(yield{mediaInfo:n,file:e})}}var Go=require("obsidian");var m2=require("url"),Kl=require("obsidian");function c0(t,e){let n=`#EXTM3U `,i=[],r=!1;for(let s of t.list)if(s.media instanceof Rn)n+=`#EXTINF:-1,${s.title} ${s.media.href} `;else if(ke(s.media))if(e.adapter instanceof Kl.FileSystemAdapter){let o=e.adapter.getFullPath(s.media.file.path);try{let a=(0,m2.pathToFileURL)(o).href;n+=`#EXTINF:-1,${s.title} ${a} `}catch(a){new Kl.Notice(`Failed to convert file path to URL: ${a}`),i.push(s.title||un(s.media))}}else r=!0,i.push(s.title||un(s.media));i.length>0&&(r?new Kl.Notice(createFragment(s=>{s.createDiv({text:"File URI is not supported in this environment. "}),s.createDiv({text:`Skipped items: ${i.join(", ")}`})})):new Kl.Notice(`Skipped items: ${i.join(", ")}`)),DB(n,t.title)}function DB(t,e){let n=new Blob([t],{type:"application/vnd.apple.mpegurl"}),i=document.createElement("a");i.href=URL.createObjectURL(n),i.download=`${e}.m3u8`,document.body.appendChild(i),i.click(),document.body.removeChild(i)}var YD=require("obsidian");function u0(t,e){let n=String(t);if(typeof e!="string")throw new TypeError("Expected character");let i=0,r=n.indexOf(e);for(;r!==-1;)i++,r=n.indexOf(e,r+e.length);return i}var xt=zs(/[A-Za-z]/),kt=zs(/[\dA-Za-z]/),g2=zs(/[#-'*+\--9=?A-Z^-~]/);function Uo(t){return t!==null&&(t<32||t===127)}var hp=zs(/\d/),y2=zs(/[\dA-Fa-f]/),v2=zs(/[!-/:-@[-`{-~]/);function z(t){return t!==null&&t<-2}function me(t){return t!==null&&(t<0||t===32)}function J(t){return t===-2||t===-1||t===32}var jo=zs(/\p{P}|\p{S}/u),ur=zs(/\s/);function zs(t){return e;function e(n){return n!==null&&n>-1&&t.test(String.fromCharCode(n))}}function d0(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var Us=function(t){if(t==null)return VB;if(typeof t=="function")return Oy(t);if(typeof t=="object")return Array.isArray(t)?NB(t):OB(t);if(typeof t=="string")return FB(t);throw new Error("Expected function, string, or object as test")};function NB(t){let e=[],n=-1;for(;++n":""))+")"})}return p;function p(){let h=w2,m,v,w;if((!e||s(l,c,u[u.length-1]||void 0))&&(h=UB(n(l,u)),h[0]===dr))return h;if("children"in l&&l.children){let f=l;if(f.children&&h[0]!==Vy)for(v=(i?f.children.length:-1)+o,w=u.concat(f);v>-1&&v0?{type:"text",value:k}:void 0),k===!1?p.lastIndex=T+1:(m!==T&&g.push({type:"text",value:c.value.slice(m,T)}),Array.isArray(k)?g.push(...k):k&&g.push(k),m=T+y[0].length,f=!0),!p.global)break;y=p.exec(c.value)}return f?(m?\]}]+$/.exec(t);if(!e)return[t,void 0];t=t.slice(0,e.index);let n=e[0],i=n.indexOf(")"),r=u0(t,"("),s=u0(t,")");for(;i!==-1&&r>s;)t+=n.slice(0,i+1),n=n.slice(i+1),i=n.indexOf(")"),s++;return[t,n]}function _2(t,e){let n=t.input.charCodeAt(t.index-1);return(t.index===0||ur(n)||jo(n))&&(!e||n!==47)}function Kt(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}b2.peek=cH;function v0(){return{enter:{gfmFootnoteDefinition:tH,gfmFootnoteDefinitionLabelString:nH,gfmFootnoteCall:sH,gfmFootnoteCallString:oH},exit:{gfmFootnoteDefinition:rH,gfmFootnoteDefinitionLabelString:iH,gfmFootnoteCall:lH,gfmFootnoteCallString:aH}}}function w0(){return{unsafe:[{character:"[",inConstruct:["phrasing","label","reference"]}],handlers:{footnoteDefinition:uH,footnoteReference:b2}}}function tH(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function nH(){this.buffer()}function iH(t){let e=this.resume(),n=this.stack[this.stack.length-1];n.type,n.label=e,n.identifier=Kt(this.sliceSerialize(t)).toLowerCase()}function rH(t){this.exit(t)}function sH(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function oH(){this.buffer()}function aH(t){let e=this.resume(),n=this.stack[this.stack.length-1];n.type,n.label=e,n.identifier=Kt(this.sliceSerialize(t)).toLowerCase()}function lH(t){this.exit(t)}function b2(t,e,n,i){let r=n.createTracker(i),s=r.move("[^"),o=n.enter("footnoteReference"),a=n.enter("reference");return s+=r.move(n.safe(n.associationId(t),{...r.current(),before:s,after:"]"})),a(),o(),s+=r.move("]"),s}function cH(){return"["}function uH(t,e,n,i){let r=n.createTracker(i),s=r.move("[^"),o=n.enter("footnoteDefinition"),a=n.enter("label");return s+=r.move(n.safe(n.associationId(t),{...r.current(),before:s,after:"]"})),a(),s+=r.move("]:"+(t.children&&t.children.length>0?" ":"")),r.shift(4),s+=r.move(n.indentLines(n.containerFlow(t,r.current()),dH)),o(),s}function dH(t,e,n){return e===0?t:(n?"":" ")+t}var pH=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];x2.peek=mH;function _0(){return{canContainEols:["delete"],enter:{strikethrough:hH},exit:{strikethrough:fH}}}function b0(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:pH}],handlers:{delete:x2}}}function hH(t){this.enter({type:"delete",children:[]},t)}function fH(t){this.exit(t)}function x2(t,e,n,i){let r=n.createTracker(i),s=n.enter("strikethrough"),o=r.move("~~");return o+=n.containerPhrasing(t,{...r.current(),before:o,after:"~"}),o+=r.move("~~"),s(),o}function mH(){return"~"}function T2(t,e={}){let n=(e.align||[]).concat(),i=e.stringLength||yH,r=[],s=[],o=[],a=[],l=0,c=-1;for(;++cl&&(l=t[c].length);++wa[w])&&(a[w]=g)}m.push(f)}s[c]=m,o[c]=v}let u=-1;if(typeof n=="object"&&"length"in n)for(;++ua[u]&&(a[u]=f),p[u]=f),d[u]=g}s.splice(1,0,d),o.splice(1,0,p),c=-1;let h=[];for(;++c "),s.shift(2);let o=n.indentLines(n.containerFlow(t,s.current()),vH);return r(),o}function vH(t,e,n){return">"+(n?"":" ")+t}function P2(t,e){return S2(t,e.inConstruct,!0)&&!S2(t,e.notInConstruct,!1)}function S2(t,e,n){if(typeof e=="string"&&(e=[e]),!e||e.length===0)return n;let i=-1;for(;++io&&(o=s):s=1,r=i+e.length,i=n.indexOf(e,r);return o}function M2(t,e){return!!(e.options.fences===!1&&t.value&&!t.lang&&/[^ \r\n]/.test(t.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(t.value))}function $2(t){let e=t.options.fence||"`";if(e!=="`"&&e!=="~")throw new Error("Cannot serialize code with `"+e+"` for `options.fence`, expected `` ` `` or `~`");return e}function R2(t,e,n,i){let r=$2(n),s=t.value||"",o=r==="`"?"GraveAccent":"Tilde";if(M2(t,n)){let d=n.enter("codeIndented"),p=n.indentLines(s,wH);return d(),p}let a=n.createTracker(i),l=r.repeat(Math.max(C2(s,r)+1,3)),c=n.enter("codeFenced"),u=a.move(l);if(t.lang){let d=n.enter(`codeFencedLang${o}`);u+=a.move(n.safe(t.lang,{before:u,after:" ",encode:["`"],...a.current()})),d()}if(t.lang&&t.meta){let d=n.enter(`codeFencedMeta${o}`);u+=a.move(" "),u+=a.move(n.safe(t.meta,{before:u,after:` `,encode:["`"],...a.current()})),d()}return u+=a.move(` `),s&&(u+=a.move(s+` `)),u+=a.move(l),c(),u}function wH(t,e,n){return(n?"":" ")+t}function Gl(t){let e=t.options.quote||'"';if(e!=='"'&&e!=="'")throw new Error("Cannot serialize title with `"+e+"` for `options.quote`, expected `\"`, or `'`");return e}function I2(t,e,n,i){let r=Gl(n),s=r==='"'?"Quote":"Apostrophe",o=n.enter("definition"),a=n.enter("label"),l=n.createTracker(i),c=l.move("[");return c+=l.move(n.safe(n.associationId(t),{before:c,after:"]",...l.current()})),c+=l.move("]: "),a(),!t.url||/[\0- \u007F]/.test(t.url)?(a=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(t.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(a=n.enter("destinationRaw"),c+=l.move(n.safe(t.url,{before:c,after:t.title?" ":` `,...l.current()}))),a(),t.title&&(a=n.enter(`title${s}`),c+=l.move(" "+r),c+=l.move(n.safe(t.title,{before:c,after:r,...l.current()})),c+=l.move(r),a()),o(),c}function L2(t){let e=t.options.emphasis||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize emphasis with `"+e+"` for `options.emphasis`, expected `*`, or `_`");return e}k0.peek=_H;function k0(t,e,n,i){let r=L2(n),s=n.enter("emphasis"),o=n.createTracker(i),a=o.move(r);return a+=o.move(n.containerPhrasing(t,{before:a,after:r,...o.current()})),a+=o.move(r),s(),a}function _H(t,e,n){return n.options.emphasis||"*"}function Yl(t,e,n,i){let r,s,o;typeof e=="function"&&typeof n!="function"?(s=void 0,o=e,r=n):(s=e,o=n,r=i),fp(t,s,a,r);function a(l,c){let u=c[c.length-1],d=u?u.children.indexOf(l):void 0;return o(l,d,u)}}var bH={};function Bo(t,e){let n=e||bH,i=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,r=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return D2(t,i,r)}function D2(t,e,n){if(xH(t)){if("value"in t)return t.type==="html"&&!n?"":t.value;if(e&&"alt"in t&&t.alt)return t.alt;if("children"in t)return A2(t.children,e,n)}return Array.isArray(t)?A2(t,e,n):""}function A2(t,e,n){let i=[],r=-1;for(;++r",...l.current()})),c+=l.move(">")):(a=n.enter("destinationRaw"),c+=l.move(n.safe(t.url,{before:c,after:t.title?" ":")",...l.current()}))),a(),t.title&&(a=n.enter(`title${s}`),c+=l.move(" "+r),c+=l.move(n.safe(t.title,{before:c,after:r,...l.current()})),c+=l.move(r),a()),c+=l.move(")"),o(),c}function TH(){return"!"}S0.peek=EH;function S0(t,e,n,i){let r=t.referenceType,s=n.enter("imageReference"),o=n.enter("label"),a=n.createTracker(i),l=a.move("!["),c=n.safe(t.alt,{before:l,after:"]",...a.current()});l+=a.move(c+"]["),o();let u=n.stack;n.stack=[],o=n.enter("reference");let d=n.safe(n.associationId(t),{before:l,after:"]",...a.current()});return o(),n.stack=u,s(),r==="full"||!c||c!==d?l+=a.move(d+"]"):r==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function EH(){return"!"}P0.peek=SH;function P0(t,e,n){let i=t.value||"",r="`",s=-1;for(;new RegExp("(^|[^`])"+r+"([^`]|$)").test(i);)r+="`";for(/[^ \r\n]/.test(i)&&(/^[ \r\n]/.test(i)&&/[ \r\n]$/.test(i)||/^`|`$/.test(i))&&(i=" "+i+" ");++s\u007F]/.test(t.url))}M0.peek=PH;function M0(t,e,n,i){let r=Gl(n),s=r==='"'?"Quote":"Apostrophe",o=n.createTracker(i),a,l;if(C0(t,n)){let u=n.stack;n.stack=[],a=n.enter("autolink");let d=o.move("<");return d+=o.move(n.containerPhrasing(t,{before:d,after:">",...o.current()})),d+=o.move(">"),a(),n.stack=u,d}a=n.enter("link"),l=n.enter("label");let c=o.move("[");return c+=o.move(n.containerPhrasing(t,{before:c,after:"](",...o.current()})),c+=o.move("]("),l(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(l=n.enter("destinationLiteral"),c+=o.move("<"),c+=o.move(n.safe(t.url,{before:c,after:">",...o.current()})),c+=o.move(">")):(l=n.enter("destinationRaw"),c+=o.move(n.safe(t.url,{before:c,after:t.title?" ":")",...o.current()}))),l(),t.title&&(l=n.enter(`title${s}`),c+=o.move(" "+r),c+=o.move(n.safe(t.title,{before:c,after:r,...o.current()})),c+=o.move(r),l()),c+=o.move(")"),a(),c}function PH(t,e,n){return C0(t,n)?"<":"["}$0.peek=CH;function $0(t,e,n,i){let r=t.referenceType,s=n.enter("linkReference"),o=n.enter("label"),a=n.createTracker(i),l=a.move("["),c=n.containerPhrasing(t,{before:l,after:"]",...a.current()});l+=a.move(c+"]["),o();let u=n.stack;n.stack=[],o=n.enter("reference");let d=n.safe(n.associationId(t),{before:l,after:"]",...a.current()});return o(),n.stack=u,s(),r==="full"||!c||c!==d?l+=a.move(d+"]"):r==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function CH(){return"["}function Ql(t){let e=t.options.bullet||"*";if(e!=="*"&&e!=="+"&&e!=="-")throw new Error("Cannot serialize items with `"+e+"` for `options.bullet`, expected `*`, `+`, or `-`");return e}function F2(t){let e=Ql(t),n=t.options.bulletOther;if(!n)return e==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===e)throw new Error("Expected `bullet` (`"+e+"`) and `bulletOther` (`"+n+"`) to be different");return n}function V2(t){let e=t.options.bulletOrdered||".";if(e!=="."&&e!==")")throw new Error("Cannot serialize items with `"+e+"` for `options.bulletOrdered`, expected `.` or `)`");return e}function zy(t){let e=t.options.rule||"*";if(e!=="*"&&e!=="-"&&e!=="_")throw new Error("Cannot serialize rules with `"+e+"` for `options.rule`, expected `*`, `-`, or `_`");return e}function z2(t,e,n,i){let r=n.enter("list"),s=n.bulletCurrent,o=t.ordered?V2(n):Ql(n),a=t.ordered?o==="."?")":".":F2(n),l=e&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!t.ordered){let u=t.children?t.children[0]:void 0;if((o==="*"||o==="-")&&u&&(!u.children||!u.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(l=!0),zy(n)===o&&u){let d=-1;for(;++d-1?e.start:1)+(n.options.incrementListMarker===!1?0:e.children.indexOf(t))+s);let o=s.length+1;(r==="tab"||r==="mixed"&&(e&&e.type==="list"&&e.spread||t.spread))&&(o=Math.ceil(o/4)*4);let a=n.createTracker(i);a.move(s+" ".repeat(o-s.length)),a.shift(o);let l=n.enter("listItem"),c=n.indentLines(n.containerFlow(t,a.current()),u);return l(),c;function u(d,p,h){return p?(h?"":" ".repeat(o))+d:(h?s:s+" ".repeat(o-s.length))+d}}function B2(t,e,n,i){let r=n.enter("paragraph"),s=n.enter("phrasing"),o=n.containerPhrasing(t,i);return s(),r(),o}var R0=Us(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function H2(t,e,n,i){return(t.children.some(function(o){return R0(o)})?n.containerPhrasing:n.containerFlow).call(n,t,i)}function q2(t){let e=t.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}I0.peek=MH;function I0(t,e,n,i){let r=q2(n),s=n.enter("strong"),o=n.createTracker(i),a=o.move(r+r);return a+=o.move(n.containerPhrasing(t,{before:a,after:r,...o.current()})),a+=o.move(r+r),s(),a}function MH(t,e,n){return n.options.strong||"*"}function W2(t,e,n,i){return n.safe(t.value,i)}function K2(t){let e=t.options.ruleRepetition||3;if(e<3)throw new Error("Cannot serialize rules with repetition `"+e+"` for `options.ruleRepetition`, expected `3` or more");return e}function G2(t,e,n){let i=(zy(n)+(n.options.ruleSpaces?" ":"")).repeat(K2(n));return n.options.ruleSpaces?i.slice(0,-1):i}var mp={blockquote:E2,break:x0,code:R2,definition:I2,emphasis:k0,hardBreak:x0,heading:O2,html:T0,image:E0,imageReference:S0,inlineCode:P0,link:M0,linkReference:$0,list:z2,listItem:j2,paragraph:B2,root:H2,strong:I0,text:W2,thematicBreak:G2};var Y2=document.createElement("i");function Xl(t){let e="&"+t+";";Y2.innerHTML=e;let n=Y2.textContent;return n.charCodeAt(n.length-1)===59&&t!=="semi"||n===e?!1:n}function Uy(t,e){let n=Number.parseInt(t,e);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"\uFFFD":String.fromCodePoint(n)}var $H=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Q2(t){return t.replace($H,RH)}function RH(t,e,n){if(e)return e;if(n.charCodeAt(0)===35){let r=n.charCodeAt(1),s=r===120||r===88;return Uy(n.slice(s?2:1),s?16:10)}return Xl(n)||t}function A0(){return{enter:{table:IH,tableData:X2,tableHeader:X2,tableRow:AH},exit:{codeText:DH,table:LH,tableData:L0,tableHeader:L0,tableRow:L0}}}function IH(t){let e=t._align;this.enter({type:"table",align:e.map(function(n){return n==="none"?null:n}),children:[]},t),this.data.inTable=!0}function LH(t){this.exit(t),this.data.inTable=void 0}function AH(t){this.enter({type:"tableRow",children:[]},t)}function L0(t){this.exit(t)}function X2(t){this.enter({type:"tableCell",children:[]},t)}function DH(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,NH));let n=this.stack[this.stack.length-1];n.type,n.value=e,this.exit(t)}function NH(t,e){return e==="|"?e:t}function D0(t){let e=t||{},n=e.tableCellPadding,i=e.tablePipeAlign,r=e.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:` `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:p,table:o,tableCell:l,tableRow:a}};function o(h,m,v,w){return c(u(h,v,w),h.align)}function a(h,m,v,w){let f=d(h,v,w),g=c([f]);return g.slice(0,g.indexOf(` `))}function l(h,m,v,w){let f=v.enter("tableCell"),g=v.enter("phrasing"),y=v.containerPhrasing(h,{...w,before:s,after:s});return g(),f(),y}function c(h,m){return T2(h,{align:m,alignDelimiters:i,padding:n,stringLength:r})}function u(h,m,v){let w=h.children,f=-1,g=[],y=m.enter("table");for(;++fr?0:r+e:e=e>r?r:e,n=n>0?n:0,i.length<1e4)o=Array.from(i),o.unshift(e,n),t.splice(...o);else for(n&&t.splice(e,n);s0?(st(t,t.length,0,e),t):e}var J2={}.hasOwnProperty;function jy(t){let e={},n=-1;for(;++n0&&!n&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}function Zl(t){if(t===null||me(t)||ur(t))return 1;if(jo(t))return 2}function js(t,e,n){let i=[],r=-1;for(;++r1&&t[n][1].end.offset-t[n][1].start.offset>1?2:1;let d=Object.assign({},t[i][1].end),p=Object.assign({},t[n][1].start);lD(d,-l),lD(p,l),o={type:l>1?"strongSequence":"emphasisSequence",start:d,end:Object.assign({},t[i][1].end)},a={type:l>1?"strongSequence":"emphasisSequence",start:Object.assign({},t[n][1].start),end:p},s={type:l>1?"strongText":"emphasisText",start:Object.assign({},t[i][1].end),end:Object.assign({},t[n][1].start)},r={type:l>1?"strong":"emphasis",start:Object.assign({},o.start),end:Object.assign({},a.end)},t[i][1].end=Object.assign({},o.start),t[n][1].start=Object.assign({},a.end),c=[],t[i][1].end.offset-t[i][1].start.offset&&(c=pn(c,[["enter",t[i][1],e],["exit",t[i][1],e]])),c=pn(c,[["enter",r,e],["enter",o,e],["exit",o,e],["enter",s,e]]),c=pn(c,js(e.parser.constructs.insideSpan.null,t.slice(i+1,n),e)),c=pn(c,[["exit",s,e],["enter",a,e],["exit",a,e],["exit",r,e]]),t[n][1].end.offset-t[n][1].start.offset?(u=2,c=pn(c,[["enter",t[n][1],e],["exit",t[n][1],e]])):u=0,st(t,i-1,n-i+3,c),n=i+c.length-u-2;break}}for(n=-1;++n0&&J(k)?G(t,g,"linePrefix",s+1)(k):g(k)}function g(k){return k===null||z(k)?t.check(cD,v,T)(k):(t.enter("codeFlowValue"),y(k))}function y(k){return k===null||z(k)?(t.exit("codeFlowValue"),g(k)):(t.consume(k),y)}function T(k){return t.exit("codeFenced"),e(k)}function P(k,M,I){let O=0;return b;function b(W){return k.enter("lineEnding"),k.consume(W),k.exit("lineEnding"),ee}function ee(W){return k.enter("codeFencedFence"),J(W)?G(k,U,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(W):U(W)}function U(W){return W===a?(k.enter("codeFencedFenceSequence"),H(W)):I(W)}function H(W){return W===a?(O++,k.consume(W),H):O>=o?(k.exit("codeFencedFenceSequence"),J(W)?G(k,q,"whitespace")(W):q(W)):I(W)}function q(W){return W===null||z(W)?(k.exit("codeFencedFence"),M(W)):I(W)}}}function a7(t,e,n){let i=this;return r;function r(o){return o===null?n(o):(t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),s)}function s(o){return i.parser.lazy[i.now().line]?n(o):e(o)}}var yp={name:"codeIndented",tokenize:c7},l7={tokenize:u7,partial:!0};function c7(t,e,n){let i=this;return r;function r(c){return t.enter("codeIndented"),G(t,s,"linePrefix",5)(c)}function s(c){let u=i.events[i.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?o(c):n(c)}function o(c){return c===null?l(c):z(c)?t.attempt(l7,o,l)(c):(t.enter("codeFlowValue"),a(c))}function a(c){return c===null||z(c)?(t.exit("codeFlowValue"),o(c)):(t.consume(c),a)}function l(c){return t.exit("codeIndented"),e(c)}}function u7(t,e,n){let i=this;return r;function r(o){return i.parser.lazy[i.now().line]?n(o):z(o)?(t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),r):G(t,s,"linePrefix",5)(o)}function s(o){let a=i.events[i.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?e(o):z(o)?r(o):n(o)}}var H0={name:"codeText",tokenize:h7,resolve:d7,previous:p7};function d7(t){let e=t.length-4,n=3,i,r;if((t[n][1].type==="lineEnding"||t[n][1].type==="space")&&(t[e][1].type==="lineEnding"||t[e][1].type==="space")){for(i=n;++i=4?e(o):t.interrupt(i.parser.constructs.flow,n,e)(o)}}function Gy(t,e,n,i,r,s,o,a,l){let c=l||Number.POSITIVE_INFINITY,u=0;return d;function d(f){return f===60?(t.enter(i),t.enter(r),t.enter(s),t.consume(f),t.exit(s),p):f===null||f===32||f===41||Uo(f)?n(f):(t.enter(i),t.enter(o),t.enter(a),t.enter("chunkString",{contentType:"string"}),v(f))}function p(f){return f===62?(t.enter(s),t.consume(f),t.exit(s),t.exit(r),t.exit(i),e):(t.enter(a),t.enter("chunkString",{contentType:"string"}),h(f))}function h(f){return f===62?(t.exit("chunkString"),t.exit(a),p(f)):f===null||f===60||z(f)?n(f):(t.consume(f),f===92?m:h)}function m(f){return f===60||f===62||f===92?(t.consume(f),h):h(f)}function v(f){return!u&&(f===null||f===41||me(f))?(t.exit("chunkString"),t.exit(a),t.exit(o),t.exit(i),e(f)):u999||h===null||h===91||h===93&&!l||h===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?n(h):h===93?(t.exit(s),t.enter(r),t.consume(h),t.exit(r),t.exit(i),e):z(h)?(t.enter("lineEnding"),t.consume(h),t.exit("lineEnding"),u):(t.enter("chunkString",{contentType:"string"}),d(h))}function d(h){return h===null||h===91||h===93||z(h)||a++>999?(t.exit("chunkString"),u(h)):(t.consume(h),l||(l=!J(h)),h===92?p:d)}function p(h){return h===91||h===92||h===93?(t.consume(h),a++,d):d(h)}}function Qy(t,e,n,i,r,s){let o;return a;function a(p){return p===34||p===39||p===40?(t.enter(i),t.enter(r),t.consume(p),t.exit(r),o=p===40?41:p,l):n(p)}function l(p){return p===o?(t.enter(r),t.consume(p),t.exit(r),t.exit(i),e):(t.enter(s),c(p))}function c(p){return p===o?(t.exit(s),l(o)):p===null?n(p):z(p)?(t.enter("lineEnding"),t.consume(p),t.exit("lineEnding"),G(t,c,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),u(p))}function u(p){return p===o||p===null||z(p)?(t.exit("chunkString"),c(p)):(t.consume(p),p===92?d:u)}function d(p){return p===o||p===92?(t.consume(p),u):u(p)}}function qo(t,e){let n;return i;function i(r){return z(r)?(t.enter("lineEnding"),t.consume(r),t.exit("lineEnding"),n=!0,i):J(r)?G(t,i,n?"linePrefix":"lineSuffix")(r):e(r)}}var W0={name:"definition",tokenize:_7},w7={tokenize:b7,partial:!0};function _7(t,e,n){let i=this,r;return s;function s(h){return t.enter("definition"),o(h)}function o(h){return Yy.call(i,t,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function a(h){return r=Kt(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),h===58?(t.enter("definitionMarker"),t.consume(h),t.exit("definitionMarker"),l):n(h)}function l(h){return me(h)?qo(t,c)(h):c(h)}function c(h){return Gy(t,u,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function u(h){return t.attempt(w7,d,d)(h)}function d(h){return J(h)?G(t,p,"whitespace")(h):p(h)}function p(h){return h===null||z(h)?(t.exit("definition"),i.parser.defined.push(r),e(h)):n(h)}}function b7(t,e,n){return i;function i(a){return me(a)?qo(t,r)(a):n(a)}function r(a){return Qy(t,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return J(a)?G(t,o,"whitespace")(a):o(a)}function o(a){return a===null||z(a)?e(a):n(a)}}var K0={name:"hardBreakEscape",tokenize:x7};function x7(t,e,n){return i;function i(s){return t.enter("hardBreakEscape"),t.consume(s),r}function r(s){return z(s)?(t.exit("hardBreakEscape"),e(s)):n(s)}}var G0={name:"headingAtx",tokenize:T7,resolve:k7};function k7(t,e){let n=t.length-2,i=3,r,s;return t[i][1].type==="whitespace"&&(i+=2),n-2>i&&t[n][1].type==="whitespace"&&(n-=2),t[n][1].type==="atxHeadingSequence"&&(i===n-1||n-4>i&&t[n-2][1].type==="whitespace")&&(n-=i+1===n?2:4),n>i&&(r={type:"atxHeadingText",start:t[i][1].start,end:t[n][1].end},s={type:"chunkText",start:t[i][1].start,end:t[n][1].end,contentType:"text"},st(t,i,n-i+1,[["enter",r,e],["enter",s,e],["exit",s,e],["exit",r,e]])),t}function T7(t,e,n){let i=0;return r;function r(u){return t.enter("atxHeading"),s(u)}function s(u){return t.enter("atxHeadingSequence"),o(u)}function o(u){return u===35&&i++<6?(t.consume(u),o):u===null||me(u)?(t.exit("atxHeadingSequence"),a(u)):n(u)}function a(u){return u===35?(t.enter("atxHeadingSequence"),l(u)):u===null||z(u)?(t.exit("atxHeading"),e(u)):J(u)?G(t,a,"whitespace")(u):(t.enter("atxHeadingText"),c(u))}function l(u){return u===35?(t.consume(u),l):(t.exit("atxHeadingSequence"),a(u))}function c(u){return u===null||u===35||me(u)?(t.exit("atxHeadingText"),a(u)):(t.consume(u),c)}}var uD=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Y0=["pre","script","style","textarea"];var Q0={name:"htmlFlow",tokenize:C7,resolveTo:P7,concrete:!0},E7={tokenize:$7,partial:!0},S7={tokenize:M7,partial:!0};function P7(t){let e=t.length;for(;e--&&!(t[e][0]==="enter"&&t[e][1].type==="htmlFlow"););return e>1&&t[e-2][1].type==="linePrefix"&&(t[e][1].start=t[e-2][1].start,t[e+1][1].start=t[e-2][1].start,t.splice(e-2,2)),t}function C7(t,e,n){let i=this,r,s,o,a,l;return c;function c(x){return u(x)}function u(x){return t.enter("htmlFlow"),t.enter("htmlFlowData"),t.consume(x),d}function d(x){return x===33?(t.consume(x),p):x===47?(t.consume(x),s=!0,v):x===63?(t.consume(x),r=3,i.interrupt?e:_):xt(x)?(t.consume(x),o=String.fromCharCode(x),w):n(x)}function p(x){return x===45?(t.consume(x),r=2,h):x===91?(t.consume(x),r=5,a=0,m):xt(x)?(t.consume(x),r=4,i.interrupt?e:_):n(x)}function h(x){return x===45?(t.consume(x),i.interrupt?e:_):n(x)}function m(x){let Cn="CDATA[";return x===Cn.charCodeAt(a++)?(t.consume(x),a===Cn.length?i.interrupt?e:U:m):n(x)}function v(x){return xt(x)?(t.consume(x),o=String.fromCharCode(x),w):n(x)}function w(x){if(x===null||x===47||x===62||me(x)){let Cn=x===47,qs=o.toLowerCase();return!Cn&&!s&&Y0.includes(qs)?(r=1,i.interrupt?e(x):U(x)):uD.includes(o.toLowerCase())?(r=6,Cn?(t.consume(x),f):i.interrupt?e(x):U(x)):(r=7,i.interrupt&&!i.parser.lazy[i.now().line]?n(x):s?g(x):y(x))}return x===45||kt(x)?(t.consume(x),o+=String.fromCharCode(x),w):n(x)}function f(x){return x===62?(t.consume(x),i.interrupt?e:U):n(x)}function g(x){return J(x)?(t.consume(x),g):b(x)}function y(x){return x===47?(t.consume(x),b):x===58||x===95||xt(x)?(t.consume(x),T):J(x)?(t.consume(x),y):b(x)}function T(x){return x===45||x===46||x===58||x===95||kt(x)?(t.consume(x),T):P(x)}function P(x){return x===61?(t.consume(x),k):J(x)?(t.consume(x),P):y(x)}function k(x){return x===null||x===60||x===61||x===62||x===96?n(x):x===34||x===39?(t.consume(x),l=x,M):J(x)?(t.consume(x),k):I(x)}function M(x){return x===l?(t.consume(x),l=null,O):x===null||z(x)?n(x):(t.consume(x),M)}function I(x){return x===null||x===34||x===39||x===47||x===60||x===61||x===62||x===96||me(x)?P(x):(t.consume(x),I)}function O(x){return x===47||x===62||J(x)?y(x):n(x)}function b(x){return x===62?(t.consume(x),ee):n(x)}function ee(x){return x===null||z(x)?U(x):J(x)?(t.consume(x),ee):n(x)}function U(x){return x===45&&r===2?(t.consume(x),xe):x===60&&r===1?(t.consume(x),Fe):x===62&&r===4?(t.consume(x),Ie):x===63&&r===3?(t.consume(x),_):x===93&&r===5?(t.consume(x),tt):z(x)&&(r===6||r===7)?(t.exit("htmlFlowData"),t.check(E7,Rt,H)(x)):x===null||z(x)?(t.exit("htmlFlowData"),H(x)):(t.consume(x),U)}function H(x){return t.check(S7,q,Rt)(x)}function q(x){return t.enter("lineEnding"),t.consume(x),t.exit("lineEnding"),W}function W(x){return x===null||z(x)?H(x):(t.enter("htmlFlowData"),U(x))}function xe(x){return x===45?(t.consume(x),_):U(x)}function Fe(x){return x===47?(t.consume(x),o="",yt):U(x)}function yt(x){if(x===62){let Cn=o.toLowerCase();return Y0.includes(Cn)?(t.consume(x),Ie):U(x)}return xt(x)&&o.length<8?(t.consume(x),o+=String.fromCharCode(x),yt):U(x)}function tt(x){return x===93?(t.consume(x),_):U(x)}function _(x){return x===62?(t.consume(x),Ie):x===45&&r===2?(t.consume(x),_):U(x)}function Ie(x){return x===null||z(x)?(t.exit("htmlFlowData"),Rt(x)):(t.consume(x),Ie)}function Rt(x){return t.exit("htmlFlow"),e(x)}}function M7(t,e,n){let i=this;return r;function r(o){return z(o)?(t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),s):n(o)}function s(o){return i.parser.lazy[i.now().line]?n(o):e(o)}}function $7(t,e,n){return i;function i(r){return t.enter("lineEnding"),t.consume(r),t.exit("lineEnding"),t.attempt(hr,e,n)}}var X0={name:"htmlText",tokenize:R7};function R7(t,e,n){let i=this,r,s,o;return a;function a(_){return t.enter("htmlText"),t.enter("htmlTextData"),t.consume(_),l}function l(_){return _===33?(t.consume(_),c):_===47?(t.consume(_),P):_===63?(t.consume(_),y):xt(_)?(t.consume(_),I):n(_)}function c(_){return _===45?(t.consume(_),u):_===91?(t.consume(_),s=0,m):xt(_)?(t.consume(_),g):n(_)}function u(_){return _===45?(t.consume(_),h):n(_)}function d(_){return _===null?n(_):_===45?(t.consume(_),p):z(_)?(o=d,Fe(_)):(t.consume(_),d)}function p(_){return _===45?(t.consume(_),h):d(_)}function h(_){return _===62?xe(_):_===45?p(_):d(_)}function m(_){let Ie="CDATA[";return _===Ie.charCodeAt(s++)?(t.consume(_),s===Ie.length?v:m):n(_)}function v(_){return _===null?n(_):_===93?(t.consume(_),w):z(_)?(o=v,Fe(_)):(t.consume(_),v)}function w(_){return _===93?(t.consume(_),f):v(_)}function f(_){return _===62?xe(_):_===93?(t.consume(_),f):v(_)}function g(_){return _===null||_===62?xe(_):z(_)?(o=g,Fe(_)):(t.consume(_),g)}function y(_){return _===null?n(_):_===63?(t.consume(_),T):z(_)?(o=y,Fe(_)):(t.consume(_),y)}function T(_){return _===62?xe(_):y(_)}function P(_){return xt(_)?(t.consume(_),k):n(_)}function k(_){return _===45||kt(_)?(t.consume(_),k):M(_)}function M(_){return z(_)?(o=M,Fe(_)):J(_)?(t.consume(_),M):xe(_)}function I(_){return _===45||kt(_)?(t.consume(_),I):_===47||_===62||me(_)?O(_):n(_)}function O(_){return _===47?(t.consume(_),xe):_===58||_===95||xt(_)?(t.consume(_),b):z(_)?(o=O,Fe(_)):J(_)?(t.consume(_),O):xe(_)}function b(_){return _===45||_===46||_===58||_===95||kt(_)?(t.consume(_),b):ee(_)}function ee(_){return _===61?(t.consume(_),U):z(_)?(o=ee,Fe(_)):J(_)?(t.consume(_),ee):O(_)}function U(_){return _===null||_===60||_===61||_===62||_===96?n(_):_===34||_===39?(t.consume(_),r=_,H):z(_)?(o=U,Fe(_)):J(_)?(t.consume(_),U):(t.consume(_),q)}function H(_){return _===r?(t.consume(_),r=void 0,W):_===null?n(_):z(_)?(o=H,Fe(_)):(t.consume(_),H)}function q(_){return _===null||_===34||_===39||_===60||_===61||_===96?n(_):_===47||_===62||me(_)?O(_):(t.consume(_),q)}function W(_){return _===47||_===62||me(_)?O(_):n(_)}function xe(_){return _===62?(t.consume(_),t.exit("htmlTextData"),t.exit("htmlText"),e):n(_)}function Fe(_){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(_),t.exit("lineEnding"),yt}function yt(_){return J(_)?G(t,tt,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(_):tt(_)}function tt(_){return t.enter("htmlTextData"),o(_)}}var Wo={name:"labelEnd",tokenize:O7,resolveTo:N7,resolveAll:D7},I7={tokenize:F7},L7={tokenize:V7},A7={tokenize:z7};function D7(t){let e=-1;for(;++e=3&&(c===null||z(c))?(t.exit("thematicBreak"),e(c)):n(c)}function l(c){return c===r?(t.consume(c),i++,l):(t.exit("thematicBreakSequence"),J(c)?G(t,a,"whitespace")(c):a(c))}}var Gt={name:"list",tokenize:K7,continuation:{tokenize:G7},exit:Q7},q7={tokenize:X7,partial:!0},W7={tokenize:Y7,partial:!0};function K7(t,e,n){let i=this,r=i.events[i.events.length-1],s=r&&r[1].type==="linePrefix"?r[2].sliceSerialize(r[1],!0).length:0,o=0;return a;function a(h){let m=i.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!i.containerState.marker||h===i.containerState.marker:hp(h)){if(i.containerState.type||(i.containerState.type=m,t.enter(m,{_container:!0})),m==="listUnordered")return t.enter("listItemPrefix"),h===42||h===45?t.check(Ko,n,c)(h):c(h);if(!i.interrupt||h===49)return t.enter("listItemPrefix"),t.enter("listItemValue"),l(h)}return n(h)}function l(h){return hp(h)&&++o<10?(t.consume(h),l):(!i.interrupt||o<2)&&(i.containerState.marker?h===i.containerState.marker:h===41||h===46)?(t.exit("listItemValue"),c(h)):n(h)}function c(h){return t.enter("listItemMarker"),t.consume(h),t.exit("listItemMarker"),i.containerState.marker=i.containerState.marker||h,t.check(hr,i.interrupt?n:u,t.attempt(q7,p,d))}function u(h){return i.containerState.initialBlankLine=!0,s++,p(h)}function d(h){return J(h)?(t.enter("listItemPrefixWhitespace"),t.consume(h),t.exit("listItemPrefixWhitespace"),p):n(h)}function p(h){return i.containerState.size=s+i.sliceSerialize(t.exit("listItemPrefix"),!0).length,e(h)}}function G7(t,e,n){let i=this;return i.containerState._closeFlow=void 0,t.check(hr,r,s);function r(a){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,G(t,e,"listItemIndent",i.containerState.size+1)(a)}function s(a){return i.containerState.furtherBlankLines||!J(a)?(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,o(a)):(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,t.attempt(W7,e,o)(a))}function o(a){return i.containerState._closeFlow=!0,i.interrupt=void 0,G(t,t.attempt(Gt,e,n),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function Y7(t,e,n){let i=this;return G(t,r,"listItemIndent",i.containerState.size+1);function r(s){let o=i.events[i.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===i.containerState.size?e(s):n(s)}}function Q7(t){t.exit(this.containerState.type)}function X7(t,e,n){let i=this;return G(t,r,"listItemPrefixWhitespace",i.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function r(s){let o=i.events[i.events.length-1];return!J(s)&&o&&o[1].type==="listItemPrefixWhitespace"?e(s):n(s)}}var Xy={name:"setextUnderline",tokenize:J7,resolveTo:Z7};function Z7(t,e){let n=t.length,i,r,s;for(;n--;)if(t[n][0]==="enter"){if(t[n][1].type==="content"){i=n;break}t[n][1].type==="paragraph"&&(r=n)}else t[n][1].type==="content"&&t.splice(n,1),!s&&t[n][1].type==="definition"&&(s=n);let o={type:"setextHeading",start:Object.assign({},t[r][1].start),end:Object.assign({},t[t.length-1][1].end)};return t[r][1].type="setextHeadingText",s?(t.splice(r,0,["enter",o,e]),t.splice(s+1,0,["exit",t[i][1],e]),t[i][1].end=Object.assign({},t[s][1].end)):t[i][1]=o,t.push(["exit",o,e]),t}function J7(t,e,n){let i=this,r;return s;function s(c){let u=i.events.length,d;for(;u--;)if(i.events[u][1].type!=="lineEnding"&&i.events[u][1].type!=="linePrefix"&&i.events[u][1].type!=="content"){d=i.events[u][1].type==="paragraph";break}return!i.parser.lazy[i.now().line]&&(i.interrupt||d)?(t.enter("setextHeadingLine"),r=c,o(c)):n(c)}function o(c){return t.enter("setextHeadingLineSequence"),a(c)}function a(c){return c===r?(t.consume(c),a):(t.exit("setextHeadingLineSequence"),J(c)?G(t,l,"lineSuffix")(c):l(c))}function l(c){return c===null||z(c)?(t.exit("setextHeadingLine"),e(c)):n(c)}}var e8={tokenize:a8,partial:!0};function eT(){return{document:{91:{tokenize:r8,continuation:{tokenize:s8},exit:o8}},text:{91:{tokenize:i8},93:{add:"after",tokenize:t8,resolveTo:n8}}}}function t8(t,e,n){let i=this,r=i.events.length,s=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]),o;for(;r--;){let l=i.events[r][1];if(l.type==="labelImage"){o=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return a;function a(l){if(!o||!o._balanced)return n(l);let c=Kt(i.sliceSerialize({start:o.end,end:i.now()}));return c.codePointAt(0)!==94||!s.includes(c.slice(1))?n(l):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(l),t.exit("gfmFootnoteCallLabelMarker"),e(l))}}function n8(t,e){let n=t.length,i;for(;n--;)if(t[n][1].type==="labelImage"&&t[n][0]==="enter"){i=t[n][1];break}t[n+1][1].type="data",t[n+3][1].type="gfmFootnoteCallLabelMarker";let r={type:"gfmFootnoteCall",start:Object.assign({},t[n+3][1].start),end:Object.assign({},t[t.length-1][1].end)},s={type:"gfmFootnoteCallMarker",start:Object.assign({},t[n+3][1].end),end:Object.assign({},t[n+3][1].end)};s.end.column++,s.end.offset++,s.end._bufferIndex++;let o={type:"gfmFootnoteCallString",start:Object.assign({},s.end),end:Object.assign({},t[t.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},l=[t[n+1],t[n+2],["enter",r,e],t[n+3],t[n+4],["enter",s,e],["exit",s,e],["enter",o,e],["enter",a,e],["exit",a,e],["exit",o,e],t[t.length-2],t[t.length-1],["exit",r,e]];return t.splice(n,t.length-n+1,...l),t}function i8(t,e,n){let i=this,r=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]),s=0,o;return a;function a(d){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(d),t.exit("gfmFootnoteCallLabelMarker"),l}function l(d){return d!==94?n(d):(t.enter("gfmFootnoteCallMarker"),t.consume(d),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",c)}function c(d){if(s>999||d===93&&!o||d===null||d===91||me(d))return n(d);if(d===93){t.exit("chunkString");let p=t.exit("gfmFootnoteCallString");return r.includes(Kt(i.sliceSerialize(p)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(d),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):n(d)}return me(d)||(o=!0),s++,t.consume(d),d===92?u:c}function u(d){return d===91||d===92||d===93?(t.consume(d),s++,c):c(d)}}function r8(t,e,n){let i=this,r=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]),s,o=0,a;return l;function l(m){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(m),t.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(m){return m===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(m),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",u):n(m)}function u(m){if(o>999||m===93&&!a||m===null||m===91||me(m))return n(m);if(m===93){t.exit("chunkString");let v=t.exit("gfmFootnoteDefinitionLabelString");return s=Kt(i.sliceSerialize(v)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(m),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),p}return me(m)||(a=!0),o++,t.consume(m),m===92?d:u}function d(m){return m===91||m===92||m===93?(t.consume(m),o++,u):u(m)}function p(m){return m===58?(t.enter("definitionMarker"),t.consume(m),t.exit("definitionMarker"),r.includes(s)||r.push(s),G(t,h,"gfmFootnoteDefinitionWhitespace")):n(m)}function h(m){return e(m)}}function s8(t,e,n){return t.check(hr,e,t.attempt(e8,e,n))}function o8(t){t.exit("gfmFootnoteDefinition")}function a8(t,e,n){let i=this;return G(t,r,"gfmFootnoteDefinitionIndent",5);function r(s){let o=i.events[i.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?e(s):n(s)}}function tT(t){let n=(t||{}).singleTilde,i={tokenize:s,resolveAll:r};return n==null&&(n=!0),{text:{126:i},insideSpan:{null:[i]},attentionMarkers:{null:[126]}};function r(o,a){let l=-1;for(;++l1?l(m):(o.consume(m),d++,h);if(d<2&&!n)return l(m);let w=o.exit("strikethroughSequenceTemporary"),f=Zl(m);return w._open=!f||f===2&&!!v,w._close=!v||v===2&&!!f,a(m)}}}var Zy=class{constructor(){this.map=[]}add(e,n,i){l8(this,e,n,i)}consume(e){if(this.map.sort(function(s,o){return s[0]-o[0]}),this.map.length===0)return;let n=this.map.length,i=[];for(;n>0;)n-=1,i.push(e.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),e.length=this.map[n][0];i.push([...e]),e.length=0;let r=i.pop();for(;r;)e.push(...r),r=i.pop();this.map.length=0}};function l8(t,e,n,i){let r=0;if(!(n===0&&i.length===0)){for(;r-1;){let q=i.events[ee][1].type;if(q==="lineEnding"||q==="linePrefix")ee--;else break}let U=ee>-1?i.events[ee][1].type:null,H=U==="tableHead"||U==="tableRow"?k:l;return H===k&&i.parser.lazy[i.now().line]?n(b):H(b)}function l(b){return t.enter("tableHead"),t.enter("tableRow"),c(b)}function c(b){return b===124||(o=!0,s+=1),u(b)}function u(b){return b===null?n(b):z(b)?s>1?(s=0,i.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(b),t.exit("lineEnding"),h):n(b):J(b)?G(t,u,"whitespace")(b):(s+=1,o&&(o=!1,r+=1),b===124?(t.enter("tableCellDivider"),t.consume(b),t.exit("tableCellDivider"),o=!0,u):(t.enter("data"),d(b)))}function d(b){return b===null||b===124||me(b)?(t.exit("data"),u(b)):(t.consume(b),b===92?p:d)}function p(b){return b===92||b===124?(t.consume(b),d):d(b)}function h(b){return i.interrupt=!1,i.parser.lazy[i.now().line]?n(b):(t.enter("tableDelimiterRow"),o=!1,J(b)?G(t,m,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(b):m(b))}function m(b){return b===45||b===58?w(b):b===124?(o=!0,t.enter("tableCellDivider"),t.consume(b),t.exit("tableCellDivider"),v):P(b)}function v(b){return J(b)?G(t,w,"whitespace")(b):w(b)}function w(b){return b===58?(s+=1,o=!0,t.enter("tableDelimiterMarker"),t.consume(b),t.exit("tableDelimiterMarker"),f):b===45?(s+=1,f(b)):b===null||z(b)?T(b):P(b)}function f(b){return b===45?(t.enter("tableDelimiterFiller"),g(b)):P(b)}function g(b){return b===45?(t.consume(b),g):b===58?(o=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(b),t.exit("tableDelimiterMarker"),y):(t.exit("tableDelimiterFiller"),y(b))}function y(b){return J(b)?G(t,T,"whitespace")(b):T(b)}function T(b){return b===124?m(b):b===null||z(b)?!o||r!==s?P(b):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(b)):P(b)}function P(b){return n(b)}function k(b){return t.enter("tableRow"),M(b)}function M(b){return b===124?(t.enter("tableCellDivider"),t.consume(b),t.exit("tableCellDivider"),M):b===null||z(b)?(t.exit("tableRow"),e(b)):J(b)?G(t,M,"whitespace")(b):(t.enter("data"),I(b))}function I(b){return b===null||b===124||me(b)?(t.exit("data"),M(b)):(t.consume(b),b===92?O:I)}function O(b){return b===92||b===124?(t.consume(b),I):I(b)}}function u8(t,e){let n=-1,i=!0,r=0,s=[0,0,0,0],o=[0,0,0,0],a=!1,l=0,c,u,d,p=new Zy;for(;++nn[2]+1){let m=n[2]+1,v=n[3]-n[2]-1;t.add(m,v,[])}}t.add(n[3]+1,0,[["exit",d,e]])}return r!==void 0&&(s.end=Object.assign({},Jl(e.events,r)),t.add(r,0,[["exit",s,e]]),s=void 0),s}function pD(t,e,n,i,r){let s=[],o=Jl(e.events,n);r&&(r.end=Object.assign({},o),s.push(["exit",r,e])),i.end=Object.assign({},o),s.push(["exit",i,e]),t.add(n+1,0,s)}function Jl(t,e){let n=t[e],i=n[0]==="enter"?"start":"end";return n[1][i]}var d8={tokenize:p8};function iT(){return{text:{91:d8}}}function p8(t,e,n){let i=this;return r;function r(l){return i.previous!==null||!i._gfmTasklistFirstContentOfListItem?n(l):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),s)}function s(l){return me(l)?(t.enter("taskListCheckValueUnchecked"),t.consume(l),t.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(t.enter("taskListCheckValueChecked"),t.consume(l),t.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),a):n(l)}function a(l){return z(l)?e(l):J(l)?t.check({tokenize:h8},e,n)(l):n(l)}}function h8(t,e,n){return G(t,i,"whitespace");function i(r){return r===null?n(r):e(r)}}function hD(t){return jy([U0(),eT(),tT(t),nT(),iT()])}var f8={};function ev(t){let e=this,n=t||f8,i=e.data(),r=i.micromarkExtensions||(i.micromarkExtensions=[]),s=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),o=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);r.push(hD(n)),s.push(F0()),o.push(V0(n))}var fD={tokenize:m8};function m8(t){let e=t.attempt(this.parser.constructs.contentInitial,i,r),n;return e;function i(a){if(a===null){t.consume(a);return}return t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),G(t,e,"linePrefix")}function r(a){return t.enter("paragraph"),s(a)}function s(a){let l=t.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,o(a)}function o(a){if(a===null){t.exit("chunkText"),t.exit("paragraph"),t.consume(a);return}return z(a)?(t.consume(a),t.exit("chunkText"),s):(t.consume(a),o)}}var gD={tokenize:g8},mD={tokenize:y8};function g8(t){let e=this,n=[],i=0,r,s,o;return a;function a(y){if(io))return;let M=e.events.length,I=M,O,b;for(;I--;)if(e.events[I][0]==="exit"&&e.events[I][1].type==="chunkFlow"){if(O){b=e.events[I][1].end;break}O=!0}for(f(i),k=M;ky;){let P=n[T];e.containerState=P[1],P[0].exit.call(e,t)}n.length=y}function g(){r.write([null]),s=void 0,r=void 0,e.containerState._closeFlow=void 0}}function y8(t,e,n){return G(t,t.attempt(this.parser.constructs.document,e,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}var yD={tokenize:v8};function v8(t){let e=this,n=t.attempt(hr,i,t.attempt(this.parser.constructs.flowInitial,r,G(t,t.attempt(this.parser.constructs.flow,r,t.attempt(q0,r)),"linePrefix")));return n;function i(s){if(s===null){t.consume(s);return}return t.enter("lineEndingBlank"),t.consume(s),t.exit("lineEndingBlank"),e.currentConstruct=void 0,n}function r(s){if(s===null){t.consume(s);return}return t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),e.currentConstruct=void 0,n}}var vD={resolveAll:xD()},wD=bD("string"),_D=bD("text");function bD(t){return{tokenize:e,resolveAll:xD(t==="text"?w8:void 0)};function e(n){let i=this,r=this.parser.constructs[t],s=n.attempt(r,o,a);return o;function o(u){return c(u)?s(u):a(u)}function a(u){if(u===null){n.consume(u);return}return n.enter("data"),n.consume(u),l}function l(u){return c(u)?(n.exit("data"),s(u)):(n.consume(u),l)}function c(u){if(u===null)return!0;let d=r[u],p=-1;if(d)for(;++p-1){let a=o[0];typeof a=="string"?o[0]=a.slice(i):o.shift()}s>0&&o.push(t[r].slice(0,s))}return o}function b8(t,e){let n=-1,i=[],r;for(;++nM8,contentInitial:()=>k8,disable:()=>$8,document:()=>x8,flow:()=>E8,flowInitial:()=>T8,insideSpan:()=>C8,string:()=>S8,text:()=>P8});var x8={42:Gt,43:Gt,45:Gt,48:Gt,49:Gt,50:Gt,51:Gt,52:Gt,53:Gt,54:Gt,55:Gt,56:Gt,57:Gt,62:By},k8={91:W0},T8={[-2]:yp,[-1]:yp,32:yp},E8={35:G0,42:Ko,45:[Xy,Ko],60:Q0,61:Xy,95:Ko,96:Wy,126:Wy},S8={38:qy,92:Hy},P8={[-5]:vp,[-4]:vp,[-3]:vp,33:Z0,38:qy,42:gp,60:[B0,X0],91:J0,92:[K0,Hy],93:Wo,95:gp,96:H0},C8={null:[gp,vD]},M8={null:[42,95]},$8={null:[]};function sT(t){let n=jy([rT,...(t||{}).extensions||[]]),i={defined:[],lazy:{},constructs:n,content:r(fD),document:r(gD),flow:r(yD),string:r(wD),text:r(_D)};return i;function r(s){return o;function o(a){return kD(i,s,a)}}}function oT(t){for(;!Ky(t););return t}var TD=/[\0\t\n\r]/g;function aT(){let t=1,e="",n=!0,i;return r;function r(s,o,a){let l=[],c,u,d,p,h;for(s=e+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s)),d=0,e="",n&&(s.charCodeAt(0)===65279&&d++,n=void 0);d0){let wi=oe.tokenStack[oe.tokenStack.length-1];(wi[1]||PD).call(oe,void 0,wi[0])}for(V.position={start:Hs(R.length>0?R[0][1].start:{line:1,column:1,offset:0}),end:Hs(R.length>0?R[R.length-2][1].end:{line:1,column:1,offset:0})},$e=-1;++$eo.length,l;a&&o.push(r);try{l=t.apply(this,o)}catch(c){let u=c;if(a&&n)throw u;return r(u)}a||(l instanceof Promise?l.then(s,r):l instanceof Error?r(l):s(l))}function r(o,...a){n||(n=!0,e(o,...a))}function s(o){r(null,o)}}var $t=class extends Error{constructor(e,n,i){super(),typeof n=="string"&&(i=n,n=void 0);let r="",s={},o=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof e=="string"?r=e:!s.cause&&e&&(o=!0,r=e.message,s.cause=e),!s.ruleId&&!s.source&&typeof i=="string"){let l=i.indexOf(":");l===-1?s.ruleId=i:(s.source=i.slice(0,l),s.ruleId=i.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){let l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}let a=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file,this.message=r,this.line=a?a.line:void 0,this.name=Bs(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual,this.expected,this.note,this.url}};$t.prototype.file="";$t.prototype.name="";$t.prototype.reason="";$t.prototype.message="";$t.prototype.stack="";$t.prototype.column=void 0;$t.prototype.line=void 0;$t.prototype.ancestors=void 0;$t.prototype.cause=void 0;$t.prototype.fatal=void 0;$t.prototype.place=void 0;$t.prototype.ruleId=void 0;$t.prototype.source=void 0;var Vi={basename:A8,dirname:D8,extname:N8,join:O8,sep:"/"};function A8(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');_p(t);let n=0,i=-1,r=t.length,s;if(e===void 0||e.length===0||e.length>t.length){for(;r--;)if(t.codePointAt(r)===47){if(s){n=r+1;break}}else i<0&&(s=!0,i=r+1);return i<0?"":t.slice(n,i)}if(e===t)return"";let o=-1,a=e.length-1;for(;r--;)if(t.codePointAt(r)===47){if(s){n=r+1;break}}else o<0&&(s=!0,o=r+1),a>-1&&(t.codePointAt(r)===e.codePointAt(a--)?a<0&&(i=r):(a=-1,i=o));return n===i?i=o:i<0&&(i=t.length),t.slice(n,i)}function D8(t){if(_p(t),t.length===0)return".";let e=-1,n=t.length,i;for(;--n;)if(t.codePointAt(n)===47){if(i){e=n;break}}else i||(i=!0);return e<0?t.codePointAt(0)===47?"/":".":e===1&&t.codePointAt(0)===47?"//":t.slice(0,e)}function N8(t){_p(t);let e=t.length,n=-1,i=0,r=-1,s=0,o;for(;e--;){let a=t.codePointAt(e);if(a===47){if(o){i=e+1;break}continue}n<0&&(o=!0,n=e+1),a===46?r<0?r=e:s!==1&&(s=1):r>-1&&(s=-1)}return r<0||n<0||s===0||s===1&&r===n-1&&r===i+1?"":t.slice(r,n)}function O8(...t){let e=-1,n;for(;++e0&&t.codePointAt(t.length-1)===47&&(n+="/"),e?"/"+n:n}function V8(t,e){let n="",i=0,r=-1,s=0,o=-1,a,l;for(;++o<=t.length;){if(o2){if(l=n.lastIndexOf("/"),l!==n.length-1){l<0?(n="",i=0):(n=n.slice(0,l),i=n.length-1-n.lastIndexOf("/")),r=o,s=0;continue}}else if(n.length>0){n="",i=0,r=o,s=0;continue}}e&&(n=n.length>0?n+"/..":"..",i=2)}else n.length>0?n+="/"+t.slice(r+1,o):n=t.slice(r+1,o),i=o-r-1;r=o,s=0}else a===46&&s>-1?s++:s=-1}return n}function _p(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}var zD={cwd:z8};function z8(){return"/"}function ec(t){return!!(t!==null&&typeof t=="object"&&"href"in t&&t.href&&"protocol"in t&&t.protocol&&t.auth===void 0)}function UD(t){if(typeof t=="string")t=new URL(t);else if(!ec(t)){let e=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+t+"`");throw e.code="ERR_INVALID_ARG_TYPE",e}if(t.protocol!=="file:"){let e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return U8(t)}function U8(t){if(t.hostname!==""){let i=new TypeError('File URL host must be "localhost" or empty on darwin');throw i.code="ERR_INVALID_FILE_URL_HOST",i}let e=t.pathname,n=-1;for(;++n0){let[h,...m]=u,v=i[p][1];wp(v)&&wp(h)&&(h=(0,rv.default)(!0,v,h)),i[p]=[c,h,...m]}}}},vT=new yT().freeze();function fT(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `parser`")}function mT(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `compiler`")}function gT(t,e){if(e)throw new Error("Cannot call `"+t+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function HD(t){if(!wp(t)||typeof t.type!="string")throw new TypeError("Expected node, got `"+t+"`")}function qD(t,e,n){if(!n)throw new Error("`"+t+"` finished async. Use `"+e+"` instead")}function iv(t){return H8(t)?t:new bp(t)}function H8(t){return!!(t&&typeof t=="object"&&"message"in t&&"messages"in t)}function q8(t){return typeof t=="string"||W8(t)}function W8(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}function WD(t){return vT().use(tv).use(ev).parse(t)}function KD(t,e){let n;if(Yl(e,"link",o=>(n=o,dr)),!n)return null;let i=n.children.first()?.position?.start.offset,r=n.children.last()?.position?.end.offset;return{display:i&&r?t.slice(i,r).trim():"",url:n.url,title:n.title}}function GD(t,e){let n="";return Yl(e,"listItem",i=>{let r=i.children.first()?.position?.start.offset,s=i.children.last()?.position?.end.offset;return r&&s&&(n=t.slice(r,s)),dr}),n}function K8(t){return!t.frontmatter||!("autoplay"in t.frontmatter)?!0:!!t.frontmatter.autoplay}async function QD(t,e){let n=e.app.metadataCache.getFileCache(t);if(!n)return null;let r=await G8(n,{source:t,plugin:e});return r?{autoplay:K8(n),title:Q8(n,t),list:r,file:t}:null}async function G8(t,e){let{metadataCache:n,vault:i}=e.plugin.app,{frontmatter:r}=t;if(r?.playlist!==!0||!t.sections||!t.listItems)return null;let s=t.sections.find(p=>p.type==="list");if(!s)return[];let o=p=>wT(p,s),a=Y8(t.listItems.filter(o)),l=t.links?.filter(o)??[],c=await i.cachedRead(e.source);return a.map((p,h,m)=>{let v=l.findIndex(M=>wT(M,p)),{parent:w,task:f}=p,g=f&&Dk[f],y=w>=0?m.findIndex(M=>M.position.start.line===w):-1;if(v!==-1){let M=l[v],I=l.findLastIndex(b=>wT(b,p));return l.splice(v,I-v+1),{media:d(M),type:g??"generic",parent:y,title:M.displayText??""}}let T=X8(c,p.position),P=WD(T),k=KD(T,P);if(k){let{url:M}=k,I=e.plugin.resolveUrl(M),{display:O}=k;return I&&(O===M||!O)&&(O=ea(I)),{media:I,title:O,type:g||"generic",parent:y}}return{media:null,title:GD(T,P)||"Item",type:g||"chapter",parent:y}});function d({link:p}){let{path:h,subpath:m}=(0,YD.parseLinktext)(p),v=n.getFirstLinkpathDest(h,e.source.path);return Ui(v,m)}}function Y8(t){return t.map(({task:e,...n})=>hL(e)?{task:e,...n}:n)}function Q8(t,e){return t.frontmatter?.title?.trim()||t.headings?.find(n=>n.level===1)?.heading?.trim()||e.basename.trim()}function wT(t,e){return t.position.start.offset>=e.position.start.offset&&t.position.end.offset<=e.position.end.offset}function X8(t,e){return t.slice(e.start.offset,e.end.offset)}var sv=class extends Go.Component{constructor(n){super();this.plugin=n;E(this,"app");E(this,"mediaToPlaylistIndex",new Map);E(this,"listVariantMap",new WeakMap);E(this,"listFileCache",new Map);E(this,"updateQueue",new Set);E(this,"updater",(0,Go.debounce)(async()=>{let n=[...this.updateQueue.values()];this.updateQueue.clear(),n.length!==0&&(await Promise.all(n.map(i=>QD(i,this.plugin).then(r=>{r?this.update(i,r):this.remove(i.path)}))),this.updateQueue.size>0&&this.updater())},500));E(this,"requestNotify",(0,Go.debounce)(()=>this.notify(),500));this.app=n.app}get(n){return n?this.mediaToPlaylistIndex.get(un(n))??Nk:Nk}onResolve(){this.mediaToPlaylistIndex.clear();for(let n of pp(this.app.vault.getRoot()))n.extension==="md"&&this.requestUpdate(n);this.registerEvent(this.app.metadataCache.on("changed",n=>{this.requestUpdate(n)})),this.registerEvent(this.app.metadataCache.on("deleted",n=>{this.remove(n.path)})),this.registerEvent(this.app.vault.on("rename",(n,i)=>{if(!(n instanceof Go.TFile))return;let r=this.listFileCache.get(i);r&&(this.remove(i),this.update(n,r))}))}remove(n){let i=this.listFileCache.get(n);if(i){this.listFileCache.delete(n);for(let r of this.mediaToPlaylistIndex.keys()){let o=this.mediaToPlaylistIndex.get(r).filter(a=>!this.listVariantMap.has(a)||this.listVariantMap.get(a)!==i);o.length===0?this.mediaToPlaylistIndex.delete(r):this.mediaToPlaylistIndex.set(r,o)}this.requestNotify()}}requestUpdate(n){this.updateQueue.add(n),this.updater()}notify(){this.app.metadataCache.trigger("mx-playlist-change")}update(n,i){this.remove(n.path),this.listFileCache.set(n.path,i);let r=new Set;i.list.forEach(s=>{let{media:o}=s;if(!o)return;let a=un(o);if(r.has(a))return;let l=this.mediaToPlaylistIndex.get(a)??[],c={...i,active:i.list.findIndex(u=>u.media&&a===un(u.media))};this.listVariantMap.set(c,i),this.mediaToPlaylistIndex.set(a,[...l,c]),r.add(a)}),this.requestNotify()}onload(){Dy(this.app.metadataCache,this).then(()=>{this.onResolve()}),this.plugin.addCommand({id:"playlist-export",name:"Export current playlist to m3u8 file",editorCheckCallback:(n,i,r)=>{if(!r.file||!this.listFileCache.has(r.file.path))return!1;if(n)return!0;c0(this.listFileCache.get(r.file.path),this.app.vault)}}),this.registerEvent(this.app.workspace.on("file-menu",(n,i,r)=>r==="more-options"&&this.listFileCache.has(i.path)&&n.addItem(s=>s.setTitle("Export to m3u8...").setIcon("file-down").setSection("action").onClick(()=>{c0(this.listFileCache.get(i.path),this.app.vault)}))))}};var XD=require("obsidian"),ZD=A(mu());var _T=A(_e()),ov=class extends XD.Component{constructor(n,i,r,s){super();this.info=n;this.file=i;this.subpath=r;this.plugin=s;E(this,"store");E(this,"root",null);E(this,"containerEl");this.containerEl=n.containerEl,this.store=Rs();let{containerEl:o}=n;o.addClasses(["mx","mx-media-embed","custom"]);function a(l){if(!(l instanceof Element))return!1;let c=l.closest("button");return c?c.hasAttribute(Hr):!1}this.registerDomEvent(o,"click",l=>{a(l.target)||l.stopImmediatePropagation()})}getMediaInfo(){return Ui(this.file,this.subpath)}render(){this.root?.unmount(),this.root=ZD.default.createRoot(this.info.containerEl),this.root.render((0,_T.jsx)(Vt.Provider,{value:{plugin:this.plugin,store:this.store,reload:()=>this.render(),embed:!0},children:(0,_T.jsx)(Os,{})}))}onload(){super.onload(),this.render()}async loadFile(){await this.store.getState().loadFile(this.file,{vault:this.plugin.app.vault,subpath:this.subpath,defaultLang:this.plugin.settings.getState().getDefaultLang()})}onunload(){this.root?.unmount(),this.root=null,super.onunload()}};function JD(t,e){let n=e.muted;t.addItem(i=>i.setSection("mx-player").setIcon(n?"volume-2":"volume-x").setTitle(n?"Unmute":"Mute").onClick(()=>{e.muted=!n}))}function eN(t,e){e.state.canPictureInPicture&&(e.state.pictureInPicture?t.addItem(n=>n.setTitle("Exit Picture in Picture").setIcon("picture-in-picture-2").setSection("mx-player").onClick(()=>e.exitPictureInPicture())):t.addItem(n=>n.setTitle("Picture in Picture").setSection("mx-player").setIcon("picture-in-picture").onClick(()=>e.enterPictureInPicture())))}function tN(t,{setTransform:e,transform:n}){let i=t.setTitle("Transform").setIcon("rotate-3d").setSection("mx-player").setSubmenu();(n?.flipHorizontal||n?.flipVertical||n?.rotate)&&i.addItem(r=>r.setIcon("reset").setTitle("Reset").onClick(()=>e(null))),i.addItem(r=>r.setTitle("Flip horizontally").setIcon("flip-horizontal").setChecked(!!n?.flipHorizontal).onClick(()=>e({flipHorizontal:!n?.flipHorizontal}))).addItem(r=>r.setTitle("Flip vertically").setIcon("flip-vertical").setChecked(!!n?.flipVertical).onClick(()=>e({flipVertical:!n?.flipVertical}))).addSeparator().addItem(r=>r.setChecked(n?.rotate==="180").setIcon("iteration-cw").setTitle("Rotate 180\xB0").onClick(()=>{e({rotate:n?.rotate==="180"?void 0:"180"})}))}var bT=require("obsidian");function nN(t,{source:e,plugin:n,viewType:i,player:r}){if(ke(e))return;if(e.isFileUrl){Ly(e,t);return}let s=e.jsonState.source,o=e.print({start:r.currentTime,end:-1});t.addItem(u=>u.setTitle("Copy URL").setIcon("copy").setSection("action").onClick(()=>{navigator.clipboard.writeText(s),new bT.Notice("URL copied to clipboard")})),o!==s&&t.addItem(u=>u.setTitle("Copy URL with timestamp").setIcon("copy-check").setSection("action").onClick(()=>{navigator.clipboard.writeText(o),new bT.Notice("URL with timestamp copied")})),t.addItem(u=>u.setTitle("Open in default browser").setIcon("globe").setSection("view").onClick(()=>{window.open(o)}));let a=n.urlViewType.getSupported(e),l=i,c=a.filter(u=>u!==l);dp(t,{mode:"always",open:!1,url:e,plugin:n,targetViewTypes:c})}function iN(t,{controls:e=!0,toggleControls:n,player:i,source:r,disableWebFullscreen:s,toggleWebFullscreen:o},a){i.provider instanceof mi&&a==="more-options"&&(t.addItem(l=>{l.setTitle(e?"Show website native controls":"Hide website controls").setSection("mx-web-player").setIcon("sliders-horizontal").onClick(()=>{n(!e)})}),r.type!=="bilibili"&&r.type!=="youtube"&&t.addItem(l=>{l.setTitle(s?"Enable in-player fullscreen":"Disable in-player fullscreen").setSection("mx-web-player").setIcon(s?"maximize":"minimize").onClick(()=>{o(!!s)})}))}function xT(){d2(this),this.registerEvent(this.app.workspace.on("mx-media-menu",(t,e,n)=>{if((n==="more-options"||n==="sidebar-context-menu"||n==="tab-header"||n==="player-menu-embed")&&t.addItem(r=>r.setTitle("Refresh").setSection("action").setIcon("reset").onClick(()=>{e.reload()})),n!=="sidebar-context-menu"&&n!=="tab-header"?(t.addItem(r=>gS(r,e.player)),e.player.state.viewType==="video"&&(t.addItem(r=>tN(r,e)),eN(t,e.player))):JD(t,e.player),n==="player-menu-embed"){let r=e.source;t.addItem(s=>s.setTitle("Open to the right").setIcon("separator-vertical").setSection("open").onClick(()=>{this.leafOpener.openMedia(r,"split")})).addItem(s=>s.setTitle("Open in new tab").setSection("open").setIcon("file-plus").onClick(()=>{this.leafOpener.openMedia(r,"tab")})).addItem(s=>s.setTitle("Open in new window").setSection("open").setIcon("maximize").onClick(()=>{this.leafOpener.openMedia(r,"window")}))}iN(t,e,n),(n==="player-menu-embed"||n==="more-options")&&nN(t,e);let i=e.player.provider;(n==="player-menu-embed"||n==="more-options"||n==="sidebar-context-menu")&&Do(i)&&t.addItem(r=>r.setTitle("Copy Screenshot").setSection("action").setIcon("focus").onClick(()=>{Gd({app:this.app,media:e.source,provider:i,settings:this.settings.getState(),state:e.player.state})}))}))}var Z8=/^(?\d+)?x(?\d+)$|^(?\d+)$/;function rN(t){let e=parseInt(t,10);return Number.isNaN(e)?-1:e}var sN=t=>{let e=t?.match(Z8)?.groups;if(!e)return null;let n=rN(e.xOnly??e.x),i=rN(e.y);return[n,i]},xp=t=>{let e=t.lastIndexOf("|"),n,i=t;return e===-1?(n=sN(t),n&&(i="")):(n=sN(i.substring(e+1)),n&&(i=i.substring(0,e))),{title:i,size:n}};function av(t,{title:e,size:n}){e?t.setAttr("alt",e):t.removeAttribute("alt");let i=(r,s)=>{s<0?t.style.removeProperty(r):t.style[r]=`${s}px`};n?(i("width",n[0]),i("height",n[1])):(i("width",-1),i("height",-1))}var oN=require("obsidian"),aN=A(mu());var kT=A(_e()),tc=class extends oN.MarkdownRenderChild{constructor(n,i){super(n);this.containerEl=n;this.plugin=i;E(this,"store");E(this,"root",null);this.store=Rs(),n.addClasses(["mx","custom","mx-media-embed"])}getMediaInfo(){return this.store.getState().source?.url??null}async setSource(n,i={}){let r=this.plugin.urlViewType.getPreferred(n),s=this.plugin.settings.getState().getDefaultLang();this.store.getState().setSource(n,{title:i.title??!0,hash:i.hash,viewType:r,textTracks:r===Xt.video?await Dg(n,s).catch(o=>(console.error("Failed to get text tracks",o,n.href,s),[])):[]})}render(){this.root?.unmount(),this.root=aN.default.createRoot(this.containerEl),this.root.render((0,kT.jsx)(Vt.Provider,{value:{plugin:this.plugin,store:this.store,reload:()=>this.render(),embed:!0},children:(0,kT.jsx)(Os,{})}))}onload(){super.onload(),this.render()}onunload(){this.root?.unmount(),this.root=null,super.onunload()}};var uN=require("@codemirror/state"),nc=require("@codemirror/view"),ic=require("obsidian");var cv=require("@codemirror/language"),RT=require("@codemirror/view");var lN=t=>!(!t.startsWith("./")&&!t.startsWith("../"))||t.indexOf(":")===-1;var MT=require("@codemirror/view"),$T=require("obsidian");var TT=class extends tc{constructor(n,i){super(n,i);this.containerEl=n;this.plugin=i;n.addClasses(["mx-external-media-embed"]);function r(s){if(!(s instanceof Element))return!1;let o=s.closest("button");return o?o.hasAttribute(Hr):!1}this.registerDomEvent(n,"click",s=>{r(s.target)||s.stopImmediatePropagation()})}},lv=class t extends MT.WidgetType{constructor(n,i,r){super();this.message=n;this.start=i;this.end=r}toDOM(n){let i=document.createElement("div");return this.hookClickHandler(n,i),i.className="external-embed mx-external-media-embed mx-invalid-notice",i.createEl("p",{text:this.message}),i}eq(n){return n instanceof t&&n.message===this.message}updateDOM(n){return n.textContent!==this.message?(n.empty(),n.createEl("p",{text:this.message}),!0):!1}hookClickHandler(n,i){i.addEventListener("click",r=>{r.defaultPrevented||(this.selectElement(n,i),r.preventDefault())})}selectElement(n,i){let r=i.playerInfo,{start:s}=r??this,{end:o}=r??this;try{if(s<0||o<0){let a=n.posAtDOM(i);n.dispatch({selection:{head:a,anchor:a}}),n.focus()}else $T.Platform.isMobile&&(o=s),n.dispatch({selection:{head:s,anchor:o}}),n.focus()}catch{}}},Yo=class extends MT.WidgetType{constructor(n,i,r,s,o){super();this.plugin=n;this.media=i;this.title=r;this.start=s;this.end=o}setPos(n){let i=n.playerInfo;i&&(i.start=this.start,i.end=this.end)}hookClickHandler(n,i){i.on("click","button.mx-lp-edit",r=>{r.defaultPrevented||(this.selectElement(n,i),r.preventDefault())})}selectElement(n,i){let r=i.playerInfo,{start:s}=r??this,{end:o}=r??this;try{if(s<0||o<0){let a=n.posAtDOM(i);n.dispatch({selection:{head:a,anchor:a}}),n.focus()}else $T.Platform.isMobile&&(o=s),n.dispatch({selection:{head:s,anchor:o}}),n.focus()}catch{}}resizeWidget(n,i){window.ResizeObserver&&new window.ResizeObserver(()=>n.requestMeasure()).observe(i,{box:"border-box"})}setInfo(n,i){n.playerInfo={title:this.title,start:this.start,end:this.end,child:i,url:this.media}}updateDOM(n){let i=n.playerInfo;if(!i)return!1;let{title:r}=i;return this.media.compare(i.url)?this.title!==r&&(i.title=this.title,this.applyTitle(n),this.setPos(n)):i.child.setSource(this.media),!0}destroy(n){let i=n.playerInfo;i&&(delete n.playerInfo,i.child.unload())}eq(n){return this.media.compare(n.media)&&this.title===n.title}setDOM(n,i){i.tabIndex=-1,this.applyTitle(i);let r=new TT(i,this.plugin);r.setSource(this.media),r.load(),this.hookClickHandler(n,i),this.setInfo(i,r),this.resizeWidget(n,i)}applyTitle(n){av(n,xp(this.title))}toDOM(n){let i=createDiv();return i.style.display="none",i.setAttr("src",this.media.source.href),i.addClasses(["external-embed","cm-embed-block","mx-media-embed"]),i.style.removeProperty("display"),this.setDOM(n,i),i}};Object.defineProperty(Yo.prototype,"estimatedHeight",{get:()=>100,enumerable:!1,configurable:!0});var ET=class extends Yo{constructor(){super(...arguments);E(this,"enableWebview",!1)}},ST=class extends Yo{constructor(){super(...arguments);E(this,"enableWebview",!1)}},PT=class extends Yo{constructor(){super(...arguments);E(this,"enableWebview",!1)}},CT=class extends Yo{constructor(){super(...arguments);E(this,"enableWebview",!0)}},cN={"mx-url-audio":ST,"mx-url-video":ET,"mx-embed":PT,"mx-webpage":CT};var J8=(t,e,n,i,r)=>{let s=e.doc,o=!1,a="",l="",c=-1;(0,cv.syntaxTree)(e).iterate({from:i,to:r,enter:({type:d,from:p,to:h})=>{let m=new Set(d.prop(cv.tokenClassNodeProp)?.split(" "));if(m){if(m.has("image-marker"))o=!0,c=p;else if(m.has("image-alt-text")&&!m.has("formatting"))a=s.sliceString(p,h);else if(o&&m.has("url")&&!m.has("formatting"))l=s.sliceString(p,h);else if(o&&l&&m.has("formatting")){if(lN(l))return;let v=t.resolveUrl(l);if(v){if(ke(v)){let w=t.app.metadataCache.fileToLinktext(v.file,"");u(new lv(`Please use internal embed in favor of file url embed: ![[${w}]]`,c,h),c,h)}else if(Wl(v,t)){let w=t.urlViewType.getPreferred(v),f=new cN[w](t,v,a,c,h);u(f,c,h)}}o=!1,l="",a="",c=-1}}}});function u(d,p,h){let{from:v,text:w}=s.lineAt(p);w.substring(0,p-v).trim()===""&&w.substring(h-v).trim()===""?n.push(RT.Decoration.widget({widget:d,block:!0,side:-1}).range(v)):n.push(RT.Decoration.widget({widget:d,side:-1}).range(p))}},IT=J8;var eq=(t,e)=>uv(t,e[0])||uv(t,e[1]),uv=(t,e)=>t[0]e,tq=(t,e)=>{let n=uv(t,e[0])?t[0]:e[0],i=uv(t,e[1])?t[1]:e[1];return[n,i]};function LT(t){return t.sort((e,n)=>e[0]-n[0]).reduce((e,n)=>{let i=e.findIndex(r=>eq(r,n));return i!==-1?e[i]=tq(e[i],n):e.push(n),e},[])}var nq=t=>{let e=n=>{if(n.field(ic.editorLivePreviewField)){let i=[];return IT(t,n,i),nc.Decoration.set(i)}else return nc.Decoration.none};return uN.StateField.define({create:e,update:(n,i)=>{let r=i.startState.field(ic.editorLivePreviewField),s=i.state.field(ic.editorLivePreviewField);if(r!==s)return e(i.state);if(!s)return nc.Decoration.none;if(!i.docChanged)return n;if(i.state.field(ic.editorEditorField).composing)return n.map(i.changes);n=n.map(i.changes);let o=[];i.changes.iterChangedRanges((l,c,u,d)=>{o.push([i.state.doc.lineAt(u).number,i.state.doc.lineAt(d).number])});let a=[];for(let[l,c]of LT(o)){let{from:u}=i.state.doc.line(l),{to:d}=i.state.doc.line(c);n=n.update({filterFrom:u,filterTo:d,filter:()=>!1}),IT(t,i.state,a,u,d)}return n.update({add:a,sort:!0})},provide:n=>nc.EditorView.decorations.from(n)})},dN=nq;function AT(t){t.registerEditorExtension(dN(t)),rq(t)}var iq=["cm-line","cm-content"],pN="mxError";function hN(t){if(!t.parentElement)return!1;let e=t.parentElement;return iq.some(n=>e.classList.contains(n))}function fN(){hN(this)&&(this.dataset[pN]="",this.removeEventListener("load",mN))}function mN(){hN(this)&&(delete this.dataset[pN],this.removeEventListener("error",fN))}function rq(t){t.register(vt(window,{createEl:e=>function(){let n=e.apply(this,arguments);return n instanceof HTMLImageElement&&(n.addEventListener("error",fN,{once:!0}),n.addEventListener("load",mN,{once:!0})),n}}))}var sq=require("obsidian");function gN(t,e){let{app:n}=e;return new Promise(i=>{function r(){let s=n.workspace.getLeavesOfType(t)[0];return s?(i(s.view),!0):!1}n.workspace.onLayoutReady(()=>{if(r())return;let s=()=>{r()&&n.workspace.off("layout-change",s)};n.workspace.on("layout-change",s),e.register(()=>n.workspace.off("layout-change",s))})})}function dv(t){return t.constructor.prototype}function DT(t){t.getLeavesOfType("markdown").forEach(async e=>{let n=e.getViewState();await e.setViewState({type:"empty"}),await e.setViewState(n)})}function OT(t){oq.call(this,t),aq.call(this),AT(this)}function oq(t){let{app:e}=this;["video","audio"].forEach(r=>{let s=Yt[r],o=i(s),a=n(s,t);this.register(()=>{a(),o()})}),DT(e.workspace),this.register(()=>{DT(e.workspace)});function n(r,s){return e.embedRegistry.registerExtensions(r,s),()=>{e.embedRegistry.unregisterExtensions(r)}}function i(r){let s=r.map(o=>e.embedRegistry.embedByExtension[o]);return e.embedRegistry.unregisterExtensions(r),()=>{r.forEach((o,a)=>{let l=s[a];l&&e.embedRegistry.registerExtension(o,l)})}}}var NT=class extends tc{constructor(n,i,r){super(i,r);this.info=n;this.containerEl=i;this.plugin=r;i.addClasses(["mx-external-media-embed"])}onload(){this.setSource(this.info),super.onload()}};function aq(){let t=this;this.registerMarkdownPostProcessor((e,n)=>{for(let r of e.querySelectorAll("img")){let s=lq(r);s&&i(s,r)}for(let r of e.querySelectorAll('iframe.external-embed[src*="youtube.com/embed/"]')){let s=n.getSectionInfo(r)?.text,o=cq(s)??uq(r);!o||!this.resolveUrl(o.url)||i(o,r)}function i(r,s){let o=t.resolveUrl(r.url);if(!o||ke(o)||!Wl(o,t))return;let a=createDiv({cls:["media-embed","external-embed","is-loaded"],attr:{src:o.href}});av(a,r),s.replaceWith(a);let l=new NT(o,a,t);n.addChild(l)}})}function lq(t){let e=t.alt,n=t.src;return n?{url:n,...xp(e)}:null}function cq(t){if(!t)return null;let e=t.match(/!\[(?[^\]]*)\]\((?[^)]+)\)/);if(!e)return null;let{alt:n,src:i}=e.groups;return i?{url:i,...xp(n)}:null}function uq(t){console.warn("cannot get source text of iframe, use src instead");let e=t.src;return e?{url:e,title:Og(e),size:null}:null}function FT({onExternalLinkClick:t}){let e=this;return gN("markdown",e).then(n=>{if(!n.editMode){console.error("MarkdownView.editMode is not available, cannot patch editor click");return}e.register(vt(dv(n.editMode),{triggerClickableToken:i=>async function(r,s,...o){let a=()=>i.call(this,r,s,...o);if(t&&r.type==="external-link")try{await t.call(e,r.text,Xr(s),a)}catch(l){console.error("onExternalLinkClick error in editor, fallback to default",l),a()}else a()}})),console.debug("editor click patched")})}var yN=require("obsidian");function VT(){let t=n=>{let i=n.target;if(!i.instanceOf(HTMLElement)||!i.matches(".metadata-property .metadata-property-value .external-link"))return;let r=i.closest(".metadata-property");if(!r)return;let s=r.dataset.propertyKey;if(!aL.includes(s))return;let o=this.resolveUrl(i.textContent);o&&(n.stopImmediatePropagation(),this.leafOpener.openMedia(o,th(n),{fromUser:!0}))},e=vt(yN.MarkdownView.prototype,{onload:n=>function(){return this.registerDomEvent(this.containerEl,"click",t,{capture:!0}),n.call(this)}});this.register(()=>{e(),this.app.workspace.getLeavesOfType("markdown").forEach(n=>n.view.containerEl.removeEventListener("click",t))})}var vN=require("obsidian");function zT({onInternalLinkClick:t}){let e=this;this.register(vt(vN.Workspace.prototype,{openLinkText:n=>async function(i,r,s,o,...a){let l=()=>n.call(this,i,r,s,o,...a);try{await t.call(e,i,r,Xr(s),l)}catch(c){console.error("onInternalLinkClick error in openLinktext, fallback to default",c),l()}}}))}function UT(){this.registerMarkdownPostProcessor(t=>t.querySelectorAll("a").forEach(e=>{let n=e.getAttr("aria-label");if(n)try{let i=decodeURI(n);n!==i&&e.setAttr("aria-label",i)}catch{}}))}var wN=require("obsidian");function jT(t){let e=this,n=vt(wN.MarkdownPreviewRenderer,{registerDomEvents:i=>function(r,s,...o){return dq(s,t,e),n(),console.debug("preview click patched"),i.call(this,r,s,...o)}});e.register(n)}function dq(t,{onExternalLinkClick:e},n){n.register(vt(dv(t),{onExternalLinkClick:i=>async function(r,s,o,...a){let l=()=>i.call(this,r,s,o,...a);if(!e)return l();r.preventDefault();try{await e.call(n,o,th(r),l)}catch(c){console.error("onExternalLinkClick error in preview, fallback to default",c),l()}}}))}function BT(t,e,n){let{app:i}=this;this.registerView(t,e),this.register(r(n)),this.registerExtensions(n,t);function r(s){let o=s.map(a=>({ext:a,type:i.viewRegistry.typeByExtension[a]}));return i.viewRegistry.unregisterExtensions(s),()=>{pq(o,"type").forEach((a,l)=>{l&&i.viewRegistry.registerExtensions(a.map(c=>c.ext),l)})}}}function pq(t,e){return t.reduce((n,i)=>{let r=i[e],s=n.get(r);return s?s.push(i):n.set(r,[i]),n},new Map)}var _N=require("obsidian");function bN(t){return t?(t=t instanceof URL?t:ki(t),_N.Platform.isWin||!t||t.protocol!=="file:"||!t.pathname.includes("%5C")||(t.pathname=t.pathname.replaceAll(/%5C/g,"/")),t):null}var MN=A(Ap()),gt=require("obsidian");var xN=()=>(...t)=>t;var kN=require("obsidian");var TN={6:"240P \u6781\u901F",16:"360P \u6D41\u7545",32:"480P \u6E05\u6670",64:"720P \u9AD8\u6E05",74:"720P60 \u9AD8\u5E27\u7387",80:"1080P \u9AD8\u6E05",112:"1080P+ \u9AD8\u7801\u7387",116:"1080P60 \u9AD8\u5E27\u7387",120:"4K \u8D85\u6E05",125:"HDR \u771F\u5F69\u8272",126:"\u675C\u6BD4\u89C6\u754C",127:"8K \u8D85\u9AD8\u6E05"};async function HT(t,e){await t.cookies.set({url:"https://www.bilibili.com",domain:".bilibili.com",path:"/",name:"CURRENT_QUALITY",value:e.toString(),expirationDate:Date.now()+1e3*60*60*24*365})}var EN=xN()("defaultVolume","urlMappingData","devices","defaultMxLinkClick","linkHandler","speedStep","loadStrategy","timestampTemplate","screenshotTemplate","screenshotEmbedTemplate","insertBefore","timestampOffset","biliDefaultQuality","screenshotFormat","screenshotQuality","defaultLanguage","screenshotFolderPath"),SN={defaultVolume:80,urlMappingData:[],devices:[],defaultMxLinkClick:{click:"split",alt:"window"},linkHandler:{"mx-embed":[],"mx-url-audio":[],"mx-url-video":[],"mx-webpage":[]},loadStrategy:"eager",timestampTemplate:` - {{TIMESTAMP}} `,screenshotEmbedTemplate:"{{TITLE}}{{DURATION}}|50",screenshotTemplate:` - !{{SCREENSHOT}} {{TIMESTAMP}} `,insertBefore:!1,timestampOffset:0,biliDefaultQuality:80,screenshotFormat:"image/webp",speedStep:.1};function PN(){return gt.Platform.isDesktopApp?require("os").hostname()||(gt.Platform.isMacOS?"Mac":gt.Platform.isWin?"Windows":gt.Platform.isLinux?"Linux":"Desktop"):gt.Platform.isIosApp?gt.Platform.isPhone?"iPhone":gt.Platform.isTablet?"iPad":"iOS Device":gt.Platform.isAndroidApp?gt.Platform.isPhone?"Android Phone":gt.Platform.isTablet?"Android Tablet":"Android Device":"Unknown Device"}function CN(t){return new Map(t.map(e=>[`${e.appId}%${e.protocol}`,e.replace]))}function hq(t){return Array.from(t.entries()).map(([e,n])=>{let[i,r]=e.split("%");return{appId:i,protocol:r,replace:n}}).filter(e=>e.appId&&e.protocol&&e.replace)}function $N(t){let e=(0,gt.debounce)(n=>{let i=Tv(n,EN);t.saveData({...i,urlMappingData:n.getUrlMappingData()})},1e3);return Ef((n,i)=>({...Cp(SN,["urlMappingData"]),setSpeedStep(r){r=Math.abs(r),r!==0&&(n({speedStep:r}),e(i()))},setScreenshotFormat(r){n({screenshotFormat:r}),e(i())},setScreenshotQuality(r){n({screenshotQuality:r??void 0}),e(i())},setDefaultLanguage(r){n({defaultLanguage:r?.format()}),e(i())},getDefaultLang(){let r=i().defaultLanguage,s=gt.moment.locale();return r&&!Mk(r)?(new gt.Notice(`Invalid language code detected in preferences: ${r}, reverting to ${s}.`),n({defaultLanguage:void 0}),e(i()),s):r??gt.moment.locale()},getUrlMappingData(){return hq(i().urlMapping)},setBiliDefaultQuality(r){n({biliDefaultQuality:r}),e(i())},setInsertPosition(r){n({insertBefore:r==="before"}),e(i())},setLinkHandler(r,s){n(o=>{let a={...o.linkHandler};for(let l of Object.keys(a)){let c=l;a[c]=a[c].filter(u=>typeof u=="string"?u!==r:typeof r=="string"||!fq(u,r)),c===s&&(a[c]=[...a[c],r])}return{linkHandler:a}}),e(i())},setTimestampOffset(r){n({timestampOffset:r}),e(i())},setDefaultMxLinkBehavior:r=>{let s;r==="split"||r==="split-horizontal"?s="window":r==="window"?s="tab":r==="tab"?s="split":s=null,n({defaultMxLinkClick:{click:r,alt:s}}),e(i())},setTemplate(r,s){switch(r){case"screenshot":n({screenshotTemplate:s});break;case"screenshotEmbed":n({screenshotEmbedTemplate:s});break;case"timestamp":n({timestampTemplate:s});break;default:(0,MN.assertNever)(r)}e(i())},setMxLinkAltBehavior:r=>{n(({defaultMxLinkClick:s})=>({defaultMxLinkClick:{...s,alt:r}})),e(i())},urlMapping:CN(SN.urlMappingData),setDefaultVolume:r=>{n({defaultVolume:r}),e(i())},getUrlMapping:r=>i().urlMapping.get(`${t.app.appId}%${r}`),setUrlMapping:(r,s)=>{if(r.includes("%"))throw new Error("Protocol cannot contain %");let o=`${t.app.appId}%${r}`;n(a=>({urlMapping:new Map(a.urlMapping).set(o,s),devices:a.getDeviceName()?a.devices:[...a.devices,{appId:t.app.appId,name:PN()}]})),e(i())},removeUrlMapping:r=>{if(r.includes("%"))throw new Error("Protocol cannot contain %");n(s=>{let o=`${t.app.appId}%${r}`,a=new Map(s.urlMapping);return a.delete(o),{urlMapping:a}}),e(i())},getDeviceName(r=t.app.appId){return i().devices.find(s=>s.appId===r)?.name},getDeviceNameWithDefault(r=t.app.appId){let s=i().devices.find(o=>o.appId===r);return s?s.name:r===t.app.appId?PN():"Unknown Device"},setDeviceName(r,s=t.app.appId){n({devices:[...i().devices.filter(o=>o.appId!==s),{appId:s,name:r}]}),e(i())},setLoadStrategy:r=>{n({loadStrategy:r}),e(i())},setScreenshotFolder(r){r!==null?(r=(0,gt.normalizePath)(r),r==="."?r="/":r.startsWith("./")&&(r=r.slice(2)),n({screenshotFolderPath:r})):n({screenshotFolderPath:void 0})},load:async()=>{let r=await t.loadData();if(!r)return;let{urlMappingData:s,...o}=Tv(r,EN);n({...o,urlMapping:CN(s??[])})},save:()=>{e(i())}}))}function fq(t,e){let n=new Set([...Object.keys(t),...Object.keys(e)]);for(let i of n)if(t[i]!==e[i])return!1;return!0}var IN=require("url"),WT=A(Pk()),ue=require("obsidian");var hv=class extends ue.PluginSettingTab{constructor(n){super(n.app,n);E(this,"plugin");this.plugin=n}get state(){return this.plugin.settings.getState()}get sub(){return this.plugin.settings.subscribe.bind(this.plugin.settings)}protocol(){new ue.Setting(this.containerEl).setHeading().setName("Protocols").setDesc("Create custom protocols that resolve link per device");let n=this.containerEl.createDiv({cls:"mx-protocol-container"});new ue.Setting(n).setHeading().setName("This device").addText(a=>a.setPlaceholder(this.state.getDeviceNameWithDefault()).setValue(this.state.getDeviceName()??"").onChange(l=>this.state.setDeviceName(l))).addExtraButton(a=>a.setIcon("plus").setTooltip("Add new protocol").onClick(()=>{let l=new ue.Menu().addItem(c=>c.setIcon("link").setTitle("Link mapping").onClick(()=>{let u=r({protocol:"",replace:"https://"});i.insertAdjacentElement("afterbegin",u.settingEl)}));ue.Platform.isDesktopApp&&l.addItem(c=>c.setIcon("folder").setTitle("Folder mapping").onClick(async()=>{let u=(await Xp().showOpenDialog({title:"Pick a folder",message:"Pick a folder to resolve media files from",buttonLabel:"Pick",properties:["openDirectory"]})).filePaths[0];if(!u)return;let d=r({protocol:"",replace:(0,IN.pathToFileURL)(u).href});i.insertAdjacentElement("afterbegin",d.settingEl)})),ya(a.extraSettingsEl,l)}));let i=n.createDiv({cls:"mx-protocol-list"}),r=a=>new ue.Setting(i).then(l=>{let c=a.protocol,u=new ue.TextComponent(l.controlEl).setPlaceholder("Protocol name").setValue(c).onChange(h=>{if(!h)return;let m=c;c=h,this.state.removeUrlMapping(m);let v=p.getValue();v&&this.state.setUrlMapping(h,v)}),d="Target URL prefix";if(a.devices){d="Configured in ";let h=a.devices.filter(m=>!!m).slice(0,2);h.length>0?(d+=h.join(", "),h.length1&&(d+="s"))}let p=new ue.TextComponent(l.controlEl).setPlaceholder(d).setValue(a.replace).onChange(h=>{u.getValue()&&this.state.setUrlMapping(u.getValue(),h)});u.inputEl.addClass("mx-protocol-input"),p.inputEl.addClass("mx-replace-input"),l.addExtraButton(h=>h.setIcon("trash").setTooltip(`Remove ${u.getValue()||"empty"} protocol`).onClick(()=>{this.state.removeUrlMapping(u.getValue()),l.settingEl.remove()}))}),s=this.state.getUrlMappingData();[...new Set(s.map(a=>a.protocol))].sort().forEach(a=>{r({protocol:a,devices:s.filter(l=>l.protocol===a&&l.appId!==this.plugin.app.appId).map(l=>this.state.devices.find(c=>c.appId===l.appId)?.name??null),replace:this.state.getUrlMapping(a)??""})})}linkOpen(){let{containerEl:n}=this;new ue.Setting(n).setHeading().setName("Link open").setDesc("Configure how links to media are opened");let i={default:"Default obsidian behavior",replace:"In current pane",split:"New pane on the right","split-horizontal":"New pane on the bottom",tab:"New tab",window:"New window"},r=c=>{switch(c){case"split":case"split-horizontal":return ue.Platform.isMacOS?"click holding \u2318+\u2325":"click holding Ctrl+Alt";case"window":return ue.Platform.isMacOS?"click holding \u2318+\u2325+\u21E7":"click holding Ctrl+Alt+Shift";case"tab":default:return ue.Platform.isMacOS?"click holding \u2318 or middle-click":"middle-click or click holding Ctrl"}},s=c=>c===null?"default":c===!1?"replace":c,o=c=>{switch(c){case"replace":return!1;case"split":case"tab":case"window":return c;case"split-horizontal":return"split-horizontal";default:return null}};new ue.Setting(n).setName("Default link click").setDesc("Configure how links to media are opened").addDropdown(c=>c.addOptions(i).setValue(s(this.state.defaultMxLinkClick.click)).onChange(u=>this.state.setDefaultMxLinkBehavior(o(u))).then(()=>this.sub((u,d)=>{u.defaultMxLinkClick.click!==d.defaultMxLinkClick.click&&c.setValue(s(u.defaultMxLinkClick.click))})));let a=new ue.Setting(n).setName("Altnernative behavior").addDropdown(c=>c.addOptions(i).setValue(s(this.state.defaultMxLinkClick.alt)).onChange(u=>this.state.setMxLinkAltBehavior(o(u))).then(()=>this.sub((u,d)=>{u.defaultMxLinkClick.alt!==d.defaultMxLinkClick.alt&&c.setValue(s(u.defaultMxLinkClick.alt))})));function l(c){let u=r(c);a.setDesc("Configure link open behavior"+u?` when ${u}`:"")}l(this.state.defaultMxLinkClick.click),this.sub((c,u)=>{c.defaultMxLinkClick!==u.defaultMxLinkClick&&l(c.defaultMxLinkClick.click)})}playback(){let{containerEl:n}=this;new ue.Setting(n).setHeading().setName("Playback"),new ue.Setting(n).setName("Default volume").setDesc("The default volume for media files").addSlider(o=>o.setLimits(0,100,1).setValue(this.state.defaultVolume).onChange(this.state.setDefaultVolume).then(a=>{this.sub((l,c)=>{l.defaultVolume!==c.defaultVolume&&a.setValue(l.defaultVolume)})})).addText(o=>o.setValue(rc(this.state.defaultVolume)).onChange(RN(this.state.setDefaultVolume)).then(a=>{pv.call(a,0,100,1),a.inputEl.type="number",a.inputEl.style.textAlign="center",this.sub((l,c)=>{l.defaultVolume!==c.defaultVolume&&a.setValue(rc(l.defaultVolume))})})).then(o=>o.controlEl.appendText("%")),new ue.Setting(n).setName("Load strategy").setDesc(createFragment(o=>{o.appendText("Configure when media embeds are loaded in the note"),o.createEl("br"),o.appendText("Useful if you want lazy load media embeds in a note when there are many of them")})).addDropdown(o=>o.addOption("eager","On note open").addOption("play","When interacted with").setValue(this.state.loadStrategy).onChange(a=>this.state.setLoadStrategy(a)));let i="_follow_",r=YI(),s=Object.fromEntries(WT.default.getAllCodes().flatMap(o=>r.has(o)?[...r.get(o).values()]:[[o,WT.default.getNativeName(o)]]));new ue.Setting(n).setName("Default locale").setDesc("The default locale for subtitles").addDropdown(o=>o.addOption(i,"Follow obsidian locale").addOptions(s).setValue(this.state.defaultLanguage??i).onChange(a=>this.state.setDefaultLanguage(a===i?null:a))),new ue.Setting(n).setName("Speed step").setDesc("Configure the step for command to slightly increasing or decreasing playback speed").addSlider(o=>o.setLimits(.01,2,.01).setValue(this.state.speedStep).onChange(this.state.setSpeedStep).then(a=>{this.sub((l,c)=>{l.speedStep!==c.speedStep&&a.setValue(l.speedStep)})})).addText(o=>o.setValue(rc(this.state.speedStep)).onChange(qT(this.state.setSpeedStep)).then(a=>{pv.call(a,.01,2,.01),a.inputEl.type="number",a.inputEl.style.textAlign="center",this.sub((l,c)=>{l.speedStep!==c.speedStep&&a.setValue(rc(l.speedStep))})})).then(o=>o.controlEl.appendText("x"))}timestamp(){let{containerEl:n}=this;new ue.Setting(n).setHeading().setName("Timestamp"),new ue.Setting(n).setName("Timestamp template").setDesc(createFragment(i=>{i.appendText("The template used to insert timestamps."),i.createEl("br"),i.appendText("Supported placeholders: {{TIMESTAMP}}")})).addTextArea(i=>{i.setValue(this.state.timestampTemplate).onChange(r=>this.state.setTemplate("timestamp",r)),i.inputEl.rows=5,i.inputEl.cols=40}),new ue.Setting(n).setName("Timestamp offset").setDesc("Offset in seconds to add to the timestamp").addSlider(i=>i.setLimits(-10,10,.01).setValue(this.state.timestampOffset).onChange(this.state.setTimestampOffset).then(r=>{this.sub((s,o)=>{s.timestampOffset!==o.timestampOffset&&r.setValue(s.timestampOffset)})})).addText(i=>i.setValue(rc(this.state.timestampOffset)).onChange(qT(this.state.setTimestampOffset)).then(r=>{pv.call(r,-10,10,.01),r.inputEl.type="number",r.inputEl.style.textAlign="center",this.sub((s,o)=>{s.timestampOffset!==o.timestampOffset&&r.setValue(rc(s.timestampOffset))})})).then(i=>i.controlEl.appendText("s"))}screenshot(){let{containerEl:n}=this;new ue.Setting(n).setHeading().setName("Screenshot"),new ue.Setting(n).setName("Screenshot linktext template").setDesc(createFragment(r=>{r.appendText("The template used to create screenshot linktext."),r.createEl("br"),r.appendText("Supported placeholders: {{DURATION}}, {{TITLE}}"),r.createEl("br"),r.appendText("Remove `|50` suffix to embed image in full size")})).addTextArea(r=>{r.setValue(this.state.screenshotEmbedTemplate).onChange(s=>this.state.setTemplate("screenshotEmbed",s)),r.inputEl.rows=5,r.inputEl.cols=40}),new ue.Setting(n).setName("Screenshot template").setDesc(createFragment(r=>{r.appendText("The template used to insert screenshot."),r.createEl("br"),r.appendText("Supported placeholders: "),r.createEl("ul",{},s=>{s.createEl("li").appendText("{{TIMESTAMP}} - timestamp link"),s.createEl("li",{},o=>{o.appendText("{{SCREENSHOT}} - link to screenshot"),o.createEl("br"),o.appendText("add `!` prefix to insert as image embed")})})})).addTextArea(r=>{r.setValue(this.state.screenshotTemplate).onChange(s=>this.state.setTemplate("screenshot",s)),r.inputEl.rows=5,r.inputEl.cols=40}),new ue.Setting(n).setName("Screenshot format").setDesc(createFragment(r=>{r.appendText("The format to use when taking screenshots"),r.createEl("br"),r.appendText("Note that the webp format falls back to jpeg in iOS or iPadOS")})).addDropdown(r=>r.addOptions({"image/png":"PNG","image/jpeg":"JPEG","image/webp":"WEBP"}).setValue(this.state.screenshotFormat).onChange(s=>this.state.setScreenshotFormat(s))),new ue.Setting(n).setName("Default location for new screenshots").setDesc("Where newly added attachments are placed.").addDropdown(r=>r.addOptions({default:"In attachment folder",specific:"In the folder specified below"}).onChange(s=>{this.state.setScreenshotFolder(s==="specific"?"":null)})),new ue.Setting(n).setName("Attachment folder path").setDesc("Place newly created screenshot files in this folder.").addText(r=>r.setPlaceholder("Example: folder 1/folder").setValue(this.state.screenshotFolderPath??"").onChange(this.state.setScreenshotFolder)).then(r=>{r.settingEl.style.display=this.state.screenshotFolderPath!==void 0?"":"none",this.sub((s,o)=>{typeof s.screenshotFolderPath!=typeof o.screenshotFolderPath&&(r.settingEl.style.display=s.screenshotFolderPath!==void 0?"":"none")})});let i=r=>r.screenshotFormat==="image/webp"?.8:.92;new ue.Setting(n).setName("Screenshot quality").setDesc("Quality of the screenshot").addText(r=>r.setValue(this.state.screenshotQuality?.toString()??"").setPlaceholder(i(this.state).toString()).onChange(qT(this.state.setScreenshotQuality)).then(s=>{pv.call(s,0,1,.01),s.inputEl.type="number",s.inputEl.style.textAlign="center",this.sub((o,a)=>{o.screenshotFormat!==a.screenshotFormat&&s.setPlaceholder(i(this.state).toString()),o.screenshotQuality!==a.screenshotQuality&&s.setValue(o.screenshotQuality?.toString()??"")})})).addButton(r=>r.setTooltip("Reset to default").setIcon("reset").onClick(()=>{this.state.setScreenshotQuality(null)}).setDisabled(this.state.screenshotQuality===null).then(()=>{this.sub((s,o)=>{s.screenshotQuality!==o.screenshotQuality&&r.setDisabled(s.screenshotQuality===null)})})).then(r=>{this.sub((s,o)=>{s.screenshotFormat!==o.screenshotFormat&&(r.settingEl.style.display=s.screenshotFormat==="image/png"?"none":"")})})}noteTaking(){let{containerEl:n}=this;new ue.Setting(n).setHeading().setName("Note taking"),new ue.Setting(n).setDesc("Configure where timestamps and screenshots are inserted").setName("Insert location").addDropdown(i=>i.addOption("before","Latest content on top").addOption("after","Latest content at end").setValue(this.state.insertBefore===!0?"before":"after").onChange(r=>this.state.setInsertPosition(r))),this.timestamp(),this.screenshot()}webpage(){if(!ue.Platform.isDesktopApp)return;let{containerEl:n}=this;new ue.Setting(n).setHeading().setName("Webpage"),new ue.Setting(n).setName("Login").setDesc("If website requires login to access content or request login during playback, you can open a browser page here to login.").addButton(i=>i.setCta().setButtonText("Open broswer").onClick(()=>{new Qr(this.app).open()}))}bilibili(){let{containerEl:n}=this;new ue.Setting(n).setHeading().setName("Bilibili"),new ue.Setting(n).setName("Default quality").setDesc(createFragment(i=>{i.appendText("The default quality for bilibili videos, will fallback to closest quality if not available"),i.createEl("br"),i.appendText("Only new videos will use this quality")})).addDropdown(i=>i.addOptions(TN).setValue(this.state.biliDefaultQuality.toString()).onChange(RN(r=>this.state.setBiliDefaultQuality(r))))}display(){let{containerEl:n}=this;n.empty(),this.webpage(),this.playback(),this.noteTaking(),this.linkOpen(),this.protocol(),this.bilibili()}};function RN(t){return e=>t(parseInt(e,10))}function qT(t){return e=>t(parseFloat(e))}function rc(t){return t.toString()}function pv(t,e,n){return this.inputEl.min=t.toString(),this.inputEl.max=e.toString(),this.inputEl.step=n.toString(),this}var ON=require("url"),FN=A(Ap()),ot=require("obsidian");var LN=require("obsidian");async function KT(t){if(!LN.Platform.isDesktopApp)throw new Error("Not supported in web");let e=await Xp().showOpenDialog({title:"Pick a media file",message:"Pick a media file to open",buttonLabel:"Pick",properties:["openFile"],filters:[{extensions:Yt.video,name:"Video"},{extensions:Yt.audio,name:"Audio"}],defaultPath:t});return e.canceled?null:e.filePaths[0]??null}var AN=require("url"),DN=require("obsidian");var fv=class t extends DN.FuzzySuggestModal{constructor(n){super(n.app);this.plugin=n;E(this,"resolve",gu)}static choose(n){return new Promise(i=>{let r=new t(n);r.open(),r.resolve=i})}getItems(){return this.plugin.settings.getState().getUrlMappingData().filter(n=>n.appId===this.app.appId&&n.replace.startsWith("file://")).map(n=>({action:n.protocol,path:(0,AN.fileURLToPath)(n.replace),url:n.replace}))}getItemText(n){return`mx://${n.action}: ${n.path}`}onChooseItem(n){this.resolve(n)}onClose(){super.onClose(),setTimeout(()=>{this.resolve(null)},0)}};var mq=/^av(?\d+)$/i,gq=/^BV1(?[1-9A-HJ-NP-Za-km-z]{9})$/,yq=/^[\w-]{11}$/,vq=/^(?:(?:[a-zA-Z\d]|[a-zA-Z\d][a-zA-Z\d-]*[a-zA-Z\d])\.)*(?:[A-Za-z\d]|[A-Za-z\d][A-Za-z\d-]*[A-Za-z\d])$/;function GT(t){try{return(0,ON.pathToFileURL)(t)}catch(e){return console.error(`Failed to convert path ${t} to URL: `,e),null}}function NN(t){let e=bi.isAbsolute(t)?GT(t):ki(t);return!e||["http:","https:"].includes(e.protocol)&&!vq.test(e.hostname)?null:e}var mv=class extends ot.SuggestModal{constructor(n){super(n.app);this.plugin=n;this.inputEl.addEventListener("drop",i=>{if(!i.dataTransfer||i.dataTransfer.files.length===0)return;let r=[...i.dataTransfer.files],s=[...i.dataTransfer.files].filter(l=>hn(bi.extname(l.name)));if(s.length===0){new ot.Notice(`Cannot open dropped file${r.length>1?"s":""}, not supported media file type`);return}let o=s[0];i.preventDefault();let a=i.target;a.value=o.path,a.dispatchEvent(new Event("input"))}),this.setPlaceholder("Enter file path, URL or media id, or drop a media file here"),this.setInstructions([{command:"\u2191\u2193",purpose:"to navigate"},{command:"\u21B5",purpose:"to open url"},{command:ot.Platform.isMacOS?"\u2318 \u21B5":"ctrl \u21B5",purpose:"to open in new tab"},{command:ot.Platform.isMacOS?"\u2318 \u2325 \u21B5":"ctrl alt \u21B5",purpose:"to open to the right"},{command:"esc",purpose:"to dismiss"}]),this.scope.register(null,"Enter",i=>(this.chooser.useSelectedItem(i),!1))}getSuggestions(n){let i=NN(n),r=[];if(!i){let a;if((a=n.match(mq))&&r.push(new URL(`https://www.bilibili.com/video/av${a.groups.id}`)),(a=n.match(gq))&&r.push(new URL(`https://www.bilibili.com/video/${n}`)),(a=n.match(yq))&&r.push(new URL(`https://www.youtube.com/watch?v=${n}`)),!a){let l=NN(`https://${n}`);l&&r.push(l)}}let s=r.map(a=>Rn.create(a.href)).filter(a=>!!a),o=this.plugin.resolveUrl(i?.href);return o?[o,...s]:s}onNoSuggestion(){super.onNoSuggestion(),this.chooser.setSuggestions(["file-picker","file-protocol-picker"])}renderSuggestion(n,i){n instanceof Rn?i.setText(decodeURI(n.href)):ke(n)?i.setText(n.file.path):n==="file-picker"?i.setText("Open local file"):n==="file-protocol-picker"?i.setText("Pick from folders defined in custom protocol"):(0,FN.assertNever)(n)}async onChooseSuggestion(n,i){let r;if(n==="file-protocol-picker"){let s=await fv.choose(this.plugin);if(!s)return;let o=await KT(s.path);if(!o)return;if(!o.startsWith(s.path)){new ot.Notice(`For protocol ${s.action}, the file must be in ${s.path}`);return}let a=GT(o);if(!a)return;let l=this.plugin.resolveUrl(a.href.replace(s.url.replace(/\/*$/,"/"),`mx://${s.action}/`));if(!l){new ot.Notice(`Failed to resolve file protocol url: ${a.href} with ${s.url}`);return}r=l}else if(n==="file-picker"){let s=await KT();if(!s)return;let o=GT(s);if(!o){new ot.Notice("Failed to convert file path to URL: "+s);return}let a=this.plugin.resolveUrl(o);if(!a){new ot.Notice("Failed to resolve file: "+s);return}r=a}else r=n;if(!ke(r)){if(r.isFileUrl){if(r.hostname){new ot.Notice(`Network path is not supported in obsidian, you need to map it to a local path: ${r.filePath??r.readableHref}`);return}let s=hS();if(!s){new ot.Notice("File path is only supported in desktop app");return}try{if(!(await s.stat(r)).isFile()){new ot.Notice("Not a file: "+r.readableHref);return}}catch(o){let a=o,l=r.filePath??r.href;a.code==="ENOENT"?new ot.Notice("File not found: "+l):a.code==="EACCES"?new ot.Notice("Permission denied: "+l):new ot.Notice(`Failed to access file (${a.code}): `+l);return}}}console.debug("media selected",r),ot.Keymap.isModifier(i,"Mod")&&ot.Keymap.isModifier(i,"Alt")?this.plugin.leafOpener.openMedia(r,"split",{direction:"vertical"}):ot.Keymap.isModifier(i,"Mod")?this.plugin.leafOpener.openMedia(r,"tab"):this.plugin.leafOpener.openMedia(r,!1)}};var kp=require("obsidian");var VN="mx-open";function zN(t){window.OBS_ACT&&t.register(vt(window,{OBS_ACT:i=>function(s){if(s.action.startsWith(VN+"/")){e(s);return}return i.apply(this,arguments)}})),t.registerObsidianProtocolHandler("mx-open",async i=>{let r=ki(i.url);if(!r){new kp.Notice("Invalid URL: "+i.url);return}await n(r)});async function e(i){let r=i.action.substring(VN.length+1),s=ki(r),o=new URLSearchParams(i);if(o.delete("action"),!s){new kp.Notice("Invalid URL: "+r+"?"+o.toString());return}s.search=o.toString(),await n(s)}async function n(i){let r=t.resolveUrl(i);if(!r){new kp.Notice("Invail URL: "+i.href);return}new kp.Notice(createFragment(s=>{s.appendText(`Opening ${r.type} from browser: `),s.createEl("br"),s.createEl("a",{text:i.href.length>50?i.href.slice(0,25)+"..."+i.href.slice(-25):i.href,href:i.href})})),await t.leafOpener.openMedia(r,"tab")}}function UN(t){function e(){new mv(t).open()}t.addCommand({id:"open-media-switcher",name:"Open media",icon:"play",callback:e}),t.addRibbonIcon("play","Open media",e),zN(t)}var XT=(t,e)=>e.some(n=>t instanceof n),jN,BN;function wq(){return jN||(jN=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function _q(){return BN||(BN=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var ZT=new WeakMap,YT=new WeakMap,gv=new WeakMap;function bq(t){let e=new Promise((n,i)=>{let r=()=>{t.removeEventListener("success",s),t.removeEventListener("error",o)},s=()=>{n(Qo(t.result)),r()},o=()=>{i(t.error),r()};t.addEventListener("success",s),t.addEventListener("error",o)});return gv.set(e,t),e}function xq(t){if(ZT.has(t))return;let e=new Promise((n,i)=>{let r=()=>{t.removeEventListener("complete",s),t.removeEventListener("error",o),t.removeEventListener("abort",o)},s=()=>{n(),r()},o=()=>{i(t.error||new DOMException("AbortError","AbortError")),r()};t.addEventListener("complete",s),t.addEventListener("error",o),t.addEventListener("abort",o)});ZT.set(t,e)}var JT={get(t,e,n){if(t instanceof IDBTransaction){if(e==="done")return ZT.get(t);if(e==="store")return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return Qo(t[e])},set(t,e,n){return t[e]=n,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function KN(t){JT=t(JT)}function kq(t){return _q().includes(t)?function(...e){return t.apply(eE(this),e),Qo(this.request)}:function(...e){return Qo(t.apply(eE(this),e))}}function Tq(t){return typeof t=="function"?kq(t):(t instanceof IDBTransaction&&xq(t),XT(t,wq())?new Proxy(t,JT):t)}function Qo(t){if(t instanceof IDBRequest)return bq(t);if(YT.has(t))return YT.get(t);let e=Tq(t);return e!==t&&(YT.set(t,e),gv.set(e,t)),e}var eE=t=>gv.get(t);function GN(t,e,{blocked:n,upgrade:i,blocking:r,terminated:s}={}){let o=indexedDB.open(t,e),a=Qo(o);return i&&o.addEventListener("upgradeneeded",l=>{i(Qo(o.result),l.oldVersion,l.newVersion,Qo(o.transaction),l)}),n&&o.addEventListener("blocked",l=>n(l.oldVersion,l.newVersion,l)),a.then(l=>{s&&l.addEventListener("close",()=>s()),r&&l.addEventListener("versionchange",c=>r(c.oldVersion,c.newVersion,c))}).catch(()=>{}),a}var Eq=["get","getKey","getAll","getAllKeys","count"],Sq=["put","add","delete","clear"],QT=new Map;function HN(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(QT.get(e))return QT.get(e);let n=e.replace(/FromIndex$/,""),i=e!==n,r=Sq.includes(n);if(!(n in(i?IDBIndex:IDBObjectStore).prototype)||!(r||Eq.includes(n)))return;let s=async function(o,...a){let l=this.transaction(o,r?"readwrite":"readonly"),c=l.store;return i&&(c=c.index(a.shift())),(await Promise.all([c[n](...a),r&&l.done]))[0]};return QT.set(e,s),s}KN(t=>({...t,get:(e,n,i)=>HN(e,n)||t.get(e,n,i),has:(e,n)=>!!HN(e,n)||t.has(e,n)}));var Pq=["continue","continuePrimaryKey","advance"],qN={},tE=new WeakMap,YN=new WeakMap,Cq={get(t,e){if(!Pq.includes(e))return t[e];let n=qN[e];return n||(n=qN[e]=function(...i){tE.set(this,YN.get(this)[e](...i))}),n}};async function*Mq(...t){let e=this;if(e instanceof IDBCursor||(e=await e.openCursor(...t)),!e)return;e=e;let n=new Proxy(e,Cq);for(YN.set(n,e),gv.set(n,eE(e));e;)yield n,e=await(tE.get(n)||e.continue()),tE.delete(n)}function WN(t,e){return e===Symbol.asyncIterator&&XT(t,[IDBIndex,IDBObjectStore,IDBCursor])||e==="iterate"&&XT(t,[IDBIndex,IDBObjectStore])}KN(t=>({...t,get(e,n,i){return WN(e,n)?Mq:t.get(e,n,i)},has(e,n){return WN(e,n)||t.has(e,n)}}));var vv=require("obsidian");function $q(t,...e){return t.reduce((n,i,r)=>{let s=e[r],o=s!==void 0?JSON.stringify(s):"";return n+i+o},"")}var Tp="mx:http_proxy",nE={type:"player_v2",host:"api.bilibili.com",pathnames:["/x/player/v2","/x/player/wbi/v2"],filter:["https://api.bilibili.com/x/player/v2*","https://api.bilibili.com/x/player/wbi/v2*"],header:"player_v2",types:["xhr"]};function QN(t,e){let n=Yr(e.appId);return n?$q` const { session, webContents, net } = require("electron"); const webviewSession = session.fromPartition(${n}); const webContent = webContents.fromId(${t}); webviewSession.webRequest.onSendHeaders( { urls: ${nE.filter}, type: ${nE.types} }, ({url, method, requestHeaders, webContentsId}) => { if (method !== "GET" || webContentsId===undefined) return; webContent.send(${Tp}, {type:${nE.type} ,url, method, requestHeaders, webContentsId}); }) `.trim():(console.log("partition disabled, cannot watch requests"),"")}async function XN(t,e){return Rq(t.pipeThrough(new DecompressionStream("gzip")),e)}function ZN(t){return new ReadableStream({start(e){e.enqueue(new Uint8Array(t)),e.close()}})}async function Rq(t,e){let n=t.getReader(),i=[];for(;;){let{done:r,value:s}=await n.read();if(r)break;i.push(s)}return new Blob(i,{type:e})}function Iq(t){return`${t.aid}-${t.bvid}-${t.cid}`}var Ep,Sp,sc,yv=class extends vv.Component{constructor(n){super();this.plugin=n;Y(this,Ep,Cf());Y(this,Sp,new Map);Y(this,sc,new Map);E(this,"app");E(this,"db");this.app=n.app,this.db=GN(`mx-cache-${this.app.appId}`,1,{upgrade(i){i.createObjectStore("bili-subtitle")}}),this.app=n.app}async getPlayerApiResp(n,i=1e4){let{aid:r,bvid:s,cid:o}=await n.methods.bili_getManifest(),a=Iq({aid:r,bvid:s,cid:o}),l=C(this,Sp).get(a);if(l)return l;let c=C(this,sc).get(`${s}-${o}`)??C(this,sc).get(`${r}-${o}`);c||(c=await new Promise((p,h)=>{let m=C(this,Ep).on("player_v2",w=>{o===w.cid&&(r===w.aid||s===w.bvid)&&(p(w.url),window.clearTimeout(v))}),v=window.setTimeout(()=>{m(),h(new Error("player_v2 timeout: "+a))},i)}));let u=await n.methods.fetch(c,{gzip:!1,credentials:"include"});if(u.type!=="application/json")throw new Error(`Unexpected response type ${u.type} for player_v2 api`);let d=JSON.parse(new TextDecoder().decode(u.ab));if(d.code!==0)throw new Error(`player_v2 api error: (${d.code}) ${d.message}`);return C(this,Sp).set(a,d.data),d.data}async cacheSubtitle(n,i){(await this.db).put("bili-subtitle",i,n.toString())}async getCachedSubtitle(n){let r=await(await this.db).get("bili-subtitle",n.toString());if(!r)return null;let{ab:s,gzip:o}=r,a="application/json",c=await(o?await XN(ZN(s),a):new Blob([s],{type:a})).text();return JSON.parse(c)}async hasSubtitle(n){return await(await this.db).count("bili-subtitle",n.toString())>0}async onload(){if(!vv.Platform.isDesktopApp)throw new Error("Cannot register ipc events, not in desktop app");let n=require("path"),i=require("fs/promises"),{ipcRenderer:r}=require("electron"),s=require("@electron/remote"),o=(a,l)=>{if(l.type!=="player_v2")return;let c=new URL(l.url),u=c.searchParams.get("aid"),d=c.searchParams.get("bvid"),p=c.searchParams.get("cid");if(!u&&!d||!p)return;C(this,Ep).emit("player_v2",{url:l.url,aid:+u,bvid:d,cid:+p});let h=d?`${d}-${p}`:`${u}-${p}`;C(this,sc).set(h,l.url)};r.on(Tp,o);try{let a=s.getCurrentWebContents().id,l=QN(a,this.app),c=n.join(this.app.vault.adapter.getBasePath(),...this.app.vault.configDir.split("/"),`mx-player-hack.${Date.now()}.js`);await i.writeFile(c,l,"utf-8");try{await s.require(c),console.log("mx-player-hack loaded")}finally{await i.rm(c,{force:!0,maxRetries:5})}this.register(()=>{r.off(Tp,o)})}catch(a){throw r.off(Tp,o),a}}};Ep=new WeakMap,Sp=new WeakMap,sc=new WeakMap;var JN=require("obsidian");async function eO(){if(!JN.Platform.isDesktopApp)return;let t=bc(this.app.appId);t&&(this.settings.subscribe((e,n)=>{e.biliDefaultQuality!==n.biliDefaultQuality&&HT(t,e.biliDefaultQuality)}),await HT(t,this.settings.getState().biliDefaultQuality))}var wv=class extends _v.Plugin{constructor(){super(...arguments);E(this,"settings",$N(this));E(this,"api",{openUrl:async(n,i,r)=>{let s=this.resolveUrl(n);if(!s){new _v.Notice("Protocol not yet supported");return}await this.leafOpener.openMedia(s,i,{direction:r})}});E(this,"urlViewType",this.addChild(new Yp(this)));E(this,"mediaNote",this.addChild(new Ny(this)));E(this,"playlist",this.addChild(new sv(this)));E(this,"biliReq",this.addChild(new yv(this)));E(this,"leafOpener",this.addChild(new Sy(this)));E(this,"recorderNote",this.addChild(new Ip(this)));E(this,"handleMediaNote",a2);E(this,"injectMediaEmbed",OT);E(this,"injectMediaView",BT);E(this,"registerMediaMenu",xT);E(this,"fixLinkLabel",UT);E(this,"patchEditorClick",FT);E(this,"patchPreviewClick",jT);E(this,"patchInlineUrl",VT);E(this,"patchLinktextOpen",zT);E(this,"modifySession",eO);E(this,"initLogin",mS)}resolveUrl(n){let i=bN(n);return i?lS(ki(i),this.settings.getState(),this.app):null}async onload(){this.addSettingTab(new hv(this)),await this.loadSettings(),this.initLogin(),this.loadPatches(),this.registerMediaMenu(),this.handleMediaNote(),await this.modifySession(),UN(this)}async loadSettings(){await this.settings.getState().load()}loadPatches(){this.injectMediaView(gn.audio,n=>new Fl(n,this),Yt.audio),this.injectMediaView(gn.video,n=>new Ol(n,this),Yt.video),this.injectMediaEmbed((n,i,r)=>new ov(n,i,r,this)),this.registerView(Jn,n=>new jl(n,this)),this.registerView(Xs,n=>new Vl(n,this)),this.registerView(Xt.video,n=>new zl(n,this)),this.registerView(Xt.audio,n=>new Ul(n,this)),this.patchEditorClick({onExternalLinkClick:o0}),this.patchPreviewClick({onExternalLinkClick:o0}),this.fixLinkLabel(),this.patchInlineUrl(),this.patchLinktextOpen({onInternalLinkClick:p2})}}; /*! Bundled license information: react/cjs/react.production.min.js: (** * @license React * react.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. *) scheduler/cjs/scheduler.production.min.js: (** * @license React * scheduler.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. *) react-dom/cjs/react-dom.production.min.js: (** * @license React * react-dom.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. *) use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js: (** * @license React * use-sync-external-store-shim.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. *) use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js: (** * @license React * use-sync-external-store-shim/with-selector.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. *) react/cjs/react-jsx-runtime.production.min.js: (** * @license React * react-jsx-runtime.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. *) */