{"version":3,"names":["_updatePropsJS","snapshots","WeakMap","makeElementVisible","element","delay","visibility","_component","setTimeout","fixElementPosition","parent","snapshot","parentRect","getBoundingClientRect","parentBorderTopValue","parseInt","getComputedStyle","borderTopWidth","parentBorderLeftValue","borderLeftWidth","dummyRect","top","style","left","setDummyPosition","dummy","transform","position","width","height","margin","parentElement"],"sources":["componentStyle.ts"],"sourcesContent":["'use strict';\n\nimport { _updatePropsJS } from '../../js-reanimated';\nimport type { ReanimatedHTMLElement } from '../../js-reanimated';\n\nexport interface ReanimatedSnapshot {\n top: number;\n left: number;\n width: number;\n height: number;\n scrollOffsets: ScrollOffsets;\n}\n\nexport interface ScrollOffsets {\n scrollTopOffset: number;\n scrollLeftOffset: number;\n}\n\nexport const snapshots = new WeakMap();\n\nexport function makeElementVisible(element: HTMLElement, delay: number) {\n if (delay === 0) {\n _updatePropsJS(\n { visibility: 'initial' },\n { _component: element as ReanimatedHTMLElement }\n );\n } else {\n setTimeout(() => {\n _updatePropsJS(\n { visibility: 'initial' },\n { _component: element as ReanimatedHTMLElement }\n );\n }, delay * 1000);\n }\n}\n\nfunction fixElementPosition(\n element: HTMLElement,\n parent: HTMLElement,\n snapshot: ReanimatedSnapshot\n) {\n const parentRect = parent.getBoundingClientRect();\n\n const parentBorderTopValue = parseInt(\n getComputedStyle(parent).borderTopWidth\n );\n\n const parentBorderLeftValue = parseInt(\n getComputedStyle(parent).borderLeftWidth\n );\n\n const dummyRect = element.getBoundingClientRect();\n // getBoundingClientRect returns DOMRect with position of the element with respect to document body.\n // However, using position `absolute` doesn't guarantee, that the dummy will be placed relative to body element.\n // The trick below allows us to once again get position relative to body, by comparing snapshot with new position of the dummy.\n if (dummyRect.top !== snapshot.top) {\n element.style.top = `${\n snapshot.top - parentRect.top - parentBorderTopValue\n }px`;\n }\n\n if (dummyRect.left !== snapshot.left) {\n element.style.left = `${\n snapshot.left - parentRect.left - parentBorderLeftValue\n }px`;\n }\n}\n\nexport function setDummyPosition(\n dummy: HTMLElement,\n snapshot: ReanimatedSnapshot\n) {\n dummy.style.transform = '';\n dummy.style.position = 'absolute';\n dummy.style.top = `${snapshot.top}px`;\n dummy.style.left = `${snapshot.left}px`;\n dummy.style.width = `${snapshot.width}px`;\n dummy.style.height = `${snapshot.height}px`;\n dummy.style.margin = '0px'; // tmpElement has absolute position, so margin is not necessary\n\n fixElementPosition(dummy, dummy.parentElement!, snapshot);\n}\n"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,cAAc,QAAQ,qBAAqB;AAgBpD,OAAO,MAAMC,SAAS,GAAG,IAAIC,OAAO,EAAmC;AAEvE,OAAO,SAASC,kBAAkBA,CAACC,OAAoB,EAAEC,KAAa,EAAE;EACtE,IAAIA,KAAK,KAAK,CAAC,EAAE;IACfL,cAAc,CACZ;MAAEM,UAAU,EAAE;IAAU,CAAC,EACzB;MAAEC,UAAU,EAAEH;IAAiC,CAAC,CACjD;EACH,CAAC,MAAM;IACLI,UAAU,CAAC,MAAM;MACfR,cAAc,CACZ;QAAEM,UAAU,EAAE;MAAU,CAAC,EACzB;QAAEC,UAAU,EAAEH;MAAiC,CAAC,CACjD;IACH,CAAC,EAAEC,KAAK,GAAG,IAAI,CAAC;EAClB;AACF;AAEA,SAASI,kBAAkBA,CACzBL,OAAoB,EACpBM,MAAmB,EACnBC,QAA4B,EAC5B;EACA,MAAMC,UAAU,GAAGF,MAAM,CAACG,qBAAqB,EAAE;EAEjD,MAAMC,oBAAoB,GAAGC,QAAQ,CACnCC,gBAAgB,CAACN,MAAM,CAAC,CAACO,cAAc,CACxC;EAED,MAAMC,qBAAqB,GAAGH,QAAQ,CACpCC,gBAAgB,CAACN,MAAM,CAAC,CAACS,eAAe,CACzC;EAED,MAAMC,SAAS,GAAGhB,OAAO,CAACS,qBAAqB,EAAE;EACjD;EACA;EACA;EACA,IAAIO,SAAS,CAACC,GAAG,KAAKV,QAAQ,CAACU,GAAG,EAAE;IAClCjB,OAAO,CAACkB,KAAK,CAACD,GAAG,GAAI,GAC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