import{d as S,m as y,b as v,h as p,l as f}from"./index.20192476.js";import{u as W}from"./SetupWizardStore.f902c357.js";import{g as L}from"./params.764403f6.js";const $=S("ConnectStore",{state:()=>({}),getters:{isConnected:()=>{var o;const n=y(),t=v();return"Lite".toLowerCase()!=="pro"&&((o=t.internalOptions.internal.siteAnalysis)==null?void 0:o.connectToken)||n.license.isActive}},actions:{getConnectUrl({key:n,wizard:t}){return p.post(f.restUrl("connect-url")).send({licenseKey:n.trim(),wizard:t})},processConnect(n){const t=W();return p.post(f.restUrl("connect-pro")).send({downloadUrl:n.file,token:n.token,wizard:n.wizard?JSON.stringify(t.wizard.$state):null})},saveConnectToken(n){return v().updateOption("internalOptions",{groups:["internal","siteAnalysis"],key:"connectToken",value:n}),p.post(f.restUrl("connect")).send({token:n})}}});let s=!1,e=null,g;const a=n=>{g(n,e,a)},x=(n,t,o,c,i,l,r,_,u)=>{let d=50,w=50;{const h=window.outerHeight;d=(window.innerWidth-o)/2,w=(h-50-c)/2}let m=`location=0,status=0,width=${o},height=${c},left=${d},top=${w}`;(t==="_blank"||t==="_self")&&(m=""),(!e||e.closed)&&(e=window.open(n,t,m)),e&&e.focus(),s=window.setInterval(()=>A(l,r,_,u),500),u&&(g=u,window.addEventListener("message",a,!1))},A=(n,t,o,c=!1)=>{if(c){if(!e){window.removeEventListener("message",a,!1),window.clearInterval(s),o();return}e.closed&&(e=null,window.removeEventListener("message",a,!1),window.clearInterval(s),o());return}let i={};try{i=L(e.location.search)}catch{}const l=[];if(n.forEach(r=>{if(i[r]!==void 0&&i[r]){l.push(!0);return}l.push(!1)}),l.every(r=>r))return window.clearInterval(s),t(i).then(()=>{e.close(),e=null,o(!0)});if(!e){window.clearInterval(s),o();return}e.closed&&(e=null,window.clearInterval(s),o())};export{x as p,$ as u};
