/**
@license
* @pnp/sp-clientsvc v1.1.5-5 - pnp - Provides core functionality to interact with the legacy client.svc SharePoint endpoint
* MIT (https://github.com/pnp/pnpjs/blob/master/LICENSE)
* Copyright (c) 2018 Microsoft
* docs: https://pnp.github.io/pnpjs/
* source: https:github.com/pnp/pnpjs
* bugs: https://github.com/pnp/pnpjs/issues
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@pnp/common"),require("tslib"),require("@pnp/odata"),require("@pnp/sp"),require("@pnp/logging")):"function"==typeof define&&define.amd?define(["exports","@pnp/common","tslib","@pnp/odata","@pnp/sp","@pnp/logging"],e):e((t.pnp=t.pnp||{},t.pnp["sp-clientsvc"]={}),t.common,t.tslib_1,t.odata,t.sp,t.logging)}(this,function(t,h,i,p,c,s){"use strict";function e(){return''}function o(t,e){void 0===t&&(t=null),void 0===e&&(e=null);var n=[];return n.push(''),null===t||t.length<1?(n.push(''),n.push("")):(n.push(''),n.push(""),[].push.apply(n,t.map(function(t){return''})),n.push("")),n.push(""),null!==e&&(e.length<1?(n.push(''),n.push("")):(n.push(''),n.push(""),[].push.apply(n,e.map(function(t){return''})),n.push("")),n.push("")),n.push(""),n.join("")}function r(t,e,n){var r=[];return r.push(''),r.push(''+n+""),r.push(""),r.join("")}function a(t,e){var n=[];if(n.push(''),null!==e){var r=e.toArray();r.length<1?n.push(""):(n.push(""),[].push.apply(n,r.map(function(t){return''+t.value+""})),n.push(""))}return n.push(""),n.join("")}function u(n){return Object.getOwnPropertyNames(n).map(function(t){var e=n[t];return"boolean"==typeof e?r(t,"Boolean",""+e):"number"==typeof e?r(t,"Number",""+e):"string"==typeof e?r(t,"String",""+e):""},[])}function l(t){for(var e=[],n=1;n',e)}function d(t,e){for(var n=[],r=2;r',n)}function n(t,e){for(var n=[],r=2;r',n)}var f=function(){function n(t){void 0===t&&(t=[]),this._p=t}return n.build=function(t){void 0===t&&(t=[]);var e=new n;return[].push.apply(e._p,t),e},n.prototype.string=function(t){return this.a("String",t)},n.prototype.number=function(t){return this.a("Number",t.toString())},n.prototype.boolean=function(t){return this.a("Boolean",t.toString())},n.prototype.objectPath=function(t){return this.a("ObjectPath",t.toString())},n.prototype.toArray=function(){return this._p},n.prototype.a=function(t,e){return this._p.push({type:t,value:e}),this},n}();function y(t,e){for(var n=[],r=2;r'),null!==e){var i=e.toArray();i.length<1?o.push(""):(o.push(""),[].push.apply(o,i.map(function(t){return"ObjectPath"===t.type?'':''+t.value+""})),o.push(""))}return o.push(""),new P(o.join(""),n)}function b(t){var e=[],n=[];return t.forEach(function(t){n.push(t.path),e.push.apply(e,t.actions)}),['',"",e.join(""),"","",n.join(""),"",""].join("")}var P=function(t,e,n,r){void 0===e&&(e=[]),void 0===n&&(n=-1),void 0===r&&(r=[]),this.path=t,this.actions=e,this.id=n,this.replaceAfter=r};function _(t,e){return e.replace(/\$\$ID\$\$/g,t)}function $(t,e){return e.replace(/\$\$PATH_ID\$\$/g,t)}function I(t,e){return e.replace(/\$\$PARENT_ID\$\$/g,t)}function g(t,e,n){void 0===n&&(n=function(t){return t});var r=/\$\$OP_PARAM_ID_(\d+)\$\$/gi.exec(e);if(null!==r)for(var o=1;o')),this.addChildRelationship(t,this._siteIndex)}return this._siteIndex},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"webIndex",{get:function(){if(this._webIndex<0){var t=this.contextIndex;this._webIndex=this.add(l("Web",'')),this.addChildRelationship(t,this._webIndex)}return this._webIndex},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"contextIndex",{get:function(){return this._contextIndex<0&&(this._contextIndex=this.add(n("Current","{3747adcd-a3c3-41b9-bfab-4a64dd2f1e0a}",''))),this._contextIndex},enumerable:!0,configurable:!0}),e.prototype.toBody=function(){return h.objectDefinedNotNull(this._xml)||(this._xml=b(this.toIndexedTree())),this._xml},e.prototype.toIndexedTree=function(){var o=this,i=-1,s=-1,a=[];return this.toArray().map(function(t,e,n){var r=++i;return a.push(r),t.path=g(a,_(r.toString(),t.path)),0<=s&&(t.path=I(s.toString(),t.path)),t.actions=t.actions.map(function(t){return _((++i).toString(),$(r.toString(),t))}),o.getChildRelationship(e).forEach(function(t){n[t].path=I(r.toString(),n[t].path)}),s=r,t})},e.prototype.dirty=function(){this._xml=null},e}(),m=function(){function t(t){this.op=t}return t.prototype.parse=function(t){var e=this;return t.text().then(function(e){if(!t.ok)throw new Error(e);try{return JSON.parse(e)}catch(t){throw new Error(e)}}).then(function(t){if(0')),new t(this,r)},t.prototype.getChildProperty=function(t,e){var n=this._objectPaths.clone();return n.add(l(e)),new t(this,n)},t.prototype.send=function(t,e,n){return void 0===e&&(e={}),void 0===n&&(n=null),h.objectDefinedNotNull(n)||(n=new m(t.last)),this.hasBatch?e=h.extend(e,{clientsvc_ObjectPaths:t.clone()}):h.hOP(e,"body")||(e=h.extend(e,{body:t.toBody()})),r.prototype.postCore.call(this,e,n)},t.prototype.sendGet=function(e){var n=this,t=this._objectPaths.clone().appendActionToLast(o(this.getSelects()));return this.send(t).then(function(t){return h.extend(new e(n),t)})},t.prototype.sendGetCollection=function(e){var t=this._objectPaths.clone().appendActionToLast(o([],this.getSelects()));return this.send(t).then(function(t){return t.map(function(t){return h.extend(e(t),t)})})},t.prototype.invokeMethod=function(t,e){void 0===e&&(e=null);for(var n=[],r=2;r'].concat(n,[r])))),this.send(i)},t}(p.Queryable),O=function(r){function t(t,e){var n=r.call(this,e)||this;return n.parentUrl=t,n}return i.__extends(t,r),t.prototype.executeImpl=function(){if(this.requests.length<1)return s.Logger.write("Resolving empty batch.",1),Promise.resolve();var t=new A(this.parentUrl,this.batchId);return t.appendRequests(this.requests),t.execute()},t}(p.ODataBatch),A=function(o){function t(t,e){var n=o.call(this,t)||this;n.batchId=e,n._requests=[],n._builderIndex=1;var r=d("GetTaxonomySession","{981cbc68-9edc-4f8d-872f-71146fcbb84f}");return r.path=_("0",r.path),r.actions.push(_("1",$("0",''))),n._objectPaths.add(r),n}return i.__extends(t,o),t.prototype.appendRequests=function(t){var c=this;t.forEach(function(t){var s=t.options.clientsvc_ObjectPaths,e=s.toArray();if(!(e.length<0)){var a=function(t){return t};/GetTaxonomySession/i.test(e[0].path)&&((e=e.slice(1))[0].path=I("0",e[0].path),a=function(t){return t-1});var u=-1,h=[];e.map(function(t,e,n){var r=++c._builderIndex;h.push(r);var o=g(h,_(r.toString(),t.path),a);0<=u&&(o=I(u.toString(),o));var i=t.actions.map(function(t){return _((++c._builderIndex).toString(),$(r.toString(),t))});return s.getChildRelationship(e+1).map(function(t){return t-1}).forEach(function(t){n[t].path=I(r.toString(),n[t].path)}),u=r,new P(o,i)}).forEach(function(t){return c._objectPaths.add(t)});var n=c._objectPaths.toArray(),r=new m(n[n.length-1]);t.parser instanceof p.CachingParserWrapper?t.parser=new w(r,t.parser):t.parser=r,c._requests.push(t),delete t.options.clientsvc_ObjectPaths}})},t.prototype.execute=function(){var r=this;s.Logger.write("["+this.batchId+"] ("+(new Date).getTime()+") Executing batch with "+this._requests.length+" requests.",1);var t={body:b(this._objectPaths.toArray())};return s.Logger.write("["+this.batchId+"] ("+(new Date).getTime()+") Sending batch request.",1),o.prototype.postCore.call(this,t,new D).then(function(n){return s.Logger.write("["+r.batchId+"] ("+(new Date).getTime()+") Resolving batched requests.",1),r._requests.reduce(function(t,e){return s.Logger.write("["+e.id+"] ("+(new Date).getTime()+") Resolving request in batch "+r.batchId+".",1),t.then(function(t){return e.parser.findResult(n).then(e.resolve).catch(e.reject)})},Promise.resolve())})},t}(x),D=function(t){function e(){return t.call(this,null)||this}return i.__extends(e,t),e.prototype.findResult=function(t){return t},e}(m),w=function(n){function t(t,e){return n.call(this,t,e.cacheOptions)||this}return i.__extends(t,n),t.prototype.findResult=function(t){var e=this;return this.parser.findResult(t).then(function(t){return e.cacheData(t)})},t}(p.CachingParserWrapper);t.ObjectPathBatch=O,t.ClientSvcQueryable=x,t.ObjectPath=P,t.opSetId=_,t.opSetPathId=$,t.opSetParentId=I,t.opSetPathParamId=g,t.ObjectPathQueue=v,t.objectPath=e,t.identityQuery=function(){return''},t.opQuery=o,t.setProperty=r,t.methodAction=a,t.objectProperties=u,t.property=l,t.staticMethod=d,t.staticProperty=n,t.objConstructor=function(t){for(var e=[],n=1;n',e)},t.MethodParams=f,t.method=y,t.ProcessQueryParser=m,t.writeObjectPathBody=b,Object.defineProperty(t,"__esModule",{value:!0})});