PageSourceSearch

https://readings.com.pk/_next/static/chunks/3180.2fb62ac956751ec3.js

js readings.com.pk collected 2026-10-02 13:41:09 UTC 18,919 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3180],{79276:function(t,e,r){r.r(e);var n=r(57437),i=r(2265),s=r(97048),a=r(30166),o=r(30095),c=r(7557),u=r(243),l=r(47949);let d=(0,a.default)(()=>Promise.all([r.e(9939),r.e(4122)]).then(r.bind(r,54524)),{loadableGenerated:{webpack:()=>[54524]},ssr:!1}),h=(0,a.default)(()=>Promise.all([r.e(9939),r.e(5436)]).then(r.bind(r,35436)),{loadableGenerated:{webpack:()=>[35436]},ssr:!1}),m=t=>{let{wrapperClasses:e="",typeLabel:r}=t;return(0,n.jsx)("section",{className:"listing-title ".concat(e),children:(0,n.jsx)("div",{className:"container",children:(0,n.jsx)("div",{className:"row",children:(0,n.jsx)("div",{className:"col-md-12 ".concat(s.tq?"p-3":""),children:(0,n.jsx)("div",{className:"container",children:(0,n.jsxs)("div",{className:"row d-flex align-items-center",children:[(0,n.jsx)("div",{className:"p-0 ".concat(s.tq?"col-md-12":"col-md-8"),children:(0,n.jsx)("h2",{className:s.tq?"":"pb-4 pt-4",children:r})}),!s.tq&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"col-md-2 text-center",children:(0,n.jsx)("strong",{children:"Can't Buy"===r?"":"Qty"})}),(0,n.jsx)("div",{className:"col-md-2 text-center",children:(0,n.jsx)("strong",{children:"Can't Buy"===r?"":"Amount"})})]})]})})})})})})};e.default=t=>{let{typeLabel:e,books:r,on_page:a}=t,[p,f]=(0,i.useState)(r),{setLoading:g,setError:v,updateBookQuantity:y,revertBookQuantity:b,clearLoadingAndErrors:_}=(0,l.x)();(0,i.useEffect)(()=>{f(r),_()},[r,_]);let{mutate:x}=(0,u.tl)(),w=(t,e)=>{if(e<1)return;let r=p.find(e=>e.cart_item_id===t);r&&(f(r=>r.map(r=>r.cart_item_id===t?{...r,cart_qty:e}:r)),y(t,e),g(t,!0),v(t,null),x({cartItemId:t,data:{quantity:e}},{onSuccess:()=>{g(t,!1)},onError:e=>{g(t,!1),v(t,"Failed to update quantity"),f(e=>e.map(e=>e.cart_item_id===t?{...e,cart_qty:r.cart_qty}:e)),b(t,r.cart_qty)}}))};if("Can't Buy"===e&&p.length>0)return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(m,{wrapperClasses:"unavailable",typeLabel:e}),(0,n.jsx)("section",{className:"products-grid-wrapper products-list demand-cart only-cart unavailable mb-0",children:(0,n.jsx)("div",{className:"container",children:(0,n.jsx)("div",{className:"row",children:p.map(t=>{let e=(0,c.p)(t.QUANTITY,t.BOOK_STATUS,t.OTHER_SOURCE_NAME,t.PUBLISHER,t.ARRIVAL_DATE);(0,o.B)(Number(t.PAK_PRICE),Number(t.Discount));let r=t.cart_item_id;return(0,n.jsx)("div",{className:"col-md-12 ".concat(e),id:"row_".concat(r),children:(0,n.jsx)("div",{className:"row d-flex align-items-center",children:(0,n.jsx)("div",{className:s.tq?"col-md-12":"col-md-8",children:s.tq?(0,n.jsx)(h,{book:t,cant_buy:!0,cart_item_id:r,on_page:a}):(0,n.jsx)(d,{book:t,cant_buy:!0,cart_item_id:r,on_page:a})})})},r)})})})})]});if(e&&p.length>0){let t="dummy book status",r=0;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(m,{typeLabel:e}),(0,n.jsx)("section",{className:"products-grid-wrapper products-list demand-cart only-cart mb-0 ".concat(s.tq?" mb-0":""),children:(0,n.jsx)("div",{className:"container",children:(0,n.jsxs)("div",{className:"row",children:[p.map(t=>{let e=(0,c.p)(t.QUANTITY,t.BOOK_STATUS,t.OTHER_SOURCE_NAME,t.PUBLISHER,t.ARRIVAL_DATE),i=(0,o.B)(Number(t.PAK_PRICE),Number(t.Discount));r+=i*Number(t.cart_qty);let u=t.cart_item_id;return(0,n.jsx)("div",{className:"col-md-12 ".concat(e),id:"row_".concat(u),children:(0,n.jsxs)("div",{className:"row d-flex align-items-center",children:[(0,n.jsx)("div",{className:s.tq?"col-md-12":"col-md-8",children:s.tq?(0,n.jsx)(h,{book:t,cant_buy:!0,cart_item_id:u,on_page:a}):(0,n.jsx)(d,{book:t,cant_buy:!0,cart_item_id:u,on_page:a})}),!s.tq&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"col-md-2",children:(0,n.jsxs)("div",{className:"input-group justify-content-center align-items-center",children:[(0,n.jsx)("div",{className:"input-group-prepend",children:(0,n.jsx)("button",{className:"btn btn-sm minus-btn qtybutton dec","data-id":u,"data-book-status":e,onClick:()=>w(u,Number(t.cart_qty)-1)})}),(0,n.jsx)("input",{type:"number",className:"form-control form-control-sm qty_input quantity_".concat(u),value:t.cart_qty,onChange:t=>
1w(u,Number(t.target.value)),min:"1","data-price":i,"data-id":u,"data-book-status":e,"data-pre-qty":t.cart_qty}),(0,n.jsx)("div",{className:"input-group-prepend",children:(0,n.jsx)("button",{className:"btn btn-sm plus-btn qtybutton inc","data-id":u,"data-book-status":e,onClick:()=>w(u,Number(t.cart_qty)+1),children:"+"})})]})}),(0,n.jsx)("div",{className:"col-md-2 text-center",children:(0,n.jsx)("span",{className:"unit-price total_price_".concat(e),id:"total_price_".concat(e,"_").concat(u),children:i*Number(t.cart_qty)})})]})]})},u)}),(0,n.jsx)("div",{className:"col-md-12 bg-light subtotal_".concat(t),children:(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("div",{className:"offset-md-9 border-left-1"}),(0,n.jsx)("div",{className:"col-md-3 border-0 p-0",children:(0,n.jsxs)("div",{className:"\n                      d-flex h-100 align-items-center fixed-r-margin\n                      ".concat(s.tq?"justify-content-end p-3 pl-4":"justify-content-around mr-5 p-4","\n                      "),children:[(0,n.jsx)("div",{className:"sub-total-heading",children:(0,n.jsx)("strong",{children:"Subtotal"})}),(0,n.jsx)("div",{className:"sub-total-amount cartSubtotal",id:"cartSubtotal_".concat(t),children:(0,n.jsx)("strong",{children:r})})]})})]})})]})})})]})}return null}},243:function(t,e,r){r.d(e,{GR:function(){return b},Bc:function(){return x},T:function(){return _},kN:function(){return j},ss:function(){return N},tl:function(){return y},Ge:function(){return w}});var n=r(29827),i=r(21770),s=r(16593),a=r(8308),o=r(49499),c=r(92110);let u=async t=>{let{cartItemId:e,data:r}=t,n=await (0,o._)("/api/cart/update-cart-item/".concat(e),{method:"PUT",data:r});if(n.error)throw Error("Failed to update cart item");return n},l=async t=>{let{cartItemId:e}=t,r=await (0,o._)("/api/cart/delete-cart-item/".concat(e),{method:"DELETE"});if(r.error)throw Error("Failed to delete cart item");return r},d=async t=>{let{cartItemId:e,cartType:r}=t,n=await (0,o._)("/api/cart/move-cart-item/".concat(e,"/").concat(r),{method:"PUT"});if(n.error)throw Error("Failed to move cart item");return n},h=async()=>(0,o._)("/api/cart/order-cart?web=true"),m=async t=>{let{cartType:e,data:r}=t,n=await (0,o._)("/api/cart/checkout/".concat(e),{method:"PUT",data:r});if(n.error)throw Error("Failed to update checkout");return n},p=async t=>{let{data:e}=t,r=(0,c.JI)(),n={"Content-Type":"application/json"};r&&(r.utm_source&&(n["X-UTM-Source"]=r.utm_source),r.utm_medium&&(n["X-UTM-Medium"]=r.utm_medium),r.utm_campaign&&(n["X-UTM-Campaign"]=r.utm_campaign),r.utm_term&&(n["X-UTM-Term"]=r.utm_term),r.utm_content&&(n["X-UTM-Content"]=r.utm_content));let i=await (0,o._)("/api/cart/place-order",{method:"POST",data:e,headers:n});if(i.error)throw Error("string"==typeof i.error?i.error:"Failed to place order");return(0,c.j0)(),i},f=async t=>{let e=await (0,o._)("/api/cart/order-confirmation?orderId=".concat(t),{method:"POST"});if(e.error)throw Error(e.error);return e};var g=r(47949),v=r(47887);let y=()=>{let t=(0,n.NL)();return(0,i.D)({mutationFn:u,onSuccess:()=>{t.invalidateQueries({queryKey:["get-order-cart"]})},onError:t=>{var e;(0,a.p)("error",{message:null!==(e=t.message)&&void 0!==e?e:"Error",position:"topRight"})}})},b=()=>{let t=(0,n.NL)();return(0,i.D)({mutationFn:l,onSuccess:e=>{var r;(0,a.p)("success",{message:null!==(r=null==e?void 0:e.message)&&void 0!==r?r:"Deleted",position:"topRight"}),t.invalidateQueries({queryKey:["get-order-cart"]}),t.invalidateQueries({queryKey:["get-cart-total"]}),t.invalidateQueries({queryKey:["wishlist"]})},onError:t=>{var e;(0,a.p)("error",{message:null!==(e=t.message)&&void 0!==e?e:"Error",position:"topRight"})}})},_=()=>{let t=(0,n.NL)();return(0,i.D)({mutationFn:d,onSuccess:e=>{var r;(0,a.p)("success",{message:null!==(r=null==e?void 0:e.message)&&void 0!==r?r:"Book Moved",position:"topRight"}),t.invalidateQueries({queryKey:["get-order-cart"]}),t.invalidateQueries({queryKey:["wishlist"]}),t.invalidateQueries({queryKey:["get-cart-total"]})},onError:t=>{var e;(0,a.p)("error",{message:null!==(e=t.message)&&void 0!==e?e:"Error",position:"topRight"})}})},x=()=>(0,s.a)({queryKey:["get-order-cart"],queryFn:h,staleTime:0}),w=()=>{let t=(0,n.NL)();return(0,i.D)({mutationFn:m,onSuccess:()=>{t.invalidateQueries({queryKey:["get-order-cart"]});let e=g.x.getState().getTotalPrice();(0,v.z)({event:"initiate_checkout",value:e,currency:"PKR"})},onError:t=>{var e;(0,a.p)("error",{message:null!==(e=t.message)&&void 0!==e?e:"Error",position:"topRight"})}})},N=()=>{let t=(0,n.NL)();return(0,i.D)({mutationFn:p,onSuccess:e=>{t.invalidateQueries({queryKey:["get-order-cart"]}),t.invalidateQueries({queryKey:["get-cart-total"]})},onError:t=>{var e;(0,a.p)("error",{message:null!==(e=t.message)&&void 0!==e?e:"Error",position:"topRight"})}})},j=()=>{let t=(0,n.NL)();return(0,i.D)({mutationFn:f,onSuccess:()=>{t.invalidateQueries({queryKey:["get-order-cart"]}),t.invalidateQueries({queryKey:["get-cart-total"]})},onError:t=>{var e;(0,a.p)("error",{message:null!==(e=t.message)&&void 0!==e?e:"Error",position:"topRight"})}})}},47887:function(t,e,r){function n(t){var e;window.dataLayer=null!==(e=window.dataLayer)&&void 0!==e?e:[],window.dataLayer.push(t)}function i(t){let e=Number(t.PAK_PRICE)||0;return e-Math.round(e*(Number(t.Discount)||0)/100)}r.d(e,{Z:function(){return i},z:function(){return n}})},7557:function(t,e,r){r.d(e,{p:function(){return i}});var n=r(76698);let i=function(t,e,r,i){let s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"";i||(i=""),r||(r="");let a=Number(t);if(null===t||null===e)return"available";if("C"===e){if(!s||""===s.trim()||"null"===s)return"pre_order";{let t=new Date(s);return(0,n.J)(t)&&!isNaN(t.getTime())&&"".concat(t.getDate(),"-").concat(t.getMonth()+1,"-").concat(t.getFullYear()),"pre_order"}}return a<=0&&"O"===e?"on_demand":i.length>1&&a<=0?"out_of_stock":a>0?"available":r.length>1&&a<=0?"out_of_stock":"out_of_stock"}},92110:function(t,e,r){r.d(e,{JI:function(){return c},QY:function(){return a},a5:function(){return o},j0:function(){return u}});var n=r(64131);let i="utm_params",s="utm_expiry";function a(){try{let t={},e=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],r=new URLSearchParams(window.location.search);
1if(e.forEach(e=>{let n=r.get(e);n&&n.trim()&&(t[e]=n.trim())}),0===Object.keys(t).length&&window.location.hash){let r=new URLSearchParams(window.location.hash.substring(1));e.forEach(e=>{let n=r.get(e);n&&n.trim()&&(t[e]=n.trim())})}return Object.keys(t).length>0?t:null}catch(t){return console.error("Error extracting UTM from URL:",t),null}}function o(t){try{let e=new Date;e.setDate(e.getDate()+30);try{n.Z.set(i,JSON.stringify(t),{expires:30,secure:"https:"===window.location.protocol,sameSite:"lax",path:"/"}),n.Z.set(s,e.toISOString(),{expires:30,secure:"https:"===window.location.protocol,sameSite:"lax",path:"/"});return}catch(r){"undefined"!=typeof Storage&&(sessionStorage.setItem(i,JSON.stringify(t)),sessionStorage.setItem(s,e.toISOString()))}}catch(t){console.error("UTM storage error:",t)}}function c(){try{let t=n.Z.get(i),e=n.Z.get(s);if(t&&e||"undefined"==typeof Storage||(t=sessionStorage.getItem(i)||void 0,e=sessionStorage.getItem(s)||void 0),!t||!e)return null;if(new Date>new Date(e))return u(),null;return JSON.parse(t)}catch(t){return console.error("Error reading UTM parameters:",t),null}}function u(){try{console.log("\uD83D\uDDD1️ Clearing UTM parameters from all storage"),n.Z.remove(i,{path:"/"}),n.Z.remove(s,{path:"/"}),"undefined"!=typeof Storage&&(sessionStorage.removeItem(i),sessionStorage.removeItem(s)),console.log("✅ UTM parameters cleared")}catch(t){console.error("UTM clear error:",t)}}},2894:function(t,e,r){r.d(e,{R:function(){return o},m:function(){return a}});var n=r(18238),i=r(7989),s=r(11255),a=class extends i.F{#t;#e;#r;constructor(t){super(),this.mutationId=t.mutationId,this.#e=t.mutationCache,this.#t=[],this.state=t.state||o(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){this.#t.includes(t)||(this.#t.push(t),this.clearGcTimeout(),this.#e.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#t=this.#t.filter(e=>e!==t),this.scheduleGc(),this.#e.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#t.length||("pending"===this.state.status?this.scheduleGc():this.#e.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(t){this.#r=(0,s.Mz)({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(Error("No mutationFn found")),onFail:(t,e)=>{this.#n({type:"failed",failureCount:t,error:e})},onPause:()=>{this.#n({type:"pause"})},onContinue:()=>{this.#n({type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#e.canRun(this)});let e="pending"===this.state.status,r=!this.#r.canStart();try{if(!e){this.#n({type:"pending",variables:t,isPaused:r}),await this.#e.config.onMutate?.(t,this);let e=await this.options.onMutate?.(t);e!==this.state.context&&this.#n({type:"pending",context:e,variables:t,isPaused:r})}let n=await this.#r.start();return await this.#e.config.onSuccess?.(n,t,this.state.context,this),await this.options.onSuccess?.(n,t,this.state.context),await this.#e.config.onSettled?.(n,null,this.state.variables,this.state.context,this),await this.options.onSettled?.(n,null,t,this.state.context),this.#n({type:"success",data:n}),n}catch(e){try{throw await this.#e.config.onError?.(e,t,this.state.context,this),await this.options.onError?.(e,t,this.state.context),await this.#e.config.onSettled?.(void 0,e,this.state.variables,this.state.context,this),await this.options.onSettled?.(void 0,e,t,this.state.context),e}finally{this.#n({type:"error",error:e})}}finally{this.#e.runNext(this)}}#n(t){this.state=(e=>{switch(t.type){case"failed":return{...e,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...e,isPaused:!0};case"continue":return{...e,isPaused:!1};case"pending":return{...e,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...e,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...e,data:void 0,error:t.error,failureCount:e.failureCount+1,failureReason:t.error,isPau
1sed:!1,status:"error"}}})(this.state),n.V.batch(()=>{this.#t.forEach(e=>{e.onMutationUpdate(t)}),this.#e.notify({mutation:this,type:"updated",action:t})})}};function o(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}},21770:function(t,e,r){r.d(e,{D:function(){return d}});var n=r(2265),i=r(2894),s=r(18238),a=r(24112),o=r(45345),c=class extends a.l{#i;#s=void 0;#a;#o;constructor(t,e){super(),this.#i=t,this.setOptions(e),this.bindMethods(),this.#c()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){let e=this.options;this.options=this.#i.defaultMutationOptions(t),(0,o.VS)(this.options,e)||this.#i.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#a,observer:this}),e?.mutationKey&&this.options.mutationKey&&(0,o.Ym)(e.mutationKey)!==(0,o.Ym)(this.options.mutationKey)?this.reset():this.#a?.state.status==="pending"&&this.#a.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#a?.removeObserver(this)}onMutationUpdate(t){this.#c(),this.#u(t)}getCurrentResult(){return this.#s}reset(){this.#a?.removeObserver(this),this.#a=void 0,this.#c(),this.#u()}mutate(t,e){return this.#o=e,this.#a?.removeObserver(this),this.#a=this.#i.getMutationCache().build(this.#i,this.options),this.#a.addObserver(this),this.#a.execute(t)}#c(){let t=this.#a?.state??(0,i.R)();this.#s={...t,isPending:"pending"===t.status,isSuccess:"success"===t.status,isError:"error"===t.status,isIdle:"idle"===t.status,mutate:this.mutate,reset:this.reset}}#u(t){s.V.batch(()=>{if(this.#o&&this.hasListeners()){let e=this.#s.variables,r=this.#s.context;t?.type==="success"?(this.#o.onSuccess?.(t.data,e,r),this.#o.onSettled?.(t.data,null,e,r)):t?.type==="error"&&(this.#o.onError?.(t.error,e,r),this.#o.onSettled?.(void 0,t.error,e,r))}this.listeners.forEach(t=>{t(this.#s)})})}},u=r(29827),l=r(51172);function d(t,e){let r=(0,u.NL)(e),[i]=n.useState(()=>new c(r,t));n.useEffect(()=>{i.setOptions(t)},[i,t]);let a=n.useSyncExternalStore(n.useCallback(t=>i.subscribe(s.V.batchCalls(t)),[i]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),o=n.useCallback((t,e)=>{i.mutate(t,e).catch(l.Z)},[i]);if(a.error&&(0,l.L)(i.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:o,mutateAsync:a.mutate}}},76698:function(t,e,r){r.d(e,{J:function(){return i}});var n=r(99649);function i(t){return(t instanceof Date||"object"==typeof t&&"[object Date]"===Object.prototype.toString.call(t)||"number"==typeof t)&&!isNaN(Number((0,n.Q)(t)))}},99649:function(t,e,r){r.d(e,{Q:function(){return n}});function n(t){let e=Object.prototype.toString.call(t);return t instanceof Date||"object"==typeof t&&"[object Date]"===e?new t.constructor(+t):new Date("number"==typeof t||"[object Number]"===e||"string"==typeof t||"[object String]"===e?t:NaN)}},64131:function(t,e,r){function n(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)t[n]=r[n]}return t}r.d(e,{Z:function(){return i}});var i=function t(e,r){function i(t,i,s){if("undefined"!=typeof document){"number"==typeof(s=n({},r,s)).expires&&(s.expires=new Date(Date.now()+864e5*s.expires)),s.expires&&(s.expires=s.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var o in s)s[o]&&(a+="; "+o,!0!==s[o]&&(a+="="+s[o].split(";")[0]));return document.cookie=t+"="+e.write(i,t)+a}}return Object.create({set:i,get:function(t){if("undefined"!=typeof document&&(!arguments.length||t)){for(var r=document.cookie?document.cookie.split("; "):[],n={},i=0;i<r.length;i++){var s=r[i].split("="),a=s.slice(1).join("=");try{var o=decodeURIComponent(s[0]);if(n[o]=e.read(a,o),t===o)break}catch(t){}}return t?n[t]:n}},remove:function(t,e){i(t,"",n({},e,{expires:-1}))},withAttributes:function(e){return t(this.converter,n({},this.attributes,e))},withConverter:function(e){return t(n({},this.converter,e),this.attributes)}},{attributes:{value:Object.freeze(r)},converter:{value:Object.freeze(e)}})}({read:function(t){return'"'===t[0]&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decode
1URIComponent)}},{path:"/"})}}]);

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.