webpackJsonp91507a74ed880bfb24f616888958a954([14],{4270:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(37),o=n(123),i=(n.n(o),n(89)),a=n(36),s=function(){function e(e,t){this.SPFxContext=e,this.webServerRelativeUrl=t,this.listService=new i.a}return e.prototype.Convert=function(e,t){var n=this;return new Promise(function(r,i){n.getListDataAsStream(e,t).then(function(e){if(n.isSupportedFileType(e)){var t=n.getConvertPDFUrl(e);n.SPFxContext.spHttpClient.get(t,o.SPHttpClient.configurations.v1).then(function(e){if(e.ok){var t=e.blob();r(t)}else e.json().then(function(e){var t=e.error.innererror?e.error.innererror.code:e.error.message;i("Failed to convert file to PDF. "+t)})}).catch(function(e){return i(e)})}else{var a=e.ListData.Row[0][".fileType"];i("Provided file type "+a+" is not supported.")}}).catch(function(e){return i(e)})})},e.prototype.getConvertPDFUrl=function(e){var t=e.ListSchema[".pdfConversionUrl"];if(!t)throw new Error("Cannot get PDF conversion URL format");var n=t.match(/\{(.*?)\}/g);if(!n)throw new Error("Cannot get PDF conversion URL. Data is unavailable");return n.forEach(function(n){var r=n,o=n.slice(1,-1),i=e.ListSchema[o],a=e.ListData.Row[0][o],s=i||a;if(!s)throw new Error("Cannot build PDF conversion URL");t=t.replace(r,s)}),t},e.prototype.getListDataAsStream=function(e,t){var n=this;return new Promise(function(o,i){var s="\n        <View Scope='RecursiveAll'>\n            <Query>\n                <Where>\n                    <Eq>\n                      <FieldRef Name='ID' />\n                      <Value Type=\"Counter\">"+t+"</Value>\n                    </Eq>\n                </Where>\n            </Query>\n            <RowLimit>1</RowLimit>\n        </View>",l={RenderOptions:r.h.EnableMediaTAUrls|r.h.ContextInfo|r.h.ListData|r.h.ListSchema,ViewXml:s},p="";if(n.webServerRelativeUrl){var c=a.a.GetHostUrl(n.SPFxContext.pageContext.web.absoluteUrl);p=a.a.Combine(c,n.webServerRelativeUrl)}n.listService.renderListDataAsStream(e,l,p).then(function(e){e&&e.ListSchema&&e.ListData&&e.ListData.Row?o(e):i("Cannot load PDF conversion data")}).catch(function(e){i("Cannot load PDF conversion data. "+e)})})},e.prototype.isSupportedFileType=function(t){var n=t.ListData.Row[0][".fileType"];return-1!=e.supportedFileTypes.indexOf(n)},e.supportedFileTypes=["docx","docm","dotx","dotm","xlsx","xlsm","xltx","xltm","xlsb","xlam","pptx","pptm","potx","potm","ppam","ppsx","ppsm","sldx","sldm","thmx"],e}();t.default=s}});