import{d as S,o as y,u as v,h as p,b as f}from"./index.684c656d.js";import{u as W}from"./SetupWizardStore.8ebf5e53.js";import{g as L}from"./params.af7ed354.js";const $=S("ConnectStore",{state:()=>({}),getters:{isConnected:()=>{var o;const n=y(),t=v();return"Pro".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,l,i,c,r,_,u)=>{let d=50,w=50;{const h=window.outerHeight;d=(window.innerWidth-o)/2,w=(h-50-l)/2}let m=`location=0,status=0,width=${o},height=${l},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(c,r,_,u),500),u&&(g=u,window.addEventListener("message",a,!1))},A=(n,t,o,l=!1)=>{if(l){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 c=[];if(n.forEach(r=>{if(i[r]!==void 0&&i[r]){c.push(!0);return}c.push(!1)}),c.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};
