!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).WebOfficeSDK={})}(this,function(e){"use strict";var t=function(){return(t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]=0&&e._handleList.splice(n,1),window.removeEventListener("message",t,!1)},e.empty=function(){for(;e._handleList.length;)window.removeEventListener("message",e._handleList.shift(),!1)},e.parse=function(e){return"object"==typeof e?e:JSON.parse(e)},e._handleList=[],e}();var a,i,c,s=this;!function(e){e.unknown="unknown",e.spreadsheet="s",e.writer="w",e.presentation="p",e.pdf="f"}(a||(a={})),function(e){e.wps="w",e.et="s",e.presentation="p",e.pdf="f"}(i||(i={})),function(e){e.nomal="nomal",e.simple="simple"}(c||(c={}));var u,p,l=(u=0,function(){return++u}),f=function(e,t){if(!p){(p=document.createElement("iframe")).classList.add("web-office-iframe");var n={id:"office-iframe",src:e,scrolling:"no",frameborder:"0",allowfullscreen:"allowfullscreen",webkitallowfullscreen:"true",mozallowfullscreen:"true",style:"width: 100%; height: 100%;"};for(var r in t||((t=document.createElement("div")).classList.add("web-office-default-container"),function(e){var t=document.createElement("style");document.head.appendChild(t);var n=t.sheet;n.insertRule(e,n.cssRules.length)}(".web-office-default-container {position: absolute; padding: 0; margin: 0; width: 100vw; height: 100vh; left: 0; top: 0;}"),document.body.appendChild(t)),n)p.setAttribute(r,n[r]);t.appendChild(p),p.destroy=function(){p.parentNode.removeChild(p),p=null}}return p},d=function(e){f().contentWindow.postMessage(JSON.stringify(e),"*")},v=function(e){return new Promise(function(t){var n=l(),r=function(e){var a=o.parse(e.data);"wps.api.reply"===a.eventName&&a.msgId===n&&(t(a.data),o.remove(r))};o.add(r),d({eventName:"wps.jssdk.api",data:e,msgId:n})})},b=function(e,a,i,c){return n(s,void 0,void 0,function(){var s,u,p,f,v,b,h,w;return r(this,function(y){switch(y.label){case 0:return s=l(),f=new Promise(function(e,t){u=e,p=t}),v={},a.args?[4,m(a.args)]:[3,2];case 1:b=y.sent(),h=b[0],w=b[1],a.args=h,v=w,y.label=2;case 2:return function(e){var n=e[0],r=e[1];"function"==typeof(n=t({},n)).data&&(n.data=n.data());r(),d(n)}([{eventName:e,data:a,msgId:s},function(){var t=this,a=function(l){return n(t,void 0,void 0,function(){var t,n,f;return r(this,function(r){switch(r.label){case 0:return"api.callback"===(t=o.parse(l.data)).eventName&&t.callbackId&&v[t.callbackId]?[4,v[t.callbackId].apply(v,t.data.args)]:[3,2];case 1:n=r.sent(),d({eventName:"api.callback.reply",result:n,callbackId:t.callbackId}),r.label=2;case 2:return t.eventName===e+".reply"&&t.msgId===s&&(t.error?((f=new Error("")).stack=t.error+"\n"+i,c&&c(),p(f)):u(t.result),o.remove(a)),[2]}})})};return o.add(a),f}]),[2,f]}})})};function m(e){return n(this,void 0,void 0,function(){var t,n,o,a,i,c,s;return r(this,function(r){switch(r.label){case 0:t={},n=[],e=e.slice(0),r.label=1;case 1:return e.length?(o=void 0,[4,e.shift()]):[3,3];case 2:if(a=r.sent(),function(e){if(!e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}(o))for(i in o={},a)"function"==typeof(c=a[i])&&(s=l(),t[s]=c,c={callbackId:s}),o[i]=c;else"function"==typeof a?(s=l(),t[s]=a,o={callbackId:s}):o=a;return n.push(o),[3,1];case 3:return[2,[n,t]]}})})}var h=function(e,n){void 0===n&&(n=!0);var r=t({},e),o=r.headers,a=void 0===o?{}:o,i=r.subscriptions,s=void 0===i?{}:i,u=r.mode,p=void 0===u?c.nomal:u,l=a.backBtn,f=void 0===l?{}:l,d=a.shareBtn,v=void 0===d?{}:d,b=a.otherMenuBtn,m=void 0===b?{}:b,h=function(e,t){e.subscribe&&"function"==typeof e.subscribe&&(e.callback=t,s[t]=e.subscribe,n&&delete e.subscribe)};if(h(f,"wpsconfig_back_btn"),h(v,"wpsconfig_share_btn"),h(m,"wpsconfig_other_menu_btn"),m.items&&Array.isArray(m.items)){var w=[];m.items.forEach(function(e,t){switch(void 0===e&&(e={}),e.type){case"export_img":e.type=1,e.callback="export_img";break;case"export_pdf":e.type=1,e.callback="export_pdf";break;case"save_version":e.type=1,e.callback="save_version";break;case"about_wps":e.type=1,e.callback="about_wps";break;case"split_line":e.type=2;break;case"custom":e.type=3,h(e,"wpsconfig_other_menu_btn_"+t),w.push(e)}}),w.length&&(I||k)&&(m.items=w)}if(r.url=r.url||r.wpsUrl,(p===c.simple||r.commonOptions&&!1===r.commonOptions.isShowTopArea)&&r.url&&(r.url+="&simple&hidecmb"),r.debug&&r.url&&(r.url+="&debugger"),r.wordOptions&&(r.wpsOptions=r.wordOptions),r.excelOptions&&(r.etOptions=r.excelOptions),r.pptOptions&&(r.wppOptions=r.pptOptions),"object"==typeof s.print){var y="wpsconfig_print";"function"==typeof s.print.subscribe&&(s[y]=s.print.subscribe,r.print={callback:y},void 0!==s.print.custom&&(r.print.custom=s.print.custom)),delete s.print}"function"==typeof s.exportPdf&&(s[y="wpsconfig_export_pdf"]=s.exportPdf,r.exportPdf={callback:y},delete s.exportPdf);return t({},r,{subscriptions:s})},w=function(e){void 0===e&&(e="");var t="";if(!t&&e){var n=e.toLowerCase();-1!==n.indexOf("/office/s/")&&(t=a.spreadsheet),-1!==n.indexOf("/office/w/")&&(t=a.writer),-1!==n.indexOf("/office/p/")&&(t=a.presentation),-1!==n.indexOf("/office/f/")&&(t=a.pdf)}if(!t){var r=e.match(/[\?&]type=([a-z]+)/)||[];t=i[r[1]]||""}return t};function y(e,t){void 0===t&&(t=!0);var n=e.map(function(e){var t=e.attributes;if(!Array.isArray(t)){var n=[];for(var r in t)if(t.hasOwnProperty(r)){var o={name:r,value:t[r]};n.push(o)}e.attributes=n}return e});return t&&d({eventName:"setCommandBars",data:n}),n}var g,j=window.navigator.userAgent.toLowerCase(),I=/Android|webOS|iPhone|iPod|BlackBerry|iPad/i.test(j),k=function(){try{return-1!==window._parent.location.search.indexOf("from=wxminiprogram")}catch(e){return!1}}();function O(e){return e=e||Object.create(null),{on:function(t,n){(e[t]||(e[t]=[])).push(n)},off:function(t,n){e[t]&&e[t].splice(e[t].indexOf(n)>>>0,1)},emit:function(t,n){(e[t]||[]).slice().map(function(e){e(n)}),(e["*"]||[]).slice().map(function(e){e(t,n)})}}}!function(e){e[e.msoFalse=0]="msoFalse",e[e.msoTrue=-1]="msoTrue"}(g||(g={}));var _=0,x=new Set;function E(e){return++_,!e&&function(e){x.forEach(function(t){return t(e)})}(_),_}function P(e,i){var c,s=this,u=i.Events,p=i.Enum,l=i.Props,f=l[0],v=l[1],m={objId:_};switch(function e(n,r,o){r=r.slice(0);var a=function(){var a=r.shift();!a.alias&&~A.indexOf(a.prop)&&r.push(t({},a,{alias:a.prop+"Async"})),Object.defineProperty(n,a.alias||a.prop,{get:function(){var r=this,i=1===a.cache,c=i&&this["__"+a.prop+"CacheValue"];if(c)return c;var s=new Error(""),u=s.stack.split("\n").slice(2).join("\n"),p=E(i),l=function(){for(var e,r=[],i=0;i