'use strict';mix_d("P13NSCCards__p13n-desktop-carousel:p13n-desktop-carousel__pqNWcOJ9","exports tslib @p/A @c/metrics @c/aui-carousel @c/dom @c/remote-operations @c/scoped-dom @p/a-carousel-framework @c/logger @c/aui-untrusted-ajax @c/browser-operations @c/aui-modal @c/aui-utils @p/jQuery".split(" "),function(ba,m,pa,z,qa,ca,ra,sa,ta,ua,va,wa,xa,ya,za){function F(a){return a&&"object"===typeof a&&"default"in a?a:{"default":a}}var v=F(pa),Aa=F(qa),M=F(ca),N=F(ra),w=F(sa),Ba=F(ta),B=F(ua),U=F(va),
T=F(wa),Ca=F(xa),V=F(ya),y=F(za),da={},W=function(a,c,b){void 0===c&&(c="");void 0===b&&(b=1);c=a+c;da.hasOwnProperty(c)||(da[c]=!0,z.count(a,(z.count(a)||0)+b))},Da=function(a){W(v["default"].capabilities.mobile?"Card:EERU:SharedLib:mobile:render":"Card:EERU:SharedLib:desktop:render");var c=function(d,e){d={$event:{preventDefault:v["default"].$.noop,stopPropagation:v["default"].$.noop},$target:d.getContent().find('[data-a-tab-name="'+e+'"]'),data:{name:"energyEfficiencyTabSet"}};v["default"].trigger("a:declarative:a-tabs:click",
d)},b=function(d,e){var f=d&&d.$event,g=d&&d.data||{},n=g.activeTabName,h=g.modalHeight,r=g.name;f&&f.preventDefault&&f.preventDefault();f&&f.stopPropagation&&f.stopPropagation();f=e.get(r);f||(v["default"].on("a:popover:beforeShow:"+r,function(k){k.popover&&k.popover.getContent&&(k=k.popover.getContent(),k.find(".a-manually-loaded").parent().css("min-height",h),v["default"].loadDescendantImagesManually(k))}),f=e.create(d.$target,g));f.show();c(f,n)};a.when("a-secondary-view").execute("RegisterEnergyEfficiencyEventMobile",
function(d){v["default"].declarative("card-energy-efficiency-secondary-view","click",function(e){W("Card:EERU:SharedLib:mobile:click",e&&e.data&&e.data.name||"");b(e,d)})});a.when("a-modal").execute("RegisterEnergyEfficiencyEventDesktop",function(d){v["default"].declarative("card-energy-efficiency-modal","click",function(e){W("Card:EERU:SharedLib:desktop:click",e&&e.data&&e.data.name||"");b(e,d)})})},Ea=function(a){a.when("ready").execute("EEBadgeProductFicheResize",function(c){var b=v["default"].$;
b(".energyEfficiencyContainer").each(function(d,e){d=b(e).find(".energyEfficiencyProductFicheLabel").first();e=b(e).find("svg").first();d.parent().outerHeight()>e.outerHeight()&&(d.removeClass("a-size-small"),d.addClass("a-size-micro"),d.parent().outerHeight()>e.outerHeight()&&d.parent().css("line-height","10px"))})})},Fa={ctiList:["Website/Personalization/Report a Problem CX"],category:"Website",type:"Personalization",item:"Report a Problem CX",folder:"9c9c97c9-6f69-4dba-a55d-26045c6a3068",group:"P13N Report a Problem CX"},
Ga=[{ctiList:["Website/Personalization/Similarities","Website/Detail Page/Similarities"],category:"Website",type:"Personalization",item:"Similarities",folder:"4d16d05d-9a17-4b36-b8fe-9ee159ff81de",group:"Similarities"}],Ka=function(a){var c=w["default"].cardRoot.querySelector(".p13n-report-flag"),b=T["default"].setup();b.define("showFlag","mouseover",function(){c.classList.remove("p13n-report-flag-hide")});b.define("hideFlag","mouseout",function(){c.classList.add("p13n-report-flag-hide")});b.attach("showFlag",
a);b.attach("hideFlag",a);var d=w["default"].cardRoot.querySelector(".internal-flag-form"),e=d.querySelector(".internal-flag-env-data").dataset,f=d.querySelector(".internal-flag-title-text"),g=d.querySelector(".internal-flag-description").firstElementChild,n=d.querySelector(".internal-flag-alias"),h=d.querySelector(".internal-flag-response-message"),r=function(k){k.preventDefault();k=function(p){return!p||!p.trim()};if(k(f.value)||k(g.value)||k(n.value))return X(h,!1,"Something went wrong. One of the required fields was missing."),
!1;k=w["default"].cardRoot.querySelectorAll(".a-dynamic-image");var q;if(q=w["default"].cardRoot.querySelector(".a-carousel-heading")){var t=Ha(a,k.length);q="Internal user reported issue '"+f.value+"' with widget: "+q.innerText}else t=Ia(a),q="Internal user reported issue '"+f.value+"'";k=Ja(k,t,g.value,n.value,e);var l=Fa;Ga.forEach(function(p){p.ctiList.includes(e.cti)&&(l=p)});U["default"].post("https://p13ngoals.corp.amazon.com/sims",{accepts:"text/html, application/json",contentType:"application/json;charset=UTF-8"},
{sim_params:{assigned_folder:l.folder,description:k,descriptionContentType:"text/amz-markdown-sim",extensions:{tt:{assignedGroup:l.group,category:l.category,impact:5,item:l.item,type:l.type}},tags:[{id:"internal-problem-generated"}],title:q}}).then(function(p){X(h,!0,p)}).catch(function(p){X(h,!1,p)});return!1};d.onsubmit=function(k){return r(k)};b=w["default"].cardRoot.querySelector(".p13n-desktop-report-problem-flag-data");if(b.dataset.name)v["default"].on("a:popover:hide:"+b.dataset.name,function(){d.reset();
h.innerText=""})},Ha=function(a,c){if(!a.dataset.aCarouselOptions)return B["default"].log("Empty ASIN List in carouselElement.dataset.aCarouselOptions","ERROR"),[];a=JSON.parse(a.dataset.aCarouselOptions).ajax.id_list;var b=w["default"].cardRoot.querySelector(".a-carousel-firstvisibleitem");b=(Number(b.value)||1)-1;return a.map(function(d){return JSON.parse(d).id}).slice(b,b+c)},Ia=function(a){return(a=a.dataset.asinList)?a.split(","):[]},Ja=function(a,c,b,d,e){for(var f="",g=0;g<a.length;g++){var n=
a[g];f+=(n?"![]("+n.src+")":"IMAGE MISSING")+"\nASIN: "+(c[g]?c[g]:"ASIN MISSING")+"\n\n"}return"**This SIM-T ticket is created by the 'Report a Problem' internal tool. To know more, here's its wiki: https://w.amazon.com/bin/view/Personalization/CoreRecommendations/Projects/Canaries/Report-a-Problem-UX-on-P13NWidget/UserGuide/**\n\n**Alias:** ["+(d+"](https://phonetool.amazon.com/users/"+d+")\n**Comment:** "+b+"\n\n**Widget Group ID:** "+e.widgetGroupId+"\n**Strategy ID:** "+e.strategyId+"\n**CTI:** "+
e.cti+"\n**Facets:** ")+(e.facets+"\n**Content Reftag:** "+e.reftag+"\n"+(""!==e.baseAsin?"**Page ASIN:** "+e.baseAsin+"\n":"")+"\n**SessionID:** ")+(e.sessionId+"\n**MarketplaceID:** "+e.marketplaceId+"\n**Device Type:** "+e.deviceType+"\n\n**List of ASINs:**\n\n")+f},X=function(a,c,b){c?(a.classList.remove("a-color-error"),b.responseBody&&"object"===typeof b.responseBody?b.responseBody.response&&b.responseBody.response.id?a.innerHTML="Success, here's the <a href=\"https://t.corp.amazon.com/"+b.responseBody.response.id+
'" target="_blank">SIM-T ticket</a> you created.':(B["default"].log("Fail to find the id of the SIM-T ticket created in the response body of response data.","ERROR"),a.innerText="Success, but we could not find the link to the SIM-T ticket."):(B["default"].log("The response body of response data is not an object.","ERROR"),a.innerText="Success, but we could not find the link to the SIM-T ticket.")):(a.classList.add("a-color-error"),a.innerText="string"===typeof b?b:"Oops! Something went wrong. Please try again.")},
La={setupModal:function(a){return m.__awaiter(void 0,void 0,void 0,function(){var c;return m.__generator(this,function(b){c=w["default"].cardRoot.querySelector(".p13n-report-problem-modal-root");if(!c)return[2];Ka(a);return[2]})})}},Ma=N["default"].setup(["getLazyLoadDeliveryMessage"]),Na=function(a){return m.__awaiter(void 0,void 0,void 0,function(){var c,b,d;return m.__generator(this,function(e){switch(e.label){case 0:c=a.querySelectorAll("[data-udm-asin]:not([data-requested=true])");if(!c.length)return[2,
void 0];b=[];c.forEach(function(f){var g=f.dataset.udmAsin,n=f.dataset.udmMerchantId,h=f.dataset.udmBlockSize,r=f.dataset.udmLayoutSize,k="true"===f.dataset.udmBadgeWithoutProgramName;g&&n&&h&&(b.push({asin:g,merchantId:n,blockSize:h,layoutSize:r,badgeWithoutProgramName:k}),f.dataset.requested="true")});return b.length?[4,Ma.getLazyLoadDeliveryMessage({lazyLoadDeliveryMessageViewModels:b})]:[2,void 0];case 1:return d=e.sent(),[2,[].slice.call(d.querySelectorAll("[data-udm-asin]:not([data-requested=true])"))]}})})},
Oa=function(a){return m.__awaiter(void 0,void 0,void 0,function(){var c;return m.__generator(this,function(b){switch(b.label){case 0:return[4,Na(a)];case 1:c=b.sent();if(!c)return[2];c.map(function(d){var e=d.dataset.udmAsin,f=d.dataset.udmMerchantId;e&&f&&(e=a.querySelector("[data-udm-asin="+e+"][data-udm-merchant-id="+f+"]"))&&(e.outerHTML=d.innerHTML)});return[2]}})})},ea=[],Pa=function(a){var c=Array.prototype.slice.call(a.querySelectorAll("[data-metrics]"));c.push(a);c.forEach(function(b){if(b&&
b.dataset&&b.dataset.metrics&&(!b.id||!ea.includes(b.id))){var d=JSON.parse(b.dataset.metrics),e;for(e in d)d.hasOwnProperty(e)&&z.count(e,d[e]);b.removeAttribute("data-metrics");b.id&&ea.push(b.id)}})},fa=/(?=[ \-\/])|(?=[\u3105-\u312F])|(?=[\u31A0-\u31BA])|(?=[\u4E00-\u9FD5])|(?=[\u3400-\u4DB5])|(?=[\uF900-\uFAFF])|(?=[\u3040-\u309F])|(?=[\u30A0-\u30FF])|(?=[\u3190-\u319F])/,ha=/[^\/\-\[\]():\s]/,Qa=function(a){var c=v["default"].$("<div>")[0];c.classList.add("p13n-sc-offscreen-truncate");var b=
parseInt(a.getAttribute("data-rows")||"2",10),d=function(){var g=a.innerHTML;a.innerHTML="&hellip;";var n=a.clientHeight;a.innerHTML=g;return n}();if(b){if(d){var e=function(g){c.innerHTML=g;return Math.round(c.clientHeight/d)<=b},f=function(g,n){g=g.split(n);var h=Math.floor(a.clientWidth/12),r=function(q){c.classList.add("p13n-sc-offscreen-truncate");c.style.overflow="hidden";c.textContent=q;a.appendChild(c);q=a.clientWidth>=a.scrollWidth;a.removeChild(c);return q},k=function(q){var t=q.length-
h;q.trim().length>h&&!r(q)&&Array.prototype.slice.call(q).map(function(l,p){return p>h&&p<=t&&ha.test(l)?"&shy;"+l:l});return q};return g.map(function(q){return k(q)}).join("")};return{truncate:function(){var g=a.innerHTML.trim(),n=a.textContent||"";g=f(g,fa);a.appendChild(c);if(e(g))a.removeChild(c),a.innerHTML=g;else{var h=g.split(fa);for(var r=1,k=h.length,q,t,l=0;r!==k;)if(q=Math.floor((k+r)/2),t=h.slice(0,q).join("")+"&hellip;",e(t)){if(1>=k-q){for(l=q;0<l&&!ha.test(h[l-1]);)l--;break}r=q}else k=
q;h=0===l?void 0:h.slice(0,l).join("")+"&hellip;";h?(a.innerHTML=h,a.setAttribute("title",n),a.setAttribute("aria-label",n)):(B["default"].log("Unable to successfully truncate line "+g,"ERROR"),a.removeChild(c))}}}}B["default"].log("Truncation element does not have a line height or it is zero","ERROR")}else B["default"].log("Truncation element missing necessary line number data","ERROR")},Ra=function(a){var c=Array.prototype.slice.call(a.getElementsByClassName("p13n-sc-truncate"));a=a.getElementsByClassName("p13n-sc-truncate-fallback");
(window.CSS&&CSS.supports&&CSS.supports("-webkit-line-clamp","1")?c:c.concat(Array.prototype.slice.call(a))).filter(function(b){return!!b.offsetParent}).map(function(b){var d=Qa(b);d&&(d.truncate(),b.classList.add("p13n-sc-truncated"),b.classList.remove("p13n-sc-truncate"),b.classList.remove("p13n-sc-truncate-fallback"),b.className=b.className.replace(/p13n-sc-line-clamp-\d/g,""))})},Sa=function(a){a.querySelectorAll(".a-carousel-viewport").forEach(function(c){c=c.querySelectorAll(".a-carousel-card");
for(var b=null,d=0;d<c.length;d++){var e=c[d].getAttribute("aria-roledescription");if(null!==e&&""!==e){b=e;break}}b=b||"slide";c.forEach(function(f){f.getAttribute("aria-roledescription")!==b&&f.setAttribute("aria-roledescription",b)})})},Y=function(a){return 0===Math.floor(a/10)?"0"+a.toString():a.toString()},Ta=function(a){var c=Date.now();var b=a.dayscountdowntoendtemplate,d=a.expiredstring,e=a.hourscountdowntoendtemplate,f=a.minutescountdowntoendtemplate;a=parseInt(a.endtime,10);if(c<=a){d=null;
var g=a-c;a=Math.floor(g/864E5);var n=Math.floor(g/36E5);c=Math.floor(g/6E4%60);g=Math.floor(g/1E3%60);if(1<a&&b&&(d=b,null!==d))return b=d.replace("${daysCount}",a.toString());f&&(d=0===n?f:e);return null!==d?(b=d.replace("_hours_",Y(n)),b=b.replace("_minutes_",Y(c)),b=b.replace("_seconds_",Y(g))):""}return d},Ua=function(a){if(null!==a&&a.dataset.endtime){a.dataset.callbackAttached="true";var c=setInterval(function(){a.innerText===a.dataset.expiredstring&&clearInterval(c);var b=Ta({dayscountdowntoendtemplate:a.dataset.dayscountdowntoendtemplate||
"",endtime:a.dataset.endtime||"",expiredstring:a.dataset.expiredstring||"",hourscountdowntoendtemplate:a.dataset.hourscountdowntoendtemplate||"",minutescountdowntoendtemplate:a.dataset.minutescountdowntoendtemplate||""});a.innerText=b},1E3)}},Q=function(a,c){return a.querySelector("[class*="+c+"]")},Va=function(a,c,b){a=JSON.parse(a);a.adCreativeMetaData=c.adCreativeMetaData;a.feedbackFormContainerId=b;return encodeURI(JSON.stringify(a))},Wa=function(a,c,b){return m.__awaiter(void 0,void 0,void 0,
function(){var d,e,f,g,n,h,r;return m.__generator(this,function(k){d="adFeedbackModal_"+a;k=(null===(r=Q(c,"ad-feedback-modal-container"))||void 0===r?void 0:r.className)||"";e="."+c.className+" ."+k.replace(" ",".");g=(f=b().adCreativeMetaData.adCreativeDetails)?f.length:0;n={a11yOpenMessage:"",width:Math.max(560,125*g+130)};try{return h=Ca["default"].create(d,e,n),[2,h]}catch(q){throw z.count("adfeedback:cards:clientDesktop:modalCreation:failure",1),Error("Modal Creation Failed : "+q);}})})},Za=
function(a,c,b,d,e,f,g){var n="rtl"===document.getElementsByTagName("html")[0].dir?"ad-feedback-loading-spinnner-rtl":"ad-feedback-loading-spinnner";var h=Q(M["default"].cardRoot,n);a.on("beforeShow",function(){return m.__awaiter(void 0,void 0,void 0,function(){var r,k;return m.__generator(this,function(q){switch(q.label){case 0:return r=Xa(a,c,b),[4,a.render(function(t){var l="250px",p=b().adCreativeMetaData.adCreativeDetails;p&&2>p.length&&(l="150px");h.style.marginTop=l;t.innerHTML="";l=t.appendChild;
p=document.getElementsByTagName("html")[0].dir;var u=M["default"].createElement("div"),x=M["default"].createElement("div");u.innerHTML=e;"rtl"===p?(u.setAttribute("style",'box-sizing: border-box; color: rgb(15, 17, 17); font-family: "Amazon Ember", Arial, sans-serif; font-size: 16px; font-weight: 700; line-height: 24px; margin-bottom: 0px; margin-left: 28px; margin-right: 0px; margin-top: 0px; min-height: 56px; padding-bottom: 16px; padding-left: 0px; padding-right: 25px; padding-top: 16px; text-align: right; text-rendering: optimizelegibility; visibility: visible;'),
x.setAttribute("style",'background-attachment: scroll; background-clip: border-box; background-color: rgb(240, 242, 242); background-image: linear-gradient(to left, #EFEFEF 66.72%, #FFFFFF); background-origin: padding-box; background-position: 0% 0%; background-position-x: 0%; background-position-y: 0%; background-repeat: repeat; background-size: auto; border-bottom-color: rgb(213, 217, 217); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-top-left-radius: 8px; border-top-right-radius: 8px; box-sizing: border-box; color: rgb(15, 17, 17); display: block; font-family: "Amazon Ember", Arial, sans-serif; font-size: 14px; line-height: 20px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 24px; padding-right: 24px; padding-top: 0px; position: relative; text-align: right; visibility: visible; z-index: 10;')):
(u.setAttribute("style",'box-sizing: border-box; color: rgb(15, 17, 17); font-family: "Amazon Ember", Arial, sans-serif; font-size: 16px; font-weight: 700; line-height: 24px; margin-bottom: 0px; margin-left: 0px; margin-right: 28px; margin-top: 0px; min-height: 56px; padding-bottom: 16px; padding-left: 25px; padding-right: 0px; padding-top: 16px; text-align: left; text-rendering: optimizelegibility; visibility: visible;'),x.setAttribute("style",'background-attachment: scroll; background-clip: border-box; background-color: rgb(240, 242, 242); background-image: linear-gradient(to right, #EFEFEF 66.72%, #FFFFFF); background-origin: padding-box; background-position: 0% 0%; background-position-x: 0%; background-position-y: 0%; background-repeat: repeat; background-size: auto; border-bottom-color: rgb(213, 217, 217); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-top-left-radius: 8px; border-top-right-radius: 8px; box-sizing: border-box; color: rgb(15, 17, 17); display: block; font-family: "Amazon Ember", Arial, sans-serif; font-size: 14px; line-height: 20px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 24px; padding-right: 24px; padding-top: 0px; position: relative; text-align: left; visibility: visible; z-index: 10;'));
x.appendChild(u);l.call(t,x);l=document.getElementsByTagName("html")[0].dir;p=M["default"].createElement("div");"rtl"===l?p.setAttribute("style","padding-bottom: 16px; padding-right: 50px ; padding-top: 16px; justify-content: center; align-items: center;"):p.setAttribute("style","padding-bottom: 16px; padding-left: 50px ; padding-top: 16px; justify-content: center; align-items: center;");Ya(h,p,d,r,f);t.appendChild(p)})];case 1:return q.sent(),(k=document.querySelector(".a-button-close"))&&k.setAttribute("aria-label",
g),[2]}})})})},Xa=function(a,c,b){b=b();var d=b.adCreativeMetaData.adCreativeDetails;null===d||void 0===d?void 0:d.sort(function(e,f){return e.adCreativeIndex<f.adCreativeIndex?-1:1});return Va(c,b,a.id)},Ya=function(a,c,b,d,e){c.appendChild(a);"function"==typeof z.uet&&z.uet("bb","adfeedback:cards:clientDesktop:fetchFormContent:time",{wb:1});U["default"].post("/af/multi-creative/feedback-form",{accepts:"application/json",contentType:"application/json",additionalHeaders:{"Accept-Language":""===b?
"en-US":b}},{pl:d,deviceType:"desktop"}).then(function(f){return m.__awaiter(void 0,void 0,void 0,function(){var g,n,h;return m.__generator(this,function(r){"function"==typeof z.uet&&z.uet("be","adfeedback:cards:clientDesktop:fetchFormContent:time",{wb:1});z.count("adfeedback:cards:clientDesktop:fetchFormContent:success",1);g=M["default"].createElement("div");g.innerHTML=String(f.responseBody);for(n=0;n<g.children.length;++n)h=g.children[n],"SCRIPT"===h.tagName?Z("script",h,c):"LINK"===h.tagName?
Z("link",h,c):Z("div",h,c);c.removeChild(a);return[2]})})}).catch(function(){"function"==typeof z.uet&&z.uet("be","adfeedback:cards:clientDesktop:fetchFormContent:time",{wb:1});z.count("adfeedback:cards:clientDesktop:fetchFormContent:failure",1);c.innerHTML=e});"function"==typeof z.uex&&z.uex("ld","adfeedback:cards:clientDesktop:fetchFormContent:time",{wb:1})},Z=function(a,c,b){var d=M["default"].createElement(a);d.innerHTML=c.innerHTML;c.getAttributeNames().forEach(function(e){d.setAttribute(e,c.getAttribute(e)||
"")});b.appendChild(d)},ia={},$a=function(a,c){return m.__awaiter(void 0,void 0,void 0,function(){var b,d,e,f,g,n,h,r,k;return m.__generator(this,function(q){b=Q(a,"ad-feedback-primary-link");d=c().adFeedbackLabelId;e=T["default"].setup();f="open-modal"+d;g=c().adCreativeMetaData.adCreativeDetails;n=a.dataset;h=n.isDsaEnabled;r=n.weblabTreatment;k=String(h);"undefined"===k&&(k=g&&0<g.length?g[0].selectionSignals?"true":"false":"false");"true"===k&&"T1"!==r&&(k="false");e.attach(f,b);e.define(f,"click",
function(){return m.__awaiter(void 0,void 0,void 0,function(){var t;return m.__generator(this,function(l){switch(l.label){case 0:return(t=ia[d])?[3,2]:[4,Wa(d,a,c)];case 1:t=l.sent();var p=a.dataset,u=p.formHeaderText,x=p.dsaFormHeaderText;Za(t,p.adFeedbackPayload,c,p.currentLocale,"true"===k?x:u,p.formLoadErrorText,p.closeButtonAriaText);ia[d]=t;l.label=2;case 2:return t.show(),[2]}})})});try{b.addEventListener("keydown",function(t){if(" "===t.key||"Enter"===t.key)t.preventDefault(),b.click()})}catch(t){console.log("Couldnt add keydown event listner")}return[2]})})},
ab=function(a,c){var b=T["default"].setup(),d="mouse-enter"+c;c="mouse-leave"+c;var e=Q(a,"ad-feedback-primary-link"),f=Q(a,"ad-feedback-text-desktop"),g=Q(a,"ad-feedback-sprite");b.attach(d,e);b.define(d,"mouseenter",function(){g.style.backgroundPosition="0px -12px";f.style.color="#111111"});b.attach(c,e);b.define(c,"mouseleave",function(){g.style.backgroundPosition="0px 0px";f.style.color="#555"})},bb=function(a){return m.__awaiter(void 0,void 0,void 0,function(){var c,b,d,e;return m.__generator(this,
function(f){switch(f.label){case 0:return f.trys.push([0,3,,4]),c=a(),b=w["default"].cardRoot.getElementsByClassName("adFeedbackMainComponent_"+c.adFeedbackLabelId)[0],d=b.dataset.isSponsoredLabelActive,"false"===(d||"false").toLowerCase()?[2]:[4,ab(b,c.adFeedbackLabelId)];case 1:return f.sent(),[4,$a(b,a)];case 2:return f.sent(),[3,4];case 3:throw e=f.sent(),z.count("adfeedback:cards:clientDesktop:enableAdFeedback:failure",1),Error("Failed to call enableAdFeedback for desktop client : "+e);case 4:return[2]}})})},
cb=function(a){a=M["default"].cardRoot.getElementsByClassName(a);return Array.prototype.slice.call(a)},eb=function(a,c){cb("p13n-sc-unified-ad-label").forEach(function(b){b={adFeedbackLabelId:b.dataset.adFeedbackLabelId||"",adFeedbackAsin:b.dataset.adFeedbackAsin||"",adId:b.dataset.adId||"",campaignId:b.dataset.campaignId||"",advertiserId:b.dataset.advertiserId||"",marketplaceId:b.dataset.marketplaceId||"",isLocationUsed:b.dataset.locationUsed||"",isInterestBasedAdsOptOut:b.dataset.interestBased||
"",title:b.dataset.asinTitle||"",price:b.dataset.asinPrice||"",currencyCode:b.dataset.currencyCode||""};b.adFeedbackLabelId&&b.adFeedbackAsin&&b.adId&&b.campaignId&&b.advertiserId&&b.marketplaceId&&b.isLocationUsed&&b.isInterestBasedAdsOptOut&&db(b,c,a)})},db=function(a,c,b){var d="mobile"===c?ja(a.adFeedbackLabelId,ka(a,"mobile")):ja(a.adFeedbackLabelId,ka(a,"desktop"));b(function(){return d})},ka=function(a,c){var b=c=m.__assign,d=a.adFeedbackAsin,e=a.adId,f=a.campaignId,g=a.title;var n=a.price;
var h=a.currencyCode;n=n&&h?{amount:n,currencyCode:h}:void 0;h=a.advertiserId;var r=a.marketplaceId;b=b.call(m,{},{asin:d,adCreativeIndex:0,adId:e,campaignId:f,title:g,priceInfo:n,advertiserIdNS:h&&r?"axiom."+r+"."+h:void 0});d=a.isLocationUsed;a=a.isInterestBasedAdsOptOut;a=void 0===d||void 0===a?void 0:{version:1,context:!0,location:"true"===d,pastActivity:"true"===a?0:1};return{adCreativeDetails:[c.call(m,b,{selectionSignals:a})]}},ja=function(a,c){return{adFeedbackLabelId:a,adCreativeMetaData:c}},
fb={initCarousel:function(a){return m.__awaiter(void 0,void 0,void 0,function(){var c,b,d;return m.__generator(this,function(e){c=(a||{}).afterPageLoaded;b=w["default"].cardRoot.classList.contains("p13n-sc-shoveler")?[w["default"].cardRoot]:Array.prototype.slice.call(w["default"].cardRoot.getElementsByClassName("p13n-sc-shoveler"));d=N["default"].setup(["getCarouselItems"]);if(null===b||void 0===b||!b.length)return[2];b.forEach(function(f){return m.__awaiter(void 0,void 0,void 0,function(){var g,
n,h,r,k,q;return m.__generator(this,function(t){switch(t.label){case 0:g=f.dataset||{};n="true"===g.showlazyloaddeliverymessage;h=function(){v["default"].loadDynamicImage("[data-name]='"+q+"' .p13n-sc-dynamic-image");Ra(f);Pa(f);null===c||void 0===c?void 0:c(f);var l=window.P;Da(l);Ea(l);Sa(f);n&&Oa(f)};h();if(f.classList.contains("p13n-carousel-initialized"))return[2];f.classList.add("p13n-carousel-initialized");r=Ba["default"].getCarousel(ca.unscope(f));k=Aa["default"].getCarousel(f);q=r.getAttr("name");
return[4,Promise.all([k.initialized,La.setupModal(f)])];case 1:return t.sent(),v["default"].on("a:carousel:"+q+":change:pageSize",h),v["default"].on("a:carousel:"+q+":change:loading",h),v["default"].on("a:carousel:"+q+":change:animating",h),v["default"].on("a:carousel:"+q+":change:fetchedItems",h),k.attachRemoteOperation(function(l){var p=l.indexes;l=l.ids;var u=d,x=u.getCarouselItems,C=m.__assign,D=m.__assign({},g),K=String(p[0]||0);var I=p[0]||0,E,J,R=0,G=g.aCarouselOptions?g.aCarouselOptions:void 0;
if(G&&(G=JSON.parse(G),G=null===(E=null===G||void 0===G?void 0:G.ajax)||void 0===E?void 0:E.id_list))for(E=0;E<I&&E<G.length;E++){var H=JSON.parse(G[E]);"true"===((null===(J=null===H||void 0===H?void 0:H.metadataMap)||void 0===J?0:J.isSponsoredProduct)?H.metadataMap.isSponsoredProduct:"false")&&(R+=1)}return x.call(u,C.call(m,D,{ids:l,indexes:p,offset:K,adOffset:R}))}),[2]}})})});return[2]})})}},gb={updateHandler:function(a){var c;void 0===a&&(a=w["default"].cardRoot);a=Array.prototype.slice.call(a.querySelectorAll('[class*="dealsCardDealTimer"]:not([data-callback-attached])'));
try{for(var b=m.__values(a),d=b.next();!d.done;d=b.next())Ua(d.value)}catch(f){var e={error:f}}finally{try{d&&!d.done&&(c=b.return)&&c.call(b)}finally{if(e)throw e.error;}}}},hb={enableDesktopUnifiedAdLabels:function(){eb(bb,"desktop")}},ib={initializeQuantitySelectorWidgets:function(){v["default"].trigger("quantity-selector-widget:loadStatesAndInitialize")}},A=function(a,c){a&&(c?V["default"].show(a):V["default"].hide(a))},aa=function(a,c){return(a=c.getElementsByClassName(a))&&1===a.length?a[0]:
void 0},O=function(a,c){void 0===c&&(c=1);z.count(a,(z.count(a)||0)+c)},jb=function(){function a(c,b,d,e,f,g,n,h){var r=this;this.throttledScrollAction=v["default"].throttle(function(){return m.__awaiter(r,void 0,void 0,function(){return m.__generator(this,function(k){switch(k.label){case 0:return[4,this.getNextBatchIfBottomInView()];case 1:return k.sent(),[2]}})})},200);this.containerDataset=this.getContainerDataset(c);this.bottomOfListElement=b;this.containerForInsertion=d;this.insertFetchedItems=
e;this.errorFetchingItemsElement=g;this.fetchAsinsRemoteOperation=f;this.spinnerFetchingItemsElement=n;this.batchSize=h||8;this.processingStatus={batchFailureCount:0,currentIndex:Number(c.dataset.indexOffset)||0,individualBatchAttemptsCount:0,isAllContentLoaded:!1,isProcessing:!1}}a.prototype.getContainerDataset=function(c){if(!c.dataset||!c.dataset.asinList)throw Error("Dataset not present or does not contain required data!");return{asinList:JSON.parse(c.dataset.asinList),linkParameters:c.dataset.linkParameters||
"{}",reftag:c.dataset.reftag||"",strategyId:c.dataset.strategyId||"",widgetGroupId:c.dataset.widgetGroupId||""}};a.prototype.getNextItemBatch=function(c){var b=this;this.processingStatus.individualBatchAttemptsCount+=1;this.processingStatus.isProcessing=!0;var d=this.processingStatus.currentIndex;if(d>=this.containerDataset.asinList.length)return this.processingStatus.isAllContentLoaded=!0,Promise.resolve(void 0);A(this.spinnerFetchingItemsElement,!0);d=this.containerDataset.asinList.slice(d,d+this.batchSize);
var e=d.map(function(f,g){return g+b.processingStatus.currentIndex});return this.fetchAsinsRemoteOperation({ids:d,indexes:e,linkparameters:this.containerDataset.linkParameters,offset:e[0].toString(),reftagprefix:this.containerDataset.reftag}).then(function(f){A(b.spinnerFetchingItemsElement,!1);b.insertFetchedItems(c,f);b.processingStatus.batchFailureCount=0;b.processingStatus.currentIndex+=b.batchSize;b.processingStatus.individualBatchAttemptsCount=0;b.processingStatus.isProcessing=!1}).catch(function(f){console.log("Error fetching items: "+
f);if(2<=b.processingStatus.individualBatchAttemptsCount){b.processingStatus.batchFailureCount+=1;if(2<=b.processingStatus.batchFailureCount){b.processingStatus.isProcessing=!0;A(b.spinnerFetchingItemsElement,!1);A(b.errorFetchingItemsElement,!0);return}b.processingStatus.currentIndex+=b.batchSize}void b.getNextItemBatch(c)})};a.prototype.getNextBatchIfBottomInView=function(){return m.__awaiter(this,void 0,void 0,function(){return m.__generator(this,function(c){switch(c.label){case 0:if(this.processingStatus.isProcessing)return[3,
3];this.processingStatus.isProcessing=!0;return V["default"].onScreen(this.bottomOfListElement,500)&&!this.processingStatus.isAllContentLoaded&&2>this.processingStatus.batchFailureCount?[4,this.getNextItemBatch(this.containerForInsertion)]:[3,2];case 1:return c.sent(),[3,3];case 2:this.processingStatus.isProcessing=!1,c.label=3;case 3:return[2]}})})};a.prototype.isInErrorState=function(){return 2<=this.processingStatus.batchFailureCount};a.prototype.resetLazyLoading=function(){this.processingStatus.batchFailureCount=
0;A(this.errorFetchingItemsElement,!1)};return a}(),la=function(a,c,b){void 0===c&&(c=function(){});void 0===b&&(b=function(){});return m.__awaiter(void 0,void 0,void 0,function(){return m.__generator(this,function(d){switch(d.label){case 0:return a.dataset.event?[4,kb(a.dataset.event,a,c,b)]:[3,2];case 1:return d.sent(),[3,5];case 2:return a.dataset.url?[4,lb(a.dataset.url,c,b)]:[3,4];case 3:return d.sent(),[3,5];case 4:B["default"].log("Element is missing dataset.url or dataset.event attribute"),
b(),d.label=5;case 5:return[2]}})})},kb=function(a,c,b,d){return m.__awaiter(void 0,void 0,void 0,function(){var e,f,g,n,h,r;return m.__generator(this,function(k){switch(k.label){case 0:e=function(q){return m.__awaiter(void 0,void 0,void 0,function(){var t,l;return m.__generator(this,function(p){switch(p.label){case 0:return t=function(u){u?b():(B["default"].log("Failed to call PPDS custom API"),d())},l=function(u){B["default"].log("Caught error when calling PPDS custom API: "+u.stack);d()},[4,q().then(t).catch(l)];
case 1:return p.sent(),[2]}})})};f=function(q){return m.__awaiter(void 0,void 0,void 0,function(){var t;return m.__generator(this,function(l){switch(l.label){case 0:if(!c.dataset.asin)return[3,2];t={asin:c.dataset.asin};return[4,e(q.bind(null,t))];case 1:return l.sent(),[3,3];case 2:B["default"].log("Element was missing required data: asin"),d(),l.label=3;case 3:return[2]}})})};g=a;switch(g){case "NOT_INTERESTED":return[3,1];case "DELETE_NOT_INTERESTED":return[3,5]}return[3,7];case 1:if(!c.dataset.asin)return[3,
3];n={asin:c.dataset.asin,expirationTime:mb(c.dataset.suppressiondays),reason:c.dataset.reason,strategyId:c.dataset.strategyId||c.dataset.strategyid,widgetGroupId:c.dataset.widgetGroupId||c.dataset.widgetgroupid};h=N["default"].setup(["recordNotInterested"]);return[4,e(h.recordNotInterested.bind(null,n))];case 2:return k.sent(),[3,4];case 3:B["default"].log("Element was missing required data: asin"),d(),k.label=4;case 4:return[3,8];case 5:return r=N["default"].setup(["deleteNotInterested"]),[4,f(r.deleteNotInterested)];
case 6:return k.sent(),[3,8];case 7:return B["default"].log("Invalid PPDS event type: "+a),d(),[3,8];case 8:return[2]}})})},lb=function(a,c,b){return m.__awaiter(void 0,void 0,void 0,function(){return m.__generator(this,function(d){switch(d.label){case 0:return[4,U["default"].post(a,{accepts:"text/html,*/*",contentType:"application/x-www-form-urlencoded"}).then(function(){c()}).catch(function(e){B["default"].log("Failed to call AJAX endpoint "+a+" with error: "+e.message,"ERROR");b()})];case 1:return d.sent(),
[2]}})})},mb=function(a){if(a&&(a=Number.parseInt(a,10),!(0>=a||(a=new Date(Date.now()+864E5*a),Number.isNaN(a.getTime())))))return a.toISOString()},nb=function(a,c,b,d,e,f,g,n,h,r){var k=a.getElementsByClassName(d)[0],q=a.getElementsByClassName(e)[0],t=n?a.getElementsByClassName(n)[0]:void 0,l=a.querySelector(f);if(!q||!k||!l)throw Error("One or more elements to record feedback are not present.");d=function(p,u){p&&(p.onclick=function(){return m.__awaiter(void 0,void 0,void 0,function(){var x;return m.__generator(this,
function(C){switch(C.label){case 0:return[4,la(p,function(){u&&h?h():!u&&r&&r();A(l,!1);A(q,u);A(k,!u);t&&(t.style.opacity=u?"0.3":"1");g&&O(g.prefix+":record-feedback:success")},function(){console.log("Failed to record feedback on click");A(l,!0);g&&O(g.prefix+":record-feedback:failure")})];case 1:return C.sent(),g&&(x=u?g.primaryAction:g.secondaryAction,O(g.prefix+":record-feedback:"+x)),[2]}})})})};c=aa(c,a);d(c,!0);a=aa(b,a);d(a,!1)},ob=function(a,c,b,d,e){var f=function(r){return N["default"].setup(["getCanariesFeedbackReasons"]).getCanariesFeedbackReasons(r)},
g=d.getElementsByClassName("p13n-not-interested-reasons")[0],n=aa("p13n-not-interested-success-message",d),h=d.querySelector("#p13n-record-feedback-error-message");return function(){e.includes(a)||e.push(a);g?(A(n,!1),g.hasChildNodes()||f({asin:a,strategyId:c,widgetGroupId:b}).then(function(r){Array.prototype.slice.call(r.getElementsByClassName("p13n-feedback-reasons-option")).forEach(function(k){function q(){return m.__awaiter(this,void 0,void 0,function(){return m.__generator(this,function(l){la(k,
function(){A(h,!1);A(g,!1);A(n,!0)},function(){console.log("Failed to record feedback reason on click");h&&A(h,!0)});return[2]})})}var t=k.getElementsByTagName("input")[0];t.addEventListener("keypress",function(l){return m.__awaiter(void 0,void 0,void 0,function(){return m.__generator(this,function(p){"Enter"===l.key&&q();return[2]})})});t.addEventListener("click",function(l){return m.__awaiter(void 0,void 0,void 0,function(){return m.__generator(this,function(p){0!==l.screenX&&0!==l.screenY&&q();
return[2]})})})});g.appendChild(r)}),A(g,!0)):A(n,!0)}},pb=function(a,c){return function(){var b=c.indexOf(a);-1<b&&c.splice(b,1)}},qb={feedbackModalInit:function(a,c){var b={prefix:"p13n-desktop-feedback-modal",primaryAction:"not-interested",secondaryAction:"remove-not-interested"},d=[],e=w["default"].cardRoot.querySelector(".p13n-desktop-canaries-kebab-data");if(e){O(b.prefix+":kebab:render");e.onclick=function(){return O(b.prefix+":kebab:click")};w["default"].cardRoot.querySelector(".p13n-desktop-feedback-modal-link").onclick=
function(){return O(b.prefix+":modal:open")};var f=w["default"].cardRoot.querySelector(".p13n-ni-iyr-redirect");f&&(f.onclick=function(){return O(b.prefix+":iyr:click")});f=w["default"].cardRoot.getElementsByClassName("p13n-canaries-desktop-feedback-modal")[0];if(!f)throw Error("Dataset not present or does not contain required data!");var g=f.querySelector("#endOfList"),n=w["default"].cardRoot.getElementsByClassName("p13n-desktop-feedback-modal-faceouts-list")[0],h=f.querySelector("#p13n-desktop-feedback-modal-loading-items"),
r=f.querySelector("#p13n-desktop-feedback-modal-error-loading-items"),k=new jb(e,g,n,function(p,u){var x;if(u.hasChildNodes()){u=Array.from(u.childNodes);try{for(var C=m.__values(u),D=C.next();!D.done;D=C.next()){var K=D.value;u=K;var I=u.getElementsByClassName("p13n-individual-feedbackButton")[0];nb(u,"p13n-individual-feedbackButton","p13n-feedback-undo-button","p13n-desktop-feedback-modal-initial-faceout","p13n-desktop-feedback-modal-undo-faceout","#p13n-record-feedback-error-message",b,"p13n-feedback-list-asin-image",
ob(I.dataset.asin||"",e.dataset.strategyId||"",e.dataset.widgetGroupId||"",u,d),pb(I.dataset.asin||"",d));p.appendChild(K);I.dataset.strategyId=e.dataset.strategyId;I.dataset.widgetGroupId=e.dataset.widgetGroupId}}catch(J){var E={error:J}}finally{try{D&&!D.done&&(x=C.return)&&x.call(C)}finally{if(E)throw E.error;}}}},function(p){return N["default"].setup(["getCanariesFeedbackModalItems"]).getCanariesFeedbackModalItems(p)},r,h);w["default"].cardRoot.querySelector(".p13n-desktop-feedback-modal-link").addEventListener("click",
function(){return m.__awaiter(void 0,void 0,void 0,function(){return m.__generator(this,function(p){switch(p.label){case 0:return""!==n.innerHTML||k.isInErrorState()?[3,2]:[4,k.getNextItemBatch(n)];case 1:return p.sent(),[3,4];case 2:if(!k.isInErrorState())return[3,4];k.resetLazyLoading();return[4,k.getNextItemBatch(n)];case 3:p.sent(),p.label=4;case 4:return[2]}})})});f.addEventListener("wheel",k.throttledScrollAction);var q=function(p){return N["default"].setup(["refreshCard"]).refreshCard(p)};
f=e.dataset.uniqueId;g=e.dataset.input;!g&&(h=w["default"].cardRoot.querySelector(".p13n-desktop-canaries-wrapper-data"),null===h||void 0===h?0:h.dataset)&&(g=h.dataset.input);var t=JSON.parse(g||"{}"),l=w["default"].cardRoot.querySelector("#p13n-desktop-feedback-modal-close-message");v["default"].on("a:popover:hide:p13n-desktop-feedback-modal_"+f,function(){return m.__awaiter(void 0,void 0,void 0,function(){var p,u,x,C,D,K,I,E,J,R;return m.__generator(this,function(G){p=e.querySelector(".p13n-feedback-popover-kebab-button");
p.focus();if(0<d.length&&t&&t.content){u=t.content.recommendations;x=[];try{for(C=m.__values(u),D=C.next();!D.done;D=C.next())K=D.value,I=K.id,E=d.indexOf(I),0>E&&x.push(K)}catch(H){J={error:H}}finally{try{D&&!D.done&&(R=C.return)&&R.call(C)}finally{if(J)throw J.error;}}x.length<c?l?(l.style.display="inline",l.style.position="absolute",l.style.top=(w["default"].cardRoot.offsetHeight-l.offsetHeight)/2+"px",l.style.right=(w["default"].cardRoot.offsetWidth-l.offsetWidth)/2+"px"):B["default"].log("Could not find the changeover element for message surfacing"):
(t.content.recommendations=x,q(t).then(function(H){w["default"].cardRoot.innerHTML=H.outerHTML;a()}).catch(function(H){B["default"].log("Error fetching items: "+H)}))}return[2]})})})}}},ma=document.body.style.overflow,L=function(a){return a.find("#cpf-sidesheet-content-container")},rb=function(a){var c,b;null!==(c=a.$target)&&void 0!==c&&c.length&&(null===(b=a.$target)||void 0===b?0:b.hasClass("cpf-sidesheet-anchor-end"))&&v["default"].delay(function(){P().find("a[href], button").first().focus()},
0)},sb=function(a){var c;null!==(c=a.$target)&&void 0!==c&&c.length&&v["default"].delay(function(){v["default"].$(document.activeElement).hasClass("cpf-sidesheet-anchor-start")&&P().find("a[href], button").last().focus()},0)},na=function(){document.body.style.overflow=ma?ma:"";y["default"]("#cpf-sidesheet-background").hide();var a=P();a.attr("aria-hidden","true");y["default"]("#cpf-sidesheet").attr("aria-hidden","true");L(a).attr("aria-hidden","true");y["default"]("#a-page").attr("aria-hidden","false");
S(a).hide();tb()},P=function(){return y["default"]("#cpf-sidesheet-containerempty-div")},S=function(a){return a.find("#cpf-sidesheet-secondary-content-container")},tb=function(){var a=y["default"]("#cpf-sidesheet").width()+50;ub({right:"-"+a+"px"},function(){y["default"]("#cpf-sidesheet").hide()})},vb=function(){y["default"]("#cpf-sidesheet").show(function(){v["default"].animate(y["default"]("#cpf-sidesheet"),{right:"0"},300,"ease-out",function(){y["default"]("#cpf-sidesheet-close").show()})})},ub=
function(a,c){v["default"].animate(y["default"]("#cpf-sidesheet"),a,300,"ease-out",c)},wb=function(a){a=T["default"].setup().define;a("cpf-side-sheet-open","click",function(c){var b;c=null===(b=c.currentTarget)||void 0===b?void 0:b.getAttribute("cpf-side-sheet-content-id");var d=P();b=y["default"]("#"+c);d&&0!==d.length||(c=y["default"](document.createElement("div")),c.attr("id","cpf-sidesheet-containerempty-div"),d=w["default"].cardRoot.getElementsByClassName("cpf-sidesheet-container")[0].innerHTML,
c.append(d),y["default"]("body").prepend(c),d=c);b&&0!==b.length&&(L(d).html(b.html()),b=P(),L(b).show(),b.attr("aria-hidden","false"),y["default"]("#cpf-sidesheet").attr("aria-hidden","false"),L(b).attr("aria-hidden","false"),y["default"]("#a-page").attr("aria-hidden","true"),y["default"]("body").css("overflow","hidden"),y["default"]("#cpf-sidesheet-background").show(),vb(),b.find(".cpf-sidesheet-close-button").focus())});v["default"].declarative("cpf-side-sheet-close","click",function(c){na()});
v["default"].declarative("cpf-side-sheet-secondary-open","click",function(c){var b,d=P();c=null===(b=c.data)||void 0===b?void 0:b.preloadDomId;b=y["default"]("#"+c);d.find(".cpf-sidesheet-close-button").focus();L(d).hide();L(d).attr("aria-hidden",!0);S(d).show().html(b.html());S(d).attr("aria-hidden",!1)});v["default"].declarative("cpf-bottom-sheet-secondary-back","click",function(c){c=P();c.find(".cpf-sidesheet-close-button").focus();L(c).show();L(c).attr("aria-hidden",!1);S(c).hide();S(c).attr("aria-hidden",
!0)});v["default"].declarative("cpf-sidesheet-capture","keydown",function(c){"keydown"!==c.type||27!==c.$event.keyCode&&27!==c.$event.key||na()});v["default"].declarative("cpf-sidesheet-capture","focusin",function(c){rb(c)});v["default"].declarative("cpf-sidesheet-capture","focusout",function(c){sb(c)})},oa=function(){return m.__awaiter(void 0,void 0,void 0,function(){var a,c;return m.__generator(this,function(b){switch(b.label){case 0:return a=fb.initCarousel({afterPageLoaded:function(d){gb.updateHandler(d);
ib.initializeQuantitySelectorWidgets();hb.enableDesktopUnifiedAdLabels()}}),c=qb.feedbackModalInit(oa,1),wb(),[4,a];case 1:return b.sent(),[4,c];case 2:return b.sent(),[2]}})})};ba._operationNames=["getCarouselItems","getCanariesFeedbackModalItems","refreshCard","deleteNotInterested","recordNotInterested"];ba.card=oa});
