| 1 |
var A=Object.defineProperty;var f=Object.getOwnPropertySymbols;var w=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable;var g=(e,t,o)=>t in e?A(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,d=(e,t)=>{for(var o in t||(t={}))w.call(t,o)&&g(e,o,t[o]);if(f)for(var o of f(t))$.call(t,o)&&g(e,o,t[o]);return e};import{_ as n,a5 as I,$ as R,c as z}from"./main-96.js";import{s as y}from"./bf-331-47.js";function U(e,t,o,h,l,i,u,c,a){const s=d({},t);s[e.target.name]=e.target.value,o(d({},s))}const v=(e,t,o,h,l,i)=>{if(!e.dataCenter||!e.clientId||!e.clientSecret){o({dataCenter:e.dataCenter?"":n("Data center cann't be empty"),clientId:e.clientId?"":n("Client ID cann't be empty"),clientSecret:e.clientSecret?"":n("Secret key cann't be empty")});return}const u=I(R);l(!0);const a=`https://accounts.zoho.${e.dataCenter}/oauth/v2/auth?scope=ZohoMail.accounts.Read,ZohoMail.messages.CREATE,ZohoMail.messages.UPDATE,ZohoMail.Attachments.CREATE,ZohoMail.Attachments.READ,ZohoMail.Attachments.UPDATE&response_type=code&client_id=${e.clientId}&prompt=Consent&access_type=offline&state=${encodeURIComponent(window.location.href)}/redirect&redirect_uri=${encodeURIComponent(u.zohoRedirectURL)}`,s=window.open(a,"zohoMail","width=400,height=609,toolbar=off"),_=setInterval(()=>{if(s.closed){clearInterval(_);let r={},m=!1;const C=localStorage.getItem("__bitforms_zohoMail");if(C&&(m=!0,r=JSON.parse(C),localStorage.removeItem("__bitforms_zohoMail")),!r.code||r.error||!r||!m){const p=r.error?`Cause: ${r.error}`:"";i({show:!0,msg:`${n("Authorization failed")} ${p}. ${n("please try again")}`}),l(!1)}else{const p=d({},e);p.accountServer=r["accounts-server"],b(r,p,t,h,l,i)}}},500)},b=(e,t,o,h,l,i)=>{const u=I(R),c=d({},e);c.dataCenter=t.dataCenter,c.clientId=t.clientId,c.clientSecret=t.clientSecret,c.redirectURI=encodeURIComponent(u.zohoRedirectURL),z(c,"bitforms_zmail_generate_token").then(a=>a).then(a=>{if(a&&a.success){const s=d({},t);s.tokenDetails=a.data,o(s),y(s),h(!0),i({show:!0,msg:n("Authorized Successfully")})}else a&&a.data&&a.data.data||!a.success&&typeof a.data=="string"?i({show:!0,msg:`${n("Authorization failed Cause:")}${a.data.data||a.data}. ${n("please try again")}`}):i({show:!0,msg:n("Authorization failed. please try again")});l(!1)})};export{v as a,U as h}; |