1234567891011121314151617181920212223242526272829303132 |
- /** Notice * This file contains works from many authors under various (but compatible) licenses. Please see core.txt for more information. **/
- (function(){(window.wpCoreControlsBundle=window.wpCoreControlsBundle||[]).push([[16],{439:function(ia,da,e){function ca(e,f,h){f.endsWith("/")||(f+="/");h=h||{};var n=h.disableWebsockets||!1;this.yY=h.singleServerMode||!1;null!=h.customQueryParameters&&Object(z.b)("wvsQueryParameters",h.customQueryParameters);f.endsWith("blackbox/")||(f+="blackbox/");this.po=h.uploadData||null;this.sy=h.uriData||null;this.FQ=h.cacheKey||null;this.wV=h.officeOptions||null;this.Bv=Object(r.a)(f,null,n);this.qf=f;this.zH=e;this.If=
- null;this.qk=ha();this.jn=ha();this.VA=!1;this.Ig=this.ke=this.De=this.pf=null;this.Nf=[];this.JB=[];this.cache={};this.timeStamp=0;this.mg=[];this.Sh=[];this.YH=null;this.sH=!1;this.GL=this.id=null;this.eK=this.RT=ea;this.SD=0;this.fJ=!1;this.rV=1;this.Vi={};this.Er=0;this.wt=y();this.Mq(!0)}function y(){var e={Es:{},Jb:[],pop:function(){var f=e.Jb.pop();e.Es[f.key]=void 0;return f},push:function(f,h){h={key:f,data:h};e.Jb.push(h);e.Es[f]=h.data},contains:function(f){return!!e.Es[f]},get:function(f){return e.Es[f]},
- set:function(f,h){e.Es[f]=h;e.Jb.forEach(function(h,n){h.key===f&&(e.Jb[n]=h)})},remove:function(f){e.Es[f]=void 0;e.Jb.forEach(function(h,n){h.key===f&&e.Jb.splice(n,1)})},length:function(){return e.Jb.length}};return e}function ha(){var e={promise:null,resolve:null,reject:null,state:0,result:null,request:null,Ts:function(){return 1===(e.state&1)},cda:function(){return 2===(e.state&2)},Qi:function(){return!e.cda()&&!e.Ts()},Eca:function(){return 4===(e.state&4)},QX:function(){e.state|=4}};e.promise=
- new Promise(function(f,h){e.resolve=function(){if(0===e.state||4===e.state)e.state=1,e.result=arguments[0],f.apply(null,arguments)};e.reject=function(){if(0===e.state||4===e.state)e.state=2,h.apply(null,arguments)}});return e}function ea(){return!1}function fa(e,f,h){if(!(f in ka))return!0;f=ka[f];for(var n=0;n<f.length;n++){var r=e;var w=f[n];var x=h;if(w.name in r){var y="",z=!1;r=r[w.name];switch(w.type){case "s":y="String";z=Object(ba.isString)(r);break;case "a":y="Array";z=Object(ba.isArray)(r);
- break;case "n":y="Number";z=Object(ba.isNumber)(r)&&Object(ba.isFinite)(r);break;case "o":y="Object",z=Object(ba.isObject)(r)&&!Object(ba.isArray)(r)}z||x.reject('Expected response field "'+w.name+'" to have type '+y);w=z}else x.reject('Response missing field "'+w.name+'"'),w=!1;if(!w)return!1}return!0}e.r(da);var ba=e(0);e.n(ba);var w=e(2);ia=e(50);var aa=e(31),r=e(457),h=e(94),n=e(371),f=e(113),z=e(40),x=e(164),ka={pages:[{name:"pages",type:"a"}],pdf:[{name:"url",type:"s"}],docmod:[{name:"url",
- type:"s"},{name:"rID",type:"s"}],health:[],tiles:[{name:"z",type:"n"},{name:"rID",type:"n"},{name:"tiles",type:"a"},{name:"size",type:"n"}],annots:[{name:"url",type:"s"},{name:"name",type:"s"}],image:[{name:"url",type:"s"},{name:"name",type:"s"},{name:"p",type:"n"}],text:[{name:"url",type:"s"},{name:"name",type:"s"},{name:"p",type:"n"}],ApString2Xod:[{name:"url",type:"s"},{name:"rID",type:"s"}]};ca.prototype=Object(ba.extend)(ca.prototype,{H6:function(){var e=this;return new Promise(function(f,h){var n=
- new XMLHttpRequest;n.open("GET",e.qf+"ck");n.withCredentials=e.wl();n.onreadystatechange=function(){n.readyState===XMLHttpRequest.DONE&&(200===n.status?f():h())};n.send()})},Xia:function(e,f){this.RT=e||ea;this.eK=f||ea},WQ:function(){var e=this;this.jn=ha();this.qk=ha();return this.Bv.OH().then(function(){e.VA=!1;e.id=null;e.sH=!1;return e.H6()})},rL:function(){this.RT();this.yJ();this.pf&&(this.pf.Qi()?this.kh(this.pf.request):this.pf.Ts()&&this.eK(this.pf.result.url,"pdf")&&(this.pf=null,this.oX()));
- this.Ig&&this.Ig.Qi()&&this.kh(this.Ig.request);this.De&&this.De.Qi()?this.kh(this.De.request):this.ke&&this.ke.Qi()&&this.CT(this.ke.request);var e;for(e=0;e<this.mg.length;e++)this.mg[e]&&this.mg[e]&&(this.mg[e].Qi()?this.kh(this.mg[e].request):this.mg[e].Ts()&&this.eK(this.mg[e].result.url,"image")&&(this.mg[e]=null,this.PD(Object(ba.uniqueId)(),e)));for(e=0;e<this.Sh.length;e++)this.Sh[e]&&this.Sh[e]&&this.Sh[e].Qi()&&!this.Sh[e].Eca()&&this.kh(this.Sh[e].request);for(e=0;e<this.Nf.length;e++)this.Nf[e]&&
- this.Nf[e].Qi()&&this.kh(this.Nf[e].request)},yJ:function(e){var h=this;this.VA||(this.timeStamp=Date.now(),this.Bv.qM(function(e){h.uea(e)},function(){return null},function(){return null},!0).then(function(){clearInterval(h.HD);h.HD=null},function(n){h.VA=!1;if(!h.HD){var r=0;h.sH=!0;h.GL=0;h.HD=setInterval(function(){2>r++?h.rL():(clearInterval(h.HD),e&&e.reject(f.a),Object(w.g)("WebViewerServer connection failed:"+n))},5E3)}}),this.VA=!0)},rla:function(){var e=this,f=createPromiseCapability();
- if(this.po){var h=new FormData;h.append("file",this.po.fileHandle,this.po.fileHandle.name);var n=this.po.loadCallback;var r="upload";var w=this.po.extension}else if(this.sy){h={uri:this.sy.uri,spa:this.sy.shareId};h=Object.keys(h).map(function(e){return e+"="+(h[e]?encodeURIComponent(h[e]):"")}).join("&");var y="application/x-www-form-urlencoded; charset=UTF-8";n=this.sy.loadCallback;r="url";w=this.sy.extension}else return Promise.resolve();var z=new XMLHttpRequest,ba=Object(aa.j)(e.qf,"AuxUpload");
- ba=Object(x.a)(ba)+"&type="+r+"&ext="+w;z.open("POST",ba);z.withCredentials=this.wl();y&&z.setRequestHeader("Content-Type",y);z.addEventListener("load",function(){if(z.readyState===z.DONE&&200===z.status){var h=JSON.parse(z.response);e.zH=h.uri;n(h);f.resolve(h)}});z.addEventListener("error",function(){f.reject(z.statusText+" "+JSON.stringify(z))});this.po&&null!=this.po.onProgress&&(z.upload.onprogress=function(f){e.po.onProgress(f)});z.send(h);return f.promise},pha:function(e){this.password=e||
- null;this.qk.Ts()||(this.qk=ha(),this.kh({t:"pages"}));return this.qk.promise},Fx:function(e){this.YH=e||null;this.qk.Ts()||(this.yJ(this.qk),this.kh({t:"pages"}));return this.qk.promise},Av:function(e){e=Object.assign(e,{uri:encodeURIComponent(this.zH)});this.YH&&(e.ext=this.YH);this.If&&(e.c=this.If);this.password&&(e.pswd=this.password);this.FQ&&(e.cacheKey=this.FQ);this.wV&&(e.officeOptions=this.wV);return e},Vha:function(){0<this.wt.length()&&10>=this.Er&&this.Wha(this.wt.pop().data)},T4:function(e){return 0<
- this.wt.length()&&this.wt.contains(e)?(this.wt.remove(e),!0):!1},kh:function(e){e=this.Av(e);this.Bv.send(e)},EX:function(e,f){10<this.Er?this.wt.push(e,f):(this.Er++,e=this.Av(f),this.Bv.send(e))},Wha:function(e){this.Er++;e=this.Av(e);this.Bv.send(e)},fl:function(e){return e},uea:function(e){var f=this,n=e.data,r=e.err,y=e.t;switch(y){case "upload":r?f.sla.reject(r):f.sla.resolve("Success");break;case "pages":r?f.qk.reject(r):fa(n,y,f.qk)&&f.qk.resolve(n);break;case "config":if(r)f.jn.reject(r);
- else if(fa(n,y,f.jn)){n.id&&(f.id=n.id);if(n.auth){var aa=Object(z.a)("wvsQueryParameters");aa.auth=n.auth;Object(z.b)("wvsQueryParameters",aa)}n.serverVersion&&(f.EZ=n.serverVersion,Object(w.h)("[WebViewer Server] server version: "+f.EZ));n.serverID?(f.SD=n.serverID===f.GL&&f.fJ?f.SD+1:0,f.GL=n.serverID):f.SD=0;f.fJ=!1;f.jn.resolve(n)}break;case "health":r?f.jn.reject(r):fa(n,y,f.jn)&&(n=n.unhealthy,f.yY&&n?Object(w.j)("Server failed health check. Single server mode ignoring check."):!f.Kna&&n&&
- 1>=f.SD&&(f.fJ=!0,f.WQ().then(function(){f.rL()},function(){f.rL()})));break;case "pdf":n.url=Object(x.a)(f.qf+"../"+encodeURI(n.url));r?f.pf.reject(r):fa(n,y,f.pf)&&f.pf.resolve(n);break;case "ApString2Xod":n.url=Object(x.a)(f.qf+"../data/"+encodeURI(n.url));r?f.Vi[n.rID].reject(r):fa(n,y,f.Vi[n.rID])&&f.Vi[n.rID].resolve(n);break;case "docmod":n.url=Object(x.a)(f.qf+"../"+encodeURI(n.url));r?f.Vi[n.rID].reject(r):fa(n,y,f.pf)&&f.Vi[n.rID].resolve(n);break;case "xod":if(r)this.De&&this.De.Qi()&&
- this.De.reject(r),this.ke&&this.ke.Qi()&&this.ke.reject(r);else if(n.notFound)n.noCreate||this.De&&this.De.Qi()&&this.De.resolve(n),this.ke&&this.ke.Qi()&&this.ke.resolve(n);else{n.url&&(n.url=Object(x.a)(f.qf+"../"+encodeURI(n.url)));if(!this.ke||this.ke.Ts())this.ke=ha(),this.ke.request={t:"xod",noCreate:!0};this.De||(this.De=ha(),this.De.request={t:"xod"});this.ke.resolve(n);this.De.resolve(n)}break;case "annots":if(r)f.Ig.reject(r);else if(fa(n,y,f.Ig)){f.Ig.QX();var ba=new XMLHttpRequest;aa=
- f.qf+"../"+encodeURI(n.url);var ca=n.hasAppearance?Object(x.a)(aa+".xodapp"):null;ba.open("GET",Object(x.a)(aa));ba.responseType="text";ba.withCredentials=this.wl();ba.addEventListener("load",function(){ba.readyState===ba.DONE&&200===ba.status&&f.Ig.resolve({RM:ba.response,xA:ca})});ba.addEventListener("error",function(){f.Ig.reject(ba.statusText+" "+JSON.stringify(ba))});ba.send()}break;case "image":f.Er--;var ea=this.mg[n.p];r?ea.promise.reject(r):fa(n,y,ea)&&(ea.result=n,ea.result.url=Object(x.a)(f.qf+
- "../"+encodeURI(ea.result.url)),ea.resolve(ea.result));break;case "tiles":f.Er--;ea=n.rID;aa=this.Nf[ea];this.Nf[ea]=null;this.JB.push(ea);if(r)aa.reject(r);else if(fa(n,y,aa)){for(r=0;r<n.tiles.length;r++)n.tiles[r]=Object(x.a)(f.qf+"../"+encodeURI(n.tiles[r]));aa.resolve(n)}break;case "text":ea=this.Sh[n.p];if(r)ea.reject(r);else if(fa(n,y,ea)){ea.QX();var da=new XMLHttpRequest;n=Object(x.a)(f.qf+"../"+encodeURI(n.url));da.open("GET",n);da.withCredentials=this.wl();da.addEventListener("load",function(){da.readyState===
- da.DONE&&200===da.status&&(ea.result=JSON.parse(da.response),ea.resolve(ea.result))});da.addEventListener("error",function(e){ea.reject(da.statusText+" "+JSON.stringify(e))});da.send()}break;case "progress":"loading"===n.t&&f.trigger(h.a.Events.DOCUMENT_LOADING_PROGRESS,[n.bytes,n.total])}this.Vha();!y&&e.echo&&e&&"apstring2xod"===e.echo.t&&(e=e.echo.reqID)&&(2<=parseInt(f.EZ,10)?f.Vi[e].reject("Message unhandled by server"):f.Vi[e].reject())},FS:function(){this.yJ(this.jn);return this.jn.promise},
- n$:function(e){for(var f=this,h=new XMLHttpRequest,n=Object(x.a)(this.qf+"aul")+"&id="+this.id,r=new FormData,w={},y=0;y<e.body.length;y++){var z=e.body[y];w[z.id]=z.JG.w+";"+z.JG.h;r.append(z.id,z.JG.dataString)}e={t:"apstring2xod",reqID:this.rV++,parts:w};var aa=this.Av(e);r.append("msg",JSON.stringify(aa));f.Vi[aa.reqID]=ha();h.open("POST",n);h.withCredentials=f.wl;n=new Promise(function(e,f){h.onreadystatechange=function(){4===h.readyState&&(200===h.status?e():f("An error occurred while sending down appearance strings to the server"))}});
- h.send(r);return n.then(function(){return f.Vi[aa.reqID].promise})},m$:function(){this.Ig||(this.Ig=ha(),this.Ig.request={t:"annots"},this.kh(this.Ig.request));return this.Ig.promise},PD:function(e,f){this.mg[f]||(this.mg[f]=ha(),this.mg[f].request={t:"image",p:f},this.EX(e,this.mg[f].request));return this.mg[f].promise},qha:function(e){this.Sh[e]||(this.Sh[e]=ha(),this.Sh[e].request={t:"text",p:e},this.kh(this.Sh[e].request));return this.Sh[e].promise},rha:function(e,f,h,n,r){var w=this.Nf.length;
- this.JB.length&&(w=this.JB.pop());this.Nf[w]=ha();this.Nf[w].request={t:"tiles",p:f,z:h,r:n,size:r,rID:w};this.EX(e,this.Nf[w].request);return this.Nf[w].promise},oX:function(){this.pf||(this.pf=ha(),this.pf.request={t:"pdf"},this.sH?this.pf.resolve({url:this.zH}):this.kh(this.pf.request));return this.pf.promise},bT:function(e){var f=this,h=new XMLHttpRequest,n=Object(x.a)(this.qf+"aul")+"&id="+this.id,r=new FormData,w={};e.annots&&(w.annots="xfdf");e.watermark&&(w.watermark="png");e.redactions&&
- (w.redactions="redact");w={t:"docmod",reqID:this.rV++,parts:w};e.print&&(w.print=!0);var y=this.Av(w);r.append("msg",JSON.stringify(y));return Promise.all([e.annots,e.watermark,e.redactions].map(function(e){return Promise.resolve(e)})).then(function(e){var w=e[0],x=e[1];e=e[2];w&&r.append("annots",w);x&&r.append("watermark",x);e&&r.append("redactions",e);f.Vi[y.reqID]=ha();h.open("POST",n);h.withCredentials=f.wl;w=new Promise(function(e,f){h.onreadystatechange=function(){4===h.readyState&&(200===
- h.status?e():f("An error occurred while sending down annotation data to the server"))}});h.send(r);return w.then(function(){return f.Vi[y.reqID].promise})})},CT:function(){this.ke||(this.ke=ha(),this.ke.request={t:"xod",noCreate:!0},this.kh(this.ke.request));return this.ke.promise},sha:function(){this.De||(this.De=ha(),this.De.request={t:"xod"},this.kh(this.De.request));return this.De.promise},Zn:function(){return!0},request:function(){},KW:function(){},abort:function(){for(var e=0;e<this.Nf.length;e++)this.Nf[e]&&
- (this.Nf[e].resolve(null),this.Nf[e]=null,this.JB.push(e));this.close()},eE:function(e){this.If=this.If||{};this.If.headers=e},ioa:function(){return this.If?Object(ba.omit)(this.If.headers,["Cookie","cookie"]):null},Mq:function(e){this.If=this.If||{};this.If.internal=this.If.internal||{};this.If.internal.withCredentials=e},wl:function(){return this.If&&this.If.internal?this.If.internal.withCredentials:null},getFileData:function(){return Promise.reject()}});Object(ia.a)(ca);Object(n.a)(ca);Object(n.b)(ca);
- da["default"]=ca},457:function(ia,da,e){function ca(e,w,aa){function r(e,f){function h(e){r().then(function(f){da&&!ia?setTimeout(function(){h(e)},1):f.send(JSON.stringify(e))})}function n(e,f,n,r){var x=window.createPromiseCapability(),z=!1,ja=x;aa=e;ba=f;ca=n;y=null;r&&(e=Object(ea.a)("wvsQueryParameters"),e.bcid=Object(ha.k)(8),Object(ea.b)("wvsQueryParameters",e));try{e=ya?wa+"/"+ya:wa+"/ws";e=Object(fa.a)(e);var ma=new WebSocket(e);ma.onopen=function(){x.resolve();z=!0;x=null;da=!1;w.resolve(ma);
- ba&&ba()};ma.onerror=function(e){da=ia=!0;x&&x.reject(e);y&&y.reject()};ma.onclose=function(){w=window.createPromiseCapability();da=!0;y||(y=window.createPromiseCapability());y.resolve();ca&&ca();aa&&z&&aa({t:"health",data:{unhealthy:!0,isDead:!0}})};ma.onmessage=function(e){e&&e.data&&(e=JSON.parse(e.data),e.hb?h({hb:!0}):e.end?close():aa(e))}}catch(Fa){x.reject(Fa),x=null}return ja.promise}function r(){da&&aa&&n(aa);return w.promise}var w=window.createPromiseCapability(),y=null,aa,ba,ca=null,da=
- !1,ia=!1,ya=f,wa=function(e){var f=e.indexOf("://"),h="ws://";0>f?f=0:(5===f&&(h="wss://"),f+=3);var n=e.lastIndexOf("/");0>n&&(n=e.length);return h+e.slice(f,n)}(e);return{send:h,qM:n,OH:function(){return y?y.promise:r().then(function(e){y=window.createPromiseCapability();aa=null;e.close();return y.promise})}}}function h(e){var f=e.lastIndexOf("/");0>f&&(f=e.length);return e.slice(0,f)}return window.WebSocket&&!aa?r(e,w):function(e,f){function n(e){(da?da.promise:Promise.resolve(ea)).then(function(f){var h=
- new XMLHttpRequest,n=ca?ba+"/"+ca+"pf":ba+"/pf";n=Object(fa.a)(n)+"&id="+f;f=new FormData;f.append("data",JSON.stringify(e));h.open("POST",n);h.withCredentials=!0;h.send(f)})}function r(){ea=0;da||(da=window.createPromiseCapability())}function w(){aa=new XMLHttpRequest;var e=ba+"/pf";e+=0!==ea?"?id="+ea+"&uc="+wa:"?uc="+wa;wa++;aa.open("GET",e,!0);aa.withCredentials=!0;aa.setRequestHeader("Cache-Control","no-cache");aa.setRequestHeader("X-Requested-With","XMLHttpRequest");var f=aa,h=!1;aa.onreadystatechange=
- function(){a:if(3<=f.readyState&&!h){try{var e=f.responseText.length}catch(Ca){Object(y.h)("caught exception");break a}if(0<e)try{var x=f.responseText.split("\n");for(x[x.length-1]&&x.pop();0<x.length&&3>x[x.length-1].length;)"]"===x.pop()&&r();0<x.length&&3>x[0].length&&x.shift();for(e=0;e<x.length;++e)x[e].endsWith(",")&&(x[e]=x[e].substr(0,x[e].length-1));0===ea&&0<x.length&&(ea=JSON.parse(x.shift()).id,e=da,da=null,e.resolve(ea));var z;for(e=0;e<x.length;++e)(z=JSON.parse(x[e]))&&z.end?close():
- z&&z.hb&&z.id===ea?n({hb:!0}):ya(z)}catch(Ca){}ha||(h=!0,w())}};aa.send()}var aa,ba=h(e),ca=f,ea=0,da=window.createPromiseCapability(),ha=!1,ia=null,ya=null,wa=0;return{send:n,qM:function(e,f,h){ya=e;ia=h;ha=!1;r();w();f&&f();return Promise.resolve()},OH:function(){r();ya=null;ha=!0;ia&&ia();aa.abort();return Promise.resolve()}}}(e,w)}e.d(da,"a",function(){return ca});var y=e(2),ha=e(31),ea=e(40),fa=e(164)}}]);}).call(this || window)
|