"use strict";{const e=self,t=e.document;(self.webpackChunkStylus=self.webpackChunkStylus||[]).push([["edit_regexp-tester_js"],{4670:(e,n,s)=>{s.r(n),n.toggle=function toggle(state=!popup){if(state&&!popup){if(!isWatching){isWatching=!0,chrome.tabs.onRemoved.addListener(onTabRemoved),chrome.tabs.onUpdated.addListener(onTabUpdated);for(const e of inputs)observe(e,!0)}popup=u.helpPopup.show(c.t("styleRegexpTestTitle")," ",{className:"regexp-report"}),popup.onClose.add(()=>toggle(!1)),update()}else!state&&popup&&(unwatch(),popup._close.click(),popup=null)};s(9458);var a=s(7986),o=s(7501),l=s(4930),r=s(8982),c=s(6940),i=s(1480),p=s(9920),u=s(4849);const cachedRegexps=new Map,inputs=p.default.regexps,observe=(e,t)=>e[t?"on":"off"]("input",update);let popup,note,isWatching=!1;async function update(){if(!popup)return void unwatch();const regexps=new Map,ael=t.activeElement;for(const e of inputs){const text=e.value,old=regexps.get(text),rxData=old||Object.assign({text},cachedRegexps.get(text));rxData.urls||cachedRegexps.set(text,Object.assign(rxData,{rx:c.tryRegExp("^"+text+"$"),urls:new Map})),old&&e!==ael||(rxData.el=e),old||regexps.set(text,rxData)}const supported=(await browser.tabs.query({})).map(tab=>tab.pendingUrl||tab.url).filter(r.supported),unique=[...new Set(supported).values()];for(const rxData of regexps.values()){const{rx:t,urls}=rxData;if(t){const urlsNow=new Map;for(const url of unique){const match=urls.get(url)||(e=url.match(t))&&{text:e[0],pos:e.index};match&&urlsNow.set(url,match)}rxData.urls=urlsNow}}var e;const stats={full:{data:[],label:c.t("styleRegexpTestFull")},partial:{data:[],label:[c.t("styleRegexpTestPartial"),o.template.regexpTestPartial.cloneNode(!0)]},none:{data:[],label:c.t("styleRegexpTestNone")},invalid:{data:[],label:c.t("styleRegexpTestInvalid")}};for(const{el:e,text,rx:t,urls}of regexps.values()){if(!t){stats.invalid.data.push({el:e,text});continue}if(!urls.size){stats.none.data.push({el:e,text});continue}const full=[],partial=[];for(const[url,match]of urls.entries()){const faviconUrl=url.startsWith(r.ownRoot)?i.MF_ICON:r.favicon(new URL(url).hostname),icon=a.$create("img",{src:faviconUrl});match.text.length===url.length?full.push(a.$create("a",{tabIndex:0},[icon,url])):partial.push(a.$create("a",{tabIndex:0},[icon,url.substr(0,match.pos),a.$create("mark",match.text),url.substr(match.pos+match.text.length)]))}full.length&&stats.full.data.push({el:e,text,urls:full}),partial.length&&stats.partial.data.push({el:e,text,urls:partial})}const report=t.createElement("div");for(const type in stats){const{label,data}=stats[type];if(!data.length)continue;const e=t.createElement("h3"),block=t.createElement("details");report.appendChild(block).appendChild(t.createElement("summary")).appendChild(e),block.open=!report.firstChild,block.dataset.type=type,e.textContent=label,e.dataset.num=data.length;for(const{el:e,text,urls}of data)block.appendChild(urls?a.$create("article",[a.$create("h4",{_source:e},text),...urls]):a.$create("a",{tabIndex:0,_source:e},text))}note||(note=a.$create("div.regexp-report-note",`${c.t("styleRegexpTestNoteStar")} ${c.t("styleRegexpTestNote")}`.split(/(<[^>]+>|\\+)/).map((e,t)=>t%2?a.$create("code","<"===e[0]?e.slice(1,-1):e):e))),popup._contents.firstChild.replaceWith(report),report.onclick=onClick,report.contains(note)||report.append(note)}function onClick(event){let e=event.target;e._source?e._source.focus():(e=e.closest("a"))&&(event.preventDefault(),l.API.openURL({url:e.href||e.textContent,currentWindow:null}))}function onTabRemoved(){update()}function onTabUpdated(tabId,info){info.url&&update()}function unwatch(){if(isWatching){chrome.tabs.onRemoved.removeListener(onTabRemoved),chrome.tabs.onUpdated.removeListener(onTabUpdated);for(const e of inputs)observe(e,!1);isWatching=!1}}["add","delete"].forEach((key,e)=>{const t=inputs[key];inputs[key]=n=>{const res=t.call(inputs,n);return isWatching&&(observe(n,!e),update()),res}})}}])}