export const debounce=(callback,wait)=>{let timeoutId=null;return(...args)=>{window.clearTimeout(timeoutId),timeoutId=window.setTimeout((()=>{callback.apply(null,args)}),wait)}};export const waitTimeout=function(maxTimeout=3e3){return new Promise((resolve=>{setTimeout((()=>{resolve()}),maxTimeout)}))};export const escapeHTML=str=>str.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");export const copyToClipoard=(data,opts)=>new Promise((resolve=>{document.addEventListener("copy",(e=>{e.preventDefault(),e.stopPropagation(),e.clipboardData.setData(opts?.type||"text/plain",data),resolve()}),{once:!0}),document.execCommand("copy")}));export const tr=function(){const args=arguments;return chrome?.i18n?.getMessage?chrome.i18n.getMessage.apply(null,args):args[0]||""};const orderForType={FixedProfile:-2e3,PacProfile:-1e3,VirtualProfile:1e3,SwitchProfile:2e3,RuleListProfile:3e3};export const compareProfile=(a,b)=>{var diff;return 0!==(diff=(0|orderForType[a.profileType])-(0|orderForType[b.profileType]))?diff:a.name===b.name?0:a.name<b.name?-1:1};const iconForProfileType={DirectProfile:"glyphicon-transfer",SystemProfile:"glyphicon-off",AutoDetectProfile:"glyphicon-file",FixedProfile:"glyphicon-globe",PacProfile:"glyphicon-file",VirtualProfile:"glyphicon-question-sign",RuleListProfile:"glyphicon-list",SwitchProfile:"glyphicon-retweet"};export const getProfileIcon=profile=>iconForProfileType[profile?.profileType||"DirectProfile"];