var AsciinemaPlayer=function(e){"use strict";class t{log(){}debug(){}info(){}warn(){}error(){}}const n=Symbol("solid-proxy"),r="function"==typeof Proxy,o=Symbol("solid-track"),s={equals:(e,t)=>e===t};let i=O;const l=1,a=2,c={owned:null,cleanups:null,context:null,owner:null};var u=null;let d=null,f=null,h=null,p=null,g=0;function v(e,t){const n=f,r=u,o=0===e.length,s=void 0===t?r:t,i=o?c:{owned:null,cleanups:null,context:s?s.context:null,owner:s},l=o?e:()=>e((()=>w((()=>j(i)))));u=i,f=null;try{return F(l,!0)}finally{f=n,u=r}}function m(e,t){const n={value:e,observers:null,observerSlots:null,comparator:(t=t?Object.assign({},s,t):s).equals||void 0};return[C.bind(n),e=>("function"==typeof e&&(e=e(n.value)),_(n,e))]}function y(e,t,n){S(P(e,t,!1,l))}function b(e,t,n){n=n?Object.assign({},s,n):s;const r=P(e,t,!0,0);return r.observers=null,r.observerSlots=null,r.comparator=n.equals||void 0,S(r),C.bind(r)}function k(e){return F(e,!1)}function w(e){if(null===f)return e();const t=f;f=null;try{return e()}finally{f=t}}function $(e){!function(e,t,n){i=T;const r=P(e,t,!1,l);n&&n.render||(r.user=!0),p?p.push(r):S(r)}((()=>w(e)))}function A(e){return null===u||(null===u.cleanups?u.cleanups=[e]:u.cleanups.push(e)),e}function x(){return f}function L(e){const t=b(e),n=b((()=>z(t())));return n.toArray=()=>{const e=n();return Array.isArray(e)?e:null!=e?[e]:[]},n}function C(){if(this.sources&&this.state)if(this.state===l)S(this);else{const e=h;h=null,F((()=>H(this)),!1),h=e}if(f){const e=this.observers?this.observers.length:0;f.sources?(f.sources.push(this),f.sourceSlots.push(e)):(f.sources=[this],f.sourceSlots=[e]),this.observers?(this.observers.push(f),this.observerSlots.push(f.sources.length-1)):(this.observers=[f],this.observerSlots=[f.sources.length-1])}return this.value}function _(e,t,n){let r=e.value;return e.comparator&&e.comparator(r,t)||(e.value=t,e.observers&&e.observers.length&&F((()=>{for(let t=0;t1e6)throw h=[],new Error}),!1)),t}function S(e){if(!e.fn)return;j(e);const t=g;!function(e,t,n){let r;const o=u,s=f;f=u=e;try{r=e.fn(t)}catch(t){return e.pure&&(e.state=l,e.owned&&e.owned.forEach(j),e.owned=null),e.updatedAt=n+1,N(t)}finally{f=s,u=o}(!e.updatedAt||e.updatedAt<=n)&&(null!=e.updatedAt&&"observers"in e?_(e,r):e.value=r,e.updatedAt=n)}(e,e.value,t)}function P(e,t,n,r=l,o){const s={fn:e,state:r,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:u,context:u?u.context:null,pure:n};return null===u||u!==c&&(u.owned?u.owned.push(s):u.owned=[s]),s}function E(e){if(0===e.state)return;if(e.state===a)return H(e);if(e.suspense&&w(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt=0;n--)if((e=t[n]).state===l)S(e);else if(e.state===a){const n=h;h=null,F((()=>H(e,t[0])),!1),h=n}}function F(e,t){if(h)return e();let n=!1;t||(h=[]),p?n=!0:p=[],g++;try{const t=e();return function(e){h&&(O(h),h=null);if(e)return;const t=p;p=null,t.length&&F((()=>i(t)),!1)}(n),t}catch(e){n||(p=null),h=null,N(e)}}function O(e){for(let t=0;t=0;t--)j(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)j(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}e.state=0}function N(e,t=u){const n=function(e){return e instanceof Error?e:new Error("string"==typeof e?e:"Unknown error",{cause:e})}(e);throw n}function z(e){if("function"==typeof e&&!e.length)return z(e());if(Array.isArray(e)){const t=[];for(let n=0;ne(t||{})))}function B(){return!0}const q={get:(e,t,r)=>t===n?r:e.get(t),has:(e,t)=>t===n||e.has(t),set:B,deleteProperty:B,getOwnPropertyDescriptor:(e,t)=>({configurable:!0,enumerable:!0,get:()=>e.get(t),set:B,deleteProperty:B}),ownKeys:e=>e.keys()};function R(e){return(e="function"==typeof e?e():e)?e:{}}function I(){for(let e=0,t=this.length;e`Stale read from <${e}>.`;function U(e){const t="fallback"in e&&{fallback:()=>e.fallback};return b(function(e,t,n={}){let r=[],s=[],i=[],l=0,a=t.length>1?[]:null;return A((()=>D(i))),()=>{let c,u,d=e()||[],f=d.length;return d[o],w((()=>{let e,t,o,p,g,m,y,b,k;if(0===f)0!==l&&(D(i),i=[],r=[],s=[],l=0,a&&(a=[])),n.fallback&&(r=[W],s[0]=v((e=>(i[0]=e,n.fallback()))),l=1);else if(0===l){for(s=new Array(f),u=0;u=m&&b>=m&&r[y]===d[b];y--,b--)o[b]=s[y],p[b]=i[y],a&&(g[b]=a[y]);for(e=new Map,t=new Array(b+1),u=b;u>=m;u--)k=d[u],c=e.get(k),t[u]=void 0===c?-1:c,e.set(k,u);for(c=m;c<=y;c++)k=r[c],u=e.get(k),void 0!==u&&-1!==u?(o[u]=s[c],p[u]=i[c],a&&(g[u]=a[c]),u=t[u],e.set(k,u)):i[c]();for(u=m;ue.each),e.children,t||void 0))}function X(e){const t="fallback"in e&&{fallback:()=>e.fallback};return b(function(e,t,n={}){let r,s=[],i=[],l=[],a=[],c=0;return A((()=>D(l))),()=>{const u=e()||[],d=u.length;return u[o],w((()=>{if(0===d)return 0!==c&&(D(l),l=[],s=[],i=[],c=0,a=[]),n.fallback&&(s=[W],i[0]=v((e=>(l[0]=e,n.fallback()))),c=1),i;for(s[0]===W&&(l[0](),l=[],s=[],i=[],c=0),r=0;ru[r])):r>=s.length&&(i[r]=v(f));for(;re.each),e.children,t||void 0))}function G(e){const t=e.keyed,n=b((()=>e.when),void 0,void 0),r=t?n:b(n,void 0,{equals:(e,t)=>!e==!t});return b((()=>{const o=r();if(o){const s=e.children;return"function"==typeof s&&s.length>0?w((()=>s(t?o:()=>{if(!w(r))throw Z("Show");return n()}))):s}return e.fallback}),void 0,void 0)}function J(e){const t=L((()=>e.children)),n=b((()=>{const e=t(),n=Array.isArray(e)?e:[e];let r=()=>{};for(let e=0;es()?void 0:o.when),void 0,void 0),l=o.keyed?i:b(i,void 0,{equals:(e,t)=>!e==!t});r=()=>s()||(l()?[t,i,o]:void 0)}return r}));return b((()=>{const t=n()();if(!t)return e.fallback;const[r,o,s]=t,i=s.children;return"function"==typeof i&&i.length>0?w((()=>i(s.keyed?o():()=>{if(w(n)()?.[0]!==r)throw Z("Match");return o()}))):i}),void 0,void 0)}function Q(e){return e}const V="_$DX_DELEGATE";function Y(e,t,n,r={}){let o;return v((r=>{o=r,t===document?e():ie(t,e(),t.firstChild?null:void 0,n)}),r.owner),()=>{o(),t.textContent=""}}function ee(e,t,n,r){let o;const s=()=>{const t=r?document.createElementNS("http://www.w3.org/1998/Math/MathML","template"):document.createElement("template");return t.innerHTML=e,n?t.content.firstChild.firstChild:r?t.firstChild:t.content.firstChild},i=t?()=>w((()=>document.importNode(o||(o=s()),!0))):()=>(o||(o=s())).cloneNode(!0);return i.cloneNode=i,i}function te(e,t=window.document){const n=t[V]||(t[V]=new Set);for(let r=0,o=e.length;rr.call(e,n[1],t))}else e.addEventListener(t,n,"function"!=typeof n&&n)}function oe(e,t,n){if(!t)return n?function(e,t,n){null==n?e.removeAttribute(t):e.setAttribute(t,n)}(e,"style"):t;const r=e.style;if("string"==typeof t)return r.cssText=t;let o,s;for(s in"string"==typeof n&&(r.cssText=n=void 0),n||(n={}),t||(t={}),n)null==t[s]&&r.removeProperty(s),delete n[s];for(s in t)o=t[s],o!==n[s]&&(r.setProperty(s,o),n[s]=o);return n}function se(e,t,n){return w((()=>e(t,n)))}function ie(e,t,n,r){if(void 0===n||r||(r=[]),"function"!=typeof t)return ae(e,t,r,n);y((r=>ae(e,t(),r,n)),r)}function le(e){let t=e.target;const n=`$$${e.type}`,r=e.target,o=e.currentTarget,s=t=>Object.defineProperty(e,"target",{configurable:!0,value:t}),i=()=>{const r=t[n];if(r&&!t.disabled){const o=t[`${n}Data`];if(void 0!==o?r.call(t,o,e):r.call(t,e),e.cancelBubble)return}return t.host&&"string"!=typeof t.host&&!t.host._$host&&t.contains(e.target)&&s(t.host),!0},l=()=>{for(;i()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get:()=>t||document}),e.composedPath){const n=e.composedPath();s(n[0]);for(let e=0;e{let o=t();for(;"function"==typeof o;)o=o();n=ae(e,o,n,r)})),()=>n;if(Array.isArray(t)){const s=[],l=n&&Array.isArray(n);if(ce(s,t,n,o))return y((()=>n=ae(e,s,n,r,!0))),()=>n;if(0===s.length){if(n=de(e,n,r),i)return n}else l?0===n.length?ue(e,s,r):function(e,t,n){let r=n.length,o=t.length,s=r,i=0,l=0,a=t[o-1].nextSibling,c=null;for(;ir-l){const o=t[i];for(;l=0;s--){const i=t[s];if(o!==i){const t=i.parentNode===e;r||s?t&&i.remove():t?e.replaceChild(o,i):e.insertBefore(o,n)}else r=!0}}else e.insertBefore(o,n);return[o]}const fe=Symbol("store-raw"),he=Symbol("store-node"),pe=Symbol("store-has"),ge=Symbol("store-self");function ve(e){let t=e[n];if(!t&&(Object.defineProperty(e,n,{value:t=new Proxy(e,$e)}),!Array.isArray(e))){const n=Object.keys(e),r=Object.getOwnPropertyDescriptors(e);for(let o=0,s=n.length;ot===fe||t===n||t===o||t===he||t===pe||"__proto__"===t||(x()&&ke(be(e,pe),t)(),t in e),set:()=>!0,deleteProperty:()=>!0,ownKeys:function(e){return we(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor:function(e,t){const r=Reflect.getOwnPropertyDescriptor(e,t);return r&&!r.get&&r.configurable&&t!==n&&t!==he?(delete r.value,delete r.writable,r.get=()=>e[n][t],r):r}};function Ae(e,t,n,r=!1){if(!r&&e[t]===n)return;const o=e[t],s=e.length;void 0===n?(delete e[t],e[pe]&&e[pe][t]&&void 0!==o&&e[pe][t].$()):(e[t]=n,e[pe]&&e[pe][t]&&void 0===o&&e[pe][t].$());let i,l=be(e,he);if((i=ke(l,t,o))&&i.$((()=>n)),Array.isArray(e)&&e.length!==s){for(let t=e.length;t1){r=t.shift();const s=typeof r,i=Array.isArray(e);if(Array.isArray(r)){for(let o=0;o1)return void Le(e[r],t,[r].concat(n));o=e[r],n=[r].concat(n)}let s=t[0];"function"==typeof s&&(s=s(o,n),s===o)||void 0===r&&null==s||(s=ye(s),void 0===r||me(o)&&me(s)&&!Array.isArray(s)?xe(o,s):Ae(e,r,s))}function Ce(...[e,t]){const n=ye(e||{}),r=Array.isArray(n);return[ve(n),function(...e){k((()=>{r&&1===e.length?function(e,t){if("function"==typeof t&&(t=t(e)),t=ye(t),Array.isArray(t)){if(e===t)return;let n=0,r=t.length;for(;n=i&&a>=i&&(s[l]===e[a]||o&&s[l]&&e[a]&&s[l][o]===e[a][o]);l--,a--)f[a]=s[l];if(i>a||i>l){for(n=i;n<=a;n++)Ae(s,n,e[n]);for(;ne.length&&Ae(s,"length",e.length))}for(u=new Array(a+1),n=a;n>=i;n--)c=e[n],d=o&&c?c[o]:c,t=h.get(d),u[n]=void 0===t?-1:t,h.set(d,n);for(t=i;t<=l;t++)c=s[t],d=o&&c?c[o]:c,n=h.get(d),void 0!==n&&-1!==n&&(f[n]=s[t],n=u[n],h.set(d,n));for(n=i;ne.length&&Ae(s,"length",e.length))}const l=Object.keys(e);for(let t=0,n=l.length;t{if(!me(e)||!me(o))return o;const t=Se(o,{[_e]:e},_e,n,r);return void 0===t?e:t}}const Ee=ee("",2);var Fe=e=>{const t=b((()=>{if(1==e.text.length){const t=e.text.codePointAt(0);if(t>=9600&&t<=9631||57520==t||57522==t)return t}})),n=b((()=>t()?" ":e.text)),r=b((()=>function(e,t,n){const r=e.get("fg"),o=e.get("bg");let s={"--offset":t,width:`${n+.01}ch`};"string"==typeof r&&(s["--fg"]=r);"string"==typeof o&&(s["--bg"]=o);return s}(e.pen,e.offset,e.width))),o=b((()=>function(e,t,n){const r=Oe(e.get("fg"),e.get("bold"),"fg-"),o=Oe(e.get("bg"),!1,"bg-");let s=n??"";void 0!==t&&(s+=` cp-${t.toString(16)}`);r&&(s+=" "+r);o&&(s+=" "+o);e.has("bold")&&(s+=" ap-bright");e.has("faint")&&(s+=" ap-faint");e.has("italic")&&(s+=" ap-italic");e.has("underline")&&(s+=" ap-underline");e.has("blink")&&(s+=" ap-blink");e.get("inverse")&&(s+=" ap-inverse");return s}(e.pen,t(),e.extraClass)));return(()=>{const e=Ee.cloneNode(!0);return ie(e,n),y((t=>{const n=o(),s=r();return n!==t._v$&&ne(e,t._v$=n),t._v$2=oe(e,s,t._v$2),t}),{_v$:void 0,_v$2:void 0}),e})()};function Oe(e,t,n){if("number"==typeof e)return t&&e<8&&(e+=8),`${n}${e}`}const Te=ee('',2);var He=e=>(()=>{const t=Te.cloneNode(!0);return ie(t,K(X,{get each(){return(()=>{if("number"==typeof e.cursor){const t=[];let n=0,r=0;for(;r0&&t.push({...o,text:o.text.substring(0,s)}),t.push({...o,text:o.text[s],offset:o.offset+s,extraClass:"ap-cursor"}),sK(Fe,function(...e){let t=!1;for(let r=0;r=0;n--){const r=R(e[n])[t];if(void 0!==r)return r}},has(t){for(let n=e.length-1;n>=0;n--)if(t in R(e[n]))return!0;return!1},keys(){const t=[];for(let n=0;n=0;t--){const n=e[t];if(!n)continue;const r=Object.getOwnPropertyNames(n);for(let e=r.length-1;e>=0;e--){const t=r[e];if("__proto__"===t||"constructor"===t)continue;const i=Object.getOwnPropertyDescriptor(n,t);if(s[t]){const e=o[t];e&&(i.get?e.push(i.get.bind(n)):void 0!==i.value&&e.push((()=>i.value)))}else s[t]=i.get?{enumerable:!0,configurable:!0,get:I.bind(o[t]=[i.get.bind(n)])}:void 0!==i.value?i:void 0}}const i={},l=Object.keys(s);for(let e=l.length-1;e>=0;e--){const t=l[e],n=s[t];n&&n.get?Object.defineProperty(i,t,n):i[t]=n?n.value:void 0}return i}(e))})),t})();const Me=ee('
',2);var je=e=>{const t=()=>e.lineHeight??1.3333333333,n=b((()=>({width:`${e.cols}ch`,height:t()*e.rows+"em","font-size":100*(e.scale||1)+"%","font-family":e.fontFamily,"--term-line-height":`${t()}em`,"--term-cols":e.cols}))),r=b((()=>e.cursor?.[0])),o=b((()=>e.cursor?.[1]));return(()=>{const t=Me.cloneNode(!0),s=e.ref;return"function"==typeof s?se(s,t):e.ref=t,ie(t,K(U,{get each(){return e.lines},children:(e,t)=>K(He,{get segments(){return e.segments},get cursor(){return(e=()=>t()===o(),b((()=>e())))()?r():null;var e}})})),y((r=>{const o=!(!e.blink&&!e.cursorHold),s=!!e.blink,i=n();return o!==r._v$&&t.classList.toggle("ap-cursor-on",r._v$=o),s!==r._v$2&&t.classList.toggle("ap-blink",r._v$2=s),r._v$3=oe(t,i,r._v$3),r}),{_v$:void 0,_v$2:void 0,_v$3:void 0}),t})()};const Ne=ee('',6),ze=ee('',4),We=ee('',2),De=ee('',6),Ke=ee('
Keyboard shortcuts (?)Fullscreen (f)
',34),Be=ee('',6);function qe(e){let t=Math.floor(e);const n=Math.floor(t/86400);t%=86400;const r=Math.floor(t/3600);t%=3600;const o=Math.floor(t/60);return t%=60,n>0?`${Re(n)}:${Re(r)}:${Re(o)}:${Re(t)}`:r>0?`${Re(r)}:${Re(o)}:${Re(t)}`:`${Re(o)}:${Re(t)}`}function Re(e){return e<10?`0${e}`:e.toString()}var Ie=e=>{const t=e=>t=>{t.preventDefault(),e(t)},n=()=>"number"==typeof e.currentTime?qe(e.currentTime):"--:--",r=()=>"number"==typeof e.remainingTime?"-"+qe(e.remainingTime):n(),o=b((()=>"number"==typeof e.duration?e.markers.filter((t=>t[0]{const t=e.currentTarget.offsetWidth,n=e.currentTarget.getBoundingClientRect(),r=e.clientX-n.left;return 100*Math.max(0,r/t)+"%"},[i,l]=m(!1),a=function(e,t){let n=!0;return function(){if(n){n=!1;for(var r=arguments.length,o=new Array(r),s=0;sn=!0),t)}}}(e.onSeekClick,50),c=t=>{t._marker||t.altKey||t.shiftKey||t.metaKey||t.ctrlKey||0!==t.button||(l(!0),e.onSeekClick(s(t)))},u=e=>{e.altKey||e.shiftKey||e.metaKey||e.ctrlKey||i()&&a(s(e))},d=()=>{l(!1)};return document.addEventListener("mouseup",d),A((()=>{document.removeEventListener("mouseup",d)})),(()=>{const s=Ke.cloneNode(!0),i=s.firstChild,l=i.firstChild,a=l.nextSibling,d=i.nextSibling,f=d.nextSibling,h=f.nextSibling,p=e.ref;return"function"==typeof p?se(p,s):e.ref=s,ie(s,K(G,{get when(){return e.isPausable},get children(){const n=We.cloneNode(!0);return re(n,"click",t(e.onPlayClick),!0),ie(n,K(J,{get children(){return[K(Q,{get when(){return e.isPlaying},get children(){return Ne.cloneNode(!0)}}),K(Q,{get when(){return!e.isPlaying},get children(){return ze.cloneNode(!0)}})]}})),n}}),i),ie(l,n),ie(a,r),ie(d,K(G,{get when(){return"number"==typeof e.progress||e.isSeekable},get children(){const n=De.cloneNode(!0),r=n.firstChild.nextSibling;return n.$$mousemove=u,n.$$mousedown=c,ie(n,K(U,{get each(){return o()},children:(n,r)=>(()=>{const o=Be.cloneNode(!0),s=o.firstChild,i=s.nextSibling;var l;return o.$$mousedown=e=>{e._marker=!0},re(o,"click",(l=r(),t((()=>{e.onSeekClick({marker:l})}))),!0),ie(i,(()=>(e=>""===e[1]?qe(e[0]):`${qe(e[0])} - ${e[1]}`)(n))),y((t=>{const r=(t=>t[0]/e.duration*100+"%")(n),i=!!(t=>"number"==typeof e.currentTime&&t[0]<=e.currentTime)(n);return r!==t._v$&&o.style.setProperty("left",t._v$=r),i!==t._v$2&&s.classList.toggle("ap-marker-past",t._v$2=i),t}),{_v$:void 0,_v$2:void 0}),o})()}),null),y((t=>oe(r,{transform:`scaleX(${e.progress||0}`},t))),n}})),re(f,"click",t(e.onHelpClick),!0),re(h,"click",t(e.onFullscreenClick),!0),y((()=>s.classList.toggle("ap-seekable",!!e.isSeekable))),s})()};te(["click","mousedown","mousemove"]);const Ze=ee('
💥
',4);var Ue=e=>Ze.cloneNode(!0);const Xe=ee('
',4);var Ge=e=>Xe.cloneNode(!0);const Je=ee('
',4);var Qe=e=>(()=>{const t=Je.cloneNode(!0),n=t.firstChild;return ie(n,(()=>e.message)),y((t=>oe(n,{"font-family":e.fontFamily},t))),t})();const Ve=ee('
',22);var Ye=e=>(()=>{const t=Ve.cloneNode(!0);var n;return re(t,"click",(n=e.onClick,e=>{e.preventDefault(),n(e)}),!0),t})();te(["click"]);const et=ee("
  • space - pause / resume
  • ",4),tt=ee("
  • / - rewind / fast-forward by 5 seconds
  • ",6),nt=ee("
  • Shift + / - rewind / fast-forward by 10%
  • ",8),rt=ee("
  • [ / ] - jump to the previous / next marker
  • ",6),ot=ee("
  • 0, 1, 2 ... 9 - jump to 0%, 10%, 20% ... 90%
  • ",10),st=ee("
  • , / . - step back / forward, a frame at a time (when paused)
  • ",6),it=ee('

    Keyboard shortcuts

    • f - toggle fullscreen mode
    • ? - toggle this help popup
    ',18);var lt=e=>(()=>{const t=it.cloneNode(!0),n=t.firstChild,r=n.firstChild.firstChild.nextSibling,o=r.firstChild;var s;return re(t,"click",(s=e.onClose,e=>{e.preventDefault(),s(e)}),!0),n.$$click=e=>{e.stopPropagation()},ie(r,K(G,{get when(){return e.isPausable},get children(){return et.cloneNode(!0)}}),o),ie(r,K(G,{get when(){return e.isSeekable},get children(){return[tt.cloneNode(!0),nt.cloneNode(!0),rt.cloneNode(!0),ot.cloneNode(!0),st.cloneNode(!0)]}}),o),y((n=>oe(t,{"font-family":e.fontFamily},n))),t})();te(["click"]);const at=ee('
    ',4);var ct=e=>{const t=e.logger,n=e.core,r=e.autoPlay,[o,s]=Ce({lines:[],cursor:void 0,charW:e.charW,charH:e.charH,bordersW:e.bordersW,bordersH:e.bordersH,containerW:0,containerH:0,isPausable:!0,isSeekable:!0,isFullscreen:!1,currentTime:null,remainingTime:null,progress:null,blink:!0,cursorHold:!1}),[i,l]=m(!1),[a,c]=m(r?null:"start"),[u,d]=m(null),[f,h]=m({cols:e.cols,rows:e.rows},{equals:(e,t)=>e.cols===t.cols&&e.rows===t.rows}),[p,g]=m(void 0),[v,w]=Ce([]),[x,L]=m(!1),[C,_]=m(!1),[S,P]=m(void 0),E=b((()=>f().cols||80)),F=b((()=>f().rows||24)),O=()=>!1===e.controls?0:32;let T,H,M,j,N,z,W,D,B,q;function R(){ge(),fe(),he()}function I(e){k((()=>{e.rows{q=e}));n.addEventListener("ready",(e=>{let{isPausable:t,isSeekable:n,poster:r}=e;s({isPausable:t,isSeekable:n}),Z(r),q()})),n.addEventListener("metadata",(e=>{let{cols:t,rows:n,duration:r,theme:o,poster:s,markers:i}=e;k((()=>{I({cols:t,rows:n}),g(r),P(o),w(i),Z(s)}))})),n.addEventListener("play",(()=>{c(null)})),n.addEventListener("playing",(()=>{k((()=>{l(!0),c(null),Y(),pe(),de()}))})),n.addEventListener("idle",(()=>{k((()=>{l(!1),R()}))})),n.addEventListener("loading",(()=>{k((()=>{l(!1),R(),c("loader")}))})),n.addEventListener("offline",(e=>{let{message:t}=e;k((()=>{l(!1),R(),void 0!==t&&(d(t),c("info"))}))}));let X=0;n.addEventListener("ended",(e=>{let{message:n}=e;k((()=>{l(!1),R(),void 0!==n&&(d(n),c("info"))})),t.debug(`view: render count: ${X}`)})),n.addEventListener("errored",(()=>{c("error")})),n.addEventListener("resize",I),n.addEventListener("reset",(e=>{let{cols:t,rows:n,theme:r}=e;k((()=>{I({cols:t,rows:n}),P(r),Y()}))})),n.addEventListener("seeked",(()=>{he()})),n.addEventListener("terminalUpdate",(()=>{void 0===T&&(T=requestAnimationFrame(Y))}));const V=()=>{B=new ResizeObserver(function(e,t){let n;return function(){for(var r=arguments.length,o=new Array(r),s=0;se.apply(this,o)),t)}}((e=>{s({containerW:N.offsetWidth,containerH:N.offsetHeight}),N.dispatchEvent(new CustomEvent("resize",{detail:{el:z}}))}),10)),B.observe(N)};$((async()=>{t.info("view: mounted"),t.debug("view: font measurements",{charW:o.charW,charH:o.charH}),V(),s({containerW:N.offsetWidth,containerH:N.offsetHeight})})),A((()=>{n.stop(),ge(),fe(),B.disconnect()}));const Y=async()=>{const e=await n.getChanges();k((()=>{void 0!==e.lines&&e.lines.forEach(((e,t)=>{s("lines",t,Pe(e))})),void 0!==e.cursor&&s("cursor",Pe(e.cursor)),s("cursorHold",!0)})),T=void 0,X+=1},ee=b((()=>{const t=o.charW*E()+o.bordersW,n=o.charH*F()+o.bordersH;let r=e.fit??"width";if("both"===r||o.isFullscreen){r=o.containerW/(o.containerH-O())>t/n?"height":"width"}if(!1===r||"none"===r)return{};if("width"===r){const e=o.containerW/t;return{scale:e,width:o.containerW,height:n*e+O()}}if("height"===r){const e=(o.containerH-O())/n;return{scale:e,width:t*e,height:o.containerH}}throw`unsupported fit mode: ${r}`})),te=()=>{s("isFullscreen",document.fullscreenElement??document.webkitFullscreenElement)},re=()=>{o.isFullscreen?(document.exitFullscreen??document.webkitExitFullscreen??(()=>{})).apply(document):(N.requestFullscreen??N.webkitRequestFullscreen??(()=>{})).apply(N)},le=()=>{C()?_(!1):(n.pause(),_(!0))},ae=e=>{if(!(e.altKey||e.metaKey||e.ctrlKey)){if(" "==e.key)n.togglePlay();else if(","==e.key)n.step(-1),he();else if("."==e.key)n.step(),he();else if("f"==e.key)re();else if("["==e.key)n.seek({marker:"prev"});else if("]"==e.key)n.seek({marker:"next"});else if(e.key.charCodeAt(0)>=48&&e.key.charCodeAt(0)<=57){const t=(e.key.charCodeAt(0)-48)/10;n.seek(100*t+"%")}else if("?"==e.key)le();else if("ArrowLeft"==e.key)e.shiftKey?n.seek("<<<"):n.seek("<<");else if("ArrowRight"==e.key)e.shiftKey?n.seek(">>>"):n.seek(">>");else{if("Escape"!=e.key)return;_(!1)}e.stopPropagation(),e.preventDefault()}},ce=()=>{o.isFullscreen&&ve(!0)},ue=()=>{o.isFullscreen||ve(!1)},de=()=>{M=setInterval(he,100)},fe=()=>{clearInterval(M)},he=async()=>{const e=await n.getCurrentTime(),t=await n.getRemainingTime(),r=await n.getProgress();s({currentTime:e,remainingTime:t,progress:r})},pe=()=>{j=setInterval((()=>{s((e=>{const t={blink:!e.blink};return t.blink&&(t.cursorHold=!1),t}))}),600)},ge=()=>{clearInterval(j),s("blink",!0)},ve=e=>{clearTimeout(H),e&&(H=setTimeout((()=>ve(!1)),2e3)),L(e)},me=b((()=>{const t=e.theme||"auto/asciinema";return"auto/"===t.slice(0,5)?{name:t.slice(5),colors:S()}:{name:t}})),ye=()=>{U.then((()=>n.play()))},be=()=>{U.then((()=>n.togglePlay()))},ke=e=>{U.then((()=>n.seek(e)))},we=(()=>{const t=at.cloneNode(!0),n=t.firstChild;"function"==typeof N?se(N,t):N=t,t.addEventListener("webkitfullscreenchange",te),t.addEventListener("fullscreenchange",te),t.$$mousemove=ce,t.$$keydown=ae;return"function"==typeof z?se(z,n):z=n,n.$$mousemove=()=>ve(!0),n.addEventListener("mouseleave",ue),ie(n,K(je,{get cols(){return E()},get rows(){return F()},get scale(){return ee()?.scale},get blink(){return o.blink},get lines(){return o.lines},get cursor(){return o.cursor},get cursorHold(){return o.cursorHold},get fontFamily(){return e.terminalFontFamily},get lineHeight(){return e.terminalLineHeight},ref(e){"function"==typeof W?W(e):W=e}}),null),ie(n,K(G,{get when(){return!1!==e.controls},get children(){return K(Ie,{get duration(){return p()},get currentTime(){return o.currentTime},get remainingTime(){return o.remainingTime},get progress(){return o.progress},markers:v,get isPlaying(){return i()},get isPausable(){return o.isPausable},get isSeekable(){return o.isSeekable},onPlayClick:be,onFullscreenClick:re,onHelpClick:le,onSeekClick:ke,ref(e){"function"==typeof D?D(e):D=e}})}}),null),ie(n,K(J,{get children(){return[K(Q,{get when(){return"start"==a()},get children(){return K(Ye,{onClick:ye})}}),K(Q,{get when(){return"loader"==a()},get children(){return K(Ge,{})}}),K(Q,{get when(){return"info"==a()},get children(){return K(Qe,{get message(){return u()},get fontFamily(){return e.terminalFontFamily}})}}),K(Q,{get when(){return"error"==a()},get children(){return K(Ue,{})}})]}}),null),ie(n,K(G,{get when(){return C()},get children(){return K(lt,{get fontFamily(){return e.terminalFontFamily},onClose:()=>_(!1),get isPausable(){return o.isPausable},get isSeekable(){return o.isSeekable}})}}),null),y((r=>{const o=!!(!0===e.controls||"auto"===e.controls&&x()),s=`ap-player asciinema-player-theme-${me().name}`,i=(()=>{const t={};!1!==e.fit&&"none"!==e.fit||void 0===e.terminalFontSize||("small"===e.terminalFontSize?t["font-size"]="12px":"medium"===e.terminalFontSize?t["font-size"]="18px":"big"===e.terminalFontSize?t["font-size"]="24px":t["font-size"]=e.terminalFontSize);const n=ee();void 0!==n.width&&(t.width=`${n.width}px`,t.height=`${n.height}px`);const r=me().colors;return r&&(t["--term-color-foreground"]=r.foreground,t["--term-color-background"]=r.background,r.palette.forEach(((e,n)=>{t[`--term-color-${n}`]=e}))),t})();return o!==r._v$&&t.classList.toggle("ap-hud",r._v$=o),s!==r._v$2&&ne(n,r._v$2=s),r._v$3=oe(n,i,r._v$3),r}),{_v$:void 0,_v$2:void 0,_v$3:void 0}),t})();return we};function ut(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=function(e,t){const n=80,r=24,o=document.createElement("div");let s;o.style.height="0px",o.style.overflow="hidden",o.style.fontSize="15px",document.body.appendChild(o);const i=Y((()=>(s=K(je,{cols:n,rows:r,lineHeight:t,fontFamily:e,lines:[]}),s)),o),l={charW:s.clientWidth/n,charH:s.clientHeight/r,bordersW:s.offsetWidth-s.clientWidth,bordersH:s.offsetHeight-s.clientHeight};return i(),document.body.removeChild(o),l}(n.terminalFontFamily,n.terminalLineHeight),o={core:e,logger:n.logger,cols:n.cols,rows:n.rows,fit:n.fit,controls:n.controls,autoPlay:n.autoPlay,terminalFontSize:n.terminalFontSize,terminalFontFamily:n.terminalFontFamily,terminalLineHeight:n.terminalLineHeight,theme:n.theme,...r};let s;const i=Y((()=>(s=K(ct,o),s)),t);return{el:s,dispose:i}}te(["keydown","mousemove"]);const dt=["autoPlay","autoplay","cols","idleTimeLimit","loop","markers","pauseOnMarkers","poster","preload","rows","speed","startAt"],ft=["autoPlay","autoplay","cols","controls","fit","rows","terminalFontFamily","terminalFontSize","terminalLineHeight","theme"];class ht{constructor(e,t,n){this.worker=new Worker(e),this.worker.onmessage=this._onMessage.bind(this),this.nextId=1,this.eventHandlers=new Map([["ended",[]],["errored",[]],["idle",[]],["input",[]],["loading",[]],["marker",[]],["metadata",[]],["offline",[]],["pause",[]],["play",[]],["playing",[]],["ready",[]],["reset",[]],["resize",[]],["seeked",[]],["terminalUpdate",[]]]),this.resolves=new Map,this._sendCommand("new",[t,n])}async init(){return this._sendCommand("init")}play(){return this._sendCommand("play")}pause(){return this._sendCommand("pause")}togglePlay(){return this._sendCommand("togglePlay")}seek(e){return this._sendCommand("seek",e)}step(e){return this._sendCommand("step",e)}stop(){return this._sendCommand("stop")}getChanges(){return this._sendCommand("getChanges")}getCurrentTime(){return this._sendCommand("getCurrentTime")}getRemainingTime(){return this._sendCommand("getRemainingTime")}getProgress(){return this._sendCommand("getProgress")}getDuration(){return this._sendCommand("getDuration")}addEventListener(e,t){const n=this.eventHandlers.get(e);0===n.length&&this._sendNotification("addEventListener",[e]),n.push(t)}_dispatchEvent(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};for(const n of this.eventHandlers.get(e))n(t)}_sendCommand(e,t){let n;const r=new Promise((e=>{n=e}));return this.resolves.set(this.nextId,n),this.worker.postMessage({method:e,params:t,id:this.nextId}),this.nextId++,r}_sendNotification(e,t){this.worker.postMessage({method:e,params:t})}_onMessage(e){void 0!==e.data.id?(this.resolves.get(e.data.id)(e.data.result),this.resolves.delete(e.data.id)):"onEvent"===e.data.method&&this._dispatchEvent(e.data.params.name,e.data.params.event)}}return e.create=function(e,n,r){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const s=o.logger===console||void 0,i=new ht(r,e,function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=Object.fromEntries(Object.entries(e).filter((e=>{let[t]=e;return dt.includes(t)})));return n.autoPlay??=n.autoplay,n.speed??=1,{...n,...t}}(o,{logger:s})),l=o.logger??new t,{el:a,dispose:c}=ut(i,n,function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=Object.fromEntries(Object.entries(e).filter((e=>{let[t]=e;return ft.includes(t)})));return n.autoPlay??=n.autoplay,n.controls??="auto",{...n,...t}}(o,{logger:l})),u=i.init(),d={el:a,dispose:c,getCurrentTime:()=>u.then(i.getCurrentTime.bind(i)),getDuration:()=>u.then(i.getDuration.bind(i)),play:()=>u.then(i.play.bind(i)),pause:()=>u.then(i.pause.bind(i)),seek:e=>u.then((()=>i.seek(e))),addEventListener:(e,t)=>i.addEventListener(e,t.bind(d))};return d},e}({});