PageSourceSearch

https://artmie.hr/cdn/shop/t/41/assets/amh-reco-rerank.js?v=75159536050680288321789718709

js artmie.hr collected 2026-10-02 23:23:48 UTC 4,004 bytes, 2 lines download raw bytes

1(function(){"use strict";var CFG=window.AMH_CART_RECO||{},MARKET=String(CFG.market||"").trim().toUpperCase(),API=String(CFG.apiBase||"").replace(/\/+$/,"");if(!MARKET||!API)return;var REC_SEL='[id*="recommended_products"], [id*="alternative_products"], [data-amh-cc="1"], [id*="__plist_bestsellers"], [id*="__product_list_"]',_sid=null;function sid(){if(_sid)return _sid;try{var k="amh_sid",v=localStorage.getItem(k);v||(v="s_"+Math.random().toString(36).slice(2)+Date.now().toString(36),localStorage.setItem(k,v)),_sid=v}catch(e){_sid="s_"+Math.random().toString(36).slice(2)}return _sid}try{!(window.Shopify&&window.Shopify.customerPrivacy)&&window.Shopify&&typeof window.Shopify.loadFeatures=="function"&&window.Shopify.loadFeatures([{name:"consent-tracking-api",version:"0.1"}],function(){})}catch(e){}function consentOk(){try{var sp=window.Shopify&&window.Shopify.customerPrivacy;if(sp&&typeof sp.analyticsProcessingAllowed=="function")return!!sp.analyticsProcessingAllowed();if(typeof window.__artmieConsent=="function")return!!window.__artmieConsent("analytics");if(document.cookie.indexOf("artmie_consent=analytics")!==-1||document.cookie.indexOf("artmie_consent=all")!==-1)return!0}catch(e){}return!1}
1function handleOf(a){if(!a)return null;var h=(a.getAttribute("href")||"").split("/products/")[1];return h?h.split("?")[0].split("#")[0].replace(/\/$/,""):null}function isHome(){return/^\/([a-z]{2}(-[a-z]{2})?\/?)?$/.test(location.pathname)}function placementOf(sec){if(sec.getAttribute&&sec.getAttribute("data-amh-cc")==="1")return"cart";var id=sec.getAttribute&&sec.getAttribute("id")||"";return id.indexOf("recommended_products")!==-1||id.indexOf("alternative_products")!==-1?"pdp":(id.indexOf("__plist_bestsellers")!==-1||id.indexOf("__product_list_")!==-1)&&isHome()?"homepage":null}function cardsIn(sec){var links=[],seen={};if(sec.querySelectorAll('a[href*="/products/"]').forEach(function(a){var h=handleOf(a);h&&!seen[h]&&(seen[h]=a,links.push(h))}),links.length<2)return{map:{},order:[],container:null};for(var a1=seen[links[0]],a2=seen[links[1]],node=a1.parentNode,container=null;node&&node!==document.body;){if(node.contains(a2)){container=node;break}node=node.parentNode}if(!container)return{map:{},order:[],container:null};var map={},order=[];return links.forEach(function(h){for(var el=seen[h];el&&el.parentNode!==container;)el=el.parentNode;el&&el!==container&&(map[h]=el,order.push(h))}),{map:map,order:order,container:container}}var done=new WeakMap;function rerank(sec){if(consentOk()){var placement=placementOf(sec);if(placement){var ci=cardsIn(sec);if(!(ci.order.length<3)){var sig=ci.order.slice().sort().join("|"),prev=done.get(sec);prev&&prev.sig===sig&&prev.el===ci.map[ci.order[0]]||(done.set(sec,{sig:sig,el:ci.map[ci.order[0]]}),fetch(API+"/api/public/reco/recommend",{method:"POST",headers:{"Content-Type":"text/plain"},body:JSON.stringify({market:MARKET,placement:placement,poolHandles:ci.order,user:sid(),session:sid(),count:ci.order.length})}).then(function(r){return r.json()}).then(function(res){if(!(!res||!res.ok||res.fallback||!Array.isArray(res.cards)||!res.cards.length)){var ranked=res.cards.map(function(c){return c.handle}).filter(function(h){return ci.map[h]});if(!(ranked.length<2)){var rest=ci.order.filter(function(h){return ranked.indexOf(h)===-1}),container=ci.container;container&&(ranked.concat(rest).forEach(function(h){var card=ci.map[h];card&&card.parentNode===container&&container.appendChild(card)}),done.set(sec,{sig:sig,el:ci.map[ranked[0]]}))}}}).catch(function(){}))}}}}function scan(){document.querySelectorAll(REC_SEL).forEach(function(sec){try{rerank(sec)}catch(e){}})}var t=null;function boot(){scan();try{new MutationObserver(function(){clearTimeout(t),t=setTimeout(scan,300)}).observe(document.body,{childList:!0,subtree:!0})}catch(e){}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",boot):boot()})();
2//# sourceMappingURL=/cdn/shop/t/41/assets/amh-reco-rerank.js.map?v=75159536050680288321789718709

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.