webpackJsonp91507a74ed880bfb24f616888958a954([16],{4914:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(82),o=n(647),i=(n.n(o),n(262)),a=n(117),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),a=o.SPHttpClient.configurations.v1;n.SPFxContext.spHttpClient.get(t,a,{cache:"no-cache",headers:{"Cache-Control":"no-cache"}}).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 s=e.ListData.Row[0][".fileType"];i("Provided file type "+s+" 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>",c={RenderOptions:r.h.EnableMediaTAUrls|r.h.ContextInfo|r.h.ListData|r.h.ListSchema,ViewXml:s},l="";if(n.webServerRelativeUrl){var p=a.a.GetHostUrl(n.SPFxContext.pageContext.web.absoluteUrl);l=a.a.Combine(p,n.webServerRelativeUrl)}n.listService.renderListDataAsStream(e,c,l).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","doc","xlsx","xlsm","xltx","xltm","xlsb","xlam","xls","pptx","pptm","potx","potm","ppam","ppsx","ppsm","sldx","sldm","thmx","ppt"],e}();t.default=s}});