PageSourceSearch

https://www.maccosmetics.com/cdn/shop/t/199/assets/findation-cta.DBygiFiZ.min.js

js maccosmetics.com collected 2026-10-02 02:34:17 UTC 6,274 bytes, 1 lines download raw bytes

1import{F as t}from"./flattenedDeepLink.Bln01QHp.min.js";import{o as e,L as i}from"./livePersonChat.C5pjShJ9.min.js";import{t as n,f as o,T as s}from"./vendor-lit.2u3dzq2T.min.js";Object.getOwnPropertyDescriptor;const r=new WeakMap;function d(t,e,i){const n=r.get(t)??{};r.set(t,n);const o=n[e];if(o)return void(o.own=i);const s={own:i,foreign:t[e],running:!1};n[e]=s;const d=(...e)=>{if(!s.running){s.running=!0;try{return s.own(...e)}finally{const i=s.foreign;if("function"==typeof i)try{i.call(t,...e)}catch{}s.running=!1}}};Object.defineProperty(t,e,{configurable:!0,enumerable:!0,get:()=>d,set:t=>{t!==d&&(s.foreign=t)}})}let a=class extends o{constructor(){super(...arguments),this.scriptPromise=null,this.lastResult=null,this.descMap=null,this.scopeRoot=document,this.embedConfirmed=!1,this.embedTimer=null,this.handleClick=()=>{const t=window.Findation;if(t&&"function"==typeof t.openWidget)try{t.openWidget()}catch{this.showError()}else this.showError()},this.handleFlattenedSelect=t=>{const e=t.detail;(null==e?void 0:e.handle)&&this.syncDesc(e.handle)}}createRenderRoot(){return document.createDocumentFragment()}render(){return s}connectedCallback(){var t;super.connectedCallback(),this.scopeRoot=this.closest("flattened-main-product")??document,null==(t=this.trigger)||t.addEventListener("click",this.handleClick),this.bindDescSync(),this.embedTimer=window.setTimeout(()=>{this.embedTimer=null,this.embedConfirmed||this.withdraw()},8e3),this.embed()}disconnectedCallback(){var e;super.disconnectedCallback(),null==(e=this.trigger)||e.removeEventListener("click",this.handleClick),this.scopeRoot.removeEventListener(t,this.handleFlattenedSelect),null!==this.embedTimer&&(window.clearTimeout(this.embedTimer),this.embedTimer=null)}get formScope(){return this.closest("flattened-product-form")??document}get trigger(){return this.formScope.querySelector("[data-findation-trigger]")}get row(){var t;return(null==(t=this.trigger)?void 0:t.closest(".vto-cta-row"))??null}async embed(){const t=this.dataset.apiKey,e=this.querySelector("[data-findation-mount]");if(this.isConnected)if(t){if(e)try{const i=await this.loadScript();if(!this.isConnected)return;d(i,"widgetEmbedded",()=>this.reveal()),d(i,"widgetDidClose",()=>this.handleClose()),d(i,"onSearchComplete",t=>{this.lastResult=t??null}),d(i,"onActionReceived",t=>this.handleAction(t));const n={};this.dataset.productId&&(n.productId=this.dataset.productId),this.dataset.productUrl&&(n.productUrl=window.location.origin+this.dataset.productUrl),i.init(e,t,n)}catch{this.withdraw()}}else this.withdraw()}loadScript(){return this.scriptPromise||(this.scriptPromise=new Promise((t,e)=>{const i=window.setTimeout(()=>{e(new Error("Findation: script load timed out"))},1e4),n=document.createElement("script");n.src="https://assets.findation.com/javascripts/w-adv-13.min.js",n.async=!0,n.onload=()=>{window.clearTimeout(i);const n=window.Findation;n&&"function"==typeof n.init?t(n):e(new Error("Findation: script loaded without its API"))},n.onerror=()=>{window.clearTimeout(i),e(new Error("Findation: script failed to load"))},document.head.appendChild(n)}),this.scriptPromise.catch(()=>{this.scriptPromise=null})),this.scriptPromise}reveal(){if(this.embedConfirmed=!0,!this.isConnected)return;null!==this.embedTimer&&(window.clearTimeout(this.embedTimer),this.embedTimer=null);const t=this.trigger,e=this.row;t&&e&&(t.disabled=!1,t.hidden=!1,e.hidden=!1,e.querySelector("[data-vto-trigger]")&&(e.dataset.ctaCount="2",this.placeDesc(e)))}placeDesc(t){const e=t.querySelector("[data-shade-desc]");e&&("2"===t.dataset.ctaCount?e!==t.lastElementChild&&t.append(e):e!==t.firstElementChild&&t.prepend(e))}withdraw(){if(!this.isConnected)return;const t=this.trigger,e=this.row;if(!t||!e)return;if(t.hidden=!0,e.querySelector("[data-vto-trigger]"))return e.dataset.ctaCount="1",void this.placeDesc(e);const i=e.querySelector("[data-findation-desc]");Object.values(this.descMap??{}).some(t=>t)||i&&!i.hidden&&""!==(i.textContent??"").trim()||(e.hidden=!0)}handleClose(){var t,e;null==(t=this.trigger)||t.focus(),(null==(e=this.lastResult)?void 0:e.matchSuccess)&&this.applyRecommendation(this.lastResult)}handleAction(t){var e,i;if("string"!=typeof t)return;if(/^https?:\/\//.test(t))return void window.open(t,"_blank","noopener");const[n,o]=t.split("::");if("event"===n){const[t]=(o??"").split("||");return void("live_chat"===t&&this.openLiveChat())}"changeSku"===n&&o?this.applyRecommendation({matchSuccess:!0,externalId:o,recommendedShade:o}):(null==(e=this.lastResult)?void 0:e.matchSuccess)&&(this.applyRecommendation(this.lastResult),null==(i=window.Findation)||i.closeWidget())}openLiveChat(){var t,n;if("pdp"===this.dataset.chatMode&&e())return void(null==(t=window.Findation)||t.closeWidget());const o=(this.dataset.chatPage??"").trim().split("#")[0];o&&(null==(n=window.Findation)||n.closeWidget(),window.location.assign(o+i))}applyRecommendation(t){const e=this.findRadio(t);e&&!e.checked&&(e.checked=!0,e.dispatchEvent(new Event("change",{bubbles:!0})))}findRadio(t){const e=t=>t.replace(/[\u200B-\u200D\uFEFF]/g,"").trim().toLowerCase(),i=Array.from(this.formScope.querySelectorAll('input[type="radio"][data-child-handle]')),n=e(t.externalId??"");if(n){const t=i.find(t=>e(t.dataset.sku??"")===n);if(t)return t}const o=e(t.recommendedShade??"");if(o){const t=i.find(t=>e(t.value)===o);if(t)return t}return null}showError(){const t=this.querySelector("[data-findation-error]");t&&(t.textContent=this.dataset.msgLoadError??"",t.hidden=""===t.textContent)}bindDescSync(){var e;const i=null==(e=this.querySelector("script[data-findation-desc-map]"))?void 0:e.textContent;if(!this.formScope.querySelector("[data-findation-desc]")||!i)return;try{this.descMap=JSON.parse(i)}catch{return}this.scopeRoot.addEventListener(t,this.handleFlattenedSelect);const n=this.formScope.querySelector('input[type="radio"][data-child-handle]:checked');(null==n?void 0:n.dataset.childHandle)&&this.syncDesc(n.dataset.childHandle)}syncDesc(t){var e;const i=this.formScope.querySelector("[data-findation-desc]");if(!i)return;const n=(null==(e=this.descMap)?void 0:e[t])??"";i.textContent=n,i.hidden=""===n}};a=((t,e)=>{for(var i,n=e,o=t.length-1;o>=0;
1o--)(i=t[o])&&(n=i(n)||n);return n})([n("findation-cta")],a);export{a as FindationCta};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.