@dori-ai/dori-side-widget 1.13.152 → 1.13.154
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{MarkdownContent-CE3Y1ZTn.js → MarkdownContent-CPJP1ggu.js} +1 -1
- package/dist/assets/MarkdownContent-CPJP1ggu.js.br +0 -0
- package/dist/assets/MarkdownContent-CPJP1ggu.js.gz +0 -0
- package/dist/assets/apply-BQSXIcbI.js +1 -0
- package/dist/assets/apply-BQSXIcbI.js.br +0 -0
- package/dist/assets/apply-BQSXIcbI.js.gz +0 -0
- package/dist/assets/main-TbBDUH7u.js +2 -0
- package/dist/assets/main-TbBDUH7u.js.br +0 -0
- package/dist/assets/main-TbBDUH7u.js.gz +0 -0
- package/dist/widget.js +2 -2
- package/dist/widget.js.br +0 -0
- package/dist/widget.js.gz +0 -0
- package/package.json +1 -1
- package/dist/assets/MarkdownContent-CE3Y1ZTn.js.br +0 -0
- package/dist/assets/MarkdownContent-CE3Y1ZTn.js.gz +0 -0
- package/dist/assets/apply-Bf5JpTVH.js +0 -1
- package/dist/assets/apply-Bf5JpTVH.js.br +0 -0
- package/dist/assets/apply-Bf5JpTVH.js.gz +0 -0
- package/dist/assets/main-BS5x7ctG.js +0 -2
- package/dist/assets/main-BS5x7ctG.js.br +0 -0
- package/dist/assets/main-BS5x7ctG.js.gz +0 -0
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as e}from"./report-BHr6U1PB.js";const t="dori-ask-button";function n(e,n){const o=Boolean(e.label),r=o?Math.max(32,Math.min(38,e.boxHeight)):Math.max(32,Math.min(44,e.boxHeight));"undefined"==typeof customElements||customElements.get(t)||customElements.define(t,class extends HTMLElement{});const a=document.createElement(t);a.style.cssText=`display:inline-flex;align-items:center;flex:0 0 auto;height:${Math.max(r,e.boxHeight)}px;margin:0;padding:0;border:0;background:none;box-shadow:none;float:none;min-width:0;max-width:none;width:auto;vertical-align:middle;position:relative;z-index:1;color:${e.color};`;const i=a.attachShadow({mode:"open",delegatesFocus:!0}),s=Math.max(12,Math.min(15,e.fontSize||14));i.innerHTML=`<style>button{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;gap:7px;height:${r}px;width:${o?"auto":`${r}px`};padding:${o?"0 14px 0 12px":"0"};border-radius:999px;cursor:pointer;color:inherit;font:inherit;font-size:${s}px;font-weight:600;line-height:1.2;white-space:nowrap;border:1.5px solid ${o?"currentColor":"transparent"}}button:hover{background:rgba(127,127,127,.12)}button:focus-visible{outline:2px solid currentColor;outline-offset:2px}svg{width:${e.iconSize}px;height:${e.iconSize}px;flex:0 0 auto}</style><button type="button"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M12 3.5l1.9 5.1 5.1 1.9-5.1 1.9L12 17.5l-1.9-5.1L5 10.5l5.1-1.9z"/><path d="M18.5 15.5l.8 2 2 .8-2 .8-.8 2-.8-2-2-.8 2-.8z"/></svg></button>`;const l=i.querySelector("button");if(l.setAttribute("aria-label",e.aria),e.label){const t=document.createElement("span");t.textContent=e.label,l.appendChild(t)}return l.addEventListener("click",n),a}const o=()=>({w:window.innerWidth,h:window.innerHeight}),r=e=>e.getBoundingClientRect();function a(e,t=o()){if(!e)return!1;const n=r(e);if(n.width<6||n.height<6||n.right<=0||n.left>=t.w||n.bottom<=0)return!1;const a=e;if(a.checkVisibility&&!a.checkVisibility({contentVisibilityAuto:!0,opacityProperty:!0,visibilityProperty:!0}))return!1;const i=getComputedStyle(e);return"hidden"!==i.visibility&&"none"!==i.display&&parseFloat(i.opacity)>=.05}function i(e){const t=r(e);if(t.width<2||t.height<2)return!1;const n=e;return!n.checkVisibility||n.checkVisibility({visibilityProperty:!0})}const s=['input[type="search"]','input[name="q"]','a[href$="/search"]','a[href*="/search?"]','button[aria-label*="search" i]','a[aria-label*="search" i]','summary[aria-label*="search" i]','[aria-controls*="search" i]',"details-modal.header__search summary","predictive-search","search-button",'[class*="search-toggle" i]','[class*="search-icon" i]','[class*="header__search" i]','[data-action*="search" i]'].join(","),l=['a[href$="/cart"]','a[href*="/cart?"]',"#cart-icon-bubble","[data-cart-toggle]","[data-cart-trigger]","[data-open-cart]",'[data-drawer-toggle*="cart" i]','[aria-controls*="cart" i]','button[aria-label*="cart" i]','a[aria-label*="cart" i]','button[aria-label*="bag" i]','a[aria-label*="bag" i]','[class*="cart-icon" i]','[class*="header__cart" i]',"cart-icon","cart-drawer-component button"].join(","),c=['[aria-label*="menu" i]','summary[aria-controls*="menu" i]','[class*="menu-drawer" i] summary','[class*="hamburger" i]','[class*="burger" i]','[data-drawer-toggle*="menu" i]','button[aria-controls*="menu" i]','[class*="menu-toggle" i]','[class*="nav-toggle" i]',"header-drawer summary"].join(","),d=e=>Math.min(300,.4*e.h),h=(e,t)=>a(e,t)&&r(e).top<d(t)&&!e.closest('[role="dialog"], [aria-modal="true"]'),u=(e,t)=>{const n=e.closest("a, button, summary");return n&&a(n,t)&&r(n).width<220?n:e};function f(e=o()){const t=[...document.querySelectorAll(s)].filter(t=>h(t,e)),n=[...document.querySelectorAll(l)].filter(t=>h(t,e));if(!t.length&&!n.length)return null;let i=null,f=!1;const p=t.find(e=>"INPUT"===e.tagName&&r(e).width>120);if(p){f=!0;let e=p.closest("form")||p.parentElement||p;for(let t=0;t<3&&e.parentElement&&r(e.parentElement).width<r(p).width+140;t++)e=e.parentElement;i=e}else if(t.length){const n=t.map(t=>u(t,e)).filter(t=>a(t,e)&&r(t).width<200&&r(t).height<90);n.sort((e,t)=>r(t).right-r(e).right),i=n[0]||null}let m=null;if(n.length){const t=n.map(t=>u(t,e)).filter(e=>r(e).width<260&&r(e).height<130);t.sort((e,t)=>r(t).right-r(e).right),m=t[0]||null}const g=[...document.querySelectorAll(c)].filter(t=>h(t,e)&&r(t).width<120).map(t=>u(t,e)),w="rtl"===getComputedStyle(document.documentElement).direction;g.sort((e,t)=>w?r(t).right-r(e).right:r(e).left-r(t).left);const b=g.find(t=>w?r(t).right>.65*e.w:r(t).left<.35*e.w)||null,y=i||m;let _=y.parentElement||y;for(let o=y.parentElement;o&&o!==document.body;o=o.parentElement){const t=r(o);if(t.top>d(e)||t.height>360)break;t.width>=.6*e.w&&(_=o)}return{search:i,isBar:f,cart:m,menu:b,header:_,rtl:w||"rtl"===getComputedStyle(_).direction}}function p(e){let t=e;for(let n=0;n<6;n++){const e=t.parentElement;if(!e||e===document.body||"HEADER"===e.tagName)break;if([...e.children].some(e=>e!==t&&a(e)))break;t=e}return t}function m(e){return[...e.querySelectorAll("svg, img")].find(e=>a(e))||e}function g(e){const t=getComputedStyle(e);return!(/grid/.test(t.display)||/flex/.test(t.display)&&/space-(between|around|evenly)/.test(t.justifyContent))}const w=(e,t)=>Math.max(0,Math.min(e.right,t.right)-Math.max(e.left,t.left))*Math.max(0,Math.min(e.bottom,t.bottom)-Math.max(e.top,t.top)),b=e=>/^(A|BUTTON|IMG|SVG|INPUT|SELECT|TEXTAREA|LABEL|SUMMARY|VIDEO|CANVAS)$/i.test(e.tagName)||e.hasAttribute("role")||(e=>[...e.childNodes].some(e=>e.nodeType===Node.TEXT_NODE&&""!==(e.textContent||"").trim()))(e),y=e=>e.top+e.height/2,_=e=>e.shadowRoot?.querySelector("button")??null;function v(e,t,{sideways:n=!0}={}){const o=(e,t)=>Math.abs(e-t)<=1,r=(e,t)=>e.length===t.length&&e.every((e,n)=>o(e,t[n]));return o(e.x,t.x)&&o(e.y,t.y)&&e.w===t.w&&e.h===t.h&&o(e.header,t.header)&&r(e.tops,t.tops)&&(!n||r(e.lefts,t.lefts))}function k(e,t){const n=t.map(r);return{x:window.scrollX,y:window.scrollY,w:window.innerWidth,h:window.innerHeight,header:r(e).height,tops:n.map(e=>e.top),lefts:n.map(e=>e.left)}}const x=e=>new Promise(t=>setTimeout(t,e));async function M(e,t,n){const o=performance.now();await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(()=>e()))),document.fonts&&await document.fonts.ready;const r=t-(performance.now()-o);r>0&&await x(r);let a=e();for(;performance.now()-o<n;){await x(80);const t=e();if(v(a,t))return!0;a=t}return!1}function E(e,t){return[...e.querySelectorAll("*")].filter(e=>!(e.closest("svg")&&"svg"!==e.tagName.toLowerCase())&&b(e)&&a(e,t)&&r(e).top<Math.min(300,.4*t.h)+60).slice(0,260)}function S(e,t,n){const o=e.closest("dialog[open]");if(o&&!o.contains(t))return!0;for(let a=e;a&&a!==document.body;a=a.parentElement){const e=getComputedStyle(a);if(!("fixed"!==e.position&&"sticky"!==e.position||a.contains(t)||t.contains(a))){const e=r(a);if(e.width*e.height>n.w*n.h*.4)return!0}}return!1}function $(e,t,n){for(const o of n)if(!e.contains(o)&&!o.contains(e)&&w(t,r(o))>16)return`overlaps_${o.tagName.toLowerCase()}`;return null}function C(e,t,n,o){for(let a=1;a<=5;a++)for(let i=1;i<=3;i++){const s=t.left+t.width*a/6,l=t.top+t.height*i/4,c=document.elementFromPoint(s,l);if(!(c===e||e.contains(c)||c&&S(c,n,o)))return`covered_by_${c?c.tagName.toLowerCase():"nothing"}`;const d=document.elementsFromPoint(s,l),h=d.indexOf(e);for(const t of d.slice(h+1))if(!t.contains(e)&&t!==document.body&&t!==document.documentElement&&b(t)&&r(t).width<.6*o.w)return`sits_on_${t.tagName.toLowerCase()}`}return null}function z(e,t=o()){const n=E(e,t),a=n.map(e=>r(e).top),i=n.map(e=>{const n=r(e);return n.left>=-1&&n.right<=t.w+1}),s=()=>{const e=n.map(r),t=new Set;for(let o=0;o<n.length;o++)for(let r=o+1;r<n.length;r++)n[o].contains(n[r])||n[r].contains(n[o])||w(e[o],e[r])>16&&t.add(`${o}:${r}`);return t},l=s(),c=r(e).height,d=t=>{const o=t&&_(t);return k(e,o?[...n,o]:n)},h=d();return{look:d,before:h,check(o,d){const h=_(o);if(!h)return["no_button"];const u=r(h),f=[],p=Math.round(r(e).height-c);Math.abs(p)>2&&f.push(`header_height_${p}`);const m=Math.max(0,...n.map((e,t)=>Math.abs(r(e).top-a[t])));m>3&&f.push(`item_moved_${Math.round(m)}`);const g=n.filter((e,n)=>{if(!i[n]||o.contains(e))return!1;const a=r(e);return a.left<-1||a.right>t.w+1});g.length&&f.push(`pushed_offscreen_${g.length}`),(u.left<0||u.right>t.w+1||u.top<0)&&f.push("offscreen"),(u.width<24||u.height<24)&&f.push("too_small");const w=Math.round(y(u)-y(r(d)));Math.abs(w)>4&&f.push(`not_centred_${w}`);const b=$(o,u,n);b&&f.push(b);const v=C(o,u,e,t);v&&f.push(v);const k=[...s()].filter(e=>!l.has(e));return k.length&&f.push(`theme_overlap_${k.length}`),f}}}function N(e,t){const n=r(t.header);return[_(e)??e,t.anchor,...t.controls].flatMap(e=>{if(!e.isConnected||!i(e))return[NaN,NaN,NaN,NaN];const t=r(e);return[t.left-n.left,t.top-n.top,t.width,t.height]})}function A(e,t,n,o){const a=_(e);if(!a)return null;const i=y(r(a)),s=r(n);return{header:n,size:{w:s.width,h:s.height},anchor:t,controls:o,offsets:o.map(e=>y(r(e))-i),layout:N(e,{header:n,anchor:t,controls:o})}}function L(e,t){if(!t.header.isConnected)return!0;const n=r(t.header);if(Math.abs(n.width-t.size.w)>1||Math.abs(n.height-t.size.h)>2)return!0;const o=N(e,t);return o.length!==t.layout.length||o.some((e,n)=>{const o=t.layout[n];return Number.isNaN(e)!==Number.isNaN(o)||Math.abs(e-o)>2})}function T(e){for(const t of e){const e=t.getAttribute("onclick");if(e&&/doriWidget/.test(e))return!0;const n=t.getAttribute("href");if(n&&/(#dori-chat\b|[?&]dori-chat=)/i.test(n))return!0}return!1}const B=e=>e?`${e.tagName.toLowerCase()}${e.classList[0]?`.${e.classList[0]}`:""}`:"-",P=e=>new Promise(t=>setTimeout(t,e)),q=e=>`dori_ask_spot_${e}`,W=e=>`${e.spot}:${e.label?"text":"icon"}`,I=new Set;function H(e,t){if(!I.has(e)){I.add(e);try{t?window.localStorage.setItem(q(e),W(t)):window.localStorage.removeItem(q(e))}catch{}}}const F=e=>{const t=r(e);return t.top>=0&&t.bottom<=window.innerHeight};function R(e){return F(e)?Promise.resolve():new Promise(t=>{const n=()=>{F(e)&&(clearInterval(o),window.removeEventListener("scroll",n),window.removeEventListener("resize",n),t())},o=setInterval(n,250);window.addEventListener("scroll",n,{passive:!0}),window.addEventListener("resize",n,{passive:!0})})}async function j(){const e=await async function(){for(let e=0;e<32;e++){const e=f();if(e)return e;await P(250)}return null}();if(!e)return null;let t=e;for(;;){await R(t.search||t.cart||t.header);const e=z(t.header,o());if(await M(()=>e.look(),150,1500),t=f()||t,F(t.search||t.cart||t.header))return t}}function O(){window.doriWidget?.open?.({source:"header_button"})}function V(e,t,n){const o=function(e,t){for(let n=t?e.nextElementSibling:e.previousElementSibling;n;n=t?n.nextElementSibling:n.previousElementSibling)if(a(n))return n;return null}(e,"end"===t);if(!o)return;const i=r(e),s=r(o);(("end"===t?!n:n)?s.left-i.right:i.left-s.right)<6&&(e.style["end"===t?"marginInlineEnd":"marginInlineStart"]="8px")}const D=e=>[e.search,e.cart,e.menu].filter(e=>Boolean(e));function U(e,t,n){const o=t.spot.endsWith("_search")?n.search:t.spot.endsWith("_cart")?n.cart:n.menu;if(!o)return!1;const a=p(o),i=a.parentElement;if(!i)return!1;const s=parseFloat(getComputedStyle(i).columnGap)||0;if("after_search"===t.spot)return i.insertBefore(e,a.nextSibling),s||(e.style.marginInlineStart="10px",V(e,"end",n.rtl)),!0;if("before_cart"===t.spot)return i.insertBefore(e,a),s||(e.style.marginInlineEnd="10px",V(e,"start",n.rtl)),!0;const l=o.offsetParent;if(!l||l===document.body||l===document.documentElement)return!1;l.appendChild(e),e.style.position="absolute";const c=r(l),d=r(e),h=r("beside_menu"===t.spot?o:a),u="beside_search"===t.spot||"beside_menu"===t.spot,f=n.rtl?!u:u,m="beside_menu"===t.spot?4:10,g=f?h.right-c.left+m:h.left-c.left-d.width-m;return e.style.left=`${Math.round(g+l.scrollLeft)}px`,e.style.top=`${Math.round(h.top+h.height/2-c.top-d.height/2)}px`,!0}async function G(e,t,i,s){const l=o(),c=e.cart||e.search||e.menu,d=[...e.header.querySelectorAll("nav a, [class*='menu' i] a")].find(e=>a(e,l)),h=getComputedStyle(d||c),u=e.cart?m(e.cart):e.search?m(e.search):null,f=u&&/^(svg|img)$/i.test(u.tagName)?Math.max(16,Math.min(26,Math.round(r(u).height))):20,w=function(e){const t=e.desktop&&e.hasLabel?[!0,!1]:[!1],n=[];if(e.hasSearch)for(const o of t)e.searchPacked&&n.push({zone:"near_search",spot:"after_search",label:o}),n.push({zone:"near_search",spot:"beside_search",label:o}),n.push({zone:"near_search",spot:"before_search",label:o});if(e.hasCart)for(const o of t)e.cartPacked&&n.push({zone:"other_header",spot:"before_cart",label:o}),n.push({zone:"other_header",spot:"beside_cart",label:o});return e.hasMenu&&!e.desktop&&n.push({zone:"other_header",spot:"beside_menu",label:!1}),n}({desktop:"computer"===i,hasLabel:Boolean(t.label),hasSearch:Boolean(e.search),searchPacked:Boolean(e.search?.parentElement&&g(p(e.search).parentElement)),hasCart:Boolean(e.cart),cartPacked:Boolean(e.cart?.parentElement&&g(p(e.cart).parentElement)),hasMenu:Boolean(e.menu)}),b=z(e.header,l);for(const o of function(e,t){let n=null;try{n=window.localStorage.getItem(q(t))}catch{}const o=e.find(e=>W(e)===n);return o?[o,...e.filter(e=>e!==o)]:e}(w,i)){const a=o.spot.endsWith("_search")?e.search:o.spot.endsWith("_cart")?e.cart:e.menu,l=e.isBar&&o.spot.endsWith("_search")?a:m(a),d=Math.max(28,Math.min(44,Math.round(r(l).height+16))),u=n({label:o.label?t.label:null,aria:t.aria,boxHeight:d,color:getComputedStyle(c).color,fontSize:parseFloat(h.fontSize),iconSize:f},O);if(u.style.opacity="0",!U(u,o,e)){s?.push(`${W(o)} cant_apply`);continue}u.parentElement&&getComputedStyle(u.parentElement).color===getComputedStyle(c).color&&u.style.removeProperty("color");const p=u.shadowRoot.querySelector("button"),g=Math.round(r(l).top+r(l).height/2-(r(p).top+r(p).height/2));Math.abs(g)>1&&Math.abs(g)<24&&(u.style.top=`${(parseFloat(u.style.top)||0)+g}px`),await M(()=>b.look(u),120,700);let w=b.check(u,l);if(!w.length){if(await M(()=>b.look(u),450,1200),w=b.check(u,l),!w.length)return H(i,o),ae=A(u,l,e.header,D(e)),s?.push(`${W(o)} ok`),{placed:!0,zone:o.zone,spot:o.spot,label:o.label,device:i};w=w.map(e=>`${e}(confirm)`)}if(u.remove(),!v(b.before,b.look(),{sideways:!1}))return s?.push(`${W(o)} ${w.join(",")} page_moved`),"page_moved";s?.push(`${W(o)} ${w.join(",")}`)}return null}function X(){return[...document.querySelectorAll("[data-dori-ask-block]")].some(e=>{if(!i(e))return!1;const t=r(e);return t.right>0&&t.left<window.innerWidth})}async function Y(t){ae=null;const n=e(),o={placed:!1,zone:"none",device:n},r=window.__doriAskTrace;if(X())return{placed:!0,zone:"block",device:n};for(let e=0;e<=3;e++){const e=await j();if(!e)return r?.push(`${n} no_anchors`),o;if(r?.push(`${n} search=${B(e.search)}${e.isBar?"(bar)":""} cart=${B(e.cart)} menu=${B(e.menu)} header=${B(e.header)}`),T(e.header.querySelectorAll("[onclick], a[href]")))return r?.push("own_entry"),o;const a=await G(e,t,n,r);if("page_moved"!==a){if(a)return a;break}}return H(n,null),o}function J(e){window.__doriAskResult=e,window.dispatchEvent(new CustomEvent("dori:ask-button",{detail:e}))}let K=null,Q=!0,Z=null,ee=null,te=!1,ne=0,oe=0,re=0,ae=null,ie=!1,se=!1,le=0,ce=!1;const de=()=>document.querySelector(t),he=()=>window.__doriAskResult;function ue(e){return!!e&&!i(e.shadowRoot?.querySelector("button")??e)}function fe(){de()?.remove(),ae=null,he()?.placed&&J({placed:!1,zone:"none",device:e(),pending:!0})}async function pe(){if(Z&&!Q)return K||(K=(async()=>{for(;;){const t=Z,n=window.innerWidth;let o;oe++,fe();try{o=await Y(t)}catch{de()?.remove(),o={placed:!1,zone:"none",device:e()}}if(Q)return void de()?.remove();if(t!==Z||window.innerWidth!==n)continue;const r=de();return r&&(r.style.transition="opacity .2s ease",r.style.opacity="1"),re=n,void J(o)}})().finally(()=>{K=null,we()}),K)}function me(){if(ne>=10){de()?.remove(),ae=null,re=window.innerWidth;const t=he();return void((t?.placed||t?.pending)&&J({placed:!1,zone:"none",device:e()}))}ne++,pe()}let ge,we=()=>{};function be(e){const t=!Z||Z.label!==e.label||Z.aria!==e.aria;t&&(Z=e);const n=Q;if(Q=!1,!n)return void(t&&pe());if(pe(),we=()=>{se||Q||(se=!0,requestAnimationFrame(()=>{se=!1,function(){if(Q||K)return;const e=he();if(!e)return;const t=de(),n="block"===(a={placed:e.placed,zone:e.zone,pending:!0===e.pending,blockShown:X(),host:t?ue(t)?"lost":"drawn":"none",widthChanged:window.innerWidth!==re,headerChanged:Boolean(t&&ae&&L(t,ae))}).zone?a.blockShown?"keep":"redo":a.blockShown?"redo":a.placed?"drawn"!==a.host||a.widthChanged?"redo":a.headerChanged?"check_fit":"keep":a.pending||a.widthChanged?"redo":"keep";var a;"redo"===n?me():"check_fit"===n&&async function(){const e=de(),t=ae;if(ie||!e||!t)return;const n=le+1e3-performance.now();if(n>0)return void(ce||(ce=!0,setTimeout(()=>{ce=!1,we()},n)));ie=!0;const a=oe;try{await R(e);const n=()=>k(t.header,[e,...t.controls]);for(let e=0;e<3&&!(await M(n,120,1200));e++);if(a!==oe||Q||K||!e.isConnected)return;const s=function(e,t,n=o()){const a=_(e);if(!a||!t.header.isConnected)return["header_redrawn"];const s=r(a),l=[];if((s.left<0||s.right>n.w+1)&&l.push("offscreen"),(s.width<24||s.height<24)&&l.push("too_small"),t.anchor.isConnected){const e=Math.round(y(s)-y(r(t.anchor)));Math.abs(e)>4&&l.push(`not_centred_${e}`)}const c=t.controls.map(e=>e.isConnected&&i(e)),d=Math.max(0,...t.controls.map((e,n)=>c[n]?Math.abs(y(r(e))-y(s)-t.offsets[n]):0));d>3&&l.push(`item_moved_${Math.round(d)}`);const h=t.controls.filter((e,t)=>{if(!c[t])return!1;const o=r(e);return o.left<-1||o.right>n.w+1});h.length&&l.push(`pushed_offscreen_${h.length}`);const u=$(e,s,E(t.header,n));if(u&&l.push(u),s.top>=0&&s.bottom<=n.h){const o=C(e,s,t.header,n);o&&l.push(o)}return l}(e,t);window.__doriAskTrace?.push(`refit ${s.join(",")||"ok"}`);const l=s.length?null:function(e,t){if([t.anchor,...t.controls].every(e=>e.isConnected)){const n=r(t.header);return{...t,size:{w:n.width,h:n.height},layout:N(e,t)}}const n=f(),o=he()?.spot;if(!n||!o)return null;const a=o.endsWith("_search")?n.search:o.endsWith("_cart")?n.cart:n.menu;return a?A(e,n.isBar&&o.endsWith("_search")?a:m(a),n.header,D(n)):null}(e,t);if(!l)return void me();ae=l}finally{ie=!1,le=performance.now()}}()}()}))},ee=new MutationObserver(e=>{we(),ae&&e.some(e=>ae.header.contains(e.target))&&(clearTimeout(ge),ge=setTimeout(()=>we(),700))}),ee.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","hidden"]}),te)return;te=!0,setInterval(()=>{ne=0},6e4);const a=e=>{ae&&e.target instanceof Node&&ae.header.contains(e.target)&&we()};let s;document.addEventListener("transitionend",a,!0),document.addEventListener("animationend",a,!0),window.addEventListener("resize",()=>{const e=he();!K&&e?.placed&&"block"!==e.zone&&window.innerWidth!==re&&fe(),clearTimeout(s),s=setTimeout(()=>we(),200)},{passive:!0})}function ye(e){return!e.designMode&&(!e.enabled||e.banned||!e.askOn)}function _e(e,t){if(!e)return;const n=window,o=!1!==e.is_widget_enabled,r=!0===e.feature_flags?.ask_button,a=ye({enabled:o,banned:t,askOn:r,designMode:!0===n.Shopify?.designMode});if(document.querySelectorAll("[data-dori-ask-block]").forEach(e=>{a?(e.hidden=!0,e.style.setProperty("display","none","important"),e.dataset.doriHidden=""):void 0!==e.dataset.doriHidden&&(e.hidden=!1,e.style.removeProperty("display"),delete e.dataset.doriHidden)}),!r||!o||t||!1===n.DORI_HEADER_BUTTON)return Q=!0,oe++,ae=null,ee?.disconnect(),ee=null,void de()?.remove();be(function(e,t){const n=(e||"").trim().slice(0,30);return n?{label:n,aria:n}:{label:null,aria:(t||"").trim()||"Ask"}}(e.feature_flags?.ask_button_text,e.agent_name))}export{_e as applyAskButton,ye as hideBlock};
|
|
Binary file
|
|
Binary file
|