@askdialog/dialog-vue 3.3.0 → 3.4.1

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.
@@ -1,4 +1,4 @@
1
- (function(g,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(g=typeof globalThis<"u"?globalThis:g||self,e(g["dialog-vue"]={},g.Vue))})(this,(function(g,e){"use strict";var _t=Object.defineProperty;var mt=(g,e,R)=>e in g?_t(g,e,{enumerable:!0,configurable:!0,writable:!0,value:R}):g[e]=R;var D=(g,e,R)=>mt(g,typeof e!="symbol"?e+"":e,R);const R=new Set(["ar","he","iw","fa","ur"]),K=o=>o!==void 0&&R.has(o.trim().toLowerCase().slice(0,2)),F=o=>K(o)?"rtl":"ltr";var N;(function(o){o.OPEN_ASSISTANT="open_assistant",o.CLOSE_ASSISTANT="close_assistant",o.SEND_MESSAGE="PRODUCT_QUESTION",o.SEND_GENERIC_QUESTION="GENERIC_QUESTION",o.TRACK_ADD_TO_CART="TRACK_ADD_TO_CART",o.TRACK_SUBMIT_CHECKOUT="TRACK_SUBMIT_CHECKOUT",o.TRACK_VIEW_SEARCH_RESULTS="TRACK_VIEW_SEARCH_RESULTS",o.TRACK_SELECT_SEARCH_RESULT="TRACK_SELECT_SEARCH_RESULT"})(N||(N={}));var A;(function(o){o.USER_OPENED_ASSISTANT="userOpenedAssistant",o.USER_CLOSED_ASSISTANT="userClosedAssistant",o.USER_SENT_MESSAGE="userSentMessage",o.USER_CLICKED_ON_PRODUCT_CARD="userClickedOnProductCard",o.USER_OPENED_RECOMMENDATION="userOpenedRecommendation",o.USER_ADDED_TO_CART="userAddedToCart",o.USER_SEND_POSITIVE_FEEDBACK="userSendPositiveFeedback",o.USER_SEND_NEGATIVE_FEEDBACK="userSendNegativeFeedback"})(A||(A={})),N.TRACK_ADD_TO_CART,N.TRACK_SUBMIT_CHECKOUT,N.TRACK_VIEW_SEARCH_RESULTS,N.TRACK_SELECT_SEARCH_RESULT;class G extends Error{constructor({status:n,code:s,message:i}){super(i);D(this,"status");D(this,"code");this.name="DialogSearchError",this.status=n,this.code=s}}const L="multiple installation methods detected:",j=()=>typeof window>"u"?void 0:window,V=()=>{const o=j();if(o!==void 0)return o.dialog=o.dialog??{},o.dialog.audit=o.dialog.audit??{methods:[],context:{},capabilities:[],warnings:[]},o.dialog.audit},Q=o=>{if(o.warnings=o.warnings.filter(t=>!t.startsWith(L)),o.methods.length>=2){const t=o.methods.map(n=>n.method).join(", ");o.warnings.push(`${L} ${t}`)}},W=(o,t)=>t===void 0?o:{version:(o==null?void 0:o.version)??t.version,commit:(o==null?void 0:o.commit)??t.commit},$=o=>{const t=V();if(t===void 0)return;const n=t.methods.find(s=>s.method===o.method);if(n===void 0){t.methods.push({...o,registeredAt:new Date().toISOString()}),Q(t);return}n.version=n.version??o.version,n.build=W(n.build,o.build),n.source=n.source??o.source},Y=o=>{const t=V();t!==void 0&&(t.capabilities.includes(o)||t.capabilities.push(o))},b={IDLE:"idle",LOADING:"loading",SUCCESS:"success",EMPTY:"empty",ERROR:"error"},z=.5,X=500,v=1500,Z=100;function J({emit:o,visibilityThreshold:t=z,dwellMs:n=X,idleFlushMs:s=v,maxItemsPerEvent:i=Z}){let r,c=[];const a=new Set,h=new Map,_=new Map;let u;const m=()=>{clearTimeout(u),!(r===void 0||c.length===0)&&(o({...r,items:c}),c=[])},f=l=>{if(r===void 0)return;const d=`${r.query_id}:${l.product_id}`;if(!a.has(d)){if(a.add(d),c.push(l),c.length>=i){m();return}clearTimeout(u),u=setTimeout(m,s)}},S=l=>{const d=_.get(l);d!==void 0&&(clearTimeout(d),_.delete(l))},p=new IntersectionObserver(l=>{for(const d of l){const C=h.get(d.target);C!==void 0&&(d.intersectionRatio>=t?_.has(d.target)||_.set(d.target,setTimeout(()=>{_.delete(d.target),f(C)},n)):S(d.target))}},{threshold:t}),k=()=>{p.disconnect();for(const l of _.values())clearTimeout(l);_.clear(),h.clear()},E=()=>{m()},y=l=>{if(l.persisted){a.clear();for(const d of h.keys())S(d),p.unobserve(d),p.observe(d)}};return window.addEventListener("pagehide",E),window.addEventListener("pageshow",y),{setContext(l){m(),r!==void 0&&r.query_id!==l.query_id&&a.clear(),r=l,k()},observe(l,d){h.set(l,d),p.observe(l)},forceImpression(l){f(l),m()},flush:m,disconnect(){m(),k(),window.removeEventListener("pagehide",E),window.removeEventListener("pageshow",y)}}}const P=(o,t)=>({product_id:o.hits[t].product.id,position:o.page*o.hitsPerPage+t+1});function ee(o){let t,n;const s=()=>(t??(t=J({emit:o.trackViewSearchResults})),t);return{onResponse(i){n={query_id:i.queryId,surface:o.surface,page:i.page+1,total_hits:i.nbHits,query_length:[...i.query].length},s().setContext(n),i.nbHits===0&&o.trackViewSearchResults({...n,items:[]})},observeResult(i,r,c){s().observe(i,P(r,c))},select(i,r){if(n===void 0)return;const c=P(i,r);s().forceImpression(c),o.trackSelectSearchResult({...n,items:[c]})},dispose(){t==null||t.disconnect()}}}const te=250,oe=12,ne=2,O={status:b.IDLE,query:"",page:0,response:void 0,error:void 0};function re({search:o,analytics:t,navigate:n,debounceMs:s=te,hitsPerPage:i=oe}){let r=O;const c=new Set,a=ee(t);let h,_,u,m=0,f=!1;const S=l=>{r={...r,...l};for(const d of c)d(r)},p=()=>{clearTimeout(h),u==null||u.abort(),u=void 0},k=(l,d)=>{const C={query:l,page:d,hitsPerPage:i},T=r.response;return(T==null?void 0:T.query)===l&&(C.queryId=T.queryId),C},E=async(l,d)=>{p(),u=new AbortController;const C=++m,T=k(l,d);S({status:b.LOADING,query:l,page:d});try{const w=await o(T,{signal:u.signal});if(C!==m)return;a.onResponse(w),S({status:w.nbHits===0?b.EMPTY:b.SUCCESS,response:w,error:void 0})}catch(w){if(w instanceof DOMException&&w.name==="AbortError"||C!==m)return;S({status:b.ERROR,error:w,response:void 0})}},y=l=>{const d=l.trim();if(p(),_=void 0,[...d].length<ne){m+=1,S(O);return}return d};return{setQuery(l){const d=f?void 0:y(l);d!==void 0&&(_=d,h=setTimeout(()=>{_=void 0,E(d,0)},s))},submit(l){const d=f?void 0:y(l);d!==void 0&&E(d,0)},setPage(l){if(!f){if(_!==void 0){const d=_;_=void 0,E(d,0);return}r.query!==""&&E(r.query,l)}},retry(){f||r.status!==b.ERROR||E(r.query,r.page)},observeResult(l,d){r.response!==void 0&&a.observeResult(l,r.response,d)},selectResult(l,d){const C=r.response;if(C===void 0)return!1;a.select(C,l);const T=C.hits[l].product.url;return((d==null?void 0:d.navigate)??!0)&&n!==void 0&&T!==void 0?(n(T,C.hits[l]),!0):!1},subscribe(l){return c.add(l),()=>{c.delete(l)}},getState:()=>r,dispose(){f=!0,p(),m+=1,_=void 0,c.clear(),a.dispose()}}}const se={class:"dialog-block-header-container"},ce={class:"dialog-block-title"},ie={class:"dialog-block-description"},ae=e.defineComponent({__name:"DialogBlockHeader",props:{title:{},description:{}},setup(o){const t=o;return(n,s)=>(e.openBlock(),e.createElementBlock("div",se,[e.createElementVNode("div",ce,e.toDisplayString(t.title??"Your expert"),1),e.createElementVNode("div",ie,e.toDisplayString(t.description??"A question about this product?"),1)]))}}),I=(o,t)=>{const n=o.__vccOpts||o;for(const[s,i]of t)n[s]=i;return n},le=I(ae,[["__scopeId","data-v-28e6dda7"]]),de={width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},ue={"clip-path":"url(#clip0_466_934)"},pe=["stroke"],_e=["stroke"],me=e.defineComponent({__name:"AiStarsIcon",props:{color:{}},setup(o){const t=o;return(n,s)=>(e.openBlock(),e.createElementBlock("svg",de,[e.createElementVNode("g",ue,[e.createElementVNode("path",{d:`M5.41675 10.8333L6.07046 12.1408C6.2917 12.5832 6.40232 12.8045 6.55011
1
+ (function(S,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(S=typeof globalThis<"u"?globalThis:S||self,e(S["dialog-vue"]={},S.Vue))})(this,(function(S,e){"use strict";var St=Object.defineProperty;var kt=(S,e,B)=>e in S?St(S,e,{enumerable:!0,configurable:!0,writable:!0,value:B}):S[e]=B;var V=(S,e,B)=>kt(S,typeof e!="symbol"?e+"":e,B);const B=new Set(["ar","he","iw","fa","ur"]),Q=o=>o!==void 0&&B.has(o.trim().toLowerCase().slice(0,2)),W=o=>Q(o)?"rtl":"ltr";var D;(function(o){o.OPEN_ASSISTANT="open_assistant",o.CLOSE_ASSISTANT="close_assistant",o.SEND_MESSAGE="PRODUCT_QUESTION",o.SEND_GENERIC_QUESTION="GENERIC_QUESTION",o.TRACK_ADD_TO_CART="TRACK_ADD_TO_CART",o.TRACK_SUBMIT_CHECKOUT="TRACK_SUBMIT_CHECKOUT",o.TRACK_VIEW_SEARCH_RESULTS="TRACK_VIEW_SEARCH_RESULTS",o.TRACK_SELECT_SEARCH_RESULT="TRACK_SELECT_SEARCH_RESULT"})(D||(D={}));var $;(function(o){o.USER_OPENED_ASSISTANT="userOpenedAssistant",o.USER_CLOSED_ASSISTANT="userClosedAssistant",o.USER_SENT_MESSAGE="userSentMessage",o.USER_CLICKED_ON_PRODUCT_CARD="userClickedOnProductCard",o.USER_OPENED_RECOMMENDATION="userOpenedRecommendation",o.USER_ADDED_TO_CART="userAddedToCart",o.USER_SEND_POSITIVE_FEEDBACK="userSendPositiveFeedback",o.USER_SEND_NEGATIVE_FEEDBACK="userSendNegativeFeedback"})($||($={})),D.TRACK_ADD_TO_CART,D.TRACK_SUBMIT_CHECKOUT,D.TRACK_VIEW_SEARCH_RESULTS,D.TRACK_SELECT_SEARCH_RESULT;class Y extends Error{constructor({status:n,code:r,message:i}){super(i);V(this,"status");V(this,"code");this.name="DialogSearchError",this.status=n,this.code=r}}const P="multiple installation methods detected:",z=()=>typeof window>"u"?void 0:window,O=()=>{const o=z();if(o!==void 0)return o.dialog=o.dialog??{},o.dialog.audit=o.dialog.audit??{methods:[],context:{},capabilities:[],warnings:[]},o.dialog.audit},X=o=>{if(o.warnings=o.warnings.filter(t=>!t.startsWith(P)),o.methods.length>=2){const t=o.methods.map(n=>n.method).join(", ");o.warnings.push(`${P} ${t}`)}},Z=(o,t)=>t===void 0?o:{version:(o==null?void 0:o.version)??t.version,commit:(o==null?void 0:o.commit)??t.commit},U=o=>{const t=O();if(t===void 0)return;const n=t.methods.find(r=>r.method===o.method);if(n===void 0){t.methods.push({...o,registeredAt:new Date().toISOString()}),X(t);return}n.version=n.version??o.version,n.build=Z(n.build,o.build),n.source=n.source??o.source},v=o=>{const t=O();t!==void 0&&(t.capabilities.includes(o)||t.capabilities.push(o))},y={IDLE:"idle",LOADING:"loading",SUCCESS:"success",EMPTY:"empty",ERROR:"error"},J=.5,ee=500,te=1500,oe=100;function ne({emit:o,visibilityThreshold:t=J,dwellMs:n=ee,idleFlushMs:r=te,maxItemsPerEvent:i=oe}){let c,a=[];const s=new Set,p=new Map,_=new Map;let d;const u=()=>{clearTimeout(d),!(c===void 0||a.length===0)&&(o({...c,items:a}),a=[])},g=m=>{if(c===void 0)return;const E=`${c.query_id}:${m.product_id}`;if(!s.has(E)){if(s.add(E),a.push(m),a.length>=i){u();return}clearTimeout(d),d=setTimeout(u,r)}},C=m=>{const E=_.get(m);E!==void 0&&(clearTimeout(E),_.delete(m))},l=new IntersectionObserver(m=>{for(const E of m){const h=p.get(E.target);h!==void 0&&(E.intersectionRatio>=t?_.has(E.target)||_.set(E.target,setTimeout(()=>{_.delete(E.target),g(h)},n)):C(E.target))}},{threshold:t}),k=()=>{l.disconnect();for(const m of _.values())clearTimeout(m);_.clear(),p.clear()},b=()=>{u()},w=m=>{if(m.persisted){s.clear();for(const E of p.keys())C(E),l.unobserve(E),l.observe(E)}};return window.addEventListener("pagehide",b),window.addEventListener("pageshow",w),{setContext(m){u(),c!==void 0&&c.query_id!==m.query_id&&s.clear(),c=m,k()},observe(m,E){p.set(m,E),l.observe(m)},forceImpression(m){g(m),u()},flush:u,disconnect(){u(),k(),window.removeEventListener("pagehide",b),window.removeEventListener("pageshow",w)}}}const M=(o,t)=>({product_id:o.hits[t].product.id,position:o.page*o.hitsPerPage+t+1});function re(o){let t,n;const r=()=>(t??(t=ne({emit:o.trackViewSearchResults})),t);return{onResponse(i){n={query_id:i.queryId,surface:o.surface,search_type:"lexical",page:i.page+1,total_hits:i.nbHits,query_length:[...i.query].length},r().setContext(n),i.nbHits===0&&o.trackViewSearchResults({...n,items:[]})},observeResult(i,c,a){r().observe(i,M(c,a))},select(i,c){if(n===void 0)return;const a=M(i,c);r().forceImpression(a),o.trackSelectSearchResult({...n,items:[a]})},dispose(){t==null||t.disconnect()}}}const se=250,ce=12,ae=2,q={status:y.IDLE,query:"",page:0,response:void 0,error:void 0};function ie({search:o,analytics:t,navigate:n,debounceMs:r=se,hitsPerPage:i=ce,locale:c,countryCode:a}){let s=q;const p=new Set,_=re(t);let d,u,g,C=0,l=!1;const k=h=>{s={...s,...h};for(const f of p)f(s)},b=()=>{clearTimeout(d),g==null||g.abort(),g=void 0},w=(h,f)=>{const T={query:h,page:f,hitsPerPage:i};c!==void 0&&(T.locale=c),a!==void 0&&(T.countryCode=a);const R=s.response;return(R==null?void 0:R.query)===h&&(T.queryId=R.queryId),T},m=async(h,f)=>{b(),g=new AbortController;const T=++C,R=w(h,f);k({status:y.LOADING,query:h,page:f});try{const I=await o(R,{signal:g.signal});if(T!==C)return;_.onResponse(I),k({status:I.nbHits===0?y.EMPTY:y.SUCCESS,response:I,error:void 0})}catch(I){if(I instanceof DOMException&&I.name==="AbortError"||T!==C)return;k({status:y.ERROR,error:I,response:void 0})}},E=h=>{const f=h.trim();if(b(),u=void 0,[...f].length<ae){C+=1,k(q);return}return f};return{setQuery(h){const f=l?void 0:E(h);f!==void 0&&(u=f,d=setTimeout(()=>{u=void 0,m(f,0)},r))},submit(h){const f=l?void 0:E(h);f!==void 0&&m(f,0)},setPage(h){if(!l){if(u!==void 0){const f=u;u=void 0,m(f,0);return}s.query!==""&&m(s.query,h)}},retry(){l||s.status!==y.ERROR||m(s.query,s.page)},observeResult(h,f){s.response!==void 0&&_.observeResult(h,s.response,f)},selectResult(h,f){const T=s.response;if(T===void 0)return!1;_.select(T,h);const R=T.hits[h].product.url;return((f==null?void 0:f.navigate)??!0)&&n!==void 0&&R!==void 0?(n(R,T.hits[h]),!0):!1},subscribe(h){return p.add(h),()=>{p.delete(h)}},getState:()=>s,dispose(){l=!0,b(),C+=1,u=void 0,p.clear(),_.dispose()}}}const le={class:"dialog-block-header-container"},de={class:"dialog-block-title"},ue={class:"dialog-block-description"},pe=e.defineComponent({__name:"DialogBlockHeader",props:{title:{},description:{}},setup(o){const t=o;return(n,r)=>(e.openBlock(),e.createElementBlock("div",le,[e.createElementVNode("div",de,e.toDisplayString(t.title??"Your expert"),1),e.createElementVNode("div",ue,e.toDisplayString(t.description??"A question about this product?"),1)]))}}),N=(o,t)=>{const n=o.__vccOpts||o;for(const[r,i]of t)n[r]=i;return n},me=N(pe,[["__scopeId","data-v-28e6dda7"]]),_e={width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},he={"clip-path":"url(#clip0_466_934)"},fe=["stroke"],ge=["stroke"],Ee=e.defineComponent({__name:"AiStarsIcon",props:{color:{}},setup(o){const t=o;return(n,r)=>(e.openBlock(),e.createElementBlock("svg",_e,[e.createElementVNode("g",he,[e.createElementVNode("path",{d:`M5.41675 10.8333L6.07046 12.1408C6.2917 12.5832 6.40232 12.8045 6.55011
2
2
  12.9962C6.68124 13.1663 6.83375 13.3188 7.00388 13.45C7.19559 13.5977 7.41684
3
3
  13.7084 7.85932 13.9296L9.16675 14.5833L7.85932 15.237C7.41684 15.4583 7.19559
4
4
  15.5689 7.00388 15.7167C6.83375 15.8478 6.68124 16.0003 6.55011 16.1704C6.40232
@@ -7,7 +7,7 @@
7
7
  15.7167C3.6379 15.5689 3.41666 15.4583 2.97418 15.237L1.66675 14.5833L2.97418
8
8
  13.9296C3.41666 13.7084 3.6379 13.5977 3.82962 13.45C3.99974 13.3188 4.15225
9
9
  13.1663 4.28339 12.9962C4.43117 12.8045 4.54179 12.5832 4.76303 12.1408L5.41675
10
- 10.8333Z`,stroke:t.color||"#181825","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,8,pe),e.createElementVNode("path",{d:`M12.5001 1.66666L13.4823 4.22034C13.7173 4.83136 13.8348 5.13688 14.0175
10
+ 10.8333Z`,stroke:t.color||"#181825","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,8,fe),e.createElementVNode("path",{d:`M12.5001 1.66666L13.4823 4.22034C13.7173 4.83136 13.8348 5.13688 14.0175
11
11
  5.39386C14.1795 5.62162 14.3785 5.82061 14.6062 5.98256C14.8632 6.16529 15.1687
12
12
  6.2828 15.7797 6.5178L18.3334 7.49999L15.7797 8.48217C15.1687 8.71718 14.8632
13
13
  8.83469 14.6062 9.01742C14.3785 9.17937 14.1795 9.37836 14.0175 9.60612C13.8348
@@ -16,4 +16,4 @@
16
16
  9.01742C10.137 8.83469 9.83145 8.71718 9.22043 8.48217L6.66675 7.49999L9.22043
17
17
  6.5178C9.83145 6.28279 10.137 6.16529 10.3939 5.98256C10.6217 5.82061 10.8207
18
18
  5.62162 10.9827 5.39386C11.1654 5.13688 11.2829 4.83136 11.5179 4.22034L12.5001
19
- 1.66666Z`,stroke:t.color||"#181825","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,8,_e)]),s[0]||(s[0]=e.createElementVNode("defs",null,[e.createElementVNode("clipPath",{id:"clip0_466_934"},[e.createElementVNode("rect",{width:"20",height:"20",fill:"white"})])],-1))]))}}),he=["onClick"],fe={class:"dialog-block-suggestions-item-label"},ge=I(e.defineComponent({__name:"DialogBlockSuggestions",props:{client:{},questions:{},productId:{},productTitle:{},selectedVariantId:{}},setup(o){const t=o,n=s=>{t.client.sendProductMessage({productId:t.productId,productTitle:t.productTitle,selectedVariantId:t.selectedVariantId,question:s,fromQuestionSuggestion:!0})};return(s,i)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.questions,r=>(e.openBlock(),e.createElementBlock("button",{key:r.question,class:"dialog-block-suggestions-item",onClick:c=>n(r.question)},[e.createVNode(me,{class:"dialog-block-suggestions-item-icon",color:t.client.theme.primaryColor},null,8,["color"]),e.createElementVNode("span",fe,e.toDisplayString(r.question),1)],8,he))),128))}}),[["__scopeId","data-v-db34d4b4"]]),Ee={};function Se(o,t){return e.openBlock(),e.createElementBlock(e.Fragment,null,[t[0]||(t[0]=e.createElementVNode("div",{class:"dialog-block-suggestions-skeleton-item"},null,-1)),t[1]||(t[1]=e.createElementVNode("div",{class:"dialog-block-suggestions-skeleton-item"},null,-1)),t[2]||(t[2]=e.createElementVNode("div",{class:"dialog-block-suggestions-skeleton-item"},null,-1))],64)}const ke=I(Ee,[["render",Se],["__scopeId","data-v-26a64b58"]]),Ce={class:"dialog-block-suggestions-container"},be=I(e.defineComponent({__name:"DialogBlockSuggestionsContainer",props:{client:{},questions:{},isLoading:{type:Boolean},productId:{},productTitle:{},selectedVariantId:{}},setup(o){const t=o;return(n,s)=>(e.openBlock(),e.createElementBlock("div",Ce,[t.isLoading||!t.questions?(e.openBlock(),e.createBlock(ke,{key:0})):(e.openBlock(),e.createBlock(ge,{key:1,client:t.client,questions:t.questions,"product-id":t.productId,"product-title":t.productTitle,"selected-variant-id":t.selectedVariantId},null,8,["client","questions","product-id","product-title","selected-variant-id"]))]))}}),[["__scopeId","data-v-18c9e78b"]]),ye={width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Te=["stroke"],we=e.defineComponent({__name:"ArrowIcon",props:{color:{}},setup(o){const t=o;return(n,s)=>(e.openBlock(),e.createElementBlock("svg",ye,[e.createElementVNode("path",{d:"M10 16.6667V3.33334M10 3.33334L5 8.33334M10 3.33334L15 8.33334",stroke:t.color||"#ffffff","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,8,Te)]))}}),Ie=["placeholder"],Re=["disabled"],U=I(e.defineComponent({__name:"DialogInput",props:{client:{},placeholder:{},productId:{},productTitle:{},selectedVariantId:{}},setup(o){const t=o,n=e.ref(),s=e.ref(""),i=()=>{var c;(c=n.value)==null||c.focus()},r=()=>{const c=s.value;c.trim()&&(t.client.sendProductMessage({productId:t.productId,productTitle:t.productTitle,selectedVariantId:t.selectedVariantId,question:c,fromQuestionSuggestion:!0}),s.value="")};return(c,a)=>(e.openBlock(),e.createElementBlock("div",{class:"dialog-input-wrapper",onClick:i},[e.withDirectives(e.createElementVNode("input",{id:"dialog-ask-anything-input-ai-input",ref_key:"inputRef",ref:n,"onUpdate:modelValue":a[0]||(a[0]=h=>s.value=h),class:"dialog-ask-anything-input-ai-input",placeholder:t.placeholder??"Ask anything...",onKeydown:e.withKeys(r,["enter"])},null,40,Ie),[[e.vModelText,s.value]]),e.createElementVNode("button",{id:"send-message-button-ai-input",class:"dialog-input-submit",disabled:!s.value.trim(),onClick:r},[e.createVNode(we,{color:t.client.theme.ctaTextColor},null,8,["color"])],8,Re)]))}}),[["__scopeId","data-v-4f5901c9"]]),Ne=e.defineComponent({__name:"ThemeProvider",props:{theme:{}},setup(o){const t=o,n=document.body,s=r=>r.replace(/([A-Z])/g,"-$1").toLowerCase(),i=r=>{r&&Object.keys(r).forEach(c=>{const a=c,h=s(c);if(r[a]!==void 0){if(typeof r[a]=="object"){Object.keys(r[a]).forEach(_=>{var m;const u=_;if(u!==void 0){const f=s(_),S=r[a];n.style.setProperty(`--dialog-theme-${h}-${f}`,(m=S[u])==null?void 0:m.toString())}});return}if(a==="ctaBorderType"){const _=r[a]==="rounded"?"24px":"0";n.style.setProperty(`--dialog-theme-${h}`,_);return}n.style.setProperty(`--dialog-theme-${h}`,r[a].toString())}})};return e.onMounted(()=>{t.theme&&i(t.theme)}),e.watch(()=>t.theme,r=>{r&&i(r)},{deep:!0}),(r,c)=>e.renderSlot(r.$slots,"default")}}),Be=["dir"],De=I(e.defineComponent({__name:"DialogProductBlock",props:{client:{},productId:{},productTitle:{},selectedVariantId:{default:void 0},enableInput:{type:Boolean,default:!0}},setup(o){const t=o;e.onMounted(()=>{$({method:"vue",version:"3.3.0"}),Y("pdp-block")});const n=e.ref(!0),s=e.ref(void 0),i=e.ref(0),r=e.computed(()=>{var u;return n.value?"":(u=s.value)==null?void 0:u.assistantName}),c=e.computed(()=>{var u;return n.value?"":(u=s.value)==null?void 0:u.description}),a=e.computed(()=>{var u;return n.value?"":(u=s.value)==null?void 0:u.inputPlaceholder}),h=e.computed(()=>{var u;return F((u=t.client.getLocalizationInformations())==null?void 0:u.languageCode)}),_=async()=>{const u=++i.value;n.value=!0,s.value=void 0;try{const m=await t.client.getSuggestions(t.productId);u===i.value&&(s.value=m)}catch(m){console.error("error",m)}finally{u===i.value&&(n.value=!1)}};return e.watch(()=>[t.client,t.productId],()=>{_()},{immediate:!0}),(u,m)=>(e.openBlock(),e.createBlock(Ne,{theme:t.client.theme},{default:e.withCtx(()=>{var f;return[e.createElementVNode("div",{id:"dialog-instant",class:"dialog-block-container",dir:h.value},[e.createVNode(le,{title:r.value,description:c.value},null,8,["title","description"]),e.createVNode(be,{client:t.client,questions:(f=s.value)==null?void 0:f.questions,"is-loading":n.value,"product-id":t.productId,"product-title":t.productTitle,"selected-variant-id":t==null?void 0:t.selectedVariantId},null,8,["client","questions","is-loading","product-id","product-title","selected-variant-id"]),t.enableInput?(e.openBlock(),e.createBlock(U,{key:0,client:t.client,placeholder:a.value,"product-id":t.productId,"product-title":t.productTitle,"selected-variant-id":t==null?void 0:t.selectedVariantId},null,8,["client","placeholder","product-id","product-title","selected-variant-id"])):e.createCommentVNode("",!0)],8,Be)]}),_:1},8,["theme"]))}}),[["__scopeId","data-v-c57aa677"]]),Ae={},Le={width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true"};function Ve(o,t){return e.openBlock(),e.createElementBlock("svg",Le,t[0]||(t[0]=[e.createElementVNode("path",{d:"M8 13V3M8 3L3 8M8 3L13 8",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)]))}const $e=I(Ae,[["render",Ve]]),Pe={width:"16",height:"16",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true"},Oe=["fill"],Ue="M5.3217 0.588255C5.63241 -0.196084 6.36759 -0.196085 6.6783 0.588254C6.98901 1.37259 7.68193 2.82807 8.42693 3.57307C9.17193 4.31807 10.6274 5.01099 11.4117 5.3217C12.1961 5.63241 12.1961 6.36759 11.4117 6.6783C10.6274 6.98901 9.17193 7.68193 8.42693 8.42693C7.68193 9.17193 6.98901 10.6274 6.6783 11.4117C6.36759 12.1961 5.63241 12.1961 5.3217 11.4117C5.01099 10.6274 4.31807 9.17193 3.57307 8.42693C2.82808 7.68193 1.37259 6.98901 0.588255 6.6783C-0.196084 6.36759 -0.196085 5.63241 0.588254 5.3217C1.37259 5.01099 2.82807 4.31807 3.57307 3.57307C4.31807 2.82808 5.01099 1.37259 5.3217 0.588255Z",Me=e.defineComponent({__name:"ShurikenIcon",props:{color:{}},setup(o){const t=o;return(n,s)=>(e.openBlock(),e.createElementBlock("svg",Pe,[e.createElementVNode("path",{d:Ue,fill:t.color||"currentColor"},null,8,Oe)]))}}),qe={class:"dialog-search-bar-field"},xe={class:"dialog-search-bar-icon"},He=["aria-label","placeholder","autofocus"],Ke=["aria-label"],Fe=e.defineComponent({__name:"DialogSearchBar",props:{controller:{},placeholder:{default:"Search products..."},autoFocus:{type:Boolean,default:!1},submitAriaLabel:{default:"Search"}},setup(o){const t=o,n=e.ref(""),s=()=>{t.controller.setQuery(n.value)},i=()=>{t.controller.submit(n.value)};return(r,c)=>(e.openBlock(),e.createElementBlock("form",{class:"dialog-search-bar",role:"search",onSubmit:e.withModifiers(i,["prevent"])},[e.createElementVNode("div",qe,[e.createElementVNode("span",xe,[e.createVNode(Me)]),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":c[0]||(c[0]=a=>n.value=a),type:"text",name:"dialog-search-query",class:"dialog-search-bar-input","aria-label":t.placeholder,placeholder:t.placeholder,autofocus:t.autoFocus,onInput:s},null,40,He),[[e.vModelText,n.value]])]),e.createElementVNode("button",{type:"submit",class:"dialog-search-bar-submit","aria-label":t.submitAriaLabel},[e.createVNode($e)],8,Ke)],32))}}),Ge={key:0,"aria-label":"Search results pages",class:"dialog-search-pagination"},je=["disabled"],Qe=["disabled"],M=e.defineComponent({__name:"DialogSearchPagination",props:{controller:{},state:{}},setup(o){const t=o,n=e.computed(()=>t.state.response);return(s,i)=>n.value!==void 0&&n.value.nbPages>1?(e.openBlock(),e.createElementBlock("nav",Ge,[e.createElementVNode("button",{type:"button",disabled:n.value.page===0,onClick:i[0]||(i[0]=r=>t.controller.setPage(n.value.page-1))}," Previous ",8,je),e.createElementVNode("span",null," Page "+e.toDisplayString(n.value.page+1)+" / "+e.toDisplayString(n.value.nbPages),1),e.createElementVNode("button",{type:"button",disabled:n.value.page>=n.value.nbPages-1,onClick:i[1]||(i[1]=r=>t.controller.setPage(n.value.page+1))}," Next ",8,Qe)])):e.createCommentVNode("",!0)}}),We=o=>{if(o===void 0)return"";const{min:t,max:n}=o,s=({amount:i,currencyCode:r})=>new Intl.NumberFormat(void 0,{style:"currency",currency:r}).format(Number(i));try{return t.amount===n.amount?s(t):`${s(t)} – ${s(n)}`}catch{return""}},Ye=o=>{try{const{protocol:t}=new URL(o,window.location.href);return t==="http:"||t==="https:"?o:void 0}catch{return}},ze={class:"dialog-search-card-image"},Xe=["src","alt"],ve={class:"dialog-search-card-info"},Ze={class:"dialog-search-card-title"},Je={key:0,class:"dialog-search-card-price"},q=e.defineComponent({__name:"DialogSearchProductCardContent",props:{hit:{}},setup(o){const t=o,n=e.computed(()=>t.hit.product.title??t.hit.product.id),s=e.computed(()=>We(t.hit.product.priceRange));return(i,r)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",ze,[t.hit.product.imageUrl!==void 0?(e.openBlock(),e.createElementBlock("img",{key:0,src:t.hit.product.imageUrl,alt:n.value,loading:"lazy"},null,8,Xe)):e.createCommentVNode("",!0)]),e.createElementVNode("div",ve,[e.createElementVNode("p",Ze,e.toDisplayString(n.value),1),s.value!==""?(e.openBlock(),e.createElementBlock("p",Je,e.toDisplayString(s.value),1)):e.createCommentVNode("",!0)])],64))}}),et={key:0,class:"dialog-search-card-body"},tt=["href"],x=e.defineComponent({__name:"DialogSearchProductCard",props:{controller:{},hit:{},index:{}},setup(o){const t=o,n=e.ref();e.watch(()=>t.hit,()=>{n.value!==void 0&&t.controller.observeResult(n.value,t.index)},{immediate:!0,flush:"post"});const s=c=>{const a=c.metaKey||c.ctrlKey||c.shiftKey||c.altKey;t.controller.selectResult(t.index,{navigate:!a})&&c.preventDefault()},i=c=>{c.button===1&&t.controller.selectResult(t.index,{navigate:!1})},r=e.computed(()=>t.hit.product.url===void 0?void 0:Ye(t.hit.product.url));return(c,a)=>(e.openBlock(),e.createElementBlock("li",{ref_key:"cardRef",ref:n,class:"dialog-search-card"},[r.value===void 0?(e.openBlock(),e.createElementBlock("div",et,[e.createVNode(q,{hit:t.hit},null,8,["hit"])])):(e.openBlock(),e.createElementBlock("a",{key:1,class:"dialog-search-card-body",href:r.value,onClick:s,onAuxclick:i},[e.createVNode(q,{hit:t.hit},null,8,["hit"])],40,tt))],512))}}),ot=o=>{const t=e.ref(),n=e.ref(void 0),s=e.ref(0);return e.watch(o,(i,r,c)=>{if(!i)return;const a=()=>{const h=t.value;if(h===void 0)return;const _=h.previousElementSibling??h,{top:u,bottom:m,left:f,width:S}=_.getBoundingClientRect();s.value=window.innerHeight;const p=n.value;(p===void 0||p.top!==u||p.bottom!==m||p.left!==f||p.width!==S)&&(n.value={top:u,bottom:m,left:f,width:S})};a(),window.addEventListener("scroll",a,!0),window.addEventListener("resize",a),c(()=>{window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a)})},{immediate:!0,flush:"post"}),{anchorRef:t,rect:n,viewportHeight:s}},nt=(o,t)=>{const n=e.ref(!1),s=e.ref(),i=e.computed(()=>o.value.status!==b.IDLE&&!n.value);e.watch(()=>o.value.query,()=>{n.value=!1}),e.watch(i,(c,a,h)=>{if(!c)return;const _=u=>{var k,E;const m=u.target;if(!(m instanceof Node))return;const f=(k=t.value)==null?void 0:k.previousElementSibling,S=((E=s.value)==null?void 0:E.contains(m))??!1,p=(f==null?void 0:f.contains(m))??!1;!S&&!p&&(n.value=!0)};document.addEventListener("pointerdown",_),h(()=>document.removeEventListener("pointerdown",_))},{immediate:!0});const r=()=>{n.value=!1};return e.onMounted(()=>{var c,a;(a=(c=t.value)==null?void 0:c.previousElementSibling)==null||a.addEventListener("focusin",r)}),e.onUnmounted(()=>{var c,a;(a=(c=t.value)==null?void 0:c.previousElementSibling)==null||a.removeEventListener("focusin",r)}),{isOpen:i,panelRef:s}},rt={key:0,role:"status",class:"dialog-search-status"},st={key:1,class:"dialog-search-error"},ct={role:"alert",class:"dialog-search-status dialog-search-status-error"},it={key:2,role:"status",class:"dialog-search-status"},at={role:"status",class:"dialog-search-status"},lt={class:"dialog-search-results"},B=8,H=16,dt=200,ut=e.defineComponent({__name:"DialogSearchResults",props:{controller:{},state:{}},setup(o){const t=o,n=p=>p instanceof G?`Search failed (${p.status}${p.code?` ${p.code}`:""}): ${p.message}`:"Search failed: network error. Check your connection and try again.",s=(p,k)=>p.bottom>0&&p.top<k,i=(p,k)=>{const E=k-p.bottom-B-H,y=p.top-B-H,l={left:`${p.left}px`,width:`${p.width}px`};return E<dt&&y>E?{...l,bottom:`${k-p.top+B}px`,maxHeight:`${Math.max(y,0)}px`}:{...l,top:`${p.bottom+B}px`,maxHeight:`${Math.max(E,0)}px`}},r=e.computed(()=>t.state),c=e.computed(()=>t.state.status!==b.IDLE),{anchorRef:a,rect:h,viewportHeight:_}=ot(c),{isOpen:u,panelRef:m}=nt(r,a),f=e.computed(()=>u.value&&h.value!==void 0&&s(h.value,_.value)),S=e.computed(()=>h.value===void 0?void 0:i(h.value,_.value));return(p,k)=>{var E;return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{ref_key:"anchorRef",ref:a},null,512),f.value?(e.openBlock(),e.createBlock(e.Teleport,{key:0,to:"body"},[e.createElementVNode("div",{ref_key:"panelRef",ref:m,class:"dialog-search-panel",style:e.normalizeStyle(S.value)},[t.state.status===e.unref(b).LOADING?(e.openBlock(),e.createElementBlock("p",rt," Searching “"+e.toDisplayString(t.state.query)+"”… ",1)):t.state.status===e.unref(b).ERROR?(e.openBlock(),e.createElementBlock("div",st,[e.createElementVNode("p",ct,e.toDisplayString(n(t.state.error)),1),e.createElementVNode("button",{type:"button",class:"dialog-search-retry",onClick:k[0]||(k[0]=y=>t.controller.retry())}," Retry ")])):t.state.status===e.unref(b).EMPTY?(e.openBlock(),e.createElementBlock("p",it," No products match “"+e.toDisplayString((E=t.state.response)==null?void 0:E.query)+"”. ",1)):t.state.status===e.unref(b).SUCCESS&&t.state.response!==void 0?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createElementVNode("p",at,e.toDisplayString(t.state.response.nbHits)+" result"+e.toDisplayString(t.state.response.nbHits>1?"s":""),1),e.createElementVNode("ul",lt,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.state.response.hits,(y,l)=>(e.openBlock(),e.createBlock(x,{key:y.id,controller:t.controller,hit:y,index:l},null,8,["controller","hit","index"]))),128))]),e.createVNode(M,{controller:t.controller,state:t.state},null,8,["controller","state"])],64)):e.createCommentVNode("",!0)],4)])):e.createCommentVNode("",!0)],64)}}}),pt=o=>{const{client:t,surface:n="search_page",...s}=o,i=re({search:(a,h)=>t.search(a,h),analytics:{surface:n,trackViewSearchResults:a=>t.trackViewSearchResults(a),trackSelectSearchResult:a=>t.trackSelectSearchResult(a)},...s}),r=e.shallowRef(i.getState()),c=i.subscribe(()=>{r.value=i.getState()});return e.onMounted(()=>{$({method:"vue",version:"3.3.0"})}),e.onUnmounted(()=>{c(),i.dispose()}),{controller:i,state:r}};g.DialogInput=U,g.DialogProductBlock=De,g.DialogSearchBar=Fe,g.DialogSearchPagination=M,g.DialogSearchProductCard=x,g.DialogSearchResults=ut,g.useDialogSearch=pt,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));
19
+ 1.66666Z`,stroke:t.color||"#181825","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,8,ge)]),r[0]||(r[0]=e.createElementVNode("defs",null,[e.createElementVNode("clipPath",{id:"clip0_466_934"},[e.createElementVNode("rect",{width:"20",height:"20",fill:"white"})])],-1))]))}}),Se=["onClick"],ke={class:"dialog-block-suggestions-item-label"},Ce=N(e.defineComponent({__name:"DialogBlockSuggestions",props:{client:{},questions:{},productId:{},productTitle:{},selectedVariantId:{}},setup(o){const t=o,n=r=>{t.client.sendProductMessage({productId:t.productId,productTitle:t.productTitle,selectedVariantId:t.selectedVariantId,question:r,fromQuestionSuggestion:!0})};return(r,i)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.questions,c=>(e.openBlock(),e.createElementBlock("button",{key:c.question,class:"dialog-block-suggestions-item",onClick:a=>n(c.question)},[e.createVNode(Ee,{class:"dialog-block-suggestions-item-icon",color:t.client.theme.primaryColor},null,8,["color"]),e.createElementVNode("span",ke,e.toDisplayString(c.question),1)],8,Se))),128))}}),[["__scopeId","data-v-db34d4b4"]]),be={};function ye(o,t){return e.openBlock(),e.createElementBlock(e.Fragment,null,[t[0]||(t[0]=e.createElementVNode("div",{class:"dialog-block-suggestions-skeleton-item"},null,-1)),t[1]||(t[1]=e.createElementVNode("div",{class:"dialog-block-suggestions-skeleton-item"},null,-1)),t[2]||(t[2]=e.createElementVNode("div",{class:"dialog-block-suggestions-skeleton-item"},null,-1))],64)}const Te=N(be,[["render",ye],["__scopeId","data-v-26a64b58"]]),we={class:"dialog-block-suggestions-container"},Re=N(e.defineComponent({__name:"DialogBlockSuggestionsContainer",props:{client:{},questions:{},isLoading:{type:Boolean},productId:{},productTitle:{},selectedVariantId:{}},setup(o){const t=o;return(n,r)=>(e.openBlock(),e.createElementBlock("div",we,[t.isLoading||!t.questions?(e.openBlock(),e.createBlock(Te,{key:0})):(e.openBlock(),e.createBlock(Ce,{key:1,client:t.client,questions:t.questions,"product-id":t.productId,"product-title":t.productTitle,"selected-variant-id":t.selectedVariantId},null,8,["client","questions","product-id","product-title","selected-variant-id"]))]))}}),[["__scopeId","data-v-18c9e78b"]]),Ie={width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Ne=["stroke"],Be=e.defineComponent({__name:"ArrowIcon",props:{color:{}},setup(o){const t=o;return(n,r)=>(e.openBlock(),e.createElementBlock("svg",Ie,[e.createElementVNode("path",{d:"M10 16.6667V3.33334M10 3.33334L5 8.33334M10 3.33334L15 8.33334",stroke:t.color||"#ffffff","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,8,Ne)]))}}),De=["placeholder"],Ae=["disabled"],x=N(e.defineComponent({__name:"DialogInput",props:{client:{},placeholder:{},productId:{},productTitle:{},selectedVariantId:{}},setup(o){const t=o,n=e.ref(),r=e.ref(""),i=()=>{var a;(a=n.value)==null||a.focus()},c=()=>{const a=r.value;a.trim()&&(t.client.sendProductMessage({productId:t.productId,productTitle:t.productTitle,selectedVariantId:t.selectedVariantId,question:a,fromQuestionSuggestion:!0}),r.value="")};return(a,s)=>(e.openBlock(),e.createElementBlock("div",{class:"dialog-input-wrapper",onClick:i},[e.withDirectives(e.createElementVNode("input",{id:"dialog-ask-anything-input-ai-input",ref_key:"inputRef",ref:n,"onUpdate:modelValue":s[0]||(s[0]=p=>r.value=p),class:"dialog-ask-anything-input-ai-input",placeholder:t.placeholder??"Ask anything...",onKeydown:e.withKeys(c,["enter"])},null,40,De),[[e.vModelText,r.value]]),e.createElementVNode("button",{id:"send-message-button-ai-input",class:"dialog-input-submit",disabled:!r.value.trim(),onClick:c},[e.createVNode(Be,{color:t.client.theme.ctaTextColor},null,8,["color"])],8,Ae)]))}}),[["__scopeId","data-v-4f5901c9"]]),Le=e.defineComponent({__name:"ThemeProvider",props:{theme:{}},setup(o){const t=o,n=document.body,r=c=>c.replace(/([A-Z])/g,"-$1").toLowerCase(),i=c=>{c&&Object.keys(c).forEach(a=>{const s=a,p=r(a);if(c[s]!==void 0){if(typeof c[s]=="object"){Object.keys(c[s]).forEach(_=>{var u;const d=_;if(d!==void 0){const g=r(_),C=c[s];n.style.setProperty(`--dialog-theme-${p}-${g}`,(u=C[d])==null?void 0:u.toString())}});return}if(s==="ctaBorderType"){const _=c[s]==="rounded"?"24px":"0";n.style.setProperty(`--dialog-theme-${p}`,_);return}n.style.setProperty(`--dialog-theme-${p}`,c[s].toString())}})};return e.onMounted(()=>{t.theme&&i(t.theme)}),e.watch(()=>t.theme,c=>{c&&i(c)},{deep:!0}),(c,a)=>e.renderSlot(c.$slots,"default")}}),Ve=["dir"],$e=N(e.defineComponent({__name:"DialogProductBlock",props:{client:{},productId:{},productTitle:{},selectedVariantId:{default:void 0},enableInput:{type:Boolean,default:!0}},setup(o){const t=o;e.onMounted(()=>{U({method:"vue",version:"3.4.1"}),v("pdp-block")});const n=e.ref(!0),r=e.ref(void 0),i=e.ref(0),c=e.computed(()=>{var d;return n.value?"":(d=r.value)==null?void 0:d.assistantName}),a=e.computed(()=>{var d;return n.value?"":(d=r.value)==null?void 0:d.description}),s=e.computed(()=>{var d;return n.value?"":(d=r.value)==null?void 0:d.inputPlaceholder}),p=e.computed(()=>{var d;return W((d=t.client.getLocalizationInformations())==null?void 0:d.languageCode)}),_=async()=>{const d=++i.value;n.value=!0,r.value=void 0;try{const u=await t.client.getSuggestions(t.productId);d===i.value&&(r.value=u)}catch(u){console.error("error",u)}finally{d===i.value&&(n.value=!1)}};return e.watch(()=>[t.client,t.productId],()=>{_()},{immediate:!0}),(d,u)=>(e.openBlock(),e.createBlock(Le,{theme:t.client.theme},{default:e.withCtx(()=>{var g;return[e.createElementVNode("div",{id:"dialog-instant",class:"dialog-block-container",dir:p.value},[e.createVNode(me,{title:c.value,description:a.value},null,8,["title","description"]),e.createVNode(Re,{client:t.client,questions:(g=r.value)==null?void 0:g.questions,"is-loading":n.value,"product-id":t.productId,"product-title":t.productTitle,"selected-variant-id":t==null?void 0:t.selectedVariantId},null,8,["client","questions","is-loading","product-id","product-title","selected-variant-id"]),t.enableInput?(e.openBlock(),e.createBlock(x,{key:0,client:t.client,placeholder:s.value,"product-id":t.productId,"product-title":t.productTitle,"selected-variant-id":t==null?void 0:t.selectedVariantId},null,8,["client","placeholder","product-id","product-title","selected-variant-id"])):e.createCommentVNode("",!0)],8,Ve)]}),_:1},8,["theme"]))}}),[["__scopeId","data-v-c57aa677"]]),Pe={},Oe={width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true"};function Ue(o,t){return e.openBlock(),e.createElementBlock("svg",Oe,t[0]||(t[0]=[e.createElementVNode("path",{d:"M8 13V3M8 3L3 8M8 3L13 8",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)]))}const Me=N(Pe,[["render",Ue]]),qe={width:"16",height:"16",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true"},xe=["fill"],He="M5.3217 0.588255C5.63241 -0.196084 6.36759 -0.196085 6.6783 0.588254C6.98901 1.37259 7.68193 2.82807 8.42693 3.57307C9.17193 4.31807 10.6274 5.01099 11.4117 5.3217C12.1961 5.63241 12.1961 6.36759 11.4117 6.6783C10.6274 6.98901 9.17193 7.68193 8.42693 8.42693C7.68193 9.17193 6.98901 10.6274 6.6783 11.4117C6.36759 12.1961 5.63241 12.1961 5.3217 11.4117C5.01099 10.6274 4.31807 9.17193 3.57307 8.42693C2.82808 7.68193 1.37259 6.98901 0.588255 6.6783C-0.196084 6.36759 -0.196085 5.63241 0.588254 5.3217C1.37259 5.01099 2.82807 4.31807 3.57307 3.57307C4.31807 2.82808 5.01099 1.37259 5.3217 0.588255Z",Ke=e.defineComponent({__name:"ShurikenIcon",props:{color:{}},setup(o){const t=o;return(n,r)=>(e.openBlock(),e.createElementBlock("svg",qe,[e.createElementVNode("path",{d:He,fill:t.color||"currentColor"},null,8,xe)]))}}),Fe={class:"dialog-search-bar-field"},Ge={class:"dialog-search-bar-icon"},je=["aria-label","placeholder","autofocus"],Qe=["aria-label"],We=e.defineComponent({__name:"DialogSearchBar",props:{controller:{},placeholder:{default:"Search products..."},autoFocus:{type:Boolean,default:!1},submitAriaLabel:{default:"Search"}},setup(o){const t=o,n=e.ref(""),r=()=>{t.controller.setQuery(n.value)},i=()=>{t.controller.submit(n.value)};return(c,a)=>(e.openBlock(),e.createElementBlock("form",{class:"dialog-search-bar",role:"search",onSubmit:e.withModifiers(i,["prevent"])},[e.createElementVNode("div",Fe,[e.createElementVNode("span",Ge,[e.createVNode(Ke)]),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":a[0]||(a[0]=s=>n.value=s),type:"text",name:"dialog-search-query",class:"dialog-search-bar-input","aria-label":t.placeholder,placeholder:t.placeholder,autofocus:t.autoFocus,onInput:r},null,40,je),[[e.vModelText,n.value]])]),e.createElementVNode("button",{type:"submit",class:"dialog-search-bar-submit","aria-label":t.submitAriaLabel},[e.createVNode(Me)],8,Qe)],32))}}),Ye={key:0,"aria-label":"Search results pages",class:"dialog-search-pagination"},ze=["disabled"],Xe=["disabled"],H=e.defineComponent({__name:"DialogSearchPagination",props:{controller:{},state:{}},setup(o){const t=o,n=e.computed(()=>t.state.response);return(r,i)=>n.value!==void 0&&n.value.nbPages>1?(e.openBlock(),e.createElementBlock("nav",Ye,[e.createElementVNode("button",{type:"button",disabled:n.value.page===0,onClick:i[0]||(i[0]=c=>t.controller.setPage(n.value.page-1))}," Previous ",8,ze),e.createElementVNode("span",null," Page "+e.toDisplayString(n.value.page+1)+" / "+e.toDisplayString(n.value.nbPages),1),e.createElementVNode("button",{type:"button",disabled:n.value.page>=n.value.nbPages-1,onClick:i[1]||(i[1]=c=>t.controller.setPage(n.value.page+1))}," Next ",8,Xe)])):e.createCommentVNode("",!0)}}),L=({amount:o,currencyCode:t},n)=>new Intl.NumberFormat(n,{style:"currency",currency:t}).format(Number(o)),K=({min:o,max:t},n)=>o.amount===t.amount?L(o,n):`${L(o,n)} – ${L(t,n)}`,Ze=(o,t)=>{if(o===void 0)return"";try{return K(o,t)}catch{return""}},ve=(o,t)=>{const n=o.priceRange,r=o.compareAtPriceRange;if(n===void 0||r===void 0||Number(r.min.amount)<=Number(n.min.amount))return"";try{return K(r,t)}catch{return""}},Je=o=>{try{const{protocol:t}=new URL(o,window.location.href);return t==="http:"||t==="https:"?o:void 0}catch{return}},et={class:"dialog-search-card-image"},tt=["src","alt"],ot={class:"dialog-search-card-info"},nt={class:"dialog-search-card-title"},rt={key:0,class:"dialog-search-card-price"},st={key:0,class:"dialog-search-card-compare-at"},F=e.defineComponent({__name:"DialogSearchProductCardContent",props:{hit:{},locale:{}},setup(o){const t=o,n=e.computed(()=>t.hit.product.title??t.hit.product.id),r=e.computed(()=>Ze(t.hit.product.priceRange,t.locale)),i=e.computed(()=>ve(t.hit.product,t.locale));return(c,a)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",et,[t.hit.product.imageUrl!==void 0?(e.openBlock(),e.createElementBlock("img",{key:0,src:t.hit.product.imageUrl,alt:n.value,loading:"lazy"},null,8,tt)):e.createCommentVNode("",!0)]),e.createElementVNode("div",ot,[e.createElementVNode("p",nt,e.toDisplayString(n.value),1),r.value!==""?(e.openBlock(),e.createElementBlock("p",rt,[e.createTextVNode(e.toDisplayString(r.value),1),i.value!==""?(e.openBlock(),e.createElementBlock("s",st,e.toDisplayString(" "+i.value),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])],64))}}),ct={key:0,class:"dialog-search-card-body"},at=["href"],G=e.defineComponent({__name:"DialogSearchProductCard",props:{controller:{},hit:{},index:{},locale:{}},setup(o){const t=o,n=e.ref();e.watch(()=>t.hit,()=>{n.value!==void 0&&t.controller.observeResult(n.value,t.index)},{immediate:!0,flush:"post"});const r=a=>{const s=a.metaKey||a.ctrlKey||a.shiftKey||a.altKey;t.controller.selectResult(t.index,{navigate:!s})&&a.preventDefault()},i=a=>{a.button===1&&t.controller.selectResult(t.index,{navigate:!1})},c=e.computed(()=>t.hit.product.url===void 0?void 0:Je(t.hit.product.url));return(a,s)=>(e.openBlock(),e.createElementBlock("li",{ref_key:"cardRef",ref:n,class:"dialog-search-card"},[c.value===void 0?(e.openBlock(),e.createElementBlock("div",ct,[e.createVNode(F,{hit:t.hit,locale:t.locale},null,8,["hit","locale"])])):(e.openBlock(),e.createElementBlock("a",{key:1,class:"dialog-search-card-body",href:c.value,onClick:r,onAuxclick:i},[e.createVNode(F,{hit:t.hit,locale:t.locale},null,8,["hit","locale"])],40,at))],512))}}),it=o=>{const t=e.ref(),n=e.ref(void 0),r=e.ref(0);return e.watch(o,(i,c,a)=>{if(!i)return;const s=()=>{const p=t.value;if(p===void 0)return;const _=p.previousElementSibling??p,{top:d,bottom:u,left:g,width:C}=_.getBoundingClientRect();r.value=window.innerHeight;const l=n.value;(l===void 0||l.top!==d||l.bottom!==u||l.left!==g||l.width!==C)&&(n.value={top:d,bottom:u,left:g,width:C})};s(),window.addEventListener("scroll",s,!0),window.addEventListener("resize",s),a(()=>{window.removeEventListener("scroll",s,!0),window.removeEventListener("resize",s)})},{immediate:!0,flush:"post"}),{anchorRef:t,rect:n,viewportHeight:r}},lt=(o,t)=>{const n=e.ref(!1),r=e.ref(),i=e.computed(()=>o.value.status!==y.IDLE&&!n.value);e.watch(()=>o.value.query,()=>{n.value=!1}),e.watch(i,(a,s,p)=>{if(!a)return;const _=d=>{var k,b;const u=d.target;if(!(u instanceof Node))return;const g=(k=t.value)==null?void 0:k.previousElementSibling,C=((b=r.value)==null?void 0:b.contains(u))??!1,l=(g==null?void 0:g.contains(u))??!1;!C&&!l&&(n.value=!0)};document.addEventListener("pointerdown",_),p(()=>document.removeEventListener("pointerdown",_))},{immediate:!0});const c=()=>{n.value=!1};return e.onMounted(()=>{var a,s;(s=(a=t.value)==null?void 0:a.previousElementSibling)==null||s.addEventListener("focusin",c)}),e.onUnmounted(()=>{var a,s;(s=(a=t.value)==null?void 0:a.previousElementSibling)==null||s.removeEventListener("focusin",c)}),{isOpen:i,panelRef:r}},dt={key:0,role:"status",class:"dialog-search-status"},ut={key:1,class:"dialog-search-error"},pt={role:"alert",class:"dialog-search-status dialog-search-status-error"},mt={key:2,role:"status",class:"dialog-search-status"},_t={role:"status",class:"dialog-search-status"},ht={class:"dialog-search-results"},A=8,j=16,ft=200,gt=e.defineComponent({__name:"DialogSearchResults",props:{controller:{},state:{},locale:{}},setup(o){const t=o,n=l=>l instanceof Y?`Search failed (${l.status}${l.code?` ${l.code}`:""}): ${l.message}`:"Search failed: network error. Check your connection and try again.",r=(l,k)=>l.bottom>0&&l.top<k,i=(l,k)=>{const b=k-l.bottom-A-j,w=l.top-A-j,m={left:`${l.left}px`,width:`${l.width}px`};return b<ft&&w>b?{...m,bottom:`${k-l.top+A}px`,maxHeight:`${Math.max(w,0)}px`}:{...m,top:`${l.bottom+A}px`,maxHeight:`${Math.max(b,0)}px`}},c=e.computed(()=>t.state),a=e.computed(()=>t.state.status!==y.IDLE),{anchorRef:s,rect:p,viewportHeight:_}=it(a),{isOpen:d,panelRef:u}=lt(c,s),g=e.computed(()=>d.value&&p.value!==void 0&&r(p.value,_.value)),C=e.computed(()=>p.value===void 0?void 0:i(p.value,_.value));return(l,k)=>{var b;return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{ref_key:"anchorRef",ref:s},null,512),g.value?(e.openBlock(),e.createBlock(e.Teleport,{key:0,to:"body"},[e.createElementVNode("div",{ref_key:"panelRef",ref:u,class:"dialog-search-panel",style:e.normalizeStyle(C.value)},[t.state.status===e.unref(y).LOADING?(e.openBlock(),e.createElementBlock("p",dt," Searching “"+e.toDisplayString(t.state.query)+"”… ",1)):t.state.status===e.unref(y).ERROR?(e.openBlock(),e.createElementBlock("div",ut,[e.createElementVNode("p",pt,e.toDisplayString(n(t.state.error)),1),e.createElementVNode("button",{type:"button",class:"dialog-search-retry",onClick:k[0]||(k[0]=w=>t.controller.retry())}," Retry ")])):t.state.status===e.unref(y).EMPTY?(e.openBlock(),e.createElementBlock("p",mt," No products match “"+e.toDisplayString((b=t.state.response)==null?void 0:b.query)+"”. ",1)):t.state.status===e.unref(y).SUCCESS&&t.state.response!==void 0?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createElementVNode("p",_t,e.toDisplayString(t.state.response.nbHits)+" result"+e.toDisplayString(t.state.response.nbHits>1?"s":""),1),e.createElementVNode("ul",ht,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.state.response.hits,(w,m)=>(e.openBlock(),e.createBlock(G,{key:w.id,controller:t.controller,hit:w,index:m,locale:t.locale},null,8,["controller","hit","index","locale"]))),128))]),e.createVNode(H,{controller:t.controller,state:t.state},null,8,["controller","state"])],64)):e.createCommentVNode("",!0)],4)])):e.createCommentVNode("",!0)],64)}}}),Et=o=>{const{client:t,surface:n="search_page",...r}=o,i=ie({search:(s,p)=>t.search(s,p),analytics:{surface:n,trackViewSearchResults:s=>t.trackViewSearchResults(s),trackSelectSearchResult:s=>t.trackSelectSearchResult(s)},...r}),c=e.shallowRef(i.getState()),a=i.subscribe(()=>{c.value=i.getState()});return e.onMounted(()=>{U({method:"vue",version:"3.4.1"})}),e.onUnmounted(()=>{a(),i.dispose()}),{controller:i,state:c}};S.DialogInput=x,S.DialogProductBlock=$e,S.DialogSearchBar=We,S.DialogSearchPagination=H,S.DialogSearchProductCard=G,S.DialogSearchResults=gt,S.useDialogSearch=Et,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@askdialog/dialog-vue",
3
3
  "private": false,
4
- "version": "3.3.0",
4
+ "version": "3.4.1",
5
5
  "type": "module",
6
6
  "main": "./dist/dialog-vue.umd.js",
7
7
  "module": "./dist/dialog-vue.js",
@@ -29,7 +29,7 @@
29
29
  "eslint-plugin-vue": "^10.0.0",
30
30
  "vite-plugin-eslint": "^1.8.1",
31
31
  "vue-tsc": "^2.2.4",
32
- "@askdialog/dialog-sdk": "2.8.1"
32
+ "@askdialog/dialog-sdk": "2.9.0"
33
33
  },
34
34
  "author": "Dialog",
35
35
  "publishConfig": {