{"version":3,"file":"AggregationStore.CLQo4Axr.mjs","names":[],"sources":["https:/framerusercontent.com/modules/FVk2Co14dEr2UBa75RZl/xsLXsin3F2i0EHi6Bs15/AggregationStore.js"],"sourcesContent":["import{Data}from\"framer\";export const aggregationStore=Data({houses:{},quantities:{},baseQuantities:{},activeSlug:\"\",expectedCount:{}});const listeners=[];const notify=()=>listeners.forEach(cb=>cb());export const subscribeToAggregation=callback=>{listeners.push(callback);return()=>{const index=listeners.indexOf(callback);if(index>-1)listeners.splice(index,1);};};/**\n * NOVÉ: IDCollector zavolá túto funkciu so súčtom všetkých IDs ktoré\n * bude registrovať. PriceTotalCMS vie koľko IDs má čakať.\n */export const setExpectedCount=(houseSlug,count)=>{if(!houseSlug)return;const prev=aggregationStore.expectedCount[houseSlug]||0;aggregationStore.expectedCount[houseSlug]=prev+count;notify();};/**\n * NOVÉ: Reset expectedCount pre slug — volá sa pri cleanup IDCollectora\n */export const resetExpectedCount=(houseSlug,count)=>{if(!houseSlug)return;const prev=aggregationStore.expectedCount[houseSlug]||0;aggregationStore.expectedCount[houseSlug]=Math.max(0,prev-count);notify();};export const registerHouseItem=(houseSlug,priceId,isPriority=false,quantity=null,onlyUpdateQuantity=false)=>{if(!houseSlug||!priceId)return;const tidiedId=priceId.trim();if(!onlyUpdateQuantity){if(isPriority||aggregationStore.activeSlug===\"\"){aggregationStore.activeSlug=houseSlug;}}if(!aggregationStore.houses[houseSlug]){aggregationStore.houses[houseSlug]=[];}const isAlreadyInList=aggregationStore.houses[houseSlug].includes(tidiedId);if(!onlyUpdateQuantity&&quantity!==-1&&!isAlreadyInList){aggregationStore.houses[houseSlug].push(tidiedId);}if(quantity!==null){if(!aggregationStore.quantities[houseSlug]){aggregationStore.quantities[houseSlug]={};}if(!aggregationStore.baseQuantities[houseSlug]){aggregationStore.baseQuantities[houseSlug]={};}if(quantity===-1){delete aggregationStore.quantities[houseSlug][tidiedId];delete aggregationStore.baseQuantities[houseSlug][tidiedId];aggregationStore.houses[houseSlug]=aggregationStore.houses[houseSlug].filter(id=>id!==tidiedId);}else{if(onlyUpdateQuantity){aggregationStore.quantities[houseSlug][tidiedId]=quantity;}else{aggregationStore.quantities[houseSlug][tidiedId]=quantity;if(aggregationStore.baseQuantities[houseSlug][tidiedId]===undefined){aggregationStore.baseQuantities[houseSlug][tidiedId]=quantity;}}}}notify();};export const getHouseIds=houseSlug=>aggregationStore.houses[houseSlug]||[];export const getExpectedCount=houseSlug=>aggregationStore.expectedCount[houseSlug]||0;export const getRawQuantity=(houseSlug,priceId,useBase=false)=>{const targetStore=useBase?aggregationStore.baseQuantities:aggregationStore.quantities;return targetStore[houseSlug]?.[priceId];};\nexport const __FramerMetadata__ = {\"exports\":{\"setExpectedCount\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getRawQuantity\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"aggregationStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getExpectedCount\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"subscribeToAggregation\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"registerHouseItem\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getHouseIds\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"resetExpectedCount\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./AggregationStore.map"],"mappings":"2IAAyB,CAAa,EAAiB,EAAK,CAAC,OAAO,EAAE,CAAC,WAAW,EAAE,CAAC,eAAe,EAAE,CAAC,WAAW,GAAG,cAAc,EAAE,CAAC,CAAC,CAAO,EAAU,EAAE,CAAO,MAAW,EAAU,QAAQ,GAAI,GAAI,CAAC,CAAc,EAAuB,IAAW,EAAU,KAAK,EAAS,KAAW,CAAC,IAAM,EAAM,E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