import{k as a,u as U,Q as V,$ as y,ap as T,a7 as W,an as w,a9 as k,af as z,aw as E,cW as F}from"./app-CgV11GBz.js";const H=()=>{const A=a([]),g=a({}),P=a(""),v=a(""),x=a(""),d=a(!1),{t:c}=U(),I=a(window.config.product_name),D=a(window.config.product_version),b=V(),M=a([]),C=a([]),f=a(!1),u=a(""),n=a(0);var p;const $=()=>{const o=window.config.product_name,t=axiosAdmin.get(w("modules")),s=y.post("https://envato.codeifly.com/product",{verified_name:o,domain:window.location.host});var e=[];Promise.all([t,s]).then(([N,r])=>{const m=r.data.product,i=window.config.installed_modules,_=window.config.modules;M.value=r.data.offers,C.value=r.data.settings,k(m.modules,l=>{const h=z(i,["verified_name",l.verified_name]);if(e.push({...l,current_version:h?h.current_version:"-",status:E(_,l.verified_name),installed:h!=null}),!l.verified||l.other_domain_verified){var O=[...window.config.modules],S=F(O,function(Q){return Q!=l.verified_name});b.updateActiveModules(S),window.config.modules=S}}),A.value=e})},j=o=>{const{success:t}=o;d.value=!0,g.value={},v.value="",y.post("https://envato.codeifly.com/verify",{verified_name:I.value,purchase_code:P.value,domain:window.location.host,app_url:window.location.href,version:D.value}).then(s=>{d.value=!1,s.data.status=="success"?(d.value=!1,T.success({message:c("common.success")}),x.value=c("messages.verify_success"),t(s.data)):(T.error({message:c("common.error")}),v.value=s.data.message)}).catch(s=>{d.value=!1;const e=s.response.data,N=s.response.status;var r={};if(N==422){if(e.errors&&typeof e.errors<"u")for(var m=Object.keys(e.errors),i=0;i<m.length;i++){var _=m[i].replace(".","\\.");r[_]={required:!0,message:e.errors[m[i]][0]}}g.value=r,W.error(c("common.fix_errors"))}else v.value=e.message?e.message:c("messages.somehing_went_wrong")})},q=o=>{f.value=!0,n.value=0,u.value="";const t={verified_name:o,domain:window.location.host};p=window.setInterval(function(){B()},1500),axiosAdmin.post(w("modules/install"),t).then(s=>{f.value=!1,n.value=100,u.value="started",axiosAdmin.post(w("modules/extract"),t).then(e=>{u.value="completed",y.post("https://envato.codeifly.com/version-update",{verified_name:e.data.verified_name,version:e.data.version,domain:window.location.host}),b.updateActiveModules(e.data.enabled_modules),window.config.modules=e.data.enabled_modules,window.config.installed_modules=e.data.installed_modules}).catch(e=>{u.value="failed"})}).catch(s=>{f.value=!1,n.value=0,clearInterval(p)})},B=()=>{axiosAdmin(w("modules/download-percentage")).then(o=>{n.value=parseInt(o.data.percentage),n.value>=100&&clearInterval(p)})};return{allModules:A,getModuleData:$,install:q,verifyPurchase:j,rules:g,purchaseCode:P,errorMessage:v,successMessage:x,loading:d,productName:I,version:D,offers:M,settings:C,downloading:f,downloadPercentage:n,extracting:u}};export{H as m};
