(function(e){var t={};function r(o){if(t[o])return t[o].exports;var n=t[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=e,r.c=t,r.i=function(e){return e},r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:o})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=23)})([,function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.openLink=function(e){e.preventDefault(),e.target.href&&chrome.tabs.create({url:e.target.href})},t.clone=function(e){return JSON.parse(JSON.stringify(e))},t.getAuthTab=function(){return new Promise(function(e,t){chrome.tabs.query({url:"https://omnibear.com/auth/success*"},function(r){r.length?e(r[0]):t("Auth tab not found")})})},t.logout=function(){["token","domain","authEndpoint","tokenEndpoint","micropubEndpoint"].map(function(e){return localStorage.removeItem(e)})},t.generateSlug=function(e){var t=e.toLocaleLowerCase().trim();t=t.replace(/\s/g,"-");for(var r=0,a=n.length;r<a;r++)t=t.replace(new RegExp(n.charAt(r),"g"),i.charAt(r));return(t=(t=t.replace(o,"")).replace(/\-\-+/g,"-")).split("-").splice(0,6).join("-")},t.getPageUrl=function(){return new Promise(function(e,t){var r=localStorage.getItem("pageTabId");chrome.tabs.get(Number(r),function(t){e(t.url)})})};var o=/[^A-Za-z0-9\-]/g,n="áäâàãåčçćďéěëèêẽĕȇęėíìîïňñóöòôõøðřŕšťúůüùûýÿžþÞĐđßÆa·/_,:;",i="aaaaaacccdeeeeeeeeeeiiiinnooooooorrstuuuuuyyzbBDdBAa------"},,function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o,n=r(11),i=(o=n)&&o.__esModule?o:{default:o};t.default=new i.default({clientId:"https://omnibear.com",redirectUri:"https://omnibear.com/auth/success/",state:"very-secret-omnibear-state",me:localStorage.getItem("domain"),authEndpoint:localStorage.getItem("authEndpoint"),tokenEndpoint:localStorage.getItem("tokenEndpoint"),micropubEndpoint:localStorage.getItem("micropubEndpoint"),token:localStorage.getItem("token")})},function(e,t,r){"use strict";var o=String.prototype.replace,n=/%20/g;e.exports={default:"RFC3986",formatters:{RFC1738:function(e){return o.call(e,n,"+")},RFC3986:function(e){return e}},RFC1738:"RFC1738",RFC3986:"RFC3986"}},function(e,t,r){"use strict";var o=Object.prototype.hasOwnProperty,n=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}();t.arrayToObject=function(e,t){for(var r=t&&t.plainObjects?Object.create(null):{},o=0;o<e.length;++o)void 0!==e[o]&&(r[o]=e[o]);return r},t.merge=function(e,r,n){if(!r)return e;if("object"!=typeof r){if(Array.isArray(e))e.push(r);else{if("object"!=typeof e)return[e,r];(n.plainObjects||n.allowPrototypes||!o.call(Object.prototype,r))&&(e[r]=!0)}return e}if("object"!=typeof e)return[e].concat(r);var i=e;return Array.isArray(e)&&!Array.isArray(r)&&(i=t.arrayToObject(e,n)),Array.isArray(e)&&Array.isArray(r)?(r.forEach(function(r,i){o.call(e,i)?e[i]&&"object"==typeof e[i]?e[i]=t.merge(e[i],r,n):e.push(r):e[i]=r}),e):Object.keys(r).reduce(function(e,i){var a=r[i];return o.call(e,i)?e[i]=t.merge(e[i],a,n):e[i]=a,e},i)},t.assign=function(e,t){return Object.keys(t).reduce(function(e,r){return e[r]=t[r],e},e)},t.decode=function(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(t){return e}},t.encode=function(e){if(0===e.length)return e;for(var t="string"==typeof e?e:String(e),r="",o=0;o<t.length;++o){var i=t.charCodeAt(o);45===i||46===i||95===i||126===i||i>=48&&i<=57||i>=65&&i<=90||i>=97&&i<=122?r+=t.charAt(o):i<128?r+=n[i]:i<2048?r+=n[192|i>>6]+n[128|63&i]:i<55296||i>=57344?r+=n[224|i>>12]+n[128|i>>6&63]+n[128|63&i]:(o+=1,i=65536+((1023&i)<<10|1023&t.charCodeAt(o)),r+=n[240|i>>18]+n[128|i>>12&63]+n[128|i>>6&63]+n[128|63&i])}return r},t.compact=function(e){for(var t=[{obj:{o:e},prop:"o"}],r=[],o=0;o<t.length;++o)for(var n=t[o],i=n.obj[n.prop],a=Object.keys(i),s=0;s<a.length;++s){var c=a[s],u=i[c];"object"==typeof u&&null!==u&&-1===r.indexOf(u)&&(t.push({obj:i,prop:c}),r.push(u))}return function(e){for(var t;e.length;){var r=e.pop();if(t=r.obj[r.prop],Array.isArray(t)){for(var o=[],n=0;n<t.length;++n)void 0!==t[n]&&o.push(t[n]);r.obj[r.prop]=o}}return t}(t)},t.isRegExp=function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},t.isBuffer=function(e){return null!==e&&void 0!==e&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))}},,function(e,t,r){"use strict";var o=r(12);r.n(o);r.o(o,"parse")&&r.d(t,"a",function(){return o.parse}),r.o(o,"stringify")&&r.d(t,"c",function(){return o.stringify});var n=r(10);r.d(t,"b",function(){return n.a});var i=r(9);r.d(t,"d",function(){return i.a});var a=r(8);r.d(t,"e",function(){return a.a})},function(e,t,r){"use strict";t.a=function(e,t){const r=-1==e.indexOf("?")?"?":"&";let o=[];for(var n in t)Array.isArray(t[n])?t[n].forEach(e=>{o.push(n+"[]="+encodeURIComponent(e))}):o.push(n+"="+encodeURIComponent(t[n]));const i=o.join("&");return e+r+i}},function(e,t,r){"use strict";t.a=function e(t,r=new FormData,o=!1){Object.keys(t).forEach(n=>{const i=t[n];o&&(n=o+"["+n+"]"),Array.isArray(i)?i.forEach(t=>{const o={};o[n+"[]"]=t,r=e(o,r)}):r.append(n,i)});return r}},function(e,t,r){"use strict";t.a=function(e,t){let r={},o=t;const n=(new DOMParser).parseFromString(e,"text/html"),i=n.querySelector("base[href]"),a=n.querySelectorAll("[rel][href]");if(i){const e=i.getAttribute("href"),r=new URL(e,t);o=r.toString()}return a.length&&a.forEach(e=>{const t=e.getAttribute("rel").toLowerCase().split("\\s+"),n=e.getAttribute("href");t.length&&null!==n&&t.forEach(e=>{r[e]||(r[e]=[]);const t=new URL(n,o).toString();-1===r[e].indexOf(t)&&r[e].push(t)})}),r}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){var o=r(7);const n=o.a,i=o.b,a=o.c,s=o.d,c=o.e;o.FormData&&!e.FormData&&(e.FormData=o.FormData),o.DOMParser&&!e.DOMParser&&(e.DOMParser=o.DOMParser),o.URL&&!e.URL&&(e.URL=o.URL);const u={me:"",scope:"post create delete update",token:"",authEndpoint:"",tokenEndpoint:"",micropubEndpoint:""},l=(e,t=null,r=null)=>({message:e,status:t,error:r});t.default=class{constructor(e={}){this.options=Object.assign({},u,e),this.create=this.create.bind(this),this.update=this.update.bind(this),this.delete=this.delete.bind(this),this.undelete=this.undelete.bind(this),this.postMicropub=this.postMicropub.bind(this),this.checkRequiredOptions=this.checkRequiredOptions.bind(this),this.getAuthUrl=this.getAuthUrl.bind(this),this.getEndpointsFromUrl=this.getEndpointsFromUrl.bind(this)}checkRequiredOptions(e){let t=[],r=!0;for(var o=0;o<e.length;o++){const n=e[o];this.options[n]||(r=!1,t.push(n))}return{pass:r,missing:t}}getEndpointsFromUrl(e){return new Promise((t,r)=>{let o={micropub:null,authorization_endpoint:null,token_endpoint:null},n=e;fetch(e).then(t=>{if(!t.ok)return r(l("Error getting page",t.status));n=t.url;const i=t.headers.get("link");return i&&i.split(",").forEach(t=>{Object.keys(o).forEach(r=>{const n=t.match(/rel=("([^"]*)"|([^,"<]+))/);if(n&&n[1]&&(" "+n[1].toLowerCase()+" ").indexOf(" "+r+" ")>=0){const n=t.match(/[^<>|\s]+/g);if(n&&n[0]){let t=n[0];t=new URL(t,e).toString(),o[r]=t}}})}),t.text()}).then(a=>{const s=i(a,n);return this.options.me=e,s&&Object.keys(o).forEach(e=>{s[e]&&s[e][0]&&(o[e]=s[e][0])}),o.micropub&&o.authorization_endpoint&&o.token_endpoint?(this.options.micropubEndpoint=o.micropub,this.options.tokenEndpoint=o.token_endpoint,this.options.authEndpoint=o.authorization_endpoint,t({auth:this.options.authEndpoint,token:this.options.tokenEndpoint,micropub:this.options.micropubEndpoint})):r(l("Error getting microformats data"))}).catch(e=>r(l("Error fetching url",null,e)))})}getToken(e){return new Promise((t,r)=>{const o=this.checkRequiredOptions(["me","clientId","redirectUri","tokenEndpoint"]);if(!o.pass)return r(l("Missing required options: "+o.missing.join(", ")));const i={grant_type:"authorization_code",me:this.options.me,code:e,client_id:this.options.clientId,redirect_uri:this.options.redirectUri},s={method:"POST",body:a(i),headers:new Headers({"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8",Accept:"application/json, application/x-www-form-urlencoded"})};fetch(this.options.tokenEndpoint,s).then(e=>{if(!e.ok)return r(l("Error getting token",e.status));const t=e.headers.get("Content-Type");return t&&0===t.indexOf("application/json")?e.json():e.text()}).then(e=>("string"==typeof e&&(e=n(e)),e.error_description?r(l(e.error_description)):e.error?r(l(e.error)):e.me&&e.scope&&e.access_token?e.me&&e.me.replace(/\/+$/,"")!==this.options.me.replace(/\/+$/,"")?r(l("The me values did not match")):(this.options.token=e.access_token,void t(e.access_token)):r(l("The token endpoint did not return the expected parameters")))).catch(e=>r(l("Error requesting token endpoint",null,e)))})}getAuthUrl(){return new Promise((e,t)=>{let r=this.checkRequiredOptions(["me","state"]);if(!r.pass)return t(l("Missing required options: "+r.missing.join(", ")));this.getEndpointsFromUrl(this.options.me).then(()=>{let r=this.checkRequiredOptions(["me","state","scope","clientId","redirectUri"]);if(!r.pass)return t(l("Missing required options: "+r.missing.join(", ")));const o={me:this.options.me,client_id:this.options.clientId,redirect_uri:this.options.redirectUri,response_type:"code",scope:this.options.scope,state:this.options.state};e(this.options.authEndpoint+"?"+a(o))}).catch(e=>t(l("Error getting auth url",null,e)))})}verifyToken(){return new Promise((e,t)=>{const r=this.checkRequiredOptions(["token","micropubEndpoint"]);if(!r.pass)return t(l("Missing required options: "+r.missing.join(", ")));const o={method:"GET",headers:new Headers({Authorization:"Bearer "+this.options.token})};fetch(this.options.micropubEndpoint,o).then(r=>r.ok?e(!0):t(l("Error verifying token",r.status))).catch(e=>t(l("Error verifying token",null,e)))})}create(e,t="json"){return this.postMicropub(e,t)}update(e,t){return this.postMicropub(Object.assign({action:"update",url:e},t))}delete(e){return this.postMicropub({action:"delete",url:e})}undelete(e){return this.postMicropub({action:"undelete",url:e})}postMicropub(e,t="json"){return new Promise((r,o)=>{const i=this.checkRequiredOptions(["token","micropubEndpoint"]);if(!i.pass)return o(l("Missing required options: "+i.missing.join(", ")));let c={method:"POST"};"json"==t?(c.body=JSON.stringify(e),c.headers=new Headers({Authorization:"Bearer "+this.options.token,"Content-Type":"application/json",Accept:"application/json, application/x-www-form-urlencoded"})):"form"==t?(c.body=a(e,{arrayFormat:"brackets"}),c.headers=new Headers({Authorization:"Bearer "+this.options.token,"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8",Accept:"application/json, application/x-www-form-urlencoded"})):"multipart"==t&&(c.body=s(e),c.headers=new Headers({Authorization:"Bearer "+this.options.token,"Content-Type":void 0,Accept:"application/json, application/x-www-form-urlencoded"})),fetch(this.options.micropubEndpoint,c).then(e=>{if(!e.ok)return o(l("Error with micropub request",e.status));const t=e.headers.get("Location")||e.headers.get("location");if(t)return r(t);const n=e.headers.get("Content-Type");return n&&0===n.indexOf("application/json")?e.json():e.text()}).then(e=>("string"==typeof e&&(e=n(e)),e.error_description?o(l(e.error_description)):e.error?o(l(e.error)):r(e))).catch(e=>o(l("Error sending request",null,e)))})}postMedia(e){return new Promise((t,r)=>{const o=this.checkRequiredOptions(["token","mediaEndpoint"]);if(!o.pass)return r(l("Missing required options: "+o.missing.join(", ")));let n={method:"POST",body:s({file:e}),headers:new Headers({Authorization:"Bearer "+this.options.token,"Content-Type":void 0,Accept:"*/*"})};fetch(this.options.mediaEndpoint,n).then(e=>{if(201!==e.status)return r(l("Error creating media",e.status));const o=e.headers.get("Location")||e.headers.get("location");return o?t(o):r(l("Media endpoint did not return a location",e.status))}).catch(e=>r(l("Error sending request")))})}query(e){return new Promise((t,r)=>{const o=this.checkRequiredOptions(["token","micropubEndpoint"]);if(!o.pass)return r(l("Missing required options: "+o.missing.join(", ")));const n=c(this.options.micropubEndpoint,{q:e}),i={method:"GET",headers:new Headers({Authorization:"Bearer "+this.options.token,"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8",Accept:"application/json"})};fetch(n,i).then(t=>t.ok?t.json():r(l("Error getting "+e,t.status))).then(e=>t(e)).catch(t=>r(l("Error getting "+e,null,t)))})}querySource(e,t=[]){return new Promise((r,o)=>{const n=this.checkRequiredOptions(["token","micropubEndpoint"]);if(!n.pass)return o(l("Missing required options: "+n.missing.join(", ")));e=c(this.options.micropubEndpoint,{q:"source",url:e,properties:t});const i={method:"GET",headers:new Headers({Authorization:"Bearer "+this.options.token,"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8",Accept:"application/json"})};fetch(e,i).then(e=>e.ok?e.json():o(l("Error getting source",e.status))).then(e=>r(e)).catch(e=>o(l("Error getting source",null,e)))})}}}.call(t,r(15))},function(e,t,r){"use strict";var o=r(14),n=r(13),i=r(4);e.exports={formats:i,parse:n,stringify:o}},function(e,t,r){"use strict";var o=r(5),n=Object.prototype.hasOwnProperty,i={allowDots:!1,allowPrototypes:!1,arrayLimit:20,decoder:o.decode,delimiter:"&",depth:5,parameterLimit:1e3,plainObjects:!1,strictNullHandling:!1},a=function(e,t,r){if(e){var o=r.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,i=/(\[[^[\]]*])/g,a=/(\[[^[\]]*])/.exec(o),s=a?o.slice(0,a.index):o,c=[];if(s){if(!r.plainObjects&&n.call(Object.prototype,s)&&!r.allowPrototypes)return;c.push(s)}for(var u=0;null!==(a=i.exec(o))&&u<r.depth;){if(u+=1,!r.plainObjects&&n.call(Object.prototype,a[1].slice(1,-1))&&!r.allowPrototypes)return;c.push(a[1])}return a&&c.push("["+o.slice(a.index)+"]"),function(e,t,r){for(var o=t,n=e.length-1;n>=0;--n){var i,a=e[n];if("[]"===a)i=(i=[]).concat(o);else{i=r.plainObjects?Object.create(null):{};var s="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,c=parseInt(s,10);!isNaN(c)&&a!==s&&String(c)===s&&c>=0&&r.parseArrays&&c<=r.arrayLimit?(i=[])[c]=o:i[s]=o}o=i}return o}(c,t,r)}};e.exports=function(e,t){var r=t?o.assign({},t):{};if(null!==r.decoder&&void 0!==r.decoder&&"function"!=typeof r.decoder)throw new TypeError("Decoder has to be a function.");if(r.ignoreQueryPrefix=!0===r.ignoreQueryPrefix,r.delimiter="string"==typeof r.delimiter||o.isRegExp(r.delimiter)?r.delimiter:i.delimiter,r.depth="number"==typeof r.depth?r.depth:i.depth,r.arrayLimit="number"==typeof r.arrayLimit?r.arrayLimit:i.arrayLimit,r.parseArrays=!1!==r.parseArrays,r.decoder="function"==typeof r.decoder?r.decoder:i.decoder,r.allowDots="boolean"==typeof r.allowDots?r.allowDots:i.allowDots,r.plainObjects="boolean"==typeof r.plainObjects?r.plainObjects:i.plainObjects,r.allowPrototypes="boolean"==typeof r.allowPrototypes?r.allowPrototypes:i.allowPrototypes,r.parameterLimit="number"==typeof r.parameterLimit?r.parameterLimit:i.parameterLimit,r.strictNullHandling="boolean"==typeof r.strictNullHandling?r.strictNullHandling:i.strictNullHandling,""===e||null===e||void 0===e)return r.plainObjects?Object.create(null):{};for(var s="string"==typeof e?function(e,t){for(var r={},o=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,a=t.parameterLimit===1/0?void 0:t.parameterLimit,s=o.split(t.delimiter,a),c=0;c<s.length;++c){var u,l,p=s[c],d=p.indexOf("]="),f=-1===d?p.indexOf("="):d+1;-1===f?(u=t.decoder(p,i.decoder),l=t.strictNullHandling?null:""):(u=t.decoder(p.slice(0,f),i.decoder),l=t.decoder(p.slice(f+1),i.decoder)),n.call(r,u)?r[u]=[].concat(r[u]).concat(l):r[u]=l}return r}(e,r):e,c=r.plainObjects?Object.create(null):{},u=Object.keys(s),l=0;l<u.length;++l){var p=u[l],d=a(p,s[p],r);c=o.merge(c,d,r)}return o.compact(c)}},function(e,t,r){"use strict";var o=r(5),n=r(4),i={brackets:function(e){return e+"[]"},indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},a=Date.prototype.toISOString,s={delimiter:"&",encode:!0,encoder:o.encode,encodeValuesOnly:!1,serializeDate:function(e){return a.call(e)},skipNulls:!1,strictNullHandling:!1},c=function e(t,r,n,i,a,c,u,l,p,d,f,h){var m=t;if("function"==typeof u)m=u(r,m);else if(m instanceof Date)m=d(m);else if(null===m){if(i)return c&&!h?c(r,s.encoder):r;m=""}if("string"==typeof m||"number"==typeof m||"boolean"==typeof m||o.isBuffer(m))return c?[f(h?r:c(r,s.encoder))+"="+f(c(m,s.encoder))]:[f(r)+"="+f(String(m))];var g,y=[];if(void 0===m)return y;if(Array.isArray(u))g=u;else{var b=Object.keys(m);g=l?b.sort(l):b}for(var v=0;v<g.length;++v){var w=g[v];a&&null===m[w]||(y=Array.isArray(m)?y.concat(e(m[w],n(r,w),n,i,a,c,u,l,p,d,f,h)):y.concat(e(m[w],r+(p?"."+w:"["+w+"]"),n,i,a,c,u,l,p,d,f,h)))}return y};e.exports=function(e,t){var r=e,a=t?o.assign({},t):{};if(null!==a.encoder&&void 0!==a.encoder&&"function"!=typeof a.encoder)throw new TypeError("Encoder has to be a function.");var u=void 0===a.delimiter?s.delimiter:a.delimiter,l="boolean"==typeof a.strictNullHandling?a.strictNullHandling:s.strictNullHandling,p="boolean"==typeof a.skipNulls?a.skipNulls:s.skipNulls,d="boolean"==typeof a.encode?a.encode:s.encode,f="function"==typeof a.encoder?a.encoder:s.encoder,h="function"==typeof a.sort?a.sort:null,m=void 0!==a.allowDots&&a.allowDots,g="function"==typeof a.serializeDate?a.serializeDate:s.serializeDate,y="boolean"==typeof a.encodeValuesOnly?a.encodeValuesOnly:s.encodeValuesOnly;if(void 0===a.format)a.format=n.default;else if(!Object.prototype.hasOwnProperty.call(n.formatters,a.format))throw new TypeError("Unknown format option provided.");var b,v,w=n.formatters[a.format];"function"==typeof a.filter?r=(v=a.filter)("",r):Array.isArray(a.filter)&&(b=v=a.filter);var k,O=[];if("object"!=typeof r||null===r)return"";k=a.arrayFormat in i?a.arrayFormat:"indices"in a?a.indices?"indices":"repeat":"indices";var j=i[k];b||(b=Object.keys(r)),h&&b.sort(h);for(var E=0;E<b.length;++E){var A=b[E];p&&null===r[A]||(O=O.concat(c(r[A],A,j,l,p,d?f:null,v,h,m,g,w,y)))}var x=O.join(u),S=!0===a.addQueryPrefix?"?":"";return x.length>0?S+x:""}},function(e,t){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getParamFromUrl=function(e,t){var r=t.split("?")[1];return a(e,r)},t.getParamFromUrlString=a,t.cleanParams=s,t.paramsToQueryString=c,t.getUrlOrigin=function(e){var t=(0,i.default)(e);return[t.protocol,"://",t.host,t.port?":"+t.port:""].join("")},t.cleanUrl=function(e){var t=(0,i.default)(e);return[t.protocol,"://",t.host,t.port?":"+t.port:"",t.path,c(s(t.queryKey))].join("")};var o,n=r(41),i=(o=n)&&o.__esModule?o:{default:o};function a(e,t){var r=t.split("&").filter(function(t){return t.startsWith(e+"=")});if(r&&r.length){var o=r[0].substr(e.length+1);return decodeURIComponent(o)}return null}function s(e){var t={};for(var r in e)r.startsWith("utm_")||(t[r]=e[r]);return t}function c(e){var t=[];for(var r in e)t.push(r+"="+e[r]);return t.length?"?"+t.join("&"):""}},,,,function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateMeDomainFromUrl=function(e){var t=(0,a.getParamFromUrl)("me",e);if(t){var r=localStorage.getItem("domain");return(0,a.getUrlOrigin)(r)!==(0,a.getUrlOrigin)(t)?(chrome.tabs.sendMessage(tab.id,{action:"fetch-token-error",payload:{error:new Error("'me' url domain doesn't match auth endpoint domain")}}),(0,s.logout)(),!1):(localStorage.setItem("domain",t),!0)}},t.fetchToken=function(e){return i.default.options.me=localStorage.getItem("domain"),i.default.options.tokenEndpoint=localStorage.getItem("tokenEndpoint"),i.default.options.micropubEndpoint=localStorage.getItem("micropubEndpoint"),i.default.getToken(e).then(function(e){if(!e)throw new Error("Token not found in token endpoint response. Missing expected field 'access_token'");localStorage.setItem("token",e),i.default.options.token=e}).catch(function(e){console.log("error fetching token",e),(0,s.getAuthTab)().then(function(t){chrome.tabs.sendMessage(t.id,{action:"fetch-token-error",payload:{error:e}}),(0,s.logout)()})})},t.fetchSyndicationTargets=function(){return i.default.query("syndicate-to").then(function(e){var t=e["syndicate-to"];e.ok&&Array.isArray(t)?localStorage.setItem("syndicateTo",JSON.stringify(t)):localStorage.setItem("syndicateTo",JSON.stringify([]))})};var o,n=r(3),i=(o=n)&&o.__esModule?o:{default:o},a=r(16),s=r(1)},,,function(e,t,r){"use strict";var o=r(16),n=(r(1),r(20)),i=null;function a(e){localStorage.setItem("selectedEntry",e)}function s(){localStorage.removeItem("selectedEntry")}chrome.runtime.onMessage.addListener(function(e,t,r){switch(e.action){case"begin-auth":l=e.payload,localStorage.setItem("domain",l.domain),localStorage.setItem("authEndpoint",l.metadata.authEndpoint),localStorage.setItem("tokenEndpoint",l.metadata.tokenEndpoint),localStorage.setItem("micropubEndpoint",l.metadata.micropub),chrome.tabs.create({url:l.authUrl},function(e){i=e.id});break;case"focus-window":n=t.tab.id,c=t.url,u=e.payload.selectedEntry,localStorage.setItem("pageUrl",(0,o.cleanUrl)(c)),localStorage.setItem("pageTabId",n),u?a(u):s();break;case"select-entry":a(e.payload.url);break;case"clear-entry":s()}var n,c,u,l}),chrome.tabs.onUpdated.addListener(function(e,t,r){if(e===i&&function(e){return e.url&&e.url.startsWith("https://omnibear.com/auth/success")}(t)&&(0,n.validateMeDomainFromUrl)(t.url)){var a=(0,o.getParamFromUrl)("code",t.url);(0,n.fetchToken)(a).then(function(){return(0,n.fetchSyndicationTargets)()}).then(function(){chrome.tabs.remove(r.id),i=null}).catch(function(e){console.error(e.message,e)})}}),chrome.contextMenus.create({title:"Reply to entry",contexts:["page","selection"],onclick:function(){"undefined"==typeof browser?window.open("index.html?reply=true","extension_popup","width=450,height=510,status=no,scrollbars=yes,resizable=no,top=80,left=2000"):browser.windows.create({url:"index.html?reply=true",width:450,height:580,type:"panel",left:2e3})}})},,,,,,,,,,,,,,,,,,function(e,t,r){"use strict";e.exports=function(e,t){t=t||{};for(var r={key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}},o=r.parser[t.strictMode?"strict":"loose"].exec(e),n={},i=14;i--;)n[r.key[i]]=o[i]||"";return n[r.q.name]={},n[r.key[12]].replace(r.q.parser,function(e,t,o){t&&(n[r.q.name][t]=o)}),n}}]);