@expedite-commerce/expedite-components 0.2.104 → 0.2.106
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.
|
@@ -42505,7 +42505,7 @@ const QT = ["innerHTML"], ZT = {
|
|
|
42505
42505
|
])
|
|
42506
42506
|
]));
|
|
42507
42507
|
}
|
|
42508
|
-
}, np = (e) => (rn("data-v-
|
|
42508
|
+
}, np = (e) => (rn("data-v-fe69264f"), e = e(), on(), e), XD = {
|
|
42509
42509
|
class: "ect-h-full ect-w-full ect-bg-white",
|
|
42510
42510
|
"data-test-id": "aiComponentLoader-wrapper"
|
|
42511
42511
|
}, WD = {
|
|
@@ -42566,6 +42566,7 @@ const QT = ["innerHTML"], ZT = {
|
|
|
42566
42566
|
configItemId: { type: String, default: "" },
|
|
42567
42567
|
configQliId: { type: String, default: "" },
|
|
42568
42568
|
configApiKey: { type: String, default: "" },
|
|
42569
|
+
resources: { type: Object, default: () => ({}) },
|
|
42569
42570
|
/** Optional functions (e.g. createQuote) for ExpediteConfigurator */
|
|
42570
42571
|
functions: { type: Object, default: () => ({}) }
|
|
42571
42572
|
},
|
|
@@ -42844,6 +42845,7 @@ const QT = ["innerHTML"], ZT = {
|
|
|
42844
42845
|
sections: e.sections,
|
|
42845
42846
|
theme: e.theme,
|
|
42846
42847
|
"composables-org-type": e.composablesOrgType,
|
|
42848
|
+
resources: e.resources,
|
|
42847
42849
|
onCatalogQuoteCreated: q,
|
|
42848
42850
|
onCatalogQuoteUpdated: G,
|
|
42849
42851
|
onCatalogItemsLoaded: T,
|
|
@@ -42853,7 +42855,7 @@ const QT = ["innerHTML"], ZT = {
|
|
|
42853
42855
|
onCatalogItemsFetched: oe,
|
|
42854
42856
|
onCatalogItemConfigure: R,
|
|
42855
42857
|
"onCatalog:id": V
|
|
42856
|
-
}, null, 8, ["template-id", "identity", "session", "security", "search-term", "on-catalog-count-update", "preview-data", "initial-data", "sections", "theme", "composables-org-type"])) : u.value === "cart" && c.value && h.value ? (B(), Ce(Ch, {
|
|
42858
|
+
}, null, 8, ["template-id", "identity", "session", "security", "search-term", "on-catalog-count-update", "preview-data", "initial-data", "sections", "theme", "composables-org-type", "resources"])) : u.value === "cart" && c.value && h.value ? (B(), Ce(Ch, {
|
|
42857
42859
|
key: _.value,
|
|
42858
42860
|
"data-test-id": "aiComponentLoader-cart",
|
|
42859
42861
|
class: "ect-h-full ect-w-full",
|
|
@@ -42863,9 +42865,10 @@ const QT = ["innerHTML"], ZT = {
|
|
|
42863
42865
|
security: e.security,
|
|
42864
42866
|
identity: e.identity,
|
|
42865
42867
|
session: d.value,
|
|
42868
|
+
resources: e.resources,
|
|
42866
42869
|
onExpeditecartItemConfigure: L,
|
|
42867
42870
|
onExpeditecartClicked: D
|
|
42868
|
-
}, null, 8, ["template-id", "host-name", "composables-org-type", "security", "identity", "session"])) : u.value === "cart" && c.value && !h.value ? (B(), U("div", WD, ZD)) : u.value === "configurator" && x.value ? (B(), Ce(ch, {
|
|
42871
|
+
}, null, 8, ["template-id", "host-name", "composables-org-type", "security", "identity", "session", "resources"])) : u.value === "cart" && c.value && !h.value ? (B(), U("div", WD, ZD)) : u.value === "configurator" && x.value ? (B(), Ce(ch, {
|
|
42869
42872
|
key: E.value,
|
|
42870
42873
|
"data-test-id": "aiComponentLoader-configurator",
|
|
42871
42874
|
class: "ect-h-full ect-w-full",
|
|
@@ -42890,7 +42893,7 @@ const QT = ["innerHTML"], ZT = {
|
|
|
42890
42893
|
]))
|
|
42891
42894
|
]));
|
|
42892
42895
|
}
|
|
42893
|
-
}, rR = /* @__PURE__ */ Me(nR, [["__scopeId", "data-v-
|
|
42896
|
+
}, rR = /* @__PURE__ */ Me(nR, [["__scopeId", "data-v-fe69264f"]]), oR = {
|
|
42894
42897
|
class: "ai-guidance-loader",
|
|
42895
42898
|
"data-test-id": "aiGuidance-loader-container"
|
|
42896
42899
|
}, iR = { "data-test-id": "aiGuidance-loader-text" }, aR = {
|
|
@@ -43004,6 +43007,11 @@ const QT = ["innerHTML"], ZT = {
|
|
|
43004
43007
|
height: "100vh"
|
|
43005
43008
|
}),
|
|
43006
43009
|
validator: (e) => typeof (e == null ? void 0 : e.height) == "string"
|
|
43010
|
+
},
|
|
43011
|
+
resources: {
|
|
43012
|
+
type: Object,
|
|
43013
|
+
required: !1,
|
|
43014
|
+
default: () => ({})
|
|
43007
43015
|
}
|
|
43008
43016
|
},
|
|
43009
43017
|
emits: [
|
|
@@ -43046,6 +43054,7 @@ const QT = ["innerHTML"], ZT = {
|
|
|
43046
43054
|
};
|
|
43047
43055
|
});
|
|
43048
43056
|
an(async () => {
|
|
43057
|
+
var D;
|
|
43049
43058
|
console.log("security", _), console.log("apiKey", I), r.updateConfig({
|
|
43050
43059
|
userId: y == null ? void 0 : y.userId,
|
|
43051
43060
|
organizationId: y == null ? void 0 : y.organizationId,
|
|
@@ -43062,7 +43071,8 @@ const QT = ["innerHTML"], ZT = {
|
|
|
43062
43071
|
graphqlEndpoint: M,
|
|
43063
43072
|
apiKey: (_ == null ? void 0 : _.apiKey) || I,
|
|
43064
43073
|
cid: y == null ? void 0 : y.contactId,
|
|
43065
|
-
isPreview: k
|
|
43074
|
+
isPreview: k,
|
|
43075
|
+
siteUrl: (D = v.resources) == null ? void 0 : D.siteUrl
|
|
43066
43076
|
});
|
|
43067
43077
|
}), bt(async () => {
|
|
43068
43078
|
var j, Z, Y, ue;
|
|
@@ -43284,7 +43294,7 @@ const QT = ["innerHTML"], ZT = {
|
|
|
43284
43294
|
]);
|
|
43285
43295
|
};
|
|
43286
43296
|
}
|
|
43287
|
-
}, fR = /* @__PURE__ */ Me(dR, [["__scopeId", "data-v-
|
|
43297
|
+
}, fR = /* @__PURE__ */ Me(dR, [["__scopeId", "data-v-920099b8"]]);
|
|
43288
43298
|
let Ba = null;
|
|
43289
43299
|
if (typeof window < "u") {
|
|
43290
43300
|
try {
|
|
@@ -184,4 +184,4 @@
|
|
|
184
184
|
`+Pt),fe&&Ms([w,T,q],On=>{Pt=Wi(Pt,On," ")}),b&&te?b.createHTML(Pt):Pt},n.setConfig=function(){let Ne=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Qn(Ne),se=!0},n.clearConfig=function(){on=null,se=!1},n.isValidAttribute=function(Ne,ge,Te){on||Qn({});const Re=ft(Ne),lt=ft(ge);return Jo(Re,lt,Te)},n.addHook=function(Ne,ge){typeof ge=="function"&&Xi(k[Ne],ge)},n.removeHook=function(Ne,ge){if(ge!==void 0){const Te=vO(k[Ne],ge);return Te===-1?void 0:bO(k[Ne],Te,1)[0]}return Zh(k[Ne])},n.removeHooks=function(Ne){k[Ne]=[]},n.removeAllHooks=function(){k=ap()},n}var NO=sp();const LO=["innerHTML"],lp=Me({__name:"MarkdownRenderer",props:{source:{type:String,default:""},wrapperClass:{type:[String,Array,Object],default:""}},setup(e){const n=e,t=new Ln({html:!1,linkify:!0,breaks:!0}),r=ye(()=>{const o=t.render(n.source||"");return NO.sanitize(o)});return(o,i)=>(B(),U("div",{class:we(["markdown-renderer",e.wrapperClass]),innerHTML:r.value},null,10,LO))}},[["__scopeId","data-v-ecacea26"]]),PO={class:"message-content"},qO={key:0,class:"message-name"},$O={class:"ect-w-full"},UO={class:"message-content"},jO={class:"message-text ect-relative"},HO={class:"ect-pr-1"},VO={class:"loading-message-skeleton"},zO={key:1,class:"buttons-wrapper ect-mt-[-8px]"},GO=Me({__name:"chatMessages",props:{undoId:{type:String,default:""},strikethroughIds:{type:Array,default:()=>[]},messages:{type:Array,required:!0,default:()=>[]},chatIndex:{type:Number,default:0},dataChanged:{type:Boolean,default:!1},loadingMessage:{type:String,default:""},buttonLinks:{type:Array,default:()=>[]}},setup(e){const n=If(),t=X(null),r=X(null);xo();const o=_o(),i=Vo(),a=e,s=ye(()=>!(i!=null&&i.activeComponentKey)),l=()=>{t.value&&t.value.scrollTo({top:t.value.scrollHeight,behavior:"smooth"})};od(()=>{a.messages.length>0&&Tt(()=>{l()})}),od(()=>{a.loadingMessage&&Tt(()=>{l(),r.value&&(r.value.scrollTop=r.value.scrollHeight)})});const u=ye(()=>{var f;return(f=o.chatStyles)==null?void 0:f.bgColor}),c=ye(()=>`linear-gradient(180deg, ${u.value} 0%, transparent 100%)`),h=ye(()=>{var f;return(f=o.chatStyles)==null?void 0:f.textColor}),d=(f,v,m=!1)=>{if(typeof f=="string"&&f.startsWith("playbookNavigate:")){const _=f.slice(17);i.navigateToBean(_);return}f==="addProducts"?i.loadComponent("catalog"):f==="quoteDocument"?n.openQuoteDocument(v.requestId):f==="quoteItem"?i.loadComponent("cart"):f==="Undo"&&o.undoAction(v.requestId)},p=f=>{if(!f)return"";let v=f.replace(/\\r\\n/g,`
|
|
185
185
|
`).replace(/\\n/g,`
|
|
186
186
|
`).replace(/\\r/g,`
|
|
187
|
-
`);return v=v.replace(/^[ \t]*•[ \t]+/gm,"- "),v};return(f,v)=>(B(),U("div",{class:we(["chat-messages",{"root-path":s.value}])},[C("div",{class:"chat-gradient",style:Ae({background:c.value})},null,4),C("div",{ref_key:"chatMessagesRef",ref:t,class:"messages-wrapper"},[(B(!0),U(ke,null,Fe([...e.messages],(m,_)=>{var g;return B(),U("div",{key:_,class:we(["message",{"user-message":m.type==="user"}])},[C("div",PO,[m.name?(B(),U("div",qO,be(m.name),1)):me("",!0),C("div",{class:we(["message-text ect-relative",{"error-message":m.error,strikethrough:m.undone}]),style:Ae(m.type==="user"?{color:h.value,backgroundColor:u.value}:{})},[C("div",$O,[pe(lp,{source:p(m.message)},null,8,["source"])]),((g=m==null?void 0:m.filesData)==null?void 0:g.length)>0?(B(!0),U(ke,{key:0},Fe(m==null?void 0:m.filesData,y=>(B(),Ce(qw,{key:y.name,info:{iconUrl:(y==null?void 0:y.type)==="csv"?Ie(rh):Ie(oh),fileName:y==null?void 0:y.name,fileSize:y==null?void 0:y.size},background:m.type=="user"?"#fff":"#f8f8f8","encoded-string":y==null?void 0:y.encodedString},null,8,["info","background","encoded-string"]))),128)):me("",!0)],6)])],2)}),128)),e.loadingMessage?(B(),U("div",{key:0,class:we(["loading-message",{"thinking-message":Ie(o).isThinkingMessage}])},[C("div",{class:we(["ect-flex ect-gap-3",{"ect-w-full":Ie(o).isThinkingMessage}])},[C("div",UO,[C("div",jO,[C("div",{ref_key:"loadingWindowRef",ref:r,class:"loading-window"},[C("div",HO,[pe(lp,{source:p(e.loadingMessage)},null,8,["source"])])],512)]),C("div",VO,[pe(Pi,{style:{height:"100%",width:"100%"}})])])],2)],2)):e.buttonLinks.length>0?(B(),U("div",zO,[pe(Bw,{links:e.buttonLinks,onPerformAction:d},null,8,["links"])])):me("",!0)],512)],2))}},[["__scopeId","data-v-d6e07984"]]),KO={class:"ai-upload ect-flex-inline ect-items-center"},XO=Me({__name:"FileUpload",props:{resetFileInput:{type:Boolean,default:!1}},emits:["upload-status","error"],setup(e,{emit:n}){const t=e,r=n,o=X(null),i=X(""),a=X(""),s=X(!1);Ke(()=>t.resetFileInput,h=>{h&&o.value&&(o.value.value="",i.value="",a.value="")});const l=h=>{const p=o.value.accept.split(",").map(v=>v.trim().toLowerCase()),f="."+h.name.split(".").pop().toLowerCase();return p.includes(f)||p.includes(h.type.toLowerCase())?!0:p.some(v=>{if(v.includes("*")){const m=v.split("*")[0];return h.type.toLowerCase().startsWith(m)}return!1})},u=async h=>{const d=h.target.files[0];if(console.info("File = ",d),d){if(!l(d)){o.value&&(o.value.value="");const f={message:"Invalid file type. Please upload a valid file type.",fileName:d.name,fileType:d.type};window&&window.$toast&&window.$toast.add({severity:"error",summary:"File Upload Error",detail:f.message,life:5e3}),r("error",f);return}i.value=d.name,a.value=d.type.split("/").pop(),r("upload-status",{status:"uploading",fileName:i.value,fileType:a.value});const p=new FileReader;p.onload=async f=>{const v=new Blob([f.target.result],{type:d.type});console.info("Blob data:",v);try{const m=await V3(v),_={attachment:{name:d.name,data:m}};console.info("AIRequestPayload = ",_),r("upload-status",{status:"uploaded",fileName:i.value,fileType:a.value,size:Af(d.size),fileData:_}),o.value&&(o.value.value="")}catch(m){console.info("[ERROR]: File upload error:",m),window&&window.$toast&&window.$toast.add({severity:"error",summary:"File Processing Error",detail:"Error processing file: "+(m.message||"Unknown error"),life:5e3}),r("error",{message:"Error processing file",fileName:i.value,fileType:a.value,error:m.message}),r("upload-status",{status:"error",fileName:i.value,fileType:a.value})}},p.onerror=f=>{console.info("[ERROR]: FileReader error:",f),window&&window.$toast&&window.$toast.add({severity:"error",summary:"File Reading Error",detail:"Could not read the selected file",life:5e3}),r("error",{message:"Error reading file",fileName:d.name,fileType:d.type,error:f})},setTimeout(()=>{p.readAsText(d)},100)}},c=()=>{o.value.click()};return(h,d)=>(B(),U("div",KO,[C("input",{ref_key:"fileInput",ref:o,type:"file",accept:".csv, .xls, .xlsx, text/csv, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",class:"ect-opacity-0 ect-h-0 ect-w-0 ect-absolute",onChange:u},null,544),C("button",{class:"attachment-button",onClick:c,onMouseenter:d[0]||(d[0]=p=>s.value=!0),onMouseleave:d[1]||(d[1]=p=>s.value=!1)},[pe(ze,{icon:"attachment",size:"11",height:"17",color:s.value?"#198708":"#828282"},null,8,["color"])],32)]))}},[["__scopeId","data-v-7fbbb7c9"]]),WO={key:0,class:"suggestions-container"},QO={key:0,class:"logo-section"},ZO={class:"help-text-section"},JO={key:0,class:"help-text"},YO={key:1,class:"sub-help-text"},eT=["onClick"],tT={key:2,class:"suggestions-list"},nT=["onClick"],rT=Me({__name:"AISuggestionsDropdown",props:{options:{type:Array,required:!0},helpText:{type:String,default:""},subHelpText:{type:String,default:""},showSuggestions:{type:Boolean,default:!1}},emits:["select","preview"],setup(e,{emit:n}){const t=e,r=n,o=X(0),i=X(0),a=X(null),s=X(null),l=d=>{a.value=d,i.value=0},u=()=>{a.value=null,o.value=0},c=d=>{r("select",d)},h=d=>{if(t.showSuggestions)switch(d.key){case"ArrowDown":d.preventDefault(),a.value?(i.value=(i.value+1)%a.value.subOptions.length,r("preview",a.value.subOptions[i.value])):(o.value=(o.value+1)%t.options.length,r("preview",t.options[o.value].title));break;case"ArrowUp":d.preventDefault(),a.value?(i.value=i.value-1<0?a.value.subOptions.length-1:i.value-1,r("preview",a.value.subOptions[i.value])):(o.value=o.value-1<0?t.options.length-1:o.value-1,r("preview",t.options[o.value].title));break;case"Enter":d.preventDefault(),a.value?c(a.value.subOptions[i.value]):l(t.options[o.value]);break;case"Escape":case"ArrowLeft":case"Backspace":a.value&&(d.preventDefault(),u());break}};return Ke(()=>t.showSuggestions,d=>{d?(window.addEventListener("keydown",h),a.value=null,o.value=0,i.value=0):window.removeEventListener("keydown",h)}),(d,p)=>e.showSuggestions?(B(),U("div",WO,[a.value?me("",!0):(B(),U("div",QO,[pe(e_)])),C("div",ZO,[e.helpText&&!a.value?(B(),U("div",JO,be(e.helpText),1)):me("",!0),e.subHelpText?(B(),U("div",YO,be(e.subHelpText),1)):me("",!0)]),a.value?(B(),U("div",tT,[(B(!0),U(ke,null,Fe(a.value.subOptions,(f,v)=>(B(),U("div",{key:v,class:we(["sub-option",{"sub-active":i.value===v}]),onClick:m=>c(f)},be(f),11,nT))),128))])):(B(),U("div",{key:1,ref_key:"suggestionsList",ref:s,class:"suggestions-list"},[(B(!0),U(ke,null,Fe(e.options,(f,v)=>(B(),U("div",{key:v,class:we(["suggestion-item",{active:o.value===v}]),onClick:m=>l(f)},be(f.title),11,eT))),128))],512))])):me("",!0)}},[["__scopeId","data-v-bbb514b3"]]),oT={class:"chat-file-info"},iT={class:"ect-flex ect-gap-2 ect-items-center ect-self-stretch ect-my-auto ect-text-xs ect-font-medium ect-text-black"},aT=["src"],sT={class:"ect-self-stretch ect-my-auto"},lT={key:0,class:"ect-flex ect-gap-2 ect-justify-center ect-items-center ect-self-stretch ect-my-auto ect-w-4 ect-h-4"},uT=Me({__name:"ChatInputFileInfo",props:{fileInfo:{type:Object,required:!0}},emits:["cancel"],setup(e,{emit:n}){const t=n,r=()=>{t("cancel")};return(o,i)=>(B(),U("div",oT,[C("div",iT,[C("img",{loading:"lazy",src:e.fileInfo.fileType==="csv"?Ie(rh):Ie(oh),class:"ect-object-contain ect-shrink-0 ect-self-stretch ect-my-auto ect-w-7 ect-aspect-square",alt:""},null,8,aT),C("div",sT,be(e.fileInfo.fileName),1)]),e.fileInfo.status==="uploading"?(B(),U("div",lT,[pe(ic,{size:18})])):me("",!0),e.fileInfo.status==="uploaded"?(B(),U("button",{key:1,class:"ect-flex ect-gap-2 ect-justify-center ect-items-center ect-self-stretch ect-my-auto ect-w-4 ect-h-4",onClick:r},[pe(ze,{icon:"close",size:"8"})])):me("",!0)]))}},[["__scopeId","data-v-24d881bd"]]),cT={class:"chat-input-wrapper"},dT={class:"chat-input-inner"},fT={class:"input-row"},hT=["disabled","placeholder","onKeydown"],pT={key:1,class:"icon-wrapper"},mT={class:"icon-wrapper"},gT=Me({__name:"chatInput",props:{modelValue:{type:String,default:""},loading:{type:Boolean,default:!1},placeholder:{type:String,default:"Ask Genesis AI"},helpText:{type:String,default:"Here are few areas where I can help"},subHelpText:{type:String,default:"Suggestions by Genesis (Click to Apply)"},showFile:{type:Boolean,default:!1},showMic:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},emits:["update:modelValue","submit","speak","file-upload-status"],setup(e,{emit:n}){const t=e,r=n;_o();const o=kn(),i=Vo(),a=X({}),s=X(!1),l=X(!1),u=X(t.modelValue),c=X(null),h=ye(()=>{const E=i.currentStep||null;return(Array.isArray(E==null?void 0:E.promptGuidance)?E.promptGuidance:[]).slice().sort((I,k)=>Number((I==null?void 0:I.sequenceNumber)??0)-Number((k==null?void 0:k.sequenceNumber)??0)).map(I=>{const w=(Array.isArray(I==null?void 0:I.relatedPG)?I.relatedPG:[]).slice().sort((T,q)=>Number((T==null?void 0:T.sequenceNumber)??0)-Number((q==null?void 0:q.sequenceNumber)??0)).map(T=>T.pgName);return{title:I.pgName,subOptions:w}})}),d=ye(()=>{var E;return(E=h.value)!=null&&E.length?h.value:[]}),p=ye(()=>{var E;return(E=h.value)!=null&&E.length?"Prompt Guidance":t.helpText});Ke(()=>t.loading,async(E,S)=>{!E&&S&&(await Tt(),c.value.focus())}),Ke(u,E=>{r("update:modelValue",E),Tt(()=>b())}),Ke(()=>t.modelValue,E=>{u.value=E});const f=E=>{console.info("[ERROR]: File upload error:",E),o.handleError(E,"ChatInput")},v=()=>{u.value.trim()&&(l.value=!1,r("submit",u.value),u.value="",c.value&&(c.value.style.height="32px"),a.value=null)},m=E=>{u.value=E,l.value=!1,Tt(()=>{b(),c.value&&(c.value.focus(),c.value.selectionStart=c.value.selectionEnd=u.value.length)})},_=E=>{u.value=E,Tt(()=>b())},g=()=>{l.value=!1},y=E=>{console.info("handleFileUploadStatus event = ",E),E!=null&&E.fileName?(a.value=E,r("file-upload-status",E)):(a.value=null,s.value=!0,r("file-upload-status",null),setTimeout(()=>{s.value=!1},3e3))},b=()=>{const E=c.value;if(!E)return;E.style.height="auto";const I=Math.max(32,Math.min(E.scrollHeight,120));E.style.height=`${I}px`},x=()=>{console.info("removeFile"),a.value=null,s.value=!0,r("file-upload-status",null),setTimeout(()=>{s.value=!1},100)},A=()=>{l.value=!1,b()};return(E,S)=>{var I,k,w,T,q;const M=nd("click-outside");return En((B(),U("div",cT,[pe(rT,{options:d.value,"help-text":p.value,"sub-help-text":e.subHelpText,"show-suggestions":l.value,onSelect:m,onPreview:_},null,8,["options","help-text","sub-help-text","show-suggestions"]),C("div",dT,[C("div",fT,[C("div",{class:we(["icon-wrapper",{"active-suggestions":l.value,disabled:((I=d.value)==null?void 0:I.length)<=0}])},[pe(ze,{disabled:((k=d.value)==null?void 0:k.length)<=0||e.loading,color:((w=d.value)==null?void 0:w.length)<=0?"#DEDEDE":l.value?"#198708":"#828282",icon:"suggestions",size:"13",height:15,onClick:S[0]||(S[0]=K=>l.value=!l.value)},null,8,["disabled","color"])],2),En(C("textarea",{ref_key:"textareaRef",ref:c,"onUpdate:modelValue":S[1]||(S[1]=K=>u.value=K),disabled:e.loading,placeholder:e.placeholder,rows:"1",onKeydown:Un(_t(v,["exact","prevent"]),["enter"]),onInput:A},null,40,hT),[[po,u.value]]),e.showFile?(B(),U("div",{key:0,class:we(["icon-wrapper",{"file-upload-disabled":e.loading}])},[pe(XO,{"reset-file-input":s.value,onUploadStatus:y,onError:f},null,8,["reset-file-input"])],2)):me("",!0),e.showMic?(B(),U("div",pT,[pe(ze,{color:"#828282",disabled:e.loading,icon:"mic",size:"13",height:15,onClick:S[2]||(S[2]=K=>E.$emit("speak"))},null,8,["disabled"])])):me("",!0),C("div",mT,[(B(),Ce(ze,{key:1,disabled:e.loading,icon:"send",size:"20",onClick:v},null,8,["disabled"]))])]),((T=a.value)==null?void 0:T.status)==="uploading"||((q=a.value)==null?void 0:q.status)==="uploaded"?(B(),Ce(uT,{key:0,class:"ect-mt-3 ect-mb-0.5","file-info":a.value,onCancel:x},null,8,["file-info"])):me("",!0)])])),[[M,g]])}}},[["__scopeId","data-v-e205d71c"]]),yT=["data-test-id"],vT=["data-test-id"],bT=["data-test-id"],_T=Me({__name:"aiChat",props:{dataTestId:{type:String,required:!0},isExternalGuidance:{type:Boolean,required:!1,default:!1},styles:{type:Object,required:!1,default:()=>({}),validator:e=>typeof(e==null?void 0:e.height)=="string"}},setup(e){const n=Vo(),t=_o(),r=X(null),o=ye(()=>{var l;return((l=n.getCurrentStepLinks)==null?void 0:l.call(n))||[]}),i=ye(()=>!0),a=l=>{console.info("[aiChat] handleSubmit",{hasFileData:!!r.value,messageLength:(l||"").length}),r.value?(console.info("[aiChat] sending with file attachment"),t.sendMessage(l,!0,r.value)):(console.info("[aiChat] sending without attachment"),t.sendMessage(l))},s=l=>{console.info("ChatScreen handleFileUploadStatus event = ",l),l!=null&&l.fileData?(r.value=l.fileData,t.attachmentData={size:l.size,type:l.fileType,name:l.fileName}):(r.value=null,t.attachmentData=null)};return(l,u)=>(B(),U("div",{class:"chat-screen","data-test-id":e.dataTestId},[C("div",{class:we(["messages-container",{"playbook-steps-mode-hybrid":Ie(n).playbookStepsMode==="hybrid","playbook-steps-mode-full":Ie(n).playbookStepsMode==="full","dxp-guiddance":e.isExternalGuidance}]),style:Ae({maxHeight:`calc(${e.styles.height} - 72px)`,height:`calc(${e.styles.height} - 72px)`}),"data-test-id":`${e.dataTestId}-messages-container`},[pe(GO,{messages:Ie(t).chatHistory,"loading-message":Ie(t).loadingMessage,"undo-id":Ie(t).latestDMLRequest,"button-links":o.value,"strikethrough-ids":Ie(t).strikethroughHistory,"data-changed":Ie(t).dataManuallyChanged,"data-test-id":`${e.dataTestId}-messages`},null,8,["messages","loading-message","undo-id","button-links","strikethrough-ids","data-changed","data-test-id"])],14,vT),C("div",{class:"input-container","data-test-id":`${e.dataTestId}-input-container`},[pe(gT,{modelValue:Ie(t).promptMessage,"onUpdate:modelValue":u[0]||(u[0]=c=>Ie(t).promptMessage=c),disabled:!i.value,"file-info":r.value,loading:!!Ie(t).loadingMessage,"data-test-id":`${e.dataTestId}-input`,onSubmit:a,onFileUploadStatus:s},null,8,["modelValue","disabled","file-info","loading","data-test-id"])],8,bT)],8,yT))}},[["__scopeId","data-v-99005673"]]),xT={class:"ect-h-full ect-w-full ect-flex ect-items-center ect-justify-center","data-test-id":"configurator-not-found"},CT={class:"ect-max-w-[720px] ect-p-[50px] ect-border ect-rounded-lg ect-bg-white ect-shadow-sm"},ET={class:"ect-text-[40px] ect-leading-none ect-mb-3"},kT=C("div",{class:"ect-text-[22px] ect-font-normal ect-leading-normal ect-mb-[12px] ect-capitalize ect-text-[#5F5F5F]","data-test-id":"configurator-not-found-title"}," Product Configurator Not Found ",-1),AT=C("div",{class:"ect-text-sm ect-text-gray-500","data-test-id":"configurator-not-found-subtitle"}," Linked composable product configurator UI component for this screen is not found OR the composable product configurator UI component does not exist. Please create / connect one and try again. ",-1),wT={class:"ect-mt-4 ect-flex ect-items-center ect-justify-between ect-gap-6"},IT={__name:"MoleculeConfiguratorNotFound",emits:["return","go-cart"],setup(e){return(n,t)=>(B(),U("div",xT,[C("div",CT,[C("div",ET,[pe(ze,{icon:"error",size:48})]),kT,AT,C("div",wT,[C("button",{type:"button",class:"ect-text-green-600 ect-text-sm ect-font-medium",onClick:t[0]||(t[0]=r=>n.$emit("return")),"data-test-id":"configurator-not-found-return"}," RETURN TO PRODUCT RESULTS "),C("button",{type:"button",class:"ect-text-green-600 ect-text-sm ect-font-medium",onClick:t[1]||(t[1]=r=>n.$emit("go-cart")),"data-test-id":"configurator-not-found-go-to-cart"}," GO TO CART ")])])]))}},up=e=>(Wt("data-v-3c362460"),e=e(),Qt(),e),ST={class:"ect-h-full ect-w-full ect-bg-white","data-test-id":"aiComponentLoader-wrapper"},OT={key:2,class:"ect-h-full ect-w-full ect-flex ect-items-center ect-justify-center","data-test-id":"aiComponentLoader-cart-error"},TT=[up(()=>C("div",{class:"ect-text-center"},[C("div",{class:"ect-text-base ect-font-medium ect-text-red-600","data-test-id":"aiComponentLoader-cart-error-title"}," Quote Required "),C("div",{class:"ect-text-sm ect-text-gray-500 ect-mt-2","data-test-id":"aiComponentLoader-cart-error-message"}," A quote is required for the cart component to work. Please ensure a quoteId is provided in the session prop. ")],-1))],DT={key:5,class:"ect-h-full ect-w-full ect-flex ect-items-center ect-justify-center"},RT={class:"ect-text-center"},MT=up(()=>C("div",{class:"ect-text-base ect-font-medium","data-test-id":"aiComponentLoader-fallback-title"}," No component to display for this step ",-1)),BT={class:"ect-text-sm ect-text-gray-500 ect-mt-2","data-test-id":"aiComponentLoader-fallback-subtitle"},FT=Me({__name:"aiComponentLoader",props:{stepComponent:{type:String,default:null},identity:{type:Object,default:()=>({})},session:{type:Object,default:()=>({})},security:{type:Object,default:()=>({})},packageVersion:{type:String,default:""},composablesOrgType:{type:String,default:""},composablesApiKey:{type:String,default:""},templateId:{type:String,default:""},hostName:{type:String,default:""},graphqlEndpoint:{type:String,default:""},apiKey:{type:String,default:""},isPreview:{type:Boolean,default:!1},sections:{type:Array,default:()=>[]},theme:{type:Object,default:()=>({})},catalogPreviewData:{type:Object,default:()=>({})},catalogInitialData:{type:Array,default:()=>[]},catalogSearchTerm:{type:String,default:""},onCatalogCountUpdate:{type:Function,default:null},cartSections:{type:String,default:""},configItemId:{type:String,default:""},configQliId:{type:String,default:""},configApiKey:{type:String,default:""},functions:{type:Object,default:()=>({})}},emits:["expeditecart-clicked","ai-guidance:error","catalog-quote-created","catalog-quote-updated","catalog-items-loaded","catalog-item-added","catalog-item-qty-updated","catalog-line-deleted","catalog-items-fetched","catalog-item-configure"],setup(e,{emit:n}){const t=n,r=e,o=Vo(),i=ec(),a=qt(),s=ye(()=>{var Z,Y,ue,fe,H;const j=((Z=r.session)==null?void 0:Z.quoteId)||((Y=a.quoteId)==null?void 0:Y.value)||((ue=o==null?void 0:o.activeComponentData)==null?void 0:ue.contextObjectId)||((H=(fe=o==null?void 0:o.activeComponentData)==null?void 0:fe.payload)==null?void 0:H.contextObjectId);return{...r.session,...j&&{quoteId:j},qliId:m.value||r.configQliId||void 0,itemId:v.value}}),l=ye(()=>{const j=r.functions||{},Z=j.createQuote;return typeof Z!="function"?j:{...j,createQuote:async(...Y)=>{const ue=await Z(...Y);return ue&&a.updateConfig({quoteId:ue}),ue}}}),u=ye(()=>{const j=o==null?void 0:o.activeComponentKey,Z=r.stepComponent;return(j||Z||"").toString().trim().toLowerCase().replace(/[^a-z0-9]+/g,"_")}),c=ye(()=>{var fe,H;const j=!!r.templateId,Z=!!((fe=r.identity)!=null&&fe.organizationId),Y=!!((H=r.identity)!=null&&H.accountId),ue=typeof r.cartSections=="string"&&r.cartSections.length>0;return j&&Z&&Y&&ue}),h=ye(()=>{var ue,fe,H,z,se;const j=(ue=r.session)==null?void 0:ue.quoteId,Z=(fe=a.quoteId)==null?void 0:fe.value,Y=((H=o==null?void 0:o.activeComponentData)==null?void 0:H.contextObjectId)||((se=(z=o==null?void 0:o.activeComponentData)==null?void 0:z.payload)==null?void 0:se.contextObjectId);return!!(j||Z||Y)}),d=ye(()=>{var Z,Y,ue,fe,H;const j=((Z=r.session)==null?void 0:Z.quoteId)||((Y=a.quoteId)==null?void 0:Y.value)||((ue=o==null?void 0:o.activeComponentData)==null?void 0:ue.contextObjectId)||((H=(fe=o==null?void 0:o.activeComponentData)==null?void 0:fe.payload)==null?void 0:H.contextObjectId);return{...r.session,...j&&{quoteId:j}}}),p=ye(()=>{var Z;if(Array.isArray(r.catalogInitialData)&&r.catalogInitialData.length>0)return r.catalogInitialData;const j=((Z=o==null?void 0:o.activeComponentData)==null?void 0:Z.payload)||{};if(j.catalog&&typeof j.catalog=="object")try{const ue=Object.values(j.catalog).map(fe=>{var H;return(H=fe==null?void 0:fe.catalogResponse)==null?void 0:H.productInfo}).filter(Boolean);if(ue.length>0)return ue}catch{}return Array.isArray(j.initialData)&&j.initialData.length>0?j.initialData:Array.isArray(j.catalogInitialData)&&j.catalogInitialData.length>0?j.catalogInitialData:Array.isArray(j.items)&&j.items.length>0?j.items:[]}),f=ye(()=>{var Z;const j=((Z=o==null?void 0:o.activeComponentData)==null?void 0:Z.payload)||{};return r.catalogSearchTerm||j.searchTerm||""}),v=ye(()=>{var Z,Y,ue,fe,H,z;const j=((fe=(ue=(Y=(Z=o==null?void 0:o.activeComponentData)==null?void 0:Z.payload)==null?void 0:Y.savedProducts)==null?void 0:ue[0])==null?void 0:fe.itemId)||((H=o==null?void 0:o.activeComponentData)==null?void 0:H.payload)&&Object.keys(((z=o.activeComponentData.payload)==null?void 0:z.quoteConfiguration)||{})[0]||"";return r.configItemId||j||""}),m=ye(()=>{var Z,Y,ue,fe,H,z,se,ce;const j=(fe=(ue=(Y=(Z=o==null?void 0:o.activeComponentData)==null?void 0:Z.payload)==null?void 0:Y.savedProducts)==null?void 0:ue[0])==null?void 0:fe.qliId;if(!j){console.log("[aiComponentLoader] configQliIdComputed: No qliId from savedProducts");const W=(z=(H=o==null?void 0:o.activeComponentData)==null?void 0:H.payload)==null?void 0:z.quoteConfiguration;if(console.log("[aiComponentLoader] configQliIdComputed: quoteConfiguration:",W),W&&typeof W=="object"){const Q=Object.keys(W)[0];if(console.log("[aiComponentLoader] configQliIdComputed: firstItemId:",Q),Q){const te=(se=W[Q])==null?void 0:se.product;if(console.log("[aiComponentLoader] configQliIdComputed: productObj:",te),te&&te.qliId)return console.log("[aiComponentLoader] configQliIdComputed: found qliId in productObj:",te.qliId),te.qliId;if((ce=W[Q])!=null&&ce.qliId)return console.log("[aiComponentLoader] configQliIdComputed: found qliId directly under itemId:",W[Q].qliId),W[Q].qliId}}}return j||""}),_=ye(()=>!!v.value),g=ye(()=>u.value==="configurator"&&!_.value?"Configurator requires an itemId (and optional qliId). Provide via playbook payload or props.":u.value==="catalog"?"Catalog step is active. Provide templateId/sections/theme when available.":u.value==="cart"?"Cart step is active.":"Awaiting playbook step selection."),y=ye(()=>{try{return JSON.stringify((o==null?void 0:o.activeComponentData)||{})}catch{return""}}),b=ye(()=>`catalog::${y.value}`),x=ye(()=>`cart::${y.value}`),A=ye(()=>{var j;try{return(((j=o==null?void 0:o.activeComponentData)==null?void 0:j.actionFunction)||"")==="Reload"}catch{return!1}}),E=ye(()=>{var Z;const j=`configurator::${v.value||""}::${m.value||""}`;if(A.value){const Y=((Z=o==null?void 0:o.activeComponentData)==null?void 0:Z.requestId)||"";return`${j}::${Y}`}return j}),{emitError:S,emitErrors:M}=nh(t,"aiComponentLoader"),I=()=>{const j=f8(o,u.value);M(j)},k=X([]),w=X(null),T=j=>{const Z=Array.isArray(j)?j:Array.isArray(j==null?void 0:j.items)?j.items:[];if(!Array.isArray(Z))return;const Y={"Needs Configuration":1,"Suggests Configuration":2,"Fully Configured":3},ue=z=>(z==null?void 0:z.requiresConfiguration)||"",fe=z=>!!z&&z in Y,H=Z.filter(z=>fe(ue(z)));H.sort((z,se)=>{const ce=ue(z),W=ue(se);return(Y[ce]||99)-(Y[W]||99)}),k.value=H,w.value=H.length?H[0]:null},q=j=>{console.log("onQuoteCreated",j),t("catalog-quote-created",j)},K=j=>{console.log("onQuoteUpdated",j),t("catalog-quote-updated",j)},$=j=>{console.log("onItemAdded",j),t("catalog-item-added",j)},ne=j=>{console.log("onItemQtyUpdated",j),t("catalog-item-qty-updated",j)},le=j=>{console.log("onLineDeleted",j),t("catalog-line-deleted",j)},oe=j=>{console.log("onQuoteItemsFetched",j),t("catalog-items-fetched",j)};Ke(()=>u.value,(j,Z)=>{var Y,ue,fe,H,z,se,ce,W,Q,te,J;if(j==="configurator"){const re=!!((fe=(ue=(Y=o==null?void 0:o.activeComponentData)==null?void 0:Y.payload)==null?void 0:ue.savedProducts)!=null&&fe.length),ie=!!((z=(H=o==null?void 0:o.activeComponentData)==null?void 0:H.payload)!=null&&z.quoteConfiguration&&Object.keys(((ce=(se=o==null?void 0:o.activeComponentData)==null?void 0:se.payload)==null?void 0:ce.quoteConfiguration)||{}).length>0);if(!re&&!ie&&w.value&&!v.value){const ae=((W=w.value)==null?void 0:W.itemId)||"";if(ae){const de=((Q=o==null?void 0:o.currentPlaybook)==null?void 0:Q.playBookSteps)||[],ve=Be=>String(Be||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_");let xe=null;const Se=de.findIndex(Be=>Be.stepName===(o==null?void 0:o.currentStepName));if(Se>=0&&de[Se+1]&&ve((te=de[Se+1])==null?void 0:te.stepComponent)==="configurator")xe=de[Se+1].stepName;else{const Be=de.findIndex(Oe=>ve(Oe==null?void 0:Oe.stepComponent)==="configurator");xe=Be>=0?(J=de[Be])==null?void 0:J.stepName:null}const De={payload:{savedProducts:[{itemId:ae}]}};xe?o.navigateToStep({stepName:xe,data:De}):o.loadComponent("configurator",De)}}}});const P=()=>{var ue,fe;const j=((ue=o==null?void 0:o.currentPlaybook)==null?void 0:ue.playBookSteps)||[],Z=H=>String(H||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_"),Y=j.findIndex(H=>Z(H==null?void 0:H.stepComponent)==="catalog"||Z(H==null?void 0:H.stepName).includes("catalog"));if(Y>=0){const H=(fe=j[Y])==null?void 0:fe.stepName;o.navigateToStep({stepName:H})}else o.loadComponent("catalog")},O=()=>{var ue,fe;const j=((ue=o==null?void 0:o.currentPlaybook)==null?void 0:ue.playBookSteps)||[],Z=H=>String(H||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_"),Y=j.findIndex(H=>Z(H==null?void 0:H.stepComponent)==="cart"||Z(H==null?void 0:H.stepName).includes("cart"));if(Y>=0){const H=(fe=j[Y])==null?void 0:fe.stepName;o.navigateToStep({stepName:H})}else o.loadComponent("cart")},R=j=>{var Z,Y;console.log("onItemConfigureClicked",j),t("catalog-item-configure",j);try{const ue=(j==null?void 0:j.itemId)||"",fe=(j==null?void 0:j.qliId)||(j==null?void 0:j.QliId)||"",H=[];if(ue){const Q={itemId:ue};fe&&(Q.qliId=fe),H.push(Q)}const z={payload:{savedProducts:H}},se=((Z=o==null?void 0:o.currentPlaybook)==null?void 0:Z.playBookSteps)||[],ce=Q=>String(Q||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_"),W=se.findIndex(Q=>{const te=ce(Q==null?void 0:Q.stepComponent),J=ce(Q==null?void 0:Q.stepName);return te==="configurator"||J.includes("configure")});if(W>=0){const Q=(Y=se[W])==null?void 0:Y.stepName;o.navigateToStep({stepName:Q,data:z})}else o.loadComponent("configurator",z)}catch(ue){console.warn("[aiComponentLoader] Failed to navigate to configurator from configure click:",ue),o.loadComponent("configurator",{payload:{}})}},D=j=>{console.log("onCartClicked",j),t("expeditecart-clicked",j)},L=j=>{var Z,Y;try{const ue=(j==null?void 0:j.itemId)||"",fe=(j==null?void 0:j.lineItemId)||(j==null?void 0:j.qliId)||"",H=[];if(ue){const Q={itemId:ue};fe&&(Q.qliId=fe),H.push(Q)}const z={payload:{savedProducts:H}},se=((Z=o==null?void 0:o.currentPlaybook)==null?void 0:Z.playBookSteps)||[],ce=Q=>String(Q||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_"),W=se.findIndex(Q=>{const te=ce(Q==null?void 0:Q.stepComponent),J=ce(Q==null?void 0:Q.stepName);return te==="configurator"||J.includes("configure")});if(W>=0){const Q=(Y=se[W])==null?void 0:Y.stepName;o.navigateToStep({stepName:Q,data:z})}else o.loadComponent("configurator",z)}catch(ue){console.warn("[aiComponentLoader] Failed to navigate to configurator from cart configure click:",ue),o.loadComponent("configurator",{payload:{}})}},V=j=>{console.log("onCatalogIdReceived",j),a.updateConfig({eCatalogId:j})},N=j=>{console.log("Action",j),j.event==="add-to-quote"?t("configurator:add-to-quote",j.data):j.event==="save"&&t("configurator:save",j.data)},G=X("");return Ke(()=>o==null?void 0:o.activeComponentData,async j=>{var Y,ue,fe;if(!j)return;console.log("activeComponentData Changed",j);const Z=(j==null?void 0:j.requestId)||"";if(console.log("requestId",Z),console.log("lastReloadRequestId",G.value),Z&&Z!==G.value)if(G.value=Z,await Tt(),(Y=j==null?void 0:j.payload)!=null&&Y.quoteConfiguration&&Object.keys(((ue=j==null?void 0:j.payload)==null?void 0:ue.quoteConfiguration)??{}).length>0){const H=Object.keys(((fe=j==null?void 0:j.payload)==null?void 0:fe.quoteConfiguration)??{})[0];i.setPreConfigData(j==null?void 0:j.payload,H)}else(j==null?void 0:j.actionFunction)==="Reload"&&(console.log("Reloading configurator 1"),i.refresh())},{deep:!0}),bt(()=>{Tt(()=>{I()})}),(j,Z)=>(B(),U("div",ST,[u.value==="catalog"?(B(),Ce(eh,{key:b.value,"data-test-id":"aiComponentLoader-catalog",class:"ect-h-full ect-w-full","template-id":e.templateId,identity:e.identity,session:e.session,security:e.security,"search-term":f.value,"on-catalog-count-update":e.onCatalogCountUpdate,"preview-data":e.catalogPreviewData,"initial-data":p.value,sections:e.sections,theme:e.theme,"composables-org-type":e.composablesOrgType,onCatalogQuoteCreated:q,onCatalogQuoteUpdated:K,onCatalogItemsLoaded:T,onCatalogItemAdded:$,onCatalogItemQtyUpdated:ne,onCatalogLineDeleted:le,onCatalogItemsFetched:oe,onCatalogItemConfigure:R,"onCatalog:id":V},null,8,["template-id","identity","session","security","search-term","on-catalog-count-update","preview-data","initial-data","sections","theme","composables-org-type"])):u.value==="cart"&&c.value&&h.value?(B(),Ce(th,{key:x.value,"data-test-id":"aiComponentLoader-cart",class:"ect-h-full ect-w-full","template-id":e.templateId,"host-name":e.hostName,"composables-org-type":e.composablesOrgType,security:e.security,identity:e.identity,session:d.value,onExpeditecartItemConfigure:L,onExpeditecartClicked:D},null,8,["template-id","host-name","composables-org-type","security","identity","session"])):u.value==="cart"&&c.value&&!h.value?(B(),U("div",OT,TT)):u.value==="configurator"&&_.value?(B(),Ce(L2,{key:E.value,"data-test-id":"aiComponentLoader-configurator",class:"ect-h-full ect-w-full",security:e.security,identity:e.identity,"user-locale":j.userLocale,cart:!0,"composables-org-type":e.composablesOrgType,session:s.value,functions:l.value,onReady:Ie(i).setExpediteConfigComp,onAction:N},null,8,["security","identity","user-locale","composables-org-type","session","functions","onReady"])):u.value==="configurator"&&!_.value?(B(),Ce(IT,{key:4,onReturn:P,onGoCart:O})):(B(),U("div",DT,[C("div",RT,[MT,C("div",BT,be(g.value),1)])]))]))}},[["__scopeId","data-v-3c362460"]]),NT={class:"ai-guidance-loader","data-test-id":"aiGuidance-loader-container"},LT={"data-test-id":"aiGuidance-loader-text"},PT={class:"aig-button","data-test-id":"aiGuidance-loader-button"},qT={class:"aig-input-box","data-test-id":"aiGuidance-loader-input"},$T=Me({__name:"AiGuidanceLoader",props:{errors:{type:Array,required:!1,default:()=>[]},chatBgColor:{type:String,required:!1,default:""}},setup(e){const n=e,t=ye(()=>`linear-gradient(180deg, ${n.chatBgColor} 0%, transparent 100%)`);return(r,o)=>(B(),U(ke,null,[C("div",{class:"chat-gradient",style:Ae({background:t.value})},null,4),C("div",NT,[C("div",LT,[pe(Pi,{style:{width:"100%",height:"16px","margin-bottom":"8px"}}),pe(Pi,{style:{width:"100%",height:"16px","margin-bottom":"32px","max-width":"481px"}})]),C("div",PT,[pe(Pi,{style:{width:"100%",height:"24px"}})]),(B(!0),U(ke,null,Fe(e.errors,i=>(B(),U("div",{key:i,class:"aig-message-error","data-test-id":"aiGuidance-loader-error"},be(i),1))),128)),C("div",qT,[pe(Pi,{style:{height:"36px",width:"100%"}})])])],64))}},[["__scopeId","data-v-5e4a9913"]]),UT={class:"ai-guidance-wrapper","data-test-id":"aiGuidance-wrapper"},jT=Me({__name:"aiGuidance",props:{templateId:{type:String,required:!1},playbookData:{type:Object,required:!1},composablesOrgType:{type:String,required:!0},identity:{type:Object,required:!1,default:()=>({})},session:{type:Object,required:!1,default:()=>({})},security:{type:Object,required:!1,default:()=>({})},functions:{type:Object,required:!1,default:()=>({})},websocketUrl:{type:String,required:!0},packageVersion:{type:String,required:!0},hostName:{type:String,required:!1},graphqlEndpoint:{type:String,required:!1},apiKey:{type:String,required:!1},isPreview:{type:Boolean,required:!1,default:!1},catalogSections:{type:Array,required:!1,default:()=>[]},cartSections:{type:String,required:!1,default:""},theme:{type:Object,required:!1,default:()=>({})},styles:{type:Object,required:!1,default:()=>({height:"100vh"}),validator:e=>typeof(e==null?void 0:e.height)=="string"}},emits:["expeditecart-item-configure","expeditecart-clicked","component-action","ai-response:success","quote-id:updated","ai-guidance:error"],setup(e,{emit:n}){const t=Vo(),r=qt(),o=_o(),i=Ti(),a=n,s=X(!0),l=X(!1),u=X(!0),c=X(!0),h=X(!1),d=X([]),{emitError:p,emitErrors:f}=nh(a,"aiGuidance"),v=e,{composablesOrgType:m,websocketUrl:_,packageVersion:g,identity:y,session:b,security:x,functions:A,templateId:E,hostName:S,graphqlEndpoint:M,apiKey:I,isPreview:k,catalogSections:w,cartSections:T,theme:q}=v,K=ye(()=>{var D,L,V;return{...v.session||{},quoteId:((D=v.session)==null?void 0:D.quoteId)||(((L=r.quoteId)==null?void 0:L.value)??""),eCatalogId:(V=r.eCatalogId)==null?void 0:V.value}});Zt(async()=>{console.log("security",x),console.log("apiKey",I),r.updateConfig({userId:y==null?void 0:y.userId,organizationId:y==null?void 0:y.organizationId,accessToken:x==null?void 0:x.accessToken,composablesApiUrl:x==null?void 0:x.baseUrl,composablesOrgType:m,websocketUrl:_,quoteId:b==null?void 0:b.quoteId,packageVersion:g,accountId:y==null?void 0:y.accountId,templateId:E,hostName:S,graphqlEndpoint:M,apiKey:(x==null?void 0:x.apiKey)||I,cid:y==null?void 0:y.contactId,isPreview:k})}),bt(async()=>{var j,Z,Y,ue;const D=c8(v,y,x);f(D);const L=p2(_);if(L&&p(L),D.length>0||L){s.value=!1;return}t.setSecretKey(x==null?void 0:x.accessToken);let V=null,N,G;try{V=await t.getPlaybookInfoFromQuote(),N=(V==null?void 0:V.XX_ORD1__Completed_PB_Step_Number_EX__c)??void 0,G=(V==null?void 0:V.XX_ORD1__Playbook_Current_Step_Meta_EX__c)??void 0}catch(fe){console.error("[aiGuidance] Failed to get playbook info from quote:",fe),p("AI_GUIDANCE_PLAYBOOK_INFO_FETCH_FAILED",{error:fe.message})}if(G)try{G=JSON.parse(G)}catch(fe){console.error("[aiGuidance] Failed to parse currentStepMetaServer:",fe),p("AI_GUIDANCE_JSON_PARSE_ERROR",{error:fe.message,data:"currentStepMetaServer"}),G=void 0}if(console.info("sequenceNumberServer = ",N),v.templateId){s.value=!0;try{const H=await t.getCatalogInContext();console.log("catalogInContext = ",H),H&&r.updateConfig({eCatalogId:H})}catch(H){console.error("[aiGuidance] Failed to get catalog in context:",H),p("AI_GUIDANCE_CATALOG_FETCH_FAILED",{error:H.message})}let fe=null;try{await i.fetchBlockInformationREST({templateId:v.templateId});const H=d8(i.pageBlocks);fe=H.playbookId,H.error&&p(H.error,{error:"Block structure validation failed"}),fe||p("AI_GUIDANCE_BLOCK_PLAYBOOK_ID_MISSING",{pageBlocks:i.pageBlocks})}catch(H){console.error("[aiGuidance] Failed to fetch block information:",H),p("AI_GUIDANCE_BLOCK_FETCH_FAILED",{error:H.message})}if(console.log("playbookID",fe),fe?l.value=!0:d.value.push("No playbook ID found in template"),t.setEmbeddedMode(!0),fe)try{t.currentPlaybook=fe,await t.getPlaybookByKey(fe),t.showPlaybookSteps=!0}catch(H){console.error("[aiGuidance] Failed to get playbook by key:",H),p("AI_GUIDANCE_PLAYBOOK_FETCH_FAILED",{error:H.message,playbookID:fe})}t.playbookStepsMode="full",o.setInitialPayload();try{await o.connectSocket()}catch(H){console.error("[aiGuidance] Failed to connect socket:",H),p("WEBSOCKET_CONNECTION_FAILED",{error:H.message})}if(N!==void 0){t.navigateToStep({stepName:(Z=(j=t.currentPlaybook)==null?void 0:j.playBookSteps[Number(N)])==null?void 0:Z.stepName,data:G}),s.value=!1;return}(ue=(Y=t.currentPlaybook)==null?void 0:Y.playBookSteps)!=null&&ue.length&&t.setCurrentStepName(t.currentPlaybook.playBookSteps[0].stepName),s.value=!1}else d.value.push("templateId is required")});const $=ye(()=>{var V;const D=((V=t.currentPlaybook)==null?void 0:V.playBookSteps)||[],L=t.currentStepName;return D.find(N=>N.stepName===L)||D[0]||null}),ne=ye(()=>{var D;return((D=$.value)==null?void 0:D.stepComponent)||null});Ke(()=>t.activeComponentKey,D=>{D&&(u.value=!1)});const le=[];bt(()=>{le.push(An("expeditecart:configure-clicked",D=>{a("expeditecart-item-configure",D)})),le.push(An("expeditecart:clicked",D=>{a("expeditecart-clicked",D)})),le.push(An("ai-response:success",D=>{try{a("ai-response:success",D)}catch{}})),le.push(An("quote-id:updated",D=>{try{a("quote-id:updated",D)}catch(L){console.info("[aiGuidance] Error emitting quote-id:updated event:",L)}})),le.push(An("websocket:error",D=>{try{D!=null&&D.isInitialization&&p(D.errorCode||"WEBSOCKET_CONNECTION_FAILED",D)}catch(L){console.info("[aiGuidance] Error handling websocket error event:",L)}}))});const oe=D=>{console.log("[aiGuidance] Received error from aiComponentLoader:",D),a("ai-guidance:error",D)},P=D=>{console.log("onExpediteCartClicked",D),a("component-action",{component:"cart",details:D})},O=(D,L)=>{var N;a("component-action",{component:"catalog",action:D,details:L});const V=(L==null?void 0:L.quoteId)??((N=L==null?void 0:L.response)==null?void 0:N.quoteId);if(V&&(D==="item-added"||D==="items-fetched"))try{a("quote-id:updated",{quoteId:V})}catch(G){console.info("[aiGuidance] Error emitting quote-id:updated from catalog event:",G)}},R=(D,L)=>{a("component-action",{component:"configurator",action:D,details:L})};return er(()=>{try{o.cancelRequest()}catch{}try{o.disconnectSocket()}catch{}try{o.resetState()}catch{}try{t.setEmbeddedMode(!1),t.currentPlaybook=null,t.currentStepName=null,t.activeComponentKey=null,t.activeComponentData=null,t.showPlaybookSteps=!1,t.playbookStepsMode="full"}catch{}s.value=!1,l.value=!1,u.value=!0,c.value=!0,h.value=!1,d.value=[],le.forEach(D=>{try{D()}catch{}})}),(D,L)=>{var V;return B(),U("div",UT,[pe(oc,{icon:"logo",color:"#000000",size:"18.75",height:"16.25"}),s.value||Ie(o).isFetchingHistory?(B(),Ce($T,{key:0,errors:d.value,"data-test-id":"aiGuidance-loader"},null,8,["errors"])):(B(),U("div",{key:1,class:we(["ai-app",{"root-path":u.value,"playbook-steps-mode-full":Ie(t).playbookStepsMode==="full","dxp-guiddance":l.value}]),style:Ae(e.styles)},[C("div",{class:"ai-app-chat-wrapper",style:Ae({height:e.styles.height})},[pe(_T,{"data-test-id":"chat-screen","is-external-guidance":l.value,styles:e.styles},null,8,["is-external-guidance","styles"])],4),!u.value&&c.value&&!h.value?(B(),U("div",{key:0,class:"component-loader-wrapper",style:Ae({height:e.styles.height,maxHeight:e.styles.height})},[Ie(t).currentPlaybook?(B(),Ce(FT,{key:0,"template-id":((V=$.value)==null?void 0:V.templateId)||Ie(E),"step-component":ne.value,identity:Ie(y),session:K.value,security:Ie(x),functions:Ie(A),"composables-org-type":Ie(m),"package-version":Ie(g),"host-name":Ie(S),"graphql-endpoint":Ie(M),"api-key":Ie(I),"is-preview":Ie(k),sections:Ie(w),"cart-sections":Ie(T),theme:Ie(q),"data-test-id":"aiComponentLoader-mounted",onExpeditecartClicked:P,onCatalogQuoteCreated:L[0]||(L[0]=N=>O("quote-created",N)),onCatalogQuoteUpdated:L[1]||(L[1]=N=>O("quote-updated",N)),onCatalogItemsLoaded:L[2]||(L[2]=N=>O("items-loaded",N)),onCatalogItemAdded:L[3]||(L[3]=N=>O("item-added",N)),onCatalogItemQtyUpdated:L[4]||(L[4]=N=>O("item-qty-updated",N)),onCatalogLineDeleted:L[5]||(L[5]=N=>O("line-deleted",N)),onCatalogItemsFetched:L[6]||(L[6]=N=>O("items-fetched",N)),onCatalogItemConfigure:L[7]||(L[7]=N=>O("item-configure",N)),"onConfigurator:addToQuote":L[8]||(L[8]=N=>R("add-to-quote",N)),"onConfigurator:save":L[9]||(L[9]=N=>R("save",N)),"onAiGuidance:error":oe},null,8,["template-id","step-component","identity","session","security","functions","composables-org-type","package-version","host-name","graphql-endpoint","api-key","is-preview","sections","cart-sections","theme"])):me("",!0)],4)):me("",!0)],6))])}}},[["__scopeId","data-v-40bb4f79"]]);let Ns=null;if(typeof window<"u"){try{Ns=Y6()}catch{}Ns||(Ns=e3(),Ei(Ns))}let Ls=null,Ps=null;const Vc=new Set;let Eo=null;const zc=new Map;async function HT(e){if(!e)return"";if(zc.has(e))return zc.get(e);try{const n=await fetch(e,{credentials:"omit",cache:"no-cache"});if(n.ok){const t=await n.text();return zc.set(e,t),t}}catch(n){console.warn("[ExpediteComponents] Failed to fetch theme CSS:",n)}return""}async function Gc(e,n){if(!e||!n)return;const t=e.querySelector("style[data-vue-expedite-theme]");t&&t.remove();try{const r=await HT(n);if(r){const o=document.createElement("style");o.setAttribute("data-vue-expedite-theme","true"),o.textContent=r,e.prepend(o)}}catch(r){console.warn("[ExpediteComponents] Failed to inject theme CSS:",r)}}function Kc(e){Eo=e||null,Eo&&Vc.forEach(n=>{n&&n.shadowRoot&&Gc(n.shadowRoot,Eo)})}async function VT(){return Ls||Ps||(Ps=(async()=>{try{const e=new URL("./style.css",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Or&&Or.src||new URL("vue-expedite-components.umd.cjs",document.baseURI).href).href,n=await fetch(e);if(n.ok)return Ls=await n.text(),Ls}catch(e){console.warn("[ExpediteComponents] Failed to load CSS:",e)}return null})(),Ps)}const Yi=e=>class extends e{async connectedCallback(){if(super.connectedCallback&&super.connectedCallback(),Vc.add(this),!!this.shadowRoot){if(this.shadowRoot.querySelector("style[data-vue-expedite-style]")){Eo&&Gc(this.shadowRoot,Eo);return}try{const n=await VT();if(n){const t=document.createElement("style");t.setAttribute("data-vue-expedite-style","true"),t.textContent=n,this.shadowRoot.prepend(t)}else{const t=new URL("./style.css",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Or&&Or.src||new URL("vue-expedite-components.umd.cjs",document.baseURI).href).href,r=document.createElement("link");r.setAttribute("rel","stylesheet"),r.setAttribute("data-vue-expedite-style","true"),r.href=t,this.shadowRoot.prepend(r)}Eo&&Gc(this.shadowRoot,Eo)}catch(n){console.warn("[ExpediteComponents] Failed to inject CSS:",n)}}}disconnectedCallback(){Vc.delete(this),super.disconnectedCallback&&super.disconnectedCallback()}},cp=Yi(Ci(L2)),dp=Yi(Ci(kx)),fp=Yi(Ci(eh)),hp=Yi(Ci(th)),pp=Yi(Ci(jT));function Xc(){typeof window<"u"&&(customElements.get("vue-expedite-configurator")||customElements.define("vue-expedite-configurator",cp),customElements.get("vue-expedite-gpt")||customElements.define("vue-expedite-gpt",dp),customElements.get("vue-expedite-catalog")||customElements.define("vue-expedite-catalog",fp),customElements.get("vue-expedite-cart")||customElements.define("vue-expedite-cart",hp),customElements.get("vue-expedite-ai-guidance")||customElements.define("vue-expedite-ai-guidance",pp))}typeof window<"u"&&Xc();const zT={register:Xc,applyThemeToShadows:Kc};typeof window<"u"&&(window.VueExpediteComponents=Object.assign(window.VueExpediteComponents||{},{applyThemeToShadows:Kc})),_n.ExpediteAIGuidanceElement=pp,_n.ExpediteCartElement=hp,_n.ExpediteCatalogElement=fp,_n.ExpediteConfiguratorElement=cp,_n.ExpediteGPTElement=dp,_n.applyThemeToShadows=Kc,_n.default=zT,_n.registerWebComponents=Xc,Object.defineProperties(_n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
187
|
+
`);return v=v.replace(/^[ \t]*•[ \t]+/gm,"- "),v};return(f,v)=>(B(),U("div",{class:we(["chat-messages",{"root-path":s.value}])},[C("div",{class:"chat-gradient",style:Ae({background:c.value})},null,4),C("div",{ref_key:"chatMessagesRef",ref:t,class:"messages-wrapper"},[(B(!0),U(ke,null,Fe([...e.messages],(m,_)=>{var g;return B(),U("div",{key:_,class:we(["message",{"user-message":m.type==="user"}])},[C("div",PO,[m.name?(B(),U("div",qO,be(m.name),1)):me("",!0),C("div",{class:we(["message-text ect-relative",{"error-message":m.error,strikethrough:m.undone}]),style:Ae(m.type==="user"?{color:h.value,backgroundColor:u.value}:{})},[C("div",$O,[pe(lp,{source:p(m.message)},null,8,["source"])]),((g=m==null?void 0:m.filesData)==null?void 0:g.length)>0?(B(!0),U(ke,{key:0},Fe(m==null?void 0:m.filesData,y=>(B(),Ce(qw,{key:y.name,info:{iconUrl:(y==null?void 0:y.type)==="csv"?Ie(rh):Ie(oh),fileName:y==null?void 0:y.name,fileSize:y==null?void 0:y.size},background:m.type=="user"?"#fff":"#f8f8f8","encoded-string":y==null?void 0:y.encodedString},null,8,["info","background","encoded-string"]))),128)):me("",!0)],6)])],2)}),128)),e.loadingMessage?(B(),U("div",{key:0,class:we(["loading-message",{"thinking-message":Ie(o).isThinkingMessage}])},[C("div",{class:we(["ect-flex ect-gap-3",{"ect-w-full":Ie(o).isThinkingMessage}])},[C("div",UO,[C("div",jO,[C("div",{ref_key:"loadingWindowRef",ref:r,class:"loading-window"},[C("div",HO,[pe(lp,{source:p(e.loadingMessage)},null,8,["source"])])],512)]),C("div",VO,[pe(Pi,{style:{height:"100%",width:"100%"}})])])],2)],2)):e.buttonLinks.length>0?(B(),U("div",zO,[pe(Bw,{links:e.buttonLinks,onPerformAction:d},null,8,["links"])])):me("",!0)],512)],2))}},[["__scopeId","data-v-d6e07984"]]),KO={class:"ai-upload ect-flex-inline ect-items-center"},XO=Me({__name:"FileUpload",props:{resetFileInput:{type:Boolean,default:!1}},emits:["upload-status","error"],setup(e,{emit:n}){const t=e,r=n,o=X(null),i=X(""),a=X(""),s=X(!1);Ke(()=>t.resetFileInput,h=>{h&&o.value&&(o.value.value="",i.value="",a.value="")});const l=h=>{const p=o.value.accept.split(",").map(v=>v.trim().toLowerCase()),f="."+h.name.split(".").pop().toLowerCase();return p.includes(f)||p.includes(h.type.toLowerCase())?!0:p.some(v=>{if(v.includes("*")){const m=v.split("*")[0];return h.type.toLowerCase().startsWith(m)}return!1})},u=async h=>{const d=h.target.files[0];if(console.info("File = ",d),d){if(!l(d)){o.value&&(o.value.value="");const f={message:"Invalid file type. Please upload a valid file type.",fileName:d.name,fileType:d.type};window&&window.$toast&&window.$toast.add({severity:"error",summary:"File Upload Error",detail:f.message,life:5e3}),r("error",f);return}i.value=d.name,a.value=d.type.split("/").pop(),r("upload-status",{status:"uploading",fileName:i.value,fileType:a.value});const p=new FileReader;p.onload=async f=>{const v=new Blob([f.target.result],{type:d.type});console.info("Blob data:",v);try{const m=await V3(v),_={attachment:{name:d.name,data:m}};console.info("AIRequestPayload = ",_),r("upload-status",{status:"uploaded",fileName:i.value,fileType:a.value,size:Af(d.size),fileData:_}),o.value&&(o.value.value="")}catch(m){console.info("[ERROR]: File upload error:",m),window&&window.$toast&&window.$toast.add({severity:"error",summary:"File Processing Error",detail:"Error processing file: "+(m.message||"Unknown error"),life:5e3}),r("error",{message:"Error processing file",fileName:i.value,fileType:a.value,error:m.message}),r("upload-status",{status:"error",fileName:i.value,fileType:a.value})}},p.onerror=f=>{console.info("[ERROR]: FileReader error:",f),window&&window.$toast&&window.$toast.add({severity:"error",summary:"File Reading Error",detail:"Could not read the selected file",life:5e3}),r("error",{message:"Error reading file",fileName:d.name,fileType:d.type,error:f})},setTimeout(()=>{p.readAsText(d)},100)}},c=()=>{o.value.click()};return(h,d)=>(B(),U("div",KO,[C("input",{ref_key:"fileInput",ref:o,type:"file",accept:".csv, .xls, .xlsx, text/csv, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",class:"ect-opacity-0 ect-h-0 ect-w-0 ect-absolute",onChange:u},null,544),C("button",{class:"attachment-button",onClick:c,onMouseenter:d[0]||(d[0]=p=>s.value=!0),onMouseleave:d[1]||(d[1]=p=>s.value=!1)},[pe(ze,{icon:"attachment",size:"11",height:"17",color:s.value?"#198708":"#828282"},null,8,["color"])],32)]))}},[["__scopeId","data-v-7fbbb7c9"]]),WO={key:0,class:"suggestions-container"},QO={key:0,class:"logo-section"},ZO={class:"help-text-section"},JO={key:0,class:"help-text"},YO={key:1,class:"sub-help-text"},eT=["onClick"],tT={key:2,class:"suggestions-list"},nT=["onClick"],rT=Me({__name:"AISuggestionsDropdown",props:{options:{type:Array,required:!0},helpText:{type:String,default:""},subHelpText:{type:String,default:""},showSuggestions:{type:Boolean,default:!1}},emits:["select","preview"],setup(e,{emit:n}){const t=e,r=n,o=X(0),i=X(0),a=X(null),s=X(null),l=d=>{a.value=d,i.value=0},u=()=>{a.value=null,o.value=0},c=d=>{r("select",d)},h=d=>{if(t.showSuggestions)switch(d.key){case"ArrowDown":d.preventDefault(),a.value?(i.value=(i.value+1)%a.value.subOptions.length,r("preview",a.value.subOptions[i.value])):(o.value=(o.value+1)%t.options.length,r("preview",t.options[o.value].title));break;case"ArrowUp":d.preventDefault(),a.value?(i.value=i.value-1<0?a.value.subOptions.length-1:i.value-1,r("preview",a.value.subOptions[i.value])):(o.value=o.value-1<0?t.options.length-1:o.value-1,r("preview",t.options[o.value].title));break;case"Enter":d.preventDefault(),a.value?c(a.value.subOptions[i.value]):l(t.options[o.value]);break;case"Escape":case"ArrowLeft":case"Backspace":a.value&&(d.preventDefault(),u());break}};return Ke(()=>t.showSuggestions,d=>{d?(window.addEventListener("keydown",h),a.value=null,o.value=0,i.value=0):window.removeEventListener("keydown",h)}),(d,p)=>e.showSuggestions?(B(),U("div",WO,[a.value?me("",!0):(B(),U("div",QO,[pe(e_)])),C("div",ZO,[e.helpText&&!a.value?(B(),U("div",JO,be(e.helpText),1)):me("",!0),e.subHelpText?(B(),U("div",YO,be(e.subHelpText),1)):me("",!0)]),a.value?(B(),U("div",tT,[(B(!0),U(ke,null,Fe(a.value.subOptions,(f,v)=>(B(),U("div",{key:v,class:we(["sub-option",{"sub-active":i.value===v}]),onClick:m=>c(f)},be(f),11,nT))),128))])):(B(),U("div",{key:1,ref_key:"suggestionsList",ref:s,class:"suggestions-list"},[(B(!0),U(ke,null,Fe(e.options,(f,v)=>(B(),U("div",{key:v,class:we(["suggestion-item",{active:o.value===v}]),onClick:m=>l(f)},be(f.title),11,eT))),128))],512))])):me("",!0)}},[["__scopeId","data-v-bbb514b3"]]),oT={class:"chat-file-info"},iT={class:"ect-flex ect-gap-2 ect-items-center ect-self-stretch ect-my-auto ect-text-xs ect-font-medium ect-text-black"},aT=["src"],sT={class:"ect-self-stretch ect-my-auto"},lT={key:0,class:"ect-flex ect-gap-2 ect-justify-center ect-items-center ect-self-stretch ect-my-auto ect-w-4 ect-h-4"},uT=Me({__name:"ChatInputFileInfo",props:{fileInfo:{type:Object,required:!0}},emits:["cancel"],setup(e,{emit:n}){const t=n,r=()=>{t("cancel")};return(o,i)=>(B(),U("div",oT,[C("div",iT,[C("img",{loading:"lazy",src:e.fileInfo.fileType==="csv"?Ie(rh):Ie(oh),class:"ect-object-contain ect-shrink-0 ect-self-stretch ect-my-auto ect-w-7 ect-aspect-square",alt:""},null,8,aT),C("div",sT,be(e.fileInfo.fileName),1)]),e.fileInfo.status==="uploading"?(B(),U("div",lT,[pe(ic,{size:18})])):me("",!0),e.fileInfo.status==="uploaded"?(B(),U("button",{key:1,class:"ect-flex ect-gap-2 ect-justify-center ect-items-center ect-self-stretch ect-my-auto ect-w-4 ect-h-4",onClick:r},[pe(ze,{icon:"close",size:"8"})])):me("",!0)]))}},[["__scopeId","data-v-24d881bd"]]),cT={class:"chat-input-wrapper"},dT={class:"chat-input-inner"},fT={class:"input-row"},hT=["disabled","placeholder","onKeydown"],pT={key:1,class:"icon-wrapper"},mT={class:"icon-wrapper"},gT=Me({__name:"chatInput",props:{modelValue:{type:String,default:""},loading:{type:Boolean,default:!1},placeholder:{type:String,default:"Ask Genesis AI"},helpText:{type:String,default:"Here are few areas where I can help"},subHelpText:{type:String,default:"Suggestions by Genesis (Click to Apply)"},showFile:{type:Boolean,default:!1},showMic:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},emits:["update:modelValue","submit","speak","file-upload-status"],setup(e,{emit:n}){const t=e,r=n;_o();const o=kn(),i=Vo(),a=X({}),s=X(!1),l=X(!1),u=X(t.modelValue),c=X(null),h=ye(()=>{const E=i.currentStep||null;return(Array.isArray(E==null?void 0:E.promptGuidance)?E.promptGuidance:[]).slice().sort((I,k)=>Number((I==null?void 0:I.sequenceNumber)??0)-Number((k==null?void 0:k.sequenceNumber)??0)).map(I=>{const w=(Array.isArray(I==null?void 0:I.relatedPG)?I.relatedPG:[]).slice().sort((T,q)=>Number((T==null?void 0:T.sequenceNumber)??0)-Number((q==null?void 0:q.sequenceNumber)??0)).map(T=>T.pgName);return{title:I.pgName,subOptions:w}})}),d=ye(()=>{var E;return(E=h.value)!=null&&E.length?h.value:[]}),p=ye(()=>{var E;return(E=h.value)!=null&&E.length?"Prompt Guidance":t.helpText});Ke(()=>t.loading,async(E,S)=>{!E&&S&&(await Tt(),c.value.focus())}),Ke(u,E=>{r("update:modelValue",E),Tt(()=>b())}),Ke(()=>t.modelValue,E=>{u.value=E});const f=E=>{console.info("[ERROR]: File upload error:",E),o.handleError(E,"ChatInput")},v=()=>{u.value.trim()&&(l.value=!1,r("submit",u.value),u.value="",c.value&&(c.value.style.height="32px"),a.value=null)},m=E=>{u.value=E,l.value=!1,Tt(()=>{b(),c.value&&(c.value.focus(),c.value.selectionStart=c.value.selectionEnd=u.value.length)})},_=E=>{u.value=E,Tt(()=>b())},g=()=>{l.value=!1},y=E=>{console.info("handleFileUploadStatus event = ",E),E!=null&&E.fileName?(a.value=E,r("file-upload-status",E)):(a.value=null,s.value=!0,r("file-upload-status",null),setTimeout(()=>{s.value=!1},3e3))},b=()=>{const E=c.value;if(!E)return;E.style.height="auto";const I=Math.max(32,Math.min(E.scrollHeight,120));E.style.height=`${I}px`},x=()=>{console.info("removeFile"),a.value=null,s.value=!0,r("file-upload-status",null),setTimeout(()=>{s.value=!1},100)},A=()=>{l.value=!1,b()};return(E,S)=>{var I,k,w,T,q;const M=nd("click-outside");return En((B(),U("div",cT,[pe(rT,{options:d.value,"help-text":p.value,"sub-help-text":e.subHelpText,"show-suggestions":l.value,onSelect:m,onPreview:_},null,8,["options","help-text","sub-help-text","show-suggestions"]),C("div",dT,[C("div",fT,[C("div",{class:we(["icon-wrapper",{"active-suggestions":l.value,disabled:((I=d.value)==null?void 0:I.length)<=0}])},[pe(ze,{disabled:((k=d.value)==null?void 0:k.length)<=0||e.loading,color:((w=d.value)==null?void 0:w.length)<=0?"#DEDEDE":l.value?"#198708":"#828282",icon:"suggestions",size:"13",height:15,onClick:S[0]||(S[0]=K=>l.value=!l.value)},null,8,["disabled","color"])],2),En(C("textarea",{ref_key:"textareaRef",ref:c,"onUpdate:modelValue":S[1]||(S[1]=K=>u.value=K),disabled:e.loading,placeholder:e.placeholder,rows:"1",onKeydown:Un(_t(v,["exact","prevent"]),["enter"]),onInput:A},null,40,hT),[[po,u.value]]),e.showFile?(B(),U("div",{key:0,class:we(["icon-wrapper",{"file-upload-disabled":e.loading}])},[pe(XO,{"reset-file-input":s.value,onUploadStatus:y,onError:f},null,8,["reset-file-input"])],2)):me("",!0),e.showMic?(B(),U("div",pT,[pe(ze,{color:"#828282",disabled:e.loading,icon:"mic",size:"13",height:15,onClick:S[2]||(S[2]=K=>E.$emit("speak"))},null,8,["disabled"])])):me("",!0),C("div",mT,[(B(),Ce(ze,{key:1,disabled:e.loading,icon:"send",size:"20",onClick:v},null,8,["disabled"]))])]),((T=a.value)==null?void 0:T.status)==="uploading"||((q=a.value)==null?void 0:q.status)==="uploaded"?(B(),Ce(uT,{key:0,class:"ect-mt-3 ect-mb-0.5","file-info":a.value,onCancel:x},null,8,["file-info"])):me("",!0)])])),[[M,g]])}}},[["__scopeId","data-v-e205d71c"]]),yT=["data-test-id"],vT=["data-test-id"],bT=["data-test-id"],_T=Me({__name:"aiChat",props:{dataTestId:{type:String,required:!0},isExternalGuidance:{type:Boolean,required:!1,default:!1},styles:{type:Object,required:!1,default:()=>({}),validator:e=>typeof(e==null?void 0:e.height)=="string"}},setup(e){const n=Vo(),t=_o(),r=X(null),o=ye(()=>{var l;return((l=n.getCurrentStepLinks)==null?void 0:l.call(n))||[]}),i=ye(()=>!0),a=l=>{console.info("[aiChat] handleSubmit",{hasFileData:!!r.value,messageLength:(l||"").length}),r.value?(console.info("[aiChat] sending with file attachment"),t.sendMessage(l,!0,r.value)):(console.info("[aiChat] sending without attachment"),t.sendMessage(l))},s=l=>{console.info("ChatScreen handleFileUploadStatus event = ",l),l!=null&&l.fileData?(r.value=l.fileData,t.attachmentData={size:l.size,type:l.fileType,name:l.fileName}):(r.value=null,t.attachmentData=null)};return(l,u)=>(B(),U("div",{class:"chat-screen","data-test-id":e.dataTestId},[C("div",{class:we(["messages-container",{"playbook-steps-mode-hybrid":Ie(n).playbookStepsMode==="hybrid","playbook-steps-mode-full":Ie(n).playbookStepsMode==="full","dxp-guiddance":e.isExternalGuidance}]),style:Ae({maxHeight:`calc(${e.styles.height} - 72px)`,height:`calc(${e.styles.height} - 72px)`}),"data-test-id":`${e.dataTestId}-messages-container`},[pe(GO,{messages:Ie(t).chatHistory,"loading-message":Ie(t).loadingMessage,"undo-id":Ie(t).latestDMLRequest,"button-links":o.value,"strikethrough-ids":Ie(t).strikethroughHistory,"data-changed":Ie(t).dataManuallyChanged,"data-test-id":`${e.dataTestId}-messages`},null,8,["messages","loading-message","undo-id","button-links","strikethrough-ids","data-changed","data-test-id"])],14,vT),C("div",{class:"input-container","data-test-id":`${e.dataTestId}-input-container`},[pe(gT,{modelValue:Ie(t).promptMessage,"onUpdate:modelValue":u[0]||(u[0]=c=>Ie(t).promptMessage=c),disabled:!i.value,"file-info":r.value,loading:!!Ie(t).loadingMessage,"data-test-id":`${e.dataTestId}-input`,onSubmit:a,onFileUploadStatus:s},null,8,["modelValue","disabled","file-info","loading","data-test-id"])],8,bT)],8,yT))}},[["__scopeId","data-v-99005673"]]),xT={class:"ect-h-full ect-w-full ect-flex ect-items-center ect-justify-center","data-test-id":"configurator-not-found"},CT={class:"ect-max-w-[720px] ect-p-[50px] ect-border ect-rounded-lg ect-bg-white ect-shadow-sm"},ET={class:"ect-text-[40px] ect-leading-none ect-mb-3"},kT=C("div",{class:"ect-text-[22px] ect-font-normal ect-leading-normal ect-mb-[12px] ect-capitalize ect-text-[#5F5F5F]","data-test-id":"configurator-not-found-title"}," Product Configurator Not Found ",-1),AT=C("div",{class:"ect-text-sm ect-text-gray-500","data-test-id":"configurator-not-found-subtitle"}," Linked composable product configurator UI component for this screen is not found OR the composable product configurator UI component does not exist. Please create / connect one and try again. ",-1),wT={class:"ect-mt-4 ect-flex ect-items-center ect-justify-between ect-gap-6"},IT={__name:"MoleculeConfiguratorNotFound",emits:["return","go-cart"],setup(e){return(n,t)=>(B(),U("div",xT,[C("div",CT,[C("div",ET,[pe(ze,{icon:"error",size:48})]),kT,AT,C("div",wT,[C("button",{type:"button",class:"ect-text-green-600 ect-text-sm ect-font-medium",onClick:t[0]||(t[0]=r=>n.$emit("return")),"data-test-id":"configurator-not-found-return"}," RETURN TO PRODUCT RESULTS "),C("button",{type:"button",class:"ect-text-green-600 ect-text-sm ect-font-medium",onClick:t[1]||(t[1]=r=>n.$emit("go-cart")),"data-test-id":"configurator-not-found-go-to-cart"}," GO TO CART ")])])]))}},up=e=>(Wt("data-v-fe69264f"),e=e(),Qt(),e),ST={class:"ect-h-full ect-w-full ect-bg-white","data-test-id":"aiComponentLoader-wrapper"},OT={key:2,class:"ect-h-full ect-w-full ect-flex ect-items-center ect-justify-center","data-test-id":"aiComponentLoader-cart-error"},TT=[up(()=>C("div",{class:"ect-text-center"},[C("div",{class:"ect-text-base ect-font-medium ect-text-red-600","data-test-id":"aiComponentLoader-cart-error-title"}," Quote Required "),C("div",{class:"ect-text-sm ect-text-gray-500 ect-mt-2","data-test-id":"aiComponentLoader-cart-error-message"}," A quote is required for the cart component to work. Please ensure a quoteId is provided in the session prop. ")],-1))],DT={key:5,class:"ect-h-full ect-w-full ect-flex ect-items-center ect-justify-center"},RT={class:"ect-text-center"},MT=up(()=>C("div",{class:"ect-text-base ect-font-medium","data-test-id":"aiComponentLoader-fallback-title"}," No component to display for this step ",-1)),BT={class:"ect-text-sm ect-text-gray-500 ect-mt-2","data-test-id":"aiComponentLoader-fallback-subtitle"},FT=Me({__name:"aiComponentLoader",props:{stepComponent:{type:String,default:null},identity:{type:Object,default:()=>({})},session:{type:Object,default:()=>({})},security:{type:Object,default:()=>({})},packageVersion:{type:String,default:""},composablesOrgType:{type:String,default:""},composablesApiKey:{type:String,default:""},templateId:{type:String,default:""},hostName:{type:String,default:""},graphqlEndpoint:{type:String,default:""},apiKey:{type:String,default:""},isPreview:{type:Boolean,default:!1},sections:{type:Array,default:()=>[]},theme:{type:Object,default:()=>({})},catalogPreviewData:{type:Object,default:()=>({})},catalogInitialData:{type:Array,default:()=>[]},catalogSearchTerm:{type:String,default:""},onCatalogCountUpdate:{type:Function,default:null},cartSections:{type:String,default:""},configItemId:{type:String,default:""},configQliId:{type:String,default:""},configApiKey:{type:String,default:""},resources:{type:Object,default:()=>({})},functions:{type:Object,default:()=>({})}},emits:["expeditecart-clicked","ai-guidance:error","catalog-quote-created","catalog-quote-updated","catalog-items-loaded","catalog-item-added","catalog-item-qty-updated","catalog-line-deleted","catalog-items-fetched","catalog-item-configure"],setup(e,{emit:n}){const t=n,r=e,o=Vo(),i=ec(),a=qt(),s=ye(()=>{var Z,Y,ue,fe,H;const j=((Z=r.session)==null?void 0:Z.quoteId)||((Y=a.quoteId)==null?void 0:Y.value)||((ue=o==null?void 0:o.activeComponentData)==null?void 0:ue.contextObjectId)||((H=(fe=o==null?void 0:o.activeComponentData)==null?void 0:fe.payload)==null?void 0:H.contextObjectId);return{...r.session,...j&&{quoteId:j},qliId:m.value||r.configQliId||void 0,itemId:v.value}}),l=ye(()=>{const j=r.functions||{},Z=j.createQuote;return typeof Z!="function"?j:{...j,createQuote:async(...Y)=>{const ue=await Z(...Y);return ue&&a.updateConfig({quoteId:ue}),ue}}}),u=ye(()=>{const j=o==null?void 0:o.activeComponentKey,Z=r.stepComponent;return(j||Z||"").toString().trim().toLowerCase().replace(/[^a-z0-9]+/g,"_")}),c=ye(()=>{var fe,H;const j=!!r.templateId,Z=!!((fe=r.identity)!=null&&fe.organizationId),Y=!!((H=r.identity)!=null&&H.accountId),ue=typeof r.cartSections=="string"&&r.cartSections.length>0;return j&&Z&&Y&&ue}),h=ye(()=>{var ue,fe,H,z,se;const j=(ue=r.session)==null?void 0:ue.quoteId,Z=(fe=a.quoteId)==null?void 0:fe.value,Y=((H=o==null?void 0:o.activeComponentData)==null?void 0:H.contextObjectId)||((se=(z=o==null?void 0:o.activeComponentData)==null?void 0:z.payload)==null?void 0:se.contextObjectId);return!!(j||Z||Y)}),d=ye(()=>{var Z,Y,ue,fe,H;const j=((Z=r.session)==null?void 0:Z.quoteId)||((Y=a.quoteId)==null?void 0:Y.value)||((ue=o==null?void 0:o.activeComponentData)==null?void 0:ue.contextObjectId)||((H=(fe=o==null?void 0:o.activeComponentData)==null?void 0:fe.payload)==null?void 0:H.contextObjectId);return{...r.session,...j&&{quoteId:j}}}),p=ye(()=>{var Z;if(Array.isArray(r.catalogInitialData)&&r.catalogInitialData.length>0)return r.catalogInitialData;const j=((Z=o==null?void 0:o.activeComponentData)==null?void 0:Z.payload)||{};if(j.catalog&&typeof j.catalog=="object")try{const ue=Object.values(j.catalog).map(fe=>{var H;return(H=fe==null?void 0:fe.catalogResponse)==null?void 0:H.productInfo}).filter(Boolean);if(ue.length>0)return ue}catch{}return Array.isArray(j.initialData)&&j.initialData.length>0?j.initialData:Array.isArray(j.catalogInitialData)&&j.catalogInitialData.length>0?j.catalogInitialData:Array.isArray(j.items)&&j.items.length>0?j.items:[]}),f=ye(()=>{var Z;const j=((Z=o==null?void 0:o.activeComponentData)==null?void 0:Z.payload)||{};return r.catalogSearchTerm||j.searchTerm||""}),v=ye(()=>{var Z,Y,ue,fe,H,z;const j=((fe=(ue=(Y=(Z=o==null?void 0:o.activeComponentData)==null?void 0:Z.payload)==null?void 0:Y.savedProducts)==null?void 0:ue[0])==null?void 0:fe.itemId)||((H=o==null?void 0:o.activeComponentData)==null?void 0:H.payload)&&Object.keys(((z=o.activeComponentData.payload)==null?void 0:z.quoteConfiguration)||{})[0]||"";return r.configItemId||j||""}),m=ye(()=>{var Z,Y,ue,fe,H,z,se,ce;const j=(fe=(ue=(Y=(Z=o==null?void 0:o.activeComponentData)==null?void 0:Z.payload)==null?void 0:Y.savedProducts)==null?void 0:ue[0])==null?void 0:fe.qliId;if(!j){console.log("[aiComponentLoader] configQliIdComputed: No qliId from savedProducts");const W=(z=(H=o==null?void 0:o.activeComponentData)==null?void 0:H.payload)==null?void 0:z.quoteConfiguration;if(console.log("[aiComponentLoader] configQliIdComputed: quoteConfiguration:",W),W&&typeof W=="object"){const Q=Object.keys(W)[0];if(console.log("[aiComponentLoader] configQliIdComputed: firstItemId:",Q),Q){const te=(se=W[Q])==null?void 0:se.product;if(console.log("[aiComponentLoader] configQliIdComputed: productObj:",te),te&&te.qliId)return console.log("[aiComponentLoader] configQliIdComputed: found qliId in productObj:",te.qliId),te.qliId;if((ce=W[Q])!=null&&ce.qliId)return console.log("[aiComponentLoader] configQliIdComputed: found qliId directly under itemId:",W[Q].qliId),W[Q].qliId}}}return j||""}),_=ye(()=>!!v.value),g=ye(()=>u.value==="configurator"&&!_.value?"Configurator requires an itemId (and optional qliId). Provide via playbook payload or props.":u.value==="catalog"?"Catalog step is active. Provide templateId/sections/theme when available.":u.value==="cart"?"Cart step is active.":"Awaiting playbook step selection."),y=ye(()=>{try{return JSON.stringify((o==null?void 0:o.activeComponentData)||{})}catch{return""}}),b=ye(()=>`catalog::${y.value}`),x=ye(()=>`cart::${y.value}`),A=ye(()=>{var j;try{return(((j=o==null?void 0:o.activeComponentData)==null?void 0:j.actionFunction)||"")==="Reload"}catch{return!1}}),E=ye(()=>{var Z;const j=`configurator::${v.value||""}::${m.value||""}`;if(A.value){const Y=((Z=o==null?void 0:o.activeComponentData)==null?void 0:Z.requestId)||"";return`${j}::${Y}`}return j}),{emitError:S,emitErrors:M}=nh(t,"aiComponentLoader"),I=()=>{const j=f8(o,u.value);M(j)},k=X([]),w=X(null),T=j=>{const Z=Array.isArray(j)?j:Array.isArray(j==null?void 0:j.items)?j.items:[];if(!Array.isArray(Z))return;const Y={"Needs Configuration":1,"Suggests Configuration":2,"Fully Configured":3},ue=z=>(z==null?void 0:z.requiresConfiguration)||"",fe=z=>!!z&&z in Y,H=Z.filter(z=>fe(ue(z)));H.sort((z,se)=>{const ce=ue(z),W=ue(se);return(Y[ce]||99)-(Y[W]||99)}),k.value=H,w.value=H.length?H[0]:null},q=j=>{console.log("onQuoteCreated",j),t("catalog-quote-created",j)},K=j=>{console.log("onQuoteUpdated",j),t("catalog-quote-updated",j)},$=j=>{console.log("onItemAdded",j),t("catalog-item-added",j)},ne=j=>{console.log("onItemQtyUpdated",j),t("catalog-item-qty-updated",j)},le=j=>{console.log("onLineDeleted",j),t("catalog-line-deleted",j)},oe=j=>{console.log("onQuoteItemsFetched",j),t("catalog-items-fetched",j)};Ke(()=>u.value,(j,Z)=>{var Y,ue,fe,H,z,se,ce,W,Q,te,J;if(j==="configurator"){const re=!!((fe=(ue=(Y=o==null?void 0:o.activeComponentData)==null?void 0:Y.payload)==null?void 0:ue.savedProducts)!=null&&fe.length),ie=!!((z=(H=o==null?void 0:o.activeComponentData)==null?void 0:H.payload)!=null&&z.quoteConfiguration&&Object.keys(((ce=(se=o==null?void 0:o.activeComponentData)==null?void 0:se.payload)==null?void 0:ce.quoteConfiguration)||{}).length>0);if(!re&&!ie&&w.value&&!v.value){const ae=((W=w.value)==null?void 0:W.itemId)||"";if(ae){const de=((Q=o==null?void 0:o.currentPlaybook)==null?void 0:Q.playBookSteps)||[],ve=Be=>String(Be||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_");let xe=null;const Se=de.findIndex(Be=>Be.stepName===(o==null?void 0:o.currentStepName));if(Se>=0&&de[Se+1]&&ve((te=de[Se+1])==null?void 0:te.stepComponent)==="configurator")xe=de[Se+1].stepName;else{const Be=de.findIndex(Oe=>ve(Oe==null?void 0:Oe.stepComponent)==="configurator");xe=Be>=0?(J=de[Be])==null?void 0:J.stepName:null}const De={payload:{savedProducts:[{itemId:ae}]}};xe?o.navigateToStep({stepName:xe,data:De}):o.loadComponent("configurator",De)}}}});const P=()=>{var ue,fe;const j=((ue=o==null?void 0:o.currentPlaybook)==null?void 0:ue.playBookSteps)||[],Z=H=>String(H||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_"),Y=j.findIndex(H=>Z(H==null?void 0:H.stepComponent)==="catalog"||Z(H==null?void 0:H.stepName).includes("catalog"));if(Y>=0){const H=(fe=j[Y])==null?void 0:fe.stepName;o.navigateToStep({stepName:H})}else o.loadComponent("catalog")},O=()=>{var ue,fe;const j=((ue=o==null?void 0:o.currentPlaybook)==null?void 0:ue.playBookSteps)||[],Z=H=>String(H||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_"),Y=j.findIndex(H=>Z(H==null?void 0:H.stepComponent)==="cart"||Z(H==null?void 0:H.stepName).includes("cart"));if(Y>=0){const H=(fe=j[Y])==null?void 0:fe.stepName;o.navigateToStep({stepName:H})}else o.loadComponent("cart")},R=j=>{var Z,Y;console.log("onItemConfigureClicked",j),t("catalog-item-configure",j);try{const ue=(j==null?void 0:j.itemId)||"",fe=(j==null?void 0:j.qliId)||(j==null?void 0:j.QliId)||"",H=[];if(ue){const Q={itemId:ue};fe&&(Q.qliId=fe),H.push(Q)}const z={payload:{savedProducts:H}},se=((Z=o==null?void 0:o.currentPlaybook)==null?void 0:Z.playBookSteps)||[],ce=Q=>String(Q||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_"),W=se.findIndex(Q=>{const te=ce(Q==null?void 0:Q.stepComponent),J=ce(Q==null?void 0:Q.stepName);return te==="configurator"||J.includes("configure")});if(W>=0){const Q=(Y=se[W])==null?void 0:Y.stepName;o.navigateToStep({stepName:Q,data:z})}else o.loadComponent("configurator",z)}catch(ue){console.warn("[aiComponentLoader] Failed to navigate to configurator from configure click:",ue),o.loadComponent("configurator",{payload:{}})}},D=j=>{console.log("onCartClicked",j),t("expeditecart-clicked",j)},L=j=>{var Z,Y;try{const ue=(j==null?void 0:j.itemId)||"",fe=(j==null?void 0:j.lineItemId)||(j==null?void 0:j.qliId)||"",H=[];if(ue){const Q={itemId:ue};fe&&(Q.qliId=fe),H.push(Q)}const z={payload:{savedProducts:H}},se=((Z=o==null?void 0:o.currentPlaybook)==null?void 0:Z.playBookSteps)||[],ce=Q=>String(Q||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_"),W=se.findIndex(Q=>{const te=ce(Q==null?void 0:Q.stepComponent),J=ce(Q==null?void 0:Q.stepName);return te==="configurator"||J.includes("configure")});if(W>=0){const Q=(Y=se[W])==null?void 0:Y.stepName;o.navigateToStep({stepName:Q,data:z})}else o.loadComponent("configurator",z)}catch(ue){console.warn("[aiComponentLoader] Failed to navigate to configurator from cart configure click:",ue),o.loadComponent("configurator",{payload:{}})}},V=j=>{console.log("onCatalogIdReceived",j),a.updateConfig({eCatalogId:j})},N=j=>{console.log("Action",j),j.event==="add-to-quote"?t("configurator:add-to-quote",j.data):j.event==="save"&&t("configurator:save",j.data)},G=X("");return Ke(()=>o==null?void 0:o.activeComponentData,async j=>{var Y,ue,fe;if(!j)return;console.log("activeComponentData Changed",j);const Z=(j==null?void 0:j.requestId)||"";if(console.log("requestId",Z),console.log("lastReloadRequestId",G.value),Z&&Z!==G.value)if(G.value=Z,await Tt(),(Y=j==null?void 0:j.payload)!=null&&Y.quoteConfiguration&&Object.keys(((ue=j==null?void 0:j.payload)==null?void 0:ue.quoteConfiguration)??{}).length>0){const H=Object.keys(((fe=j==null?void 0:j.payload)==null?void 0:fe.quoteConfiguration)??{})[0];i.setPreConfigData(j==null?void 0:j.payload,H)}else(j==null?void 0:j.actionFunction)==="Reload"&&(console.log("Reloading configurator 1"),i.refresh())},{deep:!0}),bt(()=>{Tt(()=>{I()})}),(j,Z)=>(B(),U("div",ST,[u.value==="catalog"?(B(),Ce(eh,{key:b.value,"data-test-id":"aiComponentLoader-catalog",class:"ect-h-full ect-w-full","template-id":e.templateId,identity:e.identity,session:e.session,security:e.security,"search-term":f.value,"on-catalog-count-update":e.onCatalogCountUpdate,"preview-data":e.catalogPreviewData,"initial-data":p.value,sections:e.sections,theme:e.theme,"composables-org-type":e.composablesOrgType,resources:e.resources,onCatalogQuoteCreated:q,onCatalogQuoteUpdated:K,onCatalogItemsLoaded:T,onCatalogItemAdded:$,onCatalogItemQtyUpdated:ne,onCatalogLineDeleted:le,onCatalogItemsFetched:oe,onCatalogItemConfigure:R,"onCatalog:id":V},null,8,["template-id","identity","session","security","search-term","on-catalog-count-update","preview-data","initial-data","sections","theme","composables-org-type","resources"])):u.value==="cart"&&c.value&&h.value?(B(),Ce(th,{key:x.value,"data-test-id":"aiComponentLoader-cart",class:"ect-h-full ect-w-full","template-id":e.templateId,"host-name":e.hostName,"composables-org-type":e.composablesOrgType,security:e.security,identity:e.identity,session:d.value,resources:e.resources,onExpeditecartItemConfigure:L,onExpeditecartClicked:D},null,8,["template-id","host-name","composables-org-type","security","identity","session","resources"])):u.value==="cart"&&c.value&&!h.value?(B(),U("div",OT,TT)):u.value==="configurator"&&_.value?(B(),Ce(L2,{key:E.value,"data-test-id":"aiComponentLoader-configurator",class:"ect-h-full ect-w-full",security:e.security,identity:e.identity,"user-locale":j.userLocale,cart:!0,"composables-org-type":e.composablesOrgType,session:s.value,functions:l.value,onReady:Ie(i).setExpediteConfigComp,onAction:N},null,8,["security","identity","user-locale","composables-org-type","session","functions","onReady"])):u.value==="configurator"&&!_.value?(B(),Ce(IT,{key:4,onReturn:P,onGoCart:O})):(B(),U("div",DT,[C("div",RT,[MT,C("div",BT,be(g.value),1)])]))]))}},[["__scopeId","data-v-fe69264f"]]),NT={class:"ai-guidance-loader","data-test-id":"aiGuidance-loader-container"},LT={"data-test-id":"aiGuidance-loader-text"},PT={class:"aig-button","data-test-id":"aiGuidance-loader-button"},qT={class:"aig-input-box","data-test-id":"aiGuidance-loader-input"},$T=Me({__name:"AiGuidanceLoader",props:{errors:{type:Array,required:!1,default:()=>[]},chatBgColor:{type:String,required:!1,default:""}},setup(e){const n=e,t=ye(()=>`linear-gradient(180deg, ${n.chatBgColor} 0%, transparent 100%)`);return(r,o)=>(B(),U(ke,null,[C("div",{class:"chat-gradient",style:Ae({background:t.value})},null,4),C("div",NT,[C("div",LT,[pe(Pi,{style:{width:"100%",height:"16px","margin-bottom":"8px"}}),pe(Pi,{style:{width:"100%",height:"16px","margin-bottom":"32px","max-width":"481px"}})]),C("div",PT,[pe(Pi,{style:{width:"100%",height:"24px"}})]),(B(!0),U(ke,null,Fe(e.errors,i=>(B(),U("div",{key:i,class:"aig-message-error","data-test-id":"aiGuidance-loader-error"},be(i),1))),128)),C("div",qT,[pe(Pi,{style:{height:"36px",width:"100%"}})])])],64))}},[["__scopeId","data-v-5e4a9913"]]),UT={class:"ai-guidance-wrapper","data-test-id":"aiGuidance-wrapper"},jT=Me({__name:"aiGuidance",props:{templateId:{type:String,required:!1},playbookData:{type:Object,required:!1},composablesOrgType:{type:String,required:!0},identity:{type:Object,required:!1,default:()=>({})},session:{type:Object,required:!1,default:()=>({})},security:{type:Object,required:!1,default:()=>({})},functions:{type:Object,required:!1,default:()=>({})},websocketUrl:{type:String,required:!0},packageVersion:{type:String,required:!0},hostName:{type:String,required:!1},graphqlEndpoint:{type:String,required:!1},apiKey:{type:String,required:!1},isPreview:{type:Boolean,required:!1,default:!1},catalogSections:{type:Array,required:!1,default:()=>[]},cartSections:{type:String,required:!1,default:""},theme:{type:Object,required:!1,default:()=>({})},styles:{type:Object,required:!1,default:()=>({height:"100vh"}),validator:e=>typeof(e==null?void 0:e.height)=="string"},resources:{type:Object,required:!1,default:()=>({})}},emits:["expeditecart-item-configure","expeditecart-clicked","component-action","ai-response:success","quote-id:updated","ai-guidance:error"],setup(e,{emit:n}){const t=Vo(),r=qt(),o=_o(),i=Ti(),a=n,s=X(!0),l=X(!1),u=X(!0),c=X(!0),h=X(!1),d=X([]),{emitError:p,emitErrors:f}=nh(a,"aiGuidance"),v=e,{composablesOrgType:m,websocketUrl:_,packageVersion:g,identity:y,session:b,security:x,functions:A,templateId:E,hostName:S,graphqlEndpoint:M,apiKey:I,isPreview:k,catalogSections:w,cartSections:T,theme:q}=v,K=ye(()=>{var D,L,V;return{...v.session||{},quoteId:((D=v.session)==null?void 0:D.quoteId)||(((L=r.quoteId)==null?void 0:L.value)??""),eCatalogId:(V=r.eCatalogId)==null?void 0:V.value}});Zt(async()=>{var D;console.log("security",x),console.log("apiKey",I),r.updateConfig({userId:y==null?void 0:y.userId,organizationId:y==null?void 0:y.organizationId,accessToken:x==null?void 0:x.accessToken,composablesApiUrl:x==null?void 0:x.baseUrl,composablesOrgType:m,websocketUrl:_,quoteId:b==null?void 0:b.quoteId,packageVersion:g,accountId:y==null?void 0:y.accountId,templateId:E,hostName:S,graphqlEndpoint:M,apiKey:(x==null?void 0:x.apiKey)||I,cid:y==null?void 0:y.contactId,isPreview:k,siteUrl:(D=v.resources)==null?void 0:D.siteUrl})}),bt(async()=>{var j,Z,Y,ue;const D=c8(v,y,x);f(D);const L=p2(_);if(L&&p(L),D.length>0||L){s.value=!1;return}t.setSecretKey(x==null?void 0:x.accessToken);let V=null,N,G;try{V=await t.getPlaybookInfoFromQuote(),N=(V==null?void 0:V.XX_ORD1__Completed_PB_Step_Number_EX__c)??void 0,G=(V==null?void 0:V.XX_ORD1__Playbook_Current_Step_Meta_EX__c)??void 0}catch(fe){console.error("[aiGuidance] Failed to get playbook info from quote:",fe),p("AI_GUIDANCE_PLAYBOOK_INFO_FETCH_FAILED",{error:fe.message})}if(G)try{G=JSON.parse(G)}catch(fe){console.error("[aiGuidance] Failed to parse currentStepMetaServer:",fe),p("AI_GUIDANCE_JSON_PARSE_ERROR",{error:fe.message,data:"currentStepMetaServer"}),G=void 0}if(console.info("sequenceNumberServer = ",N),v.templateId){s.value=!0;try{const H=await t.getCatalogInContext();console.log("catalogInContext = ",H),H&&r.updateConfig({eCatalogId:H})}catch(H){console.error("[aiGuidance] Failed to get catalog in context:",H),p("AI_GUIDANCE_CATALOG_FETCH_FAILED",{error:H.message})}let fe=null;try{await i.fetchBlockInformationREST({templateId:v.templateId});const H=d8(i.pageBlocks);fe=H.playbookId,H.error&&p(H.error,{error:"Block structure validation failed"}),fe||p("AI_GUIDANCE_BLOCK_PLAYBOOK_ID_MISSING",{pageBlocks:i.pageBlocks})}catch(H){console.error("[aiGuidance] Failed to fetch block information:",H),p("AI_GUIDANCE_BLOCK_FETCH_FAILED",{error:H.message})}if(console.log("playbookID",fe),fe?l.value=!0:d.value.push("No playbook ID found in template"),t.setEmbeddedMode(!0),fe)try{t.currentPlaybook=fe,await t.getPlaybookByKey(fe),t.showPlaybookSteps=!0}catch(H){console.error("[aiGuidance] Failed to get playbook by key:",H),p("AI_GUIDANCE_PLAYBOOK_FETCH_FAILED",{error:H.message,playbookID:fe})}t.playbookStepsMode="full",o.setInitialPayload();try{await o.connectSocket()}catch(H){console.error("[aiGuidance] Failed to connect socket:",H),p("WEBSOCKET_CONNECTION_FAILED",{error:H.message})}if(N!==void 0){t.navigateToStep({stepName:(Z=(j=t.currentPlaybook)==null?void 0:j.playBookSteps[Number(N)])==null?void 0:Z.stepName,data:G}),s.value=!1;return}(ue=(Y=t.currentPlaybook)==null?void 0:Y.playBookSteps)!=null&&ue.length&&t.setCurrentStepName(t.currentPlaybook.playBookSteps[0].stepName),s.value=!1}else d.value.push("templateId is required")});const $=ye(()=>{var V;const D=((V=t.currentPlaybook)==null?void 0:V.playBookSteps)||[],L=t.currentStepName;return D.find(N=>N.stepName===L)||D[0]||null}),ne=ye(()=>{var D;return((D=$.value)==null?void 0:D.stepComponent)||null});Ke(()=>t.activeComponentKey,D=>{D&&(u.value=!1)});const le=[];bt(()=>{le.push(An("expeditecart:configure-clicked",D=>{a("expeditecart-item-configure",D)})),le.push(An("expeditecart:clicked",D=>{a("expeditecart-clicked",D)})),le.push(An("ai-response:success",D=>{try{a("ai-response:success",D)}catch{}})),le.push(An("quote-id:updated",D=>{try{a("quote-id:updated",D)}catch(L){console.info("[aiGuidance] Error emitting quote-id:updated event:",L)}})),le.push(An("websocket:error",D=>{try{D!=null&&D.isInitialization&&p(D.errorCode||"WEBSOCKET_CONNECTION_FAILED",D)}catch(L){console.info("[aiGuidance] Error handling websocket error event:",L)}}))});const oe=D=>{console.log("[aiGuidance] Received error from aiComponentLoader:",D),a("ai-guidance:error",D)},P=D=>{console.log("onExpediteCartClicked",D),a("component-action",{component:"cart",details:D})},O=(D,L)=>{var N;a("component-action",{component:"catalog",action:D,details:L});const V=(L==null?void 0:L.quoteId)??((N=L==null?void 0:L.response)==null?void 0:N.quoteId);if(V&&(D==="item-added"||D==="items-fetched"))try{a("quote-id:updated",{quoteId:V})}catch(G){console.info("[aiGuidance] Error emitting quote-id:updated from catalog event:",G)}},R=(D,L)=>{a("component-action",{component:"configurator",action:D,details:L})};return er(()=>{try{o.cancelRequest()}catch{}try{o.disconnectSocket()}catch{}try{o.resetState()}catch{}try{t.setEmbeddedMode(!1),t.currentPlaybook=null,t.currentStepName=null,t.activeComponentKey=null,t.activeComponentData=null,t.showPlaybookSteps=!1,t.playbookStepsMode="full"}catch{}s.value=!1,l.value=!1,u.value=!0,c.value=!0,h.value=!1,d.value=[],le.forEach(D=>{try{D()}catch{}})}),(D,L)=>{var V;return B(),U("div",UT,[pe(oc,{icon:"logo",color:"#000000",size:"18.75",height:"16.25"}),s.value||Ie(o).isFetchingHistory?(B(),Ce($T,{key:0,errors:d.value,"data-test-id":"aiGuidance-loader"},null,8,["errors"])):(B(),U("div",{key:1,class:we(["ai-app",{"root-path":u.value,"playbook-steps-mode-full":Ie(t).playbookStepsMode==="full","dxp-guiddance":l.value}]),style:Ae(e.styles)},[C("div",{class:"ai-app-chat-wrapper",style:Ae({height:e.styles.height})},[pe(_T,{"data-test-id":"chat-screen","is-external-guidance":l.value,styles:e.styles},null,8,["is-external-guidance","styles"])],4),!u.value&&c.value&&!h.value?(B(),U("div",{key:0,class:"component-loader-wrapper",style:Ae({height:e.styles.height,maxHeight:e.styles.height})},[Ie(t).currentPlaybook?(B(),Ce(FT,{key:0,"template-id":((V=$.value)==null?void 0:V.templateId)||Ie(E),"step-component":ne.value,identity:Ie(y),session:K.value,security:Ie(x),functions:Ie(A),"composables-org-type":Ie(m),"package-version":Ie(g),"host-name":Ie(S),"graphql-endpoint":Ie(M),"api-key":Ie(I),"is-preview":Ie(k),sections:Ie(w),"cart-sections":Ie(T),theme:Ie(q),"data-test-id":"aiComponentLoader-mounted",onExpeditecartClicked:P,onCatalogQuoteCreated:L[0]||(L[0]=N=>O("quote-created",N)),onCatalogQuoteUpdated:L[1]||(L[1]=N=>O("quote-updated",N)),onCatalogItemsLoaded:L[2]||(L[2]=N=>O("items-loaded",N)),onCatalogItemAdded:L[3]||(L[3]=N=>O("item-added",N)),onCatalogItemQtyUpdated:L[4]||(L[4]=N=>O("item-qty-updated",N)),onCatalogLineDeleted:L[5]||(L[5]=N=>O("line-deleted",N)),onCatalogItemsFetched:L[6]||(L[6]=N=>O("items-fetched",N)),onCatalogItemConfigure:L[7]||(L[7]=N=>O("item-configure",N)),"onConfigurator:addToQuote":L[8]||(L[8]=N=>R("add-to-quote",N)),"onConfigurator:save":L[9]||(L[9]=N=>R("save",N)),"onAiGuidance:error":oe},null,8,["template-id","step-component","identity","session","security","functions","composables-org-type","package-version","host-name","graphql-endpoint","api-key","is-preview","sections","cart-sections","theme"])):me("",!0)],4)):me("",!0)],6))])}}},[["__scopeId","data-v-920099b8"]]);let Ns=null;if(typeof window<"u"){try{Ns=Y6()}catch{}Ns||(Ns=e3(),Ei(Ns))}let Ls=null,Ps=null;const Vc=new Set;let Eo=null;const zc=new Map;async function HT(e){if(!e)return"";if(zc.has(e))return zc.get(e);try{const n=await fetch(e,{credentials:"omit",cache:"no-cache"});if(n.ok){const t=await n.text();return zc.set(e,t),t}}catch(n){console.warn("[ExpediteComponents] Failed to fetch theme CSS:",n)}return""}async function Gc(e,n){if(!e||!n)return;const t=e.querySelector("style[data-vue-expedite-theme]");t&&t.remove();try{const r=await HT(n);if(r){const o=document.createElement("style");o.setAttribute("data-vue-expedite-theme","true"),o.textContent=r,e.prepend(o)}}catch(r){console.warn("[ExpediteComponents] Failed to inject theme CSS:",r)}}function Kc(e){Eo=e||null,Eo&&Vc.forEach(n=>{n&&n.shadowRoot&&Gc(n.shadowRoot,Eo)})}async function VT(){return Ls||Ps||(Ps=(async()=>{try{const e=new URL("./style.css",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Or&&Or.src||new URL("vue-expedite-components.umd.cjs",document.baseURI).href).href,n=await fetch(e);if(n.ok)return Ls=await n.text(),Ls}catch(e){console.warn("[ExpediteComponents] Failed to load CSS:",e)}return null})(),Ps)}const Yi=e=>class extends e{async connectedCallback(){if(super.connectedCallback&&super.connectedCallback(),Vc.add(this),!!this.shadowRoot){if(this.shadowRoot.querySelector("style[data-vue-expedite-style]")){Eo&&Gc(this.shadowRoot,Eo);return}try{const n=await VT();if(n){const t=document.createElement("style");t.setAttribute("data-vue-expedite-style","true"),t.textContent=n,this.shadowRoot.prepend(t)}else{const t=new URL("./style.css",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Or&&Or.src||new URL("vue-expedite-components.umd.cjs",document.baseURI).href).href,r=document.createElement("link");r.setAttribute("rel","stylesheet"),r.setAttribute("data-vue-expedite-style","true"),r.href=t,this.shadowRoot.prepend(r)}Eo&&Gc(this.shadowRoot,Eo)}catch(n){console.warn("[ExpediteComponents] Failed to inject CSS:",n)}}}disconnectedCallback(){Vc.delete(this),super.disconnectedCallback&&super.disconnectedCallback()}},cp=Yi(Ci(L2)),dp=Yi(Ci(kx)),fp=Yi(Ci(eh)),hp=Yi(Ci(th)),pp=Yi(Ci(jT));function Xc(){typeof window<"u"&&(customElements.get("vue-expedite-configurator")||customElements.define("vue-expedite-configurator",cp),customElements.get("vue-expedite-gpt")||customElements.define("vue-expedite-gpt",dp),customElements.get("vue-expedite-catalog")||customElements.define("vue-expedite-catalog",fp),customElements.get("vue-expedite-cart")||customElements.define("vue-expedite-cart",hp),customElements.get("vue-expedite-ai-guidance")||customElements.define("vue-expedite-ai-guidance",pp))}typeof window<"u"&&Xc();const zT={register:Xc,applyThemeToShadows:Kc};typeof window<"u"&&(window.VueExpediteComponents=Object.assign(window.VueExpediteComponents||{},{applyThemeToShadows:Kc})),_n.ExpediteAIGuidanceElement=pp,_n.ExpediteCartElement=hp,_n.ExpediteCatalogElement=fp,_n.ExpediteConfiguratorElement=cp,_n.ExpediteGPTElement=dp,_n.applyThemeToShadows=Kc,_n.default=zT,_n.registerWebComponents=Xc,Object.defineProperties(_n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/package.json
CHANGED