"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),t=require("react/jsx-runtime"),r=require("../../../../../componentsV2/AppInfoMessage/AppMessageWrapper.js"),o=require("../../../../../componentsV2/EmptyState/EmptyState.js"),s=require("../../../../../componentsV2/LoaderLogo/LoaderLogo.js"),a=require("./components/ChooseAssetButton.js"),p=require("./DevCenterAppView.scss.js"),n=require("../../../../ErrorBoundary/ErrorBoundary.js");require("../../../../ErrorBoundary/DevCenterAppErrorView/DevCenterAppErrorView.js");var i=require("../../../../../constants/segment.js");require("../../../../../componentsV2/AppCommonsProvider/AppCommonsProvider.js");var l=require("../../../../../componentsV2/AppCommonsProvider/AppCommonsContext.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=u(e);function d(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,o)}return r}function g(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?d(Object(r),!0).forEach((function(t){c.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):d(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var m=function(e){return"".concat(e," has no active well")};function f(e){var u,c=e.AppComponent,d=e.app,f=e.appData,j=e.appProps,b=e.availability,h=e.isCLIApp,v=e.isLoading,A=e.isMultiRig,y=e.layoutEnvironment,E=e.openIntercom,S=e.segment,x=e.toggleAppSettingsDialog,w=e.onError,P="DevCenterAppView_EmptyState",O=l.useAppCommonsInternal(),C=null!==(u=null==O?void 0:O.appSettings)&&void 0!==u?u:d.settings;if(!d.package)return t.jsx(r.AppMessageWrapper,{logo:d.headerLogo,children:t.jsx(o.EmptyState,{testId:P,title:"App package was not found",subTitle:"Please choose another version in the app settings menu or delete and add app again on your dashboard",image:"appLoadingError"})});if(v)return t.jsx(r.AppMessageWrapper,{showHeader:!1,children:t.jsx(s.LoaderLogo,{className:p.loader,testId:"DevCenterAppView_Loader"})});if(!b.hasProductSubscription||!b.isAppSubscribedForAsset){var L=b.hasProductSubscription?{title:"No Subscription exists for this asset.",subtitle:"Contact your Corva Account rep to get access to this asset."}:{title:"No Subscription exists for this app.",subtitle:"Contact your Corva Account rep to get access to this app."},I=L.title,M=L.subtitle;return t.jsx(r.AppMessageWrapper,{logo:d.headerLogo,children:t.jsx(o.EmptyState,{testId:P,title:I,subTitle:M,image:"noSubscription"})})}if(!c)return t.jsx(r.AppMessageWrapper,{logo:d.headerLogo,children:t.jsx(o.EmptyState,{testId:P,title:"App component was not found",image:"appLoadingError"})});if(!A){var D=h&&t.jsx(a.ChooseAssetButton,{toggleAppSettingsDialog:x}),N=S===i.SEGMENTS.INTERVENTION?f.interventionUnit:f.rig;if(N&&!f.well)return t.jsx(r.AppMessageWrapper,{logo:d.headerLogo,children:t.jsx(o.EmptyState,{testId:P,title:m(null==N?void 0:N.name),image:"noActiveWell",subTitle:D})});var T="general"===(null==y?void 0:y.type),W=S===i.SEGMENTS.COMPLETION;if(T&&W&&!f.fracFleet)return t.jsx(r.AppMessageWrapper,{logo:d.headerLogo,children:t.jsx(o.EmptyState,{testId:P,title:"Frac fleet was not found",subTitle:D,image:"fleetHasNoPad"})});if(W&&f.fracFleet&&!f.fracFleet.current_pad_id&&!d.settings.padId)return t.jsx(r.AppMessageWrapper,{logo:d.headerLogo,children:t.jsx(o.EmptyState,{testId:P,image:"fleetHasNoPad",subTitle:D,title:"Frac fleet has no active pad"})});if(W&&T&&(!f.wells||f.wells.length<1))return t.jsx(r.AppMessageWrapper,{logo:d.headerLogo,children:t.jsx(o.EmptyState,{testId:P,image:"noWellsSelected",subTitle:D,title:"This pad has no wells"})});if(!(f.rig||f.well||f.settings||f.wells))return t.jsx(r.AppMessageWrapper,{logo:d.headerLogo,children:t.jsx(o.EmptyState,{testId:P,image:"assetHasNoData",subTitle:D,title:"Asset unavailable"})})}return t.jsx(n,{openIntercom:E,onError:w,children:t.jsx(c,g(g(g(g({app:d},d.settings),C),f),j))})}f.defaultProps={availability:{hasProductSubscription:!0,isAppSubscribedForAsset:!0}},exports.default=f,exports.getNoActiveWellMessage=m;
//# sourceMappingURL=DevCenterAppView.js.map
