export const SecureRequestXhr=function(e){return class extends e{setCookies(e,t){this._eraseCookie("securerequest-endpoint"),this._eraseCookie("securerequest-csrftoken"),this._createCookie("securerequest-endpoint",e,30,e),this._createCookie("securerequest-csrftoken",t,30,e)}generateUrl(e){const t=this.getEndPoint(),r=this.getCsrfToken();return t&&r?t+e+"?token="+r:null}getEndPoint(){return this._readCookie("securerequest-endpoint")}getCsrfToken(){return this._readCookie("securerequest-csrftoken")}_createCookie(e,t,r,o){var s="";if(r){var i=new Date;i.setTime(i.getTime()+24*r*60*60*1e3),s="; expires="+i.toUTCString()}globalThis.document.cookie=e+"="+t+s+"; path="+o}_readCookie(e){for(var t=e+"=",r=globalThis.document.cookie.split(";"),o=0;o<r.length;o++){for(var s=r[o];" "==s.charAt(0);)s=s.substring(1,s.length);if(0==s.indexOf(t))return s.substring(t.length,s.length)}return null}_eraseCookie(e){this._createCookie(e,"",-1)}}};globalThis.SecureRequest=globalThis.SecureRequest||{},globalThis.SecureRequest.xhr={setCookies(e,t){this._eraseCookie("securerequest-endpoint"),this._eraseCookie("securerequest-csrftoken"),this._createCookie("securerequest-endpoint",e,30,e),this._createCookie("securerequest-csrftoken",t,30,e)},generateUrl(e){const t=this.getEndPoint(),r=this.getCsrfToken();return t&&r?t+e+"?token="+r:null},getEndPoint(){return this._readCookie("securerequest-endpoint")},getCsrfToken(){return this._readCookie("securerequest-csrftoken")},_createCookie(e,t,r,o){var s="";if(r){var i=new Date;i.setTime(i.getTime()+24*r*60*60*1e3),s="; expires="+i.toUTCString()}globalThis.document.cookie=e+"="+t+s+"; path="+o},_readCookie(e){for(var t=e+"=",r=globalThis.document.cookie.split(";"),o=0;o<r.length;o++){for(var s=r[o];" "==s.charAt(0);)s=s.substring(1,s.length);if(0==s.indexOf(t))return s.substring(t.length,s.length)}return null},_eraseCookie(e){this._createCookie(e,"",-1)}};