var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireWildcard(require("react"));var _reactLive=require("react-live");var _index=require("../../index");var _CodePreviewProvider=require("./CodePreviewProvider");var _jsxRuntime=require("react/jsx-runtime");var _excluded=["showArgsController","_rendererWrapper","showExternalResource","href"];function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap();var cacheNodeInterop=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj;}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj};}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj.default=obj;if(cache){cache.set(obj,newObj);}return newObj;}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable;})),keys.push.apply(keys,symbols);}return keys;}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys(Object(source),!0).forEach(function(key){(0,_defineProperty2.default)(target,key,source[key]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target;}var ComponentRenderer=function ComponentRenderer(_ref){var _metaData$transformCo;var showArgsController=_ref.showArgsController,_rendererWrapper=_ref._rendererWrapper,showExternalResource=_ref.showExternalResource,href=_ref.href,props=(0,_objectWithoutProperties2.default)(_ref,_excluded);var _useContext=(0,_react.useContext)(_CodePreviewProvider.CodePreviewContext),metaData=_useContext.metaData,propsString=_useContext.propsString;return(0,_jsxRuntime.jsxs)(_index.Box,_objectSpread(_objectSpread({flex:1,overflow:"hidden",flexWrap:"wrap",alignItems:"center",justifyContent:"center",minHeight:'200px'},_rendererWrapper),{},{children:[showExternalResource&&(0,_jsxRuntime.jsxs)(_index.Link,{position:"absolute",href:href,isExternal:true,right:"$4",top:"$4",flexDirection:"row",alignItems:"center",px:"$3",py:"$1",borderWidth:"$1",borderColor:"$borderDark800",rounded:"$sm",sx:{_light:{borderColor:'$borderLight300'}},children:[(0,_jsxRuntime.jsx)(_index.ExpoIcon,{h:"$5",w:"$5",mr:"$2.5",color:"#0072BC"}),(0,_jsxRuntime.jsx)(_index.Text,{color:"$textLight50",fontSize:"$sm",sx:{_web:{userSelect:'none'},_light:{color:'$textLight700'}},children:"Open in Expo"})]}),(0,_jsxRuntime.jsxs)(_reactLive.LiveProvider,_objectSpread(_objectSpread({code:showArgsController?metaData==null?void 0:metaData.code.replace('{...props}',propsString):metaData==null?void 0:metaData.code,transformCode:(_metaData$transformCo=metaData==null?void 0:metaData.transformCode)!=null?_metaData$transformCo:null,scope:_objectSpread({},metaData==null?void 0:metaData.scope)},props),{},{children:[(0,_jsxRuntime.jsx)(_reactLive.LivePreview,{}),(0,_jsxRuntime.jsx)(_reactLive.LiveError,{})]}))]}));};var _default=ComponentRenderer;exports.default=_default;
//# sourceMappingURL=ComponentRenderer.js.map