"use strict";var SPUtility=function(t){return function(){var e,r=void 0,i=!1,n="application/json;odata=verbose",o=!0,a={},s=_spPageContextInfo||{},l=function(t){r=t,i=!0,a={},u().then(function(t){e=t.d.GetContextWebInformation.FormDigestValue,setTimeout(function(){l(r)},100*t.d.GetContextWebInformation.FormDigestTimeoutSeconds-100)})},u=function(){return C({url:r+"/_api/contextinfo",contentType:"application/json;odata=verbose",headers:{accept:"application/json;odata=verbose"}})},p=function(){return i||(e=e||t("#__REQUESTDIGEST").val()),e},c=function(){this.batchGuid=d(),this.changeSetId=d(),this.batchContents=new Array};c.prototype.addToBatchContent=function(t){this.batchContents.push("--changeset_"+this.changeSetId),this.batchContents.push("Content-Type: application/http"),this.batchContents.push("Content-Transfer-Encoding: binary"),this.batchContents.push(""),this.batchContents.push(t.type+" "+t.url+" HTTP/1.1");for(var e=0;e<t.headers.length;e++){var r=t.headers[e];this.batchContents.push(r)}this.batchContents.push(""),t.data&&(this.batchContents.push(JSON.stringify(t.data)),this.batchContents.push(""))},c.prototype.executeBatch=function(){this.batchContents.push("--changeset_"+this.changeSetId+"--");var t=this.batchContents.join("\r\n");this.batchContents=new Array,this.batchContents.push("--batch_"+this.batchGuid),this.batchContents.push('Content-Type: multipart/mixed; boundary="changeset_'+this.changeSetId+'"'),this.batchContents.push("Content-Length: "+t.length),this.batchContents.push("Content-Transfer-Encoding: binary"),this.batchContents.push(""),this.batchContents.push(t),this.batchContents.push(""),this.batchContents.push("--batch_"+this.batchGuid+"--"),t=this.batchContents.join("\r\n");var e={"X-RequestDigest":p(),"Content-Type":'multipart/mixed; boundary="batch_'+this.batchGuid+'"'},i=r+"/_api/$batch";return this.batchGuid=d(),this.changeSetId=d(),this.batchContents=new Array,C({url:i,headers:e,data:t})};var d=function(){var t=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var r=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==e?r:3&r|8).toString(16)})},y=function(t){this.endPointUrl=t};y.prototype.select=function(t){return t&&(this.selectArray=t.join(",")),this},y.prototype.filter=function(t){return t&&(this.filterValue=t),this},y.prototype.get=function(){var e=this.endPointUrl,r={};return this.selectArray&&(r.$select=this.selectArray),this.filterValue&&(r.$filter=this.filterValue),I({url:e+"/Fields",data:t.param(r)})};var h=function(){s=_spPageContextInfo||{},r=r||s.webAbsoluteUrl||"..";var e,i,n,l,u,p,c,d,h=(e="",i="",n=function(){var t=r;return"getbytitle"===e.toLowerCase()?t+="/_api/lists/getbytitle('"+i+"')":"getbyid"===e.toLowerCase()&&(t+="/_api/lists(guid'"+i+"')"),I({url:t})},l=function(t,n){var o=r;return"getbytitle"===e.toLowerCase()?o+="/_api/lists/getbytitle('"+i+"')":"getbyid"===e.toLowerCase()&&(o+="/_api/lists(guid'"+i+"')"),t.__metadata={type:"SP.List"},C({url:o,data:JSON.stringify(t),contentType:"application/json;odata=verbose",headers:{"IF-MATCH":n,"X-HTTP-Method":"MERGE",accept:"application/json;odata=verbose"}})},u=function(t){var n=r;return"getbytitle"===e.toLowerCase()?n+="/_api/lists/getbytitle('"+i+"')":"getbyid"===e.toLowerCase()&&(n+="/_api/lists(guid'"+i+"')"),C({url:n,headers:{"IF-MATCH":t,"X-HTTP-Method":"DELETE"}})},p=function(){var n=r,o=t.Deferred();return"getbytitle"===e.toLowerCase()?n+="/_api/lists/getbytitle('"+i+"')?$select=ListItemEntityTypeFullName":"getbyid"===e.toLowerCase()&&(n+="/_api/lists(guid'"+i+"')?$select=ListItemEntityTypeFullName"),a.listTitleOrId===i?o.resolve(a.MetaData):I({url:n,contentType:"application/json;odata=verbose",headers:{accept:"application/json;odata=verbose"}}).then(function(t){a={listTitleOrId:i,MetaData:t},o.resolve(t)},function(t){o.reject(t)}),o.promise()},c=function(t,e){return I({url:t+"/"+e})},(d=function(){}).prototype.select=function(t){return t&&(this.selectArray=t.join(",")),this},d.prototype.expand=function(t){return t&&(this.expandArray=t.join(",")),this},d.prototype.filter=function(t){return t&&(this.filterValue=t),this},d.prototype.topItem=function(t){return t&&(this.top=t),this},d.prototype.orderBy=function(t){return t&&(this.order=t.join(",")),this},d.prototype.get=function(){var n={};return this.selectArray&&(n.$select=this.selectArray),this.expandArray&&(n.$expand=this.expandArray),this.filterValue&&(n.$filter=this.filterValue),this.top&&(n.$top=this.top),this.order&&(n.$orderby=this.order),"getbytitle"===e.toLowerCase()?I({url:r+"/_api/lists/getbytitle('"+i+"')/items",data:t.param(n)}):"getbyid"===e.toLowerCase()?I({url:r+"/_api/lists(guid'"+i+"')/items",data:t.param(n)}):void 0},d.prototype.getAllItems=function(){var n=t.Deferred(),a={},s=r,l=[];"getbytitle"===e.toLowerCase()?s+="/_api/lists/getbytitle('"+i+"')/items":"getbyid"===e.toLowerCase()&&(s+="/_api/lists(guid'"+i+"')/items"),this.selectArray&&(a.$select=this.selectArray),this.expandArray&&(a.$expand=this.expandArray),this.filterValue&&(a.$filter=this.filterValue),this.order&&(a.$orderby=this.order),a.$top=4999,this.top&&(a.$top=this.top);var u=function(e,r){I({url:e,data:t.param(r)}).then(function(e){o?(l=t.merge(l,e.d.results),e.d.__next?u(e.d.__next,""):n.resolve(l)):(l=t.merge(l,e.value),e["odata.nextLink"]?u(e["odata.nextLink"],""):n.resolve(l))},function(t){console.error("Error occurred while loading the items",t),n.reject(t)})};return u(s,a),n.promise()},d.prototype.getPaged=function(){var n=t.Deferred(),a={},s=r;"getbytitle"===e.toLowerCase()?s+="/_api/lists/getbytitle('"+i+"')/items":"getbyid"===e.toLowerCase()&&(s+="/_api/lists(guid'"+i+"')/items"),this.selectArray&&(a.$select=this.selectArray),this.expandArray&&(a.$expand=this.expandArray),this.filterValue&&(a.$filter=this.filterValue),this.order&&(a.$orderby=this.order),a.$top=4999,this.top&&(a.$top=this.top);var l=function(e,r){var i=t.Deferred();return I({url:e,data:t.param(r)}).then(function(t){if(o?t.d.__next:t["odata.nextLink"]){var e=function(t){this.nextUrlLink=t};e.prototype.getNextItems=function(){return l(this.nextUrlLink,"")},o?i.resolve(t.d.results,new e(t.d.__next)):i.resolve(t.value,new e(t["odata.nextLink"]))}else o?i.resolve(t.d.results):i.resolve(t.value)},function(t){console.error("Error occurred while loading the items",t),i.reject(t)}),i.promise()};return l(s,a).then(function(t,e){e?n.resolve(t,e):n.resolve(t)},function(t){n.reject(t)}),n.promise()},d.prototype.getItemById=function(n){var o={},a=r;return this.selectArray&&(o.$select=this.selectArray),this.expandArray&&(o.$expand=this.expandArray),"getbytitle"===e.toLowerCase()?a+="/_api/lists/getbytitle('"+i+"')/getItemById('"+n+"')":"getbyid"===e.toLowerCase()&&(a+="/_api/lists(guid'"+i+"')/getItemById('"+n+"')"),I({url:a,data:t.param(o)})},d.prototype.addNewItem=function(n){var o=t.Deferred(),a=r;return"getbytitle"===e.toLowerCase()?a+="/_api/lists/getbytitle('"+i+"')/items":"getbyid"===e.toLowerCase()&&(a+="/_api/lists(guid'"+i+"')/items"),p().then(function(t){n.__metadata={type:t.d.ListItemEntityTypeFullName},C({url:a,data:JSON.stringify(n),contentType:"application/json;odata=verbose",headers:{accept:"application/json;odata=verbose"}}).then(function(t){o.resolve(t)},function(t){o.reject(t)})},function(t){console.error("Error occurred while loading List Metadata",t),o.reject(t)}),o.promise()},d.prototype.addNewItemUsingBatch=function(t,n){var o=r;"getbytitle"===e.toLowerCase()?o+="/_api/lists/getbytitle('"+i+"')/items":"getbyid"===e.toLowerCase()&&(o+="/_api/lists(guid'"+i+"')/items"),p().then(function(e){t.__metadata={type:e.d.ListItemEntityTypeFullName},n.addToBatchContent({url:o,type:"POST",headers:["Content-Type: application/json;odata=verbose"],data:t})},function(t){console.error("Error occurred",t)})},d.prototype.uploadAttachment=function(n,o){var a=t.Deferred(),s=r+"/_api";return"getbytitle"===e.toLowerCase()?s+="/lists/getbytitle('"+i+"')/items('"+n+"')/AttachmentFiles/add(FileName='"+o.name+"')":"getbyid"===e.toLowerCase()&&(s+="/lists(guid'"+i+"')/items('"+n+"')/AttachmentFiles/add(FileName='"+o.name+"')"),w(o).then(function(t){C({url:s,data:t,processData:!1,headers:{accept:"application/json;odata=verbose"}}).then(function(t){a.resolve(t)},function(t){console.error("Error occurred while uploading the file",t),a.reject(t)})},function(t){console.error("Error occurred while reading the file",t),a.reject(t)}),a.promise()},d.prototype.getAttachments=function(t){var n=r+"/_api";return"getbytitle"===e.toLowerCase()?n+="/lists/getbytitle('"+i+"')/items('"+t+"')/AttachmentFiles":"getbyid"===e.toLowerCase()&&(n+="/lists(guid'"+i+"')/items('"+t+"')/AttachmentFiles"),I({url:n})},d.prototype.deleteAttachment=function(t,n){var o=r+"/_api";return"getbytitle"===e.toLowerCase()?o+="/lists/getbytitle('"+i+"')/items('"+t+"')/AttachmentFiles/getByFileName('"+n+"')":"getbyid"===e.toLowerCase()&&(o+="/lists(guid'"+i+"')/items('"+t+"')/AttachmentFiles/getByFileName('"+n+"')"),C({url:o,headers:{"X-HTTP-Method":"DELETE"}})},d.prototype.updateItem=function(n,o,a){var s=t.Deferred(),l=r;return"getbytitle"===e.toLowerCase()?l+="/_api/lists/getbytitle('"+i+"')/getItemById('"+n+"')":"getbyid"===e.toLowerCase()&&(l+="/_api/lists(guid'"+i+"')/getItemById('"+n+"')"),p().then(function(t){a.__metadata={type:t.d.ListItemEntityTypeFullName},C({url:l,data:JSON.stringify(a),contentType:"application/json;odata=verbose",headers:{accept:"application/json;odata=verbose","X-HTTP-Method":"MERGE","If-Match":o}}).then(function(t){s.resolve(t)},function(t){s.reject(t)})},function(t){console.error("Error occurred while loading List Metadata",t),s.reject(t)}),s.promise()},d.prototype.updateItemUsingBatch=function(t,n,o,a){var s=r;"getbytitle"===e.toLowerCase()?s+="/_api/lists/getbytitle('"+i+"')/getItemById('"+t+"')":"getbyid"===e.toLowerCase()&&(s+="/_api/lists(guid'"+i+"')/getItemById('"+t+"')"),p().then(function(t){o.__metadata={type:t.d.ListItemEntityTypeFullName},a.addToBatchContent({url:s,type:"PATCH",headers:["Content-Type: application/json;odata=verbose","If-Match: "+n],data:o})},function(t){console.error("Error occurred",t)})},d.prototype.deleteItem=function(t,n){var o=r;return"getbytitle"===e.toLowerCase()?o+="/_api/lists/getbytitle('"+i+"')/getItemById('"+t+"')":"getbyid"===e.toLowerCase()&&(o+="/_api/lists(guid'"+i+"')/getItemById('"+t+"')"),C({url:o,contentType:"application/json;odata=verbose",headers:{accept:"application/json;odata=verbose","X-HTTP-Method":"DELETE","If-Match":n}})},d.prototype.deleteItemUsingBatch=function(t,n,o){var a=r;"getbytitle"===e.toLowerCase()?a+="/_api/lists/getbytitle('"+i+"')/getItemById('"+t+"')":"getbyid"===e.toLowerCase()&&(a+="/_api/lists(guid'"+i+"')/getItemById('"+t+"')"),o.addToBatchContent({url:a,type:"DELETE",headers:["Content-Type: application/json;odata=verbose","If-Match: "+n]})},d.prototype.effectiveBasePermissions=function(t){var n=r;return"getbytitle"===e.toLowerCase()?n+="/_api/lists/getbytitle('"+i+"')/getItemById('"+t+"')":"getbyid"===e.toLowerCase()&&(n+="/_api/lists(guid'"+i+"')/getItemById('"+t+"')"),g(n)},d.prototype.hasuniqueroleassignments=function(t){var n=r;return"getbytitle"===e.toLowerCase()?n+="/_api/lists/getbytitle('"+i+"')/getItemById('"+t+"')":"getbyid"===e.toLowerCase()&&(n+="/_api/lists(guid'"+i+"')/getItemById('"+t+"')"),f(n)},d.prototype.breakroleinheritance=function(t,n,o){var a=r;return"getbytitle"===e.toLowerCase()?a+="/_api/lists/getbytitle('"+i+"')/getItemById('"+t+"')":"getbyid"===e.toLowerCase()&&(a+="/_api/lists(guid'"+i+"')/getItemById('"+t+"')"),b(a,n,o)},d.prototype.resetroleinheritance=function(t){var n=r;return"getbytitle"===e.toLowerCase()?n+="/_api/lists/getbytitle('"+i+"')/getItemById('"+t+"')":"getbyid"===e.toLowerCase()&&(n+="/_api/lists(guid'"+i+"')/getItemById('"+t+"')"),m(n)},d.prototype.addRoleAssignment=function(t,n,o){var a=r;return"getbytitle"===e.toLowerCase()?a+="/_api/lists/getbytitle('"+i+"')/getItemById('"+t+"')":"getbyid"===e.toLowerCase()&&(a+="/_api/lists(guid'"+i+"')/getItemById('"+t+"')"),_(a,n,o)},d.prototype.deleteRoleAssignment=function(t,n){var o=r;return"getbytitle"===e.toLowerCase()?o+="/_api/lists/getbytitle('"+i+"')/getItemById('"+t+"')":"getbyid"===e.toLowerCase()&&(o+="/_api/lists(guid'"+i+"')/getItemById('"+t+"')"),v(o,n)},{getListByTitle:function(t){if(!t)throw new Error("List Title cannot be empty or null");return e="getbytitle",i=t,{Items:new d,get:n,updateList:l,deleteList:u,hasuniqueroleassignments:function(){return f(r+"/_api/lists/getbytitle('"+i+"')")},effectiveBasePermissions:function(){return g(r+"/_api/lists/getbytitle('"+i+"')")},breakroleinheritance:function(t,e){return b(r+"/_api/lists/getbytitle('"+i+"')",t,e)},resetroleinheritance:function(){return m(r+"/_api/lists/getbytitle('"+i+"')")},addRoleAssignment:function(t,e){return _(r+"/_api/lists/getbytitle('"+i+"')",t,e)},deleteRoleAssignment:function(t){return v(r+"/_api/lists/getbytitle('"+i+"')",t)},getDefaultDisplayFormUrl:function(){return c(r+"/_api/lists/getbytitle('"+i+"')","DefaultDisplayFormUrl")},getDefaultEditFormUrl:function(){return c(r+"/_api/lists/getbytitle('"+i+"')","DefaultEditFormUrl")},getDefaultNewFormUrl:function(){return c(r+"/_api/lists/getbytitle('"+i+"')","DefaultNewFormUrl")},Fields:new y(r+"/_api/lists/getbytitle('"+i+"')")}},getListById:function(t){if(!t)throw new Error("List Id cannot be empty or null");return e="getbyid",i=t,{Items:new d,get:n,updateList:l,deleteList:u,hasuniqueroleassignments:function(){return f(r+"/_api/lists(guid'"+i+"')")},effectiveBasePermissions:function(){return g(r+"/_api/lists(guid'"+i+"')")},breakroleinheritance:function(t,e){return b(r+"/_api/lists(guid'"+i+"')",t,e)},resetroleinheritance:function(){return m(r+"/_api/lists(guid'"+i+"')")},addRoleAssignment:function(t,e){return _(r+"/_api/lists(guid'"+i+"')",t,e)},deleteRoleAssignment:function(t){return v(r+"/_api/lists(guid'"+i+"')",t)},getDefaultDisplayFormUrl:function(){return c(r+"/_api/lists(guid'"+i+"')","DefaultDisplayFormUrl")},getDefaultEditFormUrl:function(){return c(r+"/_api/lists(guid'"+i+"')","DefaultEditFormUrl")},getDefaultNewFormUrl:function(){return c(r+"/_api/lists(guid'"+i+"')","DefaultNewFormUrl")},Fields:new y(r+"/_api/lists(guid'"+i+"')")}},createList:function(t,e,i,n,o){var a;return a={__metadata:{type:"SP.List"},AllowContentTypes:t,BaseTemplate:e,ContentTypesEnabled:i,Description:n,Title:o},C({url:r+"/_api/web/lists",data:JSON.stringify(a),contentType:"application/json;odata=verbose",headers:{accept:"application/json;odata=verbose"}})}}),x=function(){var e,i,n=function(){};n.prototype.select=function(t){return t&&(this.selectArray=t.join(",")),this},n.prototype.expand=function(t){return t&&(this.expandArray=t.join(",")),this},n.prototype.filter=function(t){return t&&(this.filterValue=t),this},n.prototype.getAllGroups=function(){var e={};return this.selectArray&&(e.$select=this.selectArray),this.expandArray&&(e.$expand=this.expandArray),this.filterValue&&(e.$filter=this.filterValue),I({url:r+"/_api/web/sitegroups",data:t.param(e)})},n.prototype.getByName=function(t){return i="getbyname",e=t,{users:new o,get:function(){return I({url:r+"/_api/web/sitegroups/getbyname('"+t+"')"})}}},n.prototype.getById=function(t){return i="getbyid",e=t,{users:new o,get:function(){return I({url:r+"/_api/web/sitegroups/getbyid('"+t+"')"})}}};var o=function(){};return o.prototype.select=function(t){return t&&(this.selectArray=t.join(",")),this},o.prototype.expand=function(t){return t&&(this.expandArray=t.join(",")),this},o.prototype.filter=function(t){return t&&(this.filterValue=t),this},o.prototype.get=function(){var n={},o=r+"/_api/web/sitegroups/";return"getbyname"===i.toLowerCase()?o+="getbyname('"+e+"')/users":"getbyid"===i.toLowerCase()&&(o+="getbyid("+e+")/users"),this.selectArray&&(n.$select=this.selectArray),this.expandArray&&(n.$expand=this.expandArray),this.filterValue&&(n.$filter=this.filterValue),I({url:o,data:t.param(n)})},{groups:new n}}(),L=function(){};return L.prototype.GetFolderByServerRelativeUrl=function(t){return I({url:r+"/_api/web/GetFolderByServerRelativeUrl('"+t+"')"})},L.prototype.createFolder=function(t){return C({url:r+"/_api/web/folders/add('"+t+"')"})},L.prototype.listItemAllFields=function(t){return I({url:r+"/_api/web/GetFolderByServerRelativeUrl('"+t+"')/ListItemAllFields"})},L.prototype.renameFolder=function(e,i,n){var a=t.Deferred();return this.listItemAllFields(e).then(function(t){var e="",s={},l=r+"/_api/";o?(e=t.d.__metadata.type,l=t.d.__metadata.uri):(e=t["odata.type"],l+=t["odata.editLink"]),s.__metadata={type:e},s.Title=i,s.FileLeafRef=i,C({url:l,data:JSON.stringify(s),contentType:"application/json;odata=verbose",headers:{"IF-MATCH":n,"X-HTTP-Method":"MERGE",accept:"application/json;odata=verbose"}}).then(function(t){a.resolve(t)},function(t){a.reject(t)})},function(t){a.reject(t)}),a.promise()},L.prototype.getAllFilesFromFolder=function(t){return I({url:r+"/_api/web/GetFolderByServerRelativeUrl('"+t+"')/Files"})},{lists:h,ensureUser:function(t){if(!t)throw new Error("Logon Name cannot be null");var e={logonName:t};return C({url:r+"/_api/web/ensureuser",data:JSON.stringify(e)})},currentUser:function(){return I({url:r+"/_api/web/CurrentUser"})},siteGroups:x,getRoles:function(){return I({url:r+"/_api/web/roleDefinitions"})},hasuniqueroleassignments:function(){return f(r+"/_api/web")},effectiveBasePermissions:function(){return g(r+"/_api/web")},breakroleinheritance:function(t,e){return b(r+"/_api/web",t,e)},resetroleinheritance:function(){return m(r+"/_api/web")},addRoleAssignment:function(t,e){return _(r+"/_api/web",t,e)},deleteRoleAssignment:function(t){return v(r+"/_api/web",t)},siteColumns:function(){return{Fields:new y(r+"/_api/web")}},folder:new L}}(),g=function(t){return I({url:t+="/effectiveBasePermissions"})},f=function(t){return C({url:t+="/hasuniqueroleassignments"})},b=function(t,e,r){return t+="/breakroleinheritance(copyRoleAssignments="+e.toString()+",clearSubscopes="+r.toString()+")",C({url:t})},m=function(t){return C({url:t+="/resetroleinheritance"})},_=function(t,e,r){return endpointUri+=",roledefid="+r+")",C(t+="/roleassignments/addroleassignment(principalid="+e,{})},v=function(t,e){return C({url:t+="/roleassignments/getbyprincipalid("+e+")",headers:{"X-HTTP-Method":"DELETE"}})},w=function(e){var r=t.Deferred(),i=new FileReader;return i.onload=function(t){r.resolve(t.target.result)},i.onerror=function(t){r.reject(t.target.error)},i.readAsArrayBuffer(e),r.promise()},C=function(e){var r={type:"POST",contentType:n},i=t.extend({},r,e);return void 0===i.headers||null===i.headers?i.headers={"X-RequestDigest":p(),accept:n}:t.extend(i.headers,{"X-RequestDigest":p(),accept:n}),t.ajax(i)},I=function(e){var r={type:"GET",contentType:n,headers:{accept:n}},i=t.extend({},r,e);return t.ajax(i)};return{web:h,setSiteUrl:l,setNoMetaData:function(t){t?(n="application/json;odata=nometadata",o=!1):(n="application/json;odata=verbose",o=!0)},getUserProperties:function(t,e){return s=_spPageContextInfo||{},r=r||s.webAbsoluteUrl||"..",I({url:r+"/_api/SP.UserProfiles.PeopleManager/GetUserProfilePropertyFor(accountName=@v,propertyName='"+e+"')?@v='i:0%23.f|membership|"+t+"'"})},getAllUserProperties:function(t){return s=_spPageContextInfo||{},r=r||s.webAbsoluteUrl||"..",I({url:r+"/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='i:0%23.f|membership|"+encodeURIComponent(t)+"'"})},getAllPropertiesOfCurrentUser:function(){return s=_spPageContextInfo||{},r=r||s.webAbsoluteUrl||"..",I({url:r+"/_api/SP.UserProfiles.PeopleManager/GetMyProperties"})},getRequestDigest:p,setMinimalMetaData:function(t){t?(n="application/json;odata=minimalmetadata",o=!1):(n="application/json;odata=verbose",o=!0)},createNewBatch:c}}}(jQuery);