1(function(){"use strict";try{if(window.AGB_COLLECTION_REORDER_OFF===!0)return}catch(e){}try{if(sessionStorage.getItem("AGB_COLLECTION_REORDER_OFF")==="1")return}catch(e){return}var m=(location.pathname||"").match(/^\/collections\/([a-z0-9-]+)\/?$/);if(!m)return;var collectionHandle=m[1];function log(){try{window.AGB_consoleCat&&window.AGB_consoleCat("interaction")&&console.log.apply(console,["[collection-reorder]"].concat([].slice.call(arguments)))}catch(e){}}function reorderTurnedOff(){try{var d=window.__AGB_dynamicUI;if(!d)return!1;var f=d.features||d;return f.productReorder===!1}catch(e){return!1}}function shopperChoseOrder(){var search=location.search||"";return/[?&]sort_by=/.test(search)||/[?&]filter\./.test(search)||/[?&]page=/.test(search)}function recList(){try{var sr=JSON.parse(sessionStorage.getItem("AGB_SessionRecs")||"null");if(sr&&sr.length)return{list:sr,src:"session"}}catch(e){}try{var off=JSON.parse(localStorage.getItem("recommendedProducts")||"null");if(off&&off.length)return{list:off,src:"offline"}}catch(e){}return{list:[],src:"none"}}function ownedHandles(){try{var cp=JSON.parse(localStorage.getItem("SE_colorPref")||"null"),owned=cp&&cp.answer&&cp.answer.owned;return owned&&typeof owned=="object"?owned:{}}catch(e){return{}}}var _mutations=0,_runs=0,T0=Date.now(),MAX_AGE_MS=6e3,_engaged=!1;function markEngaged(){_engaged=!0}try{window.addEventListener("scroll",markEngaged,{once:!0,passive:!0}),window.addEventListener("pointerdown",markEngaged,{once:!0,passive:!0}),window.addEventListener("keydown",markEngaged,{once:!0})}catch(e){window.addEventListener("scroll",markEngaged),window.addEventListener("pointerdown",markEngaged)}function tooLateToMove(){return _mutations>0?!1:_engaged||Date.now()-T0>MAX_AGE_MS}function unitFor(card,container){for(var el=card;el&&el.parentElement&&el.parentElement!==container;)el=el.parentElement;return el&&el.parentElement===container?el:null}function run(){if(!(_mutations>=2||_runs>=8)&&(_runs++,!shopperChoseOrder())){if(reorderTurnedOff()){log("panel switch off - leaving the collection alone");return}if(tooLateToMove()){log&&log("past the no-shift window - skipping");return}var container=document.querySelector("product-list.product-list");if(container){var cards=[].slice.call(container.querySelectorAll("product-card[handle]"));if(!(cards.length<3)){var rec=recList();if(rec.list.length){for(var rank={},i=0;i<rec.list.length;i++){var h=rec.list[i]&&rec.list[i].productLink;h&&!(h in rank)&&(rank[h]=i)}for(var owned=ownedHandles(),seen=[],keyed=[],c=0;c<cards.length;c++){var unit=unitFor(cards[c],container);if(!(!unit||seen.indexOf(unit)!==-1)){seen.push(unit);var h2=cards[c].getAttribute("handle")||"",idx=keyed.length,key;owned[h2]?key=2e6+idx:h2 in rank?key=rank[h2]:key=1e6+idx,keyed.push({unit:unit,handle:h2,key:key,idx:idx})}}if(!(keyed.length<3)){var before=keyed.map(function(k){return k.handle});keyed.sort(function(a,b){return a.key-b.key||a.idx-b.idx});for(var after=keyed.map(function(k){return k.handle}),moved=0,j=0;j<before.length;j++)before[j]!==after[j]&&moved++;if(moved){var frag=document.createDocumentFragment();keyed.forEach(function(k){frag.appendChild(k.unit)}),container.appendChild(frag),_mutations++;try{var role=window.Shopify&&window.Shopify.theme&&window.Shopify.theme.role,eng=window.SE_Engine;if(role!=="main"&&eng&&eng.debugToastsEnabled&&typeof eng._emitInfoToast=="function"){var demoted=Object.keys(owned).filter(function(h3){return before.indexOf(h3)!==-1}).length;eng._emitInfoToast("collectionReorder","RECO \xB7 COLLECTION",'Collection "'+collectionHandle+'" personalized: '+moved+" of "+keyed.length+" products moved ("+rec.src+" recs first"+(demoted?", "+demoted+" owned moved last":"")+")",{source:"reco",kind:"info"})}}catch(e){}try{window.CAEDev&&typeof window.CAEDev.emit=="function"&&window.CAEDev.emit("collection_reorder",{collection:collectionHandle,src:rec.src,moved:moved,total:keyed.length,owned_demoted:Object.keys(owned).filter(function(h3){return before.indexOf(h3)!==-1}).length})}catch(e){}}}}}}}}function haveList(){var r=recList();return!!(r&&r.list&&r.list.length)}function bootNow(){return haveList()&&document.querySelector("product-list.product-list")?(log("recommendations already stored - ordering before first paint"),run(),!0):!1}function watchForGrid(){if(!bootNow()){var give_up=Date.now()+4e3,obs=new MutationObserver(function(){(bootNow()||Date.now()>give_up)&&obs.disconnect()});try{obs.observe(document.documentElement,{childList:!0,subtree:!0})}catch(e){}setTimeout(function(){obs.disconnect(),run()},4e3)}}document.addEventListener("agb:recs-applied",function(){run()}),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",watchForGrid):watchForGrid()})(); 2//# sourceMappingURL=/cdn/shop/t/118/assets/collection-reorder.js.map?v=21254521318508968071789044324
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.