(()=>{"use strict";Object.create,Object.create;const e=function(){function e(){}return e.prototype.save=function(e){return new Promise((function(o,t){return chrome.storage.local.set(e,o)}))},e}(),o=function(){function e(){}return e.prototype.clean=function(e){var o=e.targets,t=e.cookieOptions,r=e.time,n=e.tabs,a={};return t.map((function(e){a[e.id]=e.value})),o.browser?this.clearBrowser(r,a):o.tab?this.clearTab(r,a,n):void 0},e.prototype.saveCookies=function(e){var o=e.items,t=e.cookiesArray,r=e.deletedCookies,n=e.updateArray;return this.updateCookies(t,n),new Promise((function(e,t){if(r.length>0)for(var n=0;n<r.length;n++)chrome.cookies.remove({url:"https://"+r[n].domain+r[n].path,name:r[n].name});for(n=0;n<=o.length;n++)o[n].cookies.map((function(e,o){e.path||chrome.cookies.set({name:e.name,url:"https://"+e.domain,value:e.value},(function(e){console.log(JSON.stringify(e)),console.log(chrome.extension.lastError),console.log(chrome.runtime.lastError)}))}))}))},e.prototype.updateCookies=function(e,o){var t=this;o.map((function(o){t.deleteAndUpdate(o,e)}))},e.prototype.deleteAndUpdate=function(e,o){o.map((function(o){var t=/(?:[\w-]+\.)+[\w-]+/;if(o.hostname.includes(t.exec(e.domain))){var r=o.cookies[e.index];chrome.cookies.remove({url:"https://"+r.domain+r.path,name:r.name}),chrome.cookies.set({name:e.name,url:"https://"+t.exec(e.domain),value:e.value,httpOnly:e.httpOnly,expirationDate:e.expirationDate,domain:e.domain,path:e.path,sameSite:e.sameSite,secure:e.secure,storeId:e.storeId},(function(e){console.log(JSON.stringify(e)),console.log(chrome.extension.lastError),console.log(chrome.runtime.lastError)}))}}))},e.prototype.clearTab=function(e,o,t){var r=this;return new Promise((function(n,a){if(t[0]){var i=r.calculateTime(e),c=new URL(t[0].url),s=c.hostname.replace("www.","");o.cookie&&chrome.cookies.getAll({domain:s},(function(e){for(var o=0;o<e.length;o++)e[o].domain!==c&&e[o].domain!==s&&e[o].domain!=="."+s||chrome.cookies.remove({url:"https://"+e[o].domain+e[o].path,name:e[o].name})})),o.history&&chrome.history.search({text:s,startTime:i,maxResults:1e4},(function(e){var o,t;try{for(var r=function(e){var o="function"==typeof Symbol&&Symbol.iterator,t=o&&e[o],r=0;if(t)return t.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(o?"Object is not iterable.":"Symbol.iterator is not defined.")}(e),n=r.next();!n.done;n=r.next()){var a=n.value;chrome.history.deleteUrl({url:a.url},(function(){return!0}))}}catch(e){o={error:e}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(o)throw o.error}}})),n(!0)}else n(!1)}))},e.prototype.getAllCookies=function(e){var o=e.tabs;return new Promise((function(e,t){var r=[];o&&o.map((function(o){if(o.url){var t=new URL(o.url).hostname.replace("www.","");chrome.cookies.getAll({domain:t},(function(e){var o={hostname:t,cookies:e};r.push(o)}))}e(r)}))}))},e.prototype.clearBrowser=function(e,o){var t=this.calculateTime(e);return new Promise((function(e,r){chrome.browsingData.remove({since:t},{appcache:!0,cache:o.cache,cacheStorage:o.cache,cookies:o.cookie,downloads:o.downloads,fileSystems:!0,formData:o.formData,history:o.history,indexedDB:!0,localStorage:o.localStorage,passwords:o.password,serviceWorkers:o.serviceWorkers,webSQL:!0},(function(){e(!0)}))}))},e.prototype.calculateTime=function(e){return"lastHour"==e?(new Date).getTime()-36e5:"last24Hours"==e?(new Date).getTime()-864e5:"last4Weeks"==e?(new Date).getTime()-24192e5:"allTime"==e?(new Date).getTime()-31536e7:void 0},e}(),t=function(){function t(){this.storage=new e,this.cookies=new o,this.listen()}return t.prototype.listen=function(){var e=this;chrome.runtime.onMessage.addListener((function(o,t,r){var n;if(o){var a=o.class,i=o.method,c=o.args?o.args:[];return(n=e[a])[i].apply(n,function(e,o,t){if(t||2===arguments.length)for(var r,n=0,a=o.length;n<a;n++)!r&&n in o||(r||(r=Array.prototype.slice.call(o,0,n)),r[n]=o[n]);return e.concat(r||Array.prototype.slice.call(o))}([],function(e,o){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var r,n,a=t.call(e),i=[];try{for(;(void 0===o||o-- >0)&&!(r=a.next()).done;)i.push(r.value)}catch(e){n={error:e}}finally{try{r&&!r.done&&(t=a.return)&&t.call(a)}finally{if(n)throw n.error}}return i}(c))).then((function(e){r({result:e})})).catch((function(e){r({error:e})})),!0}}))},t}();console.log("Broom Cookie Cleaner & Cookie Editor, Best Cookie Cleaner"),new function(){this.storage=new e,this.messages=new t,this.cookies=new o}})();