8 lines
111 KiB
JavaScript
8 lines
111 KiB
JavaScript
(()=>{var e={9483:(e,t,r)=>{
|
|
/*!
|
|
localForage -- Offline Storage, Improved
|
|
Version 1.10.0
|
|
https://localforage.github.io/localForage
|
|
(c) 2013-2017 Mozilla, Apache License 2.0
|
|
*/
|
|
e.exports=function e(t,r,n){function o(i,c){if(!r[i]){if(!t[i]){if(a)return a(i,!0);var u=new Error("Cannot find module '"+i+"'");throw u.code="MODULE_NOT_FOUND",u}var s=r[i]={exports:{}};t[i][0].call(s.exports,(function(e){var r=t[i][1][e];return o(r||e)}),s,s.exports,e,t,r,n)}return r[i].exports}for(var a=void 0,i=0;i<n.length;i++)o(n[i]);return o}({1:[function(e,t,n){(function(e){"use strict";var r,n,o=e.MutationObserver||e.WebKitMutationObserver;if(o){var a=0,i=new o(f),c=e.document.createTextNode("");i.observe(c,{characterData:!0}),r=function(){c.data=a=++a%2}}else if(e.setImmediate||void 0===e.MessageChannel)r="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){f(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(f,0)};else{var u=new e.MessageChannel;u.port1.onmessage=f,r=function(){u.port2.postMessage(0)}}var s=[];function f(){var e,t;n=!0;for(var r=s.length;r;){for(t=s,s=[],e=-1;++e<r;)t[e]();r=s.length}n=!1}function l(e){1!==s.push(e)||n||r()}t.exports=l}).call(this,void 0!==r.g?r.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,t,r){"use strict";var n=e(1);function o(){}var a={},i=["REJECTED"],c=["FULFILLED"],u=["PENDING"];function s(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=u,this.queue=[],this.outcome=void 0,e!==o&&p(this,e)}function f(e,t,r){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof r&&(this.onRejected=r,this.callRejected=this.otherCallRejected)}function l(e,t,r){n((function(){var n;try{n=t(r)}catch(t){return a.reject(e,t)}n===e?a.reject(e,new TypeError("Cannot resolve promise with itself")):a.resolve(e,n)}))}function h(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function p(e,t){var r=!1;function n(t){r||(r=!0,a.reject(e,t))}function o(t){r||(r=!0,a.resolve(e,t))}function i(){t(o,n)}var c=d(i);"error"===c.status&&n(c.value)}function d(e,t){var r={};try{r.value=e(t),r.status="success"}catch(e){r.status="error",r.value=e}return r}function m(e){return e instanceof this?e:a.resolve(new this(o),e)}function v(e){var t=new this(o);return a.reject(t,e)}function g(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var r=e.length,n=!1;if(!r)return this.resolve([]);for(var i=new Array(r),c=0,u=-1,s=new this(o);++u<r;)f(e[u],u);return s;function f(e,o){function u(e){i[o]=e,++c!==r||n||(n=!0,a.resolve(s,i))}t.resolve(e).then(u,(function(e){n||(n=!0,a.reject(s,e))}))}}function y(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var r=e.length,n=!1;if(!r)return this.resolve([]);for(var i=-1,c=new this(o);++i<r;)u(e[i]);return c;function u(e){t.resolve(e).then((function(e){n||(n=!0,a.resolve(c,e))}),(function(e){n||(n=!0,a.reject(c,e))}))}}t.exports=s,s.prototype.catch=function(e){return this.then(null,e)},s.prototype.then=function(e,t){if("function"!=typeof e&&this.state===c||"function"!=typeof t&&this.state===i)return this;var r=new this.constructor(o);return this.state!==u?l(r,this.state===c?e:t,this.outcome):this.queue.push(new f(r,e,t)),r},f.prototype.callFulfilled=function(e){a.resolve(this.promise,e)},f.prototype.otherCallFulfilled=function(e){l(this.promise,this.onFulfilled,e)},f.prototype.callRejected=function(e){a.reject(this.promise,e)},f.prototype.otherCallRejected=function(e){l(this.promise,this.onRejected,e)},a.resolve=function(e,t){var r=d(h,t);if("error"===r.status)return a.reject(e,r.value);var n=r.value;if(n)p(e,n);else{e.state=c,e.outcome=t;for(var o=-1,i=e.queue.length;++o<i;)e.queue[o].callFulfilled(t)}return e},a.reject=function(e,t){e.state=i,e.outcome=t;for(var r=-1,n=e.queue.length;++r<n;)e.queue[r].callRejected(t);return e},s.resolve=m,s.reject=v,s.all=g,s.race=y},{1:1}],3:[function(e,t,n){(function(t){"use strict";"function"!=typeof t.Promise&&(t.Promise=e(2))}).call(this,void 0!==r.g?r.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{2:2}],4:[function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(){try{if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB;if("undefined"!=typeof mozIndexedDB)return mozIndexedDB;if("undefined"!=typeof OIndexedDB)return OIndexedDB;if("undefined"!=typeof msIndexedDB)return msIndexedDB}catch(e){return}}var i=a();function c(){try{if(!i||!i.open)return!1;var e="undefined"!=typeof openDatabase&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t="function"==typeof fetch&&-1!==fetch.toString().indexOf("[native code");return(!e||t)&&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(e){return!1}}function u(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(o){if("TypeError"!==o.name)throw o;for(var r=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),n=0;n<e.length;n+=1)r.append(e[n]);return r.getBlob(t.type)}}"undefined"==typeof Promise&&e(3);var s=Promise;function f(e,t){t&&e.then((function(e){t(null,e)}),(function(e){t(e)}))}function l(e,t,r){"function"==typeof t&&e.then(t),"function"==typeof r&&e.catch(r)}function h(e){return"string"!=typeof e&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function p(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}var d="local-forage-detect-blob-support",m=void 0,v={},g=Object.prototype.toString,y="readonly",b="readwrite";function w(e){for(var t=e.length,r=new ArrayBuffer(t),n=new Uint8Array(r),o=0;o<t;o++)n[o]=e.charCodeAt(o);return r}function x(e){return new s((function(t){var r=e.transaction(d,b),n=u([""]);r.objectStore(d).put(n,"key"),r.onabort=function(e){e.preventDefault(),e.stopPropagation(),t(!1)},r.oncomplete=function(){var e=navigator.userAgent.match(/Chrome\/(\d+)/),r=navigator.userAgent.match(/Edge\//);t(r||!e||parseInt(e[1],10)>=43)}})).catch((function(){return!1}))}function k(e){return"boolean"==typeof m?s.resolve(m):x(e).then((function(e){return m=e}))}function E(e){var t=v[e.name],r={};r.promise=new s((function(e,t){r.resolve=e,r.reject=t})),t.deferredOperations.push(r),t.dbReady?t.dbReady=t.dbReady.then((function(){return r.promise})):t.dbReady=r.promise}function _(e){var t=v[e.name].deferredOperations.pop();if(t)return t.resolve(),t.promise}function I(e,t){var r=v[e.name].deferredOperations.pop();if(r)return r.reject(t),r.promise}function S(e,t){return new s((function(r,n){if(v[e.name]=v[e.name]||P(),e.db){if(!t)return r(e.db);E(e),e.db.close()}var o=[e.name];t&&o.push(e.version);var a=i.open.apply(i,o);t&&(a.onupgradeneeded=function(t){var r=a.result;try{r.createObjectStore(e.storeName),t.oldVersion<=1&&r.createObjectStore(d)}catch(r){if("ConstraintError"!==r.name)throw r;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),a.onerror=function(e){e.preventDefault(),n(a.error)},a.onsuccess=function(){var t=a.result;t.onversionchange=function(e){e.target.close()},r(t),_(e)}}))}function L(e){return S(e,!1)}function T(e){return S(e,!0)}function A(e,t){if(!e.db)return!0;var r=!e.db.objectStoreNames.contains(e.storeName),n=e.version<e.db.version,o=e.version>e.db.version;if(n&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),o||r){if(r){var a=e.db.version+1;a>e.version&&(e.version=a)}return!0}return!1}function j(e){return new s((function(t,r){var n=new FileReader;n.onerror=r,n.onloadend=function(r){var n=btoa(r.target.result||"");t({__local_forage_encoded_blob:!0,data:n,type:e.type})},n.readAsBinaryString(e)}))}function O(e){return u([w(atob(e.data))],{type:e.type})}function N(e){return e&&e.__local_forage_encoded_blob}function R(e){var t=this,r=t._initReady().then((function(){var e=v[t._dbInfo.name];if(e&&e.dbReady)return e.dbReady}));return l(r,e,e),r}function D(e){E(e);for(var t=v[e.name],r=t.forages,n=0;n<r.length;n++){var o=r[n];o._dbInfo.db&&(o._dbInfo.db.close(),o._dbInfo.db=null)}return e.db=null,L(e).then((function(t){return e.db=t,A(e)?T(e):t})).then((function(n){e.db=t.db=n;for(var o=0;o<r.length;o++)r[o]._dbInfo.db=n})).catch((function(t){throw I(e,t),t}))}function C(e,t,r,n){void 0===n&&(n=1);try{var o=e.db.transaction(e.storeName,t);r(null,o)}catch(o){if(n>0&&(!e.db||"InvalidStateError"===o.name||"NotFoundError"===o.name))return s.resolve().then((function(){if(!e.db||"NotFoundError"===o.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),T(e)})).then((function(){return D(e).then((function(){C(e,t,r,n-1)}))})).catch(r);r(o)}}function P(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function M(e){var t=this,r={db:null};if(e)for(var n in e)r[n]=e[n];var o=v[r.name];o||(o=P(),v[r.name]=o),o.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=R);var a=[];function i(){return s.resolve()}for(var c=0;c<o.forages.length;c++){var u=o.forages[c];u!==t&&a.push(u._initReady().catch(i))}var f=o.forages.slice(0);return s.all(a).then((function(){return r.db=o.db,L(r)})).then((function(e){return r.db=e,A(r,t._defaultConfig.version)?T(r):e})).then((function(e){r.db=o.db=e,t._dbInfo=r;for(var n=0;n<f.length;n++){var a=f[n];a!==t&&(a._dbInfo.db=r.db,a._dbInfo.version=r.version)}}))}function F(e,t){var r=this;e=h(e);var n=new s((function(t,n){r.ready().then((function(){C(r._dbInfo,y,(function(o,a){if(o)return n(o);try{var i=a.objectStore(r._dbInfo.storeName).get(e);i.onsuccess=function(){var e=i.result;void 0===e&&(e=null),N(e)&&(e=O(e)),t(e)},i.onerror=function(){n(i.error)}}catch(e){n(e)}}))})).catch(n)}));return f(n,t),n}function U(e,t){var r=this,n=new s((function(t,n){r.ready().then((function(){C(r._dbInfo,y,(function(o,a){if(o)return n(o);try{var i=a.objectStore(r._dbInfo.storeName).openCursor(),c=1;i.onsuccess=function(){var r=i.result;if(r){var n=r.value;N(n)&&(n=O(n));var o=e(n,r.key,c++);void 0!==o?t(o):r.continue()}else t()},i.onerror=function(){n(i.error)}}catch(e){n(e)}}))})).catch(n)}));return f(n,t),n}function B(e,t,r){var n=this;e=h(e);var o=new s((function(r,o){var a;n.ready().then((function(){return a=n._dbInfo,"[object Blob]"===g.call(t)?k(a.db).then((function(e){return e?t:j(t)})):t})).then((function(t){C(n._dbInfo,b,(function(a,i){if(a)return o(a);try{var c=i.objectStore(n._dbInfo.storeName);null===t&&(t=void 0);var u=c.put(t,e);i.oncomplete=function(){void 0===t&&(t=null),r(t)},i.onabort=i.onerror=function(){var e=u.error?u.error:u.transaction.error;o(e)}}catch(e){o(e)}}))})).catch(o)}));return f(o,r),o}function q(e,t){var r=this;e=h(e);var n=new s((function(t,n){r.ready().then((function(){C(r._dbInfo,b,(function(o,a){if(o)return n(o);try{var i=a.objectStore(r._dbInfo.storeName).delete(e);a.oncomplete=function(){t()},a.onerror=function(){n(i.error)},a.onabort=function(){var e=i.error?i.error:i.transaction.error;n(e)}}catch(e){n(e)}}))})).catch(n)}));return f(n,t),n}function G(e){var t=this,r=new s((function(e,r){t.ready().then((function(){C(t._dbInfo,b,(function(n,o){if(n)return r(n);try{var a=o.objectStore(t._dbInfo.storeName).clear();o.oncomplete=function(){e()},o.onabort=o.onerror=function(){var e=a.error?a.error:a.transaction.error;r(e)}}catch(e){r(e)}}))})).catch(r)}));return f(r,e),r}function z(e){var t=this,r=new s((function(e,r){t.ready().then((function(){C(t._dbInfo,y,(function(n,o){if(n)return r(n);try{var a=o.objectStore(t._dbInfo.storeName).count();a.onsuccess=function(){e(a.result)},a.onerror=function(){r(a.error)}}catch(e){r(e)}}))})).catch(r)}));return f(r,e),r}function W(e,t){var r=this,n=new s((function(t,n){e<0?t(null):r.ready().then((function(){C(r._dbInfo,y,(function(o,a){if(o)return n(o);try{var i=a.objectStore(r._dbInfo.storeName),c=!1,u=i.openKeyCursor();u.onsuccess=function(){var r=u.result;r?0===e||c?t(r.key):(c=!0,r.advance(e)):t(null)},u.onerror=function(){n(u.error)}}catch(e){n(e)}}))})).catch(n)}));return f(n,t),n}function Q(e){var t=this,r=new s((function(e,r){t.ready().then((function(){C(t._dbInfo,y,(function(n,o){if(n)return r(n);try{var a=o.objectStore(t._dbInfo.storeName).openKeyCursor(),i=[];a.onsuccess=function(){var t=a.result;t?(i.push(t.key),t.continue()):e(i)},a.onerror=function(){r(a.error)}}catch(e){r(e)}}))})).catch(r)}));return f(r,e),r}function V(e,t){t=p.apply(this,arguments);var r=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var n,o=this;if(e.name){var a=e.name===r.name&&o._dbInfo.db?s.resolve(o._dbInfo.db):L(e).then((function(t){var r=v[e.name],n=r.forages;r.db=t;for(var o=0;o<n.length;o++)n[o]._dbInfo.db=t;return t}));n=e.storeName?a.then((function(t){if(t.objectStoreNames.contains(e.storeName)){var r=t.version+1;E(e);var n=v[e.name],o=n.forages;t.close();for(var a=0;a<o.length;a++){var c=o[a];c._dbInfo.db=null,c._dbInfo.version=r}var u=new s((function(t,n){var o=i.open(e.name,r);o.onerror=function(e){o.result.close(),n(e)},o.onupgradeneeded=function(){o.result.deleteObjectStore(e.storeName)},o.onsuccess=function(){var e=o.result;e.close(),t(e)}}));return u.then((function(e){n.db=e;for(var t=0;t<o.length;t++){var r=o[t];r._dbInfo.db=e,_(r._dbInfo)}})).catch((function(t){throw(I(e,t)||s.resolve()).catch((function(){})),t}))}})):a.then((function(t){E(e);var r=v[e.name],n=r.forages;t.close();for(var o=0;o<n.length;o++)n[o]._dbInfo.db=null;var a=new s((function(t,r){var n=i.deleteDatabase(e.name);n.onerror=function(){var e=n.result;e&&e.close(),r(n.error)},n.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},n.onsuccess=function(){var e=n.result;e&&e.close(),t(e)}}));return a.then((function(e){r.db=e;for(var t=0;t<n.length;t++)_(n[t]._dbInfo)})).catch((function(t){throw(I(e,t)||s.resolve()).catch((function(){})),t}))}))}else n=s.reject("Invalid arguments");return f(n,t),n}var Y={_driver:"asyncStorage",_initStorage:M,_support:c(),iterate:U,getItem:F,setItem:B,removeItem:q,clear:G,length:z,key:W,keys:Q,dropInstance:V};function K(){return"function"==typeof openDatabase}var H="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",X="~~local_forage_type~",J=/^~~local_forage_type~([^~]+)~/,Z="__lfsc__:",$=Z.length,ee="arbf",te="blob",re="si08",ne="ui08",oe="uic8",ae="si16",ie="si32",ce="ur16",ue="ui32",se="fl32",fe="fl64",le=$+ee.length,he=Object.prototype.toString;function pe(e){var t,r,n,o,a,i=.75*e.length,c=e.length,u=0;"="===e[e.length-1]&&(i--,"="===e[e.length-2]&&i--);var s=new ArrayBuffer(i),f=new Uint8Array(s);for(t=0;t<c;t+=4)r=H.indexOf(e[t]),n=H.indexOf(e[t+1]),o=H.indexOf(e[t+2]),a=H.indexOf(e[t+3]),f[u++]=r<<2|n>>4,f[u++]=(15&n)<<4|o>>2,f[u++]=(3&o)<<6|63&a;return s}function de(e){var t,r=new Uint8Array(e),n="";for(t=0;t<r.length;t+=3)n+=H[r[t]>>2],n+=H[(3&r[t])<<4|r[t+1]>>4],n+=H[(15&r[t+1])<<2|r[t+2]>>6],n+=H[63&r[t+2]];return r.length%3==2?n=n.substring(0,n.length-1)+"=":r.length%3==1&&(n=n.substring(0,n.length-2)+"=="),n}function me(e,t){var r="";if(e&&(r=he.call(e)),e&&("[object ArrayBuffer]"===r||e.buffer&&"[object ArrayBuffer]"===he.call(e.buffer))){var n,o=Z;e instanceof ArrayBuffer?(n=e,o+=ee):(n=e.buffer,"[object Int8Array]"===r?o+=re:"[object Uint8Array]"===r?o+=ne:"[object Uint8ClampedArray]"===r?o+=oe:"[object Int16Array]"===r?o+=ae:"[object Uint16Array]"===r?o+=ce:"[object Int32Array]"===r?o+=ie:"[object Uint32Array]"===r?o+=ue:"[object Float32Array]"===r?o+=se:"[object Float64Array]"===r?o+=fe:t(new Error("Failed to get type for BinaryArray"))),t(o+de(n))}else if("[object Blob]"===r){var a=new FileReader;a.onload=function(){var r=X+e.type+"~"+de(this.result);t(Z+te+r)},a.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(r){console.error("Couldn't convert value into a JSON string: ",e),t(null,r)}}function ve(e){if(e.substring(0,$)!==Z)return JSON.parse(e);var t,r=e.substring(le),n=e.substring($,le);if(n===te&&J.test(r)){var o=r.match(J);t=o[1],r=r.substring(o[0].length)}var a=pe(r);switch(n){case ee:return a;case te:return u([a],{type:t});case re:return new Int8Array(a);case ne:return new Uint8Array(a);case oe:return new Uint8ClampedArray(a);case ae:return new Int16Array(a);case ce:return new Uint16Array(a);case ie:return new Int32Array(a);case ue:return new Uint32Array(a);case se:return new Float32Array(a);case fe:return new Float64Array(a);default:throw new Error("Unkown type: "+n)}}var ge={serialize:me,deserialize:ve,stringToBuffer:pe,bufferToString:de};function ye(e,t,r,n){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],r,n)}function be(e){var t=this,r={db:null};if(e)for(var n in e)r[n]="string"!=typeof e[n]?e[n].toString():e[n];var o=new s((function(e,n){try{r.db=openDatabase(r.name,String(r.version),r.description,r.size)}catch(e){return n(e)}r.db.transaction((function(o){ye(o,r,(function(){t._dbInfo=r,e()}),(function(e,t){n(t)}))}),n)}));return r.serializer=ge,o}function we(e,t,r,n,o,a){e.executeSql(r,n,o,(function(e,i){i.code===i.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],(function(e,c){c.rows.length?a(e,i):ye(e,t,(function(){e.executeSql(r,n,o,a)}),a)}),a):a(e,i)}),a)}function xe(e,t){var r=this;e=h(e);var n=new s((function(t,n){r.ready().then((function(){var o=r._dbInfo;o.db.transaction((function(r){we(r,o,"SELECT * FROM "+o.storeName+" WHERE key = ? LIMIT 1",[e],(function(e,r){var n=r.rows.length?r.rows.item(0).value:null;n&&(n=o.serializer.deserialize(n)),t(n)}),(function(e,t){n(t)}))}))})).catch(n)}));return f(n,t),n}function ke(e,t){var r=this,n=new s((function(t,n){r.ready().then((function(){var o=r._dbInfo;o.db.transaction((function(r){we(r,o,"SELECT * FROM "+o.storeName,[],(function(r,n){for(var a=n.rows,i=a.length,c=0;c<i;c++){var u=a.item(c),s=u.value;if(s&&(s=o.serializer.deserialize(s)),void 0!==(s=e(s,u.key,c+1)))return void t(s)}t()}),(function(e,t){n(t)}))}))})).catch(n)}));return f(n,t),n}function Ee(e,t,r,n){var o=this;e=h(e);var a=new s((function(a,i){o.ready().then((function(){void 0===t&&(t=null);var c=t,u=o._dbInfo;u.serializer.serialize(t,(function(t,s){s?i(s):u.db.transaction((function(r){we(r,u,"INSERT OR REPLACE INTO "+u.storeName+" (key, value) VALUES (?, ?)",[e,t],(function(){a(c)}),(function(e,t){i(t)}))}),(function(t){if(t.code===t.QUOTA_ERR){if(n>0)return void a(Ee.apply(o,[e,c,r,n-1]));i(t)}}))}))})).catch(i)}));return f(a,r),a}function _e(e,t,r){return Ee.apply(this,[e,t,r,1])}function Ie(e,t){var r=this;e=h(e);var n=new s((function(t,n){r.ready().then((function(){var o=r._dbInfo;o.db.transaction((function(r){we(r,o,"DELETE FROM "+o.storeName+" WHERE key = ?",[e],(function(){t()}),(function(e,t){n(t)}))}))})).catch(n)}));return f(n,t),n}function Se(e){var t=this,r=new s((function(e,r){t.ready().then((function(){var n=t._dbInfo;n.db.transaction((function(t){we(t,n,"DELETE FROM "+n.storeName,[],(function(){e()}),(function(e,t){r(t)}))}))})).catch(r)}));return f(r,e),r}function Le(e){var t=this,r=new s((function(e,r){t.ready().then((function(){var n=t._dbInfo;n.db.transaction((function(t){we(t,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],(function(t,r){var n=r.rows.item(0).c;e(n)}),(function(e,t){r(t)}))}))})).catch(r)}));return f(r,e),r}function Te(e,t){var r=this,n=new s((function(t,n){r.ready().then((function(){var o=r._dbInfo;o.db.transaction((function(r){we(r,o,"SELECT key FROM "+o.storeName+" WHERE id = ? LIMIT 1",[e+1],(function(e,r){var n=r.rows.length?r.rows.item(0).key:null;t(n)}),(function(e,t){n(t)}))}))})).catch(n)}));return f(n,t),n}function Ae(e){var t=this,r=new s((function(e,r){t.ready().then((function(){var n=t._dbInfo;n.db.transaction((function(t){we(t,n,"SELECT key FROM "+n.storeName,[],(function(t,r){for(var n=[],o=0;o<r.rows.length;o++)n.push(r.rows.item(o).key);e(n)}),(function(e,t){r(t)}))}))})).catch(r)}));return f(r,e),r}function je(e){return new s((function(t,r){e.transaction((function(n){n.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],(function(r,n){for(var o=[],a=0;a<n.rows.length;a++)o.push(n.rows.item(a).name);t({db:e,storeNames:o})}),(function(e,t){r(t)}))}),(function(e){r(e)}))}))}function Oe(e,t){t=p.apply(this,arguments);var r=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var n,o=this;return f(n=e.name?new s((function(t){var n;n=e.name===r.name?o._dbInfo.db:openDatabase(e.name,"","",0),e.storeName?t({db:n,storeNames:[e.storeName]}):t(je(n))})).then((function(e){return new s((function(t,r){e.db.transaction((function(n){function o(e){return new s((function(t,r){n.executeSql("DROP TABLE IF EXISTS "+e,[],(function(){t()}),(function(e,t){r(t)}))}))}for(var a=[],i=0,c=e.storeNames.length;i<c;i++)a.push(o(e.storeNames[i]));s.all(a).then((function(){t()})).catch((function(e){r(e)}))}),(function(e){r(e)}))}))})):s.reject("Invalid arguments"),t),n}var Ne={_driver:"webSQLStorage",_initStorage:be,_support:K(),iterate:ke,getItem:xe,setItem:_e,removeItem:Ie,clear:Se,length:Le,key:Te,keys:Ae,dropInstance:Oe};function Re(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}function De(e,t){var r=e.name+"/";return e.storeName!==t.storeName&&(r+=e.storeName+"/"),r}function Ce(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch(e){return!0}}function Pe(){return!Ce()||localStorage.length>0}function Me(e){var t=this,r={};if(e)for(var n in e)r[n]=e[n];return r.keyPrefix=De(e,t._defaultConfig),Pe()?(t._dbInfo=r,r.serializer=ge,s.resolve()):s.reject()}function Fe(e){var t=this,r=t.ready().then((function(){for(var e=t._dbInfo.keyPrefix,r=localStorage.length-1;r>=0;r--){var n=localStorage.key(r);0===n.indexOf(e)&&localStorage.removeItem(n)}}));return f(r,e),r}function Ue(e,t){var r=this;e=h(e);var n=r.ready().then((function(){var t=r._dbInfo,n=localStorage.getItem(t.keyPrefix+e);return n&&(n=t.serializer.deserialize(n)),n}));return f(n,t),n}function Be(e,t){var r=this,n=r.ready().then((function(){for(var t=r._dbInfo,n=t.keyPrefix,o=n.length,a=localStorage.length,i=1,c=0;c<a;c++){var u=localStorage.key(c);if(0===u.indexOf(n)){var s=localStorage.getItem(u);if(s&&(s=t.serializer.deserialize(s)),void 0!==(s=e(s,u.substring(o),i++)))return s}}}));return f(n,t),n}function qe(e,t){var r=this,n=r.ready().then((function(){var t,n=r._dbInfo;try{t=localStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(n.keyPrefix.length)),t}));return f(n,t),n}function Ge(e){var t=this,r=t.ready().then((function(){for(var e=t._dbInfo,r=localStorage.length,n=[],o=0;o<r;o++){var a=localStorage.key(o);0===a.indexOf(e.keyPrefix)&&n.push(a.substring(e.keyPrefix.length))}return n}));return f(r,e),r}function ze(e){var t=this.keys().then((function(e){return e.length}));return f(t,e),t}function We(e,t){var r=this;e=h(e);var n=r.ready().then((function(){var t=r._dbInfo;localStorage.removeItem(t.keyPrefix+e)}));return f(n,t),n}function Qe(e,t,r){var n=this;e=h(e);var o=n.ready().then((function(){void 0===t&&(t=null);var r=t;return new s((function(o,a){var i=n._dbInfo;i.serializer.serialize(t,(function(t,n){if(n)a(n);else try{localStorage.setItem(i.keyPrefix+e,t),o(r)}catch(e){"QuotaExceededError"!==e.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==e.name||a(e),a(e)}}))}))}));return f(o,r),o}function Ve(e,t){if(t=p.apply(this,arguments),!(e="function"!=typeof e&&e||{}).name){var r=this.config();e.name=e.name||r.name,e.storeName=e.storeName||r.storeName}var n,o=this;return n=e.name?new s((function(t){e.storeName?t(De(e,o._defaultConfig)):t(e.name+"/")})).then((function(e){for(var t=localStorage.length-1;t>=0;t--){var r=localStorage.key(t);0===r.indexOf(e)&&localStorage.removeItem(r)}})):s.reject("Invalid arguments"),f(n,t),n}var Ye={_driver:"localStorageWrapper",_initStorage:Me,_support:Re(),iterate:Be,getItem:Ue,setItem:Qe,removeItem:We,clear:Fe,length:ze,key:qe,keys:Ge,dropInstance:Ve},Ke=function(e,t){return e===t||"number"==typeof e&&"number"==typeof t&&isNaN(e)&&isNaN(t)},He=function(e,t){for(var r=e.length,n=0;n<r;){if(Ke(e[n],t))return!0;n++}return!1},Xe=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},Je={},Ze={},$e={INDEXEDDB:Y,WEBSQL:Ne,LOCALSTORAGE:Ye},et=[$e.INDEXEDDB._driver,$e.WEBSQL._driver,$e.LOCALSTORAGE._driver],tt=["dropInstance"],rt=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(tt),nt={description:"",driver:et.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function ot(e,t){e[t]=function(){var r=arguments;return e.ready().then((function(){return e[t].apply(e,r)}))}}function at(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var r in t)t.hasOwnProperty(r)&&(Xe(t[r])?arguments[0][r]=t[r].slice():arguments[0][r]=t[r])}return arguments[0]}var it=function(){function e(t){for(var r in o(this,e),$e)if($e.hasOwnProperty(r)){var n=$e[r],a=n._driver;this[r]=a,Je[a]||this.defineDriver(n)}this._defaultConfig=at({},nt),this._config=at({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch((function(){}))}return e.prototype.config=function(e){if("object"===(void 0===e?"undefined":n(e))){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var t in e){if("storeName"===t&&(e[t]=e[t].replace(/\W/g,"_")),"version"===t&&"number"!=typeof e[t])return new Error("Database version must be a number.");this._config[t]=e[t]}return!("driver"in e)||!e.driver||this.setDriver(this._config.driver)}return"string"==typeof e?this._config[e]:this._config},e.prototype.defineDriver=function(e,t,r){var n=new s((function(t,r){try{var n=e._driver,o=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!e._driver)return void r(o);for(var a=rt.concat("_initStorage"),i=0,c=a.length;i<c;i++){var u=a[i];if((!He(tt,u)||e[u])&&"function"!=typeof e[u])return void r(o)}var l=function(){for(var t=function(e){return function(){var t=new Error("Method "+e+" is not implemented by the current driver"),r=s.reject(t);return f(r,arguments[arguments.length-1]),r}},r=0,n=tt.length;r<n;r++){var o=tt[r];e[o]||(e[o]=t(o))}};l();var h=function(r){Je[n]&&console.info("Redefining LocalForage driver: "+n),Je[n]=e,Ze[n]=r,t()};"_support"in e?e._support&&"function"==typeof e._support?e._support().then(h,r):h(!!e._support):h(!0)}catch(e){r(e)}}));return l(n,t,r),n},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(e,t,r){var n=Je[e]?s.resolve(Je[e]):s.reject(new Error("Driver not found."));return l(n,t,r),n},e.prototype.getSerializer=function(e){var t=s.resolve(ge);return l(t,e),t},e.prototype.ready=function(e){var t=this,r=t._driverSet.then((function(){return null===t._ready&&(t._ready=t._initDriver()),t._ready}));return l(r,e,e),r},e.prototype.setDriver=function(e,t,r){var n=this;Xe(e)||(e=[e]);var o=this._getSupportedDrivers(e);function a(){n._config.driver=n.driver()}function i(e){return n._extend(e),a(),n._ready=n._initStorage(n._config),n._ready}function c(e){return function(){var t=0;function r(){for(;t<e.length;){var o=e[t];return t++,n._dbInfo=null,n._ready=null,n.getDriver(o).then(i).catch(r)}a();var c=new Error("No available storage method found.");return n._driverSet=s.reject(c),n._driverSet}return r()}}var u=null!==this._driverSet?this._driverSet.catch((function(){return s.resolve()})):s.resolve();return this._driverSet=u.then((function(){var e=o[0];return n._dbInfo=null,n._ready=null,n.getDriver(e).then((function(e){n._driver=e._driver,a(),n._wrapLibraryMethodsWithReady(),n._initDriver=c(o)}))})).catch((function(){a();var e=new Error("No available storage method found.");return n._driverSet=s.reject(e),n._driverSet})),l(this._driverSet,t,r),this._driverSet},e.prototype.supports=function(e){return!!Ze[e]},e.prototype._extend=function(e){at(this,e)},e.prototype._getSupportedDrivers=function(e){for(var t=[],r=0,n=e.length;r<n;r++){var o=e[r];this.supports(o)&&t.push(o)}return t},e.prototype._wrapLibraryMethodsWithReady=function(){for(var e=0,t=rt.length;e<t;e++)ot(this,rt[e])},e.prototype.createInstance=function(t){return new e(t)},e}(),ct=new it;t.exports=ct},{3:3}]},{},[4])(4)}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var a=t[n]={exports:{}};return e[n](a,a.exports,r),a.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */t=function(){return n};var r,n={},o=Object.prototype,a=o.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},c="function"==typeof Symbol?Symbol:{},u=c.iterator||"@@iterator",s=c.asyncIterator||"@@asyncIterator",f=c.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(r){l=function(e,t,r){return e[t]=r}}function h(e,t,r,n){var o=t&&t.prototype instanceof b?t:b,a=Object.create(o.prototype),c=new N(n||[]);return i(a,"_invoke",{value:T(e,r,c)}),a}function p(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}n.wrap=h;var d="suspendedStart",m="suspendedYield",v="executing",g="completed",y={};function b(){}function w(){}function x(){}var k={};l(k,u,(function(){return this}));var E=Object.getPrototypeOf,_=E&&E(E(R([])));_&&_!==o&&a.call(_,u)&&(k=_);var I=x.prototype=b.prototype=Object.create(k);function S(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function L(t,r){function n(o,i,c,u){var s=p(t[o],t,i);if("throw"!==s.type){var f=s.arg,l=f.value;return l&&"object"==e(l)&&a.call(l,"__await")?r.resolve(l.__await).then((function(e){n("next",e,c,u)}),(function(e){n("throw",e,c,u)})):r.resolve(l).then((function(e){f.value=e,c(f)}),(function(e){return n("throw",e,c,u)}))}u(s.arg)}var o;i(this,"_invoke",{value:function(e,t){function a(){return new r((function(r,o){n(e,t,r,o)}))}return o=o?o.then(a,a):a()}})}function T(e,t,n){var o=d;return function(a,i){if(o===v)throw new Error("Generator is already running");if(o===g){if("throw"===a)throw i;return{value:r,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=A(c,n);if(u){if(u===y)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===d)throw o=g,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var s=p(e,t,n);if("normal"===s.type){if(o=n.done?g:m,s.arg===y)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=g,n.method="throw",n.arg=s.arg)}}}function A(e,t){var n=t.method,o=e.iterator[n];if(o===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=r,A(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var a=p(o,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,y;var i=a.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=r),t.delegate=null,y):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,y)}function j(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function N(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function R(t){if(t||""===t){var n=t[u];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function e(){for(;++o<t.length;)if(a.call(t,o))return e.value=t[o],e.done=!1,e;return e.value=r,e.done=!0,e};return i.next=i}}throw new TypeError(e(t)+" is not iterable")}return w.prototype=x,i(I,"constructor",{value:x,configurable:!0}),i(x,"constructor",{value:w,configurable:!0}),w.displayName=l(x,f,"GeneratorFunction"),n.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===w||"GeneratorFunction"===(t.displayName||t.name))},n.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,x):(e.__proto__=x,l(e,f,"GeneratorFunction")),e.prototype=Object.create(I),e},n.awrap=function(e){return{__await:e}},S(L.prototype),l(L.prototype,s,(function(){return this})),n.AsyncIterator=L,n.async=function(e,t,r,o,a){void 0===a&&(a=Promise);var i=new L(h(e,t,r,o),a);return n.isGeneratorFunction(t)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},S(I),l(I,f,"Generator"),l(I,u,(function(){return this})),l(I,"toString",(function(){return"[object Generator]"})),n.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},n.values=R,N.prototype={constructor:N,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=r,this.done=!1,this.delegate=null,this.method="next",this.arg=r,this.tryEntries.forEach(O),!e)for(var t in this)"t"===t.charAt(0)&&a.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=r)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(n,o){return c.type="throw",c.arg=e,t.next=n,o&&(t.method="next",t.arg=r),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),s=a.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,y):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),O(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;O(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:R(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=r),y}},n}function n(e,t,r,n,o,a,i){try{var c=e[a](i),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}const o=function(){var e,r=(e=t().mark((function e(){var r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,chrome.identity.getAuthToken({interactive:!0});case 3:if(r=e.sent){e.next=6;break}throw new Error("User cancelled sign-in or failed to get token");case 6:return e.next=8,new Promise((function(e){return chrome.storage.local.set({token:r.token},(function(){return e()}))}));case 8:return e.next=10,chrome.identity.getProfileUserInfo();case 10:return e.sent,e.abrupt("return",r.token);case 14:return e.prev=14,e.t0=e.catch(0),console.error("Error signing in:",e.t0.message),e.abrupt("return",null);case 19:case"end":return e.stop()}}),e,null,[[0,14]])})),function(){var t=this,r=arguments;return new Promise((function(o,a){var i=e.apply(t,r);function c(e){n(i,o,a,c,u,"next",e)}function u(e){n(i,o,a,c,u,"throw",e)}c(void 0)}))});return function(){return r.apply(this,arguments)}}();function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function i(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */i=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},c="function"==typeof Symbol?Symbol:{},u=c.iterator||"@@iterator",s=c.asyncIterator||"@@asyncIterator",f=c.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function h(e,t,r,n){var a=t&&t.prototype instanceof b?t:b,i=Object.create(a.prototype),c=new N(n||[]);return o(i,"_invoke",{value:T(e,r,c)}),i}function p(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=h;var d="suspendedStart",m="suspendedYield",v="executing",g="completed",y={};function b(){}function w(){}function x(){}var k={};l(k,u,(function(){return this}));var E=Object.getPrototypeOf,_=E&&E(E(R([])));_&&_!==r&&n.call(_,u)&&(k=_);var I=x.prototype=b.prototype=Object.create(k);function S(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function L(e,t){function r(o,i,c,u){var s=p(e[o],e,i);if("throw"!==s.type){var f=s.arg,l=f.value;return l&&"object"==a(l)&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,c,u)}),(function(e){r("throw",e,c,u)})):t.resolve(l).then((function(e){f.value=e,c(f)}),(function(e){return r("throw",e,c,u)}))}u(s.arg)}var i;o(this,"_invoke",{value:function(e,n){function o(){return new t((function(t,o){r(e,n,t,o)}))}return i=i?i.then(o,o):o()}})}function T(t,r,n){var o=d;return function(a,i){if(o===v)throw new Error("Generator is already running");if(o===g){if("throw"===a)throw i;return{value:e,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=A(c,n);if(u){if(u===y)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===d)throw o=g,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var s=p(t,r,n);if("normal"===s.type){if(o=n.done?g:m,s.arg===y)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=g,n.method="throw",n.arg=s.arg)}}}function A(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,A(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var a=p(o,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,y;var i=a.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function j(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function N(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function R(t){if(t||""===t){var r=t[u];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(a(t)+" is not iterable")}return w.prototype=x,o(I,"constructor",{value:x,configurable:!0}),o(x,"constructor",{value:w,configurable:!0}),w.displayName=l(x,f,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===w||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,x):(e.__proto__=x,l(e,f,"GeneratorFunction")),e.prototype=Object.create(I),e},t.awrap=function(e){return{__await:e}},S(L.prototype),l(L.prototype,s,(function(){return this})),t.AsyncIterator=L,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new L(h(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},S(I),l(I,f,"Generator"),l(I,u,(function(){return this})),l(I,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=R,N.prototype={constructor:N,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(O),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return c.type="throw",c.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,y):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),O(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;O(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:R(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}function c(e,t,r,n,o,a,i){try{var c=e[a](i),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function u(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function i(e){c(a,n,o,i,u,"next",e)}function u(e){c(a,n,o,i,u,"throw",e)}i(void 0)}))}}const s=function(){var e=u(i().mark((function e(t,r,n){var a,c;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return c=function(){return c=u(i().mark((function e(){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,t){chrome.storage.local.get(["token"],function(){var r=u(i().mark((function r(n){var a,c,u,s;return i().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!chrome.runtime.lastError){r.next=4;break}t(new Error(chrome.runtime.lastError)),r.next=24;break;case 4:if((a=n.token)&&null!==a){r.next=13;break}return r.next=8,o();case 8:(c=r.sent)&&null!==c||t(new Error("Sign-in failed")),e(c),r.next=24;break;case 13:r.prev=13,u=JSON.parse(atob(a.split(".")[1])),r.next=21;break;case 17:return r.prev=17,r.t0=r.catch(13),chrome.identity.getAuthToken({interactive:!0},(function(r){chrome.runtime.lastError?t(new Error(chrome.runtime.lastError)):e(r)})),r.abrupt("return");case 21:s=1e3*u.exp,Date.now()>=s?chrome.identity.getAuthToken({interactive:!0},(function(r){chrome.runtime.lastError?t(new Error(chrome.runtime.lastError)):e(r)})):e(a);case 24:case"end":return r.stop()}}),r,null,[[13,17]])})));return function(e){return r.apply(this,arguments)}}())})));case 1:case"end":return e.stop()}}),e)}))),c.apply(this,arguments)},a=function(){return c.apply(this,arguments)},e.abrupt("return",new Promise(function(){var e=u(i().mark((function e(o,c){var u,s,f,l,h,p,d,m;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,a();case 3:if((u=e.sent)&&null!==u){e.next=6;break}throw new Error("Sign-in failed");case 6:return s=new Headers({Authorization:"Bearer ".concat(u),"Content-Type":t.type}),e.next=9,fetch("https://www.googleapis.com/upload/drive/v3/files?uploadType=media",{method:"POST",headers:s,body:t});case 9:if((f=e.sent).ok){e.next=12;break}throw new Error("Error uploading to Google Drive: ".concat(f.status));case 12:return e.next=14,f.json();case 14:if(l=e.sent,h=l.id){e.next=18;break}throw new Error("File ID is undefined");case 18:return p={name:r},e.next=21,fetch("https://www.googleapis.com/drive/v3/files/".concat(h),{method:"PATCH",headers:new Headers({Authorization:"Bearer ".concat(u),"Content-Type":"application/json; charset=UTF-8"}),body:JSON.stringify(p)});case 21:if((d=e.sent).ok){e.next=28;break}return e.next=25,d.json();case 25:throw m=e.sent,console.error("Error updating file metadata:",d.status,m.error.message),new Error("Error updating file metadata: ".concat(d.status));case 28:n({status:"ok",url:h}),chrome.tabs.create({url:"https://drive.google.com/file/d/".concat(h,"/view")}),o("https://drive.google.com/file/d/".concat(h,"/view")),e.next=38;break;case 33:e.prev=33,e.t0=e.catch(0),console.error("Error uploading to Google Drive:",e.t0.message),n({status:"ew",url:null}),c(e.t0);case 38:case"end":return e.stop()}}),e,null,[[0,33]])})));return function(t,r){return e.apply(this,arguments)}}()));case 3:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}();function f(e){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},f(e)}function l(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,c=[],u=!0,s=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(c.push(n.value),c.length!==t);u=!0);}catch(e){s=!0,o=e}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)throw o}}return c}}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return h(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return h(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function p(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */p=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var a=t&&t.prototype instanceof b?t:b,i=Object.create(a.prototype),c=new N(n||[]);return o(i,"_invoke",{value:T(e,r,c)}),i}function h(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var d="suspendedStart",m="suspendedYield",v="executing",g="completed",y={};function b(){}function w(){}function x(){}var k={};s(k,i,(function(){return this}));var E=Object.getPrototypeOf,_=E&&E(E(R([])));_&&_!==r&&n.call(_,i)&&(k=_);var I=x.prototype=b.prototype=Object.create(k);function S(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function L(e,t){function r(o,a,i,c){var u=h(e[o],e,a);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==f(l)&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,i,c)}),(function(e){r("throw",e,i,c)})):t.resolve(l).then((function(e){s.value=e,i(s)}),(function(e){return r("throw",e,i,c)}))}c(u.arg)}var a;o(this,"_invoke",{value:function(e,n){function o(){return new t((function(t,o){r(e,n,t,o)}))}return a=a?a.then(o,o):o()}})}function T(t,r,n){var o=d;return function(a,i){if(o===v)throw new Error("Generator is already running");if(o===g){if("throw"===a)throw i;return{value:e,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=A(c,n);if(u){if(u===y)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===d)throw o=g,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var s=h(t,r,n);if("normal"===s.type){if(o=n.done?g:m,s.arg===y)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=g,n.method="throw",n.arg=s.arg)}}}function A(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,A(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var a=h(o,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,y;var i=a.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function j(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function N(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function R(t){if(t||""===t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,a=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw new TypeError(f(t)+" is not iterable")}return w.prototype=x,o(I,"constructor",{value:x,configurable:!0}),o(x,"constructor",{value:w,configurable:!0}),w.displayName=s(x,u,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===w||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,x):(e.__proto__=x,s(e,u,"GeneratorFunction")),e.prototype=Object.create(I),e},t.awrap=function(e){return{__await:e}},S(L.prototype),s(L.prototype,c,(function(){return this})),t.AsyncIterator=L,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new L(l(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},S(I),s(I,u,"Generator"),s(I,i,(function(){return this})),s(I,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=R,N.prototype={constructor:N,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(O),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return c.type="throw",c.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,y):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),O(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;O(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:R(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}function d(e,t,r,n,o,a,i){try{var c=e[a](i),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function m(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function i(e){d(a,n,o,i,c,"next",e)}function c(e){d(a,n,o,i,c,"throw",e)}i(void 0)}))}}var v=function(){var e=m(p().mark((function e(t,r){var n,o,a,i=arguments;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=i.length>2&&void 0!==i[2]?i[2]:null,o=i.length>3&&void 0!==i[3]?i[3]:null,null!==t&&null!==r){e.next=4;break}return e.abrupt("return",Promise.reject("Tab ID or message is null"));case 4:return e.prev=4,e.next=7,new Promise((function(e,r){chrome.tabs.get(t,(function(t){chrome.runtime.lastError?r(chrome.runtime.lastError.message):e(t)}))}));case 7:if((a=e.sent)&&a.url&&!a.url.startsWith("chrome://")&&!a.url.startsWith("chromewebstore.google.com")&&!a.url.startsWith("chrome.google.com/webstore")&&""!==a.url&&"about:blank"!==a.url){e.next=10;break}return e.abrupt("return",Promise.reject("Invalid tab URL"));case 10:return e.abrupt("return",new Promise((function(e,t){chrome.tabs.sendMessage(a.id,r,(function(r){chrome.runtime.lastError?t(chrome.runtime.lastError.message):n?n(r):e(r)}))})));case 13:return e.prev=13,e.t0=e.catch(4),console.error("Error sending message to tab:",e.t0),o&&"function"==typeof o&&o(),e.abrupt("return",Promise.reject(e.t0));case 18:case"end":return e.stop()}}),e,null,[[4,13]])})));return function(t,r){return e.apply(this,arguments)}}(),g=function(){var e=m(p().mark((function e(t){var r;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!==t){e.next=2;break}return e.abrupt("return");case 2:return e.prev=2,e.next=5,new Promise((function(e){chrome.tabs.get(t,(function(t){e(t)}))}));case 5:(r=e.sent)&&r.id&&chrome.windows.update(r.windowId,{focused:!0}).then((function(){chrome.tabs.update(r.id,{active:!0})})),e.next=11;break;case 9:e.prev=9,e.t0=e.catch(2);case 11:case"end":return e.stop()}}),e,null,[[2,9]])})));return function(t){return e.apply(this,arguments)}}(),y=function(){var e=m(p().mark((function e(t){var r;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!==t){e.next=2;break}return e.abrupt("return");case 2:return e.prev=2,e.next=5,new Promise((function(e){chrome.tabs.get(t,(function(t){e(t)}))}));case 5:(r=e.sent)&&r.id&&chrome.tabs.remove(r.id),e.next=11;break;case 9:e.prev=9,e.t0=e.catch(2);case 11:case"end":return e.stop()}}),e,null,[[2,9]])})));return function(t){return e.apply(this,arguments)}}(),b=function(){var e=m(p().mark((function e(){var t,r,n,o;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t={active:!0,lastFocusedWindow:!0},e.next=3,chrome.tabs.query(t);case 3:return r=e.sent,n=l(r,1),o=n[0],e.abrupt("return",o);case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),w=function(){var e=m(p().mark((function e(t){var r,n,o,a=arguments;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=a.length>1&&void 0!==a[1]&&a[1],n=a.length>2&&void 0!==a[2]&&a[2],t){e.next=4;break}return e.abrupt("return");case 4:r&&((o=chrome.i18n.getMessage("@@ui_locale")).includes("en")||(t="http://translate.google.com/translate?js=n&sl=auto&tl="+o+"&u="+t)),chrome.tabs.create({url:t,active:n});case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),x=r(9483),k=r.n(x);function E(e){return E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},E(e)}function _(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=S(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,c=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){c=!0,a=e},f:function(){try{i||null==r.return||r.return()}finally{if(c)throw a}}}}function I(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,c=[],u=!0,s=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(c.push(n.value),c.length!==t);u=!0);}catch(e){s=!0,o=e}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)throw o}}return c}}(e,t)||S(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(e,t){if(e){if("string"==typeof e)return L(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?L(e,t):void 0}}function L(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function T(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */T=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var a=t&&t.prototype instanceof g?t:g,i=Object.create(a.prototype),c=new N(n||[]);return o(i,"_invoke",{value:L(e,r,c)}),i}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",m="completed",v={};function g(){}function y(){}function b(){}var w={};s(w,i,(function(){return this}));var x=Object.getPrototypeOf,k=x&&x(x(R([])));k&&k!==r&&n.call(k,i)&&(w=k);var _=b.prototype=g.prototype=Object.create(w);function I(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function r(o,a,i,c){var u=l(e[o],e,a);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==E(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,i,c)}),(function(e){r("throw",e,i,c)})):t.resolve(f).then((function(e){s.value=e,i(s)}),(function(e){return r("throw",e,i,c)}))}c(u.arg)}var a;o(this,"_invoke",{value:function(e,n){function o(){return new t((function(t,o){r(e,n,t,o)}))}return a=a?a.then(o,o):o()}})}function L(t,r,n){var o=h;return function(a,i){if(o===d)throw new Error("Generator is already running");if(o===m){if("throw"===a)throw i;return{value:e,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=A(c,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var s=l(t,r,n);if("normal"===s.type){if(o=n.done?m:p,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=m,n.method="throw",n.arg=s.arg)}}}function A(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,A(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var a=l(o,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var i=a.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,v):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function j(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function N(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function R(t){if(t||""===t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,a=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw new TypeError(E(t)+" is not iterable")}return y.prototype=b,o(_,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:y,configurable:!0}),y.displayName=s(b,u,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,s(e,u,"GeneratorFunction")),e.prototype=Object.create(_),e},t.awrap=function(e){return{__await:e}},I(S.prototype),s(S.prototype,c,(function(){return this})),t.AsyncIterator=S,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new S(f(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},I(_),s(_,u,"Generator"),s(_,i,(function(){return this})),s(_,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=R,N.prototype={constructor:N,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(O),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return c.type="throw",c.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),O(r),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;O(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:R(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),v}},t}function A(e,t,r,n,o,a,i){try{var c=e[a](i),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function j(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function i(e){A(a,n,o,i,c,"next",e)}function c(e){A(a,n,o,i,c,"throw",e)}i(void 0)}))}}k().config({driver:k().INDEXEDDB,name:"screenity",version:1});var O=k().createInstance({name:"chunks"}),N=k().createInstance({name:"localDirectory"}),R=function(){var e=j(T().mark((function e(){var t,r,n,o;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,chrome.storage.local.get(["recordingTab"]);case 2:return t=e.sent,r=t.recordingTab,e.next=6,chrome.storage.local.get(["offscreen"]);case 6:n=e.sent,o=n.offscreen,(null!=r||o)&&(chrome.storage.local.set({recording:!0}),P());case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),D=function(){var e=j(T().mark((function e(){var t,r;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"editor.html",navigator.userAgent.includes("Chrome/")&&parseInt(navigator.userAgent.match(/Chrome\/([0-9]+)/)[1])<=109&&"editorfallback.html",e.next=4,chrome.storage.local.get(["activeTab"]);case 4:t=e.sent,r=t.activeTab,chrome.tabs.get(r,(function(e){e&&chrome.windows.update(e.windowId,{focused:!0},j(T().mark((function e(){var t;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return chrome.tabs.update(r,{active:!0,selected:!0,highlighted:!0}),g(r),v(r,{type:"ready-to-record"}),e.next=5,chrome.storage.local.get(["countdown"]);case 5:t=e.sent,t.countdown?setTimeout((function(){R()}),3500):setTimeout((function(){R()}),500);case 8:case"end":return e.stop()}}),e)}))))}));case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),C=function(){var e=j(T().mark((function e(){var t,r;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,chrome.storage.local.get(["activeTab"]);case 2:t=e.sent,r=t.activeTab,g(r).then(j(T().mark((function e(){var t;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return v(r,{type:"ready-to-record"}),e.next=3,chrome.storage.local.get(["countdown"]);case 3:t=e.sent,t.countdown?setTimeout((function(){R()}),3e3):P();case 6:case"end":return e.stop()}}),e)}))));case 5:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),P=function(){var e=j(T().mark((function e(){var t,r,n,o,a,i,c;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return chrome.storage.local.set({recordingStartTime:Date.now(),restarting:!1,recording:!0}),e.next=3,chrome.storage.local.get(["customRegion"]);case 3:return t=e.sent,r=t.customRegion,X(r?{type:"start-recording-tab",region:!0}:{type:"start-recording-tab"}),chrome.action.setIcon({path:"assets/recording-logo.png"}),e.next=9,chrome.storage.local.get(["alarm"]);case 9:return n=e.sent,o=n.alarm,e.next=13,chrome.storage.local.get(["alarmTime"]);case 13:a=e.sent,i=a.alarmTime,o&&(c=parseFloat(i),chrome.alarms.create("recording-alarm",{delayInMinutes:c/60}));case 16:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();chrome.commands.onCommand.addListener(function(){var e=j(T().mark((function e(t){var r,n,o;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("start-recording"!==t){e.next=7;break}return e.next=3,b();case 3:r=e.sent,!1===navigator.onLine&&!r.url.includes("/playground.html")&&!r.url.includes("/setup.html")||r.url.startsWith("chrome://")||r.url.startsWith("chrome-extension://")&&!r.url.includes("/playground.html")&&!r.url.includes("/setup.html")||r.url.includes("stackoverflow.com/")||r.url.includes("chrome.google.com/webstore")||r.url.includes("chromewebstore.google.com")?chrome.tabs.create({url:"playground.html",active:!0}).then((function(e){chrome.storage.local.set({activeTab:e.id}),chrome.tabs.onUpdated.addListener((function e(t,r,n){t===n.id&&"complete"===r.status&&(setTimeout((function(){v(n.id,{type:"start-stream"})}),500),chrome.tabs.onUpdated.removeListener(e))}))})):v(r.id,{type:"start-stream"}),e.next=19;break;case 7:if("cancel-recording"!==t){e.next=14;break}return e.next=10,b();case 10:n=e.sent,v(n.id,{type:"cancel-recording"}),e.next=19;break;case 14:if("pause-recording"!=t){e.next=19;break}return e.next=17,b();case 17:o=e.sent,v(o.id,{type:"pause-recording"});case 19:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}());var M=function(){var e=j(T().mark((function e(t){var r,n,o,a,i,c;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("recording-alarm"!==t.name){e.next=22;break}return e.next=3,chrome.storage.local.get(["recording"]);case 3:if(r=e.sent,!r.recording){e.next=21;break}return W(),e.next=9,chrome.storage.local.get(["recordingTab"]);case 9:return n=e.sent,o=n.recordingTab,v(o,{type:"stop-recording-tab"}),e.next=14,chrome.storage.local.get(["activeTab"]);case 14:return a=e.sent,i=a.activeTab,v(i,{type:"stop-recording-tab"}),e.next=19,b();case 19:c=e.sent,v(c.id,{type:"stop-recording-tab"});case 21:chrome.alarms.clear("recording-alarm");case 22:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),F=function(e){M(e)},U=function(){chrome.alarms.onAlarm.hasListener(F)||chrome.alarms.onAlarm.addListener(F)};chrome.permissions&&chrome.permissions.contains({permissions:["alarms"]},(function(e){e&&U()}));var B=function(){var e=j(T().mark((function e(t){var r,n,o,a,i,c,u,s,f,l,h,p,d,m,g,y,b,w,x,k;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,chrome.storage.local.get(["recordingStartTime"]);case 2:return r=e.sent,n=r.recordingStartTime,e.next=6,chrome.tabs.get(t.tabId);case 6:return o=e.sent,e.next=9,chrome.storage.local.get(["recording"]);case 9:return a=e.sent,i=a.recording,e.next=13,chrome.storage.local.get(["restarting"]);case 13:if(c=e.sent,u=c.restarting,!i){e.next=32;break}return e.next=18,chrome.storage.local.get(["tabRecordedID"]);case 18:return s=e.sent,(f=s.tabRecordedID)&&f!=t.tabId?v(t.tabId,{type:"hide-popup-recording"}):o.url.includes("backup.html")&&o.url.includes("chrome-extension://")||chrome.storage.local.set({activeTab:t.tabId}),e.next=23,chrome.storage.local.get(["region"]);case 23:return l=e.sent,h=l.region,e.next=27,chrome.storage.local.get(["customRegion"]);case 27:p=e.sent,d=p.customRegion,h||d||v(t.tabId,{type:"recording-check"}),e.next=33;break;case 32:i||u||v(t.tabId,{type:"recording-ended"});case 33:if(!n){e.next=51;break}return e.next=36,chrome.storage.local.get(["alarm"]);case 36:if(m=e.sent,!m.alarm){e.next=49;break}return e.next=41,chrome.storage.local.get(["alarmTime"]);case 41:g=e.sent,y=g.alarmTime,b=parseFloat(y),w=Math.floor((Date.now()-n)/1e3),x=b-w,v(t.tabId,{type:"time",time:x}),e.next=51;break;case 49:k=Math.floor((Date.now()-n)/1e3),v(t.tabId,{type:"time",time:k});case 51:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();function q(e){return new Promise((function(t,r){var n=new FileReader;n.onload=function(){t(n.result)},n.onerror=function(e){r(e)},n.readAsDataURL(e)}))}chrome.windows.onFocusChanged.addListener(function(){var e=j(T().mark((function e(t){var r,n,o;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t!==chrome.windows.WINDOW_ID_NONE){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,chrome.tabs.query({active:!0,windowId:t});case 4:r=e.sent,n=I(r,1),(o=n[0])&&B({tabId:o.id});case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),chrome.tabs.onActivated.addListener(function(){var e=j(T().mark((function e(t){return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:B(t);case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),chrome.tabs.onUpdated.addListener(function(){var e=j(T().mark((function e(t,r,n){var o,a,i,c,u,s,f,l,h,p,d,m,g,y,b,w;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("complete"!==r.status){e.next=44;break}return e.next=3,chrome.storage.local.get(["recording"]);case 3:return o=e.sent,a=o.recording,e.next=7,chrome.storage.local.get(["restarting"]);case 7:return i=e.sent,c=i.restarting,e.next=11,chrome.storage.local.get(["tabRecordedID"]);case 11:return u=e.sent,s=u.tabRecordedID,a||c?a&&s&&s==t&&v(t,{type:"recording-check",force:!0}):v(t,{type:"recording-ended"}),e.next=16,chrome.storage.local.get(["recordingStartTime"]);case 16:return f=e.sent,l=f.recordingStartTime,e.next=20,chrome.tabs.get(t);case 20:if(h=e.sent,!l){e.next=39;break}return e.next=24,chrome.storage.local.get(["alarm"]);case 24:if(p=e.sent,!p.alarm){e.next=37;break}return e.next=29,chrome.storage.local.get(["alarmTime"]);case 29:d=e.sent,m=d.alarmTime,g=parseFloat(m),y=Math.floor((Date.now()-l)/1e3),v(t,{type:"time",time:g-y}),e.next=39;break;case 37:b=Math.floor((Date.now()-l)/1e3),v(t,{type:"time",time:b});case 39:return e.next=41,chrome.commands.getAll();case 41:w=e.sent,v(t,{type:"commands",commands:w}),h.url.includes(chrome.runtime.getURL("playground.html"))&&"complete"===r.status&&v(h.id,{type:"toggle-popup"});case 44:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}());var G=function(){var e=j(T().mark((function e(t){var r,n,o,a,i,c,u,s,f,l,h,p=arguments;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=p.length>1&&void 0!==p[1]&&p[1],e.next=3,chrome.storage.local.get(["sendingChunks","sandboxTab"]);case 3:if(n=e.sent,o=n.sendingChunks,a=n.sandboxTab,!o){e.next=9;break}return console.warn("Chunks are already being sent, skipping..."),e.abrupt("return");case 9:return e.next=11,chrome.storage.local.set({sendingChunks:!0});case 11:if(0!==t.length){e.next=16;break}return e.next=14,chrome.storage.local.set({sendingChunks:!1});case 14:return v(a,{type:"make-video-tab",override:r}),e.abrupt("return");case 16:t.sort((function(e,t){return e.timestamp-t.timestamp})),i=0,c=10,3,1e3,u=t.length,v(a,{type:"chunk-count",count:u,override:r}),s=function(){var e=j(T().mark((function e(t){var r,n=arguments;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.length>1&&void 0!==n[1]?n[1]:0,e.prev=1,e.next=4,v(a,{type:"new-chunk-tab",chunks:t});case 4:if(e.sent){e.next=7;break}throw new Error("No response or failed response from tab.");case 7:e.next=12;break;case 9:e.prev=9,e.t0=e.catch(1),r<3?(console.error("Sending batch failed, retrying... Attempt ".concat(r+1),e.t0),setTimeout((function(){return s(t,r+1)}),1e3)):console.error("Maximum retry attempts reached for this batch.",e.t0);case 12:case"end":return e.stop()}}),e,null,[[1,9]])})));return function(t){return e.apply(this,arguments)}}();case 24:if(!(i<u)){e.next=36;break}return f=Math.min(i+c,u),e.next=28,Promise.all(t.slice(i,f).map(function(){var e=j(T().mark((function e(t,r){var n;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,q(t.chunk);case 3:return n=e.sent,e.abrupt("return",{chunk:n,index:i+r});case 7:return e.prev=7,e.t0=e.catch(0),console.error("Error converting chunk to Base64",e.t0),e.abrupt("return",null);case 11:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(t,r){return e.apply(this,arguments)}}()));case 28:if(l=e.sent,!((h=l.filter((function(e){return null!==e}))).length>0)){e.next=33;break}return e.next=33,s(h);case 33:i+=c,e.next=24;break;case 36:return e.next=38,chrome.storage.local.set({sendingChunks:!1});case 38:v(a,{type:"make-video-tab",override:r});case 39:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),z=function(){var e=j(T().mark((function e(){var t,r,n=arguments;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=n.length>0&&void 0!==n[0]&&n[0],e.prev=1,r=[],e.next=5,O.iterate((function(e,t){r.push(e)}));case 5:G(r,t),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),chrome.runtime.reload();case 11:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(){return e.apply(this,arguments)}}(),W=function(){var e=j(T().mark((function e(){var t,r,n,o;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return chrome.storage.local.set({restarting:!1}),e.next=3,chrome.storage.local.get(["recordingStartTime"]);case 3:return t=e.sent,r=t.recordingStartTime,n=Date.now()-r,42e4,0===r&&(n=0),chrome.storage.local.set({recording:!1,recordingDuration:n,tabRecordedID:null}),chrome.storage.local.set({recordingStartTime:0}),n>42e4?chrome.tabs.create({url:"editorfallback.html",active:!0},(function(e){chrome.tabs.onUpdated.addListener((function t(r,n,o){r===e.id&&"complete"===n.status&&(chrome.tabs.onUpdated.removeListener(t),chrome.storage.local.set({sandboxTab:e.id}),z())}))})):chrome.tabs.create({url:"editor.html",active:!0},(function(e){chrome.tabs.onUpdated.addListener((function t(r,n,o){r===e.id&&"complete"===n.status&&(chrome.tabs.onUpdated.removeListener(t),chrome.storage.local.set({sandboxTab:e.id}),z())}))})),chrome.action.setIcon({path:"assets/icon-34.png"}),e.next=14,chrome.storage.local.get(["wasRegion"]);case 14:o=e.sent,o.wasRegion&&chrome.storage.local.set({wasRegion:!1,region:!0}),chrome.alarms.clear("recording-alarm"),ee();case 19:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Q=function(){var e=j(T().mark((function e(){var t,r,n;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t="editor.html",e.next=3,chrome.storage.local.get(["sandboxTab"]);case 3:r=e.sent,n=r.sandboxTab,chrome.tabs.create({url:t,active:!0},(function(e){chrome.tabs.onUpdated.addListener((function t(r,o,a){r===e.id&&"complete"===o.status&&(chrome.tabs.onUpdated.removeListener(t),y(n),chrome.storage.local.set({sandboxTab:e.id}),z(!0))}))}));case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();chrome.runtime.onStartup.addListener((function(){console.log("Starting...")})),chrome.action.onClicked.addListener(function(){var e=j(T().mark((function e(t){var r,n,o,a,i;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,chrome.storage.local.get(["recording"]);case 2:if(r=e.sent,!r.recording){e.next=14;break}return W(),X({type:"stop-recording-tab"}),e.next=9,chrome.storage.local.get(["activeTab"]);case 9:n=e.sent,o=n.activeTab,chrome.tabs.get(o,(function(e){e?v(o,{type:"stop-recording-tab"}):(v(t.id,{type:"stop-recording-tab"}),chrome.storage.local.set({activeTab:t.id}))})),e.next=15;break;case 14:!1===navigator.onLine&&!t.url.includes("/playground.html")&&!t.url.includes("/setup.html")||t.url.startsWith("chrome://")||t.url.startsWith("chrome-extension://")&&!t.url.includes("/playground.html")&&!t.url.includes("/setup.html")||t.url.includes("stackoverflow.com/")||t.url.includes("chrome.google.com/webstore")||t.url.includes("chromewebstore.google.com")?chrome.tabs.create({url:"playground.html",active:!0}).then((function(e){chrome.storage.local.set({activeTab:e.id})})):(v(t.id,{type:"toggle-popup"}),chrome.storage.local.set({activeTab:t.id}));case 15:return e.next=17,chrome.storage.local.get(["firstTime"]);case 17:if(a=e.sent,!a.firstTime||!t.url.includes(chrome.runtime.getURL("setup.html"))){e.next=25;break}return chrome.storage.local.set({firstTime:!1}),e.next=23,b();case 23:i=e.sent,v(i.id,{type:"setup-complete"});case 25:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}());var V=function(){var e=j(T().mark((function e(){var t;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b();case 2:t=e.sent,v(t.id,{type:"ready-to-record"});case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Y=function(){var e=j(T().mark((function e(){var t,r,n,o,a,i,c;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,chrome.storage.local.get(["micActive","defaultAudioInput","defaultAudioOutput","defaultVideoInput","systemAudio","recordingType"]);case 2:return t=e.sent,r=t.micActive,n=t.defaultAudioInput,o=t.defaultAudioOutput,a=t.defaultVideoInput,i=t.systemAudio,c=t.recordingType,e.abrupt("return",{micActive:r,defaultAudioInput:n,defaultAudioOutput:o,defaultVideoInput:a,systemAudio:i,recordingType:c});case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),K=function(){var e=j(T().mark((function e(){var t,r;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return chrome.storage.local.set({restarting:!0}),e.next=3,chrome.storage.local.get(["region"]);case 3:return t=e.sent,t.region,e.next=7,chrome.storage.local.get(["wasRegion"]);case 7:r=e.sent,r.wasRegion&&chrome.storage.local.set({wasRegion:!1,region:!0}),chrome.action.setIcon({path:"assets/icon-34.png"});case 11:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),H=function(){var e=j(T().mark((function e(){return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:chrome.storage.local.set({restarting:!0}),"editor.html",navigator.userAgent.includes("Chrome/")&&parseInt(navigator.userAgent.match(/Chrome\/([0-9]+)/)[1])<=109&&"editorfallback.html",C();case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),X=function(){var e=j(T().mark((function e(t){return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:chrome.storage.local.get(["recordingTab","offscreen"],(function(e){e.offscreen?chrome.runtime.sendMessage(t):v(e.recordingTab,t)}));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),J=function(){var e=j(T().mark((function e(t,r){var n,o,a;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,chrome.storage.local.get(["backupTab"]);case 2:n=e.sent,o=n.backupTab,a=chrome.runtime.getURL("backup.html"),o?chrome.tabs.get(o,(function(e){e?v(e.id,{type:"init-backup",request:t,tabId:r}):chrome.tabs.create({url:a,active:!0,pinned:!0,index:0},(function(e){chrome.storage.local.set({backupTab:e.id}),chrome.tabs.onUpdated.addListener((function n(o,a,i){o===e.id&&"complete"===a.status&&(v(e.id,{type:"init-backup",request:t,tabId:r}),chrome.tabs.onUpdated.removeListener(n))}))}))})):chrome.tabs.create({url:a,active:!0,pinned:!0,index:0},(function(e){chrome.storage.local.set({backupTab:e.id}),chrome.tabs.onUpdated.addListener((function n(o,a,i){o===e.id&&"complete"===a.status&&(v(e.id,{type:"init-backup",request:t,tabId:r}),chrome.tabs.onUpdated.removeListener(n))}))}));case 6:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),Z=function(){var e=j(T().mark((function e(t){var r,n,o,a,i,c,u,s,f,l,h,p,d,m=arguments;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=m.length>1&&void 0!==m[1]?m[1]:null,e.next=3,chrome.storage.local.get(["backup"]);case 3:return n=e.sent,o=n.backup,e.next=7,b();case 7:if(a=e.sent,null===r){e.next=12;break}return e.next=11,chrome.tabs.get(r);case 11:a=e.sent;case 12:return chrome.storage.local.set({activeTab:a.id,tabRecordedID:null,memoryError:!1}),a.url.includes(chrome.runtime.getURL("playground.html"))?chrome.storage.local.set({tabPreferred:!0}):chrome.storage.local.set({tabPreferred:!1}),e.prev=14,e.next=17,chrome.runtime.getContexts({});case 17:if(i=e.sent,!i.find((function(e){return"OFFSCREEN_DOCUMENT"===e.contextType}))){e.next=22;break}return e.next=22,chrome.offscreen.closeDocument();case 22:e.next=26;break;case 24:e.prev=24,e.t0=e.catch(14);case 26:if(!t.region){e.next=56;break}if(null!==r&&chrome.tabs.update(r,{active:!0}),chrome.storage.local.set({recordingTab:a.id,offscreen:!1,region:!0}),!t.customRegion){e.next=33;break}X({type:"loaded",request:t,backup:o,region:!0}),e.next=54;break;case 33:throw e.prev=33,new Error("Exit offscreen recording");case 37:if(c=e.sent,!c.find((function(e){return"OFFSCREEN_DOCUMENT"===e.contextType}))){e.next=42;break}return e.next=42,chrome.offscreen.closeDocument();case 42:return e.next=44,chrome.offscreen.createDocument({url:"recorderoffscreen.html",reasons:["USER_MEDIA","AUDIO_PLAYBACK","DISPLAY_MEDIA"],justification:"Recording from getDisplayMedia API and tabCapture API"});case 44:return e.next=46,chrome.tabCapture.getMediaStreamId({targetTabId:a.id});case 46:u=e.sent,chrome.storage.local.set({recordingTab:null,offscreen:!0,region:!1,wasRegion:!0}),X({type:"loaded",request:t,isTab:!0,tabID:u}),e.next=54;break;case 51:e.prev=51,e.t1=e.catch(33),chrome.tabs.create({url:"recorder.html",pinned:!0,index:0,active:!!a.url.includes(chrome.runtime.getURL("playground.html"))}).then((function(e){chrome.storage.local.set({recordingTab:e.id,offscreen:!1,region:!1,wasRegion:!0,tabRecordedID:a.id}),chrome.tabs.onUpdated.addListener((function r(n,i,c){n===e.id&&"complete"===i.status&&(chrome.tabs.onUpdated.removeListener(r),X({type:"loaded",request:t,tabID:a.id,backup:o,isTab:!0}))}))}));case 54:e.next=86;break;case 56:if(e.prev=56,t.offscreenRecording&&!t.camera){e.next=59;break}throw new Error("Exit offscreen recording");case 59:return null!==r&&chrome.tabs.update(r,{active:!0}),e.next=62,chrome.storage.local.get(["qualityValue"]);case 62:return s=e.sent,f=s.qualityValue,e.next=66,chrome.storage.local.get(["fpsValue"]);case 66:return l=e.sent,h=l.fpsValue,e.next=70,chrome.runtime.getContexts({});case 70:if(p=e.sent,!p.find((function(e){return"OFFSCREEN_DOCUMENT"===e.contextType}))){e.next=75;break}return e.next=75,chrome.offscreen.closeDocument();case 75:return e.next=77,chrome.offscreen.createDocument({url:"recorderoffscreen.html",reasons:["USER_MEDIA","AUDIO_PLAYBACK","DISPLAY_MEDIA"],justification:"Recording from getDisplayMedia API"});case 77:chrome.storage.local.set({recordingTab:null,offscreen:!0,region:!1,wasRegion:!1}),X({type:"loaded",request:t,isTab:!1,quality:f,fps:h,backup:o}),e.next=86;break;case 81:e.prev=81,e.t2=e.catch(56),d=!0,t.camera&&(d=!1),chrome.tabs.create({url:"recorder.html",pinned:!0,index:0,active:d}).then((function(e){chrome.storage.local.set({recordingTab:e.id,offscreen:!1,region:!1,wasRegion:!1}),chrome.tabs.onUpdated.addListener((function r(n,a,i){n===e.id&&"complete"===a.status&&(chrome.tabs.onUpdated.removeListener(r),X({type:"loaded",request:t,backup:o}))}))}));case 86:case"end":return e.stop()}}),e,null,[[14,24],[33,51],[56,81]])})));return function(t){return e.apply(this,arguments)}}(),$=function(){var e=j(T().mark((function e(){var t,r;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,chrome.storage.local.get(["sandboxTab"]);case 2:t=e.sent,r=t.sandboxTab,v(r,{type:"saved-to-drive"});case 5:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),ee=function(){var e=j(T().mark((function e(){var t;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,chrome.runtime.getContexts({});case 3:if(t=e.sent,!t.find((function(e){return"OFFSCREEN_DOCUMENT"===e.contextType}))){e.next=8;break}return e.next=8,chrome.offscreen.closeDocument();case 8:e.next=12;break;case 10:e.prev=10,e.t0=e.catch(0);case 12:case"end":return e.stop()}}),e,null,[[0,10]])})));return function(){return e.apply(this,arguments)}}(),te=function(){var e=j(T().mark((function e(){var t,r,n,o,a,i,c,u,s,f,l;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=chrome.runtime.getManifest().content_scripts,r=t.map((function(e){return chrome.tabs.query({url:e.matches})})),e.next=4,Promise.all(r);case 4:for(n=e.sent,o=[],a=0;a<n.length;a++){i=n[a],c=t[a],u=_(i);try{for(u.s();!(s=u.n()).done;)f=s.value,l=chrome.scripting.executeScript({target:{tabId:f.id},files:c.js},(function(){return chrome.runtime.lastError})),o.push(l)}catch(e){u.e(e)}finally{u.f()}}return e.next=9,Promise.all(o);case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();chrome.runtime.onInstalled.addListener(function(){var e=j(T().mark((function e(t){var r,n,o,a;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"install"===t.reason?(chrome.storage.local.clear(),(r=chrome.i18n.getMessage("@@ui_locale")).includes("en")?chrome.runtime.setUninstallURL("https://app.mytechpassport.com/"):chrome.runtime.setUninstallURL("http://translate.google.com/translate?js=n&sl=auto&tl="+r+"&u=https://tally.so/r/w8Zro5?version="+chrome.runtime.getManifest().version),chrome.storage.local.set({firstTime:!0}),chrome.tabs.create({url:"setup.html"})):"update"===t.reason&&("2.8.6"===t.previousVersion?(chrome.storage.local.clear(),chrome.storage.local.set({updatingFromOld:!0})):chrome.storage.local.set({updatingFromOld:!1}),(n=chrome.i18n.getMessage("@@ui_locale")).includes("en")?chrome.runtime.setUninstallURL("https://tally.so/r/3Ex6kX?version="+chrome.runtime.getManifest().version):chrome.runtime.setUninstallURL("http://translate.google.com/translate?js=n&sl=auto&tl="+n+"&u=https://tally.so/r/3Ex6kX?version="+chrome.runtime.getManifest().version)),navigator.userAgent.includes("Chrome/")&&parseInt(navigator.userAgent.match(/Chrome\/([0-9]+)/)[1])<=109&&chrome.storage.local.set({backup:!1}),chrome.storage.local.set({systemAudio:!0}),e.next=5,chrome.storage.local.get(["backupTab"]);case 5:o=e.sent,(a=o.backupTab)&&y(a),te();case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),chrome.tabs.onRemoved.addListener(function(){var e=j(T().mark((function e(t,r){var n,o,a,i,c,u,s,f,l;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,chrome.storage.local.get(["region"]);case 2:if(n=e.sent,!n.region){e.next=6;break}return e.abrupt("return");case 6:return e.next=8,chrome.storage.local.get(["recordingTab"]);case 8:return o=e.sent,a=o.recordingTab,e.next=12,chrome.storage.local.get(["recording"]);case 12:return i=e.sent,c=i.recording,e.next=16,chrome.storage.local.get(["restarting"]);case 16:if(u=e.sent,s=u.restarting,t!==a||s){e.next=26;break}return chrome.storage.local.set({recordingTab:null}),e.next=22,chrome.storage.local.get(["activeTab"]);case 22:f=e.sent,l=f.activeTab;try{c&&g(l),v(l,{type:"stop-recording-tab"},null,(function(){v(t,{type:"stop-recording-tab"}),chrome.storage.local.set({activeTab:t})}))}catch(e){v(t,{type:"stop-recording-tab"}),chrome.storage.local.set({activeTab:t})}chrome.action.setIcon({path:"assets/icon-34.png"});case 26:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}());var re=function(){var e=j(T().mark((function e(){return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:X({type:"dismiss-recording"}),chrome.action.setIcon({path:"assets/icon-34.png"}),ee(),chrome.storage.local.set({recordingTab:null,sandboxTab:null,recording:!1}),chrome.runtime.sendMessage({type:"discard-backup"});case 5:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),ne=function(){var e=j(T().mark((function e(){var t,r,n,o,a;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,chrome.storage.local.get(["recordingTab"]);case 2:return t=e.sent,r=t.recordingTab,e.next=6,chrome.storage.local.get(["offscreen"]);case 6:if(n=e.sent,o=n.offscreen,!r||o){e.next=12;break}try{chrome.tabs.get(r,(function(e){e||re()}))}catch(e){re()}e.next=18;break;case 12:if(!o){e.next=18;break}return e.next=15,chrome.runtime.getContexts({});case 15:a=e.sent,a.find((function(e){return"OFFSCREEN_DOCUMENT"===e.contextType}))||re();case 18:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),oe=function(){var e=j(T().mark((function e(){return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:C();case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),ae=function(){var e=j(T().mark((function e(t,r){return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:chrome.tabs.create({url:"download.html",active:!1},(function(e){chrome.tabs.onUpdated.addListener((function n(o,a,i){o===e.id&&"complete"===a.status&&(chrome.tabs.onUpdated.removeListener(n),v(e.id,{type:"download-video",base64:t,title:r}))}))}));case 1:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),ie=function(){var e=j(T().mark((function e(){return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:chrome.tabs.create({url:"download.html",active:!1},(function(e){chrome.tabs.onUpdated.addListener((function t(r,n,o){r===e.id&&"complete"===n.status&&(chrome.tabs.onUpdated.removeListener(t),v(e.id,{type:"download-indexed-db"}))}))}));case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),ce=function(){var e=j(T().mark((function e(){var t,r;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t="editorfallback.html",navigator.userAgent.includes("Chrome/")&&parseInt(navigator.userAgent.match(/Chrome\/([0-9]+)/)[1])<=109&&(t="editorfallback.html"),r=[],e.next=5,O.iterate((function(e,t){r.push(e)}));case 5:if(0!==r.length){e.next=7;break}return e.abrupt("return");case 7:chrome.tabs.create({url:t,active:!0},function(){var e=j(T().mark((function e(t){return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return chrome.storage.local.set({sandboxTab:t.id}),e.next=3,new Promise((function(e){chrome.tabs.onUpdated.addListener((function(e,r){"complete"===r.status&&e===t.id&&(v(t.id,{type:"restore-recording"}),z())}))}));case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}());case 8:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),ue=function(){var e=j(T().mark((function e(t){var r;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=[],e.next=3,O.iterate((function(e,t){r.push(e)}));case 3:if(0!==r.length){e.next=6;break}return t({restore:!1,chunks:[]}),e.abrupt("return");case 6:t({restore:!0});case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),se=function(e){var t=e.match(/^data:(.*?);base64,/);if(null!==t){for(var r=t[1],n=atob(e.slice(t[0].length)),o=new Uint8Array(n.length),a=0;a<n.length;a++)o[a]=n.charCodeAt(a);return new Blob([o],{type:r})}for(var i=atob(e),c=new Uint8Array(i.length),u=0;u<i.length;u++)c[u]=i.charCodeAt(u);return new Blob([c],{type:"video/webm"})},fe=function(){var e=j(T().mark((function e(t,r){var n,o,a,i,c,u,f,l,h,p,d=arguments;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(d.length>2&&void 0!==d[2]&&d[2]){e.next=7;break}n=se(r.base64),o=r.title+".mp4",s(n,o,t).then((function(){$()})),e.next=25;break;case 7:return a=[],e.next=10,O.iterate((function(e,t){a.push(e)}));case 10:i=[],c=0,u=0,f=a;case 13:if(!(u<f.length)){e.next=22;break}if(!((l=f[u]).timestamp<c)){e.next=17;break}return e.abrupt("continue",19);case 17:c=l.timestamp,i.push(l.chunk);case 19:u++,e.next=13;break;case 22:h=new Blob(i,{type:"video/webm"}),p=r.title+".webm",s(h,p,t).then((function(){$()}));case 25:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),le=function(){var e=j(T().mark((function e(t){var r,n,o,a,i;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,chrome.storage.local.get(["backup"]);case 2:return r=e.sent,n=r.backup,e.next=6,chrome.storage.local.get(["backupSetup"]);case 6:if(o=e.sent,a=o.backupSetup,chrome.storage.local.set({sendingChunks:!1}),!n){e.next=17;break}return a||N.clear(),e.next=13,b();case 13:i=e.sent,J(t,i.id),e.next=18;break;case 17:Z(t);case 18:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),he=function(){var e=j(T().mark((function e(t){var r,n;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,chrome.storage.local.get(["backupTab"]);case 2:r=e.sent,(n=r.backupTab)?v(n,{type:"write-file",index:t.index},null,(function(){X({type:"stop-recording-tab"})})):X({type:"stop-recording-tab"});case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),pe=function(){var e=j(T().mark((function e(){var t,r;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,chrome.storage.local.get(["backupTab"]);case 2:t=e.sent,(r=t.backupTab)&&v(r,{type:"close-writable"}),W();case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),de=function(){var e=j(T().mark((function e(t){var r,n;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,chrome.storage.local.get(["sandboxTab"]);case 2:r=e.sent,n=r.sandboxTab,v(n,{type:"new-chunk-tab",chunk:t.chunk,index:t.index}),sendResponse({status:"ok"});case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),me=function(){var e=j(T().mark((function e(){var t;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Y();case 2:t=e.sent,X({type:"streaming-data",data:JSON.stringify(t)});case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),ve=function(){var e=j(T().mark((function e(){var t,r;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return chrome.action.setIcon({path:"assets/icon-34.png"}),e.next=3,chrome.storage.local.get(["activeTab"]);case 3:t=e.sent,r=t.activeTab,v(r,{type:"stop-pending"}),g(r),ee();case 8:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),ge=function(){var e=j(T().mark((function e(t){return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.memoryError&&chrome.storage.local.set({recording:!1,restarting:!1,tabRecordedID:null,memoryError:!0}),X({type:"stop-recording-tab"});case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),ye=function(){var e=j(T().mark((function e(){return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),be=function(){var e=j(T().mark((function e(){return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:chrome.runtime.sendMessage({type:"discard-backup"}),re();case 2:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),we=function(){var e=j(T().mark((function e(t){return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:chrome.storage.local.get(["region"],(function(e){e.region&&X({type:"set-mic-active-tab",active:t.active,defaultAudioInput:t.defaultAudioInput})}));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),xe=function(){var e=j(T().mark((function e(t){var r,n,o,a,i,c;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,chrome.storage.local.get(["activeTab"]);case 2:return r=e.sent,n=r.activeTab,X({type:"recording-error"}).then((function(){v(n,{type:"stop-pending"}),g(n),"stream-error"===t.error?v(n,{type:"stream-error"}):"backup-error"===t.error&&v(n,{type:"backup-error"})})),e.next=7,chrome.storage.local.get(["recordingTab"]);case 7:return o=e.sent,a=o.recordingTab,e.next=11,chrome.storage.local.get(["region"]);case 11:i=e.sent,c=i.region,a&&!c&&y(a),chrome.storage.local.set({recordingTab:null}),ee();case 16:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),ke=function(){var e=j(T().mark((function e(t){var r;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b();case 2:(r=e.sent)&&v(r.id,{type:"on-get-permissions",data:t});case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Ee=function(){var e=j(T().mark((function e(){var t,r;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,chrome.storage.local.get(["recordingTab"]);case 2:t=e.sent,(r=t.recordingTab)&&chrome.tabs.get(r,(function(e){e&&e.url.includes("chrome-extension")&&e.url.includes("recorder.html")&&y(r)}));case 5:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),_e=function(){var e=j(T().mark((function e(t){var r,n;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return chrome.storage.local.set({surface:t.surface}),e.next=3,chrome.storage.local.get(["activeTab"]);case 3:r=e.sent,n=r.activeTab,v(n,{type:"set-surface",surface:t.surface});case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Ie=function(){var e=j(T().mark((function e(){var t,r,n,o=arguments;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=o.length>0&&void 0!==o[0]&&o[0],e.next=3,chrome.storage.local.get(["activeTab"]);case 3:r=e.sent,n=r.activeTab,v(n,t?{type:"pip-started"}:{type:"pip-ended"});case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Se=function(){var e=j(T().mark((function e(){var t,r;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,chrome.storage.local.get(["token"]);case 2:t=e.sent,r=t.token,fetch("https://accounts.google.com/o/oauth2/revoke?token="+r),chrome.identity.removeCachedAuthToken({token:r}),chrome.storage.local.set({token:!1});case 8:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Le=function(){var e=j(T().mark((function e(t){var r,n;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return chrome.storage.local.set({recording:!1,restarting:!1,tabRecordedID:null,memoryError:!0}),X({type:"stop-recording-tab"}),e.next=4,chrome.storage.local.get(["activeTab"]);case 4:r=e.sent,n=r.activeTab,v(n,{type:"stop-pending"}),g(n);case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Te=function(){var e=j(T().mark((function e(){return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:O.clear();case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Ae=function(){var e=j(T().mark((function e(t,r){return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==t&&0!==r){e.next=2;break}return e.abrupt("return");case 2:chrome.windows.getCurrent((function(e){chrome.windows.update(e.id,{width:t,height:r})}));case 3:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}();chrome.runtime.onMessage.addListener((function(e,t,r){if("desktop-capture"===e.type)le(e);else if("backup-created"===e.type)Z(e.request,e.tabId);else if("write-file"===e.type)he(e);else if("handle-restart"===e.type)H();else if("handle-dismiss"===e.type)K();else if("reset-active-tab"===e.type)D();else if("reset-active-tab-restart"===e.type)C();else if("start-rec"===e.type)P();else if("video-ready"===e.type)pe();else if("start-recording"===e.type)P();else if("restarted"===e.type)V();else{if("new-chunk"===e.type)return de(e),!0;if("get-streaming-data"===e.type)me();else if("cancel-recording"===e.type)ve();else if("stop-recording-tab"===e.type)ge(e);else if("restart-recording-tab"===e.type)ye();else if("dismiss-recording-tab"===e.type)be();else if("pause-recording-tab"===e.type)X({type:"pause-recording-tab"});else if("resume-recording-tab"===e.type)X({type:"resume-recording-tab"});else if("set-mic-active-tab"===e.type)we(e);else if("recording-error"===e.type)xe(e);else if("on-get-permissions"===e.type)ke(e);else if("recording-complete"===e.type)Ee();else if("check-recording"===e.type)ne();else if("review-screenity"===e.type)w("https://chrome.google.com/webstore/detail/screenity-screen-recorder/kbbdabhdfibnancpjfhlkhafgdilcnji/reviews",!1,!0);else if("follow-twitter"===e.type)w("https://alyssax.substack.com/",!1,!0);else if("open-processing-info"===e.type)w("https://help.screenity.io/editing-and-exporting/dJRFpGq56JFKC7k8zEvsqb/why-is-there-a-5-minute-limit-for-editing/ddy4e4TpbnrFJ8VoRT37tQ",!0,!0);else if("upgrade-info"===e.type)w("https://help.screenity.io/getting-started/77KizPC8MHVGfpKpqdux9D/what-are-the-technical-requirements-for-using-screenity/6kdB6qru6naVD8ZLFvX3m9",!0,!0);else if("trim-info"===e.type)w("https://help.screenity.io/editing-and-exporting/dJRFpGq56JFKC7k8zEvsqb/how-to-cut-trim-or-mute-parts-of-your-video/svNbM7YHYY717MuSWXrKXH",!0,!0);else if("join-waitlist"===e.type)w("https://tally.so/r/npojNV",!0,!0);else if("chrome-update-info"===e.type)w("https://help.screenity.io/getting-started/77KizPC8MHVGfpKpqdux9D/what-are-the-technical-requirements-for-using-screenity/6kdB6qru6naVD8ZLFvX3m9",!0,!0);else if("set-surface"===e.type)_e(e);else if("pip-ended"===e.type)Ie(!1);else if("pip-started"===e.type)Ie(!0);else if("new-sandbox-page-restart"===e.type)oe();else if("sign-out-drive"===e.type)Se();else if("open-help"===e.type)w("https://help.screenity.io/",!0,!0);else if("memory-limit-help"===e.type)w("https://help.screenity.io/troubleshooting/9Jy5RGjNrBB42hqUdREQ7W/what-does-%E2%80%9Cmemory-limit-reached%E2%80%9D-mean-when-recording/8WkwHbt3puuXunYqQnyPcb",!0,!0);else if("open-home"===e.type)w("https://screenity.io/",!1,!0);else if("report-bug"===e.type)w("https://tally.so/r/3ElpXq?version="+chrome.runtime.getManifest().version,!1,!0);else if("clear-recordings"===e.type)Te();else if("force-processing"===e.type)Q();else if("focus-this-tab"===e.type)g(t.tab.id);else if("stop-recording-tab-backup"===e.type)Le(e);else if("indexed-db-download"===e.type)ie();else{if("get-platform-info"===e.type)return function(e){chrome.runtime.getPlatformInfo((function(t){e(t)}))}(r),!0;if("restore-recording"===e.type)ce();else{if("check-restore"===e.type)return ue(r),!0;if("check-capture-permissions"===e.type)return chrome.permissions.contains({permissions:["desktopCapture","alarms","offscreen"]},(function(e){e?r({status:"ok"}):chrome.permissions.request({permissions:["desktopCapture","alarms","offscreen"]},(function(e){e?(U(),r({status:"ok"})):r({status:"error"})}))})),!0;if("is-pinned"===e.type)return function(e){chrome.action.getUserSettings().then((function(t){e({pinned:t.isOnToolbar})}))}(r),!0;if("save-to-drive"===e.type)return fe(r,e,!1),!0;if("save-to-drive-fallback"===e.type)return fe(r,e,!0),!0;if("request-download"===e.type)ae(e.base64,e.title);else if("resize-window"===e.type)Ae(e.width,e.height);else{if("available-memory"===e.type)return function(e){navigator.storage.estimate().then((function(t){e({data:t})}))}(r),!0;"extension-media-permissions"===e.type?w("chrome://settings/content/siteDetails?site=chrome-extension://"+chrome.runtime.id,!1,!0):"add-alarm-listener"===e.type&&U()}}}}})),chrome.runtime.onMessage.addListener((function(e,t,r){if("capture"===e.msg)return chrome.tabs.captureVisibleTab(t.tab.windowId,{},(function(e){chrome.runtime.lastError?(console.error("Error capturing screenshot:",chrome.runtime.lastError),r({imgSrc:null})):r({imgSrc:e})})),!0}));var je=null,Oe=0,Ne=null;function Re(){Ne&&clearInterval(Ne),Ne=setInterval((function(){Oe++,chrome.tabs.query({},(function(e){e.forEach((function(e){chrome.tabs.sendMessage(e.id,{action:"updateTimer",timer:Oe})}))}))}),1e3)}function De(){Ne&&(clearInterval(Ne),Ne=null)}function Ce(){chrome.storage.local.set({recordingQA:!1,pausedQA:!1,timerQA:0,micEnabledQA:!0},(function(){}))}chrome.runtime.onStartup.addListener((function(){Ce()})),chrome.runtime.onInstalled.addListener((function(){Ce()})),chrome.runtime.onMessage.addListener((function(e,t,r){"startRecordingQA"===e.action?(je=t.tab.id,Oe=0,Re(),chrome.storage.local.set({recordingQA:!0,pausedQA:!1})):"stopRecordingQA"===e.action||"discardRecordingQA"===e.action?(De(),Oe=0,chrome.storage.local.set({recordingQA:!1,pausedQA:!1,timerQA:0}),je&&chrome.tabs.sendMessage(je,e)):"pauseRecordingQA"===e.action?(De(),chrome.storage.local.set({pausedQA:!0}),je&&chrome.tabs.sendMessage(je,e)):"resumeRecordingQA"===e.action?(Re(),chrome.storage.local.set({pausedQA:!1}),je&&chrome.tabs.sendMessage(je,e)):"newChunkAvailable"===e.action?chrome.tabs.query({},(function(t){t.forEach((function(t){chrome.tabs.sendMessage(t.id,{action:"receiveChunk",chunkData:e.chunkData,chunkType:e.chunkType,chunkSize:e.chunkSize})}))})):"recordingStopped"===e.action&&chrome.tabs.query({active:!0,currentWindow:!0},(function(t){t[0]&&chrome.tabs.sendMessage(t[0].id,{action:"showModalQA",stopAndShowModal:e.stopAndShowModal})}))}));var Pe={};chrome.runtime.onMessage.addListener((function(e,t,r){if("getRecording"===e.action)return chrome.tabs.query({active:!0,currentWindow:!0},(function(e){e[0]?chrome.tabs.sendMessage(e[0].id,{action:"getRecording"},(function(e){r(e)})):r({recordings:[]})})),!0;if("getCurrentTab"===e.action)return chrome.tabs.query({active:!0,currentWindow:!0},(function(e){if(e[0]){var t=new URL(e[0].url).hostname;r({hostname:t})}else r({hostname:null})})),!0;if("getRecordingState"===e.action){var n=e.hostname;r({isEnabled:Pe[n]||!1})}else if("toggleRecording"===e.action){var o=e.hostname;Pe[o]=e.enabled,chrome.tabs.query({active:!0,currentWindow:!0},(function(t){t[0]&&chrome.tabs.sendMessage(t[0].id,{action:"updateRecordingState",isEnabled:e.enabled})})),r({success:!0})}return!0})),chrome.tabs.onUpdated.addListener((function(e,t,r){if("complete"===t.status){var n=new URL(r.url).hostname;chrome.tabs.sendMessage(e,{action:"updateRecordingState",isEnabled:Pe[n]||!1})}})),chrome.runtime.onMessage.addListener((function(e,t,r){var n=e.action,o=e.data;"navigation"===n?console.log("Navigation (".concat(o.type,"):"),o):console.log("Action: ".concat(n),o)}))})()})(); |