if(!window.Packlink){window.Packlink={}}(function(){function AjaxService(){this.get=function(url,onSuccess,onError){this.call('GET',url,{},onSuccess,onError)};this.post=function(url,data,onSuccess,onError){this.call('POST',url,data,onSuccess,onError)};this.call=function(method,url,data,onSuccess,onError){const request=getRequest();const callUUID=Packlink.StateUUIDService.getStateUUID();if(!onError){onError=Packlink.responseService.errorHandler}
url=url.replace('https:','');url=url.replace('http:','');request.open(method,url,!0);request.onreadystatechange=function(){if(this.readyState===4){if(callUUID!==Packlink.StateUUIDService.getStateUUID()){return}
if(this.status>=200&&this.status<300){if(onSuccess){onSuccess(JSON.parse(this.responseText||'{}'))}}else if(onError){let response=this.responseText;try{response=JSON.parse(this.responseText||'{}')}catch(e){}
onError(response)}}};request.setRequestHeader('Accept','application/json');if(method==='POST'){this.internalPerformPost(request,data)}else{request.send()}};this.internalPerformPost=function(request,data){request.setRequestHeader('Content-Type','application/json');request.send(JSON.stringify(data))};function getRequest(){let versions=['MSXML2.XmlHttp.6.0','MSXML2.XmlHttp.5.0','MSXML2.XmlHttp.4.0','MSXML2.XmlHttp.3.0','MSXML2.XmlHttp.2.0','Microsoft.XmlHttp'],xhr;if(typeof XMLHttpRequest!=='undefined'){return new XMLHttpRequest()}
for(let version of versions){try{xhr=new ActiveXObject(version);break}catch(e){}}
return xhr}}
Packlink.ajaxService=new AjaxService()})()