1"use strict";(self.webpackChunkaem_maven_archetype=self.webpackChunkaem_maven_archetype||[]).push([[1795],{9842:function(e,t,n){n.r(t),n.d(t,{default:function(){return lt}});var r=n(1669),o=n.n(r),a=n(6540),i=n(3819),l=n(5451),u=n(2840),c=n(2323),s=function(e){var t,n,r,o,s,d,v,p,m,f,g,y=e.cartData,h=e.labels,b=e.index,k=e.refQuantity,S=e.quantityArr,w=e.updateQuantity,I=e.onChangeinputVal,_=e.onBlurInputVal,C=e.deleteCartItem,N=e.productClickDatalayer,E=e.stockDetailsObject,x=e.formatPriceBreaksForTooltip,O=e.isPriceStockSyncing,D=String((null==y?void 0:y.opnName)||"").trim().toLowerCase(),A=Array.isArray(E)?E.find((function(e){return String((null==e?void 0:e.opnName)||(null==e?void 0:e.manufacturerPartNumber)||(null==e?void 0:e.skuId)||(null==e?void 0:e.productName)||"").trim().toLowerCase()===D})):null,L=A?x(A):null,P=(0,u.Qn)(localStorage.getItem("ifxCurrencyId")),T=O&&!(null!=y&&null!==(t=y.pricing)&&void 0!==t&&t.pricePerUnit),q=O&&!(null!=y&&y.quantityAvailable);return a.createElement(a.Fragment,null,a.createElement("div",{className:"c-p p-b-0"},a.createElement("div",{className:"cart-card"},a.createElement("div",{className:"product-details-cart"},a.createElement("div",{className:"product-image"},a.createElement("div",{className:"product-image-div"},a.createElement(i.A,{key:b,src:null==y?void 0:y.imageUrl,alt:null==y?void 0:y.productTitle}))),a.createElement("div",{className:"product-name"},a.createElement("div",{className:"d-flex cart-text"},a.createElement("span",{className:"p-r-1 automotive"},y.topLevelCategory)),a.createElement("div",{className:"product-family-title"},a.createElement("a",{"aria-label":"cart data",className:"product-family-href",href:null==y?void 0:y.productUrl,onClick:function(){N(y.productTitle)}},a.createElement("span",null,y.opnName))),a.createElement("div",{className:"d-flex align-items-center cart-text"},a.createElement(l.A,{productData:L},q?a.createElement("span",{className:"stock-text"},a.createElement("span",{className:"spinner-border spinner-border-sm",role:"status","aria-label":(null==h?void 0:h.UpdatingPriceOrStock)||"Checking stock..."})):a.createElement("span",{className:"".concat(null!=y&&y.stockError?"text-danger":""," stock-text")},y.quantityAvailable||0," ",h.InStock||"in stock"),a.createElement("span",{className:"".concat(null!=y&&y.stockError?"icon icon-c-info icon-info-danger":"icon icon-c-info")})))),a.createElement("div",{className:"d-flex align-items-center justify-content-end delete-item"},a.createElement("button",{className:"btn icon icon-delete",type:"button","aria-label":"DeleteCartItem",onClick:function(){return C(y.opnName,!1)}}))),a.createElement("div",{className:"product-pricing"},a.createElement("hr",{className:"solid m-b-0"}),a.createElement("div",{className:"info-container d-flex align-items-center justify-content-between p-t-0"},a.createElement("div",{className:"cart-text price-font-family"},h.PricePerUnit||"Price Per Unit"),a.createElement("div",null,a.createElement("span",{className:"info-text"},T?a.createElement("span",{className:"spinner-border spinner-border-sm",role:"status","aria-label":(null==h?void 0:h.UpdatingPriceOrStock)||"Checking price..."}):"".concat(P).concat(null!=y&&y.quantityAvailable&&null!=y&&null!==(n=y.pricing)&&void 0!==n&&n.pricePerUnit?y.pricing.pricePerUnit:"0.00")))),a.createElement("div",{className:"d-flex align-items-center justify-content-between"},a.createElement("div",{className:"cart-text price-font-family"},h.Quantity||"Quantity"),a.createElement("div",{className:"price"},a.createElement("div",{className:"product-quantity-input d-flex"},a.createElement("button",{disabled:!(null!=y&&y.quantityAvailable)&&!q||(null===(r=S[y.opnName])||void 0===r?void 0:r[!1])<=1,className:"".concat((null==y||!y.quantityAvailable)&&!q||(null===(o=S[y.opnName])||void 0===o?void 0:o[!1])<=1?"faded":"show"," icon icon-c-delete minus-price"),"aria-label":"Decrement",onClick:function(){return w(k.current[b],null==y?void 0:y.opnName,!1,!1)}}),a.createElement("span",{className:"price-input"},a.createElement("input",{type:"number","aria-label":"input-field",className:"".concat(null!=y&&y.stockError?"text-input-danger":""," price-input-element"),value:null!=y&&y.quantityAvailable||q?""===(null===(s=S[y.opnName])||void 0===s?void 0:s[!1])?"":(null==y?void 0:y.quantityAvailable)>0&&(null===(d=S[y.opnName])||void 0===d?void 0:d[!1])>(null==y?void 0:y.quantityAvailable)?null==y?void 0:y.quantityAvailable:(null===(v=S[y.opnName])||void 0===v?void 0:v[!1])||0:0,ref:k.current[b],onKeyDown:c.Sg,onBlur:function(e){return _(null==y?void 0:y.opnName,e,!1)},onChange:function(e){return I(null==y?void 0:y.opnName,e,!1)}})),a.createElement("button",{disabled:!(null!=y&&y.quantityAvailable)&&!q||(null==y?void 0:y.quantityAvailable)>0&&(null===(p=S[y.opnName])||void 0===p?void 0:p[!1])>=(null==y?void 0:y.quantityAvailable),className:"".concat((null!=y&&y.quantityAvailable||q)&&(null===(m=S[y.opnName])||void 0===m?void 0:m[!1])<(null==y?void 0:y.quantityAvailable)?"show":"faded"," icon icon-c-add plus-price"),"aria-label":"Increment",onClick:function(){return w(k.current[b],null==y?void 0:y.opnName,!0,!1)}})))),a.createElement("hr",{className:"solid m-b-0"}),a.createElement("div",{className:"info-container d-flex align-items-center justify-content-between unit-price p-t-0 p-b-0"},a.createElement("div",{className:"cart-text price-font-family sub-total"},h.SubTotal),a.createElement("div",null,a.createElement("span",{className:"info-text-head"},T?a.createElement("span",{className:"spinner-border spinner-border-sm",role:"status","aria-label":(null==h?void 0:h.UpdatingPriceOrStock)||"Checking price..."}):"".concat(P).concat(null!=y&&y.quantityAvailable&&null!=y&&null!==(f=y.pricing)&&void 0!==f&&f.subTotal?null==y||null===(g=y.pricing)||void 0===g||null===(g=g.subTotal)||void 0===g?void 0:g.toFixed(2):"0.00"))))))),a.createElement("hr",{className:"solid h-4 m-a-0"}))},d=n(3977);function v(e){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},v(e)}function p(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */p=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",l=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";
vendor: 4,272 bytes, line 1
1function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function s(e,t,n,r){var a=t&&t.prototype instanceof b?t:b,i=Object.create(a.prototype),l=new L(r||[]);return o(i,"_invoke",{value:x(e,n,l)}),i}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=s;var m="suspendedStart",f="suspendedYield",g="executing",y="completed",h={};function b(){}function k(){}function S(){}var w={};c(w,i,(function(){return this}));var I=Object.getPrototypeOf,_=I&&I(I(P([])));_&&_!==n&&r.call(_,i)&&(w=_);var C=S.prototype=b.prototype=Object.create(w);function N(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function E(e,t){function n(o,a,i,l){var u=d(e[o],e,a);if("throw"!==u.type){var c=u.arg,s=c.value;return s&&"object"==v(s)&&r.call(s,"__await")?t.resolve(s.__await).then((function(e){n("next",e,i,l)}),(function(e){n("throw",e,i,l)})):t.resolve(s).then((function(e){c.value=e,i(c)}),(function(e){return n("throw",e,i,l)}))}l(u.arg)}var a;o(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,o){n(e,r,t,o)}))}return a=a?a.then(o,o):o()}})}function x(t,n,r){var o=m;return function(a,i){if(o===g)throw Error("Generator is already running");if(o===y){if("throw"===a)throw i;return{value:e,done:!0}}for(r.method=a,r.arg=i;;){var l=r.delegate;if(l){var u=O(l,r);if(u){if(u===h)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===m)throw o=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=g;var c=d(t,n,r);if("normal"===c.type){if(o=r.done?y:f,c.arg===h)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(o=y,r.method="throw",r.arg=c.arg)}}}function O(t,n){var r=n.method,o=t.iterator[r];if(o===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,O(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var a=d(o,t.iterator,n.arg);if("throw"===a.type)return n.method="throw",n.arg=a.arg,n.delegate=null,h;var i=a.arg;return i?i.done?(n[t.resultName]=i.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,h):i:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,h)}function D(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function L(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(D,this),this.reset(!0)}function P(t){if(t||""===t){var n=t[i];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,a=function n(){for(;++o<t.length;)if(r.call(t,o))return n.value=t[o],n.done=!1,n;return n.value=e,n.done=!0,n};return a.next=a}}throw new TypeError(v(t)+" is not iterable")}return k.prototype=S,o(C,"constructor",{value:S,configurable:!0}),o(S,"constructor",{value:k,configurable:!0}),k.displayName=c(S,u,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===k||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,S):(e.__proto__=S,c(e,u,"GeneratorFunction")),e.prototype=Object.create(C),e},t.awrap=function(e){return{__await:e}},N(E.prototype),c(E.prototype,l,(function(){return this})),t.AsyncIterator=E,t.async=function(e,n,r,o,a){void 0===a&&(a=Promise);var i=new E(s(e,n,r,o),a);return t.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},N(C),c(C,u,"Generator"),c(C,i,(function(){return this})),c(C,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=P,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEac
1h(A),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function o(r,o){return l.type="throw",l.arg=t,n.next=r,o&&(n.method="next",n.arg=e),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],l=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,h):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),A(n),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;A(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:P(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),h}},t}function m(e,t,n,r,o,a,i){try{var l=e[a](i),u=l.value}catch(e){return void n(e)}l.done?t(u):Promise.resolve(u).then(r,o)}function f(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var a=e.apply(t,n);function i(e){m(a,r,o,i,l,"next",e)}function l(e){m(a,r,o,i,l,"throw",e)}i(void 0)}))}}function g(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function y(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?g(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):g(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function h(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=v(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=v(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==v(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var b,k,S="cartDraft",w=function(e,t){if(!e)return t;try{var n=JSON.parse(e);return null!=n?n:t}catch(e){return t}},I=function(e){var t,n,r,o,l,u,s,v,m=e.cartData,g=e.labels,h=e.index,b=e.refQuantity,k=e.quantityArr,I=e.updateQuantity,_=e.onChangeinputVal,C=e.onBlurInputVal,N=e.deleteCartItem,E=e.productClickDatalayer,x=e.updateCart,O=(e.cartDetails,e.isProductEligibleForSample,e.isAccountEligibleForSamples),D=e.productNotElligibleList,A=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).excludedSkuId,t=w(localStorage.getItem(S),{}),n=(w(localStorage.getItem("cart-data"),[])||[]).map((function(e){return{skuId:null==e?void 0:e.opnName,qty:Number((null==e?void 0:e.quantity)||0),lineType:null!=e&&e.IsSample?"SAMPLE":"PAID"}})),r=Array.isArray(null==t?void 0:t.pendingOps)?t.pendingOps.filter((function(t){var n;return!e||String((null==t||null===(n=t.payload)||void 0===n?void 0:n.skuId)||"")!==String(e)})):[],o=y(y({},t),{},{items:n,badge:y(y({},(null==t?void 0:t.badge)||{}),{},{itemCount:n.length}),pendingOps:r,updatedAt:(new Date).toISOString()});localStorage.setItem(S,JSON.stringify(o))},L=(0,a.useMemo)((function(){return 0!=m.quantityAvailable&&(null===(e=k[m.opnName])||void 0===e?void 0:e[!0])>m.sampleLimit;var e}),[k,m.opnName,m.quantityAvailable,m.sampleLimit]),P=null==D?void 0:D.includes(m.opnName),T=function(){var e=f(p().mark((function e(t){var n,r,o,a,i,l,u,c,s,d,v,f,g,h,b;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=Number((null==m?void 0:m.sampleLimit)||0),i=w(localStorage.getItem("cart-data"),[]),l=i.find((function(e){return e.opnName===t&&!0===e.IsSample})),u=i.findIndex((function(e){return e.opnName===t&&!1===e.IsSample})),l){e.next=6;break}return e.abrupt("return");case 6:if(c=Number(null!==(n=null!==(r=null===(o=k[t])||void 0===o?void 0:o[!0])&&void 0!==r?r:l.quantity)&&void 0!==n?n:0),s=0,d=c,v=!1,c<=0?(s=1,d=0,v=!0):c<=a?(s=1,0===(d=c-1)&&(v=!0)):(s=c-a,d=a),!(s<=0)){e.next=13;break}return e.abrupt("return");case 13:if(i=i.map((function(e){return e.opnName===t&&!0===e.IsSample?v?null:y(y({},e),{},{quantity:d}):e.opnName===t&&!1===e.IsSample?y(y({},e),{},{quantity:Number(e.quantity||0)+s}):e}
1)).filter(Boolean),-1===u&&(f=y(y({},l),{},{IsSample:!1,lineType:"PAID",quantity:s}),i.push(f)),localStorage.setItem("cart-data",JSON.stringify(i)),A({excludedSkuId:t}),g=i.find((function(e){return e.opnName===t&&!1===e.IsSample})),h=g?Number(g.quantity||0):s,b=[{operation:-1===u?"INSERT":"UPDATE",payload:{skuId:t,qty:h,lineType:"PAID"}},v?{operation:"DELETE",payload:{skuId:t,qty:0,lineType:"SAMPLE"}}:{operation:"UPDATE",payload:{skuId:t,qty:d,lineType:"SAMPLE"}}],window.dispatchEvent(new CustomEvent("ifx:cart-op-batch-queued",{detail:{source:"add_as_paid_product",ops:b}})),"function"!=typeof x){e.next=24;break}return e.next=24,x(!1);case 24:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return a.createElement(a.Fragment,null,a.createElement("div",{className:"c-p p-b-0"},a.createElement("div",{className:"cart-card"},L&&a.createElement(d.A,{type:"warning",message:g.SampleLimitReached}),a.createElement("div",{className:"product-details-cart"},a.createElement("div",{className:"product-image"},a.createElement("div",{className:"product-image-div"},a.createElement(i.A,{key:h,src:null==m?void 0:m.imageUrl,alt:null==m?void 0:m.productTitle}))),a.createElement("div",{className:"product-name"},a.createElement("div",{className:"d-flex cart-text"},a.createElement("span",{className:"p-r-1 automotive"},m.topLevelCategory),a.createElement("span",{className:"brand-flag ".concat(0==(null==m?void 0:m.quantityAvailable)||!O||P?"brand-flag-danger text-danger":"")}," ",((null==g?void 0:g.Free)||"Free").toUpperCase()," ")),a.createElement("div",{className:"product-family-title"},a.createElement("a",{"aria-label":"cart data",className:"product-family-href",href:null==m?void 0:m.productUrl,onClick:function(){return E(m.productTitle)}},a.createElement("span",null,m.opnName))),a.createElement("div",{className:"d-flex align-items-center cart-text"},a.createElement("span",{className:"".concat(null!=m&&m.stockError?"text-danger":""," stock-text")},a.createElement("span",{className:"".concat(0==(null==m?void 0:m.quantityAvailable)?"text-danger":"")},m.quantityAvailable||0," ",g.InStock||"in stock ")," | "+g.SampleLimit+": ",m.sampleLimit))),a.createElement("div",{className:"d-flex align-items-center justify-content-end delete-item"},a.createElement("button",{className:"btn icon icon-delete",type:"button","aria-label":"DeleteCartItem",onClick:f(p().mark((function e(){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,N(m.opnName,!0);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}))),a.createElement("div",{className:"product-pricing"},a.createElement("hr",{className:"solid m-b-0"}),a.createElement("div",{className:"d-flex align-items-center justify-content-between"},a.createElement("div",{className:"cart-text price-font-family"},g.Quantity||"Quantity"),a.createElement("div",{className:"price"},a.createElement("div",{className:"product-quantity-input d-flex"},a.createElement("button",{disabled:!(null!=m&&m.quantityAvailable)||(null===(t=k[m.opnName])||void 0===t?void 0:t[!0])<=1,className:"".concat(null==m||!m.quantityAvailable||(null===(n=k[m.opnName])||void 0===n?void 0:n[!0])<=1?"faded":"show"," icon icon-c-delete minus-price"),"aria-label":"Decrement",onClick:function(){return I(b.current[h],null==m?void 0:m.opnName,!1,!0)}}),a.createElement("span",{className:"price-input"},a.createElement("input",{type:"number","aria-label":"input-field",className:"".concat(0==(null==m?void 0:m.quantityAvailable)||!O||P?"text-input-danger":""," price-input-element"),value:null!=m&&m.quantityAvailable?""===(null===(r=k[m.opnName])||void 0===r?void 0:r[!0])?"":(null===(o=k[m.opnName])||void 0===o?void 0:o[!0])>(null==m?void 0:m.quantityAvailable)?null==m?void 0:m.quantityAvailable:(null===(l=k[m.opnName])||void 0===l?void 0:l[!0])||0:0,ref:b.current[h],onKeyDown:c.Sg,onBlur:function(e){return C(null==m?void 0:m.opnName,e,!0)},onChange:function(e){return _(null==m?void 0:m.opnName,e,!0)}})),a.createElement("button",{disabled:!(null!=m&&m.quantityAvailable)||(null===(u=k[m.opnName])||void 0===u?void 0:u[!0])>=m.quantityAvailable,className:"".concat(null!=m&&m.quantityAvailable&&(null===(s=k[m.opnName])||void 0===s?void 0:s[!0])<m.quantityAvailable?"show":"faded"," icon icon-c-add plus-price"),"aria-label":"Increment",onClick:function(){return I(b.current[h],null==m?void 0:m.opnName,!0,!0)}})))),0!==m.quantityAvailable&&(!(w(localStorage.getItem("cart-data"))||[]).some((function(e){return e.opnName===m.opnName&&!1===e.IsSample}))||(null===(v=k[m.opnName])||void 0===v?void 0:v[!0])>m.sampleLimit)&&a.createElement(a.Fragment,null,a.createElement("hr",{className:"solid m-b-0"}),a.createElement("div",{className:"convert-to-paid d-flex align-items-center"},a.createElement("a",{href:"#",className:"add-paid-link btn cursor-pointer",onClick:function(){var e=f(p().mark((function e(t){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.preventDefault(),t.stopPropagation(),e.next=4,T(m.opnName);case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()},a.createElement("span",{className:"add-paid-icon"}),a.createElement("span",{className:"add-paid-label"},g.AddAsPaidProduct||"Add as paid product"))))))),a.createElement("hr",{className:"solid h-4 m-a-0"}))},_=n(6508),C=n(2906),N=n(6960),E=n(2703);function x(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */x=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",l=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";
vendor: 4,272 bytes, line 1
1function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function s(e,t,n,r){var a=t&&t.prototype instanceof y?t:y,i=Object.create(a.prototype),l=new A(r||[]);return o(i,"_invoke",{value:N(e,n,l)}),i}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=s;var v="suspendedStart",p="suspendedYield",m="executing",f="completed",g={};function y(){}function h(){}function b(){}var k={};c(k,i,(function(){return this}));var S=Object.getPrototypeOf,w=S&&S(S(P([])));w&&w!==n&&r.call(w,i)&&(k=w);var I=b.prototype=y.prototype=Object.create(k);function _(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function n(o,a,i,l){var u=d(e[o],e,a);if("throw"!==u.type){var c=u.arg,s=c.value;return s&&"object"==L(s)&&r.call(s,"__await")?t.resolve(s.__await).then((function(e){n("next",e,i,l)}),(function(e){n("throw",e,i,l)})):t.resolve(s).then((function(e){c.value=e,i(c)}),(function(e){return n("throw",e,i,l)}))}l(u.arg)}var a;o(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,o){n(e,r,t,o)}))}return a=a?a.then(o,o):o()}})}function N(t,n,r){var o=v;return function(a,i){if(o===m)throw Error("Generator is already running");if(o===f){if("throw"===a)throw i;return{value:e,done:!0}}for(r.method=a,r.arg=i;;){var l=r.delegate;if(l){var u=E(l,r);if(u){if(u===g)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===v)throw o=f,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=m;var c=d(t,n,r);if("normal"===c.type){if(o=r.done?f:p,c.arg===g)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(o=f,r.method="throw",r.arg=c.arg)}}}function E(t,n){var r=n.method,o=t.iterator[r];if(o===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,E(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var a=d(o,t.iterator,n.arg);if("throw"===a.type)return n.method="throw",n.arg=a.arg,n.delegate=null,g;var i=a.arg;return i?i.done?(n[t.resultName]=i.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,g):i:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function D(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function P(t){if(t||""===t){var n=t[i];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,a=function n(){for(;++o<t.length;)if(r.call(t,o))return n.value=t[o],n.done=!1,n;return n.value=e,n.done=!0,n};return a.next=a}}throw new TypeError(L(t)+" is not iterable")}return h.prototype=b,o(I,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:h,configurable:!0}),h.displayName=c(b,u,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,c(e,u,"GeneratorFunction")),e.prototype=Object.create(I),e},t.awrap=function(e){return{__await:e}},_(C.prototype),c(C.prototype,l,(function(){return this})),t.AsyncIterator=C,t.async=function(e,n,r,o,a){void 0===a&&(a=Promise);var i=new C(s(e,n,r,o),a);return t.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},_(I),c(I,u,"Generator"),c(I,i,(function(){return this})),c(I,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=P,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEac
vendor: 4,196 bytes, line 1
1h(D),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function o(r,o){return l.type="throw",l.arg=t,n.next=r,o&&(n.method="next",n.arg=e),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],l=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,g):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),D(n),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;D(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:P(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),g}},t}function O(e,t,n,r,o,a,i){try{var l=e[a](i),u=l.value}catch(e){return void n(e)}l.done?t(u):Promise.resolve(u).then(r,o)}function D(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var a=e.apply(t,n);function i(e){O(a,r,o,i,l,"next",e)}function l(e){O(a,r,o,i,l,"throw",e)}i(void 0)}))}}function A(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a,i,l=[],u=!0,c=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=a.call(n)).done)&&(l.push(r.value),l.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(c)throw o}}return l}}(e,t)||T(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function L(e){return L="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},L(e)}function P(e){return function(e){if(Array.isArray(e))return q(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||T(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function T(e,t){if(e){if("string"==typeof e)return q(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?q(e,t):void 0}}function q(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function R(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function j(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};
1t%2?R(Object(n),!0).forEach((function(t){M(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):R(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function M(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=L(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=L(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==L(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var K="__ifxCartPageRefreshBootstrapOwner",U=function(e){return"SAMPLE"===String((null==e?void 0:e.lineType)||"").toUpperCase()||!0===(null==e?void 0:e.IsSample)||"true"===(null==e?void 0:e.IsSample)||!0===(null==e?void 0:e.isSample)||"true"===(null==e?void 0:e.isSample)?"SAMPLE":"PAID"},F=function(e){var t=new Map;return(Array.isArray(e)?e:[]).forEac
1h((function(e){var n,r,o,a=String((null==e?void 0:e.opnName)||"").trim();if(a){var i=U(e),l="".concat(a,"::").concat(i),u=t.get(l)||{};t.set(l,j(j(j({},u),e),{},{opnName:a,IsSample:"SAMPLE"===i,lineType:i,quantity:Number(null!==(n=null!==(r=null!==(o=null==e?void 0:e.quantity)&&void 0!==o?o:null==u?void 0:u.quantity)&&void 0!==r?r:null==e?void 0:e.qty)&&void 0!==n?n:0)}))}})),Array.from(t.values())},B=function(){var e=JSON.parse(localStorage.getItem("cart-data")||"[]"),t=F(e);return Array.isArray(e)&&e.length!==t.length&&localStorage.setItem("cart-data",JSON.stringify(t)),t},G=function(e){return localStorage.setItem("cart-data",JSON.stringify(F(e)))},H="cartDraft",V="cartSequenceTrace",Q="getcartme",J="getcartmeta",Y={},z="savecart",W="synccart",X="cartMetaPollBackoffUntil",Z="cartMetaPollFailureCount",$="cartMetaMockSkipLogged",ee="__ifxCartOpEventOwner",te="cartSessionExpiredPopupShown",ne="checkout:resumeAfterDkLogin",re="cart:dkPriorityConsumed",oe="cart:dkHostedPriorityApplied",ae="cart:dkOpenCount",ie="cart:dkLocallyTouchedLineKeys",le="cart:dkDeletedTombstones",ue="cart-level",ce="realtime",se=function(){var e,t;return"true"===new URLSearchParams((null===(e=window)||void 0===e||null===(e=e.location)||void 0===e?void 0:e.search)||"").get("debugCartTriggers")||"true"===(null===(t=window)||void 0===t||null===(t=t.localStorage)||void 0===t?void 0:t.getItem("cartTriggerDebug"))},de=function(){var e,t,n,r=new URLSearchParams((null===(e=window)||void 0===e||null===(e=e.location)||void 0===e?void 0:e.search)||"").get("mockCartApi");if("true"===r)return!0;if("false"===r)return!1;var o=String((null===(t=window)||void 0===t||null===(t=t.location)||void 0===t?void 0:t.hostname)||"").toLowerCase();return("localhost"===o||"127.0.0.1"===o)&&"mock"===(null===(n=window)||void 0===n||null===(n=n.localStorage)||void 0===n?void 0:n.getItem("cartApiMode"))},ve=function(){return function(){var e,t=String(localStorage.getItem("cart:dkSyncMode")||"").trim().toLowerCase();if(t===ue||t===ce)return t;var n=String((null===(e=window)||void 0===e||null===(e=e.digikeyDetails)||void 0===e||null===(e=e.data)||void 0===e?void 0:e.cartSyncMode)||"").trim().toLowerCase();return n===ue||n===ce?n:ue}()===ue},pe=function(){return"true"===sessionStorage.getItem(re)||"true"===localStorage.getItem(re)||"true"===sessionStorage.getItem(oe)||"true"===localStorage.getItem(oe)},me=function(){var e=Number(sessionStorage.getItem(ae)||0),t=Number(localStorage.getItem(ae)||0);return Number.isFinite(t)&&t>0?t:Number.isFinite(e)?e:0},fe=function(){var e;sessionStorage.setItem(re,"true"),localStorage.setItem(re,"true"),sessionStorage.setItem(oe,"true"),localStorage.setItem(oe,"true"),console.log("%c[Cart:Priority:FLAG] â
markDkCartPriorityConsumed â flag SET (next cart open = IFX priority)","color:#856404;font-weight:bold","| caller:",(null===(e=(new Error).stack)||void 0===e||null===(e=e.split("\n"))||void 0===e||null===(e=e[2])||void 0===e?void 0:e.trim())||"unknown")},ge=function(){var e=function(e){try{var t=JSON.parse(e||"[]");return Array.isArray(t)?t.filter(Boolean):[]}catch(e){return[]}};return new Set([].concat(P(e(sessionStorage.getItem(ie))),P(e(localStorage.getItem(ie)))))},ye=function(e,t){var n=Fe(e,t);if(n){var r,o,a=ge();a.add(n),r=a,o=JSON.stringify(Array.from(r||[])),sessionStorage.setItem(ie,o),localStorage.setItem(ie,o),console.log("%c[Cart:Priority:TOUCH] âï¸ locally touched line recorded: ".concat(n),"color:#8b5cf6;font-weight:bold")}},he=function(){sessionStorage.removeItem(ie),localStorage.removeItem(ie),console.log("%c[Cart:Priority:TOUCH] ð§¹ cleared locally touched line keys","color:#8b5cf6;font-weight:bold")},be=function(){var e;sessionStorage.removeItem(re),localStorage.removeItem(re),sessionStorage.removeItem(oe),localStorage.removeItem(oe),sessionStorage.removeItem(ae),localStorage.removeItem(ae),he(),console.log("%c[Cart:Priority:FLAG] ðï¸ clearDkCartPriorityConsumed â flag CLEARED (next cart open = DK priority)","color:#cc0000;font-weight:bold","| caller:",(null===(e=(new Error).stack)||void 0===e||null===(e=e.split("\n"))||void 0===e||null===(e=e[2])||void 0===e?void 0:e.trim())||"unknown")},ke=function(){return"true"===sessionStorage.getItem("cart:orderCompleted")&&(t=new URLSearchParams((null===(e=window)||void 0===e||null===(e=e.location)||void 0===e?void 0:e.search)||""),Boolean(t.get("orderNumber")));var e,t},Se=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};se()&&console.info("[CartTrigger]",e,j({at:(new Date).toISOString()},t))},we=function(){return"true"===(0,u.Ri)("IS_LOGGED_IN")&&Boolean((0,u.eJ)("userObject"))},Ie=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=Number(sessionStorage.getItem(Z)||0)+1;sessionStorage.setItem(Z,String(n));var r=404===t?3e5:Math.min(6e4,5e3*n),o=Date.now()+r;sessionStorage.setItem(X,String(o)),Se("meta_poll_backoff_applied",{reason:e,statusCode:t,failureCount:n,backoffMs:r,suppressUntil:o})},_e=function(e){return Array.isArray(e)?e.map((function(e){return"IN_FLIGHT"===(null==e?void 0:e.status)?j(j({},e),{},{status:"PENDING"}):e})):[]},Ce=function(e){return(Array.isArray(null==e?void 0:e.pendingOps)?e.pen
1dingOps:[]).filter((function(e){return"PENDING"===(null==e?void 0:e.status)||"IN_FLIGHT"===(null==e?void 0:e.status)}))},Ne=function(e){return Ce(e).length},Ee=function(e){return Ce(e).filter((function(e){return!0!==(null==e?void 0:e.isDeltaSyncOp)})).length},xe=function(e){return Ne(e)>0||Array.isArray(null==e?void 0:e.items)&&e.items.length>0||B().length>0},Oe=function(e,t){var n=Ce(t);if(0===n.length)return e||[];var r=We(e||[]),o=et(r,n);return Ze(o)},De=function(e,t){return Ne(t)>0?"PENDING":e?"SYNCED":"LOCAL_ONLY"},Ae=0,Le=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return se()?j({cycleId:Ae+=1,startedAtMs:Date.now()},e):null},Pe=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(se()&&e){var r=Date.now()-Number((null==e?void 0:e.startedAtMs)||Date.now());console.info("[CartTriggerSummary]",{cycleId:e.cycleId,outcome:t,durationMs:r,source:e.source,pendingCount:e.pendingCount,selector:n.selector||e.selector,method:n.method||"POST",statusCode:n.statusCode,cartId:n.cartId,version:n.version,hasMorePending:n.hasMorePending,message:n.message})}},Te=function(e,t){var n,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=t||(de()?"mock":"aem"),a=(null===(n=window)||void 0===n||null===(n=n.location)||void 0===n?void 0:n.pathname)||"/",i=a.replace(/\.html$/,""),l=i.split("/"),u=l.length-1;if(u>=0&&l[u]&&(l[u]=l[u].split(".")[0],i=l.join("/")),"mock"===o){if(e===z||e===W){var c="".concat(i,".").concat(e,".json");return Se("resolve_endpoint",{selector:e,endpoint:c,mode:"mock-servlet",originalPath:a,normalizedResourcePath:i}),c}var s="/api/cart/".concat(e,".json");return Se("resolve_endpoint",{selector:e,endpoint:s,mode:"mock",originalPath:a,normalizedResourcePath:i}),s}var d=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=M(M(M(M({},Q,(null==t?void 0:t.getcartmeApi)||(null==t?void 0:t.getcartmeapi)),J,(null==t?void 0:t.getcartmetaApi)||(null==t?void 0:t.getcartmetaapi)),z,(null==t?void 0:t.savecartApi)||(null==t?void 0:t.savecartapi)),W,(null==t?void 0:t.synccartApi)||(null==t?void 0:t.synccartapi))[e];return"string"==typeof n&&n.trim()?n.trim():null}(e,r);if(d)return Se("resolve_endpoint",{selector:e,endpoint:d,mode:"aem-injected",originalPath:a,normalizedResourcePath:i}),d;var v="".concat(i,".").concat(e,".json");return Se("resolve_endpoint",{selector:e,endpoint:v,mode:"aem",originalPath:a,normalizedResourcePath:i}),v},qe=function(e,t){var n=(e||[]).map((function(e){return{skuId:null==e?void 0:e.opnName,qty:Number((null==e?void 0:e.quantity)||0),lineType:null!=e&&e.IsSample?"SAMPLE":"PAID"}})),r={status:t?"SYNCED":"LOCAL_ONLY",items:n,badge:{itemCount:n.length},pendingOps:[],updatedAt:(new Date).toISOString()};return r.status=De(t,r),r},Re=function(e,t){return"SAMPLE"===e||"PAID"===e?e:t?"SAMPLE":"PAID"},je=function(e){return{items:((null==e?void 0:e.items)||[]).map((function(e){return{opnName:null==e?void 0:e.skuId,qty:Number((null==e?void 0:e.qty)||0),lineType:Re(null==e?void 0:e.lineType)}}))}},Me=function(e){return"DELETE"===e||"removeLine"===e?"DELETE":"INSERT"===e||"insertLine"===e?"INSERT":"UPDATE"},Ke=function(e){return"".concat((null==e?void 0:e.skuId)||"","::").concat(Re(null==e?void 0:e.lineType))},Ue=function(e,t){var n=String(e||"").trim();if(!n)return 0;for(var r=Re(t),o=it(),a=Array.isArray(null==o?void 0:o.pendingOps)?o.pendingOps.filter((function(e){return"PENDING"===(null==e?void 0:e.status)||"IN_FLIGHT"===(null==e?void 0:e.status)})):[],i=a.length-1;i>=0;i-=1){var l,u,c,s=a[i],d=String((null==s||null===(l=s.payload)||void 0===l?void 0:l.skuId)||"").trim(),v=Re(null==s||null===(u=s.payload)||void 0===u?void 0:u.lineType);if(d===n&&v===r){if("DELETE"===Me(null==s?void 0:s.op))return 0;var p=Number((null==s||null===(c=s.payload)||void 0===c?void 0:c.qty)||0);if(p>0)return p}}return 0},Fe=function(e,t){var n=String(e||"").trim().toUpperCase();return n?"".concat(n,"::").concat(Re(t)):""},Be=function(e,t,n){var r=String((null==e?void 0:e.opnName)||(null==e?void 0:e.skuId)||"").trim().toUpperCase(),o=String(t||"").trim().toUpperCase();return!(!r||!o||r!==o)&&Re(null==e?void 0:e.lineType,Boolean((null==e?void 0:e.IsSample)||(null==e?void 0:e.isSample)))===Re(n)},Ge=function(){try{var e=JSON.parse(sessionStorage.getItem(le)||"{}");return e&&"object"===L(e)?e:{}}catch(e){return{}}},He=function(e){sessionStorage.setItem(le,JSON.stringify(e||{}))},Ve=function(e){var t=Date.now(),n=!1,r=j({},e||{});return Object.keys(r).forEach((function(e){t-Number(r[e]||0)>
1216e5&&(delete r[e],n=!0)})),{next:r,changed:n}},Qe=function(e,t){var n=Fe(e,t);if(n){var r=Ge(),o=Ve(r).next;Object.prototype.hasOwnProperty.call(o,n)&&(delete o[n],He(o))}},Je=function(e,t){var n=Fe(e,t);if(!n)return!1;var r=Ge(),o=Ve(r),a=o.next;return o.changed&&He(a),Object.prototype.hasOwnProperty.call(a,n)},Ye=function(e){var t=Ge(),n=Ve(t),r=n.next,o=n.changed,a=j({},r),i=o;Object.keys(a).forEach((function(t){e.has(t)||(delete a[t],i=!0)})),i&&He(a)},ze=function(e){return{ops:(e||[]).map((function(e){var t,n,r,o;return{op:Me(null==e?void 0:e.op),item:{opnName:null==e||null===(t=e.payload)||void 0===t?void 0:t.skuId,qty:"DELETE"===Me(null==e?void 0:e.op)?Number((null==e||null===(n=e.payload)||void 0===n?void 0:n.qty)||0):Math.max(1,Number((null==e||null===(r=e.payload)||void 0===r?void 0:r.qty)||0)),lineType:Re(null==e||null===(o=e.payload)||void 0===o?void 0:o.lineType)}}}))}},We=function(e){return(e||[]).map((function(e){return{skuId:null==e?void 0:e.opnName,qty:Number((null==e?void 0:e.qty)||0),lineType:Re(null==e?void 0:e.lineType)}}))},Xe=function(e,t){var n,r,o,a=Me(null==e?void 0:e.op),i=String((null==e||null===(n=e.payload)||void 0===n?void 0:n.skuId)||"").trim(),l=Re(null==e||null===(r=e.payload)||void 0===r?void 0:r.lineType),u=Number((null==e||null===(o=e.payload)||void 0===o?void 0:o.qty)||0);if(!i)return!1;var c=(Array.isArray(t)?t:[]).find((function(e){return String((null==e?void 0:e.skuId)||"").trim()===i&&Re(null==e?void 0:e.lineType)===l}));return"DELETE"===a?!c||Number((null==c?void 0:c.qty)||0)<=0:Boolean(c)&&Number((null==c?void 0:c.qty)||0)===u},Ze=function(e){return(e||[]).map((function(e){return{opnName:null==e?void 0:e.skuId,qty:Number((null==e?void 0:e.qty)||0),lineType:Re(null==e?void 0:e.lineType)}}))},$e=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:B();return(Array.isArray(e)?e:[]).map((function(e){var n,r="SAMPLE"===String((null==e?void 0:e.lineType)||"").toUpperCase(),o=(null==e?void 0:e.opnName)||(null==e?void 0:e.skuId),a=(Array.isArray(t)?t:[]).find((function(e){return Be(e,o,r?"SAMPLE":"PAID")})),i=Number((null==e?void 0:e.qty)||(null==e?void 0:e.quantity)||0),l=Number((null==a?void 0:a.quantity)||(null==a?void 0:a.qty)||0),u=Ue(o,r?"SAMPLE":"PAID"),c=i>0?i:u>0?u:l>0?l:i;return j(j({},a||{}),{},{opnName:o,quantity:c,IsSample:r,lineId:(null==e?void 0:e.lineId)||null,lineType:r?"SAMPLE":"PAID",fromRemote:!a||(null===(n=a.fromRemote)||void 0===n||n),lastSyncedAt:(new Date).toISOString()})}))},et=function(e,t){var n=new Map;return(e||[]).forEach((function(e){var t=Re(null==e?void 0:e.lineType),r="".concat(null==e?void 0:e.skuId,"::").concat(t);n.set(r,{skuId:null==e?void 0:e.skuId,qty:Number((null==e?void 0:e.qty)||0),lineType:t})})),(t||[]).forEach((function(e){var t,r,o,a,i,l=null==e||null===(t=e.payload)||void 0===t?void 0:t.skuId;if(l){var u=Re(null==e||null===(r=e.payload)||void 0===r?void 0:r.lineType),c="".concat(l,"::").concat(u),s=Me(null==e?void 0:e.op),d=Number((null===(o=n.get(c))||void 0===o?void 0:o.qty)||0),v="DELETE"===s?Number((null==e||null===(a=e.payload)||void 0===a?void 0:a.qty)||0):Math.max(1,Number((null==e||null===(i=e.payload)||void 0===i?void 0:i.qty)||d||1));"DELETE"!==s?n.set(c,{skuId:l,qty:v,lineType:u}):n.delete(c)}})),Array.from(n.values())},tt=function(e){var t=B(),n=function(e){var t=String((null==e?void 0:e.opnName)||(null==e?void 0:e.skuId)||"").trim().toUpperCase();if(!t)return"";var n=Re(null==e?void 0:e.lineType,Boolean((null==e?void 0:e.IsSample)||(null==e?void 0:e.isSample)));return"".concat(t,"::").concat(n)},r=(e||[]).map((function(e){var n,r="SAMPLE"===Re(null==e?void 0:e.lineType),o=t.find((function(t){return Be(t,null==e?void 0:e.opnName,r?"SAMPLE":"PAID")})),a=Number((null==e?void 0:e.qty)||0),i=Number((null==o?void 0:o.quantity)||(null==o?void 0:o.qty)||0),l=Ue(null==e?void 0:e.opnName,r?"SAMPLE":"PAID"),u=a>0?a:l>0?l:i>0?i:a;return j(j({},o||{}),{},{opnName:null==e?void 0:e.opnName,quantity:u,IsSample:r,fromRemote:!o||(null===(n=o.fromRemote)||void 0===n||n),lastSyncedAt:(new Date).toISOString()})})),o=new Set(r.map((function(e){return n(e)}
1)).filter(Boolean));if(t.forEach((function(e){var t=n(e);t&&!o.has(t)&&!0!==(null==e?void 0:e.fromRemote)&&r.push(j(j({},e),{},{fromRemote:!1}))})),0===r.length){var a=it();return xe(a)?void Se("merge_skip_local_clear_due_to_draft",{draftItemCount:Array.isArray(null==a?void 0:a.items)?a.items.length:0,pendingOpsCount:Ne(a)}):void localStorage.removeItem("cart-data")}G(r)},nt=function(e){var t=String((null==e?void 0:e.opnName)||(null==e?void 0:e.skuId)||"").trim().toUpperCase();if(!t)return"";var n=Re(null==e?void 0:e.lineType,Boolean((null==e?void 0:e.IsSample)||(null==e?void 0:e.isSample)));return"".concat(t,"::").concat(n)},rt=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=F(Array.isArray(e)?e:[]),n=it(),r=Array.isArray(null==n?void 0:n.items)?n.items:[];if(0===r.length||Ne(n)>0)return t;if(0===t.length&&(Array.isArray(null==n?void 0:n.pendingOps)?n.pendingOps:[]).some((function(e){return"DELETE"===(null==e?void 0:e.operation)&&"PENDING"===(null==e?void 0:e.status)})))return t;if(!(Boolean(null==n?void 0:n.cartId)||Number((null==n?void 0:n.version)||0)>0))return t;var o=new Set(t.map((function(e){return nt(e)})).filter(Boolean)),a=new Set(r.map((function(e){return nt(e)})).filter(Boolean));if(o.size===a.size&&Array.from(o).every((function(e){return a.has(e)})))return t;var i=$e(Ze(r),t);return G(i),Se("cart_data_reconciled_from_draft_snapshot",{localCount:t.length,draftCount:i.length,version:Number((null==n?void 0:n.version)||0)}),i},ot=function(e,t){try{var n=JSON.parse(localStorage.getItem(V)||"[]");n.push({at:(new Date).toISOString(),event:e,payload:t}),localStorage.setItem(V,JSON.stringify(n.slice(-100)))}catch(e){console.warn("[CartSequence] trace write failed",e)}},at=!1,it=function(){try{var e=JSON.parse(localStorage.getItem(H)||"{}");if(Array.isArray(null==e?void 0:e.pendingOps)){var t=_e(e.pendingOps);t.some((function(t,n){var r;return(null==t?void 0:t.status)!==(null==e||null===(r=e.pendingOps)||void 0===r||null===(r=r[n])||void 0===r?void 0:r.status)}))&&(e.pendingOps=t,localStorage.setItem(H,JSON.stringify(e)),Se("pending_ops_recovered",{recoveredCount:t.filter((function(e){return"PENDING"===(null==e?void 0:e.status)})).length}))}return e}catch(e){return console.warn("[CartSync] Failed to read cart draft",e),{}}},lt=function(e){var t,r,i,l,v,p,m,f,g=A((0,a.useState)({}),2),y=g[0],h=g[1],S=A((0,a.useState)(!1),2),w=S[0],O=S[1],L=A((0,a.useState)(!1),2),q=L[0],R=L[1],M=A((0,a.useState)(!0),2),V=M[0],re=M[1],oe=A((0,a.useState)({}),2),ie=oe[0],le=oe[1],ue=A((0,a.useState)(0),2),ce=ue[0],se=ue[1],Ae=A((0,a.useState)([]),2),Ue=Ae[0],Be=Ae[1],nt=A((0,a.useState)(""),2),lt=nt[0],ut=nt[1],ct=A((0,a.useState)({}),2),st=ct[0],dt=ct[1],vt=A((0,a.useState)([]),2),pt=vt[0],mt=vt[1],ft=(0,a.useRef)([]),gt=A((0,a.useState)(!1),2),yt=gt[0],ht=gt[1],bt=null===(t=window)||void 0===t||null===(t=t.digikeyDetails)||void 0===t||null===(t=t.data)||void 0===t?void 0:t.clientId,kt=A((0,a.useState)(!1),2),St=kt[0],wt=kt[1],It=A((0,a.useState)(!1),2),_t=It[0],Ct=It[1],Nt=A((0,a.useState)(!1),2),Et=Nt[0],xt=Nt[1],Ot=A((0,a.useState)(!0),2),Dt=Ot[0],At=Ot[1],Lt=A((0,a.useState)((null===(r=window)||void 0===r||null===(r=r.digikeyDetails)||void 0===r||null===(r=r.data)||void 0===r?void 0:r.language)||"en"),2),Pt=Lt[0],Tt=(Lt[1],A((0,a.useState)([]),2)),qt=Tt[0],Rt=Tt[1],jt=A((0,a.useState)(!0),2),Mt=jt[0],Kt=jt[1],Ut=A((0,a.useState)(!1),2),Ft=Ut[0],Bt=Ut[1],Gt=A((0,a.useState)([]),2),Ht=Gt[0],Vt=Gt[1],Qt=A((0,a.useState)(!1),2),Jt=Qt[0],Yt=Qt[1],zt=A((0,a.useState)(!1),2),Wt=zt[0],Xt=zt[1],Zt=A((0,a.useState)(!1),2),$t=Zt[0],en=Zt[1],tn=A((0,a.useState)(!1),2),nn=tn[0],rn=tn[1],on=A((0,a.useState)(!1),2),an=on[0],ln=on[1],un=A((0,a.useState)(!1),2),cn=un[0],sn=un[1],dn=A((0,a.useState)("IDLE"),2),vn=dn[0],pn=dn[1],mn=A((0,a.useState)(0),2),fn=mn[0],gn=mn[1],yn=A((0,a.useState)(""),2),hn=yn[0],bn=yn[1],kn=["Cut Tape (CT)","Box"],Sn=(0,u.NZ)(),wn=(0,u.Qn)(localStorage.getItem("ifxCurrencyId")),In=A((0,a.useState)(!1),2),_n=In[0],Cn=In[1],Nn=A((0,a.useState)(!1),2),En=Nn[0],xn=Nn[1],On=(0,a.useRef)(null),Dn=(0,a.useRef)(null);ft.current=pt;var An,Ln=function(e){var t;if(!e||!e.priceTiers||0===e.priceTiers.length)return null;var n=e.priceTiers.filter((function(e){return kn.includes(e.packageType)}));if(0===n.length&&(n=e.priceTiers.filter((function(e){return!kn.includes(e.packageType)}))),0===n.length||null===(t=n[0])||void 0===t||!t.pricing)return null;var r=n[0].pricing.filter((function(e){return 0!==e.breakQuantity}));return 0===r.length?null:(r.sort((function(e,t){return e.breakQuantity-t.breakQuantity})),{PriceBreaks:r.map((function(e){return{Quantity:e.breakQuantity,Price:parseFloat(e.unitPrice)}})),currency:Sn||"USD"})},Pn=!1,Tn=(0,a.useRef)([]),qn=(0,a.useRef)(null),Rn=(0,a.useRef)(0),jn=(0,a.useRef)(new Map),Mn=(0,a.useRef)(!1),Kn=(0,a.useRef)(!1),Un=(0,a.useRef)(null),Fn=(0,a.useRef)(!1),Bn=(0,a.useRef)(!1),Gn=(0,a.useRef)(!1),Hn=(0,a.useRef)(!1),Vn=(0,a.useRef)(Promise.resolve()),Qn=(0,a.useRef)(null),Jn=A((0,a.useState)(""),2),Yn=Jn[0],zn=Jn[1],Wn=a.useCallback((function(){var e=Qn.current;if(e)if(e.scrollHeight<=e.clientHeight+2)zn("");else{var t=e.scrollTop<=1,n=e.scrollHeight-e.scrollTop-e.clientHeight<=2;zn(t&&n?"":t?"shadow-bottom":n?"shadow-top":"shadow-both")}}),[]),Xn=JSON.parse(null===(i=sessionStorage)||void 0===i?void 0:i.getItem("pageValue")),Zn=null==e?void 0:e.componentname,$n="&ui_locales="+o()("html").attr("lang"),er=String((null===(l=window)||void 0===l?void 0:l.loginUrl)||(null===(v=window)||void 0===v||null===(v=v.digikeyDetails)||void 0===v||null===(v=v.data)||void 0===v?void 0:v.loginUrl)||"/login"),tr=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=rt(B()),o="true"===(0,u.Ri)("IS_LOGGED_IN")&&(0,u.eJ)("userObject");
1if(ke()){localStorage.removeItem("cart-data");var a={status:o?"SYNCED":"LOCAL_ONLY",items:[],badge:{itemCount:0},pendingOps:[],updatedAt:(new Date).toISOString(),cartId:null,version:0};return rr(a),ot(e,j(j({},n),{},{itemCount:0,status:a.status,reason:"order_completed_reset_guard"})),gn(0),a}var i=function(e,t){var n=JSON.parse(localStorage.getItem(H)||"{}"),r=qe(e,t);return r.pendingOps=Array.isArray(null==n?void 0:n.pendingOps)?n.pendingOps:[],r.version=Number((null==n?void 0:n.version)||0),r.cartId=(null==n?void 0:n.cartId)||null,r.status=De(t,r),r}(r,o),l=it();return i.pendingOps=_e(Array.isArray(null==l?void 0:l.pendingOps)?l.pendingOps:null==i?void 0:i.pendingOps),i.version=Number((null==l?void 0:l.version)||(null==i?void 0:i.version)||0),i.cartId=(null==l?void 0:l.cartId)||(null==i?void 0:i.cartId)||null,i.status=De(o,i),rr(i),ot(e,j(j({},n),{},{itemCount:(null==i||null===(t=i.badge)||void 0===t?void 0:t.itemCount)||0,status:null==i?void 0:i.status})),gn(Ne(i)),i},nr=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};window.dispatchEvent(new CustomEvent("ifx:cart-sync",{detail:j({eventType:e,at:(new Date).toISOString()},t)}))},rr=function(e){var t=j(j({},e),{},{pendingOps:_e(null==e?void 0:e.pendingOps)});localStorage.setItem(H,JSON.stringify(t)),gn(Ne(t))},or=function(){var e=it();return Array.isArray(null==e?void 0:e.items)?e:tr("cart_draft_bootstrap",{source:"worker"})},ar=function(e){return(Array.isArray(e)?e:[]).map((function(e){return(null==e?void 0:e.opnName)||(null==e?void 0:e.skuId)})).filter(Boolean).join(",")},ir=function(e){var t=Array.isArray(e)?e.length:Math.max(0,Number(e||0));document.querySelectorAll(".cart-button").forEach((function(e){var n=e.querySelector(".indicator")||e.childNodes[0];n&&(0===t?(n.style.display="none",n.innerHTML=""):(n.style.display="inline-flex",n.innerHTML=t))}))},lr=function(e,t){var n,r=Array.isArray(null==t||null===(n=t.data)||void 0===n?void 0:n.getCartProductDetails)?t.data.getCartProductDetails:Array.isArray(t)?t:[],o=new Map(r.map((function(e){return[String((null==e?void 0:e.opnName)||(null==e?void 0:e.manufacturerPartNumber)||"").toLowerCase(),e]})));return(Array.isArray(e)?e:[]).map((function(e){var t=o.get(String((null==e?void 0:e.opnName)||(null==e?void 0:e.skuId)||"").toLowerCase());return t?j(j({},e),{},{imageUrl:t.imageUrl||e.imageUrl,productName:t.productName||e.productName,productTitle:t.productTitle||e.productTitle,topLevelCategory:t.topLevelCategory||e.topLevelCategory,productUrl:t.productUrl?(0,u.IT)(t.productUrl):e.productUrl}):e}))},ur=function(){var e=rt(B());wt(null==e?void 0:e.some((function(e){return!(null!=e&&e.IsSample)}))),Ct(null==e?void 0:e.some((function(e){return null==e?void 0:e.IsSample})));var t=e.reduce((function(e,t){var n=t.opnName,r=t.IsSample,o=t.quantity;return e[n]||(e[n]={}),e[n][Boolean(r)]=o,e}),{});return dt(t),Tn.current=null==e?void 0:e.map((function(e,t){return Tn.current[t]||a.createRef()})),ir(e),e},cr=function(){var t=D(x().mark((function t(){var n,r,o,a,i,l,u,c,s,d,v,p=arguments;return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=p.length>0&&void 0!==p[0]&&p[0],r=ur(),tr("cart_state_loaded",{initModal:n,cartSize:(null==r?void 0:r.length)||0}),o={};try{o=JSON.parse((null==e?void 0:e.authorlabel)||"{}")}catch(e){o={}}a={};try{a=JSON.parse((null==e?void 0:e.labels)||"{}")}catch(e){a={}}if(h(o),le(a),!((null==r?void 0:r.length)>0)){t.next=48;break}if(!n){t.next=29;break}return rn(!0),t.prev=12,t.next=15,xr(Er(r));case 15:i=t.sent,mt(i),vr(i,r),t.next=24;break;case 20:t.prev=20,t.t0=t.catch(12),console.error("[Cart] Error in getProductInfo:",t.t0),vr([],r);case 24:return t.prev=24,rn(!1),t.finish(24);case 27:t.next=46;break;case 29:if(l=ft.current,0!==(u=Array.isArray(l)&&l.length>0?l:[]).length){t.next=45;break}return t.prev=32,s=ar(r),t.next=36,Nr(s);case 36:d=t.sent,v=Array.isArray(null==d||null===(c=d.data)||void 0===c?void 0:c.getCartProductDetails)?d.data.getCartProductDetails:[],Wr()&&console.log("[Cart][StockDebug] updateCart(false) OPN fallback result",{requestedMpns:s,fetchedCount:v.length,fetchedKeys:v.slice(0,8).map((function(e){return zr(e)}
1)).filter(Boolean)}),v.length>0&&(u=v,mt(v)),t.next=45;break;case 42:t.prev=42,t.t1=t.catch(32),console.warn("[Cart] updateCart(false): products-via-opns fallback failed",t.t1);case 45:vr(u,r);case 46:t.next=49;break;case 48:dr();case 49:return t.abrupt("return",r);case 50:case"end":return t.stop()}}),t,null,[[12,20,24,27],[32,42]])})));return function(){return t.apply(this,arguments)}}(),sr=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=Vn.current.catch((function(){})).then((function(){return cr(e)}));return Vn.current=t,t},dr=function(){le({}),Be([]),wt(!1),Ct(!1),se(0),O(!1),Cn(!0),at&&1==(null==e?void 0:e.index)&&Mr("view_cart"),localStorage.removeItem("cart-data")},vr=function(t,n){var r,o,a,i,l,u,c,s=function(e,t){var n,r=[],o=0,a=0,i=0,l=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=T(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,l=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return i=e.done,e},e:function(e){l=!0,a=e},f:function(){try{i||null==n.return||n.return()}finally{if(l)throw a}}}}(e);try{var u=function(){var e,i,l=n.value,u=String((null==l?void 0:l.opnName)||"").trim().toLowerCase(),c=null==t?void 0:t.find((function(e){return zr(e)===u}));!c&&Wr()&&console.log("[Cart][StockDebug] no stock match for cart line",{cartOpn:u,availableKeys:(Array.isArray(t)?t:[]).slice(0,8).map((function(e){return zr(e)})).filter(Boolean)});var s,d=Number.isFinite(Number(null==l?void 0:l.localStock))&&void 0!==(null==l?void 0:l.localStock)?Number(l.localStock):0,v=Number.isFinite(Number(null==l?void 0:l.unitPrice))?Number(l.unitPrice):0,p=io(c,l.quantity,{fallbackAvailability:d,fallbackPricePerUnit:v});(l.pricing=p,l.quantityAvailable=p?p.availability:0,l.localStock=l.quantityAvailable,l.sampleLimit=null!==(e=null==c?void 0:c.sampleLimit)&&void 0!==e?e:l.sampleLimit,l.IsSample||(l.stockError=0===l.quantityAvailable),!l.IsSample&&c&&l.quantityAvailable>0&&l.quantity>l.quantityAvailable&&(l.quantity=l.quantityAvailable,p=io(c,l.quantity,{fallbackAvailability:d,fallbackPricePerUnit:v}),l.pricing=p),(null===(i=l.pricing)||void 0===i?void 0:i.pricePerUnit)!=l.unitPrice)&&(l.unitPrice=null===(s=l.pricing)||void 0===s?void 0:s.pricePerUnit);o+=l.quantity,l.IsSample||(a+=l.quantityAvailable&&p.subTotal),r.push(l)};for(l.s();!(n=l.n()).done;)u()}catch(e){l.e(e)}finally{l.f()}return{cartDetailsObject:r,totalCartQuantity:o,totalCartPrice:a+i}}(n,t);console.log("[Cart] updateCartFunc: Setting cartDetails",{cartItemCount:(null===(r=s.cartDetailsObject)||void 0===r?void 0:r.length)||0,hasProductDetails:Array.isArray(t)&&t.length>0,firstItemOpn:null===(o=s.cartDetailsObject)||void 0===o||null===(o=o[0])||void 0===o?void 0:o.opnName,firstItemPricing:null===(a=s.cartDetailsObject)||void 0===a||null===(a=a[0])||void 0===a||null===(a=a.pricing)||void 0===a?void 0:a.pricePerUnit,firstItemAvailability:null===(i=s.cartDetailsObject)||void 0===i||null===(i=i[0])||void 0===i?void 0:i.quantityAvailable}),Be(s.cartDetailsObject),wt(null===(l=s.cartDetailsObject)||void 0===l?void 0:l.some((function(e){return!e.IsSample}))),Ct(null===(u=s.cartDetailsObject)||void 0===u?void 0:u.some((function(e){return e.IsSample}))),se(s.totalCartPrice),Cn(!0),dt((function(e){var t=j({},e);return s.cartDetailsObject.forEach((function(e){var n=null==e?void 0:e.opnName,r=Boolean(null==e?void 0:e.IsSample);n&&(t[n]||(t[n]={}),t[n][r]=Number((null==e?void 0:e.quantity)||0))})),t})),(Array.isArray(t)&&t.length>0||(null===(c=s.cartDetailsObject)||void 0===c?void 0:c.length)>0)&&G(s.cartDetailsObject),function(e){var t;if(nn)return;var n=null==e||null===(t=e.filter((function(e){var t;return 0===(null==e||null===(t=e.pricing)||void 0===t?void 0:t.availability)})))||void 0===t?void 0:t.length,r=null==e?void 0:e.filter((function(e){return!0===e.stockError}));(null==r?void 0:r.length)>=1||n?re(!1):re(!0)}(s.cartDetailsObject),at&&1==(null==e?void 0:e.index)&&Mr("view_cart")},pr=(0,a.useCallback)(D(x().mark((function t(){var n,r,o,a,i,l,u,c,s,d,v,p,m,f,g,y,h,b,k,S,w,I,_,C,N,E,O,D,A,L,P,T,q,R,M,K,U,F,B,G,H,V,Q,J,Y,X,Z,$,ee=arguments;return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=ee.length>0&&void 0!==ee[0]?ee[0]:"worker",r=de(),o="cart_open"===n||"cart_open_after_sso"===n,a=(we()||o)&&!r,r||a){t.next=7;break}return Se("flush_skipped_no_target",{source:n,isLoggedIn:we(),isCartOpenSource:o}),t.abrupt("return");case 7:if(!Mn.current){t.next=10;break}return Kn.current=!0,t.abrupt("return");case 10:if(i=or(),0===(l=((null==i?void 0:i.pendingOps)||[]).filter((function(e){return"PENDING"===(null==e?void 0:e.status)}))).length&&(u=((null==i?void 0:i.pendingOps)||[]).filter((function(e){return"IN_FLIGHT"===(null==e?void 0:e.status)}))).length>0&&(Se("flush_requeue_stale_in_flight",{source:n,staleCount:u.length}),i.pendingOps=((null==i?void 0:i.pendingOps)||[]).map((function(e){return"IN_FLIGHT"!==(null==e?void 0:e.status)?e:j(j({},e),{},{status:"PENDING",retryCount:Number((null==e?void 0:e.retryCount)||0)+1})}
1)),rr(i),l=((null==i?void 0:i.pendingOps)||[]).filter((function(e){return"PENDING"===(null==e?void 0:e.status)}))),0!==l.length){t.next=15;break}return t.abrupt("return");case 15:c=Boolean(null==i?void 0:i.cartId)||Number((null==i?void 0:i.version)||0)>0,Se("flush_started",{source:n,pendingCount:l.length,draftCartId:(null==i?void 0:i.cartId)||null,draftVersion:Number((null==i?void 0:i.version)||0)}),de()?Se("flush_mock_mode_details",{source:n,selector:c?W:z,pendingOpsCount:l.length,pendingOpIds:l.map((function(e){return e.opId})).slice(0,3),draftCartId:null==i?void 0:i.cartId,draftVersion:null==i?void 0:i.version}):a&&Se("flush_actual_mode_details",{source:n,selector:c?W:z,pendingOpsCount:l.length,pendingOpIds:l.map((function(e){return e.opId})).slice(0,3),draftCartId:null==i?void 0:i.cartId,draftVersion:null==i?void 0:i.version,endpointMode:"aem",isLoggedIn:we()}),s=Le({source:n,pendingCount:l.length}),Mn.current=!0,pn("SYNCING"),d=l.map((function(e){return e.opId})),i.pendingOps=(i.pendingOps||[]).map((function(e){return d.includes(e.opId)?j(j({},e),{},{status:"IN_FLIGHT"}):e})),rr(i),ot("worker_sync_started",{source:n,sentOpIds:d,pendingCount:l.length}),v=0,p={},t.prev=27,h=c?W:z,b=c?ze(l):je(i),k=[],r&&k.push({mode:"mock",endpoint:Te(h,"mock",e)}),a&&k.push({mode:"aem",endpoint:Te(h,"aem",e)}),S=[],w=0;case 35:if(!(w<k.length)){t.next=55;break}return I=k[w],t.next=39,fetch(I.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});case 39:return _=t.sent,C={},t.prev=41,t.next=44,_.json();case 44:C=t.sent,t.next=50;break;case 47:t.prev=47,t.t0=t.catch(41),C={};case 50:S.push(j(j({},I),{},{ok:_.ok,status:_.status,payload:C})),Se("flush_request_sent",{source:n,selector:h,method:"POST",pendingCount:l.length,endpointMode:I.mode,endpoint:I.endpoint,statusCode:_.status});case 52:w+=1,t.next=35;break;case 55:if(s&&(s.selector=h),N=a?S.find((function(e){return"aem"===e.mode})):S[0],v=Number((null==N?void 0:N.status)||0),p=(null==N?void 0:N.payload)||{},null!=N&&N.ok){t.next=67;break}if(a||!r||403!==v&&404!==v){t.next=66;break}Se("flush_mock_non_ok_local_fallback",{source:n,selector:h,statusCode:v,message:(null===(E=p)||void 0===E?void 0:E.error)||"mock endpoint blocked"}),p=j(j({},p||{}),{},{cartId:(null==i?void 0:i.cartId)||null,version:Number((null==i?void 0:i.version)||0)+1,items:Ze(et((null==i?void 0:i.items)||[],l))}),v=200,t.next=67;break;case 66:throw new Error((null===(O=p)||void 0===O?void 0:O.error)||"sync failed: ".concat(v));case 67:S.filter((function(e){return e!==N&&!e.ok})).forEach((function(e){var t;Se("flush_secondary_failed",{source:n,selector:h,endpointMode:e.mode,statusCode:e.status,message:(null==e||null===(t=e.payload)||void 0===t?void 0:t.error)||"secondary sync failed"})})),!a&&r&&Se("flush_mock_applied_no_actual",{source:n,selector:h,statusCode:v}),D=it(),A=new Set(d),L=((null==D?void 0:D.pendingOps)||[]).length,D.pendingOps=((null==D?void 0:D.pendingOps)||[]).filter((function(e){return!A.has(e.opId)}
1)),P=D.pendingOps.length,T=L-P,!a&&r?(Se("flush_mock_ops_cleared",{source:n,selector:h,sentOpCount:d.length,clearedCount:T,beforeClearCount:L,afterClearCount:P}),P>0&&d.length>0&&0===T&&(Se("flush_mock_safety_clear_applied",{reason:"ops_not_cleared_by_opid_match",forceClearCount:P}),D.pendingOps=[])):a&&(Se("flush_actual_ops_cleared",{source:n,selector:h,sentOpCount:d.length,clearedCount:T,beforeClearCount:L,afterClearCount:P,endpointMode:"aem"}),P>0&&d.length>0&&0===T&&(Se("flush_actual_warning_ops_not_cleared",{reason:"ops_not_cleared_by_opid_match",remainingCount:P,sentOpCount:d.length}),q=((null==D?void 0:D.pendingOps)||[]).length,D.pendingOps=((null==D?void 0:D.pendingOps)||[]).filter((function(e){return"IN_FLIGHT"!==(null==e?void 0:e.status)})),R=((null==D?void 0:D.pendingOps)||[]).length,Se("flush_actual_safety_clear_in_flight_applied",{reason:"ops_not_cleared_by_opid_match",beforeSafetyClear:q,afterSafetyClear:R,clearedCount:q-R}))),D.cartId=(null===(m=p)||void 0===m?void 0:m.cartId)||(null==D?void 0:D.cartId)||(null==i?void 0:i.cartId)||null,D.version=Number((null===(f=p)||void 0===f?void 0:f.version)||(null==D?void 0:D.version)||(null==i?void 0:i.version)||0),M=!a&&r?et((null==i?void 0:i.items)||(null==D?void 0:D.items)||[],l):We(null===(g=p)||void 0===g?void 0:g.items),D.items=M,K=((null==D?void 0:D.pendingOps)||[]).length,D.pendingOps=((null==D?void 0:D.pendingOps)||[]).filter((function(e){return"PENDING"!==(null==e?void 0:e.status)&&"IN_FLIGHT"!==(null==e?void 0:e.status)||!Xe(e,M)})),(U=((null==D?void 0:D.pendingOps)||[]).length)<K&&Se("flush_redundant_ops_cleared_after_server_sync",{source:n,selector:h,clearedCount:K-U,beforeCount:K,afterCount:U}),D.status=De(we(),D),D.updatedAt=(new Date).toISOString(),rr(D),tt(!a&&r?Ze(M):null===(y=p)||void 0===y?void 0:y.items),cr(!1),F=((null==D?void 0:D.pendingOps)||[]).length>0,pn(F?"PENDING":"IDLE"),gn(Ne(D)),ot("worker_sync_success",{source:n,sentOpIds:d,serverVersion:D.version,cartId:D.cartId,hasMorePending:F}),nr("SYNC_SUCCESS",{sentOpIds:d,serverVersion:D.version,hasMorePending:F}),Se("flush_success",{source:n,selector:h,statusCode:v,cartId:D.cartId,version:D.version,hasMorePending:F}),Pe(s,"success",{selector:h,method:"POST",statusCode:v,cartId:D.cartId,version:D.version,hasMorePending:F}),F&&qn.current&&qn.current.postMessage({type:"TRIGGER_SYNC"}),F&&pr("post_success_has_more_pending"),t.next=113;break;case 100:t.prev=100,t.t1=t.catch(27),V=it(),Q=new Set(d),V.pendingOps=((null==V?void 0:V.pendingOps)||[]).map((function(e){return Q.has(e.opId)?j(j({},e),{},{status:"PENDING",retryCount:Number(e.retryCount||0)+1}):e})),412===v&&Number((null===(B=p)||void 0===B?void 0:B.version)||0)>0?(V.version=Number(p.version),nr("VERSION_CONFLICT",{currentVersion:V.version}),Se("version_conflict_requires_refresh",{currentVersion:V.version,pendingCount:Number((null==V||null===(J=V.pendingOps)||void 0===J?void 0:J.length)||0)})):401===v&&(nr("AUTH_REQUIRED",{message:(null===(Y=p)||void 0===Y?void 0:Y.error)||(null===t.t1||void 0===t.t1?void 0:t.t1.message)||"auth required"}),Ur()),V.updatedAt=(new Date).toISOString(),V.status=De(we(),V),rr(V),de()?Se("flush_mock_mode_failed",{source:n,selector:Number((null==i?void 0:i.version)||0)>0||Boolean(null==i?void 0:i.cartId)?W:z,statusCode:v,remainingPendingCount:((null==V?void 0:V.pendingOps)||[]).length,message:(null===(X=p)||void 0===X?void 0:X.error)||(null===t.t1||void 0===t.t1?void 0:t.t1.message)||"unknown"}):a&&Se("flush_actual_mode_failed",{source:n,selector:Number((null==i?void 0:i.version)||0)>0||Boolean(null==i?void 0:i.cartId)?W:z,statusCode:v,remainingPendingCount:((null==V?void 0:V.pendingOps)||[]).length,retryCount:(null==V||null===(Z=V.pendingOps)||void 0===Z||null===(Z=Z[0])||void 0===Z?void 0:Z.retryCount)||0,message:(null===($=p)||void 0===$?void 0:$.error)||(null===t.t1||void 0===t.t1?void 0:t.t1.message)||"unknown",endpointMode:"aem"}),pn("ERROR"),ot("worker_sync_failed",{source:n,sentOpIds:d,statusCode:v,message:(null===(G=p)||void 0===G?void 0:G.error)||(null===t.t1||void 0===t.t1?void 0:t.t1.message)||"unknown"}),Pe(s,"failed",{selector:Number((null==i?void 0:i.version)||0)>0||Boolean(null==i?void 0:i.cartId)?W:z,method:"POST",statusCode:v,message:(null===(H=p)||void 0===H?void 0:H.error)||(null===t.t1||void 0===t.t1?void 0:t.t1.message)||"unknown"});case 113:return t.prev=113,Mn.current=!1,Kn.current&&(Kn.current=!1,qn.current?qn.current.postMessage({type:"TRIGGER_SYNC"}):pr("post_inflight_requeue")),t.finish(113);case 117:case"end":return t.stop()}}),t,null,[[27,100,113,117],[41,47]])}))),[]),mr=(0,a.useCallback)(D(x().mark((function t(){var n,r,o,a,i,l,u,c,s,d,v,p,m,f,g,y,h,b,k,S,w,I,_,C,N,E,O,D,A,L,P,T,q,R,M,K,U,F,G,H,V,Q,Y,z,W,ee,te,ne,re,oe,ae,ie,le=arguments;return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r="cart_open"===(n=le.length>0&&void 0!==le[0]?le[0]:"manual")||"cart_open_after_sso"===n,!ke()){t.next=8;break}return localStorage.removeItem("cart-data"),o={status:"SYNCED",items:[],badge:{itemCount:0},pendingOps:[],updatedAt:(new Date).toISOString(),cartId:null,version:0},rr(o),Se("meta_poll_skipped_order_completed_reset",{source:n}),t.abrupt("return",{fullCartLoaded:!1,versionMismatch:!1});case 8:if(we()){t.next=11;break}return Se("meta_poll_skipped_not_logged_in",{source:n,selector:J}),t.abrupt("return");case 11:if(a=Number(sessionStorage.getItem(X)||0),!(Date.now()<a)||r){t.next=15;break}return Se("meta_poll_skipped_backoff",{source:n,selector:J,suppressUntil:a}),t.abrupt("return");case 15:if(Date.now()<a&&r&&Se("meta_poll_backoff_ignored_for_cart_open",{source:n,selector:J,suppressUntil:a}),!de()||"true"!==sessionStorage.getItem("cartMetaMockUnavailable")||r){t.next=19;break}return"true"!==sessionStorage.getItem($)&&(sessionStorage.setItem($,"true"),Se("meta_poll_skipped_mock_404_cached",{source:n,selector:J})),t.abrupt("return");case 19:return t.prev=19,t.next=22,fetch(Te(J,void 0,e),{method:"GET"});case 22:if(p=t.sent,Se("meta_polled",{source:n,selector:J,method:"GET",statusCode:p.status}),!de()||404!==p.status){t.next=30;break}return sessionStorage.setItem("cartMetaMockUnavailable","true"),sessionStorage.removeItem($),Se("meta_mock_not_found_disable_poll",{selector:J,statusCode:p.status}),Ie("mock_not_found",p.status),t.abrupt("return");case 30:if(p.ok){t.next=36;break}if(401!==p.status){t.next=34;break}
1return Ur(),t.abrupt("return");case 34:return Ie("non_ok_response",p.status),t.abrupt("return");case 36:return sessionStorage.removeItem(X),sessionStorage.removeItem(Z),sessionStorage.removeItem("cartMetaMockUnavailable"),sessionStorage.removeItem($),t.next=39,p.json();case 39:if(m=t.sent,f=Number((null==m?void 0:m.itemCount)||(null==m||null===(i=m.items)||void 0===i?void 0:i.length)||0),g=null!==(l=null==m?void 0:m.cartExist)&&void 0!==l?l:null==m?void 0:m.cartExists,m&&!1!==g){t.next=76;break}if(y=B(),h=it(),!(Array.isArray(y)&&y.length>0)){t.next=58;break}return(b=qe(y,isInfineonLoggedIn())).pendingOps=Array.isArray(null==h?void 0:h.pendingOps)?h.pendingOps:[],b.cartId=null,b.version=0,b.status=De(isInfineonLoggedIn(),b),b.updatedAt=(new Date).toISOString(),rr(b),ir(y),t.next=56,cr(!1);case 56:return Se("meta_cart_missing_preserve_local",{source:n,localCartCount:y.length,pendingOpsCount:Ne(b),cartExists:g}),t.abrupt("return");case 58:if(!xe(h)){t.next=63;break}return t.next=61,cr(!1);case 61:return Se("meta_skip_local_clear_due_to_draft",{source:n,draftItemCount:Array.isArray(null==h?void 0:h.items)?h.items.length:0,pendingOpsCount:Ne(h),cartExists:g}),t.abrupt("return");case 63:return(k=h).cartId=null,k.version=Number((null==m?void 0:m.version)||(null==k?void 0:k.version)||0),k.items=[],k.pendingOps=Array.isArray(null==k?void 0:k.pendingOps)?k.pendingOps:[],k.status=De(isInfineonLoggedIn(),k),k.updatedAt=(new Date).toISOString(),rr(k),localStorage.removeItem("cart-data"),ir(0),nr("CART_SYNCED",{cartExists:!1,version:k.version}),Se("meta_sync_empty",{source:n,cartExists:!1,version:k.version}),t.abrupt("return");case 76:if(ot("worker_events_polled",{cartId:null==m?void 0:m.cartId,version:null==m?void 0:m.version,itemCount:f}),S=it(),w=Number((null==S?void 0:S.version)||0),I=Number((null==m?void 0:m.version)||w||0),_=Array.isArray(null==m?void 0:m.items),C=I>0&&I!==w,N=Ne(S),E=B().length,O=Number(f||(null==S||null===(u=S.badge)||void 0===u?void 0:u.itemCount)||0),D=!_&&0===N&&O>0&&0===E,A=!_&&0===N&&O>0&&E>0&&E!==O,L=r&&!_&&0===N&&O>0,S.cartId=(null==m?void 0:m.cartId)||(null==S?void 0:S.cartId)||null,S.version=I,S.badge=j(j({},(null==S?void 0:S.badge)||{}),{},{itemCount:Number(f||(null==S||null===(c=S.badge)||void 0===c?void 0:c.itemCount)||(null==S||null===(s=S.items)||void 0===s?void 0:s.length)||0)}),S.status=De(we(),S),S.updatedAt=(new Date).toISOString(),ir(S.badge.itemCount),!L){t.next=112;break}return Se("meta_force_rehydrate_on_cart_open",{source:n,browserVersion:w,serverVersion:I,badgeItemCount:O,localCartCount:E}),ot("meta_force_rehydrate_on_cart_open",{source:n,browserVersion:w,serverVersion:I,badgeItemCount:O,localCartCount:E}),t.prev=97,t.next=100,Qr(n);case 100:M=t.sent,t.next=109;break;case 103:return t.prev=103,t.t0=t.catch(97),console.warn("[CartSync] Worker full cart fetch failed for forced cart-open rehydrate, falling back to main thread",t.t0),t.next=108,Vr();case 108:M=t.sent;case 109:return t.next=111,Jr(j(j({},M),{},{version:Number((null===(P=M)||void 0===P?void 0:P.version)||I||0),cartId:(null===(T=M)||void 0===T?void 0:T.cartId)||(null==m?void 0:m.cartId)||(null==S?void 0:S.cartId)||null,itemCount:Number((null===(q=M)||void 0===q?void 0:q.itemCount)||(null===(R=M)||void 0===R||null===(R=R.items)||void 0===R?void 0:R.length)||O||0)}),"meta_force_cart_open",{deferProductEnrichment:!1});case 111:return t.abrupt("return",{fullCartLoaded:!0,versionMismatch:!1,forcedByCartOpen:!0});case 112:if(_||!C||0!==N){t.next=131;break}return Se("meta_version_mismatch_detected",{source:n,browserVersion:w,serverVersion:I,cartId:(null==m?void 0:m.cartId)||(null==S?void 0:S.cartId)||null}),ot("meta_version_mismatch_detected",{source:n,browserVersion:w,serverVersion:I}),Se("meta_version_mismatch_requires_refresh",{source:n,browserVersion:w,serverVersion:I,cartId:(null==m?void 0:m.cartId)||(null==S?void 0:S.cartId)||null}),t.prev=116,t.next=119,Qr(n);case 119:H=t.sent,t.next=128;break;case 122:return t.prev=122,t.t1=t.catch(116),console.warn("[CartSync] Worker full cart fetch failed, falling back to main thread",t.t1),t.next=127,Vr();case 127:H=t.sent;case 128:return t.next=130,Jr(j(j({},H),{},{version:Number((null===(K=H)||void 0===K?void 0:K.version)||I||0),cartId:(null===(U=H)||void 0===U?void 0:U.cartId)||(null==m?void 0:m.cartId)||(null==S?void 0:S.cartId)||null,itemCount:Number((null===(F=H)||void 0===F?void 0:F.itemCount)||(null===(G=H)||void 0===G||null===(G=G.items)||void 0===G?void 0:G.length)||(null==m?void 0:m.itemCount)||0)}),"meta_version_mismatch",{deferProductEnrichment:!1});case 130:return t.abrupt("return",{fullCartLoaded:!0,versionMismatch:!0});case 131:if(!_&&C&&N>0&&Se("meta_version_mismatch_deferred_pending_ops",{source:n,browserVersion:w,serverVersion:I,pendingCount:N}),!D){t.next=150;break}return Se("meta_rehydrate_missing_local_cart",{source:n,browserVersion:w,serverVersion:I,badgeItemCount:O,localCartCount:E}),ot("meta_rehydrate_missing_local_cart",{source:n,browserVersion:w,serverVersion:I,badgeItemCount:O,localCartCount:E}),t.prev=135,t.next=138,Qr(n);
1case 138:W=t.sent,t.next=147;break;case 141:return t.prev=141,t.t2=t.catch(135),console.warn("[CartSync] Worker full cart fetch failed for missing local cart rehydrate, falling back to main thread",t.t2),t.next=146,Vr();case 146:W=t.sent;case 147:return t.next=149,Jr(j(j({},W),{},{version:Number((null===(V=W)||void 0===V?void 0:V.version)||I||0),cartId:(null===(Q=W)||void 0===Q?void 0:Q.cartId)||(null==m?void 0:m.cartId)||(null==S?void 0:S.cartId)||null,itemCount:Number((null===(Y=W)||void 0===Y?void 0:Y.itemCount)||(null===(z=W)||void 0===z||null===(z=z.items)||void 0===z?void 0:z.length)||O||0)}),"meta_missing_local_cart",{deferProductEnrichment:!1});case 149:return t.abrupt("return",{fullCartLoaded:!0,versionMismatch:C,recoveredMissingLocalCart:!0});case 150:if(!A){t.next=168;break}return Se("meta_rehydrate_stale_local_cart",{source:n,browserVersion:w,serverVersion:I,badgeItemCount:O,localCartCount:E}),ot("meta_rehydrate_stale_local_cart",{source:n,browserVersion:w,serverVersion:I,badgeItemCount:O,localCartCount:E}),t.prev=153,t.next=156,Qr(n);case 156:oe=t.sent,t.next=165;break;case 159:return t.prev=159,t.t3=t.catch(153),console.warn("[CartSync] Worker full cart fetch failed for stale local cart rehydrate, falling back to main thread",t.t3),t.next=164,Vr();case 164:oe=t.sent;case 165:return t.next=167,Jr(j(j({},oe),{},{version:Number((null===(ee=oe)||void 0===ee?void 0:ee.version)||I||0),cartId:(null===(te=oe)||void 0===te?void 0:te.cartId)||(null==m?void 0:m.cartId)||(null==S?void 0:S.cartId)||null,itemCount:Number((null===(ne=oe)||void 0===ne?void 0:ne.itemCount)||(null===(re=oe)||void 0===re||null===(re=re.items)||void 0===re?void 0:re.length)||O||0)}),"meta_stale_local_cart",{deferProductEnrichment:!1});case 167:return t.abrupt("return",{fullCartLoaded:!0,versionMismatch:C,recoveredStaleLocalCart:!0});case 168:return ae=(null==m?void 0:m.items)||[],_&&((ae=Oe(null==m?void 0:m.items,S)).length!==((null==m?void 0:m.items)||[]).length&&Se("meta_sync_pending_ops_overlay_applied",{serverItemCount:Number(((null==m?void 0:m.items)||[]).length),effectiveItemCount:Number(ae.length),pendingCount:Ne(S)}),S.items=We(ae),ir(Number(f||ae.length||(null==S||null===(ie=S.badge)||void 0===ie?void 0:ie.itemCount)||0))),rr(S),_&&tt(ae),nr("CART_SYNCED",{cartId:S.cartId,version:S.version,itemCount:Number(f||(null==S||null===(d=S.badge)||void 0===d?void 0:d.itemCount)||0)}),Se("meta_sync_applied",{source:n,cartId:S.cartId,version:S.version,itemCount:Number(f||(null==S||null===(v=S.badge)||void 0===v?void 0:v.itemCount)||0),hasItemsSnapshot:_}),t.abrupt("return",{fullCartLoaded:!1,versionMismatch:C});case 177:return t.prev=177,t.t4=t.catch(19),console.warn("[CartSync] Failed to poll cart events",t.t4),Ie("network_error"),t.abrupt("return",{fullCartLoaded:!1,versionMismatch:!1});case 182:case"end":return t.stop()}}),t,null,[[19,177],[97,103],[116,122],[135,141],[153,159]])}))),[]),fr=(0,a.useCallback)((function(){if(qn.current)return qn.current.postMessage({type:"TRIGGER_SYNC"}),pr("user_action"),void Se("worker_sync_triggered",{mode:"worker_plus_direct_flush"});pr("fallback"),Se("worker_sync_triggered",{mode:"fallback"})}),[pr]),gr=function(){var e=D(x().mark((function e(){var t,n,r=arguments;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=r.length>0&&void 0!==r[0]?r[0]:"cart_op",we()){e.next=4;break}return Se("hosted_cart_sync_skipped_not_infineon_logged_in",{source:t}),e.abrupt("return",!1);case 4:return e.prev=4,e.next=7,Dr();case 7:return n=e.sent,Se("hosted_cart_sync_result",{source:t,synced:n,localCartCount:B().length}),e.abrupt("return",Boolean(n));case 12:return e.prev=12,e.t0=e.catch(4),console.warn("[Cart] Silent hosted cart sync failed:",e.t0),Se("hosted_cart_sync_error",{source:t,message:(null===e.t0||void 0===e.t0?void 0:e.t0.message)||"unknown"}),e.abrupt("return",!1);case 17:case"end":return e.stop()}}),e,null,[[4,12]])})));return function(){return e.apply(this,arguments)}}(),yr=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"cart_op";we()&&(Un.current&&window.clearTimeout(Un.current),Un.current=window.setTimeout(D(x().mark((function t(){return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Un.current=null,!Fn.current){t.next=4;break}return Bn.current=!0,t.abrupt("return");case 4:return Fn.current=!0,t.prev=5,t.next=8,gr(e);case 8:return t.prev=8,Fn.current=!1,Bn.current&&(Bn.current=!1,yr("requeue")),t.finish(8);case 12:case"end":return t.stop()}}),t,null,[[5,,8,12]])}))),350))},hr=(0,a.useCallback)((function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.triggerSync,o=void 0===r||r,a=n.triggerHostedSync,i=void 0===a||a,l=n.skipPriorityFlag,u=void 0!==l&&l,c=n.skipTombstone,s=void 0!==c&&c,d=or(),v=Array.isArray(null==d?void 0:d.pendingOps)?d.pendingOps:[],p=j(j({},t),{},{lineType:Re(null==t?void 0:t.lineType),qty:Number((null==t?void 0:t.qty)||0)}),m=Me(e);
1s||("DELETE"===m||Number((null==p?void 0:p.qty)||0)<=0?function(e,t){var n=Fe(e,t);if(n){var r=Ge(),o=Ve(r).next;o[n]=Date.now(),He(o)}}(null==p?void 0:p.skuId,null==p?void 0:p.lineType):"INSERT"!==m&&"UPDATE"!==m||Qe(null==p?void 0:p.skuId,null==p?void 0:p.lineType));var f,g=Ke(p),y=v.findIndex((function(e){return"PENDING"===(null==e?void 0:e.status)&&Ke(null==e?void 0:e.payload)===g}));if(y>=0){var h,b,k,S=function(e,t,n){var r,o,a=Me(null==e?void 0:e.op),i=Me(t);if("DELETE"===a&&("INSERT"===i||"UPDATE"===i))return j(j({},e),{},{op:"DELETE",payload:j(j({},null==e?void 0:e.payload),{},{lineType:Re(null==e||null===(o=e.payload)||void 0===o?void 0:o.lineType),qty:0}),status:"PENDING",retryCount:0,queuedAt:(new Date).toISOString()});var l=i;"INSERT"===a&&"UPDATE"===i&&(l="INSERT");var u=Number(null==n?void 0:n.qty),c=Number((null==e||null===(r=e.payload)||void 0===r?void 0:r.qty)||1),s="DELETE"===l?0:Math.max(1,Number.isFinite(u)&&u>0?u:c);return j(j({},e),{},{op:l,payload:j(j(j({},null==e?void 0:e.payload),n),{},{lineType:Re(null==n?void 0:n.lineType),qty:s}),status:"PENDING",retryCount:0,queuedAt:(new Date).toISOString()})}(v[y],e,p);f=S.opId,v[y]=S,Se("op_coalesced",{opId:f,operation:S.op,skuId:null==S||null===(h=S.payload)||void 0===h?void 0:h.skuId,qty:Number((null==S||null===(b=S.payload)||void 0===b?void 0:b.qty)||0),lineType:null==S||null===(k=S.payload)||void 0===k?void 0:k.lineType})}else f="op-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,9)),v.push({opId:f,op:e,payload:p,status:"PENDING",retryCount:0,queuedAt:(new Date).toISOString(),isDeltaSyncOp:!0===u});d.pendingOps=v,d.updatedAt=(new Date).toISOString(),rr(d),u?console.log("%c[Cart:Priority:FLAG] â© queuePendingCartOperation (skipPriorityFlag) â ".concat(e," ").concat(null==p?void 0:p.skuId,"(").concat(null==p?void 0:p.lineType,") qty=").concat(null==p?void 0:p.qty),"color:#999","â DK delta sync op, priority flag NOT changed"):(ye(null==p?void 0:p.skuId,null==p?void 0:p.lineType),console.log("%c[Cart:Priority:FLAG] ð queuePendingCartOperation â ".concat(e," ").concat(null==p?void 0:p.skuId,"(").concat(null==p?void 0:p.lineType,") qty=").concat(null==p?void 0:p.qty),"color:#856404","â marking IFX priority flag"),fe()),ot("pending_op_queued",{opId:f,operation:e,skuId:null==p?void 0:p.skuId,lineType:null==p?void 0:p.lineType,pendingCount:v.length}),Se("op_queued",{opId:f,operation:e,skuId:null==p?void 0:p.skuId,qty:Number((null==p?void 0:p.qty)||0),lineType:null==p?void 0:p.lineType,pendingCount:v.length}),Se("dk_priority_consumed_by_local_change",{opId:f,operation:e,skuId:null==p?void 0:p.skuId,lineType:null==p?void 0:p.lineType}),o&&fr(),i&&!ve()&&yr("pending_op_queued")}),[yr,fr]),br=(0,a.useCallback)((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"cart_open_async";window.setTimeout((function(){pr(e).catch((function(e){console.warn("[Cart] flushPendingCartOpsSilently: failed",e)}))}),0)}),[pr]),kr=(0,a.useCallback)(D(x().mark((function e(){var t,n,r,o,a,i,l,u,c,s,d,v,p=arguments;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=p.length>0&&void 0!==p[0]?p[0]:"cart_open",ve()){e.next=3;break}return e.abrupt("return",!1);case 3:if(we()){e.next=5;break}return e.abrupt("return",!1);case 5:if(n=it(),0!==(r=Ne(n))){e.next=9;break}return e.abrupt("return",!1);case 9:if(uo()){e.next=12;break}return Se("cart_level_dk_sync_skipped_no_dk_session",{source:t,pendingCount:r}),e.abrupt("return",!1);case 12:return e.prev=12,e.next=15,_r();case 15:if("function"!=typeof(null===(o=b)||void 0===o?void 0:o.setPartnerOriginDomain)){e.next=18;break}return e.next=18,b.setPartnerOriginDomain();case 18:if("function"!=typeof(null===(a=b)||void 0===a?void 0:a.setLanguageId)){e.next=21;break}return e.next=21,b.setLanguageId(Pt);case 21:if("function"==typeof(null===(i=b)||void 0===i?void 0:i.clearCart)&&"function"==typeof(null===(l=b)||void 0===l?void 0:l.addItemsToCart)){e.next=24;break}return Se("cart_level_dk_sync_skipped_missing_sdk_methods",{source:t,hasClearCart:"function"==typeof(null===(u=b)||void 0===u?void 0:u.clearCart),hasAddItemsToCart:"function"==typeof(null===(c=b)||void 0===c?void 0:c.addItemsToCart)}),e.abrupt("return",!1);case 24:return s=mo(),e.next=27,b.clearCart();case 27:if(null!=(d=e.sent)&&d.successful||!0===d||Se("cart_level_dk_sync_clear_non_success",{source:t,pendingCount:r}),!(s.length>0)){e.next=36;break}return e.next=32,b.addItemsToCart(s);case 32:if(null!=(v=e.sent)&&v.successful||!0===v){e.next=36;break}return Se("cart_level_dk_sync_add_non_success",{source:t,pendingCount:r,itemCount:s.length}),e.abrupt("return",!1);case 36:return Se("cart_level_dk_sync_applied",{source:t,pendingCount:r,itemCount:s.length}
1),console.log("%c[Cart:Priority:FLAG] ð IFXâDK cart-level sync complete â clearing flag (DK is now authority)","color:#cc0000;font-weight:bold","| items pushed to DK: ".concat(s.length)),be(),e.abrupt("return",!0);case 42:return e.prev=42,e.t0=e.catch(12),console.warn("[Cart] cart-level DigiKey sync failed:",e.t0),Se("cart_level_dk_sync_failed",{source:t,pendingCount:r,message:(null===e.t0||void 0===e.t0?void 0:e.t0.message)||"unknown"}),e.abrupt("return",!1);case 47:case"end":return e.stop()}}),e,null,[[12,42]])}))),[mo,Pt]);(0,a.useEffect)((function(){var t,n=String(null!==(t=null==e?void 0:e.index)&&void 0!==t?t:"unknown"),r=function(){return window[ee]||(window[ee]=n),window[ee]===n};r(),window.__ifxCartSyncReady=!0;var o=function(e){var t,n;if(r()){var o=String((null==e||null===(t=e.detail)||void 0===t?void 0:t.operation)||"").toUpperCase(),a=(null==e||null===(n=e.detail)||void 0===n?void 0:n.payload)||{};["INSERT","UPDATE","DELETE"].includes(o)&&null!=a&&a.skuId&&(tr("external_cart_op_received",{operation:o,skuId:null==a?void 0:a.skuId,lineType:null==a?void 0:a.lineType,qty:Number((null==a?void 0:a.qty)||0)}),hr(o,a))}},a=function(e){var t,n;if(r()){var o=Array.isArray(null==e||null===(t=e.detail)||void 0===t?void 0:t.ops)?e.detail.ops:[],a=["INSERT","UPDATE","DELETE"],i=o.filter((function(e){var t=String((null==e?void 0:e.operation)||"").toUpperCase(),n=(null==e?void 0:e.payload)||{};return a.includes(t)&&Boolean(null==n?void 0:n.skuId)}));0!==i.length&&(tr("external_cart_op_batch_received",{source:(null==e||null===(n=e.detail)||void 0===n?void 0:n.source)||"external",opCount:i.length,skuIds:i.map((function(e){var t;return null==e||null===(t=e.payload)||void 0===t?void 0:t.skuId})).filter(Boolean)}
1),i.forEach((function(e){hr(String(e.operation||"").toUpperCase(),e.payload,{triggerSync:!1,triggerHostedSync:!1})})),fr(),yr("pending_op_batch_queued"))}};return window.addEventListener("ifx:cart-op-queued",o),window.addEventListener("ifx:cart-op-batch-queued",a),function(){window.removeEventListener("ifx:cart-op-queued",o),window.removeEventListener("ifx:cart-op-batch-queued",a),window[ee]===n&&delete window[ee],window.__ifxCartSyncReady=Boolean(window[ee])}}),[null==e?void 0:e.index,hr,yr,tr,fr]);var Sr=null===(p=window)||void 0===p||null===(p=p.digikeyDetails)||void 0===p||null===(p=p.data)||void 0===p?void 0:p.cartDomain,wr=null===(m=window)||void 0===m||null===(m=m.digikeyDetails)||void 0===m||null===(m=m.data)||void 0===m?void 0:m.digiKeyCheckoutProcessingPage,Ir=function(){var e=D(x().mark((function e(){var t,n,r,o,a,i=arguments;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.length>0&&void 0!==i[0]&&i[0],e.prev=1,console.log("[DK-SSO] dkSignOn called | userInitiated:",t,"| cartDomain:",Sr,"| code in URL:",new URLSearchParams(window.location.search).has("code")),e.next=5,_r();case 5:if(console.log("[DK-SSO] dkInitialize done | checkInitialized:",null===(n=b)||void 0===n?void 0:n.checkInitialized()),null===(r=b)||void 0===r||!r.checkInitialized()){e.next=15;break}return e.next=9,b.signOn(Sr,bt,t);case 9:return o=e.sent,a=document.cookie.includes("MkHcLoggedInToken"),console.log("[DK-SSO] signOn result:",o,"| MkHcLoggedInToken set:",a),e.abrupt("return",Boolean(o)||a);case 15:console.warn("[DK-SSO] DigiKeyCart not initialized â signOn skipped");case 16:e.next=22;break;case 18:return e.prev=18,e.t0=e.catch(1),console.error("[DK-SSO] Failed to signOn to DigiKey",e.t0),e.abrupt("return",!1);case 22:case"end":return e.stop()}}),e,null,[[1,18]])})));return function(){return e.apply(this,arguments)}}(),_r=function(){var e=D(x().mark((function e(){var t,n,r,o,a;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,console.log("[DK-SSO] dkInitialize | window.DigiKeyCart before:",!!window.DigiKeyCart),e.next=4,(0,N.f)();case 4:if(b=window.DigiKeyCart,k=(null===(t=window.DigiKeyCart)||void 0===t?void 0:t.DkHostedCartItem)||window.DkHostedCartItem,console.log("[DK-SSO] scripts loaded | window.DigiKeyCart:",!!window.DigiKeyCart,"| DigiKeyCart:",!!b),null!==(n=b)&&void 0!==n&&n.checkInitialized()){e.next=14;break}return a=(0,u.NZ)(),e.next=11,null===(r=b)||void 0===r?void 0:r.initialize(Sr,bt,Pt,a);case 11:console.log("[DK-SSO] initialize done | checkInitialized:",null===(o=b)||void 0===o?void 0:o.checkInitialized()),e.next=15;break;case 14:console.log("[DK-SSO] already initialized");case 15:e.next=20;break;case 17:e.prev=17,e.t0=e.catch(0),console.error("[DK-SSO] Failed to initialize DigiKeyCart:",e.t0);case 20:case"end":return e.stop()}}),e,null,[[0,17]])})));return function(){return e.apply(this,arguments)}}(),Cr=(0,a.useCallback)(D(x().mark((function e(){var t,n,r,o,a,i,l;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=new URLSearchParams(window.location.search),["code","scope","state","session_state","iss","error","error_description","error_uri"].some((function(e){return t.has(e)}))){e.next=4;break}return e.abrupt("return");case 4:return n="true"===sessionStorage.getItem("cart:inSSOFlow"),r="true"===sessionStorage.getItem("openViewCartAfterSSO"),console.log("[DK-SSO] OAuth callback detected:",{inSSOFlow:n,openViewCartAfterSSO:r,hasCode:t.has("code"),hasError:t.has("error")}),e.prev=7,e.next=10,(0,N.f)();case 10:if(b=window.DigiKeyCart,"function"!=typeof(null===(o=b)||void 0===o?void 0:o.handleOAuthCallbackOnly)){e.next=17;break}return console.log("[DK-SSO] Processing OAuth callback with handleOAuthCallbackOnly"),e.next=15,b.handleOAuthCallbackOnly(Sr,bt);case 15:e.next=20;break;case 17:return console.log("[DK-SSO] Processing OAuth callback with signOn"),e.next=20,null===(a=b)||void 0===a||null===(i=a.signOn)||void 0===i?void 0:i.call(a,Sr,bt,!1);case 20:if(!n||!r){e.next=27;break}return console.log("[DK-SSO] SSO complete, opening cart directly (token now set)"),sessionStorage.removeItem("cart:inSSOFlow"),sessionStorage.removeItem("openViewCartAfterSSO"),sessionStorage.removeItem("cart:pendingOpen"),setTimeout((function(){null!=On&&On.current&&On.current(null,!1)}),0),e.abrupt("return");case 27:if(!("true"===sessionStorage.getItem(ne))){e.next=40;break}return l=function(){var e=D(x().mark((function e(){var t,n,r,o,a,i=arguments;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i.length>0&&void 0!==i[0]?i[0]:6e3,n=i.length>1&&void 0!==i[1]?i[1]:150,r=Date.now();case 3:if(!(Date.now()-r<=t)){e.next=11;break}if(!(Boolean((0,u.Ri)("MkHcLoggedInToken"))||Boolean(sessionStorage.getItem("MkHcLoggedInToken")||sessionStorage.getItem("digiKeyToken"))||Boolean(null===(o=window)||void 0===o||null===(o=o.DigiKeyCart)||void 0===o||null===(a=o.isUserLoggedIn)||void 0===a?void 0:a.call(o)))){e.next=7;break}return e.abrupt("return",!0);case 7:return e.next=9,new Promise((function(e){window.setTimeout(e,n)}));case 9:e.next=3;break;case 11:return e.abrupt("return",!1);case 12:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),e.next=32,l();case 32:if(!e.sent){e.next=40;break}if(sessionStorage.removeItem(ne),null==Dn||!Dn.current){e.next=38;break}return window.setTimeout((function(){Dn.current(null,{isResumeAfterDkLogin:!0})}),0),e.abrupt("return");case 38:return wr&&(sessionStorage.setItem("checkoutPending","true"),window.location.href=(0,u.IT)(wr)),e.abrupt("return");case 40:e.next=47;break;case 42:e.prev=42,e.t0=e.catch(7),console.error("[DK-SSO] OAuth callback handling failed",e.t0),sessionStorage.removeItem("cart:inSSOFlow"),sessionStorage.removeItem("openViewCartAfterSSO");case 47:case"end":return e.stop()}}),e,null,[[7,42]])}))),[Sr,bt,wr]),Nr=function(){var t=D(x().mark((function t(n){var r,o,a,i,l,u,c,s,d,v;return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n&&n.trim()){t.next=2;break}return t.abrupt("return",{data:{getCartProductDetails:[]}});case 2:if(0!==(r=Array.from(new Set(String(n).split(",").map((function(e){return e.trim()}
1)).filter(Boolean)))).length){t.next=5;break}return t.abrupt("return",{data:{getCartProductDetails:[]}});case 5:if(o=Date.now(),a=r.filter((function(e){var t=Y[String(e).toLowerCase()];return!t||o-t.ts>=6e4})),i=function(){return{data:{getCartProductDetails:r.map((function(e){var t;return null===(t=Y[String(e).toLowerCase()])||void 0===t?void 0:t.item})).filter(Boolean)}}},0!==a.length){t.next=10;break}return t.abrupt("return",i());case 10:return l=(null==e?void 0:e.getproductsviaopns)+"?opns="+a.join(","),u={method:"GET",headers:{"Content-Type":"application/json"}},t.prev=14,t.next=17,fetch(l,u);case 17:if((s=t.sent).ok){t.next=20;break}throw new Error("HTTP error! status: ".concat(s.status));case 20:return t.next=22,s.text();case 22:if((d=t.sent)&&d.trim()){t.next=26;break}return console.warn("[Cart] fetchProdDetailViaOpns: empty response body, returning fallback"),t.abrupt("return",i());case 26:return v=JSON.parse(d),(Array.isArray(null==v||null===(c=v.data)||void 0===c?void 0:c.getCartProductDetails)?v.data.getCartProductDetails:[]).forEach((function(e){var t=String((null==e?void 0:e.opnName)||(null==e?void 0:e.manufacturerPartNumber)||"").trim().toLowerCase();t&&(Y[t]={ts:Date.now(),item:e})})),t.abrupt("return",i());case 32:return t.prev=32,t.t0=t.catch(14),console.error("Failed to fetch productsviaopns:",t.t0),t.abrupt("return",i());case 36:case"end":return t.stop()}}),t,null,[[14,32]])})));return function(e){return t.apply(this,arguments)}}();function Er(e){return Array.isArray(e)?e.map((function(e){var t;return null!==(t=null==e?void 0:e.opnName)&&void 0!==t?t:null})):[]}function xr(e){return Or.apply(this,arguments)}function Or(){return(Or=D(x().mark((function e(t){var n,r;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,_r();case 3:return e.next=5,null===(n=b)||void 0===n?void 0:n.getProductInformation(t);case 5:return r=e.sent,e.abrupt("return",(null==r?void 0:r.data)||[]);case 9:return e.prev=9,e.t0=e.catch(0),console.error("Error fetching product info:",e.t0),e.abrupt("return",[]);case 13:case"end":return e.stop()}}),e,null,[[0,9]])})))).apply(this,arguments)}function Dr(){return Ar.apply(this,arguments)}function Ar(){return(Ar=D(x().mark((function e(){var t,n,r,o,a,i,l;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,_r();case 3:if(b){e.next=6;break}return console.warn("[Cart] syncItemsToDkCart: DigiKey Cart is unavailable"),e.abrupt("return",!1);case 6:if(o=k||(null===(t=window.DigiKeyCart)||void 0===t?void 0:t.DkHostedCartItem),a=function(e){return(e||[]).map((function(e){var t=!0===e.IsSample||"true"===e.IsSample||!0===e.isSample||"true"===e.isSample,n=Math.max(1,parseInt(e.quantity,10)||1);if(o){var r=new o;return r.manufacturerPartNumber=e.opnName,r.quantity=n,r.isSample=Boolean(t),r}return{manufacturerPartNumber:e.opnName,quantity:n,isSample:Boolean(t)}}))},i=B(),l=a(i),"function"!=typeof(null===(n=b)||void 0===n?void 0:n.setPartnerOriginDomain)){e.next=15;break}return e.next=15,b.setPartnerOriginDomain();case 15:if("function"!=typeof(null===(r=b)||void 0===r?void 0:r.setLanguageId)){e.next=18;break}return e.next=18,b.setLanguageId(Pt);case 18:if(l.length){e.next=20;break}return e.abrupt("return",!0);case 20:return console.log("[Cart] syncItemsToDkCart: DigiKey API calls disabled, local cart maintained"),e.abrupt("return",!0);case 24:return e.prev=24,e.t0=e.catch(0),console.warn("[Cart] syncItemsToDkCart failed:",e.t0),e.abrupt("return",!1);case 28:case"end":return e.stop()}}),e,null,[[0,24]])})))).apply(this,arguments)}function Lr(){return Pr.apply(this,arguments)}function Pr(){return(Pr=D(x().mark((function e(){var t,n,r,o,a,i,l;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,null!==(t=b)&&void 0!==t&&null!==(n=t.checkInitialized)&&void 0!==n&&n.call(t)&&"function"==typeof(null===(r=b)||void 0===r?void 0:r.getCart)){e.next=4;break}return console.log("[Cart] getCartFromAPI: DigiKey not initialized/getCart unavailable, returning undefined"),e.abrupt("return",void 0);case 4:return e.next=6,b.getCart();case 6:if(a=e.sent,!vo(a)){e.next=9;break}return e.abrupt("return",null);case 9:if(null!=a&&a.successful){e.next=16;break}
1if(null!==(null==a?void 0:a.data)){e.next=12;break}return e.abrupt("return",null);case 12:if(!so(a)){e.next=14;break}throw new Error("DigiKey cart auth failure");case 14:return console.warn("[Cart] getCartFromAPI: non-successful DigiKey response, preserving local cart",a),e.abrupt("return",void 0);case 16:return i=Array.isArray(null==a||null===(o=a.data)||void 0===o?void 0:o.orderLines)?a.data.orderLines:[],l=i.map((function(e){var t=String((null==e?void 0:e.manufacturerPartNumber)||"").trim(),n=Number((null==e?void 0:e.quantity)||0);if(!t||n<=0)return null;var r=Boolean(null==e?void 0:e.isSample);return{opnName:t,quantity:n,IsSample:r,lineType:r?"SAMPLE":"PAID",fromRemote:!0}})).filter(Boolean),e.abrupt("return",l);case 21:if(e.prev=21,e.t0=e.catch(0),!so(e.t0)){e.next=25;break}throw e.t0;case 25:if(!vo(e.t0)){e.next=28;break}return console.log("[Cart] getCartFromAPI: DigiKey carts returned 400/no-open-cart"),e.abrupt("return",null);case 28:return console.warn("[Cart] getCartFromAPI: failed to fetch DigiKey cart",e.t0),e.abrupt("return",void 0);case 30:case"end":return e.stop()}}),e,null,[[0,21]])})))).apply(this,arguments)}function Tr(){return qr.apply(this,arguments)}function qr(){return qr=D(x().mark((function e(){var t,n,r,o,a,i,l,u,c,s,d,v,p,m,f,g,y,h,b,k,S,w,I,_,C,N,E,O,A,L,P,T,q,R,M,K,U,F,H,V,Q;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=B(),r=pe(),o=ge(),console.log("%c[Cart:Priority] syncCart START","color:#6a0dad;font-weight:bold","\n localCart.length :",n.length,"\n localCart keys :",n.map((function(e){return"".concat(null==e?void 0:e.opnName,"(").concat(null!=e&&e.IsSample?"SAMPLE":"PAID",",qty=").concat(null==e?void 0:e.quantity,",fromRemote=").concat(null==e?void 0:e.fromRemote,")")})).join(" | ")||"(empty)","\n dkPriorityConsumed :",sessionStorage.getItem("cart:dkPriorityConsumed"),"(session) /",localStorage.getItem("cart:dkPriorityConsumed"),"(local)","\n dkHostedPriorityApplied:",sessionStorage.getItem("cart:dkHostedPriorityApplied"),"(session) /",localStorage.getItem("cart:dkHostedPriorityApplied"),"(local)","\n touchedLineKeys :",Array.from(o).join(" | ")||"(none)","\n â shouldPreferGetCartMe (IFX priority):",r),a=function(e){var t=String((null==e?void 0:e.opnName)||"").trim().toUpperCase();if(!t)return"";var n=null!=e&&e.IsSample?"SAMPLE":"PAID";return"".concat(t,"::").concat(n)},i=function(e){var t,n,r=String((null==e?void 0:e.opnName)||"").trim(),o=Number(null!==(t=null!==(n=null==e?void 0:e.quantity)&&void 0!==n?n:null==e?void 0:e.qty)&&void 0!==t?t:0),a=Boolean((null==e?void 0:e.IsSample)||"SAMPLE"===String((null==e?void 0:e.lineType)||"").toUpperCase());return j(j({},e),{},{opnName:r,quantity:o,IsSample:a,lineType:a?"SAMPLE":"PAID",fromRemote:!0})},l=function(){var e=D(x().mark((function e(t){var n,r,o;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Array.isArray(t)?t:[],r=ar(n),e.next=4,Nr(r);case 4:return o=e.sent,Rt(o),e.abrupt("return",{prodDetails:o,cartItems:n});case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),c=!1,s=null,e.prev=9,e.next=12,Lr();case 12:u=e.sent,console.log("%c[Cart:Priority] DK cart fetch result","color:#0066cc;font-weight:bold","\n remoteCart:",void 0===u?"undefined (DK SDK not initialized)":null===u?"null (no open DK cart / 400)":"array(".concat(null===(d=u)||void 0===d?void 0:d.length,") items: [").concat((u||[]).map((function(e){return"".concat(null==e?void 0:e.opnName,"(qty=").concat(null==e?void 0:e.quantity,")")})).join(", "),"]")),e.next=21;break;case 16:e.prev=16,e.t0=e.catch(9),console.warn("[Cart] syncCart: getCartFromAPI failed, preserving local cart:",e.t0),s=e.t0,c=!0;case 21:if(!c){e.next=46;break}return console.warn("[Cart] syncCart: DK API error, attempting token refresh:",s),e.prev=23,e.next=26,Ir(!1);case 26:return e.next=28,_r();case 28:return e.prev=28,e.next=31,Lr();case 31:u=e.sent,console.log("%c[Cart:Priority] DK cart fetch result (after token refresh)","color:#0066cc;font-weight:bold","\n remoteCart:",void 0===u?"undefined (DK SDK not initialized)":null===u?"null (no open DK cart / 400)":"array(".concat(null===(v=u)||void 0===v?void 0:v.length,") items: [").concat((u||[]).map((function(e){return"".concat(null==e?void 0:e.opnName,"(qty=").concat(null==e?void 0:e.quantity,")")})).join(", "),"]")),c=!1,e.next=40;break;case 36:e.prev=36,e.t1=e.catch(28),console.warn("[Cart] syncCart: getCartFromAPI still failed after token refresh:",e.t1),c=!0;case 40:e.next=46;break;case 42:e.prev=42,e.t2=e.catch(23),console.warn("[Cart] syncCart: token refresh failed:",e.t2),c=!0;case 46:if(!c){e.next=51;break}return console.warn("[Cart] syncCart: DK API error persists, rendering local cart data only"),e.next=50,l(n);case 50:return e.abrupt("return");case 51:if(void 0!==u){e.next=60;break}return p=it(),m=Array.isArray(null==p?void 0:p.items)?p.items:[],(f=0===n.length&&m.length>0?$e(Ze(m),n):n).length>0&&0===n.length&&(G(f),ir(f),Se("sync_cart_recovered_local_from_draft_remote_unavailable",{recoveredCount:f.length,draftCount:m.length})),Se("sync_cart_skip_hosted_merge_remote_unavailable",{localCount:f.length}),e.next=59,l(f);case 59:return e.abrupt("return");case 60:if(null!=u&&0!==(null===(t=u)||void 0===t?void 0:t.length)){e.next=69;break}return g=it(),y=Array.isArray(null==g?void 0:g.items)?g.items:[],(h=0===n.length&&y.length>0?$e(Ze(y),n):n).length>0&&0===n.length&&(G(h),ir(h),Se("sync_cart_recovered_local_from_draft_remote_400",{recoveredCount:h.length,draftCount:y.length})),Se("sync_cart_skip_hosted_merge_remote_empty_or_400",{localCount:h.length}),e.next=68,l(h);case 68:return e.abrupt("return");
1case 69:if(b=new Set((Array.isArray(u)?u:[]).map((function(e){return a(i(e))})).filter(Boolean)),Ye(b),k=r&&n.some((function(e){var t=a(e);return t&&!b.has(t)&&!0!==(null==e?void 0:e.fromRemote)})),S=r||k,w=it(),I=Ce(w),_=new Map,I.forEach((function(e){var t,n,r=String((null==e||null===(t=e.payload)||void 0===t?void 0:t.skuId)||"").trim().toUpperCase(),o=Re(null==e||null===(n=e.payload)||void 0===n?void 0:n.lineType),a=r?"".concat(r,"::").concat(o):"";a&&_.set(a,e)})),C=new Set(Array.from(_.keys())),S||!(Ee(w)>0)){e.next=85;break}return N=n.map((function(e){return j(j({},e),{},{fromRemote:!1})})),localStorage.setItem("cart-data",JSON.stringify(N)),Se("sync_cart_remote_merge_skipped_pending_ops",{pendingCount:Ee(w),localCount:N.length}),e.next=84,l(N);case 84:return e.abrupt("return");case 85:if(S&&Ne(w)>0&&Se("sync_cart_merge_with_digikey_despite_pending_ops",{pendingCount:Ne(w),localCount:n.length,remoteCount:Array.isArray(u)?u.length:0}),S){e.next=109;break}return E=new Map,n.forEach((function(e){var t=a(e);t&&E.set(t,e)})),console.log("%c[Cart:Priority] ð¢ DK-PRIORITY path entered","color:#007700;font-weight:bold","\n pendingOpKeys (present but belong to DK-delta, NOT user ops in this mode):",Array.from(C).join(" | ")||"(none)","\n localCart items:",n.map((function(e){return"".concat(a(e),"(fromRemote=").concat(null==e?void 0:e.fromRemote,",qty=").concat(null==e?void 0:e.quantity,")")})).join(" | ")||"(empty)","\n DK items (source of truth):",(Array.isArray(u)?u:[]).map((function(e){return"".concat(String((null==e?void 0:e.opnName)||"").trim().toUpperCase(),"::").concat(null!=e&&e.IsSample?"SAMPLE":"PAID","(qty=").concat(null==e?void 0:e.quantity,")")})).join(" | ")||"(empty)"),O=new Map,(Array.isArray(u)?u:[]).map((function(e){return i(e)})).filter((function(e){return Number((null==e?void 0:e.quantity)||0)>0})).forEach((function(e){var t=a(e),n=O.get(t);n?(n.quantity=Number(n.quantity||0)+Number(e.quantity||0),console.log("%c[Cart:Priority] DK consolidation: ".concat(t),"color:#ff8800","| ".concat(Number(n.quantity||0)-Number(e.quantity||0)," + ").concat(e.quantity," = ").concat(n.quantity))):O.set(t,e)})),A=Array.from(O.values()).map((function(e){var t,n,r=a(e);Je(null==e?void 0:e.opnName,null!=e&&e.IsSample?"SAMPLE":"PAID")&&(console.log("%c[Cart:Priority] DK item has stale tombstone, clearing it (DK is authority): ".concat(r),"color:#ff8800","| dkQty=".concat(null==e?void 0:e.quantity)),Qe(null==e?void 0:e.opnName,null!=e&&e.IsSample?"SAMPLE":"PAID"));var o=E.get(r);return console.log("%c[Cart:Priority] DK item KEPT: ".concat(r),"color:#007700","| dkQty=".concat(null==e?void 0:e.quantity," | localQty=").concat(null!==(t=null==o?void 0:o.quantity)&&void 0!==t?t:"n/a"," â using dkQty")),j(j(j({},o||{}),e),{},{quantity:Number(null!==(n=null==e?void 0:e.quantity)&&void 0!==n?n:0),fromRemote:!0})})),n.forEach((function(e){var t=a(e);t&&!b.has(t)&&console.log("%c[Cart:Priority] LOCAL item NOT in DK â REMOVED: ".concat(t),"color:#cc0000","(fromRemote=".concat(null==e?void 0:e.fromRemote,") â DK is authority, item absent from DK cart"))})),e.next=96,l(A);case 96:return L=e.sent,P=L.prodDetails,T=lr(A,P),G(T),ir(T),(q=it()).items=We(T),rr(q),he(),fe(),console.log("%c[Cart:Priority] ð¢ DK-PRIORITY complete â flag SET (next cart open = IFX priority)","color:#007700;font-weight:bold","\n final cart:",T.map((function(e){return"".concat(a(e),"(qty=").concat(null==e?void 0:e.quantity,")")})).join(" | ")||"(empty)"),Se("sync_cart_hosted_priority_applied",{mergedCount:T.length}),e.abrupt("return");
1case 109:return R=new Map,(Array.isArray(u)?u:[]).forEach((function(e){var t=i(e),n=a(t);if(n&&t.quantity>0){var r=R.get(n);r?(r.quantity=Number(r.quantity||0)+Number(t.quantity||0),console.log("%c[Cart:Priority] DK cart consolidation: ".concat(n),"color:#ff8800","| existing qty=".concat(Number(r.quantity||0)-Number(t.quantity||0)," + new qty=").concat(t.quantity," = total ").concat(r.quantity))):R.set(n,t)}})),console.log("%c[Cart:Priority] ðµ IFX-PRIORITY merge path entered","color:#0044cc;font-weight:bold","\n pendingOpKeys (IFX-touched lines):",Array.from(C).join(" | ")||"(none)","\n touchedLineKeys (persisted local touches):",Array.from(o).join(" | ")||"(none)","\n remoteItemMap (DK items):",Array.from(R.keys()).join(" | ")||"(empty)","\n localCart items:",n.map((function(e){return"".concat(a(e),"(fromRemote=").concat(null==e?void 0:e.fromRemote,",qty=").concat(null==e?void 0:e.quantity,")")})).join(" | ")||"(empty)"),M=[],K=[],n.forEach((function(e){var t=a(e);if(t){var n=C.has(t)||o.has(t),r=R.get(t);if(r){var i,l,u,c,s=n?null!==(i=null!==(l=null==e?void 0:e.quantity)&&void 0!==l?l:null==r?void 0:r.quantity)&&void 0!==i?i:0:null!==(u=null!==(c=null==r?void 0:r.quantity)&&void 0!==c?c:null==e?void 0:e.quantity)&&void 0!==u?u:0;return console.log("%c[Cart:Priority] BOTH: ".concat(t),"color:#0044cc","| ifxQty=".concat(null==e?void 0:e.quantity," | dkQty=").concat(null==r?void 0:r.quantity),"| wasLocalTouched=".concat(n," â finalQty=").concat(s," (").concat(n?"IFX wins":"DK wins",")")),M.push(j(j(j({},e),r),{},{quantity:Number(s),fromRemote:!n})),void R.delete(t)}if(!n)return console.log("%c[Cart:Priority] ABSENT FROM DK + NOT TOUCHED LOCALLY: ".concat(t," â queuing DELETE"),"color:#cc0000"),void K.push({skuId:null==e?void 0:e.opnName,qty:0,lineType:null!=e&&e.IsSample?"SAMPLE":"PAID"});console.log("%c[Cart:Priority] LOCAL ONLY (not in DK): ".concat(t," â KEPT (wasLocalTouched=").concat(n,", fromRemote=").concat(null==e?void 0:e.fromRemote,")"),"color:#0044cc"),M.push(j(j({},e),{},{fromRemote:!1}))}})),U=[],R.forEach((function(e){var t,n=a(e),r=n?_.get(n):null,o="DELETE"===(null==r?void 0:r.op)||r&&Number((null==r||null===(t=r.payload)||void 0===t?void 0:t.qty)||0)<=0,i=Je(null==e?void 0:e.opnName,null!=e&&e.IsSample?"SAMPLE":"PAID");i||o?console.log("%c[Cart:Priority] DK-ONLY item SKIPPED (deleted locally): ".concat(n),"color:#cc0000","| isLocalDeletePending=".concat(o," | isDeleteTombstoned=").concat(i)):(console.log("%c[Cart:Priority] DK-ONLY item ADDED to IFX cart: ".concat(n," qty=").concat(null==e?void 0:e.quantity),"color:#0044cc"),M.push(e),U.push(e))})),U.length>0&&(U.forEach((function(e){hr("INSERT",{skuId:null==e?void 0:e.opnName,qty:Number((null==e?void 0:e.quantity)||0),lineType:null!=e&&e.IsSample?"SAMPLE":"PAID"},{triggerSync:!1,triggerHostedSync:!1,skipPriorityFlag:!0,skipTombstone:!0})})),Se("sync_cart_remote_only_items_queued",{count:U.length})),K.length>0&&(K.forEach((function(e){hr("DELETE",{skuId:null==e?void 0:e.skuId,qty:0,lineType:null==e?void 0:e.lineType},{triggerSync:!1,triggerHostedSync:!1,skipPriorityFlag:!0,skipTombstone:!0})})),Se("sync_cart_digikey_delete_ops_queued",{count:K.length})),e.next=121,l(M);case 121:F=e.sent,H=F.prodDetails,V=lr(M,H),G(V),ir(V),(Q=it()).items=We(V),rr(Q),fe(),console.log("%c[Cart:Priority] ðµ IFX-PRIORITY merge complete â flag remains SET","color:#0044cc;font-weight:bold","\n final cart:",V.map((function(e){return"".concat(a(e),"(qty=").concat(null==e?void 0:e.quantity,")")})).join(" | ")||"(empty)","\n dkDeleteOps queued:",K.length),Se("sync_cart_dk_priority_applied_once",{mergedCount:V.length});case 132:case"end":return e.stop()}}),e,null,[[9,16],[23,42],[28,36]])}))),qr.apply(this,arguments)}function Rr(t){var n,r,o=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).showLoader,a=void 0!==o&&o,i=null==(r=An)||""===r?null==e?void 0:e.index:An,l="offcanvasWithBothOptions-".concat(i),c=document.getElementById("cart-Icon-".concat(null==e?void 0:e.index)),s=c&&null!==c.offsetParent;if(console.log("[Cart] openCartCanvas | props.index:",null==e?void 0:e.index,"| resolvedIndex:",i,"| isBtnVisible:",s,"| offcanvasEl exists:",!!document.getElementById(l)),s){var d={};try{d=JSON.parse((null==e?void 0:e.authorlabel)||"{}")}catch(e){d={}}var v={};try{v=JSON.parse((null==e?void 0:e.labels)||"{}")}catch(e){v={}}var p=null===(n=document.getElementById(l))||void 0===n||null===(n=n.classList)||void 0===n?void 0:n.contains("show");O(a),Yt(!1),Xt(!1),R(t),h(d),le(v),Cn(!a),At(!("true"===(0,u.Ri)("userMarketingOpt"))),p||setTimeout((function(){var e,t,n,r=document.getElementById(l);if(console.log("[Cart] openCartCanvas setTimeout | offcanvasElement:",!!r,"| bootstrap:",!(null===(e=window.bootstrap)||void 0===e||!e.Offcanvas)),r&&null!==(t=window.bootstrap)&&void 0!==t&&t.Offcanvas){window.bootstrap.Offcanvas.getOrCreateInstance(r,{focus:!1}).show(),document.body.style.paddingRight="",document.documentElement.style.overflow="hidden",null===(n=document.querySelector(".mainnavigation"))||void 0===n||n.classList.add("active");var o=function(){var e;document.documentElement.style.overflow="",document.body.style.paddingRight="",null===(e=document.querySelector(".mainnavigation"))||void 0===e||e.classList.remove("active"),r.removeEventListener("hidden.bs.offcanvas",o)};r.addEventListener("hidden.bs.offcanvas",o);var a=document.querySelector(".mainnavigation-component .navbar-toggler .menu_icon");document.querySelectorAll(".mainnavigation-component #navItemList li").forEach((function(e){return e.classList.remove("active")}));var i,u=localStorage.getItem("mainNavItem");if(u)null===(i=document.getElementById(u))||void 0===i||i.classList.remove("active");var c=document.querySelector(".subMenu1");if(c&&(c.style.display="none"),window.matchMedia("(max-width: 768px)").matches){var s=document.querySelector(".logo-icon");
1s&&(s.style.display="block");var d=document.querySelector(".main_menu");d&&(d.style.display="none");var v=document.querySelector(".navbar-toggler");v&&(v.style.visibility="visible");var p=document.querySelector(".chevback_icon");p&&(p.style.display="none")}if(localStorage.removeItem("mainNavItem"),window.innerWidth<768){var m=document.getElementById("navbarSupportedContent");m&&m.classList.remove("show"),a&&(a.classList.remove("icon-cross"),a.classList.add("icon-menu"));var f=document.querySelector(".navbar-toggler");f&&(f.setAttribute("aria-expanded","false"),f.style.display="block");var g=document.querySelector(".toggler-close-icon");g&&(g.style.display="none")}}else console.warn("[Cart] openCartCanvas: offcanvas element or Bootstrap not available")}),200)}else console.log("[Cart] openCartCanvas: cart button not visible for index",null==e?void 0:e.index,"skipping")}var jr=(0,a.useCallback)(D(x().mark((function t(){var n,r,o,a;return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r="offcanvasWithBothOptions-".concat(null==e?void 0:e.index),(o=document.getElementById(r))&&null!==(n=window.bootstrap)&&void 0!==n&&n.Offcanvas){t.next=4;break}return t.abrupt("return");case 4:if(a=window.bootstrap.Offcanvas.getOrCreateInstance(o,{focus:!1}),o.classList.contains("show")){t.next=7;break}return t.abrupt("return");case 7:return t.next=9,new Promise((function(e){var t=!1,n=function(){t||(t=!0,e())},r=function(){o.removeEventListener("hidden.bs.offcanvas",r),n()};o.addEventListener("hidden.bs.offcanvas",r),a.hide(),window.setTimeout((function(){o.removeEventListener("hidden.bs.offcanvas",r),n()}),250)}));case 9:case"end":return t.stop()}}),t)}))),[null==e?void 0:e.index]);function Mr(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"view_cart_intention";if(window.dataLayer=window.dataLayer||[],"view_cart_intention"===e){var t={assetLabel:window.location.pathname,assetID:null==Xn?void 0:Xn.cmsId,componentName:Zn};return window.dataLayer.push({event:"view_cart_intention",eventLabel:"View Cart",eventSource:Zn,eventSourceLabel:""}),void(document.cookie="gatedInfo=".concat(encodeURIComponent(JSON.stringify(t)),"; path=/; domain=").concat(window.location.hostname.split(".").slice(-2).join(".")))}at=!1;var n=B(),r=n.reduce((function(e,t){return t.IsSample?e:e+Number((null==t?void 0:t.unitPrice)||0)*Number(t.quantity||1)}),0),o=n.map((function(e){var t;return{item_id:(null==e?void 0:e.ispnId)||"",item_name:(null==e?void 0:e.productName)||(null==e?void 0:e.opnName)||"",item_isSample:null!=e&&e.IsSample?"Y":"N",item_category:(null==e?void 0:e.topLevelCategory)||"",item_category2:(null==e?void 0:e.divShortDescr)||"",item_category3:(null==e||null===(t=e.familyId)||void 0===t?void 0:t.toString())||"",item_category4:(null==e?void 0:e.businessSegment)||"",item_category5:(null==e?void 0:e.productStatusInfo)||"",item_variant:(null==e?void 0:e.opnName)||"",price:null!=e&&e.IsSample?0:Number((null==e?void 0:e.unitPrice)||"0"),quantity:Number(null==e?void 0:e.quantity)}})),a=n.map((function(e){return(null==e?void 0:e.productName)||(null==e?void 0:e.opnName)})).join(", ");ut(a);var i=document.getElementById("react-cart-data"),l={view_cart:{eventLabel:"view cart",eventSourceLabel:a},begin_checkout:{eventLabel:i&&i.getAttribute("data-checkout")||"",eventSourceLabel:a}}[e];window.dataLayer.push({ecommerce:null}),window.dataLayer.push({event:e,ecommerce:{currency:Sn,value:Number(r.toFixed(2)),eventLabel:null==l?void 0:l.eventLabel,eventSource:Zn,eventSourceLabel:null==l?void 0:l.eventSourceLabel,items:o}})}function Kr(e,t){if("true"===sessionStorage.getItem(te)||En)xn(!0);else{var n=t.includes("rg_cart")?"add_to_cart":t.includes("rg_checkout")?"checkout":"default";t.includes("rg_checkout")&&Mr("begin_checkout");var r=JSON.parse(o()(document).find(".popup-data").text()||"{}")[n],a=(null==r?void 0:r.title)||"Please Login / Register",i=(null==r?void 0:r.description)||"You need to have myInfineon account to perform this action";o()(document).find(".loginSigninPopup-show-js .addText").text(a),o()(document).find(".loginSigninPopup-show-js .addDescription").text(i);var l="&ui_locales="+o()("html").attr("lang");o()(document).find(".change-icon").removeClass("icon-cart icon-star icon-chip icon-usb icon-downloads icon-calender icon-bell icon-mail icon-contact icon-download icon-bookmark").addClass("icon-cart"),o()(document).find(".update-login-data-js").text("Login").attr("data-link",er+"?originURL=".concat(encodeURIComponent(window.location.pathname+window.location.hash),"&action=lg_vc").concat(l)),o()(document).find(".update-signup-data-js").text("Register").attr("data-link",er+"?originURL=".concat(encodeURIComponent(window.location.pathname+window.location.hash),"&action=rg_vc").concat(l)),o()(document).find(".update-signup-data-js").off("
1click.cartSessionExpired"),t.includes("rg_cart")&&sessionStorage.setItem("cart:pendingOpen","true"),localStorage.setItem("reg-event",t),(0,u.a0)(),Mr()}}function Ur(){if("true"!==sessionStorage.getItem(te)){sessionStorage.setItem(te,"true"),["IS_LOGGED_IN","userObject","MkHcLoggedIn","MkHcLoggedInToken"].forEach((function(e){(0,u.Yj)(e)})),document.cookie.split(";").map((function(e){var t;return null===(t=e.split("=")[0])||void 0===t?void 0:t.trim()})).filter((function(e){return e&&/token/i.test(e)})).forEach((function(e){return(0,u.Yj)(e)})),R(!1),window.userObject=null,localStorage.removeItem("userObject"),sessionStorage.removeItem("userObject");try{o()(document).find(".loginSigninPopup-show-js").modal("hide")}catch(e){console.warn("[Cart] unable to hide legacy login popup before freemailer modal",e)}sessionStorage.setItem("cart:pendingOpen","true"),localStorage.setItem("reg-event","rg_cart-".concat(null==e?void 0:e.index)),xn(!0)}}function Fr(e){return Br.apply(this,arguments)}function Br(){return Br=D(x().mark((function t(n){var r,o,a,i,l,c,s,d,v,p,m,f,g=arguments;return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=g.length>1&&void 0!==g[1]&&g[1],o=document.getElementById("cart-Icon-".concat(null==e?void 0:e.index)),(a=o&&null!==o.offsetParent)||!n){t.next=6;break}return console.log("[Cart] openCart: cart button not visible for index",null==e?void 0:e.index,"skipping"),t.abrupt("return");case 6:if(a||n||console.log("[Cart] openCart: cart button hidden, continuing due to programmatic open flow"),i=B(),l=i&&i.some((function(e){return"SAMPLE"===U(e)})),tr("cart_open_requested",{hasSampleItems:l,localCartSize:(null==i?void 0:i.length)||0}),Pn&&(console.log("Inside openCartPostLogin continuing to open cart"),Pn=!1),c=JSON.parse((0,u.Ri)("IS_LOGGED_IN")||"false")&&(0,u.eJ)("userObject")){t.next=15;break}return Kr(0,"rg_cart-".concat(null==e?void 0:e.index)),t.abrupt("return");case 15:if(sessionStorage.removeItem(te),s=function(){var e=D(x().mark((function e(t){var n,r,o,a;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,r=it(),(o=Ne(r))>0&&Se("cart_open_getcartme_hydration_with_pending_ops",{source:t,pendingCount:o}),e.next=6,Vr();case 6:return a=e.sent,e.next=9,Jr(j(j({},a),{},{version:Number((null==a?void 0:a.version)||0),cartId:(null==a?void 0:a.cartId)||null,itemCount:Number((null==a?void 0:a.itemCount)||(null==a||null===(n=a.items)||void 0===n?void 0:n.length)||0)}),t,{deferProductEnrichment:!1});case 9:return e.next=11,Yr((null==a?void 0:a.items)||[],t);case 11:return e.abrupt("return",Array.isArray(null==a?void 0:a.items)?a.items:[]);case 14:return e.prev=14,e.t0=e.catch(0),console.warn("[Cart] openCart: getcartme hydration failed, falling back to existing local/DK flow",e.t0),e.abrupt("return",[]);case 18:case"end":return e.stop()}}),e,null,[[0,14]])})));return function(t){return e.apply(this,arguments)}}(),d=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"cart_open",n=B();if(n.length>0||!Array.isArray(e)||0===e.length)return n;var r=$e(e,n);if(0===r.length)return n;G(r),ir(r);var o=it();return o.items=We(e.map((function(e){var t,n;return{opnName:(null==e?void 0:e.opnName)||(null==e?void 0:e.skuId),qty:Number(null!==(t=null!==(n=null==e?void 0:e.qty)&&void 0!==n?n:null==e?void 0:e.quantity)&&void 0!==t?t:0),lineType:null==e?void 0:e.lineType}}))),o.badge=j(j({},(null==o?void 0:o.badge)||{}),{},{itemCount:r.length}),o.updatedAt=(new Date).toISOString(),rr(o),Se("cart_open_recovered_from_getcartme_snapshot",{source:t,recoveredCount:r.length}),r},v=function(){var e=D(x().mark((function e(t){var n,r,o,a,i,l,u,v,p,m,f,g;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(ln(!1),O(!1),rn(!1),bn(""),!((n=rt(B())).length>0)){e.next=33;break}if(o=(r=function(e){try{return JSON.parse(localStorage.getItem(e)||"{}")}catch(e){return{}}})("cart:dkStockByOpn"),a=r("cart:dkPriceByOpn"),i=!1,n.forEach((function(e){var t=String(e.opnName||"").trim();if(t){if(!e.localStock){var n=Number(o[t]);Number.isFinite(n)&&n>0&&(e.localStock=n,i=!0)}if(!Number(e.unitPrice)){var r=Number(a[t]);Number.isFinite(r)&&r>0&&(e.unitPrice=String(r),i=!0)}}})),!n.some((function(e){return!e.localStock}))){e.next=29;break}if(e.prev=13,!(u=P(new Set(n.map((function(e){return e.opnName}
1)).filter(Boolean))).join(","))){e.next=21;break}return e.next=18,Nr(u);case 18:e.t0=e.sent,e.next=22;break;case 21:e.t0=null;case 22:v=e.t0,(Array.isArray(null==v||null===(l=v.data)||void 0===l?void 0:l.getCartProductDetails)?v.data.getCartProductDetails:[]).forEach((function(e){var t,r,o=String((null==e?void 0:e.opnName)||(null==e?void 0:e.manufacturerPartNumber)||"").trim().toLowerCase();if(o){var a=null!==(t=null!==(r=null==e?void 0:e.quantityAvailable)&&void 0!==r?r:null==e?void 0:e.availability)&&void 0!==t?t:null==e?void 0:e.Availability,l=Number(a);if(Number.isFinite(l)&&!(l<=0)){var u=n.find((function(e){return String(e.opnName||"").trim().toLowerCase()===o}));u&&!u.localStock&&(u.localStock=l,i=!0)}}})),e.next=29;break;case 27:e.prev=27,e.t1=e.catch(13);case 29:i&&G(n),vr([],n),e.next=34;break;case 33:dr();case 34:return ht(!1),Rr(c,{showLoader:!1}),rn(!0),e.prev=37,p=Date.now(),e.next=41,cr(!1);case 41:return console.log("[Cart] local+AEM bind duration(ms):",Date.now()-p,{sourceTag:t}),m=Date.now(),e.next=45,_r();case 45:return e.next=47,kr("".concat(t,"_pre_merge"));case 47:return e.next=49,s(t);case 49:return f=e.sent,e.next=52,Tr();case 52:return y=void 0,y=me()+1,sessionStorage.setItem(ae,String(y)),localStorage.setItem(ae,String(y)),d(f,t),console.log("[Cart] merge phase duration(ms):",Date.now()-m,{sourceTag:t}),e.next=57,cr(!1);case 57:return g=Date.now(),at=!0,e.next=61,cr(!0);case 61:return console.log("[Cart] live price/stock duration(ms):",Date.now()-g,{sourceTag:t}),br("".concat(t,"_async")),e.next=65,gr("".concat(t,"_loaded"));case 65:tr("cart_open_context_loaded",{syncMode:"background",source:t}),e.next=77;break;case 68:return e.prev=68,e.t2=e.catch(37),console.error("[Cart] openCart: Live price/stock refresh failed:",e.t2),at=!0,e.next=74,cr(!1);case 74:O(!1),Rr(c,{showLoader:!1}),tr("cart_open_context_failed",{message:(null===e.t2||void 0===e.t2?void 0:e.t2.message)||"unknown",source:t});case 77:return e.prev=77,ln(!1),rn(!1),e.finish(77);case 81:case"end":return e.stop()}var y}),e,null,[[13,27],[37,68,77,81]])})));return function(t){return e.apply(this,arguments)}}(),!l||r){t.next=76;break}return t.next=23,_r();case 23:if(!!(0,u.Ri)("MkHcLoggedInToken")){t.next=76;break}return ln(!0),Rr(c,{showLoader:!0}),sessionStorage.setItem("cart:inSSOFlow","true"),sessionStorage.setItem("openViewCartAfterSSO","true"),sessionStorage.setItem("cart:pendingOpen","true"),sn(!0),t.next=33,Ir(!0);case 33:if(p=t.sent,!!(0,u.Ri)("MkHcLoggedInToken")){t.next=58;break}if(console.log("[Cart] DigiKey SSO signOn failed, attempting initSignIn fallback"),t.prev=37,null===(f=window)||void 0===f||null===(f=f.DigiKeyCart)||void 0===f||!f.initSignIn){t.next=43;break}return console.log("[Cart] Redirecting to DigiKey login via initSignIn, keeping SSO flags"),t.next=42,window.DigiKeyCart.initSignIn();case 42:return t.abrupt("return");case 43:t.next=48;break;case 45:t.prev=45,t.t0=t.catch(37),console.error("[Cart] DigiKey initSignIn fallback also failed:",t.t0);case 48:return console.warn("[Cart] DigiKey login redirect not available after signOn attempt",{signOnStarted:p,hasInitSignIn:!(null===(m=window)||void 0===m||null===(m=m.DigiKeyCart)||void 0===m||!m.initSignIn),errorDetails:"DigiKey SSO flow failed. Sample items require DigiKey authentication."}),sessionStorage.removeItem("cart:inSSOFlow"),sessionStorage.removeItem("openViewCartAfterSSO"),sessionStorage.removeItem("cart:pendingOpen"),sn(!1),ln(!1),O(!1),Cn(!0),bn((null==ie?void 0:ie.DigiKeyLoginFailed)||"Unable to authenticate with DigiKey. Please try again or contact support if the issue persists."),t.abrupt("return");case 58:return sessionStorage.removeItem("openViewCartAfterSSO"),sessionStorage.removeItem("cart:inSSOFlow"),sn(!1),t.prev=61,t.next=64,v("cart_open_after_sso");case 64:t.next=71;break;case 66:return t.prev=66,t.t1=t.catch(61),console.error("Failed to open cart after DigiKey SSO:",t.t1),t.next=71,cr(!1);case 71:return t.prev=71,sessionStorage.removeItem("cart:pendingOpen"),ln(!1),t.finish(71);case 75:return t.abrupt("return");case 76:return t.prev=76,t.next=79,v("cart_open");case 79:t.next=89;break;case 81:return t.prev=81,t.t2=t.catch(76),console.error("[Cart] openCart: Backgroun
1d sync failed silently:",t.t2),t.next=86,cr(!1);case 86:O(!1),Rr(c,{showLoader:!1}),tr("cart_open_context_failed",{message:(null===t.t2||void 0===t.t2?void 0:t.t2.message)||"unknown"});case 89:return t.prev=89,ln(!1),t.finish(89);case 92:case"end":return t.stop()}}),t,null,[[37,45],[61,66,71,75],[76,81,89,92]])}))),Br.apply(this,arguments)}On.current=Fr;function Gr(){var e;if(hn)return hn;var t=Ue.filter((function(e){return!0===e.IsSample||!0===e.isSample}));if(!function(e){if(0==(null==e?void 0:e.length))return!0;var t=(0,C.X)();return!(!t||"Freemailer"===t||"Competitor"===t)}(t))return Kt(!1),ie.NotEligibleForSamples;if(Kt(!0),function(e,t){for(var n=[],r=function(){var r,a,i=null===(r=e[o])||void 0===r?void 0:r.opnName,l=null==t||null===(a=t.data)||void 0===a||null===(a=a.getCartProductDetails)||void 0===a?void 0:a.find((function(e){return e.opnName===i}));l&&"Y"!==l.freeSampleFlag&&n.push(i)},o=0;o<(null==e?void 0:e.length);o+=1)r();return(null==n?void 0:n.length)!==(null==Ht?void 0:Ht.length)&&Vt(n),(null==n?void 0:n.length)>0}(t,qt))return ie.ProductNotEligibleForSample;var n,r=t.find((function(e){return 0===e.quantityAvailable}))||{};return(null===(e=Object.keys(r))||void 0===e?void 0:e.length)>0||Ue.find((function(e){return!(e.IsSample||e.isSample)&&0===e.quantityAvailable}))?ie.ProductOutOfStock:(null===(n=Ue.filter((function(e){return!0===e.IsSample||!0===e.isSample})))||void 0===n?void 0:n.length)>3&&ie.SampleLimitExceeded}JSON.parse((0,u.Ri)("IS_LOGGED_IN")||"false")&&(0,u.eJ)("userObject"),JSON.parse((0,u.Ri)("MkHcLoggedIn")||"false"),(0,u.Ri)("MkHcLoggedInToken");var Hr=(0,C.X)();(0,a.useEffect)((function(){(ir(B()),"true"===sessionStorage.getItem("cart:pendingOpen"))&&(["code","state","scope","session_state"].some((function(e){return new URLSearchParams(window.location.search).has(e)}))||(sessionStorage.removeItem("cart:pendingOpen"),setTimeout((function(){Fr()}),0)));var t=function(e){var t;e.persisted&&(document.documentElement.style.overflow="",document.body.style.paddingRight="",null===(t=document.querySelector(".mainnavigation"))||void 0===t||t.classList.remove("active"),sessionStorage.removeItem("checkoutPending"))};window.addEventListener("pageshow",t);var n=localStorage.getItem("reg-event");if(An=null==n?void 0:n.split("-")[1],null!=n&&n.includes("rg_cart")){localStorage.removeItem("reg-event"),Pn=!0;var r=function(e){JSON.parse((0,u.Ri)("IS_LOGGED_IN")||"false")&&(0,u.eJ)("userObject")?Fr():e>0&&setTimeout((function(){return r(e-1)}),300)};r(14)}var o=(0,u.Ri)("affiliateCookie");return o&&"OpenCart"===o&&((0,u.Yj)("affiliateCookie"),sessionStorage.setItem("cart:affiliateOpen","true")),"true"===sessionStorage.getItem("cart:affiliateOpen")&&(Pn=!0,setTimeout(D(x().mark((function t(){var n;return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n=document.getElementById("cart-Icon-".concat(null==e?void 0:e.index)))||null===n.offsetParent){t.next=5;break}return sessionStorage.removeItem("cart:affiliateOpen"),t.next=5,Fr(null,!0);case 5:case"end":return t.stop()}}),t)}))),2500)),function(){window.removeEventListener("pageshow",t)}}),[null==e?void 0:e.index]),(0,a.useEffect)((function(){tr("app_open",{source:"ReactCartDigi"})}),[]),(0,a.useEffect)((function(){if(null!=e&&e.getproductsviaopns){var t=window.setTimeout(D(x().mark((function e(){var t,n,r,o,a,i,l,u;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,(n=B()).length){e.next=4;break}return e.abrupt("return");case 4:if(r=P(new Set(n.map((function(e){return e.opnName})).filter(Boolean))).join(",")){e.next=7;break}return e.abrupt("return");case 7:return e.next=9,Nr(r);case 9:if(o=e.sent,(a=Array.isArray(null==o||null===(t=o.data)||void 0===t?void 0:t.getCartProductDetails)?o.data.getCartProductDetails:[]).length){e.next=13;break}return e.abrupt("return");case 13:if(i={},a.forEach((function(e){var t,n,r=String((null==e?void 0:e.opnName)||(null==e?void 0:e.manufacturerPartNumber)||"").trim().toLowerCase();if(r){var o=null!==(t=null!==(n=null==e?void 0:e.quantityAvailable)&&void 0!==n?n:null==e?void 0:e.availability)&&void 0!==t?t:null==e?void 0:e.Availability,a=Number(o);Number.isFinite(a)&&a>=0&&(i[r]=a)}})),Object.keys(i).length){e.next=17;break}return e.abrupt("return");case 17:l=0,u=n.map((function(e){var t=String(e.opnName||"").trim().toLowerCase();if(!t||!(t in i))return e;var n=i[t];return e.localStock!==n?(l+=1,j(j({},e),{},{localStock:n})):e})),l>
10&&(G(u),console.log("[Cart] Background stock pre-warm: updated",l,"item(s) localStock from AEM")),e.next=25;break;case 22:e.prev=22,e.t0=e.catch(0),console.warn("[Cart] Background localStock pre-warm failed:",e.t0);case 25:case"end":return e.stop()}}),e,null,[[0,22]])}))),2500);return function(){return window.clearTimeout(t)}}}),[]),(0,a.useEffect)((function(){var e=0,t=window.setInterval((function(){e+=1;var n=it(),r=Ne(n);r>0&&(Se("bootstrap_pending_ops_flush",{attempts:e,pendingCount:r,draftCartId:(null==n?void 0:n.cartId)||null,draftVersion:Number((null==n?void 0:n.version)||0),isLoggedIn:we()}),pr("bootstrap_pending_ops")),(0===r||e>=12)&&window.clearInterval(t)}),1e3);return function(){window.clearInterval(t)}}),[pr]),(0,a.useEffect)((function(){var e=new URLSearchParams(window.location.search);["code","scope","state","session_state","iss","error","error_description","error_uri"].some((function(t){return e.has(t)}))&&(console.log("[DK-SSO] OAuth params detected in URL - processing callback once"),Cr())}),[]),(0,a.useEffect)((function(){"ERROR"!==vn||0!==fn||Mn.current||(pn("IDLE"),Se("sync_status_reset_idle",{reason:"no_pending_ops"}))}),[vn,fn]),(0,a.useEffect)((function(){var e;try{e=new Worker(new URL(n.p+n.u(3987),n.b)),qn.current=e,e.onmessage=function(e){var t,n=null==e||null===(t=e.data)||void 0===t?void 0:t.type;if("FLUSH_PENDING"!==n){if("FULL_CART_RESULT"===n){var r,o,a,i,l=null==e||null===(r=e.data)||void 0===r?void 0:r.requestId,u=jn.current.get(l);if(!u)return;if(jn.current.delete(l),null!=e&&null!==(o=e.data)&&void 0!==o&&o.ok)u.resolve((null==e||null===(a=e.data)||void 0===a?void 0:a.payload)||{items:[]});else u.reject(new Error((null==e||null===(i=e.data)||void 0===i?void 0:i.error)||"full cart fetch failed"))}}else pr("worker")},e.postMessage({type:"START",debounce:800}),ot("worker_started",{mode:"web_worker"})}catch(e){console.warn("[CartSync] Worker initialization failed, using fallback mode",e),ot("worker_failed_to_start",{message:(null==e?void 0:e.message)||"unknown"})}return function(){Un.current&&(window.clearTimeout(Un.current),Un.current=null),e&&(e.postMessage({type:"STOP"}),e.terminate()),qn.current=null}}),[pr]);var Vr=function(){var t=D(x().mark((function t(){var n,r,o;return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=de()?"/api/cart/me.json":Te(Q,void 0,e),Se("resolve_full_cart_endpoint",{endpoint:n,mode:de()?"mock":"aem"}),t.next=4,fetch(n,{method:"GET",headers:{"Content-Type":"application/json"}});case 4:if((r=t.sent).ok){t.next=8;break}throw 401===r.status&&Ur(),new Error("full cart fetch failed: ".concat(r.status));case 8:return t.next=10,r.text();case 10:if((o=t.sent)&&o.trim()){t.next=13;break}return t.abrupt("return",{items:[]});case 13:return t.abrupt("return",JSON.parse(o));case 14:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),Qr=function(){var t=D(x().mark((function t(n){var r,o,a=arguments;return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((r=a.length>1&&void 0!==a[1]?a[1]:de()?"/api/cart/me.json":Te(Q,void 0,e))&&qn.current){t.next=3;break}return t.abrupt("return",Vr());case 3:return o="cart-snapshot-".concat(Date.now(),"-").concat(++Rn.current),t.abrupt("return",new Promise((function(e,t){var a=window.setTimeout((function(){jn.current.delete(o),Vr().then(e).catch(t)}),1e4);jn.current.set(o,{resolve:function(t){window.clearTimeout(a),e(t)},reject:function(e){window.clearTimeout(a),t(e)}});try{qn.current.postMessage({type:"FETCH_FULL_CART",requestId:o,endpoint:r,source:n})}catch(n){window.clearTimeout(a),jn.current.delete(o),Vr().then(e).catch(t)}})));case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),Jr=function(){var e=D(x().mark((function e(t){var n,r,o,a,i,l,u,c,s,d,v,p,m=arguments;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=m.length>1&&void 0!==m[1]?m[1]:"server_snapshot",o=!0===(null==(r=m.length>2&&void 0!==m[2]?m[2]:{})?void 0:r.deferProductEnrichment),a=Array.isArray(null==t?void 0:t.items)?t.items:[],i=it(),l=Oe(a,i),u=B(),c=$e(l,u),s=Math.max(Number((null==t?void 0:t.itemCount)||0),Number(c.length||0)),Se("server_cart_hydration_started",{reason:n,itemCount:s,version:Number((null==t?void 0:t.ver
1sion)||0)}),d=Array.isArray(null==i?void 0:i.pendingOps)?P(i.pendingOps):[],i.cartId=(null==t?void 0:t.cartId)||(null==i?void 0:i.cartId)||null,i.version=Number((null==t?void 0:t.version)||(null==i?void 0:i.version)||0),v=We(a.map((function(e){var t,n;return{opnName:(null==e?void 0:e.opnName)||(null==e?void 0:e.skuId),qty:Number(null!==(t=null!==(n=null==e?void 0:e.qty)&&void 0!==n?n:null==e?void 0:e.quantity)&&void 0!==t?t:0),lineType:null==e?void 0:e.lineType}}))),i.items=et(v,d),i.badge=j(j({},(null==i?void 0:i.badge)||{}),{},{itemCount:s}),i.pendingOps=d,i.status=De(we(),i),i.updatedAt=(new Date).toISOString(),rr(i),0!==c.length){e.next=27;break}return localStorage.removeItem("cart-data"),ir([]),e.next=25,cr(!1);case 25:return nr("CART_SYNCED",{cartId:i.cartId,version:i.version,itemCount:0,source:n}),e.abrupt("return");case 27:if(G(c),ir(c),p=function(){var e=D(x().mark((function e(){var t,r,o,a,i;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,r=ar(c),e.next=4,Nr(r);case 4:return o=e.sent,a=lr(c,o),Rt(o),G(a),(i=it()).badge=j(j({},(null==i?void 0:i.badge)||{}),{},{itemCount:Number((null==i||null===(t=i.badge)||void 0===t?void 0:t.itemCount)||a.length||0)}),i.updatedAt=(new Date).toISOString(),rr(i),ir(a),e.next=15,cr(!1);case 15:ot("server_cart_products_merged",{reason:n,itemCount:a.length}),Se("server_cart_products_merged",{reason:n,itemCount:a.length}),e.next=22;break;case 19:e.prev=19,e.t0=e.catch(0),console.warn("[Cart] Product enrichment failed after server hydration",e.t0);case 22:case"end":return e.stop()}}),e,null,[[0,19]])})));return function(){return e.apply(this,arguments)}}(),!o){e.next=34;break}p(),e.next=36;break;case 34:return e.next=36,p();case 36:nr("CART_SYNCED",{cartId:i.cartId,version:i.version,itemCount:s,source:n}),ot("server_cart_hydration_completed",{reason:n,itemCount:s,version:i.version}),Se("server_cart_hydration_completed",{reason:n,itemCount:s,version:i.version});case 39:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Yr=function(){var e=D(x().mark((function e(){var t,n,r,o,a,i,l,u,c,s,d,v,p,m,f,g,y,h,k,S,w,I,_,C,N=arguments;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=N.length>0&&void 0!==N[0]?N[0]:[],n=N.length>1&&void 0!==N[1]?N[1]:"cart_open",e.prev=2,(i=pe())&&console.log("[Cart] syncDigiKeyCartDelta: evaluating DigiKey deltas with local-line precedence because getcartme priority is active"),null!==(r=b)&&void 0!==r&&null!==(o=r.checkInitialized)&&void 0!==o&&o.call(r)){e.next=8;break}return console.log("[Cart] syncDigiKeyCartDelta: DigiKey not initialized, skipping"),e.abrupt("return");case 8:return e.next=10,b.getCart();case 10:if(null!=(l=e.sent)&&l.successful&&!vo(l)){e.next=14;break}return console.log("[Cart] syncDigiKeyCartDelta: DigiKey cart empty (400) or error â nothing to sync"),e.abrupt("return");case 14:if(u=Array.isArray(null==l||null===(a=l.data)||void 0===a?void 0:a.orderLines)?l.data.orderLines:[],c=it(),s=Ce(c),d=ge(),v=new Map,s.forEac
1h((function(e){var t,n,r=String((null==e||null===(t=e.payload)||void 0===t?void 0:t.skuId)||"").trim().toUpperCase(),o=Re(null==e||null===(n=e.payload)||void 0===n?void 0:n.lineType),a=r?"".concat(r,"::").concat(o):"";a&&v.set(a,e)})),p=new Set(Array.from(v.keys())),0===u.length&&console.log("[Cart] syncDigiKeyCartDelta: DigiKey cart has no order lines â reconciling as empty cart"),console.log("[Cart] syncDigiKeyCartDelta: DigiKey",u.length,"items |","getCartMe",(t||[]).length,"items"),m=new Map,(Array.isArray(t)?t:[]).forEach((function(e){var t="SAMPLE"===String((null==e?void 0:e.lineType)||"").toUpperCase()?"SAMPLE":"PAID",n=String((null==e?void 0:e.skuId)||(null==e?void 0:e.opnName)||"").trim();if(n){var r="".concat(n.toUpperCase(),"::").concat(t);m.set(r,{skuId:n,qty:Number((null==e?void 0:e.qty)||(null==e?void 0:e.quantity)||0),lineType:t})}})),f=new Map,g=0,u.forEach((function(e){var t=String((null==e?void 0:e.manufacturerPartNumber)||"").trim();if(t){var n=Number((null==e?void 0:e.quantity)||0);if(n>0){var r=null!=e&&e.isSample?"SAMPLE":"PAID",o="".concat(t.toUpperCase(),"::").concat(r);f.set(o,{skuId:t,qty:n,lineType:r,isSample:Boolean(null==e?void 0:e.isSample)})}else g+=1}else g+=1})),g>0&&console.log("[Cart] syncDigiKeyCartDelta: skipped invalid DigiKey lines:",g),y=[],h=[],k=[],Ye(new Set(Array.from(f.keys()))),S=B(),w=new Map,S.forEach((function(e){var t=U(e),n="".concat(String((null==e?void 0:e.opnName)||"").trim().toUpperCase(),"::").concat(t);w.set(n,e)})),f.forEach((function(e,t){var n;if(Je(null==e?void 0:e.skuId,null==e?void 0:e.lineType))console.log("[Cart] syncDigiKeyCartDelta: skipping tombstoned item ".concat(null==e?void 0:e.skuId,"(").concat(null==e?void 0:e.lineType,") - was deleted locally"));else{var r=v.get(t);if(!("DELETE"===Me(null==r?void 0:r.op)||r&&Number((null==r||null===(n=r.payload)||void 0===n?void 0:n.qty)||0)<=0)&&!p.has(t)){var o=m.get(t);o?o.qty!==e.qty&&h.push({skuId:e.skuId,qty:e.qty,lineType:e.lineType}):y.push({skuId:e.skuId,qty:e.qty,lineType:e.lineType})}}})),m.forEach((function(e,t){if(!f.has(t)){if(p.has(t))return;if(i&&d.has(t))return;k.push({skuId:e.skuId,qty:0,lineType:e.lineType})}})),0!==y.length+h.length+k.length){e.next=42;break}return console.log("[Cart] syncDigiKeyCartDelta: carts are already in sync â no delta"),e.abrupt("return");case 42:console.log("[Cart] syncDigiKeyCartDelta: deltas â inserts:",y.length,"| updates:",h.length,"| deletes:",k.length),I=[],f.forEach((function(e,t){var n;if(Je(null==e?void 0:e.skuId,null==e?void 0:e.lineType))console.log("[Cart] syncDigiKeyCartDelta: rebuild - skipping tombstoned item ".concat(null==e?void 0:e.skuId,"(").concat(null==e?void 0:e.lineType,")"));else{var r=v.get(t);if(!("DELETE"===Me(null==r?void 0:r.op)||r&&Number((null==r||null===(n=r.payload)||void 0===n?void 0:n.qty)||0)<=0)){var o,a,i,l,u,c,s,d,p,m,f=w.get(t);if(r)return f?void I.push(j(j({},f),{},{quantity:Number(null!==(s=null!==(d=null!==(p=null==f?void 0:f.quantity)&&void 0!==p?p:null==r||null===(m=r.payload)||void 0===m?void 0:m.qty)&&void 0!==d?d:null==e?void 0:e.qty)&&void 0!==s?s:0),IsSample:"SAMPLE"===U(f),lineType:U(f),fromRemote:!1})):void I.push({opnName:(null==r||null===(o=r.payload)||void 0===o?void 0:o.skuId)||e.skuId,quantity:Number(null!==(a=null!==(i=null==r||null===(l=r.payload)||void 0===l?void 0:l.qty)&&void 0!==i?i:null==e?void 0:e.qty)&&void 0!==a?a:0),IsSample:"SAMPLE"===Re((null==r||null===(u=r.payload)||void 0===u?void 0:u.lineType)||(null==e?void 0:e.lineType)),lineType:Re((null==r||null===(c=r.payload)||void 0===c?void 0:c.lineType)||(null==e?void 0:e.lineType)),fromRemote:!1});f?I.push(j(j({},f),{},{quantity:e.qty,IsSample:e.isSample,lineType:e.lineType,fromRemote:!0})):I.push({opnName:e.skuId,quantity:e.qty,IsSample:e.isSample,lineType:e.lineType,fromRemote:!0})}}})),i&&S.forEach((function(e){var t=U(e),n="".concat(String((null==e?void 0:e.opnName)||"").trim().toUpperCase(),"::").concat(t);!f.has(n)&&d.has(n)&&I.push(e)})),G(I),ir(I),_=it(),C=I.map((function(e){return{opnName:null==e?void 0:e.opnName,qty:Number((null==e?void 0:e.quantity)||0),lineType:U(e)}})),_.items=We(C),_.badge=j(j({},(null==_?void 0:_.badge)||{}),{},{itemCount:I.length}
1),_.updatedAt=(new Date).toISOString(),rr(_),y.forEach((function(e){hr("INSERT",{skuId:e.skuId,qty:e.qty,lineType:e.lineType},{triggerSync:!1,triggerHostedSync:!1,skipPriorityFlag:!0,skipTombstone:!0})})),h.forEach((function(e){hr("UPDATE",{skuId:e.skuId,qty:e.qty,lineType:e.lineType},{triggerSync:!1,triggerHostedSync:!1,skipPriorityFlag:!0,skipTombstone:!0})})),k.forEach((function(e){hr("DELETE",{skuId:e.skuId,qty:e.qty,lineType:e.lineType},{triggerSync:!1,triggerHostedSync:!1,skipPriorityFlag:!0,skipTombstone:!0})})),Se("digikey_cart_delta_synced",{source:n,inserts:y.length,updates:h.length,deletes:k.length,totalItems:I.length}),console.log("[Cart] syncDigiKeyCartDelta: delta applied â pending ops queued for AEM sync"),e.next=67;break;case 61:if(e.prev=61,e.t0=e.catch(2),!vo(e.t0)){e.next=66;break}return console.log("[Cart] syncDigiKeyCartDelta: DigiKey carts returned 400/no-open-cart â skip delta sync"),e.abrupt("return");case 66:console.warn("[Cart] syncDigiKeyCartDelta: failed",e.t0);case 67:case"end":return e.stop()}}),e,null,[[2,61]])})));return function(){return e.apply(this,arguments)}}(),zr=function(e){return String((null==e?void 0:e.opnName)||(null==e?void 0:e.manufacturerPartNumber)||(null==e?void 0:e.skuId)||(null==e?void 0:e.productName)||"").trim().toLowerCase()},Wr=function(){try{return"true"===localStorage.getItem("cart:debugStock")}catch(e){return!1}},Xr=function(e){var t,n,r,o=String(e||"").trim().toLowerCase(),a=Array.isArray(pt)?pt.find((function(e){return zr(e)===o})):null,i=Array.isArray(Ue)?Ue.find((function(t){return String((null==t?void 0:t.opnName)||"").toLowerCase()===String(e||"").toLowerCase()})):null,l=Number(null!==(t=null!==(n=null!==(r=null==a?void 0:a.quantityAvailable)&&void 0!==r?r:null==i?void 0:i.quantityAvailable)&&void 0!==n?n:null==i?void 0:i.localStock)&&void 0!==t?t:0);return Number.isFinite(l)&&l>=0?l:0},Zr=function(e){var t=(Array.isArray(e)?e:[]).reduce((function(e,t){var n=null==t?void 0:t.opnName;return n?(e[n]||(e[n]={}),e[n][Boolean(null==t?void 0:t.IsSample)]=Number((null==t?void 0:t.quantity)||0),e):e}),{});dt(t)},$r=function(){var e=D(x().mark((function e(t,n){var r,o;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=Boolean(n),we()||!r){e.next=4;break}return(0,u.a0)("cart-remove-sample"),e.abrupt("return");case 4:return 0===(o=(o=B()).filter((function(e){return!((null==e?void 0:e.opnName)===t&&Boolean(null==e?void 0:e.IsSample)===r)}))).length?(localStorage.removeItem("cart-data"),Be([]),ir(0)):(G(o),ir(o)),Zr(o),hr("DELETE",{skuId:t,lineType:r?"SAMPLE":"PAID",qty:0}),tr("cart_item_removed",{skuId:t,lineType:r?"SAMPLE":"PAID",remainingItems:o.length}),Se("cart_item_delete_queued",{operation:"DELETE",skuId:t,lineType:r?"SAMPLE":"PAID",remainingItems:o.length}),e.next=13,cr(!1);case 13:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),eo=function(e,t,n,r){var o,a,i=Boolean(r),l=B(),u=l.find((function(e){return(null==e?void 0:e.opnName)===t&&Boolean(null==e?void 0:e.IsSample)===i}));if(u){var c=Xr(t),s=Number((null==u?void 0:u.quantity)||0),d=Number.isFinite(Number((null==e||null===(o=e.current)||void 0===o?void 0:o.value)||s||0))?Number((null==e||null===(a=e.current)||void 0===a?void 0:a.value)||s||0):s,v=c<=0?0:n?Math.min(d+1,c):Math.max(d-1,0);u.quantity=v,null!=e&&e.current&&(e.current.value=v),G(l);var p=j({},st);p[t]||(p[t]={}),p[t][i]=v,dt(p),tr("cart_item_qty_updated",{skuId:t,qty:v,lineType:i?"SAMPLE":"PAID",mode:n?"increment":"decrement"}),hr("UPDATE",{skuId:t,qty:v,lineType:i?"SAMPLE":"PAID"}),Se("cart_item_qty_updated",{operation:"UPDATE",skuId:t,beforeQty:s,afterQty:v,lineType:i?"SAMPLE":"PAID",mode:n?"increment":"decrement"}),sr(!1)}},to=function(e,t,n){var r,o,a,i=Boolean(n),l=B(),u=l.find((function(t){return(null==t?void 0:t.opnName)===e&&Boolean(null==t?void 0:t.IsSample)===i}));if(u){if(""===(null==t||null===(r=t.target)||void 0===r?void 0:r.value)){var s=j({},st);return s[e]||(s[e]={}),s[e][i]="",void dt(s)}(0,c.CI)(null==t||null===(o=t.target)||void 0===o?void 0:o.value)&&(t.target.value="1");var d=Xr(e),v=Number((null==u?void 0:u.quantity)||0),p=Number((null==t||null===(a=t.target)||void 0===a?void 0:a.value)||0),m=Number.isFinite(p)?p:v,f=d>0?Math.min(Math.max(m,0),d):0;u.quantity=f,G(l);var g=j({},st);g[e]||(g[e]={}),g[e][i]=f,dt(g),tr("cart_item_qty_input",{skuId:e,qty:f,lineType:i?"SAMPLE":"PAID"}),hr("UPDATE",{skuId:e,qty:f,lineType:i?"SAMPLE":"PAID"},{triggerSync:!1,triggerHostedSync:!1}
1),Se("cart_item_input_updated",{operation:"UPDATE",skuId:e,beforeQty:v,afterQty:f,lineType:i?"SAMPLE":"PAID",userInput:m,stockLimit:d,valueAdjusted:f!==m}),sr(!1)}},no=function(e,t,n){var r;(0,c.W_)(null==t||null===(r=t.target)||void 0===r?void 0:r.value)&&(Xr(e)>0&&(null!=t&&t.target&&(t.target.value=1),to(e,t,n)));fr()},ro=function(e){window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"select_item",eventLabel:e,eventSource:Zn,eventSourceLabel:lt})};var oo=function(e){if(null==e)return null;if("number"==typeof e)return Number.isFinite(e)&&e>=0?e:null;var t=Number(String(e).trim().replace(/,/g,""));return Number.isFinite(t)&&t>=0?t:null},ao=function(e){for(var t,n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=0,a=[null==e?void 0:e.quantityAvailable,null==e?void 0:e.availability,null==e?void 0:e.Availability,null==e||null===(t=e.price)||void 0===t?void 0:t.availability,null==e||null===(n=e.price)||void 0===n?void 0:n.Availability];o<a.length;o++){var i=oo(a[o]);if(null!==i)return i}var l=oo(r);return null!==l?l:0};function io(e,t){var n,r,o,a,i,l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},u=l.fallbackAvailability,c=void 0===u?0:u,s=l.fallbackPricePerUnit,d=void 0===s?0:s;if(!e)return{pricePerUnit:d,availability:c,subTotal:d*t};var v,p,m,f,g,y=null==e||null===(n=e.priceTiers)||void 0===n?void 0:n.filter((function(e){return kn.includes(e.packageType)}));0===(null===(r=y)||void 0===r?void 0:r.length)&&(y=null==e||null===(v=e.priceTiers)||void 0===v?void 0:v.filter((function(e){return!kn.includes(e.packageType)})));if(!((null===(o=y)||void 0===o?void 0:o.length)>0))return{pricePerUnit:d,availability:ao(e,c),subTotal:d*t};if(f=null===(m=y[0])||void 0===m?void 0:m.pricing,null==(g=null==f?void 0:f.filter((function(e){return 0!==e.breakQuantity})))||g.sort((function(e,t){return e.breakQuantity-t.breakQuantity})),!(p=null==g?void 0:g.map((function(e,t){var n,r=g[t+1];return{price:lo(e.unitPrice),minQuantity:0===t&&1!==(null===(n=g[1])||void 0===n?void 0:n.breakQuantity)?1:e.breakQuantity,maxQuantity:r?r.breakQuantity-1:1/0}})))||0===(null===(a=p)||void 0===a?void 0:a.length))return{pricePerUnit:d,availability:ao(e,c),subTotal:d*t};var h=Math.max(1,t),b=null===(i=p)||void 0===i?void 0:i.find((function(e){return h>=e.minQuantity&&h<=e.maxQuantity}));if(!b)return{pricePerUnit:d,availability:ao(e,c),subTotal:d*t};var k=b.price,S=ao(e,c);return{pricePerUnit:k,availability:S,subTotal:0!==t&&S>0?k*t:0}}function lo(e){var t=parseFloat(e);return null==t?void 0:t.toFixed(Math.max(2,((null==t?void 0:t.toString().split(".")[1])||"").length))}var uo=function(){try{var e,t,n;return!!(sessionStorage.getItem("MkHcLoggedInToken")||sessionStorage.getItem("digiKeyToken"))||(!(null===(e=window)||void 0===e||null===(e=e.DigiKeyCart)||void 0===e||null===(t=e.isUserLoggedIn)||void 0===t||!t.call(e))||!0===(null===(n=window)||void 0===n||null===(n=n.digikeyDetails)||void 0===n?void 0:n.loggedIn))}catch(e){return console.warn("[Cart] Error checking DigiKey login status:",e),!1}},co=function(){var e=D(x().mark((function e(){var t,n,r;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,Xt(!0),e.next=4,_r();case 4:if("function"!=typeof Ir){e.next=11;break}return e.next=7,Ir(!0);case 7:if(0!==(null==(r=e.sent)?void 0:r.errorCode)&&!(0,u.Ri)("MkHcLoggedInToken")){e.next=11;break}return Se("digikey_login_success",{source:"checkout"}),e.abrupt("return",!0);case 11:if(null===(t=window)||void 0===t||null===(t=t.DigiKeyCart)||void 0===t||!t.initSignIn){e.next=16;break}return console.log("[Cart] Checkout: attempting DigiKey initSignIn as fallback"),e.next=15,window.DigiKeyCart.initSignIn();case 15:return e.abrupt("return",!0);case 16:return Se("digikey_login_unavailable",{hasInitSignIn:Boolean(null===(n=window)||void 0===n||null===(n=n.DigiKeyCart)||void 0===n?void 0:n.initSignIn),hasDkSignOn:"function"==typeof Ir}),e.abrupt("return",!1);case 20:return e.prev=20,e.t0=e.catch(0),console.warn("[Cart] DigiKey login redirect failed:",e.t0),Se("digikey_login_redirect_error",{message:(null===e.t0||void 0===e.t0?void 0:e.t0.message)||"unknown"}),e.abrupt("return",!1);case 25:case"end":return e.stop()}}),e,null,[[0,20]])})));return function(){return e.apply(this,arguments)}}(),so=function(e){var t,n,r,o,a,i=[null==e?void 0:e.message,null==e?void 0:e.error,null==e?void 0:e.errorMessage,null==e?void 0:e.detail,null==e?void 0:e.statusText,null==e||null===(t=e.data)||void 0===t?void 0:t.message,null==e||null===(n=e.data)||void 0===n?void 0:n.error,null==e||null===(r=e.response)||void 0===r||null===(r=r.data)||void 0===r?void 0:r.message,null==e||null===(o=e.response)||void 0===o||null===(o=o.data)||void 0===o?void 0:o.error].filter(
1Boolean).join(" ").toLowerCase(),l=Number((null==e?void 0:e.statusCode)||(null==e?void 0:e.status)||(null==e?void 0:e.httpStatus)||(null==e||null===(a=e.response)||void 0===a?void 0:a.status)||(null==e?void 0:e.code));return[401,403].includes(l)||i.includes("unauthorized")||i.includes("forbidden")||i.includes("token expired")||i.includes("invalid token")||i.includes("access denied")},vo=function(e){var t;return 400===Number((null==e?void 0:e.statusCode)||(null==e?void 0:e.status)||(null==e?void 0:e.httpStatus)||(null==e||null===(t=e.response)||void 0===t?void 0:t.status)||(null==e?void 0:e.code))||!(!e||!Object.prototype.hasOwnProperty.call(e,"data"))&&null===(null==e?void 0:e.data)},po=(0,a.useCallback)(D(x().mark((function e(){var t,n,r;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,uo()){e.next=3;break}return e.abrupt("return",!1);case 3:return e.next=5,_r();case 5:if("function"!=typeof(null===(t=b)||void 0===t?void 0:t.isUserLoggedIn)||b.isUserLoggedIn()){e.next=7;break}return e.abrupt("return",!1);case 7:if("function"==typeof(null===(n=b)||void 0===n?void 0:n.getCart)){e.next=9;break}return e.abrupt("return",!0);case 9:return e.next=11,b.getCart();case 11:if(r=e.sent,!so(r)){e.next=14;break}return e.abrupt("return",!1);case 14:return e.abrupt("return",!0);case 17:if(e.prev=17,e.t0=e.catch(0),!so(e.t0)){e.next=21;break}return e.abrupt("return",!1);case 21:return console.warn("[Cart] validateDigiKeySessionForCheckout probe failed",e.t0),e.abrupt("return",!0);case 23:case"end":return e.stop()}}),e,null,[[0,17]])}))),[uo]),mo=(0,a.useCallback)((function(){var e,t=k||(null===(e=window.DigiKeyCart)||void 0===e?void 0:e.DkHostedCartItem),n=it(),r=Array.isArray(null==n?void 0:n.items)?n.items:[],o=F(B()).map((function(e){return{skuId:null==e?void 0:e.opnName,qty:Number((null==e?void 0:e.quantity)||0),lineType:U(e)}})),a=o.length>0?o:r,i=new Map;return a.forEach((function(e){var t=String((null==e?void 0:e.skuId)||(null==e?void 0:e.opnName)||"").trim();if(t){var n=Re(null==e?void 0:e.lineType,(null==e?void 0:e.isSample)||(null==e?void 0:e.IsSample)),r="".concat(t.toLowerCase(),"::").concat(n);i.set(r,{skuId:t,lineType:n,qty:Number((null==e?void 0:e.qty)||(null==e?void 0:e.quantity)||0)})}})),Array.from(i.values()).map((function(e){var n={manufacturerPartNumber:e.skuId,quantity:Math.max(1,parseInt(null==e?void 0:e.qty,10)||1),isSample:"SAMPLE"===e.lineType,customerReference:""};if(t){var r=new t;return Object.assign(r,n),r}return n}))}),[]),fo=function(){var e=D(x().mark((function e(){var t,n,r,o,a,i,l;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,_r();case 3:if("function"!=typeof(null===(t=b)||void 0===t?void 0:t.setPartnerOriginDomain)){e.next=6;break}return e.next=6,b.setPartnerOriginDomain();case 6:if("function"!=typeof(null===(n=b)||void 0===n?void 0:n.setLanguageId)){e.next=9;break}return e.next=9,b.setLanguageId(Pt);case 9:if(a=mo(),Se("checkout_digikey_payload_prepared",{itemCount:a.length,sampleCount:a.filter((function(e){return!0===(null==e?void 0:e.isSample)})).length,paidCount:a.filter((function(e){return!1===(null==e?void 0:e.isSample)})).length}),console.log("[Cart] checkout addItemsToCart request payload:",a.map((function(e){return{manufacturerPartNumber:null==e?void 0:e.manufacturerPartNumber,quantity:null==e?void 0:e.quantity,isSample:null==e?void 0:e.isSample,customerReference:null==e?void 0:e.customerReference}}))),a&&0!==a.length){e.next=14;break}return e.abrupt("return",!0);case 14:if("function"!=typeof(null===(r=b)||void 0===r?void 0:r.clearCart)){e.next=19;break}return e.next=17,b.clearCart();case 17:null!=(i=e.sent)&&i.successful||!0===i||console.warn("[Cart] clearCart returned non-successful result before checkout sync:",i);case 19:if("function"==typeof(null===(o=b)||void 0===o?void 0:o.addItemsToCart)){e.next=22;break}return console.warn("[Cart] syncCartForCheckout: DigiKey addItemsToCart is unavailable"),e.abrupt("return",!1);case 22:return e.next=24,b.addItemsToCart(a);case 24:if(!(null!=(l=e.sent)&&l.successful||!0===l)){e.next=28;break}return console.log("[Cart] Items synced to DigiKey cart via addItemsToCart (checkout)"),e.abrupt("return",!0);case 28:return console.warn("[Cart] addItemsToCart returned non-successful result during checkout sync:",l),e.abrupt("return",!1);case 32:return e.prev=32,e.t0=e.catch(0),console.warn("[Cart] Checkout cart sync failed:",e.t0),e.abrupt("return",!1);case 36:case"end":return e.stop()}}),e,null,[[0,32]])})));return function(){return e.apply(this,arguments)}}(),go=(0,a.useCallback)(function(){var t=D(x().mark((function t(n){var r,o,a,i,l,c,s,d,v,p,m,f,g,y,h,k,S,w,I,_,C=arguments;return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o=!0===(null==(r=C.length>1&&void 0!==C[1]?C[1]:{})?void 0:r.isResumeAfterDkLogin),!Gn.current){t.next=5;break}return Se("checkout_duplicate_click_ignored",{source:"checkout"}),t.abrupt("return");case 5:if(Gn.current=!0,bn(""),R("true"===(0,u.Ri)("IS_LOGGED_IN")&&(0,u.eJ)("userObject")),"true"===(0,u.Ri)("IS_LOGGED_IN")&&(0,u.eJ)("userObject")){t.next=11;break}return Kr(0,"rg_checkout-".concat(null==e?void 0:e.index)),t.abrupt("return");case 11:if(Xt(!0),t.prev=12,null!==(a=window)&&void 0!==a&&null!==(a=a.digikeyDetails)&&void 0!==a&&a.data){t.next=18;break}return console.error("[Cart] DigiKey configuration not found on window.digikeyDetails.data"),Se("checkout_config_missing",{hasDigikeyDetails:Boolean(null===(y=window)||void 0===y?void 0:y.digikeyDetails),hasDigikeyData:Boolean(null===(h=window)||void 0===h||null===(h=h.digikeyDetails)||void 0===h?void 0:h.data)}),bn((null==ie?void 0:ie.CheckoutUnavailable)||"Checkout configuration not available. Please refresh the page and try again."),t.abrupt("return");case 18:return t.next=20,po();case 20:if(t.sent){t.next=32;break}return console.log("[Cart] User not logged into DigiKey, redirecting to DigiKey login"),Se("checkout_digikey_login_required",{source:"checkout",reason:"missing_or_expired_session"}),be(),sessionStorage.setItem(ne,"true"),o&&Se("checkout_digikey_session_not_ready_after_resume",{source:"checkout",reason:"token_not_available_yet"}),t.next=29,co();case 29:return t.sent||(sessionStorage.removeItem(ne),bn((null==ie?void 0:ie.DigiKeyLoginRequired)||"Please log in to DigiKey to complete checkout.")),t.abrupt("return");case 32:return t.next=34,_r();case 34:return t.next=36,pr("checkout");case 36:return t.next=38,mr("checkout");case 38:return t.next=40,cr(!1);case 40:return t.next=42,fo();case 42:if(t.sent||Se("checkout_digikey_cart_sync_best_effort_continue",{localCartCount:B().length}),window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"begin_checkout",eventLabel:"Begin Checkout",eventSource:Zn,eventSourceLabel:lt}),!(k=(null===(i=window)||void 0===i||null===(i=i.digikeyDetails)||void 0===i||null===(i=i.data)||void 0===i?void 0:i.checkoutUrl)||(null===(l=window)||void 0===l||null===(l=l.digikeyDetails)||void 0===l||null===(l=l.data)||void 0===l?void 0:l.cartUrl))){t.next=52;break}return console.log("[Cart] Redirecting to DigiKey checkout URL:",k),be(),window.location.href=(0,u.IT)(k),t.abrupt("return");case 52:return S=null,t.prev=53,t.next=56,null===(w=b)||void 0===w||null===(I=w.getCart)||void 0===I?void 0:I.call(w);case 56:S=t.sent,vo(S)&&(console.log("[Cart] checkout fallback: DigiKey carts returned 400/no-open-cart"),S=null),t.next=64;break;case 60:t.prev=60,t.t0=t.catch(53),vo(t.t0)?console.log("[Cart] checkout fallback: DigiKey carts returned 400/no-open-cart (exception path)"):console.warn("[Cart] checkout fallback: DigiKey getCart probe failed",t.t0),S=null;case 64:if(!(_=(null===(c=S)||void 0===c||null===(c=c.data)||void 0===c?void 0:c.checkoutUrl)||(null===(s=S)||void 0===s||null===(s=s.data)||void 0===s?void 0:s.cartUrl)||(null===(d=S)||void 0===d||null===(d=d.data)||void 0===d?void 0:d.orderCheckoutUrl))){t.next=70;break}return console.log("[Cart] Redirecting to DigiKey SDK cart URL:",_),be(),window.location.href=(0,u.IT)(_),t.abrupt("return");case 70:if(!wr){t.next=78;break}return console.log("[Cart] Redirecting to checkout processing page:",wr),t.next=74,jr(
1);case 74:return sessionStorage.setItem("checkoutPending","true"),be(),window.location.href=(0,u.IT)(wr),t.abrupt("return");case 78:Se("checkout_unavailable",{hasGlobalCheckoutUrl:Boolean(null===(v=window)||void 0===v||null===(v=v.digikeyDetails)||void 0===v||null===(v=v.data)||void 0===v?void 0:v.checkoutUrl),hasGlobalCartUrl:Boolean(null===(p=window)||void 0===p||null===(p=p.digikeyDetails)||void 0===p||null===(p=p.data)||void 0===p?void 0:p.cartUrl),hasSdkCheckoutUrl:Boolean(null===(m=S)||void 0===m||null===(m=m.data)||void 0===m?void 0:m.checkoutUrl),hasSdkCartUrl:Boolean(null===(f=S)||void 0===f||null===(f=f.data)||void 0===f?void 0:f.cartUrl),hasProcessingPage:Boolean(wr),sdkCartPayload:JSON.stringify(S||{}),digikeyDetailsPayload:JSON.stringify((null===(g=window)||void 0===g||null===(g=g.digikeyDetails)||void 0===g?void 0:g.data)||{})}),bn((null==ie?void 0:ie.CheckoutUnavailable)||"Checkout is temporarily unavailable. Please try again."),t.next=87;break;case 82:t.prev=82,t.t1=t.catch(12),console.error("[Cart] Checkout failed",t.t1),Se("checkout_error",{errorMessage:null===t.t1||void 0===t.t1?void 0:t.t1.message,errorStack:null===t.t1||void 0===t.t1?void 0:t.t1.stack}),bn((null==ie?void 0:ie.CheckoutError)||"Unable to continue to checkout. Please try again.");case 87:return t.prev=87,Gn.current=!1,Yt(!1),Xt(!1),en(!1),t.finish(87);case 93:case"end":return t.stop()}}),t,null,[[12,82,87,93],[53,60]])})));return function(e){return t.apply(this,arguments)}}(),[Zn,lt,po,pr,ie,er,mr,null==e?void 0:e.index,$n,cr,jr]);Dn.current=go;var yo=(0,a.useMemo)((function(){return Gr()}),[Ue,hn,ie,qt,Ht,st,Hr]);(0,a.useEffect)((function(){!w&&_n&&(null==Ue?void 0:Ue.length)>0?requestAnimationFrame(Wn):zn("")}),[Ue,w,_n,Wn]);var ho=(0,a.useCallback)(function(){var e=D(x().mark((function e(t){return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Fr(t);case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),[]);return(0,a.useEffect)((function(){var e=function(e,t){var n=e.filter((function(e){return!0===e.IsSample})),r={};for(var o in n.forEach((function(e){r[e.opnName]=e.sampleLimit})),t){var a;if(Object.prototype.hasOwnProperty.call(r,o))if((null===(a=t[o])||void 0===a?void 0:a.true)>r[o])return!0}return!1}(Ue,st);Bt(e)}),[st,Ue]),(0,a.useEffect)((function(){var t=function(){var t=D(x().mark((function t(){var n,r,o,a,i,l,u,c,s,d;return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!Hn.current){t.next=2;break}return t.abrupt("return");case 2:if(r="cart-bootstrap-".concat(String(null!==(n=null==e?void 0:e.index)&&void 0!==n?n:"unknown")),!window[K]||window[K]===r){t.next=6;break}return Hn.current=!0,t.abrupt("return");case 6:if(we()){t.next=8;break}return t.abrupt("return");case 8:return Hn.current=!0,window[K]=r,t.prev=10,ot("page_refresh_bootstrap_started",{source:"page_refresh"}),o=it(),a=Number((null==o?void 0:o.version)||0),ot("page_refresh_getcartme_request_started",{source:"page_refresh",browserVersion:a}),i=Date.now(),t.next=18,mr("page_refresh");case 18:if(l=t.sent,u=Date.now()-i,ot("page_refresh_getcartme_request_completed",{source:"page_refresh",durationMs:u,fullCartLoadedByMeta:Boolean(null==l?void 0:l.fullCartLoaded)}),ot("page_refresh_version_decision",{source:"page_refresh",browserVersion:a,fullCartLoadedByMeta:Boolean(null==l?void 0:l.fullCartLoaded),versionMismatch:Boolean(null==l?void 0:l.versionMismatch)}),null==l||!l.versionMismatch||null!=l&&l.fullCartLoaded){t.next=30;break}return ot("page_refresh_forced_full_cart_started",{source:"page_refresh",browserVersion:a}),t.next=26,Qr("page_refresh_meta_mismatch");case 26:return d=t.sent,t.next=29,Jr(j(j({},d),{},{version:Number((null==d?void 0:d.version)||0),cartId:(null==d?void 0:d.cartId)||null,itemCount:Number((null==d?void 0:d.itemCount)||(null==d||null===(c=d.items)||void 0===c?void 0:c.length)||0)}),"page_refresh_meta_mismatch",{deferProductEnrichment:!0});case 29:ot("page_refresh_forced_full_cart_completed",{source:"page_refresh",itemCount:Number((null==d?void 0:d.itemCount)||(null==d||null===(s=d.items)||void 0===s?void 0:s.length)||0),version:Number((null==d?void 0:d.version)||0)});case 30:ot("page_refresh_bootstrap_completed",{source:"page_refresh",browserVersion:a,fullCartLoadedByMeta:Boolean(null==l?void 0:l.fullCartLoaded)}),t.next=36;break;case 33:t.prev=33,t.t0=t.catch(10),console.warn("[Cart] page refresh bootstrap failed",t.t0);case 36:case"end":return t.stop()}}),t,null,[[10,33]])}
1)));return function(){return t.apply(this,arguments)}}();return t(),function(){var t,n="cart-bootstrap-".concat(String(null!==(t=null==e?void 0:e.index)&&void 0!==t?t:"unknown"));window[K]===n&&delete window[K]}}),[Jr,mr,null==e?void 0:e.index,Qr]),a.createElement(a.Fragment,null,En&&a.createElement(E.default,{userEligible:!1,userGroupType:"",componentName:"IFX Free Mailer Modal Component",isEligibilityCheckLoginRequire:En,setUserEligible:function(){return xn(!1)},loginUrl:er+"?originURL=".concat(encodeURIComponent(window.location.pathname+window.location.hash),"&action=lg_os").concat($n)}),a.createElement("div",null,a.createElement("button",{className:"btn icon icon-cart cart-button",id:"cart-Icon-".concat(null==e?void 0:e.index),"data-action":"Add to cart",type:"button",title:"Cart","aria-controls":"offcanvasWithBothOptions-".concat(null==e?void 0:e.index),onClick:function(){ho()}},a.createElement("span",{className:"indicator"})),a.createElement("div",{className:"container"},a.createElement("div",{className:"row"},a.createElement("div",{className:"col-12 col-md-5 offcanvas offcanvas-end cartOffcanvas overflow-auto",tabIndex:"-1",id:"offcanvasWithBothOptions-".concat(e.index),"aria-labelledby":"offcanvas With Both Options Label"},a.createElement(a.Fragment,null,a.createElement("div",{className:"offcanvas-header"},a.createElement("div",{id:"offcanvasWithBothOptionsLabel",className:"desktop-view header-title heading-05"},y.cartHeadline," (",Ue.length,")"),a.createElement("div",{id:"offcanvasWithBothOptionsLabelmobile",className:"mobile-view header-title-mobile"},y.cartHeadline," (",Ue.length,")"),a.createElement("button",{type:"button",className:"icon icon-cross btn-close","aria-label":"Close",onClick:function(){var t,n=document.getElementById("offcanvasWithBothOptions-".concat(null==e?void 0:e.index));n&&null!==(t=window.bootstrap)&&void 0!==t&&t.Offcanvas&&window.bootstrap.Offcanvas.getOrCreateInstance(n,{focus:!1}).hide()}})),w||!_n||an?a.createElement("div",{className:"text-center mt-3"},a.createElement(_.A,null),cn?a.createElement("div",{className:"mt-2",style:{fontSize:"0.875rem",color:"#1d1d1d",fontWeight:500}},a.createElement("div",null,(null==ie?void 0:ie.DigiKeyLoginInitiated)||"DigiKey login initiatedâ¦"),a.createElement("div",{style:{fontSize:"0.8rem",color:"#555",marginTop:"4px"}},(null==ie?void 0:ie.DigiKeyLoginWait)||"You will be redirected to DigiKey to sign in. Please waitâ¦")):an?a.createElement("div",{className:"mt-2",style:{fontSize:"0.875rem",color:"#1d1d1d",fontWeight:500}},(null==ie?void 0:ie.RefreshingCartData)||"Fetching fresh cart data and merging updates. Please hold..."):nn?a.createElement("div",{className:"mt-2",style:{fontSize:"0.875rem",color:"#1d1d1d",fontWeight:500}},(null==ie?void 0:ie.UpdatingPriceOrStock)||"Checking stock and updating price, please wait..."):null):(null===(f=Object.keys(Ue))||void 0===f?void 0:f.length)>0?a.createElement(a.Fragment,null,a.createElement("div",{className:"offcanvas-body p-t-0 ".concat(Yn),ref:Qn,onScroll:Wn},(null==Ue?void 0:Ue.length)>0&&Ue.sort((function(e,t){return e.IsSample===t.IsSample?0:e.IsSample?-1:1})).map((function(e,t){return e.IsSample?a.createElement(I,{key:"".concat((null==e?void 0:e.opnName)||"unknown","-sample"),cartData:e,index:t,labels:ie,refQuantity:Tn,quantityArr:st,updateQuantity:eo,onChangeinputVal:to,onBlurInputVal:no,deleteCartItem:$r,updateCart:cr,productClickDatalayer:ro,cartDetails:Ue,prodDetailsViaOpns:qt,isAccountEligibleForSamples:Mt,productNotElligibleList:Ht}):a.createElement(s,{key:"".concat((null==e?void 0:e.opnName)||"unknown","-paid"),cartData:e,index:t,labels:ie,refQuantity:Tn,quantityArr:st,updateQuantity:eo,onChangeinputVal:to,onBlurInputVal:no,deleteCartItem:$r,productClickDatalayer:ro,stockDetailsObject:pt,formatPriceBreaksForTooltip:Ln,isPriceStockSyncing:nn})}))),a.createElement("div",{className:"offcanvas-footer"},a.createElement("div",{className:"divider"}),a.createElement("div",{className:"d-flex align-items-center justify-content-end cart-total-container"},a.createElement("div",null,a.createElement("span",{className:"cart-total"},(null==ie?void 0:ie.CartTotal)||"Cart Total ",":")),a.createElement("div",null,a.createElement("h5",{className:"m-a-0 cart
1-total-price"},wn,null==ce?void 0:ce.toFixed(2)))),St&&a.createElement("div",{className:"d-flex align-items-center justify-content-end shipping-details"},a.createElement("div",null,a.createElement("span",{className:"global-cart-text"}," ",ie.ShippingCalculated," "))),yo?a.createElement(d.A,{type:"error",message:yo}):a.createElement(a.Fragment,null,a.createElement("div",{className:"cart-legal cart-text"},a.createElement("p",{className:"content"},(null==y?void 0:y.legalDescriptionDigiKey)||ie.PurchaseRedirect)),a.createElement("div",{className:"legal-agreement"},a.createElement("div",{className:"legal-agreement-checkbox"},a.createElement("input",{type:"checkbox","aria-label":"input-field",className:"legal-checkbox",checked:yt,onChange:function(e){var t;ht(Boolean(null==e||null===(t=e.target)||void 0===t?void 0:t.checked))}})),a.createElement("div",{className:"legal-agreement-text",dangerouslySetInnerHTML:{__html:null==y?void 0:y.termsAndConditionsDigiKey}})),Dt&&_t&&a.createElement("div",{className:"marketing-opt-in"},a.createElement("div",{className:"marketing-opt-in-checkbox"},a.createElement("input",{type:"checkbox","aria-label":"input-field",className:"marketingoptin-checkbox",onChange:function(e){var t,n=Boolean(null==e||null===(t=e.target)||void 0===t?void 0:t.checked);xt(n),sessionStorage.setItem("marketingOptChecked",String(n))}})),a.createElement("div",{className:"marketing-opt-in-text",dangerouslySetInnerHTML:{__html:(null==y?void 0:y.marketOptText)||ie.OptIntoPromotions}}))),a.createElement("div",{className:"final-btn"},(fn>0||"SYNCING"===vn||"ERROR"===vn)&&a.createElement("div",{className:"d-flex align-items-center justify-content-center gap-2 mt-2",style:{fontSize:"0.875rem",color:"#1d1d1d",fontWeight:500}},a.createElement("span",{className:"spinner-border spinner-border-sm",role:"status",style:{color:"#0A8276",borderWidth:"0.15rem"}},a.createElement("span",{className:"visually-hidden"},"Loading...")),a.createElement("span",null,"SYNCING"===vn?(null==ie?void 0:ie.CartSyncInProgress)||"Syncing cart changes...":"ERROR"===vn?(null==ie?void 0:ie.CartSyncRetryPending)||"Sync delayed. Changes will retry automatically.":"".concat(fn," ").concat((null==ie?void 0:ie.CartSyncPendingOps)||"pending cart change(s)"))),!nn&&a.createElement("button",{disabled:Jt||Wt||!V||!yt||Ft||!(!Dt||!_t)&&!Et,"aria-label":"button",type:"button","data-action":null==ie?void 0:ie.Checkout,className:"".concat(!V||!yt||Ft||Dt&&_t&&!Et?"btn-disabled":""," checkoutButton w-100"),onClick:function(e){e.preventDefault(),go(e)}},q?(null==ie?void 0:ie.Checkout)||"Checkout":(null==ie?void 0:ie.login_to_checkout)||"Log in to Checkout"),(Jt||Wt||$t)&&a.createElement("div",{className:"d-flex align-items-center justify-content-center gap-2 mt-2",style:{fontSize:"0.8rem",color:"#4a4a4a",fontWeight:500}},a.createElement("span",{className:"spinner-border spinner-border-sm",role:"status",style:{color:"#0A8276",borderWidth:"0.15rem"}},a.createElement("span",{className:"visually-hidden"},"Loading...")),a.createElement("span",null,$t?(null==ie?void 0:ie.RetryingCartSync)||"Retrying cart syncâ¦":Wt?(null==ie?void 0:ie.ConnectingToDigiKey)||"Connecting to DigiKey, please waitâ¦":(null==ie?void 0:ie.RedirectingCheckout)||"Redirecting to checkout, please waitâ¦")),nn&&!an&&!Jt&&!Wt&&!$t&&a.createElement("div",{className:"d-flex align-items-center justify-content-center gap-2 mt-2",style:{fontSize:"0.875rem",color:"#1d1d1d",fontWeight:500}},a.createElement("span",{className:"spinner-border spinner-border-sm",role:"status",style:{color:"#0A8276",borderWidth:"0.15rem"}},a.createElement("span",{className:"visually-hidden"},"Loading...")),a.createElement("span",null,(null==ie?void 0:ie.UpdatingPriceOrStock)||"Checking live stock and price, please waitâ¦"))))):a.createElement(a.Fragment,null,a.createElement("div",{className:"p-l-1 p-r-1 p-t-1"}," ",null==e?void 0:e.emptycartmsg," ")," ")))))))}},2323:function(e,t,n){n.d(t,{CI:function(){return o},Sg:function(){return r},W_:function(){return a}});var r=function(e){1!==e.key.length||/\d/.test(e.key)||e.ctrlKey||e.metaKey||e.preventDefault()},o=function(e){return""!==e&&parseInt(e,10)<=0},a=function(e){return""===e||parseInt(e,10)<=0}},7007:function(e){var t,n="object"==typeof Reflect?Reflect:null,r=n&&"function"==typeof n.apply?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};t=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var o=Number.isNaN||function(e){return e!=e};function a(){a.init.call(this)}e.exports=a,e.exports.once=function(e,t){return new Promise((function(n,r){function o(n){e.removeListener(t,a),r(n)}function a(){"function"==typeof e.removeListener&&e.removeListener("error",o),n([].slice.call(arguments))}f(e,t,a,{once:!0}),"error"!==t&&function(e,t,n){"function"==typeof e.on&&f(e,"error",t,n)}(e,o,{once:!0})}))},a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var i=10;function l(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function u(e){return void 0===e._maxListeners?a.defaultMaxListeners:e._maxListeners}function c(e,t,n,r){var o,a,i,c;if(l(n),void 0===(a=e._events)?(a=e._events=Object.create(null),e._eventsCount=0):(void 0!==a.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),a=e._events),i=a[t]),void 0===i)i=a[t]=n,++e._eventsCount;else if("function"==typeof i?i=a[t]=r?[n,i]:[i,n]:r?i.unshift(n):i.push(n),(o=u(e))>0&&i.length>o&&!i.warned){i.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+i.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=e,s.type=t,s.count=i.length,c=s,console&&console.warn&&console.warn(c)}return e}function s(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},o=s.bind(r);return o.listener=n,r.wrapFn=o,o}function v(e,t,n){var r=e._events;if(void 0===r)return[];var o=r[t];return void 0===o?[]:"function"==typeof o?n?[o.listener||o]:[o]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(o):m(o,o.length)}function p(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function m(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function f(e,t,n,r){if("function"==typeof e.on)r.once?e.once(t,n):e.on(t,n);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function o(a){r.once&&e.removeEventListener(t,o),n(a)}))}}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return i},set:function(e){if("number"!=typeof e||e<0||o(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");i=e}}),a.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||o(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},a.prototype.getMaxListeners=function(){return u(this)},a.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var o="error"===e,a=this._events;if(void 0!==a)o=o&&void 0===a.error;else if(!o)return!1;if(o){var i;if(t.length>0&&(i=t[0]),i instanceof Error)throw i;var l=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw l.context=i,l}var u=a[e];if(void 0===u)return!1;if("function"==typeof u)r(u,this,t);else{var c=u.length,s=m(u,c);for(n=0;n<c;++n)r(s[n],this,t)}return!0},a.prototype.addListener=function(e,t){return c(this,e,t,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(e,t){return c(this,e,t,!0)},a.prototype.once=function(e,t){return l(t),this.on(e,d(this,e,t)),this},a.prototype.prependOnceListener=function(e,t){return l(t),this.prependListener(e,d(this,e,t)),this},a.prototype.removeListener=function(e,t){var n,r,o,a,i;if(l(t),void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit
vendor: 1,396 bytes, line 1
1("removeListener",e,n.listener||t));else if("function"!=typeof n){for(o=-1,a=n.length-1;a>=0;a--)if(n[a]===t||n[a].listener===t){i=n[a].listener,o=a;break}if(o<0)return this;0===o?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,o),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,i||t)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var o,a=Object.keys(n);for(r=0;r<a.length;++r)"removeListener"!==(o=a[r])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},a.prototype.listeners=function(e){return v(this,e,!0)},a.prototype.rawListeners=function(e){return v(this,e,!1)},a.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):p.call(e,t)},a.prototype.listenerCount=p,a.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}}}]);
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.