1{"version":3,"file":"withAndroidSplashDrawables.js","names":["withAndroidSplashDrawables","config","splash","withDangerousMod","setSplashDrawableAsync","modRequest","projectRoot","resizeMode","filePath","AndroidConfig","Paths","getResourceXMLPathAsync","name","kind","xmlContent","$","item","bitmap","filter","Boolean","XML","writeXMLAsync","path","xml"],"sources":["../../../../src/plugins/unversioned/expo-splash-screen/withAndroidSplashDrawables.ts"],"sourcesContent":["import { AndroidConfig, ConfigPlugin, withDangerousMod, XML } from '@expo/config-plugins';\n\nimport { SplashScreenConfig } from './getAndroidSplashConfig';\n\nexport const withAndroidSplashDrawables: ConfigPlugin<Pick<SplashScreenConfig, 'resizeMode'>> = (\n  config,\n  splash\n) => {\n  return withDangerousMod(config, [\n    'android',\n    async (config) => {\n      if (splash) {\n        await setSplashDrawableAsync(splash, config.modRequest.projectRoot);\n      }\n      return config;\n    },\n  ]);\n};\n\nexport async function setSplashDrawableAsync(\n  { resizeMode }: Pick<SplashScreenConfig, 'resizeMode'>,\n  projectRoot: string\n) {\n  const filePath = (await AndroidConfig.Paths.getResourceXMLPathAsync(projectRoot, {\n    name: 'splashscreen',\n    kind: 'drawable',\n  }))!;\n\n  // Nuke and rewrite the splashscreen.xml drawable\n  const xmlContent = {\n    'layer-list': {\n      $: {\n        'xmlns:android': 'http://schemas.android.com/apk/res/android',\n      },\n      item: [\n        {\n          $: {\n            // TODO: Ensure these keys don't get out of sync\n            'android:drawable': '@color/splashscreen_background',\n          },\n        },\n        // Only include the image if resizeMode native is in-use.\n        resizeMode === 'native' && {\n          bitmap: [\n            {\n              $: {\n                'android:gravity': 'center',\n                // TODO: Ensure these keys don't get out of sync\n                'android:src': '@drawable/splashscreen_image',\n              },\n            },\n          ],\n        },\n      ].filter(Boolean),\n    },\n  };\n  await XML.writeXMLAsync({ path: filePath, xml: xmlContent });\n}\n"],"mappings":";;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAIO,MAAMA,0BAAgF,GAAG,CAC9FC,MAD8F,EAE9FC,MAF8F,KAG3F;EACH,OAAO,IAAAC,iCAAA,EAAiBF,MAAjB,EAAyB,CAC9B,SAD8B,EAE9B,MAAOA,MAAP,IAAkB;IAChB,IAAIC,MAAJ,EAAY;MACV,MAAME,sBAAsB,CAACF,MAAD,EAASD,MAAM,CAACI,UAAP,CAAkBC,WAA3B,CAA5B;IACD;;IACD,OAAOL,MAAP;EACD,CAP6B,CAAzB,CAAP;AASD,CAbM;;;;AAeA,eAAeG,sBAAf,CACL;EAAEG;AAAF,CADK,EAELD,WAFK,EAGL;EACA,MAAME,QAAQ,GAAI,MAAMC,8BAAA,CAAcC,KAAd,CAAoBC,uBAApB,CAA4CL,WAA5C,EAAyD;IAC/EM,IAAI,EAAE,cADyE;IAE/EC,IAAI,EAAE;EAFyE,CAAzD,CAAxB,CADA,CAMA;;EACA,MAAMC,UAAU,GAAG;IACjB,cAAc;MACZC,CAAC,EAAE;QACD,iBAAiB;MADhB,CADS;MAIZC,IAAI,EAAE,CACJ;QACED,CAAC,EAAE;UACD;UACA,oBAAoB;QAFnB;MADL,CADI,EAOJ;MACAR,UAAU,KAAK,QAAf,IAA2B;QACzBU,MAAM,EAAE,CACN;UACEF,CAAC,EAAE;YACD,mBAAmB,QADlB;YAED;YACA,eAAe;UAHd;QADL,CADM;MADiB,CARvB,EAmBJG,MAnBI,CAmBGC,OAnBH;IAJM;EADG,CAAnB;EA2BA,MAAMC,oBAAA,CAAIC,aAAJ,CAAkB;IAAEC,IAAI,EAAEd,QAAR;IAAkBe,GAAG,EAAET;EAAvB,CAAlB,CAAN;AACD"}