var k=Object.defineProperty;var m=Object.getOwnPropertySymbols;var y=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable;var _=(e,t,a)=>t in e?k(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,g=(e,t)=>{for(var a in t||(t={}))y.call(t,a)&&_(e,a,t[a]);if(m)for(var a of m(t))$.call(t,a)&&_(e,a,t[a]);return e};import{_ as l,b as p,s as I}from"./main.2.9.0.js";import{u as M}from"./Note.NSUdvR3c.js";const q=(e,t,a,r,s,i,n,o,c)=>{let d=g({},t);switch(d[e.target.name]=e.target.value,e.target.name==="id"&&b(d,a,s,i),e.target.name){case"spreadsheetId":d=spreadSheetChange(d,r,a,s,i);break;case"worksheetName":d=worksheetChange(d,r,a,s,i);break}a(g({},d))},v=e=>{const t={},r=window.location.href.replace(`${window.opener.location.href}`,"").split("&");r&&r.forEach(s=>{const i=s.split("=");i[1]&&(t[i[0]]=i[1])}),localStorage.setItem(`__${e}`,JSON.stringify(t)),window.close()},z=(e,t,a,r,s)=>{r(!0);const i={formID:e,clientId:t.clientId,accessToken:t.tokenDetails.access_token,clientSecret:t.clientSecret,refreshToken:t.tokenDetails.refresh_token,tokenDetails:t.tokenDetails};p(i,"zoom_fetch_all_meetings").then(n=>{if(n&&n.success){const o=g({},t);o.default||(o.default={}),n.data.allMeeting&&(o.default.allMeeting=n.data.allMeeting),s({show:!0,msg:l("Meeting list refreshed","bit-integrations")}),a(g({},o))}else n&&n.data&&n.data.data||!n.success&&typeof n.data=="string"?s({show:!0,msg:I(l("All Meeting list refresh failed Cause: %s. please try again","bit-integrations"),n.data.data||n.data)}):s({show:!0,msg:l("All Meeting list failed. please try again","bit-integrations")});r(!1)}).catch(()=>r(!1))},b=(e,t,a,r)=>{a(!0);const s={meetingId:e.id,clientId:e.clientId,accessToken:e.tokenDetails.access_token,clientSecret:e.clientSecret,refreshToken:e.tokenDetails.refresh_token,tokenDetails:e.tokenDetails};p(s,"zoom_fetch_all_fields").then(i=>{a(!1),i&&i.success&&(t(n=>M(n,o=>{o.zoomFields=i.data,o.field_map=S(o.zoomFields)})),r({show:!0,msg:l("Zoom fields refreshed","bit-integrations")})),r({show:!0,msg:i!=null&&i.data?i==null?void 0:i.data:l("Zoom fields refreshed failed!","bit-integrations")})}).catch(()=>a(!1))},N=(e,t,a,r,s,i,n)=>{if(!e.clientId||!e.clientSecret){a({clientId:e.clientId?"":l("Client Id can't be empty","bit-integrations"),clientSecret:e.clientSecret?"":l("Secret key can't be empty","bit-integrations")});return}s(!0);const o=`https://zoom.us/oauth/authorize?response_type=code&client_id=${e.clientId}&state=${encodeURIComponent(window.location.href)}/redirect&redirect_uri=${encodeURIComponent(`${n.api}/redirect`)}`,c=window.open(o,"zoom","width=400,height=609,toolbar=off"),d=setInterval(()=>{if(c.closed){clearInterval(d);let h={},u=!1;const w=localStorage.getItem("__zoom");if(w&&(u=!0,h=JSON.parse(w),localStorage.removeItem("__zoom")),!h.code||h.error||!h||!u){const f=h.error?`Cause: ${h.error}`:"";i({show:!0,msg:`${l("Authorization failed","bit-integrations")} ${f}. ${l("please try again","bit-integrations")}`}),s(!1)}else{const f=g({},e);f.accountServer=h["accounts-server"],R(h,f,t,r,s,i,n)}}},500)},R=(e,t,a,r,s,i,n)=>{const o=g({},e);o.clientId=t.clientId,o.clientSecret=t.clientSecret,o.redirectURI=`${n.api}/redirect`,p(o,"zoom_generate_token").then(c=>c).then(c=>{if(c&&c.success){const d=g({},t);d.tokenDetails=c.data,a(d),r(!0),i({show:!0,msg:l("Authorized Successfully","bit-integrations")})}else c&&c.data&&c.data.data||!c.success&&typeof c.data=="string"?i({show:!0,msg:`${l("Authorization failed Cause:","bit-integrations")}${c.data.data||c.data}. ${l("please try again","bit-integrations")}`}):i({show:!0,msg:l("Authorization failed. please try again","bit-integrations")});s(!1)})},P=e=>!((e.field_map?e.field_map.filter(a=>!a.formField&&!a.zoomConf):[]).length>0),S=(e=[])=>{const t=e==null?void 0:e.filter(a=>a.required===!0);return t.length>0?t.map(a=>({formField:"",zoomField:a.key})):[{formField:"",zoomField:""}]};export{N as a,P as c,q as h,b as r,v as s,z};
