{"version":3,"file":"DurationDisplay.BUC5SwPL.mjs","names":["React.useState"],"sources":["https:/framerusercontent.com/modules/cH7dneSCDWa1JtDbf5Hx/ss5GVItcLp91vvF0sdDh/AggregationStore.js","https:/framerusercontent.com/modules/dd8kMZaprsC5M7u7EzTM/zUvjOxoPRu5l6KKEu4Ry/DurationDisplay.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","import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{calculatorStore,subscribeToCalc,getDuration}from\"https://framerusercontent.com/modules/uQNF3MjqAXSmdDpsul7P/j9h69GtyCt0zxJCLkqt1/CalculatorStore.js\";export default function DurationDisplay(props){const{houseSlug,labelBefore,labelAfter,font,color,cmsArea}=props;const[tick,setTick]=React.useState(0);// 1. Subscription na zmeny v kalkulačke\nReact.useEffect(()=>{const unsubCalc=subscribeToCalc(()=>setTick(t=>t+1));return()=>unsubCalc();},[]);// 2. Re-render pri zmene domu\nReact.useEffect(()=>{setTick(t=>t+1);},[houseSlug]);// LOGIKA:\n// Ak máme zadanú 'cmsArea' (Index Page), použijeme tú.\n// Inak použijeme 'calculatorStore.area' (Detail Page / Kalkulačka).\nconst isCmsOverride=cmsArea!==undefined&&cmsArea!==null&&cmsArea>0;const areaToUse=isCmsOverride?cmsArea:calculatorStore.area;// Výpočet trvania\nconst months=getDuration(areaToUse);const displayMonths=Math.round(months);// Fallback pre Canvas (ak nie je nič prepojené)\nconst isCanvas=RenderTarget.current()===RenderTarget.canvas;const finalValue=isCanvas&&!areaToUse?5:displayMonths;return /*#__PURE__*/_jsxs(\"div\",{style:{...containerStyle,...font,color:color},children:[labelBefore&&/*#__PURE__*/_jsx(\"span\",{style:{marginRight:4},children:labelBefore}),/*#__PURE__*/_jsx(\"span\",{style:{fontWeight:\"normal\"},children:finalValue}),labelAfter&&/*#__PURE__*/_jsx(\"span\",{style:{marginLeft:4},children:labelAfter})]});}addPropertyControls(DurationDisplay,{houseSlug:{type:ControlType.String,title:\"Slug Domu\",description:\"Prepojte s premennou Slug (z CMS).\"},cmsArea:{type:ControlType.Number,title:\"Plocha (CMS)\",description:\"Vyplniť len na Index Page. Prepojte s plochou domu. Na Detail page nechajte pr\\xe1zdne.\",defaultValue:undefined},labelBefore:{type:ControlType.String,title:\"Preffix\",defaultValue:\"\"},labelAfter:{type:ControlType.String,title:\"Suffix\",defaultValue:\"dn\\xed\"},font:{type:ControlType.Font,title:\"Typografia\",controls:\"extended\"},color:{type:ControlType.Color,title:\"Farba\",defaultValue:\"#333\"}});const containerStyle={display:\"flex\",alignItems:\"center\",justifyContent:\"center\",whiteSpace:\"nowrap\"};\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"DurationDisplay\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}"],"mappings":"mTAAwB,EAAc,EAAiB,EAAK,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC,EAAE,eAAe,CAAC,EAAE,WAAW,GAAG,cAAc,CAAC,CAAC,CAAC,EAAQ,EAAU,CAAC,EAAQ,MAAW,EAAU,QAAQ,GAAI,EAAG,CAAC,EAAe,EAAuB,IAAW,EAAU,KAAK,CAAQ,MAAY,CAAC,IAAM,EAAM,EAAU,QAAQ,CAAQ,EAAK,EAAM,IAAG,EAAU,OAAO,EAAM,CAAC,CAAE,GAGzV,GAAkB,EAAU,IAAQ,CAAC,GAAG,CAAC,EAAU,OAAO,IAAM,EAAK,EAAiB,cAAc,IAAY,EAAE,EAAiB,cAAc,GAAW,EAAK,EAAM,EAAO,CAAE,EAEhL,GAAoB,EAAU,IAAQ,CAAC,GAAG,CAAC,EAAU,OAAO,IAAM,EAAK,EAAiB,cAAc,IAAY,EAAE,EAAiB,cAAc,GAAW,KAAK,IAAI,EAAE,EAAK,CAAK,EAAE,EAAO,CAAE,EAAe,GAAmB,EAAU,EAAQ,EAAW,GAAM,EAAS,KAAK,EAAmB,KAAQ,CAAC,GAAG,CAAC,GAAW,CAAC,EAAQ,OAAO,IAAM,EAAS,EAAQ,KAAK,EAAM,IAAuB,GAAY,EAAiB,aAAa,MAAI,EAAiB,WAAW,GAAgB,EAAiB,OAAO,KAAY,EAAiB,OAAO,GAAW,CAAC,GAAG,IAAM,EAAgB,EAAiB,OAAO,EAAU,CAAC,SAAS,CAAQ,EAAK,CAAC,GAAoB,IAAW,IAAI,CAAC,GAAiB,EAAiB,OAAO,EAAU,CAAC,KAAK,CAAQ,EAAM,IAAW,OAAU,EAAiB,WAAW,KAAY,EAAiB,WAAW,GAAW,C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