import e from"@babel/runtime/helpers/defineProperty";import t from"@babel/runtime/helpers/objectWithoutProperties";import r from"@babel/runtime/helpers/typeof";import{jsx as n}from"react/jsx-runtime";import{useMemo as o,useCallback as i,useRef as p}from"react";import{AppCommonsContext as a}from"./AppCommonsContext.js";import{useAppCommonsValue as l}from"./utils.js";import{getAssetKey as c}from"../../utils/completion.js";var u=["children","app"];function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function m(t){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?s(Object(n),!0).forEach((function(r){e(t,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var f="development"===process.env.NODE_ENV,v=function(e){var t=i((function(){null==e||e()}),[e]);return e?t:void 0},d=function(e){var t=p(e);return t.current=e,i((function(){for(var e,r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return null===(e=t.current)||void 0===e?void 0:e.call.apply(e,[t].concat(n))}),[])},g=function(i){var p,s,g,y,b,O,h,j=i.children,S=i.app,P=t(i,u),A=(null==S||null===(p=S.package)||void 0===p||null===(s=p.manifest)||void 0===s||null===(g=s.application)||void 0===g?void 0:g.key)||"",C=(null==S?void 0:S.name)||(null==S||null===(y=S.package)||void 0===y||null===(b=y.manifest)||void 0===b||null===(O=b.application)||void 0===O?void 0:O.name)||"",w=c(P.fracFleet,P.well,null===(h=P.appSettings)||void 0===h?void 0:h.padId),k=v(P.onHelpCenterClick),_=v(P.onAppRemove),D=v(P.reloadApp),E=d(P.onSettingsChange),N=d(P.onSettingChange),x=o((function(){var t;if(!f)return P.appSettings;var n=function(e,t){if(!f)return{};var n="local_corva_pad_mode_".concat(e,"_").concat(t);try{var o=localStorage.getItem(n);if(!o)return{};var i=JSON.parse(o);return"object"!==r(i)||null===i||Array.isArray(i)||"string"!=typeof i.mode?{}:i}catch(e){return console.error("Error reading pad mode setting from localStorage",e),{}}}(A,w);return Object.keys(n).length?m(m({},P.appSettings),{},{settingsByAsset:m(m({},null===(t=P.appSettings)||void 0===t?void 0:t.settingsByAsset),{},e({},w,n))}):P.appSettings}),[P.appSettings,A,w]),B=l(m(m({},P),{},{app:S,appKey:A,appName:C,appSettings:x,onHelpCenterClick:k,onAppRemove:_,reloadApp:D,onSettingsChange:E,onSettingChange:N}));return n(a.Provider,{value:B,children:j})};export{g as AppCommonsProvider};
//# sourceMappingURL=AppCommonsProvider.js.map
