@hiver/connector-agent 1.6.2-editM2-beta.3 → 1.6.2-editM2-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.es.js +2 -2
- package/index.umd.js +1 -1
- package/package.json +1 -1
package/index.es.js
CHANGED
|
@@ -36865,8 +36865,8 @@ Do you want to continue?`, lV = "Select an object to create", cV = "Select an ob
|
|
|
36865
36865
|
/* @__PURE__ */ v.jsxs(YU, { className: h ? "hiver-card-expanded" : "", children: [
|
|
36866
36866
|
/* @__PURE__ */ v.jsx(zt, { title: C ? b : "", placement: "bottom", children: /* @__PURE__ */ v.jsx(GU, { variant: "h4", onMouseOver: (G) => W(G), onMouseLeave: (G) => W(G), children: b }) }),
|
|
36867
36867
|
/* @__PURE__ */ v.jsxs(tB, { children: [
|
|
36868
|
-
D ? /* @__PURE__ */ v.jsx(zt, { title: zh, placement: "bottom", children: /* @__PURE__ */ v.jsx(Or, { onClick: H, children: /* @__PURE__ */ v.jsx("img", { src: XV }) }) }) : null,
|
|
36869
|
-
P ? /* @__PURE__ */ v.jsx(zt, { title: Wh, placement: "bottom", children: /* @__PURE__ */ v.jsx(Or, { onClick: () => m(!0), children: /* @__PURE__ */ v.jsx("img", { src: GV }) }) }) : null,
|
|
36868
|
+
h && D ? /* @__PURE__ */ v.jsx(zt, { title: zh, placement: "bottom", children: /* @__PURE__ */ v.jsx(Or, { onClick: H, children: /* @__PURE__ */ v.jsx("img", { src: XV }) }) }) : null,
|
|
36869
|
+
h && P ? /* @__PURE__ */ v.jsx(zt, { title: Wh, placement: "bottom", children: /* @__PURE__ */ v.jsx(Or, { onClick: () => m(!0), children: /* @__PURE__ */ v.jsx("img", { src: GV }) }) }) : null,
|
|
36870
36870
|
h ? /* @__PURE__ */ v.jsx(zt, { title: Vh, placement: "bottom", children: /* @__PURE__ */ v.jsx(
|
|
36871
36871
|
Or,
|
|
36872
36872
|
{
|
package/index.umd.js
CHANGED
|
@@ -2416,7 +2416,7 @@ Take a look at the reducer(s) handling this action type: ${h.type}.
|
|
|
2416
2416
|
width: 10px;
|
|
2417
2417
|
}
|
|
2418
2418
|
`,hj=(e,{closeToast:t})=>v.jsx(Ij,{children:v.jsx("img",{src:fj,onClick:t})}),Vl=({message:e})=>v.jsxs(pj,{children:[v.jsx(Ej,{}),v.jsx(Cj,{children:e})]});function an(e){const{message:t,type:n,autoClose:o}=e,r={closeButton:v.jsx(hj,{}),autoClose:o??5e3,pauseOnHover:!0,position:"bottom-left",rtl:!1,draggable:!0,closeOnClick:!0,hideProgressBar:!0};let i;switch(n){case"success":{i=ot.success(v.jsx(Vl,{message:t}),{...r,icon:!1});break}case"error":{i=ot.error(v.jsx(Vl,{message:t}),{...r,icon:!1});break}case"info-dark":{i=ot.info(v.jsx(Vl,{message:t}),{...r,icon:!1,className:"toast_dark"});break}default:{i=ot.info(v.jsx(Vl,{message:t}),{...r,icon:!1});break}}return setTimeout(()=>{Bj(i)},o&&!isNaN(o)?Number(o):5e3),i}function Bj(e){ot.dismiss(e)}const jh={updateFormApiStatus:Oe.IDLE,createObjectList:[],linkObjectList:[],editObjectList:[],objectDict:null,formFields:null,previewCardData:null,objectListApiStatus:Oe.IDLE,unlinkCardApiStatus:Oe.IDLE,linkCardApiStatus:Oe.IDLE,previewCardApiStatus:Oe.IDLE,optionsMap:null,dropdownOptionsApis:Oe.IDLE,dependentFieldsMap:{},createFormApiStatus:Oe.IDLE,currentResourceDetailsApiStatus:Oe.IDLE,currentResourceDetails:null,currentCardInEdit:null,hasUnsavedChanges:!1},Yr="/v1/api",mj=`${Yr}/connectors/forms/list`,Qj=`${Yr}/connectors/cards/:id/unlink`,bj=`${Yr}/connectors/forms/:id/link`,vj=`${Yr}/connectors/forms/:id/preview`,yj=`${Yr}/connectors/forms/:formId/field/:fieldName/data`,wj=`${Yr}/connectors/form/:formId`,xj=`${Yr}/connectors/forms/:formId/data`,Tj=({inboxIds:e,channelType:t,conversationId:n})=>{const o=new URLSearchParams;return e.forEach(r=>o.append("inbox_ids",r)),o.append("channel_type",t),o.append("conversation_id",String(n)),Co({url:`${mj}?${o.toString()}`,method:jo.GET})},Fj=(e,t,n="email")=>{const o=new URLSearchParams;return o.append("channel_type",n),Co({url:U2(`${yj}?${o.toString()}`,e),method:jo.POST,data:t})},Vh=(e,t,n="email")=>{const o=new URLSearchParams;return o.append("channel_type",n),Co({url:U2(`${wj}?${o.toString()}`,e),method:jo.POST,data:t})},Sj=(e,t="email",n,o)=>{const r=new URLSearchParams;return r.append("channel_type",t),Co({url:`${Qj.replace(":id",e)}?${r.toString()}`,method:jo.POST,data:{externalResourceId:n,conversationId:o}})},Oj=(e,t,n="email",o)=>{const r=new URLSearchParams;return r.append("channel_type",n),Co({url:`${bj.replace(":id",e)}?${r.toString()}`,method:jo.POST,data:{externalResourceId:t,conversationId:o}})},kj=(e,t,n="email")=>{const o=new URLSearchParams;return o.append("channel_type",n),Co({url:`${vj.replace(":id",e)}?${o.toString()}`,method:jo.POST,data:{args:t}})},Mj=(e,t="email",n,o,r)=>{const i=new URLSearchParams;return i.append("channel_type",t),i.append("conversation_id",String(n||"")),i.append("senderEmail",r),i.append("externalResourceId",o),Co({url:`${xj.replace(":formId",e)}?${i.toString()}`,method:jo.GET})},Dj="Error in previewing the card",Pj="Card linked successfully",Rj="Error in linking the card",Hh="Please enter a valid URL",Lj="Please enter valid ID",Uj="Please enter valid input",Nj="URL must start with https://",jj="URL should not end with a slash",Vj="Invalid email address",Hj="Email must be a string",Wh="Invalid date",Wj="Date cannot be in the past",zj="Date cannot be in the future",Yj="Invalid number",Gj="Invalid text",Xj="New card created",Kj="Card creation failed",Zj="https://avatars.githubusercontent.com/u/62397590",Jj="Create and link objects from different apps to this conversation",_j="Are you sure you want to change the primary object?",qj="Changing the primary object will reset all the information you’ve entered and all data will be lost and can’t be recovered.",$j="Are you sure you want to leave?",eV=`If you go back now, all the information you’ve entered will be lost and can’t be recovered.
|
|
2419
|
-
Do you want to continue?`,tV="Select an object to create",nV="Select an object to link",zh="Select object",oV="Paste URL or ID",rV="Object ID/Link",iV="Card updated",sV="Card updation failed",aV="Required Field",AV="Invalid date",Yh=/^https:\/\/([a-z0-9-]+(\.[a-z0-9-]+)+)(:[0-9]{1,5})?(\/[^\s/]*)*$/i,lV=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,cV=(e,t)=>t?Object.values(t).filter(o=>e.values[o]&&!e.errors[o]):[],Gh=(e,t)=>t?Object.keys(t).reduce((o,r)=>{let i="";const a=t[r];return e.values&&e.values[a]&&typeof e.values[a]=="object"&&"value"in e.values[a]?i=e.values[a].value:e.values&&e.values[a]&&typeof e.values[a]!="object"?i=e.values[a]:i=null,{...o,[r]:i}},{}):{},Xh=(e,t,n)=>{let o=`${t}_${n}`;return Object.keys(e).forEach(r=>{o=`${o}_${r}:${e[r]}`}),o},uV=e=>t=>{if(t&&typeof t=="string"){const n=t.replace(/\/$/,"");return n.startsWith("https://")?t.endsWith("/")?jj:Yh.test(n)?!0:e||Hh:Nj}return!1},dV=e=>t=>t&&typeof t=="string"?lV.test(t)?!0:e||Vj:Hj,gV=e=>t=>t==null||t===""?e||aV:!0,fV=e=>(t,n)=>{var o;if(!t||(t==null?void 0:t.toString())===AV)return Wh;if(typeof t=="object"){const r=t,i=new Date;i.setHours(0,0,0,0);const a=n.disablePast,A=n.disableFuture;return a&&r<i?e||Wj:A&&r>i?e||zj:!0}return typeof t=="string"&&((o=new Date(t))==null?void 0:o.toString())!=="Invalid Date"?!0:Wh},pV=e=>(t,n)=>{if(t=Number(t),typeof t=="number"&&!isNaN(t)){const o=n.min,r=n.max;return o!==void 0&&t<o?e||`Value should not be less than ${o}`:r!==void 0&&t>r?e||`Value should not be greater than ${r}`:!0}return e||Yj},CV=e=>(t,n)=>{if(typeof t=="string"){const o=n.limit;return o!==void 0&&t.length>o?e||`Maximum characters allowed are ${o}`:!0}return e||Gj},EV=e=>t=>typeof t=="string"?t.startsWith("https:")?Yh.test(t)?!0:e||Hh:t.trim().length>0?!0:e||Lj:e||Uj,IV=({formFields:e})=>{const t={};return e.forEach(n=>{var o,r,i,a,A,l;if(t[n.name]={},(o=n.validations)!=null&&o.isRequired&&(typeof n.validations.isRequired=="object"?t[n.name].isRequired=gV(n.validations.isRequired.msg):t[n.name].isRequired=!0),n.type==="date"){let c=typeof((r=n.validations)==null?void 0:r.disableFuture)=="object"?n.validations.disableFuture.msg:"";c=typeof((i=n.validations)==null?void 0:i.disablePast)=="object"?n.validations.disablePast.msg:c,t[n.name].validate=fV(c);return}if(n.type==="number"&&((a=n.validations)!=null&&a.range)){t[n.name].validate=pV();return}if(n.type==="text"&&n.limit){t[n.name].validate=CV();return}if((A=n.validations)!=null&&A.isUrl){const c=typeof n.validations.isUrl=="object"?n.validations.isUrl.msg:"";t[n.name].validate=uV(c)}else if((l=n.validations)!=null&&l.isEmail){const c=typeof n.validations.isEmail=="object"?n.validations.isEmail.msg:"";t[n.name].validate=dV(c)}}),t},Og=(e,t)=>Object.keys(t).reduce((n,o)=>{const r=e.values[t[o]];let i;return Array.isArray(r)?i=r.map(a=>a.value):r&&typeof r=="object"&&"label"in r?i=r.value:r&&typeof r=="object"?i=r.toISOString():i=r||"",n[o]=i,n},{}),hV=e=>typeof e=="string"?/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/.test(e):typeof e=="object"&&"_isValid"in e,Kh=e=>Object.keys(e).sort((n,o)=>o.localeCompare(n)).reduce((n,o)=>{var r;return(typeof e[o]=="string"||typeof e[o]=="object"&&e[o]!==null)&&hV(e[o])?n[o]=(r=new Date(`${e[o]}`))==null?void 0:r.toString():n[o]=e[o],n},{}),Zh=Rh({name:"writeCapability",initialState:jh,reducers:{resetState:()=>jh,resetCurrentResourceDetails:e=>{e.currentResourceDetails=null,e.currentResourceDetailsApiStatus=Oe.IDLE},setCurrentCardInEdit:(e,t)=>{e.currentCardInEdit=t.payload},setHasUnsavedChanges:(e,t)=>{e.hasUnsavedChanges=t.payload}},extraReducers:e=>{e.addCase(Hl.pending,t=>{t.objectListApiStatus=Oe.LOADING}).addCase(Hl.fulfilled,(t,n)=>{const{createObjectList:o,linkObjectList:r,editObjectList:i,formFields:a,objectDict:A,dependentFieldsMap:l}=n.payload;t.objectListApiStatus=Oe.IDLE,t.createObjectList=o,t.linkObjectList=r,t.editObjectList=i,t.formFields=a,t.objectDict=A,t.dependentFieldsMap=l}).addCase(Hl.rejected,t=>{t.objectListApiStatus=Oe.FAILED}).addCase(Wl.pending,t=>{t.dropdownOptionsApis=Oe.LOADING}).addCase(Wl.fulfilled,(t,n)=>{const o=t.optionsMap||{},{optionsList:r,hasMore:i,currentPage:a,key:A}=n.payload;t.dropdownOptionsApis=Oe.IDLE,t.optionsMap={...o,[A]:{options:r,hasMore:i,currentPage:a}}}).addCase(Wl.rejected,t=>{t.dropdownOptionsApis=Oe.FAILED}).addCase(zl.pending,t=>{t.createFormApiStatus=Oe.LOADING}).addCase(zl.fulfilled,t=>{t.createFormApiStatus=Oe.IDLE}).addCase(zl.rejected,t=>{t.createFormApiStatus=Oe.FAILED}).addCase(Xl.pending,t=>{t.linkCardApiStatus=Oe.LOADING}).addCase(Xl.fulfilled,t=>{t.linkCardApiStatus=Oe.IDLE}).addCase(Xl.rejected,t=>{t.linkCardApiStatus=Oe.FAILED}).addCase(Gl.pending,t=>{t.unlinkCardApiStatus=Oe.LOADING}).addCase(Gl.fulfilled,t=>{t.unlinkCardApiStatus=Oe.IDLE}).addCase(Gl.rejected,t=>{t.unlinkCardApiStatus=Oe.FAILED}).addCase(Ea.pending,t=>{t.previewCardApiStatus=Oe.LOADING}).addCase(Ea.fulfilled,(t,n)=>{const{data:o}=n.payload;o&&(t.previewCardData=o),t.previewCardApiStatus=Oe.IDLE}).addCase(Ea.rejected,t=>{t.previewCardApiStatus=Oe.FAILED}).addCase(Yl.pending,t=>{t.updateFormApiStatus=Oe.LOADING}).addCase(Yl.fulfilled,t=>{t.updateFormApiStatus=Oe.IDLE}).addCase(Yl.rejected,t=>{t.updateFormApiStatus=Oe.FAILED}).addCase(Kl.pending,t=>{t.currentResourceDetailsApiStatus=Oe.LOADING}).addCase(Kl.fulfilled,(t,n)=>{const{data:o}=n.payload;o&&(t.currentResourceDetails=o),t.currentResourceDetailsApiStatus=Oe.IDLE}).addCase(Kl.rejected,t=>{t.currentResourceDetailsApiStatus=Oe.FAILED})}}),Hl=Eo("writeCapability/fetchObjectList",async e=>{const{inboxIds:t,channelType:n,conversationId:o}=e,r=await Tj({inboxIds:t,channelType:n,conversationId:o});if(!r||!r.data||!("formsList"in r.data)||!Array.isArray(r.data.formsList))return{createObjectList:[],linkObjectList:[],editObjectList:[],formFields:null,objectDict:null,dependentFieldsMap:{}};const i=r.data.formsList,a={},A=[],l=[],c=[],u={},C={};return i==null||i.forEach(d=>{var f,p;const h={...d};"fieldList"in h&&delete h.fieldList,C[d.id]=h,a[d.id]||(a[d.id]={}),u[d.id]||(u[d.id]=[]),d.type==="create"&&d.authenticated?A.push({value:d.id,label:d.name}):d.type==="link"&&d.authenticated?l.push({value:d.id,label:d.name}):d.type==="edit"&&d.authenticated&&c.push({value:d.id,label:d.name}),(f=d.fieldList)==null||f.sort((g,E)=>g.priority-E.priority),(p=d.fieldList)==null||p.forEach(g=>{var m,B,b,I,Q,w,T,S,O,D,R,P;let E={};switch(g.type){case"select":case"multi-select":{E={...g,defaultOptions:!!g.interfaceDetails,isInfiniteScrollable:((B=(m=g.interfaceDetails)==null?void 0:m.pagination)==null?void 0:B.enabled)||!1,loadOptionsOnFocus:Object.keys(((b=g.interfaceDetails)==null?void 0:b.args)||{}).length>0,isMultiSelect:g.type==="multi-select",type:d.interfaceDetails?"async-select":"select",isClearable:!0};break}case"date":{E={...g,type:"date",disablePast:!!((I=g.validations)!=null&&I.disablePast)||!1,disableFuture:!!((Q=g.validations)!=null&&Q.disableFuture)||!1};break}case"number":{E={...g,type:"number",min:((T=(w=g.validations)==null?void 0:w.range)==null?void 0:T.min)||Number.MIN_SAFE_INTEGER,max:((O=(S=g.validations)==null?void 0:S.range)==null?void 0:O.max)||Number.MAX_SAFE_INTEGER};break}case"multiline":{E={...g,type:"text",maxRows:((D=g.validations)==null?void 0:D.maxRows)||5,limit:(R=g.validations)==null?void 0:R.maxCharacters,rows:5,multiline:!0};break}case"text":{E={...g,type:"text",limit:(P=g.validations)==null?void 0:P.maxCharacters};break}default:E={...g}}if("value"in E&&(E.defaultValue=E.value,delete E.value),u[d.id]=[...u[d.id],E],g.interfaceDetails&&(g.interfaceDetails.args||g.interfaceDetails.optionalArgs)){const k={...g.interfaceDetails.args,...g.interfaceDetails.optionalArgs};Object.values(k).forEach(L=>{a[d.id][L]?a[d.id][L]=[...a[d.id][L],g.name]:a[d.id][L]=[g.name]})}})}),{createObjectList:A,linkObjectList:l,editObjectList:c,formFields:u,objectDict:C,dependentFieldsMap:a}}),Wl=Eo("writeCapability/fetchDropDownOptions",async(e,{getState:t,rejectWithValue:n})=>{var B;const{fieldName:o,formId:r,fieldConfig:i,callback:a,args:A={},interfaceId:l="",pagination:c={enabled:!1}}=e,u=Xh(A||{},r,o),{write:C}=t();let d=!1;i.meta&&"showAvatar"in i.meta&&typeof i.meta.showAvatar=="boolean"&&(d=i.meta.showAvatar);const{options:h=[],hasMore:f=!0,currentPage:p=0}=((B=C.optionsMap)==null?void 0:B[u])||{},{enabled:g,limit:E}=c,m=E||10;try{let b;const I=g?{pageNumber:p+1,limit:m}:null;if(f?b=await Fj({fieldName:o,formId:r},{pagination:I||{},args:A,interfaceId:l}):a==null||a(h),!b||!b.data||!("data"in b.data)||!Array.isArray(b.data.data))return{optionsList:[...h],fieldName:"",formId:"",hasMore:!1,currentPage:p,key:u};const w=b.data.data.map(O=>d?{...O,avatarUrl:O.avatarUrl||Zj}:{label:O.label,value:O.value}),T=g?w.length>=m:!1,S=[...h,...w];return a==null||a(S),{optionsList:S,fieldName:o,formId:r,currentPage:p+1,hasMore:T,key:u}}catch(b){return a==null||a(h),n(b)}},{condition:(e,{getState:t})=>{var c,u;if(e.isScrollToBottomEvent)return!0;const{fieldName:n,formId:o,callback:r,args:i}=e,a=Xh(i||{},o,n),{write:A}=t(),l=((u=(c=A.optionsMap)==null?void 0:c[a])==null?void 0:u.options)||[];return l&&l.length?(r==null||r(l),!1):!0}}),zl=Eo("writeCapability/createForm",async(e,{rejectWithValue:t})=>{const{formId:n,successCallback:o,failureCallback:r,args:i={},interfaceId:a,conversationId:A}=e;try{await Vh({formId:n},{args:i,interfaceId:a,conversationId:A}),o==null||o(),an({message:Xj,type:zr})}catch(l){return r==null||r(l),an({message:Kj,type:ar}),t(l)}}),Yl=Eo("writeCapability/updateForm",async(e,{rejectWithValue:t})=>{const{formId:n,successCallback:o,failureCallback:r,args:i={},interfaceId:a,conversationId:A,externalResourceId:l,previousArgs:c={}}=e;try{await Vh({formId:n},{args:i,interfaceId:a,conversationId:A,externalResourceId:l,previousArgs:c}),o==null||o(),an({message:iV,type:zr})}catch(u){return r==null||r(u),an({message:sV,type:ar}),t(u)}}),Gl=Eo("writeCapability/unlinkCard",async({id:e,channelType:t,externalResourceId:n,conversationId:o})=>{await Sj(e,t,n,o)}),Xl=Eo("writeCapability/linkCard",async({id:e,externalResourceId:t,channelType:n,conversationId:o})=>{await Oj(e,t,n,o)}),Ea=Eo("writeCapability/previewCard",async({id:e,args:t,channelType:n,isRefresh:o})=>{const r=await kj(e,t,n),i=r==null?void 0:r.data;if(!i)return o&&an({message:Lh,type:ar}),{data:null};if(o&&an({message:Uh,type:zr}),i.cardType==="flat"){const a=i.data.flatDisplay.data.filter(A=>Number(A.statusCode)!==ag.NOT_FOUND).sort((A,l)=>A.priority-l.priority);i.data.flatDisplay.data=a}else i.data.listItems.fields.forEach(a=>a.data.sort((A,l)=>A.priority-l.priority));return{data:i}}),Kl=Eo("connectorCardLibrary/fetchCurrentResourceDetails",async(e,{rejectWithValue:t})=>{const{id:n,channelType:o,conversationId:r,externalResourceId:i,contactEmail:a}=e;try{const A=await Mj(n,o,r,i,a),l=A==null?void 0:A.data,c=A==null?void 0:A.status,u={values:{},errors:{}};return Object.entries(l.formData).forEach(([C,d])=>{"label"in d&&(d.type&&d.type==="date"?u.values[C]=d.label?new Date(parseInt(d.label)).toISOString():"":d.type&&d.type==="multi-select"&&"value"in d&&"label"in d&&d.value&&d.label?u.values[C]=[{value:d.value,label:d.label}]:d.value?u.values[C]={value:d.value,label:d.label}:u.values[C]=d.label)}),{data:u,status:c}}catch(A){return an({message:Nh,type:ar}),t(A)}}),{resetState:TG,setCurrentCardInEdit:Ia,resetCurrentResourceDetails:BV,setHasUnsavedChanges:Jh}=Zh.actions,mV=Zh.reducer,QV=()=>{const[e,t]=y.useState(null),[n,o]=y.useState({isVertical:!1,isHorizontal:!1,isScrolling:!1}),r=y.useCallback(i=>{t(i)},[]);return y.useEffect(()=>{if(!e)return;e.dataset.prevScrollLeft="0",e.dataset.prevScrollTop="0";let i=null;const a=100;let A=null;const l=150,c=u=>{i||(i=window.setTimeout(()=>{const C=u.target,d=Number(e.dataset.prevScrollLeft)||0,h=Number(e.dataset.prevScrollTop)||0,f=C.scrollLeft,p=C.scrollTop,g=f-d,E=p-h,m=Math.abs(E)>Math.abs(g),B=Math.abs(g)>Math.abs(E);o({isVertical:m,isHorizontal:B,isScrolling:!0}),e.dataset.prevScrollLeft=String(f),e.dataset.prevScrollTop=String(p),i=null},a),A&&window.clearTimeout(A),A=window.setTimeout(()=>{o(C=>({...C,isScrolling:!1})),A=null},l))};return e.addEventListener("scroll",c),()=>{e.removeEventListener("scroll",c),i&&window.clearTimeout(i),A&&window.clearTimeout(A)}},[e]),[n,r]},bV="data:image/svg+xml,%3csvg%20width='18'%20height='18'%20viewBox='0%200%2018%2018'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M5.8016%2011.709L12.3416%205.16893L11.4298%204.25712L4.88979%2010.7972V11.709H5.8016ZM6.33618%2012.9987H3.6001V10.2626L10.9739%202.88875C11.0948%202.76786%2011.2588%202.69995%2011.4298%202.69995C11.6008%202.69995%2011.7648%202.76786%2011.8857%202.88875L13.71%204.71302C13.8309%204.83395%2013.8988%204.99794%2013.8988%205.16893C13.8988%205.33992%2013.8309%205.50391%2013.71%205.62484L6.33618%2012.9987ZM3.6001%2014.2884H15.2073V15.578H3.6001V14.2884Z'%20fill='%236C7B94'/%3e%3c/svg%3e",vV=({data:e,title:t,currentCard:n,setShowModal:o})=>{const r=Lr(),[i,a]=QV(),{isScrolling:A,isVertical:l}=i,c=A&&l,u=y.useMemo(()=>(e==null?void 0:e[0].data.map(f=>f.label))||[],[e]),C=y.useMemo(()=>e.map(f=>{const p={cells:{}};return p.externalResourceId=f.externalResourceId,f.data.forEach((g,E)=>{if(u[E]){let m=g.value?g.value:Fl;m&&g.type==="date"&&(m=new Date(parseInt(m)).toLocaleDateString(navigator.language)),p.cells[u[E]]={label:m,deepLink:g==null?void 0:g.deepLink}}}),p}),[e,u]),d=(f,p)=>v.jsx(kU,{align:"left",children:f.deepLink?v.jsx(PA,{target:"_blank",underline:"none",href:f.deepLink,children:f.label}):v.jsx(We,{variant:"body2",color:"gray.black",children:f.label})},`${p}_${f.label}`),h=f=>{!f||!n||(o(!1),r(Ia({...n,externalResourceId:f})))};return v.jsxs(Ue,{maxHeight:"340px",maxWidth:"700px",padding:"32px 0px 32px 32px",overflow:"auto",children:[v.jsx(We,{variant:"h2",color:"gray.black",marginBottom:"16px",children:t}),v.jsx(tC,{ref:a,children:v.jsxs(q1,{stickyHeader:!0,children:[v.jsx(FU,{children:v.jsxs(Wu,{children:[u.map(f=>v.jsx(SU,{children:v.jsx(We,{variant:"overline",color:"gray.gray3",children:f})},f)),v.jsx(DU,{})]})}),v.jsx(eC,{children:C.map((f,p)=>v.jsxs(OU,{children:[Object.values(f.cells).map((g,E)=>d(g,E)),v.jsx(MU,{children:!c&&f.externalResourceId&&v.jsx(Ut,{title:D2,placement:"right",children:v.jsx(_t,{className:"row-edit",onClick:()=>h(f.externalResourceId),children:v.jsx("img",{src:bV})})})})]},`id_${p}`))})]})})]})},yV="data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_602_78902)'%3e%3cpath%20d='M0.666992%2013.9999H15.3337L8.00033%201.33325L0.666992%2013.9999ZM8.66699%2011.9999H7.33366V10.6666H8.66699V11.9999ZM8.66699%209.33325H7.33366V6.66659H8.66699V9.33325Z'%20fill='%23F07530'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_602_78902'%3e%3crect%20width='16'%20height='16'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",_h=e=>{const{value:t,error:n,deepLink:o,statusCode:r,isLoading:i,type:a}=e,A=y.useRef(null),l=y.useRef(null),[c,u]=y.useState(!1);y.useEffect(()=>{const f=o?l.current:A.current;if(f){const p=f.scrollHeight>f.clientHeight||f.scrollWidth>f.clientWidth;u(p)}},[t,o]);const C=r==ag.NOT_FOUND;let d=C?Fl:t;a==="date"&&d&&!C&&(d=new Date(parseInt(d)).toLocaleDateString(navigator.language));const h=!C&&!!n;return i?v.jsx(Ur,{variant:"rounded",width:"100%",height:16,animation:"wave",margin:"4px 0 0 0"}):h?v.jsxs(q2,{gap:"5px",children:[v.jsx("img",{src:yV}),v.jsx($2,{variant:"body2",children:$R})]}):v.jsx(Ut,{title:c?d:null,placement:"bottom",children:o?v.jsx(eh,{ref:l,target:"_blank",underline:"none",href:o,fontSize:"13px",children:d||Fl}):v.jsx(TU,{ref:A,variant:"body2",children:d||Fl})})},wV="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_825_73646)'%3e%3cpath%20d='M19%206.41L17.59%205L12%2010.59L6.41%205L5%206.41L10.59%2012L5%2017.59L6.41%2019L12%2013.41L17.59%2019L19%2017.59L13.41%2012L19%206.41Z'%20fill='%236F7C90'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_825_73646'%3e%3crect%20width='24'%20height='24'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",kg=({shown:e,setShown:t,children:n,showCloseButton:o=!1,borderRadius:r=4})=>v.jsx(ku,{open:e,onClose:()=>t(!1),PaperProps:{style:{borderRadius:r,padding:0,height:"fit-content",width:"fit-content",maxWidth:"none"}},children:v.jsxs(Ue,{direction:"row",children:[o&&v.jsx(dt,{position:"absolute",right:10,top:10,children:v.jsx(Ut,{title:"Close",placement:"bottom",children:v.jsx(_t,{onClick:()=>t(!1),children:v.jsx("img",{src:wV})})})}),n]})}),qh=e=>{var H,G;const{id:t,cardTitle:n,specificCardData:o,specificConnectorApiStatus:r,isOpen:i,currentCard:a}=e,A=24,l=(r==null?void 0:r[t])===Oe.IDLE,c=(r==null?void 0:r[t])===Oe.LOADING,u=(r==null?void 0:r[t])===Oe.FAILED,{cardType:C,data:d}=(o==null?void 0:o[t])||{},h=C==="flat",[f,p]=y.useState(!1),[g,E]=y.useState(!1),[m,B]=y.useState(!1),[b,I]=y.useState(!1),Q=y.useMemo(()=>{var M,z,X,Y;return h&&((M=d==null?void 0:d.flatDisplay)!=null&&M.data)?d.flatDisplay.data:!h&&((Y=(X=(z=d==null?void 0:d.listItems)==null?void 0:z.fields)==null?void 0:X[0])!=null&&Y.data)?d==null?void 0:d.listItems.fields[0].data:[]},[h,d]),w=y.useMemo(()=>Q==null?void 0:Q.slice(0,5),[Q]),[T,S]=y.useState([]),O=y.useRef(null),[D,R]=y.useState(0),P=f?-180:0,k=h?!1:!!((H=d==null?void 0:d.listItems)!=null&&H.errorMessage),L=k||u,U=l&&!k&&i&&(m||g);y.useLayoutEffect(()=>{var M;(M=O.current)!=null&&M.scrollHeight&&R(O.current.scrollHeight+A)},[r==null?void 0:r[t],T,O]),y.useEffect(()=>{var Y,K;const M=((Q==null?void 0:Q.length)||0)>5,z=!h&&(((K=(Y=d==null?void 0:d.listItems)==null?void 0:Y.fields)==null?void 0:K.length)||0)>1;B(M&&!z),E(z)},[d,h,Q==null?void 0:Q.length]),y.useEffect(()=>{S(f?Q:w)},[d,f,w,Q]);const W=()=>{m?p(M=>!M):I(M=>!M)};return v.jsxs(v.Fragment,{children:[v.jsx(kg,{shown:b,setShown:I,showCloseButton:!0,borderRadius:12,children:v.jsx(vV,{data:((G=d==null?void 0:d.listItems)==null?void 0:G.fields)||[],title:n,currentCard:a,setShowModal:I})}),v.jsx(yU,{className:i?"":"slideUp",height:D,children:v.jsx(Ue,{ref:O,gap:1,margin:"12px",children:c&&(!(T!=null&&T.length)||L)?v.jsxs(v.Fragment,{children:[v.jsx(Ur,{variant:"rounded",width:"100%",height:20,animation:"wave"}),v.jsx(Ur,{variant:"rounded",width:"100%",height:20,animation:"wave"})]}):v.jsx(v.Fragment,{children:L?v.jsx(dt,{margin:"8px 0",children:v.jsx(_h,{error:L,isLoading:c})}):T!=null&&T.length?T==null?void 0:T.map(M=>{const{value:z,label:X,deepLink:Y,type:K}=M,q="errorMessage"in M?M.errorMessage:null,te="statusCode"in M?M.statusCode:null;return v.jsxs("div",{children:[v.jsx(wU,{variant:"overline",children:X}),v.jsx(_h,{value:z,error:q,deepLink:Y,statusCode:te,isLoading:c,type:K})]},X)}):v.jsx(dt,{margin:"8px 0",children:v.jsx($2,{children:eL})})})})}),U&&v.jsx(RU,{variant:"body2_medium",onClick:W,children:m?v.jsxs(v.Fragment,{children:[f?KU:th,v.jsx(PU,{src:XU,transformAngle:P})]}):th})]})},xV={connectorCards:null,cardSpecificData:null,connectorApiStatus:Oe.IDLE,specificConnectorApiStatus:null,threadId:null,connectorsEnabled:!1},$h="/v1/api",TV=`${$h}/connectors/cards`,FV=`${$h}/connectors/cards/:id/data`,SV=({inboxIds:e,conversationId:t,channelType:n="email"})=>{const o=new URLSearchParams;return e.forEach(r=>o.append("inbox_ids",r)),o.append("channel_type",n),o.append("conversation_id",String(t||"")),Co({url:`${TV}?${o.toString()}`,method:jo.GET})},OV=(e,t,n,o)=>{const r=new URLSearchParams;return r.append("senderEmail",t),r.append("conversation_id",String(n||"")),o&&r.append("externalResourceId",o),Co({url:`${FV.replace(":id",e)}?${r.toString()}`,method:jo.GET})},kV=e=>e.cardList.connectorCards,MV=e=>e.cardList.connectorsEnabled,DV=e=>e.cardList.connectorApiStatus,PV=e=>e.cardList.cardSpecificData,RV=e=>e.cardList.specificConnectorApiStatus,eB=Rh({name:"connectorCardLibrary",initialState:xV,reducers:{updateThreadId(e,t){const{payload:n}=t;e.threadId=n.threadId,e.connectorCards=null},clearConnectorList(e){e.connectorCards=null,e.cardSpecificData=null}},extraReducers:e=>{e.addCase(Zl.pending,t=>{t.connectorApiStatus=Oe.LOADING}).addCase(Zl.fulfilled,(t,n)=>{t.connectorApiStatus=Oe.IDLE,t.connectorCards=n.payload.cards,t.connectorsEnabled=n.payload.connectorsEnabled}).addCase(Zl.rejected,t=>{t.connectorApiStatus=Oe.FAILED}).addCase(ha.pending,(t,n)=>{const{id:o,externalResourceId:r=""}=n.meta.arg;let i=o;r&&(i=`${i}_${r}`),t.specificConnectorApiStatus={...t.specificConnectorApiStatus??{},[i]:Oe.LOADING}}).addCase(ha.fulfilled,(t,n)=>{const{id:o,externalResourceId:r=""}=n.meta.arg;let i=o;r&&(i=`${i}_${r}`);const{data:a}=n.payload||{};a&&(t.cardSpecificData={...t.cardSpecificData?t.cardSpecificData:{},[i]:a}),t.specificConnectorApiStatus={...t.specificConnectorApiStatus??{},[i]:Oe.IDLE}}).addCase(ha.rejected,(t,n)=>{const{id:o,externalResourceId:r=""}=n.meta.arg;let i=o;r&&(i=`${i}_${r}`),t.specificConnectorApiStatus={...t.specificConnectorApiStatus??{},[i]:Oe.FAILED}})}}),Zl=Eo("connectorCardLibrary/fetchAllCard",async({inboxIds:e,channelType:t,conversationId:n})=>{var A;const o=await SV({inboxIds:e,channelType:t,conversationId:n});if(!Array.isArray((A=o==null?void 0:o.data)==null?void 0:A.cards))return{cards:[],connectorsEnabled:!1};const{cards:r,connectorsEnabled:i=!1}=o.data;return{cards:r.sort((l,c)=>(l==null?void 0:l.priority)-(c==null?void 0:c.priority)),connectorsEnabled:i}}),ha=Eo("connectorCardLibrary/fetchSpecificCard",async({id:e,email:t,conversationId:n,isRefresh:o,externalResourceId:r},i)=>{try{const a=await OV(e,t,n,r),A=a==null?void 0:a.data,l=a==null?void 0:a.status;if(!A)return o&&an({message:Lh,type:ar}),{data:{},status:l};if(o&&an({message:Uh,type:zr}),A.cardType==="flat"){const c=A.data.flatDisplay.data.filter(u=>Number(u.statusCode)!==ag.NOT_FOUND).sort((u,C)=>(u==null?void 0:u.priority)-(C==null?void 0:C.priority));A.data.flatDisplay.data=c}else A.data.listItems.fields.forEach(c=>c.data.sort((u,C)=>(u==null?void 0:u.priority)-(C==null?void 0:C.priority)));return{data:A,status:l}}catch(a){return i.rejectWithValue(a)}}),LV=eB.reducer,tB=eB.actions,nB="data:image/svg+xml,%3csvg%20width='12'%20height='12'%20viewBox='0%200%2012%2012'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M9.76618%202.23341C8.79952%201.26675%207.47285%200.666748%205.99952%200.666748C3.05285%200.666748%200.672852%203.05341%200.672852%206.00008C0.672852%208.94675%203.05285%2011.3334%205.99952%2011.3334C8.48619%2011.3334%2010.5595%209.63341%2011.1529%207.33341H9.76618C9.21952%208.88675%207.73952%2010.0001%205.99952%2010.0001C3.79285%2010.0001%201.99952%208.20675%201.99952%206.00008C1.99952%203.79341%203.79285%202.00008%205.99952%202.00008C7.10618%202.00008%208.09285%202.46008%208.81285%203.18675L6.66618%205.33341H11.3329V0.666748L9.76618%202.23341Z'%20fill='%236C7B94'/%3e%3c/svg%3e",UV="data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M11.4587%206.7528C11.2244%206.51848%2010.8445%206.51848%2010.6102%206.7528C10.3759%206.98711%2010.3759%207.36701%2010.6102%207.60132L11.4587%206.7528ZM12.1916%208.33414L12.6158%207.90988L12.1916%208.33414ZM8.33462%2012.1911L8.75888%2011.7668L8.33462%2012.1911ZM7.6018%2010.6097C7.36748%2010.3754%206.98758%2010.3754%206.75327%2010.6097C6.51895%2010.8441%206.51895%2011.224%206.75327%2011.4583L7.6018%2010.6097ZM4.43911%209.14411C4.67343%209.37842%205.05333%209.37842%205.28764%209.14411C5.52196%208.9098%205.52196%208.5299%205.28764%208.29558L4.43911%209.14411ZM3.70629%207.56276L4.13056%207.1385L3.70629%207.56276ZM7.56324%203.70582L7.9875%203.28155L7.56324%203.70582ZM8.29606%205.28716C8.53037%205.52148%208.91027%205.52148%209.14459%205.28716C9.3789%205.05285%209.3789%204.67295%209.14459%204.43864L8.29606%205.28716ZM10.6102%207.60132L11.7673%208.75841L12.6158%207.90988L11.4587%206.7528L10.6102%207.60132ZM11.7673%208.75841C12.1662%209.15735%2012.3904%209.69843%2012.3904%2010.2626L13.5904%2010.2626C13.5904%209.38017%2013.2398%208.53387%2012.6158%207.90988L11.7673%208.75841ZM12.3904%2010.2626C12.3904%2010.8268%2012.1662%2011.3679%2011.7673%2011.7668L12.6158%2012.6154C13.2398%2011.9914%2013.5904%2011.1451%2013.5904%2010.2626L12.3904%2010.2626ZM11.7673%2011.7668C10.9365%2012.5976%209.58963%2012.5976%208.75888%2011.7668L7.91035%2012.6154C9.20973%2013.9147%2011.3164%2013.9147%2012.6158%2012.6154L11.7673%2011.7668ZM8.75888%2011.7668L7.6018%2010.6097L6.75327%2011.4583L7.91035%2012.6154L8.75888%2011.7668ZM5.28764%208.29558L4.13056%207.1385L3.28203%207.98703L4.43911%209.14411L5.28764%208.29558ZM4.13056%207.1385C3.73162%206.73956%203.50749%206.19848%203.50749%205.63429L2.30749%205.63429C2.30749%206.51674%202.65804%207.36304%203.28203%207.98703L4.13056%207.1385ZM3.50749%205.63429C3.50749%205.0701%203.73162%204.52902%204.13056%204.13008L3.28203%203.28155C2.65804%203.90554%202.30749%204.75184%202.30749%205.63429L3.50749%205.63429ZM4.13056%204.13008C4.96131%203.29933%206.30822%203.29933%207.13897%204.13008L7.9875%203.28155C6.68812%201.98217%204.58141%201.98217%203.28203%203.28155L4.13056%204.13008ZM7.13897%204.13008L8.29606%205.28716L9.14459%204.43864L7.9875%203.28155L7.13897%204.13008Z'%20fill='%236C7B94'/%3e%3crect%20x='5.08887'%20y='6.0791'%20width='1.33333'%20height='6.66667'%20rx='0.666667'%20transform='rotate(-45%205.08887%206.0791)'%20fill='%236C7B94'/%3e%3cpath%20d='M5.59961%2014.3998V12.7998'%20stroke='%236C7B94'%20stroke-width='1.2'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M12.7998%205.59961H14.3998'%20stroke='%236C7B94'%20stroke-width='1.2'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M2.40039%2011.2002H4.00039'%20stroke='%236C7B94'%20stroke-width='1.2'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M11.2002%202.40039V4.00039'%20stroke='%236C7B94'%20stroke-width='1.2'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",NV="data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_5908_39767)'%3e%3cpath%20d='M9.37333%206.01333L9.98667%206.62667L3.94667%2012.6667H3.33333V12.0533L9.37333%206.01333ZM11.7733%202C11.6067%202%2011.4333%202.06667%2011.3067%202.19333L10.0867%203.41333L12.5867%205.91333L13.8067%204.69333C14.0667%204.43333%2014.0667%204.01333%2013.8067%203.75333L12.2467%202.19333C12.1133%202.06%2011.9467%202%2011.7733%202ZM9.37333%204.12667L2%2011.5V14H4.5L11.8733%206.62667L9.37333%204.12667Z'%20fill='%236C7B94'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_5908_39767'%3e%3crect%20width='16'%20height='16'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",oB=e=>e.write.createObjectList,rB=e=>e.write.linkObjectList,jV=e=>e.write.editObjectList,VV=e=>e.write.objectDict,HV=e=>e.write.formFields,WV=e=>e.write.previewCardData,zV=e=>e.write.previewCardApiStatus,YV=e=>e.write.linkCardApiStatus,GV=e=>e.write.unlinkCardApiStatus,XV=e=>e.write.dependentFieldsMap,KV=e=>e.write.createFormApiStatus,ZV=e=>e.write.updateFormApiStatus,JV=e=>e.write.currentResourceDetails,_V=e=>e.write.currentResourceDetailsApiStatus,iB=e=>e.write.currentCardInEdit,sB=e=>e.write.hasUnsavedChanges,qV=({showUnlinkModal:e,setShowUnlinkModal:t,cardId:n,onCardUnlinking:o,externalResourceId:r,conversationId:i,connectorName:a})=>{const A=Lr(),{sendTrackingEvent:l}=y.useContext(Lo),u=wt(GV)===Oe.LOADING,C=()=>{i&&r&&A(Gl({id:n,conversationId:i,externalResourceId:r})).unwrap().then(()=>{l(FL,{connector_name:a,conversation_id:i}),t(!1),o(),an({message:dj,type:zr})}).catch(()=>{an({message:gj,type:zr})})};return v.jsx(kg,{shown:e,setShown:t,showCloseButton:!0,children:v.jsxs(Ue,{width:"400px",padding:"20px",gap:"8px",children:[v.jsx(We,{variant:"h2",children:aL}),v.jsx(We,{variant:"body2",children:AL}),v.jsxs(Ue,{direction:"row",gap:"8px",marginTop:"20px",justifyContent:"flex-end",children:[v.jsx(zt,{variant:"text",onClick:()=>t(!1),children:lg}),v.jsx(zt,{disabled:u,color:"error",onClick:C,children:M2})]})]})})},$V=e=>{const{card:t,specificCardData:n,email:o,specificConnectorApiStatus:r,defaultOpenState:i=!1,onCardUnlinking:a}=e,A=Lr(),{availableFeatures:l,sendTrackingEvent:c,conversationId:u,currentSmIds:C}=y.useContext(Lo),d=dl(),[h,f]=y.useState(!!i),[p,g]=y.useState(!1),[E,m]=y.useState(!1),{id:B,title:b,externalResourceId:I="",connectorName:Q="",forms:w}=t;let T=B;I&&(T=`${T}_${I}`);const{data:S,cardType:O}=(n==null?void 0:n[T])??{},D=(r==null?void 0:r[T])===Oe.LOADING,R=!!(zi(l,S2)&&I),P=y.useMemo(()=>{var G,M;if(!(zi(l,qR)&&w.some(z=>z.type==="edit")))return!1;switch(O){case"flat":return!!(S!=null&&S.flatDisplay.externalResourceId);case"flat_with_list":return((G=S==null?void 0:S.listItems)==null?void 0:G.fields.length)===1?(M=S==null?void 0:S.listItems)==null?void 0:M.fields.some(z=>z.externalResourceId):!1;default:return!1}},[S,O,l,w]),k=y.useCallback((G=!1)=>{const M=G?DL:ML;o&&B&&u&&A(ha({id:B,email:o,conversationId:u,externalResourceId:I})).unwrap().then(z=>{const X=N2(z,b,G,!0);c(M,X)}).catch(z=>{const X=N2(z,b,G,!1);c(M,X)})},[A,o,B,b,c,u,I]);y.useEffect(()=>{i&&k(!0)},[i,k]);const L=(G,M)=>{var X;G==null||G.stopPropagation(),A(ha({id:M,email:o,conversationId:u,isRefresh:!0,externalResourceId:I})).unwrap().then(()=>{c(hL,{id:M})});const z=G.target.tagName==="BUTTON"?(X=G.target)==null?void 0:X.firstChild:G.target;z.className&&(z.className=""),setTimeout(()=>z.className="selected",1)},U=(G,M)=>{G.stopPropagation(),!(n!=null&&n[M])&&!D&&k(),c(h?IL:EL,{id:M}),f(z=>!z)},W=G=>{G.stopPropagation();const M=G.currentTarget.offsetWidth<G.currentTarget.scrollWidth;g(!!M)},H=()=>{var M,z;c(LL,{card_title:b,connector_name:Q,ug_id:d,sm_ids:C});let G;O==="flat"?G=S==null?void 0:S.flatDisplay.externalResourceId:O==="flat_with_list"&&(G=(z=(M=S==null?void 0:S.listItems)==null?void 0:M.fields[0])==null?void 0:z.externalResourceId),G?A(Ia({...t,externalResourceId:G})):an({message:Nh,type:ar})};return v.jsxs(QU,{"data-testid":`test_${B}`,children:[v.jsxs(bU,{className:h?"hiver-card-expanded":"",children:[v.jsx(Ut,{title:p?b:"",placement:"bottom",children:v.jsx(vU,{variant:"h4",onMouseOver:G=>W(G),onMouseLeave:G=>W(G),children:b})}),v.jsxs(q2,{children:[P?v.jsx(Ut,{title:D2,placement:"bottom",children:v.jsx(Nr,{onClick:H,children:v.jsx("img",{src:NV})})}):null,R?v.jsx(Ut,{title:M2,placement:"bottom",children:v.jsx(Nr,{onClick:()=>m(!0),children:v.jsx("img",{src:UV})})}):null,h?v.jsx(Ut,{title:O2,placement:"bottom",children:v.jsx(Nr,{"data-testid":D?"loading":"reloadIcon",onClick:G=>L(G,B),className:D?"disabled":"",children:v.jsx("img",{src:nB})})}):null,v.jsx(Ut,{title:h?k2:Ag,placement:"bottom",children:v.jsx(Nr,{onClick:G=>U(G,T),children:v.jsx(Eg,{className:h?"":"hiver-up"})})})]})]}),v.jsx(qh,{id:T,cardTitle:t.title,currentCard:t,specificCardData:n,specificConnectorApiStatus:r,isOpen:h}),v.jsx(qV,{showUnlinkModal:E,setShowUnlinkModal:m,cardId:B,onCardUnlinking:a,conversationId:u,externalResourceId:I,connectorName:Q})]})},eH="Bring your favourite tools into Hiver",tH="Plugin image",nH="Integrate tools like Salesforce, HubSpot, and Shopify to boost productivity",oH="Enable Connectors",aB="app/custom-connectors",rH="Learn more",iH="https://help.hiverhq.com/custom-connectors/hiver-s-custom-connectors",sH="Contact your admin to enable this",aH="https://youtu.be/ODcJnzZLb50",AH="connectors-module/assets/connectors-images/connector-mainpage.png",lH="Explore connectors",cH="Connectors",uH=V(Ue)`
|
|
2419
|
+
Do you want to continue?`,tV="Select an object to create",nV="Select an object to link",zh="Select object",oV="Paste URL or ID",rV="Object ID/Link",iV="Card updated",sV="Card updation failed",aV="Required Field",AV="Invalid date",Yh=/^https:\/\/([a-z0-9-]+(\.[a-z0-9-]+)+)(:[0-9]{1,5})?(\/[^\s/]*)*$/i,lV=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,cV=(e,t)=>t?Object.values(t).filter(o=>e.values[o]&&!e.errors[o]):[],Gh=(e,t)=>t?Object.keys(t).reduce((o,r)=>{let i="";const a=t[r];return e.values&&e.values[a]&&typeof e.values[a]=="object"&&"value"in e.values[a]?i=e.values[a].value:e.values&&e.values[a]&&typeof e.values[a]!="object"?i=e.values[a]:i=null,{...o,[r]:i}},{}):{},Xh=(e,t,n)=>{let o=`${t}_${n}`;return Object.keys(e).forEach(r=>{o=`${o}_${r}:${e[r]}`}),o},uV=e=>t=>{if(t&&typeof t=="string"){const n=t.replace(/\/$/,"");return n.startsWith("https://")?t.endsWith("/")?jj:Yh.test(n)?!0:e||Hh:Nj}return!1},dV=e=>t=>t&&typeof t=="string"?lV.test(t)?!0:e||Vj:Hj,gV=e=>t=>t==null||t===""?e||aV:!0,fV=e=>(t,n)=>{var o;if(!t||(t==null?void 0:t.toString())===AV)return Wh;if(typeof t=="object"){const r=t,i=new Date;i.setHours(0,0,0,0);const a=n.disablePast,A=n.disableFuture;return a&&r<i?e||Wj:A&&r>i?e||zj:!0}return typeof t=="string"&&((o=new Date(t))==null?void 0:o.toString())!=="Invalid Date"?!0:Wh},pV=e=>(t,n)=>{if(t=Number(t),typeof t=="number"&&!isNaN(t)){const o=n.min,r=n.max;return o!==void 0&&t<o?e||`Value should not be less than ${o}`:r!==void 0&&t>r?e||`Value should not be greater than ${r}`:!0}return e||Yj},CV=e=>(t,n)=>{if(typeof t=="string"){const o=n.limit;return o!==void 0&&t.length>o?e||`Maximum characters allowed are ${o}`:!0}return e||Gj},EV=e=>t=>typeof t=="string"?t.startsWith("https:")?Yh.test(t)?!0:e||Hh:t.trim().length>0?!0:e||Lj:e||Uj,IV=({formFields:e})=>{const t={};return e.forEach(n=>{var o,r,i,a,A,l;if(t[n.name]={},(o=n.validations)!=null&&o.isRequired&&(typeof n.validations.isRequired=="object"?t[n.name].isRequired=gV(n.validations.isRequired.msg):t[n.name].isRequired=!0),n.type==="date"){let c=typeof((r=n.validations)==null?void 0:r.disableFuture)=="object"?n.validations.disableFuture.msg:"";c=typeof((i=n.validations)==null?void 0:i.disablePast)=="object"?n.validations.disablePast.msg:c,t[n.name].validate=fV(c);return}if(n.type==="number"&&((a=n.validations)!=null&&a.range)){t[n.name].validate=pV();return}if(n.type==="text"&&n.limit){t[n.name].validate=CV();return}if((A=n.validations)!=null&&A.isUrl){const c=typeof n.validations.isUrl=="object"?n.validations.isUrl.msg:"";t[n.name].validate=uV(c)}else if((l=n.validations)!=null&&l.isEmail){const c=typeof n.validations.isEmail=="object"?n.validations.isEmail.msg:"";t[n.name].validate=dV(c)}}),t},Og=(e,t)=>Object.keys(t).reduce((n,o)=>{const r=e.values[t[o]];let i;return Array.isArray(r)?i=r.map(a=>a.value):r&&typeof r=="object"&&"label"in r?i=r.value:r&&typeof r=="object"?i=r.toISOString():i=r||"",n[o]=i,n},{}),hV=e=>typeof e=="string"?/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/.test(e):typeof e=="object"&&"_isValid"in e,Kh=e=>Object.keys(e).sort((n,o)=>o.localeCompare(n)).reduce((n,o)=>{var r;return(typeof e[o]=="string"||typeof e[o]=="object"&&e[o]!==null)&&hV(e[o])?n[o]=(r=new Date(`${e[o]}`))==null?void 0:r.toString():n[o]=e[o],n},{}),Zh=Rh({name:"writeCapability",initialState:jh,reducers:{resetState:()=>jh,resetCurrentResourceDetails:e=>{e.currentResourceDetails=null,e.currentResourceDetailsApiStatus=Oe.IDLE},setCurrentCardInEdit:(e,t)=>{e.currentCardInEdit=t.payload},setHasUnsavedChanges:(e,t)=>{e.hasUnsavedChanges=t.payload}},extraReducers:e=>{e.addCase(Hl.pending,t=>{t.objectListApiStatus=Oe.LOADING}).addCase(Hl.fulfilled,(t,n)=>{const{createObjectList:o,linkObjectList:r,editObjectList:i,formFields:a,objectDict:A,dependentFieldsMap:l}=n.payload;t.objectListApiStatus=Oe.IDLE,t.createObjectList=o,t.linkObjectList=r,t.editObjectList=i,t.formFields=a,t.objectDict=A,t.dependentFieldsMap=l}).addCase(Hl.rejected,t=>{t.objectListApiStatus=Oe.FAILED}).addCase(Wl.pending,t=>{t.dropdownOptionsApis=Oe.LOADING}).addCase(Wl.fulfilled,(t,n)=>{const o=t.optionsMap||{},{optionsList:r,hasMore:i,currentPage:a,key:A}=n.payload;t.dropdownOptionsApis=Oe.IDLE,t.optionsMap={...o,[A]:{options:r,hasMore:i,currentPage:a}}}).addCase(Wl.rejected,t=>{t.dropdownOptionsApis=Oe.FAILED}).addCase(zl.pending,t=>{t.createFormApiStatus=Oe.LOADING}).addCase(zl.fulfilled,t=>{t.createFormApiStatus=Oe.IDLE}).addCase(zl.rejected,t=>{t.createFormApiStatus=Oe.FAILED}).addCase(Xl.pending,t=>{t.linkCardApiStatus=Oe.LOADING}).addCase(Xl.fulfilled,t=>{t.linkCardApiStatus=Oe.IDLE}).addCase(Xl.rejected,t=>{t.linkCardApiStatus=Oe.FAILED}).addCase(Gl.pending,t=>{t.unlinkCardApiStatus=Oe.LOADING}).addCase(Gl.fulfilled,t=>{t.unlinkCardApiStatus=Oe.IDLE}).addCase(Gl.rejected,t=>{t.unlinkCardApiStatus=Oe.FAILED}).addCase(Ea.pending,t=>{t.previewCardApiStatus=Oe.LOADING}).addCase(Ea.fulfilled,(t,n)=>{const{data:o}=n.payload;o&&(t.previewCardData=o),t.previewCardApiStatus=Oe.IDLE}).addCase(Ea.rejected,t=>{t.previewCardApiStatus=Oe.FAILED}).addCase(Yl.pending,t=>{t.updateFormApiStatus=Oe.LOADING}).addCase(Yl.fulfilled,t=>{t.updateFormApiStatus=Oe.IDLE}).addCase(Yl.rejected,t=>{t.updateFormApiStatus=Oe.FAILED}).addCase(Kl.pending,t=>{t.currentResourceDetailsApiStatus=Oe.LOADING}).addCase(Kl.fulfilled,(t,n)=>{const{data:o}=n.payload;o&&(t.currentResourceDetails=o),t.currentResourceDetailsApiStatus=Oe.IDLE}).addCase(Kl.rejected,t=>{t.currentResourceDetailsApiStatus=Oe.FAILED})}}),Hl=Eo("writeCapability/fetchObjectList",async e=>{const{inboxIds:t,channelType:n,conversationId:o}=e,r=await Tj({inboxIds:t,channelType:n,conversationId:o});if(!r||!r.data||!("formsList"in r.data)||!Array.isArray(r.data.formsList))return{createObjectList:[],linkObjectList:[],editObjectList:[],formFields:null,objectDict:null,dependentFieldsMap:{}};const i=r.data.formsList,a={},A=[],l=[],c=[],u={},C={};return i==null||i.forEach(d=>{var f,p;const h={...d};"fieldList"in h&&delete h.fieldList,C[d.id]=h,a[d.id]||(a[d.id]={}),u[d.id]||(u[d.id]=[]),d.type==="create"&&d.authenticated?A.push({value:d.id,label:d.name}):d.type==="link"&&d.authenticated?l.push({value:d.id,label:d.name}):d.type==="edit"&&d.authenticated&&c.push({value:d.id,label:d.name}),(f=d.fieldList)==null||f.sort((g,E)=>g.priority-E.priority),(p=d.fieldList)==null||p.forEach(g=>{var m,B,b,I,Q,w,T,S,O,D,R,P;let E={};switch(g.type){case"select":case"multi-select":{E={...g,defaultOptions:!!g.interfaceDetails,isInfiniteScrollable:((B=(m=g.interfaceDetails)==null?void 0:m.pagination)==null?void 0:B.enabled)||!1,loadOptionsOnFocus:Object.keys(((b=g.interfaceDetails)==null?void 0:b.args)||{}).length>0,isMultiSelect:g.type==="multi-select",type:d.interfaceDetails?"async-select":"select",isClearable:!0};break}case"date":{E={...g,type:"date",disablePast:!!((I=g.validations)!=null&&I.disablePast)||!1,disableFuture:!!((Q=g.validations)!=null&&Q.disableFuture)||!1};break}case"number":{E={...g,type:"number",min:((T=(w=g.validations)==null?void 0:w.range)==null?void 0:T.min)||Number.MIN_SAFE_INTEGER,max:((O=(S=g.validations)==null?void 0:S.range)==null?void 0:O.max)||Number.MAX_SAFE_INTEGER};break}case"multiline":{E={...g,type:"text",maxRows:((D=g.validations)==null?void 0:D.maxRows)||5,limit:(R=g.validations)==null?void 0:R.maxCharacters,rows:5,multiline:!0};break}case"text":{E={...g,type:"text",limit:(P=g.validations)==null?void 0:P.maxCharacters};break}default:E={...g}}if("value"in E&&(E.defaultValue=E.value,delete E.value),u[d.id]=[...u[d.id],E],g.interfaceDetails&&(g.interfaceDetails.args||g.interfaceDetails.optionalArgs)){const k={...g.interfaceDetails.args,...g.interfaceDetails.optionalArgs};Object.values(k).forEach(L=>{a[d.id][L]?a[d.id][L]=[...a[d.id][L],g.name]:a[d.id][L]=[g.name]})}})}),{createObjectList:A,linkObjectList:l,editObjectList:c,formFields:u,objectDict:C,dependentFieldsMap:a}}),Wl=Eo("writeCapability/fetchDropDownOptions",async(e,{getState:t,rejectWithValue:n})=>{var B;const{fieldName:o,formId:r,fieldConfig:i,callback:a,args:A={},interfaceId:l="",pagination:c={enabled:!1}}=e,u=Xh(A||{},r,o),{write:C}=t();let d=!1;i.meta&&"showAvatar"in i.meta&&typeof i.meta.showAvatar=="boolean"&&(d=i.meta.showAvatar);const{options:h=[],hasMore:f=!0,currentPage:p=0}=((B=C.optionsMap)==null?void 0:B[u])||{},{enabled:g,limit:E}=c,m=E||10;try{let b;const I=g?{pageNumber:p+1,limit:m}:null;if(f?b=await Fj({fieldName:o,formId:r},{pagination:I||{},args:A,interfaceId:l}):a==null||a(h),!b||!b.data||!("data"in b.data)||!Array.isArray(b.data.data))return{optionsList:[...h],fieldName:"",formId:"",hasMore:!1,currentPage:p,key:u};const w=b.data.data.map(O=>d?{...O,avatarUrl:O.avatarUrl||Zj}:{label:O.label,value:O.value}),T=g?w.length>=m:!1,S=[...h,...w];return a==null||a(S),{optionsList:S,fieldName:o,formId:r,currentPage:p+1,hasMore:T,key:u}}catch(b){return a==null||a(h),n(b)}},{condition:(e,{getState:t})=>{var c,u;if(e.isScrollToBottomEvent)return!0;const{fieldName:n,formId:o,callback:r,args:i}=e,a=Xh(i||{},o,n),{write:A}=t(),l=((u=(c=A.optionsMap)==null?void 0:c[a])==null?void 0:u.options)||[];return l&&l.length?(r==null||r(l),!1):!0}}),zl=Eo("writeCapability/createForm",async(e,{rejectWithValue:t})=>{const{formId:n,successCallback:o,failureCallback:r,args:i={},interfaceId:a,conversationId:A}=e;try{await Vh({formId:n},{args:i,interfaceId:a,conversationId:A}),o==null||o(),an({message:Xj,type:zr})}catch(l){return r==null||r(l),an({message:Kj,type:ar}),t(l)}}),Yl=Eo("writeCapability/updateForm",async(e,{rejectWithValue:t})=>{const{formId:n,successCallback:o,failureCallback:r,args:i={},interfaceId:a,conversationId:A,externalResourceId:l,previousArgs:c={}}=e;try{await Vh({formId:n},{args:i,interfaceId:a,conversationId:A,externalResourceId:l,previousArgs:c}),o==null||o(),an({message:iV,type:zr})}catch(u){return r==null||r(u),an({message:sV,type:ar}),t(u)}}),Gl=Eo("writeCapability/unlinkCard",async({id:e,channelType:t,externalResourceId:n,conversationId:o})=>{await Sj(e,t,n,o)}),Xl=Eo("writeCapability/linkCard",async({id:e,externalResourceId:t,channelType:n,conversationId:o})=>{await Oj(e,t,n,o)}),Ea=Eo("writeCapability/previewCard",async({id:e,args:t,channelType:n,isRefresh:o})=>{const r=await kj(e,t,n),i=r==null?void 0:r.data;if(!i)return o&&an({message:Lh,type:ar}),{data:null};if(o&&an({message:Uh,type:zr}),i.cardType==="flat"){const a=i.data.flatDisplay.data.filter(A=>Number(A.statusCode)!==ag.NOT_FOUND).sort((A,l)=>A.priority-l.priority);i.data.flatDisplay.data=a}else i.data.listItems.fields.forEach(a=>a.data.sort((A,l)=>A.priority-l.priority));return{data:i}}),Kl=Eo("connectorCardLibrary/fetchCurrentResourceDetails",async(e,{rejectWithValue:t})=>{const{id:n,channelType:o,conversationId:r,externalResourceId:i,contactEmail:a}=e;try{const A=await Mj(n,o,r,i,a),l=A==null?void 0:A.data,c=A==null?void 0:A.status,u={values:{},errors:{}};return Object.entries(l.formData).forEach(([C,d])=>{"label"in d&&(d.type&&d.type==="date"?u.values[C]=d.label?new Date(parseInt(d.label)).toISOString():"":d.type&&d.type==="multi-select"&&"value"in d&&"label"in d&&d.value&&d.label?u.values[C]=[{value:d.value,label:d.label}]:d.value?u.values[C]={value:d.value,label:d.label}:u.values[C]=d.label)}),{data:u,status:c}}catch(A){return an({message:Nh,type:ar}),t(A)}}),{resetState:TG,setCurrentCardInEdit:Ia,resetCurrentResourceDetails:BV,setHasUnsavedChanges:Jh}=Zh.actions,mV=Zh.reducer,QV=()=>{const[e,t]=y.useState(null),[n,o]=y.useState({isVertical:!1,isHorizontal:!1,isScrolling:!1}),r=y.useCallback(i=>{t(i)},[]);return y.useEffect(()=>{if(!e)return;e.dataset.prevScrollLeft="0",e.dataset.prevScrollTop="0";let i=null;const a=100;let A=null;const l=150,c=u=>{i||(i=window.setTimeout(()=>{const C=u.target,d=Number(e.dataset.prevScrollLeft)||0,h=Number(e.dataset.prevScrollTop)||0,f=C.scrollLeft,p=C.scrollTop,g=f-d,E=p-h,m=Math.abs(E)>Math.abs(g),B=Math.abs(g)>Math.abs(E);o({isVertical:m,isHorizontal:B,isScrolling:!0}),e.dataset.prevScrollLeft=String(f),e.dataset.prevScrollTop=String(p),i=null},a),A&&window.clearTimeout(A),A=window.setTimeout(()=>{o(C=>({...C,isScrolling:!1})),A=null},l))};return e.addEventListener("scroll",c),()=>{e.removeEventListener("scroll",c),i&&window.clearTimeout(i),A&&window.clearTimeout(A)}},[e]),[n,r]},bV="data:image/svg+xml,%3csvg%20width='18'%20height='18'%20viewBox='0%200%2018%2018'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M5.8016%2011.709L12.3416%205.16893L11.4298%204.25712L4.88979%2010.7972V11.709H5.8016ZM6.33618%2012.9987H3.6001V10.2626L10.9739%202.88875C11.0948%202.76786%2011.2588%202.69995%2011.4298%202.69995C11.6008%202.69995%2011.7648%202.76786%2011.8857%202.88875L13.71%204.71302C13.8309%204.83395%2013.8988%204.99794%2013.8988%205.16893C13.8988%205.33992%2013.8309%205.50391%2013.71%205.62484L6.33618%2012.9987ZM3.6001%2014.2884H15.2073V15.578H3.6001V14.2884Z'%20fill='%236C7B94'/%3e%3c/svg%3e",vV=({data:e,title:t,currentCard:n,setShowModal:o})=>{const r=Lr(),[i,a]=QV(),{isScrolling:A,isVertical:l}=i,c=A&&l,u=y.useMemo(()=>(e==null?void 0:e[0].data.map(f=>f.label))||[],[e]),C=y.useMemo(()=>e.map(f=>{const p={cells:{}};return p.externalResourceId=f.externalResourceId,f.data.forEach((g,E)=>{if(u[E]){let m=g.value?g.value:Fl;m&&g.type==="date"&&(m=new Date(parseInt(m)).toLocaleDateString(navigator.language)),p.cells[u[E]]={label:m,deepLink:g==null?void 0:g.deepLink}}}),p}),[e,u]),d=(f,p)=>v.jsx(kU,{align:"left",children:f.deepLink?v.jsx(PA,{target:"_blank",underline:"none",href:f.deepLink,children:f.label}):v.jsx(We,{variant:"body2",color:"gray.black",children:f.label})},`${p}_${f.label}`),h=f=>{!f||!n||(o(!1),r(Ia({...n,externalResourceId:f})))};return v.jsxs(Ue,{maxHeight:"340px",maxWidth:"700px",padding:"32px 0px 32px 32px",overflow:"auto",children:[v.jsx(We,{variant:"h2",color:"gray.black",marginBottom:"16px",children:t}),v.jsx(tC,{ref:a,children:v.jsxs(q1,{stickyHeader:!0,children:[v.jsx(FU,{children:v.jsxs(Wu,{children:[u.map(f=>v.jsx(SU,{children:v.jsx(We,{variant:"overline",color:"gray.gray3",children:f})},f)),v.jsx(DU,{})]})}),v.jsx(eC,{children:C.map((f,p)=>v.jsxs(OU,{children:[Object.values(f.cells).map((g,E)=>d(g,E)),v.jsx(MU,{children:!c&&f.externalResourceId&&v.jsx(Ut,{title:D2,placement:"right",children:v.jsx(_t,{className:"row-edit",onClick:()=>h(f.externalResourceId),children:v.jsx("img",{src:bV})})})})]},`id_${p}`))})]})})]})},yV="data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_602_78902)'%3e%3cpath%20d='M0.666992%2013.9999H15.3337L8.00033%201.33325L0.666992%2013.9999ZM8.66699%2011.9999H7.33366V10.6666H8.66699V11.9999ZM8.66699%209.33325H7.33366V6.66659H8.66699V9.33325Z'%20fill='%23F07530'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_602_78902'%3e%3crect%20width='16'%20height='16'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",_h=e=>{const{value:t,error:n,deepLink:o,statusCode:r,isLoading:i,type:a}=e,A=y.useRef(null),l=y.useRef(null),[c,u]=y.useState(!1);y.useEffect(()=>{const f=o?l.current:A.current;if(f){const p=f.scrollHeight>f.clientHeight||f.scrollWidth>f.clientWidth;u(p)}},[t,o]);const C=r==ag.NOT_FOUND;let d=C?Fl:t;a==="date"&&d&&!C&&(d=new Date(parseInt(d)).toLocaleDateString(navigator.language));const h=!C&&!!n;return i?v.jsx(Ur,{variant:"rounded",width:"100%",height:16,animation:"wave",margin:"4px 0 0 0"}):h?v.jsxs(q2,{gap:"5px",children:[v.jsx("img",{src:yV}),v.jsx($2,{variant:"body2",children:$R})]}):v.jsx(Ut,{title:c?d:null,placement:"bottom",children:o?v.jsx(eh,{ref:l,target:"_blank",underline:"none",href:o,fontSize:"13px",children:d||Fl}):v.jsx(TU,{ref:A,variant:"body2",children:d||Fl})})},wV="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_825_73646)'%3e%3cpath%20d='M19%206.41L17.59%205L12%2010.59L6.41%205L5%206.41L10.59%2012L5%2017.59L6.41%2019L12%2013.41L17.59%2019L19%2017.59L13.41%2012L19%206.41Z'%20fill='%236F7C90'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_825_73646'%3e%3crect%20width='24'%20height='24'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",kg=({shown:e,setShown:t,children:n,showCloseButton:o=!1,borderRadius:r=4})=>v.jsx(ku,{open:e,onClose:()=>t(!1),PaperProps:{style:{borderRadius:r,padding:0,height:"fit-content",width:"fit-content",maxWidth:"none"}},children:v.jsxs(Ue,{direction:"row",children:[o&&v.jsx(dt,{position:"absolute",right:10,top:10,children:v.jsx(Ut,{title:"Close",placement:"bottom",children:v.jsx(_t,{onClick:()=>t(!1),children:v.jsx("img",{src:wV})})})}),n]})}),qh=e=>{var H,G;const{id:t,cardTitle:n,specificCardData:o,specificConnectorApiStatus:r,isOpen:i,currentCard:a}=e,A=24,l=(r==null?void 0:r[t])===Oe.IDLE,c=(r==null?void 0:r[t])===Oe.LOADING,u=(r==null?void 0:r[t])===Oe.FAILED,{cardType:C,data:d}=(o==null?void 0:o[t])||{},h=C==="flat",[f,p]=y.useState(!1),[g,E]=y.useState(!1),[m,B]=y.useState(!1),[b,I]=y.useState(!1),Q=y.useMemo(()=>{var M,z,X,Y;return h&&((M=d==null?void 0:d.flatDisplay)!=null&&M.data)?d.flatDisplay.data:!h&&((Y=(X=(z=d==null?void 0:d.listItems)==null?void 0:z.fields)==null?void 0:X[0])!=null&&Y.data)?d==null?void 0:d.listItems.fields[0].data:[]},[h,d]),w=y.useMemo(()=>Q==null?void 0:Q.slice(0,5),[Q]),[T,S]=y.useState([]),O=y.useRef(null),[D,R]=y.useState(0),P=f?-180:0,k=h?!1:!!((H=d==null?void 0:d.listItems)!=null&&H.errorMessage),L=k||u,U=l&&!k&&i&&(m||g);y.useLayoutEffect(()=>{var M;(M=O.current)!=null&&M.scrollHeight&&R(O.current.scrollHeight+A)},[r==null?void 0:r[t],T,O]),y.useEffect(()=>{var Y,K;const M=((Q==null?void 0:Q.length)||0)>5,z=!h&&(((K=(Y=d==null?void 0:d.listItems)==null?void 0:Y.fields)==null?void 0:K.length)||0)>1;B(M&&!z),E(z)},[d,h,Q==null?void 0:Q.length]),y.useEffect(()=>{S(f?Q:w)},[d,f,w,Q]);const W=()=>{m?p(M=>!M):I(M=>!M)};return v.jsxs(v.Fragment,{children:[v.jsx(kg,{shown:b,setShown:I,showCloseButton:!0,borderRadius:12,children:v.jsx(vV,{data:((G=d==null?void 0:d.listItems)==null?void 0:G.fields)||[],title:n,currentCard:a,setShowModal:I})}),v.jsx(yU,{className:i?"":"slideUp",height:D,children:v.jsx(Ue,{ref:O,gap:1,margin:"12px",children:c&&(!(T!=null&&T.length)||L)?v.jsxs(v.Fragment,{children:[v.jsx(Ur,{variant:"rounded",width:"100%",height:20,animation:"wave"}),v.jsx(Ur,{variant:"rounded",width:"100%",height:20,animation:"wave"})]}):v.jsx(v.Fragment,{children:L?v.jsx(dt,{margin:"8px 0",children:v.jsx(_h,{error:L,isLoading:c})}):T!=null&&T.length?T==null?void 0:T.map(M=>{const{value:z,label:X,deepLink:Y,type:K}=M,q="errorMessage"in M?M.errorMessage:null,te="statusCode"in M?M.statusCode:null;return v.jsxs("div",{children:[v.jsx(wU,{variant:"overline",children:X}),v.jsx(_h,{value:z,error:q,deepLink:Y,statusCode:te,isLoading:c,type:K})]},X)}):v.jsx(dt,{margin:"8px 0",children:v.jsx($2,{children:eL})})})})}),U&&v.jsx(RU,{variant:"body2_medium",onClick:W,children:m?v.jsxs(v.Fragment,{children:[f?KU:th,v.jsx(PU,{src:XU,transformAngle:P})]}):th})]})},xV={connectorCards:null,cardSpecificData:null,connectorApiStatus:Oe.IDLE,specificConnectorApiStatus:null,threadId:null,connectorsEnabled:!1},$h="/v1/api",TV=`${$h}/connectors/cards`,FV=`${$h}/connectors/cards/:id/data`,SV=({inboxIds:e,conversationId:t,channelType:n="email"})=>{const o=new URLSearchParams;return e.forEach(r=>o.append("inbox_ids",r)),o.append("channel_type",n),o.append("conversation_id",String(t||"")),Co({url:`${TV}?${o.toString()}`,method:jo.GET})},OV=(e,t,n,o)=>{const r=new URLSearchParams;return r.append("senderEmail",t),r.append("conversation_id",String(n||"")),o&&r.append("externalResourceId",o),Co({url:`${FV.replace(":id",e)}?${r.toString()}`,method:jo.GET})},kV=e=>e.cardList.connectorCards,MV=e=>e.cardList.connectorsEnabled,DV=e=>e.cardList.connectorApiStatus,PV=e=>e.cardList.cardSpecificData,RV=e=>e.cardList.specificConnectorApiStatus,eB=Rh({name:"connectorCardLibrary",initialState:xV,reducers:{updateThreadId(e,t){const{payload:n}=t;e.threadId=n.threadId,e.connectorCards=null},clearConnectorList(e){e.connectorCards=null,e.cardSpecificData=null}},extraReducers:e=>{e.addCase(Zl.pending,t=>{t.connectorApiStatus=Oe.LOADING}).addCase(Zl.fulfilled,(t,n)=>{t.connectorApiStatus=Oe.IDLE,t.connectorCards=n.payload.cards,t.connectorsEnabled=n.payload.connectorsEnabled}).addCase(Zl.rejected,t=>{t.connectorApiStatus=Oe.FAILED}).addCase(ha.pending,(t,n)=>{const{id:o,externalResourceId:r=""}=n.meta.arg;let i=o;r&&(i=`${i}_${r}`),t.specificConnectorApiStatus={...t.specificConnectorApiStatus??{},[i]:Oe.LOADING}}).addCase(ha.fulfilled,(t,n)=>{const{id:o,externalResourceId:r=""}=n.meta.arg;let i=o;r&&(i=`${i}_${r}`);const{data:a}=n.payload||{};a&&(t.cardSpecificData={...t.cardSpecificData?t.cardSpecificData:{},[i]:a}),t.specificConnectorApiStatus={...t.specificConnectorApiStatus??{},[i]:Oe.IDLE}}).addCase(ha.rejected,(t,n)=>{const{id:o,externalResourceId:r=""}=n.meta.arg;let i=o;r&&(i=`${i}_${r}`),t.specificConnectorApiStatus={...t.specificConnectorApiStatus??{},[i]:Oe.FAILED}})}}),Zl=Eo("connectorCardLibrary/fetchAllCard",async({inboxIds:e,channelType:t,conversationId:n})=>{var A;const o=await SV({inboxIds:e,channelType:t,conversationId:n});if(!Array.isArray((A=o==null?void 0:o.data)==null?void 0:A.cards))return{cards:[],connectorsEnabled:!1};const{cards:r,connectorsEnabled:i=!1}=o.data;return{cards:r.sort((l,c)=>(l==null?void 0:l.priority)-(c==null?void 0:c.priority)),connectorsEnabled:i}}),ha=Eo("connectorCardLibrary/fetchSpecificCard",async({id:e,email:t,conversationId:n,isRefresh:o,externalResourceId:r},i)=>{try{const a=await OV(e,t,n,r),A=a==null?void 0:a.data,l=a==null?void 0:a.status;if(!A)return o&&an({message:Lh,type:ar}),{data:{},status:l};if(o&&an({message:Uh,type:zr}),A.cardType==="flat"){const c=A.data.flatDisplay.data.filter(u=>Number(u.statusCode)!==ag.NOT_FOUND).sort((u,C)=>(u==null?void 0:u.priority)-(C==null?void 0:C.priority));A.data.flatDisplay.data=c}else A.data.listItems.fields.forEach(c=>c.data.sort((u,C)=>(u==null?void 0:u.priority)-(C==null?void 0:C.priority)));return{data:A,status:l}}catch(a){return i.rejectWithValue(a)}}),LV=eB.reducer,tB=eB.actions,nB="data:image/svg+xml,%3csvg%20width='12'%20height='12'%20viewBox='0%200%2012%2012'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M9.76618%202.23341C8.79952%201.26675%207.47285%200.666748%205.99952%200.666748C3.05285%200.666748%200.672852%203.05341%200.672852%206.00008C0.672852%208.94675%203.05285%2011.3334%205.99952%2011.3334C8.48619%2011.3334%2010.5595%209.63341%2011.1529%207.33341H9.76618C9.21952%208.88675%207.73952%2010.0001%205.99952%2010.0001C3.79285%2010.0001%201.99952%208.20675%201.99952%206.00008C1.99952%203.79341%203.79285%202.00008%205.99952%202.00008C7.10618%202.00008%208.09285%202.46008%208.81285%203.18675L6.66618%205.33341H11.3329V0.666748L9.76618%202.23341Z'%20fill='%236C7B94'/%3e%3c/svg%3e",UV="data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M11.4587%206.7528C11.2244%206.51848%2010.8445%206.51848%2010.6102%206.7528C10.3759%206.98711%2010.3759%207.36701%2010.6102%207.60132L11.4587%206.7528ZM12.1916%208.33414L12.6158%207.90988L12.1916%208.33414ZM8.33462%2012.1911L8.75888%2011.7668L8.33462%2012.1911ZM7.6018%2010.6097C7.36748%2010.3754%206.98758%2010.3754%206.75327%2010.6097C6.51895%2010.8441%206.51895%2011.224%206.75327%2011.4583L7.6018%2010.6097ZM4.43911%209.14411C4.67343%209.37842%205.05333%209.37842%205.28764%209.14411C5.52196%208.9098%205.52196%208.5299%205.28764%208.29558L4.43911%209.14411ZM3.70629%207.56276L4.13056%207.1385L3.70629%207.56276ZM7.56324%203.70582L7.9875%203.28155L7.56324%203.70582ZM8.29606%205.28716C8.53037%205.52148%208.91027%205.52148%209.14459%205.28716C9.3789%205.05285%209.3789%204.67295%209.14459%204.43864L8.29606%205.28716ZM10.6102%207.60132L11.7673%208.75841L12.6158%207.90988L11.4587%206.7528L10.6102%207.60132ZM11.7673%208.75841C12.1662%209.15735%2012.3904%209.69843%2012.3904%2010.2626L13.5904%2010.2626C13.5904%209.38017%2013.2398%208.53387%2012.6158%207.90988L11.7673%208.75841ZM12.3904%2010.2626C12.3904%2010.8268%2012.1662%2011.3679%2011.7673%2011.7668L12.6158%2012.6154C13.2398%2011.9914%2013.5904%2011.1451%2013.5904%2010.2626L12.3904%2010.2626ZM11.7673%2011.7668C10.9365%2012.5976%209.58963%2012.5976%208.75888%2011.7668L7.91035%2012.6154C9.20973%2013.9147%2011.3164%2013.9147%2012.6158%2012.6154L11.7673%2011.7668ZM8.75888%2011.7668L7.6018%2010.6097L6.75327%2011.4583L7.91035%2012.6154L8.75888%2011.7668ZM5.28764%208.29558L4.13056%207.1385L3.28203%207.98703L4.43911%209.14411L5.28764%208.29558ZM4.13056%207.1385C3.73162%206.73956%203.50749%206.19848%203.50749%205.63429L2.30749%205.63429C2.30749%206.51674%202.65804%207.36304%203.28203%207.98703L4.13056%207.1385ZM3.50749%205.63429C3.50749%205.0701%203.73162%204.52902%204.13056%204.13008L3.28203%203.28155C2.65804%203.90554%202.30749%204.75184%202.30749%205.63429L3.50749%205.63429ZM4.13056%204.13008C4.96131%203.29933%206.30822%203.29933%207.13897%204.13008L7.9875%203.28155C6.68812%201.98217%204.58141%201.98217%203.28203%203.28155L4.13056%204.13008ZM7.13897%204.13008L8.29606%205.28716L9.14459%204.43864L7.9875%203.28155L7.13897%204.13008Z'%20fill='%236C7B94'/%3e%3crect%20x='5.08887'%20y='6.0791'%20width='1.33333'%20height='6.66667'%20rx='0.666667'%20transform='rotate(-45%205.08887%206.0791)'%20fill='%236C7B94'/%3e%3cpath%20d='M5.59961%2014.3998V12.7998'%20stroke='%236C7B94'%20stroke-width='1.2'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M12.7998%205.59961H14.3998'%20stroke='%236C7B94'%20stroke-width='1.2'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M2.40039%2011.2002H4.00039'%20stroke='%236C7B94'%20stroke-width='1.2'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M11.2002%202.40039V4.00039'%20stroke='%236C7B94'%20stroke-width='1.2'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",NV="data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_5908_39767)'%3e%3cpath%20d='M9.37333%206.01333L9.98667%206.62667L3.94667%2012.6667H3.33333V12.0533L9.37333%206.01333ZM11.7733%202C11.6067%202%2011.4333%202.06667%2011.3067%202.19333L10.0867%203.41333L12.5867%205.91333L13.8067%204.69333C14.0667%204.43333%2014.0667%204.01333%2013.8067%203.75333L12.2467%202.19333C12.1133%202.06%2011.9467%202%2011.7733%202ZM9.37333%204.12667L2%2011.5V14H4.5L11.8733%206.62667L9.37333%204.12667Z'%20fill='%236C7B94'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_5908_39767'%3e%3crect%20width='16'%20height='16'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",oB=e=>e.write.createObjectList,rB=e=>e.write.linkObjectList,jV=e=>e.write.editObjectList,VV=e=>e.write.objectDict,HV=e=>e.write.formFields,WV=e=>e.write.previewCardData,zV=e=>e.write.previewCardApiStatus,YV=e=>e.write.linkCardApiStatus,GV=e=>e.write.unlinkCardApiStatus,XV=e=>e.write.dependentFieldsMap,KV=e=>e.write.createFormApiStatus,ZV=e=>e.write.updateFormApiStatus,JV=e=>e.write.currentResourceDetails,_V=e=>e.write.currentResourceDetailsApiStatus,iB=e=>e.write.currentCardInEdit,sB=e=>e.write.hasUnsavedChanges,qV=({showUnlinkModal:e,setShowUnlinkModal:t,cardId:n,onCardUnlinking:o,externalResourceId:r,conversationId:i,connectorName:a})=>{const A=Lr(),{sendTrackingEvent:l}=y.useContext(Lo),u=wt(GV)===Oe.LOADING,C=()=>{i&&r&&A(Gl({id:n,conversationId:i,externalResourceId:r})).unwrap().then(()=>{l(FL,{connector_name:a,conversation_id:i}),t(!1),o(),an({message:dj,type:zr})}).catch(()=>{an({message:gj,type:zr})})};return v.jsx(kg,{shown:e,setShown:t,showCloseButton:!0,children:v.jsxs(Ue,{width:"400px",padding:"20px",gap:"8px",children:[v.jsx(We,{variant:"h2",children:aL}),v.jsx(We,{variant:"body2",children:AL}),v.jsxs(Ue,{direction:"row",gap:"8px",marginTop:"20px",justifyContent:"flex-end",children:[v.jsx(zt,{variant:"text",onClick:()=>t(!1),children:lg}),v.jsx(zt,{disabled:u,color:"error",onClick:C,children:M2})]})]})})},$V=e=>{const{card:t,specificCardData:n,email:o,specificConnectorApiStatus:r,defaultOpenState:i=!1,onCardUnlinking:a}=e,A=Lr(),{availableFeatures:l,sendTrackingEvent:c,conversationId:u,currentSmIds:C}=y.useContext(Lo),d=dl(),[h,f]=y.useState(!!i),[p,g]=y.useState(!1),[E,m]=y.useState(!1),{id:B,title:b,externalResourceId:I="",connectorName:Q="",forms:w}=t;let T=B;I&&(T=`${T}_${I}`);const{data:S,cardType:O}=(n==null?void 0:n[T])??{},D=(r==null?void 0:r[T])===Oe.LOADING,R=!!(zi(l,S2)&&I),P=y.useMemo(()=>{var G,M;if(!(zi(l,qR)&&w.some(z=>z.type==="edit")))return!1;switch(O){case"flat":return!!(S!=null&&S.flatDisplay.externalResourceId);case"flat_with_list":return((G=S==null?void 0:S.listItems)==null?void 0:G.fields.length)===1?(M=S==null?void 0:S.listItems)==null?void 0:M.fields.some(z=>z.externalResourceId):!1;default:return!1}},[S,O,l,w]),k=y.useCallback((G=!1)=>{const M=G?DL:ML;o&&B&&u&&A(ha({id:B,email:o,conversationId:u,externalResourceId:I})).unwrap().then(z=>{const X=N2(z,b,G,!0);c(M,X)}).catch(z=>{const X=N2(z,b,G,!1);c(M,X)})},[A,o,B,b,c,u,I]);y.useEffect(()=>{i&&k(!0)},[i,k]);const L=(G,M)=>{var X;G==null||G.stopPropagation(),A(ha({id:M,email:o,conversationId:u,isRefresh:!0,externalResourceId:I})).unwrap().then(()=>{c(hL,{id:M})});const z=G.target.tagName==="BUTTON"?(X=G.target)==null?void 0:X.firstChild:G.target;z.className&&(z.className=""),setTimeout(()=>z.className="selected",1)},U=(G,M)=>{G.stopPropagation(),!(n!=null&&n[M])&&!D&&k(),c(h?IL:EL,{id:M}),f(z=>!z)},W=G=>{G.stopPropagation();const M=G.currentTarget.offsetWidth<G.currentTarget.scrollWidth;g(!!M)},H=()=>{var M,z;c(LL,{card_title:b,connector_name:Q,ug_id:d,sm_ids:C});let G;O==="flat"?G=S==null?void 0:S.flatDisplay.externalResourceId:O==="flat_with_list"&&(G=(z=(M=S==null?void 0:S.listItems)==null?void 0:M.fields[0])==null?void 0:z.externalResourceId),G?A(Ia({...t,externalResourceId:G})):an({message:Nh,type:ar})};return v.jsxs(QU,{"data-testid":`test_${B}`,children:[v.jsxs(bU,{className:h?"hiver-card-expanded":"",children:[v.jsx(Ut,{title:p?b:"",placement:"bottom",children:v.jsx(vU,{variant:"h4",onMouseOver:G=>W(G),onMouseLeave:G=>W(G),children:b})}),v.jsxs(q2,{children:[h&&P?v.jsx(Ut,{title:D2,placement:"bottom",children:v.jsx(Nr,{onClick:H,children:v.jsx("img",{src:NV})})}):null,h&&R?v.jsx(Ut,{title:M2,placement:"bottom",children:v.jsx(Nr,{onClick:()=>m(!0),children:v.jsx("img",{src:UV})})}):null,h?v.jsx(Ut,{title:O2,placement:"bottom",children:v.jsx(Nr,{"data-testid":D?"loading":"reloadIcon",onClick:G=>L(G,B),className:D?"disabled":"",children:v.jsx("img",{src:nB})})}):null,v.jsx(Ut,{title:h?k2:Ag,placement:"bottom",children:v.jsx(Nr,{onClick:G=>U(G,T),children:v.jsx(Eg,{className:h?"":"hiver-up"})})})]})]}),v.jsx(qh,{id:T,cardTitle:t.title,currentCard:t,specificCardData:n,specificConnectorApiStatus:r,isOpen:h}),v.jsx(qV,{showUnlinkModal:E,setShowUnlinkModal:m,cardId:B,onCardUnlinking:a,conversationId:u,externalResourceId:I,connectorName:Q})]})},eH="Bring your favourite tools into Hiver",tH="Plugin image",nH="Integrate tools like Salesforce, HubSpot, and Shopify to boost productivity",oH="Enable Connectors",aB="app/custom-connectors",rH="Learn more",iH="https://help.hiverhq.com/custom-connectors/hiver-s-custom-connectors",sH="Contact your admin to enable this",aH="https://youtu.be/ODcJnzZLb50",AH="connectors-module/assets/connectors-images/connector-mainpage.png",lH="Explore connectors",cH="Connectors",uH=V(Ue)`
|
|
2420
2420
|
width: 250px;
|
|
2421
2421
|
height: 97px;
|
|
2422
2422
|
background-color: ${Pe.palette.purple.light};
|