{"version":3,"file":"DurationDisplay.BwR_0CDJ.mjs","names":["React.useState","React.useEffect","_jsxs","_jsx","__esmMin","init_npm_react_18_3_1","_e","p","c","init_jsx_runtime","ce","RenderTarget","addPropertyControls","ControlType","init_framer_ChujFWHC","Data","init_CalculatorStore","getDuration","calculatorStore","subscribeToCalc","aggregationStore","listeners","notify","subscribeToAggregation","setExpectedCount","resetExpectedCount","registerHouseItem","getHouseIds","getExpectedCount","getRawQuantity","init_AggregationStore","cb","callback","index","houseSlug","count","prev","priceId","isPriority","quantity","onlyUpdateQuantity","tidiedId","isAlreadyInList","id","useBase","DurationDisplay","props","labelBefore","labelAfter","font","color","cmsArea","tick","setTick","unsubCalc","t","areaToUse","months","displayMonths","finalValue","containerStyle","init_DurationDisplay"],"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":"A,0UAAsCoB,EAAiBL,EAAK,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC,EAAE,eAAe,CAAC,EAAE,WAAW,GAAG,cAAc,CAAC,CAAC,CAAC,EAAQM,EAAU,CAAC,EAAQC,MAAWD,EAAU,QAAQU,GAAIA,EAAG,CAAC,EAAeR,EAAuBS,IAAWX,EAAU,KAAKW,CAAQ,MAAY,CAAC,IAAMC,EAAMZ,EAAU,QAAQW,CAAQ,EAAKC,EAAM,IAAGZ,EAAU,OAAOY,EAAM,CAAC,CAAE,GAGzVT,GAAkBU,EAAUC,IAAQ,CAAC,GAAG,CAACD,EAAU,OAAO,IAAME,EAAKhB,EAAiB,cAAcc,IAAY,EAAEd,EAAiB,cAAcc,GAAWE,EAAKD,EAAMb,EAAO,CAAE,EAEhLG,GAAoBS,EAAUC,IAAQ,CAAC,GAAG,CAACD,EAAU,OAAO,IAAME,EAAKhB,EAAiB,cAAcc,IAAY,EAAEd,EAAiB,cAAcc,GAAW,KAAK,IAAI,EAAEE,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