// ==UserScript==
// @name yt-playlists-delete-enhancer
// @description Add a button to remove videos watched with more than X percent from watch later playlist.
// @version 1.4.2
// @author Andrew Valleteau <[email protected]>
// @grant none
// @match *://youtube.com/*
// @match *://www.youtube.com/*
// @namespace greasyfork-namespace-url
// @noframes
// @homepageURL https://github.com/avallete/yt-playlists-delete-enhancer#readme
// @supportURL https://github.com/avallete/yt-playlists-delete-enhancer/issues
// @run-at document-idle
// @license MIT
// ==/UserScript==
/*! For license information please see yt-playlists-delete-enhancer.user.js.LICENSE.txt */
!function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=9)}([function(t,e,n){"use strict";n.r(e),n.d(e,"render",(function(){return x})),n.d(e,"hydrate",(function(){return k})),n.d(e,"createElement",(function(){return _})),n.d(e,"h",(function(){return _})),n.d(e,"Fragment",(function(){return v})),n.d(e,"createRef",(function(){return y})),n.d(e,"isValidElement",(function(){return o})),n.d(e,"Component",(function(){return g})),n.d(e,"cloneElement",(function(){return j})),n.d(e,"createContext",(function(){return Y})),n.d(e,"toChildArray",(function(){return R})),n.d(e,"options",(function(){return r}));var r,o,i,u,s,a,c={},f=[],l=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function d(t,e){for(var n in e)t[n]=e[n];return t}function h(t){var e=t.parentNode;e&&e.removeChild(t)}function _(t,e,n){var r,o,i,u=arguments,s={};for(i in e)"key"==i?r=e[i]:"ref"==i?o=e[i]:s[i]=e[i];if(arguments.length>3)for(n=[n],i=3;i<arguments.length;i++)n.push(u[i]);if(null!=n&&(s.children=n),"function"==typeof t&&null!=t.defaultProps)for(i in t.defaultProps)void 0===s[i]&&(s[i]=t.defaultProps[i]);return p(t,s,r,o,null)}function p(t,e,n,o,i){var u={type:t,props:e,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==i?++r.__v:i};return null!=r.vnode&&r.vnode(u),u}function y(){return{current:null}}function v(t){return t.children}function g(t,e){this.props=t,this.context=e}function m(t,e){if(null==e)return t.__?m(t.__,t.__.__k.indexOf(t)+1):null;for(var n;e<t.__k.length;e++)if(null!=(n=t.__k[e])&&null!=n.__e)return n.__e;return"function"==typeof t.type?m(t):null}function E(t){var e,n;if(null!=(t=t.__)&&null!=t.__c){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if(null!=(n=t.__k[e])&&null!=n.__e){t.__e=t.__c.base=n.__e;break}return E(t)}}function b(t){(!t.__d&&(t.__d=!0)&&i.push(t)&&!w.__r++||s!==r.debounceRendering)&&((s=r.debounceRendering)||u)(w)}function w(){for(var t;w.__r=i.length;)t=i.sort((function(t,e){return t.__v.__b-e.__v.__b})),i=[],t.some((function(t){var e,n,r,o,i,u;t.__d&&(i=(o=(e=t).__v).__e,(u=e.__P)&&(n=[],(r=d({},o)).__v=o.__v+1,C(u,o,r,e.__n,void 0!==u.ownerSVGElement,null!=o.__h?[i]:null,n,null==i?m(o):i,o.__h),D(n,o),o.__e!=i&&E(o)))}))}function T(t,e,n,r,o,i,u,s,a,l){var d,h,_,y,g,E,b,w=r&&r.__k||f,T=w.length;for(n.__k=[],d=0;d<e.length;d++)if(null!=(y=n.__k[d]=null==(y=e[d])||"boolean"==typeof y?null:"string"==typeof y||"number"==typeof y||"bigint"==typeof y?p(null,y,null,null,y):Array.isArray(y)?p(v,{children:y},null,null,null):y.__b>0?p(y.type,y.props,y.key,null,y.__v):y)){if(y.__=n,y.__b=n.__b+1,null===(_=w[d])||_&&y.key==_.key&&y.type===_.type)w[d]=void 0;else for(h=0;h<T;h++){if((_=w[h])&&y.key==_.key&&y.type===_.type){w[h]=void 0;break}_=null}C(t,y,_=_||c,o,i,u,s,a,l),g=y.__e,(h=y.ref)&&_.ref!=h&&(b||(b=[]),_.ref&&b.push(_.ref,null,y),b.push(h,y.__c||g,y)),null!=g?(null==E&&(E=g),"function"==typeof y.type&&null!=y.__k&&y.__k===_.__k?y.__d=a=A(y,a,t):a=P(t,y,_,w,g,a),l||"option"!==n.type?"function"==typeof n.type&&(n.__d=a):t.value=""):a&&_.__e==a&&a.parentNode!=t&&(a=m(_))}for(n.__e=E,d=T;d--;)null!=w[d]&&("function"==typeof n.type&&null!=w[d].__e&&w[d].__e==n.__d&&(n.__d=m(r,d+1)),B(w[d],w[d]));if(b)for(d=0;d<b.length;d++)L(b[d],b[++d],b[++d])}function A(t,e,n){var r,o;for(r=0;r<t.__k.length;r++)(o=t.__k[r])&&(o.__=t,e="function"==typeof o.type?A(o,e,n):P(n,o,o,t.__k,o.__e,e));return e}function R(t,e){return e=e||[],null==t||"boolean"==typeof t||(Array.isArray(t)?t.some((function(t){R(t,e)})):e.push(t)),e}function P(t,e,n,r,o,i){var u,s,a;if(void 0!==e.__d)u=e.__d,e.__d=void 0;else if(null==n||o!=i||null==o.parentNode)t:if(null==i||i.parentNode!==t)t.appendChild(o),u=null;else{for(s=i,a=0;(s=s.nextSibling)&&a<r.length;a+=2)if(s==o)break t;t.insertBefore(o,i),u=i}return void 0!==u?u:o.nextSibling}function O(t,e,n){"-"===e[0]?t.setProperty(e,n):t[e]=null==n?"":"number"!=typeof n||l.test(e)?n:n+"px"}function I(t,e,n,r,o){var i;t:if("style"===e)if("string"==typeof n)t.style.cssText=n;else{if("string"==typeof r&&(t.style.cssText=r=""),r)for(e in r)n&&e in n||O(t.style,e,"");if(n)for(e in n)r&&n[e]===r[e]||O(t.style,e,n[e])}else if("o"===e[0]&&"n"===e[1])i=e!==(e=e.replace(/Capture$/,"")),e=e.toLowerCase()in t?e.toLowerCase().slice(2):e.slice(2),t.l||(t.l={}),t.l[e+i]=n,n?r||t.addEventListener(e,i?N:S,i):t.removeEventListener(e,i?N:S,i);else if("dangerouslySetInnerHTML"!==e){if(o)e=e.replace(/xlink[H:h]/,"h").replace(/sName$/,"s");else if("href"!==e&&"list"!==e&&"form"!==e&&"tabIndex"!==e&&"download"!==e&&e in t)try{t[e]=null==n?"":n;break t}catch(t){}"function"==typeof n||(null!=n&&(!1!==n||"a"===e[0]&&"r"===e[1])?t.setAttribute(e,n):t.removeAttribute(e))}}function S(t){this.l[t.type+!1](r.event?r.event(t):t)}function N(t){this.l[t.type+!0](r.event?r.event(t):t)}function C(t,e,n,o,i,u,s,a,c){var f,l,h,_,p,y,m,E,b,w,A,R=e.type;if(void 0!==e.constructor)return null;null!=n.__h&&(c=n.__h,a=e.__e=n.__e,e.__h=null,u=[a]),(f=r.__b)&&f(e);try{t:if("function"==typeof R){if(E=e.props,b=(f=R.contextType)&&o[f.__c],w=f?b?b.props.value:f.__:o,n.__c?m=(l=e.__c=n.__c).__=l.__E:("prototype"in R&&R.prototype.render?e.__c=l=new R(E,w):(e.__c=l=new g(E,w),l.constructor=R,l.render=M),b&&b.sub(l),l.props=E,l.state||(l.state={}),l.context=w,l.__n=o,h=l.__d=!0,l.__h=[]),null==l.__s&&(l.__s=l.state),null!=R.getDerivedStateFromProps&&(l.__s==l.state&&(l.__s=d({},l.__s)),d(l.__s,R.getDerivedStateFromProps(E,l.__s))),_=l.props,p=l.state,h)null==R.getDerivedStateFromProps&&null!=l.componentWillMount&&l.componentWillMount(),null!=l.componentDidMount&&l.__h.push(l.componentDidMount);else{if(null==R.getDerivedStateFromProps&&E!==_&&null!=l.componentWillReceiveProps&&l.componentWillReceiveProps(E,w),!l.__e&&null!=l.shouldComponentUpdate&&!1===l.shouldComponentUpdate(E,l.__s,w)||e.__v===n.__v){l.props=E,l.state=l.__s,e.__v!==n.__v&&(l.__d=!1),l.__v=e,e.__e=n.__e,e.__k=n.__k,e.__k.forEach((function(t){t&&(t.__=e)})),l.__h.length&&s.push(l);break t}null!=l.componentWillUpdate&&l.componentWillUpdate(E,l.__s,w),null!=l.componentDidUpdate&&l.__h.push((function(){l.componentDidUpdate(_,p,y)}))}l.context=w,l.props=E,l.state=l.__s,(f=r.__r)&&f(e),l.__d=!1,l.__v=e,l.__P=t,f=l.render(l.props,l.state,l.context),l.state=l.__s,null!=l.getChildContext&&(o=d(d({},o),l.getChildContext())),h||null==l.getSnapshotBeforeUpdate||(y=l.getSnapshotBeforeUpdate(_,p)),A=null!=f&&f.type===v&&null==f.key?f.props.children:f,T(t,Array.isArray(A)?A:[A],e,n,o,i,u,s,a,c),l.base=e.__e,e.__h=null,l.__h.length&&s.push(l),m&&(l.__E=l.__=null),l.__e=!1}else null==u&&e.__v===n.__v?(e.__k=n.__k,e.__e=n.__e):e.__e=U(n.__e,e,n,o,i,u,s,c);(f=r.diffed)&&f(e)}catch(t){e.__v=null,(c||null!=u)&&(e.__e=a,e.__h=!!c,u[u.indexOf(a)]=null),r.__e(t,e,n)}}function D(t,e){r.__c&&r.__c(e,t),t.some((function(e){try{t=e.__h,e.__h=[],t.some((function(t){t.call(e)}))}catch(t){r.__e(t,e.__v)}}))}function U(t,e,n,r,o,i,u,s){var a,l,d,_,p=n.props,y=e.props,v=e.type,g=0;if("svg"===v&&(o=!0),null!=i)for(;g<i.length;g++)if((a=i[g])&&(a===t||(v?a.localName==v:3==a.nodeType))){t=a,i[g]=null;break}if(null==t){if(null===v)return document.createTextNode(y);t=o?document.createElementNS("http://www.w3.org/2000/svg",v):document.createElement(v,y.is&&y),i=null,s=!1}if(null===v)p===y||s&&t.data===y||(t.data=y);else{if(i=i&&f.slice.call(t.childNodes),l=(p=n.props||c).dangerouslySetInnerHTML,d=y.dangerouslySetInnerHTML,!s){if(null!=i)for(p={},_=0;_<t.attributes.length;_++)p[t.attributes[_].name]=t.attributes[_].value;(d||l)&&(d&&(l&&d.__html==l.__html||d.__html===t.innerHTML)||(t.innerHTML=d&&d.__html||""))}if(function(t,e,n,r,o){var i;for(i in n)"children"===i||"key"===i||i in e||I(t,i,null,n[i],r);for(i in e)o&&"function"!=typeof e[i]||"children"===i||"key"===i||"value"===i||"checked"===i||n[i]===e[i]||I(t,i,e[i],n[i],r)}(t,y,p,o,s),d)e.__k=[];else if(g=e.props.children,T(t,Array.isArray(g)?g:[g],e,n,r,o&&"foreignObject"!==v,i,u,t.firstChild,s),null!=i)for(g=i.length;g--;)null!=i[g]&&h(i[g]);s||("value"in y&&void 0!==(g=y.value)&&(g!==t.value||"progress"===v&&!g)&&I(t,"value",g,p.value,!1),"checked"in y&&void 0!==(g=y.checked)&&g!==t.checked&&I(t,"checked",g,p.checked,!1))}return t}function L(t,e,n){try{"function"==typeof t?t(e):t.current=e}catch(t){r.__e(t,n)}}function B(t,e,n){var o,i,u;if(r.unmount&&r.unmount(t),(o=t.ref)&&(o.current&&o.current!==t.__e||L(o,null,e)),n||"function"==typeof t.type||(n=null!=(i=t.__e)),t.__e=t.__d=void 0,null!=(o=t.__c)){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(t){r.__e(t,e)}o.base=o.__P=null}if(o=t.__k)for(u=0;u<o.length;u++)o[u]&&B(o[u],e,n);null!=i&&h(i)}function M(t,e,n){return this.constructor(t,n)}function x(t,e,n){var o,i,u;r.__&&r.__(t,e),i=(o="function"==typeof n)?null:n&&n.__k||e.__k,u=[],C(e,t=(!o&&n||e).__k=_(v,null,[t]),i||c,c,void 0!==e.ownerSVGElement,!o&&n?[n]:i?null:e.firstChild?f.slice.call(e.childNodes):null,u,!o&&n?n:i?i.__e:e.firstChild,o),D(u,t)}function k(t,e){x(t,e,k)}function j(t,e,n){var r,o,i,u=arguments,s=d({},t.props);for(i in e)"key"==i?r=e[i]:"ref"==i?o=e[i]:s[i]=e[i];if(arguments.length>3)for(n=[n],i=3;i<arguments.length;i++)n.push(u[i]);return null!=n&&(s.children=n),p(t.type,s,r||t.key,o||t.ref,null)}function Y(t,e){var n={__c:e="__cC"+a++,__:t,Consumer:function(t,e){return t.children(e)},Provider:function(t){var n,r;return this.getChildContext||(n=[],(r={})[e]=this,this.getChildContext=function(){return r},this.shouldComponentUpdate=function(t){this.props.value!==t.value&&n.some(b)},this.sub=function(t){n.push(t);var e=t.componentWillUnmount;t.componentWillUnmount=function(){n.splice(n.indexOf(t),1),e&&e.call(t)}}),t.children}};return n.Provider.__=n.Consumer.contextType=n}r={__e:function(t,e){for(var n,r,o;e=e.__;)if((n=e.__c)&&!n.__)try{if((r=n.constructor)&&null!=r.getDerivedStateFromError&&(n.setState(r.getDerivedStateFromError(t)),o=n.__d),null!=n.componentDidCatch&&(n.componentDidCatch(t),o=n.__d),o)return n.__E=n}catch(e){t=e}throw t},__v:0},o=function(t){return null!=t&&void 0===t.constructor},g.prototype.setState=function(t,e){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=d({},this.state),"function"==typeof t&&(t=t(d({},n),this.props)),t&&d(n,t),null!=t&&this.__v&&(e&&this.__h.push(e),b(this))},g.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),b(this))},g.prototype.render=v,i=[],u="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,w.__r=0,a=0},function(t,e,n){"use strict";n.r(e),n.d(e,"operation",(function(){return u})),n.d(e,"run",(function(){return s}));function r(t){return"number"==typeof t}function o(t){return"string"==typeof t}function i(t){return null===t}function u(t){return t}function s(t){!function e(n,o,i){const u=r(i)&&i<=0,s=[],c=[],f=document.readyState;for(const t of n){(void 0===t.deferUntil||t.deferUntil(f)?s:c).push(t)}for(const t of s){const e=a(t);if(void 0!==e)switch(e.reason){case 0:u?o.push({result:e,operation:t}):c.push(t);break;case 1:o.push({result:e,operation:t})}}c.length>0?setTimeout(()=>e(c,o,r(i)?i-1:t.tryUntil(f)?t.extraTries:void 0),t.interval):o.length>0&&t.handleFailures(o)}(t.operations.filter(t=>t.condition(window)),[])}function a(t){const e=void 0===t.dependencies?{}:t.dependencies,n=Object.entries(e).map(([t,e])=>({key:t,selector:e,element:document.querySelector(e)})),r=n.filter(t=>i(t.element));if(r.length>0)return{reason:0,dependencies:r};const u=n.reduce((t,e)=>Object.defineProperty(t,e.key,{value:e.element}),{});return o(s=t.action(u))?{reason:1,message:s}:void 0;var s}},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(14)),i={id:o.default.name,name:o.default.name,description:o.default.description,version:o.default.version,author:o.default.author,homepage:o.default.homepage,support:o.default.bugs.url,hostname:"youtube.com",sitename:"youtube",repositoryURL:o.default.repository.url,license:o.default.license,run_at:"document-idle",releaseBranch:"gh-pages"};e.default=i},function(t,e,n){"use strict";n.r(e),n.d(e,"jsx",(function(){return o})),n.d(e,"jsxs",(function(){return o})),n.d(e,"jsxDEV",(function(){return o}));var r=n(0);function o(t,e,n,o,i){var u={};for(var s in e)"ref"!=s&&(u[s]=e[s]);var a,c,f={type:t,props:u,key:n,ref:e&&e.ref,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:++r.options.__v,__source:o,__self:i};if("function"==typeof t&&(a=t.defaultProps))for(c in a)void 0===u[c]&&(u[c]=a[c]);return r.options.vnode&&r.options.vnode(f),f}n.d(e,"Fragment",(function(){return r.Fragment}))},function(t,e,n){"use strict";n.r(e),n.d(e,"ALWAYS",(function(){return r})),n.d(e,"NEVER",(function(){return o})),n.d(e,"DOMCONTENTLOADED",(function(){return i})),n.d(e,"LOAD",(function(){return u}));const r=()=>!0,o=()=>!1,i=t=>"loading"!==t,u=t=>"complete"===t},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.XPATH=void 0,e.XPATH={APP_RENDER_ROOT:'//ytd-playlist-sidebar-renderer/div[@id="items"]/*[last()]',YT_PLAYLIST_SIDEBAR_ITEMS:'//ytd-playlist-sidebar-renderer/div[@id="items"]',YT_PLAYLIST_VIDEO_RENDERERS:"//ytd-playlist-video-renderer",YT_NUMBERS_OF_VIDEOS_IN_PLAYLIST:"//ytd-playlist-sidebar-primary-info-renderer/div/yt-formatted-string/span[1]"},e.default={XPATH:e.XPATH}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e){const n=[],r=document.evaluate(t,e||document,void 0,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE),o=r.snapshotLength;for(let t=0;t<o;t+=1)n.push(r.snapshotItem(t));return n}},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.YT_LOCATION_CHANGE_EVENT=e.HOSTNAME=e.NAME=void 0;const o=r(n(2));e.NAME=o.default.sitename,e.HOSTNAME=o.default.hostname,e.YT_LOCATION_CHANGE_EVENT="yt-navigate-finish"},function(t,e){var n={utf8:{stringToBytes:function(t){return n.bin.stringToBytes(unescape(encodeURIComponent(t)))},bytesToString:function(t){return decodeURIComponent(escape(n.bin.bytesToString(t)))}},bin:{stringToBytes:function(t){for(var e=[],n=0;n<t.length;n++)e.push(255&t.charCodeAt(n));return e},bytesToString:function(t){for(var e=[],n=0;n<t.length;n++)e.push(String.fromCharCode(t[n]));return e.join("")}}};t.exports=n},function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&r(e,t,n);return o(e,t),e},u=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const s=n(37),a=n(36),c=i(n(10)),f=u(n(11)),l=i(n(7)),d=u(n(35)),h=u(n(2)),_=a.errors.failureDescriber({siteName:l.NAME,extensionName:h.default.name,location:document.location});a.userscripter.run({id:h.default.id,name:h.default.name,initialAction:()=>a.log.log(`${h.default.name} ${h.default.version}`),stylesheets:d.default,operationsPlan:{operations:f.default,interval:c.OPERATIONS_INTERVAL,tryUntil:a.environment.DOMCONTENTLOADED,extraTries:c.OPERATIONS_EXTRA_TRIES,handleFailures:t=>t.forEach(s.compose(a.log.error,_))}})},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.OPERATIONS_EXTRA_TRIES=e.OPERATIONS_INTERVAL=void 0,e.OPERATIONS_INTERVAL=200,e.OPERATIONS_EXTRA_TRIES=3},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=n(1),i=n(4),u=n(12),s=r(n(13)),a=r(n(15)),c=n(5),f=r(n(16));function l(){const t=new URL(window.location.href).searchParams.get("list"),e={DEVICE:window.ytcfg.data_.DEVICE,DELEGATED_SESSION_ID:window.ytcfg.data_.DELEGATED_SESSION_ID,ID_TOKEN:window.ytcfg.data_.ID_TOKEN,INNERTUBE_API_KEY:window.ytcfg.data_.INNERTUBE_API_KEY,INNERTUBE_CONTEXT_CLIENT_NAME:window.ytcfg.data_.INNERTUBE_CONTEXT_CLIENT_NAME,INNERTUBE_CONTEXT_CLIENT_VERSION:window.ytcfg.data_.INNERTUBE_CONTEXT_CLIENT_VERSION,PAGE_BUILD_LABEL:window.ytcfg.data_.PAGE_BUILD_LABEL,PAGE_CL:window.ytcfg.data_.PAGE_CL,VISITOR_DATA:window.ytcfg.data_.VISITOR_DATA,SAPISID:u.get("SAPISID"),ORIGIN_URL:new URL(document.URL).origin};f.default(e,t,c.XPATH.APP_RENDER_ROOT)}function d(){a.default(window)&&l()}const h=[o.operation({description:"run main if the script start on playlist page",condition:a.default,action:()=>{l()},deferUntil:i.DOMCONTENTLOADED}),o.operation({description:"init yt-navigate-finish hooks to watch in-app navigation",condition:i.ALWAYS,action:()=>{s.default(d)},deferUntil:i.DOMCONTENTLOADED})];e.default=h},function(t,e,n){var r,o;!function(i){if(void 0===(o="function"==typeof(r=i)?r.call(e,n,e,t):r)||(t.exports=o),!0,t.exports=i(),!!0){var u=window.Cookies,s=window.Cookies=i();s.noConflict=function(){return window.Cookies=u,s}}}((function(){function t(){for(var t=0,e={};t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}function e(t){return t.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function n(r){function o(){}function i(e,n,i){if("undefined"!=typeof document){"number"==typeof(i=t({path:"/"},o.defaults,i)).expires&&(i.expires=new Date(1*new Date+864e5*i.expires)),i.expires=i.expires?i.expires.toUTCString():"";try{var u=JSON.stringify(n);/^[\{\[]/.test(u)&&(n=u)}catch(t){}n=r.write?r.write(n,e):encodeURIComponent(String(n)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),e=encodeURIComponent(String(e)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var s="";for(var a in i)i[a]&&(s+="; "+a,!0!==i[a]&&(s+="="+i[a].split(";")[0]));return document.cookie=e+"="+n+s}}function u(t,n){if("undefined"!=typeof document){for(var o={},i=document.cookie?document.cookie.split("; "):[],u=0;u<i.length;u++){var s=i[u].split("="),a=s.slice(1).join("=");n||'"'!==a.charAt(0)||(a=a.slice(1,-1));try{var c=e(s[0]);if(a=(r.read||r)(a,c)||e(a),n)try{a=JSON.parse(a)}catch(t){}if(o[c]=a,t===c)break}catch(t){}}return t?o[t]:o}}return o.set=i,o.get=function(t){return u(t,!1)},o.getJSON=function(t){return u(t,!0)},o.remove=function(e,n){i(e,"",t(n,{expires:-1}))},o.defaults={},o.withConverter=n,o}((function(){}))}))},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const r=n(7);e.default=function(t){window.addEventListener(r.YT_LOCATION_CHANGE_EVENT,t)}},function(t){t.exports=JSON.parse('{"name":"yt-playlists-delete-enhancer","description":"Add a button to remove videos watched with more than X percent from watch later playlist.","repository":{"type":"git","url":"[email protected]:avallete/yt-playlists-delete-enhancer.git"},"bugs":{"url":"https://github.com/avallete/yt-playlists-delete-enhancer/issues"},"version":"1.4.2","homepage":"https://github.com/avallete/yt-playlists-delete-enhancer#readme","license":"MIT","author":"Andrew Valleteau <[email protected]>"}')},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=t=>"/playlist"===new URL(t.location.href).pathname},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=n(3),i=n(0),u=r(n(6)),s=r(n(17));e.default=function(t,e,n){const r=u.default(n)[0];if(!r)throw new Error(`Cannot found ${n} in the DOM`);i.render(o.jsx(s.default,{config:t,playlistName:e},void 0),r)}},function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function s(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,s)}a((r=r.apply(t,e||[])).next())}))},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(3),u=n(0),s=o(n(2)),a=o(n(18)),c=n(21),f=o(n(30)),l=o(n(31));class d extends u.Component{constructor(t){super(t),this.state={},this.removeVideoHandler=this.removeVideoHandler.bind(this)}componentDidMount(){return r(this,void 0,void 0,(function*(){try{const t=yield c.fetchAllPlaylistContent(this.props.config,this.props.playlistName);this.setState({playlist:t})}catch(t){this.setState({errorMessages:[t.message]})}}))}removeVideoHandler(t){return r(this,void 0,void 0,(function*(){const{playlist:e}=this.state;if(e&&e.continuations[0].videos.length>0){const[n,r]=f.default(e.continuations[0].videos,e=>e.percentDurationWatched>=t);if(n.length>0)try{yield c.removeVideosFromPlaylist(this.props.config,null==e?void 0:e.playlistId,n),e.continuations[0].videos=r,l.default(n),this.setState(Object.assign(Object.assign({},this.state),{playlist:e}))}catch(t){this.setState(Object.assign(Object.assign({},this.state),{errorMessages:[t.message]}))}}}))}shouldComponentUpdate(t){var e,n;return t.playlistName!==(null===(n=null===(e=this.state)||void 0===e?void 0:e.playlist)||void 0===n?void 0:n.playlistId)}componentDidUpdate(t){return r(this,void 0,void 0,(function*(){if(t.playlistName!==this.props.playlistName)try{this.setState({playlist:void 0,errorMessages:void 0});const t=yield c.fetchAllPlaylistContent(this.props.config,this.props.playlistName);this.setState({playlist:t})}catch(t){this.setState({errorMessages:[t.message]})}}))}render(){var t,e,n,r;return(null===(e=null===(t=this.state)||void 0===t?void 0:t.errorMessages)||void 0===e?void 0:e.length)?i.jsx("div",Object.assign({id:s.default.id},{children:null===(n=this.state)||void 0===n?void 0:n.errorMessages.join(" ")}),void 0):(null===(r=this.state)||void 0===r?void 0:r.playlist)?this.state.playlist.isEditable?i.jsx(a.default,{removeVideoHandler:this.removeVideoHandler},void 0):i.jsx("div",Object.assign({id:s.default.id},{children:"Playlist isn't editable"}),void 0):i.jsx("div",Object.assign({id:s.default.id},{children:"Loading..."}),void 0)}}e.default=d},function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function s(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,s)}a((r=r.apply(t,e||[])).next())}))},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.REMOVE_BUTTON_ALT=e.INPUT_ALT=void 0;const i=n(3),u=n(19),s=o(n(2)),a=o(n(20));e.INPUT_ALT="Input number between 0 and 100 to choose under how much percentage of watched time a video should be removed",e.REMOVE_BUTTON_ALT="Remove button to start removing videos",e.default=function({removeVideoHandler:t,initialValue:n=99}){const[o,c]=u.useState(n),[f,l]=u.useState(!0);return i.jsx("div",Object.assign({id:s.default.id,className:"style-scope ytd-playlist-sidebar-renderer"},{children:i.jsxs("div",Object.assign({className:"style-scope ytd-menu-service-item-renderer",role:"option","aria-disabled":"false"},{children:[i.jsx("p",{children:"Remove all videos who has been watched at more or equal X percent"},void 0),i.jsx("input",{id:"removeVideosEnhancerInput",type:"number",value:o,onChange:function({currentTarget:t}){!function(t){const e=Number(t);return!!(Number.isSafeInteger(e)&&e>=0&&e<=100)}(t.value)?t.value=o.toString():c(Number(t.value))},min:"0",max:"100",required:!0,alt:e.INPUT_ALT},void 0),i.jsx(a.default,{alt:e.REMOVE_BUTTON_ALT,disabled:!f,id:"removeVideosEnhancerButton",onClick:()=>r(this,void 0,void 0,(function*(){l(!1),yield t(o),l(!0)}))},void 0)]}),void 0)}),void 0)}},function(t,e,n){"use strict";n.r(e),n.d(e,"useState",(function(){return p})),n.d(e,"useReducer",(function(){return y})),n.d(e,"useEffect",(function(){return v})),n.d(e,"useLayoutEffect",(function(){return g})),n.d(e,"useRef",(function(){return m})),n.d(e,"useImperativeHandle",(function(){return E})),n.d(e,"useMemo",(function(){return b})),n.d(e,"useCallback",(function(){return w})),n.d(e,"useContext",(function(){return T})),n.d(e,"useDebugValue",(function(){return A})),n.d(e,"useErrorBoundary",(function(){return R}));var r,o,i,u=n(0),s=0,a=[],c=u.options.__b,f=u.options.__r,l=u.options.diffed,d=u.options.__c,h=u.options.unmount;function _(t,e){u.options.__h&&u.options.__h(o,t,s||e),s=0;var n=o.__H||(o.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function p(t){return s=1,y(C,t)}function y(t,e,n){var i=_(r++,2);return i.t=t,i.__c||(i.__=[n?n(e):C(void 0,e),function(t){var e=i.t(i.__[0],t);i.__[0]!==e&&(i.__=[e,i.__[1]],i.__c.setState({}))}],i.__c=o),i.__}function v(t,e){var n=_(r++,3);!u.options.__s&&N(n.__H,e)&&(n.__=t,n.__H=e,o.__H.__h.push(n))}function g(t,e){var n=_(r++,4);!u.options.__s&&N(n.__H,e)&&(n.__=t,n.__H=e,o.__h.push(n))}function m(t){return s=5,b((function(){return{current:t}}),[])}function E(t,e,n){s=6,g((function(){"function"==typeof t?t(e()):t&&(t.current=e())}),null==n?n:n.concat(t))}function b(t,e){var n=_(r++,7);return N(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function w(t,e){return s=8,b((function(){return t}),e)}function T(t){var e=o.context[t.__c],n=_(r++,9);return n.__c=t,e?(null==n.__&&(n.__=!0,e.sub(o)),e.props.value):t.__}function A(t,e){u.options.useDebugValue&&u.options.useDebugValue(e?e(t):t)}function R(t){var e=_(r++,10),n=p();return e.__=t,o.componentDidCatch||(o.componentDidCatch=function(t){e.__&&e.__(t),n[1](t)}),[n[0],function(){n[1](void 0)}]}function P(){a.forEach((function(t){if(t.__P)try{t.__H.__h.forEach(I),t.__H.__h.forEach(S),t.__H.__h=[]}catch(e){t.__H.__h=[],u.options.__e(e,t.__v)}})),a=[]}u.options.__b=function(t){o=null,c&&c(t)},u.options.__r=function(t){f&&f(t),r=0;var e=(o=t.__c).__H;e&&(e.__h.forEach(I),e.__h.forEach(S),e.__h=[])},u.options.diffed=function(t){l&&l(t);var e=t.__c;e&&e.__H&&e.__H.__h.length&&(1!==a.push(e)&&i===u.options.requestAnimationFrame||((i=u.options.requestAnimationFrame)||function(t){var e,n=function(){clearTimeout(r),O&&cancelAnimationFrame(e),setTimeout(t)},r=setTimeout(n,100);O&&(e=requestAnimationFrame(n))})(P)),o=void 0},u.options.__c=function(t,e){e.some((function(t){try{t.__h.forEach(I),t.__h=t.__h.filter((function(t){return!t.__||S(t)}))}catch(n){e.some((function(t){t.__h&&(t.__h=[])})),e=[],u.options.__e(n,t.__v)}})),d&&d(t,e)},u.options.unmount=function(t){h&&h(t);var e=t.__c;if(e&&e.__H)try{e.__H.__.forEach(I)}catch(t){u.options.__e(t,e.__v)}};var O="function"==typeof requestAnimationFrame;function I(t){var e=o;"function"==typeof t.__c&&t.__c(),o=e}function S(t){var e=o;t.__c=t.__(),o=e}function N(t,e){return!t||t.length!==e.length||e.some((function(e,n){return e!==t[n]}))}function C(t,e){return"function"==typeof e?e(t):e}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const r=n(3);e.default=function(t){return r.jsx("button",Object.assign({},t,{children:"Remove !"}),void 0)}},function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function s(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,s)}a((r=r.apply(t,e||[])).next())}))},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.removeVideosFromPlaylist=e.fetchAllPlaylistContent=void 0;const i=o(n(22)),u=n(29),s=new URL("https://www.youtube.com/youtubei/v1"),a=new URL(s+"/browse"),c=new URL(a+"/edit_playlist"),f=new URL("https://www.youtube.com/playlist"),l=["Content-Type","Authorization","X-Goog-Visitor-Id","X-YouTube-Client-Name","X-YouTube-Client-Version","X-Goog-AuthUser","X-Goog-PageId"],d=["X-YouTube-Client-Name","X-YouTube-Client-Version","X-YouTube-Device","X-YouTube-Identity-Token","X-YouTube-Page-CL","X-YouTube-Page-Label"];function h(t,e,n=new Date){const r=Math.floor(n.getTime()/1e3);return`${r}_${i.default(`${r} ${e} ${t}`)}`}function _(t,e=[]){const n={"Content-Type":"application/json","X-Goog-Visitor-Id":t.VISITOR_DATA,"X-YouTube-Client-Name":t.INNERTUBE_CONTEXT_CLIENT_NAME,"X-YouTube-Client-Version":t.INNERTUBE_CONTEXT_CLIENT_VERSION,"X-YouTube-Device":t.DEVICE,"X-YouTube-Identity-Token":t.ID_TOKEN,"X-YouTube-Page-CL":t.PAGE_CL,"X-YouTube-Page-Label":t.PAGE_BUILD_LABEL,"X-Goog-AuthUser":"0","X-Goog-PageId":t.DELEGATED_SESSION_ID,Authorization:"SAPISIDHASH "+h(t.ORIGIN_URL,t.SAPISID)},r={};for(const t of e)r[t]=n[t];return r}function p(t){return t.map(t=>{var e;return{videoId:t.playlistVideoRenderer.videoId,percentDurationWatched:(null===(e=t.playlistVideoRenderer.thumbnailOverlays[1].thumbnailOverlayResumePlaybackRenderer)||void 0===e?void 0:e.percentDurationWatched)||0}})}function y(t){const e=t[t.length-1];return e&&e.continuationItemRenderer?(t.pop(),{videos:p(t),continuationToken:e.continuationItemRenderer.continuationEndpoint.continuationCommand.token}):{videos:p(t)}}function v(t,e){return r(this,void 0,void 0,(function*(){const n=new URL(""+a),r=_(t,l),o={context:{client:{clientName:t.INNERTUBE_CONTEXT_CLIENT_NAME,clientVersion:t.INNERTUBE_CONTEXT_CLIENT_VERSION}},continuation:e.continuationToken};n.searchParams.append("key",t.INNERTUBE_API_KEY);const i=yield fetch(""+n,{credentials:"include",headers:r,body:JSON.stringify(o),method:"POST",mode:"cors"});return y((yield i.json()).onResponseReceivedActions[0].appendContinuationItemsAction.continuationItems)}))}e.fetchAllPlaylistContent=function(t,e){return r(this,void 0,void 0,(function*(){const n=yield function(t,e){return r(this,void 0,void 0,(function*(){const n=new URL(""+f),r=_(t,d);n.searchParams.append("list",e),n.searchParams.append("pbj","1");const o=yield fetch(""+n,{credentials:"include",headers:r,method:"GET",mode:"cors"}),i=(yield o.json())[1].response.contents.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents[0].itemSectionRenderer.contents[0].playlistVideoListRenderer;return{playlistId:i.playlistId,isEditable:i.isEditable,canReorder:i.canReorder,continuations:[y(i.contents)]}}))}(t,e);if(n.isEditable){for(;void 0!==n.continuations[n.continuations.length-1].continuationToken;)n.continuations.push(yield v(t,n.continuations[n.continuations.length-1]));let e=[];for(const t of n.continuations)e=[...e,...t.videos];return n.continuations=[{videos:e}],n}throw u.PlaylistNotEditableError}))},e.removeVideosFromPlaylist=function(t,e,n){return r(this,void 0,void 0,(function*(){const r=new URL(""+c),o=_(t,l),i={actions:n.map(({videoId:t})=>({removedVideoId:t,action:"ACTION_REMOVE_VIDEO_BY_VIDEO_ID"})),context:{client:{clientName:t.INNERTUBE_CONTEXT_CLIENT_NAME,clientVersion:t.INNERTUBE_CONTEXT_CLIENT_VERSION}},params:"CAFAAQ%3D%3D",playlistId:e};r.searchParams.append("key",t.INNERTUBE_API_KEY);const u=yield fetch(""+r,{credentials:"include",headers:o,body:JSON.stringify(i),method:"POST",mode:"cors"});return"STATUS_SUCCEEDED"!==(yield u.json()).status}))}},function(t,e,n){(function(e){var r,o,i,u;r=n(28),o=n(8).utf8,i=n(8).bin,(u=function(t,n){var u=r.wordsToBytes(function(t){t.constructor==String?t=o.stringToBytes(t):void 0!==e&&"function"==typeof e.isBuffer&&e.isBuffer(t)?t=Array.prototype.slice.call(t,0):Array.isArray(t)||(t=t.toString());var n=r.bytesToWords(t),i=8*t.length,u=[],s=1732584193,a=-271733879,c=-1732584194,f=271733878,l=-1009589776;n[i>>5]|=128<<24-i%32,n[15+(i+64>>>9<<4)]=i;for(var d=0;d<n.length;d+=16){for(var h=s,_=a,p=c,y=f,v=l,g=0;g<80;g++){if(g<16)u[g]=n[d+g];else{var m=u[g-3]^u[g-8]^u[g-14]^u[g-16];u[g]=m<<1|m>>>31}var E=(s<<5|s>>>27)+l+(u[g]>>>0)+(g<20?1518500249+(a&c|~a&f):g<40?1859775393+(a^c^f):g<60?(a&c|a&f|c&f)-1894007588:(a^c^f)-899497514);l=f,f=c,c=a<<30|a>>>2,a=s,s=E}s+=h,a+=_,c+=p,f+=y,l+=v}return[s,a,c,f,l]}(t));return n&&n.asBytes?u:n&&n.asString?i.bytesToString(u):r.bytesToHex(u)})._blocksize=16,u._digestsize=20,t.exports=u}).call(this,n(23).Buffer)},function(t,e,n){"use strict";(function(t){var r=n(25),o=n(26),i=n(27);function u(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function s(t,e){if(u()<e)throw new RangeError("Invalid typed array length");return a.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=a.prototype:(null===t&&(t=new a(e)),t.length=e),t}function a(t,e,n){if(!(a.TYPED_ARRAY_SUPPORT||this instanceof a))return new a(t,e,n);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return l(this,t)}return c(this,t,e,n)}function c(t,e,n,r){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,n,r){if(e.byteLength,n<0||e.byteLength<n)throw new RangeError("'offset' is out of bounds");if(e.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");e=void 0===n&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,n):new Uint8Array(e,n,r);a.TYPED_ARRAY_SUPPORT?(t=e).__proto__=a.prototype:t=d(t,e);return t}(t,e,n,r):"string"==typeof e?function(t,e,n){"string"==typeof n&&""!==n||(n="utf8");if(!a.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|_(e,n),o=(t=s(t,r)).write(e,n);o!==r&&(t=t.slice(0,o));return t}(t,e,n):function(t,e){if(a.isBuffer(e)){var n=0|h(e.length);return 0===(t=s(t,n)).length||e.copy(t,0,0,n),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(r=e.length)!=r?s(t,0):d(t,e);if("Buffer"===e.type&&i(e.data))return d(t,e.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function f(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function l(t,e){if(f(e),t=s(t,e<0?0:0|h(e)),!a.TYPED_ARRAY_SUPPORT)for(var n=0;n<e;++n)t[n]=0;return t}function d(t,e){var n=e.length<0?0:0|h(e.length);t=s(t,n);for(var r=0;r<n;r+=1)t[r]=255&e[r];return t}function h(t){if(t>=u())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u().toString(16)+" bytes");return 0|t}function _(t,e){if(a.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return Y(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return V(t).length;default:if(r)return Y(t).length;e=(""+e).toLowerCase(),r=!0}}function p(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,e,n);case"utf8":case"utf-8":return P(this,e,n);case"ascii":return O(this,e,n);case"latin1":case"binary":return I(this,e,n);case"base64":return R(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function y(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function v(t,e,n,r,o){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(o)return-1;n=t.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof e&&(e=a.from(e,r)),a.isBuffer(e))return 0===e.length?-1:g(t,e,n,r,o);if("number"==typeof e)return e&=255,a.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):g(t,[e],n,r,o);throw new TypeError("val must be string, number or Buffer")}function g(t,e,n,r,o){var i,u=1,s=t.length,a=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;u=2,s/=2,a/=2,n/=2}function c(t,e){return 1===u?t[e]:t.readUInt16BE(e*u)}if(o){var f=-1;for(i=n;i<s;i++)if(c(t,i)===c(e,-1===f?0:i-f)){if(-1===f&&(f=i),i-f+1===a)return f*u}else-1!==f&&(i-=i-f),f=-1}else for(n+a>s&&(n=s-a),i=n;i>=0;i--){for(var l=!0,d=0;d<a;d++)if(c(t,i+d)!==c(e,d)){l=!1;break}if(l)return i}return-1}function m(t,e,n,r){n=Number(n)||0;var o=t.length-n;r?(r=Number(r))>o&&(r=o):r=o;var i=e.length;if(i%2!=0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var u=0;u<r;++u){var s=parseInt(e.substr(2*u,2),16);if(isNaN(s))return u;t[n+u]=s}return u}function E(t,e,n,r){return H(Y(e,t.length-n),t,n,r)}function b(t,e,n,r){return H(function(t){for(var e=[],n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function w(t,e,n,r){return b(t,e,n,r)}function T(t,e,n,r){return H(V(e),t,n,r)}function A(t,e,n,r){return H(function(t,e){for(var n,r,o,i=[],u=0;u<t.length&&!((e-=2)<0);++u)n=t.charCodeAt(u),r=n>>8,o=n%256,i.push(o),i.push(r);return i}(e,t.length-n),t,n,r)}function R(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function P(t,e,n){n=Math.min(t.length,n);for(var r=[],o=e;o<n;){var i,u,s,a,c=t[o],f=null,l=c>239?4:c>223?3:c>191?2:1;if(o+l<=n)switch(l){case 1:c<128&&(f=c);break;case 2:128==(192&(i=t[o+1]))&&(a=(31&c)<<6|63&i)>127&&(f=a);break;case 3:i=t[o+1],u=t[o+2],128==(192&i)&&128==(192&u)&&(a=(15&c)<<12|(63&i)<<6|63&u)>2047&&(a<55296||a>57343)&&(f=a);break;case 4:i=t[o+1],u=t[o+2],s=t[o+3],128==(192&i)&&128==(192&u)&&128==(192&s)&&(a=(15&c)<<18|(63&i)<<12|(63&u)<<6|63&s)>65535&&a<1114112&&(f=a)}null===f?(f=65533,l=1):f>65535&&(f-=65536,r.push(f>>>10&1023|55296),f=56320|1023&f),r.push(f),o+=l}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);var n="",r=0;for(;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=4096));return n}(r)}e.Buffer=a,e.SlowBuffer=function(t){+t!=t&&(t=0);return a.alloc(+t)},e.INSPECT_MAX_BYTES=50,a.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=u(),a.poolSize=8192,a._augment=function(t){return t.__proto__=a.prototype,t},a.from=function(t,e,n){return c(null,t,e,n)},a.TYPED_ARRAY_SUPPORT&&(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0})),a.alloc=function(t,e,n){return function(t,e,n,r){return f(e),e<=0?s(t,e):void 0!==n?"string"==typeof r?s(t,e).fill(n,r):s(t,e).fill(n):s(t,e)}(null,t,e,n)},a.allocUnsafe=function(t){return l(null,t)},a.allocUnsafeSlow=function(t){return l(null,t)},a.isBuffer=function(t){return!(null==t||!t._isBuffer)},a.compare=function(t,e){if(!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var n=t.length,r=e.length,o=0,i=Math.min(n,r);o<i;++o)if(t[o]!==e[o]){n=t[o],r=e[o];break}return n<r?-1:r<n?1:0},a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(t,e){if(!i(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return a.alloc(0);var n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var r=a.allocUnsafe(e),o=0;for(n=0;n<t.length;++n){var u=t[n];if(!a.isBuffer(u))throw new TypeError('"list" argument must be an Array of Buffers');u.copy(r,o),o+=u.length}return r},a.byteLength=_,a.prototype._isBuffer=!0,a.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)y(this,e,e+1);return this},a.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)y(this,e,e+3),y(this,e+1,e+2);return this},a.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)y(this,e,e+7),y(this,e+1,e+6),y(this,e+2,e+5),y(this,e+3,e+4);return this},a.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?P(this,0,t):p.apply(this,arguments)},a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===a.compare(this,t)},a.prototype.inspect=function(){var t="",n=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),"<Buffer "+t+">"},a.prototype.compare=function(t,e,n,r,o){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),e<0||n>t.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&e>=n)return 0;if(r>=o)return-1;if(e>=n)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(r>>>=0),u=(n>>>=0)-(e>>>=0),s=Math.min(i,u),c=this.slice(r,o),f=t.slice(e,n),l=0;l<s;++l)if(c[l]!==f[l]){i=c[l],u=f[l];break}return i<u?-1:u<i?1:0},a.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},a.prototype.indexOf=function(t,e,n){return v(this,t,e,n,!0)},a.prototype.lastIndexOf=function(t,e,n){return v(this,t,e,n,!1)},a.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-e;if((void 0===n||n>o)&&(n=o),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return m(this,t,e,n);case"utf8":case"utf-8":return E(this,t,e,n);case"ascii":return b(this,t,e,n);case"latin1":case"binary":return w(this,t,e,n);case"base64":return T(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function O(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;o<n;++o)r+=String.fromCharCode(127&t[o]);return r}function I(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;o<n;++o)r+=String.fromCharCode(t[o]);return r}function S(t,e,n){var r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);for(var o="",i=e;i<n;++i)o+=j(t[i]);return o}function N(t,e,n){for(var r=t.slice(e,n),o="",i=0;i<r.length;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}function C(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function D(t,e,n,r,o,i){if(!a.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function U(t,e,n,r){e<0&&(e=65535+e+1);for(var o=0,i=Math.min(t.length-n,2);o<i;++o)t[n+o]=(e&255<<8*(r?o:1-o))>>>8*(r?o:1-o)}function L(t,e,n,r){e<0&&(e=4294967295+e+1);for(var o=0,i=Math.min(t.length-n,4);o<i;++o)t[n+o]=e>>>8*(r?o:3-o)&255}function B(t,e,n,r,o,i){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function M(t,e,n,r,i){return i||B(t,0,n,4),o.write(t,e,n,r,23,4),n+4}function x(t,e,n,r,i){return i||B(t,0,n,8),o.write(t,e,n,r,52,8),n+8}a.prototype.slice=function(t,e){var n,r=this.length;if((t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t),a.TYPED_ARRAY_SUPPORT)(n=this.subarray(t,e)).__proto__=a.prototype;else{var o=e-t;n=new a(o,void 0);for(var i=0;i<o;++i)n[i]=this[i+t]}return n},a.prototype.readUIntLE=function(t,e,n){t|=0,e|=0,n||C(t,e,this.length);for(var r=this[t],o=1,i=0;++i<e&&(o*=256);)r+=this[t+i]*o;return r},a.prototype.readUIntBE=function(t,e,n){t|=0,e|=0,n||C(t,e,this.length);for(var r=this[t+--e],o=1;e>0&&(o*=256);)r+=this[t+--e]*o;return r},a.prototype.readUInt8=function(t,e){return e||C(t,1,this.length),this[t]},a.prototype.readUInt16LE=function(t,e){return e||C(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUInt16BE=function(t,e){return e||C(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUInt32LE=function(t,e){return e||C(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUInt32BE=function(t,e){return e||C(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||C(t,e,this.length);for(var r=this[t],o=1,i=0;++i<e&&(o*=256);)r+=this[t+i]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*e)),r},a.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||C(t,e,this.length);for(var r=e,o=1,i=this[t+--r];r>0&&(o*=256);)i+=this[t+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},a.prototype.readInt8=function(t,e){return e||C(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},a.prototype.readInt16LE=function(t,e){e||C(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt16BE=function(t,e){e||C(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt32LE=function(t,e){return e||C(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return e||C(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readFloatLE=function(t,e){return e||C(t,4,this.length),o.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return e||C(t,4,this.length),o.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return e||C(t,8,this.length),o.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return e||C(t,8,this.length),o.read(this,t,!1,52,8)},a.prototype.writeUIntLE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||D(this,t,e,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[e]=255&t;++i<n&&(o*=256);)this[e+i]=t/o&255;return e+n},a.prototype.writeUIntBE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||D(this,t,e,n,Math.pow(2,8*n)-1,0);var o=n-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+n},a.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,1,255,0),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},a.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):U(this,t,e,!0),e+2},a.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):U(this,t,e,!1),e+2},a.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):L(this,t,e,!0),e+4},a.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):L(this,t,e,!1),e+4},a.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e|=0,!r){var o=Math.pow(2,8*n-1);D(this,t,e,n,o-1,-o)}var i=0,u=1,s=0;for(this[e]=255&t;++i<n&&(u*=256);)t<0&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/u>>0)-s&255;return e+n},a.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e|=0,!r){var o=Math.pow(2,8*n-1);D(this,t,e,n,o-1,-o)}var i=n-1,u=1,s=0;for(this[e+i]=255&t;--i>=0&&(u*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/u>>0)-s&255;return e+n},a.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,1,127,-128),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},a.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):U(this,t,e,!0),e+2},a.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):U(this,t,e,!1),e+2},a.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):L(this,t,e,!0),e+4},a.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):L(this,t,e,!1),e+4},a.prototype.writeFloatLE=function(t,e,n){return M(this,t,e,!0,n)},a.prototype.writeFloatBE=function(t,e,n){return M(this,t,e,!1,n)},a.prototype.writeDoubleLE=function(t,e,n){return x(this,t,e,!0,n)},a.prototype.writeDoubleBE=function(t,e,n){return x(this,t,e,!1,n)},a.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);var o,i=r-n;if(this===t&&n<e&&e<r)for(o=i-1;o>=0;--o)t[o+e]=this[o+n];else if(i<1e3||!a.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)t[o+e]=this[o+n];else Uint8Array.prototype.set.call(t,this.subarray(n,n+i),e);return i},a.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===t.length){var o=t.charCodeAt(0);o<256&&(t=o)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!a.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;var i;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(i=e;i<n;++i)this[i]=t;else{var u=a.isBuffer(t)?t:Y(new a(t,r).toString()),s=u.length;for(i=0;i<n-e;++i)this[i+e]=u[i%s]}return this};var k=/[^+\/0-9A-Za-z-_]/g;function j(t){return t<16?"0"+t.toString(16):t.toString(16)}function Y(t,e){var n;e=e||1/0;for(var r=t.length,o=null,i=[],u=0;u<r;++u){if((n=t.charCodeAt(u))>55295&&n<57344){if(!o){if(n>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(u+1===r){(e-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(e-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((e-=1)<0)break;i.push(n)}else if(n<2048){if((e-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function V(t){return r.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(k,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function H(t,e,n,r){for(var o=0;o<r&&!(o+n>=e.length||o>=t.length);++o)e[o+n]=t[o];return o}}).call(this,n(24))},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";e.byteLength=function(t){var e=c(t),n=e[0],r=e[1];return 3*(n+r)/4-r},e.toByteArray=function(t){var e,n,r=c(t),u=r[0],s=r[1],a=new i(function(t,e,n){return 3*(e+n)/4-n}(0,u,s)),f=0,l=s>0?u-4:u;for(n=0;n<l;n+=4)e=o[t.charCodeAt(n)]<<18|o[t.charCodeAt(n+1)]<<12|o[t.charCodeAt(n+2)]<<6|o[t.charCodeAt(n+3)],a[f++]=e>>16&255,a[f++]=e>>8&255,a[f++]=255&e;2===s&&(e=o[t.charCodeAt(n)]<<2|o[t.charCodeAt(n+1)]>>4,a[f++]=255&e);1===s&&(e=o[t.charCodeAt(n)]<<10|o[t.charCodeAt(n+1)]<<4|o[t.charCodeAt(n+2)]>>2,a[f++]=e>>8&255,a[f++]=255&e);return a},e.fromByteArray=function(t){for(var e,n=t.length,o=n%3,i=[],u=0,s=n-o;u<s;u+=16383)i.push(f(t,u,u+16383>s?s:u+16383));1===o?(e=t[n-1],i.push(r[e>>2]+r[e<<4&63]+"==")):2===o&&(e=(t[n-2]<<8)+t[n-1],i.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"="));return i.join("")};for(var r=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,a=u.length;s<a;++s)r[s]=u[s],o[u.charCodeAt(s)]=s;function c(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function f(t,e,n){for(var o,i,u=[],s=e;s<n;s+=3)o=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),u.push(r[(i=o)>>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return u.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,n,r,o){var i,u,s=8*o-r-1,a=(1<<s)-1,c=a>>1,f=-7,l=n?o-1:0,d=n?-1:1,h=t[e+l];for(l+=d,i=h&(1<<-f)-1,h>>=-f,f+=s;f>0;i=256*i+t[e+l],l+=d,f-=8);for(u=i&(1<<-f)-1,i>>=-f,f+=r;f>0;u=256*u+t[e+l],l+=d,f-=8);if(0===i)i=1-c;else{if(i===a)return u?NaN:1/0*(h?-1:1);u+=Math.pow(2,r),i-=c}return(h?-1:1)*u*Math.pow(2,i-r)},e.write=function(t,e,n,r,o,i){var u,s,a,c=8*i-o-1,f=(1<<c)-1,l=f>>1,d=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:i-1,_=r?1:-1,p=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,u=f):(u=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-u))<1&&(u--,a*=2),(e+=u+l>=1?d/a:d*Math.pow(2,1-l))*a>=2&&(u++,a/=2),u+l>=f?(s=0,u=f):u+l>=1?(s=(e*a-1)*Math.pow(2,o),u+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,o),u=0));o>=8;t[n+h]=255&s,h+=_,s/=256,o-=8);for(u=u<<o|s,c+=o;c>0;t[n+h]=255&u,h+=_,u/=256,c-=8);t[n+h-_]|=128*p}},function(t,e){var n={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},function(t,e){var n,r;n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r={rotl:function(t,e){return t<<e|t>>>32-e},rotr:function(t,e){return t<<32-e|t>>>e},endian:function(t){if(t.constructor==Number)return 16711935&r.rotl(t,8)|4278255360&r.rotl(t,24);for(var e=0;e<t.length;e++)t[e]=r.endian(t[e]);return t},randomBytes:function(t){for(var e=[];t>0;t--)e.push(Math.floor(256*Math.random()));return e},bytesToWords:function(t){for(var e=[],n=0,r=0;n<t.length;n++,r+=8)e[r>>>5]|=t[n]<<24-r%32;return e},wordsToBytes:function(t){for(var e=[],n=0;n<32*t.length;n+=8)e.push(t[n>>>5]>>>24-n%32&255);return e},bytesToHex:function(t){for(var e=[],n=0;n<t.length;n++)e.push((t[n]>>>4).toString(16)),e.push((15&t[n]).toString(16));return e.join("")},hexToBytes:function(t){for(var e=[],n=0;n<t.length;n+=2)e.push(parseInt(t.substr(n,2),16));return e},bytesToBase64:function(t){for(var e=[],r=0;r<t.length;r+=3)for(var o=t[r]<<16|t[r+1]<<8|t[r+2],i=0;i<4;i++)8*r+6*i<=8*t.length?e.push(n.charAt(o>>>6*(3-i)&63)):e.push("=");return e.join("")},base64ToBytes:function(t){t=t.replace(/[^A-Z0-9+\/]/gi,"");for(var e=[],r=0,o=0;r<t.length;o=++r%4)0!=o&&e.push((n.indexOf(t.charAt(r-1))&Math.pow(2,-2*o+8)-1)<<2*o|n.indexOf(t.charAt(r))>>>6-2*o);return e}},t.exports=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PlaylistVideosRemoveError=e.PlaylistDataFetchError=e.PlaylistNotEditableError=void 0,e.PlaylistNotEditableError=new Error("playlist is not editable"),e.PlaylistDataFetchError=new Error("cannot fetch some data for the playlist"),e.PlaylistVideosRemoveError=new Error("cannot remove videos from playlist")},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e){const n=[[],[]];for(const r of t)n[e(r)?0:1].push(r);return n}},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=r(n(32)),i=r(n(34));e.default=function(t){try{o.default(t),i.default(t.length)}catch(t){window.location.reload()}}},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=n(5),i=r(n(6)),u=r(n(33));e.default=function(t){const e=i.default(o.XPATH.YT_PLAYLIST_VIDEO_RENDERERS);if(e.length>=t.length){const n=u.default(t,e,t=>t.videoId,t=>t.data.videoId);if(n){const t=Object.values(n);for(const e of t)e.hidden=!0;return}}throw new Error("some videos are missing from the UI, cannot dynamically delete")}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e,n,r){const o={};if(e.length<t.length)return!1;for(const e of t)o[n(e)]=void 0;let i=0;for(const n of e){const e=r(n);if(!0===Object.prototype.hasOwnProperty.call(o,e)&&void 0===o[e]&&(o[e]=n,i+=1,i===t.length))return o}return i===t.length&&o}},function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=n(5),i=r(n(6));e.default=function(t){const e=i.default(o.XPATH.YT_NUMBERS_OF_VIDEOS_IN_PLAYLIST)[0];if(!e)throw new Error("span with the number of videos in playlist not found in DOM");{const n=Number(e.textContent)-t;e.textContent=""+n}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const r={};e.default=r},function(t,e,n){"use strict";n.r(e),n.d(e,"environment",(function(){return a})),n.d(e,"errors",(function(){return r})),n.d(e,"log",(function(){return o})),n.d(e,"operations",(function(){return b})),n.d(e,"preferences",(function(){return i})),n.d(e,"stylesheets",(function(){return u})),n.d(e,"userscripter",(function(){return s}));var r={};n.r(r),n.d(r,"explanation",(function(){return l})),n.d(r,"failureDescriber",(function(){return d}));var o={};n.r(o),n.d(o,"setPrefix",(function(){return p})),n.d(o,"setLogger",(function(){return y})),n.d(o,"log",(function(){return v})),n.d(o,"info",(function(){return g})),n.d(o,"warning",(function(){return m})),n.d(o,"error",(function(){return E}));var i={};n.r(i),n.d(i,"subscriptable",(function(){return w})),n.d(i,"loggingResponseHandler",(function(){return T})),n.d(i,"noopResponseHandler",(function(){return A}));var u={};n.r(u),n.d(u,"stylesheet",(function(){return P})),n.d(u,"insert",(function(){return O})),n.d(u,"enable",(function(){return S})),n.d(u,"disable",(function(){return N}));var s={};n.r(s),n.d(s,"run",(function(){return C}));var a=n(4);function c(t){return t.map(t=>t+"\n").join("")}function f(t){return" "+t.key+": "+t.selector}function l(t){switch(t.result.reason){case 0:return c(["These dependencies were not found:","",c(t.result.dependencies.map(f))]);case 1:return c(["The operation failed with this error:","",t.result.message])}}function d(t){return e=>c([`Could not ${e.operation.description} on this page:`,""," "+location.href,"",l(e).trim(),"",`This problem might be caused by ${t.siteName} changing its content/structure, in which case ${t.extensionName} needs to be updated accordingly. Otherwise, it's probably a bug in ${t.extensionName}.`,"","If you file a bug report, please include this message."])}let h="",_=console;function p(t){h=t}function y(t){_=t}function v(t){_.log(h,t)}function g(t){_.info(h,t)}function m(t){_.warn(h,t)}function E(t){_.error(h,t)}var b=n(1);function w(t){const e=new Set;return{subscribe:t=>{e.add(t)},unsubscribe:t=>{e.delete(t)},handler:(n,r)=>("set"===n.action&&e.forEach(t=>t(n.preference)),t(n,r))}}function T(t,e){const n=t.response;switch(n.status){case 0:return n;case 1:return"get"===t.action&&(m(`The saved value for preference '${t.preference.key}' (${JSON.stringify(n.saved)}) was invalid. Replacing it with ${JSON.stringify(n.value)}.`),e.set(t.preference,n.value)),"set"===t.action&&m(`Could not set value ${JSON.stringify(n.value)} for preference '${t.preference.key}' because it was invalid.`),n;case 2:return"get"===t.action&&(m(`The saved value for preference '${t.preference.key}' had the wrong type. Replacing it with ${JSON.stringify(n.value)}.`),e.set(t.preference,n.value)),n;case 3:return"get"===t.action&&(m(`The saved value for preference '${t.preference.key}' could not be parsed. Replacing it with ${JSON.stringify(n.value)}.`),e.set(t.preference,n.value)),n;case 4:switch(t.action){case"get":E(`Could not read preference '${t.preference.key}' because localStorage could not be accessed. Using value ${JSON.stringify(t.preference.default)}.`);break;case"set":E(`Could not save value ${JSON.stringify(t.response.value)} for preference '${t.preference.key}' because localStorage could not be accessed.`);break;default:R(t.action)}return n;default:return R(n.status)}}function A(t,e){return t.response}function R(t){throw new Error("assertUnreachable: "+t)}function P(t){return t}function O(t){const e=document.createDocumentFragment();Object.entries(t).forEach(([t,n])=>{const r=document.createElement("style");void 0!==n.id&&(r.id=n.id),r.textContent=n.css,r.media=n.condition(window)?"all":"not all",e.appendChild(r)}),document.documentElement.appendChild(e)}const I=t=>e=>{const n=document.getElementById(e.id);null!==n&&n.setAttribute("media",t)},S=I("all"),N=I("not all");function C(t){p(`[${t.name}]`);const e="data-"+t.id+"-has-run";document.documentElement.hasAttribute(e)?m(`It looks as though ${t.name} has already run (because the attribute "${e}" was found on <head>). Stopping.`):(document.documentElement.setAttribute(e,""),t.initialAction(),O(t.stylesheets),b.run(t.operationsPlan))}},function(t,e,n){"use strict";function r(){switch(arguments.length){case 1:return o(arguments[0]);case 2:return i(arguments[0],arguments[1]);case 3:return u(arguments[0],arguments[1],arguments[2]);case 4:return s(arguments[0],arguments[1],arguments[2],arguments[3]);case 5:return a(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4])}}function o(t){return function(e){return t(e)}}function i(t,e){return function(n){return t(e(n))}}function u(t,e,n){return function(r){return t(e(n(r)))}}function s(t,e,n,r){return function(o){return t(e(n(r(o))))}}function a(t,e,n,r,o){return function(i){return t(e(n(r(o(i)))))}}n.r(e),n.d(e,"compose",(function(){return r}))}]);