1/*! 2 App Connect State Management 3 Version: 2.0.1 4 (c) 2025 Wappler.io 5 @build 2025-12-02 11:25:00 6 */ 7dmx.Component("query-manager",{initialData:{data:{}},methods:{set(e,t){this._setQueryParam(e,t)},remove(e){this._setQueryParam(e)},removeAll(){this._setQueryParam()}},render:!1,init(){this._updateHandler=this._updateHandler.bind(this),window.addEventListener("popstate",this._updateHandler),window.addEventListener("pushstate",this._updateHandler),window.addEventListener("replacestate",this._updateHandler),dmx.nextTick(()=>{this.initContentView()}),this._updateHandler()},initContentView(){this.contentView=dmx.app?.find("content"),this.contentView?.addEventListener("load",this._updateHandler)},destroy(){window.removeEventListener("popstate",this._updateHandler),window.removeEventListener("pushstate",this._updateHandler),window.removeEventListener("replacestate",this._updateHandler),this.contentView?.removeEventListener("load",this._updateHandler)},_setQueryParam:function(e,t){let o=!1,n=dmx.clone(this.data.data);if(null==t?null==e?(n={},o=!0):n[e]&&(delete n[e],o=!0):n[e]!=t&&(n[e]=t,o=!0),o){const e=new URL(window.location);e.search=new URLSearchParams(n),window.history.pushState(null,null,e)}},_buildQuery:function(e){const t=Object.keys(e);return t.length?"?"+t.reduce(function(t,o){return t&&(t+="&"),t+=encodeURIComponent(o)+"="+encodeURIComponent(e[o])},""):""},_parseQuery:function(){return this.search.replace(/^\?/,"").split("&").reduce(function(e,t){const o=t.replace(/\+/g," ").split("=");return o[0]&&(e[decodeURIComponent(o[0])]=decodeURIComponent(o[1]||"")),e},{})},_updateHandler(){this.contentView?.data?.loading||this.search!==window.location.search&&(this.search=window.location.search,this.set("data",this._parseQuery()))}}),dmx.Component("cookie-manager",{initialData(){return this._cookie=document.cookie,{data:this._getCookie()}},methods:{set(e,t,o={}){this._setCookie(e,t,o)},remove(e,t={}){t.expires="1970-01-01T00:00:00Z",this._setCookie(e,"",t)},removeAll(e={}){e.expires="1970-01-01T00:00:00Z",Object.keys(this.data.data).forEach(function(t){this._setCookie(t,"",e)})}},render:!1,_getCookie(){return this._cookie.split(/;\s*/).reduce(function(e,t){var o=t.indexOf("=");return e[decodeURIComponent(t.substr(0,o))]=decodeURIComponent(t.substr(o+1)),e},{})},_setCookie:function(e,t,o){if(!e||/^(?:expires|max\-age|path|domain|secure)$/i.test(e))return!1;(o=o||{}).path=o.path||"/";var n=(e=(e=(e=encodeURIComponent(String(e))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape))+"="+(t=(t=encodeURIComponent(String(t))).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent));o.expires&&("number"==typeof o.expires&&(o.expires=Date.now()+864e5*o.expires),n+="; expires="+new Date(o.expires).toUTCString()),o.domain&&(n+="; domain="+o.domain),o.path&&(n+="; path="+o.path),o.secure&&(n+="; secure"),document.cookie=n,this._cookie=document.cookie,this.set("data",this._getCookie())}}),dmx.Component("local-manager",{initialData:{data:{}},methods:{set(e,t){const o=JSON.stringify(t);null!=o?window.localStorage.setItem("dmxState-"+e,o):window.localStorage.removeItem("dmxState-"+e),this._getData()},remove(e){window.localStorage.removeItem("dmxState-"+e),this._getData()},removeAll(){Object.keys(window.localStorage).forEach(function(e){e.startsWith("dmxState-")&&window.localStorage.removeItem(e)}),this._getData()}},render:!1,init(){this._getData()},_getData(){this.set("data",Object.keys(window.localStorage).reduce(function(e,t){if(t.startsWith("dmxState-"))try{e[t.slice(9)]=JSON.parse(window.localStorage.getItem(t))}catch(e){console.warn("Error parsing JSON: "+window.localStorage.getItem(t))}return e},{}))}}),dmx.Component("session-manager",{initialData:{data:{}},methods:{set(e,t){const o=JSON.stringify(t);null!=o?window.sessionStorage.setItem("dmxState-"+e,o):window.sessionStorage.removeItem("dmxState-"+e),this._getData()},remove(e){window.sessionStorage.removeItem("dmxState-"+e),this._getData()},removeAll(){Object.keys(window.sessionStorage).forEach(function(e){e.startsWith("dmxState-")&&window.sessionStorage.removeItem(e)}),this._getData()}},render:!1,init(e){this._getData()},_getData(){this.set("data",Object.keys(window.sessionStorage).reduce(function(e,t){if(t.startsWith("dmxState-"))try{e[t.slice(9)]=JSON.parse(window.sessionStorage.getItem(t))}catch(e){console.warn("Error parsing JSON: "+window.sessionStorage.getItem(t))}return e},{}))}}); 8//# sourceMappingURL=dmxStateManagement.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.