PageSourceSearch

https://www.lyleandscott.com/cdn/shop/t/458/assets/weglot.js?v=38740280814405965521788364385

js lyleandscott.com collected 2026-09-24 22:59:54 UTC 4,534 bytes, 2 lines download raw bytes

1const SOURCE_LANGUAGE="en",LOCALE_PREFIX_PATTERN=/^[a-z]{2}(?:-[a-z]{2})?$/i,ABSOLUTE_ROUTE_PATTERN=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,WEGLOT_TIMEOUT_MS=2e3,WEGLOT_POLL_INTERVAL_MS=50,KLAVIYO_POLL_INTERVAL_MS=500,KLAVIYO_POLL_LIMIT=40,KLAVIYO_FORM_SELECTOR='form[data-testid^="klaviyo-form-"], form[data-newsletter-form]',translationCache=new Map;let klaviyoLanguageSyncStarted=!1;function currentLocalePrefix(){const[firstSegment=""]=window.location.pathname.split("/").filter(Boolean);return LOCALE_PREFIX_PATTERN.test(firstSegment)?`/${firstSegment}`:""}export function getLocalisedRoute(route="/"){if(!route||route.startsWith("#"))return route;let path=route.startsWith("/")?route:`/${route}`;if(ABSOLUTE_ROUTE_PATTERN.test(route)){const url=new URL(route,window.location.origin);if(url.origin!==window.location.origin)return route;path=`${url.pathname}${url.search}${url.hash}`}const localePrefix=currentLocalePrefix();return!localePrefix||path===localePrefix||path.startsWith(`${localePrefix}/`)?path:path==="/"?`${localePrefix}/`:`${localePrefix}${path}`}function currentLanguage(){const urlLanguage=currentLocalePrefix().slice(1);return(window.Weglot?.getCurrentLang?.()||urlLanguage||document.documentElement.lang||"en").toLowerCase().split("-")[0]}function preferredSearchTerm(query){const normalisedQuery=query.trim().toLowerCase();return{pantalon:"trousers",pantal\u00F3n:"trousers",pantalones:"trousers"}[normalisedQuery]||query.replace(/\bpants\b/gi,"trousers")}function waitForWeglot(isReady=weglot=>!!weglot,timeoutMs=2e3){return isReady(window.Weglot)?Promise.resolve(window.Weglot):new Promise(resolve=>{const startedAt=Date.now(),interval=window.setInterval(()=>{if(isReady(window.Weglot)){window.clearInterval(interval),resolve(window.Weglot);return}Date.now()-startedAt>=timeoutMs&&(window.clearInterval(interval),resolve(null))},50)})}function waitForWeglotSearch(){return waitForWeglot(weglot=>!!weglot?.search)}export function waitForWeglotApi(){return waitForWeglot(weglot=>!!weglot?.getCurrentLang&&!!weglot?.switchTo&&!!weglot?.options?.language_from,5e3)}async function translateSearchQuery(query){const normalisedQuery=query.trim();if(!normalisedQuery||currentLanguage()==="en")return query;const cacheKey=`${currentLanguage()}:${normalisedQuery}`;if(translationCache.has(cacheKey))return translationCache.get(cacheKey);const weglot=await waitForWeglotSearch();return weglot?new Promise(resolve=>{const timeout=window.setTimeout(()=>resolve(query),2e3);try{weglot.search(normalisedQuery,translatedQuery=>{window.clearTimeout(timeout);const preferredQuery=preferredSearchTerm(translatedQuery||normalisedQuery);preferredQuery!==normalisedQuery&&translationCache.set(cacheKey,preferredQuery),resolve(preferredQuery)})}catch{window.clearTimeout(timeout),resolve(query)}}):query}export async function translateWeglotSearchRequests(requests){if(currentLanguage()==="en")return requests;const queries=[...new Set(requests.map(request=>new URLSearchParams(request.params).get("query")).filter(Boolean))];if(!queries.length)return requests;const translations=new Map(await Promise.all(queries.map(async query=>[query,await translateSearchQuery(query)])));return requests.map(request=>{const params=new URLSearchParams(request.params),query=params.get("query"),translatedQuery=translations.get(query);return!translatedQuery||translatedQuery===query?request:(params.set("query",translatedQuery),{...request,params:params.toString()})})}export function startKlaviyoLanguageSync(){if(klaviyoLanguageSyncStarted)return;klaviyoLanguageSyncStarted=!0;let lastIdentifiedLanguage="";const identify=(language,force=!1)=>{const activeLanguage=(language||window.Weglot?.getCurrentLang?.()||document.documentElement.lang)?.toLowerCase().split("-")[0];!activeLanguage||!document.querySelector(KLAVIYO_FORM_SELECTOR)||!window.klaviyo?.push||!force&&lastIdentifiedLanguage===activeLanguage||(window.klaviyo.push(["identify",{lang:activeLanguage}]),lastIdentifiedLanguage=activeLanguage)},bindWeglotEvents=()=>window.Weglot?.on?(window.Weglot.on("languageChanged",language=>identify(language,!0)),window.Weglot.on("switchersReady",identify),identify(),!0):!1;if(document.addEventListener("submit",event=>{event.target.matches?.(KLAVIYO_FORM_SELECTOR)&&identify(null,!0)},!0),bindWeglotEvents())return;let pollCount=0;const interval=window.setInterval(()=>{pollCount+=1,(bindWeglotEvents()||pollCount>=40)&&window.clearInterval(interval)},500)}
2//# sourceMappingURL=/cdn/shop/t/458/assets/weglot.js.map?v=38740280814405965521788364385

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.