PageSourceSearch

https://www.bitiba.it/media/cart-assets/cart-service-js/js/CSJ-REL-3.5.0/CartService.js

js bitiba.it collected 2026-10-08 01:06:15 UTC 10,167 bytes, 1 lines download raw bytes

1!function(e){var t;try{t=window}catch(e){t=global}var n=t._async_define_queue="_async_define_queue"in t?t._async_define_queue:[],r=t._async_define_cached_dependencies="_async_define_cached_dependencies"in t?t._async_define_cached_dependencies:{};function o(){for(var e,t=!0;t;)for(t=!1,e=0;e<n.length;)i(n[e])?(n[e].name&&(t=!0),n.splice(e,1)):e++}function i(e){if(e.name in r)return!0;var n,o=function(e){var t,n,o,i,c=e.length,a=[];for(t=0;t<c;t++){if(o=(n=e[t].split("|"))[0],i=n[1],!(o in r))return;a.push(i?r[o][i]:r[o])}return a}(e.depNames);if(o){try{n=e.func.apply(t,o),e.name&&(r[e.name]=n)}catch(t){console.log('Unable to resolve dependency "'+e.name+'". Error: '+t.message),setTimeout((function(){throw t}),0)}return!0}return!1}function c(e){return"function"==typeof e?e:function(){return e}}(function(e){e(["events-bus","sentry_6"],(function(e,t){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="https://cdn.public.zooplus.net/media/cart-assets/cart-service-js/js/CSJ-REL-3.5.0",n(n.s=4)}([function(t,n){t.exports=e},function(e,t,n){"use strict";(function(e){n.d(t,"a",(function(){return i})),n.d(t,"b",(function(){return c}));var r,o=n(2),i=function(){r=new o.Hub(new o.BrowserClient({dsn:"https://[email protected]/5182810",environment:e.env.SENTRY_ENV}))},c=function(){return r}}).call(this,n(3))},function(e,n){e.exports=t},function(e,t){var n,r,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function c(){throw new Error("clearTimeout has not been defined")}function a(e){if(n===setTimeout)return setTimeout(e,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(e){n=i}try{r="function"==typeof clearTimeout?clearTimeout:c}catch(e){r=c}}();var u,s=[],f=!1,l=-1;function p(){f&&u&&(f=!1,u.length?s=u.concat(s):l=-1,s.length&&d())}function d(){if(!f){var e=a(p);f=!0;for(var t=s.length;t;){for(u=s,s=[];++l<t;)u&&u[l].run();l=-1,t=s.length}u=null,f=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===c||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function v(e,t){this.fun=e,this.array=t}function h(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];s.push(new v(e,t)),1!==s.length||f||a(d)},v.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=h,o.addListener=h,o.once=h,o.off=h,o.removeListener=h,o.removeAllListeners=h,o.emit=h,o.prependListener=h,o.prependOnceListener=h,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t,n){"use strict";n.r(t);var r=n(0),o=n.n(r);function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var c="/checkout/api/cart-api/v1",a=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,n,r;return t=e,r=[{key:"retrieveCartId",value:function(){var t=e.getHttpConfig("GET");return t.headers.append("Content-Type","application/json;charset=utf-8"),fetch("".concat("/checkout/api/shop-api/v1","/sid"),t).then(e.handleTextResponse)}},{key:"add",value:function(t,n,r,o){if(!t)return Promise.reject("Unknown Cart id");var i={articleId:n,quantity:r,voucherApplied:o},a=e.getHttpConfig("PATCH");return a.headers.append("Content-Type","application/json;charset=utf-8"),a.body=JSON.stringify(i),fetch("".concat(c,"/cart/").concat(t,"/set-article-quantity-command"),a).then(e.handleJsonResponse)}},{key:"get",value:function(t){if(!t)return Promise.reject("Unknown Cart id");var n=e.getHttpConfig("GET");return fetch("".concat(c,"/cart/").concat(t),n).then(e.handleJsonResponse)}},{key:"selectSavingsPlanArticle",value:function(t,n){if(!t)return Promise.reject("Unknown Cart id");var r=e.getHttpConfig("PATCH");return r.headers.append("Content-Type","application/json;charset=utf-8"),fetch("".concat(c,"/cart/").concat(t,"/add-savingsplan-article/").concat(n),r).then(e.handleJsonResponse)}},{key:"unselectSavingsPlanArticle",value:function(t){if(!t)return Promise.reject("Unknown Cart id");var n=e.getHttpConfig("DELETE");return n.headers.append("Content-Type","application/json;charset=utf-8"),fetch("".concat(c,"/cart/").concat(t,"/delete-savingsplan-article"),n).then(e.handleJsonResponse)}},{key:"handleJsonResponse",value:function(e){var t=e.json();return 200===e.status?t.then((function(e){return e?Promise.resolve(e):Promise.reject({code:"INCORRECT_JSON_BODY"})}
1)):t.then(Promise.reject.bind(Promise))}},{key:"handleTextResponse",value:function(e){var t=e.text();return 200===e.status?t:t.then(Promise.reject.bind(Promise))}},{key:"getHttpConfig",value:function(e){var t=new Headers;return t.append("Accept","application/json"),t.append("X-Caller","cart-service-js"),{method:e,headers:t,credentials:"same-origin",cache:"no-store",mode:"cors"}}}],(n=null)&&i(t.prototype,n),r&&i(t,r),e}(),u="GET-CART-v1",s="GET-CART-SUCCESS-v1",f="GET-CART-FAILURE-v1",l="GET-CART-ID-v1",p="GET-CART-ID-SUCCESS-v1",d="GET-CART-ID-FAILURE-v1",v="ADD-TO-CART-v1",h="ADD-TO-CART-SUCCESS-v1",y="ADD-TO-CART-FAILURE-v1",b="UPDATE-ADOBE-v1",m="ADDED",g="STANDARD",T="SAVINGS_PLAN",C=n(1);function A(e){return(A="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})(e)}function w(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,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function O(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var E=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,n,r;return t=e,r=[{key:"init",value:function(){var t=function(){o.a.post(u,{version:1,cartId:e.Id})};o.a.on(u,(function(t,n){return a.get(e.Id).then((function(t){var r={response:t,request:n};e.Cart=t,o.a.post(s,r);var i=new CustomEvent(s,{detail:r});return document.dispatchEvent(i),t})).catch((function(e){var t={error:e,request:n};return o.a.post(f,t),e}))})),o.a.on(v,(function(t,n){var r=n.articleId,i=n.quantity,c=n.status,u=n.articleType,s=void 0===u?g:u,f=n.voucherApplied,l=void 0!==f&&f,p=e.findArticle(r),d=p?p.quantity:0,v=p&&p.quantity===i;return(s===T?function(){return 0===i?a.unselectSavingsPlanArticle(e.Id):a.selectSavingsPlanArticle(e.Id,r)}:function(){return a.add(e.Id,r,i,l)})().then((function(t){var a,u,s={response:t,request:n};return e.Cart=t,p||(p=e.findArticle(r)),!v&&p&&e.generateAdobeEvent(p,t.cartId,m===c?i-d:0,null===(a=p)||void 0===a||null===(u=a.articleBasedVoucher)||void 0===u?void 0:u.isPersonalized),o.a.post(h,s),t})).catch((function(e){var t,r={error:e,request:n};return Object(C.b)().captureMessage("Add to cart failure: ".concat(JSON.stringify(r,(t=new WeakSet,function(e,n){if("object"===A(n)&&null!==n){if(t.has(n))return;t.add(n)}return n})))),o.a.post(y,r),e}))})),o.a.on(l,(function(n,r){return a.retrieveCartId().then((function(n){var i={response:n,request:r},c=null===e.Id;e.Id=n,o.a.post(p,i);var a=new CustomEvent(p,{detail:i});return document.dispatchEvent(a),c&&t(),n})).catch((function(e){var t={error:e,request:r};return o.a.post(d,t),e}))})),e.isCheckout()||o.a.post(l,{version:1}),e.Id&&t()}},{key:"generateAdobeEvent",value:function(e,t,n,r){var i=e.price,c=e.shopId,a=e.psId,u=e.bestPriceArticle;o.a.post(b,{price:i,quantity:n,shopId:c,psId:a,bestPriceArticle:u,cartId:t,isPersonalized:r})}},{key:"getCurrentCart",value:function(){return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?w(Object(n),!0).forEach((function(t){j(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):w(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},e.Cart)}},{key:"findArticle",value:function(t){return(e.getCurrentCart().articles||[]).find((function(e){return e.id===t}))}},{key:"isCheckout",value:function(){return location.href.indexOf("/checkout/")>-1}}],(n=null)&&O(t.prototype,n),r&&O(t,r),e}();E.Cart={},E.Id=null;var P=E;Object(C.a)(),P.init()}])}))}).call(t,(function(){var e={name:"string"==typeof arguments[0]?arguments[0]:void 0,depNames:Array.isArray(arguments[0])?arguments[0]:Array.isArray(arguments[1])?arguments[1]:[],func:c(arguments[arguments.length-1])};i(e)?e.name&&o():n.push(e)}))}();

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.