{"version":3,"sources":["SafeAreaView.tsx"],"names":["React","View","StyleSheet","useSafeAreaInsets","TOP","RIGHT","BOTTOM","LEFT","ALL","edgeBitmaskMap","top","right","bottom","left","SafeAreaView","style","mode","edges","rest","insets","edgeBitmask","reduce","accum","edge","appliedStyle","useMemo","insetTop","insetRight","insetBottom","insetLeft","flatStyle","flatten","margin","marginVertical","marginHorizontal","marginTop","marginRight","marginBottom","marginLeft","marginStyle","padding","paddingVertical","paddingHorizontal","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingStyle"],"mappings":";;;;;;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,IAAT,EAAeC,UAAf,QAAiC,cAAjC;AACA,SAASC,iBAAT,QAAkC,mBAAlC;AAGA;AACA,MAAMC,GAAG,GAAM,MAAf;AAAA,MACMC,KAAK,GAAI,MADf;AAAA,MAEMC,MAAM,GAAG,MAFf;AAAA,MAGMC,IAAI,GAAK,MAHf;AAAA,MAIMC,GAAG,GAAM,MAJf;AAMA;;AAEA,MAAMC,cAAoC,GAAG;AAC3CC,EAAAA,GAAG,EAAEN,GADsC;AAE3CO,EAAAA,KAAK,EAAEN,KAFoC;AAG3CO,EAAAA,MAAM,EAAEN,MAHmC;AAI3CO,EAAAA,IAAI,EAAEN;AAJqC,CAA7C;AAOA,OAAO,SAASO,YAAT,OAKqB;AAAA,MALC;AAC3BC,IAAAA,KAAK,GAAG,EADmB;AAE3BC,IAAAA,IAF2B;AAG3BC,IAAAA;AAH2B,GAKD;AAAA,MADvBC,IACuB;;AAC1B,QAAMC,MAAM,GAAGhB,iBAAiB,EAAhC;AAEA,QAAMiB,WAAW,GACfH,KAAK,IAAI,IAAT,GACIA,KAAK,CAACI,MAAN,CAAa,CAACC,KAAD,EAAQC,IAAR,KAAiBD,KAAK,GAAGb,cAAc,CAACc,IAAD,CAApD,EAA4D,CAA5D,CADJ,GAEIf,GAHN;AAKA,QAAMgB,YAAY,GAAGxB,KAAK,CAACyB,OAAN,C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,eANZ;AAOJK,QAAAA,WAAW,GAAGJ;AAPV,UAQFZ,SARJ;AAUA,YAAMiB,YAAY,GAAG;AACnBJ,QAAAA,UAAU,EAAEA,UAAU,GAAGjB,QADN;AAEnBkB,QAAAA,YAAY,EAAEA,YAAY,GAAGjB,UAFV;AAGnBkB,QAAAA,aAAa,EAAEA,aAAa,GAAGjB,WAHZ;AAInBkB,QAAAA,WAAW,EAAEA,WAAW,GAAGjB;AAJR,OAArB;AAOA,aAAO,CAACd,KAAD,EAAQgC,YAAR,CAAP;AACD;AACF,GA/CoB,EA+ClB,CAAChC,KAAD,EAAQI,MAAR,EAAgBH,IAAhB,EAAsBI,WAAtB,CA/CkB,CAArB;AAiDA,sBAAO,oBAAC,IAAD;AAAM,IAAA,KAAK,EAAEI;AAAb,KAA+BN,IAA/B,EAAP;AACD","sourcesContent":["import * as React from 'react';\nimport { View, StyleSheet } from 'react-native';\nimport { useSafeAreaInsets } from './SafeAreaContext';\nimport { Edge, NativeSafeAreaViewProps } from './SafeArea.types';\n\n// prettier-ignore\nconst TOP = 0b1000,\n RIGHT = 0b0100,\n BOTTOM = 0b0010,\n LEFT = 0b0001,\n ALL = 0b1111;\n\n/* eslint-disable no-bitwise */\n\nconst edgeBitmaskMap: Record = {\n top: TOP,\n right: RIGHT,\n bottom: BOTTOM,\n left: LEFT,\n};\n\nexport function SafeAreaView({\n style = {},\n mode,\n edges,\n ...rest\n}: NativeSafeAreaViewProps) {\n const insets = useSafeAreaInsets();\n\n const edgeBitmask =\n edges != null\n ? edges.reduce((accum, edge) => accum | edgeBitmaskMap[edge], 0)\n : ALL;\n\n const appliedStyle = React.useMemo(() => {\n const insetTop = edgeBitmask & TOP ? insets.top : 0;\n const insetRight = edgeBitmask & RIGHT ? insets.right : 0;\n const insetBottom = edgeBitmask & BOTTOM ? insets.bottom : 0;\n const insetLeft = edgeBitmask & LEFT ? insets.left : 0;\n\n const flatStyle = StyleSheet.flatten(style) as Record;\n\n if (mode === 'margin') {\n const {\n margin = 0,\n marginVertical = margin,\n marginHorizontal = margin,\n marginTop = marginVertical,\n marginRight = marginHorizontal,\n marginBottom = marginVertical,\n marginLeft = marginHorizontal,\n } = flatStyle;\n\n const marginStyle = {\n marginTop: marginTop + insetTop,\n marginRight: marginRight + insetRight,\n marginBottom: marginBottom + insetBottom,\n marginLeft: marginLeft + insetLeft,\n };\n\n return [style, marginStyle];\n } else {\n const {\n padding = 0,\n paddingVertical = padding,\n paddingHorizontal = padding,\n paddingTop = paddingVertical,\n paddingRight = paddingHorizontal,\n paddingBottom = paddingVertical,\n paddingLeft = paddingHorizontal,\n } = flatStyle;\n\n const paddingStyle = {\n paddingTop: paddingTop + insetTop,\n paddingRight: paddingRight + insetRight,\n paddingBottom: paddingBottom + insetBottom,\n paddingLeft: paddingLeft + insetLeft,\n };\n\n return [style, paddingStyle];\n }\n }, [style, insets, mode, edgeBitmask]);\n\n return ;\n}\n"]}