ngx-soap
Version:
SOAP service for Angular
2 lines • 47.7 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("sax"),require("lodash"),require("crypto-js/sha1"),require("crypto-js/enc-base64"),require("buffer"),require("url"),require("assert"),require("uuid/v4"),require("rxjs"),require("rxjs/operators"),require("@angular/common/http")):"function"==typeof define&&define.amd?define("ngx-soap",["exports","@angular/core","sax","lodash","crypto-js/sha1","crypto-js/enc-base64","buffer","url","assert","uuid/v4","rxjs","rxjs/operators","@angular/common/http"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["ngx-soap"]={},e.ng.core,e.sax,e._,e.sha1,e.Base64,e.buffer,e.url,e.assert,e.uuid4,e.rxjs,e.rxjs.operators,e.ng.common.http)}(this,(function(e,t,s,n,i,o,r,a,p,c,u,l,h){"use strict";function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=d(i),m=d(o),y=d(c);function v(e,t,s,n){return new(s||(s=Promise))((function(i,o){function r(e){try{p(n.next(e))}catch(e){o(e)}}function a(e){try{p(n.throw(e))}catch(e){o(e)}}function p(e){var t;e.done?i(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(r,a)}p((n=n.apply(e,t||[])).next())}))}function g(e,t){var s,n,i,o,r={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(s)throw new TypeError("Generator is already executing.");for(;r;)try{if(s=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return r.label++,{value:o[1],done:!1};case 5:r.label++,n=o[1],o=[0];continue;case 7:o=r.ops.pop(),r.trys.pop();continue;default:if(!(i=r.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){r=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){r.label=o[1];break}if(6===o[0]&&r.label<i[1]){r.label=i[1],i=o;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(o);break}i[2]&&r.ops.pop(),r.trys.pop();continue}o=t.call(e,r)}catch(e){o=[6,e],n=0}finally{s=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}Object.create;function x(e){var t="function"==typeof Symbol&&Symbol.iterator,s=t&&e[t],n=0;if(s)return s.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}Object.create;var b=function e(t){if(this.getNamespaceURI=function(e,t){switch(e){case"xml":return"http://www.w3.org/XML/1998/namespace";case"xmlns":return"http://www.w3.org/2000/xmlns/";default:var s=this.namespaces[e];return null!=s?s.uri:!t&&this.parent?this.parent.getNamespaceURI(e):null}},this.getNamespaceMapping=function(e){switch(e){case"xml":return{uri:"http://www.w3.org/XML/1998/namespace",prefix:"xml",declared:!0};case"xmlns":return{uri:"http://www.w3.org/2000/xmlns/",prefix:"xmlns",declared:!0};default:var t=this.namespaces[e];return null!=t?t:this.parent?this.parent.getNamespaceMapping(e):null}},this.getPrefix=function(e,t){switch(e){case"http://www.w3.org/XML/1998/namespace":return"xml";case"http://www.w3.org/2000/xmlns/":return"xmlns";default:for(var s in this.namespaces)if(this.namespaces[s].uri===e)return s;return!t&&this.parent?this.parent.getPrefix(e):null}},!(this instanceof e))return new e(t);this.parent=t,this.namespaces={}},w=function e(){if(this.addNamespace=function(e,t,s){return this.getNamespaceURI(e,s)!==t&&!!this.currentScope&&(this.currentScope.namespaces[e]={uri:t,prefix:e,declared:!1},!0)},this.pushContext=function(){var e=new b(this.currentScope);return this.scopes.push(e),this.currentScope=e,e},this.popContext=function(){var e=this.scopes.pop();return this.currentScope=e?e.parent:null,e},this.getNamespaceURI=function(e,t){return this.currentScope&&this.currentScope.getNamespaceURI(e,t)},this.getPrefix=function(e,t){return this.currentScope&&this.currentScope.getPrefix(e,t)},this.registerNamespace=function(e){var t=this.getPrefix(e);if(t)return t;for(;t="ns"+ ++this.prefixCount,this.getNamespaceURI(t););return this.addNamespace(t,e,!0),t},this.declareNamespace=function(e,t){if(this.currentScope){var s=this.currentScope.getNamespaceMapping(e);return!(s&&s.uri===t&&s.declared||(this.currentScope.namespaces[e]={uri:t,prefix:e,declared:!0},0))}return!1},!(this instanceof e))return new e;this.scopes=[],this.pushContext(),this.prefixCount=0},S="__tns__",$=function(e,t){for(var s in e)if(s!==S&&e[s]===t)return s},T=function(e){return 65279===e.charCodeAt(0)?e.slice(1):e},C=S,_=$,N={string:1,boolean:1,decimal:1,float:1,double:1,anyType:1,byte:1,int:1,long:1,short:1,negativeInteger:1,nonNegativeInteger:1,positiveInteger:1,nonPositiveInteger:1,unsignedByte:1,unsignedInt:1,unsignedLong:1,unsignedShort:1,duration:0,dateTime:0,time:0,date:0,gYearMonth:0,gYear:0,gMonthDay:0,gDay:0,gMonth:0,hexBinary:0,base64Binary:0,anyURI:0,QName:0,NOTATION:0};function j(e){var t="string"==typeof e?e.indexOf(":"):-1;return t<0?{prefix:C,name:e}:{prefix:e.substring(0,t),name:e.substring(t+1)}}function A(e){return"string"==typeof e?"<![CDATA["===e.substr(0,9)&&"]]>"===e.substr(-3)?e:e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"):e}var O=/^[\s\xA0]+/,E=/[\s\xA0]+$/;function P(e){return e.replace(O,"").replace(E,"")}var L=function(e,t,s){var n=j(e);for(var i in this.nsName=e,this.prefix=n.prefix,this.name=n.name,this.children=[],this.xmlns={},this._initializeOptions(s),t){var o=/^xmlns:?(.*)$/.exec(i);o?this.xmlns[o[1]?o[1]:C]=t[i]:"value"===i?this[this.valueKey]=t[i]:this["$"+i]=t[i]}void 0!==this.$targetNamespace&&(this.xmlns.__tns__=this.$targetNamespace)};L.prototype._initializeOptions=function(e){e?(this.valueKey=e.valueKey||"$value",this.xmlKey=e.xmlKey||"$xml",this.ignoredNamespaces=e.ignoredNamespaces||[]):(this.valueKey="$value",this.xmlKey="$xml",this.ignoredNamespaces=[])},L.prototype.deleteFixedAttrs=function(){this.children&&0===this.children.length&&delete this.children,this.xmlns&&0===Object.keys(this.xmlns).length&&delete this.xmlns,delete this.nsName,delete this.prefix,delete this.name},L.prototype.allowedChildren=[],L.prototype.startElement=function(e,t,s,n){if(this.allowedChildren){var i=this.allowedChildren[j(t).name];i?e.push(new i(t,s,n)):this.unexpected(t)}},L.prototype.endElement=function(e,t){if(this.nsName===t){if(e.length<2)return;var s=e[e.length-2];this!==e[0]&&(n.defaultsDeep(e[0].xmlns,this.xmlns),s.children.push(this),s.addChild(this)),e.pop()}},L.prototype.addChild=function(e){},L.prototype.unexpected=function(e){throw new Error("Found unexpected element ("+e+") inside "+this.nsName)},L.prototype.description=function(e){return this.$name||this.name},L.prototype.init=function(){},L.createSubClass=function(){var e=this,t=function(){e.apply(this,arguments),this.init()};return t.prototype.__proto__=e.prototype,t};var k=L.createSubClass(),M=L.createSubClass(),H=L.createSubClass(),I=L.createSubClass(),F=L.createSubClass(),B=L.createSubClass(),K=L.createSubClass(),R=L.createSubClass(),X=L.createSubClass(),D=L.createSubClass(),q=L.createSubClass(),U=L.createSubClass(),z=L.createSubClass(),W=L.createSubClass(),Y=L.createSubClass(),G=L.createSubClass(),J=L.createSubClass(),Q=L.createSubClass(),Z=L.createSubClass(),V=L.createSubClass(),ee=L.createSubClass(),te=L.createSubClass(),se=L.createSubClass(),ne=L.createSubClass(),ie={types:[Q,"schema documentation"],schema:[J,"element complexType simpleType include import"],element:[k,"annotation complexType"],any:[M,""],simpleType:[F,"restriction"],restriction:[B,"enumeration all choice sequence"],extension:[K,"all sequence choice"],choice:[R,"element sequence choice any"],enumeration:[X,""],complexType:[D,"annotation sequence all complexContent simpleContent choice"],complexContent:[q,"extension"],simpleContent:[U,"extension"],sequence:[z,"element sequence choice any"],all:[W,"element choice"],service:[se,"port documentation"],port:[te,"address documentation"],binding:[ee,"_binding SecuritySpec operation documentation"],portType:[V,"operation documentation"],message:[Y,"part documentation"],operation:[Z,"documentation input output fault _operation"],input:[H,"body SecuritySpecRef documentation header"],output:[I,"body SecuritySpecRef documentation header"],fault:[L,"_fault documentation"],definitions:[ne,"types message portType binding service import documentation"],documentation:[G,""]};function oe(e){var t={};return(e=e.split(" ")).forEach((function(e){t[e.replace(/^_/,"")]=(ie[e]||[L])[0]})),t}for(var re in ie){var ae=ie[re];ae[0].prototype.allowedChildren=oe(ae[1])}Y.prototype.init=function(){this.element=null,this.parts=null},J.prototype.init=function(){this.complexTypes={},this.types={},this.elements={},this.includes=[]},Q.prototype.init=function(){this.schemas={}},Z.prototype.init=function(){this.input=null,this.output=null,this.inputSoap=null,this.outputSoap=null,this.style="",this.soapAction=""},V.prototype.init=function(){this.methods={}},ee.prototype.init=function(){this.transport="",this.style="",this.methods={}},te.prototype.init=function(){this.location=null},se.prototype.init=function(){this.ports={}},ne.prototype.init=function(){"definitions"!==this.name&&this.unexpected(this.nsName),this.messages={},this.portTypes={},this.bindings={},this.services={},this.schemas={}},G.prototype.init=function(){},J.prototype.merge=function(e){return p.ok(e instanceof J),this.$targetNamespace===e.$targetNamespace&&(n.merge(this.complexTypes,e.complexTypes),n.merge(this.types,e.types),n.merge(this.elements,e.elements),n.merge(this.xmlns,e.xmlns)),this},J.prototype.addChild=function(e){if(!(e.$name in N)){if("include"===e.name||"import"===e.name){var t=e.$schemaLocation||e.$location;t&&this.includes.push({namespace:e.$namespace||e.$targetNamespace||this.$targetNamespace,location:t})}else"complexType"===e.name?this.complexTypes[e.$name]=e:"element"===e.name?this.elements[e.$name]=e:e.$name&&(this.types[e.$name]=e);this.children.pop()}},Q.prototype.addChild=function(e){p.ok(e instanceof J);var t=e.$targetNamespace;this.schemas.hasOwnProperty(t)?console.error('Target-Namespace "'+t+'" already in use by another Schema!'):this.schemas[t]=e},H.prototype.addChild=function(e){"body"===e.name&&(this.use=e.$use,"encoded"===this.use&&(this.encodingStyle=e.$encodingStyle),this.children.pop())},I.prototype.addChild=function(e){"body"===e.name&&(this.use=e.$use,"encoded"===this.use&&(this.encodingStyle=e.$encodingStyle),this.children.pop())},Z.prototype.addChild=function(e){"operation"===e.name&&(this.soapAction=e.$soapAction||"",this.style=e.$style||"",this.children.pop())},ee.prototype.addChild=function(e){"binding"===e.name&&(this.transport=e.$transport,this.style=e.$style,this.children.pop())},te.prototype.addChild=function(e){"address"===e.name&&void 0!==e.$location&&(this.location=e.$location)},ne.prototype.addChild=function(e){var t=this;e instanceof Q?n.merge(t.schemas,e.schemas):e instanceof Y?t.messages[e.$name]=e:"import"===e.name?(t.schemas[e.$namespace]=new J(e.$namespace,{}),t.schemas[e.$namespace].addChild(e)):e instanceof V?t.portTypes[e.$name]=e:e instanceof ee?"http://schemas.xmlsoap.org/soap/http"!==e.transport&&"http://www.w3.org/2003/05/soap/bindings/HTTP/"!==e.transport||(t.bindings[e.$name]=e):e instanceof se&&(t.services[e.$name]=e),this.children.pop()},Y.prototype.postProcess=function(e){var t=null,s=void 0,n=this.children||[],i=void 0,o=void 0,r=void 0,a=void 0;for(r in n)if("part"===(s=n[r]).name){t=s;break}if(t){if(t.$element){var c,u=[];delete this.parts,i=(o=j(t.$element)).prefix;var l=e.schemas[e.xmlns[i]];if(this.element=l.elements[o.name],!this.element)return;if(this.element.targetNSAlias=i,this.element.targetNamespace=e.xmlns[i],this.element.$lookupType=t.$element,(c=this.element.children).length>0)for(r=0;r<c.length;r++)u.push(this._getNestedLookupTypeString(c[r]));if(u.length>0){u=u.join("_").split("_").filter((function(e){return"^"!==e}));var h=e.schemas[this.element.targetNamespace].xmlns;for(r=0;r<u.length;r++)u[r]=this._createLookupTypeObject(u[r],h)}if(this.element.$lookupTypes=u,this.element.$type){a=j(this.element.$type);var d=l.xmlns&&l.xmlns[a.prefix]||e.xmlns[a.prefix];if(d)if(a.name in N);else{var f=(l=e.schemas[d]).complexTypes[a.name]||l.types[a.name]||l.elements[a.name];f&&(this.parts=f.description(e,l.xmlns))}}else{var m=this.element.description(e,l.xmlns);this.parts=m[o.name]}this.children.splice(0,1)}else for(this.parts={},delete this.element,r=0;t=this.children[r];r++)if("documentation"!==t.name){p.ok("part"===t.name,"Expected part element"),o=j(t.$type),i=e.xmlns[o.prefix],a=o.name;var y=e.schemas[i];this.parts[t.$name]=void 0!==y?e.schemas[i].types[a]||e.schemas[i].complexTypes[a]:t.$type,"object"==typeof this.parts[t.$name]&&(this.parts[t.$name].prefix=o.prefix,this.parts[t.$name].xmlns=i),this.children.splice(r--,1)}this.deleteFixedAttrs()}},Y.prototype._createLookupTypeObject=function(e,t){var s=j(e),n=s.prefix,i=s.name.split("#"),o=i[0],r=i[1],a={};return a.$namespace=t[n],a.$type=n+":"+o,a.$name=r,a},Y.prototype._getNestedLookupTypeString=function(e){var t="^",s=this.ignoredNamespaces.concat("xs");if(e.hasOwnProperty("$type")&&"string"==typeof e.$type&&-1===s.indexOf(e.$type.split(":")[0])&&(t+="_"+e.$type+"#"+e.$name),e.children.length>0){var n=this;e.children.forEach((function(e){var s=n._getNestedLookupTypeString(e).replace(/\^_/,"");s&&"string"==typeof s&&(t+="_"+s)}))}return t},Z.prototype.postProcess=function(e,t){for(var s=this.children,n=0,i=void 0;i=s[n];n++)if("input"===i.name||"output"===i.name)if("binding"!==t){var o=j(i.$message).name,r=e.messages[o];r.postProcess(e),r.element?(e.messages[r.element.$name]=r,this[i.name]=r.element):this[i.name]=r,s.splice(n--,1)}else this[i.name]=i,s.splice(n--,1);this.deleteFixedAttrs()},V.prototype.postProcess=function(e){var t=this.children;if(void 0!==t){for(var s=0,n=void 0;n=t[s];s++)"operation"===n.name&&(n.postProcess(e,"portType"),this.methods[n.$name]=n,t.splice(s--,1));delete this.$name,this.deleteFixedAttrs()}},ee.prototype.postProcess=function(e){var t=j(this.$type).name,s=e.portTypes[t],n=this.style,i=this.children;if(s){s.postProcess(e),this.methods=s.methods;for(var o=0,r=void 0;r=i[o];o++)if("operation"===r.name){r.postProcess(e,"binding"),i.splice(o--,1),r.style||(r.style=n);var a=this.methods[r.$name];a&&(a.style=r.style,a.soapAction=r.soapAction,a.inputSoap=r.input||null,a.outputSoap=r.output||null,a.inputSoap&&a.inputSoap.deleteFixedAttrs(),a.outputSoap&&a.outputSoap.deleteFixedAttrs())}}delete this.$name,delete this.$type,this.deleteFixedAttrs()},se.prototype.postProcess=function(e){var t=this.children,s=e.bindings;if(t&&t.length>0)for(var n=0,i=void 0;i=t[n];n++)if("port"===i.name){var o=s[j(i.$binding).name];o&&(o.postProcess(e),this.ports[i.$name]={location:i.location,binding:o},t.splice(n--,1))}delete this.$name,this.deleteFixedAttrs()},F.prototype.description=function(e){for(var t=this.children,s=0,n=void 0;n=t[s];s++)if(n instanceof B)return this.$name+"|"+n.description();return{}},B.prototype.description=function(e,t){for(var s,n=this.children,i=0,o=void 0;o=n[i];i++)if(o instanceof z||o instanceof R){s=o.description(e,t);break}if(s&&this.$base){var r=j(this.$base),a=r.name,p=t&&t[r.prefix]||e.xmlns[r.prefix],c=e.schemas[p],u=c&&(c.complexTypes[a]||c.types[a]||c.elements[a]);return s.getBase=function(){return u.description(e,c.xmlns)},s}return(this.$base?this.$base+"|":"")+this.children.map((function(e){return e.description()})).join(",")},K.prototype.description=function(e,t){for(var s=this.children,i={},o=0,r=void 0;r=s[o];o++)(r instanceof z||r instanceof R)&&(i=r.description(e,t));if(this.$base){var a=j(this.$base),p=a.name,c=t&&t[a.prefix]||e.xmlns[a.prefix],u=e.schemas[c];if(p in N)return this.$base;var l=u&&(u.complexTypes[p]||u.types[p]||u.elements[p]);if(l){var h=l.description(e,u.xmlns);i=n.defaultsDeep(h,i)}}return i},X.prototype.description=function(){return this[this.valueKey]},D.prototype.description=function(e,t){for(var s=this.children||[],n=0,i=void 0;i=s[n];n++)if(i instanceof R||i instanceof z||i instanceof W||i instanceof U||i instanceof q)return i.description(e,t);return{}},q.prototype.description=function(e,t){for(var s=this.children,n=0,i=void 0;i=s[n];n++)if(i instanceof K)return i.description(e,t);return{}},U.prototype.description=function(e,t){for(var s=this.children,n=0,i=void 0;i=s[n];n++)if(i instanceof K)return i.description(e,t);return{}},k.prototype.description=function(e,t){var s={},n=this.$name,i=!!this.$maxOccurs&&(isNaN(this.$maxOccurs)?"unbounded"===this.$maxOccurs:this.$maxOccurs>1);this.$minOccurs!==this.$maxOccurs&&i&&(n+="[]"),t&&t.__tns__&&(this.$targetNamespace=t.__tns__);var o=this.$type||this.$ref;if(o){var r=(o=j(o)).name,a=t&&t[o.prefix]||e.xmlns[o.prefix],p=e.schemas[a],c=p&&(this.$type?p.complexTypes[r]||p.types[r]:p.elements[r]);if(a&&e.schemas[a]&&(t=e.schemas[a].xmlns),c&&!(r in N))if(r in e.descriptions.types)this.$ref?s=e.descriptions.types[r]:s[n]=e.descriptions.types[r];else{var u={};e.descriptions.types[r]=u;var l=c.description(e,t);"string"==typeof l?u=l:Object.keys(l).forEach((function(e){u[e]=l[e]})),this.$ref?s=u:s[n]=u,"object"==typeof u&&(u.targetNSAlias=o.prefix,u.targetNamespace=a),e.descriptions.types[r]=u}else s[n]=this.$type}else{var h=this.children;s[n]={};for(var d=0,f=void 0;f=h[d];d++)f instanceof D&&(s[n]=f.description(e,t))}return s},W.prototype.description=z.prototype.description=function(e,t){for(var s=this.children,n={},i=0,o=void 0;o=s[i];i++)if(!(o instanceof M)){var r=o.description(e,t);for(var a in r)n[a]=r[a]}return n},R.prototype.description=function(e,t){for(var s=this.children,n={},i=0,o=void 0;o=s[i];i++){var r=o.description(e,t);for(var a in r)n[a]=r[a]}return n},Y.prototype.description=function(e){if(this.element)return this.element&&this.element.description(e);var t={};return t[this.$name]=this.parts,t},V.prototype.description=function(e){var t={};for(var s in this.methods){var n=this.methods[s];t[s]=n.description(e)}return t},Z.prototype.description=function(e){var t=this.input?this.input.description(e):null,s=this.output?this.output.description(e):null;return{input:t&&t[Object.keys(t)[0]],output:s&&s[Object.keys(s)[0]]}},ee.prototype.description=function(e){var t={};for(var s in this.methods){var n=this.methods[s];t[s]=n.description(e)}return t},se.prototype.description=function(e){var t={};for(var s in this.ports){var n=this.ports[s];t[s]=n.binding.description(e)}return t};var pe=function(e,t,s){var n,i=this;if(this.uri=t,this.callback=function(){},this._includesWsdl=[],this.WSDL_CACHE=(s||{}).WSDL_CACHE||{},this._initializeOptions(s),"string"==typeof e)e=T(e),n=this._fromXML;else{if("object"!=typeof e)throw new Error("WSDL letructor takes either an XML string or service definition");n=this._fromServices}Promise.resolve(!0).then((function(){try{n.call(i,e)}catch(e){return i.callback(e.message)}i.processIncludes().then((function(){i.definitions.deleteFixedAttrs();var e=i.services=i.definitions.services;if(e)for(var t in e)e[t].postProcess(i.definitions);var s=i.definitions.complexTypes;if(s)for(var t in s)s[t].deleteFixedAttrs();var n=i.definitions.bindings;for(var o in n){var r=n[o];if(void 0===r.style&&(r.style="document"),"document"===r.style){var a=r.methods,p=r.topElements={};for(var c in a)if(a[c].input){var u=a[c].input.$name,l="";a[c].output&&(l=a[c].output.$name),p[u]={methodName:c,outputName:l}}}}i.xmlnsInEnvelope=i._xmlnsMap(),i.callback(null,i)})).catch((function(e){return i.callback(e)}))}))};function ce(e){return e&&":"!==e.charAt(e.length-1)?e+":":e}function ue(e){return e&&":"===e.charAt(e.length-1)?e.substring(0,e.length-1):e}function le(e,t){var s;return(s=t.WSDL_CACHE[e])?s:he(e,t)}function he(e,t){return v(this,void 0,void 0,(function(){var s,n;return g(this,(function(i){switch(i.label){case 0:return s=t.WSDL_CACHE||{},t.wsdl_headers,t.wsdl_options,[4,t.httpClient.get(e,{responseType:"text"}).toPromise()];case 1:return n=i.sent(),[4,new Promise((function(i){var o=new pe(n,e,t);s[e]=o,o.WSDL_CACHE=s,o.onReady(i(o))}))];case 2:return[2,i.sent()]}}))}))}function de(e,t,s){this._username=e,this._password=t,this.defaults={},n.merge(this.defaults,s)}pe.prototype.ignoredNamespaces=["tns","targetNamespace","typedNamespace"],pe.prototype.ignoreBaseNameSpaces=!1,pe.prototype.valueKey="$value",pe.prototype.xmlKey="$xml",pe.prototype._initializeOptions=function(e){this._originalIgnoredNamespaces=(e||{}).ignoredNamespaces,this.options={};var t=e?e.ignoredNamespaces:null;t&&(Array.isArray(t.namespaces)||"string"==typeof t.namespaces)?t.override?this.options.ignoredNamespaces=t.namespaces:this.options.ignoredNamespaces=this.ignoredNamespaces.concat(t.namespaces):this.options.ignoredNamespaces=this.ignoredNamespaces,this.options.valueKey=e.valueKey||this.valueKey,this.options.xmlKey=e.xmlKey||this.xmlKey,void 0!==e.escapeXML?this.options.escapeXML=e.escapeXML:this.options.escapeXML=!0,void 0!==e.returnFault?this.options.returnFault=e.returnFault:this.options.returnFault=!1,this.options.handleNilAsNull=!!e.handleNilAsNull,void 0!==e.namespaceArrayElements?this.options.namespaceArrayElements=e.namespaceArrayElements:this.options.namespaceArrayElements=!0,this.options.wsdl_headers=e.wsdl_headers,this.options.wsdl_options=e.wsdl_options,e.httpClient&&(this.options.httpClient=e.httpClient),e.request&&(this.options.request=e.request);var s=e?e.ignoreBaseNameSpaces:null;this.options.ignoreBaseNameSpaces=null!=s?s:this.ignoreBaseNameSpaces,this.options.forceSoap12Headers=e.forceSoap12Headers,this.options.customDeserializer=e.customDeserializer,void 0!==e.overrideRootElement&&(this.options.overrideRootElement=e.overrideRootElement),this.options.useEmptyTag=!!e.useEmptyTag},pe.prototype.onReady=function(e){e&&(this.callback=e)},pe.prototype._processNextInclude=function(e){return v(this,void 0,void 0,(function(){var t,s,i,o,r;return g(this,(function(p){switch(p.label){case 0:return t=this,(s=e.shift())?((/^https?:/.test(t.uri)||/^https?:/.test(s.location))&&(o=a.resolve(t.uri||"",s.location)),(i=n.assign({},this.options)).ignoredNamespaces=this._originalIgnoredNamespaces||this.options.ignoredNamespaces,i.WSDL_CACHE=this.WSDL_CACHE,[4,le(o,i)]):[2];case 1:return r=p.sent(),t._includesWsdl.push(r),r.definitions instanceof ne?n.mergeWith(t.definitions,r.definitions,(function(e,t){return e instanceof J?e.merge(t):void 0})):t.definitions.schemas[s.namespace||r.definitions.$targetNamespace]=(c=t.definitions.schemas[s.namespace||r.definitions.$targetNamespace],u=r.definitions,n.mergeWith(c||{},u,(function(e,t){return n.isArray(e)?e.concat(t):void 0}))),[2,t._processNextInclude(e)]}var c,u}))}))},pe.prototype.processIncludes=function(){return v(this,void 0,void 0,(function(){var e,t,s,n;return g(this,(function(i){for(s in e=this.definitions.schemas,t=[],e)n=e[s],t=t.concat(n.includes||[]);return[2,this._processNextInclude(t)]}))}))},pe.prototype.describeServices=function(){var e={};for(var t in this.services){var s=this.services[t];e[t]=s.description(this.definitions)}return e},pe.prototype.toXML=function(){return this.xml||""},pe.prototype.xmlToObject=function(e,t){var i,o=this,r="function"==typeof t?{}:s.parser(!0),a=null,p={},c=[{name:null,object:p,schema:{Envelope:{Header:{Security:{UsernameToken:{Username:"string",Password:"string"}}},Body:{Fault:{faultcode:"string",faultstring:"string",detail:"string"}}}}}],u={},l={};if(r.onopentag=function(e){var t,s,n=e.name,p=e.attributes,h=j(n).name,d=c[c.length-1],f=d.schema,m={},y=!1,v=!1,g={},x=h;if(!a&&"Body"===d.name&&"Fault"!==h){var b=o.definitions.messages[h];if(!b)try{var w=!1;/Response$/.test(h)?(!0,h=h.replace(/Response$/,"")):/Request$/.test(h)?(w=!0,h=h.replace(/Request$/,"")):/Solicit$/.test(h)&&(w=!0,h=h.replace(/Solicit$/,""));var S=o.definitions.portTypes,$=S[Object.keys(S)[0]];h=w?$.methods[h].input.$name:$.methods[h].output.$name,b=o.definitions.messages[h],o.definitions.messages[x]=o.definitions.messages[h]}catch(e){o.options.returnFault&&r.onerror(e)}f=b.description(o.definitions),a=x}for(t in p.href&&(i=p.href.substr(1),l[i]||(l[i]={hrefs:[],obj:null}),l[i].hrefs.push({par:d.object,key:h,obj:g})),(i=p.id)&&(l[i]||(l[i]={hrefs:[],obj:null})),p)/^xmlns:|^xmlns$/.test(t)?u[j(t).name]=p[t]:(y=!0,m[t]=p[t]);for(t in m){var T=j(t);if("nil"===T.name&&"http://www.w3.org/2001/XMLSchema-instance"===u[T.prefix]&&m[t]&&("true"===m[t].toLowerCase()||"1"===m[t])){v=!0;break}}y&&(g[o.options.attributesKey]=m);var _=m["xsi:type"];if(_){var N=j(_),A=void 0;A=N.prefix===C?u[N.prefix]||u.xmlns:u[N.prefix];var O=o.findSchemaObject(A,N.name);O&&(s=O.description(o.definitions))}f&&f[h+"[]"]&&(h+="[]"),c.push({name:x,object:g,schema:s||f&&f[h],id:p.id,nil:v})},r.onclosetag=function(e){var t=c.pop(),s=t.object,i=c[c.length-1],r=i.object,a=i.schema,p=j(e).name;if("string"!=typeof t.schema||"string"!==t.schema&&"string"!==t.schema.split(":")[1]||"object"==typeof s&&0===Object.keys(s).length&&(s=t.object=""),!0===t.nil){if(!o.options.handleNilAsNull)return;s=null}n.isPlainObject(s)&&!Object.keys(s).length&&(s=null),a&&a[p+"[]"]?(r[p]||(r[p]=[]),r[p].push(s)):p in r?(Array.isArray(r[p])||(r[p]=[r[p]]),r[p].push(s)):r[p]=s,t.id&&(l[t.id].obj=s)},r.oncdata=function(e){var t=e;if((e=P(e)).length)if(/<\?xml[\s\S]+\?>/.test(e)){var s=c[c.length-1],n=o.xmlToObject(e);s.object[o.options.attributesKey]?s.object[o.options.valueKey]=n:s.object=n}else r.ontext(t)},r.onerror=function(e){throw r.resume(),{Fault:{faultcode:500,faultstring:"Invalid XML",detail:new Error(e).message,statusCode:500}}},r.ontext=function(e){var t=e;if((e=P(e)).length){var s,n=c[c.length-1],i=j(n.schema).name;o.options&&o.options.customDeserializer&&o.options.customDeserializer[i]?s=o.options.customDeserializer[i](e,n):"int"===i||"integer"===i?s=parseInt(e,10):"bool"===i||"boolean"===i?s="true"===e.toLowerCase()||"1"===e:"dateTime"===i||"date"===i?s=new Date(e):(o.options.preserveWhitespace&&(e=t),s="string"!=typeof n.object?e:n.object+e),n.object[o.options.attributesKey]?n.object[o.options.valueKey]=s:n.object=s}},"function"==typeof t){var h=s.createStream(!0);return h.on("opentag",r.onopentag),h.on("closetag",r.onclosetag),h.on("cdata",r.oncdata),h.on("text",r.ontext),void e.pipe(h).on("error",(function(e){t(e)})).on("end",(function(){var e;try{e=d()}catch(e){return t(e)}t(null,e)}))}return r.write(e).close(),d();function d(){for(var e in l)for(var t=l[e],s=0;s<t.hrefs.length;s++)n.assign(t.hrefs[s].obj,t.obj);if(p.Envelope){var i=p.Envelope.Body;if(i&&i.Fault){var o=i.Fault.faultcode&&i.Fault.faultcode.$value,r=i.Fault.faultstring&&i.Fault.faultstring.$value,a=i.Fault.detail&&i.Fault.detail.$value;o=o||i.Fault.faultcode,r=r||i.Fault.faultstring,a=a||i.Fault.detail;var c=new Error(o+": "+r+(a?": "+a:""));throw c.root=p,c}return p.Envelope}return p}},pe.prototype.findSchemaObject=function(e,t){if(!e||!t)return null;var s=null;if(this.definitions.schemas){var n=this.definitions.schemas[e];n&&(-1!==t.indexOf(":")&&(t=t.substring(t.indexOf(":")+1,t.length)),s=n.complexTypes[t]||n.types[t]||n.elements[t])}return s},pe.prototype.objectToDocumentXML=function(e,t,s,n,i){if(t&&t._xml)return t._xml;var o={};o[e]=t;var r=i?this.findSchemaObject(n,i):null;return this.objectToXML(o,null,s,n,!0,null,r)},pe.prototype.objectToRpcXML=function(e,t,s,n,i){var o=[],r=this.definitions;for(var a in s=s||_(r.xmlns,n),n=n||r.xmlns[s],s=s===C?"":s+":",o.push(["<",s,e,">"].join("")),t)if(t.hasOwnProperty(a)&&"_xmlns"!==a){var p=t[a],c=(i?"":s)+a,u=[];if("object"==typeof p&&p.hasOwnProperty(this.options.attributesKey)){var l=p[this.options.attributesKey];for(var h in l)u.push(" "+h+'="'+l[h]+'"')}o.push(["<",c].concat(u).concat(">").join("")),o.push("object"==typeof p?this.objectToXML(p,a,s,n):A(p)),o.push(["</",c,">"].join(""))}return o.push(["</",s,e,">"].join("")),o.join("")},pe.prototype.isIgnoredNameSpace=function(e){return this.options.ignoredNamespaces.indexOf(e)>-1},pe.prototype.filterOutIgnoredNameSpace=function(e){var t=ue(e);return this.isIgnoredNameSpace(t)?"":t},pe.prototype.objectToXML=function(e,t,s,n,i,o,r,a){var p=this.definitions.schemas[n],c=s?s.parent:void 0;void 0!==c&&(s=s.current),c=ue(c),this.isIgnoredNameSpace(c)&&(c="");var u=!p,l=p&&"qualified"===p.$elementFormDefault,h=[],d=(s||l)&&s!==C,f="";n&&i&&(this.options.overrideRootElement&&this.options.overrideRootElement.xmlnsAttributes?this.options.overrideRootElement.xmlnsAttributes.forEach((function(e){f+=" "+e.name+'="'+e.value+'"'})):(d&&!this.isIgnoredNameSpace(s)&&(f+=" xmlns:"+s+'="'+n+'"'),(l||u)&&(f+=' xmlns="'+n+'"'))),a?a.pushContext():(a=new w).declareNamespace(s,n),!o||this.options.overrideRootElement&&this.options.overrideRootElement.xmlnsAttributes||(f=o);var m,y,v="";if(this.options.overrideRootElement&&i?v=this.options.overrideRootElement.namespace:d&&(l||i||u)&&!this.isIgnoredNameSpace(s)&&(v=s),Array.isArray(e)){var g="",x=!1;for((O=/^([^:]+):([^:]+)$/.exec(t))?(g=O[1],t=O[2]):":"===t[0]&&(x=!0,t=t.substr(1)),m=0,y=e.length;m<y;m++){var b=e[m],S=this.processAttributes(b,a),$=g||c||v,T=this.objectToXML(b,t,s,n,!1,null,r,a),_=["<",t,S,f];x||(_=["<",ce($),t,S,f]),""===T&&this.options.useEmptyTag?(_.push(" />"),h.push(_.join(""))):(_.push(">"),(this.options.namespaceArrayElements||0===m)&&h.push(_.join("")),h.push(T),(this.options.namespaceArrayElements||m===y-1)&&(x?h.push(["</",t,">"].join("")):h.push(["</",ce($),t,">"].join(""))))}}else if("object"==typeof e){for(t in e)if(e.hasOwnProperty(t)&&t!==this.options.attributesKey){if(t===this.options.xmlKey)return a.popContext(),e[t];if(t===this.options.valueKey)return a.popContext(),A(e[t]);var N=e[t];if(void 0!==N){var O,E=this.processAttributes(N,a),P="",L=(g="",!1);if((O=/^([^:]+):([^:]+)$/.exec(t))?(g=O[1]+":",t=O[2]):":"===t[0]&&(L=!0,t=t.substr(1)),i)P=this.objectToXML(N,t,s,n,!1,null,r,a);else if(this.definitions.schemas)if(p){var k=this.findChildSchemaObject(r,t);if(k&&(k.$type&&-1===k.$type.indexOf("xsd:")||k.$ref||k.$name)){var M="",H="",I=void 0,F="",B=k.$ref||k.$name;if(B){H=(B=j(B)).name,B.prefix===C?(I=k.$targetNamespace,M=a.registerNamespace(I),this.isIgnoredNameSpace(M)&&(M=s)):(M=B.prefix,this.isIgnoredNameSpace(M)&&(M=s),I=p.xmlns[M]||this.definitions.xmlns[M]);var K=!1;k.$name&&void 0===k.targetNamespace&&(K="unqualified"===k.$form||"qualified"!==k.$form&&"qualified"!==p.$elementFormDefault),K&&(M=""),I&&M&&a.declareNamespace(M,I)&&(f+=F=" xmlns:"+M+'="'+I+'"')}var R=void 0;if(k.$type){var X=j(k.$type),D=X.prefix,q=p.xmlns[D]||this.definitions.xmlns[D];I=q,"http://www.w3.org/2001/XMLSchema"!==q&&D!==C&&a.addNamespace(D,q),R=this.findSchemaType(X.name,q)||k}else R=this.findSchemaObject(I,H)||k;k.$baseNameSpace&&this.options.ignoreBaseNameSpaces&&(M=s,I=n),this.options.ignoreBaseNameSpaces&&(M="",I=""),v=M,Array.isArray(N)?M={current:M,parent:v}:F=null,P=this.objectToXML(N,t,M,I,!1,F,R,a)}else if(e[this.options.attributesKey]&&e[this.options.attributesKey].xsi_type){this.findChildSchemaObject(e[this.options.attributesKey].xsi_type.type,e[this.options.attributesKey].xsi_type.xmlns);g=e[this.options.attributesKey].xsi_type.prefix,a.addNamespace(e[this.options.attributesKey].xsi_type.prefix,e[this.options.attributesKey].xsi_type.xmlns),P=this.objectToXML(N,t,e[this.options.attributesKey].xsi_type.prefix,e[this.options.attributesKey].xsi_type.xmlns,!1,null,null,a)}else Array.isArray(N)&&(t=L?":"+t:g+t),P=this.objectToXML(N,t,g||s,n,!1,null,null,a)}else P=this.objectToXML(N,t,g||s,n,!1,null,null,a);v=ue(v),d&&!l&&i&&!this.options.overrideRootElement?v=s:this.isIgnoredNameSpace(v)&&(v="");var U=!P&&this.options.useEmptyTag;Array.isArray(N)||h.push(["<",L?"":ce(g||v),t,E,f,null===N?' xsi:nil="true"':"",U?" />":">"].join("")),U||(h.push(P),Array.isArray(N)||h.push(["</",L?"":ce(g||v),t,">"].join("")))}}}else void 0!==e&&h.push(this.options.escapeXML?A(e):e);return a.popContext(),h.join("")},pe.prototype.processAttributes=function(e,t){var s="";null===e&&(e=[]);var n=e[this.options.attributesKey];if(n&&n.xsi_type){var i=n.xsi_type,o=i.prefix||i.namespace;o?t.declareNamespace(o,i.xmlns):o=t.registerNamespace(i.xmlns),i.prefix=o}if(n)for(var r in n)if("xsi_type"!==r)s+=" "+r+'="'+A(n[r])+'"';else{var a=n[r];s+=' xsi:type="'+a.prefix+":"+a.type+'"',s+=" xmlns:"+a.prefix+'="'+a.xmlns+'"'}return s},pe.prototype.findSchemaType=function(e,t){if(!this.definitions.schemas||!e||!t)return null;var s=this.definitions.schemas[t];return s&&s.complexTypes?s.complexTypes[e]:null},pe.prototype.findChildSchemaObject=function(e,t,s){if(!e||!t)return null;if(s||(s=[]),s.indexOf(e)>=0)return null;s=s.concat([e]);var n,i=null,o=0;if(Array.isArray(e.$lookupTypes)&&e.$lookupTypes.length){var r=e.$lookupTypes;for(o=0;o<r.length;o++){var a=r[o];if(a.$name===t){i=a;break}}}var p,c=e;if(c.$name===t&&"element"===c.name)return c;if(c.$ref&&j(c.$ref).name===t)return c;if(c.$type&&1===s.length){var u=j(c.$type);p=u.prefix===C?e.$targetNamespace:this.definitions.xmlns[u.prefix];var l=this.findSchemaType(u.name,p);if(l)return this.findChildSchemaObject(l,t,s)}if(c.children)for(o=0;(n=c.children[o])&&!(i=this.findChildSchemaObject(n,t,s));o++)if(n.$base){var h=j(n.$base),d=h.prefix===C?"":h.prefix;p=n.xmlns[h.prefix]||this.definitions.xmlns[h.prefix];var f=this.findSchemaType(h.name,p);if(f&&(i=this.findChildSchemaObject(f,t,s))){i.$baseNameSpace=d,i.$type=d+":"+t;break}}return i||c.$name!==t?i:c},pe.prototype._parse=function(e){var t=this,n=s.parser(!0),i=[],o=null,r=null,a=null,c=t.options;return n.onopentag=function(e){var s,n=e.name,p=e.attributes,u=i[i.length-1];if(u)try{u.startElement(i,n,p,c)}catch(e){if(t.options.strict)throw e;i.push(new L(n,p,c))}else if("definitions"===(s=j(n).name))o=new ne(n,p,c),i.push(o);else{if("schema"!==s)throw new Error("Unexpected root element of WSDL or include");o=new ne("definitions",{},{}),r=new Q("types",{},{}),a=new J(n,p,c),r.addChild(a),o.addChild(r),i.push(a)}},n.onclosetag=function(e){var t=i[i.length-1];p.ok(t,"Unmatched close tag: "+e),t.endElement(i,e)},n.write(e).close(),o},pe.prototype._fromXML=function(e){this.definitions=this._parse(e),this.definitions.descriptions={types:{}},this.xml=e},pe.prototype._fromServices=function(e){},pe.prototype._xmlnsMap=function(){var e=this.definitions.xmlns,t="";for(var s in e)if(""!==s&&s!==C){var n=e[s];switch(n){case"http://xml.apache.org/xml-soap":case"http://schemas.xmlsoap.org/wsdl/":case"http://schemas.xmlsoap.org/wsdl/soap/":case"http://schemas.xmlsoap.org/wsdl/soap12/":case"http://schemas.xmlsoap.org/soap/encoding/":case"http://www.w3.org/2001/XMLSchema":continue}~n.indexOf("http://schemas.xmlsoap.org/")||~n.indexOf("http://www.w3.org/")||~n.indexOf("http://xml.apache.org/")||(t+=" xmlns:"+s+'="'+n+'"')}return t},de.prototype.addHeaders=function(e){e.Authorization="Basic "+new r.Buffer(this._username+":"+this._password||"").toString("base64")},de.prototype.toXML=function(){return""},de.prototype.addOptions=function(e){n.merge(e,this.defaults)};var fe=["PasswordDigest","PasswordText"];function me(e,t,s){s=s||{},this._username=e,this._password=t,"string"==typeof s?(this._passwordType=s||"PasswordText",s={}):this._passwordType=s.passwordType?s.passwordType:"PasswordText",-1===fe.indexOf(this._passwordType)&&(this._passwordType="PasswordText"),this._hasTimeStamp=!s.hasTimeStamp&&"boolean"!=typeof s.hasTimeStamp||!!s.hasTimeStamp,null!=s.hasNonce&&(this._hasNonce=!!s.hasNonce),this._hasTokenCreated=!s.hasTokenCreated&&"boolean"!=typeof s.hasTokenCreated||!!s.hasTokenCreated,null!=s.actor&&(this._actor=s.actor),null!=s.mustUnderstand&&(this._mustUnderstand=!!s.mustUnderstand)}function ye(e,t){this._token=e,this.defaults={},n.merge(this.defaults,t)}function ve(e,t,s,n){"object"==typeof e?(this.defaults=e,this.defaults.ntlm=!0):this.defaults={ntlm:!0,username:e,password:t,domain:s,workstation:n}}me.prototype.toXML=function(){function e(e){function t(e){return e<10?"0"+e:e}return e.getUTCFullYear()+"-"+t(e.getUTCMonth()+1)+"-"+t(e.getUTCDate())+"T"+t(e.getUTCHours())+":"+t(e.getUTCMinutes())+":"+t(e.getUTCSeconds())+"Z"}var t,s,n=new Date,i=e(n),o="";this._hasTimeStamp&&(o='<wsu:Timestamp wsu:Id="Timestamp-'+i+'"><wsu:Created>'+i+"</wsu:Created><wsu:Expires>"+e(new Date(n.getTime()+6e5))+"</wsu:Expires></wsu:Timestamp>");return(this._hasNonce||"PasswordText"!==this._passwordType)&&(s=m.default.stringify(f.default(i+Math.random(),""))),"PasswordText"===this._passwordType?(t='<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">'+this._password+"</wsse:Password>",s&&(t+='<wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">'+s+"</wsse:Nonce>")):t='<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">'+function(e,t,s){var n=new r.Buffer(e||"","base64").toString("binary");return m.default.stringify(f.default(n+t+s,""))}(s,i,this._password)+'</wsse:Password><wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">'+s+"</wsse:Nonce>","<wsse:Security "+(this._actor?'soap:actor="'+this._actor+'" ':"")+(this._mustUnderstand?'soap:mustUnderstand="1" ':"")+'xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">'+o+'<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="SecurityToken-'+i+'"><wsse:Username>'+this._username+"</wsse:Username>"+t+(this._hasTokenCreated?"<wsu:Created>"+i+"</wsu:Created>":"")+"</wsse:UsernameToken></wsse:Security>"},ye.prototype.addHeaders=function(e){e.Authorization="Bearer "+this._token},ye.prototype.toXML=function(){return""},ye.prototype.addOptions=function(e){n.merge(e,this.defaults)},ve.prototype.addHeaders=function(e){e.Connection="keep-alive"},ve.prototype.toXML=function(){return""},ve.prototype.addOptions=function(e){n.merge(e,this.defaults)};var ge={BasicAuthSecurity:de,BearerSecurity:ye,WSSecurity:me,NTLMSecurity:ve},xe=function(){function e(){this.preambleCRLF=!0,this.postambleCRLF=!0}return e.prototype.build=function(e,t){var s=[];function n(e){return"number"==typeof e&&(e=e.toString()),s.push(e)}this.preambleCRLF&&n("\r\n"),e.forEach((function(e){var s="--"+t+"\r\n";Object.keys(e).forEach((function(t){"body"!==t&&(s+=t+": "+e[t]+"\r\n")})),n(s+="\r\n"),n(e.body),n("\r\n")})),n("--"+t+"--"),this.postambleCRLF&&n("\r\n");var i=s.map((function(e){return"string"==typeof e?e.length:e.byteLength})).reduce((function(e,t){return e+t}),0),o=new Uint8Array(i),r=0;return s.forEach((function(e){if("string"==typeof e)for(var t=0;t<e.length;r++,t++)o[r]=255&e.charCodeAt(t);else for(t=0;t<e.byteLength;r++,t++)o[r]=e[t]})),o.buffer},e}(),be=function(){function e(e,t,s,n){this.mimetype=e,this.contentId=t,this.name=s,this.body=n}return e.fromFormFiles=function(t){void 0===t&&(t=[]),t instanceof FileList&&(t=Array.from(t));var s=t.map((function(t){return new Promise((function(s){var n=new FileReader;n.readAsArrayBuffer(t),n.onload=function(n){var i=n.target.result,o=new Uint8Array(i),r=new e(t.type,t.contentId||t.name,t.name,o);s(r)}}))}));return Promise.all(s)},e}(),we=/[^a-z$_0-9]/i,Se=function(e,t,s){s=s||{},this.wsdl=e,this._initializeOptions(s),this._initializeServices(t),this.httpClient=s.httpClient;var n={multiArgs:!0};s.overridePromiseSuffix&&(n.suffix=s.overridePromiseSuffix),Promise.all([this,n])};Se.prototype.addSoapHeader=function(e,t,s,n){return this.soapHeaders||(this.soapHeaders=[]),"object"==typeof e&&(e=this.wsdl.objectToXML(e,t,s,n,!0)),this.soapHeaders.push(e)-1},Se.prototype.changeSoapHeader=function(e,t,s,n,i){this.soapHeaders||(this.soapHeaders=[]),"object"==typeof t&&(t=this.wsdl.objectToXML(t,s,n,i,!0)),this.soapHeaders[e]=t},Se.prototype.getSoapHeaders=function(){return this.soapHeaders},Se.prototype.clearSoapHeaders=function(){this.soapHeaders=null},Se.prototype.addHttpHeader=function(e,t){this.httpHeaders||(this.httpHeaders={}),this.httpHeaders[e]=t},Se.prototype.getHttpHeaders=function(){return this.httpHeaders},Se.prototype.clearHttpHeaders=function(){this.httpHeaders={}},Se.prototype.addBodyAttribute=function(e,t,s,n){if(this.bodyAttributes||(this.bodyAttributes=[]),"object"==typeof e){var i="";Object.getOwnPropertyNames(e).forEach((function(t,s,n){i+=" "+t+'="'+e[t]+'"'})),e=i}" "!==e.substr(0,1)&&(e=" "+e),this.bodyAttributes.push(e)},Se.prototype.getBodyAttributes=function(){return this.bodyAttributes},Se.prototype.clearBodyAttributes=function(){this.bodyAttributes=null},Se.prototype.setEndpoint=function(e){this.endpoint=e,this._initializeServices(e)},Se.prototype.describe=function(){this.wsdl.definitions.types;return this.wsdl.describeServices()},Se.prototype.setSecurity=function(e){this.security=e},Se.prototype.setSOAPAction=function(e){this.SOAPAction=e},Se.prototype._initializeServices=function(e){var t=this.wsdl.definitions.services;for(var s in t)this[s]=this._defineService(t[s],e)},Se.prototype._initializeOptions=function(e){this.streamAllowed=e.stream,this.normalizeNames=e.normalizeNames,this.wsdl.options.attributesKey=e.attributesKey||"attributes",this.wsdl.options.envelopeKey=e.envelopeKey||"soap",this.wsdl.options.preserveWhitespace=!!e.preserveWhitespace,void 0!==e.ignoredNamespaces&&void 0!==e.ignoredNamespaces.override&&!0===e.ignoredNamespaces.override&&void 0!==e.ignoredNamespaces.namespaces&&(this.wsdl.options.ignoredNamespaces=e.ignoredNamespaces.namespaces),void 0!==e.overrideRootElement&&(this.wsdl.options.overrideRootElement=e.overrideRootElement),this.wsdl.options.forceSoap12Headers=!!e.forceSoap12Headers},Se.prototype._defineService=function(e,t){var s=e.ports,n={};for(var i in s)n[i]=this._definePort(s[i],t||s[i].location);return n},Se.prototype._definePort=function(e,t){var s=t,n=e.binding.methods,i={};for(var o in n){i[o]=this._defineMethod(n[o],s),this[this.normalizeNames?o.replace(we,"_"):o]=i[o]}return i},Se.prototype._defineMethod=function(e,t){var s=this;return function(n,i,o){return s._invoke(e,n,t,i,o)}},Se.prototype._invoke=function(e,t,s,i,o){var r=this,a=e.$name,c=e.input,h=e.output,d=e.style,f=this.wsdl.definitions,m=this.wsdl.options.envelopeKey,v=f.$targetNamespace,g="",b="",w=null,S=null,T=$(f.xmlns,v),C={"Content-Type":"text/xml; charset=utf-8"},_="xmlns:"+m+'="http://schemas.xmlsoap.org/soap/envelope/"';for(var N in this.wsdl.options.forceSoap12Headers&&(C["Content-Type"]="application/soap+xml; charset=utf-8",_="xmlns:"+m+'="http://www.w3.org/2003/05/soap-envelope"'),S=this.SOAPAction?this.SOAPAction:void 0!==e.soapAction&&null!==e.soapAction?e.soapAction:(v.lastIndexOf("/")!==v.length-1?v+"/":v)+a,this.wsdl.options.forceSoap12Headers||(C.SOAPAction='"'+S+'"'),i=i||{},this.httpHeaders)C[N]=this.httpHeaders[N];for(var j in o)C[j]=o[j];r.security&&r.security.addHeaders&&r.security.addHeaders(C),r.security&&r.security.addOptions&&r.security.addOptions(i),"rpc"!==d||!c.parts&&"element"!==c.name&&null!==t?(p.ok(!d||"document"===d,"invalid message definition for rpc style binding"),b=r.wsdl.objectToDocumentXML(c.$name,t,c.targetNSAlias,c.targetNamespace,c.$type||c.$lookupType)):(p.ok(!d||"rpc"===d,"invalid message definition for document style binding"),b=r.wsdl.objectToRpcXML(a,t,T,v,"element"!==c.name),"encoded"===e.inputSoap&&(g='soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" ')),w='<?xml version="1.0" encoding="utf-8"?><'+m+":Envelope "+_+' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '+g+this.wsdl.xmlnsInEnvelope+">"+(r.soapHeaders||r.security?"<"+m+":Header>"+(r.soapHeaders?r.soapHeaders.join("\n"):"")+(r.security&&!r.security.postProcess?r.security.toXML():"")+"</"+m+":Header>":"")+"<"+m+":Body"+(r.bodyAttributes?r.bodyAttributes.join(" "):"")+(r.security&&r.security.postProcess?' Id="_0"':"")+">"+b+"</"+m+":Body></"+m+":Envelope>",r.security&&r.security.postProcess&&(w=r.security.postProcess(w,m)),i&&i.postProcess&&(w=i.postProcess(w)),r.lastMessage=b,r.lastRequest=w,r.lastEndpoint=s;return u.from(be.fromFormFiles(i.attachments)).pipe(l.map((function(e){var t,s;if(!e.length)return w;if(i.forceMTOM||e.length>0){var n=y.default(),o=y.default(),r=null;if(C["Content-Type"].indexOf("action")>-1)try{for(var a=x(C["Content-Type"].split("; ")),p=a.next();!p.done;p=a.next()){var c=p.value;c.indexOf("action")>-1&&(r=c)}}catch(e){t={error:e}}finally{try{p&&!p.done&&(s=a.return)&&s.call(a)}finally{if(t)throw t.error}}C["Content-Type"]='multipart/related; type="application/xop+xml"; start="<'+n+'>"; start-info="text/xml"; boundary="'+o+'"',r&&(C["Content-Type"]=C["Content-Type"]+"; "+r);var u=[{"Content-Type":'application/xop+xml; charset=UTF-8; type="text/xml"',"Content-ID":"<"+n+">",body:w}];return e.forEach((function(e){u.push({"Content-Type":e.mimetype+";","Content-Transfer-Encoding":"binary","Content-ID":"<"+(e.contentId||e.name)+">","Content-Disposition":'attachment; name="'+e.name+'"; filename="'+e.name+'"',body:e.body})})),(new xe).build(u,o)}})),l.flatMap((function(e){return r.httpClient.post(s,e,{headers:C,responseType:"text",observe:"response"}).pipe(l.map((function(e){return r.lastResponse=e.body,r.lastResponseHeaders=e&&e.headers,function(e,t){var s;try{s=r.wsdl.xmlToObject(e)}catch(s){if(!h||!h.$lookupTypes){var i=n.isObject(e)?e:function(e){try{return JSON.parse(e)}catch(e){return}}(e);if(i)return{err:null,response:t,responseBody:i,header:void 0,xml:w}}throw s.response=t,s.body=e,s}return function(e,t,s){var n=null;if(!h)return{err:null,response:null,responseBody:t,header:e.Header,xml:w};if(!e.html&&!e.Body)return{err:null,obj:e,responseBody:t,header:e.Header,xml:w};if("object"!=typeof e.Body){var i=new Error("Cannot parse response");return i.response=s,i.body=t,{err:i,obj:e,responseBody:t,header:void 0,xml:w}}(n=e.Body[h.$name])||(n=e.Body[h.$name.replace(/(?:Out(?:put)?|Response)$/,"")]);n||["Response","Out","Output"].forEach((function(t){if(e.Body.hasOwnProperty(a+t))return n=e.Body[a+t]}));return{err:null,result:n,responseBody:t,header:e.Header,xml:w}}(s,e,t)}(e.body,e)})))})))},Se.prototype.call=function(e,t,s,n){return this[e]?this[e].call(this,t,s,n):u.throwError("Method "+e+" not found")};var $e={},Te=function(e,t){return v(void 0,void 0,void 0,(function(){return g(this,(function(s){return $e[e]?[2,$e[e]]:[2,he(e,t).then((function(t){return $e[e]=t,t}))]}))}))};function Ce(e,t){return v(this,void 0,void 0,(function(){return g(this,(function(s){return!0===t.disableCache?[2,he(e,t)]:[2,Te(e,t)]}))}))}var _e=function(){function e(e){this.http=e}return e.prototype.createClient=function(e,t,s){return void 0===t&&(t={}),t.httpClient=this.http,function(e,t,s){return v(this,void 0,void 0,(function(){var n;return g(this,(function(i){switch(i.label){case 0:return void 0===t&&(t={}),s=t.endpoint||s,[4,Ce(e,t)];case 1:return n=i.sent(),[2,new Se(n,s,t)]}}))}))}(e,t,s)},e}();_e.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new _e(t.ɵɵinject(h.HttpClient))},token:_e,providedIn:"root"}),_e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],_e.ctorParameters=function(){return[{type:h.HttpClient}]};var Ne=function(){};Ne.decorators=[{type:t.NgModule,args:[{imports:[h.HttpClientModule],exports:[]}]}],e.NgxSoapModule=Ne,e.NgxSoapService=_e,e.security=ge,e.ɵa=de,e.ɵb=ye,e.ɵc=me,e.ɵd=ve,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=ngx-soap.umd.min.js.map