var b=Object.defineProperty;var u=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,k=Object.prototype.propertyIsEnumerable;var g=(e,a,t)=>a in e?b(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t,c=(e,a)=>{for(var t in a||(a={}))I.call(a,t)&&g(e,t,a[t]);if(u)for(var t of u(a))k.call(a,t)&&g(e,t,a[t]);return e};import{_ as d,b as m,q as w}from"./bi.394.85.js";const T=(e,a,t)=>{const o=c({},a),{name:n}=e.target;e.target.value!==""?o[n]=e.target.value:delete o[n],t(c({},o))},R=(e,a,t,o,n)=>{o(!0);const s={formID:e,clientId:a.clientId,accessToken:a.accessToken};m(s,"trello_fetch_all_board").then(i=>{if(i&&i.success){const r=c({},a);r.default||(r.default={}),i.data.allBoardlist&&(r.default.allBoardlist=i.data.allBoardlist),n({show:!0,msg:d("Board list refreshed","bit-integrations")}),t(c({},r))}else i&&i.data&&i.data.data||!i.success&&typeof i.data=="string"?n({show:!0,msg:w(d("Board list refresh failed Cause: %s. please try again","bit-integrations"),i.data.data||i.data)}):n({show:!0,msg:d("Board list failed. please try again","bit-integrations")});o(!1)}).catch(()=>o(!1))},v=(e,a,t,o)=>{t(!0);const n={clientId:e.clientId,boardId:e.boardId,accessToken:e.accessToken};m(n,"trello_fetch_all_list_Individual_board").then(s=>{var i;if(s&&s.success){const r=c({},e);r.default||(r.default={}),(i=s.data)!=null&&i.alllists&&(r.default.alllists=s.data.alllists),o({show:!0,msg:d("Board list refreshed","bit-integrations")}),a(c({},r))}else s&&s.data&&s.data.data||!s.success&&typeof s.data=="string"?o({show:!0,msg:w(d("Board list refresh failed Cause: %s. please try again","bit-integrations"),s.data.data||s.data)}):o({show:!0,msg:d("Board list failed. please try again","bit-integrations")});t(!1)}).catch(()=>t(!1))},q=e=>{const a={},o=window.location.href.replace(`${window.opener.location.href}`,"").split("&");o&&o.forEach(n=>{const s=n.split("=");s[1]&&(a[s[0]]=s[1])}),localStorage.setItem(`__${e}`,JSON.stringify(a)),window.close()},A=(e,a,t,o,n,s,i,r)=>{if(!t.clientId){n({clientId:t.clientId?"":d("Client ID cann't be empty","bit-integrations")});return}i(!0);const _=`https://trello.com/1/authorize?expiration=never&name=MyPersonalToken&scope=read,write&response_type=token&key=${t.clientId}&return_url=${encodeURIComponent(window.location.href)}/&response_type=token`,y=window.open(_,e,"width=400,height=609,toolbar=off"),F=setInterval(()=>{if(y.closed){clearInterval(F);let l={},h=!1;const p=localStorage.getItem(`__${e}`);if(p&&(h=!0,l=JSON.parse(p),localStorage.removeItem(`__${e}`),l.token&&(l.code=l.token)),!l.code||l.error||!l||!h){const f=l.error?`Cause: ${l.error}`:"";r({show:!0,msg:`${d("Authorization failed","bit-integrations")} ${f}. ${d("please try again","bit-integrations")}`}),i(!1)}else{const f=c({},t);f.accessToken=l.code,o(f),s(!0),r({show:!0,msg:d("Authorized Successfully","bit-integrations")})}}i(!1)},500)},M=e=>{const a=e==null?void 0:e.cardFields.filter(t=>t.required===!0);return a.length>0?a.map(t=>({formField:"",trelloFormField:t.key})):[{formField:"",trelloFormField:""}]},z=e=>!((e.field_map?e.field_map.filter(t=>!t.formField&&!t.trelloFormField):[]).length>0);export{R as a,A as b,z as c,v as f,M as g,T as h,q as s};
