1import{cC as D,o as L,R as T,ba as q,ac as x,ak as z,be as A,C as F,cD as S,cz as h}from"#entry";import{m as J,v as N,g as O}from"./BZS6mqMC.js";function W(){return{prescriberInformation:D("prescriber-information",{afid:null,aftype:null,voucherPrescriber:null},{serializer:{read:a=>JSON.parse(a),write:a=>JSON.stringify(a)}})}}const $=P=>{const a=O(),{t:m}=L(),{ppk:o,subscriptionPpk:y}=T(P),s=q(),d=x("useBasketPPKSync"),i=z("useBasketPPKSync"),{applyPromotions:I}=A({basket:s.data}),{toast:_}=F(),C=J(null);let c=null;const B=async()=>{var k,b,f,g,v,K,w;if(!o.value)return;const n=(s.items.value||[]).filter(t=>{const e=t.customData,r=(e==null?void 0:e.pricePromotionKey)||S,p=h(e)?y.value:o.value;return r!==p});if(n.length!==0)try{for(const t of n){const e=t.customData||{},r=h(e),p=(e==null?void 0:e.pricePromotionKey)||S,l=r?y.value:o.value;d.debug(`Updating basket items with PPK: ${l}`),await s.updateItem(t.key,{quantity:t.quantity,customData:{...e,pricePromotionKey:l,...r?{subscription:!0}:{}}}),i.event("basket_item_ppk_synced",{basketKey:(k=s.data.value)==null?void 0:k.key,itemKey:t.key,variantId:(b=t.variant)==null?void 0:b.id,productId:(f=t.product)==null?void 0:f.id,previousPricePromotionKey:p,newPricePromotionKey:l})}await I(s.data),await((v=(g=window.scayleCheckoutFunctions)==null?void 0:g.mutations)==null?void 0:v.getState()),U(),i.event("basket_ppk_sync_completed",{basketKey:(K=s.data.value)==null?void 0:K.key,updatedItemCount:n.length,targetPricePromotionKey:o.value})}catch(t){throw i.exception(t,"error",{basketKey:(w=s.data.value)==null?void 0:w.key}),t}finally{c=null}},U=()=>{C.value=_({variant:"info",title:m("info_title"),duration:7e3,description:m("basket.notification.price_update")})};a==null||a.run(()=>{N(o,async(u,n)=>{if(!(!u||u===n)){if(c){d.debug("Update already in progress, waiting..."),await c;return}await B()}},{immediate:!0})})};export{$ as a,W as u};
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.