import{S as e,a as t}from"./nc-util.BWncs0l6.js";import{t as n}from"./nc-dt.wsPmLyfq.js";var r={},i={},a=`nc-`;r.prefix=function(){return a};function o(t){let r=typeof t;return r===`object`?t.getMonth?(r=`time`,t=n.timeToString(t)):t=e(t):r===`string`&&t.length===19&&t.match(/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/)?r=`time`:r===`string`&&t.length===10&&t.match(/(\d{4})-(\d{2})-(\d{2})/)&&(r=`date`),{type:r,data:t}}function s(e){if(e==null||e===void 0||e===`undefined`)return null;let r=null;try{r=t(e)}catch(t){console.error(`decodeDataFromText fromJson error 1`,t,e),r={},r.type=`null`,r.data=null}if(r.type===`time`)return n.parseTime(r.data);if(r.type===`date`)return n.parseDate(r.data);if(r.type===`object`){try{r=t(r.data)}catch(e){return console.error(`decodeDataFromText fromJson error 2`,e,r.data),null}return r}return r.data}r.getLocalData=function(e){return s(localStorage.getItem(a+e))},r.setLocalData=function(t,n){let r=o(n);r=e(r);try{localStorage.setItem(a+t,r)}catch(e){return console.error(e),!1}return!0},r.deleteLocalData=function(e){return localStorage.removeItem(a+e)},r.getSessionData=function(e){e=a+e;let t=i[e];if(t)return t;let n=sessionStorage.getItem(e);return n||(n=localStorage.getItem(e)),t=s(n),console.log(`session.getSessionData not cached:`,e,t),i[e]=t,t},r.setSessionData=function(t,n){let r;t=a+t,i[t]=n,n&&(r=e(o(n)));try{sessionStorage.setItem(t,r),localStorage.setItem(t,r)}catch(e){return console.error(e),!1}return!0},r.clearSessionData=function(){return sessionStorage.clear(),localStorage.clear()},r.deleteSessionData=function(e){return e=a+e,sessionStorage.removeItem(e),i[e]=null},r.setParam=function(t,n){let r;return n=a+n,r=e(t),sessionStorage.setItem(n||`ma_param`,r),localStorage.setItem(n||`ma_param`,r)},r.deleteParam=function(e){return e=a+e,sessionStorage.removeItem(e||`ma_param`),localStorage.removeItem(e||`ma_param`)},r.getParam=function(e){let n,r;return e=a+e,r=sessionStorage.getItem(e||`ma_param`),r||(r=localStorage.getItem(e||`ma_param`),r)?(n=t(r),n):null},r.getPreference=function(e){let t;return t=r.getSessionData(e),t||{}};export{r as t};