@hiver/connector-agent 4.6.0-quickAccess-beta.0 → 4.6.0

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 CHANGED
@@ -18214,7 +18214,7 @@ const fI = (e) => new Promise((t) => setTimeout(t, e)), ch = ({
18214
18214
  NI({
18215
18215
  conversationId: i,
18216
18216
  openCreateForm: () => E(!0),
18217
- enabled: !!(Q != null && Q.length)
18217
+ enabled: M
18218
18218
  });
18219
18219
  const ut = Ae(() => !Q || !Q.length ? null : j8(Q, V, B), [Q, V, B]), Qe = _5(V), { data: rr, isLoading: Pt } = lh({
18220
18220
  senderEmail: t,
package/index.umd.js CHANGED
@@ -1289,7 +1289,7 @@ Do you want to continue?`,S8="Select an object to create",T8="Select an object t
1289
1289
  `,RE="data:image/svg+xml,%3csvg%20width='124'%20height='107'%20viewBox='0%200%20124%20107'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M28.6168%2054.7446C28.6931%2052.5589%2031.0146%2051.1102%2033.0842%2051.8174C35.9985%2052.8133%2040.0375%2053.9024%2044.0621%2054.043C48.0034%2054.1806%2051.968%2053.4097%2054.8762%2052.6339C57.0264%2052.0602%2059.2927%2053.6932%2059.215%2055.9172C59.1742%2057.0856%2058.4742%2058.1269%2057.3723%2058.5178C54.8051%2059.4284%2049.7633%2060.8927%2044.3075%2060.7022C38.7694%2060.5088%2033.1999%2058.6241%2030.4004%2057.5311C29.2637%2057.0873%2028.5742%2055.9641%2028.6168%2054.7446Z'%20fill='url(%23paint0_linear_8481_102191)'/%3e%3cpath%20d='M47.223%2043.6373C44.4928%2030.7926%2052.6922%2018.1666%2065.5368%2015.4364C78.3815%2012.7062%2091.0075%2020.9055%2093.7377%2033.7502L105.079%2087.1053L84.1844%2091.5466C70.0346%2094.5542%2056.1258%2085.5217%2053.1182%2071.3719L47.223%2043.6373Z'%20fill='url(%23paint1_linear_8481_102191)'/%3e%3cmask%20id='mask0_8481_102191'%20style='mask-type:luminance'%20maskUnits='userSpaceOnUse'%20x='46'%20y='14'%20width='60'%20height='79'%3e%3cpath%20d='M47.223%2043.6373C44.4928%2030.7926%2052.6922%2018.1666%2065.5368%2015.4364C78.3815%2012.7062%2091.0075%2020.9055%2093.7377%2033.7502L105.079%2087.1053L84.1844%2091.5466C70.0346%2094.5542%2056.1258%2085.5217%2053.1182%2071.3719L47.223%2043.6373Z'%20fill='white'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_8481_102191)'%3e%3cellipse%20cx='63.7775'%20cy='46.8684'%20rx='1.48152'%20ry='1.39438'%20transform='rotate(-12%2063.7775%2046.8684)'%20fill='%23435C71'/%3e%3crect%20x='47.4368'%20y='59.3203'%20width='53.657'%20height='13.2235'%20transform='rotate(-12%2047.4368%2059.3203)'%20fill='url(%23paint2_linear_8481_102191)'/%3e%3crect%20x='51.1907'%20y='76.9824'%20width='53.657'%20height='10.4263'%20transform='rotate(-12%2051.1907%2076.9824)'%20fill='url(%23paint3_linear_8481_102191)'/%3e%3c/g%3e%3cpath%20opacity='0.883952'%20d='M113.939%2051.0679C114.775%2055%20112.265%2058.865%20108.333%2059.7008L107.842%2059.8052C103.639%2060.6986%2099.5073%2058.0155%2098.6139%2053.8123L97.205%2047.1837L105.307%2045.4616C109.239%2044.6259%20113.104%2047.1359%20113.939%2051.0679Z'%20fill='url(%23paint4_linear_8481_102191)'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M68.7215%2066.4138C67.1801%2064.8725%2067.6745%2062.2062%2069.587%2061.1603C72.4457%2059.5969%2076.2861%2057.1773%2079.3785%2054.0849C82.4099%2051.0535%2084.752%2047.3461%2086.2775%2044.5465C87.3388%2042.5989%2090.0598%2042.0819%2091.6282%2043.6503C92.4782%2044.5003%2092.758%2045.7623%2092.2604%2046.8566C91.0829%2049.4466%2088.5191%2054.344%2084.4346%2058.4285C80.2853%2062.5778%2074.8639%2065.591%2072.0553%2066.9952C70.9363%2067.5548%2069.6062%2067.2985%2068.7215%2066.4138Z'%20fill='url(%23paint5_linear_8481_102191)'/%3e%3crect%20x='48.7264'%20y='33.7744'%20width='11.2108'%20height='11.2108'%20rx='5.59457'%20transform='rotate(-12%2048.7264%2033.7744)'%20fill='url(%23paint6_linear_8481_102191)'/%3e%3crect%20x='50.0175'%20y='35.8193'%20width='4.0158'%20height='3.84848'%20rx='1.92424'%20transform='rotate(-12%2050.0175%2035.8193)'%20fill='%23435C71'/%3e%3crect%20x='59.2875'%20y='31.5723'%20width='11.2108'%20height='11.2108'%20rx='5.59457'%20transform='rotate(-12%2059.2875%2031.5723)'%20fill='%23FFFEFE'/%3e%3cpath%20opacity='0.883952'%20d='M111.25%2038.5376C110.415%2034.6055%20106.55%2032.0955%20102.618%2032.9313L102.127%2033.0356C97.9234%2033.9291%2095.2403%2038.0607%2096.1337%2042.2639L97.5426%2048.8925L105.644%2047.1705C109.576%2046.3347%20112.086%2042.4696%20111.25%2038.5376Z'%20fill='url(%23paint7_linear_8481_102191)'/%3e%3crect%20x='60.0181'%20y='33.8037'%20width='3.84848'%20height='3.84848'%20rx='1.90724'%20transform='rotate(-12%2060.0181%2033.8037)'%20fill='%23435C71'/%3e%3cpath%20d='M36.9246%2059.1604C36.4487%2060.717%2034.7371%2061.6271%2033.1805%2061.1512C32.3613%2060.9007%2031.7241%2060.3475%2031.3259%2059.5987L25.2059%2046.7983C24.9784%2046.3703%2025.1286%2045.8788%2025.5566%2045.6513L28.338%2044.1724C28.7659%2043.9449%2029.2574%2044.0951%2029.4849%2044.5231L36.6496%2056.8367C37.0728%2057.5036%2037.15%2058.423%2036.9246%2059.1604Z'%20fill='%23FFDF9F'/%3e%3crect%20x='27.9973'%20y='44.333'%20width='2.39869'%20height='3.59807'%20transform='rotate(152%2027.9973%2044.333)'%20fill='%23FF9090'/%3e%3cpath%20d='M26.6628%2044.3769L26.9472%2044.9118L28.0169%2044.343L26.3106%2041.1338L24.171%2042.2714L25.0243%2043.876C25.6661%2043.5347%2026.3215%2043.7351%2026.6628%2044.3769Z'%20fill='%23FFB19F'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M7.26386%2027.248C9.3428%2020.4481%2016.5101%2016.6372%2023.31%2018.7161C30.11%2020.7951%2033.9209%2027.9624%2031.8419%2034.7623C29.763%2041.5622%2022.5956%2045.3731%2015.7958%2043.2942C8.99587%2041.2152%205.18493%2034.0479%207.26386%2027.248ZM9.72157%2027.9983C8.06843%2033.4055%2011.1399%2039.1821%2016.5471%2040.8352C21.9543%2042.4884%2027.7309%2039.4168%2029.384%2034.0096C31.0372%2028.6024%2027.9657%2022.8258%2022.5585%2021.1727C17.1513%2019.5196%2011.3747%2022.5911%209.72157%2027.9983Z'%20fill='%23FFE69F'/%3e%3ccircle%20opacity='0.414016'%20cx='19.5529'%20cy='31.0039'%20r='10.2804'%20transform='rotate(17%2019.5529%2031.0039)'%20fill='%23BBDEFC'/%3e%3cpath%20d='M14.3685%2030.6746C15.7299%2027.6867%2018.9391%2025.9803%2022.1776%2026.5225L22.2595%2026.5475C23.7024%2026.8095%2024.3854%2024.8682%2023.1497%2024.2218C22.3806%2023.8074%2021.5613%2023.557%2020.717%2023.3884C17.3715%2022.9031%2014.0553%2024.6664%2012.6939%2027.6543C12.2796%2028.4235%2012.0859%2029.3497%2012.0244%2030.1372C11.8444%2031.6051%2013.8607%2032.0424%2014.4503%2030.6997C14.3434%2030.7566%2014.3685%2030.6746%2014.3685%2030.6746Z'%20fill='%23F6FBFF'/%3e%3cpath%20d='M10.2904%2029.0679C11.9436%2023.6607%2017.7202%2020.5893%2023.1274%2022.2424C25.6671%2023.0189%2027.5785%2024.6783%2028.9301%2026.704C27.7539%2024.1048%2025.508%2022.0744%2022.5586%2021.1727C17.1514%2019.5196%2011.3748%2022.591%209.72165%2027.9982C8.81993%2030.9476%209.32924%2033.97%2010.7444%2036.3735C9.82081%2034.1203%209.51395%2031.6077%2010.2904%2029.0679Z'%20fill='%23ADCBE7'/%3e%3cpath%20opacity='0.406087'%20d='M36.4864%2056.8021L36.1373%2056.2691C36.3845%2056.8563%2036.428%2057.5516%2036.2372%2058.1754C35.9273%2059.189%2034.5593%2059.1971%2034.0713%2058.2806L28.3787%2047.5877C28.0534%2046.9767%2027.3508%2046.7619%2026.7395%2047.0866L25.7206%2047.6277L31.4395%2059.3516C31.7648%2059.9627%2032.27%2060.5434%2032.8706%2060.8123C33.7054%2061.1528%2034.6593%2061.1034%2035.3726%2060.7247C36.0858%2060.3459%2036.6602%2059.5837%2036.8444%2058.7021C37.0351%2058.0783%2036.8117%2057.4132%2036.4864%2056.8021Z'%20fill='white'/%3e%3cpath%20d='M29.8826%2048.4977C29.8006%2048.4726%2029.6368%2048.4225%2029.5799%2048.3155L28.1579%2045.6411C28.0442%2045.4272%2028.1193%2045.1814%2028.3332%2045.0677C28.5472%2044.9539%2028.7929%2045.0291%2028.9067%2045.243L30.3287%2047.9174C30.4424%2048.1313%2030.3673%2048.3771%2030.1534%2048.4908C30.1284%2048.5728%2029.9645%2048.5227%2029.8826%2048.4977Z'%20fill='%23FFF5EB'/%3e%3cellipse%20cx='29.2637'%20cy='54.631'%20rx='1.50593'%20ry='3.17918'%20transform='rotate(-23%2029.2637%2054.631)'%20fill='%23FFC478'/%3e%3cellipse%20cx='34.0592'%20cy='52.4078'%20rx='0.920288'%20ry='1.67325'%20transform='rotate(106%2034.0592%2052.4078)'%20fill='%23FFC478'/%3e%3cpath%20d='M89.1282%2019.2055L68.2257%2026.8725L45.9197%2028.3898L44.4929%2016.4082C44.3371%2013.798%2047.5283%2011.4502%2050.9859%2011.6309L65.1429%2012.369L67.3969%2012.4869C68.5309%2012.5463%2069.7066%2012.3289%2070.7522%2011.8627L78.6899%208.34726C81.725%206.99992%2085.3012%207.87475%2086.2125%2010.1876L89.1282%2019.2055Z'%20fill='url(%23paint8_linear_8481_102191)'/%3e%3cpath%20opacity='0.479771'%20d='M88.6262%2019.0953L68.3101%2026.5288L65.3314%2012.5149L67.5211%2012.6263C68.6228%2012.6824%2069.7652%2012.471%2070.7816%2012.0192L78.4972%208.61266C81.4474%207.30707%2084.9208%208.14856%2085.8036%2010.3829L88.6262%2019.0953Z'%20fill='%23ADCBE7'/%3e%3cpath%20d='M91.6332%2026.6212L46.9517%2036.1186L46.0387%2028.4438L89.2535%2019.2582L91.6332%2026.6212Z'%20fill='%23717DAD'/%3e%3cpath%20d='M102.961%2024.2033C103.125%2024.9722%20102.371%2025.7829%20101.278%2026.015L37.9675%2039.4722C36.8754%2039.7043%2035.8568%2039.2704%2035.6933%2038.5015C35.5301%2037.7336%2036.284%2036.922%2037.3761%2036.6898L100.687%2023.2327C101.779%2023.0005%20102.798%2023.4354%20102.961%2024.2033Z'%20fill='%239ED1FF'/%3e%3cpath%20d='M102.703%2024.1718C102.838%2024.805%20102.067%2025.5045%20100.983%2025.7349L69.5583%2032.4144L69.0712%2030.123L100.496%2023.4436C101.58%2023.2131%20102.569%2023.5394%20102.703%2024.1718Z'%20fill='%2378AFE1'/%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_8481_102191'%20x1='32.2665'%20y1='59.6553'%20x2='59.0518'%20y2='60.5906'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23FFFDE0'/%3e%3cstop%20offset='1'%20stop-color='%23FFB362'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint1_linear_8481_102191'%20x1='67.3434'%20y1='85.966'%20x2='103.216'%20y2='78.3411'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23FFFABC'/%3e%3cstop%20offset='1'%20stop-color='%23FFA650'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint2_linear_8481_102191'%20x1='51.4347'%20y1='74.8197'%20x2='91.1539'%20y2='74.8197'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23A3C1FF'/%3e%3cstop%20offset='1'%20stop-color='%234243FF'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint3_linear_8481_102191'%20x1='55.1887'%20y1='89.2031'%20x2='94.9078'%20y2='89.2031'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23A3C1FF'/%3e%3cstop%20offset='1'%20stop-color='%234243FF'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint4_linear_8481_102191'%20x1='94.5023'%20y1='53.1799'%20x2='106.762'%20y2='58.7056'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23FF9498'/%3e%3cstop%20offset='1'%20stop-color='%23FFD671'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint5_linear_8481_102191'%20x1='74.9906'%20y1='66.9871'%20x2='94.9778'%20y2='46.9999'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23FFFDE0'/%3e%3cstop%20offset='1'%20stop-color='%23FFB362'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint6_linear_8481_102191'%20x1='50.5805'%20y1='44.0581'%20x2='59.9372'%20y2='44.0581'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='white'/%3e%3cstop%20offset='1'%20stop-color='%23E3EEF3'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint7_linear_8481_102191'%20x1='88.4187'%20y1='43.3906'%20x2='99.3981'%20y2='25.1833'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23FF9498'/%3e%3cstop%20offset='1'%20stop-color='%23FFD671'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint8_linear_8481_102191'%20x1='56.4985'%20y1='29.5482'%20x2='100.532'%20y2='20.1885'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23ECF7FF'/%3e%3cstop%20offset='1'%20stop-color='%23C2E0FF'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",ME=()=>u.jsxs(f.Box,{justifyItems:"center",marginTop:"40px",children:[u.jsx("img",{src:RE,width:124,height:107}),u.jsx(f.Typography,{variant:"body2",color:f.theme.palette.gray.gray3,children:Ax})]}),PE=({searchResults:e,selectedObject:t,onReset:n,fetchCards:r})=>{const o=Ht(),{sendTrackingEvent:s,currentSmIds:a}=_.useContext(He),[i,c]=_.useState(null),l=bt(Sx,{count:e.length.toString(),countSuffix:e.length>1?"s":"",searchObject:t.objectName,connectorName:t.connectorName}),d=(x,y)=>{s(Gm,{search_keyword:t.label,search_result_label:y,sm_ids:a,connector_name:t.connectorName}),c({externalResourceId:x,formId:t.value.toString(),searchKeyword:t.label,searchResultLabel:y})},g=()=>{c(null),o(r8())},b=()=>{n(),r(),g()};return e.length?i?u.jsx(NE,{meta:i,onBack:g,onLink:b}):u.jsxs(f.Stack,{gap:"14px",marginTop:"12px",children:[u.jsx(f.Typography,{variant:"body2",children:l}),u.jsx(f.Stack,{gap:"17px",children:e==null?void 0:e.map(({externalResourceId:x,name:y,description:p})=>u.jsxs(dp,{onClick:()=>d(x,y),direction:"row",children:[u.jsxs(f.Stack,{flexGrow:1,children:[u.jsx(f.Typography,{variant:"body2",color:f.theme.palette.gray.gray1,children:y}),u.jsx(f.Typography,{variant:"caption",color:f.theme.palette.gray.gray3,children:p})]}),u.jsx(f.Box,{alignSelf:"center",className:"search-item__chevron",width:"20px",height:"20px",children:u.jsx("img",{src:LE})})]},x))})]}):u.jsx(ME,{})},zc=f.styled(f.Skeleton)`
1290
1290
  display: block;
1291
1291
  margin: ${e=>e.margin?e.margin:0};
1292
- `,jE=()=>u.jsxs(f.Stack,{marginTop:"12px",children:[u.jsx(zc,{variant:"rounded",width:"50%",height:"16px",animation:"wave",margin:"0 0 18px 0"}),u.jsx(f.Stack,{gap:"17px",children:u.jsxs(dp,{gap:"8px",disableHover:!0,children:[u.jsx(zc,{variant:"rounded",width:"30%",height:"16px",animation:"wave"}),u.jsx(zc,{variant:"rounded",width:"70%",height:"16px",animation:"wave"})]})})]}),BE=async({id:e,searchString:t,args:n})=>{try{if(e===void 0||t===void 0)return[];const r=await Ne({url:IE.replace(":formId",e.toString()),method:Ve.POST,data:{search_string:t,args:n}});let o=null;return r!=null&&r.data&&"data"in r.data&&(o=r.data.data),o}catch(r){Se({message:pn,type:qe}),console.error(r)}},VE=(e,t)=>mn({mutationFn:BE,onMutate:({searchString:n,connectorName:r})=>{e(n,r)},onSuccess:(n,{searchString:r,connectorName:o})=>{t(r,n,o)}}),Yc={OPEN_FORM_VIEW:"connector-agent-open-form-view"},GE=(e,t={})=>{const{delayAfterLoad:n=1e3}=t,r=_.useRef(!1),o=_.useRef(void 0),s=_.useCallback((c="auto")=>{const l=e.current;l&&l.scrollIntoView({behavior:c})},[e]),a=_.useCallback((c,l="smooth")=>{r.current||(o.current!==void 0&&clearTimeout(o.current),c&&(o.current=setTimeout(()=>{s(l),r.current=!0},n)))},[s,n]),i=_.useCallback(()=>{r.current=!1,o.current!==void 0&&clearTimeout(o.current)},[]);return _.useEffect(()=>()=>{o.current!==void 0&&clearTimeout(o.current)},[]),{scrollOnceAfterLoad:a,resetScrollState:i,hasScrolledOnce:r.current}},HE=({enabled:e,...t})=>{const{actionQueue:n}=_.useContext(He);n&&e&&n.register(t),_.useEffect(()=>{if(n)return()=>{n.destroy()}},[n,e])},WE=({isAdmin:e=!1})=>{var Uo;const{email:t,currentSmIds:n,sendTrackingEvent:r,availableFeatures:o,conversationId:s}=_.useContext(He),a=Ht(),{userGroupId:i,userId:c}=Qt()||{},l=_.useRef(!1),d=_.useRef(null),g=_.useRef(null),b=_.useRef(null),[x,y]=_.useState({}),[p,h]=_.useState(!1),[m,v]=_.useState(!1),[C,I]=_.useState(!1),[E,w]=_.useState(!1),[T,S]=_.useState(),[L,N]=_.useState(!1),[D,k]=_.useState(null),[M,B]=_.useState(),[z,q]=_.useState(null),[Q,X]=_.useState(!1),[Y,oe]=_.useState(!1),$=me(P8),P=me(j8),G=me(V8),V=me(G8),H=me(W8),J=me(B8),ne=me(g1),se=me(nv),j=me(m1),te=me(b1),Ce=me(y1),Z=me(ox),Xe=at(o,Jm),Me=at(o,Vu),Qe=at(o,e3),ot=at(o,n3),vn=at(o,r3),kt=at(o,o3);HE({conversationId:s,openCreateForm:()=>I(!0),enabled:!!($!=null&&$.length)});const tt=_.useMemo(()=>!$||!$.length?null:Y8($,G,V),[$,G,V]),ze=v3(G),{data:br,isLoading:Nt}=lp({senderEmail:t,conversationId:String(s),enabled:ot&&!!t}),{emailHeaders:Yo,selectedEmail:oo}=br??{},{scrollOnceAfterLoad:Vn,resetScrollState:Gn}=GE(g),ue=J!==ee.LOADING&&(!V||!Object.values(V).some(ye=>ye===ee.LOADING))&&$&&$.length>0;_.useLayoutEffect(()=>{var ye;Q&&!p&&Y&&((ye=b==null?void 0:b.current)!=null&&ye.scrollHeight)&&Vn(!!ue,"smooth")},[Q,p,Y,ue,Vn,(Uo=b==null?void 0:b.current)==null?void 0:Uo.scrollHeight,c]);const Oe=(ye,Be)=>{r(jm,{search_keyword:ye,sm_ids:n,connector_name:Be,suggestion_type:Z})},st=(ye,Be,ft)=>{!Array.isArray(Be)||!Be.length?r(Bm,{search_keyword:ye,sm_ids:n,connector_name:ft,suggestion_type:Z}):Be.length&&r(Vm,{num_of_results:Be.length,search_keyword:ye,sm_ids:n,connector_name:ft,suggestion_type:Z})},{mutate:Et,reset:It,data:yr,isPending:Hn,isIdle:Jo}=VE(Oe,st),Da=_.useCallback(()=>{It(),k(null)},[It,k]),Wn=_.useCallback(()=>{t&&n.length&&s&&a(Ea({inboxIds:n,conversationId:s}))},[a,t,n,s]),ka=_.useCallback((ye,Be)=>{ye&&s&&Be&&a(xa({id:ye,channelType:"email",conversationId:s,externalResourceId:Be,contactEmail:t})).unwrap().catch(()=>{a(Br(null))})},[a,s,t]);if(_.useEffect(()=>{(async()=>{c&&(X(await Ka(c)),oe(await Ml(c)))})()},[c]),_.useEffect(()=>{Nt||B(oo||t)},[t,oo,Nt]),_.useEffect(()=>{Y&&c&&Pl(c)},[Y,c]),_.useEffect(()=>{var ye;if(te){v(!0);const{externalResourceId:Be}=te,ft=(ye=te.forms.find(ln=>ln.type==="edit"))==null?void 0:ye.id;ka(ft,Be)}else v(!1),a(D8())},[te,ka,a]),_.useEffect(()=>(Wn(),Gn(),()=>{a(p1.clearConnectorList())}),[a,Wn,Gn]),_.useEffect(()=>{if(H&&$&&$.length&&tt&&!l.current){const{cards_per_app:ye,total_empty_cards:Be,total_cards_with_errors:ft}=tt;r(fm,{numOfCards:$.length,total_cards_loaded:$.length,total_empty_cards:Be,total_cards_with_errors:ft,cards_per_app:ye,sm_ids:n}),l.current=!0}return()=>{l.current=!1}},[H,$,tt,r,n]),_.useEffect(()=>{s&&n&&n.length&&a(ma({inboxIds:n,conversationId:s,channelType:"email",isExpandedFormEnabled:kt}))},[a,n,s,kt]),_.useEffect(()=>{const ye=Be=>{var ln;if(!(Be instanceof CustomEvent))return;const ft=(ln=Be.detail)==null?void 0:ln.connectorKey;y({connectorKey:ft})};return window.addEventListener(Yc.OPEN_FORM_VIEW,ye),()=>{window.removeEventListener(Yc.OPEN_FORM_VIEW,ye)}},[]),_.useEffect(()=>{if(!(ne!=null&&ne.length)||!x.connectorKey)return;const ye=x.connectorKey;y({});const Be=ne.find(ft=>{var ln;return((ln=ft.connectorKey)==null?void 0:ln.toLowerCase())===(ye==null?void 0:ye.toLowerCase())});Be&&(q(Be),I(!0))},[ne,x]),!t.length||J===ee.LOADING)return u.jsx(Zv,{});const al=ye=>{r(bm,{connector_name:se,source:ye,sm_ids:n})},so=ye=>{I(!0),al(ye)},Na=()=>{w(!0),r(ym)},xn=ye=>{r(ye,T),Ce?N(!0):(I(!1),q(null))},ao=ye=>{if(te){const{connectorName:Be,title:ft}=te;r(ye,{connector_name:Be,card_title:ft,sm_ids:n,ug_id:i})}Ce?N(!0):a(Br(null))},qo=()=>{I(!1),a(Br(null)),S(void 0),N(!1)},$o=()=>{Wn(),a(p1.clearConnectorList())},il=[{label:"Go back",variant:"text",action:qo},{label:"Stay",variant:"contained",action:()=>N(!1)}],io=ne.length>0,Qo=j.length>0,Ra=()=>io||Qo?u.jsx(yx,{haveCreateObjects:io,haveLinkObjects:Qo,onCreateClick:()=>so(Uu.MAIN_BUTTON),onLinkClick:()=>w(!0)}):u.jsx(x1,{isAdmin:e,hideHeading:!0});return u.jsxs(cd,{ref:d,"data-testid":Array.isArray($)?"connector-agent":"loading",id:"connector-agent-container",stopOverflow:C||E,children:[u.jsx(D1,{shown:L,setShown:N,title:w8,description:_8,buttons:il}),u.jsx(K3,{onWheel:()=>h(!0),ref:b,children:P?u.jsxs(u.Fragment,{children:[u.jsx(F5,{connectors:ze,isWriteFlowEnabled:Me,haveCreateObjects:io,haveLinkObjects:Qo,cards:$,handleCreateNewObject:()=>so(Uu.ICON),handleLinkNewObject:Na}),Qe?u.jsx(AE,{selectedObject:D,setSelectedObject:k,fetchSearchResults:Et,onReset:Da,root:d.current}):null,u.jsxs(Gr,{children:[u.jsx(Hr,{condition:Qe&&Hn,children:u.jsx(jE,{})},"search"),u.jsx(Hr,{condition:Qe&&!!D&&!Jo,children:u.jsx(PE,{searchResults:yr??[],selectedObject:D,onReset:Da,fetchCards:Wn})},"results"),u.jsxs(Hr,{fallback:!0,children:[ot&&($!=null&&$.length)?u.jsx(Kv,{emailHeaders:Yo,selectedEmail:M,root:d.current,isLoading:Nt,setSelectedEmail:B}):null,Xe?u.jsx(Xv,{}):null,u.jsxs(Gr,{children:[u.jsxs(Hr,{condition:!!$&&$.length>0,children:[u.jsx(Cv,{cards:$,specificCardData:G,email:M??"",specificConnectorApiStatus:V,onCardUnlinking:Wn}),u.jsx("div",{ref:g,children:vn?u.jsx(D3,{connectors:ze,expanded:Q}):null})]},"cards-list"),u.jsx(Hr,{condition:!($!=null&&$.length)&&Me,children:Ra()},"create-banner")]})]},"cards")]})]}):u.jsx(x1,{isAdmin:e})}),u.jsx(Fc,{onClose:()=>ao(Fm),isOpen:m,setIsOpen:v,title:f3,portalId:"connector-layover-portal",backButtonTooltip:"Back",children:u.jsx(N1,{isEdit:!0,onClose:()=>ao(Om),onCreateSuccess:$o,metaData:T,setMetaData:S,connectors:ze})}),u.jsx(Fc,{onClose:()=>xn(wm),portalId:"connector-layover-portal",isOpen:C,setIsOpen:I,children:u.jsx(N1,{onClose:()=>xn(Im),onCreateSuccess:$o,metaData:T,setMetaData:S,defaultOption:z,connectors:ze})}),u.jsx(Fc,{onClose:()=>w(!1),portalId:"connector-layover-portal",isOpen:E,setIsOpen:w,children:u.jsx(px,{setOpenTaskLinking:w,onLinkingSuccess:Wn})}),!P&&u.jsx(Z3,{})]})},ZE=({children:e,sendTrackingEvent:t,contactEmail:n,baseUrls:r={},currentSmIds:o=[],userEmail:s,metaData:a,availableFeatures:i,conversationId:c,connectorFunctions:l,stackingContext:d,isAdmin:g=!1,actionQueue:b})=>{const x=_.useMemo(()=>({userEmail:s,email:n,baseUrls:r,currentSmIds:o,metaData:a,conversationId:c,sendTrackingEvent:t||(()=>{}),availableFeatures:i,isAdmin:g,connectorFunctions:l,stackingContext:d,actionQueue:b}),[s,n,r,t,o,a,i,c,g,l,d,b]);return u.jsx(He.Provider,{value:x,children:e})},Jc=({children:e})=>{const[t]=_.useState(()=>new oE);return u.jsx(lE,{client:t,children:e})},XE=wd({cardList:K8,write:k8,common:s8}),qc=Q4({reducer:XE,devTools:!0}),zE=({children:e,userEmail:t,extraParams:n,contactEmail:r,baseUrls:o,availableFeatures:s,connectorFunctions:a,stackingContext:i,actionQueue:c})=>u.jsx(Pi,{store:qc,children:u.jsx(f.HiverProvider,{custom:!0,children:u.jsx(Jc,{children:u.jsx(ZE,{userEmail:t,availableFeatures:s,sendTrackingEvent:n==null?void 0:n.sendTrackingEvent,contactEmail:r,currentSmIds:n==null?void 0:n.currentSmIds,metaData:n==null?void 0:n.metaData,conversationId:n==null?void 0:n.conversationId,baseUrls:o,connectorFunctions:a,stackingContext:i,actionQueue:c,isAdmin:n==null?void 0:n.isAdmin,children:u.jsx(_.Suspense,{fallback:u.jsx(u.Fragment,{}),children:e})})})})}),$c=f.styled(f.Box)`
1292
+ `,jE=()=>u.jsxs(f.Stack,{marginTop:"12px",children:[u.jsx(zc,{variant:"rounded",width:"50%",height:"16px",animation:"wave",margin:"0 0 18px 0"}),u.jsx(f.Stack,{gap:"17px",children:u.jsxs(dp,{gap:"8px",disableHover:!0,children:[u.jsx(zc,{variant:"rounded",width:"30%",height:"16px",animation:"wave"}),u.jsx(zc,{variant:"rounded",width:"70%",height:"16px",animation:"wave"})]})})]}),BE=async({id:e,searchString:t,args:n})=>{try{if(e===void 0||t===void 0)return[];const r=await Ne({url:IE.replace(":formId",e.toString()),method:Ve.POST,data:{search_string:t,args:n}});let o=null;return r!=null&&r.data&&"data"in r.data&&(o=r.data.data),o}catch(r){Se({message:pn,type:qe}),console.error(r)}},VE=(e,t)=>mn({mutationFn:BE,onMutate:({searchString:n,connectorName:r})=>{e(n,r)},onSuccess:(n,{searchString:r,connectorName:o})=>{t(r,n,o)}}),Yc={OPEN_FORM_VIEW:"connector-agent-open-form-view"},GE=(e,t={})=>{const{delayAfterLoad:n=1e3}=t,r=_.useRef(!1),o=_.useRef(void 0),s=_.useCallback((c="auto")=>{const l=e.current;l&&l.scrollIntoView({behavior:c})},[e]),a=_.useCallback((c,l="smooth")=>{r.current||(o.current!==void 0&&clearTimeout(o.current),c&&(o.current=setTimeout(()=>{s(l),r.current=!0},n)))},[s,n]),i=_.useCallback(()=>{r.current=!1,o.current!==void 0&&clearTimeout(o.current)},[]);return _.useEffect(()=>()=>{o.current!==void 0&&clearTimeout(o.current)},[]),{scrollOnceAfterLoad:a,resetScrollState:i,hasScrolledOnce:r.current}},HE=({enabled:e,...t})=>{const{actionQueue:n}=_.useContext(He);n&&e&&n.register(t),_.useEffect(()=>{if(n)return()=>{n.destroy()}},[n,e])},WE=({isAdmin:e=!1})=>{var Uo;const{email:t,currentSmIds:n,sendTrackingEvent:r,availableFeatures:o,conversationId:s}=_.useContext(He),a=Ht(),{userGroupId:i,userId:c}=Qt()||{},l=_.useRef(!1),d=_.useRef(null),g=_.useRef(null),b=_.useRef(null),[x,y]=_.useState({}),[p,h]=_.useState(!1),[m,v]=_.useState(!1),[C,I]=_.useState(!1),[E,w]=_.useState(!1),[T,S]=_.useState(),[L,N]=_.useState(!1),[D,k]=_.useState(null),[M,B]=_.useState(),[z,q]=_.useState(null),[Q,X]=_.useState(!1),[Y,oe]=_.useState(!1),$=me(P8),P=me(j8),G=me(V8),V=me(G8),H=me(W8),J=me(B8),ne=me(g1),se=me(nv),j=me(m1),te=me(b1),Ce=me(y1),Z=me(ox),Xe=at(o,Jm),Me=at(o,Vu),Qe=at(o,e3),ot=at(o,n3),vn=at(o,r3),kt=at(o,o3);HE({conversationId:s,openCreateForm:()=>I(!0),enabled:P});const tt=_.useMemo(()=>!$||!$.length?null:Y8($,G,V),[$,G,V]),ze=v3(G),{data:br,isLoading:Nt}=lp({senderEmail:t,conversationId:String(s),enabled:ot&&!!t}),{emailHeaders:Yo,selectedEmail:oo}=br??{},{scrollOnceAfterLoad:Vn,resetScrollState:Gn}=GE(g),ue=J!==ee.LOADING&&(!V||!Object.values(V).some(ye=>ye===ee.LOADING))&&$&&$.length>0;_.useLayoutEffect(()=>{var ye;Q&&!p&&Y&&((ye=b==null?void 0:b.current)!=null&&ye.scrollHeight)&&Vn(!!ue,"smooth")},[Q,p,Y,ue,Vn,(Uo=b==null?void 0:b.current)==null?void 0:Uo.scrollHeight,c]);const Oe=(ye,Be)=>{r(jm,{search_keyword:ye,sm_ids:n,connector_name:Be,suggestion_type:Z})},st=(ye,Be,ft)=>{!Array.isArray(Be)||!Be.length?r(Bm,{search_keyword:ye,sm_ids:n,connector_name:ft,suggestion_type:Z}):Be.length&&r(Vm,{num_of_results:Be.length,search_keyword:ye,sm_ids:n,connector_name:ft,suggestion_type:Z})},{mutate:Et,reset:It,data:yr,isPending:Hn,isIdle:Jo}=VE(Oe,st),Da=_.useCallback(()=>{It(),k(null)},[It,k]),Wn=_.useCallback(()=>{t&&n.length&&s&&a(Ea({inboxIds:n,conversationId:s}))},[a,t,n,s]),ka=_.useCallback((ye,Be)=>{ye&&s&&Be&&a(xa({id:ye,channelType:"email",conversationId:s,externalResourceId:Be,contactEmail:t})).unwrap().catch(()=>{a(Br(null))})},[a,s,t]);if(_.useEffect(()=>{(async()=>{c&&(X(await Ka(c)),oe(await Ml(c)))})()},[c]),_.useEffect(()=>{Nt||B(oo||t)},[t,oo,Nt]),_.useEffect(()=>{Y&&c&&Pl(c)},[Y,c]),_.useEffect(()=>{var ye;if(te){v(!0);const{externalResourceId:Be}=te,ft=(ye=te.forms.find(ln=>ln.type==="edit"))==null?void 0:ye.id;ka(ft,Be)}else v(!1),a(D8())},[te,ka,a]),_.useEffect(()=>(Wn(),Gn(),()=>{a(p1.clearConnectorList())}),[a,Wn,Gn]),_.useEffect(()=>{if(H&&$&&$.length&&tt&&!l.current){const{cards_per_app:ye,total_empty_cards:Be,total_cards_with_errors:ft}=tt;r(fm,{numOfCards:$.length,total_cards_loaded:$.length,total_empty_cards:Be,total_cards_with_errors:ft,cards_per_app:ye,sm_ids:n}),l.current=!0}return()=>{l.current=!1}},[H,$,tt,r,n]),_.useEffect(()=>{s&&n&&n.length&&a(ma({inboxIds:n,conversationId:s,channelType:"email",isExpandedFormEnabled:kt}))},[a,n,s,kt]),_.useEffect(()=>{const ye=Be=>{var ln;if(!(Be instanceof CustomEvent))return;const ft=(ln=Be.detail)==null?void 0:ln.connectorKey;y({connectorKey:ft})};return window.addEventListener(Yc.OPEN_FORM_VIEW,ye),()=>{window.removeEventListener(Yc.OPEN_FORM_VIEW,ye)}},[]),_.useEffect(()=>{if(!(ne!=null&&ne.length)||!x.connectorKey)return;const ye=x.connectorKey;y({});const Be=ne.find(ft=>{var ln;return((ln=ft.connectorKey)==null?void 0:ln.toLowerCase())===(ye==null?void 0:ye.toLowerCase())});Be&&(q(Be),I(!0))},[ne,x]),!t.length||J===ee.LOADING)return u.jsx(Zv,{});const al=ye=>{r(bm,{connector_name:se,source:ye,sm_ids:n})},so=ye=>{I(!0),al(ye)},Na=()=>{w(!0),r(ym)},xn=ye=>{r(ye,T),Ce?N(!0):(I(!1),q(null))},ao=ye=>{if(te){const{connectorName:Be,title:ft}=te;r(ye,{connector_name:Be,card_title:ft,sm_ids:n,ug_id:i})}Ce?N(!0):a(Br(null))},qo=()=>{I(!1),a(Br(null)),S(void 0),N(!1)},$o=()=>{Wn(),a(p1.clearConnectorList())},il=[{label:"Go back",variant:"text",action:qo},{label:"Stay",variant:"contained",action:()=>N(!1)}],io=ne.length>0,Qo=j.length>0,Ra=()=>io||Qo?u.jsx(yx,{haveCreateObjects:io,haveLinkObjects:Qo,onCreateClick:()=>so(Uu.MAIN_BUTTON),onLinkClick:()=>w(!0)}):u.jsx(x1,{isAdmin:e,hideHeading:!0});return u.jsxs(cd,{ref:d,"data-testid":Array.isArray($)?"connector-agent":"loading",id:"connector-agent-container",stopOverflow:C||E,children:[u.jsx(D1,{shown:L,setShown:N,title:w8,description:_8,buttons:il}),u.jsx(K3,{onWheel:()=>h(!0),ref:b,children:P?u.jsxs(u.Fragment,{children:[u.jsx(F5,{connectors:ze,isWriteFlowEnabled:Me,haveCreateObjects:io,haveLinkObjects:Qo,cards:$,handleCreateNewObject:()=>so(Uu.ICON),handleLinkNewObject:Na}),Qe?u.jsx(AE,{selectedObject:D,setSelectedObject:k,fetchSearchResults:Et,onReset:Da,root:d.current}):null,u.jsxs(Gr,{children:[u.jsx(Hr,{condition:Qe&&Hn,children:u.jsx(jE,{})},"search"),u.jsx(Hr,{condition:Qe&&!!D&&!Jo,children:u.jsx(PE,{searchResults:yr??[],selectedObject:D,onReset:Da,fetchCards:Wn})},"results"),u.jsxs(Hr,{fallback:!0,children:[ot&&($!=null&&$.length)?u.jsx(Kv,{emailHeaders:Yo,selectedEmail:M,root:d.current,isLoading:Nt,setSelectedEmail:B}):null,Xe?u.jsx(Xv,{}):null,u.jsxs(Gr,{children:[u.jsxs(Hr,{condition:!!$&&$.length>0,children:[u.jsx(Cv,{cards:$,specificCardData:G,email:M??"",specificConnectorApiStatus:V,onCardUnlinking:Wn}),u.jsx("div",{ref:g,children:vn?u.jsx(D3,{connectors:ze,expanded:Q}):null})]},"cards-list"),u.jsx(Hr,{condition:!($!=null&&$.length)&&Me,children:Ra()},"create-banner")]})]},"cards")]})]}):u.jsx(x1,{isAdmin:e})}),u.jsx(Fc,{onClose:()=>ao(Fm),isOpen:m,setIsOpen:v,title:f3,portalId:"connector-layover-portal",backButtonTooltip:"Back",children:u.jsx(N1,{isEdit:!0,onClose:()=>ao(Om),onCreateSuccess:$o,metaData:T,setMetaData:S,connectors:ze})}),u.jsx(Fc,{onClose:()=>xn(wm),portalId:"connector-layover-portal",isOpen:C,setIsOpen:I,children:u.jsx(N1,{onClose:()=>xn(Im),onCreateSuccess:$o,metaData:T,setMetaData:S,defaultOption:z,connectors:ze})}),u.jsx(Fc,{onClose:()=>w(!1),portalId:"connector-layover-portal",isOpen:E,setIsOpen:w,children:u.jsx(px,{setOpenTaskLinking:w,onLinkingSuccess:Wn})}),!P&&u.jsx(Z3,{})]})},ZE=({children:e,sendTrackingEvent:t,contactEmail:n,baseUrls:r={},currentSmIds:o=[],userEmail:s,metaData:a,availableFeatures:i,conversationId:c,connectorFunctions:l,stackingContext:d,isAdmin:g=!1,actionQueue:b})=>{const x=_.useMemo(()=>({userEmail:s,email:n,baseUrls:r,currentSmIds:o,metaData:a,conversationId:c,sendTrackingEvent:t||(()=>{}),availableFeatures:i,isAdmin:g,connectorFunctions:l,stackingContext:d,actionQueue:b}),[s,n,r,t,o,a,i,c,g,l,d,b]);return u.jsx(He.Provider,{value:x,children:e})},Jc=({children:e})=>{const[t]=_.useState(()=>new oE);return u.jsx(lE,{client:t,children:e})},XE=wd({cardList:K8,write:k8,common:s8}),qc=Q4({reducer:XE,devTools:!0}),zE=({children:e,userEmail:t,extraParams:n,contactEmail:r,baseUrls:o,availableFeatures:s,connectorFunctions:a,stackingContext:i,actionQueue:c})=>u.jsx(Pi,{store:qc,children:u.jsx(f.HiverProvider,{custom:!0,children:u.jsx(Jc,{children:u.jsx(ZE,{userEmail:t,availableFeatures:s,sendTrackingEvent:n==null?void 0:n.sendTrackingEvent,contactEmail:r,currentSmIds:n==null?void 0:n.currentSmIds,metaData:n==null?void 0:n.metaData,conversationId:n==null?void 0:n.conversationId,baseUrls:o,connectorFunctions:a,stackingContext:i,actionQueue:c,isAdmin:n==null?void 0:n.isAdmin,children:u.jsx(_.Suspense,{fallback:u.jsx(u.Fragment,{}),children:e})})})})}),$c=f.styled(f.Box)`
1293
1293
  height: inherit;
1294
1294
  .MuiScopedCssBaseline-root {
1295
1295
  height: inherit;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hiver/connector-agent",
3
- "version": "4.6.0-quickAccess-beta.0",
3
+ "version": "4.6.0",
4
4
  "main": "index.es.js",
5
5
  "module": "index.es.js",
6
6
  "types": "index.d.ts",