@bikdotai/bik-component-library 0.0.695 → 0.0.696
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function e(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}Object.defineProperty(exports,"__esModule",{value:!0});var t,r,a=e(require("react"));function l(){return l=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},l.apply(this,arguments)}var n=e=>a.createElement("svg",l({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},e),t||(t=a.createElement("g",{clipPath:"url(#box_search_svg__a)"},a.createElement("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 11.372v11m0 0-8.447-4.224A1 1 0 0 1 3 17.255V7.46a1 1 0 0 1 .514-.874l8-4.444a1 1 0 0 1 .972 0l8 4.444A1 1 0 0 1 21 7.46v.912m-9 14 3-2"}),a.createElement("path",{stroke:"currentColor",strokeWidth:2,d:"m20.5 6.372-8.007 4.71a1 1 0 0 1-.993.012L3 6.372"}),a.createElement("g",{fill:"currentColor",fillRule:"evenodd",clipPath:"url(#box_search_svg__b)",clipRule:"evenodd"},a.createElement("path",{d:"M21.232 17.634a3.375 3.375 0 1 1 .53-.53l1.378 1.378a.375.375 0 1 1-.53.53l-1.378-1.378ZM16.5 14.997a2.625 2.625 0 1 1 4.516 1.821.378.378 0 0 0-.07.07 2.625 2.625 0 0 1-4.446-1.89Z"}),a.createElement("path",{d:"m22.61 19.015-1.378-1.378a3.375 3.375 0 1 1 .53-.53l1.378 1.378a.375.375 0 0 1-.53.53Zm-.375-1.945a3.735 3.735 0 1 0-1.04 1.04l1.16 1.16a.735.735 0 0 0 1.04-1.04l-1.16-1.16Zm-3.11-4.335a2.265 2.265 0 1 0 1.556 3.91.737.737 0 0 1 .09-.09 2.265 2.265 0 0 0-1.646-3.82Zm1.89 4.086a2.625 2.625 0 1 0-.07.07.377.377 0 0 1 .07-.07Z"})))),r||(r=a.createElement("defs",null,a.createElement("clipPath",{id:"box_search_svg__a"},a.createElement("path",{fill:"#fff",d:"M0-.132h24v24H0z"})),a.createElement("clipPath",{id:"box_search_svg__b"},a.createElement("path",{fill:"#fff",d:"M15 10.87h9v9h-9z"})))));exports.default=n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js"),t=require("@bikdotai/bik-models/growth"),s=require("../../assets/icons/boxV2.svg.js"),i=require("../../assets/icons/chevronDownOutline.svg.js"),o=require("../../assets/icons/chevronUpOutline.svg.js"),n=require("../../assets/icons/cross.svg.js"),r=require("../../assets/icons/edit.svg.js"),l=require("../../assets/icons/filePdf.svg.js"),a=require("../../assets/icons/help.svg.js"),d=require("../../assets/icons/info.svg.js"),c=require("../../assets/icons/openai.svg.js"),u=require("../../assets/icons/plus.svg.js"),x=require("../../assets/icons/redirect.svg.js"),p=require("../../assets/icons/text_t9.svg.js"),j=require("../../assets/icons/website.svg.js"),m=require("react"),g=require("../../constants/Theme.js"),h=require("../button/Button.js"),y=require("../icon-button/IconButton.js"),E=require("../shimmer/ShimmerComponent/BikShimmer.js"),C=require("../side-modal/SideModal.js"),R=require("../tag/Tag.js"),O=require("../tooltips/Tooltip.js"),f=require("../TypographyStyle.js"),v=require("./DataSourceInfoFooter.js"),S=require("./DataSourcePanel.style.js"),T=require("./IntentConfig.js"),I=require("./Modals/DescriptionModal.js"),b=require("./model.js");exports.DataSourcePanel=L=>{var w,D;const{appType:N,storeId:A,messageSource:F,setMessageSourcePanel:_,hideCloseButton:k,isSourceInfoFetched:B,allSourceInfoDetail:q,ChecklistType:P,title:M,zeroStateButton:U,editableSources:K,preFillTrainingSourceCount:W,redirect:$,footerButtonOption:H,fetchTrainingSourceCount:Q,fetchProductFAQCount:G,productSourceData:Y,reasonForAiGeneratedResponse:z,showAiResponseReason:X,productSearchRule:V,onEditProductSearchRule:J}=L,{sources:Z}=F,ee=["blog","article","page","policy"],[te,se]=m.useState(!1),[ie,oe]=m.useState(!1),[ne,re]=m.useState(!1),[le,ae]=m.useState(0),[de,ce]=m.useState(),[ue,xe]=m.useState(null!=W?W:{}),[pe,je]=m.useState(!1),[me,ge]=m.useState(!1),he={};T.intentConfig.forEach((t=>{let{key:s,type:i,tagText:o}=t;P[s]&&(he[P[s]]=e.jsxRuntimeExports.jsx(R.Tag,{theme:"light",type:i,tagText:o,cursor:"pointer"}))}));const ye=Z.filter((e=>"PRODUCTS"==e.type||"Products"==e.subTitle||e.productId)),Ee=Z.filter((e=>"PRODUCTS"!=e.type&&"Products"!=e.subTitle&&!e.productId)),Ce=m.useMemo((()=>{const e={};return["STORE_INFORMATION","CONTACT_INFO","STORE_LOCATION","SHIPPING_POLICY","RETURN_AND_REFUND","SALES_AND_OFFERS","SALES_AND_OFFERS_ISSUES","PRODUCT_CUSTOMISATION","PAYMENT_METHODS","CHECKOUT_ENQUIRY","ORDER_ENQUIRY"].forEach((t=>{P[t]&&(e[P[t]]=P[t])})),["COLLABORATION","SUBSCRIPTION_ENQUIRY"].forEach((t=>{e[t]=t})),e}),[P]);m.useEffect((()=>{var e,t,s,i;if(!(null==F?void 0:F.messageId))return;se(!0),oe(!0),re(!1!==(null===(t=null===(e=F.sources)||void 0===e?void 0:e[0])||void 0===t?void 0:t.isTrainable)||!!(null===(i=null===(s=F.sources)||void 0===s?void 0:s[0])||void 0===i?void 0:i.insights));const o=F.sources.filter((e=>!!e.productId)).map((e=>e.productId)),n=Array.from(new Set(o)).filter((e=>!!e));G(A,n).then((e=>ae(e))).then((()=>{W?(xe(W),setTimeout((()=>{se(!1),oe(!1)}),100)):(setTimeout((()=>se(!1)),100),Q(A).then((e=>xe(e))).then((()=>setTimeout((()=>{oe(!1)}),100))))}))}),[G,Q,null==F?void 0:F.messageId,F.sources,W,A]);const Re=e=>!!(e&&0===e.length||(null==F?void 0:F.isUnsatisfactoryAnswer)),Oe=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var s;return"custom"==e?e=b.CustomDataType.FILES:ee.includes(e)?e=b.CustomDataType.FETCHED_LINKS:"url"==e?e=b.CustomDataType.WEBSITE_LINKS:"text"===e?e=b.CustomDataType.TEXTS:"faq"===e&&(e=b.CustomDataType.FAQ),t?e:null===(s=null==e?void 0:e.toLowerCase())||void 0===s?void 0:s.replace(/_/g," ")},fe=e=>e?"faq"==e.toLocaleLowerCase()?"FAQ":"openai"==e.toLocaleLowerCase()?"OPENAI":"files"==e.toLocaleLowerCase()?"PDF":"texts"==e.toLocaleLowerCase()?"Custom text":((e=(e=e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).replace("_"," ")).endsWith("s")&&(e=e.slice(0,-1)),e.replace("Website","Manual")):"",ve=t=>"products"==t||"product"==t?e.jsxRuntimeExports.jsx(s.default,{height:16,width:16,color:g.COLORS.content.secondary}):"files"==t?e.jsxRuntimeExports.jsx(l.default,{height:16,width:16,color:g.COLORS.content.secondary}):"website links"==t||"fetched links"==t?e.jsxRuntimeExports.jsx(j.default,{height:16,width:16,color:g.COLORS.content.secondary}):"faq"==t?e.jsxRuntimeExports.jsx(a.default,{height:16,width:16,color:g.COLORS.content.secondary}):"texts"==t?e.jsxRuntimeExports.jsx(p.default,{height:16,width:16,color:g.COLORS.content.secondary}):e.jsxRuntimeExports.jsx(c.default,{height:16,width:16,color:g.COLORS.content.secondary}),Se=e=>{const t=e.replace(/(<([^>]+)>)/gi,""),s=document.createElement("textarea");return s.innerHTML=t,s.value};if(te||!B)return e.jsxRuntimeExports.jsx(S.SourceInfoDetailsStyle,{children:e.jsxRuntimeExports.jsx(E.BikShimmer,{boxes:[{width:"100px",height:"16px"},{width:"0",height:"4px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"0",height:"4px"},{width:"100%",height:"16px"}]})});const Te=s=>{const{title:n,count:r,isExpanded:l,onToggle:a,children:d}=s;return e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",cursor:"pointer"},onClick:a},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[e.jsxRuntimeExports.jsx(f.BodyCaption,Object.assign({style:{fontWeight:"600"}},{children:n})),N===t.ApplicationType.MANIFEST?e.jsxRuntimeExports.jsx("div",Object.assign({style:{backgroundColor:g.COLORS.surface.subdued,color:g.COLORS.content.secondary,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:"500"}},{children:r})):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{})]})),e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:N===t.ApplicationType.BIK?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):l?e.jsxRuntimeExports.jsx(i.default,{width:20,height:20,color:g.COLORS.content.primary}):e.jsxRuntimeExports.jsx(o.default,{width:20,height:20,color:g.COLORS.content.primary})})]})),l&&d]})};return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(S.SourceInfoDetailsStyle,{children:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",paddingBottom:"12px"}},{children:[!!M&&e.jsxRuntimeExports.jsx(f.TitleSmall,{children:M}),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsx(f.BodyCaption,Object.assign({color:g.COLORS.content.secondary},{children:"Intent"})),null!==(w=he[F.intent])&&void 0!==w?w:he.GENERIC,!k&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>_(void 0)},{children:e.jsxRuntimeExports.jsx(n.default,{height:20,width:20,color:g.COLORS.content.secondary})}))]})),V&&e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"6px"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[e.jsxRuntimeExports.jsx(f.BodySecondary,Object.assign({color:g.COLORS.content.primary},{children:V.rule_name})),J&&V.rule_id&&e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[e.jsxRuntimeExports.jsx(f.BodyCaption,Object.assign({color:g.COLORS.content.secondary},{children:"Edit search rule"})),e.jsxRuntimeExports.jsx(y.IconButton,{Icon:r.default,height:16,width:16,bordered:!0,iconColor:g.COLORS.content.secondary,onClick:()=>J(V.rule_id)})]}))]})),V.keywords&&V.keywords.length>0&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"12px",backgroundColor:g.COLORS.surface.subdued,borderRadius:"8px",border:`1px dashed ${g.COLORS.stroke.primary}`}},{children:V.keywords.map(((t,s)=>e.jsxRuntimeExports.jsx(R.Tag,{tagText:t,theme:"light"},`keyword-${s}`)))}))]})),Re(Z)?e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",margin:"auto",justifyContent:"center",alignItems:"center",height:"calc(100vh - 300px)"}},{children:(()=>{var t,s;return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",margin:"0px 30px",gap:"8px"}},{children:[e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"12px",backgroundColor:`${g.COLORS.background.negative.light}`,borderRadius:"100px"}},{children:e.jsxRuntimeExports.jsx(d.default,{width:24,height:24,color:g.COLORS.stroke.negative.vibrant})})),e.jsxRuntimeExports.jsx("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e.jsxRuntimeExports.jsx(f.TitleSmall,{children:"Insufficient data"})})),e.jsxRuntimeExports.jsx(f.BodySecondary,Object.assign({color:g.COLORS.content.secondary,style:{display:"flex",justifyContent:"center",textAlign:"center"}},{children:"No data available to answer this query. Add an FAQ to address it in the future"})),U&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e.jsxRuntimeExports.jsx(h.Button,{LeadingIcon:null!==(t=U.leadingIcon)&&void 0!==t?t:u.default,buttonText:null!==(s=U.title)&&void 0!==s?s:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{U.onClick()}})}))]}))})()})):e.jsxRuntimeExports.jsx(R.Tag,{LeadingIcon:d.default,version:"2.0",type:"grey",theme:"light",alignIcon:"start",contentPadding:12,tagText:F.isEditable?`If any of the information is incorrect, update the original data source and sync it again. Alternatively, you can make local corrections directly in ${N===t.ApplicationType.BIK?"BIK":"Manifest"}.`:"Edit the original source and save again to update the response"})]})),!Re(Z)&&e.jsxRuntimeExports.jsxs("div",Object.assign({className:"info-container"},{children:[e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:ye.length>0&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"info-product-source"},{children:e.jsxRuntimeExports.jsx(Te,Object.assign({title:"Product Sources",count:ye.length,isExpanded:N!==t.ApplicationType.MANIFEST||pe,onToggle:()=>je(!pe)},{children:e.jsxRuntimeExports.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:ye.map(((t,s)=>{var i,o,n,l;const a=Oe(t.type||t.subTitle||"OpenAI"),d=Oe(t.type||t.subTitle||"OpenAI",!0),c=fe(a),u=null==K?void 0:K.includes(d),p=q[null!==(i=t.productId)&&void 0!==i?i:"Products"],j=t.title,m=t.productId&&(null==Y?void 0:Y[t.productId]),h=m&&m.metafield.join(", ");return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==ye?void 0:ye.length)?`1px solid ${g.COLORS.stroke.primary}`:"none"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[ve(a),e.jsxRuntimeExports.jsx(O.Tooltip,Object.assign({body:j,placement:"top"},{children:e.jsxRuntimeExports.jsx(f.BodySecondary,Object.assign({style:d==b.CustomDataType.FETCHED_LINKS||d==b.CustomDataType.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:g.COLORS.content.primary,className:"clamp-title",onClick:()=>d==b.CustomDataType.FETCHED_LINKS||d==b.CustomDataType.WEBSITE_LINKS?$(t):{}},{children:j}))}))]})),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==P.EMAIL_COLLECTION&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(f.BodyCaption,Object.assign({color:g.COLORS.content.secondary},{children:c}))}),(t.link||t.docId)&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:u?e.jsxRuntimeExports.jsx(y.IconButton,{Icon:r.default,height:16,width:16,iconColor:g.COLORS.content.secondary,onClick:()=>null==p?void 0:p.onEditClick(p.data,p.type),disabled:!p,disabledTooltip:"This source is deleted"}):e.jsxRuntimeExports.jsx(y.IconButton,{Icon:x.default,height:16,width:16,iconColor:g.COLORS.content.secondary,disabled:"custom"===t.type&&!p,disabledTooltip:"This source is deleted",onClick:()=>$(t)})}))]}))]})),m&&e.jsxRuntimeExports.jsxs(f.BodyCaption,{children:[e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>{var e;ce({title:j,description:Se(m.description),imageUrl:null!==(e=t.imageUrl)&&void 0!==e?e:"",onClose:()=>ce(void 0)})}},{children:`${null===(o=m.description)||void 0===o?void 0:o.length} characters description,`})),e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>m.onEditFaqClick(m.faqs)},{children:`${null===(n=m.faqs)||void 0===n?void 0:n.length} FAQs, `})),e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text2"},{children:"and"})),e.jsxRuntimeExports.jsx(O.Tooltip,Object.assign({body:h,placement:"top"},{children:e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text1"},{children:`${null===(l=m.metafield)||void 0===l?void 0:l.length} metafields`}))}))]})]}),`info-${s}`)}))}))}))}))}),e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Ee.length>0&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"info-content-source"},{children:e.jsxRuntimeExports.jsx(Te,Object.assign({title:"Content Sources",count:Ee.length,isExpanded:N!==t.ApplicationType.MANIFEST||me,onToggle:()=>ge(!me)},{children:e.jsxRuntimeExports.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Ee.map(((t,s)=>{var i,o,n,l,a,d,c,u,p,j,m,h,E,C,R,v,S;const T=Oe(t.type||t.subTitle||"OpenAI"),I=Oe(t.type||t.subTitle||"OpenAI",!0),L=fe(T),w=null==K?void 0:K.includes(I),D="Products"===t.subTitle?q[null!==(i=t.productId)&&void 0!==i?i:"Products"]:q[null!==(o=t.docId)&&void 0!==o?o:""],N=I.toLowerCase()===(null===(n=b.CustomDataType.FAQ)||void 0===n?void 0:n.toLowerCase())?"faq"===(null===(l=t.title)||void 0===l?void 0:l.toLowerCase())?t.subTitle:t.title:I.toLowerCase()===(null===(a=b.CustomDataType.FILES)||void 0===a?void 0:a.toLowerCase())||I.toLowerCase()===(null===(d=b.CustomDataType.FETCHED_LINKS)||void 0===d?void 0:d.toLowerCase())||I.toLowerCase()===(null===(c=b.CustomDataType.TEXTS)||void 0===c?void 0:c.toLowerCase())?t.title:I.toLowerCase()===(null===(u=b.CustomDataType.WEBSITE_LINKS)||void 0===u?void 0:u.toLowerCase())?t.title.split("/")[t.title.split("/").length-1].replace(/[^\w\s]/gi," ").replace(/^(.)(.*)$/,((e,t,s)=>t.toUpperCase()+s)):t.intent===P.EMAIL_COLLECTION?L:t.title,A="faq"===I.toLowerCase()?null!==(m=null!==(p=null==D?void 0:D.content)&&void 0!==p?p:null===(j=null==D?void 0:D.data)||void 0===j?void 0:j.answer)&&void 0!==m?m:"":I.toLowerCase()===(null===(h=b.CustomDataType.FETCHED_LINKS)||void 0===h?void 0:h.toLowerCase())||I.toLowerCase()===(null===(E=b.CustomDataType.WEBSITE_LINKS)||void 0===E?void 0:E.toLowerCase())||I.toLowerCase()===(null===(C=b.CustomDataType.TEXTS)||void 0===C?void 0:C.toLowerCase())?null!==(S=null!==(R=null==D?void 0:D.content)&&void 0!==R?R:null===(v=null==D?void 0:D.data)||void 0===v?void 0:v.fileContentText)&&void 0!==S?S:"":t.intent===P.EMAIL_COLLECTION?"Collect leads before replying to messages":"";return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==Ee?void 0:Ee.length)?`1px solid ${g.COLORS.stroke.primary}`:"none"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[ve(T),e.jsxRuntimeExports.jsx(O.Tooltip,Object.assign({body:N,placement:"top"},{children:e.jsxRuntimeExports.jsx(f.BodySecondary,Object.assign({style:I==b.CustomDataType.FETCHED_LINKS||I==b.CustomDataType.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:g.COLORS.content.primary,className:"clamp-title",onClick:()=>I==b.CustomDataType.FETCHED_LINKS||I==b.CustomDataType.WEBSITE_LINKS?$(t):{}},{children:N}))}))]})),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==P.EMAIL_COLLECTION&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(f.BodyCaption,Object.assign({color:g.COLORS.content.secondary},{children:L}))}),(t.link||t.docId)&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:w?e.jsxRuntimeExports.jsx(y.IconButton,{Icon:r.default,height:16,width:16,iconColor:g.COLORS.content.secondary,onClick:()=>null==D?void 0:D.onEditClick(D.data,D.type),disabled:!D,disabledTooltip:"This source is deleted"}):e.jsxRuntimeExports.jsx(y.IconButton,{Icon:x.default,height:16,width:16,iconColor:g.COLORS.content.secondary,disabled:"custom"===t.type&&!D,disabledTooltip:"This source is deleted",onClick:()=>$(t)})}))]}))]})),(null!=A?A:"").trim()&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${g.COLORS.stroke.primary}`,borderRadius:"4px",backgroundColor:g.COLORS.surface.subdued}},{children:e.jsxRuntimeExports.jsx(f.BodyCaption,Object.assign({color:g.COLORS.content.primary,className:"clamp-description"},{children:Se(null!=A?A:"").trim()}))}))]}),`info-${s}`)}))}))}))}))})]})),ne&&!Re(Z)&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"footer"},{children:e.jsxRuntimeExports.jsx(v.default,{appType:N,storeId:A,messageSource:F,sourceIntent:null!==(D=F.intent)&&void 0!==D?D:P.GENERIC,faqCount:le,trainingSourceCount:ue,ShowTrainingDataSource:Ce,ChecklistType:P,footerButtonOption:H,isFooterLoading:ie,reasonForAiGeneratedResponse:z,showAiResponseReason:X})}))]})}),de&&e.jsxRuntimeExports.jsx(C.SideModal,Object.assign({header:"Product description",onClose:()=>ce(void 0),width:"30%"},{children:e.jsxRuntimeExports.jsx(I.DescriptionModal,{title:de.title,description:de.description,imageUrl:de.imageUrl,onClose:de.onClose})}))]})};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js"),t=require("@bikdotai/bik-models/growth"),s=require("../../assets/icons/box_search.svg.js"),i=require("../../assets/icons/boxV2.svg.js"),o=require("../../assets/icons/chevronDownOutline.svg.js"),n=require("../../assets/icons/chevronUpOutline.svg.js"),r=require("../../assets/icons/cross.svg.js"),l=require("../../assets/icons/edit.svg.js"),a=require("../../assets/icons/filePdf.svg.js"),d=require("../../assets/icons/help.svg.js"),c=require("../../assets/icons/info.svg.js"),u=require("../../assets/icons/openai.svg.js"),x=require("../../assets/icons/plus.svg.js"),p=require("../../assets/icons/redirect.svg.js"),j=require("../../assets/icons/text_t9.svg.js"),m=require("../../assets/icons/website.svg.js"),g=require("react"),h=require("../../constants/Theme.js"),y=require("../button/Button.js"),E=require("../icon-button/IconButton.js"),C=require("../shimmer/ShimmerComponent/BikShimmer.js"),R=require("../side-modal/SideModal.js"),O=require("../tag/Tag.js"),f=require("../tooltips/Tooltip.js"),v=require("../TypographyStyle.js"),S=require("./DataSourceInfoFooter.js"),T=require("./DataSourcePanel.style.js"),I=require("./IntentConfig.js"),b=require("./Modals/DescriptionModal.js"),L=require("./model.js");exports.DataSourcePanel=w=>{var D,N;const{appType:A,storeId:_,messageSource:F,setMessageSourcePanel:k,hideCloseButton:B,isSourceInfoFetched:q,allSourceInfoDetail:P,ChecklistType:M,title:U,zeroStateButton:K,editableSources:W,preFillTrainingSourceCount:$,redirect:H,footerButtonOption:Q,fetchTrainingSourceCount:G,fetchProductFAQCount:Y,productSourceData:z,reasonForAiGeneratedResponse:X,showAiResponseReason:V,productSearchRule:J,onEditProductSearchRule:Z}=w,{sources:ee}=F,te=["blog","article","page","policy"],[se,ie]=g.useState(!1),[oe,ne]=g.useState(!1),[re,le]=g.useState(!1),[ae,de]=g.useState(0),[ce,ue]=g.useState(),[xe,pe]=g.useState(null!=$?$:{}),[je,me]=g.useState(!1),[ge,he]=g.useState(!1),ye={};I.intentConfig.forEach((t=>{let{key:s,type:i,tagText:o}=t;M[s]&&(ye[M[s]]=e.jsxRuntimeExports.jsx(O.Tag,{theme:"light",type:i,tagText:o,cursor:"pointer"}))}));const Ee=ee.filter((e=>"PRODUCTS"==e.type||"Products"==e.subTitle||e.productId)),Ce=ee.filter((e=>"PRODUCTS"!=e.type&&"Products"!=e.subTitle&&!e.productId)),Re=g.useMemo((()=>{const e={};return["STORE_INFORMATION","CONTACT_INFO","STORE_LOCATION","SHIPPING_POLICY","RETURN_AND_REFUND","SALES_AND_OFFERS","SALES_AND_OFFERS_ISSUES","PRODUCT_CUSTOMISATION","PAYMENT_METHODS","CHECKOUT_ENQUIRY","ORDER_ENQUIRY"].forEach((t=>{M[t]&&(e[M[t]]=M[t])})),["COLLABORATION","SUBSCRIPTION_ENQUIRY"].forEach((t=>{e[t]=t})),e}),[M]);g.useEffect((()=>{var e,t,s,i;if(!(null==F?void 0:F.messageId))return;ie(!0),ne(!0),le(!1!==(null===(t=null===(e=F.sources)||void 0===e?void 0:e[0])||void 0===t?void 0:t.isTrainable)||!!(null===(i=null===(s=F.sources)||void 0===s?void 0:s[0])||void 0===i?void 0:i.insights));const o=F.sources.filter((e=>!!e.productId)).map((e=>e.productId)),n=Array.from(new Set(o)).filter((e=>!!e));Y(_,n).then((e=>de(e))).then((()=>{$?(pe($),setTimeout((()=>{ie(!1),ne(!1)}),100)):(setTimeout((()=>ie(!1)),100),G(_).then((e=>pe(e))).then((()=>setTimeout((()=>{ne(!1)}),100))))}))}),[Y,G,null==F?void 0:F.messageId,F.sources,$,_]);const Oe=e=>!!(e&&0===e.length||(null==F?void 0:F.isUnsatisfactoryAnswer)),fe=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var s;return"custom"==e?e=L.CustomDataType.FILES:te.includes(e)?e=L.CustomDataType.FETCHED_LINKS:"url"==e?e=L.CustomDataType.WEBSITE_LINKS:"text"===e?e=L.CustomDataType.TEXTS:"faq"===e&&(e=L.CustomDataType.FAQ),t?e:null===(s=null==e?void 0:e.toLowerCase())||void 0===s?void 0:s.replace(/_/g," ")},ve=e=>e?"faq"==e.toLocaleLowerCase()?"FAQ":"openai"==e.toLocaleLowerCase()?"OPENAI":"files"==e.toLocaleLowerCase()?"PDF":"texts"==e.toLocaleLowerCase()?"Custom text":((e=(e=e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).replace("_"," ")).endsWith("s")&&(e=e.slice(0,-1)),e.replace("Website","Manual")):"",Se=t=>"products"==t||"product"==t?e.jsxRuntimeExports.jsx(i.default,{height:16,width:16,color:h.COLORS.content.secondary}):"files"==t?e.jsxRuntimeExports.jsx(a.default,{height:16,width:16,color:h.COLORS.content.secondary}):"website links"==t||"fetched links"==t?e.jsxRuntimeExports.jsx(m.default,{height:16,width:16,color:h.COLORS.content.secondary}):"faq"==t?e.jsxRuntimeExports.jsx(d.default,{height:16,width:16,color:h.COLORS.content.secondary}):"texts"==t?e.jsxRuntimeExports.jsx(j.default,{height:16,width:16,color:h.COLORS.content.secondary}):e.jsxRuntimeExports.jsx(u.default,{height:16,width:16,color:h.COLORS.content.secondary}),Te=e=>{const t=e.replace(/(<([^>]+)>)/gi,""),s=document.createElement("textarea");return s.innerHTML=t,s.value};if(se||!q)return e.jsxRuntimeExports.jsx(T.SourceInfoDetailsStyle,{children:e.jsxRuntimeExports.jsx(C.BikShimmer,{boxes:[{width:"100px",height:"16px"},{width:"0",height:"4px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"0",height:"4px"},{width:"100%",height:"16px"}]})});const Ie=s=>{const{title:i,count:r,isExpanded:l,onToggle:a,children:d}=s;return e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",cursor:"pointer"},onClick:a},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[e.jsxRuntimeExports.jsx(v.BodyCaption,Object.assign({style:{fontWeight:"600"}},{children:i})),A===t.ApplicationType.MANIFEST?e.jsxRuntimeExports.jsx("div",Object.assign({style:{backgroundColor:h.COLORS.surface.subdued,color:h.COLORS.content.secondary,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:"500"}},{children:r})):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{})]})),e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:A===t.ApplicationType.BIK?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):l?e.jsxRuntimeExports.jsx(o.default,{width:20,height:20,color:h.COLORS.content.primary}):e.jsxRuntimeExports.jsx(n.default,{width:20,height:20,color:h.COLORS.content.primary})})]})),l&&d]})};return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(T.SourceInfoDetailsStyle,{children:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",paddingBottom:"12px"}},{children:[!!U&&e.jsxRuntimeExports.jsx(v.TitleSmall,{children:U}),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsx(v.BodyCaption,Object.assign({color:h.COLORS.content.secondary},{children:"Intent"})),null!==(D=ye[F.intent])&&void 0!==D?D:ye.GENERIC,!B&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>k(void 0)},{children:e.jsxRuntimeExports.jsx(r.default,{height:20,width:20,color:h.COLORS.content.secondary})}))]})),J&&e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"6px"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[e.jsxRuntimeExports.jsx(v.BodySecondary,Object.assign({color:h.COLORS.content.primary},{children:J.rule_name})),Z&&J.rule_id&&e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"6px"}},{children:[e.jsxRuntimeExports.jsx(s.default,{width:14,color:h.COLORS.content.secondary}),e.jsxRuntimeExports.jsx(v.BodyCaption,Object.assign({color:h.COLORS.content.secondary},{children:"Edit search rule"})),e.jsxRuntimeExports.jsx(E.IconButton,{Icon:l.default,height:16,width:16,bordered:!0,iconColor:h.COLORS.content.primary,onClick:()=>Z(null==J?void 0:J.rule_id)})]}))]})),J.keywords&&J.keywords.length>0&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"8px",backgroundColor:h.COLORS.surface.subdued,borderRadius:"8px",border:`1px dashed ${h.COLORS.stroke.primary}`}},{children:J.keywords.map(((t,s)=>e.jsxRuntimeExports.jsx(O.Tag,{tagText:t,theme:"light"},`keyword-${s}`)))}))]})),Oe(ee)?e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",margin:"auto",justifyContent:"center",alignItems:"center",height:"calc(100vh - 300px)"}},{children:(()=>{var t,s;return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",margin:"0px 30px",gap:"8px"}},{children:[e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"12px",backgroundColor:`${h.COLORS.background.negative.light}`,borderRadius:"100px"}},{children:e.jsxRuntimeExports.jsx(c.default,{width:24,height:24,color:h.COLORS.stroke.negative.vibrant})})),e.jsxRuntimeExports.jsx("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e.jsxRuntimeExports.jsx(v.TitleSmall,{children:"Insufficient data"})})),e.jsxRuntimeExports.jsx(v.BodySecondary,Object.assign({color:h.COLORS.content.secondary,style:{display:"flex",justifyContent:"center",textAlign:"center"}},{children:"No data available to answer this query. Add an FAQ to address it in the future"})),K&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e.jsxRuntimeExports.jsx(y.Button,{LeadingIcon:null!==(t=K.leadingIcon)&&void 0!==t?t:x.default,buttonText:null!==(s=K.title)&&void 0!==s?s:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{K.onClick()}})}))]}))})()})):!J&&e.jsxRuntimeExports.jsx(O.Tag,{LeadingIcon:c.default,version:"2.0",type:"grey",theme:"light",alignIcon:"start",contentPadding:12,tagText:F.isEditable?`If any of the information is incorrect, update the original data source and sync it again. Alternatively, you can make local corrections directly in ${A===t.ApplicationType.BIK?"BIK":"Manifest"}.`:"Edit the original source and save again to update the response"})]})),!Oe(ee)&&e.jsxRuntimeExports.jsxs("div",Object.assign({className:"info-container"},{children:[e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Ee.length>0&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"info-product-source"},{children:e.jsxRuntimeExports.jsx(Ie,Object.assign({title:"Product Sources",count:Ee.length,isExpanded:A!==t.ApplicationType.MANIFEST||je,onToggle:()=>me(!je)},{children:e.jsxRuntimeExports.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Ee.map(((t,s)=>{var i,o,n,r;const a=fe(t.type||t.subTitle||"OpenAI"),d=fe(t.type||t.subTitle||"OpenAI",!0),c=ve(a),u=null==W?void 0:W.includes(d),x=P[null!==(i=t.productId)&&void 0!==i?i:"Products"],j=t.title,m=t.productId&&(null==z?void 0:z[t.productId]),g=m&&m.metafield.join(", ");return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==Ee?void 0:Ee.length)?`1px solid ${h.COLORS.stroke.primary}`:"none"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Se(a),e.jsxRuntimeExports.jsx(f.Tooltip,Object.assign({body:j,placement:"top"},{children:e.jsxRuntimeExports.jsx(v.BodySecondary,Object.assign({style:d==L.CustomDataType.FETCHED_LINKS||d==L.CustomDataType.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:h.COLORS.content.primary,className:"clamp-title",onClick:()=>d==L.CustomDataType.FETCHED_LINKS||d==L.CustomDataType.WEBSITE_LINKS?H(t):{}},{children:j}))}))]})),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==M.EMAIL_COLLECTION&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(v.BodyCaption,Object.assign({color:h.COLORS.content.secondary},{children:c}))}),(t.link||t.docId)&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:u?e.jsxRuntimeExports.jsx(E.IconButton,{Icon:l.default,height:16,width:16,iconColor:h.COLORS.content.secondary,onClick:()=>null==x?void 0:x.onEditClick(x.data,x.type),disabled:!x,disabledTooltip:"This source is deleted"}):e.jsxRuntimeExports.jsx(E.IconButton,{Icon:p.default,height:16,width:16,iconColor:h.COLORS.content.secondary,disabled:"custom"===t.type&&!x,disabledTooltip:"This source is deleted",onClick:()=>H(t)})}))]}))]})),m&&e.jsxRuntimeExports.jsxs(v.BodyCaption,{children:[e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>{var e;ue({title:j,description:Te(m.description),imageUrl:null!==(e=t.imageUrl)&&void 0!==e?e:"",onClose:()=>ue(void 0)})}},{children:`${null===(o=m.description)||void 0===o?void 0:o.length} characters description,`})),e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>m.onEditFaqClick(m.faqs)},{children:`${null===(n=m.faqs)||void 0===n?void 0:n.length} FAQs, `})),e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text2"},{children:"and"})),e.jsxRuntimeExports.jsx(f.Tooltip,Object.assign({body:g,placement:"top"},{children:e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text1"},{children:`${null===(r=m.metafield)||void 0===r?void 0:r.length} metafields`}))}))]})]}),`info-${s}`)}))}))}))}))}),e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Ce.length>0&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"info-content-source"},{children:e.jsxRuntimeExports.jsx(Ie,Object.assign({title:"Content Sources",count:Ce.length,isExpanded:A!==t.ApplicationType.MANIFEST||ge,onToggle:()=>he(!ge)},{children:e.jsxRuntimeExports.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Ce.map(((t,s)=>{var i,o,n,r,a,d,c,u,x,j,m,g,y,C,R,O,S;const T=fe(t.type||t.subTitle||"OpenAI"),I=fe(t.type||t.subTitle||"OpenAI",!0),b=ve(T),w=null==W?void 0:W.includes(I),D="Products"===t.subTitle?P[null!==(i=t.productId)&&void 0!==i?i:"Products"]:P[null!==(o=t.docId)&&void 0!==o?o:""],N=I.toLowerCase()===(null===(n=L.CustomDataType.FAQ)||void 0===n?void 0:n.toLowerCase())?"faq"===(null===(r=t.title)||void 0===r?void 0:r.toLowerCase())?t.subTitle:t.title:I.toLowerCase()===(null===(a=L.CustomDataType.FILES)||void 0===a?void 0:a.toLowerCase())||I.toLowerCase()===(null===(d=L.CustomDataType.FETCHED_LINKS)||void 0===d?void 0:d.toLowerCase())||I.toLowerCase()===(null===(c=L.CustomDataType.TEXTS)||void 0===c?void 0:c.toLowerCase())?t.title:I.toLowerCase()===(null===(u=L.CustomDataType.WEBSITE_LINKS)||void 0===u?void 0:u.toLowerCase())?t.title.split("/")[t.title.split("/").length-1].replace(/[^\w\s]/gi," ").replace(/^(.)(.*)$/,((e,t,s)=>t.toUpperCase()+s)):t.intent===M.EMAIL_COLLECTION?b:t.title,A="faq"===I.toLowerCase()?null!==(m=null!==(x=null==D?void 0:D.content)&&void 0!==x?x:null===(j=null==D?void 0:D.data)||void 0===j?void 0:j.answer)&&void 0!==m?m:"":I.toLowerCase()===(null===(g=L.CustomDataType.FETCHED_LINKS)||void 0===g?void 0:g.toLowerCase())||I.toLowerCase()===(null===(y=L.CustomDataType.WEBSITE_LINKS)||void 0===y?void 0:y.toLowerCase())||I.toLowerCase()===(null===(C=L.CustomDataType.TEXTS)||void 0===C?void 0:C.toLowerCase())?null!==(S=null!==(R=null==D?void 0:D.content)&&void 0!==R?R:null===(O=null==D?void 0:D.data)||void 0===O?void 0:O.fileContentText)&&void 0!==S?S:"":t.intent===M.EMAIL_COLLECTION?"Collect leads before replying to messages":"";return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==Ce?void 0:Ce.length)?`1px solid ${h.COLORS.stroke.primary}`:"none"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Se(T),e.jsxRuntimeExports.jsx(f.Tooltip,Object.assign({body:N,placement:"top"},{children:e.jsxRuntimeExports.jsx(v.BodySecondary,Object.assign({style:I==L.CustomDataType.FETCHED_LINKS||I==L.CustomDataType.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:h.COLORS.content.primary,className:"clamp-title",onClick:()=>I==L.CustomDataType.FETCHED_LINKS||I==L.CustomDataType.WEBSITE_LINKS?H(t):{}},{children:N}))}))]})),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==M.EMAIL_COLLECTION&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(v.BodyCaption,Object.assign({color:h.COLORS.content.secondary},{children:b}))}),(t.link||t.docId)&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:w?e.jsxRuntimeExports.jsx(E.IconButton,{Icon:l.default,height:16,width:16,iconColor:h.COLORS.content.secondary,onClick:()=>null==D?void 0:D.onEditClick(D.data,D.type),disabled:!D,disabledTooltip:"This source is deleted"}):e.jsxRuntimeExports.jsx(E.IconButton,{Icon:p.default,height:16,width:16,iconColor:h.COLORS.content.secondary,disabled:"custom"===t.type&&!D,disabledTooltip:"This source is deleted",onClick:()=>H(t)})}))]}))]})),(null!=A?A:"").trim()&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${h.COLORS.stroke.primary}`,borderRadius:"4px",backgroundColor:h.COLORS.surface.subdued}},{children:e.jsxRuntimeExports.jsx(v.BodyCaption,Object.assign({color:h.COLORS.content.primary,className:"clamp-description"},{children:Te(null!=A?A:"").trim()}))}))]}),`info-${s}`)}))}))}))}))})]})),re&&!Oe(ee)&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"footer"},{children:e.jsxRuntimeExports.jsx(S.default,{appType:A,storeId:_,messageSource:F,sourceIntent:null!==(N=F.intent)&&void 0!==N?N:M.GENERIC,faqCount:ae,trainingSourceCount:xe,ShowTrainingDataSource:Re,ChecklistType:M,footerButtonOption:Q,isFooterLoading:oe,reasonForAiGeneratedResponse:X,showAiResponseReason:V})}))]})}),ce&&e.jsxRuntimeExports.jsx(R.SideModal,Object.assign({header:"Product description",onClose:()=>ue(void 0),width:"30%"},{children:e.jsxRuntimeExports.jsx(b.DescriptionModal,{title:ce.title,description:ce.description,imageUrl:ce.imageUrl,onClose:ce.onClose})}))]})};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as e from"react";var t,a;function r(){return r=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(e[r]=a[r])}return e},r.apply(this,arguments)}var l=l=>e.createElement("svg",r({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},l),t||(t=e.createElement("g",{clipPath:"url(#box_search_svg__a)"},e.createElement("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 11.372v11m0 0-8.447-4.224A1 1 0 0 1 3 17.255V7.46a1 1 0 0 1 .514-.874l8-4.444a1 1 0 0 1 .972 0l8 4.444A1 1 0 0 1 21 7.46v.912m-9 14 3-2"}),e.createElement("path",{stroke:"currentColor",strokeWidth:2,d:"m20.5 6.372-8.007 4.71a1 1 0 0 1-.993.012L3 6.372"}),e.createElement("g",{fill:"currentColor",fillRule:"evenodd",clipPath:"url(#box_search_svg__b)",clipRule:"evenodd"},e.createElement("path",{d:"M21.232 17.634a3.375 3.375 0 1 1 .53-.53l1.378 1.378a.375.375 0 1 1-.53.53l-1.378-1.378ZM16.5 14.997a2.625 2.625 0 1 1 4.516 1.821.378.378 0 0 0-.07.07 2.625 2.625 0 0 1-4.446-1.89Z"}),e.createElement("path",{d:"m22.61 19.015-1.378-1.378a3.375 3.375 0 1 1 .53-.53l1.378 1.378a.375.375 0 0 1-.53.53Zm-.375-1.945a3.735 3.735 0 1 0-1.04 1.04l1.16 1.16a.735.735 0 0 0 1.04-1.04l-1.16-1.16Zm-3.11-4.335a2.265 2.265 0 1 0 1.556 3.91.737.737 0 0 1 .09-.09 2.265 2.265 0 0 0-1.646-3.82Zm1.89 4.086a2.625 2.625 0 1 0-.07.07.377.377 0 0 1 .07-.07Z"})))),a||(a=e.createElement("defs",null,e.createElement("clipPath",{id:"box_search_svg__a"},e.createElement("path",{fill:"#fff",d:"M0-.132h24v24H0z"})),e.createElement("clipPath",{id:"box_search_svg__b"},e.createElement("path",{fill:"#fff",d:"M15 10.87h9v9h-9z"})))));export{l as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"../../node_modules/react/jsx-runtime.js";import{ApplicationType as t}from"@bikdotai/bik-models/growth";import s from"../../assets/icons/boxV2.svg.js";import i from"../../assets/icons/chevronDownOutline.svg.js";import o from"../../assets/icons/chevronUpOutline.svg.js";import n from"../../assets/icons/cross.svg.js";import r from"../../assets/icons/edit.svg.js";import l from"../../assets/icons/filePdf.svg.js";import c from"../../assets/icons/help.svg.js";import a from"../../assets/icons/info.svg.js";import d from"../../assets/icons/openai.svg.js";import p from"../../assets/icons/plus.svg.js";import u from"../../assets/icons/redirect.svg.js";import g from"../../assets/icons/text_t9.svg.js";import x from"../../assets/icons/website.svg.js";import{useState as h,useMemo as j,useEffect as m}from"react";import{COLORS as f}from"../../constants/Theme.js";import{Button as y}from"../button/Button.js";import{IconButton as v}from"../icon-button/IconButton.js";import{BikShimmer as C}from"../shimmer/ShimmerComponent/BikShimmer.js";import{SideModal as b}from"../side-modal/SideModal.js";import{Tag as I}from"../tag/Tag.js";import{Tooltip as O}from"../tooltips/Tooltip.js";import{TitleSmall as T,BodyCaption as E,BodySecondary as w}from"../TypographyStyle.js";import S from"./DataSourceInfoFooter.js";import{SourceInfoDetailsStyle as L}from"./DataSourcePanel.style.js";import{intentConfig as N}from"./IntentConfig.js";import{DescriptionModal as F}from"./Modals/DescriptionModal.js";import{CustomDataType as A}from"./model.js";const k=k=>{var _,D;const{appType:R,storeId:P,messageSource:B,setMessageSourcePanel:U,hideCloseButton:K,isSourceInfoFetched:M,allSourceInfoDetail:W,ChecklistType:$,title:H,zeroStateButton:q,editableSources:Q,preFillTrainingSourceCount:G,redirect:Y,footerButtonOption:z,fetchTrainingSourceCount:X,fetchProductFAQCount:V,productSourceData:J,reasonForAiGeneratedResponse:Z,showAiResponseReason:ee,productSearchRule:te,onEditProductSearchRule:se}=k,{sources:ie}=B,oe=["blog","article","page","policy"],[ne,re]=h(!1),[le,ce]=h(!1),[ae,de]=h(!1),[pe,ue]=h(0),[ge,xe]=h(),[he,je]=h(null!=G?G:{}),[me,fe]=h(!1),[ye,ve]=h(!1),Ce={};N.forEach((t=>{let{key:s,type:i,tagText:o}=t;$[s]&&(Ce[$[s]]=e.jsx(I,{theme:"light",type:i,tagText:o,cursor:"pointer"}))}));const be=ie.filter((e=>"PRODUCTS"==e.type||"Products"==e.subTitle||e.productId)),Ie=ie.filter((e=>"PRODUCTS"!=e.type&&"Products"!=e.subTitle&&!e.productId)),Oe=j((()=>{const e={};return["STORE_INFORMATION","CONTACT_INFO","STORE_LOCATION","SHIPPING_POLICY","RETURN_AND_REFUND","SALES_AND_OFFERS","SALES_AND_OFFERS_ISSUES","PRODUCT_CUSTOMISATION","PAYMENT_METHODS","CHECKOUT_ENQUIRY","ORDER_ENQUIRY"].forEach((t=>{$[t]&&(e[$[t]]=$[t])})),["COLLABORATION","SUBSCRIPTION_ENQUIRY"].forEach((t=>{e[t]=t})),e}),[$]);m((()=>{var e,t,s,i;if(!(null==B?void 0:B.messageId))return;re(!0),ce(!0),de(!1!==(null===(t=null===(e=B.sources)||void 0===e?void 0:e[0])||void 0===t?void 0:t.isTrainable)||!!(null===(i=null===(s=B.sources)||void 0===s?void 0:s[0])||void 0===i?void 0:i.insights));const o=B.sources.filter((e=>!!e.productId)).map((e=>e.productId)),n=Array.from(new Set(o)).filter((e=>!!e));V(P,n).then((e=>ue(e))).then((()=>{G?(je(G),setTimeout((()=>{re(!1),ce(!1)}),100)):(setTimeout((()=>re(!1)),100),X(P).then((e=>je(e))).then((()=>setTimeout((()=>{ce(!1)}),100))))}))}),[V,X,null==B?void 0:B.messageId,B.sources,G,P]);const Te=e=>!!(e&&0===e.length||(null==B?void 0:B.isUnsatisfactoryAnswer)),Ee=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var s;return"custom"==e?e=A.FILES:oe.includes(e)?e=A.FETCHED_LINKS:"url"==e?e=A.WEBSITE_LINKS:"text"===e?e=A.TEXTS:"faq"===e&&(e=A.FAQ),t?e:null===(s=null==e?void 0:e.toLowerCase())||void 0===s?void 0:s.replace(/_/g," ")},we=e=>e?"faq"==e.toLocaleLowerCase()?"FAQ":"openai"==e.toLocaleLowerCase()?"OPENAI":"files"==e.toLocaleLowerCase()?"PDF":"texts"==e.toLocaleLowerCase()?"Custom text":((e=(e=e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).replace("_"," ")).endsWith("s")&&(e=e.slice(0,-1)),e.replace("Website","Manual")):"",Se=t=>"products"==t||"product"==t?e.jsx(s,{height:16,width:16,color:f.content.secondary}):"files"==t?e.jsx(l,{height:16,width:16,color:f.content.secondary}):"website links"==t||"fetched links"==t?e.jsx(x,{height:16,width:16,color:f.content.secondary}):"faq"==t?e.jsx(c,{height:16,width:16,color:f.content.secondary}):"texts"==t?e.jsx(g,{height:16,width:16,color:f.content.secondary}):e.jsx(d,{height:16,width:16,color:f.content.secondary}),Le=e=>{const t=e.replace(/(<([^>]+)>)/gi,""),s=document.createElement("textarea");return s.innerHTML=t,s.value};if(ne||!M)return e.jsx(L,{children:e.jsx(C,{boxes:[{width:"100px",height:"16px"},{width:"0",height:"4px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"0",height:"4px"},{width:"100%",height:"16px"}]})});const Ne=s=>{const{title:n,count:r,isExpanded:l,onToggle:c,children:a}=s;return e.jsxs("div",{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",cursor:"pointer"},onClick:c},{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[e.jsx(E,Object.assign({style:{fontWeight:"600"}},{children:n})),R===t.MANIFEST?e.jsx("div",Object.assign({style:{backgroundColor:f.surface.subdued,color:f.content.secondary,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:"500"}},{children:r})):e.jsx(e.Fragment,{})]})),e.jsx(e.Fragment,{children:R===t.BIK?e.jsx(e.Fragment,{}):l?e.jsx(i,{width:20,height:20,color:f.content.primary}):e.jsx(o,{width:20,height:20,color:f.content.primary})})]})),l&&a]})};return e.jsxs(e.Fragment,{children:[e.jsx(L,{children:e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",paddingBottom:"12px"}},{children:[!!H&&e.jsx(T,{children:H}),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e.jsx(E,Object.assign({color:f.content.secondary},{children:"Intent"})),null!==(_=Ce[B.intent])&&void 0!==_?_:Ce.GENERIC,!K&&e.jsx("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>U(void 0)},{children:e.jsx(n,{height:20,width:20,color:f.content.secondary})}))]})),te&&e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"6px"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[e.jsx(w,Object.assign({color:f.content.primary},{children:te.rule_name})),se&&te.rule_id&&e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[e.jsx(E,Object.assign({color:f.content.secondary},{children:"Edit search rule"})),e.jsx(v,{Icon:r,height:16,width:16,bordered:!0,iconColor:f.content.secondary,onClick:()=>se(te.rule_id)})]}))]})),te.keywords&&te.keywords.length>0&&e.jsx("div",Object.assign({style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"12px",backgroundColor:f.surface.subdued,borderRadius:"8px",border:`1px dashed ${f.stroke.primary}`}},{children:te.keywords.map(((t,s)=>e.jsx(I,{tagText:t,theme:"light"},`keyword-${s}`)))}))]})),Te(ie)?e.jsx("div",Object.assign({style:{display:"flex",margin:"auto",justifyContent:"center",alignItems:"center",height:"calc(100vh - 300px)"}},{children:(()=>{var t,s;return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",margin:"0px 30px",gap:"8px"}},{children:[e.jsx("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"12px",backgroundColor:`${f.background.negative.light}`,borderRadius:"100px"}},{children:e.jsx(a,{width:24,height:24,color:f.stroke.negative.vibrant})})),e.jsx("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e.jsx(T,{children:"Insufficient data"})})),e.jsx(w,Object.assign({color:f.content.secondary,style:{display:"flex",justifyContent:"center",textAlign:"center"}},{children:"No data available to answer this query. Add an FAQ to address it in the future"})),q&&e.jsx("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e.jsx(y,{LeadingIcon:null!==(t=q.leadingIcon)&&void 0!==t?t:p,buttonText:null!==(s=q.title)&&void 0!==s?s:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{q.onClick()}})}))]}))})()})):e.jsx(I,{LeadingIcon:a,version:"2.0",type:"grey",theme:"light",alignIcon:"start",contentPadding:12,tagText:B.isEditable?`If any of the information is incorrect, update the original data source and sync it again. Alternatively, you can make local corrections directly in ${R===t.BIK?"BIK":"Manifest"}.`:"Edit the original source and save again to update the response"})]})),!Te(ie)&&e.jsxs("div",Object.assign({className:"info-container"},{children:[e.jsx(e.Fragment,{children:be.length>0&&e.jsx("div",Object.assign({className:"info-product-source"},{children:e.jsx(Ne,Object.assign({title:"Product Sources",count:be.length,isExpanded:R!==t.MANIFEST||me,onToggle:()=>fe(!me)},{children:e.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:be.map(((t,s)=>{var i,o,n,l;const c=Ee(t.type||t.subTitle||"OpenAI"),a=Ee(t.type||t.subTitle||"OpenAI",!0),d=we(c),p=null==Q?void 0:Q.includes(a),g=W[null!==(i=t.productId)&&void 0!==i?i:"Products"],x=t.title,h=t.productId&&(null==J?void 0:J[t.productId]),j=h&&h.metafield.join(", ");return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==be?void 0:be.length)?`1px solid ${f.stroke.primary}`:"none"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Se(c),e.jsx(O,Object.assign({body:x,placement:"top"},{children:e.jsx(w,Object.assign({style:a==A.FETCHED_LINKS||a==A.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:f.content.primary,className:"clamp-title",onClick:()=>a==A.FETCHED_LINKS||a==A.WEBSITE_LINKS?Y(t):{}},{children:x}))}))]})),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==$.EMAIL_COLLECTION&&e.jsx(e.Fragment,{children:e.jsx(E,Object.assign({color:f.content.secondary},{children:d}))}),(t.link||t.docId)&&e.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:p?e.jsx(v,{Icon:r,height:16,width:16,iconColor:f.content.secondary,onClick:()=>null==g?void 0:g.onEditClick(g.data,g.type),disabled:!g,disabledTooltip:"This source is deleted"}):e.jsx(v,{Icon:u,height:16,width:16,iconColor:f.content.secondary,disabled:"custom"===t.type&&!g,disabledTooltip:"This source is deleted",onClick:()=>Y(t)})}))]}))]})),h&&e.jsxs(E,{children:[e.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>{var e;xe({title:x,description:Le(h.description),imageUrl:null!==(e=t.imageUrl)&&void 0!==e?e:"",onClose:()=>xe(void 0)})}},{children:`${null===(o=h.description)||void 0===o?void 0:o.length} characters description,`})),e.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>h.onEditFaqClick(h.faqs)},{children:`${null===(n=h.faqs)||void 0===n?void 0:n.length} FAQs, `})),e.jsx("span",Object.assign({className:"product-data-text2"},{children:"and"})),e.jsx(O,Object.assign({body:j,placement:"top"},{children:e.jsx("span",Object.assign({className:"product-data-text1"},{children:`${null===(l=h.metafield)||void 0===l?void 0:l.length} metafields`}))}))]})]}),`info-${s}`)}))}))}))}))}),e.jsx(e.Fragment,{children:Ie.length>0&&e.jsx("div",Object.assign({className:"info-content-source"},{children:e.jsx(Ne,Object.assign({title:"Content Sources",count:Ie.length,isExpanded:R!==t.MANIFEST||ye,onToggle:()=>ve(!ye)},{children:e.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Ie.map(((t,s)=>{var i,o,n,l,c,a,d,p,g,x,h,j,m,y,C,b,I;const T=Ee(t.type||t.subTitle||"OpenAI"),S=Ee(t.type||t.subTitle||"OpenAI",!0),L=we(T),N=null==Q?void 0:Q.includes(S),F="Products"===t.subTitle?W[null!==(i=t.productId)&&void 0!==i?i:"Products"]:W[null!==(o=t.docId)&&void 0!==o?o:""],k=S.toLowerCase()===(null===(n=A.FAQ)||void 0===n?void 0:n.toLowerCase())?"faq"===(null===(l=t.title)||void 0===l?void 0:l.toLowerCase())?t.subTitle:t.title:S.toLowerCase()===(null===(c=A.FILES)||void 0===c?void 0:c.toLowerCase())||S.toLowerCase()===(null===(a=A.FETCHED_LINKS)||void 0===a?void 0:a.toLowerCase())||S.toLowerCase()===(null===(d=A.TEXTS)||void 0===d?void 0:d.toLowerCase())?t.title:S.toLowerCase()===(null===(p=A.WEBSITE_LINKS)||void 0===p?void 0:p.toLowerCase())?t.title.split("/")[t.title.split("/").length-1].replace(/[^\w\s]/gi," ").replace(/^(.)(.*)$/,((e,t,s)=>t.toUpperCase()+s)):t.intent===$.EMAIL_COLLECTION?L:t.title,_="faq"===S.toLowerCase()?null!==(h=null!==(g=null==F?void 0:F.content)&&void 0!==g?g:null===(x=null==F?void 0:F.data)||void 0===x?void 0:x.answer)&&void 0!==h?h:"":S.toLowerCase()===(null===(j=A.FETCHED_LINKS)||void 0===j?void 0:j.toLowerCase())||S.toLowerCase()===(null===(m=A.WEBSITE_LINKS)||void 0===m?void 0:m.toLowerCase())||S.toLowerCase()===(null===(y=A.TEXTS)||void 0===y?void 0:y.toLowerCase())?null!==(I=null!==(C=null==F?void 0:F.content)&&void 0!==C?C:null===(b=null==F?void 0:F.data)||void 0===b?void 0:b.fileContentText)&&void 0!==I?I:"":t.intent===$.EMAIL_COLLECTION?"Collect leads before replying to messages":"";return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==Ie?void 0:Ie.length)?`1px solid ${f.stroke.primary}`:"none"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Se(T),e.jsx(O,Object.assign({body:k,placement:"top"},{children:e.jsx(w,Object.assign({style:S==A.FETCHED_LINKS||S==A.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:f.content.primary,className:"clamp-title",onClick:()=>S==A.FETCHED_LINKS||S==A.WEBSITE_LINKS?Y(t):{}},{children:k}))}))]})),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==$.EMAIL_COLLECTION&&e.jsx(e.Fragment,{children:e.jsx(E,Object.assign({color:f.content.secondary},{children:L}))}),(t.link||t.docId)&&e.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:N?e.jsx(v,{Icon:r,height:16,width:16,iconColor:f.content.secondary,onClick:()=>null==F?void 0:F.onEditClick(F.data,F.type),disabled:!F,disabledTooltip:"This source is deleted"}):e.jsx(v,{Icon:u,height:16,width:16,iconColor:f.content.secondary,disabled:"custom"===t.type&&!F,disabledTooltip:"This source is deleted",onClick:()=>Y(t)})}))]}))]})),(null!=_?_:"").trim()&&e.jsx("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${f.stroke.primary}`,borderRadius:"4px",backgroundColor:f.surface.subdued}},{children:e.jsx(E,Object.assign({color:f.content.primary,className:"clamp-description"},{children:Le(null!=_?_:"").trim()}))}))]}),`info-${s}`)}))}))}))}))})]})),ae&&!Te(ie)&&e.jsx("div",Object.assign({className:"footer"},{children:e.jsx(S,{appType:R,storeId:P,messageSource:B,sourceIntent:null!==(D=B.intent)&&void 0!==D?D:$.GENERIC,faqCount:pe,trainingSourceCount:he,ShowTrainingDataSource:Oe,ChecklistType:$,footerButtonOption:z,isFooterLoading:le,reasonForAiGeneratedResponse:Z,showAiResponseReason:ee})}))]})}),ge&&e.jsx(b,Object.assign({header:"Product description",onClose:()=>xe(void 0),width:"30%"},{children:e.jsx(F,{title:ge.title,description:ge.description,imageUrl:ge.imageUrl,onClose:ge.onClose})}))]})};export{k as DataSourcePanel};
|
|
1
|
+
import{j as e}from"../../node_modules/react/jsx-runtime.js";import{ApplicationType as t}from"@bikdotai/bik-models/growth";import s from"../../assets/icons/box_search.svg.js";import i from"../../assets/icons/boxV2.svg.js";import o from"../../assets/icons/chevronDownOutline.svg.js";import n from"../../assets/icons/chevronUpOutline.svg.js";import r from"../../assets/icons/cross.svg.js";import l from"../../assets/icons/edit.svg.js";import c from"../../assets/icons/filePdf.svg.js";import a from"../../assets/icons/help.svg.js";import d from"../../assets/icons/info.svg.js";import p from"../../assets/icons/openai.svg.js";import u from"../../assets/icons/plus.svg.js";import g from"../../assets/icons/redirect.svg.js";import x from"../../assets/icons/text_t9.svg.js";import h from"../../assets/icons/website.svg.js";import{useState as j,useMemo as m,useEffect as f}from"react";import{COLORS as y}from"../../constants/Theme.js";import{Button as v}from"../button/Button.js";import{IconButton as b}from"../icon-button/IconButton.js";import{BikShimmer as C}from"../shimmer/ShimmerComponent/BikShimmer.js";import{SideModal as I}from"../side-modal/SideModal.js";import{Tag as O}from"../tag/Tag.js";import{Tooltip as T}from"../tooltips/Tooltip.js";import{TitleSmall as E,BodyCaption as w,BodySecondary as S}from"../TypographyStyle.js";import L from"./DataSourceInfoFooter.js";import{SourceInfoDetailsStyle as N}from"./DataSourcePanel.style.js";import{intentConfig as F}from"./IntentConfig.js";import{DescriptionModal as A}from"./Modals/DescriptionModal.js";import{CustomDataType as _}from"./model.js";const k=k=>{var D,R;const{appType:P,storeId:B,messageSource:U,setMessageSourcePanel:K,hideCloseButton:M,isSourceInfoFetched:W,allSourceInfoDetail:$,ChecklistType:H,title:q,zeroStateButton:Q,editableSources:G,preFillTrainingSourceCount:Y,redirect:z,footerButtonOption:X,fetchTrainingSourceCount:V,fetchProductFAQCount:J,productSourceData:Z,reasonForAiGeneratedResponse:ee,showAiResponseReason:te,productSearchRule:se,onEditProductSearchRule:ie}=k,{sources:oe}=U,ne=["blog","article","page","policy"],[re,le]=j(!1),[ce,ae]=j(!1),[de,pe]=j(!1),[ue,ge]=j(0),[xe,he]=j(),[je,me]=j(null!=Y?Y:{}),[fe,ye]=j(!1),[ve,be]=j(!1),Ce={};F.forEach((t=>{let{key:s,type:i,tagText:o}=t;H[s]&&(Ce[H[s]]=e.jsx(O,{theme:"light",type:i,tagText:o,cursor:"pointer"}))}));const Ie=oe.filter((e=>"PRODUCTS"==e.type||"Products"==e.subTitle||e.productId)),Oe=oe.filter((e=>"PRODUCTS"!=e.type&&"Products"!=e.subTitle&&!e.productId)),Te=m((()=>{const e={};return["STORE_INFORMATION","CONTACT_INFO","STORE_LOCATION","SHIPPING_POLICY","RETURN_AND_REFUND","SALES_AND_OFFERS","SALES_AND_OFFERS_ISSUES","PRODUCT_CUSTOMISATION","PAYMENT_METHODS","CHECKOUT_ENQUIRY","ORDER_ENQUIRY"].forEach((t=>{H[t]&&(e[H[t]]=H[t])})),["COLLABORATION","SUBSCRIPTION_ENQUIRY"].forEach((t=>{e[t]=t})),e}),[H]);f((()=>{var e,t,s,i;if(!(null==U?void 0:U.messageId))return;le(!0),ae(!0),pe(!1!==(null===(t=null===(e=U.sources)||void 0===e?void 0:e[0])||void 0===t?void 0:t.isTrainable)||!!(null===(i=null===(s=U.sources)||void 0===s?void 0:s[0])||void 0===i?void 0:i.insights));const o=U.sources.filter((e=>!!e.productId)).map((e=>e.productId)),n=Array.from(new Set(o)).filter((e=>!!e));J(B,n).then((e=>ge(e))).then((()=>{Y?(me(Y),setTimeout((()=>{le(!1),ae(!1)}),100)):(setTimeout((()=>le(!1)),100),V(B).then((e=>me(e))).then((()=>setTimeout((()=>{ae(!1)}),100))))}))}),[J,V,null==U?void 0:U.messageId,U.sources,Y,B]);const Ee=e=>!!(e&&0===e.length||(null==U?void 0:U.isUnsatisfactoryAnswer)),we=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var s;return"custom"==e?e=_.FILES:ne.includes(e)?e=_.FETCHED_LINKS:"url"==e?e=_.WEBSITE_LINKS:"text"===e?e=_.TEXTS:"faq"===e&&(e=_.FAQ),t?e:null===(s=null==e?void 0:e.toLowerCase())||void 0===s?void 0:s.replace(/_/g," ")},Se=e=>e?"faq"==e.toLocaleLowerCase()?"FAQ":"openai"==e.toLocaleLowerCase()?"OPENAI":"files"==e.toLocaleLowerCase()?"PDF":"texts"==e.toLocaleLowerCase()?"Custom text":((e=(e=e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).replace("_"," ")).endsWith("s")&&(e=e.slice(0,-1)),e.replace("Website","Manual")):"",Le=t=>"products"==t||"product"==t?e.jsx(i,{height:16,width:16,color:y.content.secondary}):"files"==t?e.jsx(c,{height:16,width:16,color:y.content.secondary}):"website links"==t||"fetched links"==t?e.jsx(h,{height:16,width:16,color:y.content.secondary}):"faq"==t?e.jsx(a,{height:16,width:16,color:y.content.secondary}):"texts"==t?e.jsx(x,{height:16,width:16,color:y.content.secondary}):e.jsx(p,{height:16,width:16,color:y.content.secondary}),Ne=e=>{const t=e.replace(/(<([^>]+)>)/gi,""),s=document.createElement("textarea");return s.innerHTML=t,s.value};if(re||!W)return e.jsx(N,{children:e.jsx(C,{boxes:[{width:"100px",height:"16px"},{width:"0",height:"4px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"0",height:"4px"},{width:"100%",height:"16px"}]})});const Fe=s=>{const{title:i,count:r,isExpanded:l,onToggle:c,children:a}=s;return e.jsxs("div",{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",cursor:"pointer"},onClick:c},{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[e.jsx(w,Object.assign({style:{fontWeight:"600"}},{children:i})),P===t.MANIFEST?e.jsx("div",Object.assign({style:{backgroundColor:y.surface.subdued,color:y.content.secondary,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:"500"}},{children:r})):e.jsx(e.Fragment,{})]})),e.jsx(e.Fragment,{children:P===t.BIK?e.jsx(e.Fragment,{}):l?e.jsx(o,{width:20,height:20,color:y.content.primary}):e.jsx(n,{width:20,height:20,color:y.content.primary})})]})),l&&a]})};return e.jsxs(e.Fragment,{children:[e.jsx(N,{children:e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",paddingBottom:"12px"}},{children:[!!q&&e.jsx(E,{children:q}),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e.jsx(w,Object.assign({color:y.content.secondary},{children:"Intent"})),null!==(D=Ce[U.intent])&&void 0!==D?D:Ce.GENERIC,!M&&e.jsx("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>K(void 0)},{children:e.jsx(r,{height:20,width:20,color:y.content.secondary})}))]})),se&&e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"6px"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[e.jsx(S,Object.assign({color:y.content.primary},{children:se.rule_name})),ie&&se.rule_id&&e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"6px"}},{children:[e.jsx(s,{width:14,color:y.content.secondary}),e.jsx(w,Object.assign({color:y.content.secondary},{children:"Edit search rule"})),e.jsx(b,{Icon:l,height:16,width:16,bordered:!0,iconColor:y.content.primary,onClick:()=>ie(null==se?void 0:se.rule_id)})]}))]})),se.keywords&&se.keywords.length>0&&e.jsx("div",Object.assign({style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"8px",backgroundColor:y.surface.subdued,borderRadius:"8px",border:`1px dashed ${y.stroke.primary}`}},{children:se.keywords.map(((t,s)=>e.jsx(O,{tagText:t,theme:"light"},`keyword-${s}`)))}))]})),Ee(oe)?e.jsx("div",Object.assign({style:{display:"flex",margin:"auto",justifyContent:"center",alignItems:"center",height:"calc(100vh - 300px)"}},{children:(()=>{var t,s;return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",margin:"0px 30px",gap:"8px"}},{children:[e.jsx("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"12px",backgroundColor:`${y.background.negative.light}`,borderRadius:"100px"}},{children:e.jsx(d,{width:24,height:24,color:y.stroke.negative.vibrant})})),e.jsx("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e.jsx(E,{children:"Insufficient data"})})),e.jsx(S,Object.assign({color:y.content.secondary,style:{display:"flex",justifyContent:"center",textAlign:"center"}},{children:"No data available to answer this query. Add an FAQ to address it in the future"})),Q&&e.jsx("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e.jsx(v,{LeadingIcon:null!==(t=Q.leadingIcon)&&void 0!==t?t:u,buttonText:null!==(s=Q.title)&&void 0!==s?s:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{Q.onClick()}})}))]}))})()})):!se&&e.jsx(O,{LeadingIcon:d,version:"2.0",type:"grey",theme:"light",alignIcon:"start",contentPadding:12,tagText:U.isEditable?`If any of the information is incorrect, update the original data source and sync it again. Alternatively, you can make local corrections directly in ${P===t.BIK?"BIK":"Manifest"}.`:"Edit the original source and save again to update the response"})]})),!Ee(oe)&&e.jsxs("div",Object.assign({className:"info-container"},{children:[e.jsx(e.Fragment,{children:Ie.length>0&&e.jsx("div",Object.assign({className:"info-product-source"},{children:e.jsx(Fe,Object.assign({title:"Product Sources",count:Ie.length,isExpanded:P!==t.MANIFEST||fe,onToggle:()=>ye(!fe)},{children:e.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Ie.map(((t,s)=>{var i,o,n,r;const c=we(t.type||t.subTitle||"OpenAI"),a=we(t.type||t.subTitle||"OpenAI",!0),d=Se(c),p=null==G?void 0:G.includes(a),u=$[null!==(i=t.productId)&&void 0!==i?i:"Products"],x=t.title,h=t.productId&&(null==Z?void 0:Z[t.productId]),j=h&&h.metafield.join(", ");return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==Ie?void 0:Ie.length)?`1px solid ${y.stroke.primary}`:"none"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Le(c),e.jsx(T,Object.assign({body:x,placement:"top"},{children:e.jsx(S,Object.assign({style:a==_.FETCHED_LINKS||a==_.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:y.content.primary,className:"clamp-title",onClick:()=>a==_.FETCHED_LINKS||a==_.WEBSITE_LINKS?z(t):{}},{children:x}))}))]})),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==H.EMAIL_COLLECTION&&e.jsx(e.Fragment,{children:e.jsx(w,Object.assign({color:y.content.secondary},{children:d}))}),(t.link||t.docId)&&e.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:p?e.jsx(b,{Icon:l,height:16,width:16,iconColor:y.content.secondary,onClick:()=>null==u?void 0:u.onEditClick(u.data,u.type),disabled:!u,disabledTooltip:"This source is deleted"}):e.jsx(b,{Icon:g,height:16,width:16,iconColor:y.content.secondary,disabled:"custom"===t.type&&!u,disabledTooltip:"This source is deleted",onClick:()=>z(t)})}))]}))]})),h&&e.jsxs(w,{children:[e.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>{var e;he({title:x,description:Ne(h.description),imageUrl:null!==(e=t.imageUrl)&&void 0!==e?e:"",onClose:()=>he(void 0)})}},{children:`${null===(o=h.description)||void 0===o?void 0:o.length} characters description,`})),e.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>h.onEditFaqClick(h.faqs)},{children:`${null===(n=h.faqs)||void 0===n?void 0:n.length} FAQs, `})),e.jsx("span",Object.assign({className:"product-data-text2"},{children:"and"})),e.jsx(T,Object.assign({body:j,placement:"top"},{children:e.jsx("span",Object.assign({className:"product-data-text1"},{children:`${null===(r=h.metafield)||void 0===r?void 0:r.length} metafields`}))}))]})]}),`info-${s}`)}))}))}))}))}),e.jsx(e.Fragment,{children:Oe.length>0&&e.jsx("div",Object.assign({className:"info-content-source"},{children:e.jsx(Fe,Object.assign({title:"Content Sources",count:Oe.length,isExpanded:P!==t.MANIFEST||ve,onToggle:()=>be(!ve)},{children:e.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Oe.map(((t,s)=>{var i,o,n,r,c,a,d,p,u,x,h,j,m,f,v,C,I;const O=we(t.type||t.subTitle||"OpenAI"),E=we(t.type||t.subTitle||"OpenAI",!0),L=Se(O),N=null==G?void 0:G.includes(E),F="Products"===t.subTitle?$[null!==(i=t.productId)&&void 0!==i?i:"Products"]:$[null!==(o=t.docId)&&void 0!==o?o:""],A=E.toLowerCase()===(null===(n=_.FAQ)||void 0===n?void 0:n.toLowerCase())?"faq"===(null===(r=t.title)||void 0===r?void 0:r.toLowerCase())?t.subTitle:t.title:E.toLowerCase()===(null===(c=_.FILES)||void 0===c?void 0:c.toLowerCase())||E.toLowerCase()===(null===(a=_.FETCHED_LINKS)||void 0===a?void 0:a.toLowerCase())||E.toLowerCase()===(null===(d=_.TEXTS)||void 0===d?void 0:d.toLowerCase())?t.title:E.toLowerCase()===(null===(p=_.WEBSITE_LINKS)||void 0===p?void 0:p.toLowerCase())?t.title.split("/")[t.title.split("/").length-1].replace(/[^\w\s]/gi," ").replace(/^(.)(.*)$/,((e,t,s)=>t.toUpperCase()+s)):t.intent===H.EMAIL_COLLECTION?L:t.title,k="faq"===E.toLowerCase()?null!==(h=null!==(u=null==F?void 0:F.content)&&void 0!==u?u:null===(x=null==F?void 0:F.data)||void 0===x?void 0:x.answer)&&void 0!==h?h:"":E.toLowerCase()===(null===(j=_.FETCHED_LINKS)||void 0===j?void 0:j.toLowerCase())||E.toLowerCase()===(null===(m=_.WEBSITE_LINKS)||void 0===m?void 0:m.toLowerCase())||E.toLowerCase()===(null===(f=_.TEXTS)||void 0===f?void 0:f.toLowerCase())?null!==(I=null!==(v=null==F?void 0:F.content)&&void 0!==v?v:null===(C=null==F?void 0:F.data)||void 0===C?void 0:C.fileContentText)&&void 0!==I?I:"":t.intent===H.EMAIL_COLLECTION?"Collect leads before replying to messages":"";return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==Oe?void 0:Oe.length)?`1px solid ${y.stroke.primary}`:"none"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Le(O),e.jsx(T,Object.assign({body:A,placement:"top"},{children:e.jsx(S,Object.assign({style:E==_.FETCHED_LINKS||E==_.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:y.content.primary,className:"clamp-title",onClick:()=>E==_.FETCHED_LINKS||E==_.WEBSITE_LINKS?z(t):{}},{children:A}))}))]})),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==H.EMAIL_COLLECTION&&e.jsx(e.Fragment,{children:e.jsx(w,Object.assign({color:y.content.secondary},{children:L}))}),(t.link||t.docId)&&e.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:N?e.jsx(b,{Icon:l,height:16,width:16,iconColor:y.content.secondary,onClick:()=>null==F?void 0:F.onEditClick(F.data,F.type),disabled:!F,disabledTooltip:"This source is deleted"}):e.jsx(b,{Icon:g,height:16,width:16,iconColor:y.content.secondary,disabled:"custom"===t.type&&!F,disabledTooltip:"This source is deleted",onClick:()=>z(t)})}))]}))]})),(null!=k?k:"").trim()&&e.jsx("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${y.stroke.primary}`,borderRadius:"4px",backgroundColor:y.surface.subdued}},{children:e.jsx(w,Object.assign({color:y.content.primary,className:"clamp-description"},{children:Ne(null!=k?k:"").trim()}))}))]}),`info-${s}`)}))}))}))}))})]})),de&&!Ee(oe)&&e.jsx("div",Object.assign({className:"footer"},{children:e.jsx(L,{appType:P,storeId:B,messageSource:U,sourceIntent:null!==(R=U.intent)&&void 0!==R?R:H.GENERIC,faqCount:ue,trainingSourceCount:je,ShowTrainingDataSource:Te,ChecklistType:H,footerButtonOption:X,isFooterLoading:ce,reasonForAiGeneratedResponse:ee,showAiResponseReason:te})}))]})}),xe&&e.jsx(I,Object.assign({header:"Product description",onClose:()=>he(void 0),width:"30%"},{children:e.jsx(A,{title:xe.title,description:xe.description,imageUrl:xe.imageUrl,onClose:xe.onClose})}))]})};export{k as DataSourcePanel};
|